TrinityCore
boss_occuthar.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 "baradin_hold.h"
20#include "Containers.h"
21#include "InstanceScript.h"
22#include "ObjectAccessor.h"
23#include "ScriptedCreature.h"
24#include "SpellAuraEffects.h"
25#include "SpellScript.h"
26#include "TemporarySummon.h"
27#include "Vehicle.h"
28
30{
39 SPELL_BERSERK = 47008
40};
41
43{
48
50};
51
52enum Misc
53{
55};
56
58{
59 public:
60 boss_occuthar() : CreatureScript("boss_occuthar") { }
61
62 struct boss_occutharAI : public BossAI
63 {
65 _vehicle(me->GetVehicleKit())
66 {
68 }
69
70 void JustEngagedWith(Unit* who) override
71 {
78 }
79
80 void EnterEvadeMode(EvadeReason why) override
81 {
85 }
86
87 void JustDied(Unit* /*killer*/) override
88 {
89 _JustDied();
91 }
92
93 void JustSummoned(Creature* summon) override
94 {
95 summons.Summon(summon);
96
97 if (summon->GetEntry() == NPC_FOCUS_FIRE_DUMMY)
98 {
100
101 for (uint8 i = 0; i < MAX_OCCUTHAR_VEHICLE_SEATS; ++i)
102 {
103 if (Unit* vehicle = _vehicle->GetPassenger(i))
104 vehicle->CastSpell(summon, SPELL_FOCUSED_FIRE_VISUAL);
105 }
106 }
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 {
126 break;
130 break;
135 break;
136 case EVENT_BERSERK:
137 DoCast(me, SPELL_BERSERK, true);
138 break;
139 default:
140 break;
141 }
142 }
143 }
144
145 private:
147 };
148
149 CreatureAI* GetAI(Creature* creature) const override
150 {
151 return GetBaradinHoldAI<boss_occutharAI>(creature);
152 }
153};
154
156{
157 public:
158 npc_eyestalk() : CreatureScript("npc_eyestalk") { }
159
161 {
162 npc_eyestalkAI(Creature* creature) : ScriptedAI(creature),
163 _instance(creature->GetInstanceScript())
164 {
165 _damageCount = 0;
166 }
167
168 void IsSummonedBy(WorldObject* /*summoner*/) override
169 {
170 // player is the spellcaster so register summon manually
172 occuthar->AI()->JustSummoned(me);
173 }
174
175 void Reset() override
176 {
177 _events.Reset();
179 }
180
181 void UpdateAI(uint32 diff) override
182 {
183 _events.Update(diff);
184
186 {
188 if (++_damageCount < 2)
190 }
191 }
192
193 void EnterEvadeMode(EvadeReason /*why*/) override { } // Never evade
194
195 private:
199 };
200
201 CreatureAI* GetAI(Creature* creature) const override
202 {
203 return GetBaradinHoldAI<npc_eyestalkAI>(creature);
204 }
205};
206
207// 96872 - Focused Fire
209{
210 public:
211 spell_occuthar_focused_fire() : SpellScriptLoader("spell_occuthar_focused_fire") { }
212
214 {
215 void FilterTargets(std::list<WorldObject*>& targets)
216 {
217 if (targets.size() < 2)
218 return;
219
220 targets.remove_if([&](WorldObject const* target)
221 {
222 return GetCaster()->GetVictim() == target;
223 });
224
225 if (targets.size() >= 2)
227 }
228
229 void Register() override
230 {
232 }
233 };
234
235 SpellScript* GetSpellScript() const override
236 {
238 }
239};
240
241// ID - 96931 Eyes of Occu'thar
243{
244 public:
245 spell_occuthar_eyes_of_occuthar() : SpellScriptLoader("spell_occuthar_eyes_of_occuthar") { }
246
248 {
249 bool Validate(SpellInfo const* spellInfo) override
250 {
251 return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) });
252 }
253
254 bool Load() override
255 {
256 return GetCaster()->GetTypeId() == TYPEID_PLAYER;
257 }
258
259 void FilterTargets(std::list<WorldObject*>& targets)
260 {
261 if (targets.empty())
262 return;
263
265 }
266
267 void HandleScript(SpellEffIndex /*effIndex*/)
268 {
270 }
271
272 void Register() override
273 {
276 }
277 };
278
279 SpellScript* GetSpellScript() const override
280 {
282 }
283};
284
285// ID - 96932 Eyes of Occu'thar
287{
288 public:
289 spell_occuthar_eyes_of_occuthar_vehicle() : SpellScriptLoader("spell_occuthar_eyes_of_occuthar_vehicle") { }
290
292 {
293 bool Load() override
294 {
296 }
297
299 {
301
302 if (Creature* occuthar = GetCaster()->GetInstanceScript()->GetCreature(BOSS_OCCUTHAR))
303 {
304 if (Creature* creature = occuthar->SummonCreature(NPC_EYE_OF_OCCUTHAR, pos))
305 creature->CastSpell(GetHitUnit(), SPELL_GAZE_OF_OCCUTHAR, false);
306 }
307 }
308
309 void Register() override
310 {
312 }
313 };
314
315 SpellScript* GetSpellScript() const override
316 {
318 }
319};
320
321// 96942 / 101009 - Gaze of Occu'thar
323{
324 public:
325 spell_occuthar_occuthars_destruction() : SpellScriptLoader("spell_occuthar_occuthars_destruction") { }
326
328 {
329 bool Load() override
330 {
331 return GetCaster() && GetCaster()->GetTypeId() == TYPEID_UNIT;
332 }
333
334 void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
335 {
336 if (Unit* caster = GetCaster())
337 {
338 if (IsExpired())
339 caster->CastSpell(nullptr, SPELL_OCCUTHARS_DESTUCTION, aurEff);
340
341 caster->ToCreature()->DespawnOrUnsummon(500ms);
342 }
343 }
344
345 void Register() override
346 {
348 }
349 };
350
351 AuraScript* GetAuraScript() const override
352 {
354 }
355};
356
358{
359 new boss_occuthar();
360 new npc_eyestalk();
365}
TC_GAME_API bool InstanceHasScript(WorldObject const *obj, char const *scriptName)
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
#define ASSERT
Definition: Errors.h:68
@ ENCOUNTER_FRAME_DISENGAGE
@ ENCOUNTER_FRAME_ENGAGE
@ TYPEID_UNIT
Definition: ObjectGuid.h:40
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
Spells
Definition: PlayerAI.cpp:32
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_0
Definition: SharedDefines.h:30
@ EFFECT_2
Definition: SharedDefines.h:32
@ TARGET_UNIT_SRC_AREA_ENTRY
@ TARGET_UNIT_SRC_AREA_ENEMY
@ SPELL_EFFECT_SCRIPT_EFFECT
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
#define SpellObjectAreaTargetSelectFn(F, I, N)
Definition: SpellScript.h:864
#define SpellHitFn(F)
Definition: SpellScript.h:854
#define AuraEffectRemoveFn(F, I, N, M)
Definition: SpellScript.h:2040
EvadeReason
Definition: UnitAICommon.h:30
@ UNIT_STATE_CASTING
Definition: Unit.h:270
#define BHScriptName
Definition: baradin_hold.h:24
@ BOSS_OCCUTHAR
Definition: baradin_hold.h:32
@ NPC_EYE_OF_OCCUTHAR
Definition: baradin_hold.h:50
@ NPC_FOCUS_FIRE_DUMMY
Definition: baradin_hold.h:51
@ 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
Definition: SpellScript.h:2035
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
void _DespawnAtEvade(Seconds delayToRespawn=30s, Creature *who=nullptr)
SummonList summons
EventMap events
void _JustDied()
virtual void EnterEvadeMode(EvadeReason why=EvadeReason::Other)
Definition: CreatureAI.cpp:219
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
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 RescheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:52
void Reset()
Definition: EventMap.cpp:21
Creature * GetCreature(uint32 type)
void SendEncounterUnit(EncounterFrameType type, Unit const *unit, Optional< int32 > param1={}, Optional< int32 > param2={})
TypeID GetTypeId() const
Definition: Object.h:173
uint32 GetEntry() const
Definition: Object.h:161
int32 CalcValue(WorldObject const *caster=nullptr, int32 const *basePoints=nullptr, Unit const *target=nullptr, float *variance=nullptr, uint32 castItemId=0, int32 itemLevel=-1) const
Definition: SpellInfo.cpp:495
uint32 const Id
Definition: SpellInfo.h:325
SpellEffectInfo const & GetEffect(SpellEffIndex index) const
Definition: SpellInfo.h:577
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:162
static bool ValidateSpellEffect(std::initializer_list< std::pair< uint32, SpellEffIndex > > effects)
Definition: SpellScript.h:173
Unit * GetCaster() const
HookList< HitHandler > AfterHit
Definition: SpellScript.h:852
Unit * GetHitUnit() const
int32 GetEffectValue() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
Definition: SpellScript.h:863
void Summon(Creature const *summon)
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:161
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
Unit * GetVictim() const
Definition: Unit.h:715
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
Unit * GetPassenger(int8 seatId) const
Gets a passenger on specified seat.
Definition: Vehicle.cpp:291
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
CreatureAI * GetAI(Creature *creature) const override
CreatureAI * GetAI(Creature *creature) const override
SpellScript * GetSpellScript() const override
SpellScript * GetSpellScript() const override
SpellScript * GetSpellScript() const override
AuraScript * GetAuraScript() const override
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
void RandomResize(C &container, std::size_t requestedSize)
Definition: Containers.h:67
constexpr void GetPosition(float &x, float &y) const
Definition: Position.h:81
void JustDied(Unit *) override
void UpdateAI(uint32 diff) override
void JustEngagedWith(Unit *who) override
void EnterEvadeMode(EvadeReason why) override
void JustSummoned(Creature *summon) override
boss_occutharAI(Creature *creature)
void EnterEvadeMode(EvadeReason) override
npc_eyestalkAI(Creature *creature)
void UpdateAI(uint32 diff) override
void IsSummonedBy(WorldObject *) override