mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[7710] Fixed problem with stuck in combat creatures with EventAI. Remove redundent AI field.
This commit is contained in:
parent
5d9516354e
commit
ecb5a0328a
3 changed files with 14 additions and 21 deletions
|
|
@ -37,7 +37,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())
|
||||
|
|
@ -139,7 +139,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
|
|||
{
|
||||
case EVENT_T_TIMER:
|
||||
{
|
||||
if (!InCombat)
|
||||
if (!m_creature->isInCombat())
|
||||
return false;
|
||||
|
||||
//Repeat Timers
|
||||
|
|
@ -158,7 +158,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
|
|||
break;
|
||||
case EVENT_T_TIMER_OOC:
|
||||
{
|
||||
if (InCombat)
|
||||
if (m_creature->isInCombat())
|
||||
return false;
|
||||
|
||||
//Repeat Timers
|
||||
|
|
@ -178,7 +178,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();
|
||||
|
|
@ -203,7 +203,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);
|
||||
|
|
@ -313,7 +313,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();
|
||||
|
|
@ -338,7 +338,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
|
||||
|
|
@ -358,7 +358,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);
|
||||
|
|
@ -385,7 +385,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;
|
||||
|
|
@ -989,7 +989,6 @@ void CreatureEventAI::ProcessAction(uint16 type, uint32 param1, uint32 param2, u
|
|||
|
||||
void CreatureEventAI::JustRespawned()
|
||||
{
|
||||
InCombat = false;
|
||||
Reset();
|
||||
|
||||
if (bEmptyList)
|
||||
|
|
@ -1069,8 +1068,6 @@ void CreatureEventAI::EnterEvadeMode()
|
|||
|
||||
m_creature->SetLootRecipient(NULL);
|
||||
|
||||
InCombat = false;
|
||||
|
||||
if (bEmptyList)
|
||||
return;
|
||||
|
||||
|
|
@ -1084,7 +1081,6 @@ void CreatureEventAI::EnterEvadeMode()
|
|||
|
||||
void CreatureEventAI::JustDied(Unit* killer)
|
||||
{
|
||||
InCombat = false;
|
||||
Reset();
|
||||
|
||||
if (bEmptyList)
|
||||
|
|
@ -1168,17 +1164,16 @@ void CreatureEventAI::AttackStart(Unit *who)
|
|||
if (!who)
|
||||
return;
|
||||
|
||||
bool inCombat = m_creature->isInCombat();
|
||||
|
||||
if (m_creature->Attack(who, MeleeEnabled))
|
||||
{
|
||||
m_creature->AddThreat(who, 0.0f);
|
||||
m_creature->SetInCombatWith(who);
|
||||
who->SetInCombatWith(m_creature);
|
||||
|
||||
if (!InCombat)
|
||||
{
|
||||
InCombat = true;
|
||||
if (!inCombat)
|
||||
Aggro(who);
|
||||
}
|
||||
|
||||
if (CombatMovementEnabled)
|
||||
{
|
||||
|
|
@ -1268,7 +1263,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 ? (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
|
||||
if (!m_creature->isAlive())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue