diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game/PetAI.cpp | 3 | ||||
-rw-r--r-- | src/game/Unit.cpp | 33 |
2 files changed, 20 insertions, 16 deletions
diff --git a/src/game/PetAI.cpp b/src/game/PetAI.cpp index 6a87d52cfca..82259cbba4d 100644 --- a/src/game/PetAI.cpp +++ b/src/game/PetAI.cpp @@ -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 diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index ee4ca89eaa5..8582d262e3a 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -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 && GetPetGUID()) + if(GetTypeId() != TYPEID_PLAYER && ((Creature*)this)->isPet()) { - if(Pet *pet = GetPet()) - { - pet->UpdateSpeed(MOVE_RUN, true); - pet->UpdateSpeed(MOVE_SWIM, true); - pet->UpdateSpeed(MOVE_FLIGHT, true); - } + UpdateSpeed(MOVE_RUN, true); + UpdateSpeed(MOVE_SWIM, true); + UpdateSpeed(MOVE_FLIGHT, true); } + else if(!isCharmed()) + return; + + 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(Pet *pet = GetPet()) + if(Unit *owner = GetOwner()) + { 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 |