Skip to content

Commit

Permalink
Added RatioOfPreferredWeaponPerRound config for configure AWP chance …
Browse files Browse the repository at this point in the history
…per round. (#135)
  • Loading branch information
GL1TCH1337 authored Apr 22, 2024
1 parent bd2e974 commit d2191f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions RetakesAllocatorCore/Config/Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ public Dictionary<
public bool EnableNextRoundTypeVoting { get; set; } = false;
public int NumberOfExtraVipChancesForPreferredWeapon { get; set; } = 1;
public bool AllowPreferredWeaponForEveryone { get; set; } = false;

public double ChanceForPreferredWeapon { get; set; } = 100;

public Dictionary<CsTeam, int> MaxPreferredWeaponsPerTeam { get; set; } = new()
{
{CsTeam.Terrorist, 1},
Expand Down
7 changes: 6 additions & 1 deletion RetakesAllocatorCore/OnRoundPostStartHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using RetakesAllocatorCore.Config;
using RetakesAllocatorCore.Db;
using RetakesAllocatorCore.Managers;
using System;

namespace RetakesAllocatorCore;

Expand Down Expand Up @@ -58,7 +59,11 @@ HashSet<T> FilterByPreferredWeaponPreference(IEnumerable<T> ps) =>

ICollection<T> tPreferredPlayers = new List<T>();
ICollection<T> ctPreferredPlayers = new List<T>();
if (roundType == RoundType.FullBuy)

Random random = new Random();
double generatedChance = random.NextDouble() * 100;

if (roundType == RoundType.FullBuy && generatedChance <= Configs.GetConfigData().ChanceForPreferredWeapon)
{
tPreferredPlayers =
WeaponHelpers.SelectPreferredPlayers(FilterByPreferredWeaponPreference(tPlayers), isVip,
Expand Down

0 comments on commit d2191f4

Please sign in to comment.