Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_darkness_overlay_backup_Draw_0

(view raw script w/o annotations or w/e)
1
if (sunkus_kb_check_pressed(66))
2
    active = !active;
3
image_alpha = 
scr_movetowards
scr_movetowards

function
scr_movetowards(arg0, arg1, arg2)
{ if (arg0 == arg1) return arg0; else if (arg0 > arg1) return max(arg0 - arg2, arg1); else return min(arg0 + arg2, arg1); } function scr_obj_movetowards_obj(arg0, arg1, arg2 = 0, arg3 = 0) { scr_obj_movetowards_point(arg0.x + arg2, arg0.y + arg3, arg1); } function scr_obj_movetowards_point(arg0, arg1, arg2) { var _distance = point_distance(x, y, arg0, arg1); if (arg2 >= _distance) { x = arg0; y = arg1; } else { var _direction = point_direction(x, y, arg0, arg1); x += lengthdir_x(arg2, _direction); y += lengthdir_y(arg2, _direction); } }
(image_alpha, active ? max_darkness : min_darkness, 0.05);
4
if (image_alpha == 0)
5
    exit;
6
if (!surface_exists(darkness_surf))
7
    darkness_surf = surface_create(640, 480);
8
if (!surface_exists(upper_surf))
9
    upper_surf = surface_create(640, 480);
10
if (!surface_exists(lower_surf))
11
    lower_surf = surface_create(640, 480);
12
surface_set_target(darkness_surf);
13
draw_set_blend_mode(bm_normal);
14
draw_clear(c_black);
15
with (obj_lightsource_behind)
16
    event_user(6);
17
surface_reset_target();
18
surface_set_target(lower_surf);
19
draw_set_blend_mode(bm_normal);
20
draw_clear_alpha(c_black, 0);
21
var _arrayCount = 0;
22
var _upperArrayCount = 0;
23
var _upper_array;
24
with (obj_mainchara)
25
{
26
    if (floorheight >= 1)
27
    {
28
        _upper_array[_upperArrayCount] = self;
29
        _upperArrayCount++;
30
    }
31
    else
32
    {
33
        _char_array[_arrayCount] = self;
34
        _arrayCount++;
35
    }
36
}
37
with (obj_caterpillarchara)
38
{
39
    _char_array[_arrayCount] = self;
40
    _arrayCount++;
41
}
42
with (obj_npc_room)
43
{
44
    _char_array[_arrayCount] = self;
45
    _arrayCount++;
46
}
47
with (obj_npc_room_animated)
48
{
49
    _char_array[_arrayCount] = self;
50
    _arrayCount++;
51
}
52
with (obj_darkness_unlit_object_interactable)
53
{
54
    _char_array[_arrayCount] = self;
55
    _arrayCount++;
56
}
57
with (obj_character_church_window_silhouette)
58
{
59
    _char_array[_arrayCount] = self;
60
    _arrayCount++;
61
}
62
with (obj_darkness_unlit_object)
63
{
64
    _char_array[_arrayCount] = self;
65
    _arrayCount++;
66
}
67
with (obj_darkness_bullet)
68
{
69
    _char_array[_arrayCount] = self;
70
    _arrayCount++;
71
}
72
with (obj_dw_church_pushableshelf_3x3)
73
{
74
    _char_array[_arrayCount] = self;
75
    _arrayCount++;
76
}
77
var _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);
78
if (_upperArrayCount > 0)
79
    _upper_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; }
(_upper_array, false);
80
if (castShadow)
81
{
82
    for (i = 0; i < _arrayCount; i++)
83
    {
84
        target_object = _char_array[i];
85
        event_user(0);
86
    }
87
}
88
battlemode = false;
89
if (instance_exists(obj_battleLayerHighlight))
90
{
91
    battlemode = true;
92
    with (obj_battleLayerHighlight)
93
    {
94
        show_border = 0;
95
        if (sprite_exists(spr_battleborder))
96
        {
97
            d3d_set_fog(true, #202020, 0, 1);
98
            draw_sprite_ext(spr_battleborder, 0, -camerax(), -cameray(), 1, 1, 0, c_white, 1);
99
            d3d_set_fog(false, c_white, 0, 0);
100
            draw_sprite_ext(spr_battleborder, 0, -camerax(), -cameray(), 1, 1, 0, c_white, myalpha);
101
        }
102
    }
103
}
104
for (i = 0; i < _arrayCount; i++)
105
{
106
    target_object = _char_array[i];
107
    event_user(1);
108
}
109
surface_reset_target();
110
if (_upperArrayCount > 0)
111
{
112
    surface_set_target(upper_surf);
113
    draw_clear_alpha(c_black, 0);
114
    for (i = 0; i < _upperArrayCount; i++)
115
    {
116
        target_object = _upper_array[i];
117
        event_user(0);
118
    }
119
    if (battlemode)
120
    {
121
        with (obj_battleLayerHighlight)
122
        {
123
            show_border = 0;
124
            if (sprite_exists(spr_battleborder))
125
            {
126
                d3d_set_fog(true, #202020, 0, 1);
127
                draw_sprite_ext(spr_battleborder, 0, -camerax(), -cameray(), 1, 1, 0, c_white, 1);
128
                d3d_set_fog(false, c_white, 0, 0);
129
                draw_sprite_ext(spr_battleborder, 0, -camerax(), -cameray(), 1, 1, 0, c_white, myalpha);
130
            }
131
        }
132
    }
133
    for (i = 0; i < _upperArrayCount; i++)
134
    {
135
        target_object = _upper_array[i];
136
        event_user(1);
137
    }
138
}
139
surface_reset_target();
140
surface_set_target(darkness_surf);
141
draw_surface(lower_surf, 0, 0);
142
if (_upperArrayCount > 0)
143
    draw_surface(upper_surf, 0, 0);
144
draw_set_blend_mode(bm_subtract);
145
with (obj_lightsource)
146
    event_user(6);
147
surface_reset_target();
148
draw_set_blend_mode(bm_normal);
149
draw_surface_ext(darkness_surf, camerax(), cameray(), 1, 1, 0, c_white, 0.5 * image_alpha);