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 "SpellAuraDefines.h"
27 #include "DBCStructure.h"
28 #include "DBCStores.h"
29 #include "Database/SQLStorage.h"
31 #include "Utilities/UnorderedMap.h"
42 SPELLCATEGORY_HEALTH_MANA_POTIONS
= 4,
43 SPELLCATEGORY_DEVOUR_MAGIC
= 12
48 SPELLFAMILY_GENERIC
= 0,
49 SPELLFAMILY_UNK1
= 1, // events, holidays
52 SPELLFAMILY_WARRIOR
= 4,
53 SPELLFAMILY_WARLOCK
= 5,
54 SPELLFAMILY_PRIEST
= 6,
55 SPELLFAMILY_DRUID
= 7,
56 SPELLFAMILY_ROGUE
= 8,
57 SPELLFAMILY_HUNTER
= 9,
58 SPELLFAMILY_PALADIN
= 10,
59 SPELLFAMILY_SHAMAN
= 11,
60 SPELLFAMILY_UNK2
= 12, // 2 spells (silence resistance)
61 SPELLFAMILY_POTION
= 13,
63 SPELLFAMILY_DEATHKNIGHT
= 15,
68 //Some SpellFamilyFlags
69 #define SPELLFAMILYFLAG_ROGUE_VANISH UI64LIT(0x0000000000000800)
70 #define SPELLFAMILYFLAG_ROGUE_STEALTH UI64LIT(0x0000000000400000)
71 #define SPELLFAMILYFLAG_ROGUE_BACKSTAB UI64LIT(0x0000000000800004)
72 #define SPELLFAMILYFLAG_ROGUE_SAP UI64LIT(0x0000000000000080)
73 #define SPELLFAMILYFLAG_ROGUE_FEINT UI64LIT(0x0000000008000000)
74 #define SPELLFAMILYFLAG_ROGUE_KIDNEYSHOT UI64LIT(0x0000000000200000)
75 #define SPELLFAMILYFLAG_ROGUE__FINISHING_MOVE UI64LIT(0x00000009003E0000)
77 #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
, bool friendly
= false)
111 return (friendly
? range
->minRangeFriendly
: range
->minRange
);
113 inline float GetSpellMaxRange(SpellRangeEntry
const *range
, bool friendly
= false)
117 return (friendly
? range
->maxRangeFriendly
: range
->maxRange
);
119 inline uint32
GetSpellRecoveryTime(SpellEntry
const *spellInfo
) { return spellInfo
->RecoveryTime
> spellInfo
->CategoryRecoveryTime
? spellInfo
->RecoveryTime
: spellInfo
->CategoryRecoveryTime
; }
120 int32
GetSpellDuration(SpellEntry
const *spellInfo
);
121 int32
GetSpellMaxDuration(SpellEntry
const *spellInfo
);
123 inline bool IsSpellHaveEffect(SpellEntry
const *spellInfo
, SpellEffects effect
)
125 for(int i
= 0; i
< 3; ++i
)
126 if(SpellEffects(spellInfo
->Effect
[i
])==effect
)
131 inline bool IsSpellHaveAura(SpellEntry
const *spellInfo
, AuraType aura
)
133 for(int i
= 0; i
< 3; ++i
)
134 if(AuraType(spellInfo
->EffectApplyAuraName
[i
])==aura
)
139 inline bool IsSpellLastAuraEffect(SpellEntry
const *spellInfo
, int effecIdx
)
141 for(int i
= effecIdx
+1; i
< 3; ++i
)
142 if(spellInfo
->EffectApplyAuraName
[i
])
147 bool IsNoStackAuraDueToAura(uint32 spellId_1
, uint32 effIndex_1
, uint32 spellId_2
, uint32 effIndex_2
);
149 inline bool IsSealSpell(SpellEntry
const *spellInfo
)
151 //Collection of all the seal family flags. No other paladin spell has any of those.
152 return spellInfo
->SpellFamilyName
== SPELLFAMILY_PALADIN
&&
153 ( spellInfo
->SpellFamilyFlags
& SPELLFAMILYFLAG_PALADIN_SEALS
);
156 inline bool IsElementalShield(SpellEntry
const *spellInfo
)
158 // family flags 10 (Lightning), 42 (Earth), 37 (Water), proc shield from T2 8 pieces bonus
159 return (spellInfo
->SpellFamilyFlags
& UI64LIT(0x42000000400)) || spellInfo
->Id
== 23552;
162 inline bool IsExplicitDiscoverySpell(SpellEntry
const *spellInfo
)
164 return spellInfo
->Effect
[0] == SPELL_EFFECT_CREATE_RANDOM_ITEM
165 && spellInfo
->Effect
[1] == SPELL_EFFECT_SCRIPT_EFFECT
166 || spellInfo
->Id
== 64323; // Book of Glyph Mastery (Effect0==SPELL_EFFECT_SCRIPT_EFFECT without any other data)
169 inline bool IsLootCraftingSpell(SpellEntry
const *spellInfo
)
171 return spellInfo
->Effect
[0]==SPELL_EFFECT_CREATE_RANDOM_ITEM
||
172 // different random cards from Inscription (121==Virtuoso Inking Set category)
173 spellInfo
->Effect
[0]==SPELL_EFFECT_CREATE_ITEM_2
&& spellInfo
->TotemCategory
[0] == 121;
176 int32
CompareAuraRanks(uint32 spellId_1
, uint32 effIndex_1
, uint32 spellId_2
, uint32 effIndex_2
);
177 bool IsSingleFromSpellSpecificPerCaster(SpellSpecific spellSpec1
,SpellSpecific spellSpec2
);
178 bool IsSingleFromSpellSpecificRanksPerTarget(SpellSpecific spellId_spec
, SpellSpecific i_spellId_spec
);
179 bool IsPassiveSpell(uint32 spellId
);
181 inline bool IsPassiveSpellStackableWithRanks(SpellEntry
const* spellProto
)
183 if(!IsPassiveSpell(spellProto
->Id
))
186 return !IsSpellHaveEffect(spellProto
,SPELL_EFFECT_APPLY_AURA
);
190 inline bool IsDeathPersistentSpell(SpellEntry
const *spellInfo
)
192 return spellInfo
->AttributesEx3
& SPELL_ATTR_EX3_DEATH_PERSISTENT
;
195 inline bool IsNonCombatSpell(SpellEntry
const *spellInfo
)
197 return (spellInfo
->Attributes
& SPELL_ATTR_CANT_USED_IN_COMBAT
) != 0;
200 bool IsPositiveSpell(uint32 spellId
);
201 bool IsPositiveEffect(uint32 spellId
, uint32 effIndex
);
202 bool IsPositiveTarget(uint32 targetA
, uint32 targetB
);
204 bool IsSingleTargetSpell(SpellEntry
const *spellInfo
);
205 bool IsSingleTargetSpells(SpellEntry
const *spellInfo1
, SpellEntry
const *spellInfo2
);
207 inline bool IsCasterSourceTarget(uint32 target
)
213 case TARGET_ALL_PARTY_AROUND_CASTER
:
214 case TARGET_IN_FRONT_OF_CASTER
:
217 case TARGET_ALL_PARTY
:
218 case TARGET_ALL_PARTY_AROUND_CASTER_2
:
219 case TARGET_SELF_FISHING
:
220 case TARGET_TOTEM_EARTH
:
221 case TARGET_TOTEM_WATER
:
222 case TARGET_TOTEM_AIR
:
223 case TARGET_TOTEM_FIRE
:
225 case TARGET_AREAEFFECT_CUSTOM_2
:
226 case TARGET_ALL_RAID_AROUND_CASTER
:
228 case TARGET_DIRECTLY_FORWARD
:
229 case TARGET_NONCOMBAT_PET
:
230 case TARGET_IN_FRONT_OF_CASTER_30
:
238 inline bool IsSpellWithCasterSourceTargetsOnly(SpellEntry
const* spellInfo
)
240 for(int i
= 0; i
< 3; ++i
)
241 if(uint32 target
= spellInfo
->EffectImplicitTargetA
[i
])
242 if(!IsCasterSourceTarget(target
))
247 inline bool IsPointEffectTarget( Targets target
)
251 case TARGET_INNKEEPER_COORDINATES
:
252 case TARGET_TABLE_X_Y_Z_COORDINATES
:
253 case TARGET_CASTER_COORDINATES
:
254 case TARGET_SCRIPT_COORDINATES
:
255 case TARGET_CURRENT_ENEMY_COORDINATES
:
256 case TARGET_DUELVSPLAYER_COORDINATES
:
257 case TARGET_DYNAMIC_OBJECT_COORDINATES
:
265 inline bool IsAreaEffectTarget( Targets target
)
269 case TARGET_AREAEFFECT_INSTANT
:
270 case TARGET_AREAEFFECT_CUSTOM
:
271 case TARGET_ALL_ENEMY_IN_AREA
:
272 case TARGET_ALL_ENEMY_IN_AREA_INSTANT
:
273 case TARGET_ALL_PARTY_AROUND_CASTER
:
274 case TARGET_IN_FRONT_OF_CASTER
:
275 case TARGET_ALL_ENEMY_IN_AREA_CHANNELED
:
276 case TARGET_ALL_FRIENDLY_UNITS_AROUND_CASTER
:
277 case TARGET_ALL_FRIENDLY_UNITS_IN_AREA
:
278 case TARGET_ALL_PARTY
:
279 case TARGET_ALL_PARTY_AROUND_CASTER_2
:
280 case TARGET_AREAEFFECT_PARTY
:
281 case TARGET_AREAEFFECT_CUSTOM_2
:
282 case TARGET_ALL_RAID_AROUND_CASTER
:
283 case TARGET_AREAEFFECT_PARTY_AND_CLASS
:
284 case TARGET_IN_FRONT_OF_CASTER_30
:
292 inline bool IsAreaOfEffectSpell(SpellEntry
const *spellInfo
)
294 if(IsAreaEffectTarget(Targets(spellInfo
->EffectImplicitTargetA
[0])) || IsAreaEffectTarget(Targets(spellInfo
->EffectImplicitTargetB
[0])))
296 if(IsAreaEffectTarget(Targets(spellInfo
->EffectImplicitTargetA
[1])) || IsAreaEffectTarget(Targets(spellInfo
->EffectImplicitTargetB
[1])))
298 if(IsAreaEffectTarget(Targets(spellInfo
->EffectImplicitTargetA
[2])) || IsAreaEffectTarget(Targets(spellInfo
->EffectImplicitTargetB
[2])))
303 inline bool IsAreaAuraEffect(uint32 effect
)
305 if( effect
== SPELL_EFFECT_APPLY_AREA_AURA_PARTY
||
306 effect
== SPELL_EFFECT_APPLY_AREA_AURA_RAID
||
307 effect
== SPELL_EFFECT_APPLY_AREA_AURA_FRIEND
||
308 effect
== SPELL_EFFECT_APPLY_AREA_AURA_ENEMY
||
309 effect
== SPELL_EFFECT_APPLY_AREA_AURA_PET
||
310 effect
== SPELL_EFFECT_APPLY_AREA_AURA_OWNER
)
315 inline bool IsDispelSpell(SpellEntry
const *spellInfo
)
317 if (spellInfo
->Effect
[0] == SPELL_EFFECT_DISPEL
||
318 spellInfo
->Effect
[1] == SPELL_EFFECT_DISPEL
||
319 spellInfo
->Effect
[2] == SPELL_EFFECT_DISPEL
)
323 inline bool isSpellBreakStealth(SpellEntry
const* spellInfo
)
325 return !(spellInfo
->AttributesEx
& SPELL_ATTR_EX_NOT_BREAK_STEALTH
);
328 inline bool IsAutoRepeatRangedSpell(SpellEntry
const* spellInfo
)
330 return (spellInfo
->Attributes
& SPELL_ATTR_RANGED
) && (spellInfo
->AttributesEx2
& SPELL_ATTR_EX2_AUTOREPEAT_FLAG
);
333 SpellCastResult
GetErrorAtShapeshiftedCast (SpellEntry
const *spellInfo
, uint32 form
);
335 inline bool IsChanneledSpell(SpellEntry
const* spellInfo
)
337 return (spellInfo
->AttributesEx
& (SPELL_ATTR_EX_CHANNELED_1
| SPELL_ATTR_EX_CHANNELED_2
));
340 inline bool NeedsComboPoints(SpellEntry
const* spellInfo
)
342 return (spellInfo
->AttributesEx
& (SPELL_ATTR_EX_REQ_COMBO_POINTS1
| SPELL_ATTR_EX_REQ_COMBO_POINTS2
));
345 inline SpellSchoolMask
GetSpellSchoolMask(SpellEntry
const* spellInfo
)
347 return SpellSchoolMask(spellInfo
->SchoolMask
);
350 inline uint32
GetSpellMechanicMask(SpellEntry
const* spellInfo
, int32 effect
)
353 if (spellInfo
->Mechanic
)
354 mask
|= 1<<spellInfo
->Mechanic
;
355 if (spellInfo
->EffectMechanic
[effect
])
356 mask
|= 1<<spellInfo
->EffectMechanic
[effect
];
360 inline uint32
GetAllSpellMechanicMask(SpellEntry
const* spellInfo
)
363 if (spellInfo
->Mechanic
)
364 mask
|= 1<<spellInfo
->Mechanic
;
365 for (int i
=0; i
< 3; ++i
)
366 if (spellInfo
->EffectMechanic
[i
])
367 mask
|= 1<<spellInfo
->EffectMechanic
[i
];
371 inline Mechanics
GetEffectMechanic(SpellEntry
const* spellInfo
, int32 effect
)
373 if (spellInfo
->EffectMechanic
[effect
])
374 return Mechanics(spellInfo
->EffectMechanic
[effect
]);
375 if (spellInfo
->Mechanic
)
376 return Mechanics(spellInfo
->Mechanic
);
377 return MECHANIC_NONE
;
380 inline uint32
GetDispellMask(DispelType dispel
)
383 if (dispel
== DISPEL_ALL
)
384 return DISPEL_ALL_MASK
;
386 return (1 << dispel
);
389 // Diminishing Returns interaction with spells
390 DiminishingGroup
GetDiminishingReturnsGroupForSpell(SpellEntry
const* spellproto
, bool triggered
);
391 bool IsDiminishingReturnsGroupDurationLimited(DiminishingGroup group
);
392 DiminishingReturnsType
GetDiminishingReturnsGroupType(DiminishingGroup group
);
393 int32
GetDiminishingReturnsLimitDuration(DiminishingGroup group
, SpellEntry
const* spellproto
);
395 // Spell proc event related declarations (accessed using SpellMgr functions)
398 PROC_FLAG_NONE
= 0x00000000,
400 PROC_FLAG_KILLED
= 0x00000001, // 00 Killed by agressor
401 PROC_FLAG_KILL
= 0x00000002, // 01 Kill target (in most cases need XP/Honor reward)
403 PROC_FLAG_SUCCESSFUL_MILEE_HIT
= 0x00000004, // 02 Successful melee auto attack
404 PROC_FLAG_TAKEN_MELEE_HIT
= 0x00000008, // 03 Taken damage from melee auto attack hit
406 PROC_FLAG_SUCCESSFUL_MELEE_SPELL_HIT
= 0x00000010, // 04 Successful attack by Spell that use melee weapon
407 PROC_FLAG_TAKEN_MELEE_SPELL_HIT
= 0x00000020, // 05 Taken damage by Spell that use melee weapon
409 PROC_FLAG_SUCCESSFUL_RANGED_HIT
= 0x00000040, // 06 Successful Ranged auto attack
410 PROC_FLAG_TAKEN_RANGED_HIT
= 0x00000080, // 07 Taken damage from ranged auto attack
412 PROC_FLAG_SUCCESSFUL_RANGED_SPELL_HIT
= 0x00000100, // 08 Successful Ranged attack by Spell that use ranged weapon
413 PROC_FLAG_TAKEN_RANGED_SPELL_HIT
= 0x00000200, // 09 Taken damage by Spell that use ranged weapon
415 PROC_FLAG_SUCCESSFUL_POSITIVE_AOE_HIT
= 0x00000400, // 10 Successful AoE (not 100% shure unused)
416 PROC_FLAG_TAKEN_POSITIVE_AOE
= 0x00000800, // 11 Taken AoE (not 100% shure unused)
418 PROC_FLAG_SUCCESSFUL_AOE_SPELL_HIT
= 0x00001000, // 12 Successful AoE damage spell hit (not 100% shure unused)
419 PROC_FLAG_TAKEN_AOE_SPELL_HIT
= 0x00002000, // 13 Taken AoE damage spell hit (not 100% shure unused)
421 PROC_FLAG_SUCCESSFUL_POSITIVE_SPELL
= 0x00004000, // 14 Successful cast positive spell (by default only on healing)
422 PROC_FLAG_TAKEN_POSITIVE_SPELL
= 0x00008000, // 15 Taken positive spell hit (by default only on healing)
424 PROC_FLAG_SUCCESSFUL_NEGATIVE_SPELL_HIT
= 0x00010000, // 16 Successful negative spell cast (by default only on damage)
425 PROC_FLAG_TAKEN_NEGATIVE_SPELL_HIT
= 0x00020000, // 17 Taken negative spell (by default only on damage)
427 PROC_FLAG_ON_DO_PERIODIC
= 0x00040000, // 18 Successful do periodic (damage / healing, determined from 14-17 flags)
428 PROC_FLAG_ON_TAKE_PERIODIC
= 0x00080000, // 19 Taken spell periodic (damage / healing, determined from 14-17 flags)
430 PROC_FLAG_TAKEN_ANY_DAMAGE
= 0x00100000, // 20 Taken any damage
431 PROC_FLAG_ON_TRAP_ACTIVATION
= 0x00200000, // 21 On trap activation
433 PROC_FLAG_TAKEN_OFFHAND_HIT
= 0x00400000, // 22 Taken off-hand melee attacks(not used)
434 PROC_FLAG_SUCCESSFUL_OFFHAND_HIT
= 0x00800000 // 23 Successful off-hand melee attacks
437 #define MELEE_BASED_TRIGGER_MASK (PROC_FLAG_SUCCESSFUL_MILEE_HIT | \
438 PROC_FLAG_TAKEN_MELEE_HIT | \
439 PROC_FLAG_SUCCESSFUL_MELEE_SPELL_HIT | \
440 PROC_FLAG_TAKEN_MELEE_SPELL_HIT | \
441 PROC_FLAG_SUCCESSFUL_RANGED_HIT | \
442 PROC_FLAG_TAKEN_RANGED_HIT | \
443 PROC_FLAG_SUCCESSFUL_RANGED_SPELL_HIT | \
444 PROC_FLAG_TAKEN_RANGED_SPELL_HIT)
448 PROC_EX_NONE
= 0x0000000, // If none can tigger on Hit/Crit only (passive spells MUST defined by SpellFamily flag)
449 PROC_EX_NORMAL_HIT
= 0x0000001, // If set only from normal hit (only damage spells)
450 PROC_EX_CRITICAL_HIT
= 0x0000002,
451 PROC_EX_MISS
= 0x0000004,
452 PROC_EX_RESIST
= 0x0000008,
453 PROC_EX_DODGE
= 0x0000010,
454 PROC_EX_PARRY
= 0x0000020,
455 PROC_EX_BLOCK
= 0x0000040,
456 PROC_EX_EVADE
= 0x0000080,
457 PROC_EX_IMMUNE
= 0x0000100,
458 PROC_EX_DEFLECT
= 0x0000200,
459 PROC_EX_ABSORB
= 0x0000400,
460 PROC_EX_REFLECT
= 0x0000800,
461 PROC_EX_INTERRUPT
= 0x0001000, // Melee hit result can be Interrupt (not used)
462 PROC_EX_RESERVED1
= 0x0002000,
463 PROC_EX_RESERVED2
= 0x0004000,
464 PROC_EX_RESERVED3
= 0x0008000,
465 PROC_EX_EX_TRIGGER_ALWAYS
= 0x0010000, // If set trigger always ( no matter another flags) used for drop charges
466 PROC_EX_EX_ONE_TIME_TRIGGER
= 0x0020000 // If set trigger always but only one time (not used)
469 struct SpellProcEventEntry
471 uint32 schoolMask
; // if nonzero - bit mask for matching proc condition based on spell candidate's school: Fire=2, Mask=1<<(2-1)=2
472 uint32 spellFamilyName
; // if nonzero - for matching proc condition based on candidate spell's SpellFamilyNamer value
473 uint64 spellFamilyMask
; // if nonzero - for matching proc condition based on candidate spell's SpellFamilyFlags (like auras 107 and 108 do)
474 uint32 spellFamilyMask2
; // if nonzero - for matching proc condition based on candidate spell's SpellFamilyFlags2 (like auras 107 and 108 do)
475 uint32 procFlags
; // bitmask for matching proc event
476 uint32 procEx
; // proc Extend info (see ProcFlagsEx)
477 float ppmRate
; // for melee (ranged?) damage spells - proc rate per minute. if zero, falls back to flat chance from Spell.dbc
478 float customChance
; // Owerride chance (in most cases for debug only)
479 uint32 cooldown
; // hidden cooldown used for some spell proc events, applied to _triggered_spell_
482 struct SpellBonusEntry
489 typedef UNORDERED_MAP
<uint32
, SpellProcEventEntry
> SpellProcEventMap
;
490 typedef UNORDERED_MAP
<uint32
, SpellBonusEntry
> SpellBonusMap
;
492 #define ELIXIR_BATTLE_MASK 0x1
493 #define ELIXIR_GUARDIAN_MASK 0x2
494 #define ELIXIR_FLASK_MASK (ELIXIR_BATTLE_MASK|ELIXIR_GUARDIAN_MASK)
495 #define ELIXIR_UNSTABLE_MASK 0x4
496 #define ELIXIR_SHATTRATH_MASK 0x8
498 typedef std::map
<uint32
, uint8
> SpellElixirMap
;
499 typedef std::map
<uint32
, float> SpellProcItemEnchantMap
;
500 typedef std::map
<uint32
, uint16
> SpellThreatMap
;
502 // Spell script target related declarations (accessed using SpellMgr functions)
505 SPELL_TARGET_TYPE_GAMEOBJECT
= 0,
506 SPELL_TARGET_TYPE_CREATURE
= 1,
507 SPELL_TARGET_TYPE_DEAD
= 2
510 #define MAX_SPELL_TARGET_TYPE 3
512 struct SpellTargetEntry
514 SpellTargetEntry(SpellTargetType type_
,uint32 targetEntry_
) : type(type_
), targetEntry(targetEntry_
) {}
515 SpellTargetType type
;
519 typedef std::multimap
<uint32
,SpellTargetEntry
> SpellScriptTarget
;
521 // coordinates for spells (accessed using SpellMgr functions)
522 struct SpellTargetPosition
528 float target_Orientation
;
531 typedef UNORDERED_MAP
<uint32
, SpellTargetPosition
> SpellTargetPositionMap
;
542 PetAura(uint32 petEntry
, uint32 aura
, bool _removeOnChangePet
, int _damage
) :
543 removeOnChangePet(_removeOnChangePet
), damage(_damage
)
545 auras
[petEntry
] = aura
;
548 uint32
GetAura(uint32 petEntry
) const
550 std::map
<uint32
, uint32
>::const_iterator itr
= auras
.find(petEntry
);
551 if(itr
!= auras
.end())
555 std::map
<uint32
, uint32
>::const_iterator itr2
= auras
.find(0);
556 if(itr2
!= auras
.end())
563 void AddAura(uint32 petEntry
, uint32 aura
)
565 auras
[petEntry
] = aura
;
568 bool IsRemovedOnChangePet() const
570 return removeOnChangePet
;
573 int32
GetDamage() const
579 std::map
<uint32
, uint32
> auras
;
580 bool removeOnChangePet
;
583 typedef std::map
<uint32
, PetAura
> SpellPetAuraMap
;
588 uint32 areaId
; // zone/subzone/or 0 is not limited to zone
589 uint32 questStart
; // quest start (quest must be active or rewarded for spell apply)
590 uint32 questEnd
; // quest end (quest don't must be rewarded for spell apply)
591 int32 auraSpell
; // spell aura must be applied for spell apply )if possitive) and it don't must be applied in other case
592 uint32 raceMask
; // can be applied only to races
593 Gender gender
; // can be applied only to gender
594 bool questStartCanActive
; // if true then quest start can be active (not only rewarded)
595 bool autocast
; // if true then auto applied at area enter, in other case just allowed to cast
598 bool IsFitToRequirements(Player
const* player
, uint32 newZone
, uint32 newArea
) const;
601 typedef std::multimap
<uint32
,SpellArea
> SpellAreaMap
;
602 typedef std::multimap
<uint32
,SpellArea
const*> SpellAreaForQuestMap
;
603 typedef std::multimap
<uint32
,SpellArea
const*> SpellAreaForAuraMap
;
604 typedef std::multimap
<uint32
,SpellArea
const*> SpellAreaForAreaMap
;
605 typedef std::pair
<SpellAreaMap::const_iterator
,SpellAreaMap::const_iterator
> SpellAreaMapBounds
;
606 typedef std::pair
<SpellAreaForQuestMap::const_iterator
,SpellAreaForQuestMap::const_iterator
> SpellAreaForQuestMapBounds
;
607 typedef std::pair
<SpellAreaForAuraMap::const_iterator
, SpellAreaForAuraMap::const_iterator
> SpellAreaForAuraMapBounds
;
608 typedef std::pair
<SpellAreaForAreaMap::const_iterator
, SpellAreaForAreaMap::const_iterator
> SpellAreaForAreaMapBounds
;
611 // Spell rank chain (accessed using SpellMgr functions)
612 struct SpellChainNode
620 typedef UNORDERED_MAP
<uint32
, SpellChainNode
> SpellChainMap
;
621 typedef std::multimap
<uint32
, uint32
> SpellChainMapNext
;
623 // Spell learning properties (accessed using SpellMgr functions)
624 struct SpellLearnSkillNode
627 uint32 value
; // 0 - max skill value for player level
628 uint32 maxvalue
; // 0 - max skill value for player level
631 typedef std::map
<uint32
, SpellLearnSkillNode
> SpellLearnSkillMap
;
633 struct SpellLearnSpellNode
636 bool active
; // show in spellbook or not
640 typedef std::multimap
<uint32
, SpellLearnSpellNode
> SpellLearnSpellMap
;
642 typedef std::multimap
<uint32
, SkillLineAbilityEntry
const*> SkillLineAbilityMap
;
644 typedef std::multimap
<uint32
, uint32
> PetLevelupSpellSet
;
645 typedef std::map
<uint32
, PetLevelupSpellSet
> PetLevelupSpellMap
;
647 struct PetDefaultSpellsEntry
649 uint32 spellid
[MAX_CREATURE_SPELL_DATA_SLOT
];
652 // < 0 for petspelldata id, > 0 for creature_id
653 typedef std::map
<int32
, PetDefaultSpellsEntry
> PetDefaultSpellsMap
;
656 inline bool IsPrimaryProfessionSkill(uint32 skill
)
658 SkillLineEntry
const *pSkill
= sSkillLineStore
.LookupEntry(skill
);
662 if(pSkill
->categoryId
!= SKILL_CATEGORY_PROFESSION
)
668 inline bool IsProfessionSkill(uint32 skill
)
670 return IsPrimaryProfessionSkill(skill
) || skill
== SKILL_FISHING
|| skill
== SKILL_COOKING
|| skill
== SKILL_FIRST_AID
;
673 inline bool IsProfessionOrRidingSkill(uint32 skill
)
675 return IsProfessionSkill(skill
) || skill
== SKILL_RIDING
;
680 friend struct DoSpellBonusess
;
681 friend struct DoSpellProcEvent
;
682 friend struct DoSpellProcItemEnchant
;
689 // Accessors (const or static functions)
692 bool IsAffectedByMod(SpellEntry
const *spellInfo
, SpellModifier
*mod
) const;
694 SpellElixirMap
const& GetSpellElixirMap() const { return mSpellElixirs
; }
696 uint32
GetSpellElixirMask(uint32 spellid
) const
698 SpellElixirMap::const_iterator itr
= mSpellElixirs
.find(spellid
);
699 if(itr
==mSpellElixirs
.end())
705 SpellSpecific
GetSpellElixirSpecific(uint32 spellid
) const
707 uint32 mask
= GetSpellElixirMask(spellid
);
708 if((mask
& ELIXIR_FLASK_MASK
)==ELIXIR_FLASK_MASK
)
709 return SPELL_FLASK_ELIXIR
;
710 else if(mask
& ELIXIR_BATTLE_MASK
)
711 return SPELL_BATTLE_ELIXIR
;
712 else if(mask
& ELIXIR_GUARDIAN_MASK
)
713 return SPELL_GUARDIAN_ELIXIR
;
718 uint16
GetSpellThreat(uint32 spellid
) const
720 SpellThreatMap::const_iterator itr
= mSpellThreatMap
.find(spellid
);
721 if(itr
==mSpellThreatMap
.end())
728 SpellProcEventEntry
const* GetSpellProcEvent(uint32 spellId
) const
730 SpellProcEventMap::const_iterator itr
= mSpellProcEventMap
.find(spellId
);
731 if( itr
!= mSpellProcEventMap
.end( ) )
736 // Spell procs from item enchants
737 float GetItemEnchantProcChance(uint32 spellid
) const
739 SpellProcItemEnchantMap::const_iterator itr
= mSpellProcItemEnchantMap
.find(spellid
);
740 if(itr
==mSpellProcItemEnchantMap
.end())
746 static bool IsSpellProcEventCanTriggeredBy( SpellProcEventEntry
const * spellProcEvent
, uint32 EventProcFlag
, SpellEntry
const * procSpell
, uint32 procFlags
, uint32 procExtra
, bool active
);
749 SpellBonusEntry
const* GetSpellBonusData(uint32 spellId
) const
752 SpellBonusMap::const_iterator itr
= mSpellBonusMap
.find(spellId
);
753 if( itr
!= mSpellBonusMap
.end( ) )
759 // Spell target coordinates
760 SpellTargetPosition
const* GetSpellTargetPosition(uint32 spell_id
) const
762 SpellTargetPositionMap::const_iterator itr
= mSpellTargetPositions
.find( spell_id
);
763 if( itr
!= mSpellTargetPositions
.end( ) )
768 // Spell ranks chains
769 SpellChainNode
const* GetSpellChainNode(uint32 spell_id
) const
771 SpellChainMap::const_iterator itr
= mSpellChains
.find(spell_id
);
772 if(itr
== mSpellChains
.end())
778 uint32
GetFirstSpellInChain(uint32 spell_id
) const
780 if(SpellChainNode
const* node
= GetSpellChainNode(spell_id
))
786 uint32
GetPrevSpellInChain(uint32 spell_id
) const
788 if(SpellChainNode
const* node
= GetSpellChainNode(spell_id
))
794 SpellChainMapNext
const& GetSpellChainNext() const { return mSpellChainsNext
; }
796 template<typename Worker
>
797 void doForHighRanks(uint32 spellid
, Worker
& worker
)
799 SpellChainMapNext
const& nextMap
= GetSpellChainNext();
800 for(SpellChainMapNext::const_iterator itr
= nextMap
.lower_bound(spellid
); itr
!= nextMap
.upper_bound(spellid
); ++itr
)
803 doForHighRanks(itr
->second
,worker
);
807 // Note: not use rank for compare to spell ranks: spell chains isn't linear order
808 // Use IsHighRankOfSpell instead
809 uint8
GetSpellRank(uint32 spell_id
) const
811 if(SpellChainNode
const* node
= GetSpellChainNode(spell_id
))
817 uint8
IsHighRankOfSpell(uint32 spell1
,uint32 spell2
) const
819 SpellChainMap::const_iterator itr
= mSpellChains
.find(spell1
);
821 uint32 rank2
= GetSpellRank(spell2
);
823 // not ordered correctly by rank value
824 if(itr
== mSpellChains
.end() || !rank2
|| itr
->second
.rank
<= rank2
)
827 // check present in same rank chain
828 for(; itr
!= mSpellChains
.end(); itr
= mSpellChains
.find(itr
->second
.prev
))
829 if(itr
->second
.prev
==spell2
)
835 bool IsRankSpellDueToSpell(SpellEntry
const *spellInfo_1
,uint32 spellId_2
) const;
836 static bool canStackSpellRanks(SpellEntry
const *spellInfo
);
837 bool IsNoStackSpellDueToSpell(uint32 spellId_1
, uint32 spellId_2
) const;
839 SpellEntry
const* SelectAuraRankForPlayerLevel(SpellEntry
const* spellInfo
, uint32 playerLevel
) const;
842 SpellLearnSkillNode
const* GetSpellLearnSkill(uint32 spell_id
) const
844 SpellLearnSkillMap::const_iterator itr
= mSpellLearnSkills
.find(spell_id
);
845 if(itr
!= mSpellLearnSkills
.end())
851 bool IsSpellLearnSpell(uint32 spell_id
) const
853 return mSpellLearnSpells
.find(spell_id
) != mSpellLearnSpells
.end();
856 SpellLearnSpellMap::const_iterator
GetBeginSpellLearnSpell(uint32 spell_id
) const
858 return mSpellLearnSpells
.lower_bound(spell_id
);
861 SpellLearnSpellMap::const_iterator
GetEndSpellLearnSpell(uint32 spell_id
) const
863 return mSpellLearnSpells
.upper_bound(spell_id
);
866 bool IsSpellLearnToSpell(uint32 spell_id1
,uint32 spell_id2
) const
868 SpellLearnSpellMap::const_iterator b
= GetBeginSpellLearnSpell(spell_id1
);
869 SpellLearnSpellMap::const_iterator e
= GetEndSpellLearnSpell(spell_id1
);
870 for(SpellLearnSpellMap::const_iterator i
= b
; i
!= e
; ++i
)
871 if(i
->second
.spell
==spell_id2
)
876 static bool IsProfessionOrRidingSpell(uint32 spellId
);
877 static bool IsProfessionSpell(uint32 spellId
);
878 static bool IsPrimaryProfessionSpell(uint32 spellId
);
879 bool IsPrimaryProfessionFirstRankSpell(uint32 spellId
) const;
881 bool IsSkillBonusSpell(uint32 spellId
) const;
884 // Spell script targets
885 SpellScriptTarget::const_iterator
GetBeginSpellScriptTarget(uint32 spell_id
) const
887 return mSpellScriptTarget
.lower_bound(spell_id
);
890 SpellScriptTarget::const_iterator
GetEndSpellScriptTarget(uint32 spell_id
) const
892 return mSpellScriptTarget
.upper_bound(spell_id
);
895 // Spell correctess for client using
896 static bool IsSpellValid(SpellEntry
const * spellInfo
, Player
* pl
= NULL
, bool msg
= true);
898 SkillLineAbilityMap::const_iterator
GetBeginSkillLineAbilityMap(uint32 spell_id
) const
900 return mSkillLineAbilityMap
.lower_bound(spell_id
);
903 SkillLineAbilityMap::const_iterator
GetEndSkillLineAbilityMap(uint32 spell_id
) const
905 return mSkillLineAbilityMap
.upper_bound(spell_id
);
908 PetAura
const* GetPetAura(uint32 spell_id
, uint8 eff
)
910 SpellPetAuraMap::const_iterator itr
= mSpellPetAuraMap
.find((spell_id
<<8) + eff
);
911 if(itr
!= mSpellPetAuraMap
.end())
917 PetLevelupSpellSet
const* GetPetLevelupSpellList(uint32 petFamily
) const
919 PetLevelupSpellMap::const_iterator itr
= mPetLevelupSpellMap
.find(petFamily
);
920 if(itr
!= mPetLevelupSpellMap
.end())
926 // < 0 for petspelldata id, > 0 for creature_id
927 PetDefaultSpellsEntry
const* GetPetDefaultSpellsEntry(int32 id
) const
929 PetDefaultSpellsMap::const_iterator itr
= mPetDefaultSpellsMap
.find(id
);
930 if(itr
!= mPetDefaultSpellsMap
.end())
935 SpellCastResult
GetSpellAllowedInLocationError(SpellEntry
const *spellInfo
, uint32 map_id
, uint32 zone_id
, uint32 area_id
, Player
const* player
= NULL
);
937 SpellAreaMapBounds
GetSpellAreaMapBounds(uint32 spell_id
) const
939 return SpellAreaMapBounds(mSpellAreaMap
.lower_bound(spell_id
),mSpellAreaMap
.upper_bound(spell_id
));
942 SpellAreaForQuestMapBounds
GetSpellAreaForQuestMapBounds(uint32 quest_id
, bool active
) const
945 return SpellAreaForQuestMapBounds(mSpellAreaForActiveQuestMap
.lower_bound(quest_id
),mSpellAreaForActiveQuestMap
.upper_bound(quest_id
));
947 return SpellAreaForQuestMapBounds(mSpellAreaForQuestMap
.lower_bound(quest_id
),mSpellAreaForQuestMap
.upper_bound(quest_id
));
950 SpellAreaForQuestMapBounds
GetSpellAreaForQuestEndMapBounds(uint32 quest_id
) const
952 return SpellAreaForQuestMapBounds(mSpellAreaForQuestEndMap
.lower_bound(quest_id
),mSpellAreaForQuestEndMap
.upper_bound(quest_id
));
955 SpellAreaForAuraMapBounds
GetSpellAreaForAuraMapBounds(uint32 spell_id
) const
957 return SpellAreaForAuraMapBounds(mSpellAreaForAuraMap
.lower_bound(spell_id
),mSpellAreaForAuraMap
.upper_bound(spell_id
));
960 SpellAreaForAreaMapBounds
GetSpellAreaForAreaMapBounds(uint32 area_id
) const
962 return SpellAreaForAreaMapBounds(mSpellAreaForAreaMap
.lower_bound(area_id
),mSpellAreaForAreaMap
.upper_bound(area_id
));
967 static SpellMgr
& Instance();
969 void CheckUsedSpells(char const* table
);
971 // Loading data at server startup
972 void LoadSpellChains();
973 void LoadSpellLearnSkills();
974 void LoadSpellLearnSpells();
975 void LoadSpellScriptTarget();
976 void LoadSpellElixirs();
977 void LoadSpellProcEvents();
978 void LoadSpellProcItemEnchant();
979 void LoadSpellBonusess();
980 void LoadSpellTargetPositions();
981 void LoadSpellThreats();
982 void LoadSkillLineAbilityMap();
983 void LoadSpellPetAuras();
984 void LoadPetLevelupSpellMap();
985 void LoadPetDefaultSpells();
986 void LoadSpellAreas();
989 SpellScriptTarget mSpellScriptTarget
;
990 SpellChainMap mSpellChains
;
991 SpellChainMapNext mSpellChainsNext
;
992 SpellLearnSkillMap mSpellLearnSkills
;
993 SpellLearnSpellMap mSpellLearnSpells
;
994 SpellTargetPositionMap mSpellTargetPositions
;
995 SpellElixirMap mSpellElixirs
;
996 SpellThreatMap mSpellThreatMap
;
997 SpellProcEventMap mSpellProcEventMap
;
998 SpellProcItemEnchantMap mSpellProcItemEnchantMap
;
999 SpellBonusMap mSpellBonusMap
;
1000 SkillLineAbilityMap mSkillLineAbilityMap
;
1001 SpellPetAuraMap mSpellPetAuraMap
;
1002 PetLevelupSpellMap mPetLevelupSpellMap
;
1003 PetDefaultSpellsMap mPetDefaultSpellsMap
; // only spells not listed in related mPetLevelupSpellMap entry
1004 SpellAreaMap mSpellAreaMap
;
1005 SpellAreaForQuestMap mSpellAreaForQuestMap
;
1006 SpellAreaForQuestMap mSpellAreaForActiveQuestMap
;
1007 SpellAreaForQuestMap mSpellAreaForQuestEndMap
;
1008 SpellAreaForAuraMap mSpellAreaForAuraMap
;
1009 SpellAreaForAreaMap mSpellAreaForAreaMap
;
1012 #define spellmgr SpellMgr::Instance()