TrinityCore
Loading...
Searching...
No Matches
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/*
19 * Timers requires to be revisited
20 */
21
22#include "ScriptMgr.h"
23#include "Containers.h"
24#include "ScriptedCreature.h"
25#include "SpellAuras.h"
26#include "SpellScript.h"
27#include "the_underbog.h"
28
33
35{
36 // Hungarfen - Combat
40
41 // Hungarfen - Combat - Misc
43
44 // Underbog Mushroom
45 SPELL_SHRINK = 31691,
47 SPELL_GROW = 31698,
49
50 // Scripts
52};
53
54// 17770 - Hungarfen
55struct boss_hungarfen : public BossAI
56{
57 boss_hungarfen(Creature* creature) : BossAI(creature, DATA_HUNGARFEN), _roared(false) { }
58
59 void Reset() override
60 {
62 _roared = false;
64 }
65
66 void JustEngagedWith(Unit* who) override
67 {
69
70 scheduler.Schedule(IsHeroic() ? 2500ms : 5s, [this](TaskContext& task)
71 {
73 task.Repeat(IsHeroic() ? 2500ms : 10s);
74 });
75
76 if (IsHeroic())
77 {
78 scheduler.Schedule(3s, 5s, [this](TaskContext& task)
79 {
82 task.Repeat(10s, 15s);
83 });
84 }
85 }
86
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
118
119 void JustDied(Unit* killer) override
120 {
122 BossAI::JustDied(killer);
123 }
124
125 void UpdateAI(uint32 diff) override
126 {
127 if (!UpdateVictim())
128 return;
129
130 scheduler.Update(diff);
131 }
132
133private:
135};
136
137// 17990 - Underbog Mushroom
139{
140 npc_underbog_mushroom(Creature* creature) : ScriptedAI(creature), _counter(0) { }
141
142 void InitializeAI() override
143 {
144 _counter = RAND(8, 9, 10);
148
149 _scheduler.Schedule(1s, [this](TaskContext& task)
150 {
152
153 // It's random(sniffs), makes them grow to different size. We need here count of stacks
154 // and not task repeat counter because first stack is applied not when task is repeated
155 Aura* growAura = me->GetAura(SPELL_GROW);
156 if (growAura && growAura->GetStackAmount() != _counter)
157 task.Repeat(2s);
158 else
159 {
160 task.Schedule(1s, [this](TaskContext& task)
161 {
163
164 task.Schedule(4s, [this](TaskContext const& /*task*/)
165 {
168 });
169 });
170 }
171 });
172 }
173
174 void UpdateAI(uint32 diff) override
175 {
176 _scheduler.Update(diff);
177 }
178
179private:
182};
183
184// 31693 - Putrid Mushroom Primer
208
First const & RAND(First const &first, Second const &second, Rest const &... rest)
uint8_t uint8
Definition Define.h:156
uint32_t uint32
Definition Define.h:154
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
SpellEffIndex
@ EFFECT_0
@ SPELL_EFFECT_SCRIPT_EFFECT
@ TARGET_UNIT_SRC_AREA_ENEMY
#define SpellEffectFn(F, I, N)
#define SpellObjectAreaTargetSelectFn(F, I, N)
EvadeReason
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
DamageEffectType
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:238
void JustEngagedWith(Unit *who) override
void JustDied(Unit *) override
TaskScheduler scheduler
void Reset() override
virtual void EnterEvadeMode(EvadeReason why=EvadeReason::Other)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void SetReactState(ReactStates st)
Definition Creature.h:180
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
TaskContext & Schedule(TaskScheduler::duration_t time, TaskScheduler::task_handler_t task)
TaskScheduler::repeated_t GetRepeatCounter() const
Returns the repeat counter which increases every time the task is repeated.
TaskContext & Repeat(TaskScheduler::duration_t duration)
TaskScheduler & Schedule(duration_t time, task_handler_t task)
TaskScheduler & Update()
Update the scheduler to the current time.
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:71
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:81
Definition Unit.h:647
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition Unit.cpp:4718
bool HealthBelowPctDamaged(float pct, uint32 damage) const
Definition Unit.h:805
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3992
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2222
void FilterTargets(std::list< WorldObject * > &targets)
bool Validate(SpellInfo const *) override
void RandomResize(C &container, std::size_t requestedSize)
Definition Containers.h:67
bool IsHeroic() const
boss_hungarfen(Creature *creature)
void UpdateAI(uint32 diff) override
void Reset() override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
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)
@ DATA_HUNGARFEN