mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 01:37:00 +00:00
[11721] Simplify walk/run movement mode selection code
This commit is contained in:
parent
9d566398ad
commit
fc0eb7e9fa
10 changed files with 10 additions and 54 deletions
|
|
@ -2487,7 +2487,6 @@ void Creature::SetWalk(bool enable)
|
|||
WorldPacket data(enable ? SMSG_SPLINE_MOVE_SET_WALK_MODE : SMSG_SPLINE_MOVE_SET_RUN_MODE, 9);
|
||||
data << GetPackGUID();
|
||||
SendMessageToSet(&data, true);
|
||||
UpdateWalkMode(this, false);
|
||||
}
|
||||
|
||||
void Creature::SetLevitate(bool enable)
|
||||
|
|
|
|||
|
|
@ -518,8 +518,6 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
|||
|
||||
void SetWalk(bool enable);
|
||||
void SetLevitate(bool enable);
|
||||
bool IsLevitating() const { return m_movementInfo.HasMovementFlag(MOVEFLAG_LEVITATING);}
|
||||
bool IsWalking() const { return m_movementInfo.HasMovementFlag(MOVEFLAG_WALK_MODE);}
|
||||
|
||||
uint32 GetShieldBlockValue() const // dunno mob block value
|
||||
{
|
||||
|
|
|
|||
|
|
@ -286,10 +286,6 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
|
|||
if (plMover)
|
||||
plMover->UpdateFallInformationIfNeed(movementInfo, opcode);
|
||||
|
||||
// after move info set
|
||||
if (opcode == MSG_MOVE_SET_WALK_MODE || opcode == MSG_MOVE_SET_RUN_MODE)
|
||||
mover->UpdateWalkMode(mover, false);
|
||||
|
||||
WorldPacket data(opcode, recv_data.size());
|
||||
data << mover->GetPackGUID(); // write guid
|
||||
movementInfo.Write(data); // write data
|
||||
|
|
|
|||
|
|
@ -283,8 +283,6 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool
|
|||
SetPower(POWER_MANA, savedmana > GetMaxPower(POWER_MANA) ? GetMaxPower(POWER_MANA) : savedmana);
|
||||
}
|
||||
|
||||
UpdateWalkMode(owner);
|
||||
|
||||
AIM_Initialize();
|
||||
map->Add((Creature*)this);
|
||||
|
||||
|
|
|
|||
|
|
@ -4719,8 +4719,6 @@ void Spell::DoSummon(SpellEffectIndex eff_idx)
|
|||
|
||||
spawnCreature->GetCharmInfo()->SetPetNumber(pet_number, false);
|
||||
|
||||
spawnCreature->UpdateWalkMode(m_caster);
|
||||
|
||||
spawnCreature->AIM_Initialize();
|
||||
spawnCreature->InitPetCreateSpells();
|
||||
spawnCreature->InitLevelupSpellsForLevel();
|
||||
|
|
@ -5640,8 +5638,6 @@ void Spell::EffectSummonPet(SpellEffectIndex eff_idx)
|
|||
NewSummon->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000);
|
||||
NewSummon->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);
|
||||
|
||||
NewSummon->UpdateWalkMode(m_caster);
|
||||
|
||||
NewSummon->GetCharmInfo()->SetPetNumber(pet_number, true);
|
||||
// this enables pet details window (Shift+P)
|
||||
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ void TargetedMovementGeneratorMedium<T,D>::_setTargetLocation(T &owner)
|
|||
|
||||
Movement::MoveSplineInit init(owner);
|
||||
init.MoveTo(x,y,z);
|
||||
init.SetWalk(((D*)this)->EnableWalking());
|
||||
init.Launch();
|
||||
}
|
||||
|
||||
|
|
@ -216,15 +217,15 @@ void ChaseMovementGenerator<T>::Reset(T &owner)
|
|||
|
||||
//-----------------------------------------------//
|
||||
template<>
|
||||
void FollowMovementGenerator<Creature>::_updateWalkMode(Creature &u)
|
||||
bool FollowMovementGenerator<Creature>::EnableWalking() const
|
||||
{
|
||||
if (i_target.isValid() && u.IsPet())
|
||||
u.UpdateWalkMode(i_target.getTarget());
|
||||
return i_target.isValid() && i_target->IsWalking();
|
||||
}
|
||||
|
||||
template<>
|
||||
void FollowMovementGenerator<Player>::_updateWalkMode(Player &)
|
||||
bool FollowMovementGenerator<Player>::EnableWalking() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
template<>
|
||||
|
|
@ -249,7 +250,6 @@ template<>
|
|||
void FollowMovementGenerator<Player>::Initialize(Player &owner)
|
||||
{
|
||||
owner.addUnitState(UNIT_STAT_FOLLOW|UNIT_STAT_FOLLOW_MOVE);
|
||||
_updateWalkMode(owner);
|
||||
_updateSpeed(owner);
|
||||
_setTargetLocation(owner);
|
||||
}
|
||||
|
|
@ -258,7 +258,6 @@ template<>
|
|||
void FollowMovementGenerator<Creature>::Initialize(Creature &owner)
|
||||
{
|
||||
owner.addUnitState(UNIT_STAT_FOLLOW|UNIT_STAT_FOLLOW_MOVE);
|
||||
_updateWalkMode(owner);
|
||||
_updateSpeed(owner);
|
||||
_setTargetLocation(owner);
|
||||
}
|
||||
|
|
@ -267,7 +266,6 @@ template<class T>
|
|||
void FollowMovementGenerator<T>::Finalize(T &owner)
|
||||
{
|
||||
owner.clearUnitState(UNIT_STAT_FOLLOW|UNIT_STAT_FOLLOW_MOVE);
|
||||
_updateWalkMode(owner);
|
||||
_updateSpeed(owner);
|
||||
}
|
||||
|
||||
|
|
@ -275,7 +273,6 @@ template<class T>
|
|||
void FollowMovementGenerator<T>::Interrupt(T &owner)
|
||||
{
|
||||
owner.clearUnitState(UNIT_STAT_FOLLOW|UNIT_STAT_FOLLOW_MOVE);
|
||||
_updateWalkMode(owner);
|
||||
_updateSpeed(owner);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ class MANGOS_DLL_SPEC ChaseMovementGenerator : public TargetedMovementGeneratorM
|
|||
|
||||
static void _clearUnitStateMove(T &u) { u.clearUnitState(UNIT_STAT_CHASE_MOVE); }
|
||||
static void _addUnitStateMove(T &u) { u.addUnitState(UNIT_STAT_CHASE_MOVE); }
|
||||
bool EnableWalking() const { return false;}
|
||||
bool _lostTarget(T &u) const { return u.getVictim() != this->GetTarget(); }
|
||||
void _reachTarget(T &);
|
||||
};
|
||||
|
|
@ -103,10 +104,10 @@ class MANGOS_DLL_SPEC FollowMovementGenerator : public TargetedMovementGenerator
|
|||
|
||||
static void _clearUnitStateMove(T &u) { u.clearUnitState(UNIT_STAT_FOLLOW_MOVE); }
|
||||
static void _addUnitStateMove(T &u) { u.addUnitState(UNIT_STAT_FOLLOW_MOVE); }
|
||||
bool EnableWalking() const;
|
||||
bool _lostTarget(T &) const { return false; }
|
||||
void _reachTarget(T &) {}
|
||||
private:
|
||||
void _updateWalkMode(T &u);
|
||||
void _updateSpeed(T &u);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -8122,36 +8122,6 @@ bool Unit::canDetectInvisibilityOf(Unit const* u) const
|
|||
return false;
|
||||
}
|
||||
|
||||
struct UpdateWalkModeHelper
|
||||
{
|
||||
explicit UpdateWalkModeHelper(Unit* _source) : source(_source) {}
|
||||
void operator()(Unit* unit) const { unit->UpdateWalkMode(source, true); }
|
||||
Unit* source;
|
||||
};
|
||||
|
||||
void Unit::UpdateWalkMode(Unit* source, bool self)
|
||||
{
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
CallForAllControlledUnits(UpdateWalkModeHelper(source), CONTROLLED_PET|CONTROLLED_GUARDIANS|CONTROLLED_CHARM|CONTROLLED_MINIPET);
|
||||
else if (self)
|
||||
{
|
||||
bool on = source->m_movementInfo.HasMovementFlag(MOVEFLAG_WALK_MODE);
|
||||
|
||||
if (on)
|
||||
{
|
||||
if (((Creature*)this)->IsPet() && hasUnitState(UNIT_STAT_FOLLOW))
|
||||
((Creature*)this)->SetWalk(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (((Creature*)this)->IsPet())
|
||||
((Creature*)this)->SetWalk(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
CallForAllControlledUnits(UpdateWalkModeHelper(source), CONTROLLED_PET|CONTROLLED_GUARDIANS|CONTROLLED_CHARM|CONTROLLED_MINIPET);
|
||||
}
|
||||
|
||||
void Unit::UpdateSpeed(UnitMoveType mtype, bool forced, float ratio)
|
||||
{
|
||||
// not in combat pet have same speed as owner
|
||||
|
|
|
|||
|
|
@ -1467,6 +1467,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
|
|||
// recommend use MonsterMove/MonsterMoveWithSpeed for most case that correctly work with movegens
|
||||
// if used additional args in ... part then floats must explicitly casted to double
|
||||
void SendHeartBeat();
|
||||
bool IsLevitating() const { return m_movementInfo.HasMovementFlag(MOVEFLAG_LEVITATING);}
|
||||
bool IsWalking() const { return m_movementInfo.HasMovementFlag(MOVEFLAG_WALK_MODE);}
|
||||
|
||||
void SetInFront(Unit const* target);
|
||||
void SetFacingTo(float ori);
|
||||
|
|
@ -1886,7 +1888,6 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
|
|||
void CalculateAbsorbResistBlock(Unit *pCaster, SpellNonMeleeDamage *damageInfo, SpellEntry const* spellProto, WeaponAttackType attType = BASE_ATTACK);
|
||||
void CalculateHealAbsorb(uint32 heal, uint32 *absorb);
|
||||
|
||||
void UpdateWalkMode(Unit* source, bool self = true);
|
||||
void UpdateSpeed(UnitMoveType mtype, bool forced, float ratio = 1.0f);
|
||||
float GetSpeed( UnitMoveType mtype ) const;
|
||||
float GetSpeedRate( UnitMoveType mtype ) const { return m_speed_rate[mtype]; }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "11720"
|
||||
#define REVISION_NR "11721"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue