Deltarune (Chapter 2) script viewer

← back to main script listing

gml_Object_obj_scarableSwatch_Step_0

(view raw script w/o annotations or w/e)
1
if (init == 0)
2
{
3
    if (dir == 0)
4
        dir = choose("left", "right");
5
    if (image_xscale > 0)
6
        dir = "left";
7
    else
8
        dir = "right";
9
    init = 1;
10
}
11
if (con == 0)
12
{
13
    if (instance_exists(obj_dogtable_controlled))
14
        distance = distance_to_point(obj_dogtable_controlled.x, obj_dogtable_controlled.y);
15
    if (distance <= distancechecker)
16
        con = 1;
17
}
18
if (con == 1)
19
{
20
    sprite_index = spr_npc_swatchling_scared;
21
    if (dir == "left")
22
    {
23
        hspeed = -10;
24
        vspeed = -4;
25
        image_speed = 0.25;
26
    }
27
    else
28
    {
29
        hspeed = 10;
30
        vspeed = -4;
31
        image_speed = 0.25;
32
    }
33
    con++;
34
}
35
if (con == 2)
36
{
37
    if (dir == "left" && x <= 20)
38
    {
39
        x = 20;
40
        hspeed = 0;
41
        vspeed = 0;
42
        image_speed = 0;
43
        image_alpha *= 0.6;
44
        if (image_alpha < 0.01)
45
            instance_destroy();
46
    }
47
    if (dir == "right" && x >= 640)
48
    {
49
        x = 640;
50
        hspeed = 0;
51
        vspeed = 0;
52
        image_speed = 0;
53
        image_alpha *= 0.6;
54
        if (image_alpha < 0.01)
55
            instance_destroy();
56
    }
57
}
58
if (con == 69)
59
{
60
    if (dir == "left")
61
        horizontalDirection = -1;
62
    if (dir == "right")
63
        horizontalDirection = 1;
64
    verticalDirection = -1;
65
    hspeed = 0;
66
    sprite_index = spr_swatchling_cannonball;
67
    timer = 0;
68
    con++;
69
}
70
if (con == 70)
71
{
72
    x += (16 * sign(horizontalDirection));
73
    y += (32 * sign(verticalDirection));
74
    image_angle += (16 * sign(verticalDirection) * -1);
75
    timer++;
76
    if (timer > 30)
77
        image_alpha *= 0.9;
78
    if (image_alpha < 0.1)
79
        instance_destroy();
80
}
81
scr_depth_alt
scr_depth_alt

function
scr_depth_alt()
{ depth = 100000 - ((y * 10) + ((sprite_height - sprite_yoffset) * 10)); }
();