From b102e3519e5fd86757c761cc52075ca345d3e21c Mon Sep 17 00:00:00 2001 From: wootguy Date: Sat, 22 Jun 2024 18:21:04 -0700 Subject: [PATCH] add sv_retouch for stationary monster triggers 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 --- rehlds/engine/sv_main.cpp | 1 + rehlds/engine/sv_phys.cpp | 24 ++++++++++++++++++++++-- rehlds/engine/sv_phys.h | 1 + 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index 3f0b5fca..1975c567 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -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++) diff --git a/rehlds/engine/sv_phys.cpp b/rehlds/engine/sv_phys.cpp index b9b127f3..0fa9bf2b 100644 --- a/rehlds/engine/sv_phys.cpp +++ b/rehlds/engine/sv_phys.cpp @@ -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() { @@ -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); @@ -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); @@ -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 diff --git a/rehlds/engine/sv_phys.h b/rehlds/engine/sv_phys.h index 0bb68bd6..bfc0e758 100644 --- a/rehlds/engine/sv_phys.h +++ b/rehlds/engine/sv_phys.h @@ -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;