* Cleaned up the gamemovement.cpp port

- Removed all instances of m_surfaceFriction being commented out and fixed m_surfaceFriction being set to .25 whenever in the air (this should allow for materials to set their own friction and actually have it do something)
 - Set g_bMovementOptimizations back to true (wasn't meant to be false)
 - Reverted any ported code in functions overwritten in FF's own GameMovement class and added a comment above the base class saying it's unused
* Added C_FF_SH_GameMovement class (is this an acceptable class naming scheme?)
 - Lots of code left unported in this file
 - Overwrites the PlayerRoughLandingEffects, Duck, and FinishUnDuck functions for now
* Excluded hl_gamemovement files from the project (there can only be one IGameMovement interface exposed at a time)

Conflicts:
	mp/src/game/client/client_ff.vpc
This commit is contained in:
squeek 2013-10-28 04:16:16 +00:00
parent 1ef1520ada
commit f5ed33341a
8 changed files with 670 additions and 93 deletions

View file

@ -568,6 +568,9 @@ private:
friend class CHL2GameMovement;
friend class CDODGameMovement;
friend class CPortalGameMovement;
// FF -->
friend class C_FF_SH_GameMovement;
// FF <--
// Accessors for gamemovement
float GetStepSize( void ) const { return m_Local.m_flStepSize; }

View file

@ -1,43 +1,49 @@
//-----------------------------------------------------------------------------
// CLIENT_FF.VPC
//
// Project Script
//-----------------------------------------------------------------------------
$Macro SRCDIR "..\.."
$Macro GAMENAME "ff" [!$SOURCESDK]
$Macro GAMENAME "FortressForever" [$SOURCESDK]
$Include "$SRCDIR\game\client\client_hl2mp.vpc"
$Include "$SRCDIR\game\shared\ff\ff_shared.vpc"
$Macro THIRDPARTYDIR "$SRCDIR\thirdparty"
$Configuration
{
$Compiler
{
$AdditionalIncludeDirectories "$BASE;ff\ui,.\ff,$SRCDIR\game\shared\ff,.\ff,.\ff\elements,$SRCDIR\game\shared\ff;$THIRDPARTYDIR\lua;$THIRDPARTYDIR"
$PreprocessorDefinitions "$BASE;FF;FF_CLIENT_DLL"
}
}
$Project "Client (FF)"
{
$Folder "Source Files"
{
// for FF Shared, see game\shared\ff\ff_shared.vpc
$Folder "FF"
{
$Folder "Libraries"
{
$Lib lua
$Lib luabind
}
}
// IMPORTANT: remove conflicting hl2dm SDK stuff as we implement our own!!
// done for us in HL2DM sdk vpc: -$File "$SRCDIR\game\shared\weapon_parse_default.cpp"
}
}
//-----------------------------------------------------------------------------
// CLIENT_FF.VPC
//
// Project Script
//-----------------------------------------------------------------------------
$Macro SRCDIR "..\.."
$Macro GAMENAME "ff" [!$SOURCESDK]
$Macro GAMENAME "FortressForever" [$SOURCESDK]
$Include "$SRCDIR\game\client\client_hl2mp.vpc"
$Include "$SRCDIR\game\shared\ff\ff_shared.vpc"
$Macro THIRDPARTYDIR "$SRCDIR\thirdparty"
$Configuration
{
$Compiler
{
$AdditionalIncludeDirectories "$BASE;ff\ui,.\ff,$SRCDIR\game\shared\ff,.\ff,.\ff\elements,$SRCDIR\game\shared\ff;$THIRDPARTYDIR\lua;$THIRDPARTYDIR"
$PreprocessorDefinitions "$BASE;FF;FF_CLIENT_DLL"
}
}
$Project "Client (FF)"
{
$Folder "Source Files"
{
// for FF Shared, see game\shared\ff\ff_shared.vpc
$Folder "FF"
{
$Folder "Libraries"
{
$Lib lua
$Lib luabind
}
}
// IMPORTANT: remove conflicting hl2dm SDK stuff as we implement our own!!
// done for us in HL2DM sdk vpc: -$File "$SRCDIR\game\shared\weapon_parse_default.cpp"
$Folder "HL2 DLL"
{
-$File "$SRCDIR\game\shared\hl2\hl_gamemovement.cpp"
-$File "$SRCDIR\game\shared\hl2\hl_gamemovement.h"
}
}
}

View file

@ -1137,6 +1137,9 @@ protected:
friend class CHL2GameMovement;
friend class CDODGameMovement;
friend class CPortalGameMovement;
// FF -->
friend class C_FF_SH_GameMovement;
// FF <--
// Accessors for gamemovement
bool IsDucked( void ) const { return m_Local.m_bDucked; }

View file

@ -47,6 +47,13 @@ $Project "Server (FF)"
// IMPORTANT: remove conflicting hl2dm SDK stuff as we implement our own!!
$Folder "HL2 DLL"
{
-$File "$SRCDIR\game\shared\hl2\hl_gamemovement.cpp"
-$File "$SRCDIR\game\shared\hl2\hl_gamemovement.h"
}
$Folder "HL2MP"
{
-$File "hl2mp\hl2mp_client.cpp"

View file

@ -0,0 +1,513 @@
// standard headers
#include "cbase.h"
#include "ff_sh_gamemovement.h"
// necessary headers
#include "in_buttons.h"
#include "movevars_shared.h"
#include "rumble_shared.h"
// variables
ConVar sv_sharkingfriction("sv_sharkingfriction", "1", FCVAR_REPLICATED);
#define SV_SHARKINGFRICTION sv_sharkingfriction.GetFloat()
// debug purposes
void C_FF_SH_GameMovement::PlayerMove( void )
{
static float flLastSurfaceFriction = -1.0f;
if (player->m_surfaceFriction != flLastSurfaceFriction)
{
DevMsg("m_surfaceFriction changed from %f to %f\n", flLastSurfaceFriction, player->m_surfaceFriction);
flLastSurfaceFriction = player->m_surfaceFriction;
}
BaseClass::PlayerMove();
}
void C_FF_SH_GameMovement::OnLand( float flFallVelocity )
{
BaseClass::OnLand( flFallVelocity );
// FF TODO: Rewrite this so that it doesn't use volume as a condition
// FF TODO: Make this code shared if possible
/*
if (fvol == 1.0f)
{
#ifdef GAME_DLL
if (player->GetGroundEntity() && player->GetGroundEntity()->IsPlayer())
{
CFFPlayer *pCrushedPlayer = ToFFPlayer(player->GetGroundEntity());
if (pCrushedPlayer && pCrushedPlayer != player)
{
float flCrushDamage = 0.0f;
if (HEADCRUSH_USEFALLDAMAGE > 0)
{
float flFallDamage = g_pGameRules->FlPlayerFallDamage( player );
flCrushDamage = flFallDamage * HEADCRUSH_USEFALLDAMAGE;
}
else
{
flCrushDamage = HEADCRUSH_DAMAGE;
}
CTakeDamageInfo info( player, player, flCrushDamage, DMG_DIRECT, KILLTYPE_HEADCRUSH );
pCrushedPlayer->TakeDamage(info);
}
}
#endif
}
*/
}
void C_FF_SH_GameMovement::PlayerRoughLandingEffects( float fvol )
{
if ( fvol > 0.0 )
{
// FF TODO: Play fall sound here, unported code below
/*
// --> Mirv: Use a fall sound, and reduce the volume for spies
CFFPlayer *pFFPlayer = ToFFPlayer(player);
Assert( pFFPlayer );
pFFPlayer->PlayFallSound( mv->m_vecAbsOrigin, player->m_pSurfaceData, fvol );
//
// Play landing sound right away.
// #0000599: footstep continues to play after cratering
// #0000401: Oddity with the fall sound.
pFFPlayer->m_flStepSoundTime = gpGlobals->curtime + 0.600f;
pFFPlayer->m_flJumpTime = gpGlobals->curtime + 0.600f;
// Play step sound for current texture.
//player->PlayStepSound( mv->m_vecAbsOrigin, player->m_pSurfaceData, fvol, true );
// <-- Mirv: Use a fall sound, and reduce the volume for spies
*/
//
// Play landing sound right away.
player->m_flStepSoundTime = 400;
// Play step sound for current texture.
player->PlayStepSound( (Vector &)mv->GetAbsOrigin(), player->m_pSurfaceData, fvol, true );
//
// Knock the screen around a little bit, temporary effect.
//
player->m_Local.m_vecPunchAngle.Set( ROLL, player->m_Local.m_flFallVelocity * 0.013 );
if ( player->m_Local.m_vecPunchAngle[PITCH] > 8 )
{
player->m_Local.m_vecPunchAngle.Set( PITCH, 8 );
}
#if !defined( CLIENT_DLL )
player->RumbleEffect( ( fvol > 0.85f ) ? ( RUMBLE_FALL_LONG ) : ( RUMBLE_FALL_SHORT ), 0, RUMBLE_FLAGS_NONE );
#endif
}
}
void C_FF_SH_GameMovement::FinishUnDuck( void )
{
int i;
trace_t trace;
Vector newOrigin;
VectorCopy( mv->GetAbsOrigin(), newOrigin );
// FF -->
// The extra check (m_Local.m_bDucked) added because players were popping up
// into the air when they hadn't yet been moved down for the duck
if ( player->GetGroundEntity() != NULL && player->m_Local.m_bDucked )
// FF <--
{
for ( i = 0; i < 3; i++ )
{
newOrigin[i] += ( VEC_DUCK_HULL_MIN_SCALED( player )[i] - VEC_HULL_MIN_SCALED( player )[i] );
}
}
else
{
// If in air an letting go of crouch, make sure we can offset origin to make
// up for uncrouching
Vector hullSizeNormal = VEC_HULL_MAX_SCALED( player ) - VEC_HULL_MIN_SCALED( player );
Vector hullSizeCrouch = VEC_DUCK_HULL_MAX_SCALED( player ) - VEC_DUCK_HULL_MIN_SCALED( player );
Vector viewDelta = ( hullSizeNormal - hullSizeCrouch );
viewDelta.Negate();
VectorAdd( newOrigin, viewDelta, newOrigin );
}
player->m_Local.m_bDucked = false;
player->RemoveFlag( FL_DUCKING );
player->m_Local.m_bDucking = false;
player->m_Local.m_bInDuckJump = false;
player->SetViewOffset( GetPlayerViewOffset( false ) );
player->m_Local.m_flDucktime = 0;
mv->SetAbsOrigin( newOrigin );
#ifdef CLIENT_DLL
player->ResetLatched();
#endif
// Recategorize position since ducking can change origin
CategorizePosition();
// FF TODO: A lot of unported changes here; this block replaces the else { } and below
/*
//trace = pmove->PM_PlayerTrace( newOrigin, newOrigin, PM_NORMAL, -1 );
TracePlayerBBox(newOrigin, newOrigin, PlayerSolidMask(), COLLISION_GROUP_PLAYER_MOVEMENT, trace);
if ( !trace.startsolid )
{
player->m_Local.m_bDucked = false; // pmove->usehull = 0;
// Oh, no, changing hulls stuck us into something, try unsticking downward first.
//trace = pmove->PM_PlayerTrace( newOrigin, newOrigin, PM_NORMAL, -1 );
TracePlayerBBox(newOrigin, newOrigin, PlayerSolidMask(), COLLISION_GROUP_PLAYER_MOVEMENT, trace);
if ( trace.startsolid )
{
// See if we are stuck? If so, stay ducked with the duck hull until we have a clear spot
//Con_Printf( "unstick got stuck\n" );
player->m_Local.m_bDucked = true; // pmove->usehull = 1;
return;
}
player->RemoveFlag(FL_DUCKING); // pmove->flags &= ~FL_DUCKING;
player->m_Local.m_bDucking = false;
//pmove->view_ofs[2] = VEC_VIEW;
Vector vecViewOffset = player->GetViewOffset();
vecViewOffset[2] = VEC_VIEW[2];
player->SetViewOffset(vecViewOffset);
player->m_Local.m_flDucktime = 0;
VectorCopy( newOrigin, mv->m_vecAbsOrigin );
// Recatagorize position since ducking can change origin
CategorizePosition();
}
*/
}
void C_FF_SH_GameMovement::Duck( void )
{
// FF TODO: Port these changes, this function was totally rewritten
/*
if (!player->IsAlive())
return;
int i;
float time;
float duckFraction;
int buttonsChanged = ( mv->m_nOldButtons ^ mv->m_nButtons ); // These buttons have changed this frame
int nButtonPressed = buttonsChanged & mv->m_nButtons; // The changed ones still down are "pressed"
//int duckchange = buttonsChanged & IN_DUCK ? 1 : 0;
//int duckpressed = nButtonPressed & IN_DUCK ? 1 : 0;
if ( mv->m_nButtons & IN_DUCK )
{
mv->m_nOldButtons |= IN_DUCK;
}
else
{
mv->m_nOldButtons &= ~IN_DUCK;
}
//if ( player->GetFlags() & FL_DUCKING )
//{
// pmove->cmd.forwardmove *= 0.333;
// pmove->cmd.sidemove *= 0.333;
// pmove->cmd.upmove *= 0.333;
//}
HandleDuckingSpeedCrop();
if ( ( mv->m_nButtons & IN_DUCK ) || ( player->m_Local.m_bDucking ) || ( player->GetFlags() & FL_DUCKING ) )
{
if ( mv->m_nButtons & IN_DUCK )
{
if ( (nButtonPressed & IN_DUCK ) && !( player->GetFlags() & FL_DUCKING ) )
{
// Use 1 second so super long jump will work
player->m_Local.m_flDucktime = 1000;
player->m_Local.m_bDucking = true;
}
time = max( 0.0, ( 1.0 - (float)player->m_Local.m_flDucktime / 1000.0 ) );
if ( player->m_Local.m_bDucking )
{
// Finish ducking immediately if duck time is over or not on ground
if ( ( (float)player->m_Local.m_flDucktime / 1000.0 <= ( 1.0 - TIME_TO_DUCK ) ) ||
( player->GetGroundEntity() == NULL ) && player->m_Local.m_flDucktime > 0 )
{
player->m_Local.m_bDucked = true; //pmove->usehull = 1;
//pmove->view_ofs[2] = VEC_DUCK_VIEW;
Vector vecOffset = player->GetViewOffset();
vecOffset[2] = VEC_DUCK_VIEW[2];
player->SetViewOffset(vecOffset);
player->AddFlag(FL_DUCKING); //player->GetFlags() |= FL_DUCKING;
//player->m_Local.m_bDucking = false;
// HACKHACK - Fudge for collision bug - no time to fix this properly
if ( player->GetGroundEntity() != NULL )
{
trace_t pm;
TracePlayerBBox(mv->m_vecAbsOrigin, mv->m_vecAbsOrigin - (VEC_DUCK_HULL_MIN - VEC_HULL_MIN), PlayerSolidMask(), COLLISION_GROUP_PLAYER_MOVEMENT, pm);
for ( i = 0; i < 3; i++ )
{
//Assert(pm.fraction == 1.0f);
mv->m_vecAbsOrigin[i] -= pm.fraction * ( VEC_DUCK_HULL_MIN[i] - VEC_HULL_MIN[i] );
}
// See if we are stuck?
FixPlayerCrouchStuck(true);
// Recatagorize position since ducking can change origin
CategorizePosition();
}
else
{
player->m_Local.m_bDucking = false;
}
}
else
{
float fMore = VEC_DUCK_HULL_MIN[2] - VEC_HULL_MIN[2];
// Calc parametric time
duckFraction = SplineFraction( time, (1.0/TIME_TO_DUCK) );
//pmove->view_ofs[2] = ((VEC_DUCK_VIEW - fMore ) * duckFraction) + (VEC_VIEW * (1-duckFraction));
Vector vecViewOfs = player->GetViewOffset();
vecViewOfs[2] = ((VEC_DUCK_VIEW[2] - fMore ) * duckFraction) + (VEC_VIEW[2] * (1-duckFraction));
player->SetViewOffset(vecViewOfs);
}
}
}
else
{
// Try to unduck
FinishUnDuck();
}
}
*/
int buttonsChanged = ( mv->m_nOldButtons ^ mv->m_nButtons ); // These buttons have changed this frame
int buttonsPressed = buttonsChanged & mv->m_nButtons; // The changed ones still down are "pressed"
int buttonsReleased = buttonsChanged & mv->m_nOldButtons; // The changed ones which were previously down are "released"
// Check to see if we are in the air.
bool bInAir = ( player->GetGroundEntity() == NULL );
bool bInDuck = ( player->GetFlags() & FL_DUCKING ) ? true : false;
bool bDuckJump = ( player->m_Local.m_flJumpTime > 0.0f );
bool bDuckJumpTime = ( player->m_Local.m_flDuckJumpTime > 0.0f );
if ( mv->m_nButtons & IN_DUCK )
{
mv->m_nOldButtons |= IN_DUCK;
}
else
{
mv->m_nOldButtons &= ~IN_DUCK;
}
// Handle death.
if ( IsDead() )
return;
// Slow down ducked players.
HandleDuckingSpeedCrop();
// If the player is holding down the duck button, the player is in duck transition, ducking, or duck-jumping.
if ( ( mv->m_nButtons & IN_DUCK ) || player->m_Local.m_bDucking || bInDuck || bDuckJump )
{
// DUCK
if ( ( mv->m_nButtons & IN_DUCK ) || bDuckJump )
{
/* FF: squeek: commenting this block out for now
// XBOX SERVER ONLY
#if !defined(CLIENT_DLL)
if ( IsX360() && buttonsPressed & IN_DUCK )
{
// Hinting logic
if ( player->GetToggledDuckState() && player->m_nNumCrouches < NUM_CROUCH_HINTS )
{
UTIL_HudHintText( player, "#Valve_Hint_Crouch" );
player->m_nNumCrouches++;
}
}
#endif
*/
// Have the duck button pressed, but the player currently isn't in the duck position.
if ( ( buttonsPressed & IN_DUCK ) && !bInDuck && !bDuckJump && !bDuckJumpTime )
{
player->m_Local.m_flDucktime = GAMEMOVEMENT_DUCK_TIME;
player->m_Local.m_bDucking = true;
}
// The player is in duck transition and not duck-jumping.
if ( player->m_Local.m_bDucking && !bDuckJump && !bDuckJumpTime )
{
float flDuckMilliseconds = MAX( 0.0f, GAMEMOVEMENT_DUCK_TIME - ( float )player->m_Local.m_flDucktime );
float flDuckSeconds = flDuckMilliseconds * 0.001f;
// Finish in duck transition when transition time is over, in "duck", in air.
if ( ( flDuckSeconds > TIME_TO_DUCK ) || bInDuck || bInAir )
{
FinishDuck();
}
else
{
// Calc parametric time
float flDuckFraction = SimpleSpline( flDuckSeconds / TIME_TO_DUCK );
SetDuckedEyeOffset( flDuckFraction );
}
}
if ( bDuckJump )
{
// Make the bounding box small immediately.
if ( !bInDuck )
{
StartUnDuckJump();
}
else
{
// Check for a crouch override.
if ( !( mv->m_nButtons & IN_DUCK ) )
{
trace_t trace;
if ( CanUnDuckJump( trace ) )
{
FinishUnDuckJump( trace );
player->m_Local.m_flDuckJumpTime = ( GAMEMOVEMENT_TIME_TO_UNDUCK * ( 1.0f - trace.fraction ) ) + GAMEMOVEMENT_TIME_TO_UNDUCK_INV;
}
}
}
}
}
// UNDUCK (or attempt to...)
else
{
if ( player->m_Local.m_bInDuckJump )
{
// Check for a crouch override.
if ( !( mv->m_nButtons & IN_DUCK ) )
{
trace_t trace;
if ( CanUnDuckJump( trace ) )
{
FinishUnDuckJump( trace );
if ( trace.fraction < 1.0f )
{
player->m_Local.m_flDuckJumpTime = ( GAMEMOVEMENT_TIME_TO_UNDUCK * ( 1.0f - trace.fraction ) ) + GAMEMOVEMENT_TIME_TO_UNDUCK_INV;
}
}
}
else
{
player->m_Local.m_bInDuckJump = false;
}
}
if ( bDuckJumpTime )
return;
// Try to unduck unless automovement is not allowed
// NOTE: When not onground, you can always unduck
if ( player->m_Local.m_bAllowAutoMovement || bInAir || player->m_Local.m_bDucking )
{
// We released the duck button, we aren't in "duck" and we are not in the air - start unduck transition.
if ( ( buttonsReleased & IN_DUCK ) )
{
if ( bInDuck && !bDuckJump )
{
player->m_Local.m_flDucktime = GAMEMOVEMENT_DUCK_TIME;
}
else if ( player->m_Local.m_bDucking && !player->m_Local.m_bDucked )
{
// Invert time if release before fully ducked!!!
float unduckMilliseconds = 1000.0f * TIME_TO_UNDUCK;
float duckMilliseconds = 1000.0f * TIME_TO_DUCK;
float elapsedMilliseconds = GAMEMOVEMENT_DUCK_TIME - player->m_Local.m_flDucktime;
float fracDucked = elapsedMilliseconds / duckMilliseconds;
float remainingUnduckMilliseconds = fracDucked * unduckMilliseconds;
player->m_Local.m_flDucktime = GAMEMOVEMENT_DUCK_TIME - unduckMilliseconds + remainingUnduckMilliseconds;
}
}
// Check to see if we are capable of unducking.
if ( CanUnduck() )
{
// or unducking
if ( ( player->m_Local.m_bDucking || player->m_Local.m_bDucked ) )
{
float flDuckMilliseconds = MAX( 0.0f, GAMEMOVEMENT_DUCK_TIME - (float)player->m_Local.m_flDucktime );
float flDuckSeconds = flDuckMilliseconds * 0.001f;
// Finish ducking immediately if duck time is over or not on ground
if ( flDuckSeconds > TIME_TO_UNDUCK || ( bInAir && !bDuckJump ) )
{
FinishUnDuck();
}
else
{
// Calc parametric time
float flDuckFraction = SimpleSpline( 1.0f - ( flDuckSeconds / TIME_TO_UNDUCK ) );
SetDuckedEyeOffset( flDuckFraction );
player->m_Local.m_bDucking = true;
}
}
}
else
{
// Still under something where we can't unduck, so make sure we reset this timer so
// that we'll unduck once we exit the tunnel, etc.
if ( player->m_Local.m_flDucktime != GAMEMOVEMENT_DUCK_TIME )
{
SetDuckedEyeOffset(1.0f);
player->m_Local.m_flDucktime = GAMEMOVEMENT_DUCK_TIME;
player->m_Local.m_bDucked = true;
player->m_Local.m_bDucking = false;
player->AddFlag( FL_DUCKING );
}
}
}
}
}
// HACK: (jimd 5/25/2006) we have a reoccuring bug (#50063 in Tracker) where the player's
// view height gets left at the ducked height while the player is standing, but we haven't
// been able to repro it to find the cause. It may be fixed now due to a change I'm
// also making in UpdateDuckJumpEyeOffset but just in case, this code will sense the
// problem and restore the eye to the proper position. It doesn't smooth the transition,
// but it is preferable to leaving the player's view too low.
//
// If the player is still alive and not an observer, check to make sure that
// his view height is at the standing height.
else if ( !IsDead() && !player->IsObserver() && !player->IsInAVehicle() )
{
if ( ( player->m_Local.m_flDuckJumpTime == 0.0f ) && ( fabs(player->GetViewOffset().z - GetPlayerViewOffset( false ).z) > 0.1 ) )
{
// we should rarely ever get here, so assert so a coder knows when it happens
Assert(0);
DevMsg( 1, "Restoring player view height\n" );
// set the eye height to the non-ducked height
SetDuckedEyeOffset(0.0f);
}
}
}
// Expose our interface.
static C_FF_SH_GameMovement g_GameMovement;
IGameMovement *g_pGameMovement = ( IGameMovement * )&g_GameMovement;
EXPOSE_SINGLE_INTERFACE_GLOBALVAR( C_FF_SH_GameMovement, IGameMovement, INTERFACENAME_GAMEMOVEMENT, g_GameMovement );

View file

@ -0,0 +1,33 @@
#ifndef FF_SH_GAMEMOVEMENT_H
#define FF_SH_GAMEMOVEMENT_H
#ifdef _WIN32
#pragma once
#endif
#include "gamemovement.h"
class CBasePlayer;
class C_FF_SH_GameMovement : public CGameMovement
{
DECLARE_CLASS(C_FF_SH_GameMovement, CGameMovement);
public:
C_FF_SH_GameMovement() {};
protected:
/// Catches all landings
virtual void OnLand( float flFallVelocity );
/// Overwritten from gamemovement.cpp -->
virtual void PlayerRoughLandingEffects( float fvol );
// Ducking
virtual void Duck( void );
virtual void FinishUnDuck( void );
/// Overwritten from gamemovement.cpp <---
/// For debug purposes only
virtual void PlayerMove( void );
};
#endif

View file

@ -12,6 +12,11 @@ $Project
$File "$SRCDIR\game\shared\ff\ff_scriptman_shared.cpp"
$File "$SRCDIR\game\shared\ff\ff_scriptman_shared.h"
}
$Folder "Movement"
{
$File "$SRCDIR\game\shared\ff\ff_sh_gamemovement.cpp"
$File "$SRCDIR\game\shared\ff\ff_sh_gamemovement.h"
}
$File "$SRCDIR\game\shared\ff\ff_gamerules_shared.cpp"
$File "$SRCDIR\game\shared\ff\ff_gamerules_shared.h"

View file

@ -56,8 +56,7 @@ ConVar player_limit_jump_speed( "player_limit_jump_speed", "1", FCVAR_REPLICATED
ConVar option_duck_method("option_duck_method", "1", FCVAR_REPLICATED|FCVAR_ARCHIVE );// 0 = HOLD to duck, 1 = Duck is a toggle
// [MD] I'll remove this eventually. For now, I want the ability to A/B the optimizations.
// FF port note: sets to false.. default is true, set to false here too
bool g_bMovementOptimizations = false;
bool g_bMovementOptimizations = true;
// Roughly how often we want to update the info about the ground surface we're on.
// We don't need to do this very often.
@ -1044,7 +1043,7 @@ void CGameMovement::CheckParameters( void )
}
}
// FF squeek: transition from walk -> crouch brought you back to full speed; only stop cropping speed when the player is fully ducked
// FF --> squeek: transition from walk -> crouch brought you back to full speed; only stop cropping speed when the player is fully ducked
// porting note: speed cropped changed from bool to flags
if ( m_iSpeedCropped == SPEED_CROPPED_RESET && ( mv->m_nButtons & IN_SPEED ) /*&& !(mv->m_nButtons & IN_DUCK)*/ && !( player->m_Local.m_bDucked /*&& !player->m_Local.m_bDucking*/ ))
{
@ -1056,6 +1055,7 @@ void CGameMovement::CheckParameters( void )
m_iSpeedCropped |= SPEED_CROPPED_DUCK; // FF Dexter: set to duck value since we dont use weapon
}
// FF <--
if ( player->GetFlags() & FL_FROZEN ||
player->GetFlags() & FL_ONTRAIN ||
@ -1406,22 +1406,19 @@ void CGameMovement::WaterMove( void )
//
for (i=0 ; i<3 ; i++)
{
// FF Bug #0000964: +moveup/+movedown don't work
// Hey, get some up velocity wishing going on to buddy! Don't forget about us +moveup/+movedown users!
// FF --> Add in UpMove so that +moveup/+movedown works
wishvel[i] = forward[i]*mv->m_flForwardMove + right[i]*mv->m_flSideMove + up[i]*mv->m_flUpMove;
// FF <--
}
bool bIsSharking = false;
// FF --> Mirv: Sharking fix
// if we have the jump key down, move us up as well
if (mv->m_nButtons & IN_JUMP)
{
// FF --> Move at a standard speed
//wishvel[2] += mv->m_flClientMaxSpeed;
mv->m_vecVelocity[2] = 100.0f;
bIsSharking = true;
// FF <--
}
// FF <-- Mirv: Trimping fix
// Sinking after no other movement occurs
if (!mv->m_flForwardMove && !mv->m_flSideMove && !mv->m_flUpMove && player->GetGroundEntity() == NULL) // FF |-- Mirv: But only when not on ground, to fix #0000432: Standing underwater on a slope causes player to slip
@ -1442,12 +1439,7 @@ void CGameMovement::WaterMove( void )
VectorCopy (wishvel, wishdir);
wishspeed = VectorNormalize(wishdir);
// FF --> Jon: cap swimming speed if cloaked
// FF TODO: (player stuff)
//float flMaxSpeed = mv->m_flMaxSpeed;
//if (ToFFPlayer(player)->IsCloaked())
// flMaxSpeed = SPY_MAXCLOAKSPEED;
// FF TODO: squeek: Spy cloak max swimming speed was set here, surely there's a better place for it?
// Cap speed.
if (wishspeed > mv->m_flMaxSpeed)
{
@ -1463,11 +1455,13 @@ void CGameMovement::WaterMove( void )
speed = VectorNormalize(temp);
if (speed)
{
// FF: sharking
if (!bIsSharking)
newspeed = speed - gpGlobals->frametime * speed * /*sv_friction.GetFloat()*/ 4.0f * /*player->m_surfaceFriction*/ 1.0f; // |-- Mirv: More TFC Feeling (tm) friction
else
newspeed = speed - gpGlobals->frametime * speed * SV_SHARKINGFRICTION * /*player->m_surfaceFriction*/ 1.0f;
// FF --> Different water frictions for jump key held (sharking) vs not
bool bIsSharking = player->GetWaterLevel() < WL_Waist && mv->m_nButtons & IN_JUMP;
float flWaterFriction = bIsSharking ? SV_SHARKINGFRICTION : sv_friction.GetFloat();
// FF <--
newspeed = speed - gpGlobals->frametime * speed * flWaterFriction * player->m_surfaceFriction;
if (newspeed < 0.1f)
{
newspeed = 0;
@ -1682,9 +1676,6 @@ void CGameMovement::Friction( void )
{
friction = sv_friction.GetFloat() * player->m_surfaceFriction;
// FF: friction tweak
friction *= /*player->m_surfaceFriction*/ 1.0f; // |-- Mirv: More TFC Feeling (tm) friction
// Bleed off some speed, but if we have less than the bleed
// threshold, bleed the threshold amount.
@ -1783,7 +1774,7 @@ void CGameMovement::AirAccelerate( Vector& wishdir, float wishspeed, float accel
return;
// Determine acceleration speed after acceleration
accelspeed = accel * wishspeed * gpGlobals->frametime * /*player->m_surfaceFriction*/ 1.0f; // FF |-- Mirv: More TFC Feeling (tm) friction
accelspeed = accel * wishspeed * gpGlobals->frametime * player->m_surfaceFriction;
// Cap it
if (accelspeed > addspeed)
@ -1890,7 +1881,7 @@ void CGameMovement::Accelerate( Vector& wishdir, float wishspeed, float accel )
return;
// Determine amount of accleration.
accelspeed = accel * gpGlobals->frametime * wishspeed * /*player->m_surfaceFriction*/ 1.0f; // FF |-- Mirv: More TFC Feeling (tm) friction
accelspeed = accel * gpGlobals->frametime * wishspeed * player->m_surfaceFriction;
// Cap at addspeed
if (accelspeed > addspeed)
@ -1934,14 +1925,14 @@ void CGameMovement::StayOnGround( void )
//This is incredibly hacky. The real problem is that trace returning that strange value we can't network over.
if ( flDelta > 0.5f * COORD_RESOLUTION)
{
// FF --> Mirv:
// FF --> Mirv:
// If we have stepped up far enough then flag for smoothstairs
float flDistance = mv->GetAbsOrigin().z - trace.endpos.z;
if (flDistance >= 8.0f)
{
player->m_bSmoothStair = true;
}
// <-- Mirv
// <-- FF
mv->SetAbsOrigin( trace.endpos );
}
}
@ -2095,12 +2086,13 @@ void CGameMovement::FullWalkMove( )
// See if we are still in water?
CheckWater();
// FF hlstriker: Make sure player isn't swimming before we return
// FF --> hlstriker: Make sure player isn't swimming before we return
if( player->GetWaterLevel() < WL_Waist )
{
player->m_flWaterJumpTime = 0;
return;
}
return;
}
// FF <--
}
// If we are swimming in the water, see if we are nudging against a place we can jump up out
@ -2872,7 +2864,6 @@ int CGameMovement::TryPlayerMove( Vector *pFirstDest, trace_t *pFirstTrace )
fSlamVol = 0.85f;
}
// FF TODO: move player falling sounds here
PlayerRoughLandingEffects( fSlamVol );
return blocked;
@ -3872,11 +3863,16 @@ void CGameMovement::CategorizePosition( void )
// Shooting up really fast. Definitely not on ground.
// On ladder moving up, so not on ground either
// NOTE: 145 is a jump.
// FF --> Port notes: this is done kinda wacky trrying to move mirvs code the same way
//#define NON_JUMP_VELOCITY 140.0f
// FF Port notes: this is done kinda wacky trrying to move mirvs code the same way
float NON_JUMP_VELOCITY = 180.0f;
if ( ( mv->m_nButtons & IN_JUMP ) && ! ( mv->m_nOldButtons & IN_JUMP ) )
NON_JUMP_VELOCITY = 260000;
// FF TODO: Consider rethinking this whole thing. This (indirectly) is the code that enables rampsliding,
// because if you're above this NON_JUMP_VELOCITY threshold you are considered in the air.
// This makes it hard to accurately detect if someone is truly rampsliding or just got their
// velocity altered by something recently that should put them in the air (like a server-side func_push)
float NON_JUMP_VELOCITY = 180.0f;
if ( ( mv->m_nButtons & IN_JUMP ) && ! ( mv->m_nOldButtons & IN_JUMP ) )
NON_JUMP_VELOCITY = 260000;
// FF <--
float zvel = mv->m_vecVelocity[2];
bool bMovingUp = zvel > 0.0f;
@ -3922,7 +3918,9 @@ void CGameMovement::CategorizePosition( void )
if ( ( mv->m_vecVelocity.z > 0.0f ) &&
( player->GetMoveType() != MOVETYPE_NOCLIP ) )
{
player->m_surfaceFriction = 0.25f;
// FF --> This sets surfaceFriction to 0.25 whenever not on the ground; totally undesirable behavior
//player->m_surfaceFriction = 0.25f;
// FF <--
}
}
else
@ -3987,6 +3985,10 @@ void CGameMovement::CheckFalling( void )
if ( player->GetWaterLevel() > 0 )
{
// They landed in water.
// FF --> No fall sound for water landings
// FF TODO: Check effects of this change
fvol = 0;
// FF <--
}
else
{
@ -4016,8 +4018,9 @@ void CGameMovement::CheckFalling( void )
}
else if ( player->m_Local.m_flFallVelocity > PLAYER_MAX_SAFE_FALL_SPEED / 2 )
{
// FF 0000608: Makes dropping damage sound from heights that dont inflict damage
// FF --> Only falls that actually do damage should make a sound
fvol = 0; //0.85;
// FF <--
}
else if ( player->m_Local.m_flFallVelocity < PLAYER_MIN_BOUNCE_SPEED )
{
@ -4025,8 +4028,6 @@ void CGameMovement::CheckFalling( void )
}
}
// FF Note -> was logic in fall sound code here,
// FF TODO: Landing effects sound
PlayerRoughLandingEffects( fvol );
if (bAlive)
@ -4044,6 +4045,7 @@ void CGameMovement::CheckFalling( void )
player->m_Local.m_flFallVelocity = 0;
}
// FF: UNUSED. Overwritten in FF's GameMovement
void CGameMovement::PlayerRoughLandingEffects( float fvol )
{
if ( fvol > 0.0 )
@ -4067,7 +4069,6 @@ void CGameMovement::PlayerRoughLandingEffects( float fvol )
#if !defined( CLIENT_DLL )
player->RumbleEffect( ( fvol > 0.85f ) ? ( RUMBLE_FALL_LONG ) : ( RUMBLE_FALL_SHORT ), 0, RUMBLE_FLAGS_NONE );
// FF TODO: FF player headcrush would go here!!!
#endif
}
}
@ -4159,6 +4160,7 @@ bool CGameMovement::CanUnduck()
//-----------------------------------------------------------------------------
// Purpose: Stop ducking
//-----------------------------------------------------------------------------
// FF: UNUSED. Overwritten in FF's GameMovement
void CGameMovement::FinishUnDuck( void )
{
int i;
@ -4166,11 +4168,8 @@ void CGameMovement::FinishUnDuck( void )
Vector newOrigin;
VectorCopy( mv->GetAbsOrigin(), newOrigin );
// FF : believe this is our change
// The extra check (m_Local.m_bDucked) added because players were popping up
// into the air when they hadn't yet been moved down for the duck
if ( player->GetGroundEntity() != NULL && player->m_Local.m_bDucked )
if ( player->GetGroundEntity() != NULL )
{
for ( i = 0; i < 3; i++ )
{
@ -4291,7 +4290,9 @@ void CGameMovement::FinishDuck( void )
{
Vector hullSizeNormal = VEC_HULL_MAX_SCALED( player ) - VEC_HULL_MIN_SCALED( player );
Vector hullSizeCrouch = VEC_DUCK_HULL_MAX_SCALED( player ) - VEC_DUCK_HULL_MIN_SCALED( player );
Vector viewDelta = ( hullSizeNormal - hullSizeCrouch ) / 2.0f ; // FF |-- Mirv: We only want half the difference
// FF -->
Vector viewDelta = ( hullSizeNormal - hullSizeCrouch ) / 2.0f ; // Mirv: We only want half the difference
// FF <--
Vector out;
VectorAdd( mv->GetAbsOrigin(), viewDelta, out );
mv->SetAbsOrigin( out );
@ -4321,7 +4322,9 @@ void CGameMovement::StartUnDuckJump( void )
Vector hullSizeNormal = VEC_HULL_MAX_SCALED( player ) - VEC_HULL_MIN_SCALED( player );
Vector hullSizeCrouch = VEC_DUCK_HULL_MAX_SCALED( player ) - VEC_DUCK_HULL_MIN_SCALED( player );
Vector viewDelta = ( hullSizeNormal - hullSizeCrouch ) / 2.0f; // FF |-- Mirv: We only want half the difference
// FF -->
Vector viewDelta = ( hullSizeNormal - hullSizeCrouch ) / 2.0f; // Mirv: We only want half the difference
// FF <--
Vector out;
VectorAdd( mv->GetAbsOrigin(), viewDelta, out );
mv->SetAbsOrigin( out );
@ -4401,6 +4404,7 @@ bool CGameMovement::CanUnDuckJump( trace_t &trace )
//-----------------------------------------------------------------------------
// Purpose: See if duck button is pressed and do the appropriate things
//-----------------------------------------------------------------------------
// FF: UNUSED. Overwritten in FF's GameMovement
void CGameMovement::Duck( void )
{
int buttonsChanged = ( mv->m_nOldButtons ^ mv->m_nButtons ); // These buttons have changed this frame
@ -4681,7 +4685,9 @@ void CGameMovement::PlayerMove( void )
Duck();
// Don't run ladder code if dead on on a train
if ( !player->pl.deadflag && !(player->GetFlags() & FL_ONTRAIN) )
// FF --> Also don't run ladder code for observers
if ( !player->pl.deadflag && !(player->GetFlags() & FL_ONTRAIN) && (player->GetMoveType() != MOVETYPE_OBSERVER) )
// FF <--
{
// If was not on a ladder now, but was on one before,
// get off of the ladder
@ -4717,6 +4723,7 @@ void CGameMovement::PlayerMove( void )
switch (player->GetMoveType())
{
case MOVETYPE_NONE:
// FF TODO: FullBuildMove() ?
break;
case MOVETYPE_NOCLIP:
@ -4778,7 +4785,7 @@ void CGameMovement::PerformFlyCollisionResolution( trace_t &pm, Vector &move )
case MOVECOLLIDE_DEFAULT:
{
if (player->GetMoveCollide() == MOVECOLLIDE_FLY_BOUNCE)
backoff = 2.0 - /* player->m_surfaceFriction */ 1.0f; // FF |-- Mirv: More TFC feeling (tm) friction
backoff = 2.0 - player->m_surfaceFriction; // FF TODO: Does surfaceFriction negatively impact this? FF used to use 1.0 instead of surfaceFriction; need to figure out what this affects
else
backoff = 1;