diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 78223db9b..e85cc2d59 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -3435,20 +3435,21 @@ void Aura::HandleModPossessPet(bool apply, bool Real) return; Unit* caster = GetCaster(); - if(!caster || caster->GetTypeId() != TYPEID_PLAYER) + if (!caster || caster->GetTypeId() != TYPEID_PLAYER) return; Unit* target = GetTarget(); - if (target->GetTypeId() != TYPEID_UNIT) + if (target->GetTypeId() != TYPEID_UNIT || !((Creature*)target)->isPet()) return; - Creature* pet = (Creature*)target; // not need more stricted type check + + Pet* pet = (Pet*)target; Player* p_caster = (Player*)caster; Camera& camera = p_caster->GetCamera(); if (apply) { - target->addUnitState(UNIT_STAT_CONTROLLED); + pet->addUnitState(UNIT_STAT_CONTROLLED); // target should became visible at SetView call(if not visible before): // otherwise client\p_caster will ignore packets from the target(SetClientControl for example) @@ -3483,8 +3484,17 @@ void Aura::HandleModPossessPet(bool apply, bool Real) pet->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); pet->AttackStop(); - pet->GetMotionMaster()->MoveFollow(caster, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); - pet->AddSplineFlag(SPLINEFLAG_WALKMODE); + + // out of range pet dismissed + if (!pet->IsWithinDistInMap(p_caster, pet->GetMap()->GetVisibilityDistance())) + { + pet->Remove(PET_SAVE_NOT_IN_SLOT, true); + } + else + { + pet->GetMotionMaster()->MoveFollow(caster, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + pet->AddSplineFlag(SPLINEFLAG_WALKMODE); + } } } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 4f86007ff..94be460e3 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10287" + #define REVISION_NR "10288" #endif // __REVISION_NR_H__