Scripts/Stockades: Cleanup the scripts (#23524)

* Scripts/Stockades: Cleanup the scripts

Scripts looked ugly before, now they are less ugly
Move Mortimer Moloch and Warden Thelwater to use TaskScheduler rather than EventMap
Use new script registers
Cleanup some other code

Co-authored-by: Carbenium <carbenium@outlook.com>
This commit is contained in:
Artamedes
2020-08-10 14:50:25 -04:00
committed by GitHub
parent 7e4fdf0522
commit e85bd8fd39
5 changed files with 273 additions and 344 deletions

View File

@@ -15,10 +15,10 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "InstanceScript.h"
#include "MotionMaster.h"
#include "ScriptedCreature.h"
#include "ScriptMgr.h"
#include "the_stockade.h"
enum Says
@@ -29,7 +29,7 @@ enum Says
SAY_WARDEN_1 = 0, // Yell - This ends here, Hogger!
SAY_WARDEN_2 = 1, // Say - He's...he's dead?
SAY_WARDEN_3 = 2 // Say - It's simply too good to be true. You couldn't have killed him so easily!
SAY_WARDEN_3 = 2 // Say - It's simply too good to be true. You couldn't have killed him so easily!
};
enum Spells
@@ -51,142 +51,121 @@ enum Events
enum Points
{
POINT_FINISH = 0
POINT_FINISH = 1
};
Position const wardenthelwatermovepos = { 152.019f, 106.198f, -35.1896f, 1.082104f };
Position const wardenthelwaterpos = { 138.369f, 78.2932f, -33.85627f, 1.082104f };
Position const wardenThelwaterMovePoint = { 152.019f, 106.198f, -35.1896f, 1.082104f };
Position const wardenThelwaterSpawnPosition = { 138.369f, 78.2932f, -33.85627f, 1.082104f };
class boss_hogger : public CreatureScript
// Hogger - 46254
struct boss_hogger : public BossAI
{
public:
boss_hogger() : CreatureScript("boss_hogger") { }
boss_hogger(Creature* creature) : BossAI(creature, DATA_HOGGER), _hasEnraged(false) { }
struct boss_hoggerAI : public BossAI
void Reset() override
{
boss_hoggerAI(Creature* creature) : BossAI(creature, DATA_HOGGER), _hasEnraged(false) { }
void EnterCombat(Unit* /*who*/) override
{
_EnterCombat();
Talk(SAY_PULL);
events.ScheduleEvent(EVENT_VICIOUS_SLICE, Seconds(3), Seconds(4));
events.ScheduleEvent(EVENT_MADDENING_CALL, Seconds(1), Seconds(2));
}
void JustDied(Unit* /*killer*/) override
{
Talk(SAY_DEATH);
_JustDied();
me->SummonCreature(NPC_WARDEN_THELWATER, wardenthelwaterpos);
}
void JustSummoned(Creature* summon) override
{
BossAI::JustSummoned(summon);
if (summon->GetEntry() == NPC_WARDEN_THELWATER)
summon->GetMotionMaster()->MovePoint(POINT_FINISH, wardenthelwatermovepos);
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
while (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_VICIOUS_SLICE:
DoCastVictim(SPELL_VICIOUS_SLICE);
events.Repeat(Seconds(10), Seconds(14));
break;
case EVENT_MADDENING_CALL:
DoCast(SPELL_MADDENING_CALL);
events.Repeat(Seconds(15), Seconds(20));
break;
}
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
}
DoMeleeAttackIfReady();
}
void DamageTaken(Unit* /*attacker*/, uint32& damage) override
{
if (me->HealthBelowPctDamaged(30, damage) && !_hasEnraged)
{
_hasEnraged = true;
Talk(SAY_ENRAGE);
DoCastSelf(SPELL_ENRAGE);
}
}
private:
bool _hasEnraged;
};
CreatureAI* GetAI(Creature* creature) const override
{
return GetStormwindStockadeAI<boss_hoggerAI>(creature);
_hasEnraged = false;
}
void EnterCombat(Unit* who) override
{
BossAI::EnterCombat(who);
Talk(SAY_PULL);
events.ScheduleEvent(EVENT_VICIOUS_SLICE, 3s, 4s);
events.ScheduleEvent(EVENT_MADDENING_CALL, 1s, 2s);
}
void JustDied(Unit* killer) override
{
BossAI::JustDied(killer);
Talk(SAY_DEATH);
me->SummonCreature(NPC_WARDEN_THELWATER, wardenThelwaterSpawnPosition);
}
void JustSummoned(Creature* summon) override
{
BossAI::JustSummoned(summon);
if (summon->GetEntry() == NPC_WARDEN_THELWATER)
summon->GetMotionMaster()->MovePoint(POINT_FINISH, wardenThelwaterMovePoint);
}
void ExecuteEvent(uint32 eventId) override
{
switch (eventId)
{
case EVENT_VICIOUS_SLICE:
DoCastVictim(SPELL_VICIOUS_SLICE);
events.Repeat(10s, 14s);
break;
case EVENT_MADDENING_CALL:
DoCast(SPELL_MADDENING_CALL);
events.Repeat(15s, 20s);
break;
default:
break;
}
}
void DamageTaken(Unit* /*attacker*/, uint32& damage) override
{
if (me->HealthBelowPctDamaged(30, damage) && !_hasEnraged)
{
_hasEnraged = true;
Talk(SAY_ENRAGE);
DoCastSelf(SPELL_ENRAGE);
}
}
private:
bool _hasEnraged;
};
class npc_warden_thelwater : public CreatureScript
// Warden Thelwater - 46409
struct npc_warden_thelwater : public ScriptedAI
{
public:
npc_warden_thelwater() : CreatureScript("npc_warden_thelwater") {}
npc_warden_thelwater(Creature* creature) : ScriptedAI(creature) { }
struct npc_warden_thelwaterAI : public ScriptedAI
void MovementInform(uint32 type, uint32 id) override
{
npc_warden_thelwaterAI(Creature* creature) : ScriptedAI(creature) {}
if (type != POINT_MOTION_TYPE)
return;
void MovementInform(uint32 type, uint32 id) override
if (id == POINT_FINISH)
{
if (type == POINT_MOTION_TYPE && id == POINT_FINISH)
_events.ScheduleEvent(EVENT_SAY_WARDEN_1, Seconds(1));
}
void UpdateAI(uint32 diff) override
{
_events.Update(diff);
while (uint32 eventId = _events.ExecuteEvent())
scheduler.Schedule(1s, [this](TaskContext /*context*/)
{
switch (eventId)
{
case EVENT_SAY_WARDEN_1:
Talk(SAY_WARDEN_1);
_events.ScheduleEvent(EVENT_SAY_WARDEN_2, Seconds(4));
break;
case EVENT_SAY_WARDEN_2:
Talk(SAY_WARDEN_2);
_events.ScheduleEvent(EVENT_SAY_WARDEN_3, Seconds(3));
break;
case EVENT_SAY_WARDEN_3:
Talk(SAY_WARDEN_3);
break;
}
}
}
private:
EventMap _events;
};
Talk(SAY_WARDEN_1);
});
CreatureAI* GetAI(Creature* creature) const override
{
return GetStormwindStockadeAI<npc_warden_thelwaterAI>(creature);
scheduler.Schedule(5s, [this](TaskContext /*context*/)
{
Talk(SAY_WARDEN_2);
});
scheduler.Schedule(8s, [this](TaskContext /*context*/)
{
Talk(SAY_WARDEN_3);
});
}
}
void UpdateAI(const uint32 diff) override
{
scheduler.Update(diff);
}
private:
TaskScheduler scheduler;
};
void AddSC_boss_hogger()
{
new boss_hogger();
new npc_warden_thelwater();
RegisterStormwindStockadesAI(boss_hogger);
RegisterStormwindStockadesAI(npc_warden_thelwater);
}

