Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
boss_emalon.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#include "ScriptMgr.h"
7#include "ScriptedCreature.h"
8#include "SpellAuras.h"
9#include "vault_of_archavon.h"
10
12{
13 SPELL_OVERCHARGE = 64218, // Cast every 45 sec on a random Tempest Minion
15
16 SPELL_SHOCK = 64363,
18 SPELL_OVERCHARGED_BLAST = 64219, // Cast when Overcharged reaches 10 stacks. Mob dies after that
21};
22
29
38
39enum Npcs
40{
42};
43
44enum Misc
45{
47};
48
50{
51 {-203.980103f, -281.287720f, 91.650223f, 1.598807f},
52 {-233.489410f, -281.139282f, 91.652412f, 1.598807f},
53 {-233.267578f, -297.104645f, 91.681915f, 1.598807f},
54 {-203.842529f, -297.097015f, 91.745163f, 1.598807f}
55};
56
57/*######
58## Emalon the Storm Watcher
59######*/
61{
62 public:
63 boss_emalon() : CreatureScript("boss_emalon") { }
64
65 struct boss_emalonAI : public BossAI
66 {
67 boss_emalonAI(Creature* creature) : BossAI(creature, DATA_EMALON)
68 {
69 }
70
72 {
73 _Reset();
74
75 for (uint8 i = 0; i < MAX_TEMPEST_MINIONS; ++i)
77 }
78
80 {
81 BossAI::JustSummoned(summoned);
82
83 // AttackStart has NULL-check for victim
84 if (summoned->AI())
85 summoned->AI()->AttackStart(me->GetVictim());
86 }
87
89 {
90 if (!summons.empty())
91 {
92 for (std::list<uint64>::const_iterator itr = summons.begin(); itr != summons.end(); ++itr)
93 {
94 Creature* minion = Unit::GetCreature(*me, *itr);
95 if (minion && minion->IsAlive() && !minion->GetVictim() && minion->AI())
96 minion->AI()->AttackStart(who);
97 }
98 }
99
100 events.ScheduleEvent(EVENT_CHAIN_LIGHTNING, 5000);
101 events.ScheduleEvent(EVENT_LIGHTNING_NOVA, 40000);
102 events.ScheduleEvent(EVENT_BERSERK, 360000);
103 events.ScheduleEvent(EVENT_OVERCHARGE, 45000);
104
105 _EnterCombat();
106 }
107
109 {
110 if (!UpdateVictim())
111 return;
112
113 events.Update(diff);
114
115 if (me->HasUnitState(UNIT_STATE_CASTING))
116 return;
117
118 while (uint32 eventId = events.ExecuteEvent())
119 {
120 switch (eventId)
121 {
123 if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
125 events.ScheduleEvent(EVENT_CHAIN_LIGHTNING, 25000);
126 break;
129 events.ScheduleEvent(EVENT_LIGHTNING_NOVA, 40000);
130 break;
131 case EVENT_OVERCHARGE:
132 if (!summons.empty())
133 {
135 if (minion && minion->IsAlive())
136 {
137 minion->CastSpell(me, SPELL_OVERCHARGED, true);
138 minion->SetFullHealth();
140 events.ScheduleEvent(EVENT_OVERCHARGE, 45000);
141 }
142 }
143 break;
144 case EVENT_BERSERK:
147 break;
148 default:
149 break;
150 }
151 }
152
154 }
155 };
156
158 {
159 return new boss_emalonAI(creature);
160 }
161};
162
163/*######
164## Tempest Minion
165######*/
167{
168 public:
169 npc_tempest_minion() : CreatureScript("npc_tempest_minion") { }
170
172 {
174 {
175 instance = creature->GetInstanceScript();
176 }
177
179 {
180 events.Reset();
182 }
183
184 void JustDied(Unit* /*killer*/) OVERRIDE
185 {
186 if (Creature* emalon = Unit::GetCreature(*me, instance ? instance->GetData64(DATA_EMALON) : 0))
187 {
188 if (emalon->IsAlive())
189 {
190 emalon->SummonCreature(NPC_TEMPEST_MINION, 0, 0, 0, 0, TempSummonType::TEMPSUMMON_CORPSE_DESPAWN, 0);
192 }
193 }
194 }
195
197 {
199 events.ScheduleEvent(EVENT_SHOCK, 20000);
200
201 if (Creature* pEmalon = Unit::GetCreature(*me, instance ? instance->GetData64(DATA_EMALON) : 0))
202 {
203 if (!pEmalon->GetVictim() && pEmalon->AI())
204 pEmalon->AI()->AttackStart(who);
205 }
206 }
207
209 {
210 //Return since we have no target
211 if (!UpdateVictim())
212 return;
213
214 events.Update(diff);
215
216 if (me->HasUnitState(UNIT_STATE_CASTING))
217 return;
218
219 if (Aura const* overchargedAura = me->GetAura(SPELL_OVERCHARGED))
220 {
221 if (overchargedAura->GetStackAmount() < 10)
222 {
223 if (OverchargedTimer <= diff)
224 {
226 OverchargedTimer = 2000;
227 }
228 else
229 OverchargedTimer -= diff;
230 }
231 else
232 {
233 if (overchargedAura->GetStackAmount() == 10)
234 {
236 me->DespawnOrUnsummon();
238 }
239 }
240 }
241
242 if (events.ExecuteEvent() == EVENT_SHOCK)
243 {
245 events.ScheduleEvent(EVENT_SHOCK, 20000);
246 }
247
249 }
250
251 private:
255 };
256
258 {
259 return new npc_tempest_minionAI(creature);
260 }
261};
262
264{
265 new boss_emalon();
266 new npc_tempest_minion();
267}
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
@ TEMPSUMMON_CORPSE_DESPAWN
Definition Object.h:72
@ UNIT_STATE_CASTING
Definition Unit.h:527
@ SELECT_TARGET_RANDOM
Definition UnitAI.h:23
@ NPC_TEMPEST_MINION
@ EMOTE_OVERCHARGE
@ EMOTE_MINION_RESPAWN
@ EMOTE_BERSERK
@ MAX_TEMPEST_MINIONS
@ SPELL_OVERCHARGED_BLAST
@ SPELL_SHOCK
@ SPELL_LIGHTNING_NOVA
@ SPELL_CHAIN_LIGHTNING
@ SPELL_BERSERK
@ SPELL_OVERCHARGE
@ SPELL_OVERCHARGED
void AddSC_boss_emalon()
struct Position TempestMinions[MAX_TEMPEST_MINIONS]
@ EVENT_CHAIN_LIGHTNING
@ EVENT_SHOCK
@ EVENT_LIGHTNING_NOVA
@ EVENT_OVERCHARGE
@ EVENT_BERSERK
Npcs
#define SPELL_BERSERK
@ EMOTE_BERSERK
@ EVENT_SHOCK
@ EVENT_BERSERK
@ EVENT_CHAIN_LIGHTNING
@ SPELL_SHOCK
@ SPELL_CHAIN_LIGHTNING
void JustSummoned(Creature *summon) OVERRIDE
SummonList summons
EventMap events
BossAI(Creature *creature, uint32 bossId)
void _EnterCombat()
void DoZoneInCombat(Creature *creature=NULL, float maxRangeToNearestTarget=50.0f)
void Talk(uint8 id, WorldObject const *whisperTarget=NULL)
bool UpdateVictim()
CreatureAI * AI() const
Definition Creature.h:483
CreatureScript(const char *name)
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:28
void DoCast(uint32 spellId)
Definition UnitAI.cpp:110
Unit * SelectTarget(SelectAggroTarget targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, int32 aura=0)
Definition UnitAI.cpp:66
void DoCastVictim(uint32 spellId, bool triggered=false)
Definition UnitAI.cpp:168
void DoCastAOE(uint32 spellId, bool triggered=false)
Definition UnitAI.cpp:176
virtual void AttackStart(Unit *)
Definition UnitAI.cpp:16
Definition Unit.h:1367
void SetFullHealth()
Definition Unit.h:1644
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, uint64 originalCaster=0)
bool IsAlive() const
Definition Unit.h:2032
static Creature * GetCreature(WorldObject &object, uint64 guid)
Definition Unit.cpp:4905
Unit * GetVictim() const
Definition Unit.h:1468
InstanceScript * GetInstanceScript()
Definition Object.cpp:1612
CreatureAI * GetAI(Creature *creature) const OVERRIDE
CreatureAI * GetAI(Creature *creature) const OVERRIDE
C::value_type const & SelectRandomContainerElement(C const &container)
Definition Containers.h:48
Creature * me
ScriptedAI(Creature *creature)
void JustSummoned(Creature *summoned) OVERRIDE
void EnterCombat(Unit *who) OVERRIDE
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
boss_emalonAI(Creature *creature)
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
@ DATA_EMALON