Deltarune (Chapter 5) script viewer

← back to main script listing

gml_Object_obj_castlereflect_manager_Draw_72

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

function
scr_battlebg_fullalpha()
{ with (obj_battleback) return image_alpha >= 1; return false; }
())
2
    exit;
3
if (array_get(
scr_platswap_yscale
scr_platswap_yscale

function
scr_platswap_yscale()
{ with (obj_platswap) return __transition_yscale; return [0, 1]; }
(), 0) == 1)
4
    exit;
5
if (!surface_exists(surf))
6
    surf = surface_create(640, 480);
7
if (!surface_exists(precreate_surf))
8
    precreate_surf = surface_create(640, shadow_falloff);
9
if (!surface_exists(masking_surf))
10
{
11
    masking_surf = surface_create(room_width * 0.5, room_height * 0.5);
12
    surface_set_target(masking_surf);
13
    draw_clear_alpha(c_black, 0);
14
    with (obj_spotlight_blocker)
15
        draw_sprite_ext(spr_pxwhite, 0, x * 0.5, y * 0.5, 20 * image_xscale, 20 * image_yscale, image_angle, c_white, 1);
16
    with (obj_reflect_gradient)
17
        draw_sprite_ext(sprite_index, 0, x * 0.5, y * 0.5, image_xscale * 0.5, image_yscale * 0.5, image_angle, c_white, image_alpha);
18
    surface_reset_target();
19
}
20
var _camoffx = _cx;
21
var _camoffy = _cy;
22
shader_replace_simple_set_hook(48);
23
shader_set_uniform_f(u_falloff, shadow_falloff * 1, 0.5);
24
var _tex = surface_get_texture(surf);
25
var _uvs = texture_get_uvs(_tex);
26
shader_set_uniform_f_array(u_uvs, [_uvs[0], _uvs[1], _uvs[2] - _uvs[0], _uvs[3] - _uvs[1]]);
27
surface_set_target(surf);
28
draw_clear_alpha(c_black, 0);
29
var listsize = ds_list_size(this_frame_objects);
30
for (var i = 0; i < listsize; i++)
31
{
32
    with (ds_list_find_value(this_frame_objects, i))
33
    {
34
        var x_offset = 0;
35
        var y_offset = 0;
36
        if (variable_instance_exists(id, "draw_reflection"))
37
        {
38
            draw_reflection(_camoffx, _camoffy, other.u_y);
39
        }
40
        else
41
        {
42
            var refl_off = 0;
43
            var yoff = image_yscale * sprite_get_yoffset(sprite_index);
44
            var sh = (y + (sprite_height * 2)) - _camoffy - yoff - 2;
45
            y_offset = sh;
46
            var _yo = 0;
47
            if (variable_instance_exists(self, "reflect_jump_y"))
48
                refl_off = reflect_jump_y;
49
            if (ds_map_exists(other.sprite_offsets, sprite_index))
50
            {
51
                _yo = array_get(ds_map_find_value(other.sprite_offsets, sprite_index), 1) * image_yscale;
52
                refl_off += (array_get(ds_map_find_value(other.sprite_offsets, sprite_index), 0) * image_yscale);
53
                y_offset += _yo;
54
                x_offset += (array_get(ds_map_find_value(other.sprite_offsets, sprite_index), 2) * image_xscale);
55
            }
56
            var si = sprite_index;
57
            if (ds_map_exists(other.sprite_subs, sprite_index))
58
                si = ds_map_find_value(other.sprite_subs, sprite_index);
59
            if (!sprite_exists(si))
60
            {
61
                debug_print_persistent(string(id), "no sprite for reflection: " + string(object_get_name(object_index)));
62
            }
63
            else
64
            {
65
                shader_set_uniform_f(other.u_y, (y_offset + 8) - sprite_height - 30);
66
                draw_sprite_ext(si, image_index, (x - _camoffx) + x_offset, (y_offset + refl_off) - (2 * yoff) - 8, -image_xscale, image_yscale, 180 + image_angle, image_blend, 1);
67
                x_offset = 0;
68
            }
69
        }
70
    }
71
}
72
surface_reset_target();
73
shader_replace_simple_reset_hook();
74
_tex = surface_get_texture(surf);
75
surface_uvs = texture_get_uvs(_tex);