Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
boss_mechano_lord_capacitus.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"
9#include "mechanar.h"
10#include "Player.h"
11
30
39
41{
43};
44
56
58{
59 public:
60 boss_mechano_lord_capacitus() : CreatureScript("boss_mechano_lord_capacitus") { }
61
63 {
65
66 void EnterCombat(Unit* /*who*/) OVERRIDE
67 {
70 events.ScheduleEvent(EVENT_HEADCRACK, 10 * IN_MILLISECONDS);
73 events.ScheduleEvent(EVENT_BERSERK, 3 * MINUTE * IN_MILLISECONDS);
74
75 if (IsHeroic())
76 events.ScheduleEvent(EVENT_POSITIVE_SHIFT, 15 * IN_MILLISECONDS);
77 }
78
79 void KilledUnit(Unit* /*victim*/) OVERRIDE
80 {
82 }
83
84 void JustDied(Unit* /*victim*/) OVERRIDE
85 {
86 _JustDied();
88 }
89
91 {
92 if (!UpdateVictim())
93 return;
94
95 events.Update(diff);
96
97 if (me->HasUnitState(UNIT_STATE_CASTING))
98 return;
99
100 while (uint32 eventId = events.ExecuteEvent())
101 {
102 switch (eventId)
103 {
104 case EVENT_HEADCRACK:
106 events.ScheduleEvent(EVENT_HEADCRACK, 10 * IN_MILLISECONDS);
107 break;
112 break;
117 break;
120 events.ScheduleEvent(EVENT_POSITIVE_SHIFT, std::rand() % (60 * IN_MILLISECONDS) + (45 * IN_MILLISECONDS));
121 break;
123 Position pos;
124 me->GetRandomNearPosition(pos, 5.0f);
127 break;
128 case EVENT_BERSERK:
130 break;
131 default:
132 break;
133 }
134 }
135
137 }
138 };
139
141 {
142 return new boss_mechano_lord_capacitusAI(creature);
143 }
144};
145
147{
148 public:
149 spell_capacitus_polarity_charge() : SpellScriptLoader("spell_capacitus_polarity_charge") { }
150
152 {
154
155 bool Validate(SpellInfo const* /*spell*/) OVERRIDE
156 {
157 if (!sSpellMgr->GetSpellInfo(SPELL_POSITIVE_CHARGE))
158 return false;
159 if (!sSpellMgr->GetSpellInfo(SPELL_POSITIVE_CHARGE_STACK))
160 return false;
161 if (!sSpellMgr->GetSpellInfo(SPELL_NEGATIVE_CHARGE))
162 return false;
163 if (!sSpellMgr->GetSpellInfo(SPELL_NEGATIVE_CHARGE_STACK))
164 return false;
165 return true;
166 }
167
168 void HandleTargets(std::list<WorldObject*>& targetList)
169 {
170 uint8 count = 0;
171 for (std::list<WorldObject*>::iterator ihit = targetList.begin(); ihit != targetList.end(); ++ihit)
172 if ((*ihit)->GetGUID() != GetCaster()->GetGUID())
173 if (Player* target = (*ihit)->ToPlayer())
174 if (target->HasAura(GetTriggeringSpell()->Id))
175 ++count;
176
177 if (count)
178 {
179 uint32 spellId = 0;
180
183 else // if (GetSpellInfo()->Id == SPELL_NEGATIVE_CHARGE)
185
186 GetCaster()->SetAuraStack(spellId, GetCaster(), count);
187 }
188 }
189
190 void HandleDamage(SpellEffIndex /*effIndex*/)
191 {
192 if (!GetTriggeringSpell())
193 return;
194
195 Unit* target = GetHitUnit();
196
197 if (target->HasAura(GetTriggeringSpell()->Id))
198 SetHitDamage(0);
199 }
200
206 };
207
212};
213
215{
216 public:
217 spell_capacitus_polarity_shift() : SpellScriptLoader("spell_capacitus_polarity_shift") { }
218
220 {
222
223 bool Validate(SpellInfo const* /*spell*/) OVERRIDE
224 {
225 if (!sSpellMgr->GetSpellInfo(SPELL_POSITIVE_POLARITY) || !sSpellMgr->GetSpellInfo(SPELL_NEGATIVE_POLARITY))
226 return false;
227 return true;
228 }
229
230 void HandleDummy(SpellEffIndex /* effIndex */)
231 {
232 Unit* target = GetHitUnit();
233 Unit* caster = GetCaster();
234
235 target->CastSpell(target, roll_chance_i(50) ? SPELL_POSITIVE_POLARITY : SPELL_NEGATIVE_POLARITY, true, NULL, NULL, caster->GetGUID());
236 }
237
242 };
243
248};
249
@ IN_MILLISECONDS
Definition Common.h:125
@ MINUTE
Definition Common.h:119
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
@ TEMPSUMMON_TIMED_DESPAWN
Definition Object.h:70
SpellEffIndex
@ EFFECT_0
@ SPELL_EFFECT_DUMMY
@ SPELL_EFFECT_SCHOOL_DAMAGE
@ TARGET_UNIT_SRC_AREA_ALLY
#define sSpellMgr
Definition SpellMgr.h:744
#define SpellEffectFn(F, I, N)
#define SpellObjectAreaTargetSelectFn(F, I, N)
@ UNIT_STATE_CASTING
Definition Unit.h:527
bool roll_chance_i(int chance)
Definition Util.h:89
Creatures
@ YELL_AGGRO
@ YELL_KILL
@ YELL_DEATH
@ EVENT_NONE
#define SPELL_BERSERK
@ YELL_REFLECTIVE_DAMAGE_SHIELD
@ SPELL_REFLECTIVE_MAGIC_SHIELD
@ SPELL_REFLECTIVE_DAMAGE_SHIELD
void AddSC_boss_mechano_lord_capacitus()
@ EVENT_REFLECTIVE_DAMAGE_SHIELD
@ EVENT_REFLECTIVE_MAGIE_SHIELD
@ EVENT_BERSERK
@ SPELL_NEGATIVE_CHARGE
@ SPELL_POLARITY_SHIFT
@ SPELL_POSITIVE_CHARGE
@ SPELL_POSITIVE_POLARITY
@ SPELL_POSITIVE_CHARGE_STACK
@ SPELL_NEGATIVE_CHARGE_STACK
@ SPELL_NEGATIVE_POLARITY
EventMap events
BossAI(Creature *creature, uint32 bossId)
void _EnterCombat()
void Talk(uint8 id, WorldObject const *whisperTarget=NULL)
bool UpdateVictim()
CreatureScript(const char *name)
uint64 GetGUID() const
Definition Object.h:119
Player * ToPlayer()
Definition Object.h:204
SpellInfo const * GetSpellInfo()
HookList< EffectHandler > OnEffectHitTarget
Unit * GetHitUnit()
SpellInfo const * GetTriggeringSpell()
void SetHitDamage(int32 damage)
Unit * GetCaster()
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
SpellScriptLoader(const char *name)
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:28
void DoCast(uint32 spellId)
Definition UnitAI.cpp:110
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
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)
void SetAuraStack(uint32 spellId, Unit *target, uint32 stack)
bool HasAura(uint32 spellId, uint64 casterGUID=0, uint64 itemCasterGUID=0, uint32 reqEffMask=0) const
CreatureAI * GetAI(Creature *creature) const OVERRIDE
SpellScript * GetSpellScript() const OVERRIDE
SpellScript * GetSpellScript() const OVERRIDE
@ DATA_MECHANOLORD_CAPACITUS
Definition mechanar.h:15
bool IsHeroic() const
Creature * me
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================