TrinityCore
boss_gruul.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/*
19TO-DO:
20Slighly(400ms) after spell cast 33965 creatures 19198 are spawned. I guess he forces all enemies including pets(9 summoned units
21and 9 units in his threatlist) to cast 39186(19198 were created by that spell(sniff)). Summoned by that spell creature 19198 casts 33496
22on self after being summoned. Then probably they casts 33497(Pull Towards: (150)) on their creators and that's how that knockback is handled.
23If you look closely, players are knocked to random destinations with random angles, means there is no only one spell which handles knockback.
2419198 despawns after 800ms after being summoned.
25*/
26
27#include "ScriptMgr.h"
28#include "gruuls_lair.h"
29#include "MotionMaster.h"
30#include "ScriptedCreature.h"
31#include "SpellInfo.h"
32#include "SpellScript.h"
33
35{
41
42 EMOTE_GROW = 5
43};
44
46{
47 SPELL_GROWTH = 36300,
49 SPELL_GROUND_SLAM = 33525, // AoE Ground Slam applying Ground Slam to everyone with a script effect (most likely the knock back, we can code it to a set knockback)
52
55 SPELL_STONED = 33652, // Spell is self cast by target
56
58 SPELL_KNOCK_BACK = 24199, // Knockback spell until correct implementation is made
59};
60
62{
69};
70
72{
73 public:
74 boss_gruul() : CreatureScript("boss_gruul") { }
75
76 struct boss_gruulAI : public BossAI
77 {
78 boss_gruulAI(Creature* creature) : BossAI(creature, DATA_GRUUL)
79 {
80 Initialize();
81 }
82
84 {
85 m_uiGrowth_Timer = 30000;
86 m_uiCaveIn_Timer = 27000;
88 m_uiGroundSlamTimer = 35000;
91 m_uiReverberation_Timer = 60000 + 45000;
92 }
93
100
102
103 void Reset() override
104 {
105 _Reset();
106 Initialize();
107 }
108
109 void JustEngagedWith(Unit* who) override
110 {
113 }
114
115 void KilledUnit(Unit* who) override
116 {
117 if (who->GetTypeId() == TYPEID_PLAYER)
118 Talk(SAY_SLAY);
119 }
120
121 void JustDied(Unit* /*killer*/) override
122 {
123 _JustDied();
125 }
126
127 void SpellHitTarget(WorldObject* target, SpellInfo const* spellInfo) override
128 {
129 //This to emulate effect1 (77) of SPELL_GROUND_SLAM, knock back to any direction
130 //It's initially wrong, since this will cause fall damage, which is by comments, not intended.
131 if (spellInfo->Id == SPELL_GROUND_SLAM)
132 {
133 if (target->GetTypeId() == TYPEID_PLAYER)
134 {
135 switch (urand(0, 1))
136 {
137 case 0:
139 .SetOriginalCaster(me->GetGUID()));
140 break;
141
142 case 1:
144 .SetOriginalCaster(me->GetGUID()));
145 break;
146 }
147 }
148 }
149
150 //this part should be in the core
151 if (spellInfo->Id == SPELL_SHATTER)
152 {
154 //clear this, if we are still performing
156 {
158
159 //and correct movement, if not already
161 {
162 if (me->GetVictim())
164 }
165 }
166 }
167 }
168
169 void UpdateAI(uint32 diff) override
170 {
171 if (!UpdateVictim())
172 return;
173
174 events.Update(diff);
175
177 return;
178
180
181 // Growth
182 // Gruul can cast this spell up to 30 times
183 if (m_uiGrowth_Timer <= diff)
184 {
187 m_uiGrowth_Timer = 30000;
188 }
189 else
190 m_uiGrowth_Timer -= diff;
191
193 {
194 if (m_uiGroundSlamTimer <= diff)
195 {
196 m_uiGroundSlamTimer =120000;
198
199 if (m_uiReverberation_Timer < 10000) //Give a little time to the players to undo the damage from shatter
201
203 }
204 else
205 m_uiGroundSlamTimer -= diff;
206 }
207 else
208 {
209 // Hurtful Strike
210 if (m_uiHurtfulStrike_Timer <= diff)
211 {
213
214 if (target && me->IsWithinMeleeRange(me->GetVictim()))
216 else
218
220 }
221 else
223
224 // Reverberation
225 if (m_uiReverberation_Timer <= diff)
226 {
228 m_uiReverberation_Timer = urand(15000, 25000);
229 }
230 else
232
233 // Cave In
234 if (m_uiCaveIn_Timer <= diff)
235 {
237 DoCast(target, SPELL_CAVE_IN);
238
239 if (m_uiCaveIn_StaticTimer >= 4000)
241
243 }
244 else
245 m_uiCaveIn_Timer -= diff;
246
247 // Ground Slam, Gronn Lord's Grasp, Stoned, Shatter
248 if (m_uiGroundSlamTimer <= diff)
249 {
252
254 m_uiGroundSlamTimer = 10000;
255
257 }
258 else
259 m_uiGroundSlamTimer -= diff;
260 }
261 }
262 };
263
264 CreatureAI* GetAI(Creature* creature) const override
265 {
266 return GetGruulsLairAI<boss_gruulAI>(creature);
267 }
268};
269
271{
272 public:
273 spell_gruul_shatter() : SpellScriptLoader("spell_gruul_shatter") { }
274
276 {
277 bool Validate(SpellInfo const* /*spell*/) override
278 {
280 }
281
282 void HandleScript(SpellEffIndex /*effIndex*/)
283 {
284 if (Unit* target = GetHitUnit())
285 {
286 target->RemoveAurasDueToSpell(SPELL_STONED);
287 target->CastSpell(nullptr, SPELL_SHATTER_EFFECT, true);
288 }
289 }
290
291 void Register() override
292 {
294 }
295 };
296
297 SpellScript* GetSpellScript() const override
298 {
300 }
301};
302
304{
305 public:
306 spell_gruul_shatter_effect() : SpellScriptLoader("spell_gruul_shatter_effect") { }
307
309 {
310 bool Validate(SpellInfo const* spellInfo) override
311 {
312 return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } });
313 }
314
316 {
317 if (!GetHitUnit())
318 return;
319
321 if (!radius)
322 return;
323
324 float distance = GetCaster()->GetDistance2d(GetHitUnit());
325 if (distance > 1.0f)
326 SetHitDamage(int32(GetHitDamage() * ((radius - distance) / radius)));
327 }
328
329 void Register() override
330 {
332 }
333 };
334
335 SpellScript* GetSpellScript() const override
336 {
338 }
339};
340
342{
343 new boss_gruul();
346}
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
@ CHASE_MOTION_TYPE
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
Spells
Definition: PlayerAI.cpp:32
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:42
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_0
Definition: SharedDefines.h:30
@ SPELL_EFFECT_SCRIPT_EFFECT
@ TRIGGERED_FULL_MASK
Used when doing CastSpell with triggered == true.
Definition: SpellDefines.h:266
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
#define SpellHitFn(F)
Definition: SpellScript.h:854
@ UNIT_STATE_CASTING
Definition: Unit.h:270
@ SAY_DEATH
Definition: boss_gruul.cpp:40
@ EMOTE_GROW
Definition: boss_gruul.cpp:42
@ SAY_AGGRO
Definition: boss_gruul.cpp:36
@ SAY_SLAM
Definition: boss_gruul.cpp:37
@ SAY_SLAY
Definition: boss_gruul.cpp:39
@ SAY_SHATTER
Definition: boss_gruul.cpp:38
void AddSC_boss_gruul()
Definition: boss_gruul.cpp:341
@ SPELL_REVERBERATION
Definition: boss_gruul.cpp:50
@ SPELL_SHATTER_EFFECT
Definition: boss_gruul.cpp:53
@ SPELL_KNOCK_BACK
Definition: boss_gruul.cpp:58
@ SPELL_MAGNETIC_PULL
Definition: boss_gruul.cpp:57
@ SPELL_CAVE_IN
Definition: boss_gruul.cpp:48
@ SPELL_GROUND_SLAM
Definition: boss_gruul.cpp:49
@ SPELL_GROWTH
Definition: boss_gruul.cpp:47
@ SPELL_SHATTER
Definition: boss_gruul.cpp:51
@ SPELL_HURTFUL_STRIKE
Definition: boss_gruul.cpp:54
@ SPELL_STONED
Definition: boss_gruul.cpp:55
@ EVENT_REVERBERATION
Definition: boss_gruul.cpp:68
@ EVENT_GROWTH
Definition: boss_gruul.cpp:63
@ EVENT_GROUND_SLAM
Definition: boss_gruul.cpp:66
@ EVENT_CAVE_IN_STATIC
Definition: boss_gruul.cpp:65
@ EVENT_HURTFUL_STRIKE
Definition: boss_gruul.cpp:67
@ EVENT_CAVE_IN
Definition: boss_gruul.cpp:64
Yells
void JustEngagedWith(Unit *who) override
EventMap events
void _JustDied()
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 Update(uint32 time)
Definition: EventMap.h:56
MovementGeneratorType GetCurrentMovementGeneratorType() const
void MoveChase(Unit *target, Optional< ChaseRange > dist={}, Optional< ChaseAngle > angle={})
TypeID GetTypeId() const
Definition: Object.h:173
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
float CalcRadius(WorldObject *caster=nullptr, SpellTargetIndex targetIndex=SpellTargetIndex::TargetA, Spell *=nullptr) const
Definition: SpellInfo.cpp:673
uint32 const Id
Definition: SpellInfo.h:325
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
int32 GetHitDamage() const
Unit * GetCaster() const
HookList< HitHandler > OnHit
Definition: SpellScript.h:850
Unit * GetHitUnit() const
SpellEffectInfo const & GetEffectInfo() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
void SetHitDamage(int32 damage)
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.cpp:180
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
bool IsWithinMeleeRange(Unit const *obj) const
Definition: Unit.h:699
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
Unit * GetVictim() const
Definition: Unit.h:715
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
float GetDistance2d(WorldObject const *obj) const
Definition: Object.cpp:1096
CreatureAI * GetAI(Creature *creature) const override
Definition: boss_gruul.cpp:264
SpellScript * GetSpellScript() const override
Definition: boss_gruul.cpp:335
SpellScript * GetSpellScript() const override
Definition: boss_gruul.cpp:297
@ DATA_GRUUL
Definition: gruuls_lair.h:32
void SpellHitTarget(WorldObject *target, SpellInfo const *spellInfo) override
Definition: boss_gruul.cpp:127
void KilledUnit(Unit *who) override
Definition: boss_gruul.cpp:115
void JustEngagedWith(Unit *who) override
Definition: boss_gruul.cpp:109
void UpdateAI(uint32 diff) override
Definition: boss_gruul.cpp:169
void JustDied(Unit *) override
Definition: boss_gruul.cpp:121
void Reset() override
Definition: boss_gruul.cpp:103
boss_gruulAI(Creature *creature)
Definition: boss_gruul.cpp:78