Deltarune (Chapter 5) script viewer

← back to main script listing

gml_Object_obj_caterpillar_dash_Step_0

(view raw script w/o annotations or w/e)
1
if (drown)
2
{
3
    visible = 0;
4
    speed = 0;
5
    exit;
6
}
7
t++;
8
shake = max(0, shake - 1);
9
shake_angle = 
scr_wrap
scr_wrap

function
scr_wrap(arg0, arg1, arg2)
{ if ((arg0 % 1) == 0) { while (arg0 > arg2 || arg0 < arg1) { if (arg0 > arg2) { arg0 = (arg1 + arg0) - arg2 - 1; } else if (arg0 < arg1) { arg0 = ((arg2 + arg0) - arg1) + 1; } else { } } return arg0; } else { var _old = argument[0] + 1; while (arg0 != _old) { _old = arg0; if (arg0 < arg1) { arg0 = arg2 - (arg1 - arg0); } else if (arg0 > arg2) { arg0 = arg1 + (arg0 - arg2); } else { } } return arg0; } }
(shake_angle + 80 + irandom(40), 0, 360);
10
var _mainchara = -4;
11
var impact = false;
12
if (instance_exists(obj_mainchara_dash))
13
{
14
    _mainchara = 1660;
15
    impact = _mainchara.impacted;
16
    stopping = obj_mainchara_dash.stopping;
17
}
18
if (!impact)
19
    
scr_depth_alt
scr_depth_alt

function
scr_depth_alt(arg0 = id, arg1 = 0)
{ with (arg0) depth = 100000 - ((y * 10) + ((sprite_height - sprite_yoffset) * 10) + (arg1 * 10)); }
();
20
if (wraparound)
21
{
22
    if (x > (room_width + (sprite_width / 2)))
23
    {
24
        x -= (room_width + (sprite_width / 2));
25
        x = 0;
26
    }
27
    if (x < (-sprite_width / 2))
28
        x += (room_width + (sprite_width / 2));
29
}
30
if (impact)
31
{
32
    if (bonkstate == 0)
33
    {
34
        if ((image_xscale < 0 && x <= bonk_x) || (image_xscale > 0 && x >= bonk_x))
35
        {
36
            shake = 10;
37
            if (name == "susie")
38
            {
39
                sprite_index = spr_susie_dw_jump_ball;
40
                if (instance_exists(obj_mainchara_dash))
41
                    depth = obj_mainchara_dash.depth + 400;
42
            }
43
            else
44
            {
45
                sprite_index = spr_ralsei_jump_ball;
46
                if (
scr_flag_get
scr_flag_get

function
scr_flag_get(arg0)
{ return global.flag[arg0]; } function scr_flag_name_get(arg0) { var v = global.flagname[arg0]; return is_undefined(v) ? "*unknown flag*" : v; } function scr_flag_get_ext(arg0, arg1, arg2 = 1) { if (arg1 < 0)
scr_flag_get(arg0);
else return scr_get_bitmask_value(global.flag[arg0], arg1, arg2); }
(1311) == 1)
47
                    sprite_index = spr_ralsei_jump_ball_hat;
48
            }
49
            image_speed = 0.25;
50
            hspeed = -image_xscale * 3;
51
            vspeed = 1;
52
            if (name == "susie")
53
                vspeed = -1;
54
            jumping = 1;
55
            jumpspd = bonkheight;
56
            jumpgravity = 1.25;
57
            bonkstate = 1;
58
            snd_play_pitch(snd_cymbal, 1.2);
59
            snd_play(snd_punchmed);
60
            with (instance_create(x + (20 * image_xscale), y, obj_plat_vfx))
61
            {
62
                sprite_index = spr_smack_vfx;
63
alarm[0]
64
                image_angle = 90 * irandom(3);
65
            }
66
        }
67
    }
68
}
69
if (!impacted && !impact)
70
{
71
    if ((t % 2) == 0 && (make_afterimages || jumping))
72
    {
73
        afterimage = 
scr_afterimage_monochrome
scr_afterimage_monochrome

function
scr_afterimage_monochrome(arg0, arg1)
{ afterimage = instance_create(x, y, obj_afterimage_onecolor); afterimage.tint = arg0; afterimage.additive = arg1; 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; } function scr_afterimage_monochrome_parallax(arg0, arg1, arg2) { afterimage = instance_create(x, y, obj_afterimage_onecolor_parallax); afterimage.tint = arg0; afterimage.additive = arg1; 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; afterimage.parallax_depth = arg2; return afterimage; }
(afterimagecolor, true);
74
        with (afterimage)
75
        {
76
            y = other.y - other.jumppos;
77
            image_alpha = 0.25;
78
            fadeSpeed = 0.04;
79
            
scr_depth_alt
scr_depth_alt

function
scr_depth_alt(arg0 = id, arg1 = 0)
{ with (arg0) depth = 100000 - ((y * 10) + ((sprite_height - sprite_yoffset) * 10) + (arg1 * 10)); }
();
80
            depth += 1000;
81
        }
82
    }
83
    if (instance_exists(_mainchara))
84
    {
85
        if (_mainchara.hitstop <= 0)
86
        {
87
            var _xgoal = _mainchara.x - (followdist * image_xscale);
88
            var _ygoal = _mainchara.y + followy;
89
            var _distx = abs(x - _xgoal);
90
            var _disty = abs(y - _ygoal);
91
            y = 
scr_approach
scr_approach

function
scr_approach(arg0, arg1, arg2)
{ if (arg0 < arg1) { arg0 += arg2; if (arg0 > arg1) return arg1; } else { arg0 -= arg2; if (arg0 < arg1) return arg1; } return arg0; }
(y, _ygoal, _disty * yadjust);
92
            move_towards_point(_xgoal, y, _distx * 0.3);
93
        }
94
        else
95
        {
96
            hspeed = 0;
97
            vspeed = 0;
98
        }
99
    }
100
    if (!jumping)
101
        sprite_index = spr_run;
102
    else if (jumpspd >= 0)
103
        sprite_index = spr_jump;
104
    else
105
        sprite_index = spr_fall;
106
}
107
if (stopping)
108
{
109
    speed *= 0.5;
110
    sprite_index = spr_stop;
111
    image_index = 0;
112
    if (!jumping && abs(hspeed) > 0 && (t % 2) == 0)
113
    {
114
        with (scr_vfx_above(5966))
115
        {
116
            depth = other.depth + 2;
117
            y = other.bbox_bottom;
118
            image_xscale = other.image_xscale;
119
        }
120
    }
121
}
122
if (impact)
123
    
