Dashmode Sound (answerd)

The RTG Guy

An Ink blob
I am trying to make Sonic give that boost jet sound when he is in dashmode like in the boost games. Here is the code:
Dashmode Sound:
addHook("PlayerThink", function(player)
    if (player and player.mo and player.mo.valid)
    and    player.dashmode >= 3*TICRATE
    and not S_SoundPlaying(player.mo, sfx_boost3)
        S_StartSound(player.mo, sfx_boost3)
    elseif not player.dashmode >= 3*TICRATE
    and S_SoundPlaying(player.mo, sfx_boost3)
        S_StopSoundByID(player.mo, sfx_boost3)
    end
end)

Whenever Sonic stops, he sound is still going, and when in dashmode, the sound repeats itself.
Any suggestions to help with that?
 
Whenever Sonic stops, he sound is still going...
Separate the player validity check from the Dash Mode check. I.E. have the (player and player.mo and player.mo.valid) part be in a separate if statement from player.dashmode >= 3*TICRATE and not S_SoundPlaying(player.mo, sfx_boost3).
And it'd be a good idea to encase the second player.dashmode >= 3*TICRATE (in the elseif statement) in parentheses. Or replace it with < 3*TICRATE and remove the not.
...and when in dashmode, the sound repeats itself.
I'm not sure which "jet booster sound" you're talking about, but I have a hunch, and... isn't it meant to repeat for as long as Sonic is boosting?
If you don't want it to, though, all you'd have to do is play the sound once when player.dashmode == 3*TICRATE (Dash Mode activates).

[Additional tip]
It would also be a good idea to limit your code to run with just Sonic (via checking player.mo.skin), as otherwise it'd trigger for any character that uses the dashmode variable (or the Dash/Boost Mode ability itself - notably, the base game's Metal Sonic).
 

Who is viewing this thread (Total: 0, Members: 0, Guests: 0)

Back
Top