Undertale Yellow script viewer

← back to main script listing

gml_Object_obj_actor_npc_base_Step_0

(view raw script w/o annotations or w/e)
1
if (npc_dynamic_depth == true)
2
    depth = -y;
3
interact = 0;
4
if (keyboard_multicheck_pressed(0) && scr_interact
scr_interact

function scr_interact() { if (distance_to_object(obj_pl) < 20 && obj_pl.state == scr_normal_state) { var pl_dir = obj_pl.direction; var pl_x = 0; var pl_y = 0; var check_distance_x = 0; var check_distance_y = 0; switch (pl_dir) { case 0: pl_x = obj_pl.bbox_right; pl_y = obj_pl.bbox_top + 1; check_distance_x = 20; break; case 180: pl_x = obj_pl.bbox_left; pl_y = obj_pl.bbox_top + 1; check_distance_x = -20; break; case 90: pl_x = obj_pl.x; pl_y = obj_pl.bbox_top; check_distance_y = -20; break; case 270: pl_x = obj_pl.x; pl_y = obj_pl.bbox_bottom; check_distance_y = 20; break; } if (collision_line_first(pl_x, pl_y, pl_x + check_distance_x, pl_y + check_distance_y, id, false, false)) return true; } }
() == true && can_interact && is_walking == false)
5
{
6
    npc_direction_hold = npc_direction;
7
    switch (obj_pl.direction)
8
    {
9
        case 0:
10
            npc_direction = "left";
11
            break;
12
        case 90:
13
            npc_direction = "down";
14
            break;
15
        case 180:
16
            npc_direction = "right";
17
            break;
18
        case 270:
19
            npc_direction = "up";
20
            break;
21
    }
22
    interact = true;
23
}
24
else if (!instance_exists(obj_dialogue) && !global.cutscene && npc_direction_hold != "nothing")
25
{
26
    if (npc_direction != npc_direction_hold)
27
        npc_direction = npc_direction_hold;
28
    npc_direction_hold = "nothing";
29
}
30
if (can_walk == true && is_walking == true)
31
{
32
    image_speed = 0.2;
33
    switch (npc_direction)
34
    {
35
        case "right":
36
            sprite_index = right_sprite;
37
            break;
38
        case "up":
39
            sprite_index = up_sprite;
40
            break;
41
        case "left":
42
            sprite_index = left_sprite;
43
            break;
44
        case "down":
45
            sprite_index = down_sprite;
46
            break;
47
    }
48
}
49
else if (action_sprite == false)
50
{
51
    if (instance_exists(obj_dialogue) && is_talking == true)
52
    {
53
        if (obj_dialogue.cutoff == string_length(obj_dialogue.message[obj_dialogue.message_current]))
54
        {
55
            image_speed = 0;
56
            image_index = 0;
57
        }
58
        else
59
        {
60
            image_speed = 0.2;
61
        }
62
    }
63
    else
64
    {
65
        image_speed = 0;
66
        image_index = 0;
67
        is_talking = false;
68
    }
69
    switch (npc_direction)
70
    {
71
        case "right":
72
            sprite_index = right_sprite_idle;
73
            break;
74
        case "up":
75
            sprite_index = up_sprite_idle;
76
            break;
77
        case "left":
78
            sprite_index = left_sprite_idle;
79
            break;
80
        case "down":
81
            sprite_index = down_sprite_idle;
82
            break;
83
    }
84
}
85
else if (action_sprite_stop == true)
86
{
87
    if (image_index >= (image_number - 1))
88
    {
89
        image_speed = 0;
90
        image_index = image_number - 1;
91
        action_sprite_stop = false;
92
    }
93
}
94
if (can_walk == true)
95
{
96
    x_destination = x_dest[current_destination];
97
    y_destination = y_dest[current_destination];
98
    npc_arrived = false;
99
    var destination_count = array_length_1d(x_dest) - 1;
100
    if (scr_walk_npc_free
scr_walk_npc_free

function scr_walk_npc_free(arg0, arg1, arg2, arg3, arg4, arg5, arg6) { if (arg6 == "nothing") arg6 = -4; is_walking = true; walk_speed = arg2; condition_1 = false; if (no_loop_destination == false) { var destination_x = abs(x - arg0); var destination_y = abs(y - arg1); var axis_override = arg4; if (axis_override == "x" || axis_override == "y") { walk_axis = axis_override; } else { var result = sign(destination_x - destination_y); switch (result) { case 1: walk_axis = "x"; break; case -1: walk_axis = "y"; break; default: walk_axis = "y"; } } walk_speed_x = sign(arg0 - x); walk_speed_y = sign(arg1 - y); if (walk_speed_x == 0) walk_speed_x = walk_speed; if (walk_speed_y == 0) walk_speed_y = walk_speed; no_loop_destination = true; lock_axis = false; } walk_speed_x = sign(walk_speed_x) * walk_speed; walk_speed_y = sign(walk_speed_y) * walk_speed; if (x == arg0 && y == arg1) { no_loop_destination = false; npc_walking = false; is_walking = false; if (arg5 != "nothing") npc_direction = arg5; image_speed = 0; image_index = 0; return true; exit; } switch (walk_axis) { case "x": x_previous = x; x += walk_speed_x; if (abs(arg0 - x) < walk_speed && !place_meeting(arg0, y, arg6)) x = arg0; if (!place_meeting(x, y, arg6) && x_previous != arg0) { npc_walking = true; image_speed = arg3; if (walk_speed_x == -walk_speed) npc_direction = "left"; else if (walk_speed_x == walk_speed) npc_direction = "right"; } if (!place_meeting(x, y + walk_speed_y, arg6) && lock_axis == true) { lock_axis = false; walk_axis = "y"; exit; } if ((place_meeting(x, y, arg6) || x_previous == arg0) && lock_axis == false) { if (place_meeting(x, y, arg6)) lock_axis = true; x = x_previous; walk_axis = "y"; exit; } walk_speed_y = sign(arg1 - y) * walk_speed; i = x + walk_speed_x; j = y; if (abs(arg0 - i) < walk_speed) i = arg0; while (j != arg1) { j += walk_speed_y; if (abs(arg1 - j) < walk_speed) j = arg1; if (place_meeting(i, j, arg6)) { condition_1 = true; break; } } if (condition_1 == true) ...
(x_destination, y_destination, actor_speed, 0.2, axis_override, end_direction, walk_collider))
101
    {
102
        if (current_destination < destination_count)
103
        {
104
            current_destination += 1;
105
        }
106
        else
107
        {
108
            can_walk = false;
109
            npc_arrived = true;
110
            current_destination = 0;
111
            x_dest = 0;
112
            y_dest = 0;
113
            x_dest[0] = x;
114
            y_dest[0] = y;
115
        }
116
    }
117
}
118
if (walk_direction_flip == true)
119
{
120
    var up_sprite_old = up_sprite;
121
    up_sprite = down_sprite;
122
    down_sprite = up_sprite_old;
123
    var left_sprite_old = left_sprite;
124
    left_sprite = right_sprite;
125
    right_sprite = left_sprite_old;
126
    up_sprite_old = up_sprite_idle;
127
    up_sprite_idle = down_sprite_idle;
128
    down_sprite_idle = up_sprite_old;
129
    left_sprite_old = left_sprite_idle;
130
    left_sprite_idle = right_sprite_idle;
131
    right_sprite_idle = left_sprite_old;
132
    walk_direction_flip = false;
133
}