mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-08 07:48:02 +00:00
Scripts/Pet: Gargoyle shouldn't attack ghoul target. (#229)
This commit is contained in:
@@ -75,68 +75,34 @@ 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)
|
if (owner && owner->GetTypeId() == TYPEID_PLAYER && (!me->GetVictim() || me->GetVictim()->IsImmunedToSpell(sSpellMgr->GetSpellInfo(51963)) || !me->IsValidAttackTarget(me->GetVictim()) || !owner->CanSeeOrDetect(me->GetVictim())))
|
||||||
{
|
{
|
||||||
Unit* ghoulTarget = ObjectAccessor::GetUnit(*me, GetGhoulTargetGUID());
|
Unit* selection = owner->ToPlayer()->GetSelectedUnit();
|
||||||
Unit* dkTarget = owner->ToPlayer()->GetSelectedUnit();
|
if (selection && selection != me->GetVictim() && me->IsValidAttackTarget(selection))
|
||||||
|
|
||||||
if (ghoulTarget && ghoulTarget != me->GetVictim() && me->IsValidAttackTarget(ghoulTarget))
|
|
||||||
{
|
{
|
||||||
me->GetMotionMaster()->Clear(false);
|
me->GetMotionMaster()->Clear(false);
|
||||||
SwitchTargetAndAttack(ghoulTarget);
|
SetGazeOn(selection);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dkTarget && dkTarget != me->GetVictim() && me->IsValidAttackTarget(dkTarget))
|
else if (!me->GetVictim() || !owner->CanSeeOrDetect(me->GetVictim()))
|
||||||
{
|
|
||||||
me->GetMotionMaster()->Clear(false);
|
|
||||||
SwitchTargetAndAttack(dkTarget);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 SwitchTargetAndAttack(Unit* who)
|
void AttackStart(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()
|
||||||
@@ -193,28 +159,30 @@ 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()))
|
||||||
{
|
{
|
||||||
SwitchTargetAndAttack((*iter));
|
(*iter)->RemoveAura(SPELL_DK_SUMMON_GARGOYLE_1, me->GetOwnerGUID());
|
||||||
|
SetGazeOn(*iter);
|
||||||
|
_targetGUID = (*iter)->GetGUID();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
||||||
_selectionTimer = 0;
|
_selectionTimer = 0;
|
||||||
}
|
}
|
||||||
// check start timer and if not casting
|
if (_initialCastTimer >= 2000 && !me->HasUnitState(UNIT_STATE_CASTING | UNIT_STATE_LOST_CONTROL) && me->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_CONTROLLED) == NULL_MOTION_TYPE)
|
||||||
if(_initialCastTimer >= 2000 && !me->HasUnitState(UNIT_STATE_CASTING))
|
me->CastSpell(me->GetVictim(), 51963, false);
|
||||||
if (!(me->HasAuraType(SPELL_AURA_MOD_FEAR) || me->HasAuraType(SPELL_AURA_MOD_ROOT) || me->HasAuraType(SPELL_AURA_MOD_CONFUSE) || me->HasAuraType(SPELL_AURA_MOD_STUN)))
|
|
||||||
if (_initialCastTimer >= 2000 && !me->HasUnitState(UNIT_STATE_LOST_CONTROL) && me->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_CONTROLLED) == NULL_MOTION_TYPE)
|
|
||||||
me->CastSpell(me->GetVictim(), 51963, false);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -305,11 +273,7 @@ class npc_pet_dk_dancing_rune_weapon : public CreatureScript
|
|||||||
// Xinef: Hit / Expertise scaling
|
// Xinef: Hit / Expertise scaling
|
||||||
me->AddAura(61017, me);
|
me->AddAura(61017, me);
|
||||||
if (Unit* owner = me->GetOwner())
|
if (Unit* owner = me->GetOwner())
|
||||||
{
|
|
||||||
me->GetMotionMaster()->MoveFollow(owner, 0.01f, me->GetFollowAngle(), MOTION_SLOT_CONTROLLED);
|
me->GetMotionMaster()->MoveFollow(owner, 0.01f, me->GetFollowAngle(), MOTION_SLOT_CONTROLLED);
|
||||||
if (Player* player = owner->ToPlayer())
|
|
||||||
player->setRuneWeaponGUID(me->GetGUID());
|
|
||||||
}
|
|
||||||
|
|
||||||
NullCreatureAI::InitializeAI();
|
NullCreatureAI::InitializeAI();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user