@korial29/tiny-fps 0.56.0 → 0.56.2

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={HOME:0,CARRIED:1,DROPPED:2},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},n={THRUST:0,LEFT:1,RIGHT:2,SLASH:3,LUNGE:4,SPIN_L:5,SPIN_R:6,LEAP:7},r={NONE:0,HEAD:1,ARM_L:2,ARM_R:3,LEG_L:4,LEG_R:5},i={GROUND:0,AIR:1,WALLRUN:2,HANG:3,CLIMB:4,SLIDE:5,CROUCH:6},a={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},s={BRICK:0,TILE:1,LAVA:2,STONE:3,METAL:4,WOOD:5,MOSS:6,GRATE:7,CONCRETE:8,GLASS:9,STEEL:10,PAINT:11},c=127,l=16,u=32,d=128/Math.PI,f=254/Math.PI,p=65536/(2*Math.PI),m=e=>Math.round(e*p)&65535,h=e=>Math.max(-32768,Math.min(32767,Math.round(e))),g=e=>h(e*1e4),_=e=>e/1e4,v=e=>e/p,y=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)&16383,yaw:v(t.getUint16(5)),pitch:_(t.getInt16(7)),view:(t.getUint16(9)*256+t.getUint8(11))/256}:null},b=t=>t===e.CARRIED?2:t===e.DROPPED?8:1,x=n=>{let r=4+60*n.players.length,i=n.balls??[],a=r+10+n.flags.reduce((e,t)=>e+b(t.state),0),o=new DataView(new ArrayBuffer(a+(i.length&&1+11*i.length)));o.setUint8(0,2),o.setUint16(1,n.tick&65535),o.setUint8(3,n.players.length),n.players.forEach((e,n)=>{let r=4+n*60;o.setUint8(r,e.id),o.setFloat32(r+1,e.x),o.setFloat32(r+5,e.y),o.setFloat32(r+9,e.z),o.setFloat32(r+13,e.vx),o.setFloat32(r+17,e.vy),o.setFloat32(r+21,e.vz),o.setFloat32(r+25,e.edge),o.setUint16(r+29,m(e.yaw)),o.setInt16(r+31,g(e.pitch)),o.setUint16(r+33,e.ack&65535),o.setUint8(r+35,e.mode&7|(e.wall&7)<<3|(e.jumps&1)<<6|e.dashes<<7),o.setUint8(r+36,e.t),o.setUint8(r+37,e.dash|(e.by>>2&3)<<6),o.setUint8(r+38,e.coyote&7|(e.buffer&7)<<3|(e.held&t.JUMP?64:0)|(e.held&t.DASH?128:0)),o.setUint8(r+39,e.stun|(e.by&3)<<6);let i=e.hp|e.cool<<3|(e.ammo<0?c:e.ammo)<<6|e.down<<13|!!e.rack<<20|!!e.blade<<21|!!e.wield<<22|!!e.zap<<23;o.setUint8(r+40,i>>16),o.setUint16(r+41,i&65535),o.setUint8(r+43,e.shots),o.setUint8(r+44,e.hits),o.setUint8(r+45,(e.swing??0)&63|((e.cut??0)&3)<<6),o.setUint8(r+46,(e.lost??0)&7|((e.cut??0)&4)<<1|(e.fried?16:0)|(e.heavy?32:0)),o.setUint8(r+47,e.charge??0),o.setUint8(r+48,e.lock??0),o.setUint8(r+49,(e.foe??0)&15|(e.pressed?128:0)),o.setUint8(r+50,e.pushes??0),o.setUint8(r+51,e.away??0),o.setUint8(r+52,(e.rail??-1)+1),o.setUint8(r+53,+!!e.railed|!!e.inRail<<1|!!e.zapping<<2|!!e.rifled<<3|!!e.inRifle<<4),o.setUint8(r+54,e.slow??0),o.setUint8(r+55,e.mag??0),o.setUint8(r+56,e.cap??0),o.setUint8(r+57,e.reload??0),o.setUint8(r+58,(e.rifle??-1)+1),o.setUint8(r+59,e.clip??0)}),o.setUint8(r,n.score[0]),o.setUint8(r+1,n.score[1]),o.setUint16(r+2,n.clock&32767|(n.over?32768:0));let s=n.packs??0;o.setUint16(r+4,Math.floor(s/2**32)),o.setUint32(r+6,s%2**32);let p=r+10;for(let t of n.flags)o.setUint8(p,t.state),t.state===e.CARRIED?o.setUint8(p+1,t.by):t.state===e.DROPPED&&(o.setInt16(p+1,h(t.x*l)),o.setInt16(p+3,h(t.y*l)),o.setInt16(p+5,h(t.z*l)),o.setUint8(p+7,Math.min(255,t.left))),p+=b(t.state);i.length&&o.setUint8(p++,i.length);for(let e of i)o.setUint8(p,e.id),o.setUint8(p+1,e.by&127|(e.burst?128:0)),[e.x,e.y,e.z].forEach((e,t)=>o.setInt16(p+2+2*t,h(e*u))),o.setUint8(p+8,Math.round(Math.atan2(-e.dx,-e.dz)*d)&255),o.setInt8(p+9,Math.round(Math.asin(Math.max(-1,Math.min(1,e.dy)))*f)),o.setUint8(p+10,e.power??1),p+=11;return o.buffer},S=e=>{try{let t=JSON.parse(e);return t&&typeof t.t==`string`?t:null}catch{return null}},C=.4,w=1.8,ee=1.6,te=1.55,T=.9,ne=.7,re=7.5,ie=1.5,ae=.15,oe=.5,se=.9,ce=6.5,le=.2,ue=.03,de=.2,fe=5.5,pe=2.5,me=[`#ff3d4f`,`#2f80ff`],he=.12,ge=[{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:48,strike:24,reach:2.3,arc:Math.PI,hp:3,hold:-1},{ticks:48,strike:24,reach:2.3,arc:Math.PI,hp:3,hold:-1},{ticks:58,strike:40,reach:2.4,arc:.6,hp:4,hold:-1}],[_e,ve,ye]=[1.8,15,60],[be,xe,Se]=[2,.5,1.4],Ce=7.5,[we,Te,Ee]=[.82,.45,.12],De=.012,Oe={maxPlayers:16,scoreLimit:3,timeLimit:480},ke=4,E=1024,Ae=(e,t)=>(e+E)*(2*E)+t+E,D=(e,t)=>Math.min(Math.max(Math.floor(e/t),-1024),1023),je=(e,t=ke)=>{let n=/* @__PURE__ */ new Map;return e.brushes.forEach(({min:e,max:r},i)=>{for(let a=D(e[0],t);a<=D(r[0],t);a++)for(let o=D(e[2],t);o<=D(r[2],t);o++){let e=Ae(a,o),t=n.get(e);t?t.push(i):n.set(e,[i])}}),{def:e,cell:t,grid:n}},O=(e,t,n,r)=>{let i=[];for(let a=D(t-r,e.cell);a<=D(t+r,e.cell);a++)for(let t=D(n-r,e.cell);t<=D(n+r,e.cell);t++)for(let n of e.grid.get(Ae(a,t))??[])i.includes(n)||i.push(n);return i},k=(e,t,n,r,i=0)=>{let{cell:a,def:o}=e,s=r,c=D(t[0],a),l=D(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(Ae(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)>E||Math.abs(l)>E)return s;m<h?(c+=u,m+=g):(l+=d,h+=_)}},Me=(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&&k(e,t,[r/o,i/o,a/o],o)<o-1e-4},A=1/60,Ne=Math.PI*2,j=1e-6,M=.01,Pe=.001,Fe=e=>(e%Ne+Ne)%Ne,N=e=>[-Math.sin(e),-Math.cos(e)],P=Math.fround,Ie=Math.sqrt,F=(e,t,n)=>Math.min(Math.max(e,t),n),I=(e,t)=>Ie(e*e+t*t),L=[[0,0],[1,0],[-1,0],[0,1],[0,-1]],Le={vx:0,vz:0,mode:i.GROUND,t:0,wall:a.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:r.NONE,rail:-1,railed:!1,rifle:-1,clip:0,rifled:!1,inRifle:!1,inRail:!1,zapping:!1,slow:0,fried:!1,heavy:!1,ev:0,fall:0},Re=(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:P(a),y:P(o),z:P(s),vy:0,yaw:Fe(c),pitch:0,ground:!0,...Le}},ze=(e,t,n)=>{let{yaw:r,pitch:i,id:a,shots:s,hits:c}=e;Object.assign(e,Re(a,t,a,n),{yaw:r,pitch:i,shots:s,hits:c,ev:e.ev|o.RESPAWN})},R=e=>e===i.GROUND||e===i.SLIDE||e===i.CROUCH,z=e=>e.mode===i.SLIDE||e.mode===i.CROUCH?T:w,Be=e=>e.mode===i.SLIDE||e.mode===i.CROUCH?ne:ee,Ve=e=>I(e.vx,e.vz),He=(e,t,n)=>e.max[1]>t+.5+M&&e.min[1]<t+n-M,B=(e,t,n)=>[t-F(t,e.min[0],e.max[0]),n-F(n,e.min[2],e.max[2])],Ue=(e,t,n)=>{let{brushes:r}=t.def,i=O(t,e.x,e.z,2*C),a=(C-j)**2,[o,s]=[0,0];for(let t=0;t<4;t++){let t=0,c=0,l=0;for(let o of i){let i=r[o];if(!He(i,e.y,n))continue;let[s,u]=B(i,e.x,e.z),d=s*s+u*u;if(d>=a)continue;if(d){let e=Ie(d);.4-e>t&&(t=C-e,c=s/e*t,l=u/e*t);continue}let[f,p,m]=[[e.x-i.min[0],-1,0],[i.max[0]-e.x,1,0],[e.z-i.min[2],0,-1],[i.max[2]-e.z,0,1]].reduce((e,t)=>t[0]<e[0]?t:e);f+.4>t&&(t=f+C,[c,l]=[p*t,m*t])}if(!t)break;e.x+=c,e.z+=l,o+=c,s+=l}return[o,s]},We=(e,t,n)=>{let{brushes:r}=t.def,i=(C-j)**2,a=-1/0,o=1/0;for(let s of O(t,e.x,e.z,C)){let t=r[s],[c,l]=B(t,e.x,e.z);c*c+l*l>=i||(t.max[1]<=e.y+.5+M?a=Math.max(a,t.max[1]):t.min[1]>=e.y+n-M&&(o=Math.min(o,t.min[1])))}return[a,o]},V=(e,t)=>{let n=(C-j)**2;return O(t,e.x,e.z,C).every(r=>{let i=t.def.brushes[r],[a,o]=B(i,e.x,e.z);return a*a+o*o>=n||!He(i,e.y,1.8)})},Ge=(e,t,n,r,i)=>{let a=(C-j)**2;return O(e,t,n,C).every(o=>{let s=e.def.brushes[o],[c,l]=B(s,t,n);return c*c+l*l>=a||s.max[1]<=r||s.min[1]>=i})},Ke=(e,t)=>{let[n,r]=L[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}},qe=(e,t,n,r)=>{let{a:i,o:a,sign:o,c:s,co:c}=Ke(t,n),l=((o>0?e.min[i]:e.max[i])-s)*o;return l>=.4-Pe&&l<=.4+r&&c>=e.min[a]&&c<=e.max[a]?l:void 0},Je=(e,t,n)=>{let r;for(let i of O(t,e.x,e.z,C+oe)){let a=t.def.brushes[i],o=qe(a,e,n,oe);o!==void 0&&a.min[1]<e.y+.5&&a.max[1]>e.y+1.8&&(r=Math.min(r??1/0,Math.max(0,o-C)))}return r},Ye=(e,t)=>{let[n,r]=N(e.yaw),i;for(let a=1;a<=4;a++){let[o,s]=L[a];if(a===e.wall||n*o+r*s<.5)continue;let{a:c,sign:l}=Ke(e,a);for(let n of O(t,e.x,e.z,C+le)){let r=t.def.brushes[n],o=r.max[1],s=o-e.y;if(qe(r,e,a,.2)===void 0||s<1.2||s>2.4||r.min[1]>o-.25||i&&i.top>=o)continue;let u=l>0?r.min[c]:r.max[c],d=u-l*(C+ue),f=u+l*de,[p,m]=c===0?[d,e.z]:[e.x,d],[h,g]=c===0?[f,e.z]:[e.x,f];Ge(t,p,m,Math.min(e.y,o-2)+M,o+1.8)&&Ge(t,h,g,o+M,o+1.8)&&(i={side:a,top:o,hang:d})}}return i},Xe=(e,t)=>{let{a:n,o:r,sign:i,c:a,co:o}=Ke(e,e.wall);return O(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 P(c.max[1])===e.edge&&o>=c.min[r]&&o<=c.max[r]&&l>=.2})},Ze=(e,t)=>{if(e.vy>=0)return!1;let[n]=We(e,t,w),r=6*A;return e.y-n<=-e.vy*r+10*r*r},H=(e,t)=>{e.mode=t,e.t=0},U=(e,t,n,r=48,a=6)=>{e.stun=r,e.vx=P(t*a),e.vz=P(n*a),e.dash=Math.min(e.dash,50),e.coyote=0,e.buffer=0,(e.mode===i.HANG||e.mode===i.CLIMB)&&(e.vy=0),(e.mode===i.HANG||e.mode===i.CLIMB||e.mode===i.WALLRUN)&&(H(e,i.AIR),e.edge=0)},Qe=(e,t)=>{let n=I(e.vx,e.vz);n>t&&(e.vx*=t/n,e.vz*=t/n)},$e=(e,t,n,r)=>{let[i,a]=[n.wx,n.wz];for(let n of O(t,e.x,e.z,C+Pe)){let o=t.def.brushes[n],[s,c]=B(o,e.x,e.z),l=I(s,c);if(l>0&&l<=.4+Pe&&He(o,e.y,r)){let e=(-i*s-a*c)/l;e>0&&(i+=e*s/l,a+=e*c/l)}}return[i,a]},et=(e,t,n)=>{let r=I(t[0],t[1]);if(r<j){let t=I(e.vx,e.vz),n=t?Math.max(0,t-45*A)/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*A)/l;[s,c]=[s*e,c*e]}n*=r,o=o<n?Math.min(n,o+(o>=6?3:50)*A):Math.max(n,o-12*A),e.vx=s+o*i,e.vz=c+o*a},tt=(e,t,n,r,i)=>{let a=e.y;e.x+=e.vx*A,e.z+=e.vz*A;let[o,s]=Ue(e,t,n),c=I(o,s);if(c){let t=(e.vx*o+e.vz*s)/c;t<0&&(e.vx-=t*o/c,e.vz-=t*s/c)}let[l,u]=We(e,t,n),d=e.vy-r*20*A;if(e.y+=(e.vy+d)/2*A,e.vy=d,e.y+n>u&&(e.y=u-n,e.vy=Math.min(e.vy,0)),e.vy<=0?e.y<=l+M:e.y<l){if(e.y=l,e.vy<=0){let t=-e.vy;return e.vy=0,t}}else if(i&&e.vy<=0&&l>=a-.5)return e.y=l,e.vy=0,0;return-1},W=(e,t)=>{e.vy=t,e.coyote=0,e.buffer=0,e.ev|=o.JUMP},nt=(e,n,r)=>{let[a,o]=L[e.wall],s=t=>{H(e,t),e.edge=0};if(r.keys&(t.BACK|t.CROUCH))s(i.AIR),e.coyote=0;else if(r.jump&&r.fx*a+r.fz*o<0)s(i.AIR),e.vx=-a*4,e.vz=-o*4,W(e,6);else if(r.jump||r.fwd&&e.t>=6)H(e,i.CLIMB);else if(e.t>=30)s(i.AIR),e.coyote=0;else{let t=Math.max(e.edge-2,We(e,n,w)[0]);e.y+=F(t-e.y,-8*A,8*A)}},rt=(e,t)=>{let[n,r]=L[e.wall];e.y<e.edge?e.y=Math.min(e.edge,e.y+8*A):(e.x+=n*fe*A,e.z+=r*fe*A),e.y>=e.edge&&Xe(e,t)?(H(e,i.GROUND),e.vx=n*3,e.vz=r*3,e.vy=0,e.edge=0,e.wall=a.NONE,e.coyote=6,e.ev|=o.CLIMB):e.t>=40&&(H(e,e.y>=e.edge?i.GROUND:i.AIR),e.edge=0,e.wall=a.NONE)},it=(e,t,n)=>{let[r,a]=L[e.wall],s=e.vx*r+e.vz*a,[c,l]=[e.vx-s*r,e.vz-s*a],u=I(c,l);if(n.jump)H(e,i.AIR),e.vx=c-r*5,e.vz=l-a*5,W(e,ce),e.jumps=1,e.dashes=1,e.ev|=o.WALLRUN_END;else{let s=Je(e,t,e.wall);if(s===void 0||!n.fwd||u<3.5||e.t>=60){H(e,i.AIR),e.ev|=o.WALLRUN_END;return}let d=Math.max(0,u-ie*A)/u;e.vx=c*d,e.vz=l*d;let f=Math.min(s,4*A);e.x+=r*f,e.z+=a*f}},at=(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[a,s]=L[n],c=e.vx*a+e.vz*s,[l,u]=[e.vx-c*a,e.vz-c*s];if(n!==e.wall&&c<=.75*r&&c>=-.2*r&&Je(e,t,n)!==void 0){let t=I(l,u),a=Math.max(t,se*r)/t;H(e,i.WALLRUN),e.wall=n,[e.vx,e.vz]=[l*a,u*a],e.vy=F(e.vy,2,3),e.jumps=1,e.dashes=1,e.coyote=0,e.ev|=o.WALLRUN_START;return}}},ot=(e,t)=>{H(e,i.HANG),e.wall=t.side,e.edge=P(t.top),t.side<=a.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},st=(e,n,r)=>{let s=e.mode===i.GROUND;if(r.dash&&e.dash===0&&(s||(e.mode===i.AIR||e.mode===i.WALLRUN)&&e.dashes>0)){let[t,n]=r.wx||r.wz?[r.wx,r.wz]:[r.fx,r.fz];s||(e.dashes--,e.vy=0,e.mode===i.WALLRUN&&(H(e,i.AIR),e.ev|=o.WALLRUN_END)),e.vx=t*16,e.vz=n*16,e.dash=60,e.ev|=o.DASH}let c=e.dash>50;e.mode===i.WALLRUN&&it(e,n,r),R(e.mode)&&ct(e,n,r,c),e.mode===i.AIR&&lt(e,n,r,c);let l=c&&e.vy<=0?0:e.mode===i.WALLRUN?ae:1,u=e.mode,d=tt(e,n,z(e),l,R(u));if(d>=0){if(!R(e.mode)){if(e.ev|=o.LAND|(e.mode===i.WALLRUN?o.WALLRUN_END:0),e.fall=d,e.jumps=1,e.dashes=1,e.wall=a.NONE,r.keys&t.CROUCH){let t=I(e.vx,e.vz)>=re;H(e,t?i.SLIDE:i.CROUCH),e.ev|=t?o.SLIDE_START:0}else H(e,i.GROUND)}e.coyote=6}else R(e.mode)&&(e.ev|=e.mode===i.SLIDE?o.SLIDE_END:0,H(e,i.AIR));if(e.mode===i.AIR){let t=Ye(e,n);t?ot(e,t):at(e,n,r)}},ct=(e,n,r,a)=>{let s=(r.keys&t.CROUCH)!==0;if(e.buffer>0&&(e.mode===i.GROUND||V(e,n))){e.ev|=e.mode===i.SLIDE?o.SLIDE_END:0,H(e,i.AIR),W(e,7);return}let c=I(e.vx,e.vz);if(e.mode===i.GROUND&&s){let t=c>=re;H(e,t?i.SLIDE:i.CROUCH),e.ev|=t?o.SLIDE_START:0}else e.mode===i.SLIDE&&(e.t>=60||c<4.5||r.stumble)?(e.ev|=o.SLIDE_END,H(e,!s&&V(e,n)?i.GROUND:i.CROUCH)):e.mode===i.SLIDE&&!s&&V(e,n)?(e.ev|=o.SLIDE_END,H(e,i.GROUND)):e.mode===i.CROUCH&&!s&&V(e,n)&&H(e,i.GROUND);if(!a){if(r.stumble){if(c>2.5){let t=Math.max(pe,c-12*A)/c;e.vx*=t,e.vz*=t}else et(e,$e(e,n,r,z(e)),pe)}else if(e.mode===i.SLIDE){let t=Math.max(0,c-4*A)/c;e.vx*=t,e.vz*=t}else if(e.mode===i.CROUCH)et(e,$e(e,n,r,T),3);else{let i=(r.keys&t.SPRINT)!==0&&r.fwd;et(e,$e(e,n,r,w),i?9:6)}}},lt=(e,t,n,r)=>{if(e.buffer>0&&(e.coyote>0?W(e,7):e.jumps>0&&!Ze(e,t)&&(e.jumps--,W(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*A,e.vz+=n.wz*14*A,Qe(e,Math.max(i,6))},ut=(e,n,r,a=0)=>{e.yaw=Fe(n.yaw),e.pitch=Math.max(-te,Math.min(te,n.pitch));let o=(n.keys&t.FORWARD?1:0)-(n.keys&t.BACK?1:0),s=(n.keys&t.RIGHT?1:0)-(n.keys&t.LEFT?1:0),c=I(o,s)||1,[l,u]=N(e.yaw),d=t=>(n.keys&t)!==0&&(e.held&t)===0,f=e.stun>0,p={keys:n.keys,stumble:f,jump:!f&&d(t.JUMP),dash:!f&&d(t.DASH),fwd:o>0,wx:(l*o-u*s)/c,wz:(u*o+l*s)/c,fx:l,fz:u},m=e.mode;e.ev=0,e.fall=0,p.jump&&(e.buffer=7),f&&e.stun--,e.dash>0&&(e.dash--,e.dash===50&&Qe(e,10)),e.mode===i.HANG&&nt(e,r,p),e.mode===i.CLIMB?rt(e,r):e.mode!==i.HANG&&st(e,r,p),e.slow&&(e.slow--,Qe(e,3)),e.y<r.def.floor&&ze(e,r,a),e.t=e.mode===m?Math.min(255,e.t+1):e.t,e.buffer=Math.max(0,e.buffer-1),e.mode===i.AIR&&m===i.AIR&&(e.coyote=Math.max(0,e.coyote-1)),e.held=n.keys&(t.JUMP|t.DASH),e.ground=R(e.mode),e.x=P(e.x),e.y=P(e.y),e.z=P(e.z),e.vx=P(e.vx),e.vy=P(e.vy),e.vz=P(e.vz),e.edge=P(e.edge)},dt=.7,ft=e=>{let[r,i]=[e&t.LEFT,e&t.RIGHT];return r&&!i?n.LEFT:i&&!r?n.RIGHT:e&t.FORWARD?n.THRUST:n.SLASH},G=e=>{let t=ge[e.cut??0];return e.heavy?{...t,ticks:Math.round((t.ticks-t.hold)*_e),strike:Math.round((t.strike-t.hold)*_e),reach:t.reach+xe,arc:t.arc*Se,hp:t.hp+be}:t},pt=(e,t,n)=>{let{reach:r,arc:i}=G(t),[a,o]=N(t.yaw),s=[t.x,t.y+dt*z(t),t.z];return n.filter(n=>{let[c,l]=[n.x-t.x,n.z-t.z],u=Math.hypot(c,l);if(u-.4>r||t.y>=n.y+z(n)||n.y>=t.y+z(t))return!1;let d=u>.4?Math.abs(Math.atan2(a*l-o*c,a*c+o*l)):0,f=u>.4?Math.asin(C/u):Math.PI;return d<=i+f&&!Me(e,s,[n.x,n.y+dt*z(n),n.z])})},mt=(e,t)=>{if(!t.wield||!t.swing||e.lock||t.lock)return!1;let n=G(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]=N(e.yaw);return a<1e-6||(r*t+i*n)/a>=Math.cos(.9)};return a-.4<=Math.min(n.reach,G(e).reach)&&o(e,r,i)&&o(t,-r,-i)},ht=(e,t)=>{let[r,i]=N(e.yaw),a=e.cut??0;if(a===n.SPIN_L||a===n.SPIN_R){let[n,a]=[t.x-e.x,t.z-e.z],o=Math.hypot(n,a);return o>1e-6?[n/o,a/o]:[r,i]}return a===n.LEFT?[-i,r]:a===n.RIGHT?[i,-r]:[r,i]},gt=(e,t)=>{let[i,a]=N(e.yaw),[o,s]=N(t.yaw),[c,l]=[t.x-e.x,t.z-e.z],u=-a*c+i*l,d=Math.sqrt(Math.max(C*C-u*u,0)),[f,p]=[a*u-i*d,-i*u-a*d],m=-s*f+o*p,h=(e.cut??0)%4;if(h===n.SLASH)return Math.abs(m)<=Ee?r.HEAD:m>0?r.ARM_R:r.ARM_L;let g=(e.y+dt*z(e)+Math.tan(e.pitch)*Math.hypot(c,l)-t.y)/z(t);if(g>we)return r.HEAD;let _=h===n.THRUST?m>0:(h===n.LEFT?1:-1)*(i*o+a*s)<0;return g<Te?_?r.LEG_R:r.LEG_L:h===n.THRUST&&Math.abs(m)<=Ee?r.NONE:_?r.ARM_R:r.ARM_L},K=()=>({state:e.HOME,by:0,x:0,y:0,z:0,left:0}),_t=60,vt=class{score=[0,0];over=!1;flags=[K(),K()];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=k(this.world,[e.x,e.y+.05,e.z],[0,-1,0],_t);t<_t&&(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(t){return this.flags.findIndex(n=>n.state===e.CARRIED&&n.by===t)}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=[K(),K()],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(t){if(this.over)return--this.clock<=0?(this.reset(),`start`):void 0;for(let t of[0,1]){let n=this.flags[t];this.lock[t].left--,this.hold[t]--,n.state===e.DROPPED&&(n.left=Math.ceil(--this.back[t]/60),this.back[t]<=0&&(this.flags[t]=K()))}for(let n of[0,1]){let r=this.flags[n];if(r.state===e.CARRIED)continue;let i=r.state===e.HOME?this.world.def.teams[n].base:[r.x,r.y,r.z],a=t.filter(e=>yt(e.state,i)),o=r.state===e.DROPPED&&this.hold[n]<=0?a.find(e=>e.team===n):void 0,s=a.find(e=>e.team!==n&&(e.id!==this.lock[n].id||this.lock[n].left<=0));if(o){let e=this.mates.get(o.id);e&&e.returns++,this.flags[n]=K()}else s&&(this.flags[n]={...K(),state:e.CARRIED,by:s.id})}for(let n of t){let t=this.carrying(n.id);if(t>=0&&this.flags[n.team].state===e.HOME&&yt(n.state,this.world.def.teams[n.team].base)){this.score[n.team]++;let e=this.mates.get(n.id);e&&e.caps++,this.flags[t]=K()}}if(this.score.some(e=>e>=this.rules.scoreLimit)||--this.clock<=0)return this.over=!0,this.clock=600,`end`}dropAt(t,[n,r,i]){this.flags[t]={state:e.DROPPED,by:0,x:n,y:r,z:i,left:10},this.back[t]=600}},yt=(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],q=(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},bt=e=>{if(e.mode===i.GROUND){if(e.cut===n.LUNGE){let[t,n]=N(e.yaw);e.vx=t*13,e.vz=n*13,e.dash=60,e.ev|=o.DASH}else e.cut===n.LEAP&&(e.vy=Ce,e.ev|=o.JUMP)}},J={NONE:0,SHOT:1,CUT:2,RAIL:3,LASER:4},xt=(e,n,r,a,o=!0)=>{let s=e.down>0,c=!s&&(e.lock??0)>0;if(ut(e,s||c?{...n,keys:0}:n,r,a),e.zapping=!1,e.zap=!!e.stun&&!!e.zap,s)return e.down>0&&!--e.down&&ze(e,r,a),J.NONE;if(c)return St(e,n);let{rack:l,blade:u,rail:d,rifle:f}=r.def.teams[a],p=!!l&&q(e,l,1.2);o&&p&&!e.rack&&([e.ammo,e.mag]=[60,15]),e.rack=p,e.blade=!!e.blade||o&&!!u&&q(e,u,1.2);let m=!!d&&q(e,d,1.2);o&&m&&!e.inRail&&([e.rail,e.cap]=[240,80]),e.inRail=m;let h=!!f&&q(e,f,1.2);o&&h&&!e.inRifle&&([e.rifle,e.clip]=[240,60]),e.inRifle=h,e.cool=Math.max(0,e.cool-1);let g=e.mode===i.HANG||e.mode===i.CLIMB,{ticks:_,hold:v}=ge[e.cut??0],y=!!e.swing&&!e.heavy&&_-(e.swing??0)===v;y&&e.wield&&o&&!g&&n.keys&t.FIRE?e.charge=Math.min((e.charge??0)+1,ye):y&&o&&!g&&(e.charge??0)>=ve?([e.heavy,e.charge]=[!0,0],e.swing=G(e).ticks):(e.charge=y?0:e.charge,e.swing=Math.max(0,(e.swing??0)-1),e.heavy=!!e.swing&&!!e.heavy);let b=[e.ammo>=0,!!e.blade,(e.rail??-1)>=0,(e.rifle??-1)>=0],x=n.keys&t.BLADE?1:n.keys&t.RAIL?2:n.keys&t.RIFLE?3:0,S=e.swing&&e.blade?1:b[x]?x:b.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],!o)return[e.charge,e.reload]=[0,0],J.NONE;let[C,w,ee,te]=S==3?[`clip`,60,e.rifle,96]:S==2?[`cap`,80,e.rail,90]:[`mag`,15,e.ammo,54],[T,ne]=[e[C]??0,Math.min(w,ee)];e.reload?--e.reload||(e[C]=ne):S!=1&&ee>=0&&!g&&T<ne&&(!T||n.keys&t.RELOAD)&&([e.reload,e.charge]=[te,0]);let re=G(e);if(e.swing&&re.ticks-e.swing===re.strike)return J.CUT;if((e.wield&&!y||e.railed||e.rifled||g||e.reload||!e.wield&&!e.mag)&&(e.charge=0),n.keys&t.FIRE&&!g){let r=ge[e.cut??0].ticks-(e.swing??0),i=!!(n.keys&t.SPECIAL)&&(!e.swing||!e.heavy&&(e.cut??0)<4&&r<=18);if(e.wield&&(!e.swing||i))e.cut=ft(n.keys)+(i?4:0),[e.swing,e.charge]=[ge[e.cut].ticks,0],bt(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,J.LASER}else if(e.railed){if(e.cap&&!e.reload)return e.rail--,e.cap--,e.zapping=!0,J.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(Ct(e.charge),e.mag),e.charge=0,e.ammo-=e.power,e.mag-=e.power,e.shots=e.shots+1&255,e.cool=7,J.SHOT;return J.NONE},St=(e,n)=>{let r=!!(n.keys&t.FIRE);return e.pushes=(e.pushes??0)+ +(r&&!e.pressed)&255,e.pressed=r,e.away=n.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],J.NONE},Ct=e=>e<10?1:1+Math.floor(4*(e-10)/50),wt=-30,Y=(e,t,n,r,i,a=s.CONCRETE)=>({min:[e,wt,t],max:[n,i,r],top:s.CONCRETE,side:a}),X=([e,t,n],[r,i,a],o,s=o,c)=>({min:[e,t,n],max:[r,i,a],top:o,side:s,tint:c});[Y(4,57.7,24,76,10),Y(4,36,24,53.5,10,s.GLASS),Y(4,20,24,36,12.4),Y(4,-5,24,7,12.4,s.GLASS),Y(27,20,47,50,8),Y(27,60,47,76,8,s.BRICK),X([9,12.2,39],[19,12.6,47],s.STEEL),...((e,t)=>[1,2,3,4,5,6].map(n=>X([12,t,e-n],[14,t+.4*n,e-n+1],s.CONCRETE)))(53,10),X([5,10,42],[5.5,14,42.5],s.STEEL),X([5,10,50],[5.5,14,50.5],s.STEEL),X([8,12.4,24],[20,12.85,24.45],s.STEEL),X([36,8,22],[37,14.5,48],s.PAINT,s.PAINT,[.15,.72,.62]),X([30,8,28],[34,10,32],s.CONCRETE),X([40,8,30],[44,10.2,34],s.PAINT,s.PAINT,[1,.3,.06]),X([28,9.2,44],[35,12,46],s.STEEL,s.PAINT,[.2,.42,1]),X([41.5,7.6,50],[42,8,60],s.STEEL),X([30,8,64],[34,9.6,68],s.PAINT,s.PAINT,[.2,.8,.3])];var Z=240,Q=[1,.22,.26],Tt=[.2,.46,1],Et=[1,.42,.08],Dt=[.12,.7,.62],$=(e,t,n,r,i,a,o)=>X([e,t,n],[r,i,a],s.PAINT,s.PAINT,o),Ot=(e,t,n,r,i,a,o,c=wt)=>{let l=Math.ceil((o-a)/.46);return Array.from({length:l},(u,d)=>{let[f,p]=[t+(n-t)*d/l,t+(n-t)*(d+1)/l].sort((e,t)=>e-t),m=a+(o-a)*(d+1)/l;return e===0?X([f,c,r],[p,m,i],s.CONCRETE):X([r,c,f],[i,m,p],s.CONCRETE)})},kt=(e,t,n,r,i,a,o)=>o.map((o,c)=>X([e+c*n,a,t+c*r],[e+c*n+4,o,t+c*r+i],s.STEEL,s.CONCRETE)),At=[Y(12,212,52,240,26,s.GLASS),$(12,26,212,52,26.12,212.5,Q),$(12,26,239.5,52,26.12,240,Q),$(12,26,212.5,12.5,26.12,239.5,Q),$(51.5,26,212.5,52,26.12,239.5,Q),$(11.6,12,222,12,25.8,232,Q),$(28,12,211.4,31,25.5,212,Q),X([19,26,222],[22,27.4,225],s.STEEL),X([42,26,222],[45,27.4,225],s.STEEL),X([29,26,229],[35,27.1,229.6],s.CONCRETE),X([24.5,26,215],[35,27.5,219],s.STEEL,s.PAINT,Q),Y(6,164,26,201,26,s.GLASS),Y(6,134,26,147,26,s.GLASS),Y(6,201,26,212,19),Y(15,147,26,164,19),X([14,26,164],[15,32,196],s.PAINT,s.PAINT,Dt),X([14,18,147],[15,32,164],s.PAINT,s.PAINT,Dt),X([14,26,134],[15,32,147],s.PAINT,s.PAINT,Dt),...kt(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])=>X([e,19,t],[n,i,r],s.STEEL,s.CONCRETE)),X([20,26,178],[23,27.3,181],s.STEEL),X([8,26,176],[11,27.2,179],s.STEEL),X([8,26,190],[11,27.3,193],s.STEEL),X([20,26,140],[23,27.3,143],s.STEEL),Y(32,186,76,209,19),$(32,19,207.5,76,19.1,209,Q),...kt(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])=>X([e,wt,t],[n,i,r],s.STEEL,s.CONCRETE)),Y(32,166,64,182,21.2,s.GLASS),Y(32,140,64,161,19),X([40,21.2,172],[44,22.6,176],s.STEEL),X([52,19,148],[57,20.3,151],s.STEEL),X([38,19,196],[41,20.4,199],s.STEEL),X([60,19,200],[63,20.4,203],s.STEEL),X([52,19,190],[58,20.6,194],s.STEEL),X([66,19,204],[72,20.2,207],s.STEEL),X([56,21.2,170],[60,22.4,174],s.STEEL),X([34,19,152],[37,20.3,156],s.STEEL),...kt(36,135,18,0,3,15,[17.2,17.2]),...kt(6.5,129,6,0,4,15,[17.2,19.4,21.6,23.8]),Y(76,213,100,240,14.5,s.STEEL),$(76,14.5,238.5,100,14.6,240,Q),Y(76,185,100,209,14.5),Y(76,138,100,181,14.5,s.GLASS),X([80,15.7,158],[96,17.7,162],s.STEEL,s.PAINT,Et),X([82,14.5,234],[85,15.9,237],s.STEEL),X([91,14.5,190],[94,15.9,193],s.STEEL),X([80,14.5,204],[83,15.6,207],s.STEEL),X([78,14.5,170],[81,15.9,173],s.STEEL),X([92,14.5,146],[95,15.7,149],s.STEEL),X([92,14.5,222],[96,15.8,226],s.STEEL),...Ot(0,76,52,226,232,14.5,26),...Ot(0,85,76,196,202,14.5,19,14.5)],jt=[Y(6,106,62,134,15),Y(62,106,100,134,14.5),X([34,15,112],[54,17.2,128],s.CONCRETE),$(38,17.2,116,50,17.3,124,Et),...[[35,113],[35,126.2],[51,113],[51,126.2]].map(([e,t])=>X([e,17.2,t],[e+.8,21.5,t+.8],s.STEEL)),X([34.6,21.5,112.6],[52.2,21.9,127.4],s.GLASS),X([14,15,114],[17,16.5,117],s.STEEL),X([14,15,123],[17,16.5,126],s.STEEL),X([56,15,114],[59,16.5,117],s.STEEL),X([56,15,123],[59,16.5,126],s.STEEL),X([15.35,25.5,106],[15.85,26,134],s.STEEL),X([70,14.5,108],[70.8,38,108.8],s.STEEL),X([70,14.5,131.2],[70.8,38,132],s.STEEL),X([66,14.5,110],[69,15.9,113],s.STEEL),X([66,14.5,127],[69,15.9,130],s.STEEL)],Mt=e=>({...e,min:[e.min[0],e.min[1],Z-e.max[2]],max:[e.max[0],e.max[1],Z-e.min[2]],tint:e.tint===Q?Tt:e.tint}),Nt=(e,t,n)=>[...[16,22,28,34,40].map(n=>[n,26,t,e]),...[19,31,43].map(t=>[t,26,n,e])],Pt=[[20,26,190],[48,21.2,172],[48,19,200],[88,14.5,198]],Ft=[[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]],It=[[19.5,26,179],[46,19,152],[39.5,21.2,172],[88,14.5,186],[88,14.5,207]],Lt={name:`Highline`,brushes:[...At,...At.map(Mt),...jt],teams:[{base:[32,26,224],spawns:Nt(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:Nt(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:[...Pt,...Pt.map(([e,t,n])=>[e,t,Z-n]),[24,15,112],[24,15,128]],ammo:[...Ft,...Ft.map(([e,t,n])=>[e,t,Z-n]),[12,15,116],[12,15,124]],cells:[...It,...It.map(([e,t,n])=>[e,t,Z-n]),[28,15,Z/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]},Rt=40/60,zt=(e,t=0)=>{let[n,r,i,a]=[Math.sin(e.yaw),Math.cos(e.yaw),Math.sin(e.pitch),Math.cos(e.pitch)];return{id:e.shots,by:e.id,team:t,x:e.x,y:e.y+Be(e),z:e.z,dx:-n*a,dy:i,dz:-r*a,left:80,burst:!1,power:e.power??1}},Bt=(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},Vt=(e,t,n,r)=>{let i=[t.x,t.y,t.z],a=[t.dx,t.dy,t.dz],o=Math.min(n,t.left),s=k(e,i,a,o,he),c;for(let e of r){let t=Bt(i,a,e,C+he,z(e));t<s&&([s,c]=[t,e])}return t.burst=s<o,t.left-=s,[t.x,t.y,t.z]=[i[0]+a[0]*s,i[1]+a[1]*s,i[2]+a[2]*s],c},Ht=(e,t,n=[],r=30,[i,a]=[0,0])=>{let o=[t.x,t.y+Be(t),t.z],[s,c]=[t.yaw+i,t.pitch+a],l=Math.cos(c),u=[-Math.sin(s)*l,Math.sin(c),-Math.cos(s)*l],d=k(e,o,u,r),f;for(let e of n){let t=Bt(o,u,e,C,z(e));t<d&&([d,f]=[t,e])}return{o,d:u,t:d,hit:f}},Ut=e=>[De*Math.sin(e*2.4),De*Math.cos(e*1.7)],Wt=(e,t,n=[])=>Ht(e,t,n,60,Ut(t.shots)),Gt=e=>e.mode===i.SLIDE||e.dash>50,Kt=(e,t)=>Math.hypot(e.x-t.x,e.z-t.z)<1.1&&e.y<t.y+z(t)&&t.y<e.y+z(e),qt=20,Jt=2,Yt=(e,t)=>Array.from(e).slice(0,t).join(``).trim(),Xt=e=>Yt((typeof e==`string`?e:``).replace(/\s+/g,` `).replace(/\p{Cc}/gu,``).trim(),16),Zt=(e,t)=>{let n=e;for(let r=2;t.includes(n);r++)n=`${Yt(e,15-`${r}`.length)} ${r}`;return n},Qt=(e,t)=>{let n=setInterval(e,t);return()=>clearInterval(n)},$t={lock:0,foe:0,pushes:0,pressed:!1,away:0},en=({x:e,y:t,z:n,yaw:r})=>({x:e,y:t,z:n,yaw:r}),tn=class{peers=/* @__PURE__ */ new Map;ticks=0;history=[];world;ctf;halt;rules;rr=[0,0];gone;balls=[];constructor(e={},t=Lt){this.rules={...Oe,...e},this.world=je(t),this.ctf=new vt(this.world,this.rules),this.gone=[...t.packs??[],...t.ammo??[],...t.cells??[]].map(()=>0)}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=S(t);n===null&&r?.t===`join`&&this.join(e,r.name);return}let r=n&&y(t);if(r&&n.bank>0){n.bank--;let e=n.state.slow??0,t=xt(n.state,r,this.world,n.info.team,!this.ctf.over);this.ctf.moved(n.state),this.tackle(n,r.view),t===J.SHOT?this.shoot(n,r.view):t===J.CUT?this.cut(n,r.view):t===J.RAIL?this.rail(n,r.view):t===J.LASER&&this.laser(n,r.view),n.burn=e?(n.burn??0)+1:0,e&&!(n.burn%60)&&this.fry(n),this.duel(n),n.ack=r.seq}}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.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,Rt);this.heal(e);let n=this.ctf.tick(e.filter(e=>!e.state.down).map(e=>({id:e.info.id,team:e.info.team,state:e.state})));if(n===`end`?this.end(e):n===`start`&&this.restart(e),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=x({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});e.forEach(e=>e.conn.send(n)),this.balls=this.balls.filter(e=>!e.burst&&e.left>0)}}start(e=Qt){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<qt;e++)this.tick(),r-=t;r%=t},t)}stop(){this.halt?.(),this.halt=void 0}rewind(e,t=0){let n=this.players().filter(t=>t.info.id!==e).map(e=>e.state),[r,i]=[this.history[0],this.history.at(-1)];if(!r||!i)return n;let a=((this.ticks-t+32768)%65536+65536)%65536-32768,o=Math.min(Math.max(this.ticks-a,r.tick),i.tick),s=0;for(;s+1<this.history.length&&this.history[s+1].tick<=o;)s++;let[c,l]=[this.history[s],this.history[s+1]??this.history[s]],u=l.tick>c.tick?(o-c.tick)/(l.tick-c.tick):0,d=(e,t)=>e+(t-e)*u;return n.map(e=>{let t=c.players.find(t=>t.id===e.id),n=l.players.find(t=>t.id===e.id);return t&&n?{...n,x:d(t.x,n.x),y:d(t.y,n.y),z:d(t.z,n.z)}:n??t??e})}tackle(e,t){let n=e.state;if(n.down||!Gt(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=>Kt(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=Ve(n),[s,c]=o>.001?[n.vx/o,n.vz/o]:N(n.yaw);U(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=0,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:r.NONE,rail:-1,railed:!1,rifle:-1,clip:0,rifled:!1,zapping:!1,slow:0}),this.ctf.drop(e.state),!0)}shoot(e,t=0){let n=zt(e.state,e.info.team),r=(this.ticks-t+65536)%65536;this.balls.push(n),this.fly(n,Math.min(r<32768?r:0,12)*Rt);let i=this.balls.filter(e=>!e.burst);i.length>64&&(i[0].burst=!0)}fly(e,t){let n=this.players(),r=n.filter(t=>t.info.team!==e.team&&!t.state.down),i=Vt(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);o&&(o.state.hits=o.state.hits+1&255),this.harm(a,e.power??1)}cut(e,t){let n=pt(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=>mt(e.state,{...t.state,...en(n.find(e=>e.id===t.info.id))}));if(i){for(let[t,n]of[[e,i],[i,e]])Object.assign(t.state,{...$t,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,G(e.state).hp))t.state.lost=gt(e.state,r);else{let[n,i]=ht(e.state,r);U(t.state,n,i,24,4*(e.state.heavy?_e:1)),t.state.zap=!0,t.by=e.info.id}}}}rail(e,t){let{hit:n}=Ht(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))}}laser(e,t){let{hit:n}=Wt(this.world,e.state,this.enemies(e,t)),r=this.players().find(e=>e.info.id===n?.id);r&&(e.state.hits=e.state.hits+1&255,r.graze=((r.graze??0)+1)%2,r.graze||this.harm(r,1))}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,$t);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,$t),Object.assign(n.state,$t),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]=N(t.state.yaw);U(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;U(t,-e/i,-r/i),U(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)&&q(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}})}place(e,t,n){let r=this.world.def.teams[t].spawns.findIndex((r,i)=>{let{x:a,z:o}=Re(e,this.world,i,t);return!n.some(e=>Math.hypot(e.x-a,e.z-o)<Jt)});return Re(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);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){let n=this.players();if(n.length>=this.rules.maxPlayers){e.send(JSON.stringify({t:`full`}));return}let r=0;for(;n.some(e=>e.info.id===r);)r++;let i=n.filter(e=>e.info.team===0).length,a=+(i>n.length-i),o={conn:e,info:{id:r,name:Zt(Xt(t)||`Player ${r}`,n.map(e=>e.info.name)),team:a,color:me[a]},state:this.place(r,a,n.map(e=>e.state)),bank:10,ack:65535,by:0,tackled:-30};this.peers.set(e,o),this.ctf.join(r,a,o.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})))}},nn=(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()},rn=(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 tn(t),s.start(nn),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`&&S(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{rn as localSocket};
1
+ var e={HOME:0,CARRIED:1,DROPPED:2},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},n={THRUST:0,LEFT:1,RIGHT:2,SLASH:3,LUNGE:4,ARC_L:5,ARC_R:6,LEAP:7},r={NONE:0,HEAD:1,ARM_L:2,ARM_R:3,LEG_L:4,LEG_R:5},i={GROUND:0,AIR:1,WALLRUN:2,HANG:3,CLIMB:4,SLIDE:5,CROUCH:6},a={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},s={BRICK:0,TILE:1,LAVA:2,STONE:3,METAL:4,WOOD:5,MOSS:6,GRATE:7,CONCRETE:8,GLASS:9,STEEL:10,PAINT:11},c=127,l=16,u=32,d=128/Math.PI,f=254/Math.PI,p=65536/(2*Math.PI),m=e=>Math.round(e*p)&65535,h=e=>Math.max(-32768,Math.min(32767,Math.round(e))),g=e=>h(e*1e4),_=e=>e/1e4,v=e=>e/p,y=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)&16383,yaw:v(t.getUint16(5)),pitch:_(t.getInt16(7)),view:(t.getUint16(9)*256+t.getUint8(11))/256}:null},b=t=>t===e.CARRIED?2:t===e.DROPPED?8:1,x=n=>{let r=4+60*n.players.length,i=n.balls??[],a=r+10+n.flags.reduce((e,t)=>e+b(t.state),0),o=new DataView(new ArrayBuffer(a+(i.length&&1+11*i.length)));o.setUint8(0,2),o.setUint16(1,n.tick&65535),o.setUint8(3,n.players.length),n.players.forEach((e,n)=>{let r=4+n*60;o.setUint8(r,e.id),o.setFloat32(r+1,e.x),o.setFloat32(r+5,e.y),o.setFloat32(r+9,e.z),o.setFloat32(r+13,e.vx),o.setFloat32(r+17,e.vy),o.setFloat32(r+21,e.vz),o.setFloat32(r+25,e.edge),o.setUint16(r+29,m(e.yaw)),o.setInt16(r+31,g(e.pitch)),o.setUint16(r+33,e.ack&65535),o.setUint8(r+35,e.mode&7|(e.wall&7)<<3|(e.jumps&1)<<6|e.dashes<<7),o.setUint8(r+36,e.t),o.setUint8(r+37,e.dash|(e.by>>2&3)<<6),o.setUint8(r+38,e.coyote&7|(e.buffer&7)<<3|(e.held&t.JUMP?64:0)|(e.held&t.DASH?128:0)),o.setUint8(r+39,e.stun|(e.by&3)<<6);let i=e.hp|e.cool<<3|(e.ammo<0?c:e.ammo)<<6|e.down<<13|!!e.rack<<20|!!e.blade<<21|!!e.wield<<22|!!e.zap<<23;o.setUint8(r+40,i>>16),o.setUint16(r+41,i&65535),o.setUint8(r+43,e.shots),o.setUint8(r+44,e.hits),o.setUint8(r+45,(e.swing??0)&63|((e.cut??0)&3)<<6),o.setUint8(r+46,(e.lost??0)&7|((e.cut??0)&4)<<1|(e.fried?16:0)|(e.heavy?32:0)),o.setUint8(r+47,e.charge??0),o.setUint8(r+48,e.lock??0),o.setUint8(r+49,(e.foe??0)&15|(e.pressed?128:0)),o.setUint8(r+50,e.pushes??0),o.setUint8(r+51,e.away??0),o.setUint8(r+52,(e.rail??-1)+1),o.setUint8(r+53,+!!e.railed|!!e.inRail<<1|!!e.zapping<<2|!!e.rifled<<3|!!e.inRifle<<4),o.setUint8(r+54,e.slow??0),o.setUint8(r+55,e.mag??0),o.setUint8(r+56,e.cap??0),o.setUint8(r+57,e.reload??0),o.setUint8(r+58,(e.rifle??-1)+1),o.setUint8(r+59,e.clip??0)}),o.setUint8(r,n.score[0]),o.setUint8(r+1,n.score[1]),o.setUint16(r+2,n.clock&32767|(n.over?32768:0));let s=n.packs??0;o.setUint16(r+4,Math.floor(s/2**32)),o.setUint32(r+6,s%2**32);let p=r+10;for(let t of n.flags)o.setUint8(p,t.state),t.state===e.CARRIED?o.setUint8(p+1,t.by):t.state===e.DROPPED&&(o.setInt16(p+1,h(t.x*l)),o.setInt16(p+3,h(t.y*l)),o.setInt16(p+5,h(t.z*l)),o.setUint8(p+7,Math.min(255,t.left))),p+=b(t.state);i.length&&o.setUint8(p++,i.length);for(let e of i)o.setUint8(p,e.id),o.setUint8(p+1,e.by&127|(e.burst?128:0)),[e.x,e.y,e.z].forEach((e,t)=>o.setInt16(p+2+2*t,h(e*u))),o.setUint8(p+8,Math.round(Math.atan2(-e.dx,-e.dz)*d)&255),o.setInt8(p+9,Math.round(Math.asin(Math.max(-1,Math.min(1,e.dy)))*f)),o.setUint8(p+10,e.arc?128|e.arc:e.power??1),p+=11;return o.buffer},S=e=>{try{let t=JSON.parse(e);return t&&typeof t.t==`string`?t:null}catch{return null}},C=.4,w=1.8,ee=1.6,te=1.55,ne=.9,re=.7,T=7.5,ie=1.5,ae=.15,oe=.5,se=.9,ce=6.5,le=.2,ue=.03,de=.2,fe=5.5,pe=2.5,me=[`#ff3d4f`,`#2f80ff`],he=.12,E=[{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}],[ge,_e,ve]=[1.8,15,60],[ye,be,xe]=[2,.5,1.4],[Se,Ce,we]=[24,15,.6],[Te,Ee]=[63,7],De=7.5,[Oe,ke,Ae]=[.82,.45,.12],je=.012,Me={maxPlayers:16,scoreLimit:3,timeLimit:480},Ne=4,D=1024,Pe=(e,t)=>(e+D)*(2*D)+t+D,O=(e,t)=>Math.min(Math.max(Math.floor(e/t),-1024),1023),Fe=(e,t=Ne)=>{let n=/* @__PURE__ */ new Map;return e.brushes.forEach(({min:e,max:r},i)=>{for(let a=O(e[0],t);a<=O(r[0],t);a++)for(let o=O(e[2],t);o<=O(r[2],t);o++){let e=Pe(a,o),t=n.get(e);t?t.push(i):n.set(e,[i])}}),{def:e,cell:t,grid:n}},k=(e,t,n,r)=>{let i=[];for(let a=O(t-r,e.cell);a<=O(t+r,e.cell);a++)for(let t=O(n-r,e.cell);t<=O(n+r,e.cell);t++)for(let n of e.grid.get(Pe(a,t))??[])i.includes(n)||i.push(n);return i},A=(e,t,n,r,i=0)=>{let{cell:a,def:o}=e,s=r,c=O(t[0],a),l=O(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(Pe(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)>D||Math.abs(l)>D)return s;m<h?(c+=u,m+=g):(l+=d,h+=_)}},Ie=(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&&A(e,t,[r/o,i/o,a/o],o)<o-1e-4},j=1/60,Le=Math.PI*2,M=1e-6,N=.01,Re=.001,ze=e=>(e%Le+Le)%Le,P=e=>[-Math.sin(e),-Math.cos(e)],F=Math.fround,Be=Math.sqrt,I=(e,t,n)=>Math.min(Math.max(e,t),n),L=(e,t)=>Be(e*e+t*t),R=[[0,0],[1,0],[-1,0],[0,1],[0,-1]],Ve={vx:0,vz:0,mode:i.GROUND,t:0,wall:a.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:r.NONE,rail:-1,railed:!1,rifle:-1,clip:0,rifled:!1,inRifle:!1,inRail:!1,zapping:!1,slow:0,fried:!1,heavy:!1,ev:0,fall:0},He=(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:ze(c),pitch:0,ground:!0,...Ve}},Ue=(e,t,n)=>{let{yaw:r,pitch:i,id:a,shots:s,hits:c}=e;Object.assign(e,He(a,t,a,n),{yaw:r,pitch:i,shots:s,hits:c,ev:e.ev|o.RESPAWN})},z=e=>e===i.GROUND||e===i.SLIDE||e===i.CROUCH,B=e=>e.mode===i.SLIDE||e.mode===i.CROUCH?ne:w,We=e=>e.mode===i.SLIDE||e.mode===i.CROUCH?re:ee,Ge=e=>L(e.vx,e.vz),Ke=(e,t,n)=>e.max[1]>t+.5+N&&e.min[1]<t+n-N,V=(e,t,n)=>[t-I(t,e.min[0],e.max[0]),n-I(n,e.min[2],e.max[2])],qe=(e,t,n)=>{let{brushes:r}=t.def,i=k(t,e.x,e.z,2*C),a=(C-M)**2,[o,s]=[0,0];for(let t=0;t<4;t++){let t=0,c=0,l=0;for(let o of i){let i=r[o];if(!Ke(i,e.y,n))continue;let[s,u]=V(i,e.x,e.z),d=s*s+u*u;if(d>=a)continue;if(d){let e=Be(d);.4-e>t&&(t=C-e,c=s/e*t,l=u/e*t);continue}let[f,p,m]=[[e.x-i.min[0],-1,0],[i.max[0]-e.x,1,0],[e.z-i.min[2],0,-1],[i.max[2]-e.z,0,1]].reduce((e,t)=>t[0]<e[0]?t:e);f+.4>t&&(t=f+C,[c,l]=[p*t,m*t])}if(!t)break;e.x+=c,e.z+=l,o+=c,s+=l}return[o,s]},Je=(e,t,n)=>{let{brushes:r}=t.def,i=(C-M)**2,a=-1/0,o=1/0;for(let s of k(t,e.x,e.z,C)){let t=r[s],[c,l]=V(t,e.x,e.z);c*c+l*l>=i||(t.max[1]<=e.y+.5+N?a=Math.max(a,t.max[1]):t.min[1]>=e.y+n-N&&(o=Math.min(o,t.min[1])))}return[a,o]},Ye=(e,t)=>{let n=(C-M)**2;return k(t,e.x,e.z,C).every(r=>{let i=t.def.brushes[r],[a,o]=V(i,e.x,e.z);return a*a+o*o>=n||!Ke(i,e.y,1.8)})},Xe=(e,t,n,r,i)=>{let a=(C-M)**2;return k(e,t,n,C).every(o=>{let s=e.def.brushes[o],[c,l]=V(s,t,n);return c*c+l*l>=a||s.max[1]<=r||s.min[1]>=i})},Ze=(e,t)=>{let[n,r]=R[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}},Qe=(e,t,n,r)=>{let{a:i,o:a,sign:o,c:s,co:c}=Ze(t,n),l=((o>0?e.min[i]:e.max[i])-s)*o;return l>=.4-Re&&l<=.4+r&&c>=e.min[a]&&c<=e.max[a]?l:void 0},$e=(e,t,n)=>{let r;for(let i of k(t,e.x,e.z,C+oe)){let a=t.def.brushes[i],o=Qe(a,e,n,oe);o!==void 0&&a.min[1]<e.y+.5&&a.max[1]>e.y+1.8&&(r=Math.min(r??1/0,Math.max(0,o-C)))}return r},et=(e,t)=>{let[n,r]=P(e.yaw),i;for(let a=1;a<=4;a++){let[o,s]=R[a];if(a===e.wall||n*o+r*s<.5)continue;let{a:c,sign:l}=Ze(e,a);for(let n of k(t,e.x,e.z,C+le)){let r=t.def.brushes[n],o=r.max[1],s=o-e.y;if(Qe(r,e,a,.2)===void 0||s<1.2||s>2.4||r.min[1]>o-.25||i&&i.top>=o)continue;let u=l>0?r.min[c]:r.max[c],d=u-l*(C+ue),f=u+l*de,[p,m]=c===0?[d,e.z]:[e.x,d],[h,g]=c===0?[f,e.z]:[e.x,f];Xe(t,p,m,Math.min(e.y,o-2)+N,o+1.8)&&Xe(t,h,g,o+N,o+1.8)&&(i={side:a,top:o,hang:d})}}return i},tt=(e,t)=>{let{a:n,o:r,sign:i,c:a,co:o}=Ze(e,e.wall);return k(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})},nt=(e,t)=>{if(e.vy>=0)return!1;let[n]=Je(e,t,w),r=6*j;return e.y-n<=-e.vy*r+10*r*r},H=(e,t)=>{e.mode=t,e.t=0},rt=e=>!!e.zap&&e.stun>24,U=(e,t,n,r=48,a=6)=>{e.stun=r,e.vx=F(t*a),e.vz=F(n*a),e.dash=Math.min(e.dash,50),e.coyote=0,e.buffer=0,(e.mode===i.HANG||e.mode===i.CLIMB)&&(e.vy=0),(e.mode===i.HANG||e.mode===i.CLIMB||e.mode===i.WALLRUN)&&(H(e,i.AIR),e.edge=0)},it=(e,t)=>{let n=L(e.vx,e.vz);n>t&&(e.vx*=t/n,e.vz*=t/n)},at=(e,t,n,r)=>{let[i,a]=[n.wx,n.wz];for(let n of k(t,e.x,e.z,C+Re)){let o=t.def.brushes[n],[s,c]=V(o,e.x,e.z),l=L(s,c);if(l>0&&l<=.4+Re&&Ke(o,e.y,r)){let e=(-i*s-a*c)/l;e>0&&(i+=e*s/l,a+=e*c/l)}}return[i,a]},ot=(e,t,n)=>{let r=L(t[0],t[1]);if(r<M){let t=L(e.vx,e.vz),n=t?Math.max(0,t-45*j)/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*j)/l;[s,c]=[s*e,c*e]}n*=r,o=o<n?Math.min(n,o+(o>=6?3:50)*j):Math.max(n,o-12*j),e.vx=s+o*i,e.vz=c+o*a},st=(e,t,n,r,i)=>{let a=e.y;e.x+=e.vx*j,e.z+=e.vz*j;let[o,s]=qe(e,t,n),c=L(o,s);if(c){let t=(e.vx*o+e.vz*s)/c;t<0&&(e.vx-=t*o/c,e.vz-=t*s/c)}let[l,u]=Je(e,t,n),d=e.vy-r*20*j;if(e.y+=(e.vy+d)/2*j,e.vy=d,e.y+n>u&&(e.y=u-n,e.vy=Math.min(e.vy,0)),e.vy<=0?e.y<=l+N:e.y<l){if(e.y=l,e.vy<=0){let t=-e.vy;return e.vy=0,t}}else if(i&&e.vy<=0&&l>=a-.5)return e.y=l,e.vy=0,0;return-1},W=(e,t)=>{e.vy=t,e.coyote=0,e.buffer=0,e.ev|=o.JUMP},ct=(e,n,r)=>{let[a,o]=R[e.wall],s=t=>{H(e,t),e.edge=0};if(r.keys&(t.BACK|t.CROUCH))s(i.AIR),e.coyote=0;else if(r.jump&&r.fx*a+r.fz*o<0)s(i.AIR),e.vx=-a*4,e.vz=-o*4,W(e,6);else if(r.jump||r.fwd&&e.t>=6)H(e,i.CLIMB);else if(e.t>=30)s(i.AIR),e.coyote=0;else{let t=Math.max(e.edge-2,Je(e,n,w)[0]);e.y+=I(t-e.y,-8*j,8*j)}},lt=(e,t)=>{let[n,r]=R[e.wall];e.y<e.edge?e.y=Math.min(e.edge,e.y+8*j):(e.x+=n*fe*j,e.z+=r*fe*j),e.y>=e.edge&&tt(e,t)?(H(e,i.GROUND),e.vx=n*3,e.vz=r*3,e.vy=0,e.edge=0,e.wall=a.NONE,e.coyote=6,e.ev|=o.CLIMB):e.t>=40&&(H(e,e.y>=e.edge?i.GROUND:i.AIR),e.edge=0,e.wall=a.NONE)},ut=(e,t,n)=>{let[r,a]=R[e.wall],s=e.vx*r+e.vz*a,[c,l]=[e.vx-s*r,e.vz-s*a],u=L(c,l);if(n.jump)H(e,i.AIR),e.vx=c-r*5,e.vz=l-a*5,W(e,ce),e.jumps=1,e.dashes=1,e.ev|=o.WALLRUN_END;else{let s=$e(e,t,e.wall);if(s===void 0||!n.fwd||u<3.5||e.t>=60){H(e,i.AIR),e.ev|=o.WALLRUN_END;return}let d=Math.max(0,u-ie*j)/u;e.vx=c*d,e.vz=l*d;let f=Math.min(s,4*j);e.x+=r*f,e.z+=a*f}},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[a,s]=R[n],c=e.vx*a+e.vz*s,[l,u]=[e.vx-c*a,e.vz-c*s];if(n!==e.wall&&c<=.75*r&&c>=-.2*r&&$e(e,t,n)!==void 0){let t=L(l,u),a=Math.max(t,se*r)/t;H(e,i.WALLRUN),e.wall=n,[e.vx,e.vz]=[l*a,u*a],e.vy=I(e.vy,2,3),e.jumps=1,e.dashes=1,e.coyote=0,e.ev|=o.WALLRUN_START;return}}},ft=(e,t)=>{H(e,i.HANG),e.wall=t.side,e.edge=F(t.top),t.side<=a.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},pt=(e,n,r)=>{let s=e.mode===i.GROUND;if(r.dash&&e.dash===0&&(s||(e.mode===i.AIR||e.mode===i.WALLRUN)&&e.dashes>0)){let[t,n]=r.wx||r.wz?[r.wx,r.wz]:[r.fx,r.fz];s||(e.dashes--,e.vy=0,e.mode===i.WALLRUN&&(H(e,i.AIR),e.ev|=o.WALLRUN_END)),e.vx=t*16,e.vz=n*16,e.dash=60,e.ev|=o.DASH}let c=e.dash>50;e.mode===i.WALLRUN&&ut(e,n,r),z(e.mode)&&mt(e,n,r,c),e.mode===i.AIR&&ht(e,n,r,c);let l=c&&e.vy<=0?0:e.mode===i.WALLRUN?ae:1,u=e.mode,d=st(e,n,B(e),l,z(u));if(d>=0){if(!z(e.mode)){if(e.ev|=o.LAND|(e.mode===i.WALLRUN?o.WALLRUN_END:0),e.fall=d,e.jumps=1,e.dashes=1,e.wall=a.NONE,r.keys&t.CROUCH){let t=L(e.vx,e.vz)>=T;H(e,t?i.SLIDE:i.CROUCH),e.ev|=t?o.SLIDE_START:0}else H(e,i.GROUND)}e.coyote=6}else z(e.mode)&&(e.ev|=e.mode===i.SLIDE?o.SLIDE_END:0,H(e,i.AIR));if(e.mode===i.AIR){let t=et(e,n);t?ft(e,t):dt(e,n,r)}},mt=(e,n,r,a)=>{let s=(r.keys&t.CROUCH)!==0;if(e.buffer>0&&(e.mode===i.GROUND||Ye(e,n))){e.ev|=e.mode===i.SLIDE?o.SLIDE_END:0,H(e,i.AIR),W(e,7);return}let c=L(e.vx,e.vz);if(e.mode===i.GROUND&&s){let t=c>=T;H(e,t?i.SLIDE:i.CROUCH),e.ev|=t?o.SLIDE_START:0}else e.mode===i.SLIDE&&(e.t>=60||c<4.5||r.stumble)?(e.ev|=o.SLIDE_END,H(e,!s&&Ye(e,n)?i.GROUND:i.CROUCH)):e.mode===i.SLIDE&&!s&&Ye(e,n)?(e.ev|=o.SLIDE_END,H(e,i.GROUND)):e.mode===i.CROUCH&&!s&&Ye(e,n)&&H(e,i.GROUND);if(!a){if(r.stumble){if(c>2.5){let t=Math.max(pe,c-12*j)/c;e.vx*=t,e.vz*=t}else ot(e,at(e,n,r,B(e)),pe)}else if(e.mode===i.SLIDE){let t=Math.max(0,c-4*j)/c;e.vx*=t,e.vz*=t}else if(e.mode===i.CROUCH)ot(e,at(e,n,r,ne),3);else{let i=(r.keys&t.SPRINT)!==0&&r.fwd;ot(e,at(e,n,r,w),i?9:6)}}},ht=(e,t,n,r)=>{if(e.buffer>0&&(e.coyote>0?W(e,7):e.jumps>0&&!nt(e,t)&&(e.jumps--,W(e,6),e.ev=e.ev&~o.JUMP|o.DOUBLE)),r||!n.wx&&!n.wz)return;let i=L(e.vx,e.vz);e.vx+=n.wx*14*j,e.vz+=n.wz*14*j,it(e,Math.max(i,6))},gt=(e,n,r,a=0)=>{e.yaw=ze(n.yaw),e.pitch=Math.max(-te,Math.min(te,n.pitch));let o=(n.keys&t.FORWARD?1:0)-(n.keys&t.BACK?1:0),s=(n.keys&t.RIGHT?1:0)-(n.keys&t.LEFT?1:0),c=rt(e)?1/0:L(o,s)||1,[l,u]=P(e.yaw),d=t=>(n.keys&t)!==0&&(e.held&t)===0,f=e.stun>0,p={keys:n.keys,stumble:f,jump:!f&&d(t.JUMP),dash:!f&&d(t.DASH),fwd:o>0,wx:(l*o-u*s)/c,wz:(u*o+l*s)/c,fx:l,fz:u},m=e.mode;e.ev=0,e.fall=0,p.jump&&(e.buffer=7),f&&e.stun--,e.dash>0&&(e.dash--,e.dash===50&&it(e,10)),e.mode===i.HANG&&ct(e,r,p),e.mode===i.CLIMB?lt(e,r):e.mode!==i.HANG&&pt(e,r,p),e.slow&&(e.slow--,it(e,3)),e.y<r.def.floor&&Ue(e,r,a),e.t=e.mode===m?Math.min(255,e.t+1):e.t,e.buffer=Math.max(0,e.buffer-1),e.mode===i.AIR&&m===i.AIR&&(e.coyote=Math.max(0,e.coyote-1)),e.held=n.keys&(t.JUMP|t.DASH),e.ground=z(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)},_t=.7,vt=e=>{let[r,i]=[e&t.LEFT,e&t.RIGHT];return r&&!i?n.LEFT:i&&!r?n.RIGHT:e&t.FORWARD?n.THRUST:n.SLASH},G=e=>{let t=E[e.cut??0];return e.heavy?{...t,ticks:Math.round((t.ticks-t.hold)*ge),strike:Math.round((t.strike-t.hold)*ge),reach:t.reach+be,arc:t.arc*xe,hp:t.hp+ye}:t},yt=(e,t,n)=>{let{reach:r,arc:i}=G(t),[a,o]=P(t.yaw),s=[t.x,t.y+_t*B(t),t.z];return n.filter(n=>{let[c,l]=[n.x-t.x,n.z-t.z],u=Math.hypot(c,l);if(u-.4>r||t.y>=n.y+B(n)||n.y>=t.y+B(t))return!1;let d=u>.4?Math.abs(Math.atan2(a*l-o*c,a*c+o*l)):0,f=u>.4?Math.asin(C/u):Math.PI;return d<=i+f&&!Ie(e,s,[n.x,n.y+.7*B(n),n.z])})},bt=(e,t)=>{if(!t.wield||!t.swing||e.lock||t.lock)return!1;let n=G(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,G(e).reach)&&o(e,r,i)&&o(t,-r,-i)},xt=e=>{let[t,r]=P(e.yaw),i=e.cut??0;return i===n.LEFT?[-r,t]:i===n.RIGHT?[r,-t]:[t,r]},St=(e,t)=>{let[i,a]=P(e.yaw),[o,s]=P(t.yaw),[c,l]=[t.x-e.x,t.z-e.z],u=-a*c+i*l,d=Math.sqrt(Math.max(C*C-u*u,0)),[f,p]=[a*u-i*d,-i*u-a*d],m=-s*f+o*p,h=(e.cut??0)%4;if(h===n.SLASH)return Math.abs(m)<=Ae?r.HEAD:m>0?r.ARM_R:r.ARM_L;let g=(e.y+_t*B(e)+Math.tan(e.pitch)*Math.hypot(c,l)-t.y)/B(t);if(g>Oe)return r.HEAD;let _=h===n.THRUST?m>0:(h===n.LEFT?1:-1)*(i*o+a*s)<0;return g<ke?_?r.LEG_R:r.LEG_L:h===n.THRUST&&Math.abs(m)<=Ae?r.NONE:_?r.ARM_R:r.ARM_L},K=()=>({state:e.HOME,by:0,x:0,y:0,z:0,left:0}),Ct=60,wt=class{score=[0,0];over=!1;flags=[K(),K()];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=A(this.world,[e.x,e.y+.05,e.z],[0,-1,0],Ct);t<Ct&&(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(t){return this.flags.findIndex(n=>n.state===e.CARRIED&&n.by===t)}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=[K(),K()],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(t){if(this.over)return--this.clock<=0?(this.reset(),`start`):void 0;for(let t of[0,1]){let n=this.flags[t];this.lock[t].left--,this.hold[t]--,n.state===e.DROPPED&&(n.left=Math.ceil(--this.back[t]/60),this.back[t]<=0&&(this.flags[t]=K()))}for(let n of[0,1]){let r=this.flags[n];if(r.state===e.CARRIED)continue;let i=r.state===e.HOME?this.world.def.teams[n].base:[r.x,r.y,r.z],a=t.filter(e=>Tt(e.state,i)),o=r.state===e.DROPPED&&this.hold[n]<=0?a.find(e=>e.team===n):void 0,s=a.find(e=>e.team!==n&&(e.id!==this.lock[n].id||this.lock[n].left<=0));if(o){let e=this.mates.get(o.id);e&&e.returns++,this.flags[n]=K()}else s&&(this.flags[n]={...K(),state:e.CARRIED,by:s.id})}for(let n of t){let t=this.carrying(n.id);if(t>=0&&this.flags[n.team].state===e.HOME&&Tt(n.state,this.world.def.teams[n.team].base)){this.score[n.team]++;let e=this.mates.get(n.id);e&&e.caps++,this.flags[t]=K()}}if(this.score.some(e=>e>=this.rules.scoreLimit)||--this.clock<=0)return this.over=!0,this.clock=600,`end`}dropAt(t,[n,r,i]){this.flags[t]={state:e.DROPPED,by:0,x:n,y:r,z:i,left:10},this.back[t]=600}},Tt=(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],q=(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},Et=e=>{if(e.mode===i.GROUND){if(e.cut===n.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===n.LEAP&&(e.vy=De,e.ev|=o.JUMP)}},J={NONE:0,SHOT:1,CUT:2,RAIL:3,LASER:4},Dt=(e,n,r,a,o=!0)=>{let s=e.down>0,c=!s&&(e.lock??0)>0;if(gt(e,s||c?{...n,keys:0}:n,r,a),e.zapping=!1,e.zap=!!e.stun&&!!e.zap,s)return e.down>0&&!--e.down&&Ue(e,r,a),J.NONE;if(c)return Ot(e,n);let{rack:l,blade:u,rail:d,rifle:f}=r.def.teams[a],p=!!l&&q(e,l,1.2);o&&p&&!e.rack&&([e.ammo,e.mag]=[60,15]),e.rack=p,e.blade=!!e.blade||o&&!!u&&q(e,u,1.2);let m=!!d&&q(e,d,1.2);o&&m&&!e.inRail&&([e.rail,e.cap]=[240,80]),e.inRail=m;let h=!!f&&q(e,f,1.2);o&&h&&!e.inRifle&&([e.rifle,e.clip]=[240,60]),e.inRifle=h,e.cool=Math.max(0,e.cool-1);let g=e.mode===i.HANG||e.mode===i.CLIMB,{ticks:_,hold:v}=E[e.cut??0],y=!!e.swing&&!e.heavy&&_-(e.swing??0)===v;y&&e.wield&&o&&!g&&n.keys&t.FIRE?e.charge=Math.min((e.charge??0)+1,ve):y&&o&&!g&&(e.charge??0)>=_e?([e.heavy,e.charge]=[!0,0],e.swing=G(e).ticks):(e.charge=y?0:e.charge,e.swing=Math.max(0,(e.swing??0)-1),e.heavy=!!e.swing&&!!e.heavy);let b=[e.ammo>=0,!!e.blade,(e.rail??-1)>=0,(e.rifle??-1)>=0],x=n.keys&t.BLADE?1:n.keys&t.RAIL?2:n.keys&t.RIFLE?3:0,S=e.swing&&e.blade?1:b[x]?x:b.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],!o)return[e.charge,e.reload]=[0,0],J.NONE;let[C,w,ee,te]=S==3?[`clip`,60,e.rifle,96]:S==2?[`cap`,80,e.rail,90]:[`mag`,15,e.ammo,54],[ne,re]=[e[C]??0,Math.min(w,ee)];e.reload?--e.reload||(e[C]=re):S!=1&&ee>=0&&!g&&ne<re&&(!ne||n.keys&t.RELOAD)&&([e.reload,e.charge]=[te,0]);let T=G(e);if(e.swing&&T.ticks-e.swing===T.strike)return J.CUT;if((e.wield&&!y||e.railed||e.rifled||g||e.reload||!e.wield&&!e.mag)&&(e.charge=0),n.keys&t.FIRE&&!g){let r=E[e.cut??0].ticks-(e.swing??0),i=!!(n.keys&t.SPECIAL)&&(!e.swing||!e.heavy&&(e.cut??0)<4&&r<=18);if(e.wield&&(!e.swing||i))e.cut=vt(n.keys)+(i?4:0),[e.swing,e.charge]=[E[e.cut].ticks,0],Et(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,J.LASER}else if(e.railed){if(e.cap&&!e.reload)return e.rail--,e.cap--,e.zapping=!0,J.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(kt(e.charge),e.mag),e.charge=0,e.ammo-=e.power,e.mag-=e.power,e.shots=e.shots+1&255,e.cool=7,J.SHOT;return J.NONE},Ot=(e,n)=>{let r=!!(n.keys&t.FIRE);return e.pushes=(e.pushes??0)+ +(r&&!e.pressed)&255,e.pressed=r,e.away=n.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],J.NONE},kt=e=>e<10?1:1+Math.floor(4*(e-10)/50),At=-30,Y=(e,t,n,r,i,a=s.CONCRETE)=>({min:[e,At,t],max:[n,i,r],top:s.CONCRETE,side:a}),X=([e,t,n],[r,i,a],o,s=o,c)=>({min:[e,t,n],max:[r,i,a],top:o,side:s,tint:c});[Y(4,57.7,24,76,10),Y(4,36,24,53.5,10,s.GLASS),Y(4,20,24,36,12.4),Y(4,-5,24,7,12.4,s.GLASS),Y(27,20,47,50,8),Y(27,60,47,76,8,s.BRICK),X([9,12.2,39],[19,12.6,47],s.STEEL),...((e,t)=>[1,2,3,4,5,6].map(n=>X([12,t,e-n],[14,t+.4*n,e-n+1],s.CONCRETE)))(53,10),X([5,10,42],[5.5,14,42.5],s.STEEL),X([5,10,50],[5.5,14,50.5],s.STEEL),X([8,12.4,24],[20,12.85,24.45],s.STEEL),X([36,8,22],[37,14.5,48],s.PAINT,s.PAINT,[.15,.72,.62]),X([30,8,28],[34,10,32],s.CONCRETE),X([40,8,30],[44,10.2,34],s.PAINT,s.PAINT,[1,.3,.06]),X([28,9.2,44],[35,12,46],s.STEEL,s.PAINT,[.2,.42,1]),X([41.5,7.6,50],[42,8,60],s.STEEL),X([30,8,64],[34,9.6,68],s.PAINT,s.PAINT,[.2,.8,.3])];var Z=240,Q=[1,.22,.26],jt=[.2,.46,1],Mt=[1,.42,.08],Nt=[.12,.7,.62],$=(e,t,n,r,i,a,o)=>X([e,t,n],[r,i,a],s.PAINT,s.PAINT,o),Pt=(e,t,n,r,i,a,o,c=At)=>{let l=Math.ceil((o-a)/.46);return Array.from({length:l},(u,d)=>{let[f,p]=[t+(n-t)*d/l,t+(n-t)*(d+1)/l].sort((e,t)=>e-t),m=a+(o-a)*(d+1)/l;return e===0?X([f,c,r],[p,m,i],s.CONCRETE):X([r,c,f],[i,m,p],s.CONCRETE)})},Ft=(e,t,n,r,i,a,o)=>o.map((o,c)=>X([e+c*n,a,t+c*r],[e+c*n+4,o,t+c*r+i],s.STEEL,s.CONCRETE)),It=[Y(12,212,52,240,26,s.GLASS),$(12,26,212,52,26.12,212.5,Q),$(12,26,239.5,52,26.12,240,Q),$(12,26,212.5,12.5,26.12,239.5,Q),$(51.5,26,212.5,52,26.12,239.5,Q),$(11.6,12,222,12,25.8,232,Q),$(28,12,211.4,31,25.5,212,Q),X([19,26,222],[22,27.4,225],s.STEEL),X([42,26,222],[45,27.4,225],s.STEEL),X([29,26,229],[35,27.1,229.6],s.CONCRETE),X([24.5,26,215],[35,27.5,219],s.STEEL,s.PAINT,Q),Y(6,164,26,201,26,s.GLASS),Y(6,134,26,147,26,s.GLASS),Y(6,201,26,212,19),Y(15,147,26,164,19),X([14,26,164],[15,32,196],s.PAINT,s.PAINT,Nt),X([14,18,147],[15,32,164],s.PAINT,s.PAINT,Nt),X([14,26,134],[15,32,147],s.PAINT,s.PAINT,Nt),...Ft(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])=>X([e,19,t],[n,i,r],s.STEEL,s.CONCRETE)),X([20,26,178],[23,27.3,181],s.STEEL),X([8,26,176],[11,27.2,179],s.STEEL),X([8,26,190],[11,27.3,193],s.STEEL),X([20,26,140],[23,27.3,143],s.STEEL),Y(32,186,76,209,19),$(32,19,207.5,76,19.1,209,Q),...Ft(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])=>X([e,At,t],[n,i,r],s.STEEL,s.CONCRETE)),Y(32,166,64,182,21.2,s.GLASS),Y(32,140,64,161,19),X([40,21.2,172],[44,22.6,176],s.STEEL),X([52,19,148],[57,20.3,151],s.STEEL),X([38,19,196],[41,20.4,199],s.STEEL),X([60,19,200],[63,20.4,203],s.STEEL),X([52,19,190],[58,20.6,194],s.STEEL),X([66,19,204],[72,20.2,207],s.STEEL),X([56,21.2,170],[60,22.4,174],s.STEEL),X([34,19,152],[37,20.3,156],s.STEEL),...Ft(36,135,18,0,3,15,[17.2,17.2]),...Ft(6.5,129,6,0,4,15,[17.2,19.4,21.6,23.8]),Y(76,213,100,240,14.5,s.STEEL),$(76,14.5,238.5,100,14.6,240,Q),Y(76,185,100,209,14.5),Y(76,138,100,181,14.5,s.GLASS),X([80,15.7,158],[96,17.7,162],s.STEEL,s.PAINT,Mt),X([82,14.5,234],[85,15.9,237],s.STEEL),X([91,14.5,190],[94,15.9,193],s.STEEL),X([80,14.5,204],[83,15.6,207],s.STEEL),X([78,14.5,170],[81,15.9,173],s.STEEL),X([92,14.5,146],[95,15.7,149],s.STEEL),X([92,14.5,222],[96,15.8,226],s.STEEL),...Pt(0,76,52,226,232,14.5,26),...Pt(0,85,76,196,202,14.5,19,14.5)],Lt=[Y(6,106,62,134,15),Y(62,106,100,134,14.5),X([34,15,112],[54,17.2,128],s.CONCRETE),$(38,17.2,116,50,17.3,124,Mt),...[[35,113],[35,126.2],[51,113],[51,126.2]].map(([e,t])=>X([e,17.2,t],[e+.8,21.5,t+.8],s.STEEL)),X([34.6,21.5,112.6],[52.2,21.9,127.4],s.GLASS),X([14,15,114],[17,16.5,117],s.STEEL),X([14,15,123],[17,16.5,126],s.STEEL),X([56,15,114],[59,16.5,117],s.STEEL),X([56,15,123],[59,16.5,126],s.STEEL),X([15.35,25.5,106],[15.85,26,134],s.STEEL),X([70,14.5,108],[70.8,38,108.8],s.STEEL),X([70,14.5,131.2],[70.8,38,132],s.STEEL),X([66,14.5,110],[69,15.9,113],s.STEEL),X([66,14.5,127],[69,15.9,130],s.STEEL)],Rt=e=>({...e,min:[e.min[0],e.min[1],Z-e.max[2]],max:[e.max[0],e.max[1],Z-e.min[2]],tint:e.tint===Q?jt:e.tint}),zt=(e,t,n)=>[...[16,22,28,34,40].map(n=>[n,26,t,e]),...[19,31,43].map(t=>[t,26,n,e])],Bt=[[20,26,190],[48,21.2,172],[48,19,200],[88,14.5,198]],Vt=[[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]],Ht=[[19.5,26,179],[46,19,152],[39.5,21.2,172],[88,14.5,186],[88,14.5,207]],Ut={name:`Highline`,brushes:[...It,...It.map(Rt),...Lt],teams:[{base:[32,26,224],spawns:zt(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:zt(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:[...Bt,...Bt.map(([e,t,n])=>[e,t,Z-n]),[24,15,112],[24,15,128]],ammo:[...Vt,...Vt.map(([e,t,n])=>[e,t,Z-n]),[12,15,116],[12,15,124]],cells:[...Ht,...Ht.map(([e,t,n])=>[e,t,Z-n]),[28,15,Z/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]},Wt=40/60,Gt=Se/60,Kt=(e,t=0)=>{let[n,r,i,a]=[Math.sin(e.yaw),Math.cos(e.yaw),Math.sin(e.pitch),Math.cos(e.pitch)];return{id:e.shots,by:e.id,team:t,x:e.x,y:e.y+We(e),z:e.z,dx:-n*a,dy:i,dz:-r*a,left:80,burst:!1,power:e.power??1}},qt=(e,t=0)=>({...Kt(e,t),id:e.shots^128,left:Ce,power:1,arc:e.cut}),Jt=e=>e.arc?Gt:Wt,Yt=(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},Xt=(e,t,n,r)=>{let i=[t.x,t.y,t.z],a=[t.dx,t.dy,t.dz],o=Math.min(n,t.left),s=A(e,i,a,o,he),c;for(let e of r){let n=Yt(i,a,e,C+(t.arc?we:he),B(e));n<s&&([s,c]=[n,e])}return t.burst=s<o,t.left-=s,[t.x,t.y,t.z]=[i[0]+a[0]*s,i[1]+a[1]*s,i[2]+a[2]*s],c},Zt=(e,t,n=[],r=30,[i,a]=[0,0])=>{let o=[t.x,t.y+We(t),t.z],[s,c]=[t.yaw+i,t.pitch+a],l=Math.cos(c),u=[-Math.sin(s)*l,Math.sin(c),-Math.cos(s)*l],d=A(e,o,u,r),f;for(let e of n){let t=Yt(o,u,e,C,B(e));t<d&&([d,f]=[t,e])}return{o,d:u,t:d,hit:f}},Qt=e=>[je*Math.sin(e*2.4),je*Math.cos(e*1.7)],$t=(e,t,n=[])=>Zt(e,t,n,60,Qt(t.shots)),en=e=>e.mode===i.SLIDE||e.dash>50,tn=(e,t)=>Math.hypot(e.x-t.x,e.z-t.z)<1.1&&e.y<t.y+B(t)&&t.y<e.y+B(e),nn=20,rn=2,an=(e,t)=>Array.from(e).slice(0,t).join(``).trim(),on=e=>an((typeof e==`string`?e:``).replace(/\s+/g,` `).replace(/\p{Cc}/gu,``).trim(),16),sn=(e,t)=>{let n=e;for(let r=2;t.includes(n);r++)n=`${an(e,15-`${r}`.length)} ${r}`;return n},cn=(e,t)=>{let n=setInterval(e,t);return()=>clearInterval(n)},ln={lock:0,foe:0,pushes:0,pressed:!1,away:0},un=({x:e,y:t,z:n,yaw:r})=>({x:e,y:t,z:n,yaw:r}),dn=class{peers=/* @__PURE__ */ new Map;ticks=0;history=[];world;ctf;halt;rules;rr=[0,0];gone;balls=[];constructor(e={},t=Ut){this.rules={...Me,...e},this.world=Fe(t),this.ctf=new wt(this.world,this.rules),this.gone=[...t.packs??[],...t.ammo??[],...t.cells??[]].map(()=>0)}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=S(t);n===null&&r?.t===`join`&&this.join(e,r.name);return}let r=n&&y(t);if(r&&n.bank>0){n.bank--;let e=n.state.slow??0,t=Dt(n.state,r,this.world,n.info.team,!this.ctf.over);this.ctf.moved(n.state),this.tackle(n,r.view),t===J.SHOT?this.shoot(n,r.view):t===J.CUT?this.cut(n,r.view):t===J.RAIL?this.rail(n,r.view):t===J.LASER&&this.laser(n,r.view),n.burn=e?(n.burn??0)+1:0,e&&!(n.burn%60)&&this.fry(n),this.duel(n),n.ack=r.seq}}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.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,Jt(e));this.heal(e);let n=this.ctf.tick(e.filter(e=>!e.state.down).map(e=>({id:e.info.id,team:e.info.team,state:e.state})));if(n===`end`?this.end(e):n===`start`&&this.restart(e),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=x({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});e.forEach(e=>e.conn.send(n)),this.balls=this.balls.filter(e=>!e.burst&&e.left>0)}}start(e=cn){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<nn;e++)this.tick(),r-=t;r%=t},t)}stop(){this.halt?.(),this.halt=void 0}rewind(e,t=0){let n=this.players().filter(t=>t.info.id!==e).map(e=>e.state),[r,i]=[this.history[0],this.history.at(-1)];if(!r||!i)return n;let a=((this.ticks-t+32768)%65536+65536)%65536-32768,o=Math.min(Math.max(this.ticks-a,r.tick),i.tick),s=0;for(;s+1<this.history.length&&this.history[s+1].tick<=o;)s++;let[c,l]=[this.history[s],this.history[s+1]??this.history[s]],u=l.tick>c.tick?(o-c.tick)/(l.tick-c.tick):0,d=(e,t)=>e+(t-e)*u;return n.map(e=>{let t=c.players.find(t=>t.id===e.id),n=l.players.find(t=>t.id===e.id);return t&&n?{...n,x:d(t.x,n.x),y:d(t.y,n.y),z:d(t.z,n.z)}:n??t??e})}tackle(e,t){let n=e.state;if(n.down||!en(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=>tn(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=Ge(n),[s,c]=o>.001?[n.vx/o,n.vz/o]:P(n.yaw);U(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=0,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:r.NONE,rail:-1,railed:!1,rifle:-1,clip:0,rifled:!1,zapping:!1,slow:0}),this.ctf.drop(e.state),!0)}shoot(e,t=0,n=Kt(e.state,e.info.team)){let r=(this.ticks-t+65536)%65536;this.balls.push(n),this.fly(n,Math.min(r<32768?r:0,12)*Jt(n));let i=this.balls.filter(e=>!e.burst);i.length>64&&(i[0].burst=!0)}fly(e,t){let n=this.players(),i=n.filter(t=>t.info.team!==e.team&&!t.state.down),a=Xt(this.world,e,t,i.map(e=>e.state)),o=i.find(e=>e.state===a);if(!o)return;let s=n.find(t=>t.info.id===e.by);if(s&&(s.state.hits=s.state.hits+1&255),!e.arc)this.harm(o,e.power??1);else if(this.harm(o,E[e.arc].hp)){let t=s&&{...s.state,cut:e.arc,yaw:Math.atan2(-e.dx,-e.dz)};o.state.lost=t?St(Object.assign(t,{x:e.x-e.dx,y:e.y-e.dy-_t*B(t),z:e.z-e.dz,pitch:Math.asin(e.dy)}),o.state):r.NONE}else{let t=Math.hypot(e.dx,e.dz)||1;U(o.state,e.dx/t,e.dz/t,Te,Ee),o.state.zap=!0,o.by=e.by,this.ctf.drop(o.state)}}cut(e,t){if(e.state.cut===n.ARC_L||e.state.cut===n.ARC_R){this.shoot(e,t,qt(e.state,e.info.team));return}let r=yt(this.world,e.state,this.enemies(e,t)),i=this.players().filter(e=>r.some(t=>t.id===e.info.id)),a=i.find(t=>bt(e.state,{...t.state,...un(r.find(e=>e.id===t.info.id))}));if(a){for(let[t,n]of[[e,a],[a,e]])Object.assign(t.state,{...ln,lock:240,foe:n.info.id,pressed:!0}),Object.assign(t.state,{swing:0,charge:0,stun:0,zap:!1,vx:0,vz:0});i=i.filter(e=>e!==a)}if(i.length){e.state.hits=e.state.hits+1&255;for(let t of i){let n=r.find(e=>e.id===t.info.id);if(this.harm(t,G(e.state).hp))t.state.lost=St(e.state,n);else{let[n,r]=xt(e.state);U(t.state,n,r,24,4*(e.state.heavy?ge:1)),t.state.zap=!0,t.by=e.info.id}}}}rail(e,t){let{hit:n}=Zt(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))}}laser(e,t){let{hit:n}=$t(this.world,e.state,this.enemies(e,t)),r=this.players().find(e=>e.info.id===n?.id);r&&(e.state.hits=e.state.hits+1&255,r.graze=((r.graze??0)+1)%2,r.graze||this.harm(r,1))}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,ln);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,ln),Object.assign(n.state,ln),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);U(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;U(t,-e/i,-r/i),U(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)&&q(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}})}place(e,t,n){let r=this.world.def.teams[t].spawns.findIndex((r,i)=>{let{x:a,z:o}=He(e,this.world,i,t);return!n.some(e=>Math.hypot(e.x-a,e.z-o)<rn)});return He(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);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){let n=this.players();if(n.length>=this.rules.maxPlayers){e.send(JSON.stringify({t:`full`}));return}let r=0;for(;n.some(e=>e.info.id===r);)r++;let i=n.filter(e=>e.info.team===0).length,a=+(i>n.length-i),o={conn:e,info:{id:r,name:sn(on(t)||`Player ${r}`,n.map(e=>e.info.name)),team:a,color:me[a]},state:this.place(r,a,n.map(e=>e.state)),bank:10,ack:65535,by:0,tackled:-30};this.peers.set(e,o),this.ctf.join(r,a,o.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})))}},fn=(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()},pn=(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 dn(t),s.start(fn),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`&&S(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{pn as localSocket};
package/dist/server.js CHANGED
@@ -88,20 +88,25 @@ var CUTS = [
88
88
  hold: -1
89
89
  }),
