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() //gml_Script_scr_interact { if (distance_to_object(obj_pl) < 20 && obj_pl.state == gml_Script_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
23
    interact = true
24
}
25
else if ((!instance_exists(obj_dialogue)) && (!global.cutscene) && npc_direction_hold != "nothing")
26
{
27
    if (npc_direction != npc_direction_hold)
28
        npc_direction = npc_direction_hold
29
    npc_direction_hold = "nothing"
30
}
31
if (can_walk == true && is_walking == true)
32
{
33
    image_speed = 0.2
34
    switch npc_direction
35
    {
36
        case "right":
37
            sprite_index = right_sprite
38
            break
39
        case "up":
40
            sprite_index = up_sprite
41
            break
42
        case "left":
43
            sprite_index = left_sprite
44
            break
45
        case "down":
46
            sprite_index = down_sprite
47
            break
48
    }
49
50
}
51
else if (action_sprite == false)
52
{
53
    if (instance_exists(obj_dialogue) && is_talking == true)
54
    {
55
        if (obj_dialogue.cutoff == string_length(obj_dialogue.message[obj_dialogue.message_current]))
56
        {
57
            image_speed = 0
58
            image_index = 0
59
        }
60
        else
61
            image_speed = 0.2
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
}
86
else if (action_sprite_stop == true)
87
{
88
    if (image_index >= (image_number - 1))
89
    {
90
        image_speed = 0
91
        image_index = image_number - 1
92
        action_sprite_stop = false
93
    }
94
}
95
if (can_walk == true)
96
{
97
    x_destination = x_dest[current_destination]
98
    y_destination = y_dest[current_destination]
99
    npc_arrived = false
100
    var destination_count = array_length_1d(x_dest) - 1
101
    if scr_walk_npc_free
scr_walk_npc_free

function scr_walk_npc_free(argument0, argument1, argument2, argument3, argument4, argument5, argument6) //gml_Script_scr_walk_npc_free { if (argument6 == "nothing") argument6 = noone is_walking = true walk_speed = argument2 condition_1 = false if (no_loop_destination == false) { var destination_x = abs(x - argument0) var destination_y = abs(y - argument1) var axis_override = argument4 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(argument0 - x) walk_speed_y = sign(argument1 - 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 == argument0 && y == argument1) { no_loop_destination = false npc_walking = false is_walking = false if (argument5 != "nothing") npc_direction = argument5 image_speed = 0 image_index = 0 return true; } switch walk_axis { case "x": x_previous = x x += walk_speed_x if (abs(argument0 - x) < walk_speed && (!(place_meeting(argument0, y, argument6)))) x = argument0 if ((!(place_meeting(x, y, argument6))) && x_previous != argument0) { npc_walking = true image_speed = argument3 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), argument6))) && lock_axis == true) { lock_axis = false walk_axis = "y" return; } if ((place_meeting(x, y, argument6) || x_previous == argument0) && lock_axis == false) { if place_meeting(x, y, argument6) lock_axis = true x = x_previous walk_axis = "y" return; } walk_speed_y = (sign(argument1 - y)) * walk_speed i = x + walk_speed_x j = y if (abs(argument0 - i) < walk_speed) i = argument0 while (j != argument1) { j += walk_speed_y if (abs(argument1 - j) < walk_speed) j = argument1 if place_meeting(i, j, argument6) { condition_1 = true break } else continue } if (condition_1 == true) ...
(x_destination, y_destination, actor_speed, 0.2, axis_override, end_direction, walk_collider)
102
    {
103
        if (current_destination < destination_count)
104
            current_destination += 1
105
        else
106
        {
107
            can_walk = false
108
            npc_arrived = true
109
            current_destination = 0
110
            x_dest = 0
111
            y_dest = 0
112
            x_dest[0] = x
113
            y_dest[0] = y
114
        }
115
    }
116
}
117
if (walk_direction_flip == true)
118
{
119
    var up_sprite_old = up_sprite
120
    up_sprite = down_sprite
121
    down_sprite = up_sprite_old
122
    var left_sprite_old = left_sprite
123
    left_sprite = right_sprite
124
    right_sprite = left_sprite_old
125
    up_sprite_old = up_sprite_idle
126
    up_sprite_idle = down_sprite_idle
127
    down_sprite_idle = up_sprite_old
128
    left_sprite_old = left_sprite_idle
129
    left_sprite_idle = right_sprite_idle
130
    right_sprite_idle = left_sprite_old
131
    walk_direction_flip = false
132
}