Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
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
59
void
Spell::EffectResurrectNew
(
SpellEffIndex
effIndex)
60
{
61
if
(
effectHandleMode
!=
SPELL_EFFECT_HANDLE_HIT_TARGET
)
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);
82
SendResurrectRequest
(target);
83
}
84
85
void
Spell::EffectResurrect
(
SpellEffIndex
effIndex)
86
{
87
if
(
effectHandleMode
!=
SPELL_EFFECT_HANDLE_HIT_TARGET
)
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
105
if
(
m_spellInfo
->AttributesEx8 &
SPELL_ATTR8_COMBAT_RESURECTION_LIMIT
)
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
122
void
Spell::EffectSelfResurrect
(
SpellEffIndex
effIndex)
123
{
124
if
(
effectHandleMode
!=
SPELL_EFFECT_HANDLE_HIT
)
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
138
if
(
m_spellInfo
->AttributesEx8 &
SPELL_ATTR8_COMBAT_RESURECTION_LIMIT
)
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);
166
player->
SetPower
(
POWER_ENERGY
, player->
GetMaxPower
(
POWER_ENERGY
));
167
player->
SetPower
(
POWER_FOCUS
, 0);
168
169
player->
SpawnCorpseBones
();
170
}
171
172
void
Spell::EffectSpiritHeal
(
SpellEffIndex
/*effIndex*/
)
173
{
174
if
(
effectHandleMode
!=
SPELL_EFFECT_HANDLE_HIT_TARGET
)
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
192
void
Spell::EffectResurrectWithAura
(
SpellEffIndex
effIndex)
193
{
194
if
(
effectHandleMode
!=
SPELL_EFFECT_HANDLE_HIT_TARGET
)
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
);
211
uint32
mana =
CalculatePct
(target->
GetMaxPower
(
POWER_MANA
),
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
}
AccountMgr.h
AreaTrigger.h
BattlePetMgr.h
Battleground.h
BattlegroundMgr.h
CellImpl.h
Common.h
Creature.h
CreatureAI.h
DatabaseEnv.h
uint32
std::uint32_t uint32
Definition
Define.h:77
DynamicObject.h
Formulas.h
GameObject.h
GameObjectAI.h
GossipDef.h
GridNotifiers.h
GridNotifiersImpl.h
Group.h
Guild.h
GuildMgr.h
InstanceScript.h
Language.h
Log.h
MapManager.h
TypeID::TYPEID_PLAYER
@ TYPEID_PLAYER
Definition
Object.h:55
ObjectAccessor.h
ObjectMgr.h
Opcodes.h
OutdoorPvPMgr.h
PathGenerator.h
Pet.h
Player.h
ReputationMgr.h
ScriptMgr.h
SharedDefines.h
SpellEffIndex
SpellEffIndex
Definition
SharedDefines.h:17
EFFECT_1
@ EFFECT_1
Definition
SharedDefines.h:19
EFFECT_0
@ EFFECT_0
Definition
SharedDefines.h:18
POWER_RAGE
@ POWER_RAGE
Definition
SharedDefines.h:216
POWER_ENERGY
@ POWER_ENERGY
Definition
SharedDefines.h:218
POWER_MANA
@ POWER_MANA
Definition
SharedDefines.h:215
POWER_FOCUS
@ POWER_FOCUS
Definition
SharedDefines.h:217
SPELL_ATTR8_COMBAT_RESURECTION_LIMIT
@ SPELL_ATTR8_COMBAT_RESURECTION_LIMIT
Definition
SharedDefines.h:649
SkillDiscovery.h
SkillExtraItems.h
SocialMgr.h
Spell.h
SPELL_EFFECT_HANDLE_HIT
@ SPELL_EFFECT_HANDLE_HIT
Definition
Spell.h:276
SPELL_EFFECT_HANDLE_HIT_TARGET
@ SPELL_EFFECT_HANDLE_HIT_TARGET
Definition
Spell.h:277
SpellAuraEffects.h
SpellAuras.h
SpellMgr.h
sSpellMgr
#define sSpellMgr
Definition
SpellMgr.h:744
SpellValidation.h
TemporarySummon.h
Totem.h
Unit.h
UpdateData.h
UpdateMask.h
Util.h
CalculatePct
T CalculatePct(T base, U pct)
Definition
Util.h:103
VMapFactory.h
Vehicle.h
World.h
WorldPacket.h
Player
Definition
Player.h:1289
Player::IsRessurectRequested
bool IsRessurectRequested() const
Definition
Player.h:2211
Player::SpawnCorpseBones
void SpawnCorpseBones()
Definition
Player.cpp:5378
Player::SetResurrectRequestData
void SetResurrectRequestData(Unit *caster, uint32 health, uint32 mana, uint32 appliedAura)
Definition
Player.cpp:17760
Player::ResurrectPlayer
void ResurrectPlayer(float restore_percent, bool applySickness=false)
Definition
Player.cpp:5203
SpellEffectInfo::TriggerSpell
uint32 TriggerSpell
Definition
SpellInfo.h:108
Spell::GetSpellInfo
SpellInfo const * GetSpellInfo() const
Definition
Spell.h:565
Spell::EffectResurrectNew
void EffectResurrectNew(SpellEffIndex effIndex)
Definition
SpellEffectsLifecycle.cpp:59
Spell::damage
int32 damage
Definition
Spell.h:630
Spell::effectHandleMode
SpellEffectHandleMode effectHandleMode
Definition
Spell.h:631
Spell::m_caster
Unit *const m_caster
Definition
Spell.h:581
Spell::EffectResurrectWithAura
void EffectResurrectWithAura(SpellEffIndex effIndex)
Definition
SpellEffectsLifecycle.cpp:192
Spell::unitTarget
Unit * unitTarget
Definition
Spell.h:626
Spell::ExecuteLogEffectResurrect
void ExecuteLogEffectResurrect(uint8 effIndex, Unit *target)
Definition
Spell.cpp:4982
Spell::EffectResurrect
void EffectResurrect(SpellEffIndex effIndex)
Definition
SpellEffectsLifecycle.cpp:85
Spell::EffectSelfResurrect
void EffectSelfResurrect(SpellEffIndex effIndex)
Definition
SpellEffectsLifecycle.cpp:122
Spell::SendResurrectRequest
void SendResurrectRequest(Player *target)
Definition
Spell.cpp:5108
Spell::m_spellInfo
SpellInfo const *const m_spellInfo
Definition
Spell.h:530
Spell::EffectSpiritHeal
void EffectSpiritHeal(SpellEffIndex effIndex)
Definition
SpellEffectsLifecycle.cpp:172
SpellInfo::Effects
SpellEffectInfo Effects[MAX_SPELL_EFFECTS]
Definition
SpellInfo.h:255
Unit::SetPower
void SetPower(Powers power, int32 val)
Definition
Unit.cpp:5255
Unit::GetMaxPower
int32 GetMaxPower(Powers power) const
Definition
Unit.cpp:5246
Unit::SetHealth
void SetHealth(uint32 val)
Definition
Unit.cpp:5162
Unit::HasAura
bool HasAura(uint32 spellId, uint64 casterGUID=0, uint64 itemCasterGUID=0, uint32 reqEffMask=0) const
Definition
UnitAuraState.cpp:1182
Unit::CountPctFromMaxHealth
uint32 CountPctFromMaxHealth(int32 pct) const
Definition
Unit.h:1633
src
server
game
Spells
SpellEffectsLifecycle.cpp
Generated on
for Project SkyFire Core by
1.17.0