AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
SpellMgr.cpp File Reference
#include "SpellMgr.h"
#include "BattlefieldMgr.h"
#include "BattlegroundIC.h"
#include "BattlegroundMgr.h"
#include "Chat.h"
#include "DBCStores.h"
#include "GameGraveyard.h"
#include "InstanceScript.h"
#include "MapMgr.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "SharedDefines.h"
#include "Spell.h"
#include "SpellAuraDefines.h"
#include "SpellInfo.h"
#include "World.h"

Go to the source code of this file.

Functions

bool IsPrimaryProfessionSkill (uint32 skill)
 
bool IsPartOfSkillLine (uint32 skillId, uint32 spellId)
 
DiminishingGroup GetDiminishingReturnsGroupForSpell (SpellInfo const *spellproto, bool triggered)
 
DiminishingReturnsType GetDiminishingReturnsGroupType (DiminishingGroup group)
 
DiminishingLevels GetDiminishingReturnsMaxLevel (DiminishingGroup group)
 
int32 GetDiminishingReturnsLimitDuration (DiminishingGroup group, SpellInfo const *spellproto)
 
bool IsDiminishingReturnsGroupDurationLimited (DiminishingGroup group)
 
void DeleteSpellFromAllPlayers (uint32 spellId)
 
bool LoadPetDefaultSpells_helper (CreatureTemplate const *cInfo, PetDefaultSpellsEntry &petDefSpells)
 

Function Documentation

◆ DeleteSpellFromAllPlayers()

void DeleteSpellFromAllPlayers ( uint32  spellId)
449{
451 for (uint8 i = 0; i < 2; i++)
452 {
453 CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(stmts[i]);
454 stmt->SetData(0, spellId);
455 CharacterDatabase.Execute(stmt);
456 }
457}
std::uint8_t uint8
Definition: Define.h:109
CharacterDatabaseStatements
Definition: CharacterDatabase.h:24
@ CHAR_DEL_INVALID_SPELL_TALENTS
Definition: CharacterDatabase.h:291
@ CHAR_DEL_INVALID_SPELL_SPELLS
Definition: CharacterDatabase.h:290
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: PreparedStatement.h:157
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:77

References CHAR_DEL_INVALID_SPELL_SPELLS, CHAR_DEL_INVALID_SPELL_TALENTS, CharacterDatabase, and PreparedStatementBase::SetData().

Referenced by SpellMgr::CheckSpellValid().

◆ GetDiminishingReturnsGroupForSpell()

