mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2025-11-29 17:38:24 +08:00
Fix for DK pet , Thanks to Mik & Harlock
This commit is contained in:
@@ -50,11 +50,7 @@ class npc_pet_dk_ebon_gargoyle : public CreatureScript
|
|||||||
_despawnTimer = 36000; // 30 secs + 4 fly out + 2 initial attack timer
|
_despawnTimer = 36000; // 30 secs + 4 fly out + 2 initial attack timer
|
||||||
_despawning = false;
|
_despawning = false;
|
||||||
_initialSelection = true;
|
_initialSelection = true;
|
||||||
_ghoulSelection = true;
|
|
||||||
|
|
||||||
_targetGUID = 0;
|
_targetGUID = 0;
|
||||||
_markedTargetGUID = 0;
|
|
||||||
_ghoulTargetGUID = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MovementInform(uint32 type, uint32 point)
|
void MovementInform(uint32 type, uint32 point)
|
||||||
@@ -89,10 +85,31 @@ class npc_pet_dk_ebon_gargoyle : public CreatureScript
|
|||||||
_initialCastTimer = 0;
|
_initialCastTimer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64 GetGhoulTargetGUID()
|
||||||
|
{
|
||||||
|
uint64 ghoulTargetGUID = 0;
|
||||||
|
|
||||||
|
std::list<Unit*> targets;
|
||||||
|
Trinity::AnyFriendlyUnitInObjectRangeCheck ghoul_check(me, me, 50);
|
||||||
|
Trinity::UnitListSearcher<Trinity::AnyFriendlyUnitInObjectRangeCheck> searcher(me, targets, ghoul_check);
|
||||||
|
me->VisitNearbyObject(50, searcher);
|
||||||
|
for (std::list<Unit*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
|
||||||
|
{
|
||||||
|
if ((*iter)->GetEntry() == 26125) // ghoul entry
|
||||||
|
if ((*iter)->GetOwnerGUID() == me->GetOwnerGUID()) // same owner
|
||||||
|
{
|
||||||
|
ghoulTargetGUID = (*iter)->GetTarget();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ghoulTargetGUID;
|
||||||
|
}
|
||||||
|
|
||||||
void MySelectNextTarget()
|
void MySelectNextTarget()
|
||||||
{
|
{
|
||||||
Unit* owner = me->GetOwner();
|
Unit* owner = me->GetOwner();
|
||||||
if (owner && owner->GetTypeId() == TYPEID_PLAYER && (!me->GetVictim() || me->GetVictim()->IsImmunedToSpell(sSpellMgr->GetSpellInfo(51963)) || !me->IsValidAttackTarget(me->GetVictim()) || !owner->CanSeeOrDetect(me->GetVictim())))
|
if (owner && owner->GetTypeId() == TYPEID_PLAYER)
|
||||||
{
|
{
|
||||||
Unit* ghoulTarget = ObjectAccessor::GetUnit(*me, GetGhoulTargetGUID());
|
Unit* ghoulTarget = ObjectAccessor::GetUnit(*me, GetGhoulTargetGUID());
|
||||||
Unit* dkTarget = owner->ToPlayer()->GetSelectedUnit();
|
Unit* dkTarget = owner->ToPlayer()->GetSelectedUnit();
|
||||||
@@ -107,24 +124,29 @@ class npc_pet_dk_ebon_gargoyle : public CreatureScript
|
|||||||
if (dkTarget && dkTarget != me->GetVictim() && me->IsValidAttackTarget(dkTarget))
|
if (dkTarget && dkTarget != me->GetVictim() && me->IsValidAttackTarget(dkTarget))
|
||||||
{
|
{
|
||||||
me->GetMotionMaster()->Clear(false);
|
me->GetMotionMaster()->Clear(false);
|
||||||
SetGazeOn(selection);
|
SwitchTargetAndAttack(dkTarget);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if (!me->GetVictim() || !owner->CanSeeOrDetect(me->GetVictim()))
|
|
||||||
|
if (!me->GetVictim() || !owner->CanSeeOrDetect(me->GetVictim()))
|
||||||
{
|
{
|
||||||
me->CombatStop(true);
|
me->CombatStop(true);
|
||||||
me->GetMotionMaster()->Clear(false);
|
me->GetMotionMaster()->Clear(false);
|
||||||
me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, 0.0f);
|
me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, 0.0f);
|
||||||
RemoveTargetAura();
|
RemoveTargetAura();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttackStart(Unit* who)
|
void SwitchTargetAndAttack(Unit* who)
|
||||||
{
|
{
|
||||||
RemoveTargetAura();
|
RemoveTargetAura();
|
||||||
_targetGUID = who->GetGUID();
|
_targetGUID = who->GetGUID();
|
||||||
|
|
||||||
me->AddAura(SPELL_DK_SUMMON_GARGOYLE_1, who);
|
me->AddAura(SPELL_DK_SUMMON_GARGOYLE_1, who);
|
||||||
ScriptedAI::AttackStart(who);
|
ScriptedAI::AttackStart(who);
|
||||||
|
me->SetReactState(REACT_PASSIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveTargetAura()
|
void RemoveTargetAura()
|
||||||
@@ -181,66 +203,18 @@ class npc_pet_dk_ebon_gargoyle : public CreatureScript
|
|||||||
for (std::list<Unit*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
|
for (std::list<Unit*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
|
||||||
if ((*iter)->GetAura(SPELL_DK_SUMMON_GARGOYLE_1, me->GetOwnerGUID()))
|
if ((*iter)->GetAura(SPELL_DK_SUMMON_GARGOYLE_1, me->GetOwnerGUID()))
|
||||||
{
|
{
|
||||||
(*iter)->RemoveAura(SPELL_DK_SUMMON_GARGOYLE_1, me->GetOwnerGUID());
|
SwitchTargetAndAttack((*iter));
|
||||||
SetGazeOn(*iter);
|
|
||||||
_targetGUID = (*iter)->GetGUID();
|
|
||||||
_markedTargetGUID = _targetGUID;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_ghoulSelection) //find pet ghoul target
|
|
||||||
{
|
|
||||||
std::list<Unit*> targets;
|
|
||||||
Trinity::AnyFriendlyUnitInObjectRangeCheck ghoul_check(me, me, 50);
|
|
||||||
Trinity::UnitListSearcher<Trinity::AnyFriendlyUnitInObjectRangeCheck> searcher(me, targets, ghoul_check);
|
|
||||||
me->VisitNearbyObject(50, searcher);
|
|
||||||
for (std::list<Unit*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
|
|
||||||
{
|
|
||||||
if ((*iter)->GetEntry() == 26125) // ghoul entry
|
|
||||||
{
|
|
||||||
if ((*iter)->GetOwnerGUID() == me->GetOwnerGUID()) // same owner
|
|
||||||
{
|
|
||||||
_ghoulTargetGUID = (*iter)->GetTarget();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (Unit* ghoulTarget = ObjectAccessor::GetUnit(*me, _ghoulTargetGUID))
|
|
||||||
{
|
|
||||||
if(ghoulTarget->IsAlive())
|
|
||||||
{
|
|
||||||
AttackStart(ghoulTarget);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_ghoulSelection = false; // check for ghoul at next update.
|
|
||||||
|
|
||||||
if (Unit* markedTarget = ObjectAccessor::GetUnit(*me, _markedTargetGUID))
|
|
||||||
{
|
|
||||||
if (markedTarget->IsAlive())
|
|
||||||
{
|
|
||||||
AttackStart(markedTarget);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_despawnTimer > 4000)
|
if (_despawnTimer > 4000)
|
||||||
{
|
{
|
||||||
_despawnTimer -= diff;
|
_despawnTimer -= diff;
|
||||||
if (!UpdateVictimWithGaze())
|
|
||||||
{
|
|
||||||
MySelectNextTarget();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_initialCastTimer += diff;
|
_initialCastTimer += diff;
|
||||||
_selectionTimer += diff;
|
_selectionTimer += diff;
|
||||||
|
|
||||||
if (_selectionTimer >= 1000)
|
if (_selectionTimer >= 1000)
|
||||||
{
|
{
|
||||||
MySelectNextTarget();
|
MySelectNextTarget();
|
||||||
@@ -266,14 +240,11 @@ class npc_pet_dk_ebon_gargoyle : public CreatureScript
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
uint64 _targetGUID;
|
uint64 _targetGUID;
|
||||||
uint64 _ghoulTargetGUID;
|
|
||||||
uint64 _markedTargetGUID;
|
|
||||||
uint32 _despawnTimer;
|
uint32 _despawnTimer;
|
||||||
uint32 _selectionTimer;
|
uint32 _selectionTimer;
|
||||||
uint32 _initialCastTimer;
|
uint32 _initialCastTimer;
|
||||||
bool _despawning;
|
bool _despawning;
|
||||||
bool _initialSelection;
|
bool _initialSelection;
|
||||||
bool _ghoulSelection;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
CreatureAI* GetAI(Creature* creature) const
|
CreatureAI* GetAI(Creature* creature) const
|
||||||
|
|||||||
Reference in New Issue
Block a user