@korial29/tiny-fps 0.37.0 → 0.38.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 +2 -2
- package/dist/index.js +12 -12
- package/dist/local.js +1 -1
- package/dist/server.js +32 -17
- package/dist/types/client/beams.d.ts +2 -0
- package/dist/types/client/gun.d.ts +5 -3
- package/dist/types/shared/constants.d.ts +9 -0
- package/dist/types/shared/gun.d.ts +5 -1
- package/dist/types/shared/plasma.d.ts +2 -1
- package/dist/types/shared/protocol.d.ts +2 -2
- package/dist/types/shared/room.d.ts +1 -1
- package/dist/types/shared/types.d.ts +7 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ It started as a co-op shooter inspired by carlini's [Yet Another Doom Clone](htt
|
|
|
30
30
|
| `@korial29/tiny-fps/local` | Same-browser multiplayer, no server: the host runs in a tab | ~12.7 KB |
|
|
31
31
|
| `@korial29/tiny-fps/server` | Node WebSocket server (needs `ws`) | Node only |
|
|
32
32
|
|
|
33
|
-
CI checks the budgets (
|
|
33
|
+
CI checks the budgets (60 KB and 16 KB) on every pull request.
|
|
34
34
|
|
|
35
35
|
## Live demo
|
|
36
36
|
|
|
@@ -197,7 +197,7 @@ The game is the movement and a capture the flag on top of it, with a tackle, a g
|
|
|
197
197
|
- **A match** ends at 3 captures or after 8 minutes, then everyone sees the result and each player's captures and returns for 10 seconds, and a new match starts with everyone back at their spawn.
|
|
198
198
|
- **The map**: Highline, 94 by 240 m under an open sky, the same for both teams (the blue half is the mirror of the red one). Each team holds a 26 m tower with its flag and eight spawns. Three routes lead to the other tower, and they meet at the plaza in the middle. The **Spine** (west, 26 m) is the fast one, about 25 s by sprint: an 11 m gap that takes a dash or a double jump, a 17 m viaduct along a wall that takes a wall-run and a dash, a beam over the plaza. **Midtown** (centre, 19 to 21 m) is roofs, short gaps and ledges to grab, about 36 s. The **Lowline** (east, 14.5 m) is stairs, short gaps and a sign to slide under, about 39 s, and needs no special move. A miss costs time: roofs under the gaps and ladders of ledges lead back up, and only a fall into the street puts you back at your tower.
|
|
199
199
|
- **Weapons**: each team's armoury is a plinth 1.5 m high past its flag, in sight of the spawns, with a gun rack and a katana rack: run and jump up to take them. You spawn with neither and carry both once taken.
|
|
200
|
-
- The **plasma gun** holds 60 shots
|
|
200
|
+
- The **plasma gun** holds 60 shots. A click fires a plasma ball at 40 m/s that bursts on the first wall or enemy it touches, and the view kicks up with each one. Held, the button charges the next ball, shown by a gauge under the ammo counter, and letting go fires it: up to 5 shots' worth in one second, which takes 5 health and puts any enemy down.
|
|
201
201
|
- The **electric katana** needs no ammo. A cut takes 2 to 4 health by the cut, reaches 2.2 to 3.2 m, and shocks a foe it does not put down: a short stumble the way the blade goes. A cut that puts a foe down takes off the limb the blade crosses, head, arm or leg, drawn only, with no blood.
|
|
202
202
|
- **Health**: 5 points, a plasma hit takes 1, no friendly fire, no regeneration. At 0 a player lies down for 2 seconds, drops a carried flag, loses both weapons and comes back at a team spawn. Health packs give 2 points and ammo packs 20 shots; a taken pack is back after 20 seconds.
|
|
203
203
|
- **Moving**: momentum, sprint, dash, double jump, ledge grab and climb, wall-run, slide, coyote time and a jump buffer. The host decides where everyone is. Your own moves show at once (the client predicts them) and are corrected to the host's state, to the bit.
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var e=.4,t=1.8,n=1.55,r=.5,i=.9,a=7.5,o=2.4,s=5.5,c=2.5,l=[`Red`,`Blue`],u=[`#ff3d4f`,`#2f80ff`],d=1.5,f=.12,p=.012,m=1.2,h=[{ticks:28,strike:10,reach:2.65,arc:.3,hp:2},{ticks:34,strike:13,reach:2.15,arc:1.2,hp:2},{ticks:34,strike:13,reach:2.15,arc:1.2,hp:2},{ticks:40,strike:16,reach:2.15,arc:.45,hp:3},{ticks:36,strike:12,reach:3.2,arc:.3,hp:3},{ticks:48,strike:24,reach:2.3,arc:Math.PI,hp:3},{ticks:48,strike:24,reach:2.3,arc:Math.PI,hp:3},{ticks:58,strike:40,reach:2.4,arc:.6,hp:4}],g=7.5,_={HOME:0,CARRIED:1,DROPPED:2},v={FORWARD:1,BACK:2,LEFT:4,RIGHT:8,JUMP:16,SPRINT:32,DASH:64,CROUCH:128,FIRE:256,BLADE:512,SPECIAL:1024},y={THRUST:0,LEFT:1,RIGHT:2,SLASH:3,LUNGE:4,SPIN_L:5,SPIN_R:6,LEAP:7},b={NONE:0,HEAD:1,ARM_L:2,ARM_R:3,LEG_L:4,LEG_R:5},x={GROUND:0,AIR:1,WALLRUN:2,HANG:3,CLIMB:4,SLIDE:5,CROUCH:6},S={NONE:0,EAST:1,WEST:2,SOUTH:3,NORTH:4},C={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},w={BRICK:0,TILE:1,LAVA:2,STONE:3,METAL:4,WOOD:5,MOSS:6,GRATE:7,CONCRETE:8,GLASS:9,STEEL:10,PAINT:11},T=-30,E=(e,t,n,r,i,a=w.CONCRETE)=>({min:[e,T,t],max:[n,i,r],top:w.CONCRETE,side:a}),D=([e,t,n],[r,i,a],o,s=o,c)=>({min:[e,t,n],max:[r,i,a],top:o,side:s,tint:c});[E(4,57.7,24,76,10),E(4,36,24,53.5,10,w.GLASS),E(4,20,24,36,12.4),E(4,-5,24,7,12.4,w.GLASS),E(27,20,47,50,8),E(27,60,47,76,8,w.BRICK),D([9,12.2,39],[19,12.6,47],w.STEEL),...((e,t)=>[1,2,3,4,5,6].map(n=>D([12,t,e-n],[14,t+.4*n,e-n+1],w.CONCRETE)))(53,10),D([5,10,42],[5.5,14,42.5],w.STEEL),D([5,10,50],[5.5,14,50.5],w.STEEL),D([8,12.4,24],[20,12.85,24.45],w.STEEL),D([36,8,22],[37,14.5,48],w.PAINT,w.PAINT,[.15,.72,.62]),D([30,8,28],[34,10,32],w.CONCRETE),D([40,8,30],[44,10.2,34],w.PAINT,w.PAINT,[1,.3,.06]),D([28,9.2,44],[35,12,46],w.STEEL,w.PAINT,[.2,.42,1]),D([41.5,7.6,50],[42,8,60],w.STEEL),D([30,8,64],[34,9.6,68],w.PAINT,w.PAINT,[.2,.8,.3])];var O=240,k=[1,.22,.26],A=[.2,.46,1],j=[1,.42,.08],ee=[.12,.7,.62],M=(e,t,n,r,i,a,o)=>D([e,t,n],[r,i,a],w.PAINT,w.PAINT,o),te=(e,t,n,r,i,a,o,s=T)=>{let c=Math.ceil((o-a)/.46);return Array.from({length:c},(l,u)=>{let[d,f]=[t+(n-t)*u/c,t+(n-t)*(u+1)/c].sort((e,t)=>e-t),p=a+(o-a)*(u+1)/c;return e===0?D([d,s,r],[f,p,i],w.CONCRETE):D([r,s,d],[i,p,f],w.CONCRETE)})},N=(e,t,n,r,i,a,o)=>o.map((o,s)=>D([e+s*n,a,t+s*r],[e+s*n+4,o,t+s*r+i],w.STEEL,w.CONCRETE)),P=[E(12,212,52,240,26,w.GLASS),M(12,26,212,52,26.12,212.5,k),M(12,26,239.5,52,26.12,240,k),M(12,26,212.5,12.5,26.12,239.5,k),M(51.5,26,212.5,52,26.12,239.5,k),M(11.6,12,222,12,25.8,232,k),M(28,12,211.4,31,25.5,212,k),D([19,26,222],[22,27.4,225],w.STEEL),D([42,26,222],[45,27.4,225],w.STEEL),D([29,26,229],[35,27.1,229.6],w.CONCRETE),D([29,26,215],[35,27.5,219],w.STEEL,w.PAINT,k),E(6,164,26,201,26,w.GLASS),E(6,134,26,147,26,w.GLASS),E(6,201,26,212,19),E(15,147,26,164,19),D([14,26,164],[15,32,196],w.PAINT,w.PAINT,ee),D([14,18,147],[15,32,164],w.PAINT,w.PAINT,ee),D([14,26,134],[15,32,147],w.PAINT,w.PAINT,ee),...N(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])=>D([e,19,t],[n,i,r],w.STEEL,w.CONCRETE)),D([20,26,178],[23,27.3,181],w.STEEL),D([8,26,176],[11,27.2,179],w.STEEL),D([8,26,190],[11,27.3,193],w.STEEL),D([20,26,140],[23,27.3,143],w.STEEL),E(32,186,76,209,19),M(32,19,207.5,76,19.1,209,k),...N(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])=>D([e,T,t],[n,i,r],w.STEEL,w.CONCRETE)),E(32,166,64,182,21.2,w.GLASS),E(32,140,64,161,19),D([40,21.2,172],[44,22.6,176],w.STEEL),D([52,19,148],[57,20.3,151],w.STEEL),D([38,19,196],[41,20.4,199],w.STEEL),D([60,19,200],[63,20.4,203],w.STEEL),D([52,19,190],[58,20.6,194],w.STEEL),D([66,19,204],[72,20.2,207],w.STEEL),D([56,21.2,170],[60,22.4,174],w.STEEL),D([34,19,152],[37,20.3,156],w.STEEL),...N(36,135,18,0,3,15,[17.2,17.2]),...N(6.5,129,6,0,4,15,[17.2,19.4,21.6,23.8]),E(76,213,100,240,14.5,w.STEEL),M(76,14.5,238.5,100,14.6,240,k),E(76,185,100,209,14.5),E(76,138,100,181,14.5,w.GLASS),D([80,15.7,158],[96,17.7,162],w.STEEL,w.PAINT,j),D([82,14.5,234],[85,15.9,237],w.STEEL),D([91,14.5,190],[94,15.9,193],w.STEEL),D([80,14.5,204],[83,15.6,207],w.STEEL),D([78,14.5,170],[81,15.9,173],w.STEEL),D([92,14.5,146],[95,15.7,149],w.STEEL),D([92,14.5,222],[96,15.8,226],w.STEEL),...te(0,76,52,226,232,14.5,26),...te(0,85,76,196,202,14.5,19,14.5)],F=[E(6,106,62,134,15),E(62,106,100,134,14.5),D([34,15,112],[54,17.2,128],w.CONCRETE),M(38,17.2,116,50,17.3,124,j),...[[35,113],[35,126.2],[51,113],[51,126.2]].map(([e,t])=>D([e,17.2,t],[e+.8,21.5,t+.8],w.STEEL)),D([34.6,21.5,112.6],[52.2,21.9,127.4],w.GLASS),D([14,15,114],[17,16.5,117],w.STEEL),D([14,15,123],[17,16.5,126],w.STEEL),D([56,15,114],[59,16.5,117],w.STEEL),D([56,15,123],[59,16.5,126],w.STEEL),D([15.35,25.5,106],[15.85,26,134],w.STEEL),D([70,14.5,108],[70.8,38,108.8],w.STEEL),D([70,14.5,131.2],[70.8,38,132],w.STEEL),D([66,14.5,110],[69,15.9,113],w.STEEL),D([66,14.5,127],[69,15.9,130],w.STEEL)],I=e=>({...e,min:[e.min[0],e.min[1],O-e.max[2]],max:[e.max[0],e.max[1],O-e.min[2]],tint:e.tint===k?A:e.tint}),L=(e,t,n)=>[...[16,22,28,34,40].map(n=>[n,26,t,e]),...[19,31,43].map(t=>[t,26,n,e])],R=[[20,26,190],[48,21.2,172],[48,19,200],[88,14.5,198]],ne=[[21,26,168],[46,19,144],[36,21.2,178],[88,14.5,216],[88,14.5,172]],re={name:`Highline`,brushes:[...P,...P.map(I),...F],teams:[{base:[32,26,224],spawns:L(0,236,231),rack:[30.75,27.5,217],blade:[33.25,27.5,217]},{base:[32,26,16],spawns:L(Math.PI,4,9),rack:[30.75,27.5,23],blade:[33.25,27.5,23]}],packs:[...R,...R.map(([e,t,n])=>[e,t,O-n]),[24,15,112],[24,15,128]],ammo:[...ne,...ne.map(([e,t,n])=>[e,t,O-n])],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]},ie=4,ae=1024,oe=(e,t)=>(e+ae)*(2*ae)+t+ae,se=(e,t)=>Math.min(Math.max(Math.floor(e/t),-1024),1023),ce=(e,t=ie)=>{let n=/* @__PURE__ */ new Map;return e.brushes.forEach(({min:e,max:r},i)=>{for(let a=se(e[0],t);a<=se(r[0],t);a++)for(let o=se(e[2],t);o<=se(r[2],t);o++){let e=oe(a,o),t=n.get(e);t?t.push(i):n.set(e,[i])}}),{def:e,cell:t,grid:n}},z=(e,t,n,r)=>{let i=[];for(let a=se(t-r,e.cell);a<=se(t+r,e.cell);a++)for(let t=se(n-r,e.cell);t<=se(n+r,e.cell);t++)for(let n of e.grid.get(oe(a,t))??[])i.includes(n)||i.push(n);return i},le=(e,t,n,r,i=0)=>{let{cell:a,def:o}=e,s=r,c=se(t[0],a),l=se(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(oe(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)>ae||Math.abs(l)>ae)return s;m<h?(c+=u,m+=g):(l+=d,h+=_)}},ue=(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&&le(e,t,[r/o,i/o,a/o],o)<o-1e-4},B=1/60,V=Math.PI*2,de=1e-6,fe=.01,pe=.001,me=e=>(e%V+V)%V,he=e=>[-Math.sin(e),-Math.cos(e)],ge=Math.fround,_e=Math.sqrt,ve=(e,t,n)=>Math.min(Math.max(e,t),n),ye=(e,t)=>_e(e*e+t*t),be=[[0,0],[1,0],[-1,0],[0,1],[0,-1]],xe={vx:0,vz:0,mode:x.GROUND,t:0,wall:S.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:b.NONE,ev:0,fall:0},Se=(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:ge(a),y:ge(o),z:ge(s),vy:0,yaw:me(c),pitch:0,ground:!0,...xe}},Ce=(e,t,n)=>{let{yaw:r,pitch:i,id:a,shots:o,hits:s}=e;Object.assign(e,Se(a,t,a,n),{yaw:r,pitch:i,shots:o,hits:s,ev:e.ev|C.RESPAWN})},we=e=>e===x.GROUND||e===x.SLIDE||e===x.CROUCH,Te=e=>e.mode===x.SLIDE||e.mode===x.CROUCH?i:t,Ee=e=>e.mode===x.SLIDE||e.mode===x.CROUCH?.7:1.6,De=e=>ye(e.vx,e.vz),Oe=e=>e.mode===x.GROUND&&ye(e.vx,e.vz)>6.5,ke=(e,t,n)=>e.max[1]>t+.5+fe&&e.min[1]<t+n-fe,Ae=(e,t,n)=>[t-ve(t,e.min[0],e.max[0]),n-ve(n,e.min[2],e.max[2])],je=(t,n,r)=>{let{brushes:i}=n.def,a=z(n,t.x,t.z,2*e),o=(e-de)**2,[s,c]=[0,0];for(let n=0;n<4;n++){let n=0,l=0,u=0;for(let s of a){let a=i[s];if(!ke(a,t.y,r))continue;let[c,d]=Ae(a,t.x,t.z),f=c*c+d*d;if(f>=o)continue;if(f){let t=_e(f);.4-t>n&&(n=e-t,l=c/t*n,u=d/t*n);continue}let[p,m,h]=[[t.x-a.min[0],-1,0],[a.max[0]-t.x,1,0],[t.z-a.min[2],0,-1],[a.max[2]-t.z,0,1]].reduce((e,t)=>t[0]<e[0]?t:e);p+.4>n&&(n=p+e,[l,u]=[m*n,h*n])}if(!n)break;t.x+=l,t.z+=u,s+=l,c+=u}return[s,c]},Me=(t,n,r)=>{let{brushes:i}=n.def,a=(e-de)**2,o=-1/0,s=1/0;for(let c of z(n,t.x,t.z,e)){let e=i[c],[n,l]=Ae(e,t.x,t.z);n*n+l*l>=a||(e.max[1]<=t.y+.5+fe?o=Math.max(o,e.max[1]):e.min[1]>=t.y+r-fe&&(s=Math.min(s,e.min[1])))}return[o,s]},Ne=(t,n)=>{let r=(e-de)**2;return z(n,t.x,t.z,e).every(e=>{let i=n.def.brushes[e],[a,o]=Ae(i,t.x,t.z);return a*a+o*o>=r||!ke(i,t.y,1.8)})},Pe=(t,n,r,i,a)=>{let o=(e-de)**2;return z(t,n,r,e).every(e=>{let s=t.def.brushes[e],[c,l]=Ae(s,n,r);return c*c+l*l>=o||s.max[1]<=i||s.min[1]>=a})},Fe=(e,t)=>{let[n,r]=be[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}},Ie=(e,t,n,r)=>{let{a:i,o:a,sign:o,c:s,co:c}=Fe(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},Le=(t,n,r)=>{let i;for(let a of z(n,t.x,t.z,.9)){let o=n.def.brushes[a],s=Ie(o,t,r,.5);s!==void 0&&o.min[1]<t.y+.5&&o.max[1]>t.y+1.8&&(i=Math.min(i??1/0,Math.max(0,s-e)))}return i},Re=(e,t)=>{let[n,r]=he(e.yaw),i;for(let a=1;a<=4;a++){let[o,s]=be[a];if(a===e.wall||n*o+r*s<.5)continue;let{a:c,sign:l}=Fe(e,a);for(let n of z(t,e.x,e.z,.6000000000000001)){let r=t.def.brushes[n],o=r.max[1],s=o-e.y;if(Ie(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*.43000000000000005,f=u+l*.2,[p,m]=c===0?[d,e.z]:[e.x,d],[h,g]=c===0?[f,e.z]:[e.x,f];Pe(t,p,m,Math.min(e.y,o-2)+fe,o+1.8)&&Pe(t,h,g,o+fe,o+1.8)&&(i={side:a,top:o,hang:d})}}return i},ze=(e,t)=>{let{a:n,o:r,sign:i,c:a,co:o}=Fe(e,e.wall);return z(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 ge(c.max[1])===e.edge&&o>=c.min[r]&&o<=c.max[r]&&l>=.2})},Be=(e,n)=>{if(e.vy>=0)return!1;let[r]=Me(e,n,t),i=6*B;return e.y-r<=-e.vy*i+10*i*i},Ve=(e,t)=>{e.mode=t,e.t=0},He=(e,t)=>{let n=ye(e.vx,e.vz);n>t&&(e.vx*=t/n,e.vz*=t/n)},Ue=(t,n,r,i)=>{let[a,o]=[r.wx,r.wz];for(let r of z(n,t.x,t.z,e+pe)){let e=n.def.brushes[r],[s,c]=Ae(e,t.x,t.z),l=ye(s,c);if(l>0&&l<=.4+pe&&ke(e,t.y,i)){let e=(-a*s-o*c)/l;e>0&&(a+=e*s/l,o+=e*c/l)}}return[a,o]},We=(e,t,n)=>{let r=ye(t[0],t[1]);if(r<de){let t=ye(e.vx,e.vz),n=t?Math.max(0,t-45*B)/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=ye(s,c);if(l){let e=Math.max(0,l-45*B)/l;[s,c]=[s*e,c*e]}n*=r,o=o<n?Math.min(n,o+(o>=6?3:50)*B):Math.max(n,o-12*B),e.vx=s+o*i,e.vz=c+o*a},Ge=(e,t,n,r,i)=>{let a=e.y;e.x+=e.vx*B,e.z+=e.vz*B;let[o,s]=je(e,t,n),c=ye(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]=Me(e,t,n),d=e.vy-r*20*B;if(e.y+=(e.vy+d)/2*B,e.vy=d,e.y+n>u&&(e.y=u-n,e.vy=Math.min(e.vy,0)),e.vy<=0?e.y<=l+fe: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},Ke=(e,t)=>{e.vy=t,e.coyote=0,e.buffer=0,e.ev|=C.JUMP},qe=(e,n,r)=>{let[i,a]=be[e.wall],o=t=>{Ve(e,t),e.edge=0};if(r.keys&(v.BACK|v.CROUCH))o(x.AIR),e.coyote=0;else if(r.jump&&r.fx*i+r.fz*a<0)o(x.AIR),e.vx=-i*4,e.vz=-a*4,Ke(e,6);else if(r.jump||r.fwd&&e.t>=6)Ve(e,x.CLIMB);else if(e.t>=30)o(x.AIR),e.coyote=0;else{let r=Math.max(e.edge-2,Me(e,n,t)[0]);e.y+=ve(r-e.y,-8*B,8*B)}},Je=(e,t)=>{let[n,r]=be[e.wall];e.y<e.edge?e.y=Math.min(e.edge,e.y+8*B):(e.x+=n*s*B,e.z+=r*s*B),e.y>=e.edge&&ze(e,t)?(Ve(e,x.GROUND),e.vx=n*3,e.vz=r*3,e.vy=0,e.edge=0,e.wall=S.NONE,e.coyote=6,e.ev|=C.CLIMB):e.t>=40&&(Ve(e,e.y>=e.edge?x.GROUND:x.AIR),e.edge=0,e.wall=S.NONE)},Ye=(e,t,n)=>{let[r,i]=be[e.wall],a=e.vx*r+e.vz*i,[o,s]=[e.vx-a*r,e.vz-a*i],c=ye(o,s);if(n.jump)Ve(e,x.AIR),e.vx=o-r*5,e.vz=s-i*5,Ke(e,6.5),e.jumps=1,e.dashes=1,e.ev|=C.WALLRUN_END;else{let a=Le(e,t,e.wall);if(a===void 0||!n.fwd||c<3.5||e.t>=60){Ve(e,x.AIR),e.ev|=C.WALLRUN_END;return}let l=Math.max(0,c-1.5*B)/c;e.vx=o*l,e.vz=s*l;let u=Math.min(a,4*B);e.x+=r*u,e.z+=i*u}},Xe=(e,t,n)=>{if(!n.fwd)return;let r=ye(e.vx,e.vz);if(!(r<4.5))for(let n=1;n<=4;n++){let[i,a]=be[n],o=e.vx*i+e.vz*a,[s,c]=[e.vx-o*i,e.vz-o*a];if(n!==e.wall&&o<=.75*r&&o>=-.2*r&&Le(e,t,n)!==void 0){let t=ye(s,c),i=Math.max(t,.9*r)/t;Ve(e,x.WALLRUN),e.wall=n,[e.vx,e.vz]=[s*i,c*i],e.vy=ve(e.vy,2,3),e.jumps=1,e.dashes=1,e.coyote=0,e.ev|=C.WALLRUN_START;return}}},Ze=(e,t)=>{Ve(e,x.HANG),e.wall=t.side,e.edge=ge(t.top),t.side<=S.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|=C.GRAB},Qe=(e,t,n)=>{let r=e.mode===x.GROUND;if(n.dash&&e.dash===0&&(r||(e.mode===x.AIR||e.mode===x.WALLRUN)&&e.dashes>0)){let[t,i]=n.wx||n.wz?[n.wx,n.wz]:[n.fx,n.fz];r||(e.dashes--,e.vy=0,e.mode===x.WALLRUN&&(Ve(e,x.AIR),e.ev|=C.WALLRUN_END)),e.vx=t*16,e.vz=i*16,e.dash=60,e.ev|=C.DASH}let i=e.dash>50;e.mode===x.WALLRUN&&Ye(e,t,n),we(e.mode)&&$e(e,t,n,i),e.mode===x.AIR&&et(e,t,n,i);let o=i&&e.vy<=0?0:e.mode===x.WALLRUN?.15:1,s=e.mode,c=Ge(e,t,Te(e),o,we(s));if(c>=0){if(!we(e.mode)){if(e.ev|=C.LAND|(e.mode===x.WALLRUN?C.WALLRUN_END:0),e.fall=c,e.jumps=1,e.dashes=1,e.wall=S.NONE,n.keys&v.CROUCH){let t=ye(e.vx,e.vz)>=a;Ve(e,t?x.SLIDE:x.CROUCH),e.ev|=t?C.SLIDE_START:0}else Ve(e,x.GROUND)}e.coyote=6}else we(e.mode)&&(e.ev|=e.mode===x.SLIDE?C.SLIDE_END:0,Ve(e,x.AIR));if(e.mode===x.AIR){let r=Re(e,t);r?Ze(e,r):Xe(e,t,n)}},$e=(e,n,r,o)=>{let s=(r.keys&v.CROUCH)!==0;if(e.buffer>0&&(e.mode===x.GROUND||Ne(e,n))){e.ev|=e.mode===x.SLIDE?C.SLIDE_END:0,Ve(e,x.AIR),Ke(e,7);return}let l=ye(e.vx,e.vz);if(e.mode===x.GROUND&&s){let t=l>=a;Ve(e,t?x.SLIDE:x.CROUCH),e.ev|=t?C.SLIDE_START:0}else e.mode===x.SLIDE&&(e.t>=60||l<4.5||r.stumble)?(e.ev|=C.SLIDE_END,Ve(e,!s&&Ne(e,n)?x.GROUND:x.CROUCH)):e.mode===x.SLIDE&&!s&&Ne(e,n)?(e.ev|=C.SLIDE_END,Ve(e,x.GROUND)):e.mode===x.CROUCH&&!s&&Ne(e,n)&&Ve(e,x.GROUND);if(!o){if(r.stumble){if(l>2.5){let t=Math.max(c,l-12*B)/l;e.vx*=t,e.vz*=t}else We(e,Ue(e,n,r,Te(e)),c)}else if(e.mode===x.SLIDE){let t=Math.max(0,l-4*B)/l;e.vx*=t,e.vz*=t}else if(e.mode===x.CROUCH)We(e,Ue(e,n,r,i),3);else{let i=(r.keys&v.SPRINT)!==0&&r.fwd;We(e,Ue(e,n,r,t),i?9:6)}}},et=(e,t,n,r)=>{if(e.buffer>0&&(e.coyote>0?Ke(e,7):e.jumps>0&&!Be(e,t)&&(e.jumps--,Ke(e,6),e.ev=e.ev&~C.JUMP|C.DOUBLE)),r||!n.wx&&!n.wz)return;let i=ye(e.vx,e.vz);e.vx+=n.wx*14*B,e.vz+=n.wz*14*B,He(e,Math.max(i,6))},tt=(e,t,r,i=0)=>{e.yaw=me(t.yaw),e.pitch=Math.max(-1.55,Math.min(n,t.pitch));let a=(t.keys&v.FORWARD?1:0)-(t.keys&v.BACK?1:0),o=(t.keys&v.RIGHT?1:0)-(t.keys&v.LEFT?1:0),s=ye(a,o)||1,[c,l]=he(e.yaw),u=n=>(t.keys&n)!==0&&(e.held&n)===0,d=e.stun>0,f={keys:t.keys,stumble:d,jump:!d&&u(v.JUMP),dash:!d&&u(v.DASH),fwd:a>0,wx:(c*a-l*o)/s,wz:(l*a+c*o)/s,fx:c,fz:l},p=e.mode;e.ev=0,e.fall=0,f.jump&&(e.buffer=7),d&&e.stun--,e.dash>0&&(e.dash--,e.dash===50&&He(e,10)),e.mode===x.HANG&&qe(e,r,f),e.mode===x.CLIMB?Je(e,r):e.mode!==x.HANG&&Qe(e,r,f),e.y<r.def.floor&&Ce(e,r,i),e.t=e.mode===p?Math.min(255,e.t+1):e.t,e.buffer=Math.max(0,e.buffer-1),e.mode===x.AIR&&p===x.AIR&&(e.coyote=Math.max(0,e.coyote-1)),e.held=t.keys&(v.JUMP|v.DASH),e.ground=we(e.mode),e.x=ge(e.x),e.y=ge(e.y),e.z=ge(e.z),e.vx=ge(e.vx),e.vy=ge(e.vy),e.vz=ge(e.vz),e.edge=ge(e.edge)},nt=127,rt=16,it=32,at=128/Math.PI,ot=254/Math.PI,st=65536/(2*Math.PI),ct=e=>Math.round(e*st)&65535,lt=e=>Math.max(-32768,Math.min(32767,Math.round(e))),ut=e=>lt(e*1e4),dt=e=>e/1e4,ft=e=>e/st,pt=(e=0)=>Math.round(e*256)&16777215,mt=e=>({...e,yaw:ft(ct(e.yaw)),pitch:dt(ut(e.pitch)),...e.view!==void 0&&{view:pt(e.view)/256}}),ht=e=>{let t=/* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(12));t.setUint8(0,1),t.setUint16(1,e.seq&65535),t.setUint16(3,e.keys&2047),t.setUint16(5,ct(e.yaw)),t.setInt16(7,ut(e.pitch));let n=pt(e.view);return t.setUint16(9,n>>8),t.setUint8(11,n&255),t.buffer},gt=e=>e===_.CARRIED?2:e===_.DROPPED?8:1,_t=e=>{if(e.byteLength<4)return null;let t=new DataView(e),n=t.getUint8(3),r=4+47*n;if(t.getUint8(0)!==2||e.byteLength<r+8+2)return null;let i=[];for(let e=0;e<n;e++){let n=4+e*47,r=t.getUint8(n+35),a=t.getUint8(n+38),[o,s]=[t.getUint8(n+37),t.getUint8(n+39)],c=r&7,l=t.getUint8(n+40)<<16|t.getUint16(n+41);i.push({id:t.getUint8(n),x:t.getFloat32(n+1),y:t.getFloat32(n+5),z:t.getFloat32(n+9),vx:t.getFloat32(n+13),vy:t.getFloat32(n+17),vz:t.getFloat32(n+21),edge:t.getFloat32(n+25),yaw:ft(t.getUint16(n+29)),pitch:dt(t.getInt16(n+31)),ack:t.getUint16(n+33),ground:c===x.GROUND||c===x.SLIDE||c===x.CROUCH,mode:c,wall:r>>3&7,jumps:r>>6&1,dashes:r>>7,t:t.getUint8(n+36),dash:o&63,stun:s&63,by:o>>6<<2|s>>6,coyote:a&7,buffer:a>>3&7,held:(a&64?v.JUMP:0)|(a&128?v.DASH:0),ev:0,fall:0,hp:l&7,cool:l>>3&7,ammo:(l>>6&127)===nt?-1:l>>6&127,down:l>>13&127,rack:(l>>20&1)==1,shots:t.getUint8(n+43),hits:t.getUint8(n+44),blade:(l>>21&1)==1,wield:(l>>22&1)==1,zap:(l>>23&1)==1,swing:t.getUint8(n+45)&63,cut:t.getUint8(n+45)>>6|t.getUint8(n+46)>>1&4,lost:t.getUint8(n+46)&7})}let a=t.getUint16(r+2),o=r+8,s=[];for(let n=0;n<2;n++){let n=o<e.byteLength?t.getUint8(o):-1;if(n<0||n>_.DROPPED||o+gt(n)>e.byteLength)return null;let r={state:n,by:0,x:0,y:0,z:0,left:0};n===_.CARRIED?r.by=t.getUint8(o+1):n===_.DROPPED&&([r.x,r.y,r.z]=[1,3,5].map(e=>t.getInt16(o+e)/rt),r.left=t.getUint8(o+7)),s.push(r),o+=gt(n)}let c=o<e.byteLength?t.getUint8(o++)||-1:0;if(o+c*10!==e.byteLength)return null;let l=[];for(let e=0;e<c;e++,o+=10){let[e,n]=[t.getUint8(o+8)/at,t.getInt8(o+9)/ot];l.push({id:t.getUint8(o),by:t.getUint8(o+1)&127,x:t.getInt16(o+2)/it,y:t.getInt16(o+4)/it,z:t.getInt16(o+6)/it,dx:-Math.sin(e)*Math.cos(n),dy:Math.sin(n),dz:-Math.cos(e)*Math.cos(n),burst:t.getUint8(o+1)>127})}return{tick:t.getUint16(1),players:i,score:[t.getUint8(r),t.getUint8(r+1)],clock:a&32767,over:!!(a&32768),flags:s,packs:t.getUint32(r+4),...c?{balls:l}:{}}},vt=e=>{try{let t=JSON.parse(e);return t&&typeof t.t==`string`?t:null}catch{return null}},yt=44100,bt=([e,t,n,r,i,a,o,s,c,l,u],d,f=yt)=>{let p=new Float32Array(Math.ceil((r+i+a)*f)),m=0,h=0,g=0,_=()=>{d=d+1831565813|0;let e=Math.imul(d^d>>>15,1|d);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/2**31-1};for(let d=0;d<p.length;d++){let v=d/f;m+=t*2**(n*v)*(v>c?l:1)*(1+o*Math.sin(v*44))/f,m>=1&&(m%=1,g=_());let y=e==3?g:e==2?Math.sin(m*2*Math.PI):e?1-2*m:m<.5?1:-1;h+=(y-h)*s;let b=v<r?v/r:v<r+i?1:((r+i+a-v)/a)**2;p[d]=h*b*u}return p},H={STEP:0,WALLSTEP:1,JUMP:2,DOUBLE:3,DASH:4,LAND:5,GRAB:6,SCUFF:7,WIND:8,SCRAPE:9,TAKE:10,DROP:11,RETURN:12,CAPTURE:13,TACKLE:14,GRUNT:15,LASER:16,HIT:17,HURT:18,DOWN:19,GUN:20,PACK:21,DRY:22,SHING:23,SWISH:24,ZAP:25,SPLASH:26},xt=[[[2,130,-3,.001,.005,.06,0,1,0,1,.7],[3,8e3,-1,.001,0,.035,0,.4,0,1,.45]],[[3,12e3,0,.001,0,.03,0,.5,0,1,.4],[2,190,-3,.001,0,.04,0,1,0,1,.3]],[[3,14e3,0,.015,.02,.09,.3,.18,0,1,.5],[2,70,-2,.003,0,.07,0,1,0,1,.3]],[[3,4e3,3.5,.03,.03,.2,0,.25,0,1,.5],[2,350,1.2,.03,.02,.18,.02,1,0,1,.12]],[[3,14e3,-2.5,.008,.07,.2,.25,.3,0,1,.8],[3,3500,.5,.01,.06,.2,0,.12,0,1,.5]],[[2,70,-2.5,.001,.01,.2,0,1,0,1,.9],[3,7e3,-1,.001,0,.09,0,.25,0,1,.5]],[[3,6e3,-1,.001,0,.05,0,.5,0,1,.7],[2,160,-4,.001,0,.07,0,1,0,1,.5]],[[3,5e3,0,.01,.04,.14,.5,.3,0,1,.5],[3,2500,0,.03,0,.1,.4,.2,0,1,.3,.08]],[[3,2e4,0,.001,2.1,.001,.25,.06,0,1,1.2],[3,2e4,0,.001,2.1,.001,.35,.3,0,1,.3]],[[3,9e3,0,.001,2.1,.001,.5,.4,0,1,.5],[3,3e3,0,.001,2.1,.001,.4,.2,0,1,.5]],[[0,392,0,.003,.05,.08,0,.35,.07,1.5,.5],[2,784,0,.003,.03,.1,.01,1,0,1,.3,.05]],[[1,330,-2.2,.003,.04,.22,.04,.25,0,1,.45],[3,2500,-1,.001,0,.12,0,.3,0,1,.4]],[[2,659,0,.003,.06,.25,.015,1,.09,1.5,.5],[2,1318,0,.003,.03,.2,0,1,0,1,.2,.09]],[[0,523,0,.004,.07,.1,0,.3,0,1,.4],[0,659,0,.004,.07,.1,0,.3,0,1,.4,.11],[0,784,0,.004,.07,.1,0,.3,0,1,.4,.22],[0,1047,0,.004,.2,.35,.008,.3,0,1,.5,.33],[2,262,0,.004,.25,.3,0,1,0,1,.35,.33]],[[2,120,-3,.001,.01,.24,0,1,0,1,1],[3,5e3,-1.5,.001,0,.09,0,.35,0,1,.7],[3,2200,0,.01,.03,.16,.3,.15,0,1,.4,.03]],[[1,170,-.9,.012,.05,.17,.06,.2,0,1,.5],[3,3e3,0,.01,.04,.14,.4,.12,0,1,.5]],[[0,2400,-36,.001,.012,.09,.02,.35,0,1,.32],[1,2470,-36,.001,.012,.09,.02,.3,0,1,.26],[2,190,-6,.001,.01,.06,0,1,0,1,.45]],[[2,1700,0,.001,0,.13,0,1,0,1,.6],[2,4700,0,.001,0,.05,0,1,0,1,.3],[2,1790,0,.001,0,.09,0,1,0,1,.3]],[[2,110,-2.5,.002,.01,.2,0,1,0,1,.9],[3,2500,0,.02,.03,.17,.3,.12,0,1,.5,.04]],[[2,90,-1.2,.002,.04,.45,0,1,0,1,.9],[1,180,-1.5,.01,.06,.4,.05,.2,0,1,.45],[3,3e3,0,.02,0,.35,.3,.1,0,1,.4,.12]],[[3,5e3,0,.001,0,.02,0,.5,0,1,.5],[0,260,1.5,.005,.06,.12,0,.25,0,1,.4,.02],[2,1040,.5,.003,.03,.18,.01,1,0,1,.25,.1]],[[2,523,0,.003,.03,.1,0,1,0,1,.4],[2,659,0,.003,.03,.1,0,1,0,1,.4,.07],[2,880,0,.003,.05,.2,.01,1,0,1,.45,.14]],[[0,190,-3,.001,0,.04,0,.6,0,1,.6],[3,6e3,0,.001,0,.02,0,.5,0,1,.5]],[[3,6e3,1.5,.002,.04,.07,.2,.6,0,1,.5],[2,3300,.05,.004,.02,.32,.012,1,0,1,.3,.04],[2,5250,0,.003,0,.22,0,1,0,1,.18,.04],[2,7900,0,.003,0,.12,0,1,0,1,.1,.04]],[[3,1800,7,.07,0,.09,0,.5,0,1,.6],[3,5e3,-6,.01,0,.12,.2,.3,0,1,.4,.08]],[[3,900,1.5,.001,.05,.14,.9,1,0,1,.55],[1,95,.6,.001,.07,.12,.6,.5,.05,2,.35],[2,2600,-4,.001,0,.1,.3,1,0,1,.25],[3,7e3,0,.001,0,.04,0,.6,0,1,.3,.1]],[[3,8e3,-3,.001,.02,.15,0,.5,0,1,.6],[2,500,8,.002,.01,.05,0,1,.03,1.5,.45,.01],[3,1500,-1,.001,.03,.1,.9,1,0,1,.3,.01]]],St=[H.WIND,H.SCRAPE],Ct=(e,t=xt)=>{let n=t[e].map((t,n)=>[bt(t,e*9+n),Math.round((t[11]??0)*yt)]);return Float32Array.from({length:Math.max(...n.map(([e,t])=>t+e.length))},(e,t)=>Math.tanh(n.reduce((e,[n,r])=>e+(n[t-r]??0),0)))},wt=(e,t=yt/10)=>{let n=e.length-t;return Float32Array.from({length:n},(r,i)=>i<t?e[i]*Math.sqrt(i/t)+e[n+i]*Math.sqrt(1-i/t):e[i])},Tt=yt/2,Et=Tt*60/84,Dt=16,Ot=[[5,12,16,19],[2,9,12,17],[-2,5,9,14],[0,7,14,16]],kt=[`0...2..3..1.2...`,`4..6.5..7..6.5..`],At=[3,3e4,0,.001,0,.04,0,.7,0,1,.3],jt=[2,85,-2,.008,0,.2,0,1,0,1,.22],Mt=(e,t,n,r=1,i=1,a=(t.length-1)/r,o=1,s=1)=>{let c=t.length-1,[l,u]=[1/o,1/s];for(let o=0,s=0,d=n%e.length|0;o<a;o++){let n=s|0;e[d]+=i*(t[n]+(t[n+1]-t[n])*(s-n))*Math.min(1,o*l,(a-o)*u)**2,++d==e.length&&(d=0),(s+=r)>=c&&(s-=c)}},Nt=(e,t)=>{let n=0;for(let r=0;r<t.length;r++)e[r]+=t[r],e[r+t.length]+=t[r],n=Math.max(n,Math.abs(e[r]),Math.abs(e[r+t.length]));for(let t=0;t<e.length;t++)e[t]*=.35/n;return e},Pt=()=>{let e=Et*4*Dt,t=/* @__PURE__ */ new Float32Array(44101);for(let e=0;e<=2*Tt;e++){let n=Math.PI*e/Tt;t[e]=Math.sin(220*n)+Math.sin(221*n)+.4*Math.sin(441*n)+.15*Math.sin(659*n)}let n=new Float32Array(e/2);Ot.forEach((e,r)=>e.forEach(e=>Mt(n,t,r*8*Et,2**(e/12),.06,9.5*Et,2*Et,1.5*Et)));let r=new Float32Array(e),i=bt([2,220,0,.004,0,1,.002,1,0,1,.36],1,Tt);bt([2,607,0,.002,0,.25,0,1,0,1,.1],1,Tt).forEach((e,t)=>i[t]+=e);let a=bt(At,1,Tt),o=bt(jt,1,Tt);for(let e=0;e<128;e++){let t=e*Et/2,n=+kt[e>>6][e&15];for(let a=0;n>=0&&a<3;a++)Mt(r,i,t+a*.75*Et,2**((Ot[e>>4&3][n&3]+12*(n>>2))/12),.35**a);e&1&&Mt(r,a,t),(!(e&7)||(e&7)==4&&e>=64)&&Mt(r,o,t)}return Nt(r,n)},Ft=40,It=24,Lt=.5,Rt=`tiny-fps:muted`,zt=()=>{let e=!1;return{unlock:()=>{},listen:()=>{},play:()=>{},loop:()=>({set:()=>{}}),mute:t=>{e=t},get muted(){return e},destroy:()=>{}}},Bt=(e=xt)=>{let t;try{t=new AudioContext}catch{return zt()}let n=(e,n=1)=>{let r=t.createGain();return r.gain.value=n,r.connect(e),r},r=n(t.destination),i=n(r,Lt),a=[],o=!1,s=/* @__PURE__ */ new Set,c=[0,0,0],l=0,u=!1,d=(e,n=yt)=>{let r=t.createBuffer(1,e.length,n);return r.getChannelData(0).set(e),r},f=e=>{let n=t.createBufferSource();return n.buffer=e,n};return{unlock(){if(t.resume().catch(()=>{}),!o){o=!0,e.forEach((t,n)=>{let r=Ct(n,e);a[n]=d(St.includes(n)?wt(r):r)});let t=f(d(Pt(),Tt));t.loop=!0,t.connect(i),t.start()}},listen(e,t){[c,l]=[e,t]},play(e,i,o=1,u=1){let d=0,p=o;if(i){let[e,t,n]=i.map((e,t)=>e-c[t]),r=Math.hypot(e,t,n);p=Math.max(0,1-r/Ft)**2*o,d=(e*Math.cos(l)-n*Math.sin(l))/Math.max(r,1)}let m=a[e];if(!m||!p)return;if(s.size>=It){let e=[...s].reduce((e,t)=>t.vol<e.vol?t:e);if(e.vol>=p)return;e.src.stop(),s.delete(e)}let h=f(m);h.playbackRate.value=u;let g=t.createStereoPanner();g.pan.value=d,h.connect(g).connect(n(r,p));let _={vol:p,src:h};s.add(_),h.onended=()=>s.delete(_),h.start()},loop(e){let i,o;return{set(s,c){!i&&a[e]&&(i=f(a[e]),i.loop=!0,i.connect(o=n(r,0)),i.start()),i&&(o.gain.setTargetAtTime(s,t.currentTime,.08),i.playbackRate.setTargetAtTime(c,t.currentTime,.08))}}},mute(e){u=e,r.gain.setTargetAtTime(+!e,t.currentTime,.05)},get muted(){return u},destroy:()=>void t.close().catch(()=>{})}},Vt=()=>{try{return localStorage.getItem(Rt)==`1`}catch{return!1}},Ht=e=>{e.mute(!e.muted);try{localStorage.setItem(Rt,e.muted?`1`:`0`)}catch{}return e.muted},Ut=(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+Ee(e),z:e.z,dx:-n*a,dy:i,dz:-r*a,left:80,burst:!1}},Wt=.12,Gt=1.2,Kt=e=>[e.x,e.y,e.z],qt=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],Jt=e=>{let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set;return{fire(r,i){let a=Ut(r),[o,s]=[Kt(a),[a.dx,a.dy,a.dz]],c=le(e,o,s,80,f),l=r.id<<8|r.shots;n.delete(l),t.set(l,{own:!0,by:r.id,t0:i,o,t:i,d:s,end:o.map((e,t)=>e+s[t]*c),pop:c<80,due:1/0})},snapshot(e,r,i){let a=/* @__PURE__ */ new Set;for(let o of e){let e=o.by<<8|o.id,s=t.get(e);a.add(e),o.by==r&&(s?.own||n.has(e))?o.burst&&(n.delete(e),s&&([s.end,s.pop]=[Kt(o),!0])):(s||t.set(e,s={own:!1,by:o.by,t0:i,o:Kt(o),t:i,d:[0,0,0],pop:!1,due:1/0}),o.burst?[s.end,s.pop,s.due]=[Kt(o),!0,i]:[s.o,s.t,s.d]=[Kt(o),i,[o.dx,o.dy,o.dz]])}for(let[e,n]of t)!n.own&&!a.has(e)&&n.due==1/0&&(n.due=i)},frame(e,r){let i=[],a=[];for(let[o,s]of t){let c=s.own?e:e-100,l=(c-s.t)*40/1e3;if(s.end&&l>=qt(s.end.map((e,t)=>e-s.o[t]),s.d)||c>=s.due){s.pop&&a.push(s.end),s.own&&n.add(o),t.delete(o);continue}if(c<s.t0)continue;let u=s.o.map((e,t)=>e+s.d[t]*l);s.born??=e,s.from??=r(s.by)??u;let d=Math.min(1,(e-s.born)/1e3/Wt),f=s.from,p=u.map((e,t)=>f[t]+(e-f[t])*d*(2-d));i.push({p,d:s.d,tail:Math.min(Gt,Math.hypot(...p.map((e,t)=>e-f[t])))})}return{orbs:i,bursts:a}}}},U=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],Yt=(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]],Xt=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],Zt=(e,t,n)=>[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n],W=e=>{let t=Math.hypot(...e)||1;return[e[0]/t,e[1]/t,e[2]/t]},Qt=(e,t,n=0)=>{let[r,i,a,o,s,c]=[e,t,n].flatMap(e=>[Math.sin(e),Math.cos(e)]),l=[i,0,-r],u=[r*a,o,i*a];return[l.map((e,t)=>e*c-u[t]*s),u.map((e,t)=>e*c+l[t]*s),[-r*o,a,-i*o]]},$t=(e,t,n=[0,0,0])=>{let r=[],i=e.filter((t,n)=>!n||Math.hypot(t[0]-e[n-1][0],t[1]-e[n-1][1])>1e-9),a=i.slice(1).map(([e,t],n)=>{let[r,a]=i[n],o=Math.hypot(e-r,t-a);return[(t-a)/o,-(e-r)/o]}),o=i.map(([e],t)=>{let[n,r]=[0,1].map(e=>(a[t-1]?.[e]??0)+(a[t]?.[e]??0)),i=Math.hypot(n,r);return e?[n/i,r/i]:[0,Math.sign(r)]}),s=(e,a)=>{let[s,c]=i[a],[l,u]=[Math.cos(e*V/t),Math.sin(e*V/t)];r.push(n[0]+s*l,n[1]+s*u,n[2]-c,o[a][0]*l,o[a][0]*u,-o[a][1])};for(let e=1;e<i.length;e++)for(let n=0;n<t;n++)[...i[e-1][0]?[[n,e-1],[n+1,e-1],[n+1,e]]:[],...i[e][0]?[[n,e-1],[n+1,e],[n,e]]:[]].forEach(([e,t])=>s(e,t));return r},en=(e,t,n,[r,i],a)=>{let o=(e,t,n,r)=>Array.from({length:t},(i,a)=>{let o=a*V/t/4;return[e*Math.sin(o),n-r*e*Math.cos(o)]});return $t([...r?o(t[0],r,0,1):[[0,0]],...t.map((n,r)=>[n,e*r/(t.length-1)]),...i?o(t[t.length-1],i,e,-1).reverse():[[0,e]]],n,a)},tn=(e,[t,n,r])=>Array.from({length:e.length*(10/6)},(i,a)=>{let[o,s]=[Math.floor(a/10),a%10];return s<6?e[o*6+s]:[t,n,-1,r][s-6]}),nn=[[5,1],[7,2],[10,3]],rn=/* @__PURE__ */ new Map,an=(e,t,n,r=[1,1])=>{let[i,a]=nn[e];!e&&n.length>3&&(n=[n[0],n[n.length>>1],n[n.length-1]]);let o=`${e} ${t} ${n} ${r}`,s=rn.get(o);return s||(s=tn(en(t,n,i,r.map(e=>Math.ceil(a*e))),[1,1,1]),rn.set(o,s)),s},on=(e,t,n,[r,i,a],o,s,c=[1,1,1])=>{let[l,u,d]=typeof s==`number`?[s,s,s]:s,f=l==u&&u==d,[p,m,h,g,_,v,y,b,x]=[...r,...i,...a],S=n[0]+p*o[0]+g*o[1]+y*o[2],C=n[1]+m*o[0]+_*o[1]+b*o[2],w=n[2]+h*o[0]+v*o[1]+x*o[2];for(let n=0;n<t.length;n+=10){let[r,i,a]=[t[n]*l,t[n+1]*u,t[n+2]*d],[o,s,T]=[t[n+3],t[n+4],t[n+5]];if(!f){[o,s,T]=[o/l,s/u,T/d];let e=Math.sqrt(o*o+s*s+T*T)||1;[o,s,T]=[o/e,s/e,T/e]}e.push(S+p*r+g*i-y*a,C+m*r+_*i-b*a,w+h*r+v*i-x*a,p*o+g*s-y*T,m*o+_*s-b*T,h*o+v*s-x*T,t[n+6]*c[0],t[n+7]*c[1],t[n+8],t[n+9]*c[2])}},sn=(e,t)=>{let n=e[0]*t[0]+e[1]*t[1]+e[2]*t[2],r=t.map((t,r)=>t-e[r]*n),i=Math.hypot(...r)||1,[a,o,s]=r.map(e=>e/i);return[[a,o,s],[o*e[2]-s*e[1],s*e[0]-a*e[2],a*e[1]-o*e[0]],e]},cn=(e,t,n,r,i,a,o=1,s)=>{let c=[r[0]-n[0],r[1]-n[1],r[2]-n[2]],l=Math.hypot(...c)||1,[u,d]=typeof o==`number`?[o,o]:o;on(e,t,n,sn([c[0]/l,c[1]/l,c[2]/l],i),[0,0,0],[u,d,l/a],s)},ln=2.4,un=[1,.62],dn=8,fn=28,pn=2.2,mn=.04,hn=.045,gn=e=>{let t=parseInt(u[e].slice(1),16);return[t>>16,t>>8&255,t&255].map(e=>e/255)},_n=(e,t,n)=>e.flatMap((e,r)=>{if(e.state===_.DROPPED)return[{team:r,at:[e.x,e.y,e.z],dropped:!0}];if(e.state===_.CARRIED){let t=n(e.by);return t?[{team:r,at:[t.x,t.y,t.z],by:{yaw:t.yaw,vx:t.vx,vz:t.vz}}]:[]}return[{team:r,at:t[r]}]}),vn=[[1,0,0],[0,1,0],[0,0,1]],yn=(e,t,n)=>{for(let r=t;r<e.length;r+=10)e[r+6]*=n,e[r+7]*=n,e[r+9]*=n,e[r+8]=-2},bn=(e,t,n,r,[i,a,o])=>{let[s,c,l]=[n[0]-t[0],n[1]-t[1],n[2]-t[2]],[u,d,f]=[r[0]-t[0],r[1]-t[1],r[2]-t[2]],p=[c*f-l*d,l*u-s*f,s*d-c*u],m=Math.hypot(...p)||1;for(let s of[t,n,r])e.push(...s,p[0]/m,p[1]/m,p[2]/m,i,a,-1,o)},xn=(e,t,n,r,i)=>{for(let a=0;a<fn;a++){let[o,s]=[a,a+1].map(e=>e*2*Math.PI/fn),c=(e,n)=>[t[0]+e*Math.cos(n),t[1],t[2]+e*Math.sin(n)];bn(e,c(n,o),c(r,s),c(r,o),i),bn(e,c(n,o),c(n,s),c(r,s),i)}},Sn=(e,t,n,r)=>{for(let i=0;i<fn;i++){let[a,o]=[i,i+1].map(e=>e*2*Math.PI/fn);bn(e,t,[t[0]+n*Math.cos(o),t[1],t[2]+n*Math.sin(o)],[t[0]+n*Math.cos(a),t[1],t[2]+n*Math.sin(a)],r)}},Cn=(e,t,n,r)=>{Sn(e,[t[0],t[1]+mn,t[2]],d,n.map(e=>e*.4));let i=e.length;xn(e,[t[0],t[1]+hn,t[2]],d-.16,d,n),yn(e,i,pn*(.75+.25*Math.sin(r*3)))},wn=(e,t,n,[r,i],a,o,s)=>{let c=[-n[2],0,n[0]],l=(e,s)=>{let l=a*e*Math.sin(o*7-e*5),u=i*s*(1-e);return[t[0]+n[0]*r*e+c[0]*l,t[1]-u+.12*r*e*Math.sin(o*5-e*4)*a,t[2]+n[2]*r*e+c[2]*l]};for(let t=0;t<dn;t++){let[n,r]=[t/dn,(t+1)/dn],[i,a,o,c]=[l(n,0),l(r,0),l(r,1),l(n,1)],u=[(a[1]-i[1])*(c[2]-i[2])-(a[2]-i[2])*(c[1]-i[1]),(a[2]-i[2])*(c[0]-i[0])-(a[0]-i[0])*(c[2]-i[2]),(a[0]-i[0])*(c[1]-i[1])-(a[1]-i[1])*(c[0]-i[0])],d=Math.hypot(...u)||1,f=(e,t)=>[e[0]+u[0]/d*.004*t,e[1]+u[1]/d*.004*t,e[2]+u[2]/d*.004*t];for(let t of[1,-1]){let n=[i,a,o,c].map(e=>f(e,t)),[r,l,u,d]=t>0?n:[n[0],n[3],n[2],n[1]];bn(e,r,l,u,s),bn(e,r,u,d,s)}}},Tn=(e,t,n,r)=>{cn(e,an(1,1,[1,1],[0,0]),t,n,[.6,0,.8],1,.045,[.82,.84,.9]);let i=e.length;on(e,an(1,0,[1,1]),n,vn,[0,0,0],.09,r),yn(e,i,pn)},En=(e,t,n,r)=>{let[i,a,o]=t.at,s=r+t.team*1.7;if(t.by){let{yaw:r,vx:c,vz:l}=t.by,u=-Math.sin(r),d=-Math.cos(r),f=Math.hypot(c,l),p=[i-u*.28,a+.55,o-d*.28],m=[i-u*.38,a+.55+ln-.2,o-d*.38],[h,g]=f>1?[-c/f,-l/f]:[-u,-d];Tn(e,p,m,n);let _=Math.min(1,f/8);wn(e,m,[h,0,g],[un[0]*(.7+.5*_),un[1]],.1+.16*_,s,n);return}if(t.dropped){let t=i*12.9898+o*78.233,[c,l]=[Math.cos(t),Math.sin(t)],u=[i+c*2.3,a+.6,o+l*2.3];Tn(e,[i,a+.06,o],u,n),wn(e,u,[c,0,l],[un[0]*.8,un[1]*.8],.04,s,n);let f=e.length;xn(e,[i,a+hn,o],d-.1,d,n),yn(e,f,pn*(.5+.5*Math.abs(Math.sin(r*5))));return}let c=[i,a+ln,o];Tn(e,[i,a,o],c,n);let l=.6+t.team*Math.PI;wn(e,c,[Math.cos(l),0,Math.sin(l)],un,.18,s,n)},Dn={SPOT:0,POINT:1},On=9,kn=6,An=e=>{let{ctf:t,t:n}=e;if(!t)return[];let r=([e,t,n],r,i,a)=>({kind:Dn.POINT,p:[e,t,n],d:[0,-1,0],cone:0,range:i,color:gn(r).map(e=>e*a),shadow:!1});return[...t.bases.map(([e,t,i],a)=>r([e,t+1.2,i],a,On,1.1+.3*Math.sin(n*3))),...t.flags.filter(e=>e.dropped).map(e=>r([e.at[0],e.at[1]+.8,e.at[2]],e.team,kn,.9))]},jn=.06,Mn=.16,Nn=.22,Pn=12,Fn=.05,In=10,Ln=4,Rn=[[.022,[.4,.15,1.3],0],[.007,[.7,1.7,2.2],.02]],zn=[[.22,[.2,.45,1.6],0],[.08,[2,2.6,3.6],.04]],Bn=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],Vn=(e,t)=>[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]],Hn=e=>{let t=Math.hypot(...e)||1;return[e[0]/t,e[1]/t,e[2]/t]},Un=(e,t,[n,r,i])=>e.push(...t,0,1,0,n,r,-2,i),Wn=(e,t,n)=>Math.min(Math.max(Math.hypot(...Bn(e,t))/5,n),2.5),Gn=(e,t,n,r,i,a,o,s=r,c=1)=>{let l=Bn(n,t),u=Vn(l,Bn(t,a));Math.hypot(...u)<1e-6*Math.hypot(...l)&&(u=Vn(l,[0,1,0])),u=Hn(u);let[d,f,p,m]=[[t,r],[t,-r],[n,-s],[n,s]].map(([e,t])=>{let n=Hn(Bn(a,e)),r=t*Wn(a,e,c);return e.map((e,t)=>e+u[t]*r+n[t]*o)});for(let t of[d,f,p,d,p,m])Un(e,t,i)},Kn=(e,t,n,r,i,a=0,o=8)=>{let s=Bn(t,i),c=Hn(Vn(s,[0,1,0])),l=Hn(Vn(c,s)),u=n*Wn(i,t,.1),d=Hn(s).map((e,n)=>t[n]-e*a),f=e=>{let[t,n]=[Math.cos(e*2*Math.PI/o)*u,Math.sin(e*2*Math.PI/o)*u];return[0,1,2].map(e=>d[e]+c[e]*t+l[e]*n)};for(let t=0;t<o;t++)for(let n of[d,f(t),f(t+1)])Un(e,n,r)},qn=()=>{let e=[],t=[],n=[],r=[],i=[0,0,0],a=7,o=()=>(a=a*16807%2147483647)/2147483647*2-1,s=(e,t)=>{let r=[o(),o(),o()].map(e=>e*t),i=[0,1,2].map(t=>e[t]+r[t]),a=[0,1,2].map(n=>e[n]+r[n]/2+o()*t*.3);n=[...n,{a:e,m:a,b:i,age:0}].slice(-24)},c=(e,n,r)=>{for(let i=0;i<n;i++)t.push({p:e,v:[o()*r,o()*r+1.5,o()*r],age:0});t=t.slice(-192)};return{flash(t,n){e=[...e,{p:t,age:0,own:n}].slice(-16)},burst(t){e=[...e,{p:t,age:0,splash:!0}].slice(-16),c(t,Pn,4)},orbs(e){r=e},shock(e){c(e,In,4);for(let t=0;t<In;t+=2)s(e,.6)},crackle(e){for(let t=0;t<2;t++)o()>0&&s([e[0]+o()*.4,e[1]+o()*.7,e[2]+o()*.4],.35)},spit(e){t.push({p:e,v:[o(),o()+2,o()],age:0})},mount(t){e.forEach(e=>e.own&&(e.p=t))},update(r){for(let i of[...e,...t,...n])i.age+=r;e=e.filter(e=>e.age<(e.splash?Mn:jn)),t=t.filter(e=>e.age<Nn),n=n.filter(e=>e.age<Fn);for(let e of t)e.v[1]-=9*r,e.p=e.p.map((t,n)=>t+e.v[n]*r)},draw(a,o){i=o;for(let{p:e,d:t,tail:n}of r){let r=e.map((e,r)=>e-t[r]*n);zn.forEach(([t,i,s])=>{Kn(a,e,t,i,o,s),n>.01&&Gn(a,e,r,t*.5,i,o,s,0,.1)})}for(let{p:t,age:n,splash:r}of e){let e=1-n/(r?Mn:jn);zn.forEach(([n,i,s])=>Kn(a,t,r?n*(3-2*e):n*.7*e,i.map(t=>t*(.4+.6*e)),o,s))}for(let{a:e,m:t,b:r,age:i}of n){let n=1-i/Fn;for(let[i,s]of[[e,t],[t,r]])Rn.forEach(([e,t,r])=>Gn(a,i,s,e*.5*n,t,o,r))}for(let{p:e,age:n}of t){let t=1-n/Nn;Kn(a,e,.022*t,[1.4*t+.4,2.2*t+.3,3],o,0,4)}},lights(){let t=(e,t,n,r)=>({kind:Dn.POINT,p:e,d:[0,-1,0],cone:0,range:t,color:r.map(e=>e*n),shadow:!1}),a=e=>Math.hypot(...Bn(e.p,i));return[...n.slice(-2).map(e=>t(e.m,3,.8*(1-e.age/Fn),[.3,.7,1.3])),...e.slice(-4).map(e=>e.splash?t(e.p,7,2*(1-e.age/Mn),[.35,.7,1.6]):t(e.p,6,1.3*(1-e.age/jn),[.25,.55,1.6])),...[...r].sort((e,t)=>a(e)-a(t)).slice(0,Ln).map(e=>t(e.p,4,1,[.25,.5,1.4]))]}}},Jn=(e,t)=>{if(!e)return[];if(e.over||t.over)return e.over&&!t.over?[{kind:`start`}]:[];let n=[];for(let r of[0,1])t.score[r]>e.score[r]&&n.push({kind:`capture`,team:r});let r=n.length>0;t.flags.forEach((t,i)=>{let a=e.flags[i];t.state===_.CARRIED&&(a.state!==_.CARRIED||a.by!==t.by)?n.push({kind:`take`,flag:i,by:t.by}):t.state===_.DROPPED&&a.state===_.CARRIED?n.push({kind:`drop`,flag:i}):t.state===_.HOME&&(a.state===_.DROPPED||a.state===_.CARRIED&&!r)&&n.push({kind:`return`,flag:i})});for(let r of t.players)r.stun>(e.players.find(e=>e.id===r.id)?.stun??1/0)&&n.push({kind:r.zap?`shock`:`tackle`,who:r.id,by:r.by,at:[r.x,r.y+1,r.z]});return n},Yn=(e,t,n)=>{let r=e=>l[e].toLowerCase();switch(e.kind){case`take`:{let i=1-e.flag;return{team:i,text:e.flag===t.team?`${l[i]} took your flag`:e.by===t.id?`You took the ${r(e.flag)} flag`:`${n(e.by)} took the ${r(e.flag)} flag`}}case`drop`:return{team:e.flag,text:e.flag===t.team?`Your flag was dropped`:`${l[e.flag]} flag dropped`};case`return`:return{team:e.flag,text:e.flag===t.team?`Your flag returned`:`${l[e.flag]} flag returned`};case`capture`:return{team:e.team,text:`${l[e.team]} scored`};case`tackle`:return e.by===t.id?{team:t.team,text:`Tackled ${n(e.who)}!`}:void 0;case`shock`:return;default:return{text:`New match`}}},Xn=(e,t)=>{let{team:n}=t;switch(e.kind){case`take`:return[{id:H.TAKE,rate:e.flag===n?.8:1}];case`drop`:return[{id:H.DROP,rate:e.flag===n?1:.85}];case`return`:return[{id:H.RETURN,rate:e.flag===n?1:.85}];case`capture`:return[{id:H.CAPTURE,rate:e.team===n?1:.8}];case`tackle`:return e.who===t.id?[{id:H.TACKLE},{id:H.GRUNT}]:e.by===t.id?[{id:H.TACKLE,gain:.8,rate:1.1}]:[{id:H.TACKLE,at:e.at}];case`shock`:return e.who===t.id?[{id:H.ZAP}]:e.by===t.id?[]:[{id:H.ZAP,at:e.at}];default:return[]}},G={PELVIS:0,SPINE:1,CHEST:2,NECK:3,HEAD:4,CLAVICLE_L:5,ARM_L:6,FOREARM_L:7,HAND_L:8,CLAVICLE_R:9,ARM_R:10,FOREARM_R:11,HAND_R:12,THIGH_L:13,SHIN_L:14,FOOT_L:15,TOE_L:16,THIGH_R:17,SHIN_R:18,FOOT_R:19,TOE_R:20},Zn=Object.keys(G).length,Qn=[-1,0,1,2,3,2,5,6,7,2,9,10,11,0,13,14,15,0,17,18,19],$n=[[0,.98,0],[0,.12,0],[0,.2,0],[0,.22,0],[0,.1,0],[-.04,.17,0],[-.15,0,0],[-.03,-.29,0],[0,-.26,0],[.04,.17,0],[.15,0,0],[.03,-.29,0],[0,-.26,0],[-.1,-.05,0],[0,-.44,0],[0,-.43,0],[0,-.04,-.13],[.1,-.05,0],[0,-.44,0],[0,-.43,0],[0,-.04,-.13]],er=[0,0,0,1],tr=(e=[0,0,0],t=0)=>({at:e,yaw:t,hips:[0,0,0],rot:Array.from({length:Zn},()=>[...er])}),K=([e,t,n,r],[i,a,o,s])=>[r*i+e*s+t*o-n*a,r*a-e*o+t*s+n*i,r*o+e*a-t*i+n*s,r*s-e*i-t*a-n*o],q=([e,t,n],r)=>{let i=Math.sin(r/2);return[e*i,t*i,n*i,Math.cos(r/2)]},J=(e,[t,n,r])=>{let[i,a,o,s]=e,[c,l,u]=[2*(a*r-o*n),2*(o*t-i*r),2*(i*n-a*t)];return[t+s*c+a*u-o*l,n+s*l+o*c-i*u,r+s*u+i*l-a*c]},nr=(e,t,n)=>{let r=e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3],i=r<0?-1:1;if(r*=i,r>.9995){let r=e.map((e,r)=>e+(i*t[r]-e)*n),a=Math.hypot(...r);return r.map(e=>e/a)}let a=Math.acos(r),[o,s]=[Math.sin((1-n)*a),Math.sin(n*a)*i],c=1/Math.sin(a);return e.map((e,n)=>(e*o+t[n]*s)*c)},rr=e=>{let t=[],n=[],r=q([0,1,0],e.yaw);for(let i=0;i<Zn;i++){let a=Qn[i],o=a<0?r:n[a];n[i]=K(o,e.rot[i]);let s=J(o,i===0?$n[0].map((t,n)=>t+e.hips[n]):$n[i]),c=a<0?e.at:t[a];t[i]=[c[0]+s[0],c[1]+s[1],c[2]+s[2]]}return{pos:t,rot:n}},ir=(e,t,n,r,i)=>{let a=e[t]-n,o=e[t+1]+r*a,s=Math.exp(-r*i);return e[t]=n+(a+o*i)*s,e[t+1]=(e[t+1]-r*o*i)*s,e[t]},ar=Math.PI*2,[Y,or,sr]=[[1,0,0],[0,1,0],[0,0,1]],[cr,lr,ur]=[.44,.43,.06],[dr,fr]=[.2915,.26],pr=cr+lr,X=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),mr=e=>(e=X(e))*e*(3-2*e),hr=(e,t)=>Math.atan2(Math.sin(t-e),Math.cos(t-e)),gr=e=>[-e[0],-e[1],-e[2],e[3]],_r=(e,t)=>{let n=Math.sin(e*78.233+t*37.719)*43758.5453;return n-Math.floor(n)},vr=(e,t)=>[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]],yr=(e,t,n,r=0)=>e.map((e,i)=>e*t+n[i]*r),br=e=>yr(e,1/(Math.hypot(...e)||1),e),xr=(e,t)=>yr(e,1,t,-(e[0]*t[0]+e[1]*t[1]+e[2]*t[2])),Sr=(e,t,n)=>{let r=Math.max(n-Math.abs(e-t),0)/n;return Math.min(e,t)-r*r*n/4},Cr=(e,t)=>{let n=[-t[0],-t[1],-t[2]],r=vr(e,n),i=[e[0]+n[1]+r[2],e[0]-n[1]-r[2],n[1]-e[0]-r[2],r[2]-e[0]-n[1]],a=i.indexOf(Math.max(...i)),[o,s,c,l]=[1+i[a],n[2]-r[1],r[0]-e[2],e[1]-n[0]],[u,d,f]=[n[0]+e[1],r[0]+e[2],r[1]+n[2]],p=[[s,c,l,o],[o,u,d,s],[u,o,f,c],[d,f,o,l]][a],m=Math.hypot(...p);return p.map(e=>e/m)},wr=(e,t,n,r=cr,i=lr,a=1)=>{let o=yr(t,1,e,-1),s=Math.hypot(...o)||1e-6,c=X(s,.2,(r+i)*.999),l=yr(o,1/s,o),u=br(xr(n,l)),d=X((r*r+c*c-i*i)/(2*r*c),-1,1),f=yr(l,d,u,Math.sqrt(1-d*d)),p=br(yr(l,c,f,-r)),m=yr(vr(l,u),a,l);return[Cr(m,f),Cr(m,p)]},Tr=e=>{let[t,n]=[Math.abs(e),e>0?.07:.13],[r,i]=[Math.sin(t),Math.cos(t)];return[(e>0?-1:1)*(n*(1-i)+ur*r),ur*(i-1)+n*r]},Er=[1.4,5,9],Dr={f:[.95,1.4,1.8],s:[.88,.95,1],k:[.45,.42,.4],lat:[.11,.09,.07],lift:[.09,.3,.4],d0:[.002,.01,.01],d1:[.008,.075,.05],td:[.12,.1,-.12],to:[-.45,-.6,-.8],pr:[.07,.1,.14],po:[.06,.06,.05],pt:[.04,.1,.16],pa:[.02,.05,.06],cc:[.1,.16,.22],aa:[.35,.8,1],am:[-.05,.12,.25],em:[.3,1.4,1.75],ea:[.12,.25,.3],ab:[.1,.12,.1],sw:[.025,.012,.008],hop:[0,.02,.025]},Z={AIR:0,RISE:1,DASH:2,WALL_L:3,WALL_R:4,HANG:5,CLIMB:6,SLIDE:7,STUN:8,TUCK:9,DOWN:10},Or=[[-.05,.12,0,.35,.5,.15,.7,.25,.5,.25,.5,1.15,0,0],[0,.1,0,1.2,1.5,-.35,.3,2.4,.3,2.2,.3,.35,0,0],[-.35,1.25,0,1.1,1.3,-.6,.25,-1,.3,-1,.3,.25,0,0],[],[-.02,.2,.4,.9,1.2,.6,1.3,.8,1,.3,.5,.6,0,.1],[.07,.05,0,.2,.3,.1,.2,3,.2,3,.2,.2,-.22,0],[0,.5,0,.2,.4,1.4,1.7,1,1.4,1,1.4,.15,-.1,0],[-.78,-1.1,0,1.1,1.8,1.4,.1,.5,.8,.4,.5,.8,0,0],[0,0,0,0,0,0,0,.8,1.6,.8,1.6,.2,0,0],[-.05,.9,0,1.7,2,1.7,2,.8,1.6,.8,1.6,.2,0,0],[-.5,.35,0,1.3,.3,1.1,.2,.4,.4,.2,.3,.6,0,0]],kr=Or[Z.WALL_R];Or[Z.WALL_L]=[kr[0],kr[1],-kr[2],kr[5],kr[6],kr[3],kr[4],kr[9],kr[10],kr[7],kr[8],kr[11],kr[12],-kr[13]];var Ar=[G.PELVIS,G.SPINE,G.CHEST,G.ARM_L,G.FOREARM_L,G.ARM_R,G.FOREARM_R,G.THIGH_L,G.SHIN_L,G.FOOT_L,G.TOE_L,G.THIGH_R,G.SHIN_R,G.FOOT_R,G.TOE_R],jr=e=>{let t=[],[n,r,i]=[e[1],e[2],e[11]];return t[G.PELVIS]=K(q(sr,r*.4),q(Y,-.3*n)),t[G.SPINE]=K(q(sr,r*.3),q(Y,-.35*n)),t[G.CHEST]=t[G.SPINE],t[G.ARM_L]=K(q(sr,-i),q(Y,e[7])),t[G.FOREARM_L]=q(Y,e[8]),t[G.ARM_R]=K(q(sr,i),q(Y,e[9])),t[G.FOREARM_R]=q(Y,e[10]),[G.THIGH_L,G.THIGH_R].forEach((r,i)=>{t[r]=q(Y,e[3+2*i]+.3*n),t[r+1]=q(Y,-e[4+2*i]),t[r+2]=q(Y,-.35),t[r+3]=Mr}),t},Mr=[0,0,0,1],Nr=[[0,0],[1,0],[-1,0],[0,1],[0,-1]],[Pr,Fr,Ir,Lr,Rr,zr,Br,Vr,Hr,Ur,Wr,Gr]=[0,2,4,6,8,10,12,14,16,18,20,22],Kr=5,qr=.1,Jr=()=>{let e=tr(),t={},n=Array(Gr+2*Or.length).fill(0),r=[0,1].map(()=>({x:0,y:0,z:0,px:0,pz:0,gy:0,lx:0,ly:0,lz:0,dl:0,tg:0,u:0,x0:0,w:0,th:0,tw:1,on:!0})),i={},a=!1,[o,s,c,l,u,d,f]=[0,0,0,0,0,0,0],[p,m,h,g,_]=[0,0,0,.6,0],[v,y,b,S]=[!1,!0,!0,-1],C=[1,1,1,0,.06,0],[w,T,E]=[0,0,[0,0,0]],[D,O,k,A]=[1,[1,0],[0,0,0,-1,0],!1],j=(e,j,ee)=>{j=X(j,0,.1),y=!a||Math.hypot(e.x-i.x,e.y-i.y,e.z-i.z)>Kr;let M=e.mode==x.GROUND||e.mode==x.CROUCH,te=e.mode==x.AIR,N=(e,t,r)=>{y?[n[e],n[e+1]]=[t,0]:ir(n,e,t,r,j)};N(zr,e.vx,12),N(Br,e.vz,12);let[P,F]=[n[zr],n[Br]];l=Math.sqrt(P*P+F*F);let I=l>1?Math.atan2(-P,-F):e.yaw;if(y){let t=e.id;C=[1+.08*(_r(t,0)-.5),1+.16*(_r(t,1)-.5),1+.16*(_r(t,2)-.5),.03*(_r(t,3)-.5),.05+.04*_r(t,4),_r(t,6)],o=l>.25?_r(t,5):_r(t,5)<.5?.05:.55,[s,c,h,p,m,v,S]=[0,0,0,0,0,!1,-1],f=I,d=e.yaw}else te&&i.mode==x.AIR&&e.jumps<i.jumps&&e.vy>i.vy&&(h=.001),te?m=Math.min(m,e.vy):(i.mode==x.AIR&&(M||e.mode==x.SLIDE)&&m<-3&&(p=X(-m/12,.3)),m=0),h&&=(h+=j*(te?2.2:8),h>=1?0:h);c+=j,p*=Math.exp(-j*7);let L=Nr[e.wall],R=e.mode==x.WALLRUN,ne=e.mode==x.HANG||e.mode==x.CLIMB;R&&([D,O]=[L[0]*Math.cos(I)-L[1]*Math.sin(I)<0?-1:1,L]),ne&&e.wall&&(d=Math.atan2(-L[0],-L[1]),e.mode!=x.HANG&&A||(k=[e.x,e.z,L[0],L[1],0]),k[4]=e.edge),A=ne,[te,te&&e.vy>.5,e.dash>50,R&&D<0,R&&D>0,e.mode==x.HANG,e.mode==x.CLIMB,e.mode==x.SLIDE,e.stun>0,h&&Math.sqrt(Math.sin(Math.PI*h))].forEach((e,t)=>N(Gr+2*t,+e,12)),N(Gr+2*Z.DOWN,+(e.down>0),5),N(Rr,+(e.mode==x.CROUCH),12),N(Hr,ne?X((1.7-k[4]+e.y)/1.2):0,14),N(Lr,p,26);let re=y||l<2?0:hr(f,I)/Math.max(j,.001);f=I;let ie=y?0:-((e.vx-i.vx)*Math.sin(u)+(e.vz-i.vz)*Math.cos(u))/Math.max(j,.001),ae=-(P*Math.sin(u)+F*Math.cos(u)),oe=Math.sign(ae)*X((Math.abs(ae)-1.5)*.028,0,.22);N(Pr,(ae>0?oe:oe/2)+X(ie*.012,-.3,.3),7),N(Fr,X(.3*Math.atan(l*re/9.8),-.4,.4),8),N(Ir,.5*Math.sin(hr(e.yaw,I))*X(l/2),10);let se=e=>n[Gr+2*e],ce=X(se(Z.DASH)+se(Z.WALL_L)+se(Z.WALL_R)+se(Z.SLIDE)),z=e.yaw+hr(e.yaw,I)*ce;u=z+hr(z,d)*X(se(Z.HANG)+se(Z.CLIMB)),u+=n[Ir]*(1-ce);let[le,ue]=[Math.cos(u),Math.sin(u)];N(Ur,e.stun>0?X(-(e.vx*ue+e.vz*le)/4.2,-1,1):0,18),N(Wr,e.stun>0?X((e.vx*le-e.vz*ue)/4.2,-1,1):0,18),[w,T,E]=[e.yaw,e.pitch,[e.x,e.y,e.z]];let B=l<Er[1]?0:1,V=X((l-Er[B])/(Er[B+1]-Er[B]));for(let e in Dr){let n=Dr[e];t[e]=n[B]+(n[B+1]-n[B])*V}_=mr((l-.2)/1.2);let de=t.f*C[0]*(.35+.65*X(l/1.4))*(1+.5*se(Z.STUN));g=X(t.s*de/Math.max(l,.1),.2,.62);let[fe,pe]=[Math.cos(u),-Math.sin(u)],me=(t,n)=>{let r=ee?ee(t,n):e.y;return Math.abs(r-e.y)<.6?r:e.y},he=l<=.25,ge=M&&(!he||!r[0].on||!r[1].on);(ge||R)&&(o=(o+(he&&!R?.9:de)*j)%1),r.forEach((n,a)=>{let c=a?1:-1,l=(o+a/2)%1,[d,f]=[e.x+fe*c*qr,e.z+pe*c*qr],p=u-c*C[4],[m,h]=[-Math.sin(p),-Math.cos(p)];if(M){if(v||([n.px,n.pz,n.gy,n.on]=[d,f,me(d,f),!0],y&&([n.x,n.y,n.z,n.th,n.tw]=[d,n.gy+ur,f,0,1])),n.on&&ge&&(l>=g||Math.hypot(n.x-d,n.z-f)>.56))[n.on,n.lx,n.ly,n.lz,n.dl]=[!1,n.x-e.x,n.y,n.z-e.z,l];else if(!n.on&&l<n.u){let[e]=Tr(t.td*_);[n.on,n.px,n.pz,n.gy]=[!0,n.x-m*e,n.z-h*e,n.tg],s++}if(n.u=l,n.on){if(he&&r[0].on&&r[1].on){let e=1-Math.exp(-8*j);n.px+=(d-n.px)*e,n.pz+=(f-n.pz)*e,n.gy+=(me(d,f)-n.gy)*e}n.x0=X(l/g),n.th=_*(t.td*(1-mr(n.x0/.25))+t.to*mr((n.x0-.55)/.45));let[e,i]=Tr(n.th);[n.x,n.y,n.z]=[n.px+m*e,n.gy+ur+i,n.pz+h*e],n.w=1-_*(1-mr(Math.min(n.x0,1-n.x0)/.12)),n.tw=mr(n.x0*10)}else{let r=X((l-n.dl)/(1-n.dl+1e-6)),[i,a]=[t.k*g/de,(1-l)/de+t.k*g/de],[o,s]=[P*i+fe*c*t.lat,F*i+pe*c*t.lat];n.tg=me(e.x+P*a+fe*c*t.lat,e.z+F*a+pe*c*t.lat);let[u,d]=[t.td*_,t.to*_],f=mr((r-.12)/.78);n.x=e.x+n.lx+(o-n.lx)*f,n.z=e.z+n.lz+(s-n.lz)*f,n.y=n.ly+(n.tg+ur+Tr(u)[1]-n.ly)*mr(r*1.5)+t.lift*Math.sin(Math.PI*r**.6),n.th=d+(u-d)*mr(r)+.15*Math.sin(Math.PI*r),n.tw=1-mr(r*4),n.w=0}}else{let t=y?0:Math.exp(-10*j),r=y?[0,0,0]:[n.x-i.x,n.y-i.y,n.z-i.z];n.x=e.x+r[0]*t+(d-e.x)*(1-t),n.y=e.y+r[1]*t+ur*(1-t),n.z=e.z+r[2]*t+(f-e.z)*(1-t),[n.th,n.tw,n.w,n.on,n.u]=[n.th*t,n.tw*t,0,!1,l]}}),v=M,b=!0,Object.assign(i,e),a=!0},ee=()=>{let t=e=>n[Gr+2*e],{rot:r}=e,[i,a]=[Math.cos(u),Math.sin(u)],s=(e,t,n,r=E)=>[r[0]+e*i+n*a,t,r[2]+n*i-e*a],c=(e,t,n)=>s(e,t,n,[0,0,0]),l=[],{pos:d,rot:f}=rr(e),p=d[G.PELVIS],m=e=>e<0?G.HAND_L:G.HAND_R,h=e=>e<0?G.FOOT_L:G.FOOT_R,g=K(q(or,u),q(Y,-.2)),_=X(t(Z.HANG)+t(Z.CLIMB));if(_>.002){let[r,i,a,o,s]=k,u=.4+.14*n[Hr],f=[-1,1].map(e=>{let t=d[m(e)-2],n=Math.max(u,(t[0]-r)*a+(t[2]-i)*o),c=[r+a*n-o*e*.21,s+.03,i+o*n+a*e*.21],l=(t[0]-c[0])**2+(t[2]-c[2])**2;return[c,t[1]-c[1]-Math.sqrt(Math.max(((dr+fr)*.97)**2-l,0))]}),g=_**4*X(Math.max(...f.map(e=>e[1])));e.at[1]-=g,d.forEach(e=>e[1]-=g),[-1,1].forEach((e,t)=>l.push([m(e),_,f[t][0],c(e*.8,0,.6),Cr([0,e,0],[a,0,o])]));let v=(p[0]-r)*a+(p[2]-i)*o,y=Math.max(.58,v+.45);[-1,1].forEach(e=>l.push([h(e),t(Z.CLIMB)*X(e<0?(v-.25)*4:n[Hr]*2-.4),[r+a*y-o*e*.1,s+ur,i+o*y+a*e*.1],[a,.5,o],Cr([-o,0,a],[0,-1,0])]))}[-1,1].forEach(e=>{let n=t(e<0?Z.WALL_L:Z.WALL_R);if(n>.002){let[t,r]=O;[e,-e].forEach((i,a)=>{let d=(o+.5*a)%1,f=d<.55,_=f?d/.55:(d-.55)/.45,v=f?0:Math.sin(Math.PI*_),y=(f?2*_-1:1-2*mr(_))*(a?.4:.3);l.push([h(i),n,a?s(-e*.12,p[1]-.7+.4*v,y):s(e*(.34-.2*v),p[1]-.52+.3*v,y),c(-e*.7,1,-1),a?K(q(or,u),q(Y,-.5)):nr(g,Cr(vr([t,0,r],c(0,0,-1)),[t,0,r]),1-v)]);let b=Math.cos(ar*(o+.5*(1-a)));l.push([m(i),n,a?s(-e*.5,p[1]+.3+.12*b,.2*b):s(e*.37,p[1]+.3+.05*b,.1*b),c(a?-e*.7:0,a?0:-.5,.7),Cr(a?[0,i,0]:[-i*t,0,-i*r],c(0,0,-1))])})}});let v=t(Z.SLIDE);if(v>.002){let e=E[1];l.push([G.FOOT_R,v,s(.12,e+ur+.14,-.85,p),c(.1,1,-.3),g],[G.FOOT_L,v,s(-.2,e+ur,-.3,p),c(-.4,1,-.1),g],[G.HAND_L,v,s(-.4,e+.03,.4,p),c(-.7,0,.7),Cr([0,-1,0],c(-1,0,0))])}l.forEach(([e,t,n,i,a])=>{let[o,s,c]=[e-2,e<G.THIGH_L,t*t],l=yr(yr(d[o+1],1,d[o],-1),1,J(f[o],[0,0,s?1:-1]),.05),[u,p]=[yr(d[e],1-c,n,c),e=>br(yr(e,1,d[o],-1))],m=yr(br(xr(l,p(d[e]))),1-c,br(xr(i,p(n))),c),[h,g]=s?wr(d[o],u,m,dr,fr,-1):wr(d[o],u,m),_=s?K(h,q(sr,o==G.ARM_L?.1:-.1)):h;r[o]=K(gr(f[Qn[o]]),_),r[o+1]=K(gr(_),g),r[e]=nr(r[e],K(gr(g),a),c)})},M=()=>{let{rot:i}=e,a=_,s=e=>n[Gr+2*e],[l,d,f,p,m]=[n[Pr],n[Fr],n[Ir],n[Lr],n[Rr]],[v,y]=[Math.cos(ar*o),Math.cos(2*ar*o)],x=Math.cos(ar*(o-(1+g)/2)),D=t.po*a*x,O=t.pt+C[3]+t.pa*a*y,k=(t.cc+t.pr)*a*v,A=1-a,j=A*.012*Math.sin(ar*.28*c),M=A*.012*Math.sin(ar*.17*c+C[1]*9),te=t.sw*a*x+M;e.at[0]=E[0],e.at[1]=E[1],e.at[2]=E[2],e.yaw=u,i[G.PELVIS]=K(K(q(or,-t.pr*a*v),q(sr,D+.4*d)),q(Y,-(O+.25*l+.3*m+.5*p)));let N=O+.25*l-l-.7*m-.8*p;i[G.SPINE]=K(K(q(or,.4*k-.25*f),q(sr,.25*d-.8*D+.5*M)),q(Y,.45*N+j*.5)),i[G.CHEST]=K(K(q(or,.6*k-.25*f),q(sr,.25*d-.8*D-.5*M)),q(Y,.55*N+j)),[-1,1].forEach(e=>{let n=Math.cos(ar*(o-(e<0?.5:0))),r=C[e<0?1:2];i[e<0?G.ARM_L:G.ARM_R]=K(q(sr,e*(.06+t.ab*a+.5*p)),q(Y,(t.am+t.aa*r*n)*a+.05*A*e*Math.sin(c*1.3)+p+.5*m)),i[e<0?G.FOREARM_L:G.FOREARM_R]=q(Y,.15*A+a*(t.em+t.ea*n)+p+.5*m)});let P=q(or,u),F=K(P,i[G.PELVIS]),[I,L]=[Math.cos(u),-Math.sin(u)],R=[E[0]+I*te,0,E[2]+L*te],ne=[G.THIGH_L,G.THIGH_R].map(e=>J(F,$n[e])),re=1-.25*m-.7*p,ie=E[1]+.05+ur+pr*(re-t.d0-.6*t.d1*a)+t.hop*a*(.5-.5*Math.cos(2*ar*o-2*ar*g/2)),ae=r.map((e,n)=>{let[r,i]=[e.x-R[0]-ne[n][0],e.z-R[2]-ne[n][2]],o=t.d0+t.d1*a*Math.sin(Math.PI*e.x0)+1-re,s=Math.min(pr*(1-o),pr*.99),c=e.y+Math.sqrt(Math.max(s*s-r*r-i*i,.04));return ie+(c-ne[n][1]-ie)*e.w}),oe=Sr(ae[0],ae[1],.05),se=c-S;S=c,se>.1?[n[Vr],n[Vr+1]]=[oe,0]:ir(n,Vr,oe,30,se),R[1]=Math.min(oe,n[Vr]),e.hips=[te,R[1]-E[1]-$n[0][1],0],r.forEach((e,t)=>{let n=t?1:-1,r=[R[0]+ne[t][0],R[1]+ne[t][1],R[2]+ne[t][2]],a=u-n*C[4],[o,s]=wr(r,[e.x,e.y,e.z],[-Math.sin(a),0,-Math.cos(a)]),c=t?G.THIGH_R:G.THIGH_L;i[c]=K(gr(F),o),i[c+1]=K(gr(o),s),i[c+2]=K(gr(s),K(q(or,a),q(Y,e.th))),i[c+3]=q(Y,e.th<0?-e.th*e.tw:0)}),Or.forEach((t,n)=>{let r=s(n);if(r>.002){let a=jr(t),o=n==Z.STUN;Ar.slice(o?3:0,o?7:15).forEach(e=>i[e]=nr(i[e],a[e],r)),o||[t[13],t[0],t[12]].forEach((t,n)=>e.hips[n]+=(t-e.hips[n])*r)}}),h&&(i[G.PELVIS]=K(q(Y,-ar*(3-2*h)*h*h),i[G.PELVIS]));let ce=s(Z.HANG);if(ce>.002){let[t,n]=[.01*Math.sin(ar*(.3*c+C[5])),.006*Math.sin(ar*(.2*c+3*C[5]))].map(e=>e*ce);i[G.PELVIS]=K(K(q(sr,n),q(Y,t)),i[G.PELVIS]),[G.THIGH_L,G.THIGH_R].forEach(e=>i[e]=K(i[e],q(Y,t))),e.hips[0]+=n,e.hips[2]-=t}let z=s(Z.STUN);if(z){[G.SPINE,G.CHEST].forEach((e,t)=>{let r=.3+.1*t;i[e]=K(i[e],K(q(sr,-r*n[Wr]),q(Y,-r*n[Ur])))});let e=Math.sin(c*13);[G.ARM_L,G.ARM_R].forEach((t,n)=>i[t]=K(i[t],q(Y,z*(n?e:-e)))),i[G.CHEST]=K(i[G.CHEST],q(or,.3*z*Math.sin(c*8)))}ee();let le=mr((s(Z.DOWN)-.35)/.65);le&&(i[G.PELVIS]=K(q(Y,-1.45*le),i[G.PELVIS]),e.hips[1]+=(.17-$n[0][1]-e.hips[1])*le,[G.THIGH_L,G.THIGH_R].forEach(e=>i[e]=K(i[e],q(Y,-1.25*le))),[G.ARM_L,G.ARM_R].forEach(e=>i[e]=K(i[e],q(Y,-.5*le))));let ue=K(K(P,i[G.PELVIS]),K(i[G.SPINE],i[G.CHEST])),B=K(q(or,w),q(Y,X(T,-1,1)*.9)),V=K(gr(ue),nr(ue,B,.85*(1-s(Z.TUCK))*(1-.5*z)*(1-s(Z.DOWN))));return i[G.NECK]=nr([0,0,0,1],V,.4),i[G.HEAD]=K(gr(i[G.NECK]),V),b=!1,e};return{update:j,pose:()=>b?M():e,get phase(){return o},get steps(){return s}}},Yr=e=>Math.sign(e)*Math.abs(e)**.8,Xr=(e,t,n)=>e.map((e,r)=>e+(t[r]-e)*n),Zr=e=>Math.min(Math.max(e,0),1),Qr=(e,t,n,r)=>{let i=[],a=[],o=[],s=t.map(([e,r,o,s,c=0],l)=>{let[u,d]=[t[Math.max(l-1,0)],t[Math.min(l+1,t.length-1)]],f=Math.hypot(d[0]-u[0],d[1]-u[1])||1,[p,m]=[(d[0]-u[0])/f,(d[1]-u[1])/f];return Array.from({length:o?n:1},(t,l)=>{let[u,d]=[Yr(Math.cos(l*V/n)),Yr(Math.sin(l*V/n))];return i.push([c+o*u,r+s*d*p,-(e-s*d*m)]),a.push([0,0,0]),i.length-1})});s.slice(1).forEach((e,r)=>{let c=s[r],l=[(t[r][4]??0)+(t[r+1][4]??0),t[r][1]+t[r+1][1],-t[r][0]-t[r+1][0]];for(let t=0;t<n;t++){let[n,r,s,u]=[c[t%c.length],c[(t+1)%c.length],e[(t+1)%e.length],e[t%e.length]];for(let e of[[n,r,s],[n,s,u]]){if(new Set(e).size<3)continue;let[t,n]=[1,2].map(t=>[0,1,2].map(n=>i[e[t]][n]-i[e[0]][n])),r=[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]],s=[0,1,2].reduce((t,n)=>t+r[n]*(i[e[0]][n]*2-l[n]),0)<0;o.push(...s?[e[0],e[2],e[1]]:e);for(let t of e)[0,1,2].forEach(e=>a[t][e]+=s?-r[e]:r[e])}}});for(let t of o){let n=Math.hypot(...a[t])||1,o=a[t].map(e=>e/n);e.push(...i[t],...o,...r(i[t],o))}},$r=[.34,.12,.62],ei=[.72,.46,1],ti=[.1,.38,.72],ni=[.16,.06,.34],ri=[.5,1.9,2.3],ii=(e=0)=>(t,n)=>{let r=Xr(Xr($r,ti,Zr(-t[2]*5-.3)*.8),ei,Math.max(n[1],0)**1.5*.7),[i,a,,o]=Xr([...r.slice(0,2),0,r[2]],[...ni.slice(0,2),0,ni[2]],Zr(-n[1]*.5+e));return[i,a,-1,o]},ai=[.035,.025,.08],oi=()=>[ri[0],ri[1],-2,ri[2]],si=[0,.095,.06],ci=[0,.075,-.21],li=[Math.sin(.4),Math.cos(.4)],ui=[[-.063,.1,0,0],[-.062,.098,.026,.016],[-.055,.1,.04,.02],[-.035,.103,.046,.038],[-.005,.104,.048,.04],[.035,.1,.044,.038],[.08,.094,.036,.034],[.12,.088,.028,.028],[.16,.082,.021,.021],[.19,.078,.015,.015],[.205,.076,.01,.01],[.208,.0755,0,0]],di=[[-.05,-.02,0,0],[-.045,-.025,.018,.012],[-.025,-.052,.032,.018],[.01,-.066,.036,.02],[.06,-.06,.034,.02],[.11,-.04,.028,.018],[.16,0,.02,.014],[.2,.04,.012,.01],[.222,.065,0,0]],fi=[],pi=e=>{if(fi[e])return fi[e];let[t,n]=e?[12,8]:[8,5],r=[];Qr(r,ui,t,ii()),Qr(r,di,t,ii(.25)),Qr(r,[[.03,.06,0,0],[.02,.046,.021,.022],[0,0,.021,.023],[-.02,-.046,.021,.022],[-.03,-.06,0,0]],n,ii(.1));for(let t of[-1,1])Qr(r,ui.slice(1,6).map(([e,n,r,i])=>[e,n-.1*i,.0035,.006,t*r*.93]),e?5:3,oi),Qr(r,di.slice(1,7).map(([e,n,r,i])=>[e,n+.3*i,.0035,.005,t*r*.92]),e?5:3,oi);return Qr(r,[[.198,.077,0,0],[.2,.077,.011,.011],[.207,.0757,.008,.008],[-ci[2],ci[1],0,0]],n,oi),fi[e]=r},mi=e=>{let[t,n,r]=[J(e,[0,0,-1]),J(e,[1,0,0]),J(e,[0,-1,0])],[i,a]=li;return[n,t.map((e,t)=>a*e-i*r[t]),t.map((e,t)=>i*e+a*r[t])]},hi=(e,t)=>{let[n,r]=[J(t,[0,-1,0]),J(t,[1,0,0])];return e.map((e,t)=>e+n[t]*.078-r[t]*.022)},gi=[`abcdef`,`bc`,`abdeg`,`abcdg`,`bcfg`,`acdfg`,`acdefg`,`abc`,`abcdefg`,`abcdfg`],[_i,vi,yi,bi]=[.019,.026,.0055,.004],xi={a:[0,vi-yi,_i,vi],b:[_i-yi,vi/2,_i,vi],c:[_i-yi,0,_i,vi/2],d:[0,0,_i,yi],e:[0,0,yi,vi/2],f:[0,vi/2,yi,vi],g:[0,(vi-yi)/2,_i,(vi+yi)/2]},Si=[[.032,.112,.056],[.036,.112,.012]],Ci=[[.028,.156,.036],[.028,.152,.02]],[wi,Ti,Ei]=[.023,.0175,.0455],Di=/* @__PURE__ */ new Map,Oi=e=>{let t=Math.min(Math.max(Math.floor(e),0),99),n=Di.get(t);if(!n){let e=n=[],r=e=>[-e[0],e[1],e[2]],[i,a,o,s]=[Si[0],Si[1],Ci[0],Ci[1]],c=[i,a,o,s].flatMap(e=>[e,r(e)]),l=[0,1,2].map(e=>c.reduce((t,n)=>t+n[e],0)/c.length),u=(t,n)=>{let[r,i]=[U(t[1],t[0]),U(t[2],t[0])],a=[r[1]*i[2]-r[2]*i[1],r[2]*i[0]-r[0]*i[2],r[0]*i[1]-r[1]*i[0]],o=U(t[0],l),s=Xt(a,o)<0?[t[0],t[3],t[2],t[1]]:t,[c,u,,d]=ii(.15)(s[0],W(Xt(a,o)<0?[-a[0],-a[1],-a[2]]:a));bn(e,s[0],s[1],s[2],n??[c,u,d]),bn(e,s[0],s[2],s[3],n??[c,u,d])};u([i,r(i),r(o),o]),u([a,r(a),r(s),s]),u([i,a,s,o]),u([r(i),r(a),r(s),r(o)]),u([o,r(o),r(s),s]);let d=W(U(o,i)),[f,p]=[[0,i[1],i[2]],[0,-d[2],d[1]]],m=(e,t,n)=>[f[0]+e,f[1]+d[1]*t+p[1]*n,f[2]+d[2]*t+p[2]*n];u([m(-wi,Ti,.0012),m(wi,Ti,.0012),m(wi,Ei,.0012),m(-wi,Ei,.0012)],ai);let h=e.length;[...`${t}`.padStart(2,`0`)].forEach((n,r)=>{let i=-_i-bi/2+r*(_i+bi);for(let r of gi[+n]){let[n,a,o,s]=xi[r],c=(e,t)=>m(i+e,(Ti+Ei-vi)/2+t,.0027),l=t>10?[.25,.9,1]:[1,.18,.12];bn(e,c(n,a),c(o,a),c(o,s),l),bn(e,c(n,a),c(o,s),c(n,s),l)}}),yn(e,h,1),Di.set(t,n)}return n},ki=(e,t,n,r,i=1,a)=>{let[o,s]=[hi(t,n),mi(n)];on(e,pi(r),o,s,[0,0,0],i),a!==void 0&&on(e,Oi(a),o,s,[0,0,0],i)},Ai=(e,[,t,n])=>[0,1,2].map(r=>e[r]+t[r]*ci[1]-n[r]*ci[2]),ji=Math.atan2(si[1]-ci[1],si[2]-ci[2]),Mi=(e,t,n,r)=>{let i=(e,t)=>[e[0]*t,e[1]*t,e[2]*t],a=[n,r,W(U(t,e))];for(let o=0;o<3;o++){let s=W(U(t,o?Ai(e,a):e)),c=W(U(n,i(s,Xt(n,s)))),l=W(U(U(r,i(s,Xt(r,s))),i(c,Xt(r,c)))),[u,d]=[Math.sin(ji),Math.cos(ji)];a=[c,Yt(i(l,d),i(s,-u)),Yt(i(s,d),i(l,u))]}return a},Ni=(e,t)=>{let n=[e.x,e.y+Ee(e),e.z],r=Qt(e.yaw,e.pitch)[2],i=le(t,n,r,80);return[[0,1,2].map(e=>n[e]+r[e]*i),i<80]},Pi=(e,t)=>{let[n,r,i]=Qt(e.yaw,e.pitch),a=[e.x,e.y+Ee(e),e.z],o=[0,1,2].map(e=>a[e]+n[e]*.2-r[e]*.17+i[e]*.42);return[o,Mi(o,t,n,r)]},[Fi,Ii]=[.07,1.07],Li=.03,Ri=.019,zi=.1,[Bi,Vi]=[Math.sin(.55),Math.cos(.55)],Hi=(...e)=>[0,1,2].map(t=>e.reduce((e,[n,r])=>e+n[t]*r,0)),Ui=([e,t,n],[r,i,a])=>[t*a-n*i,n*r-e*a,e*i-t*r],Wi=(e,t)=>Math.sign(e)*Math.abs(e)**t,Gi=e=>{let t=Math.sin(e*78.233)*43758.5453;return t-Math.floor(t)},Ki=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),qi=e=>Li*((e-Fi)/(Ii-Fi))**2,Ji=[[0,Ri,.0041],[.07,Ri,.0041],[.17,.0188,.0041],[.31,.0183,.004],[.44,.0178,.0039],[.58,.0172,.0036],[.71,.0166,.0034],[.82,.016,.0031],[.9,.015,.0026],[.96,.0122,.0019],[.984,.0074,.001],[1,0,0]].map(([e,t,n])=>[Fi+(Ii-Fi)*e,t,n]),Yi=(e,t,n,r,i,a,o=1)=>Array.from({length:a},(s,c)=>[t+r*Wi(Math.cos(c*2*Math.PI/a),o),n+i*Wi(Math.sin(c*2*Math.PI/a),o),-e]),Xi=(e,t,n)=>t.slice(1).forEach((r,i)=>{let a=t[i],o=[...a,...r],s=Hi(...o.map(e=>[e,1/o.length]));for(let t=0;t<Math.max(a.length,r.length);t++){let o=[a[t%a.length],a[(t+1)%a.length],r[(t+1)%r.length],r[t%r.length]];for(let[r,a,c]of[[0,1,2],[0,2,3]]){let[l,u,d]=[o[r],o[a],o[c]],f=Ui(Hi([u,1],[l,-1]),Hi([d,1],[l,-1]));if(Math.hypot(...f)<1e-12)continue;let p=f[0]*(l[0]-s[0])+f[1]*(l[1]-s[1])+f[2]*(l[2]-s[2])>0;bn(e,l,p?u:d,p?d:u,n(i,t))}}}),Zi=[[.7,.78,.9],[.16,.2,.3],[.07,.09,.14]],Qi=[.5,1.9,2.3],$i=[[.26,.09,.5],[.06,.04,.12]],ea=[.1,.09,.14],ta=[.5,.4,.16],na=[],ra=e=>{if(na[e])return na[e];let t=[],n=Ji.filter((t,n)=>e||n%2==0||n==Ji.length-1);Xi(t,n.map(([e,t,n])=>{let r=qi(e)+(Ri-t)/2;return[[0,r-t,-e],[n,r+.15*t,-e],[.6*n,r+t,-e],[-.6*n,r+t,-e],[-n,r+.15*t,-e]]}),(e,t)=>Zi[t%4==0?0:t==2?2:1]);let r=t.length;Xi(t,[...n.slice(0,-1).map(([t,n])=>Yi(t,0,qi(t)+(Ri-n)/2-n-.0012,.0026,.0026,e?5:3)),[[0,qi(Ii)+Ri/2,-Ii]]],()=>Qi),yn(t,r,1);let i=(e,t=0)=>[[0,t,-e]],a=e?8:5;Xi(t,[i(Fi-.026),...[.056,.066,.084].map(e=>Yi(e,0,0,.0066,.023,6)),i(.084)],()=>ta);let o=(t,n)=>Yi(t,0,0,.038*n,.038*n,e?16:8,.6);Xi(t,[i(.05),o(.05,.9),o(.053,1),o(.06,1),o(.063,.9),i(.063)],()=>ea);let s=e?20:9;Xi(t,[i(.052),...Array.from({length:s},(e,t)=>{let n=t/(s-1),r=1+.1*Math.sin(Math.PI*n);return Yi(.052-.262*n,0,0,.0114*r,.0136*r,a)})],(e,t)=>$i[e+t&1]);let c=e=>Yi(e,0,0,.013,.0154,a);Xi(t,[i(-.202),c(-.206),c(-.218),i(-.22)],()=>ea);let l=t.length;return Xi(t,[i(-.22),Yi(-.222,0,0,.006,.006,5),i(-.23)],()=>Qi),yn(t,l,1),na[e]=t},ia=(e,t,[n,r,i],a,o,s=1)=>{let c=Math.floor(a*14),l=e.length;for(let a=0;a<(o?4:2);a++){let o=e=>Gi(c*31+a*7+e);if(o(0)<.3)continue;let l=.12+.2*o(2),u=.12+(Ii-.17-l)*o(1),d=Array.from({length:5},(e,a)=>{let c=u+l*a/4,[d,f]=a?[(o(3+a)-.5)*.04,(o(8+a)-.5)*.04]:[0,0];return Hi([t,1],[n,d*s],[r,(f+qi(c)+.004)*s],[i,c*s])});for(let t=1;t<5;t++)for(let i of[n,r]){let n=.0035*s,[r,a,o,c]=[Hi([d[t-1],1],[i,-n]),Hi([d[t-1],1],[i,n]),Hi([d[t],1],[i,n]),Hi([d[t],1],[i,-n])];bn(e,r,a,o,[.7,1.9,2.4]),bn(e,r,o,c,[.7,1.9,2.4])}}yn(e,l,1)},aa=(e,t,n,r,i,a=1)=>{on(e,ra(r),t,n,[0,0,0],a),i!==void 0&&ia(e,t,n,i,r,a)},oa=e=>{let[t,n,r]=[J(e,[0,0,-1]),J(e,[1,0,0]),J(e,[0,-1,0])];return[n,Hi([t,Bi],[r,-Vi]),Hi([t,Vi],[r,Bi])]},sa=(e,t,n,r,i,a=1)=>aa(e,hi(t,n),oa(n),r,i,a),ca=(e,t)=>{let[n,[,r,i]]=[hi(e,t),oa(t)];return[Hi([n,1],[i,Fi]),Hi([n,1],[i,Ii],[r,qi(Ii)+Ri/2])]},la=.3,ua=[.06,-.24,.45,.16,.74,.65],da=e=>h[e].strike/h[e].ticks,fa=e=>[[0,...ua],[.12,-.14,-.08,.38,-.55,.75,-.35],[.24,-.3,0,.28,-.6,.35,-.72],[e-.07,-.22,-.1,.38,-.98,.15,.1],[e,.02,-.16,.43,0,.1,1],[.5,.32,-.18,.38,.95,-.1,.15],[.62,.34,-.22,.24,.6,-.35,-.7],[.8,.22,-.26,.36,.45,.6,.2],[1,...ua]],pa=[[[0,...ua],[.3,.17,-.28,.17,-.08,.25,1],[da(0),.03,-.2,.43,-.02,.12,1],[da(0)+.2,.03,-.2,.43,-.02,.12,1],[1,...ua]],fa(da(1)),[[0,...ua],[.12,.24,-.08,.36,.55,.75,-.35],[.24,.34,0,.24,.6,.35,-.72],[da(2)-.07,.26,-.1,.36,.98,.15,.1],[da(2),.08,-.16,.43,0,.1,1],[.5,-.16,-.18,.36,-.95,-.1,.15],[.62,-.2,-.22,.28,-.6,-.35,-.7],[.8,-.08,-.26,.38,-.3,.6,.2],[1,...ua]],[[0,...ua],[.14,.05,-.02,.34,-.05,.95,-.1],[.28,.04,.14,.26,0,.5,-.86],[.34,.05,.08,.34,0,1,.15],[da(3),.05,-.16,.43,0,.08,1],[.52,.04,-.26,.42,0,-.55,.85],[.64,.03,-.3,.38,0,-.65,.75],[1,...ua]],[[0,...ua],[.2,.18,-.26,.16,-.08,.3,1],[da(4),.03,-.18,.41,-.02,.1,1],[da(4)+.3,.03,-.18,.41,-.02,.1,1],[1,...ua]],[[0,...ua],[.15,-.3,0,.28,-.6,.35,-.72],[.25,-.1,-.12,.4,-.7,.1,.7],[.35,.24,-.14,.38,.7,.05,.7],[.65,.26,-.14,.36,.72,0,.68],[.78,.3,-.24,.26,.6,-.35,-.7],[.9,.2,-.26,.36,.45,.6,.2],[1,...ua]],[[0,...ua],[.15,.34,0,.24,.6,.35,-.72],[.25,.2,-.12,.38,.7,.1,.7],[.35,-.12,-.14,.38,-.7,.05,.7],[.65,-.14,-.14,.36,-.72,0,.68],[.78,-.2,-.22,.28,-.6,-.35,-.7],[.9,-.12,-.26,.38,-.45,.6,.2],[1,...ua]],[[0,...ua],[.12,.05,.02,.32,-.05,.95,-.1],[.3,.04,.14,.26,0,.5,-.86],[.55,.04,.14,.26,0,.5,-.86],[da(7)-.07,.05,.08,.34,0,1,.15],[da(7),.05,-.16,.43,0,.08,1],[.8,.04,-.28,.42,0,-.6,.8],[.9,.03,-.3,.38,0,-.65,.75],[1,...ua]]],ma=(e,t)=>{let n=e===y.SPIN_L?-1:+(e===y.SPIN_R),r=Ki((t-.3)/.45);return n*V*r*r*(3-2*r)},ha=[],ga=(e,t,n)=>{let r=e.length-2;for(;r>0&&e[r][0]>t;)r--;let[i,a]=[e[r],e[r+1]],o=a[0]-i[0],s=Ki((t-i[0])/o),[c,l]=[s*s,s*s*s];for(let t=1;t<i.length;t++){let u=r?(a[t]-e[r-1][t])/(a[0]-e[r-1][0]):0,d=e[r+2]?(e[r+2][t]-i[t])/(e[r+2][0]-i[0]):0;n[t-1]=(2*l-3*c+1)*i[t]+(l-2*c+s)*o*u+(3*c-2*l)*a[t]+(l-c)*o*d}return n},_a=(e,t)=>ga(pa[e],t,ha),va=e=>[[0,0,0,0],[.12,.3,-.04,.06],[.24,.55,-.06,.1],[e-.07,.32,0,.04],[e,0,.06,-.04],[.5,-.45,.12,-.1],[.62,-.55,.14,-.12],[.8,-.25,.06,-.04],[1,0,0,0]],ya=[[[0,0,0,0],[.3,-.32,-.04,0],[da(0),.36,.2,.04],[da(0)+.2,.36,.2,.04],[1,0,0,0]],va(da(1)),va(da(2)).map(e=>[e[0],-e[1],e[2],-e[3]]),(e=>[[0,0,0,0],[.14,0,-.1,0],[.28,.04,-.26,0],[.34,.04,-.2,0],[e,0,.16,0],[.52,0,.4,0],[.64,0,.42,0],[1,0,0,0]])(da(3)),[[0,0,0,0],[.2,-.4,-.06,0],[da(4),.46,.3,.06],[da(4)+.3,.46,.3,.06],[1,0,0,0]],[[0,0,0,0],[.15,.5,-.04,.08],[.35,-.3,.06,-.08],[.65,-.3,.06,-.08],[.78,-.5,.12,-.1],[1,0,0,0]],[[0,0,0,0],[.15,-.5,-.04,-.08],[.35,.3,.06,.08],[.65,.3,.06,.08],[.78,.5,.12,.1],[1,0,0,0]],[[0,0,0,0],[.3,0,-.26,0],[.55,0,-.26,0],[da(7)-.07,0,-.1,0],[da(7),0,.2,0],[.8,0,.45,0],[.9,0,.45,0],[1,0,0,0]]],ba=[],xa=(e,t)=>ga(ya[e],t,ba),Sa=.2,Ca=(e,t,n)=>{let r=t.swing??0;if(!r)return-1;let i=h[t.cut??0].ticks,a=1-r/i;return e<0?a:Math.min(Math.max(e+n*60/i,a),a+2/i,1)},wa=e=>e>.24&&e<.6,Ta=[.66,.45,.35],[Ea,Da,Oa,ka,Aa,ja,Ma,Na,Pa,Fa,Ia]=[0,1,2,3,4,5,6,7,8,9,10],La=[[.03,.03,.035],[.09,.07,.06],[.2,.12,.07],[.36,.18,.08],[.55,.16,.06],[.58,.43,.2],[.86,.72,.44],[.6,.6,.58]],Ra=e=>La[(Math.imul(e+1,2654435761)>>>29)%La.length],za=(e,t=La[1])=>[e,e.map(e=>e*.5),[.12,.13,.17],Ta,t,[.74,.74,.77],[.93,.93,.94],[.26,.26,.3],[.85,.83,.8],[.1,.06,.04],[2.8,.5,.12]],Ba={chain:[G.PELVIS,G.SPINE,G.CHEST,G.NECK,G.HEAD],n:[8,12],e:2.3,far:[0,2,4,6,7,9,12,14,15,17,19,21],rings:[[.93,0,.01,.187,.108,0,Oa],[.99,0,.005,.18,.106,.25,Da],[1.03,0,0,.17,.102,.5,Ea],[1.12,0,0,.155,.097,1,Ea],[1.24,0,-.003,.176,.112,1.7,Ea],[1.3,0,-.004,.182,.12,1.85,Ea],[1.37,0,-.005,.186,.124,2,Ea],[1.37,0,-.005,.264,.124,2,Ea],[1.41,0,-.005,.268,.123,2,Ea],[1.45,0,-.004,.26,.114,2,Ea],[1.485,0,0,.235,.098,2.05,Ea],[1.502,0,0,.185,.09,2.08,Ea],[1.512,0,0,.125,.08,2.1,Ea],[1.532,0,0,.07,.068,2.25,Da],[1.555,0,0,.06,.062,2.6,ka],[1.6,0,-.0165,.058,.0665,3.5,ka],[1.635,0,-.0085,.072,.0785,4,ka,150,Aa],[1.675,0,-.001,.08,.089,4,ka,110,Aa],[1.71,0,.0035,.083,.0935,4,ka,72,Aa],[1.75,0,.0065,.08,.0885,4,Aa],[1.785,0,.011,.056,.061,4,Aa],[1.8,0,.015,0,0,4,Aa]]},Va={chain:[G.PELVIS,G.THIGH_R,G.SHIN_R,G.FOOT_R,G.TOE_R],n:[6,8],m:!0,far:[0,2,4,6,8,10,12,14],rings:[[.93,.1,0,0,0,0,Oa],[.85,.1,.006,.093,.098,.6,Oa],[.72,.1,-.002,.088,.09,1,Oa],[.55,.1,-.003,.066,.07,1.25,Oa],[.49,.1,-.004,.058,.064,1.5,Oa],[.42,.1,.002,.056,.064,1.8,Oa],[.33,.1,.012,.055,.068,2,Oa],[.19,.1,.003,.04,.047,2.05,Oa],[.105,.1,0,.038,.045,2.3,ja],[.085,.1,.0025,.038,.0425,2.5,ja],[.065,.1,.02,.043,.098,3,ja],[.045,.1,.039,.046,.133,3,ja],[.026,.1,.059,.046,.149,3,Ma],[.008,.1,.062,.03,.138,3,Ma],[0,.1,.062,0,0,3,Ma]]},Ha={chain:[G.ARM_R,G.FOREARM_R,G.HAND_R],n:[0,0],m:!0,far:[0,2,4,5,6,8,10],rings:[[1.37,.222,0,0,0,0,Ea],[1.3,.222,0,.053,.056,.1,Ea],[1.22,.222,0,.049,.052,.2,Ea],[1.18,.222,0,.043,.046,.5,Ea],[1.09,.222,-.002,.046,.048,.8,Ea],[.975,.222,0,.034,.034,1.2,Da],[.935,.222,0,.03,.03,1.8,Na],[.885,.222,-.004,.027,.037,2,Na],[.84,.222,-.008,.029,.042,2,Na],[.795,.222,-.012,.025,.034,2,Na],[.772,.222,-.014,0,0,2,Na]]},Ua=[.925,.222,0,.027,.027,2,Na],Wa=Ba.n[1]-4,Ga={chain:[G.HEAD],n:[0,5],z:!0,m:!0,far:[],rings:[[-.07,.031,1.692,.0145,.0088,0,Pa],[-.088,.031,1.692,.0145,.0088,0,Pa],[-.0915,.031,1.692,.0105,.0072,0,Fa],[-.0932,.031,1.692,.0055,.0055,0,Fa],[-.094,.031,1.692,0,0,0,Fa]]},Ka={chain:[G.HEAD],n:[0,5],z:!0,far:[],rings:[[-.075,0,1.675,.014,.034,0,ka],[-.1,0,1.66,.012,.024,0,ka],[-.115,0,1.649,0,0,0,ka]]},qa=[Ba,Va,Ha,Ka,Ga],Ja=(e,t)=>Math.sign(e)*Math.abs(e)**(2/t),Ya=e=>Math.min(Math.max(e,0),1),Xa=e=>{let[t,n,r,i,a,o]=[[],[],[],[],[],[]],s=Ba.n[Math.min(e,1)],[c,l]=[s/2,s/2-1],u=[],d=0,f=[],p=(e,i,a,o)=>(t.push(...e,0,0,0),n.push(i,a),r.push(o),r.length-1);for(let n of qa){let r=n===Ha?s-4:n.n[Math.min(e,1)];if(!r||e>1&&(n===Ka||n===Ga))continue;let m=e>1&&n===Ba?[...n.rings.slice(0,10),[1.462,0,0,0,0,2,Ea]]:e>1&&n===Ha?[...n.rings.slice(0,6),[.95,.222,0,.037,.037,1.6,Na],Ua,[.91,.222,0,0,0,2,Na]]:e?n.rings:n.far.map(e=>n.rings[e]),h=m[m.length-1][0]>m[0][0];n===Ba&&(d=m.findIndex((e,t)=>t&&e[0]==m[t-1][0]));for(let e of n.m?[1,-1]:[1]){let g=t=>e<0&&t>G.HEAD?t-4:t,_=(t,n)=>t[e<0?(s-n)%s:n],v=(e,t,r,i)=>{i=n===Va&&t<.12?3+Ya((-r-.04)/.14):i;let a=Math.min(Math.floor(i),n.chain.length-2),o=n===Ba?Ya((Math.abs(e)-.14)/.1)*Ya((1.53-t)/.15)*Ya((t-1.35)/.02):0;return o?p([e,t,r],G.CHEST,e<0?G.ARM_L:G.ARM_R,o):p([e,t,r],g(n.chain[Math.max(a,0)]),g(n.chain[a+1]??n.chain[0]),a<0?0:i-a)},y=m.map(([i,a,o,m,h,g],y)=>{let b=[];if(!y&&n===Ha){for(let e=1;e<=l;e++)b.push(_(u[d],e));for(let e=l-1;e>1;e--)b.push(_(u[d-1],e))}else if(!y&&n===Va){for(let e=0;e<=c;e++)b.push(_(u[0],e));let[e,n]=[u[0][0]*6,u[0][c]*6];for(let i=0;i<r-c-1;i++){let a=(i+1)/(r-c);f[i]??=p([0,1,2].map(r=>t[n+r]+(t[e+r]-t[n+r])*a-(r==1?.04:0)),G.PELVIS,G.PELVIS,0),b.push(f[i])}b.push(b.shift())}else for(let t=0;t<(m?r:1);t++){if(n===Ba&&y==d-1&&!(t>1&&t<l)&&!(t>s-l&&t<s-1)){b.push(-1);continue}let c=t*2*Math.PI/r,u=(n.e??2)*(n===Va&&i<.12?2:1),[f,p]=[a+m*Ja(Math.sin(c),u),o+h*Ja(Math.cos(c),u)];b.push(n.z?v(e*f,p,i,g):v(e*f,i,-p,g))}return b});n===Ba&&(y[d-1]=y[d-1].map((e,t)=>e<0?y[d][t]:e),u=y),y.slice(1).forEach((t,s)=>{if(n===Ba&&s==d-1)return;let c=y[s],[l,,,,,,u,...f]=m[s],p=n===Ba?+(l>1.55):n===Ka||n===Ga?b.HEAD:(n===Ha?b.ARM_L:b.LEG_L)+ +(e>0);for(let n=0;n<r;n++){let[s,l,d,m]=[c[n%c.length],c[(n+1)%c.length],t[(n+1)%t.length],t[n%t.length]],g=Math.abs(((n+.5)/r*360+180)%360-180),_=f.findIndex((e,t)=>!(t%2)&&(e>0?g>e:g<-e));for(let t of[[s,l,d],[s,d,m]])new Set(t).size>2&&(i.push(...h===e<0?t:[t[0],t[2],t[1]]),a.push(_<0?u:f[_+1]),o.push(p))}})}}for(let e=0;e<i.length;e+=3){let[n,r,a]=[i[e],i[e+1],i[e+2]].map(e=>e*6),o=[0,1,2].map(e=>[t[r+e]-t[n+e],t[a+e]-t[n+e]]),s=[o[1][0]*o[2][1]-o[2][0]*o[1][1],o[2][0]*o[0][1]-o[0][0]*o[2][1],o[0][0]*o[1][1]-o[1][0]*o[0][1]];for(let e of[n,r,a])for(let n=0;n<3;n++)t[e+3+n]+=s[n]}for(let e=0;e<t.length;e+=6){let n=Math.hypot(t[e+3],t[e+4],t[e+5])||1;for(let r=3;r<6;r++)t[e+r]/=n}return{v:new Float32Array(t),j:new Uint8Array(n),w:new Float32Array(r),t:new Uint16Array(i),c:new Uint8Array(a),l:new Uint8Array(o)}},Za=[],Qa=e=>Za[e]??=Xa(e),$a=[0,G.NECK,G.CHEST,G.CHEST,G.PELVIS,G.PELVIS],eo=(e,t)=>{let n=e.w.length,[r,i]=[[[],[]],[[],[]]],[a,o]=[/* @__PURE__ */ new Set,/* @__PURE__ */ new Set];e.c.forEach((n,s)=>{let c=+(e.l[s]==t);for(let t=0;t<3;t++)r[c].push(e.t[s*3+t]),[o,a][c].add(e.t[s*3+t]<<16|e.t[s*3+(t+1)%3]);i[c].push(n)});let s=new Float32Array(n*6+6);s.set(e.v);let c=0;for(let t of a){let[a,l]=[t>>16,t&65535];if(o.has(l<<16|a)){r[0].push(a,l,n),r[1].push(l,a,n),i[0].push(Ia),i[1].push(Ia);for(let t=0;t<3;t++)s[n*6+t]+=e.v[a*6+t];c++}}for(let e=0;e<3;e++)s[n*6+e]/=c;s[n*6+4]=1;let l=new Uint8Array([...e.j,$a[t],$a[t]]),u=new Float32Array([...e.w,0]);return r.map((e,t)=>({v:s,j:l,w:u,t:new Uint16Array(e),c:new Uint8Array(i[t])}))},to=[],no=(e,t)=>to[e*8+t]??=eo(Qa(e),t),ro=rr(tr()).pos,io=new Float64Array(Zn*8),Q=/* @__PURE__ */ new Float64Array(8),ao=/* @__PURE__ */ new Float32Array,oo=(e,t,{pos:n,rot:r},i)=>{for(let e=0;e<Zn;e++){let t=J(r[e],ro[e]);io.set(r[e],e*8),io.set(K([(n[e][0]-t[0])/2,(n[e][1]-t[1])/2,(n[e][2]-t[2])/2,0],r[e]),e*8+4)}let a=t.w.length;ao.length<a*6&&(ao=new Float32Array(a*6));for(let e=0;e<a;e++){let[n,r,i,a]=[t.j[e*2]*8,t.j[e*2+1]*8,t.w[e],e*6],o=io[n]*io[r]+io[n+1]*io[r+1]+io[n+2]*io[r+2]+io[n+3]*io[r+3]<0?-i:i;for(let e=0;e<8;e++)Q[e]=(1-i)*io[n+e]+o*io[r+e];let s=Math.hypot(Q[0],Q[1],Q[2],Q[3]);for(let e=0;e<8;e++)Q[e]/=s;let c=[Q[3]*Q[4]-Q[7]*Q[0]-(Q[5]*Q[2]-Q[6]*Q[1]),Q[3]*Q[5]-Q[7]*Q[1]-(Q[6]*Q[0]-Q[4]*Q[2]),Q[3]*Q[6]-Q[7]*Q[2]-(Q[4]*Q[1]-Q[5]*Q[0])];for(let e of[a,a+3]){let[n,r,i]=[t.v[e],t.v[e+1],t.v[e+2]],[o,s,l]=[Q[1]*i-Q[2]*r,Q[2]*n-Q[0]*i,Q[0]*r-Q[1]*n],u=e==a?2:0;ao[e]=n+2*(Q[3]*o+Q[1]*l-Q[2]*s)+u*c[0],ao[e+1]=r+2*(Q[3]*s+Q[2]*o-Q[0]*l)+u*c[1],ao[e+2]=i+2*(Q[3]*l+Q[0]*s-Q[1]*o)+u*c[2]}}for(let n=0;n<t.t.length;n+=3){let[r,a,o]=i[t.c[n/3]],s=t.c[n/3]==Ia?-2:-1;for(let i=n;i<n+3;i++){let n=t.t[i]*6;e.push(ao[n],ao[n+1],ao[n+2],ao[n+3],ao[n+4],ao[n+5],r,a,s,o)}}},so=.15,co=24,lo=[.5,1.9,2.3],uo=()=>{let e=[],t=!1;return{mark(n,r,i){i&&(e.push({a:r.map((e,t)=>e+(n[t]-e)/3),b:r,age:0,start:!t}),e.length>co&&e.shift()),t=i},update(t){for(e.forEach(e=>e.age+=t);e[0]&&e[0].age>=.15;)e.shift()},draw(t){e.forEach((n,r)=>{let i=e[r-1];if(!i||n.start)return;let[a,o]=[i,n].map(e=>1-e.age/so),s=(e,t)=>e.b.map((n,r)=>n+(e.a[r]-n)*t),c=lo.map(e=>e*(.4+.6*(a+o)*.5)),[l,u,d,f]=[i.b,n.b,s(n,o),s(i,a)];for(let e of[l,u,d,l,d,f])t.push(...e,0,1,0,c[0],c[1],-2,c[2])})},get count(){return e.length}}},fo=1,[po,mo]=[.12,.03],[ho,go,_o]=[[1,0,0],[0,1,0],[0,0,1]],vo=[.7,-1,-.5],yo=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),bo=([e,t,n,r])=>[-e,-t,-n,r],xo=(e,t)=>Math.hypot(...U(e,t)),$=(e,t,n)=>Yt(e,Zt([0,0,0],t,n)),So=(e,t)=>{let[n,r]=[W(e),W(t)],i=[n[1]*r[2]-n[2]*r[1],n[2]*r[0]-n[0]*r[2],n[0]*r[1]-n[1]*r[0],1+Xt(n,r)],a=Math.hypot(...i)||1;return i.map(e=>e/a)},Co=(e,t,n,r,i)=>{let a=U(t,e),o=W(a),s=Math.max(Math.min(Math.hypot(...a),(r+i)*.99),.15),c=(r*r-i*i+s*s)/(2*s),l=Math.sqrt(Math.max(r*r-c*c,0)),u=W(U(n,Zt([0,0,0],o,Xt(n,o))));return[$($(e,o,c),u,l),$(e,o,s)]},wo=(e,t,n,r,i,a=!1)=>{let[o,s,c]=[t.pos[n],t.pos[n+1],t.pos[n+2]],[l,u]=Co(o,r,i,xo(o,s),xo(s,c)),d=K(So(U(s,o),U(l,o)),t.rot[n]),f=K(So(U(c,s),U(u,l)),t.rot[n+1]);e.rot[n]=K(bo(t.rot[Qn[n]]),d),e.rot[n+1]=K(bo(d),f),a&&(e.rot[n+2]=K(bo(f),t.rot[n+2]))},To=(e,t)=>$(e,t,-Xt(e,t)),Eo=(e,t)=>{let n=2*Math.atan2(e[0]*t[0]+e[1]*t[1]+e[2]*t[2],e[3]);return n>Math.PI?n-2*Math.PI:n<-Math.PI?n+2*Math.PI:n},Do=(e,t,n)=>K(So(J(e,t),n),e),Oo=.3,[ko,Ao]=[.22,.17],[jo,Mo]=[.16,.3],No=(e,t,n,r)=>{let[i,a]=[Yt(e.pos[G.PELVIS],[0,-.25,0]),e.pos[G.NECK]];if(r[1]>a[1]+.05)return 0;let o=Zt(i,a,yo((r[1]-i[1])/(a[1]-i[1]))),[s,c]=[e=>e[0]*Math.cos(t)-e[2]*Math.sin(t),e=>-e[0]*Math.sin(t)-e[2]*Math.cos(t)],l=U(r,o),u=Math.abs(s(l))/ko,d=u<1&&r[1]>=i[1]?Ao*Math.sqrt(1-u*u):-1/0,f=a[1]-jo;if(u<Mo/ko&&r[1]<f&&n[1]>f){let e=c(U(n,o));d=Math.max(d,e+(Ao-e)*(n[1]-r[1])/(n[1]-f))}return Math.max(0,d-c(l))},Po=(e,t,n,r,i,a)=>{let o=n===G.ARM_L?-1:1,s=U(r,t.pos[n]),[c,l]=[yo((s[1]+.12)*1.6,0,.5),yo((Math.hypot(...s)-.4)*2.5,0,.45)];e.rot[n-1]=K(e.rot[n-1],K(q(go,o*l),q(_o,o*c)));let u=rr(e),d=u.pos[n],[f,p]=[xo(d,u.pos[n+1]),xo(u.pos[n+1],u.pos[n+2])],m=W(Yt(To(W(U(r,d)),i),$([0,0,0],W(To(a,i)),-.3))),h=Yt($([0,0,0],i,Vi),$([0,0,0],m,-Bi)),g=Yt($([0,0,0],i,Bi),$([0,0,0],m,Vi)),_=Bo(g,h),v=Cr(_,g),y=$($(r,g,-.078),_,n==G.ARM_L?-.022:.022),[b,x]=Co(d,y,Yt(U($(y,g,-p),d),a),f,p),[S,C]=[W(U(b,d)),W(U(x,b))],w=Bo(S,C),T=W(Math.hypot(...w)>.001?w:Bo(S,Zt([0,0,0],a,-1))),[E,D]=[W($n[n+1]),W($n[n+2])],O=Do(Cr(T,S),E,S),k=Do(Cr(T,C),D,C),A=K(k,q(D,Eo(K(bo(k),v),D)/2));e.rot[n]=K(bo(u.rot[Qn[n]]),O),e.rot[n+1]=K(bo(O),A),e.rot[n+2]=K(bo(A),v)},Fo=[[0,0],[1,0],[-1,0],[0,1],[0,-1]],Io=[1,1.1,1,.82],Lo=[[[.55,-.2,.8],[.2,-.75,.6]],[[.4,-.1,.9],[-.55,-.5,.65]]],Ro=6,zo=rr(tr()).pos[G.HAND_R],Bo=([e,t,n],[r,i,a])=>[t*a-n*i,n*r-e*a,e*i-t*r],Vo=(e,t,n,r)=>{let i=e.map(([e,n,r])=>n.some(Boolean)?Array.from({length:t},(i,a)=>{let[o,s]=[Math.sin(a*V/t),Math.cos(a*V/t)];return[0,1,2].map(t=>e[t]+n[t]*s+r[t]*o)}):[e]),a=(e,t,n)=>{let r=e[Math.min(Math.max(t,0),e.length-1)];return r[(n+r.length)%r.length]},o=i.map((n,o)=>n.map((s,c)=>{if(r!=null&&!o){let e=c*V/t;return W([Math.cos(e),Math.sin(e),r])}return n.length<2?W(U(n[0],e[o-1][0])):W(Bo(U(a(i,o,c+1),a(i,o,c-1)),U(a(i,o+1,c),a(i,o-1,c))))}));for(let e=1;e<i.length;e++)for(let r=0;r<t;r++){let[t,s,c,l]=[[e-1,r],[e-1,r+1],[e,r+1],[e,r]];for(let r of i[e].length>1?[[t,s,c],[t,c,l]]:[[t,s,c]])for(let[e,t]of r)n(a(i,e,t),a(o,e,t))}},Ho=(e,t,n,r,i,a)=>{let o=$(e,t,r),[s,c]=[$(o,t,-r/2),$(o,n,r/2)],l=(e,t,n)=>{let[r,a]=[W(t),W(Bo(t,ho))];return[e,Bo(a,r).map(e=>e*i*n),a.map(e=>e*i*n)]};return[l(e,a,1.03),l(s,t,1),l(Zt(o,Zt(s,c,.5),.5),U(c,s),.94),l(c,n,.9),l($(o,n,r-.001),n,.74),l($(o,n,r+.006),n,0)]},Uo=(e,t)=>{let n=-(t-1.5)*.08*(1-e),[r,i]=[.1+1.3*e,.2+3*e].map(e=>W([n,-Math.sin(e),Math.cos(e)]));return[r,i]},Wo=(e,t,n,r,i,a,o)=>{let s=([a,s,c],[l,u,d])=>e.push(...[0,1,2].map(e=>t[e]+i[e]*a+r[e]*s+n[e]*c),...[0,1,2].map(e=>i[e]*l+r[e]*u+n[e]*d),o[0],o[1],-1,o[2]),c=([e,t,n,r])=>[[0,t,e],[n,0,0],[0,r,0]];Vo([c([zo[1]-Ua[0],Ua[1]-zo[0],Ua[3],Ua[4]]),c([.025,0,.04,.021]),c([.06,-.002,.0425,.017]),c([.092,-.004,.0425,.0105]),c([.104,-.004,0,0])],Wa,s,.75);for(let e=0;e<4;e++){let[t,n]=Uo(a,e);Vo(Ho([.0315-.021*e,-.004,.092],t,n,.04*Io[e],.0105,W(Yt(t,[0,0,1]))),Ro,s)}let[l,u]=Lo.map(([e,t])=>W(Zt(e,t,a)));Vo(Ho([.029,-.01,.025],l,u,.037,.0118,l),Ro,s)},Go=(e,t)=>(n,i)=>{let a=le(e,[n,t+r,i],[0,-1,0],2*r);return a>0&&a<1?t+r-a:t},Ko={amp:8,sprint:6,air:12,rise:10,dash:14,plant:16,wall:10,slide:10,stun:14,gun:10,blade:10},qo=e=>{let t=Jr(),n,r={amp:0,sprint:0,air:0,rise:0,dash:0,plant:0,wall:0,slide:0,stun:0,gun:0,blade:0},[i,a,o,s]=[0,0,0,1.6],c=-1,l=uo(),u=[0,0,8],d=[0,0,0],f=0,p=0,m,h=[0,0],g=(a,o,u=0,d=1.6)=>{if(i=u,s=d,!a){n=void 0;return}t.update(a,o,e&&Go(e,a.y)),n={...a},f+=o,c=Ca(c,a,o),l.update(o);let h=a.mode==x.GROUND||a.mode==x.CROUCH||a.mode==x.WALLRUN,g=a.dash>50,_=a.mode==x.AIR&&!g,v={amp:h?yo(De(a)/9):0,sprint:+Oe(a),air:+_,rise:+(_&&a.vy>.5),dash:+g,plant:+(a.mode==x.HANG||a.mode==x.CLIMB),wall:+(a.mode==x.WALLRUN),slide:+(a.mode==x.SLIDE),stun:+(a.stun>0),gun:+(a.ammo>=0&&!a.down&&!a.wield),blade:+(!!a.wield&&!a.down)};for(let e of Object.keys(Ko))r[e]+=(v[e]-r[e])*(1-Math.exp(-o*Ko[e]));let[y,b]=Fo[a.wall];p+=(yo(y*Math.cos(a.yaw)-b*Math.sin(a.yaw),-1,1)-p)*(1-Math.exp(-o*10)),v.plant&&a.edge&&(m={x:a.x,y:a.edge,z:a.z,dx:y,dz:b})},_=()=>{let e=r.amp*(1+.5*r.sprint),[n,a]=[Math.sin(V*t.phase),Math.cos(V*t.phase)],o=[Math.min(.22,.18*s)+.012*e*n+d[0],-.25+.018*e*a-.3*(1-r.gun)+d[1],.4-.05*i+d[2]];return[o,Mi(o,[u[0],u[1]+.1*i*Math.hypot(...u),u[2]],ho,go)]},v=()=>{let e=r.amp*(1+.5*r.sprint),[i,a]=[Math.sin(V*t.phase),Math.cos(V*t.phase)],o=_a(n?.cut??0,Math.max(c,0));return{at:[o[0]+.012*e*i,o[1]+.018*e*a-.35*(1-r.blade),o[2]],g:W([o[3],o[4],o[5]])}},y=(e,i,s,l=0)=>{if(!n||n.down||xo(e,[n.x,n.y+Ee(n),n.z])>fo)return;let u=t.pose(),g={at:[...u.at],yaw:u.yaw,hips:[...u.hips],rot:u.rot.map(e=>[...e])},[y,b,x]=Qt(i,s,l),S=([e,t,n])=>[y[0]*e+b[0]*t+x[0]*n,y[1]*e+b[1]*t+x[1]*n,y[2]*e+b[2]*t+x[2]*n],C=e=>[Xt(e,y),Xt(e,b),Xt(e,x)],w=r.blade>.002?v():void 0,[T,E,D]=w&&c>=0?xa(n.cut??0,c).map(e=>e*r.blade):[0,0,0];g.yaw+=w&&c>=0?ma(n.cut??0,c)*r.blade+Sa*T:0;let[O,k,A]=Qt(i+Oo*T,Math.max(s,-la),l),j=([e,t,n])=>[O[0]*e+k[0]*t+A[0]*n,O[1]*e+k[1]*t+A[1]*n,O[2]*e+k[2]*t+A[2]*n];for(let[e,t]of[[G.SPINE,.4],[G.CHEST,.6]])g.rot[e]=K(g.rot[e],K(K(q(go,T*t),q(ho,.12*yo(s,-1.3,1.3)-E*t)),q(_o,D*t)));let ee=rr(g),M=[-Math.sin(i),0,-Math.cos(i)],te=Yt(ee.pos[G.HEAD],J(ee.rot[G.HEAD],[0,.02,-.08]));g.at=Yt(g.at,U(e,$(te,[-M[0]*po,-mo,-M[2]*po],r.plant)));let N=rr(g),P=[-Math.sin(g.yaw),0,-Math.cos(g.yaw)];for(let e of[G.THIGH_L,G.THIGH_R])wo(g,N,e,ee.pos[e+2],P,!0);let F=(t,n=S)=>$([0,0,0],P,Math.max(...t.map(t=>No(N,g.yaw,e,Yt(e,n(t))))));d=[0,0,0];let[I,L]=_(),R=([e,t,n])=>[0,1,2].map(r=>I[r]+L[0][r]*e+L[1][r]*t-L[2][r]*n);d=C(F([I,R(si),R([0,.156,.04])]));let ne=w?F([w.at,$(w.at,w.g,-zi),$(w.at,w.g,Fi)],j):d,[re,ie]=_(),ae=[0,1,2].map(e=>li[1]*ie[2][e]-li[0]*ie[1][e]),oe=[0,1,2].map(e=>re[e]-.078*ae[e]+.022*ie[0][e]);for(let n of[-1,1]){let i=Math.cos(V*t.phase)*n,s=yo(r.amp*1.8)+.2*r.sprint,c=[.24-.05*s,-.66+.46*s*((i+1)/2)**1.2,.1+.26*s*i];c=Zt(c,[.38,-.2,.34],r.air),c=Zt(c,[.3,.02,.45],r.rise),c=Zt(c,[.14,-.1,.5],r.dash);let l=r.wall*yo(p*n);c=Zt(c,[.42,-.16,.42],l),c=Zt(c,n>0?[.36,-.26,.38]:[.28,-.1,.42],r.slide);let u=Math.sin(f*12+(n>0?Math.PI:0));if(c=Zt(c,[.46,.05+.2*u,.4+.1*u],r.stun),m){let[t,i]=[-m.dz,m.dx];Xt([t,0,i],y)<0&&([t,i]=[-t,-i]);let a=.35000000000000003,[o,s,l]=C(U([m.x+m.dx*a+t*.12*n,m.y+.03,m.z+m.dz*a+i*.12*n],e));c=Zt(c,[o*n,Math.max(s,-.28),Math.max(l,.4)],r.plant)}let d=1-yo(r.plant+l+r.stun),_=w?r.blade*d:0,v=_;n>0&&(a=r.gun*d,c=Zt(c,oe,a),o=_,v=Math.max(a,o));let b=.75+.25*r.sprint;for(let[e,t]of[[.25,r.air],[.1,r.rise],[1,r.dash],[.1,l],[.1,r.slide],[.1,r.plant],[.2,r.stun]])b+=(e-b)*t;h[(n+1)/2]=b+(.9-b)*v;let x=Yt(e,S([c[0]*n,c[1],c[2]])),T=n<0?G.ARM_L:G.ARM_R;if(wo(g,N,T,x,S([vo[0]*n,vo[1],vo[2]])),g.rot[T+2]=q(go,n*(1+.5*(r.plant+r.slide))),n>0&&a>.002){let e=Cr(S(ie[0]),S(ae));g.rot[T+2]=nr(g.rot[T+2],K(bo(rr(g).rot[G.FOREARM_R]),e),a)}if(w&&_>.002){let t=j(w.g),r=$(Yt(Yt(e,j(w.at)),ne),t,n>0?0:-zi),i={...g,rot:g.rot.slice()};Po(i,N,T,r,t,j([.5*n,-1,-.35]));for(let e of[T-1,T,T+1,T+2])g.rot[e]=nr(g.rot[e],i.rot[e],_)}}return rr(g)};return{get id(){return n?.id??-1},update:g,pose:y,draw(e,t,r,i,s=0,u=[.7,.7,.7]){let d=y(t,r,i,s);if(d){let t=za(u);oo(e,Qa(2),d,t),[G.HAND_L,G.HAND_R].forEach((n,r)=>{let i=d.rot[n];Wo(e,d.pos[n],J(i,[0,-1,0]),J(i,[r*2-1,0,0]),J(i,[0,0,-1]),h[r],t[7])}),a>.2&&ki(e,d.pos[G.HAND_R],d.rot[G.HAND_R],1,yo(a*1.5-.5),n?.ammo),o>.2&&sa(e,d.pos[G.HAND_R],d.rot[G.HAND_R],1,f,yo(o*1.5-.5));let[r,i]=ca(d.pos[G.HAND_R],d.rot[G.HAND_R]);l.mark(r,i,o>.5&&wa(c)),l.draw(e)}},aim(e){let t=Math.hypot(...e);u=t<3?t?e.map(e=>e*3/t):[0,0,3]:e},muzzle:()=>Ai(..._()),spun:()=>n&&c>=0?ma(n.cut??0,c)+Sa*xa(n.cut??0,c)[0]*r.blade:0}},Jo=(e,t,n,r,i,a)=>{let o=Qt(r,i)[2],s=le(e,t,o,80),c=[0,1,2].map(e=>t[e]+o[e]*s);return{end:c,hit:s<80,local:Qt(r,a).map(e=>(c[0]-n[0])*e[0]+(c[1]-n[1])*e[1]+(c[2]-n[2])*e[2])}},Yo=(e,t)=>e&&t?t.shots-e.shots&255:0,Xo=(e,t)=>e&&t&&(t.swing??0)>0&&((t.swing??0)>(e.swing??0)||(t.cut??0)!=(e.cut??0))?t.cut??0:-1,Zo=(e,t)=>{let{ticks:n,strike:r}=h[t?.cut??0];return!!e&&!!t&&(e.swing??0)>n-r&&(t.swing??0)<=n-r},Qo={rate:[1.3,1.05,.95,.8],gain:[.6,.8,.8,1]},$o=(e,t,r,i,a,o,s)=>{let c=[],l,u=!1,d=0,f=/* @__PURE__ */ new Map,m=/* @__PURE__ */ new Map,h=[],g=()=>.94+.12*(d++*.618%1),_=e=>t.play(H.LASER,e,e?.7:.5,g()),y=t=>Ai(...Pi(t,Ni(t,e)[0])),b=(e,n)=>t.play(H.SWISH,n,Qo.gain[e],Qo.rate[e]),x=(e,n,r)=>!!e.wield!=!!n.wield&&(n.wield||n.blade)&&t.play(H.SHING,r,.6,n.wield?1:.85);return{step(e,t){let r=Yo(e,t);r&&t&&c.push({...t});for(let e=0;e<r;e++)o.pitch=Math.min(n,o.pitch+p),i.fire();let a=Xo(e,t);a>=0&&h.push(a),t&&Zo(e,t)&&i.cut(t.cut??0)},frame(e,n,o,d,p,g=0){if(a.update(p),n){let e=l;e&&n.hits!=e.hits&&(t.play(H.HIT),r.hit(),n.wield&&t.play(H.ZAP)),e&&x(e,n),e&&n.hp<e.hp?(t.play(n.down&&!e.down?H.DOWN:H.HURT),i.wound()):e&&n.hp>e.hp&&!e.down&&t.play(H.PACK),e&&(e.ammo<0||n.ammo>e.ammo)&&n.ammo>=0&&t.play(H.GUN);let a=!!(d&v.FIRE);a&&!u&&n.ammo==0&&!n.down&&t.play(H.DRY),u=a,r.vitals(n.hp,n.ammo,!!n.blade,!!n.wield),h.forEach(e=>b(e)),r.down(i.lie,n.down/60),l={...n}}else l=void 0;let S;if(e){let[t,n,r]=Qt(e.yaw,e.drawn),i=e.muzzle;S=[0,1,2].map(a=>e.cam[a]+t[a]*i[0]+n[a]*i[1]+r[a]*i[2]),a.mount(S);for(let e of c)s.fire(e,g),a.flash(S,!0),_()}c=[],h=[];for(let e of o){let t=f.get(e.id),n=[e.x,e.y+Ee(e),e.z];t!==void 0&&e.shots!=t&&(a.flash(y(e)),_(n)),f.set(e.id,e.shots);let r=m.get(e.id),i=Xo(r,e);i>=0&&b(i,n),r&&x(r,e,n),m.set(e.id,{swing:e.swing,cut:e.cut,wield:e.wield,blade:e.blade}),e.zap&&e.stun>0&&a.crackle([e.x,e.y+1,e.z])}for(let e of f.keys())o.some(t=>t.id==e)||(f.delete(e),m.delete(e));let{orbs:C,bursts:w}=s.frame(g,e=>{let t=o.find(t=>t.id==e);return e==n?.id?S:t&&y(t)});a.orbs(C);for(let e of w)a.burst(e),t.play(H.SPLASH,e)}}},es=e=>.6+.2*e,ts=e=>e?.mode===x.GROUND||e?.mode===x.CROUCH,ns=e=>ts(e)||e?.mode===x.WALLRUN,rs=[[0,0],[1,0],[-1,0],[0,1],[0,-1]],is=e=>.02+.0025*e,as=.006,os=.03,ss=.14,cs=.05,ls=5,us=9,ds=6.5,fs=.25,ps=.22,ms=.9,hs=4,gs=1,_s=.12,vs=24,ys=15.7,bs=.45,xs=[-8,4,5],Ss=3,Cs=[-1,1.2],ws=4,Ts=[-.25,.4,.5],Es=[-.5,1.5,1.2],Ds=[-1.5,.8,1.5],Os=[.9,.3],ks=[.1,.05,11],As=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),js=(e,t)=>{let n=Math.ceil(t*120);for(let r=0;r<n;r++)e[1]+=(-15.7*ys*e[0]-2*bs*ys*e[1])*(t/n),e[0]+=e[1]*(t/n)},Ms=()=>{let e=0,t=0,n=0,r=0,i=0,a=0,o=0,s=0,c,l,u=[0,0],d=[0,0],f=[0,0],p={dy:0,pitch:0,roll:0,fov:0,lines:0,stride:0,hurt:0,kick:0,lie:0,fire(){s++,u[1]+=Ts[0],d[1]+=Ts[1],f[1]+=Ts[2]*Math.sin(s*2.4),p.kick=1},wound(){u[1]+=Ds[0],d[1]+=Ds[1],f[1]+=Ds[2]*Math.sin(s++),p.hurt=1},jolt(){u[1]+=xs[0],d[1]+=xs[1],f[1]+=xs[2],p.hurt=1},punch(){u[1]+=Cs[0],d[1]+=Cs[1],a=1},cut(e){u[1]+=Es[0],d[1]-=e==y.SLASH?Es[1]:0,f[1]+=e==y.LEFT?Es[2]:e==y.RIGHT?-Es[2]:0,a=e==y.THRUST?1:a},update(s,m,h,g={ev:0,fall:0}){let _=e=>Math.min(1,h*e),y=s?De(s):0,b=s&&l&&ns(s)&&ns(l)?Math.hypot(s.x-l.x,s.z-l.z):0;b<1&&(p.stride+=b/es(y)),e+=((ts(s)&&b>.5*h&&b<1?1:0)-e)*_(10),l=s,g.ev&C.LAND&&(u[1]-=ps*Math.min(g.fall,20)),g.ev&C.CLIMB&&(u[1]-=ps*hs),g.ev&(C.JUMP|C.DOUBLE)&&(u[1]+=ms),g.ev&C.GRAB&&(d[1]-=gs),js(u,h),js(d,h),js(f,h),p.hurt*=Math.exp(-h*Ss),a*=Math.exp(-h*10),p.kick*=Math.exp(-h*22),p.lie+=(+!!s?.down-p.lie)*_(5),o+=h*ks[2];let S=s?Math.min(1,s.stun/48):0,w=s?Ee(s):0;c=s?c===void 0?w:c+(w-c)*_(14):void 0,p.dy=(c??0)-w+u[0]-Math.cos(p.stride*2*Math.PI)*is(y)*e-p.lie*(w-Os[1]),i+=((s?.mode===x.CLIMB?_s*Math.sin(Math.PI*As(s.t/vs)):0)-i)*_(10),p.pitch=d[0]+i+Math.sin(o*.8)*ks[1]*S;let T=s?.mode===x.WALLRUN?rs[s.wall]:[0,0],E=s?T[0]*Math.cos(s.yaw)-T[1]*Math.sin(s.yaw):0,D=+!!(m&v.RIGHT)-!!(m&v.LEFT);t+=(D*os+E*ss+(s?.mode===x.SLIDE?cs:0)-t)*_(8),p.roll=t+Math.sin(p.stride*Math.PI)*as*e+f[0]+Math.sin(o)*ks[0]*S+p.lie*Os[0];let O=!!s&&s.dash>50;n+=(+O-n)*_(O?40:6),r+=(As((y-6)/3)-r)*_(4),p.fov=r*ls+n*us+a*ws,p.lines+=(As((y-ds)/(9-ds))*fs+n*.75-p.lines)*_(8)}};return p},Ns=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Ps=e=>{let t=e.loop(H.WIND),n=e.loop(H.SCRAPE),r=0,i=/* @__PURE__ */ new Map,a=(t,n,r)=>{let i=Oe(t);e.play(t.mode===x.WALLRUN?H.WALLSTEP:H.STEP,r,i||t.mode===x.WALLRUN?1:t.mode===x.CROUCH?.35:.6,(i?.92:1)*(n&1?1.06:.94))},o=(t,n)=>e.play(H.LAND,n,Ns(t/14,.2),1.25-.5*Ns(t/20));return{me(i,s,c){let l=Math.floor(c),u=l>r;if(r=l,!i||e.muted)return;u&&a(i,l);for(let[t,n]of[[C.JUMP,H.JUMP],[C.DOUBLE,H.DOUBLE],[C.DASH,H.DASH],[C.GRAB,H.GRAB],[C.CLIMB,H.SCUFF]])s.ev&t&&e.play(n);s.ev&C.LAND&&o(s.fall);let d=Ns((Math.hypot(i.vx,i.vy,i.vz)-4)/12);t.set(.55*d**1.5,.6+.9*d);let f=Ns(De(i)/9);n.set(i.mode===x.SLIDE?.2+.5*f:0,.8+.4*f)},others(t){for(let n of t){let t=i.get(n.id);if(t&&!e.muted){let e=[n.x,n.y+.1,n.z],r=Math.hypot(n.x-t.p.x,n.z-t.p.z);if(ns(n)&&ns(t.p)&&r<1){let i=Math.floor(t.stride);t.stride+=r/es(De(n)),Math.floor(t.stride)>i&&a(n,i,e)}n.ground&&!t.p.ground&&t.p.vy<-3&&o(-t.p.vy,e)}i.set(n.id,{p:n,stride:t?.stride??0})}for(let e of i.keys())t.some(t=>t.id===e)||i.delete(e)}}},Fs=`h5,aside,nav,output,section,em,u,ul,dl,s,mark{position:absolute;margin:0;padding:0;pointer-events:none;user-select:none;white-space:pre-line}h5{top:8px;right:12px;font-size:12px}u{inset:0;opacity:0;background:radial-gradient(ellipse at center,#0000 35%,#d10000dd 120%)}nav{top:8px;left:50%;transform:translateX(-50%);display:grid;grid-template-columns:1fr auto 1fr;gap:2px 16px;align-items:center;text-align:center;font-size:13px}nav span,nav time{font:900 clamp(16px,4.6vw,24px)/1 system-ui,sans-serif;letter-spacing:.03em;white-space:nowrap}nav time{min-width:4.2ch;font-variant-numeric:tabular-nums;font-size:clamp(14px,3.8vw,20px)}nav small{font-size:clamp(10px,2.6vw,12px);white-space:nowrap;opacity:.95}nav small:first-of-type{text-align:right}nav small:last-of-type{text-align:left}output{top:20%;left:50%;transform:translateX(-50%);padding:6px 18px;font:900 clamp(18px,3.4vw,30px)/1.1 system-ui,sans-serif;letter-spacing:.06em;text-transform:uppercase;white-space:nowrap;background:#000a;border-bottom:3px solid currentColor}em{font-style:normal;font-size:13px;font-weight:800;line-height:1.1;text-align:center;transform:translate(-50%,-50%)}em span{display:block;font-size:20px;line-height:1}section{inset:0;z-index:2;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:0 12px;text-align:center;background:#000c}section h6{font:900 clamp(30px,9vw,72px)/1 system-ui,sans-serif;letter-spacing:.04em}section strong{font-size:34px}section td:first-child{text-align:left;opacity:1}section td+td{text-align:center}section th{padding:2px 10px;font-size:12px;opacity:.7;font-weight:600}aside{inset:0;z-index:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;padding:0 12px;text-align:center;background:#000b}h6{margin:0;font-size:inherit;text-shadow:none}aside h6{font:900 clamp(36px,13vw,84px)/1 system-ui,sans-serif;letter-spacing:.04em;transform:skewX(-8deg);background:linear-gradient(#fe6,#f92 45%,#d21);-webkit-background-clip:text;background-clip:text;color:transparent;filter:drop-shadow(0 3px 0 #500) drop-shadow(0 0 14px #f604)}ul{left:12px;bottom:30px;display:flex;gap:4px;list-style:none}li{width:16px;height:6px;background:#fff;box-shadow:0 0 0 1px #0008}li.e{background:#0000;box-shadow:inset 0 0 0 1px #fffb,0 0 0 1px #0008}ul.low li{background:#f55}ul.low li.e{background:#0000}dl{left:50%;bottom:10px;transform:translateX(-50%);display:flex;align-items:center;gap:10px}dl svg{width:38px;fill:#fff;filter:drop-shadow(0 1px 1px #000)}dl.k svg:first-child,dl:not(.k) svg+svg,dl.k data{display:none}dl.k svg{width:64px;fill:#8ef}dl small{position:absolute;bottom:100%;left:50%;transform:translateX(-50%);display:flex;gap:10px;font-size:11px;white-space:nowrap}dl kbd{font:inherit;opacity:.5}dl kbd.a{opacity:1}@media(max-width:520px){dl{left:auto;right:12px;bottom:46px;transform:none}dl small{left:auto;right:0;transform:none}}dl data{font:900 clamp(30px,5vw,46px)/1 system-ui,sans-serif;font-variant-numeric:tabular-nums}dl.e data{color:#f66}s{left:50%;top:50%;width:28px;height:28px;margin:-14px 0 0 -14px;background:linear-gradient(45deg,#0000 44%,#fff 44% 56%,#0000 56%),linear-gradient(-45deg,#0000 44%,#fff 44% 56%,#0000 56%);-webkit-mask:radial-gradient(#0000 6px,#000 7px);mask:radial-gradient(#0000 6px,#000 7px)}mark{inset:0;z-index:1;padding-top:30vh;text-align:center;color:#ddd;background:radial-gradient(ellipse at center,#6668 0%,#4a0c0ce8 130%);backdrop-filter:grayscale(1)}mark::first-line{font:900 clamp(30px,8vw,64px)/1 system-ui,sans-serif;letter-spacing:.24em}strong{font-size:22px}table{border-collapse:collapse;font-size:16px}td{padding:2px 10px}td+td{text-align:left}td:first-child{text-align:right;opacity:.7}`,Is=2800,Ls=e=>`${Math.floor(e/60)}:${`${e%60}`.padStart(2,`0`)}`,Rs=e=>{e.insertAdjacentHTML(`beforeend`,`<aside hidden><h6>TINY FPS</h6><span></span><table><tr><td>Mouse<td>look<tr><td>WASD / ZQSD<td>move<tr><td>Shift<td>sprint<tr><td>Space<td>jump, again in the air<tr><td>Move key twice<td>dash that way<tr><td>C<td>crouch, slide when fast<tr><td>Left click<td>fire the gun<tr><td>1, 2, wheel<td>gun, katana<tr><td>Katana + W<td>thrust<tr><td>Katana + A or D<td>cut across<tr><td>Katana alone<td>slash<tr><td>Double click<td>special: lunge, spin, leap<tr><td>M<td>mute</table><span>Take the enemy flag to your own base while yours is home. Jump onto the armoury past your flag for the gun and the katana.</span><strong></strong></aside><u></u><h5 hidden>Muted (M)</h5><ul>${`<li></li>`.repeat(5)}</ul><dl hidden><svg viewBox="0 0 38 22"><path d="M1 7c3-5 13-7 22-4l7 3 3 1v4l-6 1-4 2-1 1-3 6h-5l2-7-5-1c-6-1-12-3-10-6z"/></svg><svg viewBox="0 0 38 22"><path d="M12 14.4C19 11.6 29 6.4 37 1c-3.6 7-14.4 13.4-24.4 16zM1 20.2l7-6.6 1.6 1.8-7 6.6zM7.6 12.4l3.2-1.4 2 4.6-3.2 1.4z"/></svg><data></data><small hidden><kbd>1 gun</kbd><kbd>2 katana</kbd></small></dl><s hidden></s><mark hidden></mark><nav hidden><span></span><time></time><span></span><small></small><small></small></nav><output hidden></output><section hidden><h6></h6><strong></strong><table></table><span></span></section>`);let t=t=>e.querySelector(t),[n,r]=[`h5`,`aside`].map(e=>t(e)),[i,a]=[`aside span`,`aside strong`].map(e=>t(e)),o=(e,t)=>e.textContent!=t&&(e.textContent=t),s=t(`nav`),[c,d,f]=[...s.querySelectorAll(`span, time`)],[p,m]=[...s.querySelectorAll(`small`)],h=[...e.querySelectorAll(`li`)],[g,v,y,b]=[t(`ul`),t(`dl`),t(`s`),t(`mark`)],[x,S]=[t(`data`),t(`dl small`)],C,w=t(`output`),T=t(`u`),E=t(`section`),[D,O,k]=[`h6`,`strong`,`span`].map(e=>E.querySelector(e)),A=E.querySelector(`table`),j=[],ee,M,te=(e,t)=>e.style.color=u[t];return[c,p].forEach(e=>te(e,0)),[f,m].forEach(e=>te(e,1)),{title(e,t){r.hidden=!e,o(i,t),o(a,e)},mute:e=>n.hidden=!e,match(e,t){s.hidden=!1,o(c,`${l[0].toUpperCase()} ${e.score[0]}`),o(f,`${e.score[1]} ${l[1].toUpperCase()}`),o(d,e.over?`END`:Ls(e.clock)),e.flags.forEach((e,n)=>{let r=e.state===_.CARRIED?`taken by ${t(e.by)}`:e.state===_.DROPPED?`dropped ${e.left}s`:`home`;o(n?m:p,`${l[n]} flag: ${r}`)})},marks(t){for(;j.length<t.length;){let t=document.createElement(`em`);t.innerHTML=`<span></span><small></small>`,j.push(t),e.append(t)}j.splice(t.length).forEach(e=>e.remove()),t.forEach((e,t)=>{let n=j[t];n.style.left=`${e.x*100}%`,n.style.top=`${e.y*100}%`,te(n,e.team);let[r,i]=[n.children[0],n.children[1]];r.style.transform=e.arrow===void 0?``:`rotate(${e.arrow}rad)`,o(r,e.arrow===void 0?`▼`:`▲`),o(i,`${e.kind===`base`?`Base `:``}${e.text}`)})},hurt(e){let t=e<.01?``:`${Math.min(1,e)}`;T.style.opacity!=t&&(T.style.opacity=t)},vitals(e,t,n=!1,r=!1){h.forEach((t,n)=>t.classList.toggle(`e`,n>=e)),g.classList.toggle(`low`,e<=1);let i=t>=0,a=n&&(r||!i);v.hidden=!i&&!n,v.classList.toggle(`k`,a),v.classList.toggle(`e`,!a&&!t),o(x,`${Math.max(t,0)}`),S.hidden=!(i&&n),[...S.children].forEach((e,t)=>e.classList.toggle(`a`,!!t==a))},hit(){y.hidden=!1,clearTimeout(C),C=setTimeout(()=>y.hidden=!0,140)},down(e,t){b.hidden=e<.02,b.style.opacity=`${Math.min(e,1)}`,o(b,b.hidden?``:`DOWN\nBack in ${t.toFixed(1)}`)},banner(e,t){w.hidden=!1,o(w,e),w.style.color=t===void 0?`#fff`:u[t],clearTimeout(ee),ee=setTimeout(()=>w.hidden=!0,Is)},end(e,t){if(E.hidden=!e,!e)M=void 0;else{if(M!==e){M=e;let[t,n]=e.score,r=t>n?0:n>t?1:-1;o(D,r<0?`DRAW`:`${l[r].toUpperCase()} WINS`),D.style.color=r<0?`#fff`:u[r],o(O,`${t} – ${n}`);let i=[...e.players].sort((e,t)=>t.caps-e.caps||t.returns-e.returns||e.id-t.id);A.replaceChildren(),A.insertAdjacentHTML(`beforeend`,`<tr><th>Player<th>Captures<th>Returns</tr>`);for(let e of i){let t=A.insertRow();[e.name,e.caps,e.returns].forEach(e=>t.insertCell().textContent=`${e}`),t.style.color=u[e.team]}}o(k,`Next match in ${t}`)}}}},zs=.0025,Bs=Math.PI*2,Vs={KeyW:v.FORWARD,ArrowUp:v.FORWARD,KeyS:v.BACK,ArrowDown:v.BACK,KeyA:v.LEFT,ArrowLeft:v.LEFT,KeyD:v.RIGHT,ArrowRight:v.RIGHT,Space:v.JUMP,ShiftLeft:v.SPRINT,ShiftRight:v.SPRINT,KeyC:v.CROUCH},Hs=v.FORWARD|v.BACK|v.LEFT|v.RIGHT,Us=(e,t)=>e&~Hs|t|v.DASH,Ws=e=>Vs[e]??0,Gs=(e,t)=>t==`Digit1`?!1:t==`Digit2`||e,Ks=(e,t,n)=>!n||!n.blade&&n.ammo<0?!1:n.blade&&t&&!t.blade?!0:e,qs=(e,t)=>t?e|v.BLADE:e,Js=(e,t=()=>{})=>{let r=new AbortController,i=(e,t,n,i={})=>e.addEventListener(t,n,{signal:r.signal,...i}),a=/* @__PURE__ */ new Set,o=/* @__PURE__ */ new Map,s=0,c=-1/0,l=-1/0,u=!1,d={yaw:0,pitch:0,keys:0,blade:!1,take(){let e=(s?Us(d.keys,s):d.keys)|(u?v.FIRE|v.SPECIAL:0);return s=0,u=!1,qs(e,d.blade)},track:(e,t)=>void(d.blade=Ks(d.blade,e,t)),locked:()=>e.getRootNode().pointerLockElement==e,destroy:()=>r.abort()};i(e,`click`,()=>{Promise.resolve(e.requestPointerLock()).catch(()=>{})}),i(document,`mousemove`,e=>{d.locked()&&(d.yaw=((d.yaw-e.movementX*zs)%Bs+Bs)%Bs,d.pitch=Math.max(-1.55,Math.min(n,d.pitch-e.movementY*zs)))}),i(document,`mousedown`,e=>{if(d.locked()&&!e.button){d.keys|=v.FIRE;let e=performance.now();u||=e-l<=300,l=u?-1/0:e}}),i(document,`mouseup`,e=>{e.button||(d.keys&=~v.FIRE)}),i(document,`wheel`,e=>{let t=performance.now();d.locked()&&e.deltaY&&(e.preventDefault(),t-c>=250&&(c=t,d.blade=!d.blade))},{passive:!1}),i(document,`keydown`,e=>{let n=Ws(e.code);if(d.locked()&&(d.blade=Gs(d.blade,e.code)),e.code==`KeyM`&&!e.repeat&&d.locked()&&t(),n&&d.locked()){if(n&Hs&&!e.repeat&&!a.has(e.code)){let t=performance.now(),r=o.get(e.code);r!==void 0&&t-r<=250?(s=n,o.delete(e.code)):o.set(e.code,t)}a.add(e.code),d.keys|=n,e.preventDefault()}}),i(document,`keyup`,e=>{a.delete(e.code),d.keys&=~Ws(e.code)});let f=()=>{d.keys=s=0,a.clear(),o.clear()};return i(window,`blur`,f),i(document,`pointerlockchange`,()=>d.locked()||f()),d},Ys=e=>{let[t,n]=[e&v.LEFT,e&v.RIGHT];return t&&!n?y.LEFT:n&&!t?y.RIGHT:e&v.FORWARD?y.THRUST:y.SLASH},Xs=(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},Zs=e=>{if(e.mode===x.GROUND){if(e.cut===y.LUNGE){let[t,n]=he(e.yaw);e.vx=t*13,e.vz=n*13,e.dash=60,e.ev|=C.DASH}else e.cut===y.LEAP&&(e.vy=g,e.ev|=C.JUMP)}},Qs={NONE:0,SHOT:1,CUT:2},$s=(e,t,n,r,i=!0)=>{let a=e.down>0;if(tt(e,a?{...t,keys:0}:t,n,r),e.zap=!!e.stun&&!!e.zap,a)return e.down>0&&!--e.down&&Ce(e,n,r),Qs.NONE;let{rack:o,blade:s}=n.def.teams[r],c=!!o&&Xs(e,o,1.2);i&&c&&!e.rack&&(e.ammo=60),e.rack=c,e.blade=!!e.blade||i&&!!s&&Xs(e,s,1.2),e.cool=Math.max(0,e.cool-1),e.swing=Math.max(0,(e.swing??0)-1),e.wield=e.blade&&(e.swing>0||!!(t.keys&v.BLADE)||e.ammo<0);let l=e.mode===x.HANG||e.mode===x.CLIMB;if(!i)return Qs.NONE;let u=h[e.cut??0];if(e.swing&&u.ticks-e.swing===u.strike)return Qs.CUT;if(t.keys&v.FIRE&&!l){let n=h[e.cut??0].ticks-e.swing,r=!!(t.keys&v.SPECIAL)&&(!e.swing||(e.cut??0)<4&&n<=18);if(e.wield&&(!e.swing||r))e.cut=Ys(t.keys)+(r?4:0),e.swing=h[e.cut].ticks,Zs(e);else if(!e.wield&&!e.cool&&e.ammo>0)return e.ammo--,e.shots=e.shots+1&255,e.cool=7,Qs.SHOT}return Qs.NONE},ec=120,tc=16,nc=e=>{let t={...e};return delete t.ack,delete t.by,t},rc=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n,z:e.z+(t.z-e.z)*n}),ic=(e,t,n)=>me(e+(((t-e+Math.PI)%V+V)%V-Math.PI)*n),ac=(e,t)=>(t-e&65535)<32768,oc=(e,t,n)=>({...t,...rc(e,t,n),yaw:ic(e.yaw,t.yaw,n),pitch:e.pitch+(t.pitch-e.pitch)*n}),sc=e=>{let t,n=0,r=0,i=[],a,o,s=[],c=0,l=0,u=!0,d=e=>{let t=e-100,n=0;for(;n+1<s.length&&s[n+1].t<=t;)n++;let r=s[n],i=s[n+1]??r;return{a:r,b:i,u:i.t>r.t?Math.max(0,Math.min(1,(t-r.t)/(i.t-r.t))):0}},f=e=>{if(!s.length)return;let{a:t,b:n,u:r}=d(e);return(t.s.tick+(n.s.tick-t.s.tick&65535)*r)%65536};return{you:(e,r=0)=>{[t,n]=[e,r]},step:(t,s)=>{let d=mt({...t,seq:r,view:s===void 0?void 0:f(s)});return r=r+1&65535,i.push(d),i.length>ec&&i.shift(),a&&(o=nc(a),$s(a,d,e,n,u),c|=a.ev,l=Math.max(l,a.fall)),d},snapshot:(r,c)=>{s.push({t:c,s:r}),s.length>tc&&s.shift();let l=r.players.find(e=>e.id===t);l&&(u=!r.over,i=i.filter(e=>!ac(e.seq,l.ack)),a=nc(l),o=nc(a),i.forEach((t,r)=>{r===i.length-1&&(o=nc(a)),$s(a,t,e,n,u)}))},events:()=>{let e={ev:c,fall:l};return c=l=0,e},me:e=>a&&o?oc(o,a,Math.max(0,Math.min(1,e))):void 0,others:e=>{let n=s.at(-1);if(!n)return[];let{a:r,b:i,u:a}=d(e);return n.s.players.filter(e=>e.id!==t).map(e=>{let t=r.s.players.find(t=>t.id===e.id),n=i.s.players.find(t=>t.id===e.id);return t&&n?oc(nc(t),nc(n),a):nc(n??t??e)})}}},cc={x0:.05,x1:.95,y0:.15,y1:.92},lc=(e,t,n,r,i)=>{let[a,o]=[r-e,i-t];return Math.atan2(a*Math.cos(n)-o*Math.sin(n),-a*Math.sin(n)-o*Math.cos(n))},uc=e=>{let[t,n]=[Math.sin(e),-Math.cos(e)],[r,i]=[(cc.x0+cc.x1)/2,(cc.y0+cc.y1)/2],[a,o]=[(cc.x1-cc.x0)/2,(cc.y1-cc.y0)/2],s=Math.min(a/(Math.abs(t)||1e-9),o/(Math.abs(n)||1e-9));return[r+t*s,i+n*s]},dc=2.6,fc=e=>{let t=[],n=(n,r,[i,a,o])=>{let s=Math.round(Math.hypot(i-e.eye[0],a+dc-e.eye[1],o-e.eye[2])),c=e.project(i,a+dc,o),l=c&&c[0]>=cc.x0&&c[0]<=cc.x1&&c[1]>=cc.y0&&c[1]<=cc.y1,u=`${s} m`;if(l)t.push({team:n,kind:r,x:c[0],y:c[1],text:u});else{let a=lc(e.eye[0],e.eye[2],e.yaw,i,o),[s,c]=uc(a);t.push({team:n,kind:r,x:s,y:c,arrow:a,text:u})}},r=e.flags.some(t=>t.state===_.CARRIED&&t.by===e.id);return e.flags.forEach((t,i)=>{if(t.state===_.CARRIED&&t.by===e.id){n(e.team,`base`,e.bases[e.team]);return}if(r&&i===e.team&&t.state===_.HOME)return;let a=t.state===_.HOME?e.bases[i]:t.state===_.DROPPED?[t.x,t.y,t.z]:e.where(t.by);a&&n(i,`flag`,a)}),t},pc=(e=[],t=0,n=0)=>e.filter((e,r)=>n+r<32&&t>>>n+r&1),mc=(e,t,n,r,i=!1)=>{let a=n.map(e=>e*.45);cn(e,an(1,1,[1,1],[0,0]),t,[t[0],t[1]+.72,t[2]],[1,0,0],1,.06,a);let[o,s,c]=t;on(e,an(1,0,[1,1]),[o,s+.74,c],Qt(0,0),[0,0,0],[.3,.035,.3],n);let l=e.length;xn(e,[o,s+.045,c],m-.07,m,n),yn(e,l,1.2*pn*(.7+.3*Math.sin(r*2.5)));let u=[o,s+1.05+.04*Math.sin(r*2),c],d=Qt(r*.8,0);i?aa(e,u.map((e,t)=>e-d[2][t]*.42),d,0,r):on(e,pi(0),u,d,[0,0,0],1.5)},hc=(e,t=[],n=[],r=0)=>{t.forEach((t,n)=>t&&mc(e,t,gn(n),r)),n.forEach((t,n)=>t&&mc(e,t,gn(n),r,!0))},gc=[[[1,0,0],[0,1,0],[0,0,1]],[[-1,0,0],[0,0,1],[0,1,0]],[[0,1,0],[0,0,1],[1,0,0]],[[0,-1,0],[1,0,0],[0,0,1]],[[0,0,1],[1,0,0],[0,1,0]],[[0,0,-1],[0,1,0],[1,0,0]]],_c=(e,t,n,r)=>[[[e,t],[n,t],[n,r]],[[e,t],[n,r],[e,r]]],vc=[..._c(-.13,-.04,.13,.04),..._c(-.04,-.13,.04,.13)],yc=[..._c(-.035,-.09,.035,.04),[[-.035,.04],[.035,.04],[0,.11]],..._c(-.05,-.12,.05,-.095)],bc=(e,t,n,r,i,a,o)=>{let[s,,c]=Qt(n*.9,0),l=[t[0],t[1]+.45+.07*Math.sin(n*2.2+t[0]),t[2]],u=([e,t,n])=>[s[0]*e-c[0]*n,t,s[2]*e-c[2]*n];for(let[t,n,s]of gc){let c=(e,i,a)=>{let[o,c,d]=u([0,1,2].map(o=>t[o]*r*a+n[o]*e+s[o]*i));return[l[0]+o,l[1]+c,l[2]+d]};bn(e,c(-r,-r,1),c(r,-r,1),c(r,r,1),i),bn(e,c(-r,-r,1),c(r,r,1),c(-r,r,1),i);let d=e.length;for(let[t,n,r]of a)bn(e,c(...t,1.01),c(...n,1.01),c(...r,1.01),o);for(let t=d;t<e.length;t+=10)e[t+8]=-2}},xc=(e,t,n)=>bc(e,t,n,.17,[.86,.9,.88],vc,[.1,1.2,.4]),Sc=(e,t,n)=>bc(e,t,n,.15,[.34,.14,.58],yc,[.3,1.4,1.8]),Cc=1,wc=12,Tc=(e,t)=>(n,r,i)=>{if(!e)return t;let a=le(e,[n,r+.2,i],[0,-1,0],99);return a<99?r+.2-a:-1/0},Ec=(e,t,n)=>{let r=[];oo(r,no(1,e)[1],t,za([0,0,0]));let i=r.length/10,a=r.slice(r.length-10,r.length-10+3),o=[0,1,2].map(e=>r.reduce((t,n,r)=>r%10==e?t+n:t,0)/i),s=[];for(let e=0;e<r.length;e+=30)s.push([r[e]-o[0],r[e+1]-o[1],r[e+2]-o[2]]);let c=t.pos[G.PELVIS],l=W([a[0]-c[0]+.3*Math.sin(n.yaw),0,a[2]-c[2]+.3*Math.cos(n.yaw)]);return{limb:e,s:t,c:o,pts:s,long:W([o[0]-a[0],o[1]-a[1],o[2]-a[2]]),p:[...o],v:[n.vx+l[0]*1.5,Math.max(n.vy,0)+3,n.vz+l[2]*1.5],q:[0,0,0,1],w:[l[2]*7,1.5,-l[0]*7],at:a,age:0}},Dc=(e,t,n)=>{e.age+=t,e.v[1]-=20*t,e.p=e.p.map((n,r)=>n+e.v[r]*t);let r=Math.hypot(...e.w);r>1e-6&&(e.q=K(q(W(e.w),r*t),e.q));let i=Math.min(...e.pts.map(t=>J(e.q,t)[1])),a=n(e.p[0],e.p[1],e.p[2])-e.p[1]-i;if(a>0){e.p[1]+=a,e.v[1]=e.v[1]<-2?-.3*e.v[1]:Math.max(e.v[1],0);let n=Math.exp(-6*t),[r,i,o]=J(e.q,e.long);e.w=[e.w[0]*n+40*o*i*t,e.w[1]*n,e.w[2]*n-40*r*i*t],e.v[0]*=n,e.v[2]*=n}},Oc=(e,t,n,r,i)=>{let a=e.p.down?e.p.lost??0:0;if(!a){e.cut=void 0;return}if(!e.cut){if(e.cut=Ec(a,rr(e.gait.pose()),e.p),r){for(let t=0;t<240;t++)Dc(e.cut,1/60,n);return}i?.shock(e.cut.at)}let o=e.cut.age;Dc(e.cut,t,n),o<Cc&&Math.floor(e.cut.age*wc)>Math.floor(o*wc)&&i?.spit(e.cut.at)},kc=(e,t,n,r,i)=>{let a=e.length;oo(e,no(r,t.limb)[1],t.s,n);for(let n=a;n<e.length;n+=10){let r=J(t.q,[e[n]-t.c[0],e[n+1]-t.c[1],e[n+2]-t.c[2]]),a=J(t.q,[e[n+3],e[n+4],e[n+5]]);for(let o=0;o<3;o++)e[n+o]=r[o]+t.p[o]-(o==1?i:0),e[n+3+o]=a[o]}},Ac=14,jc=e=>{let t=Qt(e.yaw,e.pitch)[2];return[e.x+t[0]*30,e.y+1.6+t[1]*30,e.z+t[2]*30]},Mc=.5,Nc=e=>e.dash>50,Pc=e=>{let t=Jr();return t.update(e,0),{p:{...e},gait:t,dash:+Nc(e),since:1e3,aim:0,focus:jc(e),prog:-1,trail:uo(),t:0}},Fc=(e,t)=>(n,i)=>{let a=le(e,[n,t+r,i],[0,-1,0],2*r);return a>0&&a<1?t+r-a:t},Ic=(e,t,n,r,i)=>{for(let n of e.keys())t.some(e=>e.id==n)||e.delete(n);for(let a of t){let t=e.get(a.id);t?(t.gait.update(a,n,r&&Fc(r,a.y)),t.dash+=(+Nc(a)-t.dash)*(1-Math.exp(-n*Ac)),t.since=a.shots==t.p.shots?t.since+n:0,t.aim=t.since==0?1:t.aim+(+(t.since<Mc)-t.aim)*(1-Math.exp(-n*12)),t.focus=t.since<Mc?r?Ni(a,r)[0]:jc(a):t.focus,t.prog=Ca(t.prog,a,n),t.trail.update(n),t.t+=n,t.p={...a}):e.set(a.id,Pc(a)),Oc(e.get(a.id),n,Tc(r,a.y),!t,i)}},Lc=(e,t,n,r,i)=>{let[a,o]=Pi(n,r),s=e.rot.slice(),c={...e,rot:s},[l,u]=[o[0],o[2].map((e,t)=>e*li[1]-o[1][t]*li[0])],d=a.map((e,t)=>e-.078*u[t]+.022*l[t]),f=[l[0]*.7,-1,l[2]*.7];return wo(c,t,G.ARM_R,d.map((e,n)=>t.pos[G.HAND_R][n]+(e-t.pos[G.HAND_R][n])*i),f),s[G.HAND_R]=nr(s[G.HAND_R],K(bo(rr(c).rot[G.FOREARM_R]),Cr(l,u)),i),c},Rc=[.08,-.3,.26,.1,.92,-.3],zc=e=>(e=Math.min(Math.max(e,0),1))*e*(3-2*e),Bc=(e,t,n,r)=>{let i=n<0?0:zc(n*6)*zc((1-n)*5),a=_a(t.cut??0,Math.max(n,0)),o=Rc.map((e,t)=>e+(a[t]-e)*i);o[1]+=.02*Math.sin(V*r)*(1-i);let[s,c,l]=n<0?[0,0,0]:xa(t.cut??0,n).map(e=>e*i),u=n<0?0:ma(t.cut??0,n)+Sa*s,d={...e,yaw:e.yaw+u},[f,p,m]=Qt(t.yaw+u+(1-Sa)*s,Math.max(t.pitch,-la)*i-.6*c),h=([e,t,n])=>[f[0]*e+p[0]*t+m[0]*n,f[1]*e+p[1]*t+m[1]*n,f[2]*e+p[2]*t+m[2]*n],g=d.rot.slice(),_={...d,rot:g};for(let[e,t]of[[G.SPINE,.4],[G.CHEST,.6]])g[e]=K(g[e],K(K(q([0,1,0],s*t),q([1,0,0],-c*t)),q([0,0,1],l*t)));let v=rr(_),y=v.pos[G.HEAD],b=W(h(o.slice(3,6))),x=Yt(y,h(o.slice(0,3)));return Po(_,v,G.ARM_R,x,b,h([.5,-1,-.35])),Po(_,v,G.ARM_L,Yt(x,b.map(e=>-zi*e)),b,h([-.5,-1,-.35])),_},Vc=(e,t,n,r)=>{let i=W([-t.p.vx,0,-t.p.vz]),[a,o,s]=n.map(e=>.6+.6*e);[[.5,.12,1.3],[.9,-.16,1.7],[1.25,.14,1.2]].forEach(([n,c,l],u)=>{let d=r([c,n,-.2-.1*u]),f=d.map((e,n)=>e+i[n]*l*t.dash);for(let t of[[-i[2]*.03,0,i[0]*.03],[0,.03,0]])for(let n of[d.map((e,n)=>e+t[n]),d.map((e,n)=>e-t[n]),f])e.push(...n,0,1,0,a,o,-2,s)})},Hc=(e,t,n,r=1)=>{let i=t.gait.pose(),{p:a}=t,o=za(n,Ra(a.id)),s=a.down?.5*Math.min(Math.max(1-a.down/30,0),1):0;a.down&&(i={...i,at:[i.at[0],i.at[1]-s,i.at[2]]});let c=rr(i),l=a.wield&&!a.down;if(l?(i=Bc(i,a,t.prog,t.gait.phase),c=rr(i)):t.aim>.01&&a.ammo>=0&&(i=Lc(i,c,a,t.focus,t.aim),c=rr(i)),t.cut?(oo(e,no(r,t.cut.limb)[0],c,o),t.cut.at=e.slice(e.length-10,e.length-10+3),kc(e,t.cut,o,r,s)):oo(e,Qa(r),c,o),l?(sa(e,c.pos[G.HAND_R],c.rot[G.HAND_R],r,t.t),t.trail.mark(...ca(c.pos[G.HAND_R],c.rot[G.HAND_R]),wa(t.prog))):a.ammo>=0&&!a.down&&ki(e,c.pos[G.HAND_R],c.rot[G.HAND_R],r),t.dash>.15){let[r,a]=[Math.sin(i.yaw),Math.cos(i.yaw)],{x:o,y:s,z:c}=t.p;Vc(e,t,n,([e,t,n])=>[o+e*a-n*r,s+t,c-e*r-n*a])}},Uc=r,Wc=o+.05,Gc=1.5,Kc=.6,qc=8,Jc=2.5,Yc=3,Xc=.4,Zc=.012,Qc=.2,$c=[1.2,1.45],el=[1.6,.12,.08],tl=[.9,.07,.05],nl=[.85,.07,.05],rl=(e,t,n,r)=>{let i=-1/0;for(let a of e)if(a!=t&&a.min[0]<=n&&n<=a.max[0]&&a.min[2]<=r&&r<=a.max[2]){if(a.max[1]>t.max[1]+.001){if(a.min[1]<t.max[1])return 1/0}else i=Math.max(i,a.max[1])}return t.max[1]-i},il=({brushes:e,floor:t},n)=>{let r=n.max.map((e,t)=>e-n.min[t]),i=[...r].sort((e,t)=>e-t),a={beam:i[1]<=Kc&&i[2]>=2*Kc,lips:[],stripes:[]};if(a.beam)return a;for(let i of[0,2]){let o=2-i;for(let t of[0,1]){let s=[n.min[0],0,n.min[2]];s[i]=(t?n.max:n.min)[i]+(t?Xc:-.4),s[o]=(n.min[o]+n.max[o])/2;let c=rl(e,n,s[0],s[2]);c>Uc&&c<=Wc&&r[o]>=Gc&&a.lips.push([i,t])}n.min[1]>t&&r[1]>=Jc&&r[o]>=qc&&r[i]<=Yc&&a.stripes.push([i,0],[i,1])}return a},al=(e,t,n,r,i,a,o)=>{let[s,c]=[(r+1)%3,(r+2)%3],l=[0,0,0];l[r]=i?1:-1;for(let[u,d]of[[0,0],[1,0],[1,1],[0,0],[1,1],[0,1]]){let f=[0,0,0];[f[r],f[s],f[c]]=[(i?n:t)[r],(u?n:t)[s],(d?n:t)[c]],e.push(...f,...l,o[0],o[1],a,o[2])}},ol=e=>{let t=[];for(let n of e.brushes){let{beam:r,lips:i,stripes:a}=il(e,n),[o,s]=[n.min.map(e=>e-Zc),n.max.map(e=>e+Zc)];if(r)for(let e=0;e<3;e++)for(let n of[0,1])(e!=1||n)&&al(t,o,s,e,n,-1,nl);for(let[e,r]of i){let i=r?1:-1,a=(r?n.max:n.min)[e],o=[n.min[0],n.max[1]+Zc,n.min[2]],s=[n.max[0],n.max[1]+Zc,n.max[2]];[o[e],s[e]]=r?[a-Qc,a]:[a,a+Qc],al(t,o,s,1,1,-2,el);let[c,l]=[o.slice(),s.slice()];[c[1],l[1]]=[n.max[1]-Qc,n.max[1]],[c[e],l[e]]=[a+i*Zc,a+i*Zc],al(t,c,l,e,r,-2,el)}for(let[e,r]of a){let i=2-e,[a,o]=[[...n.min],[...n.max]];[a[1],o[1]]=[n.min[1]+$c[0],n.min[1]+$c[1]],[a[i],o[i]]=[n.min[i]+.3,n.max[i]-.3],a[e]=o[e]=(r?n.max:n.min)[e]+(r?Zc:-.012),al(t,a,o,e,r,-2,tl)}}return t},sl=4.2,cl=({teams:e})=>{let t=[];return e.forEach(({base:[e,n,r]},i)=>{let a=gn(i),o=a.map(e=>.25+.45*e),s=(i,a,o,s,c,l)=>al(t,[e+i,n+l,r+a],[e+o,n+l,r+s],1,1,-1,c);s(-4.2,-4.2,sl,sl,o,.02);for(let[e,t,n,r]of[[-4.2,-4.2,sl,-3.85],[-4.2,3.85,sl,sl],[-4.2,-4.2,-3.85,sl],[3.85,-4.2,sl,sl]])s(e,t,n,r,a.map(e=>e*.8),.03)}),t},ll=10,ul=150,dl=3,fl=3,[pl,ml,hl,gl]=[[.3,.3,.29],[.09,.09,.1],[.8,.8,.78],[.85,.62,.08]],_l=({brushes:e})=>[0,2].flatMap(t=>[Math.min(...e.map(e=>e.min[t])),Math.max(...e.map(e=>e.max[t]))]),vl=e=>{let t=_l(e),n=Math.hypot(t[1]-t[0],t[3]-t[2])/2+ul,r=(e,t)=>{let r=[];for(let i=0;(t-e)/2+ll+8+i*72<=n;i++)r.push(e-ll-8-i*72,t+ll+8+i*72);return r.sort((e,t)=>e-t)};return{box:t,reach:n,xs:r(t[0],t[1]),zs:r(t[2],t[3])}},yl=({brushes:e,floor:t})=>e.map(e=>e.min[1]<=t?{...e,min:[e.min[0],-80,e.min[2]]}:e),bl=e=>{let{box:t,xs:n,zs:r}=vl(e),i=[],a=(e,t,n,r,a,o)=>al(i,[e,-80+a,t],[n,-80+a,r],1,1,-1,o),[o,s]=[(t[0]+t[1])/2,(t[2]+t[3])/2];a(o-1e3,s-1e3,o+1e3,s+1e3,0,pl),a(t[0],t[2],t[1],t[3],.12,ml);for(let{min:t,max:n}of e.brushes)t[1]<=e.floor&&a(t[0]-fl,t[2]-fl,n[0]+fl,n[2]+fl,.3,pl);for(let[e,t,i]of[[0,n,r],[1,r,n]])for(let n of t){let t=(t,r,i,o,s,c)=>e?a(i,n+t,o,n+r,s,c):a(n+t,i,n+r,o,s,c);t(-8,8,i[0]-8,i[i.length-1]+8,.12,ml),i.forEach((e,n)=>{for(let n of[-1,1])for(let r=0;r<8;r++)t(2*r-8+.5,2*r-8+1.5,e+n*8,e+n*11,.24,hl);let[r,a]=[e+8+dl,i[n+1]-8-dl];if(a>r){t(-7.6,-7.2,r,a,.24,hl),t(7.2,7.6,r,a,.24,hl);for(let e=r+2;e+4<a;e+=9)t(-.2,.2,e,e+4,.24,gl)}})}return i},xl=Object.keys(w).length,Sl=(e,t,n)=>{let r=Math.imul(e,374761393)+Math.imul(t,668265263)+Math.imul(n,144665)|0;return r=Math.imul(r^r>>>13,1274126177),((r^r>>>16)>>>0)/4294967296},Cl=(e,t,n,r)=>{let[i,a]=[Math.floor(e),Math.floor(t)],[o,s]=[e-i,t-a].map(e=>e*e*(3-2*e)),c=(e,t)=>Sl((i+e)%n,(a+t)%n,r);return(c(0,0)*(1-o)+c(1,0)*o)*(1-s)+(c(0,1)*(1-o)+c(1,1)*o)*s},wl=(e,t,n,r,i)=>{let[a,o]=[0,.5];for(let s=0;s<r;s++,o/=2)a+=o*Cl(e*(1<<s),t*(1<<s),n<<s,i+s);return a/(1-o*2)},Tl=(e,t,n)=>e.map((e,r)=>e+(t[r]-e)*n),El=(e,t)=>e.map(e=>e*t),Dl=e=>Math.min(Math.max(e,0),1),Ol=Math.PI*2,kl=[];kl[w.BRICK]=(e,t)=>{let n=Math.floor(t*8),r=e*4+(n&1)*.5,[i,a,o]=[Math.floor(r)%4,r%1,t*8%1],s=Cl(e*16,t*16,16,5),c=.8+.4*s;return a<.05||o<.1?[El([165,160,150],.7+.3*c),.1+.1*s]:[El([170,78,56],(.8+.4*Sl(i,n,1))*c*(.85+.15*o)),.7+.2*s+.1*Dl(Math.min(a-.05,o-.1)*12)]},kl[w.TILE]=(e,t)=>{let[n,r]=[Math.floor(e*4),Math.floor(t*4)],[i,a]=[e*4%1,t*4%1],o=Cl(e*16,t*16,16,7),s=.9+.2*o;return i<.05||a<.05?[El([85,85,80],s),.1]:[El([196,190,172],s*(.88+.08*(n+r&1)+.1*Sl(n,r,2))),.8+.1*o+.1*Dl((Math.min(i,a)-.05)*14)]},kl[w.LAVA]=(e,t)=>{let n=wl(e*4,t*4,4,4,11),r=Math.max(0,1-Math.abs(n-.5)*7)**2;return[Tl(Tl([55,8,4],[230,70,8],n),[255,215,90],r),.5]},kl[w.STONE]=(e,t)=>{let n=wl(e*8,t*8,8,4,3);return[El([128,124,120],.45+.7*(n*1.3+.1*Sl(Math.floor(e*128),Math.floor(t*128),4))),Dl(n*1.4-.2)]},kl[w.METAL]=(e,t)=>{let[n,r,i,a]=[Math.floor(e*2),Math.floor(t*2),e*2%1,t*2%1],o=Dl((Cl(e*8,t*8,8,13)-.68)*6),s=e=>Math.min(Math.max(Math.round((e-.1)/.4),0),2)*.4+.1,[c,l]=[s(i),s(a)],u=c==l&&c==.5?1:Math.hypot(i-c,a-l),d=Dl(1-u/.07),f=El([98,108,124],(.9+.2*Cl(e*32,t*32,32,9)+.12*Sl(n,r,6))*(1+.3*d)*(.65+.35*Dl((u-.06)/.04)));return Math.min(i,a,1-i,1-a)<.03?[El([40,44,50],1+o),.05]:[Tl(f,[105,68,45],o*.7),.5+.1*(1-o)+.4*d]},kl[w.WOOD]=(e,t)=>{let n=Math.floor(t*8),r=e*2+Sl(n,0,8)*2,[i,a,o]=[Math.floor(r)%2,r%1,t*8%1],s=Sl(n,i,3),c=.5+.5*Math.sin(Ol*(t*40+2.5*Cl(e*4,t*4,4,21)+s*7));return o<.08||a<.015?[[28,18,10],.05]:[Tl([92,58,32],[158,106,62],c*.6+s*.35),.7+.15*c+.15*Dl((o-.08)*15)]},kl[w.MOSS]=(e,t)=>{let n=Math.floor(t*4),r=e*2+(n&1)*.5,[i,a,o]=[Math.floor(r)%2,r%1,t*4%1],s=Math.min(a,1-a,(o<.5?o:1-o)*.5),c=a<.04||o<.06,l=Dl((.3*wl(e*12,t*12,12,3,17)-.03-s)*12),u=Cl(e*64,t*64,64,19),d=El([128,126,118],(.7+.4*Sl(i,n,5))*(.7+.5*Cl(e*16,t*16,16,15)));return[Tl(c?El(d,.45):d,Tl([52,100,34],[96,148,56],u),l),c?.1+.6*l*u:.6+.2*Dl(s*30)+.2*l*u]},kl[w.GRATE]=(e,t)=>{let[n,r]=[e*8%1,t*8%1],i=Math.max(Math.abs(n-.5),Math.abs(r-.5)),a=Math.min(Math.abs(n-.5),Math.abs(r-.5))>.43,o=Cl(e*16,t*16,16,23);return i<.36?[[9,9,12],0]:[El(Tl([104,108,116],[96,80,68],Dl((o-.55)*4)),(a?1.25:1)-(.5-i)*2.2+.2*o),a?1:.6+.4*Dl((i-.36)*12)]},kl[w.CONCRETE]=(e,t)=>{let[n,r]=[e*2%1,t*2%1],i=wl(e*4,t*4,4,3,41),a=Sl(Math.floor(e*128),Math.floor(t*128),43)>.992,o=Math.hypot(n%.5-.25,r%.5-.25)<.02,s=(.94+.1*i+.03*Sl(Math.floor(e*2),Math.floor(t*2),44))*(a||o?.9:1);return n<.015||r<.015?[El([160,164,172],s),.3]:[El([206,209,214],s),o?.5:.8+.2*i-(a?.15:0)]},kl[w.GLASS]=(e,t)=>{let n=e*2%1,r=((n+t*.7)%1-.5)/.12,i=Math.exp(-r*r);return n<.03||t<.03?[El([150,158,170],1-.3*n),.9]:[Tl(Tl([7,20,44],[48,88,136],t**2),[120,160,200],i*.18),.4]},kl[w.STEEL]=(e,t)=>{let n=Math.floor(t*128),r=.5*Sl(n,3,31)+.5*Cl(e*8,0,8,n+7),i=e*4%1;return i<.03?[[60,66,76],.1]:[El([176,184,196],.8+.35*r+(i>.97?.15:0)),.6+.2*r]},kl[w.PAINT]=(e,t)=>{let[n,r]=[e*2%1,t*2%1],i=Sl(Math.floor(e*128),Math.floor(t*128),47);return n<.02||r<.02?[[200,200,206],.3]:[El([246,246,248],.96+.06*i),.85+.04*i]};var Al=()=>{let e=new Uint8ClampedArray(xl*128*128*4);return kl.forEach((t,n)=>{for(let r=0;r<16384;r++){let[i,a]=t(r%128/128,Math.floor(r/128)/128);e.set([...i,a*255],(n*128*128+r)*4)}}),e},jl=8,Ml=40,Nl=130,Pl=60,Fl=[[1,.45,.12],[.2,.6,1],[.9,.15,.2],[.25,.85,.55]],Il=[.22,.5,.14],Ll=.3,Rl=e=>{let{box:t,reach:n,xs:r,zs:i}=vl(e),[a,o]=[(t[0]+t[1])/2,(t[2]+t[3])/2],s=Math.min(...e.brushes.map(e=>e.max[1]));return r.slice(1).flatMap((e,c)=>i.slice(1).flatMap((l,u)=>{let[d,f,p,m]=[r[c]+8,e-8,i[u]+8,l-8];if(Math.hypot((d+f)/2-a,(p+m)/2-o)>n||d<a&&a<f&&p<o&&o<m)return[];let[h,g]=[f-d,m-p].map(e=>Math.max(1,Math.round(e/Ml)));return Array.from({length:h*g},(e,n)=>{let[r,i]=[n%h,Math.floor(n/h)],a=e=>Sl(c*16+r,u*16+i,jl+e),[o,l]=[d+(f-d)*r/h,p+(m-p)*i/g],[_,v]=[o+(f-d)/h,l+(m-p)/g],[y,b]=[7+a(3)*7,7+a(4)*7],[x,S]=[(o+_)/2,(l+v)/2],C=Math.hypot(Math.max(t[0]-x,x-t[1],0),Math.max(t[2]-S,S-t[3],0)),T=C<Nl?-20+a(5)*30:-5+a(5)**1.5*100,E=[w.GLASS,w.STEEL,w.CONCRETE][+(a(6)>.7)+ +(a(6)>.85)],D={min:[o+y,-80,l+b],max:[_-y,C<Pl?Math.min(T,s-6):T,v-b],top:w.CONCRETE,side:E},O=D.max[1],k={min:[o+2,-80,l+2],max:[_-2,-80+Ll,v-2],top:w.PAINT,side:w.PAINT,tint:Il},A=a(10)<.3?[k]:[];return a(0)>.75?[k]:a(7)<.35?[...A,D,{min:[x-(_-o)/6,O,S-(v-l)/6],max:[x+(_-o)/6,O+3+a(8)*3,S+(v-l)/6],top:w.PAINT,side:w.PAINT,tint:Fl[Math.floor(a(9)*Fl.length)]}]:[...A,D]}).flat()}))},zl=1.3,Bl=6.5,Vl=.4,Hl=3,Ul=12,Wl=4.4*zl,Gl=4,Kl=260,ql=90,Jl=[[.95,.62,.03],[.9,.9,.88],[.04,.04,.045],[.7,.05,.06],[.08,.22,.7],[.5,.52,.55]],Yl=e=>{let{xs:t,zs:n}=vl(e),r=e=>e.slice(e.length/2-2,e.length/2+2),i=[];for(let[e,a,o]of[[0,t,n],[1,n,t]])for(let t of r(a))for(let n of[1,-1]){let a=n>0?r(o):r(o).reverse();a.forEach((r,o)=>Array.from({length:Hl},(r,s)=>i.push({axis:e,at:t,d:n,stops:a,cell:o,slot:s,paint:0})))}return i.map((e,t)=>[Sl(t,e.cell,3),e,Sl(t,1,4)]).sort((e,t)=>e[0]-t[0]).slice(0,64).map(([,e,t])=>({...e,paint:Math.floor(t*Jl.length)}))},Xl=({axis:e,d:t})=>e?[t,0]:[0,t],Zl=(e,t)=>{let{axis:n,at:r,d:i,stops:a,cell:o,slot:s}=e,c=t-n*16/2,l=Math.floor(c/16),u=Math.min(Math.max((c-l*16-s*Vl)/(Bl-2*Vl),0),1),d=((o+l)%a.length+a.length)%a.length,f=e=>a[e]-i*(Ul+Wl/2+s*8),p=f(d),m=u*u*(3-2*u),h=p+((d+1<a.length?f(d+1):p+i*72)-p)*m,g=d+1==a.length?1-m:d?1:m;return n?[h,r+i*Gl,g]:[r-i*Gl,h,g]},Ql=(e,[t,n,r,i],a)=>{bn(e,t,n,r,a),bn(e,t,r,i,a)},$l=(e,t,n,r,i,a,o)=>{let s=([e,t,n,r],i)=>[[e,i,n],[t,i,n],[t,i,r],[e,i,r]],[c,l]=[s(r,t),s(i,n)];c.forEach((t,n)=>{let r=(n+1)%4;Ql(e,[c[r],t,l[n],l[r]],a)}),Ql(e,[l[0],l[3],l[2],l[1]],o)},[eu,tu,nu]=(()=>{let[e,t,n]=[[],[],[]];$l(e,.25,.85,[-.95,.95,-2.2,2.2],[-.9,.9,-2.05,2.05],[1,1,1],[1,1,1]),$l(t,.85,1.4,[-.82,.82,-.6,1.5],[-.7,.7,-.15,1.05],[.1,.13,.17],[1,1,1]);for(let[e,t]of[[-1,[1,.95,.75]],[1,[1,.08,.05]]])for(let r of[-.6,.6]){let i=n.length,[a,o]=[e*2.2,e*2.1],s=[[r+.3,.5,a],[r-.3,.5,a],[r-.3,.68,a],[r+.3,.68,a]];Ql(n,e<0?s:s.reverse(),t);let c=[[r-.3,.86,o],[r-.3,.86,o-e*.25],[r+.3,.86,o-e*.25],[r+.3,.86,o]];Ql(n,e<0?c:c.reverse(),t),yn(n,i,2.5)}return[e,t,n]})(),ru=e=>{let t=Yl(e);return(e,n,r,i)=>{for(let a of t){let[t,o,s]=Zl(a,i),c=[t-n[0],-80-n[1],o-n[2]],l=c[0]**2+c[1]**2+c[2]**2;if(s<.05||l>Kl**2||c[0]*r[0]+c[1]*r[1]+c[2]*r[2]<-5.720000000000001)continue;let[u,d]=Xl(a),f=[[-d,0,u],[0,1,0],[u,0,d]],p=[t,-79.88,o];on(e,eu,p,f,[0,0,0],zl*s,Jl[a.paint]),l<ql**2&&on(e,tu,p,f,[0,0,0],zl*s,Jl[a.paint]),on(e,nu,p,f,[0,0,0],zl*s)}}},iu=1<<19,au=2,ou=1024,su=.6,cu=.02,lu=.05,uu=Math.tan(70*Math.PI/360),du=10,fu=4,pu=`#version 300 es
|
|
1
|
+
var e=.4,t=1.8,n=1.55,r=.5,i=.9,a=7.5,o=2.4,s=5.5,c=2.5,l=[`Red`,`Blue`],u=[`#ff3d4f`,`#2f80ff`],d=1.5,f=.12,p=.012,m=1.2,h=[{ticks:28,strike:10,reach:2.65,arc:.3,hp:2},{ticks:34,strike:13,reach:2.15,arc:1.2,hp:2},{ticks:34,strike:13,reach:2.15,arc:1.2,hp:2},{ticks:40,strike:16,reach:2.15,arc:.45,hp:3},{ticks:36,strike:12,reach:3.2,arc:.3,hp:3},{ticks:48,strike:24,reach:2.3,arc:Math.PI,hp:3},{ticks:48,strike:24,reach:2.3,arc:Math.PI,hp:3},{ticks:58,strike:40,reach:2.4,arc:.6,hp:4}],g=7.5,_={HOME:0,CARRIED:1,DROPPED:2},v={FORWARD:1,BACK:2,LEFT:4,RIGHT:8,JUMP:16,SPRINT:32,DASH:64,CROUCH:128,FIRE:256,BLADE:512,SPECIAL:1024},y={THRUST:0,LEFT:1,RIGHT:2,SLASH:3,LUNGE:4,SPIN_L:5,SPIN_R:6,LEAP:7},b={NONE:0,HEAD:1,ARM_L:2,ARM_R:3,LEG_L:4,LEG_R:5},x={GROUND:0,AIR:1,WALLRUN:2,HANG:3,CLIMB:4,SLIDE:5,CROUCH:6},S={NONE:0,EAST:1,WEST:2,SOUTH:3,NORTH:4},C={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},w={BRICK:0,TILE:1,LAVA:2,STONE:3,METAL:4,WOOD:5,MOSS:6,GRATE:7,CONCRETE:8,GLASS:9,STEEL:10,PAINT:11},T=-30,E=(e,t,n,r,i,a=w.CONCRETE)=>({min:[e,T,t],max:[n,i,r],top:w.CONCRETE,side:a}),D=([e,t,n],[r,i,a],o,s=o,c)=>({min:[e,t,n],max:[r,i,a],top:o,side:s,tint:c});[E(4,57.7,24,76,10),E(4,36,24,53.5,10,w.GLASS),E(4,20,24,36,12.4),E(4,-5,24,7,12.4,w.GLASS),E(27,20,47,50,8),E(27,60,47,76,8,w.BRICK),D([9,12.2,39],[19,12.6,47],w.STEEL),...((e,t)=>[1,2,3,4,5,6].map(n=>D([12,t,e-n],[14,t+.4*n,e-n+1],w.CONCRETE)))(53,10),D([5,10,42],[5.5,14,42.5],w.STEEL),D([5,10,50],[5.5,14,50.5],w.STEEL),D([8,12.4,24],[20,12.85,24.45],w.STEEL),D([36,8,22],[37,14.5,48],w.PAINT,w.PAINT,[.15,.72,.62]),D([30,8,28],[34,10,32],w.CONCRETE),D([40,8,30],[44,10.2,34],w.PAINT,w.PAINT,[1,.3,.06]),D([28,9.2,44],[35,12,46],w.STEEL,w.PAINT,[.2,.42,1]),D([41.5,7.6,50],[42,8,60],w.STEEL),D([30,8,64],[34,9.6,68],w.PAINT,w.PAINT,[.2,.8,.3])];var O=240,k=[1,.22,.26],A=[.2,.46,1],j=[1,.42,.08],ee=[.12,.7,.62],M=(e,t,n,r,i,a,o)=>D([e,t,n],[r,i,a],w.PAINT,w.PAINT,o),te=(e,t,n,r,i,a,o,s=T)=>{let c=Math.ceil((o-a)/.46);return Array.from({length:c},(l,u)=>{let[d,f]=[t+(n-t)*u/c,t+(n-t)*(u+1)/c].sort((e,t)=>e-t),p=a+(o-a)*(u+1)/c;return e===0?D([d,s,r],[f,p,i],w.CONCRETE):D([r,s,d],[i,p,f],w.CONCRETE)})},N=(e,t,n,r,i,a,o)=>o.map((o,s)=>D([e+s*n,a,t+s*r],[e+s*n+4,o,t+s*r+i],w.STEEL,w.CONCRETE)),P=[E(12,212,52,240,26,w.GLASS),M(12,26,212,52,26.12,212.5,k),M(12,26,239.5,52,26.12,240,k),M(12,26,212.5,12.5,26.12,239.5,k),M(51.5,26,212.5,52,26.12,239.5,k),M(11.6,12,222,12,25.8,232,k),M(28,12,211.4,31,25.5,212,k),D([19,26,222],[22,27.4,225],w.STEEL),D([42,26,222],[45,27.4,225],w.STEEL),D([29,26,229],[35,27.1,229.6],w.CONCRETE),D([29,26,215],[35,27.5,219],w.STEEL,w.PAINT,k),E(6,164,26,201,26,w.GLASS),E(6,134,26,147,26,w.GLASS),E(6,201,26,212,19),E(15,147,26,164,19),D([14,26,164],[15,32,196],w.PAINT,w.PAINT,ee),D([14,18,147],[15,32,164],w.PAINT,w.PAINT,ee),D([14,26,134],[15,32,147],w.PAINT,w.PAINT,ee),...N(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])=>D([e,19,t],[n,i,r],w.STEEL,w.CONCRETE)),D([20,26,178],[23,27.3,181],w.STEEL),D([8,26,176],[11,27.2,179],w.STEEL),D([8,26,190],[11,27.3,193],w.STEEL),D([20,26,140],[23,27.3,143],w.STEEL),E(32,186,76,209,19),M(32,19,207.5,76,19.1,209,k),...N(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])=>D([e,T,t],[n,i,r],w.STEEL,w.CONCRETE)),E(32,166,64,182,21.2,w.GLASS),E(32,140,64,161,19),D([40,21.2,172],[44,22.6,176],w.STEEL),D([52,19,148],[57,20.3,151],w.STEEL),D([38,19,196],[41,20.4,199],w.STEEL),D([60,19,200],[63,20.4,203],w.STEEL),D([52,19,190],[58,20.6,194],w.STEEL),D([66,19,204],[72,20.2,207],w.STEEL),D([56,21.2,170],[60,22.4,174],w.STEEL),D([34,19,152],[37,20.3,156],w.STEEL),...N(36,135,18,0,3,15,[17.2,17.2]),...N(6.5,129,6,0,4,15,[17.2,19.4,21.6,23.8]),E(76,213,100,240,14.5,w.STEEL),M(76,14.5,238.5,100,14.6,240,k),E(76,185,100,209,14.5),E(76,138,100,181,14.5,w.GLASS),D([80,15.7,158],[96,17.7,162],w.STEEL,w.PAINT,j),D([82,14.5,234],[85,15.9,237],w.STEEL),D([91,14.5,190],[94,15.9,193],w.STEEL),D([80,14.5,204],[83,15.6,207],w.STEEL),D([78,14.5,170],[81,15.9,173],w.STEEL),D([92,14.5,146],[95,15.7,149],w.STEEL),D([92,14.5,222],[96,15.8,226],w.STEEL),...te(0,76,52,226,232,14.5,26),...te(0,85,76,196,202,14.5,19,14.5)],F=[E(6,106,62,134,15),E(62,106,100,134,14.5),D([34,15,112],[54,17.2,128],w.CONCRETE),M(38,17.2,116,50,17.3,124,j),...[[35,113],[35,126.2],[51,113],[51,126.2]].map(([e,t])=>D([e,17.2,t],[e+.8,21.5,t+.8],w.STEEL)),D([34.6,21.5,112.6],[52.2,21.9,127.4],w.GLASS),D([14,15,114],[17,16.5,117],w.STEEL),D([14,15,123],[17,16.5,126],w.STEEL),D([56,15,114],[59,16.5,117],w.STEEL),D([56,15,123],[59,16.5,126],w.STEEL),D([15.35,25.5,106],[15.85,26,134],w.STEEL),D([70,14.5,108],[70.8,38,108.8],w.STEEL),D([70,14.5,131.2],[70.8,38,132],w.STEEL),D([66,14.5,110],[69,15.9,113],w.STEEL),D([66,14.5,127],[69,15.9,130],w.STEEL)],I=e=>({...e,min:[e.min[0],e.min[1],O-e.max[2]],max:[e.max[0],e.max[1],O-e.min[2]],tint:e.tint===k?A:e.tint}),L=(e,t,n)=>[...[16,22,28,34,40].map(n=>[n,26,t,e]),...[19,31,43].map(t=>[t,26,n,e])],R=[[20,26,190],[48,21.2,172],[48,19,200],[88,14.5,198]],z=[[21,26,168],[46,19,144],[36,21.2,178],[88,14.5,216],[88,14.5,172]],ne={name:`Highline`,brushes:[...P,...P.map(I),...F],teams:[{base:[32,26,224],spawns:L(0,236,231),rack:[30.75,27.5,217],blade:[33.25,27.5,217]},{base:[32,26,16],spawns:L(Math.PI,4,9),rack:[30.75,27.5,23],blade:[33.25,27.5,23]}],packs:[...R,...R.map(([e,t,n])=>[e,t,O-n]),[24,15,112],[24,15,128]],ammo:[...z,...z.map(([e,t,n])=>[e,t,O-n])],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]},re=4,ie=1024,ae=(e,t)=>(e+ie)*(2*ie)+t+ie,oe=(e,t)=>Math.min(Math.max(Math.floor(e/t),-1024),1023),se=(e,t=re)=>{let n=/* @__PURE__ */ new Map;return e.brushes.forEach(({min:e,max:r},i)=>{for(let a=oe(e[0],t);a<=oe(r[0],t);a++)for(let o=oe(e[2],t);o<=oe(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}},ce=(e,t,n,r)=>{let i=[];for(let a=oe(t-r,e.cell);a<=oe(t+r,e.cell);a++)for(let t=oe(n-r,e.cell);t<=oe(n+r,e.cell);t++)for(let n of e.grid.get(ae(a,t))??[])i.includes(n)||i.push(n);return i},le=(e,t,n,r,i=0)=>{let{cell:a,def:o}=e,s=r,c=oe(t[0],a),l=oe(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)>ie||Math.abs(l)>ie)return s;m<h?(c+=u,m+=g):(l+=d,h+=_)}},ue=(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&&le(e,t,[r/o,i/o,a/o],o)<o-1e-4},B=1/60,V=Math.PI*2,de=1e-6,fe=.01,pe=.001,me=e=>(e%V+V)%V,he=e=>[-Math.sin(e),-Math.cos(e)],ge=Math.fround,_e=Math.sqrt,ve=(e,t,n)=>Math.min(Math.max(e,t),n),ye=(e,t)=>_e(e*e+t*t),be=[[0,0],[1,0],[-1,0],[0,1],[0,-1]],xe={vx:0,vz:0,mode:x.GROUND,t:0,wall:S.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:b.NONE,ev:0,fall:0},Se=(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:ge(a),y:ge(o),z:ge(s),vy:0,yaw:me(c),pitch:0,ground:!0,...xe}},Ce=(e,t,n)=>{let{yaw:r,pitch:i,id:a,shots:o,hits:s}=e;Object.assign(e,Se(a,t,a,n),{yaw:r,pitch:i,shots:o,hits:s,ev:e.ev|C.RESPAWN})},we=e=>e===x.GROUND||e===x.SLIDE||e===x.CROUCH,Te=e=>e.mode===x.SLIDE||e.mode===x.CROUCH?i:t,Ee=e=>e.mode===x.SLIDE||e.mode===x.CROUCH?.7:1.6,De=e=>ye(e.vx,e.vz),Oe=e=>e.mode===x.GROUND&&ye(e.vx,e.vz)>6.5,ke=(e,t,n)=>e.max[1]>t+.5+fe&&e.min[1]<t+n-fe,Ae=(e,t,n)=>[t-ve(t,e.min[0],e.max[0]),n-ve(n,e.min[2],e.max[2])],je=(t,n,r)=>{let{brushes:i}=n.def,a=ce(n,t.x,t.z,2*e),o=(e-de)**2,[s,c]=[0,0];for(let n=0;n<4;n++){let n=0,l=0,u=0;for(let s of a){let a=i[s];if(!ke(a,t.y,r))continue;let[c,d]=Ae(a,t.x,t.z),f=c*c+d*d;if(f>=o)continue;if(f){let t=_e(f);.4-t>n&&(n=e-t,l=c/t*n,u=d/t*n);continue}let[p,m,h]=[[t.x-a.min[0],-1,0],[a.max[0]-t.x,1,0],[t.z-a.min[2],0,-1],[a.max[2]-t.z,0,1]].reduce((e,t)=>t[0]<e[0]?t:e);p+.4>n&&(n=p+e,[l,u]=[m*n,h*n])}if(!n)break;t.x+=l,t.z+=u,s+=l,c+=u}return[s,c]},Me=(t,n,r)=>{let{brushes:i}=n.def,a=(e-de)**2,o=-1/0,s=1/0;for(let c of ce(n,t.x,t.z,e)){let e=i[c],[n,l]=Ae(e,t.x,t.z);n*n+l*l>=a||(e.max[1]<=t.y+.5+fe?o=Math.max(o,e.max[1]):e.min[1]>=t.y+r-fe&&(s=Math.min(s,e.min[1])))}return[o,s]},Ne=(t,n)=>{let r=(e-de)**2;return ce(n,t.x,t.z,e).every(e=>{let i=n.def.brushes[e],[a,o]=Ae(i,t.x,t.z);return a*a+o*o>=r||!ke(i,t.y,1.8)})},Pe=(t,n,r,i,a)=>{let o=(e-de)**2;return ce(t,n,r,e).every(e=>{let s=t.def.brushes[e],[c,l]=Ae(s,n,r);return c*c+l*l>=o||s.max[1]<=i||s.min[1]>=a})},Fe=(e,t)=>{let[n,r]=be[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}},Ie=(e,t,n,r)=>{let{a:i,o:a,sign:o,c:s,co:c}=Fe(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},Le=(t,n,r)=>{let i;for(let a of ce(n,t.x,t.z,.9)){let o=n.def.brushes[a],s=Ie(o,t,r,.5);s!==void 0&&o.min[1]<t.y+.5&&o.max[1]>t.y+1.8&&(i=Math.min(i??1/0,Math.max(0,s-e)))}return i},Re=(e,t)=>{let[n,r]=he(e.yaw),i;for(let a=1;a<=4;a++){let[o,s]=be[a];if(a===e.wall||n*o+r*s<.5)continue;let{a:c,sign:l}=Fe(e,a);for(let n of ce(t,e.x,e.z,.6000000000000001)){let r=t.def.brushes[n],o=r.max[1],s=o-e.y;if(Ie(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*.43000000000000005,f=u+l*.2,[p,m]=c===0?[d,e.z]:[e.x,d],[h,g]=c===0?[f,e.z]:[e.x,f];Pe(t,p,m,Math.min(e.y,o-2)+fe,o+1.8)&&Pe(t,h,g,o+fe,o+1.8)&&(i={side:a,top:o,hang:d})}}return i},ze=(e,t)=>{let{a:n,o:r,sign:i,c:a,co:o}=Fe(e,e.wall);return ce(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 ge(c.max[1])===e.edge&&o>=c.min[r]&&o<=c.max[r]&&l>=.2})},Be=(e,n)=>{if(e.vy>=0)return!1;let[r]=Me(e,n,t),i=6*B;return e.y-r<=-e.vy*i+10*i*i},Ve=(e,t)=>{e.mode=t,e.t=0},He=(e,t)=>{let n=ye(e.vx,e.vz);n>t&&(e.vx*=t/n,e.vz*=t/n)},Ue=(t,n,r,i)=>{let[a,o]=[r.wx,r.wz];for(let r of ce(n,t.x,t.z,e+pe)){let e=n.def.brushes[r],[s,c]=Ae(e,t.x,t.z),l=ye(s,c);if(l>0&&l<=.4+pe&&ke(e,t.y,i)){let e=(-a*s-o*c)/l;e>0&&(a+=e*s/l,o+=e*c/l)}}return[a,o]},We=(e,t,n)=>{let r=ye(t[0],t[1]);if(r<de){let t=ye(e.vx,e.vz),n=t?Math.max(0,t-45*B)/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=ye(s,c);if(l){let e=Math.max(0,l-45*B)/l;[s,c]=[s*e,c*e]}n*=r,o=o<n?Math.min(n,o+(o>=6?3:50)*B):Math.max(n,o-12*B),e.vx=s+o*i,e.vz=c+o*a},Ge=(e,t,n,r,i)=>{let a=e.y;e.x+=e.vx*B,e.z+=e.vz*B;let[o,s]=je(e,t,n),c=ye(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]=Me(e,t,n),d=e.vy-r*20*B;if(e.y+=(e.vy+d)/2*B,e.vy=d,e.y+n>u&&(e.y=u-n,e.vy=Math.min(e.vy,0)),e.vy<=0?e.y<=l+fe: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},Ke=(e,t)=>{e.vy=t,e.coyote=0,e.buffer=0,e.ev|=C.JUMP},qe=(e,n,r)=>{let[i,a]=be[e.wall],o=t=>{Ve(e,t),e.edge=0};if(r.keys&(v.BACK|v.CROUCH))o(x.AIR),e.coyote=0;else if(r.jump&&r.fx*i+r.fz*a<0)o(x.AIR),e.vx=-i*4,e.vz=-a*4,Ke(e,6);else if(r.jump||r.fwd&&e.t>=6)Ve(e,x.CLIMB);else if(e.t>=30)o(x.AIR),e.coyote=0;else{let r=Math.max(e.edge-2,Me(e,n,t)[0]);e.y+=ve(r-e.y,-8*B,8*B)}},Je=(e,t)=>{let[n,r]=be[e.wall];e.y<e.edge?e.y=Math.min(e.edge,e.y+8*B):(e.x+=n*s*B,e.z+=r*s*B),e.y>=e.edge&&ze(e,t)?(Ve(e,x.GROUND),e.vx=n*3,e.vz=r*3,e.vy=0,e.edge=0,e.wall=S.NONE,e.coyote=6,e.ev|=C.CLIMB):e.t>=40&&(Ve(e,e.y>=e.edge?x.GROUND:x.AIR),e.edge=0,e.wall=S.NONE)},Ye=(e,t,n)=>{let[r,i]=be[e.wall],a=e.vx*r+e.vz*i,[o,s]=[e.vx-a*r,e.vz-a*i],c=ye(o,s);if(n.jump)Ve(e,x.AIR),e.vx=o-r*5,e.vz=s-i*5,Ke(e,6.5),e.jumps=1,e.dashes=1,e.ev|=C.WALLRUN_END;else{let a=Le(e,t,e.wall);if(a===void 0||!n.fwd||c<3.5||e.t>=60){Ve(e,x.AIR),e.ev|=C.WALLRUN_END;return}let l=Math.max(0,c-1.5*B)/c;e.vx=o*l,e.vz=s*l;let u=Math.min(a,4*B);e.x+=r*u,e.z+=i*u}},Xe=(e,t,n)=>{if(!n.fwd)return;let r=ye(e.vx,e.vz);if(!(r<4.5))for(let n=1;n<=4;n++){let[i,a]=be[n],o=e.vx*i+e.vz*a,[s,c]=[e.vx-o*i,e.vz-o*a];if(n!==e.wall&&o<=.75*r&&o>=-.2*r&&Le(e,t,n)!==void 0){let t=ye(s,c),i=Math.max(t,.9*r)/t;Ve(e,x.WALLRUN),e.wall=n,[e.vx,e.vz]=[s*i,c*i],e.vy=ve(e.vy,2,3),e.jumps=1,e.dashes=1,e.coyote=0,e.ev|=C.WALLRUN_START;return}}},Ze=(e,t)=>{Ve(e,x.HANG),e.wall=t.side,e.edge=ge(t.top),t.side<=S.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|=C.GRAB},Qe=(e,t,n)=>{let r=e.mode===x.GROUND;if(n.dash&&e.dash===0&&(r||(e.mode===x.AIR||e.mode===x.WALLRUN)&&e.dashes>0)){let[t,i]=n.wx||n.wz?[n.wx,n.wz]:[n.fx,n.fz];r||(e.dashes--,e.vy=0,e.mode===x.WALLRUN&&(Ve(e,x.AIR),e.ev|=C.WALLRUN_END)),e.vx=t*16,e.vz=i*16,e.dash=60,e.ev|=C.DASH}let i=e.dash>50;e.mode===x.WALLRUN&&Ye(e,t,n),we(e.mode)&&$e(e,t,n,i),e.mode===x.AIR&&et(e,t,n,i);let o=i&&e.vy<=0?0:e.mode===x.WALLRUN?.15:1,s=e.mode,c=Ge(e,t,Te(e),o,we(s));if(c>=0){if(!we(e.mode)){if(e.ev|=C.LAND|(e.mode===x.WALLRUN?C.WALLRUN_END:0),e.fall=c,e.jumps=1,e.dashes=1,e.wall=S.NONE,n.keys&v.CROUCH){let t=ye(e.vx,e.vz)>=a;Ve(e,t?x.SLIDE:x.CROUCH),e.ev|=t?C.SLIDE_START:0}else Ve(e,x.GROUND)}e.coyote=6}else we(e.mode)&&(e.ev|=e.mode===x.SLIDE?C.SLIDE_END:0,Ve(e,x.AIR));if(e.mode===x.AIR){let r=Re(e,t);r?Ze(e,r):Xe(e,t,n)}},$e=(e,n,r,o)=>{let s=(r.keys&v.CROUCH)!==0;if(e.buffer>0&&(e.mode===x.GROUND||Ne(e,n))){e.ev|=e.mode===x.SLIDE?C.SLIDE_END:0,Ve(e,x.AIR),Ke(e,7);return}let l=ye(e.vx,e.vz);if(e.mode===x.GROUND&&s){let t=l>=a;Ve(e,t?x.SLIDE:x.CROUCH),e.ev|=t?C.SLIDE_START:0}else e.mode===x.SLIDE&&(e.t>=60||l<4.5||r.stumble)?(e.ev|=C.SLIDE_END,Ve(e,!s&&Ne(e,n)?x.GROUND:x.CROUCH)):e.mode===x.SLIDE&&!s&&Ne(e,n)?(e.ev|=C.SLIDE_END,Ve(e,x.GROUND)):e.mode===x.CROUCH&&!s&&Ne(e,n)&&Ve(e,x.GROUND);if(!o){if(r.stumble){if(l>2.5){let t=Math.max(c,l-12*B)/l;e.vx*=t,e.vz*=t}else We(e,Ue(e,n,r,Te(e)),c)}else if(e.mode===x.SLIDE){let t=Math.max(0,l-4*B)/l;e.vx*=t,e.vz*=t}else if(e.mode===x.CROUCH)We(e,Ue(e,n,r,i),3);else{let i=(r.keys&v.SPRINT)!==0&&r.fwd;We(e,Ue(e,n,r,t),i?9:6)}}},et=(e,t,n,r)=>{if(e.buffer>0&&(e.coyote>0?Ke(e,7):e.jumps>0&&!Be(e,t)&&(e.jumps--,Ke(e,6),e.ev=e.ev&~C.JUMP|C.DOUBLE)),r||!n.wx&&!n.wz)return;let i=ye(e.vx,e.vz);e.vx+=n.wx*14*B,e.vz+=n.wz*14*B,He(e,Math.max(i,6))},tt=(e,t,r,i=0)=>{e.yaw=me(t.yaw),e.pitch=Math.max(-1.55,Math.min(n,t.pitch));let a=(t.keys&v.FORWARD?1:0)-(t.keys&v.BACK?1:0),o=(t.keys&v.RIGHT?1:0)-(t.keys&v.LEFT?1:0),s=ye(a,o)||1,[c,l]=he(e.yaw),u=n=>(t.keys&n)!==0&&(e.held&n)===0,d=e.stun>0,f={keys:t.keys,stumble:d,jump:!d&&u(v.JUMP),dash:!d&&u(v.DASH),fwd:a>0,wx:(c*a-l*o)/s,wz:(l*a+c*o)/s,fx:c,fz:l},p=e.mode;e.ev=0,e.fall=0,f.jump&&(e.buffer=7),d&&e.stun--,e.dash>0&&(e.dash--,e.dash===50&&He(e,10)),e.mode===x.HANG&&qe(e,r,f),e.mode===x.CLIMB?Je(e,r):e.mode!==x.HANG&&Qe(e,r,f),e.y<r.def.floor&&Ce(e,r,i),e.t=e.mode===p?Math.min(255,e.t+1):e.t,e.buffer=Math.max(0,e.buffer-1),e.mode===x.AIR&&p===x.AIR&&(e.coyote=Math.max(0,e.coyote-1)),e.held=t.keys&(v.JUMP|v.DASH),e.ground=we(e.mode),e.x=ge(e.x),e.y=ge(e.y),e.z=ge(e.z),e.vx=ge(e.vx),e.vy=ge(e.vy),e.vz=ge(e.vz),e.edge=ge(e.edge)},nt=127,rt=16,it=32,at=128/Math.PI,ot=254/Math.PI,st=65536/(2*Math.PI),ct=e=>Math.round(e*st)&65535,lt=e=>Math.max(-32768,Math.min(32767,Math.round(e))),ut=e=>lt(e*1e4),dt=e=>e/1e4,ft=e=>e/st,pt=(e=0)=>Math.round(e*256)&16777215,mt=e=>({...e,yaw:ft(ct(e.yaw)),pitch:dt(ut(e.pitch)),...e.view!==void 0&&{view:pt(e.view)/256}}),ht=e=>{let t=/* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(12));t.setUint8(0,1),t.setUint16(1,e.seq&65535),t.setUint16(3,e.keys&2047),t.setUint16(5,ct(e.yaw)),t.setInt16(7,ut(e.pitch));let n=pt(e.view);return t.setUint16(9,n>>8),t.setUint8(11,n&255),t.buffer},gt=e=>e===_.CARRIED?2:e===_.DROPPED?8:1,_t=e=>{if(e.byteLength<4)return null;let t=new DataView(e),n=t.getUint8(3),r=4+48*n;if(t.getUint8(0)!==2||e.byteLength<r+8+2)return null;let i=[];for(let e=0;e<n;e++){let n=4+e*48,r=t.getUint8(n+35),a=t.getUint8(n+38),[o,s]=[t.getUint8(n+37),t.getUint8(n+39)],c=r&7,l=t.getUint8(n+40)<<16|t.getUint16(n+41);i.push({id:t.getUint8(n),x:t.getFloat32(n+1),y:t.getFloat32(n+5),z:t.getFloat32(n+9),vx:t.getFloat32(n+13),vy:t.getFloat32(n+17),vz:t.getFloat32(n+21),edge:t.getFloat32(n+25),yaw:ft(t.getUint16(n+29)),pitch:dt(t.getInt16(n+31)),ack:t.getUint16(n+33),ground:c===x.GROUND||c===x.SLIDE||c===x.CROUCH,mode:c,wall:r>>3&7,jumps:r>>6&1,dashes:r>>7,t:t.getUint8(n+36),dash:o&63,stun:s&63,by:o>>6<<2|s>>6,coyote:a&7,buffer:a>>3&7,held:(a&64?v.JUMP:0)|(a&128?v.DASH:0),ev:0,fall:0,hp:l&7,cool:l>>3&7,ammo:(l>>6&127)===nt?-1:l>>6&127,down:l>>13&127,rack:(l>>20&1)==1,shots:t.getUint8(n+43),hits:t.getUint8(n+44),blade:(l>>21&1)==1,wield:(l>>22&1)==1,zap:(l>>23&1)==1,swing:t.getUint8(n+45)&63,cut:t.getUint8(n+45)>>6|t.getUint8(n+46)>>1&4,lost:t.getUint8(n+46)&7,charge:t.getUint8(n+47)})}let a=t.getUint16(r+2),o=r+8,s=[];for(let n=0;n<2;n++){let n=o<e.byteLength?t.getUint8(o):-1;if(n<0||n>_.DROPPED||o+gt(n)>e.byteLength)return null;let r={state:n,by:0,x:0,y:0,z:0,left:0};n===_.CARRIED?r.by=t.getUint8(o+1):n===_.DROPPED&&([r.x,r.y,r.z]=[1,3,5].map(e=>t.getInt16(o+e)/rt),r.left=t.getUint8(o+7)),s.push(r),o+=gt(n)}let c=o<e.byteLength?t.getUint8(o++)||-1:0;if(o+c*11!==e.byteLength)return null;let l=[];for(let e=0;e<c;e++,o+=11){let[e,n]=[t.getUint8(o+8)/at,t.getInt8(o+9)/ot];l.push({id:t.getUint8(o),by:t.getUint8(o+1)&127,x:t.getInt16(o+2)/it,y:t.getInt16(o+4)/it,z:t.getInt16(o+6)/it,dx:-Math.sin(e)*Math.cos(n),dy:Math.sin(n),dz:-Math.cos(e)*Math.cos(n),burst:t.getUint8(o+1)>127,power:t.getUint8(o+10)})}return{tick:t.getUint16(1),players:i,score:[t.getUint8(r),t.getUint8(r+1)],clock:a&32767,over:!!(a&32768),flags:s,packs:t.getUint32(r+4),...c?{balls:l}:{}}},vt=e=>{try{let t=JSON.parse(e);return t&&typeof t.t==`string`?t:null}catch{return null}},yt=44100,bt=([e,t,n,r,i,a,o,s,c,l,u],d,f=yt)=>{let p=new Float32Array(Math.ceil((r+i+a)*f)),m=0,h=0,g=0,_=()=>{d=d+1831565813|0;let e=Math.imul(d^d>>>15,1|d);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/2**31-1};for(let d=0;d<p.length;d++){let v=d/f;m+=t*2**(n*v)*(v>c?l:1)*(1+o*Math.sin(v*44))/f,m>=1&&(m%=1,g=_());let y=e==3?g:e==2?Math.sin(m*2*Math.PI):e?1-2*m:m<.5?1:-1;h+=(y-h)*s;let b=v<r?v/r:v<r+i?1:((r+i+a-v)/a)**2;p[d]=h*b*u}return p},H={STEP:0,WALLSTEP:1,JUMP:2,DOUBLE:3,DASH:4,LAND:5,GRAB:6,SCUFF:7,WIND:8,SCRAPE:9,TAKE:10,DROP:11,RETURN:12,CAPTURE:13,TACKLE:14,GRUNT:15,LASER:16,HIT:17,HURT:18,DOWN:19,GUN:20,PACK:21,DRY:22,SHING:23,SWISH:24,ZAP:25,SPLASH:26},xt=[[[2,130,-3,.001,.005,.06,0,1,0,1,.7],[3,8e3,-1,.001,0,.035,0,.4,0,1,.45]],[[3,12e3,0,.001,0,.03,0,.5,0,1,.4],[2,190,-3,.001,0,.04,0,1,0,1,.3]],[[3,14e3,0,.015,.02,.09,.3,.18,0,1,.5],[2,70,-2,.003,0,.07,0,1,0,1,.3]],[[3,4e3,3.5,.03,.03,.2,0,.25,0,1,.5],[2,350,1.2,.03,.02,.18,.02,1,0,1,.12]],[[3,14e3,-2.5,.008,.07,.2,.25,.3,0,1,.8],[3,3500,.5,.01,.06,.2,0,.12,0,1,.5]],[[2,70,-2.5,.001,.01,.2,0,1,0,1,.9],[3,7e3,-1,.001,0,.09,0,.25,0,1,.5]],[[3,6e3,-1,.001,0,.05,0,.5,0,1,.7],[2,160,-4,.001,0,.07,0,1,0,1,.5]],[[3,5e3,0,.01,.04,.14,.5,.3,0,1,.5],[3,2500,0,.03,0,.1,.4,.2,0,1,.3,.08]],[[3,2e4,0,.001,2.1,.001,.25,.06,0,1,1.2],[3,2e4,0,.001,2.1,.001,.35,.3,0,1,.3]],[[3,9e3,0,.001,2.1,.001,.5,.4,0,1,.5],[3,3e3,0,.001,2.1,.001,.4,.2,0,1,.5]],[[0,392,0,.003,.05,.08,0,.35,.07,1.5,.5],[2,784,0,.003,.03,.1,.01,1,0,1,.3,.05]],[[1,330,-2.2,.003,.04,.22,.04,.25,0,1,.45],[3,2500,-1,.001,0,.12,0,.3,0,1,.4]],[[2,659,0,.003,.06,.25,.015,1,.09,1.5,.5],[2,1318,0,.003,.03,.2,0,1,0,1,.2,.09]],[[0,523,0,.004,.07,.1,0,.3,0,1,.4],[0,659,0,.004,.07,.1,0,.3,0,1,.4,.11],[0,784,0,.004,.07,.1,0,.3,0,1,.4,.22],[0,1047,0,.004,.2,.35,.008,.3,0,1,.5,.33],[2,262,0,.004,.25,.3,0,1,0,1,.35,.33]],[[2,120,-3,.001,.01,.24,0,1,0,1,1],[3,5e3,-1.5,.001,0,.09,0,.35,0,1,.7],[3,2200,0,.01,.03,.16,.3,.15,0,1,.4,.03]],[[1,170,-.9,.012,.05,.17,.06,.2,0,1,.5],[3,3e3,0,.01,.04,.14,.4,.12,0,1,.5]],[[0,2400,-36,.001,.012,.09,.02,.35,0,1,.32],[1,2470,-36,.001,.012,.09,.02,.3,0,1,.26],[2,190,-6,.001,.01,.06,0,1,0,1,.45]],[[2,1700,0,.001,0,.13,0,1,0,1,.6],[2,4700,0,.001,0,.05,0,1,0,1,.3],[2,1790,0,.001,0,.09,0,1,0,1,.3]],[[2,110,-2.5,.002,.01,.2,0,1,0,1,.9],[3,2500,0,.02,.03,.17,.3,.12,0,1,.5,.04]],[[2,90,-1.2,.002,.04,.45,0,1,0,1,.9],[1,180,-1.5,.01,.06,.4,.05,.2,0,1,.45],[3,3e3,0,.02,0,.35,.3,.1,0,1,.4,.12]],[[3,5e3,0,.001,0,.02,0,.5,0,1,.5],[0,260,1.5,.005,.06,.12,0,.25,0,1,.4,.02],[2,1040,.5,.003,.03,.18,.01,1,0,1,.25,.1]],[[2,523,0,.003,.03,.1,0,1,0,1,.4],[2,659,0,.003,.03,.1,0,1,0,1,.4,.07],[2,880,0,.003,.05,.2,.01,1,0,1,.45,.14]],[[0,190,-3,.001,0,.04,0,.6,0,1,.6],[3,6e3,0,.001,0,.02,0,.5,0,1,.5]],[[3,6e3,1.5,.002,.04,.07,.2,.6,0,1,.5],[2,3300,.05,.004,.02,.32,.012,1,0,1,.3,.04],[2,5250,0,.003,0,.22,0,1,0,1,.18,.04],[2,7900,0,.003,0,.12,0,1,0,1,.1,.04]],[[3,1800,7,.07,0,.09,0,.5,0,1,.6],[3,5e3,-6,.01,0,.12,.2,.3,0,1,.4,.08]],[[3,900,1.5,.001,.05,.14,.9,1,0,1,.55],[1,95,.6,.001,.07,.12,.6,.5,.05,2,.35],[2,2600,-4,.001,0,.1,.3,1,0,1,.25],[3,7e3,0,.001,0,.04,0,.6,0,1,.3,.1]],[[3,8e3,-3,.001,.02,.15,0,.5,0,1,.6],[2,500,8,.002,.01,.05,0,1,.03,1.5,.45,.01],[3,1500,-1,.001,.03,.1,.9,1,0,1,.3,.01]]],St=[H.WIND,H.SCRAPE],Ct=(e,t=xt)=>{let n=t[e].map((t,n)=>[bt(t,e*9+n),Math.round((t[11]??0)*yt)]);return Float32Array.from({length:Math.max(...n.map(([e,t])=>t+e.length))},(e,t)=>Math.tanh(n.reduce((e,[n,r])=>e+(n[t-r]??0),0)))},wt=(e,t=yt/10)=>{let n=e.length-t;return Float32Array.from({length:n},(r,i)=>i<t?e[i]*Math.sqrt(i/t)+e[n+i]*Math.sqrt(1-i/t):e[i])},Tt=yt/2,Et=Tt*60/84,Dt=16,Ot=[[5,12,16,19],[2,9,12,17],[-2,5,9,14],[0,7,14,16]],kt=[`0...2..3..1.2...`,`4..6.5..7..6.5..`],At=[3,3e4,0,.001,0,.04,0,.7,0,1,.3],jt=[2,85,-2,.008,0,.2,0,1,0,1,.22],Mt=(e,t,n,r=1,i=1,a=(t.length-1)/r,o=1,s=1)=>{let c=t.length-1,[l,u]=[1/o,1/s];for(let o=0,s=0,d=n%e.length|0;o<a;o++){let n=s|0;e[d]+=i*(t[n]+(t[n+1]-t[n])*(s-n))*Math.min(1,o*l,(a-o)*u)**2,++d==e.length&&(d=0),(s+=r)>=c&&(s-=c)}},Nt=(e,t)=>{let n=0;for(let r=0;r<t.length;r++)e[r]+=t[r],e[r+t.length]+=t[r],n=Math.max(n,Math.abs(e[r]),Math.abs(e[r+t.length]));for(let t=0;t<e.length;t++)e[t]*=.35/n;return e},Pt=()=>{let e=Et*4*Dt,t=/* @__PURE__ */ new Float32Array(44101);for(let e=0;e<=2*Tt;e++){let n=Math.PI*e/Tt;t[e]=Math.sin(220*n)+Math.sin(221*n)+.4*Math.sin(441*n)+.15*Math.sin(659*n)}let n=new Float32Array(e/2);Ot.forEach((e,r)=>e.forEach(e=>Mt(n,t,r*8*Et,2**(e/12),.06,9.5*Et,2*Et,1.5*Et)));let r=new Float32Array(e),i=bt([2,220,0,.004,0,1,.002,1,0,1,.36],1,Tt);bt([2,607,0,.002,0,.25,0,1,0,1,.1],1,Tt).forEach((e,t)=>i[t]+=e);let a=bt(At,1,Tt),o=bt(jt,1,Tt);for(let e=0;e<128;e++){let t=e*Et/2,n=+kt[e>>6][e&15];for(let a=0;n>=0&&a<3;a++)Mt(r,i,t+a*.75*Et,2**((Ot[e>>4&3][n&3]+12*(n>>2))/12),.35**a);e&1&&Mt(r,a,t),(!(e&7)||(e&7)==4&&e>=64)&&Mt(r,o,t)}return Nt(r,n)},Ft=40,It=24,Lt=.5,Rt=`tiny-fps:muted`,zt=()=>{let e=!1;return{unlock:()=>{},listen:()=>{},play:()=>{},loop:()=>({set:()=>{}}),mute:t=>{e=t},get muted(){return e},destroy:()=>{}}},Bt=(e=xt)=>{let t;try{t=new AudioContext}catch{return zt()}let n=(e,n=1)=>{let r=t.createGain();return r.gain.value=n,r.connect(e),r},r=n(t.destination),i=n(r,Lt),a=[],o=!1,s=/* @__PURE__ */ new Set,c=[0,0,0],l=0,u=!1,d=(e,n=yt)=>{let r=t.createBuffer(1,e.length,n);return r.getChannelData(0).set(e),r},f=e=>{let n=t.createBufferSource();return n.buffer=e,n};return{unlock(){if(t.resume().catch(()=>{}),!o){o=!0,e.forEach((t,n)=>{let r=Ct(n,e);a[n]=d(St.includes(n)?wt(r):r)});let t=f(d(Pt(),Tt));t.loop=!0,t.connect(i),t.start()}},listen(e,t){[c,l]=[e,t]},play(e,i,o=1,u=1){let d=0,p=o;if(i){let[e,t,n]=i.map((e,t)=>e-c[t]),r=Math.hypot(e,t,n);p=Math.max(0,1-r/Ft)**2*o,d=(e*Math.cos(l)-n*Math.sin(l))/Math.max(r,1)}let m=a[e];if(!m||!p)return;if(s.size>=It){let e=[...s].reduce((e,t)=>t.vol<e.vol?t:e);if(e.vol>=p)return;e.src.stop(),s.delete(e)}let h=f(m);h.playbackRate.value=u;let g=t.createStereoPanner();g.pan.value=d,h.connect(g).connect(n(r,p));let _={vol:p,src:h};s.add(_),h.onended=()=>s.delete(_),h.start()},loop(e){let i,o;return{set(s,c){!i&&a[e]&&(i=f(a[e]),i.loop=!0,i.connect(o=n(r,0)),i.start()),i&&(o.gain.setTargetAtTime(s,t.currentTime,.08),i.playbackRate.setTargetAtTime(c,t.currentTime,.08))}}},mute(e){u=e,r.gain.setTargetAtTime(+!e,t.currentTime,.05)},get muted(){return u},destroy:()=>void t.close().catch(()=>{})}},Vt=()=>{try{return localStorage.getItem(Rt)==`1`}catch{return!1}},Ht=e=>{e.mute(!e.muted);try{localStorage.setItem(Rt,e.muted?`1`:`0`)}catch{}return e.muted},Ut=(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+Ee(e),z:e.z,dx:-n*a,dy:i,dz:-r*a,left:80,burst:!1,power:e.power??1}},Wt=.12,Gt=1.2,Kt=e=>[e.x,e.y,e.z],qt=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],Jt=e=>{let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set;return{fire(r,i){let a=Ut(r),[o,s]=[Kt(a),[a.dx,a.dy,a.dz]],c=le(e,o,s,80,f),l=r.id<<8|r.shots;n.delete(l),t.set(l,{own:!0,by:r.id,t0:i,o,t:i,d:s,end:o.map((e,t)=>e+s[t]*c),pop:c<80,due:1/0,power:a.power??1})},snapshot(e,r,i){let a=/* @__PURE__ */ new Set;for(let o of e){let e=o.by<<8|o.id,s=t.get(e);a.add(e),o.by==r&&(s?.own||n.has(e))?o.burst&&(n.delete(e),s&&([s.end,s.pop]=[Kt(o),!0])):(s||t.set(e,s={own:!1,by:o.by,t0:i,o:Kt(o),t:i,d:[0,0,0],pop:!1,due:1/0,power:o.power??1}),o.burst?[s.end,s.pop,s.due]=[Kt(o),!0,i]:[s.o,s.t,s.d]=[Kt(o),i,[o.dx,o.dy,o.dz]])}for(let[e,n]of t)!n.own&&!a.has(e)&&n.due==1/0&&(n.due=i)},frame(e,r){let i=[],a=[];for(let[o,s]of t){let c=s.own?e:e-100,l=(c-s.t)*40/1e3;if(s.end&&l>=qt(s.end.map((e,t)=>e-s.o[t]),s.d)||c>=s.due){s.pop&&a.push(s.end),s.own&&n.add(o),t.delete(o);continue}if(c<s.t0)continue;let u=s.o.map((e,t)=>e+s.d[t]*l);s.born??=e,s.from??=r(s.by)??u;let d=Math.min(1,(e-s.born)/1e3/Wt),f=s.from,p=u.map((e,t)=>f[t]+(e-f[t])*d*(2-d));i.push({p,d:s.d,tail:Math.min(Gt,Math.hypot(...p.map((e,t)=>e-f[t]))),power:s.power})}return{orbs:i,bursts:a}}}},U=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],Yt=(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]],Xt=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],Zt=(e,t,n)=>[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n],W=e=>{let t=Math.hypot(...e)||1;return[e[0]/t,e[1]/t,e[2]/t]},Qt=(e,t,n=0)=>{let[r,i,a,o,s,c]=[e,t,n].flatMap(e=>[Math.sin(e),Math.cos(e)]),l=[i,0,-r],u=[r*a,o,i*a];return[l.map((e,t)=>e*c-u[t]*s),u.map((e,t)=>e*c+l[t]*s),[-r*o,a,-i*o]]},$t=(e,t,n=[0,0,0])=>{let r=[],i=e.filter((t,n)=>!n||Math.hypot(t[0]-e[n-1][0],t[1]-e[n-1][1])>1e-9),a=i.slice(1).map(([e,t],n)=>{let[r,a]=i[n],o=Math.hypot(e-r,t-a);return[(t-a)/o,-(e-r)/o]}),o=i.map(([e],t)=>{let[n,r]=[0,1].map(e=>(a[t-1]?.[e]??0)+(a[t]?.[e]??0)),i=Math.hypot(n,r);return e?[n/i,r/i]:[0,Math.sign(r)]}),s=(e,a)=>{let[s,c]=i[a],[l,u]=[Math.cos(e*V/t),Math.sin(e*V/t)];r.push(n[0]+s*l,n[1]+s*u,n[2]-c,o[a][0]*l,o[a][0]*u,-o[a][1])};for(let e=1;e<i.length;e++)for(let n=0;n<t;n++)[...i[e-1][0]?[[n,e-1],[n+1,e-1],[n+1,e]]:[],...i[e][0]?[[n,e-1],[n+1,e],[n,e]]:[]].forEach(([e,t])=>s(e,t));return r},en=(e,t,n,[r,i],a)=>{let o=(e,t,n,r)=>Array.from({length:t},(i,a)=>{let o=a*V/t/4;return[e*Math.sin(o),n-r*e*Math.cos(o)]});return $t([...r?o(t[0],r,0,1):[[0,0]],...t.map((n,r)=>[n,e*r/(t.length-1)]),...i?o(t[t.length-1],i,e,-1).reverse():[[0,e]]],n,a)},tn=(e,[t,n,r])=>Array.from({length:e.length*(10/6)},(i,a)=>{let[o,s]=[Math.floor(a/10),a%10];return s<6?e[o*6+s]:[t,n,-1,r][s-6]}),nn=[[5,1],[7,2],[10,3]],rn=/* @__PURE__ */ new Map,an=(e,t,n,r=[1,1])=>{let[i,a]=nn[e];!e&&n.length>3&&(n=[n[0],n[n.length>>1],n[n.length-1]]);let o=`${e} ${t} ${n} ${r}`,s=rn.get(o);return s||(s=tn(en(t,n,i,r.map(e=>Math.ceil(a*e))),[1,1,1]),rn.set(o,s)),s},on=(e,t,n,[r,i,a],o,s,c=[1,1,1])=>{let[l,u,d]=typeof s==`number`?[s,s,s]:s,f=l==u&&u==d,[p,m,h,g,_,v,y,b,x]=[...r,...i,...a],S=n[0]+p*o[0]+g*o[1]+y*o[2],C=n[1]+m*o[0]+_*o[1]+b*o[2],w=n[2]+h*o[0]+v*o[1]+x*o[2];for(let n=0;n<t.length;n+=10){let[r,i,a]=[t[n]*l,t[n+1]*u,t[n+2]*d],[o,s,T]=[t[n+3],t[n+4],t[n+5]];if(!f){[o,s,T]=[o/l,s/u,T/d];let e=Math.sqrt(o*o+s*s+T*T)||1;[o,s,T]=[o/e,s/e,T/e]}e.push(S+p*r+g*i-y*a,C+m*r+_*i-b*a,w+h*r+v*i-x*a,p*o+g*s-y*T,m*o+_*s-b*T,h*o+v*s-x*T,t[n+6]*c[0],t[n+7]*c[1],t[n+8],t[n+9]*c[2])}},sn=(e,t)=>{let n=e[0]*t[0]+e[1]*t[1]+e[2]*t[2],r=t.map((t,r)=>t-e[r]*n),i=Math.hypot(...r)||1,[a,o,s]=r.map(e=>e/i);return[[a,o,s],[o*e[2]-s*e[1],s*e[0]-a*e[2],a*e[1]-o*e[0]],e]},cn=(e,t,n,r,i,a,o=1,s)=>{let c=[r[0]-n[0],r[1]-n[1],r[2]-n[2]],l=Math.hypot(...c)||1,[u,d]=typeof o==`number`?[o,o]:o;on(e,t,n,sn([c[0]/l,c[1]/l,c[2]/l],i),[0,0,0],[u,d,l/a],s)},ln=2.4,un=[1,.62],dn=8,fn=28,pn=2.2,mn=.04,hn=.045,gn=e=>{let t=parseInt(u[e].slice(1),16);return[t>>16,t>>8&255,t&255].map(e=>e/255)},_n=(e,t,n)=>e.flatMap((e,r)=>{if(e.state===_.DROPPED)return[{team:r,at:[e.x,e.y,e.z],dropped:!0}];if(e.state===_.CARRIED){let t=n(e.by);return t?[{team:r,at:[t.x,t.y,t.z],by:{yaw:t.yaw,vx:t.vx,vz:t.vz}}]:[]}return[{team:r,at:t[r]}]}),vn=[[1,0,0],[0,1,0],[0,0,1]],yn=(e,t,n)=>{for(let r=t;r<e.length;r+=10)e[r+6]*=n,e[r+7]*=n,e[r+9]*=n,e[r+8]=-2},bn=(e,t,n,r,[i,a,o])=>{let[s,c,l]=[n[0]-t[0],n[1]-t[1],n[2]-t[2]],[u,d,f]=[r[0]-t[0],r[1]-t[1],r[2]-t[2]],p=[c*f-l*d,l*u-s*f,s*d-c*u],m=Math.hypot(...p)||1;for(let s of[t,n,r])e.push(...s,p[0]/m,p[1]/m,p[2]/m,i,a,-1,o)},xn=(e,t,n,r,i)=>{for(let a=0;a<fn;a++){let[o,s]=[a,a+1].map(e=>e*2*Math.PI/fn),c=(e,n)=>[t[0]+e*Math.cos(n),t[1],t[2]+e*Math.sin(n)];bn(e,c(n,o),c(r,s),c(r,o),i),bn(e,c(n,o),c(n,s),c(r,s),i)}},Sn=(e,t,n,r)=>{for(let i=0;i<fn;i++){let[a,o]=[i,i+1].map(e=>e*2*Math.PI/fn);bn(e,t,[t[0]+n*Math.cos(o),t[1],t[2]+n*Math.sin(o)],[t[0]+n*Math.cos(a),t[1],t[2]+n*Math.sin(a)],r)}},Cn=(e,t,n,r)=>{Sn(e,[t[0],t[1]+mn,t[2]],d,n.map(e=>e*.4));let i=e.length;xn(e,[t[0],t[1]+hn,t[2]],d-.16,d,n),yn(e,i,pn*(.75+.25*Math.sin(r*3)))},wn=(e,t,n,[r,i],a,o,s)=>{let c=[-n[2],0,n[0]],l=(e,s)=>{let l=a*e*Math.sin(o*7-e*5),u=i*s*(1-e);return[t[0]+n[0]*r*e+c[0]*l,t[1]-u+.12*r*e*Math.sin(o*5-e*4)*a,t[2]+n[2]*r*e+c[2]*l]};for(let t=0;t<dn;t++){let[n,r]=[t/dn,(t+1)/dn],[i,a,o,c]=[l(n,0),l(r,0),l(r,1),l(n,1)],u=[(a[1]-i[1])*(c[2]-i[2])-(a[2]-i[2])*(c[1]-i[1]),(a[2]-i[2])*(c[0]-i[0])-(a[0]-i[0])*(c[2]-i[2]),(a[0]-i[0])*(c[1]-i[1])-(a[1]-i[1])*(c[0]-i[0])],d=Math.hypot(...u)||1,f=(e,t)=>[e[0]+u[0]/d*.004*t,e[1]+u[1]/d*.004*t,e[2]+u[2]/d*.004*t];for(let t of[1,-1]){let n=[i,a,o,c].map(e=>f(e,t)),[r,l,u,d]=t>0?n:[n[0],n[3],n[2],n[1]];bn(e,r,l,u,s),bn(e,r,u,d,s)}}},Tn=(e,t,n,r)=>{cn(e,an(1,1,[1,1],[0,0]),t,n,[.6,0,.8],1,.045,[.82,.84,.9]);let i=e.length;on(e,an(1,0,[1,1]),n,vn,[0,0,0],.09,r),yn(e,i,pn)},En=(e,t,n,r)=>{let[i,a,o]=t.at,s=r+t.team*1.7;if(t.by){let{yaw:r,vx:c,vz:l}=t.by,u=-Math.sin(r),d=-Math.cos(r),f=Math.hypot(c,l),p=[i-u*.28,a+.55,o-d*.28],m=[i-u*.38,a+.55+ln-.2,o-d*.38],[h,g]=f>1?[-c/f,-l/f]:[-u,-d];Tn(e,p,m,n);let _=Math.min(1,f/8);wn(e,m,[h,0,g],[un[0]*(.7+.5*_),un[1]],.1+.16*_,s,n);return}if(t.dropped){let t=i*12.9898+o*78.233,[c,l]=[Math.cos(t),Math.sin(t)],u=[i+c*2.3,a+.6,o+l*2.3];Tn(e,[i,a+.06,o],u,n),wn(e,u,[c,0,l],[un[0]*.8,un[1]*.8],.04,s,n);let f=e.length;xn(e,[i,a+hn,o],d-.1,d,n),yn(e,f,pn*(.5+.5*Math.abs(Math.sin(r*5))));return}let c=[i,a+ln,o];Tn(e,[i,a,o],c,n);let l=.6+t.team*Math.PI;wn(e,c,[Math.cos(l),0,Math.sin(l)],un,.18,s,n)},Dn={SPOT:0,POINT:1},On=9,kn=6,An=e=>{let{ctf:t,t:n}=e;if(!t)return[];let r=([e,t,n],r,i,a)=>({kind:Dn.POINT,p:[e,t,n],d:[0,-1,0],cone:0,range:i,color:gn(r).map(e=>e*a),shadow:!1});return[...t.bases.map(([e,t,i],a)=>r([e,t+1.2,i],a,On,1.1+.3*Math.sin(n*3))),...t.flags.filter(e=>e.dropped).map(e=>r([e.at[0],e.at[1]+.8,e.at[2]],e.team,kn,.9))]},jn=.06,Mn=.16,Nn=.22,Pn=12,Fn=.05,In=10,Ln=4,Rn=[[.022,[.4,.15,1.3],0],[.007,[.7,1.7,2.2],.02]],zn=[[.22,[.2,.45,1.6],0],[.08,[2,2.6,3.6],.04]],Bn=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],Vn=(e,t)=>[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]],Hn=e=>{let t=Math.hypot(...e)||1;return[e[0]/t,e[1]/t,e[2]/t]},Un=(e,t,[n,r,i])=>e.push(...t,0,1,0,n,r,-2,i),Wn=(e,t,n)=>Math.min(Math.max(Math.hypot(...Bn(e,t))/5,n),2.5),Gn=(e,t,n,r,i,a,o,s=r,c=1)=>{let l=Bn(n,t),u=Vn(l,Bn(t,a));Math.hypot(...u)<1e-6*Math.hypot(...l)&&(u=Vn(l,[0,1,0])),u=Hn(u);let[d,f,p,m]=[[t,r],[t,-r],[n,-s],[n,s]].map(([e,t])=>{let n=Hn(Bn(a,e)),r=t*Wn(a,e,c);return e.map((e,t)=>e+u[t]*r+n[t]*o)});for(let t of[d,f,p,d,p,m])Un(e,t,i)},Kn=(e,t,n,r,i,a=0,o=8)=>{let s=Bn(t,i),c=Hn(Vn(s,[0,1,0])),l=Hn(Vn(c,s)),u=n*Wn(i,t,.1),d=Hn(s).map((e,n)=>t[n]-e*a),f=e=>{let[t,n]=[Math.cos(e*2*Math.PI/o)*u,Math.sin(e*2*Math.PI/o)*u];return[0,1,2].map(e=>d[e]+c[e]*t+l[e]*n)};for(let t=0;t<o;t++)for(let n of[d,f(t),f(t+1)])Un(e,n,r)},qn=()=>{let e=[],t=[],n=[],r=[],i=[0,0,0],a=7,o=()=>(a=a*16807%2147483647)/2147483647*2-1,s=(e,t)=>{let r=[o(),o(),o()].map(e=>e*t),i=[0,1,2].map(t=>e[t]+r[t]),a=[0,1,2].map(n=>e[n]+r[n]/2+o()*t*.3);n=[...n,{a:e,m:a,b:i,age:0}].slice(-24)},c=(e,n,r)=>{for(let i=0;i<n;i++)t.push({p:e,v:[o()*r,o()*r+1.5,o()*r],age:0});t=t.slice(-192)};return{flash(t,n){e=[...e,{p:t,age:0,own:n}].slice(-16)},burst(t){e=[...e,{p:t,age:0,splash:!0}].slice(-16),c(t,Pn,4)},orbs(e){r=e},shock(e){c(e,In,4);for(let t=0;t<In;t+=2)s(e,.6)},crackle(e){for(let t=0;t<2;t++)o()>0&&s([e[0]+o()*.4,e[1]+o()*.7,e[2]+o()*.4],.35)},spit(e){t.push({p:e,v:[o(),o()+2,o()],age:0})},mount(t){e.forEach(e=>e.own&&(e.p=t))},update(r){for(let i of[...e,...t,...n])i.age+=r;e=e.filter(e=>e.age<(e.splash?Mn:jn)),t=t.filter(e=>e.age<Nn),n=n.filter(e=>e.age<Fn);for(let e of t)e.v[1]-=9*r,e.p=e.p.map((t,n)=>t+e.v[n]*r)},draw(a,o){i=o;for(let{p:e,d:t,tail:n,power:i=1}of r){let r=e.map((e,r)=>e-t[r]*n),s=1+.25*(i-1);zn.forEach(([t,i,c])=>{Kn(a,e,t*s,i,o,c),n>.01&&Gn(a,e,r,t*.5*s,i,o,c,0,.1)})}for(let{p:t,age:n,splash:r}of e){let e=1-n/(r?Mn:jn);zn.forEach(([n,i,s])=>Kn(a,t,r?n*(3-2*e):n*.7*e,i.map(t=>t*(.4+.6*e)),o,s))}for(let{a:e,m:t,b:r,age:i}of n){let n=1-i/Fn;for(let[i,s]of[[e,t],[t,r]])Rn.forEach(([e,t,r])=>Gn(a,i,s,e*.5*n,t,o,r))}for(let{p:e,age:n}of t){let t=1-n/Nn;Kn(a,e,.022*t,[1.4*t+.4,2.2*t+.3,3],o,0,4)}},lights(){let t=(e,t,n,r)=>({kind:Dn.POINT,p:e,d:[0,-1,0],cone:0,range:t,color:r.map(e=>e*n),shadow:!1}),a=e=>Math.hypot(...Bn(e.p,i));return[...n.slice(-2).map(e=>t(e.m,3,.8*(1-e.age/Fn),[.3,.7,1.3])),...e.slice(-4).map(e=>e.splash?t(e.p,7,2*(1-e.age/Mn),[.35,.7,1.6]):t(e.p,6,1.3*(1-e.age/jn),[.25,.55,1.6])),...[...r].sort((e,t)=>a(e)-a(t)).slice(0,Ln).map(e=>t(e.p,4,1,[.25,.5,1.4]))]}}},Jn=(e,t)=>{if(!e)return[];if(e.over||t.over)return e.over&&!t.over?[{kind:`start`}]:[];let n=[];for(let r of[0,1])t.score[r]>e.score[r]&&n.push({kind:`capture`,team:r});let r=n.length>0;t.flags.forEach((t,i)=>{let a=e.flags[i];t.state===_.CARRIED&&(a.state!==_.CARRIED||a.by!==t.by)?n.push({kind:`take`,flag:i,by:t.by}):t.state===_.DROPPED&&a.state===_.CARRIED?n.push({kind:`drop`,flag:i}):t.state===_.HOME&&(a.state===_.DROPPED||a.state===_.CARRIED&&!r)&&n.push({kind:`return`,flag:i})});for(let r of t.players)r.stun>(e.players.find(e=>e.id===r.id)?.stun??1/0)&&n.push({kind:r.zap?`shock`:`tackle`,who:r.id,by:r.by,at:[r.x,r.y+1,r.z]});return n},Yn=(e,t,n)=>{let r=e=>l[e].toLowerCase();switch(e.kind){case`take`:{let i=1-e.flag;return{team:i,text:e.flag===t.team?`${l[i]} took your flag`:e.by===t.id?`You took the ${r(e.flag)} flag`:`${n(e.by)} took the ${r(e.flag)} flag`}}case`drop`:return{team:e.flag,text:e.flag===t.team?`Your flag was dropped`:`${l[e.flag]} flag dropped`};case`return`:return{team:e.flag,text:e.flag===t.team?`Your flag returned`:`${l[e.flag]} flag returned`};case`capture`:return{team:e.team,text:`${l[e.team]} scored`};case`tackle`:return e.by===t.id?{team:t.team,text:`Tackled ${n(e.who)}!`}:void 0;case`shock`:return;default:return{text:`New match`}}},Xn=(e,t)=>{let{team:n}=t;switch(e.kind){case`take`:return[{id:H.TAKE,rate:e.flag===n?.8:1}];case`drop`:return[{id:H.DROP,rate:e.flag===n?1:.85}];case`return`:return[{id:H.RETURN,rate:e.flag===n?1:.85}];case`capture`:return[{id:H.CAPTURE,rate:e.team===n?1:.8}];case`tackle`:return e.who===t.id?[{id:H.TACKLE},{id:H.GRUNT}]:e.by===t.id?[{id:H.TACKLE,gain:.8,rate:1.1}]:[{id:H.TACKLE,at:e.at}];case`shock`:return e.who===t.id?[{id:H.ZAP}]:e.by===t.id?[]:[{id:H.ZAP,at:e.at}];default:return[]}},Zn=e=>{let[t,n]=[e&v.LEFT,e&v.RIGHT];return t&&!n?y.LEFT:n&&!t?y.RIGHT:e&v.FORWARD?y.THRUST:y.SLASH},Qn=(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},$n=e=>{if(e.mode===x.GROUND){if(e.cut===y.LUNGE){let[t,n]=he(e.yaw);e.vx=t*13,e.vz=n*13,e.dash=60,e.ev|=C.DASH}else e.cut===y.LEAP&&(e.vy=g,e.ev|=C.JUMP)}},er={NONE:0,SHOT:1,CUT:2},tr=(e,t,n,r,i=!0)=>{let a=e.down>0;if(tt(e,a?{...t,keys:0}:t,n,r),e.zap=!!e.stun&&!!e.zap,a)return e.down>0&&!--e.down&&Ce(e,n,r),er.NONE;let{rack:o,blade:s}=n.def.teams[r],c=!!o&&Qn(e,o,1.2);i&&c&&!e.rack&&(e.ammo=60),e.rack=c,e.blade=!!e.blade||i&&!!s&&Qn(e,s,1.2),e.cool=Math.max(0,e.cool-1),e.swing=Math.max(0,(e.swing??0)-1),e.wield=e.blade&&(e.swing>0||!!(t.keys&v.BLADE)||e.ammo<0);let l=e.mode===x.HANG||e.mode===x.CLIMB;if(!i)return e.charge=0,er.NONE;let u=h[e.cut??0];if(e.swing&&u.ticks-e.swing===u.strike)return er.CUT;if((e.wield||l||e.ammo<=0)&&(e.charge=0),t.keys&v.FIRE&&!l){let n=h[e.cut??0].ticks-e.swing,r=!!(t.keys&v.SPECIAL)&&(!e.swing||(e.cut??0)<4&&n<=18);e.wield&&(!e.swing||r)?(e.cut=Zn(t.keys)+(r?4:0),e.swing=h[e.cut].ticks,$n(e)):!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(nr(e.charge),e.ammo),e.charge=0,e.ammo-=e.power,e.shots=e.shots+1&255,e.cool=7,er.SHOT;return er.NONE},nr=e=>e<10?1:1+Math.floor(4*(e-10)/50),G={PELVIS:0,SPINE:1,CHEST:2,NECK:3,HEAD:4,CLAVICLE_L:5,ARM_L:6,FOREARM_L:7,HAND_L:8,CLAVICLE_R:9,ARM_R:10,FOREARM_R:11,HAND_R:12,THIGH_L:13,SHIN_L:14,FOOT_L:15,TOE_L:16,THIGH_R:17,SHIN_R:18,FOOT_R:19,TOE_R:20},rr=Object.keys(G).length,ir=[-1,0,1,2,3,2,5,6,7,2,9,10,11,0,13,14,15,0,17,18,19],ar=[[0,.98,0],[0,.12,0],[0,.2,0],[0,.22,0],[0,.1,0],[-.04,.17,0],[-.15,0,0],[-.03,-.29,0],[0,-.26,0],[.04,.17,0],[.15,0,0],[.03,-.29,0],[0,-.26,0],[-.1,-.05,0],[0,-.44,0],[0,-.43,0],[0,-.04,-.13],[.1,-.05,0],[0,-.44,0],[0,-.43,0],[0,-.04,-.13]],or=[0,0,0,1],sr=(e=[0,0,0],t=0)=>({at:e,yaw:t,hips:[0,0,0],rot:Array.from({length:rr},()=>[...or])}),K=([e,t,n,r],[i,a,o,s])=>[r*i+e*s+t*o-n*a,r*a-e*o+t*s+n*i,r*o+e*a-t*i+n*s,r*s-e*i-t*a-n*o],q=([e,t,n],r)=>{let i=Math.sin(r/2);return[e*i,t*i,n*i,Math.cos(r/2)]},J=(e,[t,n,r])=>{let[i,a,o,s]=e,[c,l,u]=[2*(a*r-o*n),2*(o*t-i*r),2*(i*n-a*t)];return[t+s*c+a*u-o*l,n+s*l+o*c-i*u,r+s*u+i*l-a*c]},cr=(e,t,n)=>{let r=e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3],i=r<0?-1:1;if(r*=i,r>.9995){let r=e.map((e,r)=>e+(i*t[r]-e)*n),a=Math.hypot(...r);return r.map(e=>e/a)}let a=Math.acos(r),[o,s]=[Math.sin((1-n)*a),Math.sin(n*a)*i],c=1/Math.sin(a);return e.map((e,n)=>(e*o+t[n]*s)*c)},lr=e=>{let t=[],n=[],r=q([0,1,0],e.yaw);for(let i=0;i<rr;i++){let a=ir[i],o=a<0?r:n[a];n[i]=K(o,e.rot[i]);let s=J(o,i===0?ar[0].map((t,n)=>t+e.hips[n]):ar[i]),c=a<0?e.at:t[a];t[i]=[c[0]+s[0],c[1]+s[1],c[2]+s[2]]}return{pos:t,rot:n}},ur=(e,t,n,r,i)=>{let a=e[t]-n,o=e[t+1]+r*a,s=Math.exp(-r*i);return e[t]=n+(a+o*i)*s,e[t+1]=(e[t+1]-r*o*i)*s,e[t]},dr=Math.PI*2,[Y,fr,pr]=[[1,0,0],[0,1,0],[0,0,1]],[mr,hr,gr]=[.44,.43,.06],[_r,vr]=[.2915,.26],yr=mr+hr,X=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),br=e=>(e=X(e))*e*(3-2*e),xr=(e,t)=>Math.atan2(Math.sin(t-e),Math.cos(t-e)),Sr=e=>[-e[0],-e[1],-e[2],e[3]],Cr=(e,t)=>{let n=Math.sin(e*78.233+t*37.719)*43758.5453;return n-Math.floor(n)},wr=(e,t)=>[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]],Tr=(e,t,n,r=0)=>e.map((e,i)=>e*t+n[i]*r),Er=e=>Tr(e,1/(Math.hypot(...e)||1),e),Dr=(e,t)=>Tr(e,1,t,-(e[0]*t[0]+e[1]*t[1]+e[2]*t[2])),Or=(e,t,n)=>{let r=Math.max(n-Math.abs(e-t),0)/n;return Math.min(e,t)-r*r*n/4},kr=(e,t)=>{let n=[-t[0],-t[1],-t[2]],r=wr(e,n),i=[e[0]+n[1]+r[2],e[0]-n[1]-r[2],n[1]-e[0]-r[2],r[2]-e[0]-n[1]],a=i.indexOf(Math.max(...i)),[o,s,c,l]=[1+i[a],n[2]-r[1],r[0]-e[2],e[1]-n[0]],[u,d,f]=[n[0]+e[1],r[0]+e[2],r[1]+n[2]],p=[[s,c,l,o],[o,u,d,s],[u,o,f,c],[d,f,o,l]][a],m=Math.hypot(...p);return p.map(e=>e/m)},Ar=(e,t,n,r=mr,i=hr,a=1)=>{let o=Tr(t,1,e,-1),s=Math.hypot(...o)||1e-6,c=X(s,.2,(r+i)*.999),l=Tr(o,1/s,o),u=Er(Dr(n,l)),d=X((r*r+c*c-i*i)/(2*r*c),-1,1),f=Tr(l,d,u,Math.sqrt(1-d*d)),p=Er(Tr(l,c,f,-r)),m=Tr(wr(l,u),a,l);return[kr(m,f),kr(m,p)]},jr=e=>{let[t,n]=[Math.abs(e),e>0?.07:.13],[r,i]=[Math.sin(t),Math.cos(t)];return[(e>0?-1:1)*(n*(1-i)+gr*r),gr*(i-1)+n*r]},Mr=[1.4,5,9],Nr={f:[.95,1.4,1.8],s:[.88,.95,1],k:[.45,.42,.4],lat:[.11,.09,.07],lift:[.09,.3,.4],d0:[.002,.01,.01],d1:[.008,.075,.05],td:[.12,.1,-.12],to:[-.45,-.6,-.8],pr:[.07,.1,.14],po:[.06,.06,.05],pt:[.04,.1,.16],pa:[.02,.05,.06],cc:[.1,.16,.22],aa:[.35,.8,1],am:[-.05,.12,.25],em:[.3,1.4,1.75],ea:[.12,.25,.3],ab:[.1,.12,.1],sw:[.025,.012,.008],hop:[0,.02,.025]},Z={AIR:0,RISE:1,DASH:2,WALL_L:3,WALL_R:4,HANG:5,CLIMB:6,SLIDE:7,STUN:8,TUCK:9,DOWN:10},Pr=[[-.05,.12,0,.35,.5,.15,.7,.25,.5,.25,.5,1.15,0,0],[0,.1,0,1.2,1.5,-.35,.3,2.4,.3,2.2,.3,.35,0,0],[-.35,1.25,0,1.1,1.3,-.6,.25,-1,.3,-1,.3,.25,0,0],[],[-.02,.2,.4,.9,1.2,.6,1.3,.8,1,.3,.5,.6,0,.1],[.07,.05,0,.2,.3,.1,.2,3,.2,3,.2,.2,-.22,0],[0,.5,0,.2,.4,1.4,1.7,1,1.4,1,1.4,.15,-.1,0],[-.78,-1.1,0,1.1,1.8,1.4,.1,.5,.8,.4,.5,.8,0,0],[0,0,0,0,0,0,0,.8,1.6,.8,1.6,.2,0,0],[-.05,.9,0,1.7,2,1.7,2,.8,1.6,.8,1.6,.2,0,0],[-.5,.35,0,1.3,.3,1.1,.2,.4,.4,.2,.3,.6,0,0]],Fr=Pr[Z.WALL_R];Pr[Z.WALL_L]=[Fr[0],Fr[1],-Fr[2],Fr[5],Fr[6],Fr[3],Fr[4],Fr[9],Fr[10],Fr[7],Fr[8],Fr[11],Fr[12],-Fr[13]];var Ir=[G.PELVIS,G.SPINE,G.CHEST,G.ARM_L,G.FOREARM_L,G.ARM_R,G.FOREARM_R,G.THIGH_L,G.SHIN_L,G.FOOT_L,G.TOE_L,G.THIGH_R,G.SHIN_R,G.FOOT_R,G.TOE_R],Lr=e=>{let t=[],[n,r,i]=[e[1],e[2],e[11]];return t[G.PELVIS]=K(q(pr,r*.4),q(Y,-.3*n)),t[G.SPINE]=K(q(pr,r*.3),q(Y,-.35*n)),t[G.CHEST]=t[G.SPINE],t[G.ARM_L]=K(q(pr,-i),q(Y,e[7])),t[G.FOREARM_L]=q(Y,e[8]),t[G.ARM_R]=K(q(pr,i),q(Y,e[9])),t[G.FOREARM_R]=q(Y,e[10]),[G.THIGH_L,G.THIGH_R].forEach((r,i)=>{t[r]=q(Y,e[3+2*i]+.3*n),t[r+1]=q(Y,-e[4+2*i]),t[r+2]=q(Y,-.35),t[r+3]=Rr}),t},Rr=[0,0,0,1],zr=[[0,0],[1,0],[-1,0],[0,1],[0,-1]],[Br,Vr,Hr,Ur,Wr,Gr,Kr,qr,Jr,Yr,Xr,Zr]=[0,2,4,6,8,10,12,14,16,18,20,22],Qr=5,$r=.1,ei=()=>{let e=sr(),t={},n=Array(Zr+2*Pr.length).fill(0),r=[0,1].map(()=>({x:0,y:0,z:0,px:0,pz:0,gy:0,lx:0,ly:0,lz:0,dl:0,tg:0,u:0,x0:0,w:0,th:0,tw:1,on:!0})),i={},a=!1,[o,s,c,l,u,d,f]=[0,0,0,0,0,0,0],[p,m,h,g,_]=[0,0,0,.6,0],[v,y,b,S]=[!1,!0,!0,-1],C=[1,1,1,0,.06,0],[w,T,E]=[0,0,[0,0,0]],[D,O,k,A]=[1,[1,0],[0,0,0,-1,0],!1],j=(e,j,ee)=>{j=X(j,0,.1),y=!a||Math.hypot(e.x-i.x,e.y-i.y,e.z-i.z)>Qr;let M=e.mode==x.GROUND||e.mode==x.CROUCH,te=e.mode==x.AIR,N=(e,t,r)=>{y?[n[e],n[e+1]]=[t,0]:ur(n,e,t,r,j)};N(Gr,e.vx,12),N(Kr,e.vz,12);let[P,F]=[n[Gr],n[Kr]];l=Math.sqrt(P*P+F*F);let I=l>1?Math.atan2(-P,-F):e.yaw;if(y){let t=e.id;C=[1+.08*(Cr(t,0)-.5),1+.16*(Cr(t,1)-.5),1+.16*(Cr(t,2)-.5),.03*(Cr(t,3)-.5),.05+.04*Cr(t,4),Cr(t,6)],o=l>.25?Cr(t,5):Cr(t,5)<.5?.05:.55,[s,c,h,p,m,v,S]=[0,0,0,0,0,!1,-1],f=I,d=e.yaw}else te&&i.mode==x.AIR&&e.jumps<i.jumps&&e.vy>i.vy&&(h=.001),te?m=Math.min(m,e.vy):(i.mode==x.AIR&&(M||e.mode==x.SLIDE)&&m<-3&&(p=X(-m/12,.3)),m=0),h&&=(h+=j*(te?2.2:8),h>=1?0:h);c+=j,p*=Math.exp(-j*7);let L=zr[e.wall],R=e.mode==x.WALLRUN,z=e.mode==x.HANG||e.mode==x.CLIMB;R&&([D,O]=[L[0]*Math.cos(I)-L[1]*Math.sin(I)<0?-1:1,L]),z&&e.wall&&(d=Math.atan2(-L[0],-L[1]),e.mode!=x.HANG&&A||(k=[e.x,e.z,L[0],L[1],0]),k[4]=e.edge),A=z,[te,te&&e.vy>.5,e.dash>50,R&&D<0,R&&D>0,e.mode==x.HANG,e.mode==x.CLIMB,e.mode==x.SLIDE,e.stun>0,h&&Math.sqrt(Math.sin(Math.PI*h))].forEach((e,t)=>N(Zr+2*t,+e,12)),N(Zr+2*Z.DOWN,+(e.down>0),5),N(Wr,+(e.mode==x.CROUCH),12),N(Jr,z?X((1.7-k[4]+e.y)/1.2):0,14),N(Ur,p,26);let ne=y||l<2?0:xr(f,I)/Math.max(j,.001);f=I;let re=y?0:-((e.vx-i.vx)*Math.sin(u)+(e.vz-i.vz)*Math.cos(u))/Math.max(j,.001),ie=-(P*Math.sin(u)+F*Math.cos(u)),ae=Math.sign(ie)*X((Math.abs(ie)-1.5)*.028,0,.22);N(Br,(ie>0?ae:ae/2)+X(re*.012,-.3,.3),7),N(Vr,X(.3*Math.atan(l*ne/9.8),-.4,.4),8),N(Hr,.5*Math.sin(xr(e.yaw,I))*X(l/2),10);let oe=e=>n[Zr+2*e],se=X(oe(Z.DASH)+oe(Z.WALL_L)+oe(Z.WALL_R)+oe(Z.SLIDE)),ce=e.yaw+xr(e.yaw,I)*se;u=ce+xr(ce,d)*X(oe(Z.HANG)+oe(Z.CLIMB)),u+=n[Hr]*(1-se);let[le,ue]=[Math.cos(u),Math.sin(u)];N(Yr,e.stun>0?X(-(e.vx*ue+e.vz*le)/4.2,-1,1):0,18),N(Xr,e.stun>0?X((e.vx*le-e.vz*ue)/4.2,-1,1):0,18),[w,T,E]=[e.yaw,e.pitch,[e.x,e.y,e.z]];let B=l<Mr[1]?0:1,V=X((l-Mr[B])/(Mr[B+1]-Mr[B]));for(let e in Nr){let n=Nr[e];t[e]=n[B]+(n[B+1]-n[B])*V}_=br((l-.2)/1.2);let de=t.f*C[0]*(.35+.65*X(l/1.4))*(1+.5*oe(Z.STUN));g=X(t.s*de/Math.max(l,.1),.2,.62);let[fe,pe]=[Math.cos(u),-Math.sin(u)],me=(t,n)=>{let r=ee?ee(t,n):e.y;return Math.abs(r-e.y)<.6?r:e.y},he=l<=.25,ge=M&&(!he||!r[0].on||!r[1].on);(ge||R)&&(o=(o+(he&&!R?.9:de)*j)%1),r.forEach((n,a)=>{let c=a?1:-1,l=(o+a/2)%1,[d,f]=[e.x+fe*c*$r,e.z+pe*c*$r],p=u-c*C[4],[m,h]=[-Math.sin(p),-Math.cos(p)];if(M){if(v||([n.px,n.pz,n.gy,n.on]=[d,f,me(d,f),!0],y&&([n.x,n.y,n.z,n.th,n.tw]=[d,n.gy+gr,f,0,1])),n.on&&ge&&(l>=g||Math.hypot(n.x-d,n.z-f)>.56))[n.on,n.lx,n.ly,n.lz,n.dl]=[!1,n.x-e.x,n.y,n.z-e.z,l];else if(!n.on&&l<n.u){let[e]=jr(t.td*_);[n.on,n.px,n.pz,n.gy]=[!0,n.x-m*e,n.z-h*e,n.tg],s++}if(n.u=l,n.on){if(he&&r[0].on&&r[1].on){let e=1-Math.exp(-8*j);n.px+=(d-n.px)*e,n.pz+=(f-n.pz)*e,n.gy+=(me(d,f)-n.gy)*e}n.x0=X(l/g),n.th=_*(t.td*(1-br(n.x0/.25))+t.to*br((n.x0-.55)/.45));let[e,i]=jr(n.th);[n.x,n.y,n.z]=[n.px+m*e,n.gy+gr+i,n.pz+h*e],n.w=1-_*(1-br(Math.min(n.x0,1-n.x0)/.12)),n.tw=br(n.x0*10)}else{let r=X((l-n.dl)/(1-n.dl+1e-6)),[i,a]=[t.k*g/de,(1-l)/de+t.k*g/de],[o,s]=[P*i+fe*c*t.lat,F*i+pe*c*t.lat];n.tg=me(e.x+P*a+fe*c*t.lat,e.z+F*a+pe*c*t.lat);let[u,d]=[t.td*_,t.to*_],f=br((r-.12)/.78);n.x=e.x+n.lx+(o-n.lx)*f,n.z=e.z+n.lz+(s-n.lz)*f,n.y=n.ly+(n.tg+gr+jr(u)[1]-n.ly)*br(r*1.5)+t.lift*Math.sin(Math.PI*r**.6),n.th=d+(u-d)*br(r)+.15*Math.sin(Math.PI*r),n.tw=1-br(r*4),n.w=0}}else{let t=y?0:Math.exp(-10*j),r=y?[0,0,0]:[n.x-i.x,n.y-i.y,n.z-i.z];n.x=e.x+r[0]*t+(d-e.x)*(1-t),n.y=e.y+r[1]*t+gr*(1-t),n.z=e.z+r[2]*t+(f-e.z)*(1-t),[n.th,n.tw,n.w,n.on,n.u]=[n.th*t,n.tw*t,0,!1,l]}}),v=M,b=!0,Object.assign(i,e),a=!0},ee=()=>{let t=e=>n[Zr+2*e],{rot:r}=e,[i,a]=[Math.cos(u),Math.sin(u)],s=(e,t,n,r=E)=>[r[0]+e*i+n*a,t,r[2]+n*i-e*a],c=(e,t,n)=>s(e,t,n,[0,0,0]),l=[],{pos:d,rot:f}=lr(e),p=d[G.PELVIS],m=e=>e<0?G.HAND_L:G.HAND_R,h=e=>e<0?G.FOOT_L:G.FOOT_R,g=K(q(fr,u),q(Y,-.2)),_=X(t(Z.HANG)+t(Z.CLIMB));if(_>.002){let[r,i,a,o,s]=k,u=.4+.14*n[Jr],f=[-1,1].map(e=>{let t=d[m(e)-2],n=Math.max(u,(t[0]-r)*a+(t[2]-i)*o),c=[r+a*n-o*e*.21,s+.03,i+o*n+a*e*.21],l=(t[0]-c[0])**2+(t[2]-c[2])**2;return[c,t[1]-c[1]-Math.sqrt(Math.max(((_r+vr)*.97)**2-l,0))]}),g=_**4*X(Math.max(...f.map(e=>e[1])));e.at[1]-=g,d.forEach(e=>e[1]-=g),[-1,1].forEach((e,t)=>l.push([m(e),_,f[t][0],c(e*.8,0,.6),kr([0,e,0],[a,0,o])]));let v=(p[0]-r)*a+(p[2]-i)*o,y=Math.max(.58,v+.45);[-1,1].forEach(e=>l.push([h(e),t(Z.CLIMB)*X(e<0?(v-.25)*4:n[Jr]*2-.4),[r+a*y-o*e*.1,s+gr,i+o*y+a*e*.1],[a,.5,o],kr([-o,0,a],[0,-1,0])]))}[-1,1].forEach(e=>{let n=t(e<0?Z.WALL_L:Z.WALL_R);if(n>.002){let[t,r]=O;[e,-e].forEach((i,a)=>{let d=(o+.5*a)%1,f=d<.55,_=f?d/.55:(d-.55)/.45,v=f?0:Math.sin(Math.PI*_),y=(f?2*_-1:1-2*br(_))*(a?.4:.3);l.push([h(i),n,a?s(-e*.12,p[1]-.7+.4*v,y):s(e*(.34-.2*v),p[1]-.52+.3*v,y),c(-e*.7,1,-1),a?K(q(fr,u),q(Y,-.5)):cr(g,kr(wr([t,0,r],c(0,0,-1)),[t,0,r]),1-v)]);let b=Math.cos(dr*(o+.5*(1-a)));l.push([m(i),n,a?s(-e*.5,p[1]+.3+.12*b,.2*b):s(e*.37,p[1]+.3+.05*b,.1*b),c(a?-e*.7:0,a?0:-.5,.7),kr(a?[0,i,0]:[-i*t,0,-i*r],c(0,0,-1))])})}});let v=t(Z.SLIDE);if(v>.002){let e=E[1];l.push([G.FOOT_R,v,s(.12,e+gr+.14,-.85,p),c(.1,1,-.3),g],[G.FOOT_L,v,s(-.2,e+gr,-.3,p),c(-.4,1,-.1),g],[G.HAND_L,v,s(-.4,e+.03,.4,p),c(-.7,0,.7),kr([0,-1,0],c(-1,0,0))])}l.forEach(([e,t,n,i,a])=>{let[o,s,c]=[e-2,e<G.THIGH_L,t*t],l=Tr(Tr(d[o+1],1,d[o],-1),1,J(f[o],[0,0,s?1:-1]),.05),[u,p]=[Tr(d[e],1-c,n,c),e=>Er(Tr(e,1,d[o],-1))],m=Tr(Er(Dr(l,p(d[e]))),1-c,Er(Dr(i,p(n))),c),[h,g]=s?Ar(d[o],u,m,_r,vr,-1):Ar(d[o],u,m),_=s?K(h,q(pr,o==G.ARM_L?.1:-.1)):h;r[o]=K(Sr(f[ir[o]]),_),r[o+1]=K(Sr(_),g),r[e]=cr(r[e],K(Sr(g),a),c)})},M=()=>{let{rot:i}=e,a=_,s=e=>n[Zr+2*e],[l,d,f,p,m]=[n[Br],n[Vr],n[Hr],n[Ur],n[Wr]],[v,y]=[Math.cos(dr*o),Math.cos(2*dr*o)],x=Math.cos(dr*(o-(1+g)/2)),D=t.po*a*x,O=t.pt+C[3]+t.pa*a*y,k=(t.cc+t.pr)*a*v,A=1-a,j=A*.012*Math.sin(dr*.28*c),M=A*.012*Math.sin(dr*.17*c+C[1]*9),te=t.sw*a*x+M;e.at[0]=E[0],e.at[1]=E[1],e.at[2]=E[2],e.yaw=u,i[G.PELVIS]=K(K(q(fr,-t.pr*a*v),q(pr,D+.4*d)),q(Y,-(O+.25*l+.3*m+.5*p)));let N=O+.25*l-l-.7*m-.8*p;i[G.SPINE]=K(K(q(fr,.4*k-.25*f),q(pr,.25*d-.8*D+.5*M)),q(Y,.45*N+j*.5)),i[G.CHEST]=K(K(q(fr,.6*k-.25*f),q(pr,.25*d-.8*D-.5*M)),q(Y,.55*N+j)),[-1,1].forEach(e=>{let n=Math.cos(dr*(o-(e<0?.5:0))),r=C[e<0?1:2];i[e<0?G.ARM_L:G.ARM_R]=K(q(pr,e*(.06+t.ab*a+.5*p)),q(Y,(t.am+t.aa*r*n)*a+.05*A*e*Math.sin(c*1.3)+p+.5*m)),i[e<0?G.FOREARM_L:G.FOREARM_R]=q(Y,.15*A+a*(t.em+t.ea*n)+p+.5*m)});let P=q(fr,u),F=K(P,i[G.PELVIS]),[I,L]=[Math.cos(u),-Math.sin(u)],R=[E[0]+I*te,0,E[2]+L*te],z=[G.THIGH_L,G.THIGH_R].map(e=>J(F,ar[e])),ne=1-.25*m-.7*p,re=E[1]+.05+gr+yr*(ne-t.d0-.6*t.d1*a)+t.hop*a*(.5-.5*Math.cos(2*dr*o-2*dr*g/2)),ie=r.map((e,n)=>{let[r,i]=[e.x-R[0]-z[n][0],e.z-R[2]-z[n][2]],o=t.d0+t.d1*a*Math.sin(Math.PI*e.x0)+1-ne,s=Math.min(yr*(1-o),yr*.99),c=e.y+Math.sqrt(Math.max(s*s-r*r-i*i,.04));return re+(c-z[n][1]-re)*e.w}),ae=Or(ie[0],ie[1],.05),oe=c-S;S=c,oe>.1?[n[qr],n[qr+1]]=[ae,0]:ur(n,qr,ae,30,oe),R[1]=Math.min(ae,n[qr]),e.hips=[te,R[1]-E[1]-ar[0][1],0],r.forEach((e,t)=>{let n=t?1:-1,r=[R[0]+z[t][0],R[1]+z[t][1],R[2]+z[t][2]],a=u-n*C[4],[o,s]=Ar(r,[e.x,e.y,e.z],[-Math.sin(a),0,-Math.cos(a)]),c=t?G.THIGH_R:G.THIGH_L;i[c]=K(Sr(F),o),i[c+1]=K(Sr(o),s),i[c+2]=K(Sr(s),K(q(fr,a),q(Y,e.th))),i[c+3]=q(Y,e.th<0?-e.th*e.tw:0)}),Pr.forEach((t,n)=>{let r=s(n);if(r>.002){let a=Lr(t),o=n==Z.STUN;Ir.slice(o?3:0,o?7:15).forEach(e=>i[e]=cr(i[e],a[e],r)),o||[t[13],t[0],t[12]].forEach((t,n)=>e.hips[n]+=(t-e.hips[n])*r)}}),h&&(i[G.PELVIS]=K(q(Y,-dr*(3-2*h)*h*h),i[G.PELVIS]));let se=s(Z.HANG);if(se>.002){let[t,n]=[.01*Math.sin(dr*(.3*c+C[5])),.006*Math.sin(dr*(.2*c+3*C[5]))].map(e=>e*se);i[G.PELVIS]=K(K(q(pr,n),q(Y,t)),i[G.PELVIS]),[G.THIGH_L,G.THIGH_R].forEach(e=>i[e]=K(i[e],q(Y,t))),e.hips[0]+=n,e.hips[2]-=t}let ce=s(Z.STUN);if(ce){[G.SPINE,G.CHEST].forEach((e,t)=>{let r=.3+.1*t;i[e]=K(i[e],K(q(pr,-r*n[Xr]),q(Y,-r*n[Yr])))});let e=Math.sin(c*13);[G.ARM_L,G.ARM_R].forEach((t,n)=>i[t]=K(i[t],q(Y,ce*(n?e:-e)))),i[G.CHEST]=K(i[G.CHEST],q(fr,.3*ce*Math.sin(c*8)))}ee();let le=br((s(Z.DOWN)-.35)/.65);le&&(i[G.PELVIS]=K(q(Y,-1.45*le),i[G.PELVIS]),e.hips[1]+=(.17-ar[0][1]-e.hips[1])*le,[G.THIGH_L,G.THIGH_R].forEach(e=>i[e]=K(i[e],q(Y,-1.25*le))),[G.ARM_L,G.ARM_R].forEach(e=>i[e]=K(i[e],q(Y,-.5*le))));let ue=K(K(P,i[G.PELVIS]),K(i[G.SPINE],i[G.CHEST])),B=K(q(fr,w),q(Y,X(T,-1,1)*.9)),V=K(Sr(ue),cr(ue,B,.85*(1-s(Z.TUCK))*(1-.5*ce)*(1-s(Z.DOWN))));return i[G.NECK]=cr([0,0,0,1],V,.4),i[G.HEAD]=K(Sr(i[G.NECK]),V),b=!1,e};return{update:j,pose:()=>b?M():e,get phase(){return o},get steps(){return s}}},ti=e=>Math.sign(e)*Math.abs(e)**.8,ni=(e,t,n)=>e.map((e,r)=>e+(t[r]-e)*n),ri=e=>Math.min(Math.max(e,0),1),ii=(e,t,n,r)=>{let i=[],a=[],o=[],s=t.map(([e,r,o,s,c=0],l)=>{let[u,d]=[t[Math.max(l-1,0)],t[Math.min(l+1,t.length-1)]],f=Math.hypot(d[0]-u[0],d[1]-u[1])||1,[p,m]=[(d[0]-u[0])/f,(d[1]-u[1])/f];return Array.from({length:o?n:1},(t,l)=>{let[u,d]=[ti(Math.cos(l*V/n)),ti(Math.sin(l*V/n))];return i.push([c+o*u,r+s*d*p,-(e-s*d*m)]),a.push([0,0,0]),i.length-1})});s.slice(1).forEach((e,r)=>{let c=s[r],l=[(t[r][4]??0)+(t[r+1][4]??0),t[r][1]+t[r+1][1],-t[r][0]-t[r+1][0]];for(let t=0;t<n;t++){let[n,r,s,u]=[c[t%c.length],c[(t+1)%c.length],e[(t+1)%e.length],e[t%e.length]];for(let e of[[n,r,s],[n,s,u]]){if(new Set(e).size<3)continue;let[t,n]=[1,2].map(t=>[0,1,2].map(n=>i[e[t]][n]-i[e[0]][n])),r=[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]],s=[0,1,2].reduce((t,n)=>t+r[n]*(i[e[0]][n]*2-l[n]),0)<0;o.push(...s?[e[0],e[2],e[1]]:e);for(let t of e)[0,1,2].forEach(e=>a[t][e]+=s?-r[e]:r[e])}}});for(let t of o){let n=Math.hypot(...a[t])||1,o=a[t].map(e=>e/n);e.push(...i[t],...o,...r(i[t],o))}},ai=[.34,.12,.62],oi=[.72,.46,1],si=[.1,.38,.72],ci=[.16,.06,.34],li=[.5,1.9,2.3],ui=(e=0)=>(t,n)=>{let r=ni(ni(ai,si,ri(-t[2]*5-.3)*.8),oi,Math.max(n[1],0)**1.5*.7),[i,a,,o]=ni([...r.slice(0,2),0,r[2]],[...ci.slice(0,2),0,ci[2]],ri(-n[1]*.5+e));return[i,a,-1,o]},di=[.035,.025,.08],fi=()=>[li[0],li[1],-2,li[2]],pi=[0,.095,.06],mi=[0,.075,-.21],hi=[Math.sin(.4),Math.cos(.4)],gi=[[-.063,.1,0,0],[-.062,.098,.026,.016],[-.055,.1,.04,.02],[-.035,.103,.046,.038],[-.005,.104,.048,.04],[.035,.1,.044,.038],[.08,.094,.036,.034],[.12,.088,.028,.028],[.16,.082,.021,.021],[.19,.078,.015,.015],[.205,.076,.01,.01],[.208,.0755,0,0]],_i=[[-.05,-.02,0,0],[-.045,-.025,.018,.012],[-.025,-.052,.032,.018],[.01,-.066,.036,.02],[.06,-.06,.034,.02],[.11,-.04,.028,.018],[.16,0,.02,.014],[.2,.04,.012,.01],[.222,.065,0,0]],vi=[],yi=e=>{if(vi[e])return vi[e];let[t,n]=e?[12,8]:[8,5],r=[];ii(r,gi,t,ui()),ii(r,_i,t,ui(.25)),ii(r,[[.03,.06,0,0],[.02,.046,.021,.022],[0,0,.021,.023],[-.02,-.046,.021,.022],[-.03,-.06,0,0]],n,ui(.1));for(let t of[-1,1])ii(r,gi.slice(1,6).map(([e,n,r,i])=>[e,n-.1*i,.0035,.006,t*r*.93]),e?5:3,fi),ii(r,_i.slice(1,7).map(([e,n,r,i])=>[e,n+.3*i,.0035,.005,t*r*.92]),e?5:3,fi);return ii(r,[[.198,.077,0,0],[.2,.077,.011,.011],[.207,.0757,.008,.008],[-mi[2],mi[1],0,0]],n,fi),vi[e]=r},bi=e=>{let[t,n,r]=[J(e,[0,0,-1]),J(e,[1,0,0]),J(e,[0,-1,0])],[i,a]=hi;return[n,t.map((e,t)=>a*e-i*r[t]),t.map((e,t)=>i*e+a*r[t])]},xi=(e,t)=>{let[n,r]=[J(t,[0,-1,0]),J(t,[1,0,0])];return e.map((e,t)=>e+n[t]*.078-r[t]*.022)},Si=[`abcdef`,`bc`,`abdeg`,`abcdg`,`bcfg`,`acdfg`,`acdefg`,`abc`,`abcdefg`,`abcdfg`],[Ci,wi,Ti,Ei]=[.019,.0205,.005,.004],Di={a:[0,wi-Ti,Ci,wi],b:[Ci-Ti,wi/2,Ci,wi],c:[Ci-Ti,0,Ci,wi/2],d:[0,0,Ci,Ti],e:[0,0,Ti,wi/2],f:[0,wi/2,Ti,wi],g:[0,(wi-Ti)/2,Ci,(wi+Ti)/2]},Oi=[[.032,.112,.056],[.036,.112,.012]],ki=[[.028,.156,.036],[.028,.152,.02]],[Ai,ji,Mi]=[.023,.0175,.0455],[Ni,Pi,Fi]=[.0016,.0056,.0015],Ii=/* @__PURE__ */ new Map,Li=(e,t=0)=>{let n=Math.min(Math.max(Math.floor(e),0),99),r=n*8+Math.min(Math.max(t,0),5),i=Ii.get(r);if(!i){let e=i=[],a=e=>[-e[0],e[1],e[2]],[o,s,c,l]=[Oi[0],Oi[1],ki[0],ki[1]],u=[o,s,c,l].flatMap(e=>[e,a(e)]),d=[0,1,2].map(e=>u.reduce((t,n)=>t+n[e],0)/u.length),f=(t,n)=>{let[r,i]=[U(t[1],t[0]),U(t[2],t[0])],a=[r[1]*i[2]-r[2]*i[1],r[2]*i[0]-r[0]*i[2],r[0]*i[1]-r[1]*i[0]],o=U(t[0],d),s=Xt(a,o)<0?[t[0],t[3],t[2],t[1]]:t,[c,l,,u]=ui(.15)(s[0],W(Xt(a,o)<0?[-a[0],-a[1],-a[2]]:a));bn(e,s[0],s[1],s[2],n??[c,l,u]),bn(e,s[0],s[2],s[3],n??[c,l,u])};f([o,a(o),a(c),c]),f([s,a(s),a(l),l]),f([o,s,l,c]),f([a(o),a(s),a(l),a(c)]),f([c,a(c),a(l),l]);let p=W(U(c,o)),[m,h]=[[0,o[1],o[2]],[0,-p[2],p[1]]],g=(e,t,n)=>[m[0]+e,m[1]+p[1]*t+h[1]*n,m[2]+p[2]*t+h[2]*n];f([g(-Ai,ji,.0012),g(Ai,ji,.0012),g(Ai,Mi,.0012),g(-Ai,Mi,.0012)],di);let _=n=>{let r=(2*Ci+Ei-4*Fi)/5;for(let i=0;t>0&&i<5;i++)if(i<t===n){let a=-Ci-Ei/2+i*(r+Fi),o=(e,t)=>g(e,ji+t,.0027),s=n?t>=5?[1.3,.6,.15]:[.25,.9,1]:[.04,.12,.16];bn(e,o(a,Ni),o(a+r,Ni),o(a+r,Pi),s),bn(e,o(a,Ni),o(a+r,Pi),o(a,Pi),s)}};_(!1);let v=e.length;[...`${n}`.padStart(2,`0`)].forEach((t,r)=>{let i=-Ci-Ei/2+r*(Ci+Ei);for(let r of Si[+t]){let[t,a,o,s]=Di[r],c=(e,t)=>g(i+e,Mi-wi-3e-4+t,.0027),l=n>10?[.25,.9,1]:[1,.18,.12];bn(e,c(t,a),c(o,a),c(o,s),l),bn(e,c(t,a),c(o,s),c(t,s),l)}}),_(!0),yn(e,v,1),Ii.set(r,i)}return i},Ri=(e,t,n,r,i=1,a,o=0)=>{let[s,c]=[xi(t,n),bi(n)];on(e,yi(r),s,c,[0,0,0],i),a!==void 0&&on(e,Li(a,o),s,c,[0,0,0],i)},zi=(e,[,t,n])=>[0,1,2].map(r=>e[r]+t[r]*mi[1]-n[r]*mi[2]),Bi=Math.atan2(pi[1]-mi[1],pi[2]-mi[2]),Vi=(e,t,n,r)=>{let i=(e,t)=>[e[0]*t,e[1]*t,e[2]*t],a=[n,r,W(U(t,e))];for(let o=0;o<3;o++){let s=W(U(t,o?zi(e,a):e)),c=W(U(n,i(s,Xt(n,s)))),l=W(U(U(r,i(s,Xt(r,s))),i(c,Xt(r,c)))),[u,d]=[Math.sin(Bi),Math.cos(Bi)];a=[c,Yt(i(l,d),i(s,-u)),Yt(i(s,d),i(l,u))]}return a},Hi=(e,t)=>{let n=[e.x,e.y+Ee(e),e.z],r=Qt(e.yaw,e.pitch)[2],i=le(t,n,r,80);return[[0,1,2].map(e=>n[e]+r[e]*i),i<80]},Ui=(e,t)=>{let[n,r,i]=Qt(e.yaw,e.pitch),a=[e.x,e.y+Ee(e),e.z],o=[0,1,2].map(e=>a[e]+n[e]*.2-r[e]*.17+i[e]*.42);return[o,Vi(o,t,n,r)]},[Wi,Gi]=[.07,1.07],Ki=.03,qi=.019,Ji=.1,[Yi,Xi]=[Math.sin(.55),Math.cos(.55)],Zi=(...e)=>[0,1,2].map(t=>e.reduce((e,[n,r])=>e+n[t]*r,0)),Qi=([e,t,n],[r,i,a])=>[t*a-n*i,n*r-e*a,e*i-t*r],$i=(e,t)=>Math.sign(e)*Math.abs(e)**t,ea=e=>{let t=Math.sin(e*78.233)*43758.5453;return t-Math.floor(t)},ta=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),na=e=>Ki*((e-Wi)/(Gi-Wi))**2,ra=[[0,qi,.0041],[.07,qi,.0041],[.17,.0188,.0041],[.31,.0183,.004],[.44,.0178,.0039],[.58,.0172,.0036],[.71,.0166,.0034],[.82,.016,.0031],[.9,.015,.0026],[.96,.0122,.0019],[.984,.0074,.001],[1,0,0]].map(([e,t,n])=>[Wi+(Gi-Wi)*e,t,n]),ia=(e,t,n,r,i,a,o=1)=>Array.from({length:a},(s,c)=>[t+r*$i(Math.cos(c*2*Math.PI/a),o),n+i*$i(Math.sin(c*2*Math.PI/a),o),-e]),aa=(e,t,n)=>t.slice(1).forEach((r,i)=>{let a=t[i],o=[...a,...r],s=Zi(...o.map(e=>[e,1/o.length]));for(let t=0;t<Math.max(a.length,r.length);t++){let o=[a[t%a.length],a[(t+1)%a.length],r[(t+1)%r.length],r[t%r.length]];for(let[r,a,c]of[[0,1,2],[0,2,3]]){let[l,u,d]=[o[r],o[a],o[c]],f=Qi(Zi([u,1],[l,-1]),Zi([d,1],[l,-1]));if(Math.hypot(...f)<1e-12)continue;let p=f[0]*(l[0]-s[0])+f[1]*(l[1]-s[1])+f[2]*(l[2]-s[2])>0;bn(e,l,p?u:d,p?d:u,n(i,t))}}}),oa=[[.7,.78,.9],[.16,.2,.3],[.07,.09,.14]],sa=[.5,1.9,2.3],ca=[[.26,.09,.5],[.06,.04,.12]],la=[.1,.09,.14],ua=[.5,.4,.16],da=[],fa=e=>{if(da[e])return da[e];let t=[],n=ra.filter((t,n)=>e||n%2==0||n==ra.length-1);aa(t,n.map(([e,t,n])=>{let r=na(e)+(qi-t)/2;return[[0,r-t,-e],[n,r+.15*t,-e],[.6*n,r+t,-e],[-.6*n,r+t,-e],[-n,r+.15*t,-e]]}),(e,t)=>oa[t%4==0?0:t==2?2:1]);let r=t.length;aa(t,[...n.slice(0,-1).map(([t,n])=>ia(t,0,na(t)+(qi-n)/2-n-.0012,.0026,.0026,e?5:3)),[[0,na(Gi)+qi/2,-Gi]]],()=>sa),yn(t,r,1);let i=(e,t=0)=>[[0,t,-e]],a=e?8:5;aa(t,[i(Wi-.026),...[.056,.066,.084].map(e=>ia(e,0,0,.0066,.023,6)),i(.084)],()=>ua);let o=(t,n)=>ia(t,0,0,.038*n,.038*n,e?16:8,.6);aa(t,[i(.05),o(.05,.9),o(.053,1),o(.06,1),o(.063,.9),i(.063)],()=>la);let s=e?20:9;aa(t,[i(.052),...Array.from({length:s},(e,t)=>{let n=t/(s-1),r=1+.1*Math.sin(Math.PI*n);return ia(.052-.262*n,0,0,.0114*r,.0136*r,a)})],(e,t)=>ca[e+t&1]);let c=e=>ia(e,0,0,.013,.0154,a);aa(t,[i(-.202),c(-.206),c(-.218),i(-.22)],()=>la);let l=t.length;return aa(t,[i(-.22),ia(-.222,0,0,.006,.006,5),i(-.23)],()=>sa),yn(t,l,1),da[e]=t},pa=(e,t,[n,r,i],a,o,s=1)=>{let c=Math.floor(a*14),l=e.length;for(let a=0;a<(o?4:2);a++){let o=e=>ea(c*31+a*7+e);if(o(0)<.3)continue;let l=.12+.2*o(2),u=.12+(Gi-.17-l)*o(1),d=Array.from({length:5},(e,a)=>{let c=u+l*a/4,[d,f]=a?[(o(3+a)-.5)*.04,(o(8+a)-.5)*.04]:[0,0];return Zi([t,1],[n,d*s],[r,(f+na(c)+.004)*s],[i,c*s])});for(let t=1;t<5;t++)for(let i of[n,r]){let n=.0035*s,[r,a,o,c]=[Zi([d[t-1],1],[i,-n]),Zi([d[t-1],1],[i,n]),Zi([d[t],1],[i,n]),Zi([d[t],1],[i,-n])];bn(e,r,a,o,[.7,1.9,2.4]),bn(e,r,o,c,[.7,1.9,2.4])}}yn(e,l,1)},ma=(e,t,n,r,i,a=1)=>{on(e,fa(r),t,n,[0,0,0],a),i!==void 0&&pa(e,t,n,i,r,a)},ha=e=>{let[t,n,r]=[J(e,[0,0,-1]),J(e,[1,0,0]),J(e,[0,-1,0])];return[n,Zi([t,Yi],[r,-Xi]),Zi([t,Xi],[r,Yi])]},ga=(e,t,n,r,i,a=1)=>ma(e,xi(t,n),ha(n),r,i,a),_a=(e,t)=>{let[n,[,r,i]]=[xi(e,t),ha(t)];return[Zi([n,1],[i,Wi]),Zi([n,1],[i,Gi],[r,na(Gi)+qi/2])]},va=.3,ya=[.06,-.24,.45,.16,.74,.65],ba=e=>h[e].strike/h[e].ticks,xa=e=>[[0,...ya],[.12,-.14,-.08,.38,-.55,.75,-.35],[.24,-.3,0,.28,-.6,.35,-.72],[e-.07,-.22,-.1,.38,-.98,.15,.1],[e,.02,-.16,.43,0,.1,1],[.5,.32,-.18,.38,.95,-.1,.15],[.62,.34,-.22,.24,.6,-.35,-.7],[.8,.22,-.26,.36,.45,.6,.2],[1,...ya]],Sa=[[[0,...ya],[.3,.17,-.28,.17,-.08,.25,1],[ba(0),.03,-.2,.43,-.02,.12,1],[ba(0)+.2,.03,-.2,.43,-.02,.12,1],[1,...ya]],xa(ba(1)),[[0,...ya],[.12,.24,-.08,.36,.55,.75,-.35],[.24,.34,0,.24,.6,.35,-.72],[ba(2)-.07,.26,-.1,.36,.98,.15,.1],[ba(2),.08,-.16,.43,0,.1,1],[.5,-.16,-.18,.36,-.95,-.1,.15],[.62,-.2,-.22,.28,-.6,-.35,-.7],[.8,-.08,-.26,.38,-.3,.6,.2],[1,...ya]],[[0,...ya],[.14,.05,-.02,.34,-.05,.95,-.1],[.28,.04,.14,.26,0,.5,-.86],[.34,.05,.08,.34,0,1,.15],[ba(3),.05,-.16,.43,0,.08,1],[.52,.04,-.26,.42,0,-.55,.85],[.64,.03,-.3,.38,0,-.65,.75],[1,...ya]],[[0,...ya],[.2,.18,-.26,.16,-.08,.3,1],[ba(4),.03,-.18,.41,-.02,.1,1],[ba(4)+.3,.03,-.18,.41,-.02,.1,1],[1,...ya]],[[0,...ya],[.15,-.3,0,.28,-.6,.35,-.72],[.25,-.1,-.12,.4,-.7,.1,.7],[.35,.24,-.14,.38,.7,.05,.7],[.65,.26,-.14,.36,.72,0,.68],[.78,.3,-.24,.26,.6,-.35,-.7],[.9,.2,-.26,.36,.45,.6,.2],[1,...ya]],[[0,...ya],[.15,.34,0,.24,.6,.35,-.72],[.25,.2,-.12,.38,.7,.1,.7],[.35,-.12,-.14,.38,-.7,.05,.7],[.65,-.14,-.14,.36,-.72,0,.68],[.78,-.2,-.22,.28,-.6,-.35,-.7],[.9,-.12,-.26,.38,-.45,.6,.2],[1,...ya]],[[0,...ya],[.12,.05,.02,.32,-.05,.95,-.1],[.3,.04,.14,.26,0,.5,-.86],[.55,.04,.14,.26,0,.5,-.86],[ba(7)-.07,.05,.08,.34,0,1,.15],[ba(7),.05,-.16,.43,0,.08,1],[.8,.04,-.28,.42,0,-.6,.8],[.9,.03,-.3,.38,0,-.65,.75],[1,...ya]]],Ca=(e,t)=>{let n=e===y.SPIN_L?-1:+(e===y.SPIN_R),r=ta((t-.3)/.45);return n*V*r*r*(3-2*r)},wa=[],Ta=(e,t,n)=>{let r=e.length-2;for(;r>0&&e[r][0]>t;)r--;let[i,a]=[e[r],e[r+1]],o=a[0]-i[0],s=ta((t-i[0])/o),[c,l]=[s*s,s*s*s];for(let t=1;t<i.length;t++){let u=r?(a[t]-e[r-1][t])/(a[0]-e[r-1][0]):0,d=e[r+2]?(e[r+2][t]-i[t])/(e[r+2][0]-i[0]):0;n[t-1]=(2*l-3*c+1)*i[t]+(l-2*c+s)*o*u+(3*c-2*l)*a[t]+(l-c)*o*d}return n},Ea=(e,t)=>Ta(Sa[e],t,wa),Da=e=>[[0,0,0,0],[.12,.3,-.04,.06],[.24,.55,-.06,.1],[e-.07,.32,0,.04],[e,0,.06,-.04],[.5,-.45,.12,-.1],[.62,-.55,.14,-.12],[.8,-.25,.06,-.04],[1,0,0,0]],Oa=[[[0,0,0,0],[.3,-.32,-.04,0],[ba(0),.36,.2,.04],[ba(0)+.2,.36,.2,.04],[1,0,0,0]],Da(ba(1)),Da(ba(2)).map(e=>[e[0],-e[1],e[2],-e[3]]),(e=>[[0,0,0,0],[.14,0,-.1,0],[.28,.04,-.26,0],[.34,.04,-.2,0],[e,0,.16,0],[.52,0,.4,0],[.64,0,.42,0],[1,0,0,0]])(ba(3)),[[0,0,0,0],[.2,-.4,-.06,0],[ba(4),.46,.3,.06],[ba(4)+.3,.46,.3,.06],[1,0,0,0]],[[0,0,0,0],[.15,.5,-.04,.08],[.35,-.3,.06,-.08],[.65,-.3,.06,-.08],[.78,-.5,.12,-.1],[1,0,0,0]],[[0,0,0,0],[.15,-.5,-.04,-.08],[.35,.3,.06,.08],[.65,.3,.06,.08],[.78,.5,.12,.1],[1,0,0,0]],[[0,0,0,0],[.3,0,-.26,0],[.55,0,-.26,0],[ba(7)-.07,0,-.1,0],[ba(7),0,.2,0],[.8,0,.45,0],[.9,0,.45,0],[1,0,0,0]]],ka=[],Aa=(e,t)=>Ta(Oa[e],t,ka),ja=.2,Ma=(e,t,n)=>{let r=t.swing??0;if(!r)return-1;let i=h[t.cut??0].ticks,a=1-r/i;return e<0?a:Math.min(Math.max(e+n*60/i,a),a+2/i,1)},Na=e=>e>.24&&e<.6,Pa=[.66,.45,.35],[Fa,Ia,La,Ra,za,Ba,Va,Ha,Ua,Wa,Ga]=[0,1,2,3,4,5,6,7,8,9,10],Ka=[[.03,.03,.035],[.09,.07,.06],[.2,.12,.07],[.36,.18,.08],[.55,.16,.06],[.58,.43,.2],[.86,.72,.44],[.6,.6,.58]],qa=e=>Ka[(Math.imul(e+1,2654435761)>>>29)%Ka.length],Ja=(e,t=Ka[1])=>[e,e.map(e=>e*.5),[.12,.13,.17],Pa,t,[.74,.74,.77],[.93,.93,.94],[.26,.26,.3],[.85,.83,.8],[.1,.06,.04],[2.8,.5,.12]],Ya={chain:[G.PELVIS,G.SPINE,G.CHEST,G.NECK,G.HEAD],n:[8,12],e:2.3,far:[0,2,4,6,7,9,12,14,15,17,19,21],rings:[[.93,0,.01,.187,.108,0,La],[.99,0,.005,.18,.106,.25,Ia],[1.03,0,0,.17,.102,.5,Fa],[1.12,0,0,.155,.097,1,Fa],[1.24,0,-.003,.176,.112,1.7,Fa],[1.3,0,-.004,.182,.12,1.85,Fa],[1.37,0,-.005,.186,.124,2,Fa],[1.37,0,-.005,.264,.124,2,Fa],[1.41,0,-.005,.268,.123,2,Fa],[1.45,0,-.004,.26,.114,2,Fa],[1.485,0,0,.235,.098,2.05,Fa],[1.502,0,0,.185,.09,2.08,Fa],[1.512,0,0,.125,.08,2.1,Fa],[1.532,0,0,.07,.068,2.25,Ia],[1.555,0,0,.06,.062,2.6,Ra],[1.6,0,-.0165,.058,.0665,3.5,Ra],[1.635,0,-.0085,.072,.0785,4,Ra,150,za],[1.675,0,-.001,.08,.089,4,Ra,110,za],[1.71,0,.0035,.083,.0935,4,Ra,72,za],[1.75,0,.0065,.08,.0885,4,za],[1.785,0,.011,.056,.061,4,za],[1.8,0,.015,0,0,4,za]]},Xa={chain:[G.PELVIS,G.THIGH_R,G.SHIN_R,G.FOOT_R,G.TOE_R],n:[6,8],m:!0,far:[0,2,4,6,8,10,12,14],rings:[[.93,.1,0,0,0,0,La],[.85,.1,.006,.093,.098,.6,La],[.72,.1,-.002,.088,.09,1,La],[.55,.1,-.003,.066,.07,1.25,La],[.49,.1,-.004,.058,.064,1.5,La],[.42,.1,.002,.056,.064,1.8,La],[.33,.1,.012,.055,.068,2,La],[.19,.1,.003,.04,.047,2.05,La],[.105,.1,0,.038,.045,2.3,Ba],[.085,.1,.0025,.038,.0425,2.5,Ba],[.065,.1,.02,.043,.098,3,Ba],[.045,.1,.039,.046,.133,3,Ba],[.026,.1,.059,.046,.149,3,Va],[.008,.1,.062,.03,.138,3,Va],[0,.1,.062,0,0,3,Va]]},Za={chain:[G.ARM_R,G.FOREARM_R,G.HAND_R],n:[0,0],m:!0,far:[0,2,4,5,6,8,10],rings:[[1.37,.222,0,0,0,0,Fa],[1.3,.222,0,.053,.056,.1,Fa],[1.22,.222,0,.049,.052,.2,Fa],[1.18,.222,0,.043,.046,.5,Fa],[1.09,.222,-.002,.046,.048,.8,Fa],[.975,.222,0,.034,.034,1.2,Ia],[.935,.222,0,.03,.03,1.8,Ha],[.885,.222,-.004,.027,.037,2,Ha],[.84,.222,-.008,.029,.042,2,Ha],[.795,.222,-.012,.025,.034,2,Ha],[.772,.222,-.014,0,0,2,Ha]]},Qa=[.925,.222,0,.027,.027,2,Ha],$a=Ya.n[1]-4,eo={chain:[G.HEAD],n:[0,5],z:!0,m:!0,far:[],rings:[[-.07,.031,1.692,.0145,.0088,0,Ua],[-.088,.031,1.692,.0145,.0088,0,Ua],[-.0915,.031,1.692,.0105,.0072,0,Wa],[-.0932,.031,1.692,.0055,.0055,0,Wa],[-.094,.031,1.692,0,0,0,Wa]]},to={chain:[G.HEAD],n:[0,5],z:!0,far:[],rings:[[-.075,0,1.675,.014,.034,0,Ra],[-.1,0,1.66,.012,.024,0,Ra],[-.115,0,1.649,0,0,0,Ra]]},no=[Ya,Xa,Za,to,eo],ro=(e,t)=>Math.sign(e)*Math.abs(e)**(2/t),io=e=>Math.min(Math.max(e,0),1),ao=e=>{let[t,n,r,i,a,o]=[[],[],[],[],[],[]],s=Ya.n[Math.min(e,1)],[c,l]=[s/2,s/2-1],u=[],d=0,f=[],p=(e,i,a,o)=>(t.push(...e,0,0,0),n.push(i,a),r.push(o),r.length-1);for(let n of no){let r=n===Za?s-4:n.n[Math.min(e,1)];if(!r||e>1&&(n===to||n===eo))continue;let m=e>1&&n===Ya?[...n.rings.slice(0,10),[1.462,0,0,0,0,2,Fa]]:e>1&&n===Za?[...n.rings.slice(0,6),[.95,.222,0,.037,.037,1.6,Ha],Qa,[.91,.222,0,0,0,2,Ha]]:e?n.rings:n.far.map(e=>n.rings[e]),h=m[m.length-1][0]>m[0][0];n===Ya&&(d=m.findIndex((e,t)=>t&&e[0]==m[t-1][0]));for(let e of n.m?[1,-1]:[1]){let g=t=>e<0&&t>G.HEAD?t-4:t,_=(t,n)=>t[e<0?(s-n)%s:n],v=(e,t,r,i)=>{i=n===Xa&&t<.12?3+io((-r-.04)/.14):i;let a=Math.min(Math.floor(i),n.chain.length-2),o=n===Ya?io((Math.abs(e)-.14)/.1)*io((1.53-t)/.15)*io((t-1.35)/.02):0;return o?p([e,t,r],G.CHEST,e<0?G.ARM_L:G.ARM_R,o):p([e,t,r],g(n.chain[Math.max(a,0)]),g(n.chain[a+1]??n.chain[0]),a<0?0:i-a)},y=m.map(([i,a,o,m,h,g],y)=>{let b=[];if(!y&&n===Za){for(let e=1;e<=l;e++)b.push(_(u[d],e));for(let e=l-1;e>1;e--)b.push(_(u[d-1],e))}else if(!y&&n===Xa){for(let e=0;e<=c;e++)b.push(_(u[0],e));let[e,n]=[u[0][0]*6,u[0][c]*6];for(let i=0;i<r-c-1;i++){let a=(i+1)/(r-c);f[i]??=p([0,1,2].map(r=>t[n+r]+(t[e+r]-t[n+r])*a-(r==1?.04:0)),G.PELVIS,G.PELVIS,0),b.push(f[i])}b.push(b.shift())}else for(let t=0;t<(m?r:1);t++){if(n===Ya&&y==d-1&&!(t>1&&t<l)&&!(t>s-l&&t<s-1)){b.push(-1);continue}let c=t*2*Math.PI/r,u=(n.e??2)*(n===Xa&&i<.12?2:1),[f,p]=[a+m*ro(Math.sin(c),u),o+h*ro(Math.cos(c),u)];b.push(n.z?v(e*f,p,i,g):v(e*f,i,-p,g))}return b});n===Ya&&(y[d-1]=y[d-1].map((e,t)=>e<0?y[d][t]:e),u=y),y.slice(1).forEach((t,s)=>{if(n===Ya&&s==d-1)return;let c=y[s],[l,,,,,,u,...f]=m[s],p=n===Ya?+(l>1.55):n===to||n===eo?b.HEAD:(n===Za?b.ARM_L:b.LEG_L)+ +(e>0);for(let n=0;n<r;n++){let[s,l,d,m]=[c[n%c.length],c[(n+1)%c.length],t[(n+1)%t.length],t[n%t.length]],g=Math.abs(((n+.5)/r*360+180)%360-180),_=f.findIndex((e,t)=>!(t%2)&&(e>0?g>e:g<-e));for(let t of[[s,l,d],[s,d,m]])new Set(t).size>2&&(i.push(...h===e<0?t:[t[0],t[2],t[1]]),a.push(_<0?u:f[_+1]),o.push(p))}})}}for(let e=0;e<i.length;e+=3){let[n,r,a]=[i[e],i[e+1],i[e+2]].map(e=>e*6),o=[0,1,2].map(e=>[t[r+e]-t[n+e],t[a+e]-t[n+e]]),s=[o[1][0]*o[2][1]-o[2][0]*o[1][1],o[2][0]*o[0][1]-o[0][0]*o[2][1],o[0][0]*o[1][1]-o[1][0]*o[0][1]];for(let e of[n,r,a])for(let n=0;n<3;n++)t[e+3+n]+=s[n]}for(let e=0;e<t.length;e+=6){let n=Math.hypot(t[e+3],t[e+4],t[e+5])||1;for(let r=3;r<6;r++)t[e+r]/=n}return{v:new Float32Array(t),j:new Uint8Array(n),w:new Float32Array(r),t:new Uint16Array(i),c:new Uint8Array(a),l:new Uint8Array(o)}},oo=[],so=e=>oo[e]??=ao(e),co=[0,G.NECK,G.CHEST,G.CHEST,G.PELVIS,G.PELVIS],lo=(e,t)=>{let n=e.w.length,[r,i]=[[[],[]],[[],[]]],[a,o]=[/* @__PURE__ */ new Set,/* @__PURE__ */ new Set];e.c.forEach((n,s)=>{let c=+(e.l[s]==t);for(let t=0;t<3;t++)r[c].push(e.t[s*3+t]),[o,a][c].add(e.t[s*3+t]<<16|e.t[s*3+(t+1)%3]);i[c].push(n)});let s=new Float32Array(n*6+6);s.set(e.v);let c=0;for(let t of a){let[a,l]=[t>>16,t&65535];if(o.has(l<<16|a)){r[0].push(a,l,n),r[1].push(l,a,n),i[0].push(Ga),i[1].push(Ga);for(let t=0;t<3;t++)s[n*6+t]+=e.v[a*6+t];c++}}for(let e=0;e<3;e++)s[n*6+e]/=c;s[n*6+4]=1;let l=new Uint8Array([...e.j,co[t],co[t]]),u=new Float32Array([...e.w,0]);return r.map((e,t)=>({v:s,j:l,w:u,t:new Uint16Array(e),c:new Uint8Array(i[t])}))},uo=[],fo=(e,t)=>uo[e*8+t]??=lo(so(e),t),po=lr(sr()).pos,mo=new Float64Array(rr*8),Q=/* @__PURE__ */ new Float64Array(8),ho=/* @__PURE__ */ new Float32Array,go=(e,t,{pos:n,rot:r},i)=>{for(let e=0;e<rr;e++){let t=J(r[e],po[e]);mo.set(r[e],e*8),mo.set(K([(n[e][0]-t[0])/2,(n[e][1]-t[1])/2,(n[e][2]-t[2])/2,0],r[e]),e*8+4)}let a=t.w.length;ho.length<a*6&&(ho=new Float32Array(a*6));for(let e=0;e<a;e++){let[n,r,i,a]=[t.j[e*2]*8,t.j[e*2+1]*8,t.w[e],e*6],o=mo[n]*mo[r]+mo[n+1]*mo[r+1]+mo[n+2]*mo[r+2]+mo[n+3]*mo[r+3]<0?-i:i;for(let e=0;e<8;e++)Q[e]=(1-i)*mo[n+e]+o*mo[r+e];let s=Math.hypot(Q[0],Q[1],Q[2],Q[3]);for(let e=0;e<8;e++)Q[e]/=s;let c=[Q[3]*Q[4]-Q[7]*Q[0]-(Q[5]*Q[2]-Q[6]*Q[1]),Q[3]*Q[5]-Q[7]*Q[1]-(Q[6]*Q[0]-Q[4]*Q[2]),Q[3]*Q[6]-Q[7]*Q[2]-(Q[4]*Q[1]-Q[5]*Q[0])];for(let e of[a,a+3]){let[n,r,i]=[t.v[e],t.v[e+1],t.v[e+2]],[o,s,l]=[Q[1]*i-Q[2]*r,Q[2]*n-Q[0]*i,Q[0]*r-Q[1]*n],u=e==a?2:0;ho[e]=n+2*(Q[3]*o+Q[1]*l-Q[2]*s)+u*c[0],ho[e+1]=r+2*(Q[3]*s+Q[2]*o-Q[0]*l)+u*c[1],ho[e+2]=i+2*(Q[3]*l+Q[0]*s-Q[1]*o)+u*c[2]}}for(let n=0;n<t.t.length;n+=3){let[r,a,o]=i[t.c[n/3]],s=t.c[n/3]==Ga?-2:-1;for(let i=n;i<n+3;i++){let n=t.t[i]*6;e.push(ho[n],ho[n+1],ho[n+2],ho[n+3],ho[n+4],ho[n+5],r,a,s,o)}}},_o=.15,vo=24,yo=[.5,1.9,2.3],bo=()=>{let e=[],t=!1;return{mark(n,r,i){i&&(e.push({a:r.map((e,t)=>e+(n[t]-e)/3),b:r,age:0,start:!t}),e.length>vo&&e.shift()),t=i},update(t){for(e.forEach(e=>e.age+=t);e[0]&&e[0].age>=.15;)e.shift()},draw(t){e.forEach((n,r)=>{let i=e[r-1];if(!i||n.start)return;let[a,o]=[i,n].map(e=>1-e.age/_o),s=(e,t)=>e.b.map((n,r)=>n+(e.a[r]-n)*t),c=yo.map(e=>e*(.4+.6*(a+o)*.5)),[l,u,d,f]=[i.b,n.b,s(n,o),s(i,a)];for(let e of[l,u,d,l,d,f])t.push(...e,0,1,0,c[0],c[1],-2,c[2])})},get count(){return e.length}}},xo=1,[So,Co]=[.12,.03],[wo,To,Eo]=[[1,0,0],[0,1,0],[0,0,1]],Do=[.7,-1,-.5],Oo=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),ko=([e,t,n,r])=>[-e,-t,-n,r],Ao=(e,t)=>Math.hypot(...U(e,t)),$=(e,t,n)=>Yt(e,Zt([0,0,0],t,n)),jo=(e,t)=>{let[n,r]=[W(e),W(t)],i=[n[1]*r[2]-n[2]*r[1],n[2]*r[0]-n[0]*r[2],n[0]*r[1]-n[1]*r[0],1+Xt(n,r)],a=Math.hypot(...i)||1;return i.map(e=>e/a)},Mo=(e,t,n,r,i)=>{let a=U(t,e),o=W(a),s=Math.max(Math.min(Math.hypot(...a),(r+i)*.99),.15),c=(r*r-i*i+s*s)/(2*s),l=Math.sqrt(Math.max(r*r-c*c,0)),u=W(U(n,Zt([0,0,0],o,Xt(n,o))));return[$($(e,o,c),u,l),$(e,o,s)]},No=(e,t,n,r,i,a=!1)=>{let[o,s,c]=[t.pos[n],t.pos[n+1],t.pos[n+2]],[l,u]=Mo(o,r,i,Ao(o,s),Ao(s,c)),d=K(jo(U(s,o),U(l,o)),t.rot[n]),f=K(jo(U(c,s),U(u,l)),t.rot[n+1]);e.rot[n]=K(ko(t.rot[ir[n]]),d),e.rot[n+1]=K(ko(d),f),a&&(e.rot[n+2]=K(ko(f),t.rot[n+2]))},Po=(e,t)=>$(e,t,-Xt(e,t)),Fo=(e,t)=>{let n=2*Math.atan2(e[0]*t[0]+e[1]*t[1]+e[2]*t[2],e[3]);return n>Math.PI?n-2*Math.PI:n<-Math.PI?n+2*Math.PI:n},Io=(e,t,n)=>K(jo(J(e,t),n),e),Lo=.3,[Ro,zo]=[.22,.17],[Bo,Vo]=[.16,.3],Ho=(e,t,n,r)=>{let[i,a]=[Yt(e.pos[G.PELVIS],[0,-.25,0]),e.pos[G.NECK]];if(r[1]>a[1]+.05)return 0;let o=Zt(i,a,Oo((r[1]-i[1])/(a[1]-i[1]))),[s,c]=[e=>e[0]*Math.cos(t)-e[2]*Math.sin(t),e=>-e[0]*Math.sin(t)-e[2]*Math.cos(t)],l=U(r,o),u=Math.abs(s(l))/Ro,d=u<1&&r[1]>=i[1]?zo*Math.sqrt(1-u*u):-1/0,f=a[1]-Bo;if(u<Vo/Ro&&r[1]<f&&n[1]>f){let e=c(U(n,o));d=Math.max(d,e+(zo-e)*(n[1]-r[1])/(n[1]-f))}return Math.max(0,d-c(l))},Uo=(e,t,n,r,i,a)=>{let o=n===G.ARM_L?-1:1,s=U(r,t.pos[n]),[c,l]=[Oo((s[1]+.12)*1.6,0,.5),Oo((Math.hypot(...s)-.4)*2.5,0,.45)];e.rot[n-1]=K(e.rot[n-1],K(q(To,o*l),q(Eo,o*c)));let u=lr(e),d=u.pos[n],[f,p]=[Ao(d,u.pos[n+1]),Ao(u.pos[n+1],u.pos[n+2])],m=W(Yt(Po(W(U(r,d)),i),$([0,0,0],W(Po(a,i)),-.3))),h=Yt($([0,0,0],i,Xi),$([0,0,0],m,-Yi)),g=Yt($([0,0,0],i,Yi),$([0,0,0],m,Xi)),_=Yo(g,h),v=kr(_,g),y=$($(r,g,-.078),_,n==G.ARM_L?-.022:.022),[b,x]=Mo(d,y,Yt(U($(y,g,-p),d),a),f,p),[S,C]=[W(U(b,d)),W(U(x,b))],w=Yo(S,C),T=W(Math.hypot(...w)>.001?w:Yo(S,Zt([0,0,0],a,-1))),[E,D]=[W(ar[n+1]),W(ar[n+2])],O=Io(kr(T,S),E,S),k=Io(kr(T,C),D,C),A=K(k,q(D,Fo(K(ko(k),v),D)/2));e.rot[n]=K(ko(u.rot[ir[n]]),O),e.rot[n+1]=K(ko(O),A),e.rot[n+2]=K(ko(A),v)},Wo=[[0,0],[1,0],[-1,0],[0,1],[0,-1]],Go=[1,1.1,1,.82],Ko=[[[.55,-.2,.8],[.2,-.75,.6]],[[.4,-.1,.9],[-.55,-.5,.65]]],qo=6,Jo=lr(sr()).pos[G.HAND_R],Yo=([e,t,n],[r,i,a])=>[t*a-n*i,n*r-e*a,e*i-t*r],Xo=(e,t,n,r)=>{let i=e.map(([e,n,r])=>n.some(Boolean)?Array.from({length:t},(i,a)=>{let[o,s]=[Math.sin(a*V/t),Math.cos(a*V/t)];return[0,1,2].map(t=>e[t]+n[t]*s+r[t]*o)}):[e]),a=(e,t,n)=>{let r=e[Math.min(Math.max(t,0),e.length-1)];return r[(n+r.length)%r.length]},o=i.map((n,o)=>n.map((s,c)=>{if(r!=null&&!o){let e=c*V/t;return W([Math.cos(e),Math.sin(e),r])}return n.length<2?W(U(n[0],e[o-1][0])):W(Yo(U(a(i,o,c+1),a(i,o,c-1)),U(a(i,o+1,c),a(i,o-1,c))))}));for(let e=1;e<i.length;e++)for(let r=0;r<t;r++){let[t,s,c,l]=[[e-1,r],[e-1,r+1],[e,r+1],[e,r]];for(let r of i[e].length>1?[[t,s,c],[t,c,l]]:[[t,s,c]])for(let[e,t]of r)n(a(i,e,t),a(o,e,t))}},Zo=(e,t,n,r,i,a)=>{let o=$(e,t,r),[s,c]=[$(o,t,-r/2),$(o,n,r/2)],l=(e,t,n)=>{let[r,a]=[W(t),W(Yo(t,wo))];return[e,Yo(a,r).map(e=>e*i*n),a.map(e=>e*i*n)]};return[l(e,a,1.03),l(s,t,1),l(Zt(o,Zt(s,c,.5),.5),U(c,s),.94),l(c,n,.9),l($(o,n,r-.001),n,.74),l($(o,n,r+.006),n,0)]},Qo=(e,t)=>{let n=-(t-1.5)*.08*(1-e),[r,i]=[.1+1.3*e,.2+3*e].map(e=>W([n,-Math.sin(e),Math.cos(e)]));return[r,i]},$o=(e,t,n,r,i,a,o)=>{let s=([a,s,c],[l,u,d])=>e.push(...[0,1,2].map(e=>t[e]+i[e]*a+r[e]*s+n[e]*c),...[0,1,2].map(e=>i[e]*l+r[e]*u+n[e]*d),o[0],o[1],-1,o[2]),c=([e,t,n,r])=>[[0,t,e],[n,0,0],[0,r,0]];Xo([c([Jo[1]-Qa[0],Qa[1]-Jo[0],Qa[3],Qa[4]]),c([.025,0,.04,.021]),c([.06,-.002,.0425,.017]),c([.092,-.004,.0425,.0105]),c([.104,-.004,0,0])],$a,s,.75);for(let e=0;e<4;e++){let[t,n]=Qo(a,e);Xo(Zo([.0315-.021*e,-.004,.092],t,n,.04*Go[e],.0105,W(Yt(t,[0,0,1]))),qo,s)}let[l,u]=Ko.map(([e,t])=>W(Zt(e,t,a)));Xo(Zo([.029,-.01,.025],l,u,.037,.0118,l),qo,s)},es=(e,t)=>(n,i)=>{let a=le(e,[n,t+r,i],[0,-1,0],2*r);return a>0&&a<1?t+r-a:t},ts={amp:8,sprint:6,air:12,rise:10,dash:14,plant:16,wall:10,slide:10,stun:14,gun:10,blade:10},ns=e=>{let t=ei(),n,r={amp:0,sprint:0,air:0,rise:0,dash:0,plant:0,wall:0,slide:0,stun:0,gun:0,blade:0},[i,a,o,s]=[0,0,0,1.6],c=-1,l=bo(),u=[0,0,8],d=[0,0,0],f=0,p=0,m,h=[0,0],g=(a,o,u=0,d=1.6)=>{if(i=u,s=d,!a){n=void 0;return}t.update(a,o,e&&es(e,a.y)),n={...a},f+=o,c=Ma(c,a,o),l.update(o);let h=a.mode==x.GROUND||a.mode==x.CROUCH||a.mode==x.WALLRUN,g=a.dash>50,_=a.mode==x.AIR&&!g,v={amp:h?Oo(De(a)/9):0,sprint:+Oe(a),air:+_,rise:+(_&&a.vy>.5),dash:+g,plant:+(a.mode==x.HANG||a.mode==x.CLIMB),wall:+(a.mode==x.WALLRUN),slide:+(a.mode==x.SLIDE),stun:+(a.stun>0),gun:+(a.ammo>=0&&!a.down&&!a.wield),blade:+(!!a.wield&&!a.down)};for(let e of Object.keys(ts))r[e]+=(v[e]-r[e])*(1-Math.exp(-o*ts[e]));let[y,b]=Wo[a.wall];p+=(Oo(y*Math.cos(a.yaw)-b*Math.sin(a.yaw),-1,1)-p)*(1-Math.exp(-o*10)),v.plant&&a.edge&&(m={x:a.x,y:a.edge,z:a.z,dx:y,dz:b})},_=()=>{let e=r.amp*(1+.5*r.sprint),[n,a]=[Math.sin(V*t.phase),Math.cos(V*t.phase)],o=[Math.min(.22,.18*s)+.012*e*n+d[0],-.25+.018*e*a-.3*(1-r.gun)+d[1],.4-.05*i+d[2]];return[o,Vi(o,[u[0],u[1]+.1*i*Math.hypot(...u),u[2]],wo,To)]},v=()=>{let e=r.amp*(1+.5*r.sprint),[i,a]=[Math.sin(V*t.phase),Math.cos(V*t.phase)],o=Ea(n?.cut??0,Math.max(c,0));return{at:[o[0]+.012*e*i,o[1]+.018*e*a-.35*(1-r.blade),o[2]],g:W([o[3],o[4],o[5]])}},y=(e,i,s,l=0)=>{if(!n||n.down||Ao(e,[n.x,n.y+Ee(n),n.z])>xo)return;let u=t.pose(),g={at:[...u.at],yaw:u.yaw,hips:[...u.hips],rot:u.rot.map(e=>[...e])},[y,b,x]=Qt(i,s,l),S=([e,t,n])=>[y[0]*e+b[0]*t+x[0]*n,y[1]*e+b[1]*t+x[1]*n,y[2]*e+b[2]*t+x[2]*n],C=e=>[Xt(e,y),Xt(e,b),Xt(e,x)],w=r.blade>.002?v():void 0,[T,E,D]=w&&c>=0?Aa(n.cut??0,c).map(e=>e*r.blade):[0,0,0];g.yaw+=w&&c>=0?Ca(n.cut??0,c)*r.blade+ja*T:0;let[O,k,A]=Qt(i+Lo*T,Math.max(s,-va),l),j=([e,t,n])=>[O[0]*e+k[0]*t+A[0]*n,O[1]*e+k[1]*t+A[1]*n,O[2]*e+k[2]*t+A[2]*n];for(let[e,t]of[[G.SPINE,.4],[G.CHEST,.6]])g.rot[e]=K(g.rot[e],K(K(q(To,T*t),q(wo,.12*Oo(s,-1.3,1.3)-E*t)),q(Eo,D*t)));let ee=lr(g),M=[-Math.sin(i),0,-Math.cos(i)],te=Yt(ee.pos[G.HEAD],J(ee.rot[G.HEAD],[0,.02,-.08]));g.at=Yt(g.at,U(e,$(te,[-M[0]*So,-Co,-M[2]*So],r.plant)));let N=lr(g),P=[-Math.sin(g.yaw),0,-Math.cos(g.yaw)];for(let e of[G.THIGH_L,G.THIGH_R])No(g,N,e,ee.pos[e+2],P,!0);let F=(t,n=S)=>$([0,0,0],P,Math.max(...t.map(t=>Ho(N,g.yaw,e,Yt(e,n(t))))));d=[0,0,0];let[I,L]=_(),R=([e,t,n])=>[0,1,2].map(r=>I[r]+L[0][r]*e+L[1][r]*t-L[2][r]*n);d=C(F([I,R(pi),R([0,.156,.04])]));let z=w?F([w.at,$(w.at,w.g,-Ji),$(w.at,w.g,Wi)],j):d,[ne,re]=_(),ie=[0,1,2].map(e=>hi[1]*re[2][e]-hi[0]*re[1][e]),ae=[0,1,2].map(e=>ne[e]-.078*ie[e]+.022*re[0][e]);for(let n of[-1,1]){let i=Math.cos(V*t.phase)*n,s=Oo(r.amp*1.8)+.2*r.sprint,c=[.24-.05*s,-.66+.46*s*((i+1)/2)**1.2,.1+.26*s*i];c=Zt(c,[.38,-.2,.34],r.air),c=Zt(c,[.3,.02,.45],r.rise),c=Zt(c,[.14,-.1,.5],r.dash);let l=r.wall*Oo(p*n);c=Zt(c,[.42,-.16,.42],l),c=Zt(c,n>0?[.36,-.26,.38]:[.28,-.1,.42],r.slide);let u=Math.sin(f*12+(n>0?Math.PI:0));if(c=Zt(c,[.46,.05+.2*u,.4+.1*u],r.stun),m){let[t,i]=[-m.dz,m.dx];Xt([t,0,i],y)<0&&([t,i]=[-t,-i]);let a=.35000000000000003,[o,s,l]=C(U([m.x+m.dx*a+t*.12*n,m.y+.03,m.z+m.dz*a+i*.12*n],e));c=Zt(c,[o*n,Math.max(s,-.28),Math.max(l,.4)],r.plant)}let d=1-Oo(r.plant+l+r.stun),_=w?r.blade*d:0,v=_;n>0&&(a=r.gun*d,c=Zt(c,ae,a),o=_,v=Math.max(a,o));let b=.75+.25*r.sprint;for(let[e,t]of[[.25,r.air],[.1,r.rise],[1,r.dash],[.1,l],[.1,r.slide],[.1,r.plant],[.2,r.stun]])b+=(e-b)*t;h[(n+1)/2]=b+(.9-b)*v;let x=Yt(e,S([c[0]*n,c[1],c[2]])),T=n<0?G.ARM_L:G.ARM_R;if(No(g,N,T,x,S([Do[0]*n,Do[1],Do[2]])),g.rot[T+2]=q(To,n*(1+.5*(r.plant+r.slide))),n>0&&a>.002){let e=kr(S(re[0]),S(ie));g.rot[T+2]=cr(g.rot[T+2],K(ko(lr(g).rot[G.FOREARM_R]),e),a)}if(w&&_>.002){let t=j(w.g),r=$(Yt(Yt(e,j(w.at)),z),t,n>0?0:-Ji),i={...g,rot:g.rot.slice()};Uo(i,N,T,r,t,j([.5*n,-1,-.35]));for(let e of[T-1,T,T+1,T+2])g.rot[e]=cr(g.rot[e],i.rot[e],_)}}return lr(g)};return{get id(){return n?.id??-1},update:g,pose:y,draw(e,t,r,i,s=0,u=[.7,.7,.7]){let d=y(t,r,i,s);if(d){let t=Ja(u);if(go(e,so(2),d,t),[G.HAND_L,G.HAND_R].forEach((n,r)=>{let i=d.rot[n];$o(e,d.pos[n],J(i,[0,-1,0]),J(i,[r*2-1,0,0]),J(i,[0,0,-1]),h[r],t[7])}),a>.2){let t=n&&(n.charge??0)>=10?Math.min(nr(n.charge),n.ammo):0;Ri(e,d.pos[G.HAND_R],d.rot[G.HAND_R],1,Oo(a*1.5-.5),n?.ammo,t)}o>.2&&ga(e,d.pos[G.HAND_R],d.rot[G.HAND_R],1,f,Oo(o*1.5-.5));let[r,i]=_a(d.pos[G.HAND_R],d.rot[G.HAND_R]);l.mark(r,i,o>.5&&Na(c)),l.draw(e)}},aim(e){let t=Math.hypot(...e);u=t<3?t?e.map(e=>e*3/t):[0,0,3]:e},muzzle:()=>zi(..._()),spun:()=>n&&c>=0?Ca(n.cut??0,c)+ja*Aa(n.cut??0,c)[0]*r.blade:0}},rs=(e,t,n,r,i,a)=>{let o=Qt(r,i)[2],s=le(e,t,o,80),c=[0,1,2].map(e=>t[e]+o[e]*s);return{end:c,hit:s<80,local:Qt(r,a).map(e=>(c[0]-n[0])*e[0]+(c[1]-n[1])*e[1]+(c[2]-n[2])*e[2])}},is=(e,t)=>e&&t?t.shots-e.shots&255:0,as=(e,t)=>e&&t&&(t.swing??0)>0&&((t.swing??0)>(e.swing??0)||(t.cut??0)!=(e.cut??0))?t.cut??0:-1,os=(e,t)=>{let{ticks:n,strike:r}=h[t?.cut??0];return!!e&&!!t&&(e.swing??0)>n-r&&(t.swing??0)<=n-r},ss={rate:[1.3,1.05,.95,.8],gain:[.6,.8,.8,1]},cs=(e,t,r,i,a,o,s)=>{let c=[],l,u=!1,d=0,f=/* @__PURE__ */ new Map,m=/* @__PURE__ */ new Map,h=[],g=()=>.94+.12*(d++*.618%1),_=(e,n=1)=>t.play(H.LASER,e,(e?.7:.5)*(1+.15*(n-1)),g()*(1-.1*(n-1))),y=t=>zi(...Ui(t,Hi(t,e)[0])),b=(e,n)=>t.play(H.SWISH,n,ss.gain[e],ss.rate[e]),x=(e,n,r)=>!!e.wield!=!!n.wield&&(n.wield||n.blade)&&t.play(H.SHING,r,.6,n.wield?1:.85);return{step(e,t){let r=is(e,t);r&&t&&c.push({...t});for(let e=0;e<r;e++)o.pitch=Math.min(n,o.pitch+p),i.fire();let a=as(e,t);a>=0&&h.push(a),t&&os(e,t)&&i.cut(t.cut??0)},frame(e,n,o,d,p,g=0){if(a.update(p),n){let e=l;e&&n.hits!=e.hits&&(t.play(H.HIT),r.hit(),n.wield&&t.play(H.ZAP)),e&&x(e,n),e&&n.hp<e.hp?(t.play(n.down&&!e.down?H.DOWN:H.HURT),i.wound()):e&&n.hp>e.hp&&!e.down&&t.play(H.PACK),e&&(e.ammo<0||n.ammo>e.ammo)&&n.ammo>=0&&t.play(H.GUN);let a=!!(d&v.FIRE);a&&!u&&n.ammo==0&&!n.down&&t.play(H.DRY),u=a,r.vitals(n.hp,n.ammo,!!n.blade,!!n.wield),h.forEach(e=>b(e)),r.down(i.lie,n.down/60),l={...n}}else l=void 0;let S;if(e){let[t,n,r]=Qt(e.yaw,e.drawn),i=e.muzzle;S=[0,1,2].map(a=>e.cam[a]+t[a]*i[0]+n[a]*i[1]+r[a]*i[2]),a.mount(S);for(let e of c)s.fire(e,g),a.flash(S,!0),_(void 0,e.power)}c=[],h=[];for(let e of o){let t=f.get(e.id),n=[e.x,e.y+Ee(e),e.z];t!==void 0&&e.shots!=t&&(a.flash(y(e)),_(n)),f.set(e.id,e.shots);let r=m.get(e.id),i=as(r,e);i>=0&&b(i,n),r&&x(r,e,n),m.set(e.id,{swing:e.swing,cut:e.cut,wield:e.wield,blade:e.blade}),e.zap&&e.stun>0&&a.crackle([e.x,e.y+1,e.z])}for(let e of f.keys())o.some(t=>t.id==e)||(f.delete(e),m.delete(e));let{orbs:C,bursts:w}=s.frame(g,e=>{let t=o.find(t=>t.id==e);return e==n?.id?S:t&&y(t)});a.orbs(C);for(let e of w)a.burst(e),t.play(H.SPLASH,e)}}},ls=e=>.6+.2*e,us=e=>e?.mode===x.GROUND||e?.mode===x.CROUCH,ds=e=>us(e)||e?.mode===x.WALLRUN,fs=[[0,0],[1,0],[-1,0],[0,1],[0,-1]],ps=e=>.02+.0025*e,ms=.006,hs=.03,gs=.14,_s=.05,vs=5,ys=9,bs=6.5,xs=.25,Ss=.22,Cs=.9,ws=4,Ts=1,Es=.12,Ds=24,Os=15.7,ks=.45,As=[-8,4,5],js=3,Ms=[-1,1.2],Ns=4,Ps=[-.25,.4,.5],Fs=[-.5,1.5,1.2],Is=[-1.5,.8,1.5],Ls=[.9,.3],Rs=[.1,.05,11],zs=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Bs=(e,t)=>{let n=Math.ceil(t*120);for(let r=0;r<n;r++)e[1]+=(-15.7*Os*e[0]-2*ks*Os*e[1])*(t/n),e[0]+=e[1]*(t/n)},Vs=()=>{let e=0,t=0,n=0,r=0,i=0,a=0,o=0,s=0,c,l,u=[0,0],d=[0,0],f=[0,0],p={dy:0,pitch:0,roll:0,fov:0,lines:0,stride:0,hurt:0,kick:0,lie:0,fire(){s++,u[1]+=Ps[0],d[1]+=Ps[1],f[1]+=Ps[2]*Math.sin(s*2.4),p.kick=1},wound(){u[1]+=Is[0],d[1]+=Is[1],f[1]+=Is[2]*Math.sin(s++),p.hurt=1},jolt(){u[1]+=As[0],d[1]+=As[1],f[1]+=As[2],p.hurt=1},punch(){u[1]+=Ms[0],d[1]+=Ms[1],a=1},cut(e){u[1]+=Fs[0],d[1]-=e==y.SLASH?Fs[1]:0,f[1]+=e==y.LEFT?Fs[2]:e==y.RIGHT?-Fs[2]:0,a=e==y.THRUST?1:a},update(s,m,h,g={ev:0,fall:0}){let _=e=>Math.min(1,h*e),y=s?De(s):0,b=s&&l&&ds(s)&&ds(l)?Math.hypot(s.x-l.x,s.z-l.z):0;b<1&&(p.stride+=b/ls(y)),e+=((us(s)&&b>.5*h&&b<1?1:0)-e)*_(10),l=s,g.ev&C.LAND&&(u[1]-=Ss*Math.min(g.fall,20)),g.ev&C.CLIMB&&(u[1]-=Ss*ws),g.ev&(C.JUMP|C.DOUBLE)&&(u[1]+=Cs),g.ev&C.GRAB&&(d[1]-=Ts),Bs(u,h),Bs(d,h),Bs(f,h),p.hurt*=Math.exp(-h*js),a*=Math.exp(-h*10),p.kick*=Math.exp(-h*22),p.lie+=(+!!s?.down-p.lie)*_(5),o+=h*Rs[2];let S=s?Math.min(1,s.stun/48):0,w=s?Ee(s):0;c=s?c===void 0?w:c+(w-c)*_(14):void 0,p.dy=(c??0)-w+u[0]-Math.cos(p.stride*2*Math.PI)*ps(y)*e-p.lie*(w-Ls[1]),i+=((s?.mode===x.CLIMB?Es*Math.sin(Math.PI*zs(s.t/Ds)):0)-i)*_(10),p.pitch=d[0]+i+Math.sin(o*.8)*Rs[1]*S;let T=s?.mode===x.WALLRUN?fs[s.wall]:[0,0],E=s?T[0]*Math.cos(s.yaw)-T[1]*Math.sin(s.yaw):0,D=+!!(m&v.RIGHT)-!!(m&v.LEFT);t+=(D*hs+E*gs+(s?.mode===x.SLIDE?_s:0)-t)*_(8),p.roll=t+Math.sin(p.stride*Math.PI)*ms*e+f[0]+Math.sin(o)*Rs[0]*S+p.lie*Ls[0];let O=!!s&&s.dash>50;n+=(+O-n)*_(O?40:6),r+=(zs((y-6)/3)-r)*_(4),p.fov=r*vs+n*ys+a*Ns,p.lines+=(zs((y-bs)/(9-bs))*xs+n*.75-p.lines)*_(8)}};return p},Hs=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Us=e=>{let t=e.loop(H.WIND),n=e.loop(H.SCRAPE),r=0,i=/* @__PURE__ */ new Map,a=(t,n,r)=>{let i=Oe(t);e.play(t.mode===x.WALLRUN?H.WALLSTEP:H.STEP,r,i||t.mode===x.WALLRUN?1:t.mode===x.CROUCH?.35:.6,(i?.92:1)*(n&1?1.06:.94))},o=(t,n)=>e.play(H.LAND,n,Hs(t/14,.2),1.25-.5*Hs(t/20));return{me(i,s,c){let l=Math.floor(c),u=l>r;if(r=l,!i||e.muted)return;u&&a(i,l);for(let[t,n]of[[C.JUMP,H.JUMP],[C.DOUBLE,H.DOUBLE],[C.DASH,H.DASH],[C.GRAB,H.GRAB],[C.CLIMB,H.SCUFF]])s.ev&t&&e.play(n);s.ev&C.LAND&&o(s.fall);let d=Hs((Math.hypot(i.vx,i.vy,i.vz)-4)/12);t.set(.55*d**1.5,.6+.9*d);let f=Hs(De(i)/9);n.set(i.mode===x.SLIDE?.2+.5*f:0,.8+.4*f)},others(t){for(let n of t){let t=i.get(n.id);if(t&&!e.muted){let e=[n.x,n.y+.1,n.z],r=Math.hypot(n.x-t.p.x,n.z-t.p.z);if(ds(n)&&ds(t.p)&&r<1){let i=Math.floor(t.stride);t.stride+=r/ls(De(n)),Math.floor(t.stride)>i&&a(n,i,e)}n.ground&&!t.p.ground&&t.p.vy<-3&&o(-t.p.vy,e)}i.set(n.id,{p:n,stride:t?.stride??0})}for(let e of i.keys())t.some(t=>t.id===e)||i.delete(e)}}},Ws=`h5,aside,nav,output,section,em,u,ul,dl,s,mark{position:absolute;margin:0;padding:0;pointer-events:none;user-select:none;white-space:pre-line}h5{top:8px;right:12px;font-size:12px}u{inset:0;opacity:0;background:radial-gradient(ellipse at center,#0000 35%,#d10000dd 120%)}nav{top:8px;left:50%;transform:translateX(-50%);display:grid;grid-template-columns:1fr auto 1fr;gap:2px 16px;align-items:center;text-align:center;font-size:13px}nav span,nav time{font:900 clamp(16px,4.6vw,24px)/1 system-ui,sans-serif;letter-spacing:.03em;white-space:nowrap}nav time{min-width:4.2ch;font-variant-numeric:tabular-nums;font-size:clamp(14px,3.8vw,20px)}nav small{font-size:clamp(10px,2.6vw,12px);white-space:nowrap;opacity:.95}nav small:first-of-type{text-align:right}nav small:last-of-type{text-align:left}output{top:20%;left:50%;transform:translateX(-50%);padding:6px 18px;font:900 clamp(18px,3.4vw,30px)/1.1 system-ui,sans-serif;letter-spacing:.06em;text-transform:uppercase;white-space:nowrap;background:#000a;border-bottom:3px solid currentColor}em{font-style:normal;font-size:13px;font-weight:800;line-height:1.1;text-align:center;transform:translate(-50%,-50%)}em span{display:block;font-size:20px;line-height:1}section{inset:0;z-index:2;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:0 12px;text-align:center;background:#000c}section h6{font:900 clamp(30px,9vw,72px)/1 system-ui,sans-serif;letter-spacing:.04em}section strong{font-size:34px}section td:first-child{text-align:left;opacity:1}section td+td{text-align:center}section th{padding:2px 10px;font-size:12px;opacity:.7;font-weight:600}aside{inset:0;z-index:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;padding:0 12px;text-align:center;background:#000b}h6{margin:0;font-size:inherit;text-shadow:none}aside h6{font:900 clamp(36px,13vw,84px)/1 system-ui,sans-serif;letter-spacing:.04em;transform:skewX(-8deg);background:linear-gradient(#fe6,#f92 45%,#d21);-webkit-background-clip:text;background-clip:text;color:transparent;filter:drop-shadow(0 3px 0 #500) drop-shadow(0 0 14px #f604)}ul{left:12px;bottom:30px;display:flex;gap:4px;list-style:none}li{width:16px;height:6px;background:#fff;box-shadow:0 0 0 1px #0008}li.e{background:#0000;box-shadow:inset 0 0 0 1px #fffb,0 0 0 1px #0008}ul.low li{background:#f55}ul.low li.e{background:#0000}dl{left:50%;bottom:10px;transform:translateX(-50%);display:flex;align-items:center;gap:10px}dl svg{width:38px;fill:#fff;filter:drop-shadow(0 1px 1px #000)}dl.k svg:first-child,dl:not(.k) svg+svg,dl.k data{display:none}dl.k svg{width:64px;fill:#8ef}dl small{position:absolute;bottom:100%;left:50%;transform:translateX(-50%);display:flex;gap:10px;font-size:11px;white-space:nowrap}dl kbd{font:inherit;opacity:.5}dl kbd.a{opacity:1}@media(max-width:520px){dl{left:auto;right:12px;bottom:46px;transform:none}dl small{left:auto;right:0;transform:none}}dl data{font:900 clamp(30px,5vw,46px)/1 system-ui,sans-serif;font-variant-numeric:tabular-nums}dl.e data{color:#f66}s{left:50%;top:50%;width:28px;height:28px;margin:-14px 0 0 -14px;background:linear-gradient(45deg,#0000 44%,#fff 44% 56%,#0000 56%),linear-gradient(-45deg,#0000 44%,#fff 44% 56%,#0000 56%);-webkit-mask:radial-gradient(#0000 6px,#000 7px);mask:radial-gradient(#0000 6px,#000 7px)}mark{inset:0;z-index:1;padding-top:30vh;text-align:center;color:#ddd;background:radial-gradient(ellipse at center,#6668 0%,#4a0c0ce8 130%);backdrop-filter:grayscale(1)}mark::first-line{font:900 clamp(30px,8vw,64px)/1 system-ui,sans-serif;letter-spacing:.24em}strong{font-size:22px}table{border-collapse:collapse;font-size:16px}td{padding:2px 10px}td+td{text-align:left}td:first-child{text-align:right;opacity:.7}`,Gs=2800,Ks=e=>`${Math.floor(e/60)}:${`${e%60}`.padStart(2,`0`)}`,qs=e=>{e.insertAdjacentHTML(`beforeend`,`<aside hidden><h6>TINY FPS</h6><span></span><table><tr><td>Mouse<td>look<tr><td>WASD / ZQSD<td>move<tr><td>Shift<td>sprint<tr><td>Space<td>jump, again in the air<tr><td>Move key twice<td>dash that way<tr><td>C<td>crouch, slide when fast<tr><td>Left click<td>fire, hold to charge<tr><td>1, 2, wheel<td>gun, katana<tr><td>Katana + W<td>thrust<tr><td>Katana + A or D<td>cut across<tr><td>Katana alone<td>slash<tr><td>Double click<td>special: lunge, spin, leap<tr><td>M<td>mute</table><span>Take the enemy flag to your own base while yours is home. Jump onto the armoury past your flag for the gun and the katana.</span><strong></strong></aside><u></u><h5 hidden>Muted (M)</h5><ul>${`<li></li>`.repeat(5)}</ul><dl hidden><svg viewBox="0 0 38 22"><path d="M1 7c3-5 13-7 22-4l7 3 3 1v4l-6 1-4 2-1 1-3 6h-5l2-7-5-1c-6-1-12-3-10-6z"/></svg><svg viewBox="0 0 38 22"><path d="M12 14.4C19 11.6 29 6.4 37 1c-3.6 7-14.4 13.4-24.4 16zM1 20.2l7-6.6 1.6 1.8-7 6.6zM7.6 12.4l3.2-1.4 2 4.6-3.2 1.4z"/></svg><data></data><small hidden><kbd>1 gun</kbd><kbd>2 katana</kbd></small></dl><s hidden></s><mark hidden></mark><nav hidden><span></span><time></time><span></span><small></small><small></small></nav><output hidden></output><section hidden><h6></h6><strong></strong><table></table><span></span></section>`);let t=t=>e.querySelector(t),[n,r]=[`h5`,`aside`].map(e=>t(e)),[i,a]=[`aside span`,`aside strong`].map(e=>t(e)),o=(e,t)=>e.textContent!=t&&(e.textContent=t),s=t(`nav`),[c,d,f]=[...s.querySelectorAll(`span, time`)],[p,m]=[...s.querySelectorAll(`small`)],h=[...e.querySelectorAll(`li`)],[g,v,y,b]=[t(`ul`),t(`dl`),t(`s`),t(`mark`)],[x,S]=[t(`data`),t(`dl small`)],C,w=t(`output`),T=t(`u`),E=t(`section`),[D,O,k]=[`h6`,`strong`,`span`].map(e=>E.querySelector(e)),A=E.querySelector(`table`),j=[],ee,M,te=(e,t)=>e.style.color=u[t];return[c,p].forEach(e=>te(e,0)),[f,m].forEach(e=>te(e,1)),{title(e,t){r.hidden=!e,o(i,t),o(a,e)},mute:e=>n.hidden=!e,match(e,t){s.hidden=!1,o(c,`${l[0].toUpperCase()} ${e.score[0]}`),o(f,`${e.score[1]} ${l[1].toUpperCase()}`),o(d,e.over?`END`:Ks(e.clock)),e.flags.forEach((e,n)=>{let r=e.state===_.CARRIED?`taken by ${t(e.by)}`:e.state===_.DROPPED?`dropped ${e.left}s`:`home`;o(n?m:p,`${l[n]} flag: ${r}`)})},marks(t){for(;j.length<t.length;){let t=document.createElement(`em`);t.innerHTML=`<span></span><small></small>`,j.push(t),e.append(t)}j.splice(t.length).forEach(e=>e.remove()),t.forEach((e,t)=>{let n=j[t];n.style.left=`${e.x*100}%`,n.style.top=`${e.y*100}%`,te(n,e.team);let[r,i]=[n.children[0],n.children[1]];r.style.transform=e.arrow===void 0?``:`rotate(${e.arrow}rad)`,o(r,e.arrow===void 0?`▼`:`▲`),o(i,`${e.kind===`base`?`Base `:``}${e.text}`)})},hurt(e){let t=e<.01?``:`${Math.min(1,e)}`;T.style.opacity!=t&&(T.style.opacity=t)},vitals(e,t,n=!1,r=!1){h.forEach((t,n)=>t.classList.toggle(`e`,n>=e)),g.classList.toggle(`low`,e<=1);let i=t>=0,a=n&&(r||!i);v.hidden=!i&&!n,v.classList.toggle(`k`,a),v.classList.toggle(`e`,!a&&!t),o(x,`${Math.max(t,0)}`),S.hidden=!(i&&n),[...S.children].forEach((e,t)=>e.classList.toggle(`a`,!!t==a))},hit(){y.hidden=!1,clearTimeout(C),C=setTimeout(()=>y.hidden=!0,140)},down(e,t){b.hidden=e<.02,b.style.opacity=`${Math.min(e,1)}`,o(b,b.hidden?``:`DOWN\nBack in ${t.toFixed(1)}`)},banner(e,t){w.hidden=!1,o(w,e),w.style.color=t===void 0?`#fff`:u[t],clearTimeout(ee),ee=setTimeout(()=>w.hidden=!0,Gs)},end(e,t){if(E.hidden=!e,!e)M=void 0;else{if(M!==e){M=e;let[t,n]=e.score,r=t>n?0:n>t?1:-1;o(D,r<0?`DRAW`:`${l[r].toUpperCase()} WINS`),D.style.color=r<0?`#fff`:u[r],o(O,`${t} – ${n}`);let i=[...e.players].sort((e,t)=>t.caps-e.caps||t.returns-e.returns||e.id-t.id);A.replaceChildren(),A.insertAdjacentHTML(`beforeend`,`<tr><th>Player<th>Captures<th>Returns</tr>`);for(let e of i){let t=A.insertRow();[e.name,e.caps,e.returns].forEach(e=>t.insertCell().textContent=`${e}`),t.style.color=u[e.team]}}o(k,`Next match in ${t}`)}}}},Js=.0025,Ys=Math.PI*2,Xs={KeyW:v.FORWARD,ArrowUp:v.FORWARD,KeyS:v.BACK,ArrowDown:v.BACK,KeyA:v.LEFT,ArrowLeft:v.LEFT,KeyD:v.RIGHT,ArrowRight:v.RIGHT,Space:v.JUMP,ShiftLeft:v.SPRINT,ShiftRight:v.SPRINT,KeyC:v.CROUCH},Zs=v.FORWARD|v.BACK|v.LEFT|v.RIGHT,Qs=(e,t)=>e&~Zs|t|v.DASH,$s=e=>Xs[e]??0,ec=(e,t)=>t==`Digit1`?!1:t==`Digit2`||e,tc=(e,t,n)=>!n||!n.blade&&n.ammo<0?!1:n.blade&&t&&!t.blade?!0:e,nc=(e,t)=>t?e|v.BLADE:e,rc=(e,t=()=>{})=>{let r=new AbortController,i=(e,t,n,i={})=>e.addEventListener(t,n,{signal:r.signal,...i}),a=/* @__PURE__ */ new Set,o=/* @__PURE__ */ new Map,s=0,c=-1/0,l=-1/0,u=!1,d={yaw:0,pitch:0,keys:0,blade:!1,take(){let e=(s?Qs(d.keys,s):d.keys)|(u?v.FIRE|v.SPECIAL:0);return s=0,u=!1,nc(e,d.blade)},track:(e,t)=>void(d.blade=tc(d.blade,e,t)),locked:()=>e.getRootNode().pointerLockElement==e,destroy:()=>r.abort()};i(e,`click`,()=>{Promise.resolve(e.requestPointerLock()).catch(()=>{})}),i(document,`mousemove`,e=>{d.locked()&&(d.yaw=((d.yaw-e.movementX*Js)%Ys+Ys)%Ys,d.pitch=Math.max(-1.55,Math.min(n,d.pitch-e.movementY*Js)))}),i(document,`mousedown`,e=>{if(d.locked()&&!e.button){d.keys|=v.FIRE;let e=performance.now();u||=e-l<=300,l=u?-1/0:e}}),i(document,`mouseup`,e=>{e.button||(d.keys&=~v.FIRE)}),i(document,`wheel`,e=>{let t=performance.now();d.locked()&&e.deltaY&&(e.preventDefault(),t-c>=250&&(c=t,d.blade=!d.blade))},{passive:!1}),i(document,`keydown`,e=>{let n=$s(e.code);if(d.locked()&&(d.blade=ec(d.blade,e.code)),e.code==`KeyM`&&!e.repeat&&d.locked()&&t(),n&&d.locked()){if(n&Zs&&!e.repeat&&!a.has(e.code)){let t=performance.now(),r=o.get(e.code);r!==void 0&&t-r<=250?(s=n,o.delete(e.code)):o.set(e.code,t)}a.add(e.code),d.keys|=n,e.preventDefault()}}),i(document,`keyup`,e=>{a.delete(e.code),d.keys&=~$s(e.code)});let f=()=>{d.keys=s=0,a.clear(),o.clear()};return i(window,`blur`,f),i(document,`pointerlockchange`,()=>d.locked()||f()),d},ic=120,ac=16,oc=e=>{let t={...e};return delete t.ack,delete t.by,t},sc=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n,z:e.z+(t.z-e.z)*n}),cc=(e,t,n)=>me(e+(((t-e+Math.PI)%V+V)%V-Math.PI)*n),lc=(e,t)=>(t-e&65535)<32768,uc=(e,t,n)=>({...t,...sc(e,t,n),yaw:cc(e.yaw,t.yaw,n),pitch:e.pitch+(t.pitch-e.pitch)*n}),dc=e=>{let t,n=0,r=0,i=[],a,o,s=[],c=0,l=0,u=!0,d=e=>{let t=e-100,n=0;for(;n+1<s.length&&s[n+1].t<=t;)n++;let r=s[n],i=s[n+1]??r;return{a:r,b:i,u:i.t>r.t?Math.max(0,Math.min(1,(t-r.t)/(i.t-r.t))):0}},f=e=>{if(!s.length)return;let{a:t,b:n,u:r}=d(e);return(t.s.tick+(n.s.tick-t.s.tick&65535)*r)%65536};return{you:(e,r=0)=>{[t,n]=[e,r]},step:(t,s)=>{let d=mt({...t,seq:r,view:s===void 0?void 0:f(s)});return r=r+1&65535,i.push(d),i.length>ic&&i.shift(),a&&(o=oc(a),tr(a,d,e,n,u),c|=a.ev,l=Math.max(l,a.fall)),d},snapshot:(r,c)=>{s.push({t:c,s:r}),s.length>ac&&s.shift();let l=r.players.find(e=>e.id===t);l&&(u=!r.over,i=i.filter(e=>!lc(e.seq,l.ack)),a=oc(l),o=oc(a),i.forEach((t,r)=>{r===i.length-1&&(o=oc(a)),tr(a,t,e,n,u)}))},events:()=>{let e={ev:c,fall:l};return c=l=0,e},me:e=>a&&o?uc(o,a,Math.max(0,Math.min(1,e))):void 0,others:e=>{let n=s.at(-1);if(!n)return[];let{a:r,b:i,u:a}=d(e);return n.s.players.filter(e=>e.id!==t).map(e=>{let t=r.s.players.find(t=>t.id===e.id),n=i.s.players.find(t=>t.id===e.id);return t&&n?uc(oc(t),oc(n),a):oc(n??t??e)})}}},fc={x0:.05,x1:.95,y0:.15,y1:.92},pc=(e,t,n,r,i)=>{let[a,o]=[r-e,i-t];return Math.atan2(a*Math.cos(n)-o*Math.sin(n),-a*Math.sin(n)-o*Math.cos(n))},mc=e=>{let[t,n]=[Math.sin(e),-Math.cos(e)],[r,i]=[(fc.x0+fc.x1)/2,(fc.y0+fc.y1)/2],[a,o]=[(fc.x1-fc.x0)/2,(fc.y1-fc.y0)/2],s=Math.min(a/(Math.abs(t)||1e-9),o/(Math.abs(n)||1e-9));return[r+t*s,i+n*s]},hc=2.6,gc=e=>{let t=[],n=(n,r,[i,a,o])=>{let s=Math.round(Math.hypot(i-e.eye[0],a+hc-e.eye[1],o-e.eye[2])),c=e.project(i,a+hc,o),l=c&&c[0]>=fc.x0&&c[0]<=fc.x1&&c[1]>=fc.y0&&c[1]<=fc.y1,u=`${s} m`;if(l)t.push({team:n,kind:r,x:c[0],y:c[1],text:u});else{let a=pc(e.eye[0],e.eye[2],e.yaw,i,o),[s,c]=mc(a);t.push({team:n,kind:r,x:s,y:c,arrow:a,text:u})}},r=e.flags.some(t=>t.state===_.CARRIED&&t.by===e.id);return e.flags.forEach((t,i)=>{if(t.state===_.CARRIED&&t.by===e.id){n(e.team,`base`,e.bases[e.team]);return}if(r&&i===e.team&&t.state===_.HOME)return;let a=t.state===_.HOME?e.bases[i]:t.state===_.DROPPED?[t.x,t.y,t.z]:e.where(t.by);a&&n(i,`flag`,a)}),t},_c=(e=[],t=0,n=0)=>e.filter((e,r)=>n+r<32&&t>>>n+r&1),vc=(e,t,n,r,i=!1)=>{let a=n.map(e=>e*.45);cn(e,an(1,1,[1,1],[0,0]),t,[t[0],t[1]+.72,t[2]],[1,0,0],1,.06,a);let[o,s,c]=t;on(e,an(1,0,[1,1]),[o,s+.74,c],Qt(0,0),[0,0,0],[.3,.035,.3],n);let l=e.length;xn(e,[o,s+.045,c],m-.07,m,n),yn(e,l,1.2*pn*(.7+.3*Math.sin(r*2.5)));let u=[o,s+1.05+.04*Math.sin(r*2),c],d=Qt(r*.8,0);i?ma(e,u.map((e,t)=>e-d[2][t]*.42),d,0,r):on(e,yi(0),u,d,[0,0,0],1.5)},yc=(e,t=[],n=[],r=0)=>{t.forEach((t,n)=>t&&vc(e,t,gn(n),r)),n.forEach((t,n)=>t&&vc(e,t,gn(n),r,!0))},bc=[[[1,0,0],[0,1,0],[0,0,1]],[[-1,0,0],[0,0,1],[0,1,0]],[[0,1,0],[0,0,1],[1,0,0]],[[0,-1,0],[1,0,0],[0,0,1]],[[0,0,1],[1,0,0],[0,1,0]],[[0,0,-1],[0,1,0],[1,0,0]]],xc=(e,t,n,r)=>[[[e,t],[n,t],[n,r]],[[e,t],[n,r],[e,r]]],Sc=[...xc(-.13,-.04,.13,.04),...xc(-.04,-.13,.04,.13)],Cc=[...xc(-.035,-.09,.035,.04),[[-.035,.04],[.035,.04],[0,.11]],...xc(-.05,-.12,.05,-.095)],wc=(e,t,n,r,i,a,o)=>{let[s,,c]=Qt(n*.9,0),l=[t[0],t[1]+.45+.07*Math.sin(n*2.2+t[0]),t[2]],u=([e,t,n])=>[s[0]*e-c[0]*n,t,s[2]*e-c[2]*n];for(let[t,n,s]of bc){let c=(e,i,a)=>{let[o,c,d]=u([0,1,2].map(o=>t[o]*r*a+n[o]*e+s[o]*i));return[l[0]+o,l[1]+c,l[2]+d]};bn(e,c(-r,-r,1),c(r,-r,1),c(r,r,1),i),bn(e,c(-r,-r,1),c(r,r,1),c(-r,r,1),i);let d=e.length;for(let[t,n,r]of a)bn(e,c(...t,1.01),c(...n,1.01),c(...r,1.01),o);for(let t=d;t<e.length;t+=10)e[t+8]=-2}},Tc=(e,t,n)=>wc(e,t,n,.17,[.86,.9,.88],Sc,[.1,1.2,.4]),Ec=(e,t,n)=>wc(e,t,n,.15,[.34,.14,.58],Cc,[.3,1.4,1.8]),Dc=1,Oc=12,kc=(e,t)=>(n,r,i)=>{if(!e)return t;let a=le(e,[n,r+.2,i],[0,-1,0],99);return a<99?r+.2-a:-1/0},Ac=(e,t,n)=>{let r=[];go(r,fo(1,e)[1],t,Ja([0,0,0]));let i=r.length/10,a=r.slice(r.length-10,r.length-10+3),o=[0,1,2].map(e=>r.reduce((t,n,r)=>r%10==e?t+n:t,0)/i),s=[];for(let e=0;e<r.length;e+=30)s.push([r[e]-o[0],r[e+1]-o[1],r[e+2]-o[2]]);let c=t.pos[G.PELVIS],l=W([a[0]-c[0]+.3*Math.sin(n.yaw),0,a[2]-c[2]+.3*Math.cos(n.yaw)]);return{limb:e,s:t,c:o,pts:s,long:W([o[0]-a[0],o[1]-a[1],o[2]-a[2]]),p:[...o],v:[n.vx+l[0]*1.5,Math.max(n.vy,0)+3,n.vz+l[2]*1.5],q:[0,0,0,1],w:[l[2]*7,1.5,-l[0]*7],at:a,age:0}},jc=(e,t,n)=>{e.age+=t,e.v[1]-=20*t,e.p=e.p.map((n,r)=>n+e.v[r]*t);let r=Math.hypot(...e.w);r>1e-6&&(e.q=K(q(W(e.w),r*t),e.q));let i=Math.min(...e.pts.map(t=>J(e.q,t)[1])),a=n(e.p[0],e.p[1],e.p[2])-e.p[1]-i;if(a>0){e.p[1]+=a,e.v[1]=e.v[1]<-2?-.3*e.v[1]:Math.max(e.v[1],0);let n=Math.exp(-6*t),[r,i,o]=J(e.q,e.long);e.w=[e.w[0]*n+40*o*i*t,e.w[1]*n,e.w[2]*n-40*r*i*t],e.v[0]*=n,e.v[2]*=n}},Mc=(e,t,n,r,i)=>{let a=e.p.down?e.p.lost??0:0;if(!a){e.cut=void 0;return}if(!e.cut){if(e.cut=Ac(a,lr(e.gait.pose()),e.p),r){for(let t=0;t<240;t++)jc(e.cut,1/60,n);return}i?.shock(e.cut.at)}let o=e.cut.age;jc(e.cut,t,n),o<Dc&&Math.floor(e.cut.age*Oc)>Math.floor(o*Oc)&&i?.spit(e.cut.at)},Nc=(e,t,n,r,i)=>{let a=e.length;go(e,fo(r,t.limb)[1],t.s,n);for(let n=a;n<e.length;n+=10){let r=J(t.q,[e[n]-t.c[0],e[n+1]-t.c[1],e[n+2]-t.c[2]]),a=J(t.q,[e[n+3],e[n+4],e[n+5]]);for(let o=0;o<3;o++)e[n+o]=r[o]+t.p[o]-(o==1?i:0),e[n+3+o]=a[o]}},Pc=14,Fc=e=>{let t=Qt(e.yaw,e.pitch)[2];return[e.x+t[0]*30,e.y+1.6+t[1]*30,e.z+t[2]*30]},Ic=.5,Lc=e=>e.dash>50,Rc=e=>{let t=ei();return t.update(e,0),{p:{...e},gait:t,dash:+Lc(e),since:1e3,aim:0,focus:Fc(e),prog:-1,trail:bo(),t:0}},zc=(e,t)=>(n,i)=>{let a=le(e,[n,t+r,i],[0,-1,0],2*r);return a>0&&a<1?t+r-a:t},Bc=(e,t,n,r,i)=>{for(let n of e.keys())t.some(e=>e.id==n)||e.delete(n);for(let a of t){let t=e.get(a.id);t?(t.gait.update(a,n,r&&zc(r,a.y)),t.dash+=(+Lc(a)-t.dash)*(1-Math.exp(-n*Pc)),t.since=a.shots==t.p.shots?t.since+n:0,t.aim=t.since==0?1:t.aim+(+(t.since<Ic)-t.aim)*(1-Math.exp(-n*12)),t.focus=t.since<Ic?r?Hi(a,r)[0]:Fc(a):t.focus,t.prog=Ma(t.prog,a,n),t.trail.update(n),t.t+=n,t.p={...a}):e.set(a.id,Rc(a)),Mc(e.get(a.id),n,kc(r,a.y),!t,i)}},Vc=(e,t,n,r,i)=>{let[a,o]=Ui(n,r),s=e.rot.slice(),c={...e,rot:s},[l,u]=[o[0],o[2].map((e,t)=>e*hi[1]-o[1][t]*hi[0])],d=a.map((e,t)=>e-.078*u[t]+.022*l[t]),f=[l[0]*.7,-1,l[2]*.7];return No(c,t,G.ARM_R,d.map((e,n)=>t.pos[G.HAND_R][n]+(e-t.pos[G.HAND_R][n])*i),f),s[G.HAND_R]=cr(s[G.HAND_R],K(ko(lr(c).rot[G.FOREARM_R]),kr(l,u)),i),c},Hc=[.08,-.3,.26,.1,.92,-.3],Uc=e=>(e=Math.min(Math.max(e,0),1))*e*(3-2*e),Wc=(e,t,n,r)=>{let i=n<0?0:Uc(n*6)*Uc((1-n)*5),a=Ea(t.cut??0,Math.max(n,0)),o=Hc.map((e,t)=>e+(a[t]-e)*i);o[1]+=.02*Math.sin(V*r)*(1-i);let[s,c,l]=n<0?[0,0,0]:Aa(t.cut??0,n).map(e=>e*i),u=n<0?0:Ca(t.cut??0,n)+ja*s,d={...e,yaw:e.yaw+u},[f,p,m]=Qt(t.yaw+u+(1-ja)*s,Math.max(t.pitch,-va)*i-.6*c),h=([e,t,n])=>[f[0]*e+p[0]*t+m[0]*n,f[1]*e+p[1]*t+m[1]*n,f[2]*e+p[2]*t+m[2]*n],g=d.rot.slice(),_={...d,rot:g};for(let[e,t]of[[G.SPINE,.4],[G.CHEST,.6]])g[e]=K(g[e],K(K(q([0,1,0],s*t),q([1,0,0],-c*t)),q([0,0,1],l*t)));let v=lr(_),y=v.pos[G.HEAD],b=W(h(o.slice(3,6))),x=Yt(y,h(o.slice(0,3)));return Uo(_,v,G.ARM_R,x,b,h([.5,-1,-.35])),Uo(_,v,G.ARM_L,Yt(x,b.map(e=>-Ji*e)),b,h([-.5,-1,-.35])),_},Gc=(e,t,n,r)=>{let i=W([-t.p.vx,0,-t.p.vz]),[a,o,s]=n.map(e=>.6+.6*e);[[.5,.12,1.3],[.9,-.16,1.7],[1.25,.14,1.2]].forEach(([n,c,l],u)=>{let d=r([c,n,-.2-.1*u]),f=d.map((e,n)=>e+i[n]*l*t.dash);for(let t of[[-i[2]*.03,0,i[0]*.03],[0,.03,0]])for(let n of[d.map((e,n)=>e+t[n]),d.map((e,n)=>e-t[n]),f])e.push(...n,0,1,0,a,o,-2,s)})},Kc=(e,t,n,r=1)=>{let i=t.gait.pose(),{p:a}=t,o=Ja(n,qa(a.id)),s=a.down?.5*Math.min(Math.max(1-a.down/30,0),1):0;a.down&&(i={...i,at:[i.at[0],i.at[1]-s,i.at[2]]});let c=lr(i),l=a.wield&&!a.down;if(l?(i=Wc(i,a,t.prog,t.gait.phase),c=lr(i)):t.aim>.01&&a.ammo>=0&&(i=Vc(i,c,a,t.focus,t.aim),c=lr(i)),t.cut?(go(e,fo(r,t.cut.limb)[0],c,o),t.cut.at=e.slice(e.length-10,e.length-10+3),Nc(e,t.cut,o,r,s)):go(e,so(r),c,o),l?(ga(e,c.pos[G.HAND_R],c.rot[G.HAND_R],r,t.t),t.trail.mark(..._a(c.pos[G.HAND_R],c.rot[G.HAND_R]),Na(t.prog))):a.ammo>=0&&!a.down&&Ri(e,c.pos[G.HAND_R],c.rot[G.HAND_R],r),t.dash>.15){let[r,a]=[Math.sin(i.yaw),Math.cos(i.yaw)],{x:o,y:s,z:c}=t.p;Gc(e,t,n,([e,t,n])=>[o+e*a-n*r,s+t,c-e*r-n*a])}},qc=r,Jc=o+.05,Yc=1.5,Xc=.6,Zc=8,Qc=2.5,$c=3,el=.4,tl=.012,nl=.2,rl=[1.2,1.45],il=[1.6,.12,.08],al=[.9,.07,.05],ol=[.85,.07,.05],sl=(e,t,n,r)=>{let i=-1/0;for(let a of e)if(a!=t&&a.min[0]<=n&&n<=a.max[0]&&a.min[2]<=r&&r<=a.max[2]){if(a.max[1]>t.max[1]+.001){if(a.min[1]<t.max[1])return 1/0}else i=Math.max(i,a.max[1])}return t.max[1]-i},cl=({brushes:e,floor:t},n)=>{let r=n.max.map((e,t)=>e-n.min[t]),i=[...r].sort((e,t)=>e-t),a={beam:i[1]<=Xc&&i[2]>=2*Xc,lips:[],stripes:[]};if(a.beam)return a;for(let i of[0,2]){let o=2-i;for(let t of[0,1]){let s=[n.min[0],0,n.min[2]];s[i]=(t?n.max:n.min)[i]+(t?el:-.4),s[o]=(n.min[o]+n.max[o])/2;let c=sl(e,n,s[0],s[2]);c>qc&&c<=Jc&&r[o]>=Yc&&a.lips.push([i,t])}n.min[1]>t&&r[1]>=Qc&&r[o]>=Zc&&r[i]<=$c&&a.stripes.push([i,0],[i,1])}return a},ll=(e,t,n,r,i,a,o)=>{let[s,c]=[(r+1)%3,(r+2)%3],l=[0,0,0];l[r]=i?1:-1;for(let[u,d]of[[0,0],[1,0],[1,1],[0,0],[1,1],[0,1]]){let f=[0,0,0];[f[r],f[s],f[c]]=[(i?n:t)[r],(u?n:t)[s],(d?n:t)[c]],e.push(...f,...l,o[0],o[1],a,o[2])}},ul=e=>{let t=[];for(let n of e.brushes){let{beam:r,lips:i,stripes:a}=cl(e,n),[o,s]=[n.min.map(e=>e-tl),n.max.map(e=>e+tl)];if(r)for(let e=0;e<3;e++)for(let n of[0,1])(e!=1||n)&&ll(t,o,s,e,n,-1,ol);for(let[e,r]of i){let i=r?1:-1,a=(r?n.max:n.min)[e],o=[n.min[0],n.max[1]+tl,n.min[2]],s=[n.max[0],n.max[1]+tl,n.max[2]];[o[e],s[e]]=r?[a-nl,a]:[a,a+nl],ll(t,o,s,1,1,-2,il);let[c,l]=[o.slice(),s.slice()];[c[1],l[1]]=[n.max[1]-nl,n.max[1]],[c[e],l[e]]=[a+i*tl,a+i*tl],ll(t,c,l,e,r,-2,il)}for(let[e,r]of a){let i=2-e,[a,o]=[[...n.min],[...n.max]];[a[1],o[1]]=[n.min[1]+rl[0],n.min[1]+rl[1]],[a[i],o[i]]=[n.min[i]+.3,n.max[i]-.3],a[e]=o[e]=(r?n.max:n.min)[e]+(r?tl:-.012),ll(t,a,o,e,r,-2,al)}}return t},dl=4.2,fl=({teams:e})=>{let t=[];return e.forEach(({base:[e,n,r]},i)=>{let a=gn(i),o=a.map(e=>.25+.45*e),s=(i,a,o,s,c,l)=>ll(t,[e+i,n+l,r+a],[e+o,n+l,r+s],1,1,-1,c);s(-4.2,-4.2,dl,dl,o,.02);for(let[e,t,n,r]of[[-4.2,-4.2,dl,-3.85],[-4.2,3.85,dl,dl],[-4.2,-4.2,-3.85,dl],[3.85,-4.2,dl,dl]])s(e,t,n,r,a.map(e=>e*.8),.03)}),t},pl=10,ml=150,hl=3,gl=3,[_l,vl,yl,bl]=[[.3,.3,.29],[.09,.09,.1],[.8,.8,.78],[.85,.62,.08]],xl=({brushes:e})=>[0,2].flatMap(t=>[Math.min(...e.map(e=>e.min[t])),Math.max(...e.map(e=>e.max[t]))]),Sl=e=>{let t=xl(e),n=Math.hypot(t[1]-t[0],t[3]-t[2])/2+ml,r=(e,t)=>{let r=[];for(let i=0;(t-e)/2+pl+8+i*72<=n;i++)r.push(e-pl-8-i*72,t+pl+8+i*72);return r.sort((e,t)=>e-t)};return{box:t,reach:n,xs:r(t[0],t[1]),zs:r(t[2],t[3])}},Cl=({brushes:e,floor:t})=>e.map(e=>e.min[1]<=t?{...e,min:[e.min[0],-80,e.min[2]]}:e),wl=e=>{let{box:t,xs:n,zs:r}=Sl(e),i=[],a=(e,t,n,r,a,o)=>ll(i,[e,-80+a,t],[n,-80+a,r],1,1,-1,o),[o,s]=[(t[0]+t[1])/2,(t[2]+t[3])/2];a(o-1e3,s-1e3,o+1e3,s+1e3,0,_l),a(t[0],t[2],t[1],t[3],.12,vl);for(let{min:t,max:n}of e.brushes)t[1]<=e.floor&&a(t[0]-gl,t[2]-gl,n[0]+gl,n[2]+gl,.3,_l);for(let[e,t,i]of[[0,n,r],[1,r,n]])for(let n of t){let t=(t,r,i,o,s,c)=>e?a(i,n+t,o,n+r,s,c):a(n+t,i,n+r,o,s,c);t(-8,8,i[0]-8,i[i.length-1]+8,.12,vl),i.forEach((e,n)=>{for(let n of[-1,1])for(let r=0;r<8;r++)t(2*r-8+.5,2*r-8+1.5,e+n*8,e+n*11,.24,yl);let[r,a]=[e+8+hl,i[n+1]-8-hl];if(a>r){t(-7.6,-7.2,r,a,.24,yl),t(7.2,7.6,r,a,.24,yl);for(let e=r+2;e+4<a;e+=9)t(-.2,.2,e,e+4,.24,bl)}})}return i},Tl=Object.keys(w).length,El=(e,t,n)=>{let r=Math.imul(e,374761393)+Math.imul(t,668265263)+Math.imul(n,144665)|0;return r=Math.imul(r^r>>>13,1274126177),((r^r>>>16)>>>0)/4294967296},Dl=(e,t,n,r)=>{let[i,a]=[Math.floor(e),Math.floor(t)],[o,s]=[e-i,t-a].map(e=>e*e*(3-2*e)),c=(e,t)=>El((i+e)%n,(a+t)%n,r);return(c(0,0)*(1-o)+c(1,0)*o)*(1-s)+(c(0,1)*(1-o)+c(1,1)*o)*s},Ol=(e,t,n,r,i)=>{let[a,o]=[0,.5];for(let s=0;s<r;s++,o/=2)a+=o*Dl(e*(1<<s),t*(1<<s),n<<s,i+s);return a/(1-o*2)},kl=(e,t,n)=>e.map((e,r)=>e+(t[r]-e)*n),Al=(e,t)=>e.map(e=>e*t),jl=e=>Math.min(Math.max(e,0),1),Ml=Math.PI*2,Nl=[];Nl[w.BRICK]=(e,t)=>{let n=Math.floor(t*8),r=e*4+(n&1)*.5,[i,a,o]=[Math.floor(r)%4,r%1,t*8%1],s=Dl(e*16,t*16,16,5),c=.8+.4*s;return a<.05||o<.1?[Al([165,160,150],.7+.3*c),.1+.1*s]:[Al([170,78,56],(.8+.4*El(i,n,1))*c*(.85+.15*o)),.7+.2*s+.1*jl(Math.min(a-.05,o-.1)*12)]},Nl[w.TILE]=(e,t)=>{let[n,r]=[Math.floor(e*4),Math.floor(t*4)],[i,a]=[e*4%1,t*4%1],o=Dl(e*16,t*16,16,7),s=.9+.2*o;return i<.05||a<.05?[Al([85,85,80],s),.1]:[Al([196,190,172],s*(.88+.08*(n+r&1)+.1*El(n,r,2))),.8+.1*o+.1*jl((Math.min(i,a)-.05)*14)]},Nl[w.LAVA]=(e,t)=>{let n=Ol(e*4,t*4,4,4,11),r=Math.max(0,1-Math.abs(n-.5)*7)**2;return[kl(kl([55,8,4],[230,70,8],n),[255,215,90],r),.5]},Nl[w.STONE]=(e,t)=>{let n=Ol(e*8,t*8,8,4,3);return[Al([128,124,120],.45+.7*(n*1.3+.1*El(Math.floor(e*128),Math.floor(t*128),4))),jl(n*1.4-.2)]},Nl[w.METAL]=(e,t)=>{let[n,r,i,a]=[Math.floor(e*2),Math.floor(t*2),e*2%1,t*2%1],o=jl((Dl(e*8,t*8,8,13)-.68)*6),s=e=>Math.min(Math.max(Math.round((e-.1)/.4),0),2)*.4+.1,[c,l]=[s(i),s(a)],u=c==l&&c==.5?1:Math.hypot(i-c,a-l),d=jl(1-u/.07),f=Al([98,108,124],(.9+.2*Dl(e*32,t*32,32,9)+.12*El(n,r,6))*(1+.3*d)*(.65+.35*jl((u-.06)/.04)));return Math.min(i,a,1-i,1-a)<.03?[Al([40,44,50],1+o),.05]:[kl(f,[105,68,45],o*.7),.5+.1*(1-o)+.4*d]},Nl[w.WOOD]=(e,t)=>{let n=Math.floor(t*8),r=e*2+El(n,0,8)*2,[i,a,o]=[Math.floor(r)%2,r%1,t*8%1],s=El(n,i,3),c=.5+.5*Math.sin(Ml*(t*40+2.5*Dl(e*4,t*4,4,21)+s*7));return o<.08||a<.015?[[28,18,10],.05]:[kl([92,58,32],[158,106,62],c*.6+s*.35),.7+.15*c+.15*jl((o-.08)*15)]},Nl[w.MOSS]=(e,t)=>{let n=Math.floor(t*4),r=e*2+(n&1)*.5,[i,a,o]=[Math.floor(r)%2,r%1,t*4%1],s=Math.min(a,1-a,(o<.5?o:1-o)*.5),c=a<.04||o<.06,l=jl((.3*Ol(e*12,t*12,12,3,17)-.03-s)*12),u=Dl(e*64,t*64,64,19),d=Al([128,126,118],(.7+.4*El(i,n,5))*(.7+.5*Dl(e*16,t*16,16,15)));return[kl(c?Al(d,.45):d,kl([52,100,34],[96,148,56],u),l),c?.1+.6*l*u:.6+.2*jl(s*30)+.2*l*u]},Nl[w.GRATE]=(e,t)=>{let[n,r]=[e*8%1,t*8%1],i=Math.max(Math.abs(n-.5),Math.abs(r-.5)),a=Math.min(Math.abs(n-.5),Math.abs(r-.5))>.43,o=Dl(e*16,t*16,16,23);return i<.36?[[9,9,12],0]:[Al(kl([104,108,116],[96,80,68],jl((o-.55)*4)),(a?1.25:1)-(.5-i)*2.2+.2*o),a?1:.6+.4*jl((i-.36)*12)]},Nl[w.CONCRETE]=(e,t)=>{let[n,r]=[e*2%1,t*2%1],i=Ol(e*4,t*4,4,3,41),a=El(Math.floor(e*128),Math.floor(t*128),43)>.992,o=Math.hypot(n%.5-.25,r%.5-.25)<.02,s=(.94+.1*i+.03*El(Math.floor(e*2),Math.floor(t*2),44))*(a||o?.9:1);return n<.015||r<.015?[Al([160,164,172],s),.3]:[Al([206,209,214],s),o?.5:.8+.2*i-(a?.15:0)]},Nl[w.GLASS]=(e,t)=>{let n=e*2%1,r=((n+t*.7)%1-.5)/.12,i=Math.exp(-r*r);return n<.03||t<.03?[Al([150,158,170],1-.3*n),.9]:[kl(kl([7,20,44],[48,88,136],t**2),[120,160,200],i*.18),.4]},Nl[w.STEEL]=(e,t)=>{let n=Math.floor(t*128),r=.5*El(n,3,31)+.5*Dl(e*8,0,8,n+7),i=e*4%1;return i<.03?[[60,66,76],.1]:[Al([176,184,196],.8+.35*r+(i>.97?.15:0)),.6+.2*r]},Nl[w.PAINT]=(e,t)=>{let[n,r]=[e*2%1,t*2%1],i=El(Math.floor(e*128),Math.floor(t*128),47);return n<.02||r<.02?[[200,200,206],.3]:[Al([246,246,248],.96+.06*i),.85+.04*i]};var Pl=()=>{let e=new Uint8ClampedArray(Tl*128*128*4);return Nl.forEach((t,n)=>{for(let r=0;r<16384;r++){let[i,a]=t(r%128/128,Math.floor(r/128)/128);e.set([...i,a*255],(n*128*128+r)*4)}}),e},Fl=8,Il=40,Ll=130,Rl=60,zl=[[1,.45,.12],[.2,.6,1],[.9,.15,.2],[.25,.85,.55]],Bl=[.22,.5,.14],Vl=.3,Hl=e=>{let{box:t,reach:n,xs:r,zs:i}=Sl(e),[a,o]=[(t[0]+t[1])/2,(t[2]+t[3])/2],s=Math.min(...e.brushes.map(e=>e.max[1]));return r.slice(1).flatMap((e,c)=>i.slice(1).flatMap((l,u)=>{let[d,f,p,m]=[r[c]+8,e-8,i[u]+8,l-8];if(Math.hypot((d+f)/2-a,(p+m)/2-o)>n||d<a&&a<f&&p<o&&o<m)return[];let[h,g]=[f-d,m-p].map(e=>Math.max(1,Math.round(e/Il)));return Array.from({length:h*g},(e,n)=>{let[r,i]=[n%h,Math.floor(n/h)],a=e=>El(c*16+r,u*16+i,Fl+e),[o,l]=[d+(f-d)*r/h,p+(m-p)*i/g],[_,v]=[o+(f-d)/h,l+(m-p)/g],[y,b]=[7+a(3)*7,7+a(4)*7],[x,S]=[(o+_)/2,(l+v)/2],C=Math.hypot(Math.max(t[0]-x,x-t[1],0),Math.max(t[2]-S,S-t[3],0)),T=C<Ll?-20+a(5)*30:-5+a(5)**1.5*100,E=[w.GLASS,w.STEEL,w.CONCRETE][+(a(6)>.7)+ +(a(6)>.85)],D={min:[o+y,-80,l+b],max:[_-y,C<Rl?Math.min(T,s-6):T,v-b],top:w.CONCRETE,side:E},O=D.max[1],k={min:[o+2,-80,l+2],max:[_-2,-80+Vl,v-2],top:w.PAINT,side:w.PAINT,tint:Bl},A=a(10)<.3?[k]:[];return a(0)>.75?[k]:a(7)<.35?[...A,D,{min:[x-(_-o)/6,O,S-(v-l)/6],max:[x+(_-o)/6,O+3+a(8)*3,S+(v-l)/6],top:w.PAINT,side:w.PAINT,tint:zl[Math.floor(a(9)*zl.length)]}]:[...A,D]}).flat()}))},Ul=1.3,Wl=6.5,Gl=.4,Kl=3,ql=12,Jl=4.4*Ul,Yl=4,Xl=260,Zl=90,Ql=[[.95,.62,.03],[.9,.9,.88],[.04,.04,.045],[.7,.05,.06],[.08,.22,.7],[.5,.52,.55]],$l=e=>{let{xs:t,zs:n}=Sl(e),r=e=>e.slice(e.length/2-2,e.length/2+2),i=[];for(let[e,a,o]of[[0,t,n],[1,n,t]])for(let t of r(a))for(let n of[1,-1]){let a=n>0?r(o):r(o).reverse();a.forEach((r,o)=>Array.from({length:Kl},(r,s)=>i.push({axis:e,at:t,d:n,stops:a,cell:o,slot:s,paint:0})))}return i.map((e,t)=>[El(t,e.cell,3),e,El(t,1,4)]).sort((e,t)=>e[0]-t[0]).slice(0,64).map(([,e,t])=>({...e,paint:Math.floor(t*Ql.length)}))},eu=({axis:e,d:t})=>e?[t,0]:[0,t],tu=(e,t)=>{let{axis:n,at:r,d:i,stops:a,cell:o,slot:s}=e,c=t-n*16/2,l=Math.floor(c/16),u=Math.min(Math.max((c-l*16-s*Gl)/(Wl-2*Gl),0),1),d=((o+l)%a.length+a.length)%a.length,f=e=>a[e]-i*(ql+Jl/2+s*8),p=f(d),m=u*u*(3-2*u),h=p+((d+1<a.length?f(d+1):p+i*72)-p)*m,g=d+1==a.length?1-m:d?1:m;return n?[h,r+i*Yl,g]:[r-i*Yl,h,g]},nu=(e,[t,n,r,i],a)=>{bn(e,t,n,r,a),bn(e,t,r,i,a)},ru=(e,t,n,r,i,a,o)=>{let s=([e,t,n,r],i)=>[[e,i,n],[t,i,n],[t,i,r],[e,i,r]],[c,l]=[s(r,t),s(i,n)];c.forEach((t,n)=>{let r=(n+1)%4;nu(e,[c[r],t,l[n],l[r]],a)}),nu(e,[l[0],l[3],l[2],l[1]],o)},[iu,au,ou]=(()=>{let[e,t,n]=[[],[],[]];ru(e,.25,.85,[-.95,.95,-2.2,2.2],[-.9,.9,-2.05,2.05],[1,1,1],[1,1,1]),ru(t,.85,1.4,[-.82,.82,-.6,1.5],[-.7,.7,-.15,1.05],[.1,.13,.17],[1,1,1]);for(let[e,t]of[[-1,[1,.95,.75]],[1,[1,.08,.05]]])for(let r of[-.6,.6]){let i=n.length,[a,o]=[e*2.2,e*2.1],s=[[r+.3,.5,a],[r-.3,.5,a],[r-.3,.68,a],[r+.3,.68,a]];nu(n,e<0?s:s.reverse(),t);let c=[[r-.3,.86,o],[r-.3,.86,o-e*.25],[r+.3,.86,o-e*.25],[r+.3,.86,o]];nu(n,e<0?c:c.reverse(),t),yn(n,i,2.5)}return[e,t,n]})(),su=e=>{let t=$l(e);return(e,n,r,i)=>{for(let a of t){let[t,o,s]=tu(a,i),c=[t-n[0],-80-n[1],o-n[2]],l=c[0]**2+c[1]**2+c[2]**2;if(s<.05||l>Xl**2||c[0]*r[0]+c[1]*r[1]+c[2]*r[2]<-5.720000000000001)continue;let[u,d]=eu(a),f=[[-d,0,u],[0,1,0],[u,0,d]],p=[t,-79.88,o];on(e,iu,p,f,[0,0,0],Ul*s,Ql[a.paint]),l<Zl**2&&on(e,au,p,f,[0,0,0],Ul*s,Ql[a.paint]),on(e,ou,p,f,[0,0,0],Ul*s)}}},cu=1<<19,lu=2,uu=1024,du=.6,fu=.02,pu=.05,mu=Math.tan(70*Math.PI/360),hu=10,gu=4,_u=`#version 300 es
|
|
2
2
|
layout(location=0)in vec3 p;layout(location=1)in vec3 n;layout(location=2)in vec4 c;
|
|
3
3
|
uniform mat4 m;uniform float Y;uniform vec3 J[3];out vec3 P,N;out vec4 C;
|
|
4
4
|
void main(){
|
|
5
5
|
if(Y>.5){vec2 q=vec2(gl_VertexID&1,gl_VertexID>>1)*4.-1.;gl_Position=vec4(q,1,1);P=J[0]*q.x+J[1]*q.y+J[2];N=vec3(0);C=vec4(0);return;}
|
|
6
|
-
P=p;N=n;C=c;gl_Position=m*vec4(p,1);}`,
|
|
7
|
-
out vec2 U;void main(){U=vec2(gl_VertexID&1,gl_VertexID>>1)*2.;gl_Position=vec4(U*2.-1.,0,1);}`,
|
|
6
|
+
P=p;N=n;C=c;gl_Position=m*vec4(p,1);}`,vu=`#version 300 es
|
|
7
|
+
out vec2 U;void main(){U=vec2(gl_VertexID&1,gl_VertexID>>1)*2.;gl_Position=vec4(U*2.-1.,0,1);}`,yu=`#version 300 es
|
|
8
8
|
precision highp float;uniform sampler2D S[4];uniform vec4 Y;uniform float L;in vec2 U;out vec4 o;
|
|
9
9
|
vec3 b(vec2 x){vec3 c=texture(S[0],x).rgb;return c*smoothstep(.9,2.,max(c.r,max(c.g,c.b)));}
|
|
10
10
|
#define T(k)texture(S[0],U+Y.xy*(k)).rgb
|
|
@@ -20,12 +20,12 @@ float a=atan(q.y,q.x)*24.,h=fract(sin(floor(a)*12.9898)*43758.5453);
|
|
|
20
20
|
c+=L*step(.85-.5*L,h)*sin(fract(a)*3.1416)*smoothstep(.2,.6,length(q))*fract(length(q)*3.-Y.w*.002+h*9.)*.22;
|
|
21
21
|
c*=1.-(.7+.3*L)*dot(q,q);
|
|
22
22
|
c=pow(c*vec3(.97,1.,1.03),vec3(.92))+(fract(sin(dot(gl_FragCoord.xy+Y.w,vec2(12.9898,78.233)))*43758.5453)-.5)*.03;}
|
|
23
|
-
o=vec4(c,1);}`,
|
|
23
|
+
o=vec4(c,1);}`,bu=[[.04,8],[.25,30],[0,1],[.08,10],[.8,48],[.06,12],[.3,20],[.7,40],[.06,14],[1.5,110],[.9,60],[.25,30],[.1,24]],xu=`#version 300 es
|
|
24
24
|
precision highp float;precision highp sampler2DArray;precision highp sampler2DArrayShadow;
|
|
25
25
|
in vec3 P,N;in vec4 C;uniform vec3 E;uniform float T,Z,Y;uniform int Q;
|
|
26
26
|
uniform vec4 A[16],B[16],K[16],F;uniform float U;uniform vec3 G[16],H[5],O,X;uniform mat4 M[4],W;
|
|
27
27
|
uniform sampler2DArray S;uniform sampler2DArrayShadow D;out vec4 o;
|
|
28
|
-
const vec2 SP[${
|
|
28
|
+
const vec2 SP[${bu.length}]=vec2[](${bu.map(([e,t])=>`vec2(${e},${t})`)});
|
|
29
29
|
vec3 e(vec3 x){return 2.*(1.-exp(-.5*x));}
|
|
30
30
|
vec3 K0(vec3 d){
|
|
31
31
|
float h=d.y,k=max(dot(d,O),0.);
|
|
@@ -36,19 +36,19 @@ void main(){
|
|
|
36
36
|
if(Z<0.)return;
|
|
37
37
|
if(Y>.5){o=vec4(K0(normalize(P)),1);return;}
|
|
38
38
|
float L=C.z,s=step(0.,L),I=floor(C.w*.5),g=step(abs(L-${w.LAVA}.),.5)+step(L,-1.5);
|
|
39
|
-
vec4 t=texture(S,vec3(C.xy/${
|
|
39
|
+
vec4 t=texture(S,vec3(C.xy/${lu}.+vec2(g*T*.01,0),max(L,0.)));
|
|
40
40
|
vec3 c=mix(vec3(C.xy,C.w),t.rgb,s);
|
|
41
41
|
vec3 n=normalize(N),dx=dFdx(P),dy=dFdy(P),a=cross(dy,n),b=cross(n,dx);
|
|
42
42
|
float h=t.a*s*0.06,det=dot(dx,a);
|
|
43
|
-
float f=1.-smoothstep(.6,2.5,${128/
|
|
43
|
+
float f=1.-smoothstep(.6,2.5,${128/lu}.*max(length(dFdx(C.xy)),length(dFdy(C.xy))));
|
|
44
44
|
vec3 m=normalize(abs(det)*n-sign(det)*f*(dFdx(h)*a+dFdy(h)*b)+n*1e-9);
|
|
45
|
-
vec2 R=SP[int(s>0.?L+.5:${
|
|
45
|
+
vec2 R=SP[int(s>0.?L+.5:${Tl}.)];
|
|
46
46
|
vec3 y=mix(vec3(1),G[int(min(I,15.))]*(C.w-2.*I),s),V=normalize(E-P),w=normalize(n+m);
|
|
47
47
|
float sd=max(dot(m,O),0.)*smoothstep(0.,.1,dot(n,O)),sv=1.;
|
|
48
48
|
if(sd>0.&&g<1.){
|
|
49
49
|
vec4 q=W*vec4(P+n*.08,1);q.xyz=q.xyz*.5+.5;
|
|
50
50
|
float v=0.;
|
|
51
|
-
for(int j=0;j<4;j++)v+=texture(D,vec4(q.xy+(vec2(j&1,j>>1)*2.-1.)*${.75/
|
|
51
|
+
for(int j=0;j<4;j++)v+=texture(D,vec4(q.xy+(vec2(j&1,j>>1)*2.-1.)*${.75/uu},0,q.z-.0004));
|
|
52
52
|
sv=mix(v/4.,1.,smoothstep(.8,1.,max(abs(q.x-.5),abs(q.y-.5))*2.));}
|
|
53
53
|
vec3 l=y*(mix(mix(H[1],H[0],max(w.y,0.)),H[2],max(-w.y,0.))+X*sd*sv),sp=X*sv*sd*pow(max(dot(m,normalize(O+V)),0.),R.y);
|
|
54
54
|
for(int i=0;i<16;i++){
|
|
@@ -60,11 +60,11 @@ w*=w*smoothstep(u,u+(1.-u)*.4,-dot(d,B[i].xyz))*max(dot(m,d),0.);
|
|
|
60
60
|
if(w>0.&&k>=0.){
|
|
61
61
|
vec4 q=M[int(k)]*vec4(P+n*.03,1);q.xyz=q.xyz/q.w*.5+.5;
|
|
62
62
|
float v=0.;
|
|
63
|
-
for(int j=0;j<4;j++)v+=texture(D,vec4(q.xy+(vec2(j&1,j>>1)*2.-1.)*${.75/
|
|
63
|
+
for(int j=0;j<4;j++)v+=texture(D,vec4(q.xy+(vec2(j&1,j>>1)*2.-1.)*${.75/uu},k+1.,q.z-.0005));
|
|
64
64
|
w*=v/4.;}
|
|
65
65
|
l+=K[i].rgb*w;
|
|
66
66
|
sp+=K[i].rgb*w*pow(max(dot(m,normalize(d+V)),0.),R.y);}
|
|
67
67
|
c=c*mix(e(l),vec3(1.4),g)+e(sp*R.x*(.4+.6*mix(1.,t.a,s)));
|
|
68
68
|
c+=step(abs(L-${w.GLASS}.),.5)*K0(reflect(-V,m))*(.1+.9*pow(1.-max(dot(m,V),0.),4.));
|
|
69
|
-
float D=length(P-E),x=${
|
|
70
|
-
o=vec4(mix(c,F.rgb,1.-exp(-F.a*D*(1.+${cu}*exp(${lu}*(U-E.y))*(abs(x)<1e-3?1.-x*.5:(1.-exp(-x))/x)))),1.);}`,vu=(e,t,n,r,i=0,a=uu,[o,s]=[.1,900])=>{let[c,l,u]=Qt(t,n,i),d=(s+o)/(s-o),f=[c.map(e=>e/(a*r)),l.map(e=>e/a),u.map(e=>e*d),u].map(t=>[...t,-t[0]*e[0]-t[1]*e[1]-t[2]*e[2]]);return f[2][3]-=2*s*o/(s-o),Float32Array.from({length:16},(e,t)=>f[t&3][t>>2])},yu=(e,t,n,r)=>{let i=e[3]*t+e[7]*n+e[11]*r+e[15];if(i<=0)return;let a=e[0]*t+e[4]*n+e[8]*r+e[12],o=e[1]*t+e[5]*n+e[9]*r+e[13];return[.5+a/(2*i),.5-o/(2*i)]},bu=({p:e,d:t,cone:n,range:r})=>vu(e,Math.atan2(-t[0],-t[2]),Math.atan2(t[1],Math.hypot(t[0],t[2])),1,0,Math.min(Math.tan(Math.acos(n)),5.7),[.3,r]),xu=e=>{let[t,n,r]=[0,0,0].map(()=>/* @__PURE__ */ new Float32Array(64)),i=/* @__PURE__ */ new Float32Array(64),a=0,o=e.slice(0,16);return o.forEach((e,o)=>{let s=e.shadow&&e.kind==Dn.SPOT&&a<4?a++:-1;t.set([...e.p,e.range],o*4),n.set([...e.d,e.kind==Dn.POINT?-9:e.cone],o*4),r.set([...e.color,s],o*4),s>=0&&i.set(bu(e),s*16)}),{n:o.length,maps:a,a:t,b:n,k:r,m:i}},Su=(e,t,n=64,r=100)=>{let i=e.map(e=>-e),a=Math.hypot(i[0],i[2]),o=a>.001?[-i[2]/a,0,i[0]/a]:[1,0,0],s=[o[1]*i[2]-o[2]*i[1],o[2]*i[0]-o[0]*i[2],o[0]*i[1]-o[1]*i[0]],c=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],[l,u]=[n/2,n/ou],d=[o,s].map(e=>[...e.map(e=>e/l),-(Math.round(c(e,t)/u)*u)/l]);return d.push([...i.map(e=>e/r),-c(i,t)/r],[0,0,0,1]),Float32Array.from({length:16},(e,t)=>d[t&3][t>>2])},Cu=({def:e})=>[...new Map([[`1,1,1`,[1,1,1]],...e.brushes.flatMap(({tint:e})=>e?[[`${e}`,e]]:[])]).values()].slice(0,16),wu=[[0,0],[1,0],[1,1],[0,0],[1,1],[0,1]],Tu=e=>{let{brushes:t,floor:n}=e.def,r=[],i=Cu(e).map(String);return t.forEach((e,a)=>{let o=1+2*Math.max(0,i.indexOf(`${e.tint}`));for(let i=0;i<3;i++){let[s,c]=[(i+1)%3,(i+2)%3],[l,u]=i==0?[2,1]:i==1?[0,2]:[0,1];for(let d of[0,1]){let f=d?e.max[i]:e.min[i];if(t.some((t,n)=>n!=a&&(d?t.min[i]:t.max[i])==f&&t.min[s]<=e.min[s]&&t.max[s]>=e.max[s]&&t.min[c]<=e.min[c]&&t.max[c]>=e.max[c])||i==1&&!d&&e.min[1]<=n)continue;let p=[0,0,0];p[i]=d?1:-1;for(let[t,n]of wu){let a=[0,0,0];[a[i],a[s],a[c]]=[f,(t?e.max:e.min)[s],(n?e.max:e.min)[c]],r.push(...a,...p,a[l],a[u],i==1&&d?e.top:e.side,o)}}}}),r},Eu=({sky:[e,t]})=>[e.map(e=>(e*.45+.55)*.74),t.map(e=>(e*.7+.3)*.58),t.map((e,t)=>e*[1,.92,.8][t]*.34),e,t],Du=e=>({...e,def:{...e.def,brushes:[...yl(e.def),...Rl(e.def)]}}),Ou=e=>[...Tu(Du(e)),...bl(e.def),...ol(e.def),...cl(e.def)],ku=({brushes:e})=>Math.min(...e.map(e=>e.max[1])),Au=({fog:e,sky:t})=>e?[...[0,1,2].map(n=>e[n]+(t[1][n]-e[n])*su),e[3]]:[...t[1],0],ju=2073600,Mu=(e,t,n)=>{let r=Math.min(n,2,Math.sqrt(ju/(e*t||1)));return[Math.round(e*r),Math.round(t*r)]},Nu=(e,t)=>{let n=/* @__PURE__ */ new Map,r=performance.now()/1e3,i=e.getContext(`webgl2`,{antialias:!1,depth:!1});if(!i)throw Error(`WebGL2 is not available`);let a=document.createElement(`canvas`).getContext(`2d`),o=/* @__PURE__ */ new Map,s=e=>{let t=o.get(e);if(!t){a.fillStyle=`#888`,a.fillStyle=e;let n=parseInt(a.fillStyle.slice(1),16),r=n>=0?n:8947848;o.set(e,t=[r>>16,r>>8&255,r&255].map(e=>e/255))}return t},c=()=>Mu(e.clientWidth,e.clientHeight,devicePixelRatio),l=Ou(t),u=ru(t.def),{sun:d,sky:f}=t.def,p=d.dir.map(e=>e/Math.hypot(...d.dir)),m=Al(),h=l.length*4,g=h+iu,_={},v,y,b,x,S={},C,w,T,E,D=[0,0],O=[],k=!1,A=/* @__PURE__ */ new Float32Array(16),j=()=>{i.bufferData(i.ARRAY_BUFFER,g,i.DYNAMIC_DRAW),i.bufferSubData(i.ARRAY_BUFFER,0,new Float32Array(l))},ee=(e,t,n)=>{let r=i.createProgram();for(let[n,a]of[[i.VERTEX_SHADER,e],[i.FRAGMENT_SHADER,t]]){let e=i.createShader(n);i.shaderSource(e,a),i.compileShader(e),i.attachShader(r,e)}return i.linkProgram(r),i.useProgram(r),[r,Object.fromEntries(n.map(e=>[e,i.getUniformLocation(r,e)]))]},M=(e,t)=>{let n=i.createTexture();i.bindTexture(i.TEXTURE_2D,n),i.texStorage2D(i.TEXTURE_2D,1,C,e,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE);let r=i.createFramebuffer();return i.bindFramebuffer(i.FRAMEBUFFER,r),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,n,0),O.push(()=>i.deleteTexture(n),()=>i.deleteFramebuffer(r)),{t:n,f:r,w:e,h:t}},te=(e,t)=>{O.splice(0).forEach(e=>e()),D=[e,t],T=M(e,t),E=[1,2,3].map(n=>[0,1].map(()=>M(e>>n||1,t>>n||1)));let n=n=>{let r=i.createRenderbuffer();return i.bindRenderbuffer(i.RENDERBUFFER,r),i.renderbufferStorageMultisample(i.RENDERBUFFER,fu,n,e,t),O.push(()=>i.deleteRenderbuffer(r)),r};i.bindFramebuffer(i.FRAMEBUFFER,w=i.createFramebuffer()),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,n(C)),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,n(i.DEPTH_COMPONENT24)),O.push(()=>i.deleteFramebuffer(w))},N=(e,t,n,r,...a)=>{i.bindFramebuffer(i.FRAMEBUFFER,e?.f??null),i.viewport(0,0,e?.w??D[0],e?.h??D[1]),a.forEach((e,t)=>{i.activeTexture(i.TEXTURE0+t),i.bindTexture(i.TEXTURE_2D,e.t)}),i.uniform4f(S.Y,n,r,t,performance.now()%1e4),i.drawArrays(i.TRIANGLES,0,3)},P=()=>{C=i.getExtension(`EXT_color_buffer_float`)?i.RGBA16F:i.RGBA8,O.length=0,D=[0,0],[x,S]=ee(mu,hu,[`S`,`Y`,`L`]),i.uniform1iv(S.S,[0,1,2,3]),[b,_]=ee(pu,_u,[`m`,`E`,`T`,`Z`,`Q`,`A`,`B`,`K`,`M`,`D`,`F`,`U`,`G`,`W`,`H`,`O`,`X`,`Y`,`J`]),i.uniform1i(_.D,1),i.bindBuffer(i.ARRAY_BUFFER,i.createBuffer()),j(),[3,3,4].reduce((e,t,n)=>(i.enableVertexAttribArray(n),i.vertexAttribPointer(n,t,i.FLOAT,!1,40,e*4),e+t),0),i.activeTexture(i.TEXTURE1),i.bindTexture(i.TEXTURE_2D_ARRAY,v=i.createTexture()),i.texStorage3D(i.TEXTURE_2D_ARRAY,1,i.DEPTH_COMPONENT24,ou,ou,5);for(let[e,t]of[[i.TEXTURE_MIN_FILTER,i.LINEAR],[i.TEXTURE_MAG_FILTER,i.LINEAR],[i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE],[i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE],[i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE]])i.texParameteri(i.TEXTURE_2D_ARRAY,e,t);i.bindFramebuffer(i.FRAMEBUFFER,y=i.createFramebuffer()),i.drawBuffers([i.NONE]),i.bindFramebuffer(i.FRAMEBUFFER,null),i.polygonOffset(2,4),i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D_ARRAY,i.createTexture()),i.texImage3D(i.TEXTURE_2D_ARRAY,0,i.RGBA8,128,128,xl,0,i.RGBA,i.UNSIGNED_BYTE,m),i.generateMipmap(i.TEXTURE_2D_ARRAY),i.texParameteri(i.TEXTURE_2D_ARRAY,i.TEXTURE_MIN_FILTER,i.LINEAR_MIPMAP_LINEAR);let e=i.getExtension(`EXT_texture_filter_anisotropic`);e&&i.texParameterf(i.TEXTURE_2D_ARRAY,e.TEXTURE_MAX_ANISOTROPY_EXT,8),i.enable(i.DEPTH_TEST),i.depthFunc(i.LEQUAL),F();let[t,n]=c();t&&n&&te(t,n)},F=()=>{let e=Cu(Du(t));i.uniform4fv(_.F,Au(t.def)),i.uniform1f(_.U,ku(t.def)),i.uniform3fv(_.H,Eu(t.def).flat()),i.uniform3fv(_.O,p),i.uniform3fv(_.X,d.color),i.uniform3fv(_.G,Float32Array.from({length:48},(t,n)=>e[n/3|0]?.[n%3]??1)),i.clearColor(...f[1],1)};P();let I=e=>{e.preventDefault(),k=!0},L=()=>{P(),k=!1};return e.addEventListener(`webglcontextlost`,I),e.addEventListener(`webglcontextrestored`,L),{frame(a,o,d,f,m,C,O,ee,M,P){let[F,I]=c();if(k||!F||!I)return;(e.width!=F||e.height!=I)&&(e.width=F,e.height=I),(D[0]!=F||D[1]!=I)&&te(F,I);let L=Math.tan((70+C.fov)*Math.PI/360);A=vu(a,o,d,F/I,C.roll,L);let R=[],ne=performance.now()/1e3,re=Math.min(.1,ne-r);r=ne,Ic(n,f,re,t,P);let[ie,ae,oe]=Qt(o,d,C.roll);u(R,a,oe,Date.now()/1e3),M?.bases.forEach((e,t)=>Cn(R,e,gn(t),ne)),M?.flags.forEach(e=>En(R,e,gn(e.team),ne)),hc(R,M?.racks,M?.blades,ne),M?.packs?.forEach(e=>xc(R,e,ne)),M?.ammo?.forEach(e=>Sc(R,e,ne));for(let e of f)Hc(R,n.get(e.id),s(m.get(e.id)??`#888`),+(Math.hypot(e.x-a[0],e.z-a[2])<du));let se=R.length;P?.draw(R,a);for(let e of f)n.get(e.id)?.trail.draw(R);let ce=R.length;ee?.draw(R,a,o,d,C.roll,s(m.get(ee.id)??`#888`)),h+R.length*4>g&&(g=h+R.length*8,j()),i.bufferSubData(i.ARRAY_BUFFER,h,new Float32Array(R));let z=xu(O),le=l.length/10,ue=Su(p,a);i.uniform1f(_.Z,-1),i.activeTexture(i.TEXTURE1),i.bindTexture(i.TEXTURE_2D_ARRAY,null),i.bindFramebuffer(i.FRAMEBUFFER,y),i.viewport(0,0,ou,ou),i.enable(i.POLYGON_OFFSET_FILL);for(let e=0;e<=z.maps;e++)i.framebufferTextureLayer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,v,0,e),i.uniformMatrix4fv(_.m,!1,e?z.m.subarray(e*16-16,e*16):ue),i.clear(i.DEPTH_BUFFER_BIT),i.drawArrays(i.TRIANGLES,0,le+se/10);i.disable(i.POLYGON_OFFSET_FILL),i.bindTexture(i.TEXTURE_2D_ARRAY,v),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,w),i.viewport(0,0,F,I),i.uniformMatrix4fv(_.m,!1,A),i.uniformMatrix4fv(_.W,!1,ue),i.uniform3fv(_.E,a),i.uniform1f(_.T,performance.now()/1e3),i.uniform1f(_.Z,1),i.uniform1i(_.Q,z.n),i.uniform4fv(_.A,z.a),i.uniform4fv(_.B,z.b),i.uniform4fv(_.K,z.k),i.uniformMatrix4fv(_.M,!1,z.m),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT),i.uniform3fv(_.J,[ie.map(e=>e*L*(F/I)),ae.map(e=>e*L),oe].flat()),i.uniform1f(_.Y,1),i.drawArrays(i.TRIANGLES,0,3),i.uniform1f(_.Y,0),i.drawArrays(i.TRIANGLES,0,le+ce/10),R.length>ce&&(i.clear(i.DEPTH_BUFFER_BIT),i.drawArrays(i.TRIANGLES,le+ce/10,(R.length-ce)/10)),i.bindFramebuffer(i.READ_FRAMEBUFFER,w),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,T.f),i.blitFramebuffer(0,0,F,I,0,0,F,I,i.COLOR_BUFFER_BIT,i.NEAREST),i.useProgram(x),N(E[0][0],0,1/F,1/I,T),E.forEach(([e,t],n)=>{N(t,1,1/t.w,0,E[n&&n-1][0]),N(e,1,0,1/e.h,t)}),i.uniform1f(S.L,C.lines),N(void 0,2,0,0,T,...E.map(e=>e[0]));for(let e=3;e>0;e--)i.activeTexture(i.TEXTURE0+e),i.bindTexture(i.TEXTURE_2D,null);i.activeTexture(i.TEXTURE0),i.useProgram(b)},project:(e,t,n)=>yu(A,e,t,n),destroy(){e.removeEventListener(`webglcontextlost`,I),e.removeEventListener(`webglcontextrestored`,L),i.getExtension(`WEBGL_lose_context`)?.loseContext()}}},Pu=1/60,Fu=5,Iu=(e,n)=>{let r=document.createElement(`div`),i=r.attachShadow({mode:`open`});i.innerHTML=`<style>:host{display:block;width:100%;height:100%}div{position:relative;width:100%;height:100%;overflow:hidden;background:#000;font:600 14px system-ui,sans-serif;color:#fff;text-shadow:0 1px 2px #000}canvas{display:block;width:100%;height:100%;cursor:pointer}i,p,b{position:absolute;pointer-events:none;user-select:none;margin:0}`+Fs+`i{left:50%;top:50%;width:6px;height:6px;margin:-3px;border-radius:50%;background:#fff;box-shadow:0 0 0 1px #0008}p{bottom:8px;left:12px}b{transform:translate(-50%,-100%);font-size:12px;white-space:nowrap}[hidden]{display:none}</style><div><canvas></canvas><i></i><p></p></div>`,e.append(r);let a=i.querySelector(`canvas`),o=i.querySelector(`p`),s=i.querySelector(`div`),c=Rs(s),l={roster:[],open:[],close:[]},u=e=>l[e].forEach(e=>e()),d=ce(re),f=sc(d),p=Bt();p.mute(Vt()),c.mute(p.muted);let m=Js(a,()=>c.mute(Ht(p)));a.addEventListener(`click`,()=>p.unlock());let h=Ms(),g=Ps(p),_=qo(d),v=qn(),y=Jt(d),b=$o(d,p,c,h,v,m,y),x;try{x=Nu(a,d)}catch{}let S=d.def.teams.map(e=>e.base),C=d.def.teams.map(e=>e.rack),w=d.def.teams.map(e=>e.blade),T=[],E={id:-1,team:0},D,O,k=/* @__PURE__ */ new Map,A=/* @__PURE__ */ new Map,j=/* @__PURE__ */ new Map,ee=!1,M=x?``:`WebGL2 is not available`,te=!1,N=performance.now(),P=0,F=0,I=!1,L=n.socket??new WebSocket(n.url);L.binaryType=`arraybuffer`,L.onopen=()=>{ee=!0,L.send(JSON.stringify({t:`join`,name:n.name})),u(`open`)},L.onclose=()=>{ee=!1,M||=`Connection closed`,u(`close`)},L.onmessage=({data:e})=>{if(typeof e!=`string`){let t=_t(e);if(t){f.snapshot(t,performance.now()),y.snapshot(t.balls??[],E.id,performance.now());for(let e of Jn(D,t)){let t=Yn(e,E,e=>A.get(e)??`Someone`);t&&c.banner(t.text,t.team),e.kind==`start`&&([m.yaw,m.pitch]=[d.def.teams[E.team].spawns[0][3],0]);for(let t of Xn(e,E))p.play(t.id,t.at,t.gain,t.rate);e.kind==`tackle`?e.who==E.id?h.jolt():e.by==E.id&&h.punch():e.kind==`shock`&&(v.shock(e.at),e.who==E.id&&h.jolt())}D=t}return}let t=vt(e);t?.t==`roster`?(T=t.players,k=new Map(T.map(e=>[e.id,e.color])),A=new Map(T.map(e=>[e.id,e.name])),E={id:t.you,team:T.find(e=>e.id==t.you)?.team??0},f.you(E.id,E.team),o.textContent=`Players: ${T.length}`,u(`roster`)):t?.t==`end`?O={score:t.score,players:t.players}:t?.t==`full`&&(M=`Room is full`)};let R=e=>{let t=j.get(e);return t||(j.set(e,t=document.createElement(`b`)),s.append(t)),t},ne=()=>{F=requestAnimationFrame(ne);let e=performance.now(),n=N;if(P=Math.min(P+(e-N)/1e3,Fu*Pu),N=e,!te){let e=f.me(0);e&&([m.yaw,m.pitch,te]=[e.yaw,e.pitch,!0]),P=0}for(;te&&P>=Pu;P-=Pu){let t=f.me(1),n=f.step({keys:m.take(),yaw:m.yaw,pitch:m.pitch},e);b.step(t,f.me(1)),m.track(t,f.me(1)),ee&&L.send(ht(n))}let r=f.me(P/Pu),i=f.others(e),o=r?[r.x,r.y+Ee(r),r.z]:[0,0,0];p.listen(o,m.yaw);let s=Math.min((e-n)/1e3,.1),l=e=>e==E.id?r:i.find(t=>t.id==e),u=D&&{bases:S,flags:_n(D.flags,S,l),racks:C,blades:w,packs:pc(d.def.packs,D.packs),ammo:pc(d.def.ammo,D.packs,d.def.packs?.length)},y=f.events();h.update(r,m.keys,s,y),c.hurt(h.hurt),g.me(r,y,h.stride),g.others(i),_.update(r,s,h.kick,a.clientWidth/(a.clientHeight||1));let T=[o[0],o[1]+h.dy,o[2]],I=m.pitch+h.pitch,re=m.yaw+_.spun(),ie=r&&Jo(d,o,T,m.yaw,m.pitch,I);ie&&_.aim(ie.local),b.frame(r&&ie&&{eye:o,cam:T,yaw:m.yaw,pitch:m.pitch,drawn:I,muzzle:_.muzzle(),...ie},r,i,m.keys,s,e),r&&x&&x.frame(T,re,I,i,k,h,[...An({eye:T,yaw:re,pitch:I,others:i,t:e/1e3,ctf:u}),...v.lights()],_,u,v),D&&(c.match(D,e=>A.get(e)??`?`),c.marks(r&&x?fc({eye:o,id:E.id,team:E.team,yaw:re,flags:D.flags,bases:S,where:e=>{let t=l(e);return t&&[t.x,t.y,t.z]},project:x.project}):[]),c.end(D.over?O:void 0,D.clock));let ae=/* @__PURE__ */ new Set;for(let e of i){let n=[e.x,e.y+t+.3,e.z],i=r&&!ue(d,o,n)?x?.project(...n):void 0,a=R(e.id);ae.add(e.id),a.hidden=!i,i&&(a.style.left=i[0]*100+`%`,a.style.top=i[1]*100+`%`);let s=A.get(e.id)??``;a.textContent!=s&&(a.textContent=s),a.style.color=k.get(e.id)??``}for(let[e,t]of j)ae.has(e)||(t.remove(),j.delete(e));c.title(M||(ee?te?m.locked()?``:`Click to play`:`Joining…`:`Connecting…`),d.def.name??``)};return F=requestAnimationFrame(ne),{on:(e,t)=>void l[e].push(t),players:()=>T,destroy(){I||(I=!0,cancelAnimationFrame(F),m.destroy(),p.destroy(),x?.destroy(),L.onopen=L.onclose=L.onmessage=null,L.close(),document.exitPointerLock(),r.remove())}}};export{Iu as tinyFps};
|
|
69
|
+
float D=length(P-E),x=${pu}*(P.y-E.y);
|
|
70
|
+
o=vec4(mix(c,F.rgb,1.-exp(-F.a*D*(1.+${fu}*exp(${pu}*(U-E.y))*(abs(x)<1e-3?1.-x*.5:(1.-exp(-x))/x)))),1.);}`,Su=(e,t,n,r,i=0,a=mu,[o,s]=[.1,900])=>{let[c,l,u]=Qt(t,n,i),d=(s+o)/(s-o),f=[c.map(e=>e/(a*r)),l.map(e=>e/a),u.map(e=>e*d),u].map(t=>[...t,-t[0]*e[0]-t[1]*e[1]-t[2]*e[2]]);return f[2][3]-=2*s*o/(s-o),Float32Array.from({length:16},(e,t)=>f[t&3][t>>2])},Cu=(e,t,n,r)=>{let i=e[3]*t+e[7]*n+e[11]*r+e[15];if(i<=0)return;let a=e[0]*t+e[4]*n+e[8]*r+e[12],o=e[1]*t+e[5]*n+e[9]*r+e[13];return[.5+a/(2*i),.5-o/(2*i)]},wu=({p:e,d:t,cone:n,range:r})=>Su(e,Math.atan2(-t[0],-t[2]),Math.atan2(t[1],Math.hypot(t[0],t[2])),1,0,Math.min(Math.tan(Math.acos(n)),5.7),[.3,r]),Tu=e=>{let[t,n,r]=[0,0,0].map(()=>/* @__PURE__ */ new Float32Array(64)),i=/* @__PURE__ */ new Float32Array(64),a=0,o=e.slice(0,16);return o.forEach((e,o)=>{let s=e.shadow&&e.kind==Dn.SPOT&&a<4?a++:-1;t.set([...e.p,e.range],o*4),n.set([...e.d,e.kind==Dn.POINT?-9:e.cone],o*4),r.set([...e.color,s],o*4),s>=0&&i.set(wu(e),s*16)}),{n:o.length,maps:a,a:t,b:n,k:r,m:i}},Eu=(e,t,n=64,r=100)=>{let i=e.map(e=>-e),a=Math.hypot(i[0],i[2]),o=a>.001?[-i[2]/a,0,i[0]/a]:[1,0,0],s=[o[1]*i[2]-o[2]*i[1],o[2]*i[0]-o[0]*i[2],o[0]*i[1]-o[1]*i[0]],c=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],[l,u]=[n/2,n/uu],d=[o,s].map(e=>[...e.map(e=>e/l),-(Math.round(c(e,t)/u)*u)/l]);return d.push([...i.map(e=>e/r),-c(i,t)/r],[0,0,0,1]),Float32Array.from({length:16},(e,t)=>d[t&3][t>>2])},Du=({def:e})=>[...new Map([[`1,1,1`,[1,1,1]],...e.brushes.flatMap(({tint:e})=>e?[[`${e}`,e]]:[])]).values()].slice(0,16),Ou=[[0,0],[1,0],[1,1],[0,0],[1,1],[0,1]],ku=e=>{let{brushes:t,floor:n}=e.def,r=[],i=Du(e).map(String);return t.forEach((e,a)=>{let o=1+2*Math.max(0,i.indexOf(`${e.tint}`));for(let i=0;i<3;i++){let[s,c]=[(i+1)%3,(i+2)%3],[l,u]=i==0?[2,1]:i==1?[0,2]:[0,1];for(let d of[0,1]){let f=d?e.max[i]:e.min[i];if(t.some((t,n)=>n!=a&&(d?t.min[i]:t.max[i])==f&&t.min[s]<=e.min[s]&&t.max[s]>=e.max[s]&&t.min[c]<=e.min[c]&&t.max[c]>=e.max[c])||i==1&&!d&&e.min[1]<=n)continue;let p=[0,0,0];p[i]=d?1:-1;for(let[t,n]of Ou){let a=[0,0,0];[a[i],a[s],a[c]]=[f,(t?e.max:e.min)[s],(n?e.max:e.min)[c]],r.push(...a,...p,a[l],a[u],i==1&&d?e.top:e.side,o)}}}}),r},Au=({sky:[e,t]})=>[e.map(e=>(e*.45+.55)*.74),t.map(e=>(e*.7+.3)*.58),t.map((e,t)=>e*[1,.92,.8][t]*.34),e,t],ju=e=>({...e,def:{...e.def,brushes:[...Cl(e.def),...Hl(e.def)]}}),Mu=e=>[...ku(ju(e)),...wl(e.def),...ul(e.def),...fl(e.def)],Nu=({brushes:e})=>Math.min(...e.map(e=>e.max[1])),Pu=({fog:e,sky:t})=>e?[...[0,1,2].map(n=>e[n]+(t[1][n]-e[n])*du),e[3]]:[...t[1],0],Fu=2073600,Iu=(e,t,n)=>{let r=Math.min(n,2,Math.sqrt(Fu/(e*t||1)));return[Math.round(e*r),Math.round(t*r)]},Lu=(e,t)=>{let n=/* @__PURE__ */ new Map,r=performance.now()/1e3,i=e.getContext(`webgl2`,{antialias:!1,depth:!1});if(!i)throw Error(`WebGL2 is not available`);let a=document.createElement(`canvas`).getContext(`2d`),o=/* @__PURE__ */ new Map,s=e=>{let t=o.get(e);if(!t){a.fillStyle=`#888`,a.fillStyle=e;let n=parseInt(a.fillStyle.slice(1),16),r=n>=0?n:8947848;o.set(e,t=[r>>16,r>>8&255,r&255].map(e=>e/255))}return t},c=()=>Iu(e.clientWidth,e.clientHeight,devicePixelRatio),l=Mu(t),u=su(t.def),{sun:d,sky:f}=t.def,p=d.dir.map(e=>e/Math.hypot(...d.dir)),m=Pl(),h=l.length*4,g=h+cu,_={},v,y,b,x,S={},C,w,T,E,D=[0,0],O=[],k=!1,A=/* @__PURE__ */ new Float32Array(16),j=()=>{i.bufferData(i.ARRAY_BUFFER,g,i.DYNAMIC_DRAW),i.bufferSubData(i.ARRAY_BUFFER,0,new Float32Array(l))},ee=(e,t,n)=>{let r=i.createProgram();for(let[n,a]of[[i.VERTEX_SHADER,e],[i.FRAGMENT_SHADER,t]]){let e=i.createShader(n);i.shaderSource(e,a),i.compileShader(e),i.attachShader(r,e)}return i.linkProgram(r),i.useProgram(r),[r,Object.fromEntries(n.map(e=>[e,i.getUniformLocation(r,e)]))]},M=(e,t)=>{let n=i.createTexture();i.bindTexture(i.TEXTURE_2D,n),i.texStorage2D(i.TEXTURE_2D,1,C,e,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE);let r=i.createFramebuffer();return i.bindFramebuffer(i.FRAMEBUFFER,r),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,n,0),O.push(()=>i.deleteTexture(n),()=>i.deleteFramebuffer(r)),{t:n,f:r,w:e,h:t}},te=(e,t)=>{O.splice(0).forEach(e=>e()),D=[e,t],T=M(e,t),E=[1,2,3].map(n=>[0,1].map(()=>M(e>>n||1,t>>n||1)));let n=n=>{let r=i.createRenderbuffer();return i.bindRenderbuffer(i.RENDERBUFFER,r),i.renderbufferStorageMultisample(i.RENDERBUFFER,gu,n,e,t),O.push(()=>i.deleteRenderbuffer(r)),r};i.bindFramebuffer(i.FRAMEBUFFER,w=i.createFramebuffer()),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,n(C)),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,n(i.DEPTH_COMPONENT24)),O.push(()=>i.deleteFramebuffer(w))},N=(e,t,n,r,...a)=>{i.bindFramebuffer(i.FRAMEBUFFER,e?.f??null),i.viewport(0,0,e?.w??D[0],e?.h??D[1]),a.forEach((e,t)=>{i.activeTexture(i.TEXTURE0+t),i.bindTexture(i.TEXTURE_2D,e.t)}),i.uniform4f(S.Y,n,r,t,performance.now()%1e4),i.drawArrays(i.TRIANGLES,0,3)},P=()=>{C=i.getExtension(`EXT_color_buffer_float`)?i.RGBA16F:i.RGBA8,O.length=0,D=[0,0],[x,S]=ee(vu,yu,[`S`,`Y`,`L`]),i.uniform1iv(S.S,[0,1,2,3]),[b,_]=ee(_u,xu,[`m`,`E`,`T`,`Z`,`Q`,`A`,`B`,`K`,`M`,`D`,`F`,`U`,`G`,`W`,`H`,`O`,`X`,`Y`,`J`]),i.uniform1i(_.D,1),i.bindBuffer(i.ARRAY_BUFFER,i.createBuffer()),j(),[3,3,4].reduce((e,t,n)=>(i.enableVertexAttribArray(n),i.vertexAttribPointer(n,t,i.FLOAT,!1,40,e*4),e+t),0),i.activeTexture(i.TEXTURE1),i.bindTexture(i.TEXTURE_2D_ARRAY,v=i.createTexture()),i.texStorage3D(i.TEXTURE_2D_ARRAY,1,i.DEPTH_COMPONENT24,uu,uu,5);for(let[e,t]of[[i.TEXTURE_MIN_FILTER,i.LINEAR],[i.TEXTURE_MAG_FILTER,i.LINEAR],[i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE],[i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE],[i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE]])i.texParameteri(i.TEXTURE_2D_ARRAY,e,t);i.bindFramebuffer(i.FRAMEBUFFER,y=i.createFramebuffer()),i.drawBuffers([i.NONE]),i.bindFramebuffer(i.FRAMEBUFFER,null),i.polygonOffset(2,4),i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D_ARRAY,i.createTexture()),i.texImage3D(i.TEXTURE_2D_ARRAY,0,i.RGBA8,128,128,Tl,0,i.RGBA,i.UNSIGNED_BYTE,m),i.generateMipmap(i.TEXTURE_2D_ARRAY),i.texParameteri(i.TEXTURE_2D_ARRAY,i.TEXTURE_MIN_FILTER,i.LINEAR_MIPMAP_LINEAR);let e=i.getExtension(`EXT_texture_filter_anisotropic`);e&&i.texParameterf(i.TEXTURE_2D_ARRAY,e.TEXTURE_MAX_ANISOTROPY_EXT,8),i.enable(i.DEPTH_TEST),i.depthFunc(i.LEQUAL),F();let[t,n]=c();t&&n&&te(t,n)},F=()=>{let e=Du(ju(t));i.uniform4fv(_.F,Pu(t.def)),i.uniform1f(_.U,Nu(t.def)),i.uniform3fv(_.H,Au(t.def).flat()),i.uniform3fv(_.O,p),i.uniform3fv(_.X,d.color),i.uniform3fv(_.G,Float32Array.from({length:48},(t,n)=>e[n/3|0]?.[n%3]??1)),i.clearColor(...f[1],1)};P();let I=e=>{e.preventDefault(),k=!0},L=()=>{P(),k=!1};return e.addEventListener(`webglcontextlost`,I),e.addEventListener(`webglcontextrestored`,L),{frame(a,o,d,f,m,C,O,ee,M,P){let[F,I]=c();if(k||!F||!I)return;(e.width!=F||e.height!=I)&&(e.width=F,e.height=I),(D[0]!=F||D[1]!=I)&&te(F,I);let L=Math.tan((70+C.fov)*Math.PI/360);A=Su(a,o,d,F/I,C.roll,L);let R=[],z=performance.now()/1e3,ne=Math.min(.1,z-r);r=z,Bc(n,f,ne,t,P);let[re,ie,ae]=Qt(o,d,C.roll);u(R,a,ae,Date.now()/1e3),M?.bases.forEach((e,t)=>Cn(R,e,gn(t),z)),M?.flags.forEach(e=>En(R,e,gn(e.team),z)),yc(R,M?.racks,M?.blades,z),M?.packs?.forEach(e=>Tc(R,e,z)),M?.ammo?.forEach(e=>Ec(R,e,z));for(let e of f)Kc(R,n.get(e.id),s(m.get(e.id)??`#888`),+(Math.hypot(e.x-a[0],e.z-a[2])<hu));let oe=R.length;P?.draw(R,a);for(let e of f)n.get(e.id)?.trail.draw(R);let se=R.length;ee?.draw(R,a,o,d,C.roll,s(m.get(ee.id)??`#888`)),h+R.length*4>g&&(g=h+R.length*8,j()),i.bufferSubData(i.ARRAY_BUFFER,h,new Float32Array(R));let ce=Tu(O),le=l.length/10,ue=Eu(p,a);i.uniform1f(_.Z,-1),i.activeTexture(i.TEXTURE1),i.bindTexture(i.TEXTURE_2D_ARRAY,null),i.bindFramebuffer(i.FRAMEBUFFER,y),i.viewport(0,0,uu,uu),i.enable(i.POLYGON_OFFSET_FILL);for(let e=0;e<=ce.maps;e++)i.framebufferTextureLayer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,v,0,e),i.uniformMatrix4fv(_.m,!1,e?ce.m.subarray(e*16-16,e*16):ue),i.clear(i.DEPTH_BUFFER_BIT),i.drawArrays(i.TRIANGLES,0,le+oe/10);i.disable(i.POLYGON_OFFSET_FILL),i.bindTexture(i.TEXTURE_2D_ARRAY,v),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,w),i.viewport(0,0,F,I),i.uniformMatrix4fv(_.m,!1,A),i.uniformMatrix4fv(_.W,!1,ue),i.uniform3fv(_.E,a),i.uniform1f(_.T,performance.now()/1e3),i.uniform1f(_.Z,1),i.uniform1i(_.Q,ce.n),i.uniform4fv(_.A,ce.a),i.uniform4fv(_.B,ce.b),i.uniform4fv(_.K,ce.k),i.uniformMatrix4fv(_.M,!1,ce.m),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT),i.uniform3fv(_.J,[re.map(e=>e*L*(F/I)),ie.map(e=>e*L),ae].flat()),i.uniform1f(_.Y,1),i.drawArrays(i.TRIANGLES,0,3),i.uniform1f(_.Y,0),i.drawArrays(i.TRIANGLES,0,le+se/10),R.length>se&&(i.clear(i.DEPTH_BUFFER_BIT),i.drawArrays(i.TRIANGLES,le+se/10,(R.length-se)/10)),i.bindFramebuffer(i.READ_FRAMEBUFFER,w),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,T.f),i.blitFramebuffer(0,0,F,I,0,0,F,I,i.COLOR_BUFFER_BIT,i.NEAREST),i.useProgram(x),N(E[0][0],0,1/F,1/I,T),E.forEach(([e,t],n)=>{N(t,1,1/t.w,0,E[n&&n-1][0]),N(e,1,0,1/e.h,t)}),i.uniform1f(S.L,C.lines),N(void 0,2,0,0,T,...E.map(e=>e[0]));for(let e=3;e>0;e--)i.activeTexture(i.TEXTURE0+e),i.bindTexture(i.TEXTURE_2D,null);i.activeTexture(i.TEXTURE0),i.useProgram(b)},project:(e,t,n)=>Cu(A,e,t,n),destroy(){e.removeEventListener(`webglcontextlost`,I),e.removeEventListener(`webglcontextrestored`,L),i.getExtension(`WEBGL_lose_context`)?.loseContext()}}},Ru=1/60,zu=5,Bu=(e,n)=>{let r=document.createElement(`div`),i=r.attachShadow({mode:`open`});i.innerHTML=`<style>:host{display:block;width:100%;height:100%}div{position:relative;width:100%;height:100%;overflow:hidden;background:#000;font:600 14px system-ui,sans-serif;color:#fff;text-shadow:0 1px 2px #000}canvas{display:block;width:100%;height:100%;cursor:pointer}i,p,b{position:absolute;pointer-events:none;user-select:none;margin:0}`+Ws+`i{left:50%;top:50%;width:6px;height:6px;margin:-3px;border-radius:50%;background:#fff;box-shadow:0 0 0 1px #0008}p{bottom:8px;left:12px}b{transform:translate(-50%,-100%);font-size:12px;white-space:nowrap}[hidden]{display:none}</style><div><canvas></canvas><i></i><p></p></div>`,e.append(r);let a=i.querySelector(`canvas`),o=i.querySelector(`p`),s=i.querySelector(`div`),c=qs(s),l={roster:[],open:[],close:[]},u=e=>l[e].forEach(e=>e()),d=se(ne),f=dc(d),p=Bt();p.mute(Vt()),c.mute(p.muted);let m=rc(a,()=>c.mute(Ht(p)));a.addEventListener(`click`,()=>p.unlock());let h=Vs(),g=Us(p),_=ns(d),v=qn(),y=Jt(d),b=cs(d,p,c,h,v,m,y),x;try{x=Lu(a,d)}catch{}let S=d.def.teams.map(e=>e.base),C=d.def.teams.map(e=>e.rack),w=d.def.teams.map(e=>e.blade),T=[],E={id:-1,team:0},D,O,k=/* @__PURE__ */ new Map,A=/* @__PURE__ */ new Map,j=/* @__PURE__ */ new Map,ee=!1,M=x?``:`WebGL2 is not available`,te=!1,N=performance.now(),P=0,F=0,I=!1,L=n.socket??new WebSocket(n.url);L.binaryType=`arraybuffer`,L.onopen=()=>{ee=!0,L.send(JSON.stringify({t:`join`,name:n.name})),u(`open`)},L.onclose=()=>{ee=!1,M||=`Connection closed`,u(`close`)},L.onmessage=({data:e})=>{if(typeof e!=`string`){let t=_t(e);if(t){f.snapshot(t,performance.now()),y.snapshot(t.balls??[],E.id,performance.now());for(let e of Jn(D,t)){let t=Yn(e,E,e=>A.get(e)??`Someone`);t&&c.banner(t.text,t.team),e.kind==`start`&&([m.yaw,m.pitch]=[d.def.teams[E.team].spawns[0][3],0]);for(let t of Xn(e,E))p.play(t.id,t.at,t.gain,t.rate);e.kind==`tackle`?e.who==E.id?h.jolt():e.by==E.id&&h.punch():e.kind==`shock`&&(v.shock(e.at),e.who==E.id&&h.jolt())}D=t}return}let t=vt(e);t?.t==`roster`?(T=t.players,k=new Map(T.map(e=>[e.id,e.color])),A=new Map(T.map(e=>[e.id,e.name])),E={id:t.you,team:T.find(e=>e.id==t.you)?.team??0},f.you(E.id,E.team),o.textContent=`Players: ${T.length}`,u(`roster`)):t?.t==`end`?O={score:t.score,players:t.players}:t?.t==`full`&&(M=`Room is full`)};let R=e=>{let t=j.get(e);return t||(j.set(e,t=document.createElement(`b`)),s.append(t)),t},z=()=>{F=requestAnimationFrame(z);let e=performance.now(),n=N;if(P=Math.min(P+(e-N)/1e3,zu*Ru),N=e,!te){let e=f.me(0);e&&([m.yaw,m.pitch,te]=[e.yaw,e.pitch,!0]),P=0}for(;te&&P>=Ru;P-=Ru){let t=f.me(1),n=f.step({keys:m.take(),yaw:m.yaw,pitch:m.pitch},e);b.step(t,f.me(1)),m.track(t,f.me(1)),ee&&L.send(ht(n))}let r=f.me(P/Ru),i=f.others(e),o=r?[r.x,r.y+Ee(r),r.z]:[0,0,0];p.listen(o,m.yaw);let s=Math.min((e-n)/1e3,.1),l=e=>e==E.id?r:i.find(t=>t.id==e),u=D&&{bases:S,flags:_n(D.flags,S,l),racks:C,blades:w,packs:_c(d.def.packs,D.packs),ammo:_c(d.def.ammo,D.packs,d.def.packs?.length)},y=f.events();h.update(r,m.keys,s,y),c.hurt(h.hurt),g.me(r,y,h.stride),g.others(i),_.update(r,s,h.kick,a.clientWidth/(a.clientHeight||1));let T=[o[0],o[1]+h.dy,o[2]],I=m.pitch+h.pitch,ne=m.yaw+_.spun(),re=r&&rs(d,o,T,m.yaw,m.pitch,I);re&&_.aim(re.local),b.frame(r&&re&&{eye:o,cam:T,yaw:m.yaw,pitch:m.pitch,drawn:I,muzzle:_.muzzle(),...re},r,i,m.keys,s,e),r&&x&&x.frame(T,ne,I,i,k,h,[...An({eye:T,yaw:ne,pitch:I,others:i,t:e/1e3,ctf:u}),...v.lights()],_,u,v),D&&(c.match(D,e=>A.get(e)??`?`),c.marks(r&&x?gc({eye:o,id:E.id,team:E.team,yaw:ne,flags:D.flags,bases:S,where:e=>{let t=l(e);return t&&[t.x,t.y,t.z]},project:x.project}):[]),c.end(D.over?O:void 0,D.clock));let ie=/* @__PURE__ */ new Set;for(let e of i){let n=[e.x,e.y+t+.3,e.z],i=r&&!ue(d,o,n)?x?.project(...n):void 0,a=R(e.id);ie.add(e.id),a.hidden=!i,i&&(a.style.left=i[0]*100+`%`,a.style.top=i[1]*100+`%`);let s=A.get(e.id)??``;a.textContent!=s&&(a.textContent=s),a.style.color=k.get(e.id)??``}for(let[e,t]of j)ie.has(e)||(t.remove(),j.delete(e));c.title(M||(ee?te?m.locked()?``:`Click to play`:`Joining…`:`Connecting…`),d.def.name??``)};return F=requestAnimationFrame(z),{on:(e,t)=>void l[e].push(t),players:()=>T,destroy(){I||(I=!0,cancelAnimationFrame(F),m.destroy(),p.destroy(),x?.destroy(),L.onopen=L.onclose=L.onmessage=null,L.close(),document.exitPointerLock(),r.remove())}}};export{Bu as tinyFps};
|
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},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,ee=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)&2047,yaw:v(t.getUint16(5)),pitch:_(t.getInt16(7)),view:(t.getUint16(9)*256+t.getUint8(11))/256}:null},y=t=>t===e.CARRIED?2:t===e.DROPPED?8:1,b=n=>{let r=4+47*n.players.length,i=n.balls??[],a=r+8+n.flags.reduce((e,t)=>e+y(t.state),0),o=new DataView(new ArrayBuffer(a+(i.length&&1+10*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*47;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)}),o.setUint8(r,n.score[0]),o.setUint8(r+1,n.score[1]),o.setUint16(r+2,n.clock&32767|(n.over?32768:0)),o.setUint32(r+4,n.packs??0);let s=r+8;for(let t of n.flags)o.setUint8(s,t.state),t.state===e.CARRIED?o.setUint8(s+1,t.by):t.state===e.DROPPED&&(o.setInt16(s+1,h(t.x*l)),o.setInt16(s+3,h(t.y*l)),o.setInt16(s+5,h(t.z*l)),o.setUint8(s+7,Math.min(255,t.left))),s+=y(t.state);i.length&&o.setUint8(s++,i.length);for(let e of i)o.setUint8(s,e.id),o.setUint8(s+1,e.by&127|(e.burst?128:0)),[e.x,e.y,e.z].forEach((e,t)=>o.setInt16(s+2+2*t,h(e*u))),o.setUint8(s+8,Math.round(Math.atan2(-e.dx,-e.dz)*d)&255),o.setInt8(s+9,Math.round(Math.asin(Math.max(-1,Math.min(1,e.dy)))*f)),s+=10;return o.buffer},te=e=>{try{let t=JSON.parse(e);return t&&typeof t.t==`string`?t:null}catch{return null}},x=.4,S=1.8,ne=1.6,re=1.55,ie=.9,ae=.7,oe=7.5,se=1.5,ce=.15,le=.5,ue=.9,de=6.5,fe=.2,pe=.03,me=.2,he=5.5,ge=2.5,_e=[`#ff3d4f`,`#2f80ff`],ve=.12,C=[{ticks:28,strike:10,reach:2.65,arc:.3,hp:2},{ticks:34,strike:13,reach:2.15,arc:1.2,hp:2},{ticks:34,strike:13,reach:2.15,arc:1.2,hp:2},{ticks:40,strike:16,reach:2.15,arc:.45,hp:3},{ticks:36,strike:12,reach:3.2,arc:.3,hp:3},{ticks:48,strike:24,reach:2.3,arc:Math.PI,hp:3},{ticks:48,strike:24,reach:2.3,arc:Math.PI,hp:3},{ticks:58,strike:40,reach:2.4,arc:.6,hp:4}],ye=7.5,[be,xe,Se]=[.82,.45,.12],Ce={maxPlayers:16,scoreLimit:3,timeLimit:480},we=4,w=1024,T=(e,t)=>(e+w)*(2*w)+t+w,E=(e,t)=>Math.min(Math.max(Math.floor(e/t),-1024),1023),Te=(e,t=we)=>{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=T(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(T(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(T(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)>w||Math.abs(l)>w)return s;m<h?(c+=u,m+=g):(l+=d,h+=_)}},Ee=(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,De=Math.PI*2,A=1e-6,j=.01,Oe=.001,ke=e=>(e%De+De)%De,M=e=>[-Math.sin(e),-Math.cos(e)],N=Math.fround,Ae=Math.sqrt,P=(e,t,n)=>Math.min(Math.max(e,t),n),F=(e,t)=>Ae(e*e+t*t),I=[[0,0],[1,0],[-1,0],[0,1],[0,-1]],je={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,ev:0,fall:0},Me=(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:ke(c),pitch:0,ground:!0,...je}},Ne=(e,t,n)=>{let{yaw:r,pitch:i,id:a,shots:s,hits:c}=e;Object.assign(e,Me(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?ie:S,Pe=e=>e.mode===i.SLIDE||e.mode===i.CROUCH?ae:ne,Fe=e=>F(e.vx,e.vz),z=(e,t,n)=>e.max[1]>t+.5+j&&e.min[1]<t+n-j,B=(e,t,n)=>[t-P(t,e.min[0],e.max[0]),n-P(n,e.min[2],e.max[2])],Ie=(e,t,n)=>{let{brushes:r}=t.def,i=D(t,e.x,e.z,2*x),a=(x-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(!z(i,e.y,n))continue;let[s,u]=B(i,e.x,e.z),d=s*s+u*u;if(d>=a)continue;if(d){let e=Ae(d);.4-e>t&&(t=x-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+x,[c,l]=[p*t,m*t])}if(!t)break;e.x+=c,e.z+=l,o+=c,s+=l}return[o,s]},Le=(e,t,n)=>{let{brushes:r}=t.def,i=(x-A)**2,a=-1/0,o=1/0;for(let s of D(t,e.x,e.z,x)){let t=r[s],[c,l]=B(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]},V=(e,t)=>{let n=(x-A)**2;return D(t,e.x,e.z,x).every(r=>{let i=t.def.brushes[r],[a,o]=B(i,e.x,e.z);return a*a+o*o>=n||!z(i,e.y,1.8)})},Re=(e,t,n,r,i)=>{let a=(x-A)**2;return D(e,t,n,x).every(o=>{let s=e.def.brushes[o],[c,l]=B(s,t,n);return c*c+l*l>=a||s.max[1]<=r||s.min[1]>=i})},ze=(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}},Be=(e,t,n,r)=>{let{a:i,o:a,sign:o,c:s,co:c}=ze(t,n),l=((o>0?e.min[i]:e.max[i])-s)*o;return l>=.4-Oe&&l<=.4+r&&c>=e.min[a]&&c<=e.max[a]?l:void 0},Ve=(e,t,n)=>{let r;for(let i of D(t,e.x,e.z,x+le)){let a=t.def.brushes[i],o=Be(a,e,n,le);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-x)))}return r},He=(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}=ze(e,a);for(let n of D(t,e.x,e.z,x+fe)){let r=t.def.brushes[n],o=r.max[1],s=o-e.y;if(Be(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*(x+pe),f=u+l*me,[p,m]=c===0?[d,e.z]:[e.x,d],[h,g]=c===0?[f,e.z]:[e.x,f];Re(t,p,m,Math.min(e.y,o-2)+j,o+1.8)&&Re(t,h,g,o+j,o+1.8)&&(i={side:a,top:o,hang:d})}}return i},Ue=(e,t)=>{let{a:n,o:r,sign:i,c:a,co:o}=ze(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})},We=(e,t)=>{if(e.vy>=0)return!1;let[n]=Le(e,t,S),r=6*k;return e.y-n<=-e.vy*r+10*r*r},H=(e,t)=>{e.mode=t,e.t=0},Ge=(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)&&(H(e,i.AIR),e.edge=0)},Ke=(e,t)=>{let n=F(e.vx,e.vz);n>t&&(e.vx*=t/n,e.vz*=t/n)},qe=(e,t,n,r)=>{let[i,a]=[n.wx,n.wz];for(let n of D(t,e.x,e.z,x+Oe)){let o=t.def.brushes[n],[s,c]=B(o,e.x,e.z),l=F(s,c);if(l>0&&l<=.4+Oe&&z(o,e.y,r)){let e=(-i*s-a*c)/l;e>0&&(i+=e*s/l,a+=e*c/l)}}return[i,a]},Je=(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},Ye=(e,t,n,r,i)=>{let a=e.y;e.x+=e.vx*k,e.z+=e.vz*k;let[o,s]=Ie(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]=Le(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},Xe=(e,n,r)=>{let[a,o]=I[e.wall],s=t=>{H(e,t),e.edge=0};if(r.keys&(t.BACK|t.CROUCH))s(i.AIR),e.coyote=0;else if(r.jump&&r.fx*a+r.fz*o<0)s(i.AIR),e.vx=-a*4,e.vz=-o*4,U(e,6);else if(r.jump||r.fwd&&e.t>=6)H(e,i.CLIMB);else if(e.t>=30)s(i.AIR),e.coyote=0;else{let t=Math.max(e.edge-2,Le(e,n,S)[0]);e.y+=P(t-e.y,-8*k,8*k)}},Ze=(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*he*k,e.z+=r*he*k),e.y>=e.edge&&Ue(e,t)?(H(e,i.GROUND),e.vx=n*3,e.vz=r*3,e.vy=0,e.edge=0,e.wall=a.NONE,e.coyote=6,e.ev|=o.CLIMB):e.t>=40&&(H(e,e.y>=e.edge?i.GROUND:i.AIR),e.edge=0,e.wall=a.NONE)},Qe=(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)H(e,i.AIR),e.vx=c-r*5,e.vz=l-a*5,U(e,de),e.jumps=1,e.dashes=1,e.ev|=o.WALLRUN_END;else{let s=Ve(e,t,e.wall);if(s===void 0||!n.fwd||u<3.5||e.t>=60){H(e,i.AIR),e.ev|=o.WALLRUN_END;return}let d=Math.max(0,u-se*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}},$e=(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&&Ve(e,t,n)!==void 0){let t=F(l,u),a=Math.max(t,ue*r)/t;H(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}}},et=(e,t)=>{H(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},tt=(e,n,r)=>{let s=e.mode===i.GROUND;if(r.dash&&e.dash===0&&(s||(e.mode===i.AIR||e.mode===i.WALLRUN)&&e.dashes>0)){let[t,n]=r.wx||r.wz?[r.wx,r.wz]:[r.fx,r.fz];s||(e.dashes--,e.vy=0,e.mode===i.WALLRUN&&(H(e,i.AIR),e.ev|=o.WALLRUN_END)),e.vx=t*16,e.vz=n*16,e.dash=60,e.ev|=o.DASH}let c=e.dash>50;e.mode===i.WALLRUN&&Qe(e,n,r),L(e.mode)&&nt(e,n,r,c),e.mode===i.AIR&&rt(e,n,r,c);let l=c&&e.vy<=0?0:e.mode===i.WALLRUN?ce:1,u=e.mode,d=Ye(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)>=oe;H(e,t?i.SLIDE:i.CROUCH),e.ev|=t?o.SLIDE_START:0}else H(e,i.GROUND)}e.coyote=6}else L(e.mode)&&(e.ev|=e.mode===i.SLIDE?o.SLIDE_END:0,H(e,i.AIR));if(e.mode===i.AIR){let t=He(e,n);t?et(e,t):$e(e,n,r)}},nt=(e,n,r,a)=>{let s=(r.keys&t.CROUCH)!==0;if(e.buffer>0&&(e.mode===i.GROUND||V(e,n))){e.ev|=e.mode===i.SLIDE?o.SLIDE_END:0,H(e,i.AIR),U(e,7);return}let c=F(e.vx,e.vz);if(e.mode===i.GROUND&&s){let t=c>=oe;H(e,t?i.SLIDE:i.CROUCH),e.ev|=t?o.SLIDE_START:0}else e.mode===i.SLIDE&&(e.t>=60||c<4.5||r.stumble)?(e.ev|=o.SLIDE_END,H(e,!s&&V(e,n)?i.GROUND:i.CROUCH)):e.mode===i.SLIDE&&!s&&V(e,n)?(e.ev|=o.SLIDE_END,H(e,i.GROUND)):e.mode===i.CROUCH&&!s&&V(e,n)&&H(e,i.GROUND);if(!a){if(r.stumble){if(c>2.5){let t=Math.max(ge,c-12*k)/c;e.vx*=t,e.vz*=t}else Je(e,qe(e,n,r,R(e)),ge)}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)Je(e,qe(e,n,r,ie),3);else{let i=(r.keys&t.SPRINT)!==0&&r.fwd;Je(e,qe(e,n,r,S),i?9:6)}}},rt=(e,t,n,r)=>{if(e.buffer>0&&(e.coyote>0?U(e,7):e.jumps>0&&!We(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,Ke(e,Math.max(i,6))},it=(e,n,r,a=0)=>{e.yaw=ke(n.yaw),e.pitch=Math.max(-re,Math.min(re,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&&Ke(e,10)),e.mode===i.HANG&&Xe(e,r,p),e.mode===i.CLIMB?Ze(e,r):e.mode!==i.HANG&&tt(e,r,p),e.y<r.def.floor&&Ne(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)},W=.7,at=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},ot=(e,t,n)=>{let{reach:r,arc:i}=C[t.cut??0],[a,o]=M(t.yaw),s=[t.x,t.y+W*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(x/u):Math.PI;return d<=i+f&&!Ee(e,s,[n.x,n.y+W*R(n),n.z])})},st=(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]},ct=(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(x*x-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)<=Se?r.HEAD:m>0?r.ARM_R:r.ARM_L;let g=(e.y+W*R(e)+Math.tan(e.pitch)*Math.hypot(c,l)-t.y)/R(t);if(g>be)return r.HEAD;let _=h===n.THRUST?m>0:(h===n.LEFT?1:-1)*(i*o+a*s)<0;return g<xe?_?r.LEG_R:r.LEG_L:h===n.THRUST&&Math.abs(m)<=Se?r.NONE:_?r.ARM_R:r.ARM_L},G=()=>({state:e.HOME,by:0,x:0,y:0,z:0,left:0}),lt=60,ut=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],lt);t<lt&&(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=>dt(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&&dt(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}},dt=(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},ft=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=ye,e.ev|=o.JUMP)}},q={NONE:0,SHOT:1,CUT:2},pt=(e,n,r,a,o=!0)=>{let s=e.down>0;if(it(e,s?{...n,keys:0}:n,r,a),e.zap=!!e.stun&&!!e.zap,s)return e.down>0&&!--e.down&&Ne(e,r,a),q.NONE;let{rack:c,blade:l}=r.def.teams[a],u=!!c&&K(e,c,1.2);o&&u&&!e.rack&&(e.ammo=60),e.rack=u,e.blade=!!e.blade||o&&!!l&&K(e,l,1.2),e.cool=Math.max(0,e.cool-1),e.swing=Math.max(0,(e.swing??0)-1),e.wield=e.blade&&(e.swing>0||!!(n.keys&t.BLADE)||e.ammo<0);let d=e.mode===i.HANG||e.mode===i.CLIMB;if(!o)return q.NONE;let f=C[e.cut??0];if(e.swing&&f.ticks-e.swing===f.strike)return q.CUT;if(n.keys&t.FIRE&&!d){let r=C[e.cut??0].ticks-e.swing,i=!!(n.keys&t.SPECIAL)&&(!e.swing||(e.cut??0)<4&&r<=18);if(e.wield&&(!e.swing||i))e.cut=at(n.keys)+(i?4:0),e.swing=C[e.cut].ticks,ft(e);else if(!e.wield&&!e.cool&&e.ammo>0)return e.ammo--,e.shots=e.shots+1&255,e.cool=7,q.SHOT}return q.NONE},mt=-30,J=(e,t,n,r,i,a=s.CONCRETE)=>({min:[e,mt,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],ht=[.2,.46,1],gt=[1,.42,.08],_t=[.12,.7,.62],Q=(e,t,n,r,i,a,o)=>Y([e,t,n],[r,i,a],s.PAINT,s.PAINT,o),vt=(e,t,n,r,i,a,o,c=mt)=>{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)),yt=[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([29,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,_t),Y([14,18,147],[15,32,164],s.PAINT,s.PAINT,_t),Y([14,26,134],[15,32,147],s.PAINT,s.PAINT,_t),...$(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,mt,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,gt),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),...vt(0,76,52,226,232,14.5,26),...vt(0,85,76,196,202,14.5,19,14.5)],bt=[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,gt),...[[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)],xt=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?ht:e.tint}),St=(e,t,n)=>[...[16,22,28,34,40].map(n=>[n,26,t,e]),...[19,31,43].map(t=>[t,26,n,e])],Ct=[[20,26,190],[48,21.2,172],[48,19,200],[88,14.5,198]],wt=[[21,26,168],[46,19,144],[36,21.2,178],[88,14.5,216],[88,14.5,172]],Tt={name:`Highline`,brushes:[...yt,...yt.map(xt),...bt],teams:[{base:[32,26,224],spawns:St(0,236,231),rack:[30.75,27.5,217],blade:[33.25,27.5,217]},{base:[32,26,16],spawns:St(Math.PI,4,9),rack:[30.75,27.5,23],blade:[33.25,27.5,23]}],packs:[...Ct,...Ct.map(([e,t,n])=>[e,t,X-n]),[24,15,112],[24,15,128]],ammo:[...wt,...wt.map(([e,t,n])=>[e,t,X-n])],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]},Et=40/60,Dt=(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+Pe(e),z:e.z,dx:-n*a,dy:i,dz:-r*a,left:80,burst:!1}},Ot=(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},kt=(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,ve),c;for(let e of r){let t=Ot(i,a,e,x+ve,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},At=e=>e.mode===i.SLIDE||e.dash>50,jt=(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),Mt=20,Nt=2,Pt=(e,t)=>Array.from(e).slice(0,t).join(``).trim(),Ft=e=>Pt((typeof e==`string`?e:``).replace(/\s+/g,` `).replace(/\p{Cc}/gu,``).trim(),16),It=(e,t)=>{let n=e;for(let r=2;t.includes(n);r++)n=`${Pt(e,15-`${r}`.length)} ${r}`;return n},Lt=(e,t)=>{let n=setInterval(e,t);return()=>clearInterval(n)},Rt=class{peers=/* @__PURE__ */ new Map;ticks=0;history=[];world;ctf;halt;rules;rr=[0,0];gone;balls=[];constructor(e={},t=Tt){this.rules={...Ce,...e},this.world=Te(t),this.ctf=new ut(this.world,this.rules),this.gone=[...t.packs??[],...t.ammo??[]].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=te(t);n===null&&r?.t===`join`&&this.join(e,r.name);return}let r=n&&ee(t);if(r&&n.bank>0){n.bank--;let e=pt(n.state,r,this.world,n.info.team,!this.ctf.over);this.ctf.moved(n.state),this.tackle(n,r.view),e===q.SHOT?this.shoot(n,r.view):e===q.CUT&&this.cut(n,r.view),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,Et);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=b({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|1<<n,0)>>>0,balls:this.balls});e.forEach(e=>e.conn.send(n)),this.balls=this.balls.filter(e=>!e.burst&&e.left>0)}}start(e=Lt){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<Mt;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||!At(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=>jt(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=Fe(n),[s,c]=o>.001?[n.vx/o,n.vz/o]:M(n.yaw);Ge(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,blade:!1,wield:!1,swing:0,lost:r.NONE}),this.ctf.drop(e.state),!0)}shoot(e,t=0){let n=Dt(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)*Et);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=kt(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,1)}cut(e,t){let n=ot(this.world,e.state,this.enemies(e,t)),r=this.players().filter(e=>n.some(t=>t.id===e.info.id));if(r.length){e.state.hits=e.state.hits+1&255;for(let t of r){let r=n.find(e=>e.id===t.info.id);if(this.harm(t,C[e.state.cut??0].hp))t.state.lost=ct(e.state,r);else{let[n,i]=st(e.state,r);Ge(t.state,n,i,24,4),t.state.zap=!0,t.by=e.info.id}}}}heal(e){let{packs:t=[],ammo:n=[]}=this.world.def;[...t,...n].forEach((n,r)=>{if(this.gone[r]>0){this.gone[r]--;return}let i=r<t.length,a=e.find(({state:e})=>!e.down&&(i?e.hp<5:e.ammo>=0&&e.ammo<60)&&K(e,n,.9));if(a){let e=a.state;i?e.hp=Math.min(5,e.hp+2):e.ammo=Math.min(60,e.ammo+20),this.gone[r]=1200}})}place(e,t,n){let r=this.world.def.teams[t].spawns.findIndex((r,i)=>{let{x:a,z:o}=Me(e,this.world,i,t);return!n.some(e=>Math.hypot(e.x-a,e.z-o)<Nt)});return Me(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:It(Ft(t)||`Player ${r}`,n.map(e=>e.info.name)),team:a,color:_e[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})))}},zt=(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()},Bt=(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&&b.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 Rt(t),s.start(zt),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 ee=e=>{p||(typeof e==`string`&&te(e)?.t===`join`&&(f=e),s?s.receive(g,e):u?m({kind:`m`,data:e}):d.push(e))},y=()=>{p||(p=!0,globalThis.removeEventListener?.(`pagehide`,y),s?(s.stop(),l()):(m({kind:`b`}),a.abort()),i.close(),setTimeout(()=>b.onclose?.()))},b={binaryType:`arraybuffer`,onopen:null,onclose:null,onmessage:null,send:ee,close:y};return o?o.request(n,{signal:a.signal},()=>new Promise(v)).catch(()=>{}):v(()=>{}),m({kind:`q`}),globalThis.addEventListener?.(`pagehide`,y),setTimeout(()=>!p&&b.onopen?.()),b};export{Bt 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},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,ee=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)&2047,yaw:v(t.getUint16(5)),pitch:_(t.getInt16(7)),view:(t.getUint16(9)*256+t.getUint8(11))/256}:null},y=t=>t===e.CARRIED?2:t===e.DROPPED?8:1,b=n=>{let r=4+48*n.players.length,i=n.balls??[],a=r+8+n.flags.reduce((e,t)=>e+y(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*48;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),o.setUint8(r+47,e.charge??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)),o.setUint32(r+4,n.packs??0);let s=r+8;for(let t of n.flags)o.setUint8(s,t.state),t.state===e.CARRIED?o.setUint8(s+1,t.by):t.state===e.DROPPED&&(o.setInt16(s+1,h(t.x*l)),o.setInt16(s+3,h(t.y*l)),o.setInt16(s+5,h(t.z*l)),o.setUint8(s+7,Math.min(255,t.left))),s+=y(t.state);i.length&&o.setUint8(s++,i.length);for(let e of i)o.setUint8(s,e.id),o.setUint8(s+1,e.by&127|(e.burst?128:0)),[e.x,e.y,e.z].forEach((e,t)=>o.setInt16(s+2+2*t,h(e*u))),o.setUint8(s+8,Math.round(Math.atan2(-e.dx,-e.dz)*d)&255),o.setInt8(s+9,Math.round(Math.asin(Math.max(-1,Math.min(1,e.dy)))*f)),o.setUint8(s+10,e.power??1),s+=11;return o.buffer},te=e=>{try{let t=JSON.parse(e);return t&&typeof t.t==`string`?t:null}catch{return null}},x=.4,S=1.8,ne=1.6,re=1.55,ie=.9,ae=.7,oe=7.5,se=1.5,ce=.15,le=.5,ue=.9,de=6.5,fe=.2,pe=.03,me=.2,he=5.5,ge=2.5,_e=[`#ff3d4f`,`#2f80ff`],ve=.12,C=[{ticks:28,strike:10,reach:2.65,arc:.3,hp:2},{ticks:34,strike:13,reach:2.15,arc:1.2,hp:2},{ticks:34,strike:13,reach:2.15,arc:1.2,hp:2},{ticks:40,strike:16,reach:2.15,arc:.45,hp:3},{ticks:36,strike:12,reach:3.2,arc:.3,hp:3},{ticks:48,strike:24,reach:2.3,arc:Math.PI,hp:3},{ticks:48,strike:24,reach:2.3,arc:Math.PI,hp:3},{ticks:58,strike:40,reach:2.4,arc:.6,hp:4}],ye=7.5,[be,xe,Se]=[.82,.45,.12],Ce={maxPlayers:16,scoreLimit:3,timeLimit:480},we=4,w=1024,Te=(e,t)=>(e+w)*(2*w)+t+w,T=(e,t)=>Math.min(Math.max(Math.floor(e/t),-1024),1023),Ee=(e,t=we)=>{let n=/* @__PURE__ */ new Map;return e.brushes.forEach(({min:e,max:r},i)=>{for(let a=T(e[0],t);a<=T(r[0],t);a++)for(let o=T(e[2],t);o<=T(r[2],t);o++){let e=Te(a,o),t=n.get(e);t?t.push(i):n.set(e,[i])}}),{def:e,cell:t,grid:n}},E=(e,t,n,r)=>{let i=[];for(let a=T(t-r,e.cell);a<=T(t+r,e.cell);a++)for(let t=T(n-r,e.cell);t<=T(n+r,e.cell);t++)for(let n of e.grid.get(Te(a,t))??[])i.includes(n)||i.push(n);return i},D=(e,t,n,r,i=0)=>{let{cell:a,def:o}=e,s=r,c=T(t[0],a),l=T(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(Te(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)>w||Math.abs(l)>w)return s;m<h?(c+=u,m+=g):(l+=d,h+=_)}},De=(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&&D(e,t,[r/o,i/o,a/o],o)<o-1e-4},O=1/60,Oe=Math.PI*2,k=1e-6,A=.01,ke=.001,Ae=e=>(e%Oe+Oe)%Oe,j=e=>[-Math.sin(e),-Math.cos(e)],M=Math.fround,je=Math.sqrt,N=(e,t,n)=>Math.min(Math.max(e,t),n),P=(e,t)=>je(e*e+t*t),F=[[0,0],[1,0],[-1,0],[0,1],[0,-1]],Me={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,ev:0,fall:0},I=(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:M(a),y:M(o),z:M(s),vy:0,yaw:Ae(c),pitch:0,ground:!0,...Me}},Ne=(e,t,n)=>{let{yaw:r,pitch:i,id:a,shots:s,hits:c}=e;Object.assign(e,I(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?ie:S,Pe=e=>e.mode===i.SLIDE||e.mode===i.CROUCH?ae:ne,Fe=e=>P(e.vx,e.vz),z=(e,t,n)=>e.max[1]>t+.5+A&&e.min[1]<t+n-A,B=(e,t,n)=>[t-N(t,e.min[0],e.max[0]),n-N(n,e.min[2],e.max[2])],Ie=(e,t,n)=>{let{brushes:r}=t.def,i=E(t,e.x,e.z,2*x),a=(x-k)**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(!z(i,e.y,n))continue;let[s,u]=B(i,e.x,e.z),d=s*s+u*u;if(d>=a)continue;if(d){let e=je(d);.4-e>t&&(t=x-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+x,[c,l]=[p*t,m*t])}if(!t)break;e.x+=c,e.z+=l,o+=c,s+=l}return[o,s]},V=(e,t,n)=>{let{brushes:r}=t.def,i=(x-k)**2,a=-1/0,o=1/0;for(let s of E(t,e.x,e.z,x)){let t=r[s],[c,l]=B(t,e.x,e.z);c*c+l*l>=i||(t.max[1]<=e.y+.5+A?a=Math.max(a,t.max[1]):t.min[1]>=e.y+n-A&&(o=Math.min(o,t.min[1])))}return[a,o]},H=(e,t)=>{let n=(x-k)**2;return E(t,e.x,e.z,x).every(r=>{let i=t.def.brushes[r],[a,o]=B(i,e.x,e.z);return a*a+o*o>=n||!z(i,e.y,1.8)})},Le=(e,t,n,r,i)=>{let a=(x-k)**2;return E(e,t,n,x).every(o=>{let s=e.def.brushes[o],[c,l]=B(s,t,n);return c*c+l*l>=a||s.max[1]<=r||s.min[1]>=i})},U=(e,t)=>{let[n,r]=F[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}},Re=(e,t,n,r)=>{let{a:i,o:a,sign:o,c:s,co:c}=U(t,n),l=((o>0?e.min[i]:e.max[i])-s)*o;return l>=.4-ke&&l<=.4+r&&c>=e.min[a]&&c<=e.max[a]?l:void 0},ze=(e,t,n)=>{let r;for(let i of E(t,e.x,e.z,x+le)){let a=t.def.brushes[i],o=Re(a,e,n,le);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-x)))}return r},Be=(e,t)=>{let[n,r]=j(e.yaw),i;for(let a=1;a<=4;a++){let[o,s]=F[a];if(a===e.wall||n*o+r*s<.5)continue;let{a:c,sign:l}=U(e,a);for(let n of E(t,e.x,e.z,x+fe)){let r=t.def.brushes[n],o=r.max[1],s=o-e.y;if(Re(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*(x+pe),f=u+l*me,[p,m]=c===0?[d,e.z]:[e.x,d],[h,g]=c===0?[f,e.z]:[e.x,f];Le(t,p,m,Math.min(e.y,o-2)+A,o+1.8)&&Le(t,h,g,o+A,o+1.8)&&(i={side:a,top:o,hang:d})}}return i},Ve=(e,t)=>{let{a:n,o:r,sign:i,c:a,co:o}=U(e,e.wall);return E(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 M(c.max[1])===e.edge&&o>=c.min[r]&&o<=c.max[r]&&l>=.2})},He=(e,t)=>{if(e.vy>=0)return!1;let[n]=V(e,t,S),r=6*O;return e.y-n<=-e.vy*r+10*r*r},W=(e,t)=>{e.mode=t,e.t=0},Ue=(e,t,n,r=48,a=6)=>{e.stun=r,e.vx=M(t*a),e.vz=M(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)&&(W(e,i.AIR),e.edge=0)},We=(e,t)=>{let n=P(e.vx,e.vz);n>t&&(e.vx*=t/n,e.vz*=t/n)},Ge=(e,t,n,r)=>{let[i,a]=[n.wx,n.wz];for(let n of E(t,e.x,e.z,x+ke)){let o=t.def.brushes[n],[s,c]=B(o,e.x,e.z),l=P(s,c);if(l>0&&l<=.4+ke&&z(o,e.y,r)){let e=(-i*s-a*c)/l;e>0&&(i+=e*s/l,a+=e*c/l)}}return[i,a]},Ke=(e,t,n)=>{let r=P(t[0],t[1]);if(r<k){let t=P(e.vx,e.vz),n=t?Math.max(0,t-45*O)/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=P(s,c);if(l){let e=Math.max(0,l-45*O)/l;[s,c]=[s*e,c*e]}n*=r,o=o<n?Math.min(n,o+(o>=6?3:50)*O):Math.max(n,o-12*O),e.vx=s+o*i,e.vz=c+o*a},qe=(e,t,n,r,i)=>{let a=e.y;e.x+=e.vx*O,e.z+=e.vz*O;let[o,s]=Ie(e,t,n),c=P(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]=V(e,t,n),d=e.vy-r*20*O;if(e.y+=(e.vy+d)/2*O,e.vy=d,e.y+n>u&&(e.y=u-n,e.vy=Math.min(e.vy,0)),e.vy<=0?e.y<=l+A: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},G=(e,t)=>{e.vy=t,e.coyote=0,e.buffer=0,e.ev|=o.JUMP},Je=(e,n,r)=>{let[a,o]=F[e.wall],s=t=>{W(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,G(e,6);else if(r.jump||r.fwd&&e.t>=6)W(e,i.CLIMB);else if(e.t>=30)s(i.AIR),e.coyote=0;else{let t=Math.max(e.edge-2,V(e,n,S)[0]);e.y+=N(t-e.y,-8*O,8*O)}},Ye=(e,t)=>{let[n,r]=F[e.wall];e.y<e.edge?e.y=Math.min(e.edge,e.y+8*O):(e.x+=n*he*O,e.z+=r*he*O),e.y>=e.edge&&Ve(e,t)?(W(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&&(W(e,e.y>=e.edge?i.GROUND:i.AIR),e.edge=0,e.wall=a.NONE)},Xe=(e,t,n)=>{let[r,a]=F[e.wall],s=e.vx*r+e.vz*a,[c,l]=[e.vx-s*r,e.vz-s*a],u=P(c,l);if(n.jump)W(e,i.AIR),e.vx=c-r*5,e.vz=l-a*5,G(e,de),e.jumps=1,e.dashes=1,e.ev|=o.WALLRUN_END;else{let s=ze(e,t,e.wall);if(s===void 0||!n.fwd||u<3.5||e.t>=60){W(e,i.AIR),e.ev|=o.WALLRUN_END;return}let d=Math.max(0,u-se*O)/u;e.vx=c*d,e.vz=l*d;let f=Math.min(s,4*O);e.x+=r*f,e.z+=a*f}},Ze=(e,t,n)=>{if(!n.fwd)return;let r=P(e.vx,e.vz);if(!(r<4.5))for(let n=1;n<=4;n++){let[a,s]=F[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&&ze(e,t,n)!==void 0){let t=P(l,u),a=Math.max(t,ue*r)/t;W(e,i.WALLRUN),e.wall=n,[e.vx,e.vz]=[l*a,u*a],e.vy=N(e.vy,2,3),e.jumps=1,e.dashes=1,e.coyote=0,e.ev|=o.WALLRUN_START;return}}},Qe=(e,t)=>{W(e,i.HANG),e.wall=t.side,e.edge=M(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},$e=(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&&(W(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&&Xe(e,n,r),L(e.mode)&&et(e,n,r,c),e.mode===i.AIR&&tt(e,n,r,c);let l=c&&e.vy<=0?0:e.mode===i.WALLRUN?ce:1,u=e.mode,d=qe(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=P(e.vx,e.vz)>=oe;W(e,t?i.SLIDE:i.CROUCH),e.ev|=t?o.SLIDE_START:0}else W(e,i.GROUND)}e.coyote=6}else L(e.mode)&&(e.ev|=e.mode===i.SLIDE?o.SLIDE_END:0,W(e,i.AIR));if(e.mode===i.AIR){let t=Be(e,n);t?Qe(e,t):Ze(e,n,r)}},et=(e,n,r,a)=>{let s=(r.keys&t.CROUCH)!==0;if(e.buffer>0&&(e.mode===i.GROUND||H(e,n))){e.ev|=e.mode===i.SLIDE?o.SLIDE_END:0,W(e,i.AIR),G(e,7);return}let c=P(e.vx,e.vz);if(e.mode===i.GROUND&&s){let t=c>=oe;W(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,W(e,!s&&H(e,n)?i.GROUND:i.CROUCH)):e.mode===i.SLIDE&&!s&&H(e,n)?(e.ev|=o.SLIDE_END,W(e,i.GROUND)):e.mode===i.CROUCH&&!s&&H(e,n)&&W(e,i.GROUND);if(!a){if(r.stumble){if(c>2.5){let t=Math.max(ge,c-12*O)/c;e.vx*=t,e.vz*=t}else Ke(e,Ge(e,n,r,R(e)),ge)}else if(e.mode===i.SLIDE){let t=Math.max(0,c-4*O)/c;e.vx*=t,e.vz*=t}else if(e.mode===i.CROUCH)Ke(e,Ge(e,n,r,ie),3);else{let i=(r.keys&t.SPRINT)!==0&&r.fwd;Ke(e,Ge(e,n,r,S),i?9:6)}}},tt=(e,t,n,r)=>{if(e.buffer>0&&(e.coyote>0?G(e,7):e.jumps>0&&!He(e,t)&&(e.jumps--,G(e,6),e.ev=e.ev&~o.JUMP|o.DOUBLE)),r||!n.wx&&!n.wz)return;let i=P(e.vx,e.vz);e.vx+=n.wx*14*O,e.vz+=n.wz*14*O,We(e,Math.max(i,6))},nt=(e,n,r,a=0)=>{e.yaw=Ae(n.yaw),e.pitch=Math.max(-re,Math.min(re,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=P(o,s)||1,[l,u]=j(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&&We(e,10)),e.mode===i.HANG&&Je(e,r,p),e.mode===i.CLIMB?Ye(e,r):e.mode!==i.HANG&&$e(e,r,p),e.y<r.def.floor&&Ne(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=M(e.x),e.y=M(e.y),e.z=M(e.z),e.vx=M(e.vx),e.vy=M(e.vy),e.vz=M(e.vz),e.edge=M(e.edge)},rt=.7,it=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},at=(e,t,n)=>{let{reach:r,arc:i}=C[t.cut??0],[a,o]=j(t.yaw),s=[t.x,t.y+rt*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(x/u):Math.PI;return d<=i+f&&!De(e,s,[n.x,n.y+rt*R(n),n.z])})},ot=(e,t)=>{let[r,i]=j(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]},st=(e,t)=>{let[i,a]=j(e.yaw),[o,s]=j(t.yaw),[c,l]=[t.x-e.x,t.z-e.z],u=-a*c+i*l,d=Math.sqrt(Math.max(x*x-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)<=Se?r.HEAD:m>0?r.ARM_R:r.ARM_L;let g=(e.y+rt*R(e)+Math.tan(e.pitch)*Math.hypot(c,l)-t.y)/R(t);if(g>be)return r.HEAD;let _=h===n.THRUST?m>0:(h===n.LEFT?1:-1)*(i*o+a*s)<0;return g<xe?_?r.LEG_R:r.LEG_L:h===n.THRUST&&Math.abs(m)<=Se?r.NONE:_?r.ARM_R:r.ARM_L},K=()=>({state:e.HOME,by:0,x:0,y:0,z:0,left:0}),ct=60,lt=class{score=[0,0];over=!1;flags=[K(),K()];world;rules;mates=/* @__PURE__ */ new Map;clock;back=[0,0];lock=[{id:-1,left:0},{id:-1,left:0}];hold=[0,0];constructor(e,t){this.world=e,this.rules=t,this.clock=t.timeLimit*60}join(e,t,n){this.mates.set(e,{team:t,caps:0,returns:0,ground:[n.x,n.y,n.z]})}leave(e){let t=this.carrying(e),n=this.mates.get(e);t>=0&&n&&this.dropAt(t,n.ground),this.mates.delete(e)}place(e,t){let n=this.mates.get(e);n&&(n.ground=[t.x,t.y,t.z])}moved(e){let t=this.mates.get(e.id);if(!t)return;let n=this.carrying(e.id);e.ev&o.RESPAWN&&n>=0&&this.dropAt(n,t.ground),e.ground&&(t.ground=[e.x,e.y,e.z])}drop(e){let t=this.carrying(e.id),n=this.mates.get(e.id);if(t<0||!n||this.over)return!1;let r=n.ground;if(e.ground)r=[e.x,e.y,e.z];else{let t=D(this.world,[e.x,e.y+.05,e.z],[0,-1,0],ct);t<ct&&(r=[e.x,e.y+.05-t,e.z])}return this.dropAt(t,r),this.lock[t]={id:e.id,left:120},this.hold[t]=120,!0}carrying(t){return this.flags.findIndex(n=>n.state===e.CARRIED&&n.by===t)}winner(){let[e,t]=this.score;return e>t?0:t>e?1:-1}tally(){return[...this.mates].map(([e,t])=>({id:e,caps:t.caps,returns:t.returns}))}reset(){this.over=!1,this.score=[0,0],this.flags=[K(),K()],this.back=[0,0],this.lock.forEach(e=>e.left=0),this.hold=[0,0],this.clock=this.rules.timeLimit*60;for(let e of this.mates.values())e.caps=e.returns=0}wire(){return{score:[...this.score],clock:Math.ceil(this.clock/60),over:this.over,flags:this.flags.map(e=>({...e}))}}tick(t){if(this.over)return--this.clock<=0?(this.reset(),`start`):void 0;for(let t of[0,1]){let n=this.flags[t];this.lock[t].left--,this.hold[t]--,n.state===e.DROPPED&&(n.left=Math.ceil(--this.back[t]/60),this.back[t]<=0&&(this.flags[t]=K()))}for(let n of[0,1]){let r=this.flags[n];if(r.state===e.CARRIED)continue;let i=r.state===e.HOME?this.world.def.teams[n].base:[r.x,r.y,r.z],a=t.filter(e=>ut(e.state,i)),o=r.state===e.DROPPED&&this.hold[n]<=0?a.find(e=>e.team===n):void 0,s=a.find(e=>e.team!==n&&(e.id!==this.lock[n].id||this.lock[n].left<=0));if(o){let e=this.mates.get(o.id);e&&e.returns++,this.flags[n]=K()}else s&&(this.flags[n]={...K(),state:e.CARRIED,by:s.id})}for(let n of t){let t=this.carrying(n.id);if(t>=0&&this.flags[n.team].state===e.HOME&&ut(n.state,this.world.def.teams[n.team].base)){this.score[n.team]++;let e=this.mates.get(n.id);e&&e.caps++,this.flags[t]=K()}}if(this.score.some(e=>e>=this.rules.scoreLimit)||--this.clock<=0)return this.over=!0,this.clock=600,`end`}dropAt(t,[n,r,i]){this.flags[t]={state:e.DROPPED,by:0,x:n,y:r,z:i,left:10},this.back[t]=600}},ut=(e,t)=>Math.hypot(e.x-t[0],e.z-t[2])<1.5&&e.y<t[1]+2.2&&e.y+1.8>t[1],dt=(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},ft=e=>{if(e.mode===i.GROUND){if(e.cut===n.LUNGE){let[t,n]=j(e.yaw);e.vx=t*13,e.vz=n*13,e.dash=60,e.ev|=o.DASH}else e.cut===n.LEAP&&(e.vy=ye,e.ev|=o.JUMP)}},q={NONE:0,SHOT:1,CUT:2},pt=(e,n,r,a,o=!0)=>{let s=e.down>0;if(nt(e,s?{...n,keys:0}:n,r,a),e.zap=!!e.stun&&!!e.zap,s)return e.down>0&&!--e.down&&Ne(e,r,a),q.NONE;let{rack:c,blade:l}=r.def.teams[a],u=!!c&&dt(e,c,1.2);o&&u&&!e.rack&&(e.ammo=60),e.rack=u,e.blade=!!e.blade||o&&!!l&&dt(e,l,1.2),e.cool=Math.max(0,e.cool-1),e.swing=Math.max(0,(e.swing??0)-1),e.wield=e.blade&&(e.swing>0||!!(n.keys&t.BLADE)||e.ammo<0);let d=e.mode===i.HANG||e.mode===i.CLIMB;if(!o)return e.charge=0,q.NONE;let f=C[e.cut??0];if(e.swing&&f.ticks-e.swing===f.strike)return q.CUT;if((e.wield||d||e.ammo<=0)&&(e.charge=0),n.keys&t.FIRE&&!d){let r=C[e.cut??0].ticks-e.swing,i=!!(n.keys&t.SPECIAL)&&(!e.swing||(e.cut??0)<4&&r<=18);e.wield&&(!e.swing||i)?(e.cut=it(n.keys)+(i?4:0),e.swing=C[e.cut].ticks,ft(e)):!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(mt(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},mt=e=>e<10?1:1+Math.floor(4*(e-10)/50),ht=-30,J=(e,t,n,r,i,a=s.CONCRETE)=>({min:[e,ht,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],gt=[.2,.46,1],_t=[1,.42,.08],vt=[.12,.7,.62],Q=(e,t,n,r,i,a,o)=>Y([e,t,n],[r,i,a],s.PAINT,s.PAINT,o),yt=(e,t,n,r,i,a,o,c=ht)=>{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)),bt=[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([29,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,vt),Y([14,18,147],[15,32,164],s.PAINT,s.PAINT,vt),Y([14,26,134],[15,32,147],s.PAINT,s.PAINT,vt),...$(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,ht,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,_t),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),...yt(0,76,52,226,232,14.5,26),...yt(0,85,76,196,202,14.5,19,14.5)],xt=[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,_t),...[[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)],St=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?gt:e.tint}),Ct=(e,t,n)=>[...[16,22,28,34,40].map(n=>[n,26,t,e]),...[19,31,43].map(t=>[t,26,n,e])],wt=[[20,26,190],[48,21.2,172],[48,19,200],[88,14.5,198]],Tt=[[21,26,168],[46,19,144],[36,21.2,178],[88,14.5,216],[88,14.5,172]],Et={name:`Highline`,brushes:[...bt,...bt.map(St),...xt],teams:[{base:[32,26,224],spawns:Ct(0,236,231),rack:[30.75,27.5,217],blade:[33.25,27.5,217]},{base:[32,26,16],spawns:Ct(Math.PI,4,9),rack:[30.75,27.5,23],blade:[33.25,27.5,23]}],packs:[...wt,...wt.map(([e,t,n])=>[e,t,X-n]),[24,15,112],[24,15,128]],ammo:[...Tt,...Tt.map(([e,t,n])=>[e,t,X-n])],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]},Dt=40/60,Ot=(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+Pe(e),z:e.z,dx:-n*a,dy:i,dz:-r*a,left:80,burst:!1,power:e.power??1}},kt=(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},At=(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=D(e,i,a,o,ve),c;for(let e of r){let t=kt(i,a,e,x+ve,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},jt=e=>e.mode===i.SLIDE||e.dash>50,Mt=(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),Nt=20,Pt=2,Ft=(e,t)=>Array.from(e).slice(0,t).join(``).trim(),It=e=>Ft((typeof e==`string`?e:``).replace(/\s+/g,` `).replace(/\p{Cc}/gu,``).trim(),16),Lt=(e,t)=>{let n=e;for(let r=2;t.includes(n);r++)n=`${Ft(e,15-`${r}`.length)} ${r}`;return n},Rt=(e,t)=>{let n=setInterval(e,t);return()=>clearInterval(n)},zt=class{peers=/* @__PURE__ */ new Map;ticks=0;history=[];world;ctf;halt;rules;rr=[0,0];gone;balls=[];constructor(e={},t=Et){this.rules={...Ce,...e},this.world=Ee(t),this.ctf=new lt(this.world,this.rules),this.gone=[...t.packs??[],...t.ammo??[]].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=te(t);n===null&&r?.t===`join`&&this.join(e,r.name);return}let r=n&&ee(t);if(r&&n.bank>0){n.bank--;let e=pt(n.state,r,this.world,n.info.team,!this.ctf.over);this.ctf.moved(n.state),this.tackle(n,r.view),e===q.SHOT?this.shoot(n,r.view):e===q.CUT&&this.cut(n,r.view),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,Dt);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=b({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|1<<n,0)>>>0,balls:this.balls});e.forEach(e=>e.conn.send(n)),this.balls=this.balls.filter(e=>!e.burst&&e.left>0)}}start(e=Rt){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<Nt;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||!jt(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=>Mt(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=Fe(n),[s,c]=o>.001?[n.vx/o,n.vz/o]:j(n.yaw);Ue(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}),this.ctf.drop(e.state),!0)}shoot(e,t=0){let n=Ot(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)*Dt);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=At(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=at(this.world,e.state,this.enemies(e,t)),r=this.players().filter(e=>n.some(t=>t.id===e.info.id));if(r.length){e.state.hits=e.state.hits+1&255;for(let t of r){let r=n.find(e=>e.id===t.info.id);if(this.harm(t,C[e.state.cut??0].hp))t.state.lost=st(e.state,r);else{let[n,i]=ot(e.state,r);Ue(t.state,n,i,24,4),t.state.zap=!0,t.by=e.info.id}}}}heal(e){let{packs:t=[],ammo:n=[]}=this.world.def;[...t,...n].forEach((n,r)=>{if(this.gone[r]>0){this.gone[r]--;return}let i=r<t.length,a=e.find(({state:e})=>!e.down&&(i?e.hp<5:e.ammo>=0&&e.ammo<60)&&dt(e,n,.9));if(a){let e=a.state;i?e.hp=Math.min(5,e.hp+2):e.ammo=Math.min(60,e.ammo+20),this.gone[r]=1200}})}place(e,t,n){let r=this.world.def.teams[t].spawns.findIndex((r,i)=>{let{x:a,z:o}=I(e,this.world,i,t);return!n.some(e=>Math.hypot(e.x-a,e.z-o)<Pt)});return I(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:Lt(It(t)||`Player ${r}`,n.map(e=>e.info.name)),team:a,color:_e[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})))}},Bt=(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()},Vt=(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&&b.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 zt(t),s.start(Bt),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 ee=e=>{p||(typeof e==`string`&&te(e)?.t===`join`&&(f=e),s?s.receive(g,e):u?m({kind:`m`,data:e}):d.push(e))},y=()=>{p||(p=!0,globalThis.removeEventListener?.(`pagehide`,y),s?(s.stop(),l()):(m({kind:`b`}),a.abort()),i.close(),setTimeout(()=>b.onclose?.()))},b={binaryType:`arraybuffer`,onopen:null,onclose:null,onmessage:null,send:ee,close:y};return o?o.request(n,{signal:a.signal},()=>new Promise(v)).catch(()=>{}):v(()=>{}),m({kind:`q`}),globalThis.addEventListener?.(`pagehide`,y),setTimeout(()=>!p&&b.onopen?.()),b};export{Vt as localSocket};
|
package/dist/server.js
CHANGED
|
@@ -145,7 +145,7 @@ var KEY = {
|
|
|
145
145
|
DASH: 64,
|
|
146
146
|
/** Hold to crouch, or to slide when fast. */
|
|
147
147
|
CROUCH: 128,
|
|
148
|
-
/** Hold to
|
|
148
|
+
/** Hold to charge the gun, let go to fire (see CHARGE_TICKS); with the katana in hand, a cut (see CUT). */
|
|
149
149
|
FIRE: 256,
|
|
150
150
|
/**
|
|
151
151
|
* Set while the player wants the katana in hand (the client's choice: 1, 2 or the wheel), clear
|
|
@@ -1410,8 +1410,10 @@ var STRIKE = {
|
|
|
1410
1410
|
* once and for good: it stays until he goes down.
|
|
1411
1411
|
* - In hand (`wield`) is the katana when he has it and wants it (KEY.BLADE) or has no gun, and
|
|
1412
1412
|
* it stays in hand for the length of a swing.
|
|
1413
|
-
* - The trigger: `cool` and `swing` run down, and at 0 a held FIRE
|
|
1413
|
+
* - The trigger: `cool` and `swing` run down, and at 0 a held FIRE charges the gun, with ammo, and
|
|
1414
|
+
* letting it go fires a ball as strong as the charge (powerOf()), spending as many shots; or it
|
|
1414
1415
|
* starts the katana's swing (`cut` from the keys), unless the hands are busy (a hang, a climb).
|
|
1416
|
+
* The katana in hand, busy hands or no shot left drop the charge.
|
|
1415
1417
|
* With SPECIAL (a double click) the swing is the cut's special; its press within SPECIAL_LATE
|
|
1416
1418
|
* ticks of a cut's start turns that cut into it. The cut strikes `CUTS[cut].strike` ticks into
|
|
1417
1419
|
* its swing. The look is the input's, so both go where the player sees.
|
|
@@ -1437,9 +1439,13 @@ var step = (p, i, w, team, armed = true) => {
|
|
|
1437
1439
|
p.swing = Math.max(0, (p.swing ?? 0) - 1);
|
|
1438
1440
|
p.wield = p.blade && (p.swing > 0 || !!(i.keys & KEY.BLADE) || p.ammo < 0);
|
|
1439
1441
|
const busy = p.mode === MODE.HANG || p.mode === MODE.CLIMB;
|
|
1440
|
-
if (!armed)
|
|
1442
|
+
if (!armed) {
|
|
1443
|
+
p.charge = 0;
|
|
1444
|
+
return STRIKE.NONE;
|
|
1445
|
+
}
|
|
1441
1446
|
const c = CUTS[p.cut ?? 0];
|
|
1442
1447
|
if (p.swing && c.ticks - p.swing === c.strike) return STRIKE.CUT;
|
|
1448
|
+
if (p.wield || busy || p.ammo <= 0) p.charge = 0;
|
|
1443
1449
|
if (i.keys & KEY.FIRE && !busy) {
|
|
1444
1450
|
const late = CUTS[p.cut ?? 0].ticks - p.swing;
|
|
1445
1451
|
const special = !!(i.keys & KEY.SPECIAL) && (!p.swing || (p.cut ?? 0) < 4 && late <= 18);
|
|
@@ -1447,15 +1453,19 @@ var step = (p, i, w, team, armed = true) => {
|
|
|
1447
1453
|
p.cut = cutOf(i.keys) + (special ? 4 : 0);
|
|
1448
1454
|
p.swing = CUTS[p.cut].ticks;
|
|
1449
1455
|
launch$1(p);
|
|
1450
|
-
} else if (!p.wield && !p.cool && p.ammo > 0)
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
+
} else if (!p.wield && !p.cool && p.ammo > 0) p.charge = Math.min((p.charge ?? 0) + 1, 60);
|
|
1457
|
+
} else if (p.charge) {
|
|
1458
|
+
p.power = Math.min(powerOf(p.charge), p.ammo);
|
|
1459
|
+
p.charge = 0;
|
|
1460
|
+
p.ammo -= p.power;
|
|
1461
|
+
p.shots = p.shots + 1 & 255;
|
|
1462
|
+
p.cool = 7;
|
|
1463
|
+
return STRIKE.SHOT;
|
|
1456
1464
|
}
|
|
1457
1465
|
return STRIKE.NONE;
|
|
1458
1466
|
};
|
|
1467
|
+
/** The strength a charge of `ticks` gives, 1 to CHARGE_MAX: 1 under CHARGE_TAP, CHARGE_MAX at CHARGE_TICKS. */
|
|
1468
|
+
var powerOf = (ticks) => ticks < 10 ? 1 : 1 + Math.floor(4 * (ticks - 10) / 50);
|
|
1459
1469
|
// src/shared/map.ts
|
|
1460
1470
|
/** The bottom of every building: far below the kill floor, so nothing shows beneath a roof. */
|
|
1461
1471
|
var BASE = -30;
|
|
@@ -2343,7 +2353,8 @@ var HIGHLINE = {
|
|
|
2343
2353
|
var PLASMA_STEP = 40 / 60;
|
|
2344
2354
|
/**
|
|
2345
2355
|
* The ball of the shot `p` has just fired (`p` is the state after the step that fired): from the
|
|
2346
|
-
* eye of the mode along the look, GUN_RANGE metres to go, named by his `shots` count
|
|
2356
|
+
* eye of the mode along the look, GUN_RANGE metres to go, named by his `shots` count, as strong
|
|
2357
|
+
* as the shot (`power`).
|
|
2347
2358
|
*/
|
|
2348
2359
|
var launch = (p, team = 0) => {
|
|
2349
2360
|
const [sy, cy, sp, cp] = [
|
|
@@ -2363,7 +2374,8 @@ var launch = (p, team = 0) => {
|
|
|
2363
2374
|
dy: sp,
|
|
2364
2375
|
dz: -cy * cp,
|
|
2365
2376
|
left: 80,
|
|
2366
|
-
burst: false
|
|
2377
|
+
burst: false,
|
|
2378
|
+
power: p.power ?? 1
|
|
2367
2379
|
};
|
|
2368
2380
|
};
|
|
2369
2381
|
/**
|
|
@@ -2449,15 +2461,15 @@ var decodeInput = (buf) => {
|
|
|
2449
2461
|
/** Bytes of a flag on the wire, by its state. */
|
|
2450
2462
|
var flagBytes = (state) => state === FLAG.CARRIED ? 2 : state === FLAG.DROPPED ? 8 : 1;
|
|
2451
2463
|
var encodeSnapshot = (s) => {
|
|
2452
|
-
const end = 4 +
|
|
2464
|
+
const end = 4 + 48 * s.players.length;
|
|
2453
2465
|
const balls = s.balls ?? [];
|
|
2454
2466
|
const tail = end + 8 + s.flags.reduce((n, f) => n + flagBytes(f.state), 0);
|
|
2455
|
-
const v = new DataView(new ArrayBuffer(tail + (balls.length && 1 +
|
|
2467
|
+
const v = new DataView(new ArrayBuffer(tail + (balls.length && 1 + 11 * balls.length)));
|
|
2456
2468
|
v.setUint8(0, 2);
|
|
2457
2469
|
v.setUint16(1, s.tick & 65535);
|
|
2458
2470
|
v.setUint8(3, s.players.length);
|
|
2459
2471
|
s.players.forEach((p, i) => {
|
|
2460
|
-
const o = 4 + i *
|
|
2472
|
+
const o = 4 + i * 48;
|
|
2461
2473
|
v.setUint8(o, p.id);
|
|
2462
2474
|
v.setFloat32(o + 1, p.x);
|
|
2463
2475
|
v.setFloat32(o + 5, p.y);
|
|
@@ -2481,6 +2493,7 @@ var encodeSnapshot = (s) => {
|
|
|
2481
2493
|
v.setUint8(o + 44, p.hits);
|
|
2482
2494
|
v.setUint8(o + 45, (p.swing ?? 0) & 63 | ((p.cut ?? 0) & 3) << 6);
|
|
2483
2495
|
v.setUint8(o + 46, (p.lost ?? 0) & 7 | ((p.cut ?? 0) & 4) << 1);
|
|
2496
|
+
v.setUint8(o + 47, p.charge ?? 0);
|
|
2484
2497
|
});
|
|
2485
2498
|
v.setUint8(end, s.score[0]);
|
|
2486
2499
|
v.setUint8(end + 1, s.score[1]);
|
|
@@ -2509,7 +2522,8 @@ var encodeSnapshot = (s) => {
|
|
|
2509
2522
|
].forEach((c, k) => v.setInt16(o + 2 + 2 * k, clamp16(c * BALL_POS)));
|
|
2510
2523
|
v.setUint8(o + 8, Math.round(Math.atan2(-b.dx, -b.dz) * YAW8) & 255);
|
|
2511
2524
|
v.setInt8(o + 9, Math.round(Math.asin(Math.max(-1, Math.min(1, b.dy))) * PITCH8));
|
|
2512
|
-
o
|
|
2525
|
+
v.setUint8(o + 10, b.power ?? 1);
|
|
2526
|
+
o += 11;
|
|
2513
2527
|
}
|
|
2514
2528
|
return v.buffer;
|
|
2515
2529
|
};
|
|
@@ -2776,6 +2790,7 @@ var Room = class {
|
|
|
2776
2790
|
down: 120,
|
|
2777
2791
|
ammo: -1,
|
|
2778
2792
|
cool: 0,
|
|
2793
|
+
charge: 0,
|
|
2779
2794
|
blade: false,
|
|
2780
2795
|
wield: false,
|
|
2781
2796
|
swing: 0,
|
|
@@ -2797,7 +2812,7 @@ var Room = class {
|
|
|
2797
2812
|
const live = this.balls.filter((q) => !q.burst);
|
|
2798
2813
|
if (live.length > 64) live[0].burst = true;
|
|
2799
2814
|
}
|
|
2800
|
-
/** Flies the ball `b` on by `m` metres: one that bursts on an enemy who is up takes
|
|
2815
|
+
/** Flies the ball `b` on by `m` metres: one that bursts on an enemy who is up takes its power in hp from him, and counts a hit to its shooter. */
|
|
2801
2816
|
fly(b, m) {
|
|
2802
2817
|
const peers = this.players();
|
|
2803
2818
|
const foes = peers.filter((q) => q.info.team !== b.team && !q.state.down);
|
|
@@ -2806,7 +2821,7 @@ var Room = class {
|
|
|
2806
2821
|
if (!foe) return;
|
|
2807
2822
|
const by = peers.find((q) => q.info.id === b.by);
|
|
2808
2823
|
if (by) by.state.hits = by.state.hits + 1 & 255;
|
|
2809
|
-
this.harm(foe, 1);
|
|
2824
|
+
this.harm(foe, b.power ?? 1);
|
|
2810
2825
|
}
|
|
2811
2826
|
/**
|
|
2812
2827
|
* A cut of `p` struck at the view tick `view`: every enemy it reaches as `p` drew him is hit
|
|
@@ -23,13 +23,15 @@ export declare const grip: (pos: Vec3, q: Quat) => Vec3;
|
|
|
23
23
|
* The ammo as two glowing seven-segment digits on a dark screen set in the back of a small block
|
|
24
24
|
* on top of the body, in model space: cyan, red at 10 or fewer, thick segments that bloom only a
|
|
25
25
|
* little. The block is part of the readout, so only a gun that shows the ammo carries it. 99 at most.
|
|
26
|
+
* While the gun charges, a gauge of CHARGE_MAX cells under the digits lights `level` of them, the
|
|
27
|
+
* strength the shot would have; all orange at the full charge.
|
|
26
28
|
*/
|
|
27
|
-
export declare const readout: (ammo: number) => number[];
|
|
29
|
+
export declare const readout: (ammo: number, level?: number) => number[];
|
|
28
30
|
/**
|
|
29
31
|
* Appends the gun held in the hand at `pos` with the world rotation `q`, `k` times its size about
|
|
30
|
-
* the grip, with the ammo on its back when given
|
|
32
|
+
* the grip, with the ammo on its back when given, and the charge gauge at `level`.
|
|
31
33
|
*/
|
|
32
|
-
export declare const held: (out: number[], pos: Vec3, q: Quat, lod: number, k?: number, ammo?: number) => void;
|
|
34
|
+
export declare const held: (out: number[], pos: Vec3, q: Quat, lod: number, k?: number, ammo?: number, level?: number) => void;
|
|
33
35
|
/** The muzzle of a gun whose grip is at `at` and whose axes are [right, up, forward]. */
|
|
34
36
|
export declare const tip: (at: Vec3, [, u, f]: Vec3[]) => Vec3;
|
|
35
37
|
/**
|
|
@@ -171,6 +171,15 @@ export declare const HP_MAX = 5;
|
|
|
171
171
|
export declare const AMMO_MAX = 60;
|
|
172
172
|
/** Ticks between two shots while the trigger is held: 8.6 shots a second. */
|
|
173
173
|
export declare const GUN_COOLDOWN = 7;
|
|
174
|
+
/**
|
|
175
|
+
* The charged shot (the user, 2026-11-07): FIRE held with the gun charges it, and letting go fires
|
|
176
|
+
* one ball. Let go before CHARGE_TAP ticks it is a plain shot; held on, it grows to CHARGE_MAX
|
|
177
|
+
* shots' worth at CHARGE_TICKS (1 s), spends that many and takes that much health, so a full one
|
|
178
|
+
* (HP_MAX) puts any foe down. The charge holds at the top until let go. u8 on the wire.
|
|
179
|
+
*/
|
|
180
|
+
export declare const CHARGE_TAP = 10;
|
|
181
|
+
export declare const CHARGE_TICKS = 60;
|
|
182
|
+
export declare const CHARGE_MAX = 5;
|
|
174
183
|
/** Metres a shot reaches: a plasma ball that has flown this far is gone. */
|
|
175
184
|
export declare const GUN_RANGE = 80;
|
|
176
185
|
/**
|
|
@@ -19,12 +19,16 @@ export type Strike = (typeof STRIKE)[keyof typeof STRIKE];
|
|
|
19
19
|
* once and for good: it stays until he goes down.
|
|
20
20
|
* - In hand (`wield`) is the katana when he has it and wants it (KEY.BLADE) or has no gun, and
|
|
21
21
|
* it stays in hand for the length of a swing.
|
|
22
|
-
* - The trigger: `cool` and `swing` run down, and at 0 a held FIRE
|
|
22
|
+
* - The trigger: `cool` and `swing` run down, and at 0 a held FIRE charges the gun, with ammo, and
|
|
23
|
+
* letting it go fires a ball as strong as the charge (powerOf()), spending as many shots; or it
|
|
23
24
|
* starts the katana's swing (`cut` from the keys), unless the hands are busy (a hang, a climb).
|
|
25
|
+
* The katana in hand, busy hands or no shot left drop the charge.
|
|
24
26
|
* With SPECIAL (a double click) the swing is the cut's special; its press within SPECIAL_LATE
|
|
25
27
|
* ticks of a cut's start turns that cut into it. The cut strikes `CUTS[cut].strike` ticks into
|
|
26
28
|
* its swing. The look is the input's, so both go where the player sees.
|
|
27
29
|
* `armed` is false while the match is over: no weapon, no rack.
|
|
28
30
|
*/
|
|
29
31
|
export declare const step: (p: PlayerState, i: Input, w: World, team: number, armed?: boolean) => Strike;
|
|
32
|
+
/** The strength a charge of `ticks` gives, 1 to CHARGE_MAX: 1 under CHARGE_TAP, CHARGE_MAX at CHARGE_TICKS. */
|
|
33
|
+
export declare const powerOf: (ticks: number) => number;
|
|
30
34
|
export {};
|
|
@@ -12,7 +12,8 @@ export interface Flying extends Ball {
|
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* The ball of the shot `p` has just fired (`p` is the state after the step that fired): from the
|
|
15
|
-
* eye of the mode along the look, GUN_RANGE metres to go, named by his `shots` count
|
|
15
|
+
* eye of the mode along the look, GUN_RANGE metres to go, named by his `shots` count, as strong
|
|
16
|
+
* as the shot (`power`).
|
|
16
17
|
*/
|
|
17
18
|
export declare const launch: (p: PlayerState, team?: number) => Flying;
|
|
18
19
|
/**
|
|
@@ -28,11 +28,11 @@ 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 = 48;
|
|
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 = 8;
|
|
34
34
|
/** Bytes of a plasma ball. */
|
|
35
|
-
export declare const SNAP_BALL =
|
|
35
|
+
export declare const SNAP_BALL = 11;
|
|
36
36
|
/**
|
|
37
37
|
* The input as the host will read it after encodeInput and decodeInput: yaw, pitch and view
|
|
38
38
|
* rounded to the wire (an absent view stays absent here, and reads 0 on the host). The client
|
|
@@ -90,7 +90,7 @@ export declare class Room {
|
|
|
90
90
|
* now. Past PLASMA_MAX balls in flight, the oldest bursts.
|
|
91
91
|
*/
|
|
92
92
|
private shoot;
|
|
93
|
-
/** Flies the ball `b` on by `m` metres: one that bursts on an enemy who is up takes
|
|
93
|
+
/** Flies the ball `b` on by `m` metres: one that bursts on an enemy who is up takes its power in hp from him, and counts a hit to its shooter. */
|
|
94
94
|
private fly;
|
|
95
95
|
/**
|
|
96
96
|
* A cut of `p` struck at the view tick `view`: every enemy it reaches as `p` drew him is hit
|
|
@@ -30,7 +30,7 @@ export declare const KEY: {
|
|
|
30
30
|
readonly DASH: 64;
|
|
31
31
|
/** Hold to crouch, or to slide when fast. */
|
|
32
32
|
readonly CROUCH: 128;
|
|
33
|
-
/** Hold to
|
|
33
|
+
/** Hold to charge the gun, let go to fire (see CHARGE_TICKS); with the katana in hand, a cut (see CUT). */
|
|
34
34
|
readonly FIRE: 256;
|
|
35
35
|
/**
|
|
36
36
|
* Set while the player wants the katana in hand (the client's choice: 1, 2 or the wheel), clear
|
|
@@ -181,6 +181,10 @@ export interface PlayerState {
|
|
|
181
181
|
ammo: number;
|
|
182
182
|
/** Ticks to the next shot. */
|
|
183
183
|
cool: number;
|
|
184
|
+
/** Ticks FIRE has been held with the gun, up to CHARGE_TICKS, 0 when not charging. Absent reads 0. */
|
|
185
|
+
charge?: number;
|
|
186
|
+
/** 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. */
|
|
187
|
+
power?: number;
|
|
184
188
|
/** Standing inside the circle of the team's rack as of the last step: the gun is filled on arrival only. Absent reads false. */
|
|
185
189
|
rack?: boolean;
|
|
186
190
|
/** Ticks left lying down after the health ran out; at 0 the player is back at a spawn. 0 when up. */
|
|
@@ -249,6 +253,8 @@ export interface Ball {
|
|
|
249
253
|
dz: number;
|
|
250
254
|
/** It burst where it is: the last snapshot that carries it. */
|
|
251
255
|
burst: boolean;
|
|
256
|
+
/** Its strength, 1 to CHARGE_MAX: the health it takes. Absent reads 1. */
|
|
257
|
+
power?: number;
|
|
252
258
|
}
|
|
253
259
|
/** The flag of a team as a snapshot carries it: only the fields of its state are meaningful, the rest read 0. */
|
|
254
260
|
export interface FlagState {
|
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.38.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|