Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_rotating_tower_controller_new_Draw_0

(view raw script w/o annotations or w/e)
1
var camy = cameray();
2
var render_ypos = round(camy / tile_height_fine);
3
var render_ypos_start = render_ypos - 1;
4
var render_ypos_end = render_ypos + 25;
5
if (render_ypos_start < 0)
6
    render_ypos_start = 0;
7
if (render_ypos_end > verticaltilecount)
8
    render_ypos_end = verticaltilecount;
9
tower_x += tower_xshake;
10
tower_y += tower_yshake;
11
if (
scr_debug
scr_debug

function
scr_debug()
{ if (global.debug == 1) return 1; }
() && sunkus_kb_check_pressed(49))
12
{
13
    var cx = 0;
14
    var cy = 0;
15
    for (tmidx = 0; tmidx < tileset_count; tmidx++)
16
    {
17
        var exportsurface = surface_create(tile_width_fine * horizontaltilecount, tile_width_fine * verticaltilecount);
18
        surface_set_target(exportsurface);
19
        for (var ii = 0; ii < verticaltilecount; ii++)
20
        {
21
            for (i = 0; i < horizontaltilecount; i++)
22
            {
23
                var offset = 0;
24
                if (appearance == 1)
25
                    offset = 10;
26
                var xx = (tile_width_fine * i) + offset;
27
                var yy = (tile_width_fine * ii) + offset;
28
                var col = 16777215;
29
                var pos = xy(i, ii);
30
                if (tile_index[pos][tmidx] > 0)
31
                {
32
                    var t = tile_index[pos][tmidx];
33
                    var idx = tile_get_index(t);
34
                    var yflip = 1;
35
                    var rotation = 0;
36
                    var xscale = 1;
37
                    if (tile_get_mirror(t))
38
                        xscale = -xscale;
39
                    if (tile_get_flip(t))
40
                        yflip = -1;
41
                    if (tile_get_rotate(t))
42
                    {
43
                        rotation = -90;
44
                        var yf = yflip;
45
                        yflip *= abs(xscale);
46
                        xscale = sign(xscale);
47
                    }
48
                    draw_sprite_ext(tile_sprite[pos][tmidx], idx, xx, yy, xscale, yflip, rotation, col, 1);
49
                }
50
            }
51
        }
52
        surface_save(exportsurface, string(tmidx) + "surfaceexport.png");
53
        surface_reset_target();
54
        surface_free(exportsurface);
55
    }
56
}
57
var indent;
58
if (appearance == 1)
59
{
60
    if (!surface_exists(tilesurface))
61
        tilesurface = surface_create(640, 480);
62
    surface_set_target(tilesurface);
63
    draw_clear_alpha(c_black, 0);
64
    var cx = camerax();
65
    var cy = camy;
66
    var len = array_length(backface_indices);
67
    var statictile = 4388;
68
    var statictilecount = 2;
69
    var staticyoffset = 760;
70
    if (i_ex(obj_dw_churchc_titanclimb2))
71
    {
72
        statictile = 1557;
73
        statictilecount = 3;
74
        staticyoffset = 320;
75
    }
76
    for (i = 0; i < len; i++)
77
    {
78
        var k = backface_indices[i];
79
        var xx = ((tower_x - tower_xshake) + tile_x[k] + (tile_xscale[k] * 0.5)) - cx;
80
        for (j = 0; j < statictilecount; j++)
81
        {
82
            if ((render_ypos_start * 20) <= (staticyoffset + (2560 * (j + 1))) && (render_ypos_end * 20) >= (staticyoffset + (2560 * j)))
83
                draw_sprite_ext(statictile, k + (44 * j), xx, (tower_ystart - cy) + staticyoffset + (2560 * j), (tile_xscale[k] / -tile_width_fine) * 2, 2, 0, c_dkgray, 1);
84
        }
85
    }
86
    len = array_length(valid_tile_indices);
87
    for (i = 0; i < array_length(len); i++)
88
    {
89
        var pos = valid_tile_indices[i];
90
        var k = pos % horizontaltilecount;
91
        var ii = floor(pos / horizontaltilecount);
92
        if (tile_vis[k] == 2 && ii >= render_ypos_start && ii <= render_ypos_end)
93
        {
94
            col = tile_color[k];
95
            var xx = (tower_x - tower_xshake) + tile_x[k] + (tile_xscale[k] * 0.5);
96
            var yy = (tile_height_fine * ii) + tower_ystart + 10;
97
            if (tile_index[pos][0] > 0)
98
                obj_rotating_tower_controller_new.draw_tilemap_tile(k, xx - cx, yy - cy, col, pos, 0);
99
        }
100
    }
101
    surface_reset_target();
102
    shader_set(shd_fakedepth);
103
    shader_set_uniform_f(u_extents, 0.21812);
104
    shader_set_uniform_f(u_centerx, 0.5 + (tower_xshake / 640));
105
    draw_surface(tilesurface, cx + tower_xshake, cy);
106
    shader_reset();
107
    indent = 0.98;
108
    shader_set(shd_fountaineffect);
109
    shader_set_uniform_f(u_iTime, current_time / 250);
110
    shader_set_uniform_f(u_iPosOffset, tower_angle / 360, camy / 480);
111
    shader_set_uniform_f(u_iResolution, tower_radius * 2 * indent, 480);
112
    shader_set_uniform_f(u_uvs, s_uvs[0], s_uvs[1], s_uvs[2] - s_uvs[0], s_uvs[3] - s_uvs[1]);
113
    var col = 
scr_make_color_hsv
scr_make_color_hsv

function
scr_make_color_hsv(arg0, arg1, arg2)
{ var hue = arg0; if (hue < 0) hue = 256 - (-hue % 256); else hue %= 256; return make_color_hsv(hue, arg1, arg2); }
(current_time / 400, 50, (sin(current_time / 1600) * 10) + 70);
114
    draw_sprite_ext(bg_fountain1, 0, tower_x - (tower_radius * indent), camera_get_view_y(view_camera[0]), (tower_radius * 2 * indent) / sprite_get_width(bg_fountain1), 480 / sprite_get_height(bg_fountain1), 0, col, 1);
115
    shader_reset();
116
    obj_rotating_tower_controller_new.render_big_eye(625);
117
    obj_rotating_tower_controller_new.render_big_eye(1332);
118
    surface_set_target(tilesurface);
119
    draw_clear_alpha(c_black, 0);
120
    len = array_length(visible_indices);
121
    for (i = 0; i < len; i++)
122
    {
123
        var k = visible_indices[i];
124
        col = tile_color[k];
125
        var xx = ((tower_x - tower_xshake) + tile_x[k] + (tile_xscale[k] * 0.5)) - cx;
126
        for (j = 0; j < statictilecount; j++)
127
        {
128
            if ((render_ypos_start * 20) <= (staticyoffset + (2560 * (j + 1))) && (render_ypos_end * 20) >= (staticyoffset + (2560 * j)))
129
                draw_sprite_ext(statictile, k + (44 * j), xx, (tower_ystart - cy) + staticyoffset + (2560 * j), (tile_xscale[k] / -tile_width_fine) * 2, 2, 0, col, 1);
130
        }
131
    }
132
    len = array_length(valid_tile_indices);
133
    for (i = 0; i < len; i++)
134
    {
135
        var pos = valid_tile_indices[i];
136
        var k = pos % horizontaltilecount;
137
        var ii = floor(pos / horizontaltilecount);
138
        if (tile_vis[k] == 1 && ii >= render_ypos_start && ii <= render_ypos_end)
139
        {
140
            col = tile_color[k];
141
            var xx = (tower_x - tower_xshake) + tile_x[k] + (tile_xscale[k] * 0.5);
142
            var yy = (tile_height_fine * ii) + tower_ystart + 10;
143
            for (tmidx = 0; tmidx < tileset_count; tmidx++)
144
            {
145
                if (tile_index[pos][tmidx] > 0)
146
                    obj_rotating_tower_controller_new.draw_tilemap_tile(k, xx - cx, yy - cy, col, pos, tmidx);
147
            }
148
        }
149
    }
150
    surface_reset_target();
151
    shader_set(shd_fakedepth);
152
    shader_set_uniform_f(u_extents, 0.2148, 0.218);
153
    shader_set_uniform_f(u_centerx, 0.5 + (tower_xshake / 640));
154
    draw_surface(tilesurface, cx + tower_xshake, cy);
155
    shader_reset();
156
}
157
else if (use_tilesets)
158
{
159
    var cx = 0;
160
    var cy = 0;
161
    var statictile = -4;
162
    var statictilecount = 2;
163
    var staticyoffset = 760;
164
    if (i_ex(obj_dw_churchb_rotatingtower))
165
    {
166
        statictile = 1664;
167
        statictilecount = 2;
168
        staticyoffset = 0;
169
    }
170
    if (statictile != -4)
171
    {
172
        len = array_length(visible_indices);
173
        for (i = 0; i < len; i++)
174
        {
175
            var k = visible_indices[i];
176
            var col = tile_color[k];
177
            var xx = ((tower_x - tower_xshake) + tile_x[k] + (tile_xscale[k] * 0.5)) - cx;
178
            for (j = 0; j < statictilecount; j++)
179
            {
180
                if ((render_ypos_start * tile_width_fine) <= (staticyoffset + (2560 * (j + 1))) && (render_ypos_end * tile_height_fine) >= (staticyoffset + (2560 * j)))
181
                    draw_sprite_ext(statictile, k + (horizontaltilecount * j), xx, (tower_ystart - cy) + staticyoffset + (2560 * j), (tile_xscale[k] / -tile_width_fine) * 2, 2, 0, col, 1);
182
            }
183
        }
184
    }
185
    var len = array_length(valid_tile_indices);
186
    for (i = 0; i < len; i++)
187
    {
188
        var pos = valid_tile_indices[i];
189
        var k = pos % horizontaltilecount;
190
        var ii = floor(pos / horizontaltilecount);
191
        if (tile_vis[k] == 1 && ii >= render_ypos_start && ii <= render_ypos_end)
192
        {
193
            var col = tile_color[k];
194
            var xx = (tower_x - tower_xshake) + tile_x[k] + (tile_xscale[k] * 0.5);
195
            var yy = (tile_height_fine * ii) + tower_ystart + 10;
196
            for (tmidx = 0; tmidx < tileset_count; tmidx++)
197
            {
198
                if (tile_index[pos][tmidx] > 0)
199
                    obj_rotating_tower_controller_new.draw_tilemap_tile(k, xx - cx, yy - cy, col, pos, tmidx);
200
            }
201
        }
202
    }
203
}
204
else
205
{
206
    for (var ii = render_ypos_start; ii < render_ypos_end; ii++)
207
    {
208
        for (i = 0; i < horizontaltilecount; i++)
209
        {
210
            if (tile_vis[i] == 1 && (appearance != 2 || tile_sprite[xy(i, ii)][0] != spr_nothing))
211
            {
212
                var pos = xy(i, ii);
213
                draw_sprite_ext(tile_sprite[pos][0], tile_index[pos][0], tower_x + tile_x[i] + tile_xscale[i], (tile_height_fine * ii) + tower_ystart, tile_xscale[i] / -tile_width_fine, 1, 0, tile_color[i], 1);
214
                var xoffset = 0;
215
                if (tile_sprite[pos][1] != spr_nothing && tile_vis[i] == 1)
216
                    draw_sprite_ext(tile_sprite[pos][1], tile_index[pos][1], tower_x + tile_x[i] + tile_xscale[i], (tile_height_fine * ii) + tower_ystart, tile_xscale[i] / -tile_width_fine, 1, 0, tile_color[i], 1);
217
            }
218
        }
219
    }
220
}
221
var cull_top = render_ypos_start * other.tile_height_fine;
222
var cull_bottom = render_ypos_end * other.tile_height_fine;
223
var xscale_scaled = 1 / tile_width_fine;
224
with (obj_climb_obstacle)
225
{
226
    if ((y + sprite_height) < cull_top || y > cull_bottom)
227
        continue;
228
    if (object_index == obj_climb_water)
229
    {
230
        var _tilex = (
scr_even
scr_even

function
scr_even(arg0)
{ return round(arg0 / 2) * 2; }
(x + drawx) * xscale_scaled) + 1;
231
        if (_tilex > (other.horizontaltilecount - 1))
232
            _tilex -= (other.horizontaltilecount - 1);
233
        else if (_tilex < 0)
234
            _tilex += (other.horizontaltilecount - 1);
235
        if (other.tile_vis[_tilex] == 1)
236
            draw_sprite_ext(spr_pxteal_40, image_index, other.tower_x + other.tile_x[_tilex], 
scr_even
scr_even

function
scr_even(arg0)
{ return round(arg0 / 2) * 2; }
(y + drawy), other.tile_xscale[_tilex] / other.tile_width_fine, height / 40, 0, other.tile_color[_tilex], 0.8);
237
    }
238
    else if (object_index == obj_climb_setpathenemy)
239
    {
240
        var adjustment = -260;
241
        if (other.appearance == 1)
242
            adjustment = -520;
243
        var __tile_angle = lerp(360, 0, (x + adjustment) / other.tower_circumference);
244
        var tile_angle1 = __tile_angle + other.tower_angle;
245
        while (tile_angle1 > 360)
246
            tile_angle1 -= 360;
247
        if (tile_angle1 < 0)
248
            tile_angle1 += 360;
249
        if (!(tile_angle1 > 350 || tile_angle1 <= 170))
250
            continue;
251
        var __tile_x = lengthdir_x(other.tower_radius, tile_angle1);
252
        var tile_angle2 = tile_angle1 + other.tile_angle_difference;
253
        if (tile_angle2 > 360)
254
            tile_angle2 -= 360;
255
        else if (tile_angle2 < 0)
256
            tile_angle2 += 360;
257
        var __tile_xscale = lengthdir_x(other.tower_radius, tile_angle2) - __tile_x;
258
        var __tile_yscale = other.tile_width_fine;
259
        if ((angle % 180) == 90)
260
        {
261
            __tile_yscale = __tile_xscale;
262
            __tile_xscale = other.tile_width_fine;
263
        }
264
        __tile_xscale /= other.tile_width_fine;
265
        __tile_yscale /= other.tile_width_fine;
266
        var __tile_color = merge_color(c_white, c_gray, abs(__tile_x + (__tile_xscale / 2)) / 190);
267
        draw_sprite_ext(sprite_index, current_time % 2, other.tower_x + shakex + __tile_x, y + 20, __tile_xscale, __tile_yscale, angle, __tile_color, image_alpha);
268
    }
269
    else if (object_index == obj_climb_enemy)
270
    {
271
        var _tilex = (x * xscale_scaled) + 1;
272
        if (_tilex > (other.horizontaltilecount - 1))
273
            _tilex -= (other.horizontaltilecount - 1);
274
        else if (_tilex < 0)
275
            _tilex += (other.horizontaltilecount - 1);
276
        if (other.tile_vis[_tilex] == 1)
277
            draw_sprite_ext(sprite_index, image_index, other.tower_x + shakex + other.tile_x[_tilex], y - 20, other.tile_xscale[_tilex] / other.tile_width_fine, 1, 0, other.tile_color[_tilex], 1);
278
    }
279
    else if (object_index == obj_climb_eyewaterenemy)
280
    {
281
        var adjustment = 1;
282
        if (other.appearance == 1)
283
            adjustment = 3;
284
        var xx = x;
285
        if (xx >= 830)
286
            xx -= 20;
287
        var _tilex = (xx * xscale_scaled) + adjustment;
288
        if (_tilex > (other.horizontaltilecount - 1))
289
            _tilex -= (other.horizontaltilecount - 1);
290
        else if (_tilex < 0)
291
            _tilex += (other.horizontaltilecount - 1);
292
        if (other.tile_vis[_tilex] == 1)
293
            draw_sprite_ext(sprite_index, image_index, other.tower_x + shakex + (other.tile_x[_tilex] * indent), y, (other.tile_xscale[_tilex] / other.tile_width_fine) * indent, 1, 0, other.tile_color[_tilex], 1);
294
    }
295
    else if (object_index == obj_climb_waterbucket)
296
    {
297
        var _tilex = (x * xscale_scaled) + 1;
298
        if (_tilex > (other.horizontaltilecount - 1))
299
            _tilex -= (other.horizontaltilecount - 1);
300
        else if (_tilex < 0)
301
            _tilex += (other.horizontaltilecount - 1);
302
        if (other.tile_vis[_tilex] == 1)
303
        {
304
            draw_sprite_ext(sprite_index, image_index, other.tower_x + other.tile_x[_tilex], y, (other.tile_xscale[_tilex] * 2) / other.tile_width_fine, 2.2, 0, other.tile_color[_tilex], 1);
305
            if (drawwater > 0)
306
            {
307
                var spr = 279;
308
                draw_sprite_ext(spr, sprite_get_number(spr) - (drawwater / 3), other.tower_x + other.tile_x[_tilex], y, (other.tile_xscale[_tilex] * 2) / other.tile_width_fine, 2.2, 0, other.tile_color[_tilex], 1);
309
            }
310
        }
311
    }
312
    else if (object_index == obj_climb_watergenerator)
313
    {
314
        var _tilex = (x * xscale_scaled) + 1;
315
        if (_tilex > (other.horizontaltilecount - 1))
316
            _tilex -= (other.horizontaltilecount - 1);
317
        else if (_tilex < 0)
318
            _tilex += (other.horizontaltilecount - 1);
319
        if (other.tile_vis[_tilex] == 1)
320
        {
321
            draw_sprite_ext(spr_climb_waterbucket, image_index, other.tower_x + other.tile_x[_tilex], y, (other.tile_xscale[_tilex] * 2) / other.tile_width_fine, -2, 0, other.tile_color[_tilex], 1);
322
            if (drawwater > 0)
323
            {
324
                var spr = 279;
325
                draw_sprite_ext(spr, sprite_get_number(spr) - (drawwater / 3), other.tower_x + other.tile_x[_tilex], y, (other.tile_xscale[_tilex] * 2) / other.tile_width_fine, 2.2, 0, other.tile_color[_tilex], 1);
326
            }
327
        }
328
    }
329
    else if (object_index != obj_climbstarter && object_index != obj_climb_immobileeye && object_index != obj_climb_mover && object_index != obj_climb_enemyspawner && object_index != obj_climb_enemykiller && object_index != obj_climb_susie && object_index != obj_climb_evilgrowth)
330
    {
331
        var adjustment = 1;
332
        if (other.appearance == 1)
333
            adjustment = 3;
334
        var _tilex = (x * xscale_scaled) + adjustment;
335
        if (_tilex > (other.horizontaltilecount - 1))
336
            _tilex -= (other.horizontaltilecount - 1);
337
        else if (_tilex < 0)
338
            _tilex += (other.horizontaltilecount - 1);
339
        if (other.tile_vis[_tilex] == 1)
340
            draw_sprite_ext(sprite_index, image_index, other.tower_x + other.tile_x[_tilex], y, other.tile_xscale[_tilex] / other.tile_width_fine, 1, 0, other.tile_color[_tilex], 1);
341
    }
342
}
343
with (obj_oflash_tower)
344
{
345
    var _tilex = (x * xscale_scaled) + 1;
346
    if (_tilex > (other.horizontaltilecount - 1))
347
        _tilex -= (other.horizontaltilecount - 1);
348
    else if (_tilex < 0)
349
        _tilex += (other.horizontaltilecount - 1);
350
    var _xoff = x % other.tile_width_fine;
351
    siner += flashspeed;
352
    if (other.tile_vis[_tilex] == 1)
353
    {
354
        d3d_set_fog(true, c_white, 0, 1);
355
        draw_sprite_ext(sprite_index, image_index, other.tower_x + other.tile_x[_tilex] + _xoff, y, other.tile_xscale[_tilex] / other.tile_width_fine, 1, 0, other.tile_color[_tilex], sin(siner / 3));
356
        d3d_set_fog(false, c_black, 0, 0);
357
    }
358
}
359
with (obj_afterimage_cut_half_tower)
360
{
361
    var _tilex = (x * xscale_scaled) + 1;
362
    if (_tilex > (other.horizontaltilecount - 1))
363
        _tilex -= (other.horizontaltilecount - 1);
364
    else if (_tilex < 0)
365
        _tilex += (other.horizontaltilecount - 1);
366
    siner++;
367
    if (other.tile_vis[_tilex] == 1)
368
    {
369
        var _x = (other.tower_x + other.tile_x[_tilex]) - 20;
370
        if (flash)
371
        {
372
            d3d_set_fog(true, c_white, 0, 1);
373
            d3d_set_fog(false, c_black, 0, 0);
374
            flash = false;
375
            exit;
376
        }
377
        var _xscale = 1;
378
        var _yscale = 1;
379
        var hw = width / 2;
380
        var hh = height / 2;
381
        var m = lerp_ease_out(0, sprite_height / 2, (siner + 2) / 10, 1);
382
        image_alpha -= faderate;
383
        draw_sprite_part_ext(sprite_index, image_index, 0, 0, hw * 2, hh, _x - (width / 2), y - m - ((yo * _yscale) / 2), _xscale, image_yscale, image_blend, image_alpha);
384
        draw_sprite_part_ext(sprite_index, image_index, 0, hh, hw * 2, hh, _x - (width / 2), (y + m) - ((yo * _yscale) / 2), _xscale, image_yscale, image_blend, image_alpha);
385
    }
386
    if (image_alpha < 0)
387
        instance_destroy();
388
}
389
with (obj_rotating_bullet_new)
390
    enabled = (y + sprite_height) >= cull_top && y <= cull_bottom;
391
with (obj_climb_setpathenemy)
392
{
393
    if (tower_cull_y == -4)
394
        enabled = (camy + 480 + 100) < y;
395
    else
396
        enabled = (camy + 480 + 100) < tower_cull_y;
397
}
398
if (appearance == 0)
399
{
400
    draw_sprite_ext(spr_whitegradientdown_40, 0, (tower_x - tower_radius) + tile_width, tower_y + 400, -verticaltilecount, 1, 270, c_black, 0.6 * col_blend);
401
    draw_sprite_ext(spr_whitegradientdown_40, 0, (tower_x + tower_radius) - tile_width, tower_y + 400, verticaltilecount, 1, 90, c_black, 0.6 * col_blend);
402
}
403
tower_x -= tower_xshake;
404
tower_y -= tower_yshake;