Skip to content

Commit f40409c

Browse files
authored
Scripts/Maraudon: Modernize scripts (#31092)
* New register model * Codestyle changes * TaskScheduler instead of timer variables * Implement one spell script for Noxxion encounter
1 parent 70d1875 commit f40409c

File tree

6 files changed

+231
-325
lines changed

6 files changed

+231
-325
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
--
2+
UPDATE `creature_template` SET `ScriptName` = 'boss_celebras_the_cursed' WHERE `entry` = 12225;
3+
4+
DELETE FROM `spell_script_names` WHERE `ScriptName` = 'spell_noxxion_summon_spawns';
5+
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
6+
(21708, 'spell_noxxion_summon_spawns');

src/server/scripts/Kalimdor/Maraudon/boss_celebras_the_cursed.cpp

Lines changed: 49 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -15,101 +15,77 @@
1515
* with this program. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

18-
/* ScriptData
19-
SDName: Boss_Celebras_the_Cursed
20-
SD%Complete: 100
21-
SDComment:
22-
SDCategory: Maraudon
23-
EndScriptData */
24-
2518
#include "ScriptMgr.h"
2619
#include "maraudon.h"
2720
#include "ScriptedCreature.h"
2821

29-
enum Spells
22+
enum CelebrasSpells
3023
{
3124
SPELL_WRATH = 21807,
32-
SPELL_ENTANGLINGROOTS = 12747,
25+
SPELL_ENTANGLING_ROOTS = 12747,
3326
SPELL_CORRUPT_FORCES = 21968
3427
};
3528

36-
class celebras_the_cursed : public CreatureScript
29+
enum CelebrasMisc
30+
{
31+
NPC_CELEBRAS_THE_REDEEMED = 13716
32+
};
33+
34+
// 12225 - Celebras the Cursed
35+
struct boss_celebras_the_cursed : public ScriptedAI
3736
{
38-
public:
39-
celebras_the_cursed() : CreatureScript("celebras_the_cursed") { }
37+
boss_celebras_the_cursed(Creature* creature) : ScriptedAI(creature) { }
4038

41-
CreatureAI* GetAI(Creature* creature) const override
39+
void Reset() override
4240
{
43-
return GetMaraudonAI<celebras_the_cursedAI>(creature);
41+
_scheduler.CancelAll();
4442
}
4543

46-
struct celebras_the_cursedAI : public ScriptedAI
44+
void JustEngagedWith(Unit* /*who*/) override
4745
{
48-
celebras_the_cursedAI(Creature* creature) : ScriptedAI(creature)
49-
{
50-
Initialize();
51-
}
52-
53-
void Initialize()
54-
{
55-
WrathTimer = 8000;
56-
EntanglingRootsTimer = 2000;
57-
CorruptForcesTimer = 30000;
58-
}
59-
60-
uint32 WrathTimer;
61-
uint32 EntanglingRootsTimer;
62-
uint32 CorruptForcesTimer;
63-
64-
void Reset() override
65-
{
66-
Initialize();
67-
}
68-
69-
void JustEngagedWith(Unit* /*who*/) override { }
70-
71-
void JustDied(Unit* /*killer*/) override
72-
{
73-
me->SummonCreature(13716, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10min);
74-
}
75-
76-
void UpdateAI(uint32 diff) override
77-
{
78-
if (!UpdateVictim())
79-
return;
80-
81-
//Wrath
82-
if (WrathTimer <= diff)
46+
_scheduler
47+
.SetValidator([this]
8348
{
84-
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0))
85-
DoCast(target, SPELL_WRATH);
86-
WrathTimer = 8000;
87-
}
88-
else WrathTimer -= diff;
89-
90-
//EntanglingRoots
91-
if (EntanglingRootsTimer <= diff)
49+
return !me->HasUnitState(UNIT_STATE_CASTING);
50+
})
51+
.Schedule(0s, 6s, [this](TaskContext task)
9252
{
93-
DoCastVictim(SPELL_ENTANGLINGROOTS);
94-
EntanglingRootsTimer = 20000;
95-
}
96-
else EntanglingRootsTimer -= diff;
97-
98-
//CorruptForces
99-
if (CorruptForcesTimer <= diff)
53+
DoCastVictim(SPELL_WRATH);
54+
task.Repeat(4s, 8s);
55+
})
56+
.Schedule(0s, 5s, [this](TaskContext task)
10057
{
101-
me->InterruptNonMeleeSpells(false);
102-
DoCast(me, SPELL_CORRUPT_FORCES);
103-
CorruptForcesTimer = 20000;
104-
}
105-
else CorruptForcesTimer -= diff;
58+
DoCastVictim(SPELL_ENTANGLING_ROOTS);
59+
task.Repeat(20s);
60+
})
61+
.Schedule(30s, [this](TaskContext task)
62+
{
63+
DoCastSelf(SPELL_CORRUPT_FORCES);
64+
task.Repeat(20s);
65+
});
66+
}
67+
68+
void JustDied(Unit* /*killer*/) override
69+
{
70+
me->SummonCreature(NPC_CELEBRAS_THE_REDEEMED, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_MANUAL_DESPAWN);
71+
}
72+
73+
void UpdateAI(uint32 diff) override
74+
{
75+
if (!UpdateVictim())
76+
return;
10677

78+
_scheduler.Update(diff, [this]
79+
{
10780
DoMeleeAttackIfReady();
108-
}
109-
};
81+
});
82+
}
83+
84+
private:
85+
TaskScheduler _scheduler;
11086
};
11187

