TrinityCore
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 "SpellScript.h"
30
32{
42 EMOTE_NOVA = 9
43};
44
46{
49
51};
52
53#define SPELL_PULSING_SHOCKWAVE DUNGEON_MODE<uint32>(52961,59836)
54
56{
61};
62
64{
65 // Phases are used to allow executing the intro event while UpdateVictim() returns false and convenience.
68};
69
70enum Misc
71{
73};
74
75/*######
76## Boss Loken
77######*/
78
79struct boss_loken : public BossAI
80{
81 boss_loken(Creature* creature) : BossAI(creature, DATA_LOKEN)
82 {
83 Initialize();
84 _isIntroDone = false;
85 }
86
88 {
90 }
91
92 void Reset() override
93 {
94 Initialize();
95 _Reset();
96 }
97
98 void JustEngagedWith(Unit* who) override
99 {
107 }
108
109 void JustDied(Unit* /*killer*/) override
110 {
112 _JustDied();
114 }
115
116 void KilledUnit(Unit* who) override
117 {
118 if (who->GetTypeId() == TYPEID_PLAYER)
119 Talk(SAY_SLAY);
120 }
121
122 void MoveInLineOfSight(Unit* who) override
123 {
124 if (!_isIntroDone && me->IsValidAttackTarget(who) && me->IsWithinDistInMap(who, 40.0f))
125 {
126 _isIntroDone = true;
129 }
131 }
132
133 void UpdateAI(uint32 diff) override
134 {
136 return;
137
138 events.Update(diff);
139
140 while (uint32 eventId = events.ExecuteEvent())
141 {
142 switch (eventId)
143 {
148 break;
150 Talk(SAY_NOVA);
154 events.ScheduleEvent(EVENT_RESUME_PULSING_SHOCKWAVE, DUNGEON_MODE(5s, 4s)); // Pause Pulsing Shockwave aura
156 break;
159 me->ClearUnitState(UNIT_STATE_CASTING); // Workaround to allow DoMeleeAttackIfReady work
161 break;
165 break;
166 default:
167 break;
168 }
169 }
170 }
171
172 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
173 {
174 if (me->HealthBelowPctDamaged(100 - 25 * _healthAmountModifier, damage))
175 {
176 switch (_healthAmountModifier)
177 {
178 case 1:
180 break;
181 case 2:
183 break;
184 case 3:
186 break;
187 default:
188 break;
189 }
191 }
192 }
193
194 private:
197};
198
199// 52942, 59837 - Pulsing Shockwave
201{
203 {
204 if (!GetHitUnit())
205 return;
206
207 float distance = GetCaster()->GetDistance2d(GetHitUnit());
208 if (distance > 1.0f)
209 SetHitDamage(int32(GetHitDamage() * distance));
210 }
211
212 void Register() override
213 {
215 }
216};
217
219{
222}
Texts
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
Spells
Definition: PlayerAI.cpp:32
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_0
Definition: SharedDefines.h:30
@ SPELL_EFFECT_SCHOOL_DAMAGE
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
DamageEffectType
Definition: UnitDefines.h:131
@ UNIT_STATE_CASTING
Definition: Unit.h:270
void AddSC_boss_loken()
Definition: boss_loken.cpp:218
#define SPELL_PULSING_SHOCKWAVE
Definition: boss_loken.cpp:53
@ ACHIEV_TIMELY_DEATH_START_EVENT
Definition: boss_loken.cpp:72
@ SPELL_ARC_LIGHTNING
Definition: boss_loken.cpp:47
@ SPELL_PULSING_SHOCKWAVE_AURA
Definition: boss_loken.cpp:50
@ SPELL_LIGHTNING_NOVA
Definition: boss_loken.cpp:48
@ PHASE_INTRO
Definition: boss_loken.cpp:66
@ PHASE_NORMAL
Definition: boss_loken.cpp:67
@ SAY_DEATH
Definition: boss_loken.cpp:41
@ SAY_INTRO_2
Definition: boss_loken.cpp:34
@ SAY_AGGRO
Definition: boss_loken.cpp:35
@ EMOTE_NOVA
Definition: boss_loken.cpp:42
@ SAY_INTRO_1
Definition: boss_loken.cpp:33
@ SAY_25HEALTH
Definition: boss_loken.cpp:40
@ SAY_SLAY
Definition: boss_loken.cpp:37
@ SAY_NOVA
Definition: boss_loken.cpp:36
@ SAY_50HEALTH
Definition: boss_loken.cpp:39
@ SAY_75HEALTH
Definition: boss_loken.cpp:38
@ EVENT_INTRO_DIALOGUE
Definition: boss_loken.cpp:60
@ EVENT_LIGHTNING_NOVA
Definition: boss_loken.cpp:58
@ EVENT_RESUME_PULSING_SHOCKWAVE
Definition: boss_loken.cpp:59
@ EVENT_ARC_LIGHTNING
Definition: boss_loken.cpp:57
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
EventMap events
void _JustDied()
virtual void MoveInLineOfSight(Unit *)
Definition: CreatureAI.cpp:122
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
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
bool IsInPhase(uint8 phase) const
Definition: EventMap.h:217
void SetPhase(uint8 phase)
Definition: EventMap.cpp:28
void DoRemoveAurasDueToSpellOnPlayers(uint32 spell, bool includePets=false, bool includeControlled=false)
void TriggerGameEvent(uint32 gameEventId, WorldObject *source=nullptr, WorldObject *target=nullptr) override
TypeID GetTypeId() const
Definition: Object.h:173
int32 GetHitDamage() const
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
void SetHitDamage(int32 damage)
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 DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:161
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
void ClearUnitState(uint32 f)
Definition: Unit.h:733
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition: Unit.h:781
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3831
bool IsValidAttackTarget(WorldObject const *target, SpellInfo const *bySpell=nullptr) const
Definition: Object.cpp:2991
float GetDistance2d(WorldObject const *obj) const
Definition: Object.cpp:1096
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition: Object.cpp:1147
void CalculateDamage(SpellEffIndex)
Definition: boss_loken.cpp:202
#define RegisterHallsOfLightningCreatureAI(ai_name)
@ DATA_LOKEN
T const & DUNGEON_MODE(T const &normal5, T const &heroic10) const
void JustEngagedWith(Unit *who) override
Definition: boss_loken.cpp:98
uint32 _healthAmountModifier
Definition: boss_loken.cpp:195
void UpdateAI(uint32 diff) override
Definition: boss_loken.cpp:133
void KilledUnit(Unit *who) override
Definition: boss_loken.cpp:116
boss_loken(Creature *creature)
Definition: boss_loken.cpp:81
void JustDied(Unit *) override
Definition: boss_loken.cpp:109
void Initialize()
Definition: boss_loken.cpp:87
void Reset() override
Definition: boss_loken.cpp:92
void MoveInLineOfSight(Unit *who) override
Definition: boss_loken.cpp:122
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
Definition: boss_loken.cpp:172
bool _isIntroDone
Definition: boss_loken.cpp:196