Added more BG hooks, fixed a few issues

This commit is contained in:
Foereaper
2014-09-10 23:42:20 +02:00
parent 29385c63b1
commit 731682708f
4 changed files with 50 additions and 15 deletions

View File

@@ -1935,10 +1935,41 @@ CreatureAI* Eluna::GetAI(Creature* creature)
void Eluna::OnBGStart(BattleGround* bg, BattleGroundTypeId bgId, uint32 instanceId)
{
ENTRY_BEGIN(BGEventBindings, bg->GetTypeID(), BG_EVENT_ON_START, return);
EVENT_BEGIN(BGEventBindings, BG_EVENT_ON_START, return);
Push(L, bg);
Push(L, bgId);
Push(L, instanceId);
ENTRY_EXECUTE(0);
EVENT_EXECUTE(0);
ENDCALL();
}
void Eluna::OnBGEnd(BattleGround* bg, BattleGroundTypeId bgId, uint32 instanceId, Team winner)
{
EVENT_BEGIN(BGEventBindings, BG_EVENT_ON_END, return);
Push(L, bg);
Push(L, bgId);
Push(L, instanceId);
Push(L, winner);
EVENT_EXECUTE(0);
ENDCALL();
}
void Eluna::OnBGCreate(BattleGround* bg, BattleGroundTypeId bgId, uint32 instanceId)
{
EVENT_BEGIN(BGEventBindings, BG_EVENT_ON_CREATE, return);
Push(L, bg);
Push(L, bgId);
Push(L, instanceId);
EVENT_EXECUTE(0);
ENDCALL();
}
void Eluna::OnBGDestroy(BattleGround* bg, BattleGroundTypeId bgId, uint32 instanceId)
{
EVENT_BEGIN(BGEventBindings, BG_EVENT_ON_PRE_DESTROY, return);
Push(L, bg);
Push(L, bgId);
Push(L, instanceId);
EVENT_EXECUTE(0);
ENDCALL();
}

View File

@@ -275,11 +275,13 @@ namespace HookMgr
GOSSIP_EVENT_COUNT
};
// RegisterBGEvent(map_id/entry, EventId, function)
// RegisterBGEvent(EventId, function)
enum BGEvents
{
BG_EVENT_ON_START = 1, // (event, bg, bgId, instanceId) - Needs to be added to TC
BG_EVENT_ON_END = 2, // (event, ???) - Needs to be added to TC
BG_EVENT_ON_END = 2, // (event, bg, bgId, instanceId, winner) - Needs to be added to TC
BG_EVENT_ON_CREATE = 3, // (event, bg, bgId, instanceId) - Needs to be added to TC
BG_EVENT_ON_PRE_DESTROY = 4, // (event, bg, bgId, instanceId) - Needs to be added to TC
BG_EVENT_COUNT
};
};

View File

@@ -96,6 +96,7 @@ PlayerEventBindings(new EventBind<HookMgr::PlayerEvents>("PlayerEvents", *this))
GuildEventBindings(new EventBind<HookMgr::GuildEvents>("GuildEvents", *this)),
GroupEventBindings(new EventBind<HookMgr::GroupEvents>("GroupEvents", *this)),
VehicleEventBindings(new EventBind<HookMgr::VehicleEvents>("VehicleEvents", *this)),
BGEventBindings(new EventBind<HookMgr::BGEvents>("BGEvents", *this)),
PacketEventBindings(new EntryBind<HookMgr::PacketEvents>("PacketEvents", *this)),
CreatureEventBindings(new EntryBind<HookMgr::CreatureEvents>("CreatureEvents", *this)),
@@ -104,7 +105,6 @@ GameObjectEventBindings(new EntryBind<HookMgr::GameObjectEvents>("GameObjectEven
GameObjectGossipBindings(new EntryBind<HookMgr::GossipEvents>("GossipEvents (gameobject)", *this)),
ItemEventBindings(new EntryBind<HookMgr::ItemEvents>("ItemEvents", *this)),
ItemGossipBindings(new EntryBind<HookMgr::GossipEvents>("GossipEvents (item)", *this)),
BGEventBindings(new EntryBind<HookMgr::BGEvents>("BGEvents", *this)),
playerGossipBindings(new EntryBind<HookMgr::GossipEvents>("GossipEvents (player)", *this))
{
// open base lua
@@ -659,6 +659,14 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef)
}
break;
case HookMgr::REGTYPE_BG:
if (evt < HookMgr::BG_EVENT_COUNT)
{
BGEventBindings->Insert(evt, functionRef);
return;
}
break;
case HookMgr::REGTYPE_PACKET:
if (evt < HookMgr::PACKET_EVENT_COUNT)
{
@@ -771,14 +779,6 @@ void Eluna::Register(uint8 regtype, uint32 id, uint32 evt, int functionRef)
return;
}
break;
case HookMgr::REGTYPE_BG:
if (evt < HookMgr::BG_EVENT_COUNT)
{
BGEventBindings->Insert(id, evt, functionRef);
return;
}
break;
}
luaL_unref(L, LUA_REGISTRYINDEX, functionRef);
luaL_error(L, "Unknown event type (regtype %d, id %d, event %d)", regtype, id, evt);

View File

@@ -116,6 +116,7 @@ public:
EventBind<HookMgr::GuildEvents>* GuildEventBindings;
EventBind<HookMgr::GroupEvents>* GroupEventBindings;
EventBind<HookMgr::VehicleEvents>* VehicleEventBindings;
EventBind<HookMgr::BGEvents>* BGEventBindings;
EntryBind<HookMgr::PacketEvents>* PacketEventBindings;
EntryBind<HookMgr::CreatureEvents>* CreatureEventBindings;
@@ -125,7 +126,6 @@ public:
EntryBind<HookMgr::ItemEvents>* ItemEventBindings;
EntryBind<HookMgr::GossipEvents>* ItemGossipBindings;
EntryBind<HookMgr::GossipEvents>* playerGossipBindings;
EntryBind<HookMgr::BGEvents>* BGEventBindings;
Eluna();
~Eluna();
@@ -349,7 +349,9 @@ public:
/* Battle Ground */
void OnBGStart(BattleGround* bg, BattleGroundTypeId bgId, uint32 instanceId);
void OnBGEnd(BattleGround* bg);
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);
};
template<> Unit* Eluna::CHECKOBJ<Unit>(lua_State* L, int narg, bool error);
template<> Player* Eluna::CHECKOBJ<Player>(lua_State* L, int narg, bool error);