Require pullers to be somewhat aligned with what they pull

This commit is contained in:
Pyrex 2022-12-18 17:10:18 -08:00
parent e985c29e02
commit d3583c27b4

View File

@ -1196,6 +1196,13 @@ function _linedist(x0,v,x1)
return 100 * (sum_distance(x0,v,x1)-distance(x0,x1))/distance(x0,x1)
end
function _vec_ang_diff(x0,y0,x1,y1)
local ang0=atan2(x0,y0)
local ang1=atan2(x1,y1)
return (ang1-ang0+0.5)%1-0.5
end
function sum_distance(x,y,z)
return distance(x,y) + distance(y,z)
end
@ -1452,6 +1459,7 @@ function rope:_tug(hypothetically)
sgn0(latch.dy)
local obj_anc=ancs[1]
local pull_anc=ancs[2]
local pull_dx=pull_anc.x-obj_anc.x
local pull_dy=pull_anc.y-obj_anc.y
@ -1461,21 +1469,23 @@ function rope:_tug(hypothetically)
local mxa=(pull_anc.x+dmx)\8
local mya=(pull_anc.y+dmy)\8
local too_far=false
local invalid_move=false
if
(dmx!=0 and sgn0(pull_dx)!=dmx) or
(dmy!=0 and sgn0(pull_dy)!=dmy) or
abs(_vec_ang_diff(pull_anc.x\8-mx0,pull_anc.y\8-my0,dmx,dmy)) > 0.125 or
sgn0(mx0-mxa)!=
sgn0(mx0+dmx-mxa) or
sgn0(my0-mya)!=
sgn0(my0+dmy-mya)
then
too_far=true
invalid_move=true
end
if not too_far and
if not invalid_move and
level:can_move(false,mx0,my0,dmx,dmy,1,0)
then
if (hypothetically) return ancs,0