From 7312c5034e9e98dcf935c21ced806278514fe862 Mon Sep 17 00:00:00 2001 From: megamage Date: Mon, 24 Nov 2008 15:59:02 -0600 Subject: [PATCH] *Seperate owner speed and pet speed. --HG-- branch : trunk --- src/game/Unit.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 642b49ee99..38853c6763 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -8512,10 +8512,21 @@ void Unit::SetInCombatState(bool PvP) if(PvP) m_CombatTimer = 5000; + + if(isInCombat()) + return; + SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); - if(isCharmed() || (GetTypeId()!=TYPEID_PLAYER && ((Creature*)this)->isPet())) + if(isCharmed() || GetTypeId()!=TYPEID_PLAYER && ((Creature*)this)->isPet()) SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT); + + if(GetTypeId() == TYPEID_PLAYER && GetPetGUID()) + { + if(Pet *pet = GetPet()) + for(int i = 0; i < MAX_MOVE_TYPE; ++i) + pet->UpdateSpeed(UnitMoveType(i), true); + } } void Unit::ClearInCombat() @@ -8523,12 +8534,19 @@ void Unit::ClearInCombat() m_CombatTimer = 0; RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); - if(isCharmed() || (GetTypeId()!=TYPEID_PLAYER && ((Creature*)this)->isPet())) + 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(Pet *pet = GetPet()) + for(int i = 0; i < MAX_MOVE_TYPE; ++i) + pet->SetSpeed(UnitMoveType(i), m_speed_rate[i], true); + } } //TODO: remove this function @@ -8923,8 +8941,9 @@ void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced) data << float(GetSpeed(mtype)); SendMessageToSet( &data, true ); } - if(Pet* pet = GetPet()) - pet->SetSpeed(MOVE_RUN, m_speed_rate[mtype],forced); + if(GetPetGUID() && !isInCombat()) + if(Pet* pet = GetPet()) + pet->SetSpeed(mtype, m_speed_rate[mtype], forced); } void Unit::SetHover(bool on)