Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
SpellEffectsQuest.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 "
SpellEffectMetadata.h
"
47
#include "
SpellMgr.h
"
48
#include "
SpellValidation.h
"
49
#include "
TemporarySummon.h
"
50
#include "
Totem.h
"
51
#include "
Unit.h
"
52
#include "
UpdateData.h
"
53
#include "
UpdateMask.h
"
54
#include "
Util.h
"
55
#include "
Vehicle.h
"
56
#include "
VMapFactory.h
"
57
#include "
World.h
"
58
#include "
WorldPacket.h
"
59
60
void
Spell::EffectReputation
(
SpellEffIndex
effIndex)
61
{
62
if
(
effectHandleMode
!=
SPELL_EFFECT_HANDLE_HIT_TARGET
)
63
return
;
64
65
if
(!
unitTarget
||
unitTarget
->GetTypeId() !=
TypeID::TYPEID_PLAYER
)
66
return
;
67
68
Player
* player =
unitTarget
->ToPlayer();
69
70
int32
repChange =
damage
;
71
72
uint32
factionId =
m_spellInfo
->Effects[effIndex].MiscValue;
73
74
FactionEntry
const
* factionEntry =
sFactionStore
.LookupEntry(factionId);
75
if
(!factionEntry)
76
return
;
77
78
repChange = player->
CalculateReputationGain
(
REPUTATION_SOURCE_SPELL
, 0, repChange, factionId);
79
80
player->
GetReputationMgr
().
ModifyReputation
(factionEntry, repChange);
81
}
82
83
void
Spell::EffectQuestComplete
(
SpellEffIndex
effIndex)
84
{
85
if
(
effectHandleMode
!=
SPELL_EFFECT_HANDLE_HIT_TARGET
)
86
return
;
87
88
if
(!
unitTarget
||
unitTarget
->GetTypeId() !=
TypeID::TYPEID_PLAYER
)
89
return
;
90
Player
* player =
unitTarget
->ToPlayer();
91
92
uint32
questId =
m_spellInfo
->Effects[effIndex].MiscValue;
93
if
(questId)
94
{
95
Quest
const
* quest =
sObjectMgr
->GetQuestTemplate(questId);
96
if
(!quest)
97
return
;
98
99
uint16
logSlot = player->
FindQuestSlot
(questId);
100
if
(logSlot <
MAX_QUEST_LOG_SIZE
)
101
player->
AreaExploredOrEventHappens
(questId);
102
else
if
(player->
CanTakeQuest
(quest,
false
))
// never rewarded before
103
player->
CompleteQuest
(questId);
// quest not in log - for internal use
104
}
105
}
106
107
void
Spell::EffectQuestClear
(
SpellEffIndex
effIndex)
108
{
109
if
(
effectHandleMode
!=
SPELL_EFFECT_HANDLE_HIT_TARGET
)
110
return
;
111
112
if
(!
unitTarget
||
unitTarget
->GetTypeId() !=
TypeID::TYPEID_PLAYER
)
113
return
;
114
Player
* player =
unitTarget
->ToPlayer();
115
116
uint32
quest_id =
m_spellInfo
->Effects[effIndex].MiscValue;
117
118
Quest
const
* quest =
sObjectMgr
->GetQuestTemplate(quest_id);
119
120
if
(!quest)
121
return
;
122
123
// Player has never done this quest
124
if
(player->
GetQuestStatus
(quest_id) ==
QUEST_STATUS_NONE
)
125
return
;
126
127
// remove all quest entries for 'entry' from quest log
128
for
(
uint8
slot = 0; slot <
MAX_QUEST_LOG_SIZE
; ++slot)
129
{
130
uint32
logQuest = player->
GetQuestSlotQuestId
(slot);
131
if
(logQuest == quest_id)
132
{
133
player->
SetQuestSlot
(slot, 0);
134
135
// we ignore unequippable quest items in this case, it's still be equipped
136
player->
TakeQuestSourceItem
(logQuest,
false
);
137
138
if
(quest->
HasFlag
(
QUEST_FLAGS_FLAGS_PVP
))
139
{
140
player->
pvpInfo
.
IsHostile
= player->
pvpInfo
.
IsInHostileArea
|| player->
HasPvPForcingQuest
();
141
player->
UpdatePvPState
();
142
}
143
}
144
}
145
146
player->
RemoveActiveQuest
(quest_id);
147
player->
RemoveRewardedQuest
(quest_id);
148
}
149
150
void
Spell::EffectKillCreditPersonal
(
SpellEffIndex
effIndex)
151
{
152
if
(
effectHandleMode
!=
SPELL_EFFECT_HANDLE_HIT_TARGET
)
153
return
;
154
155
if
(!
unitTarget
||
unitTarget
->GetTypeId() !=
TypeID::TYPEID_PLAYER
)
156
return
;
157
158
unitTarget
->ToPlayer()->KilledMonsterCredit(
m_spellInfo
->Effects[effIndex].MiscValue, 0);
159
}
160
161
void
Spell::EffectKillCredit
(
SpellEffIndex
effIndex)
162
{
163
if
(
effectHandleMode
!=
SPELL_EFFECT_HANDLE_HIT_TARGET
)
164
return
;
165
166
if
(!
unitTarget
||
unitTarget
->GetTypeId() !=
TypeID::TYPEID_PLAYER
)
167
return
;
168
169
int32
creatureEntry =
m_spellInfo
->Effects[effIndex].MiscValue;
170
if
(!creatureEntry)
171
creatureEntry =
Skyfire::Spells::GetKillCreditFallbackCreatureEntry
(
m_spellInfo
->Id);
172
173
if
(creatureEntry)
174
unitTarget
->ToPlayer()->RewardPlayerAndGroupAtEvent(creatureEntry,
unitTarget
);
175
}
176
177
void
Spell::EffectQuestFail
(
SpellEffIndex
effIndex)
178
{
179
if
(
effectHandleMode
!=
SPELL_EFFECT_HANDLE_HIT_TARGET
)
180
return
;
181
182
if
(!
unitTarget
||
unitTarget
->GetTypeId() !=
TypeID::TYPEID_PLAYER
)
183
return
;
184
185
unitTarget
->ToPlayer()->FailQuest(
m_spellInfo
->Effects[effIndex].MiscValue);
186
}
187
188
void
Spell::EffectQuestStart
(
SpellEffIndex
effIndex)
189
{
190
if
(
effectHandleMode
!=
SPELL_EFFECT_HANDLE_HIT_TARGET
)
191
return
;
192
193
if
(!
unitTarget
||
unitTarget
->GetTypeId() !=
TypeID::TYPEID_PLAYER
)
194
return
;
195
196
uint32
questId =
m_spellInfo
->Effects[effIndex].MiscValue;
197
Player
* player =
unitTarget
->ToPlayer();
198
199
if
(
Quest
const
* qInfo =
sObjectMgr
->GetQuestTemplate(questId))
200
{
201
if
(player->
CanTakeQuest
(qInfo,
false
) && player->
CanAddQuest
(qInfo,
false
))
202
{
203
player->
AddQuest
(qInfo, NULL);
204
205
if
(player->
CanCompleteQuest
(questId))
206
player->
CompleteQuest
(questId);
207
}
208
}
209
}
210
211
void
Spell::EffectGiveCurrency
(
SpellEffIndex
effIndex)
212
{
213
if
(
effectHandleMode
!=
SPELL_EFFECT_HANDLE_HIT_TARGET
)
214
return
;
215
216
if
(!
unitTarget
||
unitTarget
->GetTypeId() !=
TypeID::TYPEID_PLAYER
)
217
return
;
218
219
unitTarget
->ToPlayer()->ModifyCurrency(
m_spellInfo
->Effects[effIndex].MiscValue,
damage
);
220
}
AccountMgr.h
AreaTrigger.h
BattlePetMgr.h
Battleground.h
BattlegroundMgr.h
CellImpl.h
Common.h
Creature.h
CreatureAI.h
sFactionStore
DBCStorage< FactionEntry > sFactionStore(FactionEntryfmt)
DatabaseEnv.h
int32
std::int32_t int32
Definition
Define.h:73
uint8
std::uint8_t uint8
Definition
Define.h:79
uint32
std::uint32_t uint32
Definition
Define.h:77
uint16
std::uint16_t uint16
Definition
Define.h:78
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
sObjectMgr
#define sObjectMgr
Definition
ObjectMgr.h:1617
Opcodes.h
OutdoorPvPMgr.h
PathGenerator.h
Pet.h
Player.h
REPUTATION_SOURCE_SPELL
@ REPUTATION_SOURCE_SPELL
Definition
Player.h:344
QUEST_FLAGS_FLAGS_PVP
@ QUEST_FLAGS_FLAGS_PVP
Definition
QuestDef.h:128
MAX_QUEST_LOG_SIZE
#define MAX_QUEST_LOG_SIZE
Definition
QuestDef.h:22
QUEST_STATUS_NONE
@ QUEST_STATUS_NONE
Definition
QuestDef.h:86
ReputationMgr.h
ScriptMgr.h
SharedDefines.h
SpellEffIndex
SpellEffIndex
Definition
SharedDefines.h:17
SkillDiscovery.h
SkillExtraItems.h
SocialMgr.h
Spell.h
SPELL_EFFECT_HANDLE_HIT_TARGET
@ SPELL_EFFECT_HANDLE_HIT_TARGET
Definition
Spell.h:277
SpellAuraEffects.h
SpellAuras.h
SpellEffectMetadata.h
SpellMgr.h
SpellValidation.h
TemporarySummon.h
Totem.h
Unit.h
UpdateData.h
UpdateMask.h
Util.h
VMapFactory.h
Vehicle.h
World.h
WorldPacket.h
Player
Definition
Player.h:1289
Player::HasPvPForcingQuest
bool HasPvPForcingQuest() const
Definition
PlayerQuestState.cpp:2289
Player::FindQuestSlot
uint16 FindQuestSlot(uint32 quest_id) const
Definition
PlayerQuestState.cpp:1500
Player::UpdatePvPState
void UpdatePvPState(bool onlyFFA=false)
Definition
Player.cpp:17441
Player::CanTakeQuest
bool CanTakeQuest(Quest const *quest, bool msg)
Definition
PlayerQuestState.cpp:244
Player::CanCompleteQuest
bool CanCompleteQuest(uint32 quest_id)
Definition
PlayerQuestState.cpp:280
Player::AddQuest
void AddQuest(Quest const *quest, Object *questGiver)
Definition
PlayerQuestState.cpp:479
Player::CanAddQuest
bool CanAddQuest(Quest const *quest, bool msg)
Definition
PlayerQuestState.cpp:257
Player::RemoveRewardedQuest
void RemoveRewardedQuest(uint32 quest_id)
Definition
PlayerQuestState.cpp:1459
Player::CompleteQuest
void CompleteQuest(uint32 quest_id)
Definition
PlayerQuestState.cpp:585
Player::GetQuestSlotQuestId
uint32 GetQuestSlotQuestId(uint16 slot) const
Definition
PlayerQuestState.cpp:1509
Player::CalculateReputationGain
int32 CalculateReputationGain(ReputationSource source, uint32 creatureOrQuestLevel, int32 rep, int32 faction, bool noQuestBonus=false)
Definition
Player.cpp:7105
Player::SetQuestSlot
void SetQuestSlot(uint16 slot, uint32 quest_id, uint32 timer=0)
Definition
PlayerQuestState.cpp:1529
Player::pvpInfo
PvPInfo pvpInfo
Definition
Player.h:2233
Player::AreaExploredOrEventHappens
void AreaExploredOrEventHappens(uint32 questId)
Definition
PlayerQuestState.cpp:1572
Player::TakeQuestSourceItem
bool TakeQuestSourceItem(uint32 questId, bool msg)
Definition
PlayerQuestState.cpp:1323
Player::GetQuestStatus
QuestStatus GetQuestStatus(uint32 quest_id) const
Definition
PlayerQuestState.cpp:1375
Player::RemoveActiveQuest
void RemoveActiveQuest(uint32 quest_id)
Definition
PlayerQuestState.cpp:1438
Player::GetReputationMgr
ReputationMgr & GetReputationMgr()
Definition
Player.h:2555
Quest
Definition
QuestDef.h:255
Quest::HasFlag
bool HasFlag(uint32 flag) const
Definition
QuestDef.h:261
ReputationMgr::ModifyReputation
bool ModifyReputation(FactionEntry const *factionEntry, int32 standing)
Definition
ReputationMgr.h:111
Spell::EffectGiveCurrency
void EffectGiveCurrency(SpellEffIndex effIndex)
Definition
SpellEffectsQuest.cpp:211
Spell::EffectQuestStart
void EffectQuestStart(SpellEffIndex effIndex)
Definition
SpellEffectsQuest.cpp:188
Spell::damage
int32 damage
Definition
Spell.h:630
Spell::effectHandleMode
SpellEffectHandleMode effectHandleMode
Definition
Spell.h:631
Spell::EffectKillCreditPersonal
void EffectKillCreditPersonal(SpellEffIndex effIndex)
Definition
SpellEffectsQuest.cpp:150
Spell::EffectKillCredit
void EffectKillCredit(SpellEffIndex effIndex)
Definition
SpellEffectsQuest.cpp:161
Spell::EffectReputation
void EffectReputation(SpellEffIndex effIndex)
Definition
SpellEffectsQuest.cpp:60
Spell::unitTarget
Unit * unitTarget
Definition
Spell.h:626
Spell::EffectQuestClear
void EffectQuestClear(SpellEffIndex effIndex)
Definition
SpellEffectsQuest.cpp:107
Spell::EffectQuestComplete
void EffectQuestComplete(SpellEffIndex effIndex)
Definition
SpellEffectsQuest.cpp:83
Spell::m_spellInfo
SpellInfo const *const m_spellInfo
Definition
Spell.h:530
Spell::EffectQuestFail
void EffectQuestFail(SpellEffIndex effIndex)
Definition
SpellEffectsQuest.cpp:177
Skyfire::Spells::GetKillCreditFallbackCreatureEntry
uint32 GetKillCreditFallbackCreatureEntry(uint32 spellId)
Definition
SpellEffectMetadata.cpp:242
FactionEntry
Definition
DBCStructure.h:1464
PvPInfo::IsHostile
bool IsHostile
Definition
Player.h:446
PvPInfo::IsInHostileArea
bool IsInHostileArea
Definition
Player.h:447
src
server
game
Spells
SpellEffectsQuest.cpp
Generated on
for Project SkyFire Core by
1.17.0