fix(Script/Creature): Add random delay to Gargoyle casts (#22512)
This commit is contained in:
@@ -47,6 +47,8 @@ enum DeathKnightSpells
|
|||||||
// Risen Ally
|
// Risen Ally
|
||||||
SPELL_DK_RAISE_ALLY = 46619,
|
SPELL_DK_RAISE_ALLY = 46619,
|
||||||
SPELL_GHOUL_FRENZY = 62218,
|
SPELL_GHOUL_FRENZY = 62218,
|
||||||
|
// Gargoyle
|
||||||
|
SPELL_GARGOYLE_STRIKE = 51963,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct npc_pet_dk_ebon_gargoyle : ScriptedAI
|
struct npc_pet_dk_ebon_gargoyle : ScriptedAI
|
||||||
@@ -89,12 +91,13 @@ struct npc_pet_dk_ebon_gargoyle : ScriptedAI
|
|||||||
me->AddUnitState(UNIT_STATE_NO_ENVIRONMENT_UPD);
|
me->AddUnitState(UNIT_STATE_NO_ENVIRONMENT_UPD);
|
||||||
_selectionTimer = 2000;
|
_selectionTimer = 2000;
|
||||||
_initialCastTimer = 0;
|
_initialCastTimer = 0;
|
||||||
|
_decisionTimer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MySelectNextTarget()
|
void MySelectNextTarget()
|
||||||
{
|
{
|
||||||
Unit* owner = me->GetOwner();
|
Unit* owner = me->GetOwner();
|
||||||
if (owner && owner->IsPlayer() && (!me->GetVictim() || me->GetVictim()->IsImmunedToSpell(sSpellMgr->GetSpellInfo(51963)) || !me->IsValidAttackTarget(me->GetVictim()) || !owner->CanSeeOrDetect(me->GetVictim())))
|
if (owner && owner->IsPlayer() && (!me->GetVictim() || me->GetVictim()->IsImmunedToSpell(sSpellMgr->GetSpellInfo(SPELL_GARGOYLE_STRIKE)) || !me->IsValidAttackTarget(me->GetVictim()) || !owner->CanSeeOrDetect(me->GetVictim())))
|
||||||
{
|
{
|
||||||
Unit* selection = owner->ToPlayer()->GetSelectedUnit();
|
Unit* selection = owner->ToPlayer()->GetSelectedUnit();
|
||||||
if (selection && selection != me->GetVictim() && me->IsValidAttackTarget(selection))
|
if (selection && selection != me->GetVictim() && me->IsValidAttackTarget(selection))
|
||||||
@@ -118,7 +121,7 @@ struct npc_pet_dk_ebon_gargoyle : ScriptedAI
|
|||||||
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::AttackStartCaster(who, 40);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveTargetAura()
|
void RemoveTargetAura()
|
||||||
@@ -184,6 +187,7 @@ struct npc_pet_dk_ebon_gargoyle : ScriptedAI
|
|||||||
if (_despawnTimer > 4000)
|
if (_despawnTimer > 4000)
|
||||||
{
|
{
|
||||||
_despawnTimer -= diff;
|
_despawnTimer -= diff;
|
||||||
|
_decisionTimer -= diff;
|
||||||
if (!UpdateVictimWithGaze())
|
if (!UpdateVictimWithGaze())
|
||||||
{
|
{
|
||||||
MySelectNextTarget();
|
MySelectNextTarget();
|
||||||
@@ -197,8 +201,23 @@ struct npc_pet_dk_ebon_gargoyle : ScriptedAI
|
|||||||
MySelectNextTarget();
|
MySelectNextTarget();
|
||||||
_selectionTimer = 0;
|
_selectionTimer = 0;
|
||||||
}
|
}
|
||||||
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);
|
if (_decisionTimer <= 0)
|
||||||
|
{
|
||||||
|
_decisionTimer += 400;
|
||||||
|
if (_initialCastTimer >= 2000 && !me->HasUnitState(UNIT_STATE_CASTING | UNIT_STATE_LOST_CONTROL) && me->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_CONTROLLED) == NULL_MOTION_TYPE && rand_chance() > 20.0f)
|
||||||
|
{
|
||||||
|
if (me->HasSilenceAura() || me->IsSpellProhibited(SPELL_SCHOOL_MASK_NATURE))
|
||||||
|
{
|
||||||
|
me->GetMotionMaster()->MoveChase(me->GetVictim());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
me->GetMotionMaster()->MoveChase(me->GetVictim(), 40);
|
||||||
|
DoCastVictim(SPELL_GARGOYLE_STRIKE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -217,6 +236,7 @@ private:
|
|||||||
uint32 _despawnTimer;
|
uint32 _despawnTimer;
|
||||||
uint32 _selectionTimer;
|
uint32 _selectionTimer;
|
||||||
uint32 _initialCastTimer;
|
uint32 _initialCastTimer;
|
||||||
|
int32 _decisionTimer;
|
||||||
bool _despawning;
|
bool _despawning;
|
||||||
bool _initialSelection;
|
bool _initialSelection;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user