scr_depth
scr_depth

function
scr_depth(arg0 = id, arg1 = 0)
{ with (arg0) depth = 100000 - ((y * 10) + (sprite_height * 10) + (arg1 * 10)); }
(self);
124
var _can_drown = 1;
125
if (jumping)
126
{
127
    _can_drown = 0;
128
    jumppos += jumpspd;
129
    jumpspd -= jumpgravity;
130
    if (jumppos <= 0)
131
    {
132
        jumppos = 0;
133
        jumping = 0;
134
        if (impact)
135
        {
136
            if (bounces > 0)
137
            {
138
                _can_drown = 1;
139
                bounces--;
140
                jumping = 1;
141
                jumpspd = bonkheight;
142
                hspeed *= 0.75;
143
                snd_play_pitch(snd_punchmed, 0.9);
144
                shake = 4;
145
                sprite_index = spr_kris_plat_slash_airland;
146
                image_index = 0;
147
                image_speed = 0;
148
            }
149
            else
150
            {
151
                hspeed = 0;
152
                vspeed = 0;
153
                x -= 24;
154
                y -= 46;
155
                if (image_xscale < 0)
156
                    x -= sprite_width;
157
                if (name == "susie")
158
                {
159
                    sprite_index = spr_susie_dw_landed;
160
                    image_index = 0;
161
                }
162
                else if (global.flag[1311] == 1)
163
                {
164
                    sprite_index = spr_ralsei_getup_hat;
165
                }
166
                else
167
                {
168
                    sprite_index = spr_ralsei_kneel_serious;
169
                }
170
            }
171
        }
172
    }
173
}
174
if (!instance_place(x, y, obj_solidblock))
175
{
176
    last_openX = x;
177
    last_openY = y;
178
}
179
spawn_water_splash = false;
180
if (_can_drown && collision_line(x, bbox_bottom - 6, x, bbox_bottom, obj_waterpit, 0, 0) && !drown)
181
{
182
    var pit = instance_place(x, y + 6, obj_waterpit);
183
    if (pit.dash_across && !impacted)
184
    {
185
        spawn_water_splash = pit.ripple_palette + 1;
186
        if ((current_time % 10) == 0)
187
        {
188
        }
189
    }
190
    else
191
    {
192
        audio_stop_sound(snd_punchmed);
193
        snd_play(snd_splash);
194
        drown = 1;
195
        with (scr_vfx_above(7962))
196
            die_animend = 1;
197
        visible = 0;
198
        with (obj_plat_dashlines)
199
            owner = -4;
200
alarm[0]
201
alarm[1]
202
        exit;
203
    }
204
}
205
if (instance_place(x, y - abs(vspeed) - 2, obj_solidblock) && vspeed <= 0)
206
    vspeed = 0;
207
if (instance_place(x, y + abs(vspeed) + 4, obj_solidblock) && vspeed >= 0)
208
    vspeed = 0;