Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
boss_skeram.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#include "ScriptMgr.h"
7#include "ScriptedCreature.h"
8#include "SpellScript.h"
10
12{
17};
18
27
35
36uint32 const BlinkSpells[3] = { 4801, 8195, 20449 };
37
39{
40 public:
41 boss_skeram() : CreatureScript("boss_skeram") { }
42
43 struct boss_skeramAI : public BossAI
44 {
45 boss_skeramAI(Creature* creature) : BossAI(creature, DATA_SKERAM) { }
46
48 {
49 _flag = 0;
50 _hpct = 75.0f;
51 me->SetVisible(true);
52 }
53
54 void KilledUnit(Unit* /*victim*/) OVERRIDE
55 {
57 }
58
60 {
62 if (me->IsSummon())
63 ((TempSummon*)me)->UnSummon();
64 }
65
67 {
68 // Shift the boss and images (Get it? *Shift*?)
69 uint8 rand = 0;
70 if (_flag != 0)
71 {
72 while (_flag & (1 << rand))
73 rand = std::rand() % 2;
74 DoCast(me, BlinkSpells[rand]);
75 _flag |= (1 << rand);
76 _flag |= (1 << 7);
77 }
78
79 while (_flag & (1 << rand))
80 rand = std::rand() % 2;
81 creature->CastSpell(creature, BlinkSpells[rand]);
82 _flag |= (1 << rand);
83
84 if (_flag & (1 << 7))
85 _flag = 0;
86
88 creature->AI()->AttackStart(Target);
89
90 float ImageHealthPct;
91
92 if (me->GetHealthPct() < 25.0f)
93 ImageHealthPct = 0.50f;
94 else if (me->GetHealthPct() < 50.0f)
95 ImageHealthPct = 0.20f;
96 else
97 ImageHealthPct = 0.10f;
98
99 creature->SetMaxHealth(me->GetMaxHealth() * ImageHealthPct);
100 creature->SetHealth(creature->GetMaxHealth() * (me->GetHealthPct() / 100.0f));
101 }
102
103 void JustDied(Unit* /*killer*/) OVERRIDE
104 {
105 if (!me->IsSummon())
107 else
108 me->RemoveCorpse();
109 }
110
111 void EnterCombat(Unit* /*who*/) OVERRIDE
112 {
113 _EnterCombat();
114 events.Reset();
115
116 events.ScheduleEvent(EVENT_ARCANE_EXPLOSION, std::rand() % 12000 + 6000);
117 events.ScheduleEvent(EVENT_FULLFILMENT, 15000);
118 events.ScheduleEvent(EVENT_BLINK, std::rand() % 45000 + 30000);
119 events.ScheduleEvent(EVENT_EARTH_SHOCK, 2000);
120
122 }
123
125 {
126 if (!UpdateVictim())
127 return;
128
129 events.Update(diff);
130
131 while (uint32 eventId = events.ExecuteEvent())
132 {
133 switch (eventId)
134 {
137 events.ScheduleEvent(EVENT_ARCANE_EXPLOSION, std::rand() % 18000 + 8000);
138 break;
141 // Spell actually works, tested in duel
143 events.ScheduleEvent(EVENT_FULLFILMENT, std::rand() % 30000 + 20000);
144 break;
145 case EVENT_BLINK:
146 DoCast(me, BlinkSpells[std::rand() % 2]);
148 me->SetVisible(true);
149 events.ScheduleEvent(EVENT_BLINK, std::rand() % 30000 + 10000);
150 break;
153 events.ScheduleEvent(EVENT_EARTH_SHOCK, 2000);
154 break;
155 }
156 }
157
158 if (!me->IsSummon() && me->GetHealthPct() < _hpct)
159 {
162 _hpct -= 25.0f;
163 me->SetVisible(false);
164 events.RescheduleEvent(EVENT_BLINK, 2000);
165 }
166
167 if (me->IsWithinMeleeRange(me->GetVictim()))
168 {
169 events.RescheduleEvent(EVENT_EARTH_SHOCK, 2000);
171 }
172 }
173
174 private:
175 float _hpct;
177 };
178
180 {
181 return new boss_skeramAI(creature);
182 }
183};
184
186{
187 public:
188 bool operator()(WorldObject* object) const
189 {
190 if (object->GetTypeId() != TypeID::TYPEID_PLAYER)
191 if (!object->ToCreature()->IsPet())
192 return true;
193
194 return false;
195 }
196};
197
223
225{
226 new boss_skeram();
228}
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
@ TYPEID_PLAYER
Definition Object.h:55
@ EFFECT_0
@ TARGET_UNIT_SRC_AREA_ENEMY
#define SpellObjectAreaTargetSelectFn(F, I, N)
@ SELECT_TARGET_RANDOM
Definition UnitAI.h:23
@ SAY_SLAY
@ SPELL_ARCANE_EXPLOSION
#define SAY_DEATH
#define SAY_AGGRO
@ SAY_SPLIT
@ EVENT_BLINK
@ EVENT_ARCANE_EXPLOSION
uint32 const BlinkSpells[3]
@ SAY_DEATH
@ SAY_AGGRO
@ SAY_SPLIT
@ SAY_SLAY
@ SPELL_TRUE_FULFILLMENT
@ SPELL_SUMMON_IMAGES
@ SPELL_ARCANE_EXPLOSION
@ SPELL_INITIALIZE_IMAGE
@ SPELL_EARTH_SHOCK
void AddSC_boss_skeram()
@ EVENT_BLINK
@ EVENT_ARCANE_EXPLOSION
@ EVENT_EARTH_SHOCK
@ EVENT_FULLFILMENT
EventMap events
BossAI(Creature *creature, uint32 bossId)
void _EnterCombat()
void Talk(uint8 id, WorldObject const *whisperTarget=NULL)
bool UpdateVictim()
virtual void EnterEvadeMode()
CreatureScript(const char *name)
TypeID GetTypeId() const
Definition Object.h:131
Creature * ToCreature()
Definition Object.h:207
bool operator()(WorldObject *object) const
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
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
void DoCastVictim(uint32 spellId, bool triggered=false)
Definition UnitAI.cpp:168
void DoCastAOE(uint32 spellId, bool triggered=false)
Definition UnitAI.cpp:176
Definition Unit.h:1367
bool IsPet() const
Definition Unit.h:1511
CreatureAI * GetAI(Creature *creature) const OVERRIDE
SpellScript * GetSpellScript() const OVERRIDE
Creature * me
boss_skeramAI(Creature *creature)
void JustSummoned(Creature *creature) OVERRIDE
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
void EnterEvadeMode() OVERRIDE
void KilledUnit(Unit *) OVERRIDE
void EnterCombat(Unit *) OVERRIDE
void JustDied(Unit *) OVERRIDE
@ DATA_SKERAM