Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix transferring active Stim ability to Titan and endless stim effects #864

Merged
merged 14 commits into from
Nov 27, 2024
Merged
61 changes: 42 additions & 19 deletions Northstar.Custom/mod/scripts/vscripts/weapons/sh_stim.gnut
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,23 @@ void function StimPlayer( entity player, float duration, float severity = STIM_E

void function StimPlayer_Internal( entity player, float duration, float effectSeverity )
{
int endlessStatusEffectHandle = 0
// Handles for tracking status effects
int statusEffectHandle_SpeedBoost = 0
int statusEffectHandle_StimVFX = 0
if ( duration == USE_TIME_INFINITE )
{
endlessStatusEffectHandle = StatusEffect_AddEndless( player, eStatusEffect.speed_boost, effectSeverity )
statusEffectHandle_SpeedBoost = StatusEffect_AddEndless( player, eStatusEffect.speed_boost, effectSeverity )
statusEffectHandle_StimVFX = StatusEffect_AddEndless( player, eStatusEffect.stim_visual_effect, 1.0 )
}
else
{
StatusEffect_AddTimed( player, eStatusEffect.speed_boost, effectSeverity, duration + 0.5, 0.25 ) // sound is slightly off
StatusEffect_AddTimed( player, eStatusEffect.stim_visual_effect, 1.0, duration, duration )
statusEffectHandle_SpeedBoost = StatusEffect_AddTimed( player, eStatusEffect.speed_boost, effectSeverity, duration + 0.5, 0.25 ) // sound is slightly off
statusEffectHandle_StimVFX = StatusEffect_AddTimed( player, eStatusEffect.stim_visual_effect, 1.0, duration, duration )
}

#if SERVER
thread StimThink( player, duration, endlessStatusEffectHandle )
#else
thread StimThink( player, duration, statusEffectHandle_SpeedBoost, statusEffectHandle_StimVFX )
#else // CLIENT
entity cockpit = player.GetCockpit()
if ( !IsValid( cockpit ) )
return
Expand All @@ -63,15 +66,25 @@ void function StimPlayer_Internal( entity player, float duration, float effectSe
}

#if SERVER
void function StimThink( entity player, float duration, int endlessStatusEffectHandle )
void function StimThink( entity player, float duration, int statusEffectHandle_SpeedBoost, int statusEffectHandle_StimVFX )
{
player.EndSignal( "OnDeath" )
player.EndSignal( "OnChangedPlayerClass" )
if ( endlessStatusEffectHandle != 0 )
player.EndSignal( "StopEndlessStim" )
player.EndSignal( "player_embarks_titan" ) // Prevent transferring active Stim ability to Titan.

EmitSoundOnEntityOnlyToPlayer( player, player, "pilot_stimpack_loop_1P" )
EmitSoundOnEntityExceptToPlayer( player, player, "pilot_stimpack_loop_3P" )
if ( duration == USE_TIME_INFINITE )
{
player.EndSignal( "StopEndlessStim" )
// TF|2 stim loop sounds don't actually loop, use TF|1 loop sound.
// TF|1 sound is very quiet, is there a way to boost its volume (it has 300% volume in TF|1), except playing 3 sounds at once?
// BUG: It still stops playing sometimes for whatever reason ( Too many sounds? )
EmitSoundOnEntity( player, "Pilot_Stimpack_Loop" )
}
else
{
EmitSoundOnEntityOnlyToPlayer( player, player, "pilot_stimpack_loop_1P" )
EmitSoundOnEntityExceptToPlayer( player, player, "pilot_stimpack_loop_3P" )
}

int attachmentIndex = player.LookupAttachment( "CHESTFOCUS" )

Expand All @@ -82,19 +95,29 @@ void function StimThink( entity player, float duration, int endlessStatusEffectH
//thread StimSlowmoAim( player, duration )

OnThreadEnd(
function() : ( player, stimFX, endlessStatusEffectHandle )
function() : ( player, duration, stimFX, statusEffectHandle_SpeedBoost, statusEffectHandle_StimVFX )
{
if ( !IsValid( player ) )
return

if ( IsValid( stimFX ) )
EffectStop( stimFX )

StopSoundOnEntity( player, "pilot_stimpack_loop_1P" )
StopSoundOnEntity( player, "pilot_stimpack_loop_3P" )

if ( endlessStatusEffectHandle != 0 )
StatusEffect_Stop( player, endlessStatusEffectHandle )
if ( duration == USE_TIME_INFINITE )
{
StopSoundOnEntity( player, "Pilot_Stimpack_Loop" )
}
else
{
StopSoundOnEntity( player, "pilot_stimpack_loop_1P" )
StopSoundOnEntity( player, "pilot_stimpack_loop_3P" )
}

if ( statusEffectHandle_SpeedBoost != 0 )
StatusEffect_Stop( player, statusEffectHandle_SpeedBoost )

if ( statusEffectHandle_StimVFX != 0 )
StatusEffect_Stop( player, statusEffectHandle_StimVFX )

player.Signal( "EndStim" )
}
Expand All @@ -111,7 +134,7 @@ void function StimThink( entity player, float duration, int endlessStatusEffectH
wait 2.0
}

#else // #if SERVER
#else // CLIENT
void function StimVisualsEnabled( entity ent, int statusEffect, bool actuallyChanged )
{
if ( ent != GetLocalViewPlayer() )
Expand Down Expand Up @@ -164,4 +187,4 @@ void function StimScreenFXThink( entity player, int fxHandle, entity cockpit )
}
}

#endif // #else // #if SERVER
#endif
Loading