*Update pet's speed when pet is incombat rather than when owner is in combat.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-01-03 21:24:19 -06:00
parent 3c1691497d
commit 5d4dcba0de
2 changed files with 20 additions and 16 deletions
+3
View File
@@ -73,6 +73,9 @@ void PetAI::AttackStart(Unit *u)
if(i_pet.Attack(u,true)) if(i_pet.Attack(u,true))
{ {
i_pet.SetInCombatWith(u);
u->SetInCombatWith(&i_pet);
i_pet.clearUnitState(UNIT_STAT_FOLLOW); i_pet.clearUnitState(UNIT_STAT_FOLLOW);
// TMGs call CreatureRelocation which via MoveInLineOfSight can call this function // TMGs call CreatureRelocation which via MoveInLineOfSight can call this function
// thus with the following clear the original TMG gets invalidated and crash, doh // thus with the following clear the original TMG gets invalidated and crash, doh
+18 -17
View File
@@ -9757,18 +9757,16 @@ void Unit::SetInCombatState(bool PvP)
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
if(isCharmed() || GetTypeId()!=TYPEID_PLAYER && ((Creature*)this)->isPet()) if(GetTypeId() != TYPEID_PLAYER && ((Creature*)this)->isPet())
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT); {
UpdateSpeed(MOVE_RUN, true);
UpdateSpeed(MOVE_SWIM, true);
UpdateSpeed(MOVE_FLIGHT, true);
}
else if(!isCharmed())
return;
if(GetTypeId() == TYPEID_PLAYER && GetPetGUID()) SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT);
{
if(Pet *pet = GetPet())
{
pet->UpdateSpeed(MOVE_RUN, true);
pet->UpdateSpeed(MOVE_SWIM, true);
pet->UpdateSpeed(MOVE_FLIGHT, true);
}
}
} }
void Unit::ClearInCombat() void Unit::ClearInCombat()
@@ -9776,19 +9774,22 @@ void Unit::ClearInCombat()
m_CombatTimer = 0; m_CombatTimer = 0;
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); 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 // Player's state will be cleared in Player::UpdateContestedPvP
if(GetTypeId()!=TYPEID_PLAYER) if(GetTypeId()!=TYPEID_PLAYER)
clearUnitState(UNIT_STAT_ATTACK_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) 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 //TODO: remove this function