aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/ConfusedMovementGenerator.cpp6
-rw-r--r--src/game/Creature.cpp12
-rw-r--r--src/game/FleeingMovementGenerator.cpp9
-rw-r--r--src/game/Level2.cpp2
-rw-r--r--src/game/Level3.cpp20
-rw-r--r--src/game/MotionMaster.cpp80
-rw-r--r--src/game/MotionMaster.h38
-rw-r--r--src/game/Unit.cpp36
-rw-r--r--src/game/Unit.h2
9 files changed, 118 insertions, 87 deletions
diff --git a/src/game/ConfusedMovementGenerator.cpp b/src/game/ConfusedMovementGenerator.cpp
index 1163d7249cb..ad8bab6e369 100644
--- a/src/game/ConfusedMovementGenerator.cpp
+++ b/src/game/ConfusedMovementGenerator.cpp
@@ -65,6 +65,9 @@ ConfusedMovementGenerator<T>::Initialize(T &unit)
i_waypoints[idx][2] = z;
}
+ unit.SetUInt64Value(UNIT_FIELD_TARGET, 0);
+ unit.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED);
+ unit.CastStop();
unit.StopMoving();
unit.RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
unit.addUnitState(UNIT_STAT_CONFUSED);
@@ -144,7 +147,10 @@ template<class T>
void
ConfusedMovementGenerator<T>::Finalize(T &unit)
{
+ unit.RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED);
unit.clearUnitState(UNIT_STAT_CONFUSED);
+ if(unit.GetTypeId() == TYPEID_UNIT && unit.getVictim())
+ unit.SetUInt64Value(UNIT_FIELD_TARGET, unit.getVictim()->GetGUID());
}
template void ConfusedMovementGenerator<Player>::Initialize(Player &player);
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index 6ad520407cd..8c72efff03d 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -1872,18 +1872,10 @@ void Creature::DoFleeToGetAssistance(float radius) // Optional parameter
CellLock<GridReadGuard> cell_lock(cell, p);
cell_lock->Visit(cell_lock, grid_creature_searcher, *(GetMap()));
- if(!GetMotionMaster()->empty() && (GetMotionMaster()->GetCurrentMovementGeneratorType() != POINT_MOTION_TYPE))
- GetMotionMaster()->Clear(false);
- if(pCreature == NULL)
- {
- GetMotionMaster()->MoveIdle();
+ if(!pCreature)
GetMotionMaster()->MoveFleeing(getVictim());
- }
else
- {
- GetMotionMaster()->MoveIdle();
GetMotionMaster()->MovePoint(0,pCreature->GetPositionX(),pCreature->GetPositionY(),pCreature->GetPositionZ());
- }
}
Unit* Creature::SelectNearestTarget(float dist) const
@@ -2143,7 +2135,7 @@ bool Creature::HasSpellCooldown(uint32 spell_id) const
bool Creature::IsInEvadeMode() const
{
- return !i_motionMaster.empty() && i_motionMaster.GetCurrentMovementGeneratorType() == HOME_MOTION_TYPE;
+ return /*!i_motionMaster.empty() &&*/ i_motionMaster.GetCurrentMovementGeneratorType() == HOME_MOTION_TYPE;
}
bool Creature::HasSpell(uint32 spellID) const
diff --git a/src/game/FleeingMovementGenerator.cpp b/src/game/FleeingMovementGenerator.cpp
index 69c2c37dffe..6566ad4320e 100644
--- a/src/game/FleeingMovementGenerator.cpp
+++ b/src/game/FleeingMovementGenerator.cpp
@@ -306,6 +306,10 @@ FleeingMovementGenerator<T>::Initialize(T &owner)
return;
_Init(owner);
+ owner.CastStop();
+ owner.addUnitState(UNIT_STAT_FLEEING);
+ owner.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING);
+ owner.SetUInt64Value(UNIT_FIELD_TARGET, 0);
owner.RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
i_caster_x = fright->GetPositionX();
i_caster_y = fright->GetPositionY();
@@ -323,7 +327,7 @@ FleeingMovementGenerator<Creature>::_Init(Creature &owner)
{
if(!&owner)
return;
- owner.SetUInt64Value(UNIT_FIELD_TARGET, 0);
+
is_water_ok = owner.canSwim();
is_land_ok = owner.canWalk();
}
@@ -340,7 +344,10 @@ template<class T>
void
FleeingMovementGenerator<T>::Finalize(T &owner)
{
+ owner.RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING);
owner.clearUnitState(UNIT_STAT_FLEEING);
+ if(owner.GetTypeId() == TYPEID_UNIT && owner.getVictim())
+ owner.SetUInt64Value(UNIT_FIELD_TARGET, owner.getVictim()->GetGUID());
}
template<class T>
diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp
index 85eef6a6da5..d926c153e65 100644
--- a/src/game/Level2.cpp
+++ b/src/game/Level2.cpp
@@ -3728,7 +3728,7 @@ bool ChatHandler::HandleNpcUnFollowCommand(const char* /*args*/)
return false;
}
- if (creature->GetMotionMaster()->empty() ||
+ if (/*creature->GetMotionMaster()->empty() ||*/
creature->GetMotionMaster()->GetCurrentMovementGeneratorType ()!=TARGETED_MOTION_TYPE)
{
PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU);
diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp
index c14320fd68c..b896164cade 100644
--- a/src/game/Level3.cpp
+++ b/src/game/Level3.cpp
@@ -5762,9 +5762,15 @@ bool ChatHandler::HandleMovegensCommand(const char* /*args*/)
PSendSysMessage(LANG_MOVEGENS_LIST,(unit->GetTypeId()==TYPEID_PLAYER ? "Player" : "Creature" ),unit->GetGUIDLow());
MotionMaster* mm = unit->GetMotionMaster();
- for(MotionMaster::const_iterator itr = mm->begin(); itr != mm->end(); ++itr)
+ for(int i = 0; i < MAX_MOTION_SLOT; ++i)
{
- switch((*itr)->GetMovementGeneratorType())
+ MovementGenerator* mg = mm->GetMotionSlot(i);
+ if(!mg)
+ {
+ SendSysMessage("Empty");
+ continue;
+ }
+ switch(mg->GetMovementGeneratorType())
{
case IDLE_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_IDLE); break;
case RANDOM_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_RANDOM); break;
@@ -5775,7 +5781,7 @@ bool ChatHandler::HandleMovegensCommand(const char* /*args*/)
{
if(unit->GetTypeId()==TYPEID_PLAYER)
{
- TargetedMovementGenerator<Player> const* mgen = static_cast<TargetedMovementGenerator<Player> const*>(*itr);
+ TargetedMovementGenerator<Player> const* mgen = static_cast<TargetedMovementGenerator<Player> const*>(mg);
Unit* target = mgen->GetTarget();
if(target)
PSendSysMessage(LANG_MOVEGENS_TARGETED_PLAYER,target->GetName(),target->GetGUIDLow());
@@ -5784,7 +5790,7 @@ bool ChatHandler::HandleMovegensCommand(const char* /*args*/)
}
else
{
- TargetedMovementGenerator<Creature> const* mgen = static_cast<TargetedMovementGenerator<Creature> const*>(*itr);
+ TargetedMovementGenerator<Creature> const* mgen = static_cast<TargetedMovementGenerator<Creature> const*>(mg);
Unit* target = mgen->GetTarget();
if(target)
PSendSysMessage(LANG_MOVEGENS_TARGETED_CREATURE,target->GetName(),target->GetGUIDLow());
@@ -5797,7 +5803,7 @@ bool ChatHandler::HandleMovegensCommand(const char* /*args*/)
if(unit->GetTypeId()==TYPEID_UNIT)
{
float x,y,z;
- (*itr)->GetDestination(x,y,z);
+ mg->GetDestination(x,y,z);
PSendSysMessage(LANG_MOVEGENS_HOME_CREATURE,x,y,z);
}
else
@@ -5807,14 +5813,14 @@ bool ChatHandler::HandleMovegensCommand(const char* /*args*/)
case POINT_MOTION_TYPE:
{
float x,y,z;
- (*itr)->GetDestination(x,y,z);
+ mg->GetDestination(x,y,z);
PSendSysMessage(LANG_MOVEGENS_POINT,x,y,z);
break;
}
case FLEEING_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_FEAR); break;
case DISTRACT_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_DISTRACT); break;
default:
- PSendSysMessage(LANG_MOVEGENS_UNKNOWN,(*itr)->GetMovementGeneratorType());
+ PSendSysMessage(LANG_MOVEGENS_UNKNOWN,mg->GetMovementGeneratorType());
break;
}
}
diff --git a/src/game/MotionMaster.cpp b/src/game/MotionMaster.cpp
index 36bdbbb3a01..5d9059b468d 100644
--- a/src/game/MotionMaster.cpp
+++ b/src/game/MotionMaster.cpp
@@ -111,7 +111,7 @@ MotionMaster::MoveRandom(float spawndist)
if(i_owner->GetTypeId()==TYPEID_UNIT)
{
DEBUG_LOG("Creature (GUID: %u) start moving random", i_owner->GetGUIDLow() );
- Mutate(new RandomMovementGenerator<Creature>(spawndist));
+ Mutate(new RandomMovementGenerator<Creature>(spawndist), MOTION_SLOT_IDLE);
}
}
@@ -129,23 +129,27 @@ MotionMaster::MovementExpired(bool reset)
delete curr;
assert( !empty() );
- while( !empty() && top()->GetMovementGeneratorType() == TARGETED_MOTION_TYPE )
+ while(!top())
+ --i_top;
+ /*while( !empty() && top()->GetMovementGeneratorType() == TARGETED_MOTION_TYPE )
{
// Should check if target is still valid? If not valid it will crash.
curr = top();
curr->Finalize(*i_owner);
pop();
delete curr;
- }
+ }*/
if( empty() )
Initialize();
if (reset) top()->Reset(*i_owner);
}
-void MotionMaster::MoveIdle()
+void MotionMaster::MoveIdle(MovementSlot slot)
{
- if( empty() || !isStatic( top() ) )
- push( &si_idleMovement );
+ //if( empty() || !isStatic( top() ) )
+ // push( &si_idleMovement );
+ if(!isStatic(Impl[slot]))
+ Mutate(&si_idleMovement, slot);
}
void
@@ -159,7 +163,7 @@ MotionMaster::MoveTargetedHome()
if(i_owner->GetTypeId()==TYPEID_UNIT && !((Creature*)i_owner)->GetCharmerOrOwnerGUID())
{
DEBUG_LOG("Creature (Entry: %u GUID: %u) targeted home", i_owner->GetEntry(), i_owner->GetGUIDLow());
- Mutate(new HomeMovementGenerator<Creature>());
+ Mutate(new HomeMovementGenerator<Creature>(), MOTION_SLOT_ACTIVE);
}
else if(i_owner->GetTypeId()==TYPEID_UNIT && ((Creature*)i_owner)->GetCharmerOrOwnerGUID())
{
@@ -172,7 +176,7 @@ MotionMaster::MoveTargetedHome()
DEBUG_LOG("Following %s (GUID: %u)",
target->GetTypeId()==TYPEID_PLAYER ? "player" : "creature",
target->GetTypeId()==TYPEID_PLAYER ? target->GetGUIDLow() : ((Creature*)target)->GetDBTableGUIDLow() );
- Mutate(new TargetedMovementGenerator<Creature>(*target,PET_FOLLOW_DIST,PET_FOLLOW_ANGLE));
+ Mutate(new TargetedMovementGenerator<Creature>(*target,PET_FOLLOW_DIST,PET_FOLLOW_ANGLE), MOTION_SLOT_ACTIVE);
}
}
else
@@ -187,13 +191,13 @@ MotionMaster::MoveConfused()
if(i_owner->GetTypeId()==TYPEID_PLAYER)
{
DEBUG_LOG("Player (GUID: %u) move confused", i_owner->GetGUIDLow() );
- Mutate(new ConfusedMovementGenerator<Player>());
+ Mutate(new ConfusedMovementGenerator<Player>(), MOTION_SLOT_CONTROLLED);
}
else
{
DEBUG_LOG("Creature (Entry: %u GUID: %u) move confused",
i_owner->GetEntry(), i_owner->GetGUIDLow() );
- Mutate(new ConfusedMovementGenerator<Creature>());
+ Mutate(new ConfusedMovementGenerator<Creature>(), MOTION_SLOT_CONTROLLED);
}
}
@@ -211,7 +215,7 @@ MotionMaster::MoveChase(Unit* target, float dist, float angle)
i_owner->GetGUIDLow(),
target->GetTypeId()==TYPEID_PLAYER ? "player" : "creature",
target->GetTypeId()==TYPEID_PLAYER ? i_owner->GetGUIDLow() : ((Creature*)i_owner)->GetDBTableGUIDLow() );
- Mutate(new TargetedMovementGenerator<Player>(*target,dist,angle));
+ Mutate(new TargetedMovementGenerator<Player>(*target,dist,angle), MOTION_SLOT_ACTIVE);
}
else
{
@@ -219,15 +223,13 @@ MotionMaster::MoveChase(Unit* target, float dist, float angle)
i_owner->GetEntry(), i_owner->GetGUIDLow(),
target->GetTypeId()==TYPEID_PLAYER ? "player" : "creature",
target->GetTypeId()==TYPEID_PLAYER ? target->GetGUIDLow() : ((Creature*)target)->GetDBTableGUIDLow() );
- Mutate(new TargetedMovementGenerator<Creature>(*target,dist,angle));
+ Mutate(new TargetedMovementGenerator<Creature>(*target,dist,angle), MOTION_SLOT_ACTIVE);
}
}
void
MotionMaster::MoveFollow(Unit* target, float dist, float angle)
{
- Clear();
-
// ignore movement request if target not exist
if(!target)
return;
@@ -238,7 +240,7 @@ MotionMaster::MoveFollow(Unit* target, float dist, float angle)
DEBUG_LOG("Player (GUID: %u) follow to %s (GUID: %u)", i_owner->GetGUIDLow(),
target->GetTypeId()==TYPEID_PLAYER ? "player" : "creature",
target->GetTypeId()==TYPEID_PLAYER ? i_owner->GetGUIDLow() : ((Creature*)i_owner)->GetDBTableGUIDLow() );
- Mutate(new TargetedMovementGenerator<Player>(*target,dist,angle));
+ Mutate(new TargetedMovementGenerator<Player>(*target,dist,angle), MOTION_SLOT_ACTIVE);
}
else
{
@@ -246,7 +248,7 @@ MotionMaster::MoveFollow(Unit* target, float dist, float angle)
i_owner->GetEntry(), i_owner->GetGUIDLow(),
target->GetTypeId()==TYPEID_PLAYER ? "player" : "creature",
target->GetTypeId()==TYPEID_PLAYER ? target->GetGUIDLow() : ((Creature*)target)->GetDBTableGUIDLow() );
- Mutate(new TargetedMovementGenerator<Creature>(*target,dist,angle));
+ Mutate(new TargetedMovementGenerator<Creature>(*target,dist,angle), MOTION_SLOT_ACTIVE);
}
}
@@ -256,13 +258,13 @@ MotionMaster::MovePoint(uint32 id, float x, float y, float z)
if(i_owner->GetTypeId()==TYPEID_PLAYER)
{
DEBUG_LOG("Player (GUID: %u) targeted point (Id: %u X: %f Y: %f Z: %f)", i_owner->GetGUIDLow(), id, x, y, z );
- Mutate(new PointMovementGenerator<Player>(id,x,y,z));
+ Mutate(new PointMovementGenerator<Player>(id,x,y,z), MOTION_SLOT_ACTIVE);
}
else
{
DEBUG_LOG("Creature (Entry: %u GUID: %u) targeted point (ID: %u X: %f Y: %f Z: %f)",
i_owner->GetEntry(), i_owner->GetGUIDLow(), id, x, y, z );
- Mutate(new PointMovementGenerator<Creature>(id,x,y,z));
+ Mutate(new PointMovementGenerator<Creature>(id,x,y,z), MOTION_SLOT_ACTIVE);
}
}
@@ -272,12 +274,15 @@ MotionMaster::MoveFleeing(Unit* enemy)
if(!enemy)
return;
+ if(i_owner->HasAuraType(SPELL_AURA_PREVENTS_FLEEING))
+ return;
+
if(i_owner->GetTypeId()==TYPEID_PLAYER)
{
DEBUG_LOG("Player (GUID: %u) flee from %s (GUID: %u)", i_owner->GetGUIDLow(),
enemy->GetTypeId()==TYPEID_PLAYER ? "player" : "creature",
enemy->GetTypeId()==TYPEID_PLAYER ? enemy->GetGUIDLow() : ((Creature*)enemy)->GetDBTableGUIDLow() );
- Mutate(new FleeingMovementGenerator<Player>(enemy->GetGUID()));
+ Mutate(new FleeingMovementGenerator<Player>(enemy->GetGUID()), MOTION_SLOT_CONTROLLED);
}
else
{
@@ -285,7 +290,7 @@ MotionMaster::MoveFleeing(Unit* enemy)
i_owner->GetEntry(), i_owner->GetGUIDLow(),
enemy->GetTypeId()==TYPEID_PLAYER ? "player" : "creature",
enemy->GetTypeId()==TYPEID_PLAYER ? enemy->GetGUIDLow() : ((Creature*)enemy)->GetDBTableGUIDLow() );
- Mutate(new FleeingMovementGenerator<Creature>(enemy->GetGUID()));
+ Mutate(new FleeingMovementGenerator<Creature>(enemy->GetGUID()), MOTION_SLOT_CONTROLLED);
}
}
@@ -296,7 +301,7 @@ MotionMaster::MoveTaxiFlight(uint32 path, uint32 pathnode)
{
DEBUG_LOG("Player (GUID: %u) taxi to (Path %u node %u)", i_owner->GetGUIDLow(), path, pathnode);
FlightPathMovementGenerator* mgen = new FlightPathMovementGenerator(path,pathnode);
- Mutate(mgen);
+ Mutate(mgen, MOTION_SLOT_CONTROLLED);
}
else
{
@@ -308,6 +313,9 @@ MotionMaster::MoveTaxiFlight(uint32 path, uint32 pathnode)
void
MotionMaster::MoveDistract(uint32 timer)
{
+ if(Impl[MOTION_SLOT_CONTROLLED])
+ return;
+
if(i_owner->GetTypeId()==TYPEID_PLAYER)
{
DEBUG_LOG("Player (GUID: %u) distracted (timer: %u)", i_owner->GetGUIDLow(), timer);
@@ -319,12 +327,25 @@ MotionMaster::MoveDistract(uint32 timer)
}
DistractMovementGenerator* mgen = new DistractMovementGenerator(timer);
- Mutate(mgen);
+ Mutate(mgen, MOTION_SLOT_CONTROLLED);
}
-void MotionMaster::Mutate(MovementGenerator *m)
+void MotionMaster::Mutate(MovementGenerator *m, MovementSlot slot)
{
- if (!empty())
+ if(MovementGenerator *curr = Impl[slot])
+ {
+ curr->Finalize(*i_owner);
+ if( !isStatic( curr ) )
+ delete curr;
+ }
+ else if(i_top < slot)
+ {
+ i_top = slot;
+ }
+ m->Initialize(*i_owner);
+ Impl[slot] = m;
+
+ /*if (!empty())
{
switch(top()->GetMovementGeneratorType())
{
@@ -336,7 +357,7 @@ void MotionMaster::Mutate(MovementGenerator *m)
}
}
m->Initialize(*i_owner);
- push(m);
+ push(m);*/
}
void MotionMaster::MovePath(uint32 path_id, bool repeatable)
@@ -356,7 +377,7 @@ void MotionMaster::MovePath(uint32 path_id, bool repeatable)
//i_owner->GetTypeId()==TYPEID_PLAYER ?
//Mutate(new WaypointMovementGenerator<Player>(path_id, repeatable)):
- Mutate(new WaypointMovementGenerator<Creature>(path_id, repeatable));
+ Mutate(new WaypointMovementGenerator<Creature>(path_id, repeatable), MOTION_SLOT_IDLE);
DEBUG_LOG("%s (GUID: %u) start moving over path(Id:%u, repeatable: %s)",
i_owner->GetTypeId()==TYPEID_PLAYER ? "Player" : "Creature",
@@ -365,10 +386,15 @@ void MotionMaster::MovePath(uint32 path_id, bool repeatable)
void MotionMaster::propagateSpeedChange()
{
- Impl::container_type::iterator it = Impl::c.begin();
+ /*Impl::container_type::iterator it = Impl::c.begin();
for ( ;it != end(); ++it)
{
(*it)->unitSpeedChanged();
+ }*/
+ for(int i = 0; i <= i_top; ++i)
+ {
+ if(Impl[i])
+ Impl[i]->unitSpeedChanged();
}
}
diff --git a/src/game/MotionMaster.h b/src/game/MotionMaster.h
index 209b2cf176e..4d9953c9d15 100644
--- a/src/game/MotionMaster.h
+++ b/src/game/MotionMaster.h
@@ -47,31 +47,53 @@ enum MovementGeneratorType
DISTRACT_MOTION_TYPE = 10, // IdleMovementGenerator.h
};
-class TRINITY_DLL_SPEC MotionMaster : private std::stack<MovementGenerator *>
+enum MovementSlot
+{
+ MOTION_SLOT_IDLE,
+ MOTION_SLOT_ACTIVE,
+ MOTION_SLOT_CONTROLLED,
+ MAX_MOTION_SLOT,
+};
+
+class TRINITY_DLL_SPEC MotionMaster //: private std::stack<MovementGenerator *>
{
private:
- typedef std::stack<MovementGenerator *> Impl;
+ //typedef std::stack<MovementGenerator *> Impl;
+ typedef MovementGenerator* _Ty;
+ _Ty Impl[MAX_MOTION_SLOT];
+ int i_top;
+
+ bool empty() const { return i_top < 0; }
+ void pop() { Impl[i_top] = NULL; --i_top; }
+ void push(_Ty _Val) { ++i_top; Impl[i_top] = _Val; }
public:
- explicit MotionMaster(Unit *unit) : i_owner(unit) {}
+ explicit MotionMaster(Unit *unit) : i_owner(unit), i_top(-1)
+ {
+ for(int i = 0; i < MAX_MOTION_SLOT; ++i)
+ Impl[i] = NULL;
+ }
~MotionMaster();
void Initialize();
- MovementGenerator* operator->(void) { return top(); }
+ //MovementGenerator* operator->(void) { return top(); }
- using Impl::top;
+ int size() const { return i_top + 1; }
+ _Ty top() const { return Impl[i_top]; }
+ _Ty GetMotionSlot(int slot) { return Impl[slot]; }
+ /*using Impl::top;
using Impl::empty;
typedef Impl::container_type::const_iterator const_iterator;
const_iterator begin() const { return Impl::c.begin(); }
- const_iterator end() const { return Impl::c.end(); }
+ const_iterator end() const { return Impl::c.end(); }*/
void UpdateMotion(const uint32 &diff);
void Clear(bool reset = true);
void MovementExpired(bool reset = true);
- void MoveIdle();
+ void MoveIdle(MovementSlot slot = MOTION_SLOT_ACTIVE);
void MoveTargetedHome();
void MoveRandom(float spawndist = 0.0f);
void MoveFollow(Unit* target, float dist, float angle);
@@ -89,7 +111,7 @@ class TRINITY_DLL_SPEC MotionMaster : private std::stack<MovementGenerator *>
bool GetDestination(float &x, float &y, float &z);
private:
- void Mutate(MovementGenerator *m); // use Move* functions instead
+ void Mutate(MovementGenerator *m, MovementSlot slot); // use Move* functions instead
Unit *i_owner;
};
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 370a94bd93f..c415d0a9d1b 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -12857,13 +12857,6 @@ void Unit::SetFeared(bool apply)
{
if(apply)
{
- if(HasAuraType(SPELL_AURA_PREVENTS_FLEEING))
- return;
-
- SetUInt64Value(UNIT_FIELD_TARGET, 0);
- SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING);
- CastStop();
- //GetMotionMaster()->MovementExpired(false);
Unit *caster = NULL;
Unit::AuraList const& fearAuras = GetAurasByType(SPELL_AURA_MOD_FEAR);
if(!fearAuras.empty())
@@ -12872,17 +12865,8 @@ void Unit::SetFeared(bool apply)
}
else
{
- RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING);
- if(isAlive())
- {
- if( GetTypeId() != TYPEID_PLAYER && getVictim())
- {
- SetUInt64Value(UNIT_FIELD_TARGET, getVictim()->GetGUID());
- GetMotionMaster()->MoveChase(getVictim());
- }
- else
- GetMotionMaster()->Initialize();
- }
+ if(isAlive() && GetMotionMaster()->GetCurrentMovementGeneratorType() == FLEEING_MOTION_TYPE)
+ GetMotionMaster()->MovementExpired();
}
if (GetTypeId() == TYPEID_PLAYER)
@@ -12893,24 +12877,12 @@ void Unit::SetConfused(bool apply)
{
if(apply)
{
- SetUInt64Value(UNIT_FIELD_TARGET, 0);
- SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED);
- CastStop();
GetMotionMaster()->MoveConfused();
}
else
{
- RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED);
- if(isAlive())
- {
- if( GetTypeId() != TYPEID_PLAYER && getVictim())
- {
- SetUInt64Value(UNIT_FIELD_TARGET, getVictim()->GetGUID());
- GetMotionMaster()->MoveChase(getVictim());
- }
- else
- GetMotionMaster()->Initialize();
- }
+ if(isAlive() && GetMotionMaster()->GetCurrentMovementGeneratorType() == CONFUSED_MOTION_TYPE)
+ GetMotionMaster()->MovementExpired();
}
if(GetTypeId() == TYPEID_PLAYER)
diff --git a/src/game/Unit.h b/src/game/Unit.h
index 5d5b0d492f6..09c7130c92a 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -367,7 +367,7 @@ enum UnitState
UNIT_STAT_ATTACK_PLAYER = 0x00004000,
UNIT_STAT_CASTING = 0x00008000,
UNIT_STAT_POSSESSED = 0x00010000,
- UNIT_STAT_MOVING = (UNIT_STAT_ROAMING | UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING),
+ UNIT_STAT_MOVING = (UNIT_STAT_ROAMING | UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FOLLOW),
UNIT_STAT_LOST_CONTROL = (UNIT_STAT_CONFUSED | UNIT_STAT_STUNNED | UNIT_STAT_FLEEING),
UNIT_STAT_SIGHTLESS = (UNIT_STAT_LOST_CONTROL | UNIT_STAT_CHASE | UNIT_STAT_SEARCHING),
UNIT_STAT_CANNOT_AUTOATTACK = (UNIT_STAT_LOST_CONTROL | UNIT_STAT_CASTING),