Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_darkness_overlay_Draw_0

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

function
scr_debug()
{ if (global.debug == 1) return 1; }
())
2
{
3
    if (sunkus_kb_check_pressed(86))
4
        faded = !faded;
5
    if (sunkus_kb_check_pressed(66))
6
        active = !active;
7
}
8
var drawoutline = draw_silhouettes;
9
var drawripples = false;
10
if (instance_exists(obj_dw_church_intro_gerson))
11
    drawoutline = false;
12
if (instance_exists(obj_dw_church_darkclimb))
13
    drawoutline = false;
14
if (instance_exists(obj_dw_churchc_darkswords))
15
    drawoutline = false;
16
if (instance_exists(obj_dw_churchc_dodge))
17
    drawoutline = false;
18
if (instance_exists(obj_dw_churchc_ripplesneak_poc))
19
    drawoutline = false;
20
if (instance_exists(obj_dw_churchc_ripplesneak_poc))
21
    drawripples = true;
22
if (i_ex(obj_overworld_darkness_bulletarea))
23
    obj_overworld_darkness_bulletarea.active = active;
24
if (!active)
25
    exit;
26
if (image_alpha == 0)
27
    exit;
28
if (!surface_exists(darkness_surf))
29
    darkness_surf = surface_create(640, 480);
30
if (!surface_exists(dim_surf))
31
    dim_surf = surface_create(640, 480);
32
surface_set_target(dim_surf);
33
draw_set_blend_mode(bm_normal);
34
draw_clear(c_black);
35
if (drawripples)
36
{
37
    var map_id = 
scr_layer_tilemap_get_id_fixed
scr_layer_tilemap_get_id_fixed

function
scr_layer_tilemap_get_id_fixed(arg0)
{ var els = layer_get_all_elements(arg0); var n = array_length_1d(els); for (var i = 0; i < n; i++) { var el = els[i]; if (layer_get_element_type(el) == 5) return el; } return -1; }
("TILES_BATTLEBORDER");
38
    draw_tilemap(map_id, -camerax(), -cameray());
39
    with (obj_church_ripple)
40
    {
41
        if (!dodraw)
42
        {
43
            x -= camerax();
44
            y -= cameray();
45
            event_user(10);
46
            x += camerax();
47
            y += cameray();
48
        }
49
    }
50
    with (obj_dw_church_waterfallchaser_churchc)
51
    {
52
        x -= camerax();
53
        y -= cameray();
54
        draw_self();
55
        x += camerax();
56
        y += cameray();
57
    }
58
}
59
with (obj_lightsource_behind)
60
    event_user(6);
