Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_darkness_overlay_twofloor_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(dim_surf))
9
    dim_surf = surface_create(640, 480);
10
if (!surface_exists(object_surf))
11
    object_surf = surface_create(640, 480);
12
surface_set_target(dim_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(object_surf);
19
draw_set_blend_mode(bm_normal);
20
draw_clear_alpha(c_black, 0);
21
var _arrayCount = 0;
22
var _upperFloor = false;
23
var _lowerObjCount = 0;
24
with (obj_mainchara)
25
{
26
    _char_array[_arrayCount] = self;
27
    _arrayCount++;
28
    if (floorheight >= 1)
29
        _upperFloor = true;
30
}
31
with (obj_caterpillarchara)
32
{
33
    _char_array[_arrayCount] = self;
34
    _arrayCount++;
35
}
36
with (obj_npc_room)
37
{
38
    _char_array[_arrayCount] = self;
39
    _arrayCount++;
40
}
41
with (obj_npc_room_animated)
42
{
43
    _char_array[_arrayCount] = self;
44
    _arrayCount++;
45
}
46
with (obj_darkness_unlit_object_interactable)
47
{
48
    _char_array[_arrayCount] = self;
49
    _arrayCount++;
50
}
51
with (obj_character_church_window_silhouette)
52
{
53
    _char_array[_arrayCount] = self;
54
    _arrayCount++;
55
}
56
with (obj_darkness_unlit_object)
57
{
58
    _char_array[_arrayCount] = self;
59
    _arrayCount++;
60
}
61
with (obj_darkness_bullet)
62
{
63
    _char_array[_arrayCount] = self;
64
    _arrayCount++;
65
}
66
with (obj_dw_church_pushableshelf_3x3)
67
{
68
    _char_array[_arrayCount] = self;
69
    _arrayCount++;
70
    if (_upperFloor)
71
        _lowerObjCount++;
72
}
73
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);
74
if (castShadow)
75
{
76
    for (i = 0; i < _arrayCount; i++)
77
    {
78
        with (_char_array[i])
79
        {
80
            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_dw_church_pushableshelf_darklight)
81
            {
82
                continue;
83
            }
84
            else
85
            {
86
                var _yoff = 4;
87
                if (object_index == obj_caterpillarchara)
88
                {
89
                    if (name == "susie")
90
                    {
91
                        _yoff = 0;
92
                    }
93
                    else if (name == "ralsei")
94
                    {
95
                        if (facing[target] == 0)
96
                            _yoff = 8;
97
                        else if (facing[target] == 2)
98
                            _yoff = 12;
99
                    }
100
                }
101
                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);
102
            }
103
        }
104
    }