View File

@@ -15,15 +15,15 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "ScriptMgr.h"
#include "the_stockade.h"
enum Spells
{
SPELL_FIREBALL = 12466, //starts 1-2 secs from pull
SPELL_OVERHEAT = 86633, //probably cast every 10 secs, need to confirm.
SPELL_RAIN_OF_FIRE = 86636 //probably cast every 10 secs, need to confirm
SPELL_FIREBALL = 12466, // starts 1-2 secs from pull
SPELL_OVERHEAT = 86633, // probably cast every 10 secs, need to confirm.
SPELL_RAIN_OF_FIRE = 86636 // probably cast every 10 secs, need to confirm
};
enum Events
@@ -35,80 +35,57 @@ enum Events
enum Says
{
SAY_PULL = 0, //Yell: ALL MUST BURN!
SAY_DEATH = 1 //Yell: FIRE... EXTINGUISHED!
SAY_PULL = 0, // Yell: ALL MUST BURN!
SAY_DEATH = 1 // Yell: FIRE... EXTINGUISHED!
};
class boss_lord_overheat : public CreatureScript
// Lord Overheat - 46264
struct boss_lord_overheat : public BossAI
{
public:
boss_lord_overheat() : CreatureScript("boss_lord_overheat") {}
boss_lord_overheat(Creature* creature) : BossAI(creature, DATA_LORD_OVERHEAT) { }
struct boss_lord_overheatAI : public BossAI
void EnterCombat(Unit* who) override
{
boss_lord_overheatAI(Creature* creature) : BossAI(creature, DATA_LORD_OVERHEAT) { }
BossAI::EnterCombat(who);
void EnterCombat(Unit* /*who*/) override
{
_EnterCombat();
Talk(SAY_PULL);
events.ScheduleEvent(EVENT_FIREBALL, Seconds(2));
events.ScheduleEvent(EVENT_OVERHEAT, Seconds(9), Seconds(11));
events.ScheduleEvent(EVENT_RAIN_OF_FIRE, Seconds(10), Seconds(13));
}
Talk(SAY_PULL);
void JustDied(Unit* /*killer*/) override
{
Talk(SAY_DEATH);
_JustDied();
}
events.ScheduleEvent(EVENT_FIREBALL, 2s);
events.ScheduleEvent(EVENT_OVERHEAT, 9s, 11s);
events.ScheduleEvent(EVENT_RAIN_OF_FIRE, 10s, 13s);
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
while (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_FIREBALL:
DoCastVictim(SPELL_FIREBALL);
events.Repeat(Seconds(2));
break;
case EVENT_OVERHEAT:
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100.0f, true))
DoCast(target, SPELL_OVERHEAT);
events.Repeat(Seconds(9), Seconds(10));
break;
case EVENT_RAIN_OF_FIRE:
DoCastAOE(SPELL_RAIN_OF_FIRE);
events.Repeat(Seconds(15), Seconds(20));
break;
default:
break;
}
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
}
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* creature) const override
void JustDied(Unit* killer) override
{
return GetStormwindStockadeAI<boss_lord_overheatAI>(creature);
BossAI::JustDied(killer);
Talk(SAY_DEATH);
}
void ExecuteEvent(uint32 eventId) override
{
switch (eventId)
{
case EVENT_FIREBALL:
DoCastVictim(SPELL_FIREBALL);
events.Repeat(2s);
break;
case EVENT_OVERHEAT:
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100.0f, true))
DoCast(target, SPELL_OVERHEAT);
events.Repeat(9s, 10s);
break;
case EVENT_RAIN_OF_FIRE:
DoCastAOE(SPELL_RAIN_OF_FIRE);
events.Repeat(15s, 20s);
break;
default:
break;
}
}
};
void AddSC_boss_lord_overheat()
{
new boss_lord_overheat();
RegisterStormwindStockadesAI(boss_lord_overheat);
}