61
var _arrayCount = 0;
62
var _char_array;
63
with (obj_mainchara)
64
{
65
    if (visible)
66
    {
67
        _char_array[_arrayCount] = self;
68
        _arrayCount++;
69
    }
70
}
71
if (drawoutline)
72
{
73
    var krcol = 15245824;
74
    var sucol = 13138410;
75
    var racol = 1959605;
76
    var gercol = 4580517;
77
    var nocol = 12320748;
78
    with (obj_actor)
79
    {
80
        if (visible)
81
        {
82
            _char_array[_arrayCount] = self;
83
            _arrayCount++;
84
        }
85
    }
86
    with (obj_dw_church_turtles)
87
    {
88
        with (gerson)
89
        {
90
            outlineColor = gercol;
91
            _char_array[_arrayCount] = id;
92
            _arrayCount++;
93
        }
94
    }
95
    with (obj_dw_church_intro_gerson)
96
    {
97
        if (i_ex(gerson))
98
        {
99
            if (gerson.visible)
100
            {
101
                _char_array[_arrayCount] = gerson;
102
                _arrayCount++;
103
            }
104
        }
105
    }
106
    with (obj_dw_church_bookshelfpuzzle)
107
    {
108
        if (i_ex(ranpc))
109
        {
110
            with (ranpc.marker)
111
            {
112
                outlineColor = racol;
113
                _char_array[_arrayCount] = id;
114
                _arrayCount++;
115
            }
116
        }
117
        if (i_ex(sunpc))
118
        {
119
            with (sunpc.marker)
120
            {
121
                outlineColor = sucol;
122
                _char_array[_arrayCount] = id;
123
                _arrayCount++;
124
            }
125
        }
126
    }
127
    with (obj_dw_church_pianopiece_right)
128
    {
129
        if (i_ex(ranpc))
130
        {
131
            with (ranpc.marker)
132
            {
133
                outlineColor = racol;
134
                _char_array[_arrayCount] = id;
135
                _arrayCount++;
136
            }
137
        }
138
        if (i_ex(sunpc))
139
        {
140
            with (sunpc.marker)
141
            {
142
                outlineColor = sucol;
143
                _char_array[_arrayCount] = id;
144
                _arrayCount++;
145
            }
146
        }
147
    }
148
    with (obj_caterpillarchara)
149
    {
150
        if (visible)
151
        {
152
            _char_array[_arrayCount] = self;
153
            _arrayCount++;
154
        }
155
    }
156
    with (obj_npc_room)
157
    {
158
        if (visible)
159
        {
160
            _char_array[_arrayCount] = self;
161
            _arrayCount++;
162
        }
163
    }
164
    with (obj_npc_room_animated)
165
    {
166
        if (visible)
167
        {
168
            _char_array[_arrayCount] = self;
169
            _arrayCount++;
170
        }
171
    }
172
    with (obj_dw_church_darkmaze)
173
    {
174
        if (i_ex(gerson))
175
        {
176
            if (gerson.visible)
177
            {
178
                _char_array[_arrayCount] = gerson;
179
                _arrayCount++;
180
            }
181
        }
182
        if (i_ex(germark))
183
        {
184
            if (germark.visible)
185
            {
186
                _char_array[_arrayCount] = germark;
187
                _arrayCount++;
188
            }
189
        }
190
        if (i_ex(sumark))
191
        {
192
            if (sumark.visible)
193
            {
194
                _char_array[_arrayCount] = sumark;
195
                _arrayCount++;
196
            }
197
        }
198
        if (i_ex(ramark))
199
        {
200
            if (ramark.visible)
201
            {
202
                _char_array[_arrayCount] = ramark;
203
                _arrayCount++;
204
            }
205
        }
206
    }
207
}
208
with (obj_darkness_unlit_object_interactable)
209
{
210
    _char_array[_arrayCount] = self;
211
    _arrayCount++;
212
}
213
with (obj_character_church_window_silhouette)
214
{
215
    _char_array[_arrayCount] = self;
216
    _arrayCount++;
217
}
218
with (obj_darkness_unlit_object)
219
{
220
    _char_array[_arrayCount] = self;
221
    _arrayCount++;
222
}
223
with (obj_marker_darkness_unlit)
224
{
225
    if (sprite_exists(sprite_index))
226
    {
227
        _char_array[_arrayCount] = self;
228
        _arrayCount++;
229
    }
230
}
231
with (obj_darkness_bullet)
232
{
233
    _char_array[_arrayCount] = self;
234
    _arrayCount++;
235
}
236
if (_arrayCount > 1)
237
    _char_array = 
scr_sort_by_depth
scr_sort_by_depth

