mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-30 05:43:12 +01:00
[7710] Fixed problem with stuck in combat creatures with EventAI. Remove redundent AI field. Author: VladimirMangos
--HG-- branch : trunk
This commit is contained in:
@@ -39,7 +39,7 @@ int CreatureEventAI::Permissible(const Creature *creature)
|
||||
return PERMIT_BASE_NO;
|
||||
}
|
||||
|
||||
CreatureEventAI::CreatureEventAI(Creature *c) : CreatureAI(c), InCombat(false)
|
||||
CreatureEventAI::CreatureEventAI(Creature *c ) : CreatureAI(c)
|
||||
{
|
||||
CreatureEventAI_Event_Map::iterator CreatureEvents = CreatureEAI_Mgr.GetCreatureEventAIMap().find(m_creature->GetEntry());
|
||||
if (CreatureEvents != CreatureEAI_Mgr.GetCreatureEventAIMap().end())
|
||||
@@ -79,6 +79,8 @@ CreatureEventAI::CreatureEventAI(Creature *c) : CreatureAI(c), InCombat(false)
|
||||
AttackDistance = 0;
|
||||
AttackAngle = 0.0f;
|
||||
|
||||
IsFleeing = false;
|
||||
|
||||
//Handle Spawned Events
|
||||
if (!bEmptyList)
|
||||
{
|
||||
@@ -140,7 +142,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
|
||||
{
|
||||
case EVENT_T_TIMER:
|
||||
{
|
||||
if (!InCombat)
|
||||
if (!m_creature->isInCombat())
|
||||
return false;
|
||||
|
||||
//Repeat Timers
|
||||
@@ -159,7 +161,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
|
||||
break;
|
||||
case EVENT_T_TIMER_OOC:
|
||||
{
|
||||
if (InCombat)
|
||||
if (m_creature->isInCombat())
|
||||
return false;
|
||||
|
||||
//Repeat Timers
|
||||
@@ -179,7 +181,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
|
||||
break;
|
||||
case EVENT_T_HP:
|
||||
{
|
||||
if (!InCombat || !m_creature->GetMaxHealth())
|
||||
if (!m_creature->isInCombat() || !m_creature->GetMaxHealth())
|
||||
return false;
|
||||
|
||||
uint32 perc = (m_creature->GetHealth()*100) / m_creature->GetMaxHealth();
|
||||
@@ -204,7 +206,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
|
||||
break;
|
||||
case EVENT_T_MANA:
|
||||
{
|
||||
if (!InCombat || !m_creature->GetMaxPower(POWER_MANA))
|
||||
if (!m_creature->isInCombat() || !m_creature->GetMaxPower(POWER_MANA))
|
||||
return false;
|
||||
|
||||
uint32 perc = (m_creature->GetPower(POWER_MANA)*100) / m_creature->GetMaxPower(POWER_MANA);
|
||||
@@ -314,7 +316,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
|
||||
break;
|
||||
case EVENT_T_TARGET_HP:
|
||||
{
|
||||
if (!InCombat || !m_creature->getVictim() || !m_creature->getVictim()->GetMaxHealth())
|
||||
if (!m_creature->isInCombat() || !m_creature->getVictim() || !m_creature->getVictim()->GetMaxHealth())
|
||||
return false;
|
||||
|
||||
uint32 perc = (m_creature->getVictim()->GetHealth()*100) / m_creature->getVictim()->GetMaxHealth();
|
||||
@@ -339,7 +341,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
|
||||
break;
|
||||
case EVENT_T_TARGET_CASTING:
|
||||
{
|
||||
if (!InCombat || !m_creature->getVictim() || !m_creature->getVictim()->IsNonMeleeSpellCasted(false, false, true))
|
||||
if (!m_creature->isInCombat() || !m_creature->getVictim() || !m_creature->getVictim()->IsNonMeleeSpellCasted(false, false, true))
|
||||
return false;
|
||||
|
||||
//Repeat Timers
|
||||
@@ -359,7 +361,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
|
||||
break;
|
||||
case EVENT_T_FRIENDLY_HP:
|
||||
{
|
||||
if (!InCombat)
|
||||
if (!m_creature->isInCombat())
|
||||
return false;
|
||||
|
||||
Unit* pUnit = DoSelectLowestHpFriendly(param2, param1);
|
||||
@@ -386,7 +388,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
|
||||
break;
|
||||
case EVENT_T_FRIENDLY_IS_CC:
|
||||
{
|
||||
if (!InCombat)
|
||||
if (!m_creature->isInCombat())
|
||||
return false;
|
||||
|
||||
std::list<Creature*> pList;
|
||||
@@ -1003,7 +1005,6 @@ void CreatureEventAI::ProcessAction(uint16 type, uint32 param1, uint32 param2, u
|
||||
|
||||
void CreatureEventAI::JustRespawned()
|
||||
{
|
||||
InCombat = false;
|
||||
IsFleeing = false;
|
||||
Reset();
|
||||
|
||||
@@ -1087,8 +1088,6 @@ void CreatureEventAI::EnterEvadeMode()
|
||||
|
||||
m_creature->SetLootRecipient(NULL);
|
||||
|
||||
InCombat = false;
|
||||
|
||||
if (bEmptyList)
|
||||
return;
|
||||
|
||||
@@ -1102,7 +1101,6 @@ void CreatureEventAI::EnterEvadeMode()
|
||||
|
||||
void CreatureEventAI::JustDied(Unit* killer)
|
||||
{
|
||||
InCombat = false;
|
||||
IsFleeing = false;
|
||||
Reset();
|
||||
|
||||
@@ -1187,13 +1185,12 @@ void CreatureEventAI::AttackStart(Unit *who)
|
||||
if (!who)
|
||||
return;
|
||||
|
||||
bool inCombat = m_creature->isInCombat();
|
||||
|
||||
if (m_creature->Attack(who, MeleeEnabled))
|
||||
{
|
||||
if (!InCombat)
|
||||
{
|
||||
InCombat = true;
|
||||
if (!inCombat)
|
||||
Aggro(who);
|
||||
}
|
||||
|
||||
if (CombatMovementEnabled)
|
||||
{
|
||||
@@ -1208,7 +1205,7 @@ void CreatureEventAI::AttackStart(Unit *who)
|
||||
|
||||
void CreatureEventAI::MoveInLineOfSight(Unit *who)
|
||||
{
|
||||
if (!who || InCombat)
|
||||
if (!who)
|
||||
return;
|
||||
|
||||
//Check for OOC LOS Event
|
||||
@@ -1263,7 +1260,7 @@ void CreatureEventAI::SpellHit(Unit* pUnit, const SpellEntry* pSpell)
|
||||
void CreatureEventAI::UpdateAI(const uint32 diff)
|
||||
{
|
||||
//Check if we are in combat (also updates calls threat update code)
|
||||
bool Combat = InCombat ? UpdateVictim() : false;
|
||||
bool Combat = UpdateVictim();
|
||||
|
||||
//Must return if creature isn't alive. Normally select hostil target and get victim prevent this
|
||||
if (!m_creature->isAlive())
|
||||
|
||||
@@ -287,8 +287,6 @@ class TRINITY_DLL_SPEC CreatureEventAI : public CreatureAI
|
||||
void DoFindFriendlyMissingBuff(std::list<Creature*>& _list, float range, uint32 spellid);
|
||||
void DoFindFriendlyCC(std::list<Creature*>& _list, float range);
|
||||
|
||||
//Bool for if we are in combat or not
|
||||
bool InCombat;
|
||||
//Holder for events (stores enabled, time, and eventid)
|
||||
std::list<CreatureEventAIHolder> CreatureEventAIList;
|
||||
uint32 EventUpdateTime; //Time between event updates
|
||||
|
||||
Reference in New Issue
Block a user