nuclide/Source/Server/FuncLadder.c

99 lines
2.3 KiB
C
Raw Normal View History

2016-12-01 17:50:48 +00:00
/*
2017-04-30 23:21:49 +00:00
FreeCS Project
Copyright (C) 2016, 2017 Marco "eukara" Hladik
2016-12-01 17:50:48 +00:00
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
2017-04-19 21:06:41 +00:00
// Uncomment this once FTEs engine ladder is fixed?
//#define FTE_LADDER
2016-12-01 17:50:48 +00:00
/*
=================
func_ladder_sound
=================
*/
void func_ladder_sound( entity target ) {
2016-12-01 17:50:48 +00:00
if ( ( target.velocity_z == 0 ) || ( target.fStepTime > time ) ) {
return;
}
2017-04-19 21:06:41 +00:00
float vStep = target.velocity_z;
2016-12-01 17:50:48 +00:00
if ( vStep < 0 ) {
vStep *= -1.0;
}
float fForce = vStep;
float fDelay = clamp( 0.1, 1 / ( fForce / 90 ), 1 );
sound( target, CHAN_BODY, sprintf( "player/pl_ladder%d.wav", floor( random() * 4 ) + 1 ), 0.5, ATTN_IDLE );
target.fStepTime = ( time + fDelay );
2016-12-01 17:50:48 +00:00
}
/*
=================
func_ladder_touch
=================
*/
void func_ladder_touch( void ) {
2016-12-01 17:50:48 +00:00
if ( other.classname != "player" ) {
return;
}
2017-04-19 21:06:41 +00:00
#ifndef FTE_LADDER
vector vPlayerVector;
2016-12-01 17:50:48 +00:00
makevectors( other.v_angle );
vPlayerVector = v_forward;
vPlayerVector = ( vPlayerVector * 240 );
if ( other.movement_x > 0 ) {
other.velocity = vPlayerVector;
} else {
other.velocity = '0 0 0';
}
2017-04-19 21:06:41 +00:00
#endif
2016-12-01 17:50:48 +00:00
func_ladder_sound( other );
}
/*
=================
SPAWN: func_ladder
A trigger like brush that allows you to 'climb' up or down
=================
*/
void func_ladder( void ) {
precache_sound( "player/pl_ladder1.wav" );
precache_sound( "player/pl_ladder2.wav" );
precache_sound( "player/pl_ladder3.wav" );
precache_sound( "player/pl_ladder4.wav" );
self.angles = '0 0 0';
self.movetype = MOVETYPE_NONE;
self.solid = SOLID_TRIGGER;
setmodel( self, self.model );
self.model = 0;
2017-04-19 21:06:41 +00:00
#ifdef FTE_LADDER
self.skin = CONTENT_LADDER;
self.alpha = 0.001;
#endif
2016-12-01 17:50:48 +00:00
self.touch = func_ladder_touch;
}