Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_homealone_present_fallen_ball_floor_Step_0

(view raw script w/o annotations or w/e)
1
if (!i_ex(obj_homealone_dess_closet_kris))
2
    exit;
3
if (!push)
4
{
5
    var push_type = 0;
6
    if ((x - (sprite_width / 2)) < (obj_homealone_dess_closet_kris.x + 5))
7
    {
8
        if (collision_rectangle(x - (sprite_width / 2) - 20, y - (sprite_height / 2), x - (sprite_width / 2) - 20, y + (sprite_height / 2), obj_homealone_dess_closet_kris, false, true))
9
            push_type = 1;
10
    }
11
    if ((x + (sprite_width / 2)) > (obj_homealone_dess_closet_kris.x + 18))
12
    {
13
        if (collision_rectangle(x - (sprite_width / 2), y - (sprite_height / 2), x - (sprite_width / 2), y + (sprite_height / 2), obj_homealone_dess_closet_kris, false, true))
14
            push_type = 2;
15
    }
16
    if (push_type > 0)
17
    {
18
        push = true;
19
        var random_offset = irandom(8);
20
        target_x = (push_type == 1) ? (x - 20 - random_offset) : (x + 20 + random_offset);
21
    }
22
}
23
else
24
{
25
    x = 
scr_movetowards
scr_movetowards

function
scr_movetowards(arg0, arg1, arg2)
{ if (arg0 == arg1) return arg0; else if (arg0 > arg1) return max(arg0 - arg2, arg1); else return min(arg0 + arg2, arg1); } function scr_obj_movetowards_obj(arg0, arg1, arg2 = 0, arg3 = 0) { scr_obj_movetowards_point(arg0.x + arg2, arg0.y + arg3, arg1); } function scr_obj_movetowards_point(arg0, arg1, arg2) { var _distance = point_distance(x, y, arg0, arg1); if (arg2 >= _distance) { x = arg0; y = arg1; } else { var _direction = point_direction(x, y, arg0, arg1); x += lengthdir_x(arg2, _direction); y += lengthdir_y(arg2, _direction); } }
(x, target_x, 0.8);
26
    if (abs(x - target_x) < 0.1 || x >= 300 || x <= 115)
27
        push = false;
28
}