Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_mike_controller_Step_0

(view raw script w/o annotations or w/e)
1
var gpind = 0;
2
with (obj_gamecontroller)
3
    gpind = gamepad_id;
4
if (!global.use_mic)
5
{
6
    with (obj_mike_minigame_controller)
7
    {
8
        if (inv_mic)
9
            other.microphone_volume = 100 - other.microphone_volume;
10
    }
11
    var new_vol = 0;
12
    if (global.input_g[4] != gp_shoulderrb)
13
        new_vol = scr_shoulder_rb() * 100;
14
    else if (obj_gamecontroller.gamepad_shoulderlb_reassign)
15
        new_vol = scr_shoulder_lb() * 100;
16
    microphone_volume += ((new_vol - microphone_volume) * 0.25);
17
    with (obj_mike_minigame_controller)
18
    {
19
        if (inv_mic)
20
            other.microphone_volume = 100 - other.microphone_volume;
21
    }
22
}
23
if (global.right_click_mic)
24
{
25
    if (global.right_click_mic == 1)
26
    {
27
        if (device_mouse_check_button(0, mb_right))
28
            microphone_volume = 100;
29
        else
30
            microphone_volume = 0;
31
    }
32
    if (global.right_click_mic == 2)
33
    {
34
        if (button2_h())
35
            microphone_volume = 100;
36
        else
37
            microphone_volume = 0;
38
    }
39
    microphone_volume = clamp(microphone_volume, 0, 100);
40
    with (obj_mike_minigame_controller)
41
    {
42
        if (inv_mic)
43
            other.microphone_volume = 101 - other.microphone_volume;
44
    }
45
}
46
if (!__usable)
47
    exit;
48
if (battle_active && instance_number(obj_micmenu) == 0)
49
{
50
    if (grazenoise == 1)
51
    {
52
        snd_play(snd_graze);
53
        grazenoise = 0;
54
        with (obj_mike_minigame_controller)
55
        {
56
            if (phase == 2 && action == 1)
57
                myscore++;
58
        }
59
    }
60
    if (type != last_type)
61
    {
62
        if (type != 5)
63
        {
64
            if (type < 3)
65
                x = camerax() + (camerawidth() / 2);
66
            if (type > 2)
67
                y = cameray() + (cameraheight() / 2) + line_ypos;
68
        }
69
        else
70
        {
71
            phase = 0;
72
        }
73
        if (type == 15)
74
            x_target = camerax() + (camerawidth() / 2);
75
        if (type == 15)
76
            y_target = (cameray() + (cameraheight() / 2)) - 32;
77
        circle_width = 0;
78
        circle_height = 0;
79
        gravity = 0;
80
        speed = 0;
81
        size2 = 30;
82
        size3 = 13;
83
        mx = x;
84
        my = y;
85
        line_side = choose(1, -1);
86
        line_xpos = 0;
87
        hand_speed = 0;
88
        last_type = type;
89
    }
90
    if (phase == 0)
91
    {
92
        with (obj_heart)
93
        {
94
        }
95
        x += ((newx - x) * 0.25);
96
        y += ((newy - y) * 0.25);
97
        x = 
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; }
(x, newx, 1);
98
        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, newy, 1);
99
        if (x == newx && y == newy)
100
        {
101
            size2 = 30;
102
            size3 = 13;
103
            phase = 1;
104
            type = 5;
105
        }
106
    }
107
    if (sign_action == 0)
108
    {
109
        sign_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; }
(sign_y, sign_ystart, 12);
110
        if (instance_number(obj_mike_crowd) > 0 || instance_number(obj_mike_pipe) > 0)
111
            sign_action = 1;
112
    }
113
    if (sign_action == 1)
114
    {
115
        sign_vspeed += 0.25;
116
        sign_y += sign_vspeed;
117
        if (sign_y > -1)
118
        {
119
            sign_vspeed *= -0.4;
120
            sign_bounce += 1;
121
        }
122
        if (sign_bounce >= 3)
123
        {
124
            sign_vspeed = 0;
125
            sign_bounce = 0;
126
            sign_y = 0;
127
            sign_action = 2;
128
            if ((sign_col == 65280 || sign_col == 65535) && obj_mike_attack_controller.wave != 0.1)
129
                sign_sound = snd_play_x(snd_crowd, 1, 1);
130
            if (sign_col == 255)
131
            {
132
                sign_sound = snd_play(snd_shh);
133
                mus_volume(global.batmusic[1], 0, 0);
134
            }
135
        }
136
    }
