2016-12-02 18:45:59 +00:00
|
|
|
/*
|
|
|
|
OpenCS Project
|
|
|
|
Copyright (C) 2015 Marco "eukara" Hladik
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
.float fSteptime;
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
Footsteps_Update
|
|
|
|
|
|
|
|
TODO: Read sound/materials.txt and use that somehow
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
void Footsteps_Update( void ) {
|
|
|
|
float fForce;
|
|
|
|
float dDelay;
|
|
|
|
vector vStep;
|
|
|
|
|
|
|
|
if ( ( self.movetype == MOVETYPE_WALK ) && ( self.flags & FL_ONGROUND ) ) {
|
|
|
|
if ( ( self.velocity_x == 0 && self.velocity_y == 0 ) || self.fSteptime > time ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
vStep_x = fabs( self.velocity_x );
|
|
|
|
vStep_y = fabs( self.velocity_y );
|
|
|
|
|
|
|
|
fForce = ( vStep_x + vStep_y );
|
|
|
|
dDelay = clamp( 0.1, 1 / ( fForce / 90 ), 1 );
|
|
|
|
|
|
|
|
traceline( self.origin + self.view_ofs, self.origin + '0 0 -48', FALSE, self );
|
2017-01-03 01:02:00 +00:00
|
|
|
sound( self, CHAN_BODY, sprintf( "player/pl_step%d.wav", floor( ( random() * 4 ) + 1 ) ), 0.5, ATTN_IDLE );
|
2016-12-02 18:45:59 +00:00
|
|
|
|
|
|
|
self.fSteptime = time + dDelay;
|
|
|
|
}
|
|
|
|
}
|