Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
spell_warlock.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 * Scripts for spells with SPELLFAMILY_WARLOCK and SPELLFAMILY_GENERIC spells used by warlock players.
8 * Ordered alphabetically using scriptname.
9 * Scriptnames of files in this file should be prefixed with "spell_warl_".
10 */
11
12#include "Player.h"
13#include "ScriptMgr.h"
14#include "SpellScript.h"
15#include "SpellAuraEffects.h"
16#include "SpellAuras.h"
17
45
51
57
58// 111546 - Chaotic Energy
60{
61public:
62 spell_warl_chaotic_energy() : SpellScriptLoader("spell_warl_chaotic_energy") { }
63
65 {
67
68 void HandleEffectCalcSpellMod(AuraEffect const* aurEff, SpellModifier*& spellMod)
69 {
70 if (!spellMod)
71 {
72 spellMod = new SpellModifier(GetAura());
73 spellMod->op = SPELLMOD_COST;
74 spellMod->type = SPELLMOD_PCT;
75 spellMod->spellId = GetId();
76 spellMod->mask = GetSpellInfo()->Effects[aurEff->GetEffIndex()].SpellClassMask;
77 }
78
79 spellMod->value = (float)(aurEff->GetAmount() / 100);
80 }
81
86 };
87
92};
93
94// 710 - Banish
96{
97public:
98 spell_warl_banish() : SpellScriptLoader("spell_warl_banish") { }
99
101 {
103
105 {
106 _removed = false;
107 return true;
108 }
109
111 {
114 if (Unit* target = GetHitUnit())
115 {
116 if (target->GetAuraEffect(SPELL_AURA_SCHOOL_IMMUNITY, SPELLFAMILY_WARLOCK, 0, 0x08000000, 0))
117 {
118 // No need to remove old aura since its removed due to not stack by current Banish aura
122 _removed = true;
123 }
124 }
125 }
126
128 {
129 if (_removed)
131 }
132
138
140 };
141
143 {
145 }
146};
147
148// 48018 - Demonic Circle: Summon
151{
152public:
153 spell_warl_demonic_circle_summon() : SpellScriptLoader("spell_warl_demonic_circle_summon") { }
154
156 {
158
159 void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes mode)
160 {
161 // If effect is removed by expire remove the summoned demonic circle too.
162 if (!(mode & AURA_EFFECT_HANDLE_REAPPLY))
163 GetTarget()->RemoveGameObject(GetId(), true);
164
166 }
167
168 void HandleDummyTick(AuraEffect const* /*aurEff*/)
169 {
170 if (GameObject* circle = GetTarget()->GetGameObject(GetId()))
171 {
172 // Here we check if player is in demonic circle teleport range, if so add
173 // WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST; allowing him to cast the WARLOCK_DEMONIC_CIRCLE_TELEPORT.
174 // If not in range remove the WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST.
175
176 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(SPELL_WARLOCK_DEMONIC_CIRCLE_TELEPORT);
177
178 if (GetTarget()->IsWithinDist(circle, spellInfo->GetMaxRange(true)))
179 {
182 }
183 else
185 }
186 }
187
193 };
194
199};
200
201// 48020 - Demonic Circle: Teleport
204{
205public:
206 spell_warl_demonic_circle_teleport() : SpellScriptLoader("spell_warl_demonic_circle_teleport") { }
207
209 {
211
212 void HandleTeleport(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
213 {
214 if (Player* player = GetTarget()->ToPlayer())
215 {
217 {
218 player->NearTeleportTo(circle->GetPositionX(), circle->GetPositionY(), circle->GetPositionZ(), circle->GetOrientation());
219 player->RemoveMovementImpairingAuras();
220 }
221 }
222 }
223
228 };
229
234};
235
236// -47230 - Fel Synergy
238{
239public:
240 spell_warl_fel_synergy() : SpellScriptLoader("spell_warl_fel_synergy") { }
241
243 {
245
246 bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE
247 {
248 if (!sSpellMgr->GetSpellInfo(SPELL_WARLOCK_FEL_SYNERGY_HEAL))
249 return false;
250 return true;
251 }
252
253 bool CheckProc(ProcEventInfo& eventInfo)
254 {
255 return GetTarget()->GetGuardianPet() && eventInfo.GetDamageInfo()->GetDamage();
256 }
257
258 void OnProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
259 {
261
262 int32 heal = CalculatePct(int32(eventInfo.GetDamageInfo()->GetDamage()), aurEff->GetAmount());
263 GetTarget()->CastCustomSpell(SPELL_WARLOCK_FEL_SYNERGY_HEAL, SPELLVALUE_BASE_POINT0, heal, (Unit*)NULL, true, NULL, aurEff); // TARGET_UNIT_PET
264 }
265
271 };
272
277};
278
279// 6262 - Healthstone
306
307// 1454 - Life Tap
310{
311public:
312 spell_warl_life_tap() : SpellScriptLoader("spell_warl_life_tap") { }
313
315 {
317
319 {
321 }
322
323 bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE
324 {
325 if (!sSpellMgr->GetSpellInfo(SPELL_WARLOCK_LIFE_TAP_ENERGIZE))
326 return false;
327 return true;
328 }
329
330 void HandleDummy(SpellEffIndex /*effIndex*/)
331 {
332 Player* caster = GetCaster()->ToPlayer();
333 if (Unit* target = GetHitUnit())
334 {
335 int32 damage = caster->CountPctFromMaxHealth(GetSpellInfo()->Effects[EFFECT_2].CalcValue());
336 int32 mana = CalculatePct(damage, GetSpellInfo()->Effects[EFFECT_1].CalcValue());
337
338 // Shouldn't Appear in Combat Log
339 target->ModifyHealth(-damage);
340
341 // Improved Life Tap mod
343 AddPct(mana, aurEff->GetAmount());
344
345 caster->CastCustomSpell(target, SPELL_WARLOCK_LIFE_TAP_ENERGIZE, &mana, NULL, NULL, false);
346 }
347 }
348
350 {
351 if (int32(GetCaster()->GetHealth()) > int32(GetCaster()->CountPctFromMaxHealth(GetSpellInfo()->Effects[EFFECT_2].CalcValue())))
354 }
355
361 };
362
367};
368
369// 27285 - Seed of Corruption
397
398// 108558 - Nightfall
400{
401public:
402 spell_warl_shadow_trance_proc() : SpellScriptLoader("spell_warl_shadow_trance_proc") { }
403
405 {
407
408 bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE
409 {
410 if (!sSpellMgr->GetSpellInfo(SPELL_WARLOCK_SHADOW_TRANCE))
411 return false;
412 return true;
413 }
414
415 void OnProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/)
416 {
418
419 // get shadow trace proc chance
420 int32 procChance = std::max(aurEff->GetAmount(), 0);
421
422 if (roll_chance_i(procChance))
423 GetTarget()->CastSpell(GetTarget(), SPELL_WARLOCK_SHADOW_TRANCE, true, NULL, aurEff);
424 }
425
430 };
431
436};
437
438// 86121 - Soul Swap
473
474// 86211 - Soul Swap Override - Also acts as a dot container
476{
477public:
478 spell_warl_soul_swap_override() : SpellScriptLoader("spell_warl_soul_swap_override") { }
479
481 {
483
485 {
486 _swapCaster = NULL;
487 return true;
488 }
489
492
493 public:
494 void AddDot(uint32 id) { _dotList.push_back(id); }
495 std::list<uint32> const GetDotList() const { return _dotList; }
497 void SetOriginalSwapSource(Unit* victim) { _swapCaster = victim; }
498
499 private:
500 std::list<uint32> _dotList;
502 };
503
508};
509
511
514{
515public:
516 spell_warl_soul_swap_dot_marker() : SpellScriptLoader("spell_warl_soul_swap_dot_marker") { }
517
519 {
521
523 {
524 Unit* swapVictim = GetCaster();
525 Unit* warlock = GetHitUnit();
526 if (!warlock || !swapVictim)
527 return;
528
529 flag128 classMask = GetSpellInfo()->Effects[effIndex].SpellClassMask;
530
531 Unit::AuraApplicationMap const& appliedAuras = swapVictim->GetAppliedAuras();
532 SoulSwapOverrideAuraScript* swapSpellScript = NULL;
533 if (Aura* swapOverrideAura = warlock->GetAura(SPELL_WARLOCK_SOUL_SWAP_OVERRIDE))
534 swapSpellScript = dynamic_cast<SoulSwapOverrideAuraScript*>(swapOverrideAura->GetScriptByName("spell_warl_soul_swap_override"));
535
536 if (swapSpellScript == NULL)
537 return;
538
539 for (Unit::AuraApplicationMap::const_iterator itr = appliedAuras.begin(); itr != appliedAuras.end(); ++itr)
540 {
541 SpellInfo const* spellProto = itr->second->GetBase()->GetSpellInfo();
542 if (itr->second->GetBase()->GetCaster() == warlock)
543 if (spellProto->SpellFamilyName == SPELLFAMILY_WARLOCK && (spellProto->SpellFamilyFlags & classMask))
544 swapSpellScript->AddDot(itr->first);
545 }
546
547 swapSpellScript->SetOriginalSwapSource(swapVictim);
548 }
549
554 };
555
560};
561
562// 86213 - Soul Swap Exhale
564{
565public:
566 spell_warl_soul_swap_exhale() : SpellScriptLoader("spell_warl_soul_swap_exhale") { }
567
569 {
571
572 bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE
573 {
574 if (!sSpellMgr->GetSpellInfo(SPELL_WARLOCK_SOUL_SWAP_MOD_COST) ||
576 return false;
577 return true;
578 }
579
581 {
582 Unit* currentTarget = GetExplTargetUnit();
583 Unit* swapTarget = NULL;
584 if (Aura const* swapOverride = GetCaster()->GetAura(SPELL_WARLOCK_SOUL_SWAP_OVERRIDE))
585 if (SoulSwapOverrideAuraScript* swapScript = dynamic_cast<SoulSwapOverrideAuraScript*>(swapOverride->GetScriptByName("spell_warl_soul_swap_override")))
586 swapTarget = swapScript->GetOriginalSwapSource();
587
588 // Soul Swap Exhale can't be cast on the same target than Soul Swap
589 if (swapTarget && currentTarget && swapTarget == currentTarget)
591
593 }
594
595 void OnEffectHit(SpellEffIndex /*effIndex*/)
596 {
598
599 std::list<uint32> dotList;
600 Unit* swapSource = NULL;
601 if (Aura const* swapOverride = GetCaster()->GetAura(SPELL_WARLOCK_SOUL_SWAP_OVERRIDE))
602 {
603 SoulSwapOverrideAuraScript* swapScript = dynamic_cast<SoulSwapOverrideAuraScript*>(swapOverride->GetScriptByName("spell_warl_soul_swap_override"));
604 if (!swapScript)
605 return;
606 dotList = swapScript->GetDotList();
607 swapSource = swapScript->GetOriginalSwapSource();
608 }
609
610 if (dotList.empty())
611 return;
612
613 for (std::list<uint32>::const_iterator itr = dotList.begin(); itr != dotList.end(); ++itr)
614 {
615 GetCaster()->AddAura(*itr, GetHitUnit());
616 if (swapSource)
617 swapSource->RemoveAurasDueToSpell(*itr);
618 }
619
620 // Remove Soul Swap Exhale buff
622 }
623
629 };
630
635};
636
637// 29858 - Soulshatter
640{
641public:
642 spell_warl_soulshatter() : SpellScriptLoader("spell_warl_soulshatter") { }
643
645 {
647
648 bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE
649 {
650 if (!sSpellMgr->GetSpellInfo(SPELL_WARLOCK_SOULSHATTER))
651 return false;
652 return true;
653 }
654
655 void HandleDummy(SpellEffIndex /*effIndex*/)
656 {
657 Unit* caster = GetCaster();
658 if (Unit* target = GetHitUnit())
659 if (target->CanHaveThreatList() && target->getThreatManager().getThreat(caster) > 0.0f)
660 caster->CastSpell(target, SPELL_WARLOCK_SOULSHATTER, true);
661 }
662
667 };
668
673};
674
675// 30108, 34438, 34439, 35183 - Unstable Affliction
678{
679public:
680 spell_warl_unstable_affliction() : SpellScriptLoader("spell_warl_unstable_affliction") { }
681
683 {
685
686 bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE
687 {
689 return false;
690 return true;
691 }
692
693 void HandleDispel(DispelInfo* dispelInfo)
694 {
695 if (Unit* caster = GetCaster())
696 if (AuraEffect const* aurEff = GetEffect(EFFECT_1))
697 {
698 int32 damage = aurEff->GetAmount() * 9;
699 // backfire damage and silence
700 caster->CastCustomSpell(dispelInfo->GetDispeller(), SPELL_WARLOCK_UNSTABLE_AFFLICTION_DISPEL, &damage, NULL, NULL, true, NULL, aurEff);
701 }
702 }
703
708 };
709
714};
715
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
@ SPELLMOD_PCT
Definition Player.h:67
SpellEffIndex
@ EFFECT_1
@ EFFECT_0
@ EFFECT_2
@ SPELL_EFFECT_DUMMY
@ SPELL_EFFECT_SCHOOL_DAMAGE
@ TARGET_UNIT_DEST_AREA_ENEMY
@ SPELLFAMILY_WARLOCK
SpellCastResult
@ SPELL_AURA_ADD_PCT_MODIFIER
@ SPELL_AURA_DUMMY
@ SPELL_AURA_SCHOOL_IMMUNITY
@ SPELL_AURA_MECHANIC_IMMUNITY
@ SPELL_AURA_PERIODIC_DUMMY
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK
@ AURA_EFFECT_HANDLE_REAPPLY
@ AURA_EFFECT_HANDLE_REAL
#define sSpellMgr
Definition SpellMgr.h:744
#define SpellCheckCastFn(F)
#define AuraEffectProcFn(F, I, N)
#define SpellEffectFn(F, I, N)
#define SpellObjectAreaTargetSelectFn(F, I, N)
#define AuraEffectPeriodicFn(F, I, N)
#define AuraEffectApplyFn(F, I, N, M)
#define AuraCheckProcFn(F)
#define SpellHitFn(F)
#define AuraEffectCalcSpellModFn(F, I, N)
#define AuraDispelFn(F)
@ SPELLMOD_COST
Definition Unit.h:87
@ SPELLVALUE_BASE_POINT0
Definition Unit.h:114
bool roll_chance_i(int chance)
Definition Util.h:89
T AddPct(T &base, U pct)
Definition Util.h:109
T CalculatePct(T base, U pct)
Definition Util.h:103
uint32 GetEffIndex() const
int32 GetAmount() const
void PreventDefaultAction()
HookList< EffectPeriodicHandler > OnEffectPeriodic
SpellInfo const * GetSpellInfo() const
Unit * GetCaster() const
HookList< EffectCalcSpellModHandler > DoEffectCalcSpellMod
AuraEffect * GetEffect(uint8 effIndex) const
Aura * GetAura() const
Unit * GetTarget() const
HookList< CheckProcHandler > DoCheckProc
HookList< EffectApplyHandler > OnEffectRemove
HookList< AuraDispelHandler > AfterDispel
HookList< EffectProcHandler > OnEffectProc
HookList< EffectApplyHandler > OnEffectApply
uint32 GetId() const
uint32 GetDamage() const
Definition Unit.h:923
Unit * GetDispeller() const
Definition Unit.h:840
static GameObject * GetGameObject(WorldObject &object, uint64 guid)
Player * ToPlayer()
Definition Object.h:204
TypeID GetTypeId() const
Definition Object.h:131
DamageInfo * GetDamageInfo() const
Definition Unit.h:985
flag128 SpellClassMask
Definition SpellInfo.h:109
SpellEffectInfo Effects[MAX_SPELL_EFFECTS]
Definition SpellInfo.h:255
flag128 SpellFamilyFlags
Definition SpellInfo.h:227
float GetMaxRange(bool positive=false, Unit *caster=NULL, Spell *spell=NULL) const
uint32 SpellFamilyName
Definition SpellInfo.h:226
Unit * GetExplTargetUnit()
HookList< CheckCastHandler > OnCheckCast
HookList< HitHandler > AfterHit
SpellInfo const * GetSpellInfo()
HookList< HitHandler > OnHit
void PreventHitDefaultEffect(SpellEffIndex effIndex)
HookList< EffectHandler > OnEffectHitTarget
Unit * GetHitUnit()
void SetHitHeal(int32 heal)
void PreventHitAura()
int32 GetHitHeal()
Unit * GetCaster()
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
HookList< HitHandler > BeforeHit
SpellScriptLoader(const char *name)
Definition Unit.h:1367
void RemoveGameObject(GameObject *gameObj, bool del)
Definition Unit.cpp:1689
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
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 RemoveAurasDueToSpell(uint32 spellId, uint64 casterGUID=0, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
std::multimap< uint32, AuraApplication * > AuraApplicationMap
Definition Unit.h:1376
Aura * GetAura(uint32 spellId, uint64 casterGUID=0, uint64 itemCasterGUID=0, uint32 reqEffMask=0) const
Aura * AddAura(uint32 spellId, Unit *target)
void CastCustomSpell(Unit *victim, uint32 spellId, int32 const *bp0, int32 const *bp1, int32 const *bp2, bool triggered, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, uint64 originalCaster=0)
uint32 CountPctFromMaxHealth(int32 pct) const
Definition Unit.h:1633
AuraEffect * GetDummyAuraEffect(SpellFamilyNames name, uint32 iconId, uint8 effIndex) const
AuraApplicationMap & GetAppliedAuras()
Definition Unit.h:2204
Guardian * GetGuardianPet() const
Definition Unit.cpp:2390
PrepareSpellScript(spell_warl_banish_SpellScript)
SpellScript * GetSpellScript() const OVERRIDE
PrepareAuraScript(spell_warl_chaotic_energy_AuraScript)
void HandleEffectCalcSpellMod(AuraEffect const *aurEff, SpellModifier *&spellMod)
AuraScript * GetAuraScript() const OVERRIDE
void HandleRemove(AuraEffect const *, AuraEffectHandleModes mode)
AuraScript * GetAuraScript() const OVERRIDE
AuraScript * GetAuraScript() const OVERRIDE
void OnProc(AuraEffect const *aurEff, ProcEventInfo &eventInfo)
PrepareAuraScript(spell_warl_fel_synergy_AuraScript)
AuraScript * GetAuraScript() const OVERRIDE
PrepareSpellScript(spell_warl_healthstone_heal_SpellScript)
SpellScript * GetSpellScript() const OVERRIDE
PrepareSpellScript(spell_warl_life_tap_SpellScript)
SpellScript * GetSpellScript() const OVERRIDE
SpellScript * GetSpellScript() const OVERRIDE
AuraScript * GetAuraScript() const OVERRIDE
PrepareSpellScript(spell_warl_soul_swap_SpellScript)
Soul Swap Copy Spells - 92795 - Simply copies spell IDs.
SpellScript * GetSpellScript() const OVERRIDE
PrepareSpellScript(spell_warl_soul_swap_exhale_SpellScript)
SpellScript * GetSpellScript() const OVERRIDE
void Register() OVERRIDE
Forced to, pure virtual functions must have a body when linking.
AuraScript * GetAuraScript() const OVERRIDE
SpellScript * GetSpellScript() const OVERRIDE
PrepareSpellScript(spell_warl_soulshatter_SpellScript)
SpellScript * GetSpellScript() const OVERRIDE
AuraScript * GetAuraScript() const OVERRIDE
MiscSpells
@ SPELL_PRIEST_SHADOW_WORD_DEATH
@ SPELL_GEN_REPLENISHMENT
void AddSC_warlock_spell_scripts()
spell_warl_soul_swap_override::spell_warl_soul_swap_override_AuraScript SoulSwapOverrideAuraScript
@ SPELL_WARLOCK_SOUL_SWAP_MOD_COST
@ SPELL_WARLOCK_DEMONIC_CIRCLE_TELEPORT
@ SPELL_WARLOCK_SIPHON_LIFE_HEAL
@ SPELL_WARLOCK_SOUL_SWAP_DOT_MARKER
@ SPELL_WARLOCK_RAIN_OF_FIRE
@ SPELL_WARLOCK_DEMONIC_CIRCLE_SUMMON
@ SPELL_WARLOCK_SHADOW_TRANCE
@ SPELL_WARLOCK_SOUL_SWAP_OVERRIDE
@ SPELL_WARLOCK_SOUL_SWAP_CD_MARKER
@ SPELL_WARLOCK_FEL_SYNERGY_HEAL
@ SPELL_WARLOCK_LIFE_TAP_ENERGIZE
@ SPELL_WARLOCK_DEMONIC_CIRCLE_ALLOW_CAST
@ SPELL_WARLOCK_CREATE_HEALTHSTONE
@ SPELL_WARLOCK_AFTERMATH_STUN
@ SPELL_WARLOCK_UNSTABLE_AFFLICTION_DISPEL
@ SPELL_WARLOCK_SOULSHATTER
WarlockSpellIcons
@ WARLOCK_ICON_ID_MANA_FEED
@ WARLOCK_ICON_ID_IMPROVED_LIFE_TAP
SpellModOp op
Definition Player.h:171
SpellModType type
Definition Player.h:172
uint32 spellId
Definition Player.h:176
flag128 mask
Definition Player.h:175
float value
Definition Player.h:174