*Update pet's speed when pet is incombat rather than when owner is in combat.
--HG-- branch : trunk
This commit is contained in:
@@ -73,6 +73,9 @@ void PetAI::AttackStart(Unit *u)
|
||||
|
||||
if(i_pet.Attack(u,true))
|
||||
{
|
||||
i_pet.SetInCombatWith(u);
|
||||
u->SetInCombatWith(&i_pet);
|
||||
|
||||
i_pet.clearUnitState(UNIT_STAT_FOLLOW);
|
||||
// TMGs call CreatureRelocation which via MoveInLineOfSight can call this function
|
||||
// thus with the following clear the original TMG gets invalidated and crash, doh
|
||||
|
||||
+18
-17
@@ -9757,18 +9757,16 @@ void Unit::SetInCombatState(bool PvP)
|
||||
|
||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
|
||||
|
||||
if(isCharmed() || GetTypeId()!=TYPEID_PLAYER && ((Creature*)this)->isPet())
|
||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT);
|
||||
if(GetTypeId() != TYPEID_PLAYER && ((Creature*)this)->isPet())
|
||||
{
|
||||
UpdateSpeed(MOVE_RUN, true);
|
||||
UpdateSpeed(MOVE_SWIM, true);
|
||||
UpdateSpeed(MOVE_FLIGHT, true);
|
||||
}
|
||||
else if(!isCharmed())
|
||||
return;
|
||||
|
||||
if(GetTypeId() == TYPEID_PLAYER && GetPetGUID())
|
||||
{
|
||||
if(Pet *pet = GetPet())
|
||||
{
|
||||
pet->UpdateSpeed(MOVE_RUN, true);
|
||||
pet->UpdateSpeed(MOVE_SWIM, true);
|
||||
pet->UpdateSpeed(MOVE_FLIGHT, true);
|
||||
}
|
||||
}
|
||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT);
|
||||
}
|
||||
|
||||
void Unit::ClearInCombat()
|
||||
@@ -9776,19 +9774,22 @@ void Unit::ClearInCombat()
|
||||
m_CombatTimer = 0;
|
||||
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
|
||||
|
||||
if(isCharmed() || GetTypeId()!=TYPEID_PLAYER && ((Creature*)this)->isPet())
|
||||
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT);
|
||||
|
||||
// Player's state will be cleared in Player::UpdateContestedPvP
|
||||
if(GetTypeId()!=TYPEID_PLAYER)
|
||||
clearUnitState(UNIT_STAT_ATTACK_PLAYER);
|
||||
|
||||
if(GetTypeId() == TYPEID_PLAYER && GetPetGUID())
|
||||
if(GetTypeId() != TYPEID_PLAYER && ((Creature*)this)->isPet())
|
||||
{
|
||||
if(Unit *owner = GetOwner())
|
||||
{
|
||||
if(Pet *pet = GetPet())
|
||||
for(int i = 0; i < MAX_MOVE_TYPE; ++i)
|
||||
pet->SetSpeed(UnitMoveType(i), m_speed_rate[i], true);
|
||||
SetSpeed(UnitMoveType(i), owner->GetSpeedRate(UnitMoveType(i)), true);
|
||||
}
|
||||
}
|
||||
else if(!isCharmed())
|
||||
return;
|
||||
|
||||
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT);
|
||||
}
|
||||
|
||||
//TODO: remove this function
|
||||
|
||||
Reference in New Issue
Block a user