TrinityCore
Loading...
Searching...
No Matches
boss_ionar.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/*
19 * Comment: Timer check pending
20 */
21
22#include "ScriptMgr.h"
23#include "halls_of_lightning.h"
24#include "InstanceScript.h"
25#include "MotionMaster.h"
26#include "ObjectAccessor.h"
27#include "ScriptedCreature.h"
28#include "SpellInfo.h"
29
31{
34
38
39 // Spark of Ionar
41};
42
43#define SPELL_SPARK_VISUAL_TRIGGER DUNGEON_MODE<uint32>(52667,59833)
44
46{
50 SAY_DEATH = 3
51};
52
54{
55 NPC_SPARK_OF_IONAR = 28926
56};
57
63
64static constexpr float DATA_MAX_SPARK_DISTANCE = 90; // Distance to boss - prevent runs through the whole instance
65
66/*######
67## Boss Ionar
68######*/
69
70struct boss_ionar : public BossAI
71{
72 boss_ionar(Creature* creature) : BossAI(creature, DATA_IONAR)
73 {
74 Initialize();
75 }
76
89
90 void Reset() override
91 {
93
94 Initialize();
95
97 me->SetUninteractible(false);
99
100 if (!me->IsVisible())
101 me->SetVisible(true);
102
104 }
105
106 void JustEngagedWith(Unit* who) override
107 {
110 }
111
112 void JustDied(Unit* killer) override
113 {
114 BossAI::JustDied(killer);
116 }
117
118 void KilledUnit(Unit* who) override
119 {
120 if (who->GetTypeId() == TYPEID_PLAYER)
121 Talk(SAY_SLAY);
122 }
123
124 void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override
125 {
126 if (spellInfo->Id == SPELL_DISPERSE)
127 {
128 for (uint8 i = 0; i < DATA_MAX_SPARKS; ++i)
130
131 me->AttackStop();
132 me->SetVisible(false);
134 me->SetUninteractible(true);
136
139 }
140 }
141
142 //make sparks come back
144 {
145 //should never be empty here, but check
146 if (summons.empty())
147 return;
148
149 Position pos = me->GetPosition();
150
151 for (ObjectGuid guid : summons)
152 {
153 if (Creature* pSpark = ObjectAccessor::GetCreature(*me, guid))
154 {
155 if (pSpark->IsAlive())
156 {
157 pSpark->SetReactState(REACT_PASSIVE);
158 pSpark->SetSpeedRate(MOVE_RUN, 2.0f);
159 pSpark->GetMotionMaster()->Clear();
160 pSpark->GetMotionMaster()->MovePoint(DATA_POINT_CALLBACK, pos);
161 }
162 else
163 pSpark->DespawnOrUnsummon();
164 }
165 }
166 }
167
168 void DamageTaken(Unit* /*pDoneBy*/, uint32 &uiDamage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
169 {
170 if (!me->IsVisible())
171 uiDamage = 0;
172 }
173
174 void JustSummoned(Creature* summoned) override
175 {
176 if (summoned->GetEntry() == NPC_SPARK_OF_IONAR)
177 {
178 summons.Summon(summoned);
179
181 {
182 summoned->SetInCombatWith(target);
183 summoned->GetMotionMaster()->Clear();
184 summoned->GetMotionMaster()->MoveFollow(target, 0.0f, 0.0f);
185 }
186 }
187 }
188
189 void SummonedCreatureDespawn(Creature* summoned) override
190 {
191 if (summoned->GetEntry() == NPC_SPARK_OF_IONAR)
192 summons.Despawn(summoned);
193 }
194
195 void UpdateAI(uint32 uiDiff) override
196 {
197 //Return since we have no target
198 if (!UpdateVictim())
199 return;
200
201 // Splitted
202 if (!me->IsVisible())
203 {
204 if (uiSplitTimer <= uiDiff)
205 {
206 uiSplitTimer = 2500;
207
208 // Return sparks to where Ionar splitted
209 if (bIsSplitPhase)
210 {
212 bIsSplitPhase = false;
213 }
214 // Lightning effect and restore Ionar
215 else if (summons.empty())
216 {
217 me->SetVisible(true);
219 me->SetUninteractible(false);
221
223
225 bIsSplitPhase = true;
226
227 if (me->GetVictim())
229 }
230 }
231 else
232 uiSplitTimer -= uiDiff;
233
234 return;
235 }
236
237 if (uiStaticOverloadTimer <= uiDiff)
238 {
241
243 }
244 else
245 uiStaticOverloadTimer -= uiDiff;
246
247 if (uiBallLightningTimer <= uiDiff)
248 {
251 }
252 else
253 uiBallLightningTimer -= uiDiff;
254
255 // Health check
257 {
258 bHasDispersed = true;
259
261
262 if (me->IsNonMeleeSpellCast(false))
264
265 DoCast(me, SPELL_DISPERSE, false);
266 }
267 }
268
269private:
272
274
277
279};
280
281/*######
282## npc_spark_of_ionar
283######*/
284
286{
288 {
289 Initialize();
290 _instance = creature->GetInstanceScript();
291 }
292
294 {
296 }
297
304
305 void MovementInform(uint32 uiType, uint32 uiPointId) override
306 {
307 if (uiType != POINT_MOTION_TYPE || !_instance)
308 return;
309
310 if (uiPointId == DATA_POINT_CALLBACK)
312 }
313
314 void UpdateAI(uint32 uiDiff) override
315 {
316 // Despawn if the encounter is not running
318 {
320 return;
321 }
322
323 // Prevent them to follow players through the whole instance
324 if (uiCheckTimer <= uiDiff)
325 {
327 if (ionar && ionar->IsAlive())
328 {
330 {
331 Position pos = ionar->GetPosition();
332
334 me->SetSpeedRate(MOVE_RUN, 2.0f);
337 }
338 }
339 else
342 }
343 else
344 uiCheckTimer -= uiDiff;
345
346 // No melee attack at all!
347 }
348
349private:
352};
353
@ IN_MILLISECONDS
Definition Common.h:38
uint8_t uint8
Definition Define.h:156
uint32_t uint32
Definition Define.h:154
@ IN_PROGRESS
@ NOT_STARTED
@ POINT_MOTION_TYPE
@ TYPEID_PLAYER
Definition ObjectGuid.h:44
Spells
Definition PlayerAI.cpp:32
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:42
@ MOVE_RUN
@ REACT_PASSIVE
DamageEffectType
@ UNIT_FLAG_NON_ATTACKABLE
@ UNIT_STATE_ROOT
Definition Unit.h:271
Creatures
@ NPC_SPARK_OF_IONAR
@ DATA_MAX_SPARKS
@ DATA_POINT_CALLBACK
@ SAY_DEATH
@ SAY_AGGRO
@ SAY_SPLIT
@ SAY_SLAY
@ SPELL_SUMMON_SPARK
@ SPELL_BALL_LIGHTNING
@ SPELL_SPARK_DESPAWN
@ SPELL_RANDOM_LIGHTNING_VISUAL
@ SPELL_STATIC_OVERLOAD
@ SPELL_DISPERSE
#define SPELL_SPARK_VISUAL_TRIGGER
void AddSC_boss_ionar()
static constexpr float DATA_MAX_SPARK_DISTANCE
Yells
TypeID GetTypeId() const
Definition BaseEntity.h:166
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
void JustDied(Unit *) override
SummonList summons
void Reset() override
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void SetReactState(ReactStates st)
Definition Creature.h:174
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
virtual bool SetBossState(uint32 id, EncounterState state)
Creature * GetCreature(uint32 type)
EncounterState GetBossState(uint32 id) const
void MoveFollow(Unit *target, float dist, Optional< ChaseAngle > angle={}, Optional< Milliseconds > duration={}, bool ignoreTargetWalk=false, MovementSlot slot=MOTION_SLOT_ACTIVE, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
void MoveChase(Unit *target, Optional< ChaseRange > dist={}, Optional< ChaseAngle > angle={})
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={}, Optional< MovementFadeObject > fadeObject={}, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
uint32 GetEntry() const
Definition Object.h:89
uint32 const Id
Definition SpellInfo.h:328
bool empty() const
void Despawn(Creature const *summon)
void Summon(Creature const *summon)
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
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 DoCast(uint32 spellId)
Definition UnitAI.cpp:89
Definition Unit.h:635
void SetVisible(bool x)
Definition Unit.cpp:8768
void SetInCombatWith(Unit *enemy, bool addSecondUnitSuppressed=false)
Definition Unit.h:1060
void SetControlled(bool apply, UnitState state)
Definition Unit.cpp:11545
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition Unit.cpp:3231
MotionMaster * GetMotionMaster()
Definition Unit.h:1723
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition Unit.cpp:3201
bool IsAlive() const
Definition Unit.h:1185
void SetUninteractible(bool apply)
Definition Unit.cpp:8564
bool IsVisible() const
Definition Unit.cpp:8763
Unit * GetVictim() const
Definition Unit.h:726
void SetSpeedRate(UnitMoveType mtype, float rate)
Definition Unit.cpp:8942
void SetUnitFlag(UnitFlags flags)
Definition Unit.h:846
bool AttackStop()
Definition Unit.cpp:5965
void RemoveUnitFlag(UnitFlags flags)
Definition Unit.h:847
InstanceScript * GetInstanceScript() const
Definition Object.cpp:396
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
float GetDistance(WorldObject const *obj) const
Definition Object.cpp:432
#define RegisterHallsOfLightningCreatureAI(ai_name)
@ DATA_IONAR
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
constexpr void GetPosition(float &x, float &y) const
Definition Position.h:92
bool HealthBelowPct(uint32 pct) const
uint32 uiBallLightningTimer
uint32 uiDisperseHealth
bool bHasDispersed
boss_ionar(Creature *creature)
void CallBackSparks()
void JustSummoned(Creature *summoned) override
void JustDied(Unit *killer) override
bool bIsSplitPhase
void SpellHit(WorldObject *, SpellInfo const *spellInfo) override
void SummonedCreatureDespawn(Creature *summoned) override
void Initialize()
void DamageTaken(Unit *, uint32 &uiDamage, DamageEffectType, SpellInfo const *) override
uint32 uiStaticOverloadTimer
uint32 uiSplitTimer
void UpdateAI(uint32 uiDiff) override
void Reset() override
void JustEngagedWith(Unit *who) override
void KilledUnit(Unit *who) override
void Reset() override
void UpdateAI(uint32 uiDiff) override
npc_spark_of_ionar(Creature *creature)
InstanceScript * _instance
void MovementInform(uint32 uiType, uint32 uiPointId) override