mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 10:37:02 +00:00
[9209] Finish synchonization walk mode for pets.
* Re-sync at follow mode switches * Support sync for creature pets Also * Attempt fix build at *nix * Drop unused unut state mask with typo in name.
This commit is contained in:
parent
6a2e8064f1
commit
e1d0c1cdba
9 changed files with 62 additions and 27 deletions
|
|
@ -429,11 +429,29 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
||||||
void AI_SendMoveToPacket(float x, float y, float z, uint32 time, MonsterMovementFlags MovementFlags, uint8 type);
|
void AI_SendMoveToPacket(float x, float y, float z, uint32 time, MonsterMovementFlags MovementFlags, uint8 type);
|
||||||
CreatureAI* AI() { return i_AI; }
|
CreatureAI* AI() { return i_AI; }
|
||||||
|
|
||||||
void AddMonsterMoveFlag(MonsterMovementFlags f) { m_monsterMoveFlags = MonsterMovementFlags(m_monsterMoveFlags | f); }
|
void AddMonsterMoveFlag(MonsterMovementFlags f)
|
||||||
void RemoveMonsterMoveFlag(MonsterMovementFlags f) { m_monsterMoveFlags = MonsterMovementFlags(m_monsterMoveFlags & ~f); }
|
{
|
||||||
|
bool need_walk_sync = (f & MONSTER_MOVE_WALK) != (m_monsterMoveFlags & MONSTER_MOVE_WALK);
|
||||||
|
m_monsterMoveFlags = MonsterMovementFlags(m_monsterMoveFlags | f);
|
||||||
|
if (need_walk_sync)
|
||||||
|
UpdateWalkMode(this,false);
|
||||||
|
}
|
||||||
|
void RemoveMonsterMoveFlag(MonsterMovementFlags f)
|
||||||
|
{
|
||||||
|
bool need_walk_sync = (f & MONSTER_MOVE_WALK) != (m_monsterMoveFlags & MONSTER_MOVE_WALK);
|
||||||
|
m_monsterMoveFlags = MonsterMovementFlags(m_monsterMoveFlags & ~f);
|
||||||
|
if (need_walk_sync)
|
||||||
|
UpdateWalkMode(this,false);
|
||||||
|
}
|
||||||
bool HasMonsterMoveFlag(MonsterMovementFlags f) const { return m_monsterMoveFlags & f; }
|
bool HasMonsterMoveFlag(MonsterMovementFlags f) const { return m_monsterMoveFlags & f; }
|
||||||
MonsterMovementFlags GetMonsterMoveFlags() const { return m_monsterMoveFlags; }
|
MonsterMovementFlags GetMonsterMoveFlags() const { return m_monsterMoveFlags; }
|
||||||
void SetMonsterMoveFlags(MonsterMovementFlags f) { m_monsterMoveFlags = f; }
|
void SetMonsterMoveFlags(MonsterMovementFlags f)
|
||||||
|
{
|
||||||
|
bool need_walk_sync = (f & MONSTER_MOVE_WALK) != (m_monsterMoveFlags & MONSTER_MOVE_WALK);
|
||||||
|
m_monsterMoveFlags = f; // need set before
|
||||||
|
if (need_walk_sync)
|
||||||
|
UpdateWalkMode(this,false);
|
||||||
|
}
|
||||||
|
|
||||||
void SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTime = 0, Player* player = NULL);
|
void SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTime = 0, Player* player = NULL);
|
||||||
void SendMonsterMoveWithSpeedToCurrentDestination(Player* player = NULL);
|
void SendMonsterMoveWithSpeedToCurrentDestination(Player* player = NULL);
|
||||||
|
|
|
||||||
|
|
@ -299,9 +299,6 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
|
||||||
if (opcode == MSG_MOVE_FALL_LAND && plMover && !plMover->isInFlight())
|
if (opcode == MSG_MOVE_FALL_LAND && plMover && !plMover->isInFlight())
|
||||||
plMover->HandleFall(movementInfo);
|
plMover->HandleFall(movementInfo);
|
||||||
|
|
||||||
if ((opcode == MSG_MOVE_SET_WALK_MODE || opcode == MSG_MOVE_SET_RUN_MODE) && plMover)
|
|
||||||
plMover->UpdateWalkModeForPets(movementInfo.HasMovementFlag(MOVEMENTFLAG_WALK_MODE));
|
|
||||||
|
|
||||||
if (plMover && (movementInfo.HasMovementFlag(MOVEMENTFLAG_SWIMMING) != plMover->IsInWater()))
|
if (plMover && (movementInfo.HasMovementFlag(MOVEMENTFLAG_SWIMMING) != plMover->IsInWater()))
|
||||||
{
|
{
|
||||||
// now client not include swimming flag in case jumping under water
|
// now client not include swimming flag in case jumping under water
|
||||||
|
|
@ -323,6 +320,10 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
|
||||||
plMover->m_movementInfo = movementInfo;
|
plMover->m_movementInfo = movementInfo;
|
||||||
plMover->UpdateFallInformationIfNeed(movementInfo, opcode);
|
plMover->UpdateFallInformationIfNeed(movementInfo, opcode);
|
||||||
|
|
||||||
|
// after move info set
|
||||||
|
if ((opcode == MSG_MOVE_SET_WALK_MODE || opcode == MSG_MOVE_SET_RUN_MODE))
|
||||||
|
plMover->UpdateWalkMode(plMover,false);
|
||||||
|
|
||||||
if(plMover->isMovingOrTurning())
|
if(plMover->isMovingOrTurning())
|
||||||
plMover->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
|
plMover->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -293,7 +293,7 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool
|
||||||
SetPower(POWER_MANA, savedmana > GetMaxPower(POWER_MANA) ? GetMaxPower(POWER_MANA) : savedmana);
|
SetPower(POWER_MANA, savedmana > GetMaxPower(POWER_MANA) ? GetMaxPower(POWER_MANA) : savedmana);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateWalkModeForPets(owner->HasMovementFlag(MOVEMENTFLAG_WALK_MODE));
|
UpdateWalkMode(owner);
|
||||||
|
|
||||||
AIM_Initialize();
|
AIM_Initialize();
|
||||||
map->Add((Creature*)this);
|
map->Add((Creature*)this);
|
||||||
|
|
|
||||||
|
|
@ -3524,8 +3524,7 @@ void Spell::EffectSummon(uint32 i)
|
||||||
|
|
||||||
spawnCreature->GetCharmInfo()->SetPetNumber(pet_number, false);
|
spawnCreature->GetCharmInfo()->SetPetNumber(pet_number, false);
|
||||||
|
|
||||||
if (m_caster->GetTypeId() == TYPEID_PLAYER)
|
spawnCreature->UpdateWalkMode(m_caster);
|
||||||
spawnCreature->UpdateWalkModeForPets(((Player*)m_caster)->HasMovementFlag(MOVEMENTFLAG_WALK_MODE));
|
|
||||||
|
|
||||||
spawnCreature->AIM_Initialize();
|
spawnCreature->AIM_Initialize();
|
||||||
spawnCreature->InitPetCreateSpells();
|
spawnCreature->InitPetCreateSpells();
|
||||||
|
|
@ -4393,8 +4392,7 @@ void Spell::EffectSummonPet(uint32 i)
|
||||||
NewSummon->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000);
|
NewSummon->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000);
|
||||||
NewSummon->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);
|
NewSummon->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);
|
||||||
|
|
||||||
if (m_caster->GetTypeId() == TYPEID_PLAYER)
|
NewSummon->UpdateWalkMode(m_caster);
|
||||||
NewSummon->UpdateWalkModeForPets(((Player*)m_caster)->HasMovementFlag(MOVEMENTFLAG_WALK_MODE));
|
|
||||||
|
|
||||||
NewSummon->GetCharmInfo()->SetPetNumber(pet_number, true);
|
NewSummon->GetCharmInfo()->SetPetNumber(pet_number, true);
|
||||||
// this enables pet details window (Shift+P)
|
// this enables pet details window (Shift+P)
|
||||||
|
|
|
||||||
|
|
@ -226,10 +226,23 @@ void ChaseMovementGenerator<T>::Reset(T &owner)
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------//
|
//-----------------------------------------------//
|
||||||
|
template<>
|
||||||
|
void FollowMovementGenerator<Creature>::_updateWalkMode(Creature &u)
|
||||||
|
{
|
||||||
|
if (i_target.isValid() && u.isPet())
|
||||||
|
u.UpdateWalkMode(i_target.getTarget());
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
void FollowMovementGenerator<Player>::_updateWalkMode(Player &)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void FollowMovementGenerator<Player>::Initialize(Player &owner)
|
void FollowMovementGenerator<Player>::Initialize(Player &owner)
|
||||||
{
|
{
|
||||||
owner.addUnitState(UNIT_STAT_FOLLOW|UNIT_STAT_FOLLOW_MOVE);
|
owner.addUnitState(UNIT_STAT_FOLLOW|UNIT_STAT_FOLLOW_MOVE);
|
||||||
|
_updateWalkMode(owner);
|
||||||
_setTargetLocation(owner);
|
_setTargetLocation(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -237,6 +250,7 @@ template<>
|
||||||
void FollowMovementGenerator<Creature>::Initialize(Creature &owner)
|
void FollowMovementGenerator<Creature>::Initialize(Creature &owner)
|
||||||
{
|
{
|
||||||
owner.addUnitState(UNIT_STAT_FOLLOW|UNIT_STAT_FOLLOW_MOVE);
|
owner.addUnitState(UNIT_STAT_FOLLOW|UNIT_STAT_FOLLOW_MOVE);
|
||||||
|
_updateWalkMode(owner);
|
||||||
|
|
||||||
if (((Creature*)&owner)->canFly())
|
if (((Creature*)&owner)->canFly())
|
||||||
owner.AddMonsterMoveFlag(MONSTER_MOVE_FLY);
|
owner.AddMonsterMoveFlag(MONSTER_MOVE_FLY);
|
||||||
|
|
@ -248,12 +262,14 @@ template<class T>
|
||||||
void FollowMovementGenerator<T>::Finalize(T &owner)
|
void FollowMovementGenerator<T>::Finalize(T &owner)
|
||||||
{
|
{
|
||||||
owner.clearUnitState(UNIT_STAT_FOLLOW|UNIT_STAT_FOLLOW_MOVE);
|
owner.clearUnitState(UNIT_STAT_FOLLOW|UNIT_STAT_FOLLOW_MOVE);
|
||||||
|
_updateWalkMode(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
owner.clearUnitState(UNIT_STAT_FOLLOW|UNIT_STAT_FOLLOW_MOVE);
|
||||||
|
_updateWalkMode(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ class MANGOS_DLL_SPEC ChaseMovementGenerator : public TargetedMovementGeneratorM
|
||||||
|
|
||||||
static void _clearUnitStateMove(T &u) { u.clearUnitState(UNIT_STAT_CHASE_MOVE); }
|
static void _clearUnitStateMove(T &u) { u.clearUnitState(UNIT_STAT_CHASE_MOVE); }
|
||||||
static void _addUnitStateMove(T &u) { u.addUnitState(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(); }
|
bool _lostTarget(T &u) const { return u.getVictim() != GetTarget(); }
|
||||||
void _reachTarget(T &);
|
void _reachTarget(T &);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -114,6 +114,8 @@ class MANGOS_DLL_SPEC FollowMovementGenerator : public TargetedMovementGenerator
|
||||||
static void _addUnitStateMove(T &u) { u.addUnitState(UNIT_STAT_FOLLOW_MOVE); }
|
static void _addUnitStateMove(T &u) { u.addUnitState(UNIT_STAT_FOLLOW_MOVE); }
|
||||||
bool _lostTarget(T &) const { return false; }
|
bool _lostTarget(T &) const { return false; }
|
||||||
void _reachTarget(T &) {}
|
void _reachTarget(T &) {}
|
||||||
|
private:
|
||||||
|
void _updateWalkMode(T &u);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -10394,19 +10394,23 @@ bool Unit::canDetectInvisibilityOf(Unit const* u) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct UpdateWalkModeForPetsHelper
|
struct UpdateWalkModeHelper
|
||||||
{
|
{
|
||||||
explicit UpdateWalkModeForPetsHelper(bool _on) : on(_on) {}
|
explicit UpdateWalkModeHelper(Unit* _source) : source(_source) {}
|
||||||
void operator()(Unit* unit) const { unit->UpdateWalkModeForPets(on); }
|
void operator()(Unit* unit) const { unit->UpdateWalkMode(source, true); }
|
||||||
bool on;
|
Unit* source;
|
||||||
};
|
};
|
||||||
|
|
||||||
void Unit::UpdateWalkModeForPets(bool on)
|
void Unit::UpdateWalkMode(Unit* source, bool self)
|
||||||
{
|
{
|
||||||
if (GetTypeId() == TYPEID_PLAYER)
|
if (GetTypeId() == TYPEID_PLAYER)
|
||||||
((Player*)this)->CallForAllControlledUnits(UpdateWalkModeForPetsHelper(on),false,true,true,true);
|
((Player*)this)->CallForAllControlledUnits(UpdateWalkModeHelper(source),false,true,true,true);
|
||||||
else
|
else if (self)
|
||||||
{
|
{
|
||||||
|
bool on = source->GetTypeId() == TYPEID_PLAYER
|
||||||
|
? ((Player*)source)->HasMovementFlag(MOVEMENTFLAG_WALK_MODE)
|
||||||
|
: ((Creature*)source)->HasMonsterMoveFlag(MONSTER_MOVE_WALK);
|
||||||
|
|
||||||
if (on)
|
if (on)
|
||||||
{
|
{
|
||||||
if (((Creature*)this)->isPet() && hasUnitState(UNIT_STAT_FOLLOW))
|
if (((Creature*)this)->isPet() && hasUnitState(UNIT_STAT_FOLLOW))
|
||||||
|
|
@ -10417,9 +10421,9 @@ void Unit::UpdateWalkModeForPets(bool on)
|
||||||
if (((Creature*)this)->isPet())
|
if (((Creature*)this)->isPet())
|
||||||
((Creature*)this)->RemoveMonsterMoveFlag(MONSTER_MOVE_WALK);
|
((Creature*)this)->RemoveMonsterMoveFlag(MONSTER_MOVE_WALK);
|
||||||
}
|
}
|
||||||
|
|
||||||
CallForAllControlledUnits(UpdateWalkModeForPetsHelper(on),false,true,true);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
CallForAllControlledUnits(UpdateWalkModeHelper(source),false,true,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unit::UpdateSpeed(UnitMoveType mtype, bool forced)
|
void Unit::UpdateSpeed(UnitMoveType mtype, bool forced)
|
||||||
|
|
|
||||||
|
|
@ -448,10 +448,6 @@ enum UnitState
|
||||||
UNIT_STAT_IN_FLIGHT |
|
UNIT_STAT_IN_FLIGHT |
|
||||||
UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING,
|
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
|
// not react at move in sight or other
|
||||||
UNIT_STAT_CAN_NOT_REACT = UNIT_STAT_STUNNED | UNIT_STAT_DIED |
|
UNIT_STAT_CAN_NOT_REACT = UNIT_STAT_STUNNED | UNIT_STAT_DIED |
|
||||||
UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING,
|
UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING,
|
||||||
|
|
@ -1561,7 +1557,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
|
||||||
uint32 CalcArmorReducedDamage(Unit* pVictim, const uint32 damage);
|
uint32 CalcArmorReducedDamage(Unit* pVictim, const uint32 damage);
|
||||||
void CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEffectType damagetype, const uint32 damage, uint32 *absorb, uint32 *resist, bool canReflect = false);
|
void CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEffectType damagetype, const uint32 damage, uint32 *absorb, uint32 *resist, bool canReflect = false);
|
||||||
|
|
||||||
void UpdateWalkModeForPets(bool on);
|
void UpdateWalkMode(Unit* source, bool self = true);
|
||||||
void UpdateSpeed(UnitMoveType mtype, bool forced);
|
void UpdateSpeed(UnitMoveType mtype, bool forced);
|
||||||
float GetSpeed( UnitMoveType mtype ) const;
|
float GetSpeed( UnitMoveType mtype ) const;
|
||||||
float GetSpeedRate( UnitMoveType mtype ) const { return m_speed_rate[mtype]; }
|
float GetSpeedRate( UnitMoveType mtype ) const { return m_speed_rate[mtype]; }
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "9208"
|
#define REVISION_NR "9209"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue