diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game/NullCreatureAI.cpp | 4 | ||||
-rw-r--r-- | src/game/NullCreatureAI.h | 4 | ||||
-rw-r--r-- | src/game/Unit.cpp | 13 |
3 files changed, 10 insertions, 11 deletions
diff --git a/src/game/NullCreatureAI.cpp b/src/game/NullCreatureAI.cpp index 67839ab9315..164aa2f7974 100644 --- a/src/game/NullCreatureAI.cpp +++ b/src/game/NullCreatureAI.cpp @@ -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 &) diff --git a/src/game/NullCreatureAI.h b/src/game/NullCreatureAI.h index a6a072fb48e..821b42f7e76 100644 --- a/src/game/NullCreatureAI.h +++ b/src/game/NullCreatureAI.h @@ -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(); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index b2e214f915e..7c8c9179962 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -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 |