TrinityCore
Loading...
Searching...
No Matches
boss_mechano_lord_capacitus.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 "Containers.h"
20#include "GridNotifiers.h"
21#include "mechanar.h"
22#include "Player.h"
23#include "ScriptedCreature.h"
24#include "SpellInfo.h"
25#include "SpellScript.h"
26
35
60
70
71// 19219 - Mechano-Lord Capacitus
73{
75
96
97 void OnSpellStart(SpellInfo const* spellInfo) override
98 {
99 switch (spellInfo->Id)
100 {
102 if (roll_chance_i(30))
104 break;
106 if (roll_chance_i(30))
108 break;
109 default:
110 break;
111 }
112 }
113
114 void OnSpellCast(SpellInfo const* spellInfo) override
115 {
116 switch (spellInfo->Id)
117 {
121 if (roll_chance_i(30))
123 break;
127 if (roll_chance_i(30))
129 break;
130 default:
131 break;
132 }
133 }
134
135 void KilledUnit(Unit* /*victim*/) override
136 {
137 Talk(SAY_SLAY);
138 }
139
140 void JustDied(Unit* /*killer*/) override
141 {
142 _JustDied();
144 }
145
146 void UpdateAI(uint32 diff) override
147 {
148 if (!UpdateVictim())
149 return;
150
151 events.Update(diff);
152
154 return;
155
156 while (uint32 eventId = events.ExecuteEvent())
157 {
158 switch (eventId)
159 {
160 case EVENT_HEAD_CRACK:
162 events.Repeat(20s, 40s);
163 break;
166 break;
169 break;
172 events.Repeat(25s, 30s);
173 break;
176 events.Repeat(1s, 4s);
177 break;
178 case EVENT_BERSERK:
180 break;
181 default:
182 break;
183 }
184
186 return;
187 }
188
190 }
191};
192
193// 39096 - Polarity Shift
195{
197
202
203 void FilterTargets(std::list<WorldObject*>& targets)
204 {
205 if (targets.empty())
206 return;
207
208 std::vector<WorldObject*> shuffledTargets(targets.begin(), targets.end());
209 Trinity::Containers::RandomShuffle(shuffledTargets);
210
211 targets.assign(shuffledTargets.begin(), shuffledTargets.end());
212 }
213
214 void HandleDummy(SpellEffIndex /*effIndex*/)
215 {
216 Unit* target = GetHitUnit();
217
222
223 // In sniffs two or even three targets in a row can receive same buff, so current handling is not entirely correct. Just a small detail
226
227 ++_targetIndex;
228 }
229
235
236private:
238};
239
240// 39088 - Positive Charge
241// 39091 - Negative Charge
263
264// 39090 - Positive Charge
265// 39093 - Negative Charge
267{
269
270 bool Validate(SpellInfo const* /*spellInfo*/) override
271 {
272 return ValidateSpellInfo(
273 {
278 });
279 }
280
281 void FilterTargets(std::list<WorldObject*>& targets)
282 {
283 if (!GetTriggeringSpell())
284 return;
285
286 _targetCount = targets.size();
287 targets.remove_if(Trinity::UnitAuraCheck(true, GetTriggeringSpell()->Id));
288 _targetCount -= targets.size();
289 }
290
292 {
293 if (!_targetCount)
294 return;
295
296 uint32 spellId = 0;
297
302
303 if (!spellId)
304 return;
305
307
308 GetCaster()->CastSpell(nullptr, spellId, CastSpellExtraArgs()
309 .SetTriggerFlags(TRIGGERED_FULL_MASK)
310 .AddSpellMod(SPELLVALUE_AURA_STACK, _targetCount));
311 }
312
318
319private:
321};
322
First const & RAND(First const &first, Second const &second, Rest const &... rest)
uint32_t uint32
Definition Define.h:133
bool roll_chance_i(int chance)
Definition Random.h:59
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
SpellEffIndex
@ EFFECT_0
@ SPELL_EFFECT_DUMMY
@ TARGET_UNIT_SRC_AREA_ALLY
@ TARGET_UNIT_SRC_AREA_ENEMY
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_DUMMY
@ TRIGGERED_FULL_MASK
Will return SPELL_FAILED_DONT_REPORT in CheckCast functions.
@ SPELLVALUE_AURA_STACK
#define SpellEffectFn(F, I, N)
#define SpellObjectAreaTargetSelectFn(F, I, N)
#define SpellCastFn(F)
#define AuraEffectRemoveFn(F, I, N, M)
@ UNIT_STATE_CASTING
Definition Unit.h:249
@ SPELL_SUMMON_NETHER_CHARGE_NE
@ SPELL_SUMMON_NETHER_CHARGE_SE
@ SPELL_SUMMON_NETHER_CHARGE_SW
@ SPELL_NEGATIVE_CHARGE_PERIODIC
@ SPELL_SUMMON_NETHER_CHARGE_NW
@ SPELL_POSITIVE_CHARGE_PERIODIC
void AddSC_boss_mechano_lord_capacitus()
HookList< EffectApplyHandler > AfterEffectRemove
Unit * GetTarget() const
void JustEngagedWith(Unit *who) override
EventMap events
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void Update(uint32 time)
Definition EventMap.h:67
void Repeat(Milliseconds time)
Definition EventMap.cpp:63
EventId ExecuteEvent()
Definition EventMap.cpp:73
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
uint32 Id
Definition SpellInfo.h:289
HookList< CastHandler > AfterCast
Unit * GetCaster() const
SpellInfo const * GetTriggeringSpell() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
SpellInfo const * GetSpellInfo() const
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:241
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:166
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:243
Definition Unit.h:783
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:4558
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3807
bool HasUnitState(const uint32 f) const
Definition Unit.h:890
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2833
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
PrepareSpellScript(spell_capacitus_polarity_charge_damage)
void FilterTargets(std::list< WorldObject * > &targets)
PrepareAuraScript(spell_capacitus_polarity_charge_periodic)
void AfterRemove(AuraEffect const *, AuraEffectHandleModes)
bool Validate(SpellInfo const *) override
void FilterTargets(std::list< WorldObject * > &targets)
PrepareSpellScript(spell_capacitus_polarity_shift)
@ DATA_MECHANOLORD_CAPACITUS
Definition mechanar.h:32
#define RegisterMechanarCreatureAI(ai_name)
Definition mechanar.h:50
void RandomShuffle(C &container)
Reorder the elements of the container randomly.
Definition Containers.h:166
CastSpellExtraArgs & SetOriginalCaster(ObjectGuid const &guid)
bool IsHeroic() const
void OnSpellStart(SpellInfo const *spellInfo) override
void OnSpellCast(SpellInfo const *spellInfo) override