11288
void AddSC_boss_celebras_the_cursed()
11389
{
114-
new celebras_the_cursed();
90+
RegisterMaraudonCreatureAI(boss_celebras_the_cursed);
11591
}

src/server/scripts/Kalimdor/Maraudon/boss_landslide.cpp

Lines changed: 47 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -15,100 +15,78 @@
1515
* with this program. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

18-
/* ScriptData
19-
SDName: Boss_Landslide
20-
SD%Complete: 100
21-
SDComment:
22-
SDCategory: Maraudon
23-
EndScriptData */
24-
2518
#include "ScriptMgr.h"
2619
#include "maraudon.h"
2720
#include "ScriptedCreature.h"
2821

29-
enum Spells
22+
enum LandslideSpells
3023
{
31-
SPELL_KNOCKAWAY = 18670,
24+
SPELL_KNOCK_AWAY = 18670,
3225
SPELL_TRAMPLE = 5568,
3326
SPELL_LANDSLIDE = 21808
3427
};
3528

36-
class boss_landslide : public CreatureScript
29+
// 12203 - Landslide
30+
struct boss_landslide : public ScriptedAI
3731
{
38-
public:
39-
boss_landslide() : CreatureScript("boss_landslide") { }
32+
boss_landslide(Creature* creature) : ScriptedAI(creature), _landslide(false) { }
4033

41-
CreatureAI* GetAI(Creature* creature) const override
34+
void Reset() override
4235
{
43-
return GetMaraudonAI<boss_landslideAI>(creature);
36+
_scheduler.CancelAll();
37+
_landslide = false;
4438
}
4539

46-
struct boss_landslideAI : public ScriptedAI
40+
void JustEngagedWith(Unit* /*who*/) override
4741
{
48-
boss_landslideAI(Creature* creature) : ScriptedAI(creature)
49-
{
50-
Initialize();
51-
}
42+
_scheduler
43+
.SetValidator([this]
44+
{
45+
return !me->HasUnitState(UNIT_STATE_CASTING);
46+
})
47+
.Schedule(5s, 10s, [this](TaskContext task)
48+
{
49+
DoCastVictim(SPELL_KNOCK_AWAY);
50+
task.Repeat(15s, 25s);
51+
})
52+
.Schedule(10s, 15s, [this](TaskContext task)
53+
{
54+
DoCastSelf(SPELL_TRAMPLE);
55+
task.Repeat(10s, 20s);
56+
});
57+
}
5258

53-
void Initialize()
59+
void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
60+
{
61+
if (!_landslide && me->HealthBelowPctDamaged(50, damage))
5462
{
55-
KnockAwayTimer = 8000;
56-
TrampleTimer = 2000;
57-
LandslideTimer = 0;
58-
}
59-
60-
uint32 KnockAwayTimer;
61-
uint32 TrampleTimer;
62-
uint32 LandslideTimer;
63+
_landslide = true;
6364

64-
void Reset() override
65-
{
66-
Initialize();
65+
_scheduler.Schedule(0s, [this](TaskContext task)
66+
{
67+
DoCastSelf(SPELL_LANDSLIDE);
68+
task.Repeat(30s, 40s);
69+
});
6770
}
71+
}
6872

69-
void JustEngagedWith(Unit* /*who*/) override
70-
{
71-
}
73+
void UpdateAI(uint32 diff) override
74+
{
75+
if (!UpdateVictim())
76+
return;
7277

73-
void UpdateAI(uint32 diff) override
78+
_scheduler.Update(diff, [this]
7479
{
75-
if (!UpdateVictim())
76-
return;
77-
78-
//KnockAwayTimer
79-
if (KnockAwayTimer <= diff)
80-
{
81-
DoCastVictim(SPELL_KNOCKAWAY);
82-
KnockAwayTimer = 15000;
83-
}
84-
else KnockAwayTimer -= diff;
85-
86-
//TrampleTimer
87-
if (TrampleTimer <= diff)
88-
{
89-
DoCast(me, SPELL_TRAMPLE);
90-
TrampleTimer = 8000;
91-
}
92-
else TrampleTimer -= diff;
93-
94-
//Landslide
95-
if (HealthBelowPct(50))
96-
{
97-
if (LandslideTimer <= diff)
98-
{
99-
me->InterruptNonMeleeSpells(false);
100-
DoCast(me, SPELL_LANDSLIDE);
101-
LandslideTimer = 60000;
102-
}
103-
else LandslideTimer -= diff;
104-
}
105-
10680
DoMeleeAttackIfReady();
107-
}
108-
};
81+
});
82+
}
83+
84+
private:
85+
TaskScheduler _scheduler;
86+
bool _landslide;
10987
};
11088

11189
void AddSC_boss_landslide()
11290
{
113-
new boss_landslide();
91+
RegisterMaraudonCreatureAI(boss_landslide);
11492
}

0 commit comments

Comments
 (0)