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(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) {

View file

@ -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