Deltarune (Chapter 3) script viewer

← back to main script listing

gml_Object_obj_snd_complex_Step_0

(view raw script w/o annotations or w/e)
1
mastertime++;
2
timer++;
3
var count = array_length(snd);
4
for (var i = 0; i < count; i++)
5
{
6
    if (looprate[i] != -1)
7
    {
8
        if (((timer - delay[i]) % looprate[i]) == 0)
9
        {
10
            if (snd[i] != -1)
11
            {
12
                if (killsnd[i])
13
                {
14
                    if (audio_exists(play[i]))
15
                        snd_stop(play[i]);
16
                }
17
                play[i] = snd_play(snd[i], volume[i], pitch[i]);
18
            }
19
        }
20
    }
21
    else if (timer == (1 + delay[i]))
22
    {
23
        if (snd[i] != -1)
24
            play[i] = snd_play(snd[i], volume[i], pitch[i]);
25
    }
26
}
27
if (lifetime)
28
{
29
    if (mastertime >= lifetime)
30
        instance_destroy();
31
}
32
var lastdelay = 0;
33
var anyloop = 0;
34
var nothingplaying = true;
35
for (var i = 0; i < count; i++)
36
{
37
    if (snd[i] != -1)
38
        nothingplaying = false;
39
    lastdelay += delay[i];
40
    if (looprate != -1)
41
        anyloop = true;
42
}
43
if (!anyloop)
44
{
45
    if (timer > (lastdelay + 10))
46
    {
47
        var killme = true;
48
        for (var i = 0; i < count; i++)
49
        {
50
            if (audio_is_playing(play[i]))
51
                killme = false;
52
        }
53
        if (killme)
54
        {
55
            debug_message("obj_snd_complex: Sounds are done playin'. Die time.");
56
            instance_destroy();
57
        }
58
    }
59
}
60
if (nothingplaying)
61
{
62
    debug_message("obj_snd_complex: Nothing was playing in this complex sound");
63
    instance_destroy();
64
}