Skip to content

Commit da2adb6

Browse files
authored
Scripts/Spells: Implement Putrid Mushroom Primer spell (#30914)
1 parent 4a6b737 commit da2adb6

File tree

3 files changed

+58
-25
lines changed

3 files changed

+58
-25
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
--
2+
DELETE FROM `spell_script_names` WHERE `ScriptName` = 'spell_hungarfen_putrid_mushroom_primer';
3+
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
4+
(31693, 'spell_hungarfen_putrid_mushroom_primer');

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

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

18+
#include "Containers.h"
1819
#include "ScriptMgr.h"
1920
#include "ScriptedCreature.h"
2021
#include "SpellAuras.h"
22+
#include "SpellScript.h"
2123
#include "the_underbog.h"
2224

2325
enum HungarfenTexts
@@ -53,17 +55,15 @@ struct boss_hungarfen : public BossAI
5355
void JustEngagedWith(Unit* who) override
5456
{
5557
BossAI::JustEngagedWith(who);
56-
_scheduler.Schedule(IsHeroic() ? 2500ms : 5s, [this](TaskContext task)
58+
scheduler.Schedule(IsHeroic() ? 2500ms : 5s, [this](TaskContext task)
5759
{
58-
/// @todo cast here SPELL_PUTRID_MUSHROOM_PRIMER and do it in spell script
59-
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0))
60-
target->CastSpell(target, SPELL_SUMMON_UNDERBOG_MUSHROOM, true);
60+
DoCastSelf(SPELL_PUTRID_MUSHROOM_PRIMER);
6161
task.Repeat(IsHeroic() ? 2500ms : 10s);
6262
});
6363

6464
if (IsHeroic())
6565
{
66-
_scheduler.Schedule(3s, 5s, [this](TaskContext task)
66+
scheduler.Schedule(3s, 5s, [this](TaskContext task)
6767
{
6868
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0))
6969
DoCast(target, SPELL_ACID_GEYSER);
@@ -89,7 +89,7 @@ struct boss_hungarfen : public BossAI
8989
if (!UpdateVictim())
9090
return;
9191

92-
_scheduler.Update(diff, [this]
92+
scheduler.Update(diff, [this]
9393
{
9494
DoMeleeAttackIfReady();
9595
});
@@ -100,7 +100,7 @@ struct boss_hungarfen : public BossAI
100100
_roared = true;
101101
me->SetReactState(REACT_PASSIVE);
102102

103-
_scheduler.Schedule(2s, [this](TaskContext /*task*/)
103+
scheduler.Schedule(2s, [this](TaskContext /*task*/)
104104
{
105105
DoCastSelf(SPELL_FOUL_SPORES);
106106
me->SetReactState(REACT_AGGRESSIVE);
@@ -109,7 +109,6 @@ struct boss_hungarfen : public BossAI
109109
}
110110

111111
private:
112-
TaskScheduler _scheduler;
113112
bool _roared;
114113
};
115114

@@ -159,8 +158,42 @@ struct npc_underbog_mushroom : public ScriptedAI
159158
uint32 _counter;
160159
};
161160

161+
// 31693 - Putrid Mushroom Primer
162+
class spell_hungarfen_putrid_mushroom_primer : public SpellScript
163+
{
164+
PrepareSpellScript(spell_hungarfen_putrid_mushroom_primer);
165+
166+
bool Validate(SpellInfo const* /*spellInfo*/) override
167+
{
168+
return ValidateSpellInfo({ SPELL_SUMMON_UNDERBOG_MUSHROOM });
169+
}
170+
171+
/// @todo: Check if something else should be done here
172+
void FilterTargets(std::list<WorldObject*>& targets)
173+
{
174+
if (targets.empty())
175+
return;
176+
177+
WorldObject* target = Trinity::Containers::SelectRandomContainerElement(targets);
178+
targets.clear();
179+
targets.push_back(target);
180+
}
181+
182+
void HandleScript(SpellEffIndex /*effIndex*/)
183+
{
184+
GetHitUnit()->CastSpell(GetHitUnit(), SPELL_SUMMON_UNDERBOG_MUSHROOM, true);
185+
}
186+
187+
void Register() override
188+
{
189+
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_hungarfen_putrid_mushroom_primer::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY);
190+
OnEffectHitTarget += SpellEffectFn(spell_hungarfen_putrid_mushroom_primer::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
191+
}
192+
};
193+
162194
void AddSC_boss_hungarfen()
163195
{
164196
RegisterTheUnderbogCreatureAI(boss_hungarfen);
165197
RegisterTheUnderbogCreatureAI(npc_underbog_mushroom);
198+
RegisterSpellScript(spell_hungarfen_putrid_mushroom_primer);
166199
}

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

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,30 +63,30 @@ enum Events
6363

6464
struct boss_the_black_stalker : public BossAI
6565
{
66-
boss_the_black_stalker(Creature* creature) : BossAI(creature, DATA_THE_BLACK_STALKER), _summons(creature) { }
66+
boss_the_black_stalker(Creature* creature) : BossAI(creature, DATA_THE_BLACK_STALKER) { }
6767

6868
void JustEngagedWith(Unit* who) override
6969
{
7070
BossAI::JustEngagedWith(who);
71-
_events.ScheduleEvent(EVENT_LEASH_CHECK, 5s);
72-
_events.ScheduleEvent(EVENT_LEVITATE, 8s, 18s);
73-
_events.ScheduleEvent(EVENT_CHAIN_LIGHTNING, 0s, 3s);
74-
_events.ScheduleEvent(EVENT_STATIC_CHARGE, 10s);
71+
events.ScheduleEvent(EVENT_LEASH_CHECK, 5s);
72+
events.ScheduleEvent(EVENT_LEVITATE, 8s, 18s);
73+
events.ScheduleEvent(EVENT_CHAIN_LIGHTNING, 0s, 3s);
74+
events.ScheduleEvent(EVENT_STATIC_CHARGE, 10s);
7575
if (IsHeroic())
76-
_events.ScheduleEvent(EVENT_SUMMON_SPORE_STRIDER, 20s, 30s);
76+
events.ScheduleEvent(EVENT_SUMMON_SPORE_STRIDER, 20s, 30s);
7777
}
7878

7979
void UpdateAI(uint32 diff) override
8080
{
8181
if (!UpdateVictim())
8282
return;
8383

84-
_events.Update(diff);
84+
events.Update(diff);
8585

8686
if (me->HasUnitState(UNIT_STATE_CASTING))
8787
return;
8888

89-
while (uint32 eventId = _events.ExecuteEvent())
89+
while (uint32 eventId = events.ExecuteEvent())
9090
{
9191
switch (eventId)
9292
{
@@ -99,25 +99,25 @@ struct boss_the_black_stalker : public BossAI
9999
EnterEvadeMode();
100100
return;
101101
}
102-
_events.Repeat(1s);
102+
events.Repeat(1s);
103103
break;
104104
}
105105
case EVENT_LEVITATE:
106106
DoCastSelf(SPELL_LEVITATE);
107-
_events.Repeat(18s, 24s);
107+
events.Repeat(18s, 24s);
108108
break;
109109
case EVENT_CHAIN_LIGHTNING:
110110
DoCastVictim(SPELL_CHAIN_LIGHTNING);
111-
_events.Repeat(6s, 12s);
111+
events.Repeat(6s, 12s);
112112
break;
113113
case EVENT_STATIC_CHARGE:
114114
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 30, true))
115115
DoCast(target, SPELL_STATIC_CHARGE);
116-
_events.Repeat(10s);
116+
events.Repeat(10s);
117117
break;
118118
case EVENT_SUMMON_SPORE_STRIDER:
119119
DoCastSelf(SPELL_SUMMON_SPORE_STRIDER_SCRIPT);
120-
_events.Repeat(15s, 25s);
120+
events.Repeat(15s, 25s);
121121
break;
122122
default:
123123
break;
@@ -129,10 +129,6 @@ struct boss_the_black_stalker : public BossAI
129129

130130
DoMeleeAttackIfReady();
131131
}
132-
133-
private:
134-
EventMap _events;
135-
SummonList _summons;
136132
};
137133

138134
// 31704 - Levitate

0 commit comments

Comments
 (0)