Deltarune (Chapter 2) script viewer

← back to main script listing

gml_Object_obj_ch2_scene26_wine_laser_Draw_0

(view raw script w/o annotations or w/e)
1
depth = 96850;
2
laserx = x + (27 * image_xscale);
3
lasery = y - (6 * image_yscale);
4
beam_power = 0;
5
if (timer < 0)
6
{
7
    timer += 1.25;
8
    if (timer < -10)
9
        exit;
10
    draw_set_color(#B5E61D);
11
    draw_circle(laserx, lasery - ((timer + 10) * 25), 20, false);
12
}
13
if (timer > 0)
14
    beam_power = clamp(0, 5, beam_power / 2);
15
if (trailstart > 0 && trailend < 640)
16
{
17
    var _wine_color = merge_color(#B5E61D, c_white, clamp(scr_remapvalue
scr_remapvalue

function scr_remapvalue(arg0, arg1, arg2, arg3, arg4) { if (arg1 == arg0) return arg3; var __invLerp = (arg2 - arg0) / (arg1 - arg0); return lerp(arg3, arg4, __invLerp); } function remap(arg0, arg1, arg2, arg3, arg4) { var __invLerp = scr_inverselerp(arg1, arg2, arg0); return lerp(arg3, arg4, __invLerp); } function remap_clamped(arg0, arg1, arg2, arg3, arg4) { var __remapped_value = remap(arg0, arg1, arg2, arg3, arg4); return clamp(__remapped_value, arg3, arg4); }
(35, 45, timer, 0, 1), 0, 1));
18
    draw_set_color(_wine_color);
19
    if ((trailend + camerax()) < (noelle_x - 80))
20
        draw_rectangle(trailend + camerax(), 310, min(noelle_x - 80, trailstart + camerax()), 314, false);
21
    var _swerveleft = clamp((trailend + camerax()) - (noelle_x - 80), 0, 160);
22
    var _swerveright = clamp((trailstart + camerax()) - (noelle_x - 80), 0, 160 - _swerveleft);
23
    if (_swerveleft < 160 && _swerveright > 0)
24
        draw_sprite_part_ext(spr_cutscene_26_laser_swerve, 0, _swerveleft, 0, _swerveright, 160, (noelle_x - 80) + _swerveleft, 272, 1, 1, _wine_color, 1);
25
    if ((trailstart + camerax()) > (noelle_x + 80))
26
        draw_rectangle(max(trailend + camerax(), noelle_x + 80), 310, trailstart + camerax(), 314, false);
27
}
28
if (timer >= 40)
29
{
30
    if (timer >= 40 && timer < 41)
31
    {
32
        d = instance_exists(obj_shake) ? 196 : instance_create(0, 0, obj_shake);
33
        d.shakex = ceil(2);
34
        d.shakey = ceil(2);
35
        d.permashake = 1;
36
    }
37
    var bombdepth = irandom(5);
38
    d = instance_create(((camerax() + ((timer - 40) * 50)) - 50) + random_range(-15, 15), 230 + (bombdepth * 5), obj_animation_dx);
39
    trailend = d.x - 30 - camerax();
40
    d.sprite_index = spr_explosion_round;
41
    if ((explosioncount % 3) == 0)
42
        snd_play(snd_bomb);
43
    explosioncount++;
44
    d.image_xscale = 2;
45
    d.image_yscale = 2;
46
    d.image_speed = 0.75;
47
    d.depth -= bombdepth + 1;
48
    with (d)
49
        scr_depth
scr_depth

function scr_depth() { depth = 100000 - ((y * 10) + (sprite_height * 10)); }
();
50
    if (d.x > (camerax() + 680) && explosioncount >= 24)
51
    {
52
        if (instance_exists(obj_shake))
53
        {
54
            with (obj_shake)
55
                instance_destroy();
56
        }
57
        if (test_mode)
58
        {
59
            timer = -60;
60
            trailstart = 0;
61
            trailend = 0;
62
            explosioncount = 0;
63
            exit;
64
        }
65
        else
66
        {
67
            instance_destroy();
68
            exit;
69
        }
70
    }
71
}
72
if (timer >= 50)
73
{
74
    timer++;
75
    if (timer < 52)
76
    {
77
        var xincrease = lengthdir_x(4, 80);
78
        var yincrease = lengthdir_y(4, 80);
79
        for (i = 0; i < 40; i++)
80
        {
81
            d = instance_create(laserx + (xincrease * i), lasery + (yincrease * i), obj_ch2_scene26_wine_laser_splash);
82
            d.direction = 80 + random_range(-5, 5);
83
            d.speed = (i / 5) + 0.5;
84
            d.gravity = 0.5;
85
            d.image_speed = 0.25;
86
            d.depth = 1000001;
87
        }
88
    }
89
    exit;
90
}
91
var last_angle = lerp(90, 440, scr_ease_inout
scr_ease_inout

function scr_ease_inout(arg0, arg1) { if (arg1 < -3 || arg1 > 7) return arg0; if (arg1 == -3) return ease_inout_bounce(arg0, 0, 1, 1); else if (arg1 == -2) return ease_inout_elastic(arg0, 0, 1, 1); else if (arg1 == -1) return ease_inout_back(arg0, 0, 1, 1); else if (arg1 == 1) return -0.5 * cos((pi * arg0) - 1); else if (arg1 == 0) return arg0; arg0 *= 2; if (arg0 < 1) { return 0.5 * scr_ease_in(arg0, arg1); } else { arg0--; return 0.5 * (scr_ease_out(arg0, arg1) + 1); } }
(timer / 50, 6));
92
if (timer >= 0)
93
{
94
    if (timer <= 40 && timer < 49)
95
        timer += 1.75;
96
    else
97
        timer += 0.75;
98
}
99
var current_angle = lerp(90, 440, scr_ease_inout
scr_ease_inout

function scr_ease_inout(arg0, arg1) { if (arg1 < -3 || arg1 > 7) return arg0; if (arg1 == -3) return ease_inout_bounce(arg0, 0, 1, 1); else if (arg1 == -2) return ease_inout_elastic(arg0, 0, 1, 1); else if (arg1 == -1) return ease_inout_back(arg0, 0, 1, 1); else if (arg1 == 1) return -0.5 * cos((pi * arg0) - 1); else if (arg1 == 0) return arg0; arg0 *= 2; if (arg0 < 1) { return 0.5 * scr_ease_in(arg0, arg1); } else { arg0--; return 0.5 * (scr_ease_out(arg0, arg1) + 1); } }
(timer / 50, 6));
100
draw_set_color(#B5E61D);
101
var angleOffset = min(10, abs(last_angle - current_angle));
102
beam_power = clamp((1 - scr_ease_inout
scr_ease_inout

function scr_ease_inout(arg0, arg1) { if (arg1 < -3 || arg1 > 7) return arg0; if (arg1 == -3) return ease_inout_bounce(arg0, 0, 1, 1); else if (arg1 == -2) return ease_inout_elastic(arg0, 0, 1, 1); else if (arg1 == -1) return ease_inout_back(arg0, 0, 1, 1); else if (arg1 == 1) return -0.5 * cos((pi * arg0) - 1); else if (arg1 == 0) return arg0; arg0 *= 2; if (arg0 < 1) { return 0.5 * scr_ease_in(arg0, arg1); } else { arg0--; return 0.5 * (scr_ease_out(arg0, arg1) + 1); } }
(timer / 50, 6)) * 40, 2, 20);
103
if (!surface_exists(laser_surface))
104
    laser_surface = surface_create(640, 480);
105
surface_set_target(laser_surface);
106
draw_clear_alpha(c_black, 0);
107
laserx -= camerax();
108
for (i = 0; i < 2; i++)
109
{
110
    draw_primitive_begin(pr_trianglestrip);
111
    xx = laserx + lengthdir_x(beam_power, current_angle + 90);
112
    yy = lasery + lengthdir_y(beam_power, current_angle + 90);
113
    draw_vertex(xx, yy);
114
    xx2 = laserx + lengthdir_x(beam_power, current_angle - 90);
115
    yy2 = lasery + lengthdir_y(beam_power, current_angle - 90);
116
    draw_vertex(xx2, yy2);
117
    var _beam_length = (timer < 0) ? ((timer + 10) * 25) : 1200;
118
    if (trailstart < 640)
119
    {
120
        var ybeam = lengthdir_y(_beam_length, current_angle + angleOffset);
121
        if (i == 1 && ybeam > 0 && trailstart < 640)
122
            trailstart = laserx + lengthdir_x(_beam_length * ((315 - yy) / ybeam), current_angle + angleOffset);
123
        else if (trailstart > 0 && trailstart < 640)
124
            trailstart = 700;
125
    }
126
    xx += lengthdir_x(_beam_length, current_angle + angleOffset);
127
    yy += lengthdir_y(_beam_length, current_angle + angleOffset);
128
    draw_vertex(xx, yy);
129
    _beam_length = (timer < 0) ? ((timer + 10) * 25) : 1200;
130
    xx2 += lengthdir_x(_beam_length, last_angle - angleOffset);
131
    yy2 += lengthdir_y(_beam_length, last_angle - angleOffset);
132
    draw_vertex(xx2, yy2);
133
    draw_primitive_end();
134
    draw_set_color(c_white);
135
    angleOffset = 0;
136
    beam_power = 0;
137
}
138
gpu_set_blendmode(bm_subtract);
139
draw_rectangle(0, 315, noelle_x - camerax() - 80, 480, false);
140
draw_rectangle(0, 345, 640, 480, false);
141
draw_sprite(spr_cutscene_26_laser_swerve, 1, noelle_x - camerax(), 313);
142
gpu_set_blendmode(bm_normal);
143
surface_reset_target();
144
draw_surface(laser_surface, camerax(), cameray());