Skip to content

Commit

Permalink
New CVars: mp_freezetime_duck and mp_freezetime_jump (#886)
Browse files Browse the repository at this point in the history
* new cvars: prevent duck/jump during freezetime
* use CSGameRules() instead of g_pGameRules
* changed name of cvars and default value
* improved cvars description
  • Loading branch information
FEDERICOMB96 authored Nov 26, 2023
1 parent 2d0ac93 commit e3d70d2
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br/>`0` - disable spectating around death.<br/>`>0.00001` - time delay to start spectate.<br/>`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.<br/>`0` disabled<br/>`a` position where the victim died<br/>`b` index of the assistant who helped the attacker kill the victim<br/>`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.<br/> `0` disabled<br/>`1` enabled |
| mp_freezetime_jump | 1 | 0 | 1 | Allow players to jump during freezetime.<br/> `0` disabled<br/>`1` enabled |
</details>

## How to install zBot for CS 1.6?
Expand Down
14 changes: 14 additions & 0 deletions dist/game.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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"
5 changes: 5 additions & 0 deletions regamedll/dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

Expand Down Expand Up @@ -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");

Expand Down
2 changes: 2 additions & 0 deletions regamedll/dlls/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions regamedll/pm_shared/pm_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit e3d70d2

Please sign in to comment.