function
scr_sort_by_depth(arg0, arg1)
{ if (arg1) { array_sort(arg0, function(arg0, arg1) { return arg0.depth - arg1.depth; }); } else { array_sort(arg0, function(arg0, arg1) { return arg1.depth - arg0.depth; }); } return arg0; } function scr_sort_by_depth_old(arg0, arg1) { var _array = arg0; var _ascending = arg1; var _array_length = array_length(arg0); var _loopStart = 1; var _depth_array; for (i = 0; i < _array_length; i++) _depth_array[i] = _array[i].depth; var _tempValue = 0; var _loopAgain = true; while (_loopAgain == true) { _loopAgain = false; for (i = _loopStart; i < _array_length; i++) { if (i == _loopStart) _loopStart = _array_length - 1; if (_depth_array[i] == _depth_array[i - 1]) { if (_ascending == (real(_array[i].id) > real(_array[i - 1].id))) continue; } if (_ascending == (_depth_array[i] < _depth_array[i - 1]) || _depth_array[i] == _depth_array[i - 1]) { _loopAgain = true; _tempValue = _depth_array[i - 1]; _depth_array[i - 1] = _depth_array[i]; _depth_array[i] = _tempValue; _tempValue = _array[i - 1]; _loopStart = min(_loopStart, max(i - 1, 1)); _array[i - 1] = _array[i]; _array[i] = _tempValue; } } } return _array; }
(_char_array, false);
238
if (castShadow)
239
{
240
    for (var i = 0; i < _arrayCount; i++)
241
    {
242
        with (_char_array[i])
243
        {
244
            if (object_index == obj_character_church_window_silhouette || object_index == obj_darkness_unlit_object || object_index == obj_darkness_illusion || object_index == obj_darkness_bullet || object_index == obj_marker_darkness_unlit)
245
            {
246
                continue;
247
            }
248
            else
249
            {
250
                var _forceOff = false;
251
                var _yoff = 4;
252
                if (object_index == obj_caterpillarchara)
253
                {
254
                    if (shadow_force_off)
255
                    {
256
                        _forceOff = true;
257
                    }
258
                    else if (name == "susie")
259
                    {
260
                        _yoff = 0;
261
                    }
262
                    else if (name == "ralsei")
263
                    {
264
                        if (facing[target] == 0)
265
                            _yoff = 8;
266
                        else if (facing[target] == 2)
267
                            _yoff = 12;
268
                    }
269
                }
270
                if (!_forceOff)
271
                    draw_sprite_ext(sprite_index, image_index, screenx(), (screeny() + ((sprite_height - sprite_yoffset) * 2)) - _yoff, image_xscale, -image_yscale, image_angle, c_black, image_alpha);
272
            }
273
        }
274
    }
275
}
276
var _battlemode = false;
277
with (obj_growtangle)
278
{
279
    with (obj_mainchara)
280
    {
281
        if (battlemode)
282
            _battlemode = true;
283
    }
284
}
285
if (instance_exists(obj_growtangle))
286
{
287
    with (obj_ghosthouse_lock)
288
    {
289
        _blend = merge_color(image_blend, c_black, other.fade_in);
290
        draw_sprite_ext(sprite_index, 0, x - camerax(), y - cameray(), image_xscale, image_yscale, image_angle, _blend, image_alpha);
291
    }
292
    with (obj_lightsource_lamp)
293
    {
294
        _blend = merge_color(image_blend, c_black, other.fade_in);
295
        draw_sprite_ext(sprite_index, 0, x - camerax(), y - cameray(), image_xscale, image_yscale, image_angle, _blend, image_alpha);
296
    }
297
    with (obj_battlesolid)
298
    {
299
        if (sprite_index == spr_ghost_house_the_chimney || other.draw_all_solids)
300
        {
301
            _blend = merge_color(image_blend, c_black, other.fade_in);
302
            draw_sprite_ext(sprite_index, 0, x - camerax(), y - cameray(), image_xscale, image_yscale, image_angle, _blend, image_alpha);
303
        }
304
    }
305
    with (obj_growtangle)
306
    {
307
        if (growcon != 3 && visible)
308
        {
309
            _blend = merge_color(image_blend, c_black, other.fade_in);
310
            draw_sprite_ext(sprite_index, 0, x - camerax(), y - cameray(), image_xscale, image_yscale, image_angle, _blend, image_alpha);
311
        }
312
    }
313
    with (obj_ghosthouse_jackolantern_merciful)
314
    {
315
        if (scare_con >= 1)
316
        {
317
            draw_sprite_ext(head_sprite, 0, screenx(), screeny(), image_xscale, image_yscale, image_angle, image_blend, image_alpha);
318
            var _spimmer = 
scr_ease_out
scr_ease_out

function
scr_ease_out(arg0, arg1)
{ if (arg1 < -3 || arg1 > 7) return arg0; switch (arg1) { case -3: return ease_out_bounce(arg0, 0, 1, 1); case -2: return ease_out_elastic(arg0, 0, 1, 1); case -1: return ease_out_back(arg0, 0, 1, 1); case 0: return arg0; case 1: return sin(arg0 * 1.5707963267948966); case 2: return -arg0 * (arg0 - 2); case 6: return -power(2, -10 * arg0) + 1; case 7: arg0--; return sqrt(1 - (arg0 * arg0)); default: arg0--; if (arg1 == 4) { return -1 * (power(arg0, arg1) - 1); break; } return power(arg0, arg1) + 1; } }
(face_timer / 40, -2) * 180;
319
            draw_sprite_ext(mouth_sprite, 0, screenx(), screeny() + 20, image_xscale, image_yscale, image_angle + _spimmer, image_blend, image_alpha);
320
        }
321
        else if (funny)
322
        {
323
            _blend = merge_color(image_blend, c_black, other.fade_in);
324
            draw_sprite_pos(sprite_index, image_index, screenx(sx[0]), screeny(sy[0]), screenx(sx[1]), screeny(sy[1]), screenx(sx[2]), screeny(sy[2]), screenx(sx[3]), screeny(sy[3]), brightness);
325
        }
326
        else if (ticks > 0)
327
        {
328
            _blend = merge_color(image_blend, c_black, other.fade_in);
329
            draw_sprite_ext(sprite_index, image_index, screenx() + shakex, screeny() + shakey, image_xscale, image_yscale, image_angle, _blend, image_alpha);
330
        }
331
        else
332
        {
333
            _blend = merge_color(image_blend, c_black, other.fade_in);
334
            draw_sprite_ext(sprite_index, image_index, screenx(), screeny(), image_xscale, image_yscale, image_angle, _blend, image_alpha);
335
        }
336
        if (total_ticks > 0 || screamcon == 2)
337
        {
338
            gpu_set_fog(true, c_white, 0, 1000);
339
            if (funny)
340
                draw_sprite_pos(sprite_index, image_index, screenx(sx[0]), screeny(sy[0]), screenx(sx[1]), screeny(sy[1]), screenx(sx[2]), screeny(sy[2]), screenx(sx[3]), screeny(sy[3]), brightness);
341
            else
342
                draw_sprite_ext(sprite_index, image_index, screenx() + shakex, screeny() + shakey, image_xscale, image_yscale, image_angle, image_blend, brightness);
343
        }
344
        gpu_set_fog(false, c_white, 0, 1000);
345
    }
346
    var _blend = merge_color(image_blend, c_black, fade_in);
347
    draw_sprite_ext(sprite_index, 0, x - camerax(), y - cameray(), image_xscale, image_yscale, image_angle, _blend, image_alpha);
348
}
349
for (var i = 0; i < _arrayCount; i++)
350
{
351
    with (_char_array[i])
352
    {
353
        if (object_index == obj_character_church_window_silhouette)
354
        {
355
            event_user(6);
356
        }
357
        else
358
        {
359
            if (object_index == obj_darkness_unlit_object || object_index == obj_darkness_illusion || object_index == obj_marker_darkness_unlit)
360
            {
361
                draw_sprite_ext(sprite_index, image_index, x - camerax(), y - cameray(), image_xscale, image_yscale, image_angle, image_blend, image_alpha);
362
                continue;
363
            }
364
            else if (object_index == obj_darkness_bullet)
365
            {
366
                draw_sprite_ext(dark_sprite, image_index, x - camerax(), y - cameray(), image_xscale, image_yscale, image_angle, image_blend, image_alpha);
367
                continue;
368
            }
369
            if (!iv_ex(_char_array[i], "outlineColor"))
370
            {
371
                if (other.outline_style == 0)
372
                    outlineColor = other.outline_default;
373
                else
374
                    outlineColor = 
scr_get_outline_color
scr_get_outline_color

function
scr_get_outline_color(arg0, arg1 = 8421504, arg2 = 1)
{ var col = arg1; var krcol = 15245824; var sucol = 13138410; var racol = 1959605; var gercol = 2533989; var nocol = 12320748; if (arg2 == 2) { col = 12736850; krcol = 13462088; sucol = 10305336; racol = 13265482; gercol = 12736850; nocol = 12736850; } if (arg0.object_index == obj_mainchara) col = krcol; if (arg0.object_index == obj_caterpillarchara) { if (arg0.name == "susie") col = sucol; else if (arg0.name == "ralsei") col = racol; else if (arg0.name == "noelle") col = nocol; else return 8421504; } if (object_get_parent(arg0.object_index) == 1276) { if (arg0.object_index == obj_herokris) col = krcol; else if (arg0.object_index == obj_herosusie) col = sucol; else if (arg0.object_index == obj_heroralsei) col = racol; else if (arg0.object_index == obj_heronoelle) col = nocol; } if (arg0.object_index == obj_actor) { if (arg0.name == "kris") col = krcol; if (arg0.name == "susie") col = sucol; if (arg0.name == "ralsei") col = racol; if (arg0.name == "noelle") col = nocol; if (arg0.name == "gerson") col = gercol; } if (room == room_dw_church_darkmaze) { with (obj_dw_church_darkmaze) { if (arg0 == germark) col = gercol; if (arg0 == gerson) col = gercol; if (arg0 == sumark) col = sucol; if (arg0 == ramark) col = racol; } } if (room == room_dw_church_intro_gerson) { with (obj_dw_church_intro_gerson) { if (arg0 == gerson) col = gercol; } } return col; }
(_char_array[i], other.outline_default, other.outline_style);
375
            }
376
            var _outlineColor = merge_color(c_black, outlineColor, other.highlightalpha);
377
            if (i_ex(id) && image_alpha < 1 && visible)
378
            {
379
            }
380
            if (_battlemode && obj_battlealphaer.battlealpha > 0)
381
                _outlineColor = merge_color(_outlineColor, c_black, 1);
382
            if (drawoutline)
383
            {
384
                d3d_set_fog(true, _outlineColor, 0, 1);
385
                draw_sprite_ext(sprite_index, image_index, x - camerax(), y - cameray(), image_xscale, image_yscale, image_angle, image_blend, image_alpha);
386
                d3d_set_fog(false, c_black, 0, 1);
387
                gpu_set_alphatestenable(true);
388
                gpu_set_blendmode_ext_sepalpha(bm_src_alpha, bm_inv_src_alpha, bm_dest_alpha, bm_zero);
389
                draw_sprite_ext(sprite_index, image_index, x - camerax(), (y - cameray()) + 2, image_xscale, image_yscale, image_angle, c_black, image_alpha);
390
                draw_set_blend_mode(bm_normal);
391
                gpu_set_alphatestenable(false);
392
            }
393
            if (object_index == obj_mainchara && _battlemode && battlealpha > 0)
394
            {
395
                if (fun == 0)
396
                {
397
                    if (global.facing == 0)
398
                        draw_sprite_ext(spr_krisd_heart_outline, image_index, screenx(), screeny(), image_xscale, image_yscale, 0, image_blend, battlealpha);
399
                    if (global.facing == 1)
400
                        draw_sprite_ext(spr_krisr_heart_outline, image_index, screenx(), screeny(), image_xscale, image_yscale, 0, image_blend, battlealpha);
401
                    if (global.facing == 2)
402
                        draw_sprite_ext(spr_krisu_heart_outline, image_index, screenx(), screeny(), image_xscale, image_yscale, 0, image_blend, battlealpha);
403
                    if (global.facing == 3)
404
                        draw_sprite_ext(spr_krisl_heart_outline, image_index, screenx(), screeny(), image_xscale, image_yscale, 0, image_blend, battlealpha);
405
                }
406
                else if (sprite_index == spr_krisd_slide)
407
                {
408
                    draw_sprite_ext(spr_krisd_slide_heart_outline, image_index, x, y, image_xscale, image_yscale, 0, image_blend, battlealpha);
409
                }
410
                draw_sprite_ext(spr_heart_outline2, 0, screenx() + 12, screeny() + 40, 1, 1, 0, c_white, battlealpha * 2);
411
            }
412
        }
413
    }
414
}
415
draw_set_blend_mode(bm_subtract);
416
with (obj_lightsource)
417
    event_user(6);
418
surface_reset_target();
419
draw_set_blend_mode(bm_normal);
420
surface_set_target(darkness_surf);
421
draw_clear_alpha(c_black, 0);
422
surface_reset_target();
423
surface_copy(darkness_surf, 0, 0, dim_surf);
424
surface_set_target(darkness_surf);
425
draw_set_blend_mode(bm_subtract);
426
with (obj_lightsource)
427
    event_user(7);
428
surface_reset_target();
429
draw_set_blend_mode(bm_normal);
430
draw_surface_ext(dim_surf, camerax(), cameray(), 1, 1, 0, c_white, 0.5 * image_alpha);
431
draw_surface_ext(darkness_surf, camerax(), cameray(), 1, 1, 0, c_white, image_alpha);
432
with (obj_marker)
433
{
434
    if (variable_instance_exists(id, "glow"))
435
    {
436
        if (glow == true)
437
            draw_self();
438
    }
439
    else
440
    {
441
        glow = false;
442
    }
443
}