TrinityCore
Loading...
Searching...
No Matches
boss_general_vezax.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 "ScriptMgr.h"
19#include "Containers.h"
20#include "InstanceScript.h"
21#include "Map.h"
22#include "MotionMaster.h"
23#include "Player.h"
24#include "ScriptedCreature.h"
25#include "SpellAuraEffects.h"
26#include "SpellScript.h"
27#include "ulduar.h"
28
38
40{
44
45 // Saronite Vapor
46 EMOTE_VAPORS = 0
47};
48
72
79
96
97enum Misc
98{
100 DATA_SHADOWDODGER = 29962997
102
104{
105 public:
106 boss_general_vezax() : CreatureScript("boss_general_vezax") { }
107
109 {
111 {
112 Initialize();
113 }
114
116 {
117 shadowDodger = true;
118 smellSaronite = true;
119 animusDead = false;
120 vaporCount = 0;
121 }
122
124 bool smellSaronite; // HardMode
125 bool animusDead; // Check against getting a HardMode achievement before killing Saronite Animus
127
128 void Reset() override
129 {
130 _Reset();
131
132 Initialize();
133 }
134
150
151 void UpdateAI(uint32 diff) override
152 {
153 if (!UpdateVictim())
154 return;
155
156 events.Update(diff);
157
159 return;
160
161 while (uint32 eventId = events.ExecuteEvent())
162 {
163 switch (eventId)
164 {
166 {
167 Unit* target = CheckPlayersInRange(RAID_MODE<uint8>(4, 9), 15.0f, 50.0f);
168 if (!target)
169 target = SelectTarget(SelectTargetMethod::Random, 0, 150.0f, true);
170 if (target)
171 DoCast(target, SPELL_SHADOW_CRASH);
173 break;
174 }
178 break;
180 {
181 Unit* target = CheckPlayersInRange(RAID_MODE<uint8>(4, 9), 15.0f, 50.0f);
182 if (!target)
183 target = SelectTarget(SelectTargetMethod::Random, 0, 150.0f, true);
184 if (target)
187 break;
188 }
194 break;
198 if (++vaporCount == 6 && smellSaronite)
199 {
208 }
209 break;
210 case EVENT_BERSERK:
213 break;
214 }
215
217 return;
218 }
219
221 }
222
223 void SpellHitTarget(WorldObject* target, SpellInfo const* spellInfo) override
224 {
225 if (target->GetTypeId() == TYPEID_PLAYER && spellInfo->Id == SPELL_SHADOW_CRASH_HIT)
226 shadowDodger = false;
227 }
228
229 void KilledUnit(Unit* who) override
230 {
231 if (who->GetTypeId() == TYPEID_PLAYER)
232 Talk(SAY_SLAY);
233 }
234
235 void JustDied(Unit* /*killer*/) override
236 {
237 _JustDied();
240 }
241
243 {
244 // If Shaman has Shamanistic Rage and use it during the fight, it will cast Corrupted Rage on him
245 Map::PlayerList const& Players = me->GetMap()->GetPlayers();
246 for (Map::PlayerList::const_iterator itr = Players.begin(); itr != Players.end(); ++itr)
247 if (Player* player = itr->GetSource())
248 if (player->HasSpell(SPELL_SHAMANTIC_RAGE))
249 player->CastSpell(player, SPELL_CORRUPTED_RAGE, false);
250 }
251
252 uint32 GetData(uint32 type) const override
253 {
254 switch (type)
255 {
257 return shadowDodger ? 1 : 0;
259 return smellSaronite ? 1 : 0;
260 }
261
262 return 0;
263 }
264
265 void DoAction(int32 action) override
266 {
267 switch (action)
268 {
270 smellSaronite = false;
271 break;
275 animusDead = true;
276 break;
277 }
278 }
279
280 /* Player Range Check
281 Purpose: If there are playersMin people within rangeMin, rangeMax: return a random players in that range.
282 If not, return nullptr and allow other target selection
283 */
284 Unit* CheckPlayersInRange(uint8 playersMin, float rangeMin, float rangeMax)
285 {
286 std::list<Player*> PlayerList;
287 Map::PlayerList const& Players = me->GetMap()->GetPlayers();
288 for (Map::PlayerList::const_iterator itr = Players.begin(); itr != Players.end(); ++itr)
289 {
290 if (Player* player = itr->GetSource())
291 {
292 float distance = player->GetDistance(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ());
293 if (rangeMin > distance || distance > rangeMax)
294 continue;
295
296 PlayerList.push_back(player);
297 }
298 }
299
300 if (PlayerList.empty())
301 return nullptr;
302
303 size_t size = PlayerList.size();
304 if (size < playersMin)
305 return nullptr;
306
308 }
309 };
310
311 CreatureAI* GetAI(Creature* creature) const override
312 {
313 return GetUlduarAI<boss_general_vezaxAI>(creature);
314 }
315};
316
318{
319 public:
320 boss_saronite_animus() : CreatureScript("npc_saronite_animus") { }
321
323 {
325 {
327 }
328
335
336 void JustDied(Unit* /*killer*/) override
337 {
339 vezax->AI()->DoAction(ACTION_ANIMUS_DIE);
340 }
341
342 void UpdateAI(uint32 diff) override
343 {
344 if (!UpdateVictim())
345 return;
346
347 events.Update(diff);
348
350 return;
351
352 while (uint32 eventId = events.ExecuteEvent())
353 {
354 switch (eventId)
355 {
359 break;
360 default:
361 break;
362 }
363
365 return;
366 }
367
369 }
370
371 private:
374 };
375
376 CreatureAI* GetAI(Creature* creature) const override
377 {
378 return GetUlduarAI<boss_saronite_animusAI>(creature);
379 }
380};
381
383{
384 public:
385 npc_saronite_vapors() : CreatureScript("npc_saronite_vapors") { }
386
388 {
390 {
393 me->ApplySpellImmune(0, IMMUNITY_ID, 49560, true); // Death Grip jump effect
395 }
396
397 void Reset() override
398 {
399 events.Reset();
401 }
402
403 void UpdateAI(uint32 diff) override
404 {
405 events.Update(diff);
406
407 while (uint32 eventId = events.ExecuteEvent())
408 {
409 switch (eventId)
410 {
412 me->GetMotionMaster()->MoveRandom(30.0f);
414 break;
415 default:
416 break;
417 }
418 }
419 }
420
421 void DamageTaken(Unit* /*who*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
422 {
423 // This can't be on JustDied. In 63322 dummy handler caster needs to be this NPC
424 // if caster == target then damage mods will increase the damage taken
425 if (damage >= me->GetHealth())
426 {
427 damage = 0;
434 me->DespawnOrUnsummon(30s);
435
437 vezax->AI()->DoAction(ACTION_VAPORS_DIE);
438 }
439 }
440
441 private:
444 };
445
446 CreatureAI* GetAI(Creature* creature) const override
447 {
448 return GetUlduarAI<npc_saronite_vaporsAI>(creature);
449 }
450};
451
452// 63276 - Mark of the Faceless
488
489// 63278 - Mark of the Faceless
518
519// 63322 - Saronite Vapors
521{
522 public:
523 spell_general_vezax_saronite_vapors() : SpellScriptLoader("spell_general_vezax_saronite_vapors") { }
524
526 {
528
529 bool Validate(SpellInfo const* /*spell*/) override
530 {
532 }
533
535 {
536 if (Unit* caster = GetCaster())
537 {
538 int32 mana = int32(aurEff->GetAmount() * std::pow(2.0f, GetStackAmount())); // mana restore - bp * 2^stackamount
540 args1.AddSpellBP0(mana);
541 args2.AddSpellBP0(mana * 2);
542 caster->CastSpell(GetTarget(), SPELL_SARONITE_VAPORS_ENERGIZE, args1);
543 caster->CastSpell(GetTarget(), SPELL_SARONITE_VAPORS_DAMAGE, args2);
544 }
545 }
546
551 };
552
553 AuraScript* GetAuraScript() const override
554 {
556 }
557};
558
560{
561 public:
563 {
564 }
565
566 bool OnCheck(Player* /*player*/, Unit* target) override
567 {
568 if (!target)
569 return false;
570
571 if (Creature* Vezax = target->ToCreature())
572 if (Vezax->AI()->GetData(DATA_SHADOWDODGER))
573 return true;
574
575 return false;
576 }
577};
578
580{
581 public:
583 {
584 }
585
586 bool OnCheck(Player* /*player*/, Unit* target) override
587 {
588 if (!target)
589 return false;
590
591 if (Creature* Vezax = target->ToCreature())
592 if (Vezax->AI()->GetData(DATA_SMELL_SARONITE))
593 return true;
594
595 return false;
596 }
597};
598
uint8_t uint8
Definition Define.h:135
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
@ EFFECT_1
@ EFFECT_0
@ TARGET_UNIT_DEST_AREA_ENEMY
@ IMMUNITY_ID
@ LOOT_MODE_HARD_MODE_1
@ SPELL_FAILED_NO_VALID_TARGETS
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK
@ SPELL_AURA_DUMMY
@ SPELL_AURA_PERIODIC_DUMMY
@ TRIGGERED_FULL_MASK
Will return SPELL_FAILED_DONT_REPORT in CheckCast functions.
@ SPELLVALUE_BASE_POINT1
#define SpellObjectAreaTargetSelectFn(F, I, N)
#define AuraEffectPeriodicFn(F, I, N)
#define AuraEffectApplyFn(F, I, N, M)
@ REACT_PASSIVE
@ UNIT_STAND_STATE_DEAD
Definition UnitDefines.h:41
@ UNIT_FLAG_NON_ATTACKABLE
@ UNIT_FLAG_UNINTERACTIBLE
@ UNIT_STATE_ROOT
Definition Unit.h:230
@ UNIT_STATE_CASTING
Definition Unit.h:235
DamageEffectType
Definition Unit.h:352
@ EVENT_SHADOW_CRASH
@ EVENT_MARK_OF_THE_FACELESS
@ EVENT_RANDOM_MOVE
@ EVENT_BERSERK
@ EVENT_PROFOUND_OF_DARKNESS
@ EVENT_SARONITE_VAPORS
@ EVENT_SURGE_OF_DARKNESS
@ EVENT_SEARING_FLAMES
@ ACTION_VAPORS_SPAWN
@ ACTION_ANIMUS_DIE
@ ACTION_VAPORS_DIE
@ DATA_SMELL_SARONITE
@ DATA_SHADOWDODGER
@ SPELL_SHADOW_CRASH
@ SPELL_CORRUPTED_RAGE
@ SPELL_SARONITE_VAPORS_DAMAGE
@ SPELL_SUMMON_SARONITE_VAPORS
@ SPELL_SURGE_OF_DARKNESS
@ SPELL_VISUAL_SARONITE_ANIMUS
@ SPELL_SARONITE_VAPORS_ENERGIZE
@ SPELL_SARONITE_BARRIER
@ SPELL_SARONITE_VAPORS
@ SPELL_AURA_OF_DESPAIR
@ SPELL_SEARING_FLAMES
@ SPELL_SHADOW_CRASH_HIT
@ SPELL_SUMMON_SARONITE_ANIMUS
@ SPELL_BERSERK
@ SPELL_SHAMANTIC_RAGE
@ SPELL_PROFOUND_OF_DARKNESS
@ SPELL_MARK_OF_THE_FACELESS_DAMAGE
@ SPELL_MARK_OF_THE_FACELESS
@ SAY_SURGE_OF_DARKNESS
@ SAY_BERSERK
@ SAY_HARDMODE
@ EMOTE_SURGE_OF_DARKNESS
@ EMOTE_BARRIER
@ EMOTE_VAPORS
@ EMOTE_ANIMUS
void AddSC_boss_general_vezax()
int32 GetAmount() const
HookList< EffectPeriodicHandler > OnEffectPeriodic
HookList< EffectApplyHandler > AfterEffectApply
Unit * GetCaster() const
Unit * GetTarget() const
uint8 GetStackAmount() const
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
SummonList summons
EventMap events
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void SetReactState(ReactStates st)
Definition Creature.h:119
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
void AddLootMode(uint16 lootMode)
Definition Creature.h:225
void Update(uint32 time)
Definition EventMap.h:67
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
void Reset()
Definition EventMap.cpp:21
void DoRemoveAurasDueToSpellOnPlayers(uint32 spell, bool includePets=false, bool includeControlled=false)
Creature * GetCreature(uint32 type)
iterator end()
iterator begin()
PlayerList const & GetPlayers() const
Definition Map.h:448
void MoveRandom(float wanderDistance=0.0f)
static Creature * ToCreature(Object *o)
Definition Object.h:186
TypeID GetTypeId() const
Definition Object.h:93
uint32 Id
Definition SpellInfo.h:289
WorldObject * GetExplTargetWorldObject() const
void FinishCast(SpellCastResult result, uint32 *param1=nullptr, uint32 *param2=nullptr)
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:96
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:243
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
void SetControlled(bool apply, UnitState state)
Definition Unit.cpp:11256
MotionMaster * GetMotionMaster()
Definition Unit.h:1667
uint32 GetMaxHealth() const
Definition Unit.h:914
void SetHealth(uint32 val)
Definition Unit.cpp:9361
uint32 GetHealth() const
Definition Unit.h:913
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3784
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply)
Definition Unit.cpp:8142
void SetStandState(UnitStandStateType state)
Definition Unit.cpp:10363
void RemoveAllAuras()
Definition Unit.cpp:4157
void SetUnitFlag(UnitFlags flags)
Definition Unit.h:954
Map * GetMap() const
Definition Object.h:449
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1087
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
bool OnCheck(Player *, Unit *target) override
bool OnCheck(Player *, Unit *target) override
CreatureAI * GetAI(Creature *creature) const override
CreatureAI * GetAI(Creature *creature) const override
CreatureAI * GetAI(Creature *creature) const override
AuraScript * GetAuraScript() const override
AuraScript * GetAuraScript() const override
auto SelectRandomContainerElement(C const &container) -> typename std::add_const< decltype(*std::begin(container))>::type &
Definition Containers.h:108
CastSpellExtraArgs & AddSpellBP0(int32 val)
CastSpellExtraArgs & AddSpellMod(SpellValueMod mod, int32 val)
float GetPositionZ() const
Definition Position.h:81
float GetPositionX() const
Definition Position.h:79
float GetPositionY() const
Definition Position.h:80
uint32 GetData(uint32 type) const override
Unit * CheckPlayersInRange(uint8 playersMin, float rangeMin, float rangeMax)
void SpellHitTarget(WorldObject *target, SpellInfo const *spellInfo) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
@ DATA_VEZAX
Definition ulduar.h:47