TrinityCore
boss_hungarfen.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "ScriptMgr.h"
19#include "ScriptedCreature.h"
20#include "SpellAuras.h"
21#include "the_underbog.h"
22
24{
25 EMOTE_ROARS = 0
26};
27
29{
35
38 SPELL_SHRINK = 31691,
39 SPELL_GROW = 31698
40};
41
42struct boss_hungarfen : public BossAI
43{
44 boss_hungarfen(Creature* creature) : BossAI(creature, DATA_HUNGARFEN), _roared(false) { }
45
46 void Reset() override
47 {
49 _roared = false;
51 }
52
53 void JustEngagedWith(Unit* who) override
54 {
56 _scheduler.Schedule(IsHeroic() ? 2500ms : 5s, [this](TaskContext task)
57 {
60 target->CastSpell(target, SPELL_SUMMON_UNDERBOG_MUSHROOM, true);
61 task.Repeat(IsHeroic() ? 2500ms : 10s);
62 });
63
64 if (IsHeroic())
65 {
66 _scheduler.Schedule(3s, 5s, [this](TaskContext task)
67 {
70 task.Repeat(10s, 15s);
71 });
72 }
73 }
74
75 void EnterEvadeMode(EvadeReason why) override
76 {
79 }
80
81 void JustDied(Unit* killer) override
82 {
84 BossAI::JustDied(killer);
85 }
86
87 void UpdateAI(uint32 diff) override
88 {
89 if (!UpdateVictim())
90 return;
91
92 _scheduler.Update(diff);
93
94 if (!HealthAbovePct(20) && !_roared)
95 {
97 _roared = true;
99
100 _scheduler.Schedule(2s, [this](TaskContext /*task*/)
101 {
104 });
105 }
106 }
107
108private:
111};
112
114{
115 npc_underbog_mushroom(Creature* creature) : ScriptedAI(creature), _counter(0) { }
116
117 void InitializeAI() override
118 {
119 _counter = RAND(8, 9, 10);
123
124 _scheduler.Schedule(1s, [this](TaskContext task)
125 {
127
128 // It's random(sniffs), makes them grow to different size. We need here count of stacks
129 // and not task repeat counter because first stack is applied not when task is repeated
130 Aura* growAura = me->GetAura(SPELL_GROW);
131 if (growAura && growAura->GetStackAmount() != _counter)
132 task.Repeat(2s);
133 else
134 {
135 task.Schedule(1s, [this](TaskContext task)
136 {
138
139 task.Schedule(4s, [this](TaskContext /*task*/)
140 {
143 });
144 });
145 }
146 });
147 }
148
149 void UpdateAI(uint32 diff) override
150 {
151 _scheduler.Update(diff);
152 }
153
154private:
157};
158
160{
163}
First const & RAND(First const &first, Second const &second, Rest const &... rest)
uint32_t uint32
Definition: Define.h:142
EvadeReason
Definition: UnitAICommon.h:30
@ REACT_PASSIVE
Definition: UnitDefines.h:506
@ REACT_AGGRESSIVE
Definition: UnitDefines.h:508
void AddSC_boss_hungarfen()
HungarfenSpells
@ SPELL_SHRINK
@ SPELL_DESPAWN_UNDERBOG_MUSHROOMS
@ SPELL_FOUL_SPORES
@ SPELL_PUTRID_MUSHROOM_PRIMER
@ SPELL_SPORE_CLOUD
@ SPELL_ACID_GEYSER
@ SPELL_GROW
@ SPELL_PUTRID_MUSHROOM
@ SPELL_SUMMON_UNDERBOG_MUSHROOM
HungarfenTexts
@ EMOTE_ROARS
uint8 GetStackAmount() const
Definition: SpellAuras.h:189
void JustEngagedWith(Unit *who) override
void JustDied(Unit *) override
void Reset() override
virtual void EnterEvadeMode(EvadeReason why=EvadeReason::Other)
Definition: CreatureAI.cpp:219
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
void SetReactState(ReactStates st)
Definition: Creature.h:160
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
Definition: Creature.cpp:2415
TaskContext & Schedule(std::chrono::duration< Rep, Period > time, TaskScheduler::task_handler_t task)
TaskContext & Repeat(std::chrono::duration< Rep, Period > duration)
TaskScheduler & Schedule(std::chrono::duration< Rep, Period > time, task_handler_t task)
TaskScheduler & Update(success_t const &callback=nullptr)
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:159
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition: UnitAI.cpp:79
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4560
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3831
bool IsHeroic() const
bool HealthAbovePct(uint32 pct) const
boss_hungarfen(Creature *creature)
void UpdateAI(uint32 diff) override
void Reset() override
TaskScheduler _scheduler
void JustDied(Unit *killer) override
void EnterEvadeMode(EvadeReason why) override
void JustEngagedWith(Unit *who) override
npc_underbog_mushroom(Creature *creature)
void InitializeAI() override
void UpdateAI(uint32 diff) override
#define RegisterTheUnderbogCreatureAI(ai_name)
Definition: the_underbog.h:48
@ DATA_HUNGARFEN
Definition: the_underbog.h:30