diff --git a/conf/CFBG.conf.dist b/conf/CFBG.conf.dist index 2cb0565..0fed691 100644 --- a/conf/CFBG.conf.dist +++ b/conf/CFBG.conf.dist @@ -40,6 +40,16 @@ # Default: 1 - (Enabled) # 0 - (Disabled) # +# CFBG.Battlefield.SkipClasses +# Description: Comma-separated list of class IDs excluded from Wintergrasp +# cross-faction selection. Players of these classes always keep +# their native faction and are never morphed/reassigned. +# Class IDs: 1 Warrior, 2 Paladin, 3 Hunter, 4 Rogue, 5 Priest, +# 6 Death Knight, 7 Shaman, 8 Mage, 9 Warlock, 11 Druid. +# Requires CFBG.Battlefield.Enable = 1. +# Example: "2,7" - (Paladins and Shamans stay native) +# Default: "" - (no class skipped) +# # CFBG.Include.Avg.Ilvl.Enable # Description: Enable check average item level for bg # Default: 0 @@ -101,6 +111,7 @@ CFBG.Enable = 1 CFBG.Battlefield.Enable = 1 CFBG.Battlefield.TeamLock.Enable = 1 CFBG.Battlefield.ReapplyOnResurrect.Enable = 1 +CFBG.Battlefield.SkipClasses = "" CFBG.BalancedTeams = 1 CFBG.BalancedTeams.Class.LowLevel = 0 CFBG.BalancedTeams.Class.MinLevel = 10 diff --git a/src/CFBG.cpp b/src/CFBG.cpp index c89e280..d55b1be 100644 --- a/src/CFBG.cpp +++ b/src/CFBG.cpp @@ -14,6 +14,8 @@ #include "Opcodes.h" #include "ReputationMgr.h" #include "ScriptMgr.h" +#include "StringConvert.h" +#include "Tokenize.h" #include "GameTime.h" #include "Player.h" #include "WorldSessionMgr.h" @@ -152,6 +154,14 @@ void CFBG::LoadConfig() _IsEnableWGSystem = sConfigMgr->GetOption("CFBG.Battlefield.Enable", true); _IsEnableWGTeamLock = sConfigMgr->GetOption("CFBG.Battlefield.TeamLock.Enable", true); _IsEnableWGReapplyOnResurrect = sConfigMgr->GetOption("CFBG.Battlefield.ReapplyOnResurrect.Enable", true); + + _wgSkipClasses.clear(); + for (auto const& token : Acore::Tokenize(sConfigMgr->GetOption("CFBG.Battlefield.SkipClasses", ""), ',', false)) + { + if (Optional playerClass = Acore::StringTo(token)) + _wgSkipClasses.insert(*playerClass); + } + _IsEnableAvgIlvl = sConfigMgr->GetOption("CFBG.Include.Avg.Ilvl.Enable", false); _IsEnableBalancedTeams = sConfigMgr->GetOption("CFBG.BalancedTeams", false); _IsEnableEvenTeams = sConfigMgr->GetOption("CFBG.EvenTeams.Enabled", false); diff --git a/src/CFBG.h b/src/CFBG.h index 2610fc5..f8ee254 100644 --- a/src/CFBG.h +++ b/src/CFBG.h @@ -13,6 +13,7 @@ #include #include #include +#include #include class Player; @@ -138,6 +139,7 @@ class CFBG inline bool IsEnableWGSystem() const { return _IsEnableWGSystem; } inline bool IsEnableWGTeamLock() const { return _IsEnableWGTeamLock; } inline bool IsEnableWGReapplyOnResurrect() const { return _IsEnableWGReapplyOnResurrect; } + inline bool IsWGSkipClass(uint8 playerClass) const { return _wgSkipClasses.count(playerClass) > 0; } inline bool IsEnableAvgIlvl() const { return _IsEnableAvgIlvl; } inline bool IsEnableBalancedTeams() const { return _IsEnableBalancedTeams; } inline bool IsEnableBalanceClassLowLevel() const { return _IsEnableBalanceClassLowLevel; } @@ -226,6 +228,7 @@ class CFBG bool _IsEnableWGSystem; bool _IsEnableWGTeamLock; bool _IsEnableWGReapplyOnResurrect; + std::unordered_set _wgSkipClasses; bool _IsEnableAvgIlvl; bool _IsEnableBalancedTeams; bool _IsEnableBalanceClassLowLevel; diff --git a/src/CFBG_SC.cpp b/src/CFBG_SC.cpp index 6a0c0bd..7bed116 100644 --- a/src/CFBG_SC.cpp +++ b/src/CFBG_SC.cpp @@ -278,6 +278,9 @@ class CFBG_Battlefield : public BattlefieldScript if (sCFBG->IsPlayerFake(player)) return; + if (sCFBG->IsWGSkipClass(player->getClass())) + return; + TeamId realTeam = player->GetTeamId(true); TeamId assignedTeam = realTeam;