Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_box_throw_controller_Step_0

(view raw script w/o annotations or w/e)
1
timer++;
2
full_timer++;
3
switch (timer)
4
{
5
    case 15:
6
        visible = false;
7
        instance_create(x + 64, y + 36, obj_gerson_teleport_generic);
8
        x = obj_growtangle.x + 80;
9
        y = obj_growtangle.y - 20;
10
        anchor_x = x;
11
        anchor_y = y;
12
        break;
13
    case 19:
14
        with (obj_gerson_teleport_generic)
15
            instance_destroy();
16
        sprite_index = spr_gerson_swing;
17
        instance_create(x + 58, y + 36, obj_gerson_teleport_generic);
18
        break;
19
    case 23:
20
        with (obj_gerson_teleport_generic)
21
            instance_destroy();
22
        visible = true;
23
        image_index = 0;
24
        image_speed = 0;
25
        
scr_lerpvar
scr_lerpvar

function
scr_lerpvar()
{ if (argument_count < 6) ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3]);
else ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3], argument[4], argument[5]);
return ___lerpvar; } function scr_lerpvar_respect() { if (argument_count < 6) ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3]);
else ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3], argument[4], argument[5]);
___lerpvar.respectglobalinteract = true; return ___lerpvar; }
("image_index", 0, 6, 12);
26
        snd_play(motor_upper_quick_mid);
27
        break;
28
    case 31:
29
        snd_play(snd_queen_punched_lower);
30
        
scr_shakeobj
scr_shakeobj

function
scr_shakeobj()
{ var _shakeobj = instance_create(x, y, obj_shakeobj); _shakeobj.target = id; if (argument_count >= 1) { if (i_ex(argument0)) _shakeobj.target = argument0; } if (argument_count >= 2) { if (argument1 != -1) _shakeobj.shakeamt = argument1; } if (argument_count >= 3) { if (argument2 != -1) _shakeobj.shakereduct = argument2; } with (_shakeobj) event_user(0); }
();
31
        with (obj_growtangle)
32
        {
33
            
scr_lerpvar
scr_lerpvar

function
scr_lerpvar()
{ if (argument_count < 6) ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3]);
else ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3], argument[4], argument[5]);
return ___lerpvar; } function scr_lerpvar_respect() { if (argument_count < 6) ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3]);
else ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3], argument[4], argument[5]);
___lerpvar.respectglobalinteract = true; return ___lerpvar; }
("x", x, x - 80, 10, 2, "out");
34
            
scr_lerpvar
scr_lerpvar

function
scr_lerpvar()
{ if (argument_count < 6) ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3]);
else ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3], argument[4], argument[5]);
return ___lerpvar; } function scr_lerpvar_respect() { if (argument_count < 6) ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3]);
else ___lerpvar =
scr_lerpvar_instance(id, argument[0], argument[1], argument[2], argument[3], argument[4], argument[5]);
___lerpvar.respectglobalinteract = true; return ___lerpvar; }
("image_angle", image_angle, image_angle + 135, 12, 2, "out");
35
        }
36
        break;
37
}
38
if (timer > 30 && timer < 41)
39
{
40
    with (obj_growtangle)
41
    {
42
        with (
scr_afterimagefast
scr_afterimagefast

function
scr_afterimagefast()
{ 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; afterimage.fadeSpeed = 0.08; return afterimage; }
())
43
            fadeSpeed *= 3;
44
    }
45
}
46
if (hammer_phase == 0)
47
{
48
    if (timer > 84)
49
    {
50
        timer -= (30 + irandom(12));
51
        snd_play_pitch(snd_jump, 2);
52
        var new_x = 0;
53
        if (x < anchor_x)
54
            new_x = 30 + irandom(30);
55
        else if (x > anchor_x)
56
            new_x = -30 - irandom(30);
57
        else
58
            new_x = choose(-60, 60);
59
        
scr_jump_arc
scr_jump_arc

function
scr_jump_arc(arg0 = id, arg1 = x, arg2 = y, arg3, arg4, arg5, arg6)
{ var _jump = instance_create(0, 0, obj_jump_arc); with (_jump) { master = arg0; origx = arg1; origy = arg2; goalx = arg3; goaly = arg4; zheight = arg5; time = arg6; jump_start(); } return _jump; }
(id, x, y, anchor_x + new_x, anchor_y + irandom_range(-20, 20), 70 + irandom(30), 24);
60
    }
61
}
62
if (timer > 36)
63
    hammer_timer++;
