Created
May 10, 2017 20:30
-
-
Save tingtom/3f35d6d72be3a298ecee320787e951be to your computer and use it in GitHub Desktop.
HL2 mod snippet - Looping sprint sounds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Loop sprinting | |
bool running = (m_fIsSprinting && GetAbsVelocity().Length2D() > 40); | |
if( running || m_fSprintStart > 0.0f) | |
{ | |
EmitSound_t t; | |
t.m_pSoundName = "Player.SprintLoop"; | |
t.m_nFlags = SND_CHANGE_VOL; | |
if( m_fSprintStart > 0.0f && !running ) | |
{ | |
float diff = gpGlobals->curtime - m_fSprintEnd; | |
//Fadeout under 1 seconds | |
if( diff < 1.0f ) | |
t.m_flVolume = 1 - diff / 1.0f; | |
else { | |
m_fSprintStart = 0.0f; | |
m_fSprintEnd = 0.0f; | |
t.m_nFlags = SND_STOP; | |
} | |
} else { | |
float diff = gpGlobals->curtime - m_fSprintStart; | |
//Fadein under 3 seconds | |
if( diff < 3.0f ) | |
t.m_flVolume = diff / 3.0f; | |
} | |
CPASAttenuationFilter filter( this ); | |
filter.UsePredictionRules(); | |
EmitSound(filter, entindex(), t ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
AND HOW AND WHERE TO INSERT IT - I JUST NOT A PROGRAMMER