Skip to content

Commit a24baaf

Browse files
committed
Add map cooldown randomness
1 parent e11a744 commit a24baaf

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

cfg/cs2fixes/cs2fixes.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ cs2f_rtv_endround 0 // Whether to immediately end the round when RTV succee
8282

8383
// Map vote settings
8484
cs2f_vote_maps_cooldown 6.0 // Default number of hours until a map can be played again i.e. cooldown
85+
cs2f_vote_maps_cooldown_rng 0.0 // Randomness range in both directions to apply to map cooldowns
8586
cs2f_vote_max_nominations 10 // Number of nominations to include per vote, out of a maximum of 10
8687
cs2f_vote_max_maps 10 // Number of total maps to include per vote, including nominations, out of a maximum of 10
8788

src/map_votes.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
CMapVoteSystem* g_pMapVoteSystem = nullptr;
4141

4242
CConVar<float> g_cvarVoteMapsCooldown("cs2f_vote_maps_cooldown", FCVAR_NONE, "Default number of hours until a map can be played again i.e. cooldown", 6.0f);
43+
CConVar<float> g_cvarVoteMapsCooldownRng("cs2f_vote_maps_cooldown_rng", FCVAR_NONE, "Randomness range in both directions to apply to map cooldowns", 0.0f);
4344
CConVar<int> g_cvarVoteMaxNominations("cs2f_vote_max_nominations", FCVAR_NONE, "Number of nominations to include per vote, out of a maximum of 10", 10, true, 0, true, 10);
4445
CConVar<int> g_cvarVoteMaxMaps("cs2f_vote_max_maps", FCVAR_NONE, "Number of total maps to include per vote, including nominations, out of a maximum of 10", 10, true, 2, true, 10);
4546

@@ -1262,6 +1263,17 @@ void CMapVoteSystem::PutMapOnCooldown(const char* pszMapName, float fCooldown)
12621263
fCooldown = pMap->GetCustomCooldown();
12631264
else
12641265
fCooldown = g_cvarVoteMapsCooldown.Get();
1266+
1267+
// Add randomness if applicable
1268+
if (g_cvarVoteMapsCooldown.Get() != 0.0f)
1269+
{
1270+
float flRandomValue = ((float)rand() / RAND_MAX) * g_cvarVoteMapsCooldownRng.Get();
1271+
1272+
if (rand() % 2)
1273+
fCooldown += flRandomValue;
1274+
else
1275+
fCooldown -= flRandomValue;
1276+
}
12651277
}
12661278

12671279
time_t timeCooldown = std::time(0) + (time_t)(fCooldown * 60 * 60);

0 commit comments

Comments
 (0)