remade for CSS zr. csgo is no more anyways. dont need the gamedata over here

This commit is contained in:
jenz 2024-01-28 00:49:36 +01:00
parent e8dcfb5048
commit de83c59171
2 changed files with 267 additions and 266 deletions
ZombieRiot

View File

@ -1,14 +0,0 @@
"Games"
{
"csgo"
{
"Offsets"
{
"GetPlayerMaxSpeed"
{
"windows" "498"
"linux" "499"
}
}
}
}

View File

@ -12,6 +12,7 @@
#include <dhooks> #include <dhooks>
#include <clientprefs> #include <clientprefs>
#include <smlib> #include <smlib>
#pragma newdecls required #pragma newdecls required
//#pragma dynamic 131072 //#pragma dynamic 131072
static char g_cPathsClassHuman[PLATFORM_MAX_PATH]; static char g_cPathsClassHuman[PLATFORM_MAX_PATH];
@ -38,6 +39,7 @@ char g_cZMSounds[g_dIndexes][g_dLength];
char g_cWeaponEntity[g_dIndexes][g_dLength]; char g_cWeaponEntity[g_dIndexes][g_dLength];
char g_cWeaponNames[g_dIndexes][g_dLength]; char g_cWeaponNames[g_dIndexes][g_dLength];
char g_cWeaponCommand[g_dIndexes][g_dLength]; char g_cWeaponCommand[g_dIndexes][g_dLength];
int g_iLength = g_dLength - 1; int g_iLength = g_dLength - 1;
int g_iWave; int g_iWave;
int g_iZMScaleability; int g_iZMScaleability;
@ -56,6 +58,7 @@ int g_iZMBeginindex;
int g_iSoundIndexes; int g_iSoundIndexes;
int g_iWeaponIndex; int g_iWeaponIndex;
int g_iBotStuckCounts; int g_iBotStuckCounts;
float g_fKnockBackIndex[g_dIndexes]; float g_fKnockBackIndex[g_dIndexes];
float g_fJumpHeightIndex[g_dIndexes]; float g_fJumpHeightIndex[g_dIndexes];
float g_fJumpDistanceIndex[g_dIndexes]; float g_fJumpDistanceIndex[g_dIndexes];
@ -66,15 +69,17 @@ float g_fZMHealthScaleability;
float g_fRespawnTimer; float g_fRespawnTimer;
float g_fZMSounds; float g_fZMSounds;
float g_fBotStuckPush; float g_fBotStuckPush;
bool g_bSwitchingIndex; bool g_bSwitchingIndex;
bool g_bRoundInProgress; bool g_bRoundInProgress;
bool g_bShouldBeHuman[g_dIndexes]; bool g_bShouldBeHuman[g_dIndexes];
bool g_bShouldBeZM[g_dIndexes]; bool g_bShouldBeZM[g_dIndexes];
bool g_bFallDamage[g_dIndexes]; bool g_bFallDamage[g_dIndexes];
bool g_bClientProtection[g_dIndexes]; bool g_bClientProtection[g_dIndexes];
Handle g_hGetPlayerMaxSpeed = INVALID_HANDLE;
Handle g_hClientZMCookie; Handle g_hClientZMCookie;
Handle g_hClientHumanCookie; Handle g_hClientHumanCookie;
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -82,44 +87,38 @@ public Plugin myinfo =
{ {
name = "Unloze Zombie Riot", name = "Unloze Zombie Riot",
author = PLUGIN_AUTHOR, author = PLUGIN_AUTHOR,
description = "Zombie Riot mod for CSGO", description = "Zombie Riot mod. originally for csgo but remade for css",
version = PLUGIN_VERSION, version = PLUGIN_VERSION,
url = "www.unloze.com" url = "www.unloze.com"
}; };
public void OnPluginStart() public void OnPluginStart()
{ {
//gamedata
if (LibraryExists("dhooks"))
{
Handle hGameData = LoadGameConfigFile("zombieriot");
if (hGameData != null)
{
int iOffset = GameConfGetOffset(hGameData, "GetPlayerMaxSpeed");
if (iOffset != -1)
g_hGetPlayerMaxSpeed = DHookCreate(iOffset, HookType_Entity, ReturnType_Float, ThisPointer_CBaseEntity, DHook_GetPlayerMaxSpeed);
delete hGameData;
}
}
//processstring //processstring
LoadTranslations("common.phrases.txt"); LoadTranslations("common.phrases.txt");
//cookies //cookies
if (g_hClientZMCookie == null) if (g_hClientZMCookie == null)
g_hClientZMCookie = RegClientCookie("unloze_zr_classprefZM", "Cookie for ZM classes", CookieAccess_Protected); g_hClientZMCookie = RegClientCookie("unloze_zr_classprefZM", "Cookie for ZM classes", CookieAccess_Protected);
if (g_hClientHumanCookie == null) if (g_hClientHumanCookie == null)
g_hClientHumanCookie = RegClientCookie("unloze_zr_classprefHuman", "Cookie for Human classes", CookieAccess_Protected); g_hClientHumanCookie = RegClientCookie("unloze_zr_classprefHuman", "Cookie for Human classes", CookieAccess_Protected);
BuildPath(Path_SM, g_cPathsClassZM, sizeof(g_cPathsClassZM), "configs/unloze_zr/classeszm.txt"); BuildPath(Path_SM, g_cPathsClassZM, sizeof(g_cPathsClassZM), "configs/unloze_zr/classeszm.txt");
BuildPath(Path_SM, g_cPathsClassHuman, sizeof(g_cPathsClassHuman), "configs/unloze_zr/classeshuman.txt"); BuildPath(Path_SM, g_cPathsClassHuman, sizeof(g_cPathsClassHuman), "configs/unloze_zr/classeshuman.txt");
BuildPath(Path_SM, g_cPathsExtra, sizeof(g_cPathsExtra), "configs/unloze_zr/extra.txt"); BuildPath(Path_SM, g_cPathsExtra, sizeof(g_cPathsExtra), "configs/unloze_zr/extra.txt");
BuildPath(Path_SM, g_cPathsDownload, sizeof(g_cPathsDownload), "configs/unloze_zr/download.txt"); BuildPath(Path_SM, g_cPathsDownload, sizeof(g_cPathsDownload), "configs/unloze_zr/download.txt");
BuildPath(Path_SM, g_cPathsWaveSettings, sizeof(g_cPathsWaveSettings), "configs/unloze_zr/wavesettings.txt"); BuildPath(Path_SM, g_cPathsWaveSettings, sizeof(g_cPathsWaveSettings), "configs/unloze_zr/wavesettings.txt");
BuildPath(Path_SM, g_cPathsWeapons, sizeof(g_cPathsWeapons), "configs/unloze_zr/weapons.txt"); BuildPath(Path_SM, g_cPathsWeapons, sizeof(g_cPathsWeapons), "configs/unloze_zr/weapons.txt");
//hooks //hooks
HookEvent("player_spawn", ApplySettings, EventHookMode_Post); HookEvent("player_spawn", ApplySettings, EventHookMode_Post);
HookEvent("round_start", Event_roundStart, EventHookMode_Post); HookEvent("round_start", Event_roundStart, EventHookMode_Post);
HookEvent("player_death", Event_OnPlayerDeath, EventHookMode_Post); HookEvent("player_death", Event_OnPlayerDeath, EventHookMode_Post);
HookEvent("player_connect_full", Event_OnFullConnect, EventHookMode_Pre); HookEvent("player_connect", Event_OnFullConnect, EventHookMode_Pre);
HookEvent("player_hurt", EventPlayerHurt, EventHookMode_Pre); HookEvent("player_hurt", EventPlayerHurt, EventHookMode_Pre);
HookEvent("player_jump", EventPlayerJump, EventHookMode_Post); HookEvent("player_jump", EventPlayerJump, EventHookMode_Post);
//commands //commands
RegConsoleCmd("say", Cmd_Say); RegConsoleCmd("say", Cmd_Say);
RegConsoleCmd("sm_zclass", Cmd_Zclass, "Class Prefferences"); //named like zombiereloaded for ease of use RegConsoleCmd("sm_zclass", Cmd_Zclass, "Class Prefferences"); //named like zombiereloaded for ease of use
@ -136,13 +135,16 @@ public Action Cmd_LoadManually(int client, int args)
{ {
//LoadClasses(); //LoadClasses();
AddDownloadContent(); AddDownloadContent();
return Plugin_Handled;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public Action Cmd_zmarket(int client, int args) public Action Cmd_zmarket(int client, int args)
{ {
Zmarket(client); Zmarket(client);
return Plugin_Handled;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -150,6 +152,7 @@ public Action Cmd_zmarket(int client, int args)
public Action Cmd_Humanize(int client, int args) public Action Cmd_Humanize(int client, int args)
{ {
InfectionSlashHumanHandling(client, args, 0); InfectionSlashHumanHandling(client, args, 0);
return Plugin_Handled;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -157,6 +160,7 @@ public Action Cmd_Humanize(int client, int args)
public Action Cmd_Zombienize(int client, int args) public Action Cmd_Zombienize(int client, int args)
{ {
InfectionSlashHumanHandling(client, args, 1); InfectionSlashHumanHandling(client, args, 1);
return Plugin_Handled;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -164,6 +168,7 @@ public Action Cmd_Zombienize(int client, int args)
public Action Cmd_Zclass(int client, int args) public Action Cmd_Zclass(int client, int args)
{ {
Zclass(client); Zclass(client);
return Plugin_Handled;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -184,6 +189,7 @@ public Action Cmd_ChangeWave(int client, int args)
{ {
ReplyToCommand(client, "Incorrect input"); ReplyToCommand(client, "Incorrect input");
} }
return Plugin_Handled;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -328,6 +334,7 @@ static void Zclass(int client)
ZclassMenu.ExitBackButton = true; ZclassMenu.ExitBackButton = true;
ZclassMenu.Display(client, 0); ZclassMenu.Display(client, 0);
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -341,6 +348,7 @@ public int Zmarket_menu(Menu menu, MenuAction action, int client, int selection)
{ {
delete(menu); delete(menu);
} }
return 0;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -355,6 +363,7 @@ public int Zclass_Menu(Menu menu, MenuAction action, int client, int selection)
{ {
delete(menu); delete(menu);
} }
return 0;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: //https://forums.alliedmods.net/showthread.php?t=305092 // Purpose: //https://forums.alliedmods.net/showthread.php?t=305092
@ -519,6 +528,7 @@ public int Zombieclass_Menu(Menu menu, MenuAction action, int client, int select
{ {
delete(menu); delete(menu);
} }
return 0;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -540,6 +550,7 @@ public int Humanclass_Menu(Menu menu, MenuAction action, int client, int selecti
{ {
delete(menu); delete(menu);
} }
return 0;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -850,8 +861,6 @@ public void Event_roundStart(Handle event, const char[] name, bool dontBroadcast
} }
} }
} }
if (l_iHumanPlayers < 1)
ServerCommand("bot_kick");
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -877,6 +886,7 @@ public Action RetrieveWaveSettings(int wave)
public Action Timer_switchingModel(Handle timer, any data) public Action Timer_switchingModel(Handle timer, any data)
{ {
g_bSwitchingIndex = false; g_bSwitchingIndex = false;
return Plugin_Handled;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -1064,7 +1074,7 @@ public void SettingBotQoute(int botscale)
int l_iPlayers; int l_iPlayers;
for (int i = 1; i < MaxClients; i++) for (int i = 1; i < MaxClients; i++)
{ {
if (IsValidClient(i) && !IsFakeClient(i)) if (IsValidClient(i) && !IsFakeClient(i) && CS_TEAM_CT == GetClientTeam(i))
{ {
l_iPlayers++; l_iPlayers++;
} }
@ -1076,10 +1086,10 @@ public void SettingBotQoute(int botscale)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void addBots(int botcount) public void addBots(int botcount)
{ {
ServerCommand("bot_kick"); //ServerCommand("bot_kick");
for (int i = 0; i < botcount; i++) for (int i = 0; i < botcount; i++)
{ {
if (i > 32) if (i > 44) //probably will be turned into a convar somewhen.
continue; continue;
ServerCommand("bot_add_t"); ServerCommand("bot_add_t");
} }
@ -1340,6 +1350,7 @@ public Action ApplySettings(Event event, const char[] name, bool dontBroadcast)
{ {
int client = GetClientOfUserId(event.GetInt("userid")); int client = GetClientOfUserId(event.GetInt("userid"));
ApplySettingsEvent(client); ApplySettingsEvent(client);
return Plugin_Handled;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -1509,7 +1520,6 @@ public Action ModelSelection(int client, int state, int modelIndex)
else else
SetEntityHealth(client, StringToInt(g_cHealth[i][g_iLength])); SetEntityHealth(client, StringToInt(g_cHealth[i][g_iLength]));
g_iSpeedIndex[client] = i; g_iSpeedIndex[client] = i;
DHookEntity(g_hGetPlayerMaxSpeed, true, client);
g_fKnockBackIndex[client] = StringToFloat(g_cKnockback[i][g_iLength]); g_fKnockBackIndex[client] = StringToFloat(g_cKnockback[i][g_iLength]);
g_fJumpHeightIndex[client] = StringToFloat(g_cJumpHeight[i][g_iLength]); g_fJumpHeightIndex[client] = StringToFloat(g_cJumpHeight[i][g_iLength]);
g_fJumpDistanceIndex[client] = StringToFloat(g_cJumpDistance[i][g_iLength]); g_fJumpDistanceIndex[client] = StringToFloat(g_cJumpDistance[i][g_iLength]);
@ -1538,6 +1548,7 @@ public Action Timer_restrictWeapons(Handle timer, any userid)
} }
} }
} }
return Plugin_Handled;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -1569,6 +1580,7 @@ public Action Timer_CheckIfBotsStuck(Handle timer, any userid)
} }
} }
} }
return Plugin_Handled;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -1602,6 +1614,7 @@ public Action Timer_zombieSounds(Handle timer, any userid)
EmitSoundToClient(i, g_cZMSounds[l_iSoundIndexes][g_iLength], l_client); EmitSoundToClient(i, g_cZMSounds[l_iSoundIndexes][g_iLength], l_client);
} }
} }
return Plugin_Handled;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -1639,6 +1652,7 @@ public Action Timer_StopProtection(Handle timer, int client)
{ {
if (IsValidClient(client)) if (IsValidClient(client))
g_bClientProtection[client] = false; g_bClientProtection[client] = false;
return Plugin_Handled;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -1786,7 +1800,7 @@ public void KnockbackSetVelocity(int client, const float startpoint[3], const fl
vector[2] = CSGO_KNOCKBACK_BOOST; vector[2] = CSGO_KNOCKBACK_BOOST;
} }
} }
// ADD the given vector to the client's current velocity. tools_functions.inc // ADD the given vector to the clients current velocity. tools_functions.inc
ToolsClientVelocity(client, vector); ToolsClientVelocity(client, vector);
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -1815,7 +1829,7 @@ public int KnockbackFindExplodingGrenade(float heLoc[3])
{ {
continue; continue;
} }
// If entity isn't a grenade, then stop. // If entity isnt a grenade, then stop.
GetEdictClassname(x, l_cClassname, sizeof(l_cClassname)); GetEdictClassname(x, l_cClassname, sizeof(l_cClassname));
if (!StrEqual(l_cClassname, "hegrenade_projectile", false)) if (!StrEqual(l_cClassname, "hegrenade_projectile", false))
{ {
@ -1831,7 +1845,7 @@ public int KnockbackFindExplodingGrenade(float heLoc[3])
return x; return x;
} }
} }
// Didn't find the grenade. // Didnt find the grenade.
return -1; return -1;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -1843,10 +1857,11 @@ public Action EventPlayerJump(Handle event, const char[] name, bool dontBroadcas
int index = GetClientOfUserId(GetEventInt(event, "userid")); int index = GetClientOfUserId(GetEventInt(event, "userid"));
// Fire post player_jump event. // Fire post player_jump event.
CreateTimer(0.0, EventPlayerJumpPost, index); CreateTimer(0.0, EventPlayerJumpPost, index);
return Plugin_Handled;
} }
public Action EventPlayerJumpPost(Handle timer, int client) public Action EventPlayerJumpPost(Handle timer, int client)
{ {
// If client isn't in-game, then stop. // If client isnt in-game, then stop.
if (!IsClientInGame(client)) if (!IsClientInGame(client))
{ {
return Plugin_Handled; return Plugin_Handled;
@ -1861,7 +1876,7 @@ public Action EventPlayerJumpPost(Handle timer, int client)
return Plugin_Continue; return Plugin_Continue;
} }
float vecVelocity[3]; float vecVelocity[3];
// Get client's current velocity. // Get clients current velocity.
ToolsClientVelocity(client, vecVelocity, false); ToolsClientVelocity(client, vecVelocity, false);
//maybe check JumpBoostIsBHop here //maybe check JumpBoostIsBHop here
@ -1894,17 +1909,17 @@ stock void ToolsGetClientVelocity(int client, float vecVelocity[3])
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
stock void ToolsClientVelocity(int client, float vecVelocity[3], bool apply = true, bool stack = true) stock void ToolsClientVelocity(int client, float vecVelocity[3], bool apply = true, bool stack = true)
{ {
// If retrieve is true, then get client's velocity. // If retrieve is true, then get clients velocity.
if (!apply) if (!apply)
{ {
ToolsGetClientVelocity(client, vecVelocity); ToolsGetClientVelocity(client, vecVelocity);
// Stop here. // Stop here.
return; return;
} }
// If stack is true, then add client's velocity. // If stack is true, then add clients velocity.
if (stack) if (stack)
{ {
// Get client's velocity. // Get clients velocity.
float vecClientVelocity[3]; float vecClientVelocity[3];
ToolsGetClientVelocity(client, vecClientVelocity); ToolsGetClientVelocity(client, vecClientVelocity);
AddVectors(vecClientVelocity, vecVelocity, vecVelocity); AddVectors(vecClientVelocity, vecVelocity, vecVelocity);