2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 // For static or at-server-startup loaded spell data
23 // For more high level function for sSpellStore data
25 #include "SharedDefines.h"
26 #include "DBCStructure.h"
27 #include "Database/SQLStorage.h"
29 #include "Utilities/UnorderedMap.h"
38 extern SQLStorage sSpellThreatStore
;
43 SPELLCATEGORY_HEALTH_MANA_POTIONS
= 4,
44 SPELLCATEGORY_DEVOUR_MAGIC
= 12
49 SPELLFAMILY_GENERIC
= 0,
50 SPELLFAMILY_UNK1
= 1, // events, holidays
53 SPELLFAMILY_WARRIOR
= 4,
54 SPELLFAMILY_WARLOCK
= 5,
55 SPELLFAMILY_PRIEST
= 6,
56 SPELLFAMILY_DRUID
= 7,
57 SPELLFAMILY_ROGUE
= 8,
58 SPELLFAMILY_HUNTER
= 9,
59 SPELLFAMILY_PALADIN
= 10,
60 SPELLFAMILY_SHAMAN
= 11,
61 SPELLFAMILY_UNK2
= 12, // 2 spells (silence resistance)
62 SPELLFAMILY_POTION
= 13,
64 SPELLFAMILY_DEATHKNIGHT
= 15,
69 //Some SpellFamilyFlags
70 #define SPELLFAMILYFLAG_ROGUE_VANISH 0x000000800LL
71 #define SPELLFAMILYFLAG_ROGUE_STEALTH 0x000400000LL
72 #define SPELLFAMILYFLAG_ROGUE_BACKSTAB 0x000800004LL
73 #define SPELLFAMILYFLAG_ROGUE_SAP 0x000000080LL
74 #define SPELLFAMILYFLAG_ROGUE_FEINT 0x008000000LL
75 #define SPELLFAMILYFLAG_ROGUE_KIDNEYSHOT 0x000200000LL
76 #define SPELLFAMILYFLAG_ROGUE__FINISHING_MOVE 0x9003E0000LL
78 #define SPELLFAMILYFLAG_PALADIN_SEALS 0x26000C000A000000LL
79 // Spell clasification
90 SPELL_WARLOCK_ARMOR
= 8,
92 SPELL_ELEMENTAL_SHIELD
= 10,
93 SPELL_MAGE_POLYMORPH
= 11,
94 SPELL_POSITIVE_SHOUT
= 12,
96 SPELL_BATTLE_ELIXIR
= 14,
97 SPELL_GUARDIAN_ELIXIR
= 15,
98 SPELL_FLASK_ELIXIR
= 16,
102 SpellSpecific
GetSpellSpecific(uint32 spellId
);
104 // Different spell properties
105 inline float GetSpellRadius(SpellRadiusEntry
const *radius
) { return (radius
? radius
->Radius
: 0); }
106 uint32
GetSpellCastTime(SpellEntry
const* spellInfo
, Spell
const* spell
= NULL
);
107 inline float GetSpellMinRange(SpellRangeEntry
const *range
) { return (range
? range
->minRange
: 0); }
108 inline float GetSpellMaxRange(SpellRangeEntry
const *range
) { return (range
? range
->maxRange
: 0); }
109 inline uint32
GetSpellRecoveryTime(SpellEntry
const *spellInfo
) { return spellInfo
->RecoveryTime
> spellInfo
->CategoryRecoveryTime
? spellInfo
->RecoveryTime
: spellInfo
->CategoryRecoveryTime
; }
110 int32
GetSpellDuration(SpellEntry
const *spellInfo
);
111 int32
GetSpellMaxDuration(SpellEntry
const *spellInfo
);
113 inline bool IsSpellHaveEffect(SpellEntry
const *spellInfo
, SpellEffects effect
)
115 for(int i
= 0; i
< 3; ++i
)
116 if(SpellEffects(spellInfo
->Effect
[i
])==effect
)
121 bool IsNoStackAuraDueToAura(uint32 spellId_1
, uint32 effIndex_1
, uint32 spellId_2
, uint32 effIndex_2
);
123 inline bool IsSealSpell(SpellEntry
const *spellInfo
)
125 //Collection of all the seal family flags. No other paladin spell has any of those.
126 return spellInfo
->SpellFamilyName
== SPELLFAMILY_PALADIN
&&
127 ( spellInfo
->SpellFamilyFlags
& SPELLFAMILYFLAG_PALADIN_SEALS
);
130 inline bool IsElementalShield(SpellEntry
const *spellInfo
)
132 // family flags 10 (Lightning), 42 (Earth), 37 (Water), proc shield from T2 8 pieces bonus
133 return (spellInfo
->SpellFamilyFlags
& 0x42000000400LL
) || spellInfo
->Id
== 23552;
136 inline bool IsExplicitDiscoverySpell(SpellEntry
const *spellInfo
)
138 return spellInfo
->Effect
[0]==SPELL_EFFECT_CREATE_ITEM_2
&& spellInfo
->Effect
[1]==SPELL_EFFECT_SCRIPT_EFFECT
;
141 inline bool IsLootCraftingSpell(SpellEntry
const *spellInfo
)
143 return spellInfo
->Effect
[0]==SPELL_EFFECT_CREATE_ITEM_2
&&
144 (spellInfo
->Effect
[1]==SPELL_EFFECT_SCRIPT_EFFECT
|| !spellInfo
->EffectItemType
[0]);
147 int32
CompareAuraRanks(uint32 spellId_1
, uint32 effIndex_1
, uint32 spellId_2
, uint32 effIndex_2
);
148 bool IsSingleFromSpellSpecificPerCaster(SpellSpecific spellSpec1
,SpellSpecific spellSpec2
);
149 bool IsSingleFromSpellSpecificRanksPerTarget(SpellSpecific spellId_spec
, SpellSpecific i_spellId_spec
);
150 bool IsPassiveSpell(uint32 spellId
);
152 inline bool IsPassiveSpellStackableWithRanks(SpellEntry
const* spellProto
)
154 if(!IsPassiveSpell(spellProto
->Id
))
157 return !IsSpellHaveEffect(spellProto
,SPELL_EFFECT_APPLY_AURA
);
161 inline bool IsDeathPersistentSpell(SpellEntry
const *spellInfo
)
163 return spellInfo
->AttributesEx3
& SPELL_ATTR_EX3_DEATH_PERSISTENT
;
166 inline bool IsNonCombatSpell(SpellEntry
const *spellInfo
)
168 return (spellInfo
->Attributes
& SPELL_ATTR_CANT_USED_IN_COMBAT
) != 0;
171 bool IsPositiveSpell(uint32 spellId
);
172 bool IsPositiveEffect(uint32 spellId
, uint32 effIndex
);
173 bool IsPositiveTarget(uint32 targetA
, uint32 targetB
);
175 bool IsSingleTargetSpell(SpellEntry
const *spellInfo
);
176 bool IsSingleTargetSpells(SpellEntry
const *spellInfo1
, SpellEntry
const *spellInfo2
);
178 bool IsAuraAddedBySpell(uint32 auraType
, uint32 spellId
);
180 inline bool IsAreaEffectTarget( Targets target
)
184 case TARGET_AREAEFFECT_CUSTOM
:
185 case TARGET_ALL_ENEMY_IN_AREA
:
186 case TARGET_ALL_ENEMY_IN_AREA_INSTANT
:
187 case TARGET_ALL_PARTY_AROUND_CASTER
:
188 case TARGET_IN_FRONT_OF_CASTER
:
189 case TARGET_ALL_ENEMY_IN_AREA_CHANNELED
:
190 case TARGET_ALL_FRIENDLY_UNITS_AROUND_CASTER
:
191 case TARGET_ALL_FRIENDLY_UNITS_IN_AREA
:
192 case TARGET_ALL_PARTY
:
193 case TARGET_ALL_PARTY_AROUND_CASTER_2
:
194 case TARGET_AREAEFFECT_PARTY
:
195 case TARGET_AREAEFFECT_CUSTOM_2
:
196 case TARGET_ALL_RAID_AROUND_CASTER
:
197 case TARGET_AREAEFFECT_PARTY_AND_CLASS
:
205 inline bool IsAreaOfEffectSpell(SpellEntry
const *spellInfo
)
207 if(IsAreaEffectTarget(Targets(spellInfo
->EffectImplicitTargetA
[0])) || IsAreaEffectTarget(Targets(spellInfo
->EffectImplicitTargetB
[0])))
209 if(IsAreaEffectTarget(Targets(spellInfo
->EffectImplicitTargetA
[1])) || IsAreaEffectTarget(Targets(spellInfo
->EffectImplicitTargetB
[1])))
211 if(IsAreaEffectTarget(Targets(spellInfo
->EffectImplicitTargetA
[2])) || IsAreaEffectTarget(Targets(spellInfo
->EffectImplicitTargetB
[2])))
216 inline bool IsAreaAuraEffect(uint32 effect
)
218 if( effect
== SPELL_EFFECT_APPLY_AREA_AURA_PARTY
||
219 effect
== SPELL_EFFECT_APPLY_AREA_AURA_RAID
||
220 effect
== SPELL_EFFECT_APPLY_AREA_AURA_FRIEND
||
221 effect
== SPELL_EFFECT_APPLY_AREA_AURA_ENEMY
||
222 effect
== SPELL_EFFECT_APPLY_AREA_AURA_PET
||
223 effect
== SPELL_EFFECT_APPLY_AREA_AURA_OWNER
)
228 inline bool IsDispelSpell(SpellEntry
const *spellInfo
)
230 if (spellInfo
->Effect
[0] == SPELL_EFFECT_DISPEL
||
231 spellInfo
->Effect
[1] == SPELL_EFFECT_DISPEL
||
232 spellInfo
->Effect
[2] == SPELL_EFFECT_DISPEL
)
236 inline bool isSpellBreakStealth(SpellEntry
const* spellInfo
)
238 return !(spellInfo
->AttributesEx
& SPELL_ATTR_EX_NOT_BREAK_STEALTH
);
241 inline bool IsAutoRepeatRangedSpell(SpellEntry
const* spellInfo
)
243 return (spellInfo
->Attributes
& SPELL_ATTR_RANGED
) && (spellInfo
->AttributesEx2
& SPELL_ATTR_EX2_AUTOREPEAT_FLAG
);
246 SpellCastResult
GetErrorAtShapeshiftedCast (SpellEntry
const *spellInfo
, uint32 form
);
248 inline bool IsChanneledSpell(SpellEntry
const* spellInfo
)
250 return (spellInfo
->AttributesEx
& (SPELL_ATTR_EX_CHANNELED_1
| SPELL_ATTR_EX_CHANNELED_2
));
253 inline bool NeedsComboPoints(SpellEntry
const* spellInfo
)
255 return (spellInfo
->AttributesEx
& (SPELL_ATTR_EX_REQ_COMBO_POINTS1
| SPELL_ATTR_EX_REQ_COMBO_POINTS2
));
258 inline SpellSchoolMask
GetSpellSchoolMask(SpellEntry
const* spellInfo
)
260 return SpellSchoolMask(spellInfo
->SchoolMask
);
263 inline uint32
GetSpellMechanicMask(SpellEntry
const* spellInfo
, int32 effect
)
266 if (spellInfo
->Mechanic
)
267 mask
|= 1<<spellInfo
->Mechanic
;
268 if (spellInfo
->EffectMechanic
[effect
])
269 mask
|= 1<<spellInfo
->EffectMechanic
[effect
];
273 inline uint32
GetAllSpellMechanicMask(SpellEntry
const* spellInfo
)
276 if (spellInfo
->Mechanic
)
277 mask
|= 1<<spellInfo
->Mechanic
;
278 for (int i
=0; i
< 3; ++i
)
279 if (spellInfo
->EffectMechanic
[i
])
280 mask
|= 1<<spellInfo
->EffectMechanic
[i
];
284 inline Mechanics
GetEffectMechanic(SpellEntry
const* spellInfo
, int32 effect
)
286 if (spellInfo
->EffectMechanic
[effect
])
287 return Mechanics(spellInfo
->EffectMechanic
[effect
]);
288 if (spellInfo
->Mechanic
)
289 return Mechanics(spellInfo
->Mechanic
);
290 return MECHANIC_NONE
;
293 inline uint32
GetDispellMask(DispelType dispel
)
296 if (dispel
== DISPEL_ALL
)
297 return DISPEL_ALL_MASK
;
299 return (1 << dispel
);
302 // Diminishing Returns interaction with spells
303 DiminishingGroup
GetDiminishingReturnsGroupForSpell(SpellEntry
const* spellproto
, bool triggered
);
304 bool IsDiminishingReturnsGroupDurationLimited(DiminishingGroup group
);
305 DiminishingReturnsType
GetDiminishingReturnsGroupType(DiminishingGroup group
);
307 // Spell affects related declarations (accessed using SpellMgr functions)
308 struct SpellAffectEntry
310 uint32 SpellClassMask
[3];
312 typedef UNORDERED_MAP
<uint32
, SpellAffectEntry
> SpellAffectMap
;
314 // Spell proc event related declarations (accessed using SpellMgr functions)
317 PROC_FLAG_NONE
= 0x00000000,
319 PROC_FLAG_KILLED
= 0x00000001, // 00 Killed by agressor
320 PROC_FLAG_KILL
= 0x00000002, // 01 Kill target (in most cases need XP/Honor reward)
322 PROC_FLAG_SUCCESSFUL_MILEE_HIT
= 0x00000004, // 02 Successful melee auto attack
323 PROC_FLAG_TAKEN_MELEE_HIT
= 0x00000008, // 03 Taken damage from melee auto attack hit
325 PROC_FLAG_SUCCESSFUL_MELEE_SPELL_HIT
= 0x00000010, // 04 Successful attack by Spell that use melee weapon
326 PROC_FLAG_TAKEN_MELEE_SPELL_HIT
= 0x00000020, // 05 Taken damage by Spell that use melee weapon
328 PROC_FLAG_SUCCESSFUL_RANGED_HIT
= 0x00000040, // 06 Successful Ranged auto attack
329 PROC_FLAG_TAKEN_RANGED_HIT
= 0x00000080, // 07 Taken damage from ranged auto attack
331 PROC_FLAG_SUCCESSFUL_RANGED_SPELL_HIT
= 0x00000100, // 08 Successful Ranged attack by Spell that use ranged weapon
332 PROC_FLAG_TAKEN_RANGED_SPELL_HIT
= 0x00000200, // 09 Taken damage by Spell that use ranged weapon
334 PROC_FLAG_SUCCESSFUL_POSITIVE_AOE_HIT
= 0x00000400, // 10 Successful AoE (not 100% shure unused)
335 PROC_FLAG_TAKEN_POSITIVE_AOE
= 0x00000800, // 11 Taken AoE (not 100% shure unused)
337 PROC_FLAG_SUCCESSFUL_AOE_SPELL_HIT
= 0x00001000, // 12 Successful AoE damage spell hit (not 100% shure unused)
338 PROC_FLAG_TAKEN_AOE_SPELL_HIT
= 0x00002000, // 13 Taken AoE damage spell hit (not 100% shure unused)
340 PROC_FLAG_SUCCESSFUL_POSITIVE_SPELL
= 0x00004000, // 14 Successful cast positive spell (by default only on healing)
341 PROC_FLAG_TAKEN_POSITIVE_SPELL
= 0x00008000, // 15 Taken positive spell hit (by default only on healing)
343 PROC_FLAG_SUCCESSFUL_NEGATIVE_SPELL_HIT
= 0x00010000, // 16 Successful negative spell cast (by default only on damage)
344 PROC_FLAG_TAKEN_NEGATIVE_SPELL_HIT
= 0x00020000, // 17 Taken negative spell (by default only on damage)
346 PROC_FLAG_ON_DO_PERIODIC
= 0x00040000, // 18 Successful do periodic (damage / healing, determined from 14-17 flags)
347 PROC_FLAG_ON_TAKE_PERIODIC
= 0x00080000, // 19 Taken spell periodic (damage / healing, determined from 14-17 flags)
349 PROC_FLAG_TAKEN_ANY_DAMAGE
= 0x00100000, // 20 Taken any damage
350 PROC_FLAG_ON_TRAP_ACTIVATION
= 0x00200000, // 21 On trap activation
352 PROC_FLAG_TAKEN_OFFHAND_HIT
= 0x00400000, // 22 Taken off-hand melee attacks(not used)
353 PROC_FLAG_SUCCESSFUL_OFFHAND_HIT
= 0x00800000 // 23 Successful off-hand melee attacks
356 #define MELEE_BASED_TRIGGER_MASK (PROC_FLAG_SUCCESSFUL_MILEE_HIT | \
357 PROC_FLAG_TAKEN_MELEE_HIT | \
358 PROC_FLAG_SUCCESSFUL_MELEE_SPELL_HIT | \
359 PROC_FLAG_TAKEN_MELEE_SPELL_HIT | \
360 PROC_FLAG_SUCCESSFUL_RANGED_HIT | \
361 PROC_FLAG_TAKEN_RANGED_HIT | \
362 PROC_FLAG_SUCCESSFUL_RANGED_SPELL_HIT | \
363 PROC_FLAG_TAKEN_RANGED_SPELL_HIT)
367 PROC_EX_NONE
= 0x0000000, // If none can tigger on Hit/Crit only (passive spells MUST defined by SpellFamily flag)
368 PROC_EX_NORMAL_HIT
= 0x0000001, // If set only from normal hit (only damage spells)
369 PROC_EX_CRITICAL_HIT
= 0x0000002,
370 PROC_EX_MISS
= 0x0000004,
371 PROC_EX_RESIST
= 0x0000008,
372 PROC_EX_DODGE
= 0x0000010,
373 PROC_EX_PARRY
= 0x0000020,
374 PROC_EX_BLOCK
= 0x0000040,
375 PROC_EX_EVADE
= 0x0000080,
376 PROC_EX_IMMUNE
= 0x0000100,
377 PROC_EX_DEFLECT
= 0x0000200,
378 PROC_EX_ABSORB
= 0x0000400,
379 PROC_EX_REFLECT
= 0x0000800,
380 PROC_EX_INTERRUPT
= 0x0001000, // Melee hit result can be Interrupt (not used)
381 PROC_EX_RESERVED1
= 0x0002000,
382 PROC_EX_RESERVED2
= 0x0004000,
383 PROC_EX_RESERVED3
= 0x0008000,
384 PROC_EX_EX_TRIGGER_ALWAYS
= 0x0010000, // If set trigger always ( no matter another flags) used for drop charges
385 PROC_EX_EX_ONE_TIME_TRIGGER
= 0x0020000 // If set trigger always but only one time (not used)
388 struct SpellProcEventEntry
390 uint32 schoolMask
; // if nonzero - bit mask for matching proc condition based on spell candidate's school: Fire=2, Mask=1<<(2-1)=2
391 uint32 spellFamilyName
; // if nonzero - for matching proc condition based on candidate spell's SpellFamilyNamer value
392 uint64 spellFamilyMask
; // if nonzero - for matching proc condition based on candidate spell's SpellFamilyFlags (like auras 107 and 108 do)
393 uint32 spellFamilyMask2
; // if nonzero - for matching proc condition based on candidate spell's SpellFamilyFlags2 (like auras 107 and 108 do)
394 uint32 procFlags
; // bitmask for matching proc event
395 uint32 procEx
; // proc Extend info (see ProcFlagsEx)
396 float ppmRate
; // for melee (ranged?) damage spells - proc rate per minute. if zero, falls back to flat chance from Spell.dbc
397 float customChance
; // Owerride chance (in most cases for debug only)
398 uint32 cooldown
; // hidden cooldown used for some spell proc events, applied to _triggered_spell_
401 struct SpellBonusEntry
408 typedef UNORDERED_MAP
<uint32
, SpellProcEventEntry
> SpellProcEventMap
;
409 typedef UNORDERED_MAP
<uint32
, SpellBonusEntry
> SpellBonusMap
;
411 #define ELIXIR_BATTLE_MASK 0x1
412 #define ELIXIR_GUARDIAN_MASK 0x2
413 #define ELIXIR_FLASK_MASK (ELIXIR_BATTLE_MASK|ELIXIR_GUARDIAN_MASK)
414 #define ELIXIR_UNSTABLE_MASK 0x4
415 #define ELIXIR_SHATTRATH_MASK 0x8
417 typedef std::map
<uint32
, uint8
> SpellElixirMap
;
419 // Spell script target related declarations (accessed using SpellMgr functions)
422 SPELL_TARGET_TYPE_GAMEOBJECT
= 0,
423 SPELL_TARGET_TYPE_CREATURE
= 1,
424 SPELL_TARGET_TYPE_DEAD
= 2
427 #define MAX_SPELL_TARGET_TYPE 3
429 struct SpellTargetEntry
431 SpellTargetEntry(SpellTargetType type_
,uint32 targetEntry_
) : type(type_
), targetEntry(targetEntry_
) {}
432 SpellTargetType type
;
436 typedef std::multimap
<uint32
,SpellTargetEntry
> SpellScriptTarget
;
438 // coordinates for spells (accessed using SpellMgr functions)
439 struct SpellTargetPosition
445 float target_Orientation
;
448 typedef UNORDERED_MAP
<uint32
, SpellTargetPosition
> SpellTargetPositionMap
;
459 PetAura(uint16 petEntry
, uint16 aura
, bool _removeOnChangePet
, int _damage
) :
460 removeOnChangePet(_removeOnChangePet
), damage(_damage
)
462 auras
[petEntry
] = aura
;
465 uint16
GetAura(uint16 petEntry
) const
467 std::map
<uint16
, uint16
>::const_iterator itr
= auras
.find(petEntry
);
468 if(itr
!= auras
.end())
472 std::map
<uint16
, uint16
>::const_iterator itr
= auras
.find(0);
473 if(itr
!= auras
.end())
480 void AddAura(uint16 petEntry
, uint16 aura
)
482 auras
[petEntry
] = aura
;
485 bool IsRemovedOnChangePet() const
487 return removeOnChangePet
;
490 int32
GetDamage() const
496 std::map
<uint16
, uint16
> auras
;
497 bool removeOnChangePet
;
500 typedef std::map
<uint16
, PetAura
> SpellPetAuraMap
;
505 uint32 areaId
; // zone/subzone/or 0 is not limited to zone
506 uint32 questStart
; // quest start (quest must be active or rewarded for spell apply)
507 uint32 questEnd
; // quest end (quest don't must be rewarded for spell apply)
508 int32 auraSpell
; // spell aura must be applied for spell apply )if possitive) and it don't must be applied in other case
509 uint32 raceMask
; // can be applied only to races
510 Gender gender
; // can be applied only to gender
511 bool questStartCanActive
; // if true then quest start can be active (not only rewarded)
512 bool autocast
; // if true then auto applied at area enter, in other case just allowed to cast
515 bool IsFitToRequirements(Player
const* player
, uint32 newZone
, uint32 newArea
) const;
518 typedef std::multimap
<uint32
,SpellArea
> SpellAreaMap
;
519 typedef std::multimap
<uint32
,SpellArea
const*> SpellAreaForQuestMap
;
520 typedef std::multimap
<uint32
,SpellArea
const*> SpellAreaForAuraMap
;
521 typedef std::multimap
<uint32
,SpellArea
const*> SpellAreaForAreaMap
;
522 typedef std::pair
<SpellAreaMap::const_iterator
,SpellAreaMap::const_iterator
> SpellAreaMapBounds
;
523 typedef std::pair
<SpellAreaForQuestMap::const_iterator
,SpellAreaForQuestMap::const_iterator
> SpellAreaForQuestMapBounds
;
524 typedef std::pair
<SpellAreaForAuraMap::const_iterator
, SpellAreaForAuraMap::const_iterator
> SpellAreaForAuraMapBounds
;
525 typedef std::pair
<SpellAreaForAreaMap::const_iterator
, SpellAreaForAreaMap::const_iterator
> SpellAreaForAreaMapBounds
;
528 // Spell rank chain (accessed using SpellMgr functions)
529 struct SpellChainNode
537 typedef UNORDERED_MAP
<uint32
, SpellChainNode
> SpellChainMap
;
538 typedef std::multimap
<uint32
, uint32
> SpellChainMapNext
;
540 // Spell learning properties (accessed using SpellMgr functions)
541 struct SpellLearnSkillNode
544 uint32 value
; // 0 - max skill value for player level
545 uint32 maxvalue
; // 0 - max skill value for player level
548 typedef std::map
<uint32
, SpellLearnSkillNode
> SpellLearnSkillMap
;
550 struct SpellLearnSpellNode
553 bool active
; // show in spellbook or not
557 typedef std::multimap
<uint32
, SpellLearnSpellNode
> SpellLearnSpellMap
;
559 typedef std::multimap
<uint32
, SkillLineAbilityEntry
const*> SkillLineAbilityMap
;
561 typedef std::map
<uint32
, uint32
> PetLevelupSpellSet
;
562 typedef std::map
<uint32
, PetLevelupSpellSet
> PetLevelupSpellMap
;
564 inline bool IsPrimaryProfessionSkill(uint32 skill
)
566 SkillLineEntry
const *pSkill
= sSkillLineStore
.LookupEntry(skill
);
570 if(pSkill
->categoryId
!= SKILL_CATEGORY_PROFESSION
)
576 inline bool IsProfessionSkill(uint32 skill
)
578 return IsPrimaryProfessionSkill(skill
) || skill
== SKILL_FISHING
|| skill
== SKILL_COOKING
|| skill
== SKILL_FIRST_AID
;
581 inline bool IsProfessionOrRidingSkill(uint32 skill
)
583 return IsProfessionSkill(skill
) || skill
== SKILL_RIDING
;
593 // Accessors (const or static functions)
596 SpellAffectEntry
const*GetSpellAffect(uint16 spellId
, uint8 effectId
) const
598 SpellAffectMap::const_iterator itr
= mSpellAffectMap
.find((spellId
<<8) + effectId
);
599 if( itr
!= mSpellAffectMap
.end( ) )
604 bool IsAffectedByMod(SpellEntry
const *spellInfo
, SpellModifier
*mod
) const;
606 SpellElixirMap
const& GetSpellElixirMap() const { return mSpellElixirs
; }
608 uint32
GetSpellElixirMask(uint32 spellid
) const
610 SpellElixirMap::const_iterator itr
= mSpellElixirs
.find(spellid
);
611 if(itr
==mSpellElixirs
.end())
617 SpellSpecific
GetSpellElixirSpecific(uint32 spellid
) const
619 uint32 mask
= GetSpellElixirMask(spellid
);
620 if((mask
& ELIXIR_FLASK_MASK
)==ELIXIR_FLASK_MASK
)
621 return SPELL_FLASK_ELIXIR
;
622 else if(mask
& ELIXIR_BATTLE_MASK
)
623 return SPELL_BATTLE_ELIXIR
;
624 else if(mask
& ELIXIR_GUARDIAN_MASK
)
625 return SPELL_GUARDIAN_ELIXIR
;
631 SpellProcEventEntry
const* GetSpellProcEvent(uint32 spellId
) const
633 SpellProcEventMap::const_iterator itr
= mSpellProcEventMap
.find(spellId
);
634 if( itr
!= mSpellProcEventMap
.end( ) )
639 static bool IsSpellProcEventCanTriggeredBy( SpellProcEventEntry
const * spellProcEvent
, uint32 EventProcFlag
, SpellEntry
const * procSpell
, uint32 procFlags
, uint32 procExtra
, bool active
);
642 SpellBonusEntry
const* GetSpellBonusData(uint32 spellId
) const
645 SpellBonusMap::const_iterator itr
= mSpellBonusMap
.find(spellId
);
646 if( itr
!= mSpellBonusMap
.end( ) )
648 // Not found, try lookup for 1 spell rank if exist
649 if (uint32 rank_1
= GetFirstSpellInChain(spellId
))
651 SpellBonusMap::const_iterator itr
= mSpellBonusMap
.find(rank_1
);
652 if( itr
!= mSpellBonusMap
.end( ) )
658 // Spell target coordinates
659 SpellTargetPosition
const* GetSpellTargetPosition(uint32 spell_id
) const
661 SpellTargetPositionMap::const_iterator itr
= mSpellTargetPositions
.find( spell_id
);
662 if( itr
!= mSpellTargetPositions
.end( ) )
667 // Spell ranks chains
668 SpellChainNode
const* GetSpellChainNode(uint32 spell_id
) const
670 SpellChainMap::const_iterator itr
= mSpellChains
.find(spell_id
);
671 if(itr
== mSpellChains
.end())
677 uint32
GetFirstSpellInChain(uint32 spell_id
) const
679 if(SpellChainNode
const* node
= GetSpellChainNode(spell_id
))
685 uint32
GetPrevSpellInChain(uint32 spell_id
) const
687 if(SpellChainNode
const* node
= GetSpellChainNode(spell_id
))
693 SpellChainMapNext
const& GetSpellChainNext() const { return mSpellChainsNext
; }
695 // Note: not use rank for compare to spell ranks: spell chains isn't linear order
696 // Use IsHighRankOfSpell instead
697 uint8
GetSpellRank(uint32 spell_id
) const
699 if(SpellChainNode
const* node
= GetSpellChainNode(spell_id
))
705 uint8
IsHighRankOfSpell(uint32 spell1
,uint32 spell2
) const
707 SpellChainMap::const_iterator itr
= mSpellChains
.find(spell1
);
709 uint32 rank2
= GetSpellRank(spell2
);
711 // not ordered correctly by rank value
712 if(itr
== mSpellChains
.end() || !rank2
|| itr
->second
.rank
<= rank2
)
715 // check present in same rank chain
716 for(; itr
!= mSpellChains
.end(); itr
= mSpellChains
.find(itr
->second
.prev
))
717 if(itr
->second
.prev
==spell2
)
723 bool IsRankSpellDueToSpell(SpellEntry
const *spellInfo_1
,uint32 spellId_2
) const;
724 static bool canStackSpellRanks(SpellEntry
const *spellInfo
);
725 bool IsNoStackSpellDueToSpell(uint32 spellId_1
, uint32 spellId_2
) const;
727 SpellEntry
const* SelectAuraRankForPlayerLevel(SpellEntry
const* spellInfo
, uint32 playerLevel
) const;
730 SpellLearnSkillNode
const* GetSpellLearnSkill(uint32 spell_id
) const
732 SpellLearnSkillMap::const_iterator itr
= mSpellLearnSkills
.find(spell_id
);
733 if(itr
!= mSpellLearnSkills
.end())
739 bool IsSpellLearnSpell(uint32 spell_id
) const
741 return mSpellLearnSpells
.find(spell_id
) != mSpellLearnSpells
.end();
744 SpellLearnSpellMap::const_iterator
GetBeginSpellLearnSpell(uint32 spell_id
) const
746 return mSpellLearnSpells
.lower_bound(spell_id
);
749 SpellLearnSpellMap::const_iterator
GetEndSpellLearnSpell(uint32 spell_id
) const
751 return mSpellLearnSpells
.upper_bound(spell_id
);
754 bool IsSpellLearnToSpell(uint32 spell_id1
,uint32 spell_id2
) const
756 SpellLearnSpellMap::const_iterator b
= GetBeginSpellLearnSpell(spell_id1
);
757 SpellLearnSpellMap::const_iterator e
= GetEndSpellLearnSpell(spell_id1
);
758 for(SpellLearnSpellMap::const_iterator i
= b
; i
!= e
; ++i
)
759 if(i
->second
.spell
==spell_id2
)
764 static bool IsProfessionOrRidingSpell(uint32 spellId
);
765 static bool IsProfessionSpell(uint32 spellId
);
766 static bool IsPrimaryProfessionSpell(uint32 spellId
);
767 bool IsPrimaryProfessionFirstRankSpell(uint32 spellId
) const;
769 bool IsSkillBonusSpell(uint32 spellId
) const;
772 // Spell script targets
773 SpellScriptTarget::const_iterator
GetBeginSpellScriptTarget(uint32 spell_id
) const
775 return mSpellScriptTarget
.lower_bound(spell_id
);
778 SpellScriptTarget::const_iterator
GetEndSpellScriptTarget(uint32 spell_id
) const
780 return mSpellScriptTarget
.upper_bound(spell_id
);
783 // Spell correctess for client using
784 static bool IsSpellValid(SpellEntry
const * spellInfo
, Player
* pl
= NULL
, bool msg
= true);
786 SkillLineAbilityMap::const_iterator
GetBeginSkillLineAbilityMap(uint32 spell_id
) const
788 return mSkillLineAbilityMap
.lower_bound(spell_id
);
791 SkillLineAbilityMap::const_iterator
GetEndSkillLineAbilityMap(uint32 spell_id
) const
793 return mSkillLineAbilityMap
.upper_bound(spell_id
);
796 PetAura
const* GetPetAura(uint16 spell_id
)
798 SpellPetAuraMap::const_iterator itr
= mSpellPetAuraMap
.find(spell_id
);
799 if(itr
!= mSpellPetAuraMap
.end())
805 PetLevelupSpellSet
const* GetPetLevelupSpellList(uint32 petFamily
) const
807 PetLevelupSpellMap::const_iterator itr
= mPetLevelupSpellMap
.find(petFamily
);
808 if(itr
!= mPetLevelupSpellMap
.end())
814 SpellCastResult
GetSpellAllowedInLocationError(SpellEntry
const *spellInfo
, uint32 map_id
, uint32 zone_id
, uint32 area_id
, Player
const* player
= NULL
);
816 SpellAreaMapBounds
GetSpellAreaMapBounds(uint32 spell_id
) const
818 return SpellAreaMapBounds(mSpellAreaMap
.lower_bound(spell_id
),mSpellAreaMap
.upper_bound(spell_id
));
821 SpellAreaForQuestMapBounds
GetSpellAreaForQuestMapBounds(uint32 quest_id
, bool active
) const
824 return SpellAreaForQuestMapBounds(mSpellAreaForActiveQuestMap
.lower_bound(quest_id
),mSpellAreaForActiveQuestMap
.upper_bound(quest_id
));
826 return SpellAreaForQuestMapBounds(mSpellAreaForQuestMap
.lower_bound(quest_id
),mSpellAreaForQuestMap
.upper_bound(quest_id
));
829 SpellAreaForQuestMapBounds
GetSpellAreaForQuestEndMapBounds(uint32 quest_id
) const
831 return SpellAreaForQuestMapBounds(mSpellAreaForQuestEndMap
.lower_bound(quest_id
),mSpellAreaForQuestEndMap
.upper_bound(quest_id
));
834 SpellAreaForAuraMapBounds
GetSpellAreaForAuraMapBounds(uint32 spell_id
) const
836 return SpellAreaForAuraMapBounds(mSpellAreaForAuraMap
.lower_bound(spell_id
),mSpellAreaForAuraMap
.upper_bound(spell_id
));
839 SpellAreaForAreaMapBounds
GetSpellAreaForAreaMapBounds(uint32 area_id
) const
841 return SpellAreaForAreaMapBounds(mSpellAreaForAreaMap
.lower_bound(area_id
),mSpellAreaForAreaMap
.upper_bound(area_id
));
846 static SpellMgr
& Instance();
848 // Loading data at server startup
849 void LoadSpellChains();
850 void LoadSpellLearnSkills();
851 void LoadSpellLearnSpells();
852 void LoadSpellScriptTarget();
853 void LoadSpellAffects();
854 void LoadSpellElixirs();
855 void LoadSpellProcEvents();
856 void LoadSpellBonusess();
857 void LoadSpellTargetPositions();
858 void LoadSpellThreats();
859 void LoadSkillLineAbilityMap();
860 void LoadSpellPetAuras();
861 void LoadPetLevelupSpellMap();
862 void LoadSpellAreas();
865 SpellScriptTarget mSpellScriptTarget
;
866 SpellChainMap mSpellChains
;
867 SpellChainMapNext mSpellChainsNext
;
868 SpellLearnSkillMap mSpellLearnSkills
;
869 SpellLearnSpellMap mSpellLearnSpells
;
870 SpellTargetPositionMap mSpellTargetPositions
;
871 SpellAffectMap mSpellAffectMap
;
872 SpellElixirMap mSpellElixirs
;
873 SpellProcEventMap mSpellProcEventMap
;
874 SpellBonusMap mSpellBonusMap
;
875 SkillLineAbilityMap mSkillLineAbilityMap
;
876 SpellPetAuraMap mSpellPetAuraMap
;
877 PetLevelupSpellMap mPetLevelupSpellMap
;
878 SpellAreaMap mSpellAreaMap
;
879 SpellAreaForQuestMap mSpellAreaForQuestMap
;
880 SpellAreaForQuestMap mSpellAreaForActiveQuestMap
;
881 SpellAreaForQuestMap mSpellAreaForQuestEndMap
;
882 SpellAreaForAuraMap mSpellAreaForAuraMap
;
883 SpellAreaForAreaMap mSpellAreaForAreaMap
;
886 #define spellmgr SpellMgr::Instance()