DiminishingGroup GetDiminishingReturnsGroupForSpell ( SpellInfo const *  spellproto,
bool  triggered 
)
59{
60 if (spellproto->IsPositive())
61 return DIMINISHING_NONE;
62
63 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
64 {
65 if (spellproto->Effects[i].ApplyAuraName == SPELL_AURA_MOD_TAUNT)
66 return DIMINISHING_TAUNT;
67 }
68
69 // Explicit Diminishing Groups
70 switch (spellproto->SpellFamilyName)
71 {
73 {
74 // Pet charge effects (Infernal Awakening, Demon Charge)
75 if (spellproto->SpellVisual[0] == 2816 && spellproto->SpellIconID == 15)
77 // Gnaw
78 else if (spellproto->Id == 47481)
80 // Screams of the Past
81 else if (spellproto->Id == 7074)
82 return DIMINISHING_NONE;
83 break;
84 }
85 // Event spells
87 return DIMINISHING_NONE;
89 {
90 // Frostbite
91 if (spellproto->Id == 12494)
92 return DIMINISHING_ROOT;
93 // Shattered Barrier
94 else if (spellproto->Id == 55080)
95 return DIMINISHING_ROOT;
96 // Deep Freeze
97 else if (spellproto->SpellIconID == 2939 && spellproto->SpellVisual[0] == 9963)
99 // Frost Nova / Freeze (Water Elemental)
100 else if (spellproto->SpellIconID == 193)
102 // Dragon's Breath
103 else if (spellproto->SpellFamilyFlags[0] & 0x800000)
105 break;
106 }
108 {
109 // Hamstring - limit duration to 10s in PvP
110 if (spellproto->SpellFamilyFlags[0] & 0x2)
112 // Improved Hamstring
113 else if (spellproto->Id == 23694)
114 return DIMINISHING_ROOT;
115 // Charge Stun (own diminishing)
116 else if (spellproto->SpellFamilyFlags[0] & 0x01000000)
117 return DIMINISHING_CHARGE;
118 break;
119 }
121 {
122 // Curses/etc
123 if ((spellproto->SpellFamilyFlags[0] & 0x80000000) || (spellproto->SpellFamilyFlags[1] & 0x200))
125 // Seduction
126 else if (spellproto->SpellFamilyFlags[1] & 0x10000000)
127 return DIMINISHING_FEAR;
128 break;
129 }
131 {
132 // Pounce
133 if (spellproto->SpellFamilyFlags[0] & 0x20000)
135 // Cyclone
136 else if (spellproto->SpellFamilyFlags[1] & 0x20)
137 return DIMINISHING_CYCLONE;
138 // Entangling Roots
139 // Nature's Grasp
140 else if (spellproto->SpellFamilyFlags[0] & 0x00000200)
142 // Faerie Fire
143 else if (spellproto->SpellFamilyFlags[0] & 0x400)
145 // Feral Charge Root Effect
146 else if (spellproto->Id == 45334)
147 return DIMINISHING_NONE;
148 break;
149 }
151 {
152 // Gouge
153 if (spellproto->SpellFamilyFlags[0] & 0x8)
155 // Blind
156 else if (spellproto->SpellFamilyFlags[0] & 0x1000000)
157 return DIMINISHING_FEAR;
158 // Cheap Shot
159 else if (spellproto->SpellFamilyFlags[0] & 0x400)
161 // Crippling poison - Limit to 10 seconds in PvP (No SpellFamilyFlags)
162 else if (spellproto->SpellIconID == 163)
164 break;
165 }
167 {
168 // Hunter's Mark
169 if ((spellproto->SpellFamilyFlags[0] & 0x400) && spellproto->SpellIconID == 538)
171 // Scatter Shot (own diminishing)
172 else if ((spellproto->SpellFamilyFlags[0] & 0x40000) && spellproto->SpellIconID == 132)
174 // Entrapment (own diminishing)
175 else if (spellproto->SpellVisual[0] == 7484 && spellproto->SpellIconID == 20)
177 // Wyvern Sting mechanic is MECHANIC_SLEEP but the diminishing is DIMINISHING_DISORIENT
178 else if ((spellproto->SpellFamilyFlags[1] & 0x1000) && spellproto->SpellIconID == 1721)
180 // Freezing Arrow
181 else if (spellproto->SpellFamilyFlags[0] & 0x8)
183 break;
184 }
186 {
187 // Judgement of Justice - limit duration to 10s in PvP
188 if (spellproto->SpellFamilyFlags[0] & 0x100000)
190 // Turn Evil
191 else if ((spellproto->SpellFamilyFlags[1] & 0x804000) && spellproto->SpellIconID == 309)
192 return DIMINISHING_FEAR;
193 break;
194 }
196 {
197 // Storm, Earth and Fire - Earthgrab
198 if (spellproto->SpellFamilyFlags[2] & 0x4000)
199 return DIMINISHING_NONE;
200 break;
201 }
203 {
204 // Hungering Cold (no flags)
205 if (spellproto->SpellIconID == 2797)
207 // Mark of Blood
208 else if ((spellproto->SpellFamilyFlags[0] & 0x10000000) && spellproto->SpellIconID == 2285)
210 break;
211 }
212 default:
213 break;
214 }
215
216 // Lastly - Set diminishing depending on mechanic
217 uint32 mechanic = spellproto->GetAllEffectsMechanicMask();
218 if (mechanic & (1 << MECHANIC_CHARM))
220 if (mechanic & (1 << MECHANIC_SILENCE))
221 return DIMINISHING_SILENCE;
222 if (mechanic & (1 << MECHANIC_SLEEP))
223 return DIMINISHING_SLEEP;
224 if (mechanic & ((1 << MECHANIC_SAPPED) | (1 << MECHANIC_POLYMORPH) | (1 << MECHANIC_SHACKLE)))
226 // Mechanic Knockout, except Blast Wave
227 if (mechanic & (1 << MECHANIC_KNOCKOUT) && spellproto->SpellIconID != 292)
229 if (mechanic & (1 << MECHANIC_DISARM))
230 return DIMINISHING_DISARM;
231 if (mechanic & (1 << MECHANIC_FEAR))
232 return DIMINISHING_FEAR;
233 if (mechanic & (1 << MECHANIC_STUN))
235 if (mechanic & (1 << MECHANIC_BANISH))
236 return DIMINISHING_BANISH;
237 if (mechanic & (1 << MECHANIC_ROOT))
239 if (mechanic & (1 << MECHANIC_HORROR))
240 return DIMINISHING_HORROR;
241
242 return DIMINISHING_NONE;
243}
std::uint32_t uint32
Definition: Define.h:107
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:1636
@ DIMINISHING_MIND_CONTROL
Definition: SharedDefines.h:3270
@ DIMINISHING_HORROR
Definition: SharedDefines.h:3269
@ DIMINISHING_DRAGONS_BREATH
Definition: SharedDefines.h:3278
@ DIMINISHING_CONTROLLED_STUN
Definition: SharedDefines.h:3262
@ DIMINISHING_CYCLONE
Definition: SharedDefines.h:3264
@ DIMINISHING_BANISH
Definition: SharedDefines.h:3259
@ DIMINISHING_CONTROLLED_ROOT
Definition: SharedDefines.h:3263
@ DIMINISHING_NONE
Definition: SharedDefines.h:3258
@ DIMINISHING_SLEEP
Definition: SharedDefines.h:3275
@ DIMINISHING_STUN
Definition: SharedDefines.h:3272
@ DIMINISHING_DISARM
Definition: SharedDefines.h:3265
@ DIMINISHING_ENTRAPMENT
Definition: SharedDefines.h:3267
@ DIMINISHING_FEAR
Definition: SharedDefines.h:3268
@ DIMINISHING_SCATTER_SHOT
Definition: SharedDefines.h:3273
@ DIMINISHING_LIMITONLY
Definition: SharedDefines.h:3277
@ DIMINISHING_OPENING_STUN
Definition: SharedDefines.h:3261
@ DIMINISHING_DISORIENT
Definition: SharedDefines.h:3266
@ DIMINISHING_ROOT
Definition: SharedDefines.h:3271
@ DIMINISHING_TAUNT
Definition: SharedDefines.h:3276
@ DIMINISHING_CHARGE
Definition: SharedDefines.h:3260
@ DIMINISHING_SILENCE
Definition: SharedDefines.h:3274
@ MECHANIC_DISARM
Definition: SharedDefines.h:1328
@ MECHANIC_FEAR
Definition: SharedDefines.h:1330
@ MECHANIC_KNOCKOUT
Definition: SharedDefines.h:1339
@ MECHANIC_CHARM
Definition: SharedDefines.h:1326
@ MECHANIC_STUN
Definition: SharedDefines.h:1337
@ MECHANIC_ROOT
Definition: SharedDefines.h:1332
@ MECHANIC_SLEEP
Definition: SharedDefines.h:1335
@ MECHANIC_POLYMORPH
Definition: SharedDefines.h:1342
@ MECHANIC_BANISH
Definition: SharedDefines.h:1343
@ MECHANIC_SILENCE
Definition: SharedDefines.h:1334
@ MECHANIC_SHACKLE
Definition: SharedDefines.h:1345
@ MECHANIC_SAPPED
Definition: SharedDefines.h:1355
@ MECHANIC_HORROR
Definition: SharedDefines.h:1349
@ SPELLFAMILY_WARLOCK
Definition: SharedDefines.h:3533
@ SPELLFAMILY_MAGE
Definition: SharedDefines.h:3531
@ SPELLFAMILY_GENERIC
Definition: SharedDefines.h:3528
@ SPELLFAMILY_WARRIOR
Definition: SharedDefines.h:3532
@ SPELLFAMILY_PALADIN
Definition: SharedDefines.h:3538
@ SPELLFAMILY_HUNTER
Definition: SharedDefines.h:3537
@ SPELLFAMILY_ROGUE
Definition: SharedDefines.h:3536
@ SPELLFAMILY_SHAMAN
Definition: SharedDefines.h:3539
@ SPELLFAMILY_DRUID
Definition: SharedDefines.h:3535
@ SPELLFAMILY_DEATHKNIGHT
Definition: SharedDefines.h:3543
@ SPELLFAMILY_UNK1
Definition: SharedDefines.h:3529
@ SPELL_AURA_MOD_TAUNT
Definition: SpellAuraDefines.h:74