90
90
  (
91
- /** SPIN_L, then SPIN_R: a full turn on himself, the blade out all round him. */
91
+ /**
92
+ * ARC_L, then ARC_R (the user, 2026-11-08): a heavy cut down across, from high on its side to low
93
+ * on the other. It strikes no one itself: at its strike it throws an arc of energy (wave(),
94
+ * plasma.ts) that takes `hp` and floors the foe it meets (FLOOR_TICKS). Its reach and arc count
95
+ * only for a saber lock.
96
+ */
92
97
  {
93
- ticks: 48,
94
- strike: 24,
95
- reach: 2.3,
96
- arc: Math.PI,
98
+ ticks: 46,
99
+ strike: 20,
100
+ reach: 2.15,
101
+ arc: .6,
97
102
  hp: 3,
98
103
  hold: -1
99
104
  }),
100
105
  {
101
- ticks: 48,
102
- strike: 24,
103
- reach: 2.3,
104
- arc: Math.PI,
106
+ ticks: 46,
107
+ strike: 20,
108
+ reach: 2.15,
109
+ arc: .6,
105
110
  hp: 3,
106
111
  hold: -1
107
112
  },
@@ -133,6 +138,19 @@ var [HEAVY_HP, HEAVY_REACH, HEAVY_ARC] = [
133
138
  .5,
134
139
  1.4
135
140
  ];
