diff --git a/.gitignore b/.gitignore index c6e1299..66b40c8 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ CMakeLists.txt.user *.BACKUP.* *.BASE.* *.LOCAL.* +*.conf # # IDE & other softwares diff --git a/conf/mod_account_mount.conf.dist b/conf/mod_account_mount.conf.dist index 3816e6b..02a2e28 100644 --- a/conf/mod_account_mount.conf.dist +++ b/conf/mod_account_mount.conf.dist @@ -11,3 +11,8 @@ Account.Mounts.Enable = 1 # Announce the module when the player logs in? Account.Mounts.Announce = 0 + +# Excluded Spell IDs (comma-separated, no space). See example below +# Account.Mounts.ExcludedSpellIDs = 470,578,6777 + +Account.Mounts.ExcludedSpellIDs = 0 \ No newline at end of file diff --git a/src/mod_account_mount.cpp b/src/mod_account_mount.cpp index 0eabf50..3223641 100644 --- a/src/mod_account_mount.cpp +++ b/src/mod_account_mount.cpp @@ -2,14 +2,34 @@ #include "ScriptMgr.h" #include "Chat.h" #include "Player.h" +#include // Required for std::set -- might be redundant +#include // Required for std::istringstream -- might be redundant +#include // Required for std::string -- might be redundant class AccountMounts : public PlayerScript { - static const bool limitrace = false; // This set to true will only learn mounts from chars on the same team, do what you want. + static const bool limitrace = true; // This set to true will only learn mounts from chars on the same team, do what you want. + std::set excludedSpellIds; // Set to hold the Spell IDs to be excluded public: - AccountMounts() : PlayerScript("AccountMounts") { } - + AccountMounts() : PlayerScript("AccountMounts") + { + // Retrieve the string of excluded Spell IDs from the config file + std::string excludedSpellsStr = sConfigMgr->GetOption("Account.Mounts.ExcludedSpellIDs", ""); + // Proceed only if the configuration is not "0" or empty, indicating exclusions are specified + if (excludedSpellsStr != "0" && !excludedSpellsStr.empty()) + { + std::istringstream spellStream(excludedSpellsStr); + std::string spellIdStr; + while (std::getline(spellStream, spellIdStr, ',')) { + uint32 spellId = static_cast(std::stoul(spellIdStr)); + if (spellId != 0) { // Ensure the spell ID is not 0, as 0 is used to indicate no exclusions + excludedSpellIds.insert(spellId); // Add the Spell ID to the set of exclusions + } + } + } + } + void OnLogin(Player* pPlayer) { if (sConfigMgr->GetOption("Account.Mounts.Enable", true)) @@ -32,7 +52,7 @@ public: uint32 race = fields[1].Get(); if ((Player::TeamIdForRace(race) == Player::TeamIdForRace(pPlayer->getRace())) || !limitrace) - Guids.push_back(result1->Fetch()[0].Get()); + Guids.push_back(fields[0].Get()); } while (result1->NextRow()); @@ -52,9 +72,13 @@ public: for (auto& i : Spells) { - auto sSpell = sSpellStore.LookupEntry(i); - if (sSpell->Effect[0] == SPELL_EFFECT_APPLY_AURA && sSpell->EffectApplyAuraName[0] == SPELL_AURA_MOUNTED) - pPlayer->learnSpell(sSpell->Id); + // Check if the spell is in the excluded list before learning it + if (excludedSpellIds.find(i) == excludedSpellIds.end()) + { + auto sSpell = sSpellStore.LookupEntry(i); + if (sSpell->Effect[0] == SPELL_EFFECT_APPLY_AURA && sSpell->EffectApplyAuraName[0] == SPELL_AURA_MOUNTED) + pPlayer->learnSpell(sSpell->Id); + } } } }