Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_mainchara_Create_0

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

function
scr_depth(arg0 = id, arg1 = 0)
{ with (arg0) depth = 100000 - ((y * 10) + (sprite_height * 10) + (arg1 * 10)); }
();
2
global.currentroom = room;
3
scr_initialize_charnames
scr_initialize_charnames

function
scr_initialize_charnames()
{ global.lcharname = stringsetloc(
Kris
"Kris", "scr_gamestart_slash_scr_gamestart_gml_396_0"
);
global.charname[0] = stringsetloc(
" ", "scr_gamestart_slash_scr_gamestart_gml_101_0_b"
);
global.charname[1] = stringsetloc(
Kris
"Kris", "scr_gamestart_slash_scr_gamestart_gml_99_0"
);
global.charname[2] = stringsetloc(
Susie
"Susie", "scr_gamestart_slash_scr_gamestart_gml_100_0"
);
global.charname[3] = stringsetloc(
Ralsei
"Ralsei", "scr_gamestart_slash_scr_gamestart_gml_101_0"
);
global.charname[4] = stringsetloc(
Noelle
"Noelle", "scr_gamestart_slash_scr_gamestart_gml_105_0"
);
}
();
4
autorun = 0;
5
bg = 0;
6
if (instance_exists(obj_backgrounderparent))
7
    bg = 1;
8
stepping = 0;
9
stepped = 0;
10
drawbattlemode = 1;
11
battlemode = 0;
12
battleheart = instance_create(x, y, obj_overworldheart);
13
battleheart.image_alpha = 0;
14
battleheart.image_speed = 0;
15
battlealpha = 0;
16
becamebattle = 0;
17
sliding = 0;
18
becamesword = 0;
19
swordmode = 0;
20
swordcon = 0;
21
swordtimer = 0;
22
stop_movement = 0;
23
roomenterfreezeend = 0;
24
climbing = 0;
25
climbbuffer = 0;
26
floorheight = 0;
27
darkmode = global.darkzone;
28
if (darkmode == 1)
29
{
30
    stepping = 1;
31
    image_xscale = 2;
32
    image_yscale = 2;
33
}
34
cutscene = 0;
35
press_l = 0;
36
press_r = 0;
37
press_d = 0;
38
press_u = 0;
39
px = 0;
40
py = 0;
41
wallcheck = 0;
42
wspeed = 3;
43
bwspeed = 3;
44
if (darkmode == 1)
45
{
46
    bwspeed = 4;
47
    wspeed = 4;
48
}
49
run = 0;
50
runtimer = 0;
51
runcounter = 0;
52
drawdebug = 0;
53
ignoredepth = 0;
54
freeze = 0;
55
subxspeed = 0;
56
subyspeed = 0;
57
subx = 0;
58
suby = 0;
59
walkanim = 0;
60
walkbuffer = 0;
61
walktimer = 0;
62
image_speed = 0;
63
dsprite = spr_krisd;
64
rsprite = spr_krisr;
65
usprite = spr_krisu;
66
lsprite = spr_krisl;
67
climbsprite = 3708;
68
if (global.darkzone == 1)
69
{
70
    dsprite = spr_krisd_dark;
71
    rsprite = spr_krisr_dark;
72
    lsprite = spr_krisl_dark;
73
    usprite = spr_krisu_dark;
74
}
75
init_clothes = false;
76
if (global.chapter == 4)
77
{
78
    if (global.darkzone == 0 && global.plot >= 11 && global.plot < 35)
79
    {
80
        init_clothes = true;
81
        dsprite = spr_kris_walk_down_church;
82
        rsprite = spr_kris_walk_right_church;
83
        lsprite = spr_kris_walk_left_church;
84
    }
85
    tower_shake_xoffset = 0;
86
}
87
swordfacing = 1;
88
swordsprite = rsprite;
89
fun = 0;
90
if (global.facing == 0)
91
    sprite_index = dsprite;
92
if (global.facing == 1)
93
    sprite_index = rsprite;
94
if (global.facing == 2)
95
    sprite_index = usprite;
