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 UI64LIT(0x000000800)
71 #define SPELLFAMILYFLAG_ROGUE_STEALTH UI64LIT(0x000400000)
72 #define SPELLFAMILYFLAG_ROGUE_BACKSTAB UI64LIT(0x000800004)
73 #define SPELLFAMILYFLAG_ROGUE_SAP UI64LIT(0x000000080)
74 #define SPELLFAMILYFLAG_ROGUE_FEINT UI64LIT(0x008000000)
75 #define SPELLFAMILYFLAG_ROGUE_KIDNEYSHOT UI64LIT(0x000200000)
76 #define SPELLFAMILYFLAG_ROGUE__FINISHING_MOVE UI64LIT(0x9003E0000)
78 #define SPELLFAMILYFLAG_PALADIN_SEALS UI64LIT(0x26000C000A000000)
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
& UI64LIT(0x42000000400)) || 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
|| // see IsExplicitDiscoverySpell
145 !spellInfo
->EffectItemType
[0] || // result item not provided
146 spellInfo
->TotemCategory
[0] == 121); // different random cards from Inscription (121==Virtuoso Inking Set category)
149 int32
CompareAuraRanks(uint32 spellId_1
, uint32 effIndex_1
, uint32 spellId_2
, uint32 effIndex_2
);
150 bool IsSingleFromSpellSpecificPerCaster(SpellSpecific spellSpec1
,SpellSpecific spellSpec2
);
151 bool IsSingleFromSpellSpecificRanksPerTarget(SpellSpecific spellId_spec
, SpellSpecific i_spellId_spec
);
152 bool IsPassiveSpell(uint32 spellId
);
154 inline bool IsPassiveSpellStackableWithRanks(SpellEntry
const* spellProto
)
156 if(!IsPassiveSpell(spellProto
->Id
))
159 return !IsSpellHaveEffect(spellProto
,SPELL_EFFECT_APPLY_AURA
);
163 inline bool IsDeathPersistentSpell(SpellEntry
const *spellInfo
)
165 return spellInfo
->AttributesEx3
& SPELL_ATTR_EX3_DEATH_PERSISTENT
;
168 inline bool IsNonCombatSpell(SpellEntry
const *spellInfo
)
170 return (spellInfo
->Attributes
& SPELL_ATTR_CANT_USED_IN_COMBAT
) != 0;
173 bool IsPositiveSpell(uint32 spellId
);
174 bool IsPositiveEffect(uint32 spellId
, uint32 effIndex
);
175 bool IsPositiveTarget(uint32 targetA
, uint32 targetB
);
177 bool IsSingleTargetSpell(SpellEntry
const *spellInfo
);
178 bool IsSingleTargetSpells(SpellEntry
const *spellInfo1
, SpellEntry
const *spellInfo2
);
180 bool IsAuraAddedBySpell(uint32 auraType
, uint32 spellId
);
182 inline bool IsAreaEffectTarget( Targets target
)
186 case TARGET_AREAEFFECT_INSTANT
:
187 case TARGET_AREAEFFECT_CUSTOM
:
188 case TARGET_ALL_ENEMY_IN_AREA
:
189 case TARGET_ALL_ENEMY_IN_AREA_INSTANT
:
190 case TARGET_ALL_PARTY_AROUND_CASTER
:
191 case TARGET_IN_FRONT_OF_CASTER
:
192 case TARGET_ALL_ENEMY_IN_AREA_CHANNELED
:
193 case TARGET_ALL_FRIENDLY_UNITS_AROUND_CASTER
:
194 case TARGET_ALL_FRIENDLY_UNITS_IN_AREA
:
195 case TARGET_ALL_PARTY
:
196 case TARGET_ALL_PARTY_AROUND_CASTER_2
:
197 case TARGET_AREAEFFECT_PARTY
:
198 case TARGET_AREAEFFECT_CUSTOM_2
:
199 case TARGET_ALL_RAID_AROUND_CASTER
:
200 case TARGET_AREAEFFECT_PARTY_AND_CLASS
:
208 inline bool IsAreaOfEffectSpell(SpellEntry
const *spellInfo
)
210 if(IsAreaEffectTarget(Targets(spellInfo
->EffectImplicitTargetA
[0])) || IsAreaEffectTarget(Targets(spellInfo
->EffectImplicitTargetB
[0])))
212 if(IsAreaEffectTarget(Targets(spellInfo
->EffectImplicitTargetA
[1])) || IsAreaEffectTarget(Targets(spellInfo
->EffectImplicitTargetB
[1])))
214 if(IsAreaEffectTarget(Targets(spellInfo
->EffectImplicitTargetA
[2])) || IsAreaEffectTarget(Targets(spellInfo
->EffectImplicitTargetB
[2])))
219 inline bool IsAreaAuraEffect(uint32 effect
)
221 if( effect
== SPELL_EFFECT_APPLY_AREA_AURA_PARTY
||
222 effect
== SPELL_EFFECT_APPLY_AREA_AURA_RAID
||
223 effect
== SPELL_EFFECT_APPLY_AREA_AURA_FRIEND
||
224 effect
== SPELL_EFFECT_APPLY_AREA_AURA_ENEMY
||
225 effect
== SPELL_EFFECT_APPLY_AREA_AURA_PET
||
226 effect
== SPELL_EFFECT_APPLY_AREA_AURA_OWNER
)
231 inline bool IsDispelSpell(SpellEntry
const *spellInfo
)
233 if (spellInfo
->Effect
[0] == SPELL_EFFECT_DISPEL
||
234 spellInfo
->Effect
[1] == SPELL_EFFECT_DISPEL
||
235 spellInfo
->Effect
[2] == SPELL_EFFECT_DISPEL
)
239 inline bool isSpellBreakStealth(SpellEntry
const* spellInfo
)
241 return !(spellInfo
->AttributesEx
& SPELL_ATTR_EX_NOT_BREAK_STEALTH
);
244 inline bool IsAutoRepeatRangedSpell(SpellEntry
const* spellInfo
)
246 return (spellInfo
->Attributes
& SPELL_ATTR_RANGED
) && (spellInfo
->AttributesEx2
& SPELL_ATTR_EX2_AUTOREPEAT_FLAG
);
249 SpellCastResult
GetErrorAtShapeshiftedCast (SpellEntry
const *spellInfo
, uint32 form
);
251 inline bool IsChanneledSpell(SpellEntry
const* spellInfo
)
253 return (spellInfo
->AttributesEx
& (SPELL_ATTR_EX_CHANNELED_1
| SPELL_ATTR_EX_CHANNELED_2
));
256 inline bool NeedsComboPoints(SpellEntry
const* spellInfo
)
258 return (spellInfo
->AttributesEx
& (SPELL_ATTR_EX_REQ_COMBO_POINTS1
| SPELL_ATTR_EX_REQ_COMBO_POINTS2
));
261 inline SpellSchoolMask
GetSpellSchoolMask(SpellEntry
const* spellInfo
)
263 return SpellSchoolMask(spellInfo
->SchoolMask
);
266 inline uint32
GetSpellMechanicMask(SpellEntry
const* spellInfo
, int32 effect
)
269 if (spellInfo
->Mechanic
)
270 mask
|= 1<<spellInfo
->Mechanic
;
271 if (spellInfo
->EffectMechanic
[effect
])
272 mask
|= 1<<spellInfo
->EffectMechanic
[effect
];
276 inline uint32
GetAllSpellMechanicMask(SpellEntry
const* spellInfo
)
279 if (spellInfo
->Mechanic
)
280 mask
|= 1<<spellInfo
->Mechanic
;
281 for (int i
=0; i
< 3; ++i
)
282 if (spellInfo
->EffectMechanic
[i
])
283 mask
|= 1<<spellInfo
->EffectMechanic
[i
];
287 inline Mechanics
GetEffectMechanic(SpellEntry
const* spellInfo
, int32 effect
)
289 if (spellInfo
->EffectMechanic
[effect
])
290 return Mechanics(spellInfo
->EffectMechanic
[effect
]);
291 if (spellInfo
->Mechanic
)
292 return Mechanics(spellInfo
->Mechanic
);
293 return MECHANIC_NONE
;
296 inline uint32
GetDispellMask(DispelType dispel
)
299 if (dispel
== DISPEL_ALL
)
300 return DISPEL_ALL_MASK
;
302 return (1 << dispel
);
305 // Diminishing Returns interaction with spells
306 DiminishingGroup
GetDiminishingReturnsGroupForSpell(SpellEntry
const* spellproto
, bool triggered
);
307 bool IsDiminishingReturnsGroupDurationLimited(DiminishingGroup group
);
308 DiminishingReturnsType
GetDiminishingReturnsGroupType(DiminishingGroup group
);
310 // Spell affects related declarations (accessed using SpellMgr functions)
311 struct SpellAffectEntry
313 uint32 SpellClassMask
[3];
315 typedef UNORDERED_MAP
<uint32
, SpellAffectEntry
> SpellAffectMap
;
317 // Spell proc event related declarations (accessed using SpellMgr functions)
320 PROC_FLAG_NONE
= 0x00000000,
322 PROC_FLAG_KILLED
= 0x00000001, // 00 Killed by agressor
323 PROC_FLAG_KILL
= 0x00000002, // 01 Kill target (in most cases need XP/Honor reward)
325 PROC_FLAG_SUCCESSFUL_MILEE_HIT
= 0x00000004, // 02 Successful melee auto attack
326 PROC_FLAG_TAKEN_MELEE_HIT
= 0x00000008, // 03 Taken damage from melee auto attack hit
328 PROC_FLAG_SUCCESSFUL_MELEE_SPELL_HIT
= 0x00000010, // 04 Successful attack by Spell that use melee weapon
329 PROC_FLAG_TAKEN_MELEE_SPELL_HIT
= 0x00000020, // 05 Taken damage by Spell that use melee weapon
331 PROC_FLAG_SUCCESSFUL_RANGED_HIT
= 0x00000040, // 06 Successful Ranged auto attack
332 PROC_FLAG_TAKEN_RANGED_HIT
= 0x00000080, // 07 Taken damage from ranged auto attack
334 PROC_FLAG_SUCCESSFUL_RANGED_SPELL_HIT
= 0x00000100, // 08 Successful Ranged attack by Spell that use ranged weapon
335 PROC_FLAG_TAKEN_RANGED_SPELL_HIT
= 0x00000200, // 09 Taken damage by Spell that use ranged weapon
337 PROC_FLAG_SUCCESSFUL_POSITIVE_AOE_HIT
= 0x00000400, // 10 Successful AoE (not 100% shure unused)
338 PROC_FLAG_TAKEN_POSITIVE_AOE
= 0x00000800, // 11 Taken AoE (not 100% shure unused)
340 PROC_FLAG_SUCCESSFUL_AOE_SPELL_HIT
= 0x00001000, // 12 Successful AoE damage spell hit (not 100% shure unused)
341 PROC_FLAG_TAKEN_AOE_SPELL_HIT
= 0x00002000, // 13 Taken AoE damage spell hit (not 100% shure unused)
343 PROC_FLAG_SUCCESSFUL_POSITIVE_SPELL
= 0x00004000, // 14 Successful cast positive spell (by default only on healing)
344 PROC_FLAG_TAKEN_POSITIVE_SPELL
= 0x00008000, // 15 Taken positive spell hit (by default only on healing)
346 PROC_FLAG_SUCCESSFUL_NEGATIVE_SPELL_HIT
= 0x00010000, // 16 Successful negative spell cast (by default only on damage)
347 PROC_FLAG_TAKEN_NEGATIVE_SPELL_HIT
= 0x00020000, // 17 Taken negative spell (by default only on damage)
349 PROC_FLAG_ON_DO_PERIODIC
= 0x00040000, // 18 Successful do periodic (damage / healing, determined from 14-17 flags)
350 PROC_FLAG_ON_TAKE_PERIODIC
= 0x00080000, // 19 Taken spell periodic (damage / healing, determined from 14-17 flags)
352 PROC_FLAG_TAKEN_ANY_DAMAGE
= 0x00100000, // 20 Taken any damage
353 PROC_FLAG_ON_TRAP_ACTIVATION
= 0x00200000, // 21 On trap activation
355 PROC_FLAG_TAKEN_OFFHAND_HIT
= 0x00400000, // 22 Taken off-hand melee attacks(not used)
356 PROC_FLAG_SUCCESSFUL_OFFHAND_HIT
= 0x00800000 // 23 Successful off-hand melee attacks
359 #define MELEE_BASED_TRIGGER_MASK (PROC_FLAG_SUCCESSFUL_MILEE_HIT | \
360 PROC_FLAG_TAKEN_MELEE_HIT | \
361 PROC_FLAG_SUCCESSFUL_MELEE_SPELL_HIT | \
362 PROC_FLAG_TAKEN_MELEE_SPELL_HIT | \
363 PROC_FLAG_SUCCESSFUL_RANGED_HIT | \
364 PROC_FLAG_TAKEN_RANGED_HIT | \
365 PROC_FLAG_SUCCESSFUL_RANGED_SPELL_HIT | \
366 PROC_FLAG_TAKEN_RANGED_SPELL_HIT)
370 PROC_EX_NONE
= 0x0000000, // If none can tigger on Hit/Crit only (passive spells MUST defined by SpellFamily flag)
371 PROC_EX_NORMAL_HIT
= 0x0000001, // If set only from normal hit (only damage spells)
372 PROC_EX_CRITICAL_HIT
= 0x0000002,
373 PROC_EX_MISS
= 0x0000004,
374 PROC_EX_RESIST
= 0x0000008,
375 PROC_EX_DODGE
= 0x0000010,
376 PROC_EX_PARRY
= 0x0000020,
377 PROC_EX_BLOCK
= 0x0000040,
378 PROC_EX_EVADE
= 0x0000080,
379 PROC_EX_IMMUNE
= 0x0000100,
380 PROC_EX_DEFLECT
= 0x0000200,
381 PROC_EX_ABSORB
= 0x0000400,
382 PROC_EX_REFLECT
= 0x0000800,
383 PROC_EX_INTERRUPT
= 0x0001000, // Melee hit result can be Interrupt (not used)
384 PROC_EX_RESERVED1
= 0x0002000,
385 PROC_EX_RESERVED2
= 0x0004000,
386 PROC_EX_RESERVED3
= 0x0008000,
387 PROC_EX_EX_TRIGGER_ALWAYS
= 0x0010000, // If set trigger always ( no matter another flags) used for drop charges
388 PROC_EX_EX_ONE_TIME_TRIGGER
= 0x0020000 // If set trigger always but only one time (not used)
391 struct SpellProcEventEntry
393 uint32 schoolMask
; // if nonzero - bit mask for matching proc condition based on spell candidate's school: Fire=2, Mask=1<<(2-1)=2
394 uint32 spellFamilyName
; // if nonzero - for matching proc condition based on candidate spell's SpellFamilyNamer value
395 uint64 spellFamilyMask
; // if nonzero - for matching proc condition based on candidate spell's SpellFamilyFlags (like auras 107 and 108 do)
396 uint32 spellFamilyMask2
; // if nonzero - for matching proc condition based on candidate spell's SpellFamilyFlags2 (like auras 107 and 108 do)
397 uint32 procFlags
; // bitmask for matching proc event
398 uint32 procEx
; // proc Extend info (see ProcFlagsEx)
399 float ppmRate
; // for melee (ranged?) damage spells - proc rate per minute. if zero, falls back to flat chance from Spell.dbc
400 float customChance
; // Owerride chance (in most cases for debug only)
401 uint32 cooldown
; // hidden cooldown used for some spell proc events, applied to _triggered_spell_
404 struct SpellBonusEntry
411 typedef UNORDERED_MAP
<uint32
, SpellProcEventEntry
> SpellProcEventMap
;
412 typedef UNORDERED_MAP
<uint32
, SpellBonusEntry
> SpellBonusMap
;
414 #define ELIXIR_BATTLE_MASK 0x1
415 #define ELIXIR_GUARDIAN_MASK 0x2
416 #define ELIXIR_FLASK_MASK (ELIXIR_BATTLE_MASK|ELIXIR_GUARDIAN_MASK)
417 #define ELIXIR_UNSTABLE_MASK 0x4
418 #define ELIXIR_SHATTRATH_MASK 0x8
420 typedef std::map
<uint32
, uint8
> SpellElixirMap
;
422 // Spell script target related declarations (accessed using SpellMgr functions)
425 SPELL_TARGET_TYPE_GAMEOBJECT
= 0,
426 SPELL_TARGET_TYPE_CREATURE
= 1,
427 SPELL_TARGET_TYPE_DEAD
= 2
430 #define MAX_SPELL_TARGET_TYPE 3
432 struct SpellTargetEntry
434 SpellTargetEntry(SpellTargetType type_
,uint32 targetEntry_
) : type(type_
), targetEntry(targetEntry_
) {}
435 SpellTargetType type
;
439 typedef std::multimap
<uint32
,SpellTargetEntry
> SpellScriptTarget
;
441 // coordinates for spells (accessed using SpellMgr functions)
442 struct SpellTargetPosition
448 float target_Orientation
;
451 typedef UNORDERED_MAP
<uint32
, SpellTargetPosition
> SpellTargetPositionMap
;
462 PetAura(uint16 petEntry
, uint16 aura
, bool _removeOnChangePet
, int _damage
) :
463 removeOnChangePet(_removeOnChangePet
), damage(_damage
)
465 auras
[petEntry
] = aura
;
468 uint16
GetAura(uint16 petEntry
) const
470 std::map
<uint16
, uint16
>::const_iterator itr
= auras
.find(petEntry
);
471 if(itr
!= auras
.end())
475 std::map
<uint16
, uint16
>::const_iterator itr2
= auras
.find(0);
476 if(itr2
!= auras
.end())
483 void AddAura(uint16 petEntry
, uint16 aura
)
485 auras
[petEntry
] = aura
;
488 bool IsRemovedOnChangePet() const
490 return removeOnChangePet
;
493 int32
GetDamage() const
499 std::map
<uint16
, uint16
> auras
;
500 bool removeOnChangePet
;
503 typedef std::map
<uint16
, PetAura
> SpellPetAuraMap
;
508 uint32 areaId
; // zone/subzone/or 0 is not limited to zone
509 uint32 questStart
; // quest start (quest must be active or rewarded for spell apply)
510 uint32 questEnd
; // quest end (quest don't must be rewarded for spell apply)
511 int32 auraSpell
; // spell aura must be applied for spell apply )if possitive) and it don't must be applied in other case
512 uint32 raceMask
; // can be applied only to races
513 Gender gender
; // can be applied only to gender
514 bool questStartCanActive
; // if true then quest start can be active (not only rewarded)
515 bool autocast
; // if true then auto applied at area enter, in other case just allowed to cast
518 bool IsFitToRequirements(Player
const* player
, uint32 newZone
, uint32 newArea
) const;
521 typedef std::multimap
<uint32
,SpellArea
> SpellAreaMap
;
522 typedef std::multimap
<uint32
,SpellArea
const*> SpellAreaForQuestMap
;
523 typedef std::multimap
<uint32
,SpellArea
const*> SpellAreaForAuraMap
;
524 typedef std::multimap
<uint32
,SpellArea
const*> SpellAreaForAreaMap
;
525 typedef std::pair
<SpellAreaMap::const_iterator
,SpellAreaMap::const_iterator
> SpellAreaMapBounds
;
526 typedef std::pair
<SpellAreaForQuestMap::const_iterator
,SpellAreaForQuestMap::const_iterator
> SpellAreaForQuestMapBounds
;
527 typedef std::pair
<SpellAreaForAuraMap::const_iterator
, SpellAreaForAuraMap::const_iterator
> SpellAreaForAuraMapBounds
;
528 typedef std::pair
<SpellAreaForAreaMap::const_iterator
, SpellAreaForAreaMap::const_iterator
> SpellAreaForAreaMapBounds
;
531 // Spell rank chain (accessed using SpellMgr functions)
532 struct SpellChainNode
540 typedef UNORDERED_MAP
<uint32
, SpellChainNode
> SpellChainMap
;
541 typedef std::multimap
<uint32
, uint32
> SpellChainMapNext
;
543 // Spell learning properties (accessed using SpellMgr functions)
544 struct SpellLearnSkillNode
547 uint32 value
; // 0 - max skill value for player level
548 uint32 maxvalue
; // 0 - max skill value for player level
551 typedef std::map
<uint32
, SpellLearnSkillNode
> SpellLearnSkillMap
;
553 struct SpellLearnSpellNode
556 bool active
; // show in spellbook or not
560 typedef std::multimap
<uint32
, SpellLearnSpellNode
> SpellLearnSpellMap
;
562 typedef std::multimap
<uint32
, SkillLineAbilityEntry
const*> SkillLineAbilityMap
;
564 typedef std::multimap
<uint32
, uint32
> PetLevelupSpellSet
;
565 typedef std::map
<uint32
, PetLevelupSpellSet
> PetLevelupSpellMap
;
567 struct PetDefaultSpellsEntry
569 uint32 spellid
[MAX_CREATURE_SPELL_DATA_SLOT
];
572 // < 0 for petspelldata id, > 0 for creature_id
573 typedef std::map
<int32
, PetDefaultSpellsEntry
> PetDefaultSpellsMap
;
576 inline bool IsPrimaryProfessionSkill(uint32 skill
)
578 SkillLineEntry
const *pSkill
= sSkillLineStore
.LookupEntry(skill
);
582 if(pSkill
->categoryId
!= SKILL_CATEGORY_PROFESSION
)
588 inline bool IsProfessionSkill(uint32 skill
)
590 return IsPrimaryProfessionSkill(skill
) || skill
== SKILL_FISHING
|| skill
== SKILL_COOKING
|| skill
== SKILL_FIRST_AID
;
593 inline bool IsProfessionOrRidingSkill(uint32 skill
)
595 return IsProfessionSkill(skill
) || skill
== SKILL_RIDING
;
605 // Accessors (const or static functions)
608 SpellAffectEntry
const*GetSpellAffect(uint16 spellId
, uint8 effectId
) const
610 SpellAffectMap::const_iterator itr
= mSpellAffectMap
.find((spellId
<<8) + effectId
);
611 if( itr
!= mSpellAffectMap
.end( ) )
616 bool IsAffectedByMod(SpellEntry
const *spellInfo
, SpellModifier
*mod
) const;
618 SpellElixirMap
const& GetSpellElixirMap() const { return mSpellElixirs
; }
620 uint32
GetSpellElixirMask(uint32 spellid
) const
622 SpellElixirMap::const_iterator itr
= mSpellElixirs
.find(spellid
);
623 if(itr
==mSpellElixirs
.end())
629 SpellSpecific
GetSpellElixirSpecific(uint32 spellid
) const
631 uint32 mask
= GetSpellElixirMask(spellid
);
632 if((mask
& ELIXIR_FLASK_MASK
)==ELIXIR_FLASK_MASK
)
633 return SPELL_FLASK_ELIXIR
;
634 else if(mask
& ELIXIR_BATTLE_MASK
)
635 return SPELL_BATTLE_ELIXIR
;
636 else if(mask
& ELIXIR_GUARDIAN_MASK
)
637 return SPELL_GUARDIAN_ELIXIR
;
643 SpellProcEventEntry
const* GetSpellProcEvent(uint32 spellId
) const
645 SpellProcEventMap::const_iterator itr
= mSpellProcEventMap
.find(spellId
);
646 if( itr
!= mSpellProcEventMap
.end( ) )
651 static bool IsSpellProcEventCanTriggeredBy( SpellProcEventEntry
const * spellProcEvent
, uint32 EventProcFlag
, SpellEntry
const * procSpell
, uint32 procFlags
, uint32 procExtra
, bool active
);
654 SpellBonusEntry
const* GetSpellBonusData(uint32 spellId
) const
657 SpellBonusMap::const_iterator itr
= mSpellBonusMap
.find(spellId
);
658 if( itr
!= mSpellBonusMap
.end( ) )
660 // Not found, try lookup for 1 spell rank if exist
661 if (uint32 rank_1
= GetFirstSpellInChain(spellId
))
663 SpellBonusMap::const_iterator itr2
= mSpellBonusMap
.find(rank_1
);
664 if( itr2
!= mSpellBonusMap
.end( ) )
665 return &itr2
->second
;
670 // Spell target coordinates
671 SpellTargetPosition
const* GetSpellTargetPosition(uint32 spell_id
) const
673 SpellTargetPositionMap::const_iterator itr
= mSpellTargetPositions
.find( spell_id
);
674 if( itr
!= mSpellTargetPositions
.end( ) )
679 // Spell ranks chains
680 SpellChainNode
const* GetSpellChainNode(uint32 spell_id
) const
682 SpellChainMap::const_iterator itr
= mSpellChains
.find(spell_id
);
683 if(itr
== mSpellChains
.end())
689 uint32
GetFirstSpellInChain(uint32 spell_id
) const
691 if(SpellChainNode
const* node
= GetSpellChainNode(spell_id
))
697 uint32
GetPrevSpellInChain(uint32 spell_id
) const
699 if(SpellChainNode
const* node
= GetSpellChainNode(spell_id
))
705 SpellChainMapNext
const& GetSpellChainNext() const { return mSpellChainsNext
; }
707 // Note: not use rank for compare to spell ranks: spell chains isn't linear order
708 // Use IsHighRankOfSpell instead
709 uint8
GetSpellRank(uint32 spell_id
) const
711 if(SpellChainNode
const* node
= GetSpellChainNode(spell_id
))
717 uint8
IsHighRankOfSpell(uint32 spell1
,uint32 spell2
) const
719 SpellChainMap::const_iterator itr
= mSpellChains
.find(spell1
);
721 uint32 rank2
= GetSpellRank(spell2
);
723 // not ordered correctly by rank value
724 if(itr
== mSpellChains
.end() || !rank2
|| itr
->second
.rank
<= rank2
)
727 // check present in same rank chain
728 for(; itr
!= mSpellChains
.end(); itr
= mSpellChains
.find(itr
->second
.prev
))
729 if(itr
->second
.prev
==spell2
)
735 bool IsRankSpellDueToSpell(SpellEntry
const *spellInfo_1
,uint32 spellId_2
) const;
736 static bool canStackSpellRanks(SpellEntry
const *spellInfo
);
737 bool IsNoStackSpellDueToSpell(uint32 spellId_1
, uint32 spellId_2
) const;
739 SpellEntry
const* SelectAuraRankForPlayerLevel(SpellEntry
const* spellInfo
, uint32 playerLevel
) const;
742 SpellLearnSkillNode
const* GetSpellLearnSkill(uint32 spell_id
) const
744 SpellLearnSkillMap::const_iterator itr
= mSpellLearnSkills
.find(spell_id
);
745 if(itr
!= mSpellLearnSkills
.end())
751 bool IsSpellLearnSpell(uint32 spell_id
) const
753 return mSpellLearnSpells
.find(spell_id
) != mSpellLearnSpells
.end();
756 SpellLearnSpellMap::const_iterator
GetBeginSpellLearnSpell(uint32 spell_id
) const
758 return mSpellLearnSpells
.lower_bound(spell_id
);
761 SpellLearnSpellMap::const_iterator
GetEndSpellLearnSpell(uint32 spell_id
) const
763 return mSpellLearnSpells
.upper_bound(spell_id
);
766 bool IsSpellLearnToSpell(uint32 spell_id1
,uint32 spell_id2
) const
768 SpellLearnSpellMap::const_iterator b
= GetBeginSpellLearnSpell(spell_id1
);
769 SpellLearnSpellMap::const_iterator e
= GetEndSpellLearnSpell(spell_id1
);
770 for(SpellLearnSpellMap::const_iterator i
= b
; i
!= e
; ++i
)
771 if(i
->second
.spell
==spell_id2
)
776 static bool IsProfessionOrRidingSpell(uint32 spellId
);
777 static bool IsProfessionSpell(uint32 spellId
);
778 static bool IsPrimaryProfessionSpell(uint32 spellId
);
779 bool IsPrimaryProfessionFirstRankSpell(uint32 spellId
) const;
781 bool IsSkillBonusSpell(uint32 spellId
) const;
784 // Spell script targets
785 SpellScriptTarget::const_iterator
GetBeginSpellScriptTarget(uint32 spell_id
) const
787 return mSpellScriptTarget
.lower_bound(spell_id
);
790 SpellScriptTarget::const_iterator
GetEndSpellScriptTarget(uint32 spell_id
) const
792 return mSpellScriptTarget
.upper_bound(spell_id
);
795 // Spell correctess for client using
796 static bool IsSpellValid(SpellEntry
const * spellInfo
, Player
* pl
= NULL
, bool msg
= true);
798 SkillLineAbilityMap::const_iterator
GetBeginSkillLineAbilityMap(uint32 spell_id
) const
800 return mSkillLineAbilityMap
.lower_bound(spell_id
);
803 SkillLineAbilityMap::const_iterator
GetEndSkillLineAbilityMap(uint32 spell_id
) const
805 return mSkillLineAbilityMap
.upper_bound(spell_id
);
808 PetAura
const* GetPetAura(uint16 spell_id
)
810 SpellPetAuraMap::const_iterator itr
= mSpellPetAuraMap
.find(spell_id
);
811 if(itr
!= mSpellPetAuraMap
.end())
817 PetLevelupSpellSet
const* GetPetLevelupSpellList(uint32 petFamily
) const
819 PetLevelupSpellMap::const_iterator itr
= mPetLevelupSpellMap
.find(petFamily
);
820 if(itr
!= mPetLevelupSpellMap
.end())
826 // < 0 for petspelldata id, > 0 for creature_id
827 PetDefaultSpellsEntry
const* GetPetDefaultSpellsEntry(int32 id
) const
829 PetDefaultSpellsMap::const_iterator itr
= mPetDefaultSpellsMap
.find(id
);
830 if(itr
!= mPetDefaultSpellsMap
.end())
835 SpellCastResult
GetSpellAllowedInLocationError(SpellEntry
const *spellInfo
, uint32 map_id
, uint32 zone_id
, uint32 area_id
, Player
const* player
= NULL
);
837 SpellAreaMapBounds
GetSpellAreaMapBounds(uint32 spell_id
) const
839 return SpellAreaMapBounds(mSpellAreaMap
.lower_bound(spell_id
),mSpellAreaMap
.upper_bound(spell_id
));
842 SpellAreaForQuestMapBounds
GetSpellAreaForQuestMapBounds(uint32 quest_id
, bool active
) const
845 return SpellAreaForQuestMapBounds(mSpellAreaForActiveQuestMap
.lower_bound(quest_id
),mSpellAreaForActiveQuestMap
.upper_bound(quest_id
));
847 return SpellAreaForQuestMapBounds(mSpellAreaForQuestMap
.lower_bound(quest_id
),mSpellAreaForQuestMap
.upper_bound(quest_id
));
850 SpellAreaForQuestMapBounds
GetSpellAreaForQuestEndMapBounds(uint32 quest_id
) const
852 return SpellAreaForQuestMapBounds(mSpellAreaForQuestEndMap
.lower_bound(quest_id
),mSpellAreaForQuestEndMap
.upper_bound(quest_id
));
855 SpellAreaForAuraMapBounds
GetSpellAreaForAuraMapBounds(uint32 spell_id
) const
857 return SpellAreaForAuraMapBounds(mSpellAreaForAuraMap
.lower_bound(spell_id
),mSpellAreaForAuraMap
.upper_bound(spell_id
));
860 SpellAreaForAreaMapBounds
GetSpellAreaForAreaMapBounds(uint32 area_id
) const
862 return SpellAreaForAreaMapBounds(mSpellAreaForAreaMap
.lower_bound(area_id
),mSpellAreaForAreaMap
.upper_bound(area_id
));
867 static SpellMgr
& Instance();
869 // Loading data at server startup
870 void LoadSpellChains();
871 void LoadSpellLearnSkills();
872 void LoadSpellLearnSpells();
873 void LoadSpellScriptTarget();
874 void LoadSpellAffects();
875 void LoadSpellElixirs();
876 void LoadSpellProcEvents();
877 void LoadSpellBonusess();
878 void LoadSpellTargetPositions();
879 void LoadSpellThreats();
880 void LoadSkillLineAbilityMap();
881 void LoadSpellPetAuras();
882 void LoadPetLevelupSpellMap();
883 void LoadPetDefaultSpells();
884 void LoadSpellAreas();
887 SpellScriptTarget mSpellScriptTarget
;
888 SpellChainMap mSpellChains
;
889 SpellChainMapNext mSpellChainsNext
;
890 SpellLearnSkillMap mSpellLearnSkills
;
891 SpellLearnSpellMap mSpellLearnSpells
;
892 SpellTargetPositionMap mSpellTargetPositions
;
893 SpellAffectMap mSpellAffectMap
;
894 SpellElixirMap mSpellElixirs
;
895 SpellProcEventMap mSpellProcEventMap
;
896 SpellBonusMap mSpellBonusMap
;
897 SkillLineAbilityMap mSkillLineAbilityMap
;
898 SpellPetAuraMap mSpellPetAuraMap
;
899 PetLevelupSpellMap mPetLevelupSpellMap
;
900 PetDefaultSpellsMap mPetDefaultSpellsMap
; // only spells not listed in related mPetLevelupSpellMap entry
901 SpellAreaMap mSpellAreaMap
;
902 SpellAreaForQuestMap mSpellAreaForQuestMap
;
903 SpellAreaForQuestMap mSpellAreaForActiveQuestMap
;
904 SpellAreaForQuestMap mSpellAreaForQuestEndMap
;
905 SpellAreaForAuraMap mSpellAreaForAuraMap
;
906 SpellAreaForAreaMap mSpellAreaForAreaMap
;
909 #define spellmgr SpellMgr::Instance()