TrinityCore
Loading...
Searching...
No Matches
boss_lord_stormsong.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#include "AreaTrigger.h"
19#include "AreaTriggerAI.h"
20#include "Conversation.h"
21#include "ConversationAI.h"
22#include "Creature.h"
23#include "GridNotifiersImpl.h"
24#include "InstanceScript.h"
25#include "Map.h"
26#include "MotionMaster.h"
27#include "ObjectAccessor.h"
28#include "ScriptMgr.h"
29#include "ScriptedCreature.h"
30#include "SpellAuraEffects.h"
31#include "SpellScript.h"
32#include "TemporarySummon.h"
33#include "Vehicle.h"
34#include "shrine_of_the_storm.h"
35
58
68
73
79
97
98constexpr Position IntroPosition = { 3608.3933f, -1379.824f, 160.573f, 4.370550f };
99
100// 134060 - Lord Stormsong
102{
104
105 void JustAppeared() override
106 {
108 me->SetPower(POWER_ENERGY, 55); // Energy bar is bugged on retail, but its working fine
109 me->SetOverrideDisplayPowerId(DISPLAY_POWERID); // No aura handle
110
112 me->SetImmuneToPC(false);
113 }
114
116 {
117 std::list<Creature*> mindbenders;
118 me->GetCreatureListWithOptionsInGrid(mindbenders, 200.0f, { .CreatureId = NPC_ANCIENT_MINDBENDER });
119 for (Creature* mindbender : mindbenders)
120 mindbender->DespawnOrUnsummon();
121 }
122
135
151
152 void DoAction(int32 actionId) override
153 {
154 switch (actionId)
155 {
157 {
161
162 scheduler.Schedule(11s, [this](TaskContext& task)
163 {
164 me->SetFacingTo(1.047197f);
167 if (!azshara)
168 return;
169
170 azshara->DespawnOrUnsummon();
171
172 task.Schedule(16s, [this](TaskContext& task)
173 {
175
176 task.Schedule(6s, [this](TaskContext const&)
177 {
178 me->SetImmuneToPC(false);
181 });
182 });
183 });
184 break;
185 }
186 default:
187 break;
188 }
189 }
190
191 void SpellHitTarget(WorldObject* target, SpellInfo const* spellInfo) override
192 {
193 if (!target->IsPlayer())
194 return;
195
196 if (spellInfo->Id == SPELL_ANCIENT_MINDBENDER)
198 }
199
217
218 void UpdateAI(uint32 diff) override
219 {
220 scheduler.Update(diff);
221
222 if (!UpdateVictim())
223 return;
224
225 events.Update(diff);
226
228 return;
229
230 while (uint32 eventId = events.ExecuteEvent())
231 {
232 switch (eventId)
233 {
234 case EVENT_VOID_BOLT:
235 {
237 events.Repeat(8500ms);
238 break;
239 }
240 case EVENT_MIND_REND:
241 {
243 events.Repeat(10500ms);
244 break;
245 }
247 {
249 events.Repeat(43500ms);
250 break;
251 }
253 {
254 if (me->GetPower(POWER_ENERGY) >= 100)
255 {
258 }
259 events.Repeat(500ms);
260 break;
261 }
262 default:
263 break;
264 }
265
267 return;
268 }
269 }
270};
271
272// 137051 - Ancient Mindbender
274{
276
277 void JustAppeared() override
278 {
279 TempSummon* tempSummon = me->ToTempSummon();
280 if (!tempSummon)
281 return;
282
283 tempSummon->CastSpell(tempSummon->GetSummoner(), SPELL_RIDE_VEHICLE, TRIGGERED_FULL_MASK);
284 }
285};
286
287// 139971 - Rexxar
288// 139970 - Brother Pike
289template<uint32 ConvoIntroSpellId, uint32 ConvoOutroSpellId>
291{
293
294 void JustAppeared() override
295 {
297 }
298
299 void WaypointReached(uint32 waypointId, uint32 pathId) override
300 {
301 if (pathId == PATH_INTRO)
302 {
303 if (waypointId == WAYPOINT_BOSS_INTRO)
304 DoCastSelf(ConvoIntroSpellId);
305 }
306 else if (pathId == PATH_OUTRO)
307 {
308 if (waypointId == WAYPOINT_BOSS_OUTRO)
309 DoCastSelf(ConvoOutroSpellId);
310 }
311 }
312
313 void DoAction(int32 action) override
314 {
315 if (action != ACTION_START_OUTRO)
316 return;
317
319 if (!stalker)
320 return;
321
323
325 }
326
327 void UpdateAI(uint32 diff) override
328 {
329 _events.Update(diff);
330
332 return;
333
334 switch (_events.ExecuteEvent())
335 {
336 case EVENT_OUTRO:
337 {
340 break;
341 }
342 default:
343 break;
344 }
345 }
346
347private:
349};
350
351// 269396 - Lord Stormsong Gain Energy (SERVERSIDE)
353{
354 static constexpr std::array<uint8, 2> LordStormsongEnergizeCycle = { 2, 3 };
355
356 void PeriodicTick(AuraEffect const* aurEff) const
357 {
358 uint8 cycleIdx = aurEff->GetTickNumber() % LordStormsongEnergizeCycle.size();
360 }
361
366};
367
368// 269021 - Waken the Void
388
389// 269103 - Fixate
391{
392 void HandleFixate(SpellEffIndex /*effIndex*/) const
393 {
394 Creature* caster = GetCaster()->ToCreature();
395 if (!caster)
396 return;
397
398 caster->GetMotionMaster()->MoveFollow(GetHitUnit(), 0.0f);
399 }
400
405};
406
408{
409 void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) const
410 {
411 Creature* caster = GetCaster()->ToCreature();
412 if (!caster)
413 return;
414
415 caster->DespawnOrUnsummon();
416 }
417
422};
423
424// 269131 - Ancient Mindbender
444
446{
447 void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) const
448 {
449 Vehicle* playerVehicle = GetTarget()->GetVehicleKit();
450 if (!playerVehicle)
451 return;
452
453 Unit* ancientMindbender = playerVehicle->GetPassenger(0);
454 if (!ancientMindbender)
455 return;
456
457 Creature* mindbender = ancientMindbender->ToCreature();
458 if (!mindbender)
459 return;
460
461 mindbender->DespawnOrUnsummon();
462 }
463
468};
469
470// 269242 - Surrender to the Void
472{
473 bool Validate(SpellInfo const* spellInfo) override
474 {
475 return ValidateSpellInfo({ static_cast<uint32>(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) });
476 }
477
478 void HandleDummy(SpellEffIndex /* effIndex */) const
479 {
480 GetHitUnit()->m_Events.AddEvent([hitUnit = GetHitUnit(), casterGUID = GetCaster()->GetGUID(), spellId = GetEffectValueAsInt()]()
481 {
482 if (Unit* caster = ObjectAccessor::GetUnit(*hitUnit, casterGUID))
483 hitUnit->CastSpell(caster, uint32(spellId), TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR);
484 }, 0ms);
485 }
486
491};
492
493// 269289 - Disciple of the Vol'zith
495{
496 bool Validate(SpellInfo const* spellInfo) override
497 {
498 return ValidateSpellInfo({ static_cast<uint32>(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) });
499 }
500
501 void HandlePeriodic(AuraEffect const* /*aurEff*/) const
502 {
503 Unit* target = GetTarget();
505 }
506
511};
512
513// 274711 - Release Void
515{
516 void OnRemove(AuraEffect const* /*auraEffect*/, AuraEffectHandleModes /*mode*/) const
517 {
518 if (Creature* creatureCaster = GetCaster()->ToCreature())
519 creatureCaster->DespawnOrUnsummon();
520 }
521
526};
527
528// 274710 - Release Void
530{
532 {
533 Position const offset = { 0.0f, 0.0f, 20.0f, 0.0f };
534 dest.RelocateOffset(offset);
535 }
536
541};
542
543// 269094 - Waken the Void
545{
547
548 void OnUnitEnter(Unit* unit) override
549 {
550 if (!unit->IsPlayer())
551 return;
552
553 Unit* caster = at->GetCaster();
554 if (!caster)
555 return;
556
559 at->Remove();
560 }
561};
562
563// Id - XXX
565{
566 at_lord_stormsong_intro(AreaTrigger* areatrigger) : AreaTriggerAI(areatrigger) { }
567
568 void OnUnitEnter(Unit* unit) override
569 {
570 Player* player = unit->ToPlayer();
571 if (!player || player->IsGameMaster())
572 return;
573
574 InstanceScript* instance = at->GetInstanceScript();
575 if (!instance)
576 return;
577
578 if (Creature* lordStormsong = instance->GetCreature(DATA_LORD_STORMSONG))
579 lordStormsong->AI()->DoAction(ACTION_START_INTRO);
580
581 at->Remove();
582 }
583};
584
585// 274640 - Conversation
586// 274674 - Conversation
597
598// 274641 - Conversation
609
610// 274675 - Conversation
621
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
@ IN_PROGRESS
@ FAIL
@ DONE
@ ENCOUNTER_FRAME_DISENGAGE
@ ENCOUNTER_FRAME_ENGAGE
@ TEMPSUMMON_MANUAL_DESPAWN
#define RegisterSpellAndAuraScriptPair(script_1, script_2)
Definition ScriptMgr.h:1381
#define RegisterAreaTriggerAI(ai_name)
Definition ScriptMgr.h:1428
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
#define RegisterConversationAI(ai_name)
Definition ScriptMgr.h:1437
SpellEffIndex
@ EFFECT_1
@ EFFECT_11
@ EFFECT_0
@ EFFECT_2
@ TARGET_DEST_DEST_RANDOM
@ EMOTE_STATE_READY1H
@ EMOTE_ONESHOT_NONE
@ SPELL_EFFECT_DUMMY
@ SPELL_EFFECT_SCRIPT_EFFECT
@ SPELL_EFFECT_APPLY_AURA
@ HORDE
@ POWER_ENERGY
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_MOD_FIXATE
@ SPELL_AURA_PERIODIC_DUMMY
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
@ SPELL_AURA_SET_VEHICLE_ID
@ TRIGGERED_FULL_MASK
Used when doing CastSpell with triggered == true.
@ TRIGGERED_IGNORE_CAST_IN_PROGRESS
Will not check if a current cast is in progress.
@ TRIGGERED_DONT_REPORT_CAST_ERROR
Will return SPELL_FAILED_DONT_REPORT in CheckCast functions.
#define SpellEffectFn(F, I, N)
#define AuraEffectPeriodicFn(F, I, N)
#define SpellDestinationTargetSelectFn(F, I, N)
#define AuraEffectRemoveFn(F, I, N, M)
EvadeReason
@ UNIT_STATE_CASTING
Definition Unit.h:276
LordStormsongEvents
@ EVENT_MIND_REND
@ EVENT_VOID_BOLT
@ EVENT_WAKEN_THE_VOID
@ EVENT_CHECK_POWER
void AddSC_boss_lord_stormsong()
@ NPC_QUEEN_AZSHARA
@ NPC_WATER_STALKER
@ NPC_ANCIENT_MINDBENDER
@ CONVO_ACTOR_BROTHER_PIKE
@ CONVO_ACTOR_REXXAR
@ WAYPOINT_BOSS_OUTRO
@ WAYPOINT_BOSS_INTRO
@ DISPLAY_POWERID
LordStormsongActions
@ ACTION_START_OUTRO
@ ACTION_START_INTRO
LordStormsongSpells
@ SPELL_CONVERSATION_HORDE_OUTRO
@ SPELL_ANCIENT_MINDBENDER
@ SPELL_RIDE_VEHICLE
@ SPELL_RELEASE_VOID
@ SPELL_VOID_BOLT
@ SPELL_CONVERSATION_ALLIANCE_OUTRO
@ SPELL_WAKEN_THE_VOID_AREATRIGGER
@ SPELL_ENERGIZE
@ SPELL_CONVERSATION
@ SPELL_WAKEN_THE_VOID_SUMMON
@ SPELL_CONVERSATION_ALLIANCE_INTRO
@ SPELL_SURRENDER_TO_THE_VOID
@ SPELL_CONVERSATION_HORDE_INTRO
@ SPELL_EXPLOSIVE_VOID
@ SPELL_WAKEN_THE_VOID_AREA
@ SPELL_DARK_BINDING
@ SPELL_MIND_REND
@ SPELL_DISCIPLE_OF_THE_VOL_ZITH
@ SAY_MINDBENDER_WARNING
constexpr Position IntroPosition
AreaTrigger *const at
AreaTriggerAI(AreaTrigger *a, uint32 scriptId={}) noexcept
Unit * GetCaster() const
uint32 GetTickNumber() const
HookList< EffectApplyHandler > AfterEffectRemove
HookList< EffectPeriodicHandler > OnEffectPeriodic
Unit * GetCaster() const
SpellEffectInfo const & GetEffectInfo(SpellEffIndex effIndex) const
Unit * GetTarget() const
HookList< EffectApplyHandler > OnEffectRemove
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
bool IsPlayer() const
Definition BaseEntity.h:173
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
void _DespawnAtEvade(Seconds delayToRespawn=30s, Creature *who=nullptr)
TaskScheduler scheduler
EventMap events
Conversation *const conversation
void AddActor(int32 actorId, uint32 actorIdx, ObjectGuid const &actorGuid)
bool _EnterEvadeMode(EvadeReason why=EvadeReason::Other)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void SetImmuneToPC(bool apply) override
Definition Creature.h:184
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
CreatureAI * AI() const
Definition Creature.h:228
uint32 ExecuteEvent()
Definition EventMap.cpp:77
void Update(uint32 time)
Definition EventMap.h:61
void Repeat(Milliseconds time)
Definition EventMap.cpp:67
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:40
void RescheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:56
void AddEvent(BasicEvent *event, Milliseconds e_time, bool set_addtime=true)
Team GetTeamInInstance() const
Definition Map.h:903
virtual bool SetBossState(uint32 id, EncounterState state)
void DoRemoveAurasDueToSpellOnPlayers(uint32 spell, bool includePets=false, bool includeControlled=false)
Creature * GetCreature(uint32 type)
InstanceMap * instance
void SendEncounterUnit(EncounterFrameType type, Unit const *unit, Optional< int32 > param1={}, Optional< int32 > param2={})
TempSummon * SummonCreature(uint32 entry, Position const &pos, SummonPropertiesEntry const *properties=nullptr, Milliseconds duration=0ms, WorldObject *summoner=nullptr, uint32 spellId=0, uint32 vehId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty, SmoothPhasingInfo const *smoothPhasingInfo=nullptr)
Definition Object.cpp:1186
void MoveFollow(Unit *target, float dist, Optional< ChaseAngle > angle={}, Optional< Milliseconds > duration={}, bool ignoreTargetWalk=false, MovementSlot slot=MOTION_SLOT_ACTIVE, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
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={})
Player * ToPlayer()
Definition Object.h:126
Creature * ToCreature()
Definition Object.h:121
bool IsGameMaster() const
Definition Player.h:1309
uint32 const Id
Definition SpellInfo.h:328
SpellEffectInfo const & GetEffect(SpellEffIndex index) const
Definition SpellInfo.h:588
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Unit * GetCaster() const
HookList< DestinationTargetSelectHandler > OnDestinationTargetSelect
int32 GetEffectValueAsInt() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
TaskContext & Schedule(TaskScheduler::duration_t time, TaskScheduler::task_handler_t task)
TaskScheduler & Schedule(duration_t time, task_handler_t task)
TaskScheduler & Update()
Update the scheduler to the current time.
WorldObject * GetSummoner() const
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
virtual void DoAction(int32 param)
Definition UnitAI.h:73
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:180
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:89
Definition Unit.h:635
void SetOverrideDisplayPowerId(uint32 powerDisplayId)
Definition Unit.h:814
int32 ModifyPower(Powers power, int32 val, bool withPowerUpdate=true)
Definition Unit.cpp:8697
void SetPower(Powers power, int32 val, bool withPowerUpdate=true)
Definition Unit.cpp:10046
MotionMaster * GetMotionMaster()
Definition Unit.h:1723
TempSummon * ToTempSummon()
Definition Unit.h:1828
void SetEmoteState(Emote emote)
Definition Unit.h:865
int32 GetPower(Powers power) const
Definition Unit.cpp:10028
void SetFacingTo(float const ori, bool force=true)
Definition Unit.cpp:13289
bool HasUnitState(const uint32 f) const
Definition Unit.h:743
Vehicle * GetVehicleKit() const
Definition Unit.h:1782
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3974
void SetPowerType(Powers power, bool sendUpdate=true, bool onInit=false)
Definition Unit.cpp:5697
Unit * GetPassenger(int8 seatId) const
Gets a passenger on specified seat.
Definition Vehicle.cpp:303
Map * GetMap() const
Definition Object.h:411
InstanceScript * GetInstanceScript() const
Definition Object.cpp:396
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
TempSummon * SummonCreature(uint32 entry, Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, uint32 vehId=0, uint32 spellId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
Definition Object.cpp:1398
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition Object.cpp:1517
EventProcessor m_Events
Definition Object.h:561
void GetCreatureListWithOptionsInGrid(Container &creatureContainer, float maxSearchRange, FindCreatureOptions const &options) const
Definition Object.cpp:2666
virtual void DoAction(uint32 actionId, WorldObject *source=nullptr, WorldObject *target=nullptr)
Definition ZoneScript.h:104
virtual uint32 GetData(uint32) const
Definition ZoneScript.h:99
virtual void SetData(uint32, uint32)
Definition ZoneScript.h:100
conversation_lord_stormsong_brother_pike_intro_outro(Conversation *conversation)
conversation_lord_stormsong_rexxar_intro(Conversation *conversation)
conversation_lord_stormsong_rexxar_outro(Conversation *conversation)
void OnRemove(AuraEffect const *, AuraEffectHandleModes) const
bool Validate(SpellInfo const *) override
bool Validate(SpellInfo const *spellInfo) override
void PeriodicTick(AuraEffect const *aurEff) const
static constexpr std::array< uint8, 2 > LordStormsongEnergizeCycle
void AfterRemove(AuraEffect const *, AuraEffectHandleModes) const
void HandleFixate(SpellEffIndex) const
void ModDestHeight(SpellDestination &dest) const
void OnRemove(AuraEffect const *, AuraEffectHandleModes) const
bool Validate(SpellInfo const *spellInfo) override
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
#define RegisterShrineOfTheStormCreatureAI(ai_name)
@ DATA_LORD_STORMSONG_INTRO
@ DATA_LORD_STORMSONG_REXXAR
@ DATA_LORD_STORMSONG_BROTHER_PIKE
@ DATA_LORD_STORMSONG
@ NPC_LORD_STORMSONG_BROTHER_PIKE
@ NPC_LORD_STORMSONG_REXXAR
constexpr void SetOrientation(float orientation)
Definition Position.h:82
constexpr void GetPosition(float &x, float &y) const
Definition Position.h:92
constexpr float GetOrientation() const
Definition Position.h:90
bool IsHeroicOrHigher() const
void RelocateOffset(Position const &offset)
Definition Spell.cpp:90
at_lord_stormsong_intro(AreaTrigger *areatrigger)
void OnUnitEnter(Unit *unit) override
void OnUnitEnter(Unit *unit) override
void UpdateAI(uint32 diff) override
void DoAction(int32 action) override
boss_lord_stormsong_intro_npc(Creature *creature)
void WaypointReached(uint32 waypointId, uint32 pathId) override
void SpellHitTarget(WorldObject *target, SpellInfo const *spellInfo) override
void DoAction(int32 actionId) override
boss_lord_stormsong(Creature *creature)
void JustDied(Unit *) override
void UpdateAI(uint32 diff) override
void JustEngagedWith(Unit *who) override
void EnterEvadeMode(EvadeReason) override