The hook turns as hard as the geometry needs, or not at all
A slice hooking onto a body two metres to the side flew a closed loop around it forever: 285 frames of the same circuit, never arriving, never falling. A constant turn rate has a constant turn radius (v/w = 2 m), and anything inside that circle cannot be reached however long the ball steers — while the hook pins vy at 0, so nothing else ends it either. A crowd is nothing but close bodies, which made the one place this weapon should shine the one place it hung. The rate is no longer a constant. An arc leaving along the current heading and passing through a body at distance d, bearing a, has radius d/(2 sin a), so the ball needs 2 v sin(a) / d — solved every frame, because the body is walking while the ball travels. sliceTurn stays as the FLOOR, which is what it was always really for: how wide the curl looks when there is room. Turning faster than needed is safe, the aim being re-solved each frame. Two things the maths cannot cover, so they are ruled out instead: a body behind the ball, which no tangent arc reaches at any rate (sliceArc), and a target that walks out of reach mid-hook (sliceHookT, a hard 0.7 s licence to steer). An endless orbit is now impossible by construction rather than by the geometry happening to work out. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
99d84b2c9d
commit
e11ad30a63
3 files changed
+42
-11
No files matched your search
+16
-7
@@ -637,12 +637,14 @@ function splatter(i, fanfare = true) { // the MAIN ball hit a zombie
|
||||
// ball pays for plowing through meat, and a cut ball does not plow — it leaves. Only a kill gets
|
||||
// here, so a wound ends the chain on its own and no brute, steward or boss ever extends one.
|
||||
if (ball.chain > 0) {
|
||||
const nx = nearestTo(zx, zz, TUNE.sliceR);
|
||||
const nx = nearestTo(zx, zz, TUNE.sliceR, ball, TUNE.sliceArc * Math.PI / 180);
|
||||
if (nx) {
|
||||
ball.chain--;
|
||||
const k = sp0 / (Math.hypot(ball.vx, ball.vz) || 1);
|
||||
ball.vx *= k; ball.vz *= k;
|
||||
ball.hook = { x: nx.x, z: nx.z }; // a POINT, not the body: the hook must not pin a corpse alive
|
||||
// a POINT, not the body: the hook must not pin a corpse alive. `t` is its licence to steer —
|
||||
// see the hook in gameplay, and sliceHookT for why it cannot be left open-ended.
|
||||
ball.hook = { x: nx.x, z: nx.z, t: TUNE.sliceHookT };
|
||||
G.trail = null; // the fired band is the parabola this ball has just STOPPED flying — leaving
|
||||
// it up draws a streak peeling away from the ball, which is the one thing
|
||||
// the band exists to avoid. From here the chalk thread is the trail.
|
||||
@@ -711,15 +713,22 @@ export function firePellet(w = WEAPONS.gun) {
|
||||
else if (++mgTick % 2 === 0) pock(0.25, w.ignite ? 300 : 1400);
|
||||
}
|
||||
const HUES = ['#ff6b6b', '#ffd166', '#7bffa0', '#6bd5ff', '#c08bff', '#ff8bd5'];
|
||||
// the next body a slice hooks onto: nearest live thing to the kill it just made, in any direction —
|
||||
// a cut ball can come BACK down-court, and the shot that curls round into something behind the body
|
||||
// you aimed at is the one worth earning. Furniture and barrels are not bodies and never a target.
|
||||
function nearestTo(x, z, maxD) {
|
||||
// The next body a slice hooks onto: nearest live thing to the kill it just made, and it may well be
|
||||
// off to the side or short of it — that curl is the whole shot. What it may NOT be is something the
|
||||
// ball cannot physically turn onto. A ball travelling at `b` can only reach a body within `arc` of
|
||||
// its heading; past that there is no tangent arc at any turn rate, and steering at one anyway is
|
||||
// what made the ball fly circles round a body two metres away instead of ever hitting it.
|
||||
// Furniture and barrels are not bodies and are never a target.
|
||||
function nearestTo(x, z, maxD, b, arc) {
|
||||
const head = Math.atan2(b.vx, b.vz);
|
||||
let best = null, bd = maxD;
|
||||
for (const zb of zombies) {
|
||||
if ('mo'.includes(zb.variant)) continue;
|
||||
const d = Math.hypot(zb.x - x, zb.z - z);
|
||||
if (d < bd) { bd = d; best = zb; }
|
||||
if (d >= bd) continue;
|
||||
const da = ((Math.atan2(zb.x - b.x, zb.z - b.z) - head + Math.PI * 3) % (Math.PI * 2)) - Math.PI;
|
||||
if (Math.abs(da) > arc) continue; // behind the ball: no arc gets there, so the chain ends
|
||||
bd = d; best = zb;
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user