Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_spearshot_Draw_0

(view raw script w/o annotations or w/e)
1
if (!i_ex(obj_heart))
2
{
3
    instance_destroy();
4
    exit;
5
}
6
var shakelen = 0;
7
var shakedir = 0;
8
if (shakeduration > 0)
9
{
10
    shakeduration--;
11
    if (shakeduration == 2)
12
        shakelen = -4;
13
    if (shakeduration == 4)
14
        shakelen = 4;
15
    if (shakeduration == 0)
16
        shakelen = 0;
17
    shakedir = direction + 90;
18
}
19
if (longspear == 1)
20
    image_index = longnotebeingheld;
21
if (fadespear == 3 || fadespear == 4)
22
    image_angle = point_direction(x, y, obj_spearblocker.x, obj_spearblocker.y);
23
if (redhammer == 1)
24
{
25
    redhammersiner++;
26
    var _color = merge_color(c_white, c_red, 0.4 + (sin(redhammersiner / 8) / 3));
27
    var shakex = 0;
28
    if (redhammerfakeout == 1)
29
    {
30
        redhammersiner++;
31
        if (redhammersiner == 350)
32
            fakespeed = 0;
33
        if (redhammersiner == 410)
34
        {
35
            fakespeed = -15;
36
            grav = 3;
37
        }
38
        if (redhammersiner > 420)
39
        {
40
            afterimage = 
scr_afterimage
scr_afterimage

function
scr_afterimage()
{ afterimage = instance_create(x, y, obj_afterimage); afterimage.sprite_index = sprite_index; afterimage.image_index = image_index; afterimage.image_blend = image_blend; afterimage.image_speed = 0; afterimage.depth = depth; afterimage.image_xscale = image_xscale; afterimage.image_yscale = image_yscale; afterimage.image_angle = image_angle; return afterimage; }
();
41
            afterimage.sprite_index = spr_gerson_red_hammer;
42
            afterimage.image_blend = _color;
43
            afterimage.image_xscale = 2;
44
            afterimage.image_yscale = 2;
45
            afterimage.fadeSpeed = 0.15;
46
        }
47
        if (redhammersiner > 200 && redhammersiner < 410)
48
            shakex = random(4);
49
        if ((redhammersiner % 2) == 0)
50
            redhammersign = -1;
51
        else
52
            redhammersign = 1;
53
    }
54
    draw_sprite_ext(spr_gerson_red_hammer, 3, x + (shakex * redhammersign) + lengthdir_x(shakelen, shakedir), y + lengthdir_y(shakelen, shakedir), 2, 2, image_angle, _color, image_alpha);
55
}
56
else if (bouncespear > 0)
57
{
58
    var shellcolor = 16777215;
59
    if (hp == 8)
60
        shellcolor = pink3;
61
    if (hp == 7)
62
        shellcolor = pink2;
63
    if (hp == 6)
64
        shellcolor = pink1;
65
    if (hp == 5)
66
        shellcolor = 255;
67
    if (hp == 4)
68
        shellcolor = 8388736;
69
    if (hp == 3)
70
        shellcolor = 16776960;
71
    if (hp == 2)
72
        shellcolor = 65280;
73
    if (hp == 1)
74
        shellcolor = 65535;
75
    var scale = 0.75;
76
    if (gigashell == true)
77
        scale = 1;
78
    var angle = point_direction(x, y, obj_heart.x + 10, obj_heart.y + 10);
79
    if (bouncespearcon == -1)
80
        spinindex += 0.5;
81
    if (bouncespear == 1)
82
        spinindex = 0;
83
    if (len < -20)
84
    {
85
    }
86
    else
87
    {
88
        if (sprite_index == spr_bounce_shell_idle)
89
            draw_sprite_ext(spr_bounce_shell_idle_color, spinindex, x + lengthdir_x(shakelen, shakedir), y + lengthdir_y(shakelen, shakedir), scale, scale, angle, shellcolor, image_alpha);
90
        if (sprite_index == spr_bounce_shell_hit_center)
91
            draw_sprite_ext(spr_bounce_shell_hit_center_color, spinindex, x + lengthdir_x(shakelen, shakedir), y + lengthdir_y(shakelen, shakedir), scale, scale, angle, shellcolor, image_alpha);
92
        if (sprite_index == spr_bounce_shell_squish)
93
            draw_sprite_ext(spr_bounce_shell_squish_color, spinindex, x + lengthdir_x(shakelen, shakedir), y + lengthdir_y(shakelen, shakedir), scale, scale, angle, shellcolor, image_alpha);
94
        if (sprite_index == spr_bounce_shell_squish2)
95
            draw_sprite_ext(spr_bounce_shell_squish2_color, spinindex, x + lengthdir_x(shakelen, shakedir), y + lengthdir_y(shakelen, shakedir), scale, scale, angle, shellcolor, image_alpha);
96
        draw_sprite_ext(sprite_index, spinindex, x + lengthdir_x(shakelen, shakedir), y + lengthdir_y(shakelen, shakedir), scale, scale, angle, image_blend, image_alpha);
97
    }
98
    if (bouncespear == 2)
99
    {
100
    }
101
}
102
else
103
{
104
    draw_sprite_ext(sprite_index, image_index, x + lengthdir_x(shakelen, shakedir), y + lengthdir_y(shakelen, shakedir), image_xscale, image_yscale, image_angle, image_blend, image_alpha);
105
}
106
if (flashalpha > 0)
107
{
108
    flashalpha -= 0.1;
109
    var scale = lerp(2, 0, flashalpha);
110
    d3d_set_fog(true, c_white, 0, 1);
111
    draw_sprite_ext(sprite_index, image_index, x, y, image_xscale + scale, image_yscale + scale, image_angle, c_white, flashalpha);
112
    d3d_set_fog(false, c_white, 0, 0);
113
}
114
if (longspear == 1)
115
{
116
    var a = 0;
117
    repeat (longnotepieces)
118
        a++;
119
    draw_sprite_ext(spr_spear_arrow_long_piece, longnotebeingheld, x + lengthdir_x(1, image_angle + 180), y + lengthdir_y(1, image_angle + 180), image_xscale * longnotepieces, image_yscale, image_angle, image_blend, image_alpha);
120
    var barlength = (longnotepieces * 2) - 2;
121
    if (longnotebeingheld == true)
122
    {
123
        if ((longnotepieces % 1) == 0)
124
        {
125
            repeat (3)
126
            {
127
                inst = instance_create(x + lengthdir_x(barlength - random(abs(fakespeed)), image_angle + 180) + lengthdir_x(3, image_angle + 180 + 90), (y - 3) + lengthdir_y(barlength, image_angle + 180) + lengthdir_y(3, image_angle + 180 + 90), obj_arrow_long_particle);
128
                inst.image_index = 3;
129
                inst = instance_create(x + lengthdir_x(barlength - random(abs(fakespeed)), image_angle + 180) + lengthdir_x(2, image_angle + 180 + 90), (y - 2) + lengthdir_y(barlength, image_angle + 180) + lengthdir_y(2, image_angle + 180 + 90), obj_arrow_long_particle);
130
                inst.image_index = 3;
131
                inst = instance_create(x + lengthdir_x(barlength - random(abs(fakespeed)), image_angle + 180) + lengthdir_x(1, image_angle + 180 + 90), (y - 1) + lengthdir_y(barlength, image_angle + 180) + lengthdir_y(1, image_angle + 180 + 90), obj_arrow_long_particle);
132
                inst.image_index = 3;
133
                inst = instance_create(x + lengthdir_x(barlength - random(abs(fakespeed)), image_angle + 180) + lengthdir_x(-1, image_angle + 180 + 90), (y - 1) + lengthdir_y(barlength, image_angle + 180) + lengthdir_y(-1, image_angle + 180 + 90), obj_arrow_long_particle);
134
                inst.image_index = 3;
135
                inst = instance_create(x + lengthdir_x(barlength - random(abs(fakespeed)), image_angle + 180) + lengthdir_x(-2, image_angle + 180 + 90), (y - 2) + lengthdir_y(barlength, image_angle + 180) + lengthdir_y(-2, image_angle + 180 + 90), obj_arrow_long_particle);
136
                inst.image_index = 3;
137
            }
138
        }
139
        with (obj_arrow_long_particle)
140
            direction = ((other.image_angle + 180) - 45) + irandom(90);
141
        longnoteindex++;
142
        if (longnoteindex == 1)
143
            damage = round(damage / 2);
144
        var scale = 1.5;
145
        if (choose(0, 1) == 1)
146
            draw_sprite_ext(spr_sparks2, longnoteindex, x + lengthdir_x(1, image_angle + 180), y + lengthdir_y(1, image_angle + 180), scale, scale, image_angle, image_blend, image_alpha);
147
        else
148
            draw_sprite_ext(spr_sparks2, longnoteindex + 2, x + lengthdir_x(1, image_angle + 180), y + lengthdir_y(1, image_angle + 180), scale, -1 * scale, image_angle, image_blend, image_alpha);
149
        snd_stop(snd_organ_enemy_loop_temp);
150
        pitchcount--;
151
        var _pitch = 2 - (pitchcount / 60);
152
        if (_pitch < 0.5)
153
            _pitch = 0.5;
154
        snd_play_pitch(snd_organ_enemy_loop_temp, _pitch);
155
        longnotepieces -= ceil(fakespeed / 2);
156
        if (longnotepieces < 0)
157
        {
158
            inst = instance_create_depth(x, y, depth - 1000, obj_animation);
159
            inst.sprite_index = spr_finisher_explosion_quick;
160
            inst.image_speed = 1;
161
            inst.image_angle = image_angle;
162
            inst.image_xscale = 0.2;
163
            inst.image_yscale = 0.2;
164
            snd_play_x(snd_queen_punched_lower_heavy, 0.5, 2);
165
            instance_destroy();
166
        }
167
    }
168
}