105
}
106
var _battlemode = false;
107
if (instance_exists(obj_battleLayerHighlight))
108
{
109
    _battlemode = true;
110
    with (obj_battleLayerHighlight)
111
    {
112
        show_border = 0;
113
        if (sprite_exists(spr_battleborder))
114
        {
115
            d3d_set_fog(true, #202020, 0, 1);
116
            draw_sprite_ext(spr_battleborder, 0, -camerax(), -cameray(), 1, 1, 0, c_white, 1);
117
            d3d_set_fog(false, c_white, 0, 0);
118
            draw_sprite_ext(spr_battleborder, 0, -camerax(), -cameray(), 1, 1, 0, c_white, myalpha);
119
        }
120
    }
121
}
122
for (i = 0; i < _arrayCount; i++)
123
{
124
    var _castShadow = castShadow;
125
    if (castShadow && _upperFloor && _lowerObjCount == 0)
126
    {
127
        _upperFloor = false;
128
        for (i2 = 0; i2 < _arrayCount; i2++)
129
        {
130
            with (_char_array[i2])
131
            {
132
                if (object_index != obj_caterpillarchara && object_index != obj_mainchara)
133
                {
134
                    continue;
135
                }
136
                else
137
                {
138
                    var _yoff = 4;
139
                    if (object_index == obj_caterpillarchara)
140
                    {
141
                        if (special[target] == 1)
142
                            continue;
143
                        if (name == "susie")
144
                        {
145
                            _yoff = 0;
146
                        }
147
                        else if (name == "ralsei")
148
                        {
149
                            if (facing[target] == 0)
150
                                _yoff = 8;
151
                            else if (facing[target] == 2)
152
                                _yoff = 12;
153
                        }
154
                    }
155
                    else if (object_index == obj_mainchara && climbing)
156
                    {
157
                        continue;
158
                    }
159
                    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);
160
                }
161
            }
162
        }
163
    }
164
    with (_char_array[i])
165
    {
166
        if (object_index == obj_dw_church_pushableshelf_darklight)
167
        {
168
            draw_set_blend_mode(bm_subtract);
169
            draw_sprite_ext(sprite_index, image_index, screenx(), screeny(), image_xscale, image_yscale, 0, c_black, 1);
170
            draw_set_blend_mode(bm_normal);
171
            if (_upperFloor)
172
                _lowerObjCount--;
173
        }
174
        else if (object_index == obj_character_church_window_silhouette)
175
        {
176
            event_user(6);
177
        }
178
        else
179
        {
180
            if (object_index == obj_darkness_unlit_object || object_index == obj_darkness_illusion)
181
            {
182
                draw_sprite_ext(sprite_index, image_index, x - camerax(), y - cameray(), image_xscale, image_yscale, image_angle, image_blend, image_alpha);
183
                continue;
184
            }
185
            else if (object_index == obj_darkness_bullet)
186
            {
187
                draw_sprite_ext(dark_sprite, image_index, x - camerax(), y - cameray(), image_xscale, image_yscale, image_angle, image_blend, image_alpha);
188
                continue;
189
            }
190
            var _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; }
(self);
191
            var _xoff = 0;
192
            if (_battlemode && obj_battlealphaer.battlealpha > 0)
193
                _outlineColor = merge_color(_outlineColor, c_black, obj_battlealphaer.battlealpha);
194
            d3d_set_fog(true, _outlineColor, 0, 1);
195
            draw_sprite_ext(sprite_index, image_index, screenx(), screeny(), image_xscale, image_yscale, image_angle, image_blend, image_alpha);
196
            d3d_set_fog(false, c_black, 0, 1);
197
            gpu_set_alphatestenable(true);
198
            gpu_set_blendmode_ext_sepalpha(bm_src_alpha, bm_inv_src_alpha, bm_dest_alpha, bm_zero);
199
            draw_sprite_ext(sprite_index, image_index, screenx(), screeny() + 2, image_xscale, image_yscale, image_angle, c_black, image_alpha);
200
            draw_set_blend_mode(bm_normal);
201
            gpu_set_alphatestenable(false);
202
            if (object_index == obj_mainchara && _battlemode && battlealpha > 0)
203
            {
204
                if (fun == 0)
205
                {
206
                    if (global.facing == 0)
207
                        draw_sprite_ext(spr_krisd_heart_outline, image_index, screenx(), screeny(), image_xscale, image_yscale, 0, image_blend, battlealpha);
208
                    if (global.facing == 1)
209
                        draw_sprite_ext(spr_krisr_heart_outline, image_index, screenx(), screeny(), image_xscale, image_yscale, 0, image_blend, battlealpha);
210
                    if (global.facing == 2)
211
                        draw_sprite_ext(spr_krisu_heart_outline, image_index, screenx(), screeny(), image_xscale, image_yscale, 0, image_blend, battlealpha);
212
                    if (global.facing == 3)
213
                        draw_sprite_ext(spr_krisl_heart_outline, image_index, screenx(), screeny(), image_xscale, image_yscale, 0, image_blend, battlealpha);
214
                }
215
                else if (sprite_index == spr_krisd_slide)
216
                {
217
                    draw_sprite_ext(spr_krisd_slide_heart_outline, image_index, x, y, image_xscale, image_yscale, 0, image_blend, battlealpha);
218
                }
219
                draw_sprite_ext(spr_heart_outline2, 0, screenx() + 12, screeny() + 40, 1, 1, 0, c_white, battlealpha * 2);
220
            }
221
        }
222
    }
223
}
224
surface_reset_target();
225
surface_set_target(dim_surf);
226
draw_surface(object_surf, 0, 0);
227
draw_set_blend_mode(bm_subtract);
228
with (obj_lightsource)
229
    event_user(6);
230
surface_reset_target();
231
draw_set_blend_mode(bm_normal);
232
surface_set_target(darkness_surf);
233
draw_clear_alpha(c_black, 0);
234
surface_reset_target();
235
surface_copy(darkness_surf, 0, 0, dim_surf);
236
surface_set_target(darkness_surf);
237
draw_set_blend_mode(bm_subtract);
238
with (obj_lightsource)
239
    event_user(7);
240
surface_reset_target();
241
draw_set_blend_mode(bm_normal);
242
draw_surface_ext(dim_surf, camerax(), cameray(), 1, 1, 0, c_white, 0.5 * image_alpha);
243
draw_surface_ext(darkness_surf, camerax(), cameray(), 1, 1, 0, c_white, image_alpha);