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
45
51
56
58{
60
61 void Reset() override
62 {
63 _Reset();
64 _summoned = false;
65 }
66
67 void JustEngagedWith(Unit* who) override
68 {
71
72 // This is definitely just timed, not scheduled instantly when victim has specific amount of stacks of Arcane Resonance
73 events.ScheduleEvent(EVENT_ARCANE_DEVASTATION, RAND(10s, 15s, 20s, 25s, 30s, 35s));
74 // Timed in heroic (repeatable), on HP PTC in normal (not repeatable)
75 if (IsHeroic())
77 }
78
79 void KilledUnit(Unit* /*victim*/) override
80 {
82 }
83
84 void JustDied(Unit* /*killer*/) override
85 {
86 _JustDied();
88 }
89
90 void DamageTaken(Unit* /*killer*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
91 {
92 if (!_summoned && me->HealthBelowPctDamaged(55, damage) && !IsHeroic())
93 {
94 _summoned = true;
96 }
97 }
98
99 void OnSpellCast(SpellInfo const* spell) override
100 {
101 if (spell->Id == SPELL_SUMMON_REINFORCEMENTS)
103 }
104
105 // Do not despawn them
106 void JustSummoned(Creature* summon) override
107 {
108 if (me->IsEngaged())
109 DoZoneInCombat(summon);
110 }
111
112 void UpdateAI(uint32 diff) override
113 {
114 if (!UpdateVictim())
115 return;
116
117 events.Update(diff);
118
120 return;
121
122 while (uint32 eventId = events.ExecuteEvent())
123 {
124 switch (eventId)
125 {
127 // Not always?
129 // She can cast it if victim has only one stack of Arcane Resonance but can she cast it if victim has no stacks?
131 events.Repeat(RAND(10s, 15s, 20s, 25s, 30s, 35s));
132 break;
136 if (IsHeroic())
137 events.Repeat(1min);
138 break;
139 default:
140 break;
141 }
142
144 return;
145 }
146 }
147
148private:
150};
151
152// 34799 - Arcane Devastation
170
171// 34803 - Summon Reinforcements
173{
174 bool Validate(SpellInfo const* /*spellInfo*/) override
175 {
177 }
178
179 void HandleDummy(SpellEffIndex /*effIndex*/)
180 {
181 Unit* caster = GetCaster();
183 caster->CastSpell(caster, spells, true);
184 }
185
190};
191
First const & RAND(First const &first, Second const &second, Rest const &... rest)
uint32_t uint32
Definition Define.h:154
Spells
Definition PlayerAI.cpp:32
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
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)
DamageEffectType
@ UNIT_STATE_CASTING
Definition Unit.h:276
@ 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()
@ SAY_ARCANE_DEVASTATION
uint32 const SummonReinforcementsSpells[]
@ EVENT_SUMMON_REINFORCEMENTS
@ EVENT_ARCANE_DEVASTATION
HookList< EffectApplyHandler > AfterEffectApply
Unit * GetTarget() const
void JustEngagedWith(Unit *who) override
EventMap events
void DoZoneInCombat()
Definition CreatureAI.h:169
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
bool IsEngaged() const override
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
uint32 const Id
Definition SpellInfo.h:328
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Unit * GetCaster() const
HookList< EffectHandler > OnEffectHit
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:180
Definition Unit.h:635
bool HealthBelowPctDamaged(float pct, uint32 damage) const
Definition Unit.h:793
bool HasUnitState(const uint32 f) const
Definition Unit.h:743
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3974
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
void AfterApply(AuraEffect const *, AuraEffectHandleModes)
bool IsHeroic() const
void JustSummoned(Creature *summon) override
void UpdateAI(uint32 diff) 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)