115 lines
3.5 KiB
SourcePawn
115 lines
3.5 KiB
SourcePawn
#include <sourcemod>
|
|
#include <cstrike>
|
|
#include <mapchooser_extended>
|
|
|
|
bool g_bDoingMapTouristMode;
|
|
|
|
public Plugin myinfo =
|
|
{
|
|
name = "knockback low pop modifier",
|
|
author = "jenz",
|
|
description = "balances knockback for low population",
|
|
version = "1.1.0",
|
|
url = ""
|
|
}
|
|
|
|
public void OnPluginStart()
|
|
{
|
|
HookEvent("round_start", OnRoundStart);
|
|
g_bDoingMapTouristMode = false;
|
|
}
|
|
|
|
public void OnPluginEnd()
|
|
{
|
|
ServerCommand("zr_class_set_multiplier zombies knockback 1.0");
|
|
g_bDoingMapTouristMode = false;
|
|
}
|
|
|
|
public void OnMapEnd()
|
|
{
|
|
g_bDoingMapTouristMode = false;
|
|
ServerCommand("zr_class_set_multiplier zombies knockback 1.0");
|
|
}
|
|
|
|
public void OnMapStart()
|
|
{
|
|
char map[PLATFORM_MAX_PATH];
|
|
GetCurrentMap(map, PLATFORM_MAX_PATH);
|
|
|
|
//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;
|
|
}
|
|
}
|
|
}
|
|
|
|
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 TimeLeft;
|
|
if (GetMapTimeLeft(TimeLeft) && TimeLeft < 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
int active_player_count = 0;
|
|
for (int i = 1; i <= MaxClients; i++)
|
|
{
|
|
if (IsClientConnected(i) && IsClientInGame(i) && IsClientAuthorized(i) && !IsFakeClient(i) && !IsClientSourceTV(i))
|
|
{
|
|
active_player_count++;
|
|
}
|
|
}
|
|
int choosen_number = 14;
|
|
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++)
|
|
{
|
|
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
|
|
|
|
ServerCommand("zr_class_set_multiplier zombies knockback 1.0");
|
|
if (g_bDoingMapTouristMode)
|
|
{
|
|
CreateTimer(3.0, SetHealthOnCT);
|
|
}
|
|
else 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;
|
|
}
|