@korial29/tiny-fps 0.115.4 → 0.117.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/local.js CHANGED
@@ -1 +1 @@
1
- var e=.4,t=1.8,n=.9,r=7.5,i=.5,a=5.5,o=2.5,s=[`#ff3d4f`,`#2f80ff`],c={ticks:20,strike:6,reach:1.4,arc:.6,hp:0,hold:-1},[l,u,d]=[2,3,180],f=.12,p=[{ticks:28,strike:10,reach:2.65,arc:.3,hp:2,hold:8},{ticks:34,strike:13,reach:2.15,arc:1.2,hp:2,hold:4},{ticks:34,strike:13,reach:2.15,arc:1.2,hp:2,hold:4},{ticks:40,strike:16,reach:2.15,arc:.45,hp:3,hold:11},{ticks:36,strike:12,reach:3.2,arc:.3,hp:3,hold:-1},{ticks:46,strike:20,reach:2.15,arc:.6,hp:3,hold:-1},{ticks:46,strike:20,reach:2.15,arc:.6,hp:3,hold:-1},{ticks:58,strike:40,reach:2.4,arc:.6,hp:4,hold:-1}],[m,h,g]=[1.8,15,60],[_,v,y]=[2,.5,1.4],[b,x,ee]=[24,15,.6],[te,ne]=[63,7],S=7.5,[re,ie,ae]=[.82,.45,.12],oe=.012,se={maxPlayers:16,scoreLimit:3,timeLimit:480,map:`highline`},C={HOME:0,CARRIED:1,DROPPED:2},ce={MALE:0,FEMALE:1},w={FORWARD:1,BACK:2,LEFT:4,RIGHT:8,JUMP:16,SPRINT:32,DASH:64,CROUCH:128,FIRE:256,BLADE:512,SPECIAL:1024,RAIL:2048,RELOAD:4096,RIFLE:8192,USE:16384},T={THRUST:0,LEFT:1,RIGHT:2,SLASH:3,LUNGE:4,ARC_L:5,ARC_R:6,LEAP:7},E={NONE:0,HEAD:1,ARM_L:2,ARM_R:3,LEG_L:4,LEG_R:5},D={GROUND:0,AIR:1,WALLRUN:2,HANG:3,CLIMB:4,SLIDE:5,CROUCH:6,RIDE:7},le={NONE:0,EAST:1,WEST:2,SOUTH:3,NORTH:4},O={JUMP:1,DOUBLE:2,DASH:4,LAND:8,GRAB:16,CLIMB:32,WALLRUN_START:64,WALLRUN_END:128,SLIDE_START:256,SLIDE_END:512,RESPAWN:1024},k={BRICK:0,TILE:1,LAVA:2,STONE:3,METAL:4,WOOD:5,MOSS:6,GRATE:7,CONCRETE:8,GLASS:9,STEEL:10,PAINT:11,ROCK:12},ue=[`x`,`y`,`z`,`vx`,`vy`,`vz`,`yaw`,`pitch`,`roll`,`wy`,`wp`,`wr`,`steer`],de=127,fe=16,pe=32,me=128/Math.PI,he=254/Math.PI,ge=65536/(2*Math.PI),_e=e=>Math.round(e*ge)&65535,ve=e=>Math.max(-32768,Math.min(32767,Math.round(e))),ye=e=>ve(e*1e4),be=e=>e/1e4,xe=e=>e/ge,Se=e=>{if(e.byteLength!==12)return null;let t=new DataView(e);return t.getUint8(0)===1?{seq:t.getUint16(1),keys:t.getUint16(3)&32767,yaw:xe(t.getUint16(5)),pitch:be(t.getInt16(7)),view:(t.getUint16(9)*256+t.getUint8(11))/256}:null},Ce=e=>e===C.CARRIED?2:e===C.DROPPED?8:1,we=e=>{let t=(e.rovers??[]).slice(0,7),n=4+62*e.players.length,r=n+54*t.length,i=e.balls??[],a=r+10+e.flags.reduce((e,t)=>e+Ce(t.state),0),o=new DataView(new ArrayBuffer(a+(i.length&&1+11*i.length)));o.setUint8(0,2),o.setUint16(1,e.tick&65535),o.setUint8(3,e.players.length|t.length<<5),e.players.forEach((e,t)=>{let n=4+t*62;o.setUint8(n,e.id),o.setFloat32(n+1,e.x),o.setFloat32(n+5,e.y),o.setFloat32(n+9,e.z),o.setFloat32(n+13,e.vx),o.setFloat32(n+17,e.vy),o.setFloat32(n+21,e.vz),o.setFloat32(n+25,e.edge),o.setUint16(n+29,_e(e.yaw)),o.setInt16(n+31,ye(e.pitch)),o.setUint16(n+33,e.ack&65535),o.setUint8(n+35,e.mode&7|(e.wall&7)<<3|(e.jumps&1)<<6|e.dashes<<7),o.setUint8(n+36,e.t),o.setUint8(n+37,e.dash|(e.by>>2&3)<<6),o.setUint8(n+38,e.coyote&7|(e.buffer&7)<<3|(e.held&w.JUMP?64:0)|(e.held&w.DASH?128:0)),o.setUint8(n+39,e.stun|(e.by&3)<<6);let r=e.hp|e.cool<<3|(e.ammo<0?de:e.ammo)<<6|e.down<<13|!!e.rack<<20|!!e.blade<<21|!!e.wield<<22|!!e.zap<<23;o.setUint8(n+40,r>>16),o.setUint16(n+41,r&65535),o.setUint8(n+43,e.shots),o.setUint8(n+44,e.hits),o.setUint8(n+45,(e.swing??0)&63|((e.cut??0)&3)<<6),o.setUint8(n+46,(e.lost??0)&7|((e.cut??0)&4)<<1|(e.fried?16:0)|(e.heavy?32:0)),o.setUint8(n+47,e.charge??0),o.setUint8(n+48,e.lock??0),o.setUint8(n+49,(e.foe??0)&15|(e.pressed?128:0)),o.setUint8(n+50,e.pushes??0),o.setUint8(n+51,e.away??0),o.setUint8(n+52,(e.rail??-1)+1),o.setUint8(n+53,+!!e.railed|!!e.inRail<<1|!!e.zapping<<2|!!e.rifled<<3|!!e.inRifle<<4|!!e.hot<<5|(e.held&w.USE?64:0)),o.setUint8(n+54,e.slow??0),o.setUint8(n+55,e.mag??0),o.setUint8(n+56,e.cap??0),o.setUint8(n+57,e.reload??0),o.setUint8(n+58,(e.rifle??-1)+1),o.setUint8(n+59,e.clip??0),o.setUint8(n+60,e.heat??0),o.setUint8(n+61,(e.nades??0)<<6|(e.lob??0))}),t.forEach((e,t)=>{let r=n+t*54;ue.forEach((t,n)=>o.setFloat32(r+4*n,e[t])),o.setUint8(r+52,e.driver),o.setUint8(r+53,e.rider)}),o.setUint8(r,e.score[0]),o.setUint8(r+1,e.score[1]),o.setUint16(r+2,e.clock&32767|(e.over?32768:0));let s=e.packs??0;o.setUint16(r+4,Math.floor(s/2**32)),o.setUint32(r+6,s%2**32);let c=r+10;for(let t of e.flags)o.setUint8(c,t.state),t.state===C.CARRIED?o.setUint8(c+1,t.by):t.state===C.DROPPED&&(o.setInt16(c+1,ve(t.x*fe)),o.setInt16(c+3,ve(t.y*fe)),o.setInt16(c+5,ve(t.z*fe)),o.setUint8(c+7,Math.min(255,t.left))),c+=Ce(t.state);i.length&&o.setUint8(c++,i.length);for(let e of i)o.setUint8(c,e.id),o.setUint8(c+1,e.by&127|(e.burst?128:0)),[e.x,e.y,e.z].forEach((e,t)=>o.setInt16(c+2+2*t,ve(e*pe))),o.setUint8(c+8,Math.round(Math.atan2(-e.dx,-e.dz)*me)&255),o.setInt8(c+9,Math.round(Math.asin(Math.max(-1,Math.min(1,e.dy)))*he)),o.setUint8(c+10,e.arc?128|e.arc:e.power===7?64|Math.min(63,Math.round(e.v)):e.power??1),c+=11;return o.buffer},Te=e=>{try{let t=JSON.parse(e);return t&&typeof t.t==`string`?t:null}catch{return null}},Ee=(e,t,n)=>{let r=Math.imul(e,374761393)+Math.imul(t,668265263)+Math.imul(n,144665)|0;return r=Math.imul(r^r>>>13,1274126177),((r^r>>>16)>>>0)/4294967296},A=(e,t,n)=>{let[r,i]=[Math.floor(e),Math.floor(t)],[a,o]=[e-r,t-i].map(e=>e*e*(3-2*e)),s=(e,t)=>Ee(r+e,i+t,n);return(s(0,0)*(1-a)+s(1,0)*a)*(1-o)+(s(0,1)*(1-a)+s(1,1)*a)*o},De=/* @__PURE__ */ new WeakMap,Oe=e=>{let t=De.get(e);if(t)return t;let{hole:n,bound:r,cell:i,at:a,pits:o=[]}=e,s=o.reduce((e,t)=>[Math.min(e[0],t[0]),Math.min(e[1],t[1]),Math.max(e[2],t[2]),Math.max(e[3],t[3])],[1/0,1/0,-1/0,-1/0]),[c,l,u,d]=r,f=Math.floor((c-u)/i)*i,p=Math.floor((l-d)/i)*i,m=Math.ceil((c+u-f)/i)+1,h=Math.ceil((l+d-p)/i)+1,g=new Float32Array(m*h),_=-1/0;for(let e=0;e<h;e++)for(let t=0;t<m;t++)g[t+e*m]=a(f+t*i,p+e*i),_=Math.max(_,g[t+e*m]);let v=new Uint8Array(m*h);for(let[e,t,n,r]of o)for(let a=Math.floor((t-p)/i)-1;a<=Math.floor((r-p)/i)+1;a++)for(let t=Math.floor((e-f)/i)-1;t<=Math.floor((n-f)/i)+1;t++)t>=0&&a>=0&&t<m&&a<h&&(v[t+a*m]=1);let y={x0:f,z0:p,cell:i,nx:m,nz:h,h:g,hole:n,pits:o,pitted:v,box:s,bound:r,top:_};return De.set(e,y),y},ke=(e,t,n)=>{let r=e.relief;if(!r||t>r.hole[0]&&t<r.hole[2]&&n>r.hole[1]&&n<r.hole[3])return-1/0;let i=Math.min(Math.max((t-r.x0)/r.cell,0),r.nx-1),a=Math.min(Math.max((n-r.z0)/r.cell,0),r.nz-1),o=Math.min(Math.floor(i),r.nx-2),s=Math.min(Math.floor(a),r.nz-2);if(r.pitted[o+s*r.nx]&&r.pits.some(e=>t>=e[0]&&t<=e[2]&&n>=e[1]&&n<=e[3]))return-1/0;let[c,l]=[i-o,a-s],u=o+s*r.nx,[d,f,p,m]=[r.h[u],r.h[u+1],r.h[u+r.nx],r.h[u+r.nx+1]];return c>=l?d+(f-d)*c+(m-f)*l:d+(p-d)*l+(m-p)*c},Ae=(e,t)=>{if(!t.relief)return;let[n,r,i,a]=t.relief.bound,[o,s]=[(e.x-n)/i,(e.z-r)/a],c=o*o+s*s;if(c<=1)return;let l=1/Math.sqrt(c);e.x=n+o*l*i,e.z=r+s*l*a;let[u,d]=[o*l/i,s*l/a],f=(e.vx*u+e.vz*d)/(u*u+d*d);f>0&&(e.vx-=f*u,e.vz-=f*d)},je=1,Me=6,Ne=(e,t,n,r,i=0)=>{let a=e.relief;if(!a||Math.min(t[1],t[1]+n[1]*r)-i>a.top)return r;let[o,s]=[0,r];for(let e of[0,1]){let[r,i,c,l]=[t[e*2],n[e*2],a.hole[e],a.hole[e+2]];if(i){let[e,t]=[(c-r)/i,(l-r)/i];o=Math.max(o,Math.min(e,t)),s=Math.min(s,Math.max(e,t))}else(r<=c||r>=l)&&(s=-1)}let c=r=>t[1]+n[1]*r-i-ke(e,t[0]+n[0]*r,t[2]+n[2]*r);if(!n[0]&&!n[2]){let e=c(0);return e<0?0:n[1]<0?Math.min(r,e/-n[1]):r}for(let[e,t]of o<s?[[0,o],[s,r]]:[[0,r]]){if(e<t&&c(e)<0)return e;for(let n=e;n<t;n+=je){let e=Math.min(n+je,t);if(c(e)<0){let[t,r]=[n,e];for(let e=0;e<Me;e++){let e=(t+r)/2;c(e)<0?r=e:t=e}return t}}}return r},Pe=4,Fe=1024,Ie=(e,t)=>(e+Fe)*(2*Fe)+t+Fe,j=(e,t)=>Math.min(Math.max(Math.floor(e/t),-1024),1023),Le=(e,t=Pe)=>{let n=/* @__PURE__ */ new Map;return e.brushes.forEach(({min:e,max:r},i)=>{for(let a=j(e[0],t);a<=j(r[0],t);a++)for(let o=j(e[2],t);o<=j(r[2],t);o++){let e=Ie(a,o),t=n.get(e);t?t.push(i):n.set(e,[i])}}),e.relief?{def:e,cell:t,grid:n,relief:Oe(e.relief)}:{def:e,cell:t,grid:n}},Re=(e,t,n,r)=>{let i=[];for(let a=j(t-r,e.cell);a<=j(t+r,e.cell);a++)for(let t=j(n-r,e.cell);t<=j(n+r,e.cell);t++)for(let n of e.grid.get(Ie(a,t))??[])i.includes(n)||i.push(n);return i},ze=(e,t,n,r,i=0)=>{let a=Be(e,t,n,r,i);return e.relief?Ne(e,t,n,a,i):a},Be=(e,t,n,r,i)=>{let{cell:a,def:o}=e,s=r,c=j(t[0],a),l=j(t[2],a),u=Math.sign(n[0]),d=Math.sign(n[2]),f=u?((c+ +(u>0))*a-t[0])/n[0]:1/0,p=d?((l+ +(d>0))*a-t[2])/n[2]:1/0,m=f,h=p,g=u?a/Math.abs(n[0]):1/0,_=d?a/Math.abs(n[2]):1/0;for(;;){for(let r of e.grid.get(Ie(c,l))??[]){let e=o.brushes[r],[a,c]=[0,s];for(let r=0;r<3&&a<=c;r++){if(!n[r]){(t[r]<e.min[r]-i||t[r]>e.max[r]+i)&&(c=-1);continue}let o=(e.min[r]-i-t[r])/n[r],s=(e.max[r]+i-t[r])/n[r];a=Math.max(a,Math.min(o,s)),c=Math.min(c,Math.max(o,s))}a<=c&&c>0&&a<s&&(s=a)}if(Math.min(m,h)>=s||Math.abs(c)>Fe||Math.abs(l)>Fe)return s;m<h?(c+=u,m+=g):(l+=d,h+=_)}},Ve=(e,t,n)=>{let[r,i,a]=[n[0]-t[0],n[1]-t[1],n[2]-t[2]],o=Math.hypot(r,i,a);return o>0&&ze(e,t,[r/o,i/o,a/o],o)<o-1e-4},M=1/60,He=Math.PI*2,Ue=1e-6,N=.01,We=.001,Ge=e=>(e%He+He)%He,P=e=>[-Math.sin(e),-Math.cos(e)],F=Math.fround,Ke=Math.sqrt,qe=(e,t,n)=>Math.min(Math.max(e,t),n),I=(e,t)=>Ke(e*e+t*t),Je=[[0,0],[1,0],[-1,0],[0,1],[0,-1]],Ye={vx:0,vz:0,mode:D.GROUND,t:0,wall:le.NONE,edge:0,jumps:1,dashes:1,dash:0,stun:0,coyote:6,buffer:0,held:0,hp:5,ammo:-1,cool:0,mag:0,cap:0,reload:0,rack:!1,down:0,shots:0,hits:0,blade:!1,wield:!1,swing:0,cut:0,zap:!1,lost:E.NONE,rail:-1,railed:!1,rifle:-1,clip:0,rifled:!1,nades:0,lob:0,inRifle:!1,inRail:!1,zapping:!1,slow:0,fried:!1,heavy:!1,ev:0,fall:0},Xe=(e,t,n,r=0)=>{let{spawns:i}=t.def.teams[r],[a,o,s,c]=i[(n%i.length+i.length)%i.length];return{id:e,x:F(a),y:F(o),z:F(s),vy:0,yaw:Ge(c),pitch:0,ground:!0,...Ye}},Ze=(e,t,n)=>{let{yaw:r,pitch:i,id:a,shots:o,hits:s}=e;Object.assign(e,Xe(a,t,a,n),{yaw:r,pitch:i,shots:o,hits:s,ev:e.ev|O.RESPAWN})},Qe=e=>e===D.GROUND||e===D.SLIDE||e===D.CROUCH,L=e=>e.mode===D.SLIDE||e.mode===D.CROUCH?n:t,$e=e=>e.mode===D.SLIDE||e.mode===D.CROUCH?.7:1.6,et=e=>I(e.vx,e.vz),tt=(e,t,n)=>e.max[1]>t+.5+N&&e.min[1]<t+n-N,nt=(e,t,n)=>[t-qe(t,e.min[0],e.max[0]),n-qe(n,e.min[2],e.max[2])],rt=(t,n,r)=>it(t,n,r,e),it=(e,t,n,r)=>{let{brushes:i}=t.def,a=Re(t,e.x,e.z,2*r),o=(r-Ue)**2,[s,c]=[0,0];for(let t=0;t<4;t++){let t=0,l=0,u=0;for(let s of a){let a=i[s];if(!tt(a,e.y,n))continue;let[c,d]=nt(a,e.x,e.z),f=c*c+d*d;if(f>=o)continue;if(f){let e=Ke(f);r-e>t&&(t=r-e,l=c/e*t,u=d/e*t);continue}let[p,m,h]=[[e.x-a.min[0],-1,0],[a.max[0]-e.x,1,0],[e.z-a.min[2],0,-1],[a.max[2]-e.z,0,1]].reduce((e,t)=>t[0]<e[0]?t:e);p+r>t&&(t=p+r,[l,u]=[m*t,h*t])}if(!t)break;e.x+=l,e.z+=u,s+=l,c+=u}return[s,c]},at=(e,t,n)=>{let[[r,i,a],[o,s,c]]=[e.a,e.b],[l,u]=[o-r,c-a],d=l*l+u*u,f=d?qe(((t-r)*l+(n-a)*u)/d,0,1):0;return[t-r-f*l,n-a-f*u,i+f*(s-i)]},ot=(t,n,r)=>{let[i,a]=[0,0];for(let o of n){let[n,s,c]=at(o,t.x,t.z),l=o.r+e,u=n*n+s*s;if(u>=(l-Ue)**2||c+o.h<=t.y+.5+N||c>=t.y+r-N)continue;let d=Ke(u),[f,p]=[o.b[0]-o.a[0],o.b[2]-o.a[2]],m=I(f,p),[h,g]=d?[n/d,s/d]:m?[p/m,-f/m]:[1,0];t.x+=h*(l-d),t.z+=g*(l-d),i+=h*(l-d),a+=g*(l-d)}return[i,a]},st=(t,n,r,i=[])=>{let{brushes:a}=n.def,o=(e-Ue)**2,s=ke(n,t.x,t.z),c=1/0;for(let i of Re(n,t.x,t.z,e)){let e=a[i],[n,l]=nt(e,t.x,t.z);n*n+l*l>=o||(e.max[1]<=t.y+.5+N?s=Math.max(s,e.max[1]):e.min[1]>=t.y+r-N&&(c=Math.min(c,e.min[1])))}for(let e of i){let[n,i,a]=at(e,t.x,t.z);n*n+i*i>=(e.r+.4-Ue)**2||(a+e.h<=t.y+.5+N?s=Math.max(s,a+e.h):a>=t.y+r-N&&(c=Math.min(c,a)))}return[s,c]},ct=(e,t,n,r)=>{let i=ke(e,t,n);for(let a of Re(e,t,n,0)){let{min:o,max:s}=e.def.brushes[a];t>=o[0]&&t<=s[0]&&n>=o[2]&&n<=s[2]&&s[1]<=r&&(i=Math.max(i,s[1]))}return i},lt=(t,n)=>{let r=(e-Ue)**2;return Re(n,t.x,t.z,e).every(e=>{let i=n.def.brushes[e],[a,o]=nt(i,t.x,t.z);return a*a+o*o>=r||!tt(i,t.y,1.8)})},ut=(t,n,r,i,a)=>{let o=(e-Ue)**2;return Re(t,n,r,e).every(e=>{let s=t.def.brushes[e],[c,l]=nt(s,n,r);return c*c+l*l>=o||s.max[1]<=i||s.min[1]>=a})},dt=(e,t)=>{let[n,r]=Je[t],i=n?0:2;return{a:i,o:2-i,sign:n||r,c:n?e.x:e.z,co:n?e.z:e.x}},ft=(e,t,n,r)=>{let{a:i,o:a,sign:o,c:s,co:c}=dt(t,n),l=((o>0?e.min[i]:e.max[i])-s)*o;return l>=.4-We&&l<=.4+r&&c>=e.min[a]&&c<=e.max[a]?l:void 0},pt=(t,n,r)=>{let a;for(let o of Re(n,t.x,t.z,e+i)){let s=n.def.brushes[o],c=ft(s,t,r,i);c!==void 0&&s.min[1]<t.y+.5&&s.max[1]>t.y+1.8&&(a=Math.min(a??1/0,Math.max(0,c-e)))}return a},mt=(t,n)=>{let[r,i]=P(t.yaw),a;for(let o=1;o<=4;o++){let[s,c]=Je[o];if(o===t.wall||r*s+i*c<.5)continue;let{a:l,sign:u}=dt(t,o);for(let r of Re(n,t.x,t.z,e+.2)){let i=n.def.brushes[r],s=i.max[1],c=s-t.y;if(ft(i,t,o,.2)===void 0||c<1.2||c>2.4||i.min[1]>s-.25||a&&a.top>=s)continue;let d=u>0?i.min[l]:i.max[l],f=d-u*(e+.03),p=d+u*.2,[m,h]=l===0?[f,t.z]:[t.x,f],[g,_]=l===0?[p,t.z]:[t.x,p];ut(n,m,h,Math.min(t.y,s-2)+N,s+1.8)&&ut(n,g,_,s+N,s+1.8)&&(a={side:o,top:s,hang:f})}}return a},ht=(e,t)=>{let{a:n,o:r,sign:i,c:a,co:o}=dt(e,e.wall);return Re(t,e.x,e.z,0).some(s=>{let c=t.def.brushes[s],l=i>0?a-c.min[n]:c.max[n]-a;return F(c.max[1])===e.edge&&o>=c.min[r]&&o<=c.max[r]&&l>=.2})},gt=e=>20*(e.def.gravity??1),_t=(e,n)=>{if(e.vy>=0)return!1;let[r]=st(e,n,t),i=6*M;return e.y-r<=-e.vy*i+.5*gt(n)*i*i},R=(e,t)=>{e.mode=t,e.t=0},vt=e=>!!e.zap&&e.stun>24,yt=(e,t,n,r=48,i=6)=>{e.stun=r,e.vx=F(t*i),e.vz=F(n*i),e.dash=Math.min(e.dash,50),e.coyote=0,e.buffer=0,(e.mode===D.HANG||e.mode===D.CLIMB)&&(e.vy=0),(e.mode===D.HANG||e.mode===D.CLIMB||e.mode===D.WALLRUN||e.mode===D.RIDE)&&(R(e,D.AIR),e.edge=0)},bt=(e,t)=>{let n=I(e.vx,e.vz);n>t&&(e.vx*=t/n,e.vz*=t/n)},xt=(t,n,r,i)=>{let[a,o]=[r.wx,r.wz];for(let r of Re(n,t.x,t.z,e+We)){let e=n.def.brushes[r],[s,c]=nt(e,t.x,t.z),l=I(s,c);if(l>0&&l<=.4+We&&tt(e,t.y,i)){let e=(-a*s-o*c)/l;e>0&&(a+=e*s/l,o+=e*c/l)}}return[a,o]},St=(e,t,n)=>{let r=I(t[0],t[1]);if(r<Ue){let t=I(e.vx,e.vz),n=t?Math.max(0,t-45*M)/t:0;e.vx*=n,e.vz*=n;return}let[i,a]=[t[0]/r,t[1]/r],o=e.vx*i+e.vz*a,[s,c]=[e.vx-o*i,e.vz-o*a],l=I(s,c);if(l){let e=Math.max(0,l-45*M)/l;[s,c]=[s*e,c*e]}n*=r,o=o<n?Math.min(n,o+(o>=6?3:50)*M):Math.max(n,o-12*M),e.vx=s+o*i,e.vz=c+o*a},Ct=(e,t,n,r,i,a)=>{let o=e.y;e.x+=e.vx*M,e.z+=e.vz*M;let[s,c]=rt(e,t,n),[l,u]=ot(e,a,n);if(l||u){let[r,i]=rt(e,t,n);s+=l+r,c+=u+i}let d=I(s,c);if(d){let t=(e.vx*s+e.vz*c)/d;t<0&&(e.vx-=t*s/d,e.vz-=t*c/d)}Ae(e,t);let[f,p]=st(e,t,n,a),m=e.vy-r*gt(t)*M;if(e.y+=(e.vy+m)/2*M,e.vy=m,e.y+n>p&&(e.y=p-n,e.vy=Math.min(e.vy,0)),e.vy<=0?e.y<=f+N:e.y<f){if(e.y=f,e.vy<=0){let t=-e.vy;return e.vy=0,t}}else if(i&&e.vy<=0&&f>=o-.5)return e.y=f,e.vy=0,0;return-1},wt=(e,t)=>{e.vy=t,e.coyote=0,e.buffer=0,e.ev|=O.JUMP},Tt=(e,n,r)=>{let[i,a]=Je[e.wall],o=t=>{R(e,t),e.edge=0};if(r.keys&(w.BACK|w.CROUCH))o(D.AIR),e.coyote=0;else if(r.jump&&r.fx*i+r.fz*a<0)o(D.AIR),e.vx=-i*4,e.vz=-a*4,wt(e,6);else if(r.jump||r.fwd&&e.t>=6)R(e,D.CLIMB);else if(e.t>=30)o(D.AIR),e.coyote=0;else{let r=Math.max(e.edge-2,st(e,n,t)[0]);e.y+=qe(r-e.y,-8*M,8*M)}},Et=(e,t)=>{let[n,r]=Je[e.wall];e.y<e.edge?e.y=Math.min(e.edge,e.y+8*M):(e.x+=n*a*M,e.z+=r*a*M),e.y>=e.edge&&ht(e,t)?(R(e,D.GROUND),e.vx=n*3,e.vz=r*3,e.vy=0,e.edge=0,e.wall=le.NONE,e.coyote=6,e.ev|=O.CLIMB):e.t>=40&&(R(e,e.y>=e.edge?D.GROUND:D.AIR),e.edge=0,e.wall=le.NONE)},Dt=(e,t,n)=>{let[r,i]=Je[e.wall],a=e.vx*r+e.vz*i,[o,s]=[e.vx-a*r,e.vz-a*i],c=I(o,s);if(n.jump)R(e,D.AIR),e.vx=o-r*5,e.vz=s-i*5,wt(e,6.5),e.jumps=1,e.dashes=1,e.ev|=O.WALLRUN_END;else{let a=pt(e,t,e.wall);if(a===void 0||!n.fwd||c<3.5||e.t>=60){R(e,D.AIR),e.ev|=O.WALLRUN_END;return}let l=Math.max(0,c-1.5*M)/c;e.vx=o*l,e.vz=s*l;let u=Math.min(a,4*M);e.x+=r*u,e.z+=i*u}},Ot=(e,t,n)=>{if(!n.fwd)return;let r=I(e.vx,e.vz);if(!(r<4.5))for(let n=1;n<=4;n++){let[i,a]=Je[n],o=e.vx*i+e.vz*a,[s,c]=[e.vx-o*i,e.vz-o*a];if(n!==e.wall&&o<=.75*r&&o>=-.2*r&&pt(e,t,n)!==void 0){let t=I(s,c),i=Math.max(t,.9*r)/t;R(e,D.WALLRUN),e.wall=n,[e.vx,e.vz]=[s*i,c*i],e.vy=qe(e.vy,2,3),e.jumps=1,e.dashes=1,e.coyote=0,e.ev|=O.WALLRUN_START;return}}},kt=(e,t)=>{R(e,D.HANG),e.wall=t.side,e.edge=F(t.top),t.side<=le.WEST?e.x=t.hang:e.z=t.hang,e.vx=e.vy=e.vz=0,e.jumps=1,e.dashes=1,e.coyote=0,e.buffer=0,e.ev|=O.GRAB},At=(e,t,n)=>{let i=e.mode===D.GROUND;if(n.dash&&e.dash===0&&(i||(e.mode===D.AIR||e.mode===D.WALLRUN)&&e.dashes>0)){let[t,r]=n.wx||n.wz?[n.wx,n.wz]:[n.fx,n.fz];i||(e.dashes--,e.vy=0,e.mode===D.WALLRUN&&(R(e,D.AIR),e.ev|=O.WALLRUN_END)),e.vx=t*16,e.vz=r*16,e.dash=60,e.ev|=O.DASH}let a=e.dash>50;e.mode===D.WALLRUN&&Dt(e,t,n),Qe(e.mode)&&jt(e,t,n,a),e.mode===D.AIR&&Mt(e,t,n,a);let o=a&&e.vy<=0?0:e.mode===D.WALLRUN?.15:1,s=e.mode,c=Ct(e,t,L(e),o,Qe(s),n.bodies);if(c>=0){if(!Qe(e.mode)){if(e.ev|=O.LAND|(e.mode===D.WALLRUN?O.WALLRUN_END:0),e.fall=c,e.jumps=1,e.dashes=1,e.wall=le.NONE,n.keys&w.CROUCH){let t=I(e.vx,e.vz)>=r;R(e,t?D.SLIDE:D.CROUCH),e.ev|=t?O.SLIDE_START:0}else R(e,D.GROUND)}e.coyote=6}else Qe(e.mode)&&(e.ev|=e.mode===D.SLIDE?O.SLIDE_END:0,R(e,D.AIR));if(e.mode===D.AIR){let r=mt(e,t);r?kt(e,r):Ot(e,t,n)}},jt=(e,i,a,s)=>{let c=(a.keys&w.CROUCH)!==0;if(e.buffer>0&&(e.mode===D.GROUND||lt(e,i))){e.ev|=e.mode===D.SLIDE?O.SLIDE_END:0,R(e,D.AIR),wt(e,7);return}let l=I(e.vx,e.vz);if(e.mode===D.GROUND&&c){let t=l>=r;R(e,t?D.SLIDE:D.CROUCH),e.ev|=t?O.SLIDE_START:0}else e.mode===D.SLIDE&&(e.t>=60||l<4.5||a.stumble)?(e.ev|=O.SLIDE_END,R(e,!c&&lt(e,i)?D.GROUND:D.CROUCH)):e.mode===D.SLIDE&&!c&&lt(e,i)?(e.ev|=O.SLIDE_END,R(e,D.GROUND)):e.mode===D.CROUCH&&!c&&lt(e,i)&&R(e,D.GROUND);if(!s){if(a.stumble){if(l>2.5){let t=Math.max(o,l-12*M)/l;e.vx*=t,e.vz*=t}else St(e,xt(e,i,a,L(e)),o)}else if(e.mode===D.SLIDE){let t=Math.max(0,l-4*M)/l;e.vx*=t,e.vz*=t}else if(e.mode===D.CROUCH)St(e,xt(e,i,a,n),3);else{let n=(a.keys&w.SPRINT)!==0&&a.fwd;St(e,xt(e,i,a,t),n?9:6)}}},Mt=(e,t,n,r)=>{if(e.buffer>0&&(e.coyote>0?wt(e,7):e.jumps>0&&!_t(e,t)&&(e.jumps--,wt(e,6),e.ev=e.ev&~O.JUMP|O.DOUBLE)),r||!n.wx&&!n.wz)return;let i=I(e.vx,e.vz);e.vx+=n.wx*14*M,e.vz+=n.wz*14*M,bt(e,Math.max(i,6))},Nt=(e,t,n,r=0,i=[])=>{e.yaw=Ge(t.yaw),e.pitch=Math.max(-1.55,Math.min(1.55,t.pitch));let a=(t.keys&w.FORWARD?1:0)-(t.keys&w.BACK?1:0),o=(t.keys&w.RIGHT?1:0)-(t.keys&w.LEFT?1:0),s=vt(e)?1/0:I(a,o)||1,[c,l]=P(e.yaw),u=n=>(t.keys&n)!==0&&(e.held&n)===0,d=e.stun>0,f=e.mode===D.RIDE,p={keys:t.keys,stumble:d,jump:!d&&!f&&u(w.JUMP),dash:!d&&!f&&u(w.DASH),fwd:a>0,wx:(c*a-l*o)/s,wz:(l*a+c*o)/s,fx:c,fz:l,bodies:i},m=e.mode;e.ev=0,e.fall=0,p.jump&&(e.buffer=7),d&&e.stun--,e.dash>0&&(e.dash--,e.dash===50&&bt(e,10)),e.mode===D.HANG&&Tt(e,n,p),e.mode===D.CLIMB?Et(e,n):e.mode!==D.HANG&&!f&&At(e,n,p),e.slow&&(e.slow--,bt(e,3)),e.y<n.def.floor&&Ze(e,n,r),e.t=e.mode===m?Math.min(255,e.t+1):e.t,e.buffer=Math.max(0,e.buffer-1),e.mode===D.AIR&&m===D.AIR&&(e.coyote=Math.max(0,e.coyote-1)),e.held=t.keys&(w.JUMP|w.DASH|w.USE),e.ground=Qe(e.mode),e.x=F(e.x),e.y=F(e.y),e.z=F(e.z),e.vx=F(e.vx),e.vy=F(e.vy),e.vz=F(e.vz),e.edge=F(e.edge)},Pt=.7,Ft=e=>{let[t,n]=[e&w.LEFT,e&w.RIGHT];return t&&!n?T.LEFT:n&&!t?T.RIGHT:e&w.FORWARD?T.THRUST:T.SLASH},It=e=>{let t=p[e.cut??0];return e.heavy?{...t,ticks:Math.round((t.ticks-t.hold)*m),strike:Math.round((t.strike-t.hold)*m),reach:t.reach+v,arc:t.arc*y,hp:t.hp+_}:t},Lt=(e,t,n,{reach:r,arc:i}=It(t))=>{let[a,o]=P(t.yaw),s=[t.x,t.y+Pt*L(t),t.z];return n.filter(n=>{let[c,l]=[n.x-t.x,n.z-t.z],u=Math.hypot(c,l);return u-.4>r||t.y>=n.y+L(n)||n.y>=t.y+L(t)?!1:(u>.4?Math.abs(Math.atan2(a*l-o*c,a*c+o*l)):0)<=i+(u>.4?Math.asin(.4/u):Math.PI)&&!Ve(e,s,[n.x,n.y+.7*L(n),n.z])})},Rt=(e,t)=>{if(!t.wield||!t.swing||e.lock||t.lock)return!1;let n=It(t);if(Math.abs(n.strike-(n.ticks-t.swing))>9)return!1;let[r,i]=[t.x-e.x,t.z-e.z],a=Math.hypot(r,i),o=(e,t,n)=>{let[r,i]=P(e.yaw);return a<1e-6||(r*t+i*n)/a>=Math.cos(.9)};return a-.4<=Math.min(n.reach,It(e).reach)&&o(e,r,i)&&o(t,-r,-i)},zt=e=>{let[t,n]=P(e.yaw),r=e.cut??0;return r===T.LEFT?[-n,t]:r===T.RIGHT?[n,-t]:[t,n]},Bt=(t,n)=>{let[r,i]=P(t.yaw),[a,o]=P(n.yaw),[s,c]=[n.x-t.x,n.z-t.z],l=-i*s+r*c,u=Math.sqrt(Math.max(e*e-l*l,0)),[d,f]=[i*l-r*u,-r*l-i*u],p=-o*d+a*f,m=(t.cut??0)%4;if(m===T.SLASH)return Math.abs(p)<=ae?E.HEAD:p>0?E.ARM_R:E.ARM_L;let h=(t.y+Pt*L(t)+Math.tan(t.pitch)*Math.hypot(s,c)-n.y)/L(n);if(h>re)return E.HEAD;let g=m===T.THRUST?p>0:(m===T.LEFT?1:-1)*(r*a+i*o)<0;return h<ie?g?E.LEG_R:E.LEG_L:m===T.THRUST&&Math.abs(p)<=ae?E.NONE:g?E.ARM_R:E.ARM_L},Vt=()=>({state:C.HOME,by:0,x:0,y:0,z:0,left:0}),Ht=60,Ut=class{score=[0,0];over=!1;flags=[Vt(),Vt()];world;rules;mates=/* @__PURE__ */ new Map;clock;back=[0,0];lock=[{id:-1,left:0},{id:-1,left:0}];hold=[0,0];constructor(e,t){this.world=e,this.rules=t,this.clock=t.timeLimit*60}join(e,t,n){this.mates.set(e,{team:t,caps:0,returns:0,ground:[n.x,n.y,n.z]})}leave(e){let t=this.carrying(e),n=this.mates.get(e);t>=0&&n&&this.dropAt(t,n.ground),this.mates.delete(e)}place(e,t){let n=this.mates.get(e);n&&(n.ground=[t.x,t.y,t.z])}moved(e){let t=this.mates.get(e.id);if(!t)return;let n=this.carrying(e.id);e.ev&O.RESPAWN&&n>=0&&this.dropAt(n,t.ground),e.ground&&(t.ground=[e.x,e.y,e.z])}drop(e){let t=this.carrying(e.id),n=this.mates.get(e.id);if(t<0||!n||this.over)return!1;let r=n.ground;if(e.ground)r=[e.x,e.y,e.z];else{let t=ze(this.world,[e.x,e.y+.05,e.z],[0,-1,0],Ht);t<Ht&&(r=[e.x,e.y+.05-t,e.z])}return this.dropAt(t,r),this.lock[t]={id:e.id,left:120},this.hold[t]=120,!0}carrying(e){return this.flags.findIndex(t=>t.state===C.CARRIED&&t.by===e)}winner(){let[e,t]=this.score;return e>t?0:t>e?1:-1}tally(){return[...this.mates].map(([e,t])=>({id:e,caps:t.caps,returns:t.returns}))}reset(){this.over=!1,this.score=[0,0],this.flags=[Vt(),Vt()],this.back=[0,0],this.lock.forEach(e=>e.left=0),this.hold=[0,0],this.clock=this.rules.timeLimit*60;for(let e of this.mates.values())e.caps=e.returns=0}wire(){return{score:[...this.score],clock:Math.ceil(this.clock/60),over:this.over,flags:this.flags.map(e=>({...e}))}}tick(e){if(this.over)return--this.clock<=0?(this.reset(),`start`):void 0;for(let e of[0,1]){let t=this.flags[e];this.lock[e].left--,this.hold[e]--,t.state===C.DROPPED&&(t.left=Math.ceil(--this.back[e]/60),this.back[e]<=0&&(this.flags[e]=Vt()))}for(let t of[0,1]){let n=this.flags[t];if(n.state===C.CARRIED)continue;let r=n.state===C.HOME?this.world.def.teams[t].base:[n.x,n.y,n.z],i=e.filter(e=>Wt(e.state,r)),a=n.state===C.DROPPED&&this.hold[t]<=0?i.find(e=>e.team===t):void 0,o=i.find(e=>e.team!==t&&(e.id!==this.lock[t].id||this.lock[t].left<=0));if(a){let e=this.mates.get(a.id);e&&e.returns++,this.flags[t]=Vt()}else o&&(this.flags[t]={...Vt(),state:C.CARRIED,by:o.id})}for(let t of e){let e=this.carrying(t.id);if(e>=0&&this.flags[t.team].state===C.HOME&&Wt(t.state,this.world.def.teams[t.team].base)){this.score[t.team]++;let n=this.mates.get(t.id);n&&n.caps++,this.flags[e]=Vt()}}if(this.score.some(e=>e>=this.rules.scoreLimit)||--this.clock<=0)return this.over=!0,this.clock=600,`end`}dropAt(e,[t,n,r]){this.flags[e]={state:C.DROPPED,by:0,x:t,y:n,z:r,left:10},this.back[e]=600}},Wt=(e,t)=>Math.hypot(e.x-t[0],e.z-t[2])<1.5&&e.y<t[1]+2.2&&e.y+1.8>t[1],Gt=(e,t,n)=>{let[r,i]=[e.x-t[0],e.z-t[2]];return r*r+i*i<n*n&&Math.abs(e.y-t[1])<1},Kt=e=>{if(e.mode===D.GROUND){if(e.cut===T.LUNGE){let[t,n]=P(e.yaw);e.vx=t*13,e.vz=n*13,e.dash=60,e.ev|=O.DASH}else e.cut===T.LEAP&&(e.vy=S,e.ev|=O.JUMP)}},z={NONE:0,SHOT:1,CUT:2,RAIL:3,LASER:4,NADE:5},qt=(e,t,n,r,i=!0,a=[])=>{let o=e.down>0,s=!o&&(e.lock??0)>0;if(Nt(e,o||s?{...t,keys:0}:t,n,r,a),e.heat=Math.max(0,(e.heat??0)-(e.zapping?0:e.hot?1:2)),e.hot=!!e.hot&&e.heat>0,e.zapping=!1,e.zap=!!e.stun&&!!e.zap,o)return e.down>0&&!--e.down&&Ze(e,n,r),z.NONE;if(s)return Jt(e,t);let{rack:l,blade:u,rail:d,rifle:f}=n.def.teams[r],m=!!l&&Gt(e,l,1.2);i&&m&&!e.rack&&([e.ammo,e.mag]=[60,15]),e.rack=m,e.blade=!!e.blade||i&&!!u&&Gt(e,u,1.2);let _=!!d&&Gt(e,d,1.2);i&&_&&!e.inRail&&([e.rail,e.cap]=[240,80]),e.inRail=_;let v=!!f&&Gt(e,f,1.2);i&&v&&!e.inRifle&&([e.rifle,e.clip,e.nades]=[240,60,3]),e.inRifle=v,e.cool=Math.max(0,e.cool-1),e.lob=Math.max(0,(e.lob??0)-1);let y=e.mode===D.HANG||e.mode===D.CLIMB,{ticks:b,hold:x}=p[e.cut??0],ee=!!e.swing&&!e.heavy&&b-(e.swing??0)===x;ee&&e.wield&&i&&!y&&t.keys&w.FIRE?e.charge=Math.min((e.charge??0)+1,g):ee&&i&&!y&&(e.charge??0)>=h?([e.heavy,e.charge]=[!0,0],e.swing=It(e).ticks):(e.charge=ee?0:e.charge,e.swing=Math.max(0,(e.swing??0)-1),e.heavy=!!e.swing&&!!e.heavy),e.mag=Math.min(e.mag??0,Math.max(e.ammo,0));let te=[e.ammo>=0,!!e.blade,(e.rail??-1)>=0,(e.rifle??-1)>=0],ne=t.keys&w.BLADE?1:t.keys&w.RAIL?2:t.keys&w.RIFLE?3:0,S=e.swing&&e.blade?1:te[ne]?ne:te.indexOf(!0);if(S!=(e.rifled?3:e.railed?2:+!!e.wield)&&(e.reload=0),[e.wield,e.railed,e.rifled]=[S==1,S==2,S==3],e.swing&&S>=0&&!e.blade&&(e.swing=0),!i)return[e.charge,e.reload]=[0,0],z.NONE;let[re,ie,ae,oe]=S==3?[`clip`,60,e.rifle,96]:S==2?[`cap`,80,e.rail,90]:[`mag`,15,e.ammo,78],[se,C]=[e[re]??0,Math.min(ie,ae)];e.reload?--e.reload||(e[re]=C):S!=1&&ae>=0&&!y&&se<C&&(!se||t.keys&w.RELOAD)&&([e.reload,e.charge]=[oe,0]);let ce=S<0,T=ce?c:It(e);if(e.swing&&T.ticks-e.swing===T.strike)return z.CUT;if((e.wield&&!ee||e.railed||e.rifled||y||e.reload||!e.wield&&!e.mag)&&(e.charge=0),e.rifled&&t.keys&w.SPECIAL&&!y&&e.nades&&!e.lob)return e.nades--,[e.lob,e.cool]=[60,7],e.shots=e.shots+1&255,z.NADE;if(t.keys&w.FIRE&&!y){let n=p[e.cut??0].ticks-(e.swing??0),r=!!(t.keys&w.SPECIAL)&&(!e.swing||!e.heavy&&(e.cut??0)<4&&n<=18);if(ce)e.swing||([e.cut,e.heavy,e.swing]=[0,!1,c.ticks]);else if(e.wield&&(!e.swing||r))e.cut=Ft(t.keys)+(r?4:0),[e.swing,e.charge]=[p[e.cut].ticks,0],Kt(e);else if(e.rifled){if(!e.cool&&e.clip&&!e.reload)return e.rifle--,e.clip--,e.cool=3,e.shots=e.shots+1&255,z.LASER}else if(e.railed){if(e.cap&&!e.reload&&!e.hot)return e.heat=(e.heat??0)+1,e.hot=e.heat>=120,e.cool||=(e.rail--,e.cap--,2),e.zapping=!0,z.RAIL}else!e.wield&&!e.cool&&e.mag&&!e.reload&&(e.charge=Math.min((e.charge??0)+1,60))}else if(e.charge)return e.power=Math.min(Yt(e.charge),e.mag),e.charge=0,e.ammo-=e.power,e.mag-=e.power,e.shots=e.shots+1&255,e.cool=7,z.SHOT;return z.NONE},Jt=(e,t)=>{let n=!!(t.keys&w.FIRE);return e.pushes=(e.pushes??0)+ +(n&&!e.pressed)&255,e.pressed=n,e.away=t.keys&(w.LEFT|w.RIGHT|w.BACK)?Math.min((e.away??0)+1,24):0,e.lock=Math.max(1,e.lock-1),[e.wield,e.swing,e.charge]=[!0,0,0],z.NONE},Yt=e=>e<10?1:1+Math.floor(4*(e-10)/50),Xt=-30,B=(e,t,n,r,i,a=k.CONCRETE)=>({min:[e,Xt,t],max:[n,i,r],top:k.CONCRETE,side:a}),V=([e,t,n],[r,i,a],o,s=o,c)=>({min:[e,t,n],max:[r,i,a],top:o,side:s,tint:c});[B(4,57.7,24,76,10),B(4,36,24,53.5,10,k.GLASS),B(4,20,24,36,12.4),B(4,-5,24,7,12.4,k.GLASS),B(27,20,47,50,8),B(27,60,47,76,8,k.BRICK),V([9,12.2,39],[19,12.6,47],k.STEEL),...((e,t)=>[1,2,3,4,5,6].map(n=>V([12,t,e-n],[14,t+.4*n,e-n+1],k.CONCRETE)))(53,10),V([5,10,42],[5.5,14,42.5],k.STEEL),V([5,10,50],[5.5,14,50.5],k.STEEL),V([8,12.4,24],[20,12.85,24.45],k.STEEL),V([36,8,22],[37,14.5,48],k.PAINT,k.PAINT,[.15,.72,.62]),V([30,8,28],[34,10,32],k.CONCRETE),V([40,8,30],[44,10.2,34],k.PAINT,k.PAINT,[1,.3,.06]),V([28,9.2,44],[35,12,46],k.STEEL,k.PAINT,[.2,.42,1]),V([41.5,7.6,50],[42,8,60],k.STEEL),V([30,8,64],[34,9.6,68],k.PAINT,k.PAINT,[.2,.8,.3])];var Zt=240,H=[1,.22,.26],Qt=[.2,.46,1],$t=[H,Qt],en=[1,.42,.08],tn=[.12,.7,.62],nn=(e,t,n,r,i,a,o)=>V([e,t,n],[r,i,a],k.PAINT,k.PAINT,o),rn=(e,t,n,r,i,a,o,s=Xt)=>{let c=Math.ceil((o-a)/.46);return Array.from({length:c},(l,u)=>{let[d,f]=[t+(n-t)*u/c,t+(n-t)*(u+1)/c].sort((e,t)=>e-t),p=a+(o-a)*(u+1)/c;return e===0?V([d,s,r],[f,p,i],k.CONCRETE):V([r,s,d],[i,p,f],k.CONCRETE)})},an=(e,t,n,r,i,a,o)=>o.map((o,s)=>V([e+s*n,a,t+s*r],[e+s*n+4,o,t+s*r+i],k.STEEL,k.CONCRETE)),on=[B(12,212,52,240,26,k.GLASS),nn(12,26,212,52,26.12,212.5,H),nn(12,26,239.5,52,26.12,240,H),nn(12,26,212.5,12.5,26.12,239.5,H),nn(51.5,26,212.5,52,26.12,239.5,H),nn(11.6,12,222,12,25.8,232,H),nn(28,12,211.4,31,25.5,212,H),V([19,26,222],[22,27.4,225],k.STEEL),V([42,26,222],[45,27.4,225],k.STEEL),V([29,26,229],[35,27.1,229.6],k.CONCRETE),V([24.5,26,215],[35,27.5,219],k.STEEL,k.PAINT,H),B(6,164,26,201,26,k.GLASS),B(6,134,26,147,26,k.GLASS),B(6,201,26,212,19),B(15,147,26,164,19),V([14,26,164],[15,32,196],k.PAINT,k.PAINT,tn),V([14,18,147],[15,32,164],k.PAINT,k.PAINT,tn),V([14,26,134],[15,32,147],k.PAINT,k.PAINT,tn),...an(6,201,7,0,4,19,[21.2,23.4,25]),...[[18,152,22,156,21.2],[18,158,22,162,23.4],[23,160,26,164,25]].map(([e,t,n,r,i])=>V([e,19,t],[n,i,r],k.STEEL,k.CONCRETE)),V([20,26,178],[23,27.3,181],k.STEEL),V([8,26,176],[11,27.2,179],k.STEEL),V([8,26,190],[11,27.3,193],k.STEEL),V([20,26,140],[23,27.3,143],k.STEEL),B(32,186,76,209,19),nn(32,19,207.5,76,19.1,209,H),...an(33,209,7,0,3,19,[21.2,23.4,25]),...[[28,196,32,200,21.2],[28,190,32,194,23.4],[26,184,30,188,25]].map(([e,t,n,r,i])=>V([e,Xt,t],[n,i,r],k.STEEL,k.CONCRETE)),B(32,166,64,182,21.2,k.GLASS),B(32,140,64,161,19),V([40,21.2,172],[44,22.6,176],k.STEEL),V([52,19,148],[57,20.3,151],k.STEEL),V([38,19,196],[41,20.4,199],k.STEEL),V([60,19,200],[63,20.4,203],k.STEEL),V([52,19,190],[58,20.6,194],k.STEEL),V([66,19,204],[72,20.2,207],k.STEEL),V([56,21.2,170],[60,22.4,174],k.STEEL),V([34,19,152],[37,20.3,156],k.STEEL),...an(36,135,18,0,3,15,[17.2,17.2]),...an(6.5,129,6,0,4,15,[17.2,19.4,21.6,23.8]),B(76,213,100,240,14.5,k.STEEL),nn(76,14.5,238.5,100,14.6,240,H),B(76,185,100,209,14.5),B(76,138,100,181,14.5,k.GLASS),V([80,15.7,158],[96,17.7,162],k.STEEL,k.PAINT,en),V([82,14.5,234],[85,15.9,237],k.STEEL),V([91,14.5,190],[94,15.9,193],k.STEEL),V([80,14.5,204],[83,15.6,207],k.STEEL),V([78,14.5,170],[81,15.9,173],k.STEEL),V([92,14.5,146],[95,15.7,149],k.STEEL),V([92,14.5,222],[96,15.8,226],k.STEEL),...rn(0,76,52,226,232,14.5,26),...rn(0,85,76,196,202,14.5,19,14.5)],sn=[B(6,106,62,134,15),B(62,106,100,134,14.5),V([34,15,112],[54,17.2,128],k.CONCRETE),nn(38,17.2,116,50,17.3,124,en),...[[35,113],[35,126.2],[51,113],[51,126.2]].map(([e,t])=>V([e,17.2,t],[e+.8,21.5,t+.8],k.STEEL)),V([34.6,21.5,112.6],[52.2,21.9,127.4],k.GLASS),V([14,15,114],[17,16.5,117],k.STEEL),V([14,15,123],[17,16.5,126],k.STEEL),V([56,15,114],[59,16.5,117],k.STEEL),V([56,15,123],[59,16.5,126],k.STEEL),V([15.35,25.5,106],[15.85,26,134],k.STEEL),V([70,14.5,108],[70.8,38,108.8],k.STEEL),V([70,14.5,131.2],[70.8,38,132],k.STEEL),V([66,14.5,110],[69,15.9,113],k.STEEL),V([66,14.5,127],[69,15.9,130],k.STEEL)],cn=e=>({...e,min:[e.min[0],e.min[1],Zt-e.max[2]],max:[e.max[0],e.max[1],Zt-e.min[2]],tint:e.tint===H?Qt:e.tint}),ln=(e,t,n)=>[...[16,22,28,34,40].map(n=>[n,26,t,e]),...[19,31,43].map(t=>[t,26,n,e])],un=[[20,26,190],[48,21.2,172],[48,19,200],[88,14.5,198]],dn=[[21,26,168],[16,26,140],[46,19,144],[36,21.2,178],[58,19,156],[64,19,196],[88,14.5,216],[88,14.5,172],[90,14.5,150]],fn=[[19.5,26,179],[46,19,152],[39.5,21.2,172],[88,14.5,186],[88,14.5,207]],pn={armor:!0,name:`Highline`,brushes:[...on,...on.map(cn),...sn],teams:[{base:[32,26,224],spawns:ln(0,236,231),rack:[30.75,27.5,217],blade:[33.25,27.5,217],rail:[28.25,27.5,217],rifle:[25.75,27.5,217]},{base:[32,26,16],spawns:ln(Math.PI,4,9),rack:[30.75,27.5,23],blade:[33.25,27.5,23],rail:[28.25,27.5,23],rifle:[25.75,27.5,23]}],packs:[...un,...un.map(([e,t,n])=>[e,t,Zt-n]),[24,15,112],[24,15,128]],ammo:[...dn,...dn.map(([e,t,n])=>[e,t,Zt-n]),[12,15,116],[12,15,124]],cells:[...fn,...fn.map(([e,t,n])=>[e,t,Zt-n]),[28,15,Zt/2]],floor:-25,sun:{dir:[.8,.6,0],color:[2.6,2.3,1.8]},sky:[[.04,.2,.72],[.72,.86,.98]],fog:[.72,.86,.98,.0035]},{CONCRETE:mn,METAL:hn,STEEL:U,PAINT:gn}=k,W=(e,t,n,r,i,a,o,s=o,c)=>({min:[e,t,n],max:[r,i,a],top:o,side:s,tint:c}),_n=({min:e,max:t},n,r=n)=>({min:e,max:t,top:n,side:r}),vn=(e,t,n,r,i,a)=>({min:[e,t,n],max:[r,i,a]}),yn=22.4,bn=e=>e<5?yn:yn*Math.sqrt(1-((e-5)/12)**2),xn=e=>Math.round(e*10)/10,Sn=[0,10.5,13.5,15.5,17],Cn=e=>[[1,.39],[.93,.71],[.71,.93],[.39,1]].map(([t,n])=>[xn(t*e),xn(n*e)]),[[wn,Tn],[En,Dn]]=Cn(22.599999999999998),[G,On]=[.4,2.48],K=[80,236],kn=[vn(111,0,222,125,5,230),vn(96,0,196,110,5,204)],An=[vn(102,0,223.2,111,3.5,227.2),vn(98,0,204,102,3.5,227.2)],[[jn,,Mn],[Nn,Pn,Fn],[In,,Ln],[Rn]]=An.flatMap(e=>[e.min,e.max]),[[zn,Bn],[Vn,Hn]]=[[19.8,6.7],[16,13.5]],Un=[[0,-zn,2,3,2.8],[Vn,-10.8,2,3.5,2]],Wn=e=>[...new Map(e.flatMap(([e,t,n,r])=>[1,-1].flatMap(i=>[1,-1].flatMap(a=>[[e,n,t,r],[t,r,e,n]].map(([e,t,n,r])=>[Math.min(i*e,i*t),Math.min(a*n,a*r),Math.max(i*e,i*t),Math.max(a*n,a*r)])))).map(e=>[`${e}`,e])).values()],q=([e,t,n,r],i,a,o=mn,s=o)=>({...W(K[0]+e,i,K[1]+t,K[0]+n,a,K[1]+r,o,s),ghost:!0}),Gn=(e,t,n,r,i,a,o)=>{let s=Math.ceil((o-a)/.46);return Array.from({length:s},(c,l)=>{let[u,d]=[t+(n-t)*l/s,t+(n-t)*(l+1)/s].sort((e,t)=>e-t),f=a+(o-a)*(l+1)/s;return e?W(r,a,u,i,f,d,mn):W(u,a,r,d,f,i,mn)})},Kn=[...Wn([[12,-Hn,Vn,Hn],[Vn,-Bn,zn,Bn]]).filter(e=>e[1]>-zn).map(e=>q(e,3.1,3.5,hn,U)),...Gn(2,K[1]+5.6,K[1]+12,K[0]-1.5,K[0]+1.5,0,3.5).map(e=>({...e,ghost:!0})),q([-3,19,3,zn],3.5,4.6,U,hn),q([-9,12,-2.5,12.5],3.5,4.6,U,gn),q([2.5,12,9,12.5],3.5,4.6,U,gn),q([-9.5,-10,-7.5,-8],0,1.4,U),q([7.5,-10,9.5,-8],0,1.4,U),q([7.5,3,10,5.5],0,2.4,U)],{BENCH:qn,SAMPLES:Jn,RACKS:Yn,SCOPE:Xn,ANALYSER:Zn,PLANTS:Qn,LOCKERS:$n,SUIT:er}={BENCH:0,SAMPLES:1,RACKS:2,SCOPE:3,ANALYSER:4,PLANTS:5,LOCKERS:6,SUIT:7},tr=[[qn,60.2,230.5,61.2,241.5,0,.95,0],[Jn,65,233.5,66.5,238.5,0,.9,0],[Yn,98.8,229.3,99.8,234.3,0,3.1,2],[Yn,98.8,237.7,99.8,242.7,0,3.1,2],[Xn,68.9,250.8,70.1,252,3.5,4.5,3],[Zn,89.4,250.8,91.4,252,3.5,4.8,3],[Qn,115,222.4,121,223.2,0,2,1],[Qn,123.8,226.4,124.6,229.6,0,2,2],[$n,96.4,200.4,97,203.6,0,2.1,0],[er,108.6,197.4,109.6,198.4,0,2,2]],nr=(e,t,n,r,i,a,o=[])=>{let s=(t,n,o)=>e?W(r,o,t,i,a,n,mn):W(t,o,r,n,a,i,mn);return[...o,[n,n]].flatMap(([e,n],r,i)=>[s(r?i[r-1][1]:t,e,0),...n>e?[s(e,n,On)]:[]])},rr=({min:[e,,t],max:[n,r,i]},a,o)=>[W(e,4,t,n,r,i,hn,mn),...nr(0,e,n,t,t+G,4,a[0]),...nr(0,e,n,i-G,i,4,a[1]),...nr(2,t+G,i-G,e,e+G,4,a[2]),...nr(2,t+G,i-G,n-G,n,4),o],ir=[1,.42,.08],ar=[...Sn.slice(2).flatMap((e,t)=>Cn(bn(Sn[t+1])+.2).map(([n,r])=>q([-n,-r,n,r],Sn[t+1],e))),...Wn([[zn,-Tn,wn,Tn],[Vn,Bn,En,Dn],[Hn,Hn,Vn,Vn]]).map(e=>q(e,Un.find(([t,n])=>e[0]<=t&&t<=e[2]&&e[1]<=n&&n<=e[3])?.[3]??0,Sn[1])),...[[-Tn,-wn,-Un[0][2],-zn],[Un[0][2],-wn,Tn,-zn],[Vn,Fn-K[1],En,-Bn],[Vn,-Dn,In-K[0],Mn-K[1]]].map(e=>q(e,0,Sn[1])),...Kn,...tr.map(([,e,t,n,r,i,a])=>({...W(e,i,t,n,a,r,U),ghost:!0})),...rr(kn[0],[[[118,118]],[[116.8,119.2]],[[Mn+G,Fn-G]]],W(121.5,0,223.5,123.5,1.2,225.5,gn,gn,ir)),...rr(kn[1],[[[101.8,104.2]],[[In+G,Rn-G],[105.8,105.8]]],W(106,0,200.6,108,1.2,202.6,gn,gn,ir)),W(jn,On,Mn,Nn,Pn,Fn,U,hn),W(In,On,Ln,Rn,Pn,Fn,U,hn),W(In,0,Fn-G,Nn,On,Fn,hn),W(Rn-G,0,Mn,Nn,On,Mn+G,hn),W(In,0,Ln,In+G,On,Mn,hn),W(Rn-G,0,Ln,Rn,On,Mn,hn),...Gn(2,214,Mn,105,109,0,3.5),...Gn(0,108,Rn,206,210,0,3.5)],[or,sr]=$t,{STONE:J,CONCRETE:cr,METAL:lr,STEEL:ur,PAINT:dr}=k,fr=({min:e,max:t})=>vn(e[0],e[1],280-t[2],t[0],t[1],280-e[2]),pr=[40,220,13],mr=vn(33,.25,218,47,3.25,222),hr=[[27.3,207.3],[52.7,207.3],[27.3,232.7],[52.7,232.7],[106.2,230.4],[103.2,212.4]],gr=K[1]-2,Y=e=>Math.min(Math.max(e,0),1),_r=e=>Y(e)*Y(e)*(3-2*Y(e)),vr=(e,t)=>Math.sqrt(e*e+t*t),yr=[[-100,0,46,.13,.52],[-4,224,36,.12,.67],[110,236,16],[-112,108,14],[236,170,13],[-52,230,10],[80,184,14],[150,250,13],[-36,168,10],[200,152,12],[262,134,14],[240,150,9],[-140,60,12],[-66,60,9],[40,262,10],[118,200,11]],br=[[-20,0,-1,0],[192,124,0,-1],[64,236,1,0],[-60,100,0,1]],[xr,Sr]=[[248,64],[180,200]],Cr=[[12,24],[36,60],[72,88],[124,156]],wr=(()=>{let e=Array.from({length:160},(e,t)=>Cr.some(([e,n])=>t>=e-1&&t<=n)?0:Math.min(Math.round(Math.max(26*A(t/17,0,33)+8*A(t/5,0,35)-11,0))/2,6.5));for(let t of[1,-1])for(let n=t>0?1:158;n>=0&&n<160;n+=t)e[n]=Math.min(e[n],e[n-t]+.5);return e.map((e,t)=>{let n=Math.min(t,159-t);return n<4?-6:n<8?-3:e})})(),Tr=e=>e.reduce((e,t,n)=>(e.at(-1)?.[2]===t?e.at(-1)[1]++:e.push([n,1,t]),e),[]),Er=Tr(wr),X=[114,176,2],Dr=[48,144],[Or,kr]=[3,8],Ar=[[27,67,53,93],[56,74,104,133],[96,56,125,90],[98,36,102,40],[28,113,32,117],[30,45,30,45],[135,50,135,50],[50,106,50,106],[35,104,35,104],[115,22,115,22],[45,20,51,62],[114,36,114,36],[141,20,147,66]],jr=[[0,0,4.5],[-14,6,3],[10,-12,3.5],[16,10,2.5],[-8,-16,2.2],[-20,-8,3.8],[6,18,3],[22,-4,2],[-12,20,2.4]].map(([e,t,n])=>[e-50,t+330,n]),Mr=[[126,143,131,147,1.2],[130,138.5,135,141.5,2.4],[126,133,131,137,1.2]],Nr=[[180,340],[173,346],[186,347]],Pr=[yr[0][0]-4.5,140],Fr=[[4,172,4,4,2.2],[30,154,5,5,3],[66,158,3,3,1.6],[95,164,5,4,2.6],[125,175,6,5,3.2],[92,186,4,4,2.4]],Ir=.85,Lr=Array.from({length:36},(e,t)=>{let n=e=>Ee(t,e,41),r=Math.floor(n(1)*3),[i,a]=r<2?[(r?151:0)+n(2)*9,150+n(3)*122]:[5+n(2)*150,273+n(3)*7];return[i,a+(r===0&&Math.abs(a-174)<8?16:0),.6+2.4*n(4)*n(4)]}).filter(([e,t,n],r,i)=>!i.slice(0,r).some(([r,i,a])=>{let o=Math.max(Math.abs(e-r),Math.abs(t-i))-Ir*(n+a);return o>0&&o<1})),Rr=(e,t)=>{let[n,r]=[0,0];for(let[i,a,o,s=.17,c=0]of yr){let l=vr(e-i,t-a),[u,d]=l?[(e-i)/l,(t-a)/l]:[1,0],f=l/o*(.9+.2*A(2.5*u+.37*i,2.5*d+.21*a,9)),p=.03+.045*A(4*u-.1*a,4*d+.1*i,10),m=1-Y((f-1-4/o)/.6),h=c?(s+p)*Y((f-c)/(1-c))-s:(s+p)*f*f-s;n+=o*(f<1?h:p*m*m),r=Math.max(r,c?Y((1.6-f)/(1.5-c)):0)}return[n,r]},zr=(e,t)=>{let n=t=>Y((12-Math.abs(t-e))/8)*Y((152-t)/4),r=4*Math.floor(t/4);return n(r)+(n(r+4)-n(r))*(t-r)/4},Br=(e,t)=>{t=Math.abs(t-140);let n=vr((e-80)/300,t/360),r=Math.max((n-.78)/.22,0),i=Rr(e,t),a=Math.max(Math.abs(e-80)-80,t-140),o=_r((a-12)/48)*(1-.7*_r(r))*(16*A(e/96,t/96,1)+6*A(e/52,t/52,4)+5*A(e/36,t/36,2)+1.4*A(e/22,t/22,3)-14.2);if(a<0){let n=_r((t-16-10*A(e/19,.5,37))/8)*_r(-a/10);for(let[r,i,a,o]of Ar)n*=_r((vr(Math.max(r-e,e-a,0),Math.max(i-t,t-o,0))-6)/6);o=n*Math.min(Math.max(4.8*A(e/15,t/15,21)-.9,0)+Math.max(3*A(e/31,t/31,23)-.6,0),2.6);let r=_r((10-vr(e-X[0],t-(X[1]-140)))/8);o=o*(1-r)-X[2]*r;for(let n of Dr)o+=Or*Y((8+kr-t)/kr)*zr(n,e);o=t<8?0:o}o=(a<0?o:o*(1-i[1]))+i[0];for(let[n,r,i,a]of br){let[s,c]=[e-n,t-r],l=s*i+c*a;o+=5.6*Y(Math.min(l/16,(32-l)/12))*Y((18-Math.abs(s*a-c*i))/12)}let s=Y(vr(e-xr[0],Math.max(t-xr[1],0))/36);o+=12*(1-s*s)*(1-s*s)+8*_r((36-vr(e-Sr[0],t-Sr[1]))/24);let c=10*r*(1+r);return n>1&&(c=(c+(n-1)*60*(Math.abs(2*A(e/45,t/45,5)-1)-.5))*(1+(n-1)*(1.2*A(e/90,t/90,7)-.6))*(1-_r((n-1.25)/.4))),Math.max(o,-14.5)+c},Vr=[[1,0],[.309,.951],[-.809,.588],[-.809,-.588],[.309,-.951]],Hr=(e,t,n)=>{let r=t=>Ee(e,t,131),i=e=>{let[t,n]=[2*r(e)-1,2*r(e+1)-1],i=Math.sqrt(t*t+n*n)||1;return[t/i,n/i]},a=[0,1,2].slice(0,t<1.3?1:t<3.2?2:3).map(e=>{let[a,o]=i(20*e+1),[s,c]=[[.1,.45,.42][e]*t,[.8,.75,.65][e]*t],l=[a*s,o*s],u=[n,(.5+.15*r(20*e+3))*n,.34*n][e]-.25*n,d=Math.min(.06,.06/c),[f,p]=[(2*r(20*e+4)-1)*d,(2*r(20*e+5)-1)*d],m=Math.sqrt(f*f+1+p*p);return{o:l,rad:c,top:u,planes:[[f/m,1/m,p/m,(f*l[0]+u+p*l[1])/m],...Vr.map(([t,n],i)=>{let[a,o]=[t+r(20*e+6+i)-.5,n+r(20*e+11+i)-.5],s=Math.sqrt(a*a+o*o),u=-.15+.5*r(20*e+16+i),d=Math.sqrt(1-u*u),[f,p]=[d*a/s,d*o/s];return[f,u,p,f*l[0]+p*l[1]+c*(.72+.22*r(20*e+21+i))]})]}}),[o,s]=i(91),c=[.866*o,-.5,.866*s,.72*t];return{reach:t=>{let r=0;for(let{o:e,rad:i,planes:o}of a){let[a,s]=[1.2*i,1.15*n],l=(t[0]*t[0]+t[2]*t[2])/(a*a)+t[1]*t[1]/(s*s),u=-2*(t[0]*e[0]+t[2]*e[1])/(a*a),d=(e[0]*e[0]+e[1]*e[1])/(a*a)-1,f=(-u+Math.sqrt(u*u-4*l*d))/(2*l);for(let[e,n,r,i]of[...o,c]){let a=t[0]*e+t[1]*n+t[2]*r;f=a>1e-9?Math.min(f,i/a):f}r=Math.max(r,f)}return r*(.94+.12*A(1.5*t[0]+e,1.5*t[2]+2*t[1],e))},tops:a.map(({o:e,top:t})=>[e[0],e[1],t])}},Ur=({reach:e,tops:t},n,r)=>{let i=(t,n,r,i=.09)=>{let a=Math.sqrt(t*t+n*n+r*r);return a<1e-6||a<=e([t/a,n/a,r/a])+i},a=[-1,0,1],o=(e,t,n,o,s)=>[r+.05,(r+s)/2,s].every(r=>a.every(s=>a.every(a=>i(e+s*n,r,t+a*o))))&&a.every(r=>a.every(a=>!i(e+r*n,s+.2,t+a*o,0)));return t.flatMap(([e,t,i],a)=>{let s=[0,0,0,0,0,0],c=Math.sqrt(e*e+t*t)||1;for(let l of a?[.1,.3,.5]:[-.15,0,.15])for(let u of[-.15,0,.15]){let[d,f]=a?[e+(l*e-u*t)*(n/c),t+(l*t+u*e)*(n/c)]:[e+l*n,t+u*n],p=0;for(let e=i+.1;!p&&e>r+.3;e-=.1)p=o(d,f,.08*n,.08*n,e)?e:0;let[m,h]=[.08*n,.08*n];for(let[e,t]of p?[[1,1],[1,0],[0,1]]:[])for(let r=.5*n;r>.03;r/=2)[m,h]=o(d,f,m+e*r,h+t*r,p)?[m+e*r,h+t*r]:[m,h];p&&m*h*(p-r)>s[0]&&(s=[m*h*(p-r),d,f,m,h,p])}let[,l,u,d,f,p]=s;return Math.min(d,f)<(a?.25:0)?[]:[[l-d,r,u-f,l+d,p,u+f]]})},Wr=(e,t,n,r,i,a=0)=>{let o=Br(e,t),s=o+.25*r;return{at:[e,o,t],R:n,H:r,s:i,parts:Ur(Hr(i,n,r),n,-.25*r).filter((e,t,n)=>{let r=Math.max(e[0]-n[0][3],n[0][0]-e[3],e[2]-n[0][5],n[0][2]-e[5]);return!t||r<=0||r>1.2}).map(([n,,r,i,o,c])=>[e+n,a,t+r,e+i,s+o,t+c])}},Gr={arena:[...Fr.map(([e,t,n,r,i],a)=>Wr(e+n/2,t+r/2,.31*(n+r),1.15*i,a+61)),...Lr.map(([e,t,n],r)=>Wr(e,t,n,.8*n,r))],field:jr.map(([e,t,n],r)=>Wr(e,t,n,.75*n,r+100,Br(e,t)-6))},Kr=e=>e.flatMap(e=>e.parts).map(([e,t,n,r,i,a])=>({...W(e,t,n,r,i,a,J),ghost:!0})),[Z,qr,Jr,Yr]=[9,12,-19,7],Xr=yr.filter(e=>e[4]).map(([e,t],n)=>{let r=140+t,i=Array.from({length:2*Z},(e,t)=>{let i=Math.abs(t+.5-Z),a=Math.sqrt(Z*Z-i*i),o=e=>Math.ceil(2*a*(.88+.24*A(i/4,e+.5,60+n)))/2;return[r-Z+t,r-Z+t+1,o(0),o(1)]});return{x:e,z:r,level:Br(e,r),rows:i}}),Zr=({x:e,z:t,level:n,rows:r})=>{let i=r.reduce((e,[t,n,r,i])=>{let a=e.at(-1);return a&&a[2]===r&&a[3]===i?a[1]=n:e.push([t,n,r,i]),e},[]),a=r[Z][3],o=(n-Jr)/Yr;return[W(e-qr,-30,t-qr,e+qr,n,t-Z,J),W(e-qr,-30,t+Z,e+qr,n,t+qr,J),...i.flatMap(([t,r,i,a])=>[W(e-qr,-30,t,e-i,n,r,J),W(e+a,-30,t,e+qr,n,r,J)]),W(e-Z-1.5,-30,t-Z,e+Z+1.5,Jr,t+Z,J),...Array.from({length:Yr-1},(n,r)=>W(e+a-1.3*(Yr-1-r),Jr,t-1,e+a-1.3*(Yr-2-r),Jr+o*(r+1),t+1,J))].map(e=>({...e,ghost:!0}))},Qr=(e,t,n,r)=>({...W(e-n,Br(e,t)-6,t-n,e+n,Br(e,t)+r,t+n,J),ghost:!0}),$r={rocks:[...jr,...jr.map(([e,t,n])=>[e,280-t,n])],dishes:[...Nr,...Nr.map(([e,t])=>[e,280-t])],ramps:br.flatMap(([e,t,n,r])=>(t?[1,-1]:[1]).map(i=>[e+16*n,140+i*(t+16*r),n,i*r+0])),wreck:Pr,pits:Xr.flatMap(e=>e.z===140?[e]:[e,{...e,z:280-e.z,rows:e.rows.map(([e,t,n,r])=>[280-t,280-e,n,r]).reverse()}]),bowls:yr.flatMap(([e,t,n,r=.17])=>(t?[1,-1]:[1]).map(i=>[e,140+i*t,n,r])),boulders:Lr,crags:Gr,stones:Fr,pillars:Mr,domes:[K,[K[0],280-K[1]]],pads:[pr,[pr[0],280-pr[1],pr[2]]],shuttles:[mr,fr(mr)],modules:[...kn,...kn.map(fr)],tubes:[...An,...An.map(fr)],masts:[...hr,...hr.map(([e,t])=>[e,280-t])]},ei=e=>({...e,min:[e.min[0],e.min[1],280-e.max[2]],max:[e.max[0],e.max[1],280-e.min[2]],tint:e.tint===or?sr:e.tint}),ti=([e,t,n])=>[e,t,280-n],ni=(e,...t)=>[...e,...e.map(ti),...t],ri=[...[W(0,-30,160,160,0,X[1]-12,J),W(0,-30,X[1]-12,X[0]-12,0,X[1]+12,J),W(X[0]+12,-30,X[1]-12,160,0,X[1]+12,J),W(0,-30,X[1]+12,160,0,280,J),W(X[0]-12,-30,X[1]-12,X[0]+12,-3,X[1]+12,J),...Er.filter(e=>e[2]<0).map(([e,t,n])=>W(e,-30,148+n,e+t,0,160,J)),...Array.from({length:14},(e,t)=>Tr(wr.map(e=>e<0?2:+(e>t/2))).filter(e=>!e[2]).map(([e,n])=>W(e,-30,148+t/2,e+n,0,t<13?148.5+t/2:160,J))).flat(),...Dr.flatMap(e=>[-12,-10,-8,-6,-4,4,6,8,10].map(e=>[e,e+(e===-4?8:2)]).map(([t,n])=>[e+t,e+n,Or*Math.min(zr(e,e+t),zr(e,e+n))*(1-.5/kr)-.12]).filter(e=>e[2]>.3).map(([e,t,n])=>W(e,0,148,t,n,148.5,J)))].map(e=>({...e,ghost:!0})),...ar,{...W(75.25,0,gr-4.75,84.75,.5,gr+4.75,dr,cr,or),ghost:!0},{...W(75.75,.5,gr-4.25,84.25,1,gr+4.25,dr,cr,or),ghost:!0},W(60,0,259,70,1.5,265,ur,dr,or),W(27,0,207,53,.25,233,lr),{..._n(mr,dr),tint:[.82,.84,.88]},{...W(42,1,222,45.8,1.25,225.5,lr),ghost:!0},{...W(42,1,214.5,45.8,1.25,218,lr),ghost:!0},{...W(43,3.25,219.9,46.8,5.4,220.1,dr),ghost:!0},...hr.map(([e,t])=>W(e-.2,e<60?.25:0,t-.2,e+.2,e<60?10.25:10,t+.2,ur)),W(12,-30,148-2.5/2,24,0,148,dr,J,[1,.42,.08]),...Xr.filter(e=>e.z!==140).flatMap(Zr),...Kr(Gr.arena),...Kr(Gr.field),...Nr.map(([e,t])=>Qr(e,t,.4,6))],ii=[W(74,-1.5,132,86,0,148,lr,ur),W(74,0,132,74.4,1.1,148,cr),W(85.6,0,132,86,1.1,148,cr),...Mr.map(([e,t,n,r,i])=>({...W(e,-30,t,n,i,r,J),ghost:!0})),{...W(-10,-30,132,0,0,148,J),ghost:!0},{...W(160,-30,132,170,0,148,J),ghost:!0},{...W(Pr[0]-3.6,-30,Pr[1]-3.6,Pr[0]+3.6,Jr+3.5,Pr[1]+3.6,J),ghost:!0},...Xr.filter(e=>e.z===140).flatMap(Zr),...$r.ramps.flatMap(([e,t,n,r])=>[-8,8].map(i=>Qr(e+i*r,t-i*n,.2,2.2)))],ai=[...[56,68,80,92,104].map(e=>[e,0,271,0]),...[62,80,98].map(e=>[e,0,267,0])],oi=e=>Object.fromEntries([`rifle`,`rail`,`rack`,`blade`].map((t,n)=>[t,[61.25+2.5*n,1.5,e]])),si=(e,t)=>({base:[80,1,e],spawns:t,...oi(e+(e>140?28:-28))}),ci={highline:pn,tranquility:{name:`Tranquility`,brushes:[...ri,...ri.map(ei),...ii],teams:[si(gr,ai),si(280-gr,ai.map(([e,t,n])=>[e,t,280-n,Math.PI]))],packs:ni([[90,0,210],[118,5,226],[30,0,185],[80,3.5,253.5]],[45,0,162],[45,0,118]),ammo:ni([[50,0,246],[103,5,200],[135,0,190]],[115,0,162],[115,0,118]),cells:ni([[106.5,3.5,226],[35,0,244]],[80,0,140]),floor:-26,relief:{hole:[0,132,160,148],pits:[...Er.flatMap(([e,t,n])=>n>0?[[e,148,e+t,148+n],[e,132-n,e+t,132]]:[]),...$r.pits.flatMap(({x:e,rows:t})=>t.map(([t,n,r,i])=>[e-r,t,e+i,n]))],bound:[80,140,300,360],cell:4,at:Br},sun:{dir:[.87996,.40998,.23999],color:[3,2.95,2.85]},sky:[[.002,.002,.006],[.02,.02,.035]],gravity:.5,rovers:[[100,0,178,0],[30,0,255,0],[100,0,102,Math.PI],[30,0,25,Math.PI]],scenery:`moon`,helmets:!0,armor:!0}},li=e=>e!==void 0&&ci[e]||pn,ui=e=>e!==void 0&&Object.hasOwn(ci,e)?e:`highline`,di=40/60,fi=b/60,pi=e=>[oe*Math.sin(e*2.4),oe*Math.cos(e*1.7)],mi=(e,t=0)=>{let[n,r]=e.rifled?pi(e.shots):[0,0],[i,a]=[e.yaw+n,e.pitch+r],[o,s,c,l]=[Math.sin(i),Math.cos(i),Math.sin(a),Math.cos(a)];return{id:e.shots,by:e.id,team:t,x:e.x,y:e.y+$e(e),z:e.z,dx:-o*l,dy:c,dz:-s*l,left:e.rifled?60:80,burst:!1,power:e.rifled?0:e.power??1}},hi=(e,t=0)=>({...mi(e,t),id:e.shots^128,left:x,power:1,arc:e.cut}),gi=e=>e.arc?fi:e.power===6?2:di,_i=(e,t,n,r,i)=>{let[a,o]=[e[0]-n.x,e[2]-n.z],s=t[0]*t[0]+t[2]*t[2],c=a*t[0]+o*t[2],l=c*c-s*(a*a+o*o-r*r),[u,d]=[0,1/0];if(s>1e-12){if(l<0)return 1/0;[u,d]=[(-c-Math.sqrt(l))/s,(-c+Math.sqrt(l))/s]}else if(a*a+o*o>r*r)return 1/0;let[f,p]=[n.y-e[1],n.y+i-e[1]];if(t[1])[u,d]=[Math.max(u,Math.min(f/t[1],p/t[1])),Math.min(d,Math.max(f/t[1],p/t[1]))];else if(f>0||p<0)return 1/0;return u<=d&&d>=0?Math.max(u,0):1/0},vi=(t,n,r,i)=>{let a=[n.x,n.y,n.z],o=[n.dx,n.dy,n.dz],s=Math.min(r,n.left),c=ze(t,a,o,s,f),l;for(let t of i){let r=_i(a,o,t,e+(n.arc?ee:f),L(t));r<c&&([c,l]=[r,t])}return n.burst=c<s,n.left-=c,[n.x,n.y,n.z]=[a[0]+o[0]*c,a[1]+o[1]*c,a[2]+o[2]*c],l},yi=(e,t=0)=>({...mi({...e,rifled:!1},t),left:150,power:7,v:36}),bi=(e,t,n)=>{let r=Math.fround,[i,a,o]=[t.dx*t.v,t.dy*t.v-gt(e)/60,t.dz*t.v],s=Math.sqrt(i*i+a*a+o*o)||1;[t.dx,t.dy,t.dz,t.v]=[r(i/s),r(a/s),r(o/s),r(s)];let c=vi(e,t,t.v/60,n);return[t.x,t.y,t.z,t.left]=[r(t.x),r(t.y),r(t.z),r(t.left)],t.burst||=t.left<=0,c},xi=(e,t,n)=>{let r=L(n),i=[n.x,Math.max(n.y,Math.min(n.y+r,t[1])),n.z],[a,o,s]=[i[0]-t[0],i[1]-t[1],i[2]-t[2]],c=Math.sqrt(a*a+o*o+s*s);return c>=5||Ve(e,t,i)&&Ve(e,t,[n.x,n.y+.7*r,n.z])?0:Math.ceil(5*(1-c/5))},Si=(t,n,r=[],i=30,[a,o]=[0,0])=>{let s=[n.x,n.y+$e(n),n.z],[c,l]=[n.yaw+a,n.pitch+o],u=Math.cos(l),d=[-Math.sin(c)*u,Math.sin(l),-Math.cos(c)*u],f=ze(t,s,d,i),p;for(let t of r){let n=_i(s,d,t,e,L(t));n<f&&([f,p]=[n,t])}return{o:s,d,t:f,hit:p}},Q={A:1.25,B:1,WR:.5,L0:.6,CMAX:.5,K:30,D:2,KP2:1.2,KR2:.7,HC:.7,ENGINE:12,VMAX:23.2,VREV:8,BRAKE:14,ROLL:.6,HB:6,MU:1.1,MUL:1.2,HBG:.35,HBY:1.5,SK:2.5,SV:10,SMAX:.55,SRATE:3.5,YMAX:2.4,YRESP:10,AK:5,AC:3,AD:.5,TILT:.9,RB:1.05,BODY:[1.15,0,-1.15],BODY_H:1.5,WHEEL_STEP:.6,BOUNCE:.3,ENTER_R:3,SPLAT_MIN:6,SPLAT_KILL:12,GUN_COOL:8,GUN_RANGE:90,GUN_AIM:50},Ci=[[-1.05,.18,.6],[1.05,.18,.6]],wi=[[-.45,-.35,.1],[.45,-.35,.1]],Ti=[1,1,-1,-1].map(e=>e*Q.A),Ei=[-1,1,-1,1].map(e=>e*Q.B),Di=Q.L0+Q.WR,Oi=Q.RB+e+.15,ki=1,Ai=`x y z vx vy vz yaw pitch roll wy wp wr steer`.split(` `),$=1/60,ji=Math.fround,{sin:Mi,cos:Ni,min:Pi,max:Fi,abs:Ii,sqrt:Li}=Math,Ri=(e,t,n)=>Pi(Fi(e,t),n),zi=(e,t,n,r=0)=>{let[i,a]=P(e.yaw),[o,s]=[t*Ni(e.pitch),n*Ni(e.roll)];return[e.x+i*o-a*s,e.y+r+t*Mi(e.pitch)-n*Mi(e.roll),e.z+a*o+i*s]},Bi=(e,t)=>Ti.map((n,r)=>{let[i,a,o]=zi(e,n,Ei[r]);return[i,a,o,Di+ct(t,i,o,a-Q.L0+Q.WHEEL_STEP)-a]}),Vi=e=>Q.BODY.map(t=>zi(e,t,0,-Di)),Hi=e=>{let[t,,n]=Vi(e);return{a:t,b:n,r:Q.RB,h:Q.BODY_H}},Ui=e=>(e.def.rovers??[]).map(([e,t,n,r])=>({x:ji(e),y:ji(t+Di),z:ji(n),vx:0,vy:0,vz:0,yaw:ji(Ge(r)),pitch:0,roll:0,wy:0,wp:0,wr:0,steer:0,driver:255,rider:255})),Wi=(e,t,n,r=[])=>{let{A:i,B:a,CMAX:o,K:s,D:c,KP2:l,KR2:u,HC:d,MU:f,MUL:p,TILT:m}=Q,h=gt(n),g=t?t.keys:0,_=(g&w.FORWARD?1:0)-(g&w.BACK?1:0),v=g&w.JUMP,[y,b]=P(e.yaw),[x,ee]=[Ni(e.pitch),Ni(e.roll)],te=Bi(e,n),[ne,S,re,ie]=te.map(([,e,,t])=>t+e-Di),ae=te.some(e=>e[3]<-o),oe=ae?0:(ne+S-re-ie)/(4*i*x),se=ae?0:(S+ie-ne-re)/(4*a*ee),C=1/Li(oe*oe+se*se+1),ce=-(oe*y-se*b)*C,T=-(oe*b+se*y)*C,E=()=>e.vx*ce+e.vy*C+e.vz*T,D=Fi(0,...te.map(e=>e[3]-o));if(D){e.y+=D;let t=Pi(0,E());e.vx-=t*ce,e.vy-=t*C,e.vz-=t*T}let le=E(),[O,k,ue]=[0,0,0];te.forEach(([,,,t],n)=>{if(t>D){let r=Fi(0,s*(t-D)-c*(le+(Ti[n]*x*e.wp-Ei[n]*ee*e.wr)*C));O+=r,k+=r*Ti[n],ue+=r*Ei[n]}}),e.vx+=O*ce*$,e.vy+=(O*C-h)*$,e.vz+=O*T*$,e.wp+=k/l*$,e.wr-=ue/u*$;let de=Pi(O/h,2);if(de>0){let n=e.vx*y+e.vz*b,r=e.vz*y-e.vx*b,a=t?Ge(t.yaw-e.yaw+Math.PI)-Math.PI:0,o=Ri(Q.SK*a/(1+Ii(n)/Q.SV),-Q.SMAX,Q.SMAX),s=Q.SRATE*$;e.steer+=Ri((n+_<0?-o:o)-e.steer,-s,s);let c=Ri(n*e.steer/(2*i),-Q.YMAX,Q.YMAX)*(v?Q.HBY:1);e.wy+=(c-e.wy)*Q.YRESP*$*Pi(1,de);let m=h*de*$,g=Ri((_*n<0?_*Q.BRAKE:_*Q.ENGINE*Fi(0,1-Ii(n)/(_>0?Q.VMAX:Q.VREV)))*$,-p*m,p*m),x=(Q.ROLL+(v||!t?Q.HB:0))*de*$;g-=Ri(n+g,-x,x);let ee=f*m*(v?Q.HBG:1),te=-Ri(r,-ee,ee);e.vx+=g*y-te*b,e.vz+=g*b+te*y,e.wp+=g*d/l,e.wr-=te*d/u}else e.wp-=(Q.AK*e.pitch+Q.AC*e.wp)*$,e.wr-=(Q.AK*e.roll+Q.AC*e.wr)*$;e.wp*=1-Q.AD*$,e.wr*=1-Q.AD*$,e.x+=e.vx*$,e.y+=e.vy*$,e.z+=e.vz*$,e.yaw=Ge(e.yaw+e.wy*$),e.pitch=Ri(e.pitch+e.wp*$,-m,m),e.roll=Ri(e.roll+e.wr*$,-m,m),Ii(e.pitch)===m&&e.pitch*e.wp>0&&(e.wp=0),Ii(e.roll)===m&&e.roll*e.wr>0&&(e.wr=0);for(let t of Q.BODY){let[r,i,a]=zi(e,t,0,-Di),[o,s]=it({x:r,y:Fi(i,ne,S,re,ie),z:a},n,Q.BODY_H,Q.RB),c=o*o+s*s;if(c){e.x+=o,e.z+=s;let t=Pi(0,e.vx*o+e.vz*s)/c;e.vx-=t*o,e.vz-=t*s}}for(let t of r){if(t===e)continue;let n=Hi(t);for(let r of Q.BODY){let[i,a,o]=zi(e,r,0,-Di),[s,c,l]=at(n,i,o),u=2*Q.RB,d=Li(s*s+c*c);if(d>=u-1e-4||l>=a+Q.BODY_H||l+Q.BODY_H<=a)continue;let[f,p]=P(t.yaw),[m,h]=d?[s/d,c/d]:[-p,f];e.x+=m*(u-d),e.z+=h*(u-d);let g=Pi(0,e.vx*m+e.vz*h)*(1+Q.BOUNCE);e.vx-=g*m,e.vz-=g*h}}Ae(e,n);for(let t of Ai)e[t]=ji(e[t]);return e.y<n.def.floor},Gi=(e,t,n)=>{let[r,i,a]=wi[n];[e.x,e.y,e.z]=zi(t,a,r,i).map(ji),e.vx=t.vx,e.vy=t.vy,e.vz=t.vz},Ki=(e,t,n)=>{t[n?`rider`:`driver`]=e.id,e.mode=D.RIDE,e.t=0,e.edge=0,e.ground=!1,e.dash=Pi(e.dash,50),e.coyote=0,e.buffer=0,Gi(e,t,n)},qi=(n,r,i,a)=>{r[i?`rider`:`driver`]=255,n.mode=D.AIR,n.t=0,n.coyote=0,[n.vx,n.vy,n.vz]=[r.vx,r.vy,r.vz];let o=i?Oi:-Oi;for(let[s,c]of[[o,-Di],[-o,-Di],[0,Q.BODY_H-Di]]){let[o,l,u]=zi(r,wi[i][2],s,c);Object.assign(n,{x:o,y:l,z:u}),Ae(n,a);let d=ct(a,n.x,n.z,r.y);n.y=Fi(l,d);let[f,p]=it(n,a,t,e);if(!s||d>l-ki&&!f&&!p)break}[n.x,n.y,n.z,n.vx,n.vz]=[n.x,n.y,n.z,n.vx,n.vz].map(ji)},Ji=(e,t,n,r,i,a=[])=>{let o=(n.keys&w.USE)!==0&&(e.held&w.USE)===0,s=Wi(t,n,r,a);return qt(e,n,r,i,!1),e.mode===D.RIDE?(Gi(e,t,0),o&&qi(e,t,0,r)):t.driver=255,s},Yi=(e,t,n)=>{let[r,i,a,o]=[Math.sin(t),Math.cos(t),Math.sin(n),Math.cos(n)];return[e.x-r*o*Q.GUN_AIM,e.y+a*Q.GUN_AIM,e.z-i*o*Q.GUN_AIM]},Xi=(e,t,n,r,i,a)=>{let[o,s]=P(e.yaw),c=Yi(e,r,i);return Ci.map(([r,i,l],u)=>{let d=[e.x+o*l-s*r,e.y+i,e.z+s*l+o*r],f=c.map((e,t)=>e-d[t]),p=Math.sqrt(f[0]*f[0]+f[1]*f[1]+f[2]*f[2]);return{id:a+u&255,by:t,team:n,x:d[0],y:d[1],z:d[2],dx:f[0]/p,dy:f[1]/p,dz:f[2]/p,left:Q.GUN_RANGE,burst:!1,power:6}})},Zi=e=>e.mode===D.SLIDE||e.dash>50,Qi=(e,t)=>Math.hypot(e.x-t.x,e.z-t.z)<1.1&&e.y<t.y+L(t)&&t.y<e.y+L(e),$i=20,ea=2,ta=30,na=[`driver`,`rider`],ra=(e,t)=>Array.from(e).slice(0,t).join(``).trim(),ia=e=>ra((typeof e==`string`?e:``).replace(/\s+/g,` `).replace(/\p{Cc}/gu,``).trim(),16),aa=(e,t)=>{let n=e;for(let r=2;t.includes(n);r++)n=`${ra(e,15-`${r}`.length)} ${r}`;return n},oa=(e,t)=>Math.sqrt(e*e+t*t),sa=(e,t)=>{let n=setInterval(e,t);return()=>clearInterval(n)},ca={lock:0,foe:0,pushes:0,pressed:!1,away:0},la=({x:e,y:t,z:n,yaw:r})=>({x:e,y:t,z:n,yaw:r}),ua=({x:e,y:t,z:n})=>({x:e,y:t,z:n}),da=class{peers=/* @__PURE__ */ new Map;ticks=0;history=[];world;ctf;halt;rules;rr=[0,0];gone;balls=[];rovers;mapName;next;joins=0;constructor(e={},t){this.rules={...se,...e},this.mapName=ui(this.rules.map),this.world=Le(t??li(this.mapName)),this.ctf=new Ut(this.world,this.rules),this.gone=this.spots(),this.rovers=Ui(this.world)}spots(){let{packs:e=[],ammo:t=[],cells:n=[]}=this.world.def;return[...e,...t,...n].map(()=>0)}host(){return this.players().reduce((e,t)=>e&&e.since<t.since?e:t,void 0)}load(){if(this.next!==void 0){this.mapName=this.next,this.next=void 0,this.world=Le(li(this.mapName)),this.ctf=new Ut(this.world,this.rules),this.gone=this.spots(),this.rovers=Ui(this.world),this.history=[],this.balls=[];for(let e of this.players())this.ctf.join(e.info.id,e.info.team,e.state);this.roster()}}get size(){return this.players().length}connect(e){this.peers.set(e,null)}receive(e,t){let n=this.peers.get(e);if(typeof t==`string`){let r=Te(t);n===null&&r?.t===`join`?this.join(e,r.name,r.body):n&&r?.t===`map`&&n===this.host()&&Object.hasOwn(ci,r.map)&&(this.next=r.map===this.mapName?void 0:r.map,this.roster());return}let r=n&&Se(t);if(r&&n.bank>0){n.bank--;let e=n.state.slow??0,t=(r.keys&w.USE)!==0&&(n.state.held&w.USE)===0,[i,a]=this.seatOf(n);if(i&&!a){let e=Ji(n.state,i,r,this.world,n.info.team,this.rovers);this.ctf.moved(n.state),e?this.sink(i):(this.carry(i),this.splat(n,i,r.view),this.lase(n,i,r))}else{let e=qt(n.state,r,this.world,n.info.team,!this.ctf.over,this.rovers.map(Hi));this.ctf.moved(n.state),this.tackle(n,r.view);let a=ua(n.state),o=i&&e?this.past(r.view).find(e=>e.id===n.info.id):void 0;Object.assign(n.state,o&&ua(o)),e===z.SHOT?this.shoot(n,r.view):e===z.CUT?this.cut(n,r.view):e===z.RAIL?this.rail(n,r.view):e===z.LASER?this.shoot(n,r.view):e===z.NADE&&this.shoot(n,r.view,yi(n.state,n.info.team)),Object.assign(n.state,a),t&&i&&n.state.mode===D.RIDE?qi(n.state,i,1,this.world):t&&this.enter(n)}n.burn=e?(n.burn??0)+1:0,e&&!(n.burn%60)&&this.fry(n),this.duel(n),n.ack=r.seq,this.seats()}}disconnect(e){let t=this.peers.get(e);this.peers.delete(e),t&&(this.ctf.leave(t.info.id),this.size||(this.ctf.reset(),this.gone.fill(0),this.rovers=Ui(this.world),this.load()),this.seats(),this.roster())}drop(e){let t=this.players().find(t=>t.info.id===e);return!!t&&this.ctf.drop(t.state)}tick(){let e=this.players();if(!e.length){this.balls=[];return}let t=++this.ticks;for(let t of e)t.bank=Math.min(10,t.bank+1);for(let e of this.balls)!e.burst&&e.left>0&&this.fly(e,gi(e));this.heal(e);let n=this.ctf.tick(e.filter(e=>!e.state.down&&!this.rovers.some(t=>t.driver===e.info.id)).map(e=>({id:e.info.id,team:e.info.team,state:e.state})));n===`end`?this.end(e):n===`start`&&(this.load(),this.restart(e)),this.seats();for(let e of this.rovers)e.driver===255&&Wi(e,void 0,this.world,this.rovers)?this.sink(e):this.carry(e);if(this.seats(),t%2==0){for(this.history.push({tick:t,players:e.map(e=>({...e.state}))});this.history[0].tick<t-30;)this.history.shift();let n=we({tick:t,players:e.map(e=>({...e.state,ack:e.ack,by:e.state.stun?e.by:0})),...this.ctf.wire(),packs:this.gone.reduce((e,t,n)=>t?e:e+2**n,0),balls:this.balls,rovers:this.rovers});e.forEach(e=>e.conn.send(n)),this.balls=this.balls.filter(e=>!e.burst&&e.left>0)}}start(e=sa){if(this.halt)return;let t=1e3/60,n=performance.now(),r=0;this.halt=e(()=>{let e=performance.now();r+=e-n,n=e;for(let e=0;r>=t&&e<$i;e++)this.tick(),r-=t;r%=t},t)}stop(){this.halt?.(),this.halt=void 0}rewind(e,t=0){return this.past(t).filter(t=>t.id!==e)}past(e=0){let t=this.players().map(e=>e.state),[n,r]=[this.history[0],this.history.at(-1)];if(!n||!r)return t;let i=((this.ticks-e+32768)%65536+65536)%65536-32768,a=Math.min(Math.max(this.ticks-i,n.tick),r.tick),o=0;for(;o+1<this.history.length&&this.history[o+1].tick<=a;)o++;let[s,c]=[this.history[o],this.history[o+1]??this.history[o]],l=c.tick>s.tick?(a-s.tick)/(c.tick-s.tick):0,u=(e,t)=>e+(t-e)*l;return t.map(e=>{let t=s.players.find(t=>t.id===e.id),n=c.players.find(t=>t.id===e.id);return t&&n?{...n,x:u(t.x,n.x),y:u(t.y,n.y),z:u(t.z,n.z)}:n??t??e})}tackle(e,t){let n=e.state;if(n.down||!Zi(n)||this.ticks-e.tackled<30)return;let r=this.players().filter(t=>t.info.team!==e.info.team),i=this.rewind(e.info.id,t).find(e=>Qi(n,e)&&r.some(t=>t.info.id===e.id&&this.ctf.carrying(t.info.id)>=0)),a=r.find(e=>e.info.id===i?.id);if(!a||!this.drop(a.info.id))return;let o=et(n),[s,c]=o>.001?[n.vx/o,n.vz/o]:P(n.yaw);yt(a.state,s,c),a.state.zap=!1,a.by=e.info.id,e.tackled=this.ticks}enemies(e,t){let n=this.players();return this.rewind(e.info.id,t).filter(t=>{let r=n.find(e=>e.info.id===t.id);return r&&r.info.team!==e.info.team&&!r.state.down&&!t.down})}harm(e,t){return(e.state.hp-=t)>0?!1:([e.graze,e.bruise,e.blows]=[0,0,0],e.state.mode===D.RIDE&&this.unseat(e),Object.assign(e.state,{hp:0,down:120,ammo:-1,cool:0,charge:0,mag:0,cap:0,reload:0,blade:!1,wield:!1,swing:0,lost:E.NONE,rail:-1,railed:!1,rifle:-1,clip:0,rifled:!1,nades:0,lob:0,zapping:!1,slow:0}),this.ctf.drop(e.state),!0)}shoot(e,t=0,n=mi(e.state,e.info.team)){let r=(this.ticks-t+65536)%65536;this.balls.push(n);let i=Math.min(r<32768?r:0,12);if(n.power===7)for(let e=0;e<i&&!n.burst;e++)this.fly(n,0);else this.fly(n,i*gi(n));let a=this.balls.filter(e=>!e.burst);a.length>64&&(a[0].burst=!0)}fly(e,t){let n=this.players(),r=n.filter(t=>t.info.team!==e.team&&!t.state.down);if(e.power===7){bi(this.world,e,r.map(e=>e.state));let t=!1;for(let r of e.burst?n:[]){let n=r.info.id===e.by,i=!r.state.down&&(n||r.info.team!==e.team)?xi(this.world,[e.x,e.y,e.z],r.state):0;i&&(this.harm(r,i),t||=!n)}let i=n.find(t=>t.info.id===e.by);t&&i&&(i.state.hits=i.state.hits+1&255);return}let i=vi(this.world,e,t,r.map(e=>e.state)),a=r.find(e=>e.state===i);if(!a)return;let o=n.find(t=>t.info.id===e.by);if(o&&(o.state.hits=o.state.hits+1&255),e.power===0||e.power===6)a.graze=((a.graze??0)+1)%2,a.graze||this.harm(a,1);else if(!e.arc)this.harm(a,e.power??1);else if(this.harm(a,p[e.arc].hp)){let t=o&&{...o.state,cut:e.arc,yaw:Math.atan2(-e.dx,-e.dz)};a.state.lost=t?Bt(Object.assign(t,{x:e.x-e.dx,y:e.y-e.dy-Pt*L(t),z:e.z-e.dz,pitch:Math.asin(e.dy)}),a.state):E.NONE}else{let t=Math.hypot(e.dx,e.dz)||1;yt(a.state,e.dx/t,e.dz/t,te,ne),a.state.zap=!0,a.by=e.by,this.ctf.drop(a.state)}}cut(e,t){if(!e.state.blade){this.punch(e,t);return}if(e.state.cut===T.ARC_L||e.state.cut===T.ARC_R){this.shoot(e,t,hi(e.state,e.info.team));return}let n=Lt(this.world,e.state,this.enemies(e,t)),r=this.players().filter(e=>n.some(t=>t.id===e.info.id)),i=r.find(t=>Rt(e.state,{...t.state,...la(n.find(e=>e.id===t.info.id))}));if(i){for(let[t,n]of[[e,i],[i,e]])Object.assign(t.state,{...ca,lock:240,foe:n.info.id,pressed:!0}),Object.assign(t.state,{swing:0,charge:0,stun:0,zap:!1,vx:0,vz:0});r=r.filter(e=>e!==i)}if(r.length){e.state.hits=e.state.hits+1&255;for(let t of r){let r=n.find(e=>e.id===t.info.id);if(this.harm(t,It(e.state).hp))t.state.lost=Bt(e.state,r);else{let[n,r]=zt(e.state);yt(t.state,n,r,24,4*(e.state.heavy?m:1)),t.state.zap=!0,t.by=e.info.id}}}}punch(e,t){let n=Lt(this.world,e.state,this.enemies(e,t),c),r=this.players().filter(e=>n.some(t=>t.id===e.info.id));if(r.length){e.state.hits=e.state.hits+1&255;for(let t of r)if(t.blows=(this.ticks-(t.punched??-1/0)<=d?t.blows??0:0)+1,t.punched=this.ticks,t.bruise=((t.bruise??0)+1)%l,(t.bruise||!this.harm(t,1))&&t.blows>=u){t.blows=0,this.drop(t.info.id);let[n,r]=P(e.state.yaw);yt(t.state,n,r),t.state.zap=!1,t.by=e.info.id}}}rail(e,t){let{hit:n}=Si(this.world,e.state,this.enemies(e,t)),r=this.players().find(e=>e.info.id===n?.id);if(r){let t=!r.state.slow;r.state.slow=180,t&&(e.state.hits=e.state.hits+1&255,r.burn=0,this.fry(r))}}fry(e){e.state.fried=this.harm(e,1)}duel(e){let t=e.state;if(!t.lock)return;let n=this.players().find(e=>e.info.id===t.foe);if(!n||n.state.foe!==e.info.id||!n.state.lock||n.state.down||t.down){Object.assign(t,ca);return}let r=(t.pushes??0)-(n.state.pushes??0),i=(t.away??0)>=24||(n.state.away??0)>=24;if(!(Math.abs(r)<8&&!i&&t.lock>1)){if(Object.assign(t,ca),Object.assign(n.state,ca),Math.abs(r)>=8){let[t,i]=r>0?[e,n]:[n,e];if(t.state.hits=t.state.hits+1&255,!this.harm(i,3)){let[e,n]=P(t.state.yaw);yt(i.state,e,n,24,4),i.state.zap=!0,i.by=t.info.id}}else if(!i){let[e,r]=[n.state.x-t.x,n.state.z-t.z],i=Math.hypot(e,r)||1;yt(t,-e/i,-r/i),yt(n.state,e/i,r/i)}}}heal(e){let{packs:t=[],ammo:n=[],cells:r=[]}=this.world.def;[...t,...n,...r].forEach((r,i)=>{if(this.gone[i]>0){this.gone[i]--;return}let a=+(i>=t.length)+ +(i>=t.length+n.length),o=e=>[e.hp<5,e.ammo>=0&&e.ammo<60||(e.rifle??-1)>=0&&e.rifle<240,(e.rail??-1)>=0&&e.rail<240][a],s=e.find(({state:e})=>!e.down&&o(e)&&Gt(e,r,.9));if(s){let e=s.state;a==0?e.hp=Math.min(5,e.hp+2):a==1?(e.ammo=e.ammo<0?-1:Math.min(60,e.ammo+20),e.rifle=(e.rifle??-1)<0?-1:Math.min(240,e.rifle+60)):e.rail=Math.min(240,e.rail+80),this.gone[i]=(a==1?10:20)*60}})}seatOf(e){if(e.state.mode===D.RIDE)for(let t of this.rovers){let n=na.findIndex(n=>t[n]===e.info.id);if(n>=0)return[t,n]}return[]}unseat(e){for(let t of this.rovers)na.forEach(n=>t[n]=t[n]===e.info.id?255:t[n]);Object.assign(e.state,{mode:D.AIR,t:0,coyote:0})}seats(){let e=this.players();for(let t of this.rovers)for(let n of na)e.some(e=>e.info.id===t[n]&&e.state.mode===D.RIDE)||(t[n]=255);for(let t of e)t.state.mode===D.RIDE&&!this.seatOf(t).length&&this.unseat(t)}enter(e){let t=e.state;if(t.down||t.stun||t.lock||t.mode===D.RIDE)return;let n=this.ctf.carrying(e.info.id)>=0,r=e=>Math.abs(e.y-t.y)>Q.ENTER_R?1/0:(e.x-t.x)**2+(e.z-t.z)**2,i=e=>e.driver===255&&!n?0:e.rider===255?1:-1,a=this.rovers.filter(e=>r(e)<=Q.ENTER_R**2&&i(e)>=0).sort((e,t)=>r(e)-r(t))[0];a&&Ki(t,a,i(a))}carry(e){let t=this.players().find(t=>t.info.id===e.rider);if(t?.state.mode===D.RIDE){Gi(t.state,e,1);let n=ct(this.world,e.x,e.z,e.y);n>this.world.def.floor&&this.ctf.place(t.info.id,{...t.state,y:n})}}sink(e){for(let t of this.players())this.seatOf(t)[0]===e&&(Ze(t.state,this.world,t.info.team),this.ctf.moved(t.state));let t=this.rovers.indexOf(e);Object.assign(e,Ui(this.world)[t])}lase(e,t,n){if(e.gun=Math.max(0,(e.gun??0)-1),!(!(n.keys&w.FIRE)||e.gun||this.ctf.over||e.state.mode!==D.RIDE)){e.gun=Q.GUN_COOL,e.bolt=(e.bolt??0)+2&255;for(let r of Xi(t,e.info.id,e.info.team,n.yaw,n.pitch,e.bolt))this.shoot(e,n.view,r)}}splat(e,t,n){if(oa(t.vx,t.vz)<Q.SPLAT_MIN)return;let r=Vi(t);for(let i of this.enemies(e,n)){let n=this.players().find(e=>e.info.id===i.id);if(!n||n.state.mode===D.RIDE||this.ticks-n.run<ta||!r.find(([e,t,n])=>oa(i.x-e,i.z-n)<Q.RB+.4&&i.y<t+Q.BODY_H&&i.y+L(i)>t))continue;let[a,o]=[i.x-t.x,i.z-t.z],s=oa(a,o)||1,c=((t.vx-i.vx)*a+(t.vz-i.vz)*o)/s;if(!(c<Q.SPLAT_MIN)&&(n.run=this.ticks,e.state.hits=e.state.hits+1&255,!this.harm(n,c<Q.SPLAT_KILL?1:n.state.hp))){let r=oa(t.vx,t.vz);yt(n.state,t.vx/r,t.vz/r),n.state.zap=!1,n.by=e.info.id}}}place(e,t,n){let r=this.world.def.teams[t].spawns.findIndex((r,i)=>{let{x:a,z:o}=Xe(e,this.world,i,t);return!n.some(e=>Math.hypot(e.x-a,e.z-o)<ea)});return Xe(e,this.world,r<0?this.rr[t]++:r,t)}end(e){let t=this.ctf.tally().flatMap(t=>{let n=e.find(e=>e.info.id===t.id)?.info;return n?[{...t,name:n.name,team:n.team}]:[]}),n=JSON.stringify({t:`end`,score:this.ctf.score,players:t});e.forEach(e=>e.conn.send(n))}restart(e){let t=[];this.rr=[0,0],this.gone.fill(0),this.rovers=Ui(this.world);for(let n of e){let{shots:e,hits:r}=n.state;n.state={...this.place(n.info.id,n.info.team,t),shots:e,hits:r},t.push(n.state),this.ctf.place(n.info.id,n.state)}}players(){return[...this.peers.values()].filter(e=>e!==null)}join(e,t,n){let r=this.players();if(r.length>=this.rules.maxPlayers){e.send(JSON.stringify({t:`full`}));return}let i=0;for(;r.some(e=>e.info.id===i);)i++;let a=r.filter(e=>e.info.team===0).length,o=+(a>r.length-a),c={conn:e,info:{id:i,name:aa(ia(t)||`Player ${i}`,r.map(e=>e.info.name)),team:o,color:s[o],...n===ce.FEMALE?{body:n}:{}},state:this.place(i,o,r.map(e=>e.state)),since:this.joins++,bank:10,ack:65535,by:0,tackled:-30,run:-ta};this.peers.set(e,c),this.ctf.join(i,o,c.state),this.roster()}roster(){let e=this.players(),t=e.map(e=>e.info).sort((e,t)=>e.id-t.id);e.forEach(e=>e.conn.send(JSON.stringify({t:`roster`,you:e.info.id,players:t,map:this.mapName,host:this.host()?.info.id,next:this.next})))}},fa=(e,t)=>{let n=()=>{},r=()=>{n();let r=setInterval(e,t);n=()=>clearInterval(r)};try{let i=URL.createObjectURL(new Blob([`setInterval(()=>postMessage(0),${t})`])),a=new Worker(i);a.onmessage=e,a.onerror=r,n=()=>{a.terminate(),URL.revokeObjectURL(i)}}catch{r()}return()=>n()},pa=(e,t)=>{let n=`tiny-fps:`+e,r=Math.random().toString(36).slice(2),i=new BroadcastChannel(n),a=new AbortController,o=globalThis.navigator?.locks,s,c,l,u,d=[],f,p=!1,m=e=>i.postMessage({from:r,...e}),h=e=>!p&&x.onmessage?.({data:e}),g={send:e=>queueMicrotask(()=>h(e))},_=()=>{let e=d.length?d:f?[f]:[];return d=[],e},v=e=>{if(p)return e();l=e,u=r,c=/* @__PURE__ */ new Map,s=new da(t),s.start(fa),s.connect(g),_().forEach(e=>s.receive(g,e)),m({kind:`h`})};i.onmessage=({data:e})=>{if(!p){if(s&&c){let{from:t,kind:n}=e,r=c.get(t);n===`q`?m({to:t,kind:`h`}):n===`m`&&!e.to?(r||(r={send:e=>!p&&m({to:t,kind:`m`,data:e})},c.set(t,r),s.connect(r)),s.receive(r,e.data)):n===`b`&&r&&(c.delete(t),s.disconnect(r))}else e.to!==r&&e.to||(e.kind===`m`&&e.to?h(e.data):e.kind===`h`&&e.from!==u&&(u=e.from,_().forEach(e=>m({kind:`m`,data:e}))))}};let y=e=>{p||(typeof e==`string`&&Te(e)?.t===`join`&&(f=e),s?s.receive(g,e):u?m({kind:`m`,data:e}):d.push(e))},b=()=>{p||(p=!0,globalThis.removeEventListener?.(`pagehide`,b),s?(s.stop(),l()):(m({kind:`b`}),a.abort()),i.close(),setTimeout(()=>x.onclose?.()))},x={binaryType:`arraybuffer`,onopen:null,onclose:null,onmessage:null,send:y,close:b};return o?o.request(n,{signal:a.signal},()=>new Promise(v)).catch(()=>{}):v(()=>{}),m({kind:`q`}),globalThis.addEventListener?.(`pagehide`,b),setTimeout(()=>!p&&x.onopen?.()),x};export{pa as localSocket};
1
+ var e=.4,t=1.8,n=.9,r=7.5,i=.5,a=5.5,o=2.5,s=[`#ff3d4f`,`#2f80ff`],c={ticks:20,strike:6,reach:1.4,arc:.6,hp:0,hold:-1},[l,u,d]=[2,3,180],f=.12,p=[{ticks:28,strike:10,reach:2.65,arc:.3,hp:2,hold:8},{ticks:34,strike:13,reach:2.15,arc:1.2,hp:2,hold:4},{ticks:34,strike:13,reach:2.15,arc:1.2,hp:2,hold:4},{ticks:40,strike:16,reach:2.15,arc:.45,hp:3,hold:11},{ticks:36,strike:12,reach:3.2,arc:.3,hp:3,hold:-1},{ticks:46,strike:20,reach:2.15,arc:.6,hp:3,hold:-1},{ticks:46,strike:20,reach:2.15,arc:.6,hp:3,hold:-1},{ticks:58,strike:40,reach:2.4,arc:.6,hp:4,hold:-1}],[m,h,g]=[1.8,15,60],[_,v,y]=[2,.5,1.4],[b,x,ee]=[24,15,.6],[S,te]=[63,7],C=7.5,[ne,re,ie]=[.82,.45,.12],ae=.012,oe={maxPlayers:16,scoreLimit:3,timeLimit:480,map:`highline`},w={HOME:0,CARRIED:1,DROPPED:2},se={MALE:0,FEMALE:1},T={FORWARD:1,BACK:2,LEFT:4,RIGHT:8,JUMP:16,SPRINT:32,DASH:64,CROUCH:128,FIRE:256,BLADE:512,SPECIAL:1024,RAIL:2048,RELOAD:4096,RIFLE:8192,USE:16384},E={THRUST:0,LEFT:1,RIGHT:2,SLASH:3,LUNGE:4,ARC_L:5,ARC_R:6,LEAP:7},D={NONE:0,HEAD:1,ARM_L:2,ARM_R:3,LEG_L:4,LEG_R:5},O={GROUND:0,AIR:1,WALLRUN:2,HANG:3,CLIMB:4,SLIDE:5,CROUCH:6,RIDE:7},ce={NONE:0,EAST:1,WEST:2,SOUTH:3,NORTH:4},k={JUMP:1,DOUBLE:2,DASH:4,LAND:8,GRAB:16,CLIMB:32,WALLRUN_START:64,WALLRUN_END:128,SLIDE_START:256,SLIDE_END:512,RESPAWN:1024},A={BRICK:0,TILE:1,LAVA:2,STONE:3,METAL:4,WOOD:5,MOSS:6,GRATE:7,CONCRETE:8,GLASS:9,STEEL:10,PAINT:11,ROCK:12},le=[`x`,`y`,`z`,`vx`,`vy`,`vz`,`yaw`,`pitch`,`roll`,`wy`,`wp`,`wr`,`steer`],ue=127,de=16,fe=32,pe=128/Math.PI,me=254/Math.PI,he=65536/(2*Math.PI),ge=e=>Math.round(e*he)&65535,_e=e=>Math.max(-32768,Math.min(32767,Math.round(e))),ve=e=>_e(e*1e4),ye=e=>e/1e4,be=e=>e/he,xe=e=>{if(e.byteLength!==12)return null;let t=new DataView(e);return t.getUint8(0)===1?{seq:t.getUint16(1),keys:t.getUint16(3)&32767,yaw:be(t.getUint16(5)),pitch:ye(t.getInt16(7)),view:(t.getUint16(9)*256+t.getUint8(11))/256}:null},Se=e=>e===w.CARRIED?2:e===w.DROPPED?8:1,Ce=e=>{let t=(e.rovers??[]).slice(0,7),n=4+62*e.players.length,r=n+54*t.length,i=e.balls??[],a=r+10+e.flags.reduce((e,t)=>e+Se(t.state),0),o=e.doors??[],s=o.length&&1+Math.ceil(o.length/2),c=new DataView(new ArrayBuffer(a+(i.length||s?1+11*i.length:0)+s));c.setUint8(0,2),c.setUint16(1,e.tick&65535),c.setUint8(3,e.players.length|t.length<<5),e.players.forEach((e,t)=>{let n=4+t*62;c.setUint8(n,e.id),c.setFloat32(n+1,e.x),c.setFloat32(n+5,e.y),c.setFloat32(n+9,e.z),c.setFloat32(n+13,e.vx),c.setFloat32(n+17,e.vy),c.setFloat32(n+21,e.vz),c.setFloat32(n+25,e.edge),c.setUint16(n+29,ge(e.yaw)),c.setInt16(n+31,ve(e.pitch)),c.setUint16(n+33,e.ack&65535),c.setUint8(n+35,e.mode&7|(e.wall&7)<<3|(e.jumps&1)<<6|e.dashes<<7),c.setUint8(n+36,e.t),c.setUint8(n+37,e.dash|(e.by>>2&3)<<6),c.setUint8(n+38,e.coyote&7|(e.buffer&7)<<3|(e.held&T.JUMP?64:0)|(e.held&T.DASH?128:0)),c.setUint8(n+39,e.stun|(e.by&3)<<6);let r=e.hp|e.cool<<3|(e.ammo<0?ue:e.ammo)<<6|e.down<<13|!!e.rack<<20|!!e.blade<<21|!!e.wield<<22|!!e.zap<<23;c.setUint8(n+40,r>>16),c.setUint16(n+41,r&65535),c.setUint8(n+43,e.shots),c.setUint8(n+44,e.hits),c.setUint8(n+45,(e.swing??0)&63|((e.cut??0)&3)<<6),c.setUint8(n+46,(e.lost??0)&7|((e.cut??0)&4)<<1|(e.fried?16:0)|(e.heavy?32:0)),c.setUint8(n+47,e.charge??0),c.setUint8(n+48,e.lock??0),c.setUint8(n+49,(e.foe??0)&15|(e.pressed?128:0)),c.setUint8(n+50,e.pushes??0),c.setUint8(n+51,e.away??0),c.setUint8(n+52,(e.rail??-1)+1),c.setUint8(n+53,+!!e.railed|!!e.inRail<<1|!!e.zapping<<2|!!e.rifled<<3|!!e.inRifle<<4|!!e.hot<<5|(e.held&T.USE?64:0)),c.setUint8(n+54,e.slow??0),c.setUint8(n+55,e.mag??0),c.setUint8(n+56,e.cap??0),c.setUint8(n+57,e.reload??0),c.setUint8(n+58,(e.rifle??-1)+1),c.setUint8(n+59,e.clip??0),c.setUint8(n+60,e.heat??0),c.setUint8(n+61,(e.nades??0)<<6|(e.lob??0))}),t.forEach((e,t)=>{let r=n+t*54;le.forEach((t,n)=>c.setFloat32(r+4*n,e[t])),c.setUint8(r+52,e.driver),c.setUint8(r+53,e.rider)}),c.setUint8(r,e.score[0]),c.setUint8(r+1,e.score[1]),c.setUint16(r+2,e.clock&32767|(e.over?32768:0));let l=e.packs??0;c.setUint16(r+4,Math.floor(l/2**32)),c.setUint32(r+6,l%2**32);let u=r+10;for(let t of e.flags)c.setUint8(u,t.state),t.state===w.CARRIED?c.setUint8(u+1,t.by):t.state===w.DROPPED&&(c.setInt16(u+1,_e(t.x*de)),c.setInt16(u+3,_e(t.y*de)),c.setInt16(u+5,_e(t.z*de)),c.setUint8(u+7,Math.min(255,t.left))),u+=Se(t.state);(i.length||s)&&c.setUint8(u++,i.length);for(let e of i)c.setUint8(u,e.id),c.setUint8(u+1,e.by&127|(e.burst?128:0)),[e.x,e.y,e.z].forEach((e,t)=>c.setInt16(u+2+2*t,_e(e*fe))),c.setUint8(u+8,Math.round(Math.atan2(-e.dx,-e.dz)*pe)&255),c.setInt8(u+9,Math.round(Math.asin(Math.max(-1,Math.min(1,e.dy)))*me)),c.setUint8(u+10,e.arc?128|e.arc:e.power===7?64|Math.min(63,Math.round(e.v)):e.power??1),u+=11;return s&&(c.setUint8(u++,o.length),o.forEach((e,t)=>{let n=u+(t>>1);c.setUint8(n,c.getUint8(n)|Math.round(e*15)<<(t&1?0:4))})),c.buffer},we=e=>{try{let t=JSON.parse(e);return t&&typeof t.t==`string`?t:null}catch{return null}},Te=(e,t,n)=>{let r=Math.imul(e,374761393)+Math.imul(t,668265263)+Math.imul(n,144665)|0;return r=Math.imul(r^r>>>13,1274126177),((r^r>>>16)>>>0)/4294967296},j=(e,t,n)=>{let[r,i]=[Math.floor(e),Math.floor(t)],[a,o]=[e-r,t-i].map(e=>e*e*(3-2*e)),s=(e,t)=>Te(r+e,i+t,n);return(s(0,0)*(1-a)+s(1,0)*a)*(1-o)+(s(0,1)*(1-a)+s(1,1)*a)*o},Ee=/* @__PURE__ */ new WeakMap,De=e=>{let t=Ee.get(e);if(t)return t;let{hole:n,bound:r,cell:i,at:a,pits:o=[]}=e,s=o.reduce((e,t)=>[Math.min(e[0],t[0]),Math.min(e[1],t[1]),Math.max(e[2],t[2]),Math.max(e[3],t[3])],[1/0,1/0,-1/0,-1/0]),[c,l,u,d]=r,f=Math.floor((c-u)/i)*i,p=Math.floor((l-d)/i)*i,m=Math.ceil((c+u-f)/i)+1,h=Math.ceil((l+d-p)/i)+1,g=new Float32Array(m*h),_=-1/0;for(let e=0;e<h;e++)for(let t=0;t<m;t++)g[t+e*m]=a(f+t*i,p+e*i),_=Math.max(_,g[t+e*m]);let v=new Uint8Array(m*h);for(let[e,t,n,r]of o)for(let a=Math.floor((t-p)/i)-1;a<=Math.floor((r-p)/i)+1;a++)for(let t=Math.floor((e-f)/i)-1;t<=Math.floor((n-f)/i)+1;t++)t>=0&&a>=0&&t<m&&a<h&&(v[t+a*m]=1);let y={x0:f,z0:p,cell:i,nx:m,nz:h,h:g,hole:n,pits:o,pitted:v,box:s,bound:r,top:_};return Ee.set(e,y),y},Oe=(e,t,n)=>{let r=e.relief;if(!r||t>r.hole[0]&&t<r.hole[2]&&n>r.hole[1]&&n<r.hole[3])return-1/0;let i=Math.min(Math.max((t-r.x0)/r.cell,0),r.nx-1),a=Math.min(Math.max((n-r.z0)/r.cell,0),r.nz-1),o=Math.min(Math.floor(i),r.nx-2),s=Math.min(Math.floor(a),r.nz-2);if(r.pitted[o+s*r.nx]&&r.pits.some(e=>t>=e[0]&&t<=e[2]&&n>=e[1]&&n<=e[3]))return-1/0;let[c,l]=[i-o,a-s],u=o+s*r.nx,[d,f,p,m]=[r.h[u],r.h[u+1],r.h[u+r.nx],r.h[u+r.nx+1]];return c>=l?d+(f-d)*c+(m-f)*l:d+(p-d)*l+(m-p)*c},ke=(e,t)=>{if(!t.relief)return;let[n,r,i,a]=t.relief.bound,[o,s]=[(e.x-n)/i,(e.z-r)/a],c=o*o+s*s;if(c<=1)return;let l=1/Math.sqrt(c);e.x=n+o*l*i,e.z=r+s*l*a;let[u,d]=[o*l/i,s*l/a],f=(e.vx*u+e.vz*d)/(u*u+d*d);f>0&&(e.vx-=f*u,e.vz-=f*d)},Ae=1,je=6,Me=(e,t,n,r,i=0)=>{let a=e.relief;if(!a||Math.min(t[1],t[1]+n[1]*r)-i>a.top)return r;let[o,s]=[0,r];for(let e of[0,1]){let[r,i,c,l]=[t[e*2],n[e*2],a.hole[e],a.hole[e+2]];if(i){let[e,t]=[(c-r)/i,(l-r)/i];o=Math.max(o,Math.min(e,t)),s=Math.min(s,Math.max(e,t))}else(r<=c||r>=l)&&(s=-1)}let c=r=>t[1]+n[1]*r-i-Oe(e,t[0]+n[0]*r,t[2]+n[2]*r);if(!n[0]&&!n[2]){let e=c(0);return e<0?0:n[1]<0?Math.min(r,e/-n[1]):r}for(let[e,t]of o<s?[[0,o],[s,r]]:[[0,r]]){if(e<t&&c(e)<0)return e;for(let n=e;n<t;n+=Ae){let e=Math.min(n+Ae,t);if(c(e)<0){let[t,r]=[n,e];for(let e=0;e<je;e++){let e=(t+r)/2;c(e)<0?r=e:t=e}return t}}}return r},Ne=4,Pe=1024,Fe=(e,t)=>(e+Pe)*(2*Pe)+t+Pe,M=(e,t)=>Math.min(Math.max(Math.floor(e/t),-1024),1023),Ie=(e,t=Ne)=>{let n=/* @__PURE__ */ new Map;return e.brushes.forEach(({min:e,max:r},i)=>{for(let a=M(e[0],t);a<=M(r[0],t);a++)for(let o=M(e[2],t);o<=M(r[2],t);o++){let e=Fe(a,o),t=n.get(e);t?t.push(i):n.set(e,[i])}}),{def:e,cell:t,grid:n,...e.relief?{relief:De(e.relief)}:{},...e.doors?{doors:e.doors.map(()=>({open:0,wait:0}))}:{}}},Le=(e,t,n,r)=>{let i=[];for(let a=M(t-r,e.cell);a<=M(t+r,e.cell);a++)for(let t=M(n-r,e.cell);t<=M(n+r,e.cell);t++)for(let n of e.grid.get(Fe(a,t))??[])i.includes(n)||i.push(n);return i},Re=(e,t,n,r,i=0)=>{let a=ze(e,t,n,r,i);return e.doors?.forEach(({open:r},o)=>{if(r<.5){let{min:r,max:s}=e.def.doors[o],[c,l]=[0,a];for(let e=0;e<3;e++){let[a,o]=n[e]?[(r[e]-i-t[e])/n[e],(s[e]+i-t[e])/n[e]]:t[e]<r[e]-i||t[e]>s[e]+i?[1,-1]:[-1/0,1/0];c=Math.max(c,Math.min(a,o)),l=Math.min(l,Math.max(a,o))}c<=l&&l>0&&(a=c)}}),e.relief?Me(e,t,n,a,i):a},ze=(e,t,n,r,i)=>{let{cell:a,def:o}=e,s=r,c=M(t[0],a),l=M(t[2],a),u=Math.sign(n[0]),d=Math.sign(n[2]),f=u?((c+ +(u>0))*a-t[0])/n[0]:1/0,p=d?((l+ +(d>0))*a-t[2])/n[2]:1/0,m=f,h=p,g=u?a/Math.abs(n[0]):1/0,_=d?a/Math.abs(n[2]):1/0;for(;;){for(let r of e.grid.get(Fe(c,l))??[]){let e=o.brushes[r],[a,c]=[0,s];for(let r=0;r<3&&a<=c;r++){if(!n[r]){(t[r]<e.min[r]-i||t[r]>e.max[r]+i)&&(c=-1);continue}let o=(e.min[r]-i-t[r])/n[r],s=(e.max[r]+i-t[r])/n[r];a=Math.max(a,Math.min(o,s)),c=Math.min(c,Math.max(o,s))}a<=c&&c>0&&a<s&&(s=a)}if(Math.min(m,h)>=s||Math.abs(c)>Pe||Math.abs(l)>Pe)return s;m<h?(c+=u,m+=g):(l+=d,h+=_)}},Be=(e,t,n)=>{let[r,i,a]=[n[0]-t[0],n[1]-t[1],n[2]-t[2]],o=Math.hypot(r,i,a);return o>0&&Re(e,t,[r/o,i/o,a/o],o)<o-1e-4},N=1/60,Ve=Math.PI*2,He=1e-6,P=.01,Ue=.001,We=e=>(e%Ve+Ve)%Ve,F=e=>[-Math.sin(e),-Math.cos(e)],I=Math.fround,Ge=Math.sqrt,Ke=(e,t,n)=>Math.min(Math.max(e,t),n),L=(e,t)=>Ge(e*e+t*t),qe=[[0,0],[1,0],[-1,0],[0,1],[0,-1]],Je={vx:0,vz:0,mode:O.GROUND,t:0,wall:ce.NONE,edge:0,jumps:1,dashes:1,dash:0,stun:0,coyote:6,buffer:0,held:0,hp:5,ammo:-1,cool:0,mag:0,cap:0,reload:0,rack:!1,down:0,shots:0,hits:0,blade:!1,wield:!1,swing:0,cut:0,zap:!1,lost:D.NONE,rail:-1,railed:!1,rifle:-1,clip:0,rifled:!1,nades:0,lob:0,inRifle:!1,inRail:!1,zapping:!1,slow:0,fried:!1,heavy:!1,ev:0,fall:0},Ye=(e,t,n,r=0)=>{let{spawns:i}=t.def.teams[r],[a,o,s,c]=i[(n%i.length+i.length)%i.length];return{id:e,x:I(a),y:I(o),z:I(s),vy:0,yaw:We(c),pitch:0,ground:!0,...Je}},Xe=(e,t,n)=>{let{yaw:r,pitch:i,id:a,shots:o,hits:s}=e;Object.assign(e,Ye(a,t,a,n),{yaw:r,pitch:i,shots:o,hits:s,ev:e.ev|k.RESPAWN})},Ze=e=>e===O.GROUND||e===O.SLIDE||e===O.CROUCH,R=e=>e.mode===O.SLIDE||e.mode===O.CROUCH?n:t,Qe=e=>e.mode===O.SLIDE||e.mode===O.CROUCH?.7:1.6,$e=e=>L(e.vx,e.vz),et=(e,t,n)=>e.max[1]>t+.5+P&&e.min[1]<t+n-P,tt=(e,t,n)=>[t-Ke(t,e.min[0],e.max[0]),n-Ke(n,e.min[2],e.max[2])],nt=(t,n,r)=>rt(t,n,r,e),rt=(e,t,n,r)=>{let{brushes:i}=t.def,a=Le(t,e.x,e.z,2*r),o=(r-He)**2,[s,c]=[0,0];for(let t=0;t<4;t++){let t=0,l=0,u=0;for(let s of a){let a=i[s];if(!et(a,e.y,n))continue;let[c,d]=tt(a,e.x,e.z),f=c*c+d*d;if(f>=o)continue;if(f){let e=Ge(f);r-e>t&&(t=r-e,l=c/e*t,u=d/e*t);continue}let[p,m,h]=[[e.x-a.min[0],-1,0],[a.max[0]-e.x,1,0],[e.z-a.min[2],0,-1],[a.max[2]-e.z,0,1]].reduce((e,t)=>t[0]<e[0]?t:e);p+r>t&&(t=p+r,[l,u]=[m*t,h*t])}if(!t)break;e.x+=l,e.z+=u,s+=l,c+=u}return[s,c]},it=(e,t,n)=>{let[[r,i,a],[o,s,c]]=[e.a,e.b],[l,u]=[o-r,c-a],d=l*l+u*u,f=d?Ke(((t-r)*l+(n-a)*u)/d,0,1):0;return[t-r-f*l,n-a-f*u,i+f*(s-i)]},at=(t,n,r)=>{let[i,a]=[0,0];for(let o of n){let[n,s,c]=it(o,t.x,t.z),l=o.r+e,u=n*n+s*s;if(u>=(l-He)**2||c+o.h<=t.y+.5+P||c>=t.y+r-P)continue;let d=Ge(u),[f,p]=[o.b[0]-o.a[0],o.b[2]-o.a[2]],m=L(f,p),[h,g]=d?[n/d,s/d]:m?[p/m,-f/m]:[1,0];t.x+=h*(l-d),t.z+=g*(l-d),i+=h*(l-d),a+=g*(l-d)}return[i,a]},ot=(t,n,r,i=[])=>{let{brushes:a}=n.def,o=(e-He)**2,s=Oe(n,t.x,t.z),c=1/0;for(let i of Le(n,t.x,t.z,e)){let e=a[i],[n,l]=tt(e,t.x,t.z);n*n+l*l>=o||(e.max[1]<=t.y+.5+P?s=Math.max(s,e.max[1]):e.min[1]>=t.y+r-P&&(c=Math.min(c,e.min[1])))}for(let e of i){let[n,i,a]=it(e,t.x,t.z);n*n+i*i>=(e.r+.4-He)**2||(a+e.h<=t.y+.5+P?s=Math.max(s,a+e.h):a>=t.y+r-P&&(c=Math.min(c,a)))}return[s,c]},st=(e,t,n,r)=>{let i=Oe(e,t,n);for(let a of Le(e,t,n,0)){let{min:o,max:s}=e.def.brushes[a];t>=o[0]&&t<=s[0]&&n>=o[2]&&n<=s[2]&&s[1]<=r&&(i=Math.max(i,s[1]))}return i},ct=(t,n)=>{let r=(e-He)**2;return Le(n,t.x,t.z,e).every(e=>{let i=n.def.brushes[e],[a,o]=tt(i,t.x,t.z);return a*a+o*o>=r||!et(i,t.y,1.8)})},lt=(t,n,r,i,a)=>{let o=(e-He)**2;return Le(t,n,r,e).every(e=>{let s=t.def.brushes[e],[c,l]=tt(s,n,r);return c*c+l*l>=o||s.max[1]<=i||s.min[1]>=a})},ut=(e,t)=>{let[n,r]=qe[t],i=n?0:2;return{a:i,o:2-i,sign:n||r,c:n?e.x:e.z,co:n?e.z:e.x}},dt=(e,t,n,r)=>{let{a:i,o:a,sign:o,c:s,co:c}=ut(t,n),l=((o>0?e.min[i]:e.max[i])-s)*o;return l>=.4-Ue&&l<=.4+r&&c>=e.min[a]&&c<=e.max[a]?l:void 0},ft=(t,n,r)=>{let a;for(let o of Le(n,t.x,t.z,e+i)){let s=n.def.brushes[o],c=dt(s,t,r,i);c!==void 0&&s.min[1]<t.y+.5&&s.max[1]>t.y+1.8&&(a=Math.min(a??1/0,Math.max(0,c-e)))}return a},pt=(t,n)=>{let[r,i]=F(t.yaw),a;for(let o=1;o<=4;o++){let[s,c]=qe[o];if(o===t.wall||r*s+i*c<.5)continue;let{a:l,sign:u}=ut(t,o);for(let r of Le(n,t.x,t.z,e+.2)){let i=n.def.brushes[r],s=i.max[1],c=s-t.y;if(dt(i,t,o,.2)===void 0||c<1.2||c>2.4||i.min[1]>s-.25||a&&a.top>=s)continue;let d=u>0?i.min[l]:i.max[l],f=d-u*(e+.03),p=d+u*.2,[m,h]=l===0?[f,t.z]:[t.x,f],[g,_]=l===0?[p,t.z]:[t.x,p];lt(n,m,h,Math.min(t.y,s-2)+P,s+1.8)&&lt(n,g,_,s+P,s+1.8)&&(a={side:o,top:s,hang:f})}}return a},mt=(e,t)=>{let{a:n,o:r,sign:i,c:a,co:o}=ut(e,e.wall);return Le(t,e.x,e.z,0).some(s=>{let c=t.def.brushes[s],l=i>0?a-c.min[n]:c.max[n]-a;return I(c.max[1])===e.edge&&o>=c.min[r]&&o<=c.max[r]&&l>=.2})},ht=e=>20*(e.def.gravity??1),gt=(e,n)=>{if(e.vy>=0)return!1;let[r]=ot(e,n,t),i=6*N;return e.y-r<=-e.vy*i+.5*ht(n)*i*i},z=(e,t)=>{e.mode=t,e.t=0},_t=e=>!!e.zap&&e.stun>24,vt=(e,t,n,r=48,i=6)=>{e.stun=r,e.vx=I(t*i),e.vz=I(n*i),e.dash=Math.min(e.dash,50),e.coyote=0,e.buffer=0,(e.mode===O.HANG||e.mode===O.CLIMB)&&(e.vy=0),(e.mode===O.HANG||e.mode===O.CLIMB||e.mode===O.WALLRUN||e.mode===O.RIDE)&&(z(e,O.AIR),e.edge=0)},yt=(e,t)=>{let n=L(e.vx,e.vz);n>t&&(e.vx*=t/n,e.vz*=t/n)},bt=(t,n,r,i)=>{let[a,o]=[r.wx,r.wz];for(let r of Le(n,t.x,t.z,e+Ue)){let e=n.def.brushes[r],[s,c]=tt(e,t.x,t.z),l=L(s,c);if(l>0&&l<=.4+Ue&&et(e,t.y,i)){let e=(-a*s-o*c)/l;e>0&&(a+=e*s/l,o+=e*c/l)}}return[a,o]},xt=(e,t,n)=>{let r=L(t[0],t[1]);if(r<He){let t=L(e.vx,e.vz),n=t?Math.max(0,t-45*N)/t:0;e.vx*=n,e.vz*=n;return}let[i,a]=[t[0]/r,t[1]/r],o=e.vx*i+e.vz*a,[s,c]=[e.vx-o*i,e.vz-o*a],l=L(s,c);if(l){let e=Math.max(0,l-45*N)/l;[s,c]=[s*e,c*e]}n*=r,o=o<n?Math.min(n,o+(o>=6?3:50)*N):Math.max(n,o-12*N),e.vx=s+o*i,e.vz=c+o*a},St=(e,t,n,r,i,a)=>{let o=e.y;e.x+=e.vx*N,e.z+=e.vz*N;let[s,c]=nt(e,t,n),[l,u]=at(e,a,n);if(l||u){let[r,i]=nt(e,t,n);s+=l+r,c+=u+i}let d=L(s,c);if(d){let t=(e.vx*s+e.vz*c)/d;t<0&&(e.vx-=t*s/d,e.vz-=t*c/d)}ke(e,t);let[f,p]=ot(e,t,n,a),m=e.vy-r*ht(t)*N;if(e.y+=(e.vy+m)/2*N,e.vy=m,e.y+n>p&&(e.y=p-n,e.vy=Math.min(e.vy,0)),e.vy<=0?e.y<=f+P:e.y<f){if(e.y=f,e.vy<=0){let t=-e.vy;return e.vy=0,t}}else if(i&&e.vy<=0&&f>=o-.5)return e.y=f,e.vy=0,0;return-1},Ct=(e,t)=>{e.vy=t,e.coyote=0,e.buffer=0,e.ev|=k.JUMP},wt=(e,n,r)=>{let[i,a]=qe[e.wall],o=t=>{z(e,t),e.edge=0};if(r.keys&(T.BACK|T.CROUCH))o(O.AIR),e.coyote=0;else if(r.jump&&r.fx*i+r.fz*a<0)o(O.AIR),e.vx=-i*4,e.vz=-a*4,Ct(e,6);else if(r.jump||r.fwd&&e.t>=6)z(e,O.CLIMB);else if(e.t>=30)o(O.AIR),e.coyote=0;else{let r=Math.max(e.edge-2,ot(e,n,t)[0]);e.y+=Ke(r-e.y,-8*N,8*N)}},Tt=(e,t)=>{let[n,r]=qe[e.wall];e.y<e.edge?e.y=Math.min(e.edge,e.y+8*N):(e.x+=n*a*N,e.z+=r*a*N),e.y>=e.edge&&mt(e,t)?(z(e,O.GROUND),e.vx=n*3,e.vz=r*3,e.vy=0,e.edge=0,e.wall=ce.NONE,e.coyote=6,e.ev|=k.CLIMB):e.t>=40&&(z(e,e.y>=e.edge?O.GROUND:O.AIR),e.edge=0,e.wall=ce.NONE)},Et=(e,t,n)=>{let[r,i]=qe[e.wall],a=e.vx*r+e.vz*i,[o,s]=[e.vx-a*r,e.vz-a*i],c=L(o,s);if(n.jump)z(e,O.AIR),e.vx=o-r*5,e.vz=s-i*5,Ct(e,6.5),e.jumps=1,e.dashes=1,e.ev|=k.WALLRUN_END;else{let a=ft(e,t,e.wall);if(a===void 0||!n.fwd||c<3.5||e.t>=60){z(e,O.AIR),e.ev|=k.WALLRUN_END;return}let l=Math.max(0,c-1.5*N)/c;e.vx=o*l,e.vz=s*l;let u=Math.min(a,4*N);e.x+=r*u,e.z+=i*u}},Dt=(e,t,n)=>{if(!n.fwd)return;let r=L(e.vx,e.vz);if(!(r<4.5))for(let n=1;n<=4;n++){let[i,a]=qe[n],o=e.vx*i+e.vz*a,[s,c]=[e.vx-o*i,e.vz-o*a];if(n!==e.wall&&o<=.75*r&&o>=-.2*r&&ft(e,t,n)!==void 0){let t=L(s,c),i=Math.max(t,.9*r)/t;z(e,O.WALLRUN),e.wall=n,[e.vx,e.vz]=[s*i,c*i],e.vy=Ke(e.vy,2,3),e.jumps=1,e.dashes=1,e.coyote=0,e.ev|=k.WALLRUN_START;return}}},Ot=(e,t)=>{z(e,O.HANG),e.wall=t.side,e.edge=I(t.top),t.side<=ce.WEST?e.x=t.hang:e.z=t.hang,e.vx=e.vy=e.vz=0,e.jumps=1,e.dashes=1,e.coyote=0,e.buffer=0,e.ev|=k.GRAB},kt=(e,t,n)=>{let i=e.mode===O.GROUND;if(n.dash&&e.dash===0&&(i||(e.mode===O.AIR||e.mode===O.WALLRUN)&&e.dashes>0)){let[t,r]=n.wx||n.wz?[n.wx,n.wz]:[n.fx,n.fz];i||(e.dashes--,e.vy=0,e.mode===O.WALLRUN&&(z(e,O.AIR),e.ev|=k.WALLRUN_END)),e.vx=t*16,e.vz=r*16,e.dash=60,e.ev|=k.DASH}let a=e.dash>50;e.mode===O.WALLRUN&&Et(e,t,n),Ze(e.mode)&&At(e,t,n,a),e.mode===O.AIR&&jt(e,t,n,a);let o=a&&e.vy<=0?0:e.mode===O.WALLRUN?.15:1,s=e.mode,c=St(e,t,R(e),o,Ze(s),n.bodies);if(c>=0){if(!Ze(e.mode)){if(e.ev|=k.LAND|(e.mode===O.WALLRUN?k.WALLRUN_END:0),e.fall=c,e.jumps=1,e.dashes=1,e.wall=ce.NONE,n.keys&T.CROUCH){let t=L(e.vx,e.vz)>=r;z(e,t?O.SLIDE:O.CROUCH),e.ev|=t?k.SLIDE_START:0}else z(e,O.GROUND)}e.coyote=6}else Ze(e.mode)&&(e.ev|=e.mode===O.SLIDE?k.SLIDE_END:0,z(e,O.AIR));if(e.mode===O.AIR){let r=pt(e,t);r?Ot(e,r):Dt(e,t,n)}},At=(e,i,a,s)=>{let c=(a.keys&T.CROUCH)!==0;if(e.buffer>0&&(e.mode===O.GROUND||ct(e,i))){e.ev|=e.mode===O.SLIDE?k.SLIDE_END:0,z(e,O.AIR),Ct(e,7);return}let l=L(e.vx,e.vz);if(e.mode===O.GROUND&&c){let t=l>=r;z(e,t?O.SLIDE:O.CROUCH),e.ev|=t?k.SLIDE_START:0}else e.mode===O.SLIDE&&(e.t>=60||l<4.5||a.stumble)?(e.ev|=k.SLIDE_END,z(e,!c&&ct(e,i)?O.GROUND:O.CROUCH)):e.mode===O.SLIDE&&!c&&ct(e,i)?(e.ev|=k.SLIDE_END,z(e,O.GROUND)):e.mode===O.CROUCH&&!c&&ct(e,i)&&z(e,O.GROUND);if(!s){if(a.stumble){if(l>2.5){let t=Math.max(o,l-12*N)/l;e.vx*=t,e.vz*=t}else xt(e,bt(e,i,a,R(e)),o)}else if(e.mode===O.SLIDE){let t=Math.max(0,l-4*N)/l;e.vx*=t,e.vz*=t}else if(e.mode===O.CROUCH)xt(e,bt(e,i,a,n),3);else{let n=(a.keys&T.SPRINT)!==0&&a.fwd;xt(e,bt(e,i,a,t),n?9:6)}}},jt=(e,t,n,r)=>{if(e.buffer>0&&(e.coyote>0?Ct(e,7):e.jumps>0&&!gt(e,t)&&(e.jumps--,Ct(e,6),e.ev=e.ev&~k.JUMP|k.DOUBLE)),r||!n.wx&&!n.wz)return;let i=L(e.vx,e.vz);e.vx+=n.wx*14*N,e.vz+=n.wz*14*N,yt(e,Math.max(i,6))},Mt=(e,t,n,r=0,i=[])=>{e.yaw=We(t.yaw),e.pitch=Math.max(-1.55,Math.min(1.55,t.pitch));let a=(t.keys&T.FORWARD?1:0)-(t.keys&T.BACK?1:0),o=(t.keys&T.RIGHT?1:0)-(t.keys&T.LEFT?1:0),s=_t(e)?1/0:L(a,o)||1,[c,l]=F(e.yaw),u=n=>(t.keys&n)!==0&&(e.held&n)===0,d=e.stun>0,f=e.mode===O.RIDE,p={keys:t.keys,stumble:d,jump:!d&&!f&&u(T.JUMP),dash:!d&&!f&&u(T.DASH),fwd:a>0,wx:(c*a-l*o)/s,wz:(l*a+c*o)/s,fx:c,fz:l,bodies:i},m=e.mode;e.ev=0,e.fall=0,p.jump&&(e.buffer=7),d&&e.stun--,e.dash>0&&(e.dash--,e.dash===50&&yt(e,10)),e.mode===O.HANG&&wt(e,n,p),e.mode===O.CLIMB?Tt(e,n):e.mode!==O.HANG&&!f&&kt(e,n,p),e.slow&&(e.slow--,yt(e,3)),e.y<n.def.floor&&Xe(e,n,r),e.t=e.mode===m?Math.min(255,e.t+1):e.t,e.buffer=Math.max(0,e.buffer-1),e.mode===O.AIR&&m===O.AIR&&(e.coyote=Math.max(0,e.coyote-1)),e.held=t.keys&(T.JUMP|T.DASH|T.USE),e.ground=Ze(e.mode),e.x=I(e.x),e.y=I(e.y),e.z=I(e.z),e.vx=I(e.vx),e.vy=I(e.vy),e.vz=I(e.vz),e.edge=I(e.edge)},Nt=.7,Pt=e=>{let[t,n]=[e&T.LEFT,e&T.RIGHT];return t&&!n?E.LEFT:n&&!t?E.RIGHT:e&T.FORWARD?E.THRUST:E.SLASH},Ft=e=>{let t=p[e.cut??0];return e.heavy?{...t,ticks:Math.round((t.ticks-t.hold)*m),strike:Math.round((t.strike-t.hold)*m),reach:t.reach+v,arc:t.arc*y,hp:t.hp+_}:t},It=(e,t,n,{reach:r,arc:i}=Ft(t))=>{let[a,o]=F(t.yaw),s=[t.x,t.y+Nt*R(t),t.z];return n.filter(n=>{let[c,l]=[n.x-t.x,n.z-t.z],u=Math.hypot(c,l);return u-.4>r||t.y>=n.y+R(n)||n.y>=t.y+R(t)?!1:(u>.4?Math.abs(Math.atan2(a*l-o*c,a*c+o*l)):0)<=i+(u>.4?Math.asin(.4/u):Math.PI)&&!Be(e,s,[n.x,n.y+.7*R(n),n.z])})},Lt=(e,t)=>{if(!t.wield||!t.swing||e.lock||t.lock)return!1;let n=Ft(t);if(Math.abs(n.strike-(n.ticks-t.swing))>9)return!1;let[r,i]=[t.x-e.x,t.z-e.z],a=Math.hypot(r,i),o=(e,t,n)=>{let[r,i]=F(e.yaw);return a<1e-6||(r*t+i*n)/a>=Math.cos(.9)};return a-.4<=Math.min(n.reach,Ft(e).reach)&&o(e,r,i)&&o(t,-r,-i)},Rt=e=>{let[t,n]=F(e.yaw),r=e.cut??0;return r===E.LEFT?[-n,t]:r===E.RIGHT?[n,-t]:[t,n]},zt=(t,n)=>{let[r,i]=F(t.yaw),[a,o]=F(n.yaw),[s,c]=[n.x-t.x,n.z-t.z],l=-i*s+r*c,u=Math.sqrt(Math.max(e*e-l*l,0)),[d,f]=[i*l-r*u,-r*l-i*u],p=-o*d+a*f,m=(t.cut??0)%4;if(m===E.SLASH)return Math.abs(p)<=ie?D.HEAD:p>0?D.ARM_R:D.ARM_L;let h=(t.y+Nt*R(t)+Math.tan(t.pitch)*Math.hypot(s,c)-n.y)/R(n);if(h>ne)return D.HEAD;let g=m===E.THRUST?p>0:(m===E.LEFT?1:-1)*(r*a+i*o)<0;return h<re?g?D.LEG_R:D.LEG_L:m===E.THRUST&&Math.abs(p)<=ie?D.NONE:g?D.ARM_R:D.ARM_L},Bt=()=>({state:w.HOME,by:0,x:0,y:0,z:0,left:0}),Vt=60,Ht=class{score=[0,0];over=!1;flags=[Bt(),Bt()];world;rules;mates=/* @__PURE__ */ new Map;clock;back=[0,0];lock=[{id:-1,left:0},{id:-1,left:0}];hold=[0,0];constructor(e,t){this.world=e,this.rules=t,this.clock=t.timeLimit*60}join(e,t,n){this.mates.set(e,{team:t,caps:0,returns:0,ground:[n.x,n.y,n.z]})}leave(e){let t=this.carrying(e),n=this.mates.get(e);t>=0&&n&&this.dropAt(t,n.ground),this.mates.delete(e)}place(e,t){let n=this.mates.get(e);n&&(n.ground=[t.x,t.y,t.z])}moved(e){let t=this.mates.get(e.id);if(!t)return;let n=this.carrying(e.id);e.ev&k.RESPAWN&&n>=0&&this.dropAt(n,t.ground),e.ground&&(t.ground=[e.x,e.y,e.z])}drop(e){let t=this.carrying(e.id),n=this.mates.get(e.id);if(t<0||!n||this.over)return!1;let r=n.ground;if(e.ground)r=[e.x,e.y,e.z];else{let t=Re(this.world,[e.x,e.y+.05,e.z],[0,-1,0],Vt);t<Vt&&(r=[e.x,e.y+.05-t,e.z])}return this.dropAt(t,r),this.lock[t]={id:e.id,left:120},this.hold[t]=120,!0}carrying(e){return this.flags.findIndex(t=>t.state===w.CARRIED&&t.by===e)}winner(){let[e,t]=this.score;return e>t?0:t>e?1:-1}tally(){return[...this.mates].map(([e,t])=>({id:e,caps:t.caps,returns:t.returns}))}reset(){this.over=!1,this.score=[0,0],this.flags=[Bt(),Bt()],this.back=[0,0],this.lock.forEach(e=>e.left=0),this.hold=[0,0],this.clock=this.rules.timeLimit*60;for(let e of this.mates.values())e.caps=e.returns=0}wire(){return{score:[...this.score],clock:Math.ceil(this.clock/60),over:this.over,flags:this.flags.map(e=>({...e}))}}tick(e){if(this.over)return--this.clock<=0?(this.reset(),`start`):void 0;for(let e of[0,1]){let t=this.flags[e];this.lock[e].left--,this.hold[e]--,t.state===w.DROPPED&&(t.left=Math.ceil(--this.back[e]/60),this.back[e]<=0&&(this.flags[e]=Bt()))}for(let t of[0,1]){let n=this.flags[t];if(n.state===w.CARRIED)continue;let r=n.state===w.HOME?this.world.def.teams[t].base:[n.x,n.y,n.z],i=e.filter(e=>Ut(e.state,r)),a=n.state===w.DROPPED&&this.hold[t]<=0?i.find(e=>e.team===t):void 0,o=i.find(e=>e.team!==t&&(e.id!==this.lock[t].id||this.lock[t].left<=0));if(a){let e=this.mates.get(a.id);e&&e.returns++,this.flags[t]=Bt()}else o&&(this.flags[t]={...Bt(),state:w.CARRIED,by:o.id})}for(let t of e){let e=this.carrying(t.id);if(e>=0&&this.flags[t.team].state===w.HOME&&Ut(t.state,this.world.def.teams[t.team].base)){this.score[t.team]++;let n=this.mates.get(t.id);n&&n.caps++,this.flags[e]=Bt()}}if(this.score.some(e=>e>=this.rules.scoreLimit)||--this.clock<=0)return this.over=!0,this.clock=600,`end`}dropAt(e,[t,n,r]){this.flags[e]={state:w.DROPPED,by:0,x:t,y:n,z:r,left:10},this.back[e]=600}},Ut=(e,t)=>Math.hypot(e.x-t[0],e.z-t[2])<1.5&&e.y<t[1]+2.2&&e.y+1.8>t[1],Wt={R:7,ROVER_R:14,OPEN:21,SHUT:30,HOLD:60},Gt=({min:e,max:t},[n,r,i])=>r<e[1]-1||r>=t[1]?1/0:Math.sqrt((n-Math.min(Math.max(n,e[0]),t[0]))**2+(i-Math.min(Math.max(i,e[2]),t[2]))**2),Kt=(e,t,n=[])=>e.doors?.forEach((r,i)=>{let a=e.def.doors[i],o=t.some(e=>Gt(a,e)<Wt.R)||n.some(e=>Gt(a,e)<Wt.ROVER_R),s=Wt.OPEN*Wt.SHUT,c=Math.round(r.open*s)+(o||r.wait?Wt.SHUT:-Wt.OPEN);r.open=Math.min(s,Math.max(0,c))/s,r.wait=o?Wt.HOLD:Math.max(0,r.wait-1)}),qt=e=>e.doors?.forEach(e=>{e.open=e.wait=0}),Jt=(e,t,n)=>{let[r,i]=[e.x-t[0],e.z-t[2]];return r*r+i*i<n*n&&Math.abs(e.y-t[1])<1},Yt=e=>{if(e.mode===O.GROUND){if(e.cut===E.LUNGE){let[t,n]=F(e.yaw);e.vx=t*13,e.vz=n*13,e.dash=60,e.ev|=k.DASH}else e.cut===E.LEAP&&(e.vy=C,e.ev|=k.JUMP)}},B={NONE:0,SHOT:1,CUT:2,RAIL:3,LASER:4,NADE:5},Xt=(e,t,n,r,i=!0,a=[])=>{let o=e.down>0,s=!o&&(e.lock??0)>0;if(Mt(e,o||s?{...t,keys:0}:t,n,r,a),e.heat=Math.max(0,(e.heat??0)-(e.zapping?0:e.hot?1:2)),e.hot=!!e.hot&&e.heat>0,e.zapping=!1,e.zap=!!e.stun&&!!e.zap,o)return e.down>0&&!--e.down&&Xe(e,n,r),B.NONE;if(s)return Zt(e,t);let{rack:l,blade:u,rail:d,rifle:f}=n.def.teams[r],m=!!l&&Jt(e,l,1.2);i&&m&&!e.rack&&([e.ammo,e.mag]=[60,15]),e.rack=m,e.blade=!!e.blade||i&&!!u&&Jt(e,u,1.2);let _=!!d&&Jt(e,d,1.2);i&&_&&!e.inRail&&([e.rail,e.cap]=[240,80]),e.inRail=_;let v=!!f&&Jt(e,f,1.2);i&&v&&!e.inRifle&&([e.rifle,e.clip,e.nades]=[240,60,3]),e.inRifle=v,e.cool=Math.max(0,e.cool-1),e.lob=Math.max(0,(e.lob??0)-1);let y=e.mode===O.HANG||e.mode===O.CLIMB,{ticks:b,hold:x}=p[e.cut??0],ee=!!e.swing&&!e.heavy&&b-(e.swing??0)===x;ee&&e.wield&&i&&!y&&t.keys&T.FIRE?e.charge=Math.min((e.charge??0)+1,g):ee&&i&&!y&&(e.charge??0)>=h?([e.heavy,e.charge]=[!0,0],e.swing=Ft(e).ticks):(e.charge=ee?0:e.charge,e.swing=Math.max(0,(e.swing??0)-1),e.heavy=!!e.swing&&!!e.heavy),e.mag=Math.min(e.mag??0,Math.max(e.ammo,0));let S=[e.ammo>=0,!!e.blade,(e.rail??-1)>=0,(e.rifle??-1)>=0],te=t.keys&T.BLADE?1:t.keys&T.RAIL?2:t.keys&T.RIFLE?3:0,C=e.swing&&e.blade?1:S[te]?te:S.indexOf(!0);if(C!=(e.rifled?3:e.railed?2:+!!e.wield)&&(e.reload=0),[e.wield,e.railed,e.rifled]=[C==1,C==2,C==3],e.swing&&C>=0&&!e.blade&&(e.swing=0),!i)return[e.charge,e.reload]=[0,0],B.NONE;let[ne,re,ie,ae]=C==3?[`clip`,60,e.rifle,96]:C==2?[`cap`,80,e.rail,90]:[`mag`,15,e.ammo,78],[oe,w]=[e[ne]??0,Math.min(re,ie)];e.reload?--e.reload||(e[ne]=w):C!=1&&ie>=0&&!y&&oe<w&&(!oe||t.keys&T.RELOAD)&&([e.reload,e.charge]=[ae,0]);let se=C<0,E=se?c:Ft(e);if(e.swing&&E.ticks-e.swing===E.strike)return B.CUT;if((e.wield&&!ee||e.railed||e.rifled||y||e.reload||!e.wield&&!e.mag)&&(e.charge=0),e.rifled&&t.keys&T.SPECIAL&&!y&&e.nades&&!e.lob)return e.nades--,[e.lob,e.cool]=[60,7],e.shots=e.shots+1&255,B.NADE;if(t.keys&T.FIRE&&!y){let n=p[e.cut??0].ticks-(e.swing??0),r=!!(t.keys&T.SPECIAL)&&(!e.swing||!e.heavy&&(e.cut??0)<4&&n<=18);if(se)e.swing||([e.cut,e.heavy,e.swing]=[0,!1,c.ticks]);else if(e.wield&&(!e.swing||r))e.cut=Pt(t.keys)+(r?4:0),[e.swing,e.charge]=[p[e.cut].ticks,0],Yt(e);else if(e.rifled){if(!e.cool&&e.clip&&!e.reload)return e.rifle--,e.clip--,e.cool=3,e.shots=e.shots+1&255,B.LASER}else if(e.railed){if(e.cap&&!e.reload&&!e.hot)return e.heat=(e.heat??0)+1,e.hot=e.heat>=120,e.cool||=(e.rail--,e.cap--,2),e.zapping=!0,B.RAIL}else!e.wield&&!e.cool&&e.mag&&!e.reload&&(e.charge=Math.min((e.charge??0)+1,60))}else if(e.charge)return e.power=Math.min(Qt(e.charge),e.mag),e.charge=0,e.ammo-=e.power,e.mag-=e.power,e.shots=e.shots+1&255,e.cool=7,B.SHOT;return B.NONE},Zt=(e,t)=>{let n=!!(t.keys&T.FIRE);return e.pushes=(e.pushes??0)+ +(n&&!e.pressed)&255,e.pressed=n,e.away=t.keys&(T.LEFT|T.RIGHT|T.BACK)?Math.min((e.away??0)+1,24):0,e.lock=Math.max(1,e.lock-1),[e.wield,e.swing,e.charge]=[!0,0,0],B.NONE},Qt=e=>e<10?1:1+Math.floor(4*(e-10)/50),$t=-30,V=(e,t,n,r,i,a=A.CONCRETE)=>({min:[e,$t,t],max:[n,i,r],top:A.CONCRETE,side:a}),H=([e,t,n],[r,i,a],o,s=o,c)=>({min:[e,t,n],max:[r,i,a],top:o,side:s,tint:c});[V(4,57.7,24,76,10),V(4,36,24,53.5,10,A.GLASS),V(4,20,24,36,12.4),V(4,-5,24,7,12.4,A.GLASS),V(27,20,47,50,8),V(27,60,47,76,8,A.BRICK),H([9,12.2,39],[19,12.6,47],A.STEEL),...((e,t)=>[1,2,3,4,5,6].map(n=>H([12,t,e-n],[14,t+.4*n,e-n+1],A.CONCRETE)))(53,10),H([5,10,42],[5.5,14,42.5],A.STEEL),H([5,10,50],[5.5,14,50.5],A.STEEL),H([8,12.4,24],[20,12.85,24.45],A.STEEL),H([36,8,22],[37,14.5,48],A.PAINT,A.PAINT,[.15,.72,.62]),H([30,8,28],[34,10,32],A.CONCRETE),H([40,8,30],[44,10.2,34],A.PAINT,A.PAINT,[1,.3,.06]),H([28,9.2,44],[35,12,46],A.STEEL,A.PAINT,[.2,.42,1]),H([41.5,7.6,50],[42,8,60],A.STEEL),H([30,8,64],[34,9.6,68],A.PAINT,A.PAINT,[.2,.8,.3])];var en=240,U=[1,.22,.26],tn=[.2,.46,1],nn=[U,tn],rn=[1,.42,.08],an=[.12,.7,.62],on=(e,t,n,r,i,a,o)=>H([e,t,n],[r,i,a],A.PAINT,A.PAINT,o),sn=(e,t,n,r,i,a,o,s=$t)=>{let c=Math.ceil((o-a)/.46);return Array.from({length:c},(l,u)=>{let[d,f]=[t+(n-t)*u/c,t+(n-t)*(u+1)/c].sort((e,t)=>e-t),p=a+(o-a)*(u+1)/c;return e===0?H([d,s,r],[f,p,i],A.CONCRETE):H([r,s,d],[i,p,f],A.CONCRETE)})},cn=(e,t,n,r,i,a,o)=>o.map((o,s)=>H([e+s*n,a,t+s*r],[e+s*n+4,o,t+s*r+i],A.STEEL,A.CONCRETE)),ln=[V(12,212,52,240,26,A.GLASS),on(12,26,212,52,26.12,212.5,U),on(12,26,239.5,52,26.12,240,U),on(12,26,212.5,12.5,26.12,239.5,U),on(51.5,26,212.5,52,26.12,239.5,U),on(11.6,12,222,12,25.8,232,U),on(28,12,211.4,31,25.5,212,U),H([19,26,222],[22,27.4,225],A.STEEL),H([42,26,222],[45,27.4,225],A.STEEL),H([29,26,229],[35,27.1,229.6],A.CONCRETE),H([24.5,26,215],[35,27.5,219],A.STEEL,A.PAINT,U),V(6,164,26,201,26,A.GLASS),V(6,134,26,147,26,A.GLASS),V(6,201,26,212,19),V(15,147,26,164,19),H([14,26,164],[15,32,196],A.PAINT,A.PAINT,an),H([14,18,147],[15,32,164],A.PAINT,A.PAINT,an),H([14,26,134],[15,32,147],A.PAINT,A.PAINT,an),...cn(6,201,7,0,4,19,[21.2,23.4,25]),...[[18,152,22,156,21.2],[18,158,22,162,23.4],[23,160,26,164,25]].map(([e,t,n,r,i])=>H([e,19,t],[n,i,r],A.STEEL,A.CONCRETE)),H([20,26,178],[23,27.3,181],A.STEEL),H([8,26,176],[11,27.2,179],A.STEEL),H([8,26,190],[11,27.3,193],A.STEEL),H([20,26,140],[23,27.3,143],A.STEEL),V(32,186,76,209,19),on(32,19,207.5,76,19.1,209,U),...cn(33,209,7,0,3,19,[21.2,23.4,25]),...[[28,196,32,200,21.2],[28,190,32,194,23.4],[26,184,30,188,25]].map(([e,t,n,r,i])=>H([e,$t,t],[n,i,r],A.STEEL,A.CONCRETE)),V(32,166,64,182,21.2,A.GLASS),V(32,140,64,161,19),H([40,21.2,172],[44,22.6,176],A.STEEL),H([52,19,148],[57,20.3,151],A.STEEL),H([38,19,196],[41,20.4,199],A.STEEL),H([60,19,200],[63,20.4,203],A.STEEL),H([52,19,190],[58,20.6,194],A.STEEL),H([66,19,204],[72,20.2,207],A.STEEL),H([56,21.2,170],[60,22.4,174],A.STEEL),H([34,19,152],[37,20.3,156],A.STEEL),...cn(36,135,18,0,3,15,[17.2,17.2]),...cn(6.5,129,6,0,4,15,[17.2,19.4,21.6,23.8]),V(76,213,100,240,14.5,A.STEEL),on(76,14.5,238.5,100,14.6,240,U),V(76,185,100,209,14.5),V(76,138,100,181,14.5,A.GLASS),H([80,15.7,158],[96,17.7,162],A.STEEL,A.PAINT,rn),H([82,14.5,234],[85,15.9,237],A.STEEL),H([91,14.5,190],[94,15.9,193],A.STEEL),H([80,14.5,204],[83,15.6,207],A.STEEL),H([78,14.5,170],[81,15.9,173],A.STEEL),H([92,14.5,146],[95,15.7,149],A.STEEL),H([92,14.5,222],[96,15.8,226],A.STEEL),...sn(0,76,52,226,232,14.5,26),...sn(0,85,76,196,202,14.5,19,14.5)],un=[V(6,106,62,134,15),V(62,106,100,134,14.5),H([34,15,112],[54,17.2,128],A.CONCRETE),on(38,17.2,116,50,17.3,124,rn),...[[35,113],[35,126.2],[51,113],[51,126.2]].map(([e,t])=>H([e,17.2,t],[e+.8,21.5,t+.8],A.STEEL)),H([34.6,21.5,112.6],[52.2,21.9,127.4],A.GLASS),H([14,15,114],[17,16.5,117],A.STEEL),H([14,15,123],[17,16.5,126],A.STEEL),H([56,15,114],[59,16.5,117],A.STEEL),H([56,15,123],[59,16.5,126],A.STEEL),H([15.35,25.5,106],[15.85,26,134],A.STEEL),H([70,14.5,108],[70.8,38,108.8],A.STEEL),H([70,14.5,131.2],[70.8,38,132],A.STEEL),H([66,14.5,110],[69,15.9,113],A.STEEL),H([66,14.5,127],[69,15.9,130],A.STEEL)],dn=e=>({...e,min:[e.min[0],e.min[1],en-e.max[2]],max:[e.max[0],e.max[1],en-e.min[2]],tint:e.tint===U?tn:e.tint}),fn=(e,t,n)=>[...[16,22,28,34,40].map(n=>[n,26,t,e]),...[19,31,43].map(t=>[t,26,n,e])],pn=[[20,26,190],[48,21.2,172],[48,19,200],[88,14.5,198]],mn=[[21,26,168],[16,26,140],[46,19,144],[36,21.2,178],[58,19,156],[64,19,196],[88,14.5,216],[88,14.5,172],[90,14.5,150]],hn=[[19.5,26,179],[46,19,152],[39.5,21.2,172],[88,14.5,186],[88,14.5,207]],gn={armor:!0,name:`Highline`,tag:`Rooftops · 94 × 240 m`,lore:`The towers of an old business district, closed for years, far above streets that still have traffic. Two crews of runners have taken the roofs. Three routes cross between them, and a fall takes you back to your tower.`,brushes:[...ln,...ln.map(dn),...un],teams:[{base:[32,26,224],spawns:fn(0,236,231),rack:[30.75,27.5,217],blade:[33.25,27.5,217],rail:[28.25,27.5,217],rifle:[25.75,27.5,217]},{base:[32,26,16],spawns:fn(Math.PI,4,9),rack:[30.75,27.5,23],blade:[33.25,27.5,23],rail:[28.25,27.5,23],rifle:[25.75,27.5,23]}],packs:[...pn,...pn.map(([e,t,n])=>[e,t,en-n]),[24,15,112],[24,15,128]],ammo:[...mn,...mn.map(([e,t,n])=>[e,t,en-n]),[12,15,116],[12,15,124]],cells:[...hn,...hn.map(([e,t,n])=>[e,t,en-n]),[28,15,en/2]],floor:-25,sun:{dir:[.8,.6,0],color:[2.6,2.3,1.8]},sky:[[.04,.2,.72],[.72,.86,.98]],fog:[.72,.86,.98,.0035]},{CONCRETE:_n,METAL:vn,STEEL:W,PAINT:yn}=A,G=(e,t,n,r,i,a,o,s=o,c)=>({min:[e,t,n],max:[r,i,a],top:o,side:s,tint:c}),bn=({min:e,max:t},n,r=n)=>({min:e,max:t,top:n,side:r}),xn=(e,t,n,r,i,a)=>({min:[e,t,n],max:[r,i,a]}),Sn=22.4,Cn=e=>e<5?Sn:Sn*Math.sqrt(1-((e-5)/12)**2),wn=e=>Math.round(e*10)/10,Tn=[0,10.5,13.5,15.5,17],En=e=>[[1,.39],[.93,.71],[.71,.93],[.39,1]].map(([t,n])=>[wn(t*e),wn(n*e)]),[[Dn,On],[kn,An]]=En(22.599999999999998),[K,jn]=[.4,2.48],q=[80,236],Mn=[xn(111,0,222,125,5,230),xn(96,0,196,110,5,204)],Nn=[xn(102,0,223.2,111,3.5,227.2),xn(98,0,204,102,3.5,227.2)],[[Pn,,Fn],[In,Ln,Rn],[zn,,Bn],[Vn]]=Nn.flatMap(e=>[e.min,e.max]),[[Hn,Un],[Wn,Gn]]=[[19.8,6.7],[16,13.5]],Kn=[[0,-Hn,2,3,2.8],[Wn,-10.8,2,3.5,2]],qn=[xn(q[0]-Kn[0][2],0,q[1]-Hn-1.55,q[0]+Kn[0][2],Kn[0][3],q[1]-Hn-1.25),xn(116.8,0,Mn[0].max[2]-.3,119.2,jn,Mn[0].max[2]-.1),xn(101.8,0,Mn[1].min[2]+.1,104.2,jn,Mn[1].min[2]+.3)],Jn=e=>[...new Map(e.flatMap(([e,t,n,r])=>[1,-1].flatMap(i=>[1,-1].flatMap(a=>[[e,n,t,r],[t,r,e,n]].map(([e,t,n,r])=>[Math.min(i*e,i*t),Math.min(a*n,a*r),Math.max(i*e,i*t),Math.max(a*n,a*r)])))).map(e=>[`${e}`,e])).values()],Yn=([e,t,n,r],i,a,o=_n,s=o)=>({...G(q[0]+e,i,q[1]+t,q[0]+n,a,q[1]+r,o,s),ghost:!0}),Xn=(e,t,n,r,i,a,o)=>{let s=Math.ceil((o-a)/.46);return Array.from({length:s},(c,l)=>{let[u,d]=[t+(n-t)*l/s,t+(n-t)*(l+1)/s].sort((e,t)=>e-t),f=a+(o-a)*(l+1)/s;return e?G(r,a,u,i,f,d,_n):G(u,a,r,d,f,i,_n)})},Zn=[...Jn([[12,-Gn,Wn,Gn],[Wn,-Un,Hn,Un]]).filter(e=>e[1]>-Hn).map(e=>Yn(e,3.1,3.5,vn,W)),...Xn(2,q[1]+5.6,q[1]+12,q[0]-1.5,q[0]+1.5,0,3.5).map(e=>({...e,ghost:!0})),Yn([-3,19,3,Hn],3.5,4.6,W,vn),Yn([-9,12,-2.5,12.5],3.5,4.6,W,yn),Yn([2.5,12,9,12.5],3.5,4.6,W,yn),Yn([-9.5,-10,-7.5,-8],0,1.4,W),Yn([7.5,-10,9.5,-8],0,1.4,W),Yn([7.5,3,10,5.5],0,2.4,W)],{BENCH:Qn,SAMPLES:$n,RACKS:er,SCOPE:tr,ANALYSER:nr,PLANTS:rr,LOCKERS:ir,SUIT:ar}={BENCH:0,SAMPLES:1,RACKS:2,SCOPE:3,ANALYSER:4,PLANTS:5,LOCKERS:6,SUIT:7},or=[[Qn,60.2,230.5,61.2,241.5,0,.95,0],[$n,65,233.5,66.5,238.5,0,.9,0],[er,98.8,229.3,99.8,234.3,0,3.1,2],[er,98.8,237.7,99.8,242.7,0,3.1,2],[tr,68.9,250.8,70.1,252,3.5,4.5,3],[nr,89.4,250.8,91.4,252,3.5,4.8,3],[rr,115,222.4,121,223.2,0,2,1],[rr,123.8,226.4,124.6,229.6,0,2,2],[ir,96.4,200.4,97,203.6,0,2.1,0],[ar,108.6,197.4,109.6,198.4,0,2,2]],sr=(e,t,n,r,i,a,o=[])=>{let s=(t,n,o)=>e?G(r,o,t,i,a,n,_n):G(t,o,r,n,a,i,_n);return[...o,[n,n]].flatMap(([e,n],r,i)=>[s(r?i[r-1][1]:t,e,0),...n>e?[s(e,n,jn)]:[]])},cr=({min:[e,,t],max:[n,r,i]},a,o)=>[G(e,4,t,n,r,i,vn,_n),...sr(0,e,n,t,t+K,4,a[0]),...sr(0,e,n,i-K,i,4,a[1]),...sr(2,t+K,i-K,e,e+K,4,a[2]),...sr(2,t+K,i-K,n-K,n,4),o],lr=[1,.42,.08],ur=[...Tn.slice(2).flatMap((e,t)=>En(Cn(Tn[t+1])+.2).map(([n,r])=>Yn([-n,-r,n,r],Tn[t+1],e))),...Jn([[Hn,-On,Dn,On],[Wn,Un,kn,An],[Gn,Gn,Wn,Wn]]).map(e=>Yn(e,Kn.find(([t,n])=>e[0]<=t&&t<=e[2]&&e[1]<=n&&n<=e[3])?.[3]??0,Tn[1])),...[[-On,-Dn,-Kn[0][2],-Hn],[Kn[0][2],-Dn,On,-Hn],[Wn,Rn-q[1],kn,-Un],[Wn,-An,zn-q[0],Fn-q[1]]].map(e=>Yn(e,0,Tn[1])),...Zn,...or.map(([,e,t,n,r,i,a])=>({...G(e,i,t,n,a,r,W),ghost:!0})),...cr(Mn[0],[[[118,118]],[[116.8,119.2]],[[Fn+K,Rn-K]]],G(121.5,0,223.5,123.5,1.2,225.5,yn,yn,lr)),...cr(Mn[1],[[[101.8,104.2]],[[zn+K,Vn-K],[105.8,105.8]]],G(106,0,200.6,108,1.2,202.6,yn,yn,lr)),G(Pn,jn,Fn,In,Ln,Rn,W,vn),G(zn,jn,Bn,Vn,Ln,Rn,W,vn),G(zn,0,Rn-K,In,jn,Rn,vn),G(Vn-K,0,Fn,In,jn,Fn+K,vn),G(zn,0,Bn,zn+K,jn,Fn,vn),G(Vn-K,0,Bn,Vn,jn,Fn,vn),...Xn(2,214,Fn,105,109,0,3.5),...Xn(0,108,Vn,206,210,0,3.5)],[dr,fr]=nn,{STONE:J,CONCRETE:pr,METAL:mr,STEEL:hr,PAINT:gr}=A,_r=({min:e,max:t})=>xn(e[0],e[1],280-t[2],t[0],t[1],280-e[2]),vr=[40,220,13],yr=xn(33,.25,218,47,3.25,222),br=[[27.3,207.3],[52.7,207.3],[27.3,232.7],[52.7,232.7],[106.2,230.4],[103.2,212.4]],xr=q[1]-2,Y=e=>Math.min(Math.max(e,0),1),Sr=e=>Y(e)*Y(e)*(3-2*Y(e)),Cr=(e,t)=>Math.sqrt(e*e+t*t),wr=[[-100,0,46,.13,.52],[-4,224,36,.12,.67],[110,236,16],[-112,108,14],[236,170,13],[-52,230,10],[80,184,14],[150,250,13],[-36,168,10],[200,152,12],[262,134,14],[240,150,9],[-140,60,12],[-66,60,9],[40,262,10],[118,200,11]],Tr=[[-20,0,-1,0],[192,124,0,-1],[64,236,1,0],[-60,100,0,1]],[Er,Dr]=[[248,64],[180,200]],Or=[[12,24],[36,60],[72,88],[124,156]],kr=(()=>{let e=Array.from({length:160},(e,t)=>Or.some(([e,n])=>t>=e-1&&t<=n)?0:Math.min(Math.round(Math.max(26*j(t/17,0,33)+8*j(t/5,0,35)-11,0))/2,6.5));for(let t of[1,-1])for(let n=t>0?1:158;n>=0&&n<160;n+=t)e[n]=Math.min(e[n],e[n-t]+.5);return e.map((e,t)=>{let n=Math.min(t,159-t);return n<4?-6:n<8?-3:e})})(),Ar=e=>e.reduce((e,t,n)=>(e.at(-1)?.[2]===t?e.at(-1)[1]++:e.push([n,1,t]),e),[]),jr=Ar(kr),X=[114,176,2],Mr=[48,144],[Nr,Pr]=[3,8],Fr=[[27,67,53,93],[56,74,104,133],[96,56,125,90],[98,36,102,40],[28,113,32,117],[30,45,30,45],[135,50,135,50],[50,106,50,106],[35,104,35,104],[115,22,115,22],[45,20,51,62],[114,36,114,36],[141,20,147,66]],Ir=[[0,0,4.5],[-14,6,3],[10,-12,3.5],[16,10,2.5],[-8,-16,2.2],[-20,-8,3.8],[6,18,3],[22,-4,2],[-12,20,2.4]].map(([e,t,n])=>[e-50,t+330,n]),Lr=[[126,143,131,147,1.2],[130,138.5,135,141.5,2.4],[126,133,131,137,1.2]],Rr=[[180,340],[173,346],[186,347]],zr=[wr[0][0]-4.5,140],Br=[[4,172,4,4,2.2],[30,154,5,5,3],[66,158,3,3,1.6],[95,164,5,4,2.6],[125,175,6,5,3.2],[92,186,4,4,2.4]],Vr=.85,Hr=Array.from({length:36},(e,t)=>{let n=e=>Te(t,e,41),r=Math.floor(n(1)*3),[i,a]=r<2?[(r?151:0)+n(2)*9,150+n(3)*122]:[5+n(2)*150,273+n(3)*7];return[i,a+(r===0&&Math.abs(a-174)<8?16:0),.6+2.4*n(4)*n(4)]}).filter(([e,t,n],r,i)=>!i.slice(0,r).some(([r,i,a])=>{let o=Math.max(Math.abs(e-r),Math.abs(t-i))-Vr*(n+a);return o>0&&o<1})),Ur=(e,t)=>{let[n,r]=[0,0];for(let[i,a,o,s=.17,c=0]of wr){let l=Cr(e-i,t-a),[u,d]=l?[(e-i)/l,(t-a)/l]:[1,0],f=l/o*(.9+.2*j(2.5*u+.37*i,2.5*d+.21*a,9)),p=.03+.045*j(4*u-.1*a,4*d+.1*i,10),m=1-Y((f-1-4/o)/.6),h=c?(s+p)*Y((f-c)/(1-c))-s:(s+p)*f*f-s;n+=o*(f<1?h:p*m*m),r=Math.max(r,c?Y((1.6-f)/(1.5-c)):0)}return[n,r]},Wr=(e,t)=>{let n=t=>Y((12-Math.abs(t-e))/8)*Y((152-t)/4),r=4*Math.floor(t/4);return n(r)+(n(r+4)-n(r))*(t-r)/4},Gr=(e,t)=>{t=Math.abs(t-140);let n=Cr((e-80)/300,t/360),r=Math.max((n-.78)/.22,0),i=Ur(e,t),a=Math.max(Math.abs(e-80)-80,t-140),o=Sr((a-12)/48)*(1-.7*Sr(r))*(16*j(e/96,t/96,1)+6*j(e/52,t/52,4)+5*j(e/36,t/36,2)+1.4*j(e/22,t/22,3)-14.2);if(a<0){let n=Sr((t-16-10*j(e/19,.5,37))/8)*Sr(-a/10);for(let[r,i,a,o]of Fr)n*=Sr((Cr(Math.max(r-e,e-a,0),Math.max(i-t,t-o,0))-6)/6);o=n*Math.min(Math.max(4.8*j(e/15,t/15,21)-.9,0)+Math.max(3*j(e/31,t/31,23)-.6,0),2.6);let r=Sr((10-Cr(e-X[0],t-(X[1]-140)))/8);o=o*(1-r)-X[2]*r;for(let n of Mr)o+=Nr*Y((8+Pr-t)/Pr)*Wr(n,e);o=t<8?0:o}o=(a<0?o:o*(1-i[1]))+i[0];for(let[n,r,i,a]of Tr){let[s,c]=[e-n,t-r],l=s*i+c*a;o+=5.6*Y(Math.min(l/16,(32-l)/12))*Y((18-Math.abs(s*a-c*i))/12)}let s=Y(Cr(e-Er[0],Math.max(t-Er[1],0))/36);o+=12*(1-s*s)*(1-s*s)+8*Sr((36-Cr(e-Dr[0],t-Dr[1]))/24);let c=10*r*(1+r);return n>1&&(c=(c+(n-1)*60*(Math.abs(2*j(e/45,t/45,5)-1)-.5))*(1+(n-1)*(1.2*j(e/90,t/90,7)-.6))*(1-Sr((n-1.25)/.4))),Math.max(o,-14.5)+c},Kr=[[1,0],[.309,.951],[-.809,.588],[-.809,-.588],[.309,-.951]],qr=(e,t,n)=>{let r=t=>Te(e,t,131),i=e=>{let[t,n]=[2*r(e)-1,2*r(e+1)-1],i=Math.sqrt(t*t+n*n)||1;return[t/i,n/i]},a=[0,1,2].slice(0,t<1.3?1:t<3.2?2:3).map(e=>{let[a,o]=i(20*e+1),[s,c]=[[.1,.45,.42][e]*t,[.8,.75,.65][e]*t],l=[a*s,o*s],u=[n,(.5+.15*r(20*e+3))*n,.34*n][e]-.25*n,d=Math.min(.06,.06/c),[f,p]=[(2*r(20*e+4)-1)*d,(2*r(20*e+5)-1)*d],m=Math.sqrt(f*f+1+p*p);return{o:l,rad:c,top:u,planes:[[f/m,1/m,p/m,(f*l[0]+u+p*l[1])/m],...Kr.map(([t,n],i)=>{let[a,o]=[t+r(20*e+6+i)-.5,n+r(20*e+11+i)-.5],s=Math.sqrt(a*a+o*o),u=-.15+.5*r(20*e+16+i),d=Math.sqrt(1-u*u),[f,p]=[d*a/s,d*o/s];return[f,u,p,f*l[0]+p*l[1]+c*(.72+.22*r(20*e+21+i))]})]}}),[o,s]=i(91),c=[.866*o,-.5,.866*s,.72*t];return{reach:t=>{let r=0;for(let{o:e,rad:i,planes:o}of a){let[a,s]=[1.2*i,1.15*n],l=(t[0]*t[0]+t[2]*t[2])/(a*a)+t[1]*t[1]/(s*s),u=-2*(t[0]*e[0]+t[2]*e[1])/(a*a),d=(e[0]*e[0]+e[1]*e[1])/(a*a)-1,f=(-u+Math.sqrt(u*u-4*l*d))/(2*l);for(let[e,n,r,i]of[...o,c]){let a=t[0]*e+t[1]*n+t[2]*r;f=a>1e-9?Math.min(f,i/a):f}r=Math.max(r,f)}return r*(.94+.12*j(1.5*t[0]+e,1.5*t[2]+2*t[1],e))},tops:a.map(({o:e,top:t})=>[e[0],e[1],t])}},Jr=({reach:e,tops:t},n,r)=>{let i=(t,n,r,i=.09)=>{let a=Math.sqrt(t*t+n*n+r*r);return a<1e-6||a<=e([t/a,n/a,r/a])+i},a=[-1,0,1],o=(e,t,n,o,s)=>[r+.05,(r+s)/2,s].every(r=>a.every(s=>a.every(a=>i(e+s*n,r,t+a*o))))&&a.every(r=>a.every(a=>!i(e+r*n,s+.2,t+a*o,0)));return t.flatMap(([e,t,i],a)=>{let s=[0,0,0,0,0,0],c=Math.sqrt(e*e+t*t)||1;for(let l of a?[.1,.3,.5]:[-.15,0,.15])for(let u of[-.15,0,.15]){let[d,f]=a?[e+(l*e-u*t)*(n/c),t+(l*t+u*e)*(n/c)]:[e+l*n,t+u*n],p=0;for(let e=i+.1;!p&&e>r+.3;e-=.1)p=o(d,f,.08*n,.08*n,e)?e:0;let[m,h]=[.08*n,.08*n];for(let[e,t]of p?[[1,1],[1,0],[0,1]]:[])for(let r=.5*n;r>.03;r/=2)[m,h]=o(d,f,m+e*r,h+t*r,p)?[m+e*r,h+t*r]:[m,h];p&&m*h*(p-r)>s[0]&&(s=[m*h*(p-r),d,f,m,h,p])}let[,l,u,d,f,p]=s;return Math.min(d,f)<(a?.25:0)?[]:[[l-d,r,u-f,l+d,p,u+f]]})},Yr=(e,t,n,r,i,a=0)=>{let o=Gr(e,t),s=o+.25*r;return{at:[e,o,t],R:n,H:r,s:i,parts:Jr(qr(i,n,r),n,-.25*r).filter((e,t,n)=>{let r=Math.max(e[0]-n[0][3],n[0][0]-e[3],e[2]-n[0][5],n[0][2]-e[5]);return!t||r<=0||r>1.2}).map(([n,,r,i,o,c])=>[e+n,a,t+r,e+i,s+o,t+c])}},Xr={arena:[...Br.map(([e,t,n,r,i],a)=>Yr(e+n/2,t+r/2,.31*(n+r),1.15*i,a+61)),...Hr.map(([e,t,n],r)=>Yr(e,t,n,.8*n,r))],field:Ir.map(([e,t,n],r)=>Yr(e,t,n,.75*n,r+100,Gr(e,t)-6))},Zr=e=>e.flatMap(e=>e.parts).map(([e,t,n,r,i,a])=>({...G(e,t,n,r,i,a,J),ghost:!0})),[Z,Qr,$r,ei]=[9,12,-19,7],ti=wr.filter(e=>e[4]).map(([e,t],n)=>{let r=140+t,i=Array.from({length:2*Z},(e,t)=>{let i=Math.abs(t+.5-Z),a=Math.sqrt(Z*Z-i*i),o=e=>Math.ceil(2*a*(.88+.24*j(i/4,e+.5,60+n)))/2;return[r-Z+t,r-Z+t+1,o(0),o(1)]});return{x:e,z:r,level:Gr(e,r),rows:i}}),ni=({x:e,z:t,level:n,rows:r})=>{let i=r.reduce((e,[t,n,r,i])=>{let a=e.at(-1);return a&&a[2]===r&&a[3]===i?a[1]=n:e.push([t,n,r,i]),e},[]),a=r[Z][3],o=(n-$r)/ei;return[G(e-Qr,-30,t-Qr,e+Qr,n,t-Z,J),G(e-Qr,-30,t+Z,e+Qr,n,t+Qr,J),...i.flatMap(([t,r,i,a])=>[G(e-Qr,-30,t,e-i,n,r,J),G(e+a,-30,t,e+Qr,n,r,J)]),G(e-Z-1.5,-30,t-Z,e+Z+1.5,$r,t+Z,J),...Array.from({length:ei-1},(n,r)=>G(e+a-1.3*(ei-1-r),$r,t-1,e+a-1.3*(ei-2-r),$r+o*(r+1),t+1,J))].map(e=>({...e,ghost:!0}))},ri=(e,t,n,r)=>({...G(e-n,Gr(e,t)-6,t-n,e+n,Gr(e,t)+r,t+n,J),ghost:!0}),ii={rocks:[...Ir,...Ir.map(([e,t,n])=>[e,280-t,n])],dishes:[...Rr,...Rr.map(([e,t])=>[e,280-t])],ramps:Tr.flatMap(([e,t,n,r])=>(t?[1,-1]:[1]).map(i=>[e+16*n,140+i*(t+16*r),n,i*r+0])),wreck:zr,pits:ti.flatMap(e=>e.z===140?[e]:[e,{...e,z:280-e.z,rows:e.rows.map(([e,t,n,r])=>[280-t,280-e,n,r]).reverse()}]),bowls:wr.flatMap(([e,t,n,r=.17])=>(t?[1,-1]:[1]).map(i=>[e,140+i*t,n,r])),boulders:Hr,crags:Xr,stones:Br,pillars:Lr,domes:[q,[q[0],280-q[1]]],pads:[vr,[vr[0],280-vr[1],vr[2]]],shuttles:[yr,_r(yr)],modules:[...Mn,...Mn.map(_r)],tubes:[...Nn,...Nn.map(_r)],masts:[...br,...br.map(([e,t])=>[e,280-t])]},ai=e=>({...e,min:[e.min[0],e.min[1],280-e.max[2]],max:[e.max[0],e.max[1],280-e.min[2]],tint:e.tint===dr?fr:e.tint}),oi=([e,t,n])=>[e,t,280-n],si=(e,...t)=>[...e,...e.map(oi),...t],ci=[...[G(0,-30,160,160,0,X[1]-12,J),G(0,-30,X[1]-12,X[0]-12,0,X[1]+12,J),G(X[0]+12,-30,X[1]-12,160,0,X[1]+12,J),G(0,-30,X[1]+12,160,0,280,J),G(X[0]-12,-30,X[1]-12,X[0]+12,-3,X[1]+12,J),...jr.filter(e=>e[2]<0).map(([e,t,n])=>G(e,-30,148+n,e+t,0,160,J)),...Array.from({length:14},(e,t)=>Ar(kr.map(e=>e<0?2:+(e>t/2))).filter(e=>!e[2]).map(([e,n])=>G(e,-30,148+t/2,e+n,0,t<13?148.5+t/2:160,J))).flat(),...Mr.flatMap(e=>[-12,-10,-8,-6,-4,4,6,8,10].map(e=>[e,e+(e===-4?8:2)]).map(([t,n])=>[e+t,e+n,Nr*Math.min(Wr(e,e+t),Wr(e,e+n))*(1-.5/Pr)-.12]).filter(e=>e[2]>.3).map(([e,t,n])=>G(e,0,148,t,n,148.5,J)))].map(e=>({...e,ghost:!0})),...ur,{...G(75.25,0,xr-4.75,84.75,.5,xr+4.75,gr,pr,dr),ghost:!0},{...G(75.75,.5,xr-4.25,84.25,1,xr+4.25,gr,pr,dr),ghost:!0},G(60,0,259,70,1.5,265,hr,gr,dr),G(27,0,207,53,.25,233,mr),{...bn(yr,gr),tint:[.82,.84,.88]},{...G(42,1,222,45.8,1.25,225.5,mr),ghost:!0},{...G(42,1,214.5,45.8,1.25,218,mr),ghost:!0},{...G(43,3.25,219.9,46.8,5.4,220.1,gr),ghost:!0},...br.map(([e,t])=>G(e-.2,e<60?.25:0,t-.2,e+.2,e<60?10.25:10,t+.2,hr)),G(12,-30,148-2.5/2,24,0,148,gr,J,[1,.42,.08]),...ti.filter(e=>e.z!==140).flatMap(ni),...Zr(Xr.arena),...Zr(Xr.field),...Rr.map(([e,t])=>ri(e,t,.4,6))],li=[G(74,-1.5,132,86,0,148,mr,hr),G(74,0,132,74.4,1.1,148,pr),G(85.6,0,132,86,1.1,148,pr),...Lr.map(([e,t,n,r,i])=>({...G(e,-30,t,n,i,r,J),ghost:!0})),{...G(-10,-30,132,0,0,148,J),ghost:!0},{...G(160,-30,132,170,0,148,J),ghost:!0},{...G(zr[0]-3.6,-30,zr[1]-3.6,zr[0]+3.6,$r+3.5,zr[1]+3.6,J),ghost:!0},...ti.filter(e=>e.z===140).flatMap(ni),...ii.ramps.flatMap(([e,t,n,r])=>[-8,8].map(i=>ri(e+i*r,t-i*n,.2,2.2)))],ui=[...[56,68,80,92,104].map(e=>[e,0,271,0]),...[62,80,98].map(e=>[e,0,267,0])],di=e=>Object.fromEntries([`rifle`,`rail`,`rack`,`blade`].map((t,n)=>[t,[61.25+2.5*n,1.5,e]])),fi=(e,t)=>({base:[80,1,e],spawns:t,...di(e+(e>140?28:-28))}),pi={highline:gn,tranquility:{name:`Tranquility`,tag:`Moon · half gravity`,lore:`A mining base left in a lunar crater, its domes still lit. Two crews fight for it in space helmets, under the Earth and a black sky. Jumps float twice as high, and a rille cuts the base in two.`,brushes:[...ci,...ci.map(ai),...li],teams:[fi(xr,ui),fi(280-xr,ui.map(([e,t,n])=>[e,t,280-n,Math.PI]))],packs:si([[90,0,210],[118,5,226],[30,0,185],[80,3.5,253.5]],[45,0,162],[45,0,118]),ammo:si([[50,0,246],[103,5,200],[135,0,190]],[115,0,162],[115,0,118]),cells:si([[106.5,3.5,226],[35,0,244]],[80,0,140]),floor:-26,relief:{hole:[0,132,160,148],pits:[...jr.flatMap(([e,t,n])=>n>0?[[e,148,e+t,148+n],[e,132-n,e+t,132]]:[]),...ii.pits.flatMap(({x:e,rows:t})=>t.map(([t,n,r,i])=>[e-r,t,e+i,n]))],bound:[80,140,300,360],cell:4,at:Gr},sun:{dir:[.87996,.40998,.23999],color:[3,2.95,2.85]},sky:[[.002,.002,.006],[.02,.02,.035]],gravity:.5,rovers:[[100,0,178,0],[30,0,255,0],[100,0,102,Math.PI],[30,0,25,Math.PI]],doors:[...qn,...qn.map(_r)],scenery:`moon`,helmets:!0,armor:!0}},mi=e=>e!==void 0&&pi[e]||gn,hi=e=>e!==void 0&&Object.hasOwn(pi,e)?e:`highline`,gi=40/60,_i=b/60,vi=e=>[ae*Math.sin(e*2.4),ae*Math.cos(e*1.7)],yi=(e,t=0)=>{let[n,r]=e.rifled?vi(e.shots):[0,0],[i,a]=[e.yaw+n,e.pitch+r],[o,s,c,l]=[Math.sin(i),Math.cos(i),Math.sin(a),Math.cos(a)];return{id:e.shots,by:e.id,team:t,x:e.x,y:e.y+Qe(e),z:e.z,dx:-o*l,dy:c,dz:-s*l,left:e.rifled?60:80,burst:!1,power:e.rifled?0:e.power??1}},bi=(e,t=0)=>({...yi(e,t),id:e.shots^128,left:x,power:1,arc:e.cut}),xi=e=>e.arc?_i:e.power===6?2:gi,Si=(e,t,n,r,i)=>{let[a,o]=[e[0]-n.x,e[2]-n.z],s=t[0]*t[0]+t[2]*t[2],c=a*t[0]+o*t[2],l=c*c-s*(a*a+o*o-r*r),[u,d]=[0,1/0];if(s>1e-12){if(l<0)return 1/0;[u,d]=[(-c-Math.sqrt(l))/s,(-c+Math.sqrt(l))/s]}else if(a*a+o*o>r*r)return 1/0;let[f,p]=[n.y-e[1],n.y+i-e[1]];if(t[1])[u,d]=[Math.max(u,Math.min(f/t[1],p/t[1])),Math.min(d,Math.max(f/t[1],p/t[1]))];else if(f>0||p<0)return 1/0;return u<=d&&d>=0?Math.max(u,0):1/0},Ci=(t,n,r,i)=>{let a=[n.x,n.y,n.z],o=[n.dx,n.dy,n.dz],s=Math.min(r,n.left),c=Re(t,a,o,s,f),l;for(let t of i){let r=Si(a,o,t,e+(n.arc?ee:f),R(t));r<c&&([c,l]=[r,t])}return n.burst=c<s,n.left-=c,[n.x,n.y,n.z]=[a[0]+o[0]*c,a[1]+o[1]*c,a[2]+o[2]*c],l},wi=(e,t=0)=>({...yi({...e,rifled:!1},t),left:150,power:7,v:36}),Ti=(e,t,n)=>{let r=Math.fround,[i,a,o]=[t.dx*t.v,t.dy*t.v-ht(e)/60,t.dz*t.v],s=Math.sqrt(i*i+a*a+o*o)||1;[t.dx,t.dy,t.dz,t.v]=[r(i/s),r(a/s),r(o/s),r(s)];let c=Ci(e,t,t.v/60,n);return[t.x,t.y,t.z,t.left]=[r(t.x),r(t.y),r(t.z),r(t.left)],t.burst||=t.left<=0,c},Ei=(e,t,n)=>{let r=R(n),i=[n.x,Math.max(n.y,Math.min(n.y+r,t[1])),n.z],[a,o,s]=[i[0]-t[0],i[1]-t[1],i[2]-t[2]],c=Math.sqrt(a*a+o*o+s*s);return c>=5||Be(e,t,i)&&Be(e,t,[n.x,n.y+.7*r,n.z])?0:Math.ceil(5*(1-c/5))},Di=(t,n,r=[],i=30,[a,o]=[0,0])=>{let s=[n.x,n.y+Qe(n),n.z],[c,l]=[n.yaw+a,n.pitch+o],u=Math.cos(l),d=[-Math.sin(c)*u,Math.sin(l),-Math.cos(c)*u],f=Re(t,s,d,i),p;for(let t of r){let n=Si(s,d,t,e,R(t));n<f&&([f,p]=[n,t])}return{o:s,d,t:f,hit:p}},Q={A:1.25,B:1,WR:.5,L0:.6,CMAX:.5,K:30,D:2,KP2:1.2,KR2:.7,HC:.7,ENGINE:12,VMAX:23.2,VREV:8,BRAKE:14,ROLL:.6,HB:6,MU:1.1,MUL:1.2,HBG:.35,HBY:1.5,SK:2.5,SV:10,SMAX:.55,SRATE:3.5,YMAX:2.4,YRESP:10,AK:5,AC:3,AD:.5,TILT:.9,RB:1.05,BODY:[1.15,0,-1.15],BODY_H:1.5,WHEEL_STEP:.6,BOUNCE:.3,ENTER_R:3,SPLAT_MIN:6,SPLAT_KILL:12,GUN_COOL:8,GUN_RANGE:90,GUN_AIM:50},Oi=[[-1.05,.18,.6],[1.05,.18,.6]],ki=[[-.45,-.35,.1],[.45,-.35,.1]],Ai=[1,1,-1,-1].map(e=>e*Q.A),ji=[-1,1,-1,1].map(e=>e*Q.B),Mi=Q.L0+Q.WR,Ni=Q.RB+e+.15,Pi=1,Fi=`x y z vx vy vz yaw pitch roll wy wp wr steer`.split(` `),$=1/60,Ii=Math.fround,{sin:Li,cos:Ri,min:zi,max:Bi,abs:Vi,sqrt:Hi}=Math,Ui=(e,t,n)=>zi(Bi(e,t),n),Wi=(e,t,n,r=0)=>{let[i,a]=F(e.yaw),[o,s]=[t*Ri(e.pitch),n*Ri(e.roll)];return[e.x+i*o-a*s,e.y+r+t*Li(e.pitch)-n*Li(e.roll),e.z+a*o+i*s]},Gi=(e,t)=>Ai.map((n,r)=>{let[i,a,o]=Wi(e,n,ji[r]);return[i,a,o,Mi+st(t,i,o,a-Q.L0+Q.WHEEL_STEP)-a]}),Ki=e=>Q.BODY.map(t=>Wi(e,t,0,-Mi)),qi=e=>{let[t,,n]=Ki(e);return{a:t,b:n,r:Q.RB,h:Q.BODY_H}},Ji=e=>(e.def.rovers??[]).map(([e,t,n,r])=>({x:Ii(e),y:Ii(t+Mi),z:Ii(n),vx:0,vy:0,vz:0,yaw:Ii(We(r)),pitch:0,roll:0,wy:0,wp:0,wr:0,steer:0,driver:255,rider:255})),Yi=(e,t,n,r=[])=>{let{A:i,B:a,CMAX:o,K:s,D:c,KP2:l,KR2:u,HC:d,MU:f,MUL:p,TILT:m}=Q,h=ht(n),g=t?t.keys:0,_=(g&T.FORWARD?1:0)-(g&T.BACK?1:0),v=g&T.JUMP,[y,b]=F(e.yaw),[x,ee]=[Ri(e.pitch),Ri(e.roll)],S=Gi(e,n),[te,C,ne,re]=S.map(([,e,,t])=>t+e-Mi),ie=S.some(e=>e[3]<-o),ae=ie?0:(te+C-ne-re)/(4*i*x),oe=ie?0:(C+re-te-ne)/(4*a*ee),w=1/Hi(ae*ae+oe*oe+1),se=-(ae*y-oe*b)*w,E=-(ae*b+oe*y)*w,D=()=>e.vx*se+e.vy*w+e.vz*E,O=Bi(0,...S.map(e=>e[3]-o));if(O){e.y+=O;let t=zi(0,D());e.vx-=t*se,e.vy-=t*w,e.vz-=t*E}let ce=D(),[k,A,le]=[0,0,0];S.forEach(([,,,t],n)=>{if(t>O){let r=Bi(0,s*(t-O)-c*(ce+(Ai[n]*x*e.wp-ji[n]*ee*e.wr)*w));k+=r,A+=r*Ai[n],le+=r*ji[n]}}),e.vx+=k*se*$,e.vy+=(k*w-h)*$,e.vz+=k*E*$,e.wp+=A/l*$,e.wr-=le/u*$;let ue=zi(k/h,2);if(ue>0){let n=e.vx*y+e.vz*b,r=e.vz*y-e.vx*b,a=t?We(t.yaw-e.yaw+Math.PI)-Math.PI:0,o=Ui(Q.SK*a/(1+Vi(n)/Q.SV),-Q.SMAX,Q.SMAX),s=Q.SRATE*$;e.steer+=Ui((n+_<0?-o:o)-e.steer,-s,s);let c=Ui(n*e.steer/(2*i),-Q.YMAX,Q.YMAX)*(v?Q.HBY:1);e.wy+=(c-e.wy)*Q.YRESP*$*zi(1,ue);let m=h*ue*$,g=Ui((_*n<0?_*Q.BRAKE:_*Q.ENGINE*Bi(0,1-Vi(n)/(_>0?Q.VMAX:Q.VREV)))*$,-p*m,p*m),x=(Q.ROLL+(v||!t?Q.HB:0))*ue*$;g-=Ui(n+g,-x,x);let ee=f*m*(v?Q.HBG:1),S=-Ui(r,-ee,ee);e.vx+=g*y-S*b,e.vz+=g*b+S*y,e.wp+=g*d/l,e.wr-=S*d/u}else e.wp-=(Q.AK*e.pitch+Q.AC*e.wp)*$,e.wr-=(Q.AK*e.roll+Q.AC*e.wr)*$;e.wp*=1-Q.AD*$,e.wr*=1-Q.AD*$,e.x+=e.vx*$,e.y+=e.vy*$,e.z+=e.vz*$,e.yaw=We(e.yaw+e.wy*$),e.pitch=Ui(e.pitch+e.wp*$,-m,m),e.roll=Ui(e.roll+e.wr*$,-m,m),Vi(e.pitch)===m&&e.pitch*e.wp>0&&(e.wp=0),Vi(e.roll)===m&&e.roll*e.wr>0&&(e.wr=0);for(let t of Q.BODY){let[r,i,a]=Wi(e,t,0,-Mi),[o,s]=rt({x:r,y:Bi(i,te,C,ne,re),z:a},n,Q.BODY_H,Q.RB),c=o*o+s*s;if(c){e.x+=o,e.z+=s;let t=zi(0,e.vx*o+e.vz*s)/c;e.vx-=t*o,e.vz-=t*s}}for(let t of r){if(t===e)continue;let n=qi(t);for(let r of Q.BODY){let[i,a,o]=Wi(e,r,0,-Mi),[s,c,l]=it(n,i,o),u=2*Q.RB,d=Hi(s*s+c*c);if(d>=u-1e-4||l>=a+Q.BODY_H||l+Q.BODY_H<=a)continue;let[f,p]=F(t.yaw),[m,h]=d?[s/d,c/d]:[-p,f];e.x+=m*(u-d),e.z+=h*(u-d);let g=zi(0,e.vx*m+e.vz*h)*(1+Q.BOUNCE);e.vx-=g*m,e.vz-=g*h}}ke(e,n);for(let t of Fi)e[t]=Ii(e[t]);return e.y<n.def.floor},Xi=(e,t,n)=>{let[r,i,a]=ki[n];[e.x,e.y,e.z]=Wi(t,a,r,i).map(Ii),e.vx=t.vx,e.vy=t.vy,e.vz=t.vz},Zi=(e,t,n)=>{t[n?`rider`:`driver`]=e.id,e.mode=O.RIDE,e.t=0,e.edge=0,e.ground=!1,e.dash=zi(e.dash,50),e.coyote=0,e.buffer=0,Xi(e,t,n)},Qi=(n,r,i,a)=>{r[i?`rider`:`driver`]=255,n.mode=O.AIR,n.t=0,n.coyote=0,[n.vx,n.vy,n.vz]=[r.vx,r.vy,r.vz];let o=i?Ni:-Ni;for(let[s,c]of[[o,-Mi],[-o,-Mi],[0,Q.BODY_H-Mi]]){let[o,l,u]=Wi(r,ki[i][2],s,c);Object.assign(n,{x:o,y:l,z:u}),ke(n,a);let d=st(a,n.x,n.z,r.y);n.y=Bi(l,d);let[f,p]=rt(n,a,t,e);if(!s||d>l-Pi&&!f&&!p)break}[n.x,n.y,n.z,n.vx,n.vz]=[n.x,n.y,n.z,n.vx,n.vz].map(Ii)},$i=(e,t,n,r,i,a=[])=>{let o=(n.keys&T.USE)!==0&&(e.held&T.USE)===0,s=Yi(t,n,r,a);return Xt(e,n,r,i,!1),e.mode===O.RIDE?(Xi(e,t,0),o&&Qi(e,t,0,r)):t.driver=255,s},ea=(e,t,n)=>{let[r,i,a,o]=[Math.sin(t),Math.cos(t),Math.sin(n),Math.cos(n)];return[e.x-r*o*Q.GUN_AIM,e.y+a*Q.GUN_AIM,e.z-i*o*Q.GUN_AIM]},ta=(e,t,n,r,i,a)=>{let[o,s]=F(e.yaw),c=ea(e,r,i);return Oi.map(([r,i,l],u)=>{let d=[e.x+o*l-s*r,e.y+i,e.z+s*l+o*r],f=c.map((e,t)=>e-d[t]),p=Math.sqrt(f[0]*f[0]+f[1]*f[1]+f[2]*f[2]);return{id:a+u&255,by:t,team:n,x:d[0],y:d[1],z:d[2],dx:f[0]/p,dy:f[1]/p,dz:f[2]/p,left:Q.GUN_RANGE,burst:!1,power:6}})},na=e=>e.mode===O.SLIDE||e.dash>50,ra=(e,t)=>Math.hypot(e.x-t.x,e.z-t.z)<1.1&&e.y<t.y+R(t)&&t.y<e.y+R(e),ia=20,aa=2,oa=30,sa=[`driver`,`rider`],ca=(e,t)=>Array.from(e).slice(0,t).join(``).trim(),la=e=>ca((typeof e==`string`?e:``).replace(/\s+/g,` `).replace(/\p{Cc}/gu,``).trim(),16),ua=(e,t)=>{let n=e;for(let r=2;t.includes(n);r++)n=`${ca(e,15-`${r}`.length)} ${r}`;return n},da=(e,t)=>Math.sqrt(e*e+t*t),fa=(e,t)=>{let n=setInterval(e,t);return()=>clearInterval(n)},pa={lock:0,foe:0,pushes:0,pressed:!1,away:0},ma=({x:e,y:t,z:n,yaw:r})=>({x:e,y:t,z:n,yaw:r}),ha=({x:e,y:t,z:n})=>({x:e,y:t,z:n}),ga=class{peers=/* @__PURE__ */ new Map;ticks=0;history=[];world;ctf;halt;rules;rr=[0,0];gone;balls=[];rovers;mapName;next;joins=0;constructor(e={},t){this.rules={...oe,...e},this.mapName=hi(this.rules.map),this.world=Ie(t??mi(this.mapName)),this.ctf=new Ht(this.world,this.rules),this.gone=this.spots(),this.rovers=Ji(this.world)}spots(){let{packs:e=[],ammo:t=[],cells:n=[]}=this.world.def;return[...e,...t,...n].map(()=>0)}host(){return this.players().reduce((e,t)=>e&&e.since<t.since?e:t,void 0)}load(){if(this.next!==void 0){this.mapName=this.next,this.next=void 0,this.world=Ie(mi(this.mapName)),this.ctf=new Ht(this.world,this.rules),this.gone=this.spots(),this.rovers=Ji(this.world),this.history=[],this.balls=[];for(let e of this.players())this.ctf.join(e.info.id,e.info.team,e.state);this.roster()}}get size(){return this.players().length}connect(e){this.peers.set(e,null)}receive(e,t){let n=this.peers.get(e);if(typeof t==`string`){let r=we(t);n===null&&r?.t===`join`?this.join(e,r.name,r.body):n&&r?.t===`map`&&n===this.host()&&Object.hasOwn(pi,r.map)?(this.next=r.map===this.mapName?void 0:r.map,this.roster()):n&&r?.t===`body`&&r.body===se.FEMALE!=!!n.info.body&&(r.body===se.FEMALE?n.info.body=se.FEMALE:delete n.info.body,this.roster());return}let r=n&&xe(t);if(r&&n.bank>0){n.bank--;let e=n.state.slow??0,t=(r.keys&T.USE)!==0&&(n.state.held&T.USE)===0,[i,a]=this.seatOf(n);if(i&&!a){let e=$i(n.state,i,r,this.world,n.info.team,this.rovers);this.ctf.moved(n.state),e?this.sink(i):(this.carry(i),this.splat(n,i,r.view),this.lase(n,i,r))}else{let e=Xt(n.state,r,this.world,n.info.team,!this.ctf.over,this.rovers.map(qi));this.ctf.moved(n.state),this.tackle(n,r.view);let a=ha(n.state),o=i&&e?this.past(r.view).find(e=>e.id===n.info.id):void 0;Object.assign(n.state,o&&ha(o)),e===B.SHOT?this.shoot(n,r.view):e===B.CUT?this.cut(n,r.view):e===B.RAIL?this.rail(n,r.view):e===B.LASER?this.shoot(n,r.view):e===B.NADE&&this.shoot(n,r.view,wi(n.state,n.info.team)),Object.assign(n.state,a),t&&i&&n.state.mode===O.RIDE?Qi(n.state,i,1,this.world):t&&this.enter(n)}n.burn=e?(n.burn??0)+1:0,e&&!(n.burn%60)&&this.fry(n),this.duel(n),n.ack=r.seq,this.seats()}}disconnect(e){let t=this.peers.get(e);this.peers.delete(e),t&&(this.ctf.leave(t.info.id),this.size||(this.ctf.reset(),this.gone.fill(0),this.rovers=Ji(this.world),this.load()),this.seats(),this.roster())}drop(e){let t=this.players().find(t=>t.info.id===e);return!!t&&this.ctf.drop(t.state)}tick(){let e=this.players();if(!e.length){this.balls=[];return}let t=++this.ticks;for(let t of e)t.bank=Math.min(10,t.bank+1);for(let e of this.balls)!e.burst&&e.left>0&&this.fly(e,xi(e));this.heal(e),Kt(this.world,e.filter(e=>!e.state.down).map(e=>[e.state.x,e.state.y,e.state.z]),this.rovers.filter(e=>e.driver!==255).map(e=>[e.x,e.y,e.z]));let n=this.ctf.tick(e.filter(e=>!e.state.down&&!this.rovers.some(t=>t.driver===e.info.id)).map(e=>({id:e.info.id,team:e.info.team,state:e.state})));n===`end`?this.end(e):n===`start`&&(this.load(),this.restart(e)),this.seats();for(let e of this.rovers)e.driver===255&&Yi(e,void 0,this.world,this.rovers)?this.sink(e):this.carry(e);if(this.seats(),t%2==0){for(this.history.push({tick:t,players:e.map(e=>({...e.state}))});this.history[0].tick<t-30;)this.history.shift();let n=Ce({tick:t,players:e.map(e=>({...e.state,ack:e.ack,by:e.state.stun?e.by:0})),...this.ctf.wire(),packs:this.gone.reduce((e,t,n)=>t?e:e+2**n,0),balls:this.balls,rovers:this.rovers,doors:this.world.doors?.map(e=>e.open)});e.forEach(e=>e.conn.send(n)),this.balls=this.balls.filter(e=>!e.burst&&e.left>0)}}start(e=fa){if(this.halt)return;let t=1e3/60,n=performance.now(),r=0;this.halt=e(()=>{let e=performance.now();r+=e-n,n=e;for(let e=0;r>=t&&e<ia;e++)this.tick(),r-=t;r%=t},t)}stop(){this.halt?.(),this.halt=void 0}rewind(e,t=0){return this.past(t).filter(t=>t.id!==e)}past(e=0){let t=this.players().map(e=>e.state),[n,r]=[this.history[0],this.history.at(-1)];if(!n||!r)return t;let i=((this.ticks-e+32768)%65536+65536)%65536-32768,a=Math.min(Math.max(this.ticks-i,n.tick),r.tick),o=0;for(;o+1<this.history.length&&this.history[o+1].tick<=a;)o++;let[s,c]=[this.history[o],this.history[o+1]??this.history[o]],l=c.tick>s.tick?(a-s.tick)/(c.tick-s.tick):0,u=(e,t)=>e+(t-e)*l;return t.map(e=>{let t=s.players.find(t=>t.id===e.id),n=c.players.find(t=>t.id===e.id);return t&&n?{...n,x:u(t.x,n.x),y:u(t.y,n.y),z:u(t.z,n.z)}:n??t??e})}tackle(e,t){let n=e.state;if(n.down||!na(n)||this.ticks-e.tackled<30)return;let r=this.players().filter(t=>t.info.team!==e.info.team),i=this.rewind(e.info.id,t).find(e=>ra(n,e)&&r.some(t=>t.info.id===e.id&&this.ctf.carrying(t.info.id)>=0)),a=r.find(e=>e.info.id===i?.id);if(!a||!this.drop(a.info.id))return;let o=$e(n),[s,c]=o>.001?[n.vx/o,n.vz/o]:F(n.yaw);vt(a.state,s,c),a.state.zap=!1,a.by=e.info.id,e.tackled=this.ticks}enemies(e,t){let n=this.players();return this.rewind(e.info.id,t).filter(t=>{let r=n.find(e=>e.info.id===t.id);return r&&r.info.team!==e.info.team&&!r.state.down&&!t.down})}harm(e,t){return(e.state.hp-=t)>0?!1:([e.graze,e.bruise,e.blows]=[0,0,0],e.state.mode===O.RIDE&&this.unseat(e),Object.assign(e.state,{hp:0,down:120,ammo:-1,cool:0,charge:0,mag:0,cap:0,reload:0,blade:!1,wield:!1,swing:0,lost:D.NONE,rail:-1,railed:!1,rifle:-1,clip:0,rifled:!1,nades:0,lob:0,zapping:!1,slow:0}),this.ctf.drop(e.state),!0)}shoot(e,t=0,n=yi(e.state,e.info.team)){let r=(this.ticks-t+65536)%65536;this.balls.push(n);let i=Math.min(r<32768?r:0,12);if(n.power===7)for(let e=0;e<i&&!n.burst;e++)this.fly(n,0);else this.fly(n,i*xi(n));let a=this.balls.filter(e=>!e.burst);a.length>64&&(a[0].burst=!0)}fly(e,t){let n=this.players(),r=n.filter(t=>t.info.team!==e.team&&!t.state.down);if(e.power===7){Ti(this.world,e,r.map(e=>e.state));let t=!1;for(let r of e.burst?n:[]){let n=r.info.id===e.by,i=!r.state.down&&(n||r.info.team!==e.team)?Ei(this.world,[e.x,e.y,e.z],r.state):0;i&&(this.harm(r,i),t||=!n)}let i=n.find(t=>t.info.id===e.by);t&&i&&(i.state.hits=i.state.hits+1&255);return}let i=Ci(this.world,e,t,r.map(e=>e.state)),a=r.find(e=>e.state===i);if(!a)return;let o=n.find(t=>t.info.id===e.by);if(o&&(o.state.hits=o.state.hits+1&255),e.power===0||e.power===6)a.graze=((a.graze??0)+1)%2,a.graze||this.harm(a,1);else if(!e.arc)this.harm(a,e.power??1);else if(this.harm(a,p[e.arc].hp)){let t=o&&{...o.state,cut:e.arc,yaw:Math.atan2(-e.dx,-e.dz)};a.state.lost=t?zt(Object.assign(t,{x:e.x-e.dx,y:e.y-e.dy-Nt*R(t),z:e.z-e.dz,pitch:Math.asin(e.dy)}),a.state):D.NONE}else{let t=Math.hypot(e.dx,e.dz)||1;vt(a.state,e.dx/t,e.dz/t,S,te),a.state.zap=!0,a.by=e.by,this.ctf.drop(a.state)}}cut(e,t){if(!e.state.blade){this.punch(e,t);return}if(e.state.cut===E.ARC_L||e.state.cut===E.ARC_R){this.shoot(e,t,bi(e.state,e.info.team));return}let n=It(this.world,e.state,this.enemies(e,t)),r=this.players().filter(e=>n.some(t=>t.id===e.info.id)),i=r.find(t=>Lt(e.state,{...t.state,...ma(n.find(e=>e.id===t.info.id))}));if(i){for(let[t,n]of[[e,i],[i,e]])Object.assign(t.state,{...pa,lock:240,foe:n.info.id,pressed:!0}),Object.assign(t.state,{swing:0,charge:0,stun:0,zap:!1,vx:0,vz:0});r=r.filter(e=>e!==i)}if(r.length){e.state.hits=e.state.hits+1&255;for(let t of r){let r=n.find(e=>e.id===t.info.id);if(this.harm(t,Ft(e.state).hp))t.state.lost=zt(e.state,r);else{let[n,r]=Rt(e.state);vt(t.state,n,r,24,4*(e.state.heavy?m:1)),t.state.zap=!0,t.by=e.info.id}}}}punch(e,t){let n=It(this.world,e.state,this.enemies(e,t),c),r=this.players().filter(e=>n.some(t=>t.id===e.info.id));if(r.length){e.state.hits=e.state.hits+1&255;for(let t of r)if(t.blows=(this.ticks-(t.punched??-1/0)<=d?t.blows??0:0)+1,t.punched=this.ticks,t.bruise=((t.bruise??0)+1)%l,(t.bruise||!this.harm(t,1))&&t.blows>=u){t.blows=0,this.drop(t.info.id);let[n,r]=F(e.state.yaw);vt(t.state,n,r),t.state.zap=!1,t.by=e.info.id}}}rail(e,t){let{hit:n}=Di(this.world,e.state,this.enemies(e,t)),r=this.players().find(e=>e.info.id===n?.id);if(r){let t=!r.state.slow;r.state.slow=180,t&&(e.state.hits=e.state.hits+1&255,r.burn=0,this.fry(r))}}fry(e){e.state.fried=this.harm(e,1)}duel(e){let t=e.state;if(!t.lock)return;let n=this.players().find(e=>e.info.id===t.foe);if(!n||n.state.foe!==e.info.id||!n.state.lock||n.state.down||t.down){Object.assign(t,pa);return}let r=(t.pushes??0)-(n.state.pushes??0),i=(t.away??0)>=24||(n.state.away??0)>=24;if(!(Math.abs(r)<8&&!i&&t.lock>1)){if(Object.assign(t,pa),Object.assign(n.state,pa),Math.abs(r)>=8){let[t,i]=r>0?[e,n]:[n,e];if(t.state.hits=t.state.hits+1&255,!this.harm(i,3)){let[e,n]=F(t.state.yaw);vt(i.state,e,n,24,4),i.state.zap=!0,i.by=t.info.id}}else if(!i){let[e,r]=[n.state.x-t.x,n.state.z-t.z],i=Math.hypot(e,r)||1;vt(t,-e/i,-r/i),vt(n.state,e/i,r/i)}}}heal(e){let{packs:t=[],ammo:n=[],cells:r=[]}=this.world.def;[...t,...n,...r].forEach((r,i)=>{if(this.gone[i]>0){this.gone[i]--;return}let a=+(i>=t.length)+ +(i>=t.length+n.length),o=e=>[e.hp<5,e.ammo>=0&&e.ammo<60||(e.rifle??-1)>=0&&e.rifle<240,(e.rail??-1)>=0&&e.rail<240][a],s=e.find(({state:e})=>!e.down&&o(e)&&Jt(e,r,.9));if(s){let e=s.state;a==0?e.hp=Math.min(5,e.hp+2):a==1?(e.ammo=e.ammo<0?-1:Math.min(60,e.ammo+20),e.rifle=(e.rifle??-1)<0?-1:Math.min(240,e.rifle+60)):e.rail=Math.min(240,e.rail+80),this.gone[i]=(a==1?10:20)*60}})}seatOf(e){if(e.state.mode===O.RIDE)for(let t of this.rovers){let n=sa.findIndex(n=>t[n]===e.info.id);if(n>=0)return[t,n]}return[]}unseat(e){for(let t of this.rovers)sa.forEach(n=>t[n]=t[n]===e.info.id?255:t[n]);Object.assign(e.state,{mode:O.AIR,t:0,coyote:0})}seats(){let e=this.players();for(let t of this.rovers)for(let n of sa)e.some(e=>e.info.id===t[n]&&e.state.mode===O.RIDE)||(t[n]=255);for(let t of e)t.state.mode===O.RIDE&&!this.seatOf(t).length&&this.unseat(t)}enter(e){let t=e.state;if(t.down||t.stun||t.lock||t.mode===O.RIDE)return;let n=this.ctf.carrying(e.info.id)>=0,r=e=>Math.abs(e.y-t.y)>Q.ENTER_R?1/0:(e.x-t.x)**2+(e.z-t.z)**2,i=e=>e.driver===255&&!n?0:e.rider===255?1:-1,a=this.rovers.filter(e=>r(e)<=Q.ENTER_R**2&&i(e)>=0).sort((e,t)=>r(e)-r(t))[0];a&&Zi(t,a,i(a))}carry(e){let t=this.players().find(t=>t.info.id===e.rider);if(t?.state.mode===O.RIDE){Xi(t.state,e,1);let n=st(this.world,e.x,e.z,e.y);n>this.world.def.floor&&this.ctf.place(t.info.id,{...t.state,y:n})}}sink(e){for(let t of this.players())this.seatOf(t)[0]===e&&(Xe(t.state,this.world,t.info.team),this.ctf.moved(t.state));let t=this.rovers.indexOf(e);Object.assign(e,Ji(this.world)[t])}lase(e,t,n){if(e.gun=Math.max(0,(e.gun??0)-1),!(!(n.keys&T.FIRE)||e.gun||this.ctf.over||e.state.mode!==O.RIDE)){e.gun=Q.GUN_COOL,e.bolt=(e.bolt??0)+2&255;for(let r of ta(t,e.info.id,e.info.team,n.yaw,n.pitch,e.bolt))this.shoot(e,n.view,r)}}splat(e,t,n){if(da(t.vx,t.vz)<Q.SPLAT_MIN)return;let r=Ki(t);for(let i of this.enemies(e,n)){let n=this.players().find(e=>e.info.id===i.id);if(!n||n.state.mode===O.RIDE||this.ticks-n.run<oa||!r.find(([e,t,n])=>da(i.x-e,i.z-n)<Q.RB+.4&&i.y<t+Q.BODY_H&&i.y+R(i)>t))continue;let[a,o]=[i.x-t.x,i.z-t.z],s=da(a,o)||1,c=((t.vx-i.vx)*a+(t.vz-i.vz)*o)/s;if(!(c<Q.SPLAT_MIN)&&(n.run=this.ticks,e.state.hits=e.state.hits+1&255,!this.harm(n,c<Q.SPLAT_KILL?1:n.state.hp))){let r=da(t.vx,t.vz);vt(n.state,t.vx/r,t.vz/r),n.state.zap=!1,n.by=e.info.id}}}place(e,t,n){let r=this.world.def.teams[t].spawns.findIndex((r,i)=>{let{x:a,z:o}=Ye(e,this.world,i,t);return!n.some(e=>Math.hypot(e.x-a,e.z-o)<aa)});return Ye(e,this.world,r<0?this.rr[t]++:r,t)}end(e){let t=this.ctf.tally().flatMap(t=>{let n=e.find(e=>e.info.id===t.id)?.info;return n?[{...t,name:n.name,team:n.team}]:[]}),n=JSON.stringify({t:`end`,score:this.ctf.score,players:t});e.forEach(e=>e.conn.send(n))}restart(e){let t=[];this.rr=[0,0],this.gone.fill(0),this.rovers=Ji(this.world),qt(this.world);for(let n of e){let{shots:e,hits:r}=n.state;n.state={...this.place(n.info.id,n.info.team,t),shots:e,hits:r},t.push(n.state),this.ctf.place(n.info.id,n.state)}}players(){return[...this.peers.values()].filter(e=>e!==null)}join(e,t,n){let r=this.players();if(r.length>=this.rules.maxPlayers){e.send(JSON.stringify({t:`full`}));return}let i=0;for(;r.some(e=>e.info.id===i);)i++;let a=r.filter(e=>e.info.team===0).length,o=+(a>r.length-a),c={conn:e,info:{id:i,name:ua(la(t)||`Player ${i}`,r.map(e=>e.info.name)),team:o,color:s[o],...n===se.FEMALE?{body:n}:{}},state:this.place(i,o,r.map(e=>e.state)),since:this.joins++,bank:10,ack:65535,by:0,tackled:-30,run:-oa};this.peers.set(e,c),this.ctf.join(i,o,c.state),this.roster()}roster(){let e=this.players(),t=e.map(e=>e.info).sort((e,t)=>e.id-t.id);e.forEach(e=>e.conn.send(JSON.stringify({t:`roster`,you:e.info.id,players:t,map:this.mapName,host:this.host()?.info.id,next:this.next})))}},_a=(e,t)=>{let n=()=>{},r=()=>{n();let r=setInterval(e,t);n=()=>clearInterval(r)};try{let i=URL.createObjectURL(new Blob([`setInterval(()=>postMessage(0),${t})`])),a=new Worker(i);a.onmessage=e,a.onerror=r,n=()=>{a.terminate(),URL.revokeObjectURL(i)}}catch{r()}return()=>n()},va=(e,t)=>{let n=`tiny-fps:`+e,r=Math.random().toString(36).slice(2),i=new BroadcastChannel(n),a=new AbortController,o=globalThis.navigator?.locks,s,c,l,u,d=[],f,p=!1,m=e=>i.postMessage({from:r,...e}),h=e=>!p&&x.onmessage?.({data:e}),g={send:e=>queueMicrotask(()=>h(e))},_=()=>{let e=d.length?d:f?[f]:[];return d=[],e},v=e=>{if(p)return e();l=e,u=r,c=/* @__PURE__ */ new Map,s=new ga(t),s.start(_a),s.connect(g),_().forEach(e=>s.receive(g,e)),m({kind:`h`})};i.onmessage=({data:e})=>{if(!p){if(s&&c){let{from:t,kind:n}=e,r=c.get(t);n===`q`?m({to:t,kind:`h`}):n===`m`&&!e.to?(r||(r={send:e=>!p&&m({to:t,kind:`m`,data:e})},c.set(t,r),s.connect(r)),s.receive(r,e.data)):n===`b`&&r&&(c.delete(t),s.disconnect(r))}else e.to!==r&&e.to||(e.kind===`m`&&e.to?h(e.data):e.kind===`h`&&e.from!==u&&(u=e.from,_().forEach(e=>m({kind:`m`,data:e}))))}};let y=e=>{if(p)return;let t=typeof e==`string`?we(e):null;t?.t===`join`?f=e:t?.t===`body`&&f&&(f=JSON.stringify({...we(f),body:t.body})),s?s.receive(g,e):u?m({kind:`m`,data:e}):d.push(e)},b=()=>{p||(p=!0,globalThis.removeEventListener?.(`pagehide`,b),s?(s.stop(),l()):(m({kind:`b`}),a.abort()),i.close(),setTimeout(()=>x.onclose?.()))},x={binaryType:`arraybuffer`,onopen:null,onclose:null,onmessage:null,send:y,close:b};return o?o.request(n,{signal:a.signal},()=>new Promise(v)).catch(()=>{}):v(()=>{}),m({kind:`q`}),globalThis.addEventListener?.(`pagehide`,b),setTimeout(()=>!p&&x.onopen?.()),x};export{va as localSocket};
package/dist/server.js CHANGED
@@ -513,15 +513,15 @@ var build = (def, cell = CELL) => {
513
513
  else grid.set(k, [i]);
514
514
  }
515
515
  });
516
- return def.relief ? {
516
+ return {
517
517
  def,
518
518
  cell,
519
519
  grid,
520
- relief: raise(def.relief)
521
- } : {
522
- def,
523
- cell,
524
- grid
520
+ ...def.relief ? { relief: raise(def.relief) } : {},
521
+ ...def.doors ? { doors: def.doors.map(() => ({
522
+ open: 0,
523
+ wait: 0
524
+ })) } : {}
525
525
  };
526
526
  };
527
527
  /**
@@ -541,7 +541,19 @@ var near = (w, x, z, r) => {
541
541
  * (its corners square, and a brush is only found in the cells the ray crosses).
542
542
  */
543
543
  var ray = (w, o, d, max, grow = 0) => {
544
- const hit = faces(w, o, d, max, grow);
544
+ let hit = faces(w, o, d, max, grow);
545
+ w.doors?.forEach(({ open }, i) => {
546
+ if (open < .5) {
547
+ const { min, max } = w.def.doors[i];
548
+ let [lo, hi] = [0, hit];
549
+ for (let a = 0; a < 3; a++) {
550
+ const [t0, t1] = d[a] ? [(min[a] - grow - o[a]) / d[a], (max[a] + grow - o[a]) / d[a]] : o[a] < min[a] - grow || o[a] > max[a] + grow ? [1, -1] : [-Infinity, Infinity];
551
+ lo = Math.max(lo, Math.min(t0, t1));
552
+ hi = Math.min(hi, Math.max(t0, t1));
553
+ }
554
+ if (lo <= hi && hi > 0) hit = lo;
555
+ }
556
+ });
545
557
  return w.relief ? trace(w, o, d, hit, grow) : hit;
546
558
  };
547
559
  /**
@@ -1739,6 +1751,40 @@ var Ctf = class {
1739
1751
  };
1740
1752
  /** Whether the player's body reaches the flag foot at `at`: close enough, and overlapping its height. */
1741
1753
  var touches = (p, at) => Math.hypot(p.x - at[0], p.z - at[2]) < 1.5 && p.y < at[1] + 2.2 && p.y + 1.8 > at[1];
1754
+ // src/shared/doors.ts
1755
+ var DOOR = {
1756
+ /**
1757
+ * Metres from the doorway within which a player on foot opens it, and a driven rover. A dash
1758
+ * from 7 m is there in 0.65 s (2.7 m of burst at 16 m/s, the rest at a sprint's 9), a rover at
1759
+ * its 23.2 m/s from 14 m in 0.6 s: the door has been open 0.3 s and 0.25 s by then.
1760
+ */
1761
+ R: 7,
1762
+ ROVER_R: 14,
1763
+ /** Ticks it takes to open (0.35 s) and to shut (0.5 s). */
1764
+ OPEN: 21,
1765
+ SHUT: 30,
1766
+ /** Ticks it stays open after the last one has left: a second. */
1767
+ HOLD: 60
1768
+ };
1769
+ /** How far `p` is from the doorway on the floor plane, Infinity when its feet are not at its height. */
1770
+ var off = ({ min, max }, [x, y, z]) => y < min[1] - 1 || y >= max[1] ? Infinity : Math.sqrt((x - Math.min(Math.max(x, min[0]), max[0])) ** 2 + (z - Math.min(Math.max(z, min[2]), max[2])) ** 2);
1771
+ /**
1772
+ * One tick of the doors of `w`: each opens while one of `feet` (the players who are up) is within
1773
+ * DOOR.R of it or one of `rovers` (the driven ones) within DOOR.ROVER_R, stays open DOOR.HOLD ticks
1774
+ * after the last, then shuts.
1775
+ */
1776
+ var swing = (w, feet, rovers = []) => w.doors?.forEach((s, i) => {
1777
+ const d = w.def.doors[i];
1778
+ const near = feet.some((p) => off(d, p) < DOOR.R) || rovers.some((p) => off(d, p) < DOOR.ROVER_R);
1779
+ const all = DOOR.OPEN * DOOR.SHUT;
1780
+ const at = Math.round(s.open * all) + (near || s.wait ? DOOR.SHUT : -DOOR.OPEN);
1781
+ s.open = Math.min(all, Math.max(0, at)) / all;
1782
+ s.wait = near ? DOOR.HOLD : Math.max(0, s.wait - 1);
1783
+ });
1784
+ /** Every door shut: a new match. */
1785
+ var shut = (w) => w.doors?.forEach((s) => {
1786
+ s.open = s.wait = 0;
1787
+ });
1742
1788
  // src/shared/gun.ts