96
if (global.facing == 3)
97
    sprite_index = lsprite;
98
onebuffer = 0;
99
twobuffer = 0;
100
threebuffer = 0;
101
global.menuno = 0;
102
for (i = 0; i < 10; i += 1)
103
    global.menucoord[i] = 0;
104
cameFromEntrance = global.entrance;
105
if (global.interact == 3)
106
{
107
    noentrancefound = 0;
108
    if (global.entrance > 0)
109
    {
110
        if (global.flag[21 door_freeze_timer] <= 0)
111
        {
112
            global.interact = 0;
113
            global.flag[21 door_freeze_timer] = -10;
114
            roomenterfreezeend = 1;
115
        }
116
        switch (global.entrance)
117
        {
118
            case 1:
119
                if (i_ex(obj_markerA))
120
                    setxy(obj_markerA.x, obj_markerA.y);
121
                else
122
                    noentrancefound = 1;
123
                break;
124
            case 2:
125
                if (i_ex(obj_markerB))
126
                    setxy(obj_markerB.x, obj_markerB.y);
127
                else
128
                    noentrancefound = 1;
129
                break;
130
            case 3:
131
                if (i_ex(obj_markerC))
132
                    setxy(obj_markerC.x, obj_markerC.y);
133
                else
134
                    noentrancefound = 1;
135
                break;
136
            case 4:
137
                if (i_ex(obj_markerD))
138
                    setxy(obj_markerD.x, obj_markerD.y);
139
                else
140
                    noentrancefound = 1;
141
                break;
142
            case 5:
143
                if (i_ex(obj_markerE))
144
                    setxy(obj_markerE.x, obj_markerE.y);
145
                else
146
                    noentrancefound = 1;
147
                break;
148
            case 6:
149
                if (i_ex(obj_markerF))
150
                    setxy(obj_markerF.x, obj_markerF.y);
151
                else
152
                    noentrancefound = 1;
153
                break;
154
            case 18:
155
                if (i_ex(obj_markerr))
156
                    setxy(obj_markerr.x, obj_markerr.y);
157
                else
158
                    noentrancefound = 1;
159
                break;
160
            case 19:
161
                if (i_ex(obj_markers))
162
                    setxy(obj_markers.x, obj_markers.y);
163
                else
164
                    noentrancefound = 1;
165
                break;
166
            case 20:
167
                if (i_ex(obj_markert))
168
                    setxy(obj_markert.x, obj_markert.y);
169
                else
170
                    noentrancefound = 1;
171
                break;
172
            case 21:
173
                if (i_ex(obj_markeru))
174
                    setxy(obj_markeru.x, obj_markeru.y);
175
                else
176
                    noentrancefound = 1;
177
                break;
178
            case 22:
179
                if (i_ex(obj_markerv))
180
                    setxy(obj_markerv.x, obj_markerv.y);
181
                else
182
                    noentrancefound = 1;
183
                break;
184
            case 23:
185
                if (i_ex(obj_markerw))
186
                    setxy(obj_markerw.x, obj_markerw.y);
187
                else
188
                    noentrancefound = 1;
189
                break;
190
            case 24:
191
                if (i_ex(obj_markerX))
192
                    setxy(obj_markerX.x, obj_markerX.y);
193
                else
194
                    noentrancefound = 1;
195
                break;
196
            default:
197
                noentrancefound = 1;
198
        }
199
        if (noentrancefound == 1)
200
        {
201
            if (i_ex(obj_markerAny))
202
            {
203
                with (obj_markerAny)
204
                {
205
                    if (image_index == global.entrance)
206
                    {
207
                        other.x = x;
208
                        other.y = y;
209
                    }
210
                }
211
            }
212
            else
213
            {
214
                setxy(room_width / 2, room_height / 2);
215
                debug_message("entrance not found, setting to center of room");
216
                debug_message("entrance requested was global.entrance=" + string(global.entrance));
217
            }
218
        }
219
    }
220
}
221
initwd = sprite_width;
222
initht = sprite_height;
223
mywidth = sprite_width;
224
myheight = sprite_height;
225
for (i = 0; i < 3; i += 1)
226
    global.battledf[i] = global.df[global.char[i]] + global.itemdf[global.char[i]][0] + global.itemdf[global.char[i]][1] + global.itemdf[global.char[i]][2];
