mirror of
https://github.com/azerothcore/mod-learn-spells.git
synced 2026-01-13 00:58:37 +00:00
feat(cpp/conf): Add option to teach all spells on first login (#9)
- Adds a `LearnAllOnFirstLogin` (default: false) option to teach the player all the spells when he first logs in, - Disabled by default because of performance concerns, - Slight optimizations have been added to mitigate this issue - However enabling this on a more populous server could cause issues due to the current design of the module
This commit is contained in:
@@ -12,6 +12,12 @@ LearnSpells.Enable = 1
|
||||
|
||||
LearnSpells.Announce = 1
|
||||
|
||||
# Should the player receive all spells on first login?
|
||||
# Useful for instant leveling type of servers
|
||||
# (1: true | 0: false)
|
||||
|
||||
LearnSpells.LearnAllOnFirstLogin = 0
|
||||
|
||||
# Max level Limit the player will learn spells
|
||||
# Default: = 80
|
||||
|
||||
|
||||
@@ -10,12 +10,7 @@ uint32 MaxLevel;
|
||||
class LearnSpellsOnLevelUp : public PlayerScript
|
||||
{
|
||||
public:
|
||||
std::vector<uint32> ignoreSpells;
|
||||
|
||||
LearnSpellsOnLevelUp() : PlayerScript("LearnSpellsOnLevelUp")
|
||||
{
|
||||
uint32 temp[] =
|
||||
{
|
||||
std::unordered_set<uint32> ignoreSpells = {
|
||||
64380, 23885, 23880, 44461, 25346, 10274, 10273, 8418,
|
||||
8419, 7270, 7269, 7268, 54648, 12536, 24530, 70909,
|
||||
12494, 57933, 24224, 27095, 27096, 27097, 27099, 32841,
|
||||
@@ -52,10 +47,11 @@ public:
|
||||
18848, 16979, 49376, 54055, 20647, 42243, 24131
|
||||
};
|
||||
|
||||
ignoreSpells = std::vector<uint32>(temp, temp + sizeof(temp) / sizeof(temp[0]));
|
||||
LearnSpellsOnLevelUp() : PlayerScript("LearnSpellsOnLevelUp")
|
||||
{
|
||||
}
|
||||
|
||||
void OnLogin(Player *player)
|
||||
void OnLogin(Player *player) override
|
||||
{
|
||||
if (sConfigMgr->GetBoolDefault("LearnSpells.Enable", true))
|
||||
{
|
||||
@@ -66,7 +62,15 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void OnLevelChanged(Player* player, uint8 oldLevel)
|
||||
void OnFirstLogin(Player *player) override
|
||||
{
|
||||
if (sConfigMgr->GetBoolDefault("LearnSpells.LearnAllOnFirstLogin", false))
|
||||
{
|
||||
LearnSpellsForNewLevel(player, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void OnLevelChanged(Player *player, uint8 oldLevel) override
|
||||
{
|
||||
if (sConfigMgr->GetBoolDefault("LearnSpells.Enable", true))
|
||||
{
|
||||
@@ -80,13 +84,11 @@ public:
|
||||
|
||||
bool IsIgnoredSpell(uint32 spellID)
|
||||
{
|
||||
for (std::vector<uint32>::const_iterator itr = ignoreSpells.begin(); itr != ignoreSpells.end(); ++itr)
|
||||
if (spellID == (*itr))
|
||||
return true;
|
||||
return false;
|
||||
auto spellIt = ignoreSpells.find(spellID);
|
||||
return spellIt != ignoreSpells.end();
|
||||
}
|
||||
|
||||
void LearnSpellsForNewLevel(Player* player, uint8 level)
|
||||
void LearnSpellsForNewLevel(Player *player, uint8 level)
|
||||
{
|
||||
if (level == player->getLevel() + 1)
|
||||
return;
|
||||
@@ -126,18 +128,18 @@ public:
|
||||
}
|
||||
for (uint32 i = 0; i < sSpellMgr->GetSpellInfoStoreSize(); ++i)
|
||||
{
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(i);
|
||||
SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(i);
|
||||
if (!spellInfo)
|
||||
continue;
|
||||
if (spellInfo->SpellFamilyName != family)
|
||||
continue;
|
||||
if (IsIgnoredSpell(spellInfo->Id))
|
||||
if ((spellInfo->AttributesEx7 & SPELL_ATTR7_ALLIANCE_ONLY && player->GetTeamId() != TEAM_ALLIANCE) || (spellInfo->AttributesEx7 & SPELL_ATTR7_HORDE_ONLY && player->GetTeamId() != TEAM_HORDE))
|
||||
continue;
|
||||
if (spellInfo->PowerType == POWER_FOCUS)
|
||||
continue;
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, spellInfo->Id, player))
|
||||
if (IsIgnoredSpell(spellInfo->Id))
|
||||
continue;
|
||||
if ((spellInfo->AttributesEx7 & SPELL_ATTR7_ALLIANCE_ONLY && player->GetTeamId() != TEAM_ALLIANCE) || (spellInfo->AttributesEx7 & SPELL_ATTR7_HORDE_ONLY && player->GetTeamId() != TEAM_HORDE))
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, spellInfo->Id, player))
|
||||
continue;
|
||||
if (spellInfo->BaseLevel != level && sSpellMgr->IsSpellValid(spellInfo))
|
||||
continue;
|
||||
@@ -150,7 +152,7 @@ public:
|
||||
if (itr->second->spellId == spellInfo->Id && itr->second->racemask == 0 && itr->second->learnOnGetSkill == 0)
|
||||
{
|
||||
valid = true;
|
||||
SpellInfo const* prevSpell = spellInfo->GetPrevRankSpell();
|
||||
SpellInfo const *prevSpell = spellInfo->GetPrevRankSpell();
|
||||
if (prevSpell && !player->HasSpell(prevSpell->Id))
|
||||
{
|
||||
valid = false;
|
||||
@@ -173,11 +175,12 @@ public:
|
||||
class LearnAllSpellsWorld : public WorldScript
|
||||
{
|
||||
public:
|
||||
LearnAllSpellsWorld() : WorldScript("LearnAllSpellsWorld") { }
|
||||
LearnAllSpellsWorld() : WorldScript("LearnAllSpellsWorld") {}
|
||||
|
||||
void OnBeforeConfigLoad(bool reload) override
|
||||
{
|
||||
if (!reload) {
|
||||
if (!reload)
|
||||
{
|
||||
std::string conf_path = _CONF_DIR;
|
||||
std::string cfg_file = conf_path + "/mod_learnspells.conf";
|
||||
#ifdef WIN32
|
||||
|
||||
Reference in New Issue
Block a user