ff to current state #6

Merged
kistaro merged 27 commits from pyrex/chameleonic:main into main 2022-12-19 07:03:33 +00:00
Showing only changes of commit d3583c27b4 - Show all commits

View File

@ -1196,6 +1196,13 @@ function _linedist(x0,v,x1)
return 100 * (sum_distance(x0,v,x1)-distance(x0,x1))/distance(x0,x1) return 100 * (sum_distance(x0,v,x1)-distance(x0,x1))/distance(x0,x1)
end 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) function sum_distance(x,y,z)
return distance(x,y) + distance(y,z) return distance(x,y) + distance(y,z)
end end
@ -1452,6 +1459,7 @@ function rope:_tug(hypothetically)
sgn0(latch.dy) sgn0(latch.dy)
local obj_anc=ancs[1] local obj_anc=ancs[1]
local pull_anc=ancs[2] local pull_anc=ancs[2]
local pull_dx=pull_anc.x-obj_anc.x local pull_dx=pull_anc.x-obj_anc.x
local pull_dy=pull_anc.y-obj_anc.y 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 mxa=(pull_anc.x+dmx)\8
local mya=(pull_anc.y+dmy)\8 local mya=(pull_anc.y+dmy)\8
local too_far=false local invalid_move=false
if if
(dmx!=0 and sgn0(pull_dx)!=dmx) or (dmx!=0 and sgn0(pull_dx)!=dmx) or
(dmy!=0 and sgn0(pull_dy)!=dmy) 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-mxa)!=
sgn0(mx0+dmx-mxa) or sgn0(mx0+dmx-mxa) or
sgn0(my0-mya)!= sgn0(my0-mya)!=
sgn0(my0+dmy-mya) sgn0(my0+dmy-mya)
then then
too_far=true invalid_move=true
end end
if not too_far and if not invalid_move and
level:can_move(false,mx0,my0,dmx,dmy,1,0) level:can_move(false,mx0,my0,dmx,dmy,1,0)
then then
if (hypothetically) return ancs,0 if (hypothetically) return ancs,0