updated so that low pop helper has its own configuration now in the .cfg to decide with how many people on each map to help with easy settings

This commit is contained in:
jenz 2026-04-19 19:34:58 +02:00
parent 4a1ac398d0
commit c57aa5bcc2
3 changed files with 43 additions and 27 deletions

View File

@ -2,32 +2,32 @@
#include <cstrike>
#include <mapchooser_extended>
bool g_bDoingMapTouristMode;
int g_iDoingMapTouristMode;
public Plugin myinfo =
{
name = "knockback low pop modifier",
name = "knockback low pop modifier and helper",
author = "jenz",
description = "balances knockback for low population",
version = "1.1.0",
description = "balances knockback and human settings for low population",
version = "2.1.0",
url = ""
}
public void OnPluginStart()
{
HookEvent("round_start", OnRoundStart);
g_bDoingMapTouristMode = false;
g_iDoingMapTouristMode = 0;
}
public void OnPluginEnd()
{
ServerCommand("zr_class_set_multiplier zombies knockback 1.0");
g_bDoingMapTouristMode = false;
g_iDoingMapTouristMode = 0;
}
public void OnMapEnd()
{
g_bDoingMapTouristMode = false;
g_iDoingMapTouristMode = 0;
ServerCommand("zr_class_set_multiplier zombies knockback 1.0");
}
@ -39,13 +39,8 @@ public void OnMapStart()
//skipping de_, cs_, zm_ maps
if (StrContains(map, "ze_") == 0)
{
//Decided for now to exclude MaxPlayers
//MaxTime, MinTime, MinPlayers, CooldownTime, MinHoursAvg
if (GetMapMaxTime(map) != 0 || GetMapMinTime(map) != 0 || GetMapMinPlayers(map) != 0 || GetMapCooldownTime2(map) > 60
|| GetMapMinHoursAvg(map) != 0)
{
g_bDoingMapTouristMode = true;
}
//LowPopHelpCount
g_iDoingMapTouristMode = GetMapLowPopHelpCount(map);
}
}
@ -63,14 +58,19 @@ public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast)
int active_player_count = 0;
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientConnected(i) && IsClientInGame(i) && IsClientAuthorized(i) && !IsFakeClient(i) && !IsClientSourceTV(i))
if (IsClientConnected(i) && IsClientInGame(i) && IsClientAuthorized(i))
{
active_player_count++;
}
}
int choosen_number = 14;
if (active_player_count < choosen_number)
{
int choosen_number = 28;
if (g_iDoingMapTouristMode > active_player_count > 0)
{
CreateTimer(3.0, SetHealthOnCT);
}
else if (active_player_count < choosen_number)
{
int zombie_ratio = GetConVarInt(FindConVar("zr_infect_mzombie_ratio"));
int infectectable_players = 0;
for (int i = 1; i <= MaxClients; i++)
@ -80,27 +80,20 @@ public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast)
infectectable_players++;
}
}
float knockback_increase = float(zombie_ratio) / float(infectectable_players);
if (knockback_increase > 3.0)
knockback_increase = 3.0;
else if(knockback_increase < 1.0)
knockback_increase = 1.0
ServerCommand("zr_class_set_multiplier zombies knockback 1.0");
if (g_bDoingMapTouristMode)
{
CreateTimer(3.0, SetHealthOnCT);
}
else if (knockback_increase > 1.0)
if (knockback_increase > 1.0)
{
PrintToChatAll("LOW POP: increased zombie knockback to X%.2f to balance gameplay", knockback_increase);
PrintToChatAll("LOW POP: increased zombie knockback to X%.2f to balance gameplay", knockback_increase);
PrintToChatAll("LOW POP: increased zombie knockback to X%.2f to balance gameplay", knockback_increase);
ServerCommand("zr_class_set_multiplier zombies knockback %.2f", knockback_increase);
}
}
}
}
public Action SetHealthOnCT(Handle timer)

View File

@ -114,6 +114,7 @@ native bool ExcludeMapListingPriority(const char[] map, int index);
native int GetMapCooldown(const char[] map);
native int GetMapCooldownTime(const char[] map); // in unix time
native int GetMapCooldownTime2(const char[] map); // in unix time
native int GetMapLowPopHelpCount(const char[] map);
native int GetMapMinTime(const char[] map);
native int GetMapMaxTime(const char[] map);
native int GetMapMinPlayers(const char[] map);

View File

@ -473,6 +473,7 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
CreateNative("GetMapCooldown", Native_GetMapCooldown);
CreateNative("GetMapCooldownTime", Native_GetMapCooldownTime);
CreateNative("GetMapCooldownTime2", Native_GetMapCooldownTime2);
CreateNative("GetMapLowPopHelpCount", Native_GetMapLowPopHelpCount);
CreateNative("GetMapMinTime", Native_GetMapMinTime);
CreateNative("GetMapMaxTime", Native_GetMapMaxTime);
CreateNative("GetMapMinPlayers", Native_GetMapMinPlayers);
@ -2745,6 +2746,27 @@ public int Native_GetMapCooldownTime2(Handle plugin, int numParams)
return InternalGetMapCooldownTime2(map);
}
//GetMapLowPopHelpCount
public int Native_GetMapLowPopHelpCount(Handle plugin, int numParams)
{
int len;
GetNativeStringLength(1, len);
if(len <= 0)
return false;
char[] map = new char[len+1];
GetNativeString(1, map, len+1);
int count = 0;
if (g_Config && g_Config.JumpToKey(map))
{
count = g_Config.GetNum("LowPopHelpCount", count);
g_Config.Rewind();
}
return count;
}
public int Native_GetMapCooldownTime(Handle plugin, int numParams)
{
int len;