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