*Fix the bug that critters do not enterevademode.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-01-28 20:54:54 -06:00
parent 30c5bff102
commit 1d19b6bcca
3 changed files with 10 additions and 11 deletions
+3 -1
View File
@@ -21,8 +21,10 @@
#include "NullCreatureAI.h"
#include "Creature.h"
NullCreatureAI::~NullCreatureAI()
void PassiveAI::UpdateAI(const uint32)
{
if(me->isInCombat() && me->getAttackers().empty())
EnterEvadeMode();
}
void CritterAI::DamageTaken(Unit *done_by, uint32 &)
+1 -3
View File
@@ -34,7 +34,7 @@ class TRINITY_DLL_DECL PassiveAI : public CreatureAI
bool IsVisible(Unit *) const { return false; }
void UpdateAI(const uint32) {}
void UpdateAI(const uint32);
static int Permissible(const Creature *) { return PERMIT_BASE_IDLE; }
};
@@ -42,7 +42,6 @@ class TRINITY_DLL_DECL NullCreatureAI : public PassiveAI
{
public:
NullCreatureAI(Creature *c) : PassiveAI(c) {}
~NullCreatureAI();
void EnterEvadeMode() {}
};
@@ -51,7 +50,6 @@ class TRINITY_DLL_DECL CritterAI : public PassiveAI
{
public:
CritterAI(Creature *c) : PassiveAI(c) {}
~CritterAI();
void DamageTaken(Unit *done_by, uint32 & /*damage*/);
void EnterEvadeMode();
+6 -7
View File
@@ -10409,6 +10409,10 @@ Unit* Creature::SelectHostilTarget()
//next-victim-selection algorithm and evade mode are called
//threat list sorting etc.
//This should not be called by unit who does not have a threatlist
//or who does not have threat (totem/pet/critter)
//otherwise enterevademode every update
Unit* target = NULL;
//This function only useful once AI has been initialized
@@ -10446,7 +10450,7 @@ Unit* Creature::SelectHostilTarget()
for(AttackerSet::const_iterator itr = m_attackers.begin(); itr != m_attackers.end(); ++itr)
{
if( (*itr)->IsInMap(this) && canAttack(*itr) && (*itr)->isInAccessiblePlaceFor((Creature*)this) )
return false;
return NULL;
}
}*/
@@ -12902,12 +12906,7 @@ void Unit::SetFeared(bool apply)
if(!fearAuras.empty())
caster = ObjectAccessor::GetUnit(*this, fearAuras.front()->GetCasterGUID());
if(!caster)
{
if(getVictim())
caster = getVictim();
else if(m_attackers.size())
caster = *m_attackers.begin();
}
caster = getAttackerForHelper();
GetMotionMaster()->MoveFleeing(caster); // caster==NULL processed in MoveFleeing
}
else