Experimental player movements while jumping: Set a penalty for jumping and correctly reduce speed depending on FPS

This commit is contained in:
s1lentq 2023-11-25 17:47:19 +07:00
parent 2d0ac93f63
commit 412eb67fd2
4 changed files with 25 additions and 5 deletions

View File

@ -2,7 +2,6 @@ name: C/C++ CI
on:
push:
branches: [master]
paths-ignore:
- '**.md'

View File

@ -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()
{
@ -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);

View File

@ -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;

View File

@ -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;
@ -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();
@ -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