TrinityCore
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
27{
31};
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
46{
52};
53
55{
58};
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
249{
252}
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
@ TEMPSUMMON_CORPSE_DESPAWN
Definition: ObjectDefines.h:67
@ UNIT_STATE_CASTING
Definition: Unit.h:270
EmalonEvents
Definition: boss_emalon.cpp:46
@ EVENT_CHAIN_LIGHTNING
Definition: boss_emalon.cpp:47
@ EVENT_SHOCK
Definition: boss_emalon.cpp:51
@ EVENT_LIGHTNING_NOVA
Definition: boss_emalon.cpp:48
@ EVENT_OVERCHARGE
Definition: boss_emalon.cpp:49
@ EVENT_BERSERK
Definition: boss_emalon.cpp:50
EmalonTexts
Definition: boss_emalon.cpp:27
@ EMOTE_OVERCHARGE
Definition: boss_emalon.cpp:28
@ EMOTE_MINION_RESPAWN
Definition: boss_emalon.cpp:29
@ EMOTE_BERSERK
Definition: boss_emalon.cpp:30
EmalonSpells
Definition: boss_emalon.cpp:34
@ SPELL_OVERCHARGED_BLAST
Definition: boss_emalon.cpp:40
@ SPELL_SHOCK
Definition: boss_emalon.cpp:38
@ SPELL_LIGHTNING_NOVA
Definition: boss_emalon.cpp:42
@ SPELL_CHAIN_LIGHTNING
Definition: boss_emalon.cpp:41
@ SPELL_BERSERK
Definition: boss_emalon.cpp:36
@ SPELL_OVERCHARGE
Definition: boss_emalon.cpp:35
@ SPELL_OVERCHARGED
Definition: boss_emalon.cpp:39
void AddSC_boss_emalon()
Position const TempestMinions[MAX_TEMPEST_MINIONS]
Definition: boss_emalon.cpp:60
EmalonMisc
Definition: boss_emalon.cpp:55
@ MAX_TEMPEST_MINIONS
Definition: boss_emalon.cpp:57
@ NPC_TEMPEST_MINION
Definition: boss_emalon.cpp:56
void JustEngagedWith(Unit *who) override
void JustSummoned(Creature *summon) override
SummonList summons
EventMap events
void DoZoneInCombat()
Definition: CreatureAI.h:161
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
bool UpdateVictim()
Definition: CreatureAI.cpp:245
void AttackStart(Unit *victim) override
== Triggered Actions Requested ==================
Definition: CreatureAI.cpp:328
Creature *const me
Definition: CreatureAI.h:61
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
Definition: Creature.cpp:2415
CreatureAI * AI() const
Definition: Creature.h:214
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
void Reset()
Definition: EventMap.cpp:21
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:161
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
void SetFullHealth()
Definition: Unit.h:790
bool IsAlive() const
Definition: Unit.h:1164
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4560
Unit * GetVictim() const
Definition: Unit.h:715
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1042
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
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:2025
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
auto SelectRandomContainerElement(C const &container) -> typename std::add_const< decltype(*std::begin(container))>::type &
Definition: Containers.h:109
void Reset() override
Definition: boss_emalon.cpp:72
boss_emalon(Creature *creature)
Definition: boss_emalon.cpp:70
void JustSummoned(Creature *summoned) override
void UpdateAI(uint32 diff) override
void JustEngagedWith(Unit *who) override
Definition: boss_emalon.cpp:80
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)