mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 09:17:18 +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;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
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* dkTarget = owner->ToPlayer()->GetSelectedUnit();
|
||||
|
||||
if (ghoulTarget && ghoulTarget != me->GetVictim() && me->IsValidAttackTarget(ghoulTarget))
|
||||
Unit* selection = owner->ToPlayer()->GetSelectedUnit();
|
||||
if (selection && selection != me->GetVictim() && me->IsValidAttackTarget(selection))
|
||||
{
|
||||
me->GetMotionMaster()->Clear(false);
|
||||
SwitchTargetAndAttack(ghoulTarget);
|
||||
return;
|
||||
SetGazeOn(selection);
|
||||
}
|
||||
|
||||
if (dkTarget && dkTarget != me->GetVictim() && me->IsValidAttackTarget(dkTarget))
|
||||
{
|
||||
me->GetMotionMaster()->Clear(false);
|
||||
SwitchTargetAndAttack(dkTarget);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!me->GetVictim() || !owner->CanSeeOrDetect(me->GetVictim()))
|
||||
else if (!me->GetVictim() || !owner->CanSeeOrDetect(me->GetVictim()))
|
||||
{
|
||||
me->CombatStop(true);
|
||||
me->GetMotionMaster()->Clear(false);
|
||||
me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, 0.0f);
|
||||
RemoveTargetAura();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SwitchTargetAndAttack(Unit* who)
|
||||
void AttackStart(Unit* who)
|
||||
{
|
||||
RemoveTargetAura();
|
||||
_targetGUID = who->GetGUID();
|
||||
|
||||
me->AddAura(SPELL_DK_SUMMON_GARGOYLE_1, who);
|
||||
ScriptedAI::AttackStart(who);
|
||||
me->SetReactState(REACT_PASSIVE);
|
||||
}
|
||||
|
||||
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)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if (_despawnTimer > 4000)
|
||||
{
|
||||
_despawnTimer -= diff;
|
||||
if (!UpdateVictimWithGaze())
|
||||
{
|
||||
MySelectNextTarget();
|
||||
return;
|
||||
}
|
||||
|
||||
_initialCastTimer += diff;
|
||||
_selectionTimer += diff;
|
||||
|
||||
if (_selectionTimer >= 1000)
|
||||
{
|
||||
MySelectNextTarget();
|
||||
_selectionTimer = 0;
|
||||
}
|
||||
// check start timer and if not casting
|
||||
if(_initialCastTimer >= 2000 && !me->HasUnitState(UNIT_STATE_CASTING))
|
||||
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);
|
||||
if (_initialCastTimer >= 2000 && !me->HasUnitState(UNIT_STATE_CASTING | UNIT_STATE_LOST_CONTROL) && me->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_CONTROLLED) == NULL_MOTION_TYPE)
|
||||
me->CastSpell(me->GetVictim(), 51963, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -305,11 +273,7 @@ class npc_pet_dk_dancing_rune_weapon : public CreatureScript
|
||||
// Xinef: Hit / Expertise scaling
|
||||
me->AddAura(61017, me);
|
||||
if (Unit* owner = me->GetOwner())
|
||||
{
|
||||
me->GetMotionMaster()->MoveFollow(owner, 0.01f, me->GetFollowAngle(), MOTION_SLOT_CONTROLLED);
|
||||
if (Player* player = owner->ToPlayer())
|
||||
player->setRuneWeaponGUID(me->GetGUID());
|
||||
}
|
||||
|
||||
NullCreatureAI::InitializeAI();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user