137
    if (sign_action == 2)
138
    {
139
        if (instance_number(obj_mike_crowd) == 0 && instance_number(obj_mike_pipe) == 0 && obj_mike_attack_controller.wave != 0.1)
140
        {
141
            sign_action = 0;
142
            sign_col = 8421504;
143
            snd_stop(sign_sound);
144
            sign_sound = -1;
145
        }
146
    }
147
    if (sign_action2 == 0)
148
        sign_y2 = 
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; }
(sign_y2, sign_ystart, 12);
149
    if (sign_action2 == 1)
150
    {
151
        sign_y2 = 
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; }
(sign_y2, 0, 4);
152
        if (sign_y2 == 0)
153
        {
154
            sign_action2 = 2;
155
            snd_play(snd_shh);
156
            snd_stop(sign_sound);
157
            sign_sound = -1;
158
            mus_volume(global.batmusic[1], 0, 0);
159
        }
160
    }
161
    if (sign_action2 == 2)
162
    {
163
        if (instance_number(obj_mike_quiet) == 0)
164
        {
165
            sign_action2 = 0;
166
            mus_volume(global.batmusic[1], 1, 50);
167
        }
168
    }
169
    if (type == 1 || type == 2)
170
    {
171
        var my_gravity = 1;
172
        var ymax = [];
173
        ymax[0] = cameray() + 32;
174
        ymax[1] = cameray() + 300;
175
        ymax[2] = cameray() + 64;
176
        wait -= 1;
177
        var new_volume = min(12, microphone_volume / 6);
178
        if (room == room_dw_castle_tv_zone_minigame)
179
        {
180
            ymax[1] = cameray() + 340;
181
            if (i_ex(obj_mike_quiet))
182
                my_gravity = 2;
183
            else
184
                my_gravity = 0.25;
185
        }
186
        if (i_ex(obj_mike_quiet))
187
            my_gravity = 2;
188
        if (wait > 0)
189
            new_volume = 0;
190
        if (new_volume > wingbox_volume_thereshold)
191
        {
192
            y -= lerp(1, 11, (new_volume - wingbox_volume_thereshold) / (12 - wingbox_volume_thereshold));
193
            gravity = 0;
194
            vspeed = 0;
195
        }
196
        else
197
        {
198
            gravity = my_gravity;
199
            vspeed = max(vspeed, 2);
200
        }
201
        reload += 1;
202
        if (reload > (max(1, (100 - microphone_volume) * 0.1) * 2) && microphone_volume > (wingbox_volume_thereshold * 6))
203
        {
204
            reload = 0;
205
            wing_angle1 = 10;
206
            wing_angle2 = 270;
207
            size2 = 21;
208
        }
209
        vspeed = clamp(vspeed, -10, 10);
210
        y = max(y, ymax[0]);
211
        if (y <= ymax[0])
212
            wait = 1;
213
        if (y > ymax[1])
214
        {
215
            vspeed = 0;
216
            y = ymax[1];
217
        }
218
        if (vspeed > 0)
219
        {
220
            wing_angle3 = 90;
221
            wing_angle2 = 90;
222
        }
223
        if (vspeed == 0 && new_volume <= 1)
224
        {
225
            wing_angle3 = 270;
226
            wing_angle2 = 270;
227
            wing_angle1 = 270;
228
        }
229
        wing_angle1 += ((wing_angle2 - wing_angle1) * 0.2);
230
        wing_angle2 += ((wing_angle3 - wing_angle2) * 0.01);
231
    }
232
    if (type == 3 || type == 4)
