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
20 #include "ObjectMgr.h"
21 #include "SpellAuraDefines.h"
22 #include "ProgressBar.h"
23 #include "DBCStores.h"
27 #include "BattleGroundMgr.h"
37 SpellMgr
& SpellMgr::Instance()
39 static SpellMgr spellMgr
;
43 int32
GetSpellDuration(SpellEntry
const *spellInfo
)
47 SpellDurationEntry
const *du
= sSpellDurationStore
.LookupEntry(spellInfo
->DurationIndex
);
50 return (du
->Duration
[0] == -1) ? -1 : abs(du
->Duration
[0]);
53 int32
GetSpellMaxDuration(SpellEntry
const *spellInfo
)
57 SpellDurationEntry
const *du
= sSpellDurationStore
.LookupEntry(spellInfo
->DurationIndex
);
60 return (du
->Duration
[2] == -1) ? -1 : abs(du
->Duration
[2]);
63 uint32
GetSpellCastTime(SpellEntry
const* spellInfo
, Spell
const* spell
)
65 SpellCastTimesEntry
const *spellCastTimeEntry
= sSpellCastTimesStore
.LookupEntry(spellInfo
->CastingTimeIndex
);
67 // not all spells have cast time index and this is all is pasiive abilities
68 if(!spellCastTimeEntry
)
71 int32 castTime
= spellCastTimeEntry
->CastTime
;
75 if(Player
* modOwner
= spell
->GetCaster()->GetSpellModOwner())
76 modOwner
->ApplySpellMod(spellInfo
->Id
, SPELLMOD_CASTING_TIME
, castTime
, spell
);
78 if( !(spellInfo
->Attributes
& (SPELL_ATTR_UNK4
|SPELL_ATTR_UNK5
)) )
79 castTime
= int32(castTime
* spell
->GetCaster()->GetFloatValue(UNIT_MOD_CAST_SPEED
));
82 if (spell
->IsRangedSpell() && !spell
->IsAutoRepeat())
83 castTime
= int32(castTime
* spell
->GetCaster()->m_modAttackSpeedPct
[RANGED_ATTACK
]);
87 if (spellInfo
->Attributes
& SPELL_ATTR_RANGED
&& (!spell
|| !(spell
->IsAutoRepeat())))
90 return (castTime
> 0) ? uint32(castTime
) : 0;
93 bool IsPassiveSpell(uint32 spellId
)
95 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(spellId
);
98 return (spellInfo
->Attributes
& SPELL_ATTR_PASSIVE
) != 0;
101 bool IsNoStackAuraDueToAura(uint32 spellId_1
, uint32 effIndex_1
, uint32 spellId_2
, uint32 effIndex_2
)
103 SpellEntry
const *spellInfo_1
= sSpellStore
.LookupEntry(spellId_1
);
104 SpellEntry
const *spellInfo_2
= sSpellStore
.LookupEntry(spellId_2
);
105 if(!spellInfo_1
|| !spellInfo_2
) return false;
106 if(spellInfo_1
->Id
== spellId_2
) return false;
108 if (spellInfo_1
->Effect
[effIndex_1
] != spellInfo_2
->Effect
[effIndex_2
] ||
109 spellInfo_1
->EffectItemType
[effIndex_1
] != spellInfo_2
->EffectItemType
[effIndex_2
] ||
110 spellInfo_1
->EffectMiscValue
[effIndex_1
] != spellInfo_2
->EffectMiscValue
[effIndex_2
] ||
111 spellInfo_1
->EffectApplyAuraName
[effIndex_1
] != spellInfo_2
->EffectApplyAuraName
[effIndex_2
])
117 int32
CompareAuraRanks(uint32 spellId_1
, uint32 effIndex_1
, uint32 spellId_2
, uint32 effIndex_2
)
119 SpellEntry
const*spellInfo_1
= sSpellStore
.LookupEntry(spellId_1
);
120 SpellEntry
const*spellInfo_2
= sSpellStore
.LookupEntry(spellId_2
);
121 if(!spellInfo_1
|| !spellInfo_2
) return 0;
122 if (spellId_1
== spellId_2
) return 0;
124 int32 diff
= spellInfo_1
->EffectBasePoints
[effIndex_1
] - spellInfo_2
->EffectBasePoints
[effIndex_2
];
125 if (spellInfo_1
->CalculateSimpleValue(effIndex_1
) < 0 && spellInfo_2
->CalculateSimpleValue(effIndex_2
) < 0)
130 SpellSpecific
GetSpellSpecific(uint32 spellId
)
132 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(spellId
);
136 switch(spellInfo
->SpellFamilyName
)
138 case SPELLFAMILY_MAGE
:
140 // family flags 18(Molten), 25(Frost/Ice), 28(Mage)
141 if (spellInfo
->SpellFamilyFlags
& UI64LIT(0x12040000))
142 return SPELL_MAGE_ARMOR
;
144 if ((spellInfo
->SpellFamilyFlags
& UI64LIT(0x1000000)) && spellInfo
->EffectApplyAuraName
[0]==SPELL_AURA_MOD_CONFUSE
)
145 return SPELL_MAGE_POLYMORPH
;
149 case SPELLFAMILY_WARRIOR
:
151 if (spellInfo
->SpellFamilyFlags
& UI64LIT(0x00008000010000))
152 return SPELL_POSITIVE_SHOUT
;
156 case SPELLFAMILY_WARLOCK
:
158 // only warlock curses have this
159 if (spellInfo
->Dispel
== DISPEL_CURSE
)
162 // Warlock (Demon Armor | Demon Skin | Fel Armor)
163 if (spellInfo
->SpellFamilyFlags
& UI64LIT(0x2000002000000000) || spellInfo
->SpellFamilyFlags2
& 0x00000010)
164 return SPELL_WARLOCK_ARMOR
;
168 case SPELLFAMILY_HUNTER
:
170 // only hunter stings have this
171 if (spellInfo
->Dispel
== DISPEL_POISON
)
174 // only hunter aspects have this (but not all aspects in hunter family)
175 if( spellInfo
->SpellFamilyFlags
& UI64LIT(0x0044000000380000) || spellInfo
->SpellFamilyFlags2
& 0x00003010)
178 if( spellInfo
->SpellFamilyFlags2
& 0x00000002 )
179 return SPELL_TRACKER
;
183 case SPELLFAMILY_PALADIN
:
185 if (IsSealSpell(spellInfo
))
188 if (spellInfo
->SpellFamilyFlags
& UI64LIT(0x0000000011010002))
189 return SPELL_BLESSING
;
191 if ((spellInfo
->SpellFamilyFlags
& UI64LIT(0x00000820180400)) && (spellInfo
->AttributesEx3
& 0x200))
192 return SPELL_JUDGEMENT
;
194 for (int i
= 0; i
< 3; ++i
)
196 // only paladin auras have this (for palaldin class family)
197 if (spellInfo
->Effect
[i
] == SPELL_EFFECT_APPLY_AREA_AURA_RAID
)
202 case SPELLFAMILY_SHAMAN
:
204 if (IsElementalShield(spellInfo
))
205 return SPELL_ELEMENTAL_SHIELD
;
210 case SPELLFAMILY_POTION
:
211 return spellmgr
.GetSpellElixirSpecific(spellInfo
->Id
);
213 case SPELLFAMILY_DEATHKNIGHT
:
214 if ((spellInfo
->Attributes
& 0x10) && (spellInfo
->AttributesEx2
& 0x10) && (spellInfo
->AttributesEx4
& 0x200000))
215 return SPELL_PRESENCE
;
219 // elixirs can have different families, but potion most ofc.
220 if(SpellSpecific sp
= spellmgr
.GetSpellElixirSpecific(spellInfo
->Id
))
226 bool IsSingleFromSpellSpecificPerCaster(SpellSpecific spellSpec1
,SpellSpecific spellSpec2
)
237 case SPELL_WARLOCK_ARMOR
:
238 case SPELL_MAGE_ARMOR
:
239 case SPELL_MAGE_POLYMORPH
:
240 case SPELL_POSITIVE_SHOUT
:
241 case SPELL_JUDGEMENT
:
243 return spellSpec1
==spellSpec2
;
244 case SPELL_BATTLE_ELIXIR
:
245 return spellSpec2
==SPELL_BATTLE_ELIXIR
246 || spellSpec2
==SPELL_FLASK_ELIXIR
;
247 case SPELL_GUARDIAN_ELIXIR
:
248 return spellSpec2
==SPELL_GUARDIAN_ELIXIR
249 || spellSpec2
==SPELL_FLASK_ELIXIR
;
250 case SPELL_FLASK_ELIXIR
:
251 return spellSpec2
==SPELL_BATTLE_ELIXIR
252 || spellSpec2
==SPELL_GUARDIAN_ELIXIR
253 || spellSpec2
==SPELL_FLASK_ELIXIR
;
259 bool IsSingleFromSpellSpecificRanksPerTarget(SpellSpecific spellId_spec
, SpellSpecific i_spellId_spec
)
266 return spellId_spec
==i_spellId_spec
;
272 bool IsPositiveTarget(uint32 targetA
, uint32 targetB
)
274 // non-positive targets
277 case TARGET_CHAIN_DAMAGE
:
278 case TARGET_ALL_ENEMY_IN_AREA
:
279 case TARGET_ALL_ENEMY_IN_AREA_INSTANT
:
280 case TARGET_IN_FRONT_OF_CASTER
:
281 case TARGET_ALL_ENEMY_IN_AREA_CHANNELED
:
282 case TARGET_CURRENT_ENEMY_COORDINATES
:
283 case TARGET_SINGLE_ENEMY
:
285 case TARGET_CASTER_COORDINATES
:
286 return (targetB
== TARGET_ALL_PARTY
|| targetB
== TARGET_ALL_FRIENDLY_UNITS_AROUND_CASTER
);
291 return IsPositiveTarget(targetB
, 0);
295 bool IsPositiveEffect(uint32 spellId
, uint32 effIndex
)
297 SpellEntry
const *spellproto
= sSpellStore
.LookupEntry(spellId
);
298 if (!spellproto
) return false;
302 case 28441: // not positive dummy spell
303 case 37675: // Chaos Blast
307 switch(spellproto
->Effect
[effIndex
])
309 // always positive effects (check before target checks that provided non-positive result in some case for positive effects)
310 case SPELL_EFFECT_HEAL
:
311 case SPELL_EFFECT_LEARN_SPELL
:
312 case SPELL_EFFECT_SKILL_STEP
:
313 case SPELL_EFFECT_HEAL_PCT
:
314 case SPELL_EFFECT_ENERGIZE_PCT
:
317 // non-positive aura use
318 case SPELL_EFFECT_APPLY_AURA
:
319 case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND
:
321 switch(spellproto
->EffectApplyAuraName
[effIndex
])
323 case SPELL_AURA_DUMMY
:
325 // dummy aura can be positive or negative dependent from casted spell
326 switch(spellproto
->Id
)
328 case 13139: // net-o-matic special effect
329 case 23445: // evil twin
330 case 35679: // Protectorate Demolitionist
331 case 38637: // Nether Exhaustion (red)
332 case 38638: // Nether Exhaustion (green)
333 case 38639: // Nether Exhaustion (blue)
339 case SPELL_AURA_MOD_STAT
:
340 case SPELL_AURA_MOD_DAMAGE_DONE
: // dependent from bas point sign (negative -> negative)
341 case SPELL_AURA_MOD_HEALING_DONE
:
342 if(spellproto
->CalculateSimpleValue(effIndex
) < 0)
345 case SPELL_AURA_MOD_SPELL_CRIT_CHANCE
:
346 if(spellproto
->CalculateSimpleValue(effIndex
) > 0)
347 return true; // some expected possitive spells have SPELL_ATTR_EX_NEGATIVE
349 case SPELL_AURA_ADD_TARGET_TRIGGER
:
351 case SPELL_AURA_PERIODIC_TRIGGER_SPELL
:
352 if(spellId
!= spellproto
->EffectTriggerSpell
[effIndex
])
354 uint32 spellTriggeredId
= spellproto
->EffectTriggerSpell
[effIndex
];
355 SpellEntry
const *spellTriggeredProto
= sSpellStore
.LookupEntry(spellTriggeredId
);
357 if(spellTriggeredProto
)
359 // non-positive targets of main spell return early
360 for(int i
= 0; i
< 3; ++i
)
362 // if non-positive trigger cast targeted to positive target this main cast is non-positive
363 // this will place this spell auras as debuffs
364 if(IsPositiveTarget(spellTriggeredProto
->EffectImplicitTargetA
[effIndex
],spellTriggeredProto
->EffectImplicitTargetB
[effIndex
]) && !IsPositiveEffect(spellTriggeredId
,i
))
370 case SPELL_AURA_PROC_TRIGGER_SPELL
:
371 // many positive auras have negative triggered spells at damage for example and this not make it negative (it can be canceled for example)
373 case SPELL_AURA_MOD_STUN
: //have positive and negative spells, we can't sort its correctly at this moment.
374 if(effIndex
==0 && spellproto
->Effect
[1]==0 && spellproto
->Effect
[2]==0)
375 return false; // but all single stun aura spells is negative
378 if(spellproto
->Id
== 17624)
381 case SPELL_AURA_MOD_ROOT
:
382 case SPELL_AURA_MOD_SILENCE
:
383 case SPELL_AURA_GHOST
:
384 case SPELL_AURA_PERIODIC_LEECH
:
385 case SPELL_AURA_MOD_PACIFY_SILENCE
:
386 case SPELL_AURA_MOD_STALKED
:
387 case SPELL_AURA_PERIODIC_DAMAGE_PERCENT
:
389 case SPELL_AURA_PERIODIC_DAMAGE
: // used in positive spells also.
390 // part of negative spell if casted at self (prevent cancel)
391 if(spellproto
->EffectImplicitTargetA
[effIndex
] == TARGET_SELF
)
394 case SPELL_AURA_MOD_DECREASE_SPEED
: // used in positive spells also
395 // part of positive spell if casted at self
396 if(spellproto
->EffectImplicitTargetA
[effIndex
] != TARGET_SELF
)
398 // but not this if this first effect (don't found batter check)
399 if(spellproto
->Attributes
& 0x4000000 && effIndex
==0)
402 case SPELL_AURA_TRANSFORM
:
403 // some spells negative
404 switch(spellproto
->Id
)
406 case 36897: // Transporter Malfunction (race mutation to horde)
407 case 36899: // Transporter Malfunction (race mutation to alliance)
411 case SPELL_AURA_MOD_SCALE
:
412 // some spells negative
413 switch(spellproto
->Id
)
415 case 36900: // Soul Split: Evil!
416 case 36901: // Soul Split: Good
417 case 36893: // Transporter Malfunction (decrease size case)
418 case 36895: // Transporter Malfunction (increase size case)
422 case SPELL_AURA_MECHANIC_IMMUNITY
:
424 // non-positive immunities
425 switch(spellproto
->EffectMiscValue
[effIndex
])
427 case MECHANIC_BANDAGE
:
428 case MECHANIC_SHIELD
:
430 case MECHANIC_INVULNERABILITY
:
436 case SPELL_AURA_ADD_FLAT_MODIFIER
: // mods
437 case SPELL_AURA_ADD_PCT_MODIFIER
:
440 switch(spellproto
->EffectMiscValue
[effIndex
])
442 case SPELLMOD_COST
: // dependent from bas point sign (negative -> positive)
443 if(spellproto
->CalculateSimpleValue(effIndex
) > 0)
450 case SPELL_AURA_MOD_HEALING_PCT
:
451 if(spellproto
->CalculateSimpleValue(effIndex
) < 0)
454 case SPELL_AURA_MOD_SKILL
:
455 if(spellproto
->CalculateSimpleValue(effIndex
) < 0)
458 case SPELL_AURA_FORCE_REACTION
:
459 if(spellproto
->Id
==42792) // Recently Dropped Flag (prevent cancel)
471 // non-positive targets
472 if(!IsPositiveTarget(spellproto
->EffectImplicitTargetA
[effIndex
],spellproto
->EffectImplicitTargetB
[effIndex
]))
475 // AttributesEx check
476 if(spellproto
->AttributesEx
& SPELL_ATTR_EX_NEGATIVE
)
483 bool IsPositiveSpell(uint32 spellId
)
485 SpellEntry
const *spellproto
= sSpellStore
.LookupEntry(spellId
);
486 if (!spellproto
) return false;
488 // spells with atleast one negative effect are considered negative
489 // some self-applied spells have negative effects but in self casting case negative check ignored.
490 for (int i
= 0; i
< 3; ++i
)
491 if (!IsPositiveEffect(spellId
, i
))
496 bool IsSingleTargetSpell(SpellEntry
const *spellInfo
)
498 // all other single target spells have if it has AttributesEx5
499 if ( spellInfo
->AttributesEx5
& SPELL_ATTR_EX5_SINGLE_TARGET_SPELL
)
502 // TODO - need found Judgements rule
503 switch(GetSpellSpecific(spellInfo
->Id
))
505 case SPELL_JUDGEMENT
:
511 // single target triggered spell.
512 // Not real client side single target spell, but it' not triggered until prev. aura expired.
513 // This is allow store it in single target spells list for caster for spell proc checking
514 if(spellInfo
->Id
==38324) // Regeneration (triggered by 38299 (HoTs on Heals))
520 bool IsSingleTargetSpells(SpellEntry
const *spellInfo1
, SpellEntry
const *spellInfo2
)
522 // TODO - need better check
523 // Equal icon and spellfamily
524 if( spellInfo1
->SpellFamilyName
== spellInfo2
->SpellFamilyName
&&
525 spellInfo1
->SpellIconID
== spellInfo2
->SpellIconID
)
528 // TODO - need found Judgements rule
529 SpellSpecific spec1
= GetSpellSpecific(spellInfo1
->Id
);
530 // spell with single target specific types
533 case SPELL_JUDGEMENT
:
534 case SPELL_MAGE_POLYMORPH
:
535 if(GetSpellSpecific(spellInfo2
->Id
) == spec1
)
545 bool IsAuraAddedBySpell(uint32 auraType
, uint32 spellId
)
547 SpellEntry
const *spellproto
= sSpellStore
.LookupEntry(spellId
);
548 if (!spellproto
) return false;
550 for (int i
= 0; i
< 3; ++i
)
551 if (spellproto
->EffectApplyAuraName
[i
] == auraType
)
556 SpellCastResult
GetErrorAtShapeshiftedCast (SpellEntry
const *spellInfo
, uint32 form
)
558 // talents that learn spells can have stance requirements that need ignore
559 // (this requirement only for client-side stance show in talent description)
560 if( GetTalentSpellCost(spellInfo
->Id
) > 0 &&
561 (spellInfo
->Effect
[0]==SPELL_EFFECT_LEARN_SPELL
|| spellInfo
->Effect
[1]==SPELL_EFFECT_LEARN_SPELL
|| spellInfo
->Effect
[2]==SPELL_EFFECT_LEARN_SPELL
) )
562 return SPELL_CAST_OK
;
564 uint32 stanceMask
= (form
? 1 << (form
- 1) : 0);
566 if (stanceMask
& spellInfo
->StancesNot
) // can explicitly not be casted in this stance
567 return SPELL_FAILED_NOT_SHAPESHIFT
;
569 if (stanceMask
& spellInfo
->Stances
) // can explicitly be casted in this stance
570 return SPELL_CAST_OK
;
572 bool actAsShifted
= false;
575 SpellShapeshiftEntry
const *shapeInfo
= sSpellShapeshiftStore
.LookupEntry(form
);
578 sLog
.outError("GetErrorAtShapeshiftedCast: unknown shapeshift %u", form
);
579 return SPELL_CAST_OK
;
581 actAsShifted
= !(shapeInfo
->flags1
& 1); // shapeshift acts as normal form for spells
586 if (spellInfo
->Attributes
& SPELL_ATTR_NOT_SHAPESHIFT
) // not while shapeshifted
587 return SPELL_FAILED_NOT_SHAPESHIFT
;
588 else if (spellInfo
->Stances
!= 0) // needs other shapeshift
589 return SPELL_FAILED_ONLY_SHAPESHIFT
;
594 if(!(spellInfo
->AttributesEx2
& SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT
) && spellInfo
->Stances
!= 0)
595 return SPELL_FAILED_ONLY_SHAPESHIFT
;
598 return SPELL_CAST_OK
;
601 void SpellMgr::LoadSpellTargetPositions()
603 mSpellTargetPositions
.clear(); // need for reload case
608 QueryResult
*result
= WorldDatabase
.Query("SELECT id, target_map, target_position_x, target_position_y, target_position_z, target_orientation FROM spell_target_position");
617 sLog
.outString( ">> Loaded %u spell target coordinates", count
);
621 barGoLink
bar( result
->GetRowCount() );
625 Field
*fields
= result
->Fetch();
631 uint32 Spell_ID
= fields
[0].GetUInt32();
633 SpellTargetPosition st
;
635 st
.target_mapId
= fields
[1].GetUInt32();
636 st
.target_X
= fields
[2].GetFloat();
637 st
.target_Y
= fields
[3].GetFloat();
638 st
.target_Z
= fields
[4].GetFloat();
639 st
.target_Orientation
= fields
[5].GetFloat();
641 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(Spell_ID
);
644 sLog
.outErrorDb("Spell (ID:%u) listed in `spell_target_position` does not exist.",Spell_ID
);
649 for(int i
= 0; i
< 3; ++i
)
651 if( spellInfo
->EffectImplicitTargetA
[i
]==TARGET_TABLE_X_Y_Z_COORDINATES
|| spellInfo
->EffectImplicitTargetB
[i
]==TARGET_TABLE_X_Y_Z_COORDINATES
)
659 sLog
.outErrorDb("Spell (Id: %u) listed in `spell_target_position` does not have target TARGET_TABLE_X_Y_Z_COORDINATES (17).",Spell_ID
);
663 MapEntry
const* mapEntry
= sMapStore
.LookupEntry(st
.target_mapId
);
666 sLog
.outErrorDb("Spell (ID:%u) target map (ID: %u) does not exist in `Map.dbc`.",Spell_ID
,st
.target_mapId
);
670 if(st
.target_X
==0 && st
.target_Y
==0 && st
.target_Z
==0)
672 sLog
.outErrorDb("Spell (ID:%u) target coordinates not provided.",Spell_ID
);
676 mSpellTargetPositions
[Spell_ID
] = st
;
678 } while( result
->NextRow() );
683 sLog
.outString( ">> Loaded %u spell teleport coordinates", count
);
686 void SpellMgr::LoadSpellAffects()
688 mSpellAffectMap
.clear(); // need for reload case
693 QueryResult
*result
= WorldDatabase
.Query("SELECT entry, effectId, SpellClassMask0, SpellClassMask1, SpellClassMask2 FROM spell_affect");
702 sLog
.outString( ">> Loaded %u spell affect definitions", count
);
706 barGoLink
bar( result
->GetRowCount() );
710 Field
*fields
= result
->Fetch();
714 uint16 entry
= fields
[0].GetUInt16();
715 uint8 effectId
= fields
[1].GetUInt8();
717 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(entry
);
721 sLog
.outErrorDb("Spell %u listed in `spell_affect` does not exist", entry
);
727 sLog
.outErrorDb("Spell %u listed in `spell_affect` have invalid effect index (%u)", entry
,effectId
);
731 if( spellInfo
->Effect
[effectId
] != SPELL_EFFECT_APPLY_AURA
||
732 spellInfo
->EffectApplyAuraName
[effectId
] != SPELL_AURA_ADD_FLAT_MODIFIER
&&
733 spellInfo
->EffectApplyAuraName
[effectId
] != SPELL_AURA_ADD_PCT_MODIFIER
&&
734 spellInfo
->EffectApplyAuraName
[effectId
] != SPELL_AURA_ADD_TARGET_TRIGGER
)
736 sLog
.outErrorDb("Spell %u listed in `spell_affect` have not SPELL_AURA_ADD_FLAT_MODIFIER (%u) or SPELL_AURA_ADD_PCT_MODIFIER (%u) or SPELL_AURA_ADD_TARGET_TRIGGER (%u) for effect index (%u)", entry
,SPELL_AURA_ADD_FLAT_MODIFIER
,SPELL_AURA_ADD_PCT_MODIFIER
,SPELL_AURA_ADD_TARGET_TRIGGER
,effectId
);
740 SpellAffectEntry affect
;
741 affect
.SpellClassMask
[0] = fields
[2].GetUInt32();
742 affect
.SpellClassMask
[1] = fields
[3].GetUInt32();
743 affect
.SpellClassMask
[2] = fields
[4].GetUInt32();
745 // Spell.dbc have own data
746 uint32
const *ptr
= 0;
749 case 0: ptr
= &spellInfo
->EffectSpellClassMaskA
[0]; break;
750 case 1: ptr
= &spellInfo
->EffectSpellClassMaskB
[0]; break;
751 case 2: ptr
= &spellInfo
->EffectSpellClassMaskC
[0]; break;
755 if(ptr
[0] == affect
.SpellClassMask
[0] || ptr
[1] == affect
.SpellClassMask
[1] || ptr
[2] == affect
.SpellClassMask
[2])
758 sLog
.outErrorDb("Spell %u listed in `spell_affect` have redundant (same with EffectSpellClassMask%c) data for effect index (%u) and not needed, skipped.", entry
, text
[effectId
], effectId
);
762 mSpellAffectMap
[(entry
<<8) + effectId
] = affect
;
765 } while( result
->NextRow() );
770 sLog
.outString( ">> Loaded %u custom spell affect definitions", count
);
772 for (uint32 id
= 0; id
< sSpellStore
.GetNumRows(); ++id
)
774 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(id
);
778 for (int effectId
= 0; effectId
< 3; ++effectId
)
780 if( spellInfo
->Effect
[effectId
] != SPELL_EFFECT_APPLY_AURA
||
781 (spellInfo
->EffectApplyAuraName
[effectId
] != SPELL_AURA_ADD_FLAT_MODIFIER
&&
782 spellInfo
->EffectApplyAuraName
[effectId
] != SPELL_AURA_ADD_PCT_MODIFIER
&&
783 spellInfo
->EffectApplyAuraName
[effectId
] != SPELL_AURA_ADD_TARGET_TRIGGER
) )
786 uint32
const *ptr
= 0;
789 case 0: ptr
= &spellInfo
->EffectSpellClassMaskA
[0]; break;
790 case 1: ptr
= &spellInfo
->EffectSpellClassMaskB
[0]; break;
791 case 2: ptr
= &spellInfo
->EffectSpellClassMaskC
[0]; break;
795 if(ptr
[0] || ptr
[1] || ptr
[2])
798 if(mSpellAffectMap
.find((id
<<8) + effectId
) != mSpellAffectMap
.end())
801 sLog
.outErrorDb("Spell %u (%s) misses spell_affect for effect %u",id
,spellInfo
->SpellName
[sWorld
.GetDefaultDbcLocale()], effectId
);
806 bool SpellMgr::IsAffectedByMod(SpellEntry
const *spellInfo
, SpellModifier
*mod
) const
808 // false for spellInfo == NULL
809 if (!spellInfo
|| !mod
)
812 SpellEntry
const *affect_spell
= sSpellStore
.LookupEntry(mod
->spellId
);
813 // False if affect_spell == NULL or spellFamily not equal
814 if (!affect_spell
|| affect_spell
->SpellFamilyName
!= spellInfo
->SpellFamilyName
)
818 if (mod
->mask
& spellInfo
->SpellFamilyFlags
||
819 mod
->mask2
& spellInfo
->SpellFamilyFlags2
)
825 void SpellMgr::LoadSpellProcEvents()
827 mSpellProcEventMap
.clear(); // need for reload case
831 // 0 1 2 3 4 5 6 7 8 9 10
832 QueryResult
*result
= WorldDatabase
.Query("SELECT entry, SchoolMask, SpellFamilyName, SpellFamilyMask0, SpellFamilyMask1, SpellFamilyMask2, procFlags, procEx, ppmRate, CustomChance, Cooldown FROM spell_proc_event");
838 sLog
.outString( ">> Loaded %u spell proc event conditions", count
);
842 barGoLink
bar( result
->GetRowCount() );
843 uint32 customProc
= 0;
846 Field
*fields
= result
->Fetch();
850 uint32 entry
= fields
[0].GetUInt32();
852 const SpellEntry
*spell
= sSpellStore
.LookupEntry(entry
);
855 sLog
.outErrorDb("Spell %u listed in `spell_proc_event` does not exist", entry
);
859 SpellProcEventEntry spe
;
861 spe
.schoolMask
= fields
[1].GetUInt32();
862 spe
.spellFamilyName
= fields
[2].GetUInt32();
863 spe
.spellFamilyMask
= (uint64
)fields
[3].GetUInt32()|((uint64
)fields
[4].GetUInt32()<<32);
864 spe
.spellFamilyMask2
= fields
[5].GetUInt32();
865 spe
.procFlags
= fields
[6].GetUInt32();
866 spe
.procEx
= fields
[7].GetUInt32();
867 spe
.ppmRate
= fields
[8].GetFloat();
868 spe
.customChance
= fields
[9].GetFloat();
869 spe
.cooldown
= fields
[10].GetUInt32();
871 mSpellProcEventMap
[entry
] = spe
;
873 if (spell
->procFlags
==0)
875 if (spe
.procFlags
== 0)
877 sLog
.outErrorDb("Spell %u listed in `spell_proc_event` probally not triggered spell", entry
);
883 } while( result
->NextRow() );
889 sLog
.outString( ">> Loaded %u extra spell proc event conditions +%u custom", count
, customProc
);
891 sLog
.outString( ">> Loaded %u extra spell proc event conditions", count
);
894 void SpellMgr::LoadSpellBonusess()
896 mSpellBonusMap
.clear(); // need for reload case
899 QueryResult
*result
= WorldDatabase
.Query("SELECT entry, direct_bonus, dot_bonus, ap_bonus FROM spell_bonus_data");
905 sLog
.outString( ">> Loaded %u spell bonus data", count
);
909 barGoLink
bar( result
->GetRowCount() );
912 Field
*fields
= result
->Fetch();
914 uint32 entry
= fields
[0].GetUInt32();
916 const SpellEntry
*spell
= sSpellStore
.LookupEntry(entry
);
919 sLog
.outErrorDb("Spell %u listed in `spell_bonus_data` does not exist", entry
);
925 sbe
.direct_damage
= fields
[1].GetFloat();
926 sbe
.dot_damage
= fields
[2].GetFloat();
927 sbe
.ap_bonus
= fields
[3].GetFloat();
929 mSpellBonusMap
[entry
] = sbe
;
930 } while( result
->NextRow() );
935 sLog
.outString( ">> Loaded %u extra spell bonus data", count
);
938 bool SpellMgr::IsSpellProcEventCanTriggeredBy(SpellProcEventEntry
const * spellProcEvent
, uint32 EventProcFlag
, SpellEntry
const * procSpell
, uint32 procFlags
, uint32 procExtra
, bool active
)
941 uint32 procEvent_procEx
= PROC_EX_NONE
;
943 // check prockFlags for condition
944 if((procFlags
& EventProcFlag
) == 0)
947 // Always trigger for this
948 if (EventProcFlag
& (PROC_FLAG_KILLED
| PROC_FLAG_KILL
| PROC_FLAG_ON_TRAP_ACTIVATION
))
951 if (spellProcEvent
) // Exist event data
954 procEvent_procEx
= spellProcEvent
->procEx
;
956 // For melee triggers
957 if (procSpell
== NULL
)
959 // Check (if set) for school (melee attack have Normal school)
960 if(spellProcEvent
->schoolMask
&& (spellProcEvent
->schoolMask
& SPELL_SCHOOL_MASK_NORMAL
) == 0)
963 else // For spells need check school/spell family/family mask
965 // Check (if set) for school
966 if(spellProcEvent
->schoolMask
&& (spellProcEvent
->schoolMask
& procSpell
->SchoolMask
) == 0)
969 // Check (if set) for spellFamilyName
970 if(spellProcEvent
->spellFamilyName
&& (spellProcEvent
->spellFamilyName
!= procSpell
->SpellFamilyName
))
973 // spellFamilyName is Ok need check for spellFamilyMask if present
974 if(spellProcEvent
->spellFamilyMask
|| spellProcEvent
->spellFamilyMask2
)
976 if ((spellProcEvent
->spellFamilyMask
& procSpell
->SpellFamilyFlags
) == 0 &&
977 (spellProcEvent
->spellFamilyMask2
& procSpell
->SpellFamilyFlags2
) == 0)
979 active
= true; // Spell added manualy -> so its active spell
983 // Check for extra req (if none) and hit/crit
984 if (procEvent_procEx
== PROC_EX_NONE
)
986 // No extra req, so can trigger only for active (damage/healing present) and hit/crit
987 if((procExtra
& (PROC_EX_NORMAL_HIT
|PROC_EX_CRITICAL_HIT
)) && active
)
990 else // Passive spells hits here only if resist/reflect/immune/evade
992 // Exist req for PROC_EX_EX_TRIGGER_ALWAYS
993 if (procEvent_procEx
& PROC_EX_EX_TRIGGER_ALWAYS
)
995 // Passive spells can`t trigger if need hit
996 if ((procEvent_procEx
& PROC_EX_NORMAL_HIT
) && !active
)
998 // Check Extra Requirement like (hit/crit/miss/resist/parry/dodge/block/immune/reflect/absorb and other)
999 if (procEvent_procEx
& procExtra
)
1005 void SpellMgr::LoadSpellElixirs()
1007 mSpellElixirs
.clear(); // need for reload case
1012 QueryResult
*result
= WorldDatabase
.Query("SELECT entry, mask FROM spell_elixir");
1021 sLog
.outString( ">> Loaded %u spell elixir definitions", count
);
1025 barGoLink
bar( result
->GetRowCount() );
1029 Field
*fields
= result
->Fetch();
1033 uint16 entry
= fields
[0].GetUInt16();
1034 uint8 mask
= fields
[1].GetUInt8();
1036 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(entry
);
1040 sLog
.outErrorDb("Spell %u listed in `spell_elixir` does not exist", entry
);
1044 mSpellElixirs
[entry
] = mask
;
1047 } while( result
->NextRow() );
1052 sLog
.outString( ">> Loaded %u spell elixir definitions", count
);
1055 void SpellMgr::LoadSpellThreats()
1057 sSpellThreatStore
.Free(); // for reload
1059 sSpellThreatStore
.Load();
1061 sLog
.outString( ">> Loaded %u aggro generating spells", sSpellThreatStore
.RecordCount
);
1065 bool SpellMgr::IsRankSpellDueToSpell(SpellEntry
const *spellInfo_1
,uint32 spellId_2
) const
1067 SpellEntry
const *spellInfo_2
= sSpellStore
.LookupEntry(spellId_2
);
1068 if(!spellInfo_1
|| !spellInfo_2
) return false;
1069 if(spellInfo_1
->Id
== spellId_2
) return false;
1071 return GetFirstSpellInChain(spellInfo_1
->Id
)==GetFirstSpellInChain(spellId_2
);
1074 bool SpellMgr::canStackSpellRanks(SpellEntry
const *spellInfo
)
1076 if(IsPassiveSpell(spellInfo
->Id
)) // ranked passive spell
1078 if(spellInfo
->powerType
!= POWER_MANA
&& spellInfo
->powerType
!= POWER_HEALTH
)
1080 if(IsProfessionOrRidingSpell(spellInfo
->Id
))
1083 if(spellmgr
.IsSkillBonusSpell(spellInfo
->Id
))
1086 // All stance spells. if any better way, change it.
1087 for (int i
= 0; i
< 3; ++i
)
1089 switch(spellInfo
->SpellFamilyName
)
1091 case SPELLFAMILY_PALADIN
:
1092 // Paladin aura Spell
1093 if (spellInfo
->Effect
[i
]==SPELL_EFFECT_APPLY_AREA_AURA_RAID
)
1096 case SPELLFAMILY_DRUID
:
1098 if (spellInfo
->Effect
[i
]==SPELL_EFFECT_APPLY_AURA
&&
1099 spellInfo
->EffectApplyAuraName
[i
] == SPELL_AURA_MOD_SHAPESHIFT
)
1102 case SPELLFAMILY_ROGUE
:
1104 if (spellInfo
->Effect
[i
]==SPELL_EFFECT_APPLY_AURA
&&
1105 spellInfo
->EffectApplyAuraName
[i
] == SPELL_AURA_MOD_SHAPESHIFT
)
1112 bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1
, uint32 spellId_2
) const
1114 SpellEntry
const *spellInfo_1
= sSpellStore
.LookupEntry(spellId_1
);
1115 SpellEntry
const *spellInfo_2
= sSpellStore
.LookupEntry(spellId_2
);
1117 if(!spellInfo_1
|| !spellInfo_2
)
1120 if(spellInfo_1
->Id
== spellId_2
)
1123 //I think we don't check this correctly because i need a exception for spell:
1124 //72,11327,18461...(called from 1856,1857...) Call Aura 16,31, after trigger another spell who call aura 77 and 77 remove 16 and 31, this should not happen.
1125 if(spellInfo_2
->SpellFamilyFlags
== 2048)
1128 // Resurrection sickness
1129 if((spellInfo_1
->Id
== SPELL_ID_PASSIVE_RESURRECTION_SICKNESS
) != (spellInfo_2
->Id
==SPELL_ID_PASSIVE_RESURRECTION_SICKNESS
))
1132 // Allow stack passive and not passive spells
1133 if ((spellInfo_1
->Attributes
& SPELL_ATTR_PASSIVE
)!=(spellInfo_2
->Attributes
& SPELL_ATTR_PASSIVE
))
1136 // Specific spell family spells
1137 switch(spellInfo_1
->SpellFamilyName
)
1139 case SPELLFAMILY_GENERIC
:
1140 switch(spellInfo_2
->SpellFamilyName
)
1142 case SPELLFAMILY_GENERIC
: // same family case
1145 if ((spellInfo_1
->Id
== 21992 && spellInfo_2
->Id
== 27648) ||
1146 (spellInfo_2
->Id
== 21992 && spellInfo_1
->Id
== 27648))
1149 // Lightning Speed (Mongoose) and Fury of the Crashing Waves (Tsunami Talisman)
1150 if ((spellInfo_1
->Id
== 28093 && spellInfo_2
->Id
== 42084) ||
1151 (spellInfo_2
->Id
== 28093 && spellInfo_1
->Id
== 42084))
1154 // Soulstone Resurrection and Twisting Nether (resurrector)
1155 if( spellInfo_1
->SpellIconID
== 92 && spellInfo_2
->SpellIconID
== 92 && (
1156 spellInfo_1
->SpellVisual
[0] == 99 && spellInfo_2
->SpellVisual
[0] == 0 ||
1157 spellInfo_2
->SpellVisual
[0] == 99 && spellInfo_1
->SpellVisual
[0] == 0 ) )
1160 // Heart of the Wild and (Primal Instinct (Idol of Terror) triggering spell or Agility)
1161 if( spellInfo_1
->SpellIconID
== 240 && spellInfo_2
->SpellIconID
== 240 && (
1162 spellInfo_1
->SpellVisual
[0] == 0 && spellInfo_2
->SpellVisual
[0] == 78 ||
1163 spellInfo_2
->SpellVisual
[0] == 0 && spellInfo_1
->SpellVisual
[0] == 78 ) )
1166 // Personalized Weather (thunder effect should overwrite rainy aura)
1167 if(spellInfo_1
->SpellIconID
== 2606 && spellInfo_2
->SpellIconID
== 2606)
1170 // Brood Affliction: Bronze
1171 if( (spellInfo_1
->Id
== 23170 && spellInfo_2
->Id
== 23171) ||
1172 (spellInfo_2
->Id
== 23170 && spellInfo_1
->Id
== 23171) )
1175 // See Chapel Invisibility and See Noth Invisibility
1176 if( (spellInfo_1
->Id
== 52950 && spellInfo_2
->Id
== 52707) ||
1177 (spellInfo_2
->Id
== 52950 && spellInfo_1
->Id
== 52707) )
1180 // Regular and Night Elf Ghost
1181 if( (spellInfo_1
->Id
== 8326 && spellInfo_2
->Id
== 20584) ||
1182 (spellInfo_2
->Id
== 8326 && spellInfo_1
->Id
== 20584) )
1187 case SPELLFAMILY_WARRIOR
:
1189 // Scroll of Protection and Defensive Stance (multi-family check)
1190 if( spellInfo_1
->SpellIconID
== 276 && spellInfo_1
->SpellVisual
[0] == 196 && spellInfo_2
->Id
== 71)
1193 // Improved Hamstring -> Hamstring (multi-family check)
1194 if( (spellInfo_2
->SpellFamilyFlags
& UI64LIT(0x2)) && spellInfo_1
->Id
== 23694 )
1199 case SPELLFAMILY_DRUID
:
1201 // Scroll of Stamina and Leader of the Pack (multi-family check)
1202 if( spellInfo_1
->SpellIconID
== 312 && spellInfo_1
->SpellVisual
[0] == 216 && spellInfo_2
->Id
== 24932 )
1205 // Dragonmaw Illusion (multi-family check)
1206 if (spellId_1
== 40216 && spellId_2
== 42016 )
1211 case SPELLFAMILY_ROGUE
:
1213 // Garrote-Silence -> Garrote (multi-family check)
1214 if( spellInfo_1
->SpellIconID
== 498 && spellInfo_1
->SpellVisual
[0] == 0 && spellInfo_2
->SpellIconID
== 498 )
1219 case SPELLFAMILY_HUNTER
:
1221 // Concussive Shot and Imp. Concussive Shot (multi-family check)
1222 if( spellInfo_1
->Id
== 19410 && spellInfo_2
->Id
== 5116 )
1225 // Improved Wing Clip -> Wing Clip (multi-family check)
1226 if( (spellInfo_2
->SpellFamilyFlags
& UI64LIT(0x40)) && spellInfo_1
->Id
== 19229 )
1230 case SPELLFAMILY_PALADIN
:
1232 // Unstable Currents and other -> *Sanctity Aura (multi-family check)
1233 if( spellInfo_2
->SpellIconID
==502 && spellInfo_1
->SpellIconID
==502 && spellInfo_1
->SpellVisual
[0]==969 )
1236 // *Band of Eternal Champion and Seal of Command(multi-family check)
1237 if( spellId_1
== 35081 && spellInfo_2
->SpellIconID
==561 && spellInfo_2
->SpellVisual
[0]==7992)
1243 // Dragonmaw Illusion, Blood Elf Illusion, Human Illusion, Illidari Agent Illusion, Scarlet Crusade Disguise
1244 if(spellInfo_1
->SpellIconID
== 1691 && spellInfo_2
->SpellIconID
== 1691)
1247 case SPELLFAMILY_MAGE
:
1248 if( spellInfo_2
->SpellFamilyName
== SPELLFAMILY_MAGE
)
1250 // Blizzard & Chilled (and some other stacked with blizzard spells
1251 if( (spellInfo_1
->SpellFamilyFlags
& UI64LIT(0x80)) && (spellInfo_2
->SpellFamilyFlags
& UI64LIT(0x100000)) ||
1252 (spellInfo_2
->SpellFamilyFlags
& UI64LIT(0x80)) && (spellInfo_1
->SpellFamilyFlags
& UI64LIT(0x100000)) )
1255 // Blink & Improved Blink
1256 if( (spellInfo_1
->SpellFamilyFlags
& UI64LIT(0x0000000000010000)) && (spellInfo_2
->SpellVisual
[0] == 72 && spellInfo_2
->SpellIconID
== 1499) ||
1257 (spellInfo_2
->SpellFamilyFlags
& UI64LIT(0x0000000000010000)) && (spellInfo_1
->SpellVisual
[0] == 72 && spellInfo_1
->SpellIconID
== 1499) )
1260 // Detect Invisibility and Mana Shield (multi-family check)
1261 if( spellInfo_2
->Id
== 132 && spellInfo_1
->SpellIconID
== 209 && spellInfo_1
->SpellVisual
[0] == 968 )
1264 // Combustion and Fire Protection Aura (multi-family check)
1265 if( spellInfo_1
->Id
== 11129 && spellInfo_2
->SpellIconID
== 33 && spellInfo_2
->SpellVisual
[0] == 321 )
1269 case SPELLFAMILY_WARLOCK
:
1270 if( spellInfo_2
->SpellFamilyName
== SPELLFAMILY_WARLOCK
)
1272 // Siphon Life and Drain Life
1273 if( spellInfo_1
->SpellIconID
== 152 && spellInfo_2
->SpellIconID
== 546 ||
1274 spellInfo_2
->SpellIconID
== 152 && spellInfo_1
->SpellIconID
== 546 )
1277 //Corruption & Seed of corruption
1278 if( spellInfo_1
->SpellIconID
== 313 && spellInfo_2
->SpellIconID
== 1932 ||
1279 spellInfo_2
->SpellIconID
== 313 && spellInfo_1
->SpellIconID
== 1932 )
1280 if(spellInfo_1
->SpellVisual
[0] != 0 && spellInfo_2
->SpellVisual
[0] != 0)
1281 return true; // can't be stacked
1283 // Corruption and Unstable Affliction
1284 if( spellInfo_1
->SpellIconID
== 313 && spellInfo_2
->SpellIconID
== 2039 ||
1285 spellInfo_2
->SpellIconID
== 313 && spellInfo_1
->SpellIconID
== 2039 )
1288 // (Corruption or Unstable Affliction) and (Curse of Agony or Curse of Doom)
1289 if( (spellInfo_1
->SpellIconID
== 313 || spellInfo_1
->SpellIconID
== 2039) && (spellInfo_2
->SpellIconID
== 544 || spellInfo_2
->SpellIconID
== 91) ||
1290 (spellInfo_2
->SpellIconID
== 313 || spellInfo_2
->SpellIconID
== 2039) && (spellInfo_1
->SpellIconID
== 544 || spellInfo_1
->SpellIconID
== 91) )
1293 // Detect Invisibility and Mana Shield (multi-family check)
1294 if( spellInfo_1
->Id
== 132 && spellInfo_2
->SpellIconID
== 209 && spellInfo_2
->SpellVisual
[0] == 968 )
1297 case SPELLFAMILY_WARRIOR
:
1298 if( spellInfo_2
->SpellFamilyName
== SPELLFAMILY_WARRIOR
)
1300 // Rend and Deep Wound
1301 if( (spellInfo_1
->SpellFamilyFlags
& UI64LIT(0x20)) && (spellInfo_2
->SpellFamilyFlags
& UI64LIT(0x1000000000)) ||
1302 (spellInfo_2
->SpellFamilyFlags
& UI64LIT(0x20)) && (spellInfo_1
->SpellFamilyFlags
& UI64LIT(0x1000000000)) )
1305 // Battle Shout and Rampage
1306 if( (spellInfo_1
->SpellIconID
== 456 && spellInfo_2
->SpellIconID
== 2006) ||
1307 (spellInfo_2
->SpellIconID
== 456 && spellInfo_1
->SpellIconID
== 2006) )
1311 // Hamstring -> Improved Hamstring (multi-family check)
1312 if( (spellInfo_1
->SpellFamilyFlags
& UI64LIT(0x2)) && spellInfo_2
->Id
== 23694 )
1315 // Defensive Stance and Scroll of Protection (multi-family check)
1316 if( spellInfo_1
->Id
== 71 && spellInfo_2
->SpellIconID
== 276 && spellInfo_2
->SpellVisual
[0] == 196 )
1319 // Bloodlust and Bloodthirst (multi-family check)
1320 if( spellInfo_2
->Id
== 2825 && spellInfo_1
->SpellIconID
== 38 && spellInfo_1
->SpellVisual
[0] == 0 )
1324 case SPELLFAMILY_PRIEST
:
1325 if( spellInfo_2
->SpellFamilyName
== SPELLFAMILY_PRIEST
)
1327 //Devouring Plague and Shadow Vulnerability
1328 if ((spellInfo_1
->SpellFamilyFlags
& UI64LIT(0x2000000)) && (spellInfo_2
->SpellFamilyFlags
& UI64LIT(0x800000000)) ||
1329 (spellInfo_2
->SpellFamilyFlags
& UI64LIT(0x2000000)) && (spellInfo_1
->SpellFamilyFlags
& UI64LIT(0x800000000)))
1332 //StarShards and Shadow Word: Pain
1333 if ((spellInfo_1
->SpellFamilyFlags
& UI64LIT(0x200000)) && (spellInfo_2
->SpellFamilyFlags
& UI64LIT(0x8000)) ||
1334 (spellInfo_2
->SpellFamilyFlags
& UI64LIT(0x200000)) && (spellInfo_1
->SpellFamilyFlags
& UI64LIT(0x8000)))
1337 if ((spellInfo_1
->Id
== 47585 && spellInfo_2
->Id
== 60069) ||
1338 (spellInfo_2
->Id
== 47585 && spellInfo_1
->Id
== 60069))
1342 case SPELLFAMILY_DRUID
:
1343 if( spellInfo_2
->SpellFamilyName
== SPELLFAMILY_DRUID
)
1345 //Omen of Clarity and Blood Frenzy
1346 if( (spellInfo_1
->SpellFamilyFlags
== UI64LIT(0x0) && spellInfo_1
->SpellIconID
== 108) && (spellInfo_2
->SpellFamilyFlags
& UI64LIT(0x20000000000000)) ||
1347 (spellInfo_2
->SpellFamilyFlags
== UI64LIT(0x0) && spellInfo_2
->SpellIconID
== 108) && (spellInfo_1
->SpellFamilyFlags
& UI64LIT(0x20000000000000)) )
1350 // Tree of Life (Shapeshift) and 34123 Tree of Life (Passive)
1351 if ((spellId_1
== 33891 && spellId_2
== 34123) ||
1352 (spellId_2
== 33891 && spellId_1
== 34123))
1355 // Wrath of Elune and Nature's Grace
1356 if( spellInfo_1
->Id
== 16886 && spellInfo_2
->Id
== 46833 || spellInfo_2
->Id
== 16886 && spellInfo_1
->Id
== 46833 )
1359 // Bear Rage (Feral T4 (2)) and Omen of Clarity
1360 if( spellInfo_1
->Id
== 16864 && spellInfo_2
->Id
== 37306 || spellInfo_2
->Id
== 16864 && spellInfo_1
->Id
== 37306 )
1363 // Cat Energy (Feral T4 (2)) and Omen of Clarity
1364 if( spellInfo_1
->Id
== 16864 && spellInfo_2
->Id
== 37311 || spellInfo_2
->Id
== 16864 && spellInfo_1
->Id
== 37311 )
1367 // Survival Instincts and Survival Instincts
1368 if( spellInfo_1
->Id
== 61336 && spellInfo_2
->Id
== 50322 || spellInfo_2
->Id
== 61336 && spellInfo_1
->Id
== 50322 )
1372 // Leader of the Pack and Scroll of Stamina (multi-family check)
1373 if( spellInfo_1
->Id
== 24932 && spellInfo_2
->SpellIconID
== 312 && spellInfo_2
->SpellVisual
[0] == 216 )
1376 // Dragonmaw Illusion (multi-family check)
1377 if (spellId_1
== 42016 && spellId_2
== 40216 )
1381 case SPELLFAMILY_ROGUE
:
1382 if( spellInfo_2
->SpellFamilyName
== SPELLFAMILY_ROGUE
)
1384 // Master of Subtlety
1385 if (spellId_1
== 31665 && spellId_2
== 31666 || spellId_1
== 31666 && spellId_2
== 31665 )
1390 if( spellInfo_1
->SpellIconID
== 2285 && spellInfo_2
->SpellIconID
== 2285 )
1393 // Garrote -> Garrote-Silence (multi-family check)
1394 if( spellInfo_1
->SpellIconID
== 498 && spellInfo_2
->SpellIconID
== 498 && spellInfo_2
->SpellVisual
[0] == 0 )
1397 case SPELLFAMILY_HUNTER
:
1398 if( spellInfo_2
->SpellFamilyName
== SPELLFAMILY_HUNTER
)
1400 // Rapid Fire & Quick Shots
1401 if( (spellInfo_1
->SpellFamilyFlags
& UI64LIT(0x20)) && (spellInfo_2
->SpellFamilyFlags
& UI64LIT(0x20000000000)) ||
1402 (spellInfo_2
->SpellFamilyFlags
& UI64LIT(0x20)) && (spellInfo_1
->SpellFamilyFlags
& UI64LIT(0x20000000000)) )
1405 // Serpent Sting & (Immolation/Explosive Trap Effect)
1406 if( (spellInfo_1
->SpellFamilyFlags
& UI64LIT(0x4)) && (spellInfo_2
->SpellFamilyFlags
& UI64LIT(0x00000004000)) ||
1407 (spellInfo_2
->SpellFamilyFlags
& UI64LIT(0x4)) && (spellInfo_1
->SpellFamilyFlags
& UI64LIT(0x00000004000)) )
1411 if( spellInfo_1
->SpellIconID
== 1680 && spellInfo_2
->SpellIconID
== 1680 )
1415 // Wing Clip -> Improved Wing Clip (multi-family check)
1416 if( (spellInfo_1
->SpellFamilyFlags
& UI64LIT(0x40)) && spellInfo_2
->Id
== 19229 )
1419 // Concussive Shot and Imp. Concussive Shot (multi-family check)
1420 if( spellInfo_2
->Id
== 19410 && spellInfo_1
->Id
== 5116 )
1423 case SPELLFAMILY_PALADIN
:
1424 if( spellInfo_2
->SpellFamilyName
== SPELLFAMILY_PALADIN
)
1427 if( IsSealSpell(spellInfo_1
) && IsSealSpell(spellInfo_2
) )
1430 // Combustion and Fire Protection Aura (multi-family check)
1431 if( spellInfo_2
->Id
== 11129 && spellInfo_1
->SpellIconID
== 33 && spellInfo_1
->SpellVisual
[0] == 321 )
1434 // *Sanctity Aura -> Unstable Currents and other (multi-family check)
1435 if( spellInfo_1
->SpellIconID
==502 && spellInfo_2
->SpellFamilyName
== SPELLFAMILY_GENERIC
&& spellInfo_2
->SpellIconID
==502 && spellInfo_2
->SpellVisual
[0]==969 )
1438 // *Seal of Command and Band of Eternal Champion (multi-family check)
1439 if( spellInfo_1
->SpellIconID
==561 && spellInfo_1
->SpellVisual
[0]==7992 && spellId_2
== 35081)
1442 case SPELLFAMILY_SHAMAN
:
1443 if( spellInfo_2
->SpellFamilyName
== SPELLFAMILY_SHAMAN
)
1446 if( IsElementalShield(spellInfo_1
) && IsElementalShield(spellInfo_2
) )
1450 if( spellInfo_1
->SpellIconID
==220 && spellInfo_2
->SpellIconID
==220 &&
1451 spellInfo_1
->SpellFamilyFlags
!= spellInfo_2
->SpellFamilyFlags
)
1454 // Bloodlust and Bloodthirst (multi-family check)
1455 if( spellInfo_1
->Id
== 2825 && spellInfo_2
->SpellIconID
== 38 && spellInfo_2
->SpellVisual
[0] == 0 )
1462 // more generic checks
1463 if (spellInfo_1
->SpellIconID
== spellInfo_2
->SpellIconID
&&
1464 spellInfo_1
->SpellIconID
!= 0 && spellInfo_2
->SpellIconID
!= 0)
1466 bool isModifier
= false;
1467 for (int i
= 0; i
< 3; ++i
)
1469 if (spellInfo_1
->EffectApplyAuraName
[i
] == SPELL_AURA_ADD_FLAT_MODIFIER
||
1470 spellInfo_1
->EffectApplyAuraName
[i
] == SPELL_AURA_ADD_PCT_MODIFIER
||
1471 spellInfo_2
->EffectApplyAuraName
[i
] == SPELL_AURA_ADD_FLAT_MODIFIER
||
1472 spellInfo_2
->EffectApplyAuraName
[i
] == SPELL_AURA_ADD_PCT_MODIFIER
)
1480 if (IsRankSpellDueToSpell(spellInfo_1
, spellId_2
))
1483 if (spellInfo_1
->SpellFamilyName
== 0 || spellInfo_2
->SpellFamilyName
== 0)
1486 if (spellInfo_1
->SpellFamilyName
!= spellInfo_2
->SpellFamilyName
)
1489 for (int i
= 0; i
< 3; ++i
)
1490 if (spellInfo_1
->Effect
[i
] != spellInfo_2
->Effect
[i
] ||
1491 spellInfo_1
->EffectItemType
[i
] != spellInfo_2
->EffectItemType
[i
] ||
1492 spellInfo_1
->EffectMiscValue
[i
] != spellInfo_2
->EffectMiscValue
[i
] ||
1493 spellInfo_1
->EffectApplyAuraName
[i
] != spellInfo_2
->EffectApplyAuraName
[i
])
1499 bool SpellMgr::IsProfessionOrRidingSpell(uint32 spellId
)
1501 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(spellId
);
1505 if(spellInfo
->Effect
[1] != SPELL_EFFECT_SKILL
)
1508 uint32 skill
= spellInfo
->EffectMiscValue
[1];
1510 return IsProfessionOrRidingSkill(skill
);
1513 bool SpellMgr::IsProfessionSpell(uint32 spellId
)
1515 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(spellId
);
1519 if(spellInfo
->Effect
[1] != SPELL_EFFECT_SKILL
)
1522 uint32 skill
= spellInfo
->EffectMiscValue
[1];
1524 return IsProfessionSkill(skill
);
1527 bool SpellMgr::IsPrimaryProfessionSpell(uint32 spellId
)
1529 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(spellId
);
1533 if(spellInfo
->Effect
[1] != SPELL_EFFECT_SKILL
)
1536 uint32 skill
= spellInfo
->EffectMiscValue
[1];
1538 return IsPrimaryProfessionSkill(skill
);
1541 bool SpellMgr::IsPrimaryProfessionFirstRankSpell(uint32 spellId
) const
1543 return IsPrimaryProfessionSpell(spellId
) && GetSpellRank(spellId
)==1;
1546 bool SpellMgr::IsSkillBonusSpell(uint32 spellId
) const
1548 SkillLineAbilityMap::const_iterator lower
= GetBeginSkillLineAbilityMap(spellId
);
1549 SkillLineAbilityMap::const_iterator upper
= GetEndSkillLineAbilityMap(spellId
);
1551 for(SkillLineAbilityMap::const_iterator _spell_idx
= lower
; _spell_idx
!= upper
; ++_spell_idx
)
1553 SkillLineAbilityEntry
const *pAbility
= _spell_idx
->second
;
1554 if (!pAbility
|| pAbility
->learnOnGetSkill
!= ABILITY_LEARNED_ON_GET_PROFESSION_SKILL
)
1557 if(pAbility
->req_skill_value
> 0)
1564 SpellEntry
const* SpellMgr::SelectAuraRankForPlayerLevel(SpellEntry
const* spellInfo
, uint32 playerLevel
) const
1566 // ignore passive spells
1567 if(IsPassiveSpell(spellInfo
->Id
))
1570 bool needRankSelection
= false;
1571 for(int i
=0;i
<3;++i
)
1573 if( IsPositiveEffect(spellInfo
->Id
, i
) && (
1574 spellInfo
->Effect
[i
] == SPELL_EFFECT_APPLY_AURA
||
1575 spellInfo
->Effect
[i
] == SPELL_EFFECT_APPLY_AREA_AURA_PARTY
||
1576 spellInfo
->Effect
[i
] == SPELL_EFFECT_APPLY_AREA_AURA_RAID
1579 needRankSelection
= true;
1585 if(!needRankSelection
)
1588 for(uint32 nextSpellId
= spellInfo
->Id
; nextSpellId
!= 0; nextSpellId
= GetPrevSpellInChain(nextSpellId
))
1590 SpellEntry
const *nextSpellInfo
= sSpellStore
.LookupEntry(nextSpellId
);
1594 // if found appropriate level
1595 if(playerLevel
+ 10 >= nextSpellInfo
->spellLevel
)
1596 return nextSpellInfo
;
1598 // one rank less then
1605 void SpellMgr::LoadSpellChains()
1607 mSpellChains
.clear(); // need for reload case
1608 mSpellChainsNext
.clear(); // need for reload case
1610 QueryResult
*result
= WorldDatabase
.Query("SELECT spell_id, prev_spell, first_spell, rank, req_spell FROM spell_chain");
1617 sLog
.outString( ">> Loaded 0 spell chain records" );
1618 sLog
.outErrorDb("`spell_chains` table is empty!");
1624 barGoLink
bar( result
->GetRowCount() );
1628 Field
*fields
= result
->Fetch();
1630 uint32 spell_id
= fields
[0].GetUInt32();
1632 SpellChainNode node
;
1633 node
.prev
= fields
[1].GetUInt32();
1634 node
.first
= fields
[2].GetUInt32();
1635 node
.rank
= fields
[3].GetUInt8();
1636 node
.req
= fields
[4].GetUInt32();
1638 if(!sSpellStore
.LookupEntry(spell_id
))
1640 sLog
.outErrorDb("Spell %u listed in `spell_chain` does not exist",spell_id
);
1644 if(node
.prev
!=0 && !sSpellStore
.LookupEntry(node
.prev
))
1646 sLog
.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has not existed previous rank spell.",
1647 spell_id
,node
.prev
,node
.first
,node
.rank
,node
.req
);
1651 if(!sSpellStore
.LookupEntry(node
.first
))
1653 sLog
.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has not existing first rank spell.",
1654 spell_id
,node
.prev
,node
.first
,node
.rank
,node
.req
);
1658 // check basic spell chain data integrity (note: rank can be equal 0 or 1 for first/single spell)
1659 if( (spell_id
== node
.first
) != (node
.rank
<= 1) ||
1660 (spell_id
== node
.first
) != (node
.prev
== 0) ||
1661 (node
.rank
<= 1) != (node
.prev
== 0) )
1663 sLog
.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has not compatible chain data.",
1664 spell_id
,node
.prev
,node
.first
,node
.rank
,node
.req
);
1668 if(node
.req
!=0 && !sSpellStore
.LookupEntry(node
.req
))
1670 sLog
.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has not existing required spell.",
1671 spell_id
,node
.prev
,node
.first
,node
.rank
,node
.req
);
1675 // talents not required data in spell chain for work, but must be checked if present for intergrity
1676 if(TalentSpellPos
const* pos
= GetTalentSpellPos(spell_id
))
1678 if(node
.rank
!=pos
->rank
+1)
1680 sLog
.outErrorDb("Talent %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has wrong rank.",
1681 spell_id
,node
.prev
,node
.first
,node
.rank
,node
.req
);
1685 if(TalentEntry
const* talentEntry
= sTalentStore
.LookupEntry(pos
->talent_id
))
1687 if(node
.first
!=talentEntry
->RankID
[0])
1689 sLog
.outErrorDb("Talent %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has wrong first rank spell.",
1690 spell_id
,node
.prev
,node
.first
,node
.rank
,node
.req
);
1694 if(node
.rank
> 1 && node
.prev
!= talentEntry
->RankID
[node
.rank
-1-1])
1696 sLog
.outErrorDb("Talent %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has wrong prev rank spell.",
1697 spell_id
,node
.prev
,node
.first
,node
.rank
,node
.req
);
1701 /*if(node.req!=talentEntry->DependsOnSpell)
1703 sLog.outErrorDb("Talent %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has wrong required spell.",
1704 spell_id,node.prev,node.first,node.rank,node.req);
1710 mSpellChains
[spell_id
] = node
;
1713 mSpellChainsNext
.insert(SpellChainMapNext::value_type(node
.prev
,spell_id
));
1716 mSpellChainsNext
.insert(SpellChainMapNext::value_type(node
.req
,spell_id
));
1719 } while( result
->NextRow() );
1723 // additional integrity checks
1724 for(SpellChainMap::const_iterator i
= mSpellChains
.begin(); i
!= mSpellChains
.end(); ++i
)
1728 SpellChainMap::const_iterator i_prev
= mSpellChains
.find(i
->second
.prev
);
1729 if(i_prev
== mSpellChains
.end())
1731 sLog
.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has not found previous rank spell in table.",
1732 i
->first
,i
->second
.prev
,i
->second
.first
,i
->second
.rank
,i
->second
.req
);
1734 else if( i_prev
->second
.first
!= i
->second
.first
)
1736 sLog
.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has different first spell in chain compared to previous rank spell (prev: %u, first: %u, rank: %d, req: %u).",
1737 i
->first
,i
->second
.prev
,i
->second
.first
,i
->second
.rank
,i
->second
.req
,
1738 i_prev
->second
.prev
,i_prev
->second
.first
,i_prev
->second
.rank
,i_prev
->second
.req
);
1740 else if( i_prev
->second
.rank
+1 != i
->second
.rank
)
1742 sLog
.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has different rank compared to previous rank spell (prev: %u, first: %u, rank: %d, req: %u).",
1743 i
->first
,i
->second
.prev
,i
->second
.first
,i
->second
.rank
,i
->second
.req
,
1744 i_prev
->second
.prev
,i_prev
->second
.first
,i_prev
->second
.rank
,i_prev
->second
.req
);
1750 SpellChainMap::const_iterator i_req
= mSpellChains
.find(i
->second
.req
);
1751 if(i_req
== mSpellChains
.end())
1753 sLog
.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has not found required rank spell in table.",
1754 i
->first
,i
->second
.prev
,i
->second
.first
,i
->second
.rank
,i
->second
.req
);
1756 else if( i_req
->second
.first
== i
->second
.first
)
1758 sLog
.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has required rank spell from same spell chain (prev: %u, first: %u, rank: %d, req: %u).",
1759 i
->first
,i
->second
.prev
,i
->second
.first
,i
->second
.rank
,i
->second
.req
,
1760 i_req
->second
.prev
,i_req
->second
.first
,i_req
->second
.rank
,i_req
->second
.req
);
1762 else if( i_req
->second
.req
)
1764 sLog
.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has required rank spell with required spell (prev: %u, first: %u, rank: %d, req: %u).",
1765 i
->first
,i
->second
.prev
,i
->second
.first
,i
->second
.rank
,i
->second
.req
,
1766 i_req
->second
.prev
,i_req
->second
.first
,i_req
->second
.rank
,i_req
->second
.req
);
1772 sLog
.outString( ">> Loaded %u spell chain records", count
);
1775 void SpellMgr::LoadSpellLearnSkills()
1777 mSpellLearnSkills
.clear(); // need for reload case
1779 // search auto-learned skills and add its to map also for use in unlearn spells/talents
1780 uint32 dbc_count
= 0;
1781 barGoLink
bar( sSpellStore
.GetNumRows() );
1782 for(uint32 spell
= 0; spell
< sSpellStore
.GetNumRows(); ++spell
)
1785 SpellEntry
const* entry
= sSpellStore
.LookupEntry(spell
);
1790 for(int i
= 0; i
< 3; ++i
)
1792 if(entry
->Effect
[i
]==SPELL_EFFECT_SKILL
)
1794 SpellLearnSkillNode dbc_node
;
1795 dbc_node
.skill
= entry
->EffectMiscValue
[i
];
1796 if ( dbc_node
.skill
!= SKILL_RIDING
)
1799 dbc_node
.value
= entry
->CalculateSimpleValue(i
)*75;
1800 dbc_node
.maxvalue
= entry
->CalculateSimpleValue(i
)*75;
1802 mSpellLearnSkills
[spell
] = dbc_node
;
1810 sLog
.outString( ">> Loaded %u Spell Learn Skills from DBC", dbc_count
);
1813 void SpellMgr::LoadSpellLearnSpells()
1815 mSpellLearnSpells
.clear(); // need for reload case
1818 QueryResult
*result
= WorldDatabase
.Query("SELECT entry, SpellID, Active FROM spell_learn_spell");
1825 sLog
.outString( ">> Loaded 0 spell learn spells" );
1826 sLog
.outErrorDb("`spell_learn_spell` table is empty!");
1832 barGoLink
bar( result
->GetRowCount() );
1836 Field
*fields
= result
->Fetch();
1838 uint32 spell_id
= fields
[0].GetUInt32();
1840 SpellLearnSpellNode node
;
1841 node
.spell
= fields
[1].GetUInt32();
1842 node
.active
= fields
[2].GetBool();
1843 node
.autoLearned
= false;
1845 if(!sSpellStore
.LookupEntry(spell_id
))
1847 sLog
.outErrorDb("Spell %u listed in `spell_learn_spell` does not exist",spell_id
);
1851 if(!sSpellStore
.LookupEntry(node
.spell
))
1853 sLog
.outErrorDb("Spell %u listed in `spell_learn_spell` does not exist",node
.spell
);
1857 mSpellLearnSpells
.insert(SpellLearnSpellMap::value_type(spell_id
,node
));
1860 } while( result
->NextRow() );
1864 // search auto-learned spells and add its to map also for use in unlearn spells/talents
1865 uint32 dbc_count
= 0;
1866 for(uint32 spell
= 0; spell
< sSpellStore
.GetNumRows(); ++spell
)
1868 SpellEntry
const* entry
= sSpellStore
.LookupEntry(spell
);
1873 for(int i
= 0; i
< 3; ++i
)
1875 if(entry
->Effect
[i
]==SPELL_EFFECT_LEARN_SPELL
)
1877 SpellLearnSpellNode dbc_node
;
1878 dbc_node
.spell
= entry
->EffectTriggerSpell
[i
];
1879 dbc_node
.active
= true; // all dbc based learned spells is active (show in spell book or hide by client itself)
1881 // ignore learning not existed spells (broken/outdated/or generic learnig spell 483
1882 if(!sSpellStore
.LookupEntry(dbc_node
.spell
))
1885 // talent or passive spells or skill-step spells auto-casted and not need dependent learning,
1886 // pet teaching spells don't must be dependent learning (casted)
1887 // other required explicit dependent learning
1888 dbc_node
.autoLearned
= entry
->EffectImplicitTargetA
[i
]==TARGET_PET
|| GetTalentSpellCost(spell
) > 0 || IsPassiveSpell(spell
) || IsSpellHaveEffect(entry
,SPELL_EFFECT_SKILL_STEP
);
1890 SpellLearnSpellMap::const_iterator db_node_begin
= GetBeginSpellLearnSpell(spell
);
1891 SpellLearnSpellMap::const_iterator db_node_end
= GetEndSpellLearnSpell(spell
);
1894 for(SpellLearnSpellMap::const_iterator itr
= db_node_begin
; itr
!= db_node_end
; ++itr
)
1896 if(itr
->second
.spell
== dbc_node
.spell
)
1898 sLog
.outErrorDb("Spell %u auto-learn spell %u in spell.dbc then the record in `spell_learn_spell` is redundant, please fix DB.",
1899 spell
,dbc_node
.spell
);
1905 if(!found
) // add new spell-spell pair if not found
1907 mSpellLearnSpells
.insert(SpellLearnSpellMap::value_type(spell
,dbc_node
));
1915 sLog
.outString( ">> Loaded %u spell learn spells + %u found in DBC", count
, dbc_count
);
1918 void SpellMgr::LoadSpellScriptTarget()
1920 mSpellScriptTarget
.clear(); // need for reload case
1924 QueryResult
*result
= WorldDatabase
.Query("SELECT entry,type,targetEntry FROM spell_script_target");
1933 sLog
.outErrorDb(">> Loaded 0 SpellScriptTarget. DB table `spell_script_target` is empty.");
1937 barGoLink
bar(result
->GetRowCount());
1941 Field
*fields
= result
->Fetch();
1944 uint32 spellId
= fields
[0].GetUInt32();
1945 uint32 type
= fields
[1].GetUInt32();
1946 uint32 targetEntry
= fields
[2].GetUInt32();
1948 SpellEntry
const* spellProto
= sSpellStore
.LookupEntry(spellId
);
1952 sLog
.outErrorDb("Table `spell_script_target`: spellId %u listed for TargetEntry %u does not exist.",spellId
,targetEntry
);
1956 bool targetfound
= false;
1957 for(int i
= 0; i
<3; ++i
)
1959 if( spellProto
->EffectImplicitTargetA
[i
]==TARGET_SCRIPT
||
1960 spellProto
->EffectImplicitTargetB
[i
]==TARGET_SCRIPT
||
1961 spellProto
->EffectImplicitTargetA
[i
]==TARGET_SCRIPT_COORDINATES
||
1962 spellProto
->EffectImplicitTargetB
[i
]==TARGET_SCRIPT_COORDINATES
)
1970 sLog
.outErrorDb("Table `spell_script_target`: spellId %u listed for TargetEntry %u does not have any implicit target TARGET_SCRIPT(38) or TARGET_SCRIPT_COORDINATES (46).",spellId
,targetEntry
);
1974 if( type
>= MAX_SPELL_TARGET_TYPE
)
1976 sLog
.outErrorDb("Table `spell_script_target`: target type %u for TargetEntry %u is incorrect.",type
,targetEntry
);
1982 case SPELL_TARGET_TYPE_GAMEOBJECT
:
1984 if( targetEntry
==0 )
1987 if(!sGOStorage
.LookupEntry
<GameObjectInfo
>(targetEntry
))
1989 sLog
.outErrorDb("Table `spell_script_target`: gameobject template entry %u does not exist.",targetEntry
);
1996 if( targetEntry
==0 )
1998 sLog
.outErrorDb("Table `spell_script_target`: target entry == 0 for not GO target type (%u).",type
);
2001 if(!sCreatureStorage
.LookupEntry
<CreatureInfo
>(targetEntry
))
2003 sLog
.outErrorDb("Table `spell_script_target`: creature template entry %u does not exist.",targetEntry
);
2006 const CreatureInfo
* cInfo
= sCreatureStorage
.LookupEntry
<CreatureInfo
>(targetEntry
);
2008 if(spellId
== 30427 && !cInfo
->SkinLootId
)
2010 sLog
.outErrorDb("Table `spell_script_target` has creature %u as a target of spellid 30427, but this creature has no skinlootid. Gas extraction will not work!", cInfo
->Entry
);
2017 mSpellScriptTarget
.insert(SpellScriptTarget::value_type(spellId
,SpellTargetEntry(SpellTargetType(type
),targetEntry
)));
2020 } while (result
->NextRow());
2025 /* Disabled (lot errors at this moment)
2026 for(uint32 i = 1; i < sSpellStore.nCount; ++i)
2028 SpellEntry const * spellInfo = sSpellStore.LookupEntry(i);
2033 for(int j=0; j<3; ++j)
2035 if( spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT || spellInfo->EffectImplicitTargetA[j] != TARGET_SELF && spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT )
2037 SpellScriptTarget::const_iterator lower = spellmgr.GetBeginSpellScriptTarget(spellInfo->Id);
2038 SpellScriptTarget::const_iterator upper = spellmgr.GetEndSpellScriptTarget(spellInfo->Id);
2041 sLog.outErrorDb("Spell (ID: %u) has effect EffectImplicitTargetA/EffectImplicitTargetB = %u (TARGET_SCRIPT), but does not have record in `spell_script_target`",spellInfo->Id,TARGET_SCRIPT);
2042 break; // effects of spell
2050 sLog
.outString(">> Loaded %u Spell Script Targets", count
);
2053 void SpellMgr::LoadSpellPetAuras()
2055 mSpellPetAuraMap
.clear(); // need for reload case
2060 QueryResult
*result
= WorldDatabase
.Query("SELECT spell, pet, aura FROM spell_pet_auras");
2069 sLog
.outString( ">> Loaded %u spell pet auras", count
);
2073 barGoLink
bar( result
->GetRowCount() );
2077 Field
*fields
= result
->Fetch();
2081 uint16 spell
= fields
[0].GetUInt16();
2082 uint16 pet
= fields
[1].GetUInt16();
2083 uint16 aura
= fields
[2].GetUInt16();
2085 SpellPetAuraMap::iterator itr
= mSpellPetAuraMap
.find(spell
);
2086 if(itr
!= mSpellPetAuraMap
.end())
2088 itr
->second
.AddAura(pet
, aura
);
2092 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spell
);
2095 sLog
.outErrorDb("Spell %u listed in `spell_pet_auras` does not exist", spell
);
2100 if((spellInfo
->Effect
[i
] == SPELL_EFFECT_APPLY_AURA
&&
2101 spellInfo
->EffectApplyAuraName
[i
] == SPELL_AURA_DUMMY
) ||
2102 spellInfo
->Effect
[i
] == SPELL_EFFECT_DUMMY
)
2107 sLog
.outError("Spell %u listed in `spell_pet_auras` does not have dummy aura or dummy effect", spell
);
2111 SpellEntry
const* spellInfo2
= sSpellStore
.LookupEntry(aura
);
2114 sLog
.outErrorDb("Aura %u listed in `spell_pet_auras` does not exist", aura
);
2118 PetAura
pa(pet
, aura
, spellInfo
->EffectImplicitTargetA
[i
] == TARGET_PET
, spellInfo
->CalculateSimpleValue(i
));
2119 mSpellPetAuraMap
[spell
] = pa
;
2123 } while( result
->NextRow() );
2128 sLog
.outString( ">> Loaded %u spell pet auras", count
);
2131 void SpellMgr::LoadPetLevelupSpellMap()
2134 uint32 family_count
= 0;
2136 for (uint32 i
= 0; i
< sCreatureFamilyStore
.GetNumRows(); ++i
)
2138 CreatureFamilyEntry
const *creatureFamily
= sCreatureFamilyStore
.LookupEntry(i
);
2139 if(!creatureFamily
) // not exist
2142 for (uint32 j
= 0; j
< sSkillLineAbilityStore
.GetNumRows(); ++j
)
2144 SkillLineAbilityEntry
const *skillLine
= sSkillLineAbilityStore
.LookupEntry(j
);
2148 if (skillLine
->skillId
!=creatureFamily
->skillLine
[0] &&
2149 (!creatureFamily
->skillLine
[1] || skillLine
->skillId
!=creatureFamily
->skillLine
[1]))
2152 if(skillLine
->learnOnGetSkill
!= ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL
)
2155 SpellEntry
const *spell
= sSpellStore
.LookupEntry(skillLine
->spellId
);
2156 if(!spell
) // not exist
2159 PetLevelupSpellSet
& spellSet
= mPetLevelupSpellMap
[creatureFamily
->ID
];
2160 if(spellSet
.empty())
2163 spellSet
.insert(PetLevelupSpellSet::value_type(spell
->spellLevel
,spell
->Id
));
2169 sLog
.outString( ">> Loaded %u pet levelup and default spells for %u families", count
, family_count
);
2172 bool LoadPetDefaultSpells_helper(CreatureInfo
const* cInfo
, PetDefaultSpellsEntry
& petDefSpells
)
2175 bool have_spell
= false;
2176 for(int j
= 0; j
< MAX_CREATURE_SPELL_DATA_SLOT
; ++j
)
2178 if(petDefSpells
.spellid
[j
])
2187 // remove duplicates with levelupSpells if any
2188 if(PetLevelupSpellSet
const *levelupSpells
= cInfo
->family
? spellmgr
.GetPetLevelupSpellList(cInfo
->family
) : NULL
)
2190 for(int j
= 0; j
< MAX_CREATURE_SPELL_DATA_SLOT
; ++j
)
2192 if(!petDefSpells
.spellid
[j
])
2195 for(PetLevelupSpellSet::const_iterator itr
= levelupSpells
->begin(); itr
!= levelupSpells
->end(); ++itr
)
2197 if (itr
->second
== petDefSpells
.spellid
[j
])
2199 petDefSpells
.spellid
[j
] = 0;
2208 for(int j
= 0; j
< MAX_CREATURE_SPELL_DATA_SLOT
; ++j
)
2210 if(petDefSpells
.spellid
[j
])
2220 void SpellMgr::LoadPetDefaultSpells()
2222 assert(MAX_CREATURE_SPELL_DATA_SLOT
==CREATURE_MAX_SPELLS
);
2224 mPetDefaultSpellsMap
.clear();
2226 uint32 countCreature
= 0;
2227 uint32 countData
= 0;
2229 for(uint32 i
= 0; i
< sCreatureStorage
.MaxEntry
; ++i
)
2231 CreatureInfo
const* cInfo
= sCreatureStorage
.LookupEntry
<CreatureInfo
>(i
);
2235 if(!cInfo
->PetSpellDataId
)
2238 // for creature with PetSpellDataId get default pet spells from dbc
2239 CreatureSpellDataEntry
const* spellDataEntry
= sCreatureSpellDataStore
.LookupEntry(cInfo
->PetSpellDataId
);
2243 int32 petSpellsId
= -(int32
)cInfo
->PetSpellDataId
;
2244 PetDefaultSpellsEntry petDefSpells
;
2245 for(int j
= 0; j
< MAX_CREATURE_SPELL_DATA_SLOT
; ++j
)
2246 petDefSpells
.spellid
[j
] = spellDataEntry
->spellId
[j
];
2248 if(LoadPetDefaultSpells_helper(cInfo
, petDefSpells
))
2250 mPetDefaultSpellsMap
[petSpellsId
] = petDefSpells
;
2255 // different summon spells
2256 for(uint32 i
= 0; i
< sSpellStore
.GetNumRows(); ++i
)
2258 SpellEntry
const* spellEntry
= sSpellStore
.LookupEntry(i
);
2262 for(int k
= 0; k
< 3; ++k
)
2264 if(spellEntry
->Effect
[k
]==SPELL_EFFECT_SUMMON
|| spellEntry
->Effect
[k
]==SPELL_EFFECT_SUMMON_PET
)
2266 uint32 creature_id
= spellEntry
->EffectMiscValue
[k
];
2267 CreatureInfo
const* cInfo
= sCreatureStorage
.LookupEntry
<CreatureInfo
>(creature_id
);
2272 if(cInfo
->PetSpellDataId
)
2275 // for creature without PetSpellDataId get default pet spells from creature_template
2276 int32 petSpellsId
= cInfo
->Entry
;
2277 if(mPetDefaultSpellsMap
.find(cInfo
->Entry
) != mPetDefaultSpellsMap
.end())
2280 PetDefaultSpellsEntry petDefSpells
;
2281 for(int j
= 0; j
< MAX_CREATURE_SPELL_DATA_SLOT
; ++j
)
2282 petDefSpells
.spellid
[j
] = cInfo
->spells
[j
];
2284 if(LoadPetDefaultSpells_helper(cInfo
, petDefSpells
))
2286 mPetDefaultSpellsMap
[petSpellsId
] = petDefSpells
;
2294 sLog
.outString( ">> Loaded addition spells for %u pet spell data entries and %u summonable creature templates", countData
, countCreature
);
2297 /// Some checks for spells, to prevent adding deprecated/broken spells for trainers, spell book, etc
2298 bool SpellMgr::IsSpellValid(SpellEntry
const* spellInfo
, Player
* pl
, bool msg
)
2304 bool need_check_reagents
= false;
2307 for(int i
=0; i
<3; ++i
)
2309 switch(spellInfo
->Effect
[i
])
2314 // craft spell for crafting non-existed item (break client recipes list show)
2315 case SPELL_EFFECT_CREATE_ITEM
:
2317 if(!ObjectMgr::GetItemPrototype( spellInfo
->EffectItemType
[i
] ))
2322 ChatHandler(pl
).PSendSysMessage("Craft spell %u create not-exist in DB item (Entry: %u) and then...",spellInfo
->Id
,spellInfo
->EffectItemType
[i
]);
2324 sLog
.outErrorDb("Craft spell %u create not-exist in DB item (Entry: %u) and then...",spellInfo
->Id
,spellInfo
->EffectItemType
[i
]);
2329 need_check_reagents
= true;
2332 case SPELL_EFFECT_LEARN_SPELL
:
2334 SpellEntry
const* spellInfo2
= sSpellStore
.LookupEntry(spellInfo
->EffectTriggerSpell
[i
]);
2335 if( !IsSpellValid(spellInfo2
,pl
,msg
) )
2340 ChatHandler(pl
).PSendSysMessage("Spell %u learn to broken spell %u, and then...",spellInfo
->Id
,spellInfo
->EffectTriggerSpell
[i
]);
2342 sLog
.outErrorDb("Spell %u learn to invalid spell %u, and then...",spellInfo
->Id
,spellInfo
->EffectTriggerSpell
[i
]);
2351 if(need_check_reagents
)
2353 for(int j
= 0; j
< 8; ++j
)
2355 if(spellInfo
->Reagent
[j
] > 0 && !ObjectMgr::GetItemPrototype( spellInfo
->Reagent
[j
] ))
2360 ChatHandler(pl
).PSendSysMessage("Craft spell %u have not-exist reagent in DB item (Entry: %u) and then...",spellInfo
->Id
,spellInfo
->Reagent
[j
]);
2362 sLog
.outErrorDb("Craft spell %u have not-exist reagent in DB item (Entry: %u) and then...",spellInfo
->Id
,spellInfo
->Reagent
[j
]);
2372 void SpellMgr::LoadSpellAreas()
2374 mSpellAreaMap
.clear(); // need for reload case
2375 mSpellAreaForQuestMap
.clear();
2376 mSpellAreaForActiveQuestMap
.clear();
2377 mSpellAreaForQuestEndMap
.clear();
2378 mSpellAreaForAuraMap
.clear();
2382 // 0 1 2 3 4 5 6 7 8
2383 QueryResult
*result
= WorldDatabase
.Query("SELECT spell, area, quest_start, quest_start_active, quest_end, aura_spell, racemask, gender, autocast FROM spell_area");
2392 sLog
.outString( ">> Loaded %u spell area requirements", count
);
2396 barGoLink
bar( result
->GetRowCount() );
2400 Field
*fields
= result
->Fetch();
2404 uint32 spell
= fields
[0].GetUInt32();
2405 SpellArea spellArea
;
2406 spellArea
.spellId
= spell
;
2407 spellArea
.areaId
= fields
[1].GetUInt32();
2408 spellArea
.questStart
= fields
[2].GetUInt32();
2409 spellArea
.questStartCanActive
= fields
[3].GetBool();
2410 spellArea
.questEnd
= fields
[4].GetUInt32();
2411 spellArea
.auraSpell
= fields
[5].GetInt32();
2412 spellArea
.raceMask
= fields
[6].GetUInt32();
2413 spellArea
.gender
= Gender(fields
[7].GetUInt8());
2414 spellArea
.autocast
= fields
[8].GetBool();
2416 if(!sSpellStore
.LookupEntry(spell
))
2418 sLog
.outErrorDb("Spell %u listed in `spell_area` does not exist", spell
);
2424 SpellAreaMapBounds sa_bounds
= GetSpellAreaMapBounds(spellArea
.spellId
);
2425 for(SpellAreaMap::const_iterator itr
= sa_bounds
.first
; itr
!= sa_bounds
.second
; ++itr
)
2427 if(spellArea
.spellId
&& itr
->second
.spellId
&& spellArea
.spellId
!= itr
->second
.spellId
)
2429 if(spellArea
.areaId
&& itr
->second
.areaId
&& spellArea
.areaId
!= itr
->second
.areaId
)
2431 if(spellArea
.questStart
&& itr
->second
.questStart
&& spellArea
.questStart
!= itr
->second
.questStart
)
2433 if(spellArea
.auraSpell
&& itr
->second
.auraSpell
&& spellArea
.auraSpell
!= itr
->second
.auraSpell
)
2435 if(spellArea
.raceMask
&& itr
->second
.raceMask
&& (spellArea
.raceMask
& itr
->second
.raceMask
)==0)
2437 if(spellArea
.gender
!= GENDER_NONE
&& itr
->second
.gender
!= GENDER_NONE
&& spellArea
.gender
!= itr
->second
.gender
)
2440 // duplicate by requirements
2447 sLog
.outErrorDb("Spell %u listed in `spell_area` already listed with similar requirements.", spell
);
2453 if(spellArea
.areaId
&& !GetAreaEntryByAreaID(spellArea
.areaId
))
2455 sLog
.outErrorDb("Spell %u listed in `spell_area` have wrong area (%u) requirement", spell
,spellArea
.areaId
);
2459 if(spellArea
.questStart
&& !objmgr
.GetQuestTemplate(spellArea
.questStart
))
2461 sLog
.outErrorDb("Spell %u listed in `spell_area` have wrong start quest (%u) requirement", spell
,spellArea
.questStart
);
2465 if(spellArea
.questEnd
)
2467 if(!objmgr
.GetQuestTemplate(spellArea
.questEnd
))
2469 sLog
.outErrorDb("Spell %u listed in `spell_area` have wrong end quest (%u) requirement", spell
,spellArea
.questEnd
);
2473 if(spellArea
.questEnd
==spellArea
.questStart
&& !spellArea
.questStartCanActive
)
2475 sLog
.outErrorDb("Spell %u listed in `spell_area` have quest (%u) requirement for start and end in same time", spell
,spellArea
.questEnd
);
2480 if(spellArea
.auraSpell
)
2482 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(abs(spellArea
.auraSpell
));
2485 sLog
.outErrorDb("Spell %u listed in `spell_area` have wrong aura spell (%u) requirement", spell
,abs(spellArea
.auraSpell
));
2489 if(spellInfo
->EffectApplyAuraName
[0]!=SPELL_AURA_DUMMY
&& spellInfo
->EffectApplyAuraName
[0]!=SPELL_AURA_PHASE
)
2491 sLog
.outErrorDb("Spell %u listed in `spell_area` have aura spell requirement (%u) without dummy/phase aura in effect 0", spell
,abs(spellArea
.auraSpell
));
2495 if(abs(spellArea
.auraSpell
)==spellArea
.spellId
)
2497 sLog
.outErrorDb("Spell %u listed in `spell_area` have aura spell (%u) requirement for itself", spell
,abs(spellArea
.auraSpell
));
2501 // not allow autocast chains by auraSpell field (but allow use as alternative if not present)
2502 if(spellArea
.autocast
&& spellArea
.auraSpell
> 0)
2505 SpellAreaForAuraMapBounds saBound
= GetSpellAreaForAuraMapBounds(spellArea
.spellId
);
2506 for(SpellAreaForAuraMap::const_iterator itr
= saBound
.first
; itr
!= saBound
.second
; ++itr
)
2508 if(itr
->second
->autocast
&& itr
->second
->auraSpell
> 0)
2517 sLog
.outErrorDb("Spell %u listed in `spell_area` have aura spell (%u) requirement that itself autocast from aura", spell
,spellArea
.auraSpell
);
2521 SpellAreaMapBounds saBound2
= GetSpellAreaMapBounds(spellArea
.auraSpell
);
2522 for(SpellAreaMap::const_iterator itr2
= saBound2
.first
; itr2
!= saBound2
.second
; ++itr2
)
2524 if(itr2
->second
.autocast
&& itr2
->second
.auraSpell
> 0)
2533 sLog
.outErrorDb("Spell %u listed in `spell_area` have aura spell (%u) requirement that itself autocast from aura", spell
,spellArea
.auraSpell
);
2539 if(spellArea
.raceMask
&& (spellArea
.raceMask
& RACEMASK_ALL_PLAYABLE
)==0)
2541 sLog
.outErrorDb("Spell %u listed in `spell_area` have wrong race mask (%u) requirement", spell
,spellArea
.raceMask
);
2545 if(spellArea
.gender
!=GENDER_NONE
&& spellArea
.gender
!=GENDER_FEMALE
&& spellArea
.gender
!=GENDER_MALE
)
2547 sLog
.outErrorDb("Spell %u listed in `spell_area` have wrong gender (%u) requirement", spell
,spellArea
.gender
);
2551 SpellArea
const* sa
= &mSpellAreaMap
.insert(SpellAreaMap::value_type(spell
,spellArea
))->second
;
2553 // for search by current zone/subzone at zone/subzone change
2554 if(spellArea
.areaId
)
2555 mSpellAreaForAreaMap
.insert(SpellAreaForAreaMap::value_type(spellArea
.areaId
,sa
));
2557 // for search at quest start/reward
2558 if(spellArea
.questStart
)
2560 if(spellArea
.questStartCanActive
)
2561 mSpellAreaForActiveQuestMap
.insert(SpellAreaForQuestMap::value_type(spellArea
.questStart
,sa
));
2563 mSpellAreaForQuestMap
.insert(SpellAreaForQuestMap::value_type(spellArea
.questStart
,sa
));
2566 // for search at quest start/reward
2567 if(spellArea
.questEnd
)
2568 mSpellAreaForQuestEndMap
.insert(SpellAreaForQuestMap::value_type(spellArea
.questEnd
,sa
));
2570 // for search at aura apply
2571 if(spellArea
.auraSpell
)
2572 mSpellAreaForAuraMap
.insert(SpellAreaForAuraMap::value_type(abs(spellArea
.auraSpell
),sa
));
2575 } while( result
->NextRow() );
2580 sLog
.outString( ">> Loaded %u spell area requirements", count
);
2583 SpellCastResult
SpellMgr::GetSpellAllowedInLocationError(SpellEntry
const *spellInfo
, uint32 map_id
, uint32 zone_id
, uint32 area_id
, Player
const* player
)
2586 if( spellInfo
->AreaGroupId
> 0)
2589 AreaGroupEntry
const* groupEntry
= sAreaGroupStore
.LookupEntry(spellInfo
->AreaGroupId
);
2592 for (uint32 i
=0; i
<6; ++i
)
2593 if( groupEntry
->AreaId
[i
] == zone_id
|| groupEntry
->AreaId
[i
] == area_id
)
2595 if (found
|| !groupEntry
->nextGroup
)
2597 // Try search in next group
2598 groupEntry
= sAreaGroupStore
.LookupEntry(groupEntry
->nextGroup
);
2602 return SPELL_FAILED_INCORRECT_AREA
;
2605 // DB base check (if non empty then must fit at least single for allow)
2606 SpellAreaMapBounds saBounds
= spellmgr
.GetSpellAreaMapBounds(spellInfo
->Id
);
2607 if(saBounds
.first
!= saBounds
.second
)
2609 for(SpellAreaMap::const_iterator itr
= saBounds
.first
; itr
!= saBounds
.second
; ++itr
)
2611 if(itr
->second
.IsFitToRequirements(player
,zone_id
,area_id
))
2612 return SPELL_CAST_OK
;
2614 return SPELL_FAILED_INCORRECT_AREA
;
2618 switch(spellInfo
->Id
)
2620 case 23333: // Warsong Flag
2621 case 23335: // Silverwing Flag
2622 return map_id
== 489 && player
&& player
->InBattleGround() ? SPELL_CAST_OK
: SPELL_FAILED_REQUIRES_AREA
;
2623 case 34976: // Netherstorm Flag
2624 return map_id
== 566 && player
&& player
->InBattleGround() ? SPELL_CAST_OK
: SPELL_FAILED_REQUIRES_AREA
;
2625 case 2584: // Waiting to Resurrect
2626 case 22011: // Spirit Heal Channel
2627 case 22012: // Spirit Heal
2628 case 24171: // Resurrection Impact Visual
2629 case 42792: // Recently Dropped Flag
2630 case 43681: // Inactive
2631 case 44535: // Spirit Heal (mana)
2633 MapEntry
const* mapEntry
= sMapStore
.LookupEntry(map_id
);
2635 return SPELL_FAILED_INCORRECT_AREA
;
2637 return mapEntry
->IsBattleGround() && player
&& player
->InBattleGround() ? SPELL_CAST_OK
: SPELL_FAILED_REQUIRES_AREA
;
2639 case 44521: // Preparation
2642 return SPELL_FAILED_REQUIRES_AREA
;
2644 MapEntry
const* mapEntry
= sMapStore
.LookupEntry(map_id
);
2646 return SPELL_FAILED_INCORRECT_AREA
;
2648 if(!mapEntry
->IsBattleGround())
2649 return SPELL_FAILED_REQUIRES_AREA
;
2651 BattleGround
* bg
= player
->GetBattleGround();
2652 return bg
&& bg
->GetStatus()==STATUS_WAIT_JOIN
? SPELL_CAST_OK
: SPELL_FAILED_REQUIRES_AREA
;
2654 case 32724: // Gold Team (Alliance)
2655 case 32725: // Green Team (Alliance)
2656 case 35774: // Gold Team (Horde)
2657 case 35775: // Green Team (Horde)
2659 MapEntry
const* mapEntry
= sMapStore
.LookupEntry(map_id
);
2661 return SPELL_FAILED_INCORRECT_AREA
;
2663 return mapEntry
->IsBattleArena() && player
&& player
->InBattleGround() ? SPELL_CAST_OK
: SPELL_FAILED_REQUIRES_AREA
;
2665 case 32727: // Arena Preparation
2668 return SPELL_FAILED_REQUIRES_AREA
;
2670 MapEntry
const* mapEntry
= sMapStore
.LookupEntry(map_id
);
2672 return SPELL_FAILED_INCORRECT_AREA
;
2674 if(!mapEntry
->IsBattleArena())
2675 return SPELL_FAILED_REQUIRES_AREA
;
2677 BattleGround
* bg
= player
->GetBattleGround();
2678 return bg
&& bg
->GetStatus()==STATUS_WAIT_JOIN
? SPELL_CAST_OK
: SPELL_FAILED_REQUIRES_AREA
;
2682 return SPELL_CAST_OK
;
2685 void SpellMgr::LoadSkillLineAbilityMap()
2687 mSkillLineAbilityMap
.clear();
2689 barGoLink
bar( sSkillLineAbilityStore
.GetNumRows() );
2692 for (uint32 i
= 0; i
< sSkillLineAbilityStore
.GetNumRows(); ++i
)
2695 SkillLineAbilityEntry
const *SkillInfo
= sSkillLineAbilityStore
.LookupEntry(i
);
2699 mSkillLineAbilityMap
.insert(SkillLineAbilityMap::value_type(SkillInfo
->spellId
,SkillInfo
));
2704 sLog
.outString(">> Loaded %u SkillLineAbility MultiMap Data", count
);
2707 DiminishingGroup
GetDiminishingReturnsGroupForSpell(SpellEntry
const* spellproto
, bool triggered
)
2709 // Explicit Diminishing Groups
2710 switch(spellproto
->SpellFamilyName
)
2712 case SPELLFAMILY_ROGUE
:
2715 if (spellproto
->SpellFamilyFlags
& UI64LIT(0x00000200000))
2716 return DIMINISHING_KIDNEYSHOT
;
2718 else if (spellproto
->SpellFamilyFlags
& UI64LIT(0x00001000000))
2719 return DIMINISHING_BLIND_CYCLONE
;
2722 case SPELLFAMILY_WARLOCK
:
2725 if (spellproto
->SpellFamilyFlags
& UI64LIT(0x40840000000))
2726 return DIMINISHING_WARLOCK_FEAR
;
2728 else if (spellproto
->SpellFamilyFlags
& UI64LIT(0x00080000000))
2729 return DIMINISHING_LIMITONLY
;
2732 case SPELLFAMILY_DRUID
:
2735 if (spellproto
->SpellFamilyFlags
& UI64LIT(0x02000000000))
2736 return DIMINISHING_BLIND_CYCLONE
;
2739 case SPELLFAMILY_WARRIOR
:
2741 // Hamstring - limit duration to 10s in PvP
2742 if (spellproto
->SpellFamilyFlags
& UI64LIT(0x00000000002))
2743 return DIMINISHING_LIMITONLY
;
2751 uint32 mechanic
= GetAllSpellMechanicMask(spellproto
);
2752 if (mechanic
== MECHANIC_NONE
) return DIMINISHING_NONE
;
2753 if (mechanic
& (1<<MECHANIC_STUN
)) return triggered
? DIMINISHING_TRIGGER_STUN
: DIMINISHING_CONTROL_STUN
;
2754 if (mechanic
& (1<<MECHANIC_SLEEP
)) return DIMINISHING_SLEEP
;
2755 if (mechanic
& (1<<MECHANIC_POLYMORPH
)) return DIMINISHING_POLYMORPH
;
2756 if (mechanic
& (1<<MECHANIC_ROOT
)) return triggered
? DIMINISHING_TRIGGER_ROOT
: DIMINISHING_CONTROL_ROOT
;
2757 if (mechanic
& (1<<MECHANIC_FEAR
)) return DIMINISHING_FEAR
;
2758 if (mechanic
& (1<<MECHANIC_CHARM
)) return DIMINISHING_CHARM
;
2759 if (mechanic
& (1<<MECHANIC_SILENCE
)) return DIMINISHING_SILENCE
;
2760 if (mechanic
& (1<<DIMINISHING_DISARM
)) return DIMINISHING_DISARM
;
2761 if (mechanic
& (1<<MECHANIC_FREEZE
)) return DIMINISHING_FREEZE
;
2762 if (mechanic
& ((1<<MECHANIC_KNOCKOUT
) | (1<<MECHANIC_SAPPED
))) return DIMINISHING_KNOCKOUT
;
2763 if (mechanic
& (1<<MECHANIC_BANISH
)) return DIMINISHING_BANISH
;
2764 if (mechanic
& (1<<MECHANIC_HORROR
)) return DIMINISHING_DEATHCOIL
;
2767 return DIMINISHING_NONE
;
2770 bool IsDiminishingReturnsGroupDurationLimited(DiminishingGroup group
)
2774 case DIMINISHING_CONTROL_STUN
:
2775 case DIMINISHING_TRIGGER_STUN
:
2776 case DIMINISHING_KIDNEYSHOT
:
2777 case DIMINISHING_SLEEP
:
2778 case DIMINISHING_CONTROL_ROOT
:
2779 case DIMINISHING_TRIGGER_ROOT
:
2780 case DIMINISHING_FEAR
:
2781 case DIMINISHING_WARLOCK_FEAR
:
2782 case DIMINISHING_CHARM
:
2783 case DIMINISHING_POLYMORPH
:
2784 case DIMINISHING_FREEZE
:
2785 case DIMINISHING_KNOCKOUT
:
2786 case DIMINISHING_BLIND_CYCLONE
:
2787 case DIMINISHING_BANISH
:
2788 case DIMINISHING_LIMITONLY
:
2796 DiminishingReturnsType
GetDiminishingReturnsGroupType(DiminishingGroup group
)
2800 case DIMINISHING_BLIND_CYCLONE
:
2801 case DIMINISHING_CONTROL_STUN
:
2802 case DIMINISHING_TRIGGER_STUN
:
2803 case DIMINISHING_KIDNEYSHOT
:
2805 case DIMINISHING_SLEEP
:
2806 case DIMINISHING_CONTROL_ROOT
:
2807 case DIMINISHING_TRIGGER_ROOT
:
2808 case DIMINISHING_FEAR
:
2809 case DIMINISHING_CHARM
:
2810 case DIMINISHING_POLYMORPH
:
2811 case DIMINISHING_SILENCE
:
2812 case DIMINISHING_DISARM
:
2813 case DIMINISHING_DEATHCOIL
:
2814 case DIMINISHING_FREEZE
:
2815 case DIMINISHING_BANISH
:
2816 case DIMINISHING_WARLOCK_FEAR
:
2817 case DIMINISHING_KNOCKOUT
:
2818 return DRTYPE_PLAYER
;
2826 bool SpellArea::IsFitToRequirements(Player
const* player
, uint32 newZone
, uint32 newArea
) const
2828 if(gender
!=GENDER_NONE
)
2830 // not in expected gender
2831 if(!player
|| gender
!= player
->getGender())
2837 // not in expected race
2838 if(!player
|| !(raceMask
& player
->getRaceMask()))
2844 // not in expected zone
2845 if(newZone
!=areaId
&& newArea
!=areaId
)
2851 // not in expected required quest state
2852 if(!player
|| (!questStartCanActive
|| !player
->IsActiveQuest(questStart
)) && !player
->GetQuestRewardStatus(questStart
))
2858 // not in expected forbidden quest state
2859 if(!player
|| player
->GetQuestRewardStatus(questEnd
))
2865 // not have expected aura
2869 // have expected aura
2870 return player
->HasAura(auraSpell
,0);
2872 // not have expected aura
2873 return !player
->HasAura(-auraSpell
,0);