*Fix the bug that event ai mobs sometimes chase victims even when polymorphed.
--HG-- branch : trunk
This commit is contained in:
@@ -1225,7 +1225,7 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI
|
||||
void 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 = InCombat ? m_creature->SelectHostilTarget() : false;
|
||||
|
||||
//Must return if creature isn't alive. Normally select hostil target and get victim prevent this
|
||||
if (!m_creature->isAlive())
|
||||
@@ -1233,11 +1233,9 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI
|
||||
|
||||
if (IsFleeing)
|
||||
{
|
||||
if(TimetoFleeLeft < diff
|
||||
|| m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != POINT_MOTION_TYPE
|
||||
&& m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != FLEEING_MOTION_TYPE)
|
||||
if(TimetoFleeLeft < diff)
|
||||
{
|
||||
m_creature->GetMotionMaster()->Clear(false);
|
||||
m_creature->SetControlled(false, UNIT_STAT_FLEEING);
|
||||
m_creature->SetNoCallAssistance(false);
|
||||
m_creature->CallAssistance();
|
||||
if(m_creature->getVictim())
|
||||
|
||||
+2
-12
@@ -1870,22 +1870,12 @@ void Creature::DoFleeToGetAssistance(float radius) // Optional parameter
|
||||
return;
|
||||
|
||||
Creature* pCreature = NULL;
|
||||
|
||||
CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY()));
|
||||
Cell cell(p);
|
||||
cell.data.Part.reserved = ALL_DISTRICT;
|
||||
cell.SetNoCreate();
|
||||
|
||||
Trinity::NearestAssistCreatureInCreatureRangeCheck u_check(this,getVictim(),radius);
|
||||
Trinity::CreatureLastSearcher<Trinity::NearestAssistCreatureInCreatureRangeCheck> searcher(pCreature, u_check);
|
||||
|
||||
TypeContainerVisitor<Trinity::CreatureLastSearcher<Trinity::NearestAssistCreatureInCreatureRangeCheck>, GridTypeMapContainer > grid_creature_searcher(searcher);
|
||||
|
||||
CellLock<GridReadGuard> cell_lock(cell, p);
|
||||
cell_lock->Visit(cell_lock, grid_creature_searcher, *(GetMap()));
|
||||
VisitNearbyGridObject(radius, searcher);
|
||||
|
||||
if(!pCreature)
|
||||
GetMotionMaster()->MoveFleeing(getVictim());
|
||||
SetControlled(true, UNIT_STAT_FLEEING);
|
||||
else
|
||||
GetMotionMaster()->MovePoint(0,pCreature->GetPositionX(),pCreature->GetPositionY(),pCreature->GetPositionZ());
|
||||
}
|
||||
|
||||
@@ -12904,6 +12904,7 @@ void Unit::SetFeared(bool apply)
|
||||
Unit::AuraList const& fearAuras = GetAurasByType(SPELL_AURA_MOD_FEAR);
|
||||
if(!fearAuras.empty())
|
||||
caster = ObjectAccessor::GetUnit(*this, fearAuras.front()->GetCasterGUID());
|
||||
if(!caster) caster = getVictim();
|
||||
GetMotionMaster()->MoveFleeing(caster); // caster==NULL processed in MoveFleeing
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user