aboutsummaryrefslogtreecommitdiff
path: root/src/game/SpellMgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/SpellMgr.cpp')
-rw-r--r--src/game/SpellMgr.cpp506
1 files changed, 331 insertions, 175 deletions
diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp
index 2ebb273ed19..2b5787bad90 100644
--- a/src/game/SpellMgr.cpp
+++ b/src/game/SpellMgr.cpp
@@ -36,25 +36,25 @@ SpellMgr::SpellMgr()
case SPELL_EFFECT_PERSISTENT_AREA_AURA: //27
case SPELL_EFFECT_SUMMON: //28
case SPELL_EFFECT_TRIGGER_MISSILE: //32
- case SPELL_EFFECT_SUMMON_WILD: //41
- case SPELL_EFFECT_SUMMON_GUARDIAN: //42
+ //case SPELL_EFFECT_SUMMON_WILD: //41 not 303
+ //case SPELL_EFFECT_SUMMON_GUARDIAN: //42 not 303
case SPELL_EFFECT_TRANS_DOOR: //50 summon object
case SPELL_EFFECT_SUMMON_PET: //56
case SPELL_EFFECT_ADD_FARSIGHT: //72
- case SPELL_EFFECT_SUMMON_POSSESSED: //73
- case SPELL_EFFECT_SUMMON_TOTEM: //74
+ //case SPELL_EFFECT_SUMMON_POSSESSED: //73
+ //case SPELL_EFFECT_SUMMON_TOTEM: //74
case SPELL_EFFECT_SUMMON_OBJECT_WILD: //76
- case SPELL_EFFECT_SUMMON_TOTEM_SLOT1: //87
- case SPELL_EFFECT_SUMMON_TOTEM_SLOT2: //88
- case SPELL_EFFECT_SUMMON_TOTEM_SLOT3: //89
- case SPELL_EFFECT_SUMMON_TOTEM_SLOT4: //90
- case SPELL_EFFECT_SUMMON_CRITTER: //97
+ //case SPELL_EFFECT_SUMMON_TOTEM_SLOT1: //87
+ //case SPELL_EFFECT_SUMMON_TOTEM_SLOT2: //88
+ //case SPELL_EFFECT_SUMMON_TOTEM_SLOT3: //89
+ //case SPELL_EFFECT_SUMMON_TOTEM_SLOT4: //90
+ //case SPELL_EFFECT_SUMMON_CRITTER: //97 not 303
case SPELL_EFFECT_SUMMON_OBJECT_SLOT1: //104
case SPELL_EFFECT_SUMMON_OBJECT_SLOT2: //105
case SPELL_EFFECT_SUMMON_OBJECT_SLOT3: //106
case SPELL_EFFECT_SUMMON_OBJECT_SLOT4: //107
case SPELL_EFFECT_SUMMON_DEAD_PET: //109
- case SPELL_EFFECT_SUMMON_DEMON: //112
+ //case SPELL_EFFECT_SUMMON_DEMON: //112 not 303
case SPELL_EFFECT_TRIGGER_SPELL_2: //151 ritual of summon
EffectTargetType[i] = SPELL_REQUIRE_DEST;
break;
@@ -361,6 +361,13 @@ SpellSpecific GetSpellSpecific(uint32 spellId)
if (spellInfo->Dispel == DISPEL_POISON)
return SPELL_STING;
+ // only hunter aspects have this (but not all aspects in hunter family)
+ if( spellInfo->SpellFamilyFlags & 0x0044000000380000LL || spellInfo->SpellFamilyFlags2 & 0x00003010)
+ return SPELL_ASPECT;
+
+ if( spellInfo->SpellFamilyFlags2 & 0x00000002 )
+ return SPELL_TRACKER;
+
break;
}
case SPELLFAMILY_PALADIN:
@@ -368,7 +375,7 @@ SpellSpecific GetSpellSpecific(uint32 spellId)
if (IsSealSpell(spellInfo))
return SPELL_SEAL;
- if (spellInfo->SpellFamilyFlags & 0x10000100LL)
+ if (spellInfo->SpellFamilyFlags & 0x0000000011010002LL)
return SPELL_BLESSING;
if ((spellInfo->SpellFamilyFlags & 0x00000820180400LL) && (spellInfo->AttributesEx3 & 0x200))
@@ -376,8 +383,8 @@ SpellSpecific GetSpellSpecific(uint32 spellId)
for (int i = 0; i < 3; i++)
{
- // only paladin auras have this
- if (spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_PARTY)
+ // only paladin auras have this (for palaldin class family)
+ if (spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_RAID)
return SPELL_AURA;
}
break;
@@ -392,28 +399,19 @@ SpellSpecific GetSpellSpecific(uint32 spellId)
case SPELLFAMILY_POTION:
return spellmgr.GetSpellElixirSpecific(spellInfo->Id);
+
+ case SPELLFAMILY_DEATHKNIGHT:
+ if ((spellInfo->Attributes & 0x10) && (spellInfo->AttributesEx2 & 0x10) && (spellInfo->AttributesEx4 & 0x200000))
+ return SPELL_PRESENCE;
+ break;
}
// only warlock armor/skin have this (in additional to family cases)
- if( spellInfo->SpellVisual == 130 && spellInfo->SpellIconID == 89)
+ if( spellInfo->SpellVisual[0] == 130 && spellInfo->SpellIconID == 89)
{
return SPELL_WARLOCK_ARMOR;
}
- // only hunter aspects have this (but not all aspects in hunter family)
- if( spellInfo->activeIconID == 122 && (GetSpellSchoolMask(spellInfo) & SPELL_SCHOOL_MASK_NATURE) &&
- (spellInfo->Attributes & 0x50000) != 0 && (spellInfo->Attributes & 0x9000010) == 0)
- {
- return SPELL_ASPECT;
- }
-
- for(int i = 0; i < 3; i++)
- if( spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA && (
- spellInfo->EffectApplyAuraName[i] == SPELL_AURA_TRACK_CREATURES ||
- spellInfo->EffectApplyAuraName[i] == SPELL_AURA_TRACK_RESOURCES ||
- spellInfo->EffectApplyAuraName[i] == SPELL_AURA_TRACK_STEALTHED ) )
- return SPELL_TRACKER;
-
// elixirs can have different families, but potion most ofc.
if(SpellSpecific sp = spellmgr.GetSpellElixirSpecific(spellInfo->Id))
return sp;
@@ -449,6 +447,7 @@ bool IsSingleFromSpellSpecificPerTarget(uint32 spellSpec1,uint32 spellSpec2)
case SPELL_MAGE_ARMOR:
case SPELL_ELEMENTAL_SHIELD:
case SPELL_MAGE_POLYMORPH:
+ case SPELL_PRESENCE:
case SPELL_WELL_FED:
case SPELL_DRINK:
case SPELL_FOOD:
@@ -884,8 +883,8 @@ void SpellMgr::LoadSpellAffects()
uint32 count = 0;
- // 0 1 2
- QueryResult *result = WorldDatabase.Query("SELECT entry, effectId, SpellFamilyMask FROM spell_affect");
+ // 0 1 2 3 4
+ QueryResult *result = WorldDatabase.Query("SELECT entry, effectId, SpellClassMask0, SpellClassMask1, SpellClassMask2 FROM spell_affect");
if( !result )
{
@@ -932,26 +931,29 @@ void SpellMgr::LoadSpellAffects()
continue;
}
- uint64 spellAffectMask = fields[2].GetUInt64();
+ SpellAffectEntry affect;
+ affect.SpellClassMask[0] = fields[2].GetUInt32();
+ affect.SpellClassMask[1] = fields[3].GetUInt32();
+ affect.SpellClassMask[2] = fields[4].GetUInt32();
- // Spell.dbc have own data for low part of SpellFamilyMask
- if( spellInfo->EffectItemType[effectId])
+ // Spell.dbc have own data
+ uint32 const *ptr = 0;
+ switch (effectId)
{
- if(spellInfo->EffectItemType[effectId] == spellAffectMask)
- {
- sLog.outErrorDb("Spell %u listed in `spell_affect` have redundant (same with EffectItemType%d) data for effect index (%u) and not needed, skipped.", entry,effectId+1,effectId);
- continue;
- }
-
- // 24429 have wrong data in EffectItemType and overwrites by DB, possible bug in client
- if(spellInfo->Id!=24429 && spellInfo->EffectItemType[effectId] != spellAffectMask)
- {
- sLog.outErrorDb("Spell %u listed in `spell_affect` have different low part from EffectItemType%d for effect index (%u) and not needed, skipped.", entry,effectId+1,effectId);
+ case 0: ptr = &spellInfo->EffectSpellClassMaskA[0]; break;
+ case 1: ptr = &spellInfo->EffectSpellClassMaskB[0]; break;
+ case 2: ptr = &spellInfo->EffectSpellClassMaskC[0]; break;
+ default:
continue;
- }
+ }
+ if(ptr[0] == affect.SpellClassMask[0] || ptr[1] == affect.SpellClassMask[1] || ptr[2] == affect.SpellClassMask[2])
+ {
+ char text[]="ABC";
+ 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);
+ continue;
}
- mSpellAffectMap.insert(SpellAffectMap::value_type((entry<<8) + effectId,spellAffectMask));
+ mSpellAffectMap[(entry<<8) + effectId] = affect;
++count;
} while( result->NextRow() );
@@ -959,7 +961,7 @@ void SpellMgr::LoadSpellAffects()
delete result;
sLog.outString();
- sLog.outString( ">> Loaded %u spell affect definitions", count );
+ sLog.outString( ">> Loaded %u custom spell affect definitions", count );
for (uint32 id = 0; id < sSpellStore.GetNumRows(); ++id)
{
@@ -975,7 +977,16 @@ void SpellMgr::LoadSpellAffects()
spellInfo->EffectApplyAuraName[effectId] != SPELL_AURA_ADD_TARGET_TRIGGER) )
continue;
- if(spellInfo->EffectItemType[effectId] != 0)
+ uint32 const *ptr = 0;
+ switch (effectId)
+ {
+ case 0: ptr = &spellInfo->EffectSpellClassMaskA[0]; break;
+ case 1: ptr = &spellInfo->EffectSpellClassMaskB[0]; break;
+ case 2: ptr = &spellInfo->EffectSpellClassMaskC[0]; break;
+ default:
+ continue;
+ }
+ if(ptr[0] || ptr[1] || ptr[2])
continue;
if(mSpellAffectMap.find((id<<8) + effectId) != mSpellAffectMap.end())
@@ -986,33 +997,20 @@ void SpellMgr::LoadSpellAffects()
}
}
-bool SpellMgr::IsAffectedBySpell(SpellEntry const *spellInfo, uint32 spellId, uint8 effectId, uint64 familyFlags) const
+bool SpellMgr::IsAffectedByMod(SpellEntry const *spellInfo, SpellModifier *mod) const
{
// false for spellInfo == NULL
- if (!spellInfo)
- return false;
-
- SpellEntry const *affect_spell = sSpellStore.LookupEntry(spellId);
- // false for affect_spell == NULL
- if (!affect_spell)
+ if (!spellInfo || !mod)
return false;
- // False if spellFamily not equal
- if (affect_spell->SpellFamilyName != spellInfo->SpellFamilyName)
+ SpellEntry const *affect_spell = sSpellStore.LookupEntry(mod->spellId);
+ // False if affect_spell == NULL or spellFamily not equal
+ if (!affect_spell || affect_spell->SpellFamilyName != spellInfo->SpellFamilyName)
return false;
- // If familyFlags == 0
- if (!familyFlags)
- {
- // Get it from spellAffect table
- familyFlags = GetSpellAffectMask(spellId,effectId);
- // false if familyFlags == 0
- if (!familyFlags)
- return false;
- }
-
// true
- if (familyFlags & spellInfo->SpellFamilyFlags)
+ if (mod->mask & spellInfo->SpellFamilyFlags ||
+ mod->mask2 & spellInfo->SpellFamilyFlags2)
return true;
return false;
@@ -1024,15 +1022,12 @@ void SpellMgr::LoadSpellProcEvents()
uint32 count = 0;
- // 0 1 2 3 4 5 6 7 8
- QueryResult *result = WorldDatabase.Query("SELECT entry, SchoolMask, SpellFamilyName, SpellFamilyMask, procFlags, procEx, ppmRate, CustomChance, Cooldown FROM spell_proc_event");
+ // 0 1 2 3 4 5 6 7 8 9 10
+ QueryResult *result = WorldDatabase.Query("SELECT entry, SchoolMask, SpellFamilyName, SpellFamilyMask0, SpellFamilyMask1, SpellFamilyMask2, procFlags, procEx, ppmRate, CustomChance, Cooldown FROM spell_proc_event");
if( !result )
{
-
barGoLink bar( 1 );
-
bar.step();
-
sLog.outString();
sLog.outString( ">> Loaded %u spell proc event conditions", count );
return;
@@ -1059,12 +1054,13 @@ void SpellMgr::LoadSpellProcEvents()
spe.schoolMask = fields[1].GetUInt32();
spe.spellFamilyName = fields[2].GetUInt32();
- spe.spellFamilyMask = fields[3].GetUInt64();
- spe.procFlags = fields[4].GetUInt32();
- spe.procEx = fields[5].GetUInt32();
- spe.ppmRate = fields[6].GetFloat();
- spe.customChance = fields[7].GetFloat();
- spe.cooldown = fields[8].GetUInt32();
+ spe.spellFamilyMask = (uint64)fields[3].GetUInt32()|((uint64)fields[4].GetUInt32()<<32);
+ spe.spellFamilyMask2= fields[5].GetUInt32();
+ spe.procFlags = fields[6].GetUInt32();
+ spe.procEx = fields[7].GetUInt32();
+ spe.ppmRate = fields[8].GetFloat();
+ spe.customChance = fields[9].GetFloat();
+ spe.cooldown = fields[10].GetUInt32();
mSpellProcEventMap[entry] = spe;
@@ -1084,81 +1080,11 @@ void SpellMgr::LoadSpellProcEvents()
sLog.outString();
if (customProc)
- sLog.outString( ">> Loaded %u custom spell proc event conditions +%u custom", count, customProc );
+ sLog.outString( ">> Loaded %u extra spell proc event conditions +%u custom", count, customProc );
else
- sLog.outString( ">> Loaded %u spell proc event conditions", count );
-
- /*
- // Commented for now, as it still produces many errors (still quite many spells miss spell_proc_event)
- for (uint32 id = 0; id < sSpellStore.GetNumRows(); ++id)
- {
- SpellEntry const* spellInfo = sSpellStore.LookupEntry(id);
- if (!spellInfo)
- continue;
-
- bool found = false;
- for (int effectId = 0; effectId < 3; ++effectId)
- {
- // at this moment check only SPELL_AURA_PROC_TRIGGER_SPELL
- if( spellInfo->EffectApplyAuraName[effectId] == SPELL_AURA_PROC_TRIGGER_SPELL )
- {
- found = true;
- break;
- }
- }
-
- if(!found)
- continue;
-
- if(GetSpellProcEvent(id))
- continue;
-
- sLog.outErrorDb("Spell %u (%s) misses spell_proc_event",id,spellInfo->SpellName[sWorld.GetDBClang()]);
- }
- */
+ sLog.outString( ">> Loaded %u extra spell proc event conditions", count );
}
-/*
-bool SpellMgr::IsSpellProcEventCanTriggeredBy( SpellProcEventEntry const * spellProcEvent, SpellEntry const * procSpell, uint32 procFlags )
-{
- if((procFlags & spellProcEvent->procFlags) == 0)
- return false;
-
- // Additional checks in case spell cast/hit/crit is the event
- // Check (if set) school, category, skill line, spell talent mask
- if(spellProcEvent->schoolMask && (!procSpell || (GetSpellSchoolMask(procSpell) & spellProcEvent->schoolMask) == 0))
- return false;
- if(spellProcEvent->category && (!procSpell || procSpell->Category != spellProcEvent->category))
- return false;
- if(spellProcEvent->skillId)
- {
- if (!procSpell)
- return false;
-
- SkillLineAbilityMap::const_iterator lower = spellmgr.GetBeginSkillLineAbilityMap(procSpell->Id);
- SkillLineAbilityMap::const_iterator upper = spellmgr.GetEndSkillLineAbilityMap(procSpell->Id);
-
- bool found = false;
- for(SkillLineAbilityMap::const_iterator _spell_idx = lower; _spell_idx != upper; ++_spell_idx)
- {
- if(_spell_idx->second->skillId == spellProcEvent->skillId)
- {
- found = true;
- break;
- }
- }
- if (!found)
- return false;
- }
- if(spellProcEvent->spellFamilyName && (!procSpell || spellProcEvent->spellFamilyName != procSpell->SpellFamilyName))
- return false;
- if(spellProcEvent->spellFamilyMask && (!procSpell || (spellProcEvent->spellFamilyMask & procSpell->SpellFamilyFlags) == 0))
- return false;
-
- return true;
-}
-*/
-
bool SpellMgr::IsSpellProcEventCanTriggeredBy(SpellProcEventEntry const * spellProcEvent, uint32 EventProcFlag, SpellEntry const * procSpell, uint32 procFlags, uint32 procExtra, bool active)
{
// No extra req need
@@ -1169,7 +1095,7 @@ bool SpellMgr::IsSpellProcEventCanTriggeredBy(SpellProcEventEntry const * spellP
return false;
// Always trigger for this
- if (EventProcFlag & (PROC_FLAG_KILLED | PROC_FLAG_KILL_AND_GET_XP))
+ if (EventProcFlag & (PROC_FLAG_KILLED | PROC_FLAG_KILL))
return true;
if (spellProcEvent) // Exist event data
@@ -1195,9 +1121,10 @@ bool SpellMgr::IsSpellProcEventCanTriggeredBy(SpellProcEventEntry const * spellP
return false;
// spellFamilyName is Ok need check for spellFamilyMask if present
- if(spellProcEvent->spellFamilyMask)
+ if(spellProcEvent->spellFamilyMask || spellProcEvent->spellFamilyMask2)
{
- if ((spellProcEvent->spellFamilyMask & procSpell->SpellFamilyFlags) == 0)
+ if ((spellProcEvent->spellFamilyMask & procSpell->SpellFamilyFlags ) == 0 &&
+ (spellProcEvent->spellFamilyMask2 & procSpell->SpellFamilyFlags2) == 0)
return false;
active = true; // Spell added manualy -> so its active spell
}
@@ -1298,7 +1225,7 @@ bool SpellMgr::canStackSpellRanks(SpellEntry const *spellInfo)
{
if(spellInfo->powerType != POWER_MANA && spellInfo->powerType != POWER_HEALTH)
return false;
- if(IsProfessionSpell(spellInfo->Id))
+ if(IsProfessionOrRidingSpell(spellInfo->Id))
return false;
// All stance spells. if any better way, change it.
@@ -1306,7 +1233,7 @@ bool SpellMgr::canStackSpellRanks(SpellEntry const *spellInfo)
{
// Paladin aura Spell
if(spellInfo->SpellFamilyName == SPELLFAMILY_PALADIN
- && spellInfo->Effect[i]==SPELL_EFFECT_APPLY_AREA_AURA_PARTY)
+ && spellInfo->Effect[i]==SPELL_EFFECT_APPLY_AREA_AURA_RAID)
return false;
// Druid form Spell
if(spellInfo->SpellFamilyName == SPELLFAMILY_DRUID
@@ -1346,6 +1273,11 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2, bool
if(spellInfo_1->SpellFamilyName != spellInfo_2->SpellFamilyName)
return false;
+ // TODO: Is this needed?
+ // Allow stack passive and not passive spells
+ if ((spellInfo_1->Attributes & SPELL_ATTR_PASSIVE)!=(spellInfo_2->Attributes & SPELL_ATTR_PASSIVE))
+ return false;
+
// generic spells
if(!spellInfo_1->SpellFamilyName)
{
@@ -1400,6 +1332,21 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2, bool
return true;
}
+
+bool SpellMgr::IsProfessionOrRidingSpell(uint32 spellId)
+{
+ SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
+ if(!spellInfo)
+ return false;
+
+ if(spellInfo->Effect[1] != SPELL_EFFECT_SKILL)
+ return false;
+
+ uint32 skill = spellInfo->EffectMiscValue[1];
+
+ return IsProfessionOrRidingSkill(skill);
+}
+
bool SpellMgr::IsProfessionSpell(uint32 spellId)
{
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
@@ -1444,7 +1391,8 @@ SpellEntry const* SpellMgr::SelectAuraRankForPlayerLevel(SpellEntry const* spell
{
if( IsPositiveEffect(spellInfo->Id, i) && (
spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA ||
- spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_PARTY
+ spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_PARTY ||
+ spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_RAID
) )
{
needRankSelection = true;
@@ -1603,7 +1551,7 @@ void SpellMgr::LoadSpellChains()
entry.ProcFlags=SpellInfo->procFlags;
entry.SpellFamilyFlags=SpellInfo->SpellFamilyFlags;
entry.TargetAuraState=SpellInfo->TargetAuraState;
- entry.SpellVisual=SpellInfo->SpellVisual;
+ entry.SpellVisual=SpellInfo->SpellVisual[0];
entry.ManaCost=SpellInfo->manaCost;
for (;;)
@@ -1775,7 +1723,8 @@ void SpellMgr::LoadSpellLearnSpells()
{
mSpellLearnSpells.clear(); // need for reload case
- QueryResult *result = WorldDatabase.Query("SELECT entry, SpellID FROM spell_learn_spell");
+ // 0 1 2
+ QueryResult *result = WorldDatabase.Query("SELECT entry, SpellID, Active FROM spell_learn_spell");
if(!result)
{
barGoLink bar( 1 );
@@ -1799,6 +1748,7 @@ void SpellMgr::LoadSpellLearnSpells()
SpellLearnSpellNode node;
node.spell = fields[1].GetUInt32();
+ node.active = fields[2].GetBool();
node.autoLearned= false;
if(!sSpellStore.LookupEntry(spell_id))
@@ -1835,7 +1785,16 @@ void SpellMgr::LoadSpellLearnSpells()
{
SpellLearnSpellNode dbc_node;
dbc_node.spell = entry->EffectTriggerSpell[i];
- dbc_node.autoLearned = true;
+ dbc_node.active = true; // all dbc based learned spells is active (show in spell book or hide by client itself)
+
+ // ignore learning not existed spells (broken/outdated/or generic learnig spell 483
+ if(!sSpellStore.LookupEntry(dbc_node.spell))
+ continue;
+
+ // talent or passive spells or skill-step spells auto-casted and not need dependent learning,
+ // pet teaching spells don't must be dependent learning (casted)
+ // other required explicit dependent learning
+ dbc_node.autoLearned = entry->EffectImplicitTargetA[i]==TARGET_PET || GetTalentSpellCost(spell) > 0 || IsPassiveSpell(spell) || IsSpellHaveEffect(entry,SPELL_EFFECT_SKILL_STEP);
SpellLearnSpellMap::const_iterator db_node_begin = GetBeginSpellLearnSpell(spell);
SpellLearnSpellMap::const_iterator db_node_end = GetEndSpellLearnSpell(spell);
@@ -2145,7 +2104,7 @@ void SpellMgr::LoadSpellCustomAttr()
}
}
- if(spellInfo->SpellVisual == 3879)
+ if(spellInfo->SpellVisual[0] == 3879)
mSpellCustomAttr[i] |= SPELL_ATTR_CU_CONE_BACK;
switch(i)
@@ -2263,6 +2222,187 @@ void SpellMgr::LoadSpellLinked()
}
/// Some checks for spells, to prevent adding depricated/broken spells for trainers, spell book, etc
+void SpellMgr::LoadPetLevelupSpellMap()
+{
+ CreatureFamilyEntry const *creatureFamily;
+ SpellEntry const *spell;
+ uint32 count = 0;
+
+ for (uint32 i = 0; i < sCreatureFamilyStore.GetNumRows(); ++i)
+ {
+ creatureFamily = sCreatureFamilyStore.LookupEntry(i);
+
+ if(!creatureFamily) // not exist
+ continue;
+
+ if(creatureFamily->petTalentType < 0) // not hunter pet family
+ continue;
+
+ for(uint32 j = 0; j < sSpellStore.GetNumRows(); ++j)
+ {
+ spell = sSpellStore.LookupEntry(j);
+
+ // not exist
+ if(!spell)
+ continue;
+
+ // not hunter spell
+ if(spell->SpellFamilyName != SPELLFAMILY_HUNTER)
+ continue;
+
+ // not pet spell
+ if(!(spell->SpellFamilyFlags & 0x1000000000000000LL))
+ continue;
+
+ // not Growl or Cower (generics)
+ if(spell->SpellIconID != 201 && spell->SpellIconID != 958)
+ {
+ switch(creatureFamily->ID)
+ {
+ case CREATURE_FAMILY_BAT: // Bite and Sonic Blast
+ if(spell->SpellIconID != 1680 && spell->SpellIconID != 1577)
+ continue;
+ break;
+ case CREATURE_FAMILY_BEAR: // Claw and Swipe
+ if(spell->SpellIconID != 262 && spell->SpellIconID != 1562)
+ continue;
+ break;
+ case CREATURE_FAMILY_BIRD_OF_PREY: // Claw and Snatch
+ if(spell->SpellIconID != 262 && spell->SpellIconID != 168)
+ continue;
+ break;
+ case CREATURE_FAMILY_BOAR: // Bite and Gore
+ if(spell->SpellIconID != 1680 && spell->SpellIconID != 1578)
+ continue;
+ break;
+ case CREATURE_FAMILY_CARRION_BIRD: // Bite and Demoralizing Screech
+ if(spell->SpellIconID != 1680 && spell->SpellIconID != 1579)
+ continue;
+ break;
+ case CREATURE_FAMILY_CAT: // Claw and Prowl and Rake
+ if(spell->SpellIconID != 262 && spell->SpellIconID != 495 && spell->SpellIconID != 494)
+ continue;
+ break;
+ case CREATURE_FAMILY_CHIMAERA: // Bite and Froststorm Breath
+ if(spell->SpellIconID != 1680 && spell->SpellIconID != 62)
+ continue;
+ break;
+ case CREATURE_FAMILY_CORE_HOUND: // Bite and Lava Breath
+ if(spell->SpellIconID != 1680 && spell->SpellIconID != 1197)
+ continue;
+ break;
+ case CREATURE_FAMILY_CRAB: // Claw and Pin
+ if(spell->SpellIconID != 262 && spell->SpellIconID != 2679)
+ continue;
+ break;
+ case CREATURE_FAMILY_CROCOLISK: // Bite and Bad Attitude
+ if(spell->SpellIconID != 1680 && spell->SpellIconID != 1581)
+ continue;
+ break;
+ case CREATURE_FAMILY_DEVILSAUR: // Bite and Monstrous Bite
+ if(spell->SpellIconID != 1680 && spell->SpellIconID != 599)
+ continue;
+ break;
+ case CREATURE_FAMILY_DRAGONHAWK: // Bite and Fire Breath
+ if(spell->SpellIconID != 1680 && spell->SpellIconID != 2128)
+ continue;
+ break;
+ case CREATURE_FAMILY_GORILLA: // Smack and Thunderstomp
+ if(spell->SpellIconID != 473 && spell->SpellIconID != 148)
+ continue;
+ break;
+ case CREATURE_FAMILY_HYENA: // Bite and Tendon Rip
+ if(spell->SpellIconID != 1680 && spell->SpellIconID != 138)
+ continue;
+ break;
+ case CREATURE_FAMILY_MOTH: // Serenity Dust and Smack
+ if(spell->SpellIconID != 1714 && spell->SpellIconID != 473)
+ continue;
+ break;
+ case CREATURE_FAMILY_NETHER_RAY: // Bite and Nether Shock
+ if(spell->SpellIconID != 1680 && spell->SpellIconID != 2027)
+ continue;
+ break;
+ case CREATURE_FAMILY_RAPTOR: // Claw and Savage Rend
+ if(spell->SpellIconID != 262 && spell->SpellIconID != 245)
+ continue;
+ break;
+ case CREATURE_FAMILY_RAVAGER: // Bite and Ravage
+ if(spell->SpellIconID != 1680 && spell->SpellIconID != 2253)
+ continue;
+ break;
+ case CREATURE_FAMILY_RHINO: // Smack and Stampede
+ if(spell->SpellIconID != 473 && spell->SpellIconID != 3066)
+ continue;
+ break;
+ case CREATURE_FAMILY_SCORPID: // Claw and Scorpid Poison
+ if(spell->SpellIconID != 262 && spell->SpellIconID != 163)
+ continue;
+ break;
+ case CREATURE_FAMILY_SERPENT: // Bite and Poison Spit
+ if(spell->SpellIconID != 1680 && spell->SpellIconID != 68)
+ continue;
+ break;
+ case CREATURE_FAMILY_SILITHID: // Claw and Venom Web Spray
+ if(spell->SpellIconID != 262 && (spell->SpellIconID != 272 && spell->SpellVisual[0] != 12013))
+ continue;
+ break;
+ case CREATURE_FAMILY_SPIDER: // Bite and Web
+ if(spell->SpellIconID != 1680 && (spell->SpellIconID != 272 && spell->SpellVisual[0] != 684))
+ continue;
+ break;
+ case CREATURE_FAMILY_SPIRIT_BEAST: // Claw and Prowl and Spirit Strike
+ if(spell->SpellIconID != 262 && spell->SpellIconID != 495 && spell->SpellIconID != 255)
+ continue;
+ break;
+ case CREATURE_FAMILY_SPOREBAT: // Smack and Spore Cloud
+ if(spell->SpellIconID != 473 && spell->SpellIconID != 2681)
+ continue;
+ break;
+ case CREATURE_FAMILY_TALLSTRIDER: // Claw and Dust Cloud
+ if(spell->SpellIconID != 262 && (spell->SpellIconID != 157 && !(spell->Attributes & 0x4000000)))
+ continue;
+ break;
+ case CREATURE_FAMILY_TURTLE: // Bite and Shell Shield
+ if(spell->SpellIconID != 1680 && spell->SpellIconID != 1588)
+ continue;
+ break;
+ case CREATURE_FAMILY_WARP_STALKER: // Bite and Warp
+ if(spell->SpellIconID != 1680 && spell->SpellIconID != 1952)
+ continue;
+ break;
+ case CREATURE_FAMILY_WASP: // Smack and Sting
+ if(spell->SpellIconID != 473 && spell->SpellIconID != 110)
+ continue;
+ break;
+ case CREATURE_FAMILY_WIND_SERPENT: // Bite and Lightning Breath
+ if(spell->SpellIconID != 1680 && spell->SpellIconID != 62)
+ continue;
+ break;
+ case CREATURE_FAMILY_WOLF: // Bite and Furious Howl
+ if(spell->SpellIconID != 1680 && spell->SpellIconID != 1573)
+ continue;
+ break;
+ case CREATURE_FAMILY_WORM: // Acid Spit and Bite
+ if(spell->SpellIconID != 636 && spell->SpellIconID != 1680)
+ continue;
+ break;
+ default:
+ sLog.outError("LoadPetLevelupSpellMap: Unhandled creature family %u", creatureFamily->ID);
+ continue;
+ }
+ }
+
+ mPetLevelupSpellMap[creatureFamily->ID][spell->spellLevel] = spell->Id;
+ count++;
+ }
+ }
+
+ sLog.outString();
+ sLog.outString( ">> Loaded %u pet levelup spells", count );
+}
+
+/// Some checks for spells, to prevent adding deprecated/broken spells for trainers, spell book, etc
bool SpellMgr::IsSpellValid(SpellEntry const* spellInfo, Player* pl, bool msg)
{
// not exist
@@ -2337,11 +2477,24 @@ bool SpellMgr::IsSpellValid(SpellEntry const* spellInfo, Player* pl, bool msg)
return true;
}
-bool IsSpellAllowedInLocation(SpellEntry const *spellInfo,uint32 map_id,uint32 zone_id,uint32 area_id)
+uint8 GetSpellAllowedInLocationError(SpellEntry const *spellInfo,uint32 map_id,uint32 zone_id,uint32 area_id)
{
// normal case
- if( spellInfo->AreaId && spellInfo->AreaId != zone_id && spellInfo->AreaId != area_id )
- return false;
+ if( spellInfo->AreaGroupId > 0)
+ {
+ bool found = false;
+
+ AreaGroupEntry const* groupEntry = sAreaGroupStore.LookupEntry(spellInfo->AreaGroupId);
+ if(groupEntry)
+ {
+ for (uint8 i=0; i<7; i++)
+ if( groupEntry->AreaId[i] == zone_id || groupEntry->AreaId[i] == area_id )
+ found = true;
+ }
+
+ if(!found)
+ return SPELL_FAILED_INCORRECT_AREA;
+ }
// elixirs (all area dependent elixirs have family SPELLFAMILY_POTION, use this for speedup)
if(spellInfo->SpellFamilyName==SPELLFAMILY_POTION)
@@ -2351,28 +2504,28 @@ bool IsSpellAllowedInLocation(SpellEntry const *spellInfo,uint32 map_id,uint32 z
if(mask & ELIXIR_BATTLE_MASK)
{
if(spellInfo->Id==45373) // Bloodberry Elixir
- return zone_id==4075;
+ return zone_id==4075 ? 0 : SPELL_FAILED_REQUIRES_AREA;
}
if(mask & ELIXIR_UNSTABLE_MASK)
{
// in the Blade's Edge Mountains Plateaus and Gruul's Lair.
- return zone_id ==3522 || map_id==565;
+ return zone_id ==3522 || map_id==565 ? 0 : SPELL_FAILED_INCORRECT_AREA;
}
if(mask & ELIXIR_SHATTRATH_MASK)
{
// in Tempest Keep, Serpentshrine Cavern, Caverns of Time: Mount Hyjal, Black Temple, Sunwell Plateau
if(zone_id ==3607 || map_id==534 || map_id==564 || zone_id==4075)
- return true;
+ return 0;
MapEntry const* mapEntry = sMapStore.LookupEntry(map_id);
if(!mapEntry)
- return false;
+ return SPELL_FAILED_INCORRECT_AREA;
- return mapEntry->multimap_id==206;
+ return mapEntry->multimap_id==206 ? 0 : SPELL_FAILED_INCORRECT_AREA;
}
// elixirs not have another limitations
- return true;
+ return 0;
}
}
@@ -2384,25 +2537,28 @@ bool IsSpellAllowedInLocation(SpellEntry const *spellInfo,uint32 map_id,uint32 z
{
MapEntry const* mapEntry = sMapStore.LookupEntry(map_id);
if(!mapEntry)
- return false;
+ return SPELL_FAILED_INCORRECT_AREA;
- return mapEntry->multimap_id==206;
+ return mapEntry->multimap_id==206 ? 0 : SPELL_FAILED_REQUIRES_AREA;
}
case 41617: // Cenarion Mana Salve
case 41619: // Cenarion Healing Salve
{
MapEntry const* mapEntry = sMapStore.LookupEntry(map_id);
if(!mapEntry)
- return false;
+ return SPELL_FAILED_INCORRECT_AREA;
- return mapEntry->multimap_id==207;
+ return mapEntry->multimap_id==207 ? 0 : SPELL_FAILED_REQUIRES_AREA;
}
case 40216: // Dragonmaw Illusion
case 42016: // Dragonmaw Illusion
- return area_id == 3759 || area_id == 3966 || area_id == 3939;
+ return area_id == 3759 || area_id == 3966 || area_id == 3939 ? 0 : SPELL_FAILED_INCORRECT_AREA;
+ case 51721: // Dominion Over Acherus
+ case 54055: // Dominion Over Acherus
+ return area_id == 4281 || area_id == 4342 ? 0 : SPELL_FAILED_INCORRECT_AREA;
}
- return true;
+ return 0;
}
void SpellMgr::LoadSkillLineAbilityMap()