mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[9208] Big cleanup in UNIT_STAT_* use
* Re-number enums by function groups and use where possible new defined masks in code instead raw enum |-lists. * Avoid use movement generator generic state markers like UNIT_STAT_CONFUSED for mark movement stoped. Add special shadow UNIT_STAT_CONFUSED_MOVE/etc states for like use. UNIT_STAT_CONFUSED in like case will be safe expect use for normal checks confused state presence And UNIT_STAT_CONFUSED_MOVE for check real move in this state
This commit is contained in:
parent
7d6b1b292e
commit
6a2e8064f1
25 changed files with 251 additions and 104 deletions
|
|
@ -64,7 +64,7 @@ ConfusedMovementGenerator<T>::Initialize(T &unit)
|
||||||
}
|
}
|
||||||
|
|
||||||
unit.StopMoving();
|
unit.StopMoving();
|
||||||
unit.addUnitState(UNIT_STAT_CONFUSED);
|
unit.addUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_CONFUSED_MOVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
|
@ -88,6 +88,8 @@ ConfusedMovementGenerator<Player>::_InitSpecific(Player &, bool &is_water_ok, bo
|
||||||
template<class T>
|
template<class T>
|
||||||
void ConfusedMovementGenerator<T>::Interrupt(T &unit)
|
void ConfusedMovementGenerator<T>::Interrupt(T &unit)
|
||||||
{
|
{
|
||||||
|
// confused state still applied while movegen disabled
|
||||||
|
unit.clearUnitState(UNIT_STAT_CONFUSED_MOVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|
@ -97,6 +99,7 @@ void ConfusedMovementGenerator<T>::Reset(T &unit)
|
||||||
i_nextMoveTime.Reset(0);
|
i_nextMoveTime.Reset(0);
|
||||||
i_destinationHolder.ResetUpdate();
|
i_destinationHolder.ResetUpdate();
|
||||||
unit.StopMoving();
|
unit.StopMoving();
|
||||||
|
unit.addUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_CONFUSED_MOVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|
@ -105,12 +108,14 @@ bool ConfusedMovementGenerator<T>::Update(T &unit, const uint32 &diff)
|
||||||
if(!&unit)
|
if(!&unit)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(unit.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED | UNIT_STAT_DIED))
|
// ignore in case other no reaction state
|
||||||
|
if (unit.hasUnitState(UNIT_STAT_CAN_NOT_REACT & ~UNIT_STAT_CONFUSED))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if( i_nextMoveTime.Passed() )
|
if (i_nextMoveTime.Passed())
|
||||||
{
|
{
|
||||||
// currently moving, update location
|
// currently moving, update location
|
||||||
|
unit.addUnitState(UNIT_STAT_CONFUSED_MOVE);
|
||||||
Traveller<T> traveller(unit);
|
Traveller<T> traveller(unit);
|
||||||
if( i_destinationHolder.UpdateTraveller(traveller, diff, false))
|
if( i_destinationHolder.UpdateTraveller(traveller, diff, false))
|
||||||
{
|
{
|
||||||
|
|
@ -131,6 +136,7 @@ bool ConfusedMovementGenerator<T>::Update(T &unit, const uint32 &diff)
|
||||||
if( i_nextMoveTime.Passed() )
|
if( i_nextMoveTime.Passed() )
|
||||||
{
|
{
|
||||||
// start moving
|
// start moving
|
||||||
|
unit.addUnitState(UNIT_STAT_CONFUSED_MOVE);
|
||||||
assert( i_nextMove <= MAX_CONF_WAYPOINTS );
|
assert( i_nextMove <= MAX_CONF_WAYPOINTS );
|
||||||
const float x = i_waypoints[i_nextMove][0];
|
const float x = i_waypoints[i_nextMove][0];
|
||||||
const float y = i_waypoints[i_nextMove][1];
|
const float y = i_waypoints[i_nextMove][1];
|
||||||
|
|
@ -145,13 +151,13 @@ bool ConfusedMovementGenerator<T>::Update(T &unit, const uint32 &diff)
|
||||||
template<>
|
template<>
|
||||||
void ConfusedMovementGenerator<Player>::Finalize(Player &unit)
|
void ConfusedMovementGenerator<Player>::Finalize(Player &unit)
|
||||||
{
|
{
|
||||||
unit.clearUnitState(UNIT_STAT_CONFUSED);
|
unit.clearUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_CONFUSED_MOVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void ConfusedMovementGenerator<Creature>::Finalize(Creature &unit)
|
void ConfusedMovementGenerator<Creature>::Finalize(Creature &unit)
|
||||||
{
|
{
|
||||||
unit.clearUnitState(UNIT_STAT_CONFUSED);
|
unit.clearUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_CONFUSED_MOVE);
|
||||||
unit.AddMonsterMoveFlag(MONSTER_MOVE_WALK);
|
unit.AddMonsterMoveFlag(MONSTER_MOVE_WALK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ CanCastResult CreatureAI::CanCastSpell(Unit* pTarget, const SpellEntry *pSpell,
|
||||||
if (!isTriggered)
|
if (!isTriggered)
|
||||||
{
|
{
|
||||||
// State does not allow
|
// State does not allow
|
||||||
if (m_creature->hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_STUNNED | UNIT_STAT_FLEEING | UNIT_STAT_DIED))
|
if (m_creature->hasUnitState(UNIT_STAT_CAN_NOT_REACT))
|
||||||
return CAST_FAIL_STATE;
|
return CAST_FAIL_STATE;
|
||||||
|
|
||||||
if (pSpell->PreventionType == SPELL_PREVENTION_TYPE_SILENCE && m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED))
|
if (pSpell->PreventionType == SPELL_PREVENTION_TYPE_SILENCE && m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED))
|
||||||
|
|
|
||||||
|
|
@ -1343,8 +1343,8 @@ bool CreatureEventAI::CanCast(Unit* Target, SpellEntry const *Spell, bool Trigge
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//Silenced so we can't cast
|
//Silenced so we can't cast
|
||||||
if (!Triggered && (m_creature->hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_STUNNED | UNIT_STAT_FLEEING | UNIT_STAT_DIED)
|
if (!Triggered && (m_creature->hasUnitState(UNIT_STAT_CAN_NOT_REACT) ||
|
||||||
|| m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED)))
|
m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//Check for power
|
//Check for power
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,8 @@ FleeingMovementGenerator<T>::_setTargetLocation(T &owner)
|
||||||
if( !&owner )
|
if( !&owner )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DIED) )
|
// ignore in case other no reaction state
|
||||||
|
if (owner.hasUnitState(UNIT_STAT_CAN_NOT_REACT & ~UNIT_STAT_FLEEING))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!_setMoveData(owner))
|
if(!_setMoveData(owner))
|
||||||
|
|
@ -43,7 +44,7 @@ FleeingMovementGenerator<T>::_setTargetLocation(T &owner)
|
||||||
if(!_getPoint(owner, x, y, z))
|
if(!_getPoint(owner, x, y, z))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
owner.addUnitState(UNIT_STAT_FLEEING);
|
owner.addUnitState(UNIT_STAT_FLEEING_MOVE);
|
||||||
Traveller<T> traveller(owner);
|
Traveller<T> traveller(owner);
|
||||||
i_destinationHolder.SetDestination(traveller, x, y, z);
|
i_destinationHolder.SetDestination(traveller, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
@ -281,8 +282,7 @@ template<class T>
|
||||||
void
|
void
|
||||||
FleeingMovementGenerator<T>::Initialize(T &owner)
|
FleeingMovementGenerator<T>::Initialize(T &owner)
|
||||||
{
|
{
|
||||||
if(!&owner)
|
owner.addUnitState(UNIT_STAT_FLEEING|UNIT_STAT_FLEEING_MOVE);
|
||||||
return;
|
|
||||||
|
|
||||||
_Init(owner);
|
_Init(owner);
|
||||||
|
|
||||||
|
|
@ -310,9 +310,6 @@ template<>
|
||||||
void
|
void
|
||||||
FleeingMovementGenerator<Creature>::_Init(Creature &owner)
|
FleeingMovementGenerator<Creature>::_Init(Creature &owner)
|
||||||
{
|
{
|
||||||
if(!&owner)
|
|
||||||
return;
|
|
||||||
|
|
||||||
owner.RemoveMonsterMoveFlag(MONSTER_MOVE_WALK);
|
owner.RemoveMonsterMoveFlag(MONSTER_MOVE_WALK);
|
||||||
owner.SetTargetGUID(0);
|
owner.SetTargetGUID(0);
|
||||||
is_water_ok = owner.canSwim();
|
is_water_ok = owner.canSwim();
|
||||||
|
|
@ -330,19 +327,21 @@ FleeingMovementGenerator<Player>::_Init(Player &)
|
||||||
template<>
|
template<>
|
||||||
void FleeingMovementGenerator<Player>::Finalize(Player &owner)
|
void FleeingMovementGenerator<Player>::Finalize(Player &owner)
|
||||||
{
|
{
|
||||||
owner.clearUnitState(UNIT_STAT_FLEEING);
|
owner.clearUnitState(UNIT_STAT_FLEEING|UNIT_STAT_FLEEING_MOVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void FleeingMovementGenerator<Creature>::Finalize(Creature &owner)
|
void FleeingMovementGenerator<Creature>::Finalize(Creature &owner)
|
||||||
{
|
{
|
||||||
owner.AddMonsterMoveFlag(MONSTER_MOVE_WALK);
|
owner.AddMonsterMoveFlag(MONSTER_MOVE_WALK);
|
||||||
owner.clearUnitState(UNIT_STAT_FLEEING);
|
owner.clearUnitState(UNIT_STAT_FLEEING|UNIT_STAT_FLEEING_MOVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void FleeingMovementGenerator<T>::Interrupt(T &owner)
|
void FleeingMovementGenerator<T>::Interrupt(T &owner)
|
||||||
{
|
{
|
||||||
|
// flee state still applied while movegen disabled
|
||||||
|
owner.clearUnitState(UNIT_STAT_FLEEING_MOVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|
@ -356,8 +355,13 @@ bool FleeingMovementGenerator<T>::Update(T &owner, const uint32 & time_diff)
|
||||||
{
|
{
|
||||||
if( !&owner || !owner.isAlive() )
|
if( !&owner || !owner.isAlive() )
|
||||||
return false;
|
return false;
|
||||||
if( owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DIED) )
|
|
||||||
|
// ignore in case other no reaction state
|
||||||
|
if (owner.hasUnitState(UNIT_STAT_CAN_NOT_REACT & ~UNIT_STAT_FLEEING))
|
||||||
|
{
|
||||||
|
owner.clearUnitState(UNIT_STAT_FLEEING_MOVE);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Traveller<T> traveller(owner);
|
Traveller<T> traveller(owner);
|
||||||
|
|
||||||
|
|
@ -398,7 +402,7 @@ template bool FleeingMovementGenerator<Creature>::Update(Creature &, const uint3
|
||||||
|
|
||||||
void TimedFleeingMovementGenerator::Finalize(Unit &owner)
|
void TimedFleeingMovementGenerator::Finalize(Unit &owner)
|
||||||
{
|
{
|
||||||
owner.clearUnitState(UNIT_STAT_FLEEING);
|
owner.clearUnitState(UNIT_STAT_FLEEING|UNIT_STAT_FLEEING_MOVE);
|
||||||
if (Unit* victim = owner.getVictim())
|
if (Unit* victim = owner.getVictim())
|
||||||
{
|
{
|
||||||
if (owner.isAlive())
|
if (owner.isAlive())
|
||||||
|
|
@ -414,8 +418,12 @@ bool TimedFleeingMovementGenerator::Update(Unit & owner, const uint32 & time_dif
|
||||||
if( !owner.isAlive() )
|
if( !owner.isAlive() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if( owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DIED) )
|
// ignore in case other no reaction state
|
||||||
|
if (owner.hasUnitState(UNIT_STAT_CAN_NOT_REACT & ~UNIT_STAT_FLEEING))
|
||||||
|
{
|
||||||
|
owner.clearUnitState(UNIT_STAT_FLEEING_MOVE);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
i_totalFleeTime.Update(time_diff);
|
i_totalFleeTime.Update(time_diff);
|
||||||
if (i_totalFleeTime.Passed())
|
if (i_totalFleeTime.Passed())
|
||||||
|
|
|
||||||
|
|
@ -719,7 +719,7 @@ namespace MaNGOS
|
||||||
bool operator()(Unit* u)
|
bool operator()(Unit* u)
|
||||||
{
|
{
|
||||||
if(u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) &&
|
if(u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) &&
|
||||||
(u->isFeared() || u->isCharmed() || u->isFrozen() || u->hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_CONFUSED | UNIT_STAT_DIED)))
|
(u->isCharmed() || u->isFrozen() || u->hasUnitState(UNIT_STAT_CAN_NOT_REACT)))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ HomeMovementGenerator<Creature>::_setTargetLocation(Creature & owner)
|
||||||
if( !&owner )
|
if( !&owner )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED | UNIT_STAT_DIED) )
|
if( owner.hasUnitState(UNIT_STAT_NOT_MOVE) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float x, y, z;
|
float x, y, z;
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,17 @@ DistractMovementGenerator::Finalize(Unit& owner)
|
||||||
owner.clearUnitState(UNIT_STAT_DISTRACTED);
|
owner.clearUnitState(UNIT_STAT_DISTRACTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DistractMovementGenerator::Reset(Unit& owner)
|
||||||
|
{
|
||||||
|
Initialize(owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DistractMovementGenerator::Interrupt(Unit& owner)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
DistractMovementGenerator::Update(Unit& /*owner*/, const uint32& time_diff)
|
DistractMovementGenerator::Update(Unit& /*owner*/, const uint32& time_diff)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,8 @@ class MANGOS_DLL_SPEC DistractMovementGenerator : public MovementGenerator
|
||||||
|
|
||||||
void Initialize(Unit& owner);
|
void Initialize(Unit& owner);
|
||||||
void Finalize(Unit& owner);
|
void Finalize(Unit& owner);
|
||||||
void Interrupt(Unit& ) {}
|
void Interrupt(Unit& );
|
||||||
void Reset(Unit& owner) { Initialize(owner); }
|
void Reset(Unit& );
|
||||||
bool Update(Unit& owner, const uint32& time_diff);
|
bool Update(Unit& owner, const uint32& time_diff);
|
||||||
MovementGeneratorType GetMovementGeneratorType() { return DISTRACT_MOTION_TYPE; }
|
MovementGeneratorType GetMovementGeneratorType() { return DISTRACT_MOTION_TYPE; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ MotionMaster::~MotionMaster()
|
||||||
void
|
void
|
||||||
MotionMaster::UpdateMotion(uint32 diff)
|
MotionMaster::UpdateMotion(uint32 diff)
|
||||||
{
|
{
|
||||||
if( i_owner->hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DIED) )
|
if( i_owner->hasUnitState(UNIT_STAT_CAN_NOT_MOVE) )
|
||||||
return;
|
return;
|
||||||
assert( !empty() );
|
assert( !empty() );
|
||||||
m_cleanFlag |= MMCF_UPDATE;
|
m_cleanFlag |= MMCF_UPDATE;
|
||||||
|
|
@ -232,7 +232,6 @@ MotionMaster::MoveTargetedHome()
|
||||||
Unit *target = ((Creature*)i_owner)->GetCharmerOrOwner();
|
Unit *target = ((Creature*)i_owner)->GetCharmerOrOwner();
|
||||||
if(target)
|
if(target)
|
||||||
{
|
{
|
||||||
i_owner->addUnitState(UNIT_STAT_FOLLOW);
|
|
||||||
DEBUG_LOG("Following %s (GUID: %u)",
|
DEBUG_LOG("Following %s (GUID: %u)",
|
||||||
target->GetTypeId()==TYPEID_PLAYER ? "player" : "creature",
|
target->GetTypeId()==TYPEID_PLAYER ? "player" : "creature",
|
||||||
target->GetTypeId()==TYPEID_PLAYER ? target->GetGUIDLow() : ((Creature*)target)->GetDBTableGUIDLow() );
|
target->GetTypeId()==TYPEID_PLAYER ? target->GetGUIDLow() : ((Creature*)target)->GetDBTableGUIDLow() );
|
||||||
|
|
@ -268,7 +267,6 @@ MotionMaster::MoveChase(Unit* target, float dist, float angle)
|
||||||
if(!target)
|
if(!target)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
i_owner->clearUnitState(UNIT_STAT_FOLLOW);
|
|
||||||
if(i_owner->GetTypeId()==TYPEID_PLAYER)
|
if(i_owner->GetTypeId()==TYPEID_PLAYER)
|
||||||
{
|
{
|
||||||
DEBUG_LOG("Player (GUID: %u) chase to %s (GUID: %u)",
|
DEBUG_LOG("Player (GUID: %u) chase to %s (GUID: %u)",
|
||||||
|
|
@ -296,7 +294,6 @@ MotionMaster::MoveFollow(Unit* target, float dist, float angle)
|
||||||
if(!target)
|
if(!target)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
i_owner->addUnitState(UNIT_STAT_FOLLOW);
|
|
||||||
if(i_owner->GetTypeId()==TYPEID_PLAYER)
|
if(i_owner->GetTypeId()==TYPEID_PLAYER)
|
||||||
{
|
{
|
||||||
DEBUG_LOG("Player (GUID: %u) follow to %s (GUID: %u)", i_owner->GetGUIDLow(),
|
DEBUG_LOG("Player (GUID: %u) follow to %s (GUID: %u)", i_owner->GetGUIDLow(),
|
||||||
|
|
|
||||||
|
|
@ -1732,7 +1732,7 @@ namespace MaNGOS
|
||||||
|
|
||||||
float x,y,z;
|
float x,y,z;
|
||||||
|
|
||||||
if( !c->isAlive() || c->hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED | UNIT_STAT_DIED) ||
|
if( !c->isAlive() || c->hasUnitState(UNIT_STAT_NOT_MOVE) ||
|
||||||
!c->GetMotionMaster()->GetDestination(x,y,z) )
|
!c->GetMotionMaster()->GetDestination(x,y,z) )
|
||||||
{
|
{
|
||||||
x = c->GetPositionX();
|
x = c->GetPositionX();
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,6 @@ void PetAI::AttackStart(Unit *u)
|
||||||
|
|
||||||
if(m_creature->Attack(u,true))
|
if(m_creature->Attack(u,true))
|
||||||
{
|
{
|
||||||
m_creature->clearUnitState(UNIT_STAT_FOLLOW);
|
|
||||||
// TMGs call CreatureRelocation which via MoveInLineOfSight can call this function
|
// TMGs call CreatureRelocation which via MoveInLineOfSight can call this function
|
||||||
// thus with the following clear the original TMG gets invalidated and crash, doh
|
// thus with the following clear the original TMG gets invalidated and crash, doh
|
||||||
// hope it doesn't start to leak memory without this :-/
|
// hope it doesn't start to leak memory without this :-/
|
||||||
|
|
@ -126,8 +125,7 @@ void PetAI::_stopAttack()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_creature->clearUnitState(UNIT_STAT_FOLLOW);
|
m_creature->GetMotionMaster()->Clear(false);
|
||||||
m_creature->GetMotionMaster()->Clear();
|
|
||||||
m_creature->GetMotionMaster()->MoveIdle();
|
m_creature->GetMotionMaster()->MoveIdle();
|
||||||
}
|
}
|
||||||
m_creature->AttackStop();
|
m_creature->AttackStop();
|
||||||
|
|
@ -163,7 +161,7 @@ void PetAI::UpdateAI(const uint32 diff)
|
||||||
// required to be stopped cases
|
// required to be stopped cases
|
||||||
if (m_creature->IsStopped() && m_creature->IsNonMeleeSpellCasted(false))
|
if (m_creature->IsStopped() && m_creature->IsNonMeleeSpellCasted(false))
|
||||||
{
|
{
|
||||||
if (m_creature->hasUnitState(UNIT_STAT_FOLLOW))
|
if (m_creature->hasUnitState(UNIT_STAT_FOLLOW_MOVE))
|
||||||
m_creature->InterruptNonMeleeSpells(false);
|
m_creature->InterruptNonMeleeSpells(false);
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -194,7 +194,7 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data )
|
||||||
if(!pet->HasSpell(spellid) || IsPassiveSpell(spellid))
|
if(!pet->HasSpell(spellid) || IsPassiveSpell(spellid))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pet->clearUnitState(UNIT_STAT_FOLLOW);
|
pet->clearUnitState(UNIT_STAT_MOVING);
|
||||||
|
|
||||||
Spell *spell = new Spell(pet, spellInfo, false);
|
Spell *spell = new Spell(pet, spellInfo, false);
|
||||||
|
|
||||||
|
|
@ -633,7 +633,7 @@ void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket )
|
||||||
if (!targets.read(&recvPacket,pet))
|
if (!targets.read(&recvPacket,pet))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pet->clearUnitState(UNIT_STAT_FOLLOW);
|
pet->clearUnitState(UNIT_STAT_MOVING);
|
||||||
|
|
||||||
Spell *spell = new Spell(pet, spellInfo, false);
|
Spell *spell = new Spell(pet, spellInfo, false);
|
||||||
spell->m_cast_count = cast_count; // probably pending spell cast
|
spell->m_cast_count = cast_count; // probably pending spell cast
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ template<class T>
|
||||||
void PointMovementGenerator<T>::Initialize(T &unit)
|
void PointMovementGenerator<T>::Initialize(T &unit)
|
||||||
{
|
{
|
||||||
unit.StopMoving();
|
unit.StopMoving();
|
||||||
unit.addUnitState(UNIT_STAT_ROAMING);
|
unit.addUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE);
|
||||||
Traveller<T> traveller(unit);
|
Traveller<T> traveller(unit);
|
||||||
i_destinationHolder.SetDestination(traveller,i_x,i_y,i_z);
|
i_destinationHolder.SetDestination(traveller,i_x,i_y,i_z);
|
||||||
|
|
||||||
|
|
@ -36,17 +36,40 @@ void PointMovementGenerator<T>::Initialize(T &unit)
|
||||||
((Creature&)unit).AddMonsterMoveFlag(MONSTER_MOVE_FLY);
|
((Creature&)unit).AddMonsterMoveFlag(MONSTER_MOVE_FLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void PointMovementGenerator<T>::Finalize(T &unit)
|
||||||
|
{
|
||||||
|
unit.clearUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void PointMovementGenerator<T>::Interrupt(T &unit)
|
||||||
|
{
|
||||||
|
unit.clearUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void PointMovementGenerator<T>::Reset(T &unit)
|
||||||
|
{
|
||||||
|
unit.StopMoving();
|
||||||
|
unit.addUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
bool PointMovementGenerator<T>::Update(T &unit, const uint32 &diff)
|
bool PointMovementGenerator<T>::Update(T &unit, const uint32 &diff)
|
||||||
{
|
{
|
||||||
if(!&unit)
|
if(!&unit)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(unit.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DIED))
|
if(unit.hasUnitState(UNIT_STAT_CAN_NOT_MOVE))
|
||||||
|
{
|
||||||
|
unit.clearUnitState(UNIT_STAT_ROAMING_MOVE);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
unit.addUnitState(UNIT_STAT_ROAMING_MOVE);
|
||||||
Traveller<T> traveller(unit);
|
Traveller<T> traveller(unit);
|
||||||
|
|
||||||
i_destinationHolder.UpdateTraveller(traveller, diff, false);
|
i_destinationHolder.UpdateTraveller(traveller, diff, false);
|
||||||
|
|
||||||
if(i_destinationHolder.HasArrived())
|
if(i_destinationHolder.HasArrived())
|
||||||
|
|
@ -78,6 +101,8 @@ template bool PointMovementGenerator<Creature>::Update(Creature&, const uint32 &
|
||||||
|
|
||||||
void AssistanceMovementGenerator::Finalize(Unit &unit)
|
void AssistanceMovementGenerator::Finalize(Unit &unit)
|
||||||
{
|
{
|
||||||
|
unit.clearUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE);
|
||||||
|
|
||||||
((Creature*)&unit)->SetNoCallAssistance(false);
|
((Creature*)&unit)->SetNoCallAssistance(false);
|
||||||
((Creature*)&unit)->CallAssistance();
|
((Creature*)&unit)->CallAssistance();
|
||||||
if (unit.isAlive())
|
if (unit.isAlive())
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,9 @@ class MANGOS_DLL_SPEC PointMovementGenerator
|
||||||
i_x(_x), i_y(_y), i_z(_z), i_nextMoveTime(0) {}
|
i_x(_x), i_y(_y), i_z(_z), i_nextMoveTime(0) {}
|
||||||
|
|
||||||
void Initialize(T &);
|
void Initialize(T &);
|
||||||
void Finalize(T &){}
|
void Finalize(T &);
|
||||||
void Interrupt(T &) {}
|
void Interrupt(T &);
|
||||||
void Reset(T &unit){ unit.StopMoving(); }
|
void Reset(T &unit);
|
||||||
bool Update(T &, const uint32 &diff);
|
bool Update(T &, const uint32 &diff);
|
||||||
|
|
||||||
void MovementInform(T &);
|
void MovementInform(T &);
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ RandomMovementGenerator<Creature>::_setRandomLocation(Creature &creature)
|
||||||
|
|
||||||
creature.SetOrientation(creature.GetAngle(nx, ny));
|
creature.SetOrientation(creature.GetAngle(nx, ny));
|
||||||
i_destinationHolder.SetDestination(traveller, nx, ny, nz);
|
i_destinationHolder.SetDestination(traveller, nx, ny, nz);
|
||||||
creature.addUnitState(UNIT_STAT_ROAMING);
|
creature.addUnitState(UNIT_STAT_ROAMING_MOVE);
|
||||||
|
|
||||||
if (is_air_ok)
|
if (is_air_ok)
|
||||||
{
|
{
|
||||||
|
|
@ -109,8 +109,7 @@ RandomMovementGenerator<Creature>::_setRandomLocation(Creature &creature)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void
|
void RandomMovementGenerator<Creature>::Initialize(Creature &creature)
|
||||||
RandomMovementGenerator<Creature>::Initialize(Creature &creature)
|
|
||||||
{
|
{
|
||||||
if (!creature.isAlive())
|
if (!creature.isAlive())
|
||||||
return;
|
return;
|
||||||
|
|
@ -120,34 +119,47 @@ RandomMovementGenerator<Creature>::Initialize(Creature &creature)
|
||||||
else
|
else
|
||||||
creature.AddMonsterMoveFlag(MONSTER_MOVE_WALK);
|
creature.AddMonsterMoveFlag(MONSTER_MOVE_WALK);
|
||||||
|
|
||||||
|
creature.addUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE);
|
||||||
_setRandomLocation(creature);
|
_setRandomLocation(creature);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void
|
void RandomMovementGenerator<Creature>::Reset(Creature &creature)
|
||||||
RandomMovementGenerator<Creature>::Reset(Creature &creature)
|
|
||||||
{
|
{
|
||||||
Initialize(creature);
|
Initialize(creature);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
void RandomMovementGenerator<Creature>::Interrupt(Creature &creature)
|
||||||
|
{
|
||||||
|
creature.clearUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
void
|
||||||
|
RandomMovementGenerator<Creature>::Finalize(Creature &creature)
|
||||||
|
{
|
||||||
|
creature.clearUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE);
|
||||||
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
bool
|
bool
|
||||||
RandomMovementGenerator<Creature>::Update(Creature &creature, const uint32 &diff)
|
RandomMovementGenerator<Creature>::Update(Creature &creature, const uint32 &diff)
|
||||||
{
|
{
|
||||||
if (creature.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED | UNIT_STAT_DIED))
|
if (creature.hasUnitState(UNIT_STAT_NOT_MOVE))
|
||||||
{
|
{
|
||||||
i_nextMoveTime.Update(i_nextMoveTime.GetExpiry()); // Expire the timer
|
i_nextMoveTime.Update(i_nextMoveTime.GetExpiry()); // Expire the timer
|
||||||
creature.clearUnitState(UNIT_STAT_ROAMING);
|
creature.clearUnitState(UNIT_STAT_ROAMING_MOVE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
i_nextMoveTime.Update(diff);
|
i_nextMoveTime.Update(diff);
|
||||||
|
|
||||||
if (i_destinationHolder.HasArrived() && !creature.IsStopped() && !creature.canFly())
|
if (i_destinationHolder.HasArrived() && !creature.IsStopped() && !creature.canFly())
|
||||||
creature.clearUnitState(UNIT_STAT_ROAMING);
|
creature.clearUnitState(UNIT_STAT_ROAMING_MOVE);
|
||||||
|
|
||||||
if (!i_destinationHolder.HasArrived() && creature.IsStopped())
|
if (!i_destinationHolder.HasArrived() && creature.IsStopped())
|
||||||
creature.addUnitState(UNIT_STAT_ROAMING);
|
creature.addUnitState(UNIT_STAT_ROAMING_MOVE);
|
||||||
|
|
||||||
CreatureTraveller traveller(creature);
|
CreatureTraveller traveller(creature);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,8 @@ class MANGOS_DLL_SPEC RandomMovementGenerator
|
||||||
|
|
||||||
void _setRandomLocation(T &);
|
void _setRandomLocation(T &);
|
||||||
void Initialize(T &);
|
void Initialize(T &);
|
||||||
void Finalize(T &) {}
|
void Finalize(T &);
|
||||||
void Interrupt(T &) {}
|
void Interrupt(T &);
|
||||||
void Reset(T &);
|
void Reset(T &);
|
||||||
bool Update(T &, const uint32 &);
|
bool Update(T &, const uint32 &);
|
||||||
void UpdateMapPosition(uint32 mapid, float &x ,float &y, float &z)
|
void UpdateMapPosition(uint32 mapid, float &x ,float &y, float &z)
|
||||||
|
|
|
||||||
|
|
@ -2925,7 +2925,7 @@ void Spell::update(uint32 difftime)
|
||||||
cancel();
|
cancel();
|
||||||
|
|
||||||
// check for incapacitating player states
|
// check for incapacitating player states
|
||||||
if( m_caster->hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_CONFUSED))
|
if( m_caster->hasUnitState(UNIT_STAT_CAN_NOT_REACT))
|
||||||
cancel();
|
cancel();
|
||||||
|
|
||||||
// check if player has turned if flag is set
|
// check if player has turned if flag is set
|
||||||
|
|
|
||||||
|
|
@ -1607,7 +1607,7 @@ void Spell::EffectDummy(uint32 i)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Any effect which causes you to lose control of your character will supress the starfall effect.
|
//Any effect which causes you to lose control of your character will supress the starfall effect.
|
||||||
if (m_caster->hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_FLEEING | UNIT_STAT_ROOT | UNIT_STAT_CONFUSED))
|
if (m_caster->hasUnitState(UNIT_STAT_NO_FREE_MOVE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch(m_spellInfo->Id)
|
switch(m_spellInfo->Id)
|
||||||
|
|
@ -3704,7 +3704,7 @@ void Spell::EffectDistract(uint32 /*i*/)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// target must be OK to do this
|
// target must be OK to do this
|
||||||
if( unitTarget->hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_STUNNED | UNIT_STAT_FLEEING ) )
|
if( unitTarget->hasUnitState(UNIT_STAT_CAN_NOT_REACT) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float angle = unitTarget->GetAngle(m_targets.m_destX, m_targets.m_destY);
|
float angle = unitTarget->GetAngle(m_targets.m_destX, m_targets.m_destY);
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ void TargetedMovementGeneratorMedium<T,D>::_setTargetLocation(T &owner)
|
||||||
if (!i_target.isValid() || !i_target->IsInWorld())
|
if (!i_target.isValid() || !i_target->IsInWorld())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED | UNIT_STAT_DIED))
|
if (owner.hasUnitState(UNIT_STAT_NOT_MOVE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// prevent redundant micro-movement for pets, other followers.
|
// prevent redundant micro-movement for pets, other followers.
|
||||||
|
|
@ -71,7 +71,8 @@ void TargetedMovementGeneratorMedium<T,D>::_setTargetLocation(T &owner)
|
||||||
*/
|
*/
|
||||||
Traveller<T> traveller(owner);
|
Traveller<T> traveller(owner);
|
||||||
i_destinationHolder.SetDestination(traveller, x, y, z);
|
i_destinationHolder.SetDestination(traveller, x, y, z);
|
||||||
owner.addUnitState(UNIT_STAT_CHASE);
|
|
||||||
|
D::_addUnitStateMove(owner);
|
||||||
if (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->canFly())
|
if (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->canFly())
|
||||||
((Creature&)owner).AddMonsterMoveFlag(MONSTER_MOVE_FLY);
|
((Creature&)owner).AddMonsterMoveFlag(MONSTER_MOVE_FLY);
|
||||||
}
|
}
|
||||||
|
|
@ -111,8 +112,11 @@ bool TargetedMovementGeneratorMedium<T,D>::Update(T &owner, const uint32 & time_
|
||||||
if (!owner.isAlive())
|
if (!owner.isAlive())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (owner.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_FLEEING | UNIT_STAT_DISTRACTED | UNIT_STAT_DIED))
|
if (owner.hasUnitState(UNIT_STAT_NOT_MOVE))
|
||||||
|
{
|
||||||
|
D::_clearUnitStateMove(owner);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// prevent movement while casting spells with cast time or channel time
|
// prevent movement while casting spells with cast time or channel time
|
||||||
if (owner.IsNonMeleeSpellCasted(false, false, true))
|
if (owner.IsNonMeleeSpellCasted(false, false, true))
|
||||||
|
|
@ -123,8 +127,11 @@ bool TargetedMovementGeneratorMedium<T,D>::Update(T &owner, const uint32 & time_
|
||||||
}
|
}
|
||||||
|
|
||||||
// prevent crash after creature killed pet
|
// prevent crash after creature killed pet
|
||||||
if (!owner.hasUnitState(UNIT_STAT_FOLLOW) && owner.getVictim() != i_target.getTarget())
|
if (static_cast<D*>(this)->_lostTarget(owner))
|
||||||
|
{
|
||||||
|
D::_clearUnitStateMove(owner);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Traveller<T> traveller(owner);
|
Traveller<T> traveller(owner);
|
||||||
|
|
||||||
|
|
@ -132,7 +139,7 @@ bool TargetedMovementGeneratorMedium<T,D>::Update(T &owner, const uint32 & time_
|
||||||
_setTargetLocation(owner);
|
_setTargetLocation(owner);
|
||||||
if (owner.IsStopped() && !i_destinationHolder.HasArrived())
|
if (owner.IsStopped() && !i_destinationHolder.HasArrived())
|
||||||
{
|
{
|
||||||
owner.addUnitState(UNIT_STAT_CHASE);
|
D::_addUnitStateMove(owner);
|
||||||
if (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->canFly())
|
if (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->canFly())
|
||||||
((Creature&)owner).AddMonsterMoveFlag(MONSTER_MOVE_FLY);
|
((Creature&)owner).AddMonsterMoveFlag(MONSTER_MOVE_FLY);
|
||||||
|
|
||||||
|
|
@ -167,23 +174,31 @@ bool TargetedMovementGeneratorMedium<T,D>::Update(T &owner, const uint32 & time_
|
||||||
owner.SetInFront(i_target.getTarget());
|
owner.SetInFront(i_target.getTarget());
|
||||||
|
|
||||||
owner.StopMoving();
|
owner.StopMoving();
|
||||||
if(owner.canReachWithAttack(i_target.getTarget()) && !owner.hasUnitState(UNIT_STAT_FOLLOW))
|
static_cast<D*>(this)->_reachTarget(owner);
|
||||||
owner.Attack(i_target.getTarget(),true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------//
|
//-----------------------------------------------//
|
||||||
|
template<class T>
|
||||||
|
void ChaseMovementGenerator<T>::_reachTarget(T &owner)
|
||||||
|
{
|
||||||
|
if(owner.canReachWithAttack(i_target.getTarget()))
|
||||||
|
owner.Attack(i_target.getTarget(),true);
|
||||||
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void ChaseMovementGenerator<Player>::Initialize(Player &owner)
|
void ChaseMovementGenerator<Player>::Initialize(Player &owner)
|
||||||
{
|
{
|
||||||
|
owner.addUnitState(UNIT_STAT_CHASE|UNIT_STAT_CHASE_MOVE);
|
||||||
_setTargetLocation(owner);
|
_setTargetLocation(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void ChaseMovementGenerator<Creature>::Initialize(Creature &owner)
|
void ChaseMovementGenerator<Creature>::Initialize(Creature &owner)
|
||||||
{
|
{
|
||||||
|
owner.addUnitState(UNIT_STAT_CHASE|UNIT_STAT_CHASE_MOVE);
|
||||||
owner.RemoveMonsterMoveFlag(MONSTER_MOVE_WALK);
|
owner.RemoveMonsterMoveFlag(MONSTER_MOVE_WALK);
|
||||||
|
|
||||||
if (((Creature*)&owner)->canFly())
|
if (((Creature*)&owner)->canFly())
|
||||||
|
|
@ -195,12 +210,13 @@ void ChaseMovementGenerator<Creature>::Initialize(Creature &owner)
|
||||||
template<class T>
|
template<class T>
|
||||||
void ChaseMovementGenerator<T>::Finalize(T &owner)
|
void ChaseMovementGenerator<T>::Finalize(T &owner)
|
||||||
{
|
{
|
||||||
owner.clearUnitState(UNIT_STAT_CHASE | UNIT_STAT_FOLLOW);
|
owner.clearUnitState(UNIT_STAT_CHASE|UNIT_STAT_CHASE_MOVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void ChaseMovementGenerator<T>::Interrupt(T &owner)
|
void ChaseMovementGenerator<T>::Interrupt(T &owner)
|
||||||
{
|
{
|
||||||
|
owner.clearUnitState(UNIT_STAT_CHASE|UNIT_STAT_CHASE_MOVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|
@ -213,12 +229,15 @@ void ChaseMovementGenerator<T>::Reset(T &owner)
|
||||||
template<>
|
template<>
|
||||||
void FollowMovementGenerator<Player>::Initialize(Player &owner)
|
void FollowMovementGenerator<Player>::Initialize(Player &owner)
|
||||||
{
|
{
|
||||||
|
owner.addUnitState(UNIT_STAT_FOLLOW|UNIT_STAT_FOLLOW_MOVE);
|
||||||
_setTargetLocation(owner);
|
_setTargetLocation(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void FollowMovementGenerator<Creature>::Initialize(Creature &owner)
|
void FollowMovementGenerator<Creature>::Initialize(Creature &owner)
|
||||||
{
|
{
|
||||||
|
owner.addUnitState(UNIT_STAT_FOLLOW|UNIT_STAT_FOLLOW_MOVE);
|
||||||
|
|
||||||
if (((Creature*)&owner)->canFly())
|
if (((Creature*)&owner)->canFly())
|
||||||
owner.AddMonsterMoveFlag(MONSTER_MOVE_FLY);
|
owner.AddMonsterMoveFlag(MONSTER_MOVE_FLY);
|
||||||
|
|
||||||
|
|
@ -228,12 +247,13 @@ void FollowMovementGenerator<Creature>::Initialize(Creature &owner)
|
||||||
template<class T>
|
template<class T>
|
||||||
void FollowMovementGenerator<T>::Finalize(T &owner)
|
void FollowMovementGenerator<T>::Finalize(T &owner)
|
||||||
{
|
{
|
||||||
owner.clearUnitState(UNIT_STAT_CHASE | UNIT_STAT_FOLLOW);
|
owner.clearUnitState(UNIT_STAT_FOLLOW|UNIT_STAT_FOLLOW_MOVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void FollowMovementGenerator<T>::Interrupt(T &owner)
|
void FollowMovementGenerator<T>::Interrupt(T &owner)
|
||||||
{
|
{
|
||||||
|
owner.clearUnitState(UNIT_STAT_FOLLOW|UNIT_STAT_FOLLOW_MOVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|
@ -252,6 +272,8 @@ template bool TargetedMovementGeneratorMedium<Player,FollowMovementGenerator<Pla
|
||||||
template bool TargetedMovementGeneratorMedium<Creature,ChaseMovementGenerator<Creature> >::Update(Creature &, const uint32 &);
|
template bool TargetedMovementGeneratorMedium<Creature,ChaseMovementGenerator<Creature> >::Update(Creature &, const uint32 &);
|
||||||
template bool TargetedMovementGeneratorMedium<Creature,FollowMovementGenerator<Creature> >::Update(Creature &, const uint32 &);
|
template bool TargetedMovementGeneratorMedium<Creature,FollowMovementGenerator<Creature> >::Update(Creature &, const uint32 &);
|
||||||
|
|
||||||
|
template void ChaseMovementGenerator<Player>::_reachTarget(Player &);
|
||||||
|
template void ChaseMovementGenerator<Creature>::_reachTarget(Creature &);
|
||||||
template void ChaseMovementGenerator<Player>::Finalize(Player &);
|
template void ChaseMovementGenerator<Player>::Finalize(Player &);
|
||||||
template void ChaseMovementGenerator<Creature>::Finalize(Creature &);
|
template void ChaseMovementGenerator<Creature>::Finalize(Creature &);
|
||||||
template void ChaseMovementGenerator<Player>::Interrupt(Player &);
|
template void ChaseMovementGenerator<Player>::Interrupt(Player &);
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,6 @@ class MANGOS_DLL_SPEC TargetedMovementGeneratorMedium
|
||||||
void UpdateFinalDistance(float fDistance);
|
void UpdateFinalDistance(float fDistance);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void _setTargetLocation(T &);
|
void _setTargetLocation(T &);
|
||||||
|
|
||||||
float i_offset;
|
float i_offset;
|
||||||
|
|
@ -87,6 +86,11 @@ class MANGOS_DLL_SPEC ChaseMovementGenerator : public TargetedMovementGeneratorM
|
||||||
void Finalize(T &);
|
void Finalize(T &);
|
||||||
void Interrupt(T &);
|
void Interrupt(T &);
|
||||||
void Reset(T &);
|
void Reset(T &);
|
||||||
|
|
||||||
|
static void _clearUnitStateMove(T &u) { u.clearUnitState(UNIT_STAT_CHASE_MOVE); }
|
||||||
|
static void _addUnitStateMove(T &u) { u.addUnitState(UNIT_STAT_CHASE_MOVE); }
|
||||||
|
bool _lostTarget(T &u) const { return u.getVictim() != i_target.getTarget(); }
|
||||||
|
void _reachTarget(T &);
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|
@ -105,6 +109,11 @@ class MANGOS_DLL_SPEC FollowMovementGenerator : public TargetedMovementGenerator
|
||||||
void Finalize(T &);
|
void Finalize(T &);
|
||||||
void Interrupt(T &);
|
void Interrupt(T &);
|
||||||
void Reset(T &);
|
void Reset(T &);
|
||||||
|
|
||||||
|
static void _clearUnitStateMove(T &u) { u.clearUnitState(UNIT_STAT_FOLLOW_MOVE); }
|
||||||
|
static void _addUnitStateMove(T &u) { u.addUnitState(UNIT_STAT_FOLLOW_MOVE); }
|
||||||
|
bool _lostTarget(T &) const { return false; }
|
||||||
|
void _reachTarget(T &) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -2159,7 +2159,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
|
||||||
|
|
||||||
void Unit::AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType, bool extra )
|
void Unit::AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType, bool extra )
|
||||||
{
|
{
|
||||||
if(hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_STUNNED | UNIT_STAT_FLEEING | UNIT_STAT_DIED) || HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED) )
|
if(hasUnitState(UNIT_STAT_CAN_NOT_REACT) || HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!pVictim->isAlive())
|
if (!pVictim->isAlive())
|
||||||
|
|
|
||||||
|
|
@ -405,25 +405,63 @@ enum DeathState
|
||||||
DEAD_FALLING= 5
|
DEAD_FALLING= 5
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// internal state flags for some auras and movement generators, other.
|
||||||
enum UnitState
|
enum UnitState
|
||||||
{
|
{
|
||||||
UNIT_STAT_DIED = 0x0001,
|
// persistent state (applied by aura/etc until expire)
|
||||||
UNIT_STAT_MELEE_ATTACKING = 0x0002, // player is melee attacking someone
|
UNIT_STAT_MELEE_ATTACKING = 0x00000001, // unit is melee attacking someone Unit::Attack
|
||||||
//UNIT_STAT_MELEE_ATTACK_BY = 0x0004, // player is melee attack by someone
|
UNIT_STAT_ATTACK_PLAYER = 0x00000002, // unit attack player or player's controlled unit and have contested pvpv timer setup, until timer expire, combat end and etc
|
||||||
UNIT_STAT_STUNNED = 0x0008,
|
UNIT_STAT_DIED = 0x00000004, // Unit::SetFeignDeath
|
||||||
UNIT_STAT_ROAMING = 0x0010,
|
UNIT_STAT_STUNNED = 0x00000008, // Aura::HandleAuraModStun
|
||||||
UNIT_STAT_CHASE = 0x0020,
|
UNIT_STAT_ROOT = 0x00000010, // Aura::HandleAuraModRoot
|
||||||
//UNIT_STAT_SEARCHING = 0x0040,
|
UNIT_STAT_ISOLATED = 0x00000020, // area auras do not affect other players, Aura::HandleAuraModSchoolImmunity
|
||||||
UNIT_STAT_FLEEING = 0x0080,
|
|
||||||
UNIT_STAT_MOVING = (UNIT_STAT_ROAMING | UNIT_STAT_CHASE | UNIT_STAT_FLEEING),
|
// persistent movement generator state (all time while movement generator applied to unit (independent from top state of movegen)
|
||||||
UNIT_STAT_IN_FLIGHT = 0x0100, // player is in flight mode
|
UNIT_STAT_IN_FLIGHT = 0x00000040, // player is in flight mode
|
||||||
UNIT_STAT_FOLLOW = 0x0200,
|
UNIT_STAT_DISTRACTED = 0x00000080, // DistractedMovementGenerator active
|
||||||
UNIT_STAT_ROOT = 0x0400,
|
|
||||||
UNIT_STAT_CONFUSED = 0x0800,
|
// persistent movement generator state with non-persistent mirror states for stop support
|
||||||
UNIT_STAT_DISTRACTED = 0x1000,
|
// (can be removed temporary by stop command or another movement generator apply)
|
||||||
UNIT_STAT_ISOLATED = 0x2000, // area auras do not affect other players
|
// not use _MOVE versions for generic movegen state, it can be removed temporary for unit stop and etc
|
||||||
UNIT_STAT_ATTACK_PLAYER = 0x4000,
|
UNIT_STAT_CONFUSED = 0x00000100, // ConfusedMovementGenerator active/onstack
|
||||||
UNIT_STAT_ALL_STATE = 0xffff //(UNIT_STAT_STOPPED | UNIT_STAT_MOVING | UNIT_STAT_IN_COMBAT | UNIT_STAT_IN_FLIGHT)
|
UNIT_STAT_CONFUSED_MOVE = 0x00000200,
|
||||||
|
UNIT_STAT_ROAMING = 0x00000400, // RandomMovementGenerator/PointMovementGenerator/WaypointMovementGenerator active (now always set)
|
||||||
|
UNIT_STAT_ROAMING_MOVE = 0x00000800,
|
||||||
|
UNIT_STAT_CHASE = 0x00001000, // ChaseMovementGenerator active
|
||||||
|
UNIT_STAT_CHASE_MOVE = 0x00002000,
|
||||||
|
UNIT_STAT_FOLLOW = 0x00004000, // FollowMovementGenerator active
|
||||||
|
UNIT_STAT_FOLLOW_MOVE = 0x00008000,
|
||||||
|
UNIT_STAT_FLEEING = 0x00010000, // FleeMovementGenerator/TimedFleeingMovementGenerator active/onstack
|
||||||
|
UNIT_STAT_FLEEING_MOVE = 0x00020000,
|
||||||
|
|
||||||
|
// masks (only for check)
|
||||||
|
|
||||||
|
// can't move currently
|
||||||
|
UNIT_STAT_CAN_NOT_MOVE = UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DIED,
|
||||||
|
|
||||||
|
// stay by different reasons
|
||||||
|
UNIT_STAT_NOT_MOVE = UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DIED |
|
||||||
|
UNIT_STAT_DISTRACTED,
|
||||||
|
|
||||||
|
// stay or scripted movement for effect( = in player case you can't move by client command)
|
||||||
|
UNIT_STAT_NO_FREE_MOVE = UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DIED |
|
||||||
|
UNIT_STAT_IN_FLIGHT |
|
||||||
|
UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING,
|
||||||
|
|
||||||
|
UNIT_STAT_MOVE_INTERRUPRED= UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DIED |
|
||||||
|
UNIT_STAT_IN_FLIGHT | UNIT_STAT_DISTRACTED |
|
||||||
|
UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING,
|
||||||
|
|
||||||
|
// not react at move in sight or other
|
||||||
|
UNIT_STAT_CAN_NOT_REACT = UNIT_STAT_STUNNED | UNIT_STAT_DIED |
|
||||||
|
UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING,
|
||||||
|
|
||||||
|
// masks (for check or reset)
|
||||||
|
|
||||||
|
// for real move using movegen check and stop (except unstoppable flight)
|
||||||
|
UNIT_STAT_MOVING = UNIT_STAT_ROAMING_MOVE | UNIT_STAT_CHASE_MOVE | UNIT_STAT_FOLLOW_MOVE | UNIT_STAT_FLEEING_MOVE,
|
||||||
|
|
||||||
|
UNIT_STAT_ALL_STATE = 0xFFFFFFFF
|
||||||
};
|
};
|
||||||
|
|
||||||
enum UnitMoveType
|
enum UnitMoveType
|
||||||
|
|
@ -944,12 +982,11 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
|
||||||
void SendMeleeAttackStart(Unit* pVictim);
|
void SendMeleeAttackStart(Unit* pVictim);
|
||||||
|
|
||||||
void addUnitState(uint32 f) { m_state |= f; }
|
void addUnitState(uint32 f) { m_state |= f; }
|
||||||
bool hasUnitState(const uint32 f) const { return (m_state & f); }
|
bool hasUnitState(uint32 f) const { return (m_state & f); }
|
||||||
void clearUnitState(uint32 f) { m_state &= ~f; }
|
void clearUnitState(uint32 f) { m_state &= ~f; }
|
||||||
bool CanFreeMove() const
|
bool CanFreeMove() const
|
||||||
{
|
{
|
||||||
return !hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING | UNIT_STAT_IN_FLIGHT |
|
return !hasUnitState(UNIT_STAT_NO_FREE_MOVE) && GetOwnerGUID()==0;
|
||||||
UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED | UNIT_STAT_DIED ) && GetOwnerGUID()==0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 getLevel() const { return GetUInt32Value(UNIT_FIELD_LEVEL); }
|
uint32 getLevel() const { return GetUInt32Value(UNIT_FIELD_LEVEL); }
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,32 @@ void WaypointMovementGenerator<Creature>::ClearWaypoints()
|
||||||
i_path = NULL;
|
i_path = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WaypointMovementGenerator<Creature>::Initialize( Creature &u )
|
||||||
|
{
|
||||||
|
i_nextMoveTime.Reset(0); // TODO: check the lower bound (0 is probably too small)
|
||||||
|
u.StopMoving();
|
||||||
|
LoadPath(u);
|
||||||
|
u.addUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WaypointMovementGenerator<Creature>::Finalize( Creature &u )
|
||||||
|
{
|
||||||
|
u.clearUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WaypointMovementGenerator<Creature>::Interrupt( Creature &u )
|
||||||
|
{
|
||||||
|
u.addUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WaypointMovementGenerator<Creature>::Reset( Creature &u )
|
||||||
|
{
|
||||||
|
ReloadPath(u);
|
||||||
|
b_StoppedByPlayer = false;
|
||||||
|
i_nextMoveTime.Reset(0);
|
||||||
|
u.addUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING);
|
||||||
|
}
|
||||||
|
|
||||||
bool WaypointMovementGenerator<Creature>::Update(Creature &creature, const uint32 &diff)
|
bool WaypointMovementGenerator<Creature>::Update(Creature &creature, const uint32 &diff)
|
||||||
{
|
{
|
||||||
if (!&creature)
|
if (!&creature)
|
||||||
|
|
@ -81,12 +107,18 @@ bool WaypointMovementGenerator<Creature>::Update(Creature &creature, const uint3
|
||||||
|
|
||||||
// Waypoint movement can be switched on/off
|
// Waypoint movement can be switched on/off
|
||||||
// This is quite handy for escort quests and other stuff
|
// This is quite handy for escort quests and other stuff
|
||||||
if (creature.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DISTRACTED | UNIT_STAT_DIED))
|
if (creature.hasUnitState(UNIT_STAT_NOT_MOVE))
|
||||||
|
{
|
||||||
|
creature.clearUnitState(UNIT_STAT_ROAMING_MOVE);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// prevent a crash at empty waypoint path.
|
// prevent a crash at empty waypoint path.
|
||||||
if (!i_path || i_path->empty())
|
if (!i_path || i_path->empty())
|
||||||
|
{
|
||||||
|
creature.clearUnitState(UNIT_STAT_ROAMING_MOVE);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// i_path was modified by chat commands for example
|
// i_path was modified by chat commands for example
|
||||||
if (i_path->size() != i_hasDone.size())
|
if (i_path->size() != i_hasDone.size())
|
||||||
|
|
@ -108,7 +140,7 @@ bool WaypointMovementGenerator<Creature>::Update(Creature &creature, const uint3
|
||||||
{
|
{
|
||||||
SetStoppedByPlayer(false);
|
SetStoppedByPlayer(false);
|
||||||
|
|
||||||
creature.addUnitState(UNIT_STAT_ROAMING);
|
creature.addUnitState(UNIT_STAT_ROAMING_MOVE);
|
||||||
|
|
||||||
if (creature.canFly())
|
if (creature.canFly())
|
||||||
creature.AddMonsterMoveFlag(MONSTER_MOVE_FLY);
|
creature.AddMonsterMoveFlag(MONSTER_MOVE_FLY);
|
||||||
|
|
@ -183,7 +215,7 @@ bool WaypointMovementGenerator<Creature>::Update(Creature &creature, const uint3
|
||||||
// If stopped then begin a new move segment
|
// If stopped then begin a new move segment
|
||||||
if (creature.IsStopped())
|
if (creature.IsStopped())
|
||||||
{
|
{
|
||||||
creature.addUnitState(UNIT_STAT_ROAMING);
|
creature.addUnitState(UNIT_STAT_ROAMING_MOVE);
|
||||||
|
|
||||||
if (creature.canFly())
|
if (creature.canFly())
|
||||||
creature.AddMonsterMoveFlag(MONSTER_MOVE_FLY);
|
creature.AddMonsterMoveFlag(MONSTER_MOVE_FLY);
|
||||||
|
|
|
||||||
|
|
@ -76,20 +76,10 @@ public PathMovementBase<Creature, WaypointPath*>
|
||||||
public:
|
public:
|
||||||
WaypointMovementGenerator(Creature &) : i_nextMoveTime(0), b_StoppedByPlayer(false) {}
|
WaypointMovementGenerator(Creature &) : i_nextMoveTime(0), b_StoppedByPlayer(false) {}
|
||||||
~WaypointMovementGenerator() { ClearWaypoints(); }
|
~WaypointMovementGenerator() { ClearWaypoints(); }
|
||||||
void Initialize(Creature &u)
|
void Initialize(Creature &u);
|
||||||
{
|
void Interrupt(Creature &);
|
||||||
i_nextMoveTime.Reset(0); // TODO: check the lower bound (0 is probably too small)
|
void Finalize(Creature &);
|
||||||
u.StopMoving();
|
void Reset(Creature &u);
|
||||||
LoadPath(u);
|
|
||||||
}
|
|
||||||
void Interrupt(Creature &) {}
|
|
||||||
void Finalize(Creature &) {}
|
|
||||||
void Reset(Creature &u)
|
|
||||||
{
|
|
||||||
ReloadPath(u);
|
|
||||||
b_StoppedByPlayer = false;
|
|
||||||
i_nextMoveTime.Reset(0);
|
|
||||||
}
|
|
||||||
bool Update(Creature &u, const uint32 &diff);
|
bool Update(Creature &u, const uint32 &diff);
|
||||||
|
|
||||||
void MovementInform(Creature &);
|
void MovementInform(Creature &);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "9207"
|
#define REVISION_NR "9208"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue