1 |
scr_walk_npc_freescr_walk_npc_freefunction 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)
... (300, 120, 2, 0.2, "x", "left", obj_pl) |