Undertale Yellow script viewer

← back to main script listing

gml_Object_obj_ceroba_follower_Step_0

(view raw script w/o annotations or w/e)
1
depth = (-y)
2
if (global.player_sprites == "steamworkslava")
3
{
4
    palette_index = 3
5
    shader_on = true
6
}
7
else if (global.player_sprites == "normal")
8
    shader_on = false
9
if (obj_pl.yprevious != obj_pl.y || obj_pl.xprevious != obj_pl.x)
10
{
11
    npc_move_current = clamp((npc_move_current + 1), 0, npc_move_delay_max)
12
    x_new[npc_move_current] = obj_pl.x
13
    y_new[npc_move_current] = obj_pl.y
14
    dir_new[npc_move_current] = obj_pl.direction
15
    if (abs(obj_pl.yprevious - obj_pl.y) >= 5 || abs(obj_pl.xprevious - obj_pl.x) >= 5)
16
        sprinting_new[npc_move_current] = true
17
    else
18
        sprinting_new[npc_move_current] = false
19
}
20
if (npc_move_current >= npc_move_delay_max)
21
{
22
    npc_move_current = clamp((npc_move_current - 1), 0, npc_move_delay_max)
23
    x = x_new[1]
24
    y = y_new[1]
25
    follower_idle = false
26
    switch dir_new[1]
27
    {
28
        case 0:
29
            if (sprinting_new[1] == true)
30
                sprite_index = right_sprite_run
31
            else
32
                sprite_index = right_sprite
33
            break
34
        case 90:
35
            if (sprinting_new[1] == true)
36
                sprite_index = up_sprite_run
37
            else
38
                sprite_index = up_sprite
39
            break
40
        case 180:
41
            if (sprinting_new[1] == true)
42
                sprite_index = left_sprite_run
43
            else
44
                sprite_index = left_sprite
45
            break
46
        case 270:
47
            if (sprinting_new[1] == true)
48
                sprite_index = down_sprite_run
49
            else
50
                sprite_index = down_sprite
51
            break
52
    }
53
54
    image_speed = 0.2
55
    if (sprinting_new[1] == true)
56
        image_speed = 0.3
57
    for (var i = 0; i < npc_move_delay_max; i++)
58
    {
59
        x_new[i] = x_new[(i + 1)]
60
        y_new[i] = y_new[(i + 1)]
61
        dir_new[i] = dir_new[(i + 1)]
62
        sprinting_new[i] = sprinting_new[(i + 1)]
63
    }
64
}
65
else
66
{
67
    follower_idle = true
68
    switch dir_new[1]
69
    {
70
        case 0:
71
            sprite_index = right_sprite_idle
72
            break
73
        case 90:
74
            sprite_index = up_sprite_idle
75
            break
76
        case 180:
77
            sprite_index = left_sprite_idle
78
            break
79
        case 270:
80
            sprite_index = down_sprite_idle
81
            break
82
    }
83
84
}
85
if (npc_reset == true)
86
{
87
    event_perform(ev_create, 0)
88
    var player_distance = (point_distance(x, y, obj_pl.x, obj_pl.y)) / 10
89
    player_distance = clamp(player_distance, 1, 999)
90
    for (i = npc_move_delay_max; i > 0; i--)
91
    {
92
        x_new[i] = x + (sign(obj_pl.x - x)) * (i * player_distance)
93
        y_new[i] = y + (sign(obj_pl.y - y)) * (i * player_distance)
94
        if (abs(point_distance(x, y, x_new[npc_move_delay_max], y)) > abs(point_distance(x, y, x, y_new[npc_move_delay_max])))
95
        {
96
            if (obj_pl.x > x)
97
                dir_new[i] = 0
98
            else
99
                dir_new[i] = 180
100
        }
101
        else if (obj_pl.y > y)
102
            dir_new[i] = 270
103
        else
104
            dir_new[i] = 90
105
        npc_move_current += 1
106
    }
107
    npc_reset = false
108
}
109
if (follower_idle == true)
110
{
111
    if (instance_exists(obj_dialogue) && is_talking == true)
112
    {
113
        if (obj_dialogue.cutoff == string_length(obj_dialogue.message[obj_dialogue.message_current]))
114
        {
115
            image_speed = 0
116
            image_index = 0
117
        }
118
        else
119
            image_speed = 0.2
120
    }
121
    else
122
    {
123
        image_speed = 0
124
        image_index = 0
125
        is_talking = false
126
    }
127
}