mirror of
https://github.com/azerothcore/mod-learn-spells.git
synced 2026-01-13 00:58:37 +00:00
Merge pull request #1 from talamortis/master
update script also fix indentations
This commit is contained in:
@@ -11,3 +11,8 @@ LearnSpells.Enable = 1
|
|||||||
# Announce the module when the player logs in?
|
# Announce the module when the player logs in?
|
||||||
|
|
||||||
LearnSpells.Announce = 1
|
LearnSpells.Announce = 1
|
||||||
|
|
||||||
|
# Max level Limit the player will learn spells
|
||||||
|
# Default: = 80
|
||||||
|
|
||||||
|
MaxLevel = 80
|
||||||
|
|||||||
@@ -1,49 +1,52 @@
|
|||||||
#include "ScriptPCH.h"
|
#include "ScriptPCH.h"
|
||||||
#include "DisableMgr.h"
|
#include "DisableMgr.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
#include "Player.h"
|
||||||
|
|
||||||
|
uint32 MaxLevel;
|
||||||
|
|
||||||
class LearnSpellsOnLevelUp : public PlayerScript
|
class LearnSpellsOnLevelUp : public PlayerScript
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::vector<uint32> ignoreSpells;
|
std::vector<uint32> ignoreSpells;
|
||||||
|
|
||||||
LearnSpellsOnLevelUp() : PlayerScript("LearnSpellsOnLevelUp")
|
LearnSpellsOnLevelUp() : PlayerScript("LearnSpellsOnLevelUp")
|
||||||
{
|
{
|
||||||
uint32 temp[] = {
|
uint32 temp[] = {
|
||||||
64380, 23885, 23880, 44461, 25346, 10274, 10273, 8418,
|
64380, 23885, 23880, 44461, 25346, 10274, 10273, 8418,
|
||||||
8419, 7270, 7269, 7268, 54648, 12536, 24530, 70909,
|
8419, 7270, 7269, 7268, 54648, 12536, 24530, 70909,
|
||||||
12494, 57933, 24224, 27095, 27096, 27097, 27099, 32841,
|
12494, 57933, 24224, 27095, 27096, 27097, 27099, 32841,
|
||||||
56131, 56160, 56161, 48153, 34754, 64844, 64904, 48085,
|
56131, 56160, 56161, 48153, 34754, 64844, 64904, 48085,
|
||||||
33110, 48084, 28276, 27874, 27873, 7001, 49821, 53022,
|
33110, 48084, 28276, 27874, 27873, 7001, 49821, 53022,
|
||||||
47757, 47750, 47758, 47666, 53001, 52983, 52998, 52986,
|
47757, 47750, 47758, 47666, 53001, 52983, 52998, 52986,
|
||||||
52987, 52999, 52984, 53002, 53003, 53000, 52988, 52985,
|
52987, 52999, 52984, 53002, 53003, 53000, 52988, 52985,
|
||||||
42208, 42209, 42210, 42211, 42212, 42213, 42198, 42937,
|
42208, 42209, 42210, 42211, 42212, 42213, 42198, 42937,
|
||||||
42938, 12484, 12485, 12486, 44461, 55361, 55362, 34913,
|
42938, 12484, 12485, 12486, 44461, 55361, 55362, 34913,
|
||||||
43043, 43044, 38703, 38700, 27076, 42844, 42845, 64891,
|
43043, 43044, 38703, 38700, 27076, 42844, 42845, 64891,
|
||||||
25912, 25914, 25911, 25913, 25902, 25903, 27175, 27176,
|
25912, 25914, 25911, 25913, 25902, 25903, 27175, 27176,
|
||||||
33073, 33074, 48822, 48820, 48823, 48821, 20154, 25997,
|
33073, 33074, 48822, 48820, 48823, 48821, 20154, 25997,
|
||||||
20467, 20425, 67, 26017, 34471, 53254, 13812, 14314,
|
20467, 20425, 67, 26017, 34471, 53254, 13812, 14314,
|
||||||
14315, 27026, 49064, 49065, 60202, 60210, 13797, 14298,
|
14315, 27026, 49064, 49065, 60202, 60210, 13797, 14298,
|
||||||
14299, 14300, 14301, 27024, 49053, 49054, 52399, 1742,
|
14299, 14300, 14301, 27024, 49053, 49054, 52399, 1742,
|
||||||
24453, 53548, 53562, 52016, 26064, 35346, 57386, 57389,
|
24453, 53548, 53562, 52016, 26064, 35346, 57386, 57389,
|
||||||
57390, 57391, 57392, 57393, 55509, 35886, 43339, 45297,
|
57390, 57391, 57392, 57393, 55509, 35886, 43339, 45297,
|
||||||
45298, 45299, 45300, 45301, 45302, 49268, 49269, 8349,
|
45298, 45299, 45300, 45301, 45302, 49268, 49269, 8349,
|
||||||
8502, 8503, 11306, 11307, 25535, 25537, 61650, 61654,
|
8502, 8503, 11306, 11307, 25535, 25537, 61650, 61654,
|
||||||
63685, 45284, 45286, 45287, 45288, 45289, 45290, 45291,
|
63685, 45284, 45286, 45287, 45288, 45289, 45290, 45291,
|
||||||
45292, 45293, 45294, 45295, 45296, 49239, 49240, 26364,
|
45292, 45293, 45294, 45295, 45296, 49239, 49240, 26364,
|
||||||
26365, 26366, 26367, 26369, 26370, 26363, 26371, 26372,
|
26365, 26366, 26367, 26369, 26370, 26363, 26371, 26372,
|
||||||
49278, 49279, 32176, 32175, 21169, 47206, 27285, 47833,
|
49278, 49279, 32176, 32175, 21169, 47206, 27285, 47833,
|
||||||
47836, 42223, 42224, 42225, 42226, 42218, 47817, 47818,
|
47836, 42223, 42224, 42225, 42226, 42218, 47817, 47818,
|
||||||
42231, 42232, 42233, 42230, 48466, 44203, 44205, 44206,
|
42231, 42232, 42233, 42230, 48466, 44203, 44205, 44206,
|
||||||
44207, 44208, 48444, 48445, 33891, 52374, 57532, 59921,
|
44207, 44208, 48444, 48445, 33891, 52374, 57532, 59921,
|
||||||
52372, 49142, 52375, 47633, 47632, 52373, 50536, 27214,
|
52372, 49142, 52375, 47633, 47632, 52373, 50536, 27214,
|
||||||
47822, 11682, 11681, 5857, 1010, 24907, 24905, 53227,
|
47822, 11682, 11681, 5857, 1010, 24907, 24905, 53227,
|
||||||
61391, 61390, 61388, 61387, 64801, 5421, 9635, 1178,
|
61391, 61390, 61388, 61387, 64801, 5421, 9635, 1178,
|
||||||
20186, 20185, 20184, 20187, 25899, 24406, 50581, 30708
|
20186, 20185, 20184, 20187, 25899, 24406, 50581, 30708
|
||||||
};
|
};
|
||||||
|
|
||||||
ignoreSpells = std::vector<uint32> (temp, temp + sizeof(temp)/sizeof(temp[0]));
|
ignoreSpells = std::vector<uint32>(temp, temp + sizeof(temp) / sizeof(temp[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnLogin(Player *player)
|
void OnLogin(Player *player)
|
||||||
{
|
{
|
||||||
@@ -56,86 +59,89 @@ class LearnSpellsOnLevelUp : public PlayerScript
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnLevelChanged(Player* player, uint8 oldLevel)
|
void OnLevelChanged(Player* player, uint8 oldLevel)
|
||||||
{
|
{
|
||||||
if (sConfigMgr->GetBoolDefault("LearnSpells.Enable", true))
|
if (sConfigMgr->GetBoolDefault("LearnSpells.Enable", true))
|
||||||
{
|
{
|
||||||
if (oldLevel < player->getLevel())
|
if (player->getLevel() < MaxLevel)
|
||||||
LearnSpellsForNewLevel(player, oldLevel);
|
{
|
||||||
}
|
if (oldLevel < player->getLevel())
|
||||||
}
|
LearnSpellsForNewLevel(player, oldLevel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool IsIgnoredSpell(uint32 spellID)
|
bool IsIgnoredSpell(uint32 spellID)
|
||||||
{
|
{
|
||||||
for (std::vector<uint32>::const_iterator itr = ignoreSpells.begin(); itr != ignoreSpells.end(); ++itr)
|
for (std::vector<uint32>::const_iterator itr = ignoreSpells.begin(); itr != ignoreSpells.end(); ++itr)
|
||||||
if (spellID == (*itr))
|
if (spellID == (*itr))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LearnSpellsForNewLevel(Player* player, uint8 level)
|
void LearnSpellsForNewLevel(Player* player, uint8 level)
|
||||||
{
|
{
|
||||||
if (level == player->getLevel() + 1)
|
if (level == player->getLevel() + 1)
|
||||||
return;
|
return;
|
||||||
uint32 family;
|
uint32 family;
|
||||||
switch(player->getClass())
|
switch (player->getClass())
|
||||||
{
|
{
|
||||||
case CLASS_ROGUE:
|
case CLASS_ROGUE:
|
||||||
family = SPELLFAMILY_ROGUE;
|
family = SPELLFAMILY_ROGUE;
|
||||||
break;
|
break;
|
||||||
case CLASS_DEATH_KNIGHT:
|
case CLASS_DEATH_KNIGHT:
|
||||||
family = SPELLFAMILY_DEATHKNIGHT;
|
family = SPELLFAMILY_DEATHKNIGHT;
|
||||||
break;
|
break;
|
||||||
case CLASS_WARRIOR:
|
case CLASS_WARRIOR:
|
||||||
family = SPELLFAMILY_WARRIOR;
|
family = SPELLFAMILY_WARRIOR;
|
||||||
break;
|
break;
|
||||||
case CLASS_PRIEST:
|
case CLASS_PRIEST:
|
||||||
family = SPELLFAMILY_PRIEST;
|
family = SPELLFAMILY_PRIEST;
|
||||||
break;
|
break;
|
||||||
case CLASS_MAGE:
|
case CLASS_MAGE:
|
||||||
family = SPELLFAMILY_MAGE;
|
family = SPELLFAMILY_MAGE;
|
||||||
break;
|
break;
|
||||||
case CLASS_PALADIN:
|
case CLASS_PALADIN:
|
||||||
family = SPELLFAMILY_PALADIN;
|
family = SPELLFAMILY_PALADIN;
|
||||||
break;
|
break;
|
||||||
case CLASS_HUNTER:
|
case CLASS_HUNTER:
|
||||||
family = SPELLFAMILY_HUNTER;
|
family = SPELLFAMILY_HUNTER;
|
||||||
break;
|
break;
|
||||||
case CLASS_DRUID:
|
case CLASS_DRUID:
|
||||||
family = SPELLFAMILY_DRUID;
|
family = SPELLFAMILY_DRUID;
|
||||||
break;
|
break;
|
||||||
case CLASS_SHAMAN:
|
case CLASS_SHAMAN:
|
||||||
family = SPELLFAMILY_SHAMAN;
|
family = SPELLFAMILY_SHAMAN;
|
||||||
break;
|
break;
|
||||||
case CLASS_WARLOCK:
|
case CLASS_WARLOCK:
|
||||||
family = SPELLFAMILY_WARLOCK;
|
family = SPELLFAMILY_WARLOCK;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (uint32 i = 0; i < sSpellMgr->GetSpellInfoStoreSize(); ++i)
|
for (uint32 i = 0; i < sSpellMgr->GetSpellInfoStoreSize(); ++i)
|
||||||
{
|
{
|
||||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(i);
|
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(i);
|
||||||
if (!spellInfo)
|
if (!spellInfo)
|
||||||
continue;
|
continue;
|
||||||
if (spellInfo->SpellFamilyName != family)
|
if (spellInfo->SpellFamilyName != family)
|
||||||
continue;
|
continue;
|
||||||
if (IsIgnoredSpell(spellInfo->Id))
|
if (IsIgnoredSpell(spellInfo->Id))
|
||||||
continue;
|
continue;
|
||||||
if (spellInfo->PowerType == POWER_FOCUS)
|
if (spellInfo->PowerType == POWER_FOCUS)
|
||||||
continue;
|
continue;
|
||||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, spellInfo->Id, player))
|
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, spellInfo->Id, player))
|
||||||
continue;
|
continue;
|
||||||
if ((spellInfo->AttributesEx7 & SPELL_ATTR7_ALLIANCE_ONLY && player->GetTeamId() != ALLIANCE) || (spellInfo->AttributesEx7 & SPELL_ATTR7_HORDE_ONLY && player->GetTeamId() != HORDE))
|
if ((spellInfo->AttributesEx7 & SPELL_ATTR7_ALLIANCE_ONLY && player->GetTeamId() != ALLIANCE) || (spellInfo->AttributesEx7 & SPELL_ATTR7_HORDE_ONLY && player->GetTeamId() != HORDE))
|
||||||
continue;
|
continue;
|
||||||
if (spellInfo->BaseLevel != level && sSpellMgr->IsSpellValid(spellInfo))
|
if (spellInfo->BaseLevel != level && sSpellMgr->IsSpellValid(spellInfo))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
|
|
||||||
SkillLineAbilityMapBounds bounds = sSpellMgr->GetSkillLineAbilityMapBounds(spellInfo->Id);
|
SkillLineAbilityMapBounds bounds = sSpellMgr->GetSkillLineAbilityMapBounds(spellInfo->Id);
|
||||||
for (SkillLineAbilityMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr)
|
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)
|
if (itr->second->spellId == spellInfo->Id && itr->second->racemask == 0 && itr->second->learnOnGetSkill == 0)
|
||||||
{
|
{
|
||||||
valid = true;
|
valid = true;
|
||||||
SpellInfo const* prevSpell = spellInfo->GetPrevRankSpell();
|
SpellInfo const* prevSpell = spellInfo->GetPrevRankSpell();
|
||||||
if (prevSpell && !player->HasSpell(prevSpell->Id))
|
if (prevSpell && !player->HasSpell(prevSpell->Id))
|
||||||
@@ -146,40 +152,42 @@ class LearnSpellsOnLevelUp : public PlayerScript
|
|||||||
if (GetTalentSpellPos(itr->second->spellId))
|
if (GetTalentSpellPos(itr->second->spellId))
|
||||||
if (!prevSpell || !player->HasSpell(prevSpell->Id) || spellInfo->GetRank() == 1)
|
if (!prevSpell || !player->HasSpell(prevSpell->Id) || spellInfo->GetRank() == 1)
|
||||||
valid = false;
|
valid = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valid)
|
if (valid)
|
||||||
player->learnSpell(spellInfo->Id);
|
player->learnSpell(spellInfo->Id);
|
||||||
}
|
}
|
||||||
LearnSpellsForNewLevel(player, ++level);
|
LearnSpellsForNewLevel(player, ++level);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class LearnAllSpellsWorld : public WorldScript
|
class LearnAllSpellsWorld : public WorldScript
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LearnAllSpellsWorld() : WorldScript("LearnAllSpellsWorld") { }
|
LearnAllSpellsWorld() : WorldScript("LearnAllSpellsWorld") { }
|
||||||
|
|
||||||
void OnBeforeConfigLoad(bool reload) override
|
void OnBeforeConfigLoad(bool reload) override
|
||||||
{
|
{
|
||||||
if (!reload) {
|
if (!reload) {
|
||||||
std::string conf_path = _CONF_DIR;
|
std::string conf_path = _CONF_DIR;
|
||||||
std::string cfg_file = conf_path + "/mod_learnspells.conf";
|
std::string cfg_file = conf_path + "/mod_learnspells.conf";
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
cfg_file = "mod_learnspells.conf";
|
cfg_file = "mod_learnspells.conf";
|
||||||
#endif
|
#endif
|
||||||
std::string cfg_def_file = cfg_file + ".dist";
|
std::string cfg_def_file = cfg_file + ".dist";
|
||||||
sConfigMgr->LoadMore(cfg_def_file.c_str());
|
sConfigMgr->LoadMore(cfg_def_file.c_str());
|
||||||
|
|
||||||
sConfigMgr->LoadMore(cfg_file.c_str());
|
sConfigMgr->LoadMore(cfg_file.c_str());
|
||||||
}
|
|
||||||
}
|
MaxLevel = sConfigMgr->GetIntDefault("MaxLevel", 80);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void AddLearnAllSpellsScripts()
|
void AddLearnAllSpellsScripts()
|
||||||
{
|
{
|
||||||
new LearnAllSpellsWorld();
|
new LearnAllSpellsWorld();
|
||||||
new LearnSpellsOnLevelUp();
|
new LearnSpellsOnLevelUp();
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user