TrinityCore
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
25{
31 SPELL_STONED = 50812,
32 SPELL_STOMP = 48131
33};
34
36{
40 SAY_SHATTER = 3
41};
42
44{
50};
51
52struct boss_krystallus : public BossAI
53{
54 boss_krystallus(Creature* creature) : BossAI(creature, DATA_KRYSTALLUS) { }
55
56 void Reset() override
57 {
58 _Reset();
59 }
60
61 void JustEngagedWith(Unit* who) override
62 {
65
69 if (IsHeroic())
71 }
72
73 void UpdateAI(uint32 diff) override
74 {
75 // Return since we have no target
76 if (!UpdateVictim())
77 return;
78
79 events.Update(diff);
80
82 return;
83
84 while (uint32 eventId = events.ExecuteEvent())
85 {
86 switch (eventId)
87 {
89 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 50.0f, true))
92 break;
94 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100.0f, true))
97 break;
102 break;
103 case EVENT_STOMP:
106 break;
107 case EVENT_SHATTER:
109 break;
110 default:
111 break;
112 }
113
115 return;
116 }
117 }
118
119 void JustDied(Unit* /*killer*/) override
120 {
122 _JustDied();
123 }
124
125 void KilledUnit(Unit* victim) override
126 {
127 if (victim->GetTypeId() == TYPEID_PLAYER)
128 Talk(SAY_KILL);
129 }
130};
131
132// 50810, 61546 - Shatter
134{
135 void HandleScript(SpellEffIndex /*effIndex*/)
136 {
137 if (Unit* target = GetHitUnit())
138 {
139 target->RemoveAurasDueToSpell(SPELL_STONED);
140 target->CastSpell(nullptr, SPELL_SHATTER_EFFECT, true);
141 }
142 }
143
144 void Register() override
145 {
147 }
148};
149
150// 50811, 61547 - Shatter
152{
153 bool Validate(SpellInfo const* spellInfo) override
154 {
155 return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } });
156 }
157
159 {
160 if (!GetHitUnit())
161 return;
162
164 if (!radius)
165 return;
166
167 float distance = GetCaster()->GetDistance2d(GetHitUnit());
168 if (distance > 1.0f)
169 SetHitDamage(int32(GetHitDamage() * ((radius - distance) / radius)));
170 }
171
172 void Register() override
173 {
175 }
176};
177
179{
183}
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_SCRIPT_EFFECT
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
#define SpellHitFn(F)
Definition: SpellScript.h:854
@ UNIT_STATE_CASTING
Definition: Unit.h:270
@ SAY_DEATH
@ SAY_AGGRO
@ SAY_KILL
@ SAY_SHATTER
@ SPELL_STOMP
@ SPELL_BOULDER_TOSS
@ SPELL_SHATTER_EFFECT
@ SPELL_GROUND_SLAM
@ SPELL_SHATTER
@ SPELL_GROUND_SPIKE
@ SPELL_STONED
void AddSC_boss_krystallus()
@ EVENT_SHATTER
@ EVENT_GROUND_SLAM
@ EVENT_GROUND_SPIKE
@ EVENT_BOULDER_TOSS
@ EVENT_STOMP
Yells
void JustEngagedWith(Unit *who) override
EventMap events
void _JustDied()
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
TypeID GetTypeId() const
Definition: Object.h:173
float CalcRadius(WorldObject *caster=nullptr, SpellTargetIndex targetIndex=SpellTargetIndex::TargetA, Spell *=nullptr) const
Definition: SpellInfo.cpp:673
uint32 const Id
Definition: SpellInfo.h:325
static bool ValidateSpellEffect(std::initializer_list< std::pair< uint32, SpellEffIndex > > effects)
Definition: SpellScript.h:173
int32 GetHitDamage() const
Unit * GetCaster() const
HookList< HitHandler > OnHit
Definition: SpellScript.h:850
Unit * GetHitUnit() const
SpellEffectInfo const & GetEffectInfo() 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 DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
float GetDistance2d(WorldObject const *obj) const
Definition: Object.cpp:1096
bool Validate(SpellInfo const *spellInfo) override
void HandleScript(SpellEffIndex)
@ DATA_KRYSTALLUS
#define RegisterHallsOfStoneCreatureAI(ai_name)
bool IsHeroic() const
void Reset() override
void UpdateAI(uint32 diff) override
boss_krystallus(Creature *creature)
void KilledUnit(Unit *victim) override
void JustEngagedWith(Unit *who) override
void JustDied(Unit *) override