TrinityCore
Loading...
Searching...
No Matches
boss_telash_greywing.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 "AreaTrigger.h"
19#include "AreaTriggerAI.h"
20#include "CreatureAI.h"
21#include "CreatureAIImpl.h"
22#include "Map.h"
23#include "MotionMaster.h"
24#include "InstanceScript.h"
25#include "ObjectAccessor.h"
26#include "Player.h"
27#include "ScriptMgr.h"
28#include "ScriptedCreature.h"
29#include "SpellAuraEffects.h"
30#include "SpellScript.h"
31#include "SpellAuras.h"
32#include "SharedDefines.h"
33#include "azure_vault.h"
34
57
64
69
74
84
85Position const TelashJumpPosition = { -5336.8003f, 1066.6493f, 344.32678f };
86
88{
89 { -5350.0835f, 1089.8976f, 340.5709f, 5.0882f },
90 { -5310.4464f, 1066.8134f, 340.5967f, 3.9184f },
91 { -5350.3934f, 1043.9323f, 340.5894f, 2.0924f }
92};
93
94// 186737 - Telash Greywing
96{
98
104
119
120 void EnterEvadeMode(EvadeReason /*why*/) override
121 {
125 }
126
127 void JustDied(Unit* /*killer*/) override
128 {
129 _JustDied();
131 }
132
133 void MovementInform(uint32 /*type*/, uint32 id) override
134 {
135 if (id == EVENT_JUMP)
136 {
137 if (!_isInCenter)
138 {
140 _isInCenter = true;
141 }
142 else
143 {
147 _isInCenter = false;
148 }
149 }
150 }
151
152 void UpdateAI(uint32 diff) override
153 {
154 scheduler.Update(diff);
155
156 if (!UpdateVictim())
157 return;
158
159 events.Update(diff);
160
162 return;
163
164 while (uint32 eventId = events.ExecuteEvent())
165 {
166 switch (eventId)
167 {
168 case EVENT_FROST_BOMB:
169 {
172
175 {
177 {
180 }
181 break;
182 }
183
184 events.ScheduleEvent(EVENT_FROST_BOMB, _frostBombRemaining == 2 ? 18200ms : 15800ms);
185 break;
186 }
188 {
189 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 75.0f, true))
190 {
193
196 {
197 if (_frostBombRemaining == 1)
198 {
201 }
202 break;
203 }
205 }
206 break;
207 }
209 if (me->GetPower(me->GetPowerType()) >= 100)
210 {
214 me->SetDisableGravity(true, true);
221 }
222 events.Repeat(500ms);
223 break;
224 default:
225 break;
226 }
228 return;
229 }
230 }
231
232 void DoAction(int32 param) override
233 {
234 if (param == ACTION_RESCHEDULE_SPELLS)
235 {
238
241 }
242 }
243
244private:
248};
249
250// 30743 - Vault Rune
252{
254
255 void OnUnitEnter(Unit* unit) override
256 {
257 if (!unit->IsPlayer())
258 return;
259
260 Unit* caster = at->GetCaster();
261 if (!caster)
262 return;
263
264 if (caster->HasAura(SPELL_VAULT_RUNE_SHIELD))
265 return;
266
267 caster->CastSpell(nullptr, SPELL_VAULT_RUNE_SHIELD, true);
268 }
269
270 void OnUnitExit(Unit* unit, AreaTriggerExitReason /*reason*/) override
271 {
272 if (!unit->IsPlayer())
273 return;
274
275 for (ObjectGuid const& guid : at->GetInsideUnits())
276 {
277 Player* player = ObjectAccessor::GetPlayer(*at, guid);
278 if (!player)
279 continue;
280
281 if (player->isDead())
282 continue;
283
284 return;
285 }
286
287 Unit* caster = at->GetCaster();
288 if (!caster)
289 return;
290
292 }
293
294 void OnRemove() override
295 {
296 if (!at->GetMap()->IsMythic() && !at->GetMap()->IsMythicPlus())
297 return;
298
299 for (ObjectGuid const& guid : at->GetInsideUnits())
300 {
301 Player* player = ObjectAccessor::GetPlayer(*at, guid);
302 if (!player)
303 continue;
304
305 if (player->isDead())
306 continue;
307
308 Unit* caster = at->GetCaster();
309 if (!caster)
310 return;
311
312 caster->CastSpell(caster, SPELL_INACTIVE_VAULT_RUNE, true);
313 break;
314 }
315 }
316};
317
318// 389453 - Ice Power (periodic)
320{
321 void HandlePeriodic(AuraEffect const* /*aurEff*/)
322 {
323 Unit* target = GetTarget();
324 target->SetPower(target->GetPowerType(), target->GetPower(POWER_ENERGY) + 2);
325 }
326
331};
332
333// 386781 - Frost Bomb
335{
336 bool Validate(SpellInfo const* /*spellInfo*/) override
337 {
339 }
340
341 void HandleHit(SpellEffIndex /*effIndex*/)
342 {
344 }
345
350};
351
352// 386881 - Frost Bomb
354{
355 bool Validate(SpellInfo const* /*spellInfo*/) override
356 {
357 return ValidateSpellInfo(
358 {
361 });
362 }
363
364 void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
365 {
366 if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE)
367 return;
368
369 if (Unit* caster = GetCaster())
370 {
371 caster->CastSpell(GetTarget(), SPELL_FROZEN_GROUND_AT, true);
372 caster->CastSpell(GetTarget(), SPELL_FROST_BOMB_DAMAGE, true);
373 }
374 }
375
380};
381
382// 387928 - Absolute Zero
384{
385 bool Validate(SpellInfo const* /*spellInfo*/) override
386 {
388 }
389
394
399};
400
401// 390209 - Activate Vault Rune
403{
404 bool Validate(SpellInfo const* /*spellInfo*/) override
405 {
406 return ValidateSpellInfo(
407 {
410 });
411 }
412
414 {
416 return;
417
419 }
420
425};
426
427// 388008 - Absolute Zero
429{
430 bool Validate(SpellInfo const* /*spellInfo*/) override
431 {
432 return ValidateSpellInfo(
433 {
437 });
438 }
439
441 {
442 float nearestDist = std::numeric_limits<float>::max();
443 Position const* nearestPos = &TelashJumpBackPositions[0];
444
445 for (Position const& pos : TelashJumpBackPositions)
446 {
447 float dist = victim->GetDistance(pos);
448 if (dist < nearestDist)
449 {
450 nearestDist = dist;
451 nearestPos = &pos;
452 }
453 }
454
455 return *nearestPos;
456 }
457
459 {
460 Unit* caster = GetCaster();
461 UnitAI* casterAI = caster->GetAI();
462 if (!casterAI)
463 return;
464
466 if (!victim)
467 return;
468
471 }
472
478
484};
485
AreaTriggerExitReason
Definition AreaTrigger.h:69
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
@ ENCOUNTER_FRAME_ENGAGE
#define RegisterAreaTriggerAI(ai_name)
Definition ScriptMgr.h:1428
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
SpellEffIndex
@ EFFECT_1
@ EFFECT_0
@ EVENT_JUMP
@ SPELL_EFFECT_DUMMY
@ POWER_ENERGY
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ AURA_REMOVE_BY_EXPIRE
@ SPELL_AURA_DUMMY
@ SPELL_AURA_PERIODIC_DUMMY
#define SpellEffectFn(F, I, N)
#define AuraEffectPeriodicFn(F, I, N)
#define SpellCastFn(F)
#define AuraEffectRemoveFn(F, I, N, M)
EvadeReason
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
@ UNIT_STATE_CASTING
Definition Unit.h:276
#define RegisterAzureVaultCreatureAI(ai_name)
Definition azure_vault.h:68
@ DATA_TELASH_GREYWING
Definition azure_vault.h:33
void AddSC_boss_telash_greywing()
@ ACTION_RESCHEDULE_SPELLS
@ SAY_ANNOUNCE_ABSOLUTE_ZERO
@ SAY_FLY_TO_MIDDLE
@ SAY_ICY_DEVASTATOR
@ SUMMON_GROUP_TELASH_VAULT_RUNES
Position const TelashJumpBackPositions[]
@ SPELL_ABSOLUTE_ZERO_JUMP_BACK
@ SPELL_FROST_BOMB_DAMAGE
@ SPELL_FROST_BOMB_AURA
@ SPELL_ABSOLUTE_ZERO_DAMAGE
@ SPELL_ACTIVATE_VAULT_RUNE
@ SPELL_POWER_ENERGIZE_ICE_POWER_PERIODIC
@ SPELL_ABSOLUTE_ZERO_CAST
@ SPELL_ICY_DEVASTATOR
@ SPELL_TELASH_APPROACH_CONV
@ SPELL_FROZEN_GROUND_AT
@ SPELL_VAULT_RUNE_SHIELD
@ SPELL_INACTIVE_VAULT_RUNE
@ SPELL_ABSOLUTE_ZERO_SHIELD
@ SPELL_FROST_BOMB_CAST
@ SPELL_VAULT_RUNE_AT_AURA
@ SPELL_ABSOLUTE_ZERO_JUMP
@ EVENT_ICY_DEVASTATOR
@ EVENT_FROST_BOMB
@ EVENT_ABSOLUTE_ZERO
Position const TelashJumpPosition
AreaTrigger *const at
GuidUnorderedSet const & GetInsideUnits() const
Unit * GetCaster() const
AuraApplication const * GetTargetApplication() const
HookList< EffectPeriodicHandler > OnEffectPeriodic
Unit * GetCaster() const
Unit * GetTarget() const
HookList< EffectApplyHandler > OnEffectRemove
bool IsPlayer() const
Definition BaseEntity.h:173
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
void _DespawnAtEvade(Seconds delayToRespawn=30s, Creature *who=nullptr)
TaskScheduler scheduler
SummonList summons
EventMap events
bool _EnterEvadeMode(EvadeReason why=EvadeReason::Other)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void SetReactState(ReactStates st)
Definition Creature.h:174
uint32 ExecuteEvent()
Definition EventMap.cpp:77
void Update(uint32 time)
Definition EventMap.h:61
void Repeat(Milliseconds time)
Definition EventMap.cpp:67
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:40
void CancelEvent(uint32 eventId)
Definition EventMap.cpp:135
void SendEncounterUnit(EncounterFrameType type, Unit const *unit, Optional< int32 > param1={}, Optional< int32 > param2={})
bool IsMythicPlus() const
Definition Map.cpp:3339
bool IsMythic() const
Definition Map.cpp:3332
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
HookList< CastHandler > AfterCast
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
TaskScheduler & Update()
Update the scheduler to the current time.
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
virtual void DoAction(int32 param)
Definition UnitAI.h:73
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 SetPower(Powers power, int32 val, bool withPowerUpdate=true)
Definition Unit.cpp:10046
Powers GetPowerType() const
Definition Unit.h:811
UnitAI * GetAI() const
Definition Unit.h:668
bool SetDisableGravity(bool disable, bool updateAnimTier=true)
Definition Unit.cpp:13361
int32 GetPower(Powers power) const
Definition Unit.cpp:10028
bool HasUnitState(const uint32 f) const
Definition Unit.h:743
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition Unit.cpp:4804
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3974
bool isDead() const
Definition Unit.h:1187
Map * GetMap() const
Definition Object.h:411
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
float GetDistance(WorldObject const *obj) const
Definition Object.cpp:432
void SummonCreatureGroup(uint8 group, std::list< TempSummon * > *list=nullptr)
Definition Object.cpp:1507
bool Validate(SpellInfo const *) override
Position const & GetClosestPositionToMaxThreatTarget(Unit *victim)
bool Validate(SpellInfo const *) override
bool Validate(SpellInfo const *) override
void OnRemove(AuraEffect const *, AuraEffectHandleModes)
bool Validate(SpellInfo const *) override
bool Validate(SpellInfo const *) override
void HandlePeriodic(AuraEffect const *)
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
void OnUnitExit(Unit *unit, AreaTriggerExitReason) override
at_telash_greywing_vault_rune(AreaTrigger *areatrigger)
void OnUnitEnter(Unit *unit) override
void JustEngagedWith(Unit *who) override
void JustDied(Unit *) override
void MovementInform(uint32, uint32 id) override
void DoAction(int32 param) override
void UpdateAI(uint32 diff) override
void EnterEvadeMode(EvadeReason) override
boss_telash_greywing(Creature *creature)