Skip to content

Commit d592130

Browse files
authored
Scripts/RazorfenDowns: Modernize scripts (#31145)
1 parent ac1c9b8 commit d592130

File tree

6 files changed

+340
-292
lines changed

6 files changed

+340
-292
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--
2+
DELETE FROM `creature_text` WHERE `CreatureID` = 7358;
3+
INSERT INTO `creature_text` (`CreatureID`, `GroupID`, `ID`, `Text`, `Type`, `Language`, `Probability`, `Emote`, `Duration`, `Sound`, `BroadcastTextId`, `TextRange`, `comment`) VALUES
4+
(7358,0,0,"You'll never leave this place alive.",14,0,100,0,0,5825,6187,0,"amnennar SAY_AGGRO"),
5+
(7358,1,0,"Too easy.",12,0,100,0,0,5826,6188,0,"amnennar SAY_SLAY"),
6+
(7358,2,0,"I am the hand of the Lich King!",14,0,100,0,0,5827,6192,0,"amnennar SAY_HEALTH_75"),
7+
(7358,3,0,"To me, my servants!",14,0,100,0,0,5828,6189,0,"amnennar SAY_SUMMON_60"),
8+
(7358,4,0,"Come, spirits - attend your master!",14,0,100,0,0,5829,6190,0,"amnennar SAY_SUMMON_30"),
9+
(7358,5,0,"%s begins to summon wraiths out of the freezing cold air!",16,0,100,0,0,0,4483,0,"amnennar EMOTE_SUMMON");
10+
11+
DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId` = 13 AND `SourceEntry` = 12660;
12+
INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`SourceId`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionTarget`,`ConditionValue1`,`ConditionValue2`,`ConditionValue3`,`NegativeCondition`,`ErrorType`,`ErrorTextId`,`ScriptName`,`Comment`) VALUES
13+
(13,1,12660,0,0,31,0,3,8585,0,0,0,0,"","Group 0: Spell 'Banish Frost Spectres' (Effect 0) targets creature 'Frost Spectre'");
14+
15+
DELETE FROM `smart_scripts` WHERE `entryorguid` = 8585 AND `source_type` = 0;
16+
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`,`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
17+
(8585,0,0,0,37,0,100,0,0,0,0,0,0,116,4,0,0,0,0,0,1,0,0,0,0,0,0,0,0,"Frost Spectre - On AI Initialize - Set Corpse Delay"),
18+
(8585,0,1,0,8,0,100,0,12660,0,0,0,0,11,3617,0,0,0,0,0,1,0,0,0,0,0,0,0,0,"Frost Spectre - On Spellhit 'Banish Frost Spectres' - Cast 'Quiet Suicide'");

src/server/scripts/Kalimdor/RazorfenDowns/boss_amnennar_the_coldbringer.cpp

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

18+
/*
19+
* Timers requires update
20+
* Guardians are despawned in core, that should not happen here
21+
*/
22+
1823
#include "ScriptMgr.h"
1924
#include "ScriptedCreature.h"
2025
#include "razorfen_downs.h"
2126

22-
enum Say
27+
enum AmnennarTexts
2328
{
24-
SAY_AGGRO = 0,
25-
SAY_SUMMON60 = 1,
26-
SAY_SUMMON30 = 2,
27-
SAY_HP = 3,
28-
SAY_KILL = 4
29+
SAY_AGGRO = 0,
30+
SAY_SLAY = 1,
31+
SAY_HEALTH_75 = 2,
32+
SAY_SUMMON_60 = 3,
33+
SAY_SUMMON_30 = 4,
34+
EMOTE_SUMMON = 5
2935
};
3036

31-
enum Spells
37+
enum AmnennarSpells
3238
{
33-
SPELL_AMNENNARSWRATH = 13009,
34-
SPELL_FROSTBOLT = 15530,
35-
SPELL_FROST_NOVA = 15531,
36-
SPELL_FROST_SPECTRES = 12642
39+
SPELL_AMNENNARS_WRATH = 13009,
40+
SPELL_FROSTBOLT = 15530,
41+
SPELL_FROST_NOVA = 15531,
42+
SPELL_SUMMON_FROST_SPECTRES = 12642,
43+
SPELL_BANISH_FROST_SPECTRES = 12660
3744
};
3845

