124 lines
3.5 KiB
SourcePawn
124 lines
3.5 KiB
SourcePawn
#include <sourcemod>
|
|
#include <cstrike>
|
|
#include <mapchooser_extended>
|
|
|
|
int g_iDoingMapTouristMode;
|
|
int g_iActivePlayerCount;
|
|
bool g_bMapended;
|
|
|
|
public Plugin myinfo =
|
|
{
|
|
name = "knockback low pop modifier and helper",
|
|
author = "jenz",
|
|
description = "balances knockback and human settings for low population",
|
|
version = "2.1.0",
|
|
url = ""
|
|
}
|
|
|
|
public void OnPluginStart()
|
|
{
|
|
HookEvent("round_start", OnRoundStart);
|
|
CreateTimer(80.0, CheckPopulation, _, TIMER_REPEAT);
|
|
g_iDoingMapTouristMode = 0;
|
|
g_iActivePlayerCount = 0;
|
|
g_bMapended = false;
|
|
}
|
|
|
|
public Action CheckPopulation(Handle timer)
|
|
{
|
|
int TimeLeft;
|
|
if (GetMapTimeLeft(TimeLeft) && TimeLeft < 0)
|
|
{
|
|
return Plugin_Continue;
|
|
}
|
|
if (g_bMapended)
|
|
{
|
|
g_bMapended = false;
|
|
return Plugin_Continue;
|
|
}
|
|
|
|
g_iActivePlayerCount = 0;
|
|
for (int i = 1; i <= MaxClients; i++)
|
|
{
|
|
if (IsClientConnected(i) && IsClientInGame(i) && IsClientAuthorized(i))
|
|
{
|
|
g_iActivePlayerCount++;
|
|
}
|
|
}
|
|
return Plugin_Continue;
|
|
}
|
|
|
|
public void OnPluginEnd()
|
|
{
|
|
ServerCommand("zr_class_set_multiplier zombies knockback 1.0");
|
|
g_iDoingMapTouristMode = 0;
|
|
g_iActivePlayerCount = 0;
|
|
}
|
|
|
|
public void OnMapEnd()
|
|
{
|
|
g_iDoingMapTouristMode = 0;
|
|
ServerCommand("zr_class_set_multiplier zombies knockback 1.0");
|
|
g_bMapended = true;
|
|
}
|
|
|
|
public void OnMapStart()
|
|
{
|
|
char map[PLATFORM_MAX_PATH];
|
|
GetCurrentMap(map, PLATFORM_MAX_PATH);
|
|
|
|
//skipping de_, cs_, zm_ maps
|
|
if (StrContains(map, "ze_") == 0)
|
|
{
|
|
//LowPopHelpCount
|
|
g_iDoingMapTouristMode = GetMapLowPopHelpCount(map);
|
|
}
|
|
}
|
|
|
|
public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
|
{
|
|
ServerCommand("zr_class_set_multiplier zombies knockback 1.0");
|
|
ServerCommand("sm_iammo @all 0");
|
|
|
|
int choosen_number = 28;
|
|
if (g_iDoingMapTouristMode > g_iActivePlayerCount > 0)
|
|
{
|
|
CreateTimer(3.0, SetHealthOnCT);
|
|
}
|
|
else if (g_iActivePlayerCount < choosen_number)
|
|
{
|
|
int zombie_ratio = GetConVarInt(FindConVar("zr_infect_mzombie_ratio"));
|
|
int infectectable_players = 0;
|
|
for (int i = 1; i <= MaxClients; i++)
|
|
{
|
|
if (IsClientConnected(i) && IsClientInGame(i) && IsClientAuthorized(i) && GetClientTeam(i) > CS_TEAM_SPECTATOR)
|
|
{
|
|
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
|
|
|
|
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)
|
|
{
|
|
PrintToChatAll("LOW POP ON DIFFICULT MAP: ENABLING INFINITE AMMO AND 500 HP FOR CT");
|
|
PrintToChatAll("LOW POP ON DIFFICULT MAP: ENABLING INFINITE AMMO AND 500 HP FOR CT");
|
|
PrintToChatAll("LOW POP ON DIFFICULT MAP: ENABLING INFINITE AMMO AND 500 HP FOR CT");
|
|
ServerCommand("sm_iammo @all 1");
|
|
ServerCommand("sm_hp @ct 500");
|
|
return Plugin_Handled;
|
|
}
|