From e3d70d2b14f044ad0a87ac65adce6e88b53c118b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Federico=20Mat=C3=ADas?= <41979395+FEDERICOMB96@users.noreply.github.com> Date: Sun, 26 Nov 2023 01:13:29 -0300 Subject: [PATCH] New CVars: `mp_freezetime_duck` and `mp_freezetime_jump` (#886) * new cvars: prevent duck/jump during freezetime * use CSGameRules() instead of g_pGameRules * changed name of cvars and default value * improved cvars description --- README.md | 2 ++ dist/game.cfg | 14 ++++++++++++++ regamedll/dlls/game.cpp | 5 +++++ regamedll/dlls/game.h | 2 ++ regamedll/pm_shared/pm_shared.cpp | 8 ++++---- 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2785c08ea..ee928a928 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,8 @@ This means that plugins that do binary code analysis (Orpheu for example) probab | mp_dying_time | 3.0 | 0.0 | - | Time for switch to free observing after death.
`0` - disable spectating around death.
`>0.00001` - time delay to start spectate.
`NOTE`: The countdown starts when the player’s death animation is finished. | | mp_deathmsg_flags | abc | 0 | - | Sets a flags for extra information in the player's death message.
`0` disabled
`a` position where the victim died
`b` index of the assistant who helped the attacker kill the victim
`c` rarity classification bits, e.g., `blinkill`, `noscope`, `penetrated`, etc. | | mp_assist_damage_threshold | 40 | 0 | 100 | Sets the percentage of damage needed to score an assist. | +| mp_freezetime_duck | 1 | 0 | 1 | Allow players to duck during freezetime.
`0` disabled
`1` enabled | +| mp_freezetime_jump | 1 | 0 | 1 | Allow players to jump during freezetime.
`0` disabled
`1` enabled | ## How to install zBot for CS 1.6? diff --git a/dist/game.cfg b/dist/game.cfg index 8f0b9d478..a1d77c205 100644 --- a/dist/game.cfg +++ b/dist/game.cfg @@ -553,3 +553,17 @@ mp_deathmsg_flags "abc" // // Default value: "40" mp_assist_damage_threshold "40" + +// Allow players to duck during freezetime +// 0 - disabled +// 1 - enabled (default behaviour) +// +// Default value: "1" +mp_freezetime_duck "1" + +// Allow players to jump during freezetime +// 0 - disabled +// 1 - enabled (default behaviour) +// +// Default value: "1" +mp_freezetime_jump "1" \ No newline at end of file diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp index 0e792e09c..5d9238196 100644 --- a/regamedll/dlls/game.cpp +++ b/regamedll/dlls/game.cpp @@ -168,6 +168,8 @@ cvar_t plant_c4_anywhere = { "mp_plant_c4_anywhere", "0", 0, 0.0 cvar_t give_c4_frags = { "mp_give_c4_frags", "3", 0, 3.0f, nullptr }; cvar_t deathmsg_flags = { "mp_deathmsg_flags", "abc", 0, 0.0f, nullptr }; cvar_t assist_damage_threshold = { "mp_assist_damage_threshold", "40", 0, 40.0f, nullptr }; +cvar_t freezetime_duck = { "mp_freezetime_duck", "1", 0, 1.0f, nullptr }; +cvar_t freezetime_jump = { "mp_freezetime_jump", "1", 0, 1.0f, nullptr }; cvar_t hostages_rescued_ratio = { "mp_hostages_rescued_ratio", "1.0", 0, 1.0f, nullptr }; @@ -428,6 +430,9 @@ void EXT_FUNC GameDLLInit() CVAR_REGISTER(&deathmsg_flags); CVAR_REGISTER(&assist_damage_threshold); + CVAR_REGISTER(&freezetime_duck); + CVAR_REGISTER(&freezetime_jump); + // print version CONSOLE_ECHO("ReGameDLL version: " APP_VERSION "\n"); diff --git a/regamedll/dlls/game.h b/regamedll/dlls/game.h index b9b9253b9..3791a3c1f 100644 --- a/regamedll/dlls/game.h +++ b/regamedll/dlls/game.h @@ -197,6 +197,8 @@ extern cvar_t legacy_vehicle_block; extern cvar_t dying_time; extern cvar_t deathmsg_flags; extern cvar_t assist_damage_threshold; +extern cvar_t freezetime_duck; +extern cvar_t freezetime_jump; #endif diff --git a/regamedll/pm_shared/pm_shared.cpp b/regamedll/pm_shared/pm_shared.cpp index afc528ea8..c452e406d 100644 --- a/regamedll/pm_shared/pm_shared.cpp +++ b/regamedll/pm_shared/pm_shared.cpp @@ -1893,8 +1893,8 @@ void EXT_FUNC __API_HOOK(PM_Duck)() } #ifdef REGAMEDLL_ADD - // Prevent ducking if the iuser3 variable is contain PLAYER_PREVENT_DUCK - if ((pmove->iuser3 & PLAYER_PREVENT_DUCK) == PLAYER_PREVENT_DUCK) + if ((pmove->iuser3 & PLAYER_PREVENT_DUCK) == PLAYER_PREVENT_DUCK // Prevent ducking if the iuser3 variable is contain PLAYER_PREVENT_DUCK + || freezetime_duck.value == 0.0f && CSGameRules()->IsFreezePeriod()) // Prevent ducking during freezetime if the freezetime_duck cvar is 0 { // Try to unduck if (pmove->flags & FL_DUCKING) @@ -2449,8 +2449,8 @@ void EXT_FUNC __API_HOOK(PM_Jump)() } #ifdef REGAMEDLL_ADD - // Prevent jumping if the iuser3 variable is contain PLAYER_PREVENT_JUMP - if ((pmove->iuser3 & PLAYER_PREVENT_JUMP) == PLAYER_PREVENT_JUMP) + if ((pmove->iuser3 & PLAYER_PREVENT_JUMP) == PLAYER_PREVENT_JUMP // Prevent jumping if the iuser3 variable is contain PLAYER_PREVENT_JUMP + || freezetime_jump.value == 0.0f && CSGameRules()->IsFreezePeriod()) // Prevent jumping during freezetime if the freezetime_jump cvar is 0 { return; }