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
& 0x12040000)
142 return SPELL_MAGE_ARMOR
;
144 if ((spellInfo
->SpellFamilyFlags
& 0x1000000) && spellInfo
->EffectApplyAuraName
[0]==SPELL_AURA_MOD_CONFUSE
)
145 return SPELL_MAGE_POLYMORPH
;
149 case SPELLFAMILY_WARRIOR
:
151 if (spellInfo
->SpellFamilyFlags
& 0x00008000010000LL
)
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
& 0x2000002000000000LL
|| 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
& 0x0044000000380000LL
|| spellInfo
->SpellFamilyFlags2
& 0x00003010)
178 if( spellInfo
->SpellFamilyFlags2
& 0x00000002 )
179 return SPELL_TRACKER
;
183 case SPELLFAMILY_PALADIN
:
185 if (IsSealSpell(spellInfo
))
188 if (spellInfo
->SpellFamilyFlags
& 0x0000000011010002LL
)
189 return SPELL_BLESSING
;
191 if ((spellInfo
->SpellFamilyFlags
& 0x00000820180400LL
) && (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
:
343 if(spellproto
->CalculateSimpleValue(effIndex
) < 0)
347 case SPELL_AURA_ADD_TARGET_TRIGGER
:
349 case SPELL_AURA_PERIODIC_TRIGGER_SPELL
:
350 if(spellId
!= spellproto
->EffectTriggerSpell
[effIndex
])
352 uint32 spellTriggeredId
= spellproto
->EffectTriggerSpell
[effIndex
];
353 SpellEntry
const *spellTriggeredProto
= sSpellStore
.LookupEntry(spellTriggeredId
);
355 if(spellTriggeredProto
)
357 // non-positive targets of main spell return early
358 for(int i
= 0; i
< 3; ++i
)
360 // if non-positive trigger cast targeted to positive target this main cast is non-positive
361 // this will place this spell auras as debuffs
362 if(IsPositiveTarget(spellTriggeredProto
->EffectImplicitTargetA
[effIndex
],spellTriggeredProto
->EffectImplicitTargetB
[effIndex
]) && !IsPositiveEffect(spellTriggeredId
,i
))
368 case SPELL_AURA_PROC_TRIGGER_SPELL
:
369 // many positive auras have negative triggered spells at damage for example and this not make it negative (it can be canceled for example)
371 case SPELL_AURA_MOD_STUN
: //have positive and negative spells, we can't sort its correctly at this moment.
372 if(effIndex
==0 && spellproto
->Effect
[1]==0 && spellproto
->Effect
[2]==0)
373 return false; // but all single stun aura spells is negative
376 if(spellproto
->Id
== 17624)
379 case SPELL_AURA_MOD_ROOT
:
380 case SPELL_AURA_MOD_SILENCE
:
381 case SPELL_AURA_GHOST
:
382 case SPELL_AURA_PERIODIC_LEECH
:
383 case SPELL_AURA_MOD_PACIFY_SILENCE
:
384 case SPELL_AURA_MOD_STALKED
:
385 case SPELL_AURA_PERIODIC_DAMAGE_PERCENT
:
387 case SPELL_AURA_PERIODIC_DAMAGE
: // used in positive spells also.
388 // part of negative spell if casted at self (prevent cancel)
389 if(spellproto
->EffectImplicitTargetA
[effIndex
] == TARGET_SELF
)
392 case SPELL_AURA_MOD_DECREASE_SPEED
: // used in positive spells also
393 // part of positive spell if casted at self
394 if(spellproto
->EffectImplicitTargetA
[effIndex
] != TARGET_SELF
)
396 // but not this if this first effect (don't found batter check)
397 if(spellproto
->Attributes
& 0x4000000 && effIndex
==0)
400 case SPELL_AURA_TRANSFORM
:
401 // some spells negative
402 switch(spellproto
->Id
)
404 case 36897: // Transporter Malfunction (race mutation to horde)
405 case 36899: // Transporter Malfunction (race mutation to alliance)
409 case SPELL_AURA_MOD_SCALE
:
410 // some spells negative
411 switch(spellproto
->Id
)
413 case 36900: // Soul Split: Evil!
414 case 36901: // Soul Split: Good
415 case 36893: // Transporter Malfunction (decrease size case)
416 case 36895: // Transporter Malfunction (increase size case)
420 case SPELL_AURA_MECHANIC_IMMUNITY
:
422 // non-positive immunities
423 switch(spellproto
->EffectMiscValue
[effIndex
])
425 case MECHANIC_BANDAGE
:
426 case MECHANIC_SHIELD
:
428 case MECHANIC_INVULNERABILITY
:
434 case SPELL_AURA_ADD_FLAT_MODIFIER
: // mods
435 case SPELL_AURA_ADD_PCT_MODIFIER
:
438 switch(spellproto
->EffectMiscValue
[effIndex
])
440 case SPELLMOD_COST
: // dependent from bas point sign (negative -> positive)
441 if(spellproto
->CalculateSimpleValue(effIndex
) > 0)
448 case SPELL_AURA_MOD_HEALING_PCT
:
449 if(spellproto
->CalculateSimpleValue(effIndex
) < 0)
452 case SPELL_AURA_MOD_SKILL
:
453 if(spellproto
->CalculateSimpleValue(effIndex
) < 0)
456 case SPELL_AURA_FORCE_REACTION
:
457 if(spellproto
->Id
==42792) // Recently Dropped Flag (prevent cancel)
469 // non-positive targets
470 if(!IsPositiveTarget(spellproto
->EffectImplicitTargetA
[effIndex
],spellproto
->EffectImplicitTargetB
[effIndex
]))
473 // AttributesEx check
474 if(spellproto
->AttributesEx
& SPELL_ATTR_EX_NEGATIVE
)
481 bool IsPositiveSpell(uint32 spellId
)
483 SpellEntry
const *spellproto
= sSpellStore
.LookupEntry(spellId
);
484 if (!spellproto
) return false;
486 // spells with atleast one negative effect are considered negative
487 // some self-applied spells have negative effects but in self casting case negative check ignored.
488 for (int i
= 0; i
< 3; i
++)
489 if (!IsPositiveEffect(spellId
, i
))
494 bool IsSingleTargetSpell(SpellEntry
const *spellInfo
)
496 // all other single target spells have if it has AttributesEx5
497 if ( spellInfo
->AttributesEx5
& SPELL_ATTR_EX5_SINGLE_TARGET_SPELL
)
500 // TODO - need found Judgements rule
501 switch(GetSpellSpecific(spellInfo
->Id
))
503 case SPELL_JUDGEMENT
:
507 // single target triggered spell.
508 // Not real client side single target spell, but it' not triggered until prev. aura expired.
509 // This is allow store it in single target spells list for caster for spell proc checking
510 if(spellInfo
->Id
==38324) // Regeneration (triggered by 38299 (HoTs on Heals))
516 bool IsSingleTargetSpells(SpellEntry
const *spellInfo1
, SpellEntry
const *spellInfo2
)
518 // TODO - need better check
519 // Equal icon and spellfamily
520 if( spellInfo1
->SpellFamilyName
== spellInfo2
->SpellFamilyName
&&
521 spellInfo1
->SpellIconID
== spellInfo2
->SpellIconID
)
524 // TODO - need found Judgements rule
525 SpellSpecific spec1
= GetSpellSpecific(spellInfo1
->Id
);
526 // spell with single target specific types
529 case SPELL_JUDGEMENT
:
530 case SPELL_MAGE_POLYMORPH
:
531 if(GetSpellSpecific(spellInfo2
->Id
) == spec1
)
539 bool IsAuraAddedBySpell(uint32 auraType
, uint32 spellId
)
541 SpellEntry
const *spellproto
= sSpellStore
.LookupEntry(spellId
);
542 if (!spellproto
) return false;
544 for (int i
= 0; i
< 3; i
++)
545 if (spellproto
->EffectApplyAuraName
[i
] == auraType
)
550 SpellCastResult
GetErrorAtShapeshiftedCast (SpellEntry
const *spellInfo
, uint32 form
)
552 // talents that learn spells can have stance requirements that need ignore
553 // (this requirement only for client-side stance show in talent description)
554 if( GetTalentSpellCost(spellInfo
->Id
) > 0 &&
555 (spellInfo
->Effect
[0]==SPELL_EFFECT_LEARN_SPELL
|| spellInfo
->Effect
[1]==SPELL_EFFECT_LEARN_SPELL
|| spellInfo
->Effect
[2]==SPELL_EFFECT_LEARN_SPELL
) )
556 return SPELL_CAST_OK
;
558 uint32 stanceMask
= (form
? 1 << (form
- 1) : 0);
560 if (stanceMask
& spellInfo
->StancesNot
) // can explicitly not be casted in this stance
561 return SPELL_FAILED_NOT_SHAPESHIFT
;
563 if (stanceMask
& spellInfo
->Stances
) // can explicitly be casted in this stance
564 return SPELL_CAST_OK
;
566 bool actAsShifted
= false;
569 SpellShapeshiftEntry
const *shapeInfo
= sSpellShapeshiftStore
.LookupEntry(form
);
572 sLog
.outError("GetErrorAtShapeshiftedCast: unknown shapeshift %u", form
);
573 return SPELL_CAST_OK
;
575 actAsShifted
= !(shapeInfo
->flags1
& 1); // shapeshift acts as normal form for spells
580 if (spellInfo
->Attributes
& SPELL_ATTR_NOT_SHAPESHIFT
) // not while shapeshifted
581 return SPELL_FAILED_NOT_SHAPESHIFT
;
582 else if (spellInfo
->Stances
!= 0) // needs other shapeshift
583 return SPELL_FAILED_ONLY_SHAPESHIFT
;
588 if(!(spellInfo
->AttributesEx2
& SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT
) && spellInfo
->Stances
!= 0)
589 return SPELL_FAILED_ONLY_SHAPESHIFT
;
592 return SPELL_CAST_OK
;
595 void SpellMgr::LoadSpellTargetPositions()
597 mSpellTargetPositions
.clear(); // need for reload case
602 QueryResult
*result
= WorldDatabase
.Query("SELECT id, target_map, target_position_x, target_position_y, target_position_z, target_orientation FROM spell_target_position");
611 sLog
.outString( ">> Loaded %u spell target coordinates", count
);
615 barGoLink
bar( result
->GetRowCount() );
619 Field
*fields
= result
->Fetch();
625 uint32 Spell_ID
= fields
[0].GetUInt32();
627 SpellTargetPosition st
;
629 st
.target_mapId
= fields
[1].GetUInt32();
630 st
.target_X
= fields
[2].GetFloat();
631 st
.target_Y
= fields
[3].GetFloat();
632 st
.target_Z
= fields
[4].GetFloat();
633 st
.target_Orientation
= fields
[5].GetFloat();
635 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(Spell_ID
);
638 sLog
.outErrorDb("Spell (ID:%u) listed in `spell_target_position` does not exist.",Spell_ID
);
643 for(int i
= 0; i
< 3; ++i
)
645 if( spellInfo
->EffectImplicitTargetA
[i
]==TARGET_TABLE_X_Y_Z_COORDINATES
|| spellInfo
->EffectImplicitTargetB
[i
]==TARGET_TABLE_X_Y_Z_COORDINATES
)
653 sLog
.outErrorDb("Spell (Id: %u) listed in `spell_target_position` does not have target TARGET_TABLE_X_Y_Z_COORDINATES (17).",Spell_ID
);
657 MapEntry
const* mapEntry
= sMapStore
.LookupEntry(st
.target_mapId
);
660 sLog
.outErrorDb("Spell (ID:%u) target map (ID: %u) does not exist in `Map.dbc`.",Spell_ID
,st
.target_mapId
);
664 if(st
.target_X
==0 && st
.target_Y
==0 && st
.target_Z
==0)
666 sLog
.outErrorDb("Spell (ID:%u) target coordinates not provided.",Spell_ID
);
670 mSpellTargetPositions
[Spell_ID
] = st
;
672 } while( result
->NextRow() );
677 sLog
.outString( ">> Loaded %u spell teleport coordinates", count
);
680 void SpellMgr::LoadSpellAffects()
682 mSpellAffectMap
.clear(); // need for reload case
687 QueryResult
*result
= WorldDatabase
.Query("SELECT entry, effectId, SpellClassMask0, SpellClassMask1, SpellClassMask2 FROM spell_affect");
696 sLog
.outString( ">> Loaded %u spell affect definitions", count
);
700 barGoLink
bar( result
->GetRowCount() );
704 Field
*fields
= result
->Fetch();
708 uint16 entry
= fields
[0].GetUInt16();
709 uint8 effectId
= fields
[1].GetUInt8();
711 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(entry
);
715 sLog
.outErrorDb("Spell %u listed in `spell_affect` does not exist", entry
);
721 sLog
.outErrorDb("Spell %u listed in `spell_affect` have invalid effect index (%u)", entry
,effectId
);
725 if( spellInfo
->Effect
[effectId
] != SPELL_EFFECT_APPLY_AURA
||
726 spellInfo
->EffectApplyAuraName
[effectId
] != SPELL_AURA_ADD_FLAT_MODIFIER
&&
727 spellInfo
->EffectApplyAuraName
[effectId
] != SPELL_AURA_ADD_PCT_MODIFIER
&&
728 spellInfo
->EffectApplyAuraName
[effectId
] != SPELL_AURA_ADD_TARGET_TRIGGER
)
730 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
);
734 SpellAffectEntry affect
;
735 affect
.SpellClassMask
[0] = fields
[2].GetUInt32();
736 affect
.SpellClassMask
[1] = fields
[3].GetUInt32();
737 affect
.SpellClassMask
[2] = fields
[4].GetUInt32();
739 // Spell.dbc have own data
740 uint32
const *ptr
= 0;
743 case 0: ptr
= &spellInfo
->EffectSpellClassMaskA
[0]; break;
744 case 1: ptr
= &spellInfo
->EffectSpellClassMaskB
[0]; break;
745 case 2: ptr
= &spellInfo
->EffectSpellClassMaskC
[0]; break;
749 if(ptr
[0] == affect
.SpellClassMask
[0] || ptr
[1] == affect
.SpellClassMask
[1] || ptr
[2] == affect
.SpellClassMask
[2])
752 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
);
756 mSpellAffectMap
[(entry
<<8) + effectId
] = affect
;
759 } while( result
->NextRow() );
764 sLog
.outString( ">> Loaded %u custom spell affect definitions", count
);
766 for (uint32 id
= 0; id
< sSpellStore
.GetNumRows(); ++id
)
768 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(id
);
772 for (int effectId
= 0; effectId
< 3; ++effectId
)
774 if( spellInfo
->Effect
[effectId
] != SPELL_EFFECT_APPLY_AURA
||
775 (spellInfo
->EffectApplyAuraName
[effectId
] != SPELL_AURA_ADD_FLAT_MODIFIER
&&
776 spellInfo
->EffectApplyAuraName
[effectId
] != SPELL_AURA_ADD_PCT_MODIFIER
&&
777 spellInfo
->EffectApplyAuraName
[effectId
] != SPELL_AURA_ADD_TARGET_TRIGGER
) )
780 uint32
const *ptr
= 0;
783 case 0: ptr
= &spellInfo
->EffectSpellClassMaskA
[0]; break;
784 case 1: ptr
= &spellInfo
->EffectSpellClassMaskB
[0]; break;
785 case 2: ptr
= &spellInfo
->EffectSpellClassMaskC
[0]; break;
789 if(ptr
[0] || ptr
[1] || ptr
[2])
792 if(mSpellAffectMap
.find((id
<<8) + effectId
) != mSpellAffectMap
.end())
795 sLog
.outErrorDb("Spell %u (%s) misses spell_affect for effect %u",id
,spellInfo
->SpellName
[sWorld
.GetDefaultDbcLocale()], effectId
);
800 bool SpellMgr::IsAffectedByMod(SpellEntry
const *spellInfo
, SpellModifier
*mod
) const
802 // false for spellInfo == NULL
803 if (!spellInfo
|| !mod
)
806 SpellEntry
const *affect_spell
= sSpellStore
.LookupEntry(mod
->spellId
);
807 // False if affect_spell == NULL or spellFamily not equal
808 if (!affect_spell
|| affect_spell
->SpellFamilyName
!= spellInfo
->SpellFamilyName
)
812 if (mod
->mask
& spellInfo
->SpellFamilyFlags
||
813 mod
->mask2
& spellInfo
->SpellFamilyFlags2
)
819 void SpellMgr::LoadSpellProcEvents()
821 mSpellProcEventMap
.clear(); // need for reload case
825 // 0 1 2 3 4 5 6 7 8 9 10
826 QueryResult
*result
= WorldDatabase
.Query("SELECT entry, SchoolMask, SpellFamilyName, SpellFamilyMask0, SpellFamilyMask1, SpellFamilyMask2, procFlags, procEx, ppmRate, CustomChance, Cooldown FROM spell_proc_event");
832 sLog
.outString( ">> Loaded %u spell proc event conditions", count
);
836 barGoLink
bar( result
->GetRowCount() );
837 uint32 customProc
= 0;
840 Field
*fields
= result
->Fetch();
844 uint32 entry
= fields
[0].GetUInt32();
846 const SpellEntry
*spell
= sSpellStore
.LookupEntry(entry
);
849 sLog
.outErrorDb("Spell %u listed in `spell_proc_event` does not exist", entry
);
853 SpellProcEventEntry spe
;
855 spe
.schoolMask
= fields
[1].GetUInt32();
856 spe
.spellFamilyName
= fields
[2].GetUInt32();
857 spe
.spellFamilyMask
= (uint64
)fields
[3].GetUInt32()|((uint64
)fields
[4].GetUInt32()<<32);
858 spe
.spellFamilyMask2
= fields
[5].GetUInt32();
859 spe
.procFlags
= fields
[6].GetUInt32();
860 spe
.procEx
= fields
[7].GetUInt32();
861 spe
.ppmRate
= fields
[8].GetFloat();
862 spe
.customChance
= fields
[9].GetFloat();
863 spe
.cooldown
= fields
[10].GetUInt32();
865 mSpellProcEventMap
[entry
] = spe
;
867 if (spell
->procFlags
==0)
869 if (spe
.procFlags
== 0)
871 sLog
.outErrorDb("Spell %u listed in `spell_proc_event` probally not triggered spell", entry
);
877 } while( result
->NextRow() );
883 sLog
.outString( ">> Loaded %u extra spell proc event conditions +%u custom", count
, customProc
);
885 sLog
.outString( ">> Loaded %u extra spell proc event conditions", count
);
888 void SpellMgr::LoadSpellBonusess()
890 mSpellBonusMap
.clear(); // need for reload case
893 QueryResult
*result
= WorldDatabase
.Query("SELECT entry, direct_bonus, dot_bonus, ap_bonus FROM spell_bonus_data");
899 sLog
.outString( ">> Loaded %u spell bonus data", count
);
903 barGoLink
bar( result
->GetRowCount() );
906 Field
*fields
= result
->Fetch();
908 uint32 entry
= fields
[0].GetUInt32();
910 const SpellEntry
*spell
= sSpellStore
.LookupEntry(entry
);
913 sLog
.outErrorDb("Spell %u listed in `spell_bonus_data` does not exist", entry
);
919 sbe
.direct_damage
= fields
[1].GetFloat();
920 sbe
.dot_damage
= fields
[2].GetFloat();
921 sbe
.ap_bonus
= fields
[3].GetFloat();
923 mSpellBonusMap
[entry
] = sbe
;
924 } while( result
->NextRow() );
929 sLog
.outString( ">> Loaded %u extra spell bonus data", count
);
932 bool SpellMgr::IsSpellProcEventCanTriggeredBy(SpellProcEventEntry
const * spellProcEvent
, uint32 EventProcFlag
, SpellEntry
const * procSpell
, uint32 procFlags
, uint32 procExtra
, bool active
)
935 uint32 procEvent_procEx
= PROC_EX_NONE
;
937 // check prockFlags for condition
938 if((procFlags
& EventProcFlag
) == 0)
941 // Always trigger for this
942 if (EventProcFlag
& (PROC_FLAG_KILLED
| PROC_FLAG_KILL
| PROC_FLAG_ON_TRAP_ACTIVATION
))
945 if (spellProcEvent
) // Exist event data
948 procEvent_procEx
= spellProcEvent
->procEx
;
950 // For melee triggers
951 if (procSpell
== NULL
)
953 // Check (if set) for school (melee attack have Normal school)
954 if(spellProcEvent
->schoolMask
&& (spellProcEvent
->schoolMask
& SPELL_SCHOOL_MASK_NORMAL
) == 0)
957 else // For spells need check school/spell family/family mask
959 // Check (if set) for school
960 if(spellProcEvent
->schoolMask
&& (spellProcEvent
->schoolMask
& procSpell
->SchoolMask
) == 0)
963 // Check (if set) for spellFamilyName
964 if(spellProcEvent
->spellFamilyName
&& (spellProcEvent
->spellFamilyName
!= procSpell
->SpellFamilyName
))
967 // spellFamilyName is Ok need check for spellFamilyMask if present
968 if(spellProcEvent
->spellFamilyMask
|| spellProcEvent
->spellFamilyMask2
)
970 if ((spellProcEvent
->spellFamilyMask
& procSpell
->SpellFamilyFlags
) == 0 &&
971 (spellProcEvent
->spellFamilyMask2
& procSpell
->SpellFamilyFlags2
) == 0)
973 active
= true; // Spell added manualy -> so its active spell
977 // Check for extra req (if none) and hit/crit
978 if (procEvent_procEx
== PROC_EX_NONE
)
980 // No extra req, so can trigger only for active (damage/healing present) and hit/crit
981 if((procExtra
& (PROC_EX_NORMAL_HIT
|PROC_EX_CRITICAL_HIT
)) && active
)
984 else // Passive spells hits here only if resist/reflect/immune/evade
986 // Exist req for PROC_EX_EX_TRIGGER_ALWAYS
987 if (procEvent_procEx
& PROC_EX_EX_TRIGGER_ALWAYS
)
989 // Passive spells can`t trigger if need hit
990 if ((procEvent_procEx
& PROC_EX_NORMAL_HIT
) && !active
)
992 // Check Extra Requirement like (hit/crit/miss/resist/parry/dodge/block/immune/reflect/absorb and other)
993 if (procEvent_procEx
& procExtra
)
999 void SpellMgr::LoadSpellElixirs()
1001 mSpellElixirs
.clear(); // need for reload case
1006 QueryResult
*result
= WorldDatabase
.Query("SELECT entry, mask FROM spell_elixir");
1015 sLog
.outString( ">> Loaded %u spell elixir definitions", count
);
1019 barGoLink
bar( result
->GetRowCount() );
1023 Field
*fields
= result
->Fetch();
1027 uint16 entry
= fields
[0].GetUInt16();
1028 uint8 mask
= fields
[1].GetUInt8();
1030 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(entry
);
1034 sLog
.outErrorDb("Spell %u listed in `spell_elixir` does not exist", entry
);
1038 mSpellElixirs
[entry
] = mask
;
1041 } while( result
->NextRow() );
1046 sLog
.outString( ">> Loaded %u spell elixir definitions", count
);
1049 void SpellMgr::LoadSpellThreats()
1051 sSpellThreatStore
.Free(); // for reload
1053 sSpellThreatStore
.Load();
1055 sLog
.outString( ">> Loaded %u aggro generating spells", sSpellThreatStore
.RecordCount
);
1059 bool SpellMgr::IsRankSpellDueToSpell(SpellEntry
const *spellInfo_1
,uint32 spellId_2
) const
1061 SpellEntry
const *spellInfo_2
= sSpellStore
.LookupEntry(spellId_2
);
1062 if(!spellInfo_1
|| !spellInfo_2
) return false;
1063 if(spellInfo_1
->Id
== spellId_2
) return false;
1065 return GetFirstSpellInChain(spellInfo_1
->Id
)==GetFirstSpellInChain(spellId_2
);
1068 bool SpellMgr::canStackSpellRanks(SpellEntry
const *spellInfo
)
1070 if(IsPassiveSpell(spellInfo
->Id
)) // ranked passive spell
1072 if(spellInfo
->powerType
!= POWER_MANA
&& spellInfo
->powerType
!= POWER_HEALTH
)
1074 if(IsProfessionOrRidingSpell(spellInfo
->Id
))
1077 if(spellmgr
.IsSkillBonusSpell(spellInfo
->Id
))
1080 // All stance spells. if any better way, change it.
1081 for (int i
= 0; i
< 3; i
++)
1083 switch(spellInfo
->SpellFamilyName
)
1085 case SPELLFAMILY_PALADIN
:
1086 // Paladin aura Spell
1087 if (spellInfo
->Effect
[i
]==SPELL_EFFECT_APPLY_AREA_AURA_RAID
)
1090 case SPELLFAMILY_DRUID
:
1092 if (spellInfo
->Effect
[i
]==SPELL_EFFECT_APPLY_AURA
&&
1093 spellInfo
->EffectApplyAuraName
[i
] == SPELL_AURA_MOD_SHAPESHIFT
)
1096 case SPELLFAMILY_ROGUE
:
1098 if (spellInfo
->Effect
[i
]==SPELL_EFFECT_APPLY_AURA
&&
1099 spellInfo
->EffectApplyAuraName
[i
] == SPELL_AURA_MOD_SHAPESHIFT
)
1106 bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1
, uint32 spellId_2
) const
1108 SpellEntry
const *spellInfo_1
= sSpellStore
.LookupEntry(spellId_1
);
1109 SpellEntry
const *spellInfo_2
= sSpellStore
.LookupEntry(spellId_2
);
1111 if(!spellInfo_1
|| !spellInfo_2
)
1114 if(spellInfo_1
->Id
== spellId_2
)
1117 //I think we don't check this correctly because i need a exception for spell:
1118 //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.
1119 if(spellInfo_2
->SpellFamilyFlags
== 2048)
1122 // Resurrection sickness
1123 if((spellInfo_1
->Id
== SPELL_ID_PASSIVE_RESURRECTION_SICKNESS
) != (spellInfo_2
->Id
==SPELL_ID_PASSIVE_RESURRECTION_SICKNESS
))
1126 // Allow stack passive and not passive spells
1127 if ((spellInfo_1
->Attributes
& SPELL_ATTR_PASSIVE
)!=(spellInfo_2
->Attributes
& SPELL_ATTR_PASSIVE
))
1130 // Specific spell family spells
1131 switch(spellInfo_1
->SpellFamilyName
)
1133 case SPELLFAMILY_GENERIC
:
1134 switch(spellInfo_2
->SpellFamilyName
)
1136 case SPELLFAMILY_GENERIC
: // same family case
1139 if( spellInfo_1
->Id
== 21992 && spellInfo_2
->Id
== 27648 || spellInfo_2
->Id
== 21992 && spellInfo_1
->Id
== 27648 )
1142 // Lightning Speed (Mongoose) and Fury of the Crashing Waves (Tsunami Talisman)
1143 if( spellInfo_1
->Id
== 28093 && spellInfo_2
->Id
== 42084 ||
1144 spellInfo_2
->Id
== 28093 && spellInfo_1
->Id
== 42084 )
1147 // Soulstone Resurrection and Twisting Nether (resurrector)
1148 if( spellInfo_1
->SpellIconID
== 92 && spellInfo_2
->SpellIconID
== 92 && (
1149 spellInfo_1
->SpellVisual
[0] == 99 && spellInfo_2
->SpellVisual
[0] == 0 ||
1150 spellInfo_2
->SpellVisual
[0] == 99 && spellInfo_1
->SpellVisual
[0] == 0 ) )
1153 // Heart of the Wild and (Primal Instinct (Idol of Terror) triggering spell or Agility)
1154 if( spellInfo_1
->SpellIconID
== 240 && spellInfo_2
->SpellIconID
== 240 && (
1155 spellInfo_1
->SpellVisual
[0] == 0 && spellInfo_2
->SpellVisual
[0] == 78 ||
1156 spellInfo_2
->SpellVisual
[0] == 0 && spellInfo_1
->SpellVisual
[0] == 78 ) )
1159 // Personalized Weather (thunder effect should overwrite rainy aura)
1160 if(spellInfo_1
->SpellIconID
== 2606 && spellInfo_2
->SpellIconID
== 2606)
1163 // Brood Affliction: Bronze
1164 if( (spellInfo_1
->Id
== 23170 && spellInfo_2
->Id
== 23171) ||
1165 (spellInfo_2
->Id
== 23170 && spellInfo_1
->Id
== 23171) )
1168 // See Chapel Invisibility and See Noth Invisibility
1169 if( (spellInfo_1
->Id
== 52950 && spellInfo_2
->Id
== 52707) ||
1170 (spellInfo_2
->Id
== 52950 && spellInfo_1
->Id
== 52707) )
1175 case SPELLFAMILY_WARRIOR
:
1177 // Scroll of Protection and Defensive Stance (multi-family check)
1178 if( spellInfo_1
->SpellIconID
== 276 && spellInfo_1
->SpellVisual
[0] == 196 && spellInfo_2
->Id
== 71)
1181 // Improved Hamstring -> Hamstring (multi-family check)
1182 if( (spellInfo_2
->SpellFamilyFlags
& 2) && spellInfo_1
->Id
== 23694 )
1187 case SPELLFAMILY_DRUID
:
1189 // Scroll of Stamina and Leader of the Pack (multi-family check)
1190 if( spellInfo_1
->SpellIconID
== 312 && spellInfo_1
->SpellVisual
[0] == 216 && spellInfo_2
->Id
== 24932 )
1193 // Dragonmaw Illusion (multi-family check)
1194 if (spellId_1
== 40216 && spellId_2
== 42016 )
1199 case SPELLFAMILY_ROGUE
:
1201 // Garrote-Silence -> Garrote (multi-family check)
1202 if( spellInfo_1
->SpellIconID
== 498 && spellInfo_1
->SpellVisual
[0] == 0 && spellInfo_2
->SpellIconID
== 498 )
1207 case SPELLFAMILY_HUNTER
:
1209 // Concussive Shot and Imp. Concussive Shot (multi-family check)
1210 if( spellInfo_1
->Id
== 19410 && spellInfo_2
->Id
== 5116 )
1213 // Improved Wing Clip -> Wing Clip (multi-family check)
1214 if( (spellInfo_2
->SpellFamilyFlags
& 0x40) && spellInfo_1
->Id
== 19229 )
1218 case SPELLFAMILY_PALADIN
:
1220 // Unstable Currents and other -> *Sanctity Aura (multi-family check)
1221 if( spellInfo_2
->SpellIconID
==502 && spellInfo_1
->SpellIconID
==502 && spellInfo_1
->SpellVisual
[0]==969 )
1224 // *Band of Eternal Champion and Seal of Command(multi-family check)
1225 if( spellId_1
== 35081 && spellInfo_2
->SpellIconID
==561 && spellInfo_2
->SpellVisual
[0]==7992)
1231 // Dragonmaw Illusion, Blood Elf Illusion, Human Illusion, Illidari Agent Illusion, Scarlet Crusade Disguise
1232 if(spellInfo_1
->SpellIconID
== 1691 && spellInfo_2
->SpellIconID
== 1691)
1235 case SPELLFAMILY_MAGE
:
1236 if( spellInfo_2
->SpellFamilyName
== SPELLFAMILY_MAGE
)
1238 // Blizzard & Chilled (and some other stacked with blizzard spells
1239 if( (spellInfo_1
->SpellFamilyFlags
& 0x80) && (spellInfo_2
->SpellFamilyFlags
& 0x100000) ||
1240 (spellInfo_2
->SpellFamilyFlags
& 0x80) && (spellInfo_1
->SpellFamilyFlags
& 0x100000) )
1243 // Blink & Improved Blink
1244 if( (spellInfo_1
->SpellFamilyFlags
& 0x0000000000010000LL
) && (spellInfo_2
->SpellVisual
[0] == 72 && spellInfo_2
->SpellIconID
== 1499) ||
1245 (spellInfo_2
->SpellFamilyFlags
& 0x0000000000010000LL
) && (spellInfo_1
->SpellVisual
[0] == 72 && spellInfo_1
->SpellIconID
== 1499) )
1248 // Detect Invisibility and Mana Shield (multi-family check)
1249 if( spellInfo_2
->Id
== 132 && spellInfo_1
->SpellIconID
== 209 && spellInfo_1
->SpellVisual
[0] == 968 )
1252 // Combustion and Fire Protection Aura (multi-family check)
1253 if( spellInfo_1
->Id
== 11129 && spellInfo_2
->SpellIconID
== 33 && spellInfo_2
->SpellVisual
[0] == 321 )
1257 case SPELLFAMILY_WARLOCK
:
1258 if( spellInfo_2
->SpellFamilyName
== SPELLFAMILY_WARLOCK
)
1260 // Siphon Life and Drain Life
1261 if( spellInfo_1
->SpellIconID
== 152 && spellInfo_2
->SpellIconID
== 546 ||
1262 spellInfo_2
->SpellIconID
== 152 && spellInfo_1
->SpellIconID
== 546 )
1265 //Corruption & Seed of corruption
1266 if( spellInfo_1
->SpellIconID
== 313 && spellInfo_2
->SpellIconID
== 1932 ||
1267 spellInfo_2
->SpellIconID
== 313 && spellInfo_1
->SpellIconID
== 1932 )
1268 if(spellInfo_1
->SpellVisual
[0] != 0 && spellInfo_2
->SpellVisual
[0] != 0)
1269 return true; // can't be stacked
1271 // Corruption and Unstable Affliction
1272 if( spellInfo_1
->SpellIconID
== 313 && spellInfo_2
->SpellIconID
== 2039 ||
1273 spellInfo_2
->SpellIconID
== 313 && spellInfo_1
->SpellIconID
== 2039 )
1276 // (Corruption or Unstable Affliction) and (Curse of Agony or Curse of Doom)
1277 if( (spellInfo_1
->SpellIconID
== 313 || spellInfo_1
->SpellIconID
== 2039) && (spellInfo_2
->SpellIconID
== 544 || spellInfo_2
->SpellIconID
== 91) ||
1278 (spellInfo_2
->SpellIconID
== 313 || spellInfo_2
->SpellIconID
== 2039) && (spellInfo_1
->SpellIconID
== 544 || spellInfo_1
->SpellIconID
== 91) )
1281 // Detect Invisibility and Mana Shield (multi-family check)
1282 if( spellInfo_1
->Id
== 132 && spellInfo_2
->SpellIconID
== 209 && spellInfo_2
->SpellVisual
[0] == 968 )
1285 case SPELLFAMILY_WARRIOR
:
1286 if( spellInfo_2
->SpellFamilyName
== SPELLFAMILY_WARRIOR
)
1288 // Rend and Deep Wound
1289 if( (spellInfo_1
->SpellFamilyFlags
& 0x20) && (spellInfo_2
->SpellFamilyFlags
& 0x1000000000LL
) ||
1290 (spellInfo_2
->SpellFamilyFlags
& 0x20) && (spellInfo_1
->SpellFamilyFlags
& 0x1000000000LL
) )
1293 // Battle Shout and Rampage
1294 if( (spellInfo_1
->SpellIconID
== 456 && spellInfo_2
->SpellIconID
== 2006) ||
1295 (spellInfo_2
->SpellIconID
== 456 && spellInfo_1
->SpellIconID
== 2006) )
1299 // Hamstring -> Improved Hamstring (multi-family check)
1300 if( (spellInfo_1
->SpellFamilyFlags
& 2) && spellInfo_2
->Id
== 23694 )
1303 // Defensive Stance and Scroll of Protection (multi-family check)
1304 if( spellInfo_1
->Id
== 71 && spellInfo_2
->SpellIconID
== 276 && spellInfo_2
->SpellVisual
[0] == 196 )
1307 // Bloodlust and Bloodthirst (multi-family check)
1308 if( spellInfo_2
->Id
== 2825 && spellInfo_1
->SpellIconID
== 38 && spellInfo_1
->SpellVisual
[0] == 0 )
1312 case SPELLFAMILY_PRIEST
:
1313 if( spellInfo_2
->SpellFamilyName
== SPELLFAMILY_PRIEST
)
1315 //Devouring Plague and Shadow Vulnerability
1316 if( (spellInfo_1
->SpellFamilyFlags
& 0x2000000) && (spellInfo_2
->SpellFamilyFlags
& 0x800000000LL
) ||
1317 (spellInfo_2
->SpellFamilyFlags
& 0x2000000) && (spellInfo_1
->SpellFamilyFlags
& 0x800000000LL
) )
1320 //StarShards and Shadow Word: Pain
1321 if( (spellInfo_1
->SpellFamilyFlags
& 0x200000) && (spellInfo_2
->SpellFamilyFlags
& 0x8000) ||
1322 (spellInfo_2
->SpellFamilyFlags
& 0x200000) && (spellInfo_1
->SpellFamilyFlags
& 0x8000) )
1325 if( (spellInfo_1
->Id
== 47585 && spellInfo_2
->Id
== 60069) ||
1326 (spellInfo_2
->Id
== 47585 && spellInfo_1
->Id
== 60069) )
1330 case SPELLFAMILY_DRUID
:
1331 if( spellInfo_2
->SpellFamilyName
== SPELLFAMILY_DRUID
)
1333 //Omen of Clarity and Blood Frenzy
1334 if( (spellInfo_1
->SpellFamilyFlags
== 0x0 && spellInfo_1
->SpellIconID
== 108) && (spellInfo_2
->SpellFamilyFlags
& 0x20000000000000LL
) ||
1335 (spellInfo_2
->SpellFamilyFlags
== 0x0 && spellInfo_2
->SpellIconID
== 108) && (spellInfo_1
->SpellFamilyFlags
& 0x20000000000000LL
) )
1338 // Tree of Life (Shapeshift) and 34123 Tree of Life (Passive)
1339 if ((spellId_1
== 33891 && spellId_2
== 34123) ||
1340 (spellId_2
== 33891 && spellId_1
== 34123))
1343 // Wrath of Elune and Nature's Grace
1344 if( spellInfo_1
->Id
== 16886 && spellInfo_2
->Id
== 46833 || spellInfo_2
->Id
== 16886 && spellInfo_1
->Id
== 46833 )
1347 // Bear Rage (Feral T4 (2)) and Omen of Clarity
1348 if( spellInfo_1
->Id
== 16864 && spellInfo_2
->Id
== 37306 || spellInfo_2
->Id
== 16864 && spellInfo_1
->Id
== 37306 )
1351 // Cat Energy (Feral T4 (2)) and Omen of Clarity
1352 if( spellInfo_1
->Id
== 16864 && spellInfo_2
->Id
== 37311 || spellInfo_2
->Id
== 16864 && spellInfo_1
->Id
== 37311 )
1355 // Survival Instincts and Survival Instincts
1356 if( spellInfo_1
->Id
== 61336 && spellInfo_2
->Id
== 50322 || spellInfo_2
->Id
== 61336 && spellInfo_1
->Id
== 50322 )
1360 // Leader of the Pack and Scroll of Stamina (multi-family check)
1361 if( spellInfo_1
->Id
== 24932 && spellInfo_2
->SpellIconID
== 312 && spellInfo_2
->SpellVisual
[0] == 216 )
1364 // Dragonmaw Illusion (multi-family check)
1365 if (spellId_1
== 42016 && spellId_2
== 40216 )
1369 case SPELLFAMILY_ROGUE
:
1370 if( spellInfo_2
->SpellFamilyName
== SPELLFAMILY_ROGUE
)
1372 // Master of Subtlety
1373 if (spellId_1
== 31665 && spellId_2
== 31666 || spellId_1
== 31666 && spellId_2
== 31665 )
1378 if( spellInfo_1
->SpellIconID
== 2285 && spellInfo_2
->SpellIconID
== 2285 )
1381 // Garrote -> Garrote-Silence (multi-family check)
1382 if( spellInfo_1
->SpellIconID
== 498 && spellInfo_2
->SpellIconID
== 498 && spellInfo_2
->SpellVisual
[0] == 0 )
1385 case SPELLFAMILY_HUNTER
:
1386 if( spellInfo_2
->SpellFamilyName
== SPELLFAMILY_HUNTER
)
1388 // Rapid Fire & Quick Shots
1389 if( (spellInfo_1
->SpellFamilyFlags
& 0x20) && (spellInfo_2
->SpellFamilyFlags
& 0x20000000000LL
) ||
1390 (spellInfo_2
->SpellFamilyFlags
& 0x20) && (spellInfo_1
->SpellFamilyFlags
& 0x20000000000LL
) )
1393 // Serpent Sting & (Immolation/Explosive Trap Effect)
1394 if( (spellInfo_1
->SpellFamilyFlags
& 0x4) && (spellInfo_2
->SpellFamilyFlags
& 0x00000004000LL
) ||
1395 (spellInfo_2
->SpellFamilyFlags
& 0x4) && (spellInfo_1
->SpellFamilyFlags
& 0x00000004000LL
) )
1399 if( spellInfo_1
->SpellIconID
== 1680 && spellInfo_2
->SpellIconID
== 1680 )
1403 // Wing Clip -> Improved Wing Clip (multi-family check)
1404 if( (spellInfo_1
->SpellFamilyFlags
& 0x40) && spellInfo_2
->Id
== 19229 )
1407 // Concussive Shot and Imp. Concussive Shot (multi-family check)
1408 if( spellInfo_2
->Id
== 19410 && spellInfo_1
->Id
== 5116 )
1411 case SPELLFAMILY_PALADIN
:
1412 if( spellInfo_2
->SpellFamilyName
== SPELLFAMILY_PALADIN
)
1415 if( IsSealSpell(spellInfo_1
) && IsSealSpell(spellInfo_2
) )
1418 // Combustion and Fire Protection Aura (multi-family check)
1419 if( spellInfo_2
->Id
== 11129 && spellInfo_1
->SpellIconID
== 33 && spellInfo_1
->SpellVisual
[0] == 321 )
1422 // *Sanctity Aura -> Unstable Currents and other (multi-family check)
1423 if( spellInfo_1
->SpellIconID
==502 && spellInfo_2
->SpellFamilyName
== SPELLFAMILY_GENERIC
&& spellInfo_2
->SpellIconID
==502 && spellInfo_2
->SpellVisual
[0]==969 )
1426 // *Seal of Command and Band of Eternal Champion (multi-family check)
1427 if( spellInfo_1
->SpellIconID
==561 && spellInfo_1
->SpellVisual
[0]==7992 && spellId_2
== 35081)
1430 case SPELLFAMILY_SHAMAN
:
1431 if( spellInfo_2
->SpellFamilyName
== SPELLFAMILY_SHAMAN
)
1434 if( IsElementalShield(spellInfo_1
) && IsElementalShield(spellInfo_2
) )
1438 if( spellInfo_1
->SpellIconID
==220 && spellInfo_2
->SpellIconID
==220 &&
1439 spellInfo_1
->SpellFamilyFlags
!= spellInfo_2
->SpellFamilyFlags
)
1442 // Bloodlust and Bloodthirst (multi-family check)
1443 if( spellInfo_1
->Id
== 2825 && spellInfo_2
->SpellIconID
== 38 && spellInfo_2
->SpellVisual
[0] == 0 )
1450 // more generic checks
1451 if (spellInfo_1
->SpellIconID
== spellInfo_2
->SpellIconID
&&
1452 spellInfo_1
->SpellIconID
!= 0 && spellInfo_2
->SpellIconID
!= 0)
1454 bool isModifier
= false;
1455 for (int i
= 0; i
< 3; i
++)
1457 if (spellInfo_1
->EffectApplyAuraName
[i
] == SPELL_AURA_ADD_FLAT_MODIFIER
||
1458 spellInfo_1
->EffectApplyAuraName
[i
] == SPELL_AURA_ADD_PCT_MODIFIER
||
1459 spellInfo_2
->EffectApplyAuraName
[i
] == SPELL_AURA_ADD_FLAT_MODIFIER
||
1460 spellInfo_2
->EffectApplyAuraName
[i
] == SPELL_AURA_ADD_PCT_MODIFIER
)
1468 if (IsRankSpellDueToSpell(spellInfo_1
, spellId_2
))
1471 if (spellInfo_1
->SpellFamilyName
== 0 || spellInfo_2
->SpellFamilyName
== 0)
1474 if (spellInfo_1
->SpellFamilyName
!= spellInfo_2
->SpellFamilyName
)
1477 for (int i
= 0; i
< 3; ++i
)
1478 if (spellInfo_1
->Effect
[i
] != spellInfo_2
->Effect
[i
] ||
1479 spellInfo_1
->EffectItemType
[i
] != spellInfo_2
->EffectItemType
[i
] ||
1480 spellInfo_1
->EffectMiscValue
[i
] != spellInfo_2
->EffectMiscValue
[i
] ||
1481 spellInfo_1
->EffectApplyAuraName
[i
] != spellInfo_2
->EffectApplyAuraName
[i
])
1487 bool SpellMgr::IsProfessionOrRidingSpell(uint32 spellId
)
1489 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(spellId
);
1493 if(spellInfo
->Effect
[1] != SPELL_EFFECT_SKILL
)
1496 uint32 skill
= spellInfo
->EffectMiscValue
[1];
1498 return IsProfessionOrRidingSkill(skill
);
1501 bool SpellMgr::IsProfessionSpell(uint32 spellId
)
1503 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(spellId
);
1507 if(spellInfo
->Effect
[1] != SPELL_EFFECT_SKILL
)
1510 uint32 skill
= spellInfo
->EffectMiscValue
[1];
1512 return IsProfessionSkill(skill
);
1515 bool SpellMgr::IsPrimaryProfessionSpell(uint32 spellId
)
1517 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(spellId
);
1521 if(spellInfo
->Effect
[1] != SPELL_EFFECT_SKILL
)
1524 uint32 skill
= spellInfo
->EffectMiscValue
[1];
1526 return IsPrimaryProfessionSkill(skill
);
1529 bool SpellMgr::IsPrimaryProfessionFirstRankSpell(uint32 spellId
) const
1531 return IsPrimaryProfessionSpell(spellId
) && GetSpellRank(spellId
)==1;
1534 bool SpellMgr::IsSkillBonusSpell(uint32 spellId
) const
1536 SkillLineAbilityMap::const_iterator lower
= GetBeginSkillLineAbilityMap(spellId
);
1537 SkillLineAbilityMap::const_iterator upper
= GetEndSkillLineAbilityMap(spellId
);
1539 for(SkillLineAbilityMap::const_iterator _spell_idx
= lower
; _spell_idx
!= upper
; ++_spell_idx
)
1541 SkillLineAbilityEntry
const *pAbility
= _spell_idx
->second
;
1542 if (!pAbility
|| pAbility
->learnOnGetSkill
!= ABILITY_LEARNED_ON_GET_PROFESSION_SKILL
)
1545 if(pAbility
->req_skill_value
> 0)
1552 SpellEntry
const* SpellMgr::SelectAuraRankForPlayerLevel(SpellEntry
const* spellInfo
, uint32 playerLevel
) const
1554 // ignore passive spells
1555 if(IsPassiveSpell(spellInfo
->Id
))
1558 bool needRankSelection
= false;
1559 for(int i
=0;i
<3;i
++)
1561 if( IsPositiveEffect(spellInfo
->Id
, i
) && (
1562 spellInfo
->Effect
[i
] == SPELL_EFFECT_APPLY_AURA
||
1563 spellInfo
->Effect
[i
] == SPELL_EFFECT_APPLY_AREA_AURA_PARTY
||
1564 spellInfo
->Effect
[i
] == SPELL_EFFECT_APPLY_AREA_AURA_RAID
1567 needRankSelection
= true;
1573 if(!needRankSelection
)
1576 for(uint32 nextSpellId
= spellInfo
->Id
; nextSpellId
!= 0; nextSpellId
= GetPrevSpellInChain(nextSpellId
))
1578 SpellEntry
const *nextSpellInfo
= sSpellStore
.LookupEntry(nextSpellId
);
1582 // if found appropriate level
1583 if(playerLevel
+ 10 >= nextSpellInfo
->spellLevel
)
1584 return nextSpellInfo
;
1586 // one rank less then
1593 void SpellMgr::LoadSpellChains()
1595 mSpellChains
.clear(); // need for reload case
1596 mSpellChainsNext
.clear(); // need for reload case
1598 QueryResult
*result
= WorldDatabase
.Query("SELECT spell_id, prev_spell, first_spell, rank, req_spell FROM spell_chain");
1605 sLog
.outString( ">> Loaded 0 spell chain records" );
1606 sLog
.outErrorDb("`spell_chains` table is empty!");
1612 barGoLink
bar( result
->GetRowCount() );
1616 Field
*fields
= result
->Fetch();
1618 uint32 spell_id
= fields
[0].GetUInt32();
1620 SpellChainNode node
;
1621 node
.prev
= fields
[1].GetUInt32();
1622 node
.first
= fields
[2].GetUInt32();
1623 node
.rank
= fields
[3].GetUInt8();
1624 node
.req
= fields
[4].GetUInt32();
1626 if(!sSpellStore
.LookupEntry(spell_id
))
1628 sLog
.outErrorDb("Spell %u listed in `spell_chain` does not exist",spell_id
);
1632 if(node
.prev
!=0 && !sSpellStore
.LookupEntry(node
.prev
))
1634 sLog
.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has not existed previous rank spell.",
1635 spell_id
,node
.prev
,node
.first
,node
.rank
,node
.req
);
1639 if(!sSpellStore
.LookupEntry(node
.first
))
1641 sLog
.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has not existing first rank spell.",
1642 spell_id
,node
.prev
,node
.first
,node
.rank
,node
.req
);
1646 // check basic spell chain data integrity (note: rank can be equal 0 or 1 for first/single spell)
1647 if( (spell_id
== node
.first
) != (node
.rank
<= 1) ||
1648 (spell_id
== node
.first
) != (node
.prev
== 0) ||
1649 (node
.rank
<= 1) != (node
.prev
== 0) )
1651 sLog
.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has not compatible chain data.",
1652 spell_id
,node
.prev
,node
.first
,node
.rank
,node
.req
);
1656 if(node
.req
!=0 && !sSpellStore
.LookupEntry(node
.req
))
1658 sLog
.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has not existing required spell.",
1659 spell_id
,node
.prev
,node
.first
,node
.rank
,node
.req
);
1663 // talents not required data in spell chain for work, but must be checked if present for intergrity
1664 if(TalentSpellPos
const* pos
= GetTalentSpellPos(spell_id
))
1666 if(node
.rank
!=pos
->rank
+1)
1668 sLog
.outErrorDb("Talent %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has wrong rank.",
1669 spell_id
,node
.prev
,node
.first
,node
.rank
,node
.req
);
1673 if(TalentEntry
const* talentEntry
= sTalentStore
.LookupEntry(pos
->talent_id
))
1675 if(node
.first
!=talentEntry
->RankID
[0])
1677 sLog
.outErrorDb("Talent %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has wrong first rank spell.",
1678 spell_id
,node
.prev
,node
.first
,node
.rank
,node
.req
);
1682 if(node
.rank
> 1 && node
.prev
!= talentEntry
->RankID
[node
.rank
-1-1])
1684 sLog
.outErrorDb("Talent %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has wrong prev rank spell.",
1685 spell_id
,node
.prev
,node
.first
,node
.rank
,node
.req
);
1689 /*if(node.req!=talentEntry->DependsOnSpell)
1691 sLog.outErrorDb("Talent %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has wrong required spell.",
1692 spell_id,node.prev,node.first,node.rank,node.req);
1698 mSpellChains
[spell_id
] = node
;
1701 mSpellChainsNext
.insert(SpellChainMapNext::value_type(node
.prev
,spell_id
));
1704 mSpellChainsNext
.insert(SpellChainMapNext::value_type(node
.req
,spell_id
));
1707 } while( result
->NextRow() );
1711 // additional integrity checks
1712 for(SpellChainMap::iterator i
= mSpellChains
.begin(); i
!= mSpellChains
.end(); ++i
)
1716 SpellChainMap::iterator i_prev
= mSpellChains
.find(i
->second
.prev
);
1717 if(i_prev
== mSpellChains
.end())
1719 sLog
.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has not found previous rank spell in table.",
1720 i
->first
,i
->second
.prev
,i
->second
.first
,i
->second
.rank
,i
->second
.req
);
1722 else if( i_prev
->second
.first
!= i
->second
.first
)
1724 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).",
1725 i
->first
,i
->second
.prev
,i
->second
.first
,i
->second
.rank
,i
->second
.req
,
1726 i_prev
->second
.prev
,i_prev
->second
.first
,i_prev
->second
.rank
,i_prev
->second
.req
);
1728 else if( i_prev
->second
.rank
+1 != i
->second
.rank
)
1730 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).",
1731 i
->first
,i
->second
.prev
,i
->second
.first
,i
->second
.rank
,i
->second
.req
,
1732 i_prev
->second
.prev
,i_prev
->second
.first
,i_prev
->second
.rank
,i_prev
->second
.req
);
1738 SpellChainMap::iterator i_req
= mSpellChains
.find(i
->second
.req
);
1739 if(i_req
== mSpellChains
.end())
1741 sLog
.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has not found required rank spell in table.",
1742 i
->first
,i
->second
.prev
,i
->second
.first
,i
->second
.rank
,i
->second
.req
);
1744 else if( i_req
->second
.first
== i
->second
.first
)
1746 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).",
1747 i
->first
,i
->second
.prev
,i
->second
.first
,i
->second
.rank
,i
->second
.req
,
1748 i_req
->second
.prev
,i_req
->second
.first
,i_req
->second
.rank
,i_req
->second
.req
);
1750 else if( i_req
->second
.req
)
1752 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).",
1753 i
->first
,i
->second
.prev
,i
->second
.first
,i
->second
.rank
,i
->second
.req
,
1754 i_req
->second
.prev
,i_req
->second
.first
,i_req
->second
.rank
,i_req
->second
.req
);
1760 sLog
.outString( ">> Loaded %u spell chain records", count
);
1763 void SpellMgr::LoadSpellLearnSkills()
1765 mSpellLearnSkills
.clear(); // need for reload case
1767 // search auto-learned skills and add its to map also for use in unlearn spells/talents
1768 uint32 dbc_count
= 0;
1769 barGoLink
bar( sSpellStore
.GetNumRows() );
1770 for(uint32 spell
= 0; spell
< sSpellStore
.GetNumRows(); ++spell
)
1773 SpellEntry
const* entry
= sSpellStore
.LookupEntry(spell
);
1778 for(int i
= 0; i
< 3; ++i
)
1780 if(entry
->Effect
[i
]==SPELL_EFFECT_SKILL
)
1782 SpellLearnSkillNode dbc_node
;
1783 dbc_node
.skill
= entry
->EffectMiscValue
[i
];
1784 if ( dbc_node
.skill
!= SKILL_RIDING
)
1787 dbc_node
.value
= entry
->CalculateSimpleValue(i
)*75;
1788 dbc_node
.maxvalue
= entry
->CalculateSimpleValue(i
)*75;
1790 mSpellLearnSkills
[spell
] = dbc_node
;
1798 sLog
.outString( ">> Loaded %u Spell Learn Skills from DBC", dbc_count
);
1801 void SpellMgr::LoadSpellLearnSpells()
1803 mSpellLearnSpells
.clear(); // need for reload case
1806 QueryResult
*result
= WorldDatabase
.Query("SELECT entry, SpellID, Active FROM spell_learn_spell");
1813 sLog
.outString( ">> Loaded 0 spell learn spells" );
1814 sLog
.outErrorDb("`spell_learn_spell` table is empty!");
1820 barGoLink
bar( result
->GetRowCount() );
1824 Field
*fields
= result
->Fetch();
1826 uint32 spell_id
= fields
[0].GetUInt32();
1828 SpellLearnSpellNode node
;
1829 node
.spell
= fields
[1].GetUInt32();
1830 node
.active
= fields
[2].GetBool();
1831 node
.autoLearned
= false;
1833 if(!sSpellStore
.LookupEntry(spell_id
))
1835 sLog
.outErrorDb("Spell %u listed in `spell_learn_spell` does not exist",spell_id
);
1839 if(!sSpellStore
.LookupEntry(node
.spell
))
1841 sLog
.outErrorDb("Spell %u listed in `spell_learn_spell` does not exist",node
.spell
);
1845 mSpellLearnSpells
.insert(SpellLearnSpellMap::value_type(spell_id
,node
));
1848 } while( result
->NextRow() );
1852 // search auto-learned spells and add its to map also for use in unlearn spells/talents
1853 uint32 dbc_count
= 0;
1854 for(uint32 spell
= 0; spell
< sSpellStore
.GetNumRows(); ++spell
)
1856 SpellEntry
const* entry
= sSpellStore
.LookupEntry(spell
);
1861 for(int i
= 0; i
< 3; ++i
)
1863 if(entry
->Effect
[i
]==SPELL_EFFECT_LEARN_SPELL
)
1865 SpellLearnSpellNode dbc_node
;
1866 dbc_node
.spell
= entry
->EffectTriggerSpell
[i
];
1867 dbc_node
.active
= true; // all dbc based learned spells is active (show in spell book or hide by client itself)
1869 // ignore learning not existed spells (broken/outdated/or generic learnig spell 483
1870 if(!sSpellStore
.LookupEntry(dbc_node
.spell
))
1873 // talent or passive spells or skill-step spells auto-casted and not need dependent learning,
1874 // pet teaching spells don't must be dependent learning (casted)
1875 // other required explicit dependent learning
1876 dbc_node
.autoLearned
= entry
->EffectImplicitTargetA
[i
]==TARGET_PET
|| GetTalentSpellCost(spell
) > 0 || IsPassiveSpell(spell
) || IsSpellHaveEffect(entry
,SPELL_EFFECT_SKILL_STEP
);
1878 SpellLearnSpellMap::const_iterator db_node_begin
= GetBeginSpellLearnSpell(spell
);
1879 SpellLearnSpellMap::const_iterator db_node_end
= GetEndSpellLearnSpell(spell
);
1882 for(SpellLearnSpellMap::const_iterator itr
= db_node_begin
; itr
!= db_node_end
; ++itr
)
1884 if(itr
->second
.spell
== dbc_node
.spell
)
1886 sLog
.outErrorDb("Spell %u auto-learn spell %u in spell.dbc then the record in `spell_learn_spell` is redundant, please fix DB.",
1887 spell
,dbc_node
.spell
);
1893 if(!found
) // add new spell-spell pair if not found
1895 mSpellLearnSpells
.insert(SpellLearnSpellMap::value_type(spell
,dbc_node
));
1903 sLog
.outString( ">> Loaded %u spell learn spells + %u found in DBC", count
, dbc_count
);
1906 void SpellMgr::LoadSpellScriptTarget()
1908 mSpellScriptTarget
.clear(); // need for reload case
1912 QueryResult
*result
= WorldDatabase
.Query("SELECT entry,type,targetEntry FROM spell_script_target");
1921 sLog
.outErrorDb(">> Loaded 0 SpellScriptTarget. DB table `spell_script_target` is empty.");
1925 barGoLink
bar(result
->GetRowCount());
1929 Field
*fields
= result
->Fetch();
1932 uint32 spellId
= fields
[0].GetUInt32();
1933 uint32 type
= fields
[1].GetUInt32();
1934 uint32 targetEntry
= fields
[2].GetUInt32();
1936 SpellEntry
const* spellProto
= sSpellStore
.LookupEntry(spellId
);
1940 sLog
.outErrorDb("Table `spell_script_target`: spellId %u listed for TargetEntry %u does not exist.",spellId
,targetEntry
);
1944 bool targetfound
= false;
1945 for(int i
= 0; i
<3; ++i
)
1947 if( spellProto
->EffectImplicitTargetA
[i
]==TARGET_SCRIPT
||
1948 spellProto
->EffectImplicitTargetB
[i
]==TARGET_SCRIPT
||
1949 spellProto
->EffectImplicitTargetA
[i
]==TARGET_SCRIPT_COORDINATES
||
1950 spellProto
->EffectImplicitTargetB
[i
]==TARGET_SCRIPT_COORDINATES
)
1958 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
);
1962 if( type
>= MAX_SPELL_TARGET_TYPE
)
1964 sLog
.outErrorDb("Table `spell_script_target`: target type %u for TargetEntry %u is incorrect.",type
,targetEntry
);
1970 case SPELL_TARGET_TYPE_GAMEOBJECT
:
1972 if( targetEntry
==0 )
1975 if(!sGOStorage
.LookupEntry
<GameObjectInfo
>(targetEntry
))
1977 sLog
.outErrorDb("Table `spell_script_target`: gameobject template entry %u does not exist.",targetEntry
);
1984 if( targetEntry
==0 )
1986 sLog
.outErrorDb("Table `spell_script_target`: target entry == 0 for not GO target type (%u).",type
);
1989 if(!sCreatureStorage
.LookupEntry
<CreatureInfo
>(targetEntry
))
1991 sLog
.outErrorDb("Table `spell_script_target`: creature template entry %u does not exist.",targetEntry
);
1994 const CreatureInfo
* cInfo
= sCreatureStorage
.LookupEntry
<CreatureInfo
>(targetEntry
);
1996 if(spellId
== 30427 && !cInfo
->SkinLootId
)
1998 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
);
2005 mSpellScriptTarget
.insert(SpellScriptTarget::value_type(spellId
,SpellTargetEntry(SpellTargetType(type
),targetEntry
)));
2008 } while (result
->NextRow());
2013 /* Disabled (lot errors at this moment)
2014 for(uint32 i = 1; i < sSpellStore.nCount; ++i)
2016 SpellEntry const * spellInfo = sSpellStore.LookupEntry(i);
2021 for(int j=0; j<3; ++j)
2023 if( spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT || spellInfo->EffectImplicitTargetA[j] != TARGET_SELF && spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT )
2025 SpellScriptTarget::const_iterator lower = spellmgr.GetBeginSpellScriptTarget(spellInfo->Id);
2026 SpellScriptTarget::const_iterator upper = spellmgr.GetEndSpellScriptTarget(spellInfo->Id);
2029 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);
2030 break; // effects of spell
2038 sLog
.outString(">> Loaded %u Spell Script Targets", count
);
2041 void SpellMgr::LoadSpellPetAuras()
2043 mSpellPetAuraMap
.clear(); // need for reload case
2048 QueryResult
*result
= WorldDatabase
.Query("SELECT spell, pet, aura FROM spell_pet_auras");
2057 sLog
.outString( ">> Loaded %u spell pet auras", count
);
2061 barGoLink
bar( result
->GetRowCount() );
2065 Field
*fields
= result
->Fetch();
2069 uint16 spell
= fields
[0].GetUInt16();
2070 uint16 pet
= fields
[1].GetUInt16();
2071 uint16 aura
= fields
[2].GetUInt16();
2073 SpellPetAuraMap::iterator itr
= mSpellPetAuraMap
.find(spell
);
2074 if(itr
!= mSpellPetAuraMap
.end())
2076 itr
->second
.AddAura(pet
, aura
);
2080 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spell
);
2083 sLog
.outErrorDb("Spell %u listed in `spell_pet_auras` does not exist", spell
);
2088 if((spellInfo
->Effect
[i
] == SPELL_EFFECT_APPLY_AURA
&&
2089 spellInfo
->EffectApplyAuraName
[i
] == SPELL_AURA_DUMMY
) ||
2090 spellInfo
->Effect
[i
] == SPELL_EFFECT_DUMMY
)
2095 sLog
.outError("Spell %u listed in `spell_pet_auras` does not have dummy aura or dummy effect", spell
);
2099 SpellEntry
const* spellInfo2
= sSpellStore
.LookupEntry(aura
);
2102 sLog
.outErrorDb("Aura %u listed in `spell_pet_auras` does not exist", aura
);
2106 PetAura
pa(pet
, aura
, spellInfo
->EffectImplicitTargetA
[i
] == TARGET_PET
, spellInfo
->CalculateSimpleValue(i
));
2107 mSpellPetAuraMap
[spell
] = pa
;
2111 } while( result
->NextRow() );
2116 sLog
.outString( ">> Loaded %u spell pet auras", count
);
2119 void SpellMgr::LoadPetLevelupSpellMap()
2121 CreatureFamilyEntry
const *creatureFamily
;
2122 SpellEntry
const *spell
;
2125 for (uint32 i
= 0; i
< sCreatureFamilyStore
.GetNumRows(); ++i
)
2127 creatureFamily
= sCreatureFamilyStore
.LookupEntry(i
);
2129 if(!creatureFamily
) // not exist
2132 if(creatureFamily
->petTalentType
< 0) // not hunter pet family
2135 for(uint32 j
= 0; j
< sSpellStore
.GetNumRows(); ++j
)
2137 spell
= sSpellStore
.LookupEntry(j
);
2144 if(spell
->SpellFamilyName
!= SPELLFAMILY_HUNTER
)
2148 if(!(spell
->SpellFamilyFlags
& 0x1000000000000000LL
))
2151 // not Growl or Cower (generics)
2152 if(spell
->SpellIconID
!= 201 && spell
->SpellIconID
!= 958)
2154 switch(creatureFamily
->ID
)
2156 case CREATURE_FAMILY_BAT
: // Bite and Sonic Blast
2157 if(spell
->SpellIconID
!= 1680 && spell
->SpellIconID
!= 1577)
2160 case CREATURE_FAMILY_BEAR
: // Claw and Swipe
2161 if(spell
->SpellIconID
!= 262 && spell
->SpellIconID
!= 1562)
2164 case CREATURE_FAMILY_BIRD_OF_PREY
: // Claw and Snatch
2165 if(spell
->SpellIconID
!= 262 && spell
->SpellIconID
!= 168)
2168 case CREATURE_FAMILY_BOAR
: // Bite and Gore
2169 if(spell
->SpellIconID
!= 1680 && spell
->SpellIconID
!= 1578)
2172 case CREATURE_FAMILY_CARRION_BIRD
: // Bite and Demoralizing Screech
2173 if(spell
->SpellIconID
!= 1680 && spell
->SpellIconID
!= 1579)
2176 case CREATURE_FAMILY_CAT
: // Claw and Prowl and Rake
2177 if(spell
->SpellIconID
!= 262 && spell
->SpellIconID
!= 495 && spell
->SpellIconID
!= 494)
2180 case CREATURE_FAMILY_CHIMAERA
: // Bite and Froststorm Breath
2181 if(spell
->SpellIconID
!= 1680 && spell
->SpellIconID
!= 62)
2184 case CREATURE_FAMILY_CORE_HOUND
: // Bite and Lava Breath
2185 if(spell
->SpellIconID
!= 1680 && spell
->SpellIconID
!= 1197)
2188 case CREATURE_FAMILY_CRAB
: // Claw and Pin
2189 if(spell
->SpellIconID
!= 262 && spell
->SpellIconID
!= 2679)
2192 case CREATURE_FAMILY_CROCOLISK
: // Bite and Bad Attitude
2193 if(spell
->SpellIconID
!= 1680 && spell
->SpellIconID
!= 1581)
2196 case CREATURE_FAMILY_DEVILSAUR
: // Bite and Monstrous Bite
2197 if(spell
->SpellIconID
!= 1680 && spell
->SpellIconID
!= 599)
2200 case CREATURE_FAMILY_DRAGONHAWK
: // Bite and Fire Breath
2201 if(spell
->SpellIconID
!= 1680 && spell
->SpellIconID
!= 2128)
2204 case CREATURE_FAMILY_GORILLA
: // Smack and Thunderstomp
2205 if(spell
->SpellIconID
!= 473 && spell
->SpellIconID
!= 148)
2208 case CREATURE_FAMILY_HYENA
: // Bite and Tendon Rip
2209 if(spell
->SpellIconID
!= 1680 && spell
->SpellIconID
!= 138)
2212 case CREATURE_FAMILY_MOTH
: // Serenity Dust and Smack
2213 if(spell
->SpellIconID
!= 1714 && spell
->SpellIconID
!= 473)
2216 case CREATURE_FAMILY_NETHER_RAY
: // Bite and Nether Shock
2217 if(spell
->SpellIconID
!= 1680 && spell
->SpellIconID
!= 2027)
2220 case CREATURE_FAMILY_RAPTOR
: // Claw and Savage Rend
2221 if(spell
->SpellIconID
!= 262 && spell
->SpellIconID
!= 245)
2224 case CREATURE_FAMILY_RAVAGER
: // Bite and Ravage
2225 if(spell
->SpellIconID
!= 1680 && spell
->SpellIconID
!= 2253)
2228 case CREATURE_FAMILY_RHINO
: // Smack and Stampede
2229 if(spell
->SpellIconID
!= 473 && spell
->SpellIconID
!= 3066)
2232 case CREATURE_FAMILY_SCORPID
: // Claw and Scorpid Poison
2233 if(spell
->SpellIconID
!= 262 && spell
->SpellIconID
!= 163)
2236 case CREATURE_FAMILY_SERPENT
: // Bite and Poison Spit
2237 if(spell
->SpellIconID
!= 1680 && spell
->SpellIconID
!= 68)
2240 case CREATURE_FAMILY_SILITHID
: // Claw and Venom Web Spray
2241 if(spell
->SpellIconID
!= 262 && (spell
->SpellIconID
!= 272 && spell
->SpellVisual
[0] != 12013))
2244 case CREATURE_FAMILY_SPIDER
: // Bite and Web
2245 if(spell
->SpellIconID
!= 1680 && (spell
->SpellIconID
!= 272 && spell
->SpellVisual
[0] != 684))
2248 case CREATURE_FAMILY_SPIRIT_BEAST
: // Claw and Prowl and Spirit Strike
2249 if(spell
->SpellIconID
!= 262 && spell
->SpellIconID
!= 495 && spell
->SpellIconID
!= 255)
2252 case CREATURE_FAMILY_SPOREBAT
: // Smack and Spore Cloud
2253 if(spell
->SpellIconID
!= 473 && spell
->SpellIconID
!= 2681)
2256 case CREATURE_FAMILY_TALLSTRIDER
: // Claw and Dust Cloud
2257 if(spell
->SpellIconID
!= 262 && (spell
->SpellIconID
!= 157 && !(spell
->Attributes
& 0x4000000)))
2260 case CREATURE_FAMILY_TURTLE
: // Bite and Shell Shield
2261 if(spell
->SpellIconID
!= 1680 && spell
->SpellIconID
!= 1588)
2264 case CREATURE_FAMILY_WARP_STALKER
: // Bite and Warp
2265 if(spell
->SpellIconID
!= 1680 && spell
->SpellIconID
!= 1952)
2268 case CREATURE_FAMILY_WASP
: // Smack and Sting
2269 if(spell
->SpellIconID
!= 473 && spell
->SpellIconID
!= 110)
2272 case CREATURE_FAMILY_WIND_SERPENT
: // Bite and Lightning Breath
2273 if(spell
->SpellIconID
!= 1680 && spell
->SpellIconID
!= 62)
2276 case CREATURE_FAMILY_WOLF
: // Bite and Furious Howl
2277 if(spell
->SpellIconID
!= 1680 && spell
->SpellIconID
!= 1573)
2280 case CREATURE_FAMILY_WORM
: // Acid Spit and Bite
2281 if(spell
->SpellIconID
!= 636 && spell
->SpellIconID
!= 1680)
2285 sLog
.outError("LoadPetLevelupSpellMap: Unhandled creature family %u", creatureFamily
->ID
);
2290 mPetLevelupSpellMap
[creatureFamily
->ID
][spell
->spellLevel
] = spell
->Id
;
2296 sLog
.outString( ">> Loaded %u pet levelup spells", count
);
2299 /// Some checks for spells, to prevent adding deprecated/broken spells for trainers, spell book, etc
2300 bool SpellMgr::IsSpellValid(SpellEntry
const* spellInfo
, Player
* pl
, bool msg
)
2306 bool need_check_reagents
= false;
2309 for(int i
=0; i
<3; ++i
)
2311 switch(spellInfo
->Effect
[i
])
2316 // craft spell for crafting non-existed item (break client recipes list show)
2317 case SPELL_EFFECT_CREATE_ITEM
:
2319 if(!ObjectMgr::GetItemPrototype( spellInfo
->EffectItemType
[i
] ))
2324 ChatHandler(pl
).PSendSysMessage("Craft spell %u create not-exist in DB item (Entry: %u) and then...",spellInfo
->Id
,spellInfo
->EffectItemType
[i
]);
2326 sLog
.outErrorDb("Craft spell %u create not-exist in DB item (Entry: %u) and then...",spellInfo
->Id
,spellInfo
->EffectItemType
[i
]);
2331 need_check_reagents
= true;
2334 case SPELL_EFFECT_LEARN_SPELL
:
2336 SpellEntry
const* spellInfo2
= sSpellStore
.LookupEntry(spellInfo
->EffectTriggerSpell
[i
]);
2337 if( !IsSpellValid(spellInfo2
,pl
,msg
) )
2342 ChatHandler(pl
).PSendSysMessage("Spell %u learn to broken spell %u, and then...",spellInfo
->Id
,spellInfo
->EffectTriggerSpell
[i
]);
2344 sLog
.outErrorDb("Spell %u learn to invalid spell %u, and then...",spellInfo
->Id
,spellInfo
->EffectTriggerSpell
[i
]);
2353 if(need_check_reagents
)
2355 for(int j
= 0; j
< 8; ++j
)
2357 if(spellInfo
->Reagent
[j
] > 0 && !ObjectMgr::GetItemPrototype( spellInfo
->Reagent
[j
] ))
2362 ChatHandler(pl
).PSendSysMessage("Craft spell %u have not-exist reagent in DB item (Entry: %u) and then...",spellInfo
->Id
,spellInfo
->Reagent
[j
]);
2364 sLog
.outErrorDb("Craft spell %u have not-exist reagent in DB item (Entry: %u) and then...",spellInfo
->Id
,spellInfo
->Reagent
[j
]);
2374 void SpellMgr::LoadSpellAreas()
2376 mSpellAreaMap
.clear(); // need for reload case
2377 mSpellAreaForQuestMap
.clear();
2378 mSpellAreaForActiveQuestMap
.clear();
2379 mSpellAreaForQuestEndMap
.clear();
2380 mSpellAreaForAuraMap
.clear();
2384 // 0 1 2 3 4 5 6 7 8
2385 QueryResult
*result
= WorldDatabase
.Query("SELECT spell, area, quest_start, quest_start_active, quest_end, aura_spell, racemask, gender, autocast FROM spell_area");
2394 sLog
.outString( ">> Loaded %u spell area requirements", count
);
2398 barGoLink
bar( result
->GetRowCount() );
2402 Field
*fields
= result
->Fetch();
2406 uint32 spell
= fields
[0].GetUInt32();
2407 SpellArea spellArea
;
2408 spellArea
.spellId
= spell
;
2409 spellArea
.areaId
= fields
[1].GetUInt32();
2410 spellArea
.questStart
= fields
[2].GetUInt32();
2411 spellArea
.questStartCanActive
= fields
[3].GetBool();
2412 spellArea
.questEnd
= fields
[4].GetUInt32();
2413 spellArea
.auraSpell
= fields
[5].GetInt32();
2414 spellArea
.raceMask
= fields
[6].GetUInt32();
2415 spellArea
.gender
= Gender(fields
[7].GetUInt8());
2416 spellArea
.autocast
= fields
[8].GetBool();
2418 if(!sSpellStore
.LookupEntry(spell
))
2420 sLog
.outErrorDb("Spell %u listed in `spell_area` does not exist", spell
);
2426 SpellAreaMapBounds sa_bounds
= GetSpellAreaMapBounds(spellArea
.spellId
);
2427 for(SpellAreaMap::const_iterator itr
= sa_bounds
.first
; itr
!= sa_bounds
.second
; ++itr
)
2429 if(spellArea
.spellId
&& itr
->second
.spellId
&& spellArea
.spellId
!= itr
->second
.spellId
)
2431 if(spellArea
.areaId
&& itr
->second
.areaId
&& spellArea
.areaId
!= itr
->second
.areaId
)
2433 if(spellArea
.questStart
&& itr
->second
.questStart
&& spellArea
.questStart
!= itr
->second
.questStart
)
2435 if(spellArea
.auraSpell
&& itr
->second
.auraSpell
&& spellArea
.auraSpell
!= itr
->second
.auraSpell
)
2437 if(spellArea
.raceMask
&& itr
->second
.raceMask
&& (spellArea
.raceMask
& itr
->second
.raceMask
)==0)
2439 if(spellArea
.gender
!= GENDER_NONE
&& itr
->second
.gender
!= GENDER_NONE
&& spellArea
.gender
!= itr
->second
.gender
)
2442 // duplicate by requirements
2449 sLog
.outErrorDb("Spell %u listed in `spell_area` already listed with similar requirements.", spell
);
2455 if(spellArea
.areaId
&& !GetAreaEntryByAreaID(spellArea
.areaId
))
2457 sLog
.outErrorDb("Spell %u listed in `spell_area` have wrong area (%u) requirement", spell
,spellArea
.areaId
);
2461 if(spellArea
.questStart
&& !objmgr
.GetQuestTemplate(spellArea
.questStart
))
2463 sLog
.outErrorDb("Spell %u listed in `spell_area` have wrong start quest (%u) requirement", spell
,spellArea
.questStart
);
2467 if(spellArea
.questEnd
)
2469 if(!objmgr
.GetQuestTemplate(spellArea
.questEnd
))
2471 sLog
.outErrorDb("Spell %u listed in `spell_area` have wrong end quest (%u) requirement", spell
,spellArea
.questEnd
);
2475 if(spellArea
.questEnd
==spellArea
.questStart
&& !spellArea
.questStartCanActive
)
2477 sLog
.outErrorDb("Spell %u listed in `spell_area` have quest (%u) requirement for start and end in same time", spell
,spellArea
.questEnd
);
2482 if(spellArea
.auraSpell
)
2484 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(abs(spellArea
.auraSpell
));
2487 sLog
.outErrorDb("Spell %u listed in `spell_area` have wrong aura spell (%u) requirement", spell
,abs(spellArea
.auraSpell
));
2491 if(spellInfo
->EffectApplyAuraName
[0]!=SPELL_AURA_DUMMY
&& spellInfo
->EffectApplyAuraName
[0]!=SPELL_AURA_PHASE
)
2493 sLog
.outErrorDb("Spell %u listed in `spell_area` have aura spell requirement (%u) without dummy/phase aura in effect 0", spell
,abs(spellArea
.auraSpell
));
2497 if(abs(spellArea
.auraSpell
)==spellArea
.spellId
)
2499 sLog
.outErrorDb("Spell %u listed in `spell_area` have aura spell (%u) requirement for itself", spell
,abs(spellArea
.auraSpell
));
2503 // not allow autocast chains by auraSpell field (but allow use as alternative if not present)
2504 if(spellArea
.autocast
&& spellArea
.auraSpell
> 0)
2507 SpellAreaForAuraMapBounds saBound
= GetSpellAreaForAuraMapBounds(spellArea
.spellId
);
2508 for(SpellAreaForAuraMap::const_iterator itr
= saBound
.first
; itr
!= saBound
.second
; ++itr
)
2510 if(itr
->second
->autocast
&& itr
->second
->auraSpell
> 0)
2519 sLog
.outErrorDb("Spell %u listed in `spell_area` have aura spell (%u) requirement that itself autocast from aura", spell
,spellArea
.auraSpell
);
2523 SpellAreaMapBounds saBound2
= GetSpellAreaMapBounds(spellArea
.auraSpell
);
2524 for(SpellAreaMap::const_iterator itr2
= saBound2
.first
; itr2
!= saBound2
.second
; ++itr2
)
2526 if(itr2
->second
.autocast
&& itr2
->second
.auraSpell
> 0)
2535 sLog
.outErrorDb("Spell %u listed in `spell_area` have aura spell (%u) requirement that itself autocast from aura", spell
,spellArea
.auraSpell
);
2541 if(spellArea
.raceMask
&& (spellArea
.raceMask
& RACEMASK_ALL_PLAYABLE
)==0)
2543 sLog
.outErrorDb("Spell %u listed in `spell_area` have wrong race mask (%u) requirement", spell
,spellArea
.raceMask
);
2547 if(spellArea
.gender
!=GENDER_NONE
&& spellArea
.gender
!=GENDER_FEMALE
&& spellArea
.gender
!=GENDER_MALE
)
2549 sLog
.outErrorDb("Spell %u listed in `spell_area` have wrong gender (%u) requirement", spell
,spellArea
.gender
);
2553 SpellArea
const* sa
= &mSpellAreaMap
.insert(SpellAreaMap::value_type(spell
,spellArea
))->second
;
2555 // for search by current zone/subzone at zone/subzone change
2556 if(spellArea
.areaId
)
2557 mSpellAreaForAreaMap
.insert(SpellAreaForAreaMap::value_type(spellArea
.areaId
,sa
));
2559 // for search at quest start/reward
2560 if(spellArea
.questStart
)
2562 if(spellArea
.questStartCanActive
)
2563 mSpellAreaForActiveQuestMap
.insert(SpellAreaForQuestMap::value_type(spellArea
.questStart
,sa
));
2565 mSpellAreaForQuestMap
.insert(SpellAreaForQuestMap::value_type(spellArea
.questStart
,sa
));
2568 // for search at quest start/reward
2569 if(spellArea
.questEnd
)
2570 mSpellAreaForQuestEndMap
.insert(SpellAreaForQuestMap::value_type(spellArea
.questEnd
,sa
));
2572 // for search at aura apply
2573 if(spellArea
.auraSpell
)
2574 mSpellAreaForAuraMap
.insert(SpellAreaForAuraMap::value_type(abs(spellArea
.auraSpell
),sa
));
2577 } while( result
->NextRow() );
2582 sLog
.outString( ">> Loaded %u spell area requirements", count
);
2585 SpellCastResult
SpellMgr::GetSpellAllowedInLocationError(SpellEntry
const *spellInfo
, uint32 map_id
, uint32 zone_id
, uint32 area_id
, Player
const* player
)
2588 if( spellInfo
->AreaGroupId
> 0)
2592 AreaGroupEntry
const* groupEntry
= sAreaGroupStore
.LookupEntry(spellInfo
->AreaGroupId
);
2595 for (uint8 i
=0; i
<7; i
++)
2596 if( groupEntry
->AreaId
[i
] == zone_id
|| groupEntry
->AreaId
[i
] == area_id
)
2601 return SPELL_FAILED_INCORRECT_AREA
;
2604 // DB base check (if non empty then must fit at least single for allow)
2605 SpellAreaMapBounds saBounds
= spellmgr
.GetSpellAreaMapBounds(spellInfo
->Id
);
2606 if(saBounds
.first
!= saBounds
.second
)
2608 for(SpellAreaMap::const_iterator itr
= saBounds
.first
; itr
!= saBounds
.second
; ++itr
)
2610 if(itr
->second
.IsFitToRequirements(player
,zone_id
,area_id
))
2611 return SPELL_CAST_OK
;
2613 return SPELL_FAILED_INCORRECT_AREA
;
2617 switch(spellInfo
->Id
)
2619 case 23333: // Warsong Flag
2620 case 23335: // Silverwing Flag
2621 return map_id
== 489 && player
&& player
->InBattleGround() ? SPELL_CAST_OK
: SPELL_FAILED_REQUIRES_AREA
;
2622 case 34976: // Netherstorm Flag
2623 return map_id
== 566 && player
&& player
->InBattleGround() ? SPELL_CAST_OK
: SPELL_FAILED_REQUIRES_AREA
;
2624 case 2584: // Waiting to Resurrect
2625 case 22011: // Spirit Heal Channel
2626 case 22012: // Spirit Heal
2627 case 24171: // Resurrection Impact Visual
2628 case 42792: // Recently Dropped Flag
2629 case 43681: // Inactive
2630 case 44535: // Spirit Heal (mana)
2632 MapEntry
const* mapEntry
= sMapStore
.LookupEntry(map_id
);
2634 return SPELL_FAILED_INCORRECT_AREA
;
2636 return mapEntry
->IsBattleGround() && player
&& player
->InBattleGround() ? SPELL_CAST_OK
: SPELL_FAILED_REQUIRES_AREA
;
2638 case 44521: // Preparation
2641 return SPELL_FAILED_REQUIRES_AREA
;
2643 MapEntry
const* mapEntry
= sMapStore
.LookupEntry(map_id
);
2645 return SPELL_FAILED_INCORRECT_AREA
;
2647 if(!mapEntry
->IsBattleGround())
2648 return SPELL_FAILED_REQUIRES_AREA
;
2650 BattleGround
* bg
= player
->GetBattleGround();
2651 return bg
&& bg
->GetStatus()==STATUS_WAIT_JOIN
? SPELL_CAST_OK
: SPELL_FAILED_REQUIRES_AREA
;
2653 case 32724: // Gold Team (Alliance)
2654 case 32725: // Green Team (Alliance)
2655 case 35774: // Gold Team (Horde)
2656 case 35775: // Green Team (Horde)
2658 MapEntry
const* mapEntry
= sMapStore
.LookupEntry(map_id
);
2660 return SPELL_FAILED_INCORRECT_AREA
;
2662 return mapEntry
->IsBattleArena() && player
&& player
->InBattleGround() ? SPELL_CAST_OK
: SPELL_FAILED_REQUIRES_AREA
;
2664 case 32727: // Arena Preparation
2667 return SPELL_FAILED_REQUIRES_AREA
;
2669 MapEntry
const* mapEntry
= sMapStore
.LookupEntry(map_id
);
2671 return SPELL_FAILED_INCORRECT_AREA
;
2673 if(!mapEntry
->IsBattleArena())
2674 return SPELL_FAILED_REQUIRES_AREA
;
2676 BattleGround
* bg
= player
->GetBattleGround();
2677 return bg
&& bg
->GetStatus()==STATUS_WAIT_JOIN
? SPELL_CAST_OK
: SPELL_FAILED_REQUIRES_AREA
;
2681 return SPELL_CAST_OK
;
2684 void SpellMgr::LoadSkillLineAbilityMap()
2686 mSkillLineAbilityMap
.clear();
2688 barGoLink
bar( sSkillLineAbilityStore
.GetNumRows() );
2691 for (uint32 i
= 0; i
< sSkillLineAbilityStore
.GetNumRows(); i
++)
2694 SkillLineAbilityEntry
const *SkillInfo
= sSkillLineAbilityStore
.LookupEntry(i
);
2698 mSkillLineAbilityMap
.insert(SkillLineAbilityMap::value_type(SkillInfo
->spellId
,SkillInfo
));
2703 sLog
.outString(">> Loaded %u SkillLineAbility MultiMap Data", count
);
2706 DiminishingGroup
GetDiminishingReturnsGroupForSpell(SpellEntry
const* spellproto
, bool triggered
)
2708 // Explicit Diminishing Groups
2709 switch(spellproto
->SpellFamilyName
)
2711 case SPELLFAMILY_ROGUE
:
2714 if (spellproto
->SpellFamilyFlags
& 0x00000200000LL
)
2715 return DIMINISHING_KIDNEYSHOT
;
2717 else if (spellproto
->SpellFamilyFlags
& 0x00001000000LL
)
2718 return DIMINISHING_BLIND_CYCLONE
;
2721 case SPELLFAMILY_WARLOCK
:
2724 if (spellproto
->SpellFamilyFlags
& 0x40840000000LL
)
2725 return DIMINISHING_WARLOCK_FEAR
;
2727 else if (spellproto
->SpellFamilyFlags
& 0x00080000000LL
)
2728 return DIMINISHING_LIMITONLY
;
2731 case SPELLFAMILY_DRUID
:
2734 if (spellproto
->SpellFamilyFlags
& 0x02000000000LL
)
2735 return DIMINISHING_BLIND_CYCLONE
;
2738 case SPELLFAMILY_WARRIOR
:
2740 // Hamstring - limit duration to 10s in PvP
2741 if (spellproto
->SpellFamilyFlags
& 0x00000000002LL
)
2742 return DIMINISHING_LIMITONLY
;
2750 uint32 mechanic
= GetAllSpellMechanicMask(spellproto
);
2751 if (mechanic
== MECHANIC_NONE
) return DIMINISHING_NONE
;
2752 if (mechanic
& (1<<MECHANIC_STUN
)) return triggered
? DIMINISHING_TRIGGER_STUN
: DIMINISHING_CONTROL_STUN
;
2753 if (mechanic
& (1<<MECHANIC_SLEEP
)) return DIMINISHING_SLEEP
;
2754 if (mechanic
& (1<<MECHANIC_POLYMORPH
)) return DIMINISHING_POLYMORPH
;
2755 if (mechanic
& (1<<MECHANIC_ROOT
)) return triggered
? DIMINISHING_TRIGGER_ROOT
: DIMINISHING_CONTROL_ROOT
;
2756 if (mechanic
& (1<<MECHANIC_FEAR
)) return DIMINISHING_FEAR
;
2757 if (mechanic
& (1<<MECHANIC_CHARM
)) return DIMINISHING_CHARM
;
2758 if (mechanic
& (1<<MECHANIC_SILENCE
)) return DIMINISHING_SILENCE
;
2759 if (mechanic
& (1<<DIMINISHING_DISARM
)) return DIMINISHING_DISARM
;
2760 if (mechanic
& (1<<MECHANIC_FREEZE
)) return DIMINISHING_FREEZE
;
2761 if (mechanic
& ((1<<MECHANIC_KNOCKOUT
) | (1<<MECHANIC_SAPPED
))) return DIMINISHING_KNOCKOUT
;
2762 if (mechanic
& (1<<MECHANIC_BANISH
)) return DIMINISHING_BANISH
;
2763 if (mechanic
& (1<<MECHANIC_HORROR
)) return DIMINISHING_DEATHCOIL
;
2766 return DIMINISHING_NONE
;
2769 bool IsDiminishingReturnsGroupDurationLimited(DiminishingGroup group
)
2773 case DIMINISHING_CONTROL_STUN
:
2774 case DIMINISHING_TRIGGER_STUN
:
2775 case DIMINISHING_KIDNEYSHOT
:
2776 case DIMINISHING_SLEEP
:
2777 case DIMINISHING_CONTROL_ROOT
:
2778 case DIMINISHING_TRIGGER_ROOT
:
2779 case DIMINISHING_FEAR
:
2780 case DIMINISHING_WARLOCK_FEAR
:
2781 case DIMINISHING_CHARM
:
2782 case DIMINISHING_POLYMORPH
:
2783 case DIMINISHING_FREEZE
:
2784 case DIMINISHING_KNOCKOUT
:
2785 case DIMINISHING_BLIND_CYCLONE
:
2786 case DIMINISHING_BANISH
:
2787 case DIMINISHING_LIMITONLY
:
2793 DiminishingReturnsType
GetDiminishingReturnsGroupType(DiminishingGroup group
)
2797 case DIMINISHING_BLIND_CYCLONE
:
2798 case DIMINISHING_CONTROL_STUN
:
2799 case DIMINISHING_TRIGGER_STUN
:
2800 case DIMINISHING_KIDNEYSHOT
:
2802 case DIMINISHING_SLEEP
:
2803 case DIMINISHING_CONTROL_ROOT
:
2804 case DIMINISHING_TRIGGER_ROOT
:
2805 case DIMINISHING_FEAR
:
2806 case DIMINISHING_CHARM
:
2807 case DIMINISHING_POLYMORPH
:
2808 case DIMINISHING_SILENCE
:
2809 case DIMINISHING_DISARM
:
2810 case DIMINISHING_DEATHCOIL
:
2811 case DIMINISHING_FREEZE
:
2812 case DIMINISHING_BANISH
:
2813 case DIMINISHING_WARLOCK_FEAR
:
2814 case DIMINISHING_KNOCKOUT
:
2815 return DRTYPE_PLAYER
;
2821 bool SpellArea::IsFitToRequirements(Player
const* player
, uint32 newZone
, uint32 newArea
) const
2823 if(gender
!=GENDER_NONE
)
2825 // not in expected gender
2826 if(!player
|| gender
!= player
->getGender())
2832 // not in expected race
2833 if(!player
|| !(raceMask
& player
->getRaceMask()))
2839 // not in expected zone
2840 if(newZone
!=areaId
&& newArea
!=areaId
)
2846 // not in expected required quest state
2847 if(!player
|| (!questStartCanActive
|| !player
->IsActiveQuest(questStart
)) && !player
->GetQuestRewardStatus(questStart
))
2853 // not in expected forbidden quest state
2854 if(!player
|| player
->GetQuestRewardStatus(questEnd
))
2860 // not have expected aura
2864 // have expected aura
2865 return player
->HasAura(auraSpell
,0);
2867 // not have expected aura
2868 return !player
->HasAura(-auraSpell
,0);