refactor(Scripts/ZulAman): Move Spirit of the Lynx to SAI (#20498)

This commit is contained in:
Andrew
2024-11-10 14:55:04 -03:00
committed by GitHub
parent 91b8cc29cf
commit 8e05cd7e80
2 changed files with 23 additions and 85 deletions
@@ -0,0 +1,9 @@
--
UPDATE `creature_template` SET `AIName` = 'SmartAI', `ScriptName` = '' WHERE `entry` = 24143;
DELETE FROM `smart_scripts` WHERE (`entryorguid` = 24143) AND (`source_type` = 0) AND (`id` IN (0, 1, 2, 3));
INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `event_param6`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES
(24143, 0, 0, 0, 0, 0, 100, 0, 30000, 50000, 30000, 50000, 0, 0, 11, 43290, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Spirit of the Lynx - In Combat - Cast \'Lynx Flurry\''),
(24143, 0, 1, 0, 0, 0, 100, 0, 4000, 4000, 4000, 4000, 0, 0, 11, 43243, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 'Spirit of the Lynx - In Combat - Cast \'Shred Armor\''),
(24143, 0, 2, 0, 25, 0, 100, 0, 0, 0, 0, 0, 0, 0, 42, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Spirit of the Lynx - On Reset - Set Invincibility Hp 1'),
(24143, 0, 3, 0, 2, 0, 100, 0, 20, 20, 0, 0, 0, 0, 223, 0, 0, 0, 0, 0, 0, 23, 0, 0, 0, 0, 0, 0, 0, 0, 'Spirit of the Lynx - Between 20-20% Health - Do Action ID 0');
@@ -74,6 +74,11 @@ enum Groups
GROUP_MERGE = 2 GROUP_MERGE = 2
}; };
enum Actions
{
ACTION_MERGE = 0
};
struct boss_halazzi : public BossAI struct boss_halazzi : public BossAI
{ {
boss_halazzi(Creature* creature) : BossAI(creature, DATA_HALAZZI) boss_halazzi(Creature* creature) : BossAI(creature, DATA_HALAZZI)
@@ -118,33 +123,19 @@ struct boss_halazzi : public BossAI
void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damagetype*/, SpellSchoolMask /*damageSchoolMask*/) override void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damagetype*/, SpellSchoolMask /*damageSchoolMask*/) override
{ {
if (damage >= me->GetHealth() && _phase != PHASE_ENRAGE) if (damage >= me->GetHealth() && _phase != PHASE_ENRAGE)
{
damage = 0; damage = 0;
}
else else
{ {
if (_phase == PHASE_LYNX || _phase == PHASE_ENRAGE) if (_phase == PHASE_LYNX || _phase == PHASE_ENRAGE)
{ {
_healthCheckPercentage = 25 * (3 - _transformCount); _healthCheckPercentage = 25 * (3 - _transformCount);
if (!HealthAbovePct(_healthCheckPercentage)) if (!HealthAbovePct(_healthCheckPercentage))
{
EnterPhase(PHASE_SPLIT); EnterPhase(PHASE_SPLIT);
}
} }
else if (_phase == PHASE_HUMAN) else if (_phase == PHASE_HUMAN)
{ {
if (Creature* lynx = instance->GetCreature(DATA_SPIRIT_LYNX)) if (!HealthAbovePct(20))
{ EnterPhase(PHASE_MERGE);
if (!HealthAbovePct(20) || !lynx->HealthAbovePct(20))
{
EnterPhase(PHASE_MERGE);
}
}
else
{
//should not really happen
EnterEvadeMode();
}
} }
} }
} }
@@ -152,17 +143,13 @@ struct boss_halazzi : public BossAI
void SpellHit(Unit*, SpellInfo const* spell) override void SpellHit(Unit*, SpellInfo const* spell) override
{ {
if (spell->Id == SPELL_TRANSFORM_SPLIT2) if (spell->Id == SPELL_TRANSFORM_SPLIT2)
{
EnterPhase(PHASE_HUMAN); EnterPhase(PHASE_HUMAN);
}
} }
void AttackStart(Unit* who) override void AttackStart(Unit* who) override
{ {
if (_phase != PHASE_MERGE) if (_phase != PHASE_MERGE)
{
BossAI::AttackStart(who); BossAI::AttackStart(who);
}
} }
void EnterPhase(PhaseHalazzi nextPhase) void EnterPhase(PhaseHalazzi nextPhase)
@@ -175,7 +162,7 @@ struct boss_halazzi : public BossAI
{ {
DoCastSelf(SPELL_TRANSFORM_MERGE, true); DoCastSelf(SPELL_TRANSFORM_MERGE, true);
me->RemoveAurasDueToSpell(SPELL_TRANSFORM_SPLIT2); me->RemoveAurasDueToSpell(SPELL_TRANSFORM_SPLIT2);
me->GetMotionMaster()->MoveChase(me->GetVictim()); me->ResumeChasingVictim();
} }
summons.DespawnAll(); summons.DespawnAll();
me->SetMaxHealth(_lynxFormHealth); me->SetMaxHealth(_lynxFormHealth);
@@ -207,13 +194,9 @@ struct boss_halazzi : public BossAI
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0)) if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0))
{ {
if (target->IsNonMeleeSpellCast(false)) if (target->IsNonMeleeSpellCast(false))
{
DoCast(target, SPELL_EARTHSHOCK); DoCast(target, SPELL_EARTHSHOCK);
}
else else
{
DoCast(target, SPELL_FLAMESHOCK); DoCast(target, SPELL_FLAMESHOCK);
}
} }
context.Repeat(10s, 15s); context.Repeat(10s, 15s);
}).Schedule(12s, GROUP_HUMAN, [this](TaskContext context) }).Schedule(12s, GROUP_HUMAN, [this](TaskContext context)
@@ -236,19 +219,13 @@ struct boss_halazzi : public BossAI
scheduler.Schedule(2s, GROUP_MERGE, [this](TaskContext context) scheduler.Schedule(2s, GROUP_MERGE, [this](TaskContext context)
{ {
if (Creature* lynx = instance->GetCreature(DATA_SPIRIT_LYNX)) if (Creature* lynx = instance->GetCreature(DATA_SPIRIT_LYNX))
{
if (me->IsWithinDistInMap(lynx, 6.0f)) if (me->IsWithinDistInMap(lynx, 6.0f))
{ {
if (_transformCount < 3) if (_transformCount < 3)
{
EnterPhase(PHASE_LYNX); EnterPhase(PHASE_LYNX);
}
else else
{
EnterPhase(PHASE_ENRAGE); EnterPhase(PHASE_ENRAGE);
}
} }
}
context.Repeat(2s); context.Repeat(2s);
}); });
} }
@@ -263,9 +240,13 @@ struct boss_halazzi : public BossAI
{ {
BossAI::KilledUnit(victim); BossAI::KilledUnit(victim);
if (victim->IsPlayer()) if (victim->IsPlayer())
{
Talk(SAY_KILL); Talk(SAY_KILL);
} }
void DoAction(int32 actionId) override
{
if (actionId == ACTION_MERGE)
EnterPhase(PHASE_MERGE);
} }
void JustDied(Unit* killer) override void JustDied(Unit* killer) override
@@ -281,60 +262,8 @@ private:
uint32 _healthCheckPercentage; uint32 _healthCheckPercentage;
PhaseHalazzi _phase; PhaseHalazzi _phase;
}; };
// Spirits Lynx AI
struct npc_halazzi_lynx : public ScriptedAI
{
npc_halazzi_lynx(Creature* creature) : ScriptedAI(creature) { }
void Reset() override
{
scheduler.CancelAll();
}
void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damagetype*/, SpellSchoolMask /*damageSchoolMask*/) override
{
if (damage >= me->GetHealth())
{
damage = 0;
}
}
void AttackStart(Unit* who) override
{
if (!me->HasUnitFlag(UNIT_FLAG_NON_ATTACKABLE))
{
ScriptedAI::AttackStart(who);
}
}
void JustEngagedWith(Unit* who) override
{
ScriptedAI::JustEngagedWith(who);
ScheduleTimedEvent(30s, 50s, [&]
{
DoCastSelf(SPELL_LYNX_FRENZY);
}, 30s, 50s);
ScheduleTimedEvent(4s, [&]{
DoCastVictim(SPELL_SHRED_ARMOR);
}, 4s);
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
{
return;
}
scheduler.Update(diff);
DoMeleeAttackIfReady();
}
};
void AddSC_boss_halazzi() void AddSC_boss_halazzi()
{ {
RegisterZulAmanCreatureAI(boss_halazzi); RegisterZulAmanCreatureAI(boss_halazzi);
RegisterZulAmanCreatureAI(npc_halazzi_lynx);
} }