trigger_one: Fix it up to bring it up to standards.

func_pushable: Ditto, simplify Touch()
This commit is contained in:
Marco Cawthorne 2022-04-23 22:03:51 -07:00
parent 767fdd0913
commit a28caedf40
Signed by: eukara
GPG key ID: C196CD8BA993248A
2 changed files with 18 additions and 20 deletions

View file

@ -42,7 +42,7 @@ class func_pushable:func_breakable
virtual void(string, string) Restore; virtual void(string, string) Restore;
virtual void(void) customphysics; virtual void(void) customphysics;
virtual void(void) Respawn; virtual void(void) Respawn;
virtual void(void) PlayerTouch; virtual void(entity) Touch;
virtual void(void) OnPlayerUse; virtual void(void) OnPlayerUse;
}; };
@ -114,32 +114,29 @@ func_pushable::customphysics(void)
if (vlen(velocity)) if (vlen(velocity))
runstandardplayerphysics(this); runstandardplayerphysics(this);
setorigin(m_eCollBox, WorldSpaceCenter()); setorigin(m_eCollBox, position);
} }
void void
func_pushable::PlayerTouch(void) func_pushable::Touch(entity eToucher)
{ {
/* don't cause bounces */ /* don't cause bounces */
if (other.movetype == MOVETYPE_NONE) { if (eToucher.movetype == MOVETYPE_NONE) {
return; return;
} }
/* get the real position of the pushable */
vector position = WorldSpaceCenter();
/* check if we're inside the pushable */ /* check if we're inside the pushable */
if (other.origin[0] >= absmin[0] && other.origin[0] <= absmax[0]) if (eToucher.origin[0] >= absmin[0] && eToucher.origin[0] <= absmax[0])
if (other.origin[1] >= absmin[1] && other.origin[1] <= absmax[1]) if (eToucher.origin[1] >= absmin[1] && eToucher.origin[1] <= absmax[1])
return; return;
/* check if we're above the pushable... */ /* check if we're above the pushable... */
if ((other.absmin[2] + 16) >= absmax[2]) { if ((eToucher.absmin[2] + 16) >= absmax[2]) {
return; return;
} }
/* get the direction of the pushing player towards the pushable, then get a matrix */ /* 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 */ /* add forward direction times speed */
velocity = v_forward * -64; velocity = v_forward * -64;
@ -155,8 +152,9 @@ void
func_pushable::Respawn(void) func_pushable::Respawn(void)
{ {
super::Respawn(); super::Respawn();
movetype = MOVETYPE_STEP; //SetSolid(SOLID_BSP);
touch = PlayerTouch; SetOrigin(GetSpawnOrigin());
SetMovetype(MOVETYPE_STEP);
PlayerUse = OnPlayerUse; PlayerUse = OnPlayerUse;
if (!m_eCollBox) { if (!m_eCollBox) {

View file

@ -49,7 +49,7 @@ class trigger_once:NSBrushTrigger
virtual void(float) Save; virtual void(float) Save;
virtual void(string, string) Restore; virtual void(string, string) Restore;
virtual void(void) touch; virtual void(entity) Touch;
virtual void(void) Respawn; virtual void(void) Respawn;
virtual void(string, string) SpawnKey; virtual void(string, string) SpawnKey;
}; };
@ -78,26 +78,26 @@ trigger_once::Restore(string strKey, string strValue)
} }
void void
trigger_once::touch(void) trigger_once::Touch(entity eToucher)
{ {
if (GetMaster() == FALSE) if (GetMaster() == FALSE)
return; return;
if (HasSpawnFlags(TO_NOCLIENTS) && other.flags & FL_CLIENT) if (HasSpawnFlags(TO_NOCLIENTS) && eToucher.flags & FL_CLIENT)
return; return;
if (!HasSpawnFlags(TO_MONSTERS) && other.flags & FL_MONSTER) if (!HasSpawnFlags(TO_MONSTERS) && eToucher.flags & FL_MONSTER)
return; return;
if (!HasSpawnFlags(TO_PUSHABLES) && other.classname == "func_pushable") if (!HasSpawnFlags(TO_PUSHABLES) && eToucher.classname == "func_pushable")
return; return;
SetSolid(SOLID_NOT); /* make inactive */ SetSolid(SOLID_NOT); /* make inactive */
m_iValue = 1; m_iValue = 1;
if (!target) { if (!target) {
UseOutput(other, m_strOnStartTouch); UseOutput(eToucher, m_strOnStartTouch);
return; return;
} }
UseTargets(other, TRIG_TOGGLE, m_flDelay); UseTargets(eToucher, TRIG_TOGGLE, m_flDelay);
} }
void void