Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_church_kris_parry_ripple_Draw_0

(view raw script w/o annotations or w/e)
1
if (!surface_exists(surf))
2
    surf = surface_create(room_width, room_height);
3
active = true;
4
var _ripplecount = ripplecount;
5
if (type == 1)
6
{
7
    _ripplecount = 1;
8
    subrings = 4;
9
}
10
else if (type == 0)
11
{
12
    _ripplecount += 2;
13
}
14
else if (type == 2)
15
{
16
    _ripplecount = 1;
17
}
18
if (type == 2)
19
    subrings = 3;
20
if (active)
21
{
22
    draw_set_color(color);
23
    var _itv = 0;
24
    var _max_radius = max_radius;
25
    if (type == 1)
26
        _max_radius = 520;
27
    if (type == 2)
28
        _max_radius = 100;
29
    if (type == 2 && version == 1)
30
        _max_radius = 120;
31
    var _life = 40;
32
    if (type == 2)
33
        _life = 60;
34
    if (type == 2 && version == 1)
35
        _life = 15;
36
    if (type == 2 && version == 2)
37
        _life = 120;
38
    if (type == 2 && version == 3)
39
        _life = 160;
40
    var _pow = 2;
41
    var _thickness = (type == 1) ? 1 : 1;
42
    var _ringcount = 0;
43
    if (version == 1 || version == 2)
44
    {
45
        if (colortimer < 1)
46
            colortimer += 0.015;
47
        if (colortimer > 1)
48
            colortimer = 1;
49
        color = merge_color(colorstart, c_black, colortimer);
50
    }
51
    if (version == 3)
52
    {
53
        if (colortimer < 1)
54
            colortimer += 0.01;
55
        if (colortimer > 1)
56
            colortimer = 1;
57
        color = merge_color(colorstart, c_black, colortimer);
58
    }
59
    if (type == 1)
60
    {
61
        var _faux_timer = timer;
62
        var _interval = 2;
63
        var _subsize = 1;
64
        if (timer > _life)
65
            timer = _life + (timer % _interval);
66
        var _radius = 
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; } }
(_faux_timer / _life, subrings + 1) * _max_radius;
67
        var _submax = min(1, 
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; } }
(timer / _life, subrings + 1)) * _max_radius;
68
        var _col_index = 0;
69
        draw_set_color(color);
70
        draw_set_alpha(1 - (_col_index / subrings));
71
        surface_set_target(surf);
72
        draw_clear_alpha(c_black, 0);
73
        gpu_set_blendmode_ext(bm_one, bm_zero);
74
        d_circle(x, y, _radius, false);
75
        _faux_timer -= _subsize;
76
        var _first = true;
77
        while (_faux_timer > 0)
78
        {
79
            _radius = 
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; } }
(clamp01(_faux_timer / _life), subrings + 1) * _max_radius;
80
            if (_radius < (_submax + 100))
81
            {
82
            }
83
            _col_index++;
84
            if (_col_index > subrings)
85
                _col_index = 0;
86
            var _alpha = 1 - (_col_index / subrings);
87
            draw_set_alpha(_alpha * clamp01(1 - (((_radius / _max_radius) * 8) - 7)));
88
            d_circle(x, y, _radius, false);
89
            if (_col_index == subrings)
90
            {
91
                _faux_timer -= _interval;
92
                if (_faux_timer <= 0 && looping && deltatime > 1)
93
                {
94
                    looping = false;
95
                    end_timer = _faux_timer;
96
                    debug_print("end timer declared");
97
                }
98
                if (!looping && _faux_timer <= end_timer)
99
                    break;
100
            }
101
            else
102
            {
103
                _faux_timer -= _subsize;
104
            }
105
        }
106
        draw_set_alpha(1);
107
        surface_reset_target();
108
        gpu_set_blendmode(bm_normal);
109
        draw_surface(surf, 0, 0);
110
    }
111
    else
