aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormegamage <none@none>2009-01-17 00:00:48 -0600
committermegamage <none@none>2009-01-17 00:00:48 -0600
commitf414ab1686c300787e3dfb0c397227062b8feea6 (patch)
tree2c76fa147dbf95b9192b01c7484d1804c03d2ed5
parent0a1c601a1cc0e0036ad8fbfce68d87d14fa572d0 (diff)
*Update flee and confuse movement.
--HG-- branch : trunk
-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.cpp17
-rw-r--r--src/game/MotionMaster.cpp8
-rw-r--r--src/game/MotionMaster.h3
-rw-r--r--src/game/Unit.cpp36
8 files changed, 39 insertions, 54 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..62dc4ab2bd3 100644
--- a/src/game/Level3.cpp
+++ b/src/game/Level3.cpp
@@ -5762,9 +5762,12 @@ 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");
+ switch(mg->GetMovementGeneratorType())
{
case IDLE_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_IDLE); break;
case RANDOM_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_RANDOM); break;
@@ -5775,7 +5778,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 +5787,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 +5800,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 +5810,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 39260362212..551383d985a 100644
--- a/src/game/MotionMaster.cpp
+++ b/src/game/MotionMaster.cpp
@@ -230,8 +230,6 @@ MotionMaster::MoveChase(Unit* target, float dist, float angle)
void
MotionMaster::MoveFollow(Unit* target, float dist, float angle)
{
- Clear();
-
// ignore movement request if target not exist
if(!target)
return;
@@ -276,6 +274,9 @@ 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(),
@@ -312,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);
diff --git a/src/game/MotionMaster.h b/src/game/MotionMaster.h
index d275bdd4b90..31694e91420 100644
--- a/src/game/MotionMaster.h
+++ b/src/game/MotionMaster.h
@@ -63,7 +63,6 @@ class TRINITY_DLL_SPEC MotionMaster //: private std::stack<MovementGenerator *>
_Ty Impl[MAX_MOTION_SLOT];
int i_top;
- int size() const { return i_top + 1; }
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; }
@@ -76,7 +75,9 @@ class TRINITY_DLL_SPEC MotionMaster //: private std::stack<MovementGenerator *>
//MovementGenerator* operator->(void) { return 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;
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 370a94bd93f..be573338a66 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)