*Update flee and confuse movement.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-01-17 00:00:48 -06:00
parent 0a1c601a1c
commit f414ab1686
8 changed files with 39 additions and 54 deletions
+6
View File
@@ -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);
+2 -10
View File
@@ -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
+8 -1
View File
@@ -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>
+1 -1
View File
@@ -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);
+10 -7
View File
@@ -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;
}
}
+6 -2
View File
@@ -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);
+2 -1
View File
@@ -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;
+4 -32
View File
@@ -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)