big update

This commit is contained in:
2026-11-18 15:18:38 +01:00
parent e0496fa089
commit 64c5b65543
39 changed files with 1938 additions and 367 deletions

View File

@@ -30,11 +30,14 @@
let hold = { throttle: 0, turn: 0, fire: false, fire2: false }, wait = 0, stuck = 0, unstick = 0, contact = 0, retreat = 0, wob = rand() * 6;
const react = 0.32 - skill * 0.26; // seconds between decisions
function steer(me, tx, tz, speed = 1) {
const want = Math.atan2(tz - me.z, tx - me.x), diff = wrap(want - me.a);
// aim=true: orient so the weapon (which may sit on the back/side) faces the target, else aim the front
function steer(me, tx, tz, speed = 1, aim = false) {
const mA = aim ? (me.st.mountA || 0) : 0;
const want = wrap(Math.atan2(tz - me.z, tx - me.x) - mA), diff = wrap(want - me.a);
const turn = clamp(diff * 2.2, -1, 1);
const ad = Math.abs(diff);
const throttle = ad < 0.5 ? speed : ad < 1.4 ? speed * 0.45 : ad > 2.6 && Math.hypot(tx - me.x, tz - me.z) < 2 ? -0.6 : 0.1;
const dir = Math.cos(mA) < -0.5 ? -1 : 1; // rear-mounted weapon: reverse to bring it onto the enemy
const throttle = (ad < 0.5 ? speed : ad < 1.4 ? speed * 0.45 : ad > 2.6 && Math.hypot(tx - me.x, tz - me.z) < 2 ? -0.6 : 0.1) * dir;
return { turn, throttle };
}
@@ -64,7 +67,7 @@
} else if (style === 'gunner' && t) { // face the enemy (fixed turret), hold the range
tx = e.x; tz = e.z;
}
let cmd = steer(me, tx, tz, 0.75 + skill * 0.25);
let cmd = steer(me, tx, tz, 0.75 + skill * 0.25, style !== 'pusher');
// gunner too close: back off but keep the nose (and the turret) on the enemy
if (style === 'gunner' && t && dist < ((t.type === 'flamer' || t.type === 'zapper') ? 1.4 : 2.8)) cmd = { turn: cmd.turn, throttle: -0.7 };