112
    {
113
        for (var i = 0; i < _ripplecount; i++)
114
        {
115
            var _timer = (type == 1) ? fixed_timer : timer;
116
            surface_set_target(surf);
117
            if (type == 1 && _timer < (_life * 0.75))
118
                draw_clear_alpha(c_black, 1);
119
            else
120
                draw_clear_alpha(c_black, 0);
121
            _ringcount++;
122
            var _radius = 
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; } }
(clamp01(inverselerp(0, _life + (i * 30), _timer)), 4) * _max_radius;
123
            var _col = color;
124
            var _alpha = 1 - (((_radius / _max_radius) * 8) - 7);
125
            draw_set_color(_col);
126
            draw_set_alpha(_alpha);
127
            var _oradius = _radius;
128
            gpu_set_blendmode_ext(bm_one, bm_zero);
129
            d_circle(x, y, _radius, false);
130
            var _subradius = _radius;
131
            if ((_timer - 2) < 0)
132
            {
133
                draw_set_alpha(1);
134
                gpu_set_blendmode(bm_normal);
135
                surface_reset_target();
136
                draw_surface(surf, 0, 0);
137
                break;
138
            }
139
            var _prog = 1;
140
            for (var ii = 1; ii < subrings; ii++)
141
            {
142
                _alpha = 1 - (ii / subrings);
143
                _prog = 1 - 
scr_ease_in
scr_ease_in

function
scr_ease_in(arg0, arg1)
{ if (arg1 < -3 || arg1 > 7) return arg0; switch (arg1) { case -3: return ease_in_bounce(arg0, 0, 1, 1); case -2: return ease_in_elastic(arg0, 0, 1, 1); case -1: var _s = 1.70158; return arg0 * arg0 * (((_s + 1) * arg0) - _s); case 0: return arg0; case 1: return -cos(arg0 * 1.5707963267948966) + 1; case 6: return power(2, 10 * (arg0 - 1)); case 7: return -(sqrt(1 - sqr(arg0)) - 1); default: return power(arg0, arg1); } }
(clamp01(_radius / _max_radius), 2);
144
                _alpha = clamp01(_alpha - clamp01(((_radius / _max_radius) * 8) - 7));
145
                draw_set_alpha(_alpha);
146
                if (type == 1)
147
                    _subradius -= (80 + (80 * _prog));
148
                if (type == 2)
149
                    _subradius -= (3 + (3 * _prog));
150
                else
151
                    _subradius -= (4 + (4 * _prog));
152
                if (_subradius > 0)
153
                    d_circle(x, y, _subradius, false);
154
            }
155
            draw_set_color(c_black);
156
            if (type == 0)
157
                _subradius -= (4 + (4 * _prog));
158
            else if (type == 2)
159
                _subradius -= (3 + (3 * _prog));
160
            else
161
                _subradius -= (80 + (80 * _prog));
162
            draw_set_alpha(0);
163
            d_circle(x, y, _subradius, false);
164
            draw_set_alpha(1);
165
            surface_reset_target();
166
            gpu_set_blendmode(bm_normal);
167
            draw_surface(surf, 0, 0);
168
        }
169
    }
170
    timer += deltatime;
171
    fixed_timer++;
172
    if (type == 1 && !looping)
173
    {
174
        end_timer += deltatime;
175
        
scr_debug_print_persistent
scr_debug_print_persistent

function
scr_debug_print_persistent(arg0, arg1)
{ } function debug_print_persistent(arg0, arg1) { } function scr_debug_delete_persistent(arg0, arg1 = false) { } function scr_debug_clear_persistent() { }
("endtimer", string(end_timer));
176
        if (end_timer >= _life)
177
        {
178
            active = false;
179
            instance_destroy();
180
            scr_debug_delete_persistent("endtimer");
181
        }
182
    }
183
    if (type != 1 && (timer - _thickness) >= ((_itv * _ripplecount) + (_life * _ripplecount)))
184
    {
185
        timer = 0;
186
        active = false;
187
        instance_destroy();
188
    }
189
}
190
draw_set_blend_mode(bm_normal);
191
draw_set_alpha(1);
192
draw_set_color(c_white);