nuclide/Source/gs-entbase/server/trigger_push.cpp

112 lines
2.1 KiB
C++
Raw Normal View History

/***
*
* Copyright (c) 2016-2019 Marco 'eukara' Hladik. All rights reserved.
*
* See the file LICENSE attached with the sources for usage details.
*
****/
#define TP_ONCE 1
#define TP_STARTOFF 2
#define TP_AAAA 4
class CTriggerPush : CBaseTrigger
{
vector m_vecMoveDir;
float m_flDelay;
float m_flSpeed;
void() CTriggerPush;
virtual void() touch;
virtual void() Respawn;
virtual void() Trigger;
virtual void() SetMovementDirection;
};
void CTriggerPush :: SetMovementDirection ( void )
{
if ( angles == '0 -1 0' ) {
m_vecMoveDir = '0 0 1';
} else if ( angles == '0 -2 0' ) {
m_vecMoveDir = '0 0 -1';
} else {
makevectors( angles );
m_vecMoveDir = v_forward;
}
angles = '0 0 0';
//m_vecMoveDir *= 1;
}
void CTriggerPush :: Trigger ( void )
{
if ( solid == SOLID_NOT ) {
solid = SOLID_TRIGGER;
} else {
solid = SOLID_NOT;
}
}
void CTriggerPush :: touch ( void )
{
switch( other.movetype )
{
case MOVETYPE_NONE:
case MOVETYPE_PUSH:
case MOVETYPE_NOCLIP:
case MOVETYPE_FOLLOW:
return;
}
if ( other.solid != SOLID_NOT && other.solid != SOLID_BSP ) {
if ( spawnflags & TP_ONCE ) {
other.velocity = other.velocity + (m_flSpeed * m_vecMoveDir);
if ( other.velocity[2] > 0 )
other.flags &= ~FL_ONGROUND;
remove( self );
} else {
/*vector vecPush = m_flSpeed * m_vecMoveDir;
if ( other.flags & FL_BASEVELOCITY ) {
vecPush = vecPush + other.basevelocity;
}
other.basevelocity = vecPush;
other.flags |= FL_BASEVELOCITY;*/
}
}
}
void CTriggerPush :: Respawn ( void )
{
if ( angles == '0 0 0' ) {
angles[1] = 360;
}
SetMovementDirection();
if ( m_flSpeed == 0 ) {
m_flSpeed = 100;
}
if ( spawnflags & TP_STARTOFF ) {
solid = SOLID_NOT;
}
}
void CTriggerPush :: CTriggerPush ( void )
{
for ( int i = 1; i < ( tokenize( __fullspawndata ) - 1 ); i += 2 ) {
switch ( argv( i ) ) {
case "speed":
m_flSpeed = stof( argv( i + 1 ) );
break;
default:
break;
}
}
CBaseTrigger::CBaseTrigger();
CBaseTrigger::InitBrushTrigger();
CTriggerPush::Respawn();
}
CLASSEXPORT( trigger_push, CTriggerPush )