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 * Surge implementation requires additional research
21 * Combat timers requires to be revisited
22 */
23
24#include "ScriptMgr.h"
25#include "Containers.h"
26#include "Map.h"
27#include "MotionMaster.h"
28#include "ScriptedCreature.h"
29#include "SpellInfo.h"
30#include "SpellScript.h"
31#include "zulaman.h"
32
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
103
110
111static constexpr std::array<uint8, 4> WaveTexts =
112{
117};
118
119static constexpr std::array<std::string_view, 4> NalorakkWave =
120{
121 "NalorakkWave1",
122 "NalorakkWave2",
123 "NalorakkWave3",
124 "NalorakkWave4"
125};
126
127// 23576 - Nalorakk
128struct boss_nalorakk : public BossAI
129{
132
133 void Reset() override
134 {
135 _Reset();
136 SetEquipmentSlots(true);
137 _isInBearForm = false;
138
140 {
141 me->SetImmuneToAll(true);
143 }
144 }
145
158
159 void OnSpellCast(SpellInfo const* spellInfo) override
160 {
161 switch (spellInfo->Id)
162 {
167 break;
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 {
242 _isMovingToLocation = true;
243 _isWaiting = false;
246 break;
249 _isMovingToLocation = true;
250 _isWaiting = false;
253 break;
256 _isMovingToLocation = true;
257 _isWaiting = false;
260 break;
263 break;
264 default:
265 break;
266 }
267 }
268
269 void WaypointPathEnded(uint32 /*nodeId*/, uint32 /*pathId*/) override
270 {
271 _isMovingToLocation = false;
272 }
273
274 void KilledUnit(Unit* /*victim*/) override
275 {
276 Talk(SAY_SLAY);
277 }
278
279 void JustDied(Unit* /*killer*/) override
280 {
281 _JustDied();
283 }
284
286 {
287 events.Update(diff);
288
289 while (uint32 eventId = events.ExecuteEvent())
290 {
291 switch (eventId)
292 {
295 break;
298 break;
301 break;
303 me->SetImmuneToAll(false);
304 _waveEventInProgress = false;
305 break;
306 default:
307 break;
308 }
309 }
310 }
311
312 void UpdateAI(uint32 diff) override
313 {
314 if (!UpdateVictim())
315 {
317 return;
318 }
319
320 events.Update(diff);
321
323 return;
324
325 while (uint32 eventId = events.ExecuteEvent())
326 {
327 switch (eventId)
328 {
331 events.Repeat(10s, 20s);
332 break;
333 case EVENT_MANGLE:
335 events.Repeat(20s, 30s);
336 break;
337 case EVENT_SURGE:
339 events.Repeat(15s, 20s);
340 break;
341
344 events.Repeat(20s, 30s);
345 break;
346 case EVENT_REND_FLESH:
348 events.Repeat(10s, 15s);
349 break;
352 events.Repeat(10s, 15s);
353 break;
354
355 case EVENT_SHAPESHIFT:
356 {
357 if (_isInBearForm)
358 {
360 SetEquipmentSlots(true);
367 events.Repeat(45s);
368 _isInBearForm = false;
369 }
370 else
371 {
379 events.Repeat(30s);
380 _isInBearForm = true;
381 }
382 break;
383 }
384
385 case EVENT_BERSERK:
387 break;
388 default:
389 break;
390 }
391
393 return;
394 }
395
397 }
398
399private:
405};
406
407// 44019 - Surge
409{
411
412 bool Validate(SpellInfo const* /*spellInfo*/) override
413 {
415 }
416
417 void FilterTargets(std::list<WorldObject*>& targets)
418 {
419 if (targets.empty())
420 return;
421
423 targets.clear();
424 targets.push_back(target);
425 }
426
427 void HandleDummy(SpellEffIndex /*effIndex*/)
428 {
429 Unit* caster = GetCaster();
430 Unit* target = GetHitUnit();
431
432 caster->CastSpell(target, SPELL_SURGE_CHARGE, true);
433 caster->CastSpell(caster, SPELL_SURGE_HASTE, true);
434 }
435
441};
442
@ 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
#define SpellEffectFn(F, I, N)
#define SpellObjectAreaTargetSelectFn(F, I, N)
@ UNIT_STATE_CASTING
Definition Unit.h:235
NalorakkTexts
@ SAY_DEATH
@ SAY_EVENT_2
@ 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_EVENT_1
@ SAY_BERSERK
@ EMOTE_TRANSFORM
@ SAY_WAVE_2
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
void AddSC_boss_nalorakk()
static constexpr std::array< std::string_view, 4 > NalorakkWave
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:126
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:769
MotionMaster * GetMotionMaster()
Definition Unit.h:1667
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
Map * GetMap() const
Definition Object.h:449
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
bool IsHostileTo(WorldObject const *target) const
Definition Object.cpp:2796
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition Object.cpp:1192
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
void Register() override
void HandleDummy(SpellEffIndex)
PrepareSpellScript(spell_nalorakk_surge)
bool Validate(SpellInfo const *) override
void FilterTargets(std::list< WorldObject * > &targets)
auto SelectRandomContainerElement(C const &container) -> typename std::add_const< decltype(*std::begin(container))>::type &
Definition Containers.h:108
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