TrinityCore
boss_grobbulus.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 * He should call all stitched giants after aggro
20 */
21
22#include "naxxramas.h"
23#include "Map.h"
24#include "ObjectAccessor.h"
25#include "PassiveAI.h"
26#include "ScriptedCreature.h"
27#include "ScriptMgr.h"
28#include "SpellAuraEffects.h"
29#include "SpellAuras.h"
30#include "SpellInfo.h"
31#include "SpellScript.h"
32
34{
37};
38
40{
41 // Grobbulus
42 SPELL_BOMBARD_SLIME = 28280, // should be used out of combat (waypoint script?)
48 // Grobbulus Cloud
52 // Fallout Slime
54};
55
56#define SPELL_SLIME_SPRAY RAID_MODE<uint32>(28157,54364)
57
59{
64};
65
66struct boss_grobbulus : public BossAI
67{
68 boss_grobbulus(Creature* creature) : BossAI(creature, BOSS_GROBBULUS) { }
69
70 void JustEngagedWith(Unit* who) override
71 {
75 events.ScheduleEvent(EVENT_SPRAY, RAND(25700ms, 27700ms, 30000ms));
77 }
78
79 void SpellHitTarget(WorldObject* target, SpellInfo const* spellInfo) override
80 {
81 if (spellInfo->Id == SPELL_SLIME_SPRAY)
82 target->CastSpell(target, SPELL_SUMMON_FALLOUT_SLIME, true);
83 }
84
85 void UpdateAI(uint32 diff) override
86 {
87 if (!UpdateVictim())
88 return;
89
90 events.Update(diff);
91
92 while (uint32 eventId = events.ExecuteEvent())
93 {
94 switch (eventId)
95 {
96 case EVENT_CLOUD:
98 events.Repeat(RAND(15600ms, 16800ms));
99 return;
100 case EVENT_BERSERK:
102 return;
103 case EVENT_SPRAY:
106 // timers must always looks like ~30 (initial) ~30 (first repeat) 55 (second repeat) ~30 55
107 // ~30 55 ~30 55 ~30 55. So after second cast timers are always flipped
108 events.Repeat(RAND(32500ms, 33700ms));
109 return;
110 case EVENT_INJECT:
111 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true, true, -SPELL_MUTATING_INJECTION))
112 {
114 Talk(EMOTE_MUTAGEN, target);
115 }
116 // The timers indeed depends on health but most likely they are just changed at health ptc
117 // Default timers are 10800ms, 12000ms, then changed to ~8000ms, 10000ms
118 events.Repeat(Seconds(8) + Milliseconds(uint32(std::round(120 * me->GetHealthPct()))));
119 return;
120 default:
121 break;
122 }
123 }
124 }
125};
126
128{
130
131 void JustAppeared() override
132 {
135 me->DespawnOrUnsummon(61s);
136 }
137};
138
140{
141 npc_fallout_slime(Creature* creature) : ScriptedAI(creature) { }
142
143 void InitializeAI() override
144 {
145 me->SetCorpseDelay(2, true);
148
149 _scheduler.Schedule(2s, [this](TaskContext /*task*/)
150 {
152
153 if (Unit* summoner = ObjectAccessor::GetUnit(*me, _summonerGUID))
154 // maybe only if threat list was empty?
155 AddThreat(summoner, 100000.0f);
156 });
157 }
158
159 void IsSummonedBy(WorldObject* summoner) override
160 {
161 _summonerGUID = summoner->GetGUID();
162 }
163
164 void EnterEvadeMode(EvadeReason /*why*/) override
165 {
166 // They don't despawn when Grobbulus dies. Calling despawn here is not entirely correct because originally
167 // they just stuck after leaving combat(literally, they don't move), then they despawns after few seconds
169 }
170
171 void UpdateAI(uint32 diff) override
172 {
173 _scheduler.Update(diff);
174
175 if (!UpdateVictim())
176 return;
177 }
178
179private:
182};
183
184// 28169 - Mutating Injection
186{
187 bool Validate(SpellInfo const* /*spellInfo*/) override
188 {
190 }
191
192 void HandleRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
193 {
195 if (removeMode != AURA_REMOVE_BY_ENEMY_SPELL && removeMode != AURA_REMOVE_BY_EXPIRE)
196 return;
197
198 if (Unit* caster = GetCaster())
199 {
200 caster->CastSpell(GetTarget(), SPELL_MUTATING_EXPLOSION, true);
202 .SetTriggeringAura(aurEff)
203 .SetOriginalCaster(GetCasterGUID()));
204 }
205 }
206
207 void Register() override
208 {
210 }
211};
212
213// 28158, 54362 - Poison
215{
216 bool Validate(SpellInfo const* spellInfo) override
217 {
218 return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } })
219 && ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0).TriggerSpell });
220 }
221
222 void PeriodicTick(AuraEffect const* aurEff)
223 {
225 if (!aurEff->GetTotalTicks())
226 return;
227
228 uint32 triggerSpell = aurEff->GetSpellEffectInfo().TriggerSpell;
229 int32 mod = int32(((float(aurEff->GetTickNumber()) / aurEff->GetTotalTicks()) * 0.9f + 0.1f) * 10000 * 2 / 3);
230
231 CastSpellExtraArgs args(aurEff);
233 GetTarget()->CastSpell(nullptr, triggerSpell, args);
234 }
235
236 void Register() override
237 {
239 }
240};
241
243{
249}
First const & RAND(First const &first, Second const &second, Rest const &... rest)
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:32
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition: Duration.h:29
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
@ EFFECT_0
Definition: SharedDefines.h:30
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
AuraRemoveMode
@ AURA_REMOVE_BY_EXPIRE
@ AURA_REMOVE_BY_ENEMY_SPELL
@ SPELL_AURA_DUMMY
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
@ TRIGGERED_FULL_MASK
Used when doing CastSpell with triggered == true.
Definition: SpellDefines.h:266
@ SPELLVALUE_RADIUS_MOD
Definition: SpellDefines.h:229
#define AuraEffectPeriodicFn(F, I, N)
Definition: SpellScript.h:2046
#define AuraEffectRemoveFn(F, I, N, M)
Definition: SpellScript.h:2040
EvadeReason
Definition: UnitAICommon.h:30
@ REACT_PASSIVE
Definition: UnitDefines.h:506
@ REACT_AGGRESSIVE
Definition: UnitDefines.h:508
GrobbulusSpells
@ SPELL_BOMBARD_SLIME
@ SPELL_SUMMON_FALLOUT_SLIME
@ SPELL_POISON_CLOUD_PASSIVE_25
@ SPELL_MUTATING_INJECTION
@ SPELL_PACIFY_SELF
@ SPELL_DISEASE_CLOUD
@ SPELL_POISON_CLOUD_PASSIVE
@ SPELL_BERSERK
@ SPELL_MUTATING_EXPLOSION
@ SPELL_POISON_CLOUD
GrobbulusTexts
@ EMOTE_MUTAGEN
@ EMOTE_SLIME
#define SPELL_SLIME_SPRAY
GrobbulusEvents
@ EVENT_CLOUD
@ EVENT_BERSERK
@ EVENT_INJECT
@ EVENT_SPRAY
void AddSC_boss_grobbulus()
AuraRemoveMode GetRemoveMode() const
Definition: SpellAuras.h:91
uint32 GetTickNumber() const
SpellEffectInfo const & GetSpellEffectInfo() const
uint32 GetTotalTicks() const
void PreventDefaultAction()
AuraApplication const * GetTargetApplication() const
HookList< EffectApplyHandler > AfterEffectRemove
Definition: SpellScript.h:2039
HookList< EffectPeriodicHandler > OnEffectPeriodic
Definition: SpellScript.h:2045
Unit * GetCaster() const
Unit * GetTarget() const
ObjectGuid GetCasterGUID() const
void JustEngagedWith(Unit *who) override
EventMap events
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
void SetCorpseDelay(uint32 delay, bool ignoreCorpseDecayRatio=false)
Definition: Creature.h:104
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void Repeat(Milliseconds time)
Definition: EventMap.cpp:63
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
bool Is25ManRaid() const
Definition: Map.cpp:3320
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
uint32 TriggerSpell
Definition: SpellInfo.h:237
uint32 const Id
Definition: SpellInfo.h:325
SpellEffectInfo const & GetEffect(SpellEffIndex index) const
Definition: SpellInfo.h:577
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:162
static bool ValidateSpellEffect(std::initializer_list< std::pair< uint32, SpellEffIndex > > effects)
Definition: SpellScript.h:173
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 DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:161
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
float GetHealthPct() const
Definition: Unit.h:784
Map * GetMap() const
Definition: Object.h:624
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
void HandleRemove(AuraEffect const *aurEff, AuraEffectHandleModes)
bool Validate(SpellInfo const *) override
bool Validate(SpellInfo const *spellInfo) override
void PeriodicTick(AuraEffect const *aurEff)
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
@ BOSS_GROBBULUS
Definition: naxxramas.h:37
#define RegisterNaxxramasCreatureAI(ai_name)
Definition: naxxramas.h:221
CastSpellExtraArgs & AddSpellMod(SpellValueMod mod, int32 val)
Definition: SpellDefines.h:474
void AddThreat(Unit *victim, float amount, Unit *who=nullptr)
void JustEngagedWith(Unit *who) override
void UpdateAI(uint32 diff) override
void SpellHitTarget(WorldObject *target, SpellInfo const *spellInfo) override
boss_grobbulus(Creature *creature)
void EnterEvadeMode(EvadeReason) override
ObjectGuid _summonerGUID
void IsSummonedBy(WorldObject *summoner) override
void UpdateAI(uint32 diff) override
TaskScheduler _scheduler
void InitializeAI() override
npc_fallout_slime(Creature *creature)
npc_grobbulus_poison_cloud(Creature *creature)