Skip to content

Commit b3dbdae

Browse files
committed
Scripts/Underbog: Update scripts
1 parent 9746b68 commit b3dbdae

5 files changed

Lines changed: 176 additions & 98 deletions

File tree

src/server/scripts/Outland/CoilfangReservoir/TheUnderbog/boss_hungarfen.cpp

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

18-
#include "Containers.h"
18+
/*
19+
* Timers requires to be revisited
20+
*/
21+
1922
#include "ScriptMgr.h"
23+
#include "Containers.h"
2024
#include "ScriptedCreature.h"
2125
#include "SpellAuras.h"
2226
#include "SpellScript.h"
@@ -29,16 +33,22 @@ enum HungarfenTexts
2933

3034
enum HungarfenSpells
3135
{
32-
SPELL_FOUL_SPORES = 31673,
33-
SPELL_SUMMON_UNDERBOG_MUSHROOM = 31692,
36+
// Hungarfen - Combat
3437
SPELL_PUTRID_MUSHROOM_PRIMER = 31693,
35-
SPELL_DESPAWN_UNDERBOG_MUSHROOMS = 34874,
38+
SPELL_FOUL_SPORES = 31673,
3639
SPELL_ACID_GEYSER = 38739,
3740

38-
SPELL_SPORE_CLOUD = 34168,
39-
SPELL_PUTRID_MUSHROOM = 31690,
41+
// Hungarfen - Combat - Misc
42+
SPELL_DESPAWN_UNDERBOG_MUSHROOMS = 34874,
43+
44+
// Underbog Mushroom
4045
SPELL_SHRINK = 31691,
41-
SPELL_GROW = 31698
46+
SPELL_PUTRID_MUSHROOM = 31690,
47+
SPELL_GROW = 31698,
48+
SPELL_SPORE_CLOUD = 34168,
49+
50+
// Scripts
51+
SPELL_SUMMON_UNDERBOG_MUSHROOM = 31692
4252
};
4353

4454
// 17770 - Hungarfen
@@ -56,6 +66,7 @@ struct boss_hungarfen : public BossAI
5666
void JustEngagedWith(Unit* who) override
5767
{
5868
BossAI::JustEngagedWith(who);
69+
5970
scheduler.Schedule(IsHeroic() ? 2500ms : 5s, [this](TaskContext task)
6071
{
6172
DoCastSelf(SPELL_PUTRID_MUSHROOM_PRIMER);
@@ -73,6 +84,32 @@ struct boss_hungarfen : public BossAI
7384
}
7485
}
7586

87+
void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
88+
{
89+
if (!_roared && me->HealthBelowPctDamaged(20, damage))
90+
{
91+
_roared = true;
92+
93+
scheduler.Schedule(0s, [this](TaskContext task)
94+
{
95+
switch (task.GetRepeatCounter())
96+
{
97+
case 0:
98+
Talk(EMOTE_ROARS);
99+
me->SetReactState(REACT_PASSIVE);
100+
task.Repeat(2s);
101+
break;
102+
case 1:
103+
DoCastSelf(SPELL_FOUL_SPORES);
104+
me->SetReactState(REACT_AGGRESSIVE);
105+
break;
106+
default:
107+
break;
108+
}
109+
});
110+
}
111+
}
112+
76113
void EnterEvadeMode(EvadeReason why) override
77114
{
78115
DoCastSelf(SPELL_DESPAWN_UNDERBOG_MUSHROOMS, true);
@@ -94,19 +131,6 @@ struct boss_hungarfen : public BossAI
94131
{
95132
DoMeleeAttackIfReady();
96133
});
97-
98-
if (!HealthAbovePct(20) && !_roared)
99-
{
100-
Talk(EMOTE_ROARS);
101-
_roared = true;
102-
me->SetReactState(REACT_PASSIVE);
103-
104-
scheduler.Schedule(2s, [this](TaskContext /*task*/)
105-
{
106-
DoCastSelf(SPELL_FOUL_SPORES);
107-
me->SetReactState(REACT_AGGRESSIVE);
108-
});
109-
}
110134
}
111135

112136
private:
@@ -157,7 +181,7 @@ struct npc_underbog_mushroom : public ScriptedAI
157181