141
+ /**
142
+ * The arc of energy an ARC cut throws: it leaves the eye along the look at ARC_SPEED m/s, flies
143
+ * ARC_RANGE metres at most, stops on the first brush, and meets a body ARC_R metres off its line
144
+ * (it is about 1.5 m wide). The foe it meets is floored: a stumble of FLOOR_TICKS (a second on the
145
+ * ground, no move: floored(), physics.ts; the stun field holds 63 at most), thrown ARC_KNOCK m/s the way it flies, and he drops the flag.
146
+ * ARC_RANGE / ARC_SPEED stays under an ARC cut's ticks: one arc is gone before the next is thrown.
147
+ */
148
+ var [ARC_SPEED, ARC_RANGE, ARC_R] = [
149
+ 24,
150
+ 15,
151
+ .6
152
+ ];
153
+ var [FLOOR_TICKS, ARC_KNOCK] = [63, 7];
136
154
  /** The leap's jump (m/s up), from a floor only: 1.4 m up and down in 45 ticks, the blow (LEAP's strike) just before the landing. */
137
155
  var LEAP_SPEED = 7.5;
138
156
  /**
@@ -198,8 +216,9 @@ var KEY = {
198
216
  * The katana's cuts (PlayerState.cut, constants CUTS), chosen by the keys held when FIRE starts
199
217
  * one: LEFT or RIGHT (one of them) cuts across from that side, else FORWARD thrusts, else (back or
200
218
  * no key) it slashes down from above. With SPECIAL (a double click) each has its special, the cut
201
- * plus SPECIAL_CUT: the thrust a LUNGE (a dash forward on the point), a cut across a SPIN (a full
202
- * turn on himself, the blade out all round), the slash a LEAP (a jump and a blow down on landing).
219
+ * plus SPECIAL_CUT: the thrust a LUNGE (a dash forward on the point), a cut across an ARC (a heavy
220
+ * cut down across the body that throws an arc of energy ahead, see wave(), plasma.ts), the slash a
221
+ * LEAP (a jump and a blow down on landing).
203
222
  */
