Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_climb_enemyspawner_Step_0

(view raw script w/o annotations or w/e)
1
event_inherited();
2
if (init == 0)
3
{
4
    if (r_spawntimer != -1)
5
        spawntimer = r_spawntimer;
6
    if (r_spawnrate != -1)
7
        spawnrate = r_spawnrate;
8
    if (r_spawncap != -1)
9
        spawncap = r_spawncap;
10
    if (r_spawntype != -1)
11
        spawntype = r_spawntype;
12
    if (r_spawndir != -1)
13
        spawndir = r_spawndir;
14
    if (r_rotspawn != -1)
15
        rotspawn = r_rotspawn;
16
    init = 1;
17
}
18
var camy = cameray();
19
if (y < (camy - lenience) || y > (camy + 480 + 200))
20
    exit;
21
spawntimer++;
22
if (spawntimer >= spawnrate)
23
{
24
    var spawnobj = 1341;
25
    if (spawntype == 0 || spawntype == 1 || spawntype == 2)
26
        spawnobj = 990;
27
    var moveenemy = false;
28
    var makeenemy = false;
29
    if (instance_number(spawnobj) < spawncap)
30
        makeenemy = true;
31
    var xx = floor((x + 20) / 40) * 40;
32
    var yy = floor(y / 40) * 40;
33
    if (rotspawn)
34
    {
35
        if (rotspawn == 1)
36
            spawndir++;
37
        if (rotspawn == 2)
38
            spawndir--;
39
        if (spawndir < 0)
40
            spawndir = 3;
41
        if (spawndir > 3)
42
            spawndir = 0;
43
        for (var i = 0; i < 4; i++)
44
        {
45
            if (makeenemy)
46
            {
47
                if (!moveenemy)
48
                {
49
                    var spawndircheck = spawndir + i;
50
                    if (spawndircheck > 3)
51
                        spawndircheck = 0;
52
                    if (spawndircheck < 0)
53
                        spawndircheck = 3;
54
                    px = 0;
55
                    py = 0;
56
                    if (spawndircheck == 0)
57
                        py = 40;
58
                    if (spawndircheck == 1)
59
                        px = 40;
60
                    if (spawndircheck == 2)
61
                        py = -40;
62
                    if (spawndircheck == 3)
63
                        px = -40;
64
                    if (place_meeting(xx + px, yy + py, obj_climb_climbable) || place_meeting(xx + px, yy + py, obj_climb_pathturner))
65
                    {
66
                        if (!place_meeting(xx + px, yy + py, obj_climb_enemy))
67
                        {
68
                            spawndir = spawndircheck;
69
                            moveenemy = true;
70
                            makeenemy = true;
71
                        }
72
                    }
73
                }
74
            }
75
        }
76
    }
77
    var px = 0;
78
    var py = 0;
79
    if (spawndir == 0)
80
        py = 40;
81
    else if (spawndir == 1)
82
        px = 40;
83
    else if (spawndir == 2)
84
        py = -40;
85
    else if (spawndir == 3)
86
        px = -40;
87
    if (!moveenemy)
88
    {
89
        if ((place_meeting(xx + px, yy + py, obj_climb_climbable) || place_meeting(xx + px, yy + py, obj_climb_pathturner)) && !place_meeting(xx + px, yy + py, obj_climb_enemy))
90
            moveenemy = true;
91
        else
92
            makeenemy = false;
93
    }
94
    if (makeenemy)
95
    {
96
        var offset = 0;
97
        if (i_ex(obj_rotating_tower_controller_new))
98
            offset = -40;
99
        var enemy = instance_create(xx, yy, spawnobj);
100
        enemy.image_alpha = 0;
101
        scr_lerp_var_instance(enemy, "image_alpha", 0, 1, 15, 1, "out");
102
        with (enemy)
103
        {
104
            ignoreblocked = true;
105
            if (spawnobj == 990)
106
            {
107
                if (other.spawntype == 0)
108
                {
109
                }
110
                if (other.spawntype == 1)
111
                {
112
                    movetype = 1;
113
                    waittime = 15;
114
                    movetime = 15;
115
                }
116
                if (other.spawntype == 2)
117
                {
118
                    movetype = 2;
119
                    waittime = 10;
120
                    movetime = 15;
121
                }
122
                if (!i_ex(obj_rotating_tower_controller_new))
123
                {
124
                    
scr_lerpvar
scr_lerpvar

function
scr_lerpvar()
{ if (argument_count < 6) ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3]);
else ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3], argument[4], argument[5]);
return ___lerpvar; } function scr_lerpvar_respect() { if (argument_count < 6) ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3]);
else ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3], argument[4], argument[5]);
___lerpvar.respectglobalinteract = true; return ___lerpvar; }
("x", xx + offset, xx + px + offset, 8, 2, "in");
125
                    
scr_lerpvar
scr_lerpvar

function
scr_lerpvar()
{ if (argument_count < 6) ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3]);
else ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3], argument[4], argument[5]);
return ___lerpvar; } function scr_lerpvar_respect() { if (argument_count < 6) ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3]);
else ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3], argument[4], argument[5]);
___lerpvar.respectglobalinteract = true; return ___lerpvar; }
("y", yy, yy + py, 8, 2, "in");
126
                }
127
                dir = other.spawndir;
128
                angle = 360 + (other.spawndir * -90);
129
                waittimer = -10;
130
            }
131
        }
132
        spawntimer = 0;
133
    }
134
    else
135
    {
136
        spawntimer = spawnrate - 1;
137
    }
138
    if (updcap != -1)
139
    {
140
        spawncap = updcap;
141
        updcap = -1;
142
    }
143
    if (updrate != -1)
144
    {
145
        spawnrate = updrate;
146
        updrate = -1;
147
    }
148
}