From b4409d3a1b35914b368f11692de7bf5348a3e170 Mon Sep 17 00:00:00 2001 From: jenz Date: Fri, 23 Feb 2024 18:11:52 +0100 Subject: [PATCH] added smokegrenade, added ambient sound, due to request will bot scaling 0 now use zombie count to decide how many bots to spawn --- ZombieRiot/scripting/unloze_zr.sp | 61 ++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 13 deletions(-) diff --git a/ZombieRiot/scripting/unloze_zr.sp b/ZombieRiot/scripting/unloze_zr.sp index 7bbbc880..5ded2278 100644 --- a/ZombieRiot/scripting/unloze_zr.sp +++ b/ZombieRiot/scripting/unloze_zr.sp @@ -89,6 +89,7 @@ Handle g_hClientHumanCookie; Handle g_hCheckBotStuck = null; Handle g_hZombieSounds = null; Handle g_hFixKNife = null; +Handle g_hAmbient = null; //---------------------------------------------------------------------------------------------------- // Purpose: @@ -155,6 +156,7 @@ public void OnPluginStart() g_hCheckBotStuck = CreateTimer(2.0, Timer_CheckIfBotsStuck, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); g_hZombieSounds = CreateTimer(g_fZMSounds, Timer_zombieSounds, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); g_hFixKNife = CreateTimer(2.0, Timer_FixKNife, INVALID_HANDLE, TIMER_REPEAT); + g_hAmbient = CreateTimer(60.3, Timer_Ambient, INVALID_HANDLE, TIMER_REPEAT); // 0.3 seconds without sound for (int i = 1; i < MaxClients; i++) { @@ -173,6 +175,8 @@ public void OnPluginEnd() delete g_hZombieSounds; if (g_hFixKNife != null) delete g_hFixKNife; + if (g_hAmbient != null) + delete g_hAmbient; } public Action CheckPlayerTeam(Handle timer, any userid) @@ -1090,6 +1094,7 @@ public void OnClientDisconnect(int client) //---------------------------------------------------------------------------------------------------- public void Event_roundStart(Handle event, const char[] name, bool dontBroadcast) { + EmitAmbience("ambient/zr/zr_ambience.mp3"); g_iHumanCount = 999; g_iZombieCount = 999; g_bRoundInProgress = false; @@ -1348,19 +1353,23 @@ public void LoadWave(int wave) //---------------------------------------------------------------------------------------------------- public void SettingBotQoute(int botscale) { - if (botscale < 1) - { - return; - } - int l_iPlayers; - for (int i = 1; i < MaxClients; i++) - { - if (IsValidClient(i) && !IsFakeClient(i) && CS_TEAM_CT == GetClientTeam(i)) - { - l_iPlayers++; - } - } - addBots(l_iPlayers * botscale); + int l_iPlayers; + for (int i = 1; i < MaxClients; i++) + { + if (IsValidClient(i) && !IsFakeClient(i) && CS_TEAM_CT == GetClientTeam(i)) + { + l_iPlayers++; + } + } + if (botscale > 0) + { + addBots(l_iPlayers * botscale); + } + else + { + //bot_scaling 0 should imply we spawn zombie_count amount of bots instead of scaling bots to player amount. + addBots(g_iZMCount); + } } //---------------------------------------------------------------------------------------------------- // Purpose: @@ -2168,3 +2177,29 @@ stock void ReplaceStrings(char[] str, char[] strReplace) TrimString(l_cstrFix); Format(str, sizeof(l_cstrFix), l_cstrFix); } + +//ambience +void EmitAmbience(const char[] sound) +{ + PrecacheSound(sound); + StopAmbience(sound); + EmitSoundToAll(sound, SOUND_FROM_PLAYER, SNDCHAN_AUTO, SNDLEVEL_NORMAL, SND_NOFLAGS, 1.0, SNDPITCH_NORMAL, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0); +} + +void StopAmbience(const char []sound) +{ + for (int i = 0; i < MaxClients; i++) + { + if (!IsValidClient(i)) + { + continue; + } + StopSound(i, SNDCHAN_AUTO, sound); + } +} + +public Action Timer_Ambient(Handle timer, any userid) +{ + EmitAmbience("ambient/zr/zr_ambience.mp3"); + return Plugin_Handled; +}