References DIMINISHING_BANISH, DIMINISHING_CHARGE, DIMINISHING_CONTROLLED_ROOT, DIMINISHING_CONTROLLED_STUN, DIMINISHING_CYCLONE, DIMINISHING_DISARM, DIMINISHING_DISORIENT, DIMINISHING_DRAGONS_BREATH, DIMINISHING_ENTRAPMENT, DIMINISHING_FEAR, DIMINISHING_HORROR, DIMINISHING_LIMITONLY, DIMINISHING_MIND_CONTROL, DIMINISHING_NONE, DIMINISHING_OPENING_STUN, DIMINISHING_ROOT, DIMINISHING_SCATTER_SHOT, DIMINISHING_SILENCE, DIMINISHING_SLEEP, DIMINISHING_STUN, DIMINISHING_TAUNT, SpellInfo::Effects, SpellInfo::GetAllEffectsMechanicMask(), SpellInfo::Id, SpellInfo::IsPositive(), MAX_SPELL_EFFECTS, MECHANIC_BANISH, MECHANIC_CHARM, MECHANIC_DISARM, MECHANIC_FEAR, MECHANIC_HORROR, MECHANIC_KNOCKOUT, MECHANIC_POLYMORPH, MECHANIC_ROOT, MECHANIC_SAPPED, MECHANIC_SHACKLE, MECHANIC_SILENCE, MECHANIC_SLEEP, MECHANIC_STUN, SPELL_AURA_MOD_TAUNT, SPELLFAMILY_DEATHKNIGHT, SPELLFAMILY_DRUID, SPELLFAMILY_GENERIC, SPELLFAMILY_HUNTER, SPELLFAMILY_MAGE, SPELLFAMILY_PALADIN, SPELLFAMILY_ROGUE, SPELLFAMILY_SHAMAN, SPELLFAMILY_UNK1, SPELLFAMILY_WARLOCK, SPELLFAMILY_WARRIOR, SpellInfo::SpellFamilyFlags, SpellInfo::SpellFamilyName, SpellInfo::SpellIconID, and SpellInfo::SpellVisual.

