Deltarune (Chapter 3) script viewer

← back to main script listing

gml_Object_obj_sword_tunnel_manager_Step_0

(view raw script w/o annotations or w/e)
1
timer++;
2
finishtimer++;
3
var _xx = camerax() + 320;
4
var _yy = cameray() + 180;
5
if (i_ex(obj_growtangle))
6
{
7
    _xx = obj_growtangle.x;
8
    _yy = obj_growtangle.y;
9
}
10
if (finishtimer == finishtimermax)
11
{
12
    con = 1;
13
    with (obj_sword_tunnel_sword)
14
        con = 1;
15
}
16
if (timer >= rate && con == 0)
17
{
18
    if (tobymode == 0)
19
    {
20
        sword = instance_create(swordx, swordy - 50 - (gapsize / 2), obj_sword_tunnel_sword);
21
        sword.image_angle = 270;
22
        sword.damage = damage;
23
        sword = instance_create(swordx, swordy + 50 + (gapsize / 2), obj_sword_tunnel_sword);
24
        sword.image_angle = 90;
25
        sword.damage = damage;
26
    }
27
    else if (tobymode == 1)
28
    {
29
        tobytimer++;
30
        sword = instance_create(swordx, swordy - 50 - (gapsize / 2), obj_sword_tunnel_sword);
31
        sword.image_angle = 270;
32
        sword._speed += (sin(tobytimer / 6) * 16) + random(1);
33
        sword.damage = damage;
34
        sword = instance_create(swordx, swordy + 50 + (gapsize / 2), obj_sword_tunnel_sword);
35
        sword.image_angle = 90;
36
        sword._speed += (sin(tobytimer / 6) * 16) + random(1);
37
        timer = max(0, sin(tobytimer / 6) * 2);
38
        sword.damage = damage;
39
    }
40
    else if (tobymode == 2)
41
    {
42
        var sx = lengthdir_x(swordxrel, sworddirection + 180);
43
        var sy = lengthdir_y(swordxrel, sworddirection + 180);
44
        var syaddy = lengthdir_y(swordy - obj_growtangle.y, sworddirection + 270);
45
        var syaddx = lengthdir_x(swordy - obj_growtangle.y, sworddirection + 270);
46
        var sgapy = lengthdir_y(gapsize, sworddirection + 270) * 2;
47
        var sgapx = lengthdir_x(gapsize, sworddirection + 270) * 2;
48
        tobytimer++;
49
        sword = instance_create(((_xx + sx) - sgapx) + syaddx, ((_yy + sy) - sgapy) + syaddy, obj_sword_tunnel_sword);
50
        sword.image_angle = sworddirection + 270;
51
        sword.mydirection = sworddirection;
52
        sword.damage = damage;
53
        var speedproportion = lerp(1, 0.8, abs(lengthdir_y(1, sworddirection + 180)));
54
        sword._speed = -8 * speedproportion;
55
        sword._gravity = 2 * speedproportion;
56
        sword.damage = damage;
57
        sword = instance_create(_xx + sx + sgapx + syaddx, _yy + sy + sgapy + syaddy, obj_sword_tunnel_sword);
58
        sword.image_angle = sworddirection + 90;
59
        sword.mydirection = sworddirection;
60
        sword._speed = -8 * speedproportion;
61
        sword._gravity = 2 * speedproportion;
62
        sword.damage = damage;
63
        sworddirection += 4;
64
    }
65
    else if (tobymode == 3)
66
    {
67
        tobytimer++;
68
        if (!tobyvolleymode)
69
        {
70
            verticalchange = abs(sin(tobytimer / 8)) * 5;
71
            gapsize = 34 + (verticalchange * 1.4);
72
        }
73
        var sx = lengthdir_x(swordxrel, sworddirection + 180);
74
        var sy = lengthdir_y(swordxrel, sworddirection + 180);
75
        var syaddy = lengthdir_y(swordy - obj_growtangle.y, sworddirection + 270);
76
        var syaddx = lengthdir_x(swordy - obj_growtangle.y, sworddirection + 270);
77
        var sgapy = lengthdir_y(gapsize, sworddirection + 270) * 2;
78
        var sgapx = lengthdir_x(gapsize, sworddirection + 270) * 2;
79
        tobytimer++;
80
        sword = instance_create(((_xx + sx) - sgapx) + syaddx, ((_yy + sy) - sgapy) + syaddy, obj_sword_tunnel_sword);
81
        sword.image_angle = sworddirection + 270;
82
        sword.mydirection = sworddirection;
83
        sword.damage = damage;
84
        var speedproportion = lerp(1, 0.8, abs(lengthdir_y(1, sworddirection + 180)));
85
        sword._speed = -8 * speedproportion;
86
        sword._gravity = 2 * speedproportion;
87
        sword._gravity = ((2 * speedproportion) - (verticalchange / 15)) * tobyvolleymodeinitspeed;
88
        sword.damage = damage;
89
        sword = instance_create(_xx + sx + sgapx + syaddx, _yy + sy + sgapy + syaddy, obj_sword_tunnel_sword);
90
        sword.image_angle = sworddirection + 90;
91
        sword.mydirection = sworddirection;
92
        sword._speed = -8 * speedproportion;
93
        sword._gravity = 2 * speedproportion;
94
        sword._gravity = ((2 * speedproportion) - (verticalchange / 15)) * tobyvolleymodeinitspeed;
95
        sword.damage = damage;
96
        sworddirection += 8;
97
    }
98
    if (movedirection == "up")
99
        swordy -= verticalchange;
100
    if (movedirection == "down")
101
        swordy += verticalchange;
102
    swordcount++;
103
    if ((setcount == swordcount && (movedirection == "down" || movedirection == "up")) || (waitsetcount == swordcount && movedirection == "none"))
104
    {
105
        swordcount = 0;
106
        setcount = choose(2, 3, 4);
107
        waitsetcount = choose(1, 2, 3);
108
        if (tobymode == 2)
109
        {
110
            setcount = choose(4, 6, 8);
111
            waitsetcount = choose(2, 4, 6);
112
            if (tobyvolleymode)
113
            {
114
                setcount = choose(6, 10, 12);
115
                waitsetcount = choose(6, 8, 12);
116
            }
117
        }
118
        if (movedirection == "none")
119
            movedirection = choose("up", "down");
120
        else
121
            movedirection = "none";
122
        if (movedirection == "up" && swordy < (obj_growtangle.y - 20))
123
            movedirection = "down";
124
        if (movedirection == "down" && swordy > (obj_growtangle.y + 20))
125
            movedirection = "up";
126
    }
127
}
128
if (timer >= rate && stopsfxtimer < 3)
129
{
130
    if (con == 1)
131
        stopsfxtimer++;
132
    snd_play_x(snd_heavy_passing, 0.3, 1.2);
133
    timer = 0;
134
}
135
if (swordcount >= maxswords)
136
    instance_destroy();