Deltarune (Chapter 5) script viewer

← back to main script listing

gml_Object_obj_bookshelf_moveable2x2_Step_0

(view raw script w/o annotations or w/e)
1
siner++;
2
if (init == 0)
3
{
4
    init = 1;
5
    if (xflag != -4)
6
    {
7
        if (global.flag[xflag] == 0)
8
            global.flag[xflag] = x;
9
        else
10
            x = global.flag[xflag];
11
        if (global.flag[yflag] == 0)
12
            global.flag[yflag] = y;
13
        else
14
            y = global.flag[yflag];
15
    }
16
}
17
if (con == 0)
18
{
19
    var move = false;
20
    if (move)
21
    {
22
        
scr_debug_print
scr_debug_print

function
scr_debug_print()
{ if (!
scr_debug())
exit; } function scr_debug_clear_all() { }
("move");
23
        con = 1;
24
        timer = 0;
25
    }
26
    if (resetpos)
27
    {
28
        resetpos = 0;
29
        var doreset = true;
30
        if (x == xstart && y == ystart)
31
            doreset = false;
32
        if (place_meeting(xstart, ystart, object_index))
33
            doreset = false;
34
        if (doreset)
35
        {
36
            con = 40;
37
            snd_play(snd_bell, 0.5);
38
            var movespd = 16;
39
            var dist = round(point_distance(x, y, xstart, ystart) / movespd) + 1;
40
            if (x != xstart)
41
                
scr_lerpvar
scr_lerpvar

function
scr_lerpvar()
{ var _id = self; if (!is_struct(self)) _id = id; 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_lerpcol() { if (argument_count < 6) ___lerpvar = scr_lerpcol_instance(id, argument[0], argument[1], argument[2], argument[3]); else ___lerpvar = scr_lerpcol_instance(id, argument[0], argument[1], argument[2], argument[3], argument[4], argument[5]); return ___lerpvar; }
("x", x, xstart, dist, -1, "out");
42
            if (y != ystart)
43
                
scr_lerpvar
scr_lerpvar

function
scr_lerpvar()
{ var _id = self; if (!is_struct(self)) _id = id; 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_lerpcol() { if (argument_count < 6) ___lerpvar = scr_lerpcol_instance(id, argument[0], argument[1], argument[2], argument[3]); else ___lerpvar = scr_lerpcol_instance(id, argument[0], argument[1], argument[2], argument[3], argument[4], argument[5]); return ___lerpvar; }
("y", y, ystart, dist, -1, "out");
44
            scr_delay_var("con", 0, dist + 1);
45
            scr_delay_var("flagupdate", 1, dist + 1);
46
        }
47
        else
48
        {
49
            con = 0;
50
        }
51
    }
52
}
53
if (con == 1)
54
{
55
    var checkdir = dir;
56
    with (base)
57
    {
58
        var px = 0;
59
        var py = 0;
60
        switch (checkdir)
61
        {
62
            case 0:
63
                py = 1;
64
                break;
65
            case 1:
66
                px = 1;
67
                break;
68
            case 2:
69
                py = -1;
70
                break;
71
            case 3:
72
                px = -1;
73
                break;
74
        }
75
        var met = -4;
76
        for (var i = 0; i < 8000; i++)
77
        {
78
            if (met == -4)
79
            {
80
                var solidenemyspot = instance_place(x + (px * i), y + (py * i), obj_solidenemy);
81
                if (i_ex(solidenemyspot))
82
                {
83
                    with (solidenemyspot)
84
                        
scr_afterimage
scr_afterimage

function
scr_afterimage()
{ afterimage = instance_create(x, y, obj_afterimage); afterimage.sprite_index = sprite_index; afterimage.image_index = image_index; afterimage.image_blend = image_blend; afterimage.image_speed = 0; afterimage.depth = depth; afterimage.image_xscale = image_xscale; afterimage.image_yscale = image_yscale; afterimage.image_angle = image_angle; return afterimage; }
();
85
                    met = i - 1;
86
                }
87
            }
88
            if (met == -4)
89
            {
90
                var _list = ds_list_create();
91
                var _num = instance_place_list(x + (px * i), y + (py * i), 1181, _list, false);
92
                if (_num > 0)
93
                {
94
                    for (var j = 0; j < _num; j++)
95
                        met = i - 1;
96
                }
97
                ds_list_destroy(_list);
98
            }
99
        }
100
        if (met > 0)
101
        {
102
            var movetime = round(met / 16) + 1;
103
            if (checkdir == 1 || checkdir == 3)
104
            {
105
                with (other)
106
                    
scr_lerpvar
scr_lerpvar

function
scr_lerpvar()
{ var _id = self; if (!is_struct(self)) _id = id; 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_lerpcol() { if (argument_count < 6) ___lerpvar = scr_lerpcol_instance(id, argument[0], argument[1], argument[2], argument[3]); else ___lerpvar = scr_lerpcol_instance(id, argument[0], argument[1], argument[2], argument[3], argument[4], argument[5]); return ___lerpvar; }
("x", x, x + (px * met), movetime);
107
            }
108
            if (checkdir == 0 || checkdir == 2)
109
            {
110
                with (other)
111
                    
scr_lerpvar
scr_lerpvar

function
scr_lerpvar()
{ var _id = self; if (!is_struct(self)) _id = id; 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_lerpcol() { if (argument_count < 6) ___lerpvar = scr_lerpcol_instance(id, argument[0], argument[1], argument[2], argument[3]); else ___lerpvar = scr_lerpcol_instance(id, argument[0], argument[1], argument[2], argument[3], argument[4], argument[5]); return ___lerpvar; }
("y", y, y + (py * met), movetime);
112
            }
113
            other.con = -1;
114
            snd_play_delay(snd_wing, movetime, 0.7, 0.8);
115
            with (other)
116
                scr_delay_var("con", 0, movetime + 1);
117
            with (other)
118
                scr_delay_var("flagupdate", 1, movetime + 1);
119
        }
120
        else
121
        {
122
            other.con = 0;
123
        }
124
    }
125
}
126
if (flagupdate)
127
{
128
    flagupdate = 0;
129
    if (xflag != -4)
130
    {
131
        global.flag[xflag] = x;
132
        global.flag[yflag] = y;
133
    }
134
}