mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
Make ReactorAI the default AI on mangos and allow overriding.
All AI event handlers (except OnReset) can now override the default AI behavior on both mangos and Trinity by returning true. For default behavior, return false or nothing. Fixes #124.
This commit is contained in:
@@ -44,7 +44,7 @@
|
||||
#include "revision.h"
|
||||
#else
|
||||
#include "Config/Config.h"
|
||||
#include "ReactorAI.h"
|
||||
#include "AggressorAI.h"
|
||||
#include "revision_nr.h"
|
||||
#include "BattleGroundMgr.h"
|
||||
#endif
|
||||
|
||||
280
HookMgr.cpp
280
HookMgr.cpp
@@ -19,8 +19,8 @@ extern "C"
|
||||
};
|
||||
|
||||
#ifndef TRINITY
|
||||
class ReactorAI;
|
||||
typedef ReactorAI ScriptedAI;
|
||||
class AggressorAI;
|
||||
typedef AggressorAI ScriptedAI;
|
||||
#else
|
||||
struct ScriptedAI;
|
||||
#endif
|
||||
@@ -1454,176 +1454,254 @@ void Eluna::OnRemoveFromWorld(Creature* creature)
|
||||
ENDCALL();
|
||||
}
|
||||
|
||||
void Eluna::UpdateAI(Creature* me, const uint32 diff)
|
||||
bool Eluna::UpdateAI(Creature* me, const uint32 diff)
|
||||
{
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_AIUPDATE, return);
|
||||
bool result = false;
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_AIUPDATE, return false);
|
||||
Eluna::Push(L, me);
|
||||
Eluna::Push(L, diff);
|
||||
ENTRY_EXECUTE(0);
|
||||
ENTRY_EXECUTE(1);
|
||||
FOR_RETS(i) {
|
||||
result = CHECKVAL<bool>(L, i, false);
|
||||
}
|
||||
ENDCALL();
|
||||
return result;
|
||||
}
|
||||
|
||||
//Called for reaction at enter to combat if not in combat yet (enemy can be NULL)
|
||||
//Called at creature aggro either by MoveInLOS or Attack Start
|
||||
void Eluna::EnterCombat(Creature* me, Unit* target)
|
||||
bool Eluna::EnterCombat(Creature* me, Unit* target)
|
||||
{
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_ENTER_COMBAT, return);
|
||||
bool result = false;
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_ENTER_COMBAT, return false);
|
||||
Eluna::Push(L, me);
|
||||
Eluna::Push(L, target);
|
||||
ENTRY_EXECUTE(0);
|
||||
ENTRY_EXECUTE(1);
|
||||
FOR_RETS(i) {
|
||||
result = CHECKVAL<bool>(L, i, false);
|
||||
}
|
||||
ENDCALL();
|
||||
return result;
|
||||
}
|
||||
|
||||
// Called at any Damage from any attacker (before damage apply)
|
||||
void Eluna::DamageTaken(Creature* me, Unit* attacker, uint32& damage)
|
||||
bool Eluna::DamageTaken(Creature* me, Unit* attacker, uint32& damage)
|
||||
{
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_DAMAGE_TAKEN, return);
|
||||
bool result = false;
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_DAMAGE_TAKEN, return false);
|
||||
Eluna::Push(L, me);
|
||||
Eluna::Push(L, attacker);
|
||||
Eluna::Push(L, damage);
|
||||
ENTRY_EXECUTE(1);
|
||||
ENTRY_EXECUTE(2);
|
||||
FOR_RETS(i)
|
||||
{
|
||||
if (lua_isboolean(L, i))
|
||||
result = CHECKVAL<bool>(L, i);
|
||||
if (lua_isnumber(L, i))
|
||||
damage = Eluna::CHECKVAL<uint32>(L, i, damage);
|
||||
}
|
||||
ENDCALL();
|
||||
return result;
|
||||
}
|
||||
|
||||
//Called at creature death
|
||||
void Eluna::JustDied(Creature* me, Unit* killer)
|
||||
bool Eluna::JustDied(Creature* me, Unit* killer)
|
||||
{
|
||||
On_Reset(me);
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_DIED, return);
|
||||
bool result = false;
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_DIED, return false);
|
||||
Eluna::Push(L, me);
|
||||
Eluna::Push(L, killer);
|
||||
ENTRY_EXECUTE(0);
|
||||
ENTRY_EXECUTE(1);
|
||||
FOR_RETS(i) {
|
||||
result = CHECKVAL<bool>(L, i, false);
|
||||
}
|
||||
ENDCALL();
|
||||
return result;
|
||||
}
|
||||
|
||||
//Called at creature killing another unit
|
||||
void Eluna::KilledUnit(Creature* me, Unit* victim)
|
||||
bool Eluna::KilledUnit(Creature* me, Unit* victim)
|
||||
{
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_TARGET_DIED, return);
|
||||
bool result = false;
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_TARGET_DIED, return false);
|
||||
Eluna::Push(L, me);
|
||||
Eluna::Push(L, victim);
|
||||
ENTRY_EXECUTE(0);
|
||||
ENTRY_EXECUTE(1);
|
||||
FOR_RETS(i) {
|
||||
result = CHECKVAL<bool>(L, i, false);
|
||||
}
|
||||
ENDCALL();
|
||||
return result;
|
||||
}
|
||||
|
||||
// Called when the creature summon successfully other creature
|
||||
void Eluna::JustSummoned(Creature* me, Creature* summon)
|
||||
bool Eluna::JustSummoned(Creature* me, Creature* summon)
|
||||
{
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_JUST_SUMMONED_CREATURE, return);
|
||||
bool result = false;
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_JUST_SUMMONED_CREATURE, return false);
|
||||
Eluna::Push(L, me);
|
||||
Eluna::Push(L, summon);
|
||||
ENTRY_EXECUTE(0);
|
||||
ENTRY_EXECUTE(1);
|
||||
FOR_RETS(i) {
|
||||
result = CHECKVAL<bool>(L, i, false);
|
||||
}
|
||||
ENDCALL();
|
||||
return result;
|
||||
}
|
||||
|
||||
// Called when a summoned creature is despawned
|
||||
void Eluna::SummonedCreatureDespawn(Creature* me, Creature* summon)
|
||||
bool Eluna::SummonedCreatureDespawn(Creature* me, Creature* summon)
|
||||
{
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_SUMMONED_CREATURE_DESPAWN, return);
|
||||
bool result = false;
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_SUMMONED_CREATURE_DESPAWN, return false);
|
||||
Eluna::Push(L, me);
|
||||
Eluna::Push(L, summon);
|
||||
ENTRY_EXECUTE(0);
|
||||
ENTRY_EXECUTE(1);
|
||||
FOR_RETS(i) {
|
||||
result = CHECKVAL<bool>(L, i, false);
|
||||
}
|
||||
ENDCALL();
|
||||
return result;
|
||||
}
|
||||
|
||||
//Called at waypoint reached or PointMovement end
|
||||
void Eluna::MovementInform(Creature* me, uint32 type, uint32 id)
|
||||
bool Eluna::MovementInform(Creature* me, uint32 type, uint32 id)
|
||||
{
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_REACH_WP, return);
|
||||
bool result = false;
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_REACH_WP, return false);
|
||||
Eluna::Push(L, me);
|
||||
Eluna::Push(L, type);
|
||||
Eluna::Push(L, id);
|
||||
ENTRY_EXECUTE(0);
|
||||
ENTRY_EXECUTE(1);
|
||||
FOR_RETS(i) {
|
||||
result = CHECKVAL<bool>(L, i, false);
|
||||
}
|
||||
ENDCALL();
|
||||
return result;
|
||||
}
|
||||
|
||||
// Called before EnterCombat even before the creature is in combat.
|
||||
void Eluna::AttackStart(Creature* me, Unit* target)
|
||||
bool Eluna::AttackStart(Creature* me, Unit* target)
|
||||
{
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_PRE_COMBAT, return);
|
||||
bool result = false;
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_PRE_COMBAT, return false);
|
||||
Eluna::Push(L, me);
|
||||
Eluna::Push(L, target);
|
||||
ENTRY_EXECUTE(0);
|
||||
ENTRY_EXECUTE(1);
|
||||
FOR_RETS(i) {
|
||||
result = CHECKVAL<bool>(L, i, false);
|
||||
}
|
||||
ENDCALL();
|
||||
return result;
|
||||
}
|
||||
|
||||
// Called for reaction at stopping attack at no attackers or targets
|
||||
void Eluna::EnterEvadeMode(Creature* me)
|
||||
bool Eluna::EnterEvadeMode(Creature* me)
|
||||
{
|
||||
On_Reset(me);
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_LEAVE_COMBAT, return);
|
||||
bool result = false;
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_LEAVE_COMBAT, return false);
|
||||
Eluna::Push(L, me);
|
||||
ENTRY_EXECUTE(0);
|
||||
ENTRY_EXECUTE(1);
|
||||
FOR_RETS(i) {
|
||||
result = CHECKVAL<bool>(L, i, false);
|
||||
}
|
||||
ENDCALL();
|
||||
return result;
|
||||
}
|
||||
|
||||
// Called when the creature is target of hostile action: swing, hostile spell landed, fear/etc)
|
||||
void Eluna::AttackedBy(Creature* me, Unit* attacker)
|
||||
bool Eluna::AttackedBy(Creature* me, Unit* attacker)
|
||||
{
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_ATTACKED_AT, return);
|
||||
bool result = false;
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_ATTACKED_AT, return false);
|
||||
Eluna::Push(L, me);
|
||||
Eluna::Push(L, attacker);
|
||||
ENTRY_EXECUTE(0);
|
||||
ENTRY_EXECUTE(1);
|
||||
FOR_RETS(i) {
|
||||
result = CHECKVAL<bool>(L, i, false);
|
||||
}
|
||||
ENDCALL();
|
||||
return result;
|
||||
}
|
||||
|
||||
// Called when creature is spawned or respawned (for reseting variables)
|
||||
void Eluna::JustRespawned(Creature* me)
|
||||
bool Eluna::JustRespawned(Creature* me)
|
||||
{
|
||||
On_Reset(me);
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_SPAWN, return);
|
||||
bool result = false;
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_SPAWN, return false);
|
||||
Eluna::Push(L, me);
|
||||
ENTRY_EXECUTE(0);
|
||||
ENTRY_EXECUTE(1);
|
||||
FOR_RETS(i) {
|
||||
result = CHECKVAL<bool>(L, i, false);
|
||||
}
|
||||
ENDCALL();
|
||||
return result;
|
||||
}
|
||||
|
||||
// Called at reaching home after evade
|
||||
void Eluna::JustReachedHome(Creature* me)
|
||||
bool Eluna::JustReachedHome(Creature* me)
|
||||
{
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_REACH_HOME, return);
|
||||
bool result = false;
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_REACH_HOME, return false);
|
||||
Eluna::Push(L, me);
|
||||
ENTRY_EXECUTE(0);
|
||||
ENTRY_EXECUTE(1);
|
||||
FOR_RETS(i) {
|
||||
result = CHECKVAL<bool>(L, i, false);
|
||||
}
|
||||
ENDCALL();
|
||||
return result;
|
||||
}
|
||||
|
||||
// Called at text emote receive from player
|
||||
void Eluna::ReceiveEmote(Creature* me, Player* player, uint32 emoteId)
|
||||
bool Eluna::ReceiveEmote(Creature* me, Player* player, uint32 emoteId)
|
||||
{
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_RECEIVE_EMOTE, return);
|
||||
bool result = false;
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_RECEIVE_EMOTE, return false);
|
||||
Eluna::Push(L, me);
|
||||
Eluna::Push(L, player);
|
||||
Eluna::Push(L, emoteId);
|
||||
ENTRY_EXECUTE(0);
|
||||
ENTRY_EXECUTE(1);
|
||||
FOR_RETS(i) {
|
||||
result = CHECKVAL<bool>(L, i, false);
|
||||
}
|
||||
ENDCALL();
|
||||
return result;
|
||||
}
|
||||
|
||||
// called when the corpse of this creature gets removed
|
||||
void Eluna::CorpseRemoved(Creature* me, uint32& respawnDelay)
|
||||
bool Eluna::CorpseRemoved(Creature* me, uint32& respawnDelay)
|
||||
{
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_CORPSE_REMOVED, return);
|
||||
bool result = false;
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_CORPSE_REMOVED, return false);
|
||||
Eluna::Push(L, me);
|
||||
Eluna::Push(L, respawnDelay);
|
||||
ENTRY_EXECUTE(1);
|
||||
ENTRY_EXECUTE(2);
|
||||
FOR_RETS(i)
|
||||
{
|
||||
if (lua_isboolean(L, i))
|
||||
result = Eluna::CHECKVAL<bool>(L, i);
|
||||
if (lua_isnumber(L, i))
|
||||
respawnDelay = Eluna::CHECKVAL<uint32>(L, i, respawnDelay);
|
||||
}
|
||||
ENDCALL();
|
||||
return result;
|
||||
}
|
||||
|
||||
void Eluna::MoveInLineOfSight(Creature* me, Unit* who)
|
||||
bool Eluna::MoveInLineOfSight(Creature* me, Unit* who)
|
||||
{
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_MOVE_IN_LOS, return);
|
||||
bool result = false;
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_MOVE_IN_LOS, return false);
|
||||
Eluna::Push(L, me);
|
||||
Eluna::Push(L, who);
|
||||
ENTRY_EXECUTE(0);
|
||||
ENTRY_EXECUTE(1);
|
||||
FOR_RETS(i) {
|
||||
result = CHECKVAL<bool>(L, i, false);
|
||||
}
|
||||
ENDCALL();
|
||||
return result;
|
||||
}
|
||||
|
||||
// Called on creature initial spawn, respawn, death, evade (leave combat)
|
||||
@@ -1636,57 +1714,82 @@ void Eluna::On_Reset(Creature* me) // Not an override, custom
|
||||
}
|
||||
|
||||
// Called when hit by a spell
|
||||
void Eluna::SpellHit(Creature* me, Unit* caster, SpellInfo const* spell)
|
||||
bool Eluna::SpellHit(Creature* me, Unit* caster, SpellInfo const* spell)
|
||||
{
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_HIT_BY_SPELL, return);
|
||||
bool result = false;
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_HIT_BY_SPELL, return false);
|
||||
Eluna::Push(L, me);
|
||||
Eluna::Push(L, caster);
|
||||
Eluna::Push(L, spell->Id); // Pass spell object?
|
||||
ENTRY_EXECUTE(0);
|
||||
ENTRY_EXECUTE(1);
|
||||
FOR_RETS(i) {
|
||||
result = CHECKVAL<bool>(L, i, false);
|
||||
}
|
||||
ENDCALL();
|
||||
return result;
|
||||
}
|
||||
|
||||
// Called when spell hits a target
|
||||
void Eluna::SpellHitTarget(Creature* me, Unit* target, SpellInfo const* spell)
|
||||
bool Eluna::SpellHitTarget(Creature* me, Unit* target, SpellInfo const* spell)
|
||||
{
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_SPELL_HIT_TARGET, return);
|
||||
bool result = false;
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_SPELL_HIT_TARGET, return false);
|
||||
Eluna::Push(L, me);
|
||||
Eluna::Push(L, target);
|
||||
Eluna::Push(L, spell->Id); // Pass spell object?
|
||||
ENTRY_EXECUTE(0);
|
||||
ENTRY_EXECUTE(1);
|
||||
FOR_RETS(i) {
|
||||
result = CHECKVAL<bool>(L, i, false);
|
||||
}
|
||||
ENDCALL();
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef TRINITY
|
||||
|
||||
void Eluna::SummonedCreatureDies(Creature* me, Creature* summon, Unit* killer)
|
||||
bool Eluna::SummonedCreatureDies(Creature* me, Creature* summon, Unit* killer)
|
||||
{
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_SUMMONED_CREATURE_DIED, return);
|
||||
bool result = false;
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_SUMMONED_CREATURE_DIED, return false);
|
||||
Eluna::Push(L, me);
|
||||
Eluna::Push(L, summon);
|
||||
Eluna::Push(L, killer);
|
||||
ENTRY_EXECUTE(0);
|
||||
ENTRY_EXECUTE(1);
|
||||
FOR_RETS(i) {
|
||||
result = CHECKVAL<bool>(L, i, false);
|
||||
}
|
||||
ENDCALL();
|
||||
return result;
|
||||
}
|
||||
|
||||
// Called when owner takes damage
|
||||
void Eluna::OwnerAttackedBy(Creature* me, Unit* attacker)
|
||||
bool Eluna::OwnerAttackedBy(Creature* me, Unit* attacker)
|
||||
{
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_OWNER_ATTACKED_AT, return);
|
||||
bool result = false;
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_OWNER_ATTACKED_AT, return false);
|
||||
Eluna::Push(L, me);
|
||||
Eluna::Push(L, attacker);
|
||||
ENTRY_EXECUTE(0);
|
||||
ENTRY_EXECUTE(1);
|
||||
FOR_RETS(i) {
|
||||
result = CHECKVAL<bool>(L, i, false);
|
||||
}
|
||||
ENDCALL();
|
||||
return result;
|
||||
}
|
||||
|
||||
// Called when owner attacks something
|
||||
void Eluna::OwnerAttacked(Creature* me, Unit* target)
|
||||
bool Eluna::OwnerAttacked(Creature* me, Unit* target)
|
||||
{
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_OWNER_ATTACKED, return);
|
||||
bool result = false;
|
||||
ENTRY_BEGIN(CreatureEventBindings, me->GetEntry(), CREATURE_EVENT_ON_OWNER_ATTACKED, return false);
|
||||
Eluna::Push(L, me);
|
||||
Eluna::Push(L, target);
|
||||
ENTRY_EXECUTE(0);
|
||||
ENTRY_EXECUTE(1);
|
||||
FOR_RETS(i) {
|
||||
result = CHECKVAL<bool>(L, i, false);
|
||||
}
|
||||
ENDCALL();
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1709,6 +1812,8 @@ struct ElunaCreatureAI : ScriptedAI
|
||||
void UpdateAI(uint32 diff) override
|
||||
#endif
|
||||
{
|
||||
if (!sEluna->UpdateAI(me, diff))
|
||||
{
|
||||
#ifdef TRINITY
|
||||
if (!me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC))
|
||||
ScriptedAI::UpdateAI(diff);
|
||||
@@ -1716,107 +1821,106 @@ struct ElunaCreatureAI : ScriptedAI
|
||||
if (!me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE))
|
||||
ScriptedAI::UpdateAI(diff);
|
||||
#endif
|
||||
|
||||
sEluna->UpdateAI(me, diff);
|
||||
}
|
||||
}
|
||||
|
||||
//Called for reaction at enter to combat if not in combat yet (enemy can be NULL)
|
||||
//Called at creature aggro either by MoveInLOS or Attack Start
|
||||
void EnterCombat(Unit* target) override
|
||||
{
|
||||
if (!sEluna->EnterCombat(me, target))
|
||||
ScriptedAI::EnterCombat(target);
|
||||
sEluna->EnterCombat(me, target);
|
||||
}
|
||||
|
||||
// Called at any Damage from any attacker (before damage apply)
|
||||
void DamageTaken(Unit* attacker, uint32& damage) override
|
||||
{
|
||||
if (!sEluna->DamageTaken(me, attacker, damage))
|
||||
ScriptedAI::DamageTaken(attacker, damage);
|
||||
sEluna->DamageTaken(me, attacker, damage);
|
||||
}
|
||||
|
||||
//Called at creature death
|
||||
void JustDied(Unit* killer) override
|
||||
{
|
||||
if (!sEluna->JustDied(me, killer))
|
||||
ScriptedAI::JustDied(killer);
|
||||
sEluna->JustDied(me, killer);
|
||||
}
|
||||
|
||||
//Called at creature killing another unit
|
||||
void KilledUnit(Unit* victim) override
|
||||
{
|
||||
if (!sEluna->KilledUnit(me, victim))
|
||||
ScriptedAI::KilledUnit(victim);
|
||||
sEluna->KilledUnit(me, victim);
|
||||
}
|
||||
|
||||
// Called when the creature summon successfully other creature
|
||||
void JustSummoned(Creature* summon) override
|
||||
{
|
||||
if (!sEluna->JustSummoned(me, summon))
|
||||
ScriptedAI::JustSummoned(summon);
|
||||
sEluna->JustSummoned(me, summon);
|
||||
}
|
||||
|
||||
// Called when a summoned creature is despawned
|
||||
void SummonedCreatureDespawn(Creature* summon) override
|
||||
{
|
||||
if (!sEluna->SummonedCreatureDespawn(me, summon))
|
||||
ScriptedAI::SummonedCreatureDespawn(summon);
|
||||
sEluna->SummonedCreatureDespawn(me, summon);
|
||||
}
|
||||
|
||||
//Called at waypoint reached or PointMovement end
|
||||
void MovementInform(uint32 type, uint32 id) override
|
||||
{
|
||||
if (!sEluna->MovementInform(me, type, id))
|
||||
ScriptedAI::MovementInform(type, id);
|
||||
sEluna->MovementInform(me, type, id);
|
||||
}
|
||||
|
||||
// Called before EnterCombat even before the creature is in combat.
|
||||
void AttackStart(Unit* target) override
|
||||
{
|
||||
if (!sEluna->AttackStart(me, target))
|
||||
ScriptedAI::AttackStart(target);
|
||||
sEluna->AttackStart(me, target);
|
||||
}
|
||||
|
||||
// Called for reaction at stopping attack at no attackers or targets
|
||||
void EnterEvadeMode() override
|
||||
{
|
||||
if (!sEluna->EnterEvadeMode(me))
|
||||
ScriptedAI::EnterEvadeMode();
|
||||
sEluna->EnterEvadeMode(me);
|
||||
}
|
||||
|
||||
// Called when the creature is target of hostile action: swing, hostile spell landed, fear/etc)
|
||||
void AttackedBy(Unit* attacker) override
|
||||
{
|
||||
if (!sEluna->AttackedBy(me, attacker))
|
||||
ScriptedAI::AttackedBy(attacker);
|
||||
sEluna->AttackedBy(me, attacker);
|
||||
}
|
||||
|
||||
// Called when creature is spawned or respawned (for reseting variables)
|
||||
void JustRespawned() override
|
||||
{
|
||||
if (!sEluna->JustRespawned(me))
|
||||
ScriptedAI::JustRespawned();
|
||||
sEluna->JustRespawned(me);
|
||||
}
|
||||
|
||||
// Called at reaching home after evade
|
||||
void JustReachedHome() override
|
||||
{
|
||||
if (!sEluna->JustReachedHome(me))
|
||||
ScriptedAI::JustReachedHome();
|
||||
sEluna->JustReachedHome(me);
|
||||
}
|
||||
|
||||
// Called at text emote receive from player
|
||||
void ReceiveEmote(Player* player, uint32 emoteId) override
|
||||
{
|
||||
if (!sEluna->ReceiveEmote(me, player, emoteId))
|
||||
ScriptedAI::ReceiveEmote(player, emoteId);
|
||||
sEluna->ReceiveEmote(me, player, emoteId);
|
||||
}
|
||||
|
||||
// called when the corpse of this creature gets removed
|
||||
void CorpseRemoved(uint32& respawnDelay) override
|
||||
{
|
||||
if (!sEluna->CorpseRemoved(me, respawnDelay))
|
||||
ScriptedAI::CorpseRemoved(respawnDelay);
|
||||
sEluna->CorpseRemoved(me, respawnDelay);
|
||||
}
|
||||
|
||||
#ifndef TRINITY
|
||||
@@ -1829,22 +1933,22 @@ struct ElunaCreatureAI : ScriptedAI
|
||||
|
||||
void MoveInLineOfSight(Unit* who) override
|
||||
{
|
||||
if (!sEluna->MoveInLineOfSight(me, who))
|
||||
ScriptedAI::MoveInLineOfSight(who);
|
||||
sEluna->MoveInLineOfSight(me, who);
|
||||
}
|
||||
|
||||
// Called when hit by a spell
|
||||
void SpellHit(Unit* caster, SpellInfo const* spell) override
|
||||
{
|
||||
if (!sEluna->SpellHit(me, caster, spell))
|
||||
ScriptedAI::SpellHit(caster, spell);
|
||||
sEluna->SpellHit(me, caster, spell);
|
||||
}
|
||||
|
||||
// Called when spell hits a target
|
||||
void SpellHitTarget(Unit* target, SpellInfo const* spell) override
|
||||
{
|
||||
if (!sEluna->SpellHitTarget(me, target, spell))
|
||||
ScriptedAI::SpellHitTarget(target, spell);
|
||||
sEluna->SpellHitTarget(me, target, spell);
|
||||
}
|
||||
|
||||
#ifdef TRINITY
|
||||
@@ -1852,28 +1956,28 @@ struct ElunaCreatureAI : ScriptedAI
|
||||
// Called when the creature is summoned successfully by other creature
|
||||
void IsSummonedBy(Unit* summoner) override
|
||||
{
|
||||
if (!sEluna->OnSummoned(me, summoner))
|
||||
ScriptedAI::IsSummonedBy(summoner);
|
||||
sEluna->OnSummoned(me, summoner);
|
||||
}
|
||||
|
||||
void SummonedCreatureDies(Creature* summon, Unit* killer) override
|
||||
{
|
||||
if (!sEluna->SummonedCreatureDies(me, summon, killer))
|
||||
ScriptedAI::SummonedCreatureDies(summon, killer);
|
||||
sEluna->SummonedCreatureDies(me, summon, killer);
|
||||
}
|
||||
|
||||
// Called when owner takes damage
|
||||
void OwnerAttackedBy(Unit* attacker) override
|
||||
{
|
||||
if (!sEluna->OwnerAttackedBy(me, attacker))
|
||||
ScriptedAI::OwnerAttackedBy(attacker);
|
||||
sEluna->OwnerAttackedBy(me, attacker);
|
||||
}
|
||||
|
||||
// Called when owner attacks something
|
||||
void OwnerAttacked(Unit* target) override
|
||||
{
|
||||
if (!sEluna->OwnerAttacked(me, target))
|
||||
ScriptedAI::OwnerAttacked(target);
|
||||
sEluna->OwnerAttacked(me, target);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
41
LuaEngine.h
41
LuaEngine.h
@@ -227,27 +227,28 @@ public:
|
||||
uint32 GetDialogStatus(Player* pPlayer, Creature* pCreature);
|
||||
void OnSummoned(Creature* creature, Unit* summoner);
|
||||
|
||||
void UpdateAI(Creature* me, const uint32 diff);
|
||||
void EnterCombat(Creature* me, Unit* target);
|
||||
void DamageTaken(Creature* me, Unit* attacker, uint32& damage); void JustDied(Creature* me, Unit* killer);
|
||||
void KilledUnit(Creature* me, Unit* victim);
|
||||
void JustSummoned(Creature* me, Creature* summon);
|
||||
void SummonedCreatureDespawn(Creature* me, Creature* summon);
|
||||
void MovementInform(Creature* me, uint32 type, uint32 id);
|
||||
void AttackStart(Creature* me, Unit* target);
|
||||
void EnterEvadeMode(Creature* me);
|
||||
void AttackedBy(Creature* me, Unit* attacker);
|
||||
void JustRespawned(Creature* me);
|
||||
void JustReachedHome(Creature* me);
|
||||
void ReceiveEmote(Creature* me, Player* player, uint32 emoteId);
|
||||
void CorpseRemoved(Creature* me, uint32& respawnDelay);
|
||||
void MoveInLineOfSight(Creature* me, Unit* who);
|
||||
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 AttackedBy(Creature* me, Unit* attacker);
|
||||
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, Unit* caster, SpellInfo const* spell);
|
||||
bool SpellHitTarget(Creature* me, Unit* 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);
|
||||
void SpellHit(Creature* me, Unit* caster, SpellInfo const* spell);
|
||||
void SpellHitTarget(Creature* me, Unit* target, SpellInfo const* spell);
|
||||
void SummonedCreatureDies(Creature* me, Creature* summon, Unit* killer);
|
||||
void OwnerAttackedBy(Creature* me, Unit* attacker);
|
||||
void OwnerAttacked(Creature* me, Unit* target);
|
||||
|
||||
/* GameObject */
|
||||
bool OnDummyEffect(Unit* pCaster, uint32 spellId, SpellEffIndex effIndex, GameObject* pTarget);
|
||||
|
||||
Reference in New Issue
Block a user