Referenced by Spell::DoSpellHitOnUnit().

◆ GetDiminishingReturnsGroupType()

DiminishingReturnsType GetDiminishingReturnsGroupType ( DiminishingGroup  group)
246{
247 switch (group)
248 {
251 case DIMINISHING_STUN:
255 return DRTYPE_ALL;
257 case DIMINISHING_NONE:
258 return DRTYPE_NONE;
259 default:
260 return DRTYPE_PLAYER;
261 }
262}
@ DRTYPE_NONE
Definition: SharedDefines.h:3250
@ DRTYPE_PLAYER
Definition: SharedDefines.h:3251
@ DRTYPE_ALL
Definition: SharedDefines.h:3252

References DIMINISHING_CHARGE, DIMINISHING_CONTROLLED_STUN, DIMINISHING_CYCLONE, DIMINISHING_LIMITONLY, DIMINISHING_NONE, DIMINISHING_OPENING_STUN, DIMINISHING_STUN, DIMINISHING_TAUNT, DRTYPE_ALL, DRTYPE_NONE, and DRTYPE_PLAYER.

Referenced by Unit::ApplyDiminishingToDuration(), and Spell::DoSpellHitOnUnit().

◆ GetDiminishingReturnsLimitDuration()

int32 GetDiminishingReturnsLimitDuration ( DiminishingGroup  group,
SpellInfo const *  spellproto 
)
276{
278 return 0;
279
280 // Explicit diminishing duration
281 switch (spellproto->SpellFamilyName)
282 {
284 {
285 // Faerie Fire - limit to 40 seconds in PvP (3.1)
286 if (spellproto->SpellFamilyFlags[0] & 0x400)
287 return 40 * IN_MILLISECONDS;
288 break;
289 }
291 {
292 // Wyvern Sting
293 if (spellproto->SpellFamilyFlags[1] & 0x1000)
294 return 6 * IN_MILLISECONDS;
295 // Hunter's Mark
296 if (spellproto->SpellFamilyFlags[0] & 0x400)
297 return 120 * IN_MILLISECONDS;
298 break;
299 }
301 {
302 // Repentance - limit to 6 seconds in PvP
303 if (spellproto->SpellFamilyFlags[0] & 0x4)
304 return 6 * IN_MILLISECONDS;
305 break;
306 }
308 {
309 // Banish - limit to 6 seconds in PvP
310 if (spellproto->SpellFamilyFlags[1] & 0x8000000)
311 return 6 * IN_MILLISECONDS;
312 // Curse of Tongues - limit to 12 seconds in PvP
313 else if (spellproto->SpellFamilyFlags[2] & 0x800)
314 return 12 * IN_MILLISECONDS;
315 // Curse of Elements - limit to 120 seconds in PvP
316 else if (spellproto->SpellFamilyFlags[1] & 0x200)
317 return 120 * IN_MILLISECONDS;
318 // Curse of Exhaustion
319 else if (spellproto->SpellFamilyFlags[0] & 0x400000)
320 return 12 * IN_MILLISECONDS;
321 break;
322 }
323 default:
324 break;
325 }
326
327 return 10 * IN_MILLISECONDS;
328}
constexpr auto IN_MILLISECONDS
Definition: Common.h:53
bool IsDiminishingReturnsGroupDurationLimited(DiminishingGroup group)
Definition: SpellMgr.cpp:330

