TrinityCore
Loading...
Searching...
No Matches
boss_warbringer_omrogg.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/* Timers requires to be revisited */
19
20#include "ScriptMgr.h"
21#include "Containers.h"
22#include "InstanceScript.h"
23#include "ScriptedCreature.h"
24#include "SpellInfo.h"
25#include "SpellMgr.h"
26#include "SpellScript.h"
27#include "shattered_halls.h"
28
66
68{
69 SPELL_FEAR = 30584,
72 SPELL_BURNING_MAUL = 30598, // Triggers 30620, what it does? (no, it doesn't trigger 30600)
73
74 SPELL_BLAST_WAVE = 30600
75};
76
84
98
103
104// 16809 - Warbringer O'mrogg
106{
108
109 void JustEngagedWith(Unit* who) override
110 {
112
117
119 leftHead->AI()->DoAction(RAND(ACTION_AGGRO_1, ACTION_AGGRO_2, ACTION_AGGRO_3));
120 }
121
122 void OnSpellCast(SpellInfo const* spellInfo) override
123 {
124 // Apparently this and all other are handled by GameEvents since this spell sends GameEvent
125 if (spellInfo->Id == SPELL_BEATDOWN)
128
129 if (spellInfo->Id == sSpellMgr->GetSpellIdForDifficulty(SPELL_BURNING_MAUL, me))
131 }
132
133 void KilledUnit(Unit* /*victim*/) override
134 {
136 leftHead->AI()->DoAction(RAND(ACTION_SLAY_1, ACTION_SLAY_2));
137 }
138
139 void JustDied(Unit* /*killer*/) override
140 {
141 _JustDied();
142
144 leftHead->AI()->DoAction(ACTION_DEATH);
145 }
146
147 void UpdateAI(uint32 diff) override
148 {
149 if (!UpdateVictim())
150 return;
151
152 events.Update(diff);
153
155 return;
156
157 while (uint32 eventId = events.ExecuteEvent())
158 {
159 switch (eventId)
160 {
161 case EVENT_FEAR:
163 events.Repeat(15s, 35s);
164 break;
167 events.Repeat(15s, 30s);
168 break;
169 case EVENT_BEATDOWN:
171 events.Repeat(25s, 40s);
172 break;
175 events.Repeat(60s, 70s);
176 break;
177 default:
178 break;
179 }
180
182 return;
183 }
184
186 }
187};
188
189// 19523 - O'mrogg's Left Head
190// 19524 - O'mrogg's Right Head
192{
193 npc_omrogg_heads(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) { }
194
196 {
198 rightHead->AI()->Talk(text);
199 }
200
201 void DoAction(int32 action) override
202 {
203 switch (action)
204 {
205 case ACTION_AGGRO_1:
206 _scheduler.Schedule(0s, [this](TaskContext task)
207 {
208 switch (task.GetRepeatCounter())
209 {
210 case 0:
211 Talk(SAY_AGGRO_1);
212 task.Repeat(3s);
213 break;
214 case 1:
215 RightHeadTalk(SAY_AGGRO_1_1);
216 task.Repeat(3s);
217 break;
218 case 2:
219 Talk(SAY_AGGRO_1_2);
220 break;
221 default:
222 break;
223 }
224 });
225 break;
226 case ACTION_AGGRO_2:
227 _scheduler.Schedule(0s, [this](TaskContext task)
228 {
229 switch (task.GetRepeatCounter())
230 {
231 case 0:
232 Talk(SAY_AGGRO_2);
233 task.Repeat(3s);
234 break;
235 case 1:
236 RightHeadTalk(SAY_AGGRO_2_1);
237 break;
238 default:
239 break;
240 }
241 });
242 break;
243 case ACTION_AGGRO_3:
244 _scheduler.Schedule(0s, [this](TaskContext task)
245 {
246 switch (task.GetRepeatCounter())
247 {
248 case 0:
249 Talk(SAY_AGGRO_3);
250 task.Repeat(3s);
251 break;
252 case 1:
253 RightHeadTalk(SAY_AGGRO_3_1);
254 break;
255 default:
256 break;
257 }
258 });
259 break;
260 case ACTION_ATTACK_1:
261 _scheduler.Schedule(0s, [this](TaskContext task)
262 {
263 switch (task.GetRepeatCounter())
264 {
265 case 0:
266 Talk(SAY_ATTACK_1);
267 task.Repeat(3s);
268 break;
269 case 1:
270 RightHeadTalk(SAY_ATTACK_1_1);
271 task.Repeat(3s);
272 break;
273 case 2:
274 Talk(SAY_ATTACK_1_2);
275 break;
276 default:
277 break;
278 }
279 });
280 break;
281 case ACTION_ATTACK_2:
282 _scheduler.Schedule(0s, [this](TaskContext task)
283 {
284 switch (task.GetRepeatCounter())
285 {
286 case 0:
287 Talk(SAY_ATTACK_2);
288 task.Repeat(3s);
289 break;
290 case 1:
291 RightHeadTalk(SAY_ATTACK_2_1);
292 break;
293 default:
294 break;
295 }
296 });
297 break;
298 case ACTION_ATTACK_3:
299 _scheduler.Schedule(0s, [this](TaskContext task)
300 {
301 switch (task.GetRepeatCounter())
302 {
303 case 0:
304 Talk(SAY_ATTACK_3);
305 task.Repeat(3s);
306 break;
307 case 1:
308 RightHeadTalk(SAY_ATTACK_3_1);
309 task.Repeat(3s);
310 break;
311 case 2:
312 Talk(SAY_ATTACK_3_2);
313 break;
314 default:
315 break;
316 }
317 });
318 break;
319 case ACTION_ATTACK_4:
320 _scheduler.Schedule(0s, [this](TaskContext task)
321 {
322 switch (task.GetRepeatCounter())
323 {
324 case 0:
325 RightHeadTalk(SAY_ATTACK_4);
326 task.Repeat(2s);
327 break;
328 case 1:
329 Talk(SAY_ATTACK_4_1);
330 task.Repeat(2s);
331 break;
332 case 2:
333 RightHeadTalk(SAY_ATTACK_4_2);
334 break;
335 default:
336 break;
337 }
338 });
339 break;
340 case ACTION_SLAY_1:
341 _scheduler.Schedule(0s, [this](TaskContext /*task*/)
342 {
344 });
345 break;
346 case ACTION_SLAY_2:
347 _scheduler.Schedule(0s, [this](TaskContext task)
348 {
349 switch (task.GetRepeatCounter())
350 {
351 case 0:
353 task.Repeat(3s);
354 break;
355 case 1:
357 break;
358 default:
359 break;
360 }
361 });
362 break;
363 case ACTION_DEATH:
364 _scheduler.Schedule(0s, [this](TaskContext task)
365 {
366 switch (task.GetRepeatCounter())
367 {
368 case 0:
370 task.Repeat(3s);
371 break;
372 case 1:
376 rightHead->DespawnOrUnsummon(4s);
377 break;
378 default:
379 break;
380 }
381 });
382 break;
383 default:
384 break;
385 }
386 }
387
388 void UpdateAI(uint32 diff) override
389 {
390 _scheduler.Update(diff);
391 }
392
393private:
396};
397
398// 30598, 36056 - Burning Maul
400{
402
403 bool Validate(SpellInfo const* /*spellInfo*/) override
404 {
406 }
407
408 void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
409 {
410 if (Creature* creature = GetTarget()->ToCreature())
411 creature->LoadEquipment(EQUIP_ID_BURNING_MAUL);
412 }
413
414 void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
415 {
416 if (Creature* creature = GetTarget()->ToCreature())
417 creature->LoadEquipment(creature->GetOriginalEquipmentId());
418 }
419
420 void OnProc(AuraEffect const* /*aurEff*/, ProcEventInfo& /*eventInfo*/)
421 {
424 if (roll_chance_i(30))
426 }
427
434};
435
436// 30618 - Beatdown
438{
440
441 bool Load() override
442 {
443 return GetCaster()->IsCreature();
444 }
445
446 void FilterTargets(std::list<WorldObject*>& targets)
447 {
448 if (targets.empty())
449 return;
450
452
453 _selectedTargetGuid = target->GetGUID();
454 }
455
456 void HandleDummy(SpellEffIndex /*effIndex*/)
457 {
458 Unit* target = GetHitUnit();
459 if (target->GetGUID() != _selectedTargetGuid)
460 return;
461
462 Unit* caster = GetCaster();
464 caster->GetAI()->AttackStart(target);
465 }
466
472
473private:
475};
476
First const & RAND(First const &first, Second const &second, Rest const &... rest)
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
bool roll_chance_i(int chance)
Definition Random.h:59
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
SpellEffIndex
@ EFFECT_0
@ SPELL_EFFECT_DUMMY
@ TARGET_UNIT_SRC_AREA_ENEMY
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_PROC_TRIGGER_SPELL
#define sSpellMgr
Definition SpellMgr.h:738
#define AuraEffectProcFn(F, I, N)
#define SpellEffectFn(F, I, N)
#define SpellObjectAreaTargetSelectFn(F, I, N)
#define AuraEffectApplyFn(F, I, N, M)
#define AuraEffectRemoveFn(F, I, N, M)
@ UNIT_STATE_CASTING
Definition Unit.h:249
@ EQUIP_ID_BURNING_MAUL
void AddSC_boss_warbringer_omrogg()
Unit * GetTarget() const
HookList< EffectApplyHandler > OnEffectRemove
HookList< EffectProcHandler > OnEffectProc
HookList< AuraProcHandler > OnProc
HookList< EffectApplyHandler > OnEffectApply
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
EventMap events
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
void Update(uint32 time)
Definition EventMap.h:67
void Repeat(Milliseconds time)
Definition EventMap.cpp:63
EventId ExecuteEvent()
Definition EventMap.cpp:73
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
Creature * GetCreature(uint32 type)
bool IsCreature() const
Definition Object.h:188
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
uint32 Id
Definition SpellInfo.h:289
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
TaskContext & Repeat(std::chrono::duration< _Rep, _Period > const &duration)
TaskScheduler::repeated_t GetRepeatCounter() const
Returns the repeat counter which increases every time the task is repeated.
TaskScheduler & Schedule(std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task)
TaskScheduler & Update(success_t const &callback=EmptyCallback)
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:241
virtual void AttackStart(Unit *)
Definition UnitAI.cpp:30
Definition Unit.h:783
ThreatManager & GetThreatManager()
Definition Unit.h:1169
UnitAI * GetAI() const
Definition Unit.h:814
bool HasUnitState(const uint32 f) const
Definition Unit.h:890
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2833
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
PrepareSpellScript(spell_omrogg_beatdown)
void FilterTargets(std::list< WorldObject * > &targets)
bool Validate(SpellInfo const *) override
void OnRemove(AuraEffect const *, AuraEffectHandleModes)
void OnApply(AuraEffect const *, AuraEffectHandleModes)
void OnProc(AuraEffect const *, ProcEventInfo &)
PrepareAuraScript(spell_omrogg_burning_maul)
auto SelectRandomContainerElement(C const &container) -> typename std::add_const< decltype(*std::begin(container))>::type &
Definition Containers.h:108
@ DATA_OMROGG
@ DATA_RIGHT_HEAD
@ DATA_LEFT_HEAD
#define RegisterShatteredHallsCreatureAI(ai_name)
boss_warbringer_omrogg(Creature *creature)
void OnSpellCast(SpellInfo const *spellInfo) override
void UpdateAI(uint32 diff) override
void KilledUnit(Unit *) override
void JustEngagedWith(Unit *who) override
void RightHeadTalk(uint32 text)
void UpdateAI(uint32 diff) override
void DoAction(int32 action) override
npc_omrogg_heads(Creature *creature)