Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
SpellAuraProc.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 "Battlefield.h"
7#include "BattlefieldMgr.h"
8#include "Battleground.h"
9#include "CellImpl.h"
10#include "Common.h"
11#include "Formulas.h"
12#include "GridNotifiers.h"
13#include "GridNotifiersImpl.h"
14#include "Log.h"
15#include "ObjectAccessor.h"
16#include "ObjectMgr.h"
17#include "Opcodes.h"
18#include "OutdoorPvPMgr.h"
19#include "Pet.h"
20#include "Player.h"
21#include "ReputationMgr.h"
22#include "ScriptMgr.h"
23#include "Spell.h"
24#include "SpellAuraEffects.h"
25#include "SpellAuraMetadata.h"
26#include "SpellMgr.h"
27#include "SpellValidation.h"
28#include "Unit.h"
29#include "Util.h"
30#include "Vehicle.h"
31#include "WeatherMgr.h"
32#include "WorldPacket.h"
33
34class Aura;
35
37{
38 Unit* triggerCaster = aurApp->GetTarget();
39 Unit* triggerTarget = eventInfo.GetProcTarget();
40
41 uint32 triggerSpellId = GetSpellInfo()->Effects[GetEffIndex()].TriggerSpell;
42 if (SpellInfo const* triggeredSpellInfo = sSpellMgr->GetSpellInfo(triggerSpellId))
43 {
44 SF_LOG_DEBUG("spells", "AuraEffect::HandleProcTriggerSpellAuraProc: Triggering spell %u from aura %u proc", triggeredSpellInfo->Id, GetId());
45 triggerCaster->CastSpell(triggerTarget, triggeredSpellInfo, true, NULL, this);
46 }
47 else
48 SF_LOG_DEBUG("spells", "AuraEffect::HandleProcTriggerSpellAuraProc: Could not trigger spell %u from aura %u proc, because the spell does not have an entry in Spell.dbc.", triggerSpellId, GetId());
49}
50
52{
53 Unit* triggerCaster = aurApp->GetTarget();
54 Unit* triggerTarget = eventInfo.GetProcTarget();
55
57 if (SpellInfo const* triggeredSpellInfo = sSpellMgr->GetSpellInfo(triggerSpellId))
58 {
59 int32 basepoints0 = GetAmount();
60 SF_LOG_DEBUG("spells", "AuraEffect::HandleProcTriggerSpellWithValueAuraProc: Triggering spell %u with value %d from aura %u proc", triggeredSpellInfo->Id, basepoints0, GetId());
61 triggerCaster->CastCustomSpell(triggerTarget, triggerSpellId, &basepoints0, NULL, NULL, true, NULL, this);
62 }
63 else
64 SF_LOG_DEBUG("spells", "AuraEffect::HandleProcTriggerSpellWithValueAuraProc: Could not trigger spell %u from aura %u proc, because the spell does not have an entry in Spell.dbc.", triggerSpellId, GetId());
65}
66
68{
69 Unit* target = aurApp->GetTarget();
70 Unit* triggerTarget = eventInfo.GetProcTarget();
71 SpellNonMeleeDamage damageInfo(target, triggerTarget, GetId(), GetSpellInfo()->SchoolMask);
72 uint32 damage = target->SpellDamageBonusDone(triggerTarget, GetSpellInfo(), GetAmount(), SPELL_DIRECT_DAMAGE);
73 damage = triggerTarget->SpellDamageBonusTaken(target, GetSpellInfo(), damage, SPELL_DIRECT_DAMAGE);
74 target->CalculateSpellDamageTaken(&damageInfo, damage, GetSpellInfo());
75 target->DealDamageMods(damageInfo.target, damageInfo.damage, &damageInfo.absorb);
76 target->SendSpellNonMeleeDamageLog(&damageInfo);
77 SF_LOG_DEBUG("spells", "AuraEffect::HandleProcTriggerDamageAuraProc: Triggering %u spell damage from aura %u proc", damage, GetId());
78 target->DealSpellDamage(&damageInfo, true);
79}
80
82{
83 Unit* target = aurApp->GetTarget();
84
86 if (!triggerSpellId)
87 {
88 SF_LOG_DEBUG("spells", "AuraEffect::HandleRaidProcFromChargeAuraProc: received not handled spell: %u", GetId());
89 return;
90 }
91
92 int32 jumps = GetBase()->GetCharges();
93
94 // current aura expire on proc finish
95 GetBase()->SetCharges(0);
96 GetBase()->SetUsingCharges(true);
97
98 // next target selection
99 if (jumps > 0)
100 {
101 if (Unit* caster = GetCaster())
102 {
103 float radius = GetSpellInfo()->Effects[GetEffIndex()].CalcRadius(caster);
104
105 if (Unit* triggerTarget = target->GetNextRandomRaidMemberOrPet(radius))
106 {
107 target->CastSpell(triggerTarget, GetSpellInfo(), true, NULL, this, GetCasterGUID());
108 if (Aura* aura = triggerTarget->GetAura(GetId(), GetCasterGUID()))
109 aura->SetCharges(jumps);
110 }
111 }
112 }
113
114 SF_LOG_DEBUG("spells", "AuraEffect::HandleRaidProcFromChargeAuraProc: Triggering spell %u from aura %u proc", triggerSpellId, GetId());
115 target->CastSpell(target, triggerSpellId, true, NULL, this, GetCasterGUID());
116}
117
118
120{
121 Unit* target = aurApp->GetTarget();
122
123 // Currently only Prayer of Mending
124 if (!(GetSpellInfo()->SpellFamilyName == SPELLFAMILY_PRIEST && GetSpellInfo()->SpellFamilyFlags[1] & 0x20))
125 {
126 SF_LOG_DEBUG("spells", "AuraEffect::HandleRaidProcFromChargeWithValueAuraProc: received not handled spell: %u", GetId());
127 return;
128 }
129 uint32 triggerSpellId = 33110;
130
131 int32 value = GetAmount();
132
133 int32 jumps = GetBase()->GetCharges();
134
135 // current aura expire on proc finish
136 GetBase()->SetCharges(0);
137 GetBase()->SetUsingCharges(true);
138
139 // next target selection
140 if (jumps > 0)
141 {
142 if (Unit* caster = GetCaster())
143 {
144 float radius = GetSpellInfo()->Effects[GetEffIndex()].CalcRadius(caster);
145
146 if (Unit* triggerTarget = target->GetNextRandomRaidMemberOrPet(radius))
147 {
148 target->CastCustomSpell(triggerTarget, GetId(), &value, NULL, NULL, true, NULL, this, GetCasterGUID());
149 if (Aura* aura = triggerTarget->GetAura(GetId(), GetCasterGUID()))
150 aura->SetCharges(jumps);
151 }
152 }
153 }
154
155 SF_LOG_DEBUG("spells", "AuraEffect::HandleRaidProcFromChargeWithValueAuraProc: Triggering spell %u from aura %u proc", triggerSpellId, GetId());
156 target->CastCustomSpell(target, triggerSpellId, &value, NULL, NULL, true, NULL, this, GetCasterGUID());
157}
std::int32_t int32
Definition Define.h:73
std::uint32_t uint32
Definition Define.h:77
#define SF_LOG_DEBUG(filterType__,...)
Definition Log.h:134
@ SPELLFAMILY_PRIEST
#define sSpellMgr
Definition SpellMgr.h:744
@ SPELL_DIRECT_DAMAGE
Definition Unit.h:615
Unit * GetTarget() const
Definition SpellAuras.h:54
SpellInfo const * GetSpellInfo() const
uint8 const m_effIndex
uint32 GetId() const
void HandleRaidProcFromChargeAuraProc(AuraApplication *aurApp, ProcEventInfo &eventInfo)
void HandleProcTriggerSpellWithValueAuraProc(AuraApplication *aurApp, ProcEventInfo &eventInfo)
Unit * GetCaster() const
Aura * GetBase() const
uint32 GetEffIndex() const
void HandleProcTriggerDamageAuraProc(AuraApplication *aurApp, ProcEventInfo &eventInfo)
void HandleRaidProcFromChargeWithValueAuraProc(AuraApplication *aurApp, ProcEventInfo &eventInfo)
uint64 GetCasterGUID() const
void HandleProcTriggerSpellAuraProc(AuraApplication *aurApp, ProcEventInfo &eventInfo)
int32 GetAmount() const
void SetUsingCharges(bool val)
Definition SpellAuras.h:193
void SetCharges(uint8 charges)
uint8 GetCharges() const
Definition SpellAuras.h:126
Unit * GetProcTarget() const
Definition Unit.h:974
uint32 TriggerSpell
Definition SpellInfo.h:108
float CalcRadius(Unit *caster=NULL, Spell *=NULL) const
SpellEffectInfo Effects[MAX_SPELL_EFFECTS]
Definition SpellInfo.h:255
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 DealDamageMods(Unit *victim, uint32 &damage, uint32 *absorb)
void DealSpellDamage(SpellNonMeleeDamage *damageInfo, bool durabilityLoss)
Unit * GetNextRandomRaidMemberOrPet(float radius)
Definition Unit.cpp:2826
uint32 SpellDamageBonusDone(Unit *victim, SpellInfo const *spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack=1) const
void SendSpellNonMeleeDamageLog(SpellNonMeleeDamage *log)
Definition Unit.cpp:1766
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 SpellDamageBonusTaken(Unit *caster, SpellInfo const *spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack=1) const
void CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 damage, SpellInfo const *spellInfo, WeaponAttackType attackType=WeaponAttackType::BASE_ATTACK, bool crit=false)
uint32 GetRaidProcChargeTriggerSpellId(uint32 auraSpellId)