[10288] Unsummon pet if pet direct control spell expire out of visibility range from owner.

This commit is contained in:
VladimirMangos 2010-07-30 05:01:13 +04:00
parent ed737c55cd
commit 3099a99f9a
2 changed files with 17 additions and 7 deletions

View file

@ -3439,16 +3439,17 @@ void Aura::HandleModPossessPet(bool apply, bool Real)
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,10 +3484,19 @@ void Aura::HandleModPossessPet(bool apply, bool Real)
pet->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
pet->AttackStop();
// 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);
}
}
}
void Aura::HandleAuraModPetTalentsPoints(bool /*Apply*/, bool Real)
{

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10287"
#define REVISION_NR "10288"
#endif // __REVISION_NR_H__