Open ithinkandicode opened 4 years ago
The fix above doesn't work for rotate_arm
. Use this to replace the full script instead.
/// rotate_arm()
var taim_target_dir, tarm_angle, _temp_local_var_1, t_loopfix_current, t_loopfix_max;
// point_direction(x1, y1, x2, y2): Returns the direction, in degrees, of a vector comprised.
taim_target_dir = point_direction((x + (arm_xo * image_xscale)), (y + (arm_yo * image_yscale)), aim_target_x, aim_target_y)
tarm_angle = arm_angle // last arm angle
// arm_check_iteration is set in gml_Script_init_default, and also in each enemy Create eg. oOni3_Create
// For Reaper, it's 30 (the default), and every enemy seems to have their own value set (most use 15)
_temp_local_var_1 = arm_check_iteration
// [BUG_04] Decompiled code causes an infinite while loop, as it has no break (rotate_arm)
t_loopfix_current = 0 // the current number in the loop
t_loopfix_max = 20 // the maximum number of loops
if (arm_check_iteration <= 0)
{
// ???
}
else
{
// while (true)
// while( arm_check_iteration > 0 ) // Seems like a proper fix, but crashes @TODO
while (t_loopfix_current <= t_loopfix_max)
{
t_loopfix_current += 1
arm_angle = rotate_direction( arm_angle, taim_target_dir, arm_check_angle )
// Don't let arms pass through walls (pB)
// Use the last arm angle instead
if (collision_line((x + (arm_xo * image_xscale)), (y + (arm_yo * image_yscale)), ((x + (arm_xo * image_xscale)) + lengthdir_x(arm_l, arm_angle)), ((y + (arm_yo * image_yscale)) + lengthdir_y(arm_l, arm_angle)), pB, 0, 0) != -4)
{
arm_angle = tarm_angle
}
if (arm_angle == tarm_angle)
{
// ???
}
else
{
_temp_local_var_1 = (arm_check_iteration - 1)
if (arm_check_iteration - 1)
{
// continue
}
}
}
}
if (lengthdir_x(10, arm_angle) < 0)
{
arm_yscale = -1
}
else
{
arm_yscale = 1
}
Applies to:
gml_Script_motion
gml_Script_rotate_arm
The decompiled scripts for
motion
androtate_arm
have an error in theirwhile
loop, which causes them to loop infinitely with nobreak
.This causes a crash the game if you try to move or aim, letting you progress only as far as your apartment.
motion
To fix this in the script
motion
, replace this:With this:
rotate_arm
To fix it in the script
rotate_arm
:Before:
After: