TrinityCore
Loading...
Searching...
No Matches
boss_loken.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/* ScriptData
19SDName: Boss Loken
20SD%Complete: 60%
21SDComment: Missing intro.
22SDCategory: Halls of Lightning
23EndScriptData */
24
25#include "ScriptMgr.h"
26#include "halls_of_lightning.h"
27#include "InstanceScript.h"
28#include "ScriptedCreature.h"
29#include "SpellMgr.h"
30#include "SpellScript.h"
31
45
54
62
64{
65 // Phases are used to allow executing the intro event while UpdateVictim() returns false and convenience.
68};
69
74
75/*######
76## Boss Loken
77######*/
78
79struct boss_loken : public BossAI
80{
81 boss_loken(Creature* creature) : BossAI(creature, BOSS_LOKEN)
82 {
83 Initialize();
84 _isIntroDone = false;
85 }
86
88 {
90 }
91
98
109
110 void JustDied(Unit* /*killer*/) override
111 {
113 _JustDied();
115 }
116
117 void KilledUnit(Unit* who) override
118 {
119 if (who->GetTypeId() == TYPEID_PLAYER)
120 Talk(SAY_SLAY);
121 }
122
123 void MoveInLineOfSight(Unit* who) override
124 {
125 if (!_isIntroDone && me->IsValidAttackTarget(who) && me->IsWithinDistInMap(who, 40.0f))
126 {
127 _isIntroDone = true;
130 }
132 }
133
134 void UpdateAI(uint32 diff) override
135 {
137 return;
138
139 events.Update(diff);
140
141 while (uint32 eventId = events.ExecuteEvent())
142 {
143 switch (eventId)
144 {
149 break;
151 Talk(SAY_NOVA);
154 me->RemoveAurasDueToSpell(sSpellMgr->GetSpellIdForDifficulty(SPELL_PULSING_SHOCKWAVE, me));
155 events.ScheduleEvent(EVENT_RESUME_PULSING_SHOCKWAVE, DUNGEON_MODE(5s, 4s)); // Pause Pulsing Shockwave aura
157 break;
160 me->ClearUnitState(UNIT_STATE_CASTING); // Workaround to allow DoMeleeAttackIfReady work
162 break;
166 break;
167 default:
168 break;
169 }
170 }
171
173 }
174
175 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
176 {
177 if (me->HealthBelowPctDamaged(100 - 25 * _healthAmountModifier, damage))
178 {
179 switch (_healthAmountModifier)
180 {
181 case 1:
183 break;
184 case 2:
186 break;
187 case 3:
189 break;
190 default:
191 break;
192 }
194 }
195 }
196
197 private:
200};
201
202// 52942, 59837 - Pulsing Shockwave
204{
206
208 {
209 if (!GetHitUnit())
210 return;
211
212 float distance = GetCaster()->GetDistance2d(GetHitUnit());
213 if (distance > 1.0f)
214 SetHitDamage(int32(GetHitDamage() * distance));
215 }
216
221};
222
@ ACHIEVEMENT_TIMED_TYPE_EVENT
Definition DBCEnums.h:122
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
SpellEffIndex
@ EFFECT_0
@ SPELL_EFFECT_SCHOOL_DAMAGE
#define sSpellMgr
Definition SpellMgr.h:738
#define SpellEffectFn(F, I, N)
@ UNIT_STATE_CASTING
Definition Unit.h:235
DamageEffectType
Definition Unit.h:352
void AddSC_boss_loken()
LokenEvents
@ EVENT_INTRO_DIALOGUE
@ EVENT_LIGHTNING_NOVA
@ EVENT_RESUME_PULSING_SHOCKWAVE
@ EVENT_ARC_LIGHTNING
LokenTexts
@ SAY_DEATH
@ SAY_INTRO_2
@ SAY_AGGRO
@ EMOTE_NOVA
@ SAY_INTRO_1
@ SAY_25HEALTH
@ SAY_SLAY
@ SAY_NOVA
@ SAY_50HEALTH
@ SAY_75HEALTH
LokenPhases
@ PHASE_INTRO
@ PHASE_NORMAL
LokenSpells
@ SPELL_ARC_LIGHTNING
@ SPELL_PULSING_SHOCKWAVE_AURA
@ SPELL_PULSING_SHOCKWAVE
@ SPELL_LIGHTNING_NOVA
LokenMisc
@ ACHIEV_TIMELY_DEATH_START_EVENT
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
EventMap events
virtual void MoveInLineOfSight(Unit *)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void Update(uint32 time)
Definition EventMap.h:67
EventId ExecuteEvent()
Definition EventMap.cpp:73
bool IsInPhase(PhaseIndex phase) const
Definition EventMap.h:236
void SetPhase(PhaseIndex phase)
Definition EventMap.cpp:28
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
void DoRemoveAurasDueToSpellOnPlayers(uint32 spell, bool includePets=false, bool includeControlled=false)
void DoStartTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry)
void DoStopTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry)
TypeID GetTypeId() const
Definition Object.h:93
int32 GetHitDamage() const
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
void SetHitDamage(int32 damage)
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:96
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:243
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
void ClearUnitState(uint32 f)
Definition Unit.h:877
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3784
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition Unit.h:918
bool IsValidAttackTarget(WorldObject const *target, SpellInfo const *bySpell=nullptr) const
Definition Object.cpp:2856
float GetDistance2d(WorldObject const *obj) const
Definition Object.cpp:1141
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition Object.cpp:1192
PrepareSpellScript(spell_loken_pulsing_shockwave)
void CalculateDamage(SpellEffIndex)
#define RegisterHallsOfLightningCreatureAI(ai_name)
@ BOSS_LOKEN
T const & DUNGEON_MODE(T const &normal5, T const &heroic10) const
void JustEngagedWith(Unit *who) override
uint32 _healthAmountModifier
void UpdateAI(uint32 diff) override
void KilledUnit(Unit *who) override
boss_loken(Creature *creature)
void JustDied(Unit *) override
void Initialize()
void Reset() override
void MoveInLineOfSight(Unit *who) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
bool _isIntroDone