[7710] Fixed problem with stuck in combat creatures with EventAI. Remove redundent AI field.

This commit is contained in:
VladimirMangos 2009-04-24 18:55:04 +04:00
parent 5d9516354e
commit ecb5a0328a
3 changed files with 14 additions and 21 deletions

View file

@ -37,7 +37,7 @@ int CreatureEventAI::Permissible(const Creature *creature)
return PERMIT_BASE_NO; 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()); CreatureEventAI_Event_Map::iterator CreatureEvents = CreatureEAI_Mgr.GetCreatureEventAIMap().find(m_creature->GetEntry());
if (CreatureEvents != CreatureEAI_Mgr.GetCreatureEventAIMap().end()) if (CreatureEvents != CreatureEAI_Mgr.GetCreatureEventAIMap().end())
@ -139,7 +139,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
{ {
case EVENT_T_TIMER: case EVENT_T_TIMER:
{ {
if (!InCombat) if (!m_creature->isInCombat())
return false; return false;
//Repeat Timers //Repeat Timers
@ -158,7 +158,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
break; break;
case EVENT_T_TIMER_OOC: case EVENT_T_TIMER_OOC:
{ {
if (InCombat) if (m_creature->isInCombat())
return false; return false;
//Repeat Timers //Repeat Timers
@ -178,7 +178,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
break; break;
case EVENT_T_HP: case EVENT_T_HP:
{ {
if (!InCombat || !m_creature->GetMaxHealth()) if (!m_creature->isInCombat() || !m_creature->GetMaxHealth())
return false; return false;
uint32 perc = (m_creature->GetHealth()*100) / m_creature->GetMaxHealth(); uint32 perc = (m_creature->GetHealth()*100) / m_creature->GetMaxHealth();
@ -203,7 +203,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
break; break;
case EVENT_T_MANA: case EVENT_T_MANA:
{ {
if (!InCombat || !m_creature->GetMaxPower(POWER_MANA)) if (!m_creature->isInCombat() || !m_creature->GetMaxPower(POWER_MANA))
return false; return false;
uint32 perc = (m_creature->GetPower(POWER_MANA)*100) / m_creature->GetMaxPower(POWER_MANA); uint32 perc = (m_creature->GetPower(POWER_MANA)*100) / m_creature->GetMaxPower(POWER_MANA);
@ -313,7 +313,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
break; break;
case EVENT_T_TARGET_HP: 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; return false;
uint32 perc = (m_creature->getVictim()->GetHealth()*100) / m_creature->getVictim()->GetMaxHealth(); uint32 perc = (m_creature->getVictim()->GetHealth()*100) / m_creature->getVictim()->GetMaxHealth();
@ -338,7 +338,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
break; break;
case EVENT_T_TARGET_CASTING: 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; return false;
//Repeat Timers //Repeat Timers
@ -358,7 +358,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
break; break;
case EVENT_T_FRIENDLY_HP: case EVENT_T_FRIENDLY_HP:
{ {
if (!InCombat) if (!m_creature->isInCombat())
return false; return false;
Unit* pUnit = DoSelectLowestHpFriendly(param2, param1); Unit* pUnit = DoSelectLowestHpFriendly(param2, param1);
@ -385,7 +385,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
break; break;
case EVENT_T_FRIENDLY_IS_CC: case EVENT_T_FRIENDLY_IS_CC:
{ {
if (!InCombat) if (!m_creature->isInCombat())
return false; return false;
std::list<Creature*> pList; std::list<Creature*> pList;
@ -989,7 +989,6 @@ void CreatureEventAI::ProcessAction(uint16 type, uint32 param1, uint32 param2, u
void CreatureEventAI::JustRespawned() void CreatureEventAI::JustRespawned()
{ {
InCombat = false;
Reset(); Reset();
if (bEmptyList) if (bEmptyList)
@ -1069,8 +1068,6 @@ void CreatureEventAI::EnterEvadeMode()
m_creature->SetLootRecipient(NULL); m_creature->SetLootRecipient(NULL);
InCombat = false;
if (bEmptyList) if (bEmptyList)
return; return;
@ -1084,7 +1081,6 @@ void CreatureEventAI::EnterEvadeMode()
void CreatureEventAI::JustDied(Unit* killer) void CreatureEventAI::JustDied(Unit* killer)
{ {
InCombat = false;
Reset(); Reset();
if (bEmptyList) if (bEmptyList)
@ -1168,17 +1164,16 @@ void CreatureEventAI::AttackStart(Unit *who)
if (!who) if (!who)
return; return;
bool inCombat = m_creature->isInCombat();
if (m_creature->Attack(who, MeleeEnabled)) if (m_creature->Attack(who, MeleeEnabled))
{ {
m_creature->AddThreat(who, 0.0f); m_creature->AddThreat(who, 0.0f);
m_creature->SetInCombatWith(who); m_creature->SetInCombatWith(who);
who->SetInCombatWith(m_creature); who->SetInCombatWith(m_creature);
if (!InCombat) if (!inCombat)
{
InCombat = true;
Aggro(who); Aggro(who);
}
if (CombatMovementEnabled) if (CombatMovementEnabled)
{ {
@ -1268,7 +1263,7 @@ void CreatureEventAI::SpellHit(Unit* pUnit, const SpellEntry* pSpell)
void CreatureEventAI::UpdateAI(const uint32 diff) void CreatureEventAI::UpdateAI(const uint32 diff)
{ {
//Check if we are in combat (also updates calls threat update code) //Check if we are in combat (also updates calls threat update code)
bool Combat = InCombat ? (m_creature->SelectHostilTarget() && m_creature->getVictim()) : false; bool Combat = m_creature->SelectHostilTarget() && m_creature->getVictim();
//Must return if creature isn't alive. Normally select hostil target and get victim prevent this //Must return if creature isn't alive. Normally select hostil target and get victim prevent this
if (!m_creature->isAlive()) if (!m_creature->isAlive())

View file

@ -285,8 +285,6 @@ class MANGOS_DLL_SPEC CreatureEventAI : public CreatureAI
void DoFindFriendlyMissingBuff(std::list<Creature*>& _list, float range, uint32 spellid); void DoFindFriendlyMissingBuff(std::list<Creature*>& _list, float range, uint32 spellid);
void DoFindFriendlyCC(std::list<Creature*>& _list, float range); 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) //Holder for events (stores enabled, time, and eventid)
std::list<CreatureEventAIHolder> CreatureEventAIList; std::list<CreatureEventAIHolder> CreatureEventAIList;
uint32 EventUpdateTime; //Time between event updates uint32 EventUpdateTime; //Time between event updates

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "7709" #define REVISION_NR "7710"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__