1743
1789
  /** Whether the feet of `p` are within `r` of the point `at` on the floor plane and within PICK_H of its height. */
1744
1790
  var within = (p, at, r) => {
@@ -2805,6 +2851,8 @@ var CELLS = [
2805
2851
  var HIGHLINE = {
2806
2852
  armor: true,
2807
2853
  name: "Highline",
2854
+ tag: "Rooftops · 94 × 240 m",
2855
+ lore: "The towers of an old business district, closed for years, far above streets that still have traffic. Two crews of runners have taken the roofs. Three routes cross between them, and a fall takes you back to your tower.",
2808
2856
  brushes: [
2809
2857
  ...half$1,
2810
2858
  ...half$1.map(flip$1),
@@ -3024,6 +3072,15 @@ var MOUTHS = [[
3024
3072
  3.5,
3025
3073
  2
3026
3074
  ]];
3075
+ /**
3076
+ * The automatic doors of red's half (doors.ts), each the box its panels fill when shut: in the
3077
+ * middle of the dome's door, then in the wall of each module's airlock.
3078
+ */
3079
+ var DOORS = [
3080
+ bx(DOME[0] - MOUTHS[0][2], 0, DOME[1] - C0 - 1.55, DOME[0] + MOUTHS[0][2], MOUTHS[0][3], DOME[1] - C0 - 1.25),
3081
+ bx(116.8, 0, MODULES[0].max[2] - .3, 119.2, H, MODULES[0].max[2] - .1),
3082
+ bx(101.8, 0, MODULES[1].min[2] + .1, 104.2, H, MODULES[1].min[2] + .3)
3083
+ ];
3027
3084
  /** The rectangles (x0, z0, x1, z1), their mirrors and their quarter turns about the centre, each once. */
3028
3085
  var turns = (l) => [...new Map(l.flatMap(([x0, z0, x1, z1]) => [1, -1].flatMap((i) => [1, -1].flatMap((j) => [[
3029
3086
  x0,
@@ -4319,6 +4376,8 @@ var MAPS = {
4319
4376
  highline: HIGHLINE,
4320
4377
  tranquility: {
4321
4378
  name: "Tranquility",
4379
+ tag: "Moon · half gravity",
4380
+ lore: "A mining base left in a lunar crater, its domes still lit. Two crews fight for it in space helmets, under the Earth and a black sky. Jumps float twice as high, and a rille cuts the base in two.",
4322
4381
  brushes: [
4323
4382
  ...half,
4324
4383
  ...half.map(flip),
@@ -4479,6 +4538,7 @@ var MAPS = {
4479
4538
  Math.PI
4480
4539
  ]
4481
4540
  ],
4541
+ doors: [...DOORS, ...DOORS.map(mirror)],
4482
4542
  scenery: "moon",
4483
4543
  helmets: true,
4484
4544
  armor: true
@@ -4709,7 +4769,9 @@ var encodeSnapshot = (s) => {
4709
4769
  const end = mid + 54 * rovers.length;
4710
4770
  const balls = s.balls ?? [];
4711
4771
  const tail = end + 10 + s.flags.reduce((n, f) => n + flagBytes(f.state), 0);
4712
- const v = new DataView(new ArrayBuffer(tail + (balls.length && 1 + 11 * balls.length)));
4772
+ const doors = s.doors ?? [];
4773
+ const gate = doors.length && 1 + Math.ceil(doors.length / 2);
4774
+ const v = new DataView(new ArrayBuffer(tail + (balls.length || gate ? 1 + 11 * balls.length : 0) + gate));
4713
4775
  v.setUint8(0, 2);
4714
4776
  v.setUint16(1, s.tick & 65535);
4715
4777
  v.setUint8(3, s.players.length | rovers.length << 5);
@@ -4778,7 +4840,7 @@ var encodeSnapshot = (s) => {
4778
4840
  }
4779
4841
  o += flagBytes(f.state);
4780
4842
  }
4781
- if (balls.length) v.setUint8(o++, balls.length);
4843
+ if (balls.length || gate) v.setUint8(o++, balls.length);
4782
4844
  for (const b of balls) {
4783
4845
  v.setUint8(o, b.id);
4784
4846
  v.setUint8(o + 1, b.by & 127 | (b.burst ? 128 : 0));
@@ -4792,6 +4854,13 @@ var encodeSnapshot = (s) => {
4792
4854
  v.setUint8(o + 10, b.arc ? 128 | b.arc : b.power === 7 ? 64 | Math.min(63, Math.round(b.v)) : b.power ?? 1);
4793
4855
  o += 11;
4794
4856
  }
4857
+ if (gate) {
4858
+ v.setUint8(o++, doors.length);
4859
+ doors.forEach((d, k) => {
4860
+ const at = o + (k >> 1);
4861
+ v.setUint8(at, v.getUint8(at) | Math.round(d * 15) << (k & 1 ? 0 : 4));
4862
+ });
4863
+ }
4795
4864
  return v.buffer;
4796
4865
  };
4797
4866
  /** Returns null on anything that is not a known text message. */
@@ -5424,6 +5493,10 @@ var Room = class {
5424
5493
  else if (p && msg?.t === "map" && p === this.host() && Object.hasOwn(MAPS, msg.map)) {
5425
5494
  this.next = msg.map === this.mapName ? void 0 : msg.map;
5426
5495
  this.roster();
5496
+ } else if (p && msg?.t === "body" && msg.body === BODY.FEMALE !== !!p.info.body) {
5497
+ if (msg.body === BODY.FEMALE) p.info.body = BODY.FEMALE;
5498
+ else delete p.info.body;
5499
+ this.roster();
5427
5500
  }
5428
5501
  return;
5429
5502
  }
@@ -5500,6 +5573,15 @@ var Room = class {
5500
5573
  for (const p of players) p.bank = Math.min(10, p.bank + 1);
5501
5574
  for (const b of this.balls) if (!b.burst && b.left > 0) this.fly(b, stepOf(b));
5502
5575
  this.heal(players);
5576
+ swing(this.world, players.filter((p) => !p.state.down).map((p) => [
5577
+ p.state.x,
5578
+ p.state.y,
5579
+ p.state.z
5580
+ ]), this.rovers.filter((r) => r.driver !== 255).map((r) => [
5581
+ r.x,
5582
+ r.y,
5583
+ r.z
5584
+ ]));
5503
5585
  const turn = this.ctf.tick(players.filter((p) => !p.state.down && !this.rovers.some((r) => r.driver === p.info.id)).map((p) => ({
5504
5586
  id: p.info.id,
5505
5587
  team: p.info.team,
@@ -5531,7 +5613,8 @@ var Room = class {
5531
5613
  ...this.ctf.wire(),
5532
5614
  packs: this.gone.reduce((m, t, k) => t ? m : m + 2 ** k, 0),
5533
5615
  balls: this.balls,
5534
- rovers: this.rovers
5616
+ rovers: this.rovers,
5617
+ doors: this.world.doors?.map((d) => d.open)
5535
5618
  });
5536
5619
  players.forEach((p) => p.conn.send(snap));
5537
5620
  this.balls = this.balls.filter((b) => !b.burst && b.left > 0);
@@ -6047,6 +6130,7 @@ var Room = class {
6047
6130
  this.rr = [0, 0];
6048
6131
  this.gone.fill(0);
6049
6132
  this.rovers = park(this.world);
6133
+ shut(this.world);
6050
6134
  for (const p of players) {
6051
6135
  const { shots, hits } = p.state;
6052
6136
  p.state = {
@@ -0,0 +1,25 @@
1
+ import type { Door, World } from '../shared/world';
2
+ import type { Vec3 } from './mesh';
3
+ /** The strip of light: shut, then opening or open. */
4
+ export declare const LIGHT: number[][];
5
+ /**
6
+ * The vertices of the door `d`, `open` from 0 to 1: a frame just inside the doorway (two posts and
7
+ * a header, proud of the panels on both faces), and the two panels, each slid `open` of its width
8
+ * into the wall beside it.
9
+ */
10
+ export declare const panels: (o: number[], { min, max }: Door, open: number) => void;
11
+ export interface Doors {
12
+ /**
13
+ * The doors of a snapshot (Snapshot.doors): kept for the drawing and for the world's ray(), so an
14
+ * own shot stops where the host's does. Returns the sounds of those that start to move.
15
+ */
16
+ snapshot(open?: number[]): {
17
+ id: number;
18
+ at: Vec3;
19
+ }[];
20
+ /** The doors near `eye`, `dt` seconds after the last frame: each follows its snapshot's state. */
21
+ draw(o: number[], eye: Vec3, dt: number): void;
22
+ /** How far each is drawn open. */
23
+ shown(): number[];
24
+ }
25
+ export declare const createDoors: (world: World) => Doors;
@@ -2,6 +2,19 @@ import type { Result } from '../shared/protocol';
2
2
  import type { PlayerState, Rover, Snapshot } from '../shared/types';
3
3
  import type { Mark } from './marks';
4
4
  export declare const HUD_CSS: string;
5
+ /** The tabs of the title screen's menu, the first one shown first. */
6
+ export declare const TABS: string[];
7
+ /** The characters' first names (the user, 2026-11-11: names, not "man" and "woman"), in BODY's order, and the size of a card's picture in pixels. */
8
+ export declare const CAST: string[];
9
+ export declare const SHOT: number[];
10
+ /** Capture the flag in a few lines, with the room's default rules. */
11
+ export declare const GOAL: string[];
12
+ /**
13
+ * The controls of the title screen, a group each: the caps of a row split by `|` (a `+`, `/`, `or`
14
+ * or `twice` between them stays text), what they do, and the KeyboardEvent.codes the row tells,
15
+ * which together must be all of input.ts's CODES.
16
+ */
17
+ export declare const CONTROLS: [group: string, rows: [keys: string, does: string, codes?: string][]][];
5
18
  /** Seconds the way out is shown after sitting down. */
6
19
  export declare const OUT_HINT = 4;
7
20
  /**
@@ -18,10 +31,18 @@ export interface Summary {
18
31
  players: Result[];
19
32
  }
20
33
  export interface Hud {
21
- /** The title screen with `status` under the controls, "Click to play" or why not; '' hides it. */
22
- title(status: string, name: string): void;
23
34
  /**
24
- * The maps over the title screen, [key, name] each: the one the next match plays (`next`, else
35
+ * The title screen with `status` on its button, "Click to play" or why not; '' hides it. `name`,
36
+ * `tag` and `lore` are the map's (WorldDef).
37
+ */
38
+ title(status: string, name: string, tag?: string, lore?: string): void;
39
+ /**
40
+ * The character cards of the title screen: `pick` is told the BODY of the card the player
41
+ * chooses. Returns the cards' canvases, in BODY's order, for their pictures (SHOT pixels).
42
+ */
43
+ cast(pick: (body: number) => void): HTMLCanvasElement[];
44
+ /**
45
+ * The maps in the title screen's Game panel, [key, name] each: the one the next match plays (`next`, else
25
46
  * `played`) stands out. They are buttons that `pick` when the own player is the host (`mine`),
26
47
  * read-only for the others; `host` is his name.
27
48
  */
@@ -55,7 +76,7 @@ export interface Hud {
55
76
  hit(): void;
56
77
  /** The face over the health, frame `n` of face.ts (-1 hides it). */
57
78
  face(n: number): void;
58
- /** The own player's character (BODY): the face is hers when she is the woman. */
79
+ /** The own player's character (BODY): the face is hers when she is the woman, and her card is the chosen one. */
59
80
  wear(body: number): void;
60
81
  /**
61
82
  * A saber lock: the gauge of the tug of war under the crosshair, with `lead` the own side's, -1
@@ -81,5 +102,8 @@ export declare const BANNER_MS = 2800;
81
102
  export declare const HIT_MS = 140;
82
103
  /** m:ss. */
83
104
  export declare const clock: (s: number) => string;
84
- /** Appends the HUD to `screen`, whose stylesheet has HUD_CSS. */
85
- export declare const createHud: (screen: HTMLElement) => Hud;
105
+ /**
106
+ * Appends the HUD to `screen`, whose stylesheet has HUD_CSS. `play` is the title screen's button:
107
+ * the click that starts the game (the panel takes its other clicks, the view round it plays too).
108
+ */
109
+ export declare const createHud: (screen: HTMLElement, play?: () => void) => Hud;