Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_church_old_man_ripple_effect_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
if (type == 3 || type == 4)
4
{
5
    with (obj_church_old_man_ripple)
6
        event_user(0);
7
}
8
var _ripplecount = ripplecount;
9
if (type == 1)
10
{
11
    _ripplecount = 1;
12
    subrings = 4;
13
}
14
else if (type == 0)
15
{
16
    _ripplecount += 2;
17
}
18
else if (type == 2)
19
{
20
    _ripplecount = 1;
21
}
22
if (type == 2)
23
    subrings = 3;
24
if (type == 3)
25
{
26
    subrings = 3;
27
    _ripplecount = 1;
28
}
29
if (type == 5 || type == 6)
30
{
31
    _ripplecount = 1;
32
    color = c_lime;
33
}
34
if (type == 7)
35
    _ripplecount = 3;
36
if (active)
37
{
38
    draw_set_color(color);
39
    var _itv = 0;
40
    var _max_radius = max_radius;
41
    if (type == 1)
42
        _max_radius = 520;
43
    if (type == 2)
44
        _max_radius = 100;
45
    if (type == 2 && version == 1)
46
        _max_radius = 120;
47
    var _life = 40;
48
    if (type == 2)
49
        _life = 60;
50
    if (type == 2 && version == 1)
51
        _life = 15;
52
    if (type == 2 && version == 2)
53
        _life = 120;
54
    if (type == 2 && version == 3)
55
        _life = 160;
56
    if (type == 7)
57
        _life = 80;
58
    var _pow = 2;
59
    var _thickness = (type == 1) ? 1 : 1;
60
    var _ringcount = 0;
61
    if (type == 3)
62
    {
63
        _ripplecount = 1;
64
        _max_radius = 140;
65
    }
66
    else if (type == 4)
67
    {
68
        _max_radius = 300;
69
    }
70
    if (type == 5)
71
    {
72
        _max_radius = 180;
73
        if ((punch % 2) == 1)
74
            _max_radius += 20;
75
    }
76
    if (type == 7)
77
        _max_radius = 240;
78
    if (version == 1 || version == 2)
79
    {
80
        if (colortimer < 1)
81
            colortimer += 0.015;
82
        if (colortimer > 1)
83
            colortimer = 1;
84
        color = merge_color(colorstart, c_black, colortimer);
85
    }
86
    if (version == 3)
87
    {
88
        if (colortimer < 1)
89
            colortimer += 0.01;
90
        if (colortimer > 1)
91
            colortimer = 1;
92
        color = merge_color(colorstart, c_black, colortimer);
93
    }
94
    if (type == 1)
95
    {
96
        var _faux_timer = timer;
97
        var _interval = 2;
98
        var _subsize = 1;
99
        if (timer > _life)
100
            timer = _life + (timer % _interval);
101
        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;
102
        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;
103
        var _col_index = 0;
104
        draw_set_color(color);
105
        draw_set_alpha(1 - (_col_index / subrings));
106
        surface_set_target(surf);
107
        draw_clear_alpha(c_black, 0);
108
        gpu_set_blendmode_ext(bm_one, bm_zero);
109
        d_circle(x, y, _radius, false);
110
        _faux_timer -= _subsize;
111
        var _first = true;
112
        while (_faux_timer > 0)
113
        {
114
            _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;
115
            if (_radius < (_submax + 100))
116
            {
117
            }
118
            _col_index++;
119
            if (_col_index > subrings)
120
                _col_index = 0;
121
            var _alpha = 1 - (_col_index / subrings);
122
            draw_set_alpha(_alpha * clamp01(1 - (((_radius / _max_radius) * 8) - 7)));
123
            d_circle(x, y, _radius, false);
124
            if (_col_index == subrings)
125
            {
126
                _faux_timer -= _interval;
127
                if (_faux_timer <= 0 && looping && deltatime > 1)
128
                {
129
                    looping = false;
130
                    end_timer = _faux_timer;
131
                    debug_print("end timer declared");
132
                }
133
                if (!looping && _faux_timer <= end_timer)
134
                    break;
135
            }
136
            else
137
            {
138
                _faux_timer -= _subsize;
139
            }
140
        }
141
        draw_set_alpha(1);
142
        surface_reset_target();
143
        gpu_set_blendmode(bm_normal);
144
        draw_surface(surf, 0, 0);
145
    }
146
    else
147
    {
148
        for (var i = 0; i < _ripplecount; i++)
149
        {
150
            var _timer = (type == 1) ? fixed_timer : timer;
151
            surface_set_target(surf);
152
            if (type == 1 && _timer < (_life * 0.75))
153
                draw_clear_alpha(c_black, 1);
154
            else
155
                draw_clear_alpha(c_black, 0);
156
            _ringcount++;
157
            var _ease = (type >= 3) ? 6 : 4;
158
            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)), _ease) * _max_radius;
