Deltarune (Chapter 3) script viewer

← back to main script listing

gml_Object_obj_bullet_knight_crescentGenerator_Step_0

(view raw script w/o annotations or w/e)
1
if (init == 0)
2
{
3
    if (type == 0)
4
    {
5
        movementmode = 0;
6
        shootrate = 30;
7
        moverate = shootrate - 5;
8
        posrange = 2;
9
        yposcount = 6;
10
        neverstaystill = 1;
11
        myspeed = -1;
12
        myfrict = -0.5;
13
    }
14
    if (type == 1)
15
    {
16
        movementmode = 1;
17
        shootrate = 20;
18
        moverate = shootrate - 5;
19
        posrange = 2;
20
        yposcount = 6;
21
        myspeed = -1;
22
        myfrict = -0.5;
23
    }
24
    if (type == 2)
25
    {
26
        movementmode = 1;
27
        shootrate = 15;
28
        moverate = shootrate - 5;
29
        posrange = 2;
30
        yposcount = 6;
31
        neverstaystill = 1;
32
        myspeed = -1;
33
        myfrict = -0.35;
34
        if (obj_knight_enemy.damagereduction == 0.04)
35
        {
36
            shootrate = 20;
37
            myfrict = -0.3;
38
        }
39
    }
40
    if (type == 3)
41
    {
42
        diagattack = true;
43
        diagattackrate = 150;
44
        movementmode = 1;
45
        shootrate = 15;
46
        moverate = shootrate - 5;
47
        posrange = 2;
48
        yposcount = 6;
49
        neverstaystill = 1;
50
        myspeed = -1;
51
        myfrict = -0.35;
52
    }
53
    if (type == 4)
54
    {
55
        movementmode = 1;
56
        shootrate = 20;
57
        moverate = shootrate - 5;
58
        posrange = 1;
59
        yposcount = 6;
60
        myspeed = -1;
61
        myfrict = -0.5;
62
        neverstaystill = true;
63
        slowdelaycount = 0;
64
    }
65
    if (box == -1)
66
    {
67
        with (obj_growtangle)
68
            other.box = id;
69
    }
70
    else
71
    {
72
        with (box)
73
        {
74
        }
75
        init = 1;
76
    }
77
}
78
if (init)
79
{
80
    if (con == 0)
81
    {
82
        timer++;
83
        if (timer >= 1)
84
        {
85
            boxheight = box.sprite_height;
86
            con = 1;
87
            timer = 0;
88
            for (var i = 0; i < yposcount; i++)
89
                ypos[i] = (box.y - (boxheight / 2)) + ((boxheight / (yposcount + 1)) * (i + 1));
90
            curpos = round(yposcount / 2) - 1;
91
        }
92
    }
93
    if (con == 1)
94
    {
95
        if (global.turntimer > 50)
96
        {
97
            shoottimer++;
98
            timer++;
99
        }
100
        else if (global.turntimer < 20)
101
        {
102
            instance_destroy();
103
        }
104
        if (diagattack == true)
105
        {
106
            diagtimer++;
107
            if (diagtimer == diagattackrate)
108
            {
109
                diagtimer = 0;
110
                con = 10;
111
                subcon = 0;
112
                shoottimer = 0;
113
                movetimer = 0;
114
                movecon = 0;
115
            }
116
        }
117
        if (shoottimer == (shootrate - 4))
118
            createslash = 1;
119
        if (shoottimer >= shootrate)
120
        {
121
            bulcount++;
122
            var bul = instance_create(x, y + 5, obj_bullet_knightcrescent);
123
            var bul2 = instance_create(x, y - 5, obj_bullet_knightcrescent);
124
            
scr_darksize
scr_darksize

function
scr_darksize()
{ var inst = id; if (argument_count) inst = argument0; inst.image_xscale = 2; inst.image_yscale = 2; }
(bul);
125
            
scr_darksize
scr_darksize

function
scr_darksize()
{ var inst = id; if (argument_count) inst = argument0; inst.image_xscale = 2; inst.image_yscale = 2; }
(bul2);
126
            bul2.image_yscale = -2;
127
            if (movementmode == 0)
128
            {
129
                var timetosplit = 25;
130
                with (bul)
131
                    
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", y, y - 14, timetosplit);
132
                with (bul2)
133
                    
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", y, y + 14, timetosplit);
134
                bul.hspeed = myspeed;
135
                bul.friction = myfrict;
136
                bul2.hspeed = myspeed;
137
                bul2.friction = myfrict;
138
                movecon = 1;
139
            }
140
            if (movementmode == 1)
141
            {
142
                with (bul)
143
                    
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", y, other.ypos[other.curpos] - 12, 30);
144
                with (bul2)
145
                    
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", y, other.ypos[other.curpos] + 12, 30);
146
                bul.hspeed = myspeed;
147
                bul.friction = myfrict;
148
                bul2.hspeed = myspeed;
149
                bul2.friction = myfrict;
150
                if (type == 4 && choose(0, 0, 1) == 1 && slowdelaycount <= 0)
151
                {
152
                    slowdelaycount = 2;
153
                    bul.friction *= 0.25;
154
                    bul2.friction *= 0.25;
155
                    bul.hspeed *= 0.5;
156
                    bul2.hspeed *= 0.5;
157
                    bul.image_yscale = 1;
158
                    bul2.image_yscale = -1;
159
                }
160
                movecon = 1;
161
            }
162
            if (!neverstaystill)
163
                curpos += irandom_range(-posrange, posrange);
164
            else
165
                curpos += (irandom_range(1, posrange) * choose(-1, 1));
166
            if (curpos >= yposcount)
167
                curpos -= 2;
168
            if (curpos < 0)
169
                curpos = -curpos;
170
            shoottimer = 0;
171
            if (slowdelaycount == 1)
172
            {
173
                shoottimer = -shootrate / 2;
174
                slowdelaycount = -1;
175
            }
176
            slowdelaycount--;
177
        }
178
        if (movecon == 1)
179
        {
180
            if (movementmode == 0)
181
            {
182
                
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", y, ypos[curpos], moverate, 2, "out");
183
                movecon = 0;
184
            }
185
            if (movementmode == 1)
186
            {
187
                
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", y, ypos[irandom(yposcount - 1)], moverate, 2, "out");
188
                movecon = 0;
189
            }
190
        }
191
    }
192
    if (con == 10)
193
    {
194
        if (subcon == 0)
195
        {
196
            if (yprevious == y)
197
            {
198
                diagtimer++;
199
                if (diagtimer == 3)
200
                    subcon = 1;
201
            }
202
        }
203
        if (subcon == 1)
204
        {
205
            var desy = irandom(yposcount - 2) + 1;
206
            
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", y, ypos[desy], 10, 2, "out");
207
            subcon = 2;
208
            diagtimer = 0;
209
        }
210
        if (subcon == 2)
211
        {
212
            diagtimer++;
213
            if (diagtimer >= 30)
214
            {
215
                subcon = 3;
216
                diagtimer = 0;
217
                movedown = -1;
218
                if (i_ex(box))
219
                {
220
                    if (y < box.y)
221
                        movedown = 1;
222
                }
223
                var heartmovespeed = obj_heart.wspeed;
224
                framecount = 15;
225
                
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", y, y + (framecount * movedown * heartmovespeed), framecount);
226
                subtimer = 0;
227
            }
228
        }
229
        if (subcon == 3)
230
        {
231
            if (diagtimer == 2)
232
                createslash = 1;
233
            if (diagtimer <= 0)
234
            {
235
                var bul = instance_create(x, y + 5, obj_bullet_knightcrescent);
236
                var bul2 = instance_create(x, y - 5, obj_bullet_knightcrescent);
237
                
scr_darksize
scr_darksize

function
scr_darksize()
{ var inst = id; if (argument_count) inst = argument0; inst.image_xscale = 2; inst.image_yscale = 2; }
(bul);
238
                
scr_darksize
scr_darksize

function
scr_darksize()
{ var inst = id; if (argument_count) inst = argument0; inst.image_xscale = 2; inst.image_yscale = 2; }
(bul2);
239
                bul2.image_yscale = -2;
240
                var timetosplit = 25;
241
                with (bul)
242
                    
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", y, y - 16, timetosplit);
243
                with (bul2)
244
                    
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", y, y + 16, timetosplit);
245
                bul.hspeed = myspeed;
246
                bul.friction = myfrict;
247
                bul2.hspeed = myspeed;
248
                bul2.friction = myfrict;
249
                diagtimer = 3;
250
            }
251
            diagtimer--;
252
            subtimer++;
253
            if (i_ex(box))
254
            {
255
                if ((movedown == 1 && y > ((box.y + (box.sprite_height / 2)) - 30)) || (movedown == -1 && y < ((box.y - (box.sprite_height / 2)) + 30)))
256
                    subtimer = framecount + 1;
257
            }
258
            if (subtimer >= framecount)
259
            {
260
                con = 1;
261
                diagtimer = 0;
262
                subcon = 0;
263
                timer = 0;
264
                subtimer = 0;
265
                shoottimer = -10;
266
                movetimer = 0;
267
            }
268
        }
269
    }
270
}
271
if (createslash)
272
{
273
    var _slash = instance_create(x + 12, y + 18, obj_knight_crescentslash_slashinganimation);
274
    _slash.depth = depth - 20 - _slash.y;
275
    createslash = 0;
276
}