Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
spell_mastery.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
7#include "Player.h"
8#include "ScriptMgr.h"
9#include "SpellScript.h"
10#include "SpellAuraEffects.h"
11
13{
17
21
25
29
33
37
41
45
49
53
56
58
66
71};
72
74{
76};
77
78// Warrior spell : Enrage 12880
80{
81public:
82 spell_mastery_unshackled_fury() : SpellScriptLoader("spell_mastery_unshackled_fury") { }
83
85 {
87
88 void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/)
89 {
90 if (Unit* caster = GetCaster()->ToPlayer())
91 {
92 if (caster->HasAura(MASTERY_WARRIOR_FURY) && caster->getLevel() >= 80)
93 amount = caster->GetFloatValue(PLAYER_FIELD_MASTERY) + caster->ToPlayer()->GetRatingBonusValue(CombatRating::CR_MASTERY);
94 }
95 }
96
101 };
102
107};
108
109// Called by Power Word : Shield - 17, Power Word : Shield (Divine Insight) - 123258, Spirit Shell - 114908, Angelic Bulwark - 114214 and Divine Aegis - 47753
110// Mastery : Shield Discipline - 77484
112{
113public:
114 spell_mastery_shield_discipline() : SpellScriptLoader("spell_mastery_shield_discipline") { }
115
117 {
119
120 void CalculateAmount(AuraEffect const*, int32& amount, bool&)
121 {
122 if (Unit* caster = GetCaster())
123 {
124 if (caster->HasAura(MASTERY_PRIEST_DISCIPLINE) && caster->getLevel() >= 80)
125 {
126 float Mastery = 1 + (caster->GetFloatValue(PLAYER_FIELD_MASTERY) * 2.5f / 100.0f);
127 amount = int32(amount * Mastery);
128 }
129 }
130 }
131
136 };
137
142};
143
144// Called by 100780 / 108557 / 115698 / 115687 / 115693 / 115695 - Jab (and overrides)
145// 115636 - Mastery : Combo Breaker
147{
148public:
149 spell_mastery_combo_breaker() : SpellScriptLoader("spell_mastery_combo_breaker") { }
150
152 {
154
156 {
157 if (Unit* caster = GetCaster())
158 {
159 if (Unit* target = GetHitUnit())
160 {
161 if (caster->GetTypeId() == TypeID::TYPEID_PLAYER && caster->HasAura(MASTERY_MONK_WINDWALKER))
162 {
163 float Mastery = caster->GetFloatValue(PLAYER_FIELD_MASTERY) * 1.4f;
164
165 if (roll_chance_f(Mastery))
166 {
167 if (roll_chance_i(50))
168 caster->CastSpell(caster, MASTERY_SPELL_COMBO_BREAKER_1, true);
169 else
170 caster->CastSpell(caster, MASTERY_SPELL_COMBO_BREAKER_2, true);
171 }
172 }
173 }
174 }
175 }
176
181 };
182
187};
188
189// Called by 45470 - Death Strike (Heal)
190// 77513 - Mastery : Blood Shield
192{
193public:
194 spell_mastery_blood_shield() : SpellScriptLoader("spell_mastery_blood_shield") { }
195
197 {
199
201 {
202 if (Player* _plr = GetCaster()->ToPlayer())
203 {
204 if (Unit* target = GetHitUnit())
205 {
206 if (_plr->GetTypeId() == TypeID::TYPEID_PLAYER && _plr->HasAura(77513) && _plr->getLevel() >= 80)
207 {
208 // Check the Mastery aura while in Blood presence
209 if (_plr->HasAura(77513) && _plr->HasAura(48263))
210 {
211 float Mastery = _plr->GetFloatValue(PLAYER_FIELD_MASTERY) * 6.25f / 100.0f;
212
213 int32 bp = -int32(GetHitDamage() * Mastery);
214
215 if (Aura* scentOfBlood = _plr->GetAura(SPELL_DK_SCENT_OF_BLOOD))
216 AddPct(bp, (scentOfBlood->GetStackAmount() * 20));
217
218 if (AuraEffect* bloodShield = target->GetAuraEffect(MASTERY_SPELL_BLOOD_SHIELD, EFFECT_0))
219 bp += bloodShield->GetAmount();
220
221 bp = std::min(uint32(bp), target->GetMaxHealth());
222
223 _plr->CastCustomSpell(target, MASTERY_SPELL_BLOOD_SHIELD, &bp, NULL, NULL, true);
224 }
225 }
226 }
227 }
228 }
229
234 };
235
240};
241
242// Called by 133 - Fireball, 44614 - Frostfire Bolt, 108853 - Inferno Blast, 2948 - Scorch and 11366 - Pyroblast
243// 12846 - Mastery : Ignite
245{
246public:
247 spell_mastery_ignite() : SpellScriptLoader("spell_mastery_ignite") { }
248
250 {
252
254 {
255 if (Unit* caster = GetCaster())
256 {
257 if (Unit* target = GetHitUnit())
258 {
259 if (caster->GetTypeId() == TypeID::TYPEID_PLAYER && caster->HasAura(12846) && caster->getLevel() >= 80)
260 {
261 uint32 procSpellId = GetSpellInfo()->Id ? GetSpellInfo()->Id : 0;
262 if (procSpellId != MASTERY_SPELL_IGNITE)
263 {
264 float value = caster->GetFloatValue(PLAYER_FIELD_MASTERY) * 1.5f / 100.0f;
265
266 int32 bp = GetHitDamage();
267 bp = int32(bp * value / 2);
268
269 if (target->HasAura(MASTERY_SPELL_IGNITE, caster->GetGUID()))
270 {
271 bp += target->GetRemainingPeriodicAmount(caster->GetGUID(), MASTERY_SPELL_IGNITE, SPELL_AURA_PERIODIC_DAMAGE);
272 bp = int32(bp * 0.66f);
273 }
274
275 caster->CastCustomSpell(target, MASTERY_SPELL_IGNITE, &bp, NULL, NULL, true);
276 }
277 }
278 }
279 }
280 }
281
286 };
287
292};
293
294// Called by 35395 - Crusader Strike, 53595 - Hammer of the Righteous, 24275 - Hammer of Wrath, 85256 - Templar's Verdict and 53385 - Divine Storm
295// 76672 - Mastery : Hand of Light
297{
298public:
299 spell_mastery_hand_of_light() : SpellScriptLoader("spell_mastery_hand_of_light") { }
300
302 {
304
306 {
307 if (Unit* caster = GetCaster())
308 {
309 if (Unit* target = GetHitUnit())
310 {
311 if (caster->GetTypeId() == TypeID::TYPEID_PLAYER && caster->HasAura(76672) && caster->getLevel() >= 80)
312 {
313 uint32 procSpellId = GetSpellInfo()->Id ? GetSpellInfo()->Id : 0;
314 if (procSpellId != MASTERY_SPELL_HAND_OF_LIGHT)
315 {
316 float value = caster->GetFloatValue(PLAYER_FIELD_MASTERY) * 1.85f;
317
318 int32 bp = int32(GetHitDamage() * value / 100);
319
320 caster->CastCustomSpell(target, MASTERY_SPELL_HAND_OF_LIGHT, &bp, NULL, NULL, true);
321 }
322 }
323 }
324 }
325 }
326
331 };
332
337};
338
339// Called by 403 - Lightning Bolt, 421 - Chain Lightning, 51505 - Lava Burst and 117014 - Elemental Blast
340// 77222 - Mastery : Elemental Overload
342{
343public:
344 spell_mastery_elemental_overload() : SpellScriptLoader("spell_mastery_elemental_overload") { }
345
347 {
349
350 bool Validate(SpellInfo const* /*spellEntry*/) OVERRIDE
351 {
352 if (!sSpellMgr->GetSpellInfo(403) || !sSpellMgr->GetSpellInfo(421) || !sSpellMgr->GetSpellInfo(51505) || !sSpellMgr->GetSpellInfo(117014))
353 return false;
354 return true;
355 }
356
358 {
359 SpellInfo const* procSpell = GetSpellInfo();
360
361 if (procSpell)
362 {
363 if (Unit* caster = GetCaster())
364 {
365 if (Unit* unitTarget = GetHitUnit())
366 {
367 if (caster->GetTypeId() == TypeID::TYPEID_PLAYER && caster->HasAura(77222))
368 {
369 // Every Lightning Bolt, Chain Lightning and Lava Burst spells have duplicate vs 75% damage and no cost
370 switch (procSpell->Id)
371 {
372 // Lava Burst
373 case 51505:
374 {
375 float Mastery = caster->GetFloatValue(PLAYER_FIELD_MASTERY) * 2.0f;
376
377 if (roll_chance_f(Mastery))
378 caster->CastSpell(unitTarget, MASTERY_SPELL_LAVA_BURST, true);
379
380 break;
381 }
382 // Lightning Bolt
383 case 403:
384 {
385 float Mastery = caster->GetFloatValue(PLAYER_FIELD_MASTERY) * 2.0f;
386
387 if (roll_chance_f(Mastery))
388 caster->CastSpell(unitTarget, MASTERY_SPELL_LIGHTNING_BOLT, true);
389
390 break;
391 }
392 // Chain Lightning
393 case 421:
394 {
395 float Mastery = caster->GetFloatValue(PLAYER_FIELD_MASTERY) * 2.0f;
396
397 if (roll_chance_f(Mastery))
398 caster->CastSpell(unitTarget, MASTERY_SPELL_CHAIN_LIGHTNING, true);
399
400 break;
401 }
402 // Elemental Blast
403 case 117014:
404 {
405 float Mastery = caster->GetFloatValue(PLAYER_FIELD_MASTERY) * 2.0f;
406
407 if (roll_chance_f(Mastery))
408 {
409 caster->CastSpell(unitTarget, MASTERY_SPELL_ELEMENTAL_BLAST, true);
410 caster->CastSpell(unitTarget, 118517, true); // Nature visual
411 caster->CastSpell(unitTarget, 118515, true); // Frost visual
412 }
413
414 break;
415 }
416 default: break;
417 }
418 }
419 }
420 }
421 }
422 }
423
428 };
429
434};
435
std::int32_t int32
Definition Define.h:73
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
@ TYPEID_PLAYER
Definition Object.h:55
@ EFFECT_1
@ EFFECT_0
@ SPELL_AURA_PERIODIC_DAMAGE
@ SPELL_AURA_MOD_DAMAGE_PERCENT_DONE
@ SPELL_AURA_SCHOOL_ABSORB
#define sSpellMgr
Definition SpellMgr.h:744
#define AuraEffectCalcAmountFn(F, I, N)
#define SpellHitFn(F)
@ CR_MASTERY
Definition Unit.h:606
@ PLAYER_FIELD_MASTERY
bool roll_chance_f(float chance)
Definition Util.h:83
bool roll_chance_i(int chance)
Definition Util.h:89
T AddPct(T &base, U pct)
Definition Util.h:109
HookList< EffectCalcAmountHandler > DoEffectCalcAmount
Unit * GetCaster() const
uint32 Id
Definition SpellInfo.h:160
HookList< HitHandler > AfterHit
SpellInfo const * GetSpellInfo()
HookList< HitHandler > OnHit
Unit * GetHitUnit()
Unit * GetCaster()
int32 GetHitDamage()
SpellScriptLoader(const char *name)
Definition Unit.h:1367
PrepareSpellScript(spell_mastery_blood_shield_SpellScript)
SpellScript * GetSpellScript() const OVERRIDE
PrepareSpellScript(spell_mastery_combo_breaker_SpellScript)
SpellScript * GetSpellScript() const OVERRIDE
SpellScript * GetSpellScript() const OVERRIDE
PrepareSpellScript(spell_mastery_hand_of_light_SpellScript)
SpellScript * GetSpellScript() const OVERRIDE
PrepareSpellScript(spell_mastery_ignite_SpellScript)
SpellScript * GetSpellScript() const OVERRIDE
AuraScript * GetAuraScript() const OVERRIDE
void CalculateAmount(AuraEffect const *, int32 &amount, bool &)
AuraScript * GetAuraScript() const OVERRIDE
@ SPELL_DK_SCENT_OF_BLOOD
Definition spell_dk.cpp:45
@ SPELL_WARR_ENRAGE
void AddSC_masteries_spell_scripts()
MasterySpells
@ MASTERY_DRUID_GUARDIAN
@ MASTERY_MAGE_FROST
@ MASTERY_WARLOCK_DESTRUCTION
@ MASTERY_MONK_BREWMASTER
@ MASTERY_SPELL_CHAIN_LIGHTNING
@ MASTERY_SHAMAN_ENHANCEMENT
@ MASTERY_SPELL_COMBO_BREAKER_1
@ MASTERY_ROGUE_ASSASSINATION
@ MASTERY_MONK_MISTWEAVER
@ MASTERY_WARRIOR_PROTECTION
@ MASTERY_SHAMAN_ELEMENTAL
@ MASTERY_SPELL_BLOOD_SHIELD
@ MASTERY_MAGE_ARCANE
@ MASTERY_PRIEST_HOLY
@ MASTERY_PRIEST_SHADOW
@ MASTERY_MAGE_FIRE
@ MASTERY_HUNTER_SURVIVAL
@ MASTERY_WARRIOR_FURY
@ MASTERY_DRUID_RESTORATION
@ MASTERY_WARRIOR_ARMS
@ MASTERY_SPELL_LIGHTNING_BOLT
@ MASTERY_WARLOCK_AFFLICTION
@ MASTERY_SPELL_LAVA_BURST
@ MASTERY_SPELL_ELEMENTAL_BLAST
@ MASTERY_SPELL_HAND_OF_LIGHT
@ MASTERY_PALADIN_HOLY
@ MASTERY_ROGUE_SUBTLETY
@ MASTERY_DRUID_BALANCE
@ MASTERY_PRIEST_DISCIPLINE
@ MASTERY_DEATHKNIGHT_BLOOD
@ SPELL_DK_SCENT_OF_BLOOD
@ MASTERY_SHAMAN_RESTORATION
@ MASTERY_HUNTER_BEASTMASTER
@ MASTERY_WARLOCK_DEMONOLOGY
@ MASTERY_PALADIN_PROTECTION
@ MASTERY_HUNTER_MARKSMAN
@ MASTERY_PALADIN_RETRIBUTION
@ MASTERY_ROGUE_COMBAT
@ MASTERY_SPELL_COMBO_BREAKER_2
@ MASTERY_MONK_WINDWALKER
@ MASTERY_DEATHKNIGHT_UNHOLY
@ MASTERY_DEATHKNIGHT_FROST
@ MASTERY_SPELL_IGNITE
@ MASTERY_DRUID_FERAL