TrinityCore
Loading...
Searching...
No Matches
boss_commander_sarannis.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 "ScriptedCreature.h"
20#include "SpellInfo.h"
21#include "SpellScript.h"
22#include "the_botanica.h"
23
33
46
52
57
58// 17976 - Commander Sarannis
60{
62
63 void Reset() override
64 {
65 _Reset();
66 _summoned = false;
67 }
68
69 void JustEngagedWith(Unit* who) override
70 {
73
74 // This is definitely just timed, not scheduled instantly when victim has specific amount of stacks of Arcane Resonance
75 events.ScheduleEvent(EVENT_ARCANE_DEVASTATION, RAND(10s, 15s, 20s, 25s, 30s, 35s));
76 // Timed in heroic (repeatable), on HP PTC in normal (not repeatable)
77 if (IsHeroic())
79 }
80
81 void DamageTaken(Unit* /*killer*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
82 {
83 if (!_summoned && me->HealthBelowPctDamaged(55, damage) && !IsHeroic())
84 {
85 _summoned = true;
87 }
88 }
89
90 void OnSpellStart(SpellInfo const* spell) override
91 {
92 if (spell->Id == SPELL_SUMMON_REINFORCEMENTS)
94 }
95
96 void OnSpellCast(SpellInfo const* spell) override
97 {
98 // Not always?
99 if (spell->Id == SPELL_ARCANE_DEVASTATION)
101
102 if (spell->Id == SPELL_SUMMON_REINFORCEMENTS)
104 }
105
106 // Do not despawn them
107 void JustSummoned(Creature* summon) override
108 {
109 if (me->IsEngaged())
110 DoZoneInCombat(summon);
111 }
112
113 void KilledUnit(Unit* /*victim*/) override
114 {
115 Talk(SAY_SLAY);
116 }
117
118 void JustDied(Unit* /*killer*/) override
119 {
120 _JustDied();
122 }
123
124 void UpdateAI(uint32 diff) override
125 {
126 if (!UpdateVictim())
127 return;
128
129 events.Update(diff);
130
132 return;
133
134 while (uint32 eventId = events.ExecuteEvent())
135 {
136 switch (eventId)
137 {
139 // She can cast it if victim has only one stack of Arcane Resonance but can she cast it if victim has no stacks?
141 events.Repeat(RAND(10s, 15s, 20s, 25s, 30s, 35s));
142 break;
145 if (IsHeroic())
146 events.Repeat(1min);
147 break;
148 default:
149 break;
150 }
151
153 return;
154 }
155
157 }
158
159private:
161};
162
163// 34799 - Arcane Devastation
183
184// 34803 - Summon Reinforcements
206
First const & RAND(First const &first, Second const &second, Rest const &... rest)
uint32_t uint32
Definition Define.h:133
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
SpellEffIndex
@ EFFECT_0
@ EFFECT_2
@ SPELL_EFFECT_DUMMY
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_DUMMY
#define SpellEffectFn(F, I, N)
#define AuraEffectApplyFn(F, I, N, M)
@ UNIT_STATE_CASTING
Definition Unit.h:235
DamageEffectType
Definition Unit.h:352
@ SPELL_SUMMON_MENDER_1
@ SPELL_SUMMON_RESERVIST_2
@ SPELL_SUMMON_REINFORCEMENTS
@ SPELL_SUMMON_RESERVIST_1
@ SPELL_ARCANE_DEVASTATION
@ SPELL_ARCANE_RESONANCE
@ SPELL_SUMMON_RESERVIST_3
void AddSC_boss_commander_sarannis()
uint32 const SummonReinforcementsSpells[]
@ SAY_ARCANE_DEVASTATION
@ EVENT_SUMMON_REINFORCEMENTS
@ EVENT_ARCANE_DEVASTATION
HookList< EffectApplyHandler > AfterEffectApply
Unit * GetTarget() const
void JustEngagedWith(Unit *who) override
EventMap events
void DoZoneInCombat(Creature *creature=nullptr)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
bool IsEngaged() const override
void Update(uint32 time)
Definition EventMap.h:67
void Repeat(Milliseconds time)
Definition EventMap.cpp:63
EventId ExecuteEvent()
Definition EventMap.cpp:73
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
uint32 Id
Definition SpellInfo.h:289
Unit * GetCaster() const
HookList< EffectHandler > OnEffectHit
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
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
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition Unit.h:918
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
void AfterApply(AuraEffect const *, AuraEffectHandleModes)
PrepareAuraScript(spell_commander_sarannis_arcane_devastation)
PrepareSpellScript(spell_commander_sarannis_summon_reinforcements)
bool IsHeroic() const
void JustSummoned(Creature *summon) override
void UpdateAI(uint32 diff) override
void OnSpellStart(SpellInfo const *spell) override
void JustEngagedWith(Unit *who) override
void OnSpellCast(SpellInfo const *spell) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
boss_commander_sarannis(Creature *creature)
@ DATA_COMMANDER_SARANNIS
#define RegisterBotanicaCreatureAI(ai_name)