mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 04:37:00 +00:00
[9197] More propertly update walk mode for player pets.
* Use AddMonsterMoveFlag instead SetMonsterMoveFlags for set walk-mode * Apply walk/run mode to all copntrolled units (except totems). * Synchronize walk/run mode at pet creating/loading.
This commit is contained in:
parent
b0809f63b2
commit
2e9bf5ad6a
6 changed files with 43 additions and 25 deletions
|
|
@ -300,27 +300,7 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
|
||||||
plMover->HandleFall(movementInfo);
|
plMover->HandleFall(movementInfo);
|
||||||
|
|
||||||
if ((opcode == MSG_MOVE_SET_WALK_MODE || opcode == MSG_MOVE_SET_RUN_MODE) && plMover)
|
if ((opcode == MSG_MOVE_SET_WALK_MODE || opcode == MSG_MOVE_SET_RUN_MODE) && plMover)
|
||||||
{
|
plMover->UpdateWalkModeForPets(movementInfo.HasMovementFlag(MOVEMENTFLAG_WALK_MODE));
|
||||||
Pet* pPet = plMover->GetPet();
|
|
||||||
Pet* pMiniPet = plMover->GetMiniPet();
|
|
||||||
|
|
||||||
if (movementInfo.HasMovementFlag(MOVEMENTFLAG_WALK_MODE))
|
|
||||||
{
|
|
||||||
if (pPet && !pPet->isInCombat())
|
|
||||||
pPet->SetMonsterMoveFlags(MONSTER_MOVE_WALK);
|
|
||||||
|
|
||||||
if (pMiniPet)
|
|
||||||
pMiniPet->SetMonsterMoveFlags(MONSTER_MOVE_WALK);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (pPet)
|
|
||||||
pPet->RemoveMonsterMoveFlag(MONSTER_MOVE_WALK);
|
|
||||||
|
|
||||||
if (pMiniPet)
|
|
||||||
pMiniPet->RemoveMonsterMoveFlag(MONSTER_MOVE_WALK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (plMover && (movementInfo.HasMovementFlag(MOVEMENTFLAG_SWIMMING) != plMover->IsInWater()))
|
if (plMover && (movementInfo.HasMovementFlag(MOVEMENTFLAG_SWIMMING) != plMover->IsInWater()))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -293,6 +293,8 @@ 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));
|
||||||
|
|
||||||
AIM_Initialize();
|
AIM_Initialize();
|
||||||
map->Add((Creature*)this);
|
map->Add((Creature*)this);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3549,6 +3549,9 @@ void Spell::EffectSummon(uint32 i)
|
||||||
|
|
||||||
spawnCreature->GetCharmInfo()->SetPetNumber(pet_number, false);
|
spawnCreature->GetCharmInfo()->SetPetNumber(pet_number, false);
|
||||||
|
|
||||||
|
if (m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||||
|
spawnCreature->UpdateWalkModeForPets(((Player*)m_caster)->HasMovementFlag(MOVEMENTFLAG_WALK_MODE));
|
||||||
|
|
||||||
spawnCreature->AIM_Initialize();
|
spawnCreature->AIM_Initialize();
|
||||||
spawnCreature->InitPetCreateSpells();
|
spawnCreature->InitPetCreateSpells();
|
||||||
spawnCreature->InitLevelupSpellsForLevel();
|
spawnCreature->InitLevelupSpellsForLevel();
|
||||||
|
|
@ -4415,6 +4418,9 @@ 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->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)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3347,10 +3347,10 @@ void Unit::SetInFront(Unit const* target)
|
||||||
SetOrientation(GetAngle(target));
|
SetOrientation(GetAngle(target));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unit::SetFacingToObject(WorldObject* pObject)
|
void Unit::SetFacingTo(float ori)
|
||||||
{
|
{
|
||||||
// update orientation at server
|
// update orientation at server
|
||||||
SetOrientation(GetAngle(pObject));
|
SetOrientation(ori);
|
||||||
|
|
||||||
// and client
|
// and client
|
||||||
WorldPacket data;
|
WorldPacket data;
|
||||||
|
|
@ -10394,6 +10394,34 @@ bool Unit::canDetectInvisibilityOf(Unit const* u) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct UpdateWalkModeForPetsHelper
|
||||||
|
{
|
||||||
|
explicit UpdateWalkModeForPetsHelper(bool _on) : on(_on) {}
|
||||||
|
void operator()(Unit* unit) const { unit->UpdateWalkModeForPets(on); }
|
||||||
|
bool on;
|
||||||
|
};
|
||||||
|
|
||||||
|
void Unit::UpdateWalkModeForPets(bool on)
|
||||||
|
{
|
||||||
|
if (GetTypeId() == TYPEID_PLAYER)
|
||||||
|
((Player*)this)->CallForAllControlledUnits(UpdateWalkModeForPetsHelper(on),false,true,true,true);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (on)
|
||||||
|
{
|
||||||
|
if (((Creature*)this)->isPet() && hasUnitState(UNIT_STAT_FOLLOW))
|
||||||
|
((Creature*)this)->AddMonsterMoveFlag(MONSTER_MOVE_WALK);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (((Creature*)this)->isPet())
|
||||||
|
((Creature*)this)->RemoveMonsterMoveFlag(MONSTER_MOVE_WALK);
|
||||||
|
}
|
||||||
|
|
||||||
|
CallForAllControlledUnits(UpdateWalkModeForPetsHelper(on),false,true,true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Unit::UpdateSpeed(UnitMoveType mtype, bool forced)
|
void Unit::UpdateSpeed(UnitMoveType mtype, bool forced)
|
||||||
{
|
{
|
||||||
int32 main_speed_mod = 0;
|
int32 main_speed_mod = 0;
|
||||||
|
|
|
||||||
|
|
@ -1376,7 +1376,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
|
||||||
void SetBaseWeaponDamage(WeaponAttackType attType ,WeaponDamageRange damageRange, float value) { m_weaponDamage[attType][damageRange] = value; }
|
void SetBaseWeaponDamage(WeaponAttackType attType ,WeaponDamageRange damageRange, float value) { m_weaponDamage[attType][damageRange] = value; }
|
||||||
|
|
||||||
void SetInFront(Unit const* target);
|
void SetInFront(Unit const* target);
|
||||||
void SetFacingToObject(WorldObject* pObject);
|
void SetFacingTo(float ori);
|
||||||
|
void SetFacingToObject(WorldObject* pObject) { SetFacingTo(GetAngle(pObject)); }
|
||||||
|
|
||||||
// Visibility system
|
// Visibility system
|
||||||
UnitVisibility GetVisibility() const { return m_Visibility; }
|
UnitVisibility GetVisibility() const { return m_Visibility; }
|
||||||
|
|
@ -1523,6 +1524,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 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 "9196"
|
#define REVISION_NR "9197"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue