Deltarune (Chapter 5) script viewer

← back to main script listing

gml_GlobalScript_scr_plat_set_group

(view raw script w/o annotations or w/e)
1
function 
scr_plat_set_group
scr_plat_set_group

function
scr_plat_set_group(arg0, arg1 = infinity)
{ __depthgroup = arg0; if (arg0 < 0) { if (arg0 == UnknownEnum.Value_m1) depth = 1960; if (arg0 == UnknownEnum.Value_m2) depth = 1950; } if (arg1 != infinity) scr_plat_set_depth_offset(arg1); } function scr_plat_set_depth_offset(arg0 = 1) { __depth_offset = 0; if (arg0 == 1) { var floortex = collision_rectangle(bbox_left, bbox_bottom - 1, bbox_right, bbox_bottom, obj_plat_floortex, false, true); if (floortex != -4) { if (variable_instance_exists(floortex, "y_ow")) __depth_offset = bbox_bottom - floortex.y_ow_anchor; else __depth_offset = bbox_bottom - floortex.bbox_bottom; } } else { __depth_offset = arg0; } } function scr_plat_wallcast(arg0 = -1) { var _depth_group = 0; if (variable_instance_exists(id, "__depthgroup")) _depth_group = __depthgroup; var _depth_offset = 0; if (variable_instance_exists(id, "__depth_offset")) _depth_offset = __depth_offset; if (!variable_instance_exists(id, "__depthcast__results") || !ds_exists(__depthcast__results, ds_type_list)) __depthcast__results = scr_ds_list_create_managed(); ds_list_clear(__depthcast__results); if (arg0 == -1) { var best = -4; instance_place_list(x, y, 445, __depthcast__results, false); var __size = ds_list_size(__depthcast__results); for (var i = 0; i < __size; i++) { if (best == -4 || best.depth < ds_list_find_value(__depthcast__results, i).depth) best = ds_list_find_value(__depthcast__results, i); } if (best == -4) { ds_list_clear(__depthcast__results); instance_place_list(x, y, 1305, __depthcast__results, false); __size = ds_list_size(__depthcast__results); for (var i = 0; i < __size; i++) { if (best == -4 || best.depth < ds_list_find_value(__depthcast__results, i).depth) best = ds_list_find_value(__depthcast__results, i); } if (best != -4 && best.floortex != -4) { __floortex = best.floortex; scr_calculate_floortex_background_depth(best.floortex, _depth_offset + _depth_group); exit; } } else if (best.floortex != -4) { __floortex = best.floortex; scr_calculate_floortex_foreground_depth(best.floortex, _depth_offset + _depth_group); exit; } } else { var best = -4; instance_place_list(x, y, 445, __depthcast__results, false); var __size = ds_list_size(__depthcast__results); for (var i = 0; i < __size; i++) { if (best == -4 || best.depth > ds_list_find_value(__depthcast__results, i).depth) best = ds_list_find_value(__depthcast__results, i); } if (best == -4) { ds_list_clear(__depthcast__results); instance_place_list(x, y, 1305, __depthcast__results, false); __size = ds_list_size(__depthcast__results); for (var i = 0; i < __size; i++) { if (best == -4 || best.depth > ds_list_find_value(__depthcast__results, i).depth) best = ds_list_find_value(__depthcast__results, i); } if (best != -4 && best.floortex != -4) { ...
(arg0, arg1 = infinity)
2
{
3
    __depthgroup = arg0;
4
    if (arg0 < 0)
5
    {
6
        if (arg0 == UnknownEnum.Value_m1)
7
            depth = 1960;
8
        if (arg0 == UnknownEnum.Value_m2)
9
            depth = 1950;
10
    }
11
    if (arg1 != infinity)
12
        scr_plat_set_depth_offset(arg1);
13
}
14
15
function scr_plat_set_depth_offset(arg0 = 1)
16
{
17
    __depth_offset = 0;
18
    if (arg0 == 1)
19
    {
20
        var floortex = collision_rectangle(bbox_left, bbox_bottom - 1, bbox_right, bbox_bottom, obj_plat_floortex, false, true);
21
        if (floortex != -4)
22
        {
23
            if (variable_instance_exists(floortex, "y_ow"))
24
                __depth_offset = bbox_bottom - floortex.y_ow_anchor;
25
            else
26
                __depth_offset = bbox_bottom - floortex.bbox_bottom;
27
        }
28
    }
29
    else
30
    {
31
        __depth_offset = arg0;
32
    }
33
}
34
35
function scr_plat_wallcast(arg0 = -1)
36
{
37
    var _depth_group = 0;
38
    if (variable_instance_exists(id, "__depthgroup"))
39
        _depth_group = __depthgroup;
40
    var _depth_offset = 0;
41
    if (variable_instance_exists(id, "__depth_offset"))
42
        _depth_offset = __depth_offset;
43
    if (!variable_instance_exists(id, "__depthcast__results") || !ds_exists(__depthcast__results, ds_type_list))
44
        __depthcast__results = scr_ds_list_create_managed();
45
    ds_list_clear(__depthcast__results);
46
    if (arg0 == -1)
47
    {
48
        var best = -4;
49
        instance_place_list(x, y, 445, __depthcast__results, false);
50
        var __size = ds_list_size(__depthcast__results);
51
        for (var i = 0; i < __size; i++)
52
        {
53
            if (best == -4 || best.depth < ds_list_find_value(__depthcast__results, i).depth)
54
                best = ds_list_find_value(__depthcast__results, i);
55
        }
56
        if (best == -4)
57
        {
58
            ds_list_clear(__depthcast__results);
59
            instance_place_list(x, y, 1305, __depthcast__results, false);
60
            __size = ds_list_size(__depthcast__results);
61
            for (var i = 0; i < __size; i++)
62
            {
63
                if (best == -4 || best.depth < ds_list_find_value(__depthcast__results, i).depth)
64
                    best = ds_list_find_value(__depthcast__results, i);
65
            }
66
            if (best != -4 && best.floortex != -4)
67
            {
68
                __floortex = best.floortex;
69
                scr_calculate_floortex_background_depth(best.floortex, _depth_offset + _depth_group);
70
                exit;
71
            }
72
        }
73
        else if (best.floortex != -4)
74
        {
75
            __floortex = best.floortex;
76
            scr_calculate_floortex_foreground_depth(best.floortex, _depth_offset + _depth_group);
77
            exit;
78
        }
79
    }
80
    else
81
    {
82
        var best = -4;
83
        instance_place_list(x, y, 445, __depthcast__results, false);
84
        var __size = ds_list_size(__depthcast__results);
85
        for (var i = 0; i < __size; i++)
86
        {
87
            if (best == -4 || best.depth > ds_list_find_value(__depthcast__results, i).depth)
88
                best = ds_list_find_value(__depthcast__results, i);
89
        }
90
        if (best == -4)
91
        {
92
            ds_list_clear(__depthcast__results);
93
            instance_place_list(x, y, 1305, __depthcast__results, false);
94
            __size = ds_list_size(__depthcast__results);
95
            for (var i = 0; i < __size; i++)
96
            {
97
                if (best == -4 || best.depth > ds_list_find_value(__depthcast__results, i).depth)
98
                    best = ds_list_find_value(__depthcast__results, i);
99
            }
100
            if (best != -4 && best.floortex != -4)
101
            {
102
                __floortex = best.floortex;
103
                scr_calculate_floortex_background_depth(best.floortex, _depth_offset + _depth_group);
104
                exit;
105
            }
106
        }
107
        else if (best.floortex != -4)
108
        {
109
            __floortex = best.floortex;
110
            scr_calculate_floortex_foreground_depth(best.floortex, _depth_offset + _depth_group);
111
            exit;
112
        }
113
    }
114
    scr_plat_depthcast();
115
}
116
117
function scr_plat_depthcast()
118
{
119
    var _depth_group = 0;
120
    if (variable_instance_exists(id, "__depthgroup"))
121
        _depth_group = __depthgroup;
122
    if (_depth_group < 0)
123
        exit;
124
    var _depth_offset = 0;
125
    if (variable_instance_exists(id, "__depth_offset"))
126
        _depth_offset = __depth_offset;
127
    if (!variable_instance_exists(id, "__depthcast__results") || !ds_exists(__depthcast__results, ds_type_list))
128
        __depthcast__results = scr_ds_list_create_managed();
129
    ds_list_clear(__depthcast__results);
130
    collision_rectangle_list(bbox_left, bbox_bottom, bbox_right, room_height, obj_plat_floortex_FLOOR, false, false, __depthcast__results, false);
131
    var __dist = 99999999;
132
    var __closest = -4;
133
    var __size = ds_list_size(__depthcast__results);
134
    for (var i = 0; i < __size; i++)
135
    {
136
        if (!ds_list_find_value(__depthcast__results, i).depthcast_ignore && (ds_list_find_value(__depthcast__results, i).y_ow - bbox_bottom) < __dist)
137
        {
138
            __dist = ds_list_find_value(__depthcast__results, i).y_ow - bbox_bottom;
139
            __closest = ds_list_find_value(__depthcast__results, i);
140
        }
141
    }
142
    if (__closest != -4)
143
    {
144
        scr_calculate_floortex_depth(__closest, _depth_offset + _depth_group);
145
        __storeddepth = depth;
146
        __floortex = __closest;
147
    }
148
    else
149
    {
150
        if (!variable_instance_exists(id, "__storeddepth"))
151
            __storeddepth = 100000 - ((y * 10) + (sprite_height * 10));
152
        depth = __storeddepth;
153
    }
154
}
155
156
function scr_calculate_floortex_depth(arg0 = self, arg1 = 0)
157
{
158
    depth = ((1200000 - (arg0.y_ow_anchor * 10)) + arg0.depthbonus + 200000) - arg1;
159
}
160
161
function scr_calculate_floortex_foreground_depth(arg0 = self, arg1 = 0)
162
{
163
    depth = ((1200000 - (arg0.bbox_bottom * 10)) + arg0.depthbonus + 200000) - arg1;
164
}
165
166
function scr_calculate_floortex_background_depth(arg0 = self, arg1 = 0)
167
{
168
    depth = ((1200000 - (arg0.bbox_top * 10)) + arg0.depthbonus + 200000) - arg1;
169
}
170
171
enum UnknownEnum
172
{
173
    Value_m2 = -2,
174
    Value_m1
175
}