Emulator Server Discussion World of Warcraft Emulator Server general chat . [NO Questions here]
07-09-2009
Emulation Moderator
Legendary User Join Date: Feb 2007
Location: EST
Posts: 2,285
Nominated 3 Times in 1 Post
Reputation: 975
Points: 25,812, Level: 23
Level up: 19%, 1,388 Points needed
[C++] Script References If you want to start scripting but don't know where to begin, take a look at the following scripts and work your way up. Just a heads up, these scripts are just the barebone functions and classes, you need to fill in the details and do whatever you wish. These scripts are written for Aspire using shared pointers, they are relatively easy to convert to an ArcEmu format. Anything highlighted in yellow should be edited accordingly. Gossip Scripts Good for making teleporters, scripted events, scripted items, etc. Code:
class ITEMSCRIPT : public GossipScript
{
public:
void GossipHello(ObjectPointer pObject, PlayerPointer Plr, bool AutoSend)
{
//STUFF
}
void GossipSelectOption(ObjectPointer pObject, PlayerPointer Plr, uint32 Id, uint32 IntId, const char * Code)
{
switch(IntId)
{
case 0:
GossipHello(pObject, Plr, true);
break;
}
}
void GossipEnd(ObjectPointer pObject, PlayerPointer Plr)
{
GossipScript::GossipEnd(pObject, Plr);
}
void Destroy()
{
delete this;
}
};
void Setup(ScriptMgr * mgr)
{
GossipScript * itr = (GossipScript*) new ITEMSCRIPT ();
mgr->register_gossip_script(ENTRY_ID , itr); //NPC Gossip
mgr->register_go_gossip_script(ENTRY_ID , itr); //GameObject Gossip
mgr->register_item_gossip_script(ENTRY_ID , itr); //Item Gossip
}
GameObject Scripts Script an object to spawn some monsters when activated. Code:
class OBJECTSCRIPT : public GameObjectAIScript
{
public:
OBJECTSCRIPT (GameObjectPointer goinstance) : GameObjectAIScript( goinstance ) {}
GameObjectAIScript *Create(GameObjectPointer GO)
{
return new OBJECTSCRIPT (GO);
}
void OnActivate(PlayerPointer pPlayer)
{
//STUFF
}
void OnCreate()
{
//STUFF
}
void OnSpawn()
{
//STUFF
}
void OnDespawn()
{
//STUFF
}
void AIUpdate()
{
//STUFF
}
};
void Setup(ScriptMgr * mgr)
{
mgr->register_gameobject_script(ENTRYID , &OBJECTSCRIPT ::Create);
}
Instance Scripts This one I like very much. Completely customize an instance or map using this framework. Code:
class INSTANCEAI : public InstanceScript
{
public:
ADD_INSTANCE_FACTORY_FUNCTION(INSTANCEAI );
INSTANCEAI (MapMgrPointer pMapMgr) : InstanceScript(pMapMgr) {}
void OnLoad()
{
//STUFF
}
void OnPlayerDeath(PlayerPointer pVictim, UnitPointer pKiller)
{
//STUFF
}
void OnPlayerEnter(PlayerPointer pPlayer)
{
//STUFF
}
void OnAreaTrigger(PlayerPointer pPlayer, uint32 pAreaId)
{
//STUFF
}
void OnZoneChange(PlayerPointer pPlayer, uint32 pNewZone, uint32 pOldZone)
{
//STUFF
}
void OnCreatureDeath(CreaturePointer pVictim, UnitPointer pKiller)
{
//STUFF
}
void OnGameObjectActivate(GameObjectPointer pGameObject, PlayerPointer pPlayer)
{
//STUFF
}
};
void Setup(ScriptMgr * mgr)
{
mgr->register_instance_script(MAP_ID , &INSTANCEAI ::Create);
}
Quest Scripts More fun quest scripts, better than using the hooks. Code:
class QUESTAI : public QuestScript
{
public:
void OnQuestStart(PlayerPointer mTarget, QuestLogEntry *qle)
{
//STUFF
}
void OnQuestComplete(PlayerPointer mTarget, QuestLogEntry *qle)
{
//STUFF
}
void OnQuestCancel(PlayerPointer mTarget)
{
//STUFF
}
void OnGameObjectActivate(uint32 entry, PlayerPointer mTarget, QuestLogEntry *qle)
{
//STUFF
}
void OnCreatureKill(uint32 entry, PlayerPointer mTarget, QuestLogEntry *qle)
{
//STUFF
}
void OnExploreArea(uint32 areaId, PlayerPointer mTarget, QuestLogEntry *qle)
{
//STUFF
}
void OnPlayerItemPickup(uint32 itemId, uint32 totalCount, PlayerPointer mTarget, QuestLogEntry *qle)
{
//STUFF
}
};
void Setup(ScriptMgr * mgr)
{
QuestScript * qs = (QuestScript*) new QUESTAI ();
mgr->register_quest_script(ENTRY_ID , qs);
}
Creature Scripts
Make a better and more entertaining bossfight via a script. Code:
class CREATURESCRIPT : public CreatureAIScript
{
public:
ADD_CREATURE_FACTORY_FUNCTION(CREATURESCRIPT );
CREATURESCRIPT (CreaturePointer pCreature) : CreatureAIScript(pCreature) {}
void OnCombatStart(UnitPointer mTarget)
{
//STUFF
}
void OnCombatStop(UnitPointer mTarget)
{
//STUFF
}
void OnDamageTaken(UnitPointer mAttacker, float fAmount)
{
//STUFF
}
void OnCastSpell(uint32 iSpellId)
{
//STUFF
}
void OnTargetParried(UnitPointer mTarget)
{
//STUFF
}
void OnTargetDodged(UnitPointer mTarget)
{
//STUFF
}
void OnTargetBlocked(UnitPointer mTarget, int32 iAmount)
{
//STUFF
}
void OnTargetCritHit(UnitPointer mTarget, float fAmount)
{
//STUFF
}
void OnTargetDied(UnitPointer mTarget)
{
//STUFF
}
void OnParried(UnitPointer mTarget)
{
//STUFF
}
void OnDodged(UnitPointer mTarget)
{
//STUFF
}
void OnBlocked(UnitPointer mTarget, int32 iAmount)
{
//STUFF
}
void OnCritHit(UnitPointer mTarget, float fAmount)
{
//STUFF
}
void OnHit(UnitPointer mTarget, float fAmount)
{
//STUFF
}
void OnAssistTargetDied(UnitPointer mAssistTarget)
{
//STUFF
}
void OnFear(UnitPointer mFeared, uint32 iSpellId)
{
//STUFF
}
void OnFlee(UnitPointer mFlee)
{
//STUFF
}
void OnDied(UnitPointer mKiller)
{
//STUFF
}
void AIUpdate()
{
//STUFF
}
};
void Setup(ScriptMgr * mgr)
{
mgr->register_creature_script(ENTRY_ID , &CREATURESCRIPT ::Create);
}
Setup.cpp Needed for compiling your script. Code:
#include "StdAfx.h"
#include "Setup.h"
#define SKIP_ALLOCATOR_SHARING 1
#include <ScriptSetup.h>
extern "C" SCRIPT_DECL uint32 _exp_get_script_type()
{
return SCRIPT_TYPE_MISC;
}
extern "C" SCRIPT_DECL void _exp_script_register(ScriptMgr* mgr)
{
Setup(mgr);
}
#ifdef WIN32
BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved )
{
return TRUE;
}
#endif
Setup.h Goes along with Setup.cpp Code:
#ifndef CUSTOMSCRIPTS_H
#define CUSTOMSCRIPTS_H
void Setup(ScriptMgr * mgr);
#endif
Last edited by Gastricpenguin; 07-10-2009 at 12:33 AM .
Donate to remove ads, get your "DONATOR title, and get access to the MMOwned community's elite Shoutbawx.
07-09-2009
Emulation Moderator
Legendary User Join Date: Feb 2007
Location: EST
Posts: 2,285
Nominated 3 Times in 1 Post
Reputation: 975
Points: 25,812, Level: 23
Level up: 19%, 1,388 Points needed
<<Reserved for ArcEmu equivalents>>
07-09-2009
Contributor
Join Date: Sep 2007
Location: Canada
Posts: 1,067
Reputation: 147
Level up: 51%, 444 Points needed
Pretty useful. GJ Gast... Dr. Robotnik. +rep.
07-09-2009
Sergeant Major
Join Date: Apr 2007
Posts: 165
Reputation: 26
Level up: 55%, 228 Points needed
Great post +rep
07-09-2009
Elite User
Join Date: Jan 2008
Posts: 2,124
Reputation: 349
Level up: 46%, 600 Points needed
I think you should check
[Only registered and activated users can see links. ] before you call your snippet collection a 'framework'
Again, a reference is not a bad thing
07-09-2009
Emulation Moderator
Legendary User Join Date: Feb 2007
Location: EST
Posts: 2,285
Nominated 3 Times in 1 Post
Reputation: 975
Points: 25,812, Level: 23
Level up: 19%, 1,388 Points needed
Thread title changed, thanks for the info Spidey.
07-12-2009
Knight-Lieutenant
Join Date: Feb 2009
Location: Sweden
Posts: 357
Reputation: 37
Great guide i need this!
for u Dr. Robotnik (Gastricpenguin)
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT -4. The time now is 02:04 AM .