The Dink Network

Walking sound effect

August 21st 2014, 11:58 AM
custom_skull.gif
Skull
Peasant He/Him Finland bloop
A Disembodied Sod 
I was wondering, is there any way to set a certain sound effect for when Dink is moving, and would stop when Dink stands still?
August 21st 2014, 12:42 PM
spike.gif
Sure, you can. You could create a loop that checks Dink's X and Y and plays the sound when it changes, for example, or checks if Dink is going through one of his walking sequences. That would be quite a cool feature for a horror dmod, actually.

Crude example:
loop:
int &crap = sp_pseq(1,-1)
//^ not sure whether you should check sp_seq, or sp_pseq. Both probably work.
&crap / 10
&crap * 10
//^ should remove the last digit, so that instead of 72 or something, the result we get will be 70
if (&crap == 70)
&dinkysoundglobal = playsound(3,22050,0,1,0)

if (&crap != 70)
{
//if the sound is currently playing, let's kill it abruptly
if (&dinkysoundglobal != 0)
{
sp_active(&dinkysoundglobal,0)
&dinkysoundglobal = 0
}
}

wait(100)
goto loop

August 21st 2014, 01:58 PM
custom_skull.gif
Skull
Peasant He/Him Finland bloop
A Disembodied Sod 
It works fine otherwise, but once I stop moving Dink will randomly disappear and the game freezes.

Removing sp_active(&dinkysoundglobal,0) appears to fix this, though.
August 21st 2014, 02:08 PM
spike.gif
That's not good. Looking at the DinkC reference, the command to kill a sound is actually sound_set_kill(&dinkysoundglobal)... sp_active probably ends up killing something else each time (like Dink's sprite).
August 21st 2014, 03:11 PM
custom_skull.gif
Skull
Peasant He/Him Finland bloop
A Disembodied Sod 
Works great now! Thanks!