Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
boss_krystallus.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6/* Script Data Start
7SDName: Boss krystallus
8SDAuthor: LordVanMartin
9SD%Complete:
10SDComment:
11SDCategory:
12Script Data End */
13
14#include "ScriptMgr.h"
15#include "ScriptedCreature.h"
16#include "SpellScript.h"
17#include "halls_of_stone.h"
18
33
35{
40};
41
43{
44public:
45 boss_krystallus() : CreatureScript("boss_krystallus") { }
46
48 {
49 boss_krystallusAI(Creature* creature) : ScriptedAI(creature)
50 {
51 instance = creature->GetInstanceScript();
52 }
53
59
60 bool bIsSlam;
61
63
65 {
66 bIsSlam = false;
67
68 uiBoulderTossTimer = std::rand() % 9000 + 3000;
69 uiGroundSpikeTimer = std::rand() % 14000 + 9000;
70 uiGroundSlamTimer = std::rand() % 18000 + 15000;
71 uiStompTimer = std::rand() % 29000 + 20000;
73
74 if (instance)
75 instance->SetBossState(DATA_KRYSTALLUS, NOT_STARTED);
76 }
77 void EnterCombat(Unit* /*who*/) OVERRIDE
78 {
80
81 if (instance)
82 instance->SetBossState(DATA_KRYSTALLUS, IN_PROGRESS);
83 }
84
86 {
87 //Return since we have no target
88 if (!UpdateVictim())
89 return;
90
91 if (uiBoulderTossTimer <= diff)
92 {
93 if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
95 uiBoulderTossTimer = std::rand() % 15000 + 9000;
96 } else uiBoulderTossTimer -= diff;
97
98 if (uiGroundSpikeTimer <= diff)
99 {
100 if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
101 DoCast(target, SPELL_GROUND_SPIKE);
102 uiGroundSpikeTimer = std::rand() % 17000 + 12000;
103 } else uiGroundSpikeTimer -= diff;
104
105 if (uiStompTimer <= diff)
106 {
108 uiStompTimer = std::rand() % 29000 + 20000;
109 } else uiStompTimer -= diff;
110
111 if (uiGroundSlamTimer <= diff)
112 {
114 bIsSlam = true;
115 uiShatterTimer = 10000;
116 uiGroundSlamTimer = std::rand() % 18000 + 15000;
117 } else uiGroundSlamTimer -= diff;
118
119 if (bIsSlam)
120 {
121 if (uiShatterTimer <= diff)
122 {
124 } else uiShatterTimer -= diff;
125 }
126
128 }
129
130 void JustDied(Unit* /*killer*/) OVERRIDE
131 {
133
134 if (instance)
135 instance->SetBossState(DATA_KRYSTALLUS, DONE);
136 }
137
139 {
140 if (victim->GetTypeId() != TypeID::TYPEID_PLAYER)
141 return;
142
143 Talk(SAY_KILL);
144 }
145
146 void SpellHitTarget(Unit* /*target*/, const SpellInfo* pSpell) OVERRIDE
147 {
148 //this part should be in the core
149 if (pSpell->Id == SPELL_SHATTER || pSpell->Id == H_SPELL_SHATTER)
150 {
152 //clear this, if we are still performing
153 if (bIsSlam)
154 {
155 bIsSlam = false;
156
157 //and correct movement, if not already
158 if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() != CHASE_MOTION_TYPE)
159 {
160 if (me->GetVictim())
161 me->GetMotionMaster()->MoveChase(me->GetVictim());
162 }
163 }
164 }
165 }
166 };
167
169 {
171 }
172};
173
175{
176 public:
177 spell_krystallus_shatter() : SpellScriptLoader("spell_krystallus_shatter") { }
178
180 {
182
183 void HandleScript(SpellEffIndex /*effIndex*/)
184 {
185 if (Unit* target = GetHitUnit())
186 {
187 target->RemoveAurasDueToSpell(SPELL_STONED);
188 target->CastSpell((Unit*)NULL, SPELL_SHATTER_EFFECT, true);
189 }
190 }
191
196 };
197
202};
203
205{
206 public:
207 spell_krystallus_shatter_effect() : SpellScriptLoader("spell_krystallus_shatter_effect") { }
208
210 {
212
214 {
215 if (!GetHitUnit())
216 return;
217
218 float radius = GetSpellInfo()->Effects[EFFECT_0].CalcRadius(GetCaster());
219 if (!radius)
220 return;
221
222 float distance = GetCaster()->GetDistance2d(GetHitUnit());
223 if (distance > 1.0f)
224 SetHitDamage(int32(GetHitDamage() * ((radius - distance) / radius)));
225 }
226
231 };
232
237};
238
std::int32_t int32
Definition Define.h:73
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
@ IN_PROGRESS
@ DONE
@ NOT_STARTED
@ CHASE_MOTION_TYPE
@ TYPEID_PLAYER
Definition Object.h:55
SpellEffIndex
@ EFFECT_0
@ SPELL_EFFECT_SCRIPT_EFFECT
#define SpellEffectFn(F, I, N)
#define SpellHitFn(F)
@ SELECT_TARGET_RANDOM
Definition UnitAI.h:23
#define SAY_DEATH
#define SAY_AGGRO
#define SAY_KILL
@ H_SPELL_STOMP
@ SAY_DEATH
@ SAY_AGGRO
@ SAY_KILL
@ SAY_SHATTER
@ SPELL_STOMP
@ SPELL_BOULDER_TOSS
@ SPELL_SHATTER_EFFECT
@ H_SPELL_BOULDER_TOSS
@ H_SPELL_SHATTER
@ H_SPELL_SHATTER_EFFECT
@ SPELL_GROUND_SLAM
@ SPELL_SHATTER
@ SPELL_GROUND_SPIKE
@ SPELL_STONED
void AddSC_boss_krystallus()
@ SPELL_STOMP
Definition chapter5.cpp:158
void Talk(uint8 id, WorldObject const *whisperTarget=NULL)
bool UpdateVictim()
CreatureScript(const char *name)
float CalcRadius(Unit *caster=NULL, Spell *=NULL) const
SpellEffectInfo Effects[MAX_SPELL_EFFECTS]
Definition SpellInfo.h:255
SpellInfo const * GetSpellInfo()
HookList< HitHandler > OnHit
HookList< EffectHandler > OnEffectHitTarget
Unit * GetHitUnit()
void SetHitDamage(int32 damage)
Unit * GetCaster()
int32 GetHitDamage()
SpellScriptLoader(const char *name)
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:28
void DoCast(uint32 spellId)
Definition UnitAI.cpp:110
Unit * SelectTarget(SelectAggroTarget targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, int32 aura=0)
Definition UnitAI.cpp:66
Definition Unit.h:1367
InstanceScript * GetInstanceScript()
Definition Object.cpp:1612
float GetDistance2d(WorldObject const *obj) const
Definition Object.cpp:1684
CreatureAI * GetAI(Creature *creature) const OVERRIDE
PrepareSpellScript(spell_krystallus_shatter_SpellScript)
SpellScript * GetSpellScript() const OVERRIDE
SpellScript * GetSpellScript() const OVERRIDE
AI * GetHallsOfStoneAI(Creature *creature)
@ DATA_KRYSTALLUS
Creature * me
ScriptedAI(Creature *creature)
const T & DUNGEON_MODE(const T &normal5, const T &heroic5) const
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
void SpellHitTarget(Unit *, const SpellInfo *pSpell) OVERRIDE
void KilledUnit(Unit *victim) OVERRIDE