View File

@@ -15,17 +15,17 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "MotionMaster.h"
#include "ScriptedCreature.h"
#include "ScriptMgr.h"
#include "the_stockade.h"
enum Spells
{
SPELL_WILDLY_STABBING = 86726,
SPELL_SWEEP = 86729,
SPELL_VANISH = 55964,
SPELL_SHADOWSTEP = 55966
SPELL_WILDLY_STABBING = 86726,
SPELL_SWEEP = 86729,
SPELL_VANISH = 55964,
SPELL_SHADOWSTEP = 55966
};
enum Events
@@ -42,182 +42,153 @@ enum Events
enum Says
{
SAY_PULL = 0, //Allow me to introduce myself. I am Randolph Moloch and I will be killing you all today.
SAY_PULL = 0, // Allow me to introduce myself. I am Randolph Moloch and I will be killing you all today.
SAY_VANISH = 1, // Area Trigger: %s vanishes!
SAY_DEATH = 2, //My epic schemes, my great plans! Gone!
SAY_DEATH = 2, // My epic schemes, my great plans! Gone!
MORTIMER_MOLOCH_DEATH = 0, // %s collapses from a heart attack!
MORTIMER_MOLOCH_EMOTE = 1, //Egad! My sophisticated heart!
MORTIMER_MOLOCH_EMOTE = 1, // Egad! My sophisticated heart!
};
enum Points
{
POINT_FINISH = 0,
POINT_FINISH = 1,
};
Position const mortimerMolochPos = { 145.5811f, 0.7059f, -25.606f, 6.2f };
class boss_randolph_moloch : public CreatureScript
// Randolph Moloch - 46383
struct boss_randolph_moloch : public BossAI
{
public:
boss_randolph_moloch() : CreatureScript("boss_randolph_moloch") {}
boss_randolph_moloch(Creature* creature) : BossAI(creature, DATA_RANDOLPH_MOLOCH), _firstVanish(false),
_secondVanish(false) { }
struct boss_randolph_molochAI : public BossAI
void Reset() override
{
boss_randolph_molochAI(Creature* creature) : BossAI(creature, DATA_RANDOLPH_MOLOCH)
{
firstVanish = false;
secondVanish = false;
}
void EnterCombat(Unit* /*who*/) override
{
_EnterCombat();
Talk(SAY_PULL);
events.ScheduleEvent(EVENT_WILDLY_STABBING, Seconds(4), Seconds(5));
events.ScheduleEvent(EVENT_SWEEP, Seconds(2), Seconds(3));
}
void JustSummoned(Creature* summon) override
{
BossAI::JustSummoned(summon);
if (summon->GetEntry() == NPC_MORTIMER_MOLOCH)
{
summon->SetWalk(true);
summon->GetMotionMaster()->MovePoint(POINT_FINISH, me->GetPosition());
}
}
void JustDied(Unit* /*killer*/) override
{
Talk(SAY_DEATH);
_JustDied();
me->SummonCreature(NPC_MORTIMER_MOLOCH, mortimerMolochPos);
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
while (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_WILDLY_STABBING:
DoCastVictim(SPELL_WILDLY_STABBING);
events.Repeat(Seconds(8), Seconds(12));
break;
case EVENT_SWEEP:
DoCastVictim(SPELL_SWEEP);
events.ScheduleEvent(EVENT_SWEEP, Seconds(6), Seconds(7));
break;
case EVENT_VANISH:
Talk(SAY_VANISH);
me->RemoveAllAuras();
DoCastSelf(SPELL_VANISH);
me->SetReactState(REACT_PASSIVE);
me->SetInCombatState(true); // Prevents the boss from resetting
events.ScheduleEvent(EVENT_JUST_VANISHED, Seconds(2));
break;
case EVENT_JUST_VANISHED:
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100.0f, true))
DoCast(target, SPELL_SHADOWSTEP, true);
me->SetReactState(REACT_AGGRESSIVE);
break;
default:
break;
}
}
DoMeleeAttackIfReady();
}
void DamageTaken(Unit* /*attacker*/, uint32& damage) override
{
if (me->HealthBelowPctDamaged(71, damage) && me->HealthAbovePct(59) && !firstVanish)
{
firstVanish = true;
events.ScheduleEvent(EVENT_VANISH, Seconds(1));
}
if (me->HealthBelowPctDamaged(41, damage) && me->HealthAbovePct(29) && !secondVanish)
{
secondVanish = true;
events.ScheduleEvent(EVENT_VANISH, Seconds(1));
}
}
private:
bool firstVanish, secondVanish;
};
CreatureAI* GetAI(Creature* creature) const override
{
return GetStormwindStockadeAI<boss_randolph_molochAI>(creature);
_firstVanish = false;
_secondVanish = false;
}
void EnterCombat(Unit* who) override
{
BossAI::EnterCombat(who);
Talk(SAY_PULL);
events.ScheduleEvent(EVENT_WILDLY_STABBING, 4s, 5s);
events.ScheduleEvent(EVENT_SWEEP, 2s, 3s);
}
void JustSummoned(Creature* summon) override
{
BossAI::JustSummoned(summon);
if (summon->GetEntry() == NPC_MORTIMER_MOLOCH)
{
summon->SetWalk(true);
summon->GetMotionMaster()->MovePoint(POINT_FINISH, me->GetPosition());
}
}
void JustDied(Unit* killer) override
{
BossAI::JustDied(killer);
Talk(SAY_DEATH);
me->SummonCreature(NPC_MORTIMER_MOLOCH, mortimerMolochPos);
}
void ExecuteEvent(uint32 eventId) override
{
switch (eventId)
{
case EVENT_WILDLY_STABBING:
DoCastVictim(SPELL_WILDLY_STABBING);
events.Repeat(8s, 12s);
break;
case EVENT_SWEEP:
DoCastVictim(SPELL_SWEEP);
events.ScheduleEvent(EVENT_SWEEP, 6s, 7s);
break;
case EVENT_VANISH:
Talk(SAY_VANISH);
me->RemoveAllAuras();
DoCastSelf(SPELL_VANISH);
me->SetReactState(REACT_PASSIVE);
me->SetInCombatState(true); // Prevents the boss from resetting
events.ScheduleEvent(EVENT_JUST_VANISHED, 2s);
break;
case EVENT_JUST_VANISHED:
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100.0f, true))
DoCast(target, SPELL_SHADOWSTEP, true);
me->SetReactState(REACT_AGGRESSIVE);
break;
default:
break;
}
}
void DamageTaken(Unit* /*attacker*/, uint32& damage) override
{
if (me->HealthBelowPctDamaged(71, damage) && me->HealthAbovePct(59) && !_firstVanish)
{
_firstVanish = true;
events.ScheduleEvent(EVENT_VANISH, 1s);
}
if (me->HealthBelowPctDamaged(41, damage) && me->HealthAbovePct(29) && !_secondVanish)
{
_secondVanish = true;
events.ScheduleEvent(EVENT_VANISH, 1s);
}
}
private:
bool _firstVanish;
bool _secondVanish;
};
class npc_mortimer_moloch : public CreatureScript
// Mortimer Moloch - 46482
struct npc_mortimer_moloch : public ScriptedAI
{
public:
npc_mortimer_moloch() : CreatureScript("npc_mortimer_moloch") {}
npc_mortimer_moloch(Creature* creature) : ScriptedAI(creature) { }
struct npc_mortimer_molochAI : public ScriptedAI
void Reset() override
{
npc_mortimer_molochAI(Creature* creature) : ScriptedAI(creature) {}
void Reset() override
{
me->SetReactState(REACT_PASSIVE);
}
void MovementInform(uint32 type, uint32 id) override
{
if (type == POINT_MOTION_TYPE)
if(id == POINT_FINISH)
_events.ScheduleEvent(EVENT_MORTIMER_MOLOCH_EMOTE, Seconds(4));
}
void UpdateAI(uint32 diff) override
{
_events.Update(diff);
while (uint32 eventId = _events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_MORTIMER_MOLOCH_EMOTE:
Talk(MORTIMER_MOLOCH_EMOTE);
_events.ScheduleEvent(EVENT_MORTIMER_MOLOCH_DEATH, Seconds(3));
break;
case EVENT_MORTIMER_MOLOCH_DEATH:
Talk(MORTIMER_MOLOCH_DEATH);
me->KillSelf();
break;
default:
break;
}
}
}
private:
EventMap _events;
};
CreatureAI* GetAI(Creature* creature) const override
{
return GetStormwindStockadeAI<npc_mortimer_molochAI>(creature);
me->SetReactState(REACT_PASSIVE);
}
void MovementInform(uint32 type, uint32 id) override
{
if (type != POINT_MOTION_TYPE)
return;
if (id == POINT_FINISH)
{
scheduler.Schedule(4s, [this](TaskContext /*context*/)
{
Talk(MORTIMER_MOLOCH_EMOTE);
});
scheduler.Schedule(7s, [this](TaskContext /*context*/)
{
Talk(MORTIMER_MOLOCH_DEATH);
me->KillSelf();
});
}
}
void UpdateAI(uint32 diff) override
{
scheduler.Update(diff);
}
private:
TaskScheduler scheduler;
};
void AddSC_boss_randolph_moloch()
{
new boss_randolph_moloch();
new npc_mortimer_moloch();
RegisterStormwindStockadesAI(boss_randolph_moloch);
RegisterStormwindStockadesAI(npc_mortimer_moloch);
}

View File

@@ -15,8 +15,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "InstanceScript.h"
#include "ScriptMgr.h"
#include "the_stockade.h"
class instance_the_stockade : public InstanceMapScript

View File

@@ -47,4 +47,6 @@ inline AI* GetStormwindStockadeAI(Creature* creature)
return GetInstanceAI<AI>(creature, StormwindStockadeScriptName);
}
#define RegisterStormwindStockadesAI(AI) RegisterCreatureAIWithFactory(AI, GetStormwindStockadeAI)
#endif