158182
private:
159183
TaskScheduler _scheduler;
160-
uint32 _counter;
184+
uint8 _counter;
161185
};
162186

163187
// 31693 - Putrid Mushroom Primer
@@ -170,20 +194,14 @@ class spell_hungarfen_putrid_mushroom_primer : public SpellScript
170194
return ValidateSpellInfo({ SPELL_SUMMON_UNDERBOG_MUSHROOM });
171195
}
172196

173-
/// @todo: Check if something else should be done here
174197
void FilterTargets(std::list<WorldObject*>& targets)
175198
{
176-
if (targets.empty())
177-
return;
178-
179-
WorldObject* target = Trinity::Containers::SelectRandomContainerElement(targets);
180-
targets.clear();
181-
targets.push_back(target);
199+
Trinity::Containers::RandomResize(targets, 1);
182200
}
183201

184202
void HandleScript(SpellEffIndex /*effIndex*/)
185203
{
186-
GetHitUnit()->CastSpell(GetHitUnit(), SPELL_SUMMON_UNDERBOG_MUSHROOM, true);
204+
GetHitUnit()->CastSpell(nullptr, SPELL_SUMMON_UNDERBOG_MUSHROOM, true);
187205
}
188206

189207
void Register() override

src/server/scripts/Outland/CoilfangReservoir/TheUnderbog/boss_swamplord_muselek.cpp

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

18-
#include "ScriptedCreature.h"
18+
/*
19+
* Timers requires to be revisited
20+
* What does SPELL_NOTIFY_OF_DEATH is unknown
21+
* What does Script Effect of spell SPELL_HUNTERS_MARK is unknown
22+
*/
23+
1924
#include "ScriptMgr.h"
25+
#include "ScriptedCreature.h"
2026
#include "SpellScript.h"
2127
#include "SpellInfo.h"
2228
#include "MotionMaster.h"
@@ -33,19 +39,26 @@ enum MuselekTexts
3339

