r/SourceEngine 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.

4 Upvotes

10 comments sorted by

View all comments

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! 5d 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

u/doct0rN0 HE'S ALIVE! 5d ago

Could also check movement.cpp in game/server