233
    {
234
        var new_volume = min(12, microphone_volume / 8);
235
        if (new_volume > 1)
236
            line_xpos += (line_side * new_volume);
237
        if (line_side == 1 && line_xpos >= line_width)
238
        {
239
            line_side = -1;
240
            line_xpos = line_width;
241
            size2 = 20;
242
        }
243
        else if (line_side == -1 && line_xpos <= -line_width)
244
        {
245
            line_side = 1;
246
            line_xpos = -line_width;
247
            size2 = 20;
248
        }
249
        if (room == room_dw_castle_tv_zone_minigame)
250
        {
251
            if (abs(x - scr_mouse_x()) > 60)
252
            {
253
                if (scr_mouse_x() > x)
254
                    line_side = 1;
255
                else
256
                    line_side = -1;
257
            }
258
        }
259
        x = camerax() + (camerawidth() / 2) + line_xpos;
260
    }
261
    if (type == 6)
262
    {
263
        circle_width = 
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; }
(circle_width, 75, 8);
264
        circle_height = 
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; }
(circle_height, 75, 8);
265
    }
266
    if (type == 7)
267
    {
268
        circle_width = 
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; }
(circle_width, 50, 8);
269
        circle_height = 
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; }
(circle_height, 50, 8);
270
    }
271
    if (type >= 5 && type <= 7)
272
    {
273
        var new_volume = min(12, microphone_volume / 4);
274
        if (new_volume > 1)
275
            new_dir -= new_volume;
276
        dir += ((new_dir - dir) * 0.25);
277
        if (type == 5)
278
        {
279
            size2 = max(13, new_volume * 2);
280
        }
281
        else
282
        {
283
            x = camerax() + (camerawidth() / 2) + lengthdir_x(circle_width, dir);
284
            y = cameray() + (cameraheight() / 2) + lengthdir_y(circle_height, dir) + circle_offset;
285
        }
286
    }
287
}
288
if (type == 9)
289
{
290
    var new_volume = min(12, microphone_volume / 8);
291
    line_width = 200;
292
    if (new_volume > 1)
293
        line_xpos += (line_side * new_volume);
294
    if (line_side == 1 && line_xpos >= line_width)
295
    {
296
        line_side = -1;
297
        line_xpos = line_width;
298
        size2 = 20;
299
    }
300
    else if (line_side == -1 && line_xpos <= -line_width)
301
    {
302
        line_side = 1;
303
        line_xpos = -line_width;
304
        size2 = 20;
305
    }
306
    if (room == room_dw_castle_tv_zone_minigame)
307
    {
308
        if (abs(y - mouse_y) > 30)
309
        {
310
            if (mouse_y > y)
311
                line_side = 1;
312
            else
313
                line_side = -1;
314
        }
315
    }
316
    y = 90 + line_xpos;
317
}
318
if ((type == 2 || type == 4 || type == 5 || type >= 7) && global.interact != 5)
319
{
320
    var _y_offset = 0;
321
    if (type == 8 && hand_type == 2)
322
        _y_offset = -30;
323
    var hd = hand_distance;
324
    if (type == 15)
325
        hd = 100;
326
    if (type == 8)
327
        y = lerp(y, clamp(my - _y_offset, 90, 290), 0.5);
328
    if (global.is_console || onSteamDeck())
329
    {
330
        var _dist = point_distance(0, 0, gamepad_axis_value(gpind, gp_axislh), gamepad_axis_value(gpind, gp_axislv)) * hd;
331
        var _dir = 
scr_joystick
scr_joystick

function
scr_joystick(arg0, arg1)
{ var ___x = arg0; var ___y = arg1; var ___n = sqrt(sqr(___x) + sqr(___y)); return radtodeg(arctan2(-___y / ___n, ___x / ___n)); }
(gamepad_axis_value(gpind, gp_axislh), gamepad_axis_value(gpind, gp_axislv));
332
        if ((abs(gamepad_axis_value(gpind, gp_axislh)) + abs(gamepad_axis_value(gpind, gp_axislv))) > 0.1)
333
        {
334
            mx += (((x + lengthdir_x(_dist, _dir)) - mx) * 0.2);
335
            my += (((y + lengthdir_y(min(_dist, 200), _dir)) - my) * 0.2);
336
        }
337
        hand_speed = 
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; }
(hand_speed, 0.999, 0.1);
338
    }
339
    else
340
    {
341
        var _dist = min(hd, point_distance(x, y, scr_mouse_x(), scr_mouse_y()));
342
        var _dir = point_direction(x, y, scr_mouse_x(), scr_mouse_y());
343
        hand_speed = 
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; }
(hand_speed, 0.999, 0.1);
344
        mx += (((x + lengthdir_x(_dist, _dir)) - mx) * hand_speed);
