map change

This commit is contained in:
2026-11-15 20:05:02 +01:00
parent 319436a5f9
commit 3e565cf8c7
15 changed files with 242 additions and 26 deletions

View File

@@ -19,6 +19,7 @@
// solid cover and slicks: drive round them, they are not deadly
for (const b of ar.blocks || []) if (Math.abs(x - b.x) < b.hw + me.st.rad && Math.abs(z - b.z) < b.hd + me.st.rad) return 1;
for (const o of ar.oil || []) if (Math.hypot(x - o.x, z - o.z) < o.r) return 1;
for (const mn of s.mines || []) if (mn.arm <= 0 && Math.hypot(x - mn.x, z - mn.z) < mn.r + me.st.rad) return 2;
return 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@@ -148,7 +148,7 @@
const s = {
arena: A, t: 0, left: A.duration, pitOpen: 0, rand: rng(opt.seed || 1),
robots: opt.robots.map((st, i) => makeRobot(st, i, (opt.names || [])[i] || 'Robot ' + (i + 1), A)),
rockets: [], events: [], result: null, endIn: 0,
rockets: [], mines: [], events: [], result: null, endIn: 0,
press: { st: 'idle', t: 0, y: 1 }, // idle | warn | slam | up ; y 1 = top, 0 = floor
crane: { st: 'idle', t: 0, who: -1, tx: 0, tz: 0, x: A.crane.x, z: A.crane.z },
pitAlarm: false,
@@ -243,6 +243,7 @@
for (let k = 0; k < 2; k++) gadgets(s, R[k], R[1 - k], (s.result ? null : inputs[k]) || {}, dt);
for (let k = 0; k < 2; k++) weapons(s, R[k], R[1 - k], (s.result ? null : inputs[k]) || {}, dt);
rockets(s, dt);
mines(s, dt);
hazards(s, dt);
if (!s.result && s.left <= 0) {
@@ -541,6 +542,17 @@
if (r.gUses <= 0) return;
r.hp = Math.min(r.maxHp, r.hp + r.maxHp * g.heal); r.gUses--; r.gcd = g.cd;
break;
case 'mines': { // drop a mine behind you
if (r.gUses <= 0) return;
const [mx, mz] = fwd(r);
const d = r.st.len / 2 + 0.9; // well behind, not under your own tail
r.gUses--; r.gcd = g.cd;
// own: the layer is safe for a moment - drive back over it later and it still gets you
s.mines.push({ x: r.x - mx * d, z: r.z - mz * d, owner: r.i, arm: g.arm, own: 3,
r: g.r, dmg: g.dmg, launch: g.launch });
s.events.push({ type: 'mine_drop', who: r.i, x: r.x - mx * d, z: r.z - mz * d });
break;
}
case 'emp': // stun the enemy if close
r.gcd = g.cd;
if (!e.out && Math.hypot(e.x - r.x, e.z - r.z) < g.range + e.st.rad) {
@@ -563,10 +575,33 @@
case 'shield': return dist < 3 && me.flipped <= 0;
case 'repair': return me.gUses > 0 && me.hp < me.maxHp * 0.45;
case 'emp': return !e.out && dist < g.range * 0.9 && (e.boost > 0 || e.spin > 0.2 || dist < 2.5);
case 'mines': return me.gUses > 0 && dist > 1.4 && dist < 7; // drop one while they chase you
}
return false;
}
function mines(s, dt) {
for (let i = s.mines.length - 1; i >= 0; i--) {
const mn = s.mines[i];
if (mn.own > 0) mn.own -= dt;
if (mn.arm > 0) { mn.arm -= dt; continue; } // short delay so you can drive off it
for (const r of s.robots) {
if (r.out || r.dead || r.y > 0.35) continue;
if (mn.owner === r.i && mn.own > 0) continue; // grace period for whoever dropped it
if (Math.hypot(r.x - mn.x, r.z - mn.z) > mn.r + r.st.rad * 0.6) continue;
const light = Math.sqrt(70 / r.st.mass);
// your own mine pays the opponent, like any other hazard
damage(s, r, mn.dmg, mn.owner === r.i ? null : s.robots[mn.owner], { from: { x: mn.x, z: mn.z }, kind: 'mine' });
r.vy = Math.max(r.vy, mn.launch * light);
r.av += (s.rand() - 0.5) * 7;
if (!r.st.invertible && s.rand() < 0.5) r.flipped = 2.2;
s.events.push({ type: 'boom', x: mn.x, z: mn.z, y: 0.22, big: true });
s.mines.splice(i, 1);
break;
}
}
}
function rockets(s, dt) {
for (let i = s.rockets.length - 1; i >= 0; i--) {
const k = s.rockets[i], tgt = s.robots[1 - k.owner], own = s.robots[k.owner];

View File

@@ -19,7 +19,17 @@
// Credits (standard for every game): shown on the title screen, links open in the normal browser
const DISCORD = 'https://discord.gg/Ej4JPmCZva';
const CREDITS = `© 2026 Michael Media · <a href="${DISCORD}" target="_blank" rel="noopener">Discord</a>`;
const SITE = 'https://michael-media.de';
// build stamp comes from build-web.mjs; identifies the exact release in a leaked copy
const BUILD = (typeof window !== 'undefined' && window.RC_BUILD) || '';
const CREDITS = `© 2026 <a href="${SITE}" target="_blank" rel="noopener">Michael Media</a>`
+ ` · <a href="${DISCORD}" target="_blank" rel="noopener">Discord</a>`
+ (BUILD ? ` · <span class="build">${BUILD}</span>` : '');
// Soft domain lock: the published build only runs on our own site. Local file, localhost and the
// exe always run. This stops a lazy re-upload, nothing more - the file itself can always be copied.
const HOSTS = ['michael-media.de', 'www.michael-media.de', 'localhost', '127.0.0.1', ''];
const hostOk = () => location.protocol === 'file:' || HOSTS.includes(location.hostname)
|| (Kit.host && Kit.host.exe) || document.documentElement.classList.contains('exe');
// ---------------------------------------------------------------- services
const L = Kit.i18n(window.LANG, { prefix: ID });
@@ -107,6 +117,7 @@
case 'crane': audio.tone(140, 0.6, 'sawtooth', 0.07, 140); break;
case 'drop': case 'land': audio.noise(0.22, 0.35, 500); break;
case 'broke': audio.sfx('sfx_hit'); audio.noise(0.45, 0.5, 900); audio.tone(240, 0.35, 'sawtooth', 0.22, -190); break;
case 'mine_drop': audio.tone(520, 0.08, 'square', 0.12, -160); audio.noise(0.06, 0.12, 2200); break;
case 'pit_open': for (let k = 0; k < 3; k++) audio.tone(700, 0.3, 'square', 0.12, -250, k * 0.4); break;
case 'pit': audio.tone(420, 1.2, 'sawtooth', 0.14, -360); break;
case 'grab': audio.tone(150, 0.25, 'square', 0.12, -60); break;
@@ -214,6 +225,27 @@
// ---------------------------------------------------------------- intro + title
let introCue = 0;
let gateDone = false;
function startGate(next) {
if (gateDone) { next(); return; }
gateDone = true;
setScreen('intro'); // defined UI state while the gate is up (HUD stays hidden)
const logo = `<img class="tlogoimg" src="${Kit.asset('assets/Sprites/logo.png')}" alt="ROBOT CLASH"
onerror="this.remove()" onload="this.nextElementSibling.style.display='none'"><div class="big">ROBOT CLASH</div>`;
overlay.innerHTML = `<div class="title"><div class="tpanel">${logo}
<div class="hazbar"></div><p class="tag">${t('click_start')}</p>
<p class="credits">${CREDITS}</p></div></div>`;
overlay.classList.remove('hide'); overlay.classList.add('clear'); overlay.style.backgroundImage = '';
const go = e => {
if (e) { e.stopPropagation(); if (e.preventDefault) e.preventDefault(); } // must not also skip the intro
removeEventListener('pointerdown', go, true); removeEventListener('keydown', go, true);
if (audio.unlock) audio.unlock();
next();
};
addEventListener('pointerdown', go, true);
addEventListener('keydown', go, true);
}
function startIntro() {
setScreen('intro');
hideOverlay();
@@ -230,7 +262,7 @@
function introTick() {
if (mode !== 'intro' || !view) return;
const it = view.introTime;
for (const [at, f] of [[1.2, SFX.clunk], [1.5, SFX.clunk], [1.62, SFX.clunk], [4.25, SFX.clunk], [4.6, SFX.clunk]]) {
for (const [at, f] of [[0.4, SFX.clunk], [0.62, SFX.clunk], [2.2, SFX.clunk], [2.5, SFX.clunk], [3.4, SFX.clunk]]) {
if (introCue < at && it >= at) f();
}
introCue = it;
@@ -433,7 +465,7 @@
persist();
hud();
shop.reset();
if (!save.tutorialSeen) { save.tutorialSeen = true; persist(); showHelp(openGarage); } else openGarage();
if (!save.tutorialSeen) { save.tutorialSeen = true; persist(); startTutorial(openGarage); } else openGarage();
}
// saves from older versions: missing parts, invalid ids, hangar migration
function repairSave() {
@@ -563,6 +595,25 @@
<b>Shift / E</b><span>${t('key_tower')}</span><b>C</b><span>${t('key_cam')}</span><b>P / Esc</b><span>${t('pause')}</span><b>M</b><span>${t('sound_on')} / ${t('sound_off')}</span>
<b>${t('key_pad')}</b><span>${t('key_pad_text')}</span></div>`;
}
// first start: four short cards instead of the full help page
const TUT = ['tut_1', 'tut_2', 'tut_3', 'tut_4'];
function startTutorial(done) {
let i = 0;
const step = () => {
if (i >= TUT.length) { done(); return; }
const n = i + 1;
overlayEnter();
card(`<h2>${t('tut_title')} <span class="muted">${n}/${TUT.length}</span></h2>
<p>${t(TUT[i])}</p>
<div class="row"><button id="tSkip">${t('tut_skip')}</button>
<button class="primary" id="tNext">${n === TUT.length ? t('tut_go') : t('tut_next')}</button></div>`,
{ bg: 'bg_workshop.jpg' });
$('tNext').onclick = () => { SFX.click(); i++; step(); };
$('tSkip').onclick = () => { SFX.click(); done(); };
};
step();
}
function showHelp(back) {
overlayEnter();
card(`<h2>${t('how_to')}</h2><p>${t('help_text')}</p>${keysHtml()}
@@ -689,6 +740,7 @@
setScreen('fight');
audio.music('music_fight');
banner('📍 ' + t('arena_' + s.arena.id), '#ff7a1a', 2.2);
if (save.games === 0 && !F.online) setTimeout(() => { if (mode === 'fight') banner(t('tut_controls'), '#ffffff', 5); }, 2400);
const pg = $('padGadget'); if (pg) pg.style.display = s.robots[0].st.gadget ? '' : 'none';
buildCds();
buildDmg(0, save.build); buildDmg(1, opp.build);
@@ -782,6 +834,11 @@
for (const o of A.oil) { const [px, py] = P(o.x, o.z); ctx.fillStyle = 'rgba(12,12,20,.65)'; ctx.beginPath(); ctx.arc(px, py, o.r * k, 0, 7); ctx.fill(); }
for (const m of A.rams) rect(m, RC.hazardOn(m, s.t) ? 'rgba(255,60,60,.8)' : 'rgba(200,200,200,.25)');
for (const b of A.blocks) rect(b, 'rgba(150,160,175,.6)');
for (const mn of s.mines || []) {
const [px, py] = P(mn.x, mn.z);
ctx.fillStyle = mn.arm > 0 ? 'rgba(200,200,200,.45)' : 'rgba(255,70,40,.95)';
ctx.beginPath(); ctx.arc(px, py, Math.max(2, mn.r * k), 0, 7); ctx.fill();
}
s.robots.forEach((r, i) => {
if (r.out) return;
const [px, py] = P(r.x, r.z), [qx, qy] = P(r.x + Math.cos(r.a), r.z + Math.sin(r.a)), ang = Math.atan2(qy - py, qx - px);
@@ -1083,7 +1140,9 @@
accounts.resume();
if (net && net.enabled) { net.auth.resume(); net.auth.onChange(() => { hud(); if (mode === 'title') showTitle(); }); }
hud();
if (!view) {
if (!hostOk()) {
card(`<h1>Robot Clash</h1><p>${t('wrong_host')}</p><p class="credits">${CREDITS}</p>`);
} else if (!view) {
card(`<h1>Robot Clash</h1><p>${t('no_webgl')}</p><p class="credits">${CREDITS}</p>`);
} else if (DEV.has('fight') || DEV.has('play')) {
// dev: ?play = straight into the shop, ?fight=N = training fight against league robot N
@@ -1119,7 +1178,8 @@
painter.open(); view.showGarage(save.build, paintObj());
}
} else if (DEV.has('online') && net.enabled) { startIntroOrTitle(); startOnline(); }
else if (DEV.has('title')) startIntroOrTitle();
else startIntro();
else if (DEV.has('title')) startGate(startIntroOrTitle);
else startGate(startIntro);
if (DEV.has('tut')) startTutorial(openGarage); // dev: ?play&tut previews the first-start cards
if (DEV.has('uicheck') && RC.uiCheckRun) RC.uiCheckRun(); // dev: &uicheck prints layout faults as text
})();

View File

@@ -120,6 +120,7 @@
.row { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.credits { margin: 14px 0 0; font-size: 12px; color: var(--dim); }
.credits a { color: var(--accent); text-decoration: none; }
.credits .build { color: #5a6273; font-size: 10.5px; }
.credits a:hover { text-decoration: underline; }
.keys { display: grid; grid-template-columns: auto auto; gap: 3px 14px; text-align: left; margin: 10px auto 0; width: max-content; font-size: 13px; color: var(--dim); }
.keys b { color: var(--text); }

View File

@@ -9,6 +9,14 @@ window.LANG = {
league_chip: 'S{s} · {n}/{m}',
sound_on: 'Sound on', sound_off: 'Sound off', pause: 'Pause',
win_min: 'Minimise', win_full: 'Fullscreen (F11)', win_close: 'Close',
click_start: 'Click or press any key to start',
tut_title: 'Quick start', tut_next: 'Next', tut_skip: 'Skip', tut_go: "Let's build",
tut_1: 'Every robot needs four parts: chassis, motor, wheels and a battery. You pick them under Parts.',
tut_2: 'A weapon is optional - without one you can only ram. A wedge is cheap, a flipper throws them over.',
tut_3: 'Watch the two bars on the left: 100 kg is the limit, and your battery has to power every part.',
tut_4: 'Then press LEAGUE. Even a defeat pays a little, and prize money buys better parts.',
tut_controls: 'W/S drive · A/D turn · Space weapon · Shift tower · G gadget · C camera',
wrong_host: 'This copy of Robot Clash may only be played on michael-media.de.',
no_webgl: 'This game needs WebGL (3D graphics). Please use a current browser or update the graphics driver.',
menu_text: 'Build your combat robot from parts, fight your way up the league<br>and send your opponents into the pit.',
name_placeholder: 'Your name',
@@ -58,6 +66,8 @@ window.LANG = {
pd_lead: 'Heavy, but it works.',
pd_nicd: 'More power, less weight.',
pd_lipo: 'Light and powerful.',
pd_liion: 'Big cell block - runs a heavy weapon and a turret together.',
pd_supercap: 'Supercapacitor bank: the most power there is, and it weighs accordingly.',
pd_mesh: 'Thin wire grille - barely any weight, barely any protection.',
pd_buffer: 'Fat rubber buffers that soak up rams.',
pd_spiked: 'Plates with spikes, and they look the part.',
@@ -89,6 +99,7 @@ window.LANG = {
pd_shield: 'Field that cuts damage for a few seconds (G).',
pd_repair: 'Patches hull - two charges (G).',
pd_emp: 'Stuns a nearby enemy for a moment (G).',
pd_mines: 'Drops a mine behind you (G). It arms after a second - whoever drives over it gets thrown into the air. That includes you.',
// league
league_title: 'League - season {s}',
league_text: 'Beat the opponents one after another. Each season they get tougher and pay more.',
@@ -213,6 +224,14 @@ window.LANG = {
league_chip: 'S{s} · {n}/{m}',
sound_on: 'Sound an', sound_off: 'Sound aus', pause: 'Pause',
win_min: 'Minimieren', win_full: 'Vollbild (F11)', win_close: 'Schließen',
click_start: 'Klicken oder Taste drücken zum Starten',
tut_title: 'Kurzanleitung', tut_next: 'Weiter', tut_skip: 'Überspringen', tut_go: 'Los bauen',
tut_1: 'Jeder Roboter braucht vier Teile: Chassis, Motor, Räder und Batterie. Die wählst du unter „Teile".',
tut_2: 'Eine Waffe ist freiwillig – ohne kannst du nur rammen. Ein Keil ist billig, ein Flipper wirft um.',
tut_3: 'Achte auf die zwei Balken links: 100 kg sind das Limit, und die Batterie muss alle Teile versorgen.',
tut_4: 'Dann auf LIGA drücken. Auch eine Niederlage bringt Geld, und vom Preisgeld kaufst du bessere Teile.',
tut_controls: 'W/S fahren · A/D drehen · Leertaste Waffe · Shift Turm · G Gadget · C Kamera',
wrong_host: 'Diese Ausgabe von Robot Clash darf nur auf michael-media.de gespielt werden.',
no_webgl: 'Dieses Spiel braucht WebGL (3D-Grafik). Bitte einen aktuellen Browser nutzen oder den Grafiktreiber aktualisieren.',
menu_text: 'Bau deinen Kampfroboter aus Teilen, kämpf dich durch die Liga<br>und schick deine Gegner in die Grube.',
name_placeholder: 'Dein Name',
@@ -262,6 +281,8 @@ window.LANG = {
pd_lead: 'Schwer, aber sie tut es.',
pd_nicd: 'Mehr Strom, weniger Gewicht.',
pd_lipo: 'Leicht und stark.',
pd_liion: 'Großer Zellenblock – trägt schwere Waffe und Turm gleichzeitig.',
pd_supercap: 'Superkondensator-Bank: der meiste Strom, und entsprechend schwer.',
pd_mesh: 'Dünnes Drahtgitter – kaum Gewicht, kaum Schutz.',
pd_buffer: 'Dicke Gummipuffer, die Rammstöße schlucken.',
pd_spiked: 'Platten mit Stacheln, sehen auch so aus.',
@@ -293,6 +314,7 @@ window.LANG = {
pd_shield: 'Feld, das ein paar Sekunden Schaden abfängt (G).',
pd_repair: 'Flickt die Hülle – zwei Ladungen (G).',
pd_emp: 'Legt einen nahen Gegner kurz lahm (G).',
pd_mines: 'Legt eine Mine hinter dir ab (G). Nach einer Sekunde scharf – wer drüberfährt, fliegt hoch. Auch du.',
// league
league_title: 'Liga – Saison {s}',
league_text: 'Besiege die Gegner nacheinander. Jede Saison werden sie härter und zahlen mehr.',

View File

@@ -77,6 +77,9 @@
if (outgoing) return;
outgoing = uid;
const p = prof();
// a rematch reuses the match id, so clear whatever a crashed fight left behind -
// otherwise the waiting side would pick up the old seed (and the old arena) at once
await db.del(`matches/${matchId(me(), uid)}`);
await beat('searching');
await db.put(`challenges/${uid}/${me()}`, { from: me(), fromName: p.name, fromFlag: p.flag || 'XX', build: p.build, paint: p.paint, seed: (Math.random() * 1e9) | 0, ts: { '.sv': 'timestamp' } });
// wait for the other side to create the match (they host if their uid < mine)
@@ -85,7 +88,7 @@
const watch = db.stream(`matches/${id}/meta/seed`, seed => {
if (seed == null) return;
clearTimeout(give); watch.close(); outgoing = null;
createMatch(uid); // add my own robot to the match meta
createMatch(uid, false); // add my own robot; the seed is already set by the other side
watchMatch(id, uid, host);
});
}
@@ -93,17 +96,20 @@
async function accept(from) {
const id = matchId(me(), from), host = isHost(me(), from);
await db.del(`challenges/${me()}/${from}`);
await createMatch(from);
await createMatch(from, true); // whoever accepts rolls the seed (and with it the arena)
watchMatch(id, from, host);
}
function decline(from) { db.del(`challenges/${me()}/${from}`); }
function cancel() { if (outgoing) { db.del(`challenges/${outgoing}/${me()}`); outgoing = null; beat('idle'); } }
async function createMatch(oppUid) {
// setSeed: only the side that accepts writes the seed, so both read the exact same value.
// It is rolled fresh for every match - a seed derived from the match id would hand the same
// pair of players the same arena for ever.
async function createMatch(oppUid, setSeed) {
const id = matchId(me(), oppUid), p = prof();
const seed = (parseInt(id.slice(-6), 36) % 1e9) || 1; // same on both sides
// meta holds both players' robots; written once, guarded so the first writer wins
await db.patch(`matches/${id}/meta`, { seed, [me()]: { name: p.name, flag: p.flag || 'XX', build: p.build, paint: p.paint } });
const meta = { [me()]: { name: p.name, flag: p.flag || 'XX', build: p.build, paint: p.paint } };
if (setSeed) meta.seed = ((Math.random() * 1e9) | 0) || 1;
await db.patch(`matches/${id}/meta`, meta);
await beat('inmatch');
}

View File

@@ -70,6 +70,7 @@
seq: ++seq, t: rnd(s.t), left: rnd(s.left), pitOpen: rnd(s.pitOpen), pitAlarm: s.pitAlarm,
press: { st: s.press.st, y: rnd(s.press.y) }, crane: { st: s.crane.st, x: rnd(s.crane.x), z: rnd(s.crane.z), who: s.crane.who },
rockets: s.rockets.map(k => ({ x: rnd(k.x), z: rnd(k.z), y: rnd(k.y), a: rnd(k.a) })),
mines: s.mines.map(k => ({ x: rnd(k.x), z: rnd(k.z), arm: rnd(k.arm) })),
r: [packRobot(s.robots[0]), packRobot(s.robots[1])],
ev: evBuf.slice(-24), result: s.result, endIn: rnd(s.endIn),
};
@@ -108,6 +109,7 @@
s.press.st = snap.press.st; s.press.y = snap.press.y;
s.crane.st = snap.crane.st; s.crane.x = snap.crane.x; s.crane.z = snap.crane.z; s.crane.who = snap.crane.who;
syncRockets(s, snap.rockets);
syncMines(s, snap.mines);
s.result = snap.result; s.endIn = snap.endIn;
// snapshot order [host, guest]; locally guest must be index 0 -> swap
applyRobot(s.robots[0], snap.r[1], dt); // me (guest)
@@ -134,6 +136,12 @@
for (let i = 0; i < list.length; i++) s.rockets[i] = Object.assign(s.rockets[i] || { owner: 1, sp: 6, t: 3 }, list[i]);
}
function syncMines(s, list) {
list = list || [];
s.mines.length = list.length;
for (let i = 0; i < list.length; i++) s.mines[i] = Object.assign(s.mines[i] || { owner: 0, r: 0.85 }, list[i]);
}
let prevInput = null;
function changed(inp) { return !prevInput || inp.throttle !== prevInput.throttle || inp.turn !== prevInput.turn || inp.fire !== prevInput.fire || inp.fire2 !== prevInput.fire2 || inp.fire3 !== prevInput.fire3; }

View File

@@ -44,6 +44,8 @@
{ id: 'lead', slot: 'battery', name: 'Lead 12V', cost: 80, weight: 10, power: 9 },
{ id: 'nicd', slot: 'battery', name: 'NiCd Pack', cost: 320, weight: 7, power: 13 },
{ id: 'lipo', slot: 'battery', name: 'LiPo Stack', cost: 760, weight: 5, power: 19 },
{ id: 'liion', slot: 'battery', name: 'Li-Ion Brick', cost: 1150, weight: 8, power: 24 },
{ id: 'supercap', slot: 'battery', name: 'Supercap Bank', cost: 1700, weight: 11, power: 30 },
// armour: reduce = share of damage absorbed, hp bonus
{ id: 'mesh', slot: 'armour', name: 'Wire Mesh', cost: 120, weight: 5, reduce: 0.08, hp: 4, tint: 0x9aa3ad, style: 'mesh' },
@@ -83,6 +85,8 @@
{ id: 'shield', slot: 'gadget', name: 'Deflector Field', cost: 420, weight: 7, power: 4, type: 'shield', cd: 9, dur: 2.5, reduce: 0.6 },
{ id: 'repair', slot: 'gadget', name: 'Repair Kit', cost: 500, weight: 8, power: 3, type: 'repair', cd: 8, charges: 2, heal: 0.26 },
{ id: 'emp', slot: 'gadget', name: 'EMP Burst', cost: 640, weight: 7, power: 5, type: 'emp', cd: 8, range: 3.2, stun: 1.5 },
{ id: 'mines', slot: 'gadget', name: 'Mine Layer', cost: 560, weight: 9, power: 3, type: 'mines', cd: 2.2, charges: 3,
dmg: 26, launch: 7.5, r: 0.85, arm: 1.2 },
];
RC.PARTS = {};

View File

@@ -661,8 +661,9 @@
out.flashLight = new T.PointLight(0xffaa55, 0, 9); scene.add(out.flashLight);
out.scene = scene; out.group = null; out.id = null;
out.rocketGeo = new T.CylinderGeometry(0.05, 0.05, 0.32, 8); out.rocketGeo.rotateZ(Math.PI / 2);
out.rocketMat = new T.MeshStandardMaterial({ color: 0xdddddd, emissive: 0x331100 });
out.rocketMat = new T.MeshStandardMaterial({ color: 0xe8e8e8, emissive: 0xff5a10, emissiveIntensity: 0.75 });
out.rocketMeshes = [];
out.mineMeshes = [];
buildArenaGeo(out, RC.ARENA);
return out;
}
@@ -758,10 +759,14 @@
}
for (const [px, pz] of [[-1, -1], [1, -1], [-1, 1]]) {
const post = box(0.22, 3.4, 0.22, wallMat); post.position.set(px * (half + 0.35), 1.7, pz * (half + 0.35)); scene.add(post);
const lamp = box(0.5, 0.3, 0.3, m.lamp); lamp.position.set(px * (half + 0.2), 3.5, pz * (half + 0.2)); scene.add(lamp);
const rig = new T.Group(); rig.position.set(px * (half + 0.2), 3.5, pz * (half + 0.2)); scene.add(rig);
const hous = box(0.46, 0.36, 0.34, new T.MeshStandardMaterial({ color: 0x23272e, metalness: 0.6, roughness: 0.5 }));
hous.castShadow = true; rig.add(hous);
const lens = box(0.3, 0.2, 0.3, m.lamp); lens.position.set(-px * 0.13, -0.12, -pz * 0.13); rig.add(lens);
const arm = cyl(0.035, 0.035, 0.36, m.dark, 6); arm.position.set(px * 0.12, 0.26, pz * 0.12); rig.add(arm);
}
// audience stands behind the back walls
const seats = new T.InstancedMesh(new T.BoxGeometry(0.32, 0.5, 0.32), new T.MeshStandardMaterial({ roughness: 0.9 }), 900);
const seats = new T.InstancedMesh(new T.BoxGeometry(0.32, 0.5, 0.32), new T.MeshStandardMaterial({ color: 0x1b1d24, roughness: 0.95 }), 900);
const col = new T.Color(); let ci = 0; let sd = 11;
const rnd = () => { sd = (sd * 16807) % 2147483647; return sd / 2147483647; };
for (const [nx, nz] of [[-1, 0], [0, -1]]) for (let row = 0; row < 5; row++) {
@@ -776,7 +781,10 @@
col.setHSL(rnd(), 0.3, 0.07 + rnd() * 0.08); seats.setColorAt(ci, col); ci++;
}
}
seats.count = ci; dm.scale.set(1, 1, 1); scene.add(seats);
seats.count = ci; dm.scale.set(1, 1, 1);
seats.instanceMatrix.needsUpdate = true;
if (seats.instanceColor) seats.instanceColor.needsUpdate = true;
scene.add(seats);
// floor saws
// --- cover and floor traps (static, built once per arena) ---
@@ -1014,6 +1022,8 @@
showIntro(builds, paints) {
api.showArena(RC.Combat.create({ robots: builds.map(b => RC.stats(b)), seed: 3, arena: 'workshop' }), builds, paints);
mode = 'intro'; introT = 0; pointMode(true);
// compile every shader up front, otherwise the first seconds stutter while they are built
try { renderer.compile(arenaScene, pcam); } catch (e) { /* older three: just carry on */ }
},
skipIntro() { if (mode === 'intro' && introT < INTRO_END) introT = INTRO_END; },
showGarage(build, paint) {
@@ -1068,6 +1078,8 @@
sparks.clear(); smoke.clear(); fire.clear(); clearDebris(); shake = 0;
for (const m of arena.rocketMeshes) arenaScene.remove(m);
arena.rocketMeshes = [];
for (const m of arena.mineMeshes) arenaScene.remove(m);
arena.mineMeshes = [];
},
events(list) {
for (const e of list) {
@@ -1088,6 +1100,7 @@
case 'press': puff(e.x, e.z, 14); burst(e.x, 0.1, e.z, 24, 5, [1, 0.8, 0.4]); shake = Math.max(shake, 0.45); break;
case 'drop': puff(e.x, e.z, 8); shake = Math.max(shake, 0.2); break;
case 'ko': explode(e.x, 0.5, e.z, 1.2); break;
case 'mine_drop': burst(e.x, 0.12, e.z, 6, 2, [1, 0.8, 0.3]); break;
case 'broke':
breakPart(robots[e.who], e.part);
burst(e.x, 0.45, e.z, 22, 5, [1, 0.8, 0.4]); puff(e.x, e.z, 6);
@@ -1165,7 +1178,7 @@
}
// ---- intro: dark arena -> floodlights flicker on -> camera sweeps up -> two robots are lowered in
const INTRO_END = RC.INTRO_END = 7.5;
const INTRO_END = RC.INTRO_END = 5.2;
const ease = u => (u < 0.5 ? 2 * u * u : 1 - Math.pow(-2 * u + 2, 2) / 2);
function lightsOn(k) {
const L = arena.lights;
@@ -1176,12 +1189,12 @@
function introScript(dt) {
const t = introT, s = state;
// floodlights: off, flicker, on
lightsOn(t < 1.2 ? 0 : t < 1.32 ? 1 : t < 1.5 ? 0.08 : t < 1.62 ? 0.8 : t < 1.85 ? 0.25 : 1);
lightsOn(t < 0.25 ? 0.12 : t < 0.4 ? 1 : t < 0.55 ? 0.15 : t < 0.7 ? 0.9 : t < 0.85 ? 0.3 : 1);
// camera path, then a slow orbit
let ang, r, h, lx, lz;
if (t < INTRO_END) {
const e = ease(Math.min(1, t / INTRO_END));
ang = lerp(-2.4, Math.PI / 4, e); r = lerp(5, 20.5, e); h = lerp(0.8, 13.5, Math.pow(e, 1.4));
ang = lerp(-2.4, Math.PI / 4, e); r = lerp(9, 20.5, e); h = lerp(2.4, 13.5, Math.pow(e, 1.4));
lx = lerp(RC.ARENA.pit.x, -0.6, e); lz = lerp(RC.ARENA.pit.z, -0.6, e);
} else {
ang = Math.PI / 4 + (t - INTRO_END) * 0.05; r = 20.5; h = 13.5; lx = lz = 0;
@@ -1191,13 +1204,13 @@
// robots lowered in from above, landing with sparks
s.t = t + 2; // trap timing: flames ignite once the lights are on
s.robots.forEach((rb, i) => {
const k = clamp((t - 2.6 - i * 0.35) / 1.6, 0, 1);
const k = clamp((t - 0.9 - i * 0.3) / 1.3, 0, 1);
const was = rb.y;
rb.y = 7 * Math.pow(1 - k, 2); rb.vx = rb.vz = 0; rb.lifted = rb.y > 0 ? 1 : 0; // lifted: no tumbling
if (was > 0 && rb.y === 0) { burst(rb.x, 0.2, rb.z, Math.round(40 * fxMul), 5, [1, 0.8, 0.4]); puff(rb.x, rb.z, 10); }
rb.spin = t > 5.4 ? Math.min(1, (t - 5.4) * 0.8) : 0; // spinners rev up
rb.sawOn = t > 5.6;
rb.flameOn = t > 5.8 && t < 6.6 || (t > INTRO_END && Math.sin(t * 0.9 + i * 2) > 0.97);
rb.spin = t > 3.1 ? Math.min(1, (t - 3.1) * 1.1) : 0; // spinners rev up
rb.sawOn = t > 3.3;
rb.flameOn = t > 3.5 && t < 4.3 || (t > INTRO_END && Math.sin(t * 0.9 + i * 2) > 0.97);
rb.turretA = rb.a + Math.sin(t * 0.7 + i) * 0.4;
});
}
@@ -1274,6 +1287,16 @@
smoke.spawn(r.x, y, r.z, (Math.random() - 0.5) * 0.3, 0.9, (Math.random() - 0.5) * 0.3, 1.6, r.dead ? 0.12 : 0.35, r.dead ? 0.12 : 0.34, r.dead ? 0.12 : 0.33);
if (r.dead || hp < 0.2) fire.spawn(r.x, y, r.z, (Math.random() - 0.5) * 0.4, 0.8, (Math.random() - 0.5) * 0.4, 0.4, 1, 0.5, 0.1);
}
// minigun: glowing tracers flying out of the barrel so you can see where it shoots
if (r.gunOn && R.st.tower && R.st.tower.type === 'minigun') {
const ca = Math.cos(r.turretA), sa = Math.sin(r.turretA), y0 = r.y + R.top + 0.2;
for (let q = 0; q < 2; q++) {
const sp = 46 + Math.random() * 14, sprd = (Math.random() - 0.5) * 0.06;
sparks.spawn(r.x + ca * 0.62, y0, r.z + sa * 0.62,
(ca - sa * sprd) * sp, (Math.random() - 0.5) * 0.6, (sa + ca * sprd) * sp, 0.2, 1, 0.92, 0.55);
}
if (Math.random() < 0.5) smoke.spawn(r.x + ca * 0.6, y0, r.z + sa * 0.6, ca * 0.6, 0.5, sa * 0.6, 0.5, 0.42, 0.42, 0.42);
}
if (r.flameOn && Math.random() < 0.7) {
const a = r.turretA + (Math.random() - 0.5) * 0.5, v = 5 + Math.random() * 2;
fire.spawn(r.x + Math.cos(r.turretA) * 0.6, r.y + R.top + 0.18, r.z + Math.sin(r.turretA) * 0.6, Math.cos(a) * v, 0.3, Math.sin(a) * v, 0.45, 1, 0.55, 0.15);
@@ -1314,6 +1337,28 @@
for (const d of arena.pitDoors) { d.position.x = A.pit.x + d.userData.sx * (A.pit.hw / 2 + o * A.pit.hw * 1.02); d.position.y = 0.025 + o * 0.01; }
for (const l of arena.pitLamps) l.material.emissiveIntensity = s.pitAlarm ? (Math.sin(now / 150) > 0 ? 2.5 : 0.4) : 0;
// rockets
// mines lying on the floor: dark puck, the lamp blinks fast once it is armed
const mines = s.mines || [];
while (arena.mineMeshes.length < mines.length) {
const g = new T.Group();
const puck = new T.Mesh(new T.CylinderGeometry(0.3, 0.34, 0.11, 14), new T.MeshStandardMaterial({ color: 0x23262c, metalness: 0.6, roughness: 0.6 }));
puck.position.y = 0.055; puck.castShadow = true; g.add(puck);
const ring = new T.Mesh(new T.TorusGeometry(0.3, 0.03, 6, 18), new T.MeshStandardMaterial({ color: 0xf2b51c, roughness: 0.6 }));
ring.rotation.x = Math.PI / 2; ring.position.y = 0.1; g.add(ring);
const lamp = new T.Mesh(new T.SphereGeometry(0.06, 8, 6), new T.MeshStandardMaterial({ color: 0x661111, emissive: 0xff2010, emissiveIntensity: 1 }));
lamp.position.y = 0.15; g.add(lamp);
g.userData.lamp = lamp;
arenaScene.add(g); arena.mineMeshes.push(g);
}
arena.mineMeshes.forEach((g, i) => {
const mn = mines[i];
g.visible = !!mn;
if (!mn) return;
g.position.set(mn.x, 0.01, mn.z);
const armed = mn.arm <= 0;
const blink = armed ? (Math.sin(now / 90) > 0 ? 2.4 : 0.15) : 0.5;
g.userData.lamp.material.emissiveIntensity = blink;
});
while (arena.rocketMeshes.length < s.rockets.length) {
const gr = new T.Group();
const body = new T.Mesh(arena.rocketGeo, arena.rocketMat); gr.add(body);