Skip to content

Commit

Permalink
Add support IN_RUN key for +speed button in spectator/noclip and walk…
Browse files Browse the repository at this point in the history
… moves

Add cheat impulse for enable Noclip with air accelerate
  • Loading branch information
s1lentq committed Aug 5, 2024
1 parent 17386ac commit 279799b
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 12 deletions.
20 changes: 20 additions & 0 deletions regamedll/dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6768,6 +6768,26 @@ void CBasePlayer::CheatImpulseCommands(int iImpulse)

break;
}
#ifdef REGAMEDLL_ADD
// noclip with air acceleration
case 200:
{
if (pev->movetype == MOVETYPE_WALK)
{
pev->movetype = MOVETYPE_NOCLIP;
pev->fuser3 = MAX_PLAYER_RUN_MODIFIER_SPEED; // air acceleration increases xN times
ALERT(at_console, "noclip ON\n");
}
else
{
pev->movetype = MOVETYPE_WALK;
pev->fuser3 = 0;
ALERT(at_console, "noclip OFF\n");
}

break;
}
#endif
case 202:
{
// Random blood splatter
Expand Down
7 changes: 4 additions & 3 deletions regamedll/dlls/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ const int MAX_BUFFER_MENU_BRIEFING = 50;
const float SUIT_UPDATE_TIME = 3.5f;
const float SUIT_FIRST_UPDATE_TIME = 0.1f;

const float MAX_PLAYER_FATAL_FALL_SPEED = 1100.0f;
const float MAX_PLAYER_SAFE_FALL_SPEED = 500.0f;
const float MAX_PLAYER_USE_RADIUS = 64.0f;
const float MAX_PLAYER_FATAL_FALL_SPEED = 1100.0f;
const float MAX_PLAYER_SAFE_FALL_SPEED = 500.0f;
const float MAX_PLAYER_USE_RADIUS = 64.0f;
const float MAX_PLAYER_RUN_MODIFIER_SPEED = 10.0f; // x10 speed run when IN_RUN button is pressed

const float ARMOR_RATIO = 0.5f; // Armor Takes 50% of the damage
const float ARMOR_BONUS = 0.5f; // Each Point of Armor is work 1/x points of health
Expand Down
53 changes: 44 additions & 9 deletions regamedll/pm_shared/pm_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ void PM_WalkMove()

vec3_t wishvel;
real_t spd;
float fmove, smove;
float fmove, smove, maxspeed;
vec3_t wishdir;
real_t wishspeed;

Expand All @@ -882,6 +882,7 @@ void PM_WalkMove()

pmtrace_t trace;

// jump penalty
if (pmove->fuser2 > 0.0)
{
real_t flRatio = (100 - pmove->fuser2 * 0.001 * 19) * 0.01;
Expand All @@ -893,6 +894,17 @@ void PM_WalkMove()
// Copy movement amounts
fmove = pmove->cmd.forwardmove;
smove = pmove->cmd.sidemove;
maxspeed = pmove->maxspeed;

#ifdef REGAMEDLL_ADD
// Player can speed up the run if '+speed' button is pressed
if ((pmove->cmd.buttons & IN_RUN) && pmove->fuser3 > 0)
{
fmove *= pmove->fuser3;
smove *= pmove->fuser3;
maxspeed *= 2.0f; // increase speed cap to x2 when running
}
#endif

// Zero out z components of movement vectors
pmove->forward[2] = 0;
Expand All @@ -916,10 +928,10 @@ void PM_WalkMove()
wishspeed = VectorNormalize(wishdir);

// Clamp to server defined max speed
if (wishspeed > pmove->maxspeed)
if (wishspeed > maxspeed)
{
VectorScale(wishvel, pmove->maxspeed / wishspeed, wishvel);
wishspeed = pmove->maxspeed;
VectorScale(wishvel, maxspeed / wishspeed, wishvel);
wishspeed = maxspeed;
}

// Set pmove velocity
Expand Down Expand Up @@ -1636,7 +1648,7 @@ void PM_SpectatorMove()
real_t accelspeed;
int i;
vec3_t wishvel;
float fmove, smove;
float fmove, smove, spectatormaxspeed;
vec3_t wishdir;
real_t wishspeed;

Expand Down Expand Up @@ -1688,6 +1700,19 @@ void PM_SpectatorMove()
fmove = pmove->cmd.forwardmove;
smove = pmove->cmd.sidemove;

spectatormaxspeed = pmove->movevars->spectatormaxspeed;

#ifdef REGAMEDLL_ADD
// Observer can accelerate in air if '+speed' button is pressed
if (pmove->cmd.buttons & IN_RUN)
{
float flAirAccelerate = (pmove->fuser3 > 0.0f) ? pmove->fuser3 : max(pmove->movevars->airaccelerate / 100.0f, 7.0f);
fmove *= flAirAccelerate;
smove *= flAirAccelerate;
spectatormaxspeed *= 2.0f; // increase speed cap to x2 when accelerating
}
#endif

VectorNormalize(pmove->forward);
VectorNormalize(pmove->right);

Expand All @@ -1702,17 +1727,17 @@ void PM_SpectatorMove()
wishspeed = VectorNormalize(wishdir);

// clamp to server defined max speed
if (wishspeed > pmove->movevars->spectatormaxspeed)
if (wishspeed > spectatormaxspeed)
{
VectorScale(wishvel, pmove->movevars->spectatormaxspeed / wishspeed, wishvel);
wishspeed = pmove->movevars->spectatormaxspeed;
VectorScale(wishvel, spectatormaxspeed / wishspeed, wishvel);
wishspeed = spectatormaxspeed;
}

currentspeed = DotProduct(pmove->velocity, wishdir);

addspeed = wishspeed - currentspeed;

#ifdef REGAMEDLL_FIXES
#ifndef REGAMEDLL_FIXES
if (addspeed <= 0)
return;
#else
Expand Down Expand Up @@ -2338,6 +2363,16 @@ void PM_NoClip()
fmove = pmove->cmd.forwardmove;
smove = pmove->cmd.sidemove;

#ifdef REGAMEDLL_ADD
// Player with noclip can accelerate in air if '+speed' button is pressed
if ((pmove->cmd.buttons & IN_RUN) && pmove->fuser3 > 0)
{
float flAirAccelerate = pmove->fuser3;
fmove *= flAirAccelerate;
smove *= flAirAccelerate;
}
#endif

VectorNormalize(pmove->forward);
VectorNormalize(pmove->right);

Expand Down

0 comments on commit 279799b

Please sign in to comment.