/
ScriptMgr.h
585 lines (506 loc) · 22.2 KB
/
ScriptMgr.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
/*
* ArcEmu MMORPG Server
* Copyright (C) 2005-2007 Ascent Team <http://www.ascentemu.com/>
* Copyright (C) 2008-2011 <http://www.ArcEmu.org/>
*
* 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
* 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/>.
*
*/
#ifndef SCRIPTMGR_H
#define SCRIPTMGR_H
#define SCRIPT_MODULE void*
#define ADD_CREATURE_FACTORY_FUNCTION(cl) static CreatureAIScript * Create(Creature * c) { return new cl(c); }
#define ADD_INSTANCE_FACTORY_FUNCTION( ClassName ) static InstanceScript* Create( MapMgr* pMapMgr ) { return new ClassName( pMapMgr ); };
#define ADD_GAMEOBJECT_FACTORY_FUNCTION( ClassName ) static GameObjectAIScript* Create(GameObject* GO) { return new ClassName(GO); };
class Channel;
class Guild;
struct Quest;
enum ServerHookEvents
{
SERVER_HOOK_EVENT_ON_NEW_CHARACTER = 1,
SERVER_HOOK_EVENT_ON_KILL_PLAYER = 2,
SERVER_HOOK_EVENT_ON_FIRST_ENTER_WORLD = 3,
SERVER_HOOK_EVENT_ON_ENTER_WORLD = 4,
SERVER_HOOK_EVENT_ON_GUILD_JOIN = 5,
SERVER_HOOK_EVENT_ON_DEATH = 6,
SERVER_HOOK_EVENT_ON_REPOP = 7,
SERVER_HOOK_EVENT_ON_EMOTE = 8,
SERVER_HOOK_EVENT_ON_ENTER_COMBAT = 9,
SERVER_HOOK_EVENT_ON_CAST_SPELL = 10,
SERVER_HOOK_EVENT_ON_TICK = 11,
SERVER_HOOK_EVENT_ON_LOGOUT_REQUEST = 12,
SERVER_HOOK_EVENT_ON_LOGOUT = 13,
SERVER_HOOK_EVENT_ON_QUEST_ACCEPT = 14,
SERVER_HOOK_EVENT_ON_ZONE = 15,
SERVER_HOOK_EVENT_ON_CHAT = 16,
SERVER_HOOK_EVENT_ON_LOOT = 17,
SERVER_HOOK_EVENT_ON_GUILD_CREATE = 18,
SERVER_HOOK_EVENT_ON_FULL_LOGIN = 19,
SERVER_HOOK_EVENT_ON_CHARACTER_CREATE = 20,
SERVER_HOOK_EVENT_ON_QUEST_CANCELLED = 21,
SERVER_HOOK_EVENT_ON_QUEST_FINISHED = 22,
SERVER_HOOK_EVENT_ON_HONORABLE_KILL = 23,
SERVER_HOOK_EVENT_ON_ARENA_FINISH = 24,
SERVER_HOOK_EVENT_ON_OBJECTLOOT = 25,
SERVER_HOOK_EVENT_ON_AREATRIGGER = 26,
SERVER_HOOK_EVENT_ON_POST_LEVELUP = 27,
SERVER_HOOK_EVENT_ON_PRE_DIE = 28, //general unit die, not only based on players
SERVER_HOOK_EVENT_ON_ADVANCE_SKILLLINE = 29,
SERVER_HOOK_EVENT_ON_DUEL_FINISHED = 30,
SERVER_HOOK_EVENT_ON_AURA_REMOVE = 31,
SERVER_HOOK_EVENT_ON_RESURRECT = 32,
NUM_SERVER_HOOKS,
};
enum ScriptTypes
{
SCRIPT_TYPE_MISC = 0x01,
SCRIPT_TYPE_INFODUMPER = 0x02,
SCRIPT_TYPE_SCRIPT_ENGINE = 0x20,
};
/* Hook typedefs */
typedef bool(*tOnNewCharacter)(uint32 Race, uint32 Class, WorldSession* Session, const char* Name);
typedef void(*tOnKillPlayer)(Player* pPlayer, Player* pVictim);
typedef void(*tOCharacterCreate)(Player* pPlayer);
typedef void(*tOnFirstEnterWorld)(Player* pPlayer);
typedef void(*tOnEnterWorld)(Player* pPlayer);
typedef void(*tOnGuildCreate)(Player* pLeader, Guild* pGuild);
typedef void(*tOnGuildJoin)(Player* pPlayer, Guild* pGuild);
typedef void(*tOnDeath)(Player* pPlayer);
typedef bool(*tOnRepop)(Player* pPlayer);
typedef void(*tOnEmote)(Player* pPlayer, uint32 Emote, Unit* pUnit);
typedef void(*tOnEnterCombat)(Player* pPlayer, Unit* pTarget);
typedef bool(*tOnCastSpell)(Player* pPlayer, SpellEntry* pSpell, Spell* spell);
typedef void(*tOnTick)();
typedef bool(*tOnLogoutRequest)(Player* pPlayer);
typedef void(*tOnLogout)(Player* pPlayer);
typedef void(*tOnQuestAccept)(Player* pPlayer, Quest* pQuest, Object* pQuestGiver);
typedef void(*tOnZone)(Player* pPlayer, uint32 Zone, uint32 oldzone);
typedef bool(*tOnChat)(Player* pPlayer, uint32 Type, uint32 Lang, const char* Message, const char* Misc);
typedef void(*tOnLoot)(Player* pPlayer, Unit* pTarget, uint32 Money, uint32 ItemId);
typedef bool(*ItemScript)(Item* pItem, Player* pPlayer);
typedef void(*tOnQuestCancel)(Player* pPlayer, Quest* pQuest);
typedef void(*tOnQuestFinished)(Player* pPlayer, Quest* pQuest, Object* pQuestGiver);
typedef void(*tOnHonorableKill)(Player* pPlayer, Player* pKilled);
typedef void(*tOnArenaFinish)(Player* pPlayer, ArenaTeam* pTeam, bool victory, bool rated);
typedef void(*tOnObjectLoot)(Player* pPlayer, Object* pTarget, uint32 Money, uint32 ItemId);
typedef void(*tOnAreaTrigger)(Player* pPlayer, uint32 areaTrigger);
typedef void(*tOnPostLevelUp)(Player* pPlayer);
typedef bool(*tOnPreUnitDie)(Unit* killer, Unit* target);
typedef void(*tOnAdvanceSkillLine)(Player* pPlayer, uint32 SkillLine, uint32 Current);
typedef void(*tOnDuelFinished)(Player* Winner, Player* Looser);
typedef void(*tOnAuraRemove)(Aura* aura);
typedef bool(*tOnResurrect)(Player* pPlayer);
class Spell;
class Aura;
class Creature;
class CreatureAIScript;
class GossipScript;
class GameObjectAIScript;
class InstanceScript;
class ScriptMgr;
struct ItemPrototype;
class QuestLogEntry;
/* Factory Imports (from script lib) */
typedef CreatureAIScript* (*exp_create_creature_ai)(Creature* pCreature);
typedef GameObjectAIScript* (*exp_create_gameobject_ai)(GameObject* pGameObject);
typedef InstanceScript* (*exp_create_instance_ai)(MapMgr* pMapMgr);
typedef bool(*exp_handle_dummy_spell)(uint32 i, Spell* pSpell);
typedef bool(*exp_handle_script_effect)(uint32 i, Spell* pSpell);
typedef bool(*exp_handle_dummy_aura)(uint32 i, Aura* pAura, bool apply);
typedef void(*exp_script_register)(ScriptMgr* mgr);
typedef void(*exp_engine_reload)();
typedef void(*exp_engine_unload)();
typedef uint32(*exp_get_script_type)();
typedef uint32(*exp_get_version)();
/* Hashmap typedefs */
typedef HM_NAMESPACE::hash_map<uint32, exp_create_creature_ai> CreatureCreateMap;
typedef HM_NAMESPACE::hash_map<uint32, exp_create_gameobject_ai> GameObjectCreateMap;
typedef HM_NAMESPACE::hash_map<uint32, exp_handle_dummy_aura> HandleDummyAuraMap;
typedef HM_NAMESPACE::hash_map<uint32, exp_handle_dummy_spell> HandleDummySpellMap;
typedef HM_NAMESPACE::hash_map< uint32, exp_handle_script_effect > HandleScriptEffectMap;
typedef HM_NAMESPACE::hash_map<uint32, exp_create_instance_ai> InstanceCreateMap;
typedef set<Arcemu::Gossip::Script*> CustomGossipScripts;
typedef HM_NAMESPACE::hash_map<uint32, Arcemu::Gossip::Script*> GossipMap;
typedef set<QuestScript*> QuestScripts;
typedef set<void*> ServerHookList;
typedef std::list< Arcemu::DynLib* > DynamicLibraryMap;
#define VISIBLE_RANGE (26.46f)
#define MAX_SCRIPTS 1000
#define MAX_INSTANCE_SCRIPTS 1000
class SERVER_DECL ScriptMgr : public Singleton<ScriptMgr>
{
public:
ScriptMgr();
~ScriptMgr();
friend class HookInterface;
void LoadScripts();
void UnloadScripts();
/////////////////////////////////////////////////////////////////////////
//void DumpUnimplementedSpells()
// Dumps the IDs of the spells with dummy/script effects or dummy aura
// that are not yet implemented.
//
//Parameters
// None.
//
//Return Value
// None.
//
//
/////////////////////////////////////////////////////////////////////////
void DumpUnimplementedSpells();
CreatureAIScript* CreateAIScriptClassForEntry(Creature* pCreature);
GameObjectAIScript* CreateAIScriptClassForGameObject(uint32 uEntryId, GameObject* pGameObject);
InstanceScript* CreateScriptClassForInstance(uint32 pMapId, MapMgr* pMapMgr);
bool CallScriptedDummySpell(uint32 uSpellId, uint32 i, Spell* pSpell);
bool HandleScriptedSpellEffect(uint32 SpellId, uint32 i, Spell* s);
bool CallScriptedDummyAura(uint32 uSpellId, uint32 i, Aura* pAura, bool apply);
bool CallScriptedItem(Item* pItem, Player* pPlayer);
//Single Entry Registers
void register_creature_script(uint32 entry, exp_create_creature_ai callback);
void register_gameobject_script(uint32 entry, exp_create_gameobject_ai callback);
void register_dummy_aura(uint32 entry, exp_handle_dummy_aura callback);
void register_dummy_spell(uint32 entry, exp_handle_dummy_spell callback);
void register_script_effect(uint32 entry, exp_handle_script_effect callback);
void register_instance_script(uint32 pMapId, exp_create_instance_ai pCallback);
void register_gossip_script(uint32 entry, GossipScript* gs);
void register_go_gossip_script(uint32 entry, GossipScript* gs);
void register_hook(ServerHookEvents event, void* function_pointer);
void register_item_gossip_script(uint32 entry, GossipScript* gs);
void register_quest_script(uint32 entry, QuestScript* qs);
/* GOSSIP INTERFACE REGISTRATION */
void register_creature_gossip(uint32, Arcemu::Gossip::Script*);
void register_item_gossip(uint32, Arcemu::Gossip::Script*);
void register_go_gossip(uint32, Arcemu::Gossip::Script*);
//Mutliple Entry Registers
void register_creature_script(uint32* entries, exp_create_creature_ai callback);
void register_gameobject_script(uint32* entries, exp_create_gameobject_ai callback);
void register_dummy_aura(uint32* entries, exp_handle_dummy_aura callback);
void register_dummy_spell(uint32* entries, exp_handle_dummy_spell callback);
void register_script_effect(uint32* entries, exp_handle_script_effect callback);
void ReloadScriptEngines();
void UnloadScriptEngines();
//************************************
// Purpose : Returns true if ScriptMgr has already registered the specified creature id.
// Parameter: uint32 - the id of the creature to search for.
//************************************
bool has_creature_script(uint32) const;
//************************************
// Purpose : Returns true if ScriptMgr has already registered the specified gameobject id.
// Parameter: uint32 - the id of the gameobject to search for
//************************************
bool has_gameobject_script(uint32) const;
//************************************
// Purpose : Returns true if ScriptMgr has already registered the specified aura id.
// Parameter: uint32 - the aura id to search for
//************************************
bool has_dummy_aura_script(uint32) const;
//************************************
// Purpose : Returns true if ScriptMgr has already registered the specified dummy spell id.
// Parameter: uint32 - the spell id to search for
//************************************
bool has_dummy_spell_script(uint32) const;
//************************************
// Purpose : Returns true if ScriptMgr has already registered the specified spell id.
// Parameter: uint32 - the spell id to search for
//************************************
bool has_script_effect(uint32) const;
//************************************
// Purpose : Returns true if ScriptMgr has already registered the specified map id.
// Parameter: uint32 - the map id to search for
//************************************
bool has_instance_script(uint32) const;
//************************************
// Purpose : Returns true if ScriptMgr has registered the specified function ptr to the specified event.
// Parameter: ServerHookEvents - the event number
// Parameter: void * - the function pointer to search for.
//************************************
bool has_hook(ServerHookEvents, void*) const;
//************************************
// Purpose : Returns true if ScriptMgr has already registered the specified quest id.
// Parameter: uint32 - the quest id to search for
//************************************
bool has_quest_script(uint32) const;
bool has_creature_gossip(uint32) const;
bool has_item_gossip(uint32) const;
bool has_go_gossip(uint32) const;
Arcemu::Gossip::Script* get_creature_gossip(uint32) const;
Arcemu::Gossip::Script* get_go_gossip(uint32) const;
Arcemu::Gossip::Script* get_item_gossip(uint32) const;
/*
Default Gossip Script Interfaces */
Arcemu::Gossip::Trainer trainerScript_;
Arcemu::Gossip::SpiritHealer spirithealerScript_;
Arcemu::Gossip::Banker bankerScript_;
Arcemu::Gossip::Vendor vendorScript_;
Arcemu::Gossip::ClassTrainer classtrainerScript_;
Arcemu::Gossip::PetTrainer pettrainerScript_;
Arcemu::Gossip::FlightMaster flightmasterScript_;
Arcemu::Gossip::Auctioneer auctioneerScript_;
Arcemu::Gossip::InnKeeper innkeeperScript_;
Arcemu::Gossip::BattleMaster battlemasterScript_;
Arcemu::Gossip::CharterGiver chartergiverScript_;
Arcemu::Gossip::TabardDesigner tabardScript_;
Arcemu::Gossip::StableMaster stablemasterScript_;
Arcemu::Gossip::Generic genericScript_;
protected:
InstanceCreateMap mInstances;
CreatureCreateMap _creatures;
GameObjectCreateMap _gameobjects;
HandleDummyAuraMap _auras;
HandleDummySpellMap _spells;
HandleScriptEffectMap SpellScriptEffects;
DynamicLibraryMap dynamiclibs;
ServerHookList _hooks[NUM_SERVER_HOOKS];
CustomGossipScripts _customgossipscripts;
QuestScripts _questscripts;
GossipMap creaturegossip_, gogossip_, itemgossip_;
};
class SERVER_DECL CreatureAIScript
{
public:
CreatureAIScript(Creature* creature);
virtual ~CreatureAIScript();
virtual void OnCombatStart(Unit* mTarget) {}
virtual void OnCombatStop(Unit* mTarget) {}
virtual void OnDamageTaken(Unit* mAttacker, uint32 fAmount) {}
virtual void OnCastSpell(uint32 iSpellId) {}
virtual void OnTargetParried(Unit* mTarget) {}
virtual void OnTargetDodged(Unit* mTarget) {}
virtual void OnTargetBlocked(Unit* mTarget, int32 iAmount) {}
virtual void OnTargetCritHit(Unit* mTarget, int32 fAmount) {}
virtual void OnTargetDied(Unit* mTarget) {}
virtual void OnParried(Unit* mTarget) {}
virtual void OnDodged(Unit* mTarget) {}
virtual void OnBlocked(Unit* mTarget, int32 iAmount) {}
virtual void OnCritHit(Unit* mTarget, int32 fAmount) {}
virtual void OnHit(Unit* mTarget, float fAmount) {}
virtual void OnDied(Unit* mKiller) {}
virtual void OnAssistTargetDied(Unit* mAssistTarget) {}
virtual void OnFear(Unit* mFeared, uint32 iSpellId) {}
virtual void OnFlee(Unit* mFlee) {}
virtual void OnCallForHelp() {}
virtual void OnLoad() {}
virtual void OnDespawn() {}
virtual void OnReachWP(uint32 iWaypointId, bool bForwards) {}
virtual void OnLootTaken(Player* pPlayer, ItemPrototype* pItemPrototype) {}
virtual void AIUpdate() {}
virtual void OnEmote(Player* pPlayer, EmoteType Emote) {}
virtual void StringFunctionCall(int) {}
void RegisterAIUpdateEvent(uint32 frequency);
void ModifyAIUpdateEvent(uint32 newfrequency);
void RemoveAIUpdateEvent();
bool IsAlive();
virtual void Destroy() { delete this; }
Creature* GetUnit() { return _unit; }
CreatureAIScript* GetLinkedCreature() { return linkedCreatureAI; }
void SetLinkedCreature(CreatureAIScript* creatureAI);
void LinkedCreatureDeleted();
//////////////////////////////////////// Vehicle passenger hooks /////////////////////////////////////
////////////////////////////////////////////////
//void OnEnterVehicle()
// Called when this passenger enters a vehicle
//
//Parameter(s)
// None
//
//Return Value
// None
//
//
////////////////////////////////////////////////
virtual void OnEnterVehicle(){}
////////////////////////////////////////////////
//void OnExitVehicle()
// Called when this passenger leaves the vehicle
//
//Parameter(s)
// None
//
//Return Value
// None
//
//
////////////////////////////////////////////////
virtual void OnExitVehicle(){}
/////////////////////////////////////////// Vehicle Hooks ////////////////////////////////////////////
/////////////////////////////////////////////////////
//void OnFirstPassengerEntered()
// Called when the first passenger enters
//
//Parameter(s)
// Unit *passenger - The passenger who entered
//
//Return Value
// None
//
//
/////////////////////////////////////////////////////
virtual void OnFirstPassengerEntered( Unit *passenger ){}
////////////////////////////////////////////////////
//void OnVehicleFull()
// Called when there are no more free seats
//
//Parameter(s)
// None
//
//Return Value
// None
//
//
////////////////////////////////////////////////////
virtual void OnVehicleFull(){}
////////////////////////////////////////////////////
//void OnLastPassengerLeft( Unit *passenger )
// Called when the last passenger leaves
//
//Parameter(s)
// Unit *passenger - The passenger who left
//
//Return Value
// None
//
//
////////////////////////////////////////////////////
virtual void OnLastPassengerLeft( Unit *passenger ){}
protected:
Creature* _unit;
private:
CreatureAIScript* linkedCreatureAI;
};
class SERVER_DECL GameObjectAIScript
{
public:
GameObjectAIScript(GameObject* goinstance);
virtual ~GameObjectAIScript() {}
virtual void OnCreate() {}
virtual void OnSpawn() {}
virtual void OnDespawn() {}
virtual void OnLootTaken(Player* pLooter, ItemPrototype* pItemInfo) {}
virtual void OnActivate(Player* pPlayer) {}
virtual void OnDamaged( uint32 damage ){}
virtual void OnDestroyed(){}
virtual void AIUpdate() {}
virtual void Destroy() { delete this; }
void RegisterAIUpdateEvent(uint32 frequency);
void ModifyAIUpdateEvent(uint32 newfrequency);
void RemoveAIUpdateEvent();
protected:
GameObject* _gameobject;
};
class SERVER_DECL GossipScript : public Arcemu::Gossip::Script
{
public:
GossipScript() {}
virtual ~GossipScript() {}
virtual void GossipHello(Object* pObject, Player* plr) {}
virtual void GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char* EnteredCode) {}
virtual void GossipEnd(Object* pObject, Player* Plr) {}
//support for Gossip scripts added before r4106
virtual void OnHello(Object* pObject, Player* Plr);
virtual void OnSelectOption(Object* pObject, Player* Plr, uint32 Id, const char* EnteredCode);
virtual void OnEnd(Object* pObject, Player* Plr);
};
class SERVER_DECL QuestScript
{
public:
QuestScript() {};
virtual ~QuestScript() {};
virtual void OnQuestStart(Player* mTarget, QuestLogEntry* qLogEntry) {}
virtual void OnQuestComplete(Player* mTarget, QuestLogEntry* qLogEntry) {}
virtual void OnQuestCancel(Player* mTarget) {}
virtual void OnGameObjectActivate(uint32 entry, Player* mTarget, QuestLogEntry* qLogEntry) {}
virtual void OnCreatureKill(uint32 entry, Player* mTarget, QuestLogEntry* qLogEntry) {}
virtual void OnExploreArea(uint32 areaId, Player* mTarget, QuestLogEntry* qLogEntry) {}
virtual void OnPlayerItemPickup(uint32 itemId, uint32 totalCount, Player* mTarget, QuestLogEntry* qLogEntry) {}
};
/* * Class InstanceScript
* Instanced class created for each instance of the map, holds all
* scriptable exports
*/
class SERVER_DECL InstanceScript
{
public:
InstanceScript(MapMgr* pMapMgr);
virtual ~InstanceScript() {};
// Procedures that had been here before
virtual GameObject* GetObjectForOpenLock(Player* pCaster, Spell* pSpell, SpellEntry* pSpellEntry) { return NULL; };
virtual void SetLockOptions(uint32 pEntryId, GameObject* pGameObject) {};
virtual uint32 GetRespawnTimeForCreature(uint32 pEntryId, Creature* pCreature) { return 240000; };
// Player
virtual void OnPlayerDeath(Player* pVictim, Unit* pKiller) {};
// Area and AreaTrigger
virtual void OnPlayerEnter(Player* pPlayer) {};
virtual void OnAreaTrigger(Player* pPlayer, uint32 pAreaId) {};
virtual void OnZoneChange(Player* pPlayer, uint32 pNewZone, uint32 pOldZone) {};
// Data get / set - idea taken from ScriptDev2
virtual void SetInstanceData(uint32 pType, uint32 pIndex, uint32 pData) {};
virtual uint32 GetInstanceData(uint32 pType, uint32 pIndex) { return 0; };
// Creature / GameObject - part of it is simple reimplementation for easier use Creature / GO < --- > Script
virtual void OnCreatureDeath(Creature* pVictim, Unit* pKiller) {};
virtual void OnCreaturePushToWorld(Creature* pCreature) {};
virtual void OnGameObjectActivate(GameObject* pGameObject, Player* pPlayer) {};
virtual void OnGameObjectPushToWorld(GameObject* pGameObject) {};
// Standard virtual methods
virtual void OnLoad() {};
virtual void UpdateEvent() {};
virtual void Destroy() {};
// UpdateEvent
void RegisterUpdateEvent(uint32 pFrequency);
void ModifyUpdateEvent(uint32 pNewFrequency);
void RemoveUpdateEvent();
// Something to return Instance's MapMgr
MapMgr* GetInstance() { return mInstance; };
protected:
MapMgr* mInstance;
};
class SERVER_DECL HookInterface : public Singleton<HookInterface>
{
public:
friend class ScriptMgr;
bool OnNewCharacter(uint32 Race, uint32 Class, WorldSession* Session, const char* Name);
void OnKillPlayer(Player* pPlayer, Player* pVictim);
void OnFirstEnterWorld(Player* pPlayer);
void OnEnterWorld(Player* pPlayer);
void OnGuildCreate(Player* pLeader, Guild* pGuild);
void OnGuildJoin(Player* pPlayer, Guild* pGuild);
void OnDeath(Player* pPlayer);
bool OnRepop(Player* pPlayer);
void OnEmote(Player* pPlayer, uint32 Emote, Unit* pUnit);
void OnEnterCombat(Player* pPlayer, Unit* pTarget);
bool OnCastSpell(Player* pPlayer, SpellEntry* pSpell, Spell* spell);
bool OnLogoutRequest(Player* pPlayer);
void OnLogout(Player* pPlayer);
void OnQuestAccept(Player* pPlayer, Quest* pQuest, Object* pQuestGiver);
void OnZone(Player* pPlayer, uint32 Zone, uint32 oldZone);
bool OnChat(Player* pPlayer, uint32 Type, uint32 Lang, const char* Message, const char* Misc);
void OnLoot(Player* pPlayer, Unit* pTarget, uint32 Money, uint32 ItemId);
void OnFullLogin(Player* pPlayer);
void OnCharacterCreate(Player* pPlayer);
void OnQuestCancelled(Player* pPlayer, Quest* pQuest);
void OnQuestFinished(Player* pPlayer, Quest* pQuest, Object* pQuestGiver);
void OnHonorableKill(Player* pPlayer, Player* pKilled);
void OnArenaFinish(Player* pPlayer, ArenaTeam* pTeam, bool victory, bool rated);
void OnObjectLoot(Player* pPlayer, Object* pTarget, uint32 Money, uint32 ItemId);
void OnAreaTrigger(Player* pPlayer, uint32 areaTrigger);
void OnPostLevelUp(Player* pPlayer);
bool OnPreUnitDie(Unit* Killer, Unit* Victim);
void OnAdvanceSkillLine(Player* pPlayer, uint32 SkillLine, uint32 Current);
void OnDuelFinished(Player* Winner, Player* Looser);
void OnAuraRemove(Aura* aura);
bool OnResurrect(Player* pPlayer);
};
#define sScriptMgr ScriptMgr::getSingleton()
#define sHookInterface HookInterface::getSingleton()
#endif