PDA

View Full Version : [Tut] How to compile a .DLL



StickyIcky
25-07-08, 12:54 AM
Made by SectorSeven
I made a video and text guide. I suggest you use them together, and refer to the video if you have questions.

Please download these files or make sure you have them before you begin:
Microsoft Visual C++ v9: http://www.microsoft.com/express/vc/

Video made by me:
http://youtube.com/watch?v=PfpLFZWNoww

Step 1: Getting the Source
The source is the .cpp where the actions and behavior of the script is defined. For this example, we will use GastricPenguin's GlobalNPC script. Here is the link to the pastebin: http://pastebin.ca/GPYPNyzR. The password is "gastric". Now that we have the source code, we need to save it as the correct file extension. Copy all the script from the pastebin page, and open up Notepad or Wordpad and paste it in. Go to File, Save As, name the file "GlobalNPC.cpp" and make sure you have "Save as type:" set to "All Files". Click the save button and close out.

Step 2: Setting Up Source Files
Create a folder on your Desktop called "GlobalNPC", exactly like that. Drag the GlobalNPC.cpp file into this folder. Now, open up the GlobalNPC.cpp file. It should open in Microsoft Visual C++ now, not Notepad or Wordpad. When we do this, we are looking for one thing, the word after the "void" statement in blue. As we look through the script, we can see that the only void statement is "void GlobalNPC". But wait, there is one that says "void SetupGlobalNPC", we will ignore this statement because it has Setup infront of it. Sometimes you will have more than one "void" statement that you will use for each script. Also, this line:
mgr->register_gossip_script(112230, gs);
is giving the NPC ID, you can change it to anything you want. However, you must do this prior to compiling the DLL.

Now that we have the statements of the script, we need to actually do the Setup files. Now, we need to get the latest "format" for our setup files. You must have Ascent compiled prior to doing this, if you don't, please stop here and compile Ascent. If you don't know how, then search for my guide on it. Browse to the "\trunk\src\scripts\src\GossipScripts" folder. Copy the Setup files in that folder to the GlobalNPC folder. You do NOT need the Makefile.am with the method that we're using to compile. We just need the Setup.cpp and Setup.h files. Open the Setup.cpp file from the GlobalNPC folder. Delete the


SetupInnkeepers(mgr);
SetupBattlemaster(mgr);
SetupGuardGossip(mgr);


Now, we will use our void statement we got earlier "GlobalNPC". So type this line inbetween the brackets:


SetupGlobalNPC(mgr);

We will always have the portions in red there, just replace the portion in blue with your "void" statement you got earlier. Save the file and close out.

Now open up the Setup.h file. Delete the:


void SetupInnkeepers(ScriptMgr * mgr);
void SetupGuardGossip(ScriptMgr * mgr);
void SetupBattlemaster(ScriptMgr * mgr);


Replace this with the void statement. Once again, the portions in red will always need to be there, and the portion in blue is what you change, or the void statement.


void SetupGlobalNPC(ScriptMgr * mgr);

Save and close out of Setup.h. Your more than halfway there!

Step 3: Setting Up Your Project File
This is an easy thing to do, just don't make it hard. Browse in your Ascent directory to: \trunk\src\scripts\projects. Now copy the "GossipScripts2008" file to your Desktop. Right click it, and go to "Open With". We are going to want to open it with Notepad or Wordpad. Now go to Edit, Replace (CTRL H). In the "Find What:" field, enter "GossipScripts". For the "Replace With:" field, we are going to enter what the name of our source file (.cpp) is, which is GlobalNPC. Hit "Replace All" and close out of that window. Now scroll down to the bottom until you see a line that has Name:"Main Recources" there. Make sure that the directories below it are set correctly in the format:


srcScriptNameSetup.cpp or .h

Now, look just below that to the Name:"Scripts" line. Delete these two sections of code:


<File
RelativePath="..srcGossip_Innkeepers.cpp"
>
</File>
<File
RelativePath="..srcGuardGossip.cpp"
>
</File>

And make sure its in the correct format.
src\ScriptNameScriptName.cpp
Make nessicary changes and then do: File, Save As, File Name: GlobalNPC.vcproj and "Save as type:" to all files. Click Save and close out.


Step 4: Compiling the DLL
Now, browse to "\trunk\src\scripts\src" and copy your GlobalNPC folder to this location. Next, browse to "\trunk\src\scripts\projects". Copy your GlobalNPC.vcproj here. Now double click GlobalNPC.vcproj and set the build to Release. If you really have compiled Ascent before, then you know what I'm talking about. Go to Build, Build Solution or hit F7. It may ask if you want to save a file, hit save, and the compiling should begin. You should either get a "1 succeeded" message or a "1 up-to-date" message.

You have just successfully compiled a DLL! It should be in your \bin\Release\script_bin\ folder.This should take about 3-4 minutes each time after you get the hang of it, so it will become much easier. If you liked my guide or video please leave comments and/or suggestions!

Apple
25-07-08, 12:55 AM
nice Guide , thanks for sharing and giving right credits +3 Rep