Warning:
Massive Wall of Text and Pictures!!!
If you Have problems with my guide use this one SectorSeven's Guide
Ok since Gastric's Old guide (Link) doesnt work on newer versions of Ascent (atleast not for me) I decided to make a new guide for this.
In this example I will use the PvPTokenExchanger (I think its Zymeth's. Here is the link: Link)
Now we will do this step by step.
You will need:
Visual Studios 2008 (in this guide 2008 ) : Download
An already compiled version of Ascent (compiled by yourself!).
Here is a guide for it: Link
The ascent source (download via SVN look into the How to compile Ascent Guide)
Lets start.
Compiling a released Source Code
1. Go into your ascent folder and browse to .../branches/3_8_Stable/src/scripts/src
and make a new folder, in this example 'PvPToken'.
2. Make a new notepad document.
Copy and paste this into it:
Code:
/*
PvP Token Plug-in, this plug in will add a token of your choice to the killer of the opposite faction.
Copyright (C) 2008 Plexor/zxc
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Credits to NCDB for original Source
Credits to me for modifying it
*/
#include "StdAfx.h"
#include "Setup.h"
void onPvpKill(Player* plr, Player* victim)
{
int itemID;
uint32 tokenItem = Config.MainConfig.GetInt("NCDB", "PvPTokenID", &itemID);
sLog.outColor(TGREEN,"n[NCDB] (%u)%s killed (%u)%s", plr->getLevel(), plr->GetName(), victim->getLevel(), victim->GetName());
char onkill[1024];
snprintf((char*)onkill, 1024, "[PVP]%s has killed %s", plr->GetName(), victim->GetName());
sWorld.SendWorldWideScreenText(onkill);
if(plr->getLevel() >= 70 && victim->getLevel() >= 70 && plr->GetTeam() != victim->GetTeam())
{
sLog.outColor(TGREEN,"n[NCDB] Adding token to %s", plr->GetName());
sLog.outColor(TNORMAL,"n");
ItemPrototype *proto = ItemPrototypeStorage.LookupEntry(itemID);
SlotResult slotresult;
slotresult = plr->GetItemInterface()->FindFreeInventorySlot(proto);
if(!slotresult.Result)
{
plr->GetItemInterface()->BuildInventoryChangeError(NULL, NULL, INV_ERR_INVENTORY_FULL);
}
else
{
Item *itm = objmgr.CreateItem(itemID, plr);
itm->SetUInt32Value(ITEM_FIELD_STACK_COUNT, 1);
plr->GetItemInterface()->SafeAddItem(itm,slotresult.ContainerSlot, slotresult.Slot);
plr->SaveToDB(false);
}
}
else
{
sLog.outColor(TGREEN,"n[NCDB] Not adding token since they both are not level 70");
sLog.outColor(TNORMAL,"n");
}
}
void SetupPvPToken(ScriptMgr * mgr)
{
mgr->register_hook(SERVER_HOOK_EVENT_ON_KILL_PLAYER, onPvpKill);
}
3. Now save it as PvPToken.cpp file. Remember: Go to Save as and change the .txt file to All Files and then name/save it.
4. Open up another NotePad (You can close the other one or just use that) and copy&pasta that into it:
Code:
#include "StdAfx.h"
#include "Setup.h"
extern "C" SCRIPT_DECL uint32 _exp_get_script_type()
{
return SCRIPT_TYPE_MISC;
}
extern "C" SCRIPT_DECL void _exp_script_register(ScriptMgr* mgr)
{
SetupPvPToken(mgr);
}
#ifdef WIN32
BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved )
{
return TRUE;
}
#endif
5. Now save this one as Setup.cpp in our PvPToken folder.
Now we are going to create the third file
6. Open up NotePad and copy&pasta this into it:
Code:
#ifndef PvPToken_SETUP_H
#define PvPToken_SETUP_H
void SetupPvPToken(ScriptMgr * mgr);
#endif
7. Save that as Setup.h in the PvPToken Folder.
The PvPToken Folder should now look like this:
8. Ok now browse to *YourAscentSourceFolder*/branches/3_8_Stable/src/scripts/projects/
and create another NotePad.
9. Here comes another Copy - Paste:
Code:
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="PvPToken"
ProjectGUID="{495CDEBE-E216-485B-B2F1-2FC0BD9DAE7D}"
RootNamespace="PvPToken"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="......bindebugscript_bin"
IntermediateDirectory="2003_int_debug_PvPToken"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults/UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/MP"
Optimization="0"
AdditionalIncludeDirectories="....ascent-shared;....ascent-world;......depinclude;......depsrc"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SCRIPTLIB"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ascent-world.lib"
OutputFile="../../../bin/debug/script_bin/PvPToken.dll"
LinkIncremental="2"
AdditionalLibraryDirectories="......bindebug"
GenerateDebugInformation="true"
ProgramDatabaseFile="../../../bin/debug/script_bin/PvPToken.pdb"
SubSystem="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary="$(OutDir)/PvPToken.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMa****ol"
/>
<Tool
Name="VCBscMa****ol"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="......binreleasescript_bin"
IntermediateDirectory="2003_int_release_PvPToken"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults/UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
ExcludedFromBuild="true"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="....ascent-shared;....ascent-world;......depinclude;......depsrc"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SCRIPTLIB"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ascent-world.lib"
OutputFile="../../../bin/release/script_bin/PvPToken.dll"
LinkIncremental="1"
AdditionalLibraryDirectories="......binrelease"
GenerateDebugInformation="true"
ProgramDatabaseFile="../../../bin/release/script_bin/PvPToken.pdb"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary="$(OutDir)/PvPToken.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMa****ol"
/>
<Tool
Name="VCBscMa****ol"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Main Resources"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..src/PvPToken/Setup.cpp"
>
</File>
<File
RelativePath="..src/PvPToken/Setup.h"
>
</File>
</Filter>
<Filter
Name="Scripts"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..src/PvPToken/PvPToken.cpp"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
10. Save it as PvPToken.vcproj
Remember: The ending .vcproj is important!
You should have a file like this now in the projects folder:
11. Now open up the PvPToken.vcproj with Visual Studios C++ 2008.
If you use that app for the first time maybe some windows will pop up.
Just click them away (Cant remember if they are important )
It should now look similar to this:
12. Go to the tab Build and click on Configuration Manager.
A window should come up:
Be sure that 'Active solution configuration' is set to Release!
13. If it is click close. If not, set it to Release and then click close.
14. Now press F7 or under tab Build click 'Build Solution' or rightclick the project
and choose 'Build Solution'. You can choose what you want it doesnt matter.
Now the script will get compiled, this can take a while. :P
After it is build it should look like this:
15. Now you can find your fresh build dll in *YourAscentSourceFolder*/branches/3_8_Stable/bin/Release/script_bin/
There are 4 files with PvPToken in it but you just need the .dll
Gratulations you compiled your own DLL File :wave:
Compiling a custom DLL
Ok but some of you made an own code and want to make custom dlls.
Thats no problem. Remember the 3 Files: PvPToken.vcproj, Setup.h and Setup.cpp? That are the one you will need to change (and ofc you have to have an code ).
In the /Scripts/src folder just make a new folder like... eeehm... dunno... maybe WarpNPC. Copy your custom code as a .cpp into it and setup.h and setup.cpp should look like this:
Setup.h:
Code:
#ifndef PvPToken_SETUP_H
#define PvPToken_SETUP_H
void SetupPvPToken(ScriptMgr * mgr);
#endif
Setup.cpp:
Code:
#include "StdAfx.h"
#include "Setup.h"
extern "C" SCRIPT_DECL uint32 _exp_get_script_type()
{
return SCRIPT_TYPE_MISC;
}
extern "C" SCRIPT_DECL void _exp_script_register(ScriptMgr* mgr)
{
SetupPvPToken(mgr);
}
#ifdef WIN32
BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved )
{
return TRUE;
}
#endif
Just change everything marked red to (in this example) WarpNpc and save it into the WarpNpc Folder.
Same goes with the PvPToken.vcproj in the Scripts/projects folder:
PvPToken.vcproj
Code:
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="PvPToken"
ProjectGUID="{495CDEBE-E216-485B-B2F1-2FC0BD9DAE7D}"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="......bindebugscript_bin"
IntermediateDirectory="2003_int_debug_PvPToken"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults/UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/MP"
Optimization="0"
AdditionalIncludeDirectories="....ascent-shared;....ascent-world;......depinclude;......depsrc"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SCRIPTLIB"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ascent-world.lib"
OutputFile="../../../bin/debug/script_bin/PvPToken.dll"
LinkIncremental="2"
AdditionalLibraryDirectories="......bindebug"
GenerateDebugInformation="true"
ProgramDatabaseFile="../../../bin/debug/script_bin/PvPToken.pdb"
SubSystem="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary="$(OutDir)/PvPToken.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMa****ol"
/>
<Tool
Name="VCBscMa****ol"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="......binreleasescript_bin"
IntermediateDirectory="2003_int_release_PvPToken"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults/UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
ExcludedFromBuild="true"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="....ascent-shared;....ascent-world;......depinclude;......depsrc"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SCRIPTLIB"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ascent-world.lib"
OutputFile="../../../bin/release/script_bin/PvPToken.dll"
LinkIncremental="1"
AdditionalLibraryDirectories="......binrelease"
GenerateDebugInformation="true"
ProgramDatabaseFile="../../../bin/release/script_bin/PvPToken.pdb"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary="$(OutDir)/PvPToken.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMa****ol"
/>
<Tool
Name="VCBscMa****ol"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Main Resources"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..srcPvPTokenSetup.cpp"
>
</File>
<File
RelativePath="..srcPvPTokenSetup.h"
>
</File>
</Filter>
<Filter
Name="Scripts"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..srcPvPTokenPvPToken.cpp"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
It is important to change RelativePath="..src/PvPToken/Setup.h" to RelativePath="..src/WarpNPC/Setup.h" !!!
Change all red 'PvPToken' (I hope I got all ) to WarpNpc.
After that just follow the instructions from steps 11 to 15
You have to put the new DLL File into your script_bin folder in order to work.
Remember Rule #10 of the Emulation Section:
If you release a custom .dll File you have to release the source too!
I hope it was understandable for you all and if you have questions: Just ask!