Skip to content

Commit

Permalink
Add sv_gameplayfix_elevators cvar
Browse files Browse the repository at this point in the history
If an entity is standing on a platform and gets blocked by it,
try nudging it up a bit first to get it unstuck.

Cvar values:
0 = no fix (vanilla behavior)
1 = fix players only
2 = fix all entities (default)
  • Loading branch information
andrei-drexler committed Jul 20, 2024
1 parent 9587832 commit 93260ab
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Quake/sv_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ void SV_Init (void)
extern cvar_t sv_aim;
extern cvar_t sv_altnoclip; //johnfitz
extern cvar_t sv_gameplayfix_random;
extern cvar_t sv_gameplayfix_elevators;
extern cvar_t sv_autoload;
extern cvar_t sv_autosave;
extern cvar_t sv_autosave_interval;
Expand All @@ -177,6 +178,7 @@ void SV_Init (void)
Cvar_RegisterVariable (&pr_checkextension);
Cvar_RegisterVariable (&sv_altnoclip); //johnfitz
Cvar_RegisterVariable (&sv_gameplayfix_random);
Cvar_RegisterVariable (&sv_gameplayfix_elevators);
Cvar_RegisterVariable (&sv_netsort);
Cvar_RegisterVariable (&sv_autoload);
Cvar_RegisterVariable (&sv_autosave);
Expand Down
16 changes: 16 additions & 0 deletions Quake/sv_phys.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ trace_t SV_PushEntity (edict_t *ent, vec3_t push)
SV_PushMove
============
*/
cvar_t sv_gameplayfix_elevators = {"sv_gameplayfix_elevators", "2", CVAR_ARCHIVE}; // 0=off; 1=clients only; 2=all entities
void SV_PushMove (edict_t *pusher, float movetime)
{
int i, e;
Expand Down Expand Up @@ -473,6 +474,7 @@ void SV_PushMove (edict_t *pusher, float movetime)
check = NEXT_EDICT(qcvm->edicts);
for (e=1 ; e<qcvm->num_edicts ; e++, check = NEXT_EDICT(check))
{
qboolean riding;
if (check->free)
continue;
if (check->v.movetype == MOVETYPE_PUSH
Expand All @@ -495,7 +497,11 @@ void SV_PushMove (edict_t *pusher, float movetime)
// see if the ent's bbox is inside the pusher's final position
if (!SV_TestEntityPosition (check))
continue;

riding = false;
}
else
riding = true;

// remove the onground flag for non-players
if (check->v.movetype != MOVETYPE_WALK)
Expand Down Expand Up @@ -524,6 +530,16 @@ void SV_PushMove (edict_t *pusher, float movetime)
continue;
}

// try moving the entity up a bit if it's blocked by the pusher while also standing on it
if (riding && block == pusher &&
(sv_gameplayfix_elevators.value >= 2.f ||
(sv_gameplayfix_elevators.value && e <= svs.maxclients)))
{
check->v.origin[2] += DIST_EPSILON;
if (!SV_TestEntityPosition (check))
continue;
}

VectorCopy (entorig, check->v.origin);
SV_LinkEdict (check, true);

Expand Down
2 changes: 1 addition & 1 deletion Quake/world.c
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ edict_t *SV_TestEntityPosition (edict_t *ent)
trace = SV_Move (ent->v.origin, ent->v.mins, ent->v.maxs, ent->v.origin, 0, ent);

if (trace.startsolid)
return qcvm->edicts;
return trace.ent ? trace.ent : qcvm->edicts;

return NULL;
}
Expand Down

0 comments on commit 93260ab

Please sign in to comment.