345
        my += (((y + lengthdir_y(min(_dist, 200), _dir) + _y_offset) - my) * hand_speed);
346
    }
347
    if (type == 15)
348
    {
349
        hspeed *= 0.75;
350
        hspeed = clamp(hspeed + ((mx - x) / 50), -14, 14);
351
        x = clamp(x, 0, 640);
352
        x_target = x + hspeed;
353
        y = lerp(y, cameray() + (0.5 * cameraheight()) + clamp(0, -200, 8), 0.15);
354
        vspeed *= 0.9;
355
        y_target = y + vspeed;
356
        x = lerp(x, x_target, 0.3);
357
        y = lerp(y, y_target, 0.3);
358
    }
359
    if (scr_mouse_leftclick() && instance_number(obj_micmenu) == 0 && !i_ex(obj_dialoguer) && global.interact != 1 && hand_wait < 0 && hand_type == 0 && instance_number(obj_battleblcon) == 0 && (instance_number(obj_mike_attack_controller) == 0 || !obj_mike_attack_controller.talking))
360
    {
361
        hand_wait = hand_anim;
362
        with (instance_create(mx + lengthdir_x(16, point_direction(x, y, mx, my)), my + lengthdir_y(16, point_direction(x, y, mx, my)), obj_hand_collision))
363
            
scr_doom
scr_doom

function
scr_doom(arg0 = id, arg1)
{ with (instance_create_depth(0, 0, 0, obj_doom)) { alarm[0] target = arg0; persistent = arg0.persistent; } }
(id, other.hand_wait);
364
        var _juggle = 0;
365
        if (collision_circle(mx, my, 24, obj_mike_ball, 0, 0))
366
            _juggle = true;
367
        if (!_juggle)
368
        {
369
            var _sfx = snd_play(snd_wing);
370
            snd_volume(_sfx, 0.5, 0);
371
            snd_pitch(_sfx, random_range(0.95, 1.05));
372
            with (obj_mike_hand)
373
alarm[0]
374
        }
375
        if (i_ex(obj_mike_ball))
376
        {
377
            with (obj_hand_collision)
378
            {
379
                image_xscale = 0.33;
380
                image_yscale = 0.33;
381
            }
382
        }
383
        if (i_ex(obj_mike_combo) && scr_mouse_x() > 180 && scr_mouse_x() < 480)
384
        {
385
            with (obj_hand_collision)
386
            {
387
                image_xscale = 1;
388
                image_yscale = 1.5;
389
            }
390
        }
391
        var ob = instance_create(mx + lengthdir_x(16, point_direction(x, y, mx, my)), my + lengthdir_y(16, point_direction(x, y, mx, my)), obj_hand_shake);
392
        with (ob)
393
        {
394
            dir = point_direction(other.x, other.y, other.mx, other.my) - 90;
395
            x = xstart + lengthdir_x(8, dir);
396
            y = ystart + lengthdir_y(8, dir);
397
            motion_set(dir, 2);
398
            image_angle = direction;
399
            depth = obj_mike_hand.depth;
400
        }
401
        ob = instance_create(mx + lengthdir_x(16, point_direction(x, y, mx, my)), my + lengthdir_y(16, point_direction(x, y, mx, my)), obj_hand_shake);
402
        with (ob)
403
        {
404
            dir = point_direction(other.x, other.y, other.mx, other.my) + 90;
405
            x = xstart + lengthdir_x(8, dir);
406
            y = ystart + lengthdir_y(8, dir);
407
            motion_set(dir, 2);
408
            image_angle = direction;
409
            depth = obj_mike_hand.depth;
410
        }
411
    }
412
    if (!i_ex(obj_dialoguer))
