[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:
VladimirMangos 2010-01-17 07:48:04 +03:00
parent b0809f63b2
commit 2e9bf5ad6a
6 changed files with 43 additions and 25 deletions

View file

@ -3347,10 +3347,10 @@ void Unit::SetInFront(Unit const* target)
SetOrientation(GetAngle(target));
}
void Unit::SetFacingToObject(WorldObject* pObject)
void Unit::SetFacingTo(float ori)
{
// update orientation at server
SetOrientation(GetAngle(pObject));
SetOrientation(ori);
// and client
WorldPacket data;
@ -10394,6 +10394,34 @@ bool Unit::canDetectInvisibilityOf(Unit const* u) const
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)
{
int32 main_speed_mod = 0;