Undertale Yellow script viewer

← back to main script listing

gml_Object_obj_axis_npc_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)
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 (is_walking == true)
32
{
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
}
50
else if (action_sprite == false)
51
{
52
    switch npc_direction
53
    {
54
        case "right":
55
            sprite_index = right_sprite_idle
56
            break
57
        case "up":
58
            sprite_index = up_sprite_idle
59
            break
60
        case "left":
61
            sprite_index = left_sprite_idle
62
            break
63
        case "down":
64
            sprite_index = down_sprite_idle
65
            break
66
    }
67
68
}
69
if (can_walk == true)
70
{
71
    x_destination = x_dest[current_destination]
72
    y_destination = y_dest[current_destination]
73
    npc_arrived = false
74
    var destination_count = array_length_1d(x_dest) - 1
75
    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)
76
    {
77
        if (current_destination < destination_count)
78
            current_destination += 1
79
        else
80
        {
81
            can_walk = false
82
            npc_arrived = true
83
            current_destination = 0
84
            x_dest = 0
85
            y_dest = 0
86
            x_dest[0] = x
87
            y_dest[0] = y
88
        }
89
    }
90
}
91
if (walk_direction_flip == true)
92
{
93
    var up_sprite_old = up_sprite
94
    up_sprite = down_sprite
95
    down_sprite = up_sprite_old
96
    var left_sprite_old = left_sprite
97
    left_sprite = right_sprite
98
    right_sprite = left_sprite_old
99
    up_sprite_old = up_sprite_idle
100
    up_sprite_idle = down_sprite_idle
101
    down_sprite_idle = up_sprite_old
102
    left_sprite_old = left_sprite_idle
103
    left_sprite_idle = right_sprite_idle
104
    right_sprite_idle = left_sprite_old
105
    walk_direction_flip = false
106
}
107
if (action_sprite == false)
108
    image_speed = (1/3)