Physics code update, including switch to TTF for text for easier handling of international languages. Delte your fte.cfg's for all this new stuff to take effect. More testing required also.
This commit is contained in:
parent
5633ad7d59
commit
d78d12fd71
29 changed files with 655 additions and 444 deletions
|
@ -45,6 +45,7 @@ var int autocvar_v_bobclassic = FALSE;
|
|||
var int autocvar_v_lefthanded = FALSE;
|
||||
var int autocvar_cl_thirdperson = FALSE;
|
||||
var int autocvar_cl_radar = 1;
|
||||
var int autocvar_cl_smoothstairs = TRUE;
|
||||
|
||||
var string autocvar_cl_logofile = "lambda";
|
||||
var vector autocvar_cl_logocolor = '255 0 0';
|
||||
|
@ -151,7 +152,6 @@ void View_PlayAnimation( int iSequence );
|
|||
string HUD_GetChatColorHEX( float fTeam );
|
||||
|
||||
// This actually belongs in Builtins.h since its an undocumented global
|
||||
.float weapon;
|
||||
.float maxframe;
|
||||
|
||||
// For the player entity
|
||||
|
|
|
@ -727,8 +727,12 @@ void CSQC_Input_Frame( void ) {
|
|||
}
|
||||
|
||||
if ( iInputDuck == TRUE ) {
|
||||
input_buttons |= INPUT_BUTTON6;
|
||||
input_movevalues_z = -1;
|
||||
}
|
||||
|
||||
if ( input_buttons & INPUT_BUTTON2 ) {
|
||||
input_movevalues_z = 1;
|
||||
}
|
||||
|
||||
input_angles += pSeat->vPunchAngle;
|
||||
}
|
||||
|
|
|
@ -98,8 +98,8 @@ void CSQC_Init(float apilevel, string enginename, float engineversion) {
|
|||
DECAL_GLASS = particleeffectnum( "decal_glass" );
|
||||
PARTICLE_SMOKEGRENADE = particleeffectnum( "smokegren" );
|
||||
|
||||
FONT_16 = loadfont( "16", "gfx/conchars_16", "16", -1 );
|
||||
FONT_CON = loadfont( "font", "", "12", -1 );
|
||||
FONT_16 = loadfont( "16", "fonts/default", "16", -1 );
|
||||
FONT_CON = loadfont( "font", "fonts/default", "12", -1 );
|
||||
|
||||
SHADER_CULLED = shaderforname( "mirror_cull" );
|
||||
|
||||
|
|
|
@ -155,6 +155,9 @@ void Player_Predict(void) {
|
|||
}
|
||||
|
||||
for ( int i = self.pmove_frame; i <= clientcommandframe; i++ ) {
|
||||
if ( input_timelength == 0 ) {
|
||||
break;
|
||||
}
|
||||
getinputstate( i );
|
||||
runplayerphysics();
|
||||
}
|
||||
|
@ -163,32 +166,47 @@ void Player_Predict(void) {
|
|||
self.pmove_flags |= 0x80000;
|
||||
}
|
||||
}
|
||||
pSeat->vPlayerOriginOld = pSeat->vPlayerOrigin;
|
||||
|
||||
if ( autocvar_cl_smoothstairs && self.flags & FL_ONGROUND ) {
|
||||
pSeat->vPlayerOriginOld = pSeat->vPlayerOrigin;
|
||||
|
||||
if ( ( self.flags & FL_ONGROUND ) && ( self.origin_z - pSeat->vPlayerOriginOld.z > 0 ) ) {
|
||||
pSeat->vPlayerOriginOld.z += frametime * 150;
|
||||
if ( ( self.jumptime <= 0 ) && ( self.origin_z - pSeat->vPlayerOriginOld.z > 0 ) ) {
|
||||
pSeat->vPlayerOriginOld.z += frametime * 150;
|
||||
|
||||
if ( pSeat->vPlayerOriginOld.z > self.origin_z ) {
|
||||
if ( pSeat->vPlayerOriginOld.z > self.origin_z ) {
|
||||
pSeat->vPlayerOriginOld.z = self.origin_z;
|
||||
}
|
||||
if ( self.origin_z - pSeat->vPlayerOriginOld.z > 18 ) {
|
||||
pSeat->vPlayerOriginOld.z = self.origin_z - 18;
|
||||
}
|
||||
pSeat->vPlayerOrigin.z += pSeat->vPlayerOriginOld.z - self.origin_z;
|
||||
} else if ( ( self.jumptime <= 0 ) && ( self.origin_z - pSeat->vPlayerOriginOld.z < 0 ) ) {
|
||||
pSeat->vPlayerOriginOld.z -= frametime * 250;
|
||||
|
||||
if ( pSeat->vPlayerOriginOld.z < self.origin_z ) {
|
||||
pSeat->vPlayerOriginOld.z = self.origin_z;
|
||||
}
|
||||
if ( self.origin_z - pSeat->vPlayerOriginOld.z > 18 ) {
|
||||
pSeat->vPlayerOriginOld.z = self.origin_z - 18;
|
||||
}
|
||||
pSeat->vPlayerOrigin.z -= pSeat->vPlayerOriginOld.z - self.origin_z;
|
||||
} else {
|
||||
pSeat->vPlayerOriginOld.z = self.origin_z;
|
||||
}
|
||||
if ( self.origin_z - pSeat->vPlayerOriginOld.z > 18 ) {
|
||||
pSeat->vPlayerOriginOld.z = self.origin_z - 18;
|
||||
|
||||
pSeat->vPlayerVelocity = self.velocity;
|
||||
|
||||
if ( autocvar_cl_thirdperson == TRUE && getstatf( STAT_HEALTH ) > 0 ) {
|
||||
makevectors( view_angles );
|
||||
vector vStart = [ self.origin_x, self.origin_y, pSeat->vPlayerOriginOld.z + 8 ] + ( v_right * 4 );
|
||||
vector vEnd = vStart + ( v_forward * -48 ) + '0 0 8' + ( v_right * 4 );
|
||||
traceline( vStart, vEnd, FALSE, self );
|
||||
pSeat->vPlayerOrigin = trace_endpos + ( v_forward * 5 );
|
||||
} else {
|
||||
pSeat->vPlayerOrigin = [ self.origin_x, self.origin_y, pSeat->vPlayerOriginOld.z ];
|
||||
}
|
||||
pSeat->vPlayerOrigin.z += pSeat->vPlayerOriginOld.z - self.origin_z;
|
||||
} else {
|
||||
pSeat->vPlayerOriginOld.z = self.origin_z;
|
||||
}
|
||||
|
||||
pSeat->vPlayerVelocity = self.velocity;
|
||||
|
||||
if ( autocvar_cl_thirdperson == TRUE && getstatf( STAT_HEALTH ) > 0 ) {
|
||||
makevectors( view_angles );
|
||||
vector vStart = [ self.origin_x, self.origin_y, pSeat->vPlayerOriginOld.z + 8 ] + ( v_right * 4 );
|
||||
vector vEnd = vStart + ( v_forward * -48 ) + '0 0 8' + ( v_right * 4 );
|
||||
traceline( vStart, vEnd, FALSE, self );
|
||||
pSeat->vPlayerOrigin = trace_endpos + ( v_forward * 5 );
|
||||
} else {
|
||||
pSeat->vPlayerOrigin = [ self.origin_x, self.origin_y, pSeat->vPlayerOriginOld.z ];
|
||||
pSeat->vPlayerOrigin = self.origin;
|
||||
}
|
||||
|
||||
self.movetype = MOVETYPE_NONE;
|
||||
|
|
|
@ -117,7 +117,7 @@ void VGUI_Window( string sTitle, vector vPosition, vector vSize ) {
|
|||
drawfill( [vPosition_x + vSize_x - 1, vPosition_y], [1, vSize_y], vVGUIColor, VGUI_WINDOW_FGALPHA );
|
||||
|
||||
// Draw the window title
|
||||
CSQC_DrawText( vPosition + '16 16', sTitle, '12 12', '1 1 1', VGUI_WINDOW_FGALPHA, DRAWFLAG_ADDITIVE, FONT_CON );
|
||||
CSQC_DrawText( vPosition + '16 16', sTitle, '12 12', vVGUIColor, VGUI_WINDOW_FGALPHA, DRAWFLAG_ADDITIVE, FONT_CON );
|
||||
drawfill( vPosition + '0 48', [vSize_x, 1], vVGUIColor, VGUI_WINDOW_FGALPHA );
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ void VGUI_WindowSmall( string sTitle, vector vPosition, vector vSize ) {
|
|||
drawfill( [vPosition_x + vSize_x - 1, vPosition_y], [1, vSize_y], vVGUIColor, VGUI_WINDOW_FGALPHA );
|
||||
|
||||
// Draw the window title
|
||||
CSQC_DrawText( vPosition + '8 8', sTitle, '12 12', '1 1 1', VGUI_WINDOW_FGALPHA, DRAWFLAG_ADDITIVE, FONT_CON );
|
||||
CSQC_DrawText( vPosition + '8 8', sTitle, '12 12', vVGUIColor, VGUI_WINDOW_FGALPHA, DRAWFLAG_ADDITIVE, FONT_CON );
|
||||
drawfill( vPosition + '0 24', [vSize_x, 1], vVGUIColor, VGUI_WINDOW_FGALPHA );
|
||||
}
|
||||
|
||||
|
@ -179,11 +179,11 @@ float VGUI_Button( string sLabel, void() vFunction, vector vPosition, vector vSi
|
|||
fMouseClick = FALSE;
|
||||
}
|
||||
|
||||
CSQC_DrawText( vLabelPos, sLabel, '12 12', '1 1 1', VGUI_WINDOW_FGALPHA, DRAWFLAG_ADDITIVE, FONT_CON );
|
||||
CSQC_DrawText( vLabelPos, sLabel, '12 12', vVGUIColor, VGUI_WINDOW_FGALPHA, DRAWFLAG_ADDITIVE, FONT_CON );
|
||||
drawfill( vLabelPos + '0 10 0', [ stringwidth( sLabel, TRUE, '12 12' ), 1], vVGUIColor, VGUI_WINDOW_FGALPHA );
|
||||
return TRUE;
|
||||
} else {
|
||||
CSQC_DrawText( vLabelPos, sLabel, '12 12', '1 1 1' * 0.8, VGUI_WINDOW_FGALPHA, DRAWFLAG_ADDITIVE, FONT_CON );
|
||||
CSQC_DrawText( vLabelPos, sLabel, '12 12', vVGUIColor * 0.8, VGUI_WINDOW_FGALPHA, DRAWFLAG_ADDITIVE, FONT_CON );
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
@ -208,7 +208,7 @@ void VGUI_FakeButton( string sLabel, vector vPosition, vector vSize ) {
|
|||
vLabelPos_x = vPosition_x + 16;
|
||||
vLabelPos_y = vPosition_y + ( ( vSize_y / 2 ) - 4 );
|
||||
|
||||
CSQC_DrawText( vLabelPos, sLabel, '12 12', '1 1 1' * 0.5, VGUI_WINDOW_FGALPHA, DRAWFLAG_ADDITIVE, FONT_CON );
|
||||
CSQC_DrawText( vLabelPos, sLabel, '12 12', vVGUIColor * 0.5, VGUI_WINDOW_FGALPHA, DRAWFLAG_ADDITIVE, FONT_CON );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -219,7 +219,7 @@ Wrapper for simple GUI text labels
|
|||
====================
|
||||
*/
|
||||
void VGUI_Text( string sText, vector vPos, vector vSize, float fFont ) {
|
||||
CSQC_DrawText( vPos, sText, vSize, '1 1 1', VGUI_WINDOW_FGALPHA, DRAWFLAG_ADDITIVE, fFont );
|
||||
CSQC_DrawText( vPos, sText, vSize, vVGUIColor, VGUI_WINDOW_FGALPHA, DRAWFLAG_ADDITIVE, fFont );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
#includelist
|
||||
../Builtins.h
|
||||
../Globals.h
|
||||
../Shared/Physics.c
|
||||
../Math.h
|
||||
Defs.h
|
||||
|
||||
|
||||
../Shared/WeaponAK47.c
|
||||
../Shared/WeaponAUG.c
|
||||
../Shared/WeaponAWP.c
|
||||
|
|
|
@ -21,11 +21,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#pragma target FTE
|
||||
//#pragma flag enable lo //enable short-circuiting
|
||||
|
||||
#define VEC_HULL_MIN '-16 -16 -36'
|
||||
#define VEC_HULL_MAX '16 16 36'
|
||||
const vector VEC_HULL_MIN = '-16 -16 -36';
|
||||
const vector VEC_HULL_MAX = '16 16 36';
|
||||
|
||||
#define VEC_CHULL_MIN '-16 -16 -18'
|
||||
#define VEC_CHULL_MAX '16 16 18'
|
||||
const vector VEC_CHULL_MIN = '-16 -16 -18';
|
||||
const vector VEC_CHULL_MAX = '16 16 18';
|
||||
|
||||
const vector VEC_PLAYER_VIEWPOS = '0 0 20';
|
||||
const vector VEC_PLAYER_CVIEWPOS = '0 0 12';
|
||||
|
||||
#define PLAYER_SENDFLAG_UPDATE 1
|
||||
#define PLAYER_SENDFLAG_INGAME 2
|
||||
|
@ -310,3 +313,18 @@ enum {
|
|||
|
||||
void Empty( void ) { }
|
||||
void BaseGun_ShotMultiplierHandle( float fShots );
|
||||
float Weapon_GetSpeedM( float fWeapon );
|
||||
.float weapon;
|
||||
|
||||
/*
|
||||
=================
|
||||
Game_GetMaxSpeed
|
||||
=================
|
||||
*/
|
||||
float Game_GetMaxSpeed( float fWeapon ) {
|
||||
if ( self.flags & FL_CROUCHING ) {
|
||||
return ( cvar( "sv_maxspeed" ) * Weapon_GetSpeedM( fWeapon ) * 0.5 );
|
||||
} else {
|
||||
return cvar( "sv_maxspeed" ) * Weapon_GetSpeedM( fWeapon );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ void Damage_Apply( entity eTarget, entity eAttacker, int iDamage, vector vHitPos
|
|||
void runplayerphysics(void)
|
||||
{ //operates on self
|
||||
float fallvel = ( self.flags & FL_ONGROUND )?0:-self.velocity_z;
|
||||
runstandardplayerphysics(self);
|
||||
Physics_Run();
|
||||
if ( ( self.flags & FL_ONGROUND ) && self.movetype == MOVETYPE_WALK && ( fallvel > 100 )) {
|
||||
#ifdef SSQC
|
||||
if ( fallvel > 580 ) {
|
||||
|
|
|
@ -65,8 +65,6 @@ int iMapCount;
|
|||
string *sLogos;
|
||||
var int iLogos;
|
||||
|
||||
var float FONT_MENU;
|
||||
|
||||
#define MENU_COUNT 11
|
||||
enum {
|
||||
MENU_MAIN,
|
||||
|
|
|
@ -42,7 +42,6 @@ void m_init( void ) {
|
|||
}
|
||||
|
||||
search_end( shMaps );
|
||||
FONT_MENU = loadfont( "menu", "gfx/menuchars", "32", -1 );
|
||||
|
||||
vMenuButtonsSize = drawgetimagesize( "gfx/shell/btns_main" );
|
||||
|
||||
|
@ -70,7 +69,7 @@ void m_init( void ) {
|
|||
}
|
||||
search_end( shSprays );
|
||||
|
||||
drawfont = loadfont( "font", "", "12", -1 );
|
||||
drawfont = loadfont( "font", "fonts/default", "12", -1 );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -148,10 +148,10 @@ void Menu_Configuration_Video( void ) {
|
|||
}
|
||||
|
||||
if ( iSelected == i ) {
|
||||
drawfill( [ vPosition_x, vPosition_y - 1 ], [ 156, 10 ], '1 1 1', 0.5, 2 );
|
||||
drawstring( [vPosition_x + 8, vPosition_y], strResolution[ i ], '12 12', '1 1 1', 1.0f, FALSE );
|
||||
drawfill( [ vPosition_x, vPosition_y - 1 ], [ 156, 10 ], autocvar_menu_fgcolor, 0.5, 2 );
|
||||
drawstring( [vPosition_x + 8, vPosition_y], strResolution[ i ], '12 12', autocvar_menu_fgcolor, 1.0f, FALSE );
|
||||
} else {
|
||||
drawstring( [vPosition_x + 8, vPosition_y], strResolution[ i ], '12 12', '1 1 1', fItemAlpha, FALSE );
|
||||
drawstring( [vPosition_x + 8, vPosition_y], strResolution[ i ], '12 12', autocvar_menu_fgcolor, fItemAlpha, FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -386,12 +386,12 @@ void Menu_Configuration_Controls( void ) {
|
|||
}
|
||||
|
||||
if ( iSelected == i ) {
|
||||
drawfill( [ vPosition_x, vPosition_y - 1 ], [ 397, 14 ], '1 1 1', 0.5, 2 );
|
||||
drawstring( [vPosition_x + 8, vPosition_y], sBindTx, '12 12', '1 1 1', 1.0f, FALSE );
|
||||
drawstring( [vPosition_x + 128, vPosition_y], strActDescr[ i ], '12 12', '1 1 1', 1.0f, FALSE );
|
||||
drawfill( [ vPosition_x, vPosition_y - 1 ], [ 397, 14 ], autocvar_menu_fgcolor, 0.5, 2 );
|
||||
drawstring( [vPosition_x + 8, vPosition_y], sBindTx, '12 12', autocvar_menu_fgcolor, 1.0f, FALSE );
|
||||
drawstring( [vPosition_x + 128, vPosition_y], strActDescr[ i ], '12 12', autocvar_menu_fgcolor, 1.0f, FALSE );
|
||||
} else {
|
||||
drawstring( [vPosition_x + 8, vPosition_y], sBindTx, '12 12', '1 1 1', fItemAlpha, FALSE );
|
||||
drawstring( [vPosition_x + 128, vPosition_y], strActDescr[ i ], '12 12', '1 1 1', fItemAlpha, FALSE );
|
||||
drawstring( [vPosition_x + 8, vPosition_y], sBindTx, '12 12', autocvar_menu_fgcolor, fItemAlpha, FALSE );
|
||||
drawstring( [vPosition_x + 128, vPosition_y], strActDescr[ i ], '12 12', autocvar_menu_fgcolor, fItemAlpha, FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,15 +81,15 @@ void Menu_Multiplayer_Find_Item( vector vPosition, int i, __inout int iSelected
|
|||
|
||||
if ( iSelected == i ) {
|
||||
drawfill( [ vPosition_x, vPosition_y - 1 ], [ 397, 14 ], '1 1 1', 0.5, 2 );
|
||||
drawstring( [vPosition_x + 8, vPosition_y], sprintf( "%.25s", gethostcachestring( fldName, i ) ), '12 12', '1 1 1', 1.0f, FALSE );
|
||||
drawstring( [vPosition_x + 186, vPosition_y], sprintf( "%.10s", gethostcachestring( fldMap, i ) ), '12 12', '1 1 1', 1.0f, FALSE );
|
||||
drawstring( [vPosition_x + 298, vPosition_y], sprintf( "%d/%d", gethostcachenumber( fldPlayers, i ), gethostcachenumber( fldMaxplayers, i ) ), '12 12', '1 1 1', 1.0f, FALSE );
|
||||
drawstring( [vPosition_x + 362, vPosition_y], sprintf( "%.3s", ftos( gethostcachenumber( fldPing, i ) ) ), '12 12', '1 1 1', 1.0f, FALSE );
|
||||
drawstring( [vPosition_x + 8, vPosition_y], sprintf( "%.25s", gethostcachestring( fldName, i ) ), '12 12', autocvar_menu_fgcolor, 1.0f, FALSE );
|
||||
drawstring( [vPosition_x + 186, vPosition_y], sprintf( "%.10s", gethostcachestring( fldMap, i ) ), '12 12', autocvar_menu_fgcolor, 1.0f, FALSE );
|
||||
drawstring( [vPosition_x + 298, vPosition_y], sprintf( "%d/%d", gethostcachenumber( fldPlayers, i ), gethostcachenumber( fldMaxplayers, i ) ), '12 12', autocvar_menu_fgcolor, 1.0f, FALSE );
|
||||
drawstring( [vPosition_x + 362, vPosition_y], sprintf( "%.3s", ftos( gethostcachenumber( fldPing, i ) ) ), '12 12', autocvar_menu_fgcolor, 1.0f, FALSE );
|
||||
} else {
|
||||
drawstring( [vPosition_x + 8, vPosition_y], sprintf( "^3%.25s", gethostcachestring( fldName, i ) ), '12 12', '1 1 1', fItemAlpha, FALSE );
|
||||
drawstring( [vPosition_x + 186, vPosition_y], sprintf( "%.10s", gethostcachestring( fldMap, i ) ), '12 12', '1 1 1', fItemAlpha, FALSE );
|
||||
drawstring( [vPosition_x + 298, vPosition_y], sprintf( "%d/%d", gethostcachenumber( fldPlayers, i ), gethostcachenumber( fldMaxplayers, i ) ), '12 12', '1 1 1', fItemAlpha, FALSE );
|
||||
drawstring( [vPosition_x + 362, vPosition_y], sprintf( "%.3s", ftos( gethostcachenumber( fldPing, i ) ) ), '12 12', '1 1 1', fItemAlpha, FALSE );
|
||||
drawstring( [vPosition_x + 8, vPosition_y], sprintf( "^3%.25s", gethostcachestring( fldName, i ) ), '12 12', autocvar_menu_fgcolor, fItemAlpha, FALSE );
|
||||
drawstring( [vPosition_x + 186, vPosition_y], sprintf( "%.10s", gethostcachestring( fldMap, i ) ), '12 12', autocvar_menu_fgcolor, fItemAlpha, FALSE );
|
||||
drawstring( [vPosition_x + 298, vPosition_y], sprintf( "%d/%d", gethostcachenumber( fldPlayers, i ), gethostcachenumber( fldMaxplayers, i ) ), '12 12', autocvar_menu_fgcolor, fItemAlpha, FALSE );
|
||||
drawstring( [vPosition_x + 362, vPosition_y], sprintf( "%.3s", ftos( gethostcachenumber( fldPing, i ) ) ), '12 12', autocvar_menu_fgcolor, fItemAlpha, FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -243,10 +243,10 @@ void Menu_Multiplayer_Create( void ) {
|
|||
}
|
||||
|
||||
if ( iSelectedMap == iIndex ) {
|
||||
drawfill( [ vPosition_x, vPosition_y - 1 ], [ 182, 14 ], '1 1 1', 0.5, 2 );
|
||||
drawstring( vPosition + '8 0', sMapList[ iIndex ], '12 12', '1 1 1', 1.0f, 0 );
|
||||
drawfill( [ vPosition_x, vPosition_y - 1 ], [ 182, 14 ], '1 1 1', 0.25f, 2 );
|
||||
drawstring( vPosition + '8 0', sMapList[ iIndex ], '12 12', autocvar_menu_fgcolor, 1.0f, 0 );
|
||||
} else {
|
||||
drawstring( vPosition + '8 0', sMapList[ iIndex ], '12 12', '0.9 0.9 0.9', fAlpha, 0 );
|
||||
drawstring( vPosition + '8 0', sMapList[ iIndex ], '12 12', autocvar_menu_fgcolor, fAlpha, 0 );
|
||||
}
|
||||
}
|
||||
static void Create_ButtonAdvanced( void ) {
|
||||
|
|
|
@ -160,7 +160,7 @@ void Object_TextButton( vector vPosition, string sButtonText, void() vFunction,
|
|||
}
|
||||
}
|
||||
|
||||
drawstring( vPosition, sButtonText, '12 12', '1 1 1', fAlpha, 1 );
|
||||
drawstring( vPosition, sButtonText, '12 12', autocvar_menu_fgcolor, fAlpha, 1 );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -192,7 +192,7 @@ A label in a cvar driven color scheme
|
|||
*/
|
||||
void Object_Label( vector vPosition, string sLabel, vector vSize ) {
|
||||
vPosition += vMenuOffset;
|
||||
drawstring( vPosition, sLabel, vSize, '1 1 1', 1.0f, 0 );
|
||||
drawstring( vPosition, sLabel, vSize, autocvar_menu_fgcolor, 1.0f, 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -308,9 +308,9 @@ void Object_CvarToggle( vector vPosition, string sLabel, string sCvar ) {
|
|||
drawfill( vPosition + '-2 -2', [ iWidth + 36, 16 ], '0 0 0', 0.8f );
|
||||
|
||||
if ( cvar( sCvar ) == 0 ) {
|
||||
drawstring( vPosition, sprintf( "[ ] %s", sLabel ), '12 12', '1 1 1', fAlpha, 0 );
|
||||
drawstring( vPosition, sprintf( "[ ] %s", sLabel ), '12 12', autocvar_menu_fgcolor, fAlpha, 0 );
|
||||
} else {
|
||||
drawstring( vPosition, sprintf( "[X] %s", sLabel ), '12 12', '1 1 1', fAlpha, 0 );
|
||||
drawstring( vPosition, sprintf( "[X] %s", sLabel ), '12 12', autocvar_menu_fgcolor, fAlpha, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -337,9 +337,9 @@ void Object_FuncToggle( vector vPosition, string sLabel, void( void ) vFunc, int
|
|||
drawfill( vPosition + '-2 -2', [ iWidth + 36, 16 ], '0 0 0', 0.8f );
|
||||
|
||||
if ( iValue == 0 ) {
|
||||
drawstring( vPosition, sprintf( "[ ] %s", sLabel ), '12 12', '1 1 1', fAlpha, 0 );
|
||||
drawstring( vPosition, sprintf( "[ ] %s", sLabel ), '12 12', autocvar_menu_fgcolor, fAlpha, 0 );
|
||||
} else {
|
||||
drawstring( vPosition, sprintf( "[X] %s", sLabel ), '12 12', '1 1 1', fAlpha, 0 );
|
||||
drawstring( vPosition, sprintf( "[X] %s", sLabel ), '12 12', autocvar_menu_fgcolor, fAlpha, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -374,8 +374,8 @@ void Object_Textfield( vector vPosition, __inout string strValue, int iMaxChars
|
|||
}
|
||||
}
|
||||
fFieldAlpha = 1.0f;
|
||||
drawstring( vPosition, sprintf( "%s_", strValue ), '12 12', '1 1 1', fFieldAlpha, FALSE );
|
||||
drawstring( vPosition, sprintf( "%s_", strValue ), '12 12', autocvar_menu_fgcolor, fFieldAlpha, FALSE );
|
||||
} else {
|
||||
drawstring( vPosition, strValue, '12 12', '1 1 1', fFieldAlpha, FALSE );
|
||||
drawstring( vPosition, strValue, '12 12', autocvar_menu_fgcolor, fFieldAlpha, FALSE );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,7 +79,6 @@ enum {
|
|||
.float fStepTime;
|
||||
.int iInGame;
|
||||
.float fCharModel;
|
||||
.int iCrouchAttempt;
|
||||
//.int iHasBomb;
|
||||
.float fDeaths;
|
||||
.int iEquipment;
|
||||
|
@ -162,9 +161,6 @@ float BaseGun_Reload( void );
|
|||
|
||||
void BaseMelee_Draw( void );
|
||||
int BaseMelee_Attack( void );
|
||||
|
||||
float Player_GetMaxSpeed( float fWeapon );
|
||||
|
||||
void Effect_Impact( int iType, vector vPos, vector vNormal );
|
||||
void Effect_CreateSmoke( vector vPos );
|
||||
void Effect_CreateExplosion( vector vPos );
|
||||
|
|
|
@ -55,12 +55,6 @@ void Input_Handle( void ) {
|
|||
Player_UseUp();
|
||||
}
|
||||
|
||||
if ( self.button6 ) {
|
||||
Player_CrouchDown();
|
||||
} else if ( self.flags & FL_CROUCHING ) {
|
||||
Player_CrouchUp();
|
||||
}
|
||||
|
||||
if ( self.button0 ) {
|
||||
if ( fGameState != GAME_FREEZE ) {
|
||||
Weapon_PrimaryAttack( self.weapon );
|
||||
|
|
|
@ -1,277 +0,0 @@
|
|||
/*
|
||||
OpenCS Project
|
||||
Copyright (C) 2016, 2017 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.
|
||||
*/
|
||||
|
||||
#define movevars_stepheight 22
|
||||
#define movevars_friction 4
|
||||
#define movevars_gravity 800
|
||||
#define movevars_accelerate 10
|
||||
#define movevars_stopspeed 100
|
||||
#define movevars_maxspeed 320
|
||||
#define movevars_jumpheight 270
|
||||
|
||||
.float pmove_flags;
|
||||
.float gravity;
|
||||
|
||||
enumflags {
|
||||
PMF_JUMP_HELD,
|
||||
PMF_RESERVED,
|
||||
PMF_ONGROUND
|
||||
};
|
||||
|
||||
static void dotouch( entity tother ) {
|
||||
entity oself;
|
||||
if (tother.touch == __NULL__)
|
||||
return;
|
||||
|
||||
oself = self;
|
||||
other = self;
|
||||
self = tother;
|
||||
self.touch();
|
||||
self = oself;
|
||||
}
|
||||
|
||||
void PhysicsMove_Rebound(vector surfnorm) {
|
||||
float v;
|
||||
v = self.velocity*surfnorm;
|
||||
self.velocity = self.velocity - surfnorm*(v);
|
||||
}
|
||||
|
||||
//move forwards (preferably on the level) (does step ups)
|
||||
void PhysicsMove_Move(void) {
|
||||
vector dest;
|
||||
vector saved_plane_normal;
|
||||
float stepped;
|
||||
float movetime;
|
||||
float attempts;
|
||||
|
||||
//we need to bounce off surfaces (in order to slide along them), so we need at 2 attempts
|
||||
for (attempts = 3, movetime = input_timelength; movetime>0 && attempts; attempts--)
|
||||
{
|
||||
dest = self.origin + self.velocity*movetime;
|
||||
tracebox(self.origin, self.mins, self.maxs, dest, FALSE, self); //try going straight there
|
||||
self.origin = trace_endpos;
|
||||
|
||||
if (trace_fraction < 1)
|
||||
{
|
||||
saved_plane_normal = trace_plane_normal;
|
||||
|
||||
movetime -= movetime * trace_fraction;
|
||||
|
||||
if (movetime)
|
||||
{
|
||||
//step up if we can
|
||||
trace_endpos = self.origin;
|
||||
trace_endpos_z += movevars_stepheight;
|
||||
tracebox( self.origin, self.mins, self.maxs, trace_endpos, FALSE, self );
|
||||
stepped = trace_endpos_z - self.origin_z;
|
||||
|
||||
dest = trace_endpos + self.velocity*movetime;
|
||||
dest_z = trace_endpos_z;
|
||||
//move forwards
|
||||
tracebox(trace_endpos, self.mins, self.maxs, dest, FALSE, self);
|
||||
|
||||
//if we got anywhere, make this raised-step move count
|
||||
if (trace_fraction != 0)
|
||||
{
|
||||
if (trace_fraction < 1)
|
||||
PhysicsMove_Rebound(trace_plane_normal);
|
||||
|
||||
//move down
|
||||
dest = trace_endpos;
|
||||
dest_z -= stepped+1;
|
||||
tracebox(trace_endpos, self.mins, self.maxs, dest, FALSE, self);
|
||||
if (trace_fraction < 1)
|
||||
PhysicsMove_Rebound(trace_plane_normal);
|
||||
|
||||
self.origin = trace_endpos;
|
||||
|
||||
movetime -= movetime * input_timelength;
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//stepping failed, just bounce off
|
||||
PhysicsMove_Rebound(saved_plane_normal);
|
||||
|
||||
dotouch(trace_ent);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*
|
||||
void(vector dest) PhysicsMove_StepMove =
|
||||
{
|
||||
//we hit something...
|
||||
|
||||
//step up
|
||||
src = trace_endpos;
|
||||
trace_endpos_z += movevars_stepheight;
|
||||
tracebox(src, self.mins, self.maxs, dest, FALSE, self);
|
||||
stepped = trace_endpos_z - src_z;
|
||||
dest_z += stepped;
|
||||
|
||||
//move forwards
|
||||
tracebox(trace_endpos, self.mins, self.maxs, dest, FALSE, self);
|
||||
|
||||
//move down
|
||||
dest_z -= stepped;
|
||||
tracebox(trace_endpos, self.mins, self.maxs, dest, FALSE, self);
|
||||
}
|
||||
*/
|
||||
void PhysicsMove_ApplyFriction( void ) {
|
||||
float newspeed, oldspeed;
|
||||
oldspeed = vlen(self.velocity);
|
||||
if (oldspeed < 1)
|
||||
{
|
||||
self.velocity = '0 0 0';
|
||||
return;
|
||||
}
|
||||
|
||||
//calculate what their new speed should be
|
||||
newspeed = oldspeed - oldspeed*movevars_friction*input_timelength;
|
||||
|
||||
//and slow them
|
||||
if (newspeed < 0)
|
||||
newspeed = 0;
|
||||
self.velocity = self.velocity * (newspeed/oldspeed);
|
||||
}
|
||||
|
||||
void PhysicsMove_Accelerate(vector wishdir, float wishspeed, float accel) {
|
||||
float addspeed, accelspeed;
|
||||
float d;
|
||||
d = self.velocity*wishdir;
|
||||
addspeed = wishspeed - (d);
|
||||
if (addspeed <= 0)
|
||||
return;
|
||||
accelspeed = accel*input_timelength*wishspeed;
|
||||
if (accelspeed > addspeed)
|
||||
accelspeed = addspeed;
|
||||
|
||||
self.velocity = self.velocity + accelspeed*wishdir;
|
||||
}
|
||||
|
||||
void PhysicsMove_InAirAccelerate( void ) {
|
||||
vector hforward;
|
||||
vector hright;
|
||||
vector desireddir;
|
||||
float desiredspeed;
|
||||
|
||||
hforward = v_forward;
|
||||
hforward_z = 0;
|
||||
hforward = normalize(hforward);
|
||||
hright = v_right;
|
||||
hright_z = 0;
|
||||
hright = normalize(hright);
|
||||
|
||||
desireddir = hforward*input_movevalues_x + hright*input_movevalues_y;
|
||||
desiredspeed = vlen(desireddir);
|
||||
desireddir = normalize(desireddir);
|
||||
|
||||
if (desiredspeed > movevars_maxspeed)
|
||||
desiredspeed = movevars_maxspeed;
|
||||
|
||||
if (self.pmove_flags & PMF_ONGROUND)
|
||||
{
|
||||
if (input_buttons & 2)
|
||||
{
|
||||
if (!(self.pmove_flags & PMF_JUMP_HELD))
|
||||
{
|
||||
self.velocity_z += movevars_jumpheight;
|
||||
self.pmove_flags (+) PMF_ONGROUND;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (self.pmove_flags & PMF_ONGROUND)
|
||||
{
|
||||
PhysicsMove_ApplyFriction();
|
||||
PhysicsMove_Accelerate(desireddir, desiredspeed, movevars_accelerate);
|
||||
}
|
||||
else
|
||||
{
|
||||
//there's no friction in air...
|
||||
if (desiredspeed > 30)
|
||||
desiredspeed = 30;
|
||||
PhysicsMove_Accelerate(desireddir, desiredspeed, movevars_accelerate);
|
||||
|
||||
if (self.gravity)
|
||||
self.velocity_z -= self.gravity * movevars_gravity * input_timelength;
|
||||
else
|
||||
self.velocity_z -= movevars_gravity * input_timelength;
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsMove_NoclipAccelerate( void ) {
|
||||
vector desireddir;
|
||||
float desiredspeed;
|
||||
|
||||
desireddir = v_forward*input_movevalues_x + v_right*input_movevalues_y+v_up*input_movevalues_z;
|
||||
desiredspeed = vlen(desireddir);
|
||||
desireddir = normalize(desireddir);
|
||||
|
||||
PhysicsMove_ApplyFriction();
|
||||
PhysicsMove_Accelerate(desireddir, desiredspeed, movevars_accelerate);
|
||||
}
|
||||
|
||||
void PhysicsMove_Categorise( void ) {
|
||||
//if we're moving up, we're not on the ground
|
||||
if (self.velocity_z > 0)
|
||||
self.pmove_flags (-) PMF_ONGROUND;
|
||||
else
|
||||
{
|
||||
//don't know, maybe we are, maybe we're not
|
||||
tracebox(self.origin, self.mins, self.maxs, self.origin-'0 0 1', FALSE, self);
|
||||
if (trace_fraction == 1 || trace_plane_normal_z < 0.7) {
|
||||
self.pmove_flags (-) PMF_ONGROUND;
|
||||
// self.groundentity = trace_ent;
|
||||
}
|
||||
else
|
||||
self.pmove_flags (+) PMF_ONGROUND;
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsMove( entity eEnt ) {
|
||||
self = eEnt;
|
||||
makevectors(input_angles);
|
||||
|
||||
if (!(input_buttons & PMF_JUMP_HELD))
|
||||
self.pmove_flags (-) PMF_JUMP_HELD;
|
||||
|
||||
PhysicsMove_Categorise();
|
||||
|
||||
switch ( self.movetype ) {
|
||||
case MOVETYPE_WALK:
|
||||
PhysicsMove_InAirAccelerate();
|
||||
PhysicsMove_Move();
|
||||
break;
|
||||
case MOVETYPE_FLY:
|
||||
PhysicsMove_NoclipAccelerate();
|
||||
PhysicsMove_Move();
|
||||
break;
|
||||
case MOVETYPE_NOCLIP:
|
||||
PhysicsMove_NoclipAccelerate();
|
||||
self.origin += self.velocity*input_timelength;
|
||||
break;
|
||||
case MOVETYPE_NONE:
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -127,12 +127,7 @@ void Player_Death( int iHitBody ) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( self.flags & FL_CROUCHING ) {
|
||||
self.flags -= FL_CROUCHING;
|
||||
self.maxspeed = Player_GetMaxSpeed( 0 );
|
||||
}
|
||||
|
||||
|
||||
Spawn_MakeSpectator();
|
||||
self.classname = "player";
|
||||
self.health = 0;
|
||||
|
@ -167,84 +162,6 @@ void Player_Death( int iHitBody ) {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Player_GetMaxSpeed
|
||||
=================
|
||||
*/
|
||||
float Player_GetMaxSpeed( float fWeapon ) {
|
||||
if ( self.flags & FL_CROUCHING ) {
|
||||
return ( cvar( "sv_maxspeed" ) * wptTable[ fWeapon ].fSpeedM ) * 0.5;
|
||||
} else {
|
||||
return cvar( "sv_maxspeed" ) * wptTable[ fWeapon ].fSpeedM;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Player_CrouchCheck
|
||||
=================
|
||||
*/
|
||||
float Player_CrouchCheck( entity targ ) {
|
||||
vector vTrace = self.origin + '0 0 18';
|
||||
|
||||
tracebox( vTrace, VEC_HULL_MIN, VEC_HULL_MAX, vTrace, FALSE, self );
|
||||
|
||||
if ( trace_startsolid == FALSE ) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Player_CrouchDown
|
||||
=================
|
||||
*/
|
||||
void Player_CrouchDown( void ) {
|
||||
if ( self.movetype != MOVETYPE_WALK ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !( self.flags & FL_CROUCHING ) ) {
|
||||
setsize( self, VEC_CHULL_MIN, VEC_CHULL_MAX );
|
||||
setorigin( self, self.origin - '0 0 18' );
|
||||
self.velocity_z = self.velocity_z + 50;
|
||||
self.flags = self.flags | FL_CROUCHING;
|
||||
self.view_ofs = VEC_PLAYER_CVIEWPOS;
|
||||
self.maxspeed = Player_GetMaxSpeed( self.weapon );
|
||||
self.iCrouchAttempt = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
self.iCrouchAttempt = FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Player_CrouchUp
|
||||
=================
|
||||
*/
|
||||
void Player_CrouchUp( void ) {
|
||||
if ( self.movetype != MOVETYPE_WALK ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ( self.flags & FL_CROUCHING ) && ( Player_CrouchCheck( self ) ) ) {
|
||||
setsize( self, VEC_HULL_MIN, VEC_HULL_MAX );
|
||||
setorigin( self, self.origin + '0 0 18' );
|
||||
//self.velocity_z = self.velocity_z + 50;
|
||||
self.view_ofs = VEC_PLAYER_VIEWPOS;
|
||||
self.flags = ( self.flags - FL_CROUCHING );
|
||||
self.iCrouchAttempt = FALSE;
|
||||
self.maxspeed = Player_GetMaxSpeed( self.weapon );
|
||||
return;
|
||||
}
|
||||
|
||||
self.iCrouchAttempt = TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
Player_UseDown
|
||||
|
|
|
@ -154,7 +154,6 @@ void Spawn_RespawnClient( float fTeam ) {
|
|||
|
||||
self.view_ofs = VEC_PLAYER_VIEWPOS;
|
||||
self.velocity = '0 0 0';
|
||||
self.maxspeed = Player_GetMaxSpeed( self.weapon );
|
||||
|
||||
self.frame = 1; // Idle frame
|
||||
self.fBombProgress = 0;
|
||||
|
|
|
@ -5,13 +5,12 @@
|
|||
#includelist
|
||||
../Builtins.h
|
||||
../Globals.h
|
||||
../Shared/Physics.c
|
||||
../Math.h
|
||||
Defs.h
|
||||
|
||||
Money.c
|
||||
../Shared/Animations.c
|
||||
|
||||
PhysicsMove.c
|
||||
../Shared/Radio.c
|
||||
../Shared/WeaponAK47.c
|
||||
../Shared/WeaponAUG.c
|
||||
|
|
535
Source/Shared/Physics.c
Executable file
535
Source/Shared/Physics.c
Executable file
|
@ -0,0 +1,535 @@
|
|||
/*
|
||||
FreeCS Project
|
||||
Copyright (C) 2016, 2017, 2018 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 input_timelength;
|
||||
vector input_angles;
|
||||
vector input_movevalues;
|
||||
float input_buttons;
|
||||
|
||||
#define PHYSICS_STEPHEIGHT 18
|
||||
#define PHYSICS_AIRSTEPHEIGHT 18
|
||||
#define PHYSICS_FRICTION 4
|
||||
#define PHYSICS_EDGEFRICTION 2
|
||||
#define PHYSICS_GRAVITY 800
|
||||
#define PHYSICS_ACCELERATE 4
|
||||
#define PHYSICS_STOPSPEED 100
|
||||
|
||||
#define PHYSICS_JUMP_CHAINWINDOW 0.5
|
||||
// maximum possible height from double/chain jump
|
||||
#define PHYSICS_JUMP_CHAIN 100
|
||||
// decay over lifetime of window
|
||||
#define PHYSICS_JUMP_CHAINDECAY 50
|
||||
|
||||
/*FIXME: jumptime should use the time global, as time intervals are not predictable - decrement it based upon input_timelength*/
|
||||
.float jumptime;
|
||||
.float waterlevel;
|
||||
.float watertype;
|
||||
.float teleport_time;
|
||||
.float maxspeed;
|
||||
.vector view_ofs;
|
||||
|
||||
/*
|
||||
=================
|
||||
Physics_Categorize
|
||||
|
||||
Figures out where we are in the game world.
|
||||
Whether we are in water, on the ground etc.
|
||||
=================
|
||||
*/
|
||||
void Physics_Categorize( void ) {
|
||||
int iContents;
|
||||
|
||||
tracebox( self.origin, self.mins, self.maxs, self.origin - '0 0 0.25', FALSE, self );
|
||||
|
||||
if ( !trace_startsolid ) {
|
||||
if ( ( trace_fraction < 1 ) && ( trace_plane_normal_z > 0.7 ) ) {
|
||||
self.flags |= FL_ONGROUND;
|
||||
} else {
|
||||
if ( self.flags & FL_ONGROUND ) {
|
||||
self.flags -= FL_ONGROUND;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
iContents = pointcontents( self.origin + self.mins + '0 0 1' );
|
||||
|
||||
if ( iContents < CONTENT_SOLID && iContents != CONTENT_LADDER ) {
|
||||
self.watertype = iContents;
|
||||
if ( pointcontents( self.origin + ( self.mins + self.maxs ) * 0.5 ) < CONTENT_SOLID && iContents != CONTENT_LADDER ) {
|
||||
if ( pointcontents( self.origin + self.maxs - '0 0 1' ) < CONTENT_SOLID && iContents != CONTENT_LADDER ) {
|
||||
self.waterlevel = 3;
|
||||
} else {
|
||||
self.waterlevel = 2;
|
||||
}
|
||||
} else {
|
||||
self.waterlevel = 1;
|
||||
}
|
||||
} else {
|
||||
self.watertype = CONTENT_EMPTY;
|
||||
self.waterlevel = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Physics_GetMaxSpeed
|
||||
|
||||
Gets the maximum speed of the player
|
||||
=================
|
||||
*/
|
||||
float Physics_GetMaxSpeed( void ) {
|
||||
float flMaxSpeed = 240;
|
||||
flMaxSpeed *= Weapon_GetSpeedM( self.weapon );
|
||||
|
||||
if ( self.flags & FL_CROUCHING ) {
|
||||
return ( flMaxSpeed * 0.5 );
|
||||
} else {
|
||||
return flMaxSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Physics_Run_Acceleration
|
||||
|
||||
This function applies the velocity changes the player wishes to apply
|
||||
=================
|
||||
*/
|
||||
void Physics_Run_Acceleration( float flMovetime, float flBefore ) {
|
||||
vector vWishVelocity;
|
||||
vector vWishDirection;
|
||||
vector vTemp;
|
||||
float flWishSpeed;
|
||||
float f;
|
||||
float flJumptimeDelta;
|
||||
float flChainBonus;
|
||||
|
||||
Physics_Categorize();
|
||||
|
||||
// Update the timer
|
||||
self.jumptime -= flMovetime;
|
||||
self.teleport_time -= flMovetime;
|
||||
|
||||
// Corpses
|
||||
if ( self.movetype == MOVETYPE_TOSS ) {
|
||||
self.velocity_z = self.velocity_z - ( PHYSICS_GRAVITY * flMovetime );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( self.movetype == MOVETYPE_WALK ) {
|
||||
// Crouching
|
||||
if ( input_movevalues_z < 0 ) {
|
||||
if ( !( self.flags & FL_CROUCHING ) ) {
|
||||
setorigin( self, self.origin - '0 0 18' );
|
||||
self.flags |= FL_CROUCHING;
|
||||
}
|
||||
} else {
|
||||
if ( self.flags & FL_CROUCHING || ( self.flags & FL_CROUCHING ) ) {
|
||||
tracebox( self.origin + '0 0 18', VEC_HULL_MIN, VEC_HULL_MAX, self.origin + '0 0 18', FALSE, self );
|
||||
if ( trace_startsolid == FALSE ) {
|
||||
setorigin( self, self.origin + '0 0 18' );
|
||||
self.flags -= FL_CROUCHING;
|
||||
|
||||
if ( self.velocity_z <= 0 ) {
|
||||
self.velocity_z = self.velocity_z + 25;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Adjust the bounds and the viewheight, as well as speed
|
||||
if ( self.flags & FL_CROUCHING ) {
|
||||
self.mins = VEC_CHULL_MIN;
|
||||
self.maxs = VEC_CHULL_MAX;
|
||||
self.view_ofs = VEC_PLAYER_CVIEWPOS;
|
||||
} else {
|
||||
self.mins = VEC_HULL_MIN;
|
||||
self.maxs = VEC_HULL_MAX;
|
||||
self.view_ofs = VEC_PLAYER_VIEWPOS;
|
||||
}
|
||||
self.maxspeed = Game_GetMaxSpeed( self.weapon );
|
||||
|
||||
makevectors( input_angles );
|
||||
// swim
|
||||
if ( self.waterlevel >= 2 ) {
|
||||
if ( self.movetype != MOVETYPE_NOCLIP ) {
|
||||
if ( self.flags & FL_ONGROUND ) {
|
||||
self.flags -= FL_ONGROUND;
|
||||
}
|
||||
|
||||
if ( input_movevalues == '0 0 0' ) {
|
||||
vWishVelocity = '0 0 -60'; // drift towards bottom
|
||||
} else {
|
||||
vWishVelocity = v_forward * input_movevalues_x + v_right * vTemp_y + '0 0 1' * input_movevalues_z;
|
||||
}
|
||||
|
||||
flWishSpeed = vlen( vWishVelocity );
|
||||
|
||||
if ( flWishSpeed > self.maxspeed ) {
|
||||
flWishSpeed = self.maxspeed;
|
||||
}
|
||||
|
||||
flWishSpeed = flWishSpeed * 0.7;
|
||||
|
||||
// water friction
|
||||
if ( self.velocity != '0 0 0' ) {
|
||||
f = vlen( self.velocity ) * ( 1 - flMovetime * PHYSICS_FRICTION );
|
||||
if ( f > 0 ) {
|
||||
self.velocity = normalize( self.velocity ) * f;
|
||||
} else {
|
||||
self.velocity = '0 0 0';
|
||||
}
|
||||
} else {
|
||||
f = 0;
|
||||
}
|
||||
|
||||
// water acceleration
|
||||
if ( flWishSpeed <= f ) {
|
||||
return;
|
||||
}
|
||||
|
||||
f = min( flWishSpeed - f, PHYSICS_ACCELERATE * flWishSpeed * flMovetime );
|
||||
self.velocity = self.velocity + normalize( vWishVelocity ) * f;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// hack to not let you back into teleporter
|
||||
if ( self.teleport_time > 0 && input_movevalues_x < 0 ) {
|
||||
vWishVelocity = v_right * input_movevalues_y;
|
||||
} else {
|
||||
if ( self.movetype == MOVETYPE_NOCLIP ) {
|
||||
} else if ( self.flags & FL_ONGROUND ) {
|
||||
makevectors (input_angles_y * '0 1 0');
|
||||
}
|
||||
|
||||
vWishVelocity = v_forward * input_movevalues_x + v_right * input_movevalues_y;
|
||||
}
|
||||
|
||||
if ( self.movetype != MOVETYPE_WALK ) {
|
||||
vWishVelocity_z += input_movevalues_z;
|
||||
} else {
|
||||
vWishVelocity_z = 0;
|
||||
}
|
||||
|
||||
vWishDirection = normalize( vWishVelocity );
|
||||
flWishSpeed = vlen( vWishVelocity );
|
||||
|
||||
if ( flWishSpeed > self.maxspeed ) {
|
||||
flWishSpeed = self.maxspeed;
|
||||
}
|
||||
|
||||
if (self.movetype == MOVETYPE_NOCLIP) {
|
||||
if ( self.flags & FL_ONGROUND ) {
|
||||
self.flags -= FL_ONGROUND;
|
||||
}
|
||||
self.velocity = vWishDirection * flWishSpeed;
|
||||
} else {
|
||||
/*FIXME: pogostick*/
|
||||
if ( self.flags & FL_ONGROUND )
|
||||
if ( !( self.flags & FL_WATERJUMP ) )
|
||||
if ( self.flags & FL_JUMPRELEASED )
|
||||
if ( input_movevalues_z > 0 && flBefore ) {
|
||||
if (self.velocity_z < 0) {
|
||||
self.velocity_z = 0;
|
||||
}
|
||||
|
||||
if ( self.waterlevel >= 2 ) {
|
||||
if ( self.watertype == CONTENT_WATER ) {
|
||||
self.velocity_z = 100;
|
||||
} else if ( self.watertype == CONTENT_SLIME ) {
|
||||
self.velocity_z = 80;
|
||||
} else {
|
||||
self.velocity_z = 50;
|
||||
}
|
||||
} else {
|
||||
self.velocity_z += 240;
|
||||
}
|
||||
|
||||
if ( self.jumptime > 0 ) {
|
||||
// time since last jump
|
||||
flJumptimeDelta = 0 - ( self.jumptime - PHYSICS_JUMP_CHAINWINDOW );
|
||||
//self.velocity_z += PHYSICS_JUMP_CHAIN;
|
||||
flChainBonus = PHYSICS_JUMP_CHAIN - ( ( ( PHYSICS_JUMP_CHAINWINDOW - ( PHYSICS_JUMP_CHAINWINDOW - flJumptimeDelta ) ) * 2) * PHYSICS_JUMP_CHAINDECAY );
|
||||
self.velocity_z += flChainBonus;
|
||||
}
|
||||
self.jumptime = PHYSICS_JUMP_CHAINWINDOW;
|
||||
self.flags -= FL_ONGROUND;
|
||||
self.flags -= FL_JUMPRELEASED;
|
||||
}
|
||||
// not pressing jump, set released flag
|
||||
if ( !( input_movevalues_z > 0 ) ) {
|
||||
self.flags |= FL_JUMPRELEASED;
|
||||
}
|
||||
|
||||
if ( self.flags & FL_ONGROUND ) {
|
||||
// friction
|
||||
if ( self.velocity_x || self.velocity_y ) {
|
||||
vTemp = self.velocity;
|
||||
vTemp_z = 0;
|
||||
f = vlen( vTemp );
|
||||
|
||||
// if the leading edge is over a dropoff, increase friction
|
||||
vTemp = self.origin + normalize( vTemp ) * 16 + '0 0 1' * VEC_HULL_MIN_z;
|
||||
|
||||
traceline( vTemp, vTemp + '0 0 -34', TRUE, self );
|
||||
|
||||
// apply friction
|
||||
if ( trace_fraction == 1.0 ) {
|
||||
if (f < PHYSICS_STOPSPEED)
|
||||
f = 1 - flMovetime * ( PHYSICS_STOPSPEED / f ) * PHYSICS_FRICTION * PHYSICS_EDGEFRICTION;
|
||||
else
|
||||
f = 1 - flMovetime * PHYSICS_FRICTION * PHYSICS_EDGEFRICTION;
|
||||
} else {
|
||||
if (f < PHYSICS_STOPSPEED)
|
||||
f = 1 - flMovetime * ( PHYSICS_STOPSPEED / f ) * PHYSICS_FRICTION;
|
||||
else
|
||||
f = 1 - flMovetime * PHYSICS_FRICTION;
|
||||
}
|
||||
|
||||
if ( f < 0 ) {
|
||||
self.velocity = '0 0 0';
|
||||
} else {
|
||||
self.velocity = self.velocity * f;
|
||||
}
|
||||
}
|
||||
|
||||
// acceleration
|
||||
f = flWishSpeed - ( self.velocity * vWishDirection );
|
||||
if ( f > 0 ) {
|
||||
self.velocity = self.velocity + vWishDirection * min( f, PHYSICS_ACCELERATE * flMovetime * flWishSpeed );
|
||||
}
|
||||
|
||||
} else {
|
||||
/*apply gravity*/
|
||||
self.velocity_z = self.velocity_z - ( PHYSICS_GRAVITY * flMovetime );
|
||||
|
||||
if ( flWishSpeed < 30 ) {
|
||||
f = flWishSpeed - ( self.velocity * vWishDirection );
|
||||
} else {
|
||||
f = 30 - ( self.velocity * vWishDirection );
|
||||
}
|
||||
|
||||
if ( f > 0 ) {
|
||||
self.velocity = self.velocity + vWishDirection * ( min( f, PHYSICS_ACCELERATE ) * flWishSpeed * flMovetime );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Physics_Rebound
|
||||
|
||||
Calls somethings touch() function upon hit.
|
||||
=================
|
||||
*/
|
||||
void Physics_DoTouch( entity tother ) {
|
||||
entity oself = self;
|
||||
|
||||
if ( tother.touch ) {
|
||||
other = self;
|
||||
self = tother;
|
||||
self.touch();
|
||||
}
|
||||
|
||||
self = oself;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Physics_Rebound
|
||||
|
||||
This function 'bounces' off any surfaces that were hit
|
||||
=================
|
||||
*/
|
||||
static void Physics_Rebound( vector vNormal ) {
|
||||
float v;
|
||||
v = self.velocity * vNormal;
|
||||
self.velocity = self.velocity - vNormal * v;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Physics_Fix_Origin
|
||||
|
||||
Incase BSP precision messes up, this function will attempt
|
||||
to correct the origin to stop it from being invalid.
|
||||
=================
|
||||
*/
|
||||
float Physics_Fix_Origin( void ) {
|
||||
float x, y, z;
|
||||
vector norg, oorg = self.origin;
|
||||
|
||||
for ( z = 0; z < 3; z++ ) {
|
||||
norg_z = oorg_z + ((z==2)?-1:z)*0.0125;
|
||||
for ( x = 0; x < 3; x++ ) {
|
||||
norg_x = oorg_x + ((x==2)?-1:x)*0.0125;
|
||||
for ( y = 0; y < 3; y++ ) {
|
||||
norg_y = oorg_y + ((y==2)?-1:y)*0.0125;
|
||||
|
||||
tracebox( norg, self.mins, self.maxs, norg, FALSE, self );
|
||||
if ( !trace_startsolid ) {
|
||||
//dprint( "[PHYSICS] Unstuck\n" );
|
||||
self.origin = norg;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//dprint( "[PHYSICS] Stuck\n" );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Physics_Run_Move
|
||||
|
||||
This function is responsible for moving the entity
|
||||
forwards according to the various inputs/state.
|
||||
=================
|
||||
*/
|
||||
void Physics_Run_Move( void ) {
|
||||
vector destp;
|
||||
vector saved_plane_normal;
|
||||
float flStepped;
|
||||
float flMoveTime;
|
||||
int iAttempts;
|
||||
|
||||
if ( self.movetype == MOVETYPE_NOCLIP ) {
|
||||
self.origin = self.origin + self.velocity * input_timelength;
|
||||
return;
|
||||
}
|
||||
|
||||
//we need to bounce off surfaces (in order to slide along them), so we need at 2 attempts
|
||||
for ( iAttempts = 3, flMoveTime = input_timelength; flMoveTime > 0 && iAttempts; iAttempts-- ) {
|
||||
destp = self.origin + ( self.velocity * flMoveTime );
|
||||
tracebox( self.origin, self.mins, self.maxs, destp, FALSE, self );
|
||||
|
||||
if ( trace_startsolid ) {
|
||||
if ( !Physics_Fix_Origin() ) {
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
self.origin = trace_endpos;
|
||||
|
||||
if ( trace_fraction < 1 ) {
|
||||
saved_plane_normal = trace_plane_normal;
|
||||
flMoveTime -= flMoveTime * trace_fraction;
|
||||
|
||||
if ( flMoveTime ) {
|
||||
//step up if we can
|
||||
trace_endpos = self.origin;
|
||||
|
||||
if ( self.flags & FL_ONGROUND ) {
|
||||
trace_endpos_z += PHYSICS_STEPHEIGHT;
|
||||
} else {
|
||||
trace_endpos_z += PHYSICS_AIRSTEPHEIGHT;
|
||||
}
|
||||
|
||||
tracebox( self.origin, self.mins, self.maxs, trace_endpos, FALSE, self );
|
||||
flStepped = trace_endpos_z - self.origin_z;
|
||||
|
||||
float roof_fraction = trace_fraction;
|
||||
vector roof_plane_normal = trace_plane_normal;
|
||||
|
||||
destp = trace_endpos + self.velocity*flMoveTime;
|
||||
destp_z = trace_endpos_z; /*only horizontally*/
|
||||
|
||||
//move forwards
|
||||
tracebox( trace_endpos, self.mins, self.maxs, destp, FALSE, self );
|
||||
|
||||
//if we got anywhere, make this raised-step move count
|
||||
if ( trace_fraction != 0 ) {
|
||||
float fwfrac = trace_fraction;
|
||||
vector fwplane = trace_plane_normal;
|
||||
|
||||
//move down
|
||||
destp = trace_endpos;
|
||||
destp_z -= flStepped + 1;
|
||||
tracebox( trace_endpos, self.mins, self.maxs, destp, FALSE, self );
|
||||
|
||||
if (trace_fraction == 1 || trace_plane_normal_z > .7) {
|
||||
flMoveTime -= flMoveTime * fwfrac;
|
||||
/*bounce off the ceiling if we hit it while airstepping*/
|
||||
if (roof_fraction < 1) {
|
||||
Physics_Rebound( roof_plane_normal );
|
||||
}
|
||||
|
||||
/*FIXME: you probably want this: && self.velocity_z < 0*/
|
||||
if ( trace_fraction < 1 ) {
|
||||
Physics_Rebound( trace_plane_normal );
|
||||
} else if ( fwfrac < 1 ) {
|
||||
Physics_Rebound( fwplane );
|
||||
}
|
||||
|
||||
self.origin = trace_endpos;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//stepping failed, just bounce off
|
||||
Physics_Rebound( saved_plane_normal );
|
||||
Physics_DoTouch( trace_ent );
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( self.flags & FL_ONGROUND ) && !( self.velocity_z > 0 ) ) {
|
||||
/*try to step down, only if there's something down there*/
|
||||
destp = self.origin;
|
||||
destp_z -= PHYSICS_STEPHEIGHT;
|
||||
tracebox( self.origin, self.mins, self.maxs, destp, FALSE, self ); //try going straight there
|
||||
if ( trace_fraction >= 1 ) {
|
||||
return;
|
||||
}
|
||||
if ( trace_startsolid ) {
|
||||
if ( !Physics_Fix_Origin() )
|
||||
return;
|
||||
}
|
||||
self.origin = trace_endpos;
|
||||
|
||||
Physics_DoTouch( trace_ent );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Physics_Run
|
||||
|
||||
Runs the physics for one input frame.
|
||||
=================
|
||||
*/
|
||||
void Physics_Run( void ) {
|
||||
/*Call accelerate flBefore and after the actual move, with half the move each time. This reduces framerate dependance.*/
|
||||
Physics_Run_Acceleration( input_timelength / 2, TRUE );
|
||||
Physics_Run_Move();
|
||||
Physics_Run_Acceleration( input_timelength / 2, FALSE );
|
||||
|
||||
/*NOTE: should clip to network precision here if lower than a float*/
|
||||
self.angles = input_angles;
|
||||
self.angles_x *= -0.333;
|
||||
|
||||
touchtriggers();
|
||||
}
|
|
@ -106,7 +106,6 @@ void Weapon_Draw( float fWeapon ) {
|
|||
self.viewzoom = 1.0;
|
||||
self.weapon = fWeapon;
|
||||
self.fAttackFinished = time + 1.0;
|
||||
self.maxspeed = Player_GetMaxSpeed( fWeapon );
|
||||
#endif
|
||||
|
||||
#ifdef CSQC
|
||||
|
@ -220,6 +219,17 @@ float Weapon_GetReloadTime( float fWeapon ) {
|
|||
return wptTable[ fWeapon ].fReloadFinished;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Weapon_GetSpeedM
|
||||
|
||||
Returns the speed multiplier
|
||||
=================
|
||||
*/
|
||||
float Weapon_GetSpeedM( float fWeapon ) {
|
||||
return wptTable[ fWeapon ].fSpeedM;
|
||||
}
|
||||
|
||||
#ifdef SSQC
|
||||
/*
|
||||
=================
|
||||
|
|
0
default.fmf
Normal file → Executable file
0
default.fmf
Normal file → Executable file
BIN
freecs/csprogs.dat
Executable file → Normal file
BIN
freecs/csprogs.dat
Executable file → Normal file
Binary file not shown.
|
@ -70,19 +70,20 @@ seta r_polygonoffset_submodel_offset "0"
|
|||
seta r_polygonoffset_submodel_factor "0"
|
||||
seta r_fullbrightSkins "0"
|
||||
seta r_fb_models "0"
|
||||
seta con_logcenterprint "0"
|
||||
seta v_contentblend "0"
|
||||
seta com_nogamedirnativecode "0"
|
||||
seta cl_cursor_scale "1"
|
||||
seta r_shadow_realtime_world_shadows "0"
|
||||
seta r_shadow_realtime_dlight_shadows "0"
|
||||
seta r_imageexensions "tga bmp pcx"
|
||||
seta gl_blacklist_debug_glsl 1
|
||||
seta gl_blacklist_debug_glsl 0
|
||||
seta vid_conautoscale "1"
|
||||
seta scr_conalpha "1"
|
||||
seta con_notifylines "0"
|
||||
seta con_logcenterprint "0"
|
||||
seta maxplayers "8"
|
||||
seta lang "en_us"
|
||||
seta cfg_save_auto "1"
|
||||
seta r_meshpitch "1"
|
||||
seta gl_overbright "0"
|
||||
seta gl_font "fonts/default"
|
||||
|
|
BIN
freecs/fonts/default.ttf
Normal file
BIN
freecs/fonts/default.ttf
Normal file
Binary file not shown.
BIN
freecs/menu.dat
BIN
freecs/menu.dat
Binary file not shown.
0
freecs/particles/decal_glass.tga
Normal file → Executable file
0
freecs/particles/decal_glass.tga
Normal file → Executable file
0
freecs/particles/decal_shot.tga
Normal file → Executable file
0
freecs/particles/decal_shot.tga
Normal file → Executable file
BIN
freecs/progs.dat
Executable file → Normal file
BIN
freecs/progs.dat
Executable file → Normal file
Binary file not shown.
Loading…
Reference in a new issue