Consistently bias pushout toward origin

Under pathological circumstances such as players
getting stuck near mapgen_limit, we don't want them getting stuck outside the bounds and then
pushed up past the ceiling.  Instead always try to
bias the push toward the origin, under the
assumption that some place near there should
be safe.
This commit is contained in:
Aaron Suen 2020-07-11 21:13:05 -04:00
parent 574f4f1ccb
commit 4e8bccc9f4

View File

@ -66,10 +66,14 @@ nodecore.register_playerstep({
return pushto(p)
end
end
local function bias(n)
return n + ((n > 0) and math_random(-6, 4)
or math_random(-4, 6))
end
return pushto({
x = pos.x + math_random(-5, 5),
y = pos.y + math_random(-3, 7),
z = pos.z + math_random(-5, 5)
x = bias(pos.x),
y = bias(pos.y),
z = bias(pos.z)
})
end
})