Deltarune (Chapter 4) script viewer

← back to main script listing

gml_Object_obj_chaseenemy_Step_2

(view raw script w/o annotations or w/e)
1
if (alertcon >= 1 && frozen == 0 && ignoresolid == 0)
2
{
3
    if (slide == 0)
4
    {
5
        if (collision_rectangle(bbox_left, bbox_top, bbox_right, bbox_bottom, obj_solidblock, false, true) || collision_rectangle(bbox_left, bbox_top, bbox_right, bbox_bottom, obj_solidenemy, false, true))
6
        {
7
            x -= hspeed;
8
            y -= vspeed;
9
            hspeed = 0;
10
            vspeed = 0;
11
        }
12
    }
13
    if (slide == 1)
14
    {
15
        var repositioned = 0;
16
        if (place_meeting(x, y, obj_solidblock) || place_meeting(x, y, obj_solidenemy))
17
        {
18
            if (!place_meeting(x - hspeed, y, obj_solidblock) && !place_meeting(x - hspeed, y, obj_solidenemy))
19
            {
20
                x -= hspeed;
21
                repositioned = 1;
22
            }
23
            if (!repositioned && !place_meeting(x, y - vspeed, obj_solidblock) && !place_meeting(x, y - vspeed, obj_solidenemy))
24
            {
25
                y -= vspeed;
26
                repositioned = 1;
27
            }
28
            if (!repositioned)
29
            {
30
                x -= hspeed;
31
                y -= vspeed;
32
            }
33
        }
34
    }
35
}
36
if (pacetype == 11)
37
{
38
    if (global.interact == 0)
39
    {
40
        if (path_speed == 0)
41
            path_speed = pathSpeed;
42
    }
43
    else
44
    {
45
        path_speed = 0;
46
    }
47
}
48
var dotouch = false;
49
if (customhitbox == 1)
50
    hitvar = collision_rectangle(x + hitx1, y + hity1, x + hitx2, y + hity2, obj_mainchara, true, true);
51
if (largetouchregion)
52
{
53
    var xx = x + (sprite_width / 2);
54
    var yy = y + (sprite_height / 2);
55
    var touched = collision_circle(xx, yy, largetouchregion, obj_mainchara, false, true);
56
    if (i_ex(touched))
57
        dotouch = true;
58
}
59
if ((place_meeting(x, y, obj_mainchara) && customhitbox == 0) || (customhitbox == 1 && hitvar != -4) || dotouch)
60
{
61
    if (global.interact == 0 || global.interact == 4)
62
    {
63
        if (encounterflag > 0)
64
            global.flag[54 encounter_pointer] = encounterflag;
65
        event_user(0);
66
    }
67
}