Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_homealone_heart_Step_0

(view raw script w/o annotations or w/e)
1
wallcheck = 0;
2
nowx = x;
3
nowy = y;
4
if (press_d == 0 && press_l == 0 && press_u == 0 && press_r == 0)
5
    nopress = 1;
6
press_l = 0;
7
press_r = 0;
8
press_d = 0;
9
press_u = 0;
10
bkx = 0;
11
bky = 0;
12
bkxy = 0;
13
if (!roomenterfreezeend)
14
{
15
    if (global.interact == 3)
16
    {
17
        if (global.flag[21 door_freeze_timer] > 0)
18
        {
19
            global.flag[21 door_freeze_timer]--;
20
        }
21
        else
22
        {
23
            roomenterfreezeend = 1;
24
            global.interact = 0;
25
            global.flag[21 door_freeze_timer] = -10;
26
        }
27
    }
28
}
29
if (global.interact == 0 && freeze == 0)
30
{
31
    if (run == 0)
32
        wspeed = bwspeed;
33
    if (left_h())
34
        press_l = 1;
35
    if (right_h())
36
        press_r = 1;
37
    if (up_h())
38
        press_u = 1;
39
    if (down_h())
40
        press_d = 1;
41
    px = 0;
42
    py = 0;
43
    pressdir = -1;
44
    if (press_r == 1)
45
    {
46
        px = wspeed;
47
        pressdir = 1;
48
    }
49
    if (press_l == 1)
50
    {
51
        px = -wspeed;
52
        pressdir = 3;
53
    }
54
    if (press_d == 1)
55
    {
56
        py = wspeed;
57
        pressdir = 0;
58
    }
59
    if (press_u == 1)
60
    {
61
        py = -wspeed;
62
        pressdir = 2;
63
    }
64
    if (nopress == 1 && pressdir != -1)
65
        global.facing = pressdir;
66
    if (global.facing == 2)
67
    {
68
        if (press_d == 1)
69
            global.facing = 0;
70
        if (press_u == 0 && pressdir != -1)
71
            global.facing = pressdir;
72
    }
73
    if (global.facing == 0)
74
    {
75
        if (press_u == 1)
76
            global.facing = 2;
77
        if (press_d == 0 && pressdir != -1)
78
            global.facing = pressdir;
79
    }
80
    if (global.facing == 3)
81
    {
82
        if (press_r == 1)
83
            global.facing = 1;
84
        if (press_l == 0 && pressdir != -1)
85
            global.facing = pressdir;
86
    }
87
    if (global.facing == 1)
88
    {
89
        if (press_l == 1)
90
            global.facing = 3;
91
        if (press_r == 0 && pressdir != -1)
92
            global.facing = pressdir;
93
    }
94
    nopress = 0;
95
    xmeet = 0;
96
    ymeet = 0;
97
    xymeet = 0;
98
    var slow_down = false;
99
    var type = 0;
100
    var wall_check = false;
101
    var pushable = collision_rectangle(x + px, y, x + sprite_width + -1 + px, (y + sprite_height) - 5, obj_homealone_pushable, false, true);
102
    if (pushable != -4)
103
    {
104
        type = 1;
105
        px = (px * pushable.movespeed) / 8;
106
        var _px = px;
107
        with (pushable)
108
        {
109
            if (pushable.object_index == obj_train_snowball)
110
                event_user(0);
111
            if (place_meeting(x + (_px * 0.5), y, obj_solidblock))
112
            {
113
                can_push = false;
114
            }
115
            else
116
            {
117
                can_push = true;
118
                x += (_px * 0.5);
119
                if (_px != 0)
120
                    shake = true;
121
            }
122
            wall_check = !can_push;
123
            slow_down = can_push;
124
        }
125
    }
126
    if (collision_rectangle(x, y, x + sprite_width + px, (y + sprite_height) - 5, obj_homealone_pushable, false, true))
127
    {
128
        var stopped = false;
129
        if (wall_check)
130
        {
131
            for (i = px; i >= 0; i -= 1)
132
            {
133
                if (!place_meeting(x + i, y, obj_homealone_pushable))
134
                {
135
                    stopped = true;
136
                    px = i;
137
                    break;
138
                }
139
            }
140
            if (!stopped)
141
                px = 0;
142
        }
143
    }
144
    if (collision_rectangle(x + px, y, x, (y + sprite_height) - 5, obj_homealone_pushable, false, true))
145
    {
146
        var stopped = false;
147
        if (wall_check)
148
        {
149
            for (i = px; i <= 0; i += 1)
150
            {
151
                if (!place_meeting(x + i, y, obj_homealone_pushable))
152
                {
153
                    stopped = true;
154
                    px = i;
155
                    break;
156
                }
157
            }
158
            if (!stopped && px < 0)
159
                px = 0;
160
        }
161
    }
162
    if (collision_rectangle(x, y, (x + sprite_width) - 1, y + py, obj_homealone_pushable, false, true))
163
    {
164
        if (py <= 0)
165
        {
166
            var stopped = false;
167
            for (i = py; i <= 0; i += 1)
168
            {
169
                if (!place_meeting(x, y + i, obj_homealone_pushable))
170
                {
171
                    stopped = true;
172
                    py = i;
173
                    break;
174
                }
175
            }
176
            if (!stopped)
177
                py = 0;
178
        }
179
    }
180
    if (collision_rectangle(x, y, (x + sprite_width) - 1, y + sprite_height + py, obj_homealone_pushable, false, true))
181
    {
182
        if (py >= 0)
183
        {
184
            var stopped = false;
185
            for (i = py; i >= 0; i -= 1)
186
            {
187
                if (!place_meeting(x, y + i, obj_homealone_pushable))
188
                {
189
                    stopped = true;
190
                    py = i;
191
                    break;
192
                }
193
            }
194
            if (!stopped)
195
                py = 0;
196
        }
197
    }
198
    var airflow_area = collision_rectangle(x, y, x + sprite_width, (y + sprite_height) - 1, obj_homealone_vent_airflow, false, true);
199
    if (airflow_area != -4)
200
    {
201
        if (airflow_area.image_index == 0)
202
        {
203
            var bottom_area = collision_rectangle(x, y + 8, x + sprite_width, y + sprite_height + 4, obj_homealone_vent_airflow, false, true);
204
            if (bottom_area != -4 && bottom_area.image_index == 2)
205
                py -= 4;
206
            px += 4;
207
        }
208
        if (airflow_area.image_index == 1)
209
        {
210
            var top_area = collision_rectangle(x, y - 4, x + sprite_width, y + 4, obj_homealone_vent_airflow, false, true);
211
            if (top_area != -4 && top_area.image_index == 3)
212
                py += 4;
213
            px -= 4;
214
        }
215
        if (airflow_area.image_index == 2)
216
            py -= 4;
217
        if (airflow_area.image_index == 3)
218
            py += 4;
219
    }
220
    if (place_meeting(x + px, y + py, obj_homealone_solid))
221
        xymeet = 1;
222
    if (place_meeting(x + px, y, obj_homealone_solid))
223
    {
224
        if (place_meeting(x + px, y, obj_homealone_solid))
225
        {
226
            for (g = wspeed; g > 0; g -= 1)
227
            {
228
                mvd = 0;
229
                if (press_d == 0 && !place_meeting(x + px, y - g, obj_homealone_solid))
230
                {
231
                    y -= g;
232
                    py = 0;
233
                    break;
234
                    mvd = 1;
235
                }
236
                if (press_u == 0 && mvd == 0 && !place_meeting(x + px, y + g, obj_homealone_solid))
237
                {
238
                    y += g;
239
                    py = 0;
240
                    break;
241
                }
242
            }
243
        }
244
        xmeet = 1;
245
        bkx = 0;
246
        if (px > 0)
247
        {
248
            for (i = px; i >= 0; i -= 1)
249
            {
250
                if (!place_meeting(x + i, y, obj_homealone_solid))
251
                {
252
                    px = i;
253
                    bkx = 1;
254
                    break;
255
                }
256
            }
257
        }
258
        if (px < 0)
259
        {
260
            for (i = px; i <= 0; i += 1)
261
            {
262
                if (!place_meeting(x + i, y, obj_homealone_solid))
263
                {
264
                    px = i;
265
                    bkx = 1;
266
                    break;
267
                }
268
            }
269
        }
270
        if (bkx == 0)
271
            px = 0;
272
    }
273
    if (place_meeting(x, y + py, obj_homealone_solid))
274
    {
275
        ymeet = 1;
276
        bky = 0;
277
        if (place_meeting(x, y + py, obj_homealone_solid))
278
        {
279
            for (g = wspeed; g > 0; g -= 1)
280
            {
281
                mvd = 0;
282
                if (press_r == 0 && !place_meeting(x - g, y + py, obj_homealone_solid))
283
                {
284
                    x -= g;
285
                    px = 0;
286
                    break;
287
                    mvd = 1;
288
                }
289
                if (mvd == 0 && press_l == 0 && !place_meeting(x + g, y + py, obj_homealone_solid))
290
                {
291
                    x += g;
292
                    px = 0;
293
                    break;
294
                }
295
            }
296
        }
297
        if (py > 0)
298
        {
299
            for (i = py; i >= 0; i -= 1)
300
            {
301
                if (!place_meeting(x, y + i, obj_homealone_solid))
302
                {
303
                    py = i;
304
                    bky = 1;
305
                    break;
306
                }
307
            }
308
        }
309
        if (py < 0)
310
        {
311
            for (i = py; i <= 0; i += 1)
312
            {
313
                if (!place_meeting(x, y + i, obj_homealone_solid))
314
                {
315
                    py = i;
316
                    bky = 1;
317
                    break;
318
                }
319
            }
320
        }
321
        if (bky == 0)
322
            py = 0;
323
    }
324
    if (place_meeting(x + px, y + py, obj_homealone_solid))
325
    {
326
        xymeet = 1;
327
        bkxy = 0;
328
        i = px;
329
        j = py;
330
        while (j != 0 || i != 0)
331
        {
332
            if (!place_meeting(x + i, y + j, obj_homealone_solid))
333
            {
334
                px = i;
335
                py = j;
336
                bkxy = 1;
337
                break;
338
            }
339
            if (abs(j) >= 1)
340
            {
341
                if (j > 0)
342
                    j -= 1;
343
                if (j < 0)
344
                    j += 1;
345
            }
346
            else
347
            {
348
                j = 0;
349
            }
350
            if (abs(i) >= 1)
351
            {
352
                if (i > 0)
353
                    i -= 1;
354
                if (i < 0)
355
                    i += 1;
356
            }
357
            else
358
            {
359
                i = 0;
360
            }
361
        }
362
        if (bkxy == 0)
363
        {
364
            px = 0;
365
            py = 0;
366
        }
367
    }
368
    runmove = 0;
369
    if (run == 1 && xmeet == 0 && ymeet == 0 && xymeet == 0)
370
    {
371
        if (abs(px) > 0 || abs(py) > 0)
372
        {
373
            runmove = 1;
374
            runtimer += 1;
375
            runcounter += 1;
376
        }
377
        else
378
        {
379
            runtimer = 0;
380
        }
381
    }
382
    else
383
    {
384
        runtimer = 0;
385
    }
386
    px = slow_down ? (px * 0.5) : px;
387
    if (angel_mode)
388
    {
389
        px *= 0.1;
390
        py = 0;
391
    }
392
    x += px;
393
    y += py;
394
}
395
if (fun == 0)
396
{
397
    walk = 0;
398
    if (x != nowx && nopress == 0)
399
        walk = 1;
400
    if (y != nowy && nopress == 0)
401
        walk = 1;
402
    if (angel_mode)
403
        shake = false;
404
    if (walk == 1)
405
    {
406
        walkbuffer = 6;
407
        if (angel_mode)
408
            shake = true;
409
    }
410
    if (walkbuffer > 3 && fun == 0)
411
    {
412
        walktimer += 1.5;
413
        if (runmove == 1 || (run == 1 && climbing == 1))
414
            walktimer += 1.5;
415
        if (climbing == 1)
416
        {
417
            with (obj_rotating_tower_caterpillar)
418
                index += 0.15;
419
        }
420
        if (walktimer >= 40)
421
            walktimer -= 40;
422
        if (walktimer < 10)
423
            image_index = 0;
424
        if (walktimer >= 10)
425
            image_index = 1;
426
        if (walktimer >= 20)
427
            image_index = 2;
428
        if (walktimer >= 30)
429
            image_index = 3;
430
    }
431
    if (walkbuffer <= 0 && fun == 0 && climbing == 0)
432
    {
433
        if (walktimer < 10)
434
            walktimer = 9.5;
435
        if (walktimer >= 10 && walktimer < 20)
436
            walktimer = 19.5;
437
        if (walktimer >= 20 && walktimer < 30)
438
            walktimer = 29.5;
439
        if (walktimer >= 30)
440
            walktimer = 39.5;
441
        image_index = 0;
442
    }
443
    walkbuffer -= 0.75;
444
}
445
if (onebuffer < 0)
446
{
447
    if (global.interact == 0)
448
    {
449
        if (!interacted)
450
        {
451
            thisinteract = 0;
452
            d = global.darkzone + 1;
453
            var right_check = x + sprite_width + 1;
454
            var left_check = x - (1 * d);
455
            if (global.facing == 1)
456
            {
457
                if (collision_rectangle((x + sprite_width) - 1, y, x + sprite_width + 1, (y + sprite_height) - 5, obj_homealone_interactable, false, true))
458
                    thisinteract = 1;
459
            }
460
            if (collision_rectangle(x, y, (x + sprite_width) - 1, (y + sprite_height) - 5, obj_homealone_pushable, false, true))
461
                thisinteract = 2;
462
            if (thisinteract > 0)
463
            {
464
                if (thisinteract == 1)
465
                    interactedobject = collision_rectangle((x + sprite_width) - 1, y, x + sprite_width + 1, (y + sprite_height) - 5, obj_homealone_interactable, false, true);
466
                if (thisinteract == 2)
467
                    interactedobject = collision_rectangle(x, y, (x + sprite_width) - 1, (y + sprite_height) - 5, obj_homealone_pushable, false, true);
468
                if (interactedobject != -4)
469
                {
470
                    if (thisinteract == 1)
471
                    {
472
                        interacted = true;
473
                        with (interactedobject)
474
                            interact_event = true;
475
                    }
476
                    if (thisinteract == 2)
477
                    {
478
                        var _px = px;
479
                        with (interactedobject)
480
                        {
481
                            if (can_push && _px != 0)
482
                            {
483
                                shake = true;
484
                                x += _px;
485
                            }
486
                        }
487
                    }
488
                }
489
            }
490
            thisinteract = 0;
491
            if (global.facing == 3)
492
            {
493
                if (collision_rectangle(x, y, left_check, (y + sprite_height) - 5, obj_homealone_interactable, false, true))
494
                    thisinteract = 1;
495
            }
496
            if (thisinteract > 0)
497
            {
498
                if (thisinteract == 1)
499
                    interactedobject = collision_rectangle(x, y, left_check, (y + sprite_height) - 5, obj_homealone_interactable, false, true);
500
                if (interactedobject != -4)
501
                {
502
                    if (thisinteract == 1)
503
                    {
504
                        interacted = true;
505
                        with (interactedobject)
506
                            interact_event = true;
507
                    }
508
                }
509
            }
510
            thisinteract = 0;
511
            if (global.facing == 0)
512
            {
513
                if (collision_rectangle(x + (4 * d), y + (1 * d), (x + sprite_width) - (4 * d), y + (sprite_height * d), obj_homealone_interactable, false, true))
514
                    thisinteract = 1;
515
            }
516
            if (thisinteract > 0)
517
            {
518
                if (thisinteract == 1)
519
                    interactedobject = collision_rectangle(x + (4 * d), y + (1 * d), (x + sprite_width) - (4 * d), y + (sprite_height * d), obj_homealone_interactable, false, true);
520
                if (thisinteract == 1)
521
                {
522
                    interacted = true;
523
                    with (interactedobject)
524
                        interact_event = true;
525
                }
526
            }
527
            thisinteract = 0;
528
            if (global.facing == 2)
529
            {
530
                if (collision_rectangle(x, y, (x + sprite_width) - 1, y + py, obj_homealone_interactable, false, true))
531
                    thisinteract = 1;
532
                if (collision_rectangle(x + 3, y, (x + sprite_width) - (5 * d), y - (5 * d), obj_homealone_vent, false, true))
533
                    thisinteract = 2;
534
            }
535
            if (thisinteract > 0)
536
            {
537
                if (thisinteract == 1)
538
                    interactedobject = collision_rectangle(x, y, (x + sprite_width) - 1, y + py, obj_homealone_interactable, false, true);
539
                if (thisinteract == 2)
540
                    interactedobject = collision_rectangle(x + (3 * d), y, (x + sprite_width) - (5 * d), y * d, obj_homealone_vent, false, true);
541
                if (interactedobject != -4)
542
                {
543
                    if (thisinteract == 1)
544
                    {
545
                        interacted = true;
546
                        with (interactedobject)
547
                            interact_event = true;
548
                    }
549
                }
550
            }
551
        }
552
        else
553
        {
554
            var still_interacting = false;
555
            var right_check = x + sprite_width + (1 * d);
556
            var left_check = x - (1 * d);
557
            if (global.facing == 1)
558
            {
559
                if (collision_rectangle((x + sprite_width) - 1, y, x + sprite_width + 1, (y + sprite_height) - 1, obj_homealone_interactable, false, true))
560
                    still_interacting = true;
561
            }
562
            if (global.facing == 3)
563
            {
564
                if (collision_rectangle(x, y, left_check, y + sprite_height, obj_homealone_interactable, false, true))
565
                    still_interacting = true;
566
            }
567
            if (global.facing == 0)
568
            {
569
                if (collision_rectangle(x + (4 * d), y + (1 * d), (x + sprite_width) - (4 * d), y + sprite_height + (1 * d), obj_homealone_interactable, false, true))
570
                    still_interacting = true;
571
            }
572
            if (global.facing == 2)
573
            {
574
                if (collision_rectangle(x, y, (x + sprite_width) - 1, y + py, obj_homealone_interactable, false, true))
575
                    still_interacting = true;
576
            }
577
            if (!still_interacting)
578
            {
579
                var interacted_objects = 0;
580
                if (interacted_objects == 0 || px == 0)
581
                {
582
                    interacted = false;
583
                    interactedobject = -4;
584
                }
585
            }
586
        }
587
    }
588
}
589
onebuffer -= 1;
590
twobuffer -= 1;
591
threebuffer -= 1;
592
with (collision_rectangle(bbox_left, bbox_top, bbox_right, bbox_bottom, obj_homealone_vent, 0, 0))
593
alarm[0]
594
if (
scr_debug
scr_debug

function
scr_debug()
{ if (global.debug == 1) return 1; }
())
595
{
596
}