aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bindings/scripts/scripts/creature/mob_event_ai.cpp8
-rw-r--r--src/game/Creature.cpp14
-rw-r--r--src/game/Unit.cpp1
3 files changed, 6 insertions, 17 deletions
diff --git a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp
index eee4269e12c..6b46b7aecde 100644
--- a/src/bindings/scripts/scripts/creature/mob_event_ai.cpp
+++ b/src/bindings/scripts/scripts/creature/mob_event_ai.cpp
@@ -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())
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index 56b5ff2ed3f..553beb79509 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -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());
}
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 9d9b1fdc101..0296f7ceb4d 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -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