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 "SpellMgr.h"
23#include "SpellScript.h"
24
32
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 == sSpellMgr->GetSpellIdForDifficulty(SPELL_SHATTER, me))
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
133 }
134};
135
136// 50810, 61546 - Shatter
138{
140
141 void HandleScript(SpellEffIndex /*effIndex*/)
142 {
143 if (Unit* target = GetHitUnit())
144 {
145 target->RemoveAurasDueToSpell(SPELL_STONED);
146 target->CastSpell(nullptr, SPELL_SHATTER_EFFECT, true);
147 }
148 }
149
154};
155
156// 50811, 61547 - Shatter
158{
160
162 {
163 if (!GetHitUnit())
164 return;
165
166 float radius = GetEffectInfo(EFFECT_0).CalcRadius(GetCaster());
167 if (!radius)
168 return;
169
170 float distance = GetCaster()->GetDistance2d(GetHitUnit());
171 if (distance > 1.0f)
172 SetHitDamage(int32(GetHitDamage() * ((radius - distance) / radius)));
173 }
174
179};
180
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_SCRIPT_EFFECT
#define sSpellMgr
Definition SpellMgr.h:738
#define SpellEffectFn(F, I, N)
#define SpellHitFn(F)
@ UNIT_STATE_CASTING
Definition Unit.h:235
KrystallusSpells
@ SPELL_STOMP
@ SPELL_BOULDER_TOSS
@ SPELL_SHATTER_EFFECT
@ SPELL_GROUND_SLAM
@ SPELL_SHATTER
@ SPELL_GROUND_SPIKE
@ SPELL_STONED
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()
void JustEngagedWith(Unit *who) override
EventMap events
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void Update(uint32 time)
Definition EventMap.h:67
void Repeat(Milliseconds time)
Definition EventMap.cpp:63
EventId ExecuteEvent()
Definition EventMap.cpp:73
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
TypeID GetTypeId() const
Definition Object.h:93
float CalcRadius(WorldObject *caster=nullptr, Spell *=nullptr) const
uint32 Id
Definition SpellInfo.h:289
int32 GetHitDamage() const
Unit * GetCaster() const
HookList< HitHandler > OnHit
Unit * GetHitUnit() const
SpellEffectInfo const & GetEffectInfo() const
HookList< EffectHandler > OnEffectHitTarget
void SetHitDamage(int32 damage)
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:241
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 DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
float GetDistance2d(WorldObject const *obj) const
Definition Object.cpp:1141
PrepareSpellScript(spell_krystallus_shatter_effect)
PrepareSpellScript(spell_krystallus_shatter)
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