From effc246b451091e09206118374a5ab353369a835 Mon Sep 17 00:00:00 2001 From: jenz Date: Sat, 24 Feb 2024 02:47:22 +0100 Subject: [PATCH] added option to comma separate the soundfiles --- ZombieRiot/configs/unloze_zr/extra.txt | 2 +- ZombieRiot/scripting/unloze_zr.sp | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/ZombieRiot/configs/unloze_zr/extra.txt b/ZombieRiot/configs/unloze_zr/extra.txt index 412938b0..186348f1 100644 --- a/ZombieRiot/configs/unloze_zr/extra.txt +++ b/ZombieRiot/configs/unloze_zr/extra.txt @@ -13,7 +13,7 @@ "human spawn protection" "10.0" "Global command" "mp_afterroundmoney 16000" "Global command" "bot_difficulty 3" - "ambientSound" "ambient/zr/zr_ambience.mp3" + "ambientSound" "ambient/zr/zr_ambience.mp3,ambient/zr/ambience_1.mp3" "ambientLoopDuration" "60.3" "bossSound" "ambient/zr/satanic_demona.mp3" "bossLoopDuration" "155.3" diff --git a/ZombieRiot/scripting/unloze_zr.sp b/ZombieRiot/scripting/unloze_zr.sp index 38da0594..18138637 100644 --- a/ZombieRiot/scripting/unloze_zr.sp +++ b/ZombieRiot/scripting/unloze_zr.sp @@ -44,8 +44,8 @@ char g_cZMSounds[g_dIndexes][g_dLength]; char g_cWeaponEntity[g_dIndexes][g_dLength]; char g_cWeaponNames[g_dIndexes][g_dLength]; char g_cWeaponCommand[g_dIndexes][g_dLength]; -char g_cAmbientSOund[512]; char g_cBossSound[512]; +char g_cAmbientSOund[64][512]; float g_fAmbientSoundLoopDuration; float g_fBossSoundLoopDuration; @@ -913,7 +913,7 @@ public void LoadExtraSettings() if (StrContains(l_cLine, "ambientSound", false) > -1) { ReplaceStrings(l_cLine, "ambientSound"); - Format(g_cAmbientSOund, sizeof(g_cAmbientSOund), l_cLine); + ExplodeString(l_cLine, ",", g_cAmbientSOund, 64, 512); } if (StrContains(l_cLine, "ambientLoopDuration") > -1) { @@ -1157,10 +1157,25 @@ public void Event_roundStart(Handle event, const char[] name, bool dontBroadcast } else { - EmitAmbience(g_cAmbientSOund); + int index = ambient_index(); + EmitAmbience(g_cAmbientSOund[index]); g_hAmbient = CreateTimer(g_fAmbientSoundLoopDuration, Timer_Ambient, INVALID_HANDLE, TIMER_REPEAT); // 0.3 seconds without sound } } + +public int ambient_index() +{ + int index = 0; + for (int i = 0; i < sizeof(g_cAmbientSOund); i++) + { + if (strlen(g_cAmbientSOund[i]) == 0) + { + index = (g_iWave - 1) % i; + break; + } + } + return index; +} //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- @@ -2248,7 +2263,8 @@ public Action Timer_Ambient(Handle timer, any userid) } else { - EmitAmbience(g_cAmbientSOund); + int index = ambient_index(); + EmitAmbience(g_cAmbientSOund[index]); } return Plugin_Handled; }