void OnLevelChanged(Player* player, uint8 oldLevel) { bool EnableAutoLearnSpell = ConfigMgr::GetBoolDefault("Enable.Learn.Spell.On.Level.Up", true); if (EnableAutoLearnSpell) { if (oldLevel < player->getLevel()) LearnSpellsForNewLevel(player, oldLevel); } }
void LearnSpellsForNewLevel(Player* player, uint8 level) { if (level == player->getLevel() + 1) return; uint32 family; switch(player->getClass()) { case CLASS_ROGUE: family = SPELLFAMILY_ROGUE; break; case CLASS_DEATH_KNIGHT: family = SPELLFAMILY_DEATHKNIGHT; break; case CLASS_WARRIOR: family = SPELLFAMILY_WARRIOR; break; case CLASS_PRIEST: family = SPELLFAMILY_PRIEST; break; case CLASS_MAGE: family = SPELLFAMILY_MAGE; break; case CLASS_PALADIN: family = SPELLFAMILY_PALADIN; break; case CLASS_HUNTER: family = SPELLFAMILY_HUNTER; break; case CLASS_DRUID: family = SPELLFAMILY_DRUID; break; case CLASS_SHAMAN: family = SPELLFAMILY_SHAMAN; break; case CLASS_WARLOCK: family = SPELLFAMILY_WARLOCK; break; } for (uint32 i = 0; i < sSpellMgr->GetSpellInfoStoreSize(); ++i) { SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(i); if (!spellInfo) continue; if (spellInfo->SpellFamilyName != family) continue; if (IsIgnoredSpell(spellInfo->Id)) continue; if (spellInfo->PowerType == POWER_FOCUS) continue; if (DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, spellInfo->Id, player)) continue; if ((spellInfo->AttributesEx7 & SPELL_ATTR7_ALLIANCE_ONLY && player->GetTeam() != ALLIANCE) || (spellInfo->AttributesEx7 & SPELL_ATTR7_HORDE_ONLY && player->GetTeam() != HORDE)) continue; if (spellInfo->BaseLevel != level && sSpellMgr->IsSpellValid(spellInfo, player)) continue; bool valid = false; SkillLineAbilityMapBounds bounds = sSpellMgr->GetSkillLineAbilityMapBounds(spellInfo->Id); for (SkillLineAbilityMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr) { if (itr->second->spellId == spellInfo->Id && itr->second->racemask == 0 && itr->second->learnOnGetSkill == 0) { valid = true; SpellInfo const* prevSpell = spellInfo->GetPrevRankSpell(); if (prevSpell && !player->HasSpell(prevSpell->Id)) { valid = false; break; } if (GetTalentSpellPos(itr->second->spellId)) if (!prevSpell || !player->HasSpell(prevSpell->Id) || spellInfo->GetRank() == 1) valid = false; break; } } if (valid) player->learnSpell(spellInfo->Id, false); } LearnSpellsForNewLevel(player, ++level); }
void OnLevelChanged(Player* player, uint8 oldLevel) { if (oldLevel < player->getLevel()) LearnSpellsForNewLevel(player, oldLevel); }