TrinityCore
Loading...
Searching...
No Matches
boss_krystallus.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 "halls_of_stone.h"
20#include "ScriptedCreature.h"
21#include "SpellInfo.h"
22#include "SpellScript.h"
23
31
41
42#define SPELL_SHATTER DUNGEON_MODE<uint32>(50810,61546)
43
52
53// 27977 - Krystallus
54struct boss_krystallus : public BossAI
55{
56 boss_krystallus(Creature* creature) : BossAI(creature, DATA_KRYSTALLUS) { }
57
69
70 void OnSpellCast(SpellInfo const* spell) override
71 {
72 if (spell->Id == SPELL_SHATTER)
74 }
75
76 void KilledUnit(Unit* victim) override
77 {
78 if (victim->GetTypeId() == TYPEID_PLAYER)
80 }
81
82 void JustDied(Unit* /*killer*/) override
83 {
85 _JustDied();
86 }
87
88 void UpdateAI(uint32 diff) override
89 {
90 if (!UpdateVictim())
91 return;
92
93 events.Update(diff);
94
96 return;
97
98 while (uint32 eventId = events.ExecuteEvent())
99 {
100 switch (eventId)
101 {
103 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 50.0f, true))
104 DoCast(target, SPELL_BOULDER_TOSS);
105 events.Repeat(9s, 15s);
106 break;
108 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100.0f, true))
109 DoCast(target, SPELL_GROUND_SPIKE);
110 events.Repeat(12s, 17s);
111 break;
115 events.Repeat(15s, 18s);
116 break;
117 case EVENT_STOMP:
119 events.Repeat(20s, 29s);
120 break;
121 case EVENT_SHATTER:
123 break;
124 default:
125 break;
126 }
127
129 return;
130 }
131 }
132};
133
134// 50810, 61546 - Shatter
136{
137 void HandleScript(SpellEffIndex /*effIndex*/)
138 {
139 if (Unit* target = GetHitUnit())
140 {
141 target->RemoveAurasDueToSpell(SPELL_STONED);
142 target->CastSpell(nullptr, SPELL_SHATTER_EFFECT, true);
143 }
144 }
145
150};
151
152// 50811, 61547 - Shatter
154{
155 bool Validate(SpellInfo const* spellInfo) override
156 {
157 return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } });
158 }
159
161 {
162 if (!GetHitUnit())
163 return;
164
166 if (radius <= 0.0f)
167 return;
168
169 float distance = GetCaster()->GetDistance2d(GetHitUnit());
170 if (distance > 1.0f)
171 SetHitDamage(int32(GetHitDamage() * ((radius - distance) / radius)));
172 }
173
178};
179
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
@ TYPEID_PLAYER
Definition ObjectGuid.h:44
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
SpellEffIndex
@ EFFECT_0
@ SPELL_EFFECT_SCRIPT_EFFECT
#define SpellEffectFn(F, I, N)
#define SpellHitFn(F)
@ UNIT_STATE_CASTING
Definition Unit.h:290
KrystallusSpells
@ SPELL_STOMP
@ SPELL_BOULDER_TOSS
@ SPELL_SHATTER_EFFECT
@ SPELL_GROUND_SLAM
@ SPELL_GROUND_SPIKE
@ SPELL_STONED
#define SPELL_SHATTER
KrystallusEvents
@ EVENT_SHATTER
@ EVENT_GROUND_SLAM
@ EVENT_GROUND_SPIKE
@ EVENT_BOULDER_TOSS
@ EVENT_STOMP
KrystallusTexts
@ SAY_DEATH
@ SAY_AGGRO
@ SAY_SLAY
@ SAY_SHATTER
void AddSC_boss_krystallus()
TypeID GetTypeId() const
Definition BaseEntity.h:166
void JustEngagedWith(Unit *who) override
EventMap events
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void Update(uint32 time)
Definition EventMap.h:77
void Repeat(Milliseconds time)
Definition EventMap.cpp:67
EventId ExecuteEvent()
Definition EventMap.cpp:77
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:40
SpellRange CalcRadius(WorldObject const *caster=nullptr, SpellTargetIndex targetIndex=SpellTargetIndex::TargetA, Spell *spell=nullptr) const
uint32 const Id
Definition SpellInfo.h:328
static bool ValidateSpellEffect(std::initializer_list< std::pair< uint32, SpellEffIndex > > effects)
int32 GetHitDamage() const
Unit * GetCaster() const
HookList< HitHandler > OnHit
Unit * GetHitUnit() const
SpellEffectInfo const & GetEffectInfo() const
HookList< EffectHandler > OnEffectHitTarget
void SetHitDamage(int32 damage)
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:71
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:81
Definition Unit.h:647
bool HasUnitState(const uint32 f) const
Definition Unit.h:755
float GetDistance2d(WorldObject const *obj) const
Definition Object.cpp:448
bool Validate(SpellInfo const *spellInfo) override
void HandleScript(SpellEffIndex)
@ DATA_KRYSTALLUS
#define RegisterHallsOfStoneCreatureAI(ai_name)
bool IsHeroic() const
void UpdateAI(uint32 diff) override
void OnSpellCast(SpellInfo const *spell) override
boss_krystallus(Creature *creature)
void KilledUnit(Unit *victim) override
void JustEngagedWith(Unit *who) override
void JustDied(Unit *) override