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_SURGE = 44019,
57
58 // Bear form
62
63 // Shared
66
67 // Scripts
69 SPELL_SURGE_HASTE = 44960
70};
71
93
99
107
114
115static constexpr std::array<uint8, 4> WaveTexts =
116{
121};
122
123static constexpr std::array<std::string_view, 4> NalorakkWave =
124{
125 "NalorakkWave1",
126 "NalorakkWave2",
127 "NalorakkWave3",
128 "NalorakkWave4"
129};
130
131// 23576 - Nalorakk
132struct boss_nalorakk : public BossAI
133{
136
137 void Reset() override
138 {
139 _Reset();
140 SetEquipmentSlots(true);
141
143 {
144 me->SetImmuneToAll(true);
146 }
147 }
148
149 void JustEngagedWith(Unit* who) override
150 {
152
154
159 }
160
161 void OnSpellCast(SpellInfo const* spellInfo) override
162 {
163 switch (spellInfo->Id)
164 {
165 case SPELL_SURGE:
167 break;
168 case SPELL_BERSERK:
170 break;
171 default:
172 break;
173 }
174 }
175
176 void HandleWave(Unit* who)
177 {
179
180 std::vector<Creature*> waveCreatures;
181 GetCreatureListWithOptionsInGrid(waveCreatures, me, 50.0f, { .StringId = NalorakkWave[_currentWaveCount] });
182 for (Creature* waveCreature : waveCreatures)
183 {
184 waveCreature->SetImmuneToAll(false);
185 waveCreature->AI()->AttackStart(who);
186 }
187
189 _isWaiting = true;
190 }
191
193 void MoveInLineOfSight(Unit* who) override
194 {
196 {
198 return;
199 }
200
201 if (!me->IsHostileTo(who))
202 return;
203
205 return;
206
207 if (_isWaiting)
208 return;
209
210 switch (_currentWaveCount)
211 {
212 case 0:
213 if (me->IsWithinDistInMap(who, 50))
214 HandleWave(who);
215 break;
216 case 1:
217 if (me->IsWithinDistInMap(who, 40))
218 HandleWave(who);
219 break;
220 case 2:
221 if (me->IsWithinDistInMap(who, 40))
222 HandleWave(who);
223 break;
224 case 3:
225 if (me->IsWithinDistInMap(who, 60))
226 HandleWave(who);
227 break;
228 default:
229 break;
230 }
231 }
232
233 void DoAction(int32 action) override
234 {
235 switch (action)
236 {
246 break;
249 SetEquipmentSlots(true);
255 break;
258 _isMovingToLocation = true;
259 _isWaiting = false;
262 break;
265 _isMovingToLocation = true;
266 _isWaiting = false;
269 break;
272 _isMovingToLocation = true;
273 _isWaiting = false;
276 break;
279 break;
280 default:
281 break;
282 }
283 }
284
285 void WaypointPathEnded(uint32 /*nodeId*/, uint32 /*pathId*/) override
286 {
287 _isMovingToLocation = false;
288 }
289
290 void KilledUnit(Unit* /*victim*/) override
291 {
292 Talk(SAY_SLAY);
293 }
294
295 void JustDied(Unit* /*killer*/) override
296 {
297 _JustDied();
299 }
300
302 {
303 events.Update(diff);
304
305 while (uint32 eventId = events.ExecuteEvent())
306 {
307 switch (eventId)
308 {
311 break;
314 break;
317 break;
319 me->SetImmuneToAll(false);
320 _waveEventInProgress = false;
321 break;
322 default:
323 break;
324 }
325 }
326 }
327
328 void UpdateAI(uint32 diff) override
329 {
330 if (!UpdateVictim())
331 {
333 return;
334 }
335
336 events.Update(diff);
337
339 return;
340
341 while (uint32 eventId = events.ExecuteEvent())
342 {
343 switch (eventId)
344 {
347 events.Repeat(10s, 20s);
348 break;
349 case EVENT_SURGE:
351 events.Repeat(15s, 20s);
352 break;
353
356 events.Repeat(20s, 30s);
357 break;
358 case EVENT_REND_FLESH:
360 events.Repeat(10s, 15s);
361 break;
364 events.Repeat(10s, 15s);
365 break;
366
367 case EVENT_SHAPESHIFT:
369 events.Repeat(75s);
370 break;
371
372 case EVENT_BERSERK:
374 break;
375 default:
376 break;
377 }
378
380 return;
381 }
382 }
383
384private:
389};
390
391// 44019 - Surge
393{
394 bool Validate(SpellInfo const* /*spellInfo*/) override
395 {
397 }
398
399 void FilterTargets(std::list<WorldObject*>& targets)
400 {
402 }
403
404 void HandleDummy(SpellEffIndex /*effIndex*/)
405 {
406 Unit* caster = GetCaster();
407 Unit* target = GetHitUnit();
408
409 caster->CastSpell(target, SPELL_SURGE_CHARGE, true);
410 caster->CastSpell(caster, SPELL_SURGE_HASTE, true);
411 }
412
418};
419
420// 42377 - Shape of the Bear
422{
423 void AfterApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
424 {
425 if (Creature* target = GetTarget()->ToCreature())
426 target->AI()->DoAction(ACTION_SHAPE_APPLIED);
427 }
428
429 void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
430 {
431 if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE)
432 return;
433
434 if (Creature* target = GetTarget()->ToCreature())
435 target->AI()->DoAction(ACTION_SHAPE_REMOVED);
436 }
437
443};
444
@ EQUIP_UNEQUIP
Definition CreatureAI.h:57
@ EQUIP_NO_CHANGE
Definition CreatureAI.h:56
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
void GetCreatureListWithOptionsInGrid(Container &container, WorldObject *source, float maxSearchRange, FindCreatureOptions const &options)
SpellEffIndex
@ EFFECT_0
@ SPELL_EFFECT_DUMMY
@ TARGET_UNIT_SRC_AREA_ENEMY
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ AURA_REMOVE_BY_EXPIRE
@ 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:290
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_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_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:63
void SetImmuneToAll(bool apply) override
Definition Creature.h:187
void Update(uint32 time)
Definition EventMap.h:77
void Repeat(Milliseconds time)
Definition EventMap.cpp:67
EventId ExecuteEvent()
Definition EventMap.cpp:77
void CancelEvent(EventId eventId)
Definition EventMap.cpp:156
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:40
bool SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn=false, bool force=false, std::vector< WorldObject * > *spawnedObjects=nullptr)
Definition Map.cpp:2360
void MovePath(uint32 pathId, bool repeatable, Optional< Milliseconds > duration={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< std::pair< Milliseconds, Milliseconds > > waitTimeRangeAtPathEnd={}, Optional< float > wanderDistanceAtPathEnds={}, Optional< bool > followPathBackwardsFromEndToStart={}, Optional< bool > exactSplinePath={}, bool generatePath=true, Optional< MovementFadeObject > fadeObject={}, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
uint32 const Id
Definition SpellInfo.h:328
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:172
Definition Unit.h:647
MotionMaster * GetMotionMaster()
Definition Unit.h:1750
bool HasUnitState(const uint32 f) const
Definition Unit.h:755
Map * GetMap() const
Definition Object.h:411
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2222
bool IsHostileTo(WorldObject const *target) const
Definition Object.cpp:2186
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition Object.cpp:499
void AfterApply(AuraEffect const *, AuraEffectHandleModes)
void Register() override
void AfterRemove(AuraEffect const *, AuraEffectHandleModes)
void Register() override
void HandleDummy(SpellEffIndex)
bool Validate(SpellInfo const *) override
void FilterTargets(std::list< WorldObject * > &targets)
void RandomResize(C &container, std::size_t requestedSize)
Definition Containers.h:67
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:29
#define RegisterZulAmanCreatureAI(ai_name)
Definition zulaman.h:114
@ ACTION_WAVE_DONE_2
Definition zulaman.h:103
@ ACTION_WAVE_DONE_4
Definition zulaman.h:105
@ ACTION_WAVE_DONE_1
Definition zulaman.h:102
@ ACTION_WAVE_DONE_3
Definition zulaman.h:104