Deltarune (Chapter 3) script viewer

← back to main script listing

gml_Object_obj_mainchara_board_OLD_Step_0

(view raw script w/o annotations or w/e)
1
if (i_ex(obj_board_controller) && movetype == "board")
2
{
3
    if (keyboard_check_pressed(ord("1")))
4
        movesleft = 1;
5
    if (keyboard_check_pressed(ord("2")))
6
        movesleft = 2;
7
    if (keyboard_check_pressed(ord("3")))
8
        movesleft = 3;
9
    if (keyboard_check_pressed(ord("4")))
10
        movesleft = 4;
11
    if (keyboard_check_pressed(ord("5")))
12
        movesleft = 5;
13
    if (keyboard_check_pressed(ord("6")))
14
        movesleft = 6;
15
    if (keyboard_check_pressed(ord("0")))
16
        movesleft = 0;
17
    facing = 0;
18
    sprite_index = spr_board_kris_walk_down;
19
    image_speed = 0.25;
20
    if (obj_board_controller.phase == 0 && movebuffer <= 0)
21
    {
22
        if (movesleft > 0)
23
        {
24
            if (movingnow == 0)
25
            {
26
                canmove = false;
27
                if (i_ex(obj_board_camera))
28
                {
29
                    if (obj_board_camera.con == 0)
30
                        canmove = true;
31
                }
32
                if (i_ex(obj_growtangle))
33
                    canmove = false;
34
                if (movesleft > 0 && canmove)
35
                {
36
                    var destination = 0;
37
                    var i;
38
                    if (right_p())
39
                    {
40
                        i = 1;
41
                        do
42
                        {
43
                            if (place_meeting(x + (i * 32), y, obj_boardtile))
44
                                destination = 1;
45
                            if (place_meeting(x + (i * 32), y, obj_board_solid))
46
                                destination = 2;
47
                            dir = "right";
48
                            i++;
49
                            if (i > 32)
50
                                destination = 3;
51
                        }
52
                        until (destination != 0);
53
                    }
54
                    else if (left_p())
55
                    {
56
                        i = 1;
57
                        do
58
                        {
59
                            if (place_meeting(x - (i * 32), y, obj_boardtile))
60
                                destination = 1;
61
                            if (place_meeting(x - (i * 32), y, obj_board_solid))
62
                                destination = 2;
63
                            dir = "left";
64
                            i++;
65
                            if (i > 32)
66
                                destination = 3;
67
                        }
68
                        until (destination != 0);
69
                    }
70
                    else if (down_p())
71
                    {
72
                        i = 1;
73
                        do
74
                        {
75
                            if (place_meeting(x, y + (i * 32), obj_boardtile))
76
                                destination = 1;
77
                            if (place_meeting(x, y + (i * 32), obj_board_solid))
78
                                destination = 2;
79
                            dir = "down";
80
                            i++;
81
                            if (i > 32)
82
                                destination = 3;
83
                        }
84
                        until (destination != 0);
85
                    }
86
                    else if (up_p())
87
                    {
88
                        i = 1;
89
                        do
90
                        {
91
                            if (place_meeting(x, y - (i * 32), obj_boardtile))
92
                                destination = 1;
93
                            if (place_meeting(x, y - (i * 32), obj_board_solid))
94
                                destination = 2;
95
                            dir = "up";
96
                            i++;
97
                            if (i > 32)
98
                                destination = 3;
99
                        }
100
                        until (destination != 0);
101
                    }
102
                    if (destination == 2)
103
                    {
104
                        movingnow = 0;
105
                        debug_message("Solid Block Found, can't go that way. Requested direction=" + dir);
106
                        dir = "null";
107
                    }
108
                    if (destination == 1)
109
                    {
110
                        movingnow = (i - 1) * 2;
111
                        movesleft--;
112
                    }
113
                }
114
            }
115
        }
116
        if (movingnow != 0)
117
        {
118
            if (dir == "left")
119
                x -= 16;
120
            else if (dir == "right")
121
                x += 16;
122
            else if (dir == "up")
123
                y -= 16;
124
            else if (dir == "down")
125
                y += 16;
126
            movingnow--;
127
            movebuffer = 2;
128
        }
129
        if (movesleft > 0 && movingnow == 0 && movebuffer <= 0)
130
        {
131
            if (place_meeting(x, y, obj_board_readable))
132
            {
133
                var currentTile = instance_place(x, y, obj_board_readable);
134
                with (currentTile)
135
                    event_user(15);
136
            }
137
        }
138
        if (movesleft == 0 && movingnow == 0 && movebuffer <= 0 && canmove == true)
139
            obj_board_controller.phase = 1;
140
    }
141
    if (movebuffer > -10)
142
        movebuffer--;
143
    if (place_meeting(x, y, obj_board_freeroam_trigger))
144
        movetype = "free";
145
}
146
else if (movetype == "free")
147
{
148
    if (i_ex(obj_board_controller))
149
        obj_board_controller.phase = 3;
150
    wallcheck = 0;
151
    nowx = x;
152
    nowy = y;
153
    if (press_d == 0 && press_l == 0 && press_u == 0 && press_r == 0)
154
        nopress = 1;
155
    press_l = 0;
156
    press_r = 0;
157
    press_d = 0;
158
    press_u = 0;
159
    bkx = 0;
160
    bky = 0;
161
    bkxy = 0;
162
    if (global.interact == 0 && canfreemove == 1)
163
    {
164
        if (left_h())
165
            press_l = 1;
166
        if (right_h())
167
            press_r = 1;
168
        if (up_h())
169
            press_u = 1;
170
        if (down_h())
171
            press_d = 1;
172
        px = 0;
173
        py = 0;
174
        pressdir = -1;
175
        if (press_r == 1)
176
        {
177
            px = wspeed;
178
            pressdir = 1;
179
        }
180
        if (press_l == 1)
181
        {
182
            px = -wspeed;
183
            pressdir = 3;
184
        }
185
        if (press_d == 1)
186
        {
187
            py = wspeed;
188
            pressdir = 0;
189
        }
190
        if (press_u == 1)
191
        {
192
            py = -wspeed;
193
            pressdir = 2;
194
        }
195
        if (nopress == 1 && pressdir != -1)
196
            facing = pressdir;
197
        if (facing == 2)
198
        {
199
            if (press_d == 1)
200
                facing = 0;
201
            if (press_u == 0 && pressdir != -1)
202
                facing = pressdir;
203
        }
204
        if (facing == 0)
205
        {
206
            if (press_u == 1)
207
                facing = 2;
208
            if (press_d == 0 && pressdir != -1)
209
                facing = pressdir;
210
        }
211
        if (facing == 3)
212
        {
213
            if (press_r == 1)
214
                facing = 1;
215
            if (press_l == 0 && pressdir != -1)
216
                facing = pressdir;
217
        }
218
        if (facing == 1)
219
        {
220
            if (press_l == 1)
221
                facing = 3;
222
            if (press_r == 0 && pressdir != -1)
223
                facing = pressdir;
224
        }
225
        nopress = 0;
226
        xmeet = 0;
227
        ymeet = 0;
228
        xymeet = 0;
229
        if (place_meeting(x + px, y + py, obj_board_solid))
230
            xymeet = 1;
231
        if (place_meeting(x + px, y, obj_board_solid))
232
        {
233
            if (place_meeting(x + px, y, obj_board_solid))
234
            {
235
                for (g = wspeed; g > 0; g -= 1)
236
                {
237
                    mvd = 0;
238
                    if (press_d == 0 && !place_meeting(x + px, y - g, obj_board_solid))
239
                    {
240
                        y -= g;
241
                        py = 0;
242
                        break;
243
                        mvd = 1;
244
                    }
245
                    if (press_u == 0 && mvd == 0 && !place_meeting(x + px, y + g, obj_board_solid))
246
                    {
247
                        y += g;
248
                        py = 0;
249
                        break;
250
                    }
251
                }
252
            }
253
            xmeet = 1;
254
            bkx = 0;
255
            if (px > 0)
256
            {
257
                for (var i = px; i >= 0; i -= 1)
258
                {
259
                    if (!place_meeting(x + i, y, obj_board_solid))
260
                    {
261
                        px = i;
262
                        bkx = 1;
263
                        break;
264
                    }
265
                }
266
            }
267
            if (px < 0)
268
            {
269
                for (var i = px; i <= 0; i += 1)
270
                {
271
                    if (!place_meeting(x + i, y, obj_board_solid))
272
                    {
273
                        px = i;
274
                        bkx = 1;
275
                        break;
276
                    }
277
                }
278
            }
279
            if (bkx == 0)
280
                px = 0;
281
        }
282
        if (place_meeting(x, y + py, obj_board_solid))
283
        {
284
            ymeet = 1;
285
            bky = 0;
286
            if (place_meeting(x, y + py, obj_board_solid))
287
            {
288
                for (g = wspeed; g > 0; g -= 1)
289
                {
290
                    mvd = 0;
291
                    if (press_r == 0 && !place_meeting(x - g, y + py, obj_board_solid))
292
                    {
293
                        x -= g;
294
                        px = 0;
295
                        break;
296
                        mvd = 1;
297
                    }
298
                    if (mvd == 0 && press_l == 0 && !place_meeting(x + g, y + py, obj_board_solid))
299
                    {
300
                        x += g;
301
                        px = 0;
302
                        break;
303
                    }
304
                }
305
            }
306
            if (py > 0)
307
            {
308
                for (var i = py; i >= 0; i -= 1)
309
                {
310
                    if (!place_meeting(x, y + i, obj_board_solid))
311
                    {
312
                        py = i;
313
                        bky = 1;
314
                        break;
315
                    }
316
                }
317
            }
318
            if (py < 0)
319
            {
320
                for (var i = py; i <= 0; i += 1)
321
                {
322
                    if (!place_meeting(x, y + i, obj_board_solid))
323
                    {
324
                        py = i;
325
                        bky = 1;
326
                        break;
327
                    }
328
                }
329
            }
330
            if (bky == 0)
331
                py = 0;
332
        }
333
        if (place_meeting(x + px, y + py, obj_board_solid))
334
        {
335
            xymeet = 1;
336
            bkxy = 0;
337
            var i = px;
338
            j = py;
339
            while (j != 0 || i != 0)
340
            {
341
                if (!place_meeting(x + i, y + j, obj_board_solid))
342
                {
343
                    px = i;
344
                    py = j;
345
                    bkxy = 1;
346
                    break;
347
                }
348
                if (abs(j) >= 1)
349
                {
350
                    if (j > 0)
351
                        j -= 1;
352
                    if (j < 0)
353
                        j += 1;
354
                }
355
                else
356
                {
357
                    j = 0;
358
                }
359
                if (abs(i) >= 1)
360
                {
361
                    if (i > 0)
362
                        i -= 1;
363
                    if (i < 0)
364
                        i += 1;
365
                }
366
                else
367
                {
368
                    i = 0;
369
                }
370
            }
371
            if (bkxy == 0)
372
            {
373
                px = 0;
374
                py = 0;
375
            }
376
        }
377
        x += px;
378
        y += py;
379
    }
380
    if (fun == 0)
381
    {
382
        walk = 0;
383
        if (x != nowx && nopress == 0)
384
            walk = 1;
385
        if (y != nowy && nopress == 0)
386
            walk = 1;
387
        if (walk == 1)
388
            walkbuffer = 6;
389
        if (walkbuffer > 3)
390
        {
391
            walktimer += 1.5;
392
            if (walktimer >= 40)
393
                walktimer -= 40;
394
            if (walktimer < 10)
395
                image_index = 0;
396
            if (walktimer >= 10)
397
                image_index = 1;
398
            if (walktimer >= 20)
399
                image_index = 2;
400
            if (walktimer >= 30)
401
                image_index = 3;
402
        }
403
        if (walkbuffer <= 0 && fun == 0)
404
        {
405
            if (walktimer < 10)
406
                walktimer = 9.5;
407
            if (walktimer >= 10 && walktimer < 20)
408
                walktimer = 19.5;
409
            if (walktimer >= 20 && walktimer < 30)
410
                walktimer = 29.5;
411
            if (walktimer >= 30)
412
                walktimer = 39.5;
413
            image_index = 0;
414
        }
415
        walkbuffer -= 0.75;
416
        if (facing == 0)
417
            sprite_index = spr_board_kris_walk_down;
418
        if (facing == 1)
419
            sprite_index = spr_board_kris_walk_right;
420
        if (facing == 2)
421
            sprite_index = spr_board_kris_walk_up;
422
        if (facing == 3)
423
            sprite_index = spr_board_kris_walk_left;
424
    }
425
    if (onebuffer <= 0 && swordbuffer <= 0 && global.interact == 0 && button1_p())
426
    {
427
        onebuffer = 6;
428
        thisinteract = 0;
429
        if (facing == 1)
430
        {
431
            if (collision_rectangle(x + 16, y + 16 + 2, x + 16 + 32, (y + 32) - 2, obj_board_interactable, false, true))
432
                thisinteract = 1;
433
            if (collision_rectangle(x + 16, y + 16 + 2, x + 16 + 32, (y + 32) - 2, obj_board_interactable_solid, false, true))
434
                thisinteract = 2;
435
        }
436
        if (thisinteract > 0)
437
        {
438
            if (thisinteract == 1)
439
                interactedobject = collision_rectangle(x + 16, y + 16 + 2, x + 16 + 32, (y + 32) - 2, obj_board_interactable, false, true);
440
            if (thisinteract == 2)
441
                interactedobject = collision_rectangle(x + 16, y + 16 + 2, x + 16 + 32, (y + 32) - 2, obj_board_interactable_solid, false, true);
442
            if (interactedobject != -4)
443
            {
444
                with (interactedobject)
445
                    facing = 3;
446
                with (interactedobject)
447
                    
scr_interact
scr_interact

function
scr_interact()
{ myinteract = 1; event_user(0); }
();
448
            }
449
        }
450
        thisinteract = 0;
451
        if (facing == 3)
452
        {
453
            if (collision_rectangle(x + 16, y + 16 + 2, (x + 16) - 32, (y + 32) - 2, obj_board_interactable, false, true))
454
                thisinteract = 1;
455
            if (collision_rectangle(x + 16, y + 16 + 2, (x + 16) - 32, (y + 32) - 2, obj_board_interactable_solid, false, true))
456
                thisinteract = 2;
457
        }
458
        if (thisinteract > 0)
459
        {
460
            if (thisinteract == 1)
461
                interactedobject = collision_rectangle(x + 16, y + 16 + 2, (x + 16) - 32, (y + 32) - 2, obj_board_interactable, false, true);
462
            if (thisinteract == 2)
463
                interactedobject = collision_rectangle(x + 16, y + 16 + 2, (x + 16) - 32, (y + 32) - 2, obj_board_interactable_solid, false, true);
464
            if (interactedobject != -4)
465
            {
466
                with (interactedobject)
467
                    facing = 1;
468
                with (interactedobject)
469
                    
scr_interact
scr_interact

function
scr_interact()
{ myinteract = 1; event_user(0); }
();
470
            }
471
        }
472
        thisinteract = 0;
473
        if (facing == 0)
474
        {
475
            if (collision_rectangle(x + 8, y + 16 + 4, (x + 32) - 8, y + 16 + 28, obj_board_interactable, false, true))
476
                thisinteract = 1;
477
            if (collision_rectangle(x + 8, y + 16 + 4, (x + 32) - 8, y + 16 + 28, obj_board_interactable_solid, false, true))
478
                thisinteract = 2;
479
        }
480
        if (thisinteract > 0)
481
        {
482
            if (thisinteract == 1)
483
                interactedobject = collision_rectangle(x + 8, y + 16 + 4, (x + 32) - 8, y + 16 + 28, obj_board_interactable, false, true);
484
            if (thisinteract == 2)
485
                interactedobject = collision_rectangle(x + 8, y + 16 + 4, (x + 32) - 8, y + 16 + 28, obj_board_interactable_solid, false, true);
486
            if (interactedobject != -4)
487
            {
488
                with (interactedobject)
489
                    facing = 2;
490
                with (interactedobject)
491
                    
scr_interact
scr_interact

function
scr_interact()
{ myinteract = 1; event_user(0); }
();
492
            }
493
        }
494
        thisinteract = 0;
495
        if (global.facing == 2)
496
        {
497
            if (collision_rectangle(x + 8, y + 16 + 4, (x + 32) - 8, (y + 16) - 28, obj_board_interactable, false, true))
498
                thisinteract = 1;
499
            if (collision_rectangle(x + 8, y + 16 + 4, (x + 32) - 8, (y + 16) - 28, obj_board_interactable_solid, false, true))
500
                thisinteract = 2;
501
        }
502
        if (thisinteract > 0)
503
        {
504
            if (thisinteract == 1)
505
                interactedobject = collision_rectangle(x + 8, y + 16 + 4, (x + 32) - 8, (y + 16) - 28, obj_board_interactable, false, true);
506
            if (thisinteract == 2)
507
                interactedobject = collision_rectangle(x + 8, y + 16 + 4, (x + 32) - 8, (y + 16) - 28, obj_board_interactable_solid, false, true);
508
            if (interactedobject != -4)
509
            {
510
                with (interactedobject)
511
                    facing = 0;
512
                with (interactedobject)
513
                    
scr_interact
scr_interact

function
scr_interact()
{ myinteract = 1; event_user(0); }
();
514
            }
515
        }
516
    }
517
    onebuffer -= 1;
518
    if (button2_p() && swordbuffer <= 0 && onebuffer <= 0 && global.interact == 0)
519
    {
520
        swordbuffer = 8;
521
        swordfacing = facing;
522
        canfreemove = 0;
523
    }
524
    if (swordbuffer > 0)
525
    {
526
        swordbuffer--;
527
        facing = swordfacing;
528
        if (facing == 0)
529
            sprite_index = spr_board_kris_strike_down;
530
        if (facing == 1)
531
            sprite_index = spr_board_kris_strike_right;
532
        if (facing == 2)
533
            sprite_index = spr_board_kris_strike_up;
534
        if (facing == 3)
535
            sprite_index = spr_board_kris_strike_left;
536
        if (swordbuffer == 7)
537
            image_index = 0;
538
        if (swordbuffer == 6)
539
            image_index = 0;
540
        if (swordbuffer == 5)
541
            image_index = 1;
542
        if (swordbuffer == 4)
543
            image_index = 1;
544
        if (swordbuffer == 3)
545
            image_index = 1;
546
        if (swordbuffer == 2)
547
            image_index = 2;
548
        if (swordbuffer == 1)
549
            image_index = 0;
550
        if (swordbuffer == 0)
551
            canfreemove = 1;
552
        if (swordbuffer == 5)
553
        {
554
            var swordhitbox = instance_create(x, y, obj_board_swordhitbox);
555
            swordhitbox.facing = facing;
556
        }
557
    }
558
}
559
else
560
{
561
    movetype = "free";
562
}