TrinityCore
Loading...
Searching...
No Matches
boss_emalon.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 "ObjectAccessor.h"
22#include "ScriptedCreature.h"
23#include "SpellAuras.h"
24#include "vault_of_archavon.h"
25
32
34{
35 SPELL_OVERCHARGE = 64218, // Cast every 45 sec on a random Tempest Minion
37
38 SPELL_SHOCK = 64363,
40 SPELL_OVERCHARGED_BLAST = 64219, // Cast when Overcharged reaches 10 stacks. Mob dies after that
43};
44
53
59
61{
62 {-203.980103f, -281.287720f, 91.650223f, 1.598807f},
63 {-233.489410f, -281.139282f, 91.652412f, 1.598807f},
64 {-233.267578f, -297.104645f, 91.681915f, 1.598807f},
65 {-203.842529f, -297.097015f, 91.745163f, 1.598807f}
66};
67
68struct boss_emalon : public BossAI
69{
70 boss_emalon(Creature* creature) : BossAI(creature, DATA_EMALON) { }
71
72 void Reset() override
73 {
74 _Reset();
75
76 for (uint8 i = 0; i < MAX_TEMPEST_MINIONS; ++i)
78 }
79
80 void JustEngagedWith(Unit* who) override
81 {
82 if (!summons.empty())
83 {
84 for (SummonList::const_iterator itr = summons.begin(); itr != summons.end(); ++itr)
85 {
86 Creature* minion = ObjectAccessor::GetCreature(*me, *itr);
87 if (minion && minion->IsAlive() && !minion->GetVictim() && minion->AI())
88 minion->AI()->AttackStart(who);
89 }
90 }
91
96
98 }
99
100 void JustSummoned(Creature* summoned) override
101 {
102 BossAI::JustSummoned(summoned);
103
104 // AttackStart has nullptr-check for victim
105 if (summoned->AI())
106 summoned->AI()->AttackStart(me->GetVictim());
107 }
108
109 void UpdateAI(uint32 diff) override
110 {
111 if (!UpdateVictim())
112 return;
113
114 events.Update(diff);
115
117 return;
118
119 while (uint32 eventId = events.ExecuteEvent())
120 {
121 switch (eventId)
122 {
127 break;
131 break;
132 case EVENT_OVERCHARGE:
133 if (!summons.empty())
134 {
136 if (minion && minion->IsAlive())
137 {
138 minion->CastSpell(me, SPELL_OVERCHARGED, true);
139 minion->SetFullHealth();
142 }
143 }
144 break;
145 case EVENT_BERSERK:
148 break;
149 default:
150 break;
151 }
152
154 return;
155 }
156 }
157};
158
160{
162 {
163 Initialize();
164 _instance = creature->GetInstanceScript();
165 }
166
168 {
170 }
171
172 void Reset() override
173 {
174 _events.Reset();
175 Initialize();
176 }
177
178 void JustEngagedWith(Unit* who) override
179 {
182
184 {
185 if (!pEmalon->GetVictim() && pEmalon->AI())
186 pEmalon->AI()->AttackStart(who);
187 }
188 }
189
190 void JustDied(Unit* /*killer*/) override
191 {
193 {
194 if (emalon->IsAlive())
195 {
196 emalon->SummonCreature(NPC_TEMPEST_MINION, 0, 0, 0, 0, TEMPSUMMON_CORPSE_DESPAWN);
198 }
199 }
200 }
201
202 void UpdateAI(uint32 diff) override
203 {
204 if (!UpdateVictim())
205 return;
206
207 _events.Update(diff);
208
210 return;
211
212 if (Aura const* overchargedAura = me->GetAura(SPELL_OVERCHARGED))
213 {
214 if (overchargedAura->GetStackAmount() < 10)
215 {
216 if (_overchargedTimer <= diff)
217 {
219 _overchargedTimer = 2000; // ms
220 }
221 else
222 _overchargedTimer -= diff;
223 }
224 else
225 {
226 if (overchargedAura->GetStackAmount() == 10)
227 {
231 }
232 }
233 }
234
236 {
239 }
240 }
241
242private:
246};
247
uint8_t uint8
Definition Define.h:156
uint32_t uint32
Definition Define.h:154
@ TEMPSUMMON_CORPSE_DESPAWN
@ UNIT_STATE_CASTING
Definition Unit.h:276
EmalonEvents
@ EVENT_CHAIN_LIGHTNING
@ EVENT_SHOCK
@ EVENT_LIGHTNING_NOVA
@ EVENT_OVERCHARGE
@ EVENT_BERSERK
EmalonTexts
@ EMOTE_OVERCHARGE
@ EMOTE_MINION_RESPAWN
@ EMOTE_BERSERK
EmalonSpells
@ SPELL_OVERCHARGED_BLAST
@ SPELL_SHOCK
@ SPELL_LIGHTNING_NOVA
@ SPELL_CHAIN_LIGHTNING
@ SPELL_BERSERK
@ SPELL_OVERCHARGE
@ SPELL_OVERCHARGED
void AddSC_boss_emalon()
Position const TempestMinions[MAX_TEMPEST_MINIONS]
EmalonMisc
@ MAX_TEMPEST_MINIONS
@ NPC_TEMPEST_MINION
void JustEngagedWith(Unit *who) override
void JustSummoned(Creature *summon) override
SummonList summons
EventMap events
void DoZoneInCombat()
Definition CreatureAI.h:169
bool UpdateVictim()
void AttackStart(Unit *victim) override
== Triggered Actions Requested ==================
Creature *const me
Definition CreatureAI.h:63
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 ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:40
void Reset()
Definition EventMap.cpp:25
virtual ObjectGuid GetGuidData(uint32 type) const override
bool empty() const
iterator begin()
StorageType::const_iterator const_iterator
iterator end()
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:180
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:79
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:162
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:89
Definition Unit.h:635
void SetFullHealth()
Definition Unit.h:802
bool IsAlive() const
Definition Unit.h:1185
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition Unit.cpp:4700
Unit * GetVictim() const
Definition Unit.h:726
bool HasUnitState(const uint32 f) const
Definition Unit.h:743
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
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
auto SelectRandomContainerElement(C const &container) -> std::add_const_t< decltype(*std::ranges::begin(container))> &
Definition Containers.h:110
void Reset() override
boss_emalon(Creature *creature)
void JustSummoned(Creature *summoned) override
void UpdateAI(uint32 diff) override
void JustEngagedWith(Unit *who) override
void UpdateAI(uint32 diff) override
InstanceScript * _instance
npc_tempest_minion(Creature *creature)
void JustDied(Unit *) override
void Reset() override
void JustEngagedWith(Unit *who) override
@ DATA_EMALON
#define RegisterVaultOfArchavonCreatureAI(ai_name)