Skip to content

Commit

Permalink
Experimental player movements while jumping: Set a penalty for jumpin…
Browse files Browse the repository at this point in the history
…g and correctly reduce speed depending on FPS
  • Loading branch information
s1lentq committed Nov 25, 2023
1 parent 2d0ac93 commit 412eb67
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: C/C++ CI

on:
push:
branches: [master]
paths-ignore:
- '**.md'

Expand Down
4 changes: 4 additions & 0 deletions regamedll/dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ cvar_t hostages_rescued_ratio = { "mp_hostages_rescued_ratio", "1.0", 0, 1.0f, n
cvar_t legacy_vehicle_block = { "mp_legacy_vehicle_block", "1", 0, 0.0f, nullptr };

cvar_t dying_time = { "mp_dying_time", "3.0", 0, 3.0f, nullptr };
cvar_t player_movement_legacy = { "mp_player_movement_legacy", "1", 0, 1.0f, nullptr };
cvar_t player_movement_penalty_jump = {"mp_player_movement_penalty_jump", "100", 0, 100.0f, nullptr};

void GameDLL_Version_f()
{
Expand Down Expand Up @@ -425,6 +427,8 @@ void EXT_FUNC GameDLLInit()
CVAR_REGISTER(&legacy_vehicle_block);

CVAR_REGISTER(&dying_time);
CVAR_REGISTER(&player_movement_legacy);
CVAR_REGISTER(&player_movement_penalty_jump);
CVAR_REGISTER(&deathmsg_flags);
CVAR_REGISTER(&assist_damage_threshold);

Expand Down
2 changes: 2 additions & 0 deletions regamedll/dlls/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ extern cvar_t give_c4_frags;
extern cvar_t hostages_rescued_ratio;
extern cvar_t legacy_vehicle_block;
extern cvar_t dying_time;
extern cvar_t player_movement_legacy;
extern cvar_t player_movement_penalty_jump;
extern cvar_t deathmsg_flags;
extern cvar_t assist_damage_threshold;

Expand Down
23 changes: 19 additions & 4 deletions regamedll/pm_shared/pm_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,14 @@ void PM_WalkMove()

if (pmove->fuser2 > 0.0)
{
real_t flRatio = (100 - pmove->fuser2 * 0.001 * 19) * 0.01;
real_t flRatio;

#ifdef REGAMEDLL_ADD
if (player_movement_legacy.value == 0)
flRatio = (100.0 - pmove->fuser2 * 0.001 * 19.0 * player_movement_penalty_jump.value * pmove->frametime) * 0.01;
else
#endif
flRatio = (100.0 - pmove->fuser2 * 0.001 * 19.0) * 0.01;

pmove->velocity[0] *= flRatio;
pmove->velocity[1] *= flRatio;
Expand Down Expand Up @@ -2555,11 +2562,19 @@ void EXT_FUNC __API_HOOK(PM_Jump)()
if (pmove->fuser2 > 0.0f)
{
// NOTE: don't do it in .f (float)
real_t flRatio = (100.0 - pmove->fuser2 * 0.001 * 19.0) * 0.01;
real_t flRatio;

#ifdef REGAMEDLL_ADD
if (player_movement_legacy.value == 0)
flRatio = (100.0 - pmove->fuser2 * 0.001 * 19.0 * player_movement_penalty_jump.value * pmove->frametime) * 0.01;
else
#endif
flRatio = (100.0 - pmove->fuser2 * 0.001 * 19.0) * 0.01;

pmove->velocity[2] *= flRatio;
}

pmove->fuser2 = 1315.789429;
pmove->fuser2 = 100.0 * 1000.0 / 19.0 / 4.0;

// Decay it for simulation
PM_FixupGravityVelocity();
Expand Down Expand Up @@ -3275,7 +3290,7 @@ void EXT_FUNC __API_HOOK(PM_Move)(struct playermove_s *ppmove, int server)
assert(pm_shared_initialized);

pmove = ppmove;

#ifdef REGAMEDLL_API
pmoveplayer = UTIL_PlayerByIndex(pmove->player_index + 1)->CSPlayer();
#endif
Expand Down

0 comments on commit 412eb67

Please sign in to comment.