References IN_MILLISECONDS, IsDiminishingReturnsGroupDurationLimited(), SPELLFAMILY_DRUID, SPELLFAMILY_HUNTER, SPELLFAMILY_PALADIN, SPELLFAMILY_WARLOCK, SpellInfo::SpellFamilyFlags, and SpellInfo::SpellFamilyName.

Referenced by Spell::DoSpellHitOnUnit().

◆ GetDiminishingReturnsMaxLevel()

DiminishingLevels GetDiminishingReturnsMaxLevel ( DiminishingGroup  group)
265{
266 switch (group)
267 {
270 default:
272 }
273}
@ DIMINISHING_LEVEL_IMMUNE
Definition: Unit.h:266
@ DIMINISHING_LEVEL_TAUNT_IMMUNE
Definition: Unit.h:268

References DIMINISHING_LEVEL_IMMUNE, DIMINISHING_LEVEL_TAUNT_IMMUNE, and DIMINISHING_TAUNT.

Referenced by Unit::IncrDiminishing().

◆ IsDiminishingReturnsGroupDurationLimited()

◆ IsPartOfSkillLine()

bool IsPartOfSkillLine ( uint32  skillId,
uint32  spellId 
)
49{
50 SkillLineAbilityMapBounds skillBounds = sSpellMgr->GetSkillLineAbilityMapBounds(spellId);
51 for (SkillLineAbilityMap::const_iterator itr = skillBounds.first; itr != skillBounds.second; ++itr)
52 if (itr->second->SkillLine == skillId)
53 return true;
54
55 return false;
56}
#define sSpellMgr
Definition: SpellMgr.h:825
std::pair< SkillLineAbilityMap::const_iterator, SkillLineAbilityMap::const_iterator > SkillLineAbilityMapBounds
Definition: SpellMgr.h:584

