Skip to content

Commit c3c2535

Browse files
authored
Fix transferring active Stim ability to Titan and endless stim effects (R2Northstar#864)
Fix endless Stim ability not playing loop sound and visual effects. Fix transferring active Pilot Stim ability to Titan when embarking it. Fix transferring active timed Stim ability to Titan.
1 parent 49791ea commit c3c2535

File tree

1 file changed

+42
-19
lines changed

1 file changed

+42
-19
lines changed

Northstar.Custom/mod/scripts/vscripts/weapons/sh_stim.gnut

+42-19
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,23 @@ void function StimPlayer( entity player, float duration, float severity = STIM_E
4040

4141
void function StimPlayer_Internal( entity player, float duration, float effectSeverity )
4242
{
43-
int endlessStatusEffectHandle = 0
43+
// Handles for tracking status effects
44+
int statusEffectHandle_SpeedBoost = 0
45+
int statusEffectHandle_StimVFX = 0
4446
if ( duration == USE_TIME_INFINITE )
4547
{
46-
endlessStatusEffectHandle = StatusEffect_AddEndless( player, eStatusEffect.speed_boost, effectSeverity )
48+
statusEffectHandle_SpeedBoost = StatusEffect_AddEndless( player, eStatusEffect.speed_boost, effectSeverity )
49+
statusEffectHandle_StimVFX = StatusEffect_AddEndless( player, eStatusEffect.stim_visual_effect, 1.0 )
4750
}
4851
else
4952
{
50-
StatusEffect_AddTimed( player, eStatusEffect.speed_boost, effectSeverity, duration + 0.5, 0.25 ) // sound is slightly off
51-
StatusEffect_AddTimed( player, eStatusEffect.stim_visual_effect, 1.0, duration, duration )
53+
statusEffectHandle_SpeedBoost = StatusEffect_AddTimed( player, eStatusEffect.speed_boost, effectSeverity, duration + 0.5, 0.25 ) // sound is slightly off
54+
statusEffectHandle_StimVFX = StatusEffect_AddTimed( player, eStatusEffect.stim_visual_effect, 1.0, duration, duration )
5255
}
5356

5457
#if SERVER
55-
thread StimThink( player, duration, endlessStatusEffectHandle )
56-
#else
58+
thread StimThink( player, duration, statusEffectHandle_SpeedBoost, statusEffectHandle_StimVFX )
59+
#else // CLIENT
5760
entity cockpit = player.GetCockpit()
5861
if ( !IsValid( cockpit ) )
5962
return
@@ -63,15 +66,25 @@ void function StimPlayer_Internal( entity player, float duration, float effectSe
6366
}
6467

6568
#if SERVER
66-
void function StimThink( entity player, float duration, int endlessStatusEffectHandle )
69+
void function StimThink( entity player, float duration, int statusEffectHandle_SpeedBoost, int statusEffectHandle_StimVFX )
6770
{
6871
player.EndSignal( "OnDeath" )
6972
player.EndSignal( "OnChangedPlayerClass" )
70-
if ( endlessStatusEffectHandle != 0 )
71-
player.EndSignal( "StopEndlessStim" )
73+
player.EndSignal( "player_embarks_titan" ) // Prevent transferring active Stim ability to Titan.
7274

73-
EmitSoundOnEntityOnlyToPlayer( player, player, "pilot_stimpack_loop_1P" )
74-
EmitSoundOnEntityExceptToPlayer( player, player, "pilot_stimpack_loop_3P" )
75+
if ( duration == USE_TIME_INFINITE )
76+
{
77+
player.EndSignal( "StopEndlessStim" )
78+
// TF|2 stim loop sounds don't actually loop, use TF|1 loop sound.
79+
// 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?
80+
// BUG: It still stops playing sometimes for whatever reason ( Too many sounds? )
81+
EmitSoundOnEntity( player, "Pilot_Stimpack_Loop" )
82+
}
83+
else
84+
{
85+
EmitSoundOnEntityOnlyToPlayer( player, player, "pilot_stimpack_loop_1P" )
86+
EmitSoundOnEntityExceptToPlayer( player, player, "pilot_stimpack_loop_3P" )
87+
}
7588

7689
int attachmentIndex = player.LookupAttachment( "CHESTFOCUS" )
7790

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

8497
OnThreadEnd(
85-
function() : ( player, stimFX, endlessStatusEffectHandle )
98+
function() : ( player, duration, stimFX, statusEffectHandle_SpeedBoost, statusEffectHandle_StimVFX )
8699
{
87100
if ( !IsValid( player ) )
88101
return
89102

90103
if ( IsValid( stimFX ) )
91104
EffectStop( stimFX )
92105

93-
StopSoundOnEntity( player, "pilot_stimpack_loop_1P" )
94-
StopSoundOnEntity( player, "pilot_stimpack_loop_3P" )
95-
96-
if ( endlessStatusEffectHandle != 0 )
97-
StatusEffect_Stop( player, endlessStatusEffectHandle )
106+
if ( duration == USE_TIME_INFINITE )
107+
{
108+
StopSoundOnEntity( player, "Pilot_Stimpack_Loop" )
109+
}
110+
else
111+
{
112+
StopSoundOnEntity( player, "pilot_stimpack_loop_1P" )
113+
StopSoundOnEntity( player, "pilot_stimpack_loop_3P" )
114+
}
115+
116+
if ( statusEffectHandle_SpeedBoost != 0 )
117+
StatusEffect_Stop( player, statusEffectHandle_SpeedBoost )
118+
119+
if ( statusEffectHandle_StimVFX != 0 )
120+
StatusEffect_Stop( player, statusEffectHandle_StimVFX )
98121

99122
player.Signal( "EndStim" )
100123
}
@@ -111,7 +134,7 @@ void function StimThink( entity player, float duration, int endlessStatusEffectH
111134
wait 2.0
112135
}
113136

114-
#else // #if SERVER
137+
#else // CLIENT
115138
void function StimVisualsEnabled( entity ent, int statusEffect, bool actuallyChanged )
116139
{
117140
if ( ent != GetLocalViewPlayer() )
@@ -164,4 +187,4 @@ void function StimScreenFXThink( entity player, int fxHandle, entity cockpit )
164187
}
165188
}
166189

167-
#endif // #else // #if SERVER
190+
#endif

0 commit comments

Comments
 (0)