3 |
scr_walk_aiscr_walk_aifunction scr_walk_ai(argument0, argument1, argument2, argument3, argument4) //gml_Script_scr_walk_ai
{
dalv_walk_speed = argument3
condition_1 = false
if (no_loop_destination_dalv == false)
{
var destination_x = abs(x - argument0)
var destination_y = abs(y - argument1)
var axis_override = argument4
if (axis_override == "x" || axis_override == "y")
dalv_walk_axis = axis_override
else
{
var result = sign(destination_x - destination_y)
switch result
{
case 1:
dalv_walk_axis = "x"
break
case -1:
dalv_walk_axis = "y"
break
default:
dalv_walk_axis = "y"
}
}
dalv_walk_speed_x = (sign(argument0 - x)) * dalv_walk_speed
dalv_walk_speed_y = (sign(argument1 - y)) * dalv_walk_speed
no_loop_destination_dalv = true
}
if (x == argument0 && y == argument1)
{
npc_walking = false
path_speed = 0
image_speed = 0
image_index = 0
return;
}
switch dalv_walk_axis
{
case "x":
x_previous = x
x += dalv_walk_speed_x
if (abs(argument0 - x) < dalv_walk_speed && place_free(argument0, y) && (!(place_meeting(argument0, y, argument2))))
x = argument0
if (place_free(x, y) && (!(place_meeting(x, y, argument2))) && x_previous != argument0)
{
npc_walking = true
image_speed = 0.2
if (dalv_walk_speed_x == (-dalv_walk_speed))
direction = 180
else if (dalv_walk_speed_x == dalv_walk_speed)
direction = 0
}
if ((!(place_free(x, y))) || place_meeting(x, y, argument2) || x_previous == argument0)
{
x = x_previous
dalv_walk_axis = "y"
return;
}
dalv_walk_speed_y = (sign(argument1 - y)) * dalv_walk_speed
i = x + dalv_walk_speed_x
j = y
if (abs(argument0 - i) < dalv_walk_speed)
i = argument0
while (j != argument1)
{
j += dalv_walk_speed_y
if (abs(argument1 - j) < dalv_walk_speed)
j = argument1
if ((!(place_free(i, j))) || place_meeting(i, j, argument2))
{
condition_1 = true
break
}
else
continue
}
if (condition_1 == true)
{
while (i != argument0)
{
i += dalv_walk_speed_x
j = y
if (abs(argument0 - i) < dalv_walk_speed)
i = argument0
while (j != argument1)
{
j += dalv_walk_speed_y
if (abs(argument1 - j) < dalv_walk_speed)
j = argument1
if (i == argument0 && j == argument1)
return;
else if ((!(place_free(i, j))) || place_meeting(i, j, argument2))
break
else
{
if (j == argument1)
return;
continue
... (obj_dalv2.destination_x_dalv, obj_dalv2.destination_y_dalv, obj_wall, 3, "x") |