Deltarune (Chapter 5) script viewer

← back to main script listing

gml_Object_obj_ch5_LW20_zorgon_Create_0

(view raw script w/o annotations or w/e)
1
image_speed = 0;
2
_input_enabled = false;
3
_sprite_left = 3122;
4
_sprite_right = 99;
5
_sprite_down = 2254;
6
_sprite_up = 4343;
7
directional_sprites = [2254, 99, 4343, 3122];
8
press_l = -1;
9
press_r = -1;
10
press_u = -1;
11
press_d = -1;
12
pressdir = 0;
13
px = 0;
14
py = 0;
15
wspeed = 0.2;
16
walk = 0;
17
walkanim = 0;
18
walkbuffer = 0;
19
walktimer = 0;
20
fun = 0;
21
climbing = 0;
22
_weird_mode = false;
23
runmove = 0;
24
fullspeed = false;
25
_parent = -4;
26
27
init = function(arg0)
28
{
29
    _parent = arg0;
30
};
31
32
enable_input = function()
33
{
34
    _input_enabled = true;
35
};
36
37
disable_input = function()
38
{
39
    _input_enabled = false;
40
};
41
42
pause = function()
43
{
44
    disable_input();
45
    image_index = 0;
46
};
47
48
resume = function()
49
{
50
    enable_input();
51
};
52
53
is_paused = function()
54
{
55
    return !_input_enabled;
56
};
57
58
reset_input = function()
59
{
60
    press_l = -1;
61
    press_r = -1;
62
    press_u = -1;
63
    press_d = -1;
64
};
65
66
update_facing = function()
67
{
68
    reset_input();
69
    if (left_h())
70
        press_l = 1;
71
    if (right_h())
72
        press_r = 1;
73
    if (up_h())
74
        press_u = 1;
75
    if (down_h())
76
        press_d = 1;
77
    pressdir = -1;
78
    px = 0;
79
    py = 0;
80
    if (press_r == 1)
81
    {
82
        px = wspeed;
83
        pressdir = 1;
84
    }
85
    if (press_l == 1)
86
    {
87
        px = -wspeed;
88
        pressdir = 3;
89
    }
90
    if (press_d == 1)
91
    {
92
        py = wspeed;
93
        pressdir = 0;
94
    }
95
    if (press_u == 1)
96
    {
97
        py = -wspeed;
98
        pressdir = 2;
99
    }
100
    if (pressdir != -1)
101
        sprite_index = directional_sprites[pressdir];
102
};
103
104
collision_check = function()
105
{
106
    nopress = 0;
107
    xmeet = 0;
108
    ymeet = 0;
109
    xymeet = 0;
110
    run = 0;
111
    nowx = x;
112
    nowy = y;
113
    if (press_d == 0 && press_l == 0 && press_u == 0 && press_r == 0)
114
        nopress = 1;
115
    if (place_meeting(x + px, y + py, obj_solidblock))
116
        xymeet = 1;
117
    if (place_meeting(x + px, y, obj_solidblock))
118
    {
119
        if (place_meeting(x + px, y, obj_solidblock))
120
        {
121
            for (g = wspeed; g > 0; g -= 1)
122
            {
123
                mvd = 0;
124
                if (press_d == 0 && !place_meeting(x + px, y - g, obj_solidblock))
125
                {
126
                    y -= g;
127
                    py = 0;
128
                    break;
129
                    mvd = 1;
130
                }
131
                if (press_u == 0 && mvd == 0 && !place_meeting(x + px, y + g, obj_solidblock))
132
                {
133
                    y += g;
134
                    py = 0;
135
                    break;
136
                }
137
            }
138
        }
139
        xmeet = 1;
140
        bkx = 0;
141
        if (px > 0)
142
        {
143
            for (i = px; i >= 0; i -= 1)
144
            {
145
                if (!place_meeting(x + i, y, obj_solidblock))
146
                {
147
                    px = i;
148
                    bkx = 1;
149
                    break;
150
                }
151
            }
152
        }
153
        if (px < 0)
154
        {
155
            for (i = px; i <= 0; i += 1)
156
            {
157
                if (!place_meeting(x + i, y, obj_solidblock))
158
                {
159
                    px = i;
160
                    bkx = 1;
161
                    break;
162
                }
163
            }
164
        }
165
        if (bkx == 0)
166
            px = 0;
167
    }
168
    if (place_meeting(x, y + py, obj_solidblock))
169
    {
170
        ymeet = 1;
171
        bky = 0;
172
        if (place_meeting(x, y + py, obj_solidblock))
173
        {
174
            for (g = wspeed; g > 0; g -= 1)
175
            {
176
                mvd = 0;
177
                if (press_r == 0 && !place_meeting(x - g, y + py, obj_solidblock))
178
                {
179
                    x -= g;
180
                    px = 0;
181
                    break;
182
                    mvd = 1;
183
                }
184
                if (mvd == 0 && press_l == 0 && !place_meeting(x + g, y + py, obj_solidblock))
185
                {
186
                    x += g;
187
                    px = 0;
188
                    break;
189
                }
190
            }
191
        }
192
        if (py > 0)
193
        {
194
            for (i = py; i >= 0; i -= 1)
195
            {
196
                if (!place_meeting(x, y + i, obj_solidblock))
197
                {
198
                    py = i;
199
                    bky = 1;
200
                    break;
201
                }
202
            }
203
        }
204
        if (py < 0)
205
        {
206
            for (i = py; i <= 0; i += 1)
207
            {
208
                if (!place_meeting(x, y + i, obj_solidblock))
209
                {
210
                    py = i;
211
                    bky = 1;
212
                    break;
213
                }
214
            }
215
        }
216
        if (bky == 0)
217
            py = 0;
218
    }
219
    if (place_meeting(x + px, y + py, obj_solidblock))
220
    {
221
        xymeet = 1;
222
        bkxy = 0;
223
        i = px;
224
        j = py;
225
        while (j != 0 || i != 0)
226
        {
227
            if (!place_meeting(x + i, y + j, obj_solidblock))
228
            {
229
                px = i;
230
                py = j;
231
                bkxy = 1;
232
                break;
233
            }
234
            if (abs(j) >= 1)
235
            {
236
                if (j > 0)
237
                    j -= 1;
238
                if (j < 0)
239
                    j += 1;
240
            }
241
            else
242
            {
243
                j = 0;
244
            }
245
            if (abs(i) >= 1)
246
            {
247
                if (i > 0)
248
                    i -= 1;
249
                if (i < 0)
250
                    i += 1;
251
            }
252
            else
253
            {
254
                i = 0;
255
            }
256
        }
257
        if (bkxy == 0)
258
        {
259
            px = 0;
260
            py = 0;
261
        }
262
    }
263
};
264
265
update_walk = function()
266
{
267
    if (walkbuffer > 3 && fun == 0)
268
    {
269
        walktimer += 1.5;
270
        if (runmove == 1)
271
            walktimer += 1.5;
272
        if (walktimer >= 40)
273
            walktimer -= 40;
274
        if (walktimer < 10)
275
            image_index = 0;
276
        if (walktimer >= 10)
277
            image_index = 1;
278
        if (walktimer >= 20)
279
            image_index = 2;
280
        if (walktimer >= 30)
281
            image_index = 3;
282
    }
283
    if (walkbuffer <= 0 && fun == 0 && climbing == 0)
284
    {
285
        if (walktimer < 10)
286
            walktimer = 9.5;
287
        if (walktimer >= 10 && walktimer < 20)
288
            walktimer = 19.5;
289
        if (walktimer >= 20 && walktimer < 30)
290
            walktimer = 29.5;
291
        if (walktimer >= 30)
292
            walktimer = 39.5;
293
        image_index = 0;
294
    }
295
    walkbuffer -= 0.75;
296
};
297
298
is_full_speed = function()
299
{
300
    return wspeed >= 3.5;
301
};
302
303
draw_func = -1;
304
scr_addtoselfshadows(true, id, true, false);