From 1f1d2cb1114f3076e57332df65fe42c285696a9b Mon Sep 17 00:00:00 2001 From: jenz Date: Mon, 29 Jan 2024 22:03:19 +0100 Subject: [PATCH] trying to fix stuff --- ZombieRiot/scripting/unloze_zr.sp | 137 +++++++++++++++++++++--------- 1 file changed, 97 insertions(+), 40 deletions(-) diff --git a/ZombieRiot/scripting/unloze_zr.sp b/ZombieRiot/scripting/unloze_zr.sp index 004e8f70..70f70ea6 100644 --- a/ZombieRiot/scripting/unloze_zr.sp +++ b/ZombieRiot/scripting/unloze_zr.sp @@ -34,6 +34,7 @@ char g_cSpeed[g_dIndexes][g_dLength]; char g_cKnockback[g_dIndexes][g_dLength]; char g_cJumpHeight[g_dIndexes][g_dLength]; char g_cJumpDistance[g_dIndexes][g_dLength]; +char g_cDamageMultiplier[g_dIndexes][g_dLength]; char g_cAdminGroups[g_dIndexes][g_dIndexes][g_dLength]; char g_cZMSounds[g_dIndexes][g_dLength]; char g_cWeaponEntity[g_dIndexes][g_dLength]; @@ -59,9 +60,10 @@ int g_iSoundIndexes; int g_iWeaponIndex; int g_iBotStuckCounts; -float g_fKnockBackIndex[g_dIndexes]; -float g_fJumpHeightIndex[g_dIndexes]; -float g_fJumpDistanceIndex[g_dIndexes]; +float g_fKnockBackIndex[g_dIndexes + 1]; +float g_fJumpHeightIndex[g_dIndexes + 1]; +float g_fJumpDistanceIndex[g_dIndexes + 1]; +float g_fDamageMultiplier[g_dIndexes + 1]; float g_fSwitchingTimer; float g_fZMSpawnProtection; float g_fHumanSpawnProtection; @@ -75,7 +77,6 @@ bool g_bRoundInProgress; bool g_bFallDamage[g_dIndexes]; bool g_bClientProtection[g_dIndexes]; -bool g_bRestartRound = true; Handle g_hClientZMCookie; Handle g_hClientHumanCookie; @@ -94,6 +95,9 @@ public Plugin myinfo = public void OnPluginStart() { + OnMapStart(); + RetrieveWaveSettings(1); + //processstring LoadTranslations("common.phrases.txt"); @@ -126,14 +130,22 @@ public void OnPluginStart() RegAdminCmd("sm_wave", Cmd_ChangeWave, ADMFLAG_RCON); RegAdminCmd("sm_human", Cmd_Humanize, ADMFLAG_BAN); RegAdminCmd("sm_infect", Cmd_Zombienize, ADMFLAG_BAN); + + for (int i = 1; i < MaxClients; i++) + { + if (IsValidClient(i)) + { + OnClientPostAdminCheck(i); + } + } } -public Action ApplySettings(Event event, const char[] name, bool dontBroadcast) +public Action Timer_CheckIfRestartNeeded(Handle timer, any userid) { int activePlayers = 0; for (int i = 1; i < MaxClients; i++) { - if (IsValidClient(i) && !IsFakeClient(i) && (GetClientTeam(i) == CS_TEAM_CT || GetClientTeam(i) == CS_TEAM_T)) + if (IsValidClient(i) && (GetClientTeam(i) == CS_TEAM_CT || GetClientTeam(i) == CS_TEAM_T)) { activePlayers++; } @@ -142,18 +154,32 @@ public Action ApplySettings(Event event, const char[] name, bool dontBroadcast) break; } } - if (activePlayers == 1 && g_bRestartRound) + if (activePlayers == 1) { PrintToChatAll("First Player joining. Restarting the round..."); - g_bRestartRound = false; CS_TerminateRound(4.0, CSRoundEnd_Draw, false); } - else if (activePlayers == 0) + return Plugin_Handled; +} + +public Action ApplySettings(Event event, const char[] name, bool dontBroadcast) +{ + int activePlayers = 0; + for (int i = 1; i < MaxClients; i++) { - g_bRestartRound = true; + if (IsValidClient(i) && (GetClientTeam(i) == CS_TEAM_CT || GetClientTeam(i) == CS_TEAM_T)) + { + activePlayers++; + } + if (activePlayers > 1) + { + break; + } + } + if (activePlayers == 1) + { + CreateTimer(10.0, Timer_CheckIfRestartNeeded); } - - int client = GetClientOfUserId(event.GetInt("userid")); if (!IsValidClient(client) || !IsPlayerAlive(client) || IsClientSourceTV(client)) { @@ -269,7 +295,6 @@ public Action Cmd_Say(int client, int args) continue; if (StrEqual(l_cBuffer, g_cWeaponCommand[i][g_iLength], false) || StrEqual(l_cBuffer2, g_cWeaponCommand[i][g_iLength], false)) { - //PrintToChatAll("SUCCESS: %s", l_cBuffer); ZmarketGetWeapon(client, i); break; } @@ -758,8 +783,6 @@ public Action LoadClasses() l_hFileZM = OpenFile(g_cPathsClassZM, "r"); if (!FileExists(g_cPathsClassHuman) && !FileExists(g_cPathsClassZM)) { - //PrintToChatAll("File does not exist g_cPathsClassHuman: %s", g_cPathsClassHuman); - //PrintToChatAll("File does not exist g_cPathsClassZM: %s", g_cPathsClassZM); CreateBackUpClassHuman(g_iLoadClassesIndex); CreateBackUpClassZM(g_iLoadClassesIndex); delete l_hFile; @@ -820,6 +843,7 @@ public void OnClientPostAdminCheck(int client) g_fKnockBackIndex[client] = 1.0; g_fJumpHeightIndex[client] = 1.0; g_fJumpDistanceIndex[client] = 1.0; + g_fDamageMultiplier[client] = 1.0; g_iClientRespawnCount[client] = g_iClientRespawnCountNum; char sCookieValue[12]; GetClientCookie(client, g_hClientZMCookie, sCookieValue, sizeof(sCookieValue)); @@ -862,13 +886,14 @@ public void SetAdminGroups(int client) //---------------------------------------------------------------------------------------------------- public void OnClientDisconnect(int client) { - g_bClientProtection[client] = false; - g_bFallDamage[client] = false; - g_fKnockBackIndex[client] = 1.0; - g_fJumpHeightIndex[client] = 1.0; - g_fJumpDistanceIndex[client] = 1.0; - g_iClientRespawnCount[client] = 0; - SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage); + g_bClientProtection[client] = false; + g_bFallDamage[client] = false; + g_fKnockBackIndex[client] = 1.0; + g_fJumpHeightIndex[client] = 1.0; + g_fJumpDistanceIndex[client] = 1.0; + g_fDamageMultiplier[client] = 1.0; + g_iClientRespawnCount[client] = 0; + SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage); } //---------------------------------------------------------------------------------------------------- // Purpose: @@ -1084,8 +1109,6 @@ public void LoadWave(int wave) if (strlen(g_cSMFLAGS[i][g_iLength]) > 0 && StrEqual(g_cTeam[i][g_iLength], "Human")) { Format(g_cHumanClasses[i][g_iLength], sizeof(g_cHumanClasses), g_cUniqueName[i][g_iLength]); - //PrintToChatAll("SUCCESS: g_cTeam[i][g_iLength]: %s", g_cTeam[i][g_iLength]); - //PrintToChatAll("g_cHumanClasses[i][g_iLength]: %s", g_cHumanClasses[i][g_iLength]); } } } @@ -1099,7 +1122,6 @@ public void LoadWave(int wave) } if (StrEqual(l_cLine, g_cUniqueName[i][g_iLength], false)) { - //PrintToChatAll("l_cLine SUCCESS: %s \n%i", l_cLine, i); Format(g_cHumanClasses[i][g_iLength], sizeof(g_cHumanClasses), g_cUniqueName[i][g_iLength]); break; } @@ -1261,6 +1283,8 @@ public void CreateBackUpClassZM(int index) kv.SetString("jump_height", g_cJumpHeight[index][g_iLength]); Format(g_cJumpDistance[index][g_iLength], sizeof(g_cJumpDistance), "1.0"); kv.SetString("jump_distance", g_cJumpDistance[index][g_iLength]); + Format(g_cDamageMultiplier[index][g_iLength], sizeof(g_cDamageMultiplier), "1.0"); + kv.SetString("damage_multiplier", g_cDamageMultiplier[index][g_iLength]); kv.Rewind(); kv.ExportToFile(g_cPathsClassZM); delete kv; @@ -1291,6 +1315,8 @@ public void CreateBackUpClassHuman(int index) kv.SetString("jump_height", g_cJumpHeight[index][g_iLength]); Format(g_cJumpDistance[index][g_iLength], sizeof(g_cJumpDistance), "1.0"); kv.SetString("jump_distance", g_cJumpDistance[index][g_iLength]); + Format(g_cDamageMultiplier[index][g_iLength], sizeof(g_cDamageMultiplier), "1.0"); + kv.SetString("damage_multiplier", g_cDamageMultiplier[index][g_iLength]); kv.Rewind(); kv.ExportToFile(g_cPathsClassHuman); delete kv; @@ -1373,12 +1399,18 @@ public void ReadingClassValuesFromFile(int index, char[] Line) { ReplaceStrings(li_c, "jump_distance"); Format(g_cJumpDistance[index][g_iLength], sizeof(g_cJumpDistance), li_c); + } + else if (StrContains(Line, "damage_multiplier") > -1) + { + ReplaceStrings(li_c, "damage_multiplier"); + Format(g_cDamageMultiplier[index][g_iLength], sizeof(g_cDamageMultiplier), li_c); g_iLoadClassesIndex++; } } //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- +//we should only be able to land in here if terrorist or CT. public Action SelectWavebasedHuman(int client) { if (!IsValidClient(client)) @@ -1388,6 +1420,12 @@ public Action SelectWavebasedHuman(int client) { ChangeClientTeam(client, CS_TEAM_CT); //default putting humans to CT team CreateTimer(1.0, Timer_delayedRespawn, GetClientUserId(client)); + return Plugin_Continue; + } + if (!IsPlayerAlive(client) && CS_TEAM_CT) //this should help if you spawn late into a round so that you actually respawn + { + CreateTimer(1.0, Timer_delayedRespawn, GetClientUserId(client)); + return Plugin_Continue; } ModelSelection(client, 2, g_iClientHumanClasses[client]); @@ -1507,12 +1545,10 @@ public Action ModelSelection(int client, int state, int modelIndex) if (state < 2) { CreateTimer(g_fZMSpawnProtection, Timer_StopProtection, GetClientUserId(client)); - //Client_SetActiveWeapon(client, GetPlayerWeaponSlot(client, 2)); } else { CreateTimer(g_fHumanSpawnProtection, Timer_StopProtection, GetClientUserId(client)); - //Client_SetActiveWeapon(client, GetPlayerWeaponSlot(client, 1)); } if (state < 2) //setting the zombie health here using the HealthScaleAbility. { @@ -1534,6 +1570,7 @@ public Action ModelSelection(int client, int state, int modelIndex) g_fKnockBackIndex[client] = StringToFloat(g_cKnockback[i][g_iLength]); g_fJumpHeightIndex[client] = StringToFloat(g_cJumpHeight[i][g_iLength]); g_fJumpDistanceIndex[client] = StringToFloat(g_cJumpDistance[i][g_iLength]); + g_fDamageMultiplier[client] = StringToFloat(g_cDamageMultiplier[i][g_iLength]); return Plugin_Handled; } } @@ -1611,13 +1648,6 @@ public Action Timer_zombieSounds(Handle timer, any userid) } l_client = l_clients[GetRandomInt(0, l_iclientCount - 1)]; l_iSoundIndexes = GetRandomInt(0, g_iSoundIndexes - 1); - /* - PrintToChatAll("emitting sound from client: %N", l_client); - PrintToChatAll("with l_iSoundIndexes: %i", l_iSoundIndexes); - PrintToChatAll("g_cZMSounds[l_iSoundIndexes][g_iLength]: %s", g_cZMSounds[l_iSoundIndexes][g_iLength]); - EmitSound(l_clients, l_iclientCount, g_cZMSounds[l_iSoundIndexes][g_iLength], l_client, SNDCHAN_BODY, SNDLEVEL_NORMAL, SND_NOFLAGS, 0.45, SNDPITCH_NORMAL); - EmitSoundToAll(g_cZMSounds[l_iSoundIndexes][g_iLength]); - */ for (int i = 1; i < MaxClients; i++) { if (IsValidClient(i) && !IsFakeClient(i)) @@ -1666,7 +1696,29 @@ public Action Timer_StopProtection(Handle timer, any userid) if (client == 0) return Plugin_Continue; if (IsValidClient(client)) + { g_bClientProtection[client] = false; + if (GetPlayerWeaponSlot(client, CS_SLOT_KNIFE) == -1) //just making sure everybody has a knife. otherwise giving them one + { + GivePlayerItem(client, "weapon_knife"); + CreateTimer(1.0, Timer_SwitchKnife, GetClientOfUserId(client)); + } + } + return Plugin_Handled; +} + +public Action Timer_SwitchKnife(Handle timer, any userid) +{ + int client = GetClientOfUserId(userid); + if (client == 0) + return Plugin_Continue; + + if (!IsValidClient(client) || !IsPlayerAlive(client)) + { + return Plugin_Continue; + } + + Client_ChangeWeapon(client, "weapon_knife"); return Plugin_Handled; } //---------------------------------------------------------------------------------------------------- @@ -1701,7 +1753,6 @@ public Action Event_OnPlayerDeath(Handle event, const char[] name, bool dontBroa //---------------------------------------------------------------------------------------------------- public Action UpdateWaveCount(int client) { - //PrintToChatAll("Player %N died", client); if (GetClientTeam(client) == CS_TEAM_CT) { g_iClientRespawnCount[client]--; @@ -1748,11 +1799,17 @@ public Action UpdateWaveCount(int client) //---------------------------------------------------------------------------------------------------- public Action OnTakeDamage(int client, int &attacker, int &inflictor, float &damage, int &damagetype) { - if (g_bClientProtection[client]) - return Plugin_Handled; - else if (damagetype & DMG_FALL && g_bFallDamage[client]) - return Plugin_Handled; - return Plugin_Continue; + if (g_bClientProtection[client]) + return Plugin_Handled; + else if (damagetype & DMG_FALL && g_bFallDamage[client]) + return Plugin_Handled; + if (IsValidClient(attacker) && g_fDamageMultiplier[attacker] != 1.0) //damage multiplier + { + //value lower than 1.0 will reduce the actual damage. + damage *= g_fDamageMultiplier[attacker]; + return Plugin_Changed; + } + return Plugin_Continue; } //---------------------------------------------------------------------------------------------------- // Purpose: zombie reloaded copied knockback