Footsteps (basic) and viewmodels now bob. Also flashing HUD elements!.
This commit is contained in:
parent
c366e8fc9a
commit
bb4a790f62
6 changed files with 94 additions and 29 deletions
|
@ -33,7 +33,7 @@ void CSQC_UpdateView( float fWinWidth, float fWinHeight, float fGameFocus ) {
|
|||
if( fGameFocus == TRUE ) {
|
||||
HUD_Draw();
|
||||
CSQC_VGUI_Draw();
|
||||
drawstring( '320 240 0 ', sprintf( "FRAMETIME: %f",eViewModel.frame1time ) , '8 8 0', '1 1 1', 1, 0 );
|
||||
drawstring( '320 240 0 ', sprintf( "FRAMETIME: %f", eViewModel.frame1time ) , '8 8 0', '1 1 1', 1, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,23 +39,25 @@ float vHUDNumPos[10] = {
|
|||
|
||||
vector vHUDCalPos[10] = {
|
||||
'0 0 0',
|
||||
'0.09375 0.28125 0', // 50AE
|
||||
'0.28125 0.28125 0', // 762MM
|
||||
'0 0.375 0', // 556MM
|
||||
'0.09375 0.375 0', // 338MAG
|
||||
'0.1875 0.28125 0', // 9MM
|
||||
'0 0.28125 0', // BUCKSHOT
|
||||
'0.375 0.28125 0', // 45ACP
|
||||
'0.46875 0.28125 0', // 357SIG
|
||||
'0.46875 0.375 0', // 57MM
|
||||
'0.09375 0.28125 0', // 50AE
|
||||
'0.28125 0.28125 0', // 762MM
|
||||
'0 0.375 0', // 556MM
|
||||
'0.09375 0.375 0', // 338MAG
|
||||
'0.1875 0.28125 0', // 9MM
|
||||
'0 0.28125 0', // BUCKSHOT
|
||||
'0.375 0.28125 0', // 45ACP
|
||||
'0.46875 0.28125 0', // 357SIG
|
||||
'0.46875 0.375 0', // 57MM
|
||||
};
|
||||
|
||||
// Draws an individual number
|
||||
void HUD_DrawNumber( int iNumber, vector vPos ) {
|
||||
if (iNumber < 0) iNumber = 0;
|
||||
if (iNumber > 9) iNumber = 9;
|
||||
|
||||
drawsubpic( vPos, '24 25 0', HUD_NUMFILE_LAYER, [ vHUDNumPos[ iNumber ], 0], [ NUMSIZE_X, NUMSIZE_Y ], VGUI_WINDOW_FGCOLOR, 1, DRAWFLAG_ADDITIVE );
|
||||
// Wrapper that draws an individual number
|
||||
void HUD_DrawNumber( int iNumber, vector vPos, float fAlpha ) {
|
||||
drawsubpic( vPos, '24 25 0', HUD_NUMFILE_LAYER, [ vHUDNumPos[ iNumber ], 0], [ NUMSIZE_X, NUMSIZE_Y ], VGUI_WINDOW_FGCOLOR, fAlpha, DRAWFLAG_ADDITIVE );
|
||||
}
|
||||
|
||||
// Draws a red number
|
||||
void HUD_DrawRedNumber( int iNumber, vector vPos, float fAlpha ) {
|
||||
drawsubpic( vPos, '24 25 0', HUD_NUMFILE_LAYER, [ vHUDNumPos[ iNumber ], 0], [ NUMSIZE_X, NUMSIZE_Y ], '1 0 0', fAlpha, DRAWFLAG_ADDITIVE );
|
||||
}
|
||||
|
||||
// Draws numerals quickly with a maximum length of 3 - e.g. for health, armor etc.
|
||||
|
@ -63,12 +65,12 @@ void HUD_DrawNums( float fNumber, vector vPos ) {
|
|||
int iNumber = fNumber;
|
||||
if ( iNumber > 0 ) {
|
||||
while ( iNumber > 0 ) {
|
||||
HUD_DrawNumber( (float)iNumber % 10, vPos );
|
||||
HUD_DrawNumber( (float)iNumber % 10, vPos, 1 );
|
||||
iNumber = iNumber / 10;
|
||||
vPos_x -= 24;
|
||||
}
|
||||
} else {
|
||||
HUD_DrawNumber( 0, vPos );
|
||||
HUD_DrawNumber( 0, vPos, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,24 +128,35 @@ void HUD_Draw( void ) {
|
|||
iTens = iSeconds / 10;
|
||||
iUnits = iSeconds - 10*iTens;
|
||||
}
|
||||
|
||||
drawsubpic( vTimePos, '24 25 0', HUD_NUMFILE_LAYER, [ NUMSIZE_X * 6, NUMSIZE_Y * 3], [ NUMSIZE_X, NUMSIZE_Y ], VGUI_WINDOW_FGCOLOR, 1, DRAWFLAG_ADDITIVE );
|
||||
HUD_DrawNumber( iMinutes, vTimePos + '48 0 0');
|
||||
HUD_DrawNumber( iTens, vTimePos + '70 0 0');
|
||||
HUD_DrawNumber( iUnits, vTimePos + '94 0 0' );
|
||||
|
||||
// Timer: Flashing red numbers
|
||||
if ( ( iMinutes == 0 ) && ( iTens <= 1 ) ) {
|
||||
float fAlpha = fabs( sin( time * 20 ) );
|
||||
HUD_DrawRedNumber( iMinutes, vTimePos + '48 0 0', fAlpha);
|
||||
HUD_DrawRedNumber( iTens, vTimePos + '70 0 0', fAlpha);
|
||||
HUD_DrawRedNumber( iUnits, vTimePos + '94 0 0',fAlpha );
|
||||
HUD_DrawNumber( iMinutes, vTimePos + '48 0 0', 1 - fAlpha);
|
||||
HUD_DrawNumber( iTens, vTimePos + '70 0 0', 1 - fAlpha);
|
||||
HUD_DrawNumber( iUnits, vTimePos + '94 0 0',1 - fAlpha );
|
||||
|
||||
drawsubpic( vTimePos, '24 25 0', HUD_NUMFILE_LAYER, [ NUMSIZE_X * 6, NUMSIZE_Y * 3], [ NUMSIZE_X, NUMSIZE_Y ], '1 0 0', fAlpha, DRAWFLAG_ADDITIVE );
|
||||
drawsubpic( vTimePos, '24 25 0', HUD_NUMFILE_LAYER, [ NUMSIZE_X * 6, NUMSIZE_Y * 3], [ NUMSIZE_X, NUMSIZE_Y ], VGUI_WINDOW_FGCOLOR, 1 - fAlpha, DRAWFLAG_ADDITIVE );
|
||||
} else {
|
||||
HUD_DrawNumber( iMinutes, vTimePos + '48 0 0', 1);
|
||||
HUD_DrawNumber( iTens, vTimePos + '70 0 0', 1);
|
||||
HUD_DrawNumber( iUnits, vTimePos + '94 0 0', 1);
|
||||
drawsubpic( vTimePos, '24 25 0', HUD_NUMFILE_LAYER, [ NUMSIZE_X * 6, NUMSIZE_Y * 3], [ NUMSIZE_X, NUMSIZE_Y ], VGUI_WINDOW_FGCOLOR, 1, DRAWFLAG_ADDITIVE );
|
||||
}
|
||||
|
||||
// The money
|
||||
vector vMoneyPos = [ vVideoResolution_x - 160, vVideoResolution_y - 72 ];
|
||||
|
||||
drawsubpic( vMoneyPos, '18 25 0', HUD_NUMFILE_LAYER, [ NUMSIZE_X * 8, NUMSIZE_Y * 1], [ NUMSIZE_X * 0.75, NUMSIZE_Y ], VGUI_WINDOW_FGCOLOR, 1, DRAWFLAG_ADDITIVE );
|
||||
vMoneyPos_x += ( 24 * 5 );
|
||||
|
||||
HUD_DrawNums( getstatf( STAT_MONEY ), vMoneyPos );
|
||||
|
||||
// Ammo
|
||||
vector vAmmoClipPos = [ vVideoResolution_x - 136, vVideoResolution_y - 42 ];
|
||||
HUD_DrawNums( getstatf( STAT_CURRENT_CLIP ), vAmmoClipPos );
|
||||
|
||||
vector vAmmoCalPos = [ vVideoResolution_x - 64, vVideoResolution_y - 42 ];
|
||||
HUD_DrawNums( getstatf( STAT_CURRENT_CALIBER ), vAmmoCalPos );
|
||||
|
||||
|
|
|
@ -49,11 +49,10 @@ entity eViewModel;
|
|||
void View_DrawViewModel( void ) {
|
||||
if( !eViewModel ) {
|
||||
eViewModel = spawn();
|
||||
eViewModel.renderflags = RF_DEPTHHACK;
|
||||
eViewModel.renderflags = RF_DEPTHHACK | RF_VIEWMODEL;
|
||||
}
|
||||
|
||||
eViewModel.origin = getproperty( VF_ORIGIN ) + '0 0 -1';
|
||||
eViewModel.angles = getproperty( VF_ANGLES );
|
||||
eViewModel.origin = '0 0 -1';
|
||||
|
||||
if( getstatf( STAT_ACTIVEWEAPON ) < CS_WEAPON_COUNT ) {
|
||||
setmodel( eViewModel, sViewModels[ getstatf( STAT_ACTIVEWEAPON ) ] );
|
||||
|
|
|
@ -80,6 +80,7 @@ void SV_RunClientCommand( void ) {
|
|||
input_impulse = 0;
|
||||
}
|
||||
|
||||
Footsteps_Update();
|
||||
runstandardplayerphysics( self );
|
||||
}
|
||||
|
||||
|
|
51
Source/Server/Footsteps.c
Normal file
51
Source/Server/Footsteps.c
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
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 );
|
||||
sound( self, CHAN_BODY, sprintf( "player/pl_step%d.wav", ceil( random() * 4) ), 0.5, ATTN_IDLE );
|
||||
|
||||
self.fSteptime = time + dDelay;
|
||||
}
|
||||
}
|
|
@ -43,6 +43,7 @@ FuncBombTarget.c
|
|||
FuncBuyZone.c
|
||||
Spawn.c
|
||||
Entities.c
|
||||
Footsteps.c
|
||||
Input.c
|
||||
Client.c
|
||||
#endlist
|
||||
|
|
Loading…
Reference in a new issue