diff options
Diffstat (limited to 'src/game/SpellMgr.cpp')
-rw-r--r-- | src/game/SpellMgr.cpp | 381 |
1 files changed, 253 insertions, 128 deletions
diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index e67030b77f2..a7096b818d1 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -41,13 +41,13 @@ SpellMgr::SpellMgr() 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_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_OBJECT_SLOT1: //104 case SPELL_EFFECT_SUMMON_OBJECT_SLOT2: //105 @@ -358,7 +358,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)) @@ -366,8 +366,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; @@ -382,10 +382,15 @@ 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; } @@ -439,6 +444,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: @@ -874,8 +880,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 ) { @@ -922,26 +928,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); + case 0: ptr = &spellInfo->EffectSpellClassMaskA[0]; break; + case 1: ptr = &spellInfo->EffectSpellClassMaskB[0]; break; + case 2: ptr = &spellInfo->EffectSpellClassMaskC[0]; break; + default: 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); - 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() ); @@ -949,7 +958,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) { @@ -965,7 +974,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()) @@ -976,33 +994,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; @@ -1074,80 +1079,10 @@ 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()]); - } - */ -} - -/* -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; + sLog.outString( ">> Loaded %u extra spell proc event conditions", count ); } -*/ bool SpellMgr::IsSpellProcEventCanTriggeredBy(SpellProcEventEntry const * spellProcEvent, uint32 EventProcFlag, SpellEntry const * procSpell, uint32 procFlags, uint32 procExtra, bool active) { @@ -1159,7 +1094,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 @@ -1296,7 +1231,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 @@ -1433,7 +1368,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; @@ -1565,7 +1501,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; value.Id=spell_id; @@ -1789,7 +1725,15 @@ void SpellMgr::LoadSpellLearnSpells() { SpellLearnSpellNode dbc_node; dbc_node.spell = entry->EffectTriggerSpell[i]; - dbc_node.autoLearned = true; + + // 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); @@ -2088,7 +2032,7 @@ void SpellMgr::LoadSpellCustomAttr() } } - if(spellInfo->SpellVisual == 3879) + if(spellInfo->SpellVisual[0] == 3879) mSpellCustomAttr[i] |= SPELL_ATTR_CU_CONE_BACK; switch(i) @@ -2192,6 +2136,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 @@ -2269,7 +2394,7 @@ bool SpellMgr::IsSpellValid(SpellEntry const* spellInfo, Player* pl, bool msg) bool IsSpellAllowedInLocation(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 ) + if( spellInfo->AreaId > 0 && spellInfo->AreaId != zone_id && spellInfo->AreaId != area_id ) return false; // elixirs (all area dependent elixirs have family SPELLFAMILY_POTION, use this for speedup) |