[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

@ -3435,20 +3435,21 @@ void Aura::HandleModPossessPet(bool apply, bool Real)
return; return;
Unit* caster = GetCaster(); Unit* caster = GetCaster();
if(!caster || caster->GetTypeId() != TYPEID_PLAYER) if (!caster || caster->GetTypeId() != TYPEID_PLAYER)
return; return;
Unit* target = GetTarget(); Unit* target = GetTarget();
if (target->GetTypeId() != TYPEID_UNIT) if (target->GetTypeId() != TYPEID_UNIT || !((Creature*)target)->isPet())
return; return;
Creature* pet = (Creature*)target; // not need more stricted type check
Pet* pet = (Pet*)target;
Player* p_caster = (Player*)caster; Player* p_caster = (Player*)caster;
Camera& camera = p_caster->GetCamera(); Camera& camera = p_caster->GetCamera();
if (apply) if (apply)
{ {
target->addUnitState(UNIT_STAT_CONTROLLED); pet->addUnitState(UNIT_STAT_CONTROLLED);
// target should became visible at SetView call(if not visible before): // target should became visible at SetView call(if not visible before):
// otherwise client\p_caster will ignore packets from the target(SetClientControl for example) // 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->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
pet->AttackStop(); 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);
}
} }
} }

View file

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