Eluna fix mangos hooks

This commit is contained in:
Rochet2
2014-04-22 01:26:18 +03:00
committed by Foereaper
parent eaf8ca0369
commit afb3aa8ca0
2 changed files with 50 additions and 100 deletions

View File

@@ -1592,13 +1592,20 @@ void HookMgr::OnSummoned(Creature* pCreature, Unit* pSummoner)
struct ElunaCreatureAI : ScriptedAI
{
ElunaCreatureAI(Creature* creature) : ScriptedAI(creature) {}
~ElunaCreatureAI() {}
#ifdef MANGOS
#define me m_creature
#endif
ElunaCreatureAI(Creature* creature) : ScriptedAI(creature)
{
JustRespawned();
#ifdef MANGOS
if (!me->isDead())
Reset();
#endif
}
~ElunaCreatureAI() {}
//Called at World update tick
#ifdef MANGOS
void UpdateAI(const uint32 diff) OVERRIDE
@@ -1654,6 +1661,9 @@ struct ElunaCreatureAI : ScriptedAI
void JustDied(Unit* killer) OVERRIDE
{
ScriptedAI::JustDied(killer);
#ifdef MANGOS
Reset();
#endif
int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_DIED);
if (!bind)
return;
@@ -1745,6 +1755,9 @@ struct ElunaCreatureAI : ScriptedAI
void EnterEvadeMode() OVERRIDE
{
ScriptedAI::EnterEvadeMode();
#ifdef MANGOS
Reset();
#endif
int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_LEAVE_COMBAT);
if (!bind)
return;
@@ -1829,6 +1842,13 @@ struct ElunaCreatureAI : ScriptedAI
sEluna->ExecuteCall(3, 0);
}
#ifdef MANGOS
bool IsVisible(Unit* who) const OVERRIDE
{
return me->IsWithinLOSInMap(who);
}
#endif
void MoveInLineOfSight(Unit* who) OVERRIDE
{
ScriptedAI::MoveInLineOfSight(who);
@@ -1843,7 +1863,22 @@ struct ElunaCreatureAI : ScriptedAI
sEluna->ExecuteCall(3, 0);
}
#ifndef MANGOS
//Called at creature reset either by death or evade
void Reset()
{
#ifdef TRINITY
ScriptedAI::Reset();
#endif
int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_RESET);
if (!bind)
return;
ELUNA_GUARD();
sEluna->BeginCall(bind);
sEluna->Push(sEluna->L, CREATURE_EVENT_ON_RESET);
sEluna->Push(sEluna->L, me);
sEluna->ExecuteCall(2, 0);
}
// Called when hit by a spell
void SpellHit(Unit* caster, SpellInfo const* spell) OVERRIDE
{
@@ -1876,49 +1911,7 @@ struct ElunaCreatureAI : ScriptedAI
sEluna->ExecuteCall(4, 0);
}
// Called when AI is temporarily replaced or put back when possess is applied or removed
void OnPossess(bool apply)
{
ScriptedAI::OnPossess(apply);
int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_POSSESS);
if (!bind)
return;
ELUNA_GUARD();
sEluna->BeginCall(bind);
sEluna->Push(sEluna->L, CREATURE_EVENT_ON_POSSESS);
sEluna->Push(sEluna->L, me);
sEluna->Push(sEluna->L, apply);
sEluna->ExecuteCall(3, 0);
}
//Called at creature reset either by death or evade
void Reset() OVERRIDE
{
ELUNA_GUARD();
ScriptedAI::Reset();
int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_RESET);
if (!bind)
return;
sEluna->BeginCall(bind);
sEluna->Push(sEluna->L, CREATURE_EVENT_ON_RESET);
sEluna->Push(sEluna->L, me);
sEluna->ExecuteCall(2, 0);
}
// Called in Creature::Update when deathstate = DEAD. Inherited classes may maniuplate the ability to respawn based on scripted events.
bool CanRespawn() OVERRIDE
{
ScriptedAI::CanRespawn();
int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_CAN_RESPAWN);
if (!bind)
return true;
ELUNA_GUARD();
sEluna->BeginCall(bind);
sEluna->Push(sEluna->L, CREATURE_EVENT_ON_CAN_RESPAWN);
sEluna->Push(sEluna->L, me);
sEluna->ExecuteCall(2, 0);
return true;
}
#ifndef MANGOS
// Called when the creature is summoned successfully by other creature
void IsSummonedBy(Unit* summoner) OVERRIDE
@@ -1942,20 +1935,6 @@ struct ElunaCreatureAI : ScriptedAI
sEluna->ExecuteCall(4, 0);
}
void OnCharmed(bool apply) OVERRIDE
{
ScriptedAI::OnCharmed(apply);
int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_CHARMED);
if (!bind)
return;
ELUNA_GUARD();
sEluna->BeginCall(bind);
sEluna->Push(sEluna->L, CREATURE_EVENT_ON_CHARMED);
sEluna->Push(sEluna->L, me);
sEluna->Push(sEluna->L, apply);
sEluna->ExecuteCall(3, 0);
}
// Called when owner takes damage
void OwnerAttackedBy(Unit* attacker) OVERRIDE
{
@@ -2001,36 +1980,6 @@ struct ElunaCreatureAI : ScriptedAI
sEluna->Push(sEluna->L, apply);
sEluna->ExecuteCall(5, 0);
}
void OnSpellClick(Unit* clicker, bool& result) OVERRIDE
{
ScriptedAI::OnSpellClick(clicker, result);
int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_SPELL_CLICK);
if (!bind)
return;
ELUNA_GUARD();
sEluna->BeginCall(bind);
sEluna->Push(sEluna->L, CREATURE_EVENT_ON_SPELL_CLICK);
sEluna->Push(sEluna->L, me);
sEluna->Push(sEluna->L, clicker);
sEluna->Push(sEluna->L, result);
sEluna->ExecuteCall(4, 0);
}
// Called if IsVisible(Unit* who) is true at each who move, reaction at visibility zone enter
void MoveInLineOfSight_Safe(Unit* who)
{
ScriptedAI::MoveInLineOfSight_Safe(who);
int bind = sEluna->CreatureEventBindings.GetBind(me->GetEntry(), CREATURE_EVENT_ON_VISIBLE_MOVE_IN_LOS);
if (!bind)
return;
ELUNA_GUARD();
sEluna->BeginCall(bind);
sEluna->Push(sEluna->L, CREATURE_EVENT_ON_VISIBLE_MOVE_IN_LOS);
sEluna->Push(sEluna->L, me);
sEluna->Push(sEluna->L, who);
sEluna->ExecuteCall(3, 0);
}
#endif
#ifdef MANGOS

