void LuaGossip::OnHello(Object* pObject, Player* Plr)
{
    GET_LOCK;
    if(pObject->GetTypeId() == TYPEID_UNIT)
    {
        if(m_unit_gossip_binding == NULL) { RELEASE_LOCK; return; }

        lua_engine::BeginLuaFunctionCall(m_unit_gossip_binding->refs[GOSSIP_EVENT_ON_TALK]);
        push_creature(TO_CREATURE(pObject));
        push_int(GOSSIP_EVENT_ON_TALK);
        push_player(Plr);
        lua_engine::ExecuteLuaFunction(3);
    }
    else if(pObject->GetTypeId() == TYPEID_ITEM)
    {
        if(m_item_gossip_binding == NULL) { RELEASE_LOCK; return; }

        lua_engine::BeginLuaFunctionCall(m_item_gossip_binding->refs[GOSSIP_EVENT_ON_TALK]);
        push_item(TO_ITEM(pObject));
        push_int(GOSSIP_EVENT_ON_TALK);
        push_player(Plr);
        lua_engine::ExecuteLuaFunction(3);
    }
    else if(pObject->GetTypeId() == TYPEID_GAMEOBJECT)
    {
        if(m_go_gossip_binding == NULL) { RELEASE_LOCK; return; }

        lua_engine::BeginLuaFunctionCall(m_go_gossip_binding->refs[GOSSIP_EVENT_ON_TALK]);
        push_go(TO_GAMEOBJECT(pObject));
        push_int(GOSSIP_EVENT_ON_TALK);
        push_player(Plr);
        lua_engine::ExecuteLuaFunction(3);
    }
    RELEASE_LOCK
}
void LuaCreature::AIUpdate()
{
	NULL_BINDING_CHECK

	lua_engine::BeginLuaFunctionCall(m_binding->refs[CREATURE_EVENT_ON_AIUPDATE]);
	push_creature(_unit);
	push_int(CREATURE_EVENT_ON_AIUPDATE);
	lua_engine::ExecuteLuaFunction(2);

	RELEASE_LOCK
}
void LuaCreature::OnDodged(Unit* mTarget)
{
	NULL_BINDING_CHECK

	lua_engine::BeginLuaFunctionCall(m_binding->refs[CREATURE_EVENT_ON_DODGED]);
	push_creature(_unit);
	push_int(CREATURE_EVENT_ON_DODGED);
	push_unit(mTarget);
	lua_engine::ExecuteLuaFunction(3);
	RELEASE_LOCK
}
void LuaCreature::OnCallForHelp()
{
	NULL_BINDING_CHECK

	lua_engine::BeginLuaFunctionCall(m_binding->refs[CREATURE_EVENT_ON_CALL_FOR_HELP]);
	push_creature(_unit);
	push_int(CREATURE_EVENT_ON_CALL_FOR_HELP);
	lua_engine::ExecuteLuaFunction(2);

	RELEASE_LOCK
}
void LuaCreature::OnCombatStart(Unit* mTarget)
{
	NULL_BINDING_CHECK
	lua_engine::BeginLuaFunctionCall(m_binding->refs[CREATURE_EVENT_ON_ENTER_COMBAT]);
	push_creature(_unit);
	push_int(CREATURE_EVENT_ON_ENTER_COMBAT);
	push_unit(mTarget);
	lua_engine::ExecuteLuaFunction(3);


	RELEASE_LOCK
}
void LuaCreature::OnDamageTaken(Unit* mAttacker, uint32 fAmount)
{
	NULL_BINDING_CHECK

	lua_engine::BeginLuaFunctionCall(m_binding->refs[CREATURE_EVENT_ON_DAMAGE_TAKEN]);
	push_creature(_unit);
	push_int(CREATURE_EVENT_ON_DAMAGE_TAKEN);
	push_unit(mAttacker);
	push_int(fAmount);
	lua_engine::ExecuteLuaFunction(4);
	RELEASE_LOCK
}
void LuaCreature::OnLootTaken(Player* pPlayer, ItemPrototype* pItemPrototype)
{
	NULL_BINDING_CHECK

	lua_engine::BeginLuaFunctionCall(m_binding->refs[CREATURE_EVENT_ON_LOOT_TAKEN]);
	push_creature(_unit);
	push_int(CREATURE_EVENT_ON_LOOT_TAKEN);
	push_player(pPlayer);
	push_int(pItemPrototype->ItemId);
	lua_engine::ExecuteLuaFunction(4);
	RELEASE_LOCK
}
void LuaCreature::OnFlee(Unit* mFlee)
{
	NULL_BINDING_CHECK

	lua_engine::BeginLuaFunctionCall(m_binding->refs[CREATURE_EVENT_ON_FLEE]);
	push_creature(_unit);
	push_int(CREATURE_EVENT_ON_FLEE);
	push_unit(mFlee);
	lua_engine::ExecuteLuaFunction(3);

	RELEASE_LOCK
}
void LuaCreature::OnCritHit(Unit* mTarget, int32 fAmount)
{
	NULL_BINDING_CHECK

	lua_engine::BeginLuaFunctionCall(m_binding->refs[CREATURE_EVENT_ON_CRIT_HIT]);
	push_creature(_unit);
	push_int(CREATURE_EVENT_ON_CRIT_HIT);
	push_unit(mTarget);
	push_int(fAmount);
	lua_engine::ExecuteLuaFunction(4);
	RELEASE_LOCK
}
void LuaCreature::OnBlocked(Unit* mTarget, int32 iAmount)
{
	NULL_BINDING_CHECK

	lua_engine::BeginLuaFunctionCall(m_binding->refs[CREATURE_EVENT_ON_BLOCKED]);
	push_creature(_unit);
	push_int(CREATURE_EVENT_ON_BLOCKED);
	push_unit(mTarget);
	push_int(iAmount);
	lua_engine::ExecuteLuaFunction(4);
	RELEASE_LOCK
}
void LuaCreature::OnEmote(Player* pPlayer, EmoteType Emote)
{
	NULL_BINDING_CHECK

	lua_engine::BeginLuaFunctionCall(m_binding->refs[CREATURE_EVENT_ON_EMOTE]);
	push_creature(_unit);
	push_int(CREATURE_EVENT_ON_EMOTE);
	push_player(pPlayer);
	push_int((int)Emote);
	lua_engine::ExecuteLuaFunction(4);

	RELEASE_LOCK
}
void LuaCreature::OnReachWP(uint32 iWaypointId, bool bForwards)
{
	NULL_BINDING_CHECK

	lua_engine::BeginLuaFunctionCall(m_binding->refs[CREATURE_EVENT_ON_REACH_WP]);
	push_creature(_unit);
	push_int(CREATURE_EVENT_ON_REACH_WP);
	push_int(iWaypointId);
	push_bool(bForwards);
	lua_engine::ExecuteLuaFunction(4);

	RELEASE_LOCK
}
void LuaCreature::OnFear(Unit* mFeared, uint32 iSpellId)
{
	NULL_BINDING_CHECK

	lua_engine::BeginLuaFunctionCall(m_binding->refs[CREATURE_EVENT_ON_FEAR]);
	push_creature(_unit);
	push_int(CREATURE_EVENT_ON_FEAR);
	push_unit(mFeared);
	push_int(iSpellId);
	lua_engine::ExecuteLuaFunction(4);

	RELEASE_LOCK
}
void LuaCreature::OnAssistTargetDied(Unit* mAssistTarget)
{

	NULL_BINDING_CHECK

	lua_engine::BeginLuaFunctionCall(m_binding->refs[CREATURE_EVENT_ON_ASSIST_TARGET_DIED]);
	push_creature(_unit);
	push_int(CREATURE_EVENT_ON_ASSIST_TARGET_DIED);
	push_unit(mAssistTarget);
	lua_engine::ExecuteLuaFunction(3);

	RELEASE_LOCK
}
Exemple #15
0
void LuaGossip::OnSelectOption(Object* pObject, Player* Plr, uint32 Id, const char* EnteredCode)
{
    GET_LOCK;
    if(pObject->GetTypeId() == TYPEID_UNIT)
    {
        if(m_unit_gossip_binding == NULL) { RELEASE_LOCK; return; }

        lua_engine::BeginLuaFunctionCall(m_unit_gossip_binding->refs[GOSSIP_EVENT_ON_SELECT_OPTION]);
        push_creature(TO_CREATURE(pObject));
        push_int(GOSSIP_EVENT_ON_SELECT_OPTION);
        push_player(Plr);
        push_int(Id);
        push_str(EnteredCode);
        lua_engine::ExecuteLuaFunction(5);
    }
    else if(pObject->GetTypeId() == TYPEID_ITEM)
    {
        if(m_item_gossip_binding == NULL) { RELEASE_LOCK; return; }
        lua_engine::BeginLuaFunctionCall(m_item_gossip_binding->refs[GOSSIP_EVENT_ON_SELECT_OPTION]);
        push_item(TO_ITEM(pObject));
        push_int(GOSSIP_EVENT_ON_SELECT_OPTION);
        push_player(Plr);
        push_int(Id);
        push_str(EnteredCode);
        lua_engine::ExecuteLuaFunction(5);
    }
    else if(pObject->GetTypeId() == TYPEID_GAMEOBJECT)
    {
        if(m_go_gossip_binding == NULL) { RELEASE_LOCK; return; }
        lua_engine::BeginLuaFunctionCall(m_go_gossip_binding->refs[GOSSIP_EVENT_ON_SELECT_OPTION]);
        push_go(TO_GAMEOBJECT(pObject));
        push_int(GOSSIP_EVENT_ON_SELECT_OPTION);
        push_player(Plr);
        push_int(Id);
        push_str(EnteredCode);
        lua_engine::ExecuteLuaFunction(5);
    }
    RELEASE_LOCK
}