39-
enum Events
46+
enum AmnennarEvents
4047
{
41-
EVENT_AMNENNARSWRATH = 1,
42-
EVENT_FROSTBOLT = 2,
43-
EVENT_FROST_NOVA = 3
48+
EVENT_AMNENNARS_WRATH = 1,
49+
EVENT_FROSTBOLT,
50+
EVENT_FROST_NOVA,
51+
52+
EVENT_HEALTH_75,
53+
EVENT_HEALTH_60,
54+
EVENT_HEALTH_30
4455
};
4556

46-
class boss_amnennar_the_coldbringer : public CreatureScript
57+
enum AmnennarPhases : uint8
4758
{
48-
public:
49-
boss_amnennar_the_coldbringer() : CreatureScript("boss_amnennar_the_coldbringer") { }
59+
PHASE_NONE = 0,
60+
PHASE_HEALTH_75,
61+
PHASE_HEALTH_60,
62+
PHASE_HEALTH_30
63+
};
5064

51-
struct boss_amnennar_the_coldbringerAI : public BossAI
65+
// 7358 - Amnennar the Coldbringer
66+
struct boss_amnennar_the_coldbringer : public BossAI
67+
{
68+
boss_amnennar_the_coldbringer(Creature* creature) : BossAI(creature, DATA_AMNENNAR_THE_COLD_BRINGER), _phase(PHASE_NONE) { }
69+
70+
void Reset() override
5271
{
53-
boss_amnennar_the_coldbringerAI(Creature* creature) : BossAI(creature, DATA_AMNENNAR_THE_COLD_BRINGER)
54-
{
55-
Initialize();
56-
}
72+
_Reset();
73+
_phase = PHASE_NONE;
74+
}
5775

58-
void Initialize()
59-
{
60-
hp60Spectrals = false;
61-
hp30Spectrals = false;
62-
hp50 = false;
63-
}
76+
void JustEngagedWith(Unit* who) override
77+
{
78+
BossAI::JustEngagedWith(who);
79+
events.ScheduleEvent(EVENT_AMNENNARS_WRATH, 8s);
80+
events.ScheduleEvent(EVENT_FROSTBOLT, 0s);
81+
events.ScheduleEvent(EVENT_FROST_NOVA, 10s, 15s);
82+
Talk(SAY_AGGRO);
83+
}
6484

65-
void Reset() override
85+
void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
86+
{
87+
if (_phase < PHASE_HEALTH_75 && me->HealthBelowPctDamaged(75, damage))
6688
{
67-
_Reset();
68-
Initialize();
89+
_phase++;
90+
events.ScheduleEvent(EVENT_HEALTH_75, 0s);
6991
}
7092

71-
void JustEngagedWith(Unit* who) override
93+
if (_phase < PHASE_HEALTH_60 && me->HealthBelowPctDamaged(60, damage))
7294
{
73-
BossAI::JustEngagedWith(who);
74-
events.ScheduleEvent(EVENT_AMNENNARSWRATH, 8s);
75-
events.ScheduleEvent(EVENT_FROSTBOLT, 1s);
76-
events.ScheduleEvent(EVENT_FROST_NOVA, 10s, 15s);
77-
Talk(SAY_AGGRO);
95+
_phase++;
96+
events.ScheduleEvent(EVENT_HEALTH_60, 0s);
7897
}
7998

80-
void KilledUnit(Unit* who) override
99+
if (_phase < PHASE_HEALTH_30 && me->HealthBelowPctDamaged(30, damage))
81100
{
82-
if (who->GetTypeId() == TYPEID_PLAYER)
83-
Talk(SAY_KILL);
101+
_phase++;
102+
events.ScheduleEvent(EVENT_HEALTH_30, 0s);
84103
}
104+
}
85105

86-
void JustDied(Unit* /*killer*/) override
87-
{
88-
_JustDied();
89-
}
106+
void KilledUnit(Unit* who) override
107+
{
108+
if (who->GetTypeId() == TYPEID_PLAYER)
109+
Talk(SAY_SLAY);
110+
}
90111

91-
void UpdateAI(uint32 diff) override
92-
{
93-
if (!UpdateVictim())
94-
return;
112+
// Despawn is handled by spell, don't store anything
113+
void JustSummoned(Creature* /*summon*/) override { }
95114

96-
events.Update(diff);
115+
void EnterEvadeMode(EvadeReason why) override
116+
{
117+
DoCastSelf(SPELL_BANISH_FROST_SPECTRES, true);
118+
BossAI::EnterEvadeMode(why);
119+
}
97120

98-
if (me->HasUnitState(UNIT_STATE_CASTING))
99-
return;
121+
void JustDied(Unit* /*killer*/) override
122+
{
123+
_JustDied();
124+
DoCastSelf(SPELL_BANISH_FROST_SPECTRES, true);
125+
}
100126

101-
while (uint32 eventId = events.ExecuteEvent())
102-
{
103-
switch (eventId)
104-
{
105-
case EVENT_AMNENNARSWRATH:
106-
DoCastVictim(SPELL_AMNENNARSWRATH);
107-
events.ScheduleEvent(EVENT_AMNENNARSWRATH, 12s);
108-
break;
109-
case EVENT_FROSTBOLT:
110-
DoCastVictim(SPELL_FROSTBOLT);
111-
events.ScheduleEvent(EVENT_FROSTBOLT, 8s);
112-
break;
113-
case EVENT_FROST_NOVA:
114-
DoCast(me, SPELL_FROST_NOVA);
115-
events.ScheduleEvent(EVENT_FROST_NOVA, 15s);
116-
break;
117-
}
118-
119-
if (me->HasUnitState(UNIT_STATE_CASTING))
120-
return;
121-
}
127+
void UpdateAI(uint32 diff) override
128+
{
129+
if (!UpdateVictim())
130+
return;
122131

123-
if (!hp60Spectrals && HealthBelowPct(60))
124-
{
125-
Talk(SAY_SUMMON60);
126-
DoCastVictim(SPELL_FROST_SPECTRES);
127-
hp60Spectrals = true;
128-
}
132+
events.Update(diff);
129133

130-
if (!hp50 && HealthBelowPct(50))
131-
{
132-
Talk(SAY_HP);
133-
hp50 = true;
134-
}
134+
if (me->HasUnitState(UNIT_STATE_CASTING))
135+
return;
135136

136-
if (!hp30Spectrals && HealthBelowPct(30))
137+
while (uint32 eventId = events.ExecuteEvent())
138+
{
139+
switch (eventId)
137140
{
138-
Talk(SAY_SUMMON30);
139-
DoCastVictim(SPELL_FROST_SPECTRES);
140-
hp30Spectrals = true;
141+
case EVENT_AMNENNARS_WRATH:
142+
DoCastVictim(SPELL_AMNENNARS_WRATH);
143+
events.Repeat(12s);
144+
break;
145+
case EVENT_FROSTBOLT:
146+
DoCastVictim(SPELL_FROSTBOLT);
147+
events.Repeat(8s);
148+
break;
149+
case EVENT_FROST_NOVA:
150+
DoCastSelf(SPELL_FROST_NOVA);
151+
events.Repeat(15s);
152+
break;
153+
154+
case EVENT_HEALTH_75:
155+
Talk(SAY_HEALTH_75);
156+
break;
157+
case EVENT_HEALTH_60:
158+
Talk(EMOTE_SUMMON);
159+
Talk(SAY_SUMMON_60);
160+
DoCastSelf(SPELL_SUMMON_FROST_SPECTRES);
161+
break;
162+
case EVENT_HEALTH_30:
163+
Talk(EMOTE_SUMMON);
164+
Talk(SAY_SUMMON_30);
165+
DoCastSelf(SPELL_SUMMON_FROST_SPECTRES);
166+
break;
167+
default:
168+
break;
141169
}
142170

143-
DoMeleeAttackIfReady();
171+
if (me->HasUnitState(UNIT_STATE_CASTING))
172+
return;
144173
}
145174

146-
private:
147-
bool hp60Spectrals;
148-
bool hp30Spectrals;
149-
bool hp50;
150-
};
151-
152-
CreatureAI* GetAI(Creature* creature) const override
153-
{
154-
return GetRazorfenDownsAI<boss_amnennar_the_coldbringerAI>(creature);
175+
DoMeleeAttackIfReady();
155176
}
177+
178+
private:
179+
uint8 _phase;
156180
};
157181

158182
void AddSC_boss_amnennar_the_coldbringer()
159183
{
160-
new boss_amnennar_the_coldbringer();
184+
RegisterRazorfenDownsCreatureAI(boss_amnennar_the_coldbringer);
161185
}

0 commit comments

Comments
 (0)