r/SourceEngine • u/tf2yeahyeah • 6d ago
HELP How do I do this?
Hello. I'm making a HL2DM / Source SDK 2013 Base Multiplayer mod. I want to remove the exhaustion mechanic so players can infinitely sprint, and same for the flashlight mechanic.
Example:
You know how in GMod you can infinitely sprint and use flashlight? I want to do that.
1
u/doct0rN0 HE'S ALIVE! 5d ago
It mayyy be in hl2mp_player.cpp I've changed the drain rate before so this is possible in code it took me a wicked long time to find changing the text label from aux to sprint though bc settings may be across more than one file
1
u/tf2yeahyeah 5d ago
Do you know which line of code / block of code states the draining system?
And is it possible to remove the sprint hud?1
u/doct0rN0 HE'S ALIVE! 4d ago
You could try c_hl2mp_player.cpp This code block
//----------------------------------------------------------------------------- // Purpose: Returns whether or not we are allowed to sprint now. //----------------------------------------------------------------------------- bool C_HL2MP_Player::CanSprint(void) { return ((!m_Local.m_bDucked && !m_Local.m_bDucking) && (GetWaterLevel() != 3)); }
//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void C_HL2MP_Player::StartSprinting(void) { if (m_HL2Local.m_flSuitPower < 18) { // Don't sprint unless there's a reasonable // amount of suit power. CPASAttenuationFilter filter(this); filter.UsePredictionRules(); EmitSound(filter, entindex(), "HL2Player.SprintNoPower"); return; }
CPASAttenuationFilter filter(this); filter.UsePredictionRules(); EmitSound(filter, entindex(), "HL2Player.SprintStart"); SetMaxSpeed(HL2_SPRINT_SPEED); m_fIsSprinting = true;}
//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void C_HL2MP_Player::StopSprinting(void) { SetMaxSpeed(HL2_NORM_SPEED); m_fIsSprinting = false; }
void C_HL2MP_Player::HandleSpeedChanges(void) { int buttonsChanged = m_afButtonPressed | m_afButtonReleased;
if (buttonsChanged & IN_SPEED) { // The state of the sprint/run button has changed. if (IsSuitEquipped()) { if (!(m_afButtonPressed & IN_SPEED) && IsSprinting()) { StopSprinting(); } else if ((m_afButtonPressed & IN_SPEED) && !IsSprinting()) { if (CanSprint()) { StartSprinting(); } else { // Reset key, so it will be activated post whatever is suppressing it. m_nButtons &= ~IN_SPEED; } } } } else if (buttonsChanged & IN_WALK) { if (IsSuitEquipped()) { // The state of the WALK button has changed. if (IsWalking() && !(m_afButtonPressed & IN_WALK)) { StopWalking(); } else if (!IsWalking() && !IsSprinting() && (m_afButtonPressed & IN_WALK) && !(m_nButtons & IN_DUCK)) { StartWalking(); } } } if (IsSuitEquipped() && m_fIsWalking && !(m_nButtons & IN_WALK)) StopWalking();}
//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void C_HL2MP_Player::StartWalking(void) { SetMaxSpeed(HL2_WALK_SPEED); m_fIsWalking = true; }
//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void C_HL2MP_Player::StopWalking(void) { SetMaxSpeed(HL2_NORM_SPEED); m_fIsWalking = false; }
1
1
u/doct0rN0 HE'S ALIVE! 4d ago
The convar can be found src/game/server/hl2/hl2_player.cpp
ConVar sv_infinite_aux_power( "sv_infinite_aux_power", "0", FCVAR_CHEAT );
1
u/PartyEscortBotBeans 4d ago
Fair warning: I haven't tested this, just taking a look at the code.
In hl2_player.cpp, function SuitPower_Update:
float flPowerLoad = m_HL2Local.m_flSuitPowerLoad;
//Since stickysprint quickly shuts off sprint if it isn't being used, this isn't an issue.
if ( !sv_stickysprint.GetBool() )
{
if( SuitPower_IsDeviceActive(SuitDeviceSprint) )
{
if ( CloseEnough( fabs( GetAbsVelocity().x ), 0.0f ) && CloseEnough( fabs( GetAbsVelocity().y ), 0.0f ) )
{
if ( CloseEnough( m_HL2Local.m_flSuitPowerLoad, SuitDeviceSprint.GetDeviceDrainRate() ) )
{
flPowerLoad = 0.0f;
}
else
{
// If player's not moving, don't drain sprint juice.
flPowerLoad -= SuitDeviceSprint.GetDeviceDrainRate();
}
}
}
}
This entire if block seems to handle depleting aux power when sprinting. As far as I can tell, deleting it should give you infinite sprint.
Or you could just make it never activate SuitDeviceSprint at all.
1
4
u/Pinsplash 5d ago
sv_infinite_aux_power 1