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
2325enum 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
111111private:
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+
162194void AddSC_boss_hungarfen ()
163195{
164196 RegisterTheUnderbogCreatureAI (boss_hungarfen);
165197 RegisterTheUnderbogCreatureAI (npc_underbog_mushroom);
198+ RegisterSpellScript (spell_hungarfen_putrid_mushroom_primer);
166199}
0 commit comments