Add GameDojo game environments (part 2)
Browse filesUpload the local game environment package into environments/. Includes the 42 boss spec scripts. Runtime text is English.
This view is limited to 50 files because it contains too many changes. See raw diff
- environments/games/web/games/mario64_remake/app3d.js +68 -0
- environments/games/web/games/mario64_remake/compact_actions.json +1987 -0
- environments/games/web/games/mario64_remake/draw.js +46 -0
- environments/games/web/games/mario64_remake/game.js +0 -0
- environments/games/web/games/mario64_remake/index.html +7 -0
- environments/games/web/games/mario64_remake/manifest.json +34 -0
- environments/games/web/games/mario64_remake/renderer3d.js +387 -0
- environments/games/web/games/mario64_remake/style3d.css +1 -0
- environments/games/web/games/megaman_remake/arena.js +118 -0
- environments/games/web/games/megaman_remake/art/scenes.js +15 -0
- environments/games/web/games/megaman_remake/body_megaman.js +471 -0
- environments/games/web/games/megaman_remake/bosses/bomb_man.js +162 -0
- environments/games/web/games/megaman_remake/bosses/cut_man.js +193 -0
- environments/games/web/games/megaman_remake/bosses/elec_man.js +117 -0
- environments/games/web/games/megaman_remake/bosses/fire_man.js +119 -0
- environments/games/web/games/megaman_remake/bosses/guts_man.js +160 -0
- environments/games/web/games/megaman_remake/bosses/ice_man.js +93 -0
- environments/games/web/games/megaman_remake/bosses/robot_master.js +90 -0
- environments/games/web/games/megaman_remake/compact_actions.json +373 -0
- environments/games/web/games/megaman_remake/data/weapons.js +62 -0
- environments/games/web/games/megaman_remake/draw/compose.js +83 -0
- environments/games/web/games/megaman_remake/draw/hud.js +78 -0
- environments/games/web/games/megaman_remake/draw/palette.js +22 -0
- environments/games/web/games/megaman_remake/draw/player.js +130 -0
- environments/games/web/games/megaman_remake/draw/rooms.js +241 -0
- environments/games/web/games/megaman_remake/game.js +34 -0
- environments/games/web/games/megaman_remake/index.html +14 -0
- environments/games/web/games/megaman_remake/page.js +71 -0
- environments/games/web/games/megaman_remake/scripted.js +163 -0
- environments/games/web/games/megaman_remake/specs/bomb_man.spec.js +117 -0
- environments/games/web/games/megaman_remake/specs/cut_man.spec.js +122 -0
- environments/games/web/games/megaman_remake/specs/elec_man.spec.js +129 -0
- environments/games/web/games/megaman_remake/specs/fire_man.spec.js +133 -0
- environments/games/web/games/megaman_remake/specs/guts_man.spec.js +113 -0
- environments/games/web/games/megaman_remake/specs/ice_man.spec.js +107 -0
- environments/games/web/games/minecraft_remake/compact_actions.json +224 -0
- environments/games/web/games/minecraft_remake/index.html +86 -0
- environments/games/web/games/minecraft_remake/manifest.json +79 -0
- environments/games/web/games/minecraft_remake/play.js +338 -0
- environments/games/web/games/minecraft_remake/style.css +44 -0
- environments/games/web/games/nfsmw_remake/compact_actions.json +269 -0
- environments/games/web/games/nfsmw_remake/cops.js +158 -0
- environments/games/web/games/nfsmw_remake/draw.js +166 -0
- environments/games/web/games/nfsmw_remake/game.js +167 -0
- environments/games/web/games/nfsmw_remake/index.html +7 -0
- environments/games/web/games/nfsmw_remake/manifest.json +55 -0
- environments/games/web/games/nfsmw_remake/modes_drag.js +113 -0
- environments/games/web/games/nfsmw_remake/modes_knockout.js +57 -0
- environments/games/web/games/nfsmw_remake/modes_pursuit.js +437 -0
- environments/games/web/games/nfsmw_remake/modes_speedtrap.js +62 -0
environments/games/web/games/mario64_remake/app3d.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Human play and exact native-input recording. Game state is owned by each module. */
|
| 2 |
+
(function () {
|
| 3 |
+
'use strict';
|
| 4 |
+
const N=NativeBench, M=window.GAME_MODULE, $=s=>document.querySelector(s), canvas=$('canvas'), context=canvas.getContext('2d');
|
| 5 |
+
let session=new N.Session(M,M.cases[0].id,1,.5),running=false,last=0,accumulator=0;
|
| 6 |
+
// A key pressed and released between two ticks stays held until one tick has sampled it (same latch as _native/shell.js),
|
| 7 |
+
// so fast taps (jump, ground pound, camera steps) are never lost.
|
| 8 |
+
const held=new Set(),pending=new Set(),releaseAfter=new Set(),pointerHeld=new Map(),touchHeld=new Map(); let mouse=[0,0,0],replay=null,replayIndex=0,automatic=false,script=null,scriptTick=0;
|
| 9 |
+
const keys={KeyW:'W',KeyA:'A',KeyS:'S',KeyD:'D',Space:'Space',ShiftLeft:'Shift',ShiftRight:'Shift',KeyJ:'J',KeyK:'K',KeyL:'L',KeyQ:'Q',KeyE:'E',KeyR:'R',ArrowUp:'W',ArrowDown:'S',ArrowLeft:'A',ArrowRight:'D'};
|
| 10 |
+
document.body.dataset.game=M.id;
|
| 11 |
+
// Public difficulty = three tiers (2026-11-02): rebuilt from Module.tiers when the game declares it.
|
| 12 |
+
if(M.tiers&&$('#difficulty')){const sel=$('#difficulty'),names={easy:'Easy',normal:'Normal',hard:'Hard'};sel.textContent='';
|
| 13 |
+
for(const t of ['easy','normal','hard']){const op=document.createElement('option');op.value=String(M.tiers[t]);op.textContent=names[t]+' (d='+M.tiers[t]+')';if(t==='normal')op.selected=true;sel.append(op);}}
|
| 14 |
+
for(const def of M.cases){const option=document.createElement('option');option.value=def.id;option.textContent=def.name;$('#case').append(option);}
|
| 15 |
+
const controls=Array.isArray(M.controls)?M.controls.map(value=>['',value]):Object.entries(M.controls);
|
| 16 |
+
for(const [key,value]of controls){const dt=document.createElement('dt'),dd=document.createElement('dd');dt.textContent=key;dd.textContent=value;$('dl').append(dt,dd);}
|
| 17 |
+
function status(value){$('#status').textContent=value;}
|
| 18 |
+
function clear(){held.clear();pending.clear();releaseAfter.clear();pointerHeld.clear();touchHeld.clear();mouse=[0,0,0];accumulator=0;}
|
| 19 |
+
function inputKeys(){return [...new Set([...held,...[...pointerHeld.values()].flatMap(keys=>[...keys]),...touchHeld.values()])].filter(key=>N.keys.includes(key)).slice(0,4);}
|
| 20 |
+
function draw(){
|
| 21 |
+
M.draw(session.game,context);
|
| 22 |
+
$('#pause').textContent=running?'Pause':'Resume';
|
| 23 |
+
$('#overlay').hidden=running&&!session.game.outcome;
|
| 24 |
+
$('#overlay strong').textContent=session.game.outcome?{win:'Challenge Complete',loss:'Challenge Failed',timeout:'Time up'}[session.game.outcome]:replay?'Replay · Paused':session.game.t?'Paused':'Are You Ready?';
|
| 25 |
+
$('#overlay span').textContent=session.game.outcome?'Restart the challenge or export the replay':session.game.t?'Click Resume to return to battle':'Click Start Challenge, then click the screen to use keyboard and mouse';
|
| 26 |
+
}
|
| 27 |
+
function reset(id,seed,difficulty){running=false;automatic=false;replay=null;script=null;scriptTick=0;clear();session=new N.Session(M,id,seed,difficulty);draw();return session.snapshot();}
|
| 28 |
+
window.nativeAPI={reset,packet(packet){if(running)throw Error('Pause before a scripted packet');const value=session.packet(packet);draw();return value;},
|
| 29 |
+
state(){return session.snapshot();},recording(){return session.export();},
|
| 30 |
+
render(){draw();return canvas.toDataURL('image/png');},
|
| 31 |
+
renderMetrics(){return M.renderMetrics?M.renderMetrics(context):{};},
|
| 32 |
+
module(){return {id:M.id,hz:M.hz,version:M.version,cases:M.cases};}};
|
| 33 |
+
function start(useScript){try{reset($('#case').value,Number($('#seed').value),Number($('#difficulty').value));automatic=useScript;running=true;status(useScript?'Script verification running':'Battle started; recording this match');canvas.focus();draw();}catch(error){status(error.message);}}
|
| 34 |
+
$('#start').onclick=()=>start(false);$('#demo').onclick=()=>start(true);
|
| 35 |
+
$('#pause').onclick=()=>{if(session.game.outcome)return;running=!running;clear();if(running)canvas.focus();draw();};
|
| 36 |
+
$('#step').onclick=()=>{running=false;if(replay)replayTick();else session.tick();draw();};
|
| 37 |
+
function openReplay(data){N.Session.import(M,data);reset(data.case,data.seed,data.difficulty);replay=data;replayIndex=0;running=true;$('#case').value=data.case;status('Replay verified; playback started');draw();}
|
| 38 |
+
$('#sample').onclick=()=>{try{const data=M.example?.[$('#case').value];if(!data)throw Error('No built-in replay for this fight; try the scripted demo');openReplay(data);}catch(error){status(error.message);}};
|
| 39 |
+
function replayTick(){if(replayIndex<replay.inputs.length){const input=replay.inputs[replayIndex++];session.tick(input[0],input[1]);}if(replayIndex===replay.inputs.length){running=false;status('Replay Finished · '+(N.hash(session.state())===replay.finalHash?'final state matches':'final state mismatch'));}}
|
| 40 |
+
$('#export').onclick=()=>{const data=session.export(),url=URL.createObjectURL(new Blob([JSON.stringify(data)],{type:'application/json'}));const link=document.createElement('a');link.href=url;link.download=M.id+'-'+session.seed+'.json';link.click();setTimeout(()=>URL.revokeObjectURL(url),1000);status('Current replay exported');};
|
| 41 |
+
$('#import').onclick=()=>$('#file').click();$('#file').onchange=async event=>{const file=event.target.files[0];if(!file)return;try{if(file.size>12e6)throw Error('Replay file is too large');openReplay(JSON.parse(await file.text()));}catch(error){status('Import failed: '+error.message);}event.target.value='';};
|
| 42 |
+
function release(){clear();if(running){running=false;status('Window lost focus; battle paused');}draw();}
|
| 43 |
+
window.addEventListener('blur',release);document.addEventListener('visibilitychange',()=>{if(document.hidden)release();});
|
| 44 |
+
window.addEventListener('keydown',event=>{if(['INPUT','SELECT','BUTTON'].includes(document.activeElement.tagName))return;if(keys[event.code]){event.preventDefault();held.add(keys[event.code]);pending.add(keys[event.code]);releaseAfter.delete(keys[event.code]);}if(event.code==='Escape'){running=false;clear();draw();}});
|
| 45 |
+
window.addEventListener('keyup',event=>{const key=keys[event.code];if(key){event.preventDefault();if(pending.has(key))releaseAfter.add(key);else held.delete(key);}});
|
| 46 |
+
canvas.oncontextmenu=event=>event.preventDefault();canvas.onpointerdown=event=>{if(event.button!==0&&event.button!==2)return;canvas.focus();const keys=pointerHeld.get(event.pointerId)||new Set();keys.add(event.button===2?'RMB':'LMB');pointerHeld.set(event.pointerId,keys);};
|
| 47 |
+
// Pointer Events emits pointerup only after the final mouse button is released.
|
| 48 |
+
// pointermove carries changes to the button mask for chorded mouse presses.
|
| 49 |
+
function syncMouse(event){if(event.pointerType==='mouse'&&pointerHeld.has(event.pointerId)){const keys=new Set();if(event.buttons&1)keys.add('LMB');if(event.buttons&2)keys.add('RMB');if(keys.size)pointerHeld.set(event.pointerId,keys);else pointerHeld.delete(event.pointerId);}}
|
| 50 |
+
window.addEventListener('pointermove',syncMouse);
|
| 51 |
+
window.addEventListener('pointerup',event=>{if(event.pointerType==='mouse')syncMouse(event);else pointerHeld.delete(event.pointerId);touchHeld.delete(event.pointerId);});
|
| 52 |
+
window.addEventListener('pointercancel',event=>{pointerHeld.delete(event.pointerId);touchHeld.delete(event.pointerId);});
|
| 53 |
+
canvas.onpointermove=event=>{if(event.buttons||document.pointerLockElement===canvas){mouse[0]+=event.movementX;mouse[1]+=event.movementY;}};
|
| 54 |
+
canvas.onwheel=event=>{event.preventDefault();mouse[2]+=Math.sign(event.deltaY);};
|
| 55 |
+
canvas.ondblclick=()=>canvas.requestPointerLock?.();
|
| 56 |
+
document.querySelectorAll('[data-key]').forEach(button=>{button.onpointerdown=event=>{event.preventDefault();button.setPointerCapture(event.pointerId);touchHeld.set(event.pointerId,button.dataset.key);};button.onpointerup=button.onpointercancel=event=>touchHeld.delete(event.pointerId);});
|
| 57 |
+
function frame(now){const delta=Math.min(.1,(now-last)/1000||0);last=now;const beforeTick=session.game.t,wasRunning=running;try{
|
| 58 |
+
if(running&&!session.game.outcome){accumulator+=delta;while(accumulator>=1/M.hz&&running&&!session.game.outcome){accumulator-=1/M.hz;
|
| 59 |
+
if(replay)replayTick();else if(automatic){const count=M.hz/5;if(scriptTick===0)script=(M.scripted||M.oracle).call(M,session.game);const sub=Math.ceil((scriptTick+1)*6/count)-1;session.tick(script.holds[sub],script.mouse.map(value=>value/count));scriptTick=(scriptTick+1)%count;}
|
| 60 |
+
else{session.tick(inputKeys(),mouse.map((value,index)=>N.clamp(value,index===2?-5:-1000,index===2?5:1000)));mouse=[0,0,0];pending.clear();for(const key of releaseAfter)held.delete(key);releaseAfter.clear();}}
|
| 61 |
+
if(session.game.outcome){running=false;status({win:'Challenge Complete',loss:'Challenge Failed',timeout:'Challenge Timed Out'}[session.game.outcome]+' · export or replay this match');}}
|
| 62 |
+
if(session.game.t!==beforeTick||running!==wasRunning)draw();
|
| 63 |
+
}catch(error){running=false;clear();status('Runtime error: '+error.message);$('#overlay').hidden=false;$('#overlay strong').textContent='Unable to resume right now';$('#overlay span').textContent=error.message;}
|
| 64 |
+
requestAnimationFrame(frame);
|
| 65 |
+
}
|
| 66 |
+
window.addEventListener('pagehide',()=>M.closeRenderer?.(context));
|
| 67 |
+
draw();requestAnimationFrame(frame);
|
| 68 |
+
})();
|
environments/games/web/games/mario64_remake/compact_actions.json
ADDED
|
@@ -0,0 +1,1987 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema": "bossbench/compact-actions@1",
|
| 3 |
+
"game": "mario64_remake",
|
| 4 |
+
"version": "mario64-compact@4",
|
| 5 |
+
"heads": [
|
| 6 |
+
{
|
| 7 |
+
"name": "move",
|
| 8 |
+
"options": [
|
| 9 |
+
{
|
| 10 |
+
"label": "none"
|
| 11 |
+
},
|
| 12 |
+
{
|
| 13 |
+
"label": "cam_left",
|
| 14 |
+
"tap": [
|
| 15 |
+
"Q"
|
| 16 |
+
]
|
| 17 |
+
},
|
| 18 |
+
{
|
| 19 |
+
"label": "cam_right",
|
| 20 |
+
"tap": [
|
| 21 |
+
"E"
|
| 22 |
+
]
|
| 23 |
+
},
|
| 24 |
+
{
|
| 25 |
+
"label": "cam_reset",
|
| 26 |
+
"tap": [
|
| 27 |
+
"R"
|
| 28 |
+
]
|
| 29 |
+
},
|
| 30 |
+
{
|
| 31 |
+
"label": "w",
|
| 32 |
+
"keys": [
|
| 33 |
+
"W"
|
| 34 |
+
]
|
| 35 |
+
},
|
| 36 |
+
{
|
| 37 |
+
"label": "wa",
|
| 38 |
+
"keys": [
|
| 39 |
+
"W",
|
| 40 |
+
"A"
|
| 41 |
+
]
|
| 42 |
+
},
|
| 43 |
+
{
|
| 44 |
+
"label": "a",
|
| 45 |
+
"keys": [
|
| 46 |
+
"A"
|
| 47 |
+
]
|
| 48 |
+
},
|
| 49 |
+
{
|
| 50 |
+
"label": "as",
|
| 51 |
+
"keys": [
|
| 52 |
+
"A",
|
| 53 |
+
"S"
|
| 54 |
+
]
|
| 55 |
+
},
|
| 56 |
+
{
|
| 57 |
+
"label": "s",
|
| 58 |
+
"keys": [
|
| 59 |
+
"S"
|
| 60 |
+
]
|
| 61 |
+
},
|
| 62 |
+
{
|
| 63 |
+
"label": "sd",
|
| 64 |
+
"keys": [
|
| 65 |
+
"S",
|
| 66 |
+
"D"
|
| 67 |
+
]
|
| 68 |
+
},
|
| 69 |
+
{
|
| 70 |
+
"label": "d",
|
| 71 |
+
"keys": [
|
| 72 |
+
"D"
|
| 73 |
+
]
|
| 74 |
+
},
|
| 75 |
+
{
|
| 76 |
+
"label": "wd",
|
| 77 |
+
"keys": [
|
| 78 |
+
"W",
|
| 79 |
+
"D"
|
| 80 |
+
]
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
"label": "m_w_a_s_d_w_a",
|
| 84 |
+
"subs": [
|
| 85 |
+
[
|
| 86 |
+
"W"
|
| 87 |
+
],
|
| 88 |
+
[
|
| 89 |
+
"A"
|
| 90 |
+
],
|
| 91 |
+
[
|
| 92 |
+
"S"
|
| 93 |
+
],
|
| 94 |
+
[
|
| 95 |
+
"D"
|
| 96 |
+
],
|
| 97 |
+
[
|
| 98 |
+
"W"
|
| 99 |
+
],
|
| 100 |
+
[
|
| 101 |
+
"A"
|
| 102 |
+
]
|
| 103 |
+
]
|
| 104 |
+
},
|
| 105 |
+
{
|
| 106 |
+
"label": "m_wa_as_sd_wd_wa_as",
|
| 107 |
+
"subs": [
|
| 108 |
+
[
|
| 109 |
+
"W",
|
| 110 |
+
"A"
|
| 111 |
+
],
|
| 112 |
+
[
|
| 113 |
+
"A",
|
| 114 |
+
"S"
|
| 115 |
+
],
|
| 116 |
+
[
|
| 117 |
+
"S",
|
| 118 |
+
"D"
|
| 119 |
+
],
|
| 120 |
+
[
|
| 121 |
+
"W",
|
| 122 |
+
"D"
|
| 123 |
+
],
|
| 124 |
+
[
|
| 125 |
+
"W",
|
| 126 |
+
"A"
|
| 127 |
+
],
|
| 128 |
+
[
|
| 129 |
+
"A",
|
| 130 |
+
"S"
|
| 131 |
+
]
|
| 132 |
+
]
|
| 133 |
+
},
|
| 134 |
+
{
|
| 135 |
+
"label": "m_a_s_d_w_a_s",
|
| 136 |
+
"subs": [
|
| 137 |
+
[
|
| 138 |
+
"A"
|
| 139 |
+
],
|
| 140 |
+
[
|
| 141 |
+
"S"
|
| 142 |
+
],
|
| 143 |
+
[
|
| 144 |
+
"D"
|
| 145 |
+
],
|
| 146 |
+
[
|
| 147 |
+
"W"
|
| 148 |
+
],
|
| 149 |
+
[
|
| 150 |
+
"A"
|
| 151 |
+
],
|
| 152 |
+
[
|
| 153 |
+
"S"
|
| 154 |
+
]
|
| 155 |
+
]
|
| 156 |
+
},
|
| 157 |
+
{
|
| 158 |
+
"label": "m_as_sd_wd_wa_as_sd",
|
| 159 |
+
"subs": [
|
| 160 |
+
[
|
| 161 |
+
"A",
|
| 162 |
+
"S"
|
| 163 |
+
],
|
| 164 |
+
[
|
| 165 |
+
"S",
|
| 166 |
+
"D"
|
| 167 |
+
],
|
| 168 |
+
[
|
| 169 |
+
"W",
|
| 170 |
+
"D"
|
| 171 |
+
],
|
| 172 |
+
[
|
| 173 |
+
"W",
|
| 174 |
+
"A"
|
| 175 |
+
],
|
| 176 |
+
[
|
| 177 |
+
"A",
|
| 178 |
+
"S"
|
| 179 |
+
],
|
| 180 |
+
[
|
| 181 |
+
"S",
|
| 182 |
+
"D"
|
| 183 |
+
]
|
| 184 |
+
]
|
| 185 |
+
},
|
| 186 |
+
{
|
| 187 |
+
"label": "m_s_d_w_a_s_d",
|
| 188 |
+
"subs": [
|
| 189 |
+
[
|
| 190 |
+
"S"
|
| 191 |
+
],
|
| 192 |
+
[
|
| 193 |
+
"D"
|
| 194 |
+
],
|
| 195 |
+
[
|
| 196 |
+
"W"
|
| 197 |
+
],
|
| 198 |
+
[
|
| 199 |
+
"A"
|
| 200 |
+
],
|
| 201 |
+
[
|
| 202 |
+
"S"
|
| 203 |
+
],
|
| 204 |
+
[
|
| 205 |
+
"D"
|
| 206 |
+
]
|
| 207 |
+
]
|
| 208 |
+
},
|
| 209 |
+
{
|
| 210 |
+
"label": "m_sd_wd_wa_as_sd_wd",
|
| 211 |
+
"subs": [
|
| 212 |
+
[
|
| 213 |
+
"S",
|
| 214 |
+
"D"
|
| 215 |
+
],
|
| 216 |
+
[
|
| 217 |
+
"W",
|
| 218 |
+
"D"
|
| 219 |
+
],
|
| 220 |
+
[
|
| 221 |
+
"W",
|
| 222 |
+
"A"
|
| 223 |
+
],
|
| 224 |
+
[
|
| 225 |
+
"A",
|
| 226 |
+
"S"
|
| 227 |
+
],
|
| 228 |
+
[
|
| 229 |
+
"S",
|
| 230 |
+
"D"
|
| 231 |
+
],
|
| 232 |
+
[
|
| 233 |
+
"W",
|
| 234 |
+
"D"
|
| 235 |
+
]
|
| 236 |
+
]
|
| 237 |
+
},
|
| 238 |
+
{
|
| 239 |
+
"label": "m_d_w_a_s_d_w",
|
| 240 |
+
"subs": [
|
| 241 |
+
[
|
| 242 |
+
"D"
|
| 243 |
+
],
|
| 244 |
+
[
|
| 245 |
+
"W"
|
| 246 |
+
],
|
| 247 |
+
[
|
| 248 |
+
"A"
|
| 249 |
+
],
|
| 250 |
+
[
|
| 251 |
+
"S"
|
| 252 |
+
],
|
| 253 |
+
[
|
| 254 |
+
"D"
|
| 255 |
+
],
|
| 256 |
+
[
|
| 257 |
+
"W"
|
| 258 |
+
]
|
| 259 |
+
]
|
| 260 |
+
},
|
| 261 |
+
{
|
| 262 |
+
"label": "m_wd_wa_as_sd_wd_wa",
|
| 263 |
+
"subs": [
|
| 264 |
+
[
|
| 265 |
+
"W",
|
| 266 |
+
"D"
|
| 267 |
+
],
|
| 268 |
+
[
|
| 269 |
+
"W",
|
| 270 |
+
"A"
|
| 271 |
+
],
|
| 272 |
+
[
|
| 273 |
+
"A",
|
| 274 |
+
"S"
|
| 275 |
+
],
|
| 276 |
+
[
|
| 277 |
+
"S",
|
| 278 |
+
"D"
|
| 279 |
+
],
|
| 280 |
+
[
|
| 281 |
+
"W",
|
| 282 |
+
"D"
|
| 283 |
+
],
|
| 284 |
+
[
|
| 285 |
+
"W",
|
| 286 |
+
"A"
|
| 287 |
+
]
|
| 288 |
+
]
|
| 289 |
+
},
|
| 290 |
+
{
|
| 291 |
+
"label": "m_w_x_w_w_w_w",
|
| 292 |
+
"subs": [
|
| 293 |
+
[
|
| 294 |
+
"W"
|
| 295 |
+
],
|
| 296 |
+
[],
|
| 297 |
+
[
|
| 298 |
+
"W"
|
| 299 |
+
],
|
| 300 |
+
[
|
| 301 |
+
"W"
|
| 302 |
+
],
|
| 303 |
+
[
|
| 304 |
+
"W"
|
| 305 |
+
],
|
| 306 |
+
[
|
| 307 |
+
"W"
|
| 308 |
+
]
|
| 309 |
+
]
|
| 310 |
+
},
|
| 311 |
+
{
|
| 312 |
+
"label": "m_wa_x_wa_wa_wa_wa",
|
| 313 |
+
"subs": [
|
| 314 |
+
[
|
| 315 |
+
"W",
|
| 316 |
+
"A"
|
| 317 |
+
],
|
| 318 |
+
[],
|
| 319 |
+
[
|
| 320 |
+
"W",
|
| 321 |
+
"A"
|
| 322 |
+
],
|
| 323 |
+
[
|
| 324 |
+
"W",
|
| 325 |
+
"A"
|
| 326 |
+
],
|
| 327 |
+
[
|
| 328 |
+
"W",
|
| 329 |
+
"A"
|
| 330 |
+
],
|
| 331 |
+
[
|
| 332 |
+
"W",
|
| 333 |
+
"A"
|
| 334 |
+
]
|
| 335 |
+
]
|
| 336 |
+
},
|
| 337 |
+
{
|
| 338 |
+
"label": "m_a_x_a_a_a_a",
|
| 339 |
+
"subs": [
|
| 340 |
+
[
|
| 341 |
+
"A"
|
| 342 |
+
],
|
| 343 |
+
[],
|
| 344 |
+
[
|
| 345 |
+
"A"
|
| 346 |
+
],
|
| 347 |
+
[
|
| 348 |
+
"A"
|
| 349 |
+
],
|
| 350 |
+
[
|
| 351 |
+
"A"
|
| 352 |
+
],
|
| 353 |
+
[
|
| 354 |
+
"A"
|
| 355 |
+
]
|
| 356 |
+
]
|
| 357 |
+
},
|
| 358 |
+
{
|
| 359 |
+
"label": "m_as_x_as_as_as_as",
|
| 360 |
+
"subs": [
|
| 361 |
+
[
|
| 362 |
+
"A",
|
| 363 |
+
"S"
|
| 364 |
+
],
|
| 365 |
+
[],
|
| 366 |
+
[
|
| 367 |
+
"A",
|
| 368 |
+
"S"
|
| 369 |
+
],
|
| 370 |
+
[
|
| 371 |
+
"A",
|
| 372 |
+
"S"
|
| 373 |
+
],
|
| 374 |
+
[
|
| 375 |
+
"A",
|
| 376 |
+
"S"
|
| 377 |
+
],
|
| 378 |
+
[
|
| 379 |
+
"A",
|
| 380 |
+
"S"
|
| 381 |
+
]
|
| 382 |
+
]
|
| 383 |
+
},
|
| 384 |
+
{
|
| 385 |
+
"label": "m_s_x_s_s_s_s",
|
| 386 |
+
"subs": [
|
| 387 |
+
[
|
| 388 |
+
"S"
|
| 389 |
+
],
|
| 390 |
+
[],
|
| 391 |
+
[
|
| 392 |
+
"S"
|
| 393 |
+
],
|
| 394 |
+
[
|
| 395 |
+
"S"
|
| 396 |
+
],
|
| 397 |
+
[
|
| 398 |
+
"S"
|
| 399 |
+
],
|
| 400 |
+
[
|
| 401 |
+
"S"
|
| 402 |
+
]
|
| 403 |
+
]
|
| 404 |
+
},
|
| 405 |
+
{
|
| 406 |
+
"label": "m_sd_x_sd_sd_sd_sd",
|
| 407 |
+
"subs": [
|
| 408 |
+
[
|
| 409 |
+
"S",
|
| 410 |
+
"D"
|
| 411 |
+
],
|
| 412 |
+
[],
|
| 413 |
+
[
|
| 414 |
+
"S",
|
| 415 |
+
"D"
|
| 416 |
+
],
|
| 417 |
+
[
|
| 418 |
+
"S",
|
| 419 |
+
"D"
|
| 420 |
+
],
|
| 421 |
+
[
|
| 422 |
+
"S",
|
| 423 |
+
"D"
|
| 424 |
+
],
|
| 425 |
+
[
|
| 426 |
+
"S",
|
| 427 |
+
"D"
|
| 428 |
+
]
|
| 429 |
+
]
|
| 430 |
+
},
|
| 431 |
+
{
|
| 432 |
+
"label": "m_d_x_d_d_d_d",
|
| 433 |
+
"subs": [
|
| 434 |
+
[
|
| 435 |
+
"D"
|
| 436 |
+
],
|
| 437 |
+
[],
|
| 438 |
+
[
|
| 439 |
+
"D"
|
| 440 |
+
],
|
| 441 |
+
[
|
| 442 |
+
"D"
|
| 443 |
+
],
|
| 444 |
+
[
|
| 445 |
+
"D"
|
| 446 |
+
],
|
| 447 |
+
[
|
| 448 |
+
"D"
|
| 449 |
+
]
|
| 450 |
+
]
|
| 451 |
+
},
|
| 452 |
+
{
|
| 453 |
+
"label": "m_wd_x_wd_wd_wd_wd",
|
| 454 |
+
"subs": [
|
| 455 |
+
[
|
| 456 |
+
"W",
|
| 457 |
+
"D"
|
| 458 |
+
],
|
| 459 |
+
[],
|
| 460 |
+
[
|
| 461 |
+
"W",
|
| 462 |
+
"D"
|
| 463 |
+
],
|
| 464 |
+
[
|
| 465 |
+
"W",
|
| 466 |
+
"D"
|
| 467 |
+
],
|
| 468 |
+
[
|
| 469 |
+
"W",
|
| 470 |
+
"D"
|
| 471 |
+
],
|
| 472 |
+
[
|
| 473 |
+
"W",
|
| 474 |
+
"D"
|
| 475 |
+
]
|
| 476 |
+
]
|
| 477 |
+
},
|
| 478 |
+
{
|
| 479 |
+
"label": "m_w_w_x_w_w_w",
|
| 480 |
+
"subs": [
|
| 481 |
+
[
|
| 482 |
+
"W"
|
| 483 |
+
],
|
| 484 |
+
[
|
| 485 |
+
"W"
|
| 486 |
+
],
|
| 487 |
+
[],
|
| 488 |
+
[
|
| 489 |
+
"W"
|
| 490 |
+
],
|
| 491 |
+
[
|
| 492 |
+
"W"
|
| 493 |
+
],
|
| 494 |
+
[
|
| 495 |
+
"W"
|
| 496 |
+
]
|
| 497 |
+
]
|
| 498 |
+
},
|
| 499 |
+
{
|
| 500 |
+
"label": "m_wa_wa_x_wa_wa_wa",
|
| 501 |
+
"subs": [
|
| 502 |
+
[
|
| 503 |
+
"W",
|
| 504 |
+
"A"
|
| 505 |
+
],
|
| 506 |
+
[
|
| 507 |
+
"W",
|
| 508 |
+
"A"
|
| 509 |
+
],
|
| 510 |
+
[],
|
| 511 |
+
[
|
| 512 |
+
"W",
|
| 513 |
+
"A"
|
| 514 |
+
],
|
| 515 |
+
[
|
| 516 |
+
"W",
|
| 517 |
+
"A"
|
| 518 |
+
],
|
| 519 |
+
[
|
| 520 |
+
"W",
|
| 521 |
+
"A"
|
| 522 |
+
]
|
| 523 |
+
]
|
| 524 |
+
},
|
| 525 |
+
{
|
| 526 |
+
"label": "m_a_a_x_a_a_a",
|
| 527 |
+
"subs": [
|
| 528 |
+
[
|
| 529 |
+
"A"
|
| 530 |
+
],
|
| 531 |
+
[
|
| 532 |
+
"A"
|
| 533 |
+
],
|
| 534 |
+
[],
|
| 535 |
+
[
|
| 536 |
+
"A"
|
| 537 |
+
],
|
| 538 |
+
[
|
| 539 |
+
"A"
|
| 540 |
+
],
|
| 541 |
+
[
|
| 542 |
+
"A"
|
| 543 |
+
]
|
| 544 |
+
]
|
| 545 |
+
},
|
| 546 |
+
{
|
| 547 |
+
"label": "m_s_s_x_s_s_s",
|
| 548 |
+
"subs": [
|
| 549 |
+
[
|
| 550 |
+
"S"
|
| 551 |
+
],
|
| 552 |
+
[
|
| 553 |
+
"S"
|
| 554 |
+
],
|
| 555 |
+
[],
|
| 556 |
+
[
|
| 557 |
+
"S"
|
| 558 |
+
],
|
| 559 |
+
[
|
| 560 |
+
"S"
|
| 561 |
+
],
|
| 562 |
+
[
|
| 563 |
+
"S"
|
| 564 |
+
]
|
| 565 |
+
]
|
| 566 |
+
},
|
| 567 |
+
{
|
| 568 |
+
"label": "m_d_d_x_d_d_d",
|
| 569 |
+
"subs": [
|
| 570 |
+
[
|
| 571 |
+
"D"
|
| 572 |
+
],
|
| 573 |
+
[
|
| 574 |
+
"D"
|
| 575 |
+
],
|
| 576 |
+
[],
|
| 577 |
+
[
|
| 578 |
+
"D"
|
| 579 |
+
],
|
| 580 |
+
[
|
| 581 |
+
"D"
|
| 582 |
+
],
|
| 583 |
+
[
|
| 584 |
+
"D"
|
| 585 |
+
]
|
| 586 |
+
]
|
| 587 |
+
},
|
| 588 |
+
{
|
| 589 |
+
"label": "m_wd_wd_x_wd_wd_wd",
|
| 590 |
+
"subs": [
|
| 591 |
+
[
|
| 592 |
+
"W",
|
| 593 |
+
"D"
|
| 594 |
+
],
|
| 595 |
+
[
|
| 596 |
+
"W",
|
| 597 |
+
"D"
|
| 598 |
+
],
|
| 599 |
+
[],
|
| 600 |
+
[
|
| 601 |
+
"W",
|
| 602 |
+
"D"
|
| 603 |
+
],
|
| 604 |
+
[
|
| 605 |
+
"W",
|
| 606 |
+
"D"
|
| 607 |
+
],
|
| 608 |
+
[
|
| 609 |
+
"W",
|
| 610 |
+
"D"
|
| 611 |
+
]
|
| 612 |
+
]
|
| 613 |
+
},
|
| 614 |
+
{
|
| 615 |
+
"label": "m_w_w_w_x_w_w",
|
| 616 |
+
"subs": [
|
| 617 |
+
[
|
| 618 |
+
"W"
|
| 619 |
+
],
|
| 620 |
+
[
|
| 621 |
+
"W"
|
| 622 |
+
],
|
| 623 |
+
[
|
| 624 |
+
"W"
|
| 625 |
+
],
|
| 626 |
+
[],
|
| 627 |
+
[
|
| 628 |
+
"W"
|
| 629 |
+
],
|
| 630 |
+
[
|
| 631 |
+
"W"
|
| 632 |
+
]
|
| 633 |
+
]
|
| 634 |
+
},
|
| 635 |
+
{
|
| 636 |
+
"label": "m_wa_wa_wa_x_wa_wa",
|
| 637 |
+
"subs": [
|
| 638 |
+
[
|
| 639 |
+
"W",
|
| 640 |
+
"A"
|
| 641 |
+
],
|
| 642 |
+
[
|
| 643 |
+
"W",
|
| 644 |
+
"A"
|
| 645 |
+
],
|
| 646 |
+
[
|
| 647 |
+
"W",
|
| 648 |
+
"A"
|
| 649 |
+
],
|
| 650 |
+
[],
|
| 651 |
+
[
|
| 652 |
+
"W",
|
| 653 |
+
"A"
|
| 654 |
+
],
|
| 655 |
+
[
|
| 656 |
+
"W",
|
| 657 |
+
"A"
|
| 658 |
+
]
|
| 659 |
+
]
|
| 660 |
+
},
|
| 661 |
+
{
|
| 662 |
+
"label": "m_a_a_a_x_a_a",
|
| 663 |
+
"subs": [
|
| 664 |
+
[
|
| 665 |
+
"A"
|
| 666 |
+
],
|
| 667 |
+
[
|
| 668 |
+
"A"
|
| 669 |
+
],
|
| 670 |
+
[
|
| 671 |
+
"A"
|
| 672 |
+
],
|
| 673 |
+
[],
|
| 674 |
+
[
|
| 675 |
+
"A"
|
| 676 |
+
],
|
| 677 |
+
[
|
| 678 |
+
"A"
|
| 679 |
+
]
|
| 680 |
+
]
|
| 681 |
+
},
|
| 682 |
+
{
|
| 683 |
+
"label": "m_as_as_as_x_as_as",
|
| 684 |
+
"subs": [
|
| 685 |
+
[
|
| 686 |
+
"A",
|
| 687 |
+
"S"
|
| 688 |
+
],
|
| 689 |
+
[
|
| 690 |
+
"A",
|
| 691 |
+
"S"
|
| 692 |
+
],
|
| 693 |
+
[
|
| 694 |
+
"A",
|
| 695 |
+
"S"
|
| 696 |
+
],
|
| 697 |
+
[],
|
| 698 |
+
[
|
| 699 |
+
"A",
|
| 700 |
+
"S"
|
| 701 |
+
],
|
| 702 |
+
[
|
| 703 |
+
"A",
|
| 704 |
+
"S"
|
| 705 |
+
]
|
| 706 |
+
]
|
| 707 |
+
},
|
| 708 |
+
{
|
| 709 |
+
"label": "m_s_s_s_x_s_s",
|
| 710 |
+
"subs": [
|
| 711 |
+
[
|
| 712 |
+
"S"
|
| 713 |
+
],
|
| 714 |
+
[
|
| 715 |
+
"S"
|
| 716 |
+
],
|
| 717 |
+
[
|
| 718 |
+
"S"
|
| 719 |
+
],
|
| 720 |
+
[],
|
| 721 |
+
[
|
| 722 |
+
"S"
|
| 723 |
+
],
|
| 724 |
+
[
|
| 725 |
+
"S"
|
| 726 |
+
]
|
| 727 |
+
]
|
| 728 |
+
},
|
| 729 |
+
{
|
| 730 |
+
"label": "m_sd_sd_sd_x_sd_sd",
|
| 731 |
+
"subs": [
|
| 732 |
+
[
|
| 733 |
+
"S",
|
| 734 |
+
"D"
|
| 735 |
+
],
|
| 736 |
+
[
|
| 737 |
+
"S",
|
| 738 |
+
"D"
|
| 739 |
+
],
|
| 740 |
+
[
|
| 741 |
+
"S",
|
| 742 |
+
"D"
|
| 743 |
+
],
|
| 744 |
+
[],
|
| 745 |
+
[
|
| 746 |
+
"S",
|
| 747 |
+
"D"
|
| 748 |
+
],
|
| 749 |
+
[
|
| 750 |
+
"S",
|
| 751 |
+
"D"
|
| 752 |
+
]
|
| 753 |
+
]
|
| 754 |
+
},
|
| 755 |
+
{
|
| 756 |
+
"label": "m_d_d_d_x_d_d",
|
| 757 |
+
"subs": [
|
| 758 |
+
[
|
| 759 |
+
"D"
|
| 760 |
+
],
|
| 761 |
+
[
|
| 762 |
+
"D"
|
| 763 |
+
],
|
| 764 |
+
[
|
| 765 |
+
"D"
|
| 766 |
+
],
|
| 767 |
+
[],
|
| 768 |
+
[
|
| 769 |
+
"D"
|
| 770 |
+
],
|
| 771 |
+
[
|
| 772 |
+
"D"
|
| 773 |
+
]
|
| 774 |
+
]
|
| 775 |
+
},
|
| 776 |
+
{
|
| 777 |
+
"label": "m_wd_wd_wd_x_wd_wd",
|
| 778 |
+
"subs": [
|
| 779 |
+
[
|
| 780 |
+
"W",
|
| 781 |
+
"D"
|
| 782 |
+
],
|
| 783 |
+
[
|
| 784 |
+
"W",
|
| 785 |
+
"D"
|
| 786 |
+
],
|
| 787 |
+
[
|
| 788 |
+
"W",
|
| 789 |
+
"D"
|
| 790 |
+
],
|
| 791 |
+
[],
|
| 792 |
+
[
|
| 793 |
+
"W",
|
| 794 |
+
"D"
|
| 795 |
+
],
|
| 796 |
+
[
|
| 797 |
+
"W",
|
| 798 |
+
"D"
|
| 799 |
+
]
|
| 800 |
+
]
|
| 801 |
+
},
|
| 802 |
+
{
|
| 803 |
+
"label": "m_w_w_w_w_x_w",
|
| 804 |
+
"subs": [
|
| 805 |
+
[
|
| 806 |
+
"W"
|
| 807 |
+
],
|
| 808 |
+
[
|
| 809 |
+
"W"
|
| 810 |
+
],
|
| 811 |
+
[
|
| 812 |
+
"W"
|
| 813 |
+
],
|
| 814 |
+
[
|
| 815 |
+
"W"
|
| 816 |
+
],
|
| 817 |
+
[],
|
| 818 |
+
[
|
| 819 |
+
"W"
|
| 820 |
+
]
|
| 821 |
+
]
|
| 822 |
+
},
|
| 823 |
+
{
|
| 824 |
+
"label": "m_wa_wa_wa_wa_x_wa",
|
| 825 |
+
"subs": [
|
| 826 |
+
[
|
| 827 |
+
"W",
|
| 828 |
+
"A"
|
| 829 |
+
],
|
| 830 |
+
[
|
| 831 |
+
"W",
|
| 832 |
+
"A"
|
| 833 |
+
],
|
| 834 |
+
[
|
| 835 |
+
"W",
|
| 836 |
+
"A"
|
| 837 |
+
],
|
| 838 |
+
[
|
| 839 |
+
"W",
|
| 840 |
+
"A"
|
| 841 |
+
],
|
| 842 |
+
[],
|
| 843 |
+
[
|
| 844 |
+
"W",
|
| 845 |
+
"A"
|
| 846 |
+
]
|
| 847 |
+
]
|
| 848 |
+
},
|
| 849 |
+
{
|
| 850 |
+
"label": "m_a_a_a_a_x_a",
|
| 851 |
+
"subs": [
|
| 852 |
+
[
|
| 853 |
+
"A"
|
| 854 |
+
],
|
| 855 |
+
[
|
| 856 |
+
"A"
|
| 857 |
+
],
|
| 858 |
+
[
|
| 859 |
+
"A"
|
| 860 |
+
],
|
| 861 |
+
[
|
| 862 |
+
"A"
|
| 863 |
+
],
|
| 864 |
+
[],
|
| 865 |
+
[
|
| 866 |
+
"A"
|
| 867 |
+
]
|
| 868 |
+
]
|
| 869 |
+
},
|
| 870 |
+
{
|
| 871 |
+
"label": "m_as_as_as_as_x_as",
|
| 872 |
+
"subs": [
|
| 873 |
+
[
|
| 874 |
+
"A",
|
| 875 |
+
"S"
|
| 876 |
+
],
|
| 877 |
+
[
|
| 878 |
+
"A",
|
| 879 |
+
"S"
|
| 880 |
+
],
|
| 881 |
+
[
|
| 882 |
+
"A",
|
| 883 |
+
"S"
|
| 884 |
+
],
|
| 885 |
+
[
|
| 886 |
+
"A",
|
| 887 |
+
"S"
|
| 888 |
+
],
|
| 889 |
+
[],
|
| 890 |
+
[
|
| 891 |
+
"A",
|
| 892 |
+
"S"
|
| 893 |
+
]
|
| 894 |
+
]
|
| 895 |
+
},
|
| 896 |
+
{
|
| 897 |
+
"label": "m_s_s_s_s_x_s",
|
| 898 |
+
"subs": [
|
| 899 |
+
[
|
| 900 |
+
"S"
|
| 901 |
+
],
|
| 902 |
+
[
|
| 903 |
+
"S"
|
| 904 |
+
],
|
| 905 |
+
[
|
| 906 |
+
"S"
|
| 907 |
+
],
|
| 908 |
+
[
|
| 909 |
+
"S"
|
| 910 |
+
],
|
| 911 |
+
[],
|
| 912 |
+
[
|
| 913 |
+
"S"
|
| 914 |
+
]
|
| 915 |
+
]
|
| 916 |
+
},
|
| 917 |
+
{
|
| 918 |
+
"label": "m_sd_sd_sd_sd_x_sd",
|
| 919 |
+
"subs": [
|
| 920 |
+
[
|
| 921 |
+
"S",
|
| 922 |
+
"D"
|
| 923 |
+
],
|
| 924 |
+
[
|
| 925 |
+
"S",
|
| 926 |
+
"D"
|
| 927 |
+
],
|
| 928 |
+
[
|
| 929 |
+
"S",
|
| 930 |
+
"D"
|
| 931 |
+
],
|
| 932 |
+
[
|
| 933 |
+
"S",
|
| 934 |
+
"D"
|
| 935 |
+
],
|
| 936 |
+
[],
|
| 937 |
+
[
|
| 938 |
+
"S",
|
| 939 |
+
"D"
|
| 940 |
+
]
|
| 941 |
+
]
|
| 942 |
+
},
|
| 943 |
+
{
|
| 944 |
+
"label": "m_d_d_d_d_x_d",
|
| 945 |
+
"subs": [
|
| 946 |
+
[
|
| 947 |
+
"D"
|
| 948 |
+
],
|
| 949 |
+
[
|
| 950 |
+
"D"
|
| 951 |
+
],
|
| 952 |
+
[
|
| 953 |
+
"D"
|
| 954 |
+
],
|
| 955 |
+
[
|
| 956 |
+
"D"
|
| 957 |
+
],
|
| 958 |
+
[],
|
| 959 |
+
[
|
| 960 |
+
"D"
|
| 961 |
+
]
|
| 962 |
+
]
|
| 963 |
+
},
|
| 964 |
+
{
|
| 965 |
+
"label": "m_wd_wd_wd_wd_x_wd",
|
| 966 |
+
"subs": [
|
| 967 |
+
[
|
| 968 |
+
"W",
|
| 969 |
+
"D"
|
| 970 |
+
],
|
| 971 |
+
[
|
| 972 |
+
"W",
|
| 973 |
+
"D"
|
| 974 |
+
],
|
| 975 |
+
[
|
| 976 |
+
"W",
|
| 977 |
+
"D"
|
| 978 |
+
],
|
| 979 |
+
[
|
| 980 |
+
"W",
|
| 981 |
+
"D"
|
| 982 |
+
],
|
| 983 |
+
[],
|
| 984 |
+
[
|
| 985 |
+
"W",
|
| 986 |
+
"D"
|
| 987 |
+
]
|
| 988 |
+
]
|
| 989 |
+
},
|
| 990 |
+
{
|
| 991 |
+
"label": "m_w_w_w_w_w_x",
|
| 992 |
+
"subs": [
|
| 993 |
+
[
|
| 994 |
+
"W"
|
| 995 |
+
],
|
| 996 |
+
[
|
| 997 |
+
"W"
|
| 998 |
+
],
|
| 999 |
+
[
|
| 1000 |
+
"W"
|
| 1001 |
+
],
|
| 1002 |
+
[
|
| 1003 |
+
"W"
|
| 1004 |
+
],
|
| 1005 |
+
[
|
| 1006 |
+
"W"
|
| 1007 |
+
],
|
| 1008 |
+
[]
|
| 1009 |
+
]
|
| 1010 |
+
},
|
| 1011 |
+
{
|
| 1012 |
+
"label": "m_wa_wa_wa_wa_wa_x",
|
| 1013 |
+
"subs": [
|
| 1014 |
+
[
|
| 1015 |
+
"W",
|
| 1016 |
+
"A"
|
| 1017 |
+
],
|
| 1018 |
+
[
|
| 1019 |
+
"W",
|
| 1020 |
+
"A"
|
| 1021 |
+
],
|
| 1022 |
+
[
|
| 1023 |
+
"W",
|
| 1024 |
+
"A"
|
| 1025 |
+
],
|
| 1026 |
+
[
|
| 1027 |
+
"W",
|
| 1028 |
+
"A"
|
| 1029 |
+
],
|
| 1030 |
+
[
|
| 1031 |
+
"W",
|
| 1032 |
+
"A"
|
| 1033 |
+
],
|
| 1034 |
+
[]
|
| 1035 |
+
]
|
| 1036 |
+
},
|
| 1037 |
+
{
|
| 1038 |
+
"label": "m_a_a_a_a_a_x",
|
| 1039 |
+
"subs": [
|
| 1040 |
+
[
|
| 1041 |
+
"A"
|
| 1042 |
+
],
|
| 1043 |
+
[
|
| 1044 |
+
"A"
|
| 1045 |
+
],
|
| 1046 |
+
[
|
| 1047 |
+
"A"
|
| 1048 |
+
],
|
| 1049 |
+
[
|
| 1050 |
+
"A"
|
| 1051 |
+
],
|
| 1052 |
+
[
|
| 1053 |
+
"A"
|
| 1054 |
+
],
|
| 1055 |
+
[]
|
| 1056 |
+
]
|
| 1057 |
+
},
|
| 1058 |
+
{
|
| 1059 |
+
"label": "m_as_as_as_as_as_x",
|
| 1060 |
+
"subs": [
|
| 1061 |
+
[
|
| 1062 |
+
"A",
|
| 1063 |
+
"S"
|
| 1064 |
+
],
|
| 1065 |
+
[
|
| 1066 |
+
"A",
|
| 1067 |
+
"S"
|
| 1068 |
+
],
|
| 1069 |
+
[
|
| 1070 |
+
"A",
|
| 1071 |
+
"S"
|
| 1072 |
+
],
|
| 1073 |
+
[
|
| 1074 |
+
"A",
|
| 1075 |
+
"S"
|
| 1076 |
+
],
|
| 1077 |
+
[
|
| 1078 |
+
"A",
|
| 1079 |
+
"S"
|
| 1080 |
+
],
|
| 1081 |
+
[]
|
| 1082 |
+
]
|
| 1083 |
+
},
|
| 1084 |
+
{
|
| 1085 |
+
"label": "m_s_s_s_s_s_x",
|
| 1086 |
+
"subs": [
|
| 1087 |
+
[
|
| 1088 |
+
"S"
|
| 1089 |
+
],
|
| 1090 |
+
[
|
| 1091 |
+
"S"
|
| 1092 |
+
],
|
| 1093 |
+
[
|
| 1094 |
+
"S"
|
| 1095 |
+
],
|
| 1096 |
+
[
|
| 1097 |
+
"S"
|
| 1098 |
+
],
|
| 1099 |
+
[
|
| 1100 |
+
"S"
|
| 1101 |
+
],
|
| 1102 |
+
[]
|
| 1103 |
+
]
|
| 1104 |
+
},
|
| 1105 |
+
{
|
| 1106 |
+
"label": "m_sd_sd_sd_sd_sd_x",
|
| 1107 |
+
"subs": [
|
| 1108 |
+
[
|
| 1109 |
+
"S",
|
| 1110 |
+
"D"
|
| 1111 |
+
],
|
| 1112 |
+
[
|
| 1113 |
+
"S",
|
| 1114 |
+
"D"
|
| 1115 |
+
],
|
| 1116 |
+
[
|
| 1117 |
+
"S",
|
| 1118 |
+
"D"
|
| 1119 |
+
],
|
| 1120 |
+
[
|
| 1121 |
+
"S",
|
| 1122 |
+
"D"
|
| 1123 |
+
],
|
| 1124 |
+
[
|
| 1125 |
+
"S",
|
| 1126 |
+
"D"
|
| 1127 |
+
],
|
| 1128 |
+
[]
|
| 1129 |
+
]
|
| 1130 |
+
},
|
| 1131 |
+
{
|
| 1132 |
+
"label": "m_d_d_d_d_d_x",
|
| 1133 |
+
"subs": [
|
| 1134 |
+
[
|
| 1135 |
+
"D"
|
| 1136 |
+
],
|
| 1137 |
+
[
|
| 1138 |
+
"D"
|
| 1139 |
+
],
|
| 1140 |
+
[
|
| 1141 |
+
"D"
|
| 1142 |
+
],
|
| 1143 |
+
[
|
| 1144 |
+
"D"
|
| 1145 |
+
],
|
| 1146 |
+
[
|
| 1147 |
+
"D"
|
| 1148 |
+
],
|
| 1149 |
+
[]
|
| 1150 |
+
]
|
| 1151 |
+
},
|
| 1152 |
+
{
|
| 1153 |
+
"label": "m_wd_wd_wd_wd_wd_x",
|
| 1154 |
+
"subs": [
|
| 1155 |
+
[
|
| 1156 |
+
"W",
|
| 1157 |
+
"D"
|
| 1158 |
+
],
|
| 1159 |
+
[
|
| 1160 |
+
"W",
|
| 1161 |
+
"D"
|
| 1162 |
+
],
|
| 1163 |
+
[
|
| 1164 |
+
"W",
|
| 1165 |
+
"D"
|
| 1166 |
+
],
|
| 1167 |
+
[
|
| 1168 |
+
"W",
|
| 1169 |
+
"D"
|
| 1170 |
+
],
|
| 1171 |
+
[
|
| 1172 |
+
"W",
|
| 1173 |
+
"D"
|
| 1174 |
+
],
|
| 1175 |
+
[]
|
| 1176 |
+
]
|
| 1177 |
+
},
|
| 1178 |
+
{
|
| 1179 |
+
"label": "m_x_x_x_w_w_w",
|
| 1180 |
+
"subs": [
|
| 1181 |
+
[],
|
| 1182 |
+
[],
|
| 1183 |
+
[],
|
| 1184 |
+
[
|
| 1185 |
+
"W"
|
| 1186 |
+
],
|
| 1187 |
+
[
|
| 1188 |
+
"W"
|
| 1189 |
+
],
|
| 1190 |
+
[
|
| 1191 |
+
"W"
|
| 1192 |
+
]
|
| 1193 |
+
]
|
| 1194 |
+
},
|
| 1195 |
+
{
|
| 1196 |
+
"label": "m_w_w_x_x_x_x",
|
| 1197 |
+
"subs": [
|
| 1198 |
+
[
|
| 1199 |
+
"W"
|
| 1200 |
+
],
|
| 1201 |
+
[
|
| 1202 |
+
"W"
|
| 1203 |
+
],
|
| 1204 |
+
[],
|
| 1205 |
+
[],
|
| 1206 |
+
[],
|
| 1207 |
+
[]
|
| 1208 |
+
]
|
| 1209 |
+
},
|
| 1210 |
+
{
|
| 1211 |
+
"label": "m_wd_wd_wd_d_d_d",
|
| 1212 |
+
"subs": [
|
| 1213 |
+
[
|
| 1214 |
+
"W",
|
| 1215 |
+
"D"
|
| 1216 |
+
],
|
| 1217 |
+
[
|
| 1218 |
+
"W",
|
| 1219 |
+
"D"
|
| 1220 |
+
],
|
| 1221 |
+
[
|
| 1222 |
+
"W",
|
| 1223 |
+
"D"
|
| 1224 |
+
],
|
| 1225 |
+
[
|
| 1226 |
+
"D"
|
| 1227 |
+
],
|
| 1228 |
+
[
|
| 1229 |
+
"D"
|
| 1230 |
+
],
|
| 1231 |
+
[
|
| 1232 |
+
"D"
|
| 1233 |
+
]
|
| 1234 |
+
]
|
| 1235 |
+
},
|
| 1236 |
+
{
|
| 1237 |
+
"label": "m_wa_wa_wa_a_a_a",
|
| 1238 |
+
"subs": [
|
| 1239 |
+
[
|
| 1240 |
+
"W",
|
| 1241 |
+
"A"
|
| 1242 |
+
],
|
| 1243 |
+
[
|
| 1244 |
+
"W",
|
| 1245 |
+
"A"
|
| 1246 |
+
],
|
| 1247 |
+
[
|
| 1248 |
+
"W",
|
| 1249 |
+
"A"
|
| 1250 |
+
],
|
| 1251 |
+
[
|
| 1252 |
+
"A"
|
| 1253 |
+
],
|
| 1254 |
+
[
|
| 1255 |
+
"A"
|
| 1256 |
+
],
|
| 1257 |
+
[
|
| 1258 |
+
"A"
|
| 1259 |
+
]
|
| 1260 |
+
]
|
| 1261 |
+
},
|
| 1262 |
+
{
|
| 1263 |
+
"label": "m_x_x_x_wd_wd_wd",
|
| 1264 |
+
"subs": [
|
| 1265 |
+
[],
|
| 1266 |
+
[],
|
| 1267 |
+
[],
|
| 1268 |
+
[
|
| 1269 |
+
"W",
|
| 1270 |
+
"D"
|
| 1271 |
+
],
|
| 1272 |
+
[
|
| 1273 |
+
"W",
|
| 1274 |
+
"D"
|
| 1275 |
+
],
|
| 1276 |
+
[
|
| 1277 |
+
"W",
|
| 1278 |
+
"D"
|
| 1279 |
+
]
|
| 1280 |
+
]
|
| 1281 |
+
},
|
| 1282 |
+
{
|
| 1283 |
+
"label": "m_d_d_d_sd_sd_sd",
|
| 1284 |
+
"subs": [
|
| 1285 |
+
[
|
| 1286 |
+
"D"
|
| 1287 |
+
],
|
| 1288 |
+
[
|
| 1289 |
+
"D"
|
| 1290 |
+
],
|
| 1291 |
+
[
|
| 1292 |
+
"D"
|
| 1293 |
+
],
|
| 1294 |
+
[
|
| 1295 |
+
"S",
|
| 1296 |
+
"D"
|
| 1297 |
+
],
|
| 1298 |
+
[
|
| 1299 |
+
"S",
|
| 1300 |
+
"D"
|
| 1301 |
+
],
|
| 1302 |
+
[
|
| 1303 |
+
"S",
|
| 1304 |
+
"D"
|
| 1305 |
+
]
|
| 1306 |
+
]
|
| 1307 |
+
},
|
| 1308 |
+
{
|
| 1309 |
+
"label": "m_w_x_x_x_x_x",
|
| 1310 |
+
"subs": [
|
| 1311 |
+
[
|
| 1312 |
+
"W"
|
| 1313 |
+
],
|
| 1314 |
+
[],
|
| 1315 |
+
[],
|
| 1316 |
+
[],
|
| 1317 |
+
[],
|
| 1318 |
+
[]
|
| 1319 |
+
]
|
| 1320 |
+
},
|
| 1321 |
+
{
|
| 1322 |
+
"label": "m_w_w_w_wa_wa_wa",
|
| 1323 |
+
"subs": [
|
| 1324 |
+
[
|
| 1325 |
+
"W"
|
| 1326 |
+
],
|
| 1327 |
+
[
|
| 1328 |
+
"W"
|
| 1329 |
+
],
|
| 1330 |
+
[
|
| 1331 |
+
"W"
|
| 1332 |
+
],
|
| 1333 |
+
[
|
| 1334 |
+
"W",
|
| 1335 |
+
"A"
|
| 1336 |
+
],
|
| 1337 |
+
[
|
| 1338 |
+
"W",
|
| 1339 |
+
"A"
|
| 1340 |
+
],
|
| 1341 |
+
[
|
| 1342 |
+
"W",
|
| 1343 |
+
"A"
|
| 1344 |
+
]
|
| 1345 |
+
]
|
| 1346 |
+
},
|
| 1347 |
+
{
|
| 1348 |
+
"label": "m_wa_wa_wa_w_w_w",
|
| 1349 |
+
"subs": [
|
| 1350 |
+
[
|
| 1351 |
+
"W",
|
| 1352 |
+
"A"
|
| 1353 |
+
],
|
| 1354 |
+
[
|
| 1355 |
+
"W",
|
| 1356 |
+
"A"
|
| 1357 |
+
],
|
| 1358 |
+
[
|
| 1359 |
+
"W",
|
| 1360 |
+
"A"
|
| 1361 |
+
],
|
| 1362 |
+
[
|
| 1363 |
+
"W"
|
| 1364 |
+
],
|
| 1365 |
+
[
|
| 1366 |
+
"W"
|
| 1367 |
+
],
|
| 1368 |
+
[
|
| 1369 |
+
"W"
|
| 1370 |
+
]
|
| 1371 |
+
]
|
| 1372 |
+
},
|
| 1373 |
+
{
|
| 1374 |
+
"label": "m_sd_sd_s_x_x_x",
|
| 1375 |
+
"subs": [
|
| 1376 |
+
[
|
| 1377 |
+
"S",
|
| 1378 |
+
"D"
|
| 1379 |
+
],
|
| 1380 |
+
[
|
| 1381 |
+
"S",
|
| 1382 |
+
"D"
|
| 1383 |
+
],
|
| 1384 |
+
[
|
| 1385 |
+
"S"
|
| 1386 |
+
],
|
| 1387 |
+
[],
|
| 1388 |
+
[],
|
| 1389 |
+
[]
|
| 1390 |
+
]
|
| 1391 |
+
},
|
| 1392 |
+
{
|
| 1393 |
+
"label": "m_x_x_x_x_x_w",
|
| 1394 |
+
"subs": [
|
| 1395 |
+
[],
|
| 1396 |
+
[],
|
| 1397 |
+
[],
|
| 1398 |
+
[],
|
| 1399 |
+
[],
|
| 1400 |
+
[
|
| 1401 |
+
"W"
|
| 1402 |
+
]
|
| 1403 |
+
]
|
| 1404 |
+
},
|
| 1405 |
+
{
|
| 1406 |
+
"label": "m_x_x_x_x_wa_wa",
|
| 1407 |
+
"subs": [
|
| 1408 |
+
[],
|
| 1409 |
+
[],
|
| 1410 |
+
[],
|
| 1411 |
+
[],
|
| 1412 |
+
[
|
| 1413 |
+
"W",
|
| 1414 |
+
"A"
|
| 1415 |
+
],
|
| 1416 |
+
[
|
| 1417 |
+
"W",
|
| 1418 |
+
"A"
|
| 1419 |
+
]
|
| 1420 |
+
]
|
| 1421 |
+
},
|
| 1422 |
+
{
|
| 1423 |
+
"label": "m_d_d_d_wd_wd_wd",
|
| 1424 |
+
"subs": [
|
| 1425 |
+
[
|
| 1426 |
+
"D"
|
| 1427 |
+
],
|
| 1428 |
+
[
|
| 1429 |
+
"D"
|
| 1430 |
+
],
|
| 1431 |
+
[
|
| 1432 |
+
"D"
|
| 1433 |
+
],
|
| 1434 |
+
[
|
| 1435 |
+
"W",
|
| 1436 |
+
"D"
|
| 1437 |
+
],
|
| 1438 |
+
[
|
| 1439 |
+
"W",
|
| 1440 |
+
"D"
|
| 1441 |
+
],
|
| 1442 |
+
[
|
| 1443 |
+
"W",
|
| 1444 |
+
"D"
|
| 1445 |
+
]
|
| 1446 |
+
]
|
| 1447 |
+
},
|
| 1448 |
+
{
|
| 1449 |
+
"label": "m_a_a_a_as_as_as",
|
| 1450 |
+
"subs": [
|
| 1451 |
+
[
|
| 1452 |
+
"A"
|
| 1453 |
+
],
|
| 1454 |
+
[
|
| 1455 |
+
"A"
|
| 1456 |
+
],
|
| 1457 |
+
[
|
| 1458 |
+
"A"
|
| 1459 |
+
],
|
| 1460 |
+
[
|
| 1461 |
+
"A",
|
| 1462 |
+
"S"
|
| 1463 |
+
],
|
| 1464 |
+
[
|
| 1465 |
+
"A",
|
| 1466 |
+
"S"
|
| 1467 |
+
],
|
| 1468 |
+
[
|
| 1469 |
+
"A",
|
| 1470 |
+
"S"
|
| 1471 |
+
]
|
| 1472 |
+
]
|
| 1473 |
+
},
|
| 1474 |
+
{
|
| 1475 |
+
"label": "m_a_a_a_wa_wa_wa",
|
| 1476 |
+
"subs": [
|
| 1477 |
+
[
|
| 1478 |
+
"A"
|
| 1479 |
+
],
|
| 1480 |
+
[
|
| 1481 |
+
"A"
|
| 1482 |
+
],
|
| 1483 |
+
[
|
| 1484 |
+
"A"
|
| 1485 |
+
],
|
| 1486 |
+
[
|
| 1487 |
+
"W",
|
| 1488 |
+
"A"
|
| 1489 |
+
],
|
| 1490 |
+
[
|
| 1491 |
+
"W",
|
| 1492 |
+
"A"
|
| 1493 |
+
],
|
| 1494 |
+
[
|
| 1495 |
+
"W",
|
| 1496 |
+
"A"
|
| 1497 |
+
]
|
| 1498 |
+
]
|
| 1499 |
+
},
|
| 1500 |
+
{
|
| 1501 |
+
"label": "m_w_w_w_s_s_s",
|
| 1502 |
+
"subs": [
|
| 1503 |
+
[
|
| 1504 |
+
"W"
|
| 1505 |
+
],
|
| 1506 |
+
[
|
| 1507 |
+
"W"
|
| 1508 |
+
],
|
| 1509 |
+
[
|
| 1510 |
+
"W"
|
| 1511 |
+
],
|
| 1512 |
+
[
|
| 1513 |
+
"S"
|
| 1514 |
+
],
|
| 1515 |
+
[
|
| 1516 |
+
"S"
|
| 1517 |
+
],
|
| 1518 |
+
[
|
| 1519 |
+
"S"
|
| 1520 |
+
]
|
| 1521 |
+
]
|
| 1522 |
+
},
|
| 1523 |
+
{
|
| 1524 |
+
"label": "m_wd_wd_wd_w_w_w",
|
| 1525 |
+
"subs": [
|
| 1526 |
+
[
|
| 1527 |
+
"W",
|
| 1528 |
+
"D"
|
| 1529 |
+
],
|
| 1530 |
+
[
|
| 1531 |
+
"W",
|
| 1532 |
+
"D"
|
| 1533 |
+
],
|
| 1534 |
+
[
|
| 1535 |
+
"W",
|
| 1536 |
+
"D"
|
| 1537 |
+
],
|
| 1538 |
+
[
|
| 1539 |
+
"W"
|
| 1540 |
+
],
|
| 1541 |
+
[
|
| 1542 |
+
"W"
|
| 1543 |
+
],
|
| 1544 |
+
[
|
| 1545 |
+
"W"
|
| 1546 |
+
]
|
| 1547 |
+
]
|
| 1548 |
+
},
|
| 1549 |
+
{
|
| 1550 |
+
"label": "m_x_w_x_w_x_w",
|
| 1551 |
+
"subs": [
|
| 1552 |
+
[],
|
| 1553 |
+
[
|
| 1554 |
+
"W"
|
| 1555 |
+
],
|
| 1556 |
+
[],
|
| 1557 |
+
[
|
| 1558 |
+
"W"
|
| 1559 |
+
],
|
| 1560 |
+
[],
|
| 1561 |
+
[
|
| 1562 |
+
"W"
|
| 1563 |
+
]
|
| 1564 |
+
]
|
| 1565 |
+
},
|
| 1566 |
+
{
|
| 1567 |
+
"label": "m_w_w_w_wd_wd_wd",
|
| 1568 |
+
"subs": [
|
| 1569 |
+
[
|
| 1570 |
+
"W"
|
| 1571 |
+
],
|
| 1572 |
+
[
|
| 1573 |
+
"W"
|
| 1574 |
+
],
|
| 1575 |
+
[
|
| 1576 |
+
"W"
|
| 1577 |
+
],
|
| 1578 |
+
[
|
| 1579 |
+
"W",
|
| 1580 |
+
"D"
|
| 1581 |
+
],
|
| 1582 |
+
[
|
| 1583 |
+
"W",
|
| 1584 |
+
"D"
|
| 1585 |
+
],
|
| 1586 |
+
[
|
| 1587 |
+
"W",
|
| 1588 |
+
"D"
|
| 1589 |
+
]
|
| 1590 |
+
]
|
| 1591 |
+
},
|
| 1592 |
+
{
|
| 1593 |
+
"label": "m_x_x_x_x_s_s",
|
| 1594 |
+
"subs": [
|
| 1595 |
+
[],
|
| 1596 |
+
[],
|
| 1597 |
+
[],
|
| 1598 |
+
[],
|
| 1599 |
+
[
|
| 1600 |
+
"S"
|
| 1601 |
+
],
|
| 1602 |
+
[
|
| 1603 |
+
"S"
|
| 1604 |
+
]
|
| 1605 |
+
]
|
| 1606 |
+
},
|
| 1607 |
+
{
|
| 1608 |
+
"label": "m_s_s_s_x_x_x",
|
| 1609 |
+
"subs": [
|
| 1610 |
+
[
|
| 1611 |
+
"S"
|
| 1612 |
+
],
|
| 1613 |
+
[
|
| 1614 |
+
"S"
|
| 1615 |
+
],
|
| 1616 |
+
[
|
| 1617 |
+
"S"
|
| 1618 |
+
],
|
| 1619 |
+
[],
|
| 1620 |
+
[],
|
| 1621 |
+
[]
|
| 1622 |
+
]
|
| 1623 |
+
},
|
| 1624 |
+
{
|
| 1625 |
+
"label": "m_x_x_wa_wa_wa_wa",
|
| 1626 |
+
"subs": [
|
| 1627 |
+
[],
|
| 1628 |
+
[],
|
| 1629 |
+
[
|
| 1630 |
+
"W",
|
| 1631 |
+
"A"
|
| 1632 |
+
],
|
| 1633 |
+
[
|
| 1634 |
+
"W",
|
| 1635 |
+
"A"
|
| 1636 |
+
],
|
| 1637 |
+
[
|
| 1638 |
+
"W",
|
| 1639 |
+
"A"
|
| 1640 |
+
],
|
| 1641 |
+
[
|
| 1642 |
+
"W",
|
| 1643 |
+
"A"
|
| 1644 |
+
]
|
| 1645 |
+
]
|
| 1646 |
+
},
|
| 1647 |
+
{
|
| 1648 |
+
"label": "m_w_x_w_x_w_x",
|
| 1649 |
+
"subs": [
|
| 1650 |
+
[
|
| 1651 |
+
"W"
|
| 1652 |
+
],
|
| 1653 |
+
[],
|
| 1654 |
+
[
|
| 1655 |
+
"W"
|
| 1656 |
+
],
|
| 1657 |
+
[],
|
| 1658 |
+
[
|
| 1659 |
+
"W"
|
| 1660 |
+
],
|
| 1661 |
+
[]
|
| 1662 |
+
]
|
| 1663 |
+
},
|
| 1664 |
+
{
|
| 1665 |
+
"label": "m_s_s_s_sd_sd_sd",
|
| 1666 |
+
"subs": [
|
| 1667 |
+
[
|
| 1668 |
+
"S"
|
| 1669 |
+
],
|
| 1670 |
+
[
|
| 1671 |
+
"S"
|
| 1672 |
+
],
|
| 1673 |
+
[
|
| 1674 |
+
"S"
|
| 1675 |
+
],
|
| 1676 |
+
[
|
| 1677 |
+
"S",
|
| 1678 |
+
"D"
|
| 1679 |
+
],
|
| 1680 |
+
[
|
| 1681 |
+
"S",
|
| 1682 |
+
"D"
|
| 1683 |
+
],
|
| 1684 |
+
[
|
| 1685 |
+
"S",
|
| 1686 |
+
"D"
|
| 1687 |
+
]
|
| 1688 |
+
]
|
| 1689 |
+
},
|
| 1690 |
+
{
|
| 1691 |
+
"label": "m_x_x_w_w_w_w",
|
| 1692 |
+
"subs": [
|
| 1693 |
+
[],
|
| 1694 |
+
[],
|
| 1695 |
+
[
|
| 1696 |
+
"W"
|
| 1697 |
+
],
|
| 1698 |
+
[
|
| 1699 |
+
"W"
|
| 1700 |
+
],
|
| 1701 |
+
[
|
| 1702 |
+
"W"
|
| 1703 |
+
],
|
| 1704 |
+
[
|
| 1705 |
+
"W"
|
| 1706 |
+
]
|
| 1707 |
+
]
|
| 1708 |
+
},
|
| 1709 |
+
{
|
| 1710 |
+
"label": "m_sd_sd_sd_d_d_d",
|
| 1711 |
+
"subs": [
|
| 1712 |
+
[
|
| 1713 |
+
"S",
|
| 1714 |
+
"D"
|
| 1715 |
+
],
|
| 1716 |
+
[
|
| 1717 |
+
"S",
|
| 1718 |
+
"D"
|
| 1719 |
+
],
|
| 1720 |
+
[
|
| 1721 |
+
"S",
|
| 1722 |
+
"D"
|
| 1723 |
+
],
|
| 1724 |
+
[
|
| 1725 |
+
"D"
|
| 1726 |
+
],
|
| 1727 |
+
[
|
| 1728 |
+
"D"
|
| 1729 |
+
],
|
| 1730 |
+
[
|
| 1731 |
+
"D"
|
| 1732 |
+
]
|
| 1733 |
+
]
|
| 1734 |
+
},
|
| 1735 |
+
{
|
| 1736 |
+
"label": "m_x_x_x_x_wd_wd",
|
| 1737 |
+
"subs": [
|
| 1738 |
+
[],
|
| 1739 |
+
[],
|
| 1740 |
+
[],
|
| 1741 |
+
[],
|
| 1742 |
+
[
|
| 1743 |
+
"W",
|
| 1744 |
+
"D"
|
| 1745 |
+
],
|
| 1746 |
+
[
|
| 1747 |
+
"W",
|
| 1748 |
+
"D"
|
| 1749 |
+
]
|
| 1750 |
+
]
|
| 1751 |
+
},
|
| 1752 |
+
{
|
| 1753 |
+
"label": "m_x_x_x_x_w_w",
|
| 1754 |
+
"subs": [
|
| 1755 |
+
[],
|
| 1756 |
+
[],
|
| 1757 |
+
[],
|
| 1758 |
+
[],
|
| 1759 |
+
[
|
| 1760 |
+
"W"
|
| 1761 |
+
],
|
| 1762 |
+
[
|
| 1763 |
+
"W"
|
| 1764 |
+
]
|
| 1765 |
+
]
|
| 1766 |
+
},
|
| 1767 |
+
{
|
| 1768 |
+
"label": "m_x_w_w_w_w_w",
|
| 1769 |
+
"subs": [
|
| 1770 |
+
[],
|
| 1771 |
+
[
|
| 1772 |
+
"W"
|
| 1773 |
+
],
|
| 1774 |
+
[
|
| 1775 |
+
"W"
|
| 1776 |
+
],
|
| 1777 |
+
[
|
| 1778 |
+
"W"
|
| 1779 |
+
],
|
| 1780 |
+
[
|
| 1781 |
+
"W"
|
| 1782 |
+
],
|
| 1783 |
+
[
|
| 1784 |
+
"W"
|
| 1785 |
+
]
|
| 1786 |
+
]
|
| 1787 |
+
},
|
| 1788 |
+
{
|
| 1789 |
+
"label": "m_w_w_w_x_x_x",
|
| 1790 |
+
"subs": [
|
| 1791 |
+
[
|
| 1792 |
+
"W"
|
| 1793 |
+
],
|
| 1794 |
+
[
|
| 1795 |
+
"W"
|
| 1796 |
+
],
|
| 1797 |
+
[
|
| 1798 |
+
"W"
|
| 1799 |
+
],
|
| 1800 |
+
[],
|
| 1801 |
+
[],
|
| 1802 |
+
[]
|
| 1803 |
+
]
|
| 1804 |
+
},
|
| 1805 |
+
{
|
| 1806 |
+
"label": "m_x_x_wd_wd_wd_wd",
|
| 1807 |
+
"subs": [
|
| 1808 |
+
[],
|
| 1809 |
+
[],
|
| 1810 |
+
[
|
| 1811 |
+
"W",
|
| 1812 |
+
"D"
|
| 1813 |
+
],
|
| 1814 |
+
[
|
| 1815 |
+
"W",
|
| 1816 |
+
"D"
|
| 1817 |
+
],
|
| 1818 |
+
[
|
| 1819 |
+
"W",
|
| 1820 |
+
"D"
|
| 1821 |
+
],
|
| 1822 |
+
[
|
| 1823 |
+
"W",
|
| 1824 |
+
"D"
|
| 1825 |
+
]
|
| 1826 |
+
]
|
| 1827 |
+
},
|
| 1828 |
+
{
|
| 1829 |
+
"label": "m_wa_wa_x_x_x_x",
|
| 1830 |
+
"subs": [
|
| 1831 |
+
[
|
| 1832 |
+
"W",
|
| 1833 |
+
"A"
|
| 1834 |
+
],
|
| 1835 |
+
[
|
| 1836 |
+
"W",
|
| 1837 |
+
"A"
|
| 1838 |
+
],
|
| 1839 |
+
[],
|
| 1840 |
+
[],
|
| 1841 |
+
[],
|
| 1842 |
+
[]
|
| 1843 |
+
]
|
| 1844 |
+
}
|
| 1845 |
+
]
|
| 1846 |
+
},
|
| 1847 |
+
{
|
| 1848 |
+
"name": "action",
|
| 1849 |
+
"options": [
|
| 1850 |
+
{
|
| 1851 |
+
"label": "none"
|
| 1852 |
+
},
|
| 1853 |
+
{
|
| 1854 |
+
"label": "punch_s1",
|
| 1855 |
+
"subs": [
|
| 1856 |
+
[
|
| 1857 |
+
"J"
|
| 1858 |
+
],
|
| 1859 |
+
[],
|
| 1860 |
+
[],
|
| 1861 |
+
[],
|
| 1862 |
+
[],
|
| 1863 |
+
[]
|
| 1864 |
+
]
|
| 1865 |
+
},
|
| 1866 |
+
{
|
| 1867 |
+
"label": "punch_s2",
|
| 1868 |
+
"subs": [
|
| 1869 |
+
[],
|
| 1870 |
+
[
|
| 1871 |
+
"J"
|
| 1872 |
+
],
|
| 1873 |
+
[],
|
| 1874 |
+
[],
|
| 1875 |
+
[],
|
| 1876 |
+
[]
|
| 1877 |
+
]
|
| 1878 |
+
},
|
| 1879 |
+
{
|
| 1880 |
+
"label": "punch_s3",
|
| 1881 |
+
"subs": [
|
| 1882 |
+
[],
|
| 1883 |
+
[],
|
| 1884 |
+
[
|
| 1885 |
+
"J"
|
| 1886 |
+
],
|
| 1887 |
+
[],
|
| 1888 |
+
[],
|
| 1889 |
+
[]
|
| 1890 |
+
]
|
| 1891 |
+
},
|
| 1892 |
+
{
|
| 1893 |
+
"label": "punch_s4",
|
| 1894 |
+
"subs": [
|
| 1895 |
+
[],
|
| 1896 |
+
[],
|
| 1897 |
+
[],
|
| 1898 |
+
[
|
| 1899 |
+
"J"
|
| 1900 |
+
],
|
| 1901 |
+
[],
|
| 1902 |
+
[]
|
| 1903 |
+
]
|
| 1904 |
+
},
|
| 1905 |
+
{
|
| 1906 |
+
"label": "punch_s5",
|
| 1907 |
+
"subs": [
|
| 1908 |
+
[],
|
| 1909 |
+
[],
|
| 1910 |
+
[],
|
| 1911 |
+
[],
|
| 1912 |
+
[
|
| 1913 |
+
"J"
|
| 1914 |
+
],
|
| 1915 |
+
[]
|
| 1916 |
+
]
|
| 1917 |
+
},
|
| 1918 |
+
{
|
| 1919 |
+
"label": "punch_s6",
|
| 1920 |
+
"subs": [
|
| 1921 |
+
[],
|
| 1922 |
+
[],
|
| 1923 |
+
[],
|
| 1924 |
+
[],
|
| 1925 |
+
[],
|
| 1926 |
+
[
|
| 1927 |
+
"J"
|
| 1928 |
+
]
|
| 1929 |
+
]
|
| 1930 |
+
},
|
| 1931 |
+
{
|
| 1932 |
+
"label": "jump_hold",
|
| 1933 |
+
"keys": [
|
| 1934 |
+
"Space"
|
| 1935 |
+
]
|
| 1936 |
+
},
|
| 1937 |
+
{
|
| 1938 |
+
"label": "jump_pound_s2",
|
| 1939 |
+
"subs": [
|
| 1940 |
+
[
|
| 1941 |
+
"Space"
|
| 1942 |
+
],
|
| 1943 |
+
[
|
| 1944 |
+
"Shift"
|
| 1945 |
+
],
|
| 1946 |
+
[],
|
| 1947 |
+
[],
|
| 1948 |
+
[],
|
| 1949 |
+
[]
|
| 1950 |
+
]
|
| 1951 |
+
},
|
| 1952 |
+
{
|
| 1953 |
+
"label": "jump_pound_s3",
|
| 1954 |
+
"subs": [
|
| 1955 |
+
[
|
| 1956 |
+
"Space"
|
| 1957 |
+
],
|
| 1958 |
+
[
|
| 1959 |
+
"Space"
|
| 1960 |
+
],
|
| 1961 |
+
[
|
| 1962 |
+
"Shift"
|
| 1963 |
+
],
|
| 1964 |
+
[],
|
| 1965 |
+
[],
|
| 1966 |
+
[]
|
| 1967 |
+
]
|
| 1968 |
+
},
|
| 1969 |
+
{
|
| 1970 |
+
"label": "jump_short",
|
| 1971 |
+
"subs": [
|
| 1972 |
+
[
|
| 1973 |
+
"Space"
|
| 1974 |
+
],
|
| 1975 |
+
[
|
| 1976 |
+
"Space"
|
| 1977 |
+
],
|
| 1978 |
+
[],
|
| 1979 |
+
[],
|
| 1980 |
+
[],
|
| 1981 |
+
[]
|
| 1982 |
+
]
|
| 1983 |
+
}
|
| 1984 |
+
]
|
| 1985 |
+
}
|
| 1986 |
+
]
|
| 1987 |
+
}
|
environments/games/web/games/mario64_remake/draw.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* HUD for the Super Mario 64 boss trials, drawn over the WebGL frame: SM64-style 8-wedge power meter, boss hits,
|
| 2 |
+
* timer, native Hz and tier. Reads state only. */
|
| 3 |
+
(function(root){
|
| 4 |
+
'use strict';const M=root.Mario64Game,R=root.Mario3D;
|
| 5 |
+
const NAMES={whomp:['Toppling Slab','TOPPLING SLAB'],king:['Grappler Orb','GRAPPLER ORB'],bully:['Horned Rammer','HORNED RAMMER'],eyerok:['Twin Sandstone Fists','TWIN SANDSTONE FISTS'],wiggler:['Frenzy Crawler','FRENZY CRAWLER'],bowser:['Fire Shell Beast','FIRE SHELL BEAST']};
|
| 6 |
+
const ACT={idle:'Idle',walking:'Running',decel:'Slowing down',braking:'Braking',turnaround:'Quick turn',jump:'jump',double:'Double jump',triple:'Triple jump',backflip:'Backflip',
|
| 7 |
+
sideflip:'Side flip',longjump:'Long jump',freefall:'Falling',dive:'Pounce',diveslide:'Dive slide',divestop:'Rise up',jumpkick:'Jump kick',slidekick:'Slide kick',slidekickslide:'Sliding',
|
| 8 |
+
rollout:'Rolling up',gp:'Ground pound',gpLand:'Ground pound landing',crouchIn:'Crouching',crouch:'Crouched',crouchOut:'Rise up',crouchslide:'Crouch slide',punching:'Punching',movepunch:'Punching',
|
| 9 |
+
pickup:'Picking up',hold:'Holding',holdwalk:'Walking while holding',heavythrow:'Throwing',land:'Landing',kb:'Knocked back',airkb:'Launched',thrown:'Thrown',grabbed:'Grabbed',
|
| 10 |
+
grabbowser:'Tail grabbed',swing:'Swinging',release:'Released',shockwave:'Stunned by shockwave',burnjump:'Burning',burnfall:'Burning',burnground:'Burning',squished:'Squashed',lava:'Burned by lava',dead:'Down'};
|
| 11 |
+
function text(c,s,x,y,size,color,align='left',weight='bold'){c.font=`${weight} ${size}px "Segoe UI","Microsoft YaHei",sans-serif`;c.textAlign=align;c.lineJoin='round';
|
| 12 |
+
c.lineWidth=Math.max(3,size/4.5);c.strokeStyle='rgba(12,14,40,.88)';c.strokeText(s,x,y);c.fillStyle=color;c.fillText(s,x,y);}
|
| 13 |
+
// The SM64 power meter: eight wedges, coloured by how many remain (blue / green / yellow / red).
|
| 14 |
+
function power(c,x,y,r,health){const units=Math.max(0,Math.min(8,health/256)),whole=Math.floor(units+1e-6),col=whole>=7?'#3fa8ff':whole>=5?'#3cd25a':whole>=3?'#f2c230':'#ef3b2e';
|
| 15 |
+
c.save();c.beginPath();c.arc(x,y,r+5,0,Math.PI*2);c.fillStyle='rgba(18,22,60,.85)';c.fill();c.lineWidth=3;c.strokeStyle='#f6f2e6';c.stroke();
|
| 16 |
+
for(let i=0;i<8;i++){const a0=-Math.PI/2+i*Math.PI/4,a1=a0+Math.PI/4-.06;c.beginPath();c.moveTo(x,y);c.arc(x,y,r,a0,a1);c.closePath();
|
| 17 |
+
c.fillStyle=i<whole?col:i<units?'rgba(255,255,255,.35)':'rgba(70,74,110,.55)';c.fill();}
|
| 18 |
+
c.beginPath();c.arc(x,y,r*.42,0,Math.PI*2);c.fillStyle='rgba(18,22,60,.95)';c.fill();text(c,String(whole),x,y+7,20,'#fff','center');c.restore();}
|
| 19 |
+
function pips(c,x,y,n,max,kind){if(max>12){const w=230;c.fillStyle='rgba(18,22,60,.8)';c.fillRect(x-w/2,y-9,w,14);c.fillStyle=kind==='bully'?'#ff8a2a':'#ffd23a';c.fillRect(x-w/2+2,y-7,(w-4)*n/max,10);
|
| 20 |
+
c.strokeStyle='#f6f2e6';c.lineWidth=1.5;c.strokeRect(x-w/2,y-9,w,14);text(c,`${n} / ${max}`,x,y+22,13,'#fff','center');return;}
|
| 21 |
+
const gap=22,x0=x-(max-1)*gap/2;for(let i=0;i<max;i++){const cx=x0+i*gap;c.save();c.translate(cx,y);c.beginPath();
|
| 22 |
+
for(let k=0;k<10;k++){const a=-Math.PI/2+k*Math.PI/5,rr=k%2?4.2:9.5;c.lineTo(Math.cos(a)*rr,Math.sin(a)*rr);}c.closePath();
|
| 23 |
+
c.fillStyle=i<n?(kind==='bully'?'#ff8a2a':'#ffd23a'):'rgba(70,74,110,.7)';c.fill();c.lineWidth=1.6;c.strokeStyle='rgba(12,14,40,.9)';c.stroke();c.restore();}}
|
| 24 |
+
function tierName(d){for(const [k,v] of Object.entries(M.tiers))if(Math.abs(v-d)<1e-9)return k;return 'd='+(+d).toFixed(2);}
|
| 25 |
+
M.draw=function(g,c){R.render(g,c);const m=g.mario,b=g.boss,[cn,en]=NAMES[b.kind],h=g.health();
|
| 26 |
+
power(c,58,60,30,m.health);text(c,'HP',58,112,12,'#f6f2e6','center');text(c,ACT[m.action]||m.action,100,52,16,'#fff');
|
| 27 |
+
if(m.holding&&b.kind==='king')text(c,'Holding opponent: press J to throw',100,74,13,'#ffe9a8');
|
| 28 |
+
text(c,`${cn} ${en}`,427,30,19,'#fff6d8','center');pips(c,427,52,h[2],h[3],b.kind);
|
| 29 |
+
const s=g.t/M.hz,mm=Math.floor(s/60),ss=(s%60).toFixed(1).padStart(4,'0');text(c,`${mm}:${ss}`,830,32,20,'#fff','right');
|
| 30 |
+
text(c,`${M.hz}Hz`,830,54,14,'#9fe7ff','right');text(c,tierName(g.d).toUpperCase(),830,74,13,'#ffd23a','right');
|
| 31 |
+
if(b.kind==='king'&&m.action==='grabbed')text(c,`Grabbed! Tap Space to escape ${Math.min(b.escape,g.T.escape+1)}/${g.T.escape+1}`,427,150,20,'#ffe9a8','center');
|
| 32 |
+
if(b.kind==='bowser'&&m.holding)text(c,`Circle the arrow keys to swing (speed ${Math.round(Math.abs(m.swing)/40.96)}%); press J toward a mine to throw`,427,150,18,'#ffe9a8','center');
|
| 33 |
+
else if(b.kind==='bowser'&&b.hp>0&&b.guard>0&&b.act!=='hitmine')text(c,'He just got up. His dim tail cannot be grabbed yet; keep your distance.',427,150,15,'#fff3c4','center','600');
|
| 34 |
+
else if(b.kind==='bowser'&&b.hp>0&&b.act==='walk')text(c,'Get behind him and press J near his tail to grab it.',427,150,15,'#fff3c4','center','600');
|
| 35 |
+
if(b.kind==='bowser')text(c,`Mines ${b.mines.filter(q=>q.alive).length} / 4`,427,96,14,'#ffb0a0','center');
|
| 36 |
+
if(m.action==='squished')text(c,'Squashed!',427,150,26,'#ffd0c0','center');
|
| 37 |
+
if(b.kind==='whomp'&&b.act==='ground'&&b.sub===0&&m.action!=='squished')text(c,'Exposed back! Jump up and ground pound with Shift.',427,150,15,'#fff3c4','center','600');
|
| 38 |
+
if(b.kind==='eyerok'&&b.hands.some(q=>q.act==='eye')&&m.action!=='squished')text(c,'Eye open! Face the palm and punch with J.',427,150,15,'#fff3c4','center','600');
|
| 39 |
+
if(b.kind==='wiggler'&&b.act==='walk'&&b.intro===0&&b.timer<60&&b.hp<b.maxHp&&m.action!=='squished')text(c,'He just got up and cannot be stomped yet. Keep clear.',427,150,15,'#fff3c4','center','600');
|
| 40 |
+
if(g.outcome==='win')text(c,'★ VICTORY!',427,226,44,'#ffe24a','center');
|
| 41 |
+
if(g.outcome==='loss')text(c,'GAME OVER',427,226,44,'#ff6b5b','center');
|
| 42 |
+
if(g.outcome==='timeout')text(c,'TIME UP',427,226,44,'#ffd0c0','center');
|
| 43 |
+
text(c,`Follow camera ${Math.round(((g.cam.offset*180/Math.PI)%360+360)%360)}°`,22,462,12,'#d8e8ff');
|
| 44 |
+
text(c,'WASD Move Space Jump Shift Crouch/Ground pound J Punch/Grab/Throw Q·E Rotate camera',832,462,12,'#d8e8ff','right','600');};
|
| 45 |
+
M.renderStatus=ctx=>R.status(ctx);M.renderMetrics=ctx=>R.metrics(ctx);M.closeRenderer=ctx=>R.close(ctx);
|
| 46 |
+
})(window);
|
environments/games/web/games/mario64_remake/game.js
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
environments/games/web/games/mario64_remake/index.html
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="data:,"><title>Super Mario 64 · Boss Challenges</title><link rel="stylesheet" href="style3d.css"></head><body><main>
|
| 2 |
+
<header><div><div class="eyebrow">Super Mario 64 · 1996 · Boss Trials</div><h1>Super Mario 64 · Boss Challenges</h1><p>Face Whomp King, King Bob-omb, Big Bully, Eyerok, Wiggler, and Bowser. Triple jump, ground pound, grab and throw, knock foes into lava, strike exposed palms, stomp heads, and swing Bowser into mines. Mechanics follow the public SM64 decompilation; the low-poly art is original.</p></div><a href="../../index.html">Back to Game Lobby ↗</a></header>
|
| 3 |
+
<div class="layout"><section><div class="stage"><canvas width="854" height="480" tabindex="0" aria-label="Super Mario 64 3D boss battle screen"></canvas><div id="overlay"><div><strong>Are You Ready?</strong><span>Click Start Challenge</span></div></div><div class="toolbar"><button id="start" class="primary">Start Challenge / Restart</button><button id="pause">Resume</button><button id="step">Step</button><button id="demo">Scripted Demo</button><button id="sample">Winning Replay</button></div></div>
|
| 4 |
+
<div class="mobile"><button data-key="W">↑</button><button data-key="A">←</button><button data-key="S">↓</button><button data-key="D">→</button><button data-key="Space">Jump A</button><button data-key="J">Punch B</button><button data-key="Shift">Crouch Z</button><button data-key="Q">Camera ◀</button><button data-key="E">Camera ▶</button><button data-key="R">Reset camera</button></div><p id="status" role="status"></p><div class="toolbar record-toolbar"><button id="export">Export Current Replay</button><button id="import">Import and Replay</button><input id="file" type="file" accept=".json,application/json"></div><p class="note">The scripted demo reads internal state to verify each fight can be completed. Replays save real inputs, reproduce the entire fight, and verify the final state.</p></section>
|
| 5 |
+
<aside><div><h2>Challenge Settings</h2><label for="case">Boss</label><select id="case"></select><label for="seed">Seed</label><input id="seed" type="number" min="0" max="4294967295" step="1" value="1"></div><div><label for="difficulty">Difficulty Tier</label><select id="difficulty"><option value="0.2">Easy</option><option value="0.5" selected>Normal</option><option value="0.8">Hard</option></select><p class="note">Click the screen to enable keyboard and mouse controls; Esc pauses. Drag with the mouse or double-click to lock the pointer and freely rotate the follow camera. Q/E rotate 45°; R resets the camera.</p></div><dl></dl></aside></div>
|
| 6 |
+
<footer></footer></main>
|
| 7 |
+
<script src="../_native/runtime.js"></script><script src="../_boss3d/vendor/three.min.js"></script><script src="renderer3d.js"></script><script src="game.js"></script><script src="draw.js"></script><script>window.GAME_MODULE=Mario64Game;</script><script src="app3d.js"></script></body></html>
|
environments/games/web/games/mario64_remake/manifest.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema": "bossbench/game-manifest@1",
|
| 3 |
+
"engine": "independent",
|
| 4 |
+
"game": "mario64_remake",
|
| 5 |
+
"module": "Mario64Game",
|
| 6 |
+
"title": "Super Mario 64: Boss Challenges",
|
| 7 |
+
"dimension": "3d",
|
| 8 |
+
"native_hz": 60,
|
| 9 |
+
"max_seconds": 300,
|
| 10 |
+
"renderer": "webgl-mario64",
|
| 11 |
+
"rules": "sm64-bosses@5",
|
| 12 |
+
"cases": [
|
| 13 |
+
"mario64/whomp_king",
|
| 14 |
+
"mario64/king_bobomb",
|
| 15 |
+
"mario64/big_bully",
|
| 16 |
+
"mario64/eyerok",
|
| 17 |
+
"mario64/wiggler",
|
| 18 |
+
"mario64/bowser_dark_world"
|
| 19 |
+
],
|
| 20 |
+
"scripts": [
|
| 21 |
+
"_native/runtime.js",
|
| 22 |
+
"_boss3d/vendor/three.min.js",
|
| 23 |
+
"mario64_remake/renderer3d.js",
|
| 24 |
+
"mario64_remake/game.js",
|
| 25 |
+
"mario64_remake/draw.js"
|
| 26 |
+
],
|
| 27 |
+
"sim_scripts": [
|
| 28 |
+
"_native/runtime.js",
|
| 29 |
+
"mario64_remake/game.js"
|
| 30 |
+
],
|
| 31 |
+
"play_page": "web/games/mario64_remake/index.html",
|
| 32 |
+
"original_clock": "SM64 logic runs at 30 Hz (n64decomp/sm64 src/game/hud.c: 30 frames per second); this port runs 60 Hz, two ticks per original frame",
|
| 33 |
+
"scripted_controller": "Mario64Game.scripted(game) -> {holds:[6 key arrays], mouse:[0,0,0]} (plans on deep copies, deterministic; .oracle is an alias)"
|
| 34 |
+
}
|
environments/games/web/games/mario64_remake/renderer3d.js
ADDED
|
@@ -0,0 +1,387 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Original low-poly, N64-flavoured art for the Super Mario 64 boss trials. Three.js 0.160.1 is the vendored shared copy
|
| 2 |
+
* (MIT, web/games/_boss3d/vendor, read-only). Every mesh and texture below is built procedurally in this file; no
|
| 3 |
+
* Nintendo model, texture or sound is used (ASSET_RIGHTS.md). Rendering only reads game state: the Lakitu camera,
|
| 4 |
+
* every pose clock and every effect come from the simulation, so a frame is a pure function of the state. */
|
| 5 |
+
(function(root){
|
| 6 |
+
'use strict';
|
| 7 |
+
const T=root.THREE,R=root.Mario3D={};
|
| 8 |
+
if(!T)throw Error('Offline Three.js renderer library is missing');
|
| 9 |
+
const U=.01,byCanvas=new WeakMap(),clamp=(x,a,b)=>Math.max(a,Math.min(b,x)),items=a=>Array.isArray(a)?a:[],PI=Math.PI;
|
| 10 |
+
function hash(x,y,s){let n=Math.imul(x*73856093^y*19349663^s*83492791,1274126177);n^=n>>>15;n=Math.imul(n,2246822519);return ((n^(n>>>13))>>>0)/4294967295;}
|
| 11 |
+
function canvasTex(w,h,draw,repeat){const c=document.createElement('canvas');c.width=w;c.height=h;draw(c.getContext('2d'),w,h);
|
| 12 |
+
const t=new T.CanvasTexture(c);t.colorSpace=T.SRGBColorSpace;if(repeat){t.wrapS=t.wrapT=T.RepeatWrapping;t.repeat.set(repeat[0],repeat[1]);}return t;}
|
| 13 |
+
const rgb=(r,g,b)=>`rgb(${r|0},${g|0},${b|0})`;
|
| 14 |
+
// Stone tiles: blocks with per-block brightness and a mortar line (Whomp's Fortress, the Bully platform).
|
| 15 |
+
function tiles(q,w,h,base,mortar,cols,rows,seed,offset=true){q.fillStyle=mortar;q.fillRect(0,0,w,h);const bw=w/cols,bh=h/rows;
|
| 16 |
+
for(let j=0;j<rows;j++)for(let i=0;i<cols+1;i++){const x=(i-(offset&&j%2?.5:0))*bw,v=.84+hash(i,j,seed)*.3;q.fillStyle=rgb(base[0]*v,base[1]*v,base[2]*v);q.fillRect(x+2,j*bh+2,bw-4,bh-4);
|
| 17 |
+
q.fillStyle='rgba(255,255,255,.10)';q.fillRect(x+2,j*bh+2,bw-4,3);q.fillStyle='rgba(0,0,0,.12)';q.fillRect(x+2,j*bh+bh-5,bw-4,3);}}
|
| 18 |
+
function speckle(q,w,h,n,seed,a,b){for(let i=0;i<n;i++){q.fillStyle=hash(i,1,seed)<.5?a:b;q.fillRect(hash(i,2,seed)*w,hash(i,3,seed)*h,1+hash(i,4,seed)*3,1+hash(i,5,seed)*3);}}
|
| 19 |
+
const TEX={
|
| 20 |
+
brick:()=>canvasTex(256,256,(q,w,h)=>{tiles(q,w,h,[206,190,160],'#8e806a',4,8,3);speckle(q,w,h,700,4,'rgba(80,60,40,.18)','rgba(255,255,240,.16)');},[9,9]),
|
| 21 |
+
wall:()=>canvasTex(256,256,(q,w,h)=>{tiles(q,w,h,[176,160,132],'#776a57',4,8,9);speckle(q,w,h,500,5,'rgba(60,50,40,.2)','rgba(255,250,230,.1)');},[9,4]),
|
| 22 |
+
grass:()=>canvasTex(256,256,(q,w,h)=>{q.fillStyle='#4f9a33';q.fillRect(0,0,w,h);speckle(q,w,h,2600,7,'#3f8628','#69b443');
|
| 23 |
+
for(let i=0;i<220;i++){const x=hash(i,8,7)*w,y=hash(i,9,7)*h;q.strokeStyle=hash(i,10,7)<.5?'#2f6e1f':'#7cc452';q.beginPath();q.moveTo(x,y);q.lineTo(x+2-hash(i,11,7)*4,y-4-hash(i,12,7)*5);q.stroke();}},[14,14]),
|
| 24 |
+
slope:()=>canvasTex(128,256,(q,w,h)=>{const g=q.createLinearGradient(0,0,0,h);g.addColorStop(0,'#4c8e31');g.addColorStop(.35,'#6f6a3c');g.addColorStop(1,'#5b4b33');q.fillStyle=g;q.fillRect(0,0,w,h);
|
| 25 |
+
speckle(q,w,h,1400,13,'rgba(40,30,20,.25)','rgba(255,240,200,.12)');for(let y=30;y<h;y+=34){q.fillStyle='rgba(60,45,30,.35)';q.fillRect(0,y,w,4);}},[10,1]),
|
| 26 |
+
grate:()=>canvasTex(256,256,(q,w,h)=>{tiles(q,w,h,[132,124,118],'#3e3533',4,4,21,false);
|
| 27 |
+
q.strokeStyle='rgba(30,24,22,.55)';q.lineWidth=3;for(let i=0;i<=4;i++){q.beginPath();q.moveTo(i*w/4,0);q.lineTo(i*w/4,h);q.stroke();q.beginPath();q.moveTo(0,i*h/4);q.lineTo(w,i*h/4);q.stroke();}
|
| 28 |
+
for(let i=0;i<4;i++)for(let j=0;j<4;j++){q.fillStyle='#d9cfc3';q.beginPath();q.arc(i*w/4+10,j*h/4+10,3,0,PI*2);q.fill();}},[6,6]),
|
| 29 |
+
lava:()=>canvasTex(256,256,(q,w,h)=>{q.fillStyle='#a3200c';q.fillRect(0,0,w,h);
|
| 30 |
+
for(let i=0;i<150;i++){const x=hash(i,1,31)*w,y=hash(i,2,31)*h,r=4+hash(i,3,31)*18;const g=q.createRadialGradient(x,y,0,x,y,r);g.addColorStop(0,'rgba(255,214,90,.95)');g.addColorStop(.5,'rgba(255,120,30,.55)');g.addColorStop(1,'rgba(255,80,10,0)');
|
| 31 |
+
for(const ox of [-w,0,w])for(const oy of [-h,0,h]){q.fillStyle=g;q.save();q.translate(ox,oy);q.beginPath();q.arc(x,y,r,0,PI*2);q.fill();q.restore();}}
|
| 32 |
+
speckle(q,w,h,600,33,'rgba(80,10,0,.35)','rgba(255,240,150,.25)');},[24,24]),
|
| 33 |
+
sand:()=>canvasTex(256,256,(q,w,h)=>{tiles(q,w,h,[214,178,112],'#9a7a48',4,4,71);speckle(q,w,h,1200,72,'rgba(90,60,20,.2)','rgba(255,240,190,.18)');},[8,8]),
|
| 34 |
+
stone:()=>canvasTex(128,128,(q,w,h)=>{q.fillStyle='#a9a8a2';q.fillRect(0,0,w,h);speckle(q,w,h,900,41,'rgba(70,70,70,.28)','rgba(255,255,255,.18)');
|
| 35 |
+
q.strokeStyle='rgba(60,60,60,.35)';for(let i=0;i<5;i++){q.beginPath();const x=hash(i,1,42)*w,y=hash(i,2,42)*h;q.moveTo(x,y);q.lineTo(x+10-hash(i,3,42)*20,y+12);q.lineTo(x+18-hash(i,4,42)*30,y+26);q.stroke();}},[1,1]),
|
| 36 |
+
face:()=>canvasTex(256,320,(q,w,h)=>{q.fillStyle='#b3b1aa';q.fillRect(0,0,w,h);speckle(q,w,h,1500,51,'rgba(70,70,70,.25)','rgba(255,255,255,.16)');
|
| 37 |
+
for(const s of [-1,1]){const cx=w/2+s*58,cy=88;q.fillStyle='#fafaf2';q.beginPath();q.ellipse(cx,cy,34,40,0,0,PI*2);q.fill();q.strokeStyle='#2c2b2a';q.lineWidth=5;q.stroke();
|
| 38 |
+
q.fillStyle='#1d1c1c';q.beginPath();q.ellipse(cx-s*6,cy+6,13,18,0,0,PI*2);q.fill();q.fillStyle='#fff';q.fillRect(cx-s*6-4,cy-4,5,6);
|
| 39 |
+
q.fillStyle='#3d3b39';q.beginPath();q.moveTo(cx-s*46,cy-50);q.lineTo(cx+s*40,cy-30);q.lineTo(cx+s*38,cy-18);q.lineTo(cx-s*46,cy-36);q.closePath();q.fill();}
|
| 40 |
+
q.fillStyle='#3a2a26';q.beginPath();q.moveTo(w/2-60,182);q.quadraticCurveTo(w/2,158,w/2+60,182);q.lineTo(w/2+52,202);q.quadraticCurveTo(w/2,186,w/2-52,202);q.closePath();q.fill();
|
| 41 |
+
q.fillStyle='#ebe6da';for(let i=0;i<5;i++)q.fillRect(w/2-44+i*19,180,13,9);
|
| 42 |
+
q.strokeStyle='rgba(50,50,50,.45)';q.lineWidth=3;q.strokeRect(10,10,w-20,h-20);}),
|
| 43 |
+
back:()=>canvasTex(256,320,(q,w,h)=>{q.fillStyle='#a7a59e';q.fillRect(0,0,w,h);speckle(q,w,h,1500,61,'rgba(70,70,70,.25)','rgba(255,255,255,.16)');
|
| 44 |
+
q.save();q.translate(w/2,h*.46);for(const a of [-.62,.62]){q.save();q.rotate(a);q.fillStyle='#efe6cf';q.fillRect(-26,-128,52,256);q.fillStyle='rgba(150,130,100,.5)';for(let y=-120;y<128;y+=22)q.fillRect(-26,y,52,3);q.restore();}q.restore();
|
| 45 |
+
q.strokeStyle='rgba(50,50,50,.45)';q.lineWidth=3;q.strokeRect(10,10,w-20,h-20);}),
|
| 46 |
+
blob:()=>canvasTex(64,64,(q,w,h)=>{const g=q.createRadialGradient(32,32,2,32,32,31);g.addColorStop(0,'rgba(0,0,0,.62)');g.addColorStop(.7,'rgba(0,0,0,.42)');g.addColorStop(1,'rgba(0,0,0,0)');q.fillStyle=g;q.fillRect(0,0,w,h);}),
|
| 47 |
+
cloud:()=>canvasTex(128,64,(q,w,h)=>{for(const [x,y,r] of [[40,38,24],[64,30,28],[90,38,22],[60,44,22]]){const g=q.createRadialGradient(x,y,2,x,y,r);g.addColorStop(0,'rgba(255,255,255,.95)');g.addColorStop(1,'rgba(255,255,255,0)');q.fillStyle=g;q.beginPath();q.arc(x,y,r,0,PI*2);q.fill();}}),
|
| 48 |
+
sky:(top,mid,bottom)=>canvasTex(16,256,(q,w,h)=>{const g=q.createLinearGradient(0,0,0,h);g.addColorStop(0,top);g.addColorStop(.55,mid);g.addColorStop(1,bottom);q.fillStyle=g;q.fillRect(0,0,w,h);})
|
| 49 |
+
};
|
| 50 |
+
const COL={red:0xd8262b,blue:0x2a4ed0,skin:0xffc9a0,white:0xf4f4f0,brown:0x7a4422,hair:0x3a2414,yellow:0xf2c230,gold:0xe2aa2a,black:0x1d1e24,stone:0xc9c7bf,iron:0x30333a,horn:0xf3eee0};
|
| 51 |
+
class Scene{
|
| 52 |
+
constructor(canvas){
|
| 53 |
+
this.canvas=canvas;this.resources=new Set();this.times=[];this.ready=false;this.error=null;this.closed=false;this.kind=null;
|
| 54 |
+
this.view=document.createElement('canvas');this.view.width=854;this.view.height=480;
|
| 55 |
+
this.renderer=new T.WebGLRenderer({canvas:this.view,alpha:false,antialias:true,preserveDrawingBuffer:true,powerPreference:'low-power'});
|
| 56 |
+
this.renderer.setPixelRatio(1);this.renderer.setSize(854,480,false);this.renderer.outputColorSpace=T.SRGBColorSpace;
|
| 57 |
+
this.renderer.toneMapping=T.ACESFilmicToneMapping;this.renderer.toneMappingExposure=1.08;this.renderer.info.autoReset=false;
|
| 58 |
+
this.view.addEventListener('webglcontextlost',e=>{e.preventDefault();this.ready=false;this.error='WebGL context lost';});
|
| 59 |
+
this.world=new T.Scene();this.camera=new T.PerspectiveCamera(50,854/480,.1,420);
|
| 60 |
+
this.hemi=new T.HemisphereLight(0xdcefff,0x6a6250,2.1);this.world.add(this.hemi);
|
| 61 |
+
this.sun=new T.DirectionalLight(0xfff1d6,2.6);this.sun.position.set(-30,60,25);this.world.add(this.sun);
|
| 62 |
+
this.geo={box:this.keep(new T.BoxGeometry(1,1,1)),sphere:this.keep(new T.SphereGeometry(1,14,10)),half:this.keep(new T.SphereGeometry(1,14,6,0,PI*2,0,PI/2)),
|
| 63 |
+
cyl:this.keep(new T.CylinderGeometry(1,1,1,12)),cone:this.keep(new T.ConeGeometry(1,1,10)),disc:this.keep(new T.CircleGeometry(1,24)),ring:this.keep(new T.RingGeometry(.82,1,32)),
|
| 64 |
+
ico:this.keep(new T.IcosahedronGeometry(1,0)),oct:this.keep(new T.OctahedronGeometry(1,0)),plane:this.keep(new T.PlaneGeometry(1,1)),torus:this.keep(new T.TorusGeometry(1,.18,6,14))};
|
| 65 |
+
const L=(c,o={})=>this.keep(new T.MeshLambertMaterial({color:c,flatShading:o.flat!==false,...o.extra}));
|
| 66 |
+
this.mat={red:L(COL.red),blue:L(COL.blue),skin:L(COL.skin),white:L(COL.white),brown:L(COL.brown),hair:L(COL.hair),yellow:L(COL.yellow),
|
| 67 |
+
gold:this.keep(new T.MeshStandardMaterial({color:COL.gold,roughness:.35,metalness:.75,flatShading:true})),black:this.keep(new T.MeshStandardMaterial({color:COL.black,roughness:.38,metalness:.25})),
|
| 68 |
+
iron:this.keep(new T.MeshStandardMaterial({color:COL.iron,roughness:.42,metalness:.65,flatShading:true})),horn:L(COL.horn),eye:L(0xffffff),pupil:L(0x101014),orange:L(0xf08a24),
|
| 69 |
+
stone:L(0xffffff,{extra:{map:this.keep(TEX.stone())}}),face:L(0xffffff,{flat:false,extra:{map:this.keep(TEX.face())}}),back:L(0xffffff,{flat:false,extra:{map:this.keep(TEX.back())}})};
|
| 70 |
+
this.fxMat={dust:this.keep(new T.MeshLambertMaterial({color:0xe9e2d2,transparent:true,opacity:.8,depthWrite:false})),star:this.keep(new T.MeshBasicMaterial({color:0xffe24a})),
|
| 71 |
+
ring:this.keep(new T.MeshBasicMaterial({color:0xfff6d8,transparent:true,opacity:.55,side:T.DoubleSide,depthWrite:false})),
|
| 72 |
+
fire:this.keep(new T.MeshBasicMaterial({color:0xff7a1a,transparent:true,opacity:.85,depthWrite:false})),ember:this.keep(new T.MeshBasicMaterial({color:0xffb347}))};
|
| 73 |
+
this.blobMat=this.keep(new T.MeshBasicMaterial({map:this.keep(TEX.blob()),transparent:true,depthWrite:false}));
|
| 74 |
+
this.slabShadowMat=this.keep(new T.MeshBasicMaterial({color:0x1a1410,transparent:true,opacity:.0,depthWrite:false}));
|
| 75 |
+
this.landMat=this.keep(new T.MeshBasicMaterial({color:0x7a1c10,transparent:true,opacity:0,depthWrite:false}));
|
| 76 |
+
this.arenas={};this.mario=this.buildMario();this.world.add(this.mario.root);
|
| 77 |
+
this.handShadowMat=this.keep(new T.MeshBasicMaterial({color:0x1a1008,transparent:true,opacity:.42,depthWrite:false}));
|
| 78 |
+
this.bosses={whomp:this.buildWhomp(),king:this.buildKing(),bully:this.buildBully(),eyerok:this.buildEyerok(),wiggler:this.buildWiggler(),bowser:this.buildBowser()};for(const b of Object.values(this.bosses)){b.root.visible=false;this.world.add(b.root);}
|
| 79 |
+
this.marioBlob=this.blob(.42);this.bossBlob=this.blob(1);this.slabShadow=new T.Mesh(this.geo.plane,this.slabShadowMat);this.slabShadow.rotation.x=-PI/2;this.world.add(this.slabShadow);
|
| 80 |
+
this.landZone=new T.Mesh(this.geo.plane,this.landMat);this.landZone.renderOrder=2;this.world.add(this.landZone);
|
| 81 |
+
this.pools={dust:this.pool(this.geo.ico,this.fxMat.dust,96),star:this.pool(this.geo.oct,this.fxMat.star,64),ring:this.pool(this.geo.ring,this.fxMat.ring,16),fire:this.pool(this.geo.ico,this.fxMat.fire,220),ember:this.pool(this.geo.box,this.fxMat.ember,48)};
|
| 82 |
+
this.o=new T.Object3D();
|
| 83 |
+
}
|
| 84 |
+
keep(x){this.resources.add(x);return x;}
|
| 85 |
+
mesh(geo,mat,parent,pos=[0,0,0],scale=[1,1,1],rot=[0,0,0]){const m=new T.Mesh(geo,mat);m.position.set(pos[0],pos[1],pos[2]);m.scale.set(scale[0],scale[1],scale[2]);m.rotation.set(rot[0],rot[1],rot[2]);parent.add(m);return m;}
|
| 86 |
+
group(parent,pos=[0,0,0]){const g=new T.Group();g.position.set(pos[0],pos[1],pos[2]);parent.add(g);return g;}
|
| 87 |
+
pool(geo,mat,n){const m=new T.InstancedMesh(geo,mat,n);m.count=0;m.frustumCulled=false;this.world.add(m);this.keep(m);return m;}
|
| 88 |
+
blob(r){const m=new T.Mesh(this.geo.disc,this.blobMat);m.rotation.x=-PI/2;m.scale.set(r,r,1);m.renderOrder=1;this.world.add(m);return m;}
|
| 89 |
+
// ---------------- characters (original low-poly designs) ----------------
|
| 90 |
+
buildMario(){const M=this.mat,g=this.geo,root=new T.Group(),body=this.group(root,[0,.78,0]);
|
| 91 |
+
this.mesh(g.sphere,M.blue,body,[0,-.12,0],[.34,.30,.29]);this.mesh(g.sphere,M.red,body,[0,.12,0],[.31,.27,.26]);
|
| 92 |
+
for(const s of [-1,1]){this.mesh(g.box,M.blue,body,[s*.12,.13,.2],[.07,.26,.05]);this.mesh(g.sphere,M.yellow,body,[s*.12,.02,.25],[.045,.045,.03]);}
|
| 93 |
+
const head=this.group(body,[0,.48,0]);this.mesh(g.sphere,M.skin,head,[0,0,0],[.25,.24,.24]);
|
| 94 |
+
this.mesh(g.half,M.red,head,[0,.04,0],[.265,.2,.265]);this.mesh(g.cyl,M.red,head,[0,.05,.16],[.2,.025,.17]);
|
| 95 |
+
this.mesh(g.disc,M.white,head,[0,.14,.235],[.07,.07,1],[-.35,0,0]);this.mesh(g.box,M.red,head,[0,.14,.237],[.05,.05,.01],[-.35,0,0]);
|
| 96 |
+
this.mesh(g.sphere,M.skin,head,[0,-.02,.24],[.075,.07,.08]);this.mesh(g.box,M.hair,head,[0,-.09,.21],[.22,.05,.05]);
|
| 97 |
+
for(const s of [-1,1]){this.mesh(g.sphere,M.eye,head,[s*.075,.06,.2],[.05,.065,.03]);this.mesh(g.sphere,M.blue,head,[s*.07,.055,.225],[.025,.035,.012]);
|
| 98 |
+
this.mesh(g.box,M.hair,head,[s*.21,-.02,-.02],[.04,.12,.12]);this.mesh(g.sphere,M.skin,head,[s*.235,-.02,0],[.04,.06,.04]);}
|
| 99 |
+
const arms=[],legs=[];
|
| 100 |
+
for(const s of [-1,1]){const sh=this.group(body,[s*.3,.24,0]);this.mesh(g.cyl,M.red,sh,[0,-.14,0],[.07,.28,.07]);const fore=this.group(sh,[0,-.28,0]);
|
| 101 |
+
this.mesh(g.cyl,M.red,fore,[0,-.08,0],[.06,.16,.06]);this.mesh(g.sphere,M.white,fore,[0,-.2,0],[.095,.09,.095]);arms.push({sh,fore});
|
| 102 |
+
const hip=this.group(body,[s*.13,-.3,0]);this.mesh(g.cyl,M.blue,hip,[0,-.17,0],[.085,.34,.085]);const shin=this.group(hip,[0,-.32,0]);
|
| 103 |
+
this.mesh(g.sphere,M.brown,shin,[0,-.12,.05],[.1,.07,.16]);legs.push({hip,shin});}
|
| 104 |
+
return {root,body,head,arms,legs};}
|
| 105 |
+
buildWhomp(){const M=this.mat,g=this.geo,s=200*U*1,root=new T.Group(),tilt=this.group(root),slab=this.group(tilt);
|
| 106 |
+
// Collision box x -150..150, y 50..430, z -100..-3 at scale 2 (S11): 6 m wide, 1.0..8.6 m high, 1.94 m deep.
|
| 107 |
+
const W=6,H0=1,H1=8.6,D0=-2,D1=-.06,cy=(H0+H1)/2,cz=(D0+D1)/2;
|
| 108 |
+
this.mesh(g.box,[M.stone,M.stone,M.stone,M.stone,M.face,M.back],slab,[0,cy,cz],[W,H1-H0,D1-D0]);
|
| 109 |
+
this.mesh(g.box,M.stone,slab,[0,H1+.12,cz],[W*.92,.24,(D1-D0)*.9]);
|
| 110 |
+
const arms=[];for(const sd of [-1,1]){const sh=this.group(slab,[sd*(W/2+.15),5.6,cz]);this.mesh(g.box,M.stone,sh,[sd*.55,-1.2,0],[1.0,2.6,1.0]);this.mesh(g.box,M.stone,sh,[sd*.6,-2.75,.15],[1.2,.8,1.25]);arms.push(sh);}
|
| 111 |
+
const feet=[];for(const sd of [-1,1]){const f=this.group(root,[sd*1.6,0,cz+.5]);this.mesh(g.box,M.stone,f,[0,.45,0],[1.25,.9,1.6]);this.mesh(g.box,M.stone,f,[0,.18,.55],[1.35,.36,.9]);feet.push(f);}
|
| 112 |
+
return {root,tilt,slab,arms,feet,size:s};}
|
| 113 |
+
buildKing(){const M=this.mat,g=this.geo,root=new T.Group(),body=this.group(root,[0,1.32,0]);
|
| 114 |
+
this.mesh(g.sphere,M.black,body,[0,0,0],[1.16,1.12,1.16]);
|
| 115 |
+
for(const sd of [-1,1]){this.mesh(g.sphere,M.eye,body,[sd*.34,.25,.98],[.25,.36,.15]);this.mesh(g.sphere,M.pupil,body,[sd*.32,.22,1.1],[.1,.17,.06]);
|
| 116 |
+
this.mesh(g.sphere,M.white,body,[sd*.33,-.26,1.04],[.42,.15,.16],[0,0,sd*.25]);}
|
| 117 |
+
const crown=this.group(body,[0,1.02,0]);this.mesh(g.cyl,M.gold,crown,[0,0,0],[.62,.42,.62]);
|
| 118 |
+
for(let i=0;i<6;i++){const a=i*PI/3;this.mesh(g.cone,M.gold,crown,[Math.sin(a)*.5,.36,Math.cos(a)*.5],[.17,.38,.17]);this.mesh(g.sphere,M.red,crown,[Math.sin(a)*.62,.02,Math.cos(a)*.62],[.07,.07,.07]);}
|
| 119 |
+
const key=this.group(body,[0,.15,-1.12]);this.mesh(g.cyl,M.gold,key,[0,0,-.18],[.08,.36,.08],[PI/2,0,0]);for(const sd of [-1,1])this.mesh(g.torus,M.gold,key,[sd*.26,0,-.42],[.28,.28,.28],[0,PI/2,0]);
|
| 120 |
+
const arms=[];for(const sd of [-1,1]){const sh=this.group(body,[sd*1.08,.05,.1]);this.mesh(g.cyl,M.black,sh,[sd*.25,0,0],[.12,.5,.12],[0,0,PI/2]);this.mesh(g.sphere,M.white,sh,[sd*.6,0,0],[.26,.26,.26]);arms.push(sh);}
|
| 121 |
+
const feet=[];for(const sd of [-1,1]){const f=this.group(root,[sd*.55,0,.1]);this.mesh(g.sphere,M.orange,f,[0,.18,.15],[.36,.2,.5]);feet.push(f);}
|
| 122 |
+
return {root,body,arms,feet,key};}
|
| 123 |
+
buildBully(){const M=this.mat,g=this.geo,root=new T.Group(),body=this.group(root,[0,1.18,0]);
|
| 124 |
+
this.mesh(g.sphere,M.iron,body,[0,0,0],[1.15,1.15,1.15]);
|
| 125 |
+
for(const sd of [-1,1]){const h=this.mesh(g.cone,M.horn,body,[sd*.62,.92,.05],[.2,.75,.2],[0,0,-sd*.6]);
|
| 126 |
+
this.mesh(g.sphere,M.eye,body,[sd*.32,.22,1.0],[.22,.27,.12]);this.mesh(g.sphere,M.pupil,body,[sd*.3,.2,1.09],[.1,.14,.05]);
|
| 127 |
+
this.mesh(g.box,M.black,body,[sd*.32,.52,.98],[.34,.08,.08],[0,0,sd*.35]);}
|
| 128 |
+
const feet=[];for(const sd of [-1,1]){const f=this.group(root,[sd*.5,0,.05]);this.mesh(g.sphere,M.black,f,[0,.16,.2],[.32,.18,.46]);feet.push(f);}
|
| 129 |
+
return {root,body,feet};}
|
| 130 |
+
// ---------------- arenas ----------------
|
| 131 |
+
// Extruded outline (local world units): top face at y0, walls down by depth; [top, side] materials.
|
| 132 |
+
prism(poly,depth,top,side,y0=0){const s=new T.Shape();poly.forEach(([x,z],i)=>i?s.lineTo(x*U,z*U):s.moveTo(x*U,z*U));
|
| 133 |
+
const m=new T.Mesh(this.keep(new T.ExtrudeGeometry(s,{depth:depth*U,bevelEnabled:false,curveSegments:1})),[top,side]);m.rotation.x=PI/2;m.position.y=y0*U;return m;}
|
| 134 |
+
tex(make,rep){const t=this.keep(make());t.repeat.set(rep,rep);return t;}
|
| 135 |
+
// Arenas follow the measured outlines (game.js ARENA: decomp collision of WF / BOB / LLL). Beyond each edge a ledge
|
| 136 |
+
// is drawn at that edge's measured drop, so a fall looks like the floor the simulation lands Mario on.
|
| 137 |
+
// Eyerok's two stone hands. The fist and palm blocks use the measured collision boxes (S36 x 1.5), so what is drawn is what
|
| 138 |
+
// squishes or blocks Mario; the model is unmirrored for the same reason. Each hand throws a footprint shadow on the floor.
|
| 139 |
+
buildEyerok(){const M=this.mat,g=this.geo,root=new T.Group(),sand=this.keep(new T.MeshLambertMaterial({color:0xb4764a,flatShading:true})),dark=this.keep(new T.MeshLambertMaterial({color:0x7c4a2c,flatShading:true}));
|
| 140 |
+
const lid=this.keep(new T.MeshLambertMaterial({color:0x96603a,flatShading:true})),iris=this.keep(new T.MeshLambertMaterial({color:0xd8362a}));
|
| 141 |
+
const hands=[];for(const side of [-1,1]){const h=this.group(root);
|
| 142 |
+
const fist=this.group(h);this.mesh(g.box,sand,fist,[-.1425,1.5525,.0975],[2.325,3.015,4.215]);
|
| 143 |
+
for(let i=0;i<4;i++)this.mesh(g.box,dark,fist,[-1.0+i*.58,2.85,2.05],[.5,.72,.46]);
|
| 144 |
+
this.mesh(g.box,dark,fist,[-.1425,.28,-1.75],[2.45,.56,.8]);
|
| 145 |
+
const palm=this.group(h);this.mesh(g.box,sand,palm,[.3825,2.535,0],[3.825,5.07,1.53]);
|
| 146 |
+
for(let i=0;i<4;i++)this.mesh(g.box,dark,palm,[-1.1+i*.98,5.45,0],[.72,.9,1.16]);
|
| 147 |
+
this.mesh(g.box,dark,palm,[.3825,.22,0],[3.95,.44,1.7]);
|
| 148 |
+
const eye=this.group(palm,[.3825,2.6,.77]);this.mesh(g.sphere,M.eye,eye,[0,0,0],[1.05,1.05,.22]);const pupil=this.group(eye);
|
| 149 |
+
this.mesh(g.sphere,iris,pupil,[0,0,.16],[.5,.5,.12]);this.mesh(g.sphere,M.pupil,pupil,[0,0,.25],[.24,.24,.06]);
|
| 150 |
+
const upper=this.mesh(g.box,lid,eye,[0,.55,.27],[2.3,1.1,.16]),lower=this.mesh(g.box,lid,eye,[0,-.55,.27],[2.3,1.1,.16]);
|
| 151 |
+
const shadow=new T.Mesh(g.plane,this.handShadowMat);shadow.rotation.x=-PI/2;shadow.renderOrder=1;root.add(shadow);
|
| 152 |
+
hands.push({h,fist,palm,eye,pupil,upper,lower,shadow,side});}
|
| 153 |
+
return {root,hands};}
|
| 154 |
+
// Wiggler: a yellow caterpillar with a flower on his head; his eyes and mouth turn angry after the first stomp, as the walking speed rises (S40).
|
| 155 |
+
buildWiggler(){const M=this.mat,g=this.geo,root=new T.Group(),L=c=>this.keep(new T.MeshLambertMaterial({color:c})),body=L(0xf2c230),belly=L(0xf7dd7a),foot=L(0xe8872a),petal=L(0xf0568c),stem=L(0x3f9a3a),angry=L(0xe8562a);
|
| 156 |
+
const head=this.group(root),hb=this.group(head);this.mesh(g.sphere,body,hb,[0,1.0,0],[1.2,1.0,1.2]);this.mesh(g.sphere,belly,hb,[0,.78,.72],[.8,.55,.5]);
|
| 157 |
+
const eyes=[];for(const s of [-1,1]){const e=this.group(hb,[s*.45,1.3,.92]);this.mesh(g.sphere,M.eye,e,[0,0,0],[.28,.36,.16]);this.mesh(g.sphere,M.pupil,e,[-s*.04,-.03,.13],[.11,.15,.06]);eyes.push(this.mesh(g.box,M.pupil,e,[0,.33,.12],[.5,.1,.08],[0,0,s*.12]));}
|
| 158 |
+
this.mesh(g.box,M.pupil,hb,[0,.72,1.17],[.5,.07,.05]);this.mesh(g.cyl,stem,hb,[0,2.1,0],[.07,.3,.07]);
|
| 159 |
+
for(let i=0;i<5;i++){const a=i*PI*.4;this.mesh(g.sphere,petal,hb,[Math.sin(a)*.32,2.28,Math.cos(a)*.32],[.26,.11,.26]);}this.mesh(g.sphere,M.yellow,hb,[0,2.32,0],[.15,.1,.15]);
|
| 160 |
+
const parts=[];for(let i=0;i<3;i++){const p=this.group(root),q=this.group(p);this.mesh(g.sphere,body,q,[0,.8,0],[.8,.8,.8]);this.mesh(g.sphere,belly,q,[0,.62,.3],[.5,.42,.5]);const feet=[];for(const s of [-1,1])feet.push(this.mesh(g.sphere,foot,p,[s*.5,.2,.1],[.3,.2,.42]));parts.push({p,q,feet});}
|
| 161 |
+
const hf=[-1,1].map(s=>this.mesh(g.sphere,foot,head,[s*.7,.2,.2],[.36,.22,.5]));
|
| 162 |
+
return {root,head,hb,parts,hf,eyes,mats:[body,angry]};}
|
| 163 |
+
// Bowser: a green shell with spikes, a pale belly, horns, a red mane and a bright tail tip (where to grab him). Mines: black spheres with spikes on a post (the post is scenery). Original procedural art.
|
| 164 |
+
buildBowser(){const M=this.mat,g=this.geo,root=new T.Group(),L=c=>this.keep(new T.MeshLambertMaterial({color:c})),shell=L(0x2f8a3a),skin=L(0xe2a92c),belly=L(0xf2dc9a),rim=L(0xf4efe0),hair=L(0xd6402a),horn=L(0xf0ead8),dark=L(0x20242c),post=L(0x4a4458);
|
| 165 |
+
const body=this.group(root,[0,0,0]);this.mesh(g.sphere,skin,body,[0,1.5,0],[1.35,1.45,1.3]);this.mesh(g.sphere,belly,body,[0,1.4,.72],[1.0,1.15,.72]);this.mesh(g.sphere,shell,body,[0,1.65,-.55],[1.5,1.5,1.15]);this.mesh(g.torus,rim,body,[0,1.65,-.5],[1.42,1.42,1.1]);
|
| 166 |
+
for(let i=0;i<9;i++){const a=i*PI*2/9,r=.75;this.mesh(g.cone,horn,body,[Math.sin(a)*r,1.7+Math.cos(a)*r,-1.45],[.2,.55,.2],[-PI/2,0,0]);}
|
| 167 |
+
const head=this.group(body,[0,2.75,.65]);this.mesh(g.sphere,skin,head,[0,0,0],[.72,.68,.72]);this.mesh(g.sphere,belly,head,[0,-.18,.55],[.62,.34,.55]);
|
| 168 |
+
for(const s of [-1,1]){const e=this.group(head,[s*.3,.25,.56]);this.mesh(g.sphere,M.eye,e,[0,0,0],[.2,.25,.12]);this.mesh(g.sphere,M.pupil,e,[-s*.03,0,.1],[.09,.12,.05]);this.mesh(g.cone,horn,head,[s*.55,.72,-.05],[.16,.55,.16],[0,0,-s*.45]);}
|
| 169 |
+
for(let i=0;i<5;i++)this.mesh(g.sphere,hair,head,[(i-2)*.2,.62-Math.abs(i-2)*.08,-.28],[.2,.34,.26]);
|
| 170 |
+
const limbs=[[-.95,.42,.25],[.95,.42,.25],[-1.2,1.9,.45],[1.2,1.9,.45]].map(([x,y,z],i)=>{const p=this.group(body,[x,y,z]);this.mesh(g.sphere,skin,p,[0,i<2?-.15:-.25,i<2?.1:.1],i<2?[.48,.48,.68]:[.3,.55,.3]);return p;});
|
| 171 |
+
const tail=this.group(body,[0,.62,-1.05]);this.mesh(g.cone,skin,tail,[0,0,-.65],[.42,1.5,.42],[-PI/2,0,0]);const tip=this.mesh(g.sphere,L(0xffc83a),tail,[0,0,-1.45],[.2,.2,.3]),tipOff=L(0x4a4458),tipOn=tip.material;
|
| 172 |
+
const mines=[0,1,2,3].map(()=>{const p=this.group(root.parent||this.world);const q=this.group(p,[0,0,0]);this.mesh(g.sphere,dark,q,[0,0,0],[.5,.5,.5]);for(let i=0;i<8;i++){const a=i*PI/4;this.mesh(g.cone,horn,q,[Math.sin(a)*.5,0,Math.cos(a)*.5],[.1,.3,.1],[PI/2,0,a]);}this.mesh(g.cone,horn,q,[0,.52,0],[.1,.3,.1]);this.mesh(g.cyl,post,p,[0,-1.4,0],[.12,2.8,.12]);p.visible=false;return {p,q};});
|
| 173 |
+
return {root,body,head,limbs,tail,mines,tip,tipOn,tipOff};}
|
| 174 |
+
arena(kind,A){if(this.arenas[kind])return this.arenas[kind];const g=new T.Group(),G=this.geo,L=(c,map)=>this.keep(new T.MeshLambertMaterial({color:c,map:map||null}));
|
| 175 |
+
const clouds=[],cloudMat=this.keep(new T.SpriteMaterial({map:this.keep(TEX.cloud()),transparent:true,depthWrite:false,fog:false}));
|
| 176 |
+
const addClouds=(n,r,y)=>{for(let i=0;i<n;i++){const s=new T.Sprite(cloudMat),a=i*2.4+.3,d=r*(.8+hash(i,1,77)*.5);s.position.set(A.centre.x*U+Math.sin(a)*d,y+hash(i,2,77)*18,A.centre.z*U+Math.cos(a)*d);const w=18+hash(i,3,77)*16;s.scale.set(w,w*.5,1);g.add(s);clouds.push(s);}};
|
| 177 |
+
const P=A.poly,cx=A.centre.x*U,cz=A.centre.z*U;
|
| 178 |
+
const trim=mat=>{for(let i=0;i<P.length;i++){const [x0,z0]=P[i],[x1,z1]=P[(i+1)%P.length],len=Math.hypot(x1-x0,z1-z0)*U;
|
| 179 |
+
this.mesh(G.box,mat,g,[(x0+x1)/2*U,.05,(z0+z1)/2*U],[len+.25,.1,.25],[0,Math.atan2(x1-x0,z1-z0)+PI/2,0]);}};
|
| 180 |
+
const ledges=(mat,width)=>{for(let i=0;i<P.length;i++){const [x0,z0]=P[i],[x1,z1]=P[(i+1)%P.length],ex=x1-x0,ez=z1-z0,l=Math.hypot(ex,ez);
|
| 181 |
+
let nx=ez/l,nz=-ex/l;const mx=(x0+x1)/2,mz=(z0+z1)/2;if(Math.hypot(mx+nx*5-A.centre.x,mz+nz*5-A.centre.z)<Math.hypot(mx-A.centre.x,mz-A.centre.z)){nx=-nx;nz=-nz;}
|
| 182 |
+
g.add(this.prism([[x0,z0],[x1,z1],[x1+nx*width,z1+nz*width],[x0+nx*width,z0+nz*width]],400,mat,mat,A.drop[i]));}};
|
| 183 |
+
if(kind==='whomp'){ // Whomp's Fortress top (y 3584): brick summit over the fortress deck (y 2560); ground y 922
|
| 184 |
+
const brick=L(0xffffff,this.tex(TEX.brick,.36)),wall=L(0xffffff,this.tex(TEX.wall,.3)),deckTop=L(0xd8cbb0,this.tex(TEX.brick,.3));
|
| 185 |
+
g.add(this.prism(P,1024,brick,wall));trim(L(0xe2d7bf));
|
| 186 |
+
g.add(this.prism([[-2100,-3100],[2600,-3100],[2600,1024],[1536,1024],[1024,1536],[-2100,1536]],1638,deckTop,wall,-1024));
|
| 187 |
+
// North of the summit the slippery slope falls from -1580 at the edge to the ground (-2662) at ~0.72 (S29 samples).
|
| 188 |
+
const slope=this.mesh(G.plane,L(0xffffff,this.tex(TEX.slope,.12)),g,[0,(-1580-2662)/2*U,(1536+3040)/2*U],[21,Math.hypot(15.04,10.82),1]);
|
| 189 |
+
slope.rotation.set(-PI/2+Math.atan2(10.82,15.04),0,0);
|
| 190 |
+
this.mesh(G.plane,L(0xffffff,this.tex(TEX.grass,.08)),g,[0,-26.63,0],[320,320,1],[-PI/2,0,0]);
|
| 191 |
+
this.mesh(G.plane,L(0x3d7fd1),g,[0,-27.5,0],[900,900,1],[-PI/2,0,0]);
|
| 192 |
+
for(let i=0;i<12;i++){const a=i*.55+.4,r=45+hash(i,4,5)*40;this.mesh(G.cone,L(0x3f7d2e),g,[Math.sin(a)*r,-21,Math.cos(a)*r],[3+hash(i,6,5)*2,11+hash(i,7,5)*6,3+hash(i,6,5)*2]);}
|
| 193 |
+
addClouds(9,120,14);}
|
| 194 |
+
else if(kind==='king'){ // Bob-omb Battlefield summit (y 4293) with the east apron; plain y ~0 far below
|
| 195 |
+
const grass=L(0xffffff,this.tex(TEX.grass,.22)),dirt=L(0xffffff,this.tex(TEX.slope,.18)),ledge=L(0x5f8f3a,this.tex(TEX.grass,.2));
|
| 196 |
+
g.add(this.prism(P,1200,grass,dirt));ledges(ledge,520);
|
| 197 |
+
this.mesh(this.keep(new T.CylinderGeometry(24,75,31,40,1,true)),L(0xffffff,this.tex(TEX.slope,.05)),g,[cx,-27.4,cz]);
|
| 198 |
+
this.mesh(G.plane,L(0xffffff,this.tex(TEX.grass,.05)),g,[cx,-42.9,cz],[800,800,1],[-PI/2,0,0]);
|
| 199 |
+
for(let i=0;i<18;i++){const a=i*.35+.2,d=85+hash(i,1,9)*60;this.mesh(G.sphere,L(0x3c8a2a),g,[cx+Math.sin(a)*d,-42.9,cz+Math.cos(a)*d],[6+hash(i,2,9)*8,4+hash(i,3,9)*9,6+hash(i,2,9)*8]);}
|
| 200 |
+
for(let i=0;i<6;i++){const a=i*1.05+.5;this.mesh(G.cone,L(0x7a8fa8),g,[cx+Math.sin(a)*240,-30,cz+Math.cos(a)*240],[40,70+hash(i,6,9)*30,40]);}
|
| 201 |
+
addClouds(10,110,4);}
|
| 202 |
+
else if(kind==='eyerok'){ // Shifting Sand Land pyramid, top floor (S38): 1893 x 2099 slab over the void; back wall 1125 high
|
| 203 |
+
const top=L(0xffffff,this.tex(TEX.sand,.3)),side=L(0x7d6238);g.add(this.prism(P,700,top,side));trim(L(0xb99a5e));
|
| 204 |
+
this.mesh(G.box,side,g,[0,5.625,-2.61],[18.93,11.25,.3]); // back wall, z -261
|
| 205 |
+
for(let i=0;i<7;i++){const x=-8.1+i*2.7,y=.63+hash(i,1,83)*3.21;this.mesh(G.box,top,g,[x,y/2,-.565],[2.6,y,4.09]);} // decorative blocks, z -261..148, 63..384 high (A6)
|
| 206 |
+
for(const sx of [-1,1])for(let i=0;i<6;i++){const y=7+i*5,z=i*2.2;this.mesh(G.box,side,g,[sx*(26-i*1.9),y,8+z],[3,1.2,60]);} // stepped pyramid walls, scenery only
|
| 207 |
+
this.mesh(G.plane,this.keep(new T.MeshBasicMaterial({color:0x140c06})),g,[0,-30.72,8],[420,420,1],[-PI/2,0,0]);}
|
| 208 |
+
else if(kind==='bowser'){ // Bowser in the Dark World (S53): an octagon of circumradius 3072 over the void, sides down 2354
|
| 209 |
+
g.add(this.prism(P,2354,L(0x8d82a8,this.tex(TEX.stone,.2)),L(0x3a3350)));trim(L(0xc9b45a));
|
| 210 |
+
this.mesh(G.plane,this.keep(new T.MeshBasicMaterial({color:0x07060f})),g,[0,-64.5,10],[900,900,1],[-PI/2,0,0]);
|
| 211 |
+
const stars=this.keep(new T.InstancedMesh(G.sphere,this.keep(new T.MeshBasicMaterial({color:0xdcd8ff,fog:false})),60)),o=new T.Object3D();stars.frustumCulled=false;for(let i=0;i<60;i++){const a=hash(i,1,41)*PI*2,e=hash(i,2,41)*.9-.1,d=180;o.position.set(Math.sin(a)*Math.cos(e)*d,Math.sin(e)*d,10+Math.cos(a)*Math.cos(e)*d);o.scale.setScalar(.28);o.updateMatrix();stars.setMatrixAt(i,o.matrix);}g.add(stars);}
|
| 212 |
+
else if(kind==='wiggler'){ // Tiny-Huge Island's mountain cave (S41): 4095 x 4095 room, flat middle rising to 307 at the walls, a pyramid hanging over the middle (A10)
|
| 213 |
+
const flat=L(0xffffff,this.tex(TEX.grass,.28)),rise=L(0xffffff,this.tex(TEX.grass,.28)),rock=L(0x6d6253),dark=L(0x4a4238);const hx=-.17,hz=.625,R=7.165,O=20.47,H=3.07,y0=.012;
|
| 214 |
+
this.mesh(G.plane,flat,g,[hx,y0,hz],[R*2,R*2,1],[-PI/2,0,0]);
|
| 215 |
+
const quad=(a,b,c,d)=>{const p=this.keep(new T.BufferGeometry()),v=[...a,...b,...c,...a,...c,...d],uv=[];for(let i=0;i<v.length;i+=3)uv.push(v[i]*.2,v[i+2]*.2);p.setAttribute('position',new T.Float32BufferAttribute(v,3));p.setAttribute('uv',new T.Float32BufferAttribute(uv,2));p.computeVertexNormals();return new T.Mesh(p,rise);};
|
| 216 |
+
const c=[[-1,-1],[1,-1],[1,1],[-1,1]];for(let i=0;i<4;i++){const [a,b]=[c[i],c[(i+1)%4]],pt=(q,r,y)=>[hx+q[0]*r,y,hz+q[1]*r],m=quad(pt(a,R,y0),pt(b,R,y0),pt(b,O,H),pt(a,O,H));g.add(m);}
|
| 217 |
+
for(let i=0;i<4;i++){const a=i*PI/2;this.mesh(G.box,rock,g,[hx+Math.sin(a)*O,8,hz+Math.cos(a)*O],[Math.abs(Math.cos(a))*41+.3,16,Math.abs(Math.sin(a))*41+.3]);}
|
| 218 |
+
this.mesh(G.plane,dark,g,[hx,16,hz],[42,42,1],[PI/2,0,0]);
|
| 219 |
+
const px=-.17,pz=.62,tip=this.keep(new T.ConeGeometry(4.33,2.05,4));tip.rotateY(PI/4);tip.rotateX(PI);this.mesh(tip,rock,g,[px,5.125,pz]);this.mesh(G.box,rock,g,[px,6.66,pz],[6.13,1.02,6.13]);
|
| 220 |
+
this.mesh(G.cyl,dark,g,[px,12,pz],[.5,8,.5]);}
|
| 221 |
+
else{ // Lethal Lava Land: the Big Bully's 1535 x 1408 platform, 307 above the lava; the volcano at the level centre
|
| 222 |
+
g.add(this.prism(P,307,L(0xffffff,this.tex(TEX.grate,.3)),L(0x5d524d)));trim(this.mat.iron);
|
| 223 |
+
const lavaTex=this.keep(TEX.lava());this.lavaTex=lavaTex;
|
| 224 |
+
this.mesh(G.plane,this.keep(new T.MeshBasicMaterial({map:lavaTex,color:0xffffff,fog:true})),g,[0,-3.07,0],[700,700,1],[-PI/2,0,0]);
|
| 225 |
+
this.mesh(this.keep(new T.ConeGeometry(16,26,12,1,true)),L(0x3a2622),g,[0,9.9,43.85]);this.mesh(G.sphere,this.keep(new T.MeshBasicMaterial({color:0xffa040})),g,[0,22.5,43.85],[3.4,1.2,3.4]);
|
| 226 |
+
for(let i=0;i<8;i++){const a=i*.8+.3,d=40+hash(i,1,19)*60;this.mesh(G.ico,L(0x4a3a35),g,[Math.sin(a)*d,-3,Math.cos(a)*d],[4+hash(i,2,19)*4,2+hash(i,3,19)*3,4]);}}
|
| 227 |
+
g.visible=false;this.world.add(g);this.arenas[kind]={group:g,clouds};return this.arenas[kind];}
|
| 228 |
+
setKind(kind,A){if(this.kind===kind)return;this.kind=kind;for(const [k,a] of Object.entries(this.arenas))a.group.visible=k===kind;this.arena(kind,A).group.visible=true;
|
| 229 |
+
for(const [k,b] of Object.entries(this.bosses))b.root.visible=k===kind;
|
| 230 |
+
this.bosses.bowser.mines.forEach(q=>{q.p.visible=false;});
|
| 231 |
+
const sky={whomp:['#3f8be0','#8fc4f2','#e6f3fb'],king:['#3a86e6','#91c9f5','#eaf6fb'],bully:['#2a0d0b','#7a2412','#d9682a'],eyerok:['#1b120a','#4f3518','#a97e42'],wiggler:['#141a10','#2a3320','#4c5a38'],bowser:['#07060f','#120d24','#2c1f47']}[kind];
|
| 232 |
+
if(this.skyTex)this.skyTex.dispose();this.skyTex=TEX.sky(...sky);this.world.background=this.skyTex;
|
| 233 |
+
this.world.fog=kind==='bowser'?new T.Fog(0x1a1430,70,240):kind==='wiggler'?new T.Fog(0x2a3320,40,110):kind==='eyerok'?new T.Fog(0x4f3518,60,150):kind==='bully'?new T.Fog(0x8a3418,40,190):new T.Fog(kind==='king'?0xcfe6f6:0xd6eaf7,70,260);
|
| 234 |
+
this.hemi.color.set(kind==='eyerok'?0xffe2b0:kind==='bully'?0xffc49a:0xdcefff);this.hemi.groundColor.set(kind==='bully'?0x6a2412:0x6a6250);this.sun.color.set(kind==='bully'?0xffb27a:0xfff1d6);}
|
| 235 |
+
// ---------------- poses (pure functions of the game state) ----------------
|
| 236 |
+
poseMario(g){const P=this.mario,m=g.mario,t=g.t,a=m.action;
|
| 237 |
+
P.root.position.set(m.x*U,m.y*U,m.z*U);P.root.rotation.set(0,m.yaw,0);P.root.scale.set(1,1,1);P.root.visible=!(m.invinc>0&&m.invinc%6<3&&a!=='dead');
|
| 238 |
+
const B=P.body;B.position.set(0,.78,0);B.rotation.set(0,0,0);P.head.rotation.set(0,0,0);
|
| 239 |
+
const arm=(i,x,z=0,fx=0)=>{P.arms[i].sh.rotation.set(x,0,z);P.arms[i].fore.rotation.set(fx,0,0);},leg=(i,x,k=0)=>{P.legs[i].hip.rotation.set(x,0,0);P.legs[i].shin.rotation.set(k,0,0);};
|
| 240 |
+
arm(0,0,.12);arm(1,0,-.12);leg(0,0);leg(1,0);
|
| 241 |
+
const run=f=>{const ph=t*(.11+Math.abs(m.fwd)*.009),s=Math.sin(ph),amp=Math.min(1.05,.2+Math.abs(m.fwd)/30);leg(0,s*amp,Math.max(0,-s)*.6);leg(1,-s*amp,Math.max(0,s)*.6);arm(0,-s*amp*.8,.15,-.4);arm(1,s*amp*.8,-.15,-.4);
|
| 242 |
+
B.position.y=.78+Math.abs(Math.cos(ph))*.05*amp;B.rotation.x=Math.min(.35,Math.abs(m.fwd)/90);};
|
| 243 |
+
const air=m.y>0?Math.min(1,(m.timer||0)/16):0,tk=m.timer||0;
|
| 244 |
+
switch(a){
|
| 245 |
+
case 'walking':run();break;
|
| 246 |
+
case 'holdwalk':run();arm(0,-3.0,.3);arm(1,-3.0,-.3);break;
|
| 247 |
+
case 'decel':case 'braking':B.rotation.x=-.25;leg(0,.5,.2);leg(1,-.2);arm(0,-.6,.3);arm(1,-.6,-.3);break;
|
| 248 |
+
case 'turnaround':B.rotation.x=-.35;B.rotation.z=.2;leg(0,.7,.3);leg(1,-.3);break;
|
| 249 |
+
case 'jump':case 'freefall':case 'rollout':leg(0,-.9,1.2);leg(1,.35,.3);arm(0,-2.6,.3);arm(1,.5,-.5);if(a==='rollout')B.rotation.x=tk*.25;break;
|
| 250 |
+
case 'double':leg(0,-1.1,1.4);leg(1,-.3,.9);arm(0,-2.8,.2);arm(1,-2.8,-.2);break;
|
| 251 |
+
case 'triple':B.rotation.x=Math.min(PI*2,tk*.24);leg(0,-1.3,1.8);leg(1,-1.3,1.8);arm(0,-.4,.9);arm(1,-.4,-.9);break;
|
| 252 |
+
case 'backflip':B.rotation.x=-Math.min(PI*2,tk*.2);leg(0,-1.2,1.6);leg(1,-1.2,1.6);arm(0,-2.6,.4);arm(1,-2.6,-.4);break;
|
| 253 |
+
case 'sideflip':B.rotation.z=Math.min(PI*2,tk*.22);leg(0,-.6,1);leg(1,.2,.4);arm(0,-.4,1.4);arm(1,-.4,-1.4);break;
|
| 254 |
+
case 'longjump':B.rotation.x=1.05;leg(0,.9,0);leg(1,1.1,0);arm(0,-2.9,.15);arm(1,-2.9,-.15);break;
|
| 255 |
+
case 'dive':case 'diveslide':case 'divestop':B.rotation.x=1.45;B.position.y=a==='dive'?.78:.32;leg(0,.25);leg(1,.25);arm(0,-3,.2);arm(1,-3,-.2);break;
|
| 256 |
+
case 'jumpkick':leg(0,-1.4,0);leg(1,.5,.8);arm(0,-.8,.9);arm(1,-.8,-.9);B.rotation.x=-.25;break;
|
| 257 |
+
case 'slidekick':case 'slidekickslide':B.rotation.x=-1.0;B.position.y=.45;leg(0,-1.5,0);leg(1,-1.2,.4);arm(0,-2.2,.6);arm(1,-2.2,-.6);break;
|
| 258 |
+
case 'gp':if(m.state===0){B.rotation.x=Math.min(PI*2,tk*.42);leg(0,-1.5,2);leg(1,-1.5,2);arm(0,-.3,.8);arm(1,-.3,-.8);}else{leg(0,-1.6,1.9);leg(1,-1.6,1.9);arm(0,-2.7,.5);arm(1,-2.7,-.5);B.position.y=.95;}break;
|
| 259 |
+
case 'gpLand':B.position.y=.55;leg(0,-1.4,1.8);leg(1,-1.4,1.8);arm(0,-.2,1.2);arm(1,-.2,-1.2);break;
|
| 260 |
+
case 'crouchIn':case 'crouch':case 'crouchOut':case 'crouchslide':B.position.y=.5;B.rotation.x=a==='crouchslide'?.35:.2;leg(0,-1.2,1.9);leg(1,-1.2,1.9);arm(0,-.4,.2);arm(1,-.4,-.2);break;
|
| 261 |
+
case 'punching':case 'movepunch':{const k=m.arg>=6&&m.arg<9,sec=m.arg>=3&&m.arg<6,e=Math.min(1,tk/4);
|
| 262 |
+
if(m.arg===9){B.position.y=.4;B.rotation.y=tk*.35;leg(0,-1.6,0);leg(1,.9,0);arm(0,-1.4,.6);arm(1,-1.4,-.6);break;}
|
| 263 |
+
if(k){leg(0,-1.5*e,0);arm(0,-.6,.6);arm(1,.4,-.6);B.rotation.x=-.2;}else if(sec){arm(0,-1.55*e,0,0);arm(1,.4,-.3);B.rotation.y=-.3*e;}else{arm(1,-1.55*e,0,0);arm(0,.4,.3);B.rotation.y=.3*e;}break;}
|
| 264 |
+
case 'pickup':B.rotation.x=tk<16?.6:.1;arm(0,-1.2-(tk>16?1.2:0),.2);arm(1,-1.2-(tk>16?1.2:0),-.2);break;
|
| 265 |
+
case 'hold':arm(0,-3.0,.3);arm(1,-3.0,-.3);break;
|
| 266 |
+
case 'heavythrow':{const e=Math.min(1,tk/26);arm(0,-3+e*1.6,.3);arm(1,-3+e*1.6,-.3);B.rotation.x=-.3+e*.6;break;}
|
| 267 |
+
case 'grabbowser':B.rotation.x=tk<20?.5:-.1;B.position.y=.6;arm(0,-1.5,.2);arm(1,-1.5,-.2);break;
|
| 268 |
+
case 'swing':B.rotation.x=-.35;B.position.y=.72;arm(0,-1.57,.1);arm(1,-1.57,-.1);leg(0,.5,.3);leg(1,-.5,.3);break;
|
| 269 |
+
case 'release':{const e=Math.min(1,tk/20);B.rotation.x=-.35+e*.6;arm(0,-1.57+e*.6,.4);arm(1,-1.57+e*.6,-.4);break;}
|
| 270 |
+
case 'shockwave':B.position.y=.78+Math.abs(Math.sin(tk*.2))*.25;arm(0,-.2,1.3);arm(1,-.2,-1.3);leg(0,.25);leg(1,-.25);break;
|
| 271 |
+
case 'burnjump':case 'burnfall':leg(0,-.9,1.2);leg(1,.35,.3);arm(0,-2.6,.6);arm(1,-2.6,-.6);B.rotation.x=-.2;break;
|
| 272 |
+
case 'burnground':run();arm(0,-2.6,.5);arm(1,-2.6,-.5);break;
|
| 273 |
+
case 'grabbed':arm(0,-1.5,1.2);arm(1,-1.5,-1.2);leg(0,.4);leg(1,-.4);B.rotation.z=Math.sin(t*.4)*.25;break;
|
| 274 |
+
case 'thrown':case 'airkb':B.rotation.x=a==='thrown'?-tk*.15:-.6;arm(0,-2.6,1.1);arm(1,-2.6,-1.1);leg(0,.6,.8);leg(1,-.4,.6);break;
|
| 275 |
+
case 'kb':B.rotation.x=(m.fwd<0?-1:1)*Math.min(1.3,tk*.08);B.position.y=.78-Math.min(.35,tk*.02);arm(0,-2,.9);arm(1,-2,-.9);break;
|
| 276 |
+
case 'squished':P.root.scale.set(1.8,.06,1.8);break;
|
| 277 |
+
case 'lava':B.rotation.x=-.4;leg(0,Math.sin(t*.9)*.9,.6);leg(1,-Math.sin(t*.9)*.9,.6);arm(0,-2.6,.6);arm(1,.6,-.4);break;
|
| 278 |
+
case 'dead':B.rotation.x=-1.5;B.position.y=.25;arm(0,-2.8,.6);arm(1,-2.8,-.6);break;
|
| 279 |
+
case 'land':B.position.y=.66;leg(0,-.6,1.0);leg(1,-.6,1.0);break;
|
| 280 |
+
default:{const br=Math.sin(t*.06)*.015;B.position.y=.78+br;}
|
| 281 |
+
}
|
| 282 |
+
if(m.squish>0&&a!=='squished'){const k=1-m.squish/120;P.root.scale.set(1+.5*(1-k),Math.max(.3,k),1+.5*(1-k));}
|
| 283 |
+
}
|
| 284 |
+
poseWhomp(g){const b=g.boss,P=this.bosses.whomp,t=g.t;P.root.position.set(b.x*U,(b.y+(b.shake||0))*U,b.z*U);P.root.rotation.set(0,b.yaw,0);P.tilt.rotation.set(b.pitch,0,0);
|
| 285 |
+
P.root.visible=b.act!=='dead';const walk=b.act==='chase'&&b.fwd>0,ph=t*(.04+b.fwd*.012),prep=b.act==='prepare'?Math.min(1,b.timer/26):b.act==='jump'||b.act==='land'?1:0;
|
| 286 |
+
P.feet.forEach((f,i)=>{f.position.y=walk?Math.max(0,Math.sin(ph+i*PI))*.5:0;f.rotation.x=0;});
|
| 287 |
+
P.arms.forEach((s,i)=>s.rotation.set(prep*1.1+(walk?Math.sin(ph+i*PI)*.25:0),0,(i?1:-1)*prep*.9)); // arms swing back and out for the dive
|
| 288 |
+
if(b.act==='die'){const k=Math.min(1,b.timer/60);P.root.scale.set(1-k*.6,1-k*.9,1-k*.6);}else P.root.scale.set(1,1,1);
|
| 289 |
+
// The slab's vertical projection is its own shadow: as it tips forward this rectangle is exactly where it will land.
|
| 290 |
+
const p=b.pitch,fs=[100*Math.sin(p)-200*Math.cos(p),860*Math.sin(p)-200*Math.cos(p),100*Math.sin(p)-6*Math.cos(p),860*Math.sin(p)-6*Math.cos(p)];
|
| 291 |
+
const f0=Math.min(...fs),f1=Math.max(...fs),fc=(f0+f1)/2,fx=Math.sin(b.yaw),fz=Math.cos(b.yaw),S=this.slabShadow;
|
| 292 |
+
S.visible=b.act!=='dead';S.position.set((b.x+fx*fc)*U,.02,(b.z+fz*fc)*U);S.rotation.set(-PI/2,0,b.yaw);S.scale.set(600*U,(f1-f0)*U,1);
|
| 293 |
+
this.slabShadowMat.opacity=b.act==='die'?0:.18+.32*clamp(p/(PI/2),0,1);
|
| 294 |
+
// Readability aid (not in the 1996 game): during the wind-up and fall, the exact squish footprint f 100..860, |u|<=300.
|
| 295 |
+
const warn=b.act==='prepare'?clamp(b.timer/28,0,1):b.act==='jump'||b.act==='land'?1:0,L=this.landZone;L.visible=warn>0;
|
| 296 |
+
if(warn>0){L.position.set((b.x+fx*480)*U,.035,(b.z+fz*480)*U);L.rotation.set(-PI/2,0,b.yaw);L.scale.set(600*U,760*U,1);this.landMat.opacity=.10+.22*warn;}}
|
| 297 |
+
poseKing(g){const k=g.boss,P=this.bosses.king,t=g.t;P.root.position.set(k.x*U,k.y*U,k.z*U);P.root.rotation.set(0,k.yaw,0);P.body.rotation.set(0,0,0);P.body.position.set(0,1.32,0);
|
| 298 |
+
const walk=k.act===2&&k.fwd>0||(k.act===3&&k.sub===1),ph=t*.12;P.feet.forEach((f,i)=>{f.position.set(f.position.x,walk?Math.max(0,Math.sin(ph+i*PI))*.25:0,walk?Math.sin(ph+i*PI)*.2+.1:.1);});
|
| 299 |
+
P.arms.forEach((s,i)=>s.rotation.set(k.act===3?-1.1:walk?Math.sin(ph+i*PI)*.3:0,0,0));
|
| 300 |
+
if(k.held){P.body.rotation.x=-.3;P.arms.forEach((s,i)=>s.rotation.set(-.8,0,(i?-1:1)*.6));}
|
| 301 |
+
if(k.act===4)P.body.rotation.x=-k.timer*.12;
|
| 302 |
+
const hurt=k.act===6&&k.sub===0;P.body.children[0].material=hurt&&(t>>2)%2?this.mat.red:this.mat.black;
|
| 303 |
+
if(k.act===7){const e=Math.min(1,k.timer/60);P.root.scale.setScalar(1-e*.7);}else P.root.scale.setScalar(1);
|
| 304 |
+
P.root.visible=!(k.act===7&&k.timer>55);}
|
| 305 |
+
poseBully(g){const b=g.boss,P=this.bosses.bully,t=g.t;P.root.position.set(b.x*U,b.y*U,b.z*U);P.root.rotation.set(0,b.faceYaw,0);
|
| 306 |
+
const charge=b.act==='chase'&&b.fwd>10,ph=t*(charge?.5:.15);P.body.rotation.set(charge?.35:b.act==='knockback'&&b.fwd>2?-.35:0,0,0);
|
| 307 |
+
P.feet.forEach((f,i)=>{f.position.y=(b.act==='chase'||b.act==='patrol'||b.act==='backup')?Math.max(0,Math.sin(ph+i*PI))*.22:0;});
|
| 308 |
+
P.root.visible=b.act!=='dead'&&!(b.act==='sink'&&b.timer>58);P.body.children[0].material=b.act==='sink'?this.mat.red:this.mat.iron;}
|
| 309 |
+
poseEyerok(g){const b=g.boss,P=this.bosses.eyerok,m=g.mario,t=g.t,HB=root.Mario64Game.HAND;
|
| 310 |
+
b.hands.forEach((h,i)=>{const H=P.hands[i],dying=h.act==='die',shake=h.act==='attacked'||dying?Math.sin(t*1.7)*.05:0;H.h.visible=!h.gone&&(h.act!=='sleep'||b.act!=='sleep');
|
| 311 |
+
H.h.position.set(h.x*U,h.y*U,h.z*U);H.h.rotation.set(dying?-Math.min(1,(h.af+1)/40)*.5:0,h.face,shake);
|
| 312 |
+
// Opening takes anim 4 (30 frames), closing anim 7 (28 frames up to its check), S37: the fist folds into the raised palm.
|
| 313 |
+
const p=h.act==='open'?clamp((h.af+1)/30,0,1):h.act==='close'?clamp(1-h.timer/28,0,1):h.open?1:0;
|
| 314 |
+
H.fist.visible=p<1;H.palm.visible=p>0;H.fist.scale.set(1,Math.max(.02,1-p),1);H.palm.scale.set(1,Math.max(.02,p),1);
|
| 315 |
+
const c=h.blink/3;H.upper.position.y=.55+(1-c)*.95;H.lower.position.y=-.55-(1-c)*.95;const l=Math.atan2(m.x-h.x,m.z-h.z)-h.face;H.pupil.position.set(clamp(Math.sin(l),-1,1)*.4,clamp((m.y-h.y-260)*.001,-.3,.3),0);
|
| 316 |
+
const B=h.open?HB.open:HB.fist,w=B.x1-B.x0,dp=B.z1-B.z0,cx=(B.x0+B.x1)/2,cz=(B.z0+B.z1)/2,s=Math.sin(h.face),co=Math.cos(h.face);
|
| 317 |
+
H.shadow.visible=H.h.visible;H.shadow.position.set((h.x+cx*co+cz*s)*U,.035,(h.z-cx*s+cz*co)*U);H.shadow.scale.set(w*U,dp*U,1);H.shadow.rotation.z=h.face;});}
|
| 318 |
+
poseWiggler(g){const b=g.boss,P=this.bosses.wiggler,t=g.t,run=b.act==='walk'?t*(.05+b.fwd*.012):0,angry=b.hp<b.maxHp;
|
| 319 |
+
P.root.visible=b.act!=='dead';P.head.position.set(b.x*U,b.y*U,b.z*U);P.head.rotation.set(0,b.face,0);P.hb.rotation.x=b.pitch;const sx=b.sx/4,sy=b.sy/4;P.head.scale.set(sx,sy,sx);
|
| 320 |
+
P.eyes.forEach(e=>{e.visible=angry;});P.hb.children[0].material=P.mats[angry?1:0];
|
| 321 |
+
P.hf.forEach((f,i)=>{f.position.y=.2+Math.max(0,Math.sin(run+i*PI))*.25;});
|
| 322 |
+
P.parts.forEach((q,i)=>{const s=b.s[i+1];q.p.position.set((s.px??s.x)*U,s.y*U,(s.pz??s.z)*U);q.p.rotation.set(0,s.yaw,0);q.p.scale.set(sx,sx,sx);q.q.rotation.x=s.pitch;q.q.children[0].material=P.mats[angry?1:0];
|
| 323 |
+
q.feet.forEach((f,j)=>{f.position.y=.2+Math.max(0,Math.sin(run+(i+1)*1.4+j*PI))*.22;});});}
|
| 324 |
+
poseBowser(g){const b=g.boss,P=this.bosses.bowser,t=g.t,B=P.body;P.tip.material=b.guard>0||b.tail===1?P.tipOff:P.tipOn;P.root.visible=b.op>=30;P.root.position.set(b.x*U,b.y*U,b.z*U);P.root.rotation.set(0,b.yaw,0);B.rotation.set(0,0,0);B.position.set(0,0,0);P.head.rotation.set(0,0,0);P.tail.rotation.set(0,0,0);
|
| 325 |
+
const f=Math.max(0,b.af),walk=(b.act==='walk'&&b.fwd>0)?Math.sin(t*.09):0;P.limbs[0].rotation.x=walk*.5;P.limbs[1].rotation.x=-walk*.5;P.limbs[2].rotation.x=-.6-walk*.3;P.limbs[3].rotation.x=-.6+walk*.3;P.tail.rotation.y=Math.sin(t*.05)*.2;
|
| 326 |
+
switch(b.act){
|
| 327 |
+
case 'breath':{const e=f<46?-Math.min(1,f/30)*.5:Math.min(1,(f-46)/8)*.3;P.head.rotation.x=e;B.rotation.x=e*.3;break;}
|
| 328 |
+
case 'dance':B.rotation.z=Math.sin(f*.18)*.22;P.limbs[2].rotation.x=-2.5;P.limbs[3].rotation.x=-2.5;break;
|
| 329 |
+
case 'quickjump':P.limbs[0].rotation.x=.6;P.limbs[1].rotation.x=.6;break;
|
| 330 |
+
case 'held':B.rotation.x=-1.2;B.position.y=.9;B.rotation.z=Math.sin(t*.5)*.08;break;
|
| 331 |
+
case 'thrown':if(b.sub===0){B.rotation.x=-1.2+Math.sin(t*.6)*.25;B.position.y=.7;}else{const e=Math.min(1,f/30);B.rotation.x=-1.2*(1-e);B.position.y=.7*(1-e);}break;
|
| 332 |
+
case 'hitmine':case 'dead':B.rotation.x=b.sub<2?-(t*.25)%(PI*2):-Math.max(0,1-f/30)*1.5;B.position.y=.9;break;
|
| 333 |
+
case 'jumpstage':B.rotation.x=(b.spin&0xffff)/65536*PI*2;break;
|
| 334 |
+
}
|
| 335 |
+
P.mines.forEach((q,i)=>{const n=b.mines[i];q.p.visible=this.kind==='bowser'&&n.alive;q.p.position.set(n.x*U,n.y*U,n.z*U);q.q.rotation.y=t*.01;});}
|
| 336 |
+
// ---------------- effects ----------------
|
| 337 |
+
effects(g){const pools=this.pools,o=this.o,n={dust:0,star:0,ring:0,fire:0,ember:0};
|
| 338 |
+
const put=(pool,x,y,z,s,rx=0,ry=0)=>{const P=pools[pool];if(n[pool]>=P.instanceMatrix.count)return;o.position.set(x,y,z);o.rotation.set(rx,ry,0);o.scale.set(s,s,s);o.updateMatrix();P.setMatrixAt(n[pool]++,o.matrix);};
|
| 339 |
+
const putRing=(x,y,z,r)=>{const P=pools.ring;if(n.ring>=P.instanceMatrix.count)return;o.position.set(x,y,z);o.rotation.set(-PI/2,0,0);o.scale.set(r,r,r);o.updateMatrix();P.setMatrixAt(n.ring++,o.matrix);};
|
| 340 |
+
items(g.effects).forEach((e,idx)=>{const age=1-e.life/e.maxLife,x=e.x*U,y=(e.y||0)*U,z=e.z*U;
|
| 341 |
+
switch(e.type){
|
| 342 |
+
case 'pound':case 'slam_dust':case 'bump':{const big=e.type==='slam_dust'?3.2:e.type==='pound'?1.4:.6;putRing(x,y+.05,z,.3+big*age*1.6);
|
| 343 |
+
for(let i=0;i<10;i++){const a=i*PI/5+idx,r=.2+big*age*1.4;put('dust',x+Math.sin(a)*r,y+.25+age*.6*big*.3,z+Math.cos(a)*r,(.28+.25*big*.3)*(1-age*.6));}
|
| 344 |
+
if(e.type==='pound')for(let i=0;i<6;i++){const a=i*PI/3,r=.4+age*1.5;put('star',x+Math.sin(a)*r,y+.5+Math.sin(age*PI)*.8,z+Math.cos(a)*r,.16,age*6,a);}break;}
|
| 345 |
+
case 'impact':case 'hit_star':for(let i=0;i<8;i++){const a=i*PI/4+idx*.3,r=.3+age*1.8;put('star',x+Math.sin(a)*r,y+1.2+Math.cos(a*2)*.4+age*.6,z+Math.cos(a)*r,.2*(1-age*.5),age*8,a);}break;
|
| 346 |
+
case 'lava_burst':for(let i=0;i<12;i++){const a=i*PI/6+idx,r=.2+age*1.2;put('fire',x+Math.sin(a)*r,y+.3+age*2.2*(.5+hash(i,idx,3)),z+Math.cos(a)*r,.35*(1-age));}break;
|
| 347 |
+
case 'mist':for(let i=0;i<18;i++){const a=i*.7+idx,r=.8+age*3;put('dust',x+Math.sin(a)*r,y+1+age*2+(i%4)*.5,z+Math.cos(a)*r,.9*(1-age*.7));}break;
|
| 348 |
+
}});
|
| 349 |
+
if(this.kind==='bowser'){const b=g.boss;
|
| 350 |
+
b.flames.forEach((f,i)=>{const r=f.s*.1;put('fire',f.x*U,f.y*U,f.z*U,r,g.t*.1,i);});
|
| 351 |
+
b.fires.forEach((f,i)=>{const r=f.s*.1,k=1+Math.sin(g.t*.3+i)*.15;put('fire',f.x*U,(f.y+f.s*14)*U,f.z*U,r*k,g.t*.08,i);put('fire',f.x*U,(f.y+f.s*30)*U,f.z*U,r*.6/k,g.t*.1,i+1);});
|
| 352 |
+
if(['burnjump','burnfall','burnground'].includes(g.mario.action))for(let i=0;i<7;i++){const a=i*.9+g.t*.25,m=g.mario;put('fire',m.x*U+Math.sin(a)*.3,m.y*U+.5+(i%4)*.35,m.z*U+Math.cos(a)*.3,.2,g.t*.2,i);}}
|
| 353 |
+
if(this.kind==='bully')for(let i=0;i<24;i++){const ph=((g.t*.004+hash(i,1,91))%1),a=hash(i,2,91)*PI*2,d=10+hash(i,3,91)*40;put('ember',Math.sin(a)*d,-3+ph*14,Math.cos(a)*d,.12*(1-ph),ph*9,a);}
|
| 354 |
+
for(const k of Object.keys(pools)){pools[k].count=n[k];pools[k].instanceMatrix.needsUpdate=true;}}
|
| 355 |
+
shadows(g){const m=g.mario,b=g.boss,fl=typeof g.floor==='function'?g.floor(m.x,m.z,m.y+1):{y:0};const my=fl?fl.y:-1e4;
|
| 356 |
+
this.marioBlob.visible=!!fl&&m.action!=='squished'&&m.y-my<2500;this.marioBlob.position.set(m.x*U,my*U+.04,m.z*U);const k=clamp(1-(m.y-my)/1600,.35,1);this.marioBlob.scale.set(.45*k,.45*k,1);
|
| 357 |
+
const r=b.kind==='whomp'||b.kind==='eyerok'?0:b.kind==='bowser'?(b.op<100||b.held?0:1.9):b.kind==='wiggler'?1.3:b.kind==='king'?1.25:1.2;this.bossBlob.visible=r>0&&b.y>-50&&!(b.kind==='king'&&b.held)&&b.act!=='dead';this.bossBlob.position.set(b.x*U,(b.kind==='wiggler'?g.floor(b.x,b.z,b.y).y*U:0)+.03,b.z*U);this.bossBlob.scale.set(r,r,1);}
|
| 358 |
+
render(g,ctx){
|
| 359 |
+
if(this.closed||this.renderer.getContext().isContextLost()){this.ready=false;this.error=this.closed?'3D renderer is closed':'WebGL context lost';throw Error(this.error);}const start=performance.now();
|
| 360 |
+
try{const kind=g.boss.kind;this.setKind(kind,g.arena);this.poseMario(g);
|
| 361 |
+
if(kind==='whomp')this.poseWhomp(g);else if(kind==='king')this.poseKing(g);else if(kind==='eyerok')this.poseEyerok(g);else if(kind==='wiggler')this.poseWiggler(g);else if(kind==='bowser')this.poseBowser(g);else this.poseBully(g);
|
| 362 |
+
this.slabShadow.visible=kind==='whomp'&&this.slabShadow.visible;this.landZone.visible=kind==='whomp'&&this.landZone.visible;this.shadows(g);this.effects(g);
|
| 363 |
+
if(this.lavaTex)this.lavaTex.offset.set((g.t*.0006)%1,(g.t*.0004)%1);
|
| 364 |
+
const c=g.cam,m=g.mario,d=c.dist*U,p=c.pitch,tx=m.x*U,ty=Math.max(m.y*U,-2.5)+.95,tz=m.z*U;
|
| 365 |
+
this.camera.position.set(tx-Math.sin(c.yaw)*d*Math.cos(p),ty+d*Math.sin(p),tz-Math.cos(c.yaw)*d*Math.cos(p));
|
| 366 |
+
if(kind==='wiggler'){const P=this.camera.position,cl=(v,a,b)=>clamp(v,a+.4,b-.4);P.x=cl(P.x,-20.64,20.31);P.z=cl(P.z,-19.85,21.1);P.y=clamp(P.y,g.floor(P.x/U,P.z/U,1e4).y*U+.6,15.6);} // closed room (S41): the view stays inside its walls
|
| 367 |
+
this.camera.lookAt(tx+Math.sin(c.yaw)*1.4,ty+.15,tz+Math.cos(c.yaw)*1.4);
|
| 368 |
+
this.renderer.info.reset();this.renderer.render(this.world,this.camera);ctx.drawImage(this.view,0,0,854,480);
|
| 369 |
+
this.times.push(performance.now()-start);if(this.times.length>120)this.times.shift();this.ready=true;this.error=null;
|
| 370 |
+
}catch(e){this.ready=false;this.error=String(e);throw e;}
|
| 371 |
+
}
|
| 372 |
+
metrics(){const info=this.renderer.info,sorted=[...this.times].sort((a,b)=>a-b);let geometryBytes=0,textureBytes=0;
|
| 373 |
+
for(const r of this.resources){if(r.isBufferGeometry){for(const a of Object.values(r.attributes))geometryBytes+=a.array.byteLength;if(r.index)geometryBytes+=r.index.array.byteLength;}
|
| 374 |
+
if(r.isTexture&&r.image)textureBytes+=(r.image.width||0)*(r.image.height||0)*4;if(r.isInstancedMesh)geometryBytes+=r.instanceMatrix.array.byteLength;}
|
| 375 |
+
return {renderer:'webgl-mario64',webglVersion:this.renderer.capabilities.isWebGL2?2:1,drawCalls:info.render.calls,triangles:info.render.triangles,geometries:info.memory.geometries,
|
| 376 |
+
textures:info.memory.textures,geometryBytes,textureBytes,canvasBytes:854*480*4,resourceBytesEstimate:geometryBytes+textureBytes+854*480*8,staticAssetBytes:669884,
|
| 377 |
+
renderSamples:sorted.length,cpuRenderMsP50:sorted.length?sorted[Math.floor((sorted.length-1)*.5)]:null,cpuRenderMsP95:sorted.length?sorted[Math.floor((sorted.length-1)*.95)]:null,
|
| 378 |
+
shadows:'blob shadows (N64 style) + projected slab footprint; no shadow maps',postprocess:false};}
|
| 379 |
+
close(){if(this.closed)return;this.closed=true;this.ready=false;if(this.skyTex)this.skyTex.dispose();this.resources.forEach(r=>r.dispose?.());this.renderer.dispose();this.renderer.forceContextLoss();this.resources.clear();}
|
| 380 |
+
}
|
| 381 |
+
R.render=function(g,ctx){let s=byCanvas.get(ctx.canvas);if(!s||s.closed){s=new Scene(ctx.canvas);byCanvas.set(ctx.canvas,s);}s.render(g,ctx);return s;};
|
| 382 |
+
R.status=function(ctx){const s=ctx&&byCanvas.get(ctx.canvas);if(s&&!s.closed&&s.renderer.getContext().isContextLost()){s.ready=false;s.error='WebGL context lost';}
|
| 383 |
+
return {renderer:'webgl-mario64',kind:'perspective',ready:!!s?.ready&&!s.closed,error:s?.error||null};};
|
| 384 |
+
R.metrics=function(ctx){const s=ctx&&byCanvas.get(ctx.canvas);return s?s.metrics():null;};
|
| 385 |
+
R.scene=function(ctx){return ctx&&byCanvas.get(ctx.canvas)||null;};
|
| 386 |
+
R.close=function(ctx){const s=ctx&&byCanvas.get(ctx.canvas);if(s){s.close();byCanvas.delete(ctx.canvas);}};
|
| 387 |
+
})(window);
|
environments/games/web/games/mario64_remake/style3d.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
:root{color-scheme:dark;--bg:#14191a;--panel:#1d2425;--edge:#354141;--text:#ebe7dc;--muted:#a5b2ad;--accent:#dfb676}*{box-sizing:border-box}body{margin:0;background:radial-gradient(ellipse at top,#29312b,transparent 60%),var(--bg);color:var(--text);font:14px/1.7 'Segoe UI','Microsoft YaHei',sans-serif}body[data-game=genshin_remake]{--bg:#101822;--panel:#1b2530;--edge:#374754;--accent:#baacff;background:radial-gradient(ellipse at top,#2b2942,transparent 60%),var(--bg)}body[data-game=mario64_remake]{--bg:#0f1530;--panel:#18214a;--edge:#34407a;--text:#f3f1ea;--muted:#aeb7dd;--accent:#ffd23a;background:radial-gradient(ellipse at top,#2b3a8a,transparent 62%),radial-gradient(ellipse at bottom right,#5a1616,transparent 55%),var(--bg)}body[data-game=mario64_remake] h1{font-family:"Segoe UI","Microsoft YaHei",sans-serif;font-weight:800;letter-spacing:.5px;text-shadow:0 3px 0 #b81d22,0 6px 14px #0008}body[data-game=mario64_remake] button.primary{background:#e52521;color:#fff}body[data-game=mario64_remake] .stage{border-color:#ffd23a55}main{max-width:1220px;margin:auto;padding:28px 24px 40px}header{display:flex;align-items:center;justify-content:space-between;margin-bottom:22px;gap:20px}.eyebrow{color:var(--accent);font-size:11px;letter-spacing:2.5px;text-transform:uppercase}h1{font:500 32px/1.35 Georgia,'Microsoft YaHei',serif;letter-spacing:1px;margin:6px 0}header p{color:var(--muted);margin:0;font-size:13px}a{color:var(--accent);text-decoration:none}a:hover{text-decoration:underline}.layout{display:grid;grid-template-columns:minmax(0,854px) 245px;gap:24px;align-items:start}.stage{position:relative;border:1px solid var(--edge);box-shadow:0 22px 55px #0005;background:#111b1c}canvas{display:block;width:100%;aspect-ratio:854/480;touch-action:none;outline:none}canvas:focus-visible{outline:2px solid var(--accent);outline-offset:3px}#overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:#10171b30;pointer-events:none}#overlay[hidden]{display:none}#overlay div{background:#111b23de;padding:19px 32px;border:1px solid #9ba6a655;max-width:80%;text-align:center}#overlay strong{font:500 24px Georgia,'Microsoft YaHei',serif;display:block}#overlay span{display:block;color:var(--muted);font-size:12px;margin-top:7px}.toolbar{display:flex;gap:8px;flex-wrap:wrap;padding:12px;background:var(--panel);border-top:1px solid var(--edge)}button,select,input{font:inherit;background:var(--panel);color:var(--text);border:1px solid var(--edge);border-radius:4px;padding:7px 11px}button{cursor:pointer}button:hover{border-color:var(--accent);background:#ffffff09}button.primary{background:var(--accent);color:var(--bg);font-weight:600}button:focus-visible,select:focus-visible,input:focus-visible,a:focus-visible{outline:2px solid var(--accent);outline-offset:3px}aside{padding:19px;border:1px solid var(--edge);background:var(--panel)}h2{font-size:16px;margin:0 0 8px}label{display:block;font-size:12px;color:var(--muted);margin:12px 0 5px}select,input{width:100%}dl{border-top:1px solid var(--edge);padding-top:16px;margin:18px 0 0}dt{color:var(--accent);font:12px/1.8 Consolas,monospace}dd{color:var(--muted);font-size:12px;margin:0 0 10px}.note{color:var(--muted);font-size:12px}#status{min-height:25px;margin:10px 0;color:var(--accent);overflow-wrap:anywhere}.record-toolbar{border:1px solid var(--edge);padding:10px;background:transparent}.record-toolbar button{font-size:12px}#file{display:none}.mobile{display:none}footer{display:flex;flex-wrap:wrap;gap:22px;border-top:1px solid var(--edge);margin-top:28px;padding-top:15px;font-size:12px}@media(max-width:950px){main{padding:14px}.layout{grid-template-columns:1fr}aside{display:grid;grid-template-columns:1fr 1fr;gap:0 18px}aside dl,aside .note{grid-column:1/-1}dl{columns:2}.mobile{display:flex;gap:8px;flex-wrap:wrap;margin-top:10px}.mobile button{min-width:45px;touch-action:none}header{align-items:start}h1{font-size:26px}}@media(max-width:500px){header{display:block}header a{font-size:12px}aside{padding:14px}#overlay div{padding:14px 20px}#overlay strong{font-size:19px}.toolbar{gap:6px;padding:8px}button{font-size:12px}h1{font-size:25px}}
|
environments/games/web/games/megaman_remake/arena.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Mega Man (NES, 1987) on the BB.Case engine: shared rules for the Robot Master rooms.
|
| 2 |
+
// World units are NES pixels. A room is 256 x 240 with the origin at the top-left and y growing downward, as the
|
| 3 |
+
// original stores positions; one 60 Hz tick is one NES frame. Speeds are px/frame written as the original 8.8
|
| 4 |
+
// fixed-point values (MM.fx(0x4DF) = 4.87109375), so every constant can be checked against the disassembly cited
|
| 5 |
+
// in SOURCES.md. Energy and damage are NES units (one bar = 28 units); hit points are reported as points =
|
| 6 |
+
// units x 18, so one full NES bar is 504 points (the 2026-11-02 meeting asks for ~500 on easy).
|
| 7 |
+
// Update order of one tick follows the original main loop (bank 5 $915E): player update -> weapon flight
|
| 8 |
+
// services -> boss AI -> player i-frame countdown -> player contact -> shot collision -> entity motion ->
|
| 9 |
+
// render-time counters (boss i-frames, animation timers). body_megaman.js resolveInteractions() runs the part
|
| 10 |
+
// after the boss AI.
|
| 11 |
+
(function (g) {
|
| 12 |
+
var B = g.BB;
|
| 13 |
+
B.ARENA = { W: 256, H: 240 };
|
| 14 |
+
var MM = B.MM = {};
|
| 15 |
+
|
| 16 |
+
MM.fx = function (hex) { return hex / 256; }; // 8.8 fixed point -> px/frame
|
| 17 |
+
MM.FLOOR = 192; // floor top of every boss room; a standing 24 px body has its centre at y = 180
|
| 18 |
+
MM.WALL_L = 16; MM.WALL_R = 240; // inner faces of the side walls
|
| 19 |
+
MM.UNIT = 18; MM.BAR = 28;
|
| 20 |
+
MM.GRAVITY = MM.fx(0x40); // -0.25 px/frame^2 for the player and every entity with gravity
|
| 21 |
+
MM.FALL_MAX = 12; // terminal velocity -0C.00
|
| 22 |
+
MM.TOP_EXIT = 4; MM.BOTTOM_EXIT = 0xE8; // entity y outside [4, $E8) has left the screen
|
| 23 |
+
|
| 24 |
+
MM.box = function (x, y, hw, hh) { return { x: x, y: y, hw: hw, hh: hh }; };
|
| 25 |
+
// hitbox_overlap_test ($C9BE) on integer pixel positions: e = the tested entity (boss, boss shot), b = the
|
| 26 |
+
// probing box (a player shot or the player's touch box). Top/bottom compare strict/inclusive, sides inclusive.
|
| 27 |
+
MM.overlap = function (e, b) {
|
| 28 |
+
var ex = Math.floor(e.x), ey = Math.floor(e.y), bx = Math.floor(b.x), by = Math.floor(b.y);
|
| 29 |
+
return ey - e.hh < by + b.hh && ey + e.hh >= by - b.hh && ex - e.hw <= bx + b.hw && ex + e.hw >= bx - b.hw;
|
| 30 |
+
};
|
| 31 |
+
MM.offscreen = function (o) { return o.x < 0 || o.x >= 256 || o.y < MM.TOP_EXIT || o.y >= MM.BOTTOM_EXIT; };
|
| 32 |
+
MM.r = function (v) { return B.r4(v); };
|
| 33 |
+
MM.snapshot = function (v) {
|
| 34 |
+
if (typeof v === 'number') return B.r4(v);
|
| 35 |
+
if (Array.isArray(v)) return v.map(MM.snapshot);
|
| 36 |
+
if (v && typeof v === 'object') { var o = {}; Object.keys(v).forEach(function (k) { o[k] = MM.snapshot(v[k]); }); return o; }
|
| 37 |
+
return v;
|
| 38 |
+
};
|
| 39 |
+
// tier knobs: spec rows are [easy, normal, hard] at d = 0 / 0.5 / 1, the values BB.GAME.tiers declares,
|
| 40 |
+
// so the public tiers read the spec rows exactly and any d in between interpolates (BB.knobs).
|
| 41 |
+
MM.knobs = function (spec, d) { return B.knobs(spec.difficulty, d); };
|
| 42 |
+
|
| 43 |
+
// Shared entity physics (boss_walk_tick $EDF8 + vertical_collision $9BC4): x moves by |vx| along dir with a
|
| 44 |
+
// wall clamp (o.blocked = the $2A wall probe); y -= vy (up = positive); a falling body that reaches the floor
|
| 45 |
+
// snaps onto it with the grounded hold velocity $FF.40 (o.landed = the $2B probe, set again every frame it
|
| 46 |
+
// stands); otherwise gravity applies if o.grav. Ice Man's descent relies on the hold value being negative.
|
| 47 |
+
MM.GROUND_VY = -(1 - MM.fx(0x40));
|
| 48 |
+
MM.step = function (o) {
|
| 49 |
+
o.blocked = false; o.landed = false;
|
| 50 |
+
if (o.vx) {
|
| 51 |
+
var nx = o.x + o.vx * o.dir, lo = MM.WALL_L + o.hw, hi = MM.WALL_R - o.hw;
|
| 52 |
+
if (nx < lo) { nx = lo; o.blocked = true; } else if (nx > hi) { nx = hi; o.blocked = true; }
|
| 53 |
+
if (o.room && o.room.length) { var cx = MM.clampX(o.room, o.x, nx, o.hw, o.y, o.hh); if (cx !== nx) { nx = cx; o.blocked = true; } }
|
| 54 |
+
o.x = nx;
|
| 55 |
+
}
|
| 56 |
+
var ny = o.y - o.vy, floor = o.room && o.room.length ? MM.floorUnder(o.room, o.x - o.hw + 1, o.x + o.hw - 1, o.y + o.hh) : MM.FLOOR;
|
| 57 |
+
if (o.vy < 0 && ny + o.hh >= floor) { o.y = floor - o.hh; o.vy = MM.GROUND_VY; o.landed = true; o.grounded = true; return; }
|
| 58 |
+
o.y = ny; o.grounded = false;
|
| 59 |
+
if (o.grav) o.vy = Math.max(-MM.FALL_MAX, o.vy - MM.GRAVITY);
|
| 60 |
+
};
|
| 61 |
+
|
| 62 |
+
// Room solids beyond the side walls and the floor: the scene's collision override records and solid step tiles,
|
| 63 |
+
// as rectangles {x0, x1, y0, y1} (x1/y1 exclusive). The flat rooms have none (MM.ROOMS has no entry), and every
|
| 64 |
+
// caller skips these helpers for an empty list, so their arithmetic is exactly the flat-room one.
|
| 65 |
+
MM.ROOMS = {};
|
| 66 |
+
MM.roomOf = function (caseId) { return MM.ROOMS[caseId] || []; };
|
| 67 |
+
// Cut Man's and Guts Man's rooms have the same step: solid tiles x 16-32 and two liftable blocks x 32-64, 64-96 (override
|
| 68 |
+
// type 2), top y 160. A lifted block leaves the body's and the boss's own copy of the list, never this table.
|
| 69 |
+
MM.blockRoom = function (caseId) {
|
| 70 |
+
MM.ROOMS[caseId] = [{ x0: 16, x1: 32, y0: 160, y1: 192 }, { x0: 32, x1: 64, y0: 160, y1: 192, block: true }, { x0: 64, x1: 96, y0: 160, y1: 192, block: true }];
|
| 71 |
+
};
|
| 72 |
+
// override_search on the record bounds: x0 <= x < x1, y0 <= y < y1; returns the liftable block there or null
|
| 73 |
+
MM.blockAt = function (room, x, y) {
|
| 74 |
+
for (var i = 0; i < room.length; i++) {
|
| 75 |
+
var r = room[i];
|
| 76 |
+
if (r.block && r.x0 <= x && x < r.x1 && r.y0 <= y && y < r.y1) return r;
|
| 77 |
+
}
|
| 78 |
+
return null;
|
| 79 |
+
};
|
| 80 |
+
// top of the highest surface under the span [x0, x1] at or below a body whose bottom is at `bottom`
|
| 81 |
+
// (vertical_collision probes the two side edges of the body: x +- (half-width - 1) for entities, x +- 7 for Mega Man)
|
| 82 |
+
MM.floorUnder = function (room, x0, x1, bottom) {
|
| 83 |
+
var f = MM.FLOOR;
|
| 84 |
+
for (var i = 0; i < room.length; i++) {
|
| 85 |
+
var r = room[i];
|
| 86 |
+
if (x1 >= r.x0 && x0 < r.x1 && r.y0 >= bottom - 1e-9 && r.y0 < f) f = r.y0;
|
| 87 |
+
}
|
| 88 |
+
return f;
|
| 89 |
+
};
|
| 90 |
+
// wall probe against the room solids (move_right/move_left): a body whose bottom is below a solid's top is pushed
|
| 91 |
+
// back out to the side it came from
|
| 92 |
+
MM.clampX = function (room, x, nx, hw, y, hh) {
|
| 93 |
+
for (var i = 0; i < room.length; i++) {
|
| 94 |
+
var r = room[i];
|
| 95 |
+
if (y + hh > r.y0 + 1e-9 && y - hh < r.y1 && nx - hw < r.x1 && nx + hw > r.x0) nx = x >= (r.x0 + r.x1) / 2 ? r.x1 + hw : r.x0 - hw;
|
| 96 |
+
}
|
| 97 |
+
return nx;
|
| 98 |
+
};
|
| 99 |
+
|
| 100 |
+
// proportional_velocity ($F8C6) with fraction_divide / divide_24_16: the major axis gets the full speed, the minor one
|
| 101 |
+
// speed x minor / major through two 8.8 divisions (truncating like the 16-step long division). dy = source - target
|
| 102 |
+
// y; a target below takes |dy| with EOR #$FF (one less, as the original) and a downward Y speed. speedRaw is 8.8 raw.
|
| 103 |
+
MM.propVel = function (speedRaw, adx, dy) {
|
| 104 |
+
var up = dy >= 0, ady = up ? dy & 0xFF : (~dy) & 0xFF;
|
| 105 |
+
function frac(a, divRaw) { return divRaw ? Math.floor(a * 65536 / divRaw) & 0xFFFF : 0xFFFF; }
|
| 106 |
+
var major = speedRaw, minor;
|
| 107 |
+
if (adx >= ady) minor = frac(ady, frac(adx, major)); else minor = frac(adx, frac(ady, major));
|
| 108 |
+
var vx = (adx >= ady ? major : minor) / 256, vy = (adx >= ady ? minor : major) / 256;
|
| 109 |
+
return { vx: vx, vy: up ? vy : -vy, ady: ady };
|
| 110 |
+
};
|
| 111 |
+
|
| 112 |
+
// Boss projectiles live in enemy slots $10-$1F (find_free_slot from $10); the player's contact check tests
|
| 113 |
+
// only the slots whose parity matches the frame counter (player_contact_service $A18B).
|
| 114 |
+
MM.freeSlot = function (list) {
|
| 115 |
+
for (var s = 16; s < 32; s++) if (!list.some(function (p) { return p.slot === s; })) return s;
|
| 116 |
+
return -1;
|
| 117 |
+
};
|
| 118 |
+
})(typeof window !== 'undefined' ? window : globalThis);
|
environments/games/web/games/megaman_remake/art/scenes.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Scene hooks the shared renderer expects (ART.scene / ART.ambient). Mega Man draws its whole picture in
|
| 2 |
+
// draw/hud.js (BODY_DRAW.megaman.fullHud), so the background and foreground here are empty 1x1 layers.
|
| 3 |
+
(function (g) {
|
| 4 |
+
var B = g.BB, A = B.ART;
|
| 5 |
+
var blank = {};
|
| 6 |
+
A.scene = function (doc, id) {
|
| 7 |
+
if (!blank[id]) {
|
| 8 |
+
var bg = doc.createElement('canvas'), fg = doc.createElement('canvas');
|
| 9 |
+
bg.width = bg.height = fg.width = fg.height = 1;
|
| 10 |
+
blank[id] = { bg: bg, fg: fg };
|
| 11 |
+
}
|
| 12 |
+
return blank[id];
|
| 13 |
+
};
|
| 14 |
+
A.ambient = function () {};
|
| 15 |
+
})(typeof window !== 'undefined' ? window : globalThis);
|
environments/games/web/games/megaman_remake/body_megaman.js
ADDED
|
@@ -0,0 +1,471 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Mega Man, the player body (NES 1987 rules; no slide and no charge shot - those arrived in Mega Man 3 and 4).
|
| 2 |
+
// Constants are the ROM's 8.8 values (bank 5 player_update $94A8, TASVideos Rockman data for RM1):
|
| 3 |
+
// walk 01.60 after a start-up of 9 frames at 00.20; releasing the d-pad at top speed slides 13 frames at 00.80;
|
| 4 |
+
// air X 01.50 (00.20 on the first frame of a fresh press); jump 04.DF up, gravity 00.40, fall cap 12;
|
| 5 |
+
// releasing jump while still rising at 02.00 or more sets the rise to 01.00 (player_fall_cap).
|
| 6 |
+
// Touch box 14 x 22 (x +-7, y +-11); the wall/floor body is 16 x 24.
|
| 7 |
+
// A hit costs the damage, starts 29 frames of knockback (a 01.40 hop, drifting 00.90 along the attacker's facing,
|
| 8 |
+
// no control) and 111 ($6F) frames of blinking invulnerability. Weapons: Buster (3 shots, 4 px/frame), Thunder
|
| 9 |
+
// Beam (three-way crawling bolt), Ice Slasher (piercing), Fire Storm (wave + 32-frame orbit shield), Hyper Bomb
|
| 10 |
+
// (three bounces, 146-frame fuse, 12-way flames), Rolling Cutter (piercing, flies out 42 frames and homes back), Super Arm
|
| 11 |
+
// (lifts a block of the room, throws it, it shatters into 4 chunks); 28 units each.
|
| 12 |
+
(function (g) {
|
| 13 |
+
var B = g.BB, MM = B.MM, fx = MM.fx;
|
| 14 |
+
var WALK = fx(0x160), START = fx(0x20), SLIDE = fx(0x80), AIR = fx(0x150);
|
| 15 |
+
// knockback (special state 3, $9742): anim $12 runs 30 frames; entering it sets Y velocity 01.40 (a small hop)
|
| 16 |
+
// and the speed row for anim $12 ($9DDD list index 5 -> $9DE6 row 9 -> $8643 = 00.90) drifts him along the
|
| 17 |
+
// attacker's facing
|
| 18 |
+
var JUMP = fx(0x4DF), KNOCK = fx(0x90), KNOCK_VY = fx(0x140);
|
| 19 |
+
// anim $12 (30-frame cycle) starts at frame 1 on the frame after the hit, so it wraps after 29 frames and control
|
| 20 |
+
// returns on the 30th (player_state_exit). knockT is set on the hit frame and counted down at its end too.
|
| 21 |
+
var START_T = 9, SLIDE_T = 13, KNOCK_T = 30, IFRAMES = 0x6F, HW = 7, HH = 11, BODY_HW = 8, BODY_HH = 12;
|
| 22 |
+
// Thunder Beam crawl chain (thunder_flight, tables $A5A9 x / $A5B1 y / $A5B9 next anim): when a forward piece's
|
| 23 |
+
// 10-frame animation wraps it jumps ahead and changes shape; row = animation - $62. Half sizes from $FAB5/$FB83.
|
| 24 |
+
MM.PLAYER_BOLT = { jx: [28, 32, 32, 28, 24, 28, 28, 28], jy: [-4, -24, 0, 28, 16, -12, -4, -4],
|
| 25 |
+
next: [5, 6, 7, 1, 2, 3, 4, 5], hw: [4, 8, 4, 4, 4, 8, 8, 4], hh: [8, 4, 8, 8, 8, 4, 4, 8] };
|
| 26 |
+
// records 6-$0A (dx, dy) and the frames until the first wrap: start frames $40,$30,$20,$10,$01 stagger it
|
| 27 |
+
var THUNDER = [[16, -4, 2], [20, 8, 4], [24, -4, 6], [32, -20, 8], [40, -20, 9]];
|
| 28 |
+
// Fire Storm shield orbit ($A4FA y / $A502 x): offset index = frames since the shot & 7, gone at 32
|
| 29 |
+
var ORBIT_Y = [20, 14, 0, -14, -20, -14, 0, 14], ORBIT_X = [0, -14, -20, -14, 0, 14, 20, 14];
|
| 30 |
+
// spread_shot_spawn rows 0..11 ($F88A-$F8BA), shared by the boss bomb's shrapnel and the Hyper Bomb's flames:
|
| 31 |
+
// [X speed, Y speed (+ = up), facing right ($40 in $F8BA)]
|
| 32 |
+
var D = fx(0x160);
|
| 33 |
+
MM.SPREAD = [[0, 2, 0], [2, 0, 1], [0, -2, 0], [2, 0, 0], [D, D, 1], [D, -D, 1], [D, -D, 0], [D, D, 0],
|
| 34 |
+
[0, fx(0xC0), 0], [fx(0xC0), 0, 1], [0, -fx(0xC0), 0], [fx(0xE0), 0, 0]];
|
| 35 |
+
// Hyper Bomb: record $0D (anim $5D, Y 03.00, X 01.80, dy -4, dx +12); bomb_flight bursts at $61 = $92, cleans up at $A0
|
| 36 |
+
var BOMB_FUSE = 0x92, BOMB_END = 0xA0;
|
| 37 |
+
// the quake's stun is special state 2 (anim $13, rate $57 = 48 frames from frame byte 1): 47 frames without control, moving
|
| 38 |
+
// backwards at 00.20 (row 1 of $9DE6), with Y velocity 00.E0 re-applied at frame bytes $01, $21, $41 (stunT 47, 31, 15)
|
| 39 |
+
var STUN_T = 47, STUN_VY = fx(0xE0);
|
| 40 |
+
// Super Arm: block half size by stage ($A888: anim $6C 16 x 16 for Cut Man, $32 14 x 14 for Guts Man); thrown block
|
| 41 |
+
// (record 3) Y 03.00, X 03.A0, dy -16, dx +16; chunks ($F826-$F832: x, y, X speed, Y speed), half size 4 x 4
|
| 42 |
+
var BLOCK_HALF = { 'megaman/cut_man': 16, 'megaman/guts_man': 14 }, THROW_VX = fx(0x3A0), THROW_VY = 3, ARM_LIFT = 26;
|
| 43 |
+
var CHUNKS = [[8, 8, 4, 2], [24, 8, 4, 0], [8, 24, 3, 2], [24, 24, 3, 0]];
|
| 44 |
+
|
| 45 |
+
function MegaMan() {}
|
| 46 |
+
var P = MegaMan.prototype;
|
| 47 |
+
P.id = 'megaman';
|
| 48 |
+
P.keys = { left: 'A', right: 'D', up: 'W', down: 'S', jump: 'Space', fire: 'J|LMB', prev: 'Q', next: 'E' };
|
| 49 |
+
P.NAIL = 0; P.HITSTOP = 0; P.slashFacing = 1;
|
| 50 |
+
P.manual = [
|
| 51 |
+
'A/D move left and right (9 slow startup frames and 13 frames of sliding after release, as in the NES original). Space jumps; hold it to jump higher. Releasing while rising immediately slows the ascent',
|
| 52 |
+
'J or left mouse button fires one shot per press; at most three Arm Gun shots can be on screen. The first game has neither sliding nor charged shots',
|
| 53 |
+
'Q/E cycles acquired special weapons (Returning Blade / Pierce Dart / Fuse Lob / Orbit Guard / Tri Arc / Rock Throw). Each shot costs one energy unit, except Fuse Lob and Rock Throw, which cost two; each weapon has 28 units. You cannot switch while a timed bomb or rock remains active',
|
| 54 |
+
'Rock Throw: face a nearby rock and press fire to lift it, then press again to throw it (only the Blade Tosser and Quake Hurler rooms contain rocks). When Quake Hurler lands, grounded players are stunned for about 0.8 seconds; jump to avoid it',
|
| 55 |
+
'Health: 28 units (504 points). Taking damage causes 0.5 seconds of knockback and 1.85 seconds of flashing invulnerability. Defeat a boss to acquire its weapon; bosses have weapon weaknesses'
|
| 56 |
+
];
|
| 57 |
+
P.reset = function (c) {
|
| 58 |
+
var o = c.options || {}, self = this;
|
| 59 |
+
// entry position: in the original it depends on how the player walked through the boss door; here the seed
|
| 60 |
+
// picks it (28..68 px), which also makes the RNG-free Ice Man and Fire Man fights differ between seeds
|
| 61 |
+
this.room = MM.roomOf(c.id);
|
| 62 |
+
this.x = 28 + c.rng.int(41); this.y = MM.FLOOR - BODY_HH; this.vy = 0; this.facing = 1; this.grounded = true;
|
| 63 |
+
if (this.room.length) this.y = MM.floorUnder(this.room, this.x - 7, this.x + 7, 0) - BODY_HH; // walked in onto the step
|
| 64 |
+
this.speed = 0; this.walkT = 0; this.slideT = 0; this.airHeld = false;
|
| 65 |
+
this.max_hp = this.hp = MM.BAR * MM.UNIT;
|
| 66 |
+
this.iframes = 0; this.knockT = 0; this.knockDir = 0; this.shootT = 0; this.stunT = 0; this.airHit = false; this.blockTarget = null; this.blocksGone = [];
|
| 67 |
+
this.weapons = MM.loadout(o); this.weapon = 'P'; this.energy = {};
|
| 68 |
+
this.weapons.forEach(function (w) { if (w !== 'P') self.energy[w] = MM.BAR; });
|
| 69 |
+
this.shots = []; this.nextShot = 1; this.shieldN = 0;
|
| 70 |
+
this.prev = {}; this.fired = false; this.anyInput = false; this.hits = 0; this.slashHits = {};
|
| 71 |
+
};
|
| 72 |
+
P.hurtBox = function () { return MM.box(this.x, this.y, HW, HH); };
|
| 73 |
+
P.box = P.hurtBox;
|
| 74 |
+
P.centre = function () { return { x: this.x, y: this.y }; };
|
| 75 |
+
P.slashBox = function () { return null; };
|
| 76 |
+
P.onSlashContact = function () {};
|
| 77 |
+
|
| 78 |
+
// weapon menu (bank 6 weapon_menu_main): MM1 switches in the SELECT menu, which freezes the world and hides
|
| 79 |
+
// entity slot 5 (STA $0605 = F8: the special-weapon slot); Buster shots in slots 2-4 and the other pieces keep
|
| 80 |
+
// flying. Here Q/E switch instantly with the same effect on the shots.
|
| 81 |
+
P.cycle = function (step) {
|
| 82 |
+
var i = this.weapons.indexOf(this.weapon), n = this.weapons.length;
|
| 83 |
+
if (n < 2) return;
|
| 84 |
+
if (this.count('hyper_bomb') || this.count('hyper_flame') || this.blockOut()) return; // main_select: no menu while $60 is set
|
| 85 |
+
this.weapon = this.weapons[(i + step + n) % n];
|
| 86 |
+
// slot 5 is hidden by the menu; the Fire Storm shield (slot 6) loses its orbit service and would hang in
|
| 87 |
+
// place forever in the original (an orphan that also blocks the Thunder Beam) - it is dropped here instead
|
| 88 |
+
this.shots = this.shots.filter(function (s) { return s.slot !== 5 && s.kind !== 'fire_shield'; });
|
| 89 |
+
};
|
| 90 |
+
// shot_collision_service ($A261) tests the slot range of the CURRENT weapon, whatever occupies it: Buster 2-4,
|
| 91 |
+
// Ice 5, Fire 5-6, Thunder 5-11; damage is looked up for the current weapon. A shot left over from another
|
| 92 |
+
// weapon outside that range flies on harmlessly.
|
| 93 |
+
var HIT_SLOTS = { P: [2, 4], C: [5, 5], I: [5, 5], F: [5, 6], E: [5, 11], G: [5, 7] };
|
| 94 |
+
P.collides = function (s) {
|
| 95 |
+
if (this.weapon === 'B') return s.kind === 'hyper_flame'; // shotcoll_bomb: only the explosion window
|
| 96 |
+
if (s.kind === 'held_block') return false; // flags $24: bit 5 keeps it out of the collision
|
| 97 |
+
if (s.kind === 'block_chunk') return s.slot <= 7; // shotcoll_guts, and thunder_spent after a beam broke a block
|
| 98 |
+
var r = HIT_SLOTS[this.weapon]; return s.slot >= r[0] && s.slot <= r[1]; };
|
| 99 |
+
P.spendable = function (w) { return w === 'P' || (this.energy[w] || 0) >= MM.WEAPONS[w].cost; };
|
| 100 |
+
P.spend = function (w) { if (w !== 'P') this.energy[w] = Math.max(0, this.energy[w] - MM.WEAPONS[w].cost); };
|
| 101 |
+
P.count = function (kind) { var n = 0; this.shots.forEach(function (s) { if (s.kind === kind) n++; }); return n; };
|
| 102 |
+
P.slotUsed = function (slot) { return this.shots.some(function (s) { return s.slot === slot; }); };
|
| 103 |
+
P.addShot = function (s) { s.id = this.nextShot++; s.dir = this.facing; s.vy = s.vy || 0; s.age = 0; this.shots.push(s); return s; };
|
| 104 |
+
// $60 "a shot is out" stays set until every player-shot slot (2-15) is empty (shots_gone_check); the Thunder
|
| 105 |
+
// Beam's fire handler refuses while it is set, so even a Buster shot still on screen blocks it
|
| 106 |
+
P.shotOut = function () { return this.shots.length > 0; };
|
| 107 |
+
P.blockOut = function () { return this.count('held_block') > 0 || this.count('thrown_block') > 0 || this.count('block_chunk') > 0; };
|
| 108 |
+
|
| 109 |
+
// fire_weapon ($A71E) and the per-weapon fire handlers ($A999 spawn records: slot, offset, velocity)
|
| 110 |
+
P.fire = function (c) {
|
| 111 |
+
var w = this.weapon, f = this.facing, x = this.x, y = this.y, self = this;
|
| 112 |
+
if (!this.spendable(w)) return;
|
| 113 |
+
if (w === 'P') {
|
| 114 |
+
var free = [2, 3, 4].filter(function (k) { return !self.slotUsed(k); })[0];
|
| 115 |
+
if (!free) return; // three shots out
|
| 116 |
+
this.addShot({ kind: 'buster', w: 'P', slot: free, x: x + 16 * f, y: y, vx: 4 * f, hw: 4, hh: 4, pierce: false });
|
| 117 |
+
c.emit('mm_shot', x + 16 * f, y);
|
| 118 |
+
} else if (w === 'E') {
|
| 119 |
+
if (this.shotOut()) return; // one beam at a time
|
| 120 |
+
THUNDER.forEach(function (r, i) { // records 6-$0A -> slots 5-9
|
| 121 |
+
self.addShot({ kind: 'thunder', w: 'E', slot: 5 + i, x: x + r[0] * f, y: y + r[1], vx: AIR * f, row: i, t: r[2],
|
| 122 |
+
hw: MM.PLAYER_BOLT.hw[i], hh: MM.PLAYER_BOLT.hh[i], pierce: true });
|
| 123 |
+
});
|
| 124 |
+
this.addShot({ kind: 'thunder_v', w: 'E', slot: 10, x: x + 16 * f, y: y - 16, vx: 0, vy: 6, hw: 8, hh: 16, pierce: true });
|
| 125 |
+
this.addShot({ kind: 'thunder_v', w: 'E', slot: 11, x: x + 16 * f, y: y + 16, vx: 0, vy: -6, hw: 8, hh: 16, pierce: true });
|
| 126 |
+
this.spend(w); c.emit('mm_thunder', x, y);
|
| 127 |
+
} else if (w === 'I') {
|
| 128 |
+
if (this.slotUsed(5)) return; // record 5 needs slot 5
|
| 129 |
+
this.addShot({ kind: 'slasher', w: 'I', slot: 5, x: x + 16 * f, y: y, vx: 4 * f, hw: 8, hh: 8, pierce: true });
|
| 130 |
+
this.spend(w); c.emit('mm_slasher', x, y);
|
| 131 |
+
} else if (w === 'F') {
|
| 132 |
+
if (this.slotUsed(5)) return; // the wave (record 0) needs slot 5
|
| 133 |
+
this.addShot({ kind: 'fire_wave', w: 'F', slot: 5, x: x + 16 * f, y: y, vx: 4 * f, hw: 8, hh: 8, pierce: true });
|
| 134 |
+
if (!this.slotUsed(6)) this.addShot({ kind: 'fire_shield', w: 'F', slot: 6, x: x, y: y - 20, vx: 0, hw: 8, hh: 8, pierce: true });
|
| 135 |
+
this.shieldN = 0; this.spend(w); c.emit('mm_fire', x, y); // re-firing restarts the 32-frame shield
|
| 136 |
+
} else if (w === 'C') {
|
| 137 |
+
if (this.shotOut()) return; // single_shot_gate: $60; record $0E, kick 02.80
|
| 138 |
+
this.addShot({ kind: 'cutter', w: 'C', slot: 5, x: x + 12 * f, y: y - 4, vx: 2 * f, vy: 2, hw: 8, hh: 8, pierce: true, n: 0, ret: 0, kick: 0x280 });
|
| 139 |
+
this.spend(w); c.emit('mm_cutter', x, y);
|
| 140 |
+
} else if (w === 'B') {
|
| 141 |
+
if (this.shotOut()) return; // single_shot_gate: $60
|
| 142 |
+
this.addShot({ kind: 'hyper_bomb', w: 'B', slot: 5, x: x + 12 * f, y: y - 4, vx: fx(0x180) * f, vy: 3, hw: 8, hh: 8, pierce: true, fuse: 0, bounces: 3 });
|
| 143 |
+
this.spend(w); c.emit('mm_hyper_bomb', x, y);
|
| 144 |
+
} else if (w === 'G') { // fire_super_arm
|
| 145 |
+
var held = this.shots.filter(function (s) { return s.kind === 'held_block'; })[0];
|
| 146 |
+
if (!held) { // lifting costs nothing and has no firing pose
|
| 147 |
+
if (this.shotOut() || !this.blockTarget) return;
|
| 148 |
+
this.takeBlock(c, this.blockTarget);
|
| 149 |
+
this.addShot({ kind: 'held_block', w: 'G', slot: 5, x: x + 16 * f, y: y - 16, vx: 0, hw: BLOCK_HALF[c.id], hh: BLOCK_HALF[c.id], pierce: true, n: 0 });
|
| 150 |
+
c.emit('mm_lift', x, y);
|
| 151 |
+
return;
|
| 152 |
+
}
|
| 153 |
+
this.shots = this.shots.filter(function (s) { return s !== held; }); // the throw replaces it, and only the throw costs energy
|
| 154 |
+
this.addShot({ kind: 'thrown_block', w: 'G', slot: 5, x: x + 16 * f, y: y - 16, vx: THROW_VX * f, vy: THROW_VY, hw: held.hw, hh: held.hh, pierce: true, n: 0 });
|
| 155 |
+
this.spend(w); c.emit('mm_throw', x, y);
|
| 156 |
+
}
|
| 157 |
+
this.shootT = 15;
|
| 158 |
+
};
|
| 159 |
+
|
| 160 |
+
// horizontal speed (player_hspeed $9CE7 with the anim -> speed rows $9DDD/$9DE6): the walk-start anim $03 runs
|
| 161 |
+
// 9 frames at 00.20, then the walk anim $06 at 01.60. On the release frame the speed of the current anim still
|
| 162 |
+
// applies; releasing from $06 starts the stop-step anim $0C (13 more frames at 00.80), from $03 he just stands.
|
| 163 |
+
P.walk = function (dx) {
|
| 164 |
+
var was = this.prev.left || this.prev.right;
|
| 165 |
+
if (this.grounded) {
|
| 166 |
+
if (dx) {
|
| 167 |
+
if (!was) this.walkT = 0; // from a stop or mid-slowdown: start-up
|
| 168 |
+
this.facing = dx; this.slideT = 0;
|
| 169 |
+
this.speed = this.walkT < START_T ? START : WALK; this.walkT++;
|
| 170 |
+
} else if (was) { // release frame: the current anim's speed
|
| 171 |
+
this.speed = this.walkT >= START_T ? WALK : START;
|
| 172 |
+
this.slideT = this.walkT >= START_T ? SLIDE_T : 0; this.walkT = 0;
|
| 173 |
+
} else if (this.slideT > 0) { this.speed = SLIDE; this.slideT--; }
|
| 174 |
+
else this.speed = 0;
|
| 175 |
+
this.airHeld = !!dx;
|
| 176 |
+
} else {
|
| 177 |
+
if (dx) { this.facing = dx; this.speed = this.airHeld ? AIR : START; this.airHeld = true; }
|
| 178 |
+
else { this.speed = 0; this.airHeld = false; }
|
| 179 |
+
this.slideT = 0; this.walkT = dx ? START_T + 1 : 0; // landing with the d-pad held keeps full walk speed
|
| 180 |
+
}
|
| 181 |
+
this.moveX(this.speed * this.facing);
|
| 182 |
+
};
|
| 183 |
+
P.moveX = function (v) {
|
| 184 |
+
var nx = this.x + v, lo = MM.WALL_L + BODY_HW, hi = MM.WALL_R - BODY_HW;
|
| 185 |
+
nx = nx < lo ? lo : nx > hi ? hi : nx;
|
| 186 |
+
if (this.room.length) nx = MM.clampX(this.room, this.x, nx, BODY_HW, this.y, BODY_HH);
|
| 187 |
+
this.x = nx;
|
| 188 |
+
};
|
| 189 |
+
// vertical_collision for the player; returns true on the frame it lands
|
| 190 |
+
P.fall = function () {
|
| 191 |
+
var ny = this.y - this.vy, air = !this.grounded;
|
| 192 |
+
var floor = this.room.length ? MM.floorUnder(this.room, this.x - 7, this.x + 7, this.y + BODY_HH) : MM.FLOOR;
|
| 193 |
+
if (this.vy <= 0 && ny + BODY_HH >= floor) { this.y = floor - BODY_HH; this.vy = 0; this.grounded = true; return air; }
|
| 194 |
+
this.y = ny; this.grounded = false;
|
| 195 |
+
this.vy = Math.max(-MM.FALL_MAX, this.vy - MM.GRAVITY);
|
| 196 |
+
return false;
|
| 197 |
+
};
|
| 198 |
+
|
| 199 |
+
P.update = function (c, i) {
|
| 200 |
+
var p = this.prev, dx = (i.right ? 1 : 0) - (i.left ? 1 : 0), landed = false, exit = this.exitKnock;
|
| 201 |
+
this.fired = false; this.exitKnock = false;
|
| 202 |
+
this.anyInput = !!(i.left || i.right || i.up || i.down || i.jump || i.fire || i.prev || i.next);
|
| 203 |
+
if (c.boss.intro > 0 || this.hp <= 0) { this.prev = {}; this.fall(); this.flight(c); return; } // input locked
|
| 204 |
+
this.fired = !!i.fire && !p.fire; // p1_new_presses & B: bosses read it even in knockback
|
| 205 |
+
if (i.prev && !p.prev) this.cycle(-1);
|
| 206 |
+
if (i.next && !p.next) this.cycle(1);
|
| 207 |
+
if (exit) this.prev = { jump: p.jump, fire: p.fire }; // player_state_exit clears p1_prev_buttons this frame only
|
| 208 |
+
if (this.knockT > 0) { // special state 3: knockback, no control
|
| 209 |
+
this.moveX(KNOCK * this.knockDir);
|
| 210 |
+
this.speed = 0; this.walkT = 0; this.slideT = 0; this.airHeld = false;
|
| 211 |
+
landed = this.fall();
|
| 212 |
+
} else if (this.stunT > 0) { // special state 2 (the quake): no control, drifts backwards
|
| 213 |
+
if ((this.stunT & 15) === 15) { this.vy = STUN_VY; this.grounded = false; }
|
| 214 |
+
this.moveX(-START * this.facing);
|
| 215 |
+
this.speed = 0; this.walkT = 0; this.slideT = 0; this.airHeld = false;
|
| 216 |
+
landed = this.fall();
|
| 217 |
+
} else {
|
| 218 |
+
this.walk(dx);
|
| 219 |
+
if (this.fired) this.fire(c);
|
| 220 |
+
if (this.vy < 0 || this.grounded) { // falling or standing: land first, then the jump check
|
| 221 |
+
landed = this.fall();
|
| 222 |
+
if (this.grounded && i.jump && !p.jump) { this.vy = JUMP; this.grounded = false; c.emit('mm_jump', this.x, this.y); }
|
| 223 |
+
} else { // rising: step, then releasing jump feathers the rise
|
| 224 |
+
this.fall();
|
| 225 |
+
if (!this.grounded && !i.jump && this.vy >= 2) this.vy = 1; // player_fall_cap
|
| 226 |
+
}
|
| 227 |
+
}
|
| 228 |
+
if (landed) c.emit('mm_land', this.x, MM.FLOOR);
|
| 229 |
+
this.flight(c);
|
| 230 |
+
this.prev = { left: !!i.left, right: !!i.right, up: !!i.up, down: !!i.down, jump: !!i.jump, fire: !!i.fire, prev: !!i.prev, next: !!i.next };
|
| 231 |
+
};
|
| 232 |
+
|
| 233 |
+
// weapon flight services, run before the boss AI ($A35C, dispatched by the CURRENT weapon): Thunder Beam crawl
|
| 234 |
+
// jumps (thunder_flight; pieces left over after a switch only drift), Fire Storm shield orbit
|
| 235 |
+
// (fire_storm_flight: INC the timer, drop the shield at 32, else orbit at offset timer & 7)
|
| 236 |
+
P.flight = function (c) {
|
| 237 |
+
var self = this, T = MM.PLAYER_BOLT;
|
| 238 |
+
this.hyperFlight();
|
| 239 |
+
this.cutterFlight();
|
| 240 |
+
this.armFlight();
|
| 241 |
+
if (this.count('fire_shield') && ++this.shieldN === 32) {
|
| 242 |
+
this.shots = this.shots.filter(function (s) { return s.kind !== 'fire_shield'; });
|
| 243 |
+
}
|
| 244 |
+
this.shots.forEach(function (s) {
|
| 245 |
+
if (s.kind === 'thunder' && s.t <= 0 && self.weapon === 'E') {
|
| 246 |
+
s.x += T.jx[s.row] * s.dir; s.y += T.jy[s.row]; s.row = T.next[s.row]; s.hw = T.hw[s.row]; s.hh = T.hh[s.row]; s.t = 10;
|
| 247 |
+
} else if (s.kind === 'fire_shield') {
|
| 248 |
+
var k = self.shieldN & 7; s.x = self.x + ORBIT_X[k]; s.y = self.y + ORBIT_Y[k];
|
| 249 |
+
}
|
| 250 |
+
});
|
| 251 |
+
this.thunderBlocks(c);
|
| 252 |
+
};
|
| 253 |
+
|
| 254 |
+
// guts_flight / guts_block_detect: the held block settles for one frame, then floats 26 px over the player. With no
|
| 255 |
+
// shot out the Super Arm probes one tile ahead at the player's y (+8 facing right, -9 facing left) for a liftable block.
|
| 256 |
+
// guts_thrown: while the throw's $61 runs from $10 to $1F, an airborne player takes the firing pose $6F, one count per frame.
|
| 257 |
+
P.armFlight = function () {
|
| 258 |
+
if (this.weapon !== 'G') return;
|
| 259 |
+
var s = this.shots.filter(function (q) { return q.kind === 'held_block'; })[0];
|
| 260 |
+
if (s) {
|
| 261 |
+
if (!s.n) { s.n = 1; return; }
|
| 262 |
+
s.x = this.x; s.y = this.y - ARM_LIFT; s.dir = this.facing;
|
| 263 |
+
return;
|
| 264 |
+
}
|
| 265 |
+
if (!this.grounded && this.knockT === 0 && this.stunT === 0) this.shots.forEach(function (q) { if (q.kind === 'thrown_block' && q.n < 15) q.n++; });
|
| 266 |
+
if (this.shotOut()) return;
|
| 267 |
+
this.blockTarget = MM.blockAt(this.room, Math.floor(this.x) + (this.facing > 0 ? 8 : -9), Math.floor(this.y));
|
| 268 |
+
};
|
| 269 |
+
// the record becomes type 4: the block is gone for the rest of the fight, for the player and the boss alike
|
| 270 |
+
P.takeBlock = function (c, block) {
|
| 271 |
+
var rest = function (r) { return r.x0 !== block.x0; };
|
| 272 |
+
this.room = this.room.filter(rest); c.boss.room = c.boss.room.filter(rest);
|
| 273 |
+
this.blocksGone.push(block.x0); this.blockTarget = null;
|
| 274 |
+
};
|
| 275 |
+
// guts_block_shatter: 4 chunks in slots 5-8 around (x0, y0), the facing of slot 5, slots 9-$F cleared. Chunks move straight
|
| 276 |
+
// without tile collision, and pierce: only the block itself breaks on a hit.
|
| 277 |
+
P.placeChunks = function (x0, y0, dir, keep) {
|
| 278 |
+
var self = this;
|
| 279 |
+
this.shots = this.shots.filter(keep);
|
| 280 |
+
CHUNKS.forEach(function (r, i) {
|
| 281 |
+
self.shots.push({ kind: 'block_chunk', w: 'G', slot: 5 + i, x: x0 + r[0], y: y0 + r[1], vx: r[2] * dir, vy: r[3], hw: 4, hh: 4, pierce: true,
|
| 282 |
+
id: self.nextShot++, dir: dir, age: 0 });
|
| 283 |
+
});
|
| 284 |
+
};
|
| 285 |
+
// block_impact_shatter: the fragments start 16 px up-left of the impact
|
| 286 |
+
P.blockShatter = function (c, s) {
|
| 287 |
+
this.placeChunks(s.x - 16, s.y - 16, s.dir, function (q) { return q !== s; });
|
| 288 |
+
c.emit('mm_block_shatter', s.x, s.y);
|
| 289 |
+
};
|
| 290 |
+
// thunder_block_scan: every frame the live beam pieces of one parity probe the override records; a liftable block under one
|
| 291 |
+
// breaks (guts_block_pickup), which ends the beam: the chunks take slots 5-8, slots 9-$F are cleared
|
| 292 |
+
P.thunderBlocks = function (c) {
|
| 293 |
+
if (this.weapon !== 'E' || !this.room.length || (!this.count('thunder') && !this.count('thunder_v'))) return;
|
| 294 |
+
var hit = null, self = this;
|
| 295 |
+
for (var slot = 5 + (c.t & 1); slot < 12 && !hit; slot += 2) {
|
| 296 |
+
this.shots.forEach(function (s) {
|
| 297 |
+
if (hit || s.slot !== slot) return;
|
| 298 |
+
var b = MM.blockAt(self.room, Math.floor(s.x), Math.floor(s.y));
|
| 299 |
+
if (b) hit = b;
|
| 300 |
+
});
|
| 301 |
+
}
|
| 302 |
+
if (!hit) return;
|
| 303 |
+
this.takeBlock(c, hit);
|
| 304 |
+
var five = this.shots.filter(function (q) { return q.slot === 5; })[0]; // the chunks take slot 5's facing
|
| 305 |
+
this.placeChunks(hit.x0, hit.y0, five ? five.dir : this.facing, function (q) { return q.slot < 5 || q.slot > 11; });
|
| 306 |
+
c.emit('mm_block_shatter', hit.x0 + 16, hit.y0 + 16);
|
| 307 |
+
};
|
| 308 |
+
|
| 309 |
+
// cutter_flight: 42 frames out with Y velocity falling 00.1A per frame, then it homes on the player at 02.80 + 0.08
|
| 310 |
+
// per frame, caught within 12 px on both axes; the throw kick (02.80, -0.20 per frame) comes off the Y velocity. The
|
| 311 |
+
// service is dispatched by the current weapon, and a switch removes slot 5, so only the Cutter selected reaches here.
|
| 312 |
+
P.cutterFlight = function () {
|
| 313 |
+
var s = this.shots.filter(function (q) { return q.kind === 'cutter'; })[0];
|
| 314 |
+
if (!s) return;
|
| 315 |
+
if (s.n < 0x2A) { s.n++; s.vy -= fx(0x1A); return; }
|
| 316 |
+
if (s.n === 0x2A) { s.n++; s.ret = 0x280; }
|
| 317 |
+
var dx = Math.floor(this.x) - Math.floor(s.x), adx = Math.abs(dx);
|
| 318 |
+
s.ret += 8;
|
| 319 |
+
var v = MM.propVel(s.ret, adx, Math.floor(s.y) - Math.floor(this.y));
|
| 320 |
+
s.vx = v.vx * (dx >= 0 ? 1 : -1); s.vy = v.vy; s.dir = dx >= 0 ? 1 : -1;
|
| 321 |
+
if (v.ady < 12 && adx < 12) { s.dead = true; this.shots = this.shots.filter(function (q) { return q !== s; }); return; }
|
| 322 |
+
if (s.kick) { s.kick -= 0x20; s.vy -= s.kick / 256; }
|
| 323 |
+
};
|
| 324 |
+
|
| 325 |
+
// bomb_flight: the fuse ($61) counts from the firing frame; at $92 slot 5 becomes 12 flames in slots 2-13 (row 11
|
| 326 |
+
// first), which fly straight and are cleared at $A0. The counter lives on the shots, so fights without the bomb
|
| 327 |
+
// keep exactly the same state.
|
| 328 |
+
P.hyperFlight = function () {
|
| 329 |
+
var burst = null;
|
| 330 |
+
this.shots.forEach(function (s) {
|
| 331 |
+
if (s.kind !== 'hyper_bomb' && s.kind !== 'hyper_flame') return;
|
| 332 |
+
s.fuse++;
|
| 333 |
+
if (s.kind === 'hyper_bomb' && s.fuse === BOMB_FUSE) burst = s;
|
| 334 |
+
});
|
| 335 |
+
if (burst) {
|
| 336 |
+
this.shots = this.shots.filter(function (s) { return s !== burst; });
|
| 337 |
+
for (var row = 11; row >= 0; row--) {
|
| 338 |
+
var r = MM.SPREAD[row], dir = r[2] ? 1 : -1;
|
| 339 |
+
this.shots.push({ kind: 'hyper_flame', w: 'B', slot: 13 - row, x: burst.x, y: burst.y, vx: r[0] * dir, vy: r[1], hw: 8, hh: 8, pierce: false,
|
| 340 |
+
fuse: BOMB_FUSE, id: this.nextShot++, dir: dir, age: 0 });
|
| 341 |
+
}
|
| 342 |
+
}
|
| 343 |
+
if (this.count('hyper_flame')) this.shots = this.shots.filter(function (s) { return s.kind !== 'hyper_flame' || s.fuse < BOMB_END; });
|
| 344 |
+
};
|
| 345 |
+
// entity_pass + react_bubble for the fused bomb: tile collision and gravity. A wall only pushes it out; each landing
|
| 346 |
+
// halves the X speed and bounces with Y speed n.n while the counter $62 (3) runs down to 0.
|
| 347 |
+
P.hyperMove = function (s) {
|
| 348 |
+
var lo = MM.WALL_L + s.hw, hi = MM.WALL_R - s.hw, room = this.room;
|
| 349 |
+
s.x = Math.min(hi, Math.max(lo, s.x + s.vx)); s.age++;
|
| 350 |
+
if (room.length) s.x = MM.clampX(room, s.x - s.vx, s.x, s.hw, s.y, s.hh);
|
| 351 |
+
var ny = s.y - s.vy, floor = room.length ? MM.floorUnder(room, s.x - s.hw + 1, s.x + s.hw - 1, s.y + s.hh) : MM.FLOOR;
|
| 352 |
+
if (s.vy < 0 && ny + s.hh >= floor) {
|
| 353 |
+
var n = s.bounces; s.y = floor - s.hh; s.vy = n + n / 256; if (n > 0) s.bounces--;
|
| 354 |
+
s.vx = (s.vx < 0 ? -1 : 1) * Math.floor(Math.abs(s.vx) * 128) / 256;
|
| 355 |
+
return;
|
| 356 |
+
}
|
| 357 |
+
s.y = ny; s.vy = Math.max(-MM.FALL_MAX, s.vy - MM.GRAVITY);
|
| 358 |
+
};
|
| 359 |
+
|
| 360 |
+
// entity_pass for the thrown block (flags $15: tile collision, gravity): a wall or the floor shatters it; at the top of the
|
| 361 |
+
// screen a rising block only slows down, a falling one vanishes (react_floater)
|
| 362 |
+
P.blockMove = function (c, s) {
|
| 363 |
+
var lo = MM.WALL_L + s.hw, hi = MM.WALL_R - s.hw, room = this.room, nx = s.x + s.vx, stop = false;
|
| 364 |
+
s.age++;
|
| 365 |
+
if (nx < lo) { nx = lo; stop = true; } else if (nx > hi) { nx = hi; stop = true; }
|
| 366 |
+
if (room.length) { var cx = MM.clampX(room, s.x, nx, s.hw, s.y, s.hh); if (cx !== nx) { nx = cx; stop = true; } }
|
| 367 |
+
s.x = nx;
|
| 368 |
+
if (stop) { this.blockShatter(c, s); return; }
|
| 369 |
+
var ny = s.y - s.vy, floor = room.length ? MM.floorUnder(room, s.x - s.hw + 1, s.x + s.hw - 1, s.y + s.hh) : MM.FLOOR;
|
| 370 |
+
if (ny < MM.TOP_EXIT) { if (s.vy < 0) s.dead = true; else s.vy -= MM.GRAVITY; return; }
|
| 371 |
+
if (s.vy < 0 && ny + s.hh >= floor) { s.y = floor - s.hh; this.blockShatter(c, s); return; }
|
| 372 |
+
s.y = ny; s.vy = Math.max(-MM.FALL_MAX, s.vy - MM.GRAVITY);
|
| 373 |
+
};
|
| 374 |
+
|
| 375 |
+
// ---- the part of the tick after the boss AI (arena.js lists the order) ----
|
| 376 |
+
P.resolveInteractions = function (c) {
|
| 377 |
+
var b = c.boss, j;
|
| 378 |
+
if (this.iframes > 0) this.iframes--;
|
| 379 |
+
if (b.fight && this.hp > 0 && b.hp > 0) {
|
| 380 |
+
// player contact (player_contact_service $A18B): boss body every frame, boss shots by slot parity
|
| 381 |
+
var hb = this.hurtBox();
|
| 382 |
+
if (this.iframes === 0 && MM.overlap(b.hitBox(), hb)) this.hurt(c, b.contactDamage(), b.dir, b.id + '_body');
|
| 383 |
+
else if (this.iframes === 0) {
|
| 384 |
+
for (j = 0; j < b.projectiles.length; j++) {
|
| 385 |
+
var q = b.projectiles[j];
|
| 386 |
+
if (q.harmless || (q.slot & 1) !== (c.t & 1)) continue;
|
| 387 |
+
if (MM.overlap(q, hb)) { this.hurt(c, q.dmg, q.dir, q.kind); break; }
|
| 388 |
+
}
|
| 389 |
+
}
|
| 390 |
+
// shots vs boss ($C8B2): only the current weapon's slots, skipped while the boss blinks; the damage row is
|
| 391 |
+
// the CURRENT weapon (current_weapon indexes $FDEE); a non-piercing shot is consumed by a hit
|
| 392 |
+
for (j = 0; j < this.shots.length && b.hp > 0 && this.hp > 0; j++) {
|
| 393 |
+
var s = this.shots[j];
|
| 394 |
+
if (b.iframes > 0 || s.dead || !this.collides(s)) continue;
|
| 395 |
+
if (MM.overlap(b.hitBox(), s)) {
|
| 396 |
+
b.takeHit(c, this.weapon, s.x, s.y); if (!s.pierce) s.dead = true;
|
| 397 |
+
if (s.kind === 'thrown_block') { this.blockShatter(c, s); break; } // gutscoll_hit: the service ends here
|
| 398 |
+
}
|
| 399 |
+
}
|
| 400 |
+
}
|
| 401 |
+
// entity pass: player shots drift and leave the screen; the boss moves its own projectiles
|
| 402 |
+
var self = this;
|
| 403 |
+
this.shots.forEach(function (s) {
|
| 404 |
+
if (s.dead || s.kind === 'fire_shield') return;
|
| 405 |
+
if (s.kind === 'hyper_bomb') { self.hyperMove(s); return; }
|
| 406 |
+
if (s.kind === 'held_block') return;
|
| 407 |
+
if (s.kind === 'thrown_block') { self.blockMove(c, s); return; }
|
| 408 |
+
s.x += s.vx; s.y -= s.vy; s.age++;
|
| 409 |
+
if (MM.offscreen(s)) s.dead = true;
|
| 410 |
+
});
|
| 411 |
+
this.shots = this.shots.filter(function (s) { return !s.dead; });
|
| 412 |
+
b.entityPass(c);
|
| 413 |
+
// render-time counters: animation timers and poses, the boss's blink
|
| 414 |
+
this.shots.forEach(function (s) { if (s.kind === 'thunder') s.t--; });
|
| 415 |
+
if (this.shootT > 0) this.shootT--;
|
| 416 |
+
if (this.knockT > 0 && --this.knockT === 0) this.exitKnock = true;
|
| 417 |
+
if (this.stunT > 0 && --this.stunT === 0) this.exitKnock = true;
|
| 418 |
+
b.renderTick(c);
|
| 419 |
+
};
|
| 420 |
+
|
| 421 |
+
P.hurt = function (c, dmg, fromDir, kind) {
|
| 422 |
+
if (this.iframes > 0 || this.hp <= 0 || !(dmg > 0)) return false;
|
| 423 |
+
this.hp = Math.max(0, this.hp - dmg); this.hits++;
|
| 424 |
+
c.events.push({ t: c.t, name: 'hurt_by', by: kind });
|
| 425 |
+
if (this.hp <= 0) { this.knockT = 0; this.stunT = 0; this.shots = []; this.shieldN = 0; c.emit('mm_player_dead', this.x, this.y); return true; }
|
| 426 |
+
if (this.stunT > 0 && c.boss.shake > 0) { // the NMI rewrites the state to 2 this very frame: anim $13 never changed, so no knockback starts
|
| 427 |
+
if (fromDir) this.facing = -fromDir;
|
| 428 |
+
this.iframes = IFRAMES; c.emit('mm_hurt', this.x, this.y);
|
| 429 |
+
return true;
|
| 430 |
+
}
|
| 431 |
+
this.stunT = 0;
|
| 432 |
+
this.airHit = !this.grounded && !!c.boss.shake; // anim $09 still reads airborne to this frame's NMI: the stun comes one frame later
|
| 433 |
+
this.knockDir = fromDir || -this.facing; this.facing = -this.knockDir;
|
| 434 |
+
this.knockT = KNOCK_T; this.iframes = IFRAMES; this.speed = 0; this.walkT = 0; this.slideT = 0;
|
| 435 |
+
this.vy = KNOCK_VY; this.grounded = false;
|
| 436 |
+
c.emit('mm_hurt', this.x, this.y);
|
| 437 |
+
return true;
|
| 438 |
+
};
|
| 439 |
+
|
| 440 |
+
// The quake (nmi_shake_palette, one call per shake_timer frame at the end of the tick, Guts Man's renderTick): the player
|
| 441 |
+
// is forced into special state 2 unless his anim is $09 or $6F, the airborne poses. Knockback is anim $12, so it is
|
| 442 |
+
// overwritten, including its last frame (the state exit only runs next frame). An already stunned player does not restart.
|
| 443 |
+
P.quake = function () {
|
| 444 |
+
if (this.hp <= 0 || this.stunT > 0) return;
|
| 445 |
+
if (this.airHit) { this.airHit = false; return; }
|
| 446 |
+
if (!this.grounded && this.knockT === 0 && !this.exitKnock) return;
|
| 447 |
+
this.stunT = STUN_T; this.knockT = 0; this.exitKnock = false;
|
| 448 |
+
};
|
| 449 |
+
|
| 450 |
+
// the player's jump/fall pose anim $09 (player_air_pose); Cut Man reads it. Knockback is anim $12, and for the first
|
| 451 |
+
// 15 frames of a thrown Cutter or Hyper Bomb an airborne player is in the firing variant $6F; Buster shots keep $09
|
| 452 |
+
P.airPose = function () {
|
| 453 |
+
if (this.grounded || this.knockT > 0 || this.stunT > 0) return false;
|
| 454 |
+
return !this.shots.some(function (s) { return (s.kind === 'cutter' && s.n < 0x0F) || (s.kind === 'hyper_bomb' && s.fuse < 0x0F) || (s.kind === 'thrown_block' && s.n < 0x0F); });
|
| 455 |
+
};
|
| 456 |
+
|
| 457 |
+
P.state = function () {
|
| 458 |
+
var o = { x: this.x, y: this.y, vy: this.vy, facing: this.facing, grounded: this.grounded,
|
| 459 |
+
speed: this.speed, walk_t: this.walkT, slide_t: this.slideT, air_held: this.airHeld,
|
| 460 |
+
hp: this.hp, max_hp: this.max_hp, iframes: this.iframes, knock_t: this.knockT, knock_dir: this.knockDir,
|
| 461 |
+
shoot_t: this.shootT, weapon: this.weapon, weapons: this.weapons, energy: this.energy,
|
| 462 |
+
shots: this.shots, next_shot: this.nextShot, shield_n: this.shieldN, previous: this.prev,
|
| 463 |
+
fired: this.fired, any_input: this.anyInput, hits: this.hits };
|
| 464 |
+
// only while they differ from their initial values, so fights without a quake or the Super Arm keep the same state hash
|
| 465 |
+
if (this.stunT) o.stun_t = this.stunT;
|
| 466 |
+
if (this.blockTarget) o.block_target = this.blockTarget.x0;
|
| 467 |
+
if (this.blocksGone.length) o.blocks_gone = this.blocksGone;
|
| 468 |
+
return MM.snapshot(o);
|
| 469 |
+
};
|
| 470 |
+
B.MegaMan = MegaMan;
|
| 471 |
+
})(typeof window !== 'undefined' ? window : globalThis);
|
environments/games/web/games/megaman_remake/bosses/bomb_man.js
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Bomb Man (game mode 2, fixed bank $DFF0). Port of the original 18-state table $E0ED:
|
| 2 |
+
// jump_pick face the player, rng & 1 picks jump variant 0 (big leap toward, 02.90 / 07.60) or 1 (hop toward,
|
| 3 |
+
// 01.09 / 05.B0) from $E03B; the variant's state number sends the table to walk_idle at index 8 or 17
|
| 4 |
+
// walk_idle fly the jump; landing stops him (X speed 0) -> pattern_roll
|
| 5 |
+
// pattern_roll random_mod 6 walks the table back: r odd -> 3 bombs, r 0/4 -> 2, r 2 -> 1
|
| 6 |
+
// throw / land_throw a 15-frame windup ($0641 = $1F: draw_entity counts the low nibble), then a bomb; the next windup waits until the bomb burst
|
| 7 |
+
// wait_bomb wait for the last bomb; the second set (index 10) then leap_away: turn away, variant 2 (01.09/05.B0)
|
| 8 |
+
// guard during pattern_roll / land_throw / throw, the player within 48 px aborts the state and jumps at once
|
| 9 |
+
// Boss bomb (record 0): anim $27 8x8, gravity, X speed (|dx| - 24) / 51, Y 05.B0, dy -11, dx +8 along his look.
|
| 10 |
+
// It bursts on the floor or a wall into 12 shrapnel pieces ($F88A-$F8BA, no gravity, no tile collision); a piece
|
| 11 |
+
// flies 7-8 frames, turns into dust (still harmful) for 7 more and vanishes. Player shots pass through bombs and
|
| 12 |
+
// pieces (no flag bit 2); touching a bomb hurts but does not set it off. Bomb Man has no hit reaction.
|
| 13 |
+
// Tier knobs (specs/bomb_man.yaml): hp, bomb/shrapnel damage, contact damage, windup frames.
|
| 14 |
+
(function (g) {
|
| 15 |
+
var B = g.BB, BB = B, MM = B.MM, RM = MM.RobotMaster, fx = MM.fx;
|
| 16 |
+
// $E03B variant table: table index after the jump (state - 5), X speed, Y speed
|
| 17 |
+
var VARIANTS = [[8, fx(0x290), fx(0x760)], [17, fx(0x109), fx(0x5B0)], [8, fx(0x109), fx(0x5B0)]];
|
| 18 |
+
var SEQ = ['jump_pick', 'wait_bomb', 'throw', 'land_throw', 'throw', 'land_throw', 'throw', 'pattern_roll', 'walk_idle',
|
| 19 |
+
'leap_away', 'wait_bomb', 'throw', 'land_throw', 'throw', 'land_throw', 'throw', 'pattern_roll', 'walk_idle'];
|
| 20 |
+
var GUARD = 0x30, LEAD = 0x18, DIV = 0x33, BOMB_VY = fx(0x5B0);
|
| 21 |
+
// the shrapnel uses the spread_shot_spawn rows MM.SPREAD (body_megaman.js); the facing also sets a hit's knockback
|
| 22 |
+
// anim $39 (9 one-tick frames) starts at frame 1 and wraps to 0 after 8 renders: the pass that sees frame 0 turns
|
| 23 |
+
// it into dust $54 (8 one-tick frames from 0), which wraps after 8 more renders and is removed. A piece moves once
|
| 24 |
+
// per pass: 7 steps as shrapnel (8 if its slot comes after the bomb's, so the burst pass moves it too), 7 as dust.
|
| 25 |
+
var DUST_AT = 8, GONE_AT = 16;
|
| 26 |
+
// drop-in: the boss animation reaches frame byte $3C about 51 frames into the 94-frame intro (anim $1E, 13 ticks
|
| 27 |
+
// per frame, started at $01); the type $0C bomb (Y 03.30, dy -20, dx +6, no contact flag) only decorates the intro
|
| 28 |
+
var INTRO_BOMB_AT = 51, INTRO_BOMB_LIFE = 27;
|
| 29 |
+
|
| 30 |
+
function BombMan() {}
|
| 31 |
+
var P = BombMan.prototype;
|
| 32 |
+
RM.install(P, 'bomb_man', B.SPECS.bomb_man);
|
| 33 |
+
P.reset = function (c) {
|
| 34 |
+
this.base(c); this.n = 0; this.variant = -1; this.roll = -1; this.lastDx = 0;
|
| 35 |
+
this.jumps = 0; this.leaps = 0; this.guards = 0; this.bombs = 0; this.bursts = 0;
|
| 36 |
+
};
|
| 37 |
+
P.onFight = function () { this.n = 0; this.st = SEQ[0]; };
|
| 38 |
+
P.go = function (n) { this.n = n; this.st = SEQ[n]; };
|
| 39 |
+
P.back = function () { this.go(this.n - 1); };
|
| 40 |
+
|
| 41 |
+
// bombman_guard_range: |dx| < $30 resets the table to jump_pick and aborts the caller (PLA PLA)
|
| 42 |
+
P.guard = function (c) {
|
| 43 |
+
var d = this.lastDx = this.face(c);
|
| 44 |
+
if (d >= GUARD) return false;
|
| 45 |
+
this.go(0); this.guards++; return true;
|
| 46 |
+
};
|
| 47 |
+
P.windupStart = function () { this.back(); this.setPose('windup'); this.windup = Math.round(this.k.windup); };
|
| 48 |
+
P.jump = function (c, v) {
|
| 49 |
+
var row = VARIANTS[v];
|
| 50 |
+
this.windup = 0; this.variant = v; this.vx = row[1]; this.vy = row[2]; this.grounded = false;
|
| 51 |
+
this.setPose(v === 2 ? 'leap' : 'jump'); this.go(row[0]);
|
| 52 |
+
c.emit('mm_jump', this.x, this.y);
|
| 53 |
+
};
|
| 54 |
+
|
| 55 |
+
P.update = function (c) {
|
| 56 |
+
if (this.hp <= 0) return;
|
| 57 |
+
if (this.introTick()) {
|
| 58 |
+
if (RM.INTRO - this.intro === INTRO_BOMB_AT) this.spawnBomb(c, 'intro_bomb', this.x + 6 * this.look, this.y - 20, 0, fx(0x330));
|
| 59 |
+
MM.step(this); return;
|
| 60 |
+
}
|
| 61 |
+
switch (this.st) {
|
| 62 |
+
case 'jump_pick':
|
| 63 |
+
this.updateFacing(c); this.jumps++;
|
| 64 |
+
this.jump(c, c.rng.int(2)); break;
|
| 65 |
+
case 'leap_away':
|
| 66 |
+
this.updateFacing(c); this.dir = -this.dir; this.leaps++;
|
| 67 |
+
this.jump(c, 2); break;
|
| 68 |
+
case 'walk_idle':
|
| 69 |
+
if (this.walkTick(c)) { this.vx = 0; this.setPose('stand'); this.back(); c.emit('mm_land', this.x, MM.FLOOR); }
|
| 70 |
+
break;
|
| 71 |
+
case 'pattern_roll': {
|
| 72 |
+
if (this.guard(c)) break;
|
| 73 |
+
var r = this.roll = c.rng.int(6);
|
| 74 |
+
if (r & 1) { this.windupStart(); break; } // 3 bombs
|
| 75 |
+
this.go(this.n - 2);
|
| 76 |
+
if (!(r & 2)) { this.windupStart(); break; } // r 0 / 4: 2 bombs
|
| 77 |
+
this.go(this.n - 2); this.windupStart(); // r 2: 1 bomb
|
| 78 |
+
break;
|
| 79 |
+
}
|
| 80 |
+
case 'land_throw':
|
| 81 |
+
if (this.guard(c)) break;
|
| 82 |
+
if (this.out === 0) this.windupStart();
|
| 83 |
+
break;
|
| 84 |
+
case 'wait_bomb':
|
| 85 |
+
if (this.out === 0) this.back();
|
| 86 |
+
break;
|
| 87 |
+
case 'throw': {
|
| 88 |
+
if (this.guard(c)) break;
|
| 89 |
+
if (this.windup > 0) break;
|
| 90 |
+
this.back();
|
| 91 |
+
var d = this.lastDx >= LEAD ? this.lastDx - LEAD : this.lastDx;
|
| 92 |
+
var vx = Math.floor(d * 256 / DIV) / 256; // divide_16 quotient in 8.8
|
| 93 |
+
if (this.spawnBomb(c, 'bomb', this.x + 8 * this.look, this.y - 11, vx, BOMB_VY)) { this.bombs++; this.setPose('throw'); }
|
| 94 |
+
break;
|
| 95 |
+
}
|
| 96 |
+
}
|
| 97 |
+
};
|
| 98 |
+
P.spawnBomb = function (c, kind, x, y, vx, vy) {
|
| 99 |
+
var p = this.spawn({ kind: kind, x: x, y: y, dir: this.look, vx: vx, vy: vy, hw: 8, hh: 8, grav: true,
|
| 100 |
+
dmg: this.shotDamage(), harmless: kind === 'intro_bomb' });
|
| 101 |
+
if (!p) return null;
|
| 102 |
+
this.out++;
|
| 103 |
+
if (kind === 'bomb') c.emit('mm_boss_bomb', p.x, p.y);
|
| 104 |
+
return p;
|
| 105 |
+
};
|
| 106 |
+
// react_boss_bomb: $44--, in the fight the bomb becomes piece 11 in its own slot and pieces 10..0 fill free slots
|
| 107 |
+
P.burst = function (c, p) {
|
| 108 |
+
this.out = Math.max(0, this.out - 1);
|
| 109 |
+
if (!this.fight || p.kind === 'intro_bomb') { p.dead = true; return; }
|
| 110 |
+
this.bursts++;
|
| 111 |
+
var self = this;
|
| 112 |
+
function shard(q, row) {
|
| 113 |
+
q.kind = 'shrapnel'; q.row = row; q.vx = MM.SPREAD[row][0]; q.vy = MM.SPREAD[row][1]; q.grav = false; q.age = 0;
|
| 114 |
+
q.hw = 8; q.hh = 8; q.dir = MM.SPREAD[row][2] ? 1 : -1; return q;
|
| 115 |
+
}
|
| 116 |
+
shard(p, 11);
|
| 117 |
+
for (var row = 10; row >= 0; row--) {
|
| 118 |
+
var q = this.spawn({ x: p.x, y: p.y, dmg: this.shotDamage() });
|
| 119 |
+
if (!q) break; // no free slot: the burst is cut short
|
| 120 |
+
shard(q, row);
|
| 121 |
+
}
|
| 122 |
+
c.emit('mm_boss_burst', p.x, p.y);
|
| 123 |
+
};
|
| 124 |
+
// entity_pass over the boss's slots in slot order (pieces spawned into a later slot move in the same pass):
|
| 125 |
+
// bombs move x (wall probe, reason 3) then y with gravity (floor probe, reason 4); pieces float straight
|
| 126 |
+
P.entityPass = function (c) {
|
| 127 |
+
var self = this;
|
| 128 |
+
for (var slot = 16; slot < 32; slot++) this.passSlot(c, slot);
|
| 129 |
+
this.projectiles = this.projectiles.filter(function (p) { return !p.dead; });
|
| 130 |
+
};
|
| 131 |
+
P.passSlot = function (c, slot) {
|
| 132 |
+
var self = this, p = null;
|
| 133 |
+
this.projectiles.forEach(function (q) { if (q.slot === slot && !q.dead) p = q; });
|
| 134 |
+
if (!p) return;
|
| 135 |
+
(function () {
|
| 136 |
+
if (p.kind === 'bomb' || p.kind === 'intro_bomb') {
|
| 137 |
+
if (p.kind === 'intro_bomb' && p.age >= INTRO_BOMB_LIFE) { self.burst(c, p); return; }
|
| 138 |
+
var nx = p.x + p.vx * p.dir, lo = MM.WALL_L + p.hw, hi = MM.WALL_R - p.hw;
|
| 139 |
+
if (nx < lo || nx > hi) { p.x = nx < lo ? lo : hi; self.burst(c, p); return; }
|
| 140 |
+
p.x = nx;
|
| 141 |
+
var ny = p.y - p.vy;
|
| 142 |
+
if (p.vy < 0 && ny + p.hh >= MM.FLOOR) { p.y = MM.FLOOR - p.hh; self.burst(c, p); return; }
|
| 143 |
+
p.y = ny; p.vy = Math.max(-MM.FALL_MAX, p.vy - MM.GRAVITY);
|
| 144 |
+
return;
|
| 145 |
+
}
|
| 146 |
+
// shrapnel / dust: the one-shot animation ending (age counts renders since the burst) raises reason 0
|
| 147 |
+
if (p.age === DUST_AT) { p.kind = 'dust'; return; }
|
| 148 |
+
if (p.age >= GONE_AT) { p.dead = true; return; }
|
| 149 |
+
p.x += p.vx * p.dir;
|
| 150 |
+
var y = p.y - p.vy;
|
| 151 |
+
if (y < MM.TOP_EXIT || y >= MM.BOTTOM_EXIT || p.x < 0 || p.x >= 256) { p.dead = true; return; }
|
| 152 |
+
p.y = y;
|
| 153 |
+
})();
|
| 154 |
+
};
|
| 155 |
+
P.state = function () {
|
| 156 |
+
return this.baseState({ n: this.n, variant: this.variant, roll: this.roll, last_dx: this.lastDx, jumps: this.jumps,
|
| 157 |
+
leaps: this.leaps, guards: this.guards, bombs: this.bombs, bursts: this.bursts });
|
| 158 |
+
};
|
| 159 |
+
B.CASES = B.CASES || {};
|
| 160 |
+
BB.CASES['megaman/bomb_man'] = { title: 'Shard Lobber', Body: B.MegaMan, Boss: BombMan };
|
| 161 |
+
B.BombMan = BombMan;
|
| 162 |
+
})(typeof window !== 'undefined' ? window : globalThis);
|
environments/games/web/games/megaman_remake/bosses/cut_man.js
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Cut Man (game mode 0, fixed bank $DC8B). Port of the original 21-entry table $DFC0 ( 1.3):
|
| 2 |
+
// 5 retarget |dx| >= 64: walk; else jump - unless the player stands at another height (not in the air): chase
|
| 3 |
+
// 6 walk 01.20 toward the player; a wall (the step) -> jump
|
| 4 |
+
// 7 jump 06.40 up; random_mod 6 picks the landing class 2 (1/2, 32 px past), 1 (1/3, on him), 0 (1/6, 32 px short);
|
| 5 |
+
// X speed = (|dx| + $DFED[class]) / 50 with the original's 8-bit sign quirk
|
| 6 |
+
// 8/9/$C the frame after take-off: 2 in 3 (cutter home) the pose timer runs and he throws in mid-air
|
| 7 |
+
// $A-$D landing branches (a short 04.E0 hop near the player, coin flips)
|
| 8 |
+
// $E/$F land, then the throw stance $43: the cutter leaves on its 16th frame
|
| 9 |
+
// $10-$17 timed pose / mid-air throw pairs (timers 8, $12, $12, $15)
|
| 10 |
+
// $18 chase: stand 63 frames while the player is on another level, then throw
|
| 11 |
+
// hit for the first 32 of his 63 blink frames: turn away and hop (01.40 / 01.20), then state $E
|
| 12 |
+
// The Rolling Cutter (record 6, 6x6, no tile collision) is aimed at the player at 02.60 (proportional_velocity), turns
|
| 13 |
+
// back outside x [24, 232) / y [24, 216), and homes on him at 02.60 + 0.04 per retarget every 4th frame, caught within
|
| 14 |
+
// 8 px; one cutter at a time. AI timing reads the boss animation frame byte ($0441), so the animation counter is kept.
|
| 15 |
+
// Tier knobs (specs/cut_man.yaml): hp, cutter/contact damage, cutter speed scale, chase wait.
|
| 16 |
+
(function (g) {
|
| 17 |
+
var B = g.BB, BB = B, MM = B.MM, RM = MM.RobotMaster, fx = MM.fx;
|
| 18 |
+
// $DFC0 by seq_step - 5; entry 20 is the forced hit reaction (Y = $28), handled by react()
|
| 19 |
+
var SEQ = ['retarget', 'walk', 'jump', 'air_high', 'air_flip', 'descend', 'walk_until_blocked', 'air_land', 'walk_coinflip',
|
| 20 |
+
'land_settle', 'throw_windup', 'timed_pose', 'walk_throw', 'timed_pose', 'walk_throw', 'timed_pose', 'walk_throw',
|
| 21 |
+
'timed_pose', 'walk_throw', 'chase'];
|
| 22 |
+
var LAND = [0x08, 0x09, 0x0C], ADJUST = [-0x20, 0, 0x20], AFTER_THROW = [0x0E, 0x0A, 0x05, 0x05];
|
| 23 |
+
// animation rate bytes (advance_anim_counters $D2F8: low nibble = ticks per frame - 1, high nibble = last frame slot)
|
| 24 |
+
var RATE = { 0x1B: 0, 0x3F: 0x36, 0x41: 0x00, 0x43: 0x1F, 0x46: 0x18, 0x57: 0x00 };
|
| 25 |
+
var REACT = 0x1F, CUT_SPEED = 0x260, CHASE = 0x3F;
|
| 26 |
+
|
| 27 |
+
function CutMan() {}
|
| 28 |
+
var P = CutMan.prototype;
|
| 29 |
+
RM.install(P, 'cut_man', B.SPECS.cut_man);
|
| 30 |
+
var baseRender = P.renderTick;
|
| 31 |
+
// the step at the left of the room: tiles x 0-31 and the two liftable blocks x 32-96 (override type 2), top y 160
|
| 32 |
+
MM.blockRoom('megaman/cut_man');
|
| 33 |
+
P.reset = function (c) {
|
| 34 |
+
this.base(c); this.seq = 5; this.anim = 0x1B; this.af = 0; this.cut = 0; this.ret = 0; this.timer = 0;
|
| 35 |
+
this.jumps = 0; this.throws = 0; this.catches = 0; this.chases = 0; this.reacts = 0; this.lastClass = -1;
|
| 36 |
+
};
|
| 37 |
+
P.onFight = function () { this.go(5); };
|
| 38 |
+
P.go = function (n) { this.seq = n; this.st = SEQ[n - 5]; };
|
| 39 |
+
// same height ($0601 == ent_y_px) or the player in the air pose $09: the throw goes ahead; otherwise chase
|
| 40 |
+
P.level = function (c) { return Math.floor(this.y) === Math.floor(c.body.y) || c.body.airPose(); };
|
| 41 |
+
P.cutterHome = function () { return this.cut === 0; };
|
| 42 |
+
|
| 43 |
+
P.update = function (c) {
|
| 44 |
+
if (this.hp <= 0) return;
|
| 45 |
+
if (this.introTick()) { MM.step(this); return; }
|
| 46 |
+
this.trackCutter(c);
|
| 47 |
+
if (this.iframes >= REACT) { this.react(c); return; }
|
| 48 |
+
this[this.st](c);
|
| 49 |
+
};
|
| 50 |
+
// ---- the cutter service that runs before the state ----
|
| 51 |
+
P.trackCutter = function (c) {
|
| 52 |
+
if (!this.cut) return;
|
| 53 |
+
var p = this.projectiles.filter(function (q) { return q.kind === 'rolling_cutter'; })[0];
|
| 54 |
+
if (!p) return;
|
| 55 |
+
if (this.cut === 1) {
|
| 56 |
+
var px = Math.floor(p.x), py = Math.floor(p.y);
|
| 57 |
+
if (py < 0x18 || py >= 0xD8 || px < 0x18 || px >= 0xE8) {
|
| 58 |
+
this.cut = 2; p.dir = -p.dir; p.vy = -p.vy; this.ret = Math.round(CUT_SPEED * this.k.speed);
|
| 59 |
+
}
|
| 60 |
+
return;
|
| 61 |
+
}
|
| 62 |
+
if (c.t & 3) return; // returning: retarget the boss every 4th frame
|
| 63 |
+
var dx = Math.floor(this.x) - Math.floor(p.x);
|
| 64 |
+
p.dir = dx >= 0 ? 1 : -1; this.ret += 4;
|
| 65 |
+
var v = MM.propVel(this.ret, Math.abs(dx), Math.floor(p.y) - Math.floor(this.y));
|
| 66 |
+
p.vx = v.vx; p.vy = v.vy;
|
| 67 |
+
if (v.ady < 8 && Math.abs(dx) < 8) { p.dead = true; this.projectiles = this.projectiles.filter(function (q) { return !q.dead; }); this.cut = 0; this.catches++; }
|
| 68 |
+
};
|
| 69 |
+
// record 6 inherits the sprite flip at spawn time; the aim afterwards only sets the speeds (proportional_velocity)
|
| 70 |
+
P.throwCutter = function (c) {
|
| 71 |
+
var f = this.look, p = this.spawn({ kind: 'rolling_cutter', x: this.x + 8 * f, y: this.y - 10, dir: f, vx: 0, vy: 0, hw: 6, hh: 6, dmg: this.shotDamage() });
|
| 72 |
+
if (!p) return;
|
| 73 |
+
var adx = this.face(c), v = MM.propVel(Math.round(CUT_SPEED * this.k.speed), adx, Math.floor(this.y) - 10 - Math.floor(c.body.y));
|
| 74 |
+
p.vx = v.vx; p.vy = v.vy;
|
| 75 |
+
this.cut = 1; this.throws++; this.setPose('throw');
|
| 76 |
+
c.emit('mm_boss_cutter', p.x, p.y);
|
| 77 |
+
};
|
| 78 |
+
// throw stance: anim $43 without resetting the frame byte (the original leaves $0441 alone)
|
| 79 |
+
P.throwStance = function () { this.anim = 0x43; this.vx = 0; this.setPose('stance'); this.go(this.seq + 1); };
|
| 80 |
+
|
| 81 |
+
// ---- states ----
|
| 82 |
+
P.retarget = function (c) {
|
| 83 |
+
var n = 6;
|
| 84 |
+
if (this.face(c) < 0x40) n = this.level(c) ? 7 : 0x18;
|
| 85 |
+
this.go(n);
|
| 86 |
+
};
|
| 87 |
+
P.walk = function (c) {
|
| 88 |
+
this.updateFacing(c);
|
| 89 |
+
if (this.anim !== 0x3F) { this.anim = 0x3F; this.af = 0; this.vx = fx(0x120); this.setPose('walk'); }
|
| 90 |
+
this.walkTick(c);
|
| 91 |
+
if (this.blocked) this.go(7); else this.retarget(c);
|
| 92 |
+
};
|
| 93 |
+
P.jump = function (c) {
|
| 94 |
+
this.updateFacing(c); this.anim = 0x41; this.af = 0; this.setPose('jump');
|
| 95 |
+
var r = c.rng.int(6), k = 2;
|
| 96 |
+
if (!(r & 1)) { k = 1; if (r & 2) k = 0; }
|
| 97 |
+
this.lastClass = k; this.jumps++;
|
| 98 |
+
this.go(LAND[k]); this.vy = fx(0x640); this.grounded = false;
|
| 99 |
+
var v = (this.face(c) + ADJUST[k]) & 0xFF;
|
| 100 |
+
if (v & 0x80) v = (256 - v) & 0xFF; // BPL / EOR #$FF / ADC #1 on the 8-bit sum
|
| 101 |
+
this.vx = Math.floor(v * 256 / 50) / 256; // divide_16: X speed = v / 50 in 8.8
|
| 102 |
+
};
|
| 103 |
+
P.walkRandom = function (c) { this.walkTick(c); return c.rng.int(3); };
|
| 104 |
+
P.air_high = function (c) {
|
| 105 |
+
var r = this.walkRandom(c);
|
| 106 |
+
if (!(r & 1) && this.cutterHome()) { this.go(0x10); this.timer = 8; } else this.go(0x0E);
|
| 107 |
+
};
|
| 108 |
+
P.air_flip = function (c) {
|
| 109 |
+
var r = this.walkRandom(c);
|
| 110 |
+
if (!(r & 1) && this.cutterHome()) { this.go(0x12); this.timer = 0x12; } else this.go(this.seq + 1);
|
| 111 |
+
};
|
| 112 |
+
P.air_land = function (c) {
|
| 113 |
+
var r = this.walkRandom(c);
|
| 114 |
+
if (!(r & 1) && this.cutterHome()) { this.go(0x16); this.timer = 0x15; } else this.go(0x0D);
|
| 115 |
+
};
|
| 116 |
+
P.descend = function (c) {
|
| 117 |
+
if (!this.walkTick(c)) return;
|
| 118 |
+
this.go(this.seq + 1);
|
| 119 |
+
if (this.face(c) >= 0x0E) { this.go(5); return; }
|
| 120 |
+
if ((c.rng.int(3) & 1) && this.cutterHome()) { this.go(0x14); this.timer = 0x12; }
|
| 121 |
+
this.vy = fx(0x4E0); this.vx = fx(0xC0); this.grounded = false; // short hop
|
| 122 |
+
};
|
| 123 |
+
P.walk_until_blocked = function (c) { if (this.walkTick(c)) this.go(5); };
|
| 124 |
+
P.walk_coinflip = function (c) {
|
| 125 |
+
if (!this.walkTick(c)) return;
|
| 126 |
+
if (c.rng.int(2)) this.go(5); else this.go(this.seq + 1);
|
| 127 |
+
};
|
| 128 |
+
P.land_settle = function (c) {
|
| 129 |
+
if (!this.walkTick(c)) return;
|
| 130 |
+
if (!this.cutterHome()) { this.go(5); return; }
|
| 131 |
+
if (!this.level(c)) { this.go(0x18); return; }
|
| 132 |
+
this.throwStance();
|
| 133 |
+
};
|
| 134 |
+
P.throw_windup = function (c) {
|
| 135 |
+
this.walkTick(c);
|
| 136 |
+
if (this.af === 0) { this.go(5); return; }
|
| 137 |
+
if (this.af === 0x10) this.throwCutter(c);
|
| 138 |
+
};
|
| 139 |
+
P.timed_pose = function (c) {
|
| 140 |
+
this.walkTick(c);
|
| 141 |
+
if (--this.timer > 0) return;
|
| 142 |
+
this.anim = 0x43; this.af = 0; this.setPose('stance'); this.go(this.seq + 1);
|
| 143 |
+
};
|
| 144 |
+
P.walk_throw = function (c) {
|
| 145 |
+
if (this.af === 0) this.anim = 0x41;
|
| 146 |
+
else if (this.af === 0x10) this.throwCutter(c);
|
| 147 |
+
if (!this.walkTick(c)) return;
|
| 148 |
+
if (!this.level(c)) { this.go(0x18); return; }
|
| 149 |
+
this.go(AFTER_THROW[(this.seq & 7) >> 1]);
|
| 150 |
+
};
|
| 151 |
+
P.chase = function (c) {
|
| 152 |
+
if (this.anim !== 0x46) { this.anim = 0x46; this.af = 0; this.timer = Math.round(this.k.wait); this.vx = 0; this.chases++; this.setPose('chase'); }
|
| 153 |
+
this.walkTick(c);
|
| 154 |
+
var same = Math.floor(this.y) === Math.floor(c.body.y);
|
| 155 |
+
if (!same || c.body.airPose()) {
|
| 156 |
+
if (this.timer > 0 && --this.timer > 0) return;
|
| 157 |
+
}
|
| 158 |
+
if (!this.cutterHome()) return;
|
| 159 |
+
this.go(0x0E); this.throwStance();
|
| 160 |
+
};
|
| 161 |
+
// boss_anim_hop: the first reaction frame turns away and hops; mode 0 restarts at state $E
|
| 162 |
+
P.react = function (c) {
|
| 163 |
+
if (this.anim !== 0x57) {
|
| 164 |
+
this.anim = 0x57; this.af = 0; this.updateFacing(c); this.dir = -this.dir;
|
| 165 |
+
this.vy = fx(0x140); this.vx = fx(0x120); this.grounded = false; this.go(0x0E); this.reacts++; this.setPose('hurt');
|
| 166 |
+
}
|
| 167 |
+
this.walkTick(c);
|
| 168 |
+
};
|
| 169 |
+
|
| 170 |
+
// entity pass: the cutter flies straight (no gravity, no tile collision) and is removed if it leaves the screen
|
| 171 |
+
P.entityPass = function () {
|
| 172 |
+
var self = this;
|
| 173 |
+
this.projectiles.forEach(function (p) {
|
| 174 |
+
p.x += p.vx * p.dir; p.y -= p.vy;
|
| 175 |
+
if (MM.offscreen(p)) p.dead = true;
|
| 176 |
+
});
|
| 177 |
+
this.projectiles = this.projectiles.filter(function (p) { return !p.dead; });
|
| 178 |
+
};
|
| 179 |
+
// render: the shared counters, then the animation frame byte the AI reads
|
| 180 |
+
P.renderTick = function (c) {
|
| 181 |
+
baseRender.call(this, c);
|
| 182 |
+
var rate = RATE[this.anim] || 0, lo = this.af & 15;
|
| 183 |
+
if (lo < (rate & 15)) this.af++;
|
| 184 |
+
else this.af = (this.af & 0xF0) >= (rate & 0xF0) ? 0 : (this.af & 0xF0) + 0x10;
|
| 185 |
+
};
|
| 186 |
+
P.state = function () {
|
| 187 |
+
return this.baseState({ seq: this.seq, anim: this.anim, af: this.af, cutter: this.cut, ret: this.ret, jumps: this.jumps,
|
| 188 |
+
throws: this.throws, catches: this.catches, chases: this.chases, reacts: this.reacts, last_class: this.lastClass });
|
| 189 |
+
};
|
| 190 |
+
B.CASES = B.CASES || {};
|
| 191 |
+
BB.CASES['megaman/cut_man'] = { title: 'Blade Tosser', Body: B.MegaMan, Boss: CutMan };
|
| 192 |
+
B.CutMan = CutMan;
|
| 193 |
+
})(typeof window !== 'undefined' ? window : globalThis);
|
environments/games/web/games/megaman_remake/bosses/elec_man.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Elec Man (game mode 4, fixed bank $E434). Port of the original state machine:
|
| 2 |
+
// guard walk at 02.00 toward the wall position $E550[step] (176, 128, 48, 128) looking where he goes;
|
| 3 |
+
// arriving starts the shot; the player pressing fire (or a wall) makes him leap at once
|
| 4 |
+
// halt stop and wind up (15 frames) fire release the Thunder Beam, then wait until it has left
|
| 5 |
+
// leap jump 04.00 up / 01.E0 forward toward the player, 1 in 4 a feint away; pressing fire while he is in
|
| 6 |
+
// the air makes him wind up and fire in mid-air; landing restarts the pattern
|
| 7 |
+
// react for the first 32 of his 63 blink frames after a hit: turn away and hop (01.40 up, 01.20)
|
| 8 |
+
// The Thunder Beam (records 7-$0B, 01.50 px/frame) is five pieces that crawl: each time a piece's 10-frame
|
| 9 |
+
// animation wraps it jumps ahead and changes shape ($9AF4 x, $9AFC y, $9B04 next; staggered first wraps).
|
| 10 |
+
// Tier knobs (specs/elec_man.yaml): hp, beam/contact damage, walk speed, windup, chance to counter a shot.
|
| 11 |
+
(function (g) {
|
| 12 |
+
var B = g.BB, BB = B, MM = B.MM, RM = MM.RobotMaster, fx = MM.fx;
|
| 13 |
+
var WALLS = [0xB0, 0x80, 0x30, 0x80];
|
| 14 |
+
MM.ELEC_BOLT = { jx: [29, 33, 33, 29, 25, 29, 29, 29], jy: [-4, -24, 0, 28, 16, -12, -4, -4],
|
| 15 |
+
next: [5, 6, 7, 1, 2, 3, 4, 5], hw: [4, 8, 4, 4, 4, 8, 8, 4], hh: [8, 4, 8, 8, 8, 4, 4, 8] };
|
| 16 |
+
var PIECES = [[20, -4, 2], [24, 8, 4], [28, -4, 6], [36, -20, 8], [44, -20, 9]]; // dx, dy, first wrap
|
| 17 |
+
var REACT = 0x1F;
|
| 18 |
+
|
| 19 |
+
function ElecMan() {}
|
| 20 |
+
var P = ElecMan.prototype;
|
| 21 |
+
RM.install(P, 'elec_man', B.SPECS.elec_man);
|
| 22 |
+
P.reset = function (c) { this.base(c); this.step = 0; this.leaps = 0; this.feints = 0; this.bolts = 0; this.counters = 0; };
|
| 23 |
+
P.onFight = function () { this.st = 'guard'; };
|
| 24 |
+
|
| 25 |
+
P.fireBolt = function (c) {
|
| 26 |
+
var self = this, f = this.look, made = 0;
|
| 27 |
+
PIECES.forEach(function (r, i) {
|
| 28 |
+
var p = self.spawn({ kind: 'thunder_beam', x: self.x + r[0] * f, y: self.y + r[1], dir: f, vx: fx(0x150), row: i, t: r[2],
|
| 29 |
+
hw: MM.ELEC_BOLT.hw[i], hh: MM.ELEC_BOLT.hh[i], dmg: self.shotDamage() });
|
| 30 |
+
if (p) made++;
|
| 31 |
+
});
|
| 32 |
+
this.out += made; this.bolts++;
|
| 33 |
+
c.emit('mm_boss_bolt', this.x, this.y);
|
| 34 |
+
};
|
| 35 |
+
P.countered = function (c) {
|
| 36 |
+
if (!c.body.fired) return false;
|
| 37 |
+
var k = this.k.counter;
|
| 38 |
+
return k >= 1 || (k > 0 && c.rng.chance(k));
|
| 39 |
+
};
|
| 40 |
+
P.halt = function () { this.vx = 0; };
|
| 41 |
+
|
| 42 |
+
P.update = function (c) {
|
| 43 |
+
if (this.hp <= 0) return;
|
| 44 |
+
if (this.introTick()) { MM.step(this); return; }
|
| 45 |
+
if (this.iframes >= REACT) { this.react(c); return; }
|
| 46 |
+
switch (this.st) {
|
| 47 |
+
case 'guard': {
|
| 48 |
+
if (this.pose !== 'walk') { this.setPose('walk'); this.vx = this.k.walk; }
|
| 49 |
+
var target = WALLS[this.step & 3], d = this.faceTo(target);
|
| 50 |
+
if (d < 3) this.st = 'halt';
|
| 51 |
+
this.dir = this.look; // boss_update_facing toward the wall position
|
| 52 |
+
this.walkNoFace();
|
| 53 |
+
if (this.blocked || this.countered(c)) { this.st = 'leap'; this.counters++; }
|
| 54 |
+
break;
|
| 55 |
+
}
|
| 56 |
+
case 'halt':
|
| 57 |
+
this.halt(); this.setPose('fire'); this.windup = this.k.windup; this.st = 'fire';
|
| 58 |
+
this.walkTick(c); break;
|
| 59 |
+
case 'fire':
|
| 60 |
+
if (this.windup <= 0) { this.fireBolt(c); this.st = 'wait'; }
|
| 61 |
+
this.walkTick(c); break;
|
| 62 |
+
case 'wait':
|
| 63 |
+
this.walkTick(c);
|
| 64 |
+
if (this.out <= 0) { this.step = (this.step + 1) & 3; this.st = 'guard'; }
|
| 65 |
+
break;
|
| 66 |
+
case 'leap':
|
| 67 |
+
this.setPose('leap'); this.vx = fx(0x1E0); this.vy = 4;
|
| 68 |
+
this.updateFacing(c); this.leaps++;
|
| 69 |
+
if (c.rng.int(4) === 0) { this.dir = -this.dir; this.feints++; }
|
| 70 |
+
this.st = 'air'; break;
|
| 71 |
+
case 'air':
|
| 72 |
+
if (this.walkTick(c)) { this.st = 'guard'; break; }
|
| 73 |
+
if (c.body.fired) this.st = 'air_pose';
|
| 74 |
+
break;
|
| 75 |
+
case 'air_pose':
|
| 76 |
+
this.setPose('fire'); this.windup = this.k.windup; this.st = 'air_fire';
|
| 77 |
+
if (this.walkTick(c)) this.halt();
|
| 78 |
+
break;
|
| 79 |
+
case 'air_fire':
|
| 80 |
+
if (this.windup <= 0) { this.fireBolt(c); this.st = 'air_land'; }
|
| 81 |
+
if (this.walkTick(c)) this.halt();
|
| 82 |
+
break;
|
| 83 |
+
case 'air_land':
|
| 84 |
+
if (this.out <= 0) this.st = 'guard';
|
| 85 |
+
if (this.walkTick(c)) this.halt();
|
| 86 |
+
break;
|
| 87 |
+
}
|
| 88 |
+
};
|
| 89 |
+
// boss_anim_hop: on the first react frame turn away from the player and hop, the pattern restarts at guard
|
| 90 |
+
P.react = function (c) {
|
| 91 |
+
if (this.pose !== 'hurt') {
|
| 92 |
+
this.setPose('hurt'); this.updateFacing(c); this.dir = -this.dir;
|
| 93 |
+
this.vy = fx(0x140); this.vx = fx(0x120); this.st = 'guard';
|
| 94 |
+
}
|
| 95 |
+
this.walkTick(c);
|
| 96 |
+
};
|
| 97 |
+
|
| 98 |
+
// entity pass for the Thunder Beam pieces (react_pickup $9AF4 chain): wrap -> jump, otherwise drift
|
| 99 |
+
P.entityPass = function () {
|
| 100 |
+
var self = this, T = MM.ELEC_BOLT;
|
| 101 |
+
this.projectiles.forEach(function (p) {
|
| 102 |
+
if (p.t <= 0) {
|
| 103 |
+
p.x += T.jx[p.row] * p.dir + (p.dir > 0 ? fx(0x50) : 0); p.y += T.jy[p.row];
|
| 104 |
+
p.row = T.next[p.row]; p.hw = T.hw[p.row]; p.hh = T.hh[p.row]; p.t = 10;
|
| 105 |
+
} else p.x += p.vx * p.dir;
|
| 106 |
+
if (MM.offscreen(p)) { p.dead = true; self.out--; }
|
| 107 |
+
});
|
| 108 |
+
this.projectiles = this.projectiles.filter(function (p) { return !p.dead; });
|
| 109 |
+
};
|
| 110 |
+
|
| 111 |
+
P.state = function () {
|
| 112 |
+
return this.baseState({ step: this.step, leaps: this.leaps, feints: this.feints, bolts: this.bolts, counters: this.counters });
|
| 113 |
+
};
|
| 114 |
+
B.CASES = B.CASES || {};
|
| 115 |
+
BB.CASES['megaman/elec_man'] = { title: 'Pouncer', Body: B.MegaMan, Boss: ElecMan };
|
| 116 |
+
B.ElecMan = ElecMan;
|
| 117 |
+
})(typeof window !== 'undefined' ? window : globalThis);
|
environments/games/web/games/megaman_remake/bosses/fire_man.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Fire Man (game mode 3, fixed bank $E2E4). Port of the original state machine:
|
| 2 |
+
// pace keep |dx| to the player inside the band [95, 97): walk toward him at 01.20 when farther, turn and
|
| 3 |
+
// walk away when closer; backed into a wall he turns and walks at (and past) the player
|
| 4 |
+
// volley five Fire Storm waves, each followed by a 63-frame stance; after the first 15 stance frames,
|
| 5 |
+
// leaving the band cancels the volley; after the fifth wave he holds a pose until the player
|
| 6 |
+
// presses anything or leaves the band. Deviation: the original holds that pose forever while the
|
| 7 |
+
// player stays perfectly still; BossBench requires a boss to keep engaging, so the pose ends after
|
| 8 |
+
// POSE_MAX = 90 frames (1.5 s) and he resumes pacing.
|
| 9 |
+
// retaliate 14 frames into his 30 blink frames after a hit he starts a new volley at once
|
| 10 |
+
// A wave (record 1) forms at his hand for 23 frames at 00.20, then runs at 05.10 ($37 X-speed row 6). When a
|
| 11 |
+
// running wave passes within 8 px of the player, a fire pillar (record 4, 16 x 16) rises there at floor level
|
| 12 |
+
// and burns for 131 frames (anim $38, 12 slots x 11 ticks) unless the next wave puts it out.
|
| 13 |
+
// Tier knobs (specs/fire_man.yaml): hp, wave/contact damage, stance length, retaliation on/off.
|
| 14 |
+
(function (g) {
|
| 15 |
+
var B = g.BB, BB = B, MM = B.MM, RM = MM.RobotMaster, fx = MM.fx;
|
| 16 |
+
var BAND_LO = 0x5F, BAND_HI = 0x61, FORM_T = 23, PILLAR_T = 131, EARLY = 15, POSE_MAX = 90;
|
| 17 |
+
var SEQ = ['pace', 'walk_far', 'summon', 'hold', 'spawn', 'hold', 'spawn', 'hold', 'spawn', 'hold', 'spawn', 'pose'];
|
| 18 |
+
|
| 19 |
+
function FireMan() {}
|
| 20 |
+
var P = FireMan.prototype;
|
| 21 |
+
RM.install(P, 'fire_man', B.SPECS.fire_man);
|
| 22 |
+
P.reset = function (c) { this.base(c); this.n = 0; this.waves = 0; this.pillars = 0; this.volleys = 0; this.retaliations = 0; };
|
| 23 |
+
P.onFight = function () { this.go(0); };
|
| 24 |
+
P.go = function (n) { this.n = n; this.st = SEQ[n]; };
|
| 25 |
+
P.inBand = function (d) { return d >= BAND_LO && d < BAND_HI; };
|
| 26 |
+
P.hold = function () { return Math.round(this.k.hold); };
|
| 27 |
+
|
| 28 |
+
// record 1 (wave) at 8 px ahead, 8 px above centre; spawning a wave puts out the old pillar
|
| 29 |
+
P.spawnWave = function (c) {
|
| 30 |
+
this.face(c);
|
| 31 |
+
var f = this.look, p = this.spawn({ kind: 'fire_wave', x: this.x + 8 * f, y: this.y - 8, dir: f, vx: fx(0x20),
|
| 32 |
+
t: FORM_T, running: false, hw: 8, hh: 16, dmg: this.shotDamage() });
|
| 33 |
+
if (!p) return false;
|
| 34 |
+
this.timer = this.hold(); this.waves++;
|
| 35 |
+
this.projectiles = this.projectiles.filter(function (q) { return q.kind !== 'fire_pillar'; });
|
| 36 |
+
c.emit('mm_boss_wave', p.x, p.y);
|
| 37 |
+
return true;
|
| 38 |
+
};
|
| 39 |
+
// pre-dispatch: a running wave within 8 px of the player raises (or moves) the pillar under it
|
| 40 |
+
P.tendWaves = function (c) {
|
| 41 |
+
for (var i = 0; i < this.projectiles.length; i++) {
|
| 42 |
+
var w = this.projectiles[i];
|
| 43 |
+
if (w.kind !== 'fire_wave' || !w.running || Math.abs(c.body.x - w.x) >= 8) continue;
|
| 44 |
+
var pillar = null;
|
| 45 |
+
this.projectiles.forEach(function (q) { if (q.kind === 'fire_pillar') pillar = q; });
|
| 46 |
+
if (pillar) { pillar.x = w.x; pillar.y = this.y + 4; pillar.t = PILLAR_T; pillar.age = 0; }
|
| 47 |
+
else if (this.spawn({ kind: 'fire_pillar', x: w.x, y: this.y + 4, dir: this.look, vx: 0, t: PILLAR_T, hw: 8, hh: 8, dmg: this.shotDamage() })) {
|
| 48 |
+
this.pillars++; c.emit('mm_boss_pillar', w.x, this.y + 4);
|
| 49 |
+
}
|
| 50 |
+
return;
|
| 51 |
+
}
|
| 52 |
+
};
|
| 53 |
+
P.walkPace = function () {
|
| 54 |
+
this.dir = this.look; // sync facing memory
|
| 55 |
+
if (this.pose !== 'walk') { this.setPose('walk'); this.vx = fx(0x120); }
|
| 56 |
+
this.walkNoFace();
|
| 57 |
+
};
|
| 58 |
+
|
| 59 |
+
P.update = function (c) {
|
| 60 |
+
if (this.hp <= 0) return;
|
| 61 |
+
if (this.introTick()) { MM.step(this); return; }
|
| 62 |
+
if (this.iframes === 0x10 && this.k.retaliate >= 0.5) { this.go(2); this.retaliations++; }
|
| 63 |
+
this.tendWaves(c);
|
| 64 |
+
var d;
|
| 65 |
+
switch (this.st) {
|
| 66 |
+
case 'pace':
|
| 67 |
+
d = this.face(c);
|
| 68 |
+
if (this.inBand(d)) { this.go(2); break; }
|
| 69 |
+
if (d < BAND_LO) this.look = -this.look; // too close: turn away
|
| 70 |
+
this.walkPace();
|
| 71 |
+
if (this.blocked) { this.updateFacing(c); this.go(1); }
|
| 72 |
+
break;
|
| 73 |
+
case 'walk_far':
|
| 74 |
+
var keep = this.look; d = this.face(c);
|
| 75 |
+
if (d >= BAND_HI) { this.go(0); break; }
|
| 76 |
+
this.look = keep; this.walkNoFace();
|
| 77 |
+
if (this.blocked) { this.updateFacing(c); this.go(0); }
|
| 78 |
+
break;
|
| 79 |
+
case 'summon':
|
| 80 |
+
this.vx = 0; this.setPose('summon'); this.volleys++;
|
| 81 |
+
if (this.spawnWave(c)) this.go(this.n + 1);
|
| 82 |
+
break;
|
| 83 |
+
case 'spawn':
|
| 84 |
+
this.vx = 0; this.setPose('summon');
|
| 85 |
+
if (this.spawnWave(c)) this.go(this.n + 1);
|
| 86 |
+
break;
|
| 87 |
+
case 'hold':
|
| 88 |
+
if (this.timer < this.hold() - EARLY) { // original: range check once the timer is below $30
|
| 89 |
+
d = this.face(c);
|
| 90 |
+
if (!this.inBand(d)) { this.go(0); break; }
|
| 91 |
+
}
|
| 92 |
+
if (--this.timer <= 0) this.go(this.n + 1);
|
| 93 |
+
break;
|
| 94 |
+
case 'pose': // stand down after the volley
|
| 95 |
+
d = this.face(c);
|
| 96 |
+
if (this.pose !== 'pose') { this.setPose('pose'); this.timer = POSE_MAX; }
|
| 97 |
+
if (!this.inBand(d) || c.body.anyInput || --this.timer <= 0) this.go(0);
|
| 98 |
+
break;
|
| 99 |
+
}
|
| 100 |
+
};
|
| 101 |
+
|
| 102 |
+
// entity pass: waves form then run; pillars burn down
|
| 103 |
+
P.entityPass = function () {
|
| 104 |
+
this.projectiles.forEach(function (p) {
|
| 105 |
+
if (p.kind === 'fire_wave') {
|
| 106 |
+
if (!p.running && p.t <= 0) { p.running = true; p.vx = fx(0x510); } // react_hyper_bomb: $36 -> $37, row 6
|
| 107 |
+
else p.x += p.vx * p.dir;
|
| 108 |
+
} else if (p.kind === 'fire_pillar' && p.t <= 0) p.dead = true;
|
| 109 |
+
if (MM.offscreen(p)) p.dead = true;
|
| 110 |
+
});
|
| 111 |
+
this.projectiles = this.projectiles.filter(function (p) { return !p.dead; });
|
| 112 |
+
};
|
| 113 |
+
P.state = function () {
|
| 114 |
+
return this.baseState({ n: this.n, waves: this.waves, pillars: this.pillars, volleys: this.volleys, retaliations: this.retaliations });
|
| 115 |
+
};
|
| 116 |
+
B.CASES = B.CASES || {};
|
| 117 |
+
BB.CASES['megaman/fire_man'] = { title: 'Wave Keeper', Body: B.MegaMan, Boss: FireMan };
|
| 118 |
+
B.FireMan = FireMan;
|
| 119 |
+
})(typeof window !== 'undefined' ? window : globalThis);
|
environments/games/web/games/megaman_remake/bosses/guts_man.js
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Guts Man (game mode 5, fixed bank $E56E). Port of the original 21-entry table $E6CA:
|
| 2 |
+
// 5 leap a 15-frame crouch ($0641 = $1F), then straight up at 04.30 -> $19
|
| 3 |
+
// $19 in the air without X speed; landing quakes, and a ceiling rock (record 3) falls into his hands
|
| 4 |
+
// $18 / $17 wait for that rock and the quake, 15-frame windup, throw the rock (record 2) at the player
|
| 5 |
+
// $16 wait for the rock to shatter; random_mod 3: 0 throw again, 1 three leaps toward, 2 a leap away
|
| 6 |
+
// airborne X speed 01.09; the walk tick runs only 3 of every 4 frames (x, y and gravity alike)
|
| 7 |
+
// landing shake_timer = $20: the land_* states wait it out, and the NMI stuns a player who is not in the jump
|
| 8 |
+
// pose (body_megaman.js quake(); the player's special state 2)
|
| 9 |
+
// The thrown rock (anim $32, 14 x 14 half size, no gravity, cannot be shot) flies at 04.00 at the player's feet and
|
| 10 |
+
// shatters on any tile or screen edge into 4 chunks (anim $56, 4 x 4, no gravity, no tile collision) placed at the rock's
|
| 11 |
+
// position + (8,8) (24,8) (8,24) (24,24): the rock path does not take off the 16 px the player's block path does.
|
| 12 |
+
// The ceiling rock has no contact flag: it only decorates the 23 frames before he can throw. Guts Man has no hit reaction.
|
| 13 |
+
// Tier knobs (specs/guts_man.yaml): hp, rock/chunk damage, contact damage, windup frames, rock speed scale.
|
| 14 |
+
(function (g) {
|
| 15 |
+
var B = g.BB, BB = B, MM = B.MM, RM = MM.RobotMaster, fx = MM.fx;
|
| 16 |
+
// $E6CA by seq_step - 5
|
| 17 |
+
var SEQ = ['leap', 'land_wait', 'airborne', 'land_b', 'airborne', 'land_a', 'airborne', 'land_rehop', 'airborne', 'land_rehop',
|
| 18 |
+
'airborne', 'land_wait', 'airborne', 'land_rehop', 'airborne', 'land_roll', 'airborne', 'pattern_roll', 'throw_rock',
|
| 19 |
+
'windup_rock', 'ceiling_rock'];
|
| 20 |
+
var LEAP_VY = fx(0x430), AIR_VX = fx(0x109), SHAKE = 0x20, ROCK_SPEED = 0x400;
|
| 21 |
+
// record 3 starts at anim frame byte $19 unless he stands at y $C0, which this room's floor never gives (y $B0):
|
| 22 |
+
// anim $32 (rate $2F) wraps after 23 renders, and the pass that sees frame 0 ends it
|
| 23 |
+
var CEILING_LIFE = 23, CEILING_VY = -fx(0xC0);
|
| 24 |
+
var CHUNKS = [[8, 8, 4, 2], [24, 8, 4, 0], [8, 24, 3, 2], [24, 24, 3, 0]]; // $F826 x, $F82A y, $F82E X speed, $F832 Y speed
|
| 25 |
+
|
| 26 |
+
function GutsMan() {}
|
| 27 |
+
var P = GutsMan.prototype;
|
| 28 |
+
RM.install(P, 'guts_man', B.SPECS.guts_man);
|
| 29 |
+
var baseRender = P.renderTick;
|
| 30 |
+
MM.blockRoom('megaman/guts_man');
|
| 31 |
+
P.reset = function (c) {
|
| 32 |
+
this.base(c); this.y = 0xB0; this.hw = 16; this.hh = 16; this.seq = 5; this.shake = 0; this.roll = -1;
|
| 33 |
+
this.leaps = 0; this.quakes = 0; this.rocks = 0; this.ceilings = 0; this.shatters = 0;
|
| 34 |
+
};
|
| 35 |
+
P.onFight = function () { this.go(5); };
|
| 36 |
+
P.go = function (n) { this.seq = n; this.st = SEQ[n - 5]; };
|
| 37 |
+
|
| 38 |
+
P.update = function (c) {
|
| 39 |
+
if (this.hp <= 0) return;
|
| 40 |
+
if (this.introTick()) { MM.step(this); return; }
|
| 41 |
+
this[this.st](c);
|
| 42 |
+
};
|
| 43 |
+
// gutsman_leap: every leap starts from this crouch and goes to $19 unless the caller picks another airborne state
|
| 44 |
+
P.startLeap = function () {
|
| 45 |
+
this.windup = Math.round(this.k.windup); this.vx = 0; this.vy = LEAP_VY; this.setPose('crouch'); this.leaps++;
|
| 46 |
+
this.go(0x19);
|
| 47 |
+
};
|
| 48 |
+
// gutsman_leap_away: face the player, leap, but move away from him
|
| 49 |
+
P.leapAway = function (c) { this.updateFacing(c); this.startLeap(); this.dir = -this.dir; this.go(0x13); };
|
| 50 |
+
// gutsman_air_tick: returns true on the landing frame (one state back, the quake starts)
|
| 51 |
+
P.airTick = function (c) {
|
| 52 |
+
if (this.windup > 0 || !(c.t & 3)) return false;
|
| 53 |
+
this.setPose('air');
|
| 54 |
+
if (!this.walkTick(c)) return false;
|
| 55 |
+
this.go(this.seq - 1); this.setPose('land'); this.shake = SHAKE; this.quakes++;
|
| 56 |
+
c.emit('mm_quake', this.x, this.y + this.hh);
|
| 57 |
+
return true;
|
| 58 |
+
};
|
| 59 |
+
|
| 60 |
+
// ---- states ----
|
| 61 |
+
P.leap = function () { this.startLeap(); };
|
| 62 |
+
P.airborne = function (c) { this.vx = AIR_VX; this.airTick(c); };
|
| 63 |
+
P.land_wait = function () { if (!this.shake) this.go(5); };
|
| 64 |
+
P.land_b = function (c) { if (this.shake) return; this.leapAway(c); this.go(7); };
|
| 65 |
+
P.land_a = function (c) {
|
| 66 |
+
if (this.shake) return;
|
| 67 |
+
if (c.rng.int(2)) { this.leapAway(c); this.go(9); } else this.go(5);
|
| 68 |
+
};
|
| 69 |
+
P.land_rehop = function (c) {
|
| 70 |
+
if (this.shake) return;
|
| 71 |
+
var s = this.seq; this.updateFacing(c); this.startLeap(); this.go(s - 1);
|
| 72 |
+
};
|
| 73 |
+
P.land_roll = function (c) {
|
| 74 |
+
if (this.shake) return;
|
| 75 |
+
if (c.rng.int(2)) this.go(5); else this.leapAway(c);
|
| 76 |
+
};
|
| 77 |
+
P.pattern_roll = function (c) {
|
| 78 |
+
if (this.out) return;
|
| 79 |
+
this.updateFacing(c);
|
| 80 |
+
var r = this.roll = c.rng.int(3);
|
| 81 |
+
if (r === 0) { this.go(5); return; }
|
| 82 |
+
this.startLeap();
|
| 83 |
+
if (r === 1) this.go(0x0F); else { this.go(0x15); this.dir = -this.dir; }
|
| 84 |
+
};
|
| 85 |
+
P.throw_rock = function (c) {
|
| 86 |
+
if (this.windup > 0) return;
|
| 87 |
+
var adx = this.face(c), f = this.look; this.go(0x16);
|
| 88 |
+
var p = this.spawn({ kind: 'rock', x: this.x + 16 * f, y: this.y - 24, dir: f, vx: 0, vy: 0, hw: 14, hh: 14, dmg: this.shotDamage() });
|
| 89 |
+
if (!p) return;
|
| 90 |
+
// aimed from the height of the rock over his head at the player's feet (ent_y_px + 12)
|
| 91 |
+
var v = MM.propVel(Math.round(ROCK_SPEED * this.k.speed), adx, Math.floor(this.y) - 24 - (Math.floor(c.body.y) + 12));
|
| 92 |
+
p.vx = v.vx; p.vy = v.vy; this.out++; this.rocks++; this.setPose('throw');
|
| 93 |
+
c.emit('mm_boss_rock', p.x, p.y);
|
| 94 |
+
};
|
| 95 |
+
// gutsman_windup rewrites $0641 every frame until the rock is gone and the quake over, so the 15 frames start then
|
| 96 |
+
P.windup_rock = function () {
|
| 97 |
+
if (this.out) return;
|
| 98 |
+
this.setPose('lift'); this.windup = Math.round(this.k.windup);
|
| 99 |
+
if (!this.shake) this.go(0x17);
|
| 100 |
+
};
|
| 101 |
+
P.ceiling_rock = function (c) {
|
| 102 |
+
if (!this.airTick(c)) return;
|
| 103 |
+
this.setPose('lift');
|
| 104 |
+
var p = this.spawn({ kind: 'ceiling_rock', x: this.x - 10 * this.look, y: 0x20, dir: this.look, vx: 0, vy: CEILING_VY, hw: 14, hh: 14, harmless: true, t: CEILING_LIFE, dmg: 0 });
|
| 105 |
+
if (p) { this.out++; this.ceilings++; }
|
| 106 |
+
};
|
| 107 |
+
|
| 108 |
+
// react_thrown_block: $44--, the rock's slot is free for the chunks, which fill free slots from $10
|
| 109 |
+
P.shatter = function (c, p) {
|
| 110 |
+
var self = this;
|
| 111 |
+
this.out = Math.max(0, this.out - 1); this.shatters++;
|
| 112 |
+
this.projectiles = this.projectiles.filter(function (q) { return q !== p; });
|
| 113 |
+
CHUNKS.forEach(function (r) {
|
| 114 |
+
self.spawn({ kind: 'rock_chunk', x: p.x + r[0], y: p.y + r[1], dir: p.dir, vx: r[2], vy: r[3], hw: 4, hh: 4, dmg: self.shotDamage() });
|
| 115 |
+
});
|
| 116 |
+
c.emit('mm_boss_shatter', p.x, p.y);
|
| 117 |
+
};
|
| 118 |
+
// entity_pass in slot order, so chunks spawned into a later slot than the rock's move in the same pass
|
| 119 |
+
P.entityPass = function (c) {
|
| 120 |
+
for (var slot = 16; slot < 32; slot++) this.passSlot(c, slot);
|
| 121 |
+
this.projectiles = this.projectiles.filter(function (p) { return !p.dead; });
|
| 122 |
+
};
|
| 123 |
+
P.passSlot = function (c, slot) {
|
| 124 |
+
var p = null;
|
| 125 |
+
this.projectiles.forEach(function (q) { if (q.slot === slot && !q.dead) p = q; });
|
| 126 |
+
if (!p) return;
|
| 127 |
+
if (p.kind === 'ceiling_rock') {
|
| 128 |
+
if (p.t <= 0) { p.dead = true; this.out = Math.max(0, this.out - 1); return; }
|
| 129 |
+
p.y -= p.vy; p.vy = Math.max(-MM.FALL_MAX, p.vy - MM.GRAVITY);
|
| 130 |
+
return;
|
| 131 |
+
}
|
| 132 |
+
if (p.kind === 'rock_chunk') {
|
| 133 |
+
p.x += p.vx * p.dir; p.y -= p.vy;
|
| 134 |
+
if (MM.offscreen(p)) p.dead = true;
|
| 135 |
+
return;
|
| 136 |
+
}
|
| 137 |
+
// the rock: X with the wall probes, then Y with the floor probe while falling; any stop shatters it
|
| 138 |
+
var nx = p.x + p.vx * p.dir, lo = MM.WALL_L + p.hw, hi = MM.WALL_R - p.hw, stop = false;
|
| 139 |
+
if (nx < lo) { nx = lo; stop = true; } else if (nx > hi) { nx = hi; stop = true; }
|
| 140 |
+
if (this.room.length) { var cx = MM.clampX(this.room, p.x, nx, p.hw, p.y, p.hh); if (cx !== nx) { nx = cx; stop = true; } }
|
| 141 |
+
p.x = nx;
|
| 142 |
+
if (stop) { this.shatter(c, p); return; }
|
| 143 |
+
var ny = p.y - p.vy, floor = this.room.length ? MM.floorUnder(this.room, p.x - p.hw + 1, p.x + p.hw - 1, p.y + p.hh) : MM.FLOOR;
|
| 144 |
+
if (p.vy < 0 && ny + p.hh >= floor) { p.y = floor - p.hh; this.shatter(c, p); return; }
|
| 145 |
+
if (ny < MM.TOP_EXIT || ny >= MM.BOTTOM_EXIT) { this.shatter(c, p); return; } // the vertical exit keeps the old y
|
| 146 |
+
p.y = ny;
|
| 147 |
+
};
|
| 148 |
+
// render: the shared counters, then the NMI: each shake frame stuns the player and counts down ($20 NMIs)
|
| 149 |
+
P.renderTick = function (c) {
|
| 150 |
+
baseRender.call(this, c);
|
| 151 |
+
if (this.shake > 0) { c.body.quake(); this.shake--; }
|
| 152 |
+
};
|
| 153 |
+
P.state = function () {
|
| 154 |
+
return this.baseState({ seq: this.seq, shake: this.shake, roll: this.roll, leaps: this.leaps, quakes: this.quakes,
|
| 155 |
+
rocks: this.rocks, ceilings: this.ceilings, shatters: this.shatters });
|
| 156 |
+
};
|
| 157 |
+
B.CASES = B.CASES || {};
|
| 158 |
+
BB.CASES['megaman/guts_man'] = { title: 'Quake Hurler', Body: B.MegaMan, Boss: GutsMan };
|
| 159 |
+
B.GutsMan = GutsMan;
|
| 160 |
+
})(typeof window !== 'undefined' ? window : globalThis);
|
environments/games/web/games/megaman_remake/bosses/ice_man.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Ice Man (game mode 1, fixed bank $E111). Port of the original state machine:
|
| 2 |
+
// walk to the waypoint $E2C8[n] (208, 168, 128, 168) at 01.20, stance (15-frame windup), hop straight up
|
| 3 |
+
// (04.DF); falling past y 148 / 164 / 180 he fires an Ice Slasher at each level and, with gravity switched
|
| 4 |
+
// off, sinks at a slow speed; he hovers $E2D8 frames (48/46/38/27), fires at the bottom, then rises back
|
| 5 |
+
// through 164 and 148 firing again - six slashers per cycle in a V; finally gravity returns with a 02.C0 pop
|
| 6 |
+
// and he lands. Every landing advances the waypoint and the pattern counter (0..9); counter / 3 picks the
|
| 7 |
+
// slasher speed (01.60 / 01.80 / 02.00 / 02.E0), hover time and sink speed, so the pattern speeds up.
|
| 8 |
+
// Ice Man has no hit reaction. Tier knobs (specs/ice_man.yaml): hp, slasher/contact damage, slasher speed
|
| 9 |
+
// scale, hover scale, stance windup.
|
| 10 |
+
(function (g) {
|
| 11 |
+
var B = g.BB, BB = B, MM = B.MM, RM = MM.RobotMaster, fx = MM.fx;
|
| 12 |
+
var WAYPOINTS = [0xD0, 0xA8, 0x80, 0xA8];
|
| 13 |
+
var SPEEDS = [fx(0x160), fx(0x180), fx(0x200), fx(0x2E0)];
|
| 14 |
+
var HOVER = [0x30, 0x2E, 0x26, 0x1B];
|
| 15 |
+
var SINK = [-(1 - fx(0x60)), -(1 - fx(0x50)), -(1 - fx(0x2C)), -(2 - fx(0xE0))]; // $FF.60 $FF.50 $FF.2C $FE.E0
|
| 16 |
+
var DOWN = [0x94, 0xA4, 0xB4], UP = [0xA5, 0x95];
|
| 17 |
+
// the 19 states of the mode 1 table, in order
|
| 18 |
+
var SEQ = ['leg_start', 'leg_walk', 'stance', 'hop', 'rise', 'fire', 'rise', 'fire', 'rise', 'fire', 'set_timer',
|
| 19 |
+
'hover', 'fire', 'climb', 'fire', 'climb', 'fire', 'drop', 'land'];
|
| 20 |
+
|
| 21 |
+
function IceMan() {}
|
| 22 |
+
var P = IceMan.prototype;
|
| 23 |
+
RM.install(P, 'ice_man', B.SPECS.ice_man);
|
| 24 |
+
P.reset = function (c) { this.base(c); this.n = 0; this.wp = 0; this.counter = 0; this.level = 0; this.volleys = 0; this.slashers = 0; };
|
| 25 |
+
P.onFight = function () { this.n = 0; this.st = SEQ[0]; };
|
| 26 |
+
P.next = function () { this.n++; this.st = SEQ[this.n]; };
|
| 27 |
+
P.q = function () { return Math.floor(this.counter / 3); };
|
| 28 |
+
|
| 29 |
+
P.update = function (c) {
|
| 30 |
+
if (this.hp <= 0) return;
|
| 31 |
+
if (this.introTick()) { MM.step(this); return; }
|
| 32 |
+
var wx = WAYPOINTS[this.wp & 3], q = this.q();
|
| 33 |
+
switch (this.st) {
|
| 34 |
+
case 'leg_start':
|
| 35 |
+
this.setPose('walk'); this.vx = fx(0x120);
|
| 36 |
+
this.faceTo(wx); this.dir = this.look; this.next(); break;
|
| 37 |
+
case 'leg_walk':
|
| 38 |
+
if (this.faceTo(wx) < 2) { // fire stance: anim + 1, nearly stop
|
| 39 |
+
this.setPose('stance'); this.windup = this.k.windup; this.vx = fx(0x10); this.next();
|
| 40 |
+
} else this.walkNoFace();
|
| 41 |
+
break;
|
| 42 |
+
case 'stance':
|
| 43 |
+
if (this.windup > 0) this.walkNoFace(); else this.next();
|
| 44 |
+
break;
|
| 45 |
+
case 'hop':
|
| 46 |
+
this.face(c); this.vx = 0; this.vy = fx(0x4DF); this.setPose('jump'); this.level = 0; this.next(); break;
|
| 47 |
+
case 'rise': // falling past the next level: sink slowly
|
| 48 |
+
this.walkTick(c);
|
| 49 |
+
if (this.vy < 0 && this.y >= DOWN[this.level]) { this.vy = SINK[q]; this.grav = false; this.level++; this.next(); }
|
| 50 |
+
break;
|
| 51 |
+
case 'fire':
|
| 52 |
+
this.face(c); this.fireSlasher(c, q); this.next(); break;
|
| 53 |
+
case 'set_timer':
|
| 54 |
+
this.timer = Math.round(HOVER[q] * this.k.hover); this.next(); break;
|
| 55 |
+
case 'hover':
|
| 56 |
+
this.updateFacing(c);
|
| 57 |
+
if (--this.timer <= 0) { this.vy = -this.vy; this.level = 0; this.next(); }
|
| 58 |
+
break;
|
| 59 |
+
case 'climb':
|
| 60 |
+
this.walkTick(c);
|
| 61 |
+
if (this.y < UP[this.level]) { this.level++; this.next(); }
|
| 62 |
+
break;
|
| 63 |
+
case 'drop':
|
| 64 |
+
this.grav = true; this.vy = fx(0x2C0); this.next(); break;
|
| 65 |
+
case 'land':
|
| 66 |
+
if (this.walkTick(c)) {
|
| 67 |
+
if (this.counter < 9) this.counter++;
|
| 68 |
+
this.wp = (this.wp + 1) & 3; this.volleys++;
|
| 69 |
+
this.n = 0; this.st = SEQ[0];
|
| 70 |
+
}
|
| 71 |
+
break;
|
| 72 |
+
}
|
| 73 |
+
};
|
| 74 |
+
// record 5: Ice Slasher 2 px above centre, 8 px ahead, speed $E2CC[counter / 3]
|
| 75 |
+
P.fireSlasher = function (c, q) {
|
| 76 |
+
var f = this.look;
|
| 77 |
+
var p = this.spawn({ kind: 'ice_slasher', x: this.x + 8 * f, y: this.y - 2, dir: f, vx: SPEEDS[q] * this.k.speed,
|
| 78 |
+
hw: 4, hh: 4, dmg: this.shotDamage() });
|
| 79 |
+
if (p) { this.slashers++; c.emit('mm_boss_slasher', p.x, p.y); }
|
| 80 |
+
this.setPose('shoot');
|
| 81 |
+
};
|
| 82 |
+
P.entityPass = function () {
|
| 83 |
+
this.projectiles.forEach(function (p) { p.x += p.vx * p.dir; if (MM.offscreen(p)) p.dead = true; });
|
| 84 |
+
this.projectiles = this.projectiles.filter(function (p) { return !p.dead; });
|
| 85 |
+
};
|
| 86 |
+
P.state = function () {
|
| 87 |
+
return this.baseState({ n: this.n, waypoint: this.wp, counter: this.counter, level: this.level,
|
| 88 |
+
volleys: this.volleys, slashers: this.slashers });
|
| 89 |
+
};
|
| 90 |
+
B.CASES = B.CASES || {};
|
| 91 |
+
BB.CASES['megaman/ice_man'] = { title: 'V Gunner', Body: B.MegaMan, Boss: IceMan };
|
| 92 |
+
B.IceMan = IceMan;
|
| 93 |
+
})(typeof window !== 'undefined' ? window : globalThis);
|
environments/games/web/games/megaman_remake/bosses/robot_master.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Shared parts of a Robot Master fight (boss_fight_controller $DB8C and the fixed-bank boss services $EDC2-$EF36).
|
| 2 |
+
// A boss keeps two facings like the original: `look` is the sprite flip ($0421 bit 6, set by boss_face_player)
|
| 3 |
+
// and `dir` is the movement memory ($43 bit 6, copied from the flip by boss_update_facing). Bosses stand at
|
| 4 |
+
// x $C0 / y $B4 when the fight starts ($ED9A/$EDA3), have gravity, and blink for a per-mode number of frames after
|
| 5 |
+
// every hit, during which the player's shots pass through ($C994). The intro locks the player's input while the
|
| 6 |
+
// boss drops in and its bar fills (one unit every other frame, boss_hp_fill_tick $F39B).
|
| 7 |
+
(function (g) {
|
| 8 |
+
var B = g.BB, MM = B.MM;
|
| 9 |
+
// intro timer $5E = 94 frames from the drop-in to the fight (boss_fight_controller $DB8C); the bar fills one unit
|
| 10 |
+
// every other frame once the timer is below $3A, i.e. 28 units over the last 56 frames
|
| 11 |
+
var DROP = 0x5E - 0x3A + 2, FILL = 0x3A - 2;
|
| 12 |
+
|
| 13 |
+
var RM = MM.RobotMaster = {};
|
| 14 |
+
RM.install = function (P, id, spec) {
|
| 15 |
+
P.id = id; P.spec = spec; P.info = MM.ROBOT_MASTERS[id];
|
| 16 |
+
P.base = function (c) {
|
| 17 |
+
var k = this.k = MM.knobs(spec, c.d);
|
| 18 |
+
this.room = MM.roomOf(c.id);
|
| 19 |
+
this.x = 0xC0; this.y = 0xB4; this.vx = 0; this.vy = 0; this.dir = -1; this.look = -1;
|
| 20 |
+
this.hw = 8; this.hh = 12; this.grav = true; this.grounded = true; this.blocked = false; this.landed = false;
|
| 21 |
+
this.max_hp = this.hp = Math.round(k.hp) * MM.UNIT;
|
| 22 |
+
this.iframes = 0; this.intro = DROP + FILL; this.fight = false;
|
| 23 |
+
this.projectiles = []; this.nextId = 1; this.out = 0;
|
| 24 |
+
this.windup = 0; this.pose = 'stand'; this.poseT = 0; this.timer = 0;
|
| 25 |
+
this.st = 'intro'; this.hitsBy = {}; this.damageBy = {}; this.lastHit = null;
|
| 26 |
+
this.dmg = MM.CONTACT * MM.UNIT;
|
| 27 |
+
};
|
| 28 |
+
P.introTick = function () {
|
| 29 |
+
if (this.intro <= 0) return false;
|
| 30 |
+
this.intro--;
|
| 31 |
+
if (this.intro === 0) { this.fight = true; this.onFight(); }
|
| 32 |
+
return true;
|
| 33 |
+
};
|
| 34 |
+
P.hitBox = function () { return MM.box(this.x, this.y, this.hw, this.hh); };
|
| 35 |
+
P.bodyBox = P.hitBox;
|
| 36 |
+
P.contactDamage = function () { return Math.round(this.k.contact * MM.UNIT); };
|
| 37 |
+
P.shotDamage = function () { return Math.round(this.k.shot * MM.UNIT); };
|
| 38 |
+
// boss_face_player: sprite flip toward px (default: the player), returns |dx| in whole pixels (the original
|
| 39 |
+
// subtracts the integer pixel bytes, so band and arrival checks are integer comparisons)
|
| 40 |
+
P.faceTo = function (px) { var d = Math.floor(px) - Math.floor(this.x); this.look = d >= 0 ? 1 : -1; return Math.abs(d); };
|
| 41 |
+
P.face = function (c) { return this.faceTo(c.body.x); };
|
| 42 |
+
P.updateFacing = function (c, px) { this.faceTo(px == null ? c.body.x : px); this.dir = this.look; };
|
| 43 |
+
P.walkNoFace = function () { MM.step(this); return this.landed; };
|
| 44 |
+
P.walkTick = function (c) { this.face(c); return this.walkNoFace(); };
|
| 45 |
+
P.setPose = function (name) { if (this.pose !== name) { this.pose = name; this.poseT = 0; } };
|
| 46 |
+
P.spawn = function (p) {
|
| 47 |
+
var slot = MM.freeSlot(this.projectiles);
|
| 48 |
+
if (slot < 0) return null;
|
| 49 |
+
p.slot = slot; p.id = this.nextId++; p.age = 0; this.projectiles.push(p); return p;
|
| 50 |
+
};
|
| 51 |
+
// shot hit on the boss ($C8B2): damage from the table (0 still blinks), lethal hits end the fight
|
| 52 |
+
P.takeHit = function (c, w, sx, sy) {
|
| 53 |
+
var units = MM.DAMAGE[id][w] || 0, dmg = units * MM.UNIT;
|
| 54 |
+
this.hitsBy[w] = (this.hitsBy[w] || 0) + 1; this.damageBy[w] = (this.damageBy[w] || 0) + dmg;
|
| 55 |
+
this.lastHit = { t: c.t, w: w, units: units };
|
| 56 |
+
if (dmg >= this.hp) {
|
| 57 |
+
this.hp = 0; this.st = 'dead'; this.fight = false; this.projectiles = [];
|
| 58 |
+
c.emit('mm_boss_dead', this.x, this.y); return;
|
| 59 |
+
}
|
| 60 |
+
this.hp -= dmg; this.iframes = this.info.iframes;
|
| 61 |
+
c.emit(units ? 'mm_hit' : 'mm_clank', sx, sy);
|
| 62 |
+
if (this.onHit) this.onHit(c, w);
|
| 63 |
+
};
|
| 64 |
+
// render-time counters: the blink ($56 is ticked by draw_entity), anim-control windups, pose clocks
|
| 65 |
+
P.renderTick = function () {
|
| 66 |
+
if (this.iframes > 0) this.iframes--;
|
| 67 |
+
if (this.windup > 0) this.windup--;
|
| 68 |
+
this.poseT++;
|
| 69 |
+
this.projectiles.forEach(function (p) { if (p.t != null) p.t--; p.age++; });
|
| 70 |
+
};
|
| 71 |
+
P.baseState = function (extra) {
|
| 72 |
+
var o = { x: this.x, y: this.y, vx: this.vx, vy: this.vy, dir: this.dir, look: this.look, grav: this.grav,
|
| 73 |
+
grounded: this.grounded, hp: this.hp, max_hp: this.max_hp, iframes: this.iframes, intro: this.intro,
|
| 74 |
+
fight: this.fight, fsm: this.st, timer: this.timer, windup: this.windup, pose: this.pose, pose_t: this.poseT,
|
| 75 |
+
out: this.out, projectiles: this.projectiles, next_id: this.nextId, hits_by: this.hitsBy,
|
| 76 |
+
damage_by: this.damageBy, last_hit: this.lastHit };
|
| 77 |
+
Object.keys(extra || {}).forEach(function (key) { o[key] = extra[key]; });
|
| 78 |
+
return MM.snapshot(o);
|
| 79 |
+
};
|
| 80 |
+
// the shared Case wiring (default interact() is replaced by the body's resolveInteractions)
|
| 81 |
+
P.onNailHit = function () { return null; };
|
| 82 |
+
P.hazards = function () {
|
| 83 |
+
if (this.hp <= 0) return [];
|
| 84 |
+
var out = [{ kind: id + '_body', box: { x: this.x, y: this.y, w: this.hw * 2, h: this.hh * 2 }, dmg: this.contactDamage() }];
|
| 85 |
+
this.projectiles.forEach(function (p) { if (!p.harmless) out.push({ kind: p.kind, box: { x: p.x, y: p.y, w: p.hw * 2, h: p.hh * 2 }, dmg: p.dmg }); });
|
| 86 |
+
return out;
|
| 87 |
+
};
|
| 88 |
+
};
|
| 89 |
+
RM.INTRO = DROP + FILL; RM.DROP = DROP; RM.FILL = FILL;
|
| 90 |
+
})(typeof window !== 'undefined' ? window : globalThis);
|
environments/games/web/games/megaman_remake/compact_actions.json
ADDED
|
@@ -0,0 +1,373 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema": "bossbench/compact-actions@1",
|
| 3 |
+
"game": "megaman_remake",
|
| 4 |
+
"version": "megaman-compact@1",
|
| 5 |
+
"heads": [
|
| 6 |
+
{
|
| 7 |
+
"name": "move",
|
| 8 |
+
"options": [
|
| 9 |
+
{
|
| 10 |
+
"label": "none"
|
| 11 |
+
},
|
| 12 |
+
{
|
| 13 |
+
"label": "left",
|
| 14 |
+
"keys": [
|
| 15 |
+
"A"
|
| 16 |
+
]
|
| 17 |
+
},
|
| 18 |
+
{
|
| 19 |
+
"label": "right",
|
| 20 |
+
"keys": [
|
| 21 |
+
"D"
|
| 22 |
+
]
|
| 23 |
+
},
|
| 24 |
+
{
|
| 25 |
+
"label": "left_half",
|
| 26 |
+
"subs": [
|
| 27 |
+
[
|
| 28 |
+
"A"
|
| 29 |
+
],
|
| 30 |
+
[
|
| 31 |
+
"A"
|
| 32 |
+
],
|
| 33 |
+
[
|
| 34 |
+
"A"
|
| 35 |
+
],
|
| 36 |
+
[],
|
| 37 |
+
[],
|
| 38 |
+
[]
|
| 39 |
+
]
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"label": "right_half",
|
| 43 |
+
"subs": [
|
| 44 |
+
[
|
| 45 |
+
"D"
|
| 46 |
+
],
|
| 47 |
+
[
|
| 48 |
+
"D"
|
| 49 |
+
],
|
| 50 |
+
[
|
| 51 |
+
"D"
|
| 52 |
+
],
|
| 53 |
+
[],
|
| 54 |
+
[],
|
| 55 |
+
[]
|
| 56 |
+
]
|
| 57 |
+
},
|
| 58 |
+
{
|
| 59 |
+
"label": "left_4",
|
| 60 |
+
"subs": [
|
| 61 |
+
[
|
| 62 |
+
"A"
|
| 63 |
+
],
|
| 64 |
+
[
|
| 65 |
+
"A"
|
| 66 |
+
],
|
| 67 |
+
[
|
| 68 |
+
"A"
|
| 69 |
+
],
|
| 70 |
+
[
|
| 71 |
+
"A"
|
| 72 |
+
],
|
| 73 |
+
[],
|
| 74 |
+
[]
|
| 75 |
+
]
|
| 76 |
+
},
|
| 77 |
+
{
|
| 78 |
+
"label": "right_4",
|
| 79 |
+
"subs": [
|
| 80 |
+
[
|
| 81 |
+
"D"
|
| 82 |
+
],
|
| 83 |
+
[
|
| 84 |
+
"D"
|
| 85 |
+
],
|
| 86 |
+
[
|
| 87 |
+
"D"
|
| 88 |
+
],
|
| 89 |
+
[
|
| 90 |
+
"D"
|
| 91 |
+
],
|
| 92 |
+
[],
|
| 93 |
+
[]
|
| 94 |
+
]
|
| 95 |
+
}
|
| 96 |
+
]
|
| 97 |
+
},
|
| 98 |
+
{
|
| 99 |
+
"name": "jump",
|
| 100 |
+
"options": [
|
| 101 |
+
{
|
| 102 |
+
"label": "none"
|
| 103 |
+
},
|
| 104 |
+
{
|
| 105 |
+
"label": "hold",
|
| 106 |
+
"keys": [
|
| 107 |
+
"Space"
|
| 108 |
+
]
|
| 109 |
+
},
|
| 110 |
+
{
|
| 111 |
+
"label": "tap",
|
| 112 |
+
"subs": [
|
| 113 |
+
[
|
| 114 |
+
"Space"
|
| 115 |
+
],
|
| 116 |
+
[],
|
| 117 |
+
[],
|
| 118 |
+
[],
|
| 119 |
+
[],
|
| 120 |
+
[]
|
| 121 |
+
]
|
| 122 |
+
},
|
| 123 |
+
{
|
| 124 |
+
"label": "from_2",
|
| 125 |
+
"subs": [
|
| 126 |
+
[],
|
| 127 |
+
[
|
| 128 |
+
"Space"
|
| 129 |
+
],
|
| 130 |
+
[
|
| 131 |
+
"Space"
|
| 132 |
+
],
|
| 133 |
+
[
|
| 134 |
+
"Space"
|
| 135 |
+
],
|
| 136 |
+
[
|
| 137 |
+
"Space"
|
| 138 |
+
],
|
| 139 |
+
[
|
| 140 |
+
"Space"
|
| 141 |
+
]
|
| 142 |
+
]
|
| 143 |
+
},
|
| 144 |
+
{
|
| 145 |
+
"label": "from_3",
|
| 146 |
+
"subs": [
|
| 147 |
+
[],
|
| 148 |
+
[],
|
| 149 |
+
[
|
| 150 |
+
"Space"
|
| 151 |
+
],
|
| 152 |
+
[
|
| 153 |
+
"Space"
|
| 154 |
+
],
|
| 155 |
+
[
|
| 156 |
+
"Space"
|
| 157 |
+
],
|
| 158 |
+
[
|
| 159 |
+
"Space"
|
| 160 |
+
]
|
| 161 |
+
]
|
| 162 |
+
},
|
| 163 |
+
{
|
| 164 |
+
"label": "from_4",
|
| 165 |
+
"subs": [
|
| 166 |
+
[],
|
| 167 |
+
[],
|
| 168 |
+
[],
|
| 169 |
+
[
|
| 170 |
+
"Space"
|
| 171 |
+
],
|
| 172 |
+
[
|
| 173 |
+
"Space"
|
| 174 |
+
],
|
| 175 |
+
[
|
| 176 |
+
"Space"
|
| 177 |
+
]
|
| 178 |
+
]
|
| 179 |
+
},
|
| 180 |
+
{
|
| 181 |
+
"label": "from_5",
|
| 182 |
+
"subs": [
|
| 183 |
+
[],
|
| 184 |
+
[],
|
| 185 |
+
[],
|
| 186 |
+
[],
|
| 187 |
+
[
|
| 188 |
+
"Space"
|
| 189 |
+
],
|
| 190 |
+
[
|
| 191 |
+
"Space"
|
| 192 |
+
]
|
| 193 |
+
]
|
| 194 |
+
},
|
| 195 |
+
{
|
| 196 |
+
"label": "at_6",
|
| 197 |
+
"subs": [
|
| 198 |
+
[],
|
| 199 |
+
[],
|
| 200 |
+
[],
|
| 201 |
+
[],
|
| 202 |
+
[],
|
| 203 |
+
[
|
| 204 |
+
"Space"
|
| 205 |
+
]
|
| 206 |
+
]
|
| 207 |
+
},
|
| 208 |
+
{
|
| 209 |
+
"label": "first_2",
|
| 210 |
+
"subs": [
|
| 211 |
+
[
|
| 212 |
+
"Space"
|
| 213 |
+
],
|
| 214 |
+
[
|
| 215 |
+
"Space"
|
| 216 |
+
],
|
| 217 |
+
[],
|
| 218 |
+
[],
|
| 219 |
+
[],
|
| 220 |
+
[]
|
| 221 |
+
]
|
| 222 |
+
},
|
| 223 |
+
{
|
| 224 |
+
"label": "first_5",
|
| 225 |
+
"subs": [
|
| 226 |
+
[
|
| 227 |
+
"Space"
|
| 228 |
+
],
|
| 229 |
+
[
|
| 230 |
+
"Space"
|
| 231 |
+
],
|
| 232 |
+
[
|
| 233 |
+
"Space"
|
| 234 |
+
],
|
| 235 |
+
[
|
| 236 |
+
"Space"
|
| 237 |
+
],
|
| 238 |
+
[
|
| 239 |
+
"Space"
|
| 240 |
+
],
|
| 241 |
+
[]
|
| 242 |
+
]
|
| 243 |
+
},
|
| 244 |
+
{
|
| 245 |
+
"label": "first_3",
|
| 246 |
+
"subs": [
|
| 247 |
+
[
|
| 248 |
+
"Space"
|
| 249 |
+
],
|
| 250 |
+
[
|
| 251 |
+
"Space"
|
| 252 |
+
],
|
| 253 |
+
[
|
| 254 |
+
"Space"
|
| 255 |
+
],
|
| 256 |
+
[],
|
| 257 |
+
[],
|
| 258 |
+
[]
|
| 259 |
+
]
|
| 260 |
+
},
|
| 261 |
+
{
|
| 262 |
+
"label": "first_4",
|
| 263 |
+
"subs": [
|
| 264 |
+
[
|
| 265 |
+
"Space"
|
| 266 |
+
],
|
| 267 |
+
[
|
| 268 |
+
"Space"
|
| 269 |
+
],
|
| 270 |
+
[
|
| 271 |
+
"Space"
|
| 272 |
+
],
|
| 273 |
+
[
|
| 274 |
+
"Space"
|
| 275 |
+
],
|
| 276 |
+
[],
|
| 277 |
+
[]
|
| 278 |
+
]
|
| 279 |
+
},
|
| 280 |
+
{
|
| 281 |
+
"label": "tap_rehold",
|
| 282 |
+
"subs": [
|
| 283 |
+
[
|
| 284 |
+
"Space"
|
| 285 |
+
],
|
| 286 |
+
[],
|
| 287 |
+
[
|
| 288 |
+
"Space"
|
| 289 |
+
],
|
| 290 |
+
[
|
| 291 |
+
"Space"
|
| 292 |
+
],
|
| 293 |
+
[
|
| 294 |
+
"Space"
|
| 295 |
+
],
|
| 296 |
+
[
|
| 297 |
+
"Space"
|
| 298 |
+
]
|
| 299 |
+
]
|
| 300 |
+
},
|
| 301 |
+
{
|
| 302 |
+
"label": "tap_tap6",
|
| 303 |
+
"subs": [
|
| 304 |
+
[
|
| 305 |
+
"Space"
|
| 306 |
+
],
|
| 307 |
+
[],
|
| 308 |
+
[],
|
| 309 |
+
[],
|
| 310 |
+
[],
|
| 311 |
+
[
|
| 312 |
+
"Space"
|
| 313 |
+
]
|
| 314 |
+
]
|
| 315 |
+
},
|
| 316 |
+
{
|
| 317 |
+
"label": "tap_hold5",
|
| 318 |
+
"subs": [
|
| 319 |
+
[
|
| 320 |
+
"Space"
|
| 321 |
+
],
|
| 322 |
+
[],
|
| 323 |
+
[],
|
| 324 |
+
[],
|
| 325 |
+
[
|
| 326 |
+
"Space"
|
| 327 |
+
],
|
| 328 |
+
[
|
| 329 |
+
"Space"
|
| 330 |
+
]
|
| 331 |
+
]
|
| 332 |
+
}
|
| 333 |
+
]
|
| 334 |
+
},
|
| 335 |
+
{
|
| 336 |
+
"name": "fire",
|
| 337 |
+
"options": [
|
| 338 |
+
{
|
| 339 |
+
"label": "none"
|
| 340 |
+
},
|
| 341 |
+
{
|
| 342 |
+
"label": "fire",
|
| 343 |
+
"subs": [
|
| 344 |
+
[
|
| 345 |
+
"J"
|
| 346 |
+
],
|
| 347 |
+
[],
|
| 348 |
+
[
|
| 349 |
+
"J"
|
| 350 |
+
],
|
| 351 |
+
[],
|
| 352 |
+
[
|
| 353 |
+
"J"
|
| 354 |
+
],
|
| 355 |
+
[]
|
| 356 |
+
]
|
| 357 |
+
},
|
| 358 |
+
{
|
| 359 |
+
"label": "next_weapon",
|
| 360 |
+
"tap": [
|
| 361 |
+
"E"
|
| 362 |
+
]
|
| 363 |
+
},
|
| 364 |
+
{
|
| 365 |
+
"label": "prev_weapon",
|
| 366 |
+
"tap": [
|
| 367 |
+
"Q"
|
| 368 |
+
]
|
| 369 |
+
}
|
| 370 |
+
]
|
| 371 |
+
}
|
| 372 |
+
]
|
| 373 |
+
}
|
environments/games/web/games/megaman_remake/data/weapons.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Data-driven weapon x boss tables of Mega Man (NES, 1987), transcribed from the ROM via the annotated
|
| 2 |
+
// disassembly (plasticsmoke/megaman1-disassembly-ca65 @2771fb3, see SOURCES.md S-DASM):
|
| 3 |
+
// $FDEE weapon damage vs boss, 8 weapons (P C I B F E G M) x game mode (0 Cut 1 Ice 2 Bomb 3 Fire 4 Elec 5 Guts)
|
| 4 |
+
// $C994 boss post-hit invulnerability frames per mode
|
| 5 |
+
// $FEBB damage a boss projectile deals per mode; boss body contact is a flat 4 (player_contact_service)
|
| 6 |
+
// $A8DE weapon energy units per shot ($A8D7 shots-per-charge is 1 for every weapon)
|
| 7 |
+
// Every Robot Master is listed so scenes 4-6 plug in later; `built` marks what this round implements.
|
| 8 |
+
(function (g) {
|
| 9 |
+
var MM = g.BB.MM;
|
| 10 |
+
MM.WEAPON_ORDER = ['P', 'C', 'I', 'B', 'F', 'E', 'G', 'M'];
|
| 11 |
+
MM.WEAPONS = {
|
| 12 |
+
P: { name: 'Arm Gun', zh: 'Arm Gun', from: null, cost: 0, built: true },
|
| 13 |
+
C: { name: 'Return Blade', zh: 'Returning blade', from: 'cut_man', cost: 1, built: true },
|
| 14 |
+
I: { name: 'Pierce Dart', zh: 'Pierce Dart', from: 'ice_man', cost: 1, built: true },
|
| 15 |
+
B: { name: 'Fuse Lob', zh: 'Fuse Lob', from: 'bomb_man', cost: 2, built: true },
|
| 16 |
+
F: { name: 'Orbit Guard', zh: 'Orbit Guard', from: 'fire_man', cost: 1, built: true },
|
| 17 |
+
E: { name: 'Tri Arc', zh: 'Tri Arc', from: 'elec_man', cost: 1, built: true },
|
| 18 |
+
G: { name: 'Block Toss', zh: 'Boulder throw', from: 'guts_man', cost: 2, built: true },
|
| 19 |
+
M: { name: 'Bridge Ray', zh: 'Bridge Ray', from: null, cost: 2, built: false }
|
| 20 |
+
};
|
| 21 |
+
MM.ROBOT_MASTERS = {
|
| 22 |
+
cut_man: { mode: 0, zh: 'Blade Tosser', en: 'BLADE TOSSER', weapon: 'C', iframes: 0x3F, shot: 4 },
|
| 23 |
+
ice_man: { mode: 1, zh: 'V Gunner', en: 'V GUNNER', weapon: 'I', iframes: 0x1E, shot: 10 },
|
| 24 |
+
bomb_man: { mode: 2, zh: 'Shard Lobber', en: 'SHARD LOBBER', weapon: 'B', iframes: 0x1E, shot: 4 },
|
| 25 |
+
fire_man: { mode: 3, zh: 'Wave Keeper', en: 'WAVE KEEPER', weapon: 'F', iframes: 0x1E, shot: 4 },
|
| 26 |
+
elec_man: { mode: 4, zh: 'Pouncer', en: 'POUNCER', weapon: 'E', iframes: 0x3F, shot: 10 },
|
| 27 |
+
guts_man: { mode: 5, zh: 'Quake Hurler', en: 'QUAKE HURLER', weapon: 'G', iframes: 0x1E, shot: 4 }
|
| 28 |
+
};
|
| 29 |
+
MM.CONTACT = 4;
|
| 30 |
+
// P C I B F E G M
|
| 31 |
+
var ROWS = {
|
| 32 |
+
cut_man: [3, 1, 0, 2, 3, 1, 14, 0],
|
| 33 |
+
ice_man: [1, 2, 0, 4, 1, 10, 0, 0],
|
| 34 |
+
bomb_man: [2, 2, 0, 1, 4, 2, 0, 0],
|
| 35 |
+
fire_man: [2, 2, 4, 1, 1, 1, 0, 0],
|
| 36 |
+
elec_man: [1, 10, 0, 2, 1, 1, 4, 0],
|
| 37 |
+
guts_man: [2, 1, 0, 10, 2, 1, 1, 0]
|
| 38 |
+
};
|
| 39 |
+
MM.DAMAGE = {};
|
| 40 |
+
Object.keys(ROWS).forEach(function (boss) {
|
| 41 |
+
var row = MM.DAMAGE[boss] = {};
|
| 42 |
+
MM.WEAPON_ORDER.forEach(function (w, i) { row[w] = ROWS[boss][i]; });
|
| 43 |
+
});
|
| 44 |
+
// the boss a weapon is strongest against (ties are impossible in the table)
|
| 45 |
+
MM.weakTo = function (boss) {
|
| 46 |
+
var row = MM.DAMAGE[boss], best = 'P';
|
| 47 |
+
MM.WEAPON_ORDER.forEach(function (w) { if (row[w] > row[best]) best = w; });
|
| 48 |
+
return best;
|
| 49 |
+
};
|
| 50 |
+
// reset option {weapons: ['E', 'I', ...]}: weapons won from earlier bosses (the Buster is always owned)
|
| 51 |
+
MM.loadout = function (options) {
|
| 52 |
+
var list = (options && options.weapons) || [], out = ['P'];
|
| 53 |
+
if (!Array.isArray(list)) throw new Error('options.weapons must be a list of weapon letters');
|
| 54 |
+
list.forEach(function (w) {
|
| 55 |
+
w = String(w).toUpperCase();
|
| 56 |
+
if (!MM.WEAPONS[w]) throw new Error('unknown weapon ' + JSON.stringify(w) + ' (use ' + MM.WEAPON_ORDER.join(' ') + ')');
|
| 57 |
+
if (!MM.WEAPONS[w].built) throw new Error('weapon ' + w + ' (' + MM.WEAPONS[w].name + ') is not implemented in this build');
|
| 58 |
+
if (out.indexOf(w) < 0) out.push(w);
|
| 59 |
+
});
|
| 60 |
+
return MM.WEAPON_ORDER.filter(function (w) { return out.indexOf(w) >= 0; });
|
| 61 |
+
};
|
| 62 |
+
})(typeof window !== 'undefined' ? window : globalThis);
|
environments/games/web/games/megaman_remake/draw/compose.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Frame compositor for Mega Man: every frame is drawn at the NES's native 256x240 into an offscreen canvas with
|
| 2 |
+
// integer-pixel rects only, then scaled 2x (nearest neighbour) into the middle of the 854x480 frame. The side
|
| 3 |
+
// panels carry the readable HUD (weapon menu, bars, boss, timer, tier, native Hz); the original's vertical
|
| 4 |
+
// energy bars are also drawn inside the room where the NES put them. The shared renderer's layer hooks are
|
| 5 |
+
// routed here (BODY_DRAW.megaman.fullHud runs last and owns the whole picture), so one pass draws the room in
|
| 6 |
+
// the original's order: background, boss shots, boss, player shots, player, effects, HUD bars.
|
| 7 |
+
// Pure presentation: reads the case, never writes it; effects are a function of (event tick, current tick).
|
| 8 |
+
(function (g) {
|
| 9 |
+
var B = g.BB, MM = B.MM, P = MM.PAL, S = MM.SCREEN;
|
| 10 |
+
var low = null, lx = null;
|
| 11 |
+
function lowCanvas(doc) {
|
| 12 |
+
if (!low) { low = doc.createElement('canvas'); low.width = 256; low.height = 240; lx = low.getContext('2d'); }
|
| 13 |
+
return lx;
|
| 14 |
+
}
|
| 15 |
+
function px(x, X, Y, w, h, col) { x.fillStyle = col; x.fillRect(Math.round(X), Math.round(Y), w, h); }
|
| 16 |
+
MM.px = px;
|
| 17 |
+
|
| 18 |
+
// ---------- effects from the event log (deterministic: age = c.t - e.t) ----------
|
| 19 |
+
function recent(c, names, maxAge, fn) {
|
| 20 |
+
for (var i = c.events.length - 1; i >= 0; i--) {
|
| 21 |
+
var e = c.events[i]; if (c.t - e.t > maxAge) break;
|
| 22 |
+
if (names.indexOf(e.name) >= 0) fn(e, c.t - e.t);
|
| 23 |
+
}
|
| 24 |
+
}
|
| 25 |
+
function effects(x, c) {
|
| 26 |
+
recent(c, ['mm_hit', 'mm_clank'], 8, function (e, a) { // hit spark (anim $19)
|
| 27 |
+
var col = e.name === 'mm_clank' ? P.light : P.white, r = 2 + a;
|
| 28 |
+
px(x, e.x - r, e.y - 1, r * 2, 2, col); px(x, e.x - 1, e.y - r, 2, r * 2, col);
|
| 29 |
+
});
|
| 30 |
+
recent(c, ['mm_hurt'], 10, function (e, a) { // the player's hit spark (knockback entry)
|
| 31 |
+
var r = 4 + a; px(x, e.x - r, e.y - 1, r * 2, 2, P.white); px(x, e.x - 1, e.y - r, 2, r * 2, P.white);
|
| 32 |
+
px(x, e.x - r + 2, e.y - r + 2, 3, 3, P.yellow); px(x, e.x + r - 5, e.y + r - 5, 3, 3, P.yellow);
|
| 33 |
+
});
|
| 34 |
+
recent(c, ['mm_land'], 6, function (e, a) { // landing dust
|
| 35 |
+
px(x, e.x - 6 - a, e.y - 2, 3, 2, P.light); px(x, e.x + 3 + a, e.y - 2, 3, 2, P.light);
|
| 36 |
+
});
|
| 37 |
+
recent(c, ['mm_boss_dead', 'mm_player_dead'], 120, function (e, a) { // 8-orb radial burst (two speeds)
|
| 38 |
+
for (var k = 0; k < 16; k++) {
|
| 39 |
+
var ang = k * Math.PI / 8, sp = k < 8 ? 1.5 : 0.75, r = 6 + a * sp, ox = e.x + Math.cos(ang) * r, oy = e.y + Math.sin(ang) * r;
|
| 40 |
+
if (oy < 0 || oy > 240) continue;
|
| 41 |
+
var ph = (a >> 2) & 1, col = e.name === 'mm_boss_dead' ? (ph ? P.white : P.yellow) : (ph ? P.white : P.sky);
|
| 42 |
+
px(x, ox - 3, oy - 3, 6, 6, col); px(x, ox - 1, oy - 1, 2, 2, ph ? P.yellow : P.white);
|
| 43 |
+
}
|
| 44 |
+
});
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
// ---------- NES-style vertical bars (28 units, 7 cells of 4) ----------
|
| 48 |
+
function bar(x, X, units, fill) {
|
| 49 |
+
px(x, X, 16, 8, 57, P.black);
|
| 50 |
+
for (var u = 0; u < MM.BAR; u++) {
|
| 51 |
+
var yy = 16 + 56 - (u + 1) * 2;
|
| 52 |
+
if (u < units) { px(x, X + 1, yy + 1, 6, 1, fill); px(x, X + 3, yy + 1, 2, 1, P.white); }
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
function compose(x, c, t) {
|
| 57 |
+
var doc = x.canvas.ownerDocument || g.document, L = lowCanvas(doc), bossDraw = B.BOSS_DRAW[c.id];
|
| 58 |
+
L.setTransform(1, 0, 0, 1, 0, 0);
|
| 59 |
+
MM.drawRoom(L, c, t);
|
| 60 |
+
if (bossDraw && bossDraw.projectiles) bossDraw.projectiles(L, c, t);
|
| 61 |
+
if (bossDraw && bossDraw.boss) bossDraw.boss(L, c, t);
|
| 62 |
+
MM.drawPlayerShots(L, c, t);
|
| 63 |
+
MM.drawPlayer(L, c, t);
|
| 64 |
+
effects(L, c);
|
| 65 |
+
var b = c.body, o = c.boss, R = MM.RobotMaster;
|
| 66 |
+
bar(L, 24, Math.ceil(MM.BAR * b.hp / b.max_hp), P.gold); // life bar
|
| 67 |
+
if (b.weapon !== 'P') bar(L, 16, b.energy[b.weapon] || 0, MM.weaponColor(b.weapon));
|
| 68 |
+
// boss bar: the whole tier bar mapped onto 28 cells; it fills during the intro like boss_hp_fill_tick
|
| 69 |
+
var fillK = o.fight || o.hp <= 0 ? 1 : Math.max(0, Math.min(1, 1 - o.intro / R.FILL));
|
| 70 |
+
if (o.fight || o.intro < R.FILL || o.hp <= 0) bar(L, 40, Math.ceil(MM.BAR * fillK * o.hp / o.max_hp), P.orange);
|
| 71 |
+
x.save(); x.setTransform(1, 0, 0, 1, 0, 0); x.imageSmoothingEnabled = false;
|
| 72 |
+
// the quake moves the picture: PPUSCROLL + $D583/$D588[(timer / 2) & 3] on odd timer values, nothing on even ones (o.shake has
|
| 73 |
+
// already counted this frame down); a positive scroll moves the picture the other way, and the side panels cover the edges
|
| 74 |
+
var sh = o.shake > 0 ? o.shake + 1 : 0, ph = sh & 1 ? (sh >> 1) & 3 : 4;
|
| 75 |
+
if (ph !== 4) { x.fillStyle = '#000000'; x.fillRect(S.OX, S.OY, 256 * S.SCALE, 240 * S.SCALE); }
|
| 76 |
+
x.drawImage(low, S.OX - [0, 8, 0, -8, 0][ph] * S.SCALE, S.OY - [-24, 0, 8, 0, 0][ph] * S.SCALE, 256 * S.SCALE, 240 * S.SCALE);
|
| 77 |
+
x.restore();
|
| 78 |
+
}
|
| 79 |
+
MM.compose = compose;
|
| 80 |
+
MM.weaponColor = function (w) {
|
| 81 |
+
return { P: P.sky, E: P.yellow, I: P.ice, F: P.ember, C: P.light, B: P.green, G: P.orange, M: P.red }[w] || P.white;
|
| 82 |
+
};
|
| 83 |
+
})(typeof window !== 'undefined' ? window : globalThis);
|
environments/games/web/games/megaman_remake/draw/hud.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// HUD side panels around the 512x480 room: left = player (life, weapon menu with energy, counter chain hint),
|
| 2 |
+
// right = boss (name, health in points and NES units, state, timer, tier, native Hz). The whole picture is drawn
|
| 3 |
+
// by BODY_DRAW.megaman.fullHud, which the shared renderer calls last (renderer.js hud()).
|
| 4 |
+
(function (g) {
|
| 5 |
+
var B = g.BB, MM = B.MM, P = MM.PAL, S = MM.SCREEN;
|
| 6 |
+
var W = 854, H = 480, L = S.OX, R = S.OX + 512;
|
| 7 |
+
var FONT = '"Press Start 2P", "Lucida Console", Consolas, monospace';
|
| 8 |
+
function txt(x, s, X, Y, col, size, align) {
|
| 9 |
+
x.font = (size || 11) + 'px ' + FONT; x.textAlign = align || 'left'; x.textBaseline = 'alphabetic';
|
| 10 |
+
x.fillStyle = '#000000'; x.fillText(s, X + 1, Y + 1); x.fillStyle = col || '#fcfcfc'; x.fillText(s, X, Y);
|
| 11 |
+
}
|
| 12 |
+
function hbar(x, X, Y, w, frac, col) {
|
| 13 |
+
x.fillStyle = '#000000'; x.fillRect(X, Y, w, 10);
|
| 14 |
+
x.fillStyle = '#202020'; x.fillRect(X + 1, Y + 1, w - 2, 8);
|
| 15 |
+
var n = 28, cw = (w - 2) / n, k = Math.round(frac * n);
|
| 16 |
+
for (var i = 0; i < k; i++) { x.fillStyle = col; x.fillRect(X + 1 + i * cw, Y + 1, cw - 1, 8); x.fillStyle = 'rgba(255,255,255,.55)'; x.fillRect(X + 1 + i * cw, Y + 2, cw - 1, 2); }
|
| 17 |
+
}
|
| 18 |
+
function panel(x, X) {
|
| 19 |
+
x.fillStyle = '#0c0c18'; x.fillRect(X, 0, 171, H);
|
| 20 |
+
x.fillStyle = '#1c1c34'; for (var y = 0; y < H; y += 4) x.fillRect(X, y, 171, 1);
|
| 21 |
+
x.fillStyle = '#3c3c64'; x.fillRect(X === 0 ? 169 : X, 0, 2, H);
|
| 22 |
+
}
|
| 23 |
+
function hud(x, c, V, extra) {
|
| 24 |
+
var b = c.body, o = c.boss, G = B.GAME;
|
| 25 |
+
MM.VIEW_LAST = c; // read-only handle for page tests (never written back)
|
| 26 |
+
MM.compose(x, c, c.t / B.FPS);
|
| 27 |
+
x.save(); x.setTransform(1, 0, 0, 1, 0, 0);
|
| 28 |
+
panel(x, 0); panel(x, R);
|
| 29 |
+
// ---- left: player ----
|
| 30 |
+
txt(x, 'BLUE GUNNER', 12, 26, '#3cbcfc', 12);
|
| 31 |
+
txt(x, 'LIFE ' + b.hp + '/' + b.max_hp, 12, 46, '#fcfcfc', 9);
|
| 32 |
+
hbar(x, 12, 52, 146, b.hp / b.max_hp, '#fce0a8');
|
| 33 |
+
txt(x, 'WEAPON (Q/E)', 12, 84, '#bcbcbc', 9);
|
| 34 |
+
MM.WEAPON_ORDER.forEach(function (w, i) {
|
| 35 |
+
if (b.weapons.indexOf(w) < 0) return;
|
| 36 |
+
var row = b.weapons.indexOf(w), Y = 100 + row * 34, on = w === b.weapon, info = MM.WEAPONS[w];
|
| 37 |
+
if (on) { x.fillStyle = '#28285c'; x.fillRect(6, Y - 12, 158, 32); x.fillStyle = MM.weaponColor(w); x.fillRect(6, Y - 12, 3, 32); }
|
| 38 |
+
txt(x, w + ' ' + info.name.toUpperCase(), 14, Y, on ? MM.weaponColor(w) : '#7c7c7c', 8);
|
| 39 |
+
if (w === 'P') txt(x, 'UNLIMITED', 14, Y + 14, '#7c7c7c', 7);
|
| 40 |
+
else hbar(x, 14, Y + 5, 140, (b.energy[w] || 0) / MM.BAR, MM.weaponColor(w));
|
| 41 |
+
});
|
| 42 |
+
var dmg = MM.DAMAGE[o.id][b.weapon], best = MM.weakTo(o.id), bestHave = b.weapons.indexOf(best) >= 0;
|
| 43 |
+
txt(x, 'VS ' + MM.ROBOT_MASTERS[o.id].en + ': ' + dmg + ' / HIT', 12, 380, dmg >= 4 ? '#f8b800' : dmg === 0 ? '#f87858' : '#bcbcbc', 8);
|
| 44 |
+
txt(x, 'WEAK: ' + MM.WEAPONS[best].name.toUpperCase() + (bestHave ? '' : ' (X)'), 12, 396, '#7c7c7c', 7);
|
| 45 |
+
txt(x, 'A/D MOVE SPACE JUMP', 12, 444, '#5c5c7c', 7);
|
| 46 |
+
txt(x, 'J / LMB FIRE P PAUSE', 12, 458, '#5c5c7c', 7);
|
| 47 |
+
// ---- right: boss ----
|
| 48 |
+
var info2 = MM.ROBOT_MASTERS[o.id], name = info2.en;
|
| 49 |
+
txt(x, name, R + 12, 26, '#f87858', 12);
|
| 50 |
+
txt(x, (info2.zh || '') , R + 12, 44, '#bcbcbc', 10);
|
| 51 |
+
txt(x, o.hp + '/' + o.max_hp, R + 12, 64, '#fcfcfc', 9);
|
| 52 |
+
hbar(x, R + 12, 70, 146, o.max_hp ? o.hp / o.max_hp : 0, '#f87858');
|
| 53 |
+
txt(x, 'NES ' + Math.ceil(o.hp / MM.UNIT) + '/' + Math.round(o.max_hp / MM.UNIT) + ' UNITS', R + 12, 96, '#7c7c7c', 7);
|
| 54 |
+
txt(x, 'STATE ' + String(o.st).toUpperCase(), R + 12, 116, '#bcbcbc', 8);
|
| 55 |
+
// pattern position, the Robot Masters' equivalent of a phase (all read from the boss state)
|
| 56 |
+
var phase = o.id === 'elec_man' ? 'WALL POS ' + ((o.step & 3) + 1) + '/4'
|
| 57 |
+
: o.id === 'ice_man' ? 'SPEED LV ' + (Math.floor(o.counter / 3) + 1) + '/4'
|
| 58 |
+
: o.id === 'cut_man' ? 'BLADE ' + (o.cut === 0 ? 'HOME' : o.cut === 1 ? 'OUT' : 'BACK') + ' / ' + o.throws + ' THROWN'
|
| 59 |
+
: o.id === 'bomb_man' ? 'BOMBS ' + o.out + ' OUT / ' + o.bursts + ' BURST'
|
| 60 |
+
: o.id === 'guts_man' ? (b.stunT > 0 ? 'STUNNED ' + b.stunT : 'QUAKES ' + o.quakes + ' / ROCKS ' + o.rocks)
|
| 61 |
+
: 'VOLLEY ' + (o.n >= 2 ? Math.min(5, Math.floor((o.n - 2) / 2) + 1) : 0) + '/5';
|
| 62 |
+
txt(x, phase, R + 12, 132, '#bcbcbc', 8);
|
| 63 |
+
var secs = c.t / B.FPS, mm = Math.floor(secs / 60), ss = Math.floor(secs % 60), cs = Math.floor((secs * 10) % 10);
|
| 64 |
+
txt(x, 'TIME ' + mm + ':' + (ss < 10 ? '0' : '') + ss + '.' + cs, R + 12, 150, '#fcfcfc', 10);
|
| 65 |
+
var tier = null; if (G.tiers) Object.keys(G.tiers).forEach(function (k) { if (Math.abs(G.tiers[k] - c.d) < 1e-9) tier = k; });
|
| 66 |
+
txt(x, (tier ? tier.toUpperCase() : 'D=' + c.d.toFixed(2)), R + 12, 172, '#f8b800', 10);
|
| 67 |
+
txt(x, (G.hz || B.FPS) + 'Hz', R + 158, 466, '#3cbcfc', 12, 'right');
|
| 68 |
+
txt(x, 'NES 1987 RULES', R + 12, 444, '#5c5c7c', 7);
|
| 69 |
+
if (extra) txt(x, extra, R + 12, 200, '#f8b800', 8);
|
| 70 |
+
// ---- banners over the room ----
|
| 71 |
+
if (o.intro > 0 && !c.result) txt(x, 'READY', W / 2, 220, (c.t >> 3) & 1 ? '#fcfcfc' : '#3cbcfc', 18, 'center');
|
| 72 |
+
if (c.result === 'win') { txt(x, 'BOSS DEFEATED', W / 2, 200, '#f8b800', 18, 'center'); txt(x, 'YOU GOT ' + MM.WEAPONS[info2.weapon].name.toUpperCase(), W / 2, 232, '#fcfcfc', 11, 'center'); }
|
| 73 |
+
else if (c.result === 'loss') txt(x, 'GAME OVER', W / 2, 220, '#f87858', 18, 'center');
|
| 74 |
+
else if (c.result === 'timeout') txt(x, 'TIME UP', W / 2, 220, '#f87858', 18, 'center');
|
| 75 |
+
x.restore();
|
| 76 |
+
}
|
| 77 |
+
B.BODY_DRAW.megaman = { draw: function () {}, fullHud: hud };
|
| 78 |
+
})(typeof window !== 'undefined' ? window : globalThis);
|
environments/games/web/games/megaman_remake/draw/palette.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Original procedural NES-style art for the three Robot Master rooms (no ROM graphics are used or shipped).
|
| 2 |
+
// The renderer maps NES pixels to the 854x480 frame with an integer 2x scale: the 256x240 room is drawn at
|
| 3 |
+
// 512x480, centred with 171 px side panels that carry the HUD (weapon menu, bars, timer, native Hz).
|
| 4 |
+
// Pure presentation: reads the case, never writes it; animation uses presentation time t only.
|
| 5 |
+
(function (g) {
|
| 6 |
+
var B = g.BB, A = B.ART, MM = B.MM, V = B.VIEW;
|
| 7 |
+
var SCALE = 2, OX = 171, OY = 0;
|
| 8 |
+
// the shared renderer computed its own layout from BB.ARENA; replace it with the NES room mapping
|
| 9 |
+
V.S = SCALE; V.OX = OX; V.FLOOR = OY + MM.FLOOR * SCALE;
|
| 10 |
+
V.sx = function (x) { return OX + x * SCALE; };
|
| 11 |
+
V.sy = function (y) { return OY + y * SCALE; };
|
| 12 |
+
V.PAL = { boss: '#3c7cf0', tele: '#f8d878' };
|
| 13 |
+
// NES-like master palette subset (hand-picked RGB, not copied from any emulator palette file)
|
| 14 |
+
var NES = MM.PAL = {
|
| 15 |
+
black: '#000000', white: '#fcfcfc', grey: '#7c7c7c', light: '#bcbcbc',
|
| 16 |
+
blue: '#0078f8', sky: '#3cbcfc', navy: '#0000bc', cyan: '#00e8d8', skin: '#fcd8a8',
|
| 17 |
+
red: '#d82800', orange: '#f87858', yellow: '#f8b800', gold: '#fce0a8', green: '#00b800', teal: '#008888',
|
| 18 |
+
purple: '#6844fc', ice: '#a4e4fc', frost: '#e4f8fc', fire: '#f83800', ember: '#fca044', brick: '#a81000'
|
| 19 |
+
};
|
| 20 |
+
MM.SCREEN = { SCALE: SCALE, OX: OX, OY: OY };
|
| 21 |
+
A.view = { W: 854, H: 480, OX: OX, FLOOR: V.FLOOR, ROOF: OY, S: SCALE };
|
| 22 |
+
})(typeof window !== 'undefined' ? window : globalThis);
|
environments/games/web/games/megaman_remake/draw/player.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Original NES-style pixel sprites for Mega Man and the shots, drawn at native resolution (1 unit = 1 NES pixel).
|
| 2 |
+
// Shapes are hand-authored here as small character grids; they are not traced from any Capcom sprite sheet.
|
| 3 |
+
(function (g) {
|
| 4 |
+
var B = g.BB, MM = B.MM, P = MM.PAL, px = MM.px;
|
| 5 |
+
// grid painter: each string row is one pixel row; '.' = transparent, other chars index the colour map.
|
| 6 |
+
// With `dup` (row indexes to draw twice) the trailing blank rows are dropped and the picture is bottom-aligned
|
| 7 |
+
// to a 24-pixel box starting at Y, so a stretched figure stands exactly on the floor line of its hitbox.
|
| 8 |
+
function sprite(x, rows, map, X, Y, flip, dup) {
|
| 9 |
+
if (dup) {
|
| 10 |
+
var keep = rows.slice(), out = [];
|
| 11 |
+
while (keep.length && !/[^.]/.test(keep[keep.length - 1])) keep.pop();
|
| 12 |
+
keep.forEach(function (row, i) { out.push(row); if (dup.indexOf(i) >= 0) out.push(row); });
|
| 13 |
+
Y += 24 - out.length; rows = out;
|
| 14 |
+
}
|
| 15 |
+
var w = rows[0].length;
|
| 16 |
+
for (var r = 0; r < rows.length; r++) {
|
| 17 |
+
var row = rows[r];
|
| 18 |
+
for (var c = 0; c < w; c++) {
|
| 19 |
+
var ch = row.charAt(flip ? w - 1 - c : c);
|
| 20 |
+
if (ch === '.') continue;
|
| 21 |
+
x.fillStyle = map[ch]; x.fillRect(X + c, Y + r, 1, 1);
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
}
|
| 25 |
+
MM.sprite = sprite;
|
| 26 |
+
// 24 x 24 player frames (body box 16 x 24 centred); k = outline, b = dark armour, l = light armour, s = skin,
|
| 27 |
+
// w = eye white, e = pupil
|
| 28 |
+
var STAND = [
|
| 29 |
+
'........kkkkk...........', '......kkbbbbbkk.........', '.....kbbbllllbbk........', '....kbbblllllllbk.......',
|
| 30 |
+
'....kbbllllwwwlbk.......', '....kbblswwwewwsk.......', '....kbblswwweswsk.......', '.....kbbssssssssk.......',
|
| 31 |
+
'......kbbsskkssk........', '.....kkbbbsssskkk.......', '....klllbbbkkbbllk......', '...kllllbbbbbbbllk......',
|
| 32 |
+
'...kllkllbbbbbbkllk.....', '...kssk.kbbbbbbkssk.....', '....kk..klllllbk.kk.....', '........kllklllk........',
|
| 33 |
+
'.......kbbbk.kbbbk......', '......kbbbbk.kbbbbk.....', '.....kbbbbbk.kbbbbbk....', '.....kkkkkkk.kkkkkkk....',
|
| 34 |
+
'........................', '........................', '........................', '........................'];
|
| 35 |
+
var SHOOT = [
|
| 36 |
+
'........kkkkk...........', '......kkbbbbbkk.........', '.....kbbbllllbbk........', '....kbbblllllllbk.......',
|
| 37 |
+
'....kbbllllwwwlbk.......', '....kbblswwwewwsk.......', '....kbblswwweswsk.......', '.....kbbssssssssk.......',
|
| 38 |
+
'......kbbsskkssk........', '.....kkbbbsssskkkkkkk...', '....klllbbbkkbbllbbbbk..', '...kllllbbbbbbbllbbbbbk.',
|
| 39 |
+
'...kllkllbbbbbbkllbbbbk.', '...kssk.kbbbbbbk.kkkkk..', '....kk..klllllbk........', '........kllklllk........',
|
| 40 |
+
'.......kbbbk.kbbbk......', '......kbbbbk.kbbbbk.....', '.....kbbbbbk.kbbbbbk....', '.....kkkkkkk.kkkkkkk....',
|
| 41 |
+
'........................', '........................', '........................', '........................'];
|
| 42 |
+
var RUN = [
|
| 43 |
+
'........kkkkk...........', '......kkbbbbbkk.........', '.....kbbbllllbbk........', '....kbbblllllllbk.......',
|
| 44 |
+
'....kbbllllwwwlbk.......', '....kbblswwwewwsk.......', '....kbblswwweswsk.......', '.....kbbssssssssk.......',
|
| 45 |
+
'......kbbsskkssk........', '....kkkbbbsssskk........', '...kllllbbbkkbbllk......', '..kllllkbbbbbbbllk......',
|
| 46 |
+
'..kssk.klbbbbbbkllk.....', '...kk..kbbbbbbkssk......', '......klllllbbkkk.......', '.....kllkkklllbk........',
|
| 47 |
+
'....kbbbk..kkbbbk.......', '...kbbbbk...kbbbbk......', '..kbbbbk.....kbbbbk.....', '..kkkkk.......kkkkk.....',
|
| 48 |
+
'........................', '........................', '........................', '........................'];
|
| 49 |
+
var JUMP = [
|
| 50 |
+
'........kkkkk...........', '......kkbbbbbkk.....kk..', '.....kbbbllllbbk...kssk.', '....kbbblllllllbk..kllk.',
|
| 51 |
+
'....kbbllllwwwlbk.kllk..', '....kbblswwwewwsk.kllk..', '....kbblswwweswsk.kbk...', '.....kbbssssssssk.kbk...',
|
| 52 |
+
'......kbbsskkssk.kbbk...', '.....kkbbbsssskkkbbk....', '....klllbbbkkbbllbk.....', '...kllllbbbbbbbllk......',
|
| 53 |
+
'..kllk.kbbbbbbbbk.......', '..kssk.klllllllbk.......', '...kk..kllllllbbk.......', '......kbbbkk.kbbk.......',
|
| 54 |
+
'.....kbbbbk...kbbk......', '.....kbbbk.....kbbk.....', '.....kkkk.......kkk.....', '........................',
|
| 55 |
+
'........................', '........................', '........................', '........................'];
|
| 56 |
+
var HURT = [
|
| 57 |
+
'...k...kkkkk...k........', '....k.kbbbbbkk.k........', '.....kbbbllllbbk........', '....kbbblllllllbk.......',
|
| 58 |
+
'....kbblkkllkkkbk.......', '....kbblskwkskwsk.......', '....kbblswkkswksk.......', '.....kbbssssssssk.......',
|
| 59 |
+
'..kk..kbsskkkssk..kk....', '.kssk.kbbbsssskk.kssk...', '.kllkkllbbbkkbbllkllk...', '..kllllbbbbbbbbllllk....',
|
| 60 |
+
'...kkkllbbbbbbbllkk.....', '......kbbbbbbbbk........', '.....kllllkkllllk.......', '....kbbbbk..kbbbbk......',
|
| 61 |
+
'...kbbbbk....kbbbbk.....', '...kkkkk......kkkkk.....', '........................', '........................',
|
| 62 |
+
'........................', '........................', '........................', '........................'];
|
| 63 |
+
function colours(w) {
|
| 64 |
+
var dark = { P: P.blue, E: '#a87800', I: '#0058f8', F: P.red }[w] || P.blue;
|
| 65 |
+
var light = { P: P.sky, E: P.yellow, I: P.frost, F: P.ember }[w] || P.sky;
|
| 66 |
+
return { k: P.black, b: dark, l: light, s: P.skin, w: P.white, e: P.black };
|
| 67 |
+
}
|
| 68 |
+
MM.drawPlayer = function (x, c, t) {
|
| 69 |
+
var b = c.body;
|
| 70 |
+
if (b.hp <= 0) return;
|
| 71 |
+
if (b.iframes > 0 && (b.iframes & 2)) return; // blink: hidden while bit 1 of the i-frame timer is set
|
| 72 |
+
var frame = b.knockT > 0 || b.stunT > 0 ? HURT : !b.grounded ? JUMP : b.shootT > 0 ? SHOOT : b.speed > 0.5 ? RUN : STAND;
|
| 73 |
+
if (frame === RUN && (Math.floor(c.t / 8) & 1)) frame = STAND; // two-step run cycle
|
| 74 |
+
var map = colours(b.weapon);
|
| 75 |
+
// 20-row figure stretched to 22 rows (= the 14x22 touch box) and standing on the 16x24 body's floor line
|
| 76 |
+
sprite(x, frame, map, Math.round(b.x) - 12, Math.round(b.y) - 12, b.facing < 0, [10, 16]);
|
| 77 |
+
};
|
| 78 |
+
|
| 79 |
+
// ---------- player shots ----------
|
| 80 |
+
MM.drawPlayerShots = function (x, c, t) {
|
| 81 |
+
var b = c.body;
|
| 82 |
+
b.shots.forEach(function (s) {
|
| 83 |
+
var X = Math.round(s.x), Y = Math.round(s.y);
|
| 84 |
+
if (s.kind === 'buster') { px(x, X - 3, Y - 2, 6, 4, P.yellow); px(x, X - 2, Y - 3, 4, 6, P.yellow); px(x, X - 1, Y - 1, 2, 2, P.white); }
|
| 85 |
+
else if (s.kind === 'slasher') MM.drawSlasher(x, s, 8);
|
| 86 |
+
else if (s.kind === 'fire_wave' || s.kind === 'fire_shield') MM.drawFlame(x, X, Y + 8, 16, 16, c.t >> 2, false);
|
| 87 |
+
else if (s.kind === 'thunder' || s.kind === 'thunder_v') MM.drawBolt(x, s, c.t, true);
|
| 88 |
+
else if (s.kind === 'cutter') MM.drawCutter(x, X, Y, c.t, s.hw);
|
| 89 |
+
else if (s.kind === 'hyper_bomb') MM.drawBomb(x, X, Y, c.t, s.fuse > 110);
|
| 90 |
+
else if (s.kind === 'hyper_flame') MM.drawFlame(x, X, Y + 8, 16, 16, c.t >> 1, false);
|
| 91 |
+
else if (s.kind === 'held_block' || s.kind === 'thrown_block') MM.drawBlock(x, X, Y, s.hw);
|
| 92 |
+
else if (s.kind === 'block_chunk') MM.drawChunk(x, X, Y, '#7c7c7c', '#bcbcbc');
|
| 93 |
+
});
|
| 94 |
+
};
|
| 95 |
+
// zigzag electric segment covering the hitbox (hw x hh), flickering between two shapes
|
| 96 |
+
MM.drawBolt = function (x, s, tick, player) {
|
| 97 |
+
var X = Math.round(s.x), Y = Math.round(s.y), hw = s.hw, hh = s.hh, ph = (tick >> 1) & 1;
|
| 98 |
+
var core = ph ? P.white : P.yellow, edge = player ? P.yellow : P.gold, pts = [], k;
|
| 99 |
+
// a jagged polyline that spans the hitbox along its long axis, so the picture covers exactly what hurts
|
| 100 |
+
if (hh >= hw) for (k = -hh; k <= hh; k += 4) pts.push([X + (((k + hh) >> 2) & 1 ? hw - 1 : 1 - hw) * (ph ? 1 : -1), Y + k]);
|
| 101 |
+
else for (k = -hw; k <= hw; k += 4) pts.push([X + k, Y + (((k + hw) >> 2) & 1 ? hh - 1 : 1 - hh) * (ph ? 1 : -1)]);
|
| 102 |
+
for (k = 1; k < pts.length; k++) MM.seg(x, pts[k - 1][0], pts[k - 1][1], pts[k][0], pts[k][1], edge, 3);
|
| 103 |
+
for (k = 1; k < pts.length; k++) MM.seg(x, pts[k - 1][0], pts[k - 1][1], pts[k][0], pts[k][1], core, 1);
|
| 104 |
+
};
|
| 105 |
+
// pixel line: squares of size w stepped along the segment
|
| 106 |
+
MM.seg = function (x, x0, y0, x1, y1, col, w) {
|
| 107 |
+
var n = Math.max(Math.abs(x1 - x0), Math.abs(y1 - y0)) || 1, h = w >> 1;
|
| 108 |
+
x.fillStyle = col;
|
| 109 |
+
for (var i = 0; i <= n; i++) x.fillRect(Math.round(x0 + (x1 - x0) * i / n) - h, Math.round(y0 + (y1 - y0) * i / n) - h, w, w);
|
| 110 |
+
};
|
| 111 |
+
// Ice Slasher: a chevron of three ice blades pointing along its flight, filling the hitbox (half = half-size)
|
| 112 |
+
MM.drawSlasher = function (x, s, half) {
|
| 113 |
+
var X = Math.round(s.x), Y = Math.round(s.y), f = s.dir || 1, h = half;
|
| 114 |
+
for (var r = -h; r < h; r++) {
|
| 115 |
+
var d = Math.abs(r + 0.5), len = Math.max(2, Math.round(2 * h - d * 1.6)), tip = f > 0 ? X + h - Math.round(d * 0.8) : X - h + Math.round(d * 0.8);
|
| 116 |
+
px(x, f > 0 ? tip - len : tip, Y + r, len, 1, d < 1 ? P.white : (r & 1) ? P.ice : '#3cbcfc');
|
| 117 |
+
}
|
| 118 |
+
px(x, f > 0 ? X + h - 2 : X - h, Y - 1, 2, 2, P.white);
|
| 119 |
+
};
|
| 120 |
+
// a flame of exactly w x h pixels standing on (X, bottom); `ph` animates the tongues
|
| 121 |
+
MM.drawFlame = function (x, X, bottom, w, h, ph, dim) {
|
| 122 |
+
var outer = dim ? '#a81000' : P.fire, mid = dim ? P.fire : P.ember, core = dim ? P.ember : P.yellow;
|
| 123 |
+
for (var c2 = 0; c2 < w; c2++) {
|
| 124 |
+
var k = Math.abs(c2 - (w - 1) / 2) / (w / 2), tongue = Math.round(h * (1 - 0.35 * k * k) - (((c2 + ph) & 3) === 0 ? 3 : 0));
|
| 125 |
+
px(x, X - (w >> 1) + c2, bottom - tongue, 1, tongue, outer);
|
| 126 |
+
if (k < 0.75) px(x, X - (w >> 1) + c2, bottom - Math.round(tongue * 0.75), 1, Math.round(tongue * 0.75), mid);
|
| 127 |
+
if (k < 0.35) px(x, X - (w >> 1) + c2, bottom - Math.round(tongue * 0.45), 1, Math.round(tongue * 0.45), core);
|
| 128 |
+
}
|
| 129 |
+
};
|
| 130 |
+
})(typeof window !== 'undefined' ? window : globalThis);
|
environments/games/web/games/megaman_remake/draw/rooms.js
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Original procedural backgrounds for the Robot Master rooms at NES resolution, and the boss sprites.
|
| 2 |
+
// Rooms: Elec Man's generator hall (circuit panels, conduit), Ice Man's frozen hangar (snow blocks, icicles),
|
| 3 |
+
// Fire Man's furnace (brick, lava glow), Bomb Man's demolition yard (girders, hazard stripes, the open roof at
|
| 4 |
+
// x 96-159 of the original room). Static layers are cached per case; flicker/scroll uses time only.
|
| 5 |
+
(function (g) {
|
| 6 |
+
var B = g.BB, MM = B.MM, P = MM.PAL, px = MM.px, sprite = MM.sprite;
|
| 7 |
+
var cache = {};
|
| 8 |
+
function H(i) { var s = Math.sin(i * 91.7 + 17.3) * 43758.5453; return s - Math.floor(s); }
|
| 9 |
+
|
| 10 |
+
function roomElec(x) {
|
| 11 |
+
px(x, 0, 0, 256, 240, '#000000');
|
| 12 |
+
for (var cx = 0; cx < 256; cx += 32) for (var cy = 16; cy < 192; cy += 32) { // circuit panels
|
| 13 |
+
px(x, cx + 1, cy + 1, 30, 30, '#00285c'); px(x, cx + 3, cy + 3, 26, 26, '#00184a');
|
| 14 |
+
for (var k = 0; k < 4; k++) { var lx = cx + 5 + Math.floor(H(cx * 7 + cy + k) * 20), ly = cy + 5 + k * 6; px(x, lx, ly, 6, 1, '#0058a8'); px(x, lx + 5, ly, 1, 4, '#0058a8'); }
|
| 15 |
+
px(x, cx + 14, cy + 14, 4, 4, '#a87800');
|
| 16 |
+
}
|
| 17 |
+
px(x, 0, 0, 256, 16, '#202020'); for (var i = 0; i < 256; i += 8) px(x, i, 12, 6, 2, '#a87800');
|
| 18 |
+
floor(x, '#585858', '#a8a8a8', '#202020');
|
| 19 |
+
walls(x, '#404040', '#787878');
|
| 20 |
+
}
|
| 21 |
+
function roomIce(x) {
|
| 22 |
+
px(x, 0, 0, 256, 240, '#000028');
|
| 23 |
+
for (var s = 0; s < 70; s++) px(x, Math.floor(H(s) * 256), 16 + Math.floor(H(s + 99) * 170), 1, 1, s % 3 ? '#3cbcfc' : '#fcfcfc');
|
| 24 |
+
for (var cx = 0; cx < 256; cx += 16) { var h = 6 + Math.floor(H(cx) * 18); for (var y = 0; y < h; y += 2) px(x, cx + 4 + (y >> 2), 16 + y, Math.max(1, 8 - y / 2), 2, y < 4 ? '#fcfcfc' : '#a4e4fc'); }
|
| 25 |
+
px(x, 0, 0, 256, 16, '#a4e4fc'); for (var i = 0; i < 256; i += 16) px(x, i, 0, 15, 15, '#e4f8fc');
|
| 26 |
+
floor(x, '#a4e4fc', '#fcfcfc', '#3cbcfc');
|
| 27 |
+
walls(x, '#3cbcfc', '#e4f8fc');
|
| 28 |
+
}
|
| 29 |
+
function roomFire(x) {
|
| 30 |
+
px(x, 0, 0, 256, 240, '#280000');
|
| 31 |
+
for (var cy = 16; cy < 192; cy += 8) for (var cx = ((cy >> 3) & 1) * 8; cx < 256; cx += 16) px(x, cx + 1, cy + 1, 14, 6, (cx + cy) % 48 ? '#580000' : '#781800');
|
| 32 |
+
px(x, 0, 0, 256, 16, '#a81000'); for (var i = 0; i < 256; i += 16) px(x, i + 2, 4, 12, 8, '#d82800');
|
| 33 |
+
floor(x, '#a81000', '#f87858', '#500000');
|
| 34 |
+
walls(x, '#781800', '#d82800');
|
| 35 |
+
}
|
| 36 |
+
function roomBomb(x) {
|
| 37 |
+
px(x, 0, 0, 256, 240, '#001800');
|
| 38 |
+
for (var cx = 16; cx < 240; cx += 48) { // steel girders
|
| 39 |
+
px(x, cx, 32, 6, 160, '#005800'); px(x, cx + 1, 32, 1, 160, '#00a800');
|
| 40 |
+
for (var gy = 40; gy < 192; gy += 24) { px(x, cx + 6, gy, 18, 2, '#005800'); px(x, cx + 6 + ((gy >> 3) % 3) * 4, gy + 2, 2, 10, '#004000'); }
|
| 41 |
+
}
|
| 42 |
+
for (var s = 0; s < 30; s++) px(x, 96 + Math.floor(H(s) * 64), Math.floor(H(s + 7) * 30), 1, 1, '#fcfcfc'); // sky through the roof gap
|
| 43 |
+
[[0, 96], [160, 96]].forEach(function (r) {
|
| 44 |
+
px(x, r[0], 0, r[1], 32, '#7c7c7c');
|
| 45 |
+
for (var i = r[0]; i < r[0] + r[1]; i += 16) { px(x, i, 0, 16, 1, '#bcbcbc'); px(x, i + 15, 0, 1, 32, '#3c3c3c'); px(x, i, 16, 16, 1, '#3c3c3c'); }
|
| 46 |
+
for (var j = r[0]; j < r[0] + r[1]; j += 8) px(x, j, 28, 4, 4, '#f8b800'); // hazard stripe
|
| 47 |
+
});
|
| 48 |
+
floor(x, '#7c7c7c', '#bcbcbc', '#3c3c3c');
|
| 49 |
+
for (var k = 0; k < 256; k += 8) px(x, k, 194, 4, 2, '#f8b800');
|
| 50 |
+
walls(x, '#3c3c3c', '#7c7c7c');
|
| 51 |
+
}
|
| 52 |
+
function roomCut(x) {
|
| 53 |
+
px(x, 0, 0, 256, 240, '#2c1c00');
|
| 54 |
+
for (var cy = 32; cy < 192; cy += 32) for (var cx = 0; cx < 256; cx += 32) { // timber frames of the logging yard
|
| 55 |
+
px(x, cx + 1, cy + 1, 30, 30, '#4c3000'); px(x, cx + 2, cy + 15, 28, 2, '#2c1c00'); px(x, cx + 15, cy + 2, 2, 28, '#2c1c00');
|
| 56 |
+
}
|
| 57 |
+
px(x, 0, 0, 256, 32, '#7c5c00'); for (var i = 0; i < 256; i += 16) { px(x, i, 0, 15, 15, '#a87800'); px(x, i + 8, 16, 15, 15, '#a87800'); }
|
| 58 |
+
floor(x, '#7c5c00', '#d8a038', '#3c2800');
|
| 59 |
+
walls(x, '#4c3000', '#a87800');
|
| 60 |
+
px(x, 16, 160, 16, 32, '#3c3c3c'); px(x, 16, 160, 16, 2, '#7c7c7c'); // the solid tiles beside the wall
|
| 61 |
+
}
|
| 62 |
+
function roomGuts(x) {
|
| 63 |
+
px(x, 0, 0, 256, 240, '#1c1408');
|
| 64 |
+
for (var cy = 0; cy < 192; cy += 16) for (var cx = ((cy >> 4) & 1) * 12; cx < 256; cx += 24) { // quarry face: offset courses of rough stone
|
| 65 |
+
var v = H(cx * 3 + cy); px(x, cx + 1, cy + 1, 22, 14, v < 0.33 ? '#3c2c14' : v < 0.66 ? '#30220e' : '#463418');
|
| 66 |
+
px(x, cx + 3 + Math.floor(v * 12), cy + 4, 5, 1, '#5c4820');
|
| 67 |
+
}
|
| 68 |
+
for (var tx = 40; tx < 240; tx += 64) { px(x, tx, 0, 6, 192, '#5c3c10'); px(x, tx + 1, 0, 1, 192, '#8c6420'); } // timber props
|
| 69 |
+
floor(x, '#5c4820', '#a88c48', '#2c2008');
|
| 70 |
+
[0, 240].forEach(function (wx) {
|
| 71 |
+
px(x, wx, 0, 16, 192, '#463418');
|
| 72 |
+
for (var y = 0; y < 192; y += 16) { px(x, wx, y, 16, 1, '#8c6c30'); px(x, wx + 15, y, 1, 16, '#000000'); }
|
| 73 |
+
});
|
| 74 |
+
px(x, 16, 160, 16, 32, '#463418'); px(x, 16, 160, 16, 2, '#a88c48'); // the solid tiles beside the wall
|
| 75 |
+
}
|
| 76 |
+
// one liftable block (override type 2): 32 x 32 of cracked stone, also what the player carries and throws
|
| 77 |
+
MM.drawBlock = function (x, X, Y, h) {
|
| 78 |
+
px(x, X - h, Y - h, h * 2, h * 2, '#000000'); px(x, X - h + 1, Y - h + 1, h * 2 - 2, h * 2 - 2, '#7c7c7c');
|
| 79 |
+
px(x, X - h + 1, Y - h + 1, h * 2 - 2, 2, '#bcbcbc'); px(x, X - h + 1, Y - h + 1, 2, h * 2 - 2, '#bcbcbc');
|
| 80 |
+
px(x, X - h + 8, Y - 6, 8, 2, '#3c3c3c'); px(x, X + 2, Y + 2, 8, 2, '#3c3c3c');
|
| 81 |
+
};
|
| 82 |
+
// Guts Man's boulder (28 x 28 hitbox) and a chunk of it (8 x 8): every pixel of the box is drawn, so what you see is what hurts
|
| 83 |
+
MM.drawRock = function (x, X, Y, h, t) {
|
| 84 |
+
px(x, X - h, Y - h + 3, h * 2, h * 2 - 6, '#000000'); px(x, X - h + 3, Y - h, h * 2 - 6, h * 2, '#000000');
|
| 85 |
+
px(x, X - h + 1, Y - h + 4, h * 2 - 2, h * 2 - 8, '#a87800'); px(x, X - h + 4, Y - h + 1, h * 2 - 8, h * 2 - 2, '#a87800');
|
| 86 |
+
px(x, X - h + 4, Y - h + 3, h - 2, 3, '#f8d878'); px(x, X - 2, Y + 2, 8, 2, '#5c3c10'); px(x, X - 8, Y - 3, 5, 2, '#5c3c10');
|
| 87 |
+
};
|
| 88 |
+
MM.drawChunk = function (x, X, Y, a, b) { px(x, X - 4, Y - 4, 8, 8, '#000000'); px(x, X - 3, Y - 3, 6, 6, a); px(x, X - 3, Y - 3, 3, 2, b); };
|
| 89 |
+
function floor(x, base, top, dark) {
|
| 90 |
+
px(x, 0, 192, 256, 48, base);
|
| 91 |
+
for (var i = 0; i < 256; i += 16) { px(x, i, 192, 16, 2, top); px(x, i + 15, 192, 1, 16, dark); px(x, i, 207, 16, 1, dark); px(x, i + 7, 208, 1, 16, dark); px(x, i, 223, 16, 1, dark); }
|
| 92 |
+
}
|
| 93 |
+
function walls(x, base, top) {
|
| 94 |
+
[0, 240].forEach(function (wx) {
|
| 95 |
+
px(x, wx, 16, 16, 176, base);
|
| 96 |
+
for (var y = 16; y < 192; y += 16) { px(x, wx, y, 16, 1, top); px(x, wx + 15, y, 1, 16, '#000000'); }
|
| 97 |
+
});
|
| 98 |
+
}
|
| 99 |
+
var ROOMS = { 'megaman/elec_man': roomElec, 'megaman/ice_man': roomIce, 'megaman/fire_man': roomFire, 'megaman/bomb_man': roomBomb, 'megaman/cut_man': roomCut, 'megaman/guts_man': roomGuts };
|
| 100 |
+
MM.drawRoom = function (x, c, t) {
|
| 101 |
+
var key = c.id, img = cache[key];
|
| 102 |
+
if (!img) {
|
| 103 |
+
var doc = x.canvas.ownerDocument || g.document, cv = doc.createElement('canvas'); cv.width = 256; cv.height = 240;
|
| 104 |
+
ROOMS[key](cv.getContext('2d')); img = cache[key] = cv;
|
| 105 |
+
}
|
| 106 |
+
x.drawImage(img, 0, 0);
|
| 107 |
+
c.body.room.forEach(function (r) { if (r.block) MM.drawBlock(x, r.x0 + 16, r.y0 + 16, 16); }); // lifted blocks leave the list
|
| 108 |
+
if (key === 'megaman/fire_man') { // furnace glow rising from the floor seams
|
| 109 |
+
for (var i = 0; i < 16; i++) { var f = (Math.floor(t * 8) + i * 3) % 6; px(x, i * 16 + 6, 186 - f, 3, 2, f < 3 ? P.ember : P.fire); }
|
| 110 |
+
} else if (key === 'megaman/elec_man') {
|
| 111 |
+
var on = Math.floor(t * 6) % 8; px(x, on * 32 + 14, 30, 4, 4, P.yellow);
|
| 112 |
+
}
|
| 113 |
+
};
|
| 114 |
+
|
| 115 |
+
// ---------- bosses: 24 x 24 grids, k outline ----------
|
| 116 |
+
var ELEC = [
|
| 117 |
+
'...........kk...........', '..........kyyk..........', '.........kyyyyk.........', '........kkrrrrkk........',
|
| 118 |
+
'.......kddrrrrddk.......', '.......kdwwkwwkdk.......', '.......kdswswssdk.......', '.......kdssssssdk.......',
|
| 119 |
+
'........kdsskssk........', '......kkkdddddkkkk......', '.....kyyddkkkddyyyk.....', '....kyyyddddddddyyyk....',
|
| 120 |
+
'....kyykddddddddkyyk....', '....kssk.kddddddkssk....', '.....kk..kyyyyyyk.kk....', '.........kyykkyyk.......',
|
| 121 |
+
'........kdddk.kdddk.....', '.......kddddk.kddddk....', '......kyyyyyk.kyyyyyk...', '......kkkkkkk.kkkkkkk...',
|
| 122 |
+
'........................', '........................', '........................', '........................'];
|
| 123 |
+
var ICE = [
|
| 124 |
+
'........................', '.........kkkkkk.........', '.......kkbbbbbbkk.......', '......kbbffffffbbk......',
|
| 125 |
+
'.....kbbfkkkkkkfbbk.....', '.....kbfkswwswwkfbk.....', '.....kbfkswesweskfbk....', '.....kbfksssssskfbk.....',
|
| 126 |
+
'.....kbbfkkkkkkfbbk.....', '......kbbffffffbbk......', '.....kkbbbbbbbbbbkk.....', '....kffbbbbbbbbbbffk....',
|
| 127 |
+
'....kffkbbbbbbbbkffk....', '....kssk.kbbbbbbkssk....', '.....kk..kffffffk.kk....', '.........kffkkffk.......',
|
| 128 |
+
'........kbbbk.kbbbk.....', '.......kbbbbk.kbbbbk....', '.......kffffk.kffffk....', '.......kkkkkk.kkkkkk....',
|
| 129 |
+
'........................', '........................', '........................', '........................'];
|
| 130 |
+
var FIRE = [
|
| 131 |
+
'.........y..y...........', '........yoyyoy..........', '.......yooooooy.........', '.......kkookookk........',
|
| 132 |
+
'......kgggkkkgggk.......', '......kgwwkkwwkgk.......', '......kgwekkewkgk.......', '......kgkkkkkkkgk.......',
|
| 133 |
+
'.......kgggggggk........', '......kkrrrrrrrkkk......', '.....krrrrkkkrrrrrk.....', '....krrrgrrrrrgrrrrk....',
|
| 134 |
+
'....krrkrrrrrrrrkrrk....', '....kook.krrrrrrkook....', '.....kk..kgggggok.kk....', '.........kggkkggk.......',
|
| 135 |
+
'........krrrk.krrrk.....', '.......krrrrk.krrrrk....', '.......kggggk.kggggk....', '.......kkkkkk.kkkkkk....',
|
| 136 |
+
'........................', '........................', '........................', '........................'];
|
| 137 |
+
var BOMB = [
|
| 138 |
+
'..........kkk...........', '.........kwwwk..........', '.........kkkkk..........', '.......kkggggkk.........',
|
| 139 |
+
'......kgggggggggk.......', '......kgwwkkwwkgk.......', '......kgwekkewkgk.......', '......kgkssssskgk.......',
|
| 140 |
+
'.......kgggggggk........', '......kkllllllllkk......', '.....kllllkkkllllk......', '....kllgllllllllgllk....',
|
| 141 |
+
'....kllkllllllllkllk....', '....kssk.kllllllkssk....', '.....kk..kggggggk.kk....', '.........kggkkggk.......',
|
| 142 |
+
'........klllk.klllk.....', '.......kllllk.kllllk....', '.......kggggk.kggggk....', '.......kkkkkk.kkkkkk....',
|
| 143 |
+
'........................', '........................', '........................', '........................'];
|
| 144 |
+
var CUT = [
|
| 145 |
+
'..........k....k........', '.........krk..krk.......', '..........krkkrk........', '...........krrk.........',
|
| 146 |
+
'.......kkkkkkkkkk.......', '......krrrrrrrrrrk......', '......krwwkrrwwkrk......', '......krwekssewkrk......',
|
| 147 |
+
'.......kssssssssk.......', '......kkrrrrrrrrkkk.....', '.....krrrrkkkrrrrrk.....', '....krrrwrrrrrwrrrrk....',
|
| 148 |
+
'....krrkrrrrrrrrkrrk....', '....kssk.krrrrrrkssk....', '.....kk..kwwwwwwk.kk....', '.........kwwkkwwk.......',
|
| 149 |
+
'........krrrk.krrrk.....', '.......krrrrk.krrrrk....', '.......kwwwwk.kwwwwk....', '.......kkkkkk.kkkkkk....',
|
| 150 |
+
'........................', '........................', '........................', '........................'];
|
| 151 |
+
var MAPS = {
|
| 152 |
+
elec_man: { k: '#000000', y: '#f8b800', r: '#d82800', d: '#a87800', w: '#fcfcfc', s: '#fcd8a8', e: '#000000' },
|
| 153 |
+
ice_man: { k: '#000000', b: '#0078f8', f: '#fcfcfc', w: '#fcfcfc', s: '#fcd8a8', e: '#000000' },
|
| 154 |
+
fire_man: { k: '#000000', y: '#f8b800', o: '#f87858', r: '#d82800', g: '#7c7c7c', w: '#fcfcfc', e: '#000000' },
|
| 155 |
+
bomb_man: { k: '#000000', g: '#00a800', l: '#b8f818', w: '#fcfcfc', s: '#fcd8a8', e: '#000000' },
|
| 156 |
+
cut_man: { k: '#000000', r: '#d82800', w: '#fcfcfc', s: '#fcd8a8', e: '#000000' }
|
| 157 |
+
};
|
| 158 |
+
var GRIDS = { elec_man: ELEC, ice_man: ICE, fire_man: FIRE, bomb_man: BOMB, cut_man: CUT };
|
| 159 |
+
var WHITE = {}; 'kyrdwsebfogl'.split('').forEach(function (ch) { WHITE[ch] = '#fcfcfc'; });
|
| 160 |
+
// bosses stand on the floor with a 16x24 body box: the 20-row grids are stretched to 24 rows by doubling the
|
| 161 |
+
// torso and leg rows, so the drawn body covers the hitbox exactly (feet on the floor, head at the box top)
|
| 162 |
+
var BOSS_DUP = [10, 11, 16, 17];
|
| 163 |
+
// Guts Man fills his 32 x 32 hitbox (anims $25-$30 are 16 x 16 half size), so he is drawn from rectangles, not the 24-grid
|
| 164 |
+
function gutsBody(x, o, white) {
|
| 165 |
+
var X = Math.round(o.x), Y = Math.round(o.y), f = o.look, crouch = o.pose === 'crouch' || o.pose === 'land' ? 3 : 0, up = o.pose === 'lift' || o.pose === 'air';
|
| 166 |
+
function r(rx, ry, w, h, col) { px(x, f > 0 ? X + rx : X - rx - w, Y + ry, w, h, white ? '#fcfcfc' : col); }
|
| 167 |
+
r(-11, 8, 10, 8, '#000000'); r(1, 8, 10, 8, '#000000'); r(-10, 9, 8, 6, '#d82800'); r(2, 9, 8, 6, '#d82800'); // boots
|
| 168 |
+
r(-12, -4 + crouch, 24, 13 - crouch, '#000000'); r(-11, -3 + crouch, 22, 11 - crouch, '#a81000'); r(-5, 0 + crouch, 10, 4, '#f8b800'); // torso, belt plate
|
| 169 |
+
r(-16, up ? -16 : -4 + crouch, 5, up ? 14 : 12, '#000000'); r(-15, up ? -15 : -3 + crouch, 3, up ? 12 : 10, '#fcd8a8'); // back arm
|
| 170 |
+
r(11, up ? -16 : -4 + crouch, 5, up ? 14 : 12, '#000000'); r(12, up ? -15 : -3 + crouch, 3, up ? 12 : 10, '#fcd8a8'); // front arm
|
| 171 |
+
r(-10, -16 + crouch, 20, 13, '#000000'); r(-9, -15 + crouch, 18, 11, '#f8b800'); r(-9, -15 + crouch, 18, 2, '#fce0a8'); // helmet
|
| 172 |
+
r(-2, -13 + crouch, 4, 2, '#d82800');
|
| 173 |
+
r(-5, -10 + crouch, 13, 7, '#fcd8a8'); r(1, -9 + crouch, 2, 2, '#000000'); r(6, -9 + crouch, 2, 2, '#000000'); r(-3, -5 + crouch, 11, 2, '#fcfcfc'); // face, jaw
|
| 174 |
+
}
|
| 175 |
+
function bossSprite(x, c, t) {
|
| 176 |
+
var o = c.boss, id = o.id;
|
| 177 |
+
if (o.hp <= 0) return;
|
| 178 |
+
var R = MM.RobotMaster, since = R.INTRO - o.intro;
|
| 179 |
+
if (o.intro > 0 && since < 24 && ((since >> 2) & 1)) return; // the boss materialises during its intro
|
| 180 |
+
if (id === 'guts_man') {
|
| 181 |
+
if (o.pose === 'lift' && o.st === 'throw_rock') MM.drawRock(x, Math.round(o.x) + 16 * o.look, Math.round(o.y) - 24, 14, c.t); // the boulder he is about to throw
|
| 182 |
+
gutsBody(x, o, ((o.iframes + 1) & 2) !== 0);
|
| 183 |
+
return;
|
| 184 |
+
}
|
| 185 |
+
// white flash: draw_entity tests bit 1 of boss_iframes BEFORE its render-time decrement; the simulation has
|
| 186 |
+
// already decremented it at the end of the tick, so the pre-decrement value is iframes + 1
|
| 187 |
+
if ((o.iframes + 1) & 2) { sprite(x, GRIDS[id], WHITE, Math.round(o.x) - 12, Math.round(o.y) + 12 - 24, o.look < 0, BOSS_DUP); return; }
|
| 188 |
+
sprite(x, GRIDS[id], MAPS[id], Math.round(o.x) - 12, Math.round(o.y) + 12 - 24, o.look < 0, BOSS_DUP);
|
| 189 |
+
if (id === 'bomb_man' && o.pose === 'windup') { // the bomb held over his head while he winds up
|
| 190 |
+
MM.drawBomb(x, Math.round(o.x) - 4 * o.look, Math.round(o.y) - 18, c.t, o.windup < 8);
|
| 191 |
+
}
|
| 192 |
+
if (o.windup > 0 && (o.pose === 'fire' || o.pose === 'stance' || o.pose === 'summon' || o.pose === 'windup')) { // telegraph glint
|
| 193 |
+
var gx = Math.round(o.x) + 10 * o.look, gy = Math.round(o.y) - 4;
|
| 194 |
+
if ((o.windup >> 1) & 1) { px(x, gx - 2, gy - 2, 4, 4, '#fcfcfc'); px(x, gx - 4, gy, 8, 1, '#fcfcfc'); px(x, gx, gy - 4, 1, 8, '#fcfcfc'); }
|
| 195 |
+
}
|
| 196 |
+
}
|
| 197 |
+
// every hazard is drawn to its exact hitbox (hw x hh around its centre), so what you see is what hurts
|
| 198 |
+
function projectiles(x, c, t) {
|
| 199 |
+
c.boss.projectiles.forEach(function (p) {
|
| 200 |
+
var X = Math.round(p.x), Y = Math.round(p.y);
|
| 201 |
+
if (p.kind === 'thunder_beam') MM.drawBolt(x, p, c.t, false);
|
| 202 |
+
else if (p.kind === 'ice_slasher') { px(x, X - 6, Y - 5, 12, 10, 'rgba(0,0,40,.55)'); MM.drawSlasher(x, p, 4); }
|
| 203 |
+
else if (p.kind === 'fire_wave') MM.drawFlame(x, X, Y + p.hh, p.hw * 2, p.hh * 2, (c.t >> 2) + p.id, false); // harmful while forming too
|
| 204 |
+
else if (p.kind === 'bomb' || p.kind === 'intro_bomb') MM.drawBomb(x, X, Y, c.t, false);
|
| 205 |
+
else if (p.kind === 'shrapnel' || p.kind === 'dust') MM.drawShard(x, p, c.t);
|
| 206 |
+
else if (p.kind === 'rolling_cutter') MM.drawCutter(x, X, Y, c.t, p.hw);
|
| 207 |
+
else if (p.kind === 'rock' || p.kind === 'ceiling_rock') MM.drawRock(x, X, Y, p.hw, c.t);
|
| 208 |
+
else if (p.kind === 'rock_chunk') MM.drawChunk(x, X, Y, '#a87800', '#f8d878');
|
| 209 |
+
else if (p.kind === 'fire_pillar') {
|
| 210 |
+
MM.drawFlame(x, X, Y + p.hh, p.hw * 2, p.hh * 2, (c.t >> 1) + 1, p.t < 30 && (c.t & 4));
|
| 211 |
+
}
|
| 212 |
+
});
|
| 213 |
+
}
|
| 214 |
+
// the Rolling Cutter: open scissors spinning through four shapes, filling its hitbox
|
| 215 |
+
MM.drawCutter = function (x, X, Y, t, h) {
|
| 216 |
+
var k = (t >> 2) & 3, a = [[1, 1], [1, 0], [1, -1], [0, 1]][k], n = h + 1;
|
| 217 |
+
for (var i = -n; i <= n; i++) {
|
| 218 |
+
px(x, X + i * a[0] - 1, Y + i * a[1] - 1, 3, 3, i < 0 ? '#fcfcfc' : '#bcbcbc');
|
| 219 |
+
px(x, X - i * a[1] - 1, Y + i * a[0] - 1, 3, 3, '#fcfcfc');
|
| 220 |
+
}
|
| 221 |
+
px(x, X - 1, Y - 1, 3, 3, '#d82800');
|
| 222 |
+
};
|
| 223 |
+
// the boss bomb: an 8x8-radius black sphere with a fuse spark (16x16 hitbox drawn as 14 px + outline)
|
| 224 |
+
MM.drawBomb = function (x, X, Y, t, flash) {
|
| 225 |
+
px(x, X - 6, Y - 5, 12, 12, '#000000'); px(x, X - 7, Y - 3, 14, 8, '#000000'); px(x, X - 5, Y - 7, 10, 2, '#000000');
|
| 226 |
+
px(x, X - 5, Y - 4, 10, 9, flash && (t & 2) ? '#fcfcfc' : '#3c3c3c'); px(x, X - 3, Y - 3, 3, 2, '#bcbcbc');
|
| 227 |
+
px(x, X + 1, Y - 9, 2, 3, '#7c7c7c'); px(x, X + 2, Y - 11, 2, 2, (t >> 1) & 1 ? '#f8b800' : '#fcfcfc');
|
| 228 |
+
};
|
| 229 |
+
// shrapnel: a white-hot star; dust: an orange-brown puff (both harmful, both drawn to the 16x16 box)
|
| 230 |
+
MM.drawShard = function (x, p, t) {
|
| 231 |
+
var X = Math.round(p.x), Y = Math.round(p.y), dust = p.kind === 'dust', k = (t + p.slot) & 1;
|
| 232 |
+
var hot = dust ? '#c84c0c' : '#fcfcfc', mid = dust ? '#7c3c00' : '#f8b800';
|
| 233 |
+
px(x, X - 2, Y - 7, 4, 14, mid); px(x, X - 7, Y - 2, 14, 4, mid);
|
| 234 |
+
px(x, X - 4, Y - 4, 8, 8, hot); if (!dust) { px(x, X - 5 - k, Y - 5 - k, 2, 2, mid); px(x, X + 3 + k, Y + 3 + k, 2, 2, mid); }
|
| 235 |
+
else px(x, X - 6, Y - 6 + k, 3, 3, '#7c3c00');
|
| 236 |
+
};
|
| 237 |
+
['megaman/elec_man', 'megaman/ice_man', 'megaman/fire_man', 'megaman/bomb_man', 'megaman/cut_man', 'megaman/guts_man'].forEach(function (id) {
|
| 238 |
+
B.BOSS_DRAW[id] = { hazards: function () {}, body: function () {}, boss: bossSprite, projectiles: projectiles,
|
| 239 |
+
bar: function () { return '#f87858'; } };
|
| 240 |
+
});
|
| 241 |
+
})(typeof window !== 'undefined' ? window : globalThis);
|
environments/games/web/games/megaman_remake/game.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Mega Man (NES, 1987) · Robot Masters - game manifest for the BB.Case shell (engine/app.js).
|
| 2 |
+
// Public difficulty is three tiers; the spec rows (specs/*.yaml) are written at exactly these values, so
|
| 3 |
+
// tier = spec column and any d in between interpolates. Rule version bumps whenever rules or tiers change.
|
| 4 |
+
(function (g) {
|
| 5 |
+
var B = g.BB, MM = B.MM;
|
| 6 |
+
B.GAME = {
|
| 7 |
+
id: 'megaman_remake',
|
| 8 |
+
title: 'Mega Man · Boss Rush',
|
| 9 |
+
rules: 'megaman-nes-20261105-r4',
|
| 10 |
+
tiers: { easy: 0, normal: 0.5, hard: 1 },
|
| 11 |
+
hz: 60,
|
| 12 |
+
defaultCase: 'megaman/elec_man',
|
| 13 |
+
hitstop: false, // the NES game has no hit-stop
|
| 14 |
+
results: { win: 'BOSS DEFEATED', loss: 'GAME OVER', timeout: 'TIME UP' },
|
| 15 |
+
roster: [
|
| 16 |
+
{ id: 'megaman/elec_man', name: 'POUNCER · Counterattack Unit', arch: 'Fast movement · Counters every shot · Crawling zigzag arcs (10 damage). Weak to the returning blade' },
|
| 17 |
+
{ id: 'megaman/ice_man', name: 'V GUNNER · V-Shot Unit', arch: 'Fixed barrage · Jumps straight up and fires six blades in a V, faster as the fight goes on. Weak to the tri arc (10 damage)' },
|
| 18 |
+
{ id: 'megaman/fire_man', name: 'WAVE KEEPER · Ground-Wave Unit', arch: 'Keeps 96 px away · Ground-hugging fire waves and flames beneath your feet · Counterattacks when hit. Weak to the pierce dart (4 damage)' },
|
| 19 |
+
{ id: 'megaman/bomb_man', name: 'SHARD LOBBER · Bomb Unit', arch: 'Random jumps · Throws 1–3 bombs that burst into 12-way shrapnel on landing · Leaps away at close range. Weak to orbit guard (4 damage)' },
|
| 20 |
+
{ id: 'megaman/cut_man', name: 'BLADE TOSSER · Returning-Blade Unit', arch: 'Random jumps · Throws a blade that returns · The room has steps and two liftable rocks. Weak to the rock throw (14 damage)' },
|
| 21 |
+
{ id: 'megaman/guts_man', name: 'QUAKE HURLER · Ground-Shock Unit', arch: 'Landing shakes the screen and stuns grounded players · Catches falling ceiling rocks and throws them, splitting each into four · Two rocks can be lifted. Weak to the timed bomb (10 damage)' }
|
| 22 |
+
],
|
| 23 |
+
// weapon x boss damage, the demonstrable counter chain of this round (data/weapons.js is the source)
|
| 24 |
+
chain: [['elec_man', 'E', 'ice_man'], ['ice_man', 'I', 'fire_man'], ['fire_man', 'F', 'bomb_man'], ['cut_man', 'C', 'elec_man'], ['guts_man', 'G', 'cut_man'], ['bomb_man', 'B', 'guts_man']],
|
| 25 |
+
// human play on the page: the weapons won so far (page.js keeps them); the harness passes options itself
|
| 26 |
+
resetOptions: function () { return { weapons: (B.MM_PAGE && B.MM_PAGE.loadout()) || [] }; }
|
| 27 |
+
};
|
| 28 |
+
B.GAME.skillText = {};
|
| 29 |
+
B.GAME.roster.forEach(function (r) {
|
| 30 |
+
var id = r.id.split('/')[1], spec = B.SPECS[id], text = B.GAME.skillText[r.id] = {};
|
| 31 |
+
spec.moves.forEach(function (m) { text[m.name] = m.cue + ' → ' + m.punish; });
|
| 32 |
+
});
|
| 33 |
+
MM.caseBoss = function (caseId) { return String(caseId).split('/')[1]; };
|
| 34 |
+
})(typeof window !== 'undefined' ? window : globalThis);
|
environments/games/web/games/megaman_remake/index.html
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="data:,"><title>Mega Man · Boss Rush — BossBench</title>
|
| 2 |
+
<style>
|
| 3 |
+
:root{--bg:#0b0b16;--panel:#141428;--line:#3c3c64;--ink:#e8e8fc;--dim:#8c8cb0;--gold:#f8b800;--blue:#3cbcfc}*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--ink);font:14px/1.6 "Segoe UI","Microsoft YaHei",sans-serif;background-image:linear-gradient(#ffffff05 1px,transparent 1px);background-size:100% 4px}#wrap{max-width:1110px;margin:auto;padding:22px 24px}header{display:flex;justify-content:space-between;align-items:center;border-bottom:2px solid var(--line);padding:10px 0}.brand{font:bold 12px Consolas,monospace;letter-spacing:.2em;color:var(--blue);text-decoration:none}.edition{font:11px Consolas,monospace;letter-spacing:.12em;color:var(--dim)}h1{font:900 40px/1 Consolas,"Lucida Console",monospace;letter-spacing:.02em;margin:16px 0 8px;color:var(--blue);text-shadow:3px 3px 0 #0000bc}h1 em{font-style:normal;color:var(--gold);text-shadow:3px 3px 0 #a81000}.sub{color:var(--dim);margin:0 0 18px;max-width:860px}#stage{position:relative;width:854px;max-width:100%;aspect-ratio:854/480;margin:auto;border:3px solid #000;outline:2px solid var(--line);image-rendering:pixelated;margin-bottom:22px}#view{display:block;width:100%;height:100%;outline:none;image-rendering:pixelated}.overlay{position:absolute;inset:0;display:flex;flex-direction:column;justify-content:center;align-items:center;padding:18px;overflow:auto;background:#05050cdc}.hidden{display:none!important}#select h2{font:bold 18px Consolas,monospace;letter-spacing:.1em;margin:0 0 12px;color:var(--gold)}.grid{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;width:100%;max-width:784px}.card{position:relative;min-height:128px;border:2px solid var(--line);background:#101024;color:var(--ink);padding:16px 14px;text-align:left;font:inherit;cursor:pointer}.card .nm{font:bold 17px Consolas,monospace;line-height:1.2;color:var(--blue)}.card .ar{font:12px/1.6 "Microsoft YaHei",sans-serif;color:var(--dim);margin-top:10px}.tag{font:8px Consolas,monospace;letter-spacing:.1em;position:absolute;right:8px;bottom:6px;color:var(--gold)}.card.on{border-color:var(--gold);box-shadow:inset 0 0 0 2px var(--gold)}.card:focus-visible,button:focus-visible{outline:3px solid var(--blue);outline-offset:3px}.row{display:flex;gap:9px;align-items:center;justify-content:center;flex-wrap:wrap;margin-top:14px}.b{font:13px "Microsoft YaHei",sans-serif;border:2px solid var(--line);background:var(--panel);color:var(--ink);padding:7px 12px;cursor:pointer}.b.on{color:var(--gold);border-color:var(--gold);font-weight:bold}.go{background:#0058f8;border-color:#3cbcfc;color:#fff;padding:10px 26px;font-weight:bold}.loadout{display:flex;gap:8px;flex-wrap:wrap;justify-content:center;margin-top:12px;font:12px "Microsoft YaHei",sans-serif;color:var(--dim)}.loadout label{border:1px solid var(--line);padding:4px 9px;cursor:pointer;background:#101024}.loadout input{vertical-align:middle;margin-right:4px}input,select{font:inherit;border:1px solid var(--line);background:var(--panel);color:var(--ink)}input[type=range]{width:95px}#result h2{font:bold 34px Consolas,monospace;margin:0 0 10px}#rjson{font:10px/1.4 Consolas,monospace;max-width:100%;white-space:pre-wrap;overflow-wrap:anywhere;color:var(--dim)}#pausehint{position:absolute;top:100%;left:0;right:0;margin-top:4px;text-align:center;font:11px sans-serif;color:var(--dim)}#help{display:grid;grid-template-columns:1.1fr 1fr;gap:22px;margin-top:24px}.box{padding:14px 0;border-top:2px solid var(--line)}.box h3{margin:0 0 9px;font:700 14px "Microsoft YaHei",sans-serif;letter-spacing:.08em;color:var(--gold)}.box ul{padding-left:19px;margin:0;font:12px/1.9 "Microsoft YaHei",sans-serif}kbd{font:11px Consolas,monospace;padding:1px 5px;border:1px solid var(--line);background:#1c1c34;color:#fff}table.dmg{border-collapse:collapse;font:12px Consolas,monospace;margin-top:6px}table.dmg td,table.dmg th{border:1px solid var(--line);padding:3px 8px;text-align:center}table.dmg th{color:var(--dim);font-weight:normal}table.dmg td.weak{color:#000;background:var(--gold);font-weight:bold}table.dmg td.zero{color:#f87858}.replay-panel{padding:14px;margin-top:18px;border:2px solid var(--line);background:var(--panel);font:12px "Microsoft YaHei",sans-serif}.note{color:var(--dim);font:11px/1.7 "Microsoft YaHei",sans-serif}.note a{color:inherit}footer{border-top:1px solid var(--line);padding-top:12px;margin-top:16px;font:11px "Microsoft YaHei",sans-serif;color:var(--dim)}footer a{color:var(--blue)}@media(max-width:700px){#wrap{padding:12px}h1{font-size:28px}.grid{gap:7px}.card{padding:10px 8px;min-height:92px}.card .nm{font-size:14px}.card .ar{font-size:10px}.overlay{padding:10px;justify-content:flex-start}#select h2{font-size:14px;margin:0 0 7px}#select .note,.loadout{display:none}#help{grid-template-columns:1fr;gap:0}.row{gap:6px;margin-top:9px}.b{font-size:11px;padding:6px 9px}#dslider,#dval{display:none}}
|
| 4 |
+
</style></head><body><div id="wrap"><header><a class="brand" href="../../index.html">BOSSBENCH / 2D</a><span class="edition">NES 1987 · 60 Hz</span></header><h1>MEGA MAN <em>BOSS RUSH</em></h1><p class="sub" id="mmsub">Boss battles recreated from the 1987 NES rules. Defeat bosses to acquire their weapons and follow the weakness chain. No slide or charge shot.</p>
|
| 5 |
+
<div id="stage"><canvas id="view" width="854" height="480" tabindex="0" aria-label="Battle Screen"></canvas><div id="select" class="overlay"><h2>STAGE SELECT · Select Boss</h2><div id="grid" class="grid"></div><div class="loadout" id="loadout" aria-label="Acquired weapons"></div><div class="row"><button class="b" data-d="0">Easy</button><button class="b on" data-d="0.5">Normal</button><button class="b" data-d="1">Hard</button><input id="dslider" aria-label="Difficulty" type="range" min="0" max="1" step="0.05" value="0.5"><span id="dval">0.50</span><label for="seed">Seed</label><input id="seed" type="number" value="0" style="width:64px"></div><div class="row"><button id="start" class="b go">START · Start Challenge</button></div><p class="note">Select acquired weapons to bring them into the challenge. Defeating a boss unlocks its weapon. Hard uses original values (boss projectile damage: 10 units; contact damage: 4 units).</p></div>
|
| 6 |
+
<div id="result" class="overlay hidden"><h2 id="rtitle">BOSS DEFEATED</h2><div id="rsub"></div><div id="rweapon" class="note"></div><pre id="rjson"></pre><div class="row"><button class="b go" id="again">Try again (R)</button><button class="b" id="back">Select Boss (Esc)</button></div></div><div id="pausehint" class="hidden">P / Esc Pause · Press Q while paused to go back</div></div>
|
| 7 |
+
<div class="row hidden" id="play-actions"><button class="b" id="pause">Pause</button></div><div id="pausepanel" class="row hidden"><button id="resume" class="b">Resume</button><button id="quit" class="b">Back to Stages</button></div>
|
| 8 |
+
<div id="help"><section class="box"><h3>Controls · CONTROLS</h3><ul><li><kbd>A</kbd><kbd>D</kbd> / arrow keys to move; <kbd>Space</kbd> / <kbd>Z</kbd> to jump; hold for more height</li><li><kbd>J</kbd> / <kbd>X</kbd> / left mouse button to fire (one shot per press, up to three Arm Gun shots on screen)</li><li><kbd>Q</kbd> / <kbd>E</kbd> switch weapons (replaces the original pause menu: switching recalls the active special shot; fired Arm Gun shots continue moving but no longer deal damage)</li><li><kbd>P</kbd>/<kbd>Esc</kbd> to pause; then <kbd>Q</kbd> to go back; after a result, press <kbd>R</kbd> to retry. Scripted Demo runs reference script <code>BB.GAME.scripted</code></li><li>Sliding was added in Mega Man 3 and charge shots in Mega Man 4; neither is available here</li></ul><h3 style="margin-top:14px">Weapon × boss damage table (NES units)</h3><div id="dmgtable"></div></section><section class="box" id="skills"><h3>Skill list</h3><ul id="skilllist"></ul></section></div>
|
| 9 |
+
<div class="replay-panel"><b>Replay and step playback</b><div class="row"><button id="save-run" class="b">Save this replay</button><label class="b">Import Replay <input id="load-run" type="file" accept=".json" style="max-width:150px"></label><select id="demo-run" class="b" aria-label="Select an automatic example"><option value="">Select an automatic example…</option></select><button id="replay-toggle" class="b">Play / Pause</button><button id="replay-back" class="b">Exit Replay</button><span id="replay-status">One packet every 200 ms; replays are deterministic with the same seed, options, and rules</span></div></div>
|
| 10 |
+
<footer>Independent mechanics recreation: boss state machines, damage tables, invulnerability frames, and physics constants follow public annotated disassemblies of the first game. Visuals are original pixel art drawn in code; no original ROM images or audio are used.</footer></div>
|
| 11 |
+
<script src="../../engine/core.js"></script><script src="arena.js"></script><script src="data/weapons.js"></script><script src="specs/elec_man.spec.js"></script><script src="specs/ice_man.spec.js"></script><script src="specs/fire_man.spec.js"></script>
|
| 12 |
+
<script src="specs/bomb_man.spec.js"></script><script src="specs/cut_man.spec.js"></script><script src="specs/guts_man.spec.js"></script><script src="body_megaman.js"></script><script src="../../engine/boss_kit.js"></script><script src="bosses/robot_master.js"></script><script src="bosses/elec_man.js"></script><script src="bosses/ice_man.js"></script><script src="bosses/fire_man.js"></script>
|
| 13 |
+
<script src="bosses/bomb_man.js"></script><script src="bosses/cut_man.js"></script><script src="bosses/guts_man.js"></script><script src="../../engine/case.js"></script><script src="../../engine/juice.js"></script><script src="../../engine/art_kit.js"></script><script src="../../engine/renderer.js"></script><script src="draw/palette.js"></script><script src="draw/compose.js"></script><script src="draw/player.js"></script><script src="draw/rooms.js"></script><script src="draw/hud.js"></script><script src="art/scenes.js"></script><script src="game.js"></script><script src="scripted.js"></script><script src="../../engine/input.js"></script><script src="../../engine/app.js"></script><script src="page.js"></script><script src="../../engine/sessions.js"></script>
|
| 14 |
+
</body></html>
|
environments/games/web/games/megaman_remake/page.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Play-page extras (browser only; harmless in Node and in the policy-env page, where the DOM nodes are absent):
|
| 2 |
+
// the weapon loadout chooser (weapons won so far, unlocked automatically by a win), the weapon x boss damage
|
| 3 |
+
// table rendered from data/weapons.js, and the "YOU GOT ..." line on the result screen.
|
| 4 |
+
(function (g) {
|
| 5 |
+
var B = g.BB, MM = B.MM;
|
| 6 |
+
var owned = {};
|
| 7 |
+
try { owned = JSON.parse(g.localStorage && g.localStorage.getItem('bb.megaman.weapons') || '{}') || {}; } catch (e) { owned = {}; }
|
| 8 |
+
function save() { try { g.localStorage.setItem('bb.megaman.weapons', JSON.stringify(owned)); } catch (e) { /* file:// may refuse */ } }
|
| 9 |
+
B.MM_PAGE = { loadout: function () { return MM.WEAPON_ORDER.filter(function (w) { return owned[w] && MM.WEAPONS[w].built; }); } };
|
| 10 |
+
var doc = g.document;
|
| 11 |
+
if (!doc || !doc.getElementById || !doc.getElementById('loadout')) return;
|
| 12 |
+
var $ = function (id) { return doc.getElementById(id); };
|
| 13 |
+
|
| 14 |
+
function renderLoadout() {
|
| 15 |
+
var host = $('loadout'); host.textContent = '';
|
| 16 |
+
var lab = doc.createElement('span'); lab.textContent = 'Acquired weapons: '; host.appendChild(lab);
|
| 17 |
+
MM.WEAPON_ORDER.forEach(function (w) {
|
| 18 |
+
var info = MM.WEAPONS[w];
|
| 19 |
+
if (!info.from || !info.built) return;
|
| 20 |
+
var l = doc.createElement('label'), cb = doc.createElement('input');
|
| 21 |
+
cb.type = 'checkbox'; cb.checked = !!owned[w]; cb.dataset.weapon = w;
|
| 22 |
+
cb.addEventListener('change', function () { owned[w] = cb.checked; save(); });
|
| 23 |
+
l.appendChild(cb); l.appendChild(doc.createTextNode(info.name + ' (defeat ' + MM.ROBOT_MASTERS[info.from].zh + ')'));
|
| 24 |
+
host.appendChild(l);
|
| 25 |
+
});
|
| 26 |
+
}
|
| 27 |
+
function renderTable() {
|
| 28 |
+
var bosses = ['elec_man', 'ice_man', 'fire_man', 'cut_man', 'bomb_man', 'guts_man'];
|
| 29 |
+
var weapons = MM.WEAPON_ORDER.filter(function (w) { return w !== 'M'; });
|
| 30 |
+
var t = doc.createElement('table'); t.className = 'dmg';
|
| 31 |
+
var head = doc.createElement('tr'); head.appendChild(doc.createElement('th'));
|
| 32 |
+
weapons.forEach(function (w) { var th = doc.createElement('th'); th.textContent = MM.WEAPONS[w].zh; th.title = MM.WEAPONS[w].name; head.appendChild(th); });
|
| 33 |
+
t.appendChild(head);
|
| 34 |
+
bosses.forEach(function (id) {
|
| 35 |
+
var tr = doc.createElement('tr'), th = doc.createElement('th'), weak = MM.weakTo(id);
|
| 36 |
+
th.textContent = MM.ROBOT_MASTERS[id].zh + (B.CASES['megaman/' + id] ? '' : '*'); tr.appendChild(th);
|
| 37 |
+
weapons.forEach(function (w) {
|
| 38 |
+
var td = doc.createElement('td'), v = MM.DAMAGE[id][w]; td.textContent = v;
|
| 39 |
+
if (w === weak) td.className = 'weak'; else if (v === 0) td.className = 'zero';
|
| 40 |
+
tr.appendChild(td);
|
| 41 |
+
});
|
| 42 |
+
t.appendChild(tr);
|
| 43 |
+
});
|
| 44 |
+
var note = doc.createElement('p'); note.className = 'note';
|
| 45 |
+
note.textContent = 'Each cell is one NES energy unit (a boss has 28 at full health). Gold marks a weakness. Values come from the original ROM. Weakness chain: Pouncer → Tri Arc → V Gunner → Pierce Dart → Wave Keeper → Orbit Guard → Shard Lobber → Fuse Lob → Quake Hurler → Rock Throw → Blade Tosser → Returning Blade → Pouncer.';
|
| 46 |
+
$('dmgtable').appendChild(t); $('dmgtable').appendChild(note);
|
| 47 |
+
}
|
| 48 |
+
// the subtitle names the scenes from the roster, so the count never drifts from the code (hand-written counts did)
|
| 49 |
+
function renderSub() {
|
| 50 |
+
var el = $('mmsub'), names = B.GAME.roster.map(function (r) { return MM.ROBOT_MASTERS[MM.caseBoss(r.id)].zh; });
|
| 51 |
+
var chain = B.GAME.chain.filter(function (k) { return MM.WEAPONS[k[1]].built && B.CASES['megaman/' + k[2]]; })
|
| 52 |
+
.map(function (k) { return MM.WEAPONS[k[1]].zh + ' is strong against ' + MM.ROBOT_MASTERS[k[2]].zh; });
|
| 53 |
+
if (el) el.textContent = 'Faithful to the 1987 NES rules across ' + names.length + ' boss battles: ' + names.join(', ') +
|
| 54 |
+
'. Defeat bosses to acquire their weapons. The weakness chain is: ' + chain.join(', ') + '. There is no slide or charge shot.';
|
| 55 |
+
}
|
| 56 |
+
renderLoadout(); renderTable(); renderSub();
|
| 57 |
+
// a win unlocks the boss's weapon for later fights (only for human or demo play on this page)
|
| 58 |
+
var result = $('result'), seen = null;
|
| 59 |
+
new g.MutationObserver(function () {
|
| 60 |
+
if (result.classList.contains('hidden')) return;
|
| 61 |
+
var run = g.BossBench && g.BossBench.lastRun;
|
| 62 |
+
if (!run || run === seen) return;
|
| 63 |
+
seen = run;
|
| 64 |
+
var boss = MM.caseBoss(run.case), info = MM.ROBOT_MASTERS[boss], w = info && info.weapon;
|
| 65 |
+
if (run.verifier && run.verifier.outcome === 'win' && w && MM.WEAPONS[w].built) {
|
| 66 |
+
var fresh = !owned[w]; owned[w] = true; save(); renderLoadout();
|
| 67 |
+
$('rweapon').textContent = (fresh ? 'New weapon acquired: ' : 'Already owned: ') + MM.WEAPONS[w].name + '. Strong against: ' +
|
| 68 |
+
Object.keys(MM.DAMAGE).filter(function (id) { return MM.weakTo(id) === w; }).map(function (id) { return MM.ROBOT_MASTERS[id].zh; }).join(', ');
|
| 69 |
+
} else $('rweapon').textContent = '';
|
| 70 |
+
}).observe(result, { attributes: true, attributeFilter: ['class'] });
|
| 71 |
+
})(typeof window !== 'undefined' ? window : globalThis);
|
environments/games/web/games/megaman_remake/scripted.js
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Standard scripted reference controller for the Mega Man cases (BossBench protocol section 3).
|
| 2 |
+
// BB.GAME.scripted(c) is called once per 200 ms packet with the live BB.Case. It plans by receding-horizon
|
| 3 |
+
// search: a systematic set of action sequences (direction x jump start x jump height x fire pattern), 48 ticks
|
| 4 |
+
// long, plus the previous best plan shifted by one packet, is simulated on deep copies of the case (the live
|
| 5 |
+
// case, its RNG and its event list are never touched) and scored on damage taken (dominant), damage dealt and a
|
| 6 |
+
// small positional heuristic; the first packet of the best sequence is played.
|
| 7 |
+
// Deterministic (no Math.random, no clock); emits legal packets (<= 4 keys per hold set). It reads privileged
|
| 8 |
+
// state and simulates the boss, but rolls not yet made are re-drawn from a synthetic RNG: a trusted demo/recording
|
| 9 |
+
// tool, not a policy.
|
| 10 |
+
(function (g) {
|
| 11 |
+
var B = g.BB, MM = B.MM;
|
| 12 |
+
if (!B || !B.GAME) return;
|
| 13 |
+
var SUBS = 24, TICKS = 2; // horizon: 24 hold sets x 2 ticks = 48 ticks = 4 packets
|
| 14 |
+
var MEMORY = typeof WeakMap === 'function' ? new WeakMap() : null;
|
| 15 |
+
var JUMP_AT = [0, 1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 18], JUMP_LEN = [14, 5];
|
| 16 |
+
|
| 17 |
+
function clone(o) { return JSON.parse(JSON.stringify(o)); }
|
| 18 |
+
function copyCase(c, k) {
|
| 19 |
+
var n = Object.create(Object.getPrototypeOf(c)); Object.assign(n, c);
|
| 20 |
+
n.body = Object.assign(Object.create(Object.getPrototypeOf(c.body)), clone(c.body));
|
| 21 |
+
n.boss = Object.assign(Object.create(Object.getPrototypeOf(c.boss)), clone(c.boss));
|
| 22 |
+
// the look-ahead gets its own RNG: decisions already taken are readable, rolls not yet made are not (EXPAND_TO_6.md 2.4)
|
| 23 |
+
n.rng = new B.RNG(((c.t + 1) * 2654435761 + 97 + k * 40503) >>> 0);
|
| 24 |
+
n.events = []; return n;
|
| 25 |
+
}
|
| 26 |
+
function blank() { var a = []; for (var i = 0; i < SUBS; i++) a.push(0); return a; }
|
| 27 |
+
function fill(a, from, to, v) { for (var i = Math.max(0, from); i < Math.min(SUBS, to); i++) a[i] = v; return a; }
|
| 28 |
+
function pulses(from, every) { var a = blank(); for (var i = from; i < SUBS; i += every) a[i] = 1; return a; }
|
| 29 |
+
function plan(dir, jump, fire) { return { dir: dir, jump: jump, fire: fire }; }
|
| 30 |
+
function holdSet(p, i) {
|
| 31 |
+
var k = {};
|
| 32 |
+
if (p.dir[i] < 0) k.A = true; else if (p.dir[i] > 0) k.D = true;
|
| 33 |
+
if (p.jump[i]) k.Space = true;
|
| 34 |
+
if (p.fire[i]) k.J = true;
|
| 35 |
+
return k;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
// ---------------- scoring ----------------
|
| 39 |
+
// The plan's 48 ticks are followed by a short continuation (keep the direction, release jump, keep firing) so a
|
| 40 |
+
// jump that lands on a pillar or into a shot just past the horizon is still seen; its damage counts half.
|
| 41 |
+
var EXTRA = 24, STUN_COST = 1.5;
|
| 42 |
+
function evaluate(c, p, k) {
|
| 43 |
+
var sim = copyCase(c, k), b = sim.body, o = sim.boss, score = 0, hp = b.hp, bhp = o.hp, t;
|
| 44 |
+
for (var i = 0; i < SUBS; i++) {
|
| 45 |
+
var keys = holdSet(p, i);
|
| 46 |
+
for (var k = 0; k < TICKS; k++) {
|
| 47 |
+
sim.tick(keys); t = i * TICKS + k;
|
| 48 |
+
if (b.hp < hp) { score -= (hp - b.hp) / MM.UNIT * 400 * (1 - t / 200); hp = b.hp; }
|
| 49 |
+
if (b.stunT > 0) score -= STUN_COST; // a stunned player cannot dodge the rock that follows (Guts Man only)
|
| 50 |
+
if (o.hp < bhp) { score += (bhp - o.hp) / MM.UNIT * 40 * (1 - t / 120); bhp = o.hp; }
|
| 51 |
+
if (sim.result === 'loss') return score - 1e6;
|
| 52 |
+
if (sim.result === 'win') return score + 1e6 - t * 10;
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
var last = p.dir[SUBS - 1], tail = {};
|
| 56 |
+
if (last < 0) tail.A = true; else if (last > 0) tail.D = true;
|
| 57 |
+
for (var e = 0; e < EXTRA && !sim.result; e++) {
|
| 58 |
+
tail.J = !(e & 2);
|
| 59 |
+
sim.tick(tail);
|
| 60 |
+
if (b.hp < hp) { score -= (hp - b.hp) / MM.UNIT * 200; hp = b.hp; }
|
| 61 |
+
}
|
| 62 |
+
if (sim.result === 'loss') return score - 5e5;
|
| 63 |
+
// terminal heuristic: margin from boss shots, room from the boss and the walls, shots on their way to hit
|
| 64 |
+
var hb = b.hurtBox(), margin = 40;
|
| 65 |
+
o.projectiles.forEach(function (q) {
|
| 66 |
+
if (q.harmless) return;
|
| 67 |
+
var dx = Math.max(0, Math.abs(q.x - hb.x) - q.hw - hb.hw), dy = Math.max(0, Math.abs(q.y - hb.y) - q.hh - hb.hh);
|
| 68 |
+
margin = Math.min(margin, Math.max(dx, dy));
|
| 69 |
+
});
|
| 70 |
+
score += margin * 1.2;
|
| 71 |
+
if (o.hp > 0) score -= Math.max(0, 52 - Math.abs(o.x - b.x)) * (Math.abs(o.y - b.y) < 40 ? 7 : 2);
|
| 72 |
+
score -= Math.max(0, 32 - Math.min(b.x - MM.WALL_L, MM.WALL_R - b.x)) * 0.8;
|
| 73 |
+
b.shots.forEach(function (s) {
|
| 74 |
+
if (Math.abs(s.y - o.y) < o.hh + s.hh && (o.x - s.x) * (s.vx || 0) > 0) score += 6;
|
| 75 |
+
});
|
| 76 |
+
if (b.knockT > 0) score -= 20;
|
| 77 |
+
return score;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
// ---------------- candidate sequences ----------------
|
| 81 |
+
function candidates(c, mem) {
|
| 82 |
+
var b = c.body, out = [], grounded = b.grounded, held = !!b.prev.jump;
|
| 83 |
+
var fireAll = pulses(0, 2), fireNone = blank();
|
| 84 |
+
if (mem.best) { // previous best, shifted one packet
|
| 85 |
+
var s = mem.best, keep = plan(s.dir.slice(6), s.jump.slice(6), s.fire.slice(6));
|
| 86 |
+
while (keep.dir.length < SUBS) { keep.dir.push(keep.dir[keep.dir.length - 1]); keep.jump.push(0); keep.fire.push(keep.fire.length % 2 ? 0 : 1); }
|
| 87 |
+
out.push(keep);
|
| 88 |
+
}
|
| 89 |
+
[-1, 0, 1].forEach(function (d) {
|
| 90 |
+
var dir = fill(blank(), 0, SUBS, d);
|
| 91 |
+
[fireAll, fireNone].forEach(function (fire) {
|
| 92 |
+
// no new jump: keep holding Space while airborne (full height) or release now (feather)
|
| 93 |
+
out.push(plan(dir, !grounded && held ? fill(blank(), 0, 14, 1) : blank(), fire));
|
| 94 |
+
if (!grounded && held) out.push(plan(dir, blank(), fire));
|
| 95 |
+
JUMP_AT.forEach(function (at) {
|
| 96 |
+
JUMP_LEN.forEach(function (len) {
|
| 97 |
+
var jump = blank(), start = at;
|
| 98 |
+
if (start === 0 && held) start = 1; // a new press needs a released sub-step first
|
| 99 |
+
fill(jump, start, start + len, 1);
|
| 100 |
+
if (!grounded && held && at > 0) fill(jump, 0, 1, 1);
|
| 101 |
+
out.push(plan(dir, jump, fire));
|
| 102 |
+
});
|
| 103 |
+
});
|
| 104 |
+
});
|
| 105 |
+
});
|
| 106 |
+
// move-then-stop plans (step out of the way, then hold position), with and without a jump
|
| 107 |
+
[-1, 1].forEach(function (d) {
|
| 108 |
+
[3, 6, 10].forEach(function (k) {
|
| 109 |
+
[blank(), fill(blank(), held ? 1 : 0, 14, 1), fill(blank(), k, k + 14, 1)].forEach(function (jump) {
|
| 110 |
+
[fireAll, fireNone].forEach(function (fire) { out.push(plan(fill(fill(blank(), 0, k, d), k, SUBS, 0), jump, fire)); });
|
| 111 |
+
});
|
| 112 |
+
});
|
| 113 |
+
});
|
| 114 |
+
// a few two-segment plans (turn around mid-horizon)
|
| 115 |
+
[-1, 1].forEach(function (d) {
|
| 116 |
+
[6, 12].forEach(function (cut) {
|
| 117 |
+
out.push(plan(fill(fill(blank(), 0, cut, d), cut, SUBS, -d), fill(blank(), held ? 1 : 0, 14, 1), fireAll));
|
| 118 |
+
out.push(plan(fill(fill(blank(), 0, cut, d), cut, SUBS, -d), blank(), fireAll));
|
| 119 |
+
});
|
| 120 |
+
});
|
| 121 |
+
return out;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
// the owned weapon with the best damage RATE against this boss that still has energy: shots are limited by the boss's
|
| 125 |
+
// blink, the Hyper Bomb by its 160-frame fuse-and-flames cycle, the Rolling Cutter by its roughly 64-frame round trip
|
| 126 |
+
function bestWeapon(c) {
|
| 127 |
+
var b = c.body, row = MM.DAMAGE[c.boss.id], blink = c.boss.info.iframes + 1, best = 'P';
|
| 128 |
+
function rate(w) { return row[w] / Math.max(blink, w === 'B' ? 160 : w === 'C' ? 64 : 0); }
|
| 129 |
+
// the Super Arm needs a block: one left in the room, or one held, thrown or broken into chunks
|
| 130 |
+
function usable(w) { return b.spendable(w) && (w !== 'G' || b.blockOut() || b.room.some(function (r) { return r.block; })); }
|
| 131 |
+
var weak = MM.weakTo(c.boss.id);
|
| 132 |
+
if (b.weapons.indexOf(weak) >= 0 && usable(weak)) return weak; // the counter chain: the boss's weakness first
|
| 133 |
+
b.weapons.forEach(function (w) { if (usable(w) && rate(w) > rate(best)) best = w; });
|
| 134 |
+
return best;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
// Bosses whose AI rolls dice get several sampled futures per plan, scored half worst case, half mean, so a plan is
|
| 138 |
+
// not chosen for surviving only one outcome of a roll not yet made. RNG-free bosses need a single evaluation.
|
| 139 |
+
var ROLLS = { elec_man: 3, bomb_man: 3, cut_man: 3, guts_man: 3 };
|
| 140 |
+
function robust(c, p) {
|
| 141 |
+
var n = ROLLS[c.boss.id] || 1, worst = Infinity, sum = 0;
|
| 142 |
+
for (var k = 0; k < n; k++) { var v = evaluate(c, p, k); sum += v; if (v < worst) worst = v; }
|
| 143 |
+
return n === 1 ? worst : 0.5 * worst + 0.5 * sum / n;
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
B.GAME.scripted = function (c) {
|
| 147 |
+
var mem = MEMORY ? MEMORY.get(c) : null;
|
| 148 |
+
if (!mem || c.t === 0 || mem.t > c.t) { mem = { t: c.t, best: null }; if (MEMORY) MEMORY.set(c, mem); }
|
| 149 |
+
mem.t = c.t;
|
| 150 |
+
var b = c.body, o = c.boss, idle = [{}, {}, {}, {}, {}, {}];
|
| 151 |
+
if (o.intro > 0 || b.hp <= 0 || o.hp <= 0) { mem.best = null; return idle; }
|
| 152 |
+
if (b.weapon !== bestWeapon(c) && !b.count('hyper_bomb') && !b.count('hyper_flame')) { mem.best = null; return [{ E: true }, {}, {}, {}, {}, {}]; } // one step per press
|
| 153 |
+
var cands = candidates(c, mem), bestScore = -Infinity, best = null;
|
| 154 |
+
for (var i = 0; i < cands.length; i++) {
|
| 155 |
+
var s = robust(c, cands[i]);
|
| 156 |
+
if (s > bestScore + 1e-9) { bestScore = s; best = cands[i]; }
|
| 157 |
+
}
|
| 158 |
+
mem.best = best;
|
| 159 |
+
var out = [];
|
| 160 |
+
for (var k = 0; k < 6; k++) out.push(holdSet(best, k));
|
| 161 |
+
return out;
|
| 162 |
+
};
|
| 163 |
+
})(typeof window !== 'undefined' ? window : globalThis);
|
environments/games/web/games/megaman_remake/specs/bomb_man.spec.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// GENERATED from bomb_man.yaml by tools/gen_spec.py - edit the YAML, not this file.
|
| 2 |
+
(function (g) { var BB = g.BB = g.BB || {}; BB.SPECS = BB.SPECS || {};
|
| 3 |
+
BB.SPECS["bomb_man"] = {
|
| 4 |
+
"schema": "bossbench/boss-spec@1",
|
| 5 |
+
"id": "bomb_man",
|
| 6 |
+
"dims": "2d",
|
| 7 |
+
"family": "megaman_nes",
|
| 8 |
+
"archetype": "Mega Man (NES 1987) Bomb Man: random leap toward the player, lobs 1-3 bombs that burst into 12-way shrapnel, jumps at a player who closes in",
|
| 9 |
+
"hp_model": {
|
| 10 |
+
"knob": "hp",
|
| 11 |
+
"integer": true
|
| 12 |
+
},
|
| 13 |
+
"states": {
|
| 14 |
+
"idle": "walk_idle",
|
| 15 |
+
"telegraph": "throw",
|
| 16 |
+
"active": "land_throw",
|
| 17 |
+
"recovery": "wait_bomb"
|
| 18 |
+
},
|
| 19 |
+
"timing": {
|
| 20 |
+
"telegraph": {
|
| 21 |
+
"knob": "windup",
|
| 22 |
+
"min": 1
|
| 23 |
+
},
|
| 24 |
+
"recovery": {
|
| 25 |
+
"knob": "windup",
|
| 26 |
+
"until": "timer"
|
| 27 |
+
}
|
| 28 |
+
},
|
| 29 |
+
"locomotion": {
|
| 30 |
+
"knob": "windup",
|
| 31 |
+
"when": "before_select",
|
| 32 |
+
"speed_by_state": {
|
| 33 |
+
"idle": 1.0,
|
| 34 |
+
"telegraph": 0.0,
|
| 35 |
+
"active": 0.0,
|
| 36 |
+
"recovery": 0.0
|
| 37 |
+
}
|
| 38 |
+
},
|
| 39 |
+
"select": {
|
| 40 |
+
"trigger": "pattern_step",
|
| 41 |
+
"policy": "first",
|
| 42 |
+
"face_target": true
|
| 43 |
+
},
|
| 44 |
+
"moves": [
|
| 45 |
+
{
|
| 46 |
+
"name": "lob_bomb",
|
| 47 |
+
"atoms": [
|
| 48 |
+
"projectile"
|
| 49 |
+
],
|
| 50 |
+
"damage": 4,
|
| 51 |
+
"cue": "After landing he raises a bomb and charges for about 0.25 seconds, then throws it at you. The bomb lands after 49 frames, about 20 px short of you. He waits for each bomb to explode before throwing the next, 1-3 per volley",
|
| 52 |
+
"punish": "The bomb itself cannot be shot (bullets pass through). Read the landing spot, jump over the horizontal fragments, or back out of their range (about 30 px)"
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"name": "shrapnel",
|
| 56 |
+
"atoms": [
|
| 57 |
+
"burst"
|
| 58 |
+
],
|
| 59 |
+
"damage": 4,
|
| 60 |
+
"cue": "The bomb explodes into 12 pieces when it lands or hits a wall: fast pieces about 30 px up, down, left, and right, diagonal pieces about 20 px, plus four slow pieces",
|
| 61 |
+
"punish": "The ground-level horizontal pieces are only 16 px tall, so a jump clears them. Do not stand directly above the landing spot"
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"name": "leap",
|
| 65 |
+
"atoms": [
|
| 66 |
+
"leap"
|
| 67 |
+
],
|
| 68 |
+
"damage": 4,
|
| 69 |
+
"cue": "Each volley starts with a random jump: a long pounce toward you (about 154 px) or a short hop closer (about 49 px). After a short-hop volley he jumps away with his back to you",
|
| 70 |
+
"punish": "The long jump carries him over you, so walk under him. He only starts charging after he lands and settles, which is the damage window"
|
| 71 |
+
},
|
| 72 |
+
{
|
| 73 |
+
"name": "close_guard",
|
| 74 |
+
"atoms": [
|
| 75 |
+
"leap"
|
| 76 |
+
],
|
| 77 |
+
"damage": 4,
|
| 78 |
+
"cue": "If you walk within 48 px, he drops the current bomb and jumps at you immediately",
|
| 79 |
+
"punish": "You can use this to break his throw rhythm, but he jumps over your head, so watch the contact damage"
|
| 80 |
+
}
|
| 81 |
+
],
|
| 82 |
+
"difficulty": {
|
| 83 |
+
"hp": [
|
| 84 |
+
66,
|
| 85 |
+
180,
|
| 86 |
+
520
|
| 87 |
+
],
|
| 88 |
+
"shot": [
|
| 89 |
+
2,
|
| 90 |
+
3,
|
| 91 |
+
4
|
| 92 |
+
],
|
| 93 |
+
"contact": [
|
| 94 |
+
2,
|
| 95 |
+
3,
|
| 96 |
+
4
|
| 97 |
+
],
|
| 98 |
+
"windup": [
|
| 99 |
+
30,
|
| 100 |
+
20,
|
| 101 |
+
15
|
| 102 |
+
]
|
| 103 |
+
},
|
| 104 |
+
"skills_tested": [
|
| 105 |
+
"read_telegraph",
|
| 106 |
+
"timing_jump",
|
| 107 |
+
"spacing",
|
| 108 |
+
"hazard_avoid",
|
| 109 |
+
"aim",
|
| 110 |
+
"weapon_choice"
|
| 111 |
+
],
|
| 112 |
+
"provenance": {
|
| 113 |
+
"source": "plasticsmoke/megaman1-disassembly-ca65 @2771fb3 src/fixed/fixed_game_modes.asm mode 2 ($DFF0); see SOURCES.md",
|
| 114 |
+
"license": "Original procedural art and implementation; mechanics read from the annotated disassembly (MIT annotations), no ROM data or assets shipped"
|
| 115 |
+
}
|
| 116 |
+
};
|
| 117 |
+
})(typeof window !== 'undefined' ? window : globalThis);
|
environments/games/web/games/megaman_remake/specs/cut_man.spec.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// GENERATED from cut_man.yaml by tools/gen_spec.py - edit the YAML, not this file.
|
| 2 |
+
(function (g) { var BB = g.BB = g.BB || {}; BB.SPECS = BB.SPECS || {};
|
| 3 |
+
BB.SPECS["cut_man"] = {
|
| 4 |
+
"schema": "bossbench/boss-spec@1",
|
| 5 |
+
"id": "cut_man",
|
| 6 |
+
"dims": "2d",
|
| 7 |
+
"family": "megaman_nes",
|
| 8 |
+
"archetype": "Mega Man (NES 1987) Cut Man: random leaps at the player, a homing Rolling Cutter that flies out and back, a step and two blocks in the room",
|
| 9 |
+
"hp_model": {
|
| 10 |
+
"knob": "hp",
|
| 11 |
+
"integer": true
|
| 12 |
+
},
|
| 13 |
+
"states": {
|
| 14 |
+
"idle": "retarget",
|
| 15 |
+
"telegraph": "land_settle",
|
| 16 |
+
"active": "throw_windup",
|
| 17 |
+
"recovery": "chase"
|
| 18 |
+
},
|
| 19 |
+
"timing": {
|
| 20 |
+
"telegraph": {
|
| 21 |
+
"knob": "wait",
|
| 22 |
+
"min": 1
|
| 23 |
+
},
|
| 24 |
+
"recovery": {
|
| 25 |
+
"knob": "wait",
|
| 26 |
+
"until": "timer"
|
| 27 |
+
}
|
| 28 |
+
},
|
| 29 |
+
"locomotion": {
|
| 30 |
+
"knob": "speed",
|
| 31 |
+
"when": "before_select",
|
| 32 |
+
"speed_by_state": {
|
| 33 |
+
"idle": 1.0,
|
| 34 |
+
"telegraph": 0.0,
|
| 35 |
+
"active": 0.0,
|
| 36 |
+
"recovery": 0.0
|
| 37 |
+
}
|
| 38 |
+
},
|
| 39 |
+
"select": {
|
| 40 |
+
"trigger": "pattern_step",
|
| 41 |
+
"policy": "first",
|
| 42 |
+
"face_target": true
|
| 43 |
+
},
|
| 44 |
+
"moves": [
|
| 45 |
+
{
|
| 46 |
+
"name": "return_blade",
|
| 47 |
+
"atoms": [
|
| 48 |
+
"boomerang"
|
| 49 |
+
],
|
| 50 |
+
"damage": 4,
|
| 51 |
+
"cue": "After landing he stands, raises the cutter for about 16 frames, and throws it at you. It turns around at the room edge and speeds back to his hand, and the return pass sweeps through where you are",
|
| 52 |
+
"punish": "While the cutter is out he has no weapon, so close in and shoot. The return path follows him; do not stand between him and the blade"
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"name": "leap",
|
| 56 |
+
"atoms": [
|
| 57 |
+
"leap"
|
| 58 |
+
],
|
| 59 |
+
"damage": 4,
|
| 60 |
+
"cue": "Within 64 px he jumps (6.4 px/frame upward): a 1/2 chance to land 32 px past you, 1/3 to land on you, and 1/6 to land in front of you",
|
| 61 |
+
"punish": "When he jumps, walk under him or the other way. He may throw the cutter in the air"
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"name": "chase",
|
| 65 |
+
"atoms": [
|
| 66 |
+
"wait"
|
| 67 |
+
],
|
| 68 |
+
"damage": 4,
|
| 69 |
+
"cue": "If you are on a ledge and he is on the ground, he runs in place for about 1 second, then throws the cutter",
|
| 70 |
+
"punish": "The ledge is a safe place to watch, but the cutter flies at you when the wait ends"
|
| 71 |
+
},
|
| 72 |
+
{
|
| 73 |
+
"name": "hop_back",
|
| 74 |
+
"atoms": [
|
| 75 |
+
"hop"
|
| 76 |
+
],
|
| 77 |
+
"damage": 4,
|
| 78 |
+
"cue": "After a hit he flashes for 63 frames and hops away with his back to you for the first 32 frames",
|
| 79 |
+
"punish": "Bullets pass through him while he is flashing"
|
| 80 |
+
}
|
| 81 |
+
],
|
| 82 |
+
"difficulty": {
|
| 83 |
+
"hp": [
|
| 84 |
+
60,
|
| 85 |
+
170,
|
| 86 |
+
520
|
| 87 |
+
],
|
| 88 |
+
"shot": [
|
| 89 |
+
2,
|
| 90 |
+
3,
|
| 91 |
+
4
|
| 92 |
+
],
|
| 93 |
+
"contact": [
|
| 94 |
+
2,
|
| 95 |
+
3,
|
| 96 |
+
4
|
| 97 |
+
],
|
| 98 |
+
"speed": [
|
| 99 |
+
0.8,
|
| 100 |
+
0.9,
|
| 101 |
+
1.0
|
| 102 |
+
],
|
| 103 |
+
"wait": [
|
| 104 |
+
63,
|
| 105 |
+
63,
|
| 106 |
+
63
|
| 107 |
+
]
|
| 108 |
+
},
|
| 109 |
+
"skills_tested": [
|
| 110 |
+
"read_telegraph",
|
| 111 |
+
"timing_jump",
|
| 112 |
+
"spacing",
|
| 113 |
+
"hazard_avoid",
|
| 114 |
+
"aim",
|
| 115 |
+
"weapon_choice"
|
| 116 |
+
],
|
| 117 |
+
"provenance": {
|
| 118 |
+
"source": "plasticsmoke/megaman1-disassembly-ca65 @2771fb3 src/fixed/fixed_game_modes.asm mode 0 ($DC8B); see SOURCES.md",
|
| 119 |
+
"license": "Original procedural art and implementation; mechanics read from the annotated disassembly (MIT annotations), no ROM data or assets shipped"
|
| 120 |
+
}
|
| 121 |
+
};
|
| 122 |
+
})(typeof window !== 'undefined' ? window : globalThis);
|
environments/games/web/games/megaman_remake/specs/elec_man.spec.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// GENERATED from elec_man.yaml by tools/gen_spec.py - edit the YAML, not this file.
|
| 2 |
+
(function (g) { var BB = g.BB = g.BB || {}; BB.SPECS = BB.SPECS || {};
|
| 3 |
+
BB.SPECS["elec_man"] = {
|
| 4 |
+
"schema": "bossbench/boss-spec@1",
|
| 5 |
+
"id": "elec_man",
|
| 6 |
+
"dims": "2d",
|
| 7 |
+
"family": "megaman_nes",
|
| 8 |
+
"archetype": "Mega Man (NES 1987) Elec Man: wall-position patrol, counter-leap on the player's shot, crawling Thunder Beam",
|
| 9 |
+
"hp_model": {
|
| 10 |
+
"knob": "hp",
|
| 11 |
+
"integer": true
|
| 12 |
+
},
|
| 13 |
+
"states": {
|
| 14 |
+
"idle": "guard",
|
| 15 |
+
"telegraph": "halt",
|
| 16 |
+
"active": "fire",
|
| 17 |
+
"recovery": "wait"
|
| 18 |
+
},
|
| 19 |
+
"timing": {
|
| 20 |
+
"telegraph": {
|
| 21 |
+
"knob": "windup",
|
| 22 |
+
"min": 1
|
| 23 |
+
},
|
| 24 |
+
"recovery": {
|
| 25 |
+
"knob": "windup",
|
| 26 |
+
"until": "timer"
|
| 27 |
+
}
|
| 28 |
+
},
|
| 29 |
+
"locomotion": {
|
| 30 |
+
"knob": "walk",
|
| 31 |
+
"when": "before_select",
|
| 32 |
+
"speed_by_state": {
|
| 33 |
+
"idle": 1.0,
|
| 34 |
+
"telegraph": 0.0,
|
| 35 |
+
"active": 0.0,
|
| 36 |
+
"recovery": 0.0
|
| 37 |
+
}
|
| 38 |
+
},
|
| 39 |
+
"select": {
|
| 40 |
+
"trigger": "pattern_step",
|
| 41 |
+
"policy": "first",
|
| 42 |
+
"face_target": true
|
| 43 |
+
},
|
| 44 |
+
"moves": [
|
| 45 |
+
{
|
| 46 |
+
"name": "zigzag_arc",
|
| 47 |
+
"atoms": [
|
| 48 |
+
"crawling_bolt"
|
| 49 |
+
],
|
| 50 |
+
"damage": 10,
|
| 51 |
+
"cue": "He stops, raises his hand for 15 frames, then fires a five-segment jagged arc. Each segment hops forward and changes shape every 10 frames, averaging about 4 px/frame",
|
| 52 |
+
"punish": "The high arc arrives first and you can let it pass while standing. Jump before the low arc arrives; jumping toward him makes it easier to pass through"
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"name": "counter_leap",
|
| 56 |
+
"atoms": [
|
| 57 |
+
"leap"
|
| 58 |
+
],
|
| 59 |
+
"damage": 4,
|
| 60 |
+
"cue": "If you press fire while he is walking, he immediately jumps at you (a 1/4 chance it is a feint the other way)",
|
| 61 |
+
"punish": "Do not fire while he is repositioning. Wait until he stands and fires the arc"
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"name": "air_arc",
|
| 65 |
+
"atoms": [
|
| 66 |
+
"crawling_bolt"
|
| 67 |
+
],
|
| 68 |
+
"damage": 10,
|
| 69 |
+
"cue": "If you fire again while he is in the air, he charges in the air and releases one arc",
|
| 70 |
+
"punish": "The air arc stays at his height, so watch where he lands"
|
| 71 |
+
},
|
| 72 |
+
{
|
| 73 |
+
"name": "hop_back",
|
| 74 |
+
"atoms": [
|
| 75 |
+
"hop"
|
| 76 |
+
],
|
| 77 |
+
"damage": 4,
|
| 78 |
+
"cue": "After a hit he flashes for 63 frames and jumps away with his back to you for the first 32 frames",
|
| 79 |
+
"punish": "Bullets pass through him while he flashes, so save shots until the flash ends"
|
| 80 |
+
}
|
| 81 |
+
],
|
| 82 |
+
"difficulty": {
|
| 83 |
+
"hp": [
|
| 84 |
+
19,
|
| 85 |
+
40,
|
| 86 |
+
150
|
| 87 |
+
],
|
| 88 |
+
"shot": [
|
| 89 |
+
4,
|
| 90 |
+
7,
|
| 91 |
+
10
|
| 92 |
+
],
|
| 93 |
+
"contact": [
|
| 94 |
+
2,
|
| 95 |
+
3,
|
| 96 |
+
4
|
| 97 |
+
],
|
| 98 |
+
"walk": [
|
| 99 |
+
1.5,
|
| 100 |
+
1.75,
|
| 101 |
+
2.0
|
| 102 |
+
],
|
| 103 |
+
"windup": [
|
| 104 |
+
30,
|
| 105 |
+
20,
|
| 106 |
+
15
|
| 107 |
+
],
|
| 108 |
+
"counter": [
|
| 109 |
+
0.35,
|
| 110 |
+
0.7,
|
| 111 |
+
1.0
|
| 112 |
+
]
|
| 113 |
+
},
|
| 114 |
+
"kinds": {
|
| 115 |
+
"counter": "continuous"
|
| 116 |
+
},
|
| 117 |
+
"skills_tested": [
|
| 118 |
+
"read_telegraph",
|
| 119 |
+
"timing_jump",
|
| 120 |
+
"bait_counter",
|
| 121 |
+
"spacing",
|
| 122 |
+
"weapon_choice"
|
| 123 |
+
],
|
| 124 |
+
"provenance": {
|
| 125 |
+
"source": "plasticsmoke/megaman1-disassembly-ca65 @2771fb3 src/fixed/fixed_game_modes.asm mode 4 ($E434); see SOURCES.md",
|
| 126 |
+
"license": "Original procedural art and implementation; mechanics read from the annotated disassembly (MIT annotations), no ROM data or assets shipped"
|
| 127 |
+
}
|
| 128 |
+
};
|
| 129 |
+
})(typeof window !== 'undefined' ? window : globalThis);
|
environments/games/web/games/megaman_remake/specs/fire_man.spec.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// GENERATED from fire_man.yaml by tools/gen_spec.py - edit the YAML, not this file.
|
| 2 |
+
(function (g) { var BB = g.BB = g.BB || {}; BB.SPECS = BB.SPECS || {};
|
| 3 |
+
BB.SPECS["fire_man"] = {
|
| 4 |
+
"schema": "bossbench/boss-spec@1",
|
| 5 |
+
"id": "fire_man",
|
| 6 |
+
"dims": "2d",
|
| 7 |
+
"family": "megaman_nes",
|
| 8 |
+
"archetype": "Mega Man (NES 1987) Fire Man: keeps a 96 px band, five-wave Fire Storm volleys, floor pillars, retaliates when hit",
|
| 9 |
+
"hp_model": {
|
| 10 |
+
"knob": "hp",
|
| 11 |
+
"integer": true
|
| 12 |
+
},
|
| 13 |
+
"states": {
|
| 14 |
+
"idle": "pace",
|
| 15 |
+
"telegraph": "summon",
|
| 16 |
+
"active": "hold",
|
| 17 |
+
"recovery": "pose"
|
| 18 |
+
},
|
| 19 |
+
"timing": {
|
| 20 |
+
"telegraph": {
|
| 21 |
+
"knob": "hold",
|
| 22 |
+
"min": 1
|
| 23 |
+
},
|
| 24 |
+
"recovery": {
|
| 25 |
+
"knob": "hold",
|
| 26 |
+
"until": "timer"
|
| 27 |
+
}
|
| 28 |
+
},
|
| 29 |
+
"locomotion": {
|
| 30 |
+
"knob": "hold",
|
| 31 |
+
"when": "before_select",
|
| 32 |
+
"speed_by_state": {
|
| 33 |
+
"idle": 1.0,
|
| 34 |
+
"telegraph": 0.0,
|
| 35 |
+
"active": 0.0,
|
| 36 |
+
"recovery": 0.0
|
| 37 |
+
}
|
| 38 |
+
},
|
| 39 |
+
"select": {
|
| 40 |
+
"trigger": "distance_band",
|
| 41 |
+
"policy": "first",
|
| 42 |
+
"face_target": true
|
| 43 |
+
},
|
| 44 |
+
"moves": [
|
| 45 |
+
{
|
| 46 |
+
"name": "ground_wave",
|
| 47 |
+
"atoms": [
|
| 48 |
+
"projectile"
|
| 49 |
+
],
|
| 50 |
+
"damage": 4,
|
| 51 |
+
"cue": "He stands about 96 px away. The flame in his hand forms for 23 frames, then rushes along the ground at 5 px/frame. A volley is at most five shots, about 1 second apart",
|
| 52 |
+
"punish": "Get ready to jump when the flame forms. The wave is 32 px tall, so clear it near the top of the jump"
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"name": "fire_pillar",
|
| 56 |
+
"atoms": [
|
| 57 |
+
"hazard"
|
| 58 |
+
],
|
| 59 |
+
"damage": 4,
|
| 60 |
+
"cue": "Where a fire wave passes under you, a pillar rises and lasts about 2.2 seconds",
|
| 61 |
+
"punish": "Avoid the pillar when you land. The old pillar goes out when he fires the next wave"
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"name": "keep_distance",
|
| 65 |
+
"atoms": [
|
| 66 |
+
"walk"
|
| 67 |
+
],
|
| 68 |
+
"damage": 4,
|
| 69 |
+
"cue": "He backs away when you close in and advances when you retreat, holding about 96 px. Cornered against a wall, he turns and walks straight through you",
|
| 70 |
+
"punish": "Shoot while he is backing up. Watch the contact damage when he is against the wall"
|
| 71 |
+
},
|
| 72 |
+
{
|
| 73 |
+
"name": "retaliate",
|
| 74 |
+
"atoms": [
|
| 75 |
+
"projectile"
|
| 76 |
+
],
|
| 77 |
+
"damage": 4,
|
| 78 |
+
"cue": "About 14 frames (0.23 seconds) after a hit, he immediately starts a new fire volley",
|
| 79 |
+
"punish": "Get ready to jump right after a hit connects"
|
| 80 |
+
},
|
| 81 |
+
{
|
| 82 |
+
"name": "stand_down",
|
| 83 |
+
"atoms": [
|
| 84 |
+
"pose"
|
| 85 |
+
],
|
| 86 |
+
"damage": 0,
|
| 87 |
+
"cue": "After five shots he poses and stops firing. Any key you press, or leaving the distance band, makes him start again",
|
| 88 |
+
"punish": "Original behavior: if you do not move at all, he will not attack again"
|
| 89 |
+
}
|
| 90 |
+
],
|
| 91 |
+
"difficulty": {
|
| 92 |
+
"hp": [
|
| 93 |
+
66,
|
| 94 |
+
86,
|
| 95 |
+
270
|
| 96 |
+
],
|
| 97 |
+
"shot": [
|
| 98 |
+
2,
|
| 99 |
+
3,
|
| 100 |
+
4
|
| 101 |
+
],
|
| 102 |
+
"contact": [
|
| 103 |
+
2,
|
| 104 |
+
3,
|
| 105 |
+
4
|
| 106 |
+
],
|
| 107 |
+
"hold": [
|
| 108 |
+
90,
|
| 109 |
+
75,
|
| 110 |
+
63
|
| 111 |
+
],
|
| 112 |
+
"retaliate": [
|
| 113 |
+
0,
|
| 114 |
+
1,
|
| 115 |
+
1
|
| 116 |
+
]
|
| 117 |
+
},
|
| 118 |
+
"kinds": {
|
| 119 |
+
"retaliate": "unlock"
|
| 120 |
+
},
|
| 121 |
+
"skills_tested": [
|
| 122 |
+
"timing_jump",
|
| 123 |
+
"spacing",
|
| 124 |
+
"hazard_avoid",
|
| 125 |
+
"aim",
|
| 126 |
+
"weapon_choice"
|
| 127 |
+
],
|
| 128 |
+
"provenance": {
|
| 129 |
+
"source": "plasticsmoke/megaman1-disassembly-ca65 @2771fb3 src/fixed/fixed_game_modes.asm mode 3 ($E2E4); see SOURCES.md",
|
| 130 |
+
"license": "Original procedural art and implementation; mechanics read from the annotated disassembly (MIT annotations), no ROM data or assets shipped"
|
| 131 |
+
}
|
| 132 |
+
};
|
| 133 |
+
})(typeof window !== 'undefined' ? window : globalThis);
|
environments/games/web/games/megaman_remake/specs/guts_man.spec.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// GENERATED from guts_man.yaml by tools/gen_spec.py - edit the YAML, not this file.
|
| 2 |
+
(function (g) { var BB = g.BB = g.BB || {}; BB.SPECS = BB.SPECS || {};
|
| 3 |
+
BB.SPECS["guts_man"] = {
|
| 4 |
+
"schema": "bossbench/boss-spec@1",
|
| 5 |
+
"id": "guts_man",
|
| 6 |
+
"dims": "2d",
|
| 7 |
+
"family": "megaman_nes",
|
| 8 |
+
"archetype": "Mega Man (NES 1987) Guts Man: heavy leaps that quake the room and stun anyone standing on the floor, a boulder from the ceiling thrown at you that shatters into four chunks",
|
| 9 |
+
"hp_model": {
|
| 10 |
+
"knob": "hp",
|
| 11 |
+
"integer": true
|
| 12 |
+
},
|
| 13 |
+
"states": {
|
| 14 |
+
"idle": "land_wait",
|
| 15 |
+
"telegraph": "windup_rock",
|
| 16 |
+
"active": "throw_rock",
|
| 17 |
+
"recovery": "pattern_roll"
|
| 18 |
+
},
|
| 19 |
+
"timing": {
|
| 20 |
+
"telegraph": {
|
| 21 |
+
"knob": "windup",
|
| 22 |
+
"min": 1
|
| 23 |
+
},
|
| 24 |
+
"recovery": {
|
| 25 |
+
"knob": "windup",
|
| 26 |
+
"until": "timer"
|
| 27 |
+
}
|
| 28 |
+
},
|
| 29 |
+
"locomotion": {
|
| 30 |
+
"knob": "windup",
|
| 31 |
+
"when": "before_select",
|
| 32 |
+
"speed_by_state": {
|
| 33 |
+
"idle": 1.0,
|
| 34 |
+
"telegraph": 0.0,
|
| 35 |
+
"active": 0.0,
|
| 36 |
+
"recovery": 0.0
|
| 37 |
+
}
|
| 38 |
+
},
|
| 39 |
+
"select": {
|
| 40 |
+
"trigger": "pattern_step",
|
| 41 |
+
"policy": "first",
|
| 42 |
+
"face_target": true
|
| 43 |
+
},
|
| 44 |
+
"moves": [
|
| 45 |
+
{
|
| 46 |
+
"name": "quake_leap",
|
| 47 |
+
"atoms": [
|
| 48 |
+
"leap"
|
| 49 |
+
],
|
| 50 |
+
"damage": 4,
|
| 51 |
+
"cue": "He crouches for about 0.25 seconds, then leaps. The landing shakes the screen for about 0.5 seconds, and if you are on the ground (or were just knocked back) you are stuck for about 0.8 seconds",
|
| 52 |
+
"punish": "Jump as he is about to land, and stay off the ground until the shake ends, or you will be stuck. His rise and fall are slow, so you can walk under him"
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"name": "boulder_throw",
|
| 56 |
+
"atoms": [
|
| 57 |
+
"projectile"
|
| 58 |
+
],
|
| 59 |
+
"damage": 4,
|
| 60 |
+
"cue": "He jumps in place. On landing a rock drops from the ceiling into his hands. He holds it for about 0.25 seconds, then throws it in a straight line at your feet",
|
| 61 |
+
"punish": "The rock cannot be shot (bullets pass through). While he stands holding it, that is the damage window. Jump or move the moment he throws"
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"name": "chunks",
|
| 65 |
+
"atoms": [
|
| 66 |
+
"burst"
|
| 67 |
+
],
|
| 68 |
+
"damage": 4,
|
| 69 |
+
"cue": "The rock shatters into four pieces on a wall, the ground, or a step. They keep flying the original way at 3-4 px/frame, and two of them rise",
|
| 70 |
+
"punish": "The pieces appear at the lower right of the impact (they are not mirrored with direction) and fly the original way. After the rock lands, walk back or jump"
|
| 71 |
+
}
|
| 72 |
+
],
|
| 73 |
+
"skills_tested": [
|
| 74 |
+
"read_telegraph",
|
| 75 |
+
"timing_jump",
|
| 76 |
+
"spacing",
|
| 77 |
+
"hazard_avoid",
|
| 78 |
+
"aim",
|
| 79 |
+
"weapon_choice"
|
| 80 |
+
],
|
| 81 |
+
"difficulty": {
|
| 82 |
+
"hp": [
|
| 83 |
+
56,
|
| 84 |
+
165,
|
| 85 |
+
470
|
| 86 |
+
],
|
| 87 |
+
"shot": [
|
| 88 |
+
2,
|
| 89 |
+
3,
|
| 90 |
+
4
|
| 91 |
+
],
|
| 92 |
+
"contact": [
|
| 93 |
+
2,
|
| 94 |
+
3,
|
| 95 |
+
4
|
| 96 |
+
],
|
| 97 |
+
"windup": [
|
| 98 |
+
30,
|
| 99 |
+
20,
|
| 100 |
+
15
|
| 101 |
+
],
|
| 102 |
+
"speed": [
|
| 103 |
+
0.8,
|
| 104 |
+
0.9,
|
| 105 |
+
1.0
|
| 106 |
+
]
|
| 107 |
+
},
|
| 108 |
+
"provenance": {
|
| 109 |
+
"source": "plasticsmoke/megaman1-disassembly-ca65 @2771fb3 src/fixed/fixed_game_modes.asm mode 5 ($E56E); see SOURCES.md",
|
| 110 |
+
"license": "Original procedural art and implementation; mechanics read from the annotated disassembly (MIT annotations), no ROM data or assets shipped"
|
| 111 |
+
}
|
| 112 |
+
};
|
| 113 |
+
})(typeof window !== 'undefined' ? window : globalThis);
|
environments/games/web/games/megaman_remake/specs/ice_man.spec.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// GENERATED from ice_man.yaml by tools/gen_spec.py - edit the YAML, not this file.
|
| 2 |
+
(function (g) { var BB = g.BB = g.BB || {}; BB.SPECS = BB.SPECS || {};
|
| 3 |
+
BB.SPECS["ice_man"] = {
|
| 4 |
+
"schema": "bossbench/boss-spec@1",
|
| 5 |
+
"id": "ice_man",
|
| 6 |
+
"dims": "2d",
|
| 7 |
+
"family": "megaman_nes",
|
| 8 |
+
"archetype": "Mega Man (NES 1987) Ice Man: four-waypoint patrol, vertical hop firing a six-shot V of Ice Slashers that speeds up",
|
| 9 |
+
"hp_model": {
|
| 10 |
+
"knob": "hp",
|
| 11 |
+
"integer": true
|
| 12 |
+
},
|
| 13 |
+
"states": {
|
| 14 |
+
"idle": "leg_walk",
|
| 15 |
+
"telegraph": "stance",
|
| 16 |
+
"active": "fire",
|
| 17 |
+
"recovery": "land"
|
| 18 |
+
},
|
| 19 |
+
"timing": {
|
| 20 |
+
"telegraph": {
|
| 21 |
+
"knob": "windup",
|
| 22 |
+
"min": 1
|
| 23 |
+
},
|
| 24 |
+
"recovery": {
|
| 25 |
+
"knob": "hover",
|
| 26 |
+
"until": "timer"
|
| 27 |
+
}
|
| 28 |
+
},
|
| 29 |
+
"locomotion": {
|
| 30 |
+
"knob": "speed",
|
| 31 |
+
"when": "before_select",
|
| 32 |
+
"speed_by_state": {
|
| 33 |
+
"idle": 1.0,
|
| 34 |
+
"telegraph": 0.0,
|
| 35 |
+
"active": 0.0,
|
| 36 |
+
"recovery": 0.0
|
| 37 |
+
}
|
| 38 |
+
},
|
| 39 |
+
"select": {
|
| 40 |
+
"trigger": "waypoint_cycle",
|
| 41 |
+
"policy": "first",
|
| 42 |
+
"face_target": true
|
| 43 |
+
},
|
| 44 |
+
"moves": [
|
| 45 |
+
{
|
| 46 |
+
"name": "v_volley",
|
| 47 |
+
"atoms": [
|
| 48 |
+
"projectile"
|
| 49 |
+
],
|
| 50 |
+
"damage": 10,
|
| 51 |
+
"cue": "He walks to a stance, charges 15 frames, and jumps straight up. On the way down he fires one blade at each of three heights, hovers at the ground, then rises in reverse and fires three more (six blades in a V)",
|
| 52 |
+
"punish": "Only the ground-level blade needs a jump. The middle and high blades can be let past while standing. Jumping too high hits the upper blade"
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"name": "patrol",
|
| 56 |
+
"atoms": [
|
| 57 |
+
"walk"
|
| 58 |
+
],
|
| 59 |
+
"damage": 4,
|
| 60 |
+
"cue": "He walks back and forth among the stances at 208, 168, 128, and 168. Every third landing raises the blade speed and the hover and sink timing by one level, up to four",
|
| 61 |
+
"punish": "Walking and charging are the safest windows to shoot. He has no hit reaction"
|
| 62 |
+
}
|
| 63 |
+
],
|
| 64 |
+
"difficulty": {
|
| 65 |
+
"hp": [
|
| 66 |
+
29,
|
| 67 |
+
85,
|
| 68 |
+
245
|
| 69 |
+
],
|
| 70 |
+
"shot": [
|
| 71 |
+
4,
|
| 72 |
+
7,
|
| 73 |
+
10
|
| 74 |
+
],
|
| 75 |
+
"contact": [
|
| 76 |
+
2,
|
| 77 |
+
3,
|
| 78 |
+
4
|
| 79 |
+
],
|
| 80 |
+
"speed": [
|
| 81 |
+
0.8,
|
| 82 |
+
0.9,
|
| 83 |
+
1.0
|
| 84 |
+
],
|
| 85 |
+
"hover": [
|
| 86 |
+
1.4,
|
| 87 |
+
1.2,
|
| 88 |
+
1.0
|
| 89 |
+
],
|
| 90 |
+
"windup": [
|
| 91 |
+
30,
|
| 92 |
+
20,
|
| 93 |
+
15
|
| 94 |
+
]
|
| 95 |
+
},
|
| 96 |
+
"skills_tested": [
|
| 97 |
+
"pattern_gaps",
|
| 98 |
+
"timing_jump",
|
| 99 |
+
"aim",
|
| 100 |
+
"weapon_choice"
|
| 101 |
+
],
|
| 102 |
+
"provenance": {
|
| 103 |
+
"source": "plasticsmoke/megaman1-disassembly-ca65 @2771fb3 src/fixed/fixed_game_modes.asm mode 1 ($E111); see SOURCES.md",
|
| 104 |
+
"license": "Original procedural art and implementation; mechanics read from the annotated disassembly (MIT annotations), no ROM data or assets shipped"
|
| 105 |
+
}
|
| 106 |
+
};
|
| 107 |
+
})(typeof window !== 'undefined' ? window : globalThis);
|
environments/games/web/games/minecraft_remake/compact_actions.json
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema": "bossbench/compact-actions@1",
|
| 3 |
+
"game": "minecraft",
|
| 4 |
+
"version": "minecraft-compact@2",
|
| 5 |
+
"heads": [
|
| 6 |
+
{
|
| 7 |
+
"name": "move",
|
| 8 |
+
"options": [
|
| 9 |
+
{
|
| 10 |
+
"label": "none"
|
| 11 |
+
},
|
| 12 |
+
{
|
| 13 |
+
"label": "forward",
|
| 14 |
+
"keys": [
|
| 15 |
+
"W"
|
| 16 |
+
]
|
| 17 |
+
},
|
| 18 |
+
{
|
| 19 |
+
"label": "back",
|
| 20 |
+
"keys": [
|
| 21 |
+
"S"
|
| 22 |
+
]
|
| 23 |
+
},
|
| 24 |
+
{
|
| 25 |
+
"label": "left",
|
| 26 |
+
"keys": [
|
| 27 |
+
"A"
|
| 28 |
+
]
|
| 29 |
+
},
|
| 30 |
+
{
|
| 31 |
+
"label": "right",
|
| 32 |
+
"keys": [
|
| 33 |
+
"D"
|
| 34 |
+
]
|
| 35 |
+
},
|
| 36 |
+
{
|
| 37 |
+
"label": "sprint",
|
| 38 |
+
"keys": [
|
| 39 |
+
"W",
|
| 40 |
+
"Shift"
|
| 41 |
+
]
|
| 42 |
+
}
|
| 43 |
+
]
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
"name": "action",
|
| 47 |
+
"options": [
|
| 48 |
+
{
|
| 49 |
+
"label": "none"
|
| 50 |
+
},
|
| 51 |
+
{
|
| 52 |
+
"label": "swing",
|
| 53 |
+
"tap": [
|
| 54 |
+
"LMB"
|
| 55 |
+
]
|
| 56 |
+
},
|
| 57 |
+
{
|
| 58 |
+
"label": "swing_late",
|
| 59 |
+
"subs": [
|
| 60 |
+
[],
|
| 61 |
+
[],
|
| 62 |
+
[],
|
| 63 |
+
[],
|
| 64 |
+
[
|
| 65 |
+
"LMB"
|
| 66 |
+
],
|
| 67 |
+
[]
|
| 68 |
+
]
|
| 69 |
+
},
|
| 70 |
+
{
|
| 71 |
+
"label": "draw",
|
| 72 |
+
"keys": [
|
| 73 |
+
"RMB"
|
| 74 |
+
]
|
| 75 |
+
},
|
| 76 |
+
{
|
| 77 |
+
"label": "jump",
|
| 78 |
+
"subs": [
|
| 79 |
+
[
|
| 80 |
+
"Space"
|
| 81 |
+
],
|
| 82 |
+
[
|
| 83 |
+
"Space"
|
| 84 |
+
],
|
| 85 |
+
[
|
| 86 |
+
"Space"
|
| 87 |
+
],
|
| 88 |
+
[],
|
| 89 |
+
[],
|
| 90 |
+
[]
|
| 91 |
+
]
|
| 92 |
+
},
|
| 93 |
+
{
|
| 94 |
+
"label": "switch",
|
| 95 |
+
"dz": 1
|
| 96 |
+
}
|
| 97 |
+
]
|
| 98 |
+
},
|
| 99 |
+
{
|
| 100 |
+
"name": "aim",
|
| 101 |
+
"options": [
|
| 102 |
+
{
|
| 103 |
+
"label": "none"
|
| 104 |
+
},
|
| 105 |
+
{
|
| 106 |
+
"label": "r8_c0",
|
| 107 |
+
"dx": 8
|
| 108 |
+
},
|
| 109 |
+
{
|
| 110 |
+
"label": "l8_c0",
|
| 111 |
+
"dx": -8
|
| 112 |
+
},
|
| 113 |
+
{
|
| 114 |
+
"label": "c0_d40",
|
| 115 |
+
"dy": 40
|
| 116 |
+
},
|
| 117 |
+
{
|
| 118 |
+
"label": "c0_u40",
|
| 119 |
+
"dy": -40
|
| 120 |
+
},
|
| 121 |
+
{
|
| 122 |
+
"label": "r25_c0",
|
| 123 |
+
"dx": 25
|
| 124 |
+
},
|
| 125 |
+
{
|
| 126 |
+
"label": "r25_d40",
|
| 127 |
+
"dx": 25,
|
| 128 |
+
"dy": 40
|
| 129 |
+
},
|
| 130 |
+
{
|
| 131 |
+
"label": "r25_u40",
|
| 132 |
+
"dx": 25,
|
| 133 |
+
"dy": -40
|
| 134 |
+
},
|
| 135 |
+
{
|
| 136 |
+
"label": "l25_c0",
|
| 137 |
+
"dx": -25
|
| 138 |
+
},
|
| 139 |
+
{
|
| 140 |
+
"label": "l25_d40",
|
| 141 |
+
"dx": -25,
|
| 142 |
+
"dy": 40
|
| 143 |
+
},
|
| 144 |
+
{
|
| 145 |
+
"label": "l25_u40",
|
| 146 |
+
"dx": -25,
|
| 147 |
+
"dy": -40
|
| 148 |
+
},
|
| 149 |
+
{
|
| 150 |
+
"label": "r60_c0",
|
| 151 |
+
"dx": 60
|
| 152 |
+
},
|
| 153 |
+
{
|
| 154 |
+
"label": "r60_d40",
|
| 155 |
+
"dx": 60,
|
| 156 |
+
"dy": 40
|
| 157 |
+
},
|
| 158 |
+
{
|
| 159 |
+
"label": "r60_u40",
|
| 160 |
+
"dx": 60,
|
| 161 |
+
"dy": -40
|
| 162 |
+
},
|
| 163 |
+
{
|
| 164 |
+
"label": "l60_c0",
|
| 165 |
+
"dx": -60
|
| 166 |
+
},
|
| 167 |
+
{
|
| 168 |
+
"label": "l60_d40",
|
| 169 |
+
"dx": -60,
|
| 170 |
+
"dy": 40
|
| 171 |
+
},
|
| 172 |
+
{
|
| 173 |
+
"label": "l60_u40",
|
| 174 |
+
"dx": -60,
|
| 175 |
+
"dy": -40
|
| 176 |
+
},
|
| 177 |
+
{
|
| 178 |
+
"label": "r150_c0",
|
| 179 |
+
"dx": 150
|
| 180 |
+
},
|
| 181 |
+
{
|
| 182 |
+
"label": "r150_d40",
|
| 183 |
+
"dx": 150,
|
| 184 |
+
"dy": 40
|
| 185 |
+
},
|
| 186 |
+
{
|
| 187 |
+
"label": "r150_u40",
|
| 188 |
+
"dx": 150,
|
| 189 |
+
"dy": -40
|
| 190 |
+
},
|
| 191 |
+
{
|
| 192 |
+
"label": "l150_c0",
|
| 193 |
+
"dx": -150
|
| 194 |
+
},
|
| 195 |
+
{
|
| 196 |
+
"label": "l150_d40",
|
| 197 |
+
"dx": -150,
|
| 198 |
+
"dy": 40
|
| 199 |
+
},
|
| 200 |
+
{
|
| 201 |
+
"label": "l150_u40",
|
| 202 |
+
"dx": -150,
|
| 203 |
+
"dy": -40
|
| 204 |
+
},
|
| 205 |
+
{
|
| 206 |
+
"label": "r300_c0",
|
| 207 |
+
"dx": 300
|
| 208 |
+
},
|
| 209 |
+
{
|
| 210 |
+
"label": "l300_c0",
|
| 211 |
+
"dx": -300
|
| 212 |
+
},
|
| 213 |
+
{
|
| 214 |
+
"label": "r600_c0",
|
| 215 |
+
"dx": 600
|
| 216 |
+
},
|
| 217 |
+
{
|
| 218 |
+
"label": "l600_c0",
|
| 219 |
+
"dx": -600
|
| 220 |
+
}
|
| 221 |
+
]
|
| 222 |
+
}
|
| 223 |
+
]
|
| 224 |
+
}
|
environments/games/web/games/minecraft_remake/index.html
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
| 6 |
+
<link rel="icon" href="data:,">
|
| 7 |
+
<title>Minecraft · Voxel Arena</title>
|
| 8 |
+
<link rel="stylesheet" href="style.css">
|
| 9 |
+
</head>
|
| 10 |
+
<body data-game="minecraft_remake">
|
| 11 |
+
<main>
|
| 12 |
+
<header>
|
| 13 |
+
<div><h1>Minecraft · Voxel Arena</h1>
|
| 14 |
+
<p>Java Edition 1.21 combat subset · Six boss arenas · Three public difficulty tiers · ModernGL rendering · 60 Hz · Recording and replay · Rules <code id="rules">minecraft-arena@7</code></p></div>
|
| 15 |
+
<a href="../../index.html">Back to Game Lobby</a>
|
| 16 |
+
</header>
|
| 17 |
+
<div class="layout">
|
| 18 |
+
<section>
|
| 19 |
+
<div class="stage" id="stage">
|
| 20 |
+
<img id="view" width="854" height="480" alt="Game screen rendered by the local Python server" draggable="false">
|
| 21 |
+
<div id="capture" tabindex="0" aria-label="Game screen: click to use keyboard and mouse controls"></div>
|
| 22 |
+
<div id="overlay"><div id="overlay-text">Select a boss to start</div></div>
|
| 23 |
+
<div id="offline" hidden>
|
| 24 |
+
<h2>Local game server is not running</h2>
|
| 25 |
+
<p>This Minecraft remake uses Python simulation and ModernGL rendering. Start the server from the project root:</p>
|
| 26 |
+
<pre id="launch">python games/prototype/bossbench/play_server.py</pre>
|
| 27 |
+
<button id="retry">Retry connection</button>
|
| 28 |
+
</div>
|
| 29 |
+
</div>
|
| 30 |
+
<div class="toolbar">
|
| 31 |
+
<button id="start" class="primary">Start Challenge / Restart</button>
|
| 32 |
+
<button id="pause">Pause</button>
|
| 33 |
+
<button id="step">Step (200 ms)</button>
|
| 34 |
+
<button id="demo">Scripted Demo</button>
|
| 35 |
+
<button id="export">Export Replay</button>
|
| 36 |
+
<button id="import">Import and Replay</button>
|
| 37 |
+
<input id="file" type="file" accept=".json,application/json" hidden>
|
| 38 |
+
</div>
|
| 39 |
+
<div class="mobile" aria-label="Touch controls">
|
| 40 |
+
<button data-key="W">W forward</button><button data-key="A">A left</button><button data-key="S">S backward</button><button data-key="D">D right</button>
|
| 41 |
+
<button data-key="Space">Jump</button><button data-key="Shift">Sprint</button><button data-key="LMB">Attack</button><button data-key="RMB">Draw bow</button>
|
| 42 |
+
<button data-wheel="1">Switch weapon</button>
|
| 43 |
+
</div>
|
| 44 |
+
<p id="status" role="status">Connecting to local server…</p>
|
| 45 |
+
<p class="note">Every 200 ms, your input becomes a standard action packet: six 33 ms key windows, each with up to four keys plus mouse movement. The packet goes to the same simulation as <code>make_policy_env</code>. Pausing stops the world. Replays use <code>bossbench/policy-replay@1</code>; import simulates each packet again and checks the final-state hash. Scripted Demo is a reference controller that reads internal state, not a trained model; it does not start RL training.</p>
|
| 46 |
+
</section>
|
| 47 |
+
<aside>
|
| 48 |
+
<div>
|
| 49 |
+
<h2>Select Challenge</h2>
|
| 50 |
+
<label for="case">Boss</label><select id="case"></select>
|
| 51 |
+
<label for="weapon">Starting weapon (two hotbar slots; switch with the mouse wheel)</label>
|
| 52 |
+
<select id="weapon"><option value="sword" selected>Sword</option><option value="bow">Bow</option></select>
|
| 53 |
+
<label for="camera">View</label>
|
| 54 |
+
<select id="camera"><option value="first" selected>First person</option><option value="third">Third person</option></select>
|
| 55 |
+
<label for="difficulty">Difficulty (three public tiers)</label>
|
| 56 |
+
<select id="difficulty"><option value="easy">Easy</option><option value="normal" selected>Normal</option><option value="hard">Hard</option></select>
|
| 57 |
+
<p class="hint" id="tier-hint">Reference script target: about one minute</p>
|
| 58 |
+
<label for="seed">Seed</label><input id="seed" type="number" min="0" max="4294967295" value="1" step="1">
|
| 59 |
+
</div>
|
| 60 |
+
<div class="panel" id="hudpanel">
|
| 61 |
+
<div class="row"><span>Time</span><b id="time">0.0 s</b></div>
|
| 62 |
+
<div class="row"><span>Native rate</span><b id="hz">60 Hz</b></div>
|
| 63 |
+
<div class="row"><span>Difficulty</span><b id="tier">—</b></div>
|
| 64 |
+
<div class="row"><span>Health</span><b id="php">20 / 20</b></div>
|
| 65 |
+
<div class="row"><span>Weapon</span><b id="wpn">Sword</b></div>
|
| 66 |
+
<div class="row"><span>Boss</span><b id="bname">—</b></div>
|
| 67 |
+
<div class="row"><span>Boss Health</span><b id="bhp">—</b></div>
|
| 68 |
+
<div class="row"><span>Phase</span><b id="bphase">—</b></div>
|
| 69 |
+
</div>
|
| 70 |
+
<h2>Controls</h2>
|
| 71 |
+
<dl id="controls">
|
| 72 |
+
<dt>W A S D</dt><dd>Move (one direction at a time; W takes priority)</dd>
|
| 73 |
+
<dt>Mouse</dt><dd>Click the screen to lock the mouse. Move left or right to turn and up or down to pitch the view; there is no aim assist. Arrow keys also turn and pitch.</dd>
|
| 74 |
+
<dt>Space / Shift</dt><dd>Jump / Sprint (while holding W)</dd>
|
| 75 |
+
<dt>left mouse button / J</dt><dd>Sword: each press swings once. Let the cooldown fill before swinging again; a falling attack at full charge deals a 1.5× critical hit. With a bow equipped, this is a punch.</dd>
|
| 76 |
+
<dt>right mouse button / K</dt><dd>Bow: hold to draw and release to fire (one second for a fully charged critical arrow)</dd>
|
| 77 |
+
<dt>Mouse wheel / Q / 1 2</dt><dd>Switch between sword and bow (switching resets the attack cooldown)</dd>
|
| 78 |
+
<dt>Esc / P</dt><dd>Pause; losing window focus pauses automatically</dd>
|
| 79 |
+
</dl>
|
| 80 |
+
</aside>
|
| 81 |
+
</div>
|
| 82 |
+
<footer></footer>
|
| 83 |
+
</main>
|
| 84 |
+
<script src="play.js"></script>
|
| 85 |
+
</body>
|
| 86 |
+
</html>
|
environments/games/web/games/minecraft_remake/manifest.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema": "bossbench/game-manifest@1",
|
| 3 |
+
"engine": "python",
|
| 4 |
+
"game": "minecraft_remake",
|
| 5 |
+
"title": "Minecraft: Voxel Arena",
|
| 6 |
+
"dimension": "3d",
|
| 7 |
+
"native_hz": 60,
|
| 8 |
+
"max_seconds": {
|
| 9 |
+
"3d/minecraft_iron_golem": 300,
|
| 10 |
+
"3d/minecraft_zombie": 90,
|
| 11 |
+
"3d/minecraft_ender_dragon": 300,
|
| 12 |
+
"3d/minecraft_wither": 300,
|
| 13 |
+
"3d/minecraft_warden": 300,
|
| 14 |
+
"3d/minecraft_skeleton": 300,
|
| 15 |
+
"3d/minecraft_zombie_leader": 300
|
| 16 |
+
},
|
| 17 |
+
"renderer": "moderngl",
|
| 18 |
+
"rules": "minecraft-arena@7",
|
| 19 |
+
"tiers": {
|
| 20 |
+
"easy": 0.0,
|
| 21 |
+
"normal": 0.5,
|
| 22 |
+
"hard": 1.0
|
| 23 |
+
},
|
| 24 |
+
"tiers_source": "prototype/bossbench/mc4d.py TIERS (read by bossbench.make_policy_env and the play server)",
|
| 25 |
+
"cases": [
|
| 26 |
+
"3d/minecraft_iron_golem",
|
| 27 |
+
"3d/minecraft_ender_dragon",
|
| 28 |
+
"3d/minecraft_wither",
|
| 29 |
+
"3d/minecraft_warden",
|
| 30 |
+
"3d/minecraft_skeleton",
|
| 31 |
+
"3d/minecraft_zombie_leader"
|
| 32 |
+
],
|
| 33 |
+
"retired_cases": {
|
| 34 |
+
"3d/minecraft_zombie": "2026-11-10 user request: remove the green-skinned grappler. It remains registered in FORMAL_CASES under frozen @4 rules, but is excluded from the benchmark list (scope.BENCH_RETIRED). Its media was moved to archived history."
|
| 35 |
+
},
|
| 36 |
+
"formal_cases": [
|
| 37 |
+
"3d/minecraft_iron_golem",
|
| 38 |
+
"3d/minecraft_zombie",
|
| 39 |
+
"3d/minecraft_ender_dragon",
|
| 40 |
+
"3d/minecraft_wither"
|
| 41 |
+
],
|
| 42 |
+
"formal_note": "FORMAL_CASES (prototype/bossbench/scope.py): their rules stay exactly @4 (difficulty tables, behaviour, arena, kit, time limit, observation layout); d = 0.5 of each was evaluated 16 times in reports/mc-bow-comparison-20261020. 3d/minecraft_zombie stays exactly as in @4 and is reported \"uncalibrated\" against the tier windows (1.4-3.2 s fights); the user decided on 2026-11-04 to keep it at @4 (no re-calibration).",
|
| 43 |
+
"round_20261102_scenes": [
|
| 44 |
+
"3d/minecraft_iron_golem",
|
| 45 |
+
"3d/minecraft_ender_dragon",
|
| 46 |
+
"3d/minecraft_wither"
|
| 47 |
+
],
|
| 48 |
+
"round_20261103_scenes": [
|
| 49 |
+
"3d/minecraft_warden",
|
| 50 |
+
"3d/minecraft_skeleton",
|
| 51 |
+
"3d/minecraft_zombie_leader"
|
| 52 |
+
],
|
| 53 |
+
"kits": {
|
| 54 |
+
"diamond": "diamond sword 7 + full diamond armor 20 / 8 (flung giant, green-skinned grappler, purple-breathing flyer, triple-headed floating cannon, shockwave beast)",
|
| 55 |
+
"iron": "iron sword 6 + full iron armor 15 / 0 (mobile archer, summoner)",
|
| 56 |
+
"source": "prototype/bossbench/mc4d.py KITS / SCENE_KIT (the same on every tier)"
|
| 57 |
+
},
|
| 58 |
+
"options": {
|
| 59 |
+
"weapon": [
|
| 60 |
+
"sword",
|
| 61 |
+
"bow"
|
| 62 |
+
],
|
| 63 |
+
"camera": [
|
| 64 |
+
"first",
|
| 65 |
+
"third"
|
| 66 |
+
]
|
| 67 |
+
},
|
| 68 |
+
"play_page": "web/games/minecraft_remake/index.html",
|
| 69 |
+
"server": "prototype/bossbench/play_server.py",
|
| 70 |
+
"launch": "powershell -NoProfile -ExecutionPolicy Bypass -File web/games/minecraft_remake/run_server.ps1",
|
| 71 |
+
"url": "http://127.0.0.1:8765/",
|
| 72 |
+
"simulation": [
|
| 73 |
+
"prototype/bossbench/mc4d.py",
|
| 74 |
+
"prototype/bossbench/mcskin.py",
|
| 75 |
+
"prototype/bossbench/rig.py"
|
| 76 |
+
],
|
| 77 |
+
"scripted_controller": "bossbench.mc_scripted.scripted(case) -> packet text (prototype/bossbench/mc_scripted.py)",
|
| 78 |
+
"golden": "prototype/tests/mc4d_golden_20261107_arena7.json (rules minecraft-arena@7); frozen guards: mc4d_golden_20261103_arena6.json (@6), mc4d_golden_20261103.json (@5), mc4d_golden_20261102.json (@4), mc4d_golden_20261031.json (@3), mc4d_golden.json (@1, MD5 e778e5d30f6941ab44a91c86da8bd115)"
|
| 79 |
+
}
|
environments/games/web/games/minecraft_remake/play.js
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Minecraft remake play page client: samples real keyboard/mouse input into standard 200 ms packets
|
| 2 |
+
(6 hold sets of <= 4 keys + mouse dx dy dz), sends them to the local Python play server, and plays back the
|
| 3 |
+
6 frames per packet that the real ModernGL renderer returns. The page itself simulates nothing. */
|
| 4 |
+
(function () {
|
| 5 |
+
'use strict';
|
| 6 |
+
const $ = s => document.querySelector(s);
|
| 7 |
+
const KEYS = ['W', 'A', 'S', 'D', 'Space', 'Shift', 'J', 'K', 'L', 'Q', 'E', 'R', 'LMB', 'RMB'];
|
| 8 |
+
const CODE = {KeyW: 'W', KeyA: 'A', KeyS: 'S', KeyD: 'D', Space: 'Space', ShiftLeft: 'Shift', ShiftRight: 'Shift',
|
| 9 |
+
KeyJ: 'J', KeyK: 'RMB'};
|
| 10 |
+
const SUB_MS = 200 / 6;
|
| 11 |
+
const view = $('#view'), capture = $('#capture');
|
| 12 |
+
let API = '', sid = null, meta = null, state = null, running = false, mode = 'idle'; // idle | play | demo | replay
|
| 13 |
+
let down = new Set(), taps = new Set(), mouse = [0, 0, 0], subs = [], timer = null;
|
| 14 |
+
let queue = [], sending = false, clock0 = 0, subsDone = 0;
|
| 15 |
+
let frames = [], lastShown = 0, replayQueue = [], replayExpect = null, pending = false, epoch = 0;
|
| 16 |
+
|
| 17 |
+
function status(text) { $('#status').textContent = text; }
|
| 18 |
+
function overlay(text) {
|
| 19 |
+
$('#overlay').hidden = !text;
|
| 20 |
+
$('#overlay-text').textContent = text || '';
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
// ------------------------------------------------------------------ server connection
|
| 24 |
+
async function api(path, body) {
|
| 25 |
+
const opt = body === undefined ? {} : {method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(body)};
|
| 26 |
+
const r = await fetch(API + path, opt);
|
| 27 |
+
const data = await r.json();
|
| 28 |
+
if (!r.ok) throw Error(data.error || r.statusText);
|
| 29 |
+
return data;
|
| 30 |
+
}
|
| 31 |
+
async function connect() {
|
| 32 |
+
const bases = location.protocol.startsWith('http') && location.port === '8765' ? [''] :
|
| 33 |
+
['', 'http://127.0.0.1:8765'];
|
| 34 |
+
for (const base of bases) {
|
| 35 |
+
try {
|
| 36 |
+
const r = await fetch(base + '/api/meta', {cache: 'no-store'});
|
| 37 |
+
if (!r.ok) continue;
|
| 38 |
+
meta = await r.json();
|
| 39 |
+
API = base;
|
| 40 |
+
$('#offline').hidden = true;
|
| 41 |
+
$('#rules').textContent = meta.rules;
|
| 42 |
+
const sel = $('#case');
|
| 43 |
+
if (!sel.options.length) for (const c of meta.cases) {
|
| 44 |
+
const o = document.createElement('option');
|
| 45 |
+
o.value = c.id; o.textContent = c.name; sel.appendChild(o);
|
| 46 |
+
}
|
| 47 |
+
tierControl();
|
| 48 |
+
$('#hz').textContent = meta.native_hz + ' Hz';
|
| 49 |
+
status('Connected to local server (' + meta.rules + ' · ' + meta.native_hz + ' Hz). Select a boss, then click Start Challenge.');
|
| 50 |
+
overlay('Select a boss to start');
|
| 51 |
+
return true;
|
| 52 |
+
} catch (e) { /* try next */ }
|
| 53 |
+
}
|
| 54 |
+
$('#offline').hidden = false;
|
| 55 |
+
overlay('');
|
| 56 |
+
status('Could not connect. Start the local Python server using the command shown on screen.');
|
| 57 |
+
return false;
|
| 58 |
+
}
|
| 59 |
+
$('#retry').onclick = connect;
|
| 60 |
+
|
| 61 |
+
// ------------------------------------------------------------------ public difficulty: three tiers (2026-11-02)
|
| 62 |
+
// Rebuilt from the server's declaration (mc4d.TIERS via /api/meta), the same source make_policy_env reads, so the
|
| 63 |
+
// page can never offer a difficulty the public interface does not. Each option shows the meeting's target window.
|
| 64 |
+
function tierControl() {
|
| 65 |
+
const sel = $('#difficulty'), keep = sel.value || meta.default_tier;
|
| 66 |
+
if (!meta.tiers || !meta.tiers.length) return;
|
| 67 |
+
sel.textContent = '';
|
| 68 |
+
for (const t of meta.tiers) {
|
| 69 |
+
const o = document.createElement('option');
|
| 70 |
+
o.value = t.name; o.textContent = t.label + '(d=' + t.difficulty + ')';
|
| 71 |
+
o.selected = t.name === keep; sel.appendChild(o);
|
| 72 |
+
}
|
| 73 |
+
tierHint();
|
| 74 |
+
}
|
| 75 |
+
function tierInfo(name) { return meta && meta.tiers ? meta.tiers.find(t => t.name === name) : null; }
|
| 76 |
+
function tierHint() {
|
| 77 |
+
const t = tierInfo($('#difficulty').value);
|
| 78 |
+
$('#tier-hint').textContent = t ? 'Reference script target: ' + t.target_seconds[0] + '–' + t.target_seconds[1] + ' seconds to win' : '';
|
| 79 |
+
}
|
| 80 |
+
$('#difficulty').onchange = tierHint;
|
| 81 |
+
|
| 82 |
+
// ------------------------------------------------------------------ input sampling
|
| 83 |
+
function heldNow() {
|
| 84 |
+
const all = new Set([...down, ...taps]);
|
| 85 |
+
taps.clear();
|
| 86 |
+
const out = [];
|
| 87 |
+
for (const k of ['W', 'S', 'A', 'D']) if (all.has(k)) { out.push(k); break; }
|
| 88 |
+
for (const k of ['Space', 'Shift', 'LMB', 'J', 'RMB']) if (all.has(k) && out.length < 4) out.push(k);
|
| 89 |
+
return out;
|
| 90 |
+
}
|
| 91 |
+
function packetText(sets, m) {
|
| 92 |
+
const mx = m.map((v, i) => Math.max(i === 2 ? -5 : -1000, Math.min(i === 2 ? 5 : 1000, Math.round(v))));
|
| 93 |
+
return '<|action_start|> ' + mx.join(' ') + ' ; ' + sets.map(s => s.join(',')).join(' ; ') + ' <|action_end|>';
|
| 94 |
+
}
|
| 95 |
+
function takePacket() {
|
| 96 |
+
while (subs.length < 6) subs.push(heldNow());
|
| 97 |
+
const p = packetText(subs, mouse);
|
| 98 |
+
subs = []; mouse = [0, 0, 0];
|
| 99 |
+
return p;
|
| 100 |
+
}
|
| 101 |
+
// Wall-clock scheduler: one hold set per 33.3 ms of real time, whatever the timer jitter, so the world runs at
|
| 102 |
+
// real speed; packets go out in order, one request at a time (a lagging server gets up to 5 per request).
|
| 103 |
+
function sampleClock() {
|
| 104 |
+
if (!running || mode !== 'play') return;
|
| 105 |
+
const due = Math.floor((performance.now() - clock0) / SUB_MS);
|
| 106 |
+
if (due - subsDone > 18) subsDone = due - 6; // tab stalled: drop the backlog instead of a burst
|
| 107 |
+
while (subsDone < due) {
|
| 108 |
+
if (arrows.has('ArrowLeft')) mouse[0] -= 7;
|
| 109 |
+
if (arrows.has('ArrowRight')) mouse[0] += 7;
|
| 110 |
+
if (arrows.has('ArrowUp')) mouse[1] -= 4;
|
| 111 |
+
if (arrows.has('ArrowDown')) mouse[1] += 4;
|
| 112 |
+
subs.push(heldNow());
|
| 113 |
+
subsDone++;
|
| 114 |
+
if (subs.length >= 6) queue.push(takePacket());
|
| 115 |
+
}
|
| 116 |
+
pump();
|
| 117 |
+
}
|
| 118 |
+
async function pump() {
|
| 119 |
+
if (sending || !queue.length || !sid) return;
|
| 120 |
+
sending = true;
|
| 121 |
+
const batch = queue.splice(0, 5), my = epoch;
|
| 122 |
+
try {
|
| 123 |
+
const r = await api('/api/step', {sid, packets: batch, frames: true});
|
| 124 |
+
if (my === epoch) accept(r);
|
| 125 |
+
} catch (e) { status('Server error: ' + e.message); pause(); }
|
| 126 |
+
finally { sending = false; if (queue.length && my === epoch) pump(); }
|
| 127 |
+
}
|
| 128 |
+
function lock() {
|
| 129 |
+
try { const p = capture.requestPointerLock && capture.requestPointerLock(); if (p && p.catch) p.catch(() => {}); } catch (e) { /* headless */ }
|
| 130 |
+
}
|
| 131 |
+
document.addEventListener('pointerlockchange', () => {
|
| 132 |
+
if (document.pointerLockElement !== capture && running && mode === 'play') {
|
| 133 |
+
pause(); status('Mouse unlocked (Esc) · Paused. Click Resume to continue.');
|
| 134 |
+
}
|
| 135 |
+
});
|
| 136 |
+
const arrows = new Set();
|
| 137 |
+
window.addEventListener('keydown', e => {
|
| 138 |
+
if (['INPUT', 'SELECT', 'TEXTAREA'].includes(document.activeElement.tagName)) return;
|
| 139 |
+
if (e.code === 'Escape' || e.code === 'KeyP') { if (running) pause(); return; }
|
| 140 |
+
if (e.code.startsWith('Arrow')) { arrows.add(e.code); e.preventDefault(); return; }
|
| 141 |
+
if (e.code === 'KeyQ' || e.code === 'Digit1' || e.code === 'Digit2') {
|
| 142 |
+
const want = e.code === 'Digit1' ? 'sword' : e.code === 'Digit2' ? 'bow' : null;
|
| 143 |
+
if (!want || (state && state.player.weapon !== want)) mouse[2] += 1;
|
| 144 |
+
e.preventDefault(); return;
|
| 145 |
+
}
|
| 146 |
+
const k = CODE[e.code];
|
| 147 |
+
if (k) { e.preventDefault(); down.add(k); taps.add(k); }
|
| 148 |
+
});
|
| 149 |
+
window.addEventListener('keyup', e => {
|
| 150 |
+
if (e.code.startsWith('Arrow')) arrows.delete(e.code);
|
| 151 |
+
const k = CODE[e.code];
|
| 152 |
+
if (k) down.delete(k);
|
| 153 |
+
});
|
| 154 |
+
capture.addEventListener('contextmenu', e => e.preventDefault());
|
| 155 |
+
capture.addEventListener('pointerdown', e => {
|
| 156 |
+
capture.focus();
|
| 157 |
+
if (running && mode === 'play' && document.pointerLockElement !== capture) lock();
|
| 158 |
+
const k = e.button === 2 ? 'RMB' : e.button === 0 ? 'LMB' : null;
|
| 159 |
+
if (k) { down.add(k); taps.add(k); }
|
| 160 |
+
e.preventDefault();
|
| 161 |
+
});
|
| 162 |
+
window.addEventListener('pointerup', e => { down.delete(e.button === 2 ? 'RMB' : 'LMB'); });
|
| 163 |
+
window.addEventListener('mousemove', e => {
|
| 164 |
+
if (document.pointerLockElement === capture) { mouse[0] += e.movementX; mouse[1] += e.movementY; }
|
| 165 |
+
else if (e.buttons && e.target === capture) { mouse[0] += e.movementX; mouse[1] += e.movementY; }
|
| 166 |
+
});
|
| 167 |
+
capture.addEventListener('wheel', e => { e.preventDefault(); mouse[2] += e.deltaY > 0 ? 1 : -1; }, {passive: false});
|
| 168 |
+
document.querySelectorAll('[data-key]').forEach(b => {
|
| 169 |
+
b.onpointerdown = e => { e.preventDefault(); b.setPointerCapture(e.pointerId); down.add(b.dataset.key); taps.add(b.dataset.key); };
|
| 170 |
+
b.onpointerup = b.onpointercancel = () => down.delete(b.dataset.key);
|
| 171 |
+
});
|
| 172 |
+
document.querySelectorAll('[data-wheel]').forEach(b => { b.onclick = () => { mouse[2] += 1; }; });
|
| 173 |
+
function releaseAll() { down.clear(); taps.clear(); arrows.clear(); }
|
| 174 |
+
window.addEventListener('blur', () => { releaseAll(); if (running && mode === 'play') { pause(); status('Window lost focus · Paused. Click Resume to continue.'); } });
|
| 175 |
+
document.addEventListener('visibilitychange', () => { if (document.hidden) { releaseAll(); if (running) pause(); } });
|
| 176 |
+
|
| 177 |
+
// ------------------------------------------------------------------ stepping and frames
|
| 178 |
+
function accept(r) {
|
| 179 |
+
state = r.state || r;
|
| 180 |
+
if (r.frames && r.frames.length) {
|
| 181 |
+
if (frames.length > 12) frames = frames.slice(-6); // keep latency bounded
|
| 182 |
+
frames.push(...r.frames);
|
| 183 |
+
}
|
| 184 |
+
panel();
|
| 185 |
+
if (state.outcome) finish();
|
| 186 |
+
}
|
| 187 |
+
function showFrames(now) {
|
| 188 |
+
if (frames.length && now - lastShown >= SUB_MS - 2) {
|
| 189 |
+
view.src = frames.shift();
|
| 190 |
+
lastShown = now;
|
| 191 |
+
}
|
| 192 |
+
requestAnimationFrame(showFrames);
|
| 193 |
+
}
|
| 194 |
+
requestAnimationFrame(showFrames);
|
| 195 |
+
async function still() {
|
| 196 |
+
if (!sid) return;
|
| 197 |
+
const r = await api('/api/still', {sid});
|
| 198 |
+
frames = [r.frame];
|
| 199 |
+
state = r.state; panel();
|
| 200 |
+
}
|
| 201 |
+
function panel() {
|
| 202 |
+
if (!state) return;
|
| 203 |
+
const p = state.player, b = state.boss;
|
| 204 |
+
$('#time').textContent = state.t.toFixed(1) + ' / ' + state.max_seconds + ' s';
|
| 205 |
+
const o = state.options || {}, tier = tierInfo(o.resolved_from_tier);
|
| 206 |
+
$('#tier').textContent = tier ? tier.label + ' · d=' + o.difficulty : 'd=' + o.difficulty;
|
| 207 |
+
$('#php').textContent = p.hp.toFixed(1) + ' / ' + p.max_hp + (p.wither_effect_s > 0 ? ' (Wither damage for ' + p.wither_effect_s.toFixed(0) + 's)' : '');
|
| 208 |
+
$('#wpn').textContent = (p.kit === 'iron' ? 'Iron ' : 'Diamond ') + (p.weapon === 'sword' ? 'sword ' + Math.round(p.attack_charge * 100) + '%' :
|
| 209 |
+
'Bow ' + (p.bow_drawing ? Math.round(p.bow_charge * 100) + '%' : 'ready') + ' · Hits ' + p.arrows_hit + '/' + p.arrows_fired);
|
| 210 |
+
$('#bname').textContent = b.name;
|
| 211 |
+
$('#bhp').textContent = b.hp.toFixed(1) + ' / ' + b.max_hp;
|
| 212 |
+
$('#bphase').textContent = b.phase + (b.armored ? ' · Half-health armor' : '') + (b.crystals !== null ? ' · Crystals ' + b.crystals : '') +
|
| 213 |
+
(b.minions !== null && b.minions !== undefined ? ' · Minions ' + b.minions : '') +
|
| 214 |
+
(b.darkness_s ? ' · Darkness ' + b.darkness_s.toFixed(0) + 's' : '');
|
| 215 |
+
}
|
| 216 |
+
function finish() {
|
| 217 |
+
stopLoop();
|
| 218 |
+
// Show the terminal frame at once: frames play back ~0.2 s behind the simulation, so the result overlay would
|
| 219 |
+
// otherwise sit on a frame where the boss still has health left.
|
| 220 |
+
if (frames.length) { view.src = frames[frames.length - 1]; frames = []; }
|
| 221 |
+
window.__bbOutcome = state.outcome; // read by web/tools/bench_media.py ui
|
| 222 |
+
const label = {win: 'Victory', loss: 'Failure', timeout: 'Time up'}[state.outcome] || state.outcome;
|
| 223 |
+
overlay(label + ' · ' + state.t.toFixed(2) + ' seconds');
|
| 224 |
+
if (mode === 'replay' && replayExpect) verifyReplay();
|
| 225 |
+
else status('Match over: ' + label + ' · ' + state.packets + ' action packets. You can export the replay.');
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
// ------------------------------------------------------------------ loop control
|
| 229 |
+
function stopLoop() { running = false; clearInterval(timer); timer = null; $('#pause').textContent = 'Resume'; }
|
| 230 |
+
function startLoop() {
|
| 231 |
+
if (!sid || (state && state.outcome)) return;
|
| 232 |
+
running = true; $('#pause').textContent = 'Pause'; overlay('');
|
| 233 |
+
clearInterval(timer);
|
| 234 |
+
if (mode === 'play') { subs = []; mouse = [0, 0, 0]; clock0 = performance.now(); subsDone = 0; timer = setInterval(sampleClock, 8); }
|
| 235 |
+
else timer = setInterval(tickAuto, 200);
|
| 236 |
+
}
|
| 237 |
+
function pause() { stopLoop(); releaseAll(); if (document.pointerLockElement) document.exitPointerLock(); overlay(state && state.outcome ? $('#overlay-text').textContent : 'Paused'); }
|
| 238 |
+
async function tickAuto() {
|
| 239 |
+
if (pending || !running) return;
|
| 240 |
+
pending = true;
|
| 241 |
+
const my = epoch;
|
| 242 |
+
try {
|
| 243 |
+
if (mode === 'demo') {
|
| 244 |
+
const r = await api('/api/scripted', {sid, n: 1, frames: true});
|
| 245 |
+
if (my === epoch) accept(r);
|
| 246 |
+
} else if (mode === 'replay') {
|
| 247 |
+
if (!replayQueue.length) { if (state && !state.outcome) { stopLoop(); verifyReplay(); } }
|
| 248 |
+
else { const r = await api('/api/step', {sid, packets: [replayQueue.shift()], frames: true}); if (my === epoch) accept(r); }
|
| 249 |
+
}
|
| 250 |
+
} catch (e) { status('Server error: ' + e.message); stopLoop(); }
|
| 251 |
+
finally { pending = false; }
|
| 252 |
+
}
|
| 253 |
+
async function newSession(caseId, useMode, tier) {
|
| 254 |
+
if (!meta && !(await connect())) return false;
|
| 255 |
+
epoch++; stopLoop(); frames = []; replayQueue = []; replayExpect = null; queue = []; window.__bbOutcome = null;
|
| 256 |
+
if (sid) api('/api/close', {sid}).catch(() => {});
|
| 257 |
+
const body = {case: caseId || $('#case').value, seed: Number($('#seed').value), tier: tier || $('#difficulty').value,
|
| 258 |
+
weapon: $('#weapon').value, camera: $('#camera').value};
|
| 259 |
+
$('#case').value = body.case;
|
| 260 |
+
$('#difficulty').value = body.tier; tierHint();
|
| 261 |
+
const r = await api('/api/new', body);
|
| 262 |
+
sid = r.sid; state = r.state; mode = useMode; panel();
|
| 263 |
+
await still();
|
| 264 |
+
return true;
|
| 265 |
+
}
|
| 266 |
+
$('#start').onclick = async () => {
|
| 267 |
+
try {
|
| 268 |
+
if (!(await newSession(null, 'play'))) return;
|
| 269 |
+
status('Match in progress: click the screen to lock the mouse (Esc unlocks and pauses). One action packet every 200 ms.');
|
| 270 |
+
capture.focus(); startLoop();
|
| 271 |
+
} catch (e) { status('Unable to start: ' + e.message); }
|
| 272 |
+
};
|
| 273 |
+
$('#pause').onclick = () => {
|
| 274 |
+
if (running) pause();
|
| 275 |
+
else if (sid && state && !state.outcome) { startLoop(); capture.focus(); if (mode === 'play') lock(); }
|
| 276 |
+
};
|
| 277 |
+
$('#step').onclick = async () => {
|
| 278 |
+
if (!sid || (state && state.outcome)) return;
|
| 279 |
+
if (running) pause();
|
| 280 |
+
overlay('Step');
|
| 281 |
+
const sets = Array.from({length: 6}, () => heldNow());
|
| 282 |
+
if (mode === 'demo') { accept(await api('/api/scripted', {sid, n: 1, frames: true})); }
|
| 283 |
+
else if (mode === 'replay') { if (replayQueue.length) accept(await api('/api/step', {sid, packets: [replayQueue.shift()], frames: true})); }
|
| 284 |
+
else { const p = packetText(sets, mouse); mouse = [0, 0, 0]; accept(await api('/api/step', {sid, packets: [p], frames: true})); }
|
| 285 |
+
};
|
| 286 |
+
async function demo(caseId, tier) {
|
| 287 |
+
if (!(await newSession(caseId, 'demo', tier))) return false;
|
| 288 |
+
status('Scripted Demo: a reference controller reads internal state and emits valid 200 ms action packets.');
|
| 289 |
+
startLoop();
|
| 290 |
+
return true;
|
| 291 |
+
}
|
| 292 |
+
$('#demo').onclick = () => demo(null).catch(e => status('Demo failed: ' + e.message));
|
| 293 |
+
$('#export').onclick = async () => {
|
| 294 |
+
if (!sid) { status('No match is available to export yet.'); return; }
|
| 295 |
+
const data = await api('/api/replay?sid=' + sid);
|
| 296 |
+
const blob = new Blob([JSON.stringify(data, null, 1)], {type: 'application/json'});
|
| 297 |
+
const a = document.createElement('a');
|
| 298 |
+
a.href = URL.createObjectURL(blob);
|
| 299 |
+
a.download = data.case_id.replace('/', '__') + '-seed' + data.engine_seed + '.replay.json';
|
| 300 |
+
a.click(); setTimeout(() => URL.revokeObjectURL(a.href), 1000);
|
| 301 |
+
status('Exported ' + data.steps + ' action packets (' + data.rules + ') · Final-state hash: ' + data.final_hash.slice(0, 12));
|
| 302 |
+
};
|
| 303 |
+
$('#import').onclick = () => $('#file').click();
|
| 304 |
+
$('#file').onchange = async e => {
|
| 305 |
+
const file = e.target.files[0]; e.target.value = '';
|
| 306 |
+
if (!file) return;
|
| 307 |
+
try {
|
| 308 |
+
if (file.size > 12e6) throw Error('Replay must be 12 MB or smaller');
|
| 309 |
+
await importReplay(JSON.parse(await file.text()));
|
| 310 |
+
} catch (err) { status('Import failed: ' + err.message); }
|
| 311 |
+
};
|
| 312 |
+
async function importReplay(data) {
|
| 313 |
+
if (!meta && !(await connect())) return;
|
| 314 |
+
epoch++; stopLoop(); frames = [];
|
| 315 |
+
const r = await api('/api/import', {replay: data});
|
| 316 |
+
if (sid) api('/api/close', {sid}).catch(() => {});
|
| 317 |
+
sid = r.sid; state = r.state; mode = 'replay'; panel();
|
| 318 |
+
replayQueue = data.packets.slice(); replayExpect = r.expect;
|
| 319 |
+
$('#case').value = data.case_id;
|
| 320 |
+
await still();
|
| 321 |
+
status('Replay rules verified (' + data.rules + ') · Playing back ' + replayQueue.length + ' action packets…');
|
| 322 |
+
startLoop();
|
| 323 |
+
}
|
| 324 |
+
async function verifyReplay() {
|
| 325 |
+
const v = await api('/api/verify', {sid});
|
| 326 |
+
const ok = v.final_hash === replayExpect.final_hash && v.outcome === replayExpect.outcome && v.ticks === replayExpect.ticks;
|
| 327 |
+
status('Replay finished: ' + ({win: 'Victory', loss: 'Failure', timeout: 'Time up'}[v.outcome] || 'Replay ended before the match concluded') + ' · ' + v.ticks + ' ticks · ' + (ok ? 'Final-state hash matches ✓' : 'Final state differs from replay ✗ (' + v.final_hash.slice(0, 10) + ' vs ' + String(replayExpect.final_hash).slice(0, 10) + ')'));
|
| 328 |
+
replayExpect = null;
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
// ------------------------------------------------------------------ harness hook (web/tools/bench_media.py ui)
|
| 332 |
+
window.bossbenchUI = {
|
| 333 |
+
demo: (caseId, tier) => demo(caseId, tier),
|
| 334 |
+
start: (caseId, tier) => newSession(caseId, 'play', tier).then(() => { startLoop(); return true; }),
|
| 335 |
+
state: () => state, connected: () => !!meta,
|
| 336 |
+
};
|
| 337 |
+
connect();
|
| 338 |
+
})();
|
environments/games/web/games/minecraft_remake/style.css
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
:root{color-scheme:dark;--paper:#ece6d6;--muted:#a7b3a2;--accent:#8fd16a;--bg:#1b1f17;--panel:#262c21;--edge:#4a5940;--warn:#e7b35d}
|
| 2 |
+
*{box-sizing:border-box}
|
| 3 |
+
body{margin:0;background:var(--bg) radial-gradient(circle at 20% -10%,#2f3a26 0,transparent 55%);color:var(--paper);font:15px/1.6 'Segoe UI','Microsoft YaHei',sans-serif}
|
| 4 |
+
main{max-width:1180px;margin:auto;padding:24px 24px 40px}
|
| 5 |
+
header{display:flex;gap:24px;align-items:baseline;justify-content:space-between;margin-bottom:18px}
|
| 6 |
+
h1{font-family:Georgia,'Microsoft YaHei',serif;font-size:29px;font-weight:600;line-height:1.3;margin:6px 0;letter-spacing:.5px}
|
| 7 |
+
header p{margin:0;color:var(--muted);font-size:13px}
|
| 8 |
+
code{font-family:Consolas,monospace;font-size:12px;color:var(--accent)}
|
| 9 |
+
a{color:var(--accent)}
|
| 10 |
+
a:focus-visible,button:focus-visible,input:focus-visible,select:focus-visible,#capture:focus-visible{outline:3px solid var(--accent);outline-offset:3px}
|
| 11 |
+
.layout{display:grid;grid-template-columns:minmax(0,854px) 240px;gap:20px}
|
| 12 |
+
.stage{position:relative;align-self:start;border:2px solid #10130d;box-shadow:0 0 0 1px var(--edge);background:#0b0d09;aspect-ratio:854/480}
|
| 13 |
+
#view{display:block;width:100%;height:100%;image-rendering:pixelated;user-select:none}
|
| 14 |
+
#capture{position:absolute;inset:0;cursor:crosshair;touch-action:none}
|
| 15 |
+
#overlay{pointer-events:none;position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:#0d110a55}
|
| 16 |
+
#overlay[hidden]{display:none}
|
| 17 |
+
#overlay div{padding:12px 25px;background:#141a10ee;text-align:center;border:2px solid var(--edge);font-size:22px;font-family:Georgia,'Microsoft YaHei',serif}
|
| 18 |
+
#offline{position:absolute;inset:0;display:flex;flex-direction:column;justify-content:center;padding:28px 40px;background:#12160fef;font-size:14px}
|
| 19 |
+
#offline[hidden]{display:none}
|
| 20 |
+
#offline h2{margin:0 0 8px;font-size:20px;color:var(--warn)}
|
| 21 |
+
#offline pre{white-space:pre-wrap;background:#0a0c08;border:1px solid var(--edge);padding:10px 12px;font:13px Consolas,monospace;color:#d8f0c4}
|
| 22 |
+
.toolbar{display:flex;flex-wrap:wrap;gap:9px;padding:12px;background:var(--panel);border:1px solid var(--edge);border-top:0}
|
| 23 |
+
button,select,input{font:inherit;border:1px solid var(--edge);border-radius:2px;background:#30382a;color:var(--paper);padding:7px 10px}
|
| 24 |
+
button{cursor:pointer;box-shadow:inset 0 -3px 0 #1d2318}
|
| 25 |
+
button:hover{border-color:var(--accent)}
|
| 26 |
+
button.primary{background:#5d8f3c;color:#0f140b;font-weight:700;box-shadow:inset 0 -3px 0 #3d6524}
|
| 27 |
+
select,input[type=number]{width:100%}
|
| 28 |
+
aside label{display:block;margin:12px 0 5px;color:var(--muted);font-size:13px}
|
| 29 |
+
.hint{margin:5px 0 0;color:var(--muted);font-size:12px}
|
| 30 |
+
aside h2{font-size:17px;margin:18px 0 10px}
|
| 31 |
+
aside>div:first-child h2{margin-top:0}
|
| 32 |
+
.panel{margin-top:16px;padding:10px 12px;background:var(--panel);border:1px solid var(--edge)}
|
| 33 |
+
.row{display:flex;justify-content:space-between;gap:10px;font-size:13px;color:var(--muted)}
|
| 34 |
+
.row b{color:var(--paper);font-weight:600;text-align:right}
|
| 35 |
+
dl{margin:8px 0}
|
| 36 |
+
dt{color:var(--accent);font-family:Consolas,monospace;font-size:12px}
|
| 37 |
+
dd{margin:0 0 10px;font-size:13px;color:var(--muted)}
|
| 38 |
+
#status{min-height:28px;margin:10px 0;color:var(--warn);font-size:13px;overflow-wrap:anywhere}
|
| 39 |
+
.note{color:var(--muted);font-size:13px}
|
| 40 |
+
.mobile{display:none;gap:6px;flex-wrap:wrap;padding:10px;background:var(--panel);border:1px solid var(--edge);border-top:0}
|
| 41 |
+
.mobile button{flex:1 1 22%;padding:12px 4px}
|
| 42 |
+
footer{border-top:1px solid var(--edge);margin-top:25px;padding-top:14px;display:flex;gap:18px;flex-wrap:wrap;font-size:13px}
|
| 43 |
+
@media (max-width:900px){.layout{grid-template-columns:1fr}main{padding:14px}header{flex-direction:column;gap:6px}.mobile{display:flex}}
|
| 44 |
+
@media (pointer:coarse){.mobile{display:flex}}
|
environments/games/web/games/nfsmw_remake/compact_actions.json
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema": "bossbench/compact-actions@1",
|
| 3 |
+
"game": "nfsmw_remake",
|
| 4 |
+
"version": "nfsmw-compact@1",
|
| 5 |
+
"note": "Four heads, 4 x 13 x 2 x 6 = 624 actions, each held for one 200 ms packet (6 sub-steps of 2 native ticks). No mouse: this game reads none. Pedal and steering are duty cycles over the 6 sub-steps because the car model integrates them: the wheel slews towards the key held and back to centre at the same rate (nfscore.js carStep), so a steering key held for 3 of 6 sub-steps keeps the current angle, 4 or 6 winds it on, 2 lets it come back slowly, none returns it to centre. Options chosen from the reference controller (harness/duty_stats.js: 16001 packets, all six events x three tiers x seeds 1-2) and tested by projecting every reference packet onto this set (harness/compact_sim.js, the same projection as compact.py): versions with 11 steering options lost speed-trap hard 4->2 and the final normal 3->2; the 2/6 ease options brought them back.",
|
| 6 |
+
"heads": [
|
| 7 |
+
{
|
| 8 |
+
"name": "pedal",
|
| 9 |
+
"options": [
|
| 10 |
+
{
|
| 11 |
+
"label": "none"
|
| 12 |
+
},
|
| 13 |
+
{
|
| 14 |
+
"label": "throttle_light",
|
| 15 |
+
"note": "the reference's corner exit: drive force limited by the friction circle",
|
| 16 |
+
"subs": [
|
| 17 |
+
[],
|
| 18 |
+
[],
|
| 19 |
+
[],
|
| 20 |
+
[],
|
| 21 |
+
[],
|
| 22 |
+
[
|
| 23 |
+
"W"
|
| 24 |
+
]
|
| 25 |
+
]
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
"label": "throttle",
|
| 29 |
+
"keys": [
|
| 30 |
+
"W"
|
| 31 |
+
]
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"label": "brake",
|
| 35 |
+
"keys": [
|
| 36 |
+
"S"
|
| 37 |
+
]
|
| 38 |
+
}
|
| 39 |
+
],
|
| 40 |
+
"note": "full throttle 65% of the reference packets, brake 16%, one sub-step in six 11% (corner exits, where the friction circle leaves little drive). A half throttle option was tried and dropped: it changed no result (v6 vs v7)."
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"name": "steer",
|
| 44 |
+
"options": [
|
| 45 |
+
{
|
| 46 |
+
"label": "none"
|
| 47 |
+
},
|
| 48 |
+
{
|
| 49 |
+
"label": "left_tap",
|
| 50 |
+
"note": "drag series: A and D are lane changes on a press (modes_drag.js input), so one press per packet",
|
| 51 |
+
"tap": [
|
| 52 |
+
"A"
|
| 53 |
+
]
|
| 54 |
+
},
|
| 55 |
+
{
|
| 56 |
+
"label": "left_ease",
|
| 57 |
+
"subs": [
|
| 58 |
+
[],
|
| 59 |
+
[],
|
| 60 |
+
[
|
| 61 |
+
"A"
|
| 62 |
+
],
|
| 63 |
+
[],
|
| 64 |
+
[
|
| 65 |
+
"A"
|
| 66 |
+
],
|
| 67 |
+
[]
|
| 68 |
+
]
|
| 69 |
+
},
|
| 70 |
+
{
|
| 71 |
+
"label": "left_hold",
|
| 72 |
+
"subs": [
|
| 73 |
+
[
|
| 74 |
+
"A"
|
| 75 |
+
],
|
| 76 |
+
[],
|
| 77 |
+
[
|
| 78 |
+
"A"
|
| 79 |
+
],
|
| 80 |
+
[],
|
| 81 |
+
[
|
| 82 |
+
"A"
|
| 83 |
+
],
|
| 84 |
+
[]
|
| 85 |
+
]
|
| 86 |
+
},
|
| 87 |
+
{
|
| 88 |
+
"label": "left_hold_late",
|
| 89 |
+
"subs": [
|
| 90 |
+
[],
|
| 91 |
+
[
|
| 92 |
+
"A"
|
| 93 |
+
],
|
| 94 |
+
[],
|
| 95 |
+
[
|
| 96 |
+
"A"
|
| 97 |
+
],
|
| 98 |
+
[],
|
| 99 |
+
[
|
| 100 |
+
"A"
|
| 101 |
+
]
|
| 102 |
+
]
|
| 103 |
+
},
|
| 104 |
+
{
|
| 105 |
+
"label": "left_more",
|
| 106 |
+
"subs": [
|
| 107 |
+
[
|
| 108 |
+
"A"
|
| 109 |
+
],
|
| 110 |
+
[
|
| 111 |
+
"A"
|
| 112 |
+
],
|
| 113 |
+
[],
|
| 114 |
+
[
|
| 115 |
+
"A"
|
| 116 |
+
],
|
| 117 |
+
[],
|
| 118 |
+
[
|
| 119 |
+
"A"
|
| 120 |
+
]
|
| 121 |
+
]
|
| 122 |
+
},
|
| 123 |
+
{
|
| 124 |
+
"label": "left_full",
|
| 125 |
+
"keys": [
|
| 126 |
+
"A"
|
| 127 |
+
]
|
| 128 |
+
},
|
| 129 |
+
{
|
| 130 |
+
"label": "right_tap",
|
| 131 |
+
"tap": [
|
| 132 |
+
"D"
|
| 133 |
+
]
|
| 134 |
+
},
|
| 135 |
+
{
|
| 136 |
+
"label": "right_ease",
|
| 137 |
+
"subs": [
|
| 138 |
+
[],
|
| 139 |
+
[],
|
| 140 |
+
[
|
| 141 |
+
"D"
|
| 142 |
+
],
|
| 143 |
+
[],
|
| 144 |
+
[
|
| 145 |
+
"D"
|
| 146 |
+
],
|
| 147 |
+
[]
|
| 148 |
+
]
|
| 149 |
+
},
|
| 150 |
+
{
|
| 151 |
+
"label": "right_hold",
|
| 152 |
+
"subs": [
|
| 153 |
+
[
|
| 154 |
+
"D"
|
| 155 |
+
],
|
| 156 |
+
[],
|
| 157 |
+
[
|
| 158 |
+
"D"
|
| 159 |
+
],
|
| 160 |
+
[],
|
| 161 |
+
[
|
| 162 |
+
"D"
|
| 163 |
+
],
|
| 164 |
+
[]
|
| 165 |
+
]
|
| 166 |
+
},
|
| 167 |
+
{
|
| 168 |
+
"label": "right_hold_late",
|
| 169 |
+
"subs": [
|
| 170 |
+
[],
|
| 171 |
+
[
|
| 172 |
+
"D"
|
| 173 |
+
],
|
| 174 |
+
[],
|
| 175 |
+
[
|
| 176 |
+
"D"
|
| 177 |
+
],
|
| 178 |
+
[],
|
| 179 |
+
[
|
| 180 |
+
"D"
|
| 181 |
+
]
|
| 182 |
+
]
|
| 183 |
+
},
|
| 184 |
+
{
|
| 185 |
+
"label": "right_more",
|
| 186 |
+
"subs": [
|
| 187 |
+
[
|
| 188 |
+
"D"
|
| 189 |
+
],
|
| 190 |
+
[
|
| 191 |
+
"D"
|
| 192 |
+
],
|
| 193 |
+
[],
|
| 194 |
+
[
|
| 195 |
+
"D"
|
| 196 |
+
],
|
| 197 |
+
[],
|
| 198 |
+
[
|
| 199 |
+
"D"
|
| 200 |
+
]
|
| 201 |
+
]
|
| 202 |
+
},
|
| 203 |
+
{
|
| 204 |
+
"label": "right_full",
|
| 205 |
+
"keys": [
|
| 206 |
+
"D"
|
| 207 |
+
]
|
| 208 |
+
}
|
| 209 |
+
],
|
| 210 |
+
"note": "left_tap / right_tap: one press per packet, the lane change of the drag series (modes_drag.js reads pressed A / D there). The duty options steer everywhere else."
|
| 211 |
+
},
|
| 212 |
+
{
|
| 213 |
+
"name": "nitrous",
|
| 214 |
+
"options": [
|
| 215 |
+
{
|
| 216 |
+
"label": "none"
|
| 217 |
+
},
|
| 218 |
+
{
|
| 219 |
+
"label": "nitrous",
|
| 220 |
+
"note": "only burns while the throttle is down (nfscore.js carStep)",
|
| 221 |
+
"keys": [
|
| 222 |
+
"Shift"
|
| 223 |
+
]
|
| 224 |
+
}
|
| 225 |
+
],
|
| 226 |
+
"note": "only burns while the throttle is down (nfscore.js carStep: engaged needs thr > 0)"
|
| 227 |
+
},
|
| 228 |
+
{
|
| 229 |
+
"name": "press",
|
| 230 |
+
"note": "J (slow motion), K / L (gears, drag series only) and R (reset) act on a press (pressed.has in game.js), so each is one press at the start of the packet. The handbrake is held, and it shares this head because a handbrake turn and a gear change or a reset are never wanted in the same 200 ms.",
|
| 231 |
+
"options": [
|
| 232 |
+
{
|
| 233 |
+
"label": "none"
|
| 234 |
+
},
|
| 235 |
+
{
|
| 236 |
+
"label": "shift_up",
|
| 237 |
+
"tap": [
|
| 238 |
+
"K"
|
| 239 |
+
]
|
| 240 |
+
},
|
| 241 |
+
{
|
| 242 |
+
"label": "shift_down",
|
| 243 |
+
"tap": [
|
| 244 |
+
"L"
|
| 245 |
+
]
|
| 246 |
+
},
|
| 247 |
+
{
|
| 248 |
+
"label": "slowmo",
|
| 249 |
+
"tap": [
|
| 250 |
+
"J"
|
| 251 |
+
]
|
| 252 |
+
},
|
| 253 |
+
{
|
| 254 |
+
"label": "reset",
|
| 255 |
+
"tap": [
|
| 256 |
+
"R"
|
| 257 |
+
]
|
| 258 |
+
},
|
| 259 |
+
{
|
| 260 |
+
"label": "handbrake",
|
| 261 |
+
"note": "held, not a press: carStep reads it every tick. The reference controller never uses it; kept because it is a basic control of the event. It shares this head with the single presses because a handbrake turn and a gear change or a reset are never wanted in the same 200 ms",
|
| 262 |
+
"keys": [
|
| 263 |
+
"Space"
|
| 264 |
+
]
|
| 265 |
+
}
|
| 266 |
+
]
|
| 267 |
+
}
|
| 268 |
+
]
|
| 269 |
+
}
|
environments/games/web/games/nfsmw_remake/cops.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Police. Rules read from AI/Common/AIPursuit.cpp unless noted (all values in the VLT pursuitlevels table are approximations, by tier):
|
| 2 |
+
- busted meter: :1887-1940, up while a cop sees the player, the player is under BustSpeed and the nearest cop is within 15 m, down twice
|
| 3 |
+
as fast otherwise, busted above 5 (kBustedTimeout, kBustedCopDistance :1607-8; Sim/Common/Simulation.cpp:345 for the task rates);
|
| 4 |
+
- during a manual-reset flash the distance is x6 and the rate x4 (:1895-1909);
|
| 5 |
+
- sight: 150 m ahead of the cop, 50 m behind it, and the world ray must be clear (AIVehicleCopCar.cpp:88-168), helicopter 250 m (AIVehicleHelicopter.cpp:114);
|
| 6 |
+
- evade: more than 7 s unseen, then (unseen + hidden time) / evadetimeout reaches 1 (:2027-2061); seen again, it decays x0.93 per task (:2097);
|
| 7 |
+
- roadblocks: a request every 8-12 s with a probability (:2459-2507); a roadblock's cops join the chase after a spike hit (SpikesHit :2791);
|
| 8 |
+
- formations: FOLLOW, ROLLING_BLOCK, BOX_IN, PIT (:976-1010), cops within 60 m qualify (kFormationCandidateDistance :1221);
|
| 9 |
+
- spikes: a tyre over the strip punctures and blows 0.5 s later (DamageRacer.cpp:12), grip x0.3 (SuspensionRacer.cpp:1569);
|
| 10 |
+
- destroying cops: bonus multiplier up to 3 inside DestroyCopBonusTime (IncNumCopsDestroyed :917).
|
| 11 |
+
A cop is a free body, not on rails: with sight it drives straight at its slot (sight means the straight line is clear), without sight it follows
|
| 12 |
+
the route towards where the player was last seen. All decisions draw from the game RNG, and the controller never copies the game. */
|
| 13 |
+
(function (root) {
|
| 14 |
+
'use strict';
|
| 15 |
+
const M = root.NfsmwGame, C = M.C, N = root.NativeBench, clamp = C.clamp, P = C.PLAYER;
|
| 16 |
+
const BUST_MAX = 5, BUST_DIST = 15, FRONT_LOS = 150, REAR_LOS = 50, HELI_LOS = 250, EVADE_AFTER = 7, RESET_DIST = 6, RESET_RATE = 4, RECYCLE_DIST = 320, RECYCLE_S = 6, BARRIER_R = 2.6, BARRIER_KEEP = 0.62;
|
| 17 |
+
const wrapTo = (R, v, ref) => { if (!R.loop) return v; let ds = (v - ref) % R.L; if (ds > R.L / 2) ds -= R.L; else if (ds < -R.L / 2) ds += R.L; return ref + ds; };
|
| 18 |
+
M.wrapTo = wrapTo;
|
| 19 |
+
// o: copsMax, top, grip, accel, spawnGap, formations, rbChance, spikeChance, heli, heliAfter, heliFuel, heliGap, bustKph
|
| 20 |
+
M.initPolice = (g, o) => {
|
| 21 |
+
g.pol = Object.assign({ bust: 0, seen: 0, sinceSeen: 0, evade: 0, spawnT: o.spawnGap, rbT: 9, formT: 4, formation: 'FOLLOW', pursuitT: 0, destroyed: 0, bonusT: 0, bonusMult: 1, lockT: 0, lastS: g.s, heliT: o.heliAfter, combo: 0, sawNow: 1, inSight: 1 }, o);
|
| 22 |
+
g.cops = []; g.props = []; g.blocks = []; g.heli = null; g.puncT = 0; g.punc = 0;
|
| 23 |
+
};
|
| 24 |
+
M.spawnCop = (g, s, lat, dir, state = 'chase', h) => {
|
| 25 |
+
const R = g.route, a = C.routeAt(R, s, lat), c = { x: a.x, y: a.y, h: h !== undefined ? h : dir > 0 ? a.h : a.h + Math.PI, v: state === 'rb' ? 0 : 20, s, lat, hp: 100, state, chasing: state === 'chase' ? 1 : 0, dead: 0, gone: 0, slot: g.cops.length, sees: 0, hitT: 0, deadT: 0, lostT: 0 };
|
| 26 |
+
g.cops.push(c); return c;
|
| 27 |
+
};
|
| 28 |
+
const destroy = (g, c, why) => {
|
| 29 |
+
c.dead = 1; c.chasing = 0; c.deadT = 4; const p = g.pol; p.destroyed++;
|
| 30 |
+
p.bonusMult = p.bonusT > 0 ? Math.min(3, p.bonusMult + 1) : 1; p.bonusT = 8; p.combo = p.bonusMult;
|
| 31 |
+
g.events.push({ type: 'cop_destroyed', why, mult: p.bonusMult });
|
| 32 |
+
};
|
| 33 |
+
M.destroyCop = destroy;
|
| 34 |
+
// Slot offsets in the player's frame: [metres ahead, metres to the left]. Numbers are original: the formation classes' tables are VLT-driven.
|
| 35 |
+
const SLOTS = { FOLLOW: [[-11, -2.5], [-11, 2.5], [-22, 0], [-30, -4], [-30, 4]], ROLLING_BLOCK: [[14, -3.2], [14, 3.2], [24, 0], [-12, 0], [-22, 3]], BOX_IN: [[-6, -4.2], [-6, 4.2], [12, 0], [-14, 0], [-22, 0]], PIT: [[-3, -3.4], [-3, 3.4], [-12, 0], [-22, 3], [-22, -3]] };
|
| 36 |
+
function stepCop(g, c, wdt, losTick) {
|
| 37 |
+
const p = g.pol, R = g.route, car = g.car;
|
| 38 |
+
if (c.deadT > 0) { c.deadT -= wdt; c.v = Math.max(0, c.v - 12 * wdt); c.x += Math.cos(c.h) * c.v * wdt; c.y += Math.sin(c.h) * c.v * wdt; if (c.deadT <= 0) c.gone = 1; return; }
|
| 39 |
+
const dx = car.x - c.x, dy = car.y - c.y, dist = Math.hypot(dx, dy);
|
| 40 |
+
c.s = C.routeNear(R, c.x, c.y, wrapTo(R, c.s, g.s), 30, 30); c.lat = C.routeLat(R, c.x, c.y, c.s);
|
| 41 |
+
if (losTick) { const dot = (Math.cos(c.h) * dx + Math.sin(c.h) * dy) / (dist || 1); c.sees = (dist < REAR_LOS || (dist < FRONT_LOS && dot > 0)) && C.lineClear(c.x, c.y, car.x, car.y) ? 1 : 0; }
|
| 42 |
+
if (c.state === 'rb') { // parked across the road; joins in once the player is past or a strip was hit
|
| 43 |
+
if (g.s - c.s > 12 || c.join) { c.state = 'chase'; c.chasing = 1; }
|
| 44 |
+
else return;
|
| 45 |
+
}
|
| 46 |
+
let tx, ty;
|
| 47 |
+
if (c.sees && dist < 60) { // in formation (kFormationCandidateDistance)
|
| 48 |
+
const slots = SLOTS[p.formation], sl = slots[c.slot % slots.length], ch = Math.cos(car.h), sh = Math.sin(car.h), lead = C.speed(car) * 0.25;
|
| 49 |
+
tx = car.x + ch * (sl[0] + lead) - sh * sl[1]; ty = car.y + sh * (sl[0] + lead) + ch * sl[1];
|
| 50 |
+
if (p.formation === 'PIT' && (c.slot % slots.length) < 2 && dist < 9) { tx = car.x + ch * lead; ty = car.y + sh * lead; } // the ram itself
|
| 51 |
+
} else if (c.sees) { const lead = C.speed(car) * 0.35; tx = car.x + Math.cos(car.h) * lead; ty = car.y + Math.sin(car.h) * lead; }
|
| 52 |
+
else { // search: along the route towards the last known position (the route is where the sim keeps its cops)
|
| 53 |
+
const dS = wrapTo(R, p.lastS, c.s) - c.s, dirn = dS >= 0 ? 1 : -1, a = C.routeAt(R, c.s + dirn * Math.max(10, c.v * 0.6), clamp(c.lat, -3, 3)); tx = a.x; ty = a.y;
|
| 54 |
+
}
|
| 55 |
+
let want = Math.atan2(ty - c.y, tx - c.x) - c.h; want = Math.atan2(Math.sin(want), Math.cos(want));
|
| 56 |
+
const grip = P.grip * p.grip, rate = grip / Math.max(c.v, 6);
|
| 57 |
+
c.h += clamp(want, -rate * wdt, rate * wdt);
|
| 58 |
+
// Speed: the road's limit ahead, its class top, and the gap to its slot when it has sight (it has to hold station, not overshoot).
|
| 59 |
+
const prof = C.profile(R, grip, P.aero, P.brake * 0.9, p.top); let lim = Math.min(C.profileAt(R, prof, c.s + c.v * 0.3), C.profileAt(R, prof, c.s - c.v * 0.3));
|
| 60 |
+
if (Math.abs(want) > 0.9) lim = Math.min(lim, 12);
|
| 61 |
+
if (!c.sees) lim = Math.min(lim, p.searchTop);
|
| 62 |
+
else if (dist < 60) { const sd = Math.hypot(tx - c.x, ty - c.y), ahead = Math.cos(want) > 0; lim = Math.min(lim, Math.max(4, C.speed(car) + (ahead ? clamp(sd * 0.5, -6, p.close) : -6))); }
|
| 63 |
+
if (c.v > lim) c.v = Math.max(lim, c.v - P.brake * 0.9 * wdt);
|
| 64 |
+
else c.v = Math.min(lim, c.v + Math.max(0.5, C.driveAt(c.v) * p.accel - P.drag * c.v * c.v - P.roll) * wdt);
|
| 65 |
+
c.x += Math.cos(c.h) * c.v * wdt; c.y += Math.sin(c.h) * c.v * wdt;
|
| 66 |
+
const q = C.road(c.x, c.y), over = q.d + 1.2; if (over > 0) { c.x -= q.nx * over; c.y -= q.ny * over; c.v *= 1 - Math.min(0.4, 2 * wdt); }
|
| 67 |
+
}
|
| 68 |
+
// Contact with the player: equal masses along the normal, closing speed scrapes the cop's damage (DamageVehicle::OnImpact; the table is VLT).
|
| 69 |
+
function contact(g, c) {
|
| 70 |
+
const car = g.car, dx = car.x - c.x, dy = car.y - c.y, d2 = dx * dx + dy * dy, R2 = M.carRadius * 2; if (d2 >= R2 * R2) return;
|
| 71 |
+
const d = Math.max(0.01, Math.sqrt(d2)), nx = dx / d, ny = dy / d, cvx = Math.cos(c.h) * c.v, cvy = Math.sin(c.h) * c.v, rel = (car.vx - cvx) * nx + (car.vy - cvy) * ny, push = R2 - d;
|
| 72 |
+
car.x += nx * push * 0.5; car.y += ny * push * 0.5; c.x -= nx * push * 0.5; c.y -= ny * push * 0.5;
|
| 73 |
+
if (rel >= 0) return;
|
| 74 |
+
const j = -0.75 * rel; car.vx += nx * j; car.vy += ny * j; c.v = Math.max(0, c.v - j * (Math.cos(c.h) * -nx + Math.sin(c.h) * -ny) * -1); if (c.v > 90) c.v = 90;
|
| 75 |
+
if (c.hitT <= 0 && -rel > 3) {
|
| 76 |
+
c.hitT = 0.4; g.lastHit = 0.25; g.hits++; const dmg = -rel * g.pol.copFrail; c.hp -= dmg;
|
| 77 |
+
if (c.state === 'rb') { c.join = 1; for (const o of g.cops) if (o.state === 'rb') o.join = 1; }
|
| 78 |
+
g.events.push({ type: 'cop_contact', speed: -rel, hp: c.hp });
|
| 79 |
+
if (c.hp <= 0) destroy(g, c, 'ram');
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
const spawnAway = (g) => {
|
| 83 |
+
const p = g.pol, R = g.route, ahead = (p.sawNow || p.aheadBlind) && N.rand(g) < p.aheadChance, S = g.s + (ahead ? 320 + N.rand(g) * 120 : -(210 + N.rand(g) * 90)), lat = (N.rand(g) < 0.5 ? -1 : 1) * R.halfW * 0.4;
|
| 84 |
+
if (!R.loop && (S < 20 || S > R.L - 20)) return;
|
| 85 |
+
const c = M.spawnCop(g, S, lat, ahead ? -1 : 1, 'chase');
|
| 86 |
+
c.slot = p.nextSlot = (p.nextSlot || 0) + 1;
|
| 87 |
+
};
|
| 88 |
+
function stepRoadblocks(g, wdt) {
|
| 89 |
+
const p = g.pol, R = g.route; p.rbT -= wdt;
|
| 90 |
+
// AIPursuit.cpp:2459: a request every 8-12 s; the probability and the spike chance are the heat level's VLT values (approximations).
|
| 91 |
+
if (p.rbT <= 0) {
|
| 92 |
+
p.rbT = 8 + N.rand(g) * 4;
|
| 93 |
+
if (!g.props.some(x => x.type === 'barrier') && p.rbChance > 0 && N.rand(g) < p.rbChance && C.speed(g.car) > 15 && !p.lockT) {
|
| 94 |
+
const S = g.s + Math.max(180, C.speed(g.car) * 5.5), a = C.routeAt(R, S), h = a.h, kN = Math.abs(a.k); if (kN < 0.012) {
|
| 95 |
+
const hw = R.halfW, gapSide = N.rand(g) < 0.5 ? -1 : 1, gapW = p.rbGap, block = []; for (let l = -hw + 1.8; l < hw - 1.6; l += 4.3) if (gapSide * l < hw - gapW || Math.abs(l) < 0) block.push(l);
|
| 96 |
+
block.forEach((l, i) => { if (i % 2 === 0) { const c = M.spawnCop(g, S, l, 1, 'rb', h + Math.PI / 2); c.slot = i; } else { const b = C.routeAt(R, S, l); g.props.push({ type: 'barrier', x: b.x, y: b.y, h: h + Math.PI / 2, s: S, lat: l, ttl: 40 }); } g.blocks.push({ s: S, lat: l }); });
|
| 97 |
+
if (N.rand(g) < p.spikeChance) { const S2 = S - 26, side = -gapSide, L = hw + 3, l0 = gapSide * (hw - gapW) + side * 0 - gapSide * L / 2, b = C.routeAt(R, S2, l0); g.props.push({ type: 'spike', x: b.x, y: b.y, h: h, s: S2, lat: l0, len: L, ttl: 40 }); }
|
| 98 |
+
g.events.push({ type: 'roadblock', s: S, gap: gapSide });
|
| 99 |
+
}
|
| 100 |
+
}
|
| 101 |
+
}
|
| 102 |
+
for (const o of g.props) if (o.ttl !== undefined) { o.ttl -= wdt; if (o.ttl <= 0 || g.s - wrapTo(R, o.s, g.s) > 160) o.gone = 1; }
|
| 103 |
+
g.props = g.props.filter(o => !o.gone);
|
| 104 |
+
g.blocks = g.blocks.filter(b => g.s - wrapTo(R, b.s, g.s) < 40);
|
| 105 |
+
for (const o of g.props) if (o.type === 'barrier' && !o.gone) { const dx = g.car.x - o.x, dy = g.car.y - o.y; if (dx * dx + dy * dy < BARRIER_R * BARRIER_R) { const v = C.speed(g.car); g.car.vx *= BARRIER_KEEP; g.car.vy *= BARRIER_KEEP; o.gone = 1; g.hits++; g.lastHit = 0.3; g.events.push({ type: 'barrier', speed: v }); for (const k of g.cops) if (k.state === 'rb') k.join = 1; } }
|
| 106 |
+
// Spikes: wheels are ±0.9 m off the centreline; each side over the strip is two tyres, punctured now and blown 0.5 s later.
|
| 107 |
+
const c = g.car;
|
| 108 |
+
for (const o of g.props) if (o.type === 'spike' && !o.used) {
|
| 109 |
+
const a = C.routeAt(R, o.s), ds = (c.x - a.x) * Math.cos(a.h) + (c.y - a.y) * Math.sin(a.h);
|
| 110 |
+
if (Math.abs(ds) < C.speed(c) * wdt + 0.6) { let n = 0; for (const w of [-0.9, 0.9]) if (Math.abs(g.lat + w - o.lat) < o.len / 2) n += 2; if (n && !g.flash) { o.used = 1; g.punc = Math.max(g.punc, n); g.puncT = 0.5; for (const k of g.cops) if (k.state === 'rb') k.join = 1; g.events.push({ type: 'spikes', tyres: n }); } }
|
| 111 |
+
}
|
| 112 |
+
if (g.puncT > 0) { g.puncT -= wdt; if (g.puncT <= 0) c.tires = Math.max(c.tires, g.punc); }
|
| 113 |
+
}
|
| 114 |
+
function stepHeli(g, wdt) {
|
| 115 |
+
const p = g.pol, car = g.car; if (!p.heli) return;
|
| 116 |
+
if (!g.heli) { p.heliT -= wdt; if (p.heliT <= 0 && !p.lockT) { g.heli = { x: car.x - Math.cos(car.h) * 200, y: car.y - Math.sin(car.h) * 200, z: 34, h: car.h, fuel: p.heliFuel, sees: 0, gone: 0 }; g.events.push({ type: 'helicopter' }); } return; }
|
| 117 |
+
const h = g.heli, sp = C.speed(car), lead = sp * 0.4 + 30, ch = Math.cos(car.h), sh = Math.sin(car.h), tx = car.x + ch * lead, ty = car.y + sh * lead, dx = tx - h.x, dy = ty - h.y, d = Math.hypot(dx, dy) || 1, v = Math.min(85, d * 1.4); // AIActionHeliPursuit.cpp:26,leadDist
|
| 118 |
+
h.x += dx / d * v * wdt; h.y += dy / d * v * wdt; h.h = Math.atan2(dy, dx); h.fuel -= wdt; h.sees = Math.hypot(car.x - h.x, car.y - h.y) < HELI_LOS ? 1 : 0;
|
| 119 |
+
if (h.fuel <= 0) { g.heli = null; p.heliT = p.heliGap; g.events.push({ type: 'helicopter_leaves' }); }
|
| 120 |
+
}
|
| 121 |
+
// Returns nothing; updates sight, the bust meter, spawns and contacts. evadeOn: whether the evade meter runs (pursuit only).
|
| 122 |
+
M.stepPolice = (g, wdt, evadeOn) => {
|
| 123 |
+
const p = g.pol, car = g.car, R = g.route, losTick = g.t % 4 === 0;
|
| 124 |
+
if (p.bonusT > 0) p.bonusT = Math.max(0, p.bonusT - wdt);
|
| 125 |
+
if (p.lockT > 0) p.lockT = Math.max(0, p.lockT - wdt);
|
| 126 |
+
p.formT -= wdt; if (p.formT <= 0) { p.formT = 9 + N.rand(g) * 6; p.formation = p.formations[Math.floor(N.rand(g) * p.formations.length) % p.formations.length]; }
|
| 127 |
+
let seen = 0, near = Infinity;
|
| 128 |
+
for (const c of g.cops) { if (c.gone) continue; c.hitT = Math.max(0, c.hitT - wdt); stepCop(g, c, wdt, losTick); if (!c.dead && c.state !== 'rb') { if (c.sees) seen = 1; near = Math.min(near, Math.hypot(car.x - c.x, car.y - c.y)); } contact(g, c); }
|
| 129 |
+
// Out of sight and far behind for a while: gone, so the slot can spawn a cop that can still engage (RemoveUnwantedVehicles / StartFlee; the distances are approximations).
|
| 130 |
+
for (const c of g.cops) { if (c.dead || c.state === 'rb') continue; const far = !c.sees && Math.hypot(car.x - c.x, car.y - c.y) > RECYCLE_DIST; c.lostT = far ? c.lostT + wdt : 0; if (c.lostT > RECYCLE_S) c.gone = 1; }
|
| 131 |
+
g.cops = g.cops.filter(c => !c.gone);
|
| 132 |
+
for (let i = 0; i < g.cops.length; i++) for (let j = i + 1; j < g.cops.length; j++) { const a = g.cops[i], b = g.cops[j]; if (a.dead || b.dead) continue; const dx = a.x - b.x, dy = a.y - b.y, d2 = dx * dx + dy * dy; if (d2 < 10 && d2 > 1e-4 && a.state !== 'rb' && b.state !== 'rb') { const d = Math.sqrt(d2), pu = (3.2 - d) * 0.5; a.x += dx / d * pu; a.y += dy / d * pu; b.x -= dx / d * pu; b.y -= dy / d * pu; } }
|
| 133 |
+
stepHeli(g, wdt); if (g.heli && g.heli.sees) seen = 1;
|
| 134 |
+
stepRoadblocks(g, wdt);
|
| 135 |
+
p.sawNow = seen;
|
| 136 |
+
const active = g.cops.filter(c => !c.dead && c.state !== 'rb').length;
|
| 137 |
+
p.spawnT -= wdt; if (p.spawnT <= 0 && active < p.copsMax && !p.lockT) { p.spawnT = p.spawnGap; spawnAway(g); }
|
| 138 |
+
// Bust meter (AIPursuit.cpp:1889-1940, the flash rules at :1895-1909).
|
| 139 |
+
const flashing = g.flash > 0, bdist = BUST_DIST * (flashing ? RESET_DIST : 1), slow = flashing || C.speed(car) < p.bustSpeed;
|
| 140 |
+
if (seen) { p.seen += wdt; p.sinceSeen = 0; p.lastS = g.s; p.pursuitT += wdt; } else p.sinceSeen += wdt;
|
| 141 |
+
// mIsPerpInSight is "a cop saw the perp within the last 7 s" (AIPursuit.cpp:2000), not "a cop sees the perp now".
|
| 142 |
+
p.inSight = p.sinceSeen < EVADE_AFTER ? 1 : 0;
|
| 143 |
+
p.bust = Math.max(0, p.bust + (p.inSight && slow && near < bdist ? (flashing ? RESET_RATE : 1) : -2) * wdt);
|
| 144 |
+
if (evadeOn) {
|
| 145 |
+
if (seen) p.evade *= Math.pow(0.93, wdt * 15);
|
| 146 |
+
else if (p.sinceSeen > EVADE_AFTER) p.evade = Math.max(p.evade, Math.min(1, p.sinceSeen / p.evadeTimeout));
|
| 147 |
+
}
|
| 148 |
+
if (p.bust > BUST_MAX) { p.bust = BUST_MAX; g.lose('busted'); }
|
| 149 |
+
};
|
| 150 |
+
M.BUST_MAX = BUST_MAX;
|
| 151 |
+
M.bustHp = g => Math.round((BUST_MAX - g.pol.bust) * 10);
|
| 152 |
+
// Road users for the controller: decided poses only.
|
| 153 |
+
M.copUsers = (g, R, out) => {
|
| 154 |
+
const add = (s, lat, vs, cop, vl = 0) => out.push({ s: wrapTo(R, s, g.s), lat, vs, r: 2, cop, vl });
|
| 155 |
+
for (const c of g.cops) { if (c.gone) continue; const dh = c.h - C.routeAt(R, c.s).h, still = c.dead || c.state === 'rb'; add(c.s, c.lat, still ? 0 : c.v * Math.cos(dh), still ? 0 : 1, still ? 0 : c.v * Math.sin(dh)); }
|
| 156 |
+
for (const o of g.props) if (o.type === 'barrier') add(o.s, o.lat, 0); else if (o.type === 'spike' && !o.used) for (let l = -o.len / 2; l <= o.len / 2 + 0.01; l += 2) add(o.s, o.lat + l, 0);
|
| 157 |
+
};
|
| 158 |
+
})(typeof window === 'undefined' ? globalThis : window);
|
environments/games/web/games/nfsmw_remake/draw.js
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* NFS Most Wanted events - Module.draw: the WebGL chase view plus an original Canvas 2D HUD (speed, gear, nitrous and Speedbreaker
|
| 2 |
+
gauges, route minimap, event panel). BossBench additions: both public health bars, fight timer and the native tick rate.
|
| 3 |
+
Read-only on the game state.
|
| 4 |
+
2026-11-08: what the agent needs from the picture alone.
|
| 5 |
+
- Threat telegraphs: a warning strip when a roadblock or spike strip is on the road ahead, when a cop holds a ramming slot
|
| 6 |
+
beside the car, when the helicopter's light is on the car, when the bust meter rises; edge arrows for cops and rivals
|
| 7 |
+
outside the picture (behind, round a corner); a frame around the rear-view mirror when a cop is in it.
|
| 8 |
+
- The drag series' manual box: a tachometer with the shift window (the perfect-shift band of carStep) and a light that turns
|
| 9 |
+
green there, the launch band during staging, and the keys to press. A player who only holds W knew none of this.
|
| 10 |
+
- HUD panels keep to the screen edges and are smaller, so more of the road and the cars stays visible.
|
| 11 |
+
Everything here is drawn from state the simulation already decided this tick; nothing is written back. */
|
| 12 |
+
(function (root) {
|
| 13 |
+
'use strict';
|
| 14 |
+
const M = root.NfsmwGame, C = M.C, R = M.R3;
|
| 15 |
+
const W = 854, H = 480;
|
| 16 |
+
const panel = (c, x, y, w, h, a = 0.58) => { c.fillStyle = `rgba(10,14,22,${a})`; c.beginPath(); c.roundRect(x, y, w, h, 6); c.fill(); };
|
| 17 |
+
const bar = (c, x, y, w, h, v, col, back = 'rgba(255,255,255,.14)') => { c.fillStyle = back; c.fillRect(x, y, w, h); c.fillStyle = col; c.fillRect(x, y, w * C.clamp(v, 0, 1), h); };
|
| 18 |
+
const LABEL = { time: 'Time expired', gap: 'Rival pulled away', blown: 'Engine blown', totaled: 'Crash wreck', busted: 'Busted', knocked: 'Eliminated in last place', score: 'Lost on total score' };
|
| 19 |
+
// HUD rectangles [x0, y0, x1, y1]; the view metric counts a target under one of these as not visible.
|
| 20 |
+
const RECT = { tier: [8, 8, 150, 46], event: [158, 8, 696, 46], clock: [704, 8, 846, 46], speedo: [708, 392, 846, 472], map: [10, 372, 108, 470], tach: [708, 352, 846, 382] };
|
| 21 |
+
M.hudRects = Object.values(RECT);
|
| 22 |
+
const FONT = '"Microsoft YaHei",Consolas,sans-serif';
|
| 23 |
+
function minimap(g, c) {
|
| 24 |
+
const R0 = g.route, size = 98, x0 = RECT.map[0], y0 = RECT.map[1], big = R0.name === 'downtown', span = R0.name === 'strip' ? 700 : big ? 200 : 460, k = size / 2 / span;
|
| 25 |
+
panel(c, x0, y0, size, size, 0.62); c.save(); c.beginPath(); c.rect(x0, y0, size, size); c.clip();
|
| 26 |
+
const car = g.car, tx = u => x0 + size / 2 + (u - car.x) * k, ty = v => y0 + size / 2 - (v - car.y) * k;
|
| 27 |
+
c.lineWidth = Math.max(2.4, 8 * k * 6); c.strokeStyle = 'rgba(190,200,215,.28)';
|
| 28 |
+
for (const st of C.streets) { c.beginPath(); st.forEach((p, i) => i ? c.lineTo(tx(p[0]), ty(p[1])) : c.moveTo(tx(p[0]), ty(p[1]))); c.stroke(); }
|
| 29 |
+
c.strokeStyle = 'rgba(245,240,225,.85)'; c.beginPath(); for (let i = 0; i <= R0.n; i += 6) { const u = i % R0.n; const px = tx(R0.x[u]), py = ty(R0.y[u]); i ? c.lineTo(px, py) : c.moveTo(px, py); } if (R0.loop) c.closePath(); c.stroke();
|
| 30 |
+
const dot = (x, y, col, r = 3) => { c.fillStyle = col; c.beginPath(); c.arc(tx(x), ty(y), r, 0, 7); c.fill(); };
|
| 31 |
+
for (const gt of g.gates || []) if (!gt.done) { const a = C.routeAt(R0, gt.s !== undefined ? gt.s : g.s0 + gt.at); dot(a.x, a.y, gt.kind === 'trap' ? '#ffb037' : '#7dff9a', 3.2); }
|
| 32 |
+
for (const r of g.rivals) if (!r.gone) dot(r.x, r.y, r.name === 'champion' ? '#ff4a3a' : '#ffffff');
|
| 33 |
+
for (const b of g.breakers || []) if (!(b.rearm > 0)) dot(b.x, b.y, '#ff8a3c', 3);
|
| 34 |
+
for (const p of g.cops) if (!p.gone && !p.dead) dot(p.x, p.y, (g.t >> 4) % 2 ? '#4a8cff' : '#ff4a5a');
|
| 35 |
+
for (const p of g.props || []) if (!p.gone && p.type !== 'cone') dot(p.x, p.y, p.type === 'spike' ? '#ffd020' : '#ffe030', 2.4);
|
| 36 |
+
if (g.heli && !g.heli.gone) dot(g.heli.x, g.heli.y, '#ffffff', 2.6);
|
| 37 |
+
c.translate(tx(car.x), ty(car.y)); c.rotate(-car.h); c.fillStyle = '#ffb060'; c.beginPath(); c.moveTo(7, 0); c.lineTo(-4, 4); c.lineTo(-4, -4); c.closePath(); c.fill(); c.restore();
|
| 38 |
+
}
|
| 39 |
+
// ---- telegraphs: everything here is a fact the sim decided already (a placed prop, a cop's position, the formation) ----
|
| 40 |
+
const warnings = [];
|
| 41 |
+
function threats(g, info) {
|
| 42 |
+
warnings.length = 0; info.warn = []; info.arrows = []; info.flames = []; info.cover = [];
|
| 43 |
+
const car = g.car, R = g.route, sp = Math.max(C.speed(car), 5), ch = Math.cos(car.h), sh = Math.sin(car.h);
|
| 44 |
+
if (g.outcome) return;
|
| 45 |
+
// roadblock / spikes on the road ahead (cops.js places them max(180, 5.5 v) m ahead; the original 250 m)
|
| 46 |
+
let rb = null, sk = null;
|
| 47 |
+
for (const p of g.props || []) { if (p.gone || p.used) continue; const ds = M.wrapTo ? M.wrapTo(R, p.s, g.s) - g.s : p.s - g.s; if (ds <= 0 || ds > 320) continue; if (p.type === 'spike') { if (!sk || ds < sk.ds) sk = { ds, p }; } else if (p.type === 'barrier') { if (!rb || ds < rb.ds) rb = { ds, p }; } }
|
| 48 |
+
if (rb) { warnings.push({ col: '#ffb020', text: `Roadblock ahead: ${Math.round(rb.ds)} m (${(rb.ds / sp).toFixed(1)} s)` }); info.warn.push('roadblock'); }
|
| 49 |
+
if (sk) { warnings.push({ col: '#ffd020', text: `Spike strip: ${Math.round(sk.ds)} m · on the ${sk.p.lat > 0 ? 'left' : 'right'} side` }); info.warn.push('spikes'); }
|
| 50 |
+
// ramming formation: a cop with sight inside 12 m while PIT or BOX_IN is the formation
|
| 51 |
+
if (g.pol) {
|
| 52 |
+
const close = g.cops.filter(k => !k.dead && !k.gone && k.state !== 'rb' && k.sees && Math.hypot(k.x - car.x, k.y - car.y) < 12);
|
| 53 |
+
if (close.length && (g.pol.formation === 'PIT' || g.pol.formation === 'BOX_IN')) { const k = close[0], side = (-(k.x - car.x) * sh + (k.y - car.y) * ch) > 0 ? 'left' : 'right'; warnings.push({ col: '#ff4a5a', text: g.pol.formation === 'PIT' ? `Police car ${side} rear ready to ram` : 'Police car box-in' }); info.warn.push('pit'); }
|
| 54 |
+
if (g.heli && !g.heli.gone && g.heli.sees) { warnings.push({ col: '#cfe0ff', text: 'Helicopter spotlight locked on' }); info.warn.push('heli'); }
|
| 55 |
+
if (g.pol.bust > 0.03) info.warn.push('bust');
|
| 56 |
+
}
|
| 57 |
+
// edge arrows: cops within 160 m and rivals within 200 m that are not in the main picture
|
| 58 |
+
const sc = R3sc(g);
|
| 59 |
+
const arrow = (kind, ref, x, y, col) => {
|
| 60 |
+
if (!sc) return; const p = sc.project(x, y, 0.8); const inside = p.front && p.x > 8 && p.x < W - 8 && p.y > 50 && p.y < H - 8; if (inside) return;
|
| 61 |
+
// direction in the car's frame -> a point on an ellipse around the screen centre
|
| 62 |
+
const dx = x - car.x, dy = y - car.y, fwd = dx * ch + dy * sh, left = -dx * sh + dy * ch, ang = Math.atan2(-left, fwd); // 0 = ahead, +pi/2 = right
|
| 63 |
+
info.arrows.push({ kind, ref, ang, dist: Math.hypot(dx, dy), col });
|
| 64 |
+
};
|
| 65 |
+
g.cops.forEach((k, i) => { if (!k.gone && !k.dead && Math.hypot(k.x - car.x, k.y - car.y) < 160) arrow('cop', i, k.x, k.y, (g.t >> 3) % 2 ? '#ff4a5a' : '#4a8cff'); });
|
| 66 |
+
g.rivals.forEach((r, i) => { if (!r.gone && !r.out && Math.hypot(r.x - car.x, r.y - car.y) < 200) arrow('rival', i, r.x, r.y, r.name === 'champion' ? '#ff4a3a' : '#ffffff'); });
|
| 67 |
+
g.rivals.forEach((r, i) => { if (!r.gone && !r.out && (r.nosT > 0 || r.trapNos > 0) && r.nos > 0.02) info.flames.push(i); });
|
| 68 |
+
if (g.heli && !g.heli.gone) arrow('heli', 0, g.heli.x, g.heli.y, '#e8f0ff');
|
| 69 |
+
}
|
| 70 |
+
let cur = null; const R3sc = () => cur; // the scene this frame was rendered with (R3.render returns it)
|
| 71 |
+
function drawArrows(c, info) {
|
| 72 |
+
// one arrow per side of the screen at most: overlapping arrows (two rivals right behind) read as one, the nearest wins
|
| 73 |
+
const drawn = [];
|
| 74 |
+
for (const a of [...info.arrows].sort((p, q) => p.dist - q.dist)) {
|
| 75 |
+
const s = Math.sin(a.ang), co = Math.cos(a.ang), x = W / 2 + s * 380, y = H / 2 + 24 - co * 200;
|
| 76 |
+
let cx = C.clamp(x, 26, W - 26), cy = C.clamp(y, 64, H - 70);
|
| 77 |
+
if (cy >= H - 100 && Math.abs(cx - W / 2) < 130) cx = W / 2 + (s >= 0 ? 130 : -130); // behind: either side of the car, not over it
|
| 78 |
+
if (cy > 350 && (cx < 122 || cx > 696)) cy = 350; // clear of the minimap and the speedometer
|
| 79 |
+
if (drawn.some(d => Math.hypot(d[0] - cx, d[1] - cy) < 34)) continue; drawn.push([cx, cy]);
|
| 80 |
+
const near = C.clamp(1 - a.dist / 160, 0.25, 1), size = 9 + 9 * near;
|
| 81 |
+
c.save(); c.translate(cx, cy); c.rotate(a.ang); c.globalAlpha = 0.55 + 0.45 * near; c.fillStyle = 'rgba(0,0,0,.6)'; c.beginPath(); c.moveTo(0, -size - 3); c.lineTo(size * 0.85 + 3, size * 0.6 + 2); c.lineTo(-size * 0.85 - 3, size * 0.6 + 2); c.closePath(); c.fill();
|
| 82 |
+
c.fillStyle = a.col; c.beginPath(); c.moveTo(0, -size); c.lineTo(size * 0.85, size * 0.6); c.lineTo(-size * 0.85, size * 0.6); c.closePath(); c.fill(); c.restore();
|
| 83 |
+
c.globalAlpha = 1; c.font = 'bold 10px Consolas,monospace'; c.fillStyle = '#ffffff'; c.textAlign = 'center'; c.fillText(Math.round(a.dist) + 'm', cx, cy + (cy > H / 2 ? -14 : 22)); c.textAlign = 'left';
|
| 84 |
+
}
|
| 85 |
+
}
|
| 86 |
+
// One row at the bottom centre, on the road just in front of the bumper: the horizon band (y 150-190), where a roadblock
|
| 87 |
+
// 200 m ahead appears, stays clear.
|
| 88 |
+
function drawWarnings(c, g) {
|
| 89 |
+
if (!warnings.length) return;
|
| 90 |
+
c.font = `bold 14px ${FONT}`; const widths = warnings.map(w => c.measureText(w.text).width + 30), total = widths.reduce((a, b) => a + b, 0) + 8 * (warnings.length - 1), y = H - 32;
|
| 91 |
+
let x = W / 2 - total / 2;
|
| 92 |
+
M.hudInfo.cover.push([x, y, x + total, y + 24]);
|
| 93 |
+
for (const [i, w] of warnings.entries()) {
|
| 94 |
+
const tw = widths[i], on = (g.t >> 3) % 2 === 0;
|
| 95 |
+
c.fillStyle = 'rgba(10,10,14,.72)'; c.beginPath(); c.roundRect(x, y, tw, 24, 4); c.fill(); c.strokeStyle = w.col; c.lineWidth = on ? 3 : 1.5; c.stroke();
|
| 96 |
+
c.fillStyle = w.col; c.beginPath(); c.moveTo(x + 9, y + 18); c.lineTo(x + 15, y + 6); c.lineTo(x + 21, y + 18); c.closePath(); c.fill(); c.fillStyle = '#111'; c.fillRect(x + 14.2, y + 10, 1.6, 4.5);
|
| 97 |
+
c.fillStyle = '#ffffff'; c.textAlign = 'left'; c.fillText(w.text, x + 25, y + 17); x += tw + 8;
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
// mirror frame (renderer3d draws the mirror image itself); red border while a cop is in it
|
| 101 |
+
function mirrorFrame(c, g) {
|
| 102 |
+
const sc = R3sc(g); if (!sc || !sc.mirrorOn) return; const [x0, y0, x1, y1] = sc.mirrorRect;
|
| 103 |
+
const copIn = g.cops.some(k => { if (k.gone || k.dead) return false; const dx = k.x - g.car.x, dy = k.y - g.car.y, fwd = dx * Math.cos(g.car.h) + dy * Math.sin(g.car.h); return fwd < 0 && Math.hypot(dx, dy) < 120; });
|
| 104 |
+
c.strokeStyle = copIn && (g.t >> 3) % 2 ? '#ff4a5a' : 'rgba(230,236,245,.85)'; c.lineWidth = 2.5; c.strokeRect(x0 - 1, y0 - 1, x1 - x0 + 2, y1 - y0 + 2);
|
| 105 |
+
c.font = `10px ${FONT}`; c.fillStyle = 'rgba(230,236,245,.85)'; c.fillText('Rearview mirror', x0 + 3, y1 + 11);
|
| 106 |
+
}
|
| 107 |
+
// tachometer: fraction of the current gear's top speed (carStep's u), shift band 0.88-0.99, limiter at 1
|
| 108 |
+
function tach(g, c) {
|
| 109 |
+
const car = g.car, [x, y, x1, y1] = RECT.tach, w = x1 - x, h = y1 - y, staging = g.pre > 0 && g.rev !== undefined;
|
| 110 |
+
const fwd = Math.max(0, car.vx * Math.cos(car.h) + car.vy * Math.sin(car.h)), u = staging ? g.rev : C.clamp(fwd / C.TOPS[car.gear], 0, 1.05);
|
| 111 |
+
const band = staging ? [0.62, 0.86] : [0.88, 0.99], inBand = u >= band[0] && u <= band[1];
|
| 112 |
+
panel(c, x, y, w, h, 0.7); const bx = x + 6, bw = w - 12, by = y + 6;
|
| 113 |
+
c.fillStyle = 'rgba(255,255,255,.12)'; c.fillRect(bx, by, bw, 9);
|
| 114 |
+
c.fillStyle = 'rgba(90,255,140,.55)'; c.fillRect(bx + bw * band[0], by, bw * (band[1] - band[0]), 9);
|
| 115 |
+
if (!staging) { c.fillStyle = 'rgba(255,70,60,.55)'; c.fillRect(bx + bw * 0.99, by, bw * 0.01 + 2, 9); }
|
| 116 |
+
c.fillStyle = inBand ? '#7dff9a' : u > band[1] ? '#ff5a4a' : '#ffd08a'; c.fillRect(bx, by + 2, bw * C.clamp(u, 0, 1), 5);
|
| 117 |
+
c.font = `bold 11px ${FONT}`; c.fillStyle = inBand ? '#7dff9a' : '#c6d0dc';
|
| 118 |
+
c.fillText(staging ? (inBand ? 'Launch RPM ✓ Hold steady' : g.rev < band[0] ? 'Hold W to raise RPM into the green zone' : 'RPM too high; release W briefly') : car.gear >= 5 ? 'Top gear · Stay below the redline' : inBand ? '▶ Press K to upshift' : u > band[1] ? 'Press K to upshift now!' : `RPM → Green zone: press K`, bx, by + 21);
|
| 119 |
+
if (inBand && !staging && car.gear < 5 && (g.t >> 2) % 2) { c.strokeStyle = '#7dff9a'; c.lineWidth = 2; c.strokeRect(x + 1, y + 1, w - 2, h - 2); }
|
| 120 |
+
}
|
| 121 |
+
M.draw = function (g, c) {
|
| 122 |
+
const sc = R.render(g, c), info = {}; cur = sc;
|
| 123 |
+
M.hudInfo = info;
|
| 124 |
+
const car = g.car, kmh = C.speed(car) * 3.6, h = g.health(), hud = (M.MODES[g.key].hud || (() => ({ label: '', detail: '' })))(g);
|
| 125 |
+
threats(g, info);
|
| 126 |
+
// knockout: the mode's text measures the last rival still in, and after the win none is left ( 11-06 item 7)
|
| 127 |
+
if (g.key === 'knockout' && g.outcome === 'win') hud.detail = `${g.laps} / ${g.laps} laps · All rivals eliminated`;
|
| 128 |
+
if (g.sb) { const v = c.createRadialGradient(W / 2, H / 2, 150, W / 2, H / 2, 520); v.addColorStop(0, 'rgba(120,170,255,0)'); v.addColorStop(1, 'rgba(70,110,220,.42)'); c.fillStyle = v; c.fillRect(0, 0, W, H); }
|
| 129 |
+
// hit: a red vignette at the edges, not a full-screen wash, so the road stays readable
|
| 130 |
+
if (g.lastHit > 0) { const v = c.createRadialGradient(W / 2, H / 2, 170, W / 2, H / 2, 500); v.addColorStop(0, 'rgba(220,40,30,0)'); v.addColorStop(1, `rgba(220,40,30,${Math.min(0.75, g.lastHit * 1.6)})`); c.fillStyle = v; c.fillRect(0, 0, W, H); }
|
| 131 |
+
if (g.flash > 0 && (g.t >> 3) % 2) { c.fillStyle = 'rgba(255,255,255,.1)'; c.fillRect(0, 0, W, H); }
|
| 132 |
+
mirrorFrame(c, g);
|
| 133 |
+
info.cover.push(RECT.tier, RECT.event, RECT.clock, RECT.speedo, RECT.map); if (g.manual) info.cover.push(RECT.tach); if (sc && sc.mirrorOn) info.cover.push(sc.mirrorRect);
|
| 134 |
+
// event panel: boss_hp and player_hp under their event-specific names
|
| 135 |
+
const [ex0, ey0, ex1] = RECT.event; panel(c, ex0, ey0, ex1 - ex0, 38);
|
| 136 |
+
c.font = `bold 12px ${FONT}`; c.fillStyle = '#f2ecdc'; c.textAlign = 'left'; c.fillText(hud.label || '', ex0 + 8, ey0 + 14);
|
| 137 |
+
c.font = `11px ${FONT}`; c.fillStyle = '#c6d0dc'; c.textAlign = 'right'; c.fillText(hud.detail || '', ex1 - 8, ey0 + 14); c.textAlign = 'left';
|
| 138 |
+
bar(c, ex0 + 8, ey0 + 20, ex1 - ex0 - 16, 5, h[3] ? h[2] / h[3] : 0, '#ff8a3c');
|
| 139 |
+
bar(c, ex0 + 8, ey0 + 28, ex1 - ex0 - 16, 5, h[1] ? h[0] / h[1] : 0, h[0] / (h[1] || 1) < 0.25 ? '#ff4a3a' : '#5bd18a');
|
| 140 |
+
// clock and tier
|
| 141 |
+
const [cx0, cy0, cx1] = RECT.clock; panel(c, cx0, cy0, cx1 - cx0, 38); c.textAlign = 'right'; c.font = 'bold 16px Consolas,monospace'; c.fillStyle = '#f2ecdc'; c.fillText((g.t / M.hz).toFixed(1) + ' s', cx1 - 8, cy0 + 18);
|
| 142 |
+
c.font = 'bold 10px Consolas,monospace'; c.fillStyle = '#9fd0ff'; c.fillText(M.hz + 'Hz · tick ' + g.t, cx1 - 8, cy0 + 32); c.textAlign = 'left';
|
| 143 |
+
const [tx0, ty0, tx1] = RECT.tier; panel(c, tx0, ty0, tx1 - tx0, 38); c.font = 'bold 11px Consolas,monospace'; c.fillStyle = '#ffd08a'; c.fillText((g.tier || '').toUpperCase() + ' d=' + g.d, tx0 + 8, ty0 + 16); c.fillStyle = '#b8c2cc'; c.font = '10px Consolas,monospace'; c.fillText(M.version, tx0 + 8, ty0 + 30);
|
| 144 |
+
// speedometer
|
| 145 |
+
const [sx0, sy0, sx1, sy1] = RECT.speedo; panel(c, sx0, sy0, sx1 - sx0, sy1 - sy0); c.textAlign = 'right'; c.font = 'bold 32px Consolas,monospace'; c.fillStyle = '#ffffff'; c.fillText(String(Math.round(kmh)), sx1 - 40, sy0 + 34);
|
| 146 |
+
c.font = '10px Consolas,monospace'; c.fillStyle = '#a8b4c0'; c.fillText('KM/H', sx1 - 8, sy0 + 34);
|
| 147 |
+
c.font = 'bold 18px Consolas,monospace'; c.fillStyle = car.over ? '#ff5a4a' : '#ffd08a'; c.textAlign = 'center'; c.fillText(String(car.gear + 1), sx0 + 14, sy0 + 26); c.textAlign = 'left';
|
| 148 |
+
c.font = '9px Consolas,monospace'; c.fillStyle = '#9fc8ff'; c.fillText('NOS', sx0 + 6, sy0 + 52); bar(c, sx0 + 34, sy0 + 45, sx1 - sx0 - 42, 7, car.nos, car.nosOn ? '#bfe4ff' : '#4aa0ff');
|
| 149 |
+
c.fillStyle = '#ffd08a'; c.fillText('SLOW', sx0 + 6, sy0 + 64); bar(c, sx0 + 34, sy0 + 57, sx1 - sx0 - 42, 7, g.sbMeter, g.sb ? '#ffffff' : '#ffb84a');
|
| 150 |
+
if (g.manual) { c.fillStyle = '#ff9a7a'; c.fillText('HEAT', sx0 + 6, sy0 + 76); bar(c, sx0 + 34, sy0 + 70, sx1 - sx0 - 42, 6, car.heat, car.heat > 0.6 ? '#ff4a3a' : '#ffa14a'); }
|
| 151 |
+
if (g.manual) tach(g, c);
|
| 152 |
+
minimap(g, c);
|
| 153 |
+
if (M.MODES[g.key].hudExtra) M.MODES[g.key].hudExtra(g, c, { panel, bar, W, H });
|
| 154 |
+
drawArrows(c, info); drawWarnings(c, g);
|
| 155 |
+
if (g.pre > 0) {
|
| 156 |
+
c.font = 'bold 54px Consolas,monospace'; c.textAlign = 'center'; c.fillStyle = '#ffe28a'; c.fillText(String(Math.ceil(g.pre)), W / 2, 210);
|
| 157 |
+
if (g.manual) { c.font = `bold 14px ${FONT}`; c.fillStyle = '#ffffff'; c.fillText('Manual gears: K upshift · L downshift · A / D change lanes', W / 2, 238); }
|
| 158 |
+
c.textAlign = 'left';
|
| 159 |
+
}
|
| 160 |
+
if (g.outcome) { c.fillStyle = 'rgba(0,0,0,.42)'; c.fillRect(0, H / 2 - 44, W, 88); c.font = 'bold 36px "Microsoft YaHei",sans-serif'; c.textAlign = 'center'; c.fillStyle = g.outcome === 'win' ? '#7dff9a' : '#ff6a5a'; c.fillText(g.outcome === 'win' ? 'Challenge complete' : g.outcome === 'timeout' ? 'Time up' : (LABEL[g.lossReason] || 'Challenge Failed'), W / 2, H / 2 + 13); c.textAlign = 'left'; }
|
| 161 |
+
return sc;
|
| 162 |
+
};
|
| 163 |
+
M.renderStatus = ctx => R.status(ctx);
|
| 164 |
+
M.renderMetrics = ctx => R.metrics(ctx);
|
| 165 |
+
M.closeRenderer = ctx => R.close(ctx);
|
| 166 |
+
})(typeof window === 'undefined' ? globalThis : window);
|
environments/games/web/games/nfsmw_remake/game.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Need for Speed: Most Wanted (2005) events, rules nfsmw-arena@2 - the module: cases, tiers, the tick, the health mapping.
|
| 2 |
+
A race has no health bars, so the public contract maps onto the event's own win and loss conditions:
|
| 3 |
+
boss_hp is what is left of the event (route metres from a high-water mark, so it never jumps back), and player_hp
|
| 4 |
+
is what the opponent still needs to beat you (clock, gap, score margin, bust meter). See
|
| 5 |
+
Independent reimplementation; facts read from the CC0 decompilation dbalatoni13/nfsmw@80993f3 are cited as file:line
|
| 6 |
+
in that repository. All art is procedural; no game data (VLT attributes, models, textures, audio, maps) is used. */
|
| 7 |
+
(function (root) {
|
| 8 |
+
'use strict';
|
| 9 |
+
const N = root.NativeBench, M = root.NfsmwGame, C = M.C;
|
| 10 |
+
const HZ = 60, DT = 1 / HZ;
|
| 11 |
+
// Tiers are one fight at three paces: event length, opponent skill, traffic and police pressure all scale continuously.
|
| 12 |
+
// The original has no mode gate on these values (GRace.h: Easy/Medium/Hard is a per-event parameter), so hard stays 0.85.
|
| 13 |
+
const TIERS = { easy: 0.2, normal: 0.5, hard: 0.85 };
|
| 14 |
+
// Piecewise linear through the three tier values, extrapolated beyond them, so any d in [0,1] is a valid fight.
|
| 15 |
+
const tierValue = (d, [e, n, h]) => d <= TIERS.normal ? n + (e - n) * (TIERS.normal - d) / (TIERS.normal - TIERS.easy) : n + (h - n) * (d - TIERS.normal) / (TIERS.hard - TIERS.normal);
|
| 16 |
+
const tierOf = d => d <= (TIERS.easy + TIERS.normal) / 2 ? 'easy' : d <= (TIERS.normal + TIERS.hard) / 2 ? 'normal' : 'hard';
|
| 17 |
+
M.MODES = M.MODES || {};
|
| 18 |
+
|
| 19 |
+
const CASES = [
|
| 20 |
+
{ id: 'nfsmw/tollbooth', name: 'Tollbooth Race (Coastal Highway)' },
|
| 21 |
+
{ id: 'nfsmw/drag', name: 'Drag Series (Highway 99)' },
|
| 22 |
+
{ id: 'nfsmw/speedtrap', name: 'Speed Trap (Coastal Highway)' },
|
| 23 |
+
{ id: 'nfsmw/knockout', name: 'Lap Knockout (Downtown Night Race)' },
|
| 24 |
+
{ id: 'nfsmw/pursuit', name: 'Police Pursuit (Bounty + Escape)' },
|
| 25 |
+
{ id: 'nfsmw/street_champion', name: 'Street Champion Showdown (Multi-leg Race + Police)' },
|
| 26 |
+
];
|
| 27 |
+
Object.assign(M, {
|
| 28 |
+
id: 'nfsmw_remake', version: 'nfsmw-arena@2', hz: HZ, maxSeconds: 300, dimension: '3d', renderer: 'webgl-nfsmw',
|
| 29 |
+
title: 'Need for Speed: Most Wanted · Street Challenges', cases: CASES, tiers: TIERS, tierValue, tierOf, DT,
|
| 30 |
+
controls: {
|
| 31 |
+
'W': 'throttle', 'S': 'brake; reverse at low speed', 'A / D': 'Steer left / right (steering increases while held and decreases at higher speed)', 'Space': 'Handbrake (drift)',
|
| 32 |
+
'Shift': 'nitrous', 'J': 'Toggle slow motion (time slows and downforce increases)', 'K / L': 'Manual upshift / downshift in drag races (A / D change lanes)', 'R': 'Reset onto the route (easier to bust during the 2-second flashing period)',
|
| 33 |
+
},
|
| 34 |
+
});
|
| 35 |
+
|
| 36 |
+
// SB: world time scale is in the ITimeManager data (not in the repository), approximation 0.45; the handling side is
|
| 37 |
+
// SuspensionRacer.cpp:936 Tweak_GameBreakerExtraGs (-2 g of extra downforce) with a 1/3 s physics ramp-out (:937).
|
| 38 |
+
const SB_SCALE = 0.45, SB_GRIP = 2 * 9.81, SB_RAMP = 1 / 3, SB_SECONDS = 6;
|
| 39 |
+
const RESET_INVULN = 2; // ResetCar.cpp:26 Tweak_ResetInvulnerablitiyTime
|
| 40 |
+
|
| 41 |
+
class Game {
|
| 42 |
+
constructor(id, seed, d) {
|
| 43 |
+
this.id = id; this.key = id.split('/')[1]; this.d = d; this.tier = tierOf(d);
|
| 44 |
+
this.t = 0; this.outcome = null; this.events = []; this.seed = seed;
|
| 45 |
+
// The multiply decorrelates neighbouring seeds; xorshift has a fixed point at zero.
|
| 46 |
+
this.rng = (Math.imul((seed >>> 0) + 1, 2654435761) >>> 0) || 1;
|
| 47 |
+
this.pre = 1.2; this.clock = 0; // staging countdown; event clock in world seconds
|
| 48 |
+
this.sb = 0; this.sbMeter = 1; this.sbRamp = 0; // Speedbreaker
|
| 49 |
+
this.flash = 0; this.resets = 0; this.hits = 0; this.nearMisses = 0; this.manual = 0; this.lastHit = 0;
|
| 50 |
+
this.slowT = 0; this.s = 0; this.s0 = 0; this.prog = 0; this.total = 1; this.lat = 0; this.offRoute = 0;
|
| 51 |
+
this.traffic = []; this.rivals = []; this.cops = []; this.props = []; this.gates = []; this.status = '';
|
| 52 |
+
const mode = M.MODES[this.key]; if (!mode) throw Error('Unknown event ' + id);
|
| 53 |
+
this.routeKey = mode.route(d);
|
| 54 |
+
mode.init(this, d);
|
| 55 |
+
this.camH = this.car.h; this.heldBrake = 0; this.flashT = 0; this.heli = null;
|
| 56 |
+
}
|
| 57 |
+
get route() { return C.routes[this.routeKey]; }
|
| 58 |
+
placeCar(s, lat, speed = 0) {
|
| 59 |
+
const a = C.routeAt(this.route, s, lat), c = C.newCar(a.x, a.y, a.h);
|
| 60 |
+
c.vx = Math.cos(a.h) * speed; c.vy = Math.sin(a.h) * speed;
|
| 61 |
+
this.car = c; this.s = s; this.lat = lat;
|
| 62 |
+
}
|
| 63 |
+
update(keys, pressed) {
|
| 64 |
+
const mode = M.MODES[this.key], car = this.car;
|
| 65 |
+
this.heldBrake = keys.has('S') ? 1 : 0;
|
| 66 |
+
// Chase camera: lags the heading (state only the renderer reads; it cannot affect the simulation).
|
| 67 |
+
{ let dh = car.h - this.camH; dh = Math.atan2(Math.sin(dh), Math.cos(dh)); this.camH += dh * Math.min(1, DT * 5.5); }
|
| 68 |
+
if (this.lastHit > 0) this.lastHit = Math.max(0, this.lastHit - DT);
|
| 69 |
+
if (this.flash > 0) this.flash = Math.max(0, this.flash - DT);
|
| 70 |
+
if (pressed.has('J') && (this.sb || this.sbMeter > 0.05)) { this.sb = this.sb ? 0 : 1; if (!this.sb) this.sbRamp = SB_RAMP; this.events.push({ type: this.sb ? 'slowmo_on' : 'slowmo_off' }); }
|
| 71 |
+
if (this.sb) { this.sbMeter = Math.max(0, this.sbMeter - DT / SB_SECONDS); if (this.sbMeter <= 0) { this.sb = 0; this.sbRamp = SB_RAMP; } }
|
| 72 |
+
else if (this.sbRamp > 0) this.sbRamp = Math.max(0, this.sbRamp - DT);
|
| 73 |
+
const wdt = DT * (this.sb ? SB_SCALE : 1);
|
| 74 |
+
if (this.pre > 0) { // staging: the world runs, the car is held at the line
|
| 75 |
+
this.pre = Math.max(0, this.pre - DT);
|
| 76 |
+
if (mode.staging) mode.staging(this, keys, pressed, DT);
|
| 77 |
+
M.stepTraffic(this, wdt); if (mode.idle) mode.idle(this, wdt);
|
| 78 |
+
return;
|
| 79 |
+
}
|
| 80 |
+
if (pressed.has('R')) this.resetCar();
|
| 81 |
+
const speed = C.speed(car), fwd = car.vx * Math.cos(car.h) + car.vy * Math.sin(car.h);
|
| 82 |
+
const inp = {
|
| 83 |
+
thr: keys.has('W') ? 1 : 0, brk: keys.has('S'), steer: (keys.has('A') ? 1 : 0) - (keys.has('D') ? 1 : 0), hb: keys.has('Space'), nos: keys.has('Shift'),
|
| 84 |
+
up: this.manual && pressed.has('K'), down: this.manual && pressed.has('L'), manual: !!this.manual, reverse: keys.has('S') && fwd < 2 && speed < 6,
|
| 85 |
+
sbGrip: this.sb ? SB_GRIP : SB_GRIP * this.sbRamp / SB_RAMP,
|
| 86 |
+
};
|
| 87 |
+
if (mode.input) mode.input(this, inp, keys, pressed);
|
| 88 |
+
C.carStep(car, inp, wdt, this.P || C.PLAYER);
|
| 89 |
+
if (car.hit > 3) { this.hits++; if (car.hit > 6) this.lastHit = 0.4; this.events.push({ type: 'wall', speed: car.hit }); }
|
| 90 |
+
if (!this.sb && speed > 35) this.sbMeter = Math.min(1, this.sbMeter + wdt * 0.02);
|
| 91 |
+
this.slowT = C.speed(car) < 2 ? this.slowT + DT : 0;
|
| 92 |
+
this.clock += wdt;
|
| 93 |
+
this.trackProgress();
|
| 94 |
+
M.stepTraffic(this, wdt);
|
| 95 |
+
mode.tick(this, wdt);
|
| 96 |
+
}
|
| 97 |
+
// Progress is route distance from a high-water mark, inside a short window so a junction can't jump to another leg.
|
| 98 |
+
trackProgress() {
|
| 99 |
+
const R = this.route, c = this.car;
|
| 100 |
+
this.s = C.routeNear(R, c.x, c.y, this.s);
|
| 101 |
+
this.lat = C.routeLat(R, c.x, c.y, this.s);
|
| 102 |
+
this.offRoute = Math.abs(this.lat) > R.halfW + 3 ? 1 : 0;
|
| 103 |
+
if (!this.offRoute && this.s - this.s0 > this.prog) this.prog = Math.min(this.total, this.s - this.s0);
|
| 104 |
+
}
|
| 105 |
+
resetCar() {
|
| 106 |
+
const s = this.s0 + this.prog, a = C.routeAt(this.route, s, 0), keep = this.car;
|
| 107 |
+
Object.assign(keep, { x: a.x, y: a.y, h: a.h, vx: 0, vy: 0, r: 0, steer: 0, gear: 0, clutch: 0, tires: 0 }); // tyres: approximation, see SOURCES.md
|
| 108 |
+
this.s = s; this.lat = 0; this.slowT = 0; this.flash = RESET_INVULN; this.resets++;
|
| 109 |
+
this.events.push({ type: 'reset' });
|
| 110 |
+
}
|
| 111 |
+
win() { if (!this.outcome) { this.outcome = 'win'; this.events.push({ type: 'win' }); } }
|
| 112 |
+
lose(why) { if (!this.outcome) { this.outcome = 'loss'; this.lossReason = why; this.events.push({ type: 'loss', why }); } }
|
| 113 |
+
health() { return M.MODES[this.key].health(this); }
|
| 114 |
+
}
|
| 115 |
+
Object.assign(M, { Game, DT, copyGame: g => Object.assign(Object.create(Game.prototype), N.copy(g)) });
|
| 116 |
+
|
| 117 |
+
// ---------------- traffic (AIActionTraffic: stays in lane at the speed limit, does not race, does not dodge) ----------------
|
| 118 |
+
const carRadius = 1.6;
|
| 119 |
+
M.carRadius = carRadius;
|
| 120 |
+
M.spawnTraffic = (g, n, opt = {}) => {
|
| 121 |
+
g.trafficOpt = { ahead: opt.ahead || 420, spread: opt.spread || 620, opposing: opt.opposing === undefined ? 0.35 : opt.opposing, lanes: opt.lanes || null };
|
| 122 |
+
for (let i = 0; i < n; i++) {
|
| 123 |
+
const t = { s: 0, lat: 0, dir: 1, v: 0, x: 0, y: 0, h: 0, crash: 0, vx: 0, vy: 0, nm: 0, paint: i % 6 };
|
| 124 |
+
placeTraffic(g, t, g.s + 90 + (g.trafficOpt.spread + g.trafficOpt.ahead) * (i + N.rand(g)) / n);
|
| 125 |
+
g.traffic.push(t);
|
| 126 |
+
}
|
| 127 |
+
};
|
| 128 |
+
const lanesOf = (R, dir) => dir > 0 ? [-R.halfW * 0.25, -R.halfW * 0.72] : [R.halfW * 0.25, R.halfW * 0.72];
|
| 129 |
+
function placeTraffic(g, t, s) {
|
| 130 |
+
const R = g.route, o = g.trafficOpt;
|
| 131 |
+
t.dir = N.rand(g) < o.opposing ? -1 : 1; t.nm = 0; t.crash = 0; t.vx = 0; t.vy = 0;
|
| 132 |
+
const lanes = o.lanes || lanesOf(R, t.dir); t.lat = lanes[Math.floor(N.rand(g) * lanes.length) % lanes.length];
|
| 133 |
+
t.v = t.dir * (17 + N.rand(g) * 9); t.s = s;
|
| 134 |
+
if (!R.loop) t.s = C.clamp(s, 40, R.L - 40);
|
| 135 |
+
const a = C.routeAt(R, t.s, t.lat); t.x = a.x; t.y = a.y; t.h = t.dir > 0 ? a.h : a.h + Math.PI;
|
| 136 |
+
}
|
| 137 |
+
M.stepTraffic = (g, wdt) => {
|
| 138 |
+
const R = g.route, c = g.car;
|
| 139 |
+
for (const t of g.traffic) {
|
| 140 |
+
if (t.crash) { // knocked out of lane: a free body that coasts to a stop
|
| 141 |
+
t.x += t.vx * wdt; t.y += t.vy * wdt; const f = Math.max(0, 1 - 1.6 * wdt); t.vx *= f; t.vy *= f; t.h += t.crash * wdt; t.crash *= f;
|
| 142 |
+
const q = C.road(t.x, t.y), over = q.d + 1.2; if (over > 0) { t.x -= q.nx * over; t.y -= q.ny * over; t.vx = 0; t.vy = 0; }
|
| 143 |
+
t.s = C.routeNear(R, t.x, t.y, t.s, 10, 10); t.lat = C.routeLat(R, t.x, t.y, t.s);
|
| 144 |
+
} else {
|
| 145 |
+
t.s += t.v * wdt; const a = C.routeAt(R, t.s, t.lat); t.x = a.x; t.y = a.y; t.h = t.dir > 0 ? a.h : a.h + Math.PI;
|
| 146 |
+
}
|
| 147 |
+
const rel = t.s - g.s;
|
| 148 |
+
if (rel < -140 || rel > g.trafficOpt.ahead + g.trafficOpt.spread + 60 || (!R.loop && (t.s < 30 || t.s > R.L - 30))) { placeTraffic(g, t, g.s + g.trafficOpt.ahead + N.rand(g) * g.trafficOpt.spread); continue; }
|
| 149 |
+
const dx = c.x - t.x, dy = c.y - t.y, dist2 = dx * dx + dy * dy;
|
| 150 |
+
if (dist2 < 30 && !t.nm && C.speed(c) > 25) { const d = Math.sqrt(dist2); if (d > carRadius * 2 + 0.4 && d < 4.6) { t.nm = 1; g.nearMisses++; g.sbMeter = Math.min(1, g.sbMeter + 0.04); } }
|
| 151 |
+
if (dist2 < (carRadius * 2) * (carRadius * 2)) M.bump(g, t, dx, dy, dist2, 0.8);
|
| 152 |
+
}
|
| 153 |
+
};
|
| 154 |
+
// Player against a lighter body: momentum exchange along the contact normal. Returns the closing speed.
|
| 155 |
+
M.bump = (g, o, dx, dy, dist2, mass) => {
|
| 156 |
+
const c = g.car, d = Math.max(0.01, Math.sqrt(dist2)), nx = dx / d, ny = dy / d;
|
| 157 |
+
const moving = o.v !== undefined && !o.crash, ovx = moving ? Math.cos(o.h) * Math.abs(o.v) : o.vx, ovy = moving ? Math.sin(o.h) * Math.abs(o.v) : o.vy;
|
| 158 |
+
const rel = (c.vx - ovx) * nx + (c.vy - ovy) * ny, push = carRadius * 2 - d;
|
| 159 |
+
c.x += nx * push * 0.6; c.y += ny * push * 0.6;
|
| 160 |
+
if (rel >= 0) return 0;
|
| 161 |
+
const j = -(1.3) * rel * mass / (1 + mass);
|
| 162 |
+
c.vx += nx * j; c.vy += ny * j; c.r += ((nx * c.vy - ny * c.vx) > 0 ? 1 : -1) * Math.min(0.8, -rel * 0.02);
|
| 163 |
+
o.vx = ovx - nx * j / mass * 1.0; o.vy = ovy - ny * j / mass * 1.0; if (o.v !== undefined && !o.crash) o.crash = nx * Math.sin(o.h) - ny * Math.cos(o.h) > 0 ? 0.8 : -0.8;
|
| 164 |
+
if (-rel > 4) { g.hits++; g.lastHit = 0.4; g.events.push({ type: 'crash', speed: -rel }); }
|
| 165 |
+
return -rel;
|
| 166 |
+
};
|
| 167 |
+
})(typeof window === 'undefined' ? globalThis : window);
|
environments/games/web/games/nfsmw_remake/index.html
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="data:,"><title>Need for Speed: Most Wanted · Street Challenges(nfsmw-arena@2)</title><link rel="stylesheet" href="../_native/style.css"><style>body[data-game=nfsmw_remake]{--bg:#161a20;--panel:#222831;--edge:#4b5563;--accent:#ff9a4a}body[data-game=nfsmw_remake] #overlay{display:none!important}#nfs-panel{position:absolute;left:0;top:0;width:100%;aspect-ratio:854/480;display:flex;align-items:center;justify-content:center;background:rgba(6,10,16,.5);cursor:pointer;z-index:2}#nfs-panel[hidden]{display:none}.nfs-card{background:#10161eee;border:1px solid var(--edge);border-radius:6px;padding:14px 22px 12px;max-width:560px;text-align:center;cursor:default;box-shadow:0 8px 30px #0008}.nfs-card h2{margin:2px 0 6px;font-size:22px}.nfs-card h2.win{color:#7dff9a}.nfs-card h2.loss{color:#ff7a66}.nfs-card ul{text-align:left;margin:6px 0 10px;padding-left:20px;font-size:13px;color:var(--muted)}.nfs-card .tip{color:#ffd08a;font-size:13px;margin:6px 0}.nfs-card .row{display:flex;gap:10px;justify-content:center;margin:8px 0 4px}.nfs-card .small{font-size:12px;color:var(--muted);margin:4px 0 0}#nfs-panel{overflow:hidden}@media(max-width:900px){.nfs-card{padding:6px 10px;max-width:96%;max-height:100%;overflow:hidden}.nfs-card h2{font-size:16px;margin:0 0 2px}.nfs-card ul,.nfs-card .small{display:none}.nfs-card p{font-size:12px;margin:2px 0}.nfs-card .row{margin:4px 0 0}.nfs-card button{padding:4px 8px;font-size:13px}}</style></head><body><main>
|
| 3 |
+
<header><div><h1>Need for Speed: Most Wanted · Street Challenges</h1><p>2005 original rules, independently recreated from CC0 decompilation · Native 60 Hz · Third-person WebGL · Original procedural city</p></div><a href="../../index.html">Back to Game Lobby</a></header>
|
| 4 |
+
<div class="layout"><section><div class="stage"><canvas width="854" height="480" tabindex="0" aria-label="Game Screen"></canvas><div id="nfs-panel"><div class="nfs-card"></div></div><div id="overlay"><div>Select an event, then start the challenge</div></div><div class="toolbar"><button id="start" class="primary">Start Challenge / Restart</button><button id="pause">Resume</button><button id="step">Step</button><button id="demo">Scripted Demo</button><button id="sample">Example Replay</button></div></div><div class="mobile"><button data-key="A">← left</button><button data-key="W">Accelerate</button><button data-key="D">right →</button><button data-key="S">Brake</button><button data-key="Space">Handbrake</button><button data-key="Shift">Nitrous</button><button data-key="J">Slow motion</button><button data-key="R">Reset</button></div><p id="status" role="status"></p><div class="toolbar"><button id="export">Export Current Replay</button><button id="import">Import and Replay</button><input id="file" type="file" accept=".json,application/json"></div><p class="note">Replays save inputs and the seed, then simulate the match again and verify the final state. Scripted Demo reads internal state for verification; it does not start RL training.</p></section>
|
| 5 |
+
<aside><div><h2>Select Challenge</h2><label for="case">Event</label><select id="case"></select><label for="seed">Seed</label><input id="seed" type="number" min="0" max="4294967295" value="1" step="1"></div><div><label for="difficulty">Difficulty</label><select id="difficulty"></select><p class="note">The three tiers vary the pace of the same event: route length, rival skill, traffic, and police pressure all increase.</p><p class="note">The two top bars show event progress: orange is the remaining event objective (boss_hp, which only decreases); green is your remaining margin (player_hp, based on time, distance, or the bust meter).</p></div><dl></dl></aside></div>
|
| 6 |
+
<footer></footer></main>
|
| 7 |
+
<script src="../_native/runtime.js"></script><script src="../_boss3d/vendor/three.min.js"></script><script src="nfscore.js"></script><script src="game.js"></script><script src="rivals.js"></script><script src="modes_tollbooth.js"></script><script src="modes_drag.js"></script><script src="modes_speedtrap.js"></script><script src="modes_knockout.js"></script><script src="cops.js"></script><script src="modes_pursuit.js"></script><script src="scripted.js"></script><script src="renderer3d.js"></script><script src="draw.js"></script><script>window.GAME_MODULE=window.NfsmwGame;</script><script src="../_native/shell.js"></script><script src="page.js"></script></body></html>
|
environments/games/web/games/nfsmw_remake/manifest.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema": "bossbench/game-manifest@1",
|
| 3 |
+
"engine": "independent",
|
| 4 |
+
"game": "nfsmw_remake",
|
| 5 |
+
"module": "NfsmwGame",
|
| 6 |
+
"title": "Need for Speed Most Wanted: Street Challenges",
|
| 7 |
+
"dimension": "3d",
|
| 8 |
+
"native_hz": 60,
|
| 9 |
+
"max_seconds": 300,
|
| 10 |
+
"renderer": "webgl-nfsmw",
|
| 11 |
+
"rules": "nfsmw-arena@2",
|
| 12 |
+
"cases": [
|
| 13 |
+
"nfsmw/tollbooth",
|
| 14 |
+
"nfsmw/drag",
|
| 15 |
+
"nfsmw/speedtrap",
|
| 16 |
+
"nfsmw/knockout",
|
| 17 |
+
"nfsmw/pursuit",
|
| 18 |
+
"nfsmw/street_champion"
|
| 19 |
+
],
|
| 20 |
+
"scripts": [
|
| 21 |
+
"_native/runtime.js",
|
| 22 |
+
"_boss3d/vendor/three.min.js",
|
| 23 |
+
"nfsmw_remake/nfscore.js",
|
| 24 |
+
"nfsmw_remake/game.js",
|
| 25 |
+
"nfsmw_remake/rivals.js",
|
| 26 |
+
"nfsmw_remake/modes_tollbooth.js",
|
| 27 |
+
"nfsmw_remake/modes_drag.js",
|
| 28 |
+
"nfsmw_remake/modes_speedtrap.js",
|
| 29 |
+
"nfsmw_remake/modes_knockout.js",
|
| 30 |
+
"nfsmw_remake/cops.js",
|
| 31 |
+
"nfsmw_remake/modes_pursuit.js",
|
| 32 |
+
"nfsmw_remake/scripted.js",
|
| 33 |
+
"nfsmw_remake/renderer3d.js",
|
| 34 |
+
"nfsmw_remake/draw.js"
|
| 35 |
+
],
|
| 36 |
+
"sim_scripts": [
|
| 37 |
+
"_native/runtime.js",
|
| 38 |
+
"nfsmw_remake/nfscore.js",
|
| 39 |
+
"nfsmw_remake/game.js",
|
| 40 |
+
"nfsmw_remake/rivals.js",
|
| 41 |
+
"nfsmw_remake/modes_tollbooth.js",
|
| 42 |
+
"nfsmw_remake/modes_drag.js",
|
| 43 |
+
"nfsmw_remake/modes_speedtrap.js",
|
| 44 |
+
"nfsmw_remake/modes_knockout.js",
|
| 45 |
+
"nfsmw_remake/cops.js",
|
| 46 |
+
"nfsmw_remake/modes_pursuit.js",
|
| 47 |
+
"nfsmw_remake/scripted.js"
|
| 48 |
+
],
|
| 49 |
+
"play_page": "web/games/nfsmw_remake/index.html",
|
| 50 |
+
"scripted_controller": "NfsmwGame.scripted(game) -> {holds:[6 key arrays], mouse:[0,0,0]}; pure car-model look-ahead, others extrapolated at constant speed (NfsmwGame.oracle is an alias)",
|
| 51 |
+
"tests": [
|
| 52 |
+
"nfsmw_remake/tests/mechanics.js"
|
| 53 |
+
],
|
| 54 |
+
"source": "https://github.com/dbalatoni13/nfsmw/tree/80993f35224c61d2f1b135beba76c6f8234c7940 (CC0-1.0)"
|
| 55 |
+
}
|
environments/games/web/games/nfsmw_remake/modes_drag.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Drag (GRace.h kRaceType_Drag), run as a series the way a Blacklist rival is fought (Wikipedia: "win against the racer in a
|
| 2 |
+
successive series of races"). Rules that exist only here, all from the decompilation:
|
| 3 |
+
- manual gearbox with a perfect-shift bonus (EngineRacer EPerfectShift; the window width is VLT, approximation);
|
| 4 |
+
- over-rev heat, EngineRacer.cpp:1340-1345: +0.45/s on the limiter, -0.1/s otherwise, torque -25% from 0.6, blown at 1;
|
| 5 |
+
- the car steers itself and the driver changes lanes (AIVehicle.cpp IsDragSteering, ChangeDragLanes);
|
| 6 |
+
- total on hard contact, DamageDragster.cpp: above 100 mph, losing more than 40 mph in one impact destroys the car;
|
| 7 |
+
- launch: GetPerfectLaunchRange, EngineRacer.cpp:127-135 (a band a quarter of the rev range below the redline).
|
| 8 |
+
boss_hp = metres left in the whole series; player_hp = metres the rival still needs in this heat. */
|
| 9 |
+
(function (root) {
|
| 10 |
+
'use strict';
|
| 11 |
+
const M = root.NfsmwGame, C = M.C, clamp = C.clamp;
|
| 12 |
+
const MPH = C.MPH, KILL_SPEED = 100 * MPH, KILL_DELTA = 40 * MPH, STAGE = 2.5; // AIActionRace.cpp:99 Tweak_UnstageTime
|
| 13 |
+
const LANES = [-7.5, -2.5, 2.5, 7.5], REV_UP = 1.5, REV_DOWN = 1.1, LAUNCH = [0.62, 0.86], START_S = 60, LANE_RATE = 7, LANE_GAIN = 2.2;
|
| 14 |
+
const startHeat = g => {
|
| 15 |
+
const lane = g.heat % 2 ? 2 : 1, rl = g.heat % 2 ? 1 : 2;
|
| 16 |
+
g.placeCar(START_S, LANES[lane]); g.s0 = START_S; g.lane = lane; g.pre = STAGE; g.rev = 0; g.prevV = 0; g.heatProg = 0;
|
| 17 |
+
g.gates = [{ s: START_S + g.heatLen, at: g.heatLen, done: 0 }];
|
| 18 |
+
g.rivals = [M.newRival(g, { s: START_S, lat: LANES[rl], skill: clamp(g.rivalSkill + M.formOf(g), 0, 1), drag: true, paint: 1 })];
|
| 19 |
+
g.traffic = []; M.spawnTraffic(g, g.trafficN, { opposing: 0, lanes: LANES, spread: Math.max(0, g.heatLen - 240), ahead: 140 });
|
| 20 |
+
// highwater across heats: every heat restarts the car at the line, and prog is measured from heatBase
|
| 21 |
+
g.prog = 0; g.total = g.heatLen;
|
| 22 |
+
};
|
| 23 |
+
M.MODES.drag = {
|
| 24 |
+
route: () => 'strip',
|
| 25 |
+
init(g, d) {
|
| 26 |
+
g.P = Object.assign({}, C.PLAYER, { overheat: true });
|
| 27 |
+
g.manual = 1; g.noGlue = 1;
|
| 28 |
+
g.heats = Math.round(M.tierValue(d, [1, 2, 6])); g.heatLen = M.tierValue(d, [1000, 1500, 1500]); g.seriesLen = g.heats * g.heatLen;
|
| 29 |
+
g.rivalSkill = M.tierValue(d, [0.2, 0.5, 0.8]); g.trafficN = Math.round(M.tierValue(d, [3, 6, 10]));
|
| 30 |
+
g.heat = 0; g.launch = 0;
|
| 31 |
+
startHeat(g);
|
| 32 |
+
},
|
| 33 |
+
staging(g, keys, pressed, dt) {
|
| 34 |
+
g.rev = clamp(g.rev + (keys.has('W') ? REV_UP : -REV_DOWN) * dt, 0, 1);
|
| 35 |
+
if (g.pre <= 0) { const inBand = g.rev >= LAUNCH[0] && g.rev <= LAUNCH[1]; g.launch = inBand ? 1 : 0; if (inBand) { g.car.bonus = 1.2; g.events.push({ type: 'perfect_launch' }); } else if (g.rev > LAUNCH[1]) g.car.clutch = 0.45; }
|
| 36 |
+
g.prevV = 0;
|
| 37 |
+
},
|
| 38 |
+
idle(g) { for (const r of g.rivals) { const a = C.routeAt(g.route, r.s, r.lat); r.x = a.x; r.y = a.y; r.h = a.h; } },
|
| 39 |
+
input(g, inp, keys, pressed) {
|
| 40 |
+
if (pressed.has('A') && g.lane < LANES.length - 1) g.lane++;
|
| 41 |
+
if (pressed.has('D') && g.lane > 0) g.lane--;
|
| 42 |
+
// Lane keeper: the driver has no wheel here (IsDragSteering), a fixed servo turns the lane error into steering.
|
| 43 |
+
const R = g.route, c = g.car, a = C.routeAt(R, g.s), lat = C.routeLat(R, c.x, c.y, g.s), v = Math.max(C.speed(c), 6);
|
| 44 |
+
let dh = c.h - a.h; dh = Math.atan2(Math.sin(dh), Math.cos(dh));
|
| 45 |
+
// Lateral error -> a heading limited to LANE_RATE across the road -> the yaw rate that reaches it -> the wheel for that rate.
|
| 46 |
+
const lim = LANE_RATE / v, want = clamp((LANES[g.lane] - lat) * LANE_GAIN / v, -lim, lim), full = v * Math.tan(C.steerRange(v / C.MPH) * Math.PI / 180) / C.PLAYER.wheelbase;
|
| 47 |
+
inp.steer = clamp((want - dh) * 3 / full, -1, 1); inp.hb = false;
|
| 48 |
+
},
|
| 49 |
+
tick(g, wdt) {
|
| 50 |
+
const c = g.car, v = C.speed(c);
|
| 51 |
+
if (g.prevV > KILL_SPEED && g.prevV - v > KILL_DELTA) return g.lose('totaled');
|
| 52 |
+
g.prevV = v;
|
| 53 |
+
if (c.blown) return g.lose('blown');
|
| 54 |
+
for (const r of g.rivals) M.stepRival(g, r, wdt);
|
| 55 |
+
const rv = g.rivals[0];
|
| 56 |
+
if (g.prog >= g.heatLen) {
|
| 57 |
+
g.events.push({ type: 'heat_won', heat: g.heat, gap: g.heatLen - rv.prog });
|
| 58 |
+
g.heat++;
|
| 59 |
+
if (g.heat >= g.heats) return g.win();
|
| 60 |
+
startHeat(g);
|
| 61 |
+
return;
|
| 62 |
+
}
|
| 63 |
+
if (rv.prog >= g.heatLen) g.lose('gap');
|
| 64 |
+
},
|
| 65 |
+
health(g) {
|
| 66 |
+
const rv = g.rivals[0], left = Math.max(0, g.heatLen - rv.prog), done = g.outcome === 'win' ? g.seriesLen : g.heat * g.heatLen + g.prog;
|
| 67 |
+
return [g.outcome === 'loss' ? 0 : left, g.heatLen, Math.max(0, g.seriesLen - done), g.seriesLen];
|
| 68 |
+
},
|
| 69 |
+
hud(g) { const rv = g.rivals[0]; return { label: 'Drag Race', detail: `Heat ${Math.min(g.heat + 1, g.heats)} / ${g.heats} · Rival needs ${Math.max(0, g.heatLen - rv.prog).toFixed(0)} m · ${g.pre > 0 ? 'RPM ' + Math.round(g.rev * 100) + '%' : 'Gear ' + (g.car.gear + 1)}` }; },
|
| 70 |
+
// Reference: launch inside the band, shift inside the window, change lanes for traffic, nitrous when nothing is close.
|
| 71 |
+
scripted(g) {
|
| 72 |
+
const holds = [[], [], [], [], [], []], c = g.car;
|
| 73 |
+
if (g.pre > 0) { // feather the throttle so the revs sit in the launch band when the lights go
|
| 74 |
+
let rev = g.rev, left = g.pre;
|
| 75 |
+
for (let i = 0; i < 6; i++) { const on = rev < (LAUNCH[0] + LAUNCH[1]) / 2 - 0.02 && left < 1.2; if (on) holds[i].push('W'); rev = clamp(rev + (on ? REV_UP : -REV_DOWN) * (2 / 60), 0, 1); left -= 2 / 60; }
|
| 76 |
+
return { holds, mouse: [0, 0, 0] };
|
| 77 |
+
}
|
| 78 |
+
const P = g.P, k = M.ctl.copyCar(c), fwd0 = Math.max(0, c.vx * Math.cos(c.h) + c.vy * Math.sin(c.h)); let press = -1;
|
| 79 |
+
// After a hit the box is still in a tall gear with almost no drive: one gear down per packet until the revs are useful.
|
| 80 |
+
const lug = c.gear > 0 && c.clutch <= 0 && fwd0 < C.TOPS[c.gear - 1] * 0.8;
|
| 81 |
+
for (let i = 0; i < 6; i++) {
|
| 82 |
+
const u = Math.max(0, k.vx * Math.cos(k.h) + k.vy * Math.sin(k.h)) / C.TOPS[k.gear];
|
| 83 |
+
if (press < 0 && k.gear < 5 && u >= 0.9) press = i;
|
| 84 |
+
C.carStep(k, { thr: 1, brk: false, steer: 0, hb: false, nos: false, manual: true, up: false, down: false, sbGrip: 0 }, 1 / 30, P);
|
| 85 |
+
}
|
| 86 |
+
// Lane plan: for each lane and a short wait before moving, the time until first contact with anything on the road.
|
| 87 |
+
const users = M.ctl.roadUsers(g, g.route), v = C.speed(c), lane = g.lane, HORIZON_S = 6, STAY_S = 3.4;
|
| 88 |
+
const contact = (target, wait) => {
|
| 89 |
+
// The same first-order lane servo the car runs (rate capped, gain LANE_GAIN), started 0.2 s late for the wheel to slew.
|
| 90 |
+
let lat = g.lat;
|
| 91 |
+
for (let t = 0.1; t < HORIZON_S; t += 0.1) {
|
| 92 |
+
if (t > wait + 0.2) lat += clamp((LANES[target] - lat) * LANE_GAIN, -LANE_RATE, LANE_RATE) * 0.1;
|
| 93 |
+
const sp = g.s + v * t;
|
| 94 |
+
for (const o of users) { const ds = o.s + o.vs * t - sp, ds0 = o.s + o.vs * (t - 0.1) - (g.s + v * (t - 0.1)); if (o.s > g.s + 1 && Math.abs(o.lat - lat) < 3.6 && ((ds > 1 && ds < 6.5) || (ds0 > 1 && ds <= 1))) return t; }
|
| 95 |
+
}
|
| 96 |
+
return HORIZON_S;
|
| 97 |
+
};
|
| 98 |
+
const here = contact(lane, 0);
|
| 99 |
+
let bestT = here, go = lane;
|
| 100 |
+
// Stay put until contact is near: a move costs nothing only if nothing else is decided on the way. Then take the lane
|
| 101 |
+
// that stays clear longest, nearer lanes first on a tie. A wrong late move is cheaper than weaving through everything.
|
| 102 |
+
if (here < STAY_S) { let bs = here; for (let l = 0; l < LANES.length; l++) { if (l === lane) continue; const t = contact(l, 0), v2 = t - 0.25 * Math.abs(l - lane); if (t > here + 0.5 && v2 > bs) { bs = v2; bestT = t; go = l; } } }
|
| 103 |
+
const move = Math.sign(go - lane);
|
| 104 |
+
// A blocked lane with nowhere to go: braking costs seconds on this gearing, a total above 100 mph costs the event.
|
| 105 |
+
const blocked = bestT < 0.8 && !move, coast = bestT < 1.2 && !move;
|
| 106 |
+
// Top gear on the limiter only cooks the engine (EngineRacer.cpp:1340): lift until the speed is back under it.
|
| 107 |
+
const onLimiter = c.gear === 5 && Math.max(0, c.vx * Math.cos(c.h) + c.vy * Math.sin(c.h)) >= C.TOPS[5] * 0.995;
|
| 108 |
+
const nos = c.nos > 0.02 && v > 30 && here > 3 && c.clutch <= 0 && !c.over && v < C.TOPS[5] * 0.97;
|
| 109 |
+
for (let i = 0; i < 6; i++) { if (blocked) holds[i].push('S'); else if (!onLimiter && !coast) holds[i].push('W'); if (nos && !blocked) holds[i].push('Shift'); if (i === press && !lug) holds[i].push('K'); if (i === 0 && lug) holds[i].push('L'); if (i === 0 && move) holds[i].push(move > 0 ? 'A' : 'D'); }
|
| 110 |
+
return { holds, mouse: [0, 0, 0] };
|
| 111 |
+
},
|
| 112 |
+
};
|
| 113 |
+
})(typeof window === 'undefined' ? globalThis : window);
|
environments/games/web/games/nfsmw_remake/modes_knockout.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Lap Knockout (GRace.h kRaceType_Knockout; GRaceStatus.h GRacerInfo::KnockOut, mKnockedOut). A short downtown circuit at night:
|
| 2 |
+
when every car but one has finished the lap, that last car is out. One lap per rival, so the field sets the length.
|
| 3 |
+
boss_hp = route metres left in the whole event; player_hp = metres the slowest remaining rival still needs to finish this
|
| 4 |
+
lap (at 0 every rival is home and the player is the one knocked out). The field and the circuit are original: race data is VLT. */
|
| 5 |
+
(function (root) {
|
| 6 |
+
'use strict';
|
| 7 |
+
const M = root.NfsmwGame, C = M.C, S0 = 40, ROW = 9;
|
| 8 |
+
M.MODES.knockout = {
|
| 9 |
+
route: () => 'downtown',
|
| 10 |
+
init(g, d) {
|
| 11 |
+
const R = g.route, field = Math.round(M.tierValue(d, [1, 2, 5]));
|
| 12 |
+
// The grid is short of the line, so lap 1 is partial and its length is part of the event's pace.
|
| 13 |
+
const first = Math.min(R.L, M.tierValue(d, [420, 520, 694])), start = R.L - first + S0;
|
| 14 |
+
g.L = R.L; g.first = first; g.laps = field; g.total = first + (field - 1) * R.L; g.lap = 0; g.s0 = start; g.placeCar(start, -2.2);
|
| 15 |
+
const lo = M.tierValue(d, [0.12, 0.2, 0.3]), hi = M.tierValue(d, [0.12, 0.34, 0.62]);
|
| 16 |
+
g.rivals = [];
|
| 17 |
+
// Two columns, a full row apart: the player is alone on the last row. Skill runs from the back of the grid to the front, as a Blacklist field does.
|
| 18 |
+
for (let i = 0; i < field; i++) {
|
| 19 |
+
const r = M.newRival(g, { s: start + ROW * (Math.floor(i / 2) + 1), lat: i % 2 ? -2.2 : 2.2, skill: C.clamp((field > 1 ? C.lerp(lo, hi, i / (field - 1)) : lo) + M.formOf(g), 0, 1), paint: i % 4 });
|
| 20 |
+
r.s0 = start; r.prog = r.s - start; g.rivals.push(r);
|
| 21 |
+
}
|
| 22 |
+
g.gates = [{ s: R.L + S0, at: 0, kind: 'line', keep: 1, done: 0 }];
|
| 23 |
+
M.spawnTraffic(g, Math.round(M.tierValue(d, [0, 2, 3])), { ahead: 120, spread: 260, opposing: 0 });
|
| 24 |
+
},
|
| 25 |
+
idle() {},
|
| 26 |
+
tick(g, wdt) {
|
| 27 |
+
const alive = g.rivals.filter(r => !r.out);
|
| 28 |
+
for (const r of alive) M.stepRival(g, r, wdt);
|
| 29 |
+
// Rivals ride rails, so they part sideways here rather than drive through each other.
|
| 30 |
+
for (let i = 0; i < alive.length; i++) for (let j = i + 1; j < alive.length; j++) {
|
| 31 |
+
const a = alive[i], b = alive[j], ds = a.s - b.s, dl = a.lat - b.lat;
|
| 32 |
+
if (Math.abs(ds) < 6 && Math.abs(dl) < 3.2) { const push = (dl >= 0 ? 1 : -1) * 2.4 * wdt, e = g.route.halfW - 2.1; a.lat = C.clamp(a.lat + push, -e, e); b.lat = C.clamp(b.lat - push, -e, e); if (Math.abs(ds) < 4.4 && a.v !== b.v) { const back = ds < 0 ? a : b; back.v = Math.max(0, back.v - 6 * wdt); } }
|
| 33 |
+
}
|
| 34 |
+
const end = g.first + g.lap * g.L, pending = alive.filter(r => r.prog < end), youIn = g.prog >= end;
|
| 35 |
+
if (!youIn && pending.length === 0) return g.lose('knocked');
|
| 36 |
+
// <= 1, not === 1: two rivals crossing on the same tick take pending from 2 to 0, and the last car still goes out.
|
| 37 |
+
if (youIn && pending.length <= 1) {
|
| 38 |
+
const out = pending[0] || alive.reduce((a, b) => b.prog < a.prog ? b : a); out.out = 1; out.gone = 1; g.events.push({ type: 'knockout', lap: g.lap }); g.lap++;
|
| 39 |
+
if (g.rivals.every(r => r.out)) { g.prog = g.total; g.win(); }
|
| 40 |
+
}
|
| 41 |
+
},
|
| 42 |
+
health(g) {
|
| 43 |
+
const end = g.first + g.lap * g.L; let worst = 0;
|
| 44 |
+
for (const r of g.rivals) if (!r.out) worst = Math.max(worst, end - r.prog);
|
| 45 |
+
// A win knocks out the last rival, so no rival is left to measure: player_hp stays full rather than reading as a loss.
|
| 46 |
+
return [g.outcome === 'loss' ? 0 : g.outcome === 'win' ? g.L : C.clamp(worst, 0, g.L), g.L, g.outcome === 'win' ? 0 : Math.max(0, g.total - g.prog), g.total];
|
| 47 |
+
},
|
| 48 |
+
hud(g) { const alive = g.rivals.filter(r => !r.out); const place = 1 + alive.filter(r => r.prog > g.prog).length; return { label: 'Lap Knockout', detail: `Lap ${Math.min(g.lap + 1, g.laps)} / ${g.laps} · Place ${place} / ${alive.length + 1} · Last-place rival needs ${M.MODES.knockout.health(g)[0].toFixed(0)} m` }; }, // draw.js calls hud unbound: no `this`
|
| 49 |
+
// Reference: a tighter line, and slow motion (J, the public Speedbreaker key: +2 g of downforce) only while it would brake,
|
| 50 |
+
// for a corner or for a car ahead. Seeds 1-32: normal 22 -> 32, hard 24 -> 32.
|
| 51 |
+
scripted(g) {
|
| 52 |
+
const opt = { margin: 0.96 }, pk = M.ctl.drive(g, opt);
|
| 53 |
+
if (g.pre <= 0) { const why = M.ctl.planDrive(g, opt).why, want = why === 'speed' || why === 'contact'; if (want !== !!g.sb && (g.sb || g.sbMeter > 0.15) && pk.holds[0].length < 4) pk.holds[0].push('J'); }
|
| 54 |
+
return pk;
|
| 55 |
+
},
|
| 56 |
+
};
|
| 57 |
+
})(typeof window === 'undefined' ? globalThis : window);
|
environments/games/web/games/nfsmw_remake/modes_pursuit.js
ADDED
|
@@ -0,0 +1,437 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Free-roam pursuit (AI/Common/AIPursuit.cpp, rules listed in cops.js). The event is the Blacklist's own gate: raise a bounty, then get away.
|
| 2 |
+
Bounty accrues only while a cop can see the player (:1920 AddToPendingRepPointsNormal runs inside the in-sight branch) and in lumps for
|
| 3 |
+
destroying cops, with the multiplier up to 3 (:917). Then the evade meter must fill. Clearing a stage raises the heat: after the lock-out
|
| 4 |
+
(:2061 LockoutCops) a new pursuit starts at the next level. The heat values are VLT data, so every number below is an approximation.
|
| 5 |
+
Pursuit Breakers: EPursuitBreaker exists in the decompilation, the placement and radius are map data; here two per lap, original.
|
| 6 |
+
boss_hp = stages x 200 minus bounty and evade progress, both from high-water marks, so it never jumps back; player_hp = the bust meter. */
|
| 7 |
+
(function (root) {
|
| 8 |
+
'use strict';
|
| 9 |
+
const M = root.NfsmwGame, C = M.C, N = root.NativeBench, clamp = C.clamp;
|
| 10 |
+
const BOUNTY_UNITS = 100, EVADE_UNITS = 100, S0 = 5560, BREAKER_R = 46;
|
| 11 |
+
const heat = (g, d) => {
|
| 12 |
+
const lvl = g.stage / Math.max(1, g.stages - 1); // inside the event the heat climbs a little, tier sets the base
|
| 13 |
+
return { copsMax: Math.round(M.tierValue(d, [2, 3, 5])) + (g.stage > 1 ? 1 : 0), top: M.tierValue(d, [52, 66, 70]) + lvl * 4 };
|
| 14 |
+
};
|
| 15 |
+
const startStage = (g, d) => {
|
| 16 |
+
const p = g.pol, h = heat(g, d);
|
| 17 |
+
p.copsMax = h.copsMax; p.top = h.top; p.seen = 0; p.sinceSeen = 0; p.evade = 0; p.lockT = g.stage ? 3 : 0; p.spawnT = g.stage ? 3.5 : p.spawnGap;
|
| 18 |
+
g.stageBounty = 0; g.stageEvadeHW = 0;
|
| 19 |
+
if (!g.stage) { const c = M.spawnCop(g, g.s - 85, 2, 1); c.slot = 0; c.v = 34; }
|
| 20 |
+
else g.events.push({ type: 'heat_up', stage: g.stage });
|
| 21 |
+
};
|
| 22 |
+
// ---------------- Reference controllers for these two events (2026-11-11 recalibration). Only these two events call them; the shared
|
| 23 |
+
// planDrive / drive in scripted.js are untouched. Read decided state only (poses, timers, the episode seed), never the live RNG: the
|
| 24 |
+
// champion's look-ahead rolls copies forward in a fixed independent scenario. Both keep a little memory per game object (WeakMap); a
|
| 25 |
+
// repeated call on the same state returns the same packet (tests/leak_probe.js asks five times per packet).
|
| 26 |
+
|
| 27 |
+
// Pursuit. The strategy follows whether this heat level brings a helicopter (g.pol.heli, fixed when the pursuit starts; the HUD shows
|
| 28 |
+
// helicopter once one is up). In the block's tight corners the cops lose sight within seconds, so without a helicopter (250 m sight) the bounty
|
| 29 |
+
// stops growing there: d = 0.65-0.7 timed out 8/8 when the switch was the stage count instead.
|
| 30 |
+
// - no helicopter: the 11-06 controller. While bounty is owed, hold station just ahead of the chase so it keeps sight; once the 7 s in-sight
|
| 31 |
+
// grace (cops.js inSight, AIPursuit.cpp:2000) covers what is owed with 5 s to spare, or the bounty is full, run on the racing line with
|
| 32 |
+
// nitrous, through any Pursuit Breaker with a cop near. Same rule at every tier (the 11-06 version started early on easy only).
|
| 33 |
+
// - helicopter: the downtown block, ported from the 600-hour dataset pipeline's tools/trajectory_dataset/pursuit_recovery_source_v87.js
|
| 34 |
+
// (read-only there; its route table, path smoothing and follower, config speed 42, owed 34, lane spread 3). Into the block by one of
|
| 35 |
+
// five connector streets, laps of its tight corners until the stage clears, back out to the coast between stages.
|
| 36 |
+
// Added to both: blown tyres are reset once no chasing cop is within 95 m (11-06 rule); on the block, a cop within 6 m with the car under
|
| 37 |
+
// BustSpeed + 2 means it is pinned, so it floors it instead of braking for the corner.
|
| 38 |
+
const pursuitPolicy = (() => {
|
| 39 |
+
const HIDE = true, HIDE_GAP = 175, HIDE_SEE = 520, SPEED = 42, OWED = 34, REENTER_OWED = 8, LANE_SPREAD = 3, EARLY_MARGIN = 5, RESET_NEAR = 95, UNPIN_R = 6, FAR_COP = 110, MID_COP = 70, TOP_FAR = 20, TOP_MID = 30;
|
| 40 |
+
const memory = new WeakMap();
|
| 41 |
+
function choice(g) { let n = g.seed ^ Math.imul(g.stage + 1, 0x9e3779b1); n = Math.imul(n ^ (n >>> 16), 0x21f0aaad); n = Math.imul(n ^ (n >>> 15), 0x735a2d97); return ((n ^ (n >>> 15)) >>> 0) / 4294967296; }
|
| 42 |
+
const lane = g => (choice(g) - 0.5) * 2 * LANE_SPREAD;
|
| 43 |
+
// Connector streets from the coast road into the downtown block (nfscore.js STREETS), outer end first.
|
| 44 |
+
const routes = [[[0, -520], [0, -80]], [[420, -520], [420, 3], [46, 3]], [[-400, -520], [-400, 0], [-85, 0]], [[0, 400], [0, 80]], [[-400, 560], [-400, 0], [-85, 0]]];
|
| 45 |
+
const nearestCop = g => { let near = Infinity; for (const k of g.cops) if (!k.dead && k.state !== 'rb') near = Math.min(near, Math.hypot(g.car.x - k.x, g.car.y - k.y)); return near; };
|
| 46 |
+
function sixSteer(c, target, sp, scale) {
|
| 47 |
+
const rate = (sp < 15 ? 7 : sp < 40 ? 5 : 3.6) * scale / 30, keys = []; let st = c.steer;
|
| 48 |
+
for (let i = 0; i < 6; i++) { let k0 = 0, error = Infinity; for (const k of [0, 1, -1]) { const n = st + clamp(k - st, -rate, rate), e = Math.abs(n - target); if (e < error) { error = e; k0 = k; } } keys.push(k0); st += clamp(k0 - st, -rate, rate); }
|
| 49 |
+
return keys;
|
| 50 |
+
}
|
| 51 |
+
// Drop collinear points, then round each corner with the largest arc (16, 12, 8 m) that stays on the road.
|
| 52 |
+
function smooth(points) {
|
| 53 |
+
const sparse = [points[0]];
|
| 54 |
+
for (let i = 1; i < points.length - 1; i++) {
|
| 55 |
+
const a = sparse[sparse.length - 1], b = points[i], c = points[i + 1], ux = b[0] - a[0], uy = b[1] - a[1], vx = c[0] - b[0], vy = c[1] - b[1], L = Math.hypot(ux, uy) * Math.hypot(vx, vy);
|
| 56 |
+
if (L < 0.01) continue;
|
| 57 |
+
if (Math.abs(ux * vy - uy * vx) / L < 0.01 && (ux * vx + uy * vy) / L > 0.999) continue;
|
| 58 |
+
sparse.push(b);
|
| 59 |
+
}
|
| 60 |
+
sparse.push(points[points.length - 1]); points = sparse;
|
| 61 |
+
const out = [points[0]];
|
| 62 |
+
for (let i = 1; i < points.length - 1; i++) {
|
| 63 |
+
const a = points[i - 1], b = points[i], c = points[i + 1], la = Math.hypot(b[0] - a[0], b[1] - a[1]), lc = Math.hypot(c[0] - b[0], c[1] - b[1]);
|
| 64 |
+
if (la < 30 || lc < 30) { out.push(b); continue; }
|
| 65 |
+
const ux = (a[0] - b[0]) / la, uy = (a[1] - b[1]) / la, vx = (c[0] - b[0]) / lc, vy = (c[1] - b[1]) / lc;
|
| 66 |
+
const theta = Math.acos(clamp(ux * vx + uy * vy, -1, 1)); if (theta < 0.3 || theta > 2.9) { out.push(b); continue; }
|
| 67 |
+
let arc = null;
|
| 68 |
+
for (const radius of [16, 12, 8]) {
|
| 69 |
+
const tangent = radius / Math.tan(theta / 2); if (tangent > Math.min(la, lc) * 0.4) continue;
|
| 70 |
+
const hl = Math.hypot(ux + vx, uy + vy), distance = radius / Math.sin(theta / 2), cx = b[0] + (ux + vx) / hl * distance, cy = b[1] + (uy + vy) / hl * distance;
|
| 71 |
+
const ax = b[0] + ux * tangent, ay = b[1] + uy * tangent, angle = Math.atan2(ay - cy, ax - cx), sign = -Math.sign(ux * vy - uy * vx), sweep = Math.PI - theta;
|
| 72 |
+
const n = Math.ceil(radius * sweep / 2), candidate = [];
|
| 73 |
+
for (let j = 0; j <= n; j++) { const t = angle + sign * sweep * j / n; candidate.push([cx + Math.cos(t) * radius, cy + Math.sin(t) * radius]); }
|
| 74 |
+
if (candidate.every(p => C.road(p[0], p[1]).d < -1.8)) { arc = candidate; break; }
|
| 75 |
+
}
|
| 76 |
+
out.push(...(arc || [b]));
|
| 77 |
+
}
|
| 78 |
+
out.push(points[points.length - 1]); return out;
|
| 79 |
+
}
|
| 80 |
+
// Pure pursuit along mem.points, speed limited by the path's curvature and the tyres; null at the end of the path.
|
| 81 |
+
function follow(g, mem) {
|
| 82 |
+
if (mem.rawPoints !== mem.points) { mem.points = smooth(mem.points); mem.rawPoints = mem.points; }
|
| 83 |
+
const c = g.car, sp = C.speed(c), points = mem.points; let i = mem.i;
|
| 84 |
+
while (i < points.length - 1) { const a = points[i], b = points[i + 1], dx = b[0] - a[0], dy = b[1] - a[1], l2 = dx * dx + dy * dy; const t = ((c.x - a[0]) * dx + (c.y - a[1]) * dy) / l2; if (t > 1 || Math.hypot(c.x - b[0], c.y - b[1]) < 3.5) { i++; continue; } break; }
|
| 85 |
+
mem.i = i;
|
| 86 |
+
if (i >= points.length - 1) return null;
|
| 87 |
+
const a = points[i], b = points[i + 1], dx = b[0] - a[0], dy = b[1] - a[1], length = Math.hypot(dx, dy);
|
| 88 |
+
const t = clamp(((c.x - a[0]) * dx + (c.y - a[1]) * dy) / (length * length), 0, 1), remaining = length * (1 - t);
|
| 89 |
+
let look = Math.max(5, sp * 0.45), x = a[0] + dx * t, y = a[1] + dy * t, j = i;
|
| 90 |
+
while (look > 0 && j < points.length - 1) { const dest = points[j + 1], d = Math.hypot(dest[0] - x, dest[1] - y); if (d >= look) { x += (dest[0] - x) * look / d; y += (dest[1] - y) * look / d; break; } look -= d; x = dest[0]; y = dest[1]; j++; }
|
| 91 |
+
const lag = 0.1 * (g.sb ? 0.45 : 1); let angle = Math.atan2(y - c.y - c.vy * lag, x - c.x - c.vx * lag) - c.h - c.r * lag; angle = Math.atan2(Math.sin(angle), Math.cos(angle));
|
| 92 |
+
const L = Math.max(3, Math.hypot(x - c.x, y - c.y)), kappa = 2 * Math.sin(angle) / L;
|
| 93 |
+
const nose = C.road(c.x + Math.cos(c.h) * 3.2, c.y + Math.sin(c.h) * 3.2).d > -0.5;
|
| 94 |
+
if (sp < 7 && (Math.abs(angle) > 0.9 || nose)) {
|
| 95 |
+
const clear = C.road(c.x - Math.cos(c.h) * 3.5, c.y - Math.sin(c.h) * 3.5).d < -0.6, side = angle > 0 ? 1 : -1;
|
| 96 |
+
const pk = M.ctl.toPacket({ keys: sixSteer(c, clear ? -side : side, sp, g.sb ? 0.45 : 1), thr: clear ? 0 : 6, brk: clear, nos: false });
|
| 97 |
+
if (g.sb) pk.holds[0].push('J'); return pk;
|
| 98 |
+
}
|
| 99 |
+
const target = clamp(Math.atan(kappa * C.PLAYER.wheelbase) / (C.steerRange(sp / C.MPH) * Math.PI / 180), -1, 1);
|
| 100 |
+
const end = !mem.continuous && i + 1 === points.length - 1;
|
| 101 |
+
let future = SPEED, ds = -length * t, upcoming = 0;
|
| 102 |
+
const grip = (C.PLAYER.grip + (g.sb ? 19.62 : 0)) * C.tireFactor(c) * 0.78;
|
| 103 |
+
for (let k = i; k < points.length - 2 && ds < 150; k++) {
|
| 104 |
+
const a = points[k], b = points[k + 1], c0 = points[k + 2], d1 = Math.hypot(b[0] - a[0], b[1] - a[1]), d2 = Math.hypot(c0[0] - b[0], c0[1] - b[1]), d3 = Math.hypot(c0[0] - a[0], c0[1] - a[1]);
|
| 105 |
+
ds += d1; const curv = Math.abs(2 * ((b[0] - a[0]) * (c0[1] - b[1]) - (b[1] - a[1]) * (c0[0] - b[0])) / Math.max(0.001, d1 * d2 * d3));
|
| 106 |
+
if (ds < sp * 1.5 + 10) upcoming = Math.max(upcoming, curv);
|
| 107 |
+
if (curv > 0.0001) future = Math.min(future, Math.sqrt(grip / curv + 2 * 8 * Math.max(0, ds - 6)));
|
| 108 |
+
}
|
| 109 |
+
const limit = Math.min(future, Math.sqrt(grip / (Math.abs(kappa) + 0.0001)), end ? Math.sqrt(2 * 8 * Math.max(0, remaining - 3)) : SPEED);
|
| 110 |
+
const brk = sp > limit + 0.8, keys = sixSteer(c, brk ? target / 1.45 : target, sp, g.sb ? 0.45 : 1);
|
| 111 |
+
const spare = Math.max(0, 1 - sp * sp * Math.abs(kappa) / grip);
|
| 112 |
+
const thr = Math.max(1, Math.min(6, Math.round(6 * spare / 0.55)));
|
| 113 |
+
let pinned = false; for (const k of g.cops) if (!k.dead && k.state !== 'rb' && Math.hypot(c.x - k.x, c.y - k.y) < UNPIN_R) pinned = true;
|
| 114 |
+
pinned = pinned && sp < g.pol.bustSpeed + 2;
|
| 115 |
+
const pk = pinned ? M.ctl.toPacket({ keys: sixSteer(c, target, sp, g.sb ? 0.45 : 1), thr: 6, brk: false, nos: c.nos > 0.02 }) : M.ctl.toPacket({ keys, thr: brk ? 0 : thr, brk, nos: false });
|
| 116 |
+
const want = (upcoming > 0.035 || Math.abs(angle) > 0.3) && sp > 10;
|
| 117 |
+
if (want !== !!g.sb && (g.sb || g.sbMeter > 0.2) && pk.holds[0].length < 4) pk.holds[0].push('J');
|
| 118 |
+
return pk;
|
| 119 |
+
}
|
| 120 |
+
const nearestS = (R, x, y) => { let best = 0, dist = Infinity; for (let i = 0; i < R.n; i++) { const d = Math.hypot(R.x[i] - x, R.y[i] - y); if (d < dist) { dist = d; best = i * R.ds; } } return best; };
|
| 121 |
+
// One lap of the downtown block starting at the point nearest (x, y). routeAt returns one shared object: copy before the next call.
|
| 122 |
+
function lapFrom(x, y) { const R = C.routes.downtown, best = nearestS(R, x, y), pts = []; for (let s = 4; s < R.L + 4; s += 4) { const p = C.routeAt(R, best + s); pts.push([p.x, p.y]); } const last = C.routeAt(R, best); pts.push([last.x, last.y]); return pts; }
|
| 123 |
+
function startReturn(g, mem, escape, entryS) {
|
| 124 |
+
const join = { ...C.routeAt(g.route, entryS + 35) };
|
| 125 |
+
mem.points = [[g.car.x, g.car.y], ...escape.slice(0, -1).reverse(), [join.x, join.y]]; mem.i = 0; mem.mode = 'return'; mem.continuous = false; mem.returnPending = false;
|
| 126 |
+
mem.escape = escape; mem.entryS = entryS;
|
| 127 |
+
}
|
| 128 |
+
// One heat stage: the 11-06 coast run.
|
| 129 |
+
function coastRun(g, owed, p) {
|
| 130 |
+
const R = g.route, nearest = nearestCop(g), opt = { ram: true }, covered = 7 - p.sinceSeen - EARLY_MARGIN > owed;
|
| 131 |
+
// Hide: bounty full, nobody sees the car, and a roadblock is already set up ahead (g.blocks, decided state). Driving past it re-sights the
|
| 132 |
+
// car (50 m all round, AIVehicleCopCar.cpp:88-89) and restarts the 7 s + evade clock; instead stop HIDE_GAP m short of it, outside its
|
| 133 |
+
// 150 m view, and let the evade meter run. A car under 15 m/s draws no new roadblock (cops.js stepRoadblocks).
|
| 134 |
+
if (HIDE && owed <= 0 && !p.sawNow) { let ahead = Infinity; for (const b of g.blocks) { const ds = M.wrapTo(R, b.s, g.s) - g.s; if (ds > 0 && ds < ahead) ahead = ds; }
|
| 135 |
+
if (ahead < HIDE_SEE) { const room = ahead - HIDE_GAP, sp = C.speed(g.car); if (room < 3) return M.ctl.toPacket({ thr: 0, brk: sp > 2, nos: false }); return M.ctl.drive(g, { ram: true, nos: false, top: Math.max(4, Math.sqrt(2 * 8 * Math.max(0, room - 3))) }); } }
|
| 136 |
+
if (owed > 0 && !covered) { opt.nos = false; if (nearest > FAR_COP || !p.sawNow) opt.top = TOP_FAR; else if (nearest > MID_COP) opt.top = TOP_MID; }
|
| 137 |
+
if (owed <= 0 || covered) for (const b of g.breakers) { const ds = M.wrapTo(R, b.s, g.s) - g.s; if (ds > 0 && ds < 130 && !b.rearm && nearest < 90) opt.lat = b.lat; }
|
| 138 |
+
return M.ctl.drive(g, opt);
|
| 139 |
+
}
|
| 140 |
+
return function policy(g) {
|
| 141 |
+
let mem = memory.get(g); if (!mem) { mem = { stage: g.stage, mode: 'coast' }; memory.set(g, mem); }
|
| 142 |
+
if (g.car.tires > 0 && g.flash <= 0 && nearestCop(g) > RESET_NEAR) { mem.mode = 'coast'; mem.reenter = mem.reenter || g.bountyNeed - g.stageBounty > 0; return { holds: [['R'], [], [], [], [], []], mouse: [0, 0, 0] }; }
|
| 143 |
+
const owed = g.bountyNeed - g.stageBounty, p = g.pol;
|
| 144 |
+
if (!g.pol.heli) return coastRun(g, owed, p);
|
| 145 |
+
if (g.stage !== mem.stage) {
|
| 146 |
+
mem.stage = g.stage;
|
| 147 |
+
if (mem.mode === 'city') mem.returnPending = false;
|
| 148 |
+
else if (mem.mode !== 'coast') startReturn(g, mem, mem.escape, mem.entryS);
|
| 149 |
+
}
|
| 150 |
+
if (mem.mode === 'city') {
|
| 151 |
+
const pk = follow(g, mem); if (pk) return pk;
|
| 152 |
+
if (mem.returnPending) { startReturn(g, mem, mem.escape, mem.entryS); return follow(g, mem); }
|
| 153 |
+
mem.points = [[g.car.x, g.car.y], ...mem.cityPoints]; mem.i = 0; return follow(g, mem);
|
| 154 |
+
}
|
| 155 |
+
if (mem.mode === 'return' || mem.mode === 'inside') {
|
| 156 |
+
if (mem.mode === 'inside' && mem.i >= mem.points.length - 2) mem.continuous = true;
|
| 157 |
+
const pk = follow(g, mem); if (pk) return pk;
|
| 158 |
+
mem.continuous = false; mem.mode = 'coast';
|
| 159 |
+
}
|
| 160 |
+
if (mem.mode === 'coast' && owed <= (mem.reenter ? REENTER_OWED : OWED)) {
|
| 161 |
+
mem.reenter = false;
|
| 162 |
+
const R = g.route, choices = routes.map(points => { const best = nearestS(R, points[0][0], points[0][1]); let ds = (best - g.s) % R.L; if (ds < 30) ds += R.L; return { points, s: g.s + ds, ds }; });
|
| 163 |
+
const ranked = choices.sort((a, b) => a.ds - b.ds), options = ranked.filter(r => r.ds < ranked[0].ds + 1100).slice(0, 3);
|
| 164 |
+
const target = options[Math.min(options.length - 1, Math.floor(choice(g) * options.length))];
|
| 165 |
+
mem.escape = target.points.map(q => q.slice()); mem.entryS = target.s; mem.mode = 'approach';
|
| 166 |
+
}
|
| 167 |
+
if (mem.mode === 'approach') {
|
| 168 |
+
const distance = mem.entryS - g.s;
|
| 169 |
+
if (distance < 100) {
|
| 170 |
+
const approach = { ...C.routeAt(g.route, mem.entryS - 150) }, end = mem.escape[mem.escape.length - 1];
|
| 171 |
+
mem.cityPoints = lapFrom(end[0], end[1]);
|
| 172 |
+
mem.points = [[approach.x, approach.y], ...mem.escape, ...mem.cityPoints]; mem.i = 0; mem.mode = 'city'; mem.continuous = true;
|
| 173 |
+
return follow(g, mem);
|
| 174 |
+
}
|
| 175 |
+
return M.ctl.drive(g, { ram: true, lat: lane(g), margin: 0.9, top: Math.min(70, Math.sqrt(12 * 12 + 2 * 8 * Math.max(0, distance - 12))) });
|
| 176 |
+
}
|
| 177 |
+
return M.ctl.drive(g, { ram: true, lat: lane(g), margin: 0.9 });
|
| 178 |
+
};
|
| 179 |
+
})();
|
| 180 |
+
|
| 181 |
+
// Street champion. Ported from the dataset pipeline's tools/trajectory_dataset/street_interaction_source_v42.js (read-only there). v42
|
| 182 |
+
// replaced the page's M.ctl with a modified copy of scripted.js; here that copy is private to this event. Kept from v42: lane choice with
|
| 183 |
+
// hysteresis, Speedbreaker grip in the racing line and friction circle, and each packet picks one of nine driving choices by rolling copies
|
| 184 |
+
// of the game 120 ticks forward with the RNG set to one fixed scenario (never the live RNG). Added: blown tyres are reset once no chasing
|
| 185 |
+
// cop is within 95 m (the 11-06 rule v42 dropped), and a roadblock already placed ahead (g.blocks, decided state) adds its widest gap as a
|
| 186 |
+
// candidate lane and pulls the score towards it: a 2 s rollout cannot see a block 300 m away, and at 55 m/s the car cannot cross the
|
| 187 |
+
// road in the 2 s it does see (seeds 4, 8, 13, 22, 24 hard: busted or out-run behind a block).
|
| 188 |
+
const championPolicy = (() => {
|
| 189 |
+
const HOLD_SETS = 6, DT = 1 / 60, CONTACT = 3.5, RESET_NEAR = 95, GAP_AHEAD = 360, GAP_CLEAR = 3.3, GAP_EDGE = 1.6, GAP_PULL = 8;
|
| 190 |
+
const laneMem = new WeakMap();
|
| 191 |
+
function laneTarget(g, R, S, others, speed, base) {
|
| 192 |
+
const edge = R.halfW - 2.2, prev = laneMem.get(g) ?? g.lat;
|
| 193 |
+
const lanes = [clamp(prev, -edge, edge), base, -edge, edge, -edge * .5, 0, edge * .5];
|
| 194 |
+
let best = lanes[0], bs = -Infinity;
|
| 195 |
+
for (const lat of lanes) {
|
| 196 |
+
let sc = -Math.abs(lat - prev) * 3 - .15 * Math.abs(lat - base);
|
| 197 |
+
for (const o of others) {
|
| 198 |
+
const ds = o.s - S; if (ds < -10 || ds > 200) continue;
|
| 199 |
+
const closing = speed - o.vs, tt = closing > 1 ? Math.max(0, ds) / closing : ds < 30 ? 0.5 : 99;
|
| 200 |
+
if (tt > 4) continue;
|
| 201 |
+
const gap = Math.abs(o.lat + (o.vl || 0) * Math.min(tt, 1) - lat);
|
| 202 |
+
if (gap < 3.8) sc -= (3.8 - gap) * (5 - tt) * 5;
|
| 203 |
+
}
|
| 204 |
+
if (sc > bs) { bs = sc; best = lat; }
|
| 205 |
+
}
|
| 206 |
+
laneMem.set(g, best); return best;
|
| 207 |
+
}
|
| 208 |
+
function roadUsers(g, R) {
|
| 209 |
+
const out = [], L = R.L;
|
| 210 |
+
const near = v => { if (!R.loop) return v; let ds = (v - g.s) % L; if (ds > L / 2) ds -= L; else if (ds < -L / 2) ds += L; return Math.abs(v - g.s) <= L / 2 ? v : g.s + ds; };
|
| 211 |
+
for (const t of g.traffic) out.push({ s: near(t.s), lat: t.lat, vs: t.crash ? 0 : t.v, r: 2 });
|
| 212 |
+
for (const r of g.rivals) if (!r.out) out.push({ s: near(r.s), lat: r.lat, vs: r.v, r: 2, a: r.v < 25 ? 5 : 0 });
|
| 213 |
+
M.copUsers(g, R, out);
|
| 214 |
+
return out;
|
| 215 |
+
}
|
| 216 |
+
const lines = new Map();
|
| 217 |
+
function racingLine(R, P, grip, brake, top) {
|
| 218 |
+
let L = lines.get(R.name);
|
| 219 |
+
if (!L) {
|
| 220 |
+
const n = R.n, lat = new Float64Array(n), edge = R.halfW - 2.4, wrap = i => R.loop ? (i + n) % n : Math.max(0, Math.min(n - 1, i)), K = Math.max(2, Math.round(10 / R.ds));
|
| 221 |
+
const nx = i => -Math.sin(R.h[i]), ny = i => Math.cos(R.h[i]), px = i => R.x[i] + nx(i) * lat[i], py = i => R.y[i] + ny(i) * lat[i];
|
| 222 |
+
for (let it = 0; it < 400; it++) for (let i = 0; i < n; i++) { const a = wrap(i - K), b = wrap(i + K), tx = (px(a) + px(b)) / 2 - px(i), ty = (py(a) + py(b)) / 2 - py(i); lat[i] = clamp(lat[i] + 0.5 * (tx * nx(i) + ty * ny(i)), -edge, edge); }
|
| 223 |
+
const kap = new Float64Array(n);
|
| 224 |
+
for (let i = 0; i < n; i++) { const a = wrap(i - K), b = wrap(i + K), x1 = px(i) - px(a), y1 = py(i) - py(a), x2 = px(b) - px(i), y2 = py(b) - py(i), l1 = Math.hypot(x1, y1), l2 = Math.hypot(x2, y2), l3 = Math.hypot(x1 + x2, y1 + y2); kap[i] = l1 && l2 && l3 ? Math.abs(2 * (x1 * y2 - y1 * x2) / (l1 * l2 * l3)) : 0; }
|
| 225 |
+
L = { lat, kap, prof: new Map() }; lines.set(R.name, L);
|
| 226 |
+
}
|
| 227 |
+
const key = [grip, brake, top].map(v => v.toFixed(3)).join('|'); let v = L.prof.get(key);
|
| 228 |
+
if (!v) {
|
| 229 |
+
v = new Float64Array(R.n);
|
| 230 |
+
for (let i = 0; i < R.n; i++) v[i] = L.kap[i] > P.aero + 1e-5 ? Math.min(top, Math.sqrt(grip / (L.kap[i] - P.aero))) : top;
|
| 231 |
+
for (let p = 0; p < (R.loop ? 2 : 1); p++) for (let i = R.n - 1; i >= 0; i--) { const j = i + 1 < R.n ? i + 1 : R.loop ? 0 : i, lim = Math.sqrt(v[j] * v[j] + 2 * brake * R.ds); if (lim < v[i]) v[i] = lim; }
|
| 232 |
+
L.prof.set(key, v);
|
| 233 |
+
}
|
| 234 |
+
return { lat: L.lat, prof: v };
|
| 235 |
+
}
|
| 236 |
+
const lineLat = (R, lat, s) => { let i = Math.round(s / R.ds); if (R.loop) { i %= R.n; if (i < 0) i += R.n; } else i = clamp(i, 0, R.n - 1); return lat[i]; };
|
| 237 |
+
function contactTime(g, others, S, speed, lat) {
|
| 238 |
+
const rate = 4, HORIZON_S = 3;
|
| 239 |
+
for (let t = 0.1; t < HORIZON_S; t += 0.1) {
|
| 240 |
+
const dl = lat - g.lat, l = g.lat + Math.sign(dl) * Math.min(Math.abs(dl), rate * t), sp = S + speed * t;
|
| 241 |
+
for (const o of others) {
|
| 242 |
+
if (o.s <= S) continue;
|
| 243 |
+
const ol = o.lat + (o.vl || 0) * Math.min(t, 2), ds = o.s + o.vs * t + 0.5 * (o.a || 0) * t * t - sp, t0 = t - 0.1, ds0 = o.s + o.vs * t0 + 0.5 * (o.a || 0) * t0 * t0 - (S + speed * t0);
|
| 244 |
+
if (Math.abs(ol - l) < CONTACT && ((ds > 0 && Math.hypot(ds, ol - l) < CONTACT) || (ds0 > 0 && ds <= 0))) return t;
|
| 245 |
+
}
|
| 246 |
+
}
|
| 247 |
+
return HORIZON_S;
|
| 248 |
+
}
|
| 249 |
+
function steerKeys(c, target, speed, wscale) {
|
| 250 |
+
const rate = (speed < 15 ? 7 : speed < 40 ? 5 : 3.6) * wscale * 2 * DT, out = []; let st = c.steer;
|
| 251 |
+
for (let i = 0; i < HOLD_SETS; i++) {
|
| 252 |
+
let best = 0, bd = Infinity;
|
| 253 |
+
for (const k of [0, 1, -1]) { const n = st + clamp(k - st, -rate, rate), e = Math.abs(n - target); if (e < bd - 1e-9) { bd = e; best = k; } }
|
| 254 |
+
out.push(best); st += clamp(best - st, -rate, rate);
|
| 255 |
+
}
|
| 256 |
+
return out;
|
| 257 |
+
}
|
| 258 |
+
function planDrive(g, opt = {}) {
|
| 259 |
+
const R = g.route, c = g.car, P = g.P || C.PLAYER, S = g.s, speed = C.speed(c), tire = C.tireFactor(c);
|
| 260 |
+
const margin = opt.margin || 0.92, top = opt.top || C.TOPS[5], wscale = g.sb ? 0.45 : 1;
|
| 261 |
+
const line = racingLine(R, P, (P.grip + 19.62 * (g.sb ? 1 : g.sbRamp / (1 / 3))) * tire * margin, P.brake * 0.8, top), prof = line.prof;
|
| 262 |
+
const others = roadUsers(g, R), base = opt.lat !== undefined ? opt.lat : lineLat(R, line.lat, S + speed * 0.8), lat = opt.fixedLane ? base : laneTarget(g, R, S, others, speed, base), onLine = lat === base && opt.lat === undefined;
|
| 263 |
+
const lag = 0.1 * wscale, px = c.x + c.vx * lag, py = c.y + c.vy * lag, ph = c.h + c.r * lag, Ld = Math.max(7, speed * 0.62);
|
| 264 |
+
const sNear = C.routeNear(R, px, py, S, 8, 16), aim = C.routeAt(R, sNear + Ld, onLine ? lineLat(R, line.lat, sNear + Ld) : lat);
|
| 265 |
+
let alpha = Math.atan2(aim.y - py, aim.x - px) - ph; alpha = Math.atan2(Math.sin(alpha), Math.cos(alpha));
|
| 266 |
+
const far = C.routeAt(R, S + 18, lat); let off = Math.atan2(far.y - c.y, far.x - c.x) - c.h; off = Math.atan2(Math.sin(off), Math.cos(off));
|
| 267 |
+
const nose = C.road(c.x + Math.cos(c.h) * 3.2, c.y + Math.sin(c.h) * 3.2).d > -0.5;
|
| 268 |
+
if (speed < 7 && (Math.abs(off) > 0.9 || nose)) {
|
| 269 |
+
const clearBehind = C.road(c.x - Math.cos(c.h) * 3.5, c.y - Math.sin(c.h) * 3.5).d < -0.6, side = off > 0 ? 1 : -1;
|
| 270 |
+
return { keys: steerKeys(c, clearBehind ? -side : side, speed, wscale), thr: clearBehind ? 0 : HOLD_SETS, brk: clearBehind, nos: false, lat, contact: 3, why: 'recover' };
|
| 271 |
+
}
|
| 272 |
+
const kappa = 2 * Math.sin(alpha) / Ld, delta = Math.atan(kappa * P.wheelbase), range = C.steerRange(speed / C.MPH) * Math.PI / 180;
|
| 273 |
+
const vlim = Math.min(C.profileAt(R, prof, S + speed * 0.2), C.profileAt(R, prof, S + speed * 0.45));
|
| 274 |
+
const contact = contactTime(g, opt.ram ? others.filter(o => !o.cop) : others, S, speed, lat), over = speed > vlim + 0.8, brk = over || contact < 0.8, coast = !brk && contact < 1.2;
|
| 275 |
+
const grip = (P.grip + 19.62 * (g.sb ? 1 : g.sbRamp / (1 / 3)) + P.aero * speed * speed) * tire, ay = speed * speed * Math.abs(kappa), spare = Math.max(0, 1 - ay / grip);
|
| 276 |
+
const allowed = spare / 0.55 * grip * 1.1, drive = Math.max(1, C.driveAt(speed) * P.accel), thr = coast ? 0 : Math.round(HOLD_SETS * clamp(allowed / drive, 0.17, 1));
|
| 277 |
+
const nos = !brk && !coast && (opt.forceNos ? c.nos > 0.02 && speed > 12 : c.nos > 0.02 && speed > 18 && opt.nos !== false && thr === HOLD_SETS && C.profileAt(R, prof, S + speed * 1.8) > speed + 8);
|
| 278 |
+
return { keys: steerKeys(c, clamp(delta / range, -1, 1), speed, wscale), thr: brk ? 0 : thr, brk, nos, lat, contact, why: over ? 'speed' : contact < 0.8 ? 'contact' : coast ? 'coast' : 'drive' };
|
| 279 |
+
}
|
| 280 |
+
function toPacket(plan) {
|
| 281 |
+
const holds = [];
|
| 282 |
+
for (let i = 0; i < HOLD_SETS; i++) {
|
| 283 |
+
const h = [], k = plan.keys ? plan.keys[i] : 0;
|
| 284 |
+
if (plan.brk) h.push('S'); else if (plan.thr >= HOLD_SETS || Math.floor((i + 1) * plan.thr / HOLD_SETS) > Math.floor(i * plan.thr / HOLD_SETS)) h.push('W');
|
| 285 |
+
if (k) h.push(k > 0 ? 'A' : 'D');
|
| 286 |
+
if (plan.nos) h.push('Shift');
|
| 287 |
+
holds.push(h);
|
| 288 |
+
}
|
| 289 |
+
return { holds, mouse: [0, 0, 0] };
|
| 290 |
+
}
|
| 291 |
+
function packet(g, choice) {
|
| 292 |
+
if (g.pre > .21) return toPacket({ thr: HOLD_SETS, brk: false, nos: false });
|
| 293 |
+
const opt = { ram: true, margin: 1.02 }; if (choice.lat !== null) { opt.lat = choice.lat; opt.fixedLane = true; }
|
| 294 |
+
const p = planDrive(g, opt), sp = C.speed(g.car);
|
| 295 |
+
if (choice.gas && p.why !== 'recover') { p.brk = false; p.thr = 6; p.nos = g.car.nos > .02 && sp > 18; }
|
| 296 |
+
const pk = toPacket(p);
|
| 297 |
+
const sb = choice.sb === undefined ? (sp > 18 && (p.why === 'speed' || Math.abs(g.car.steer) > .65)) : choice.sb;
|
| 298 |
+
if (sb !== !!g.sb && (g.sb || g.sbMeter > .2) && pk.holds[0].length < 4) pk.holds[0].push('J');
|
| 299 |
+
return pk;
|
| 300 |
+
}
|
| 301 |
+
// Keys held at the end of the last packet, kept per game tick so a repeated call on one state starts every rollout from the same keys.
|
| 302 |
+
const heldMem = new WeakMap();
|
| 303 |
+
const heldBefore = g => { const m = heldMem.get(g); return !m ? [] : m.t === g.t ? m.prev : m.next; };
|
| 304 |
+
const heldAfter = (g, next) => heldMem.set(g, { t: g.t, prev: heldBefore(g), next });
|
| 305 |
+
function session(g, held) {
|
| 306 |
+
const s = Object.create(N.Session.prototype); s.module = M; s.game = M.copyGame(g);
|
| 307 |
+
s.game.rng = 2463534242; s.game.seed = 0; s.held = held.slice(); s.inputs = []; s.recording = false; s.events = []; // one fixed scenario, not the live draws
|
| 308 |
+
return s;
|
| 309 |
+
}
|
| 310 |
+
// The widest free stretch across the next roadblock within GAP_AHEAD m: between parked cars, barriers and the road edges.
|
| 311 |
+
function roadblockGap(g) {
|
| 312 |
+
const R = g.route, hw = R.halfW; let S = Infinity;
|
| 313 |
+
for (const b of g.blocks) { const bs = M.wrapTo(R, b.s, g.s); if (bs > g.s + 3 && bs < S) S = bs; }
|
| 314 |
+
if (S === Infinity || S - g.s > GAP_AHEAD) return null;
|
| 315 |
+
const occ = []; for (const b of g.blocks) if (Math.abs(M.wrapTo(R, b.s, g.s) - S) < 1) occ.push([b.lat - GAP_CLEAR, b.lat + GAP_CLEAR]);
|
| 316 |
+
occ.sort((x, y) => x[0] - y[0]);
|
| 317 |
+
let lo = -hw + GAP_EDGE, best = null; const hi = hw - GAP_EDGE;
|
| 318 |
+
for (const [x, y] of occ) { if (x > lo && (!best || Math.min(x, hi) - lo > best[1] - best[0])) best = [lo, Math.min(x, hi)]; lo = Math.max(lo, y); }
|
| 319 |
+
if (hi > lo && (!best || hi - lo > best[1] - best[0])) best = [lo, hi];
|
| 320 |
+
return best && best[1] > best[0] ? { s: S, lat: (best[0] + best[1]) / 2 } : null;
|
| 321 |
+
}
|
| 322 |
+
return function policy(g) {
|
| 323 |
+
if (g.car.tires > 0 && g.flash <= 0) {
|
| 324 |
+
let near = Infinity; for (const k of g.cops) if (!k.dead && k.state !== 'rb') near = Math.min(near, Math.hypot(g.car.x - k.x, g.car.y - k.y));
|
| 325 |
+
if (near > RESET_NEAR) { heldAfter(g, []); return { holds: [['R'], [], [], [], [], []], mouse: [0, 0, 0] }; }
|
| 326 |
+
}
|
| 327 |
+
const held = heldBefore(g), edge = g.route.halfW - 2.6;
|
| 328 |
+
const choices = [{ lat: null }, { lat: g.lat }, { lat: -edge * .85 }, { lat: edge * .85 }, { lat: -edge * .4 }, { lat: edge * .4 },
|
| 329 |
+
{ lat: null, gas: true }, { lat: g.lat, gas: true }, { lat: null, sb: true }];
|
| 330 |
+
const gap = roadblockGap(g); if (gap) choices.push({ lat: gap.lat }, { lat: gap.lat, gas: true });
|
| 331 |
+
let best = null, bestScore = -Infinity;
|
| 332 |
+
for (const choice of choices) {
|
| 333 |
+
const s = session(g, held), first = packet(s.game, choice); let proximity = 0;
|
| 334 |
+
for (let t = 0; t < 120 && !s.game.outcome; t += 12) {
|
| 335 |
+
s.packet(t === 0 ? first : packet(s.game, choice));
|
| 336 |
+
const z = s.game, sp = C.speed(z.car);
|
| 337 |
+
for (const cop of z.cops) if (!cop.dead && !cop.gone) { const d = Math.hypot(z.car.x - cop.x, z.car.y - cop.y); proximity = Math.max(proximity, Math.max(0, 4 - d) * (sp < 15 ? 3 : 1)); }
|
| 338 |
+
}
|
| 339 |
+
const z = s.game, road = C.routeAt(z.route, z.s), a = N.angle(z.car.h - road.h);
|
| 340 |
+
const score = (z.prog - g.prog) * 3 + C.speed(z.car) * .65 - (z.hits - g.hits) * 8
|
| 341 |
+
- (z.pol.bust - g.pol.bust) * 90 - (z.car.tires - g.car.tires) * 200 - proximity * 12
|
| 342 |
+
- Math.max(0, Math.abs(z.lat) - edge) * 10 - a * a * 5 + (z.car.nos - g.car.nos) * 8
|
| 343 |
+
+ (z.outcome === 'win' ? 100000 : 0) - (z.outcome && z.outcome !== 'win' ? 100000 : 0)
|
| 344 |
+
- (gap && z.s < gap.s ? Math.abs(z.lat - gap.lat) * GAP_PULL : 0);
|
| 345 |
+
if (score > bestScore) { bestScore = score; best = first; }
|
| 346 |
+
}
|
| 347 |
+
heldAfter(g, best.holds[5].slice().sort()); return best;
|
| 348 |
+
};
|
| 349 |
+
})();
|
| 350 |
+
|
| 351 |
+
M.MODES.pursuit = {
|
| 352 |
+
route: () => 'coast',
|
| 353 |
+
init(g, d) {
|
| 354 |
+
g.s0 = S0; g.total = 1e9; g.pre = 0; g.placeCar(S0, -2.5, 34); g.car.gear = 3; // spotted at speed: a pursuit has no starting grid
|
| 355 |
+
g.stages = Math.round(M.tierValue(d, [1, 1, 3])); g.stage = 0; g.diff = d;
|
| 356 |
+
g.bountyNeed = M.tierValue(d, [10, 32, 34]); g.prog = 0;
|
| 357 |
+
M.initPolice(g, { copsMax: 2, top: 60, grip: M.tierValue(d, [0.78, 0.85, 0.92]), accel: M.tierValue(d, [0.8, 0.95, 1.05]), spawnGap: M.tierValue(d, [12, 9, 7]), formations: d < 0.35 ? ['FOLLOW'] : d < 0.7 ? ['FOLLOW', 'ROLLING_BLOCK', 'PIT'] : ['FOLLOW', 'ROLLING_BLOCK', 'BOX_IN', 'PIT'],
|
| 358 |
+
rbChance: M.tierValue(d, [0, 0.45, 0.7]), spikeChance: M.tierValue(d, [0, 0.25, 0.5]), rbGap: M.tierValue(d, [8, 7, 6]), heli: d > 0.7, heliAfter: 30, heliFuel: 22, heliGap: 30, bustSpeed: M.tierValue(d, [7, 10, 13]), searchTop: M.tierValue(d, [34, 42, 50]), close: M.tierValue(d, [8, 11, 14]), copFrail: 3.2, aheadChance: M.tierValue(d, [0.25, 0.35, 0.45]), evadeTimeout: M.tierValue(d, [8, 13, 15]) });
|
| 359 |
+
g.breakers = []; const R = g.route;
|
| 360 |
+
for (const off of [500, 1500, 2600, 3600, 4600]) { for (const side of [1]) { const s = (S0 + off) % R.L, a = C.routeAt(R, s, side * (R.halfW - 1.5)); g.breakers.push({ s, lat: side * (R.halfW - 2.5), x: a.x, y: a.y, h: a.h, fired: 0, rearm: 0 }); } }
|
| 361 |
+
g.bountyTotal = 0;
|
| 362 |
+
startStage(g, d);
|
| 363 |
+
M.spawnTraffic(g, Math.round(M.tierValue(d, [4, 7, 10])));
|
| 364 |
+
},
|
| 365 |
+
idle(g) { for (const c of g.cops) { const a = C.routeAt(g.route, c.s, c.lat); c.x = a.x; c.y = a.y; c.h = a.h; } },
|
| 366 |
+
tick(g, wdt) {
|
| 367 |
+
const p = g.pol, R = g.route, before = p.destroyed;
|
| 368 |
+
M.stepPolice(g, wdt, g.stageBounty >= g.bountyNeed);
|
| 369 |
+
if (g.outcome) return;
|
| 370 |
+
// Pursuit Breaker: driving through the structure brings it down on whatever is around it.
|
| 371 |
+
for (const b of g.breakers) {
|
| 372 |
+
if (b.rearm > 0) b.rearm -= wdt;
|
| 373 |
+
const bs = M.wrapTo(R, b.s, g.s);
|
| 374 |
+
if (!b.rearm && Math.abs(g.s - bs) < C.speed(g.car) * wdt + 2 && Math.abs(g.lat - b.lat) < 3.4) {
|
| 375 |
+
b.rearm = 60; g.events.push({ type: 'trap_collapse' });
|
| 376 |
+
for (const c of g.cops) if (!c.dead && c.state !== 'rb' && Math.hypot(c.x - b.x, c.y - b.y) < BREAKER_R) M.destroyCop(g, c, 'breaker');
|
| 377 |
+
for (const t of g.traffic) if (!t.crash && Math.hypot(t.x - b.x, t.y - b.y) < 14) { t.crash = 0.6; t.vx = Math.cos(t.h) * Math.abs(t.v) * 0.4; t.vy = Math.sin(t.h) * Math.abs(t.v) * 0.4; }
|
| 378 |
+
}
|
| 379 |
+
}
|
| 380 |
+
// Bounty: seconds in sight, plus a lump per destroyed cop x the multiplier.
|
| 381 |
+
if (g.stageBounty < g.bountyNeed) {
|
| 382 |
+
if (p.inSight) g.stageBounty += wdt;
|
| 383 |
+
if (p.destroyed > before) g.stageBounty += 1.5 * p.bonusMult * (p.destroyed - before);
|
| 384 |
+
g.stageBounty = Math.min(g.bountyNeed, g.stageBounty);
|
| 385 |
+
}
|
| 386 |
+
g.stageEvadeHW = Math.max(g.stageEvadeHW, g.stageBounty >= g.bountyNeed ? p.evade : 0);
|
| 387 |
+
if (p.evade >= 1 && g.stageBounty >= g.bountyNeed) {
|
| 388 |
+
g.events.push({ type: 'evaded', stage: g.stage }); g.stage++;
|
| 389 |
+
if (g.stage >= g.stages) return g.win();
|
| 390 |
+
for (const c of g.cops) c.gone = 1; g.cops = [];
|
| 391 |
+
p.evade = 0; startStage(g, g.diff);
|
| 392 |
+
}
|
| 393 |
+
},
|
| 394 |
+
health(g) {
|
| 395 |
+
const total = g.stages * (BOUNTY_UNITS + EVADE_UNITS);
|
| 396 |
+
if (g.outcome === 'win') return [M.bustHp(g), 50, 0, total];
|
| 397 |
+
const done = g.stage * (BOUNTY_UNITS + EVADE_UNITS) + BOUNTY_UNITS * g.stageBounty / g.bountyNeed + EVADE_UNITS * g.stageEvadeHW;
|
| 398 |
+
return [g.outcome === 'loss' ? 0 : M.bustHp(g), 50, Math.max(0, total - done), total];
|
| 399 |
+
},
|
| 400 |
+
hud(g) { const p = g.pol, s = Math.min(g.stage + 1, g.stages); return { label: 'Police pursuit', detail: `Heat ${s} / ${g.stages} · Bounty ${(100 * g.stageBounty / g.bountyNeed).toFixed(0)}% · Escape ${(100 * p.evade).toFixed(0)}% · Cops ${g.cops.filter(c => !c.dead).length}${g.heli ? ' · Helicopter' : ''}` }; },
|
| 401 |
+
// Reference controller: pursuitPolicy above.
|
| 402 |
+
scripted(g) { return pursuitPolicy(g); },
|
| 403 |
+
hudExtra(g, c, u) { const p = g.pol; if (p.bust > 0.03) { c.font = 'bold 13px "Microsoft YaHei",sans-serif'; c.fillStyle = '#ff6a5a'; c.textAlign = 'center'; c.fillText('Busted ' + Math.round(100 * p.bust / M.BUST_MAX) + '%', u.W / 2, 78); c.textAlign = 'left'; } },
|
| 404 |
+
};
|
| 405 |
+
// Razor. GRace kRaceType_P2P with GetIsPursuitRace: the rival and the police at once. Wikipedia: the rematch is "another 5-street racing pink
|
| 406 |
+
// slip". Streets are legs of the route here; the player must keep ahead of Razor while the chase is on.
|
| 407 |
+
// boss_hp = route metres left; player_hp = the lesser of Razor's remaining share and the bust meter's, per mille.
|
| 408 |
+
M.MODES.street_champion = {
|
| 409 |
+
route: () => 'coast',
|
| 410 |
+
init(g, d) {
|
| 411 |
+
const S = 1500; g.s0 = S; g.total = Math.max(120, M.tierValue(d, [920, 2500, 7000])); g.legs = Math.max(1, Math.round(M.tierValue(d, [1, 2, 5]))); /* floors: d < 0.05 extrapolated to a negative route and 0 streets */ g.placeCar(S, -2.2);
|
| 412 |
+
g.rivals = [M.newRival(g, { s: S + 9, lat: 2.2, skill: C.clamp(M.tierValue(d, [0.1, 0.3, 0.5]) + M.formOf(g), 0, 1), paint: 3, name: 'champion' })];
|
| 413 |
+
g.rivals[0].s0 = S; g.rivals[0].prog = 9; g.glue = 0.7;
|
| 414 |
+
M.initPolice(g, { copsMax: Math.round(M.tierValue(d, [1, 2, 4])), top: M.tierValue(d, [56, 62, 66]), grip: M.tierValue(d, [0.75, 0.82, 0.9]), accel: M.tierValue(d, [0.75, 0.9, 1]), spawnGap: M.tierValue(d, [16, 12, 9]), formations: d < 0.35 ? ['FOLLOW'] : ['FOLLOW', 'ROLLING_BLOCK', 'PIT'], rbChance: M.tierValue(d, [0, 0.35, 0.6]), spikeChance: M.tierValue(d, [0, 0.15, 0.4]), rbGap: M.tierValue(d, [8, 7.5, 6.5]), heli: false, heliAfter: 1e6, heliFuel: 0, heliGap: 1e6, bustSpeed: M.tierValue(d, [6, 9, 12]), searchTop: 40, close: M.tierValue(d, [6, 9, 12]), copFrail: 3.2, aheadChance: M.tierValue(d, [0.2, 0.5, 0.6]), aheadBlind: 1, evadeTimeout: 1e9 });
|
| 415 |
+
g.gates = []; for (let i = 1; i <= g.legs; i++) g.gates.push({ at: g.total * i / g.legs, done: 0, kind: 'line' });
|
| 416 |
+
g.next = 0;
|
| 417 |
+
M.spawnTraffic(g, Math.round(M.tierValue(d, [5, 8, 11])));
|
| 418 |
+
},
|
| 419 |
+
idle(g) { for (const r of g.rivals) { const a = C.routeAt(g.route, r.s, r.lat); r.x = a.x; r.y = a.y; r.h = a.h; } },
|
| 420 |
+
tick(g, wdt) {
|
| 421 |
+
const r = g.rivals[0];
|
| 422 |
+
M.stepRival(g, r, wdt); M.stepPolice(g, wdt, false);
|
| 423 |
+
if (g.outcome) return;
|
| 424 |
+
while (g.next < g.gates.length && g.prog >= g.gates[g.next].at) { g.gates[g.next].done = 1; g.next++; g.events.push({ type: 'leg', leg: g.next }); }
|
| 425 |
+
if (g.prog >= g.total) return g.win();
|
| 426 |
+
if (r.prog >= g.total) g.lose('gap');
|
| 427 |
+
},
|
| 428 |
+
health(g) {
|
| 429 |
+
const r = g.rivals[0], a = clamp((g.total - r.prog) / g.total, 0, 1), b = M.bustHp(g) / 50, hp = g.outcome === 'loss' ? 0 : Math.round(Math.min(a, b) * 1000);
|
| 430 |
+
return [hp, 1000, g.outcome === 'win' ? 0 : Math.max(0, g.total - g.prog), g.total];
|
| 431 |
+
},
|
| 432 |
+
hud(g) { const r = g.rivals[0], lead = g.prog - r.prog; return { label: 'Street Champion Showdown', detail: `Leg ${Math.min(g.next + 1, g.legs)} / ${g.legs} · ${lead >= 0 ? 'Ahead by' : 'Behind by'} ${Math.abs(lead).toFixed(0)} m · Cops ${g.cops.filter(c => !c.dead).length}` }; },
|
| 433 |
+
scripted(g) { return championPolicy(g); },
|
| 434 |
+
hudExtra(g, c, u) { M.MODES.pursuit.hudExtra(g, c, u); },
|
| 435 |
+
};
|
| 436 |
+
void N;
|
| 437 |
+
})(typeof window === 'undefined' ? globalThis : window);
|
environments/games/web/games/nfsmw_remake/modes_speedtrap.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Speed Trap (GRace.h kRaceType_SpeedTrap). Crossing order does not matter: "each checkpoint's total speed is accumulated to
|
| 2 |
+
determine the winner" (Wikipedia). The speed at each camera is what counts, so the driver saves nitrous for the camera, and the
|
| 3 |
+
rival does the same (AIActionRace.cpp CheckSpeedTraps: nitrous 1-3 s ahead by skill, Tweak_SpeedTrapSkillBoost :50), with
|
| 4 |
+
half the usual catch-up glue (AIVehicle.cpp:2053 Tweak_SpeedTrapCatchupGlue 0.5). GRaceStatus.h keeps one speed per trap.
|
| 5 |
+
boss_hp = route metres left to the last camera; player_hp = cushion + score lead over the traps both cars have crossed. The
|
| 6 |
+
camera positions and the cushion are original (the race database is VLT data): cameras sit on the fastest ground nearby. */
|
| 7 |
+
(function (root) {
|
| 8 |
+
'use strict';
|
| 9 |
+
const M = root.NfsmwGame, C = M.C, P = C.PLAYER, KMH = 3.6, S0 = 900;
|
| 10 |
+
M.MODES.speedtrap = {
|
| 11 |
+
route: () => 'coast',
|
| 12 |
+
init(g, d) {
|
| 13 |
+
const R = g.route, v = C.profile(R, P.grip, P.aero, P.brake, C.TOPS[5]);
|
| 14 |
+
g.total = M.tierValue(d, [900, 3100, 7800]); g.s0 = S0; g.placeCar(S0, -2.1); g.glue = 0.5;
|
| 15 |
+
const count = Math.max(2, Math.round(g.total / 480)), reach = C.reachable(R, v, S0, g.total + 100, P);
|
| 16 |
+
g.gates = [];
|
| 17 |
+
for (let i = 1; i <= count; i++) {
|
| 18 |
+
let at = g.total * i / count;
|
| 19 |
+
if (i < count) { let best = at, bv = -1; for (let x = at - 150; x <= at + 150; x += 6) { const u = reach[Math.round(x / R.ds)]; if (u > bv) { bv = u; best = x; } } at = best; }
|
| 20 |
+
g.gates.push({ at, kind: 'trap', done: 0, you: 0, them: 0, themDone: 0 });
|
| 21 |
+
}
|
| 22 |
+
// Pretraining engineering target from the existing deterministic vehicle/route
|
| 23 |
+
// reachability profile. No policy, sampled rival score or evaluation result is used.
|
| 24 |
+
// Freeze once at reset; keep health(), HUD, finish and win/loss rules unchanged.
|
| 25 |
+
g.reward_target_version = 'speedtrap-reachable-profile@1';
|
| 26 |
+
g.reward_target_cameras = g.gates.map(t => Math.round(reach[Math.round(t.at / R.ds)] * KMH * 1e6) / 1e6);
|
| 27 |
+
g.reward_target_score = Math.round(g.reward_target_cameras.reduce((a,b) => a+b, 0) * 1e6) / 1e6;
|
| 28 |
+
if (!Number.isFinite(g.reward_target_score) || g.reward_target_score <= 0) throw Error('invalid fixed speedtrap target');
|
| 29 |
+
g.next = 0; g.rNext = 0; g.you = 0; g.them = 0; g.flashT = 0; g.cushion = M.tierValue(d, [130, 95, 70]);
|
| 30 |
+
g.rivals = [M.newRival(g, { s: S0, lat: 2.1, skill: C.clamp(M.tierValue(d, [0.15, 0.42, 0.68]) + M.formOf(g), 0, 1), paint: 2 })];
|
| 31 |
+
M.spawnTraffic(g, Math.round(M.tierValue(d, [6, 9, 13])));
|
| 32 |
+
},
|
| 33 |
+
idle() {},
|
| 34 |
+
lead(g) { let lead = 0; for (let i = 0; i < g.gates.length; i++) { const t = g.gates[i]; if (t.done && t.themDone) lead += t.you - t.them; } return lead; },
|
| 35 |
+
tick(g, wdt) {
|
| 36 |
+
if (g.flashT > 0) g.flashT = Math.max(0, g.flashT - wdt);
|
| 37 |
+
const r = g.rivals[0];
|
| 38 |
+
while (g.rNext < g.gates.length && r.prog >= g.gates[g.rNext].at) { const t = g.gates[g.rNext]; t.them = r.v * KMH; t.themDone = 1; g.them += t.them; g.rNext++; }
|
| 39 |
+
if (g.rNext < g.gates.length) { const ahead = g.gates[g.rNext].at - r.prog, tt = ahead / Math.max(r.v, 5); if (tt < C.lerp(1, 3, r.skill)) r.trapNos = 0.2; }
|
| 40 |
+
M.stepRival(g, r, wdt);
|
| 41 |
+
while (g.next < g.gates.length && g.prog >= g.gates[g.next].at) { const t = g.gates[g.next]; t.done = 1; t.keep = 0; t.you = C.speed(g.car) * KMH; g.you += t.you; g.next++; g.flashT = 0.15; g.events.push({ type: 'speedtrap', kmh: t.you }); }
|
| 42 |
+
if (g.next >= g.gates.length) {
|
| 43 |
+
// The player's last camera ends the event. Cameras the rival has not reached yet are scored at the speed it would carry there.
|
| 44 |
+
let them = g.them; for (let i = g.rNext; i < g.gates.length; i++) them += M.projectRival(g, r, g.s0 + g.gates[i].at) * KMH;
|
| 45 |
+
g.themFinal = them;
|
| 46 |
+
if (g.you >= them) g.win(); else g.lose('score');
|
| 47 |
+
return;
|
| 48 |
+
}
|
| 49 |
+
if (g.cushion + this.lead(g) <= 0) g.lose('score');
|
| 50 |
+
},
|
| 51 |
+
health(g) {
|
| 52 |
+
const max = g.cushion * 2, hp = g.outcome === 'loss' ? 0 : C.clamp(g.cushion + this.lead(g), 0, max);
|
| 53 |
+
return [hp, max, g.outcome === 'win' ? 0 : Math.max(0, g.total - g.prog), g.total];
|
| 54 |
+
},
|
| 55 |
+
hud(g) { return { label: 'Speed Trap', detail: `Checkpoint ${Math.min(g.next + 1, g.gates.length)} / ${g.gates.length} · You: ${g.you.toFixed(0)} · Rival: ${g.them.toFixed(0)} km/h` }; },
|
| 56 |
+
// Reference: drive the line, and spend nitrous only in the last seconds before a camera.
|
| 57 |
+
scripted(g) {
|
| 58 |
+
const v = Math.max(C.speed(g.car), 5), t = g.gates[g.next], ahead = t ? (t.at - g.prog) / v : 99;
|
| 59 |
+
return M.ctl.drive(g, ahead < 2.8 ? { forceNos: true } : { nos: false });
|
| 60 |
+
},
|
| 61 |
+
};
|
| 62 |
+
})(typeof window === 'undefined' ? globalThis : window);
|