mirror of
https://github.com/azerothcore/mod-learn-spells.git
synced 2026-01-13 00:58:37 +00:00
@@ -1,4 +1,3 @@
|
|||||||
AC_ADD_SCRIPT("${CMAKE_CURRENT_LIST_DIR}/src/mod_learnspells.cpp")
|
AC_ADD_SCRIPT("${CMAKE_CURRENT_LIST_DIR}/src/mod_learnspells.cpp")
|
||||||
AC_ADD_SCRIPT_LOADER("LearnAllSpells" "${CMAKE_CURRENT_LIST_DIR}/src/loader.h")
|
AC_ADD_SCRIPT_LOADER("LearnAllSpells" "${CMAKE_CURRENT_LIST_DIR}/src/loader.h")
|
||||||
|
|
||||||
AC_ADD_CONFIG_FILE("${CMAKE_CURRENT_LIST_DIR}/conf/mod_learnspells.conf.dist")
|
AC_ADD_CONFIG_FILE("${CMAKE_CURRENT_LIST_DIR}/conf/mod_learnspells.conf.dist")
|
||||||
@@ -21,4 +21,4 @@ LearnSpells.LearnAllOnFirstLogin = 0
|
|||||||
# Max level Limit the player will learn spells
|
# Max level Limit the player will learn spells
|
||||||
# Default: = 80
|
# Default: = 80
|
||||||
|
|
||||||
MaxLevel = 80
|
LearnSpells.MaxLevel = 80
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
if( WIN32 )
|
|
||||||
if ( MSVC )
|
|
||||||
add_custom_command(TARGET worldserver
|
|
||||||
POST_BUILD
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_MOD_LEARNSPELLS_DIR}/conf/mod_learnspells.conf.dist" ${CMAKE_BINARY_DIR}/bin/$(ConfigurationName)/
|
|
||||||
)
|
|
||||||
elseif ( MINGW )
|
|
||||||
add_custom_command(TARGET worldserver
|
|
||||||
POST_BUILD
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_MOD_LEARNSPELLS_DIR}/conf/mod_learnspells.conf.dist" ${CMAKE_BINARY_DIR}/bin/
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
install(FILES "${CMAKE_MOD_LEARNSPELLS_DIR}/conf/mod_learnspells.conf.dist" DESTINATION ${CONF_DIR})
|
|
||||||
19
src/loader.h
19
src/loader.h
@@ -1 +1,18 @@
|
|||||||
void AddLearnAllSpellsScripts();
|
/*
|
||||||
|
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
|
||||||
|
* Copyright (C) 2021+ WarheadCore <https://github.com/WarheadCore>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _LEARN_ALL_SPELLS_LOADER_H_
|
||||||
|
#define _LEARN_ALL_SPELLS_LOADER_H_
|
||||||
|
|
||||||
|
// From SC
|
||||||
|
void AddSC_LearnAllSpells();
|
||||||
|
|
||||||
|
// Add all
|
||||||
|
void AddLearnAllSpellsScripts()
|
||||||
|
{
|
||||||
|
AddSC_LearnAllSpells();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _LEARN_ALL_SPELLS_LOADER_H_ */
|
||||||
|
|||||||
@@ -5,57 +5,31 @@
|
|||||||
#include "ScriptMgr.h"
|
#include "ScriptMgr.h"
|
||||||
#include "SpellInfo.h"
|
#include "SpellInfo.h"
|
||||||
|
|
||||||
static bool learnlpells_announce;
|
|
||||||
static bool learnspells_enable;
|
|
||||||
static bool learnspells_onfirstlogin;
|
|
||||||
static uint32 learnspells_maxlevel;
|
|
||||||
|
|
||||||
class LearnAllSpellseBeforeConfigLoad : public WorldScript {
|
|
||||||
public:
|
|
||||||
|
|
||||||
LearnAllSpellseBeforeConfigLoad() : WorldScript("LearnAllSpellseBeforeConfigLoad") { }
|
|
||||||
|
|
||||||
void OnBeforeConfigLoad(bool /*reload*/) override {
|
|
||||||
learnlpells_announce = sConfigMgr->GetBoolDefault("LearnSpells.Announce", 1);
|
|
||||||
learnspells_enable = sConfigMgr->GetBoolDefault("LearnSpells.Enable", 1);
|
|
||||||
learnspells_onfirstlogin = sConfigMgr->GetBoolDefault("LearnSpells.OnFirstLogin", 0);
|
|
||||||
learnspells_maxlevel = sConfigMgr->GetIntDefault("learnspells_maxlevel", 80);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class LearnSpellsOnLevelUp : public PlayerScript
|
class LearnSpellsOnLevelUp : public PlayerScript
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LearnSpellsOnLevelUp() : PlayerScript("LearnSpellsOnLevelUp")
|
LearnSpellsOnLevelUp() : PlayerScript("LearnSpellsOnLevelUp") { }
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnLogin(Player* player) override
|
|
||||||
{
|
|
||||||
if (learnspells_enable && learnlpells_announce){
|
|
||||||
ChatHandler(player->GetSession()).SendSysMessage("This server is running the |cff4CFF00LearnAllSpells |rmodule.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnFirstLogin(Player* player) override
|
void OnFirstLogin(Player* player) override
|
||||||
{
|
{
|
||||||
if (learnspells_onfirstlogin){
|
if (sConfigMgr->GetOption<bool>("LearnSpells.OnFirstLogin", 0))
|
||||||
|
{
|
||||||
LearnSpellsForNewLevel(player, 1);
|
LearnSpellsForNewLevel(player, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnLevelChanged(Player* player, uint8 oldLevel) override
|
void OnLevelChanged(Player* player, uint8 oldLevel) override
|
||||||
{
|
{
|
||||||
if (sConfigMgr->GetBoolDefault("LearnSpells.Enable", true)){
|
if (sConfigMgr->GetOption<bool>("LearnSpells.Enable", true))
|
||||||
if (player->getLevel() <= learnspells_maxlevel){
|
{
|
||||||
if (oldLevel < player->getLevel())
|
if (player->getLevel() <= sConfigMgr->GetOption<uint8>("LearnSpells.MaxLevel", 80) && oldLevel < player->getLevel())
|
||||||
LearnSpellsForNewLevel(player, oldLevel);
|
LearnSpellsForNewLevel(player, oldLevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unordered_set<uint32> m_ignoreSpells = {
|
std::unordered_set<uint32> m_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, 56131, 56160, 56161, 48153, 34754, 64844, 64904, 48085, 33110, 48084,
|
64380, 23885, 23880, 44461, 25346, 10274, 10273, 8418, 8419, 7270, 7269, 7268, 54648, 12536, 24530, 70909, 12494, 57933, 24224, 27095, 27096, 27097, 27099, 32841, 56131, 56160, 56161, 48153, 34754, 64844, 64904, 48085, 33110, 48084,
|
||||||
28276, 27874, 27873, 7001, 49821, 53022, 47757, 47750, 47758, 47666, 53001, 52983, 52998, 52986, 52987, 52999, 52984, 53002, 53003, 53000, 52988, 52985, 42208, 42209, 42210, 42211, 42212, 42213, 42198, 42937, 42938, 12484, 12485, 12486,
|
28276, 27874, 27873, 7001, 49821, 53022, 47757, 47750, 47758, 47666, 53001, 52983, 52998, 52986, 52987, 52999, 52984, 53002, 53003, 53000, 52988, 52985, 42208, 42209, 42210, 42211, 42212, 42213, 42198, 42937, 42938, 12484, 12485, 12486,
|
||||||
44461, 55361, 55362, 34913, 43043, 43044, 38703, 38700, 27076, 42844, 42845, 64891, 25912, 25914, 25911, 25913, 25902, 25903, 27175, 27176, 33073, 33074, 48822, 48820, 48823, 48821, 20154, 25997, 20467, 20425, 67, 26017, 34471, 53254,
|
44461, 55361, 55362, 34913, 43043, 43044, 38703, 38700, 27076, 42844, 42845, 64891, 25912, 25914, 25911, 25913, 25902, 25903, 27175, 27176, 33073, 33074, 48822, 48820, 48823, 48821, 20154, 25997, 20467, 20425, 67, 26017, 34471, 53254,
|
||||||
@@ -80,7 +54,8 @@ class LearnSpellsOnLevelUp : public PlayerScript
|
|||||||
using AdditionalSpellsList = std::unordered_map<uint8, SpellFamilyToExtraSpells>;
|
using AdditionalSpellsList = std::unordered_map<uint8, SpellFamilyToExtraSpells>;
|
||||||
// -------------------------------------------- ^^^^^ level
|
// -------------------------------------------- ^^^^^ level
|
||||||
|
|
||||||
AdditionalSpellsList m_additionalSpells = {
|
AdditionalSpellsList m_additionalSpells =
|
||||||
|
{
|
||||||
{6,
|
{6,
|
||||||
{
|
{
|
||||||
{SPELLFAMILY_WARRIOR,
|
{SPELLFAMILY_WARRIOR,
|
||||||
@@ -218,8 +193,7 @@ class LearnSpellsOnLevelUp : public PlayerScript
|
|||||||
|
|
||||||
bool IsIgnoredSpell(uint32 spellID)
|
bool IsIgnoredSpell(uint32 spellID)
|
||||||
{
|
{
|
||||||
auto spellIt = m_ignoreSpells.find(spellID);
|
return m_ignoreSpells.find(spellID) != m_ignoreSpells.end();
|
||||||
return spellIt != m_ignoreSpells.end();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LearnSpellsForNewLevel(Player* player, uint8 fromLevel)
|
void LearnSpellsForNewLevel(Player* player, uint8 fromLevel)
|
||||||
@@ -230,22 +204,29 @@ class LearnSpellsOnLevelUp : public PlayerScript
|
|||||||
for (int level = fromLevel; level <= upToLevel; level++)
|
for (int level = fromLevel; level <= upToLevel; level++)
|
||||||
{
|
{
|
||||||
ApplyAdditionalSpells(level, family, player);
|
ApplyAdditionalSpells(level, family, player);
|
||||||
|
|
||||||
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 ((spellInfo->AttributesEx7 & SPELL_ATTR7_ALLIANCE_ONLY && player->GetTeamId() != TEAM_ALLIANCE) || (spellInfo->AttributesEx7 & SPELL_ATTR7_HORDE_ONLY && player->GetTeamId() != TEAM_HORDE))
|
|
||||||
|
if ((spellInfo->AttributesEx7 & SPELL_ATTR7_ALLIANCE_SPECIFIC_SPELL && player->GetTeamId() != TEAM_ALLIANCE) || (spellInfo->AttributesEx7 & SPELL_ATTR7_HORDE_SPECIFIC_SPELL && player->GetTeamId() != TEAM_HORDE))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (spellInfo->PowerType == POWER_FOCUS)
|
if (spellInfo->PowerType == POWER_FOCUS)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (IsIgnoredSpell(spellInfo->Id))
|
if (IsIgnoredSpell(spellInfo->Id))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, spellInfo->Id, player))
|
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, spellInfo->Id, player))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (spellInfo->BaseLevel != uint32(level) && sSpellMgr->IsSpellValid(spellInfo))
|
if (spellInfo->BaseLevel != uint32(level) && sSpellMgr->IsSpellValid(spellInfo))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -253,20 +234,23 @@ class LearnSpellsOnLevelUp : public PlayerScript
|
|||||||
|
|
||||||
SkillLineAbilityMapBounds bounds = sSpellMgr->GetSkillLineAbilityMapBounds(spellInfo->Id);
|
SkillLineAbilityMapBounds bounds = sSpellMgr->GetSkillLineAbilityMapBounds(spellInfo->Id);
|
||||||
|
|
||||||
for (SkillLineAbilityMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr)
|
for (auto 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))
|
||||||
{
|
{
|
||||||
valid = false;
|
valid = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -283,6 +267,7 @@ class LearnSpellsOnLevelUp : public PlayerScript
|
|||||||
if (spells != m_additionalSpells.end())
|
if (spells != m_additionalSpells.end())
|
||||||
{
|
{
|
||||||
SpellFamilyToExtraSpells spellsMap = spells->second;
|
SpellFamilyToExtraSpells spellsMap = spells->second;
|
||||||
|
|
||||||
auto spellsForPlayersFamily = spellsMap.find(playerSpellFamily);
|
auto spellsForPlayersFamily = spellsMap.find(playerSpellFamily);
|
||||||
if (spellsForPlayersFamily != spellsMap.end())
|
if (spellsForPlayersFamily != spellsMap.end())
|
||||||
{
|
{
|
||||||
@@ -328,8 +313,7 @@ class LearnSpellsOnLevelUp : public PlayerScript
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void AddLearnAllSpellsScripts()
|
void AddSC_LearnAllSpells()
|
||||||
{
|
{
|
||||||
new LearnAllSpellseBeforeConfigLoad();
|
|
||||||
new LearnSpellsOnLevelUp();
|
new LearnSpellsOnLevelUp();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user