159
            if (type == 7)
160
                _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 * 40), _timer)), _ease) * _max_radius;
161
            var _col = color;
162
            var _alpha = 1 - (((_radius / _max_radius) * 8) - 7);
163
            draw_set_color(_col);
164
            if (type == 7)
165
                draw_set_color(merge_color(color, c_black, i / _ripplecount));
166
            draw_set_alpha(_alpha);
167
            var _oradius = _radius;
168
            gpu_set_blendmode_ext(bm_one, bm_zero);
169
            d_circle(x, y, _radius, false);
170
            var _subradius = _radius;
171
            if ((_timer - 2) < 0)
172
            {
173
                draw_set_alpha(1);
174
                gpu_set_blendmode(bm_normal);
175
                surface_reset_target();
176
                draw_surface(surf, 0, 0);
177
                break;
178
            }
179
            var _prog = 1;
180
            for (var ii = 1; ii < subrings; ii++)
181
            {
182
                _alpha = 1 - (ii / subrings);
183
                _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);
184
                _alpha = clamp01(_alpha - clamp01(((_radius / _max_radius) * 8) - 7));
185
                draw_set_alpha(_alpha);
186
                if (type == 1)
187
                    _subradius -= (80 + (80 * _prog));
188
                if (type == 2)
189
                    _subradius -= (3 + (3 * _prog));
190
                else if (type == 7)
191
                    _subradius -= (5 + (5 * _prog));
192
                else
193
                    _subradius -= (4 + (4 * _prog));
194
                if (_subradius > 0)
195
                    d_circle(x, y, _subradius, false);
196
            }
197
            draw_set_color(c_black);
198
            if (type == 0)
199
                _subradius -= (4 + (4 * _prog));
200
            else if (type == 2 || type == 3)
201
                _subradius -= (3 + (3 * _prog));
202
            else if (type == 4 || type == 5)
203
                _subradius -= (5 + (5 * _prog));
204
            else if (type == 7)
205
                _subradius -= (6 + (6 * _prog));
206
            else
207
                _subradius -= (80 + (80 * _prog));
208
            draw_set_alpha(0);
209
            d_circle(x, y, _subradius, false);
210
            draw_set_alpha(1);
211
            surface_reset_target();
212
            gpu_set_blendmode(bm_normal);
213
            draw_surface(surf, 0, 0);
214
        }
215
    }
216
    timer += deltatime;
217
    fixed_timer++;
218
    if (type == 1 && !looping)
219
    {
220
        end_timer += deltatime;
221
        if (end_timer >= _life)
222
        {
223
            active = false;
224
            instance_destroy();
225
        }
226
    }
227
    if (type != 1 && (timer - _thickness) >= ((_itv * _ripplecount) + (_life * _ripplecount)))
228
    {
229
        timer = 0;
230
        active = false;
231
        instance_destroy();
232
    }
233
}
234
draw_set_blend_mode(bm_normal);
235
if (active && type >= 3 && timer < 3)
236
{
237
    var _scale = lerp(2, 0, timer / 3);
238
    if (type == 4)
239
        draw_sprite_ext(spr_parry_impact, 0, x, y, _scale, _scale, 0, c_aqua, 1);
240
    _scale = lerp(100, 0, timer / 3);
241
    draw_set_alpha(0.33);
242
    d_circle(x, y, _scale + 10, false);
243
    if (timer > 0)
244
        d_circle(x, y, _scale + 20, false);
245
    draw_set_alpha(1);
246
    if (timer > 1)
247
        d_circle(x, y, _scale, false);
248
}
249
if (active && type == 4 && timer < 3)
250
{
251
    var _scale = lerp(8, 0, timer / 3);
252
    draw_sprite_ext(spr_parry_impact, 0, x, y, _scale, _scale, 0, c_aqua, 1);
253
}
254
draw_set_alpha(1);
255
draw_set_color(c_white);