Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
SpellEffectsLifecycle.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 "AccountMgr.h"
7#include "AreaTrigger.h"
8#include "Battleground.h"
9#include "BattlegroundMgr.h"
10#include "BattlePetMgr.h"
11#include "CellImpl.h"
12#include "Common.h"
13#include "Creature.h"
14#include "CreatureAI.h"
15#include "DatabaseEnv.h"
16#include "DynamicObject.h"
17#include "Formulas.h"
18#include "GameObject.h"
19#include "GameObjectAI.h"
20#include "GossipDef.h"
21#include "GridNotifiers.h"
22#include "GridNotifiersImpl.h"
23#include "Group.h"
24#include "Guild.h"
25#include "GuildMgr.h"
26#include "InstanceScript.h"
27#include "Language.h"
28#include "Log.h"
29#include "MapManager.h"
30#include "ObjectAccessor.h"
31#include "ObjectMgr.h"
32#include "Opcodes.h"
33#include "OutdoorPvPMgr.h"
34#include "PathGenerator.h"
35#include "Pet.h"
36#include "Player.h"
37#include "ReputationMgr.h"
38#include "ScriptMgr.h"
39#include "SharedDefines.h"
40#include "SkillDiscovery.h"
41#include "SkillExtraItems.h"
42#include "SocialMgr.h"
43#include "Spell.h"
44#include "SpellAuraEffects.h"
45#include "SpellAuras.h"
46#include "SpellMgr.h"
47#include "SpellValidation.h"
48#include "TemporarySummon.h"
49#include "Totem.h"
50#include "Unit.h"
51#include "UpdateData.h"
52#include "UpdateMask.h"
53#include "Util.h"
54#include "Vehicle.h"
55#include "VMapFactory.h"
56#include "World.h"
57#include "WorldPacket.h"
58
60{
62 return;
63
64 if (!unitTarget || unitTarget->IsAlive())
65 return;
66
67 if (unitTarget->GetTypeId() != TypeID::TYPEID_PLAYER)
68 return;
69
70 if (!unitTarget->IsInWorld())
71 return;
72
73 Player* target = unitTarget->ToPlayer();
74
75 if (target->IsRessurectRequested()) // already have one active request
76 return;
77
78 uint32 health = damage;
79 uint32 mana = m_spellInfo->Effects[effIndex].MiscValue;
80 ExecuteLogEffectResurrect(effIndex, target);
81 target->SetResurrectRequestData(m_caster, health, mana, 0);
83}
84
86{
88 return;
89
90 if (!unitTarget || unitTarget->GetTypeId() != TypeID::TYPEID_PLAYER)
91 return;
92
93 if (unitTarget->IsAlive() || !unitTarget->IsInWorld())
94 return;
95
96 Player* target = unitTarget->ToPlayer();
97
98 if (target->IsRessurectRequested()) // already have one active request
99 return;
100
101 uint32 health = 0;
102 uint32 mana = 0;
103
104 // check for spells that use different health and mana % on some resurrection
106 {
107 health = target->CountPctFromMaxHealth(m_spellInfo->Effects[EFFECT_1].BasePoints);
108 mana = CalculatePct(target->GetMaxPower(POWER_MANA), m_spellInfo->Effects[EFFECT_0].BasePoints);
109 }
110 else
111 {
112 health = target->CountPctFromMaxHealth(damage);
113 mana = CalculatePct(target->GetMaxPower(POWER_MANA), damage);
114 }
115
116 ExecuteLogEffectResurrect(effIndex, target);
117
118 target->SetResurrectRequestData(m_caster, health, mana, 0);
119 SendResurrectRequest(target);
120}
121
123{
125 return;
126
127 if (!m_caster || m_caster->IsAlive())
128 return;
129 if (m_caster->GetTypeId() != TypeID::TYPEID_PLAYER)
130 return;
131 if (!m_caster->IsInWorld())
132 return;
133
134 uint32 health = 0;
135 uint32 mana = 0;
136
137 // check for spells that use different health and mana % on some battle resurrection
139 {
140 health = m_caster->CountPctFromMaxHealth(m_spellInfo->Effects[EFFECT_1].BasePoints);
141 mana = CalculatePct(m_caster->GetMaxPower(POWER_MANA), m_spellInfo->Effects[EFFECT_0].BasePoints);
142 }
143 else
144 {
145 // flat case
146 if (damage < 0)
147 {
148 health = uint32(-damage);
149 mana = m_spellInfo->Effects[effIndex].MiscValue;
150 }
151 // percent case
152 else
153 {
154 health = m_caster->CountPctFromMaxHealth(damage);
155 if (m_caster->GetMaxPower(POWER_MANA) > 0)
156 mana = CalculatePct(m_caster->GetMaxPower(POWER_MANA), damage);
157 }
158 }
159
160 Player* player = m_caster->ToPlayer();
161 player->ResurrectPlayer(0.0f);
162
163 player->SetHealth(health);
164 player->SetPower(POWER_MANA, mana);
165 player->SetPower(POWER_RAGE, 0);
167 player->SetPower(POWER_FOCUS, 0);
168
169 player->SpawnCorpseBones();
170}
171
173{
175 return;
176
177 /*
178 if (unitTarget->GetTypeId() != TYPEID_PLAYER)
179 return;
180 if (!unitTarget->IsInWorld())
181 return;
182
183 //m_spellInfo->Effects[i].BasePoints; == 99 (percent?)
184 //unitTarget->ToPlayer()->setResurrect(m_caster->GetGUID(), unitTarget->GetPositionX(), unitTarget->GetPositionY(), unitTarget->GetPositionZ(), unitTarget->GetMaxHealth(), unitTarget->GetMaxPower(POWER_MANA));
185 unitTarget->ToPlayer()->ResurrectPlayer(1.0f);
186 unitTarget->ToPlayer()->SpawnCorpseBones();
187 */
188}
189
190// remove insignia spell effect
191
193{
195 return;
196
197 if (!unitTarget || !unitTarget->IsInWorld())
198 return;
199
200 Player* target = unitTarget->ToPlayer();
201 if (!target)
202 return;
203
204 if (unitTarget->IsAlive())
205 return;
206
207 if (target->IsRessurectRequested()) // already have one active request
208 return;
209
210 uint32 health = target->CountPctFromMaxHealth(damage);
212 uint32 resurrectAura = 0;
213 if (sSpellMgr->GetSpellInfo(GetSpellInfo()->Effects[effIndex].TriggerSpell))
214 resurrectAura = GetSpellInfo()->Effects[effIndex].TriggerSpell;
215
216 if (resurrectAura && target->HasAura(resurrectAura))
217 return;
218
219 ExecuteLogEffectResurrect(effIndex, target);
220 target->SetResurrectRequestData(m_caster, health, mana, resurrectAura);
221 SendResurrectRequest(target);
222}
std::uint32_t uint32
Definition Define.h:77
@ TYPEID_PLAYER
Definition Object.h:55
SpellEffIndex
@ EFFECT_1
@ EFFECT_0
@ POWER_RAGE
@ POWER_ENERGY
@ POWER_MANA
@ POWER_FOCUS
@ SPELL_ATTR8_COMBAT_RESURECTION_LIMIT
@ SPELL_EFFECT_HANDLE_HIT
Definition Spell.h:276
@ SPELL_EFFECT_HANDLE_HIT_TARGET
Definition Spell.h:277
#define sSpellMgr
Definition SpellMgr.h:744
T CalculatePct(T base, U pct)
Definition Util.h:103
bool IsRessurectRequested() const
Definition Player.h:2211
void SpawnCorpseBones()
Definition Player.cpp:5378
void SetResurrectRequestData(Unit *caster, uint32 health, uint32 mana, uint32 appliedAura)
Definition Player.cpp:17760
void ResurrectPlayer(float restore_percent, bool applySickness=false)
Definition Player.cpp:5203
uint32 TriggerSpell
Definition SpellInfo.h:108
SpellInfo const * GetSpellInfo() const
Definition Spell.h:565
void EffectResurrectNew(SpellEffIndex effIndex)
int32 damage
Definition Spell.h:630
SpellEffectHandleMode effectHandleMode
Definition Spell.h:631
Unit *const m_caster
Definition Spell.h:581
void EffectResurrectWithAura(SpellEffIndex effIndex)
Unit * unitTarget
Definition Spell.h:626
void ExecuteLogEffectResurrect(uint8 effIndex, Unit *target)
Definition Spell.cpp:4982
void EffectResurrect(SpellEffIndex effIndex)
void EffectSelfResurrect(SpellEffIndex effIndex)
void SendResurrectRequest(Player *target)
Definition Spell.cpp:5108
SpellInfo const *const m_spellInfo
Definition Spell.h:530
void EffectSpiritHeal(SpellEffIndex effIndex)
SpellEffectInfo Effects[MAX_SPELL_EFFECTS]
Definition SpellInfo.h:255
void SetPower(Powers power, int32 val)
Definition Unit.cpp:5255
int32 GetMaxPower(Powers power) const
Definition Unit.cpp:5246
void SetHealth(uint32 val)
Definition Unit.cpp:5162
bool HasAura(uint32 spellId, uint64 casterGUID=0, uint64 itemCasterGUID=0, uint32 reqEffMask=0) const
uint32 CountPctFromMaxHealth(int32 pct) const
Definition Unit.h:1633