@korial29/tiny-fps 0.49.4 → 0.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/dist/index.js +12 -12
- package/dist/local.js +1 -1
- package/dist/server.js +34 -11
- package/dist/types/client/gun.d.ts +42 -6
- package/dist/types/client/hud.d.ts +3 -2
- package/dist/types/client/katana.d.ts +3 -3
- package/dist/types/client/mesh.d.ts +2 -0
- package/dist/types/client/skin.d.ts +1 -1
- package/dist/types/shared/constants.d.ts +10 -0
- package/dist/types/shared/gun.d.ts +4 -0
- package/dist/types/shared/physics.d.ts +3 -0
- package/dist/types/shared/protocol.d.ts +1 -1
- package/dist/types/shared/types.d.ts +8 -0
- package/package.json +1 -1
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},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)&4095,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+55*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*55;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),o.setUint8(r+54,e.slow??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},ee=e=>{try{let t=JSON.parse(e);return t&&typeof t.t==`string`?t:null}catch{return null}},S=.4,C=1.8,te=1.6,ne=1.55,re=.9,ie=.7,ae=7.5,oe=1.5,se=.15,ce=.5,le=.9,ue=6.5,de=.2,fe=.03,pe=.2,me=5.5,he=2.5,ge=[`#ff3d4f`,`#2f80ff`],_e=.12,w=[{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}],[ve,ye,be]=[1.8,15,60],[xe,Se,Ce]=[2,.5,1.4],we=7.5,[Te,Ee,De]=[.82,.45,.12],Oe={maxPlayers:16,scoreLimit:3,timeLimit:480},ke=4,T=1024,Ae=(e,t)=>(e+T)*(2*T)+t+T,E=(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=E(e[0],t);a<=E(r[0],t);a++)for(let o=E(e[2],t);o<=E(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}},D=(e,t,n,r)=>{let i=[];for(let a=E(t-r,e.cell);a<=E(t+r,e.cell);a++)for(let t=E(n-r,e.cell);t<=E(n+r,e.cell);t++)for(let n of e.grid.get(Ae(a,t))??[])i.includes(n)||i.push(n);return i},O=(e,t,n,r,i=0)=>{let{cell:a,def:o}=e,s=r,c=E(t[0],a),l=E(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)>T||Math.abs(l)>T)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&&O(e,t,[r/o,i/o,a/o],o)<o-1e-4},k=1/60,Ne=Math.PI*2,A=1e-6,j=.01,Pe=.001,Fe=e=>(e%Ne+Ne)%Ne,M=e=>[-Math.sin(e),-Math.cos(e)],N=Math.fround,Ie=Math.sqrt,P=(e,t,n)=>Math.min(Math.max(e,t),n),F=(e,t)=>Ie(e*e+t*t),I=[[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,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,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:N(a),y:N(o),z:N(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})},L=e=>e===i.GROUND||e===i.SLIDE||e===i.CROUCH,R=e=>e.mode===i.SLIDE||e.mode===i.CROUCH?re:C,Be=e=>e.mode===i.SLIDE||e.mode===i.CROUCH?ie:te,Ve=e=>F(e.vx,e.vz),He=(e,t,n)=>e.max[1]>t+.5+j&&e.min[1]<t+n-j,z=(e,t,n)=>[t-P(t,e.min[0],e.max[0]),n-P(n,e.min[2],e.max[2])],Ue=(e,t,n)=>{let{brushes:r}=t.def,i=D(t,e.x,e.z,2*S),a=(S-A)**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]=z(i,e.x,e.z),d=s*s+u*u;if(d>=a)continue;if(d){let e=Ie(d);.4-e>t&&(t=S-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+S,[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=(S-A)**2,a=-1/0,o=1/0;for(let s of D(t,e.x,e.z,S)){let t=r[s],[c,l]=z(t,e.x,e.z);c*c+l*l>=i||(t.max[1]<=e.y+.5+j?a=Math.max(a,t.max[1]):t.min[1]>=e.y+n-j&&(o=Math.min(o,t.min[1])))}return[a,o]},B=(e,t)=>{let n=(S-A)**2;return D(t,e.x,e.z,S).every(r=>{let i=t.def.brushes[r],[a,o]=z(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=(S-A)**2;return D(e,t,n,S).every(o=>{let s=e.def.brushes[o],[c,l]=z(s,t,n);return c*c+l*l>=a||s.max[1]<=r||s.min[1]>=i})},Ke=(e,t)=>{let[n,r]=I[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 D(t,e.x,e.z,S+ce)){let a=t.def.brushes[i],o=qe(a,e,n,ce);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-S)))}return r},Ye=(e,t)=>{let[n,r]=M(e.yaw),i;for(let a=1;a<=4;a++){let[o,s]=I[a];if(a===e.wall||n*o+r*s<.5)continue;let{a:c,sign:l}=Ke(e,a);for(let n of D(t,e.x,e.z,S+de)){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*(S+fe),f=u+l*pe,[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)+j,o+1.8)&&Ge(t,h,g,o+j,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 D(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 N(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,C),r=6*k;return e.y-n<=-e.vy*r+10*r*r},V=(e,t)=>{e.mode=t,e.t=0},H=(e,t,n,r=48,a=6)=>{e.stun=r,e.vx=N(t*a),e.vz=N(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)&&(V(e,i.AIR),e.edge=0)},Qe=(e,t)=>{let n=F(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 D(t,e.x,e.z,S+Pe)){let o=t.def.brushes[n],[s,c]=z(o,e.x,e.z),l=F(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=F(t[0],t[1]);if(r<A){let t=F(e.vx,e.vz),n=t?Math.max(0,t-45*k)/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=F(s,c);if(l){let e=Math.max(0,l-45*k)/l;[s,c]=[s*e,c*e]}n*=r,o=o<n?Math.min(n,o+(o>=6?3:50)*k):Math.max(n,o-12*k),e.vx=s+o*i,e.vz=c+o*a},tt=(e,t,n,r,i)=>{let a=e.y;e.x+=e.vx*k,e.z+=e.vz*k;let[o,s]=Ue(e,t,n),c=F(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*k;if(e.y+=(e.vy+d)/2*k,e.vy=d,e.y+n>u&&(e.y=u-n,e.vy=Math.min(e.vy,0)),e.vy<=0?e.y<=l+j: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},U=(e,t)=>{e.vy=t,e.coyote=0,e.buffer=0,e.ev|=o.JUMP},nt=(e,n,r)=>{let[a,o]=I[e.wall],s=t=>{V(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,U(e,6);else if(r.jump||r.fwd&&e.t>=6)V(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,C)[0]);e.y+=P(t-e.y,-8*k,8*k)}},rt=(e,t)=>{let[n,r]=I[e.wall];e.y<e.edge?e.y=Math.min(e.edge,e.y+8*k):(e.x+=n*me*k,e.z+=r*me*k),e.y>=e.edge&&Xe(e,t)?(V(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&&(V(e,e.y>=e.edge?i.GROUND:i.AIR),e.edge=0,e.wall=a.NONE)},it=(e,t,n)=>{let[r,a]=I[e.wall],s=e.vx*r+e.vz*a,[c,l]=[e.vx-s*r,e.vz-s*a],u=F(c,l);if(n.jump)V(e,i.AIR),e.vx=c-r*5,e.vz=l-a*5,U(e,ue),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){V(e,i.AIR),e.ev|=o.WALLRUN_END;return}let d=Math.max(0,u-oe*k)/u;e.vx=c*d,e.vz=l*d;let f=Math.min(s,4*k);e.x+=r*f,e.z+=a*f}},at=(e,t,n)=>{if(!n.fwd)return;let r=F(e.vx,e.vz);if(!(r<4.5))for(let n=1;n<=4;n++){let[a,s]=I[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=F(l,u),a=Math.max(t,le*r)/t;V(e,i.WALLRUN),e.wall=n,[e.vx,e.vz]=[l*a,u*a],e.vy=P(e.vy,2,3),e.jumps=1,e.dashes=1,e.coyote=0,e.ev|=o.WALLRUN_START;return}}},ot=(e,t)=>{V(e,i.HANG),e.wall=t.side,e.edge=N(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&&(V(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),L(e.mode)&&ct(e,n,r,c),e.mode===i.AIR&<(e,n,r,c);let l=c&&e.vy<=0?0:e.mode===i.WALLRUN?se:1,u=e.mode,d=tt(e,n,R(e),l,L(u));if(d>=0){if(!L(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=F(e.vx,e.vz)>=ae;V(e,t?i.SLIDE:i.CROUCH),e.ev|=t?o.SLIDE_START:0}else V(e,i.GROUND)}e.coyote=6}else L(e.mode)&&(e.ev|=e.mode===i.SLIDE?o.SLIDE_END:0,V(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||B(e,n))){e.ev|=e.mode===i.SLIDE?o.SLIDE_END:0,V(e,i.AIR),U(e,7);return}let c=F(e.vx,e.vz);if(e.mode===i.GROUND&&s){let t=c>=ae;V(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,V(e,!s&&B(e,n)?i.GROUND:i.CROUCH)):e.mode===i.SLIDE&&!s&&B(e,n)?(e.ev|=o.SLIDE_END,V(e,i.GROUND)):e.mode===i.CROUCH&&!s&&B(e,n)&&V(e,i.GROUND);if(!a){if(r.stumble){if(c>2.5){let t=Math.max(he,c-12*k)/c;e.vx*=t,e.vz*=t}else et(e,$e(e,n,r,R(e)),he)}else if(e.mode===i.SLIDE){let t=Math.max(0,c-4*k)/c;e.vx*=t,e.vz*=t}else if(e.mode===i.CROUCH)et(e,$e(e,n,r,re),3);else{let i=(r.keys&t.SPRINT)!==0&&r.fwd;et(e,$e(e,n,r,C),i?9:6)}}},lt=(e,t,n,r)=>{if(e.buffer>0&&(e.coyote>0?U(e,7):e.jumps>0&&!Ze(e,t)&&(e.jumps--,U(e,6),e.ev=e.ev&~o.JUMP|o.DOUBLE)),r||!n.wx&&!n.wz)return;let i=F(e.vx,e.vz);e.vx+=n.wx*14*k,e.vz+=n.wz*14*k,Qe(e,Math.max(i,6))},ut=(e,n,r,a=0)=>{e.yaw=Fe(n.yaw),e.pitch=Math.max(-ne,Math.min(ne,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=F(o,s)||1,[l,u]=M(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=L(e.mode),e.x=N(e.x),e.y=N(e.y),e.z=N(e.z),e.vx=N(e.vx),e.vy=N(e.vy),e.vz=N(e.vz),e.edge=N(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},W=e=>{let t=w[e.cut??0];return e.heavy?{...t,ticks:Math.round((t.ticks-t.hold)*ve),strike:Math.round((t.strike-t.hold)*ve),reach:t.reach+Se,arc:t.arc*Ce,hp:t.hp+xe}:t},pt=(e,t,n)=>{let{reach:r,arc:i}=W(t),[a,o]=M(t.yaw),s=[t.x,t.y+dt*R(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+R(n)||n.y>=t.y+R(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(S/u):Math.PI;return d<=i+f&&!Me(e,s,[n.x,n.y+dt*R(n),n.z])})},mt=(e,t)=>{if(!t.wield||!t.swing||e.lock||t.lock)return!1;let n=W(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]=M(e.yaw);return a<1e-6||(r*t+i*n)/a>=Math.cos(.9)};return a-.4<=Math.min(n.reach,W(e).reach)&&o(e,r,i)&&o(t,-r,-i)},ht=(e,t)=>{let[r,i]=M(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]=M(e.yaw),[o,s]=M(t.yaw),[c,l]=[t.x-e.x,t.z-e.z],u=-a*c+i*l,d=Math.sqrt(Math.max(S*S-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)<=De?r.HEAD:m>0?r.ARM_R:r.ARM_L;let g=(e.y+dt*R(e)+Math.tan(e.pitch)*Math.hypot(c,l)-t.y)/R(t);if(g>Te)return r.HEAD;let _=h===n.THRUST?m>0:(h===n.LEFT?1:-1)*(i*o+a*s)<0;return g<Ee?_?r.LEG_R:r.LEG_L:h===n.THRUST&&Math.abs(m)<=De?r.NONE:_?r.ARM_R:r.ARM_L},G=()=>({state:e.HOME,by:0,x:0,y:0,z:0,left:0}),_t=60,vt=class{score=[0,0];over=!1;flags=[G(),G()];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=O(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=[G(),G()],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]=G()))}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]=G()}else s&&(this.flags[n]={...G(),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]=G()}}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],K=(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]=M(e.yaw);e.vx=t*13,e.vz=n*13,e.dash=60,e.ev|=o.DASH}else e.cut===n.LEAP&&(e.vy=we,e.ev|=o.JUMP)}},q={NONE:0,SHOT:1,CUT:2,RAIL:3},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),q.NONE;if(c)return St(e,n);let{rack:l,blade:u,rail:d}=r.def.teams[a],f=!!l&&K(e,l,1.2);o&&f&&!e.rack&&(e.ammo=60),e.rack=f,e.blade=!!e.blade||o&&!!u&&K(e,u,1.2);let p=!!d&&K(e,d,1.2);o&&p&&!e.inRail&&(e.rail=240),e.inRail=p,e.cool=Math.max(0,e.cool-1);let m=e.mode===i.HANG||e.mode===i.CLIMB,{ticks:h,hold:g}=w[e.cut??0],_=!!e.swing&&!e.heavy&&h-(e.swing??0)===g;_&&e.wield&&o&&!m&&n.keys&t.FIRE?e.charge=Math.min((e.charge??0)+1,be):_&&o&&!m&&(e.charge??0)>=ye?([e.heavy,e.charge]=[!0,0],e.swing=W(e).ticks):(e.charge=_?0:e.charge,e.swing=Math.max(0,(e.swing??0)-1),e.heavy=!!e.swing&&!!e.heavy);let v=[e.ammo>=0,!!e.blade,(e.rail??-1)>=0],y=n.keys&t.BLADE?1:n.keys&t.RAIL?2:0,b=e.swing&&e.blade?1:v[y]?y:v.indexOf(!0);if([e.wield,e.railed]=[b==1,b==2],!o)return e.charge=0,q.NONE;let x=W(e);if(e.swing&&x.ticks-e.swing===x.strike)return q.CUT;if((e.wield&&!_||e.railed||m||!e.wield&&e.ammo<=0)&&(e.charge=0),n.keys&t.FIRE&&!m){let r=w[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]=[w[e.cut].ticks,0],bt(e);else if(e.railed){if(e.rail>0)return e.rail--,e.zapping=!0,q.RAIL}else!e.wield&&!e.cool&&e.ammo>0&&(e.charge=Math.min((e.charge??0)+1,60))}else if(e.charge)return e.power=Math.min(Ct(e.charge),e.ammo),e.charge=0,e.ammo-=e.power,e.shots=e.shots+1&255,e.cool=7,q.SHOT;return q.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],q.NONE},Ct=e=>e<10?1:1+Math.floor(4*(e-10)/50),wt=-30,J=(e,t,n,r,i,a=s.CONCRETE)=>({min:[e,wt,t],max:[n,i,r],top:s.CONCRETE,side:a}),Y=([e,t,n],[r,i,a],o,s=o,c)=>({min:[e,t,n],max:[r,i,a],top:o,side:s,tint:c});[J(4,57.7,24,76,10),J(4,36,24,53.5,10,s.GLASS),J(4,20,24,36,12.4),J(4,-5,24,7,12.4,s.GLASS),J(27,20,47,50,8),J(27,60,47,76,8,s.BRICK),Y([9,12.2,39],[19,12.6,47],s.STEEL),...((e,t)=>[1,2,3,4,5,6].map(n=>Y([12,t,e-n],[14,t+.4*n,e-n+1],s.CONCRETE)))(53,10),Y([5,10,42],[5.5,14,42.5],s.STEEL),Y([5,10,50],[5.5,14,50.5],s.STEEL),Y([8,12.4,24],[20,12.85,24.45],s.STEEL),Y([36,8,22],[37,14.5,48],s.PAINT,s.PAINT,[.15,.72,.62]),Y([30,8,28],[34,10,32],s.CONCRETE),Y([40,8,30],[44,10.2,34],s.PAINT,s.PAINT,[1,.3,.06]),Y([28,9.2,44],[35,12,46],s.STEEL,s.PAINT,[.2,.42,1]),Y([41.5,7.6,50],[42,8,60],s.STEEL),Y([30,8,64],[34,9.6,68],s.PAINT,s.PAINT,[.2,.8,.3])];var X=240,Z=[1,.22,.26],Tt=[.2,.46,1],Et=[1,.42,.08],Dt=[.12,.7,.62],Q=(e,t,n,r,i,a,o)=>Y([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?Y([f,c,r],[p,m,i],s.CONCRETE):Y([r,c,f],[i,m,p],s.CONCRETE)})},$=(e,t,n,r,i,a,o)=>o.map((o,c)=>Y([e+c*n,a,t+c*r],[e+c*n+4,o,t+c*r+i],s.STEEL,s.CONCRETE)),kt=[J(12,212,52,240,26,s.GLASS),Q(12,26,212,52,26.12,212.5,Z),Q(12,26,239.5,52,26.12,240,Z),Q(12,26,212.5,12.5,26.12,239.5,Z),Q(51.5,26,212.5,52,26.12,239.5,Z),Q(11.6,12,222,12,25.8,232,Z),Q(28,12,211.4,31,25.5,212,Z),Y([19,26,222],[22,27.4,225],s.STEEL),Y([42,26,222],[45,27.4,225],s.STEEL),Y([29,26,229],[35,27.1,229.6],s.CONCRETE),Y([27,26,215],[35,27.5,219],s.STEEL,s.PAINT,Z),J(6,164,26,201,26,s.GLASS),J(6,134,26,147,26,s.GLASS),J(6,201,26,212,19),J(15,147,26,164,19),Y([14,26,164],[15,32,196],s.PAINT,s.PAINT,Dt),Y([14,18,147],[15,32,164],s.PAINT,s.PAINT,Dt),Y([14,26,134],[15,32,147],s.PAINT,s.PAINT,Dt),...$(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])=>Y([e,19,t],[n,i,r],s.STEEL,s.CONCRETE)),Y([20,26,178],[23,27.3,181],s.STEEL),Y([8,26,176],[11,27.2,179],s.STEEL),Y([8,26,190],[11,27.3,193],s.STEEL),Y([20,26,140],[23,27.3,143],s.STEEL),J(32,186,76,209,19),Q(32,19,207.5,76,19.1,209,Z),...$(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])=>Y([e,wt,t],[n,i,r],s.STEEL,s.CONCRETE)),J(32,166,64,182,21.2,s.GLASS),J(32,140,64,161,19),Y([40,21.2,172],[44,22.6,176],s.STEEL),Y([52,19,148],[57,20.3,151],s.STEEL),Y([38,19,196],[41,20.4,199],s.STEEL),Y([60,19,200],[63,20.4,203],s.STEEL),Y([52,19,190],[58,20.6,194],s.STEEL),Y([66,19,204],[72,20.2,207],s.STEEL),Y([56,21.2,170],[60,22.4,174],s.STEEL),Y([34,19,152],[37,20.3,156],s.STEEL),...$(36,135,18,0,3,15,[17.2,17.2]),...$(6.5,129,6,0,4,15,[17.2,19.4,21.6,23.8]),J(76,213,100,240,14.5,s.STEEL),Q(76,14.5,238.5,100,14.6,240,Z),J(76,185,100,209,14.5),J(76,138,100,181,14.5,s.GLASS),Y([80,15.7,158],[96,17.7,162],s.STEEL,s.PAINT,Et),Y([82,14.5,234],[85,15.9,237],s.STEEL),Y([91,14.5,190],[94,15.9,193],s.STEEL),Y([80,14.5,204],[83,15.6,207],s.STEEL),Y([78,14.5,170],[81,15.9,173],s.STEEL),Y([92,14.5,146],[95,15.7,149],s.STEEL),Y([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)],At=[J(6,106,62,134,15),J(62,106,100,134,14.5),Y([34,15,112],[54,17.2,128],s.CONCRETE),Q(38,17.2,116,50,17.3,124,Et),...[[35,113],[35,126.2],[51,113],[51,126.2]].map(([e,t])=>Y([e,17.2,t],[e+.8,21.5,t+.8],s.STEEL)),Y([34.6,21.5,112.6],[52.2,21.9,127.4],s.GLASS),Y([14,15,114],[17,16.5,117],s.STEEL),Y([14,15,123],[17,16.5,126],s.STEEL),Y([56,15,114],[59,16.5,117],s.STEEL),Y([56,15,123],[59,16.5,126],s.STEEL),Y([15.35,25.5,106],[15.85,26,134],s.STEEL),Y([70,14.5,108],[70.8,38,108.8],s.STEEL),Y([70,14.5,131.2],[70.8,38,132],s.STEEL),Y([66,14.5,110],[69,15.9,113],s.STEEL),Y([66,14.5,127],[69,15.9,130],s.STEEL)],jt=e=>({...e,min:[e.min[0],e.min[1],X-e.max[2]],max:[e.max[0],e.max[1],X-e.min[2]],tint:e.tint===Z?Tt:e.tint}),Mt=(e,t,n)=>[...[16,22,28,34,40].map(n=>[n,26,t,e]),...[19,31,43].map(t=>[t,26,n,e])],Nt=[[20,26,190],[48,21.2,172],[48,19,200],[88,14.5,198]],Pt=[[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]],Ft=[[19.5,26,179],[46,19,152],[39.5,21.2,172],[88,14.5,186],[88,14.5,207]],It={name:`Highline`,brushes:[...kt,...kt.map(jt),...At],teams:[{base:[32,26,224],spawns:Mt(0,236,231),rack:[30.75,27.5,217],blade:[33.25,27.5,217],rail:[28.25,27.5,217]},{base:[32,26,16],spawns:Mt(Math.PI,4,9),rack:[30.75,27.5,23],blade:[33.25,27.5,23],rail:[28.25,27.5,23]}],packs:[...Nt,...Nt.map(([e,t,n])=>[e,t,X-n]),[24,15,112],[24,15,128]],ammo:[...Pt,...Pt.map(([e,t,n])=>[e,t,X-n]),[12,15,116],[12,15,124]],cells:[...Ft,...Ft.map(([e,t,n])=>[e,t,X-n]),[28,15,X/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]},Lt=40/60,Rt=(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}},zt=(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},Bt=(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=O(e,i,a,o,_e),c;for(let e of r){let t=zt(i,a,e,S+_e,R(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},Vt=(e,t,n=[])=>{let r=[t.x,t.y+Be(t),t.z],i=Math.cos(t.pitch),a=[-Math.sin(t.yaw)*i,Math.sin(t.pitch),-Math.cos(t.yaw)*i],o=O(e,r,a,30),s;for(let e of n){let t=zt(r,a,e,S,R(e));t<o&&([o,s]=[t,e])}return{o:r,d:a,t:o,hit:s}},Ht=e=>e.mode===i.SLIDE||e.dash>50,Ut=(e,t)=>Math.hypot(e.x-t.x,e.z-t.z)<1.1&&e.y<t.y+R(t)&&t.y<e.y+R(e),Wt=20,Gt=2,Kt=(e,t)=>Array.from(e).slice(0,t).join(``).trim(),qt=e=>Kt((typeof e==`string`?e:``).replace(/\s+/g,` `).replace(/\p{Cc}/gu,``).trim(),16),Jt=(e,t)=>{let n=e;for(let r=2;t.includes(n);r++)n=`${Kt(e,15-`${r}`.length)} ${r}`;return n},Yt=(e,t)=>{let n=setInterval(e,t);return()=>clearInterval(n)},Xt={lock:0,foe:0,pushes:0,pressed:!1,away:0},Zt=({x:e,y:t,z:n,yaw:r})=>({x:e,y:t,z:n,yaw:r}),Qt=class{peers=/* @__PURE__ */ new Map;ticks=0;history=[];world;ctf;halt;rules;rr=[0,0];gone;balls=[];constructor(e={},t=It){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=ee(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===q.SHOT?this.shoot(n,r.view):t===q.CUT?this.cut(n,r.view):t===q.RAIL&&this.rail(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,Lt);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=Yt){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<Wt;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||!Ht(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=>Ut(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]:M(n.yaw);H(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:(Object.assign(e.state,{hp:0,down:120,ammo:-1,cool:0,charge:0,blade:!1,wield:!1,swing:0,lost:r.NONE,rail:-1,railed:!1,zapping:!1,slow:0}),this.ctf.drop(e.state),!0)}shoot(e,t=0){let n=Rt(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)*Lt);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=Bt(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,...Zt(n.find(e=>e.id===t.info.id))}));if(i){for(let[t,n]of[[e,i],[i,e]])Object.assign(t.state,{...Xt,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,W(e.state).hp))t.state.lost=gt(e.state,r);else{let[n,i]=ht(e.state,r);H(t.state,n,i,24,4*(e.state.heavy?ve:1)),t.state.zap=!0,t.by=e.info.id}}}}rail(e,t){let{hit:n}=Vt(this.world,e.state,this.enemies(e,t)),r=this.players().find(e=>e.info.id===n?.id);if(r){let t=!r.state.slow;r.state.slow=180,t&&(e.state.hits=e.state.hits+1&255,r.burn=0,this.fry(r))}}fry(e){e.state.fried=this.harm(e,1)}duel(e){let t=e.state;if(!t.lock)return;let n=this.players().find(e=>e.info.id===t.foe);if(!n||n.state.foe!==e.info.id||!n.state.lock||n.state.down||t.down){Object.assign(t,Xt);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,Xt),Object.assign(n.state,Xt),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]=M(t.state.yaw);H(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;H(t,-e/i,-r/i),H(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.rail??-1)>=0&&e.rail<240][a],s=e.find(({state:e})=>!e.down&&o(e)&&K(e,r,.9));if(s){let e=s.state;a==0?e.hp=Math.min(5,e.hp+2):a==1?e.ammo=Math.min(60,e.ammo+20):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)<Gt)});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:Jt(qt(t)||`Player ${r}`,n.map(e=>e.info.name)),team:a,color:ge[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})))}},$t=(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()},en=(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 Qt(t),s.start($t),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`&&ee(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{en 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},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)&8191,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+58*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*58;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),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,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,ne=.9,re=.7,ie=7.5,ae=1.5,oe=.15,se=.5,ce=.9,le=6.5,ue=.2,de=.03,fe=.2,pe=5.5,me=2.5,he=[`#ff3d4f`,`#2f80ff`],ge=.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: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}],[ve,ye,be]=[1.8,15,60],[xe,Se,Ce]=[2,.5,1.4],we=7.5,[Te,Ee,De]=[.82,.45,.12],Oe={maxPlayers:16,scoreLimit:3,timeLimit:480},ke=4,T=1024,Ae=(e,t)=>(e+T)*(2*T)+t+T,E=(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=E(e[0],t);a<=E(r[0],t);a++)for(let o=E(e[2],t);o<=E(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}},D=(e,t,n,r)=>{let i=[];for(let a=E(t-r,e.cell);a<=E(t+r,e.cell);a++)for(let t=E(n-r,e.cell);t<=E(n+r,e.cell);t++)for(let n of e.grid.get(Ae(a,t))??[])i.includes(n)||i.push(n);return i},O=(e,t,n,r,i=0)=>{let{cell:a,def:o}=e,s=r,c=E(t[0],a),l=E(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)>T||Math.abs(l)>T)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&&O(e,t,[r/o,i/o,a/o],o)<o-1e-4},k=1/60,Ne=Math.PI*2,A=1e-6,j=.01,Pe=.001,Fe=e=>(e%Ne+Ne)%Ne,M=e=>[-Math.sin(e),-Math.cos(e)],N=Math.fround,Ie=Math.sqrt,P=(e,t,n)=>Math.min(Math.max(e,t),n),F=(e,t)=>Ie(e*e+t*t),I=[[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,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:N(a),y:N(o),z:N(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})},L=e=>e===i.GROUND||e===i.SLIDE||e===i.CROUCH,R=e=>e.mode===i.SLIDE||e.mode===i.CROUCH?ne:w,Be=e=>e.mode===i.SLIDE||e.mode===i.CROUCH?re:ee,Ve=e=>F(e.vx,e.vz),He=(e,t,n)=>e.max[1]>t+.5+j&&e.min[1]<t+n-j,z=(e,t,n)=>[t-P(t,e.min[0],e.max[0]),n-P(n,e.min[2],e.max[2])],Ue=(e,t,n)=>{let{brushes:r}=t.def,i=D(t,e.x,e.z,2*C),a=(C-A)**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]=z(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-A)**2,a=-1/0,o=1/0;for(let s of D(t,e.x,e.z,C)){let t=r[s],[c,l]=z(t,e.x,e.z);c*c+l*l>=i||(t.max[1]<=e.y+.5+j?a=Math.max(a,t.max[1]):t.min[1]>=e.y+n-j&&(o=Math.min(o,t.min[1])))}return[a,o]},B=(e,t)=>{let n=(C-A)**2;return D(t,e.x,e.z,C).every(r=>{let i=t.def.brushes[r],[a,o]=z(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-A)**2;return D(e,t,n,C).every(o=>{let s=e.def.brushes[o],[c,l]=z(s,t,n);return c*c+l*l>=a||s.max[1]<=r||s.min[1]>=i})},Ke=(e,t)=>{let[n,r]=I[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 D(t,e.x,e.z,C+se)){let a=t.def.brushes[i],o=qe(a,e,n,se);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]=M(e.yaw),i;for(let a=1;a<=4;a++){let[o,s]=I[a];if(a===e.wall||n*o+r*s<.5)continue;let{a:c,sign:l}=Ke(e,a);for(let n of D(t,e.x,e.z,C+ue)){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+de),f=u+l*fe,[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)+j,o+1.8)&&Ge(t,h,g,o+j,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 D(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 N(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*k;return e.y-n<=-e.vy*r+10*r*r},V=(e,t)=>{e.mode=t,e.t=0},H=(e,t,n,r=48,a=6)=>{e.stun=r,e.vx=N(t*a),e.vz=N(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)&&(V(e,i.AIR),e.edge=0)},Qe=(e,t)=>{let n=F(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 D(t,e.x,e.z,C+Pe)){let o=t.def.brushes[n],[s,c]=z(o,e.x,e.z),l=F(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=F(t[0],t[1]);if(r<A){let t=F(e.vx,e.vz),n=t?Math.max(0,t-45*k)/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=F(s,c);if(l){let e=Math.max(0,l-45*k)/l;[s,c]=[s*e,c*e]}n*=r,o=o<n?Math.min(n,o+(o>=6?3:50)*k):Math.max(n,o-12*k),e.vx=s+o*i,e.vz=c+o*a},tt=(e,t,n,r,i)=>{let a=e.y;e.x+=e.vx*k,e.z+=e.vz*k;let[o,s]=Ue(e,t,n),c=F(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*k;if(e.y+=(e.vy+d)/2*k,e.vy=d,e.y+n>u&&(e.y=u-n,e.vy=Math.min(e.vy,0)),e.vy<=0?e.y<=l+j: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},U=(e,t)=>{e.vy=t,e.coyote=0,e.buffer=0,e.ev|=o.JUMP},nt=(e,n,r)=>{let[a,o]=I[e.wall],s=t=>{V(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,U(e,6);else if(r.jump||r.fwd&&e.t>=6)V(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+=P(t-e.y,-8*k,8*k)}},rt=(e,t)=>{let[n,r]=I[e.wall];e.y<e.edge?e.y=Math.min(e.edge,e.y+8*k):(e.x+=n*pe*k,e.z+=r*pe*k),e.y>=e.edge&&Xe(e,t)?(V(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&&(V(e,e.y>=e.edge?i.GROUND:i.AIR),e.edge=0,e.wall=a.NONE)},it=(e,t,n)=>{let[r,a]=I[e.wall],s=e.vx*r+e.vz*a,[c,l]=[e.vx-s*r,e.vz-s*a],u=F(c,l);if(n.jump)V(e,i.AIR),e.vx=c-r*5,e.vz=l-a*5,U(e,le),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){V(e,i.AIR),e.ev|=o.WALLRUN_END;return}let d=Math.max(0,u-ae*k)/u;e.vx=c*d,e.vz=l*d;let f=Math.min(s,4*k);e.x+=r*f,e.z+=a*f}},at=(e,t,n)=>{if(!n.fwd)return;let r=F(e.vx,e.vz);if(!(r<4.5))for(let n=1;n<=4;n++){let[a,s]=I[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=F(l,u),a=Math.max(t,ce*r)/t;V(e,i.WALLRUN),e.wall=n,[e.vx,e.vz]=[l*a,u*a],e.vy=P(e.vy,2,3),e.jumps=1,e.dashes=1,e.coyote=0,e.ev|=o.WALLRUN_START;return}}},ot=(e,t)=>{V(e,i.HANG),e.wall=t.side,e.edge=N(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&&(V(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),L(e.mode)&&ct(e,n,r,c),e.mode===i.AIR&<(e,n,r,c);let l=c&&e.vy<=0?0:e.mode===i.WALLRUN?oe:1,u=e.mode,d=tt(e,n,R(e),l,L(u));if(d>=0){if(!L(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=F(e.vx,e.vz)>=ie;V(e,t?i.SLIDE:i.CROUCH),e.ev|=t?o.SLIDE_START:0}else V(e,i.GROUND)}e.coyote=6}else L(e.mode)&&(e.ev|=e.mode===i.SLIDE?o.SLIDE_END:0,V(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||B(e,n))){e.ev|=e.mode===i.SLIDE?o.SLIDE_END:0,V(e,i.AIR),U(e,7);return}let c=F(e.vx,e.vz);if(e.mode===i.GROUND&&s){let t=c>=ie;V(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,V(e,!s&&B(e,n)?i.GROUND:i.CROUCH)):e.mode===i.SLIDE&&!s&&B(e,n)?(e.ev|=o.SLIDE_END,V(e,i.GROUND)):e.mode===i.CROUCH&&!s&&B(e,n)&&V(e,i.GROUND);if(!a){if(r.stumble){if(c>2.5){let t=Math.max(me,c-12*k)/c;e.vx*=t,e.vz*=t}else et(e,$e(e,n,r,R(e)),me)}else if(e.mode===i.SLIDE){let t=Math.max(0,c-4*k)/c;e.vx*=t,e.vz*=t}else if(e.mode===i.CROUCH)et(e,$e(e,n,r,ne),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?U(e,7):e.jumps>0&&!Ze(e,t)&&(e.jumps--,U(e,6),e.ev=e.ev&~o.JUMP|o.DOUBLE)),r||!n.wx&&!n.wz)return;let i=F(e.vx,e.vz);e.vx+=n.wx*14*k,e.vz+=n.wz*14*k,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=F(o,s)||1,[l,u]=M(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=L(e.mode),e.x=N(e.x),e.y=N(e.y),e.z=N(e.z),e.vx=N(e.vx),e.vy=N(e.vy),e.vz=N(e.vz),e.edge=N(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},W=e=>{let t=_e[e.cut??0];return e.heavy?{...t,ticks:Math.round((t.ticks-t.hold)*ve),strike:Math.round((t.strike-t.hold)*ve),reach:t.reach+Se,arc:t.arc*Ce,hp:t.hp+xe}:t},pt=(e,t,n)=>{let{reach:r,arc:i}=W(t),[a,o]=M(t.yaw),s=[t.x,t.y+dt*R(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+R(n)||n.y>=t.y+R(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*R(n),n.z])})},mt=(e,t)=>{if(!t.wield||!t.swing||e.lock||t.lock)return!1;let n=W(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]=M(e.yaw);return a<1e-6||(r*t+i*n)/a>=Math.cos(.9)};return a-.4<=Math.min(n.reach,W(e).reach)&&o(e,r,i)&&o(t,-r,-i)},ht=(e,t)=>{let[r,i]=M(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]=M(e.yaw),[o,s]=M(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)<=De?r.HEAD:m>0?r.ARM_R:r.ARM_L;let g=(e.y+dt*R(e)+Math.tan(e.pitch)*Math.hypot(c,l)-t.y)/R(t);if(g>Te)return r.HEAD;let _=h===n.THRUST?m>0:(h===n.LEFT?1:-1)*(i*o+a*s)<0;return g<Ee?_?r.LEG_R:r.LEG_L:h===n.THRUST&&Math.abs(m)<=De?r.NONE:_?r.ARM_R:r.ARM_L},G=()=>({state:e.HOME,by:0,x:0,y:0,z:0,left:0}),_t=60,vt=class{score=[0,0];over=!1;flags=[G(),G()];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=O(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=[G(),G()],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]=G()))}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]=G()}else s&&(this.flags[n]={...G(),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]=G()}}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],K=(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]=M(e.yaw);e.vx=t*13,e.vz=n*13,e.dash=60,e.ev|=o.DASH}else e.cut===n.LEAP&&(e.vy=we,e.ev|=o.JUMP)}},q={NONE:0,SHOT:1,CUT:2,RAIL:3},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),q.NONE;if(c)return St(e,n);let{rack:l,blade:u,rail:d}=r.def.teams[a],f=!!l&&K(e,l,1.2);o&&f&&!e.rack&&([e.ammo,e.mag]=[60,15]),e.rack=f,e.blade=!!e.blade||o&&!!u&&K(e,u,1.2);let p=!!d&&K(e,d,1.2);o&&p&&!e.inRail&&([e.rail,e.cap]=[240,80]),e.inRail=p,e.cool=Math.max(0,e.cool-1);let m=e.mode===i.HANG||e.mode===i.CLIMB,{ticks:h,hold:g}=_e[e.cut??0],_=!!e.swing&&!e.heavy&&h-(e.swing??0)===g;_&&e.wield&&o&&!m&&n.keys&t.FIRE?e.charge=Math.min((e.charge??0)+1,be):_&&o&&!m&&(e.charge??0)>=ye?([e.heavy,e.charge]=[!0,0],e.swing=W(e).ticks):(e.charge=_?0:e.charge,e.swing=Math.max(0,(e.swing??0)-1),e.heavy=!!e.swing&&!!e.heavy);let v=[e.ammo>=0,!!e.blade,(e.rail??-1)>=0],y=n.keys&t.BLADE?1:n.keys&t.RAIL?2:0,b=e.swing&&e.blade?1:v[y]?y:v.indexOf(!0);if(b!=(e.railed?2:+!!e.wield)&&(e.reload=0),[e.wield,e.railed]=[b==1,b==2],!o)return[e.charge,e.reload]=[0,0],q.NONE;let x=b==0?e.ammo>=0:b==2,[S,C]=e.railed?[e.cap??0,Math.min(80,e.rail)]:[e.mag??0,Math.min(15,e.ammo)];e.reload?--e.reload||(e[e.railed?`cap`:`mag`]=C):x&&!m&&S<C&&(!S||n.keys&t.RELOAD)&&([e.reload,e.charge]=[e.railed?90:54,0]);let w=W(e);if(e.swing&&w.ticks-e.swing===w.strike)return q.CUT;if((e.wield&&!_||e.railed||m||e.reload||!e.wield&&!e.mag)&&(e.charge=0),n.keys&t.FIRE&&!m){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=ft(n.keys)+(i?4:0),[e.swing,e.charge]=[_e[e.cut].ticks,0],bt(e);else if(e.railed){if(e.cap&&!e.reload)return e.rail--,e.cap--,e.zapping=!0,q.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,q.SHOT;return q.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],q.NONE},Ct=e=>e<10?1:1+Math.floor(4*(e-10)/50),wt=-30,J=(e,t,n,r,i,a=s.CONCRETE)=>({min:[e,wt,t],max:[n,i,r],top:s.CONCRETE,side:a}),Y=([e,t,n],[r,i,a],o,s=o,c)=>({min:[e,t,n],max:[r,i,a],top:o,side:s,tint:c});[J(4,57.7,24,76,10),J(4,36,24,53.5,10,s.GLASS),J(4,20,24,36,12.4),J(4,-5,24,7,12.4,s.GLASS),J(27,20,47,50,8),J(27,60,47,76,8,s.BRICK),Y([9,12.2,39],[19,12.6,47],s.STEEL),...((e,t)=>[1,2,3,4,5,6].map(n=>Y([12,t,e-n],[14,t+.4*n,e-n+1],s.CONCRETE)))(53,10),Y([5,10,42],[5.5,14,42.5],s.STEEL),Y([5,10,50],[5.5,14,50.5],s.STEEL),Y([8,12.4,24],[20,12.85,24.45],s.STEEL),Y([36,8,22],[37,14.5,48],s.PAINT,s.PAINT,[.15,.72,.62]),Y([30,8,28],[34,10,32],s.CONCRETE),Y([40,8,30],[44,10.2,34],s.PAINT,s.PAINT,[1,.3,.06]),Y([28,9.2,44],[35,12,46],s.STEEL,s.PAINT,[.2,.42,1]),Y([41.5,7.6,50],[42,8,60],s.STEEL),Y([30,8,64],[34,9.6,68],s.PAINT,s.PAINT,[.2,.8,.3])];var X=240,Z=[1,.22,.26],Tt=[.2,.46,1],Et=[1,.42,.08],Dt=[.12,.7,.62],Q=(e,t,n,r,i,a,o)=>Y([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?Y([f,c,r],[p,m,i],s.CONCRETE):Y([r,c,f],[i,m,p],s.CONCRETE)})},$=(e,t,n,r,i,a,o)=>o.map((o,c)=>Y([e+c*n,a,t+c*r],[e+c*n+4,o,t+c*r+i],s.STEEL,s.CONCRETE)),kt=[J(12,212,52,240,26,s.GLASS),Q(12,26,212,52,26.12,212.5,Z),Q(12,26,239.5,52,26.12,240,Z),Q(12,26,212.5,12.5,26.12,239.5,Z),Q(51.5,26,212.5,52,26.12,239.5,Z),Q(11.6,12,222,12,25.8,232,Z),Q(28,12,211.4,31,25.5,212,Z),Y([19,26,222],[22,27.4,225],s.STEEL),Y([42,26,222],[45,27.4,225],s.STEEL),Y([29,26,229],[35,27.1,229.6],s.CONCRETE),Y([27,26,215],[35,27.5,219],s.STEEL,s.PAINT,Z),J(6,164,26,201,26,s.GLASS),J(6,134,26,147,26,s.GLASS),J(6,201,26,212,19),J(15,147,26,164,19),Y([14,26,164],[15,32,196],s.PAINT,s.PAINT,Dt),Y([14,18,147],[15,32,164],s.PAINT,s.PAINT,Dt),Y([14,26,134],[15,32,147],s.PAINT,s.PAINT,Dt),...$(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])=>Y([e,19,t],[n,i,r],s.STEEL,s.CONCRETE)),Y([20,26,178],[23,27.3,181],s.STEEL),Y([8,26,176],[11,27.2,179],s.STEEL),Y([8,26,190],[11,27.3,193],s.STEEL),Y([20,26,140],[23,27.3,143],s.STEEL),J(32,186,76,209,19),Q(32,19,207.5,76,19.1,209,Z),...$(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])=>Y([e,wt,t],[n,i,r],s.STEEL,s.CONCRETE)),J(32,166,64,182,21.2,s.GLASS),J(32,140,64,161,19),Y([40,21.2,172],[44,22.6,176],s.STEEL),Y([52,19,148],[57,20.3,151],s.STEEL),Y([38,19,196],[41,20.4,199],s.STEEL),Y([60,19,200],[63,20.4,203],s.STEEL),Y([52,19,190],[58,20.6,194],s.STEEL),Y([66,19,204],[72,20.2,207],s.STEEL),Y([56,21.2,170],[60,22.4,174],s.STEEL),Y([34,19,152],[37,20.3,156],s.STEEL),...$(36,135,18,0,3,15,[17.2,17.2]),...$(6.5,129,6,0,4,15,[17.2,19.4,21.6,23.8]),J(76,213,100,240,14.5,s.STEEL),Q(76,14.5,238.5,100,14.6,240,Z),J(76,185,100,209,14.5),J(76,138,100,181,14.5,s.GLASS),Y([80,15.7,158],[96,17.7,162],s.STEEL,s.PAINT,Et),Y([82,14.5,234],[85,15.9,237],s.STEEL),Y([91,14.5,190],[94,15.9,193],s.STEEL),Y([80,14.5,204],[83,15.6,207],s.STEEL),Y([78,14.5,170],[81,15.9,173],s.STEEL),Y([92,14.5,146],[95,15.7,149],s.STEEL),Y([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)],At=[J(6,106,62,134,15),J(62,106,100,134,14.5),Y([34,15,112],[54,17.2,128],s.CONCRETE),Q(38,17.2,116,50,17.3,124,Et),...[[35,113],[35,126.2],[51,113],[51,126.2]].map(([e,t])=>Y([e,17.2,t],[e+.8,21.5,t+.8],s.STEEL)),Y([34.6,21.5,112.6],[52.2,21.9,127.4],s.GLASS),Y([14,15,114],[17,16.5,117],s.STEEL),Y([14,15,123],[17,16.5,126],s.STEEL),Y([56,15,114],[59,16.5,117],s.STEEL),Y([56,15,123],[59,16.5,126],s.STEEL),Y([15.35,25.5,106],[15.85,26,134],s.STEEL),Y([70,14.5,108],[70.8,38,108.8],s.STEEL),Y([70,14.5,131.2],[70.8,38,132],s.STEEL),Y([66,14.5,110],[69,15.9,113],s.STEEL),Y([66,14.5,127],[69,15.9,130],s.STEEL)],jt=e=>({...e,min:[e.min[0],e.min[1],X-e.max[2]],max:[e.max[0],e.max[1],X-e.min[2]],tint:e.tint===Z?Tt:e.tint}),Mt=(e,t,n)=>[...[16,22,28,34,40].map(n=>[n,26,t,e]),...[19,31,43].map(t=>[t,26,n,e])],Nt=[[20,26,190],[48,21.2,172],[48,19,200],[88,14.5,198]],Pt=[[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]],Ft=[[19.5,26,179],[46,19,152],[39.5,21.2,172],[88,14.5,186],[88,14.5,207]],It={name:`Highline`,brushes:[...kt,...kt.map(jt),...At],teams:[{base:[32,26,224],spawns:Mt(0,236,231),rack:[30.75,27.5,217],blade:[33.25,27.5,217],rail:[28.25,27.5,217]},{base:[32,26,16],spawns:Mt(Math.PI,4,9),rack:[30.75,27.5,23],blade:[33.25,27.5,23],rail:[28.25,27.5,23]}],packs:[...Nt,...Nt.map(([e,t,n])=>[e,t,X-n]),[24,15,112],[24,15,128]],ammo:[...Pt,...Pt.map(([e,t,n])=>[e,t,X-n]),[12,15,116],[12,15,124]],cells:[...Ft,...Ft.map(([e,t,n])=>[e,t,X-n]),[28,15,X/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]},Lt=40/60,Rt=(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}},zt=(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},Bt=(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=O(e,i,a,o,ge),c;for(let e of r){let t=zt(i,a,e,C+ge,R(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},Vt=(e,t,n=[])=>{let r=[t.x,t.y+Be(t),t.z],i=Math.cos(t.pitch),a=[-Math.sin(t.yaw)*i,Math.sin(t.pitch),-Math.cos(t.yaw)*i],o=O(e,r,a,30),s;for(let e of n){let t=zt(r,a,e,C,R(e));t<o&&([o,s]=[t,e])}return{o:r,d:a,t:o,hit:s}},Ht=e=>e.mode===i.SLIDE||e.dash>50,Ut=(e,t)=>Math.hypot(e.x-t.x,e.z-t.z)<1.1&&e.y<t.y+R(t)&&t.y<e.y+R(e),Wt=20,Gt=2,Kt=(e,t)=>Array.from(e).slice(0,t).join(``).trim(),qt=e=>Kt((typeof e==`string`?e:``).replace(/\s+/g,` `).replace(/\p{Cc}/gu,``).trim(),16),Jt=(e,t)=>{let n=e;for(let r=2;t.includes(n);r++)n=`${Kt(e,15-`${r}`.length)} ${r}`;return n},Yt=(e,t)=>{let n=setInterval(e,t);return()=>clearInterval(n)},Xt={lock:0,foe:0,pushes:0,pressed:!1,away:0},Zt=({x:e,y:t,z:n,yaw:r})=>({x:e,y:t,z:n,yaw:r}),Qt=class{peers=/* @__PURE__ */ new Map;ticks=0;history=[];world;ctf;halt;rules;rr=[0,0];gone;balls=[];constructor(e={},t=It){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===q.SHOT?this.shoot(n,r.view):t===q.CUT?this.cut(n,r.view):t===q.RAIL&&this.rail(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,Lt);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=Yt){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<Wt;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||!Ht(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=>Ut(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]:M(n.yaw);H(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:(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,zapping:!1,slow:0}),this.ctf.drop(e.state),!0)}shoot(e,t=0){let n=Rt(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)*Lt);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=Bt(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,...Zt(n.find(e=>e.id===t.info.id))}));if(i){for(let[t,n]of[[e,i],[i,e]])Object.assign(t.state,{...Xt,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,W(e.state).hp))t.state.lost=gt(e.state,r);else{let[n,i]=ht(e.state,r);H(t.state,n,i,24,4*(e.state.heavy?ve:1)),t.state.zap=!0,t.by=e.info.id}}}}rail(e,t){let{hit:n}=Vt(this.world,e.state,this.enemies(e,t)),r=this.players().find(e=>e.info.id===n?.id);if(r){let t=!r.state.slow;r.state.slow=180,t&&(e.state.hits=e.state.hits+1&255,r.burn=0,this.fry(r))}}fry(e){e.state.fried=this.harm(e,1)}duel(e){let t=e.state;if(!t.lock)return;let n=this.players().find(e=>e.info.id===t.foe);if(!n||n.state.foe!==e.info.id||!n.state.lock||n.state.down||t.down){Object.assign(t,Xt);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,Xt),Object.assign(n.state,Xt),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]=M(t.state.yaw);H(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;H(t,-e/i,-r/i),H(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.rail??-1)>=0&&e.rail<240][a],s=e.find(({state:e})=>!e.down&&o(e)&&K(e,r,.9));if(s){let e=s.state;a==0?e.hp=Math.min(5,e.hp+2):a==1?e.ammo=Math.min(60,e.ammo+20):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)<Gt)});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:Jt(qt(t)||`Player ${r}`,n.map(e=>e.info.name)),team:a,color:he[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})))}},$t=(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()},en=(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 Qt(t),s.start($t),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{en as localSocket};
|
package/dist/server.js
CHANGED
|
@@ -187,7 +187,9 @@ var KEY = {
|
|
|
187
187
|
* Set while the player wants the rail gun in hand (the client's choice: 3 or the wheel), with
|
|
188
188
|
* KEY.BLADE clear. Ignored without the rail gun.
|
|
189
189
|
*/
|
|
190
|
-
RAIL: 2048
|
|
190
|
+
RAIL: 2048,
|
|
191
|
+
/** Press to swap the battery or the capsule of the gun in hand (see GUN_MAG). */
|
|
192
|
+
RELOAD: 4096
|
|
191
193
|
};
|
|
192
194
|
/**
|
|
193
195
|
* The katana's cuts (PlayerState.cut, constants CUTS), chosen by the keys held when FIRE starts
|
|
@@ -436,6 +438,9 @@ var STILL = {
|
|
|
436
438
|
hp: 5,
|
|
437
439
|
ammo: -1,
|
|
438
440
|
cool: 0,
|
|
441
|
+
mag: 0,
|
|
442
|
+
cap: 0,
|
|
443
|
+
reload: 0,
|
|
439
444
|
rack: false,
|
|
440
445
|
down: 0,
|
|
441
446
|
shots: 0,
|
|
@@ -1490,6 +1495,10 @@ var STRIKE = {
|
|
|
1490
1495
|
* - In hand is the weapon he wants (KEY.BLADE the katana, KEY.RAIL the rail gun, neither the gun)
|
|
1491
1496
|
* when he has it, else the first he has of the gun, the katana and the rail gun; the katana
|
|
1492
1497
|
* stays in hand for the length of a swing. `wield` is the katana in hand, `railed` the rail gun.
|
|
1498
|
+
* - The gun fires from its battery (`mag`), the rail gun from its capsule (`cap`). An empty one, or
|
|
1499
|
+
* KEY.RELOAD with room in it, swaps it for a full one from what he carries: `reload` ticks
|
|
1500
|
+
* without firing, then it holds GUN_MAG (RAIL_CAP) or what is left. A switch of weapon drops it.
|
|
1501
|
+
* The racks fill both.
|
|
1493
1502
|
* - The rail gun throws its bolt on every step FIRE is held, spending a tick of it (`zapping`).
|
|
1494
1503
|
* - The trigger: `cool` and `swing` run down, and at 0 a held FIRE charges the gun, with ammo, and
|
|
1495
1504
|
* letting it go fires a ball as strong as the charge (powerOf()), spending as many shots; or it
|
|
@@ -1516,11 +1525,11 @@ var step = (p, i, w, team, armed = true) => {
|
|
|
1516
1525
|
if (locked) return duel(p, i);
|
|
1517
1526
|
const { rack, blade, rail } = w.def.teams[team];
|
|
1518
1527
|
const inside = !!rack && within(p, rack, 1.2);
|
|
1519
|
-
if (armed && inside && !p.rack) p.ammo = 60;
|
|
1528
|
+
if (armed && inside && !p.rack) [p.ammo, p.mag] = [60, 15];
|
|
1520
1529
|
p.rack = inside;
|
|
1521
1530
|
p.blade = !!p.blade || armed && !!blade && within(p, blade, 1.2);
|
|
1522
1531
|
const inRail = !!rail && within(p, rail, 1.2);
|
|
1523
|
-
if (armed && inRail && !p.inRail) p.rail = 240;
|
|
1532
|
+
if (armed && inRail && !p.inRail) [p.rail, p.cap] = [240, 80];
|
|
1524
1533
|
p.inRail = inRail;
|
|
1525
1534
|
p.cool = Math.max(0, p.cool - 1);
|
|
1526
1535
|
const busy = p.mode === MODE.HANG || p.mode === MODE.CLIMB;
|
|
@@ -1542,14 +1551,20 @@ var step = (p, i, w, team, armed = true) => {
|
|
|
1542
1551
|
];
|
|
1543
1552
|
const want = i.keys & KEY.BLADE ? 1 : i.keys & KEY.RAIL ? 2 : 0;
|
|
1544
1553
|
const hand = p.swing && p.blade ? 1 : has[want] ? want : has.indexOf(true);
|
|
1554
|
+
if (hand != (p.railed ? 2 : +!!p.wield)) p.reload = 0;
|
|
1545
1555
|
[p.wield, p.railed] = [hand == 1, hand == 2];
|
|
1546
1556
|
if (!armed) {
|
|
1547
|
-
p.charge = 0;
|
|
1557
|
+
[p.charge, p.reload] = [0, 0];
|
|
1548
1558
|
return STRIKE.NONE;
|
|
1549
1559
|
}
|
|
1560
|
+
const loads = hand == 0 ? p.ammo >= 0 : hand == 2;
|
|
1561
|
+
const [load, full] = p.railed ? [p.cap ?? 0, Math.min(80, p.rail)] : [p.mag ?? 0, Math.min(15, p.ammo)];
|
|
1562
|
+
if (p.reload) {
|
|
1563
|
+
if (!--p.reload) p[p.railed ? "cap" : "mag"] = full;
|
|
1564
|
+
} else if (loads && !busy && load < full && (!load || i.keys & KEY.RELOAD)) [p.reload, p.charge] = [p.railed ? 90 : 54, 0];
|
|
1550
1565
|
const c = swingOf(p);
|
|
1551
1566
|
if (p.swing && c.ticks - p.swing === c.strike) return STRIKE.CUT;
|
|
1552
|
-
if (p.wield && !top || p.railed || busy || !p.wield && p.
|
|
1567
|
+
if (p.wield && !top || p.railed || busy || p.reload || !p.wield && !p.mag) p.charge = 0;
|
|
1553
1568
|
if (i.keys & KEY.FIRE && !busy) {
|
|
1554
1569
|
const late = CUTS[p.cut ?? 0].ticks - (p.swing ?? 0);
|
|
1555
1570
|
const special = !!(i.keys & KEY.SPECIAL) && (!p.swing || !p.heavy && (p.cut ?? 0) < 4 && late <= 18);
|
|
@@ -1558,16 +1573,18 @@ var step = (p, i, w, team, armed = true) => {
|
|
|
1558
1573
|
[p.swing, p.charge] = [CUTS[p.cut].ticks, 0];
|
|
1559
1574
|
launch$1(p);
|
|
1560
1575
|
} else if (p.railed) {
|
|
1561
|
-
if (p.
|
|
1576
|
+
if (p.cap && !p.reload) {
|
|
1562
1577
|
p.rail--;
|
|
1578
|
+
p.cap--;
|
|
1563
1579
|
p.zapping = true;
|
|
1564
1580
|
return STRIKE.RAIL;
|
|
1565
1581
|
}
|
|
1566
|
-
} else if (!p.wield && !p.cool && p.
|
|
1582
|
+
} else if (!p.wield && !p.cool && p.mag && !p.reload) p.charge = Math.min((p.charge ?? 0) + 1, 60);
|
|
1567
1583
|
} else if (p.charge) {
|
|
1568
|
-
p.power = Math.min(powerOf(p.charge), p.
|
|
1584
|
+
p.power = Math.min(powerOf(p.charge), p.mag);
|
|
1569
1585
|
p.charge = 0;
|
|
1570
1586
|
p.ammo -= p.power;
|
|
1587
|
+
p.mag = p.mag - p.power;
|
|
1571
1588
|
p.shots = p.shots + 1 & 255;
|
|
1572
1589
|
p.cool = 7;
|
|
1573
1590
|
return STRIKE.SHOT;
|
|
@@ -2667,7 +2684,7 @@ var decodeInput = (buf) => {
|
|
|
2667
2684
|
if (v.getUint8(0) !== 1) return null;
|
|
2668
2685
|
return {
|
|
2669
2686
|
seq: v.getUint16(1),
|
|
2670
|
-
keys: v.getUint16(3) &
|
|
2687
|
+
keys: v.getUint16(3) & 8191,
|
|
2671
2688
|
yaw: fromTurn(v.getUint16(5)),
|
|
2672
2689
|
pitch: fromPitch(v.getInt16(7)),
|
|
2673
2690
|
view: (v.getUint16(9) * 256 + v.getUint8(11)) / 256
|
|
@@ -2676,7 +2693,7 @@ var decodeInput = (buf) => {
|
|
|
2676
2693
|
/** Bytes of a flag on the wire, by its state. */
|
|
2677
2694
|
var flagBytes = (state) => state === FLAG.CARRIED ? 2 : state === FLAG.DROPPED ? 8 : 1;
|
|
2678
2695
|
var encodeSnapshot = (s) => {
|
|
2679
|
-
const end = 4 +
|
|
2696
|
+
const end = 4 + 58 * s.players.length;
|
|
2680
2697
|
const balls = s.balls ?? [];
|
|
2681
2698
|
const tail = end + 10 + s.flags.reduce((n, f) => n + flagBytes(f.state), 0);
|
|
2682
2699
|
const v = new DataView(new ArrayBuffer(tail + (balls.length && 1 + 11 * balls.length)));
|
|
@@ -2684,7 +2701,7 @@ var encodeSnapshot = (s) => {
|
|
|
2684
2701
|
v.setUint16(1, s.tick & 65535);
|
|
2685
2702
|
v.setUint8(3, s.players.length);
|
|
2686
2703
|
s.players.forEach((p, i) => {
|
|
2687
|
-
const o = 4 + i *
|
|
2704
|
+
const o = 4 + i * 58;
|
|
2688
2705
|
v.setUint8(o, p.id);
|
|
2689
2706
|
v.setFloat32(o + 1, p.x);
|
|
2690
2707
|
v.setFloat32(o + 5, p.y);
|
|
@@ -2716,6 +2733,9 @@ var encodeSnapshot = (s) => {
|
|
|
2716
2733
|
v.setUint8(o + 52, (p.rail ?? -1) + 1);
|
|
2717
2734
|
v.setUint8(o + 53, +!!p.railed | +!!p.inRail << 1 | +!!p.zapping << 2);
|
|
2718
2735
|
v.setUint8(o + 54, p.slow ?? 0);
|
|
2736
|
+
v.setUint8(o + 55, p.mag ?? 0);
|
|
2737
|
+
v.setUint8(o + 56, p.cap ?? 0);
|
|
2738
|
+
v.setUint8(o + 57, p.reload ?? 0);
|
|
2719
2739
|
});
|
|
2720
2740
|
v.setUint8(end, s.score[0]);
|
|
2721
2741
|
v.setUint8(end + 1, s.score[1]);
|
|
@@ -3069,6 +3089,9 @@ var Room = class {
|
|
|
3069
3089
|
ammo: -1,
|
|
3070
3090
|
cool: 0,
|
|
3071
3091
|
charge: 0,
|
|
3092
|
+
mag: 0,
|
|
3093
|
+
cap: 0,
|
|
3094
|
+
reload: 0,
|
|
3072
3095
|
blade: false,
|
|
3073
3096
|
wield: false,
|
|
3074
3097
|
swing: 0,
|
|
@@ -30,6 +30,35 @@ export declare const ARC: number[];
|
|
|
30
30
|
* tipped with a glowing ball. arc() is the spark between them.
|
|
31
31
|
*/
|
|
32
32
|
export declare const railgun: (lod: number) => number[];
|
|
33
|
+
/**
|
|
34
|
+
* The gun's battery (the user, 2026-11-08), built once: a gunmetal cell in the grip, along its own
|
|
35
|
+
* forward from its foot, which stands out under the lower shell with a band of glow round it.
|
|
36
|
+
*/
|
|
37
|
+
export declare const battery: (lod: number) => number[];
|
|
38
|
+
/**
|
|
39
|
+
* The rail gun's capsule, built once: a copper screw base, a violet core of lightning in a cage of
|
|
40
|
+
* three steel posts, and a cap, standing along its own forward from its base.
|
|
41
|
+
*/
|
|
42
|
+
export declare const capsule: (lod: number) => number[];
|
|
43
|
+
export declare const ease: (t: number) => number;
|
|
44
|
+
/** `t` from `a` to `b` as 0 to 1. */
|
|
45
|
+
export declare const span: (t: number, a: number, b: number) => number;
|
|
46
|
+
/** How far through the swap of the gun in hand `p` is, 0 to 1; -1 when it is not swapping. */
|
|
47
|
+
export declare const swapOf: (p: Pick<PlayerState, "reload" | "railed">) => number;
|
|
48
|
+
/** The glow of a weapon `t` seconds after it came to hand: dark as it rises, then flickering up to full at 0.6 s. */
|
|
49
|
+
export declare const power: (t: number) => number;
|
|
50
|
+
/**
|
|
51
|
+
* Where the battery or the capsule is at `s` of a swap (0 to 1; -1 none): how far out of its seat
|
|
52
|
+
* along its axis (metres), how far round its axis (radians, the capsule's screw), and how far it
|
|
53
|
+
* tumbles (radians). The old one comes out and goes, the new one comes in, the left hand bringing it.
|
|
54
|
+
*/
|
|
55
|
+
export declare const swapped: (s: number, rail: boolean) => number[];
|
|
56
|
+
/**
|
|
57
|
+
* The frame of the battery (the capsule when `rail`) of a gun whose grip is at `at` and whose axes
|
|
58
|
+
* are `ax`, `k` times its size, at `s` of a swap: its foot (base) and its axes, its forward along
|
|
59
|
+
* the grip (up).
|
|
60
|
+
*/
|
|
61
|
+
export declare const loadFrame: (at: Vec3, ax: Vec3[], rail: boolean, s?: number, k?: number) => [Vec3, Vec3[]];
|
|
33
62
|
/**
|
|
34
63
|
* The spark between the electrodes' tips at the time `t` (s), in model space: a thin glowing line
|
|
35
64
|
* through four jagged points, a new shape 30 times a second.
|
|
@@ -43,15 +72,15 @@ export declare const arc: (t: number) => number[];
|
|
|
43
72
|
export declare const fore: (at: Vec3, [r, u, f]: Vec3[]) => [Vec3, Vec3];
|
|
44
73
|
/** fore() for the hand at `pos` turned by `q`, which holds the grip. */
|
|
45
74
|
export declare const foregrip: (pos: Vec3, q: Quat) => [Vec3, Vec3];
|
|
46
|
-
/** The rail gun's lightning left as the counters show it: 99 when full, 0 when spent. */
|
|
47
|
-
export declare const charge: (rail: number) => number;
|
|
75
|
+
/** The rail gun's lightning left as the counters show it: 99 when full (of `max`, a load by default), 0 when spent. */
|
|
76
|
+
export declare const charge: (rail: number, max?: number) => number;
|
|
48
77
|
/** The electrodes' tips of a gun whose grip is at `at` and whose axes are [right, up, forward]. */
|
|
49
78
|
export declare const electrodes: (at: Vec3, [, u, f]: Vec3[]) => Vec3[];
|
|
50
79
|
/** The middle of the grip, for a wrist at `pos`: 8 cm along the fingers and 2 cm toward the palm. */
|
|
51
80
|
export declare const grip: (pos: Vec3, q: Quat) => Vec3;
|
|
52
81
|
/**
|
|
53
|
-
* The
|
|
54
|
-
* on top of the body, in model space: cyan, red at
|
|
82
|
+
* The shots in the battery as two glowing seven-segment digits on a dark screen set in the back of
|
|
83
|
+
* a small block on top of the body, in model space: cyan, red at 4 or fewer, thick segments that bloom only a
|
|
55
84
|
* little. The block is part of the readout, so only a gun that shows the ammo carries it. 99 at most.
|
|
56
85
|
* While the gun charges, a gauge of CHARGE_MAX cells under the digits lights `level` of them, the
|
|
57
86
|
* strength the shot would have; all orange at the full charge.
|
|
@@ -64,12 +93,19 @@ export declare const readout: (ammo: number, level?: number) => number[];
|
|
|
64
93
|
* the metal round it: a glow would bloom over the digits.
|
|
65
94
|
*/
|
|
66
95
|
export declare const lcd: (ammo: number) => number[];
|
|
96
|
+
/** How a gun is drawn beyond its place: its glow from 0 (off) to 1, the swap under way (0 to 1, -1 none), and whether its battery or capsule holds any. */
|
|
97
|
+
export interface Lit {
|
|
98
|
+
light?: number;
|
|
99
|
+
swap?: number;
|
|
100
|
+
empty?: boolean;
|
|
101
|
+
}
|
|
67
102
|
/**
|
|
68
103
|
* Appends the gun (the rail gun when `rail`, its spark at the time `t`) held in the hand at `pos`
|
|
69
104
|
* with the world rotation `q`, `k` times its size about the grip, with the ammo on its back when
|
|
70
|
-
* given, and the charge gauge at `level
|
|
105
|
+
* given, and the charge gauge at `level`; its battery (capsule) where the swap has it, its glow and
|
|
106
|
+
* its counter dimmed with `light`, and the spark only when it is all on.
|
|
71
107
|
*/
|
|
72
|
-
export declare const held: (out: number[], pos: Vec3, q: Quat, lod: number, k?: number, ammo?: number, level?: number, rail?: boolean, t?: number) => void;
|
|
108
|
+
export declare const held: (out: number[], pos: Vec3, q: Quat, lod: number, k?: number, ammo?: number, level?: number, rail?: boolean, t?: number, { light, swap, empty }?: Lit) => void;
|
|
73
109
|
/** The muzzle of a gun (the rail gun's when `rail`) whose grip is at `at` and whose axes are [right, up, forward]. */
|
|
74
110
|
export declare const tip: (at: Vec3, [, u, f]: Vec3[], rail?: boolean) => Vec3;
|
|
75
111
|
/**
|
|
@@ -26,9 +26,10 @@ export interface Hud {
|
|
|
26
26
|
* the katana glyph when `wield` (or when it is all there is), or the rail gun's lightning left
|
|
27
27
|
* (charge(), 99 full) with the gun glyph in violet when `railed`. -1 ammo is no gun, `blade` is a
|
|
28
28
|
* katana carried, `rail` the rail gun's lightning (-1 none); two or more carried show their slots (1 gun, 2 katana, 3 rail gun)
|
|
29
|
-
* over the glyph, none hides it.
|
|
29
|
+
* over the glyph, none hides it. `loaded` is what the battery or the capsule of the gun in hand
|
|
30
|
+
* holds, in the same count: big, with the rest after it; faded while `swapping` it.
|
|
30
31
|
*/
|
|
31
|
-
vitals(hp: number, ammo: number, blade?: boolean, wield?: boolean, rail?: number, railed?: boolean): void;
|
|
32
|
+
vitals(hp: number, ammo: number, blade?: boolean, wield?: boolean, rail?: number, railed?: boolean, loaded?: number, swapping?: boolean): void;
|
|
32
33
|
/** A hit marker on the crosshair for a moment: a ball or a cut of the own player hit. */
|
|
33
34
|
hit(): void;
|
|
34
35
|
/**
|
|
@@ -17,9 +17,9 @@ export declare const katana: (lod: number) => number[];
|
|
|
17
17
|
export declare const arcs: (out: number[], at: Vec3, [r, u, f]: Vec3[], t: number, lod: number, k?: number) => void;
|
|
18
18
|
/**
|
|
19
19
|
* Appends the katana with its right-hand grip at `at`, axes `[right, up, forward]`, `k` times its
|
|
20
|
-
* size; with the clock `t` (s) it crackles.
|
|
20
|
+
* size; with the clock `t` (s) it crackles, once its glow is all on (`light`, 0 off to 1).
|
|
21
21
|
*/
|
|
22
|
-
export declare const sword: (out: number[], at: Vec3, ax: Vec3[], lod: number, t?: number, k?: number) => void;
|
|
22
|
+
export declare const sword: (out: number[], at: Vec3, ax: Vec3[], lod: number, t?: number, k?: number, light?: number) => void;
|
|
23
23
|
/** The sword's axes [right, up, forward] for a hand turned by `q` (see body.ts): the back of the hand to its right, the blade off the thumb toward the fingers. */
|
|
24
24
|
export declare const axes: (q: Quat) => Vec3[];
|
|
25
25
|
/** Where the fingers point for a sword with axes `ax`: the inverse of axes(). */
|
|
@@ -27,7 +27,7 @@ export declare const fingers: ([, u, f]: Vec3[]) => Vec3;
|
|
|
27
27
|
/** The right and the left wrist for a sword with its right-hand grip at `at`: the left hand is BEHIND the right one, mirrored. */
|
|
28
28
|
export declare const wrists: (at: Vec3, ax: Vec3[]) => Vec3[];
|
|
29
29
|
/** Appends the katana held in the right hand at `pos` turned by `q`. */
|
|
30
|
-
export declare const held: (out: number[], pos: Vec3, q: Quat, lod: number, t?: number, k?: number) => void;
|
|
30
|
+
export declare const held: (out: number[], pos: Vec3, q: Quat, lod: number, t?: number, k?: number, light?: number) => void;
|
|
31
31
|
/** The root of the blade and its point, in the world, for the hand at `pos` turned by `q`. */
|
|
32
32
|
export declare const ends: (pos: Vec3, q: Quat) => Vec3[];
|
|
33
33
|
/**
|
|
@@ -57,6 +57,8 @@ export declare const solid: (lod: number, len: number, radii: number[], ends?: [
|
|
|
57
57
|
* a thousand vertices at a time.
|
|
58
58
|
*/
|
|
59
59
|
export declare const place: (out: number[], src: number[], eye: Vec3, [r, u, f]: Vec3[], off: Vec3, k: number | Vec3, tint?: number[]) => void;
|
|
60
|
+
/** Dims by `k` the glow (layer -2) of the vertices of `out` from the float `from` on: a light that is off, or coming on. */
|
|
61
|
+
export declare const dim: (out: number[], from: number, k: number) => void;
|
|
60
62
|
/**
|
|
61
63
|
* Axes [r, u, f] with f along the unit vector `to` and r as near `side` as it can be: the frame of
|
|
62
64
|
* a bone, which `place` takes. Right-handed like `basis`.
|
|
@@ -2,7 +2,7 @@ import type { Quat } from './rig';
|
|
|
2
2
|
import type { Vec3 } from './mesh';
|
|
3
3
|
/** A hair colour for the runner `id`, picked at random from HAIRS but the same for everyone who sees him. */
|
|
4
4
|
export declare const hairOf: (id: number) => number[];
|
|
5
|
-
/** Jacket, its darker trim, trousers, skin, hair,
|
|
5
|
+
/** Jacket, its darker trim, trousers (the suit's legs, darker), skin, hair, boots and webbing, sole, gloves, the whites of the eyes and their irises, the lips, and the cut's cauterized face, which glows. */
|
|
6
6
|
export declare const palette: (jacket: number[], hair?: number[]) => number[][];
|
|
7
7
|
/** The ring where the eye's sleeve ends in the glove, which body.ts starts the palm on, and its sides. */
|
|
8
8
|
export declare const CUFF: number[];
|
|
@@ -169,6 +169,16 @@ export declare const FLAG_RETURN = 10;
|
|
|
169
169
|
export declare const HP_MAX = 5;
|
|
170
170
|
/** Shots the rack loads. */
|
|
171
171
|
export declare const AMMO_MAX = 60;
|
|
172
|
+
/**
|
|
173
|
+
* The magazines (the user, 2026-11-08): the gun fires from a battery in its grip, GUN_MAG shots,
|
|
174
|
+
* the rail gun from a capsule on its top, RAIL_CAP ticks of lightning (a third of a load). An empty
|
|
175
|
+
* one, or KEY.RELOAD, swaps it from what the player carries (`ammo`, `rail`): GUN_RELOAD and
|
|
176
|
+
* RAIL_RELOAD ticks without firing. u8 each on the wire.
|
|
177
|
+
*/
|
|
178
|
+
export declare const GUN_MAG = 15;
|
|
179
|
+
export declare const GUN_RELOAD = 54;
|
|
180
|
+
export declare const RAIL_CAP = 80;
|
|
181
|
+
export declare const RAIL_RELOAD = 90;
|
|
172
182
|
/** Ticks between two shots while the trigger is held: 8.6 shots a second. */
|
|
173
183
|
export declare const GUN_COOLDOWN = 7;
|
|
174
184
|
/**
|
|
@@ -22,6 +22,10 @@ export type Strike = (typeof STRIKE)[keyof typeof STRIKE];
|
|
|
22
22
|
* - In hand is the weapon he wants (KEY.BLADE the katana, KEY.RAIL the rail gun, neither the gun)
|
|
23
23
|
* when he has it, else the first he has of the gun, the katana and the rail gun; the katana
|
|
24
24
|
* stays in hand for the length of a swing. `wield` is the katana in hand, `railed` the rail gun.
|
|
25
|
+
* - The gun fires from its battery (`mag`), the rail gun from its capsule (`cap`). An empty one, or
|
|
26
|
+
* KEY.RELOAD with room in it, swaps it for a full one from what he carries: `reload` ticks
|
|
27
|
+
* without firing, then it holds GUN_MAG (RAIL_CAP) or what is left. A switch of weapon drops it.
|
|
28
|
+
* The racks fill both.
|
|
25
29
|
* - The rail gun throws its bolt on every step FIRE is held, spending a tick of it (`zapping`).
|
|
26
30
|
* - The trigger: `cool` and `swing` run down, and at 0 a held FIRE charges the gun, with ammo, and
|
|
27
31
|
* letting it go fires a ball as strong as the charge (powerOf()), spending as many shots; or it
|
|
@@ -28,7 +28,7 @@ export declare const MSG_INPUT = 1;
|
|
|
28
28
|
export declare const MSG_SNAPSHOT = 2;
|
|
29
29
|
export declare const INPUT_BYTES = 12;
|
|
30
30
|
export declare const SNAP_HEAD = 4;
|
|
31
|
-
export declare const SNAP_PLAYER =
|
|
31
|
+
export declare const SNAP_PLAYER = 58;
|
|
32
32
|
/** The match block after the players: the captures, the clock, the packs; the flags follow (2 to 16 bytes). */
|
|
33
33
|
export declare const SNAP_MATCH = 10;
|
|
34
34
|
/** Bytes of a plasma ball. */
|
|
@@ -47,6 +47,8 @@ export declare const KEY: {
|
|
|
47
47
|
* KEY.BLADE clear. Ignored without the rail gun.
|
|
48
48
|
*/
|
|
49
49
|
readonly RAIL: 2048;
|
|
50
|
+
/** Press to swap the battery or the capsule of the gun in hand (see GUN_MAG). */
|
|
51
|
+
readonly RELOAD: 4096;
|
|
50
52
|
};
|
|
51
53
|
/**
|
|
52
54
|
* The katana's cuts (PlayerState.cut, constants CUTS), chosen by the keys held when FIRE starts
|
|
@@ -186,6 +188,12 @@ export interface PlayerState {
|
|
|
186
188
|
ammo: number;
|
|
187
189
|
/** Ticks to the next shot. */
|
|
188
190
|
cool: number;
|
|
191
|
+
/** Shots in the gun's battery, of `ammo` (GUN_MAG at most). Absent reads 0. */
|
|
192
|
+
mag?: number;
|
|
193
|
+
/** Ticks of lightning in the rail gun's capsule, of `rail` (RAIL_CAP at most). Absent reads 0. */
|
|
194
|
+
cap?: number;
|
|
195
|
+
/** Ticks left swapping the battery or the capsule of the gun in hand, 0 when not. Absent reads 0. */
|
|
196
|
+
reload?: number;
|
|
189
197
|
/** Ticks FIRE has been held with the gun, up to CHARGE_TICKS, 0 when not charging. Absent reads 0. */
|
|
190
198
|
charge?: number;
|
|
191
199
|
/** The strength of the last shot, 1 to CHARGE_MAX: the shots it spent and the health it takes. Set by the step that fires; not on the wire. */
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@korial29/tiny-fps",
|
|
3
3
|
"description": "Tiny multiplayer first-person rooftop game for the browser: raw WebGL, zero runtime dependencies, WebSocket or same-browser multi-tab play.",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.51.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|