Skip to content

Commit

Permalink
add sv_retouch for stationary monster triggers
Browse files Browse the repository at this point in the history
fixes bugs with monsters not being affected by things like trigger_push or trigger_hurt while not moving. Possibly causes other bugs. "sv_retouch 1" to enable
  • Loading branch information
wootguy committed Jun 23, 2024
1 parent 457a35c commit b102e35
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions rehlds/engine/sv_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8142,6 +8142,7 @@ void SV_Init(void)
Cvar_RegisterVariable(&sv_lowercase);
Cvar_RegisterVariable(&sv_printcvar);
Cvar_RegisterVariable(&sv_max_client_edicts);
Cvar_RegisterVariable(&sv_retouch);
#endif

for (int i = 0; i < MAX_MODELS; i++)
Expand Down
24 changes: 22 additions & 2 deletions rehlds/engine/sv_phys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ cvar_t sv_stepsize = { "sv_stepsize", "18", FCVAR_SERVER, 0.0f, NULL };
cvar_t sv_ledgesize = { "sv_ledgesize", "18", FCVAR_SERVER, 0.0f, NULL };
cvar_t sv_friction = { "sv_friction", "4", FCVAR_SERVER, 0.0f, NULL };
cvar_t sv_stopspeed = { "sv_stopspeed", "100", FCVAR_SERVER, 0.0f, NULL };
cvar_t sv_retouch = { "sv_retouch", "0", 0, 1.0f, nullptr };

NOXREF void SV_CheckAllEnts()
{
Expand Down Expand Up @@ -1057,8 +1058,15 @@ void SV_Physics_Toss(edict_t *ent)
{
VectorClear(ent->v.avelocity);

if (VectorIsZero(ent->v.basevelocity))
if (VectorIsZero(ent->v.basevelocity)) {

if (sv_retouch.value) {
// force retouch even for stationary
SV_LinkEdict(ent, TRUE);
}

return; // at rest
}
}

SV_CheckVelocity(ent);
Expand Down Expand Up @@ -1134,8 +1142,15 @@ void SV_Physics_Bounce(edict_t *ent)
{
VectorClear(ent->v.avelocity);

if (VectorIsZero(ent->v.basevelocity))
if (VectorIsZero(ent->v.basevelocity)) {

if (sv_retouch.value) {
// force retouch even for stationary
SV_LinkEdict(ent, TRUE);
}

return; // at rest
}
}

SV_CheckVelocity(ent);
Expand Down Expand Up @@ -1463,6 +1478,11 @@ void SV_Physics_Step(edict_t *ent)
SV_Impact(ent, trace.ent, &trace);
}
}

if (sv_retouch.value) {
// always run touch functions for triggers touched by stationary monsters
SV_LinkEdict(ent, TRUE);
}
}

// regular thinking
Expand Down
1 change: 1 addition & 0 deletions rehlds/engine/sv_phys.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ extern cvar_t sv_stepsize;
extern cvar_t sv_ledgesize;
extern cvar_t sv_friction;
extern cvar_t sv_stopspeed;
extern cvar_t sv_retouch;

extern vec3_t *g_moved_from;
extern edict_t **g_moved_edict;
Expand Down

0 comments on commit b102e35

Please sign in to comment.