References sSpellMgr.

Referenced by SpellMgr::LoadSpellInfoCustomAttributes().

◆ IsPrimaryProfessionSkill()

bool IsPrimaryProfessionSkill ( uint32  skill)
37{
38 SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(skill);
39 if (!pSkill)
40 return false;
41
43 return false;
44
45 return true;
46}
@ SKILL_CATEGORY_PROFESSION
Definition: SharedDefines.h:3078
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
Definition: DBCStructure.h:1582
int32 categoryId
Definition: DBCStructure.h:1584

References SkillLineEntry::categoryId, SKILL_CATEGORY_PROFESSION, and sSkillLineStore.

Referenced by WorldSession::HandleUnlearnSkillOpcode(), SpellInfo::IsPrimaryProfession(), and IsProfessionSkill().

◆ LoadPetDefaultSpells_helper()

bool LoadPetDefaultSpells_helper ( CreatureTemplate const *  cInfo,
PetDefaultSpellsEntry petDefSpells 
)
2352{
2353 // skip empty list;
2354 bool have_spell = false;
2355 for (uint8 j = 0; j < MAX_CREATURE_SPELL_DATA_SLOT; ++j)
2356 {
2357 if (petDefSpells.spellid[j])
2358 {
2359 have_spell = true;
2360 break;
2361 }
2362 }
2363 if (!have_spell)
2364 return false;
2365
2366 // remove duplicates with levelupSpells if any
2367 if (PetLevelupSpellSet const* levelupSpells = cInfo->family ? sSpellMgr->GetPetLevelupSpellList(cInfo->family) : nullptr)
2368 {
2369 for (uint8 j = 0; j < MAX_CREATURE_SPELL_DATA_SLOT; ++j)
2370 {
2371 if (!petDefSpells.spellid[j])
2372 continue;
2373
2374 for (PetLevelupSpellSet::const_iterator itr = levelupSpells->begin(); itr != levelupSpells->end(); ++itr)
2375 {
2376 if (itr->second == petDefSpells.spellid[j])
2377 {
2378 petDefSpells.spellid[j] = 0;
2379 break;
2380 }
2381 }
2382 }
2383 }
2384
2385 // skip empty list;
2386 have_spell = false;
2387 for (uint8 j = 0; j < MAX_CREATURE_SPELL_DATA_SLOT; ++j)
2388 {
2389 if (petDefSpells.spellid[j])
2390 {
2391 have_spell = true;
2392 break;
2393 }
2394 }
2395
2396 return have_spell;
2397}
#define MAX_CREATURE_SPELL_DATA_SLOT
Definition: DBCStructure.h:806
std::multimap< uint32, uint32 > PetLevelupSpellSet
Definition: SpellMgr.h:586
uint32 spellid[MAX_CREATURE_SPELL_DATA_SLOT]
Definition: SpellMgr.h:593

References CreatureTemplate::family, MAX_CREATURE_SPELL_DATA_SLOT, PetDefaultSpellsEntry::spellid, and sSpellMgr.

Referenced by SpellMgr::LoadPetDefaultSpells().