TrinityCore
Loading...
Searching...
No Matches
boss_nalorakk.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 * Creatures in waves should load waypoints, not engage immediately
20 * Combat timers requires to be revisited
21 * SAY_EVENT is NYI
22 */
23
24#include "ScriptMgr.h"
25#include "Containers.h"
26#include "Map.h"
27#include "MotionMaster.h"
28#include "ScriptedCreature.h"
29#include "SpellAuraEffects.h"
30#include "SpellInfo.h"
31#include "SpellScript.h"
32#include "zulaman.h"
33
51
53{
54 // Troll form
56 SPELL_MANGLE = 42389,
57 SPELL_SURGE = 44019,
58
59 // Bear form
63
64 // Shared
67
68 // Scripts
70 SPELL_SURGE_HASTE = 44960
71};
72
95
101
109
116
117static constexpr std::array<uint8, 4> WaveTexts =
118{
123};
124
125static constexpr std::array<std::string_view, 4> NalorakkWave =
126{
127 "NalorakkWave1",
128 "NalorakkWave2",
129 "NalorakkWave3",
130 "NalorakkWave4"
131};
132
133// 23576 - Nalorakk
134struct boss_nalorakk : public BossAI
135{
138
139 void Reset() override
140 {
141 _Reset();
142 SetEquipmentSlots(true);
143
145 {
146 me->SetImmuneToAll(true);
148 }
149 }
150
163
164 void OnSpellCast(SpellInfo const* spellInfo) override
165 {
166 switch (spellInfo->Id)
167 {
168 case SPELL_SURGE:
170 break;
171 case SPELL_BERSERK:
173 break;
174 default:
175 break;
176 }
177 }
178
179 void HandleWave(Unit* who)
180 {
182
183 std::vector<Creature*> waveCreatures;
184 GetCreatureListWithOptionsInGrid(waveCreatures, me, 50.0f, { .StringId = NalorakkWave[_currentWaveCount] });
185 for (Creature* waveCreature : waveCreatures)
186 {
187 waveCreature->SetImmuneToAll(false);
188 waveCreature->AI()->AttackStart(who);
189 }
190
192 _isWaiting = true;
193 }
194
196 void MoveInLineOfSight(Unit* who) override
197 {
199 {
201 return;
202 }
203
204 if (!me->IsHostileTo(who))
205 return;
206
208 return;
209
210 if (_isWaiting)
211 return;
212
213 switch (_currentWaveCount)
214 {
215 case 0:
216 if (me->IsWithinDistInMap(who, 50))
217 HandleWave(who);
218 break;
219 case 1:
220 if (me->IsWithinDistInMap(who, 40))
221 HandleWave(who);
222 break;
223 case 2:
224 if (me->IsWithinDistInMap(who, 40))
225 HandleWave(who);
226 break;
227 case 3:
228 if (me->IsWithinDistInMap(who, 60))
229 HandleWave(who);
230 break;
231 default:
232 break;
233 }
234 }
235
236 void DoAction(int32 action) override
237 {
238 switch (action)
239 {
250 break;
253 SetEquipmentSlots(true);
260 break;
263 _isMovingToLocation = true;
264 _isWaiting = false;
267 break;
270 _isMovingToLocation = true;
271 _isWaiting = false;
274 break;
277 _isMovingToLocation = true;
278 _isWaiting = false;
281 break;
284 break;
285 default:
286 break;
287 }
288 }
289
290 void WaypointPathEnded(uint32 /*nodeId*/, uint32 /*pathId*/) override
291 {
292 _isMovingToLocation = false;
293 }
294
295 void KilledUnit(Unit* /*victim*/) override
296 {
297 Talk(SAY_SLAY);
298 }
299
300 void JustDied(Unit* /*killer*/) override
301 {
302 _JustDied();
304 }
305
307 {
308 events.Update(diff);
309
310 while (uint32 eventId = events.ExecuteEvent())
311 {
312 switch (eventId)
313 {
316 break;
319 break;
322 break;
324 me->SetImmuneToAll(false);
325 _waveEventInProgress = false;
326 break;
327 default:
328 break;
329 }
330 }
331 }
332
333 void UpdateAI(uint32 diff) override
334 {
335 if (!UpdateVictim())
336 {
338 return;
339 }
340
341 events.Update(diff);
342
344 return;
345
346 while (uint32 eventId = events.ExecuteEvent())
347 {
348 switch (eventId)
349 {
352 events.Repeat(10s, 20s);
353 break;
354 case EVENT_MANGLE:
356 events.Repeat(20s, 30s);
357 break;
358 case EVENT_SURGE:
360 events.Repeat(15s, 20s);
361 break;
362
365 events.Repeat(20s, 30s);
366 break;
367 case EVENT_REND_FLESH:
369 events.Repeat(10s, 15s);
370 break;
373 events.Repeat(10s, 15s);
374 break;
375
376 case EVENT_SHAPESHIFT:
378 events.Repeat(75s);
379 break;
380
381 case EVENT_BERSERK:
383 break;
384 default:
385 break;
386 }
387
389 return;
390 }
391
393 }
394
395private:
400};
401
402// 44019 - Surge
404{
406
407 bool Validate(SpellInfo const* /*spellInfo*/) override
408 {
410 }
411
412 void FilterTargets(std::list<WorldObject*>& targets)
413 {
415 }
416
417 void HandleDummy(SpellEffIndex /*effIndex*/)
418 {
419 Unit* caster = GetCaster();
420 Unit* target = GetHitUnit();
421
422 caster->CastSpell(target, SPELL_SURGE_CHARGE, true);
423 caster->CastSpell(caster, SPELL_SURGE_HASTE, true);
424 }
425
431};
432
433// 42377 - Shape of the Bear
435{
437
438 void AfterApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
439 {
440 if (Creature* target = GetTarget()->ToCreature())
441 target->AI()->DoAction(ACTION_SHAPE_APPLIED);
442 }
443
444 void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
445 {
446 if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE)
447 return;
448
449 if (Creature* target = GetTarget()->ToCreature())
450 target->AI()->DoAction(ACTION_SHAPE_REMOVED);
451 }
452
458};
459
@ EQUIP_UNEQUIP
Definition CreatureAI.h:76
@ EQUIP_NO_CHANGE
Definition CreatureAI.h:75
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
void GetCreatureListWithOptionsInGrid(Container &container, WorldObject *source, float maxSearchRange, FindCreatureOptions const &options)
SpellEffIndex
@ EFFECT_0
@ SPELL_EFFECT_DUMMY
@ TARGET_UNIT_SRC_AREA_ENEMY
@ AURA_REMOVE_BY_EXPIRE
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_TRANSFORM
#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
NalorakkTexts
@ SAY_DEATH
@ SAY_SURGE
@ SAY_TO_TROLL
@ SAY_AGGRO
@ SAY_WAVE_1
@ SAY_WAVE_3
@ SAY_TO_BEAR
@ SAY_WAVE_4
@ SAY_SLAY
@ SAY_WAVE_DONE
@ SAY_BERSERK
@ EMOTE_TRANSFORM
@ SAY_WAVE_2
@ SAY_EVENT
NalorakkSpawnGroups
@ SPAWN_GROUP_NALORAKK_WAVE_1
@ SPAWN_GROUP_NALORAKK_WAVE_3
@ SPAWN_GROUP_NALORAKK_WAVE_2
@ SPAWN_GROUP_NALORAKK_WAVE_4
NalorakkPaths
@ PATH_WAVE_DONE_3
@ PATH_WAVE_DONE_2
@ PATH_WAVE_DONE_1
static constexpr std::array< uint8, 4 > WaveTexts
NalorakkSpells
@ SPELL_BRUTAL_SWIPE
@ SPELL_MANGLE
@ SPELL_SURGE_CHARGE
@ SPELL_LACERATING_SLASH
@ SPELL_SHAPE_OF_THE_BEAR
@ SPELL_REND_FLESH
@ SPELL_SURGE_HASTE
@ SPELL_BERSERK
@ SPELL_SURGE
@ SPELL_DEAFENING_ROAR
NalorakkEvents
@ EVENT_WAVE_DONE_1
@ EVENT_WAVE_DONE_4
@ EVENT_BRUTAL_SWIPE
@ EVENT_SHAPESHIFT
@ EVENT_WAVE_DONE_2
@ EVENT_BERSERK
@ EVENT_LACERATING_SLASH
@ EVENT_REND_FLESH
@ EVENT_SURGE
@ EVENT_WAVE_DONE_3
@ EVENT_MANGLE
@ EVENT_DEAFENING_ROAR
NalorakkActions
@ ACTION_SHAPE_REMOVED
@ ACTION_SHAPE_APPLIED
void AddSC_boss_nalorakk()
static constexpr std::array< std::string_view, 4 > NalorakkWave
AuraApplication const * GetTargetApplication() const
HookList< EffectApplyHandler > AfterEffectRemove
HookList< EffectApplyHandler > AfterEffectApply
Unit * GetTarget() const
void JustEngagedWith(Unit *who) override
EventMap events
virtual void MoveInLineOfSight(Unit *)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void SetImmuneToAll(bool apply) override
Definition Creature.h:135
void Update(uint32 time)
Definition EventMap.h:67
void Repeat(Milliseconds time)
Definition EventMap.cpp:63
EventId ExecuteEvent()
Definition EventMap.cpp:73
void CancelEvent(EventId eventId)
Definition EventMap.cpp:151
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
bool SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn=false, bool force=false, std::vector< WorldObject * > *spawnedObjects=nullptr)
Definition Map.cpp:3382
void MovePath(uint32 pathId, bool repeatable)
uint32 Id
Definition SpellInfo.h:289
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:241
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:166
Definition Unit.h:783
MotionMaster * GetMotionMaster()
Definition Unit.h:1683
bool HasUnitState(const uint32 f) const
Definition Unit.h:890
Map * GetMap() const
Definition Object.h:451
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2833
bool IsHostileTo(WorldObject const *target) const
Definition Object.cpp:2797
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition Object.cpp:1193
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
void AfterApply(AuraEffect const *, AuraEffectHandleModes)
PrepareAuraScript(spell_nalorakk_shape)
void Register() override
void AfterRemove(AuraEffect const *, AuraEffectHandleModes)
void Register() override
void HandleDummy(SpellEffIndex)
PrepareSpellScript(spell_nalorakk_surge)
bool Validate(SpellInfo const *) override
void FilterTargets(std::list< WorldObject * > &targets)
void RandomResize(C &container, std::size_t requestedSize)
Definition Containers.h:66
void SetEquipmentSlots(bool loadDefault, int32 mainHand=EQUIP_NO_CHANGE, int32 offHand=EQUIP_NO_CHANGE, int32 ranged=EQUIP_NO_CHANGE)
void JustDied(Unit *) override
void JustEngagedWith(Unit *who) override
void HandleWave(Unit *who)
void MoveInLineOfSight(Unit *who) override
void DoAction(int32 action) override
void UpdateAI(uint32 diff) override
boss_nalorakk(Creature *creature)
void OnSpellCast(SpellInfo const *spellInfo) override
void Reset() override
void UpdateOutOfCombatEvents(uint32 diff)
void KilledUnit(Unit *) override
void WaypointPathEnded(uint32, uint32) override
@ BOSS_NALORAKK
Definition zulaman.h:28
#define RegisterZulAmanCreatureAI(ai_name)
Definition zulaman.h:94
@ ACTION_WAVE_DONE_2
Definition zulaman.h:83
@ ACTION_WAVE_DONE_4
Definition zulaman.h:85
@ ACTION_WAVE_DONE_1
Definition zulaman.h:82
@ ACTION_WAVE_DONE_3
Definition zulaman.h:84