Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
SpellEffectsProgression.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
61{
63 return;
64
65 if (!unitTarget || unitTarget->GetTypeId() != TypeID::TYPEID_PLAYER)
66 return;
67
68 Player* player = unitTarget->ToPlayer();
69 uint32 spellToUnlearn = m_spellInfo->Effects[effIndex].TriggerSpell;
70
71 player->removeSpell(spellToUnlearn);
72
73 SF_LOG_DEBUG("spells", "Spell: Player %u has unlearned spell %u from NpcGUID: %u", player->GetGUIDLow(), spellToUnlearn, m_caster->GetGUIDLow());
74}
75
77{
79 return;
80
81 if (m_caster->GetTypeId() != TypeID::TYPEID_PLAYER)
82 return;
83 Player* p_target = m_caster->ToPlayer();
84
85 uint32 subClassMask = m_spellInfo->EquippedItemSubClassMask;
86 if (m_spellInfo->EquippedItemClass == ITEM_CLASS_WEAPON && !(p_target->GetWeaponProficiency() & subClassMask))
87 {
88 p_target->AddWeaponProficiency(subClassMask);
90 }
91 if (m_spellInfo->EquippedItemClass == ITEM_CLASS_ARMOR && !(p_target->GetArmorProficiency() & subClassMask))
92 {
93 p_target->AddArmorProficiency(subClassMask);
95 }
96}
97
99{
101 return;
102
103 if (!unitTarget)
104 return;
105
106 if (unitTarget->GetTypeId() != TypeID::TYPEID_PLAYER)
107 {
108 if (unitTarget->ToPet())
109 EffectLearnPetSpell(effIndex);
110 return;
111 }
112
113 Player* player = unitTarget->ToPlayer();
114
116 damage : m_spellInfo->Effects[effIndex].TriggerSpell;
117 player->learnSpell(spellToLearn, false);
118
119 SF_LOG_DEBUG("spells", "Spell: Player %u has learned spell %u from NpcGUID=%u", player->GetGUIDLow(), spellToLearn, m_caster->GetGUIDLow());
120}
121
123{
125 return;
126
127 if (!unitTarget || m_caster->GetTypeId() == TypeID::TYPEID_PLAYER)
128 return;
129
130 if (uint64 guid = m_caster->GetGUID()) // the trainer is the caster
131 unitTarget->ToPlayer()->SendTalentWipeConfirm(guid, false);
132}
133
135{
137 return;
138
139 if (unitTarget->GetTypeId() != TypeID::TYPEID_PLAYER)
140 return;
141
142 if (damage < 0)
143 return;
144
145 uint32 skillid = m_spellInfo->Effects[effIndex].MiscValue;
146 uint16 skillval = unitTarget->ToPlayer()->GetPureSkillValue(skillid);
147 unitTarget->ToPlayer()->SetSkill(skillid, m_spellInfo->Effects[effIndex].CalcValue(), skillval ? skillval : 1, damage * 75);
148}
149
151{
153 return;
154
156 return;
157
158 Player* player = m_caster->ToPlayer();
159 if (!player)
160 return;
161
162 // glyph sockets level requirement
163 uint8 minLevel = 0;
164 switch (m_glyphIndex)
165 {
166 case 0:
167 case 1:
168 minLevel = 25;
169 break;
170 case 2:
171 case 3:
172 minLevel = 50;
173 break;
174 case 4:
175 case 5:
176 minLevel = 75;
177 break;
178 }
179
180 if (minLevel && m_caster->getLevel() < minLevel)
181 {
183 return;
184 }
185
186 // apply new one
187 if (uint32 newGlyph = m_spellInfo->Effects[effIndex].MiscValue)
188 {
189 if (GlyphPropertiesEntry const* newGlyphProperties = sGlyphPropertiesStore.LookupEntry(newGlyph))
190 {
191 if (GlyphSlotEntry const* newGlyphSlot = sGlyphSlotStore.LookupEntry(player->GetGlyphSlot(m_glyphIndex)))
192 {
193 if (newGlyphProperties->TypeFlags != newGlyphSlot->TypeFlags)
194 {
196 return; // glyph slot mismatch
197 }
198 }
199
200 // remove old glyph
201 if (uint32 oldGlyph = player->GetGlyph(player->GetActiveSpec(), m_glyphIndex))
202 {
203 if (GlyphPropertiesEntry const* oldGlyphProperties = sGlyphPropertiesStore.LookupEntry(oldGlyph))
204 {
205 player->RemoveAurasDueToSpell(oldGlyphProperties->SpellId);
206 player->SetGlyph(m_glyphIndex, 0);
207 }
208 }
209
210 player->CastSpell(m_caster, newGlyphProperties->SpellId, true);
211 player->SetGlyph(m_glyphIndex, newGlyph);
212 player->SendTalentsInfoData();
213 }
214 }
215 else if (uint32 oldGlyph = player->GetGlyph(player->GetActiveSpec(), m_glyphIndex)) // Removing the glyph, get the old one
216 {
217 if (GlyphPropertiesEntry const* oldGlyphProperties = sGlyphPropertiesStore.LookupEntry(oldGlyph))
218 {
219 player->RemoveAurasDueToSpell(oldGlyphProperties->SpellId);
220 player->SetGlyph(m_glyphIndex, 0);
221 player->SendTalentsInfoData();
222 }
223 }
224}
225
227{
229 return;
230
231 SF_LOG_DEBUG("spells", "WORLD: SkillEFFECT");
232}
233
234/* There is currently no need for this effect. We handle it in Battleground.cpp
235 If we would handle the resurrection here, the spiritguide would instantly disappear as the
236 player revives, and so we wouldn't see the spirit heal visual effect on the npc.
237 This is why we use a half sec delay between the visual effect and the resurrection itself */
238
240{
242 return;
243
244 if (!unitTarget || unitTarget->GetTypeId() != TypeID::TYPEID_PLAYER)
245 return;
246
247 unitTarget->ToPlayer()->UpdateSpecCount(damage);
248}
249
251{
253 return;
254
255 if (!unitTarget || unitTarget->GetTypeId() != TypeID::TYPEID_PLAYER)
256 return;
257
258 unitTarget->ToPlayer()->ActivateSpec(damage - 1); // damage is 1 or 2, spec is 0 or 1
259}
260
262{
264 return;
265
266 Player* player = GetCaster()->ToPlayer();
267
268 // Blizz sends talentId as glyphIndex
269 if (player)
270 player->RemoveTalent(m_glyphIndex);
271}
DBCStorage< GlyphSlotEntry > sGlyphSlotStore(GlyphSlotfmt)
DBCStorage< GlyphPropertiesEntry > sGlyphPropertiesStore(GlyphPropertiesfmt)
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
std::uint64_t uint64
Definition Define.h:76
std::uint16_t uint16
Definition Define.h:78
@ ITEM_CLASS_ARMOR
@ ITEM_CLASS_WEAPON
#define SF_LOG_DEBUG(filterType__,...)
Definition Log.h:134
@ TYPEID_PLAYER
Definition Object.h:55
SpellEffIndex
#define MAX_GLYPH_SLOT_INDEX
@ SPELL_EFFECT_HANDLE_HIT
Definition Spell.h:276
@ SPELL_EFFECT_HANDLE_HIT_TARGET
Definition Spell.h:277
Player * ToPlayer()
Definition Object.h:204
uint32 GetGUIDLow() const
Definition Object.h:120
uint32 GetArmorProficiency() const
Definition Player.h:1677
void SendProficiency(ItemClass itemClass, uint32 itemSubclassMask)
Definition Player.cpp:16438
void SendTalentsInfoData()
Definition Player.cpp:21306
bool RemoveTalent(uint32 talentId)
Definition Player.cpp:4596
uint32 GetGlyphSlot(uint8 slot) const
Definition Player.h:2108
uint32 GetGlyph(uint8 spec, uint8 slot) const
Definition Player.h:2113
uint32 GetWeaponProficiency() const
Definition Player.h:1673
void removeSpell(uint32 spell_id, bool disabled=false, bool learn_low_rank=true)
Definition Player.cpp:4073
void SetGlyph(uint8 slot, uint32 glyph)
Definition Player.cpp:20404
void learnSpell(uint32 spell_id, bool dependent)
Definition Player.cpp:4021
uint8 GetActiveSpec() const
Definition Player.h:2077
void AddArmorProficiency(uint32 newflag)
Definition Player.h:1669
void AddWeaponProficiency(uint32 newflag)
Definition Player.h:1665
void EffectActivateSpec(SpellEffIndex effIndex)
static void SendCastResult(Player *caster, SpellInfo const *spellInfo, uint8 cast_count, SpellCastResult result, SpellCustomErrors customError=SPELL_CUSTOM_ERROR_NONE, Opcodes opcode=SMSG_CAST_FAILED)
Definition Spell.cpp:3874
void EffectLearnSpell(SpellEffIndex effIndex)
Unit * GetCaster() const
Definition Spell.h:563
int32 damage
Definition Spell.h:630
void EffectLearnSkill(SpellEffIndex effIndex)
SpellEffectHandleMode effectHandleMode
Definition Spell.h:631
Unit *const m_caster
Definition Spell.h:581
void EffectUnlearnSpecialization(SpellEffIndex effIndex)
void EffectLearnPetSpell(SpellEffIndex effIndex)
void EffectSpecCount(SpellEffIndex effIndex)
void EffectSkill(SpellEffIndex effIndex)
uint32 m_glyphIndex
Definition Spell.h:534
Unit * unitTarget
Definition Spell.h:626
void EffectUntrainTalents(SpellEffIndex effIndex)
void EffectApplyGlyph(SpellEffIndex effIndex)
void EffectRemoveTalent(SpellEffIndex effIndex)
SpellInfo const *const m_spellInfo
Definition Spell.h:530
void EffectProficiency(SpellEffIndex effIndex)
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)
bool ShouldLearnSpellFromEffectDamage(uint32 spellId)