Deltarune (Chapter 2) script viewer

← back to main script listing

gml_Object_obj_swatch_potchaser_Step_0

(view raw script w/o annotations or w/e)
1
if (dir == "left")
2
{
3
    if (target.going == "left")
4
    {
5
        sprite_index = spr_npc_butler;
6
        image_xscale = 2;
7
        x = target.x + 20;
8
        y = target.y - 156;
9
    }
10
    if (target.going == "right")
11
    {
12
        sprite_index = spr_npc_swatchling_scared;
13
        image_xscale = -2;
14
        x = target.x + 120;
15
        y = target.y - 150;
16
    }
17
}
18
if (dir == "right")
19
{
20
    if (target.going == "left")
21
    {
22
        sprite_index = spr_npc_swatchling_scared;
23
        image_xscale = 2;
24
        x = target.x - 120;
25
        y = target.y - 150;
26
    }
27
    if (target.going == "right")
28
    {
29
        sprite_index = spr_npc_butler;
30
        image_xscale = -2;
31
        x = target.x - 20;
32
        y = target.y - 156;
33
    }
34
}
35
if (abs(target.tellspeed) < 3)
36
    image_speed = abs(target.tellspeed) / 15;
37
else
38
    image_speed = 0.25;
39
if (sprite_index == spr_npc_swatchling_scared && image_xscale == 2)
40
{
41
    colX = 30;
42
    colY = 116;
43
}
44
if (sprite_index == spr_npc_swatchling_scared && image_xscale == -2)
45
{
46
    colX = -71;
47
    colY = 116;
48
}
49
if (sprite_index == spr_npc_butler && image_xscale == 2)
50
{
51
    colX = 61;
52
    colY = 122;
53
}
54
if (sprite_index == spr_npc_butler && image_xscale == -2)
55
{
56
    colX = -101;
57
    colY = 122;
58
}
59
if (point_in_rectangle(charaX(), charaY(), x + colX, y + colY, x + colX + 40, y + colY + 34) || (instance_exists(obj_caterpillarchara) && point_in_rectangle(obj_caterpillarchara.x + (obj_caterpillarchara.sprite_width / 2), (obj_caterpillarchara.y + obj_caterpillarchara.sprite_height) - 8, x + colX, y + colY, x + colX + 40, y + colY + 34)))
60
{
61
    if (room == room_dw_mansion_east_2f_c)
62
    {
63
        if (instance_exists(obj_swatch_potchaser))
64
        {
65
            with (obj_swatch_potchaser)
66
            {
67
                newenem = instance_create(x, y, obj_chaseenemy);
68
                with (newenem)
69
                {
70
                    if (other.sprite_index == spr_npc_swatchling_scared)
71
                    {
72
                        if (other.image_xscale == -2)
73
                        {
74
                            x = other.x - 110;
75
                            y = other.y + 2;
76
                        }
77
                        else
78
                        {
79
                            x = other.x - 12;
80
                            y = other.y + 2;
81
                        }
82
                    }
83
                    else if (other.image_xscale == -2)
84
                    {
85
                        x = other.x - 142;
86
                        y = other.y;
87
                    }
88
                    else
89
                    {
90
                        x = other.x + 24;
91
                        y = other.y;
92
                    }
93
                    myencounter = 56;
94
                    sprite_index = spr_npc_swatchling_sweep;
95
                    touchsprite = spr_npc_swatchling_sweep;
96
                    radius = 10000;
97
                    ignoresolid = 0;
98
                    alertcon = 0;
99
                    eraser = 1;
100
                    facing = 1;
101
                }
102
                instance_destroy();
103
            }
104
        }
105
        if (instance_exists(obj_controller_dw_mansion_potBalance))
106
            obj_controller_dw_mansion_potBalance.triggered = 1;
107
    }
108
}