*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)
|
void 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 = InCombat ? m_creature->SelectHostilTarget() : false;
|
||||||
|
|
||||||
//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())
|
||||||
@@ -1233,11 +1233,9 @@ struct TRINITY_DLL_DECL Mob_EventAI : public ScriptedAI
|
|||||||
|
|
||||||
if (IsFleeing)
|
if (IsFleeing)
|
||||||
{
|
{
|
||||||
if(TimetoFleeLeft < diff
|
if(TimetoFleeLeft < diff)
|
||||||
|| m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != POINT_MOTION_TYPE
|
|
||||||
&& m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != FLEEING_MOTION_TYPE)
|
|
||||||
{
|
{
|
||||||
m_creature->GetMotionMaster()->Clear(false);
|
m_creature->SetControlled(false, UNIT_STAT_FLEEING);
|
||||||
m_creature->SetNoCallAssistance(false);
|
m_creature->SetNoCallAssistance(false);
|
||||||
m_creature->CallAssistance();
|
m_creature->CallAssistance();
|
||||||
if(m_creature->getVictim())
|
if(m_creature->getVictim())
|
||||||
|
|||||||
+2
-12
@@ -1870,22 +1870,12 @@ void Creature::DoFleeToGetAssistance(float radius) // Optional parameter
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Creature* pCreature = NULL;
|
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::NearestAssistCreatureInCreatureRangeCheck u_check(this,getVictim(),radius);
|
||||||
Trinity::CreatureLastSearcher<Trinity::NearestAssistCreatureInCreatureRangeCheck> searcher(pCreature, u_check);
|
Trinity::CreatureLastSearcher<Trinity::NearestAssistCreatureInCreatureRangeCheck> searcher(pCreature, u_check);
|
||||||
|
VisitNearbyGridObject(radius, searcher);
|
||||||
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()));
|
|
||||||
|
|
||||||
if(!pCreature)
|
if(!pCreature)
|
||||||
GetMotionMaster()->MoveFleeing(getVictim());
|
SetControlled(true, UNIT_STAT_FLEEING);
|
||||||
else
|
else
|
||||||
GetMotionMaster()->MovePoint(0,pCreature->GetPositionX(),pCreature->GetPositionY(),pCreature->GetPositionZ());
|
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);
|
Unit::AuraList const& fearAuras = GetAurasByType(SPELL_AURA_MOD_FEAR);
|
||||||
if(!fearAuras.empty())
|
if(!fearAuras.empty())
|
||||||
caster = ObjectAccessor::GetUnit(*this, fearAuras.front()->GetCasterGUID());
|
caster = ObjectAccessor::GetUnit(*this, fearAuras.front()->GetCasterGUID());
|
||||||
|
if(!caster) caster = getVictim();
|
||||||
GetMotionMaster()->MoveFleeing(caster); // caster==NULL processed in MoveFleeing
|
GetMotionMaster()->MoveFleeing(caster); // caster==NULL processed in MoveFleeing
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user