Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
boss_occuthar.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 "Vehicle.h"
9#include "SpellScript.h"
10#include "SpellAuraEffects.h"
11#include "baradin_hold.h"
12
25
35
40
42{
43 public:
44 boss_occuthar() : CreatureScript("boss_occuthar") { }
45
46 struct boss_occutharAI : public BossAI
47 {
49 _vehicle(me->GetVehicleKit())
50 {
52 }
53
54 void EnterCombat(Unit* /*who*/) OVERRIDE
55 {
57 instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me);
59 events.ScheduleEvent(EVENT_FOCUSED_FIRE, 15 * IN_MILLISECONDS);
61 events.ScheduleEvent(EVENT_BERSERK, 5 * MINUTE * IN_MILLISECONDS);
62 }
63
70
71 void JustDied(Unit* /*killer*/) OVERRIDE
72 {
73 _JustDied();
74 instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, me);
75 }
76
78 {
79 summons.Summon(summon);
80
81 if (summon->GetEntry() == NPC_FOCUS_FIRE_DUMMY)
82 {
84
85 for (uint8 i = 0; i < MAX_OCCUTHAR_VEHICLE_SEATS; ++i)
86 {
87 if (Unit* vehicle = _vehicle->GetPassenger(i))
88 vehicle->CastSpell(summon, SPELL_FOCUSED_FIRE_VISUAL);
89 }
90 }
91 }
92
94 {
95 if (!UpdateVictim())
96 return;
97
98 events.Update(diff);
99
100 if (me->HasUnitState(UNIT_STATE_CASTING))
101 return;
102
103 while (uint32 eventId = events.ExecuteEvent())
104 {
105 switch (eventId)
106 {
109 events.ScheduleEvent(EVENT_SEARING_SHADOWS, 25 * IN_MILLISECONDS);
110 break;
113 events.ScheduleEvent(EVENT_FOCUSED_FIRE, 15 * IN_MILLISECONDS);
114 break;
117 events.RescheduleEvent(EVENT_FOCUSED_FIRE, 15 * IN_MILLISECONDS);
118 events.ScheduleEvent(EVENT_EYES_OF_OCCUTHAR, 60 * IN_MILLISECONDS);
119 break;
120 case EVENT_BERSERK:
121 DoCast(me, SPELL_BERSERK, true);
122 break;
123 default:
124 break;
125 }
126 }
127
129 }
130
131 private:
133 };
134
136 {
137 return GetBaradinHoldAI<boss_occutharAI>(creature);
138 }
139};
140
142{
143 public:
144 npc_eyestalk() : CreatureScript("npc_eyestalk") { }
145
147 {
148 npc_eyestalkAI(Creature* creature) : ScriptedAI(creature),
149 _instance(creature->GetInstanceScript())
150 {
151 _damageCount = 0;
152 }
153
154 void IsSummonedBy(Unit* /*summoner*/) OVERRIDE
155 {
156 // player is the spellcaster so register summon manually
157 if (Creature* occuthar = ObjectAccessor::GetCreature(*me, _instance->GetData64(DATA_OCCUTHAR)))
158 occuthar->AI()->JustSummoned(me);
159 }
160
162 {
163 _events.Reset();
165 }
166
168 {
169 _events.Update(diff);
170
171 if (_events.ExecuteEvent() == EVENT_FOCUSED_FIRE_FIRST_DAMAGE)
172 {
174 if (++_damageCount < 2)
176 }
177 }
178
179 void EnterEvadeMode() OVERRIDE { } // Never evade
180
181 private:
185 };
186
188 {
189 return GetBaradinHoldAI<npc_eyestalkAI>(creature);
190 }
191};
192
194{
195 public:
196 FocusedFireTargetSelector(Creature* me, const Unit* victim) : _me(me), _victim(victim) { }
197
199 {
200 if (target == _victim && _me->getThreatManager().getThreatList().size() > 1)
201 return true;
202
203 if (target->GetTypeId() != TypeID::TYPEID_PLAYER)
204 return true;
205
206 return false;
207 }
208
210 Unit const* _victim;
211};
212
213// 96872 - Focused Fire
215{
216 public:
217 spell_occuthar_focused_fire() : SpellScriptLoader("spell_occuthar_focused_fire") { }
218
220 {
222
223 void FilterTargets(std::list<WorldObject*>& targets)
224 {
225 if (targets.empty())
226 return;
227
228 targets.remove_if(FocusedFireTargetSelector(GetCaster()->ToCreature(), GetCaster()->GetVictim()));
230 targets.clear();
231 targets.push_back(target);
232 }
233
238 };
239
244};
245
246// ID - 96931 Eyes of Occu'thar
248{
249 public:
250 spell_occuthar_eyes_of_occuthar() : SpellScriptLoader("spell_occuthar_eyes_of_occuthar") { }
251
253 {
255
256 bool Validate(SpellInfo const* spellInfo) OVERRIDE
257 {
258 if (!sSpellMgr->GetSpellInfo(spellInfo->Effects[EFFECT_0].CalcValue()))
259 return false;
260 return true;
261 }
262
264 {
266 }
267
268 void FilterTargets(std::list<WorldObject*>& targets)
269 {
270 if (targets.empty())
271 return;
272
274 targets.clear();
275 targets.push_back(target);
276 }
277
278 void HandleScript(SpellEffIndex /*effIndex*/)
279 {
281 }
282
288 };
289
294};
295
296// ID - 96932 Eyes of Occu'thar
298{
299 public:
300 spell_occuthar_eyes_of_occuthar_vehicle() : SpellScriptLoader("spell_occuthar_eyes_of_occuthar_vehicle") { }
301
303 {
305
307 {
308 return GetCaster()->GetInstanceScript() != NULL;
309 }
310
312 {
313 Position pos;
314 GetHitUnit()->GetPosition(&pos);
315
316 if (Creature* occuthar = ObjectAccessor::GetCreature(*GetCaster(), GetCaster()->GetInstanceScript()->GetData64(DATA_OCCUTHAR)))
317 {
318 if (Creature* creature = occuthar->SummonCreature(NPC_EYE_OF_OCCUTHAR, pos))
319 creature->CastSpell(GetHitUnit(), SPELL_GAZE_OF_OCCUTHAR, false);
320 }
321 }
322
327 };
328
333};
334
335// 96942 / 101009 - Gaze of Occu'thar
337{
338 public:
339 spell_occuthar_occuthars_destruction() : SpellScriptLoader("spell_occuthar_occuthars_destruction") { }
340
342 {
344
346 {
348 }
349
350 void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
351 {
352 if (Unit* caster = GetCaster())
353 {
354 if (IsExpired())
355 caster->CastSpell((Unit*)NULL, SPELL_OCCUTHARS_DESTUCTION, true, NULL, aurEff);
356
357 caster->ToCreature()->DespawnOrUnsummon(500);
358 }
359 }
360
365 };
366
371};
372
@ IN_MILLISECONDS
Definition Common.h:125
@ MINUTE
Definition Common.h:119
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
#define ASSERT
Definition Errors.h:29
@ ENCOUNTER_FRAME_DISENGAGE
@ ENCOUNTER_FRAME_ENGAGE
@ TYPEID_PLAYER
Definition Object.h:55
@ TYPEID_UNIT
Definition Object.h:54
SpellEffIndex
@ EFFECT_0
@ EFFECT_2
@ SPELL_EFFECT_SCRIPT_EFFECT
@ TARGET_UNIT_SRC_AREA_ENTRY
@ TARGET_UNIT_SRC_AREA_ENEMY
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
#define sSpellMgr
Definition SpellMgr.h:744
#define SpellEffectFn(F, I, N)
#define SpellObjectAreaTargetSelectFn(F, I, N)
#define SpellHitFn(F)
#define AuraEffectRemoveFn(F, I, N, M)
#define SF_UNARY_FUNCTION
@ UNIT_STATE_CASTING
Definition Unit.h:527
CreatureAI * GetBaradinHoldAI(Creature *creature)
@ NPC_EYE_OF_OCCUTHAR
@ NPC_FOCUS_FIRE_DUMMY
@ DATA_OCCUTHAR
#define SPELL_BERSERK
@ MAX_OCCUTHAR_VEHICLE_SEATS
@ SPELL_FOCUSED_FIRE_FIRST_DAMAGE
@ SPELL_EYES_OF_OCCUTHAR
@ SPELL_SEARING_SHADOWS
@ SPELL_GAZE_OF_OCCUTHAR
@ SPELL_FOCUSED_FIRE_TRIGGER
@ SPELL_FOCUSED_FIRE
@ SPELL_OCCUTHARS_DESTUCTION
@ SPELL_BERSERK
@ SPELL_FOCUSED_FIRE_VISUAL
void AddSC_boss_occuthar()
@ EVENT_FOCUSED_FIRE_FIRST_DAMAGE
@ EVENT_FOCUSED_FIRE
@ EVENT_BERSERK
@ EVENT_EYES_OF_OCCUTHAR
@ EVENT_SEARING_SHADOWS
bool IsExpired() const
Unit * GetCaster() const
HookList< EffectApplyHandler > OnEffectRemove
InstanceScript *const instance
void _DespawnAtEvade()
SummonList summons
EventMap events
BossAI(Creature *creature, uint32 bossId)
void _EnterCombat()
bool UpdateVictim()
virtual void EnterEvadeMode()
CreatureScript(const char *name)
FocusedFireTargetSelector(Creature *me, const Unit *victim)
bool operator()(WorldObject *target)
static Creature * GetCreature(WorldObject const &u, uint64 guid)
TypeID GetTypeId() const
Definition Object.h:131
HookList< HitHandler > AfterHit
HookList< EffectHandler > OnEffectHitTarget
Unit * GetHitUnit()
int32 GetEffectValue()
Unit * GetCaster()
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
SpellScriptLoader(const char *name)
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:28
void DoCast(uint32 spellId)
Definition UnitAI.cpp:110
void DoCastAOE(uint32 spellId, bool triggered=false)
Definition UnitAI.cpp:176
Definition Unit.h:1367
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)
InstanceScript * GetInstanceScript()
Definition Object.cpp:1612
TempSummon * SummonCreature(uint32 id, Position const &pos, TempSummonType spwtype=TempSummonType::TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, uint32 vehId=0) const
Definition Object.cpp:2703
CreatureAI * GetAI(Creature *creature) const OVERRIDE
CreatureAI * GetAI(Creature *creature) const OVERRIDE
SpellScript * GetSpellScript() const OVERRIDE
SpellScript * GetSpellScript() const OVERRIDE
PrepareSpellScript(spell_occuthar_focused_fire_SpellScript)
SpellScript * GetSpellScript() const OVERRIDE
AuraScript * GetAuraScript() const OVERRIDE
C::value_type const & SelectRandomContainerElement(C const &container)
Definition Containers.h:48
void GetPosition(float &x, float &y) const
Definition Object.h:333
Creature * me
ScriptedAI(Creature *creature)
void JustSummoned(Creature *summon) OVERRIDE
void EnterCombat(Unit *) OVERRIDE
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
void JustDied(Unit *) OVERRIDE
boss_occutharAI(Creature *creature)
npc_eyestalkAI(Creature *creature)
void IsSummonedBy(Unit *) OVERRIDE
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================