From 3b4025746bc6e16d69dfc54552d327c24eccc8c6 Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Fri, 7 Oct 2022 22:37:58 +1000 Subject: [PATCH] func_door: fix erratic behaviour of spawned trigger field This was most noticeable with door .wait <= 1 but would eventually occur at higher wait values if players hang around in the trigger field. Also the door(s) usually did not stay open for the full .wait time after the player left the trigger field, as some time had passed since the .door_finished timestamp was set. To make this reliable AND efficient requires updating the state of the door(s), instead of maintaining a separate state in the trigger field entity. --- qcsrc/common/mapobjects/func/door.qc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/qcsrc/common/mapobjects/func/door.qc b/qcsrc/common/mapobjects/func/door.qc index 1316c3283..aed02cf3d 100644 --- a/qcsrc/common/mapobjects/func/door.qc +++ b/qcsrc/common/mapobjects/func/door.qc @@ -369,14 +369,25 @@ void door_trigger_touch(entity this, entity toucher) #endif return; - if (time < this.door_finished) + if (this.owner.state == STATE_UP) return; // check if door is locked if (!door_check_keys(this, toucher)) return; - this.door_finished = time + 1; + if (this.owner.state == STATE_TOP) + { + if (this.owner.nextthink < this.owner.ltime + this.owner.wait) + { + entity e = this.owner; + do { + e.nextthink = e.ltime + e.wait; + e = e.enemy; + } while (e != this.owner); + } + return; + } door_use(this.owner, toucher, NULL); } -- 2.39.2