204
223
  var CUT = {
205
224
  THRUST: 0,
@@ -207,8 +226,8 @@ var CUT = {
207
226
  RIGHT: 2,
208
227
  SLASH: 3,
209
228
  LUNGE: 4,
210
- SPIN_L: 5,
211
- SPIN_R: 6,
229
+ ARC_L: 5,
230
+ ARC_R: 6,
212
231
  LEAP: 7
213
232
  };
214
233
  /**
@@ -715,6 +734,8 @@ var enter = (p, mode) => {
715
734
  p.mode = mode;
716
735
  p.t = 0;
717
736
  };
737
+ /** Whether an arc of energy floored `p` (FLOOR_TICKS): he lies down for the stun's ticks over SHOCK_TICKS, and does not move. */
738
+ var floored = (p) => !!p.zap && p.stun > 24;
718
739
  /**
719
740
  * A tackle lands on the player: he stumbles for `ticks` (STUMBLE_TICKS) and is thrown `knock`
720
741
  * (STUMBLE_KNOCK) m/s along (dx, dz), a unit vector (the tackler's way). It ends a dash, a wall-run,
@@ -1070,7 +1091,7 @@ var move = (p, i, w, team = 0) => {
1070
1091
  p.pitch = Math.max(-MAX_PITCH, Math.min(MAX_PITCH, i.pitch));
1071
1092
  const f = (i.keys & KEY.FORWARD ? 1 : 0) - (i.keys & KEY.BACK ? 1 : 0);
1072
1093
  const s = (i.keys & KEY.RIGHT ? 1 : 0) - (i.keys & KEY.LEFT ? 1 : 0);
1073
- const n = len(f, s) || 1;
1094
+ const n = floored(p) ? Infinity : len(f, s) || 1;
1074
1095
  const [fx, fz] = forward(p.yaw);
1075
1096
  const pressed = (bit) => (i.keys & bit) !== 0 && (p.held & bit) === 0;
1076
1097
  const stumbling = p.stun > 0;
@@ -1164,7 +1185,7 @@ var strike = (w, p, foes) => {
1164
1185
  const wide = d > .4 ? Math.asin(PLAYER_R / d) : Math.PI;
1165
1186
  return off <= arc + wide && !hidden(w, o, [
1166
1187
  f.x,
1167
- f.y + CHEST * heightOf(f),
1188
+ f.y + .7 * heightOf(f),
1168
1189
  f.z
1169
1190
  ]);
1170
1191
  });
@@ -1191,16 +1212,11 @@ var crossing = (p, f) => {
1191
1212
  /**
1192
1213
  * The way the shock of the cut of `p` throws the foe `f`, a unit vector on the floor plane: along
1193
1214
  * his look for a thrust, a slash and their specials; a cut across ends on the opposite side to the
1194
- * one it starts from, so LEFT throws to his right and RIGHT to his left; a spin throws out from him.
1215
+ * one it starts from, so LEFT throws to his right and RIGHT to his left.
1195
1216
  */
1196
- var knock = (p, f) => {
1217
+ var knock = (p) => {
1197
1218
  const [fx, fz] = forward(p.yaw);
1198
1219
  const c = p.cut ?? 0;
1199
- if (c === CUT.SPIN_L || c === CUT.SPIN_R) {
1200
- const [dx, dz] = [f.x - p.x, f.z - p.z];
1201
- const d = Math.hypot(dx, dz);
1202
- return d > 1e-6 ? [dx / d, dz / d] : [fx, fz];
1203
- }
1204
1220
  return c === CUT.LEFT ? [-fz, fx] : c === CUT.RIGHT ? [fz, -fx] : [fx, fz];
1205
1221
  };
1206
1222
  /**
@@ -2632,8 +2648,9 @@ var HIGHLINE = {
2632
2648
  ]
2633
2649
  };
2634
2650
  // src/shared/plasma.ts
2635
- /** Metres a ball flies in a tick. */
2651
+ /** Metres a ball flies in a tick, and an arc. */
2636
2652
  var PLASMA_STEP = 40 / 60;
2653
+ var ARC_STEP = ARC_SPEED / 60;
2637
2654
  /**
2638
2655
  * The ball of the shot `p` has just fired (`p` is the state after the step that fired): from the
2639
2656
  * eye of the mode along the look, GUN_RANGE metres to go, named by his `shots` count, as strong
@@ -2662,6 +2679,20 @@ var launch = (p, team = 0) => {
2662
2679
  };
2663
2680
  };
2664
2681
  /**
2682
+ * The arc of energy the ARC cut of `p` throws at its strike (`p` the state after that step): from
2683
+ * the eye along the look like a ball, ARC_RANGE metres to go, its CUT in `arc`. Its id is the
2684
+ * `shots` count with the top bit turned, apart from his balls' (one arc is gone before the next).
2685
+ */
2686
+ var wave = (p, team = 0) => ({
2687
+ ...launch(p, team),
2688
+ id: p.shots ^ 128,
2689
+ left: ARC_RANGE,
2690
+ power: 1,
2691
+ arc: p.cut
2692
+ });
2693
+ /** Metres the flight `b` goes in a tick. */
2694
+ var stepOf = (b) => b.arc ? ARC_STEP : PLASMA_STEP;
2695
+ /**
2665
2696
  * Distance at which the ray from `o` along the unit `d` enters the upright cylinder of radius `r`
2666
2697
  * on `c`'s feet, `h` tall; Infinity on a miss.
2667
2698
  */
@@ -2682,8 +2713,8 @@ var cylinder = (o, d, c, r, h) => {
2682
2713
  };
2683
2714
  /**
2684
2715
  * Flies `b` on by `m` metres (at most what it has left) as a sphere of PLASMA_R: it stops and
2685
- * bursts on the first brush, or on the first of `foes` whose body (a cylinder PLASMA_R wider) it
2686
- * enters. Returns the foe it burst on.
2716
+ * bursts on the first brush, or on the first of `foes` whose body (a cylinder PLASMA_R wider, ARC_R
2717
+ * for an arc) it enters. Returns the foe it burst on.
2687
2718
  */
2688
2719
  var fly = (w, b, m, foes) => {
2689
2720
  const o = [
@@ -2700,7 +2731,7 @@ var fly = (w, b, m, foes) => {
2700
2731
  let t = ray(w, o, d, go, PLASMA_R);
2701
2732
  let hit;
2702
2733
  for (const f of foes) {
2703
- const u = cylinder(o, d, f, PLAYER_R + PLASMA_R, heightOf(f));
2734
+ const u = cylinder(o, d, f, PLAYER_R + (b.arc ? ARC_R : PLASMA_R), heightOf(f));
2704
2735
  if (u < t) [t, hit] = [u, f];
2705
2736
  }
2706
2737
  b.burst = t < go;
@@ -2819,7 +2850,7 @@ var encodeSnapshot = (s) => {
2819
2850
  ].forEach((c, k) => v.setInt16(o + 2 + 2 * k, clamp16(c * BALL_POS)));
2820
2851
  v.setUint8(o + 8, Math.round(Math.atan2(-b.dx, -b.dz) * YAW8) & 255);
2821
2852
  v.setInt8(o + 9, Math.round(Math.asin(Math.max(-1, Math.min(1, b.dy))) * PITCH8));
2822
- v.setUint8(o + 10, b.power ?? 1);
2853
+ v.setUint8(o + 10, b.arc ? 128 | b.arc : b.power ?? 1);
2823
2854
  o += 11;
2824
2855
  }
2825
2856
  return v.buffer;
@@ -3020,7 +3051,7 @@ var Room = class {
3020
3051
  }
3021
3052
  const now = ++this.ticks;
3022
3053
  for (const p of players) p.bank = Math.min(10, p.bank + 1);
3023
- for (const b of this.balls) if (!b.burst && b.left > 0) this.fly(b, PLASMA_STEP);
3054
+ for (const b of this.balls) if (!b.burst && b.left > 0) this.fly(b, stepOf(b));
3024
3055
  this.heal(players);
3025
3056
  const turn = this.ctf.tick(players.filter((p) => !p.state.down).map((p) => ({
3026
3057
  id: p.info.id,
@@ -3169,19 +3200,22 @@ var Room = class {
3169
3200
  return true;
3170
3201
  }
3171
3202
  /**
3172
- * A shot of `p` went off at the view tick `view`: its ball starts where `p` saw it start, flown
3173
- * on by his lag (the view tick to now, at most PLASMA_LAG ticks) against the others as they are
3174
- * now. Past PLASMA_MAX balls in flight, the oldest bursts.
3203
+ * A shot of `p` went off at the view tick `view`: its ball (or the arc `b` of an ARC cut) starts
3204
+ * where `p` saw it start, flown on by his lag (the view tick to now, at most PLASMA_LAG ticks)
3205
+ * against the others as they are now. Past PLASMA_MAX balls in flight, the oldest bursts.
3175
3206
  */
3176
- shoot(p, view = 0) {
3177
- const b = launch(p.state, p.info.team);
3207
+ shoot(p, view = 0, b = launch(p.state, p.info.team)) {
3178
3208
  const lag = (this.ticks - view + 65536) % 65536;
3179
3209
  this.balls.push(b);
3180
- this.fly(b, Math.min(lag < 32768 ? lag : 0, 12) * PLASMA_STEP);
3210
+ this.fly(b, Math.min(lag < 32768 ? lag : 0, 12) * stepOf(b));
3181
3211
  const live = this.balls.filter((q) => !q.burst);
3182
3212
  if (live.length > 64) live[0].burst = true;
3183
3213
  }
3184
- /** Flies the ball `b` on by `m` metres: one that bursts on an enemy who is up takes its power in hp from him, and counts a hit to its shooter. */
3214
+ /**
3215
+ * Flies the ball `b` on by `m` metres: one that bursts on an enemy who is up takes its power in hp
3216
+ * from him, and counts a hit to its shooter. An arc takes its cut's hp; one it does not put down
3217
+ * is floored (FLOOR_TICKS, `zap`), thrown ARC_KNOCK m/s the way it flies, and drops the flag.
3218
+ */
3185
3219
  fly(b, m) {
3186
3220
  const peers = this.players();
3187
3221
  const foes = peers.filter((q) => q.info.team !== b.team && !q.state.down);
@@ -3190,7 +3224,26 @@ var Room = class {
3190
3224
  if (!foe) return;
3191
3225
  const by = peers.find((q) => q.info.id === b.by);
3192
3226
  if (by) by.state.hits = by.state.hits + 1 & 255;
3193
- this.harm(foe, b.power ?? 1);
3227
+ if (!b.arc) this.harm(foe, b.power ?? 1);
3228
+ else if (this.harm(foe, CUTS[b.arc].hp)) {
3229
+ const from = by && {
3230
+ ...by.state,
3231
+ cut: b.arc,
3232
+ yaw: Math.atan2(-b.dx, -b.dz)
3233
+ };
3234
+ foe.state.lost = from ? limbOf(Object.assign(from, {
3235
+ x: b.x - b.dx,
3236
+ y: b.y - b.dy - CHEST * heightOf(from),
3237
+ z: b.z - b.dz,
3238
+ pitch: Math.asin(b.dy)
3239
+ }), foe.state) : LIMB.NONE;
3240
+ } else {
3241
+ const n = Math.hypot(b.dx, b.dz) || 1;
3242
+ stumble(foe.state, b.dx / n, b.dz / n, FLOOR_TICKS, ARC_KNOCK);
3243
+ foe.state.zap = true;
3244
+ foe.by = b.by;
3245
+ this.ctf.drop(foe.state);
3246
+ }
3194
3247
  }
3195
3248
  /**
3196
3249
  * A cut of `p` struck at the view tick `view`: every enemy it reaches as `p` drew him is hit
@@ -3200,6 +3253,10 @@ var Room = class {
3200
3253
  * crosses where `p` drew him (`limbOf`).
3201
3254
  */
3202
3255
  cut(p, view) {
3256
+ if (p.state.cut === CUT.ARC_L || p.state.cut === CUT.ARC_R) {
3257
+ this.shoot(p, view, wave(p.state, p.info.team));
3258
+ return;
3259
+ }
3203
3260
  const seen = strike(this.world, p.state, this.enemies(p, view));
3204
3261
  let foes = this.players().filter((q) => seen.some((s) => s.id === q.info.id));
3205
3262
  const locked = foes.find((q) => crossing(p.state, {
@@ -3231,7 +3288,7 @@ var Room = class {
3231
3288
  const drawn = seen.find((s) => s.id === foe.info.id);
3232
3289
  if (this.harm(foe, swingOf(p.state).hp)) foe.state.lost = limbOf(p.state, drawn);
3233
3290
  else {
3234
- const [dx, dz] = knock(p.state, drawn);
3291
+ const [dx, dz] = knock(p.state);
3235
3292
  stumble(foe.state, dx, dz, 24, 4 * (p.state.heavy ? HEAVY : 1));
3236
3293
  foe.state.zap = true;
3237
3294
  foe.by = p.info.id;
@@ -6,7 +6,7 @@ import type { Vec3 } from './mesh';
6
6
  export declare const CATCH = 0.12;
7
7
  export declare const TRAIL = 1.2;
8
8
  export interface Balls {
9
- /** The own player fired: `p` is his state after the step, `now` the time of the step (ms). */
9
+ /** The own player fired, or threw an arc with the katana: `p` is his state after the step, `now` the time of the step (ms). */
10
10
  fire(p: PlayerState, now: number): void;
11
11
  /** The balls of a snapshot received at `now` (ms); `me` is the own id. */
12
12
  snapshot(balls: Ball[], me: number, now: number): void;
@@ -7,6 +7,8 @@ export interface Orb {
7
7
  tail: number;
8
8
  /** Its strength, 1 to CHARGE_MAX: a charged ball is bigger. Absent reads 1. */
9
9
  power?: number;
10
+ /** An arc of energy, not a ball: the CUT that threw it (Ball.arc). */
11
+ arc?: number;
10
12
  }
11
13
  /** Seconds a muzzle flash, a splash and a spark last. */
12
14
  export declare const FLASH = 0.06;
@@ -16,7 +16,7 @@ export interface Body {
16
16
  aim(target: Vec3): void;
17
17
  /** The muzzle of the gun in the right hand, in the camera's space (right, up, forward), as of the last update. */
18
18
  muzzle(): Vec3;
19
- /** How far round a spin, and a share of the trunk's twist in a cut, have turned the body as of the last update (radians, whirl(), trunk()): the drawn view turns with it. */
19
+ /** How far a share of the trunk's twist in a cut has turned the body as of the last update (radians, trunk()): the drawn view turns with it. */
20
20
  spun(): number;
21
21
  /** The joints for a camera at `eye`; undefined without a player, or with the camera away from the body. */
22
22
  pose(eye: Vec3, yaw: number, pitch: number, roll?: number): Solved | undefined;
@@ -1,13 +1,15 @@
1
1
  import type { FlagState, PlayerState } from '../shared/types';
2
2
  import type { Vec3 } from './mesh';
3
+ import type { Quat } from './rig';
3
4
  /** One flag to draw. */
4
5
  export interface FlagDraw {
5
6
  /** The team the flag belongs to: its colour. */
6
7
  team: number;
7
8
  /** The foot of the pole: the base, where it lies, or the feet of the carrier. */
8
9
  at: Vec3;
9
- /** On a carrier's back: where he looks (yaw) and his speed on x and z, which the cloth trails against. */
10
+ /** On a carrier's back: who he is, where he looks (yaw) and his speed on x and z, which the cloth trails against. */
10
11
  by?: {
12
+ id: number;
11
13
  yaw: number;
12
14
  vx: number;
13
15
  vz: number;
@@ -55,8 +57,10 @@ export declare const ring: (out: number[], at: Vec3, r0: number, r1: number, rgb
55
57
  export declare const base: (out: number[], at: Vec3, rgb: number[], t: number) => void;
56
58
  /**
57
59
  * A flag. At rest on its base it stands upright with the cloth blowing out to one side. On a
58
- * carrier's back it leans out behind him and the cloth trails away from where he runs, more
59
- * stretched the faster he goes. Dropped, it lies on the ground, the pole leaning, with a ring
60
- * on the ground where it is to be touched. `t` is the clock in seconds.
60
+ * carrier it is strapped to his back, from the belt up over his head, and leans and turns with
61
+ * his `chest` (where it is and how it turns, from his skeleton; standing upright where he looks
62
+ * without one); the cloth trails away from where he runs, more stretched the faster he goes.
63
+ * Dropped, it lies on the ground, the pole leaning, with a ring on the ground where it is to be
64
+ * touched. `t` is the clock in seconds.
61
65
  */
62
- export declare const flag: (out: number[], f: FlagDraw, rgb: number[], t: number) => void;
66
+ export declare const flag: (out: number[], f: FlagDraw, rgb: number[], t: number, chest?: [Vec3, Quat]) => void;
@@ -51,12 +51,6 @@ export declare const GUARD: number[];
51
51
  export declare const LOCK: number[];
52
52
  /** The lock's hold shaking with the clock `t` (s), the hands out by `push` (0 to 1) of 6 cm: a press drives the blade on. */
53
53
  export declare const locked: (t: number, push?: number) => number[];
54
- /**
55
- * How far round a spin has turned the body at `p` of its swing (radians, added to the look's yaw for
56
- * the drawing only): a full turn, eased, between the wind-up and the follow-through; to the right
57
- * (yaw down) for SPIN_L, to the left for SPIN_R; 0 for any other cut.
58
- */
59
- export declare const whirl: (cut: number, p: number) => number;
60
54
  /** The grip and the blade direction (x, y, z each) of cut `cut` at `p` of the swing: one array, rewritten by each call. */
61
55
  export declare const stroke: (cut: number, p: number) => number[];
62
56
  /** The trunk's [twist, bend, lean] (radians, see TRUNK) of cut `cut` at `p` of its swing: one array, rewritten by each call. */
@@ -36,8 +36,7 @@ export declare const animate: (book: Map<number, Runner>, others: PlayerState[],
36
36
  /**
37
37
  * The pose with the katana in both hands: carried, or in a cut, which is the first person's cut
38
38
  * seen from the runner's eye (the share `e` of it, so that it is drawn from the carry and back to
39
- * it), the trunk twisting, bending and leaning through it (trunk()), and the whole body turning
40
- * round in a spin.
39
+ * it), and the trunk twisting, bending and leaning through it (trunk()).
41
40
  */
42
41
  export declare const brandish: (from: Pose, p: PlayerState, prog: number, ph: number, t?: number) => Pose;
43
42
  /** Seconds a runner the rail gun's bolt put down takes to come apart. */
@@ -64,4 +63,8 @@ export declare const stance: (r: Runner) => {
64
63
  sink: number;
65
64
  yaw: number;
66
65
  };
67
- export declare const soldier: (out: number[], r: Runner, color: number[], lod?: number) => void;
66
+ /** Draws the runner and gives back its solved skeleton, or nothing once a bolt has burnt it away. */
67
+ export declare const soldier: (out: number[], r: Runner, color: number[], lod?: number) => {
68
+ pos: Vec3[];
69
+ rot: import("./rig").Quat[];
70
+ } | undefined;
@@ -1,5 +1,7 @@
1
1
  import type { PlayerState } from './types';
2
2
  import type { World } from './world';
3
+ /** Where on the body the blade is, as a share of its height: the chest, which a brush must not cover. */
4
+ export declare const CHEST = 0.7;
3
5
  /**
4
6
  * The cut the keys held when FIRE starts a swing give: LEFT or RIGHT, one of them, cuts across from
5
7
  * that side; else FORWARD thrusts; else (back or no key) it slashes. Both sides held are neither.
@@ -35,9 +37,9 @@ export declare const crossing: (p: PlayerState, f: PlayerState) => boolean;
35
37
  /**
36
38
  * The way the shock of the cut of `p` throws the foe `f`, a unit vector on the floor plane: along
37
39
  * his look for a thrust, a slash and their specials; a cut across ends on the opposite side to the
38
- * one it starts from, so LEFT throws to his right and RIGHT to his left; a spin throws out from him.
40
+ * one it starts from, so LEFT throws to his right and RIGHT to his left.
39
41
  */
40
- export declare const knock: (p: PlayerState, f: PlayerState) => [x: number, z: number];
42
+ export declare const knock: (p: PlayerState) => [x: number, z: number];
41
43
  /**
42
44
  * The LIMB the cut of `p` (the state after the step that struck) takes off `f` (as he saw him) when
43
45
  * it puts him down. The blade's line is his look from his chest (CHEST of his height), so a level
@@ -242,6 +242,15 @@ export declare const CUTS: {
242
242
  */
243
243
  export declare const HEAVY: number, HEAVY_TAP: number, HEAVY_MAX: number;
244
244
  export declare const HEAVY_HP: number, HEAVY_REACH: number, HEAVY_ARC: number;
245
+ /**
246
+ * The arc of energy an ARC cut throws: it leaves the eye along the look at ARC_SPEED m/s, flies
247
+ * ARC_RANGE metres at most, stops on the first brush, and meets a body ARC_R metres off its line
248
+ * (it is about 1.5 m wide). The foe it meets is floored: a stumble of FLOOR_TICKS (a second on the
249
+ * ground, no move: floored(), physics.ts; the stun field holds 63 at most), thrown ARC_KNOCK m/s the way it flies, and he drops the flag.
250
+ * ARC_RANGE / ARC_SPEED stays under an ARC cut's ticks: one arc is gone before the next is thrown.
251
+ */
252
+ export declare const ARC_SPEED: number, ARC_RANGE: number, ARC_R: number;
253
+ export declare const FLOOR_TICKS: number, ARC_KNOCK: number;
245
254
  /** Ticks into a cut's swing in which a double click's second press still turns it into its special. */
246
255
  export declare const SPECIAL_LATE = 18;
247
256
  /** The lunge's throw along the look (m/s), held for the burst of a dash: it spends the dash. */
@@ -65,6 +65,8 @@ export declare const eyeHeight: (p: Pick<PlayerState, "mode">) => number;
65
65
  export declare const speedOf: (p: Pick<PlayerState, "vx" | "vz">) => number;
66
66
  /** Running faster than a walk on the ground: the sprint, for the animation to pump the arms. */
67
67
  export declare const sprinting: (p: Pick<PlayerState, "mode" | "vx" | "vz">) => boolean;
68
+ /** Whether an arc of energy floored `p` (FLOOR_TICKS): he lies down for the stun's ticks over SHOCK_TICKS, and does not move. */
69
+ export declare const floored: (p: Pick<PlayerState, "zap" | "stun">) => boolean;
68
70
  /**
69
71
  * A tackle lands on the player: he stumbles for `ticks` (STUMBLE_TICKS) and is thrown `knock`
70
72
  * (STUMBLE_KNOCK) m/s along (dx, dz), a unit vector (the tackler's way). It ends a dash, a wall-run,