Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
boss_mother_shahraz.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/* ScriptData
7SDName: Boss_Mother_Shahraz
8SD%Complete: 80
9SDComment: Saber Lash missing, Fatal Attraction slightly incorrect; need to damage only if affected players are within range of each other
10SDCategory: Black Temple
11EndScriptData */
12
13#include "ScriptMgr.h"
14#include "ScriptedCreature.h"
15#include "black_temple.h"
16
40
42{
43 40880, // Shadow
44 40882, // Fire
45 40883, // Nature
46 40891, // Arcane
47 40896, // Frost
48 40897, // Holy
49};
50
51struct Locations
52{
53 float x, y, z;
54};
55
57{
58 {959.996f, 212.576f, 193.843f},
59 {932.537f, 231.813f, 193.838f},
60 {958.675f, 254.767f, 193.822f},
61 {946.955f, 201.316f, 192.535f},
62 {944.294f, 149.676f, 197.551f},
63 {930.548f, 284.888f, 193.367f},
64 {965.997f, 278.398f, 195.777f}
65};
66
68{
69public:
70 boss_mother_shahraz() : CreatureScript("boss_mother_shahraz") { }
71
73 {
74 return new boss_shahrazAI(creature);
75 }
76
77 struct boss_shahrazAI : public ScriptedAI
78 {
79 boss_shahrazAI(Creature* creature) : ScriptedAI(creature)
80 {
81 instance = creature->GetInstanceScript();
82 }
83
85
98
99 bool Enraged;
100
102 {
103 if (instance)
105
106 for (uint8 i = 0; i<3; ++i)
107 TargetGUID[i] = 0;
108
109 BeamTimer = 20000; // Timers may be incorrect
110 BeamCount = 0;
111 CurrentBeam = 0; // 0 - Sinister, 1 - Vile, 2 - Wicked, 3 - Sinful
113 FatalAttractionTimer = 60000;
115 ShriekTimer = 30000;
116 SaberTimer = 35000;
117 RandomYellTimer = std::rand() % (111 * IN_MILLISECONDS) + (70 * IN_MILLISECONDS);
118 EnrageTimer = 600000;
119 ExplosionCount = 0;
120
121 Enraged = false;
122 }
123
124 void EnterCombat(Unit* /*who*/) OVERRIDE
125 {
126 if (instance)
128
131 }
132
133 void KilledUnit(Unit* /*victim*/) OVERRIDE
134 {
135 Talk(SAY_SLAY);
136 }
137
138 void JustDied(Unit* /*killer*/) OVERRIDE
139 {
140 if (instance)
141 instance->SetBossState(DATA_MOTHER_SHAHRAZ, DONE);
142
144 }
145
147 {
148 uint32 random = rand()%7;
149 float X = TeleportPoint[random].x;
150 float Y = TeleportPoint[random].y;
151 float Z = TeleportPoint[random].z;
152 for (uint8 i = 0; i < 3; ++i)
153 {
155 if (unit && unit->IsAlive() && (unit->GetTypeId() == TypeID::TYPEID_PLAYER))
156 {
157 TargetGUID[i] = unit->GetGUID();
158 unit->CastSpell(unit, SPELL_TELEPORT_VISUAL, true);
159 DoTeleportPlayer(unit, X, Y, Z, unit->GetOrientation());
160 }
161 }
162 }
163
165 {
166 if (!UpdateVictim())
167 return;
168
169 if (HealthBelowPct(10) && !Enraged)
170 {
171 Enraged = true;
172 DoCast(me, SPELL_ENRAGE, true);
174 }
175
176 //Randomly cast one beam.
177 if (BeamTimer <= diff)
178 {
180 if (!target || !target->IsAlive())
181 return;
182
183 BeamTimer = 9000;
184
185 switch (CurrentBeam)
186 {
187 case 0:
189 break;
190 case 1:
191 DoCast(target, SPELL_BEAM_VILE);
192 break;
193 case 2:
194 DoCast(target, SPELL_BEAM_WICKED);
195 break;
196 case 3:
197 DoCast(target, SPELL_BEAM_SINFUL);
198 break;
199 }
200 ++BeamCount;
201 uint32 Beam = CurrentBeam;
202 if (BeamCount > 3)
203 while (CurrentBeam == Beam)
204 CurrentBeam = rand()%3;
205
206 } else BeamTimer -= diff;
207
208 // Random Prismatic Shield every 15 seconds.
209 if (PrismaticShieldTimer <= diff)
210 {
211 uint32 random = rand()%6;
212 if (PrismaticAuras[random])
213 DoCast(me, PrismaticAuras[random]);
214 PrismaticShieldTimer = 15000;
215 } else PrismaticShieldTimer -= diff;
216
217 // Select 3 random targets (can select same target more than once), teleport to a random location then make them cast explosions until they get away from each other.
218 if (FatalAttractionTimer <= diff)
219 {
220 ExplosionCount = 0;
221
223
226 FatalAttractionTimer = std::rand() % (71 * IN_MILLISECONDS) + (40 * IN_MILLISECONDS);
227 } else FatalAttractionTimer -= diff;
228
229 if (FatalAttractionExplodeTimer <= diff)
230 {
231 // Just make them explode three times... they're supposed to keep exploding while they are in range, but it'll take too much code. I'll try to think of an efficient way for it later.
232 if (ExplosionCount < 3)
233 {
234 for (uint8 i = 0; i < 3; ++i)
235 {
236 if (TargetGUID[i])
237 {
238 if (Unit* unit = Unit::GetUnit(*me, TargetGUID[i]))
239 unit->CastSpell(unit, SPELL_ATTRACTION, true);
240 TargetGUID[i] = 0;
241 }
242 }
243
246 }
247 else
248 {
250 ExplosionCount = 0;
251 }
252 } else FatalAttractionExplodeTimer -= diff;
253
254 if (ShriekTimer <= diff)
255 {
257 ShriekTimer = 25000+rand()%10 * 1000;
258 } else ShriekTimer -= diff;
259
260 if (SaberTimer <= diff)
261 {
263 SaberTimer = 25000+rand()%10 * 1000;
264 } else SaberTimer -= diff;
265
266 //Enrage
267 if (!me->HasAura(SPELL_BERSERK))
268 {
269 if (EnrageTimer <= diff)
270 {
273 } else EnrageTimer -= diff;
274 }
275
276 //Random taunts
277 if (RandomYellTimer <= diff)
278 {
280 RandomYellTimer = std::rand() % (151*IN_MILLISECONDS) + (60*IN_MILLISECONDS);
281 } else RandomYellTimer -= diff;
282
284 }
285 };
286};
287
@ IN_MILLISECONDS
Definition Common.h:125
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
std::uint64_t uint64
Definition Define.h:76
@ IN_PROGRESS
@ DONE
@ NOT_STARTED
@ TYPEID_PLAYER
Definition Object.h:55
@ SELECT_TARGET_RANDOM
Definition UnitAI.h:23
@ SPELL_ENRAGE
@ DATA_MOTHER_SHAHRAZ
@ SAY_SLAY
#define SAY_DEATH
#define SAY_AGGRO
@ SAY_ENRAGE
#define SPELL_BERSERK
static Locations TeleportPoint[]
void AddSC_boss_mother_shahraz()
uint32 PrismaticAuras[]
@ SPELL_SABER_LASH
@ SPELL_ATTRACTION
@ SPELL_SILENCING_SHRIEK
@ SPELL_BEAM_WICKED
@ SPELL_TELEPORT_VISUAL
@ SPELL_BEAM_VILE
@ SPELL_BEAM_SINISTER
@ SPELL_BEAM_SINFUL
@ SPELL_BERSERK
@ SPELL_SABER_LASH_IMM
@ SPELL_TELEPORT_VISUAL
Definition chapter5.cpp:145
void DoZoneInCombat(Creature *creature=NULL, float maxRangeToNearestTarget=50.0f)
void Talk(uint8 id, WorldObject const *whisperTarget=NULL)
bool UpdateVictim()
CreatureScript(const char *name)
uint64 GetGUID() const
Definition Object.h:119
TypeID GetTypeId() const
Definition Object.h:131
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
void DoCastVictim(uint32 spellId, bool triggered=false)
Definition UnitAI.cpp:168
Definition Unit.h:1367
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, uint64 originalCaster=0)
bool IsAlive() const
Definition Unit.h:2032
static Unit * GetUnit(WorldObject &object, uint64 guid)
Definition Unit.cpp:4895
InstanceScript * GetInstanceScript()
Definition Object.cpp:1612
CreatureAI * GetAI(Creature *creature) const OVERRIDE
@ SAY_SPELL
float GetOrientation() const
Definition Object.h:331
Creature * me
void DoTeleportPlayer(Unit *unit, float x, float y, float z, float o)
bool HealthBelowPct(uint32 pct) const
ScriptedAI(Creature *creature)
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================