View File

@@ -24,6 +24,7 @@
#ifdef MANGOS
typedef SpellEffectIndex SpellEffIndex;
typedef SpellEntry SpellInfo;
typedef ItemPrototype ItemTemplate;
#define GetTemplate GetProto
#ifdef CLASSIC
@@ -241,24 +242,24 @@ enum CreatureEvents
CREATURE_EVENT_ON_DAMAGE_TAKEN = 9, // (event, creature, attacker, damage)
CREATURE_EVENT_ON_PRE_COMBAT = 10, // (event, creature, target)
CREATURE_EVENT_ON_ATTACKED_AT = 11, // (event, creature, attacker)
CREATURE_EVENT_ON_OWNER_ATTACKED = 12, // (event, creature, target)
CREATURE_EVENT_ON_OWNER_ATTACKED_AT = 13, // (event, creature, attacker)
CREATURE_EVENT_ON_OWNER_ATTACKED = 12, // (event, creature, target) // Not on mangos
CREATURE_EVENT_ON_OWNER_ATTACKED_AT = 13, // (event, creature, attacker) // Not on mangos
CREATURE_EVENT_ON_HIT_BY_SPELL = 14, // (event, creature, caster, spellid)
CREATURE_EVENT_ON_SPELL_HIT_TARGET = 15, // (event, creature, target, spellid)
CREATURE_EVENT_ON_SPELL_CLICK = 16, // (event, creature, clicker)
CREATURE_EVENT_ON_CHARMED = 17, // (event, creature, apply)
CREATURE_EVENT_ON_POSSESS = 18, // (event, creature, apply)
// UNUSED = 16, // (event, creature)
// UNUSED = 17, // (event, creature)
// UNUSED = 18, // (event, creature)
CREATURE_EVENT_ON_JUST_SUMMONED_CREATURE = 19, // (event, creature, summon)
CREATURE_EVENT_ON_SUMMONED_CREATURE_DESPAWN = 20, // (event, creature, summon)
CREATURE_EVENT_ON_SUMMONED_CREATURE_DIED = 21, // (event, creature, summon, killer)
CREATURE_EVENT_ON_SUMMONED_CREATURE_DIED = 21, // (event, creature, summon, killer) // Not on mangos
CREATURE_EVENT_ON_SUMMONED = 22, // (event, creature, summoner)
CREATURE_EVENT_ON_RESET = 23, // (event, creature)
CREATURE_EVENT_ON_REACH_HOME = 24, // (event, creature)
CREATURE_EVENT_ON_CAN_RESPAWN = 25, // (event, creature)
// UNUSED = 25, // (event, creature)
CREATURE_EVENT_ON_CORPSE_REMOVED = 26, // (event, creature, respawndelay)
CREATURE_EVENT_ON_MOVE_IN_LOS = 27, // (event, creature, unit)
CREATURE_EVENT_ON_VISIBLE_MOVE_IN_LOS = 28, // (event, creature, unit)
CREATURE_EVENT_ON_PASSANGER_BOARDED = 29, // (event, creature, passanger, seatid, apply)
// UNUSED = 28, // (event, creature)
CREATURE_EVENT_ON_PASSANGER_BOARDED = 29, // (event, creature, passanger, seatid, apply) // Not on mangos
CREATURE_EVENT_ON_DUMMY_EFFECT = 30, // (event, caster, spellid, effindex, creature)
CREATURE_EVENT_ON_QUEST_ACCEPT = 31, // (event, player, creature, quest)
CREATURE_EVENT_ON_QUEST_SELECT = 32, // (event, player, creature, quest)