227
if (global.chapter == 2)
228
{
229
    if (global.flag[302 toy_deliver_progress] == 1)
230
        instance_create(x, y, obj_kris_headobj);
231
}
232
if (global.chapter == 4)
233
{
234
    if (!cameFromEntrance && room == room_dw_castle_town)
235
    {
236
        if (global.plot >= 240 && global.flag[1661] > 0)
237
        {
238
            x = 920;
239
            y = 1200;
240
        }
241
    }
242
}
243
244
function check_heightfloor(arg0, arg1, arg2)
245
{
246
    var __onfloor = 0;
247
    var __inst = instance_position(bbox_right + arg0, bbox_top + arg1, arg2);
248
    if (__inst != -4)
249
    {
250
        if (__inst.floorheight == floorheight)
251
            __onfloor++;
252
    }
253
    __inst = instance_position(bbox_right + arg0, bbox_bottom + arg1, arg2);
254
    if (__inst != -4)
255
    {
256
        if (__inst.floorheight == floorheight)
257
            __onfloor++;
258
    }
259
    __inst = instance_position(bbox_left + arg0, bbox_top + arg1, arg2);
260
    if (__inst != -4)
261
    {
262
        if (__inst.floorheight == floorheight)
263
            __onfloor++;
264
    }
265
    __inst = instance_position(bbox_left + arg0, bbox_bottom + arg1, arg2);
266
    if (__inst != -4)
267
    {
268
        if (__inst.floorheight == floorheight)
269
            __onfloor++;
270
    }
271
    if (__onfloor == 4)
272
        __onfloor = 1;
273
    else
274
        __onfloor = 0;
275
    return __onfloor;
276
}
277
278
nudgex = 0;
279
nudgey = 0;
280
nudgelerp = 0.1;
281
if (global.interact == 7)
282
{
283
    if (global.tempflag[93] == 1)
284
    {
285
        freeze = true;
286
        cutscene = true;
287
    }
288
    else
289
    {
290
        var found = 0;
291
        with (obj_climb_marker)
292
        {
293
            if (found == 0)
294
            {
295
                if (image_index == global.entrance)
296
                {
297
                    found = 1;
298
                    with (instance_create(x + 20, y + 20, obj_climb_kris))
299
                    {
300
                        var roomw = room_width;
301
                        var roomh = room_height;
302
                        var vieww = view_wport[0];
303
                        var viewh = view_hport[0];
304
                        var camx = clamp(x - floor(vieww / 2), 0, roomw - vieww);
305
                        var camy = clamp(y - floor(viewh / 2), 0, roomh - viewh);
306
                        var lclamp = 0;
307
                        var rclamp = roomw - vieww;
308
                        var uclamp = 0;
309
                        var dclamp = roomh - viewh;
310
                        camx = clamp(camx, lclamp, rclamp);
311
                        camy = clamp(camy, uclamp, dclamp);
312
                        camerax_set(camx);
313
                        cameray_set(camy);
314
                        startofroom = true;
315
                    }
316
                    global.interact = 0;
317
                }
318
            }
319
        }
320
        if (found)
321
        {
322
            visible = false;
323
            freeze = true;
324
            cutscene = true;
325
        }
326
    }
327
}
328
noclip = false;
329
if (
scr_debug
scr_debug

function
scr_debug()
{ if (global.debug == 1) return 1; }
())
330
{
331
    if (layer_exists("OBJECTS_MAIN"))
332
    {
333
        if (!layer_get_visible("OBJECTS_MAIN"))
334
        {
335
            debug_message("OBJECTS_MAIN layer is disabled in room: " + room_get_name(room));
336
            layer_set_visible("OBJECTS_MAIN", true);
337
        }
338
    }
339
}