forked from ElunaLuaEngine/Eluna
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LuaEngine.h
613 lines (540 loc) · 24.8 KB
/
LuaEngine.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
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
/*
* Copyright (C) 2010 - 2024 Eluna Lua Engine <https://elunaluaengine.github.io/>
* This program is free software licensed under GPL version 3
* Please see the included DOCS/LICENSE.md for more information
*/
#ifndef _LUA_ENGINE_H
#define _LUA_ENGINE_H
#include "Common.h"
#include "ElunaUtility.h"
#include "Hooks.h"
#if !defined ELUNA_CMANGOS
#include "DBCEnums.h"
#include "Group.h"
#include "Item.h"
#include "Map.h"
#include "SharedDefines.h"
#include "Weather.h"
#include "World.h"
#if defined ELUNA_VMANGOS
#include "Player.h"
#endif
#else
#include "Entities/Item.h"
#include "Globals/SharedDefines.h"
#include "Groups/Group.h"
#include "Maps/Map.h"
#include "Server/DBCEnums.h"
#include "Weather/Weather.h"
#include "World/World.h"
#include "Entities/Player.h"
#endif
#include <mutex>
#include <memory>
extern "C"
{
#include "lua.h"
};
class AuctionHouseObject;
class Channel;
class Corpse;
class Creature;
class CreatureAI;
class ElunaInstanceAI;
class GameObject;
class Group;
class Guild;
class Item;
class Pet;
class Player;
class Quest;
class Spell;
class SpellCastTargets;
class Unit;
class Weather;
class WorldPacket;
struct AreaTriggerEntry;
struct AuctionEntry;
#if defined ELUNA_TRINITY
class Battleground;
class GameObjectAI;
class InstanceScript;
class TempSummon;
class Vehicle;
struct ItemTemplate;
typedef Battleground BattleGround;
typedef BattlegroundTypeId BattleGroundTypeId;
typedef InstanceScript InstanceData;
#else
class InstanceData;
struct ItemPrototype;
struct SpellEntry;
typedef ItemPrototype ItemTemplate;
typedef SpellEffectIndex SpellEffIndex;
typedef SpellEntry SpellInfo;
#if defined ELUNA_CMANGOS
class TemporarySpawn;
typedef TemporarySpawn TempSummon;
#endif
#if defined ELUNA_VMANGOS || ELUNA_MANGOS
class TemporarySummon;
typedef TemporarySummon TempSummon;
#endif
#if ELUNA_EXPANSION == EXP_CLASSIC
typedef int Difficulty;
#endif
#if ELUNA_EXPANSION >= EXP_WOTLK
class VehicleInfo;
typedef VehicleInfo Vehicle;
#endif
#endif
struct lua_State;
class EventMgr;
class ElunaObject;
template<typename T> class ElunaTemplate;
template<typename K> class BindingMap;
template<typename T> struct EventKey;
template<typename T> struct EntryKey;
template<typename T> struct UniqueObjectKey;
struct LuaScript
{
std::string fileext;
std::string filename;
std::string filepath;
std::string modulepath;
BytecodeBuffer bytecode;
int32 mapId;
};
enum MethodRegisterState
{
METHOD_REG_NONE = 0,
METHOD_REG_MAP,
METHOD_REG_WORLD,
METHOD_REG_ALL
};
#define ELUNA_STATE_PTR "Eluna State Ptr"
#if defined ELUNA_TRINITY
#define ELUNA_GAME_API TC_GAME_API
#define TRACKABLE_PTR_NAMESPACE ::Trinity::
#else
#define ELUNA_GAME_API
#if defined ELUNA_CMANGOS
#define TRACKABLE_PTR_NAMESPACE ::MaNGOS::
#endif
#endif
class ELUNA_GAME_API Eluna
{
public:
typedef std::list<LuaScript> ScriptList;
typedef std::recursive_mutex LockType;
void ReloadEluna() { reload = true; }
bool ExecuteCall(int params, int res);
private:
// Indicates that the lua state should be reloaded
bool reload = false;
#if !defined TRACKABLE_PTR_NAMESPACE
// A counter for lua event stacks that occur (see event_level).
// This is used to determine whether an object belongs to the current call stack or not.
// 0 is reserved for always belonging to the call stack
// 1 is reserved for a non valid callstackid
uint64 callstackid = 2;
#endif
// A counter for the amount of nested events. When the event_level
// reaches 0 we are about to return back to C++. At this point the
// objects used during the event stack are invalidated.
uint32 event_level;
// When a hook pushes arguments to be passed to event handlers,
// this is used to keep track of how many arguments were pushed.
uint8 push_counter;
Map* const boundMap;
// Whether or not Eluna is in compatibility mode. Used in some method wrappers.
bool compatibilityMode;
// Index of the Eluna::StackTrace function pushed to the lua state stack when lua is opened
// We store the function to stack on lua open because it cannot be a pseudo-index (must be on stack) and we want access it on every call
int stacktraceFunctionStackIndex = 0;
// Map from instance ID -> Lua table ref
std::unordered_map<uint32, int> instanceDataRefs;
// Map from map ID -> Lua table ref
std::unordered_map<uint32, int> continentDataRefs;
void OpenLua();
void CloseLua();
void DestroyBindStores();
void CreateBindStores();
#if !defined TRACKABLE_PTR_NAMESPACE
void InvalidateObjects();
#endif
// Use ReloadEluna() to make eluna reload
// This is called on world update to reload eluna
void _ReloadEluna();
// Some helpers for hooks to call event handlers.
// The bodies of the templates are in HookHelpers.h, so if you want to use them you need to #include "HookHelpers.h".
template<typename K1, typename K2> int SetupStack(BindingMap<K1>* bindings1, BindingMap<K2>* bindings2, const K1& key1, const K2& key2, int number_of_arguments);
int CallOneFunction(int number_of_functions, int number_of_arguments, int number_of_results);
void CleanUpStack(int number_of_arguments);
template<typename T> void ReplaceArgument(T value, uint8 index);
template<typename K1, typename K2> void CallAllFunctions(BindingMap<K1>* bindings1, BindingMap<K2>* bindings2, const K1& key1, const K2& key2);
template<typename K1, typename K2> bool CallAllFunctionsBool(BindingMap<K1>* bindings1, BindingMap<K2>* bindings2, const K1& key1, const K2& key2, bool default_value = false);
// Same as above but for only one binding instead of two.
// `key` is passed twice because there's no NULL for references, but it's not actually used if `bindings2` is NULL.
template<typename K> int SetupStack(BindingMap<K>* bindings, const K& key, int number_of_arguments)
{
return SetupStack<K, K>(bindings, NULL, key, key, number_of_arguments);
}
template<typename K> void CallAllFunctions(BindingMap<K>* bindings, const K& key)
{
CallAllFunctions<K, K>(bindings, NULL, key, key);
}
template<typename K> bool CallAllFunctionsBool(BindingMap<K>* bindings, const K& key, bool default_value = false)
{
return CallAllFunctionsBool<K, K>(bindings, NULL, key, key, default_value);
}
// Non-static pushes, to be used in hooks.
// They up the pushed value counter for hook helper functions.
void HookPush() { Push(); ++push_counter; }
void HookPush(const long long value) { Push(value); ++push_counter; }
void HookPush(const unsigned long long value) { Push(value); ++push_counter; }
void HookPush(const long value) { Push(value); ++push_counter; }
void HookPush(const unsigned long value) { Push(value); ++push_counter; }
void HookPush(const int value) { Push(value); ++push_counter; }
void HookPush(const unsigned int value) { Push(value); ++push_counter; }
void HookPush(const bool value) { Push(value); ++push_counter; }
void HookPush(const float value) { Push(value); ++push_counter; }
void HookPush(const double value) { Push(value); ++push_counter; }
void HookPush(const std::string& value) { Push(value); ++push_counter; }
void HookPush(const char* value) { Push(value); ++push_counter; }
void HookPush(ObjectGuid const value) { Push(value); ++push_counter; }
template<typename T>
void HookPush(T const* ptr) { Push(ptr); ++push_counter; }
public:
lua_State* L;
EventMgr* eventMgr;
#if defined ELUNA_TRINITY
QueryCallbackProcessor queryProcessor;
QueryCallbackProcessor& GetQueryProcessor() { return queryProcessor; }
#endif
BindingMap< EventKey<Hooks::ServerEvents> >* ServerEventBindings;
BindingMap< EventKey<Hooks::PlayerEvents> >* PlayerEventBindings;
BindingMap< EventKey<Hooks::GuildEvents> >* GuildEventBindings;
BindingMap< EventKey<Hooks::GroupEvents> >* GroupEventBindings;
BindingMap< EventKey<Hooks::VehicleEvents> >* VehicleEventBindings;
BindingMap< EventKey<Hooks::BGEvents> >* BGEventBindings;
BindingMap< EntryKey<Hooks::PacketEvents> >* PacketEventBindings;
BindingMap< EntryKey<Hooks::CreatureEvents> >* CreatureEventBindings;
BindingMap< EntryKey<Hooks::GossipEvents> >* CreatureGossipBindings;
BindingMap< EntryKey<Hooks::GameObjectEvents> >* GameObjectEventBindings;
BindingMap< EntryKey<Hooks::GossipEvents> >* GameObjectGossipBindings;
BindingMap< EntryKey<Hooks::SpellEvents> >* SpellEventBindings;
BindingMap< EntryKey<Hooks::ItemEvents> >* ItemEventBindings;
BindingMap< EntryKey<Hooks::GossipEvents> >* ItemGossipBindings;
BindingMap< EntryKey<Hooks::GossipEvents> >* PlayerGossipBindings;
BindingMap< EntryKey<Hooks::InstanceEvents> >* MapEventBindings;
BindingMap< EntryKey<Hooks::InstanceEvents> >* InstanceEventBindings;
BindingMap< UniqueObjectKey<Hooks::CreatureEvents> >* CreatureUniqueBindings;
static int StackTrace(lua_State* _L);
static void Report(lua_State* _L);
// Never returns nullptr
static Eluna* GetEluna(lua_State* L)
{
lua_pushstring(L, ELUNA_STATE_PTR);
lua_rawget(L, LUA_REGISTRYINDEX);
ASSERT(lua_islightuserdata(L, -1));
Eluna* E = static_cast<Eluna*>(lua_touserdata(L, -1));
lua_pop(L, 1);
ASSERT(E);
return E;
}
// can be used by anything, including methods.
void Push(); // nil
void Push(const long long);
void Push(const unsigned long long);
void Push(const long);
void Push(const unsigned long);
void Push(const int);
void Push(const unsigned int);
void Push(const bool);
void Push(const float);
void Push(const double);
void Push(const std::string&);
void Push(const char*);
void Push(Object const* obj);
void Push(WorldObject const* obj);
void Push(Unit const* unit);
void Push(Pet const* pet);
void Push(TempSummon const* summon);
void Push(ObjectGuid const guid);
template<typename T>
void Push(T const* ptr)
{
ElunaTemplate<T>::Push(this, ptr);
}
/*
* Returns `true` if Eluna has instance data for `map`.
*/
bool HasInstanceData(Map const* map);
/*
* Use the top element of the stack as the instance data table for `map`,
* then pops it off the stack.
*/
void CreateInstanceData(Map const* map);
/*
* Retrieve the instance data for the `Map` scripted by `ai` and push it
* onto the stack.
*
* An `ElunaInstanceAI` is needed because the instance data might
* not exist (i.e. Eluna has been reloaded).
*
* In that case, the AI is "reloaded" (new instance data table is created
* and loaded with the last known save state, and `Load`/`Initialize`
* hooks are called).
*/
void PushInstanceData(ElunaInstanceAI* ai, bool incrementCounter = true);
void RunScripts();
bool HasLuaState() const { return L != NULL; }
#if !defined TRACKABLE_PTR_NAMESPACE
uint64 GetCallstackId() const { return callstackid; }
#endif
int Register(uint8 reg, uint32 entry, ObjectGuid guid, uint32 instanceId, uint32 event_id, int functionRef, uint32 shots);
void UpdateEluna(uint32 diff);
// Checks
template<typename T> T CHECKVAL(int narg);
template<typename T> T CHECKVAL(int narg, T def)
{
return lua_isnoneornil(L, narg) ? def : CHECKVAL<T>(narg);
}
template<typename T> T* CHECKOBJ(int narg, bool error = true)
{
return ElunaTemplate<T>::Check(this, narg, error);
}
ElunaObject* CHECKTYPE(int narg, const char* tname, bool error = true);
CreatureAI* GetAI(Creature* creature);
InstanceData* GetInstanceData(Map* map);
void FreeInstanceId(uint32 instanceId);
Map* GetBoundMap() const { return boundMap; }
int32 GetBoundMapId() const
{
if(const Map * map = GetBoundMap())
return map->GetId();
return -1;
}
uint32 GetBoundInstanceId() const
{
if(const Map * map = GetBoundMap())
return map->GetInstanceId();
return 0;
}
bool GetCompatibilityMode() const { return compatibilityMode; }
Eluna(Map * map, bool compatMode = false);
~Eluna();
// Prevent copy
Eluna(Eluna const&) = delete;
Eluna& operator=(const Eluna&) = delete;
/* Custom */
void OnTimedEvent(int funcRef, uint32 delay, uint32 calls, WorldObject* obj);
bool OnCommand(Player* player, const char* text);
void OnWorldUpdate(uint32 diff);
void OnLootItem(Player* pPlayer, Item* pItem, uint32 count, ObjectGuid guid);
void OnLootMoney(Player* pPlayer, uint32 amount);
void OnFirstLogin(Player* pPlayer);
void OnEquip(Player* pPlayer, Item* pItem, uint8 bag, uint8 slot);
void OnRepop(Player* pPlayer);
void OnResurrect(Player* pPlayer);
void OnQuestAbandon(Player* pPlayer, uint32 questId);
void OnQuestStatusChanged(Player* pPlayer, uint32 questId, uint8 status);
void OnLearnTalents(Player* pPlayer, uint32 talentId, uint32 talentRank, uint32 spellid);
void OnSkillChange(Player* pPlayer, uint32 skillId, uint32 skillValue);
void OnLearnSpell(Player* pPlayer, uint32 spellid);
InventoryResult OnCanUseItem(const Player* pPlayer, uint32 itemEntry);
void OnLuaStateClose();
void OnLuaStateOpen();
bool OnAddonMessage(Player* sender, uint32 type, std::string& msg, Player* receiver, Guild* guild, Group* group, Channel* channel);
bool OnTradeInit(Player* trader, Player* tradee);
bool OnTradeAccept(Player* trader, Player* tradee);
bool OnSendMail(Player* sender, ObjectGuid recipientGuid);
void OnDiscoverArea(Player* player, uint32 area);
/* Item */
void OnDummyEffect(WorldObject* pCaster, uint32 spellId, SpellEffIndex effIndex, Item* pTarget);
bool OnQuestAccept(Player* pPlayer, Item* pItem, Quest const* pQuest);
bool OnUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targets);
bool OnItemUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targets);
bool OnItemGossip(Player* pPlayer, Item* pItem, SpellCastTargets const& targets);
bool OnExpire(Player* pPlayer, ItemTemplate const* pProto);
bool OnRemove(Player* pPlayer, Item* item);
void OnAdd(Player* pPlayer, Item* item);
void HandleGossipSelectOption(Player* pPlayer, Item* item, uint32 sender, uint32 action, const std::string& code);
void OnItemEquip(Player* pPlayer, Item* pItem, uint8 slot);
void OnItemUnEquip(Player* pPlayer, Item* pItem, uint8 slot);
/* Creature */
void OnDummyEffect(WorldObject* pCaster, uint32 spellId, SpellEffIndex effIndex, Creature* pTarget);
bool OnGossipHello(Player* pPlayer, Creature* pCreature);
bool OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 sender, uint32 action);
bool OnGossipSelectCode(Player* pPlayer, Creature* pCreature, uint32 sender, uint32 action, const char* code);
bool OnQuestAccept(Player* pPlayer, Creature* pCreature, Quest const* pQuest);
bool OnQuestReward(Player* pPlayer, Creature* pCreature, Quest const* pQuest, uint32 opt);
void GetDialogStatus(const Player* pPlayer, const Creature* pCreature);
bool OnSummoned(Creature* creature, Unit* summoner);
bool UpdateAI(Creature* me, const uint32 diff);
bool EnterCombat(Creature* me, Unit* target);
bool DamageTaken(Creature* me, Unit* attacker, uint32& damage);
bool JustDied(Creature* me, Unit* killer);
bool KilledUnit(Creature* me, Unit* victim);
bool JustSummoned(Creature* me, Creature* summon);
bool SummonedCreatureDespawn(Creature* me, Creature* summon);
bool MovementInform(Creature* me, uint32 type, uint32 id);
bool AttackStart(Creature* me, Unit* target);
bool EnterEvadeMode(Creature* me);
bool JustRespawned(Creature* me);
bool JustReachedHome(Creature* me);
bool ReceiveEmote(Creature* me, Player* player, uint32 emoteId);
bool CorpseRemoved(Creature* me, uint32& respawnDelay);
bool MoveInLineOfSight(Creature* me, Unit* who);
bool SpellHit(Creature* me, WorldObject* caster, SpellInfo const* spell);
bool SpellHitTarget(Creature* me, WorldObject* target, SpellInfo const* spell);
bool SummonedCreatureDies(Creature* me, Creature* summon, Unit* killer);
bool OwnerAttackedBy(Creature* me, Unit* attacker);
bool OwnerAttacked(Creature* me, Unit* target);
void On_Reset(Creature* me);
/* GameObject */
void OnDummyEffect(WorldObject* pCaster, uint32 spellId, SpellEffIndex effIndex, GameObject* pTarget);
bool OnGameObjectUse(Player* pPlayer, GameObject* pGameObject);
bool OnGossipHello(Player* pPlayer, GameObject* pGameObject);
bool OnGossipSelect(Player* pPlayer, GameObject* pGameObject, uint32 sender, uint32 action);
bool OnGossipSelectCode(Player* pPlayer, GameObject* pGameObject, uint32 sender, uint32 action, const char* code);
bool OnQuestAccept(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest);
bool OnQuestReward(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest, uint32 opt);
void GetDialogStatus(const Player* pPlayer, const GameObject* pGameObject);
#if ELUNA_EXPANSION >= EXP_WOTLK
void OnDestroyed(GameObject* pGameObject, WorldObject* attacker);
void OnDamaged(GameObject* pGameObject, WorldObject* attacker);
#endif
void OnLootStateChanged(GameObject* pGameObject, uint32 state);
void OnGameObjectStateChanged(GameObject* pGameObject, uint32 state);
void UpdateAI(GameObject* pGameObject, uint32 diff);
void OnSpawn(GameObject* gameobject);
/* Packet */
bool OnPacketSend(WorldSession* session, const WorldPacket& packet);
void OnPacketSendAny(Player* player, const WorldPacket& packet, bool& result);
void OnPacketSendOne(Player* player, const WorldPacket& packet, bool& result);
bool OnPacketReceive(WorldSession* session, WorldPacket& packet);
void OnPacketReceiveAny(Player* player, WorldPacket& packet, bool& result);
void OnPacketReceiveOne(Player* player, WorldPacket& packet, bool& result);
/* Player */
void OnPlayerEnterCombat(Player* pPlayer, Unit* pEnemy);
void OnPlayerLeaveCombat(Player* pPlayer);
void OnPVPKill(Player* pKiller, Player* pKilled);
void OnCreatureKill(Player* pKiller, Creature* pKilled);
void OnPlayerKilledByCreature(Creature* pKiller, Player* pKilled);
void OnPlayerKilledByEnvironment(Player* pKilled, uint8 damageType);
void OnLevelChanged(Player* pPlayer, uint8 oldLevel);
void OnFreeTalentPointsChanged(Player* pPlayer, uint32 newPoints);
void OnTalentsReset(Player* pPlayer, bool noCost);
void OnMoneyChanged(Player* pPlayer, int32& amount);
#if ELUNA_EXPANSION >= EXP_CATA
void OnMoneyChanged(Player* pPlayer, int64& amount);
#endif
void OnGiveXP(Player* pPlayer, uint32& amount, Unit* pVictim);
void OnReputationChange(Player* pPlayer, uint32 factionID, int32& standing, bool incremental);
void OnDuelRequest(Player* pTarget, Player* pChallenger);
void OnDuelStart(Player* pStarter, Player* pChallenger);
void OnDuelEnd(Player* pWinner, Player* pLoser, DuelCompleteType type);
bool OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg);
bool OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Group* pGroup);
bool OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Guild* pGuild);
bool OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Channel* pChannel);
bool OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Player* pReceiver);
void OnEmote(Player* pPlayer, uint32 emote);
void OnTextEmote(Player* pPlayer, uint32 textEmote, uint32 emoteNum, ObjectGuid guid);
void OnSpellCast(Player* pPlayer, Spell* pSpell, bool skipCheck);
void OnLogin(Player* pPlayer);
void OnLogout(Player* pPlayer);
void OnCreate(Player* pPlayer);
void OnDelete(uint32 guid);
void OnSave(Player* pPlayer);
void OnBindToInstance(Player* pPlayer, Difficulty difficulty, uint32 mapid, bool permanent);
void OnUpdateZone(Player* pPlayer, uint32 newZone, uint32 newArea);
void OnUpdateArea(Player* pPlayer, uint32 oldArea, uint32 newArea);
void OnMapChanged(Player* pPlayer);
void HandleGossipSelectOption(Player* pPlayer, uint32 menuId, uint32 sender, uint32 action, const std::string& code);
void OnAchievementComplete(Player* pPlayer, uint32 achievementId);
#if ELUNA_EXPANSION >= EXP_WOTLK
/* Vehicle */
void OnInstall(Vehicle* vehicle);
void OnUninstall(Vehicle* vehicle);
void OnInstallAccessory(Vehicle* vehicle, Creature* accessory);
void OnAddPassenger(Vehicle* vehicle, Unit* passenger, int8 seatId);
void OnRemovePassenger(Vehicle* vehicle, Unit* passenger);
#endif
/* AreaTrigger */
bool OnAreaTrigger(Player* pPlayer, AreaTriggerEntry const* pTrigger);
/* Weather */
void OnChange(Weather* weather, uint32 zone, WeatherState state, float grade);
/* Auction House */
void OnAdd(AuctionHouseObject* ah, AuctionEntry* entry);
void OnRemove(AuctionHouseObject* ah, AuctionEntry* entry);
void OnSuccessful(AuctionHouseObject* ah, AuctionEntry* entry);
void OnExpire(AuctionHouseObject* ah, AuctionEntry* entry);
/* Guild */
void OnAddMember(Guild* guild, Player* player, uint32 plRank);
void OnRemoveMember(Guild* guild, Player* player, bool isDisbanding);
void OnMOTDChanged(Guild* guild, const std::string& newMotd);
void OnInfoChanged(Guild* guild, const std::string& newInfo);
void OnCreate(Guild* guild, Player* leader, const std::string& name);
void OnDisband(Guild* guild);
void OnMemberWitdrawMoney(Guild* guild, Player* player, uint32& amount, bool isRepair);
void OnMemberDepositMoney(Guild* guild, Player* player, uint32& amount);
#if ELUNA_EXPANSION >= EXP_CATA
void OnMemberWitdrawMoney(Guild* guild, Player* player, uint64& amount, bool isRepair);
void OnMemberDepositMoney(Guild* guild, Player* player, uint64& amount);
#endif
void OnItemMove(Guild* guild, Player* player, Item* pItem, bool isSrcBank, uint8 srcContainer, uint8 srcSlotId, bool isDestBank, uint8 destContainer, uint8 destSlotId);
void OnEvent(Guild* guild, uint8 eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank);
void OnBankEvent(Guild* guild, uint8 eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId);
/* Group */
void OnAddMember(Group* group, ObjectGuid guid);
void OnInviteMember(Group* group, ObjectGuid guid);
void OnRemoveMember(Group* group, ObjectGuid guid, uint8 method);
void OnChangeLeader(Group* group, ObjectGuid newLeaderGuid, ObjectGuid oldLeaderGuid);
void OnDisband(Group* group);
void OnCreate(Group* group, ObjectGuid leaderGuid, GroupType groupType);
bool OnMemberAccept(Group* group, Player* player);
/* Map */
void OnCreate(Map* map);
void OnDestroy(Map* map);
void OnPlayerEnter(Map* map, Player* player);
void OnPlayerLeave(Map* map, Player* player);
void OnUpdate(Map* map, uint32 diff);
void OnAddToWorld(Creature* creature);
void OnRemoveFromWorld(Creature* creature);
void OnAddToWorld(GameObject* gameobject);
void OnRemoveFromWorld(GameObject* gameobject);
void OnRemove(Creature* creature);
void OnRemove(GameObject* gameobject);
/* Instance */
void OnInitialize(ElunaInstanceAI* ai);
void OnLoad(ElunaInstanceAI* ai);
void OnUpdateInstance(ElunaInstanceAI* ai, uint32 diff);
void OnPlayerEnterInstance(ElunaInstanceAI* ai, Player* player);
void OnCreatureCreate(ElunaInstanceAI* ai, Creature* creature);
void OnGameObjectCreate(ElunaInstanceAI* ai, GameObject* gameobject);
bool OnCheckEncounterInProgress(ElunaInstanceAI* ai);
/* World */
void OnOpenStateChange(bool open);
void OnConfigLoad(bool reload);
void OnShutdownInitiate(ShutdownExitCode code, ShutdownMask mask);
void OnShutdownCancel();
void OnStartup();
void OnShutdown();
void OnGameEventStart(uint32 eventid);
void OnGameEventStop(uint32 eventid);
/* Battle Ground */
void OnBGStart(BattleGround* bg, BattleGroundTypeId bgId, uint32 instanceId);
void OnBGEnd(BattleGround* bg, BattleGroundTypeId bgId, uint32 instanceId, Team winner);
void OnBGCreate(BattleGround* bg, BattleGroundTypeId bgId, uint32 instanceId);
void OnBGDestroy(BattleGround* bg, BattleGroundTypeId bgId, uint32 instanceId);
/* Spell */
void OnSpellCast(Spell* pSpell, bool skipCheck);
};
template<> Unit* Eluna::CHECKOBJ<Unit>(int narg, bool error);
template<> Object* Eluna::CHECKOBJ<Object>(int narg, bool error);
template<> WorldObject* Eluna::CHECKOBJ<WorldObject>(int narg, bool error);
template<> ElunaObject* Eluna::CHECKOBJ<ElunaObject>(int narg, bool error);
#endif