Scripts/Gundrak: Update Slad'ran encounter to current coding standards (#25180)
* Scripts/Gundrak: Update Slad'Ran's script to use TaskScheduler * No functional changes * Scripts/Gundrak: Update Slad'Ran's adds to use TaskScheduler * No functional changes (cherry picked from commit 7abe9d66d049204240060f1976c51ff2297bf266)
This commit is contained in:
committed by
Shauren
parent
35a348dfdb
commit
5b1ba7b503
@@ -70,232 +70,215 @@ enum Misc
|
||||
DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES = 1
|
||||
};
|
||||
|
||||
class boss_slad_ran : public CreatureScript
|
||||
enum Phase
|
||||
{
|
||||
public:
|
||||
boss_slad_ran() : CreatureScript("boss_slad_ran") { }
|
||||
PHASE_NONE = 0,
|
||||
PHASE_SNAKES = 1,
|
||||
PHASE_CONSTRICTORS = 2
|
||||
};
|
||||
|
||||
struct boss_slad_ranAI : public BossAI
|
||||
enum TaskGroup
|
||||
{
|
||||
GROUP_SNAKES = 0
|
||||
};
|
||||
|
||||
struct boss_slad_ran : public BossAI
|
||||
{
|
||||
boss_slad_ran(Creature* creature) : BossAI(creature, DATA_SLAD_RAN)
|
||||
{
|
||||
boss_slad_ranAI(Creature* creature) : BossAI(creature, DATA_SLAD_RAN)
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
Initialize();
|
||||
}
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
uiPoisonNovaTimer = 10 * IN_MILLISECONDS;
|
||||
uiPowerfullBiteTimer = 3 * IN_MILLISECONDS;
|
||||
uiVenomBoltTimer = 15 * IN_MILLISECONDS;
|
||||
uiSpawnTimer = 5 * IN_MILLISECONDS;
|
||||
uiPhase = 0;
|
||||
}
|
||||
void Initialize()
|
||||
{
|
||||
_phase = Phase::PHASE_NONE;
|
||||
}
|
||||
|
||||
uint32 uiPoisonNovaTimer;
|
||||
uint32 uiPowerfullBiteTimer;
|
||||
uint32 uiVenomBoltTimer;
|
||||
uint32 uiSpawnTimer;
|
||||
void Reset() override
|
||||
{
|
||||
_Reset();
|
||||
Initialize();
|
||||
_wrappedPlayers.clear();
|
||||
}
|
||||
|
||||
uint8 uiPhase;
|
||||
void JustEngagedWith(Unit* who) override
|
||||
{
|
||||
BossAI::JustEngagedWith(who);
|
||||
Talk(SAY_AGGRO);
|
||||
}
|
||||
|
||||
GuidSet lWrappedPlayers;
|
||||
|
||||
void Reset() override
|
||||
{
|
||||
Initialize();
|
||||
_Reset();
|
||||
lWrappedPlayers.clear();
|
||||
}
|
||||
|
||||
void JustEngagedWith(Unit* who) override
|
||||
{
|
||||
BossAI::JustEngagedWith(who);
|
||||
Talk(SAY_AGGRO);
|
||||
}
|
||||
|
||||
void UpdateAI(uint32 diff) override
|
||||
{
|
||||
//Return since we have no target
|
||||
if (!UpdateVictim())
|
||||
return;
|
||||
|
||||
if (uiPoisonNovaTimer <= diff)
|
||||
void ScheduleTasks() override
|
||||
{
|
||||
scheduler
|
||||
.Schedule(10s, [this](TaskContext task)
|
||||
{
|
||||
DoCastVictim(SPELL_POISON_NOVA);
|
||||
Talk(EMOTE_NOVA);
|
||||
uiPoisonNovaTimer = 15*IN_MILLISECONDS;
|
||||
} else uiPoisonNovaTimer -= diff;
|
||||
|
||||
if (uiPowerfullBiteTimer <= diff)
|
||||
task.Repeat(15s);
|
||||
})
|
||||
.Schedule(3s, [this](TaskContext task)
|
||||
{
|
||||
DoCastVictim(SPELL_POWERFULL_BITE);
|
||||
uiPowerfullBiteTimer = 10*IN_MILLISECONDS;
|
||||
} else uiPowerfullBiteTimer -= diff;
|
||||
|
||||
if (uiVenomBoltTimer <= diff)
|
||||
task.Repeat(10s);
|
||||
})
|
||||
.Schedule(15s, [this](TaskContext task)
|
||||
{
|
||||
DoCastVictim(SPELL_VENOM_BOLT);
|
||||
uiVenomBoltTimer = 10*IN_MILLISECONDS;
|
||||
} else uiVenomBoltTimer -= diff;
|
||||
task.Repeat(10s);
|
||||
});
|
||||
}
|
||||
|
||||
if (uiPhase)
|
||||
{
|
||||
if (uiSpawnTimer <= diff)
|
||||
{
|
||||
if (uiPhase == 1)
|
||||
for (uint8 i = 0; i < DUNGEON_MODE(3, 5); ++i)
|
||||
me->SummonCreature(CREATURE_SNAKE, SpawnLoc[i], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20s);
|
||||
if (uiPhase == 2)
|
||||
for (uint8 i = 0; i < DUNGEON_MODE(3, 5); ++i)
|
||||
me->SummonCreature(CREATURE_CONSTRICTORS, SpawnLoc[i], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20s);
|
||||
uiSpawnTimer = 5*IN_MILLISECONDS;
|
||||
} else uiSpawnTimer -= diff;
|
||||
}
|
||||
|
||||
if (uiPhase == 0 && HealthBelowPct(30))
|
||||
{
|
||||
Talk(SAY_SUMMON_SNAKES);
|
||||
uiPhase = 1;
|
||||
}
|
||||
|
||||
if (uiPhase == 1 && HealthBelowPct(25))
|
||||
{
|
||||
Talk(SAY_SUMMON_CONSTRICTORS);
|
||||
uiPhase = 2;
|
||||
}
|
||||
void UpdateAI(uint32 diff) override
|
||||
{
|
||||
if (!UpdateVictim())
|
||||
return;
|
||||
|
||||
scheduler.Update(diff, [this]
|
||||
{
|
||||
DoMeleeAttackIfReady();
|
||||
}
|
||||
|
||||
void JustDied(Unit* /*killer*/) override
|
||||
{
|
||||
_JustDied();
|
||||
Talk(EMOTE_ACTIVATE_ALTAR);
|
||||
Talk(SAY_DEATH);
|
||||
}
|
||||
|
||||
void KilledUnit(Unit* who) override
|
||||
{
|
||||
if (who->GetTypeId() == TYPEID_PLAYER)
|
||||
Talk(SAY_SLAY);
|
||||
}
|
||||
|
||||
void JustSummoned(Creature* summon) override
|
||||
{
|
||||
summon->GetMotionMaster()->MovePoint(0, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ());
|
||||
summons.Summon(summon);
|
||||
}
|
||||
|
||||
void SetGUID(ObjectGuid const& guid, int32 id) override
|
||||
{
|
||||
if (id == DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES)
|
||||
lWrappedPlayers.insert(guid);
|
||||
}
|
||||
|
||||
bool WasWrapped(ObjectGuid guid)
|
||||
{
|
||||
return lWrappedPlayers.count(guid) != 0;
|
||||
}
|
||||
};
|
||||
|
||||
CreatureAI* GetAI(Creature* creature) const override
|
||||
{
|
||||
return GetGundrakAI<boss_slad_ranAI>(creature);
|
||||
});
|
||||
}
|
||||
|
||||
void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/) override
|
||||
{
|
||||
if (_phase == Phase::PHASE_NONE && HealthBelowPct(30))
|
||||
{
|
||||
Talk(SAY_SUMMON_SNAKES);
|
||||
_phase = Phase::PHASE_SNAKES;
|
||||
|
||||
scheduler.Schedule(5s, GROUP_SNAKES, [this](TaskContext task)
|
||||
{
|
||||
for (uint8 i = 0; i < DUNGEON_MODE(3, 5); ++i)
|
||||
me->SummonCreature(CREATURE_SNAKE, SpawnLoc[i], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20s);
|
||||
|
||||
task.Repeat();
|
||||
});
|
||||
}
|
||||
|
||||
if (_phase == Phase::PHASE_SNAKES && HealthBelowPct(25))
|
||||
{
|
||||
Talk(SAY_SUMMON_CONSTRICTORS);
|
||||
_phase = Phase::PHASE_CONSTRICTORS;
|
||||
|
||||
scheduler.CancelGroup(GROUP_SNAKES);
|
||||
scheduler.Schedule(5s, [this](TaskContext task)
|
||||
{
|
||||
for (uint8 i = 0; i < DUNGEON_MODE(3, 5); ++i)
|
||||
me->SummonCreature(CREATURE_CONSTRICTORS, SpawnLoc[i], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20s);
|
||||
|
||||
task.Repeat();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void JustDied(Unit* /*killer*/) override
|
||||
{
|
||||
_JustDied();
|
||||
Talk(EMOTE_ACTIVATE_ALTAR);
|
||||
Talk(SAY_DEATH);
|
||||
}
|
||||
|
||||
void KilledUnit(Unit* who) override
|
||||
{
|
||||
if (who->GetTypeId() == TYPEID_PLAYER)
|
||||
Talk(SAY_SLAY);
|
||||
}
|
||||
|
||||
void JustSummoned(Creature* summon) override
|
||||
{
|
||||
summon->GetMotionMaster()->MovePoint(0, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ());
|
||||
summons.Summon(summon);
|
||||
}
|
||||
|
||||
void SetGUID(ObjectGuid const& guid, int32 id) override
|
||||
{
|
||||
if (id == DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES)
|
||||
_wrappedPlayers.insert(guid);
|
||||
}
|
||||
|
||||
bool WasWrapped(ObjectGuid guid) const
|
||||
{
|
||||
return _wrappedPlayers.count(guid) != 0;
|
||||
}
|
||||
|
||||
private:
|
||||
Phase _phase;
|
||||
GuidSet _wrappedPlayers;
|
||||
};
|
||||
|
||||
class npc_slad_ran_constrictor : public CreatureScript
|
||||
struct npc_slad_ran_constrictor : public ScriptedAI
|
||||
{
|
||||
public:
|
||||
npc_slad_ran_constrictor() : CreatureScript("npc_slad_ran_constrictor") { }
|
||||
npc_slad_ran_constrictor(Creature* creature) : ScriptedAI(creature) { }
|
||||
|
||||
CreatureAI* GetAI(Creature* creature) const override
|
||||
void Reset() override
|
||||
{
|
||||
return GetGundrakAI<npc_slad_ran_constrictorAI>(creature);
|
||||
_scheduler.CancelAll();
|
||||
}
|
||||
|
||||
struct npc_slad_ran_constrictorAI : public ScriptedAI
|
||||
void JustEngagedWith(Unit* /*who*/) override
|
||||
{
|
||||
npc_slad_ran_constrictorAI(Creature* creature) : ScriptedAI(creature)
|
||||
_scheduler.Schedule(2s, [this](TaskContext task)
|
||||
{
|
||||
uiGripOfSladRanTimer = 1 * IN_MILLISECONDS;
|
||||
}
|
||||
Unit* target = me->GetVictim();
|
||||
|
||||
uint32 uiGripOfSladRanTimer;
|
||||
DoCast(target, SPELL_GRIP_OF_SLAD_RAN);
|
||||
|
||||
void Reset() override
|
||||
{
|
||||
uiGripOfSladRanTimer = 1*IN_MILLISECONDS;
|
||||
}
|
||||
|
||||
void UpdateAI(uint32 diff) override
|
||||
{
|
||||
if (!UpdateVictim())
|
||||
return;
|
||||
|
||||
if (uiGripOfSladRanTimer <= diff)
|
||||
Aura* grip = target->GetAura(SPELL_GRIP_OF_SLAD_RAN, me->GetGUID());
|
||||
if (grip && grip->GetStackAmount() == 5)
|
||||
{
|
||||
Unit* target = me->GetVictim();
|
||||
target->RemoveAurasDueToSpell(SPELL_GRIP_OF_SLAD_RAN, me->GetGUID());
|
||||
target->CastSpell(target, SPELL_SNAKE_WRAP, true);
|
||||
|
||||
DoCast(target, SPELL_GRIP_OF_SLAD_RAN);
|
||||
uiGripOfSladRanTimer = urand(3, 6)*IN_MILLISECONDS;
|
||||
if (TempSummon* _me = me->ToTempSummon())
|
||||
if (Unit* summoner = _me->GetSummonerUnit())
|
||||
if (Creature* sladran = summoner->ToCreature())
|
||||
sladran->AI()->SetGUID(target->GetGUID(), DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES);
|
||||
|
||||
Aura* grip = target->GetAura(SPELL_GRIP_OF_SLAD_RAN, me->GetGUID());
|
||||
if (grip && grip->GetStackAmount() == 5)
|
||||
{
|
||||
target->RemoveAurasDueToSpell(SPELL_GRIP_OF_SLAD_RAN, me->GetGUID());
|
||||
target->CastSpell(target, SPELL_SNAKE_WRAP, true);
|
||||
me->DespawnOrUnsummon();
|
||||
}
|
||||
|
||||
if (TempSummon* _me = me->ToTempSummon())
|
||||
if (Unit* summoner = _me->GetSummonerUnit())
|
||||
if (Creature* sladran = summoner->ToCreature())
|
||||
sladran->AI()->SetGUID(target->GetGUID(), DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES);
|
||||
task.Repeat(3s, 6s);
|
||||
});
|
||||
}
|
||||
|
||||
me->DespawnOrUnsummon();
|
||||
}
|
||||
} else uiGripOfSladRanTimer -= diff;
|
||||
}
|
||||
};
|
||||
void UpdateAI(uint32 diff) override
|
||||
{
|
||||
if (!UpdateVictim())
|
||||
return;
|
||||
|
||||
_scheduler.Update(diff);
|
||||
}
|
||||
private:
|
||||
TaskScheduler _scheduler;
|
||||
};
|
||||
|
||||
class npc_slad_ran_viper : public CreatureScript
|
||||
struct npc_slad_ran_viper : public ScriptedAI
|
||||
{
|
||||
public:
|
||||
npc_slad_ran_viper() : CreatureScript("npc_slad_ran_viper") { }
|
||||
npc_slad_ran_viper(Creature* creature) : ScriptedAI(creature) { }
|
||||
|
||||
CreatureAI* GetAI(Creature* creature) const override
|
||||
void Reset() override
|
||||
{
|
||||
return GetGundrakAI<npc_slad_ran_viperAI>(creature);
|
||||
_scheduler.CancelAll();
|
||||
}
|
||||
|
||||
struct npc_slad_ran_viperAI : public ScriptedAI
|
||||
void JustEngagedWith(Unit* /*who*/) override
|
||||
{
|
||||
npc_slad_ran_viperAI(Creature* creature) : ScriptedAI(creature)
|
||||
_scheduler.Schedule(2s, [this](TaskContext task)
|
||||
{
|
||||
uiVenomousBiteTimer = 2 * IN_MILLISECONDS;
|
||||
}
|
||||
DoCastVictim(SPELL_VENOMOUS_BITE);
|
||||
task.Repeat(10s);
|
||||
});
|
||||
}
|
||||
|
||||
uint32 uiVenomousBiteTimer;
|
||||
|
||||
void Reset() override
|
||||
{
|
||||
uiVenomousBiteTimer = 2*IN_MILLISECONDS;
|
||||
}
|
||||
|
||||
void UpdateAI(uint32 diff) override
|
||||
{
|
||||
if (!UpdateVictim())
|
||||
return;
|
||||
|
||||
if (uiVenomousBiteTimer <= diff)
|
||||
{
|
||||
DoCastVictim(SPELL_VENOMOUS_BITE);
|
||||
uiVenomousBiteTimer = 10*IN_MILLISECONDS;
|
||||
} else uiVenomousBiteTimer -= diff;
|
||||
}
|
||||
};
|
||||
void UpdateAI(uint32 diff) override
|
||||
{
|
||||
if (!UpdateVictim())
|
||||
return;
|
||||
|
||||
_scheduler.Update(diff);
|
||||
}
|
||||
private:
|
||||
TaskScheduler _scheduler;
|
||||
};
|
||||
|
||||
class achievement_snakes_whyd_it_have_to_be_snakes : public AchievementCriteriaScript
|
||||
@@ -308,7 +291,7 @@ class achievement_snakes_whyd_it_have_to_be_snakes : public AchievementCriteriaS
|
||||
if (!target)
|
||||
return false;
|
||||
|
||||
if (boss_slad_ran::boss_slad_ranAI* sladRanAI = CAST_AI(boss_slad_ran::boss_slad_ranAI, target->GetAI()))
|
||||
if (boss_slad_ran* sladRanAI = CAST_AI(boss_slad_ran, target->GetAI()))
|
||||
return !sladRanAI->WasWrapped(player->GetGUID());
|
||||
return false;
|
||||
}
|
||||
@@ -316,8 +299,8 @@ class achievement_snakes_whyd_it_have_to_be_snakes : public AchievementCriteriaS
|
||||
|
||||
void AddSC_boss_slad_ran()
|
||||
{
|
||||
new boss_slad_ran();
|
||||
new npc_slad_ran_constrictor();
|
||||
new npc_slad_ran_viper();
|
||||
RegisterCreatureAIWithFactory(boss_slad_ran, GetGundrakAI);
|
||||
RegisterCreatureAIWithFactory(npc_slad_ran_constrictor, GetGundrakAI);
|
||||
RegisterCreatureAIWithFactory(npc_slad_ran_viper, GetGundrakAI);
|
||||
new achievement_snakes_whyd_it_have_to_be_snakes();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user