diff --git a/MapChooserSharp/Modules/RockTheVote/McsRtvController.cs b/MapChooserSharp/Modules/RockTheVote/McsRtvController.cs index bb764d0..aa0d961 100644 --- a/MapChooserSharp/Modules/RockTheVote/McsRtvController.cs +++ b/MapChooserSharp/Modules/RockTheVote/McsRtvController.cs @@ -54,6 +54,9 @@ internal sealed class McsRtvController(IServiceProvider serviceProvider, bool ho new("mcs_rtv_map_change_timing", "Seconds to change map after RTV is success. Set 0.0 to change immediately", 3.0F, ConVarFlags.FCVAR_NONE, new RangeValidator(0.0F, 60.0F)); + public readonly FakeConVar MinimumRtvRequirements = + new("mcs_rtv_minimum_requirements", + "Minimum RTV requirements to start RTV vote. Set 0 to disable this requirement", 0, ConVarFlags.FCVAR_NONE, new RangeValidator(0, 64)); public RtvStatus RtvCommandStatus { get; private set; } = RtvStatus.Enabled; @@ -112,19 +115,19 @@ protected override void OnAllPluginsLoaded() if (Utilities.GetPlayerFromSlot(slot)?.IsHLTV ?? true) return; - - CountsRequiredToInitiateRtv = (int)Math.Truncate(Utilities.GetPlayers().Count(p => p is { IsBot: false, IsHLTV: false }) * RtvVoteStartThreshold.Value); + + RefreshRtvRequirementCounts(); }); Plugin.RegisterListener((slot) => { _rtvVoteParticipants.Remove(slot); - CountsRequiredToInitiateRtv = (int)Math.Truncate(Utilities.GetPlayers().Count(p => p is { IsBot: false, IsHLTV: false }) * RtvVoteStartThreshold.Value); + RefreshRtvRequirementCounts(); }); if (hotReload) { - CountsRequiredToInitiateRtv = (int)Math.Truncate(Utilities.GetPlayers().Count(p => p is { IsBot: false, IsHLTV: false }) * RtvVoteStartThreshold.Value); + RefreshRtvRequirementCounts(); } } @@ -168,14 +171,11 @@ public PlayerRtvResult AddPlayerToRtv(CCSPlayerController player) return PlayerRtvResult.NotAllowed; } - - // CountsRequiredToInitiateRtv is possibly 0, so if 0 visual required count is set to 1, otherwise actual count. - int visualRequiredCount = CountsRequiredToInitiateRtv > 0 ? CountsRequiredToInitiateRtv : 1; - - PrintLocalizedChatToAllWithModulePrefix("RTV.Broadcast.PlayerCastRtv", player.PlayerName, _rtvVoteParticipants.Count, visualRequiredCount); + int requiredCount = GetMinimumRtvRequirementCounts(); + PrintLocalizedChatToAllWithModulePrefix("RTV.Broadcast.PlayerCastRtv", player.PlayerName, _rtvVoteParticipants.Count, requiredCount); - if (_rtvVoteParticipants.Count >= CountsRequiredToInitiateRtv) + if (_rtvVoteParticipants.Count >= requiredCount) { if (_mcsMapCycleController.IsNextMapConfirmed) { @@ -337,6 +337,21 @@ private void ResetRtvStatus() _rtvVoteParticipants.Clear(); } + private void RefreshRtvRequirementCounts() + { + CountsRequiredToInitiateRtv = (int)Math.Truncate(Utilities.GetPlayers().Count(p => p is { IsBot: false, IsHLTV: false }) * RtvVoteStartThreshold.Value); + } + + private int GetMinimumRtvRequirementCounts() + { + int count = Math.Max(CountsRequiredToInitiateRtv, MinimumRtvRequirements.Value); + + if (count <= 0) + return 1; + + return count; + } + private enum RtvCommandUnlockTimeOverride { diff --git a/docs/en/configuration/CONVAR.md b/docs/en/configuration/CONVAR.md index f1574d8..784f60d 100644 --- a/docs/en/configuration/CONVAR.md +++ b/docs/en/configuration/CONVAR.md @@ -66,6 +66,7 @@ ConVar configuration file is located in `game/csgo/cfg/MapChooserSharp/convars.c | mcs_rtv_command_unlock_time_map_start | Seconds to take unlock RTV command after map started | 300.0 | Valid Range is 0.0 - 1200.0 | | mcs_rtv_vote_start_threshold | How many percent to require start rtv vote? | 0.5 | Valid Range is 0.0 - 1.0 | | mcs_rtv_map_change_timing | Seconds to change map when next map is confirmed and after RTV is success. Set 0.0 to change immediately | 3.0 | Valid Range is 0.0 - 60.0 | +| mcs_rtv_minimum_requirements | Minimum RTV requirements to start RTV vote. Set 0 to disable this requirement | 0 | Valid Range is 0 - 64 | ## Timeleft Util diff --git a/docs/ja/configuration/CONVAR.md b/docs/ja/configuration/CONVAR.md index b5eb3db..b2ebb60 100644 --- a/docs/ja/configuration/CONVAR.md +++ b/docs/ja/configuration/CONVAR.md @@ -58,14 +58,15 @@ ConVarのコンフィグファイルは `game/csgo/cfg/MapChooserSharp/convars.c ## RTV Controller -| ConVar | Description | Default Value | note | -|------------------------------------------------|------------------------------------------------|---------------|------------------------------| -| mcs_rtv_command_unlock_time_next_map_confirmed | 次のマップが決まってからRTV出来るようになるまでの秒数 | 60.0 | 有効な範囲: 0.0 - 1200.0 | -| mcs_rtv_command_unlock_time_map_dont_change | RTVでマップを変更しないと決まってからRTV出来るようになるまでの秒数 | 240.0 | 有効な範囲: 0.0 - 1200.0 | -| mcs_rtv_command_unlock_time_map_extend | マップの延長が決まってからRTV出来るようになるまでの秒数 | 120.0 | 有効な範囲: 0.0 - 1200.0 | -| mcs_rtv_command_unlock_time_map_start | マップがスタートしてからRTV出来るようになるまでの秒数 | 300.0 | 有効な範囲: 0.0 - 1200.0 | -| mcs_rtv_vote_start_threshold | RTV投票を始めるために必要な投票率 | 0.5 | 有効な範囲: 0.0 - 1.0 | -| mcs_rtv_map_change_timing | 次のマップが確定している際にRTVが可決された場合にマップを変更するまでの時間 (秒で指定) | 3.0 | 有効な範囲: 0.0 - 60.0 | +| ConVar | Description | Default Value | note | +|------------------------------------------------|------------------------------------------------|---------------|---------------------| +| mcs_rtv_command_unlock_time_next_map_confirmed | 次のマップが決まってからRTV出来るようになるまでの秒数 | 60.0 | 有効な範囲: 0.0 - 1200.0 | +| mcs_rtv_command_unlock_time_map_dont_change | RTVでマップを変更しないと決まってからRTV出来るようになるまでの秒数 | 240.0 | 有効な範囲: 0.0 - 1200.0 | +| mcs_rtv_command_unlock_time_map_extend | マップの延長が決まってからRTV出来るようになるまでの秒数 | 120.0 | 有効な範囲: 0.0 - 1200.0 | +| mcs_rtv_command_unlock_time_map_start | マップがスタートしてからRTV出来るようになるまでの秒数 | 300.0 | 有効な範囲: 0.0 - 1200.0 | +| mcs_rtv_vote_start_threshold | RTV投票を始めるために必要な投票率 | 0.5 | 有効な範囲: 0.0 - 1.0 | +| mcs_rtv_map_change_timing | 次のマップが確定している際にRTVが可決された場合にマップを変更するまでの時間 (秒で指定) | 3.0 | 有効な範囲: 0.0 - 60.0 | +| mcs_rtv_minimum_requirements | RTVを行うために最低限必要な人数を指定します。 0を指定すると無効化出来ます。 | 0 | 有効な範囲: 0 - 64 | ## Timeleft Util