From a28caedf40462c0cca2d9147e5c38bb776d44ef4 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Sat, 23 Apr 2022 22:03:51 -0700 Subject: [PATCH] trigger_one: Fix it up to bring it up to standards. func_pushable: Ditto, simplify Touch() --- src/gs-entbase/server/func_pushable.qc | 24 +++++++++++------------- src/gs-entbase/server/trigger_once.qc | 14 +++++++------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/gs-entbase/server/func_pushable.qc b/src/gs-entbase/server/func_pushable.qc index 98aa6e3d..bc7d5420 100644 --- a/src/gs-entbase/server/func_pushable.qc +++ b/src/gs-entbase/server/func_pushable.qc @@ -42,7 +42,7 @@ class func_pushable:func_breakable virtual void(string, string) Restore; virtual void(void) customphysics; virtual void(void) Respawn; - virtual void(void) PlayerTouch; + virtual void(entity) Touch; virtual void(void) OnPlayerUse; }; @@ -114,32 +114,29 @@ func_pushable::customphysics(void) if (vlen(velocity)) runstandardplayerphysics(this); - setorigin(m_eCollBox, WorldSpaceCenter()); + setorigin(m_eCollBox, position); } void -func_pushable::PlayerTouch(void) +func_pushable::Touch(entity eToucher) { /* don't cause bounces */ - if (other.movetype == MOVETYPE_NONE) { + if (eToucher.movetype == MOVETYPE_NONE) { return; } - /* get the real position of the pushable */ - vector position = WorldSpaceCenter(); - /* check if we're inside the pushable */ - if (other.origin[0] >= absmin[0] && other.origin[0] <= absmax[0]) - if (other.origin[1] >= absmin[1] && other.origin[1] <= absmax[1]) + if (eToucher.origin[0] >= absmin[0] && eToucher.origin[0] <= absmax[0]) + if (eToucher.origin[1] >= absmin[1] && eToucher.origin[1] <= absmax[1]) return; /* check if we're above the pushable... */ - if ((other.absmin[2] + 16) >= absmax[2]) { + if ((eToucher.absmin[2] + 16) >= absmax[2]) { return; } /* get the direction of the pushing player towards the pushable, then get a matrix */ - makevectors(vectoangles(other.origin - position)); + makevectors(vectoangles(eToucher.origin - WorldSpaceCenter())); /* add forward direction times speed */ velocity = v_forward * -64; @@ -155,8 +152,9 @@ void func_pushable::Respawn(void) { super::Respawn(); - movetype = MOVETYPE_STEP; - touch = PlayerTouch; + //SetSolid(SOLID_BSP); + SetOrigin(GetSpawnOrigin()); + SetMovetype(MOVETYPE_STEP); PlayerUse = OnPlayerUse; if (!m_eCollBox) { diff --git a/src/gs-entbase/server/trigger_once.qc b/src/gs-entbase/server/trigger_once.qc index 47605983..0665f989 100644 --- a/src/gs-entbase/server/trigger_once.qc +++ b/src/gs-entbase/server/trigger_once.qc @@ -49,7 +49,7 @@ class trigger_once:NSBrushTrigger virtual void(float) Save; virtual void(string, string) Restore; - virtual void(void) touch; + virtual void(entity) Touch; virtual void(void) Respawn; virtual void(string, string) SpawnKey; }; @@ -78,26 +78,26 @@ trigger_once::Restore(string strKey, string strValue) } void -trigger_once::touch(void) +trigger_once::Touch(entity eToucher) { if (GetMaster() == FALSE) return; - if (HasSpawnFlags(TO_NOCLIENTS) && other.flags & FL_CLIENT) + if (HasSpawnFlags(TO_NOCLIENTS) && eToucher.flags & FL_CLIENT) return; - if (!HasSpawnFlags(TO_MONSTERS) && other.flags & FL_MONSTER) + if (!HasSpawnFlags(TO_MONSTERS) && eToucher.flags & FL_MONSTER) return; - if (!HasSpawnFlags(TO_PUSHABLES) && other.classname == "func_pushable") + if (!HasSpawnFlags(TO_PUSHABLES) && eToucher.classname == "func_pushable") return; SetSolid(SOLID_NOT); /* make inactive */ m_iValue = 1; if (!target) { - UseOutput(other, m_strOnStartTouch); + UseOutput(eToucher, m_strOnStartTouch); return; } - UseTargets(other, TRIG_TOGGLE, m_flDelay); + UseTargets(eToucher, TRIG_TOGGLE, m_flDelay); } void