64
if (hammer_phase == 0)
65
{
66
    if (hammer_timer == hammer_timer_goal)
67
    {
68
        snd_stop(snd_smallswing);
69
        snd_play_pitch(snd_smallswing, 1 + random(0.3));
70
        var hammer_amount = 3 + irandom(1);
71
        if (!irandom(3))
72
            hammer_cmount = 2;
73
        var hammer_type = 1;
74
        var small_offset = irandom_range(-30, 30);
75
        for (var a = 0; a < hammer_amount; a++)
76
        {
77
            with (instance_create((x + 100) - 42, (y + 90) - 86, obj_gerson_hammer_bro_hammer))
78
            {
79
                
scr_bullet_init
scr_bullet_init

function
scr_bullet_init()
{ grazed = 0; grazetimer = 0; destroyonhit = 1; target = 0; inv = 60; damage = 10; element = 0; grazepoints = 1; timepoints = 1; active = 1; updateimageangle = 0; }
();
80
                active = 1;
81
                
scr_darksize
scr_darksize

function
scr_darksize()
{ var inst = id; if (argument_count) inst = argument0; inst.image_xscale = 2; inst.image_yscale = 2; }
();
82
                if (hammer_type)
83
                    fakehspeed = (-abs(x - (obj_growtangle.x + small_offset)) / 45) + (-2 + ((4 / (hammer_amount - 1)) * a)) + random_range(-0.5, 0.5);
84
                else
85
                    fakehspeed = -abs(x - (obj_growtangle.x + small_offset)) / 45;
86
                if (hammer_type)
87
                    fakevspeed = -14 + (-1 + ((2 / (hammer_amount - 1)) * a)) + random_range(-1, 1);
88
                else
89
                    fakevspeed = -14;
90
                gravity_direction = 270;
91
                fakegravity = 0.6;
92
                depth -= 1;
93
                target = 3;
94
                damage = 1;
95
                grazed = 0;
96
                grazepoints = 2.5;
97
            }
98
        }
99
        sprite_index = spr_gerson_hammer_throw;
100
        image_index = 0.1;
101
        hammer_timer = 0;
102
        hammer_counter++;
103
        if (hammer_counter == 16)
104
        {
105
            hammer_counter = 0;
106
            hammer_phase = 1;
107
            hammer_timer = -12;
108
            hammer_timer_goal = 3;
109
        }
110
    }
111
}
112
if (hammer_phase == 1)
113
{
114
    if (hammer_timer == hammer_timer_goal)
115
    {
116
        snd_stop(snd_smallswing);
117
        snd_play_pitch(snd_smallswing, 0.75 + random(0.3));
118
        var hammer_amount = 1;
119
        for (var a = 0; a < hammer_amount; a++)
120
        {
121
            with (instance_create((x + 100) - 42, (y + 90) - 86, obj_gerson_hammer_bro_hammer))
122
            {
123
                
scr_bullet_init
scr_bullet_init

function
scr_bullet_init()
{ grazed = 0; grazetimer = 0; destroyonhit = 1; target = 0; inv = 60; damage = 10; element = 0; grazepoints = 1; timepoints = 1; active = 1; updateimageangle = 0; }
();
124
                active = 1;
125
                
scr_darksize
scr_darksize

function
scr_darksize()
{ var inst = id; if (argument_count) inst = argument0; inst.image_xscale = 2; inst.image_yscale = 2; }
();
126
                image_xscale++;
127
                image_yscale++;
128
                if (hammer_amount == 1)
129
                {
130
                    fakehspeed = -abs((x - (obj_growtangle.x + (sin(other.full_timer * 0.325) * 80))) / 45) + random_range(-0.25, 0.25);
131
                    fakevspeed = -14 + random_range(-0.5, 0.5);
132
                }
133
                else
134
                {
135
                    fakehspeed = (-abs(x - (obj_growtangle.x + (sin(other.full_timer * 0.325) * 80))) / 45) + ((-hammer_amount * 0.75) + (((hammer_amount * 2 * 0.75) / (hammer_amount - 1)) * a)) + random_range(-0.25, 0.25);
136
                    fakevspeed = -14 + (-1 + ((2 / (hammer_amount - 1)) * a)) + random_range(-0.5, 0.5);
137
                }
138
                gravity_direction = 270;
139
                fakegravity = 0.6;
140
                depth -= 1;
141
                target = 3;
142
                damage = 1;
143
                grazed = 0;
144
                grazepoints = 2.5;
145
            }
146
        }
147
        sprite_index = spr_gerson_hammer_throw;
148
        image_index = 0.1;
149
        hammer_timer = 0;
150
        hammer_counter++;
151
        if ((hammer_counter % 5) == 0)
152
            hammer_timer = -4;
153
        if (hammer_counter == 25)
154
        {
155
            hammer_counter = 0;
156
            hammer_phase = 2;
157
            hammer_timer = 0;
158
        }
159
    }
160
}
161
if (hammer_phase == 2)
162
{
163
    if (hammer_timer == 1)
164
    {
165
        snd_play_pitch(snd_jump, 2);
166
        
scr_jump_arc
scr_jump_arc

function
scr_jump_arc(arg0 = id, arg1 = x, arg2 = y, arg3, arg4, arg5, arg6)
{ var _jump = instance_create(0, 0, obj_jump_arc); with (_jump) { master = arg0; origx = arg1; origy = arg2; goalx = arg3; goaly = arg4; zheight = arg5; time = arg6; jump_start(); } return _jump; }
(id, x, y, xstart - 30, ystart, 80, 32);
167
        image_index = 0;
168
        snd_play(snd_boost);
169
        my_flash = 
scr_custom_afterimage_ext
scr_custom_afterimage_ext

function
scr_custom_afterimage_ext(arg0, arg1, arg2, arg3, arg4, arg5, arg6)
{ afterimage = instance_create(arg3, arg4, arg0); afterimage.sprite_index = arg1; afterimage.image_index = arg2; afterimage.image_blend = image_blend; afterimage.image_speed = 0; afterimage.depth = depth + 1; afterimage.image_angle = image_angle; afterimage.image_xscale = arg5; afterimage.image_yscale = arg6; return afterimage; }
(obj_oflash, sprite_index, image_index, x, y - z, image_xscale, image_yscale);
170
        with (my_flash)
171
        {
172
            target = other.id;
173
            image_index = other.image_index;
174
            image_speed = 0;
175
            depth = other.depth - 1;
176
        }
177
    }
178
    if (hammer_timer >= 2 && hammer_timer < 24 && (hammer_timer % 3) == 0)
179
    {
180
        with (
scr_oflash
scr_oflash

function
scr_oflash()
{ _oflash = instance_create(x, y, obj_oflash); _oflash.image_xscale = image_xscale; _oflash.image_speed = 0; _oflash.image_index = image_index; _oflash.image_yscale = image_yscale; _oflash.sprite_index = sprite_index; _oflash.depth = depth - 1; _oflash.target = id; return _oflash; }
())
181
        {
182
            depth += 1;
183
            y -= other.z;
184
            flashcolor = c_lime;
185
        }
186
    }
187
    if (hammer_timer == 9)
188
    {
189
        snd_stop(snd_smallswing);
190
        snd_play_pitch(snd_smallswing, 0.5);
191
        with (instance_create((x + 100) - 42, (y + 90) - 86, obj_gerson_hammer_bro_hammer))
192
        {
193
            
scr_bullet_init
scr_bullet_init

function
scr_bullet_init()
{ grazed = 0; grazetimer = 0; destroyonhit = 1; target = 0; inv = 60; damage = 10; element = 0; grazepoints = 1; timepoints = 1; active = 1; updateimageangle = 0; }
();
194
            
scr_darksize
scr_darksize

function
scr_darksize()
{ var inst = id; if (argument_count) inst = argument0; inst.image_xscale = 2; inst.image_yscale = 2; }
();
195
            image_xscale += 6;
196
            image_yscale += 6;
197
            mask_index = spr_gerson_gigahammer_mask;
198
            fakehspeed = -abs((x - obj_growtangle.x) / 25.5);
199
            fakevspeed = -16;
200
            destroyonhit = false;
201
            gigahammer = true;
202
            gravity_direction = 270;
203
            fakegravity = 0.6;
204
            depth = other.depth + 1;
205
            target = 3;
206
            damage = 1;
207
            grazed = 0;
208
            grazepoints = 2.5;
209
        }
210
        sprite_index = spr_gerson_hammer_throw;
211
        image_index = 0.1;
212
    }
213
    if (hammer_timer == 36)
214
    {
215
        sprite_index = spr_gerson_spin;
216
        image_speed = 0.125;
217
        x += 60;
218
        y += 60;
219
    }
220
}
221
if ((403 - full_timer) < 8 && ending_counter == 0)
222
{
223
    ending_counter = 1;
224
    visible = false;
225
    instance_create(x, y - 40, obj_gerson_teleport_generic);
226
}
227
if ((403 - full_timer) < 4 && ending_counter == 1)
228
{
229
    ending_counter = 2;
230
    with (obj_gerson_teleport_generic)
231
        instance_destroy();
232
    instance_create(obj_hammer_of_justice_enemy.x + 68, obj_hammer_of_justice_enemy.y + 36, obj_gerson_teleport_generic);
233
}
234
if ((403 - full_timer) < 2 && ending_counter == 2)
235
{
236
    ending_counter = 3;
237
    global.turntimer = 1;
238
}
239
if (global.turntimer < 1)
240
{
241
    with (obj_gerson_teleport_generic)
242
        instance_destroy();
243
    with (obj_hammer_of_justice_enemy)
244
        visible = true;
245
    instance_destroy();
246
}
247
if (sprite_index == spr_gerson_spin)
248
    image_index %= 4;
249
if (sprite_index == spr_gerson_hammer_throw && image_index > 0)
250
{
251
    image_index = 
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; }
(image_index, 3, 0.5);
252
    if (image_index == 3)
253
    {
254
        if (hammer_phase == 2)
255
            image_index = 2;
256
        else
257
            image_index = 0;
258
    }
259
}
260
with (obj_heart)
261
{
262
    if (place_meeting(x, y, obj_battlesolid))
263
    {
264
        x += lengthdir_x(1, point_direction(x + 10, y + 10, obj_growtangle.x, obj_growtangle.y));
265
        y += lengthdir_y(1, point_direction(x + 10, y + 10, obj_growtangle.x, obj_growtangle.y));
266
    }
267
}