3440
enum MuselekSpells
3541
{
42+
// Musel'ek - Combat - Ranged
3643
SPELL_SHOOT = 22907,
3744
SPELL_MULTI_SHOT = 34974,
38-
SPELL_AIMED_SHOT = 31623,
3945

46+
// Musel'ek - Combat - Melee
4047
SPELL_KNOCK_AWAY = 18813,
4148
SPELL_BEAR_COMMAND = 34662,
49+
SPELL_RAPTOR_STRIKE = 31566,
4250
SPELL_DETERRENCE = 31567,
4351

52+
// Musel'ek - Combat - Sequence
4453
SPELL_HUNTERS_MARK = 31615,
4554
SPELL_FREEZING_TRAP = 31946,
4655
SPELL_PACIFY_SELF = 19951,
4756
SPELL_MOVE_AWAY_PRIMER = 31564,
4857
SPELL_FACE_HIGHEST_THREAT = 32425,
58+
SPELL_AIMED_SHOT = 31623,
59+
60+
// Musel'ek - Combat - Death
61+
SPELL_NOTIFY_OF_DEATH = 31547,
4962

5063
// Claw
5164
SPELL_ECHOING_ROAR = 31429,
@@ -56,16 +69,19 @@ enum MuselekSpells
5669

5770
enum MuselekEvents
5871
{
72+
// Ranged
5973
EVENT_SHOOT = 1,
6074
EVENT_MULTI_SHOT,
6175

76+
// Melee
6277
EVENT_KNOCK_AWAY,
6378
EVENT_BEAR_COMMAND,
79+
EVENT_RAPTOR_STRIKE,
6480

81+
// Sequence
6582
EVENT_COMBAT_SEQUENCE_1,
6683
EVENT_COMBAT_SEQUENCE_2,
6784
EVENT_COMBAT_SEQUENCE_3,
68-
EVENT_COMBAT_SEQUENCE_4,
6985

7086
// Claw
7187
EVENT_ECHOING_ROAR,
@@ -81,12 +97,20 @@ enum MuselekEvents
8197
enum MuselekMisc
8298
{
8399
FACTION_CENARION_EXP = 1660,
100+
NPC_CLAW = 17827,
84101
NPC_WINDCALLER_CLAW = 17894,
85102
POINT_OUTRO_1 = 1,
86103
POINT_OUTRO_2 = 2,
87104
POINT_MOVE_AWAY = 1
88105
};
89106

107+
enum MuselekPhases : uint8
108+
{
109+
PHASE_NONE = 0,
110+
PHASE_HEALTH_70,
111+
PHASE_HEALTH_30
112+
};
113+
90114
Position const OutroPos[2] =
91115
{
92116
{ 290.53226f, -125.35236f, 29.697079f, 0.0f },
@@ -96,31 +120,52 @@ Position const OutroPos[2] =
96120
// 17826 - Swamplord Musel'ek
97121
struct boss_swamplord_muselek : public BossAI
98122
{
99-
boss_swamplord_muselek(Creature* creature) : BossAI(creature, DATA_SWAMPLORD_MUSELEK) { }
123+
boss_swamplord_muselek(Creature* creature) : BossAI(creature, DATA_SWAMPLORD_MUSELEK), _phase(PHASE_NONE) { }
124+
125+
void Reset() override
126+
{
127+
_Reset();
128+
_phase = PHASE_NONE;
129+
me->SetReactState(REACT_AGGRESSIVE);
130+
}
100131

101132
void JustEngagedWith(Unit* who) override
102133
{
103-
Talk(SAY_AGGRO);
104134
BossAI::JustEngagedWith(who);
105-
me->SetReactState(REACT_AGGRESSIVE);
135+
136+
Talk(SAY_AGGRO);
106137

107138
events.ScheduleEvent(EVENT_SHOOT, 0s);
108139
events.ScheduleEvent(EVENT_MULTI_SHOT, 20s, 30s);
109140

110141
events.ScheduleEvent(EVENT_KNOCK_AWAY, 35s, 40s);
111142
events.ScheduleEvent(EVENT_BEAR_COMMAND, 10s);
112-
113-
events.ScheduleEvent(EVENT_COMBAT_SEQUENCE_1, 15s, 20s);
143+
events.ScheduleEvent(EVENT_RAPTOR_STRIKE, 10s, 20s);
114144
}
115145

116146
void AttackStart(Unit* who) override
117147
{
118148
ScriptedAI::AttackStartCaster(who, 30.0f);
119149
}
120150

121-
void OnSpellCast(SpellInfo const* spell) override
151+
void DamageTaken(Unit* /*killer*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
122152
{
123-
if (spell->Id == SPELL_BEAR_COMMAND)
153+
if (_phase < PHASE_HEALTH_70 && me->HealthBelowPctDamaged(70, damage))
154+
{
155+
_phase++;
156+
events.ScheduleEvent(EVENT_COMBAT_SEQUENCE_1, 0s);
157+
}
158+
159+
if (_phase < PHASE_HEALTH_30 && me->HealthBelowPctDamaged(30, damage))
160+
{
161+
_phase++;
162+
events.ScheduleEvent(EVENT_COMBAT_SEQUENCE_1, 0s);
163+
}
164+
}
165+
166+
void OnSpellCast(SpellInfo const* spellInfo) override
167+
{
168+
if (spellInfo->Id == SPELL_BEAR_COMMAND)
124169
Talk(SAY_COMMAND);
125170
}
126171

@@ -133,15 +178,25 @@ struct boss_swamplord_muselek : public BossAI
133178
events.ScheduleEvent(EVENT_COMBAT_SEQUENCE_3, 1s);
134179
}
135180

181+
void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override
182+
{
183+
if (spellInfo->Id == SPELL_FACE_HIGHEST_THREAT)
184+
if (Unit* target = SelectTarget(SelectTargetMethod::MaxThreat))
185+
me->SetFacingToObject(target);
186+
}
187+
136188
void KilledUnit(Unit* /*victim*/) override
137189
{
138190
Talk(SAY_SLAY);
139191
}
140192

141193
void JustDied(Unit* /*killer*/) override
142194
{
143-
Talk(SAY_DEATH);
144195
_JustDied();
196+
Talk(SAY_DEATH);
197+
198+
if (Creature* claw = me->FindNearestCreature(NPC_CLAW, 100.0f))
199+
DoCast(claw, SPELL_NOTIFY_OF_DEATH);
145200
}
146201

147202
void UpdateAI(uint32 diff) override
@@ -158,6 +213,7 @@ struct boss_swamplord_muselek : public BossAI
158213
{
159214
switch (eventId)
160215
{
216+
// Ranged
161217
case EVENT_SHOOT:
162218
DoCastVictim(SPELL_SHOOT);
163219
events.Repeat(2s, 4s);
@@ -166,6 +222,8 @@ struct boss_swamplord_muselek : public BossAI
166222
DoCastVictim(SPELL_MULTI_SHOT);
167223
events.Repeat(25s, 35s);
168224
break;
225+
226+
// Melee
169227
case EVENT_KNOCK_AWAY:
170228
DoCastVictim(SPELL_KNOCK_AWAY);
171229
events.Repeat(30s, 40s);
@@ -174,8 +232,12 @@ struct boss_swamplord_muselek : public BossAI
174232
DoCastSelf(SPELL_BEAR_COMMAND);
175233
events.Repeat(25s);
176234
break;
235+
case EVENT_RAPTOR_STRIKE:
236+
DoCastVictim(SPELL_RAPTOR_STRIKE);
237+
events.Repeat(10s, 20s);
238+
break;
177239

178-
// This part requires additional research
240+
// Sequence
179241
case EVENT_COMBAT_SEQUENCE_1:
180242
DoCastSelf(SPELL_HUNTERS_MARK);
181243

@@ -184,27 +246,22 @@ struct boss_swamplord_muselek : public BossAI
184246

185247
me->SetReactState(REACT_PASSIVE);
186248
events.ScheduleEvent(EVENT_COMBAT_SEQUENCE_2, 2s);
187-
events.Repeat(25s, 50s);
188249
break;
189250
case EVENT_COMBAT_SEQUENCE_2:
190251
DoCastSelf(SPELL_PACIFY_SELF);
191252
DoCastSelf(SPELL_MOVE_AWAY_PRIMER);
192253

193-
// This is based only on one cast in sniff, need more info
254+
// Not always? Or wrong place? This is based only on one cast in sniff, need more info
194255
if (roll_chance_i(50))
195256
DoCastSelf(SPELL_DETERRENCE);
196257
break;
197258
case EVENT_COMBAT_SEQUENCE_3:
198-
// NYI
199259
DoCastSelf(SPELL_FACE_HIGHEST_THREAT);
200260
me->RemoveAurasDueToSpell(SPELL_PACIFY_SELF);
201261
me->SetReactState(REACT_AGGRESSIVE);
202262

203-
// On next update, otherwise it will not work
204-
events.ScheduleEvent(EVENT_COMBAT_SEQUENCE_4, 1ms);
205-
break;
206-
case EVENT_COMBAT_SEQUENCE_4:
207-
DoCastVictim(SPELL_AIMED_SHOT);
263+
if (Unit* target = SelectTarget(SelectTargetMethod::MaxThreat))
264+
DoCast(target, SPELL_AIMED_SHOT);
208265
break;
209266
default:
210267
break;
@@ -216,6 +273,9 @@ struct boss_swamplord_muselek : public BossAI
216273

217274
DoMeleeAttackIfReady();
218275
}
276+
277+
private:
278+
uint8 _phase;
219279
};
220280

221281
// 17827 - Claw
@@ -379,9 +439,7 @@ class spell_swamplord_muselek_move_away_primer : public SpellScript
379439

380440
void HandleDummy(SpellEffIndex /*effIndex*/)
381441
{
382-
// This should be more tricky. More like random position but with min and max distance, not just random
383-
Position pos = GetCaster()->GetRandomNearPosition(30.0f);
384-
GetCaster()->GetMotionMaster()->MovePoint(POINT_MOVE_AWAY, pos);
442+
GetCaster()->GetMotionMaster()->MovePoint(POINT_MOVE_AWAY, GetCaster()->GetNearPosition(frand(15.0f, 35.0f), frand(0.0f, 2.0f * float(M_PI))));
385443
}
386444

387445
void Register() override

0 commit comments

Comments
 (0)