413
    {
414
        var ob = collision_circle(mx, my, 24, obj_mike_grabcat, 1, 0);
415
        var ob2 = collision_circle(mx, my, 24, obj_gravity_ball, 1, 0);
416
        var ob3 = collision_circle(mx, my, 24, obj_mike_grabcat_pluey, 1, 0);
417
        if (ob || ob3)
418
        {
419
            if (hand_type == 0)
420
                hand_type = 1;
421
            if (scr_mouse_leftclick())
422
            {
423
                if (ob == -4)
424
                    ob = ob3;
425
                with (ob)
426
                {
427
                    action = 1;
428
                    speed = 0;
429
                    gravity = 0;
430
                    xscale = 1;
431
                    if (ob == ob3)
432
                    {
433
                        var li = ds_list_create();
434
                        instance_place_list(x, y, 594, li, false);
435
                        for (var i = 0; i < ds_list_size(li); i++)
436
                            instance_destroy(ds_list_find_value(li, i));
437
                        ds_list_destroy(li);
438
                        sprite_index = spr_mike_cat_hold_outline_smallhitbox;
439
                    }
440
                    else
441
                    {
442
                        sprite_index = spr_mike_cat_hold;
443
                    }
444
                }
445
                hand_type = 2;
446
                hand_target = ob;
447
            }
448
        }
449
        else if (ob2)
450
        {
451
            if (hand_type == 0)
452
                hand_type = 1;
453
            if (scr_mouse_leftclick())
454
            {
455
                with (ob2)
456
                {
457
                    action = 1;
458
                    speed = 0;
459
                    gravity = 0;
460
                    xscale = 1;
461
                }
462
                hand_type = 2;
463
                hand_target = ob2;
464
            }
465
        }
466
        else if (battle_active)
467
        {
468
            if (hand_type == 1)
469
                hand_type = 0;
470
        }
471
        if (hand_target != -1)
472
        {
473
            hand_type = 2;
474
            if (!instance_exists(hand_target))
475
            {
476
                hand_type = 0;
477
                hand_target = -1;
478
            }
479
        }
480
        if (hand_type == 2 && !scr_mouse_left())
481
        {
482
            hand_type = 0;
483
            with (hand_target)
484
            {
485
                action = 5;
486
                if (object_index == obj_mike_grabcat_pluey)
487
                {
488
                    var _averagex2frame = (x + xprevious) / 2;
489
                    var _averagey2frame = (y + yprevious) / 2;
490
                    var _averagex4frame = (last_x[1] + last_x[2]) / 2;
491
                    var _averagey4frame = (last_y[1] + last_y[2]) / 2;
492
                    var aag2 = abs(_averagex2frame) + abs(_averagey2frame);
493
                    var aag4 = abs(_averagex4frame) + abs(_averagey4frame);
494
                    if (aag4 < 350)
495
                    {
496
                        _averagex4frame = _averagex2frame;
497
                        _averagey4frame = _averagey2frame;
498
                        aag4 = aag2;
499
                    }
500
                    var _spd = max(2, point_distance(_averagex4frame, _averagey4frame, _averagex2frame, _averagey2frame) / 4);
501
                    var _dir = point_direction(_averagex4frame, _averagey4frame, _averagex2frame, _averagey2frame);
502
                    var mult = 1;
503
                    if (aag2 > 500 && aag2 >= aag4)
504
                        mult = 1.5;
505
                    hspeed = lengthdir_x(_spd, _dir) * mult;
506
                    vspeed = lengthdir_y(_spd, _dir) * mult;
507
                }
508
            }
509
            hand_target = -1;
510
        }
511
    }
512
}
513
with (obj_hand_collision)
514
{
515
    x = other.mx + lengthdir_x(24, point_direction(other.x, other.y, other.mx, other.my));
516
    y = other.my + lengthdir_y(24, point_direction(other.x, other.y, other.mx, other.my));
517
}
518
if (hand_wait > 0)
519
    hand_angle = sin(current_time / 20) * 15;
520
else
521
    hand_angle = 
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; }
(hand_angle, 0, 2);
522
hand_wait -= 1;
523
if (room == room_dw_castle_tv_zone_3 && i_ex(obj_actor))
524
{
525
    x = obj_room_castle_tv_zone_3.kr_actor.x + 20;
526
    y = obj_room_castle_tv_zone_3.kr_actor.y + 48;
527
}
528
else if (!battle_active && instance_number(obj_mainchara) == 1)
529
{
530
    x = obj_mainchara.x + 20;
531
    y = obj_mainchara.y + 48;
532
}