yolkbot 1.4.3 → 1.4.4
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/browser/build/global.js +1 -1
- package/browser/build/module.js +1 -1
- package/dist/bot.js +1 -1
- package/package.json +2 -2
package/browser/build/global.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Ue=Object.defineProperty;var it=(t,e)=>{for(var s in e)Ue(t,s,{get:e[s],enumerable:!0,configurable:!0,set:(i)=>e[s]=()=>i})};var We=globalThis.fetch,Rt=We;console.error("wwws does not support the browser.");var Gt=null;var W={},Z=typeof window<"u"&&typeof HTMLElement<"u",ot=typeof WebSocketPair<"u"&&typeof Cloudflare<"u",Ot=typeof process<"u"&&process.moduleLoadList?.length>0,_t=typeof Deno<"u",vt=typeof process<"u"&&!!process.versions?.bun;if(!Z&&!ot&&!Ot&&!_t&&!vt)throw Error("yolkbot doesn't know how to run in this environment. Please open an issue on GitHub with information on where you run yolkbot.");W.isBrowser=Z;W.isIsolated=!Ot&&!_t&&!vt;W.fetch=Z||ot?globalThis.fetch:Rt;W.WebSocket=Z||ot?globalThis.WebSocket:Gt;var w=W;var kt={};it(kt,{findItemById:()=>l,UserAgent:()=>$,URLRewards:()=>He,Team:()=>Ke,StateBufferSize:()=>j,SocialReward:()=>Je,SocialMedia:()=>wt,ShellStreak:()=>g,PlayType:()=>I,Movement:()=>S,ItemType:()=>P,GunList:()=>_,GunEquipTime:()=>xt,GameOptionFlag:()=>gt,GameMode:()=>M,GameAction:()=>L,FramesBetweenSyncs:()=>C,FirebaseKey:()=>O,CoopState:()=>X,CollectType:()=>Q,ChiknWinnerDailyLimit:()=>lt,ChatFlag:()=>Be,ChallengeType:()=>$e,ChallengeSubType:()=>je,BanDuration:()=>dt});var pt={};it(pt,{SMG:()=>ut,RPEGG:()=>at,M24:()=>ft,Eggk47:()=>nt,DozenGauge:()=>rt,Cluck9mm:()=>ht,CSG1:()=>ct,AUG:()=>mt});var R=class{constructor(){this.adsMod=0.5,this.burst=0,this.burstRof=0,this.movementAccuracyMod=1,this.radius=0,this.reloadBloom=!0,this.reloadTimeMod=1,this.tracer=0}},nt=class extends R{constructor(){super();this.ammo={rounds:30,capacity:30,reload:30,store:240,storeMax:240,pickup:30},this.longReloadTime=205,this.shortReloadTime=160,this.weaponName="EggK-47",this.internalName="Eggk47",this.standardMeshName="eggk47",this.automatic=!0,this.damage=30,this.range=20,this.recoil=7,this.rof=3,this.totalDamage=30,this.velocity=1.5,this.accuracyMin=0.15,this.accuracyMax=0.03,this.accuracyLoss=0.05,this.accuracyRecover=0.025,this.tracer=1}},rt=class extends R{constructor(){super();this.ammo={rounds:2,capacity:2,reload:2,store:24,storeMax:24,pickup:8},this.longReloadTime=155,this.shortReloadTime=155,this.weaponName="Scrambler",this.internalName="Dozen Gauge",this.standardMeshName="dozenGauge",this.automatic=!1,this.damage=8.5,this.range=8,this.recoil=10,this.rof=8,this.totalDamage=170,this.velocity=1,this.accuracyMin=0.16,this.accuracyMax=0.13,this.accuracyLoss=0.17,this.accuracyRecover=0.02,this.adsMod=0.6,this.movementAccuracyMod=0.2,this.tracer=0}},ct=class extends R{constructor(){super();this.ammo={rounds:15,capacity:15,reload:15,store:60,storeMax:60,pickup:15},this.longReloadTime=225,this.shortReloadTime=165,this.weaponName="Free Ranger",this.internalName="CSG-1",this.standardMeshName="csg1",this.automatic=!1,this.damage=105,this.range=50,this.recoil=13,this.rof=13,this.totalDamage=105,this.velocity=1.75,this.accuracyMin=0.3,this.accuracyMax=0.004,this.accuracyLoss=0.3,this.accuracyRecover=0.025,this.tracer=0}},ht=class extends R{constructor(){super();this.ammo={rounds:15,capacity:15,reload:15,store:60,storeMax:60,pickup:15},this.longReloadTime=195,this.shortReloadTime=160,this.weaponName="Cluck 9mm",this.internalName="Cluck 9mm",this.standardMeshName="cluck9mm",this.automatic=!1,this.damage=26,this.range=15,this.recoil=6,this.rof=4,this.totalDamage=26,this.velocity=1,this.accuracyMin=0.15,this.accuracyMax=0.035,this.accuracyLoss=0.09,this.accuracyRecover=0.08,this.adsMod=0.8,this.movementAccuracyMod=0.6,this.tracer=0}},at=class extends R{constructor(){super();this.ammo={rounds:1,capacity:1,reload:1,store:3,storeMax:3,pickup:1},this.longReloadTime=170,this.shortReloadTime=170,this.weaponName="RPEGG",this.internalName="Eggsploder",this.standardMeshName="rpegg",this.automatic=!1,this.damage=140,this.range=45,this.recoil=60,this.rof=40,this.totalDamage=192.5,this.velocity=0.4,this.accuracyMin=0.3,this.accuracyMax=0.015,this.accuracyLoss=0.3,this.accuracyRecover=0.02,this.radius=2.75}},ut=class extends R{constructor(){super();this.ammo={rounds:40,capacity:40,reload:40,store:200,storeMax:200,pickup:40},this.longReloadTime=225,this.shortReloadTime=190,this.weaponName="Whipper",this.internalName="SMEGG",this.standardMeshName="smg",this.automatic=!0,this.damage=23,this.range=20,this.recoil=7,this.rof=2,this.totalDamage=23,this.velocity=1.25,this.accuracyMin=0.19,this.accuracyMax=0.06,this.accuracyLoss=0.045,this.accuracyRecover=0.05,this.adsMod=0.6,this.movementAccuracyMod=0.7,this.tracer=2}},ft=class extends R{constructor(){super();this.ammo={rounds:1,capacity:1,reload:1,store:12,storeMax:12,pickup:4},this.longReloadTime=144,this.shortReloadTime=144,this.weaponName="Crackshot",this.internalName="M2DZ",this.standardMeshName="m24",this.automatic=!0,this.damage=170,this.range=60,this.recoil=20,this.rof=15,this.totalDamage=170,this.velocity=2,this.accuracyMin=0.35,this.accuracyMax=0,this.accuracyLoss=0.1,this.accuracyRecover=0.023,this.movementAccuracyMod=1.3,this.reloadBloom=!1,this.reloadTimeMod=0.8,this.tracer=0}},mt=class extends R{constructor(){super();this.ammo={rounds:24,capacity:24,reload:24,store:150,storeMax:150,pickup:24},this.longReloadTime=205,this.shortReloadTime=160,this.weaponName="Tri-Hard",this.internalName="AUG",this.standardMeshName="aug",this.automatic=!1,this.damage=32,this.range=20,this.recoil=18,this.rof=15,this.totalDamage=34,this.velocity=1.5,this.accuracyMin=0.15,this.accuracyMax=0.03,this.accuracyLoss=0.037,this.accuracyRecover=0.03,this.adsMod=0.6,this.burst=3,this.burstRof=3,this.movementAccuracyMod=0.8,this.movementInstability=2,this.tracer=0}};var l=()=>null;var dt={FiveMinutes:0,FifteenMinutes:1,OneHour:2},je={Killstreak:0,KillWithWeapon:1,MovementDistance:3,Jumping:4,TimePlayed:6,TimeAlive:7,KillWithCondition:8,TotalKills:10,SpatulaKills:10,Collecting:18,FromTheCoop:20,SpecialOffensive:21,WinKOTC:23,KillWithSpatula:23},$e={Kill:0,Damage:1,Death:2,Movement:3,Collect:4,Time:5,KOTC:6,Spatula:7},Be={None:0,Pinned:2,Team:4,Mod:254,Server:255},lt=3,Q={Ammo:0,Grenade:1},X={Start:0,Score:1,Win:2,Capturing:3,Contested:4,Takeover:5,Abandoned:6,Unclaimed:7},O="AIzaSyDP4SIjKaw6A4c-zvfYxICpbEjn1rRnN50",C=3,L={Reset:1,Pause:2},M={FFA:0,Team:1,Spatula:2,KOTC:3},gt={Locked:1,NoTeamChange:2,NoTeamShuffle:4},xt=13,_=[nt,rt,ct,at,ut,ft,mt],P={Hat:1,Stamp:2,Primary:3,Secondary:4,Grenade:6,Melee:7},S={Forward:1,Backward:2,Left:4,Right:8,Jump:16,Fire:32,Melee:64,Scope:128},I={JoinPublic:0,CreatePrivate:1,JoinPrivate:2},g={HardBoiled:1,EggBreaker:2,Restock:4,OverHeal:8,DoubleEggs:16,MiniEgg:32},wt={Facebook:0,Instagram:1,Tiktok:2,Discord:3,Youtube:4,Twitter:5,Twitch:6},Je={Discord:"rew_1200",Tiktok:"rew_1208",Instagram:"rew_1219",Steam:"rew_1223",Facebook:"rew_1227",Twitter:"rew_1234",Twitch:"rew_twitch_social"},j=256,Ke={Blue:1,Red:2},He=["giveBasketBrosReward","mercZoneFinalGift","midMonthGiveMeEggs","newYolkerSignupReward","newYolkerItemReward","newYolkerWelcomeBack","WelcomeBack"],$=w.isBrowser?null:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36";class At{url="";proxy="";binaryType="";maxRetries=5;connectionTimeout=5000;constructor(t,e){if(w.isBrowser&&e)throw Error("You cannot pass a proxy to a WebSocket in a browser.");this.url=t,this.proxy=e}async tryConnect(t=1){let e=new URL(this.url),s=async()=>{if(t===5)return!1;return await this.tryConnect(t+1)};try{if(this.socket=w.isBrowser?new w.WebSocket(this.url):new w.WebSocket(this.url,{proxy:this.proxy||null,headers:{"accept-encoding":"gzip, deflate, br, zstd","accept-language":"en-US,en;q=0.9","cache-control":"no-cache",connection:"Upgrade",origin:e.origin.replace("ws","http"),pragma:"no-cache","sec-websocket-extensions":"permessage-deflate; client_max_window_bits","user-agent":$}}),this.binaryType)this.socket.binaryType=this.binaryType}catch(i){return console.error(`Failed to connect on try ${t}, trying again...`,i),await s()}if(this.onBeforeConnect)this.onBeforeConnect();return new Promise((i)=>{let n=setTimeout(async()=>{this.socket.close(),i(await s())},this.connectionTimeout),r=async(c)=>{clearTimeout(n),console.error("WebSocket error",c),i(await s())};this.socket.addEventListener("open",async()=>{clearTimeout(n),this.socket.removeEventListener("error",r),i(!0)}),this.socket.addEventListener("error",r)})}get onmessage(){return this.socket?.onmessage}set onmessage(t){if(this.socket)this.socket.onmessage=t;else console.error("set onmessage before socket existed")}get onclose(){return this.socket?.onclose}set onclose(t){if(this.socket)this.socket.onclose=t;else console.error("set onclose before socket existed")}get onerror(){return this.socket?.onerror}set onerror(t){if(this.socket)this.socket.onerror=t;else console.error("set onclose before socket existed")}send(t){return this.socket?.send(t)}close(t){return this.socket?.close(t)}}var F=At;var B={origin:"https://shellshock.io","user-agent":$,"x-client-version":"Chrome/JsCore/9.17.2/FirebaseCore-web","x-firebase-locale":"en"};class D{constructor(t={}){this.proxy=t.proxy,this.instance=t.instance||"shellshock.io",this.protocol=t.protocol||"wss",this.maxRetries=t.maxRetries||5,this.suppressErrors=t.suppressErrors||!1,this.connectionTimeout=t.connectionTimeout||5000}queryServices=async(t)=>{let e=new F(`${this.protocol}://${this.instance}/services/`,this.proxy);if(e.connectionTimeout=this.connectionTimeout,!await e.tryConnect(-2)||e.socket.readyState!==1)return"websocket_connect_fail";return new Promise((i)=>{let n=!1;e.onmessage=(r)=>{n=!0;try{let c=JSON.parse(r.data);i(c)}catch{if(!this.suppressErrors)console.error("queryServices: Bad API JSON response with call:",t.cmd,"and data:",JSON.stringify(t)),console.error("queryServices: Full data sent:",JSON.stringify(t));i("bad_json")}e.close()},e.onerror=()=>!n&&i("unknown_socket_error"),e.onclose=()=>!n&&i("services_closed_early"),e.send(JSON.stringify(t))})};#t=async(t,e,s)=>{if(!t||!e)return"firebase_no_credentials";let i,n;try{i=await(await w.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:${s}?key=${O}`,{method:"POST",body:JSON.stringify({email:t,password:e,returnSecureToken:!0}),headers:{...B,"content-type":"application/json"},proxy:this.proxy})).json(),n=i.idToken}catch(c){if(c.code==="auth/network-request-failed"){if(!this.suppressErrors)console.error("loginWithCredentials: Network req failed (auth/network-request-failed)");return"firebase_network_failed"}else if(c.code==="auth/missing-email")return"firebase_no_credentials";else if(c.code==="ERR_BAD_REQUEST"){if(!this.suppressErrors)console.error("loginWithCredentials: Error:",t,e);if(!this.suppressErrors)console.error("loginWithCredentials: Error:",i||c);return"firebase_bad_request"}if(!this.suppressErrors)console.error("loginWithCredentials: Error:",t,e,c);return"firebase_unknown_error"}if(!n){if(!this.suppressErrors)console.error("loginWithCredentials: the game sent no idToken",i);return"firebase_no_token"}this.idToken=n;let r=await this.queryServices({cmd:"auth",firebaseToken:n});return typeof r==="object"?{firebase:i,...r}:r};createAccount=async(t,e)=>await this.#t(t,e,"signUp");loginWithCredentials=async(t,e)=>await this.#t(t,e,"signInWithPassword");loginWithRefreshToken=async(t)=>{if(!t)return"firebase_no_credentials";let e=new URLSearchParams;e.append("grant_type","refresh_token"),e.append("refresh_token",t);let s,i;try{s=await(await w.fetch(`https://securetoken.googleapis.com/v1/token?key=${O}`,{method:"POST",body:e,headers:{...B,"content-type":"application/x-www-form-urlencoded"},proxy:this.proxy})).json(),i=s.id_token}catch(r){if(r.code==="auth/network-request-failed"){if(!this.suppressErrors)console.error("loginWithRefreshToken: Network req failed (auth/network-request-failed)");return"firebase_network_failed"}else if(r.code==="auth/missing-email")return"firebase_no_credentials";if(!this.suppressErrors)console.error("loginWithRefreshToken: Error:",r,t);return"firebase_unknown_error"}if(!i){if(!this.suppressErrors)console.error("loginWithRefreshToken: the game sent no idToken",s);return"firebase_no_token"}this.idToken=i;let n=await this.queryServices({cmd:"auth",firebaseToken:i});return typeof n==="object"?{firebase:s,...n}:n};loginAnonymously=async()=>{let e=await(await w.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=${O}`,{method:"POST",body:JSON.stringify({returnSecureToken:!0}),headers:{...B,"content-type":"application/json"},proxy:this.proxy})).json(),s=e.idToken;if(!s){if(!this.suppressErrors)console.error("loginAnonymously: the game sent no idToken",e);return"firebase_no_token"}this.idToken=s;let i=await this.queryServices({cmd:"auth",firebaseToken:s});return typeof i==="object"?{firebase:e,...i}:i};sendEmailVerification=async(t=this.idToken)=>{if(!t)return"no_idtoken_passed";let s=await(await w.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode?key=${O}`,{method:"POST",body:JSON.stringify({requestType:"VERIFY_EMAIL",idToken:t}),headers:{...B,"content-type":"application/json"},proxy:this.proxy})).json();if(s.kind!=="identitytoolkit#GetOobConfirmationCodeResponse"){if(!this.suppressErrors)console.error("sendEmailVerification: the game sent an invalid response",s);return"firebase_invalid_response"}return{email:s.email}};verifyOobCode=async(t)=>{if(!t)return"no_oob_code_passed";let s=await(await w.fetch(`https://www.googleapis.com/identitytoolkit/v3/relyingparty/setAccountInfo?key=${O}`,{method:"POST",body:JSON.stringify({oobCode:t}),headers:{...B,"x-client-version":"Chrome/JsCore/3.7.5/FirebaseCore-web",referer:"https://shellshockio-181719.firebaseapp.com/","content-type":"application/json"},proxy:this.proxy})).json();if(!s.emailVerified){if(!this.suppressErrors)console.error("verifyOobCode: the game sent an invalid response",s);return"firebase_invalid_response"}return s.email}}var V=D;class Ct{static buffer;static idx;static init(t){this.buffer=new Uint8Array(t),this.idx=0}static isMoreDataAvailable(){return Math.max(0,this.buffer.length-this.idx)}static unPackInt8U(){let t=this.idx;return this.idx++,this.buffer[t]}static unPackInt8(){return(this.unPackInt8U()+128)%256-128}static unPackInt16U(){let t=this.idx;return this.idx+=2,this.buffer[t]+this.buffer[t+1]*256}static unPackInt24U(){let t=this.idx;return this.idx+=3,this.buffer[t]+this.buffer[t+1]*256+this.buffer[t+2]*65536}static unPackInt32U(){let t=this.idx;return this.idx+=4,this.buffer[t]+this.buffer[t+1]*256+this.buffer[t+2]*65536+this.buffer[t+3]*16777216}static unPackInt16(){return(this.unPackInt16U()+32768)%65536-32768}static unPackInt32(){return(this.unPackInt32U()+2147483648)%4294967296-2147483648}static unPackRadU(){return this.unPackInt24U()/2097152}static unPackRad(){return this.unPackInt16U()/8192-Math.PI}static unPackFloat(){return this.unPackInt16()/256}static unPackDouble(){return this.unPackInt32()/1048576}static unPackString(t){t=t||255;let e=Math.min(this.unPackInt8U(),t);return this.unPackStringHelper(e)}static unPackLongString(t){t=t||16383;let e=Math.min(this.unPackInt16U(),t);return this.unPackStringHelper(e)}static unPackStringHelper(t){if(this.isMoreDataAvailable()<t)return 0;let s="";for(let i=0;i<t;i++){let n=this.unPackInt16U();if(n>0)s+=String.fromCodePoint(n)}return s}}var o=Ct;class Lt{constructor(t=16384){this.idx=0,this.arrayBuffer=new ArrayBuffer(t),this.buffer=new Uint8Array(this.arrayBuffer,0,t)}send(t){let e=new Uint8Array(this.arrayBuffer,0,this.idx);t.send(e)}packInt8(t){this.buffer[this.idx]=t&255,this.idx++}packInt16(t){this.buffer[this.idx]=t&255,this.buffer[this.idx+1]=t>>8&255,this.idx+=2}packInt24(t){this.buffer[this.idx]=t&255,this.buffer[this.idx+1]=t>>8&255,this.buffer[this.idx+2]=t>>16&255,this.idx+=3}packInt32(t){this.buffer[this.idx]=t&255,this.buffer[this.idx+1]=t>>8&255,this.buffer[this.idx+2]=t>>16&255,this.buffer[this.idx+3]=t>>24&255,this.idx+=4}packRadU(t){this.packInt24(t*2097152)}packRad(t){this.packInt16((t+Math.PI)*8192)}packFloat(t){this.packInt16(t*256)}packDouble(t){this.packInt32(t*1048576)}packString(t){if(typeof t!=="string")t="";this.packInt8(t.length);for(let e=0;e<t.length;e++)this.packInt16(t.charCodeAt(e))}packLongString(t){if(typeof t!=="string")t="";this.packInt16(t.length);for(let e=0;e<t.length;e++)this.packInt16(t.charCodeAt(e))}}var p=Lt;var Ye={gameNotFound:4000,gameFull:4001,badName:4002,mainMenu:4003,gameIdleExceeded:4004,corruptedLoginData0:4005,corruptedLoginData1:4006,corruptedLoginData2:4007,corruptedLoginData3:4008,corruptedLoginData4:4009,corruptedLoginData5:4010,gameMaxPlayersExceeded:4011,gameDestroyUser:4012,joinGameOutOfOrder:4013,gameShuttingDown:4014,readyBeforeReady:4015,booted:4016,gameErrorOnUserSocket:4017,uuidNotFound:4018,sessionNotFound:4019,clusterFullCpu:4020,clusterFullMem:4021,noClustersAvailable:4022,locked:4023},b=Ye;var Ze={},a=Ze;var Qe=Object.fromEntries(Object.entries(wt).map(([t,e])=>[e,t.toLowerCase()]));class tt{constructor(t,e=null){if(this.id=t.id,this.uniqueId=t.uniqueId,this.name=t.name,this.safeName=t.safeName,this.team=t.team,this.playing=t.playing,this.socials=t.social&&JSON.parse(t.social),this.socials)this.socials.forEach((s)=>s.type=Qe[s.id]);if(this.isVip=t.upgradeProductId>0,this.showBadge=!t.hideBadge||!1,this.streak=t.score,this.streakRewards=Object.values(g).filter((s)=>t.activeShellStreaks&s),this.scale=this.streakRewards.includes(g.MiniEgg)?0.5:1,this.position={x:t.x,y:t.y,z:t.z},this.jumping=t.$controlKeys&S.Jump,this.scoping=t.$controlKeys&S.Scope,this.climbing=!1,this.view={yaw:t.yaw,pitch:t.pitch},this.updateKotcZone(e),this.character={eggColor:t.shellColor,primaryGun:t.primaryWeaponItem,secondaryGun:t.secondaryWeaponItem,stamp:t.stampItem,hat:t.hatItem,grenade:t.grenadeItem,melee:t.meleeItem,stampPos:{x:t.stampPosX,y:t.stampPosY}},this.stats={totalKills:t.totalKills,totalDeaths:t.totalDeaths,bestStreak:t.bestStreak},this.activeGun=t.weaponIdx,this.selectedGun=t.charClass,this.weapons=[],this.character.primaryGun)this.weapons[0]=new _[this.selectedGun],this.weapons[1]=new ht;this.grenades=1,this.hp=t.hp,this.hpShield=0,this.spawnShield=t.shield,this.randomSeed=0}updateKotcZone(t){if(!t)return this.inKotcZone=!1;let e=Math.floor(this.position.x),s=Math.floor(this.position.y),i=Math.floor(this.position.z);this.inKotcZone=t.some((n)=>n.x===e&&n.y===s&&n.z===i)&&this.playing}}var et=tt;var Xe=(t)=>new Uint8Array(t.match(/.{2}/g).map((e)=>parseInt(e,16))),Ie=new TextEncoder,Ft=async(t)=>{if(typeof process<"u"&&typeof process.getBuiltinModule==="function"){let n=process.getBuiltinModule("node:crypto"),r=Buffer.from("3496afb51f42553e31635211400c000b","hex");return n.createHmac("sha256",r).update(t).digest("hex")}let e=Xe("3496afb51f42553e31635211400c000b"),s=await crypto.subtle.importKey("raw",e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),i=await crypto.subtle.sign("HMAC",s,Ie.encode(t));return Array.from(new Uint8Array(i)).map((n)=>n.toString(16).padStart(2,"0")).join("")},G=(t)=>{return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(t-1050359)},qt=(t,e)=>{let s=Math.round(t/(Math.PI*2)*65535),i=0,n=Math.round((e+1.5)/3*32767),r=s<0?0:s;s=r>65535?65535:r;let c=Math.trunc(s);if(c<0)c=0;if(c>4294967295)c=4294967295;c=s>=0?c:0,c=s>65535?0:c;let h=c;i^=h;let m=n<0?0:n;s=m,m=s>32767?32767:s,s=m;let f=Math.trunc(s);if(f<0)f=0;if(f>4294967295)f=4294967295;f=s>=0?f:0,f=s>65535?0:f;let u=f,d=u,k=i^d,E=k&255,N=i<<8,v=(i&65280)>>>8;u=(N|v)>>>0;let Y=E^u;k=k<<8|(k&65280)>>>8,h^=d,d=k^h&255,h=h<<8|(h&65280)>>>8,i=h^i&255;let z=[];return z[3]=G(1050359+(d&63)),z[7]=G(1050359+(u>>>8&63)),z[4]=G(1050359+(k>>>10&63)),z[0]=G(1050359+((i&252)>>>2)),z[5]=G(1050359+(k>>>4&48|Y>>>4&15)),z[2]=G(1050359+(h>>>6&60|d>>>6&3)),z[6]=G(1050359+((u>>>14&3|Y<<2)&63)),z[1]=G(1050359+((h>>>12&15|i<<4)&63)),String.fromCharCode(...z)};class st{connected=!1;onceConnected=[];regionList=[];proxy=null;sessionId="";onListeners=new Map;onceListeners=new Map;#t=!1;#e=!1;constructor(t={}){if(this.#t=t.noExitOnError||!1,!t.instance)t.instance="shellshock.io";if(!t.protocol)t.protocol="wss";if(t.api)this.api=t.api;else this.api=new V({proxy:t.proxy,protocol:t.protocol,instance:t.instance,connectionTimeout:t.connectionTimeout});if(t.sessionId||t.noLogin)this.sessionId=t.sessionId;else this.#s();if(t.proxy&&w.isBrowser)this.#i("proxies do not work and hence are not supported in the browser");else if(t.proxy)this.proxy=t.proxy;this.#n(t.instance,t.protocol,t.noLogin,t.connectionTimeout)}async#n(t,e,s,i){if(this.ws=new F(`${e}://${t}/matchmaker/`,this.proxy),this.ws.connectionTimeout=i||5000,!await this.ws.tryConnect())return this.#i("WebSocket did not connect...");if(this.ws.onmessage=async(r)=>{let c=JSON.parse(r.data);if(c.command==="validateUUID")return this.ws.send(JSON.stringify({command:"validateUUID",hash:await Ft(c.uuid)}));this.#o("msg",c)},this.ws.onclose=()=>{if(this.connected=!1,!this.#e)this.#n(t,e,s,i)},this.connected=!0,this.sessionId||s)this.onceConnected.forEach((r)=>r())}async#s(){let t=await this.api.loginAnonymously();if(!t||typeof t==="string")this.#o("authFail",t);if(this.sessionId=t.sessionId,this.connected)this.onceConnected.forEach((e)=>e())}send(t){this.ws.send(JSON.stringify(t))}async waitForConnect(){return new Promise((t)=>{if(this.connected)t();else this.onceConnected.push(t)})}async getRegions(){await this.waitForConnect();let t=this;return new Promise((e)=>{let s=(i)=>{if(i.command==="regionList")this.regionList=i.regionList,this.off("msg",s),e(i.regionList)};this.on("msg",s),this.ws.onerror=(i)=>t.#i("failed to get regions",i),this.ws.send(JSON.stringify({command:"regionList"}))})}close(){this.#e=!0,this.connected=!1,this.ws.close()}on(t,e){if(!this.onListeners.has(t))this.onListeners.set(t,[]);this.onListeners.get(t).push(e)}once(t,e){if(!this.onceListeners.has(t))this.onceListeners.set(t,[]);this.onceListeners.get(t).push(e)}off(t,e){if(this.onListeners.has(t))this.onListeners.set(t,this.onListeners.get(t).filter((s)=>s!==e));if(this.onceListeners.has(t))this.onceListeners.set(t,this.onceListeners.get(t).filter((s)=>s!==e))}#o(t,...e){if(this.onListeners.has(t))this.onListeners.get(t).forEach((s)=>s(...e));if(this.onceListeners.has(t))this.onceListeners.get(t).forEach((s)=>s(...e)),this.onceListeners.delete(t)}#i(t){if(this.onListeners.has("error"))this.#o("error",t);else if(this.#t)console.error(t);else throw Error(t)}}var Ut=st;var De=(t,e)=>(t%e+e)%e,Ve=Math.PI*2,Wt=(t)=>Math.round(t*8192)/8192,be=(t)=>Wt(De(Math.atan2(-t.x,-t.z),Ve)),ts=(t)=>Wt(Math.atan2(t.y,Math.hypot(t.x,t.z)));class jt{constructor(t){this.pos=t}validate(){return this.pos&&this.pos.x&&this.pos.y&&this.pos.z}check(t){return t.me.playing}execute(t){let e={x:this.pos.x-t.me.position.x,y:this.pos.y-t.me.position.y,z:this.pos.z-t.me.position.z},s=be(e),i=ts(e);t.state.yaw=s,t.state.pitch=i}}var J=jt;class $t{constructor(t){if(typeof t==="number")this.inputKeys=t;else if(typeof t==="object")this.inputKeys=t.reduce((e,s)=>e|s,0)}validate(){if(typeof this.inputKeys!=="number")return!1;if(this.inputKeys&S.Forward&&this.inputKeys&S.Backward)return!1;if(this.inputKeys&S.Left&&this.inputKeys&S.Right)return!1;return!0}check(t){return t.me.playing}execute(t){t.state.controlKeys=this.inputKeys}}var K=$t;class Mt{constructor(t,e){if(this.x=e.x,this.y=e.y,this.z=e.z,this.positionStr=`${this.x},${this.y},${this.z}`,this.position={x:this.x,y:this.y,z:this.z},this.meshType=t.split(".").pop(),this.f=0,this.g=0,this.h=0,this.visited=null,this.parent=null,this.closed=null,this.links=[],this.isStair())if(e.ry)this.ry=e.ry;else this.ry=0}isFull(){return this.meshType==="full"}canWalkThrough(){return this.meshType==="none"||this.meshType==="ladder"}canWalkOn(){return this.meshType==="full"}isLadder(){return this.meshType==="ladder"}isStair(){return this.meshType==="wedge"}isAir(){return this.meshType==="none"}canLink(t,e){let s=this.x-t.x,i=this.z-t.z,n=this.y-t.y,r=Math.abs(s),c=Math.abs(n),h=Math.abs(i);if(r+c+h===0||r+h>1||this.isFull()||t.isFull())return!1;let m=e.at(this.x,this.y-1,this.z),f=e.at(t.x,t.y-1,t.z);if(!m||!f)return!1;let u={0:{x:0,z:-1},1:{x:-1,z:0},2:{x:0,z:1},3:{x:1,z:0}};switch(this.meshType){case"none":if(n===1&&t.canWalkThrough())return!0;if(m.canWalkOn()||m.isLadder()){if(t.meshType==="none"||t.meshType==="ladder"&&c===0||t.meshType==="wedge"&&n===0&&s===-u[t.ry].x&&i===-u[t.ry].z)return!0}return!1;case"ladder":if(c===1&&t.canWalkThrough())return!0;if(c===0&&m.canWalkOn())return!0;if(t.meshType==="ladder"&&(c===1||m.canWalkOn()&&f.canWalkOn()))return!0;return!1;case"wedge":if(this.x+u[this.ry].x===t.x&&this.z+u[this.ry].z===t.z&&this.y+1===t.y)return!0;if(this.x-u[this.ry].x===t.x&&this.z-u[this.ry].z===t.z&&(this.y===t.y||this.y-1===t.y))return!0;return!1;default:return!1}}flatCenter(){return{x:this.x+0.5,y:this.y+0,z:this.z+0.5}}flatRadialDistance(t){let e=this.flatCenter();return Math.hypot(e.x-t.x,e.z-t.z)}}class St{list=[];constructor(t){let e={};for(let i of Object.keys(t.data))for(let n of t.data[i])e[n.x<<16|n.y<<8|n.z]=!0,this.list.push(new Mt(i,n));for(let i=0;i<t.width;i++)for(let n=0;n<t.height;n++)for(let r=0;r<t.depth;r++)if(!e[i<<16|n<<8|r])this.list.push(new Mt("SPECIAL.air.none",{x:i,y:n,z:r}));let s=new Map;for(let i of this.list)s.set(i.positionStr,i);for(let i of this.list){let n=[{x:i.x+1,y:i.y,z:i.z},{x:i.x-1,y:i.y,z:i.z},{x:i.x,y:i.y+1,z:i.z},{x:i.x,y:i.y-1,z:i.z},{x:i.x,y:i.y,z:i.z+1},{x:i.x,y:i.y,z:i.z-1}];for(let r of n){let c=`${r.x},${r.y},${r.z}`,h=s.get(c);if(h&&i.canLink(h,this))i.links.push(h)}}}at(t,e,s){if(!this.nodeMap){this.nodeMap=new Map;for(let n of this.list){let r=`${n.x},${n.y},${n.z}`;this.nodeMap.set(r,n)}}let i=`${t},${e},${s}`;return this.nodeMap.get(i)}clean(){for(let t of this.list)t.f=0,t.g=0,t.h=0,t.visited=null,t.parent=null,t.closed=null}hasLineOfSight(t,e){let s=e.x-t.x,i=e.y-t.y,n=e.z-t.z,r=Math.max(Math.abs(s),Math.abs(i),Math.abs(n)),c=s/r,h=i/r,m=n/r,f=t.x,u=t.y,d=t.z;for(let k=0;k<=r;k++){let E=this.at(Math.round(f),Math.round(u),Math.round(d));if(E&&E.isFull())return!1;f+=c,u+=h,d+=m}return!0}}var Bt=async(t,e)=>{if(!w.isIsolated&&typeof process<"u"){let{existsSync:i,mkdirSync:n,readFileSync:r,writeFileSync:c}=process.getBuiltinModule("node:fs"),{join:h}=process.getBuiltinModule("node:path"),{homedir:m}=process.getBuiltinModule("node:os"),f=h(m(),".yolkbot");if(!i(f))n(f);let u=h(f,"maps");if(!i(u))n(u);let d=h(u,`${t}-${e}.json`);if(i(d))return JSON.parse(r(d,"utf-8"));let k=await(await fetch(`https://esm.sh/gh/yolkorg/maps/maps/${t}.json?${e}`)).json();return c(d,JSON.stringify(k,null,4),{flag:"w+"}),k}return await(await fetch(`https://esm.sh/gh/yolkorg/maps/maps/${t}.json?${e}`)).json()},Jt=(t)=>{let e=0,s={},i=[];for(let c of t){if(!s[c.x])s[c.x]={};if(!s[c.x][c.y])s[c.x][c.y]={};s[c.x][c.y][c.z]={zone:null}}let n=[{x:-1,z:0},{x:1,z:0},{x:0,z:-1},{x:0,z:1}],r=(c,h,m)=>s[c]&&s[c][h]&&s[c][h][m]?s[c][h][m]:null;for(let c of t)if(!s[c.x][c.y][c.z].zone){c.zone=++e,s[c.x][c.y][c.z].zone=c.zone;let h=[c],m;do{m=0;for(let f of t)if(!s[f.x][f.y][f.z].zone)for(let u of n){let d=r(f.x+u.x,f.y,f.z+u.z);if(d&&d.zone===c.zone){m++,f.zone=c.zone,s[f.x][f.y][f.z].zone=c.zone,h.push(f);break}}}while(m>0);i.push(h)}return i};var Kt=[];var H=[];var yt=[];var Ht=Object.fromEntries(Object.entries(M).map(([t,e])=>[e,t])),Yt=Object.fromEntries(Object.entries(gt).map(([t,e])=>[t[0].toLowerCase()+t.slice(1),e])),Zt={CHALLENGES:1,BOT_STATS:2,PATHFINDING:3,PING:5,COSMETIC_DATA:6,PLAYER_HEALTH:7,PACKET_HOOK:8,LOG_PACKETS:10,NO_LOGIN:11,DEBUG_BUFFER:12,NO_AFK_KICK:16,LOAD_MAP:17,OBSERVE_GAME:18,NO_REGION_CHECK:19,NO_EXIT_ON_ERROR:20,RENEW_SESSION:21,VIP_HIDE_BADGE:22},zt=(t,e)=>(t%e+e)%e;class Tt{static Intents=Zt;Intents=Zt;#t=[];#e={};#n=[];#s;#o;constructor(t={}){if(t.proxy&&w.isBrowser)this.processError("proxies do not work and hence are not supported in the browser");if(this.intents=t.intents||[],this.intents.includes(this.Intents.COSMETIC_DATA)){if(!l(1001))this.processError("you cannot use the COSMETIC_DATA intent inside of the singlefile browser bundles")}if(this.instance=t.instance||"shellshock.io",this.protocol=t.protocol||"wss",this.proxy=t.proxy||"",this.connectionTimeout=t.connectionTimeout||5000,this.state={name:"yolkbot",weaponIdx:0,inGame:!1,chatLines:0,yaw:0,pitch:0,controlKeys:0,reloading:!1,swappingGun:!1,usingMelee:!1,stateIdx:0,serverStateIdx:0,shotsFired:0,buffer:[],left:!1},this.players={},this.me=new et({}),this.game={raw:{},code:"",socket:null,gameModeId:0,gameMode:Ht[0],mapIdx:0,map:{filename:"",hash:"",name:"",modes:{FFA:!1,Teams:!1,Spatula:!1,King:!1},availability:"both",numPlayers:"18",raw:{},nodes:{},zones:[]},playerLimit:0,isGameOwner:!1,isPrivate:!0,options:{gravity:1,damage:1,healthRegen:1,locked:!1,noTeamChange:!1,noTeamShuffle:!1,weaponsDisabled:Array(7).fill(!1),mustUseSecondary:!1},collectables:[[],[]],teamScore:[0,0,0],spatula:{coords:{x:0,y:0,z:0},controlledBy:0,controlledByTeam:0},stage:X.Capturing,zoneNumber:0,activeZone:[],capturing:0,captureProgress:0,numCapturing:0,capturePercent:0},this.#o=this.game,this.account={id:0,firebase:{idToken:"",refreshToken:"",expiresIn:"3600",localId:""},firebaseId:"",sessionId:"",session:0,email:"",password:"",cw:{atLimit:!1,limit:0,secondsUntilPlay:0,canPlayAgain:Date.now()},loadout:{hatId:null,meleeId:0,stampId:null,classIdx:0,colorIdx:0,grenadeId:0,primaryId:[3100,3600,3400,3800,4000,4200,4500],secondaryId:[,,,,,,,].fill(3000),stampPositionX:0,stampPositionY:0},ownedItemIds:[],vip:!1,emailVerified:!1,isAged:!1,eggBalance:0,adminRoles:0,rawLoginData:{},isDoubleEggWeeknd:()=>{let e=new Date().getUTCDay(),s=new Date().getUTCHours();return e>=5&&s>=20||e===6||e===0}},this.#s=this.account,this.matchmaker=null,this.api=new V({proxy:this.proxy,protocol:this.protocol,instance:this.instance,maxRetries:t?.apiMaxRetries,connectionTimeout:this.connectionTimeout}),this.ping=0,this.lastPingTime=-1,this.lastDeathTime=-1,this.lastUpdateTick=0,this.pathing={nodeList:null,followingPath:!1,activePath:null,activeNode:null,activeNodeIdx:0},this.hasQuit=!1,this.intents.includes(this.Intents.NO_AFK_KICK))this.afkKickInterval=0;if(this.intents.includes(this.Intents.RENEW_SESSION))this.renewSessionInterval=0}dispatch(t){if(t.validate(this)){if(t.check(this))t.execute(this);else this.#t.push(t);return!0}return!1}async createAccount(t,e){this.account=this.#s,this.account.email=t,this.account.password=e;let s=await this.api.createAccount(t,e);return this.processLoginData(s)}async login(t,e){this.account=this.#s,this.account.email=t,this.account.password=e;let s=await this.api.loginWithCredentials(t,e);return this.processLoginData(s)}async loginWithRefreshToken(t){this.account=this.#s;let e=await this.api.loginWithRefreshToken(t);return this.processLoginData(e)}async loginAnonymously(){this.account=this.#s;let t=await this.api.loginAnonymously();return this.processLoginData(t)}processLoginData(t){if(typeof t!=="object")return this.emit("authFail",t),t;if(t.banRemaining)return this.emit("banned",t.banRemaining),"account_banned";if(!t.playerOutput)return this.emit("authFail",t),t;if(this.account.firebase=t.firebase||{},t=t.playerOutput,this.account.rawLoginData=t,this.account.adminRoles=t.adminRoles||0,this.account.eggBalance=t.currentBalance,this.account.emailVerified=t.emailVerified,this.account.firebaseId=t.firebaseId,this.account.id=t.id,this.account.isAged=new Date(t.dateCreated).getTime()<1714546800000,this.account.loadout=t.loadout,this.account.ownedItemIds=t.ownedItemIds,this.account.session=t.session,this.account.sessionId=t.sessionId,this.account.vip=t.active_sub==="IsVIP",this.intents.includes(this.Intents.BOT_STATS))this.account.stats={lifetime:t.statsLifetime,monthly:t.statsCurrent};if(this.intents.includes(this.Intents.CHALLENGES))this.#i(t.challenges);if(this.emit("authSuccess",this.account),this.intents.includes(this.Intents.RENEW_SESSION))this.renewSessionInterval=setInterval(async()=>{if(!this.account?.sessionId)return clearInterval(this.renewSessionInterval);if((await this.api.queryServices({cmd:"renewSession",sessionId:this.account.sessionId})).data!=="renewed")this.emit("sessionExpired")},600000);return this.account}#i(t){this.account.challenges=[];for(let e of t){let s=Kt.find((i)=>i.id===e.challengeId);if(!s)continue;delete e.playerId,this.account.challenges.push({raw:{challengeInfo:s,challengeData:e},id:e.challengeId,name:s.loc.title,desc:s.loc.desc,rewardEggs:s.reward,isRerolled:!!e.reset,isClaimed:!!e.claimed,isCompleted:!!e.completed,progressNum:e.progress,goalNum:s.goal})}}async initMatchmaker(){if(!this.account.sessionId&&!this.intents.includes(this.Intents.NO_LOGIN)){let t=await this.loginAnonymously();if(typeof t!=="object")return t}if(!this.matchmaker){if(this.matchmaker=new Ut({api:this.api,proxy:this.proxy,protocol:this.protocol,instance:this.instance,sessionId:this.account.sessionId,connectionTimeout:this.connectionTimeout,noLogin:this.intents.includes(this.Intents.NO_LOGIN)}),!await this.matchmaker.ws.tryConnect())return"matchmaker_tryconnect_failed";this.matchmaker.on("authFail",(e)=>this.emit("authFail",e)),this.matchmaker.on("error",(e)=>this.processError(e))}return!0}async findPublicGame(t,e){if(typeof t!=="string")return"no_region_passed";if(!yt.find((i)=>i.id===t)&&!this.intents.includes(this.Intents.NO_REGION_CHECK))return"invalid_region_passed";if(typeof e!=="number")return"no_mode_passed";if(Object.values(M).indexOf(e)===-1)return"invalid_mode_passed";if(!await this.initMatchmaker())return"matchmaker_init_fail";return await new Promise((i)=>{let n=(r)=>{if(r.command==="notice")return;if(this.matchmaker.off("msg",n),r.command==="gameFound")return i(r);if(r.error==="sessionNotFound")return i("internal_session_error");this.processError("unknown matchmaker response",JSON.stringify(r))};this.matchmaker.on("msg",n),this.matchmaker.send({command:"findGame",region:t,playType:I.JoinPublic,gameType:e,sessionId:this.account.sessionId})})}async createPrivateGame(t,e,s){if(typeof t!=="string")return"no_region_passed";if(!yt.find((r)=>r.id===t)&&!this.intents.includes(this.Intents.NO_REGION_CHECK))return"invalid_region_passed";if(typeof e!=="number")return"no_mode_passed";if(Object.values(M).indexOf(e)===-1)return"invalid_mode_passed";if(typeof s!=="string")return"no_map_passed";let i=H.findIndex((r)=>r.name.toLowerCase()===s.toLowerCase());if(i===-1)return"invalid_map_passed";if(!await this.initMatchmaker())return"matchmaker_init_fail";return await new Promise((r)=>{let c=(h)=>{if(h.command==="notice")return;if(this.matchmaker.off("msg",c),h.command==="gameFound")return r(h);if(h.error==="sessionNotFound")return r("internal_session_error");this.processError("unknown matchmaker response",JSON.stringify(h))};this.matchmaker.on("msg",c),this.matchmaker.send({command:"findGame",region:t,playType:I.CreatePrivate,gameType:e,sessionId:this.account.sessionId,noobLobby:!1,map:i})})}async join(t,e){if(this.state.name=t||"yolkbot",typeof e==="string"){if(e.includes("#"))e=e.split("#")[1];if(!await this.initMatchmaker())return"matchmaker_init_fail";if(await new Promise((r)=>{let c=(h)=>{if(h.command==="gameFound")this.matchmaker.off("msg",c),this.game.raw=h,this.game.code=h.id,r(h.id);if(h.error&&h.error==="gameNotFound")return this.processError(`game "${e}" not found, it may have expired.`),this.leave(),"gameNotFound"};this.matchmaker.on("msg",c),this.matchmaker.send({command:"joinGame",id:e,observe:!1,sessionId:this.account.sessionId})})==="gameNotFound")return"game_not_found";if(!this.game.raw.id)return this.processError("an internal error occured while joining the game, please report this to developers")}if(typeof e==="object"){if(this.account.id===0)await this.loginAnonymously();if(this.game.raw=e,this.game.code=this.game.raw.id,!this.game.raw.id)return"invalid_game_object";if(!this.game.raw.subdomain)return"invalid_game_object";if(!this.game.raw.uuid)return"invalid_game_object"}let s=this.game.raw.host||(this.instance.startsWith("localhost:")?this.instance:`${this.game.raw.subdomain}.${this.instance}`);if(this.game.socket=new F(`${this.protocol}://${s}/game/${this.game.raw.id}`,this.proxy),this.game.socket.binaryType="arraybuffer",this.game.socket.connectionTimeout=this.connectionTimeout,this.game.socket.onBeforeConnect=()=>{this.game.socket.onmessage=(n)=>this.processPacket(n.data),this.game.socket.onclose=(n)=>{if(this.state.left)this.state.left=!1;else this.emit("close",n.code),this.leave(-1)}},!await this.game.socket.tryConnect())return"websocket_tryconnect_fail";return!0}#r(){if(Object.entries(this.me.position).map((e)=>Math.floor(e[1])).join(",")===this.pathing.activePath[this.pathing.activePath.length-1].positionStr)this.pathing.followingPath=!1,this.pathing.activePath=null,this.pathing.activeNode=null,this.pathing.activeNodeIdx=0,this.dispatch(new K(0));else{let e;if(this.pathing.activeNodeIdx<this.pathing.activePath.length-1)e=this.pathing.activePath[this.pathing.activeNodeIdx+1].flatCenter(),this.dispatch(new J(e));else e=this.pathing.activePath[this.pathing.activeNodeIdx].flatCenter(),this.dispatch(new J(e));for(let s of this.pathing.activePath)if(s.flatRadialDistance(this.me.position)<0.1&&s.position.y===Math.floor(this.me.position.y)){if(this.pathing.activePath.indexOf(s)>=this.pathing.activeNodeIdx){this.pathing.activeNodeIdx=this.pathing.activePath.indexOf(s)+1,this.pathing.activeNode=this.pathing.activePath[this.pathing.activeNodeIdx];break}}if(!(this.state.controlKeys&S.Forward))this.dispatch(new K(S.Forward))}}update(){if(this.hasQuit)return;if(this.pathing.followingPath&&this.intents.includes(this.Intents.PATHFINDING))this.#r();for(let e=0;e<this.#t.length;e++){let s=this.#t[e];if(s.check(this))s.execute(this),this.#t.splice(e,1)}if(this.state.chatLines=Math.max(0,this.state.chatLines-0.008333333333333333),this.me.playing){let e=this.state.stateIdx;if(this.intents.includes(this.Intents.DEBUG_BUFFER))console.log("setting buffer for idx",e),console.log("checking...shotsFired",this.state.shotsFired);if(this.me.jumping=!!(this.state.controlKeys&S.Jump),this.state.buffer[e]={controlKeys:this.state.controlKeys,yaw:this.state.yaw,pitch:this.state.pitch,shotsFired:this.state.shotsFired},this.state.shotsFired=0,this.lastUpdateTick>=2){this.emit("tick");let s=new p;s.packInt8(a.syncMe),s.packInt8(this.state.stateIdx),s.packInt8(this.state.serverStateIdx);let i=zt(this.state.stateIdx-C+1,j);for(let n=0;n<C;n++){let r=zt(i+n,j),c=this.state.buffer[r]||{},h=c.controlKeys||0,m=c.shotsFired||0,f=c.yaw??this.state.yaw,u=c.pitch??this.state.pitch;if(this.intents.includes(this.Intents.DEBUG_BUFFER))console.log("going with",this.state.stateIdx,i,r,c);s.packInt8(h),s.packInt8(m),s.packString(qt(f,u)),s.packInt8(100)}s.send(this.game.socket),this.state.buffer=[],this.lastUpdateTick=0}else this.lastUpdateTick++;this.state.stateIdx=zt(this.state.stateIdx+1,j)}if(!this.intents.includes(this.Intents.PLAYER_HEALTH))return;let t=0.1*(this.game.isPrivate?this.game.options.healthRegen:1);for(let e of Object.values(this.players)){if(e.playing&&e.hp>0){let s=e.streakRewards.includes(g.OverHeal);e.hp+=s?-t:t,e.hp=s?Math.max(100,e.hp):Math.min(100,e.hp)}if(e.spawnShield>0)e.spawnShield-=6}}on(t,e){if(Object.keys(this.#e).includes(t))this.#e[t].push(e);else this.#e[t]=[e]}once(t,e){let s=(...i)=>{e(...i),this.off(t,s)};this.on(t,s)}onAny(t){this.#n.push(t)}off(t,e){if(e)this.#e[t]=this.#e[t].filter((s)=>s!==e);else this.#e[t]=[]}emit(t,...e){if(this.hasQuit)return;if(this.#e[t])for(let s of this.#e[t])s(...e);for(let s of this.#n)s(t,...e)}#c(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=o.unPackString().valueOf(),i=this.players[t];this.emit("chat",i,s,e)}#h(){let t=o.unPackInt8U(),e=this.intents.includes(this.Intents.COSMETIC_DATA),s={id:t,uniqueId:o.unPackString(),name:o.unPackString(),safeName:o.unPackString(),charClass:o.unPackInt8U(),team:o.unPackInt8U(),primaryWeaponItem:e?l(o.unPackInt16U()):o.unPackInt16U(),secondaryWeaponItem:e?l(o.unPackInt16U()):o.unPackInt16U(),shellColor:o.unPackInt8U(),hatItem:e?l(o.unPackInt16U()):o.unPackInt16U(),stampItem:e?l(o.unPackInt16U()):o.unPackInt16U(),stampPosX:o.unPackInt8(),stampPosY:o.unPackInt8(),grenadeItem:e?l(o.unPackInt16U()):o.unPackInt16U(),meleeItem:e?l(o.unPackInt16U()):o.unPackInt16U(),x:o.unPackFloat(),y:o.unPackFloat(),z:o.unPackFloat(),$dx:o.unPackFloat(),$dy:o.unPackFloat(),$dz:o.unPackFloat(),yaw:o.unPackRadU(),pitch:o.unPackRad(),score:o.unPackInt32U(),$kills:o.unPackInt16U(),$deaths:o.unPackInt16U(),$streak:o.unPackInt16U(),totalKills:o.unPackInt32U(),totalDeaths:o.unPackInt32U(),bestStreak:o.unPackInt16U(),$bestOverallStreak:o.unPackInt16U(),shield:o.unPackInt8U(),hp:o.unPackInt8U(),playing:o.unPackInt8U(),weaponIdx:o.unPackInt8U(),$controlKeys:o.unPackInt8U(),upgradeProductId:o.unPackInt8U(),activeShellStreaks:o.unPackInt8U(),social:o.unPackLongString(),hideBadge:o.unPackInt8U()};this.game.mapIdx=o.unPackInt8U(),this.game.isPrivate=o.unPackInt8U()===1,this.game.gameModeId=o.unPackInt8U();let i=new et(s,this.game.gameMode===M.KOTC?this.game.activeZone:null);if(!this.players[s.id])this.players[s.id]=i;if(this.emit("playerJoin",i),this.me.id===s.id)this.me=i,this.emit("botJoin",this.me)}#a(){let t=o.unPackInt8U(),e=o.unPackInt16U(),s=o.unPackFloat(),i=o.unPackFloat(),n=o.unPackFloat(),r=o.unPackInt8U(),c=o.unPackInt8U(),h=o.unPackInt8U(),m=o.unPackInt8U(),f=o.unPackInt8U(),u=this.players[t];if(u){if(u.playing=!0,u.randomSeed=e,u.weapons[0]&&u.weapons[0].ammo)u.weapons[0].ammo.rounds=r;if(u.weapons[0]&&u.weapons[0].ammo)u.weapons[0].ammo.store=c;if(u.weapons[1]&&u.weapons[1].ammo)u.weapons[1].ammo.rounds=h;if(u.weapons[1]&&u.weapons[1].ammo)u.weapons[1].ammo.store=m;u.grenades=f,u.position={x:s,y:i,z:n},u.spawnShield=120,this.emit("playerRespawn",u)}}#u(){let t=o.unPackInt8U(),e=o.unPackFloat(),s=o.unPackFloat(),i=o.unPackFloat(),n=o.unPackInt8U(),r=this.players[t];if(!r||r.id===this.me.id){for(let N=0;N<C;N++)o.unPackInt8U(),o.unPackRadU(),o.unPackRad(),o.unPackInt8U();return}for(let N=0;N<C;N++){let v=o.unPackInt8U();if(v&S.Jump)r.jumping=!0;else r.jumping=!1;if(v&S.Scope)r.scoping=!0;else r.scoping=!1;let A={...r.view};if(r.view.yaw=o.unPackRadU(),r.view.pitch=o.unPackRad(),r.view.yaw!==A.yaw||r.view.pitch!==A.pitch)this.emit("playerRotate",r,A,r.view);r.scale=o.unPackInt8U()}let c=r.position,h=c.x!==e||c.y!==s||c.z!==i,m=r.climbing!==n,f=h||m,u=f?{...c}:null;if(c.x!==e)c.x=e;if(c.z!==i)c.z=i;if(!r.jumping||Math.abs(c.y-s)>0.5)c.y=s;if(m)r.climbing=n;if(!f)return;if(this.emit("playerMove",r,u,c),this.game.gameModeId!==M.KOTC)return;let d=this.game.activeZone,k=!!r.inKotcZone;if(!d&&k){r.inKotcZone=!1,this.emit("playerLeaveZone",r);return}r.updateKotcZone(d);let E=!!r.inKotcZone;if(k!==E)r.inKotcZone=E,this.emit(E?"playerEnterZone":"playerLeaveZone",r)}#f(){let t=o.unPackInt8U(),e=this.players[t];if(e){if(e.playing=!1,e.streakRewards)e.streakRewards=[];if(this.emit("playerPause",e),e.inKotcZone)e.inKotcZone=!1,this.emit("playerLeaveZone",e)}}#m(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(s)s.activeGun=e,this.emit("playerSwapWeapon",s,e)}#p(){let t=o.unPackInt8U(),e=o.unPackInt8U();o.unPackInt8U(),o.unPackInt8U();let s=o.unPackInt8U(),i=this.players[t],n=this.players[e],r=i?{...i}:null;if(i){if(i.id===this.me.id)this.lastDeathTime=Date.now();i.playing=!1,i.streak=0,i.hp=100,i.spawnShield=0,i.stats.totalDeaths++,i.inKotcZone=!1,this.emit("playerLeaveZone",i)}if(n){if(n.streak++,n.stats.totalKills++,n.streak>n.stats.bestStreak)n.stats.bestStreak=n.streak}this.emit("playerDeath",i,n,r,s)}#d(){let t=o.unPackInt8U(),e={posX:o.unPackFloat(),posY:o.unPackFloat(),posZ:o.unPackFloat(),dirX:o.unPackFloat(),dirY:o.unPackFloat(),dirZ:o.unPackFloat()},s=this.players[t];if(!s)return;let i=s.weapons[s.activeGun];if(i&&i.ammo)i.ammo.rounds--,this.emit("playerFire",s,i,e)}#l(){let t=o.unPackInt16U(),e=o.unPackInt8U(),s=o.unPackFloat(),i=o.unPackFloat(),n=o.unPackFloat();this.game.collectables[e].push({id:t,x:s,y:i,z:n}),this.emit("spawnItem",e,{x:s,y:i,z:n},t)}#g(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=o.unPackInt8U(),i=o.unPackInt16U(),n=this.players[t];if(!n)return;if(this.game.collectables[e]=this.game.collectables[e].filter((r)=>r.id!==i),e===Q.Ammo){let r=n.weapons[s];if(r&&r.ammo)r.ammo.store=Math.min(r.ammo.storeMax,r.ammo.store+r.ammo.pickup),this.emit("playerCollectAmmo",n,r,i)}if(e===Q.Grenade){if(n.grenades++,n.grenades>3)n.grenades=3;this.emit("playerCollectGrenade",n,i)}}#x(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;let i=s.hp;s.hp=e,this.emit("playerDamage",s,i,s.hp)}#w(){let t=o.unPackInt8U();o.unPackFloat(),o.unPackFloat();let e=this.me.hp;this.me.hp=t,this.emit("playerDamage",this.me,e,this.me.hp)}#k(){let t=o.unPackInt8U(),e=this.players[t];o.unPackInt8U();let s=o.unPackInt8U(),i=o.unPackFloat(),n=o.unPackFloat(),r=o.unPackFloat();if(this.me.climbing=!!o.unPackInt8U(),o.unPackInt8U(),o.unPackInt8U(),!e)return;this.state.serverStateIdx=s;let c=e.position.x,h=e.position.y,m=e.position.z;if(e.position.x=i,e.position.y=n,e.position.z=r,c!==i||h!==n||m!==r)this.emit("playerMove",e,{x:c,y:h,z:m},{x:i,y:n,z:r})}#M(){let t=new p;t.packInt8(a.eventModifier),t.send(this.game.socket)}#S(){let t=o.unPackInt8U(),e={...this.players[t]};delete this.players[t],this.emit("playerLeave",e)}#y(){if(this.game.gameModeId===M.Spatula){let t={...this.game};this.game.teamScore[1]=o.unPackInt16U(),this.game.teamScore[2]=o.unPackInt16U();let e={x:o.unPackFloat(),y:o.unPackFloat(),z:o.unPackFloat()},s=o.unPackInt8U(),i=o.unPackInt8U();this.game.spatula={coords:e,controlledBy:s,controlledByTeam:i},this.emit("gameStateChange",t,this.game)}else if(this.game.gameModeId===M.KOTC){let t={...this.game};this.game.stage=o.unPackInt8U(),this.game.zoneNumber=o.unPackInt8U(),this.game.capturing=o.unPackInt8U(),this.game.captureProgress=o.unPackInt16U(),this.game.numCapturing=o.unPackInt8U(),this.game.teamScore[1]=o.unPackInt8U(),this.game.teamScore[2]=o.unPackInt8U(),this.game.capturePercent=this.game.captureProgress/1000,this.game.activeZone=this.game.map.zones?this.game.map.zones[this.game.zoneNumber-1]:null;let e=Object.values(this.players).filter((s)=>s.inKotcZone&&s.playing);if(this.game.activeZone)Object.values(this.players).forEach((s)=>s.updateKotcZone(this.game.activeZone));if(this.game.numCapturing<=0)Object.values(this.players).forEach((s)=>{s.inKotcZone=!1,this.emit("playerLeaveZone",s)});this.emit("gameStateChange",t,this.game,e)}else if(this.game.gameModeId===M.Team)this.game.teamScore[1]=o.unPackInt16U(),this.game.teamScore[2]=o.unPackInt16U();if(this.game.gameModeId!==M.Spatula)delete this.game.spatula;if(this.game.gameModeId!==M.KOTC)delete this.game.stage,delete this.game.zoneNumber,delete this.game.capturing,delete this.game.captureProgress,delete this.game.numCapturing,delete this.game.numCapturing,delete this.game.activeZone;if(this.game.gameModeId===M.FFA)delete this.game.teamScore}#z(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;switch(e){case g.HardBoiled:if(t===this.me.id)this.me.shieldHp=100;s.streakRewards.push(g.HardBoiled);break;case g.EggBreaker:s.streakRewards.push(g.EggBreaker);break;case g.Restock:{if(s.grenades=3,s.weapons[0]&&s.weapons[0].ammo)s.weapons[0].ammo.rounds=s.weapons[0].ammo.capacity,s.weapons[0].ammo.store=s.weapons[0].ammo.storeMax;if(s.weapons[1]&&s.weapons[1].ammo)s.weapons[1].ammo.rounds=s.weapons[1].ammo.capacity,s.weapons[1].ammo.store=s.weapons[1].ammo.storeMax;break}case g.OverHeal:s.hp=Math.min(200,s.hp+100),s.streakRewards.push(g.OverHeal);break;case g.DoubleEggs:s.streakRewards.push(g.DoubleEggs);break;case g.MiniEgg:s.scale=0.5,s.streakRewards.push(g.MiniEgg);break}this.emit("playerBeginStreak",s,e)}#T(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;if([g.EggBreaker,g.OverHeal,g.DoubleEggs,g.MiniEgg].includes(e)&&s.streakRewards.includes(e))s.streakRewards=s.streakRewards.filter((n)=>n!==e);if(e===g.MiniEgg)s.scale=1;this.emit("playerEndStreak",s,e)}#E(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=o.unPackFloat(),i=o.unPackFloat();if(!this.me)return;if(this.me.shieldHp=t,this.me.hp=e,this.me.shieldHp<=0)this.me.streakRewards=this.me.streakRewards.filter((n)=>n!==g.HardBoiled),this.emit("selfShieldLost",this.me.hp,{dx:s,dz:i});else this.emit("selfShieldHit",this.me.shieldHp,this.me.hp,{dx:s,dz:i})}#P(){let t={...this.game.options},e=o.unPackInt8U(),s=o.unPackInt8U(),i=o.unPackInt8U();if(e<1||e>4)e=4;if(s<0||s>8)s=4;if(i>16)i=4;this.game.options.gravity=e/4,this.game.options.damage=s/4,this.game.options.healthRegen=i/4;let n=o.unPackInt8U();Object.keys(Yt).forEach((r)=>{let c=n&Yt[r]?1:0;this.game.options[r]=c}),this.game.options.weaponsDisabled=Array.from({length:7},()=>o.unPackInt8U()===1),this.game.options.mustUseSecondary=this.game.options.weaponsDisabled.every((r)=>r),this.emit("gameOptionsChange",t,this.game.options)}#N(){let t=o.unPackInt8U();if(t===L.Pause)this.emit("gameForcePause"),setTimeout(()=>this.me.playing=!1,3000);if(t===L.Reset){if(Object.values(this.players).forEach((e)=>e.streak=0),this.game.gameModeId!==M.FFA)this.game.teamScore=[0,0,0];if(this.game.gameModeId===M.Spatula)this.game.spatula.controlledBy=0,this.game.spatula.controlledByTeam=0,this.game.spatula.coords={x:0,y:0,z:0};if(this.game.gameModeId===M.KOTC)this.game.stage=X.Capturing,this.game.zoneNumber=0,this.game.activeZone=null,this.game.capturing=0,this.game.captureProgress=0,this.game.numCapturing=0,this.game.capturePercent=0;this.emit("gameReset")}}#R(){if(!this.intents.includes(this.Intents.PING))return;let t=this.ping;this.ping=Date.now()-this.lastPingTime,this.emit("pingUpdate",t,this.ping),setTimeout(()=>{let e=new p;e.packInt8(a.ping),e.send(this.game.socket),this.lastPingTime=Date.now()},1000)}#G(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;let i=s.team;s.team=e,s.streak=0,this.emit("playerSwitchTeam",s,i,e)}#O(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=o.unPackInt16U(),i=o.unPackInt16U(),n=o.unPackInt8U(),r=o.unPackInt16U(),c=o.unPackInt16U(),h=o.unPackInt16U(),m=o.unPackInt16U(),f=o.unPackInt8(),u=o.unPackInt8(),d=this.intents.includes(this.Intents.COSMETIC_DATA),k=d?l(s):s,E=d?l(i):i,N=d?l(r):r,v=d?l(c):c,A=d?l(h):h,Y=d?l(m):m,x=this.players[t];if(x){let z={...x.character},Nt=x.selectedGun;if(x.character.eggColor=n,x.character.primaryGun=k,x.character.secondaryGun=E,x.character.stamp=v,x.character.hat=N,x.character.grenade=A,x.character.melee=Y,x.character.stampPos.x=f,x.character.stampPos.y=u,x.selectedGun=e,x.weapons[0]=new _[e],Nt!==x.selectedGun)this.emit("playerChangeGun",x,Nt,x.selectedGun);if(z!==x.character)this.emit("playerChangeCharacter",x,z,x.character)}}#_(){let t=o.unPackInt32U(),e=this.account.eggBalance;this.account.eggBalance=t,this.emit("balanceUpdate",e,t)}#v(){this.me.playing=!1,this.emit("respawnDenied")}#A(){let t=o.unPackInt8U(),e=this.players[t];if(e)this.emit("playerMelee",e)}#C(){let t=o.unPackInt8U(),e=this.players[t];if(!e)return;let s=e.weapons[e.activeGun];if(s.ammo){let i=Math.min(Math.min(s.ammo.capacity,s.ammo.reload)-s.ammo.rounds,s.ammo.store);s.ammo.rounds+=i,s.ammo.store-=i}this.emit("playerReload",e,s)}updateGameOptions(){let t=new p;t.packInt8(a.gameOptions),t.packInt8(this.game.options.gravity*4),t.packInt8(this.game.options.damage*4),t.packInt8(this.game.options.healthRegen*4);let e=(this.game.options.locked?1:0)|(this.game.options.noTeamChange?2:0)|(this.game.options.noTeamShuffle?4:0);t.packInt8(e),this.game.options.weaponsDisabled.forEach((s)=>{t.packInt8(s?1:0)}),t.send(this.game.socket)}#L(){this.game.isPrivate=!0,this.updateGameOptions()}#F(){let t=o.unPackInt8U(),e=o.unPackInt16U(),s=o.unPackFloat(),i=o.unPackFloat(),n=o.unPackFloat(),r=o.unPackInt8U(),c=o.unPackFloat();if(this.intents.includes(this.Intents.COSMETIC_DATA))e=l(e);if(t===P.Grenade)this.emit("grenadeExplode",e,{x:s,y:i,z:n},r,c);else this.emit("rocketHit",{x:s,y:i,z:n},r,c)}#q(){let t=o.unPackInt8U(),e=o.unPackFloat(),s=o.unPackFloat(),i=o.unPackFloat(),n=o.unPackFloat(),r=o.unPackFloat(),c=o.unPackFloat(),h=this.players[t];if(h)h.grenades--,this.emit("playerThrowGrenade",h,{x:e,y:s,z:i},{x:n,y:r,z:c})}#U(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;if(!this.intents.includes(this.Intents.CHALLENGES))return this.emit("challengeComplete",s,e);let i=this.account.challenges.find((n)=>n.id===e);if(this.emit("challengeComplete",s,i),s.id===this.me.id)this.refreshChallenges()}#W(){let t=new p;t.packInt8(this.intents.includes(this.Intents.OBSERVE_GAME)?a.observeGame:a.joinGame),t.packString(this.game.raw.uuid),t.packInt8(+this.intents.includes(this.Intents.VIP_HIDE_BADGE)),t.packInt8(this.state.weaponIdx||this.account?.loadout?.classIdx||0),t.packString(this.state.name),t.packInt32(this.account.session),t.packString(this.account.sessionId),t.packString(this.account.firebaseId),t.send(this.game.socket)}async#j(){if(this.me.id=o.unPackInt8U(),this.me.team=o.unPackInt8U(),this.game.gameModeId=o.unPackInt8U(),this.game.gameMode=Ht[this.game.gameModeId],this.game.mapIdx=o.unPackInt8U(),this.game.map=H[this.game.mapIdx],this.game.playerLimit=o.unPackInt8U(),this.game.isGameOwner=o.unPackInt8U()===1,this.game.isPrivate=o.unPackInt8U()===1||this.game.isGameOwner,o.unPackInt8U(),this.intents.includes(this.Intents.LOAD_MAP)||this.intents.includes(this.Intents.PATHFINDING)){if(this.game.map.raw=await Bt(this.game.map.filename,this.game.map.hash),this.emit("mapLoad",this.game.map.raw),this.game.gameModeId===M.KOTC){let e=this.game.map.raw.data["DYNAMIC.capture-zone.none"];if(e){if(this.game.map.zones=Jt(e),!this.game.activeZone)this.game.activeZone=this.game.map.zones[this.game.zoneNumber-1]}else delete this.game.map.zones}if(this.intents.includes(this.Intents.PATHFINDING))this.pathing.nodeList=new St(this.game.map.raw)}this.state.inGame=!0,this.lastDeathTime=Date.now();let t=new p;if(t.packInt8(a.clientReady),t.send(this.game.socket),this.updateIntervalId=setInterval(()=>this.update(),33.333333333333336),this.intents.includes(this.Intents.PING)){this.lastPingTime=Date.now();let e=new p;e.packInt8(a.ping),e.send(this.game.socket)}if(this.intents.includes(this.Intents.NO_AFK_KICK))this.afkKickInterval=setInterval(()=>{if(this.state.inGame&&!this.me.playing&&Date.now()-this.lastDeathTime>=15000){let e=new p;e.packInt8(a.keepAlive),e.send(this.game.socket)}},15000);this.emit("gameReady")}#$(){let t=o.unPackInt8U(),e=o.unPackString(128),s=o.unPackString(32),i=this.players[t];if(!i)return;i.admin={ip:s,dbId:e},this.emit("playerInfo",i,s,e)}packetHandlers={[a.syncThem]:()=>this.#u(),[a.fire]:()=>this.#d(),[a.hitThem]:()=>this.#x(),[a.syncMe]:()=>this.#k(),[a.hitMe]:()=>this.#w(),[a.swapWeapon]:()=>this.#m(),[a.collectItem]:()=>this.#g(),[a.respawn]:()=>this.#a(),[a.die]:()=>this.#p(),[a.pause]:()=>this.#f(),[a.chat]:()=>this.#c(),[a.addPlayer]:()=>this.#h(),[a.removePlayer]:()=>this.#S(),[a.eventModifier]:()=>this.#M(),[a.metaGameState]:()=>this.#y(),[a.beginShellStreak]:()=>this.#z(),[a.endShellStreak]:()=>this.#T(),[a.hitMeHardBoiled]:()=>this.#E(),[a.gameOptions]:()=>this.#P(),[a.ping]:()=>this.#R(),[a.switchTeam]:()=>this.#G(),[a.changeCharacter]:()=>this.#O(),[a.reload]:()=>this.#C(),[a.explode]:()=>this.#F(),[a.throwGrenade]:()=>this.#q(),[a.spawnItem]:()=>this.#l(),[a.melee]:()=>this.#A(),[a.updateBalance]:()=>this.#_(),[a.challengeCompleted]:()=>this.#U(),[a.socketReady]:()=>this.#W(),[a.gameJoined]:()=>this.#j(),[a.gameAction]:()=>this.#N(),[a.requestGameOptions]:()=>this.#L(),[a.respawnDenied]:()=>this.#v(),[a.playerInfo]:()=>this.#$(),[a.expireUpgrade]:()=>{},[a.clientReady]:()=>{},[a.musicInfo]:()=>o.unPackLongString()};processPacket(t){if(o.init(t),this.intents.includes(this.Intents.PACKET_HOOK))this.emit("packet",t);let e=0,s=0,i=!1;while(o.isMoreDataAvailable()&&!i){let n=o.unPackInt8U(),r=this.packetHandlers[n];if(r)r();else{if(console.error(`processPacket: I got but couldn't identify a: ${Object.keys(a).find((c)=>a[c]===n)} ${n}`),e)console.error(`processPacket: It may be a result of the ${e} command (${s}).`);i=!0;break}if(e=Object.keys(a).find((c)=>a[c]===n),s=n,this.intents.includes(this.Intents.LOG_PACKETS))console.log(`[LOG_PACKETS] Packet ${e}: ${s}`)}}async checkChiknWinner(){let t=await this.api.queryServices({cmd:"chicknWinnerReady",id:this.account.id,sessionId:this.account.sessionId});if(typeof t==="string")return t;return this.account.cw.limit=t.limit,this.account.cw.atLimit=t.limit>=4,this.account.cw.secondsUntilPlay=(this.account.cw.atLimit?t.period:t.span)||0,this.account.cw.canPlayAgain=Date.now()+this.account.cw.secondsUntilPlay*1000,this.account.cw}async playChiknWinner(t=!0){if(this.account.cw.atLimit||this.account.cw.limit>lt)return"hit_daily_limit";if(this.account.cw.canPlayAgain>Date.now()&&t)return"on_cooldown";let e=await this.api.queryServices({cmd:"incentivizedVideoReward",firebaseId:this.account.firebaseId,id:this.account.id,sessionId:this.account.sessionId,token:null});if(typeof e==="string")return e;if(e.error){if(e.error==="RATELIMITED"||e.error==="RATELMITED")return await this.checkChiknWinner(),"on_cooldown";else if(e.error==="SESSION_EXPIRED")return this.emit("sessionExpired"),"session_expired";return console.error("Unknown Chikn Winner response, report this on Github:",e),"unknown_error"}if(e.reward)return this.account.eggBalance+=e.reward.eggsGiven,e.reward.itemIds.forEach((s)=>this.account.ownedItemIds.push(s)),await this.checkChiknWinner(),e.reward;return console.error("Unknown Chikn Winner response, report this on Github:",e),"unknown_error"}async resetChiknWinner(){if(this.account.eggBalance<200)return"not_enough_eggs";if(!this.account.cw.atLimit)return"not_at_limit";let t=await this.api.queryServices({cmd:"chwReset",sessionId:this.account.sessionId});if(typeof t==="string")return t;if(t.result!=="SUCCESS")return console.error("Unknown Chikn Winner reset response, report this on Github:",t),"unknown_error";return this.account.eggBalance-=200,await this.checkChiknWinner(),this.account.cw}canSee(t){if(!this.intents.includes(this.Intents.PATHFINDING))return this.processError("You must have the PATHFINDING intent to use this method.");return this.pathing.nodeList.hasLineOfSight(this.me.position,t.position)}async refreshChallenges(){let t=await this.api.queryServices({cmd:"challengeGetDaily",sessionId:this.account.sessionId,playerId:this.account.id});if(typeof t==="string")return t;return this.#i(t),this.account.challenges}async rerollChallenge(t){let e=await this.api.queryServices({cmd:"challengeRerollSlot",sessionId:this.account.sessionId,slotId:t});if(typeof e==="string")return e;return this.#i(e),this.account.challenges}async claimChallenge(t){let e=await this.api.queryServices({cmd:"challengeClaimReward",sessionId:this.account.sessionId,slotId:t});if(typeof e==="string")return e;if(this.#i(e.challenges),e.reward>0)this.account.eggBalance+=e.reward;return{eggReward:e.reward,updatedChallenges:this.account.challenges}}async refreshBalance(){let t=await this.api.queryServices({cmd:"checkBalance",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId});if(typeof t==="string")return t;return this.account.eggBalance=t.currentBalance,t.currentBalance}async redeemCode(t){let e=await this.api.queryServices({cmd:"redeem",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,id:this.account.id,code:t});if(typeof e==="string")return e;if(e.result==="SUCCESS")return this.account.eggBalance=e.eggs_given,e.item_ids.forEach((s)=>this.account.ownedItemIds.push(s)),{result:e,eggsGiven:e.eggs_given,itemIds:e.item_ids};return e}async claimURLReward(t){let e=await this.api.queryServices({cmd:"urlRewardParams",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,reward:t});if(typeof e==="string")return e;if(e.result==="SUCCESS")this.account.eggBalance+=e.eggsGiven,e.itemIds.forEach((s)=>this.account.ownedItemIds.push(s));return e}async claimSocialReward(t){let e=await this.api.queryServices({cmd:"reward",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,rewardTag:t});if(typeof e==="string")return e;if(e.result==="SUCCESS")this.account.eggBalance+=e.eggsGiven,e.itemIds.forEach((s)=>this.account.ownedItemIds.push(s));return e}async buyItem(t){let e=await this.api.queryServices({cmd:"buy",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,itemId:t,save:!0});if(typeof e==="string")return e;if(e.result==="SUCCESS")this.account.eggBalance=e.currentBalance,this.account.ownedItemIds.push(e.itemId);return e}processError(...t){let e=t.join(" ");if(this.#e.error&&this.#e.error.length)this.emit("error",e);else if(this.intents.includes(this.Intents.NO_EXIT_ON_ERROR))console.error(e);else throw Error(e)}leave(t=b.mainMenu){if(this.hasQuit)return;if(t>-1)this.game?.socket?.close(t),this.state.left=!0,this.emit("leave",t);clearInterval(this.updateIntervalId),this.#t=[],this.state.inGame=!1,this.state.chatLines=0,this.state.reloading=!1,this.state.swappingGun=!1,this.state.usingMelee=!1,this.state.stateIdx=0,this.state.serverStateIdx=0,this.state.shotsFired=0,this.state.buffer=[],this.players={},this.me=new et({}),this.game=this.#o,this.ping=0,this.lastPingTime=-1,this.lastDeathTime=-1,this.lastUpdateTick=0,this.pathing={nodeList:null,followingPath:!1,activePath:null,activeNode:null,activeNodeIdx:0}}logout(){if(this.account=this.#s,this.intents.includes(this.Intents.RENEW_SESSION))clearInterval(this.renewSessionInterval)}quit(t=!1){if(this.hasQuit)return;if(this.leave(),this.matchmaker){if(this.matchmaker.close(),!t)delete this.matchmaker}if(!t)delete this.account,delete this.api,delete this.game,delete this.me,delete this.pathing,delete this.players,delete this.state,this.#s={},this.#o={},this.#e={},this.#n=[],this.#t=[];if(this.intents.includes(this.Intents.NO_AFK_KICK))clearInterval(this.afkKickInterval);if(this.intents.includes(this.Intents.RENEW_SESSION))clearInterval(this.renewSessionInterval);this.hasQuit=!0}}class Qt{constructor(t,e,s=""){this.uniqueId=t,this.duration=e,this.reason=s}validate(t){if(typeof this.uniqueId!=="string"||typeof this.reason!=="string")return!1;if(typeof this.duration!=="number"||!Object.values(dt).some((e)=>this.duration===e))return!1;if(!(t.account.adminRoles&4))return!1;return!0}check(){return!0}execute(t){let e=new p;e.packInt8(a.banPlayer),e.packString(this.uniqueId),e.packString(this.reason),e.packInt8(this.duration),e.send(t.game.socket)}}var Xt=Qt;class It{constructor(t){this.uniqueId=t}validate(t){return typeof this.uniqueId==="string"&&t.game.isGameOwner&&Object.values(t.players).find((e)=>e.uniqueId===this.uniqueId)}check(){return!0}execute(t){let e=new p;e.packInt8(a.bootPlayer),e.packString(this.uniqueId),e.send(t.game.socket)}}var Dt=It;class Vt{constructor(t){this.msg=t}validate(){if(typeof this.msg!=="string")return!1;if(this.msg.length<1||this.msg.length>64)return!1;return!0}check(t){if(!t.state?.inGame)return!1;if(!t.game.isPrivate&&!t.account.adminRoles&&t.state.chatLines>=2)return!1;if(!t.game.isPrivate&&!t.account.emailVerified&&!t.account.isAged)return!1;return!0}execute(t){t.state.chatLines++;let e=new p;e.packInt8(a.chat),e.packString(this.msg),e.send(t.game.socket)}}var bt=Vt;class te{constructor(t){this.amount=t||1}validate(){return this.amount>=1}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee&&t.me.weapons[t.me.activeGun].ammo.rounds>=this.amount}execute(t){t.state.shotsFired+=this.amount||1}}var ee=te;var es=Array.from({length:4},(t,e)=>(e+1)*0.25),ss=Array.from({length:9},(t,e)=>e*0.25),is=Array.from({length:17},(t,e)=>e*0.25),y=(t,e)=>typeof t>"u"?e:t;class se{constructor(t){this.changes=t}#t(t){let e={};if(e.gravity=y(this.changes.gravity,t.game.options.gravity),e.damage=y(this.changes.damage,t.game.options.damage),e.healthRegen=y(this.changes.healthRegen,t.game.options.healthRegen),e.locked=y(this.changes.locked,t.game.options.locked),e.noTeamChange=y(this.changes.noTeamChange,t.game.options.noTeamChange),e.noTeamShuffle=y(this.changes.noTeamShuffle,t.game.options.noTeamShuffle),e.weaponsDisabled=[y(this.changes.disableEggk,t.game.options.weaponsDisabled[0]),y(this.changes.disableScrambler,t.game.options.weaponsDisabled[1]),y(this.changes.disableFreeRanger,t.game.options.weaponsDisabled[2]),y(this.changes.disableRPG,t.game.options.weaponsDisabled[3]),y(this.changes.disableWhipper,t.game.options.weaponsDisabled[4]),y(this.changes.disableCrackshot,t.game.options.weaponsDisabled[5]),y(this.changes.disableTriHard,t.game.options.weaponsDisabled[6])],this.changes.toDisable&&Array.isArray(this.changes.toDisable))this.changes.toDisable.forEach((s)=>e.weaponsDisabled[s]=!0);if(this.changes.toEnable&&Array.isArray(this.changes.toEnable))this.changes.toEnable.forEach((s)=>e.weaponsDisabled[s]=!1);if(this.changes.rawWeaponsDisabled&&Array.isArray(this.changes.rawWeaponsDisabled)&&this.changes.rawWeaponsDisabled.length===7)e.weaponsDisabled=this.changes.rawWeaponsDisabled.map((s)=>!!s);return e.mustUseSecondary=e.weaponsDisabled.every((s)=>s),e}validate(t){let e=this.#t(t);if(!es.includes(e.gravity))return!1;if(!ss.includes(e.damage))return!1;if(!is.includes(e.healthRegen))return!1;if(typeof e.locked!=="boolean")return!1;if(typeof e.noTeamChange!=="boolean")return!1;if(typeof e.noTeamShuffle!=="boolean")return!1;if(!Array.isArray(e.weaponsDisabled))return!1;if(e.weaponsDisabled.length!==7)return!1;if(e.weaponsDisabled.some((s)=>typeof s!=="boolean"))return!1;return!0}check(t){return t.game.isGameOwner}execute(t){t.game.options=this.#t(t),t.updateGameOptions()}}var ie=se;class Et{constructor(t){this.content=[],this.scoreFunction=t}push(t){this.content.push(t),this.bubbleUp(this.content.length-1)}rescoreElement(t){this.sinkDown(this.content.indexOf(t))}pop(){let t=this.content[0],e=this.content.pop();if(this.content.length>0)this.content[0]=e,this.sinkDown(0);return t}remove(t){let e=this.content.length;for(let s=0;s<e;s++){if(this.content[s]!==t)continue;let i=this.content.pop();if(s===e-1)break;this.content[s]=i,this.bubbleUp(s),this.sinkDown(s);break}}size(){return this.content.length}bubbleUp(t){let e=this.content[t],s=this.scoreFunction(e);while(t>0){let i=Math.floor((t+1)/2)-1,n=this.content[i];if(s>=this.scoreFunction(n))break;this.content[i]=e,this.content[t]=n,t=i}}includes(t){return this.content.includes(t)}sinkDown(t){let e=this.content.length,s=this.content[t],i=this.scoreFunction(s);while(!0){let n=(t+1)*2,r=n-1,c=null,h;if(r<e){let m=this.content[r];if(h=this.scoreFunction(m),h<i)c=r}if(n<e){let m=this.content[n];if(this.scoreFunction(m)<(c===null?i:h))c=n}if(c===null)break;this.content[t]=this.content[c],this.content[c]=s,t=c}}}class T{constructor(t){this.list=t}heuristic(t,e){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)+Math.abs(t.z-e.z)}reversePath(t){let e=[];while(t.parent)e.push(t),t=t.parent;return e.reverse(),e}path(t,e){this.list.clean();let s=new Et((n)=>n.f),i=[];t.h=this.heuristic(t,e),t.g=0,t.f=t.g+t.h,s.push(t);while(s.size()!==0){let n=s.pop();if(n===e)return this.reversePath(n);i.push(n);let r=n.links;for(let c=0;c<r.length;c++){let h=r[c];if(i.includes(h))continue;let m=n.g+1,f=h.visited;if(!f||m<h.g)if(h.visited=!0,h.parent=n,h.g=m,h.h=this.heuristic(h.position,e.position),h.f=h.g+h.h,f)s.rescoreElement(h);else s.push(h)}}return null}}class oe{validate(t){return t.intents.includes(t.Intents.PATHFINDING)}check(t){return t.me.playing&&t.game.collectables[0].length}execute(t){this.pather=new T(t.pathing.nodeList);let e=200,s=null;for(let h of t.game.collectables[0]){let m=h.x-t.me.position.x,f=h.y-t.me.position.y,u=h.z-t.me.position.z,d=Math.sqrt(m*m+f*f+u*u);if(d<e)e=d,s=h}let i=Object.entries(t.me.position).map((h)=>Math.floor(h[1])),n=Object.entries(s).map((h)=>Math.floor(h[1])),r=t.pathing.nodeList.at(...i),c=t.pathing.nodeList.at(...n);if(t.pathing.activePath=this.pather.path(r,c),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var ne=oe;class re{validate(t){return t.intents.includes(t.Intents.PATHFINDING)}check(t){return t.me.playing&&t.game.zoneNumber&&t.game.activeZone}execute(t){this.pather=new T(t.pathing.nodeList);let e=200,s=null;for(let h of t.game.activeZone){let m=h.x-t.me.position.x,f=h.y-t.me.position.y,u=h.z-t.me.position.z,d=Math.sqrt(m*m+f*f+u*u);if(d<e)e=d,s=h}let i=Object.entries(t.me.position).map((h)=>Math.floor(h[1])),n=Object.entries(s).map((h)=>Math.floor(h[1])),r=t.pathing.nodeList.at(...i),c=t.pathing.nodeList.at(...n);if(t.pathing.activePath=this.pather.path(r,c),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var ce=re;class he{validate(t){return t.intents.includes(t.Intents.PATHFINDING)}check(t){return t.me.playing&&t.game.collectables[1].length}execute(t){this.pather=new T(t.pathing.nodeList);let e=200,s=null;for(let h of t.game.collectables[1]){let m=h.x-t.me.position.x,f=h.y-t.me.position.y,u=h.z-t.me.position.z,d=Math.sqrt(m*m+f*f+u*u);if(d<e)e=d,s=h}let i=Object.entries(t.me.position).map((h)=>Math.floor(h[1])),n=Object.entries(s).map((h)=>Math.floor(h[1])),r=t.pathing.nodeList.at(...i),c=t.pathing.nodeList.at(...n);if(t.pathing.activePath=this.pather.path(r,c),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var ae=he;class ue{idOrName;constructor(t){this.idOrName=t}validate(t){if(!t.intents.includes(t.Intents.PATHFINDING))return!1;if(!this.idOrName)return!1;return!!(t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName))}check(t){if(!t.me.playing)return!1;let e=t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName);return e&&e.playing&&e.position&&e.position.x}execute(t){this.pather=new T(t.pathing.nodeList);let e=t.players[this.idOrName.toString()]||t.players.find((c)=>c.name===this.idOrName),s=Object.entries(t.me.position).map((c)=>Math.floor(c[1])),i=Object.entries(e.position).map((c)=>Math.floor(c[1])),n=t.pathing.nodeList.at(...s),r=t.pathing.nodeList.at(...i);if(t.pathing.activePath=this.pather.path(n,r),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var fe=ue;class me{validate(t){return t.intents.includes(t.Intents.PATHFINDING)}check(t){return t.me.playing&&t.game.spatula&&t.game.spatula.coords&&t.game.spatula.coords.x}execute(t){this.pather=new T(t.pathing.nodeList);let e=Object.entries(t.me.position).map((r)=>Math.floor(r[1])),s=Object.entries(t.game.spatula.coords).map((r)=>Math.floor(r[1])),i=t.pathing.nodeList.at(...e),n=t.pathing.nodeList.at(...s);if(t.pathing.activePath=this.pather.path(i,n),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var pe=me;var os=(t,e)=>(t%e+e)%e,ns=Math.PI*2,de=(t)=>Math.round(t*8192)/8192,rs=(t)=>de(os(Math.atan2(-t.x,-t.z),ns)),cs=(t)=>de(Math.atan2(t.y,Math.hypot(t.x,t.z)));class le{idOrName;constructor(t){this.idOrName=t}validate(t){return!!(t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName))}check(t){if(!t.me.playing)return!1;let e=t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName);return e&&e.playing&&e.position&&e.position.x}execute(t){let e=t.players[this.idOrName.toString()]||t.players.find((r)=>r.name===this.idOrName),s={x:e.position.x-t.me.position.x,y:e.position.y-t.me.position.y-0.05,z:e.position.z-t.me.position.z},i=rs(s),n=cs(s);t.state.yaw=i,t.state.pitch=n}}var ge=le;class xe{validate(){return!0}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee}execute(t){let e=new p;e.packInt8(a.melee),e.send(t.game.socket),t.usingMelee=!0,setTimeout(()=>{t.usingMelee=!1,t.swappingGun=!0,setTimeout(()=>{t.swappingGun=!1},0.5*xt)},566.6666666666667)}}var we=xe;class ke{validate(){return!0}check(t){return t.me.playing}execute(t){let e=new p;e.packInt8(a.pause),e.send(t.game.socket),setTimeout(()=>t.me.playing=!1,3000)}}var Me=ke;class Se{validate(){return!0}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee}execute(t){let e=new p;e.packInt8(a.reload),e.send(t.game.socket);let s=t.me.weapons[t.me.activeGun];if(s.ammo){let r=Math.min(Math.min(s.ammo.capacity,s.ammo.reload)-s.ammo.rounds,s.ammo.store);s.ammo.rounds+=r,s.ammo.store-=r}t.emit("playerReload",t.me,s);let i=t.me.weapons[t.me.activeGun],n=i.ammo.rounds<1;t.state.reloading=!0,setTimeout(()=>t.state.reloading=!1,n?i.longReloadTime:i.shortReloadTime)}}var ye=Se;class ze{constructor(t,e={}){if(this.idOrName=t,this.reasons=[!!e.cheating,!!e.harassment,!!e.offensive,!!e.other],!this.reasons.includes(!0))this.reasons[3]=!0;for(let s=0;s<this.reasons.length;s++)if(this.reasons[s]===!0)this.reasonInt|=1<<s}validate(t){if(this.reasons.every((s)=>s===!1))return!1;if(!(t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName)))return!1;return!0}check(t){if(!t.state.inGame)return!1;return!!(t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName))}execute(t){let e=t.players[this.idOrName.toString()]||t.players.find((i)=>i.name===this.idOrName),s=new p;s.packInt8(a.reportPlayer),s.packString(e.uniqueId),s.packInt8(this.reasonInt),s.send(t.game.socket)}}var Te=ze;class Ee{validate(){return!0}check(t){return t.game.isGameOwner}execute(t){let e=new p;e.packInt8(a.gameAction),e.packInt8(L.Reset),e.send(t.game.socket)}}var Pe=Ee;var q=(t)=>l(t)&&l(t).unlock==="default",U=(t,e)=>l(t)&&l(t).item_type_id===e;class Ne{constructor(t){this.changes={classIdx:t.gunId,hatId:t.hatId,stampId:t.stampId,grenadeId:t.grenadeId,meleeId:t.meleeId,colorIdx:t.eggColor,primaryId:t.primaryIds,secondaryId:t.secondaryIds},this.changes=Object.fromEntries(Object.entries(this.changes).filter(([,e])=>!!e))}validate(t){let e=this.changes;if(e.colorIdx&&e.colorIdx>=7&&!t.account.vip)return!1;if(e.colorIdx&&e.colorIdx>=14)return!1;if(U(e.hatId,P.Hat)&&!q(e.hatId)&&!t.account.ownedItemIds.includes(e.hatId))return!1;if(U(e.stampId,P.Stamp)&&!q(e.stampId)&&!t.account.ownedItemIds.includes(e.stampId))return!1;if(U(e.grenadeId,P.Grenade)&&!q(e.grenadeId)&&!t.account.ownedItemIds.includes(e.grenadeId))return!1;if(U(e.meleeId,P.Melee)&&!q(e.meleeId)&&!t.account.ownedItemIds.includes(e.meleeId))return!1;if(typeof e.classIdx==="number"&&e.classIdx>6||e.classIdx<0)return!1;if(this.changes.primaryId)for(let s=0;s<7;s++){let i=this.changes.primaryId[s];if(!U(i,P.Primary)||!q(i)&&!t.account.ownedItemIds.includes(i))return!1}if(this.changes.secondaryId)for(let s=0;s<7;s++){let i=this.changes.secondaryId[s];if(!U(i,P.Secondary)||!q(i)&&!t.account.ownedItemIds.includes(i))return!1}return!0}check(t){return!t.me.playing}execute(t){if(t.me&&this.changes.classIdx&&this.changes.classIdx!==t.me.selectedGun)t.me.weapons[0]=new _[this.changes.classIdx];t.state.weaponIdx=this.changes.classIdx||t.state.weaponIdx;let e={...t.account.loadout,...this.changes},s=t.api.queryServices({cmd:"saveLoadout",save:!0,firebaseId:t.account.firebaseId,sessionId:t.account.sessionId,loadout:e});if(t.account.loadout=e,t.me)s.then(()=>{if(t.state.inGame){let n=new p;n.packInt8(a.changeCharacter),n.packInt8(this.changes?.classIdx||t.me.selectedGun),n.send(t.game.socket)}let i=t.intents.includes(t.Intents.COSMETIC_DATA);Object.entries(this.changes).forEach(([n,r])=>{if(n==="classIdx")t.me.selectedGun=r;else if(n==="hatId")t.me.character.hat=i?l(r):r;else if(n==="stampId")t.me.character.stamp=i?l(r):r;else if(n==="grenadeId")t.me.character.grenade=i?l(r):r;else if(n==="meleeId")t.me.character.melee=i?l(r):r;else if(n==="colorIdx")t.me.character.eggColor=r;else if(n==="primaryId")t.me.character.primaryGun=i?l(r[t.me.selectedGun]):r;else if(n==="secondaryId")t.me.character.secondaryGun=i?l(r[t.me.selectedGun]):r})})}}var Re=Ne;class Ge{validate(){return!0}check(t){if(t.me.playing)return!1;if(t.lastDeathTime+6000<Date.now())return!1;if(t.intents.includes(t.Intents.OBSERVE_GAME))return!1;return!0}execute(t){let e=new p;e.packInt8(a.requestRespawn),e.send(t.game.socket),t.state.buffer=[]}}var Oe=Ge;class _e{constructor(t){this.manualWeapon=t}validate(){return typeof this.manualWeapon==="number"||typeof this.manualWeapon>"u"}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee}execute(t){let e=+!t.me.activeGun;if(typeof this.manualWeapon==="number")e=this.manualWeapon;t.me.activeGun=e;let s=new p;s.packInt8(a.swapWeapon),s.packInt8(t.me.activeGun),s.send(t.game.socket)}}var ve=_e;class Ae{validate(){return!0}check(t){if(!t.state.inGame||t.me.playing)return!1;if(t.game.gameModeId===0)return!1;if(t.intents.includes(t.Intents.OBSERVE_GAME))return!1;if(t.game.isPrivate)return!t.game.options.noTeamChange;let e=t.players,s=t.me.team,i=e.filter((r)=>r.team===s).length,n=e.filter((r)=>r.team!==s).length;if(n>i)return!1;if(i===n)return!1;return!0}execute(t){let e=new p;e.packInt8(a.switchTeam),e.send(t.game.socket)}}var Ce=Ae;class Le{constructor(t=1){this.power=t}validate(){return typeof this.power==="number"&&this.power>=0&&this.power<=1}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee}execute(t){let e=new p;e.packInt8(a.throwGrenade),e.packFloat(this.power),e.send(t.game.socket)}}var Fe=Le;var qe={BanPlayerDispatch:Xt,BootPlayerDispatch:Dt,ChatDispatch:bt,FireDispatch:ee,GameOptionsDispatch:ie,GoToAmmoDispatch:ne,GoToCoopDispatch:ce,GoToGrenadeDispatch:ae,GoToPlayerDispatch:fe,GoToSpatulaDispatch:pe,LookAtDispatch:ge,LookAtPosDispatch:J,MeleeDispatch:we,MovementDispatch:K,PauseDispatch:Me,ReloadDispatch:ye,ReportPlayerDispatch:Te,ResetGameDispatch:Pe,SaveLoadoutDispatch:Re,SpawnDispatch:Oe,SwapWeaponDispatch:ve,SwitchTeamDispatch:Ce,ThrowGrenadeDispatch:Fe};var Pt={};it(Pt,{CommOut:()=>p,CommIn:()=>o,CommCode:()=>a,CloseCode:()=>b});var hs={API:D,Bot:Tt,GamePlayer:tt,Matchmaker:st,Dispatches:qe,Comm:Pt,Constants:kt,Guns:pt,Maps:H};window.yolkbot=hs;if(window.onYolkReady&&typeof window.onYolkReady==="function")console.warn("window.onYolkReady is no longer required as of yolkbot 1.3.0. You don't have to put your code inside it anymore."),window.onYolkReady();
|
|
1
|
+
var Ue=Object.defineProperty;var it=(t,e)=>{for(var s in e)Ue(t,s,{get:e[s],enumerable:!0,configurable:!0,set:(i)=>e[s]=()=>i})};var We=globalThis.fetch,Rt=We;console.error("wwws does not support the browser.");var Gt=null;var W={},Z=typeof window<"u"&&typeof HTMLElement<"u",ot=typeof WebSocketPair<"u"&&typeof Cloudflare<"u",Ot=typeof process<"u"&&process.moduleLoadList?.length>0,_t=typeof Deno<"u",vt=typeof process<"u"&&!!process.versions?.bun;if(!Z&&!ot&&!Ot&&!_t&&!vt)throw Error("yolkbot doesn't know how to run in this environment. Please open an issue on GitHub with information on where you run yolkbot.");W.isBrowser=Z;W.isIsolated=!Ot&&!_t&&!vt;W.fetch=Z||ot?globalThis.fetch:Rt;W.WebSocket=Z||ot?globalThis.WebSocket:Gt;var w=W;var kt={};it(kt,{findItemById:()=>l,UserAgent:()=>$,URLRewards:()=>He,Team:()=>Ke,StateBufferSize:()=>j,SocialReward:()=>Je,SocialMedia:()=>wt,ShellStreak:()=>g,PlayType:()=>I,Movement:()=>S,ItemType:()=>P,GunList:()=>_,GunEquipTime:()=>xt,GameOptionFlag:()=>gt,GameMode:()=>M,GameAction:()=>L,FramesBetweenSyncs:()=>C,FirebaseKey:()=>O,CoopState:()=>X,CollectType:()=>Q,ChiknWinnerDailyLimit:()=>lt,ChatFlag:()=>Be,ChallengeType:()=>$e,ChallengeSubType:()=>je,BanDuration:()=>dt});var pt={};it(pt,{SMG:()=>ut,RPEGG:()=>at,M24:()=>ft,Eggk47:()=>nt,DozenGauge:()=>rt,Cluck9mm:()=>ht,CSG1:()=>ct,AUG:()=>mt});var R=class{constructor(){this.adsMod=0.5,this.burst=0,this.burstRof=0,this.movementAccuracyMod=1,this.radius=0,this.reloadBloom=!0,this.reloadTimeMod=1,this.tracer=0}},nt=class extends R{constructor(){super();this.ammo={rounds:30,capacity:30,reload:30,store:240,storeMax:240,pickup:30},this.longReloadTime=205,this.shortReloadTime=160,this.weaponName="EggK-47",this.internalName="Eggk47",this.standardMeshName="eggk47",this.automatic=!0,this.damage=30,this.range=20,this.recoil=7,this.rof=3,this.totalDamage=30,this.velocity=1.5,this.accuracyMin=0.15,this.accuracyMax=0.03,this.accuracyLoss=0.05,this.accuracyRecover=0.025,this.tracer=1}},rt=class extends R{constructor(){super();this.ammo={rounds:2,capacity:2,reload:2,store:24,storeMax:24,pickup:8},this.longReloadTime=155,this.shortReloadTime=155,this.weaponName="Scrambler",this.internalName="Dozen Gauge",this.standardMeshName="dozenGauge",this.automatic=!1,this.damage=8.5,this.range=8,this.recoil=10,this.rof=8,this.totalDamage=170,this.velocity=1,this.accuracyMin=0.16,this.accuracyMax=0.13,this.accuracyLoss=0.17,this.accuracyRecover=0.02,this.adsMod=0.6,this.movementAccuracyMod=0.2,this.tracer=0}},ct=class extends R{constructor(){super();this.ammo={rounds:15,capacity:15,reload:15,store:60,storeMax:60,pickup:15},this.longReloadTime=225,this.shortReloadTime=165,this.weaponName="Free Ranger",this.internalName="CSG-1",this.standardMeshName="csg1",this.automatic=!1,this.damage=105,this.range=50,this.recoil=13,this.rof=13,this.totalDamage=105,this.velocity=1.75,this.accuracyMin=0.3,this.accuracyMax=0.004,this.accuracyLoss=0.3,this.accuracyRecover=0.025,this.tracer=0}},ht=class extends R{constructor(){super();this.ammo={rounds:15,capacity:15,reload:15,store:60,storeMax:60,pickup:15},this.longReloadTime=195,this.shortReloadTime=160,this.weaponName="Cluck 9mm",this.internalName="Cluck 9mm",this.standardMeshName="cluck9mm",this.automatic=!1,this.damage=26,this.range=15,this.recoil=6,this.rof=4,this.totalDamage=26,this.velocity=1,this.accuracyMin=0.15,this.accuracyMax=0.035,this.accuracyLoss=0.09,this.accuracyRecover=0.08,this.adsMod=0.8,this.movementAccuracyMod=0.6,this.tracer=0}},at=class extends R{constructor(){super();this.ammo={rounds:1,capacity:1,reload:1,store:3,storeMax:3,pickup:1},this.longReloadTime=170,this.shortReloadTime=170,this.weaponName="RPEGG",this.internalName="Eggsploder",this.standardMeshName="rpegg",this.automatic=!1,this.damage=140,this.range=45,this.recoil=60,this.rof=40,this.totalDamage=192.5,this.velocity=0.4,this.accuracyMin=0.3,this.accuracyMax=0.015,this.accuracyLoss=0.3,this.accuracyRecover=0.02,this.radius=2.75}},ut=class extends R{constructor(){super();this.ammo={rounds:40,capacity:40,reload:40,store:200,storeMax:200,pickup:40},this.longReloadTime=225,this.shortReloadTime=190,this.weaponName="Whipper",this.internalName="SMEGG",this.standardMeshName="smg",this.automatic=!0,this.damage=23,this.range=20,this.recoil=7,this.rof=2,this.totalDamage=23,this.velocity=1.25,this.accuracyMin=0.19,this.accuracyMax=0.06,this.accuracyLoss=0.045,this.accuracyRecover=0.05,this.adsMod=0.6,this.movementAccuracyMod=0.7,this.tracer=2}},ft=class extends R{constructor(){super();this.ammo={rounds:1,capacity:1,reload:1,store:12,storeMax:12,pickup:4},this.longReloadTime=144,this.shortReloadTime=144,this.weaponName="Crackshot",this.internalName="M2DZ",this.standardMeshName="m24",this.automatic=!0,this.damage=170,this.range=60,this.recoil=20,this.rof=15,this.totalDamage=170,this.velocity=2,this.accuracyMin=0.35,this.accuracyMax=0,this.accuracyLoss=0.1,this.accuracyRecover=0.023,this.movementAccuracyMod=1.3,this.reloadBloom=!1,this.reloadTimeMod=0.8,this.tracer=0}},mt=class extends R{constructor(){super();this.ammo={rounds:24,capacity:24,reload:24,store:150,storeMax:150,pickup:24},this.longReloadTime=205,this.shortReloadTime=160,this.weaponName="Tri-Hard",this.internalName="AUG",this.standardMeshName="aug",this.automatic=!1,this.damage=32,this.range=20,this.recoil=18,this.rof=15,this.totalDamage=34,this.velocity=1.5,this.accuracyMin=0.15,this.accuracyMax=0.03,this.accuracyLoss=0.037,this.accuracyRecover=0.03,this.adsMod=0.6,this.burst=3,this.burstRof=3,this.movementAccuracyMod=0.8,this.movementInstability=2,this.tracer=0}};var l=()=>null;var dt={FiveMinutes:0,FifteenMinutes:1,OneHour:2},je={Killstreak:0,KillWithWeapon:1,MovementDistance:3,Jumping:4,TimePlayed:6,TimeAlive:7,KillWithCondition:8,TotalKills:10,SpatulaKills:10,Collecting:18,FromTheCoop:20,SpecialOffensive:21,WinKOTC:23,KillWithSpatula:23},$e={Kill:0,Damage:1,Death:2,Movement:3,Collect:4,Time:5,KOTC:6,Spatula:7},Be={None:0,Pinned:2,Team:4,Mod:254,Server:255},lt=3,Q={Ammo:0,Grenade:1},X={Start:0,Score:1,Win:2,Capturing:3,Contested:4,Takeover:5,Abandoned:6,Unclaimed:7},O="AIzaSyDP4SIjKaw6A4c-zvfYxICpbEjn1rRnN50",C=3,L={Reset:1,Pause:2},M={FFA:0,Team:1,Spatula:2,KOTC:3},gt={Locked:1,NoTeamChange:2,NoTeamShuffle:4},xt=13,_=[nt,rt,ct,at,ut,ft,mt],P={Hat:1,Stamp:2,Primary:3,Secondary:4,Grenade:6,Melee:7},S={Forward:1,Backward:2,Left:4,Right:8,Jump:16,Fire:32,Melee:64,Scope:128},I={JoinPublic:0,CreatePrivate:1,JoinPrivate:2},g={HardBoiled:1,EggBreaker:2,Restock:4,OverHeal:8,DoubleEggs:16,MiniEgg:32},wt={Facebook:0,Instagram:1,Tiktok:2,Discord:3,Youtube:4,Twitter:5,Twitch:6},Je={Discord:"rew_1200",Tiktok:"rew_1208",Instagram:"rew_1219",Steam:"rew_1223",Facebook:"rew_1227",Twitter:"rew_1234",Twitch:"rew_twitch_social"},j=256,Ke={Blue:1,Red:2},He=["giveBasketBrosReward","mercZoneFinalGift","midMonthGiveMeEggs","newYolkerSignupReward","newYolkerItemReward","newYolkerWelcomeBack","WelcomeBack"],$=w.isBrowser?null:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36";class At{url="";proxy="";binaryType="";maxRetries=5;connectionTimeout=5000;constructor(t,e){if(w.isBrowser&&e)throw Error("You cannot pass a proxy to a WebSocket in a browser.");this.url=t,this.proxy=e}async tryConnect(t=1){let e=new URL(this.url),s=async()=>{if(t===5)return!1;return await this.tryConnect(t+1)};try{if(this.socket=w.isBrowser?new w.WebSocket(this.url):new w.WebSocket(this.url,{proxy:this.proxy||null,headers:{"accept-encoding":"gzip, deflate, br, zstd","accept-language":"en-US,en;q=0.9","cache-control":"no-cache",connection:"Upgrade",origin:e.origin.replace("ws","http"),pragma:"no-cache","sec-websocket-extensions":"permessage-deflate; client_max_window_bits","user-agent":$}}),this.binaryType)this.socket.binaryType=this.binaryType}catch(i){return console.error(`Failed to connect on try ${t}, trying again...`,i),await s()}if(this.onBeforeConnect)this.onBeforeConnect();return new Promise((i)=>{let n=setTimeout(async()=>{this.socket.close(),i(await s())},this.connectionTimeout),r=async(c)=>{clearTimeout(n),console.error("WebSocket error",c),i(await s())};this.socket.addEventListener("open",async()=>{clearTimeout(n),this.socket.removeEventListener("error",r),i(!0)}),this.socket.addEventListener("error",r)})}get onmessage(){return this.socket?.onmessage}set onmessage(t){if(this.socket)this.socket.onmessage=t;else console.error("set onmessage before socket existed")}get onclose(){return this.socket?.onclose}set onclose(t){if(this.socket)this.socket.onclose=t;else console.error("set onclose before socket existed")}get onerror(){return this.socket?.onerror}set onerror(t){if(this.socket)this.socket.onerror=t;else console.error("set onclose before socket existed")}send(t){return this.socket?.send(t)}close(t){return this.socket?.close(t)}}var F=At;var B={origin:"https://shellshock.io","user-agent":$,"x-client-version":"Chrome/JsCore/9.17.2/FirebaseCore-web","x-firebase-locale":"en"};class D{constructor(t={}){this.proxy=t.proxy,this.instance=t.instance||"shellshock.io",this.protocol=t.protocol||"wss",this.maxRetries=t.maxRetries||5,this.suppressErrors=t.suppressErrors||!1,this.connectionTimeout=t.connectionTimeout||5000}queryServices=async(t)=>{let e=new F(`${this.protocol}://${this.instance}/services/`,this.proxy);if(e.connectionTimeout=this.connectionTimeout,!await e.tryConnect(-2)||e.socket.readyState!==1)return"websocket_connect_fail";return new Promise((i)=>{let n=!1;e.onmessage=(r)=>{n=!0;try{let c=JSON.parse(r.data);i(c)}catch{if(!this.suppressErrors)console.error("queryServices: Bad API JSON response with call:",t.cmd,"and data:",JSON.stringify(t)),console.error("queryServices: Full data sent:",JSON.stringify(t));i("bad_json")}e.close()},e.onerror=()=>!n&&i("unknown_socket_error"),e.onclose=()=>!n&&i("services_closed_early"),e.send(JSON.stringify(t))})};#t=async(t,e,s)=>{if(!t||!e)return"firebase_no_credentials";let i,n;try{i=await(await w.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:${s}?key=${O}`,{method:"POST",body:JSON.stringify({email:t,password:e,returnSecureToken:!0}),headers:{...B,"content-type":"application/json"},proxy:this.proxy})).json(),n=i.idToken}catch(c){if(c.code==="auth/network-request-failed"){if(!this.suppressErrors)console.error("loginWithCredentials: Network req failed (auth/network-request-failed)");return"firebase_network_failed"}else if(c.code==="auth/missing-email")return"firebase_no_credentials";else if(c.code==="ERR_BAD_REQUEST"){if(!this.suppressErrors)console.error("loginWithCredentials: Error:",t,e);if(!this.suppressErrors)console.error("loginWithCredentials: Error:",i||c);return"firebase_bad_request"}if(!this.suppressErrors)console.error("loginWithCredentials: Error:",t,e,c);return"firebase_unknown_error"}if(!n){if(!this.suppressErrors)console.error("loginWithCredentials: the game sent no idToken",i);return"firebase_no_token"}this.idToken=n;let r=await this.queryServices({cmd:"auth",firebaseToken:n});return typeof r==="object"?{firebase:i,...r}:r};createAccount=async(t,e)=>await this.#t(t,e,"signUp");loginWithCredentials=async(t,e)=>await this.#t(t,e,"signInWithPassword");loginWithRefreshToken=async(t)=>{if(!t)return"firebase_no_credentials";let e=new URLSearchParams;e.append("grant_type","refresh_token"),e.append("refresh_token",t);let s,i;try{s=await(await w.fetch(`https://securetoken.googleapis.com/v1/token?key=${O}`,{method:"POST",body:e,headers:{...B,"content-type":"application/x-www-form-urlencoded"},proxy:this.proxy})).json(),i=s.id_token}catch(r){if(r.code==="auth/network-request-failed"){if(!this.suppressErrors)console.error("loginWithRefreshToken: Network req failed (auth/network-request-failed)");return"firebase_network_failed"}else if(r.code==="auth/missing-email")return"firebase_no_credentials";if(!this.suppressErrors)console.error("loginWithRefreshToken: Error:",r,t);return"firebase_unknown_error"}if(!i){if(!this.suppressErrors)console.error("loginWithRefreshToken: the game sent no idToken",s);return"firebase_no_token"}this.idToken=i;let n=await this.queryServices({cmd:"auth",firebaseToken:i});return typeof n==="object"?{firebase:s,...n}:n};loginAnonymously=async()=>{let e=await(await w.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=${O}`,{method:"POST",body:JSON.stringify({returnSecureToken:!0}),headers:{...B,"content-type":"application/json"},proxy:this.proxy})).json(),s=e.idToken;if(!s){if(!this.suppressErrors)console.error("loginAnonymously: the game sent no idToken",e);return"firebase_no_token"}this.idToken=s;let i=await this.queryServices({cmd:"auth",firebaseToken:s});return typeof i==="object"?{firebase:e,...i}:i};sendEmailVerification=async(t=this.idToken)=>{if(!t)return"no_idtoken_passed";let s=await(await w.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode?key=${O}`,{method:"POST",body:JSON.stringify({requestType:"VERIFY_EMAIL",idToken:t}),headers:{...B,"content-type":"application/json"},proxy:this.proxy})).json();if(s.kind!=="identitytoolkit#GetOobConfirmationCodeResponse"){if(!this.suppressErrors)console.error("sendEmailVerification: the game sent an invalid response",s);return"firebase_invalid_response"}return{email:s.email}};verifyOobCode=async(t)=>{if(!t)return"no_oob_code_passed";let s=await(await w.fetch(`https://www.googleapis.com/identitytoolkit/v3/relyingparty/setAccountInfo?key=${O}`,{method:"POST",body:JSON.stringify({oobCode:t}),headers:{...B,"x-client-version":"Chrome/JsCore/3.7.5/FirebaseCore-web",referer:"https://shellshockio-181719.firebaseapp.com/","content-type":"application/json"},proxy:this.proxy})).json();if(!s.emailVerified){if(!this.suppressErrors)console.error("verifyOobCode: the game sent an invalid response",s);return"firebase_invalid_response"}return s.email}}var V=D;class Ct{static buffer;static idx;static init(t){this.buffer=new Uint8Array(t),this.idx=0}static isMoreDataAvailable(){return Math.max(0,this.buffer.length-this.idx)}static unPackInt8U(){let t=this.idx;return this.idx++,this.buffer[t]}static unPackInt8(){return(this.unPackInt8U()+128)%256-128}static unPackInt16U(){let t=this.idx;return this.idx+=2,this.buffer[t]+this.buffer[t+1]*256}static unPackInt24U(){let t=this.idx;return this.idx+=3,this.buffer[t]+this.buffer[t+1]*256+this.buffer[t+2]*65536}static unPackInt32U(){let t=this.idx;return this.idx+=4,this.buffer[t]+this.buffer[t+1]*256+this.buffer[t+2]*65536+this.buffer[t+3]*16777216}static unPackInt16(){return(this.unPackInt16U()+32768)%65536-32768}static unPackInt32(){return(this.unPackInt32U()+2147483648)%4294967296-2147483648}static unPackRadU(){return this.unPackInt24U()/2097152}static unPackRad(){return this.unPackInt16U()/8192-Math.PI}static unPackFloat(){return this.unPackInt16()/256}static unPackDouble(){return this.unPackInt32()/1048576}static unPackString(t){t=t||255;let e=Math.min(this.unPackInt8U(),t);return this.unPackStringHelper(e)}static unPackLongString(t){t=t||16383;let e=Math.min(this.unPackInt16U(),t);return this.unPackStringHelper(e)}static unPackStringHelper(t){if(this.isMoreDataAvailable()<t)return 0;let s="";for(let i=0;i<t;i++){let n=this.unPackInt16U();if(n>0)s+=String.fromCodePoint(n)}return s}}var o=Ct;class Lt{constructor(t=16384){this.idx=0,this.arrayBuffer=new ArrayBuffer(t),this.buffer=new Uint8Array(this.arrayBuffer,0,t)}send(t){let e=new Uint8Array(this.arrayBuffer,0,this.idx);t.send(e)}packInt8(t){this.buffer[this.idx]=t&255,this.idx++}packInt16(t){this.buffer[this.idx]=t&255,this.buffer[this.idx+1]=t>>8&255,this.idx+=2}packInt24(t){this.buffer[this.idx]=t&255,this.buffer[this.idx+1]=t>>8&255,this.buffer[this.idx+2]=t>>16&255,this.idx+=3}packInt32(t){this.buffer[this.idx]=t&255,this.buffer[this.idx+1]=t>>8&255,this.buffer[this.idx+2]=t>>16&255,this.buffer[this.idx+3]=t>>24&255,this.idx+=4}packRadU(t){this.packInt24(t*2097152)}packRad(t){this.packInt16((t+Math.PI)*8192)}packFloat(t){this.packInt16(t*256)}packDouble(t){this.packInt32(t*1048576)}packString(t){if(typeof t!=="string")t="";this.packInt8(t.length);for(let e=0;e<t.length;e++)this.packInt16(t.charCodeAt(e))}packLongString(t){if(typeof t!=="string")t="";this.packInt16(t.length);for(let e=0;e<t.length;e++)this.packInt16(t.charCodeAt(e))}}var p=Lt;var Ye={gameNotFound:4000,gameFull:4001,badName:4002,mainMenu:4003,gameIdleExceeded:4004,corruptedLoginData0:4005,corruptedLoginData1:4006,corruptedLoginData2:4007,corruptedLoginData3:4008,corruptedLoginData4:4009,corruptedLoginData5:4010,gameMaxPlayersExceeded:4011,gameDestroyUser:4012,joinGameOutOfOrder:4013,gameShuttingDown:4014,readyBeforeReady:4015,booted:4016,gameErrorOnUserSocket:4017,uuidNotFound:4018,sessionNotFound:4019,clusterFullCpu:4020,clusterFullMem:4021,noClustersAvailable:4022,locked:4023},b=Ye;var Ze={},a=Ze;var Qe=Object.fromEntries(Object.entries(wt).map(([t,e])=>[e,t.toLowerCase()]));class tt{constructor(t,e=null){if(this.id=t.id,this.uniqueId=t.uniqueId,this.name=t.name,this.safeName=t.safeName,this.team=t.team,this.playing=t.playing,this.socials=t.social&&JSON.parse(t.social),this.socials)this.socials.forEach((s)=>s.type=Qe[s.id]);if(this.isVip=t.upgradeProductId>0,this.showBadge=!t.hideBadge||!1,this.streak=t.score,this.streakRewards=Object.values(g).filter((s)=>t.activeShellStreaks&s),this.scale=this.streakRewards.includes(g.MiniEgg)?0.5:1,this.position={x:t.x,y:t.y,z:t.z},this.jumping=t.$controlKeys&S.Jump,this.scoping=t.$controlKeys&S.Scope,this.climbing=!1,this.view={yaw:t.yaw,pitch:t.pitch},this.updateKotcZone(e),this.character={eggColor:t.shellColor,primaryGun:t.primaryWeaponItem,secondaryGun:t.secondaryWeaponItem,stamp:t.stampItem,hat:t.hatItem,grenade:t.grenadeItem,melee:t.meleeItem,stampPos:{x:t.stampPosX,y:t.stampPosY}},this.stats={totalKills:t.totalKills,totalDeaths:t.totalDeaths,bestStreak:t.bestStreak},this.activeGun=t.weaponIdx,this.selectedGun=t.charClass,this.weapons=[],this.character.primaryGun)this.weapons[0]=new _[this.selectedGun],this.weapons[1]=new ht;this.grenades=1,this.hp=t.hp,this.hpShield=0,this.spawnShield=t.shield,this.randomSeed=0}updateKotcZone(t){if(!t)return this.inKotcZone=!1;let e=Math.floor(this.position.x),s=Math.floor(this.position.y),i=Math.floor(this.position.z);this.inKotcZone=t.some((n)=>n.x===e&&n.y===s&&n.z===i)&&this.playing}}var et=tt;var Xe=(t)=>new Uint8Array(t.match(/.{2}/g).map((e)=>parseInt(e,16))),Ie=new TextEncoder,Ft=async(t)=>{if(typeof process<"u"&&typeof process.getBuiltinModule==="function"){let n=process.getBuiltinModule("node:crypto"),r=Buffer.from("3496afb51f42553e31635211400c000b","hex");return n.createHmac("sha256",r).update(t).digest("hex")}let e=Xe("3496afb51f42553e31635211400c000b"),s=await crypto.subtle.importKey("raw",e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),i=await crypto.subtle.sign("HMAC",s,Ie.encode(t));return Array.from(new Uint8Array(i)).map((n)=>n.toString(16).padStart(2,"0")).join("")},G=(t)=>{return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(t-1050359)},qt=(t,e)=>{let s=Math.round(t/(Math.PI*2)*65535),i=0,n=Math.round((e+1.5)/3*32767),r=s<0?0:s;s=r>65535?65535:r;let c=Math.trunc(s);if(c<0)c=0;if(c>4294967295)c=4294967295;c=s>=0?c:0,c=s>65535?0:c;let h=c;i^=h;let m=n<0?0:n;s=m,m=s>32767?32767:s,s=m;let f=Math.trunc(s);if(f<0)f=0;if(f>4294967295)f=4294967295;f=s>=0?f:0,f=s>65535?0:f;let u=f,d=u,k=i^d,E=k&255,N=i<<8,v=(i&65280)>>>8;u=(N|v)>>>0;let Y=E^u;k=k<<8|(k&65280)>>>8,h^=d,d=k^h&255,h=h<<8|(h&65280)>>>8,i=h^i&255;let z=[];return z[3]=G(1050359+(d&63)),z[7]=G(1050359+(u>>>8&63)),z[4]=G(1050359+(k>>>10&63)),z[0]=G(1050359+((i&252)>>>2)),z[5]=G(1050359+(k>>>4&48|Y>>>4&15)),z[2]=G(1050359+(h>>>6&60|d>>>6&3)),z[6]=G(1050359+((u>>>14&3|Y<<2)&63)),z[1]=G(1050359+((h>>>12&15|i<<4)&63)),String.fromCharCode(...z)};class st{connected=!1;onceConnected=[];regionList=[];proxy=null;sessionId="";onListeners=new Map;onceListeners=new Map;#t=!1;#e=!1;constructor(t={}){if(this.#t=t.noExitOnError||!1,!t.instance)t.instance="shellshock.io";if(!t.protocol)t.protocol="wss";if(t.api)this.api=t.api;else this.api=new V({proxy:t.proxy,protocol:t.protocol,instance:t.instance,connectionTimeout:t.connectionTimeout});if(t.sessionId||t.noLogin)this.sessionId=t.sessionId;else this.#s();if(t.proxy&&w.isBrowser)this.#i("proxies do not work and hence are not supported in the browser");else if(t.proxy)this.proxy=t.proxy;this.#n(t.instance,t.protocol,t.noLogin,t.connectionTimeout)}async#n(t,e,s,i){if(this.ws=new F(`${e}://${t}/matchmaker/`,this.proxy),this.ws.connectionTimeout=i||5000,!await this.ws.tryConnect())return this.#i("WebSocket did not connect...");if(this.ws.onmessage=async(r)=>{let c=JSON.parse(r.data);if(c.command==="validateUUID")return this.ws.send(JSON.stringify({command:"validateUUID",hash:await Ft(c.uuid)}));this.#o("msg",c)},this.ws.onclose=()=>{if(this.connected=!1,!this.#e)this.#n(t,e,s,i)},this.connected=!0,this.sessionId||s)this.onceConnected.forEach((r)=>r())}async#s(){let t=await this.api.loginAnonymously();if(!t||typeof t==="string")this.#o("authFail",t);if(this.sessionId=t.sessionId,this.connected)this.onceConnected.forEach((e)=>e())}send(t){this.ws.send(JSON.stringify(t))}async waitForConnect(){return new Promise((t)=>{if(this.connected)t();else this.onceConnected.push(t)})}async getRegions(){await this.waitForConnect();let t=this;return new Promise((e)=>{let s=(i)=>{if(i.command==="regionList")this.regionList=i.regionList,this.off("msg",s),e(i.regionList)};this.on("msg",s),this.ws.onerror=(i)=>t.#i("failed to get regions",i),this.ws.send(JSON.stringify({command:"regionList"}))})}close(){this.#e=!0,this.connected=!1,this.ws.close()}on(t,e){if(!this.onListeners.has(t))this.onListeners.set(t,[]);this.onListeners.get(t).push(e)}once(t,e){if(!this.onceListeners.has(t))this.onceListeners.set(t,[]);this.onceListeners.get(t).push(e)}off(t,e){if(this.onListeners.has(t))this.onListeners.set(t,this.onListeners.get(t).filter((s)=>s!==e));if(this.onceListeners.has(t))this.onceListeners.set(t,this.onceListeners.get(t).filter((s)=>s!==e))}#o(t,...e){if(this.onListeners.has(t))this.onListeners.get(t).forEach((s)=>s(...e));if(this.onceListeners.has(t))this.onceListeners.get(t).forEach((s)=>s(...e)),this.onceListeners.delete(t)}#i(t){if(this.onListeners.has("error"))this.#o("error",t);else if(this.#t)console.error(t);else throw Error(t)}}var Ut=st;var De=(t,e)=>(t%e+e)%e,Ve=Math.PI*2,Wt=(t)=>Math.round(t*8192)/8192,be=(t)=>Wt(De(Math.atan2(-t.x,-t.z),Ve)),ts=(t)=>Wt(Math.atan2(t.y,Math.hypot(t.x,t.z)));class jt{constructor(t){this.pos=t}validate(){return this.pos&&this.pos.x&&this.pos.y&&this.pos.z}check(t){return t.me.playing}execute(t){let e={x:this.pos.x-t.me.position.x,y:this.pos.y-t.me.position.y,z:this.pos.z-t.me.position.z},s=be(e),i=ts(e);t.state.yaw=s,t.state.pitch=i}}var J=jt;class $t{constructor(t){if(typeof t==="number")this.inputKeys=t;else if(typeof t==="object")this.inputKeys=t.reduce((e,s)=>e|s,0)}validate(){if(typeof this.inputKeys!=="number")return!1;if(this.inputKeys&S.Forward&&this.inputKeys&S.Backward)return!1;if(this.inputKeys&S.Left&&this.inputKeys&S.Right)return!1;return!0}check(t){return t.me.playing}execute(t){t.state.controlKeys=this.inputKeys}}var K=$t;class Mt{constructor(t,e){if(this.x=e.x,this.y=e.y,this.z=e.z,this.positionStr=`${this.x},${this.y},${this.z}`,this.position={x:this.x,y:this.y,z:this.z},this.meshType=t.split(".").pop(),this.f=0,this.g=0,this.h=0,this.visited=null,this.parent=null,this.closed=null,this.links=[],this.isStair())if(e.ry)this.ry=e.ry;else this.ry=0}isFull(){return this.meshType==="full"}canWalkThrough(){return this.meshType==="none"||this.meshType==="ladder"}canWalkOn(){return this.meshType==="full"}isLadder(){return this.meshType==="ladder"}isStair(){return this.meshType==="wedge"}isAir(){return this.meshType==="none"}canLink(t,e){let s=this.x-t.x,i=this.z-t.z,n=this.y-t.y,r=Math.abs(s),c=Math.abs(n),h=Math.abs(i);if(r+c+h===0||r+h>1||this.isFull()||t.isFull())return!1;let m=e.at(this.x,this.y-1,this.z),f=e.at(t.x,t.y-1,t.z);if(!m||!f)return!1;let u={0:{x:0,z:-1},1:{x:-1,z:0},2:{x:0,z:1},3:{x:1,z:0}};switch(this.meshType){case"none":if(n===1&&t.canWalkThrough())return!0;if(m.canWalkOn()||m.isLadder()){if(t.meshType==="none"||t.meshType==="ladder"&&c===0||t.meshType==="wedge"&&n===0&&s===-u[t.ry].x&&i===-u[t.ry].z)return!0}return!1;case"ladder":if(c===1&&t.canWalkThrough())return!0;if(c===0&&m.canWalkOn())return!0;if(t.meshType==="ladder"&&(c===1||m.canWalkOn()&&f.canWalkOn()))return!0;return!1;case"wedge":if(this.x+u[this.ry].x===t.x&&this.z+u[this.ry].z===t.z&&this.y+1===t.y)return!0;if(this.x-u[this.ry].x===t.x&&this.z-u[this.ry].z===t.z&&(this.y===t.y||this.y-1===t.y))return!0;return!1;default:return!1}}flatCenter(){return{x:this.x+0.5,y:this.y+0,z:this.z+0.5}}flatRadialDistance(t){let e=this.flatCenter();return Math.hypot(e.x-t.x,e.z-t.z)}}class St{list=[];constructor(t){let e={};for(let i of Object.keys(t.data))for(let n of t.data[i])e[n.x<<16|n.y<<8|n.z]=!0,this.list.push(new Mt(i,n));for(let i=0;i<t.width;i++)for(let n=0;n<t.height;n++)for(let r=0;r<t.depth;r++)if(!e[i<<16|n<<8|r])this.list.push(new Mt("SPECIAL.air.none",{x:i,y:n,z:r}));let s=new Map;for(let i of this.list)s.set(i.positionStr,i);for(let i of this.list){let n=[{x:i.x+1,y:i.y,z:i.z},{x:i.x-1,y:i.y,z:i.z},{x:i.x,y:i.y+1,z:i.z},{x:i.x,y:i.y-1,z:i.z},{x:i.x,y:i.y,z:i.z+1},{x:i.x,y:i.y,z:i.z-1}];for(let r of n){let c=`${r.x},${r.y},${r.z}`,h=s.get(c);if(h&&i.canLink(h,this))i.links.push(h)}}}at(t,e,s){if(!this.nodeMap){this.nodeMap=new Map;for(let n of this.list){let r=`${n.x},${n.y},${n.z}`;this.nodeMap.set(r,n)}}let i=`${t},${e},${s}`;return this.nodeMap.get(i)}clean(){for(let t of this.list)t.f=0,t.g=0,t.h=0,t.visited=null,t.parent=null,t.closed=null}hasLineOfSight(t,e){let s=e.x-t.x,i=e.y-t.y,n=e.z-t.z,r=Math.max(Math.abs(s),Math.abs(i),Math.abs(n)),c=s/r,h=i/r,m=n/r,f=t.x,u=t.y,d=t.z;for(let k=0;k<=r;k++){let E=this.at(Math.round(f),Math.round(u),Math.round(d));if(E&&E.isFull())return!1;f+=c,u+=h,d+=m}return!0}}var Bt=async(t,e)=>{if(!w.isIsolated&&typeof process<"u"){let{existsSync:i,mkdirSync:n,readFileSync:r,writeFileSync:c}=process.getBuiltinModule("node:fs"),{join:h}=process.getBuiltinModule("node:path"),{homedir:m}=process.getBuiltinModule("node:os"),f=h(m(),".yolkbot");if(!i(f))n(f);let u=h(f,"maps");if(!i(u))n(u);let d=h(u,`${t}-${e}.json`);if(i(d))return JSON.parse(r(d,"utf-8"));let k=await(await fetch(`https://esm.sh/gh/yolkorg/maps/maps/${t}.json?${e}`)).json();return c(d,JSON.stringify(k,null,4),{flag:"w+"}),k}return await(await fetch(`https://esm.sh/gh/yolkorg/maps/maps/${t}.json?${e}`)).json()},Jt=(t)=>{let e=0,s={},i=[];for(let c of t){if(!s[c.x])s[c.x]={};if(!s[c.x][c.y])s[c.x][c.y]={};s[c.x][c.y][c.z]={zone:null}}let n=[{x:-1,z:0},{x:1,z:0},{x:0,z:-1},{x:0,z:1}],r=(c,h,m)=>s[c]&&s[c][h]&&s[c][h][m]?s[c][h][m]:null;for(let c of t)if(!s[c.x][c.y][c.z].zone){c.zone=++e,s[c.x][c.y][c.z].zone=c.zone;let h=[c],m;do{m=0;for(let f of t)if(!s[f.x][f.y][f.z].zone)for(let u of n){let d=r(f.x+u.x,f.y,f.z+u.z);if(d&&d.zone===c.zone){m++,f.zone=c.zone,s[f.x][f.y][f.z].zone=c.zone,h.push(f);break}}}while(m>0);i.push(h)}return i};var Kt=[];var H=[];var yt=[];var Ht=Object.fromEntries(Object.entries(M).map(([t,e])=>[e,t])),Yt=Object.fromEntries(Object.entries(gt).map(([t,e])=>[t[0].toLowerCase()+t.slice(1),e])),Zt={CHALLENGES:1,BOT_STATS:2,PATHFINDING:3,PING:5,COSMETIC_DATA:6,PLAYER_HEALTH:7,PACKET_HOOK:8,LOG_PACKETS:10,NO_LOGIN:11,DEBUG_BUFFER:12,NO_AFK_KICK:16,LOAD_MAP:17,OBSERVE_GAME:18,NO_REGION_CHECK:19,NO_EXIT_ON_ERROR:20,RENEW_SESSION:21,VIP_HIDE_BADGE:22},zt=(t,e)=>(t%e+e)%e;class Tt{static Intents=Zt;Intents=Zt;#t=[];#e={};#n=[];#s;#o;constructor(t={}){if(t.proxy&&w.isBrowser)this.processError("proxies do not work and hence are not supported in the browser");if(this.intents=t.intents||[],this.intents.includes(this.Intents.COSMETIC_DATA)){if(!l(1001))this.processError("you cannot use the COSMETIC_DATA intent inside of the singlefile browser bundles")}if(this.instance=t.instance||"shellshock.io",this.protocol=t.protocol||"wss",this.proxy=t.proxy||"",this.connectionTimeout=t.connectionTimeout||5000,this.state={name:"yolkbot",weaponIdx:0,useAltGameURL:!1,inGame:!1,chatLines:0,yaw:0,pitch:0,controlKeys:0,reloading:!1,swappingGun:!1,usingMelee:!1,stateIdx:0,serverStateIdx:0,shotsFired:0,buffer:[],left:!1},this.players={},this.me=new et({}),this.game={raw:{},code:"",socket:null,gameModeId:0,gameMode:Ht[0],mapIdx:0,map:{filename:"",hash:"",name:"",modes:{FFA:!1,Teams:!1,Spatula:!1,King:!1},availability:"both",numPlayers:"18",raw:{},nodes:{},zones:[]},playerLimit:0,isGameOwner:!1,isPrivate:!0,options:{gravity:1,damage:1,healthRegen:1,locked:!1,noTeamChange:!1,noTeamShuffle:!1,weaponsDisabled:Array(7).fill(!1),mustUseSecondary:!1},collectables:[[],[]],teamScore:[0,0,0],spatula:{coords:{x:0,y:0,z:0},controlledBy:0,controlledByTeam:0},stage:X.Capturing,zoneNumber:0,activeZone:[],capturing:0,captureProgress:0,numCapturing:0,capturePercent:0},this.#o=this.game,this.account={id:0,firebase:{idToken:"",refreshToken:"",expiresIn:"3600",localId:""},firebaseId:"",sessionId:"",session:0,email:"",password:"",cw:{atLimit:!1,limit:0,secondsUntilPlay:0,canPlayAgain:Date.now()},loadout:{hatId:null,meleeId:0,stampId:null,classIdx:0,colorIdx:0,grenadeId:0,primaryId:[3100,3600,3400,3800,4000,4200,4500],secondaryId:[,,,,,,,].fill(3000),stampPositionX:0,stampPositionY:0},ownedItemIds:[],vip:!1,emailVerified:!1,isAged:!1,eggBalance:0,adminRoles:0,rawLoginData:{},isDoubleEggWeeknd:()=>{let e=new Date().getUTCDay(),s=new Date().getUTCHours();return e>=5&&s>=20||e===6||e===0}},this.#s=this.account,this.matchmaker=null,this.api=new V({proxy:this.proxy,protocol:this.protocol,instance:this.instance,maxRetries:t?.apiMaxRetries,connectionTimeout:this.connectionTimeout}),this.ping=0,this.lastPingTime=-1,this.lastDeathTime=-1,this.lastUpdateTick=0,this.pathing={nodeList:null,followingPath:!1,activePath:null,activeNode:null,activeNodeIdx:0},this.hasQuit=!1,this.intents.includes(this.Intents.NO_AFK_KICK))this.afkKickInterval=0;if(this.intents.includes(this.Intents.RENEW_SESSION))this.renewSessionInterval=0}dispatch(t){if(t.validate(this)){if(t.check(this))t.execute(this);else this.#t.push(t);return!0}return!1}async createAccount(t,e){this.account=this.#s,this.account.email=t,this.account.password=e;let s=await this.api.createAccount(t,e);return this.processLoginData(s)}async login(t,e){this.account=this.#s,this.account.email=t,this.account.password=e;let s=await this.api.loginWithCredentials(t,e);return this.processLoginData(s)}async loginWithRefreshToken(t){this.account=this.#s;let e=await this.api.loginWithRefreshToken(t);return this.processLoginData(e)}async loginAnonymously(){this.account=this.#s;let t=await this.api.loginAnonymously();return this.processLoginData(t)}processLoginData(t){if(typeof t!=="object")return this.emit("authFail",t),t;if(t.banRemaining)return this.emit("banned",t.banRemaining),"account_banned";if(!t.playerOutput)return this.emit("authFail",t),t;if(this.account.firebase=t.firebase||{},t=t.playerOutput,this.account.rawLoginData=t,this.account.adminRoles=t.adminRoles||0,this.account.eggBalance=t.currentBalance,this.account.emailVerified=t.emailVerified,this.account.firebaseId=t.firebaseId,this.account.id=t.id,this.account.isAged=new Date(t.dateCreated).getTime()<1714546800000,this.account.loadout=t.loadout,this.account.ownedItemIds=t.ownedItemIds,this.account.session=t.session,this.account.sessionId=t.sessionId,this.account.vip=t.active_sub==="IsVIP",this.intents.includes(this.Intents.BOT_STATS))this.account.stats={lifetime:t.statsLifetime,monthly:t.statsCurrent};if(this.intents.includes(this.Intents.CHALLENGES))this.#i(t.challenges);if(this.emit("authSuccess",this.account),this.intents.includes(this.Intents.RENEW_SESSION))this.renewSessionInterval=setInterval(async()=>{if(!this.account?.sessionId)return clearInterval(this.renewSessionInterval);if((await this.api.queryServices({cmd:"renewSession",sessionId:this.account.sessionId})).data!=="renewed")this.emit("sessionExpired")},600000);return this.account}#i(t){this.account.challenges=[];for(let e of t){let s=Kt.find((i)=>i.id===e.challengeId);if(!s)continue;delete e.playerId,this.account.challenges.push({raw:{challengeInfo:s,challengeData:e},id:e.challengeId,name:s.loc.title,desc:s.loc.desc,rewardEggs:s.reward,isRerolled:!!e.reset,isClaimed:!!e.claimed,isCompleted:!!e.completed,progressNum:e.progress,goalNum:s.goal})}}async initMatchmaker(){if(!this.account.sessionId&&!this.intents.includes(this.Intents.NO_LOGIN)){let t=await this.loginAnonymously();if(typeof t!=="object")return t}if(!this.matchmaker){if(this.matchmaker=new Ut({api:this.api,proxy:this.proxy,protocol:this.protocol,instance:this.instance,sessionId:this.account.sessionId,connectionTimeout:this.connectionTimeout,noLogin:this.intents.includes(this.Intents.NO_LOGIN)}),!await this.matchmaker.ws.tryConnect())return"matchmaker_tryconnect_failed";this.matchmaker.on("authFail",(e)=>this.emit("authFail",e)),this.matchmaker.on("error",(e)=>this.processError(e))}return!0}async findPublicGame(t,e){if(typeof t!=="string")return"no_region_passed";if(!yt.find((i)=>i.id===t)&&!this.intents.includes(this.Intents.NO_REGION_CHECK))return"invalid_region_passed";if(typeof e!=="number")return"no_mode_passed";if(Object.values(M).indexOf(e)===-1)return"invalid_mode_passed";if(!await this.initMatchmaker())return"matchmaker_init_fail";return await new Promise((i)=>{let n=(r)=>{if(r.command==="notice")return;if(this.matchmaker.off("msg",n),r.command==="gameFound"){if(r.useAltGameURL)this.state.useAltGameURL=!0;return i(r)}if(r.error==="sessionNotFound")return i("internal_session_error");this.processError("unknown matchmaker response",JSON.stringify(r))};this.matchmaker.on("msg",n),this.matchmaker.send({command:"findGame",region:t,playType:I.JoinPublic,gameType:e,sessionId:this.account.sessionId})})}async createPrivateGame(t,e,s){if(typeof t!=="string")return"no_region_passed";if(!yt.find((r)=>r.id===t)&&!this.intents.includes(this.Intents.NO_REGION_CHECK))return"invalid_region_passed";if(typeof e!=="number")return"no_mode_passed";if(Object.values(M).indexOf(e)===-1)return"invalid_mode_passed";if(typeof s!=="string")return"no_map_passed";let i=H.findIndex((r)=>r.name.toLowerCase()===s.toLowerCase());if(i===-1)return"invalid_map_passed";if(!await this.initMatchmaker())return"matchmaker_init_fail";return await new Promise((r)=>{let c=(h)=>{if(h.command==="notice")return;if(this.matchmaker.off("msg",c),h.command==="gameFound"){if(h.useAltGameURL)this.state.useAltGameURL=!0;return r(h)}if(h.error==="sessionNotFound")return r("internal_session_error");this.processError("unknown matchmaker response",JSON.stringify(h))};this.matchmaker.on("msg",c),this.matchmaker.send({command:"findGame",region:t,playType:I.CreatePrivate,gameType:e,sessionId:this.account.sessionId,noobLobby:!1,map:i})})}async join(t,e){if(this.state.name=t||"yolkbot",typeof e==="string"){if(e.includes("#"))e=e.split("#")[1];if(!await this.initMatchmaker())return"matchmaker_init_fail";if(await new Promise((r)=>{let c=(h)=>{if(h.command==="gameFound")this.matchmaker.off("msg",c),this.game.raw=h,this.game.code=h.id,r(h.id);if(h.error&&h.error==="gameNotFound")return this.processError(`game "${e}" not found, it may have expired.`),this.leave(),"gameNotFound"};this.matchmaker.on("msg",c),this.matchmaker.send({command:"joinGame",id:e,observe:!1,sessionId:this.account.sessionId})})==="gameNotFound")return"game_not_found";if(!this.game.raw.id)return this.processError("an internal error occured while joining the game, please report this to developers")}if(typeof e==="object"){if(this.account.id===0)await this.loginAnonymously();if(this.game.raw=e,this.game.code=this.game.raw.id,!this.game.raw.id)return"invalid_game_object";if(!this.game.raw.subdomain)return"invalid_game_object";if(!this.game.raw.uuid)return"invalid_game_object"}let s=this.state.useAltGameURL?`${this.instance}/servers/${this.game.raw.subdomain}`:`${this.game.raw.subdomain}.${this.instance}`;if(this.game.socket=new F(`${this.protocol}://${s}/game/${this.game.raw.id}`,this.proxy),this.game.socket.binaryType="arraybuffer",this.game.socket.connectionTimeout=this.connectionTimeout,this.game.socket.onBeforeConnect=()=>{this.game.socket.onmessage=(n)=>this.processPacket(n.data),this.game.socket.onclose=(n)=>{if(this.state.left)this.state.left=!1;else this.emit("close",n.code),this.leave(-1)}},!await this.game.socket.tryConnect())return"websocket_tryconnect_fail";return!0}#r(){if(Object.entries(this.me.position).map((e)=>Math.floor(e[1])).join(",")===this.pathing.activePath[this.pathing.activePath.length-1].positionStr)this.pathing.followingPath=!1,this.pathing.activePath=null,this.pathing.activeNode=null,this.pathing.activeNodeIdx=0,this.dispatch(new K(0));else{let e;if(this.pathing.activeNodeIdx<this.pathing.activePath.length-1)e=this.pathing.activePath[this.pathing.activeNodeIdx+1].flatCenter(),this.dispatch(new J(e));else e=this.pathing.activePath[this.pathing.activeNodeIdx].flatCenter(),this.dispatch(new J(e));for(let s of this.pathing.activePath)if(s.flatRadialDistance(this.me.position)<0.1&&s.position.y===Math.floor(this.me.position.y)){if(this.pathing.activePath.indexOf(s)>=this.pathing.activeNodeIdx){this.pathing.activeNodeIdx=this.pathing.activePath.indexOf(s)+1,this.pathing.activeNode=this.pathing.activePath[this.pathing.activeNodeIdx];break}}if(!(this.state.controlKeys&S.Forward))this.dispatch(new K(S.Forward))}}update(){if(this.hasQuit)return;if(this.pathing.followingPath&&this.intents.includes(this.Intents.PATHFINDING))this.#r();for(let e=0;e<this.#t.length;e++){let s=this.#t[e];if(s.check(this))s.execute(this),this.#t.splice(e,1)}if(this.state.chatLines=Math.max(0,this.state.chatLines-0.008333333333333333),this.me.playing){let e=this.state.stateIdx;if(this.intents.includes(this.Intents.DEBUG_BUFFER))console.log("setting buffer for idx",e),console.log("checking...shotsFired",this.state.shotsFired);if(this.me.jumping=!!(this.state.controlKeys&S.Jump),this.state.buffer[e]={controlKeys:this.state.controlKeys,yaw:this.state.yaw,pitch:this.state.pitch,shotsFired:this.state.shotsFired},this.state.shotsFired=0,this.lastUpdateTick>=2){this.emit("tick");let s=new p;s.packInt8(a.syncMe),s.packInt8(this.state.stateIdx),s.packInt8(this.state.serverStateIdx);let i=zt(this.state.stateIdx-C+1,j);for(let n=0;n<C;n++){let r=zt(i+n,j),c=this.state.buffer[r]||{},h=c.controlKeys||0,m=c.shotsFired||0,f=c.yaw??this.state.yaw,u=c.pitch??this.state.pitch;if(this.intents.includes(this.Intents.DEBUG_BUFFER))console.log("going with",this.state.stateIdx,i,r,c);s.packInt8(h),s.packInt8(m),s.packString(qt(f,u)),s.packInt8(100)}s.send(this.game.socket),this.state.buffer=[],this.lastUpdateTick=0}else this.lastUpdateTick++;this.state.stateIdx=zt(this.state.stateIdx+1,j)}if(!this.intents.includes(this.Intents.PLAYER_HEALTH))return;let t=0.1*(this.game.isPrivate?this.game.options.healthRegen:1);for(let e of Object.values(this.players)){if(e.playing&&e.hp>0){let s=e.streakRewards.includes(g.OverHeal);e.hp+=s?-t:t,e.hp=s?Math.max(100,e.hp):Math.min(100,e.hp)}if(e.spawnShield>0)e.spawnShield-=6}}on(t,e){if(Object.keys(this.#e).includes(t))this.#e[t].push(e);else this.#e[t]=[e]}once(t,e){let s=(...i)=>{e(...i),this.off(t,s)};this.on(t,s)}onAny(t){this.#n.push(t)}off(t,e){if(e)this.#e[t]=this.#e[t].filter((s)=>s!==e);else this.#e[t]=[]}emit(t,...e){if(this.hasQuit)return;if(this.#e[t])for(let s of this.#e[t])s(...e);for(let s of this.#n)s(t,...e)}#c(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=o.unPackString().valueOf(),i=this.players[t];this.emit("chat",i,s,e)}#h(){let t=o.unPackInt8U(),e=this.intents.includes(this.Intents.COSMETIC_DATA),s={id:t,uniqueId:o.unPackString(),name:o.unPackString(),safeName:o.unPackString(),charClass:o.unPackInt8U(),team:o.unPackInt8U(),primaryWeaponItem:e?l(o.unPackInt16U()):o.unPackInt16U(),secondaryWeaponItem:e?l(o.unPackInt16U()):o.unPackInt16U(),shellColor:o.unPackInt8U(),hatItem:e?l(o.unPackInt16U()):o.unPackInt16U(),stampItem:e?l(o.unPackInt16U()):o.unPackInt16U(),stampPosX:o.unPackInt8(),stampPosY:o.unPackInt8(),grenadeItem:e?l(o.unPackInt16U()):o.unPackInt16U(),meleeItem:e?l(o.unPackInt16U()):o.unPackInt16U(),x:o.unPackFloat(),y:o.unPackFloat(),z:o.unPackFloat(),$dx:o.unPackFloat(),$dy:o.unPackFloat(),$dz:o.unPackFloat(),yaw:o.unPackRadU(),pitch:o.unPackRad(),score:o.unPackInt32U(),$kills:o.unPackInt16U(),$deaths:o.unPackInt16U(),$streak:o.unPackInt16U(),totalKills:o.unPackInt32U(),totalDeaths:o.unPackInt32U(),bestStreak:o.unPackInt16U(),$bestOverallStreak:o.unPackInt16U(),shield:o.unPackInt8U(),hp:o.unPackInt8U(),playing:o.unPackInt8U(),weaponIdx:o.unPackInt8U(),$controlKeys:o.unPackInt8U(),upgradeProductId:o.unPackInt8U(),activeShellStreaks:o.unPackInt8U(),social:o.unPackLongString(),hideBadge:o.unPackInt8U()};this.game.mapIdx=o.unPackInt8U(),this.game.isPrivate=o.unPackInt8U()===1,this.game.gameModeId=o.unPackInt8U();let i=new et(s,this.game.gameMode===M.KOTC?this.game.activeZone:null);if(!this.players[s.id])this.players[s.id]=i;if(this.emit("playerJoin",i),this.me.id===s.id)this.me=i,this.emit("botJoin",this.me)}#a(){let t=o.unPackInt8U(),e=o.unPackInt16U(),s=o.unPackFloat(),i=o.unPackFloat(),n=o.unPackFloat(),r=o.unPackInt8U(),c=o.unPackInt8U(),h=o.unPackInt8U(),m=o.unPackInt8U(),f=o.unPackInt8U(),u=this.players[t];if(u){if(u.playing=!0,u.randomSeed=e,u.weapons[0]&&u.weapons[0].ammo)u.weapons[0].ammo.rounds=r;if(u.weapons[0]&&u.weapons[0].ammo)u.weapons[0].ammo.store=c;if(u.weapons[1]&&u.weapons[1].ammo)u.weapons[1].ammo.rounds=h;if(u.weapons[1]&&u.weapons[1].ammo)u.weapons[1].ammo.store=m;u.grenades=f,u.position={x:s,y:i,z:n},u.spawnShield=120,this.emit("playerRespawn",u)}}#u(){let t=o.unPackInt8U(),e=o.unPackFloat(),s=o.unPackFloat(),i=o.unPackFloat(),n=o.unPackInt8U(),r=this.players[t];if(!r||r.id===this.me.id){for(let N=0;N<C;N++)o.unPackInt8U(),o.unPackRadU(),o.unPackRad(),o.unPackInt8U();return}for(let N=0;N<C;N++){let v=o.unPackInt8U();if(v&S.Jump)r.jumping=!0;else r.jumping=!1;if(v&S.Scope)r.scoping=!0;else r.scoping=!1;let A={...r.view};if(r.view.yaw=o.unPackRadU(),r.view.pitch=o.unPackRad(),r.view.yaw!==A.yaw||r.view.pitch!==A.pitch)this.emit("playerRotate",r,A,r.view);r.scale=o.unPackInt8U()}let c=r.position,h=c.x!==e||c.y!==s||c.z!==i,m=r.climbing!==n,f=h||m,u=f?{...c}:null;if(c.x!==e)c.x=e;if(c.z!==i)c.z=i;if(!r.jumping||Math.abs(c.y-s)>0.5)c.y=s;if(m)r.climbing=n;if(!f)return;if(this.emit("playerMove",r,u,c),this.game.gameModeId!==M.KOTC)return;let d=this.game.activeZone,k=!!r.inKotcZone;if(!d&&k){r.inKotcZone=!1,this.emit("playerLeaveZone",r);return}r.updateKotcZone(d);let E=!!r.inKotcZone;if(k!==E)r.inKotcZone=E,this.emit(E?"playerEnterZone":"playerLeaveZone",r)}#f(){let t=o.unPackInt8U(),e=this.players[t];if(e){if(e.playing=!1,e.streakRewards)e.streakRewards=[];if(this.emit("playerPause",e),e.inKotcZone)e.inKotcZone=!1,this.emit("playerLeaveZone",e)}}#m(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(s)s.activeGun=e,this.emit("playerSwapWeapon",s,e)}#p(){let t=o.unPackInt8U(),e=o.unPackInt8U();o.unPackInt8U(),o.unPackInt8U();let s=o.unPackInt8U(),i=this.players[t],n=this.players[e],r=i?{...i}:null;if(i){if(i.id===this.me.id)this.lastDeathTime=Date.now();i.playing=!1,i.streak=0,i.hp=100,i.spawnShield=0,i.stats.totalDeaths++,i.inKotcZone=!1,this.emit("playerLeaveZone",i)}if(n){if(n.streak++,n.stats.totalKills++,n.streak>n.stats.bestStreak)n.stats.bestStreak=n.streak}this.emit("playerDeath",i,n,r,s)}#d(){let t=o.unPackInt8U(),e={posX:o.unPackFloat(),posY:o.unPackFloat(),posZ:o.unPackFloat(),dirX:o.unPackFloat(),dirY:o.unPackFloat(),dirZ:o.unPackFloat()},s=this.players[t];if(!s)return;let i=s.weapons[s.activeGun];if(i&&i.ammo)i.ammo.rounds--,this.emit("playerFire",s,i,e)}#l(){let t=o.unPackInt16U(),e=o.unPackInt8U(),s=o.unPackFloat(),i=o.unPackFloat(),n=o.unPackFloat();this.game.collectables[e].push({id:t,x:s,y:i,z:n}),this.emit("spawnItem",e,{x:s,y:i,z:n},t)}#g(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=o.unPackInt8U(),i=o.unPackInt16U(),n=this.players[t];if(!n)return;if(this.game.collectables[e]=this.game.collectables[e].filter((r)=>r.id!==i),e===Q.Ammo){let r=n.weapons[s];if(r&&r.ammo)r.ammo.store=Math.min(r.ammo.storeMax,r.ammo.store+r.ammo.pickup),this.emit("playerCollectAmmo",n,r,i)}if(e===Q.Grenade){if(n.grenades++,n.grenades>3)n.grenades=3;this.emit("playerCollectGrenade",n,i)}}#x(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;let i=s.hp;s.hp=e,this.emit("playerDamage",s,i,s.hp)}#w(){let t=o.unPackInt8U();o.unPackFloat(),o.unPackFloat();let e=this.me.hp;this.me.hp=t,this.emit("playerDamage",this.me,e,this.me.hp)}#k(){let t=o.unPackInt8U(),e=this.players[t];o.unPackInt8U();let s=o.unPackInt8U(),i=o.unPackFloat(),n=o.unPackFloat(),r=o.unPackFloat();if(this.me.climbing=!!o.unPackInt8U(),o.unPackInt8U(),o.unPackInt8U(),!e)return;this.state.serverStateIdx=s;let c=e.position.x,h=e.position.y,m=e.position.z;if(e.position.x=i,e.position.y=n,e.position.z=r,c!==i||h!==n||m!==r)this.emit("playerMove",e,{x:c,y:h,z:m},{x:i,y:n,z:r})}#M(){let t=new p;t.packInt8(a.eventModifier),t.send(this.game.socket)}#S(){let t=o.unPackInt8U(),e={...this.players[t]};delete this.players[t],this.emit("playerLeave",e)}#y(){if(this.game.gameModeId===M.Spatula){let t={...this.game};this.game.teamScore[1]=o.unPackInt16U(),this.game.teamScore[2]=o.unPackInt16U();let e={x:o.unPackFloat(),y:o.unPackFloat(),z:o.unPackFloat()},s=o.unPackInt8U(),i=o.unPackInt8U();this.game.spatula={coords:e,controlledBy:s,controlledByTeam:i},this.emit("gameStateChange",t,this.game)}else if(this.game.gameModeId===M.KOTC){let t={...this.game};this.game.stage=o.unPackInt8U(),this.game.zoneNumber=o.unPackInt8U(),this.game.capturing=o.unPackInt8U(),this.game.captureProgress=o.unPackInt16U(),this.game.numCapturing=o.unPackInt8U(),this.game.teamScore[1]=o.unPackInt8U(),this.game.teamScore[2]=o.unPackInt8U(),this.game.capturePercent=this.game.captureProgress/1000,this.game.activeZone=this.game.map.zones?this.game.map.zones[this.game.zoneNumber-1]:null;let e=Object.values(this.players).filter((s)=>s.inKotcZone&&s.playing);if(this.game.activeZone)Object.values(this.players).forEach((s)=>s.updateKotcZone(this.game.activeZone));if(this.game.numCapturing<=0)Object.values(this.players).forEach((s)=>{s.inKotcZone=!1,this.emit("playerLeaveZone",s)});this.emit("gameStateChange",t,this.game,e)}else if(this.game.gameModeId===M.Team)this.game.teamScore[1]=o.unPackInt16U(),this.game.teamScore[2]=o.unPackInt16U();if(this.game.gameModeId!==M.Spatula)delete this.game.spatula;if(this.game.gameModeId!==M.KOTC)delete this.game.stage,delete this.game.zoneNumber,delete this.game.capturing,delete this.game.captureProgress,delete this.game.numCapturing,delete this.game.numCapturing,delete this.game.activeZone;if(this.game.gameModeId===M.FFA)delete this.game.teamScore}#z(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;switch(e){case g.HardBoiled:if(t===this.me.id)this.me.shieldHp=100;s.streakRewards.push(g.HardBoiled);break;case g.EggBreaker:s.streakRewards.push(g.EggBreaker);break;case g.Restock:{if(s.grenades=3,s.weapons[0]&&s.weapons[0].ammo)s.weapons[0].ammo.rounds=s.weapons[0].ammo.capacity,s.weapons[0].ammo.store=s.weapons[0].ammo.storeMax;if(s.weapons[1]&&s.weapons[1].ammo)s.weapons[1].ammo.rounds=s.weapons[1].ammo.capacity,s.weapons[1].ammo.store=s.weapons[1].ammo.storeMax;break}case g.OverHeal:s.hp=Math.min(200,s.hp+100),s.streakRewards.push(g.OverHeal);break;case g.DoubleEggs:s.streakRewards.push(g.DoubleEggs);break;case g.MiniEgg:s.scale=0.5,s.streakRewards.push(g.MiniEgg);break}this.emit("playerBeginStreak",s,e)}#T(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;if([g.EggBreaker,g.OverHeal,g.DoubleEggs,g.MiniEgg].includes(e)&&s.streakRewards.includes(e))s.streakRewards=s.streakRewards.filter((n)=>n!==e);if(e===g.MiniEgg)s.scale=1;this.emit("playerEndStreak",s,e)}#E(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=o.unPackFloat(),i=o.unPackFloat();if(!this.me)return;if(this.me.shieldHp=t,this.me.hp=e,this.me.shieldHp<=0)this.me.streakRewards=this.me.streakRewards.filter((n)=>n!==g.HardBoiled),this.emit("selfShieldLost",this.me.hp,{dx:s,dz:i});else this.emit("selfShieldHit",this.me.shieldHp,this.me.hp,{dx:s,dz:i})}#P(){let t={...this.game.options},e=o.unPackInt8U(),s=o.unPackInt8U(),i=o.unPackInt8U();if(e<1||e>4)e=4;if(s<0||s>8)s=4;if(i>16)i=4;this.game.options.gravity=e/4,this.game.options.damage=s/4,this.game.options.healthRegen=i/4;let n=o.unPackInt8U();Object.keys(Yt).forEach((r)=>{let c=n&Yt[r]?1:0;this.game.options[r]=c}),this.game.options.weaponsDisabled=Array.from({length:7},()=>o.unPackInt8U()===1),this.game.options.mustUseSecondary=this.game.options.weaponsDisabled.every((r)=>r),this.emit("gameOptionsChange",t,this.game.options)}#N(){let t=o.unPackInt8U();if(t===L.Pause)this.emit("gameForcePause"),setTimeout(()=>this.me.playing=!1,3000);if(t===L.Reset){if(Object.values(this.players).forEach((e)=>e.streak=0),this.game.gameModeId!==M.FFA)this.game.teamScore=[0,0,0];if(this.game.gameModeId===M.Spatula)this.game.spatula.controlledBy=0,this.game.spatula.controlledByTeam=0,this.game.spatula.coords={x:0,y:0,z:0};if(this.game.gameModeId===M.KOTC)this.game.stage=X.Capturing,this.game.zoneNumber=0,this.game.activeZone=null,this.game.capturing=0,this.game.captureProgress=0,this.game.numCapturing=0,this.game.capturePercent=0;this.emit("gameReset")}}#R(){if(!this.intents.includes(this.Intents.PING))return;let t=this.ping;this.ping=Date.now()-this.lastPingTime,this.emit("pingUpdate",t,this.ping),setTimeout(()=>{let e=new p;e.packInt8(a.ping),e.send(this.game.socket),this.lastPingTime=Date.now()},1000)}#G(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;let i=s.team;s.team=e,s.streak=0,this.emit("playerSwitchTeam",s,i,e)}#O(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=o.unPackInt16U(),i=o.unPackInt16U(),n=o.unPackInt8U(),r=o.unPackInt16U(),c=o.unPackInt16U(),h=o.unPackInt16U(),m=o.unPackInt16U(),f=o.unPackInt8(),u=o.unPackInt8(),d=this.intents.includes(this.Intents.COSMETIC_DATA),k=d?l(s):s,E=d?l(i):i,N=d?l(r):r,v=d?l(c):c,A=d?l(h):h,Y=d?l(m):m,x=this.players[t];if(x){let z={...x.character},Nt=x.selectedGun;if(x.character.eggColor=n,x.character.primaryGun=k,x.character.secondaryGun=E,x.character.stamp=v,x.character.hat=N,x.character.grenade=A,x.character.melee=Y,x.character.stampPos.x=f,x.character.stampPos.y=u,x.selectedGun=e,x.weapons[0]=new _[e],Nt!==x.selectedGun)this.emit("playerChangeGun",x,Nt,x.selectedGun);if(z!==x.character)this.emit("playerChangeCharacter",x,z,x.character)}}#_(){let t=o.unPackInt32U(),e=this.account.eggBalance;this.account.eggBalance=t,this.emit("balanceUpdate",e,t)}#v(){this.me.playing=!1,this.emit("respawnDenied")}#A(){let t=o.unPackInt8U(),e=this.players[t];if(e)this.emit("playerMelee",e)}#C(){let t=o.unPackInt8U(),e=this.players[t];if(!e)return;let s=e.weapons[e.activeGun];if(s.ammo){let i=Math.min(Math.min(s.ammo.capacity,s.ammo.reload)-s.ammo.rounds,s.ammo.store);s.ammo.rounds+=i,s.ammo.store-=i}this.emit("playerReload",e,s)}updateGameOptions(){let t=new p;t.packInt8(a.gameOptions),t.packInt8(this.game.options.gravity*4),t.packInt8(this.game.options.damage*4),t.packInt8(this.game.options.healthRegen*4);let e=(this.game.options.locked?1:0)|(this.game.options.noTeamChange?2:0)|(this.game.options.noTeamShuffle?4:0);t.packInt8(e),this.game.options.weaponsDisabled.forEach((s)=>{t.packInt8(s?1:0)}),t.send(this.game.socket)}#L(){this.game.isPrivate=!0,this.updateGameOptions()}#F(){let t=o.unPackInt8U(),e=o.unPackInt16U(),s=o.unPackFloat(),i=o.unPackFloat(),n=o.unPackFloat(),r=o.unPackInt8U(),c=o.unPackFloat();if(this.intents.includes(this.Intents.COSMETIC_DATA))e=l(e);if(t===P.Grenade)this.emit("grenadeExplode",e,{x:s,y:i,z:n},r,c);else this.emit("rocketHit",{x:s,y:i,z:n},r,c)}#q(){let t=o.unPackInt8U(),e=o.unPackFloat(),s=o.unPackFloat(),i=o.unPackFloat(),n=o.unPackFloat(),r=o.unPackFloat(),c=o.unPackFloat(),h=this.players[t];if(h)h.grenades--,this.emit("playerThrowGrenade",h,{x:e,y:s,z:i},{x:n,y:r,z:c})}#U(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;if(!this.intents.includes(this.Intents.CHALLENGES))return this.emit("challengeComplete",s,e);let i=this.account.challenges.find((n)=>n.id===e);if(this.emit("challengeComplete",s,i),s.id===this.me.id)this.refreshChallenges()}#W(){let t=new p;t.packInt8(this.intents.includes(this.Intents.OBSERVE_GAME)?a.observeGame:a.joinGame),t.packString(this.game.raw.uuid),t.packInt8(+this.intents.includes(this.Intents.VIP_HIDE_BADGE)),t.packInt8(this.state.weaponIdx||this.account?.loadout?.classIdx||0),t.packString(this.state.name),t.packInt32(this.account.session),t.packString(this.account.sessionId),t.packString(this.account.firebaseId),t.send(this.game.socket)}async#j(){if(this.me.id=o.unPackInt8U(),this.me.team=o.unPackInt8U(),this.game.gameModeId=o.unPackInt8U(),this.game.gameMode=Ht[this.game.gameModeId],this.game.mapIdx=o.unPackInt8U(),this.game.map=H[this.game.mapIdx],this.game.playerLimit=o.unPackInt8U(),this.game.isGameOwner=o.unPackInt8U()===1,this.game.isPrivate=o.unPackInt8U()===1||this.game.isGameOwner,o.unPackInt8U(),this.intents.includes(this.Intents.LOAD_MAP)||this.intents.includes(this.Intents.PATHFINDING)){if(this.game.map.raw=await Bt(this.game.map.filename,this.game.map.hash),this.emit("mapLoad",this.game.map.raw),this.game.gameModeId===M.KOTC){let e=this.game.map.raw.data["DYNAMIC.capture-zone.none"];if(e){if(this.game.map.zones=Jt(e),!this.game.activeZone)this.game.activeZone=this.game.map.zones[this.game.zoneNumber-1]}else delete this.game.map.zones}if(this.intents.includes(this.Intents.PATHFINDING))this.pathing.nodeList=new St(this.game.map.raw)}this.state.inGame=!0,this.lastDeathTime=Date.now();let t=new p;if(t.packInt8(a.clientReady),t.send(this.game.socket),this.updateIntervalId=setInterval(()=>this.update(),33.333333333333336),this.intents.includes(this.Intents.PING)){this.lastPingTime=Date.now();let e=new p;e.packInt8(a.ping),e.send(this.game.socket)}if(this.intents.includes(this.Intents.NO_AFK_KICK))this.afkKickInterval=setInterval(()=>{if(this.state.inGame&&!this.me.playing&&Date.now()-this.lastDeathTime>=15000){let e=new p;e.packInt8(a.keepAlive),e.send(this.game.socket)}},15000);this.emit("gameReady")}#$(){let t=o.unPackInt8U(),e=o.unPackString(128),s=o.unPackString(32),i=this.players[t];if(!i)return;i.admin={ip:s,dbId:e},this.emit("playerInfo",i,s,e)}packetHandlers={[a.syncThem]:()=>this.#u(),[a.fire]:()=>this.#d(),[a.hitThem]:()=>this.#x(),[a.syncMe]:()=>this.#k(),[a.hitMe]:()=>this.#w(),[a.swapWeapon]:()=>this.#m(),[a.collectItem]:()=>this.#g(),[a.respawn]:()=>this.#a(),[a.die]:()=>this.#p(),[a.pause]:()=>this.#f(),[a.chat]:()=>this.#c(),[a.addPlayer]:()=>this.#h(),[a.removePlayer]:()=>this.#S(),[a.eventModifier]:()=>this.#M(),[a.metaGameState]:()=>this.#y(),[a.beginShellStreak]:()=>this.#z(),[a.endShellStreak]:()=>this.#T(),[a.hitMeHardBoiled]:()=>this.#E(),[a.gameOptions]:()=>this.#P(),[a.ping]:()=>this.#R(),[a.switchTeam]:()=>this.#G(),[a.changeCharacter]:()=>this.#O(),[a.reload]:()=>this.#C(),[a.explode]:()=>this.#F(),[a.throwGrenade]:()=>this.#q(),[a.spawnItem]:()=>this.#l(),[a.melee]:()=>this.#A(),[a.updateBalance]:()=>this.#_(),[a.challengeCompleted]:()=>this.#U(),[a.socketReady]:()=>this.#W(),[a.gameJoined]:()=>this.#j(),[a.gameAction]:()=>this.#N(),[a.requestGameOptions]:()=>this.#L(),[a.respawnDenied]:()=>this.#v(),[a.playerInfo]:()=>this.#$(),[a.expireUpgrade]:()=>{},[a.clientReady]:()=>{},[a.musicInfo]:()=>o.unPackLongString()};processPacket(t){if(o.init(t),this.intents.includes(this.Intents.PACKET_HOOK))this.emit("packet",t);let e=0,s=0,i=!1;while(o.isMoreDataAvailable()&&!i){let n=o.unPackInt8U(),r=this.packetHandlers[n];if(r)r();else{if(console.error(`processPacket: I got but couldn't identify a: ${Object.keys(a).find((c)=>a[c]===n)} ${n}`),e)console.error(`processPacket: It may be a result of the ${e} command (${s}).`);i=!0;break}if(e=Object.keys(a).find((c)=>a[c]===n),s=n,this.intents.includes(this.Intents.LOG_PACKETS))console.log(`[LOG_PACKETS] Packet ${e}: ${s}`)}}async checkChiknWinner(){let t=await this.api.queryServices({cmd:"chicknWinnerReady",id:this.account.id,sessionId:this.account.sessionId});if(typeof t==="string")return t;return this.account.cw.limit=t.limit,this.account.cw.atLimit=t.limit>=4,this.account.cw.secondsUntilPlay=(this.account.cw.atLimit?t.period:t.span)||0,this.account.cw.canPlayAgain=Date.now()+this.account.cw.secondsUntilPlay*1000,this.account.cw}async playChiknWinner(t=!0){if(this.account.cw.atLimit||this.account.cw.limit>lt)return"hit_daily_limit";if(this.account.cw.canPlayAgain>Date.now()&&t)return"on_cooldown";let e=await this.api.queryServices({cmd:"incentivizedVideoReward",firebaseId:this.account.firebaseId,id:this.account.id,sessionId:this.account.sessionId,token:null});if(typeof e==="string")return e;if(e.error){if(e.error==="RATELIMITED"||e.error==="RATELMITED")return await this.checkChiknWinner(),"on_cooldown";else if(e.error==="SESSION_EXPIRED")return this.emit("sessionExpired"),"session_expired";return console.error("Unknown Chikn Winner response, report this on Github:",e),"unknown_error"}if(e.reward)return this.account.eggBalance+=e.reward.eggsGiven,e.reward.itemIds.forEach((s)=>this.account.ownedItemIds.push(s)),await this.checkChiknWinner(),e.reward;return console.error("Unknown Chikn Winner response, report this on Github:",e),"unknown_error"}async resetChiknWinner(){if(this.account.eggBalance<200)return"not_enough_eggs";if(!this.account.cw.atLimit)return"not_at_limit";let t=await this.api.queryServices({cmd:"chwReset",sessionId:this.account.sessionId});if(typeof t==="string")return t;if(t.result!=="SUCCESS")return console.error("Unknown Chikn Winner reset response, report this on Github:",t),"unknown_error";return this.account.eggBalance-=200,await this.checkChiknWinner(),this.account.cw}canSee(t){if(!this.intents.includes(this.Intents.PATHFINDING))return this.processError("You must have the PATHFINDING intent to use this method.");return this.pathing.nodeList.hasLineOfSight(this.me.position,t.position)}async refreshChallenges(){let t=await this.api.queryServices({cmd:"challengeGetDaily",sessionId:this.account.sessionId,playerId:this.account.id});if(typeof t==="string")return t;return this.#i(t),this.account.challenges}async rerollChallenge(t){let e=await this.api.queryServices({cmd:"challengeRerollSlot",sessionId:this.account.sessionId,slotId:t});if(typeof e==="string")return e;return this.#i(e),this.account.challenges}async claimChallenge(t){let e=await this.api.queryServices({cmd:"challengeClaimReward",sessionId:this.account.sessionId,slotId:t});if(typeof e==="string")return e;if(this.#i(e.challenges),e.reward>0)this.account.eggBalance+=e.reward;return{eggReward:e.reward,updatedChallenges:this.account.challenges}}async refreshBalance(){let t=await this.api.queryServices({cmd:"checkBalance",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId});if(typeof t==="string")return t;return this.account.eggBalance=t.currentBalance,t.currentBalance}async redeemCode(t){let e=await this.api.queryServices({cmd:"redeem",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,id:this.account.id,code:t});if(typeof e==="string")return e;if(e.result==="SUCCESS")return this.account.eggBalance=e.eggs_given,e.item_ids.forEach((s)=>this.account.ownedItemIds.push(s)),{result:e,eggsGiven:e.eggs_given,itemIds:e.item_ids};return e}async claimURLReward(t){let e=await this.api.queryServices({cmd:"urlRewardParams",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,reward:t});if(typeof e==="string")return e;if(e.result==="SUCCESS")this.account.eggBalance+=e.eggsGiven,e.itemIds.forEach((s)=>this.account.ownedItemIds.push(s));return e}async claimSocialReward(t){let e=await this.api.queryServices({cmd:"reward",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,rewardTag:t});if(typeof e==="string")return e;if(e.result==="SUCCESS")this.account.eggBalance+=e.eggsGiven,e.itemIds.forEach((s)=>this.account.ownedItemIds.push(s));return e}async buyItem(t){let e=await this.api.queryServices({cmd:"buy",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,itemId:t,save:!0});if(typeof e==="string")return e;if(e.result==="SUCCESS")this.account.eggBalance=e.currentBalance,this.account.ownedItemIds.push(e.itemId);return e}processError(...t){let e=t.join(" ");if(this.#e.error&&this.#e.error.length)this.emit("error",e);else if(this.intents.includes(this.Intents.NO_EXIT_ON_ERROR))console.error(e);else throw Error(e)}leave(t=b.mainMenu){if(this.hasQuit)return;if(t>-1)this.game?.socket?.close(t),this.state.left=!0,this.emit("leave",t);clearInterval(this.updateIntervalId),this.#t=[],this.state.inGame=!1,this.state.chatLines=0,this.state.reloading=!1,this.state.swappingGun=!1,this.state.usingMelee=!1,this.state.stateIdx=0,this.state.serverStateIdx=0,this.state.shotsFired=0,this.state.buffer=[],this.players={},this.me=new et({}),this.game=this.#o,this.ping=0,this.lastPingTime=-1,this.lastDeathTime=-1,this.lastUpdateTick=0,this.pathing={nodeList:null,followingPath:!1,activePath:null,activeNode:null,activeNodeIdx:0}}logout(){if(this.account=this.#s,this.intents.includes(this.Intents.RENEW_SESSION))clearInterval(this.renewSessionInterval)}quit(t=!1){if(this.hasQuit)return;if(this.leave(),this.matchmaker){if(this.matchmaker.close(),!t)delete this.matchmaker}if(!t)delete this.account,delete this.api,delete this.game,delete this.me,delete this.pathing,delete this.players,delete this.state,this.#s={},this.#o={},this.#e={},this.#n=[],this.#t=[];if(this.intents.includes(this.Intents.NO_AFK_KICK))clearInterval(this.afkKickInterval);if(this.intents.includes(this.Intents.RENEW_SESSION))clearInterval(this.renewSessionInterval);this.hasQuit=!0}}class Qt{constructor(t,e,s=""){this.uniqueId=t,this.duration=e,this.reason=s}validate(t){if(typeof this.uniqueId!=="string"||typeof this.reason!=="string")return!1;if(typeof this.duration!=="number"||!Object.values(dt).some((e)=>this.duration===e))return!1;if(!(t.account.adminRoles&4))return!1;return!0}check(){return!0}execute(t){let e=new p;e.packInt8(a.banPlayer),e.packString(this.uniqueId),e.packString(this.reason),e.packInt8(this.duration),e.send(t.game.socket)}}var Xt=Qt;class It{constructor(t){this.uniqueId=t}validate(t){return typeof this.uniqueId==="string"&&t.game.isGameOwner&&Object.values(t.players).find((e)=>e.uniqueId===this.uniqueId)}check(){return!0}execute(t){let e=new p;e.packInt8(a.bootPlayer),e.packString(this.uniqueId),e.send(t.game.socket)}}var Dt=It;class Vt{constructor(t){this.msg=t}validate(){if(typeof this.msg!=="string")return!1;if(this.msg.length<1||this.msg.length>64)return!1;return!0}check(t){if(!t.state?.inGame)return!1;if(!t.game.isPrivate&&!t.account.adminRoles&&t.state.chatLines>=2)return!1;if(!t.game.isPrivate&&!t.account.emailVerified&&!t.account.isAged)return!1;return!0}execute(t){t.state.chatLines++;let e=new p;e.packInt8(a.chat),e.packString(this.msg),e.send(t.game.socket)}}var bt=Vt;class te{constructor(t){this.amount=t||1}validate(){return this.amount>=1}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee&&t.me.weapons[t.me.activeGun].ammo.rounds>=this.amount}execute(t){t.state.shotsFired+=this.amount||1}}var ee=te;var es=Array.from({length:4},(t,e)=>(e+1)*0.25),ss=Array.from({length:9},(t,e)=>e*0.25),is=Array.from({length:17},(t,e)=>e*0.25),y=(t,e)=>typeof t>"u"?e:t;class se{constructor(t){this.changes=t}#t(t){let e={};if(e.gravity=y(this.changes.gravity,t.game.options.gravity),e.damage=y(this.changes.damage,t.game.options.damage),e.healthRegen=y(this.changes.healthRegen,t.game.options.healthRegen),e.locked=y(this.changes.locked,t.game.options.locked),e.noTeamChange=y(this.changes.noTeamChange,t.game.options.noTeamChange),e.noTeamShuffle=y(this.changes.noTeamShuffle,t.game.options.noTeamShuffle),e.weaponsDisabled=[y(this.changes.disableEggk,t.game.options.weaponsDisabled[0]),y(this.changes.disableScrambler,t.game.options.weaponsDisabled[1]),y(this.changes.disableFreeRanger,t.game.options.weaponsDisabled[2]),y(this.changes.disableRPG,t.game.options.weaponsDisabled[3]),y(this.changes.disableWhipper,t.game.options.weaponsDisabled[4]),y(this.changes.disableCrackshot,t.game.options.weaponsDisabled[5]),y(this.changes.disableTriHard,t.game.options.weaponsDisabled[6])],this.changes.toDisable&&Array.isArray(this.changes.toDisable))this.changes.toDisable.forEach((s)=>e.weaponsDisabled[s]=!0);if(this.changes.toEnable&&Array.isArray(this.changes.toEnable))this.changes.toEnable.forEach((s)=>e.weaponsDisabled[s]=!1);if(this.changes.rawWeaponsDisabled&&Array.isArray(this.changes.rawWeaponsDisabled)&&this.changes.rawWeaponsDisabled.length===7)e.weaponsDisabled=this.changes.rawWeaponsDisabled.map((s)=>!!s);return e.mustUseSecondary=e.weaponsDisabled.every((s)=>s),e}validate(t){let e=this.#t(t);if(!es.includes(e.gravity))return!1;if(!ss.includes(e.damage))return!1;if(!is.includes(e.healthRegen))return!1;if(typeof e.locked!=="boolean")return!1;if(typeof e.noTeamChange!=="boolean")return!1;if(typeof e.noTeamShuffle!=="boolean")return!1;if(!Array.isArray(e.weaponsDisabled))return!1;if(e.weaponsDisabled.length!==7)return!1;if(e.weaponsDisabled.some((s)=>typeof s!=="boolean"))return!1;return!0}check(t){return t.game.isGameOwner}execute(t){t.game.options=this.#t(t),t.updateGameOptions()}}var ie=se;class Et{constructor(t){this.content=[],this.scoreFunction=t}push(t){this.content.push(t),this.bubbleUp(this.content.length-1)}rescoreElement(t){this.sinkDown(this.content.indexOf(t))}pop(){let t=this.content[0],e=this.content.pop();if(this.content.length>0)this.content[0]=e,this.sinkDown(0);return t}remove(t){let e=this.content.length;for(let s=0;s<e;s++){if(this.content[s]!==t)continue;let i=this.content.pop();if(s===e-1)break;this.content[s]=i,this.bubbleUp(s),this.sinkDown(s);break}}size(){return this.content.length}bubbleUp(t){let e=this.content[t],s=this.scoreFunction(e);while(t>0){let i=Math.floor((t+1)/2)-1,n=this.content[i];if(s>=this.scoreFunction(n))break;this.content[i]=e,this.content[t]=n,t=i}}includes(t){return this.content.includes(t)}sinkDown(t){let e=this.content.length,s=this.content[t],i=this.scoreFunction(s);while(!0){let n=(t+1)*2,r=n-1,c=null,h;if(r<e){let m=this.content[r];if(h=this.scoreFunction(m),h<i)c=r}if(n<e){let m=this.content[n];if(this.scoreFunction(m)<(c===null?i:h))c=n}if(c===null)break;this.content[t]=this.content[c],this.content[c]=s,t=c}}}class T{constructor(t){this.list=t}heuristic(t,e){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)+Math.abs(t.z-e.z)}reversePath(t){let e=[];while(t.parent)e.push(t),t=t.parent;return e.reverse(),e}path(t,e){this.list.clean();let s=new Et((n)=>n.f),i=[];t.h=this.heuristic(t,e),t.g=0,t.f=t.g+t.h,s.push(t);while(s.size()!==0){let n=s.pop();if(n===e)return this.reversePath(n);i.push(n);let r=n.links;for(let c=0;c<r.length;c++){let h=r[c];if(i.includes(h))continue;let m=n.g+1,f=h.visited;if(!f||m<h.g)if(h.visited=!0,h.parent=n,h.g=m,h.h=this.heuristic(h.position,e.position),h.f=h.g+h.h,f)s.rescoreElement(h);else s.push(h)}}return null}}class oe{validate(t){return t.intents.includes(t.Intents.PATHFINDING)}check(t){return t.me.playing&&t.game.collectables[0].length}execute(t){this.pather=new T(t.pathing.nodeList);let e=200,s=null;for(let h of t.game.collectables[0]){let m=h.x-t.me.position.x,f=h.y-t.me.position.y,u=h.z-t.me.position.z,d=Math.sqrt(m*m+f*f+u*u);if(d<e)e=d,s=h}let i=Object.entries(t.me.position).map((h)=>Math.floor(h[1])),n=Object.entries(s).map((h)=>Math.floor(h[1])),r=t.pathing.nodeList.at(...i),c=t.pathing.nodeList.at(...n);if(t.pathing.activePath=this.pather.path(r,c),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var ne=oe;class re{validate(t){return t.intents.includes(t.Intents.PATHFINDING)}check(t){return t.me.playing&&t.game.zoneNumber&&t.game.activeZone}execute(t){this.pather=new T(t.pathing.nodeList);let e=200,s=null;for(let h of t.game.activeZone){let m=h.x-t.me.position.x,f=h.y-t.me.position.y,u=h.z-t.me.position.z,d=Math.sqrt(m*m+f*f+u*u);if(d<e)e=d,s=h}let i=Object.entries(t.me.position).map((h)=>Math.floor(h[1])),n=Object.entries(s).map((h)=>Math.floor(h[1])),r=t.pathing.nodeList.at(...i),c=t.pathing.nodeList.at(...n);if(t.pathing.activePath=this.pather.path(r,c),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var ce=re;class he{validate(t){return t.intents.includes(t.Intents.PATHFINDING)}check(t){return t.me.playing&&t.game.collectables[1].length}execute(t){this.pather=new T(t.pathing.nodeList);let e=200,s=null;for(let h of t.game.collectables[1]){let m=h.x-t.me.position.x,f=h.y-t.me.position.y,u=h.z-t.me.position.z,d=Math.sqrt(m*m+f*f+u*u);if(d<e)e=d,s=h}let i=Object.entries(t.me.position).map((h)=>Math.floor(h[1])),n=Object.entries(s).map((h)=>Math.floor(h[1])),r=t.pathing.nodeList.at(...i),c=t.pathing.nodeList.at(...n);if(t.pathing.activePath=this.pather.path(r,c),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var ae=he;class ue{idOrName;constructor(t){this.idOrName=t}validate(t){if(!t.intents.includes(t.Intents.PATHFINDING))return!1;if(!this.idOrName)return!1;return!!(t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName))}check(t){if(!t.me.playing)return!1;let e=t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName);return e&&e.playing&&e.position&&e.position.x}execute(t){this.pather=new T(t.pathing.nodeList);let e=t.players[this.idOrName.toString()]||t.players.find((c)=>c.name===this.idOrName),s=Object.entries(t.me.position).map((c)=>Math.floor(c[1])),i=Object.entries(e.position).map((c)=>Math.floor(c[1])),n=t.pathing.nodeList.at(...s),r=t.pathing.nodeList.at(...i);if(t.pathing.activePath=this.pather.path(n,r),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var fe=ue;class me{validate(t){return t.intents.includes(t.Intents.PATHFINDING)}check(t){return t.me.playing&&t.game.spatula&&t.game.spatula.coords&&t.game.spatula.coords.x}execute(t){this.pather=new T(t.pathing.nodeList);let e=Object.entries(t.me.position).map((r)=>Math.floor(r[1])),s=Object.entries(t.game.spatula.coords).map((r)=>Math.floor(r[1])),i=t.pathing.nodeList.at(...e),n=t.pathing.nodeList.at(...s);if(t.pathing.activePath=this.pather.path(i,n),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var pe=me;var os=(t,e)=>(t%e+e)%e,ns=Math.PI*2,de=(t)=>Math.round(t*8192)/8192,rs=(t)=>de(os(Math.atan2(-t.x,-t.z),ns)),cs=(t)=>de(Math.atan2(t.y,Math.hypot(t.x,t.z)));class le{idOrName;constructor(t){this.idOrName=t}validate(t){return!!(t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName))}check(t){if(!t.me.playing)return!1;let e=t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName);return e&&e.playing&&e.position&&e.position.x}execute(t){let e=t.players[this.idOrName.toString()]||t.players.find((r)=>r.name===this.idOrName),s={x:e.position.x-t.me.position.x,y:e.position.y-t.me.position.y-0.05,z:e.position.z-t.me.position.z},i=rs(s),n=cs(s);t.state.yaw=i,t.state.pitch=n}}var ge=le;class xe{validate(){return!0}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee}execute(t){let e=new p;e.packInt8(a.melee),e.send(t.game.socket),t.usingMelee=!0,setTimeout(()=>{t.usingMelee=!1,t.swappingGun=!0,setTimeout(()=>{t.swappingGun=!1},0.5*xt)},566.6666666666667)}}var we=xe;class ke{validate(){return!0}check(t){return t.me.playing}execute(t){let e=new p;e.packInt8(a.pause),e.send(t.game.socket),setTimeout(()=>t.me.playing=!1,3000)}}var Me=ke;class Se{validate(){return!0}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee}execute(t){let e=new p;e.packInt8(a.reload),e.send(t.game.socket);let s=t.me.weapons[t.me.activeGun];if(s.ammo){let r=Math.min(Math.min(s.ammo.capacity,s.ammo.reload)-s.ammo.rounds,s.ammo.store);s.ammo.rounds+=r,s.ammo.store-=r}t.emit("playerReload",t.me,s);let i=t.me.weapons[t.me.activeGun],n=i.ammo.rounds<1;t.state.reloading=!0,setTimeout(()=>t.state.reloading=!1,n?i.longReloadTime:i.shortReloadTime)}}var ye=Se;class ze{constructor(t,e={}){if(this.idOrName=t,this.reasons=[!!e.cheating,!!e.harassment,!!e.offensive,!!e.other],!this.reasons.includes(!0))this.reasons[3]=!0;for(let s=0;s<this.reasons.length;s++)if(this.reasons[s]===!0)this.reasonInt|=1<<s}validate(t){if(this.reasons.every((s)=>s===!1))return!1;if(!(t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName)))return!1;return!0}check(t){if(!t.state.inGame)return!1;return!!(t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName))}execute(t){let e=t.players[this.idOrName.toString()]||t.players.find((i)=>i.name===this.idOrName),s=new p;s.packInt8(a.reportPlayer),s.packString(e.uniqueId),s.packInt8(this.reasonInt),s.send(t.game.socket)}}var Te=ze;class Ee{validate(){return!0}check(t){return t.game.isGameOwner}execute(t){let e=new p;e.packInt8(a.gameAction),e.packInt8(L.Reset),e.send(t.game.socket)}}var Pe=Ee;var q=(t)=>l(t)&&l(t).unlock==="default",U=(t,e)=>l(t)&&l(t).item_type_id===e;class Ne{constructor(t){this.changes={classIdx:t.gunId,hatId:t.hatId,stampId:t.stampId,grenadeId:t.grenadeId,meleeId:t.meleeId,colorIdx:t.eggColor,primaryId:t.primaryIds,secondaryId:t.secondaryIds},this.changes=Object.fromEntries(Object.entries(this.changes).filter(([,e])=>!!e))}validate(t){let e=this.changes;if(e.colorIdx&&e.colorIdx>=7&&!t.account.vip)return!1;if(e.colorIdx&&e.colorIdx>=14)return!1;if(U(e.hatId,P.Hat)&&!q(e.hatId)&&!t.account.ownedItemIds.includes(e.hatId))return!1;if(U(e.stampId,P.Stamp)&&!q(e.stampId)&&!t.account.ownedItemIds.includes(e.stampId))return!1;if(U(e.grenadeId,P.Grenade)&&!q(e.grenadeId)&&!t.account.ownedItemIds.includes(e.grenadeId))return!1;if(U(e.meleeId,P.Melee)&&!q(e.meleeId)&&!t.account.ownedItemIds.includes(e.meleeId))return!1;if(typeof e.classIdx==="number"&&e.classIdx>6||e.classIdx<0)return!1;if(this.changes.primaryId)for(let s=0;s<7;s++){let i=this.changes.primaryId[s];if(!U(i,P.Primary)||!q(i)&&!t.account.ownedItemIds.includes(i))return!1}if(this.changes.secondaryId)for(let s=0;s<7;s++){let i=this.changes.secondaryId[s];if(!U(i,P.Secondary)||!q(i)&&!t.account.ownedItemIds.includes(i))return!1}return!0}check(t){return!t.me.playing}execute(t){if(t.me&&this.changes.classIdx&&this.changes.classIdx!==t.me.selectedGun)t.me.weapons[0]=new _[this.changes.classIdx];t.state.weaponIdx=this.changes.classIdx||t.state.weaponIdx;let e={...t.account.loadout,...this.changes},s=t.api.queryServices({cmd:"saveLoadout",save:!0,firebaseId:t.account.firebaseId,sessionId:t.account.sessionId,loadout:e});if(t.account.loadout=e,t.me)s.then(()=>{if(t.state.inGame){let n=new p;n.packInt8(a.changeCharacter),n.packInt8(this.changes?.classIdx||t.me.selectedGun),n.send(t.game.socket)}let i=t.intents.includes(t.Intents.COSMETIC_DATA);Object.entries(this.changes).forEach(([n,r])=>{if(n==="classIdx")t.me.selectedGun=r;else if(n==="hatId")t.me.character.hat=i?l(r):r;else if(n==="stampId")t.me.character.stamp=i?l(r):r;else if(n==="grenadeId")t.me.character.grenade=i?l(r):r;else if(n==="meleeId")t.me.character.melee=i?l(r):r;else if(n==="colorIdx")t.me.character.eggColor=r;else if(n==="primaryId")t.me.character.primaryGun=i?l(r[t.me.selectedGun]):r;else if(n==="secondaryId")t.me.character.secondaryGun=i?l(r[t.me.selectedGun]):r})})}}var Re=Ne;class Ge{validate(){return!0}check(t){if(t.me.playing)return!1;if(t.lastDeathTime+6000<Date.now())return!1;if(t.intents.includes(t.Intents.OBSERVE_GAME))return!1;return!0}execute(t){let e=new p;e.packInt8(a.requestRespawn),e.send(t.game.socket),t.state.buffer=[]}}var Oe=Ge;class _e{constructor(t){this.manualWeapon=t}validate(){return typeof this.manualWeapon==="number"||typeof this.manualWeapon>"u"}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee}execute(t){let e=+!t.me.activeGun;if(typeof this.manualWeapon==="number")e=this.manualWeapon;t.me.activeGun=e;let s=new p;s.packInt8(a.swapWeapon),s.packInt8(t.me.activeGun),s.send(t.game.socket)}}var ve=_e;class Ae{validate(){return!0}check(t){if(!t.state.inGame||t.me.playing)return!1;if(t.game.gameModeId===0)return!1;if(t.intents.includes(t.Intents.OBSERVE_GAME))return!1;if(t.game.isPrivate)return!t.game.options.noTeamChange;let e=t.players,s=t.me.team,i=e.filter((r)=>r.team===s).length,n=e.filter((r)=>r.team!==s).length;if(n>i)return!1;if(i===n)return!1;return!0}execute(t){let e=new p;e.packInt8(a.switchTeam),e.send(t.game.socket)}}var Ce=Ae;class Le{constructor(t=1){this.power=t}validate(){return typeof this.power==="number"&&this.power>=0&&this.power<=1}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee}execute(t){let e=new p;e.packInt8(a.throwGrenade),e.packFloat(this.power),e.send(t.game.socket)}}var Fe=Le;var qe={BanPlayerDispatch:Xt,BootPlayerDispatch:Dt,ChatDispatch:bt,FireDispatch:ee,GameOptionsDispatch:ie,GoToAmmoDispatch:ne,GoToCoopDispatch:ce,GoToGrenadeDispatch:ae,GoToPlayerDispatch:fe,GoToSpatulaDispatch:pe,LookAtDispatch:ge,LookAtPosDispatch:J,MeleeDispatch:we,MovementDispatch:K,PauseDispatch:Me,ReloadDispatch:ye,ReportPlayerDispatch:Te,ResetGameDispatch:Pe,SaveLoadoutDispatch:Re,SpawnDispatch:Oe,SwapWeaponDispatch:ve,SwitchTeamDispatch:Ce,ThrowGrenadeDispatch:Fe};var Pt={};it(Pt,{CommOut:()=>p,CommIn:()=>o,CommCode:()=>a,CloseCode:()=>b});var hs={API:D,Bot:Tt,GamePlayer:tt,Matchmaker:st,Dispatches:qe,Comm:Pt,Constants:kt,Guns:pt,Maps:H};window.yolkbot=hs;if(window.onYolkReady&&typeof window.onYolkReady==="function")console.warn("window.onYolkReady is no longer required as of yolkbot 1.3.0. You don't have to put your code inside it anymore."),window.onYolkReady();
|
package/browser/build/module.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var qe=Object.defineProperty;var tt=(t,e)=>{for(var s in e)qe(t,s,{get:e[s],enumerable:!0,configurable:!0,set:(i)=>e[s]=()=>i})};var Ue=globalThis.fetch,Tt=Ue;console.error("wwws does not support the browser.");var Et=null;var W={},Z=typeof window<"u"&&typeof HTMLElement<"u",et=typeof WebSocketPair<"u"&&typeof Cloudflare<"u",Pt=typeof process<"u"&&process.moduleLoadList?.length>0,Nt=typeof Deno<"u",Gt=typeof process<"u"&&!!process.versions?.bun;if(!Z&&!et&&!Pt&&!Nt&&!Gt)throw Error("yolkbot doesn't know how to run in this environment. Please open an issue on GitHub with information on where you run yolkbot.");W.isBrowser=Z;W.isIsolated=!Pt&&!Nt&&!Gt;W.fetch=Z||et?globalThis.fetch:Tt;W.WebSocket=Z||et?globalThis.WebSocket:Et;var w=W;var Rt={};tt(Rt,{findItemById:()=>l,UserAgent:()=>$,URLRewards:()=>Ke,Team:()=>Je,StateBufferSize:()=>j,SocialReward:()=>Be,SocialMedia:()=>dt,ShellStreak:()=>g,PlayType:()=>X,Movement:()=>S,ItemType:()=>P,GunList:()=>_,GunEquipTime:()=>pt,GameOptionFlag:()=>mt,GameMode:()=>M,GameAction:()=>L,FramesBetweenSyncs:()=>C,FirebaseKey:()=>R,CoopState:()=>Q,CollectType:()=>Y,ChiknWinnerDailyLimit:()=>ft,ChatFlag:()=>$e,ChallengeType:()=>je,ChallengeSubType:()=>We,BanDuration:()=>ut});var Ot={};tt(Ot,{SMG:()=>ct,RPEGG:()=>nt,M24:()=>ht,Eggk47:()=>st,DozenGauge:()=>it,Cluck9mm:()=>rt,CSG1:()=>ot,AUG:()=>at});var G=class{constructor(){this.adsMod=0.5,this.burst=0,this.burstRof=0,this.movementAccuracyMod=1,this.radius=0,this.reloadBloom=!0,this.reloadTimeMod=1,this.tracer=0}},st=class extends G{constructor(){super();this.ammo={rounds:30,capacity:30,reload:30,store:240,storeMax:240,pickup:30},this.longReloadTime=205,this.shortReloadTime=160,this.weaponName="EggK-47",this.internalName="Eggk47",this.standardMeshName="eggk47",this.automatic=!0,this.damage=30,this.range=20,this.recoil=7,this.rof=3,this.totalDamage=30,this.velocity=1.5,this.accuracyMin=0.15,this.accuracyMax=0.03,this.accuracyLoss=0.05,this.accuracyRecover=0.025,this.tracer=1}},it=class extends G{constructor(){super();this.ammo={rounds:2,capacity:2,reload:2,store:24,storeMax:24,pickup:8},this.longReloadTime=155,this.shortReloadTime=155,this.weaponName="Scrambler",this.internalName="Dozen Gauge",this.standardMeshName="dozenGauge",this.automatic=!1,this.damage=8.5,this.range=8,this.recoil=10,this.rof=8,this.totalDamage=170,this.velocity=1,this.accuracyMin=0.16,this.accuracyMax=0.13,this.accuracyLoss=0.17,this.accuracyRecover=0.02,this.adsMod=0.6,this.movementAccuracyMod=0.2,this.tracer=0}},ot=class extends G{constructor(){super();this.ammo={rounds:15,capacity:15,reload:15,store:60,storeMax:60,pickup:15},this.longReloadTime=225,this.shortReloadTime=165,this.weaponName="Free Ranger",this.internalName="CSG-1",this.standardMeshName="csg1",this.automatic=!1,this.damage=105,this.range=50,this.recoil=13,this.rof=13,this.totalDamage=105,this.velocity=1.75,this.accuracyMin=0.3,this.accuracyMax=0.004,this.accuracyLoss=0.3,this.accuracyRecover=0.025,this.tracer=0}},rt=class extends G{constructor(){super();this.ammo={rounds:15,capacity:15,reload:15,store:60,storeMax:60,pickup:15},this.longReloadTime=195,this.shortReloadTime=160,this.weaponName="Cluck 9mm",this.internalName="Cluck 9mm",this.standardMeshName="cluck9mm",this.automatic=!1,this.damage=26,this.range=15,this.recoil=6,this.rof=4,this.totalDamage=26,this.velocity=1,this.accuracyMin=0.15,this.accuracyMax=0.035,this.accuracyLoss=0.09,this.accuracyRecover=0.08,this.adsMod=0.8,this.movementAccuracyMod=0.6,this.tracer=0}},nt=class extends G{constructor(){super();this.ammo={rounds:1,capacity:1,reload:1,store:3,storeMax:3,pickup:1},this.longReloadTime=170,this.shortReloadTime=170,this.weaponName="RPEGG",this.internalName="Eggsploder",this.standardMeshName="rpegg",this.automatic=!1,this.damage=140,this.range=45,this.recoil=60,this.rof=40,this.totalDamage=192.5,this.velocity=0.4,this.accuracyMin=0.3,this.accuracyMax=0.015,this.accuracyLoss=0.3,this.accuracyRecover=0.02,this.radius=2.75}},ct=class extends G{constructor(){super();this.ammo={rounds:40,capacity:40,reload:40,store:200,storeMax:200,pickup:40},this.longReloadTime=225,this.shortReloadTime=190,this.weaponName="Whipper",this.internalName="SMEGG",this.standardMeshName="smg",this.automatic=!0,this.damage=23,this.range=20,this.recoil=7,this.rof=2,this.totalDamage=23,this.velocity=1.25,this.accuracyMin=0.19,this.accuracyMax=0.06,this.accuracyLoss=0.045,this.accuracyRecover=0.05,this.adsMod=0.6,this.movementAccuracyMod=0.7,this.tracer=2}},ht=class extends G{constructor(){super();this.ammo={rounds:1,capacity:1,reload:1,store:12,storeMax:12,pickup:4},this.longReloadTime=144,this.shortReloadTime=144,this.weaponName="Crackshot",this.internalName="M2DZ",this.standardMeshName="m24",this.automatic=!0,this.damage=170,this.range=60,this.recoil=20,this.rof=15,this.totalDamage=170,this.velocity=2,this.accuracyMin=0.35,this.accuracyMax=0,this.accuracyLoss=0.1,this.accuracyRecover=0.023,this.movementAccuracyMod=1.3,this.reloadBloom=!1,this.reloadTimeMod=0.8,this.tracer=0}},at=class extends G{constructor(){super();this.ammo={rounds:24,capacity:24,reload:24,store:150,storeMax:150,pickup:24},this.longReloadTime=205,this.shortReloadTime=160,this.weaponName="Tri-Hard",this.internalName="AUG",this.standardMeshName="aug",this.automatic=!1,this.damage=32,this.range=20,this.recoil=18,this.rof=15,this.totalDamage=34,this.velocity=1.5,this.accuracyMin=0.15,this.accuracyMax=0.03,this.accuracyLoss=0.037,this.accuracyRecover=0.03,this.adsMod=0.6,this.burst=3,this.burstRof=3,this.movementAccuracyMod=0.8,this.movementInstability=2,this.tracer=0}};var l=()=>null;var ut={FiveMinutes:0,FifteenMinutes:1,OneHour:2},We={Killstreak:0,KillWithWeapon:1,MovementDistance:3,Jumping:4,TimePlayed:6,TimeAlive:7,KillWithCondition:8,TotalKills:10,SpatulaKills:10,Collecting:18,FromTheCoop:20,SpecialOffensive:21,WinKOTC:23,KillWithSpatula:23},je={Kill:0,Damage:1,Death:2,Movement:3,Collect:4,Time:5,KOTC:6,Spatula:7},$e={None:0,Pinned:2,Team:4,Mod:254,Server:255},ft=3,Y={Ammo:0,Grenade:1},Q={Start:0,Score:1,Win:2,Capturing:3,Contested:4,Takeover:5,Abandoned:6,Unclaimed:7},R="AIzaSyDP4SIjKaw6A4c-zvfYxICpbEjn1rRnN50",C=3,L={Reset:1,Pause:2},M={FFA:0,Team:1,Spatula:2,KOTC:3},mt={Locked:1,NoTeamChange:2,NoTeamShuffle:4},pt=13,_=[st,it,ot,nt,ct,ht,at],P={Hat:1,Stamp:2,Primary:3,Secondary:4,Grenade:6,Melee:7},S={Forward:1,Backward:2,Left:4,Right:8,Jump:16,Fire:32,Melee:64,Scope:128},X={JoinPublic:0,CreatePrivate:1,JoinPrivate:2},g={HardBoiled:1,EggBreaker:2,Restock:4,OverHeal:8,DoubleEggs:16,MiniEgg:32},dt={Facebook:0,Instagram:1,Tiktok:2,Discord:3,Youtube:4,Twitter:5,Twitch:6},Be={Discord:"rew_1200",Tiktok:"rew_1208",Instagram:"rew_1219",Steam:"rew_1223",Facebook:"rew_1227",Twitter:"rew_1234",Twitch:"rew_twitch_social"},j=256,Je={Blue:1,Red:2},Ke=["giveBasketBrosReward","mercZoneFinalGift","midMonthGiveMeEggs","newYolkerSignupReward","newYolkerItemReward","newYolkerWelcomeBack","WelcomeBack"],$=w.isBrowser?null:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36";class _t{url="";proxy="";binaryType="";maxRetries=5;connectionTimeout=5000;constructor(t,e){if(w.isBrowser&&e)throw Error("You cannot pass a proxy to a WebSocket in a browser.");this.url=t,this.proxy=e}async tryConnect(t=1){let e=new URL(this.url),s=async()=>{if(t===5)return!1;return await this.tryConnect(t+1)};try{if(this.socket=w.isBrowser?new w.WebSocket(this.url):new w.WebSocket(this.url,{proxy:this.proxy||null,headers:{"accept-encoding":"gzip, deflate, br, zstd","accept-language":"en-US,en;q=0.9","cache-control":"no-cache",connection:"Upgrade",origin:e.origin.replace("ws","http"),pragma:"no-cache","sec-websocket-extensions":"permessage-deflate; client_max_window_bits","user-agent":$}}),this.binaryType)this.socket.binaryType=this.binaryType}catch(i){return console.error(`Failed to connect on try ${t}, trying again...`,i),await s()}if(this.onBeforeConnect)this.onBeforeConnect();return new Promise((i)=>{let r=setTimeout(async()=>{this.socket.close(),i(await s())},this.connectionTimeout),n=async(c)=>{clearTimeout(r),console.error("WebSocket error",c),i(await s())};this.socket.addEventListener("open",async()=>{clearTimeout(r),this.socket.removeEventListener("error",n),i(!0)}),this.socket.addEventListener("error",n)})}get onmessage(){return this.socket?.onmessage}set onmessage(t){if(this.socket)this.socket.onmessage=t;else console.error("set onmessage before socket existed")}get onclose(){return this.socket?.onclose}set onclose(t){if(this.socket)this.socket.onclose=t;else console.error("set onclose before socket existed")}get onerror(){return this.socket?.onerror}set onerror(t){if(this.socket)this.socket.onerror=t;else console.error("set onclose before socket existed")}send(t){return this.socket?.send(t)}close(t){return this.socket?.close(t)}}var F=_t;var B={origin:"https://shellshock.io","user-agent":$,"x-client-version":"Chrome/JsCore/9.17.2/FirebaseCore-web","x-firebase-locale":"en"};class lt{constructor(t={}){this.proxy=t.proxy,this.instance=t.instance||"shellshock.io",this.protocol=t.protocol||"wss",this.maxRetries=t.maxRetries||5,this.suppressErrors=t.suppressErrors||!1,this.connectionTimeout=t.connectionTimeout||5000}queryServices=async(t)=>{let e=new F(`${this.protocol}://${this.instance}/services/`,this.proxy);if(e.connectionTimeout=this.connectionTimeout,!await e.tryConnect(-2)||e.socket.readyState!==1)return"websocket_connect_fail";return new Promise((i)=>{let r=!1;e.onmessage=(n)=>{r=!0;try{let c=JSON.parse(n.data);i(c)}catch{if(!this.suppressErrors)console.error("queryServices: Bad API JSON response with call:",t.cmd,"and data:",JSON.stringify(t)),console.error("queryServices: Full data sent:",JSON.stringify(t));i("bad_json")}e.close()},e.onerror=()=>!r&&i("unknown_socket_error"),e.onclose=()=>!r&&i("services_closed_early"),e.send(JSON.stringify(t))})};#t=async(t,e,s)=>{if(!t||!e)return"firebase_no_credentials";let i,r;try{i=await(await w.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:${s}?key=${R}`,{method:"POST",body:JSON.stringify({email:t,password:e,returnSecureToken:!0}),headers:{...B,"content-type":"application/json"},proxy:this.proxy})).json(),r=i.idToken}catch(c){if(c.code==="auth/network-request-failed"){if(!this.suppressErrors)console.error("loginWithCredentials: Network req failed (auth/network-request-failed)");return"firebase_network_failed"}else if(c.code==="auth/missing-email")return"firebase_no_credentials";else if(c.code==="ERR_BAD_REQUEST"){if(!this.suppressErrors)console.error("loginWithCredentials: Error:",t,e);if(!this.suppressErrors)console.error("loginWithCredentials: Error:",i||c);return"firebase_bad_request"}if(!this.suppressErrors)console.error("loginWithCredentials: Error:",t,e,c);return"firebase_unknown_error"}if(!r){if(!this.suppressErrors)console.error("loginWithCredentials: the game sent no idToken",i);return"firebase_no_token"}this.idToken=r;let n=await this.queryServices({cmd:"auth",firebaseToken:r});return typeof n==="object"?{firebase:i,...n}:n};createAccount=async(t,e)=>await this.#t(t,e,"signUp");loginWithCredentials=async(t,e)=>await this.#t(t,e,"signInWithPassword");loginWithRefreshToken=async(t)=>{if(!t)return"firebase_no_credentials";let e=new URLSearchParams;e.append("grant_type","refresh_token"),e.append("refresh_token",t);let s,i;try{s=await(await w.fetch(`https://securetoken.googleapis.com/v1/token?key=${R}`,{method:"POST",body:e,headers:{...B,"content-type":"application/x-www-form-urlencoded"},proxy:this.proxy})).json(),i=s.id_token}catch(n){if(n.code==="auth/network-request-failed"){if(!this.suppressErrors)console.error("loginWithRefreshToken: Network req failed (auth/network-request-failed)");return"firebase_network_failed"}else if(n.code==="auth/missing-email")return"firebase_no_credentials";if(!this.suppressErrors)console.error("loginWithRefreshToken: Error:",n,t);return"firebase_unknown_error"}if(!i){if(!this.suppressErrors)console.error("loginWithRefreshToken: the game sent no idToken",s);return"firebase_no_token"}this.idToken=i;let r=await this.queryServices({cmd:"auth",firebaseToken:i});return typeof r==="object"?{firebase:s,...r}:r};loginAnonymously=async()=>{let e=await(await w.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=${R}`,{method:"POST",body:JSON.stringify({returnSecureToken:!0}),headers:{...B,"content-type":"application/json"},proxy:this.proxy})).json(),s=e.idToken;if(!s){if(!this.suppressErrors)console.error("loginAnonymously: the game sent no idToken",e);return"firebase_no_token"}this.idToken=s;let i=await this.queryServices({cmd:"auth",firebaseToken:s});return typeof i==="object"?{firebase:e,...i}:i};sendEmailVerification=async(t=this.idToken)=>{if(!t)return"no_idtoken_passed";let s=await(await w.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode?key=${R}`,{method:"POST",body:JSON.stringify({requestType:"VERIFY_EMAIL",idToken:t}),headers:{...B,"content-type":"application/json"},proxy:this.proxy})).json();if(s.kind!=="identitytoolkit#GetOobConfirmationCodeResponse"){if(!this.suppressErrors)console.error("sendEmailVerification: the game sent an invalid response",s);return"firebase_invalid_response"}return{email:s.email}};verifyOobCode=async(t)=>{if(!t)return"no_oob_code_passed";let s=await(await w.fetch(`https://www.googleapis.com/identitytoolkit/v3/relyingparty/setAccountInfo?key=${R}`,{method:"POST",body:JSON.stringify({oobCode:t}),headers:{...B,"x-client-version":"Chrome/JsCore/3.7.5/FirebaseCore-web",referer:"https://shellshockio-181719.firebaseapp.com/","content-type":"application/json"},proxy:this.proxy})).json();if(!s.emailVerified){if(!this.suppressErrors)console.error("verifyOobCode: the game sent an invalid response",s);return"firebase_invalid_response"}return s.email}}var I=lt;class At{static buffer;static idx;static init(t){this.buffer=new Uint8Array(t),this.idx=0}static isMoreDataAvailable(){return Math.max(0,this.buffer.length-this.idx)}static unPackInt8U(){let t=this.idx;return this.idx++,this.buffer[t]}static unPackInt8(){return(this.unPackInt8U()+128)%256-128}static unPackInt16U(){let t=this.idx;return this.idx+=2,this.buffer[t]+this.buffer[t+1]*256}static unPackInt24U(){let t=this.idx;return this.idx+=3,this.buffer[t]+this.buffer[t+1]*256+this.buffer[t+2]*65536}static unPackInt32U(){let t=this.idx;return this.idx+=4,this.buffer[t]+this.buffer[t+1]*256+this.buffer[t+2]*65536+this.buffer[t+3]*16777216}static unPackInt16(){return(this.unPackInt16U()+32768)%65536-32768}static unPackInt32(){return(this.unPackInt32U()+2147483648)%4294967296-2147483648}static unPackRadU(){return this.unPackInt24U()/2097152}static unPackRad(){return this.unPackInt16U()/8192-Math.PI}static unPackFloat(){return this.unPackInt16()/256}static unPackDouble(){return this.unPackInt32()/1048576}static unPackString(t){t=t||255;let e=Math.min(this.unPackInt8U(),t);return this.unPackStringHelper(e)}static unPackLongString(t){t=t||16383;let e=Math.min(this.unPackInt16U(),t);return this.unPackStringHelper(e)}static unPackStringHelper(t){if(this.isMoreDataAvailable()<t)return 0;let s="";for(let i=0;i<t;i++){let r=this.unPackInt16U();if(r>0)s+=String.fromCodePoint(r)}return s}}var o=At;class vt{constructor(t=16384){this.idx=0,this.arrayBuffer=new ArrayBuffer(t),this.buffer=new Uint8Array(this.arrayBuffer,0,t)}send(t){let e=new Uint8Array(this.arrayBuffer,0,this.idx);t.send(e)}packInt8(t){this.buffer[this.idx]=t&255,this.idx++}packInt16(t){this.buffer[this.idx]=t&255,this.buffer[this.idx+1]=t>>8&255,this.idx+=2}packInt24(t){this.buffer[this.idx]=t&255,this.buffer[this.idx+1]=t>>8&255,this.buffer[this.idx+2]=t>>16&255,this.idx+=3}packInt32(t){this.buffer[this.idx]=t&255,this.buffer[this.idx+1]=t>>8&255,this.buffer[this.idx+2]=t>>16&255,this.buffer[this.idx+3]=t>>24&255,this.idx+=4}packRadU(t){this.packInt24(t*2097152)}packRad(t){this.packInt16((t+Math.PI)*8192)}packFloat(t){this.packInt16(t*256)}packDouble(t){this.packInt32(t*1048576)}packString(t){if(typeof t!=="string")t="";this.packInt8(t.length);for(let e=0;e<t.length;e++)this.packInt16(t.charCodeAt(e))}packLongString(t){if(typeof t!=="string")t="";this.packInt16(t.length);for(let e=0;e<t.length;e++)this.packInt16(t.charCodeAt(e))}}var p=vt;var He={gameNotFound:4000,gameFull:4001,badName:4002,mainMenu:4003,gameIdleExceeded:4004,corruptedLoginData0:4005,corruptedLoginData1:4006,corruptedLoginData2:4007,corruptedLoginData3:4008,corruptedLoginData4:4009,corruptedLoginData5:4010,gameMaxPlayersExceeded:4011,gameDestroyUser:4012,joinGameOutOfOrder:4013,gameShuttingDown:4014,readyBeforeReady:4015,booted:4016,gameErrorOnUserSocket:4017,uuidNotFound:4018,sessionNotFound:4019,clusterFullCpu:4020,clusterFullMem:4021,noClustersAvailable:4022,locked:4023},D=He;var Ze={},a=Ze;var Ye=Object.fromEntries(Object.entries(dt).map(([t,e])=>[e,t.toLowerCase()]));class gt{constructor(t,e=null){if(this.id=t.id,this.uniqueId=t.uniqueId,this.name=t.name,this.safeName=t.safeName,this.team=t.team,this.playing=t.playing,this.socials=t.social&&JSON.parse(t.social),this.socials)this.socials.forEach((s)=>s.type=Ye[s.id]);if(this.isVip=t.upgradeProductId>0,this.showBadge=!t.hideBadge||!1,this.streak=t.score,this.streakRewards=Object.values(g).filter((s)=>t.activeShellStreaks&s),this.scale=this.streakRewards.includes(g.MiniEgg)?0.5:1,this.position={x:t.x,y:t.y,z:t.z},this.jumping=t.$controlKeys&S.Jump,this.scoping=t.$controlKeys&S.Scope,this.climbing=!1,this.view={yaw:t.yaw,pitch:t.pitch},this.updateKotcZone(e),this.character={eggColor:t.shellColor,primaryGun:t.primaryWeaponItem,secondaryGun:t.secondaryWeaponItem,stamp:t.stampItem,hat:t.hatItem,grenade:t.grenadeItem,melee:t.meleeItem,stampPos:{x:t.stampPosX,y:t.stampPosY}},this.stats={totalKills:t.totalKills,totalDeaths:t.totalDeaths,bestStreak:t.bestStreak},this.activeGun=t.weaponIdx,this.selectedGun=t.charClass,this.weapons=[],this.character.primaryGun)this.weapons[0]=new _[this.selectedGun],this.weapons[1]=new rt;this.grenades=1,this.hp=t.hp,this.hpShield=0,this.spawnShield=t.shield,this.randomSeed=0}updateKotcZone(t){if(!t)return this.inKotcZone=!1;let e=Math.floor(this.position.x),s=Math.floor(this.position.y),i=Math.floor(this.position.z);this.inKotcZone=t.some((r)=>r.x===e&&r.y===s&&r.z===i)&&this.playing}}var V=gt;var Qe=(t)=>new Uint8Array(t.match(/.{2}/g).map((e)=>parseInt(e,16))),Xe=new TextEncoder,Ct=async(t)=>{if(typeof process<"u"&&typeof process.getBuiltinModule==="function"){let r=process.getBuiltinModule("node:crypto"),n=Buffer.from("3496afb51f42553e31635211400c000b","hex");return r.createHmac("sha256",n).update(t).digest("hex")}let e=Qe("3496afb51f42553e31635211400c000b"),s=await crypto.subtle.importKey("raw",e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),i=await crypto.subtle.sign("HMAC",s,Xe.encode(t));return Array.from(new Uint8Array(i)).map((r)=>r.toString(16).padStart(2,"0")).join("")},O=(t)=>{return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(t-1050359)},Lt=(t,e)=>{let s=Math.round(t/(Math.PI*2)*65535),i=0,r=Math.round((e+1.5)/3*32767),n=s<0?0:s;s=n>65535?65535:n;let c=Math.trunc(s);if(c<0)c=0;if(c>4294967295)c=4294967295;c=s>=0?c:0,c=s>65535?0:c;let h=c;i^=h;let m=r<0?0:r;s=m,m=s>32767?32767:s,s=m;let f=Math.trunc(s);if(f<0)f=0;if(f>4294967295)f=4294967295;f=s>=0?f:0,f=s>65535?0:f;let u=f,d=u,k=i^d,E=k&255,N=i<<8,A=(i&65280)>>>8;u=(N|A)>>>0;let H=E^u;k=k<<8|(k&65280)>>>8,h^=d,d=k^h&255,h=h<<8|(h&65280)>>>8,i=h^i&255;let z=[];return z[3]=O(1050359+(d&63)),z[7]=O(1050359+(u>>>8&63)),z[4]=O(1050359+(k>>>10&63)),z[0]=O(1050359+((i&252)>>>2)),z[5]=O(1050359+(k>>>4&48|H>>>4&15)),z[2]=O(1050359+(h>>>6&60|d>>>6&3)),z[6]=O(1050359+((u>>>14&3|H<<2)&63)),z[1]=O(1050359+((h>>>12&15|i<<4)&63)),String.fromCharCode(...z)};class xt{connected=!1;onceConnected=[];regionList=[];proxy=null;sessionId="";onListeners=new Map;onceListeners=new Map;#t=!1;#e=!1;constructor(t={}){if(this.#t=t.noExitOnError||!1,!t.instance)t.instance="shellshock.io";if(!t.protocol)t.protocol="wss";if(t.api)this.api=t.api;else this.api=new I({proxy:t.proxy,protocol:t.protocol,instance:t.instance,connectionTimeout:t.connectionTimeout});if(t.sessionId||t.noLogin)this.sessionId=t.sessionId;else this.#s();if(t.proxy&&w.isBrowser)this.#i("proxies do not work and hence are not supported in the browser");else if(t.proxy)this.proxy=t.proxy;this.#r(t.instance,t.protocol,t.noLogin,t.connectionTimeout)}async#r(t,e,s,i){if(this.ws=new F(`${e}://${t}/matchmaker/`,this.proxy),this.ws.connectionTimeout=i||5000,!await this.ws.tryConnect())return this.#i("WebSocket did not connect...");if(this.ws.onmessage=async(n)=>{let c=JSON.parse(n.data);if(c.command==="validateUUID")return this.ws.send(JSON.stringify({command:"validateUUID",hash:await Ct(c.uuid)}));this.#o("msg",c)},this.ws.onclose=()=>{if(this.connected=!1,!this.#e)this.#r(t,e,s,i)},this.connected=!0,this.sessionId||s)this.onceConnected.forEach((n)=>n())}async#s(){let t=await this.api.loginAnonymously();if(!t||typeof t==="string")this.#o("authFail",t);if(this.sessionId=t.sessionId,this.connected)this.onceConnected.forEach((e)=>e())}send(t){this.ws.send(JSON.stringify(t))}async waitForConnect(){return new Promise((t)=>{if(this.connected)t();else this.onceConnected.push(t)})}async getRegions(){await this.waitForConnect();let t=this;return new Promise((e)=>{let s=(i)=>{if(i.command==="regionList")this.regionList=i.regionList,this.off("msg",s),e(i.regionList)};this.on("msg",s),this.ws.onerror=(i)=>t.#i("failed to get regions",i),this.ws.send(JSON.stringify({command:"regionList"}))})}close(){this.#e=!0,this.connected=!1,this.ws.close()}on(t,e){if(!this.onListeners.has(t))this.onListeners.set(t,[]);this.onListeners.get(t).push(e)}once(t,e){if(!this.onceListeners.has(t))this.onceListeners.set(t,[]);this.onceListeners.get(t).push(e)}off(t,e){if(this.onListeners.has(t))this.onListeners.set(t,this.onListeners.get(t).filter((s)=>s!==e));if(this.onceListeners.has(t))this.onceListeners.set(t,this.onceListeners.get(t).filter((s)=>s!==e))}#o(t,...e){if(this.onListeners.has(t))this.onListeners.get(t).forEach((s)=>s(...e));if(this.onceListeners.has(t))this.onceListeners.get(t).forEach((s)=>s(...e)),this.onceListeners.delete(t)}#i(t){if(this.onListeners.has("error"))this.#o("error",t);else if(this.#t)console.error(t);else throw Error(t)}}var Ft=xt;var Ie=(t,e)=>(t%e+e)%e,De=Math.PI*2,qt=(t)=>Math.round(t*8192)/8192,Ve=(t)=>qt(Ie(Math.atan2(-t.x,-t.z),De)),be=(t)=>qt(Math.atan2(t.y,Math.hypot(t.x,t.z)));class Ut{constructor(t){this.pos=t}validate(){return this.pos&&this.pos.x&&this.pos.y&&this.pos.z}check(t){return t.me.playing}execute(t){let e={x:this.pos.x-t.me.position.x,y:this.pos.y-t.me.position.y,z:this.pos.z-t.me.position.z},s=Ve(e),i=be(e);t.state.yaw=s,t.state.pitch=i}}var J=Ut;class Wt{constructor(t){if(typeof t==="number")this.inputKeys=t;else if(typeof t==="object")this.inputKeys=t.reduce((e,s)=>e|s,0)}validate(){if(typeof this.inputKeys!=="number")return!1;if(this.inputKeys&S.Forward&&this.inputKeys&S.Backward)return!1;if(this.inputKeys&S.Left&&this.inputKeys&S.Right)return!1;return!0}check(t){return t.me.playing}execute(t){t.state.controlKeys=this.inputKeys}}var K=Wt;class wt{constructor(t,e){if(this.x=e.x,this.y=e.y,this.z=e.z,this.positionStr=`${this.x},${this.y},${this.z}`,this.position={x:this.x,y:this.y,z:this.z},this.meshType=t.split(".").pop(),this.f=0,this.g=0,this.h=0,this.visited=null,this.parent=null,this.closed=null,this.links=[],this.isStair())if(e.ry)this.ry=e.ry;else this.ry=0}isFull(){return this.meshType==="full"}canWalkThrough(){return this.meshType==="none"||this.meshType==="ladder"}canWalkOn(){return this.meshType==="full"}isLadder(){return this.meshType==="ladder"}isStair(){return this.meshType==="wedge"}isAir(){return this.meshType==="none"}canLink(t,e){let s=this.x-t.x,i=this.z-t.z,r=this.y-t.y,n=Math.abs(s),c=Math.abs(r),h=Math.abs(i);if(n+c+h===0||n+h>1||this.isFull()||t.isFull())return!1;let m=e.at(this.x,this.y-1,this.z),f=e.at(t.x,t.y-1,t.z);if(!m||!f)return!1;let u={0:{x:0,z:-1},1:{x:-1,z:0},2:{x:0,z:1},3:{x:1,z:0}};switch(this.meshType){case"none":if(r===1&&t.canWalkThrough())return!0;if(m.canWalkOn()||m.isLadder()){if(t.meshType==="none"||t.meshType==="ladder"&&c===0||t.meshType==="wedge"&&r===0&&s===-u[t.ry].x&&i===-u[t.ry].z)return!0}return!1;case"ladder":if(c===1&&t.canWalkThrough())return!0;if(c===0&&m.canWalkOn())return!0;if(t.meshType==="ladder"&&(c===1||m.canWalkOn()&&f.canWalkOn()))return!0;return!1;case"wedge":if(this.x+u[this.ry].x===t.x&&this.z+u[this.ry].z===t.z&&this.y+1===t.y)return!0;if(this.x-u[this.ry].x===t.x&&this.z-u[this.ry].z===t.z&&(this.y===t.y||this.y-1===t.y))return!0;return!1;default:return!1}}flatCenter(){return{x:this.x+0.5,y:this.y+0,z:this.z+0.5}}flatRadialDistance(t){let e=this.flatCenter();return Math.hypot(e.x-t.x,e.z-t.z)}}class kt{list=[];constructor(t){let e={};for(let i of Object.keys(t.data))for(let r of t.data[i])e[r.x<<16|r.y<<8|r.z]=!0,this.list.push(new wt(i,r));for(let i=0;i<t.width;i++)for(let r=0;r<t.height;r++)for(let n=0;n<t.depth;n++)if(!e[i<<16|r<<8|n])this.list.push(new wt("SPECIAL.air.none",{x:i,y:r,z:n}));let s=new Map;for(let i of this.list)s.set(i.positionStr,i);for(let i of this.list){let r=[{x:i.x+1,y:i.y,z:i.z},{x:i.x-1,y:i.y,z:i.z},{x:i.x,y:i.y+1,z:i.z},{x:i.x,y:i.y-1,z:i.z},{x:i.x,y:i.y,z:i.z+1},{x:i.x,y:i.y,z:i.z-1}];for(let n of r){let c=`${n.x},${n.y},${n.z}`,h=s.get(c);if(h&&i.canLink(h,this))i.links.push(h)}}}at(t,e,s){if(!this.nodeMap){this.nodeMap=new Map;for(let r of this.list){let n=`${r.x},${r.y},${r.z}`;this.nodeMap.set(n,r)}}let i=`${t},${e},${s}`;return this.nodeMap.get(i)}clean(){for(let t of this.list)t.f=0,t.g=0,t.h=0,t.visited=null,t.parent=null,t.closed=null}hasLineOfSight(t,e){let s=e.x-t.x,i=e.y-t.y,r=e.z-t.z,n=Math.max(Math.abs(s),Math.abs(i),Math.abs(r)),c=s/n,h=i/n,m=r/n,f=t.x,u=t.y,d=t.z;for(let k=0;k<=n;k++){let E=this.at(Math.round(f),Math.round(u),Math.round(d));if(E&&E.isFull())return!1;f+=c,u+=h,d+=m}return!0}}var jt=async(t,e)=>{if(!w.isIsolated&&typeof process<"u"){let{existsSync:i,mkdirSync:r,readFileSync:n,writeFileSync:c}=process.getBuiltinModule("node:fs"),{join:h}=process.getBuiltinModule("node:path"),{homedir:m}=process.getBuiltinModule("node:os"),f=h(m(),".yolkbot");if(!i(f))r(f);let u=h(f,"maps");if(!i(u))r(u);let d=h(u,`${t}-${e}.json`);if(i(d))return JSON.parse(n(d,"utf-8"));let k=await(await fetch(`https://esm.sh/gh/yolkorg/maps/maps/${t}.json?${e}`)).json();return c(d,JSON.stringify(k,null,4),{flag:"w+"}),k}return await(await fetch(`https://esm.sh/gh/yolkorg/maps/maps/${t}.json?${e}`)).json()},$t=(t)=>{let e=0,s={},i=[];for(let c of t){if(!s[c.x])s[c.x]={};if(!s[c.x][c.y])s[c.x][c.y]={};s[c.x][c.y][c.z]={zone:null}}let r=[{x:-1,z:0},{x:1,z:0},{x:0,z:-1},{x:0,z:1}],n=(c,h,m)=>s[c]&&s[c][h]&&s[c][h][m]?s[c][h][m]:null;for(let c of t)if(!s[c.x][c.y][c.z].zone){c.zone=++e,s[c.x][c.y][c.z].zone=c.zone;let h=[c],m;do{m=0;for(let f of t)if(!s[f.x][f.y][f.z].zone)for(let u of r){let d=n(f.x+u.x,f.y,f.z+u.z);if(d&&d.zone===c.zone){m++,f.zone=c.zone,s[f.x][f.y][f.z].zone=c.zone,h.push(f);break}}}while(m>0);i.push(h)}return i};var Bt=[];var b=[];var Mt=[];var Jt=Object.fromEntries(Object.entries(M).map(([t,e])=>[e,t])),Kt=Object.fromEntries(Object.entries(mt).map(([t,e])=>[t[0].toLowerCase()+t.slice(1),e])),Ht={CHALLENGES:1,BOT_STATS:2,PATHFINDING:3,PING:5,COSMETIC_DATA:6,PLAYER_HEALTH:7,PACKET_HOOK:8,LOG_PACKETS:10,NO_LOGIN:11,DEBUG_BUFFER:12,NO_AFK_KICK:16,LOAD_MAP:17,OBSERVE_GAME:18,NO_REGION_CHECK:19,NO_EXIT_ON_ERROR:20,RENEW_SESSION:21,VIP_HIDE_BADGE:22},St=(t,e)=>(t%e+e)%e;class Zt{static Intents=Ht;Intents=Ht;#t=[];#e={};#r=[];#s;#o;constructor(t={}){if(t.proxy&&w.isBrowser)this.processError("proxies do not work and hence are not supported in the browser");if(this.intents=t.intents||[],this.intents.includes(this.Intents.COSMETIC_DATA)){if(!l(1001))this.processError("you cannot use the COSMETIC_DATA intent inside of the singlefile browser bundles")}if(this.instance=t.instance||"shellshock.io",this.protocol=t.protocol||"wss",this.proxy=t.proxy||"",this.connectionTimeout=t.connectionTimeout||5000,this.state={name:"yolkbot",weaponIdx:0,inGame:!1,chatLines:0,yaw:0,pitch:0,controlKeys:0,reloading:!1,swappingGun:!1,usingMelee:!1,stateIdx:0,serverStateIdx:0,shotsFired:0,buffer:[],left:!1},this.players={},this.me=new V({}),this.game={raw:{},code:"",socket:null,gameModeId:0,gameMode:Jt[0],mapIdx:0,map:{filename:"",hash:"",name:"",modes:{FFA:!1,Teams:!1,Spatula:!1,King:!1},availability:"both",numPlayers:"18",raw:{},nodes:{},zones:[]},playerLimit:0,isGameOwner:!1,isPrivate:!0,options:{gravity:1,damage:1,healthRegen:1,locked:!1,noTeamChange:!1,noTeamShuffle:!1,weaponsDisabled:Array(7).fill(!1),mustUseSecondary:!1},collectables:[[],[]],teamScore:[0,0,0],spatula:{coords:{x:0,y:0,z:0},controlledBy:0,controlledByTeam:0},stage:Q.Capturing,zoneNumber:0,activeZone:[],capturing:0,captureProgress:0,numCapturing:0,capturePercent:0},this.#o=this.game,this.account={id:0,firebase:{idToken:"",refreshToken:"",expiresIn:"3600",localId:""},firebaseId:"",sessionId:"",session:0,email:"",password:"",cw:{atLimit:!1,limit:0,secondsUntilPlay:0,canPlayAgain:Date.now()},loadout:{hatId:null,meleeId:0,stampId:null,classIdx:0,colorIdx:0,grenadeId:0,primaryId:[3100,3600,3400,3800,4000,4200,4500],secondaryId:[,,,,,,,].fill(3000),stampPositionX:0,stampPositionY:0},ownedItemIds:[],vip:!1,emailVerified:!1,isAged:!1,eggBalance:0,adminRoles:0,rawLoginData:{},isDoubleEggWeeknd:()=>{let e=new Date().getUTCDay(),s=new Date().getUTCHours();return e>=5&&s>=20||e===6||e===0}},this.#s=this.account,this.matchmaker=null,this.api=new I({proxy:this.proxy,protocol:this.protocol,instance:this.instance,maxRetries:t?.apiMaxRetries,connectionTimeout:this.connectionTimeout}),this.ping=0,this.lastPingTime=-1,this.lastDeathTime=-1,this.lastUpdateTick=0,this.pathing={nodeList:null,followingPath:!1,activePath:null,activeNode:null,activeNodeIdx:0},this.hasQuit=!1,this.intents.includes(this.Intents.NO_AFK_KICK))this.afkKickInterval=0;if(this.intents.includes(this.Intents.RENEW_SESSION))this.renewSessionInterval=0}dispatch(t){if(t.validate(this)){if(t.check(this))t.execute(this);else this.#t.push(t);return!0}return!1}async createAccount(t,e){this.account=this.#s,this.account.email=t,this.account.password=e;let s=await this.api.createAccount(t,e);return this.processLoginData(s)}async login(t,e){this.account=this.#s,this.account.email=t,this.account.password=e;let s=await this.api.loginWithCredentials(t,e);return this.processLoginData(s)}async loginWithRefreshToken(t){this.account=this.#s;let e=await this.api.loginWithRefreshToken(t);return this.processLoginData(e)}async loginAnonymously(){this.account=this.#s;let t=await this.api.loginAnonymously();return this.processLoginData(t)}processLoginData(t){if(typeof t!=="object")return this.emit("authFail",t),t;if(t.banRemaining)return this.emit("banned",t.banRemaining),"account_banned";if(!t.playerOutput)return this.emit("authFail",t),t;if(this.account.firebase=t.firebase||{},t=t.playerOutput,this.account.rawLoginData=t,this.account.adminRoles=t.adminRoles||0,this.account.eggBalance=t.currentBalance,this.account.emailVerified=t.emailVerified,this.account.firebaseId=t.firebaseId,this.account.id=t.id,this.account.isAged=new Date(t.dateCreated).getTime()<1714546800000,this.account.loadout=t.loadout,this.account.ownedItemIds=t.ownedItemIds,this.account.session=t.session,this.account.sessionId=t.sessionId,this.account.vip=t.active_sub==="IsVIP",this.intents.includes(this.Intents.BOT_STATS))this.account.stats={lifetime:t.statsLifetime,monthly:t.statsCurrent};if(this.intents.includes(this.Intents.CHALLENGES))this.#i(t.challenges);if(this.emit("authSuccess",this.account),this.intents.includes(this.Intents.RENEW_SESSION))this.renewSessionInterval=setInterval(async()=>{if(!this.account?.sessionId)return clearInterval(this.renewSessionInterval);if((await this.api.queryServices({cmd:"renewSession",sessionId:this.account.sessionId})).data!=="renewed")this.emit("sessionExpired")},600000);return this.account}#i(t){this.account.challenges=[];for(let e of t){let s=Bt.find((i)=>i.id===e.challengeId);if(!s)continue;delete e.playerId,this.account.challenges.push({raw:{challengeInfo:s,challengeData:e},id:e.challengeId,name:s.loc.title,desc:s.loc.desc,rewardEggs:s.reward,isRerolled:!!e.reset,isClaimed:!!e.claimed,isCompleted:!!e.completed,progressNum:e.progress,goalNum:s.goal})}}async initMatchmaker(){if(!this.account.sessionId&&!this.intents.includes(this.Intents.NO_LOGIN)){let t=await this.loginAnonymously();if(typeof t!=="object")return t}if(!this.matchmaker){if(this.matchmaker=new Ft({api:this.api,proxy:this.proxy,protocol:this.protocol,instance:this.instance,sessionId:this.account.sessionId,connectionTimeout:this.connectionTimeout,noLogin:this.intents.includes(this.Intents.NO_LOGIN)}),!await this.matchmaker.ws.tryConnect())return"matchmaker_tryconnect_failed";this.matchmaker.on("authFail",(e)=>this.emit("authFail",e)),this.matchmaker.on("error",(e)=>this.processError(e))}return!0}async findPublicGame(t,e){if(typeof t!=="string")return"no_region_passed";if(!Mt.find((i)=>i.id===t)&&!this.intents.includes(this.Intents.NO_REGION_CHECK))return"invalid_region_passed";if(typeof e!=="number")return"no_mode_passed";if(Object.values(M).indexOf(e)===-1)return"invalid_mode_passed";if(!await this.initMatchmaker())return"matchmaker_init_fail";return await new Promise((i)=>{let r=(n)=>{if(n.command==="notice")return;if(this.matchmaker.off("msg",r),n.command==="gameFound")return i(n);if(n.error==="sessionNotFound")return i("internal_session_error");this.processError("unknown matchmaker response",JSON.stringify(n))};this.matchmaker.on("msg",r),this.matchmaker.send({command:"findGame",region:t,playType:X.JoinPublic,gameType:e,sessionId:this.account.sessionId})})}async createPrivateGame(t,e,s){if(typeof t!=="string")return"no_region_passed";if(!Mt.find((n)=>n.id===t)&&!this.intents.includes(this.Intents.NO_REGION_CHECK))return"invalid_region_passed";if(typeof e!=="number")return"no_mode_passed";if(Object.values(M).indexOf(e)===-1)return"invalid_mode_passed";if(typeof s!=="string")return"no_map_passed";let i=b.findIndex((n)=>n.name.toLowerCase()===s.toLowerCase());if(i===-1)return"invalid_map_passed";if(!await this.initMatchmaker())return"matchmaker_init_fail";return await new Promise((n)=>{let c=(h)=>{if(h.command==="notice")return;if(this.matchmaker.off("msg",c),h.command==="gameFound")return n(h);if(h.error==="sessionNotFound")return n("internal_session_error");this.processError("unknown matchmaker response",JSON.stringify(h))};this.matchmaker.on("msg",c),this.matchmaker.send({command:"findGame",region:t,playType:X.CreatePrivate,gameType:e,sessionId:this.account.sessionId,noobLobby:!1,map:i})})}async join(t,e){if(this.state.name=t||"yolkbot",typeof e==="string"){if(e.includes("#"))e=e.split("#")[1];if(!await this.initMatchmaker())return"matchmaker_init_fail";if(await new Promise((n)=>{let c=(h)=>{if(h.command==="gameFound")this.matchmaker.off("msg",c),this.game.raw=h,this.game.code=h.id,n(h.id);if(h.error&&h.error==="gameNotFound")return this.processError(`game "${e}" not found, it may have expired.`),this.leave(),"gameNotFound"};this.matchmaker.on("msg",c),this.matchmaker.send({command:"joinGame",id:e,observe:!1,sessionId:this.account.sessionId})})==="gameNotFound")return"game_not_found";if(!this.game.raw.id)return this.processError("an internal error occured while joining the game, please report this to developers")}if(typeof e==="object"){if(this.account.id===0)await this.loginAnonymously();if(this.game.raw=e,this.game.code=this.game.raw.id,!this.game.raw.id)return"invalid_game_object";if(!this.game.raw.subdomain)return"invalid_game_object";if(!this.game.raw.uuid)return"invalid_game_object"}let s=this.game.raw.host||(this.instance.startsWith("localhost:")?this.instance:`${this.game.raw.subdomain}.${this.instance}`);if(this.game.socket=new F(`${this.protocol}://${s}/game/${this.game.raw.id}`,this.proxy),this.game.socket.binaryType="arraybuffer",this.game.socket.connectionTimeout=this.connectionTimeout,this.game.socket.onBeforeConnect=()=>{this.game.socket.onmessage=(r)=>this.processPacket(r.data),this.game.socket.onclose=(r)=>{if(this.state.left)this.state.left=!1;else this.emit("close",r.code),this.leave(-1)}},!await this.game.socket.tryConnect())return"websocket_tryconnect_fail";return!0}#n(){if(Object.entries(this.me.position).map((e)=>Math.floor(e[1])).join(",")===this.pathing.activePath[this.pathing.activePath.length-1].positionStr)this.pathing.followingPath=!1,this.pathing.activePath=null,this.pathing.activeNode=null,this.pathing.activeNodeIdx=0,this.dispatch(new K(0));else{let e;if(this.pathing.activeNodeIdx<this.pathing.activePath.length-1)e=this.pathing.activePath[this.pathing.activeNodeIdx+1].flatCenter(),this.dispatch(new J(e));else e=this.pathing.activePath[this.pathing.activeNodeIdx].flatCenter(),this.dispatch(new J(e));for(let s of this.pathing.activePath)if(s.flatRadialDistance(this.me.position)<0.1&&s.position.y===Math.floor(this.me.position.y)){if(this.pathing.activePath.indexOf(s)>=this.pathing.activeNodeIdx){this.pathing.activeNodeIdx=this.pathing.activePath.indexOf(s)+1,this.pathing.activeNode=this.pathing.activePath[this.pathing.activeNodeIdx];break}}if(!(this.state.controlKeys&S.Forward))this.dispatch(new K(S.Forward))}}update(){if(this.hasQuit)return;if(this.pathing.followingPath&&this.intents.includes(this.Intents.PATHFINDING))this.#n();for(let e=0;e<this.#t.length;e++){let s=this.#t[e];if(s.check(this))s.execute(this),this.#t.splice(e,1)}if(this.state.chatLines=Math.max(0,this.state.chatLines-0.008333333333333333),this.me.playing){let e=this.state.stateIdx;if(this.intents.includes(this.Intents.DEBUG_BUFFER))console.log("setting buffer for idx",e),console.log("checking...shotsFired",this.state.shotsFired);if(this.me.jumping=!!(this.state.controlKeys&S.Jump),this.state.buffer[e]={controlKeys:this.state.controlKeys,yaw:this.state.yaw,pitch:this.state.pitch,shotsFired:this.state.shotsFired},this.state.shotsFired=0,this.lastUpdateTick>=2){this.emit("tick");let s=new p;s.packInt8(a.syncMe),s.packInt8(this.state.stateIdx),s.packInt8(this.state.serverStateIdx);let i=St(this.state.stateIdx-C+1,j);for(let r=0;r<C;r++){let n=St(i+r,j),c=this.state.buffer[n]||{},h=c.controlKeys||0,m=c.shotsFired||0,f=c.yaw??this.state.yaw,u=c.pitch??this.state.pitch;if(this.intents.includes(this.Intents.DEBUG_BUFFER))console.log("going with",this.state.stateIdx,i,n,c);s.packInt8(h),s.packInt8(m),s.packString(Lt(f,u)),s.packInt8(100)}s.send(this.game.socket),this.state.buffer=[],this.lastUpdateTick=0}else this.lastUpdateTick++;this.state.stateIdx=St(this.state.stateIdx+1,j)}if(!this.intents.includes(this.Intents.PLAYER_HEALTH))return;let t=0.1*(this.game.isPrivate?this.game.options.healthRegen:1);for(let e of Object.values(this.players)){if(e.playing&&e.hp>0){let s=e.streakRewards.includes(g.OverHeal);e.hp+=s?-t:t,e.hp=s?Math.max(100,e.hp):Math.min(100,e.hp)}if(e.spawnShield>0)e.spawnShield-=6}}on(t,e){if(Object.keys(this.#e).includes(t))this.#e[t].push(e);else this.#e[t]=[e]}once(t,e){let s=(...i)=>{e(...i),this.off(t,s)};this.on(t,s)}onAny(t){this.#r.push(t)}off(t,e){if(e)this.#e[t]=this.#e[t].filter((s)=>s!==e);else this.#e[t]=[]}emit(t,...e){if(this.hasQuit)return;if(this.#e[t])for(let s of this.#e[t])s(...e);for(let s of this.#r)s(t,...e)}#c(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=o.unPackString().valueOf(),i=this.players[t];this.emit("chat",i,s,e)}#h(){let t=o.unPackInt8U(),e=this.intents.includes(this.Intents.COSMETIC_DATA),s={id:t,uniqueId:o.unPackString(),name:o.unPackString(),safeName:o.unPackString(),charClass:o.unPackInt8U(),team:o.unPackInt8U(),primaryWeaponItem:e?l(o.unPackInt16U()):o.unPackInt16U(),secondaryWeaponItem:e?l(o.unPackInt16U()):o.unPackInt16U(),shellColor:o.unPackInt8U(),hatItem:e?l(o.unPackInt16U()):o.unPackInt16U(),stampItem:e?l(o.unPackInt16U()):o.unPackInt16U(),stampPosX:o.unPackInt8(),stampPosY:o.unPackInt8(),grenadeItem:e?l(o.unPackInt16U()):o.unPackInt16U(),meleeItem:e?l(o.unPackInt16U()):o.unPackInt16U(),x:o.unPackFloat(),y:o.unPackFloat(),z:o.unPackFloat(),$dx:o.unPackFloat(),$dy:o.unPackFloat(),$dz:o.unPackFloat(),yaw:o.unPackRadU(),pitch:o.unPackRad(),score:o.unPackInt32U(),$kills:o.unPackInt16U(),$deaths:o.unPackInt16U(),$streak:o.unPackInt16U(),totalKills:o.unPackInt32U(),totalDeaths:o.unPackInt32U(),bestStreak:o.unPackInt16U(),$bestOverallStreak:o.unPackInt16U(),shield:o.unPackInt8U(),hp:o.unPackInt8U(),playing:o.unPackInt8U(),weaponIdx:o.unPackInt8U(),$controlKeys:o.unPackInt8U(),upgradeProductId:o.unPackInt8U(),activeShellStreaks:o.unPackInt8U(),social:o.unPackLongString(),hideBadge:o.unPackInt8U()};this.game.mapIdx=o.unPackInt8U(),this.game.isPrivate=o.unPackInt8U()===1,this.game.gameModeId=o.unPackInt8U();let i=new V(s,this.game.gameMode===M.KOTC?this.game.activeZone:null);if(!this.players[s.id])this.players[s.id]=i;if(this.emit("playerJoin",i),this.me.id===s.id)this.me=i,this.emit("botJoin",this.me)}#a(){let t=o.unPackInt8U(),e=o.unPackInt16U(),s=o.unPackFloat(),i=o.unPackFloat(),r=o.unPackFloat(),n=o.unPackInt8U(),c=o.unPackInt8U(),h=o.unPackInt8U(),m=o.unPackInt8U(),f=o.unPackInt8U(),u=this.players[t];if(u){if(u.playing=!0,u.randomSeed=e,u.weapons[0]&&u.weapons[0].ammo)u.weapons[0].ammo.rounds=n;if(u.weapons[0]&&u.weapons[0].ammo)u.weapons[0].ammo.store=c;if(u.weapons[1]&&u.weapons[1].ammo)u.weapons[1].ammo.rounds=h;if(u.weapons[1]&&u.weapons[1].ammo)u.weapons[1].ammo.store=m;u.grenades=f,u.position={x:s,y:i,z:r},u.spawnShield=120,this.emit("playerRespawn",u)}}#u(){let t=o.unPackInt8U(),e=o.unPackFloat(),s=o.unPackFloat(),i=o.unPackFloat(),r=o.unPackInt8U(),n=this.players[t];if(!n||n.id===this.me.id){for(let N=0;N<C;N++)o.unPackInt8U(),o.unPackRadU(),o.unPackRad(),o.unPackInt8U();return}for(let N=0;N<C;N++){let A=o.unPackInt8U();if(A&S.Jump)n.jumping=!0;else n.jumping=!1;if(A&S.Scope)n.scoping=!0;else n.scoping=!1;let v={...n.view};if(n.view.yaw=o.unPackRadU(),n.view.pitch=o.unPackRad(),n.view.yaw!==v.yaw||n.view.pitch!==v.pitch)this.emit("playerRotate",n,v,n.view);n.scale=o.unPackInt8U()}let c=n.position,h=c.x!==e||c.y!==s||c.z!==i,m=n.climbing!==r,f=h||m,u=f?{...c}:null;if(c.x!==e)c.x=e;if(c.z!==i)c.z=i;if(!n.jumping||Math.abs(c.y-s)>0.5)c.y=s;if(m)n.climbing=r;if(!f)return;if(this.emit("playerMove",n,u,c),this.game.gameModeId!==M.KOTC)return;let d=this.game.activeZone,k=!!n.inKotcZone;if(!d&&k){n.inKotcZone=!1,this.emit("playerLeaveZone",n);return}n.updateKotcZone(d);let E=!!n.inKotcZone;if(k!==E)n.inKotcZone=E,this.emit(E?"playerEnterZone":"playerLeaveZone",n)}#f(){let t=o.unPackInt8U(),e=this.players[t];if(e){if(e.playing=!1,e.streakRewards)e.streakRewards=[];if(this.emit("playerPause",e),e.inKotcZone)e.inKotcZone=!1,this.emit("playerLeaveZone",e)}}#m(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(s)s.activeGun=e,this.emit("playerSwapWeapon",s,e)}#p(){let t=o.unPackInt8U(),e=o.unPackInt8U();o.unPackInt8U(),o.unPackInt8U();let s=o.unPackInt8U(),i=this.players[t],r=this.players[e],n=i?{...i}:null;if(i){if(i.id===this.me.id)this.lastDeathTime=Date.now();i.playing=!1,i.streak=0,i.hp=100,i.spawnShield=0,i.stats.totalDeaths++,i.inKotcZone=!1,this.emit("playerLeaveZone",i)}if(r){if(r.streak++,r.stats.totalKills++,r.streak>r.stats.bestStreak)r.stats.bestStreak=r.streak}this.emit("playerDeath",i,r,n,s)}#d(){let t=o.unPackInt8U(),e={posX:o.unPackFloat(),posY:o.unPackFloat(),posZ:o.unPackFloat(),dirX:o.unPackFloat(),dirY:o.unPackFloat(),dirZ:o.unPackFloat()},s=this.players[t];if(!s)return;let i=s.weapons[s.activeGun];if(i&&i.ammo)i.ammo.rounds--,this.emit("playerFire",s,i,e)}#l(){let t=o.unPackInt16U(),e=o.unPackInt8U(),s=o.unPackFloat(),i=o.unPackFloat(),r=o.unPackFloat();this.game.collectables[e].push({id:t,x:s,y:i,z:r}),this.emit("spawnItem",e,{x:s,y:i,z:r},t)}#g(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=o.unPackInt8U(),i=o.unPackInt16U(),r=this.players[t];if(!r)return;if(this.game.collectables[e]=this.game.collectables[e].filter((n)=>n.id!==i),e===Y.Ammo){let n=r.weapons[s];if(n&&n.ammo)n.ammo.store=Math.min(n.ammo.storeMax,n.ammo.store+n.ammo.pickup),this.emit("playerCollectAmmo",r,n,i)}if(e===Y.Grenade){if(r.grenades++,r.grenades>3)r.grenades=3;this.emit("playerCollectGrenade",r,i)}}#x(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;let i=s.hp;s.hp=e,this.emit("playerDamage",s,i,s.hp)}#w(){let t=o.unPackInt8U();o.unPackFloat(),o.unPackFloat();let e=this.me.hp;this.me.hp=t,this.emit("playerDamage",this.me,e,this.me.hp)}#k(){let t=o.unPackInt8U(),e=this.players[t];o.unPackInt8U();let s=o.unPackInt8U(),i=o.unPackFloat(),r=o.unPackFloat(),n=o.unPackFloat();if(this.me.climbing=!!o.unPackInt8U(),o.unPackInt8U(),o.unPackInt8U(),!e)return;this.state.serverStateIdx=s;let c=e.position.x,h=e.position.y,m=e.position.z;if(e.position.x=i,e.position.y=r,e.position.z=n,c!==i||h!==r||m!==n)this.emit("playerMove",e,{x:c,y:h,z:m},{x:i,y:r,z:n})}#M(){let t=new p;t.packInt8(a.eventModifier),t.send(this.game.socket)}#S(){let t=o.unPackInt8U(),e={...this.players[t]};delete this.players[t],this.emit("playerLeave",e)}#y(){if(this.game.gameModeId===M.Spatula){let t={...this.game};this.game.teamScore[1]=o.unPackInt16U(),this.game.teamScore[2]=o.unPackInt16U();let e={x:o.unPackFloat(),y:o.unPackFloat(),z:o.unPackFloat()},s=o.unPackInt8U(),i=o.unPackInt8U();this.game.spatula={coords:e,controlledBy:s,controlledByTeam:i},this.emit("gameStateChange",t,this.game)}else if(this.game.gameModeId===M.KOTC){let t={...this.game};this.game.stage=o.unPackInt8U(),this.game.zoneNumber=o.unPackInt8U(),this.game.capturing=o.unPackInt8U(),this.game.captureProgress=o.unPackInt16U(),this.game.numCapturing=o.unPackInt8U(),this.game.teamScore[1]=o.unPackInt8U(),this.game.teamScore[2]=o.unPackInt8U(),this.game.capturePercent=this.game.captureProgress/1000,this.game.activeZone=this.game.map.zones?this.game.map.zones[this.game.zoneNumber-1]:null;let e=Object.values(this.players).filter((s)=>s.inKotcZone&&s.playing);if(this.game.activeZone)Object.values(this.players).forEach((s)=>s.updateKotcZone(this.game.activeZone));if(this.game.numCapturing<=0)Object.values(this.players).forEach((s)=>{s.inKotcZone=!1,this.emit("playerLeaveZone",s)});this.emit("gameStateChange",t,this.game,e)}else if(this.game.gameModeId===M.Team)this.game.teamScore[1]=o.unPackInt16U(),this.game.teamScore[2]=o.unPackInt16U();if(this.game.gameModeId!==M.Spatula)delete this.game.spatula;if(this.game.gameModeId!==M.KOTC)delete this.game.stage,delete this.game.zoneNumber,delete this.game.capturing,delete this.game.captureProgress,delete this.game.numCapturing,delete this.game.numCapturing,delete this.game.activeZone;if(this.game.gameModeId===M.FFA)delete this.game.teamScore}#z(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;switch(e){case g.HardBoiled:if(t===this.me.id)this.me.shieldHp=100;s.streakRewards.push(g.HardBoiled);break;case g.EggBreaker:s.streakRewards.push(g.EggBreaker);break;case g.Restock:{if(s.grenades=3,s.weapons[0]&&s.weapons[0].ammo)s.weapons[0].ammo.rounds=s.weapons[0].ammo.capacity,s.weapons[0].ammo.store=s.weapons[0].ammo.storeMax;if(s.weapons[1]&&s.weapons[1].ammo)s.weapons[1].ammo.rounds=s.weapons[1].ammo.capacity,s.weapons[1].ammo.store=s.weapons[1].ammo.storeMax;break}case g.OverHeal:s.hp=Math.min(200,s.hp+100),s.streakRewards.push(g.OverHeal);break;case g.DoubleEggs:s.streakRewards.push(g.DoubleEggs);break;case g.MiniEgg:s.scale=0.5,s.streakRewards.push(g.MiniEgg);break}this.emit("playerBeginStreak",s,e)}#T(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;if([g.EggBreaker,g.OverHeal,g.DoubleEggs,g.MiniEgg].includes(e)&&s.streakRewards.includes(e))s.streakRewards=s.streakRewards.filter((r)=>r!==e);if(e===g.MiniEgg)s.scale=1;this.emit("playerEndStreak",s,e)}#E(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=o.unPackFloat(),i=o.unPackFloat();if(!this.me)return;if(this.me.shieldHp=t,this.me.hp=e,this.me.shieldHp<=0)this.me.streakRewards=this.me.streakRewards.filter((r)=>r!==g.HardBoiled),this.emit("selfShieldLost",this.me.hp,{dx:s,dz:i});else this.emit("selfShieldHit",this.me.shieldHp,this.me.hp,{dx:s,dz:i})}#P(){let t={...this.game.options},e=o.unPackInt8U(),s=o.unPackInt8U(),i=o.unPackInt8U();if(e<1||e>4)e=4;if(s<0||s>8)s=4;if(i>16)i=4;this.game.options.gravity=e/4,this.game.options.damage=s/4,this.game.options.healthRegen=i/4;let r=o.unPackInt8U();Object.keys(Kt).forEach((n)=>{let c=r&Kt[n]?1:0;this.game.options[n]=c}),this.game.options.weaponsDisabled=Array.from({length:7},()=>o.unPackInt8U()===1),this.game.options.mustUseSecondary=this.game.options.weaponsDisabled.every((n)=>n),this.emit("gameOptionsChange",t,this.game.options)}#N(){let t=o.unPackInt8U();if(t===L.Pause)this.emit("gameForcePause"),setTimeout(()=>this.me.playing=!1,3000);if(t===L.Reset){if(Object.values(this.players).forEach((e)=>e.streak=0),this.game.gameModeId!==M.FFA)this.game.teamScore=[0,0,0];if(this.game.gameModeId===M.Spatula)this.game.spatula.controlledBy=0,this.game.spatula.controlledByTeam=0,this.game.spatula.coords={x:0,y:0,z:0};if(this.game.gameModeId===M.KOTC)this.game.stage=Q.Capturing,this.game.zoneNumber=0,this.game.activeZone=null,this.game.capturing=0,this.game.captureProgress=0,this.game.numCapturing=0,this.game.capturePercent=0;this.emit("gameReset")}}#G(){if(!this.intents.includes(this.Intents.PING))return;let t=this.ping;this.ping=Date.now()-this.lastPingTime,this.emit("pingUpdate",t,this.ping),setTimeout(()=>{let e=new p;e.packInt8(a.ping),e.send(this.game.socket),this.lastPingTime=Date.now()},1000)}#O(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;let i=s.team;s.team=e,s.streak=0,this.emit("playerSwitchTeam",s,i,e)}#R(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=o.unPackInt16U(),i=o.unPackInt16U(),r=o.unPackInt8U(),n=o.unPackInt16U(),c=o.unPackInt16U(),h=o.unPackInt16U(),m=o.unPackInt16U(),f=o.unPackInt8(),u=o.unPackInt8(),d=this.intents.includes(this.Intents.COSMETIC_DATA),k=d?l(s):s,E=d?l(i):i,N=d?l(n):n,A=d?l(c):c,v=d?l(h):h,H=d?l(m):m,x=this.players[t];if(x){let z={...x.character},zt=x.selectedGun;if(x.character.eggColor=r,x.character.primaryGun=k,x.character.secondaryGun=E,x.character.stamp=A,x.character.hat=N,x.character.grenade=v,x.character.melee=H,x.character.stampPos.x=f,x.character.stampPos.y=u,x.selectedGun=e,x.weapons[0]=new _[e],zt!==x.selectedGun)this.emit("playerChangeGun",x,zt,x.selectedGun);if(z!==x.character)this.emit("playerChangeCharacter",x,z,x.character)}}#_(){let t=o.unPackInt32U(),e=this.account.eggBalance;this.account.eggBalance=t,this.emit("balanceUpdate",e,t)}#A(){this.me.playing=!1,this.emit("respawnDenied")}#v(){let t=o.unPackInt8U(),e=this.players[t];if(e)this.emit("playerMelee",e)}#C(){let t=o.unPackInt8U(),e=this.players[t];if(!e)return;let s=e.weapons[e.activeGun];if(s.ammo){let i=Math.min(Math.min(s.ammo.capacity,s.ammo.reload)-s.ammo.rounds,s.ammo.store);s.ammo.rounds+=i,s.ammo.store-=i}this.emit("playerReload",e,s)}updateGameOptions(){let t=new p;t.packInt8(a.gameOptions),t.packInt8(this.game.options.gravity*4),t.packInt8(this.game.options.damage*4),t.packInt8(this.game.options.healthRegen*4);let e=(this.game.options.locked?1:0)|(this.game.options.noTeamChange?2:0)|(this.game.options.noTeamShuffle?4:0);t.packInt8(e),this.game.options.weaponsDisabled.forEach((s)=>{t.packInt8(s?1:0)}),t.send(this.game.socket)}#L(){this.game.isPrivate=!0,this.updateGameOptions()}#F(){let t=o.unPackInt8U(),e=o.unPackInt16U(),s=o.unPackFloat(),i=o.unPackFloat(),r=o.unPackFloat(),n=o.unPackInt8U(),c=o.unPackFloat();if(this.intents.includes(this.Intents.COSMETIC_DATA))e=l(e);if(t===P.Grenade)this.emit("grenadeExplode",e,{x:s,y:i,z:r},n,c);else this.emit("rocketHit",{x:s,y:i,z:r},n,c)}#q(){let t=o.unPackInt8U(),e=o.unPackFloat(),s=o.unPackFloat(),i=o.unPackFloat(),r=o.unPackFloat(),n=o.unPackFloat(),c=o.unPackFloat(),h=this.players[t];if(h)h.grenades--,this.emit("playerThrowGrenade",h,{x:e,y:s,z:i},{x:r,y:n,z:c})}#U(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;if(!this.intents.includes(this.Intents.CHALLENGES))return this.emit("challengeComplete",s,e);let i=this.account.challenges.find((r)=>r.id===e);if(this.emit("challengeComplete",s,i),s.id===this.me.id)this.refreshChallenges()}#W(){let t=new p;t.packInt8(this.intents.includes(this.Intents.OBSERVE_GAME)?a.observeGame:a.joinGame),t.packString(this.game.raw.uuid),t.packInt8(+this.intents.includes(this.Intents.VIP_HIDE_BADGE)),t.packInt8(this.state.weaponIdx||this.account?.loadout?.classIdx||0),t.packString(this.state.name),t.packInt32(this.account.session),t.packString(this.account.sessionId),t.packString(this.account.firebaseId),t.send(this.game.socket)}async#j(){if(this.me.id=o.unPackInt8U(),this.me.team=o.unPackInt8U(),this.game.gameModeId=o.unPackInt8U(),this.game.gameMode=Jt[this.game.gameModeId],this.game.mapIdx=o.unPackInt8U(),this.game.map=b[this.game.mapIdx],this.game.playerLimit=o.unPackInt8U(),this.game.isGameOwner=o.unPackInt8U()===1,this.game.isPrivate=o.unPackInt8U()===1||this.game.isGameOwner,o.unPackInt8U(),this.intents.includes(this.Intents.LOAD_MAP)||this.intents.includes(this.Intents.PATHFINDING)){if(this.game.map.raw=await jt(this.game.map.filename,this.game.map.hash),this.emit("mapLoad",this.game.map.raw),this.game.gameModeId===M.KOTC){let e=this.game.map.raw.data["DYNAMIC.capture-zone.none"];if(e){if(this.game.map.zones=$t(e),!this.game.activeZone)this.game.activeZone=this.game.map.zones[this.game.zoneNumber-1]}else delete this.game.map.zones}if(this.intents.includes(this.Intents.PATHFINDING))this.pathing.nodeList=new kt(this.game.map.raw)}this.state.inGame=!0,this.lastDeathTime=Date.now();let t=new p;if(t.packInt8(a.clientReady),t.send(this.game.socket),this.updateIntervalId=setInterval(()=>this.update(),33.333333333333336),this.intents.includes(this.Intents.PING)){this.lastPingTime=Date.now();let e=new p;e.packInt8(a.ping),e.send(this.game.socket)}if(this.intents.includes(this.Intents.NO_AFK_KICK))this.afkKickInterval=setInterval(()=>{if(this.state.inGame&&!this.me.playing&&Date.now()-this.lastDeathTime>=15000){let e=new p;e.packInt8(a.keepAlive),e.send(this.game.socket)}},15000);this.emit("gameReady")}#$(){let t=o.unPackInt8U(),e=o.unPackString(128),s=o.unPackString(32),i=this.players[t];if(!i)return;i.admin={ip:s,dbId:e},this.emit("playerInfo",i,s,e)}packetHandlers={[a.syncThem]:()=>this.#u(),[a.fire]:()=>this.#d(),[a.hitThem]:()=>this.#x(),[a.syncMe]:()=>this.#k(),[a.hitMe]:()=>this.#w(),[a.swapWeapon]:()=>this.#m(),[a.collectItem]:()=>this.#g(),[a.respawn]:()=>this.#a(),[a.die]:()=>this.#p(),[a.pause]:()=>this.#f(),[a.chat]:()=>this.#c(),[a.addPlayer]:()=>this.#h(),[a.removePlayer]:()=>this.#S(),[a.eventModifier]:()=>this.#M(),[a.metaGameState]:()=>this.#y(),[a.beginShellStreak]:()=>this.#z(),[a.endShellStreak]:()=>this.#T(),[a.hitMeHardBoiled]:()=>this.#E(),[a.gameOptions]:()=>this.#P(),[a.ping]:()=>this.#G(),[a.switchTeam]:()=>this.#O(),[a.changeCharacter]:()=>this.#R(),[a.reload]:()=>this.#C(),[a.explode]:()=>this.#F(),[a.throwGrenade]:()=>this.#q(),[a.spawnItem]:()=>this.#l(),[a.melee]:()=>this.#v(),[a.updateBalance]:()=>this.#_(),[a.challengeCompleted]:()=>this.#U(),[a.socketReady]:()=>this.#W(),[a.gameJoined]:()=>this.#j(),[a.gameAction]:()=>this.#N(),[a.requestGameOptions]:()=>this.#L(),[a.respawnDenied]:()=>this.#A(),[a.playerInfo]:()=>this.#$(),[a.expireUpgrade]:()=>{},[a.clientReady]:()=>{},[a.musicInfo]:()=>o.unPackLongString()};processPacket(t){if(o.init(t),this.intents.includes(this.Intents.PACKET_HOOK))this.emit("packet",t);let e=0,s=0,i=!1;while(o.isMoreDataAvailable()&&!i){let r=o.unPackInt8U(),n=this.packetHandlers[r];if(n)n();else{if(console.error(`processPacket: I got but couldn't identify a: ${Object.keys(a).find((c)=>a[c]===r)} ${r}`),e)console.error(`processPacket: It may be a result of the ${e} command (${s}).`);i=!0;break}if(e=Object.keys(a).find((c)=>a[c]===r),s=r,this.intents.includes(this.Intents.LOG_PACKETS))console.log(`[LOG_PACKETS] Packet ${e}: ${s}`)}}async checkChiknWinner(){let t=await this.api.queryServices({cmd:"chicknWinnerReady",id:this.account.id,sessionId:this.account.sessionId});if(typeof t==="string")return t;return this.account.cw.limit=t.limit,this.account.cw.atLimit=t.limit>=4,this.account.cw.secondsUntilPlay=(this.account.cw.atLimit?t.period:t.span)||0,this.account.cw.canPlayAgain=Date.now()+this.account.cw.secondsUntilPlay*1000,this.account.cw}async playChiknWinner(t=!0){if(this.account.cw.atLimit||this.account.cw.limit>ft)return"hit_daily_limit";if(this.account.cw.canPlayAgain>Date.now()&&t)return"on_cooldown";let e=await this.api.queryServices({cmd:"incentivizedVideoReward",firebaseId:this.account.firebaseId,id:this.account.id,sessionId:this.account.sessionId,token:null});if(typeof e==="string")return e;if(e.error){if(e.error==="RATELIMITED"||e.error==="RATELMITED")return await this.checkChiknWinner(),"on_cooldown";else if(e.error==="SESSION_EXPIRED")return this.emit("sessionExpired"),"session_expired";return console.error("Unknown Chikn Winner response, report this on Github:",e),"unknown_error"}if(e.reward)return this.account.eggBalance+=e.reward.eggsGiven,e.reward.itemIds.forEach((s)=>this.account.ownedItemIds.push(s)),await this.checkChiknWinner(),e.reward;return console.error("Unknown Chikn Winner response, report this on Github:",e),"unknown_error"}async resetChiknWinner(){if(this.account.eggBalance<200)return"not_enough_eggs";if(!this.account.cw.atLimit)return"not_at_limit";let t=await this.api.queryServices({cmd:"chwReset",sessionId:this.account.sessionId});if(typeof t==="string")return t;if(t.result!=="SUCCESS")return console.error("Unknown Chikn Winner reset response, report this on Github:",t),"unknown_error";return this.account.eggBalance-=200,await this.checkChiknWinner(),this.account.cw}canSee(t){if(!this.intents.includes(this.Intents.PATHFINDING))return this.processError("You must have the PATHFINDING intent to use this method.");return this.pathing.nodeList.hasLineOfSight(this.me.position,t.position)}async refreshChallenges(){let t=await this.api.queryServices({cmd:"challengeGetDaily",sessionId:this.account.sessionId,playerId:this.account.id});if(typeof t==="string")return t;return this.#i(t),this.account.challenges}async rerollChallenge(t){let e=await this.api.queryServices({cmd:"challengeRerollSlot",sessionId:this.account.sessionId,slotId:t});if(typeof e==="string")return e;return this.#i(e),this.account.challenges}async claimChallenge(t){let e=await this.api.queryServices({cmd:"challengeClaimReward",sessionId:this.account.sessionId,slotId:t});if(typeof e==="string")return e;if(this.#i(e.challenges),e.reward>0)this.account.eggBalance+=e.reward;return{eggReward:e.reward,updatedChallenges:this.account.challenges}}async refreshBalance(){let t=await this.api.queryServices({cmd:"checkBalance",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId});if(typeof t==="string")return t;return this.account.eggBalance=t.currentBalance,t.currentBalance}async redeemCode(t){let e=await this.api.queryServices({cmd:"redeem",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,id:this.account.id,code:t});if(typeof e==="string")return e;if(e.result==="SUCCESS")return this.account.eggBalance=e.eggs_given,e.item_ids.forEach((s)=>this.account.ownedItemIds.push(s)),{result:e,eggsGiven:e.eggs_given,itemIds:e.item_ids};return e}async claimURLReward(t){let e=await this.api.queryServices({cmd:"urlRewardParams",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,reward:t});if(typeof e==="string")return e;if(e.result==="SUCCESS")this.account.eggBalance+=e.eggsGiven,e.itemIds.forEach((s)=>this.account.ownedItemIds.push(s));return e}async claimSocialReward(t){let e=await this.api.queryServices({cmd:"reward",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,rewardTag:t});if(typeof e==="string")return e;if(e.result==="SUCCESS")this.account.eggBalance+=e.eggsGiven,e.itemIds.forEach((s)=>this.account.ownedItemIds.push(s));return e}async buyItem(t){let e=await this.api.queryServices({cmd:"buy",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,itemId:t,save:!0});if(typeof e==="string")return e;if(e.result==="SUCCESS")this.account.eggBalance=e.currentBalance,this.account.ownedItemIds.push(e.itemId);return e}processError(...t){let e=t.join(" ");if(this.#e.error&&this.#e.error.length)this.emit("error",e);else if(this.intents.includes(this.Intents.NO_EXIT_ON_ERROR))console.error(e);else throw Error(e)}leave(t=D.mainMenu){if(this.hasQuit)return;if(t>-1)this.game?.socket?.close(t),this.state.left=!0,this.emit("leave",t);clearInterval(this.updateIntervalId),this.#t=[],this.state.inGame=!1,this.state.chatLines=0,this.state.reloading=!1,this.state.swappingGun=!1,this.state.usingMelee=!1,this.state.stateIdx=0,this.state.serverStateIdx=0,this.state.shotsFired=0,this.state.buffer=[],this.players={},this.me=new V({}),this.game=this.#o,this.ping=0,this.lastPingTime=-1,this.lastDeathTime=-1,this.lastUpdateTick=0,this.pathing={nodeList:null,followingPath:!1,activePath:null,activeNode:null,activeNodeIdx:0}}logout(){if(this.account=this.#s,this.intents.includes(this.Intents.RENEW_SESSION))clearInterval(this.renewSessionInterval)}quit(t=!1){if(this.hasQuit)return;if(this.leave(),this.matchmaker){if(this.matchmaker.close(),!t)delete this.matchmaker}if(!t)delete this.account,delete this.api,delete this.game,delete this.me,delete this.pathing,delete this.players,delete this.state,this.#s={},this.#o={},this.#e={},this.#r=[],this.#t=[];if(this.intents.includes(this.Intents.NO_AFK_KICK))clearInterval(this.afkKickInterval);if(this.intents.includes(this.Intents.RENEW_SESSION))clearInterval(this.renewSessionInterval);this.hasQuit=!0}}class Yt{constructor(t,e,s=""){this.uniqueId=t,this.duration=e,this.reason=s}validate(t){if(typeof this.uniqueId!=="string"||typeof this.reason!=="string")return!1;if(typeof this.duration!=="number"||!Object.values(ut).some((e)=>this.duration===e))return!1;if(!(t.account.adminRoles&4))return!1;return!0}check(){return!0}execute(t){let e=new p;e.packInt8(a.banPlayer),e.packString(this.uniqueId),e.packString(this.reason),e.packInt8(this.duration),e.send(t.game.socket)}}var Qt=Yt;class Xt{constructor(t){this.uniqueId=t}validate(t){return typeof this.uniqueId==="string"&&t.game.isGameOwner&&Object.values(t.players).find((e)=>e.uniqueId===this.uniqueId)}check(){return!0}execute(t){let e=new p;e.packInt8(a.bootPlayer),e.packString(this.uniqueId),e.send(t.game.socket)}}var It=Xt;class Dt{constructor(t){this.msg=t}validate(){if(typeof this.msg!=="string")return!1;if(this.msg.length<1||this.msg.length>64)return!1;return!0}check(t){if(!t.state?.inGame)return!1;if(!t.game.isPrivate&&!t.account.adminRoles&&t.state.chatLines>=2)return!1;if(!t.game.isPrivate&&!t.account.emailVerified&&!t.account.isAged)return!1;return!0}execute(t){t.state.chatLines++;let e=new p;e.packInt8(a.chat),e.packString(this.msg),e.send(t.game.socket)}}var Vt=Dt;class bt{constructor(t){this.amount=t||1}validate(){return this.amount>=1}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee&&t.me.weapons[t.me.activeGun].ammo.rounds>=this.amount}execute(t){t.state.shotsFired+=this.amount||1}}var te=bt;var ts=Array.from({length:4},(t,e)=>(e+1)*0.25),es=Array.from({length:9},(t,e)=>e*0.25),ss=Array.from({length:17},(t,e)=>e*0.25),y=(t,e)=>typeof t>"u"?e:t;class ee{constructor(t){this.changes=t}#t(t){let e={};if(e.gravity=y(this.changes.gravity,t.game.options.gravity),e.damage=y(this.changes.damage,t.game.options.damage),e.healthRegen=y(this.changes.healthRegen,t.game.options.healthRegen),e.locked=y(this.changes.locked,t.game.options.locked),e.noTeamChange=y(this.changes.noTeamChange,t.game.options.noTeamChange),e.noTeamShuffle=y(this.changes.noTeamShuffle,t.game.options.noTeamShuffle),e.weaponsDisabled=[y(this.changes.disableEggk,t.game.options.weaponsDisabled[0]),y(this.changes.disableScrambler,t.game.options.weaponsDisabled[1]),y(this.changes.disableFreeRanger,t.game.options.weaponsDisabled[2]),y(this.changes.disableRPG,t.game.options.weaponsDisabled[3]),y(this.changes.disableWhipper,t.game.options.weaponsDisabled[4]),y(this.changes.disableCrackshot,t.game.options.weaponsDisabled[5]),y(this.changes.disableTriHard,t.game.options.weaponsDisabled[6])],this.changes.toDisable&&Array.isArray(this.changes.toDisable))this.changes.toDisable.forEach((s)=>e.weaponsDisabled[s]=!0);if(this.changes.toEnable&&Array.isArray(this.changes.toEnable))this.changes.toEnable.forEach((s)=>e.weaponsDisabled[s]=!1);if(this.changes.rawWeaponsDisabled&&Array.isArray(this.changes.rawWeaponsDisabled)&&this.changes.rawWeaponsDisabled.length===7)e.weaponsDisabled=this.changes.rawWeaponsDisabled.map((s)=>!!s);return e.mustUseSecondary=e.weaponsDisabled.every((s)=>s),e}validate(t){let e=this.#t(t);if(!ts.includes(e.gravity))return!1;if(!es.includes(e.damage))return!1;if(!ss.includes(e.healthRegen))return!1;if(typeof e.locked!=="boolean")return!1;if(typeof e.noTeamChange!=="boolean")return!1;if(typeof e.noTeamShuffle!=="boolean")return!1;if(!Array.isArray(e.weaponsDisabled))return!1;if(e.weaponsDisabled.length!==7)return!1;if(e.weaponsDisabled.some((s)=>typeof s!=="boolean"))return!1;return!0}check(t){return t.game.isGameOwner}execute(t){t.game.options=this.#t(t),t.updateGameOptions()}}var se=ee;class yt{constructor(t){this.content=[],this.scoreFunction=t}push(t){this.content.push(t),this.bubbleUp(this.content.length-1)}rescoreElement(t){this.sinkDown(this.content.indexOf(t))}pop(){let t=this.content[0],e=this.content.pop();if(this.content.length>0)this.content[0]=e,this.sinkDown(0);return t}remove(t){let e=this.content.length;for(let s=0;s<e;s++){if(this.content[s]!==t)continue;let i=this.content.pop();if(s===e-1)break;this.content[s]=i,this.bubbleUp(s),this.sinkDown(s);break}}size(){return this.content.length}bubbleUp(t){let e=this.content[t],s=this.scoreFunction(e);while(t>0){let i=Math.floor((t+1)/2)-1,r=this.content[i];if(s>=this.scoreFunction(r))break;this.content[i]=e,this.content[t]=r,t=i}}includes(t){return this.content.includes(t)}sinkDown(t){let e=this.content.length,s=this.content[t],i=this.scoreFunction(s);while(!0){let r=(t+1)*2,n=r-1,c=null,h;if(n<e){let m=this.content[n];if(h=this.scoreFunction(m),h<i)c=n}if(r<e){let m=this.content[r];if(this.scoreFunction(m)<(c===null?i:h))c=r}if(c===null)break;this.content[t]=this.content[c],this.content[c]=s,t=c}}}class T{constructor(t){this.list=t}heuristic(t,e){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)+Math.abs(t.z-e.z)}reversePath(t){let e=[];while(t.parent)e.push(t),t=t.parent;return e.reverse(),e}path(t,e){this.list.clean();let s=new yt((r)=>r.f),i=[];t.h=this.heuristic(t,e),t.g=0,t.f=t.g+t.h,s.push(t);while(s.size()!==0){let r=s.pop();if(r===e)return this.reversePath(r);i.push(r);let n=r.links;for(let c=0;c<n.length;c++){let h=n[c];if(i.includes(h))continue;let m=r.g+1,f=h.visited;if(!f||m<h.g)if(h.visited=!0,h.parent=r,h.g=m,h.h=this.heuristic(h.position,e.position),h.f=h.g+h.h,f)s.rescoreElement(h);else s.push(h)}}return null}}class ie{validate(t){return t.intents.includes(t.Intents.PATHFINDING)}check(t){return t.me.playing&&t.game.collectables[0].length}execute(t){this.pather=new T(t.pathing.nodeList);let e=200,s=null;for(let h of t.game.collectables[0]){let m=h.x-t.me.position.x,f=h.y-t.me.position.y,u=h.z-t.me.position.z,d=Math.sqrt(m*m+f*f+u*u);if(d<e)e=d,s=h}let i=Object.entries(t.me.position).map((h)=>Math.floor(h[1])),r=Object.entries(s).map((h)=>Math.floor(h[1])),n=t.pathing.nodeList.at(...i),c=t.pathing.nodeList.at(...r);if(t.pathing.activePath=this.pather.path(n,c),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var oe=ie;class re{validate(t){return t.intents.includes(t.Intents.PATHFINDING)}check(t){return t.me.playing&&t.game.zoneNumber&&t.game.activeZone}execute(t){this.pather=new T(t.pathing.nodeList);let e=200,s=null;for(let h of t.game.activeZone){let m=h.x-t.me.position.x,f=h.y-t.me.position.y,u=h.z-t.me.position.z,d=Math.sqrt(m*m+f*f+u*u);if(d<e)e=d,s=h}let i=Object.entries(t.me.position).map((h)=>Math.floor(h[1])),r=Object.entries(s).map((h)=>Math.floor(h[1])),n=t.pathing.nodeList.at(...i),c=t.pathing.nodeList.at(...r);if(t.pathing.activePath=this.pather.path(n,c),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var ne=re;class ce{validate(t){return t.intents.includes(t.Intents.PATHFINDING)}check(t){return t.me.playing&&t.game.collectables[1].length}execute(t){this.pather=new T(t.pathing.nodeList);let e=200,s=null;for(let h of t.game.collectables[1]){let m=h.x-t.me.position.x,f=h.y-t.me.position.y,u=h.z-t.me.position.z,d=Math.sqrt(m*m+f*f+u*u);if(d<e)e=d,s=h}let i=Object.entries(t.me.position).map((h)=>Math.floor(h[1])),r=Object.entries(s).map((h)=>Math.floor(h[1])),n=t.pathing.nodeList.at(...i),c=t.pathing.nodeList.at(...r);if(t.pathing.activePath=this.pather.path(n,c),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var he=ce;class ae{idOrName;constructor(t){this.idOrName=t}validate(t){if(!t.intents.includes(t.Intents.PATHFINDING))return!1;if(!this.idOrName)return!1;return!!(t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName))}check(t){if(!t.me.playing)return!1;let e=t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName);return e&&e.playing&&e.position&&e.position.x}execute(t){this.pather=new T(t.pathing.nodeList);let e=t.players[this.idOrName.toString()]||t.players.find((c)=>c.name===this.idOrName),s=Object.entries(t.me.position).map((c)=>Math.floor(c[1])),i=Object.entries(e.position).map((c)=>Math.floor(c[1])),r=t.pathing.nodeList.at(...s),n=t.pathing.nodeList.at(...i);if(t.pathing.activePath=this.pather.path(r,n),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var ue=ae;class fe{validate(t){return t.intents.includes(t.Intents.PATHFINDING)}check(t){return t.me.playing&&t.game.spatula&&t.game.spatula.coords&&t.game.spatula.coords.x}execute(t){this.pather=new T(t.pathing.nodeList);let e=Object.entries(t.me.position).map((n)=>Math.floor(n[1])),s=Object.entries(t.game.spatula.coords).map((n)=>Math.floor(n[1])),i=t.pathing.nodeList.at(...e),r=t.pathing.nodeList.at(...s);if(t.pathing.activePath=this.pather.path(i,r),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var me=fe;var is=(t,e)=>(t%e+e)%e,os=Math.PI*2,pe=(t)=>Math.round(t*8192)/8192,rs=(t)=>pe(is(Math.atan2(-t.x,-t.z),os)),ns=(t)=>pe(Math.atan2(t.y,Math.hypot(t.x,t.z)));class de{idOrName;constructor(t){this.idOrName=t}validate(t){return!!(t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName))}check(t){if(!t.me.playing)return!1;let e=t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName);return e&&e.playing&&e.position&&e.position.x}execute(t){let e=t.players[this.idOrName.toString()]||t.players.find((n)=>n.name===this.idOrName),s={x:e.position.x-t.me.position.x,y:e.position.y-t.me.position.y-0.05,z:e.position.z-t.me.position.z},i=rs(s),r=ns(s);t.state.yaw=i,t.state.pitch=r}}var le=de;class ge{validate(){return!0}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee}execute(t){let e=new p;e.packInt8(a.melee),e.send(t.game.socket),t.usingMelee=!0,setTimeout(()=>{t.usingMelee=!1,t.swappingGun=!0,setTimeout(()=>{t.swappingGun=!1},0.5*pt)},566.6666666666667)}}var xe=ge;class we{validate(){return!0}check(t){return t.me.playing}execute(t){let e=new p;e.packInt8(a.pause),e.send(t.game.socket),setTimeout(()=>t.me.playing=!1,3000)}}var ke=we;class Me{validate(){return!0}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee}execute(t){let e=new p;e.packInt8(a.reload),e.send(t.game.socket);let s=t.me.weapons[t.me.activeGun];if(s.ammo){let n=Math.min(Math.min(s.ammo.capacity,s.ammo.reload)-s.ammo.rounds,s.ammo.store);s.ammo.rounds+=n,s.ammo.store-=n}t.emit("playerReload",t.me,s);let i=t.me.weapons[t.me.activeGun],r=i.ammo.rounds<1;t.state.reloading=!0,setTimeout(()=>t.state.reloading=!1,r?i.longReloadTime:i.shortReloadTime)}}var Se=Me;class ye{constructor(t,e={}){if(this.idOrName=t,this.reasons=[!!e.cheating,!!e.harassment,!!e.offensive,!!e.other],!this.reasons.includes(!0))this.reasons[3]=!0;for(let s=0;s<this.reasons.length;s++)if(this.reasons[s]===!0)this.reasonInt|=1<<s}validate(t){if(this.reasons.every((s)=>s===!1))return!1;if(!(t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName)))return!1;return!0}check(t){if(!t.state.inGame)return!1;return!!(t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName))}execute(t){let e=t.players[this.idOrName.toString()]||t.players.find((i)=>i.name===this.idOrName),s=new p;s.packInt8(a.reportPlayer),s.packString(e.uniqueId),s.packInt8(this.reasonInt),s.send(t.game.socket)}}var ze=ye;class Te{validate(){return!0}check(t){return t.game.isGameOwner}execute(t){let e=new p;e.packInt8(a.gameAction),e.packInt8(L.Reset),e.send(t.game.socket)}}var Ee=Te;var q=(t)=>l(t)&&l(t).unlock==="default",U=(t,e)=>l(t)&&l(t).item_type_id===e;class Pe{constructor(t){this.changes={classIdx:t.gunId,hatId:t.hatId,stampId:t.stampId,grenadeId:t.grenadeId,meleeId:t.meleeId,colorIdx:t.eggColor,primaryId:t.primaryIds,secondaryId:t.secondaryIds},this.changes=Object.fromEntries(Object.entries(this.changes).filter(([,e])=>!!e))}validate(t){let e=this.changes;if(e.colorIdx&&e.colorIdx>=7&&!t.account.vip)return!1;if(e.colorIdx&&e.colorIdx>=14)return!1;if(U(e.hatId,P.Hat)&&!q(e.hatId)&&!t.account.ownedItemIds.includes(e.hatId))return!1;if(U(e.stampId,P.Stamp)&&!q(e.stampId)&&!t.account.ownedItemIds.includes(e.stampId))return!1;if(U(e.grenadeId,P.Grenade)&&!q(e.grenadeId)&&!t.account.ownedItemIds.includes(e.grenadeId))return!1;if(U(e.meleeId,P.Melee)&&!q(e.meleeId)&&!t.account.ownedItemIds.includes(e.meleeId))return!1;if(typeof e.classIdx==="number"&&e.classIdx>6||e.classIdx<0)return!1;if(this.changes.primaryId)for(let s=0;s<7;s++){let i=this.changes.primaryId[s];if(!U(i,P.Primary)||!q(i)&&!t.account.ownedItemIds.includes(i))return!1}if(this.changes.secondaryId)for(let s=0;s<7;s++){let i=this.changes.secondaryId[s];if(!U(i,P.Secondary)||!q(i)&&!t.account.ownedItemIds.includes(i))return!1}return!0}check(t){return!t.me.playing}execute(t){if(t.me&&this.changes.classIdx&&this.changes.classIdx!==t.me.selectedGun)t.me.weapons[0]=new _[this.changes.classIdx];t.state.weaponIdx=this.changes.classIdx||t.state.weaponIdx;let e={...t.account.loadout,...this.changes},s=t.api.queryServices({cmd:"saveLoadout",save:!0,firebaseId:t.account.firebaseId,sessionId:t.account.sessionId,loadout:e});if(t.account.loadout=e,t.me)s.then(()=>{if(t.state.inGame){let r=new p;r.packInt8(a.changeCharacter),r.packInt8(this.changes?.classIdx||t.me.selectedGun),r.send(t.game.socket)}let i=t.intents.includes(t.Intents.COSMETIC_DATA);Object.entries(this.changes).forEach(([r,n])=>{if(r==="classIdx")t.me.selectedGun=n;else if(r==="hatId")t.me.character.hat=i?l(n):n;else if(r==="stampId")t.me.character.stamp=i?l(n):n;else if(r==="grenadeId")t.me.character.grenade=i?l(n):n;else if(r==="meleeId")t.me.character.melee=i?l(n):n;else if(r==="colorIdx")t.me.character.eggColor=n;else if(r==="primaryId")t.me.character.primaryGun=i?l(n[t.me.selectedGun]):n;else if(r==="secondaryId")t.me.character.secondaryGun=i?l(n[t.me.selectedGun]):n})})}}var Ne=Pe;class Ge{validate(){return!0}check(t){if(t.me.playing)return!1;if(t.lastDeathTime+6000<Date.now())return!1;if(t.intents.includes(t.Intents.OBSERVE_GAME))return!1;return!0}execute(t){let e=new p;e.packInt8(a.requestRespawn),e.send(t.game.socket),t.state.buffer=[]}}var Oe=Ge;class Re{constructor(t){this.manualWeapon=t}validate(){return typeof this.manualWeapon==="number"||typeof this.manualWeapon>"u"}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee}execute(t){let e=+!t.me.activeGun;if(typeof this.manualWeapon==="number")e=this.manualWeapon;t.me.activeGun=e;let s=new p;s.packInt8(a.swapWeapon),s.packInt8(t.me.activeGun),s.send(t.game.socket)}}var _e=Re;class Ae{validate(){return!0}check(t){if(!t.state.inGame||t.me.playing)return!1;if(t.game.gameModeId===0)return!1;if(t.intents.includes(t.Intents.OBSERVE_GAME))return!1;if(t.game.isPrivate)return!t.game.options.noTeamChange;let e=t.players,s=t.me.team,i=e.filter((n)=>n.team===s).length,r=e.filter((n)=>n.team!==s).length;if(r>i)return!1;if(i===r)return!1;return!0}execute(t){let e=new p;e.packInt8(a.switchTeam),e.send(t.game.socket)}}var ve=Ae;class Ce{constructor(t=1){this.power=t}validate(){return typeof this.power==="number"&&this.power>=0&&this.power<=1}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee}execute(t){let e=new p;e.packInt8(a.throwGrenade),e.packFloat(this.power),e.send(t.game.socket)}}var Le=Ce;var cs={BanPlayerDispatch:Qt,BootPlayerDispatch:It,ChatDispatch:Vt,FireDispatch:te,GameOptionsDispatch:se,GoToAmmoDispatch:oe,GoToCoopDispatch:ne,GoToGrenadeDispatch:he,GoToPlayerDispatch:ue,GoToSpatulaDispatch:me,LookAtDispatch:le,LookAtPosDispatch:J,MeleeDispatch:xe,MovementDispatch:K,PauseDispatch:ke,ReloadDispatch:Se,ReportPlayerDispatch:ze,ResetGameDispatch:Ee,SaveLoadoutDispatch:Ne,SpawnDispatch:Oe,SwapWeaponDispatch:_e,SwitchTeamDispatch:ve,ThrowGrenadeDispatch:Le};var Fe={};tt(Fe,{CommOut:()=>p,CommIn:()=>o,CommCode:()=>a,CloseCode:()=>D});export{xt as Matchmaker,b as Maps,Ot as Guns,gt as GamePlayer,cs as Dispatches,Rt as Constants,Fe as Comm,Zt as Bot,lt as API};
|
|
1
|
+
var qe=Object.defineProperty;var tt=(t,e)=>{for(var s in e)qe(t,s,{get:e[s],enumerable:!0,configurable:!0,set:(i)=>e[s]=()=>i})};var Ue=globalThis.fetch,Tt=Ue;console.error("wwws does not support the browser.");var Et=null;var W={},Z=typeof window<"u"&&typeof HTMLElement<"u",et=typeof WebSocketPair<"u"&&typeof Cloudflare<"u",Pt=typeof process<"u"&&process.moduleLoadList?.length>0,Nt=typeof Deno<"u",Gt=typeof process<"u"&&!!process.versions?.bun;if(!Z&&!et&&!Pt&&!Nt&&!Gt)throw Error("yolkbot doesn't know how to run in this environment. Please open an issue on GitHub with information on where you run yolkbot.");W.isBrowser=Z;W.isIsolated=!Pt&&!Nt&&!Gt;W.fetch=Z||et?globalThis.fetch:Tt;W.WebSocket=Z||et?globalThis.WebSocket:Et;var w=W;var Rt={};tt(Rt,{findItemById:()=>l,UserAgent:()=>$,URLRewards:()=>Ke,Team:()=>Je,StateBufferSize:()=>j,SocialReward:()=>Be,SocialMedia:()=>dt,ShellStreak:()=>g,PlayType:()=>X,Movement:()=>S,ItemType:()=>P,GunList:()=>_,GunEquipTime:()=>pt,GameOptionFlag:()=>mt,GameMode:()=>M,GameAction:()=>L,FramesBetweenSyncs:()=>C,FirebaseKey:()=>R,CoopState:()=>Q,CollectType:()=>Y,ChiknWinnerDailyLimit:()=>ft,ChatFlag:()=>$e,ChallengeType:()=>je,ChallengeSubType:()=>We,BanDuration:()=>ut});var Ot={};tt(Ot,{SMG:()=>ct,RPEGG:()=>nt,M24:()=>ht,Eggk47:()=>st,DozenGauge:()=>it,Cluck9mm:()=>rt,CSG1:()=>ot,AUG:()=>at});var G=class{constructor(){this.adsMod=0.5,this.burst=0,this.burstRof=0,this.movementAccuracyMod=1,this.radius=0,this.reloadBloom=!0,this.reloadTimeMod=1,this.tracer=0}},st=class extends G{constructor(){super();this.ammo={rounds:30,capacity:30,reload:30,store:240,storeMax:240,pickup:30},this.longReloadTime=205,this.shortReloadTime=160,this.weaponName="EggK-47",this.internalName="Eggk47",this.standardMeshName="eggk47",this.automatic=!0,this.damage=30,this.range=20,this.recoil=7,this.rof=3,this.totalDamage=30,this.velocity=1.5,this.accuracyMin=0.15,this.accuracyMax=0.03,this.accuracyLoss=0.05,this.accuracyRecover=0.025,this.tracer=1}},it=class extends G{constructor(){super();this.ammo={rounds:2,capacity:2,reload:2,store:24,storeMax:24,pickup:8},this.longReloadTime=155,this.shortReloadTime=155,this.weaponName="Scrambler",this.internalName="Dozen Gauge",this.standardMeshName="dozenGauge",this.automatic=!1,this.damage=8.5,this.range=8,this.recoil=10,this.rof=8,this.totalDamage=170,this.velocity=1,this.accuracyMin=0.16,this.accuracyMax=0.13,this.accuracyLoss=0.17,this.accuracyRecover=0.02,this.adsMod=0.6,this.movementAccuracyMod=0.2,this.tracer=0}},ot=class extends G{constructor(){super();this.ammo={rounds:15,capacity:15,reload:15,store:60,storeMax:60,pickup:15},this.longReloadTime=225,this.shortReloadTime=165,this.weaponName="Free Ranger",this.internalName="CSG-1",this.standardMeshName="csg1",this.automatic=!1,this.damage=105,this.range=50,this.recoil=13,this.rof=13,this.totalDamage=105,this.velocity=1.75,this.accuracyMin=0.3,this.accuracyMax=0.004,this.accuracyLoss=0.3,this.accuracyRecover=0.025,this.tracer=0}},rt=class extends G{constructor(){super();this.ammo={rounds:15,capacity:15,reload:15,store:60,storeMax:60,pickup:15},this.longReloadTime=195,this.shortReloadTime=160,this.weaponName="Cluck 9mm",this.internalName="Cluck 9mm",this.standardMeshName="cluck9mm",this.automatic=!1,this.damage=26,this.range=15,this.recoil=6,this.rof=4,this.totalDamage=26,this.velocity=1,this.accuracyMin=0.15,this.accuracyMax=0.035,this.accuracyLoss=0.09,this.accuracyRecover=0.08,this.adsMod=0.8,this.movementAccuracyMod=0.6,this.tracer=0}},nt=class extends G{constructor(){super();this.ammo={rounds:1,capacity:1,reload:1,store:3,storeMax:3,pickup:1},this.longReloadTime=170,this.shortReloadTime=170,this.weaponName="RPEGG",this.internalName="Eggsploder",this.standardMeshName="rpegg",this.automatic=!1,this.damage=140,this.range=45,this.recoil=60,this.rof=40,this.totalDamage=192.5,this.velocity=0.4,this.accuracyMin=0.3,this.accuracyMax=0.015,this.accuracyLoss=0.3,this.accuracyRecover=0.02,this.radius=2.75}},ct=class extends G{constructor(){super();this.ammo={rounds:40,capacity:40,reload:40,store:200,storeMax:200,pickup:40},this.longReloadTime=225,this.shortReloadTime=190,this.weaponName="Whipper",this.internalName="SMEGG",this.standardMeshName="smg",this.automatic=!0,this.damage=23,this.range=20,this.recoil=7,this.rof=2,this.totalDamage=23,this.velocity=1.25,this.accuracyMin=0.19,this.accuracyMax=0.06,this.accuracyLoss=0.045,this.accuracyRecover=0.05,this.adsMod=0.6,this.movementAccuracyMod=0.7,this.tracer=2}},ht=class extends G{constructor(){super();this.ammo={rounds:1,capacity:1,reload:1,store:12,storeMax:12,pickup:4},this.longReloadTime=144,this.shortReloadTime=144,this.weaponName="Crackshot",this.internalName="M2DZ",this.standardMeshName="m24",this.automatic=!0,this.damage=170,this.range=60,this.recoil=20,this.rof=15,this.totalDamage=170,this.velocity=2,this.accuracyMin=0.35,this.accuracyMax=0,this.accuracyLoss=0.1,this.accuracyRecover=0.023,this.movementAccuracyMod=1.3,this.reloadBloom=!1,this.reloadTimeMod=0.8,this.tracer=0}},at=class extends G{constructor(){super();this.ammo={rounds:24,capacity:24,reload:24,store:150,storeMax:150,pickup:24},this.longReloadTime=205,this.shortReloadTime=160,this.weaponName="Tri-Hard",this.internalName="AUG",this.standardMeshName="aug",this.automatic=!1,this.damage=32,this.range=20,this.recoil=18,this.rof=15,this.totalDamage=34,this.velocity=1.5,this.accuracyMin=0.15,this.accuracyMax=0.03,this.accuracyLoss=0.037,this.accuracyRecover=0.03,this.adsMod=0.6,this.burst=3,this.burstRof=3,this.movementAccuracyMod=0.8,this.movementInstability=2,this.tracer=0}};var l=()=>null;var ut={FiveMinutes:0,FifteenMinutes:1,OneHour:2},We={Killstreak:0,KillWithWeapon:1,MovementDistance:3,Jumping:4,TimePlayed:6,TimeAlive:7,KillWithCondition:8,TotalKills:10,SpatulaKills:10,Collecting:18,FromTheCoop:20,SpecialOffensive:21,WinKOTC:23,KillWithSpatula:23},je={Kill:0,Damage:1,Death:2,Movement:3,Collect:4,Time:5,KOTC:6,Spatula:7},$e={None:0,Pinned:2,Team:4,Mod:254,Server:255},ft=3,Y={Ammo:0,Grenade:1},Q={Start:0,Score:1,Win:2,Capturing:3,Contested:4,Takeover:5,Abandoned:6,Unclaimed:7},R="AIzaSyDP4SIjKaw6A4c-zvfYxICpbEjn1rRnN50",C=3,L={Reset:1,Pause:2},M={FFA:0,Team:1,Spatula:2,KOTC:3},mt={Locked:1,NoTeamChange:2,NoTeamShuffle:4},pt=13,_=[st,it,ot,nt,ct,ht,at],P={Hat:1,Stamp:2,Primary:3,Secondary:4,Grenade:6,Melee:7},S={Forward:1,Backward:2,Left:4,Right:8,Jump:16,Fire:32,Melee:64,Scope:128},X={JoinPublic:0,CreatePrivate:1,JoinPrivate:2},g={HardBoiled:1,EggBreaker:2,Restock:4,OverHeal:8,DoubleEggs:16,MiniEgg:32},dt={Facebook:0,Instagram:1,Tiktok:2,Discord:3,Youtube:4,Twitter:5,Twitch:6},Be={Discord:"rew_1200",Tiktok:"rew_1208",Instagram:"rew_1219",Steam:"rew_1223",Facebook:"rew_1227",Twitter:"rew_1234",Twitch:"rew_twitch_social"},j=256,Je={Blue:1,Red:2},Ke=["giveBasketBrosReward","mercZoneFinalGift","midMonthGiveMeEggs","newYolkerSignupReward","newYolkerItemReward","newYolkerWelcomeBack","WelcomeBack"],$=w.isBrowser?null:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36";class _t{url="";proxy="";binaryType="";maxRetries=5;connectionTimeout=5000;constructor(t,e){if(w.isBrowser&&e)throw Error("You cannot pass a proxy to a WebSocket in a browser.");this.url=t,this.proxy=e}async tryConnect(t=1){let e=new URL(this.url),s=async()=>{if(t===5)return!1;return await this.tryConnect(t+1)};try{if(this.socket=w.isBrowser?new w.WebSocket(this.url):new w.WebSocket(this.url,{proxy:this.proxy||null,headers:{"accept-encoding":"gzip, deflate, br, zstd","accept-language":"en-US,en;q=0.9","cache-control":"no-cache",connection:"Upgrade",origin:e.origin.replace("ws","http"),pragma:"no-cache","sec-websocket-extensions":"permessage-deflate; client_max_window_bits","user-agent":$}}),this.binaryType)this.socket.binaryType=this.binaryType}catch(i){return console.error(`Failed to connect on try ${t}, trying again...`,i),await s()}if(this.onBeforeConnect)this.onBeforeConnect();return new Promise((i)=>{let r=setTimeout(async()=>{this.socket.close(),i(await s())},this.connectionTimeout),n=async(c)=>{clearTimeout(r),console.error("WebSocket error",c),i(await s())};this.socket.addEventListener("open",async()=>{clearTimeout(r),this.socket.removeEventListener("error",n),i(!0)}),this.socket.addEventListener("error",n)})}get onmessage(){return this.socket?.onmessage}set onmessage(t){if(this.socket)this.socket.onmessage=t;else console.error("set onmessage before socket existed")}get onclose(){return this.socket?.onclose}set onclose(t){if(this.socket)this.socket.onclose=t;else console.error("set onclose before socket existed")}get onerror(){return this.socket?.onerror}set onerror(t){if(this.socket)this.socket.onerror=t;else console.error("set onclose before socket existed")}send(t){return this.socket?.send(t)}close(t){return this.socket?.close(t)}}var F=_t;var B={origin:"https://shellshock.io","user-agent":$,"x-client-version":"Chrome/JsCore/9.17.2/FirebaseCore-web","x-firebase-locale":"en"};class lt{constructor(t={}){this.proxy=t.proxy,this.instance=t.instance||"shellshock.io",this.protocol=t.protocol||"wss",this.maxRetries=t.maxRetries||5,this.suppressErrors=t.suppressErrors||!1,this.connectionTimeout=t.connectionTimeout||5000}queryServices=async(t)=>{let e=new F(`${this.protocol}://${this.instance}/services/`,this.proxy);if(e.connectionTimeout=this.connectionTimeout,!await e.tryConnect(-2)||e.socket.readyState!==1)return"websocket_connect_fail";return new Promise((i)=>{let r=!1;e.onmessage=(n)=>{r=!0;try{let c=JSON.parse(n.data);i(c)}catch{if(!this.suppressErrors)console.error("queryServices: Bad API JSON response with call:",t.cmd,"and data:",JSON.stringify(t)),console.error("queryServices: Full data sent:",JSON.stringify(t));i("bad_json")}e.close()},e.onerror=()=>!r&&i("unknown_socket_error"),e.onclose=()=>!r&&i("services_closed_early"),e.send(JSON.stringify(t))})};#t=async(t,e,s)=>{if(!t||!e)return"firebase_no_credentials";let i,r;try{i=await(await w.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:${s}?key=${R}`,{method:"POST",body:JSON.stringify({email:t,password:e,returnSecureToken:!0}),headers:{...B,"content-type":"application/json"},proxy:this.proxy})).json(),r=i.idToken}catch(c){if(c.code==="auth/network-request-failed"){if(!this.suppressErrors)console.error("loginWithCredentials: Network req failed (auth/network-request-failed)");return"firebase_network_failed"}else if(c.code==="auth/missing-email")return"firebase_no_credentials";else if(c.code==="ERR_BAD_REQUEST"){if(!this.suppressErrors)console.error("loginWithCredentials: Error:",t,e);if(!this.suppressErrors)console.error("loginWithCredentials: Error:",i||c);return"firebase_bad_request"}if(!this.suppressErrors)console.error("loginWithCredentials: Error:",t,e,c);return"firebase_unknown_error"}if(!r){if(!this.suppressErrors)console.error("loginWithCredentials: the game sent no idToken",i);return"firebase_no_token"}this.idToken=r;let n=await this.queryServices({cmd:"auth",firebaseToken:r});return typeof n==="object"?{firebase:i,...n}:n};createAccount=async(t,e)=>await this.#t(t,e,"signUp");loginWithCredentials=async(t,e)=>await this.#t(t,e,"signInWithPassword");loginWithRefreshToken=async(t)=>{if(!t)return"firebase_no_credentials";let e=new URLSearchParams;e.append("grant_type","refresh_token"),e.append("refresh_token",t);let s,i;try{s=await(await w.fetch(`https://securetoken.googleapis.com/v1/token?key=${R}`,{method:"POST",body:e,headers:{...B,"content-type":"application/x-www-form-urlencoded"},proxy:this.proxy})).json(),i=s.id_token}catch(n){if(n.code==="auth/network-request-failed"){if(!this.suppressErrors)console.error("loginWithRefreshToken: Network req failed (auth/network-request-failed)");return"firebase_network_failed"}else if(n.code==="auth/missing-email")return"firebase_no_credentials";if(!this.suppressErrors)console.error("loginWithRefreshToken: Error:",n,t);return"firebase_unknown_error"}if(!i){if(!this.suppressErrors)console.error("loginWithRefreshToken: the game sent no idToken",s);return"firebase_no_token"}this.idToken=i;let r=await this.queryServices({cmd:"auth",firebaseToken:i});return typeof r==="object"?{firebase:s,...r}:r};loginAnonymously=async()=>{let e=await(await w.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=${R}`,{method:"POST",body:JSON.stringify({returnSecureToken:!0}),headers:{...B,"content-type":"application/json"},proxy:this.proxy})).json(),s=e.idToken;if(!s){if(!this.suppressErrors)console.error("loginAnonymously: the game sent no idToken",e);return"firebase_no_token"}this.idToken=s;let i=await this.queryServices({cmd:"auth",firebaseToken:s});return typeof i==="object"?{firebase:e,...i}:i};sendEmailVerification=async(t=this.idToken)=>{if(!t)return"no_idtoken_passed";let s=await(await w.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode?key=${R}`,{method:"POST",body:JSON.stringify({requestType:"VERIFY_EMAIL",idToken:t}),headers:{...B,"content-type":"application/json"},proxy:this.proxy})).json();if(s.kind!=="identitytoolkit#GetOobConfirmationCodeResponse"){if(!this.suppressErrors)console.error("sendEmailVerification: the game sent an invalid response",s);return"firebase_invalid_response"}return{email:s.email}};verifyOobCode=async(t)=>{if(!t)return"no_oob_code_passed";let s=await(await w.fetch(`https://www.googleapis.com/identitytoolkit/v3/relyingparty/setAccountInfo?key=${R}`,{method:"POST",body:JSON.stringify({oobCode:t}),headers:{...B,"x-client-version":"Chrome/JsCore/3.7.5/FirebaseCore-web",referer:"https://shellshockio-181719.firebaseapp.com/","content-type":"application/json"},proxy:this.proxy})).json();if(!s.emailVerified){if(!this.suppressErrors)console.error("verifyOobCode: the game sent an invalid response",s);return"firebase_invalid_response"}return s.email}}var I=lt;class At{static buffer;static idx;static init(t){this.buffer=new Uint8Array(t),this.idx=0}static isMoreDataAvailable(){return Math.max(0,this.buffer.length-this.idx)}static unPackInt8U(){let t=this.idx;return this.idx++,this.buffer[t]}static unPackInt8(){return(this.unPackInt8U()+128)%256-128}static unPackInt16U(){let t=this.idx;return this.idx+=2,this.buffer[t]+this.buffer[t+1]*256}static unPackInt24U(){let t=this.idx;return this.idx+=3,this.buffer[t]+this.buffer[t+1]*256+this.buffer[t+2]*65536}static unPackInt32U(){let t=this.idx;return this.idx+=4,this.buffer[t]+this.buffer[t+1]*256+this.buffer[t+2]*65536+this.buffer[t+3]*16777216}static unPackInt16(){return(this.unPackInt16U()+32768)%65536-32768}static unPackInt32(){return(this.unPackInt32U()+2147483648)%4294967296-2147483648}static unPackRadU(){return this.unPackInt24U()/2097152}static unPackRad(){return this.unPackInt16U()/8192-Math.PI}static unPackFloat(){return this.unPackInt16()/256}static unPackDouble(){return this.unPackInt32()/1048576}static unPackString(t){t=t||255;let e=Math.min(this.unPackInt8U(),t);return this.unPackStringHelper(e)}static unPackLongString(t){t=t||16383;let e=Math.min(this.unPackInt16U(),t);return this.unPackStringHelper(e)}static unPackStringHelper(t){if(this.isMoreDataAvailable()<t)return 0;let s="";for(let i=0;i<t;i++){let r=this.unPackInt16U();if(r>0)s+=String.fromCodePoint(r)}return s}}var o=At;class vt{constructor(t=16384){this.idx=0,this.arrayBuffer=new ArrayBuffer(t),this.buffer=new Uint8Array(this.arrayBuffer,0,t)}send(t){let e=new Uint8Array(this.arrayBuffer,0,this.idx);t.send(e)}packInt8(t){this.buffer[this.idx]=t&255,this.idx++}packInt16(t){this.buffer[this.idx]=t&255,this.buffer[this.idx+1]=t>>8&255,this.idx+=2}packInt24(t){this.buffer[this.idx]=t&255,this.buffer[this.idx+1]=t>>8&255,this.buffer[this.idx+2]=t>>16&255,this.idx+=3}packInt32(t){this.buffer[this.idx]=t&255,this.buffer[this.idx+1]=t>>8&255,this.buffer[this.idx+2]=t>>16&255,this.buffer[this.idx+3]=t>>24&255,this.idx+=4}packRadU(t){this.packInt24(t*2097152)}packRad(t){this.packInt16((t+Math.PI)*8192)}packFloat(t){this.packInt16(t*256)}packDouble(t){this.packInt32(t*1048576)}packString(t){if(typeof t!=="string")t="";this.packInt8(t.length);for(let e=0;e<t.length;e++)this.packInt16(t.charCodeAt(e))}packLongString(t){if(typeof t!=="string")t="";this.packInt16(t.length);for(let e=0;e<t.length;e++)this.packInt16(t.charCodeAt(e))}}var p=vt;var He={gameNotFound:4000,gameFull:4001,badName:4002,mainMenu:4003,gameIdleExceeded:4004,corruptedLoginData0:4005,corruptedLoginData1:4006,corruptedLoginData2:4007,corruptedLoginData3:4008,corruptedLoginData4:4009,corruptedLoginData5:4010,gameMaxPlayersExceeded:4011,gameDestroyUser:4012,joinGameOutOfOrder:4013,gameShuttingDown:4014,readyBeforeReady:4015,booted:4016,gameErrorOnUserSocket:4017,uuidNotFound:4018,sessionNotFound:4019,clusterFullCpu:4020,clusterFullMem:4021,noClustersAvailable:4022,locked:4023},D=He;var Ze={},a=Ze;var Ye=Object.fromEntries(Object.entries(dt).map(([t,e])=>[e,t.toLowerCase()]));class gt{constructor(t,e=null){if(this.id=t.id,this.uniqueId=t.uniqueId,this.name=t.name,this.safeName=t.safeName,this.team=t.team,this.playing=t.playing,this.socials=t.social&&JSON.parse(t.social),this.socials)this.socials.forEach((s)=>s.type=Ye[s.id]);if(this.isVip=t.upgradeProductId>0,this.showBadge=!t.hideBadge||!1,this.streak=t.score,this.streakRewards=Object.values(g).filter((s)=>t.activeShellStreaks&s),this.scale=this.streakRewards.includes(g.MiniEgg)?0.5:1,this.position={x:t.x,y:t.y,z:t.z},this.jumping=t.$controlKeys&S.Jump,this.scoping=t.$controlKeys&S.Scope,this.climbing=!1,this.view={yaw:t.yaw,pitch:t.pitch},this.updateKotcZone(e),this.character={eggColor:t.shellColor,primaryGun:t.primaryWeaponItem,secondaryGun:t.secondaryWeaponItem,stamp:t.stampItem,hat:t.hatItem,grenade:t.grenadeItem,melee:t.meleeItem,stampPos:{x:t.stampPosX,y:t.stampPosY}},this.stats={totalKills:t.totalKills,totalDeaths:t.totalDeaths,bestStreak:t.bestStreak},this.activeGun=t.weaponIdx,this.selectedGun=t.charClass,this.weapons=[],this.character.primaryGun)this.weapons[0]=new _[this.selectedGun],this.weapons[1]=new rt;this.grenades=1,this.hp=t.hp,this.hpShield=0,this.spawnShield=t.shield,this.randomSeed=0}updateKotcZone(t){if(!t)return this.inKotcZone=!1;let e=Math.floor(this.position.x),s=Math.floor(this.position.y),i=Math.floor(this.position.z);this.inKotcZone=t.some((r)=>r.x===e&&r.y===s&&r.z===i)&&this.playing}}var V=gt;var Qe=(t)=>new Uint8Array(t.match(/.{2}/g).map((e)=>parseInt(e,16))),Xe=new TextEncoder,Ct=async(t)=>{if(typeof process<"u"&&typeof process.getBuiltinModule==="function"){let r=process.getBuiltinModule("node:crypto"),n=Buffer.from("3496afb51f42553e31635211400c000b","hex");return r.createHmac("sha256",n).update(t).digest("hex")}let e=Qe("3496afb51f42553e31635211400c000b"),s=await crypto.subtle.importKey("raw",e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),i=await crypto.subtle.sign("HMAC",s,Xe.encode(t));return Array.from(new Uint8Array(i)).map((r)=>r.toString(16).padStart(2,"0")).join("")},O=(t)=>{return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(t-1050359)},Lt=(t,e)=>{let s=Math.round(t/(Math.PI*2)*65535),i=0,r=Math.round((e+1.5)/3*32767),n=s<0?0:s;s=n>65535?65535:n;let c=Math.trunc(s);if(c<0)c=0;if(c>4294967295)c=4294967295;c=s>=0?c:0,c=s>65535?0:c;let h=c;i^=h;let m=r<0?0:r;s=m,m=s>32767?32767:s,s=m;let f=Math.trunc(s);if(f<0)f=0;if(f>4294967295)f=4294967295;f=s>=0?f:0,f=s>65535?0:f;let u=f,d=u,k=i^d,E=k&255,N=i<<8,A=(i&65280)>>>8;u=(N|A)>>>0;let H=E^u;k=k<<8|(k&65280)>>>8,h^=d,d=k^h&255,h=h<<8|(h&65280)>>>8,i=h^i&255;let z=[];return z[3]=O(1050359+(d&63)),z[7]=O(1050359+(u>>>8&63)),z[4]=O(1050359+(k>>>10&63)),z[0]=O(1050359+((i&252)>>>2)),z[5]=O(1050359+(k>>>4&48|H>>>4&15)),z[2]=O(1050359+(h>>>6&60|d>>>6&3)),z[6]=O(1050359+((u>>>14&3|H<<2)&63)),z[1]=O(1050359+((h>>>12&15|i<<4)&63)),String.fromCharCode(...z)};class xt{connected=!1;onceConnected=[];regionList=[];proxy=null;sessionId="";onListeners=new Map;onceListeners=new Map;#t=!1;#e=!1;constructor(t={}){if(this.#t=t.noExitOnError||!1,!t.instance)t.instance="shellshock.io";if(!t.protocol)t.protocol="wss";if(t.api)this.api=t.api;else this.api=new I({proxy:t.proxy,protocol:t.protocol,instance:t.instance,connectionTimeout:t.connectionTimeout});if(t.sessionId||t.noLogin)this.sessionId=t.sessionId;else this.#s();if(t.proxy&&w.isBrowser)this.#i("proxies do not work and hence are not supported in the browser");else if(t.proxy)this.proxy=t.proxy;this.#r(t.instance,t.protocol,t.noLogin,t.connectionTimeout)}async#r(t,e,s,i){if(this.ws=new F(`${e}://${t}/matchmaker/`,this.proxy),this.ws.connectionTimeout=i||5000,!await this.ws.tryConnect())return this.#i("WebSocket did not connect...");if(this.ws.onmessage=async(n)=>{let c=JSON.parse(n.data);if(c.command==="validateUUID")return this.ws.send(JSON.stringify({command:"validateUUID",hash:await Ct(c.uuid)}));this.#o("msg",c)},this.ws.onclose=()=>{if(this.connected=!1,!this.#e)this.#r(t,e,s,i)},this.connected=!0,this.sessionId||s)this.onceConnected.forEach((n)=>n())}async#s(){let t=await this.api.loginAnonymously();if(!t||typeof t==="string")this.#o("authFail",t);if(this.sessionId=t.sessionId,this.connected)this.onceConnected.forEach((e)=>e())}send(t){this.ws.send(JSON.stringify(t))}async waitForConnect(){return new Promise((t)=>{if(this.connected)t();else this.onceConnected.push(t)})}async getRegions(){await this.waitForConnect();let t=this;return new Promise((e)=>{let s=(i)=>{if(i.command==="regionList")this.regionList=i.regionList,this.off("msg",s),e(i.regionList)};this.on("msg",s),this.ws.onerror=(i)=>t.#i("failed to get regions",i),this.ws.send(JSON.stringify({command:"regionList"}))})}close(){this.#e=!0,this.connected=!1,this.ws.close()}on(t,e){if(!this.onListeners.has(t))this.onListeners.set(t,[]);this.onListeners.get(t).push(e)}once(t,e){if(!this.onceListeners.has(t))this.onceListeners.set(t,[]);this.onceListeners.get(t).push(e)}off(t,e){if(this.onListeners.has(t))this.onListeners.set(t,this.onListeners.get(t).filter((s)=>s!==e));if(this.onceListeners.has(t))this.onceListeners.set(t,this.onceListeners.get(t).filter((s)=>s!==e))}#o(t,...e){if(this.onListeners.has(t))this.onListeners.get(t).forEach((s)=>s(...e));if(this.onceListeners.has(t))this.onceListeners.get(t).forEach((s)=>s(...e)),this.onceListeners.delete(t)}#i(t){if(this.onListeners.has("error"))this.#o("error",t);else if(this.#t)console.error(t);else throw Error(t)}}var Ft=xt;var Ie=(t,e)=>(t%e+e)%e,De=Math.PI*2,qt=(t)=>Math.round(t*8192)/8192,Ve=(t)=>qt(Ie(Math.atan2(-t.x,-t.z),De)),be=(t)=>qt(Math.atan2(t.y,Math.hypot(t.x,t.z)));class Ut{constructor(t){this.pos=t}validate(){return this.pos&&this.pos.x&&this.pos.y&&this.pos.z}check(t){return t.me.playing}execute(t){let e={x:this.pos.x-t.me.position.x,y:this.pos.y-t.me.position.y,z:this.pos.z-t.me.position.z},s=Ve(e),i=be(e);t.state.yaw=s,t.state.pitch=i}}var J=Ut;class Wt{constructor(t){if(typeof t==="number")this.inputKeys=t;else if(typeof t==="object")this.inputKeys=t.reduce((e,s)=>e|s,0)}validate(){if(typeof this.inputKeys!=="number")return!1;if(this.inputKeys&S.Forward&&this.inputKeys&S.Backward)return!1;if(this.inputKeys&S.Left&&this.inputKeys&S.Right)return!1;return!0}check(t){return t.me.playing}execute(t){t.state.controlKeys=this.inputKeys}}var K=Wt;class wt{constructor(t,e){if(this.x=e.x,this.y=e.y,this.z=e.z,this.positionStr=`${this.x},${this.y},${this.z}`,this.position={x:this.x,y:this.y,z:this.z},this.meshType=t.split(".").pop(),this.f=0,this.g=0,this.h=0,this.visited=null,this.parent=null,this.closed=null,this.links=[],this.isStair())if(e.ry)this.ry=e.ry;else this.ry=0}isFull(){return this.meshType==="full"}canWalkThrough(){return this.meshType==="none"||this.meshType==="ladder"}canWalkOn(){return this.meshType==="full"}isLadder(){return this.meshType==="ladder"}isStair(){return this.meshType==="wedge"}isAir(){return this.meshType==="none"}canLink(t,e){let s=this.x-t.x,i=this.z-t.z,r=this.y-t.y,n=Math.abs(s),c=Math.abs(r),h=Math.abs(i);if(n+c+h===0||n+h>1||this.isFull()||t.isFull())return!1;let m=e.at(this.x,this.y-1,this.z),f=e.at(t.x,t.y-1,t.z);if(!m||!f)return!1;let u={0:{x:0,z:-1},1:{x:-1,z:0},2:{x:0,z:1},3:{x:1,z:0}};switch(this.meshType){case"none":if(r===1&&t.canWalkThrough())return!0;if(m.canWalkOn()||m.isLadder()){if(t.meshType==="none"||t.meshType==="ladder"&&c===0||t.meshType==="wedge"&&r===0&&s===-u[t.ry].x&&i===-u[t.ry].z)return!0}return!1;case"ladder":if(c===1&&t.canWalkThrough())return!0;if(c===0&&m.canWalkOn())return!0;if(t.meshType==="ladder"&&(c===1||m.canWalkOn()&&f.canWalkOn()))return!0;return!1;case"wedge":if(this.x+u[this.ry].x===t.x&&this.z+u[this.ry].z===t.z&&this.y+1===t.y)return!0;if(this.x-u[this.ry].x===t.x&&this.z-u[this.ry].z===t.z&&(this.y===t.y||this.y-1===t.y))return!0;return!1;default:return!1}}flatCenter(){return{x:this.x+0.5,y:this.y+0,z:this.z+0.5}}flatRadialDistance(t){let e=this.flatCenter();return Math.hypot(e.x-t.x,e.z-t.z)}}class kt{list=[];constructor(t){let e={};for(let i of Object.keys(t.data))for(let r of t.data[i])e[r.x<<16|r.y<<8|r.z]=!0,this.list.push(new wt(i,r));for(let i=0;i<t.width;i++)for(let r=0;r<t.height;r++)for(let n=0;n<t.depth;n++)if(!e[i<<16|r<<8|n])this.list.push(new wt("SPECIAL.air.none",{x:i,y:r,z:n}));let s=new Map;for(let i of this.list)s.set(i.positionStr,i);for(let i of this.list){let r=[{x:i.x+1,y:i.y,z:i.z},{x:i.x-1,y:i.y,z:i.z},{x:i.x,y:i.y+1,z:i.z},{x:i.x,y:i.y-1,z:i.z},{x:i.x,y:i.y,z:i.z+1},{x:i.x,y:i.y,z:i.z-1}];for(let n of r){let c=`${n.x},${n.y},${n.z}`,h=s.get(c);if(h&&i.canLink(h,this))i.links.push(h)}}}at(t,e,s){if(!this.nodeMap){this.nodeMap=new Map;for(let r of this.list){let n=`${r.x},${r.y},${r.z}`;this.nodeMap.set(n,r)}}let i=`${t},${e},${s}`;return this.nodeMap.get(i)}clean(){for(let t of this.list)t.f=0,t.g=0,t.h=0,t.visited=null,t.parent=null,t.closed=null}hasLineOfSight(t,e){let s=e.x-t.x,i=e.y-t.y,r=e.z-t.z,n=Math.max(Math.abs(s),Math.abs(i),Math.abs(r)),c=s/n,h=i/n,m=r/n,f=t.x,u=t.y,d=t.z;for(let k=0;k<=n;k++){let E=this.at(Math.round(f),Math.round(u),Math.round(d));if(E&&E.isFull())return!1;f+=c,u+=h,d+=m}return!0}}var jt=async(t,e)=>{if(!w.isIsolated&&typeof process<"u"){let{existsSync:i,mkdirSync:r,readFileSync:n,writeFileSync:c}=process.getBuiltinModule("node:fs"),{join:h}=process.getBuiltinModule("node:path"),{homedir:m}=process.getBuiltinModule("node:os"),f=h(m(),".yolkbot");if(!i(f))r(f);let u=h(f,"maps");if(!i(u))r(u);let d=h(u,`${t}-${e}.json`);if(i(d))return JSON.parse(n(d,"utf-8"));let k=await(await fetch(`https://esm.sh/gh/yolkorg/maps/maps/${t}.json?${e}`)).json();return c(d,JSON.stringify(k,null,4),{flag:"w+"}),k}return await(await fetch(`https://esm.sh/gh/yolkorg/maps/maps/${t}.json?${e}`)).json()},$t=(t)=>{let e=0,s={},i=[];for(let c of t){if(!s[c.x])s[c.x]={};if(!s[c.x][c.y])s[c.x][c.y]={};s[c.x][c.y][c.z]={zone:null}}let r=[{x:-1,z:0},{x:1,z:0},{x:0,z:-1},{x:0,z:1}],n=(c,h,m)=>s[c]&&s[c][h]&&s[c][h][m]?s[c][h][m]:null;for(let c of t)if(!s[c.x][c.y][c.z].zone){c.zone=++e,s[c.x][c.y][c.z].zone=c.zone;let h=[c],m;do{m=0;for(let f of t)if(!s[f.x][f.y][f.z].zone)for(let u of r){let d=n(f.x+u.x,f.y,f.z+u.z);if(d&&d.zone===c.zone){m++,f.zone=c.zone,s[f.x][f.y][f.z].zone=c.zone,h.push(f);break}}}while(m>0);i.push(h)}return i};var Bt=[];var b=[];var Mt=[];var Jt=Object.fromEntries(Object.entries(M).map(([t,e])=>[e,t])),Kt=Object.fromEntries(Object.entries(mt).map(([t,e])=>[t[0].toLowerCase()+t.slice(1),e])),Ht={CHALLENGES:1,BOT_STATS:2,PATHFINDING:3,PING:5,COSMETIC_DATA:6,PLAYER_HEALTH:7,PACKET_HOOK:8,LOG_PACKETS:10,NO_LOGIN:11,DEBUG_BUFFER:12,NO_AFK_KICK:16,LOAD_MAP:17,OBSERVE_GAME:18,NO_REGION_CHECK:19,NO_EXIT_ON_ERROR:20,RENEW_SESSION:21,VIP_HIDE_BADGE:22},St=(t,e)=>(t%e+e)%e;class Zt{static Intents=Ht;Intents=Ht;#t=[];#e={};#r=[];#s;#o;constructor(t={}){if(t.proxy&&w.isBrowser)this.processError("proxies do not work and hence are not supported in the browser");if(this.intents=t.intents||[],this.intents.includes(this.Intents.COSMETIC_DATA)){if(!l(1001))this.processError("you cannot use the COSMETIC_DATA intent inside of the singlefile browser bundles")}if(this.instance=t.instance||"shellshock.io",this.protocol=t.protocol||"wss",this.proxy=t.proxy||"",this.connectionTimeout=t.connectionTimeout||5000,this.state={name:"yolkbot",weaponIdx:0,useAltGameURL:!1,inGame:!1,chatLines:0,yaw:0,pitch:0,controlKeys:0,reloading:!1,swappingGun:!1,usingMelee:!1,stateIdx:0,serverStateIdx:0,shotsFired:0,buffer:[],left:!1},this.players={},this.me=new V({}),this.game={raw:{},code:"",socket:null,gameModeId:0,gameMode:Jt[0],mapIdx:0,map:{filename:"",hash:"",name:"",modes:{FFA:!1,Teams:!1,Spatula:!1,King:!1},availability:"both",numPlayers:"18",raw:{},nodes:{},zones:[]},playerLimit:0,isGameOwner:!1,isPrivate:!0,options:{gravity:1,damage:1,healthRegen:1,locked:!1,noTeamChange:!1,noTeamShuffle:!1,weaponsDisabled:Array(7).fill(!1),mustUseSecondary:!1},collectables:[[],[]],teamScore:[0,0,0],spatula:{coords:{x:0,y:0,z:0},controlledBy:0,controlledByTeam:0},stage:Q.Capturing,zoneNumber:0,activeZone:[],capturing:0,captureProgress:0,numCapturing:0,capturePercent:0},this.#o=this.game,this.account={id:0,firebase:{idToken:"",refreshToken:"",expiresIn:"3600",localId:""},firebaseId:"",sessionId:"",session:0,email:"",password:"",cw:{atLimit:!1,limit:0,secondsUntilPlay:0,canPlayAgain:Date.now()},loadout:{hatId:null,meleeId:0,stampId:null,classIdx:0,colorIdx:0,grenadeId:0,primaryId:[3100,3600,3400,3800,4000,4200,4500],secondaryId:[,,,,,,,].fill(3000),stampPositionX:0,stampPositionY:0},ownedItemIds:[],vip:!1,emailVerified:!1,isAged:!1,eggBalance:0,adminRoles:0,rawLoginData:{},isDoubleEggWeeknd:()=>{let e=new Date().getUTCDay(),s=new Date().getUTCHours();return e>=5&&s>=20||e===6||e===0}},this.#s=this.account,this.matchmaker=null,this.api=new I({proxy:this.proxy,protocol:this.protocol,instance:this.instance,maxRetries:t?.apiMaxRetries,connectionTimeout:this.connectionTimeout}),this.ping=0,this.lastPingTime=-1,this.lastDeathTime=-1,this.lastUpdateTick=0,this.pathing={nodeList:null,followingPath:!1,activePath:null,activeNode:null,activeNodeIdx:0},this.hasQuit=!1,this.intents.includes(this.Intents.NO_AFK_KICK))this.afkKickInterval=0;if(this.intents.includes(this.Intents.RENEW_SESSION))this.renewSessionInterval=0}dispatch(t){if(t.validate(this)){if(t.check(this))t.execute(this);else this.#t.push(t);return!0}return!1}async createAccount(t,e){this.account=this.#s,this.account.email=t,this.account.password=e;let s=await this.api.createAccount(t,e);return this.processLoginData(s)}async login(t,e){this.account=this.#s,this.account.email=t,this.account.password=e;let s=await this.api.loginWithCredentials(t,e);return this.processLoginData(s)}async loginWithRefreshToken(t){this.account=this.#s;let e=await this.api.loginWithRefreshToken(t);return this.processLoginData(e)}async loginAnonymously(){this.account=this.#s;let t=await this.api.loginAnonymously();return this.processLoginData(t)}processLoginData(t){if(typeof t!=="object")return this.emit("authFail",t),t;if(t.banRemaining)return this.emit("banned",t.banRemaining),"account_banned";if(!t.playerOutput)return this.emit("authFail",t),t;if(this.account.firebase=t.firebase||{},t=t.playerOutput,this.account.rawLoginData=t,this.account.adminRoles=t.adminRoles||0,this.account.eggBalance=t.currentBalance,this.account.emailVerified=t.emailVerified,this.account.firebaseId=t.firebaseId,this.account.id=t.id,this.account.isAged=new Date(t.dateCreated).getTime()<1714546800000,this.account.loadout=t.loadout,this.account.ownedItemIds=t.ownedItemIds,this.account.session=t.session,this.account.sessionId=t.sessionId,this.account.vip=t.active_sub==="IsVIP",this.intents.includes(this.Intents.BOT_STATS))this.account.stats={lifetime:t.statsLifetime,monthly:t.statsCurrent};if(this.intents.includes(this.Intents.CHALLENGES))this.#i(t.challenges);if(this.emit("authSuccess",this.account),this.intents.includes(this.Intents.RENEW_SESSION))this.renewSessionInterval=setInterval(async()=>{if(!this.account?.sessionId)return clearInterval(this.renewSessionInterval);if((await this.api.queryServices({cmd:"renewSession",sessionId:this.account.sessionId})).data!=="renewed")this.emit("sessionExpired")},600000);return this.account}#i(t){this.account.challenges=[];for(let e of t){let s=Bt.find((i)=>i.id===e.challengeId);if(!s)continue;delete e.playerId,this.account.challenges.push({raw:{challengeInfo:s,challengeData:e},id:e.challengeId,name:s.loc.title,desc:s.loc.desc,rewardEggs:s.reward,isRerolled:!!e.reset,isClaimed:!!e.claimed,isCompleted:!!e.completed,progressNum:e.progress,goalNum:s.goal})}}async initMatchmaker(){if(!this.account.sessionId&&!this.intents.includes(this.Intents.NO_LOGIN)){let t=await this.loginAnonymously();if(typeof t!=="object")return t}if(!this.matchmaker){if(this.matchmaker=new Ft({api:this.api,proxy:this.proxy,protocol:this.protocol,instance:this.instance,sessionId:this.account.sessionId,connectionTimeout:this.connectionTimeout,noLogin:this.intents.includes(this.Intents.NO_LOGIN)}),!await this.matchmaker.ws.tryConnect())return"matchmaker_tryconnect_failed";this.matchmaker.on("authFail",(e)=>this.emit("authFail",e)),this.matchmaker.on("error",(e)=>this.processError(e))}return!0}async findPublicGame(t,e){if(typeof t!=="string")return"no_region_passed";if(!Mt.find((i)=>i.id===t)&&!this.intents.includes(this.Intents.NO_REGION_CHECK))return"invalid_region_passed";if(typeof e!=="number")return"no_mode_passed";if(Object.values(M).indexOf(e)===-1)return"invalid_mode_passed";if(!await this.initMatchmaker())return"matchmaker_init_fail";return await new Promise((i)=>{let r=(n)=>{if(n.command==="notice")return;if(this.matchmaker.off("msg",r),n.command==="gameFound"){if(n.useAltGameURL)this.state.useAltGameURL=!0;return i(n)}if(n.error==="sessionNotFound")return i("internal_session_error");this.processError("unknown matchmaker response",JSON.stringify(n))};this.matchmaker.on("msg",r),this.matchmaker.send({command:"findGame",region:t,playType:X.JoinPublic,gameType:e,sessionId:this.account.sessionId})})}async createPrivateGame(t,e,s){if(typeof t!=="string")return"no_region_passed";if(!Mt.find((n)=>n.id===t)&&!this.intents.includes(this.Intents.NO_REGION_CHECK))return"invalid_region_passed";if(typeof e!=="number")return"no_mode_passed";if(Object.values(M).indexOf(e)===-1)return"invalid_mode_passed";if(typeof s!=="string")return"no_map_passed";let i=b.findIndex((n)=>n.name.toLowerCase()===s.toLowerCase());if(i===-1)return"invalid_map_passed";if(!await this.initMatchmaker())return"matchmaker_init_fail";return await new Promise((n)=>{let c=(h)=>{if(h.command==="notice")return;if(this.matchmaker.off("msg",c),h.command==="gameFound"){if(h.useAltGameURL)this.state.useAltGameURL=!0;return n(h)}if(h.error==="sessionNotFound")return n("internal_session_error");this.processError("unknown matchmaker response",JSON.stringify(h))};this.matchmaker.on("msg",c),this.matchmaker.send({command:"findGame",region:t,playType:X.CreatePrivate,gameType:e,sessionId:this.account.sessionId,noobLobby:!1,map:i})})}async join(t,e){if(this.state.name=t||"yolkbot",typeof e==="string"){if(e.includes("#"))e=e.split("#")[1];if(!await this.initMatchmaker())return"matchmaker_init_fail";if(await new Promise((n)=>{let c=(h)=>{if(h.command==="gameFound")this.matchmaker.off("msg",c),this.game.raw=h,this.game.code=h.id,n(h.id);if(h.error&&h.error==="gameNotFound")return this.processError(`game "${e}" not found, it may have expired.`),this.leave(),"gameNotFound"};this.matchmaker.on("msg",c),this.matchmaker.send({command:"joinGame",id:e,observe:!1,sessionId:this.account.sessionId})})==="gameNotFound")return"game_not_found";if(!this.game.raw.id)return this.processError("an internal error occured while joining the game, please report this to developers")}if(typeof e==="object"){if(this.account.id===0)await this.loginAnonymously();if(this.game.raw=e,this.game.code=this.game.raw.id,!this.game.raw.id)return"invalid_game_object";if(!this.game.raw.subdomain)return"invalid_game_object";if(!this.game.raw.uuid)return"invalid_game_object"}let s=this.state.useAltGameURL?`${this.instance}/servers/${this.game.raw.subdomain}`:`${this.game.raw.subdomain}.${this.instance}`;if(this.game.socket=new F(`${this.protocol}://${s}/game/${this.game.raw.id}`,this.proxy),this.game.socket.binaryType="arraybuffer",this.game.socket.connectionTimeout=this.connectionTimeout,this.game.socket.onBeforeConnect=()=>{this.game.socket.onmessage=(r)=>this.processPacket(r.data),this.game.socket.onclose=(r)=>{if(this.state.left)this.state.left=!1;else this.emit("close",r.code),this.leave(-1)}},!await this.game.socket.tryConnect())return"websocket_tryconnect_fail";return!0}#n(){if(Object.entries(this.me.position).map((e)=>Math.floor(e[1])).join(",")===this.pathing.activePath[this.pathing.activePath.length-1].positionStr)this.pathing.followingPath=!1,this.pathing.activePath=null,this.pathing.activeNode=null,this.pathing.activeNodeIdx=0,this.dispatch(new K(0));else{let e;if(this.pathing.activeNodeIdx<this.pathing.activePath.length-1)e=this.pathing.activePath[this.pathing.activeNodeIdx+1].flatCenter(),this.dispatch(new J(e));else e=this.pathing.activePath[this.pathing.activeNodeIdx].flatCenter(),this.dispatch(new J(e));for(let s of this.pathing.activePath)if(s.flatRadialDistance(this.me.position)<0.1&&s.position.y===Math.floor(this.me.position.y)){if(this.pathing.activePath.indexOf(s)>=this.pathing.activeNodeIdx){this.pathing.activeNodeIdx=this.pathing.activePath.indexOf(s)+1,this.pathing.activeNode=this.pathing.activePath[this.pathing.activeNodeIdx];break}}if(!(this.state.controlKeys&S.Forward))this.dispatch(new K(S.Forward))}}update(){if(this.hasQuit)return;if(this.pathing.followingPath&&this.intents.includes(this.Intents.PATHFINDING))this.#n();for(let e=0;e<this.#t.length;e++){let s=this.#t[e];if(s.check(this))s.execute(this),this.#t.splice(e,1)}if(this.state.chatLines=Math.max(0,this.state.chatLines-0.008333333333333333),this.me.playing){let e=this.state.stateIdx;if(this.intents.includes(this.Intents.DEBUG_BUFFER))console.log("setting buffer for idx",e),console.log("checking...shotsFired",this.state.shotsFired);if(this.me.jumping=!!(this.state.controlKeys&S.Jump),this.state.buffer[e]={controlKeys:this.state.controlKeys,yaw:this.state.yaw,pitch:this.state.pitch,shotsFired:this.state.shotsFired},this.state.shotsFired=0,this.lastUpdateTick>=2){this.emit("tick");let s=new p;s.packInt8(a.syncMe),s.packInt8(this.state.stateIdx),s.packInt8(this.state.serverStateIdx);let i=St(this.state.stateIdx-C+1,j);for(let r=0;r<C;r++){let n=St(i+r,j),c=this.state.buffer[n]||{},h=c.controlKeys||0,m=c.shotsFired||0,f=c.yaw??this.state.yaw,u=c.pitch??this.state.pitch;if(this.intents.includes(this.Intents.DEBUG_BUFFER))console.log("going with",this.state.stateIdx,i,n,c);s.packInt8(h),s.packInt8(m),s.packString(Lt(f,u)),s.packInt8(100)}s.send(this.game.socket),this.state.buffer=[],this.lastUpdateTick=0}else this.lastUpdateTick++;this.state.stateIdx=St(this.state.stateIdx+1,j)}if(!this.intents.includes(this.Intents.PLAYER_HEALTH))return;let t=0.1*(this.game.isPrivate?this.game.options.healthRegen:1);for(let e of Object.values(this.players)){if(e.playing&&e.hp>0){let s=e.streakRewards.includes(g.OverHeal);e.hp+=s?-t:t,e.hp=s?Math.max(100,e.hp):Math.min(100,e.hp)}if(e.spawnShield>0)e.spawnShield-=6}}on(t,e){if(Object.keys(this.#e).includes(t))this.#e[t].push(e);else this.#e[t]=[e]}once(t,e){let s=(...i)=>{e(...i),this.off(t,s)};this.on(t,s)}onAny(t){this.#r.push(t)}off(t,e){if(e)this.#e[t]=this.#e[t].filter((s)=>s!==e);else this.#e[t]=[]}emit(t,...e){if(this.hasQuit)return;if(this.#e[t])for(let s of this.#e[t])s(...e);for(let s of this.#r)s(t,...e)}#c(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=o.unPackString().valueOf(),i=this.players[t];this.emit("chat",i,s,e)}#h(){let t=o.unPackInt8U(),e=this.intents.includes(this.Intents.COSMETIC_DATA),s={id:t,uniqueId:o.unPackString(),name:o.unPackString(),safeName:o.unPackString(),charClass:o.unPackInt8U(),team:o.unPackInt8U(),primaryWeaponItem:e?l(o.unPackInt16U()):o.unPackInt16U(),secondaryWeaponItem:e?l(o.unPackInt16U()):o.unPackInt16U(),shellColor:o.unPackInt8U(),hatItem:e?l(o.unPackInt16U()):o.unPackInt16U(),stampItem:e?l(o.unPackInt16U()):o.unPackInt16U(),stampPosX:o.unPackInt8(),stampPosY:o.unPackInt8(),grenadeItem:e?l(o.unPackInt16U()):o.unPackInt16U(),meleeItem:e?l(o.unPackInt16U()):o.unPackInt16U(),x:o.unPackFloat(),y:o.unPackFloat(),z:o.unPackFloat(),$dx:o.unPackFloat(),$dy:o.unPackFloat(),$dz:o.unPackFloat(),yaw:o.unPackRadU(),pitch:o.unPackRad(),score:o.unPackInt32U(),$kills:o.unPackInt16U(),$deaths:o.unPackInt16U(),$streak:o.unPackInt16U(),totalKills:o.unPackInt32U(),totalDeaths:o.unPackInt32U(),bestStreak:o.unPackInt16U(),$bestOverallStreak:o.unPackInt16U(),shield:o.unPackInt8U(),hp:o.unPackInt8U(),playing:o.unPackInt8U(),weaponIdx:o.unPackInt8U(),$controlKeys:o.unPackInt8U(),upgradeProductId:o.unPackInt8U(),activeShellStreaks:o.unPackInt8U(),social:o.unPackLongString(),hideBadge:o.unPackInt8U()};this.game.mapIdx=o.unPackInt8U(),this.game.isPrivate=o.unPackInt8U()===1,this.game.gameModeId=o.unPackInt8U();let i=new V(s,this.game.gameMode===M.KOTC?this.game.activeZone:null);if(!this.players[s.id])this.players[s.id]=i;if(this.emit("playerJoin",i),this.me.id===s.id)this.me=i,this.emit("botJoin",this.me)}#a(){let t=o.unPackInt8U(),e=o.unPackInt16U(),s=o.unPackFloat(),i=o.unPackFloat(),r=o.unPackFloat(),n=o.unPackInt8U(),c=o.unPackInt8U(),h=o.unPackInt8U(),m=o.unPackInt8U(),f=o.unPackInt8U(),u=this.players[t];if(u){if(u.playing=!0,u.randomSeed=e,u.weapons[0]&&u.weapons[0].ammo)u.weapons[0].ammo.rounds=n;if(u.weapons[0]&&u.weapons[0].ammo)u.weapons[0].ammo.store=c;if(u.weapons[1]&&u.weapons[1].ammo)u.weapons[1].ammo.rounds=h;if(u.weapons[1]&&u.weapons[1].ammo)u.weapons[1].ammo.store=m;u.grenades=f,u.position={x:s,y:i,z:r},u.spawnShield=120,this.emit("playerRespawn",u)}}#u(){let t=o.unPackInt8U(),e=o.unPackFloat(),s=o.unPackFloat(),i=o.unPackFloat(),r=o.unPackInt8U(),n=this.players[t];if(!n||n.id===this.me.id){for(let N=0;N<C;N++)o.unPackInt8U(),o.unPackRadU(),o.unPackRad(),o.unPackInt8U();return}for(let N=0;N<C;N++){let A=o.unPackInt8U();if(A&S.Jump)n.jumping=!0;else n.jumping=!1;if(A&S.Scope)n.scoping=!0;else n.scoping=!1;let v={...n.view};if(n.view.yaw=o.unPackRadU(),n.view.pitch=o.unPackRad(),n.view.yaw!==v.yaw||n.view.pitch!==v.pitch)this.emit("playerRotate",n,v,n.view);n.scale=o.unPackInt8U()}let c=n.position,h=c.x!==e||c.y!==s||c.z!==i,m=n.climbing!==r,f=h||m,u=f?{...c}:null;if(c.x!==e)c.x=e;if(c.z!==i)c.z=i;if(!n.jumping||Math.abs(c.y-s)>0.5)c.y=s;if(m)n.climbing=r;if(!f)return;if(this.emit("playerMove",n,u,c),this.game.gameModeId!==M.KOTC)return;let d=this.game.activeZone,k=!!n.inKotcZone;if(!d&&k){n.inKotcZone=!1,this.emit("playerLeaveZone",n);return}n.updateKotcZone(d);let E=!!n.inKotcZone;if(k!==E)n.inKotcZone=E,this.emit(E?"playerEnterZone":"playerLeaveZone",n)}#f(){let t=o.unPackInt8U(),e=this.players[t];if(e){if(e.playing=!1,e.streakRewards)e.streakRewards=[];if(this.emit("playerPause",e),e.inKotcZone)e.inKotcZone=!1,this.emit("playerLeaveZone",e)}}#m(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(s)s.activeGun=e,this.emit("playerSwapWeapon",s,e)}#p(){let t=o.unPackInt8U(),e=o.unPackInt8U();o.unPackInt8U(),o.unPackInt8U();let s=o.unPackInt8U(),i=this.players[t],r=this.players[e],n=i?{...i}:null;if(i){if(i.id===this.me.id)this.lastDeathTime=Date.now();i.playing=!1,i.streak=0,i.hp=100,i.spawnShield=0,i.stats.totalDeaths++,i.inKotcZone=!1,this.emit("playerLeaveZone",i)}if(r){if(r.streak++,r.stats.totalKills++,r.streak>r.stats.bestStreak)r.stats.bestStreak=r.streak}this.emit("playerDeath",i,r,n,s)}#d(){let t=o.unPackInt8U(),e={posX:o.unPackFloat(),posY:o.unPackFloat(),posZ:o.unPackFloat(),dirX:o.unPackFloat(),dirY:o.unPackFloat(),dirZ:o.unPackFloat()},s=this.players[t];if(!s)return;let i=s.weapons[s.activeGun];if(i&&i.ammo)i.ammo.rounds--,this.emit("playerFire",s,i,e)}#l(){let t=o.unPackInt16U(),e=o.unPackInt8U(),s=o.unPackFloat(),i=o.unPackFloat(),r=o.unPackFloat();this.game.collectables[e].push({id:t,x:s,y:i,z:r}),this.emit("spawnItem",e,{x:s,y:i,z:r},t)}#g(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=o.unPackInt8U(),i=o.unPackInt16U(),r=this.players[t];if(!r)return;if(this.game.collectables[e]=this.game.collectables[e].filter((n)=>n.id!==i),e===Y.Ammo){let n=r.weapons[s];if(n&&n.ammo)n.ammo.store=Math.min(n.ammo.storeMax,n.ammo.store+n.ammo.pickup),this.emit("playerCollectAmmo",r,n,i)}if(e===Y.Grenade){if(r.grenades++,r.grenades>3)r.grenades=3;this.emit("playerCollectGrenade",r,i)}}#x(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;let i=s.hp;s.hp=e,this.emit("playerDamage",s,i,s.hp)}#w(){let t=o.unPackInt8U();o.unPackFloat(),o.unPackFloat();let e=this.me.hp;this.me.hp=t,this.emit("playerDamage",this.me,e,this.me.hp)}#k(){let t=o.unPackInt8U(),e=this.players[t];o.unPackInt8U();let s=o.unPackInt8U(),i=o.unPackFloat(),r=o.unPackFloat(),n=o.unPackFloat();if(this.me.climbing=!!o.unPackInt8U(),o.unPackInt8U(),o.unPackInt8U(),!e)return;this.state.serverStateIdx=s;let c=e.position.x,h=e.position.y,m=e.position.z;if(e.position.x=i,e.position.y=r,e.position.z=n,c!==i||h!==r||m!==n)this.emit("playerMove",e,{x:c,y:h,z:m},{x:i,y:r,z:n})}#M(){let t=new p;t.packInt8(a.eventModifier),t.send(this.game.socket)}#S(){let t=o.unPackInt8U(),e={...this.players[t]};delete this.players[t],this.emit("playerLeave",e)}#y(){if(this.game.gameModeId===M.Spatula){let t={...this.game};this.game.teamScore[1]=o.unPackInt16U(),this.game.teamScore[2]=o.unPackInt16U();let e={x:o.unPackFloat(),y:o.unPackFloat(),z:o.unPackFloat()},s=o.unPackInt8U(),i=o.unPackInt8U();this.game.spatula={coords:e,controlledBy:s,controlledByTeam:i},this.emit("gameStateChange",t,this.game)}else if(this.game.gameModeId===M.KOTC){let t={...this.game};this.game.stage=o.unPackInt8U(),this.game.zoneNumber=o.unPackInt8U(),this.game.capturing=o.unPackInt8U(),this.game.captureProgress=o.unPackInt16U(),this.game.numCapturing=o.unPackInt8U(),this.game.teamScore[1]=o.unPackInt8U(),this.game.teamScore[2]=o.unPackInt8U(),this.game.capturePercent=this.game.captureProgress/1000,this.game.activeZone=this.game.map.zones?this.game.map.zones[this.game.zoneNumber-1]:null;let e=Object.values(this.players).filter((s)=>s.inKotcZone&&s.playing);if(this.game.activeZone)Object.values(this.players).forEach((s)=>s.updateKotcZone(this.game.activeZone));if(this.game.numCapturing<=0)Object.values(this.players).forEach((s)=>{s.inKotcZone=!1,this.emit("playerLeaveZone",s)});this.emit("gameStateChange",t,this.game,e)}else if(this.game.gameModeId===M.Team)this.game.teamScore[1]=o.unPackInt16U(),this.game.teamScore[2]=o.unPackInt16U();if(this.game.gameModeId!==M.Spatula)delete this.game.spatula;if(this.game.gameModeId!==M.KOTC)delete this.game.stage,delete this.game.zoneNumber,delete this.game.capturing,delete this.game.captureProgress,delete this.game.numCapturing,delete this.game.numCapturing,delete this.game.activeZone;if(this.game.gameModeId===M.FFA)delete this.game.teamScore}#z(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;switch(e){case g.HardBoiled:if(t===this.me.id)this.me.shieldHp=100;s.streakRewards.push(g.HardBoiled);break;case g.EggBreaker:s.streakRewards.push(g.EggBreaker);break;case g.Restock:{if(s.grenades=3,s.weapons[0]&&s.weapons[0].ammo)s.weapons[0].ammo.rounds=s.weapons[0].ammo.capacity,s.weapons[0].ammo.store=s.weapons[0].ammo.storeMax;if(s.weapons[1]&&s.weapons[1].ammo)s.weapons[1].ammo.rounds=s.weapons[1].ammo.capacity,s.weapons[1].ammo.store=s.weapons[1].ammo.storeMax;break}case g.OverHeal:s.hp=Math.min(200,s.hp+100),s.streakRewards.push(g.OverHeal);break;case g.DoubleEggs:s.streakRewards.push(g.DoubleEggs);break;case g.MiniEgg:s.scale=0.5,s.streakRewards.push(g.MiniEgg);break}this.emit("playerBeginStreak",s,e)}#T(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;if([g.EggBreaker,g.OverHeal,g.DoubleEggs,g.MiniEgg].includes(e)&&s.streakRewards.includes(e))s.streakRewards=s.streakRewards.filter((r)=>r!==e);if(e===g.MiniEgg)s.scale=1;this.emit("playerEndStreak",s,e)}#E(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=o.unPackFloat(),i=o.unPackFloat();if(!this.me)return;if(this.me.shieldHp=t,this.me.hp=e,this.me.shieldHp<=0)this.me.streakRewards=this.me.streakRewards.filter((r)=>r!==g.HardBoiled),this.emit("selfShieldLost",this.me.hp,{dx:s,dz:i});else this.emit("selfShieldHit",this.me.shieldHp,this.me.hp,{dx:s,dz:i})}#P(){let t={...this.game.options},e=o.unPackInt8U(),s=o.unPackInt8U(),i=o.unPackInt8U();if(e<1||e>4)e=4;if(s<0||s>8)s=4;if(i>16)i=4;this.game.options.gravity=e/4,this.game.options.damage=s/4,this.game.options.healthRegen=i/4;let r=o.unPackInt8U();Object.keys(Kt).forEach((n)=>{let c=r&Kt[n]?1:0;this.game.options[n]=c}),this.game.options.weaponsDisabled=Array.from({length:7},()=>o.unPackInt8U()===1),this.game.options.mustUseSecondary=this.game.options.weaponsDisabled.every((n)=>n),this.emit("gameOptionsChange",t,this.game.options)}#N(){let t=o.unPackInt8U();if(t===L.Pause)this.emit("gameForcePause"),setTimeout(()=>this.me.playing=!1,3000);if(t===L.Reset){if(Object.values(this.players).forEach((e)=>e.streak=0),this.game.gameModeId!==M.FFA)this.game.teamScore=[0,0,0];if(this.game.gameModeId===M.Spatula)this.game.spatula.controlledBy=0,this.game.spatula.controlledByTeam=0,this.game.spatula.coords={x:0,y:0,z:0};if(this.game.gameModeId===M.KOTC)this.game.stage=Q.Capturing,this.game.zoneNumber=0,this.game.activeZone=null,this.game.capturing=0,this.game.captureProgress=0,this.game.numCapturing=0,this.game.capturePercent=0;this.emit("gameReset")}}#G(){if(!this.intents.includes(this.Intents.PING))return;let t=this.ping;this.ping=Date.now()-this.lastPingTime,this.emit("pingUpdate",t,this.ping),setTimeout(()=>{let e=new p;e.packInt8(a.ping),e.send(this.game.socket),this.lastPingTime=Date.now()},1000)}#O(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;let i=s.team;s.team=e,s.streak=0,this.emit("playerSwitchTeam",s,i,e)}#R(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=o.unPackInt16U(),i=o.unPackInt16U(),r=o.unPackInt8U(),n=o.unPackInt16U(),c=o.unPackInt16U(),h=o.unPackInt16U(),m=o.unPackInt16U(),f=o.unPackInt8(),u=o.unPackInt8(),d=this.intents.includes(this.Intents.COSMETIC_DATA),k=d?l(s):s,E=d?l(i):i,N=d?l(n):n,A=d?l(c):c,v=d?l(h):h,H=d?l(m):m,x=this.players[t];if(x){let z={...x.character},zt=x.selectedGun;if(x.character.eggColor=r,x.character.primaryGun=k,x.character.secondaryGun=E,x.character.stamp=A,x.character.hat=N,x.character.grenade=v,x.character.melee=H,x.character.stampPos.x=f,x.character.stampPos.y=u,x.selectedGun=e,x.weapons[0]=new _[e],zt!==x.selectedGun)this.emit("playerChangeGun",x,zt,x.selectedGun);if(z!==x.character)this.emit("playerChangeCharacter",x,z,x.character)}}#_(){let t=o.unPackInt32U(),e=this.account.eggBalance;this.account.eggBalance=t,this.emit("balanceUpdate",e,t)}#A(){this.me.playing=!1,this.emit("respawnDenied")}#v(){let t=o.unPackInt8U(),e=this.players[t];if(e)this.emit("playerMelee",e)}#C(){let t=o.unPackInt8U(),e=this.players[t];if(!e)return;let s=e.weapons[e.activeGun];if(s.ammo){let i=Math.min(Math.min(s.ammo.capacity,s.ammo.reload)-s.ammo.rounds,s.ammo.store);s.ammo.rounds+=i,s.ammo.store-=i}this.emit("playerReload",e,s)}updateGameOptions(){let t=new p;t.packInt8(a.gameOptions),t.packInt8(this.game.options.gravity*4),t.packInt8(this.game.options.damage*4),t.packInt8(this.game.options.healthRegen*4);let e=(this.game.options.locked?1:0)|(this.game.options.noTeamChange?2:0)|(this.game.options.noTeamShuffle?4:0);t.packInt8(e),this.game.options.weaponsDisabled.forEach((s)=>{t.packInt8(s?1:0)}),t.send(this.game.socket)}#L(){this.game.isPrivate=!0,this.updateGameOptions()}#F(){let t=o.unPackInt8U(),e=o.unPackInt16U(),s=o.unPackFloat(),i=o.unPackFloat(),r=o.unPackFloat(),n=o.unPackInt8U(),c=o.unPackFloat();if(this.intents.includes(this.Intents.COSMETIC_DATA))e=l(e);if(t===P.Grenade)this.emit("grenadeExplode",e,{x:s,y:i,z:r},n,c);else this.emit("rocketHit",{x:s,y:i,z:r},n,c)}#q(){let t=o.unPackInt8U(),e=o.unPackFloat(),s=o.unPackFloat(),i=o.unPackFloat(),r=o.unPackFloat(),n=o.unPackFloat(),c=o.unPackFloat(),h=this.players[t];if(h)h.grenades--,this.emit("playerThrowGrenade",h,{x:e,y:s,z:i},{x:r,y:n,z:c})}#U(){let t=o.unPackInt8U(),e=o.unPackInt8U(),s=this.players[t];if(!s)return;if(!this.intents.includes(this.Intents.CHALLENGES))return this.emit("challengeComplete",s,e);let i=this.account.challenges.find((r)=>r.id===e);if(this.emit("challengeComplete",s,i),s.id===this.me.id)this.refreshChallenges()}#W(){let t=new p;t.packInt8(this.intents.includes(this.Intents.OBSERVE_GAME)?a.observeGame:a.joinGame),t.packString(this.game.raw.uuid),t.packInt8(+this.intents.includes(this.Intents.VIP_HIDE_BADGE)),t.packInt8(this.state.weaponIdx||this.account?.loadout?.classIdx||0),t.packString(this.state.name),t.packInt32(this.account.session),t.packString(this.account.sessionId),t.packString(this.account.firebaseId),t.send(this.game.socket)}async#j(){if(this.me.id=o.unPackInt8U(),this.me.team=o.unPackInt8U(),this.game.gameModeId=o.unPackInt8U(),this.game.gameMode=Jt[this.game.gameModeId],this.game.mapIdx=o.unPackInt8U(),this.game.map=b[this.game.mapIdx],this.game.playerLimit=o.unPackInt8U(),this.game.isGameOwner=o.unPackInt8U()===1,this.game.isPrivate=o.unPackInt8U()===1||this.game.isGameOwner,o.unPackInt8U(),this.intents.includes(this.Intents.LOAD_MAP)||this.intents.includes(this.Intents.PATHFINDING)){if(this.game.map.raw=await jt(this.game.map.filename,this.game.map.hash),this.emit("mapLoad",this.game.map.raw),this.game.gameModeId===M.KOTC){let e=this.game.map.raw.data["DYNAMIC.capture-zone.none"];if(e){if(this.game.map.zones=$t(e),!this.game.activeZone)this.game.activeZone=this.game.map.zones[this.game.zoneNumber-1]}else delete this.game.map.zones}if(this.intents.includes(this.Intents.PATHFINDING))this.pathing.nodeList=new kt(this.game.map.raw)}this.state.inGame=!0,this.lastDeathTime=Date.now();let t=new p;if(t.packInt8(a.clientReady),t.send(this.game.socket),this.updateIntervalId=setInterval(()=>this.update(),33.333333333333336),this.intents.includes(this.Intents.PING)){this.lastPingTime=Date.now();let e=new p;e.packInt8(a.ping),e.send(this.game.socket)}if(this.intents.includes(this.Intents.NO_AFK_KICK))this.afkKickInterval=setInterval(()=>{if(this.state.inGame&&!this.me.playing&&Date.now()-this.lastDeathTime>=15000){let e=new p;e.packInt8(a.keepAlive),e.send(this.game.socket)}},15000);this.emit("gameReady")}#$(){let t=o.unPackInt8U(),e=o.unPackString(128),s=o.unPackString(32),i=this.players[t];if(!i)return;i.admin={ip:s,dbId:e},this.emit("playerInfo",i,s,e)}packetHandlers={[a.syncThem]:()=>this.#u(),[a.fire]:()=>this.#d(),[a.hitThem]:()=>this.#x(),[a.syncMe]:()=>this.#k(),[a.hitMe]:()=>this.#w(),[a.swapWeapon]:()=>this.#m(),[a.collectItem]:()=>this.#g(),[a.respawn]:()=>this.#a(),[a.die]:()=>this.#p(),[a.pause]:()=>this.#f(),[a.chat]:()=>this.#c(),[a.addPlayer]:()=>this.#h(),[a.removePlayer]:()=>this.#S(),[a.eventModifier]:()=>this.#M(),[a.metaGameState]:()=>this.#y(),[a.beginShellStreak]:()=>this.#z(),[a.endShellStreak]:()=>this.#T(),[a.hitMeHardBoiled]:()=>this.#E(),[a.gameOptions]:()=>this.#P(),[a.ping]:()=>this.#G(),[a.switchTeam]:()=>this.#O(),[a.changeCharacter]:()=>this.#R(),[a.reload]:()=>this.#C(),[a.explode]:()=>this.#F(),[a.throwGrenade]:()=>this.#q(),[a.spawnItem]:()=>this.#l(),[a.melee]:()=>this.#v(),[a.updateBalance]:()=>this.#_(),[a.challengeCompleted]:()=>this.#U(),[a.socketReady]:()=>this.#W(),[a.gameJoined]:()=>this.#j(),[a.gameAction]:()=>this.#N(),[a.requestGameOptions]:()=>this.#L(),[a.respawnDenied]:()=>this.#A(),[a.playerInfo]:()=>this.#$(),[a.expireUpgrade]:()=>{},[a.clientReady]:()=>{},[a.musicInfo]:()=>o.unPackLongString()};processPacket(t){if(o.init(t),this.intents.includes(this.Intents.PACKET_HOOK))this.emit("packet",t);let e=0,s=0,i=!1;while(o.isMoreDataAvailable()&&!i){let r=o.unPackInt8U(),n=this.packetHandlers[r];if(n)n();else{if(console.error(`processPacket: I got but couldn't identify a: ${Object.keys(a).find((c)=>a[c]===r)} ${r}`),e)console.error(`processPacket: It may be a result of the ${e} command (${s}).`);i=!0;break}if(e=Object.keys(a).find((c)=>a[c]===r),s=r,this.intents.includes(this.Intents.LOG_PACKETS))console.log(`[LOG_PACKETS] Packet ${e}: ${s}`)}}async checkChiknWinner(){let t=await this.api.queryServices({cmd:"chicknWinnerReady",id:this.account.id,sessionId:this.account.sessionId});if(typeof t==="string")return t;return this.account.cw.limit=t.limit,this.account.cw.atLimit=t.limit>=4,this.account.cw.secondsUntilPlay=(this.account.cw.atLimit?t.period:t.span)||0,this.account.cw.canPlayAgain=Date.now()+this.account.cw.secondsUntilPlay*1000,this.account.cw}async playChiknWinner(t=!0){if(this.account.cw.atLimit||this.account.cw.limit>ft)return"hit_daily_limit";if(this.account.cw.canPlayAgain>Date.now()&&t)return"on_cooldown";let e=await this.api.queryServices({cmd:"incentivizedVideoReward",firebaseId:this.account.firebaseId,id:this.account.id,sessionId:this.account.sessionId,token:null});if(typeof e==="string")return e;if(e.error){if(e.error==="RATELIMITED"||e.error==="RATELMITED")return await this.checkChiknWinner(),"on_cooldown";else if(e.error==="SESSION_EXPIRED")return this.emit("sessionExpired"),"session_expired";return console.error("Unknown Chikn Winner response, report this on Github:",e),"unknown_error"}if(e.reward)return this.account.eggBalance+=e.reward.eggsGiven,e.reward.itemIds.forEach((s)=>this.account.ownedItemIds.push(s)),await this.checkChiknWinner(),e.reward;return console.error("Unknown Chikn Winner response, report this on Github:",e),"unknown_error"}async resetChiknWinner(){if(this.account.eggBalance<200)return"not_enough_eggs";if(!this.account.cw.atLimit)return"not_at_limit";let t=await this.api.queryServices({cmd:"chwReset",sessionId:this.account.sessionId});if(typeof t==="string")return t;if(t.result!=="SUCCESS")return console.error("Unknown Chikn Winner reset response, report this on Github:",t),"unknown_error";return this.account.eggBalance-=200,await this.checkChiknWinner(),this.account.cw}canSee(t){if(!this.intents.includes(this.Intents.PATHFINDING))return this.processError("You must have the PATHFINDING intent to use this method.");return this.pathing.nodeList.hasLineOfSight(this.me.position,t.position)}async refreshChallenges(){let t=await this.api.queryServices({cmd:"challengeGetDaily",sessionId:this.account.sessionId,playerId:this.account.id});if(typeof t==="string")return t;return this.#i(t),this.account.challenges}async rerollChallenge(t){let e=await this.api.queryServices({cmd:"challengeRerollSlot",sessionId:this.account.sessionId,slotId:t});if(typeof e==="string")return e;return this.#i(e),this.account.challenges}async claimChallenge(t){let e=await this.api.queryServices({cmd:"challengeClaimReward",sessionId:this.account.sessionId,slotId:t});if(typeof e==="string")return e;if(this.#i(e.challenges),e.reward>0)this.account.eggBalance+=e.reward;return{eggReward:e.reward,updatedChallenges:this.account.challenges}}async refreshBalance(){let t=await this.api.queryServices({cmd:"checkBalance",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId});if(typeof t==="string")return t;return this.account.eggBalance=t.currentBalance,t.currentBalance}async redeemCode(t){let e=await this.api.queryServices({cmd:"redeem",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,id:this.account.id,code:t});if(typeof e==="string")return e;if(e.result==="SUCCESS")return this.account.eggBalance=e.eggs_given,e.item_ids.forEach((s)=>this.account.ownedItemIds.push(s)),{result:e,eggsGiven:e.eggs_given,itemIds:e.item_ids};return e}async claimURLReward(t){let e=await this.api.queryServices({cmd:"urlRewardParams",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,reward:t});if(typeof e==="string")return e;if(e.result==="SUCCESS")this.account.eggBalance+=e.eggsGiven,e.itemIds.forEach((s)=>this.account.ownedItemIds.push(s));return e}async claimSocialReward(t){let e=await this.api.queryServices({cmd:"reward",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,rewardTag:t});if(typeof e==="string")return e;if(e.result==="SUCCESS")this.account.eggBalance+=e.eggsGiven,e.itemIds.forEach((s)=>this.account.ownedItemIds.push(s));return e}async buyItem(t){let e=await this.api.queryServices({cmd:"buy",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,itemId:t,save:!0});if(typeof e==="string")return e;if(e.result==="SUCCESS")this.account.eggBalance=e.currentBalance,this.account.ownedItemIds.push(e.itemId);return e}processError(...t){let e=t.join(" ");if(this.#e.error&&this.#e.error.length)this.emit("error",e);else if(this.intents.includes(this.Intents.NO_EXIT_ON_ERROR))console.error(e);else throw Error(e)}leave(t=D.mainMenu){if(this.hasQuit)return;if(t>-1)this.game?.socket?.close(t),this.state.left=!0,this.emit("leave",t);clearInterval(this.updateIntervalId),this.#t=[],this.state.inGame=!1,this.state.chatLines=0,this.state.reloading=!1,this.state.swappingGun=!1,this.state.usingMelee=!1,this.state.stateIdx=0,this.state.serverStateIdx=0,this.state.shotsFired=0,this.state.buffer=[],this.players={},this.me=new V({}),this.game=this.#o,this.ping=0,this.lastPingTime=-1,this.lastDeathTime=-1,this.lastUpdateTick=0,this.pathing={nodeList:null,followingPath:!1,activePath:null,activeNode:null,activeNodeIdx:0}}logout(){if(this.account=this.#s,this.intents.includes(this.Intents.RENEW_SESSION))clearInterval(this.renewSessionInterval)}quit(t=!1){if(this.hasQuit)return;if(this.leave(),this.matchmaker){if(this.matchmaker.close(),!t)delete this.matchmaker}if(!t)delete this.account,delete this.api,delete this.game,delete this.me,delete this.pathing,delete this.players,delete this.state,this.#s={},this.#o={},this.#e={},this.#r=[],this.#t=[];if(this.intents.includes(this.Intents.NO_AFK_KICK))clearInterval(this.afkKickInterval);if(this.intents.includes(this.Intents.RENEW_SESSION))clearInterval(this.renewSessionInterval);this.hasQuit=!0}}class Yt{constructor(t,e,s=""){this.uniqueId=t,this.duration=e,this.reason=s}validate(t){if(typeof this.uniqueId!=="string"||typeof this.reason!=="string")return!1;if(typeof this.duration!=="number"||!Object.values(ut).some((e)=>this.duration===e))return!1;if(!(t.account.adminRoles&4))return!1;return!0}check(){return!0}execute(t){let e=new p;e.packInt8(a.banPlayer),e.packString(this.uniqueId),e.packString(this.reason),e.packInt8(this.duration),e.send(t.game.socket)}}var Qt=Yt;class Xt{constructor(t){this.uniqueId=t}validate(t){return typeof this.uniqueId==="string"&&t.game.isGameOwner&&Object.values(t.players).find((e)=>e.uniqueId===this.uniqueId)}check(){return!0}execute(t){let e=new p;e.packInt8(a.bootPlayer),e.packString(this.uniqueId),e.send(t.game.socket)}}var It=Xt;class Dt{constructor(t){this.msg=t}validate(){if(typeof this.msg!=="string")return!1;if(this.msg.length<1||this.msg.length>64)return!1;return!0}check(t){if(!t.state?.inGame)return!1;if(!t.game.isPrivate&&!t.account.adminRoles&&t.state.chatLines>=2)return!1;if(!t.game.isPrivate&&!t.account.emailVerified&&!t.account.isAged)return!1;return!0}execute(t){t.state.chatLines++;let e=new p;e.packInt8(a.chat),e.packString(this.msg),e.send(t.game.socket)}}var Vt=Dt;class bt{constructor(t){this.amount=t||1}validate(){return this.amount>=1}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee&&t.me.weapons[t.me.activeGun].ammo.rounds>=this.amount}execute(t){t.state.shotsFired+=this.amount||1}}var te=bt;var ts=Array.from({length:4},(t,e)=>(e+1)*0.25),es=Array.from({length:9},(t,e)=>e*0.25),ss=Array.from({length:17},(t,e)=>e*0.25),y=(t,e)=>typeof t>"u"?e:t;class ee{constructor(t){this.changes=t}#t(t){let e={};if(e.gravity=y(this.changes.gravity,t.game.options.gravity),e.damage=y(this.changes.damage,t.game.options.damage),e.healthRegen=y(this.changes.healthRegen,t.game.options.healthRegen),e.locked=y(this.changes.locked,t.game.options.locked),e.noTeamChange=y(this.changes.noTeamChange,t.game.options.noTeamChange),e.noTeamShuffle=y(this.changes.noTeamShuffle,t.game.options.noTeamShuffle),e.weaponsDisabled=[y(this.changes.disableEggk,t.game.options.weaponsDisabled[0]),y(this.changes.disableScrambler,t.game.options.weaponsDisabled[1]),y(this.changes.disableFreeRanger,t.game.options.weaponsDisabled[2]),y(this.changes.disableRPG,t.game.options.weaponsDisabled[3]),y(this.changes.disableWhipper,t.game.options.weaponsDisabled[4]),y(this.changes.disableCrackshot,t.game.options.weaponsDisabled[5]),y(this.changes.disableTriHard,t.game.options.weaponsDisabled[6])],this.changes.toDisable&&Array.isArray(this.changes.toDisable))this.changes.toDisable.forEach((s)=>e.weaponsDisabled[s]=!0);if(this.changes.toEnable&&Array.isArray(this.changes.toEnable))this.changes.toEnable.forEach((s)=>e.weaponsDisabled[s]=!1);if(this.changes.rawWeaponsDisabled&&Array.isArray(this.changes.rawWeaponsDisabled)&&this.changes.rawWeaponsDisabled.length===7)e.weaponsDisabled=this.changes.rawWeaponsDisabled.map((s)=>!!s);return e.mustUseSecondary=e.weaponsDisabled.every((s)=>s),e}validate(t){let e=this.#t(t);if(!ts.includes(e.gravity))return!1;if(!es.includes(e.damage))return!1;if(!ss.includes(e.healthRegen))return!1;if(typeof e.locked!=="boolean")return!1;if(typeof e.noTeamChange!=="boolean")return!1;if(typeof e.noTeamShuffle!=="boolean")return!1;if(!Array.isArray(e.weaponsDisabled))return!1;if(e.weaponsDisabled.length!==7)return!1;if(e.weaponsDisabled.some((s)=>typeof s!=="boolean"))return!1;return!0}check(t){return t.game.isGameOwner}execute(t){t.game.options=this.#t(t),t.updateGameOptions()}}var se=ee;class yt{constructor(t){this.content=[],this.scoreFunction=t}push(t){this.content.push(t),this.bubbleUp(this.content.length-1)}rescoreElement(t){this.sinkDown(this.content.indexOf(t))}pop(){let t=this.content[0],e=this.content.pop();if(this.content.length>0)this.content[0]=e,this.sinkDown(0);return t}remove(t){let e=this.content.length;for(let s=0;s<e;s++){if(this.content[s]!==t)continue;let i=this.content.pop();if(s===e-1)break;this.content[s]=i,this.bubbleUp(s),this.sinkDown(s);break}}size(){return this.content.length}bubbleUp(t){let e=this.content[t],s=this.scoreFunction(e);while(t>0){let i=Math.floor((t+1)/2)-1,r=this.content[i];if(s>=this.scoreFunction(r))break;this.content[i]=e,this.content[t]=r,t=i}}includes(t){return this.content.includes(t)}sinkDown(t){let e=this.content.length,s=this.content[t],i=this.scoreFunction(s);while(!0){let r=(t+1)*2,n=r-1,c=null,h;if(n<e){let m=this.content[n];if(h=this.scoreFunction(m),h<i)c=n}if(r<e){let m=this.content[r];if(this.scoreFunction(m)<(c===null?i:h))c=r}if(c===null)break;this.content[t]=this.content[c],this.content[c]=s,t=c}}}class T{constructor(t){this.list=t}heuristic(t,e){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)+Math.abs(t.z-e.z)}reversePath(t){let e=[];while(t.parent)e.push(t),t=t.parent;return e.reverse(),e}path(t,e){this.list.clean();let s=new yt((r)=>r.f),i=[];t.h=this.heuristic(t,e),t.g=0,t.f=t.g+t.h,s.push(t);while(s.size()!==0){let r=s.pop();if(r===e)return this.reversePath(r);i.push(r);let n=r.links;for(let c=0;c<n.length;c++){let h=n[c];if(i.includes(h))continue;let m=r.g+1,f=h.visited;if(!f||m<h.g)if(h.visited=!0,h.parent=r,h.g=m,h.h=this.heuristic(h.position,e.position),h.f=h.g+h.h,f)s.rescoreElement(h);else s.push(h)}}return null}}class ie{validate(t){return t.intents.includes(t.Intents.PATHFINDING)}check(t){return t.me.playing&&t.game.collectables[0].length}execute(t){this.pather=new T(t.pathing.nodeList);let e=200,s=null;for(let h of t.game.collectables[0]){let m=h.x-t.me.position.x,f=h.y-t.me.position.y,u=h.z-t.me.position.z,d=Math.sqrt(m*m+f*f+u*u);if(d<e)e=d,s=h}let i=Object.entries(t.me.position).map((h)=>Math.floor(h[1])),r=Object.entries(s).map((h)=>Math.floor(h[1])),n=t.pathing.nodeList.at(...i),c=t.pathing.nodeList.at(...r);if(t.pathing.activePath=this.pather.path(n,c),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var oe=ie;class re{validate(t){return t.intents.includes(t.Intents.PATHFINDING)}check(t){return t.me.playing&&t.game.zoneNumber&&t.game.activeZone}execute(t){this.pather=new T(t.pathing.nodeList);let e=200,s=null;for(let h of t.game.activeZone){let m=h.x-t.me.position.x,f=h.y-t.me.position.y,u=h.z-t.me.position.z,d=Math.sqrt(m*m+f*f+u*u);if(d<e)e=d,s=h}let i=Object.entries(t.me.position).map((h)=>Math.floor(h[1])),r=Object.entries(s).map((h)=>Math.floor(h[1])),n=t.pathing.nodeList.at(...i),c=t.pathing.nodeList.at(...r);if(t.pathing.activePath=this.pather.path(n,c),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var ne=re;class ce{validate(t){return t.intents.includes(t.Intents.PATHFINDING)}check(t){return t.me.playing&&t.game.collectables[1].length}execute(t){this.pather=new T(t.pathing.nodeList);let e=200,s=null;for(let h of t.game.collectables[1]){let m=h.x-t.me.position.x,f=h.y-t.me.position.y,u=h.z-t.me.position.z,d=Math.sqrt(m*m+f*f+u*u);if(d<e)e=d,s=h}let i=Object.entries(t.me.position).map((h)=>Math.floor(h[1])),r=Object.entries(s).map((h)=>Math.floor(h[1])),n=t.pathing.nodeList.at(...i),c=t.pathing.nodeList.at(...r);if(t.pathing.activePath=this.pather.path(n,c),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var he=ce;class ae{idOrName;constructor(t){this.idOrName=t}validate(t){if(!t.intents.includes(t.Intents.PATHFINDING))return!1;if(!this.idOrName)return!1;return!!(t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName))}check(t){if(!t.me.playing)return!1;let e=t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName);return e&&e.playing&&e.position&&e.position.x}execute(t){this.pather=new T(t.pathing.nodeList);let e=t.players[this.idOrName.toString()]||t.players.find((c)=>c.name===this.idOrName),s=Object.entries(t.me.position).map((c)=>Math.floor(c[1])),i=Object.entries(e.position).map((c)=>Math.floor(c[1])),r=t.pathing.nodeList.at(...s),n=t.pathing.nodeList.at(...i);if(t.pathing.activePath=this.pather.path(r,n),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var ue=ae;class fe{validate(t){return t.intents.includes(t.Intents.PATHFINDING)}check(t){return t.me.playing&&t.game.spatula&&t.game.spatula.coords&&t.game.spatula.coords.x}execute(t){this.pather=new T(t.pathing.nodeList);let e=Object.entries(t.me.position).map((n)=>Math.floor(n[1])),s=Object.entries(t.game.spatula.coords).map((n)=>Math.floor(n[1])),i=t.pathing.nodeList.at(...e),r=t.pathing.nodeList.at(...s);if(t.pathing.activePath=this.pather.path(i,r),!t.pathing.activePath)return t.processError("no path found");if(t.pathing.activePath.length<2)return t.processError("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var me=fe;var is=(t,e)=>(t%e+e)%e,os=Math.PI*2,pe=(t)=>Math.round(t*8192)/8192,rs=(t)=>pe(is(Math.atan2(-t.x,-t.z),os)),ns=(t)=>pe(Math.atan2(t.y,Math.hypot(t.x,t.z)));class de{idOrName;constructor(t){this.idOrName=t}validate(t){return!!(t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName))}check(t){if(!t.me.playing)return!1;let e=t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName);return e&&e.playing&&e.position&&e.position.x}execute(t){let e=t.players[this.idOrName.toString()]||t.players.find((n)=>n.name===this.idOrName),s={x:e.position.x-t.me.position.x,y:e.position.y-t.me.position.y-0.05,z:e.position.z-t.me.position.z},i=rs(s),r=ns(s);t.state.yaw=i,t.state.pitch=r}}var le=de;class ge{validate(){return!0}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee}execute(t){let e=new p;e.packInt8(a.melee),e.send(t.game.socket),t.usingMelee=!0,setTimeout(()=>{t.usingMelee=!1,t.swappingGun=!0,setTimeout(()=>{t.swappingGun=!1},0.5*pt)},566.6666666666667)}}var xe=ge;class we{validate(){return!0}check(t){return t.me.playing}execute(t){let e=new p;e.packInt8(a.pause),e.send(t.game.socket),setTimeout(()=>t.me.playing=!1,3000)}}var ke=we;class Me{validate(){return!0}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee}execute(t){let e=new p;e.packInt8(a.reload),e.send(t.game.socket);let s=t.me.weapons[t.me.activeGun];if(s.ammo){let n=Math.min(Math.min(s.ammo.capacity,s.ammo.reload)-s.ammo.rounds,s.ammo.store);s.ammo.rounds+=n,s.ammo.store-=n}t.emit("playerReload",t.me,s);let i=t.me.weapons[t.me.activeGun],r=i.ammo.rounds<1;t.state.reloading=!0,setTimeout(()=>t.state.reloading=!1,r?i.longReloadTime:i.shortReloadTime)}}var Se=Me;class ye{constructor(t,e={}){if(this.idOrName=t,this.reasons=[!!e.cheating,!!e.harassment,!!e.offensive,!!e.other],!this.reasons.includes(!0))this.reasons[3]=!0;for(let s=0;s<this.reasons.length;s++)if(this.reasons[s]===!0)this.reasonInt|=1<<s}validate(t){if(this.reasons.every((s)=>s===!1))return!1;if(!(t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName)))return!1;return!0}check(t){if(!t.state.inGame)return!1;return!!(t.players[this.idOrName.toString()]||t.players.find((s)=>s.name===this.idOrName))}execute(t){let e=t.players[this.idOrName.toString()]||t.players.find((i)=>i.name===this.idOrName),s=new p;s.packInt8(a.reportPlayer),s.packString(e.uniqueId),s.packInt8(this.reasonInt),s.send(t.game.socket)}}var ze=ye;class Te{validate(){return!0}check(t){return t.game.isGameOwner}execute(t){let e=new p;e.packInt8(a.gameAction),e.packInt8(L.Reset),e.send(t.game.socket)}}var Ee=Te;var q=(t)=>l(t)&&l(t).unlock==="default",U=(t,e)=>l(t)&&l(t).item_type_id===e;class Pe{constructor(t){this.changes={classIdx:t.gunId,hatId:t.hatId,stampId:t.stampId,grenadeId:t.grenadeId,meleeId:t.meleeId,colorIdx:t.eggColor,primaryId:t.primaryIds,secondaryId:t.secondaryIds},this.changes=Object.fromEntries(Object.entries(this.changes).filter(([,e])=>!!e))}validate(t){let e=this.changes;if(e.colorIdx&&e.colorIdx>=7&&!t.account.vip)return!1;if(e.colorIdx&&e.colorIdx>=14)return!1;if(U(e.hatId,P.Hat)&&!q(e.hatId)&&!t.account.ownedItemIds.includes(e.hatId))return!1;if(U(e.stampId,P.Stamp)&&!q(e.stampId)&&!t.account.ownedItemIds.includes(e.stampId))return!1;if(U(e.grenadeId,P.Grenade)&&!q(e.grenadeId)&&!t.account.ownedItemIds.includes(e.grenadeId))return!1;if(U(e.meleeId,P.Melee)&&!q(e.meleeId)&&!t.account.ownedItemIds.includes(e.meleeId))return!1;if(typeof e.classIdx==="number"&&e.classIdx>6||e.classIdx<0)return!1;if(this.changes.primaryId)for(let s=0;s<7;s++){let i=this.changes.primaryId[s];if(!U(i,P.Primary)||!q(i)&&!t.account.ownedItemIds.includes(i))return!1}if(this.changes.secondaryId)for(let s=0;s<7;s++){let i=this.changes.secondaryId[s];if(!U(i,P.Secondary)||!q(i)&&!t.account.ownedItemIds.includes(i))return!1}return!0}check(t){return!t.me.playing}execute(t){if(t.me&&this.changes.classIdx&&this.changes.classIdx!==t.me.selectedGun)t.me.weapons[0]=new _[this.changes.classIdx];t.state.weaponIdx=this.changes.classIdx||t.state.weaponIdx;let e={...t.account.loadout,...this.changes},s=t.api.queryServices({cmd:"saveLoadout",save:!0,firebaseId:t.account.firebaseId,sessionId:t.account.sessionId,loadout:e});if(t.account.loadout=e,t.me)s.then(()=>{if(t.state.inGame){let r=new p;r.packInt8(a.changeCharacter),r.packInt8(this.changes?.classIdx||t.me.selectedGun),r.send(t.game.socket)}let i=t.intents.includes(t.Intents.COSMETIC_DATA);Object.entries(this.changes).forEach(([r,n])=>{if(r==="classIdx")t.me.selectedGun=n;else if(r==="hatId")t.me.character.hat=i?l(n):n;else if(r==="stampId")t.me.character.stamp=i?l(n):n;else if(r==="grenadeId")t.me.character.grenade=i?l(n):n;else if(r==="meleeId")t.me.character.melee=i?l(n):n;else if(r==="colorIdx")t.me.character.eggColor=n;else if(r==="primaryId")t.me.character.primaryGun=i?l(n[t.me.selectedGun]):n;else if(r==="secondaryId")t.me.character.secondaryGun=i?l(n[t.me.selectedGun]):n})})}}var Ne=Pe;class Ge{validate(){return!0}check(t){if(t.me.playing)return!1;if(t.lastDeathTime+6000<Date.now())return!1;if(t.intents.includes(t.Intents.OBSERVE_GAME))return!1;return!0}execute(t){let e=new p;e.packInt8(a.requestRespawn),e.send(t.game.socket),t.state.buffer=[]}}var Oe=Ge;class Re{constructor(t){this.manualWeapon=t}validate(){return typeof this.manualWeapon==="number"||typeof this.manualWeapon>"u"}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee}execute(t){let e=+!t.me.activeGun;if(typeof this.manualWeapon==="number")e=this.manualWeapon;t.me.activeGun=e;let s=new p;s.packInt8(a.swapWeapon),s.packInt8(t.me.activeGun),s.send(t.game.socket)}}var _e=Re;class Ae{validate(){return!0}check(t){if(!t.state.inGame||t.me.playing)return!1;if(t.game.gameModeId===0)return!1;if(t.intents.includes(t.Intents.OBSERVE_GAME))return!1;if(t.game.isPrivate)return!t.game.options.noTeamChange;let e=t.players,s=t.me.team,i=e.filter((n)=>n.team===s).length,r=e.filter((n)=>n.team!==s).length;if(r>i)return!1;if(i===r)return!1;return!0}execute(t){let e=new p;e.packInt8(a.switchTeam),e.send(t.game.socket)}}var ve=Ae;class Ce{constructor(t=1){this.power=t}validate(){return typeof this.power==="number"&&this.power>=0&&this.power<=1}check(t){return t.me.playing&&!t.state.reloading&&!t.state.swappingGun&&!t.state.usingMelee}execute(t){let e=new p;e.packInt8(a.throwGrenade),e.packFloat(this.power),e.send(t.game.socket)}}var Le=Ce;var cs={BanPlayerDispatch:Qt,BootPlayerDispatch:It,ChatDispatch:Vt,FireDispatch:te,GameOptionsDispatch:se,GoToAmmoDispatch:oe,GoToCoopDispatch:ne,GoToGrenadeDispatch:he,GoToPlayerDispatch:ue,GoToSpatulaDispatch:me,LookAtDispatch:le,LookAtPosDispatch:J,MeleeDispatch:xe,MovementDispatch:K,PauseDispatch:ke,ReloadDispatch:Se,ReportPlayerDispatch:ze,ResetGameDispatch:Ee,SaveLoadoutDispatch:Ne,SpawnDispatch:Oe,SwapWeaponDispatch:_e,SwitchTeamDispatch:ve,ThrowGrenadeDispatch:Le};var Fe={};tt(Fe,{CommOut:()=>p,CommIn:()=>o,CommCode:()=>a,CloseCode:()=>D});export{xt as Matchmaker,b as Maps,Ot as Guns,gt as GamePlayer,cs as Dispatches,Rt as Constants,Fe as Comm,Zt as Bot,lt as API};
|
package/dist/bot.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import y from"./api.js";import J from"./comm/CommIn.js";import R from"./comm/CommOut.js";import d from"./constants/CloseCode.js";import $ from"./constants/CommCode.js";import T from"./bot/GamePlayer.js";import s from"./matchmaker.js";import n from"./socket.js";import{ChiknWinnerDailyLimit as t,CollectType as C,CoopState as k,findItemById as V,FramesBetweenSyncs as z,GameAction as x,GameMode as O,GameOptionFlag as o,GunList as p,ItemType as r,Movement as B,PlayType as v,ShellStreak as K,StateBufferSize as b}from"./constants/index.js";import h from"./dispatches/LookAtPosDispatch.js";import D from"./dispatches/MovementDispatch.js";import l from"./env/globals.js";import{NodeList as a}from"./pathing/mapnode.js";import{coords as e}from"./wasm/direct.js";import{fetchMap as jj,initKotcZones as Ej}from"./util.js";import{Challenges as Jj}from"./constants/challenges.js";import{Maps as I}from"./constants/maps.js";import{Regions as u}from"./constants/regions.js";const c=Object.fromEntries(Object.entries(O).map(([E,j])=>[j,E])),m=Object.fromEntries(Object.entries(o).map(([E,j])=>[E[0].toLowerCase()+E.slice(1),j])),g={CHALLENGES:1,BOT_STATS:2,PATHFINDING:3,PING:5,COSMETIC_DATA:6,PLAYER_HEALTH:7,PACKET_HOOK:8,LOG_PACKETS:10,NO_LOGIN:11,DEBUG_BUFFER:12,NO_AFK_KICK:16,LOAD_MAP:17,OBSERVE_GAME:18,NO_REGION_CHECK:19,NO_EXIT_ON_ERROR:20,RENEW_SESSION:21,VIP_HIDE_BADGE:22},f=(E,j)=>(E%j+j)%j;export class Bot{static Intents=g;Intents=g;#J=[];#j={};#Q=[];#E;#U;constructor(E={}){if(E.proxy&&l.isBrowser)this.processError("proxies do not work and hence are not supported in the browser");this.intents=E.intents||[];if(this.intents.includes(this.Intents.COSMETIC_DATA)){if(!V(1001))this.processError("you cannot use the COSMETIC_DATA intent inside of the singlefile browser bundles")}this.instance=E.instance||"shellshock.io";this.protocol=E.protocol||"wss";this.proxy=E.proxy||"";this.connectionTimeout=E.connectionTimeout||5000;this.state={name:"yolkbot",weaponIdx:0,inGame:!1,chatLines:0,yaw:0,pitch:0,controlKeys:0,reloading:!1,swappingGun:!1,usingMelee:!1,stateIdx:0,serverStateIdx:0,shotsFired:0,buffer:[],left:!1};this.players={};this.me=new T({});this.game={raw:{},code:"",socket:null,gameModeId:0,gameMode:c[0],mapIdx:0,map:{filename:"",hash:"",name:"",modes:{FFA:!1,Teams:!1,Spatula:!1,King:!1},availability:"both",numPlayers:"18",raw:{},nodes:{},zones:[]},playerLimit:0,isGameOwner:!1,isPrivate:!0,options:{gravity:1,damage:1,healthRegen:1,locked:!1,noTeamChange:!1,noTeamShuffle:!1,weaponsDisabled:Array(7).fill(!1),mustUseSecondary:!1},collectables:[[],[]],teamScore:[0,0,0],spatula:{coords:{x:0,y:0,z:0},controlledBy:0,controlledByTeam:0},stage:k.Capturing,zoneNumber:0,activeZone:[],capturing:0,captureProgress:0,numCapturing:0,capturePercent:0};this.#U=this.game;this.account={id:0,firebase:{idToken:"",refreshToken:"",expiresIn:"3600",localId:""},firebaseId:"",sessionId:"",session:0,email:"",password:"",cw:{atLimit:!1,limit:0,secondsUntilPlay:0,canPlayAgain:Date.now()},loadout:{hatId:null,meleeId:0,stampId:null,classIdx:0,colorIdx:0,grenadeId:0,primaryId:[3100,3600,3400,3800,4000,4200,4500],secondaryId:Array(7).fill(3000),stampPositionX:0,stampPositionY:0},ownedItemIds:[],vip:!1,emailVerified:!1,isAged:!1,eggBalance:0,adminRoles:0,rawLoginData:{},isDoubleEggWeeknd:()=>{const j=new Date().getUTCDay(),M=new Date().getUTCHours();return j>=5&&M>=20||j===6||j===0}};this.#E=this.account;this.matchmaker=null;this.api=new y({proxy:this.proxy,protocol:this.protocol,instance:this.instance,maxRetries:E?.apiMaxRetries,connectionTimeout:this.connectionTimeout});this.ping=0;this.lastPingTime=-1;this.lastDeathTime=-1;this.lastUpdateTick=0;this.pathing={nodeList:null,followingPath:!1,activePath:null,activeNode:null,activeNodeIdx:0};this.hasQuit=!1;if(this.intents.includes(this.Intents.NO_AFK_KICK))this.afkKickInterval=0;if(this.intents.includes(this.Intents.RENEW_SESSION))this.renewSessionInterval=0}dispatch(E){if(E.validate(this)){if(E.check(this))E.execute(this);else this.#J.push(E);return!0}return!1}async createAccount(E,j){this.account=this.#E;this.account.email=E;this.account.password=j;const M=await this.api.createAccount(E,j);return this.processLoginData(M)}async login(E,j){this.account=this.#E;this.account.email=E;this.account.password=j;const M=await this.api.loginWithCredentials(E,j);return this.processLoginData(M)}async loginWithRefreshToken(E){this.account=this.#E;const j=await this.api.loginWithRefreshToken(E);return this.processLoginData(j)}async loginAnonymously(){this.account=this.#E;const E=await this.api.loginAnonymously();return this.processLoginData(E)}processLoginData(E){if(typeof E!=="object"){this.emit("authFail",E);return E}if(E.banRemaining){this.emit("banned",E.banRemaining);return"account_banned"}if(!E.playerOutput){this.emit("authFail",E);return E}this.account.firebase=E.firebase||{};E=E.playerOutput;this.account.rawLoginData=E;this.account.adminRoles=E.adminRoles||0;this.account.eggBalance=E.currentBalance;this.account.emailVerified=E.emailVerified;this.account.firebaseId=E.firebaseId;this.account.id=E.id;this.account.isAged=new Date(E.dateCreated).getTime()<1714546800000;this.account.loadout=E.loadout;this.account.ownedItemIds=E.ownedItemIds;this.account.session=E.session;this.account.sessionId=E.sessionId;this.account.vip=E.active_sub==="IsVIP";if(this.intents.includes(this.Intents.BOT_STATS))this.account.stats={lifetime:E.statsLifetime,monthly:E.statsCurrent};if(this.intents.includes(this.Intents.CHALLENGES))this.#M(E.challenges);this.emit("authSuccess",this.account);if(this.intents.includes(this.Intents.RENEW_SESSION))this.renewSessionInterval=setInterval(async()=>{if(!this.account?.sessionId)return clearInterval(this.renewSessionInterval);if((await this.api.queryServices({cmd:"renewSession",sessionId:this.account.sessionId})).data!=="renewed")this.emit("sessionExpired")},600000);return this.account}#M(E){this.account.challenges=[];for(const j of E){const M=Jj.find((Q)=>Q.id===j.challengeId);if(!M)continue;delete j.playerId;this.account.challenges.push({raw:{challengeInfo:M,challengeData:j},id:j.challengeId,name:M.loc.title,desc:M.loc.desc,rewardEggs:M.reward,isRerolled:!!j.reset,isClaimed:!!j.claimed,isCompleted:!!j.completed,progressNum:j.progress,goalNum:M.goal})}}async initMatchmaker(){if(!this.account.sessionId&&!this.intents.includes(this.Intents.NO_LOGIN)){const E=await this.loginAnonymously();if(typeof E!=="object")return E}if(!this.matchmaker){this.matchmaker=new s({api:this.api,proxy:this.proxy,protocol:this.protocol,instance:this.instance,sessionId:this.account.sessionId,connectionTimeout:this.connectionTimeout,noLogin:this.intents.includes(this.Intents.NO_LOGIN)});if(!await this.matchmaker.ws.tryConnect())return"matchmaker_tryconnect_failed";this.matchmaker.on("authFail",(j)=>this.emit("authFail",j));this.matchmaker.on("error",(j)=>this.processError(j))}return!0}async findPublicGame(E,j){if(typeof E!=="string")return"no_region_passed";if(!u.find((Q)=>Q.id===E)&&!this.intents.includes(this.Intents.NO_REGION_CHECK))return"invalid_region_passed";if(typeof j!=="number")return"no_mode_passed";if(Object.values(O).indexOf(j)===-1)return"invalid_mode_passed";if(!await this.initMatchmaker())return"matchmaker_init_fail";return await new Promise((Q)=>{const _=(U)=>{if(U.command==="notice")return;this.matchmaker.off("msg",_);if(U.command==="gameFound")return Q(U);if(U.error==="sessionNotFound")return Q("internal_session_error");this.processError("unknown matchmaker response",JSON.stringify(U))};this.matchmaker.on("msg",_);this.matchmaker.send({command:"findGame",region:E,playType:v.JoinPublic,gameType:j,sessionId:this.account.sessionId})})}async createPrivateGame(E,j,M){if(typeof E!=="string")return"no_region_passed";if(!u.find((U)=>U.id===E)&&!this.intents.includes(this.Intents.NO_REGION_CHECK))return"invalid_region_passed";if(typeof j!=="number")return"no_mode_passed";if(Object.values(O).indexOf(j)===-1)return"invalid_mode_passed";if(typeof M!=="string")return"no_map_passed";const Q=I.findIndex((U)=>U.name.toLowerCase()===M.toLowerCase());if(Q===-1)return"invalid_map_passed";if(!await this.initMatchmaker())return"matchmaker_init_fail";return await new Promise((U)=>{const q=(L)=>{if(L.command==="notice")return;this.matchmaker.off("msg",q);if(L.command==="gameFound")return U(L);if(L.error==="sessionNotFound")return U("internal_session_error");this.processError("unknown matchmaker response",JSON.stringify(L))};this.matchmaker.on("msg",q);this.matchmaker.send({command:"findGame",region:E,playType:v.CreatePrivate,gameType:j,sessionId:this.account.sessionId,noobLobby:!1,map:Q})})}async join(E,j){this.state.name=E||"yolkbot";if(typeof j==="string"){if(j.includes("#"))j=j.split("#")[1];if(!await this.initMatchmaker())return"matchmaker_init_fail";if(await new Promise((U)=>{const q=(L)=>{if(L.command==="gameFound"){this.matchmaker.off("msg",q);this.game.raw=L;this.game.code=L.id;U(L.id)}if(L.error&&L.error==="gameNotFound"){this.processError(`game "${j}" not found, it may have expired.`);this.leave();return"gameNotFound"}};this.matchmaker.on("msg",q);this.matchmaker.send({command:"joinGame",id:j,observe:!1,sessionId:this.account.sessionId})})==="gameNotFound")return"game_not_found";if(!this.game.raw.id)return this.processError("an internal error occured while joining the game, please report this to developers")}if(typeof j==="object"){if(this.account.id===0)await this.loginAnonymously();this.game.raw=j;this.game.code=this.game.raw.id;if(!this.game.raw.id)return"invalid_game_object";if(!this.game.raw.subdomain)return"invalid_game_object";if(!this.game.raw.uuid)return"invalid_game_object"}const M=this.game.raw.host||(this.instance.startsWith("localhost:")?this.instance:`${this.game.raw.subdomain}.${this.instance}`);this.game.socket=new n(`${this.protocol}://${M}/game/${this.game.raw.id}`,this.proxy);this.game.socket.binaryType="arraybuffer";this.game.socket.connectionTimeout=this.connectionTimeout;this.game.socket.onBeforeConnect=()=>{this.game.socket.onmessage=(_)=>this.processPacket(_.data);this.game.socket.onclose=(_)=>{if(this.state.left)this.state.left=!1;else{this.emit("close",_.code);this.leave(-1)}}};if(!await this.game.socket.tryConnect())return"websocket_tryconnect_fail";return!0}#_(){if(Object.entries(this.me.position).map((j)=>Math.floor(j[1])).join(",")===this.pathing.activePath[this.pathing.activePath.length-1].positionStr){this.pathing.followingPath=!1;this.pathing.activePath=null;this.pathing.activeNode=null;this.pathing.activeNodeIdx=0;this.dispatch(new D(0))}else{let j;if(this.pathing.activeNodeIdx<this.pathing.activePath.length-1){j=this.pathing.activePath[this.pathing.activeNodeIdx+1].flatCenter();this.dispatch(new h(j))}else{j=this.pathing.activePath[this.pathing.activeNodeIdx].flatCenter();this.dispatch(new h(j))}for(const M of this.pathing.activePath)if(M.flatRadialDistance(this.me.position)<0.1&&M.position.y===Math.floor(this.me.position.y)){if(this.pathing.activePath.indexOf(M)>=this.pathing.activeNodeIdx){this.pathing.activeNodeIdx=this.pathing.activePath.indexOf(M)+1;this.pathing.activeNode=this.pathing.activePath[this.pathing.activeNodeIdx];break}}if(!(this.state.controlKeys&B.Forward))this.dispatch(new D(B.Forward))}}update(){if(this.hasQuit)return;if(this.pathing.followingPath&&this.intents.includes(this.Intents.PATHFINDING))this.#_();for(let j=0;j<this.#J.length;j++){const M=this.#J[j];if(M.check(this)){M.execute(this);this.#J.splice(j,1)}}this.state.chatLines=Math.max(0,this.state.chatLines-0.008333333333333333);if(this.me.playing){const j=this.state.stateIdx;if(this.intents.includes(this.Intents.DEBUG_BUFFER)){console.log("setting buffer for idx",j);console.log("checking...shotsFired",this.state.shotsFired)}this.me.jumping=!!(this.state.controlKeys&B.Jump);this.state.buffer[j]={controlKeys:this.state.controlKeys,yaw:this.state.yaw,pitch:this.state.pitch,shotsFired:this.state.shotsFired};this.state.shotsFired=0;if(this.lastUpdateTick>=2){this.emit("tick");const M=new R;M.packInt8($.syncMe);M.packInt8(this.state.stateIdx);M.packInt8(this.state.serverStateIdx);const Q=f(this.state.stateIdx-z+1,b);for(let _=0;_<z;_++){const U=f(Q+_,b),q=this.state.buffer[U]||{},L=q.controlKeys||0,N=q.shotsFired||0,H=q.yaw??this.state.yaw,S=q.pitch??this.state.pitch;if(this.intents.includes(this.Intents.DEBUG_BUFFER))console.log("going with",this.state.stateIdx,Q,U,q);M.packInt8(L);M.packInt8(N);M.packString(e(H,S));M.packInt8(100)}M.send(this.game.socket);this.state.buffer=[];this.lastUpdateTick=0}else this.lastUpdateTick++;this.state.stateIdx=f(this.state.stateIdx+1,b)}if(!this.intents.includes(this.Intents.PLAYER_HEALTH))return;const E=0.1*(this.game.isPrivate?this.game.options.healthRegen:1);for(const j of Object.values(this.players)){if(j.playing&&j.hp>0){const M=j.streakRewards.includes(K.OverHeal);j.hp+=M?-E:E;j.hp=M?Math.max(100,j.hp):Math.min(100,j.hp)}if(j.spawnShield>0)j.spawnShield-=6}}on(E,j){if(Object.keys(this.#j).includes(E))this.#j[E].push(j);else this.#j[E]=[j]}once(E,j){const M=(...Q)=>{j(...Q);this.off(E,M)};this.on(E,M)}onAny(E){this.#Q.push(E)}off(E,j){if(j)this.#j[E]=this.#j[E].filter((M)=>M!==j);else this.#j[E]=[]}emit(E,...j){if(this.hasQuit)return;if(this.#j[E])for(const M of this.#j[E])M(...j);for(const M of this.#Q)M(E,...j)}#$(){const E=J.unPackInt8U(),j=J.unPackInt8U(),M=J.unPackString().valueOf(),Q=this.players[E];this.emit("chat",Q,M,j)}#q(){const E=J.unPackInt8U(),j=this.intents.includes(this.Intents.COSMETIC_DATA),M={id:E,uniqueId:J.unPackString(),name:J.unPackString(),safeName:J.unPackString(),charClass:J.unPackInt8U(),team:J.unPackInt8U(),primaryWeaponItem:j?V(J.unPackInt16U()):J.unPackInt16U(),secondaryWeaponItem:j?V(J.unPackInt16U()):J.unPackInt16U(),shellColor:J.unPackInt8U(),hatItem:j?V(J.unPackInt16U()):J.unPackInt16U(),stampItem:j?V(J.unPackInt16U()):J.unPackInt16U(),stampPosX:J.unPackInt8(),stampPosY:J.unPackInt8(),grenadeItem:j?V(J.unPackInt16U()):J.unPackInt16U(),meleeItem:j?V(J.unPackInt16U()):J.unPackInt16U(),x:J.unPackFloat(),y:J.unPackFloat(),z:J.unPackFloat(),$dx:J.unPackFloat(),$dy:J.unPackFloat(),$dz:J.unPackFloat(),yaw:J.unPackRadU(),pitch:J.unPackRad(),score:J.unPackInt32U(),$kills:J.unPackInt16U(),$deaths:J.unPackInt16U(),$streak:J.unPackInt16U(),totalKills:J.unPackInt32U(),totalDeaths:J.unPackInt32U(),bestStreak:J.unPackInt16U(),$bestOverallStreak:J.unPackInt16U(),shield:J.unPackInt8U(),hp:J.unPackInt8U(),playing:J.unPackInt8U(),weaponIdx:J.unPackInt8U(),$controlKeys:J.unPackInt8U(),upgradeProductId:J.unPackInt8U(),activeShellStreaks:J.unPackInt8U(),social:J.unPackLongString(),hideBadge:J.unPackInt8U()};this.game.mapIdx=J.unPackInt8U();this.game.isPrivate=J.unPackInt8U()===1;this.game.gameModeId=J.unPackInt8U();const Q=new T(M,this.game.gameMode===O.KOTC?this.game.activeZone:null);if(!this.players[M.id])this.players[M.id]=Q;this.emit("playerJoin",Q);if(this.me.id===M.id){this.me=Q;this.emit("botJoin",this.me)}}#L(){const E=J.unPackInt8U(),j=J.unPackInt16U(),M=J.unPackFloat(),Q=J.unPackFloat(),_=J.unPackFloat(),U=J.unPackInt8U(),q=J.unPackInt8U(),L=J.unPackInt8U(),N=J.unPackInt8U(),H=J.unPackInt8U(),S=this.players[E];if(S){S.playing=!0;S.randomSeed=j;if(S.weapons[0]&&S.weapons[0].ammo)S.weapons[0].ammo.rounds=U;if(S.weapons[0]&&S.weapons[0].ammo)S.weapons[0].ammo.store=q;if(S.weapons[1]&&S.weapons[1].ammo)S.weapons[1].ammo.rounds=L;if(S.weapons[1]&&S.weapons[1].ammo)S.weapons[1].ammo.store=N;S.grenades=H;S.position={x:M,y:Q,z:_};S.spawnShield=120;this.emit("playerRespawn",S)}}#S(){const E=J.unPackInt8U(),j=J.unPackFloat(),M=J.unPackFloat(),Q=J.unPackFloat(),_=J.unPackInt8U(),U=this.players[E];if(!U||U.id===this.me.id){for(let X=0;X<z;X++){J.unPackInt8U();J.unPackRadU();J.unPackRad();J.unPackInt8U()}return}for(let X=0;X<z;X++){const P=J.unPackInt8U();if(P&B.Jump)U.jumping=!0;else U.jumping=!1;if(P&B.Scope)U.scoping=!0;else U.scoping=!1;const Z={...U.view};U.view.yaw=J.unPackRadU();U.view.pitch=J.unPackRad();if(U.view.yaw!==Z.yaw||U.view.pitch!==Z.pitch)this.emit("playerRotate",U,Z,U.view);U.scale=J.unPackInt8U()}const q=U.position,L=q.x!==j||q.y!==M||q.z!==Q,N=U.climbing!==_,H=L||N,S=H?{...q}:null;if(q.x!==j)q.x=j;if(q.z!==Q)q.z=Q;if(!U.jumping||Math.abs(q.y-M)>0.5)q.y=M;if(N)U.climbing=_;if(!H)return;this.emit("playerMove",U,S,q);if(this.game.gameModeId!==O.KOTC)return;const F=this.game.activeZone,A=!!U.inKotcZone;if(!F&&A){U.inKotcZone=!1;this.emit("playerLeaveZone",U);return}U.updateKotcZone(F);const Y=!!U.inKotcZone;if(A!==Y){U.inKotcZone=Y;this.emit(Y?"playerEnterZone":"playerLeaveZone",U)}}#G(){const E=J.unPackInt8U(),j=this.players[E];if(j){j.playing=!1;if(j.streakRewards)j.streakRewards=[];this.emit("playerPause",j);if(j.inKotcZone){j.inKotcZone=!1;this.emit("playerLeaveZone",j)}}}#K(){const E=J.unPackInt8U(),j=J.unPackInt8U(),M=this.players[E];if(M){M.activeGun=j;this.emit("playerSwapWeapon",M,j)}}#O(){const E=J.unPackInt8U(),j=J.unPackInt8U();J.unPackInt8U();J.unPackInt8U();const M=J.unPackInt8U(),Q=this.players[E],_=this.players[j],U=Q?{...Q}:null;if(Q){if(Q.id===this.me.id)this.lastDeathTime=Date.now();Q.playing=!1;Q.streak=0;Q.hp=100;Q.spawnShield=0;Q.stats.totalDeaths++;Q.inKotcZone=!1;this.emit("playerLeaveZone",Q)}if(_){_.streak++;_.stats.totalKills++;if(_.streak>_.stats.bestStreak)_.stats.bestStreak=_.streak}this.emit("playerDeath",Q,_,U,M)}#V(){const E=J.unPackInt8U(),j={posX:J.unPackFloat(),posY:J.unPackFloat(),posZ:J.unPackFloat(),dirX:J.unPackFloat(),dirY:J.unPackFloat(),dirZ:J.unPackFloat()},M=this.players[E];if(!M)return;const Q=M.weapons[M.activeGun];if(Q&&Q.ammo){Q.ammo.rounds--;this.emit("playerFire",M,Q,j)}}#N(){const E=J.unPackInt16U(),j=J.unPackInt8U(),M=J.unPackFloat(),Q=J.unPackFloat(),_=J.unPackFloat();this.game.collectables[j].push({id:E,x:M,y:Q,z:_});this.emit("spawnItem",j,{x:M,y:Q,z:_},E)}#F(){const E=J.unPackInt8U(),j=J.unPackInt8U(),M=J.unPackInt8U(),Q=J.unPackInt16U(),_=this.players[E];if(!_)return;this.game.collectables[j]=this.game.collectables[j].filter((U)=>U.id!==Q);if(j===C.Ammo){const U=_.weapons[M];if(U&&U.ammo){U.ammo.store=Math.min(U.ammo.storeMax,U.ammo.store+U.ammo.pickup);this.emit("playerCollectAmmo",_,U,Q)}}if(j===C.Grenade){_.grenades++;if(_.grenades>3)_.grenades=3;this.emit("playerCollectGrenade",_,Q)}}#H(){const E=J.unPackInt8U(),j=J.unPackInt8U(),M=this.players[E];if(!M)return;const Q=M.hp;M.hp=j;this.emit("playerDamage",M,Q,M.hp)}#R(){const E=J.unPackInt8U();J.unPackFloat();J.unPackFloat();const j=this.me.hp;this.me.hp=E;this.emit("playerDamage",this.me,j,this.me.hp)}#X(){const E=J.unPackInt8U(),j=this.players[E];J.unPackInt8U();const M=J.unPackInt8U(),Q=J.unPackFloat(),_=J.unPackFloat(),U=J.unPackFloat();this.me.climbing=!!J.unPackInt8U();J.unPackInt8U();J.unPackInt8U();if(!j)return;this.state.serverStateIdx=M;const q=j.position.x,L=j.position.y,N=j.position.z;j.position.x=Q;j.position.y=_;j.position.z=U;if(q!==Q||L!==_||N!==U)this.emit("playerMove",j,{x:q,y:L,z:N},{x:Q,y:_,z:U})}#Y(){const E=new R;E.packInt8($.eventModifier);E.send(this.game.socket)}#Z(){const E=J.unPackInt8U(),j={...this.players[E]};delete this.players[E];this.emit("playerLeave",j)}#B(){if(this.game.gameModeId===O.Spatula){const E={...this.game};this.game.teamScore[1]=J.unPackInt16U();this.game.teamScore[2]=J.unPackInt16U();const j={x:J.unPackFloat(),y:J.unPackFloat(),z:J.unPackFloat()},M=J.unPackInt8U(),Q=J.unPackInt8U();this.game.spatula={coords:j,controlledBy:M,controlledByTeam:Q};this.emit("gameStateChange",E,this.game)}else if(this.game.gameModeId===O.KOTC){const E={...this.game};this.game.stage=J.unPackInt8U();this.game.zoneNumber=J.unPackInt8U();this.game.capturing=J.unPackInt8U();this.game.captureProgress=J.unPackInt16U();this.game.numCapturing=J.unPackInt8U();this.game.teamScore[1]=J.unPackInt8U();this.game.teamScore[2]=J.unPackInt8U();this.game.capturePercent=this.game.captureProgress/1000;this.game.activeZone=this.game.map.zones?this.game.map.zones[this.game.zoneNumber-1]:null;const j=Object.values(this.players).filter((M)=>M.inKotcZone&&M.playing);if(this.game.activeZone)Object.values(this.players).forEach((M)=>M.updateKotcZone(this.game.activeZone));if(this.game.numCapturing<=0)Object.values(this.players).forEach((M)=>{M.inKotcZone=!1;this.emit("playerLeaveZone",M)});this.emit("gameStateChange",E,this.game,j)}else if(this.game.gameModeId===O.Team){this.game.teamScore[1]=J.unPackInt16U();this.game.teamScore[2]=J.unPackInt16U()}if(this.game.gameModeId!==O.Spatula)delete this.game.spatula;if(this.game.gameModeId!==O.KOTC){delete this.game.stage;delete this.game.zoneNumber;delete this.game.capturing;delete this.game.captureProgress;delete this.game.numCapturing;delete this.game.numCapturing;delete this.game.activeZone}if(this.game.gameModeId===O.FFA)delete this.game.teamScore}#A(){const E=J.unPackInt8U(),j=J.unPackInt8U(),M=this.players[E];if(!M)return;switch(j){case K.HardBoiled:if(E===this.me.id)this.me.shieldHp=100;M.streakRewards.push(K.HardBoiled);break;case K.EggBreaker:M.streakRewards.push(K.EggBreaker);break;case K.Restock:{M.grenades=3;if(M.weapons[0]&&M.weapons[0].ammo){M.weapons[0].ammo.rounds=M.weapons[0].ammo.capacity;M.weapons[0].ammo.store=M.weapons[0].ammo.storeMax}if(M.weapons[1]&&M.weapons[1].ammo){M.weapons[1].ammo.rounds=M.weapons[1].ammo.capacity;M.weapons[1].ammo.store=M.weapons[1].ammo.storeMax}break}case K.OverHeal:M.hp=Math.min(200,M.hp+100);M.streakRewards.push(K.OverHeal);break;case K.DoubleEggs:M.streakRewards.push(K.DoubleEggs);break;case K.MiniEgg:M.scale=0.5;M.streakRewards.push(K.MiniEgg);break}this.emit("playerBeginStreak",M,j)}#P(){const E=J.unPackInt8U(),j=J.unPackInt8U(),M=this.players[E];if(!M)return;if([K.EggBreaker,K.OverHeal,K.DoubleEggs,K.MiniEgg].includes(j)&&M.streakRewards.includes(j))M.streakRewards=M.streakRewards.filter((_)=>_!==j);if(j===K.MiniEgg)M.scale=1;this.emit("playerEndStreak",M,j)}#z(){const E=J.unPackInt8U(),j=J.unPackInt8U(),M=J.unPackFloat(),Q=J.unPackFloat();if(!this.me)return;this.me.shieldHp=E;this.me.hp=j;if(this.me.shieldHp<=0){this.me.streakRewards=this.me.streakRewards.filter((_)=>_!==K.HardBoiled);this.emit("selfShieldLost",this.me.hp,{dx:M,dz:Q})}else this.emit("selfShieldHit",this.me.shieldHp,this.me.hp,{dx:M,dz:Q})}#T(){const E={...this.game.options};let j=J.unPackInt8U(),M=J.unPackInt8U(),Q=J.unPackInt8U();if(j<1||j>4)j=4;if(M<0||M>8)M=4;if(Q>16)Q=4;this.game.options.gravity=j/4;this.game.options.damage=M/4;this.game.options.healthRegen=Q/4;const _=J.unPackInt8U();Object.keys(m).forEach((U)=>{const q=_&m[U]?1:0;this.game.options[U]=q});this.game.options.weaponsDisabled=Array.from({length:7},()=>J.unPackInt8U()===1);this.game.options.mustUseSecondary=this.game.options.weaponsDisabled.every((U)=>U);this.emit("gameOptionsChange",E,this.game.options)}#b(){const E=J.unPackInt8U();if(E===x.Pause){this.emit("gameForcePause");setTimeout(()=>this.me.playing=!1,3000)}if(E===x.Reset){Object.values(this.players).forEach((j)=>j.streak=0);if(this.game.gameModeId!==O.FFA)this.game.teamScore=[0,0,0];if(this.game.gameModeId===O.Spatula){this.game.spatula.controlledBy=0;this.game.spatula.controlledByTeam=0;this.game.spatula.coords={x:0,y:0,z:0}}if(this.game.gameModeId===O.KOTC){this.game.stage=k.Capturing;this.game.zoneNumber=0;this.game.activeZone=null;this.game.capturing=0;this.game.captureProgress=0;this.game.numCapturing=0;this.game.capturePercent=0}this.emit("gameReset")}}#f(){if(!this.intents.includes(this.Intents.PING))return;const E=this.ping;this.ping=Date.now()-this.lastPingTime;this.emit("pingUpdate",E,this.ping);setTimeout(()=>{const j=new R;j.packInt8($.ping);j.send(this.game.socket);this.lastPingTime=Date.now()},1000)}#W(){const E=J.unPackInt8U(),j=J.unPackInt8U(),M=this.players[E];if(!M)return;const Q=M.team;M.team=j;M.streak=0;this.emit("playerSwitchTeam",M,Q,j)}#w(){const E=J.unPackInt8U(),j=J.unPackInt8U(),M=J.unPackInt16U(),Q=J.unPackInt16U(),_=J.unPackInt8U(),U=J.unPackInt16U(),q=J.unPackInt16U(),L=J.unPackInt16U(),N=J.unPackInt16U(),H=J.unPackInt8(),S=J.unPackInt8(),F=this.intents.includes(this.Intents.COSMETIC_DATA),A=F?V(M):M,Y=F?V(Q):Q,X=F?V(U):U,P=F?V(q):q,Z=F?V(L):L,i=F?V(N):N,G=this.players[E];if(G){const W={...G.character},w=G.selectedGun;G.character.eggColor=_;G.character.primaryGun=A;G.character.secondaryGun=Y;G.character.stamp=P;G.character.hat=X;G.character.grenade=Z;G.character.melee=i;G.character.stampPos.x=H;G.character.stampPos.y=S;G.selectedGun=j;G.weapons[0]=new p[j];if(w!==G.selectedGun)this.emit("playerChangeGun",G,w,G.selectedGun);if(W!==G.character)this.emit("playerChangeCharacter",G,W,G.character)}}#C(){const E=J.unPackInt32U(),j=this.account.eggBalance;this.account.eggBalance=E;this.emit("balanceUpdate",j,E)}#k(){this.me.playing=!1;this.emit("respawnDenied")}#x(){const E=J.unPackInt8U(),j=this.players[E];if(j)this.emit("playerMelee",j)}#v(){const E=J.unPackInt8U(),j=this.players[E];if(!j)return;const M=j.weapons[j.activeGun];if(M.ammo){const Q=Math.min(Math.min(M.ammo.capacity,M.ammo.reload)-M.ammo.rounds,M.ammo.store);M.ammo.rounds+=Q;M.ammo.store-=Q}this.emit("playerReload",j,M)}updateGameOptions(){const E=new R;E.packInt8($.gameOptions);E.packInt8(this.game.options.gravity*4);E.packInt8(this.game.options.damage*4);E.packInt8(this.game.options.healthRegen*4);const j=(this.game.options.locked?1:0)|(this.game.options.noTeamChange?2:0)|(this.game.options.noTeamShuffle?4:0);E.packInt8(j);this.game.options.weaponsDisabled.forEach((M)=>{E.packInt8(M?1:0)});E.send(this.game.socket)}#h(){this.game.isPrivate=!0;this.updateGameOptions()}#D(){const E=J.unPackInt8U();let j=J.unPackInt16U();const M=J.unPackFloat(),Q=J.unPackFloat(),_=J.unPackFloat(),U=J.unPackInt8U(),q=J.unPackFloat();if(this.intents.includes(this.Intents.COSMETIC_DATA))j=V(j);if(E===r.Grenade)this.emit("grenadeExplode",j,{x:M,y:Q,z:_},U,q);else this.emit("rocketHit",{x:M,y:Q,z:_},U,q)}#I(){const E=J.unPackInt8U(),j=J.unPackFloat(),M=J.unPackFloat(),Q=J.unPackFloat(),_=J.unPackFloat(),U=J.unPackFloat(),q=J.unPackFloat(),L=this.players[E];if(L){L.grenades--;this.emit("playerThrowGrenade",L,{x:j,y:M,z:Q},{x:_,y:U,z:q})}}#u(){const E=J.unPackInt8U(),j=J.unPackInt8U(),M=this.players[E];if(!M)return;if(!this.intents.includes(this.Intents.CHALLENGES))return this.emit("challengeComplete",M,j);const Q=this.account.challenges.find((_)=>_.id===j);this.emit("challengeComplete",M,Q);if(M.id===this.me.id)this.refreshChallenges()}#c(){const E=new R;E.packInt8(this.intents.includes(this.Intents.OBSERVE_GAME)?$.observeGame:$.joinGame);E.packString(this.game.raw.uuid);E.packInt8(+this.intents.includes(this.Intents.VIP_HIDE_BADGE));E.packInt8(this.state.weaponIdx||this.account?.loadout?.classIdx||0);E.packString(this.state.name);E.packInt32(this.account.session);E.packString(this.account.sessionId);E.packString(this.account.firebaseId);E.send(this.game.socket)}async#m(){this.me.id=J.unPackInt8U();this.me.team=J.unPackInt8U();this.game.gameModeId=J.unPackInt8U();this.game.gameMode=c[this.game.gameModeId];this.game.mapIdx=J.unPackInt8U();this.game.map=I[this.game.mapIdx];this.game.playerLimit=J.unPackInt8U();this.game.isGameOwner=J.unPackInt8U()===1;this.game.isPrivate=J.unPackInt8U()===1||this.game.isGameOwner;J.unPackInt8U();if(this.intents.includes(this.Intents.LOAD_MAP)||this.intents.includes(this.Intents.PATHFINDING)){this.game.map.raw=await jj(this.game.map.filename,this.game.map.hash);this.emit("mapLoad",this.game.map.raw);if(this.game.gameModeId===O.KOTC){const j=this.game.map.raw.data["DYNAMIC.capture-zone.none"];if(j){this.game.map.zones=Ej(j);if(!this.game.activeZone)this.game.activeZone=this.game.map.zones[this.game.zoneNumber-1]}else delete this.game.map.zones}if(this.intents.includes(this.Intents.PATHFINDING))this.pathing.nodeList=new a(this.game.map.raw)}this.state.inGame=!0;this.lastDeathTime=Date.now();const E=new R;E.packInt8($.clientReady);E.send(this.game.socket);this.updateIntervalId=setInterval(()=>this.update(),33.333333333333336);if(this.intents.includes(this.Intents.PING)){this.lastPingTime=Date.now();const j=new R;j.packInt8($.ping);j.send(this.game.socket)}if(this.intents.includes(this.Intents.NO_AFK_KICK))this.afkKickInterval=setInterval(()=>{if(this.state.inGame&&!this.me.playing&&Date.now()-this.lastDeathTime>=15000){const j=new R;j.packInt8($.keepAlive);j.send(this.game.socket)}},15000);this.emit("gameReady")}#g(){const E=J.unPackInt8U(),j=J.unPackString(128),M=J.unPackString(32),Q=this.players[E];if(!Q)return;Q.admin={ip:M,dbId:j};this.emit("playerInfo",Q,M,j)}packetHandlers={[$.syncThem]:()=>this.#S(),[$.fire]:()=>this.#V(),[$.hitThem]:()=>this.#H(),[$.syncMe]:()=>this.#X(),[$.hitMe]:()=>this.#R(),[$.swapWeapon]:()=>this.#K(),[$.collectItem]:()=>this.#F(),[$.respawn]:()=>this.#L(),[$.die]:()=>this.#O(),[$.pause]:()=>this.#G(),[$.chat]:()=>this.#$(),[$.addPlayer]:()=>this.#q(),[$.removePlayer]:()=>this.#Z(),[$.eventModifier]:()=>this.#Y(),[$.metaGameState]:()=>this.#B(),[$.beginShellStreak]:()=>this.#A(),[$.endShellStreak]:()=>this.#P(),[$.hitMeHardBoiled]:()=>this.#z(),[$.gameOptions]:()=>this.#T(),[$.ping]:()=>this.#f(),[$.switchTeam]:()=>this.#W(),[$.changeCharacter]:()=>this.#w(),[$.reload]:()=>this.#v(),[$.explode]:()=>this.#D(),[$.throwGrenade]:()=>this.#I(),[$.spawnItem]:()=>this.#N(),[$.melee]:()=>this.#x(),[$.updateBalance]:()=>this.#C(),[$.challengeCompleted]:()=>this.#u(),[$.socketReady]:()=>this.#c(),[$.gameJoined]:()=>this.#m(),[$.gameAction]:()=>this.#b(),[$.requestGameOptions]:()=>this.#h(),[$.respawnDenied]:()=>this.#k(),[$.playerInfo]:()=>this.#g(),[$.expireUpgrade]:()=>{},[$.clientReady]:()=>{},[$.musicInfo]:()=>J.unPackLongString()};processPacket(E){J.init(E);if(this.intents.includes(this.Intents.PACKET_HOOK))this.emit("packet",E);let j=0,M=0,Q=!1;while(J.isMoreDataAvailable()&&!Q){const _=J.unPackInt8U(),U=this.packetHandlers[_];if(U)U();else{console.error(`processPacket: I got but couldn't identify a: ${Object.keys($).find((q)=>$[q]===_)} ${_}`);if(j)console.error(`processPacket: It may be a result of the ${j} command (${M}).`);Q=!0;break}j=Object.keys($).find((q)=>$[q]===_);M=_;if(this.intents.includes(this.Intents.LOG_PACKETS))console.log(`[LOG_PACKETS] Packet ${j}: ${M}`)}}async checkChiknWinner(){const E=await this.api.queryServices({cmd:"chicknWinnerReady",id:this.account.id,sessionId:this.account.sessionId});if(typeof E==="string")return E;this.account.cw.limit=E.limit;this.account.cw.atLimit=E.limit>=4;this.account.cw.secondsUntilPlay=(this.account.cw.atLimit?E.period:E.span)||0;this.account.cw.canPlayAgain=Date.now()+this.account.cw.secondsUntilPlay*1000;return this.account.cw}async playChiknWinner(E=!0){if(this.account.cw.atLimit||this.account.cw.limit>t)return"hit_daily_limit";if(this.account.cw.canPlayAgain>Date.now()&&E)return"on_cooldown";const j=await this.api.queryServices({cmd:"incentivizedVideoReward",firebaseId:this.account.firebaseId,id:this.account.id,sessionId:this.account.sessionId,token:null});if(typeof j==="string")return j;if(j.error){if(j.error==="RATELIMITED"||j.error==="RATELMITED"){await this.checkChiknWinner();return"on_cooldown"}else if(j.error==="SESSION_EXPIRED"){this.emit("sessionExpired");return"session_expired"}console.error("Unknown Chikn Winner response, report this on Github:",j);return"unknown_error"}if(j.reward){this.account.eggBalance+=j.reward.eggsGiven;j.reward.itemIds.forEach((M)=>this.account.ownedItemIds.push(M));await this.checkChiknWinner();return j.reward}console.error("Unknown Chikn Winner response, report this on Github:",j);return"unknown_error"}async resetChiknWinner(){if(this.account.eggBalance<200)return"not_enough_eggs";if(!this.account.cw.atLimit)return"not_at_limit";const E=await this.api.queryServices({cmd:"chwReset",sessionId:this.account.sessionId});if(typeof E==="string")return E;if(E.result!=="SUCCESS"){console.error("Unknown Chikn Winner reset response, report this on Github:",E);return"unknown_error"}this.account.eggBalance-=200;await this.checkChiknWinner();return this.account.cw}canSee(E){if(!this.intents.includes(this.Intents.PATHFINDING))return this.processError("You must have the PATHFINDING intent to use this method.");return this.pathing.nodeList.hasLineOfSight(this.me.position,E.position)}async refreshChallenges(){const E=await this.api.queryServices({cmd:"challengeGetDaily",sessionId:this.account.sessionId,playerId:this.account.id});if(typeof E==="string")return E;this.#M(E);return this.account.challenges}async rerollChallenge(E){const j=await this.api.queryServices({cmd:"challengeRerollSlot",sessionId:this.account.sessionId,slotId:E});if(typeof j==="string")return j;this.#M(j);return this.account.challenges}async claimChallenge(E){const j=await this.api.queryServices({cmd:"challengeClaimReward",sessionId:this.account.sessionId,slotId:E});if(typeof j==="string")return j;this.#M(j.challenges);if(j.reward>0)this.account.eggBalance+=j.reward;return{eggReward:j.reward,updatedChallenges:this.account.challenges}}async refreshBalance(){const E=await this.api.queryServices({cmd:"checkBalance",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId});if(typeof E==="string")return E;this.account.eggBalance=E.currentBalance;return E.currentBalance}async redeemCode(E){const j=await this.api.queryServices({cmd:"redeem",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,id:this.account.id,code:E});if(typeof j==="string")return j;if(j.result==="SUCCESS"){this.account.eggBalance=j.eggs_given;j.item_ids.forEach((M)=>this.account.ownedItemIds.push(M));return{result:j,eggsGiven:j.eggs_given,itemIds:j.item_ids}}return j}async claimURLReward(E){const j=await this.api.queryServices({cmd:"urlRewardParams",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,reward:E});if(typeof j==="string")return j;if(j.result==="SUCCESS"){this.account.eggBalance+=j.eggsGiven;j.itemIds.forEach((M)=>this.account.ownedItemIds.push(M))}return j}async claimSocialReward(E){const j=await this.api.queryServices({cmd:"reward",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,rewardTag:E});if(typeof j==="string")return j;if(j.result==="SUCCESS"){this.account.eggBalance+=j.eggsGiven;j.itemIds.forEach((M)=>this.account.ownedItemIds.push(M))}return j}async buyItem(E){const j=await this.api.queryServices({cmd:"buy",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,itemId:E,save:!0});if(typeof j==="string")return j;if(j.result==="SUCCESS"){this.account.eggBalance=j.currentBalance;this.account.ownedItemIds.push(j.itemId)}return j}processError(...E){const j=E.join(" ");if(this.#j.error&&this.#j.error.length)this.emit("error",j);else if(this.intents.includes(this.Intents.NO_EXIT_ON_ERROR))console.error(j);else throw Error(j)}leave(E=d.mainMenu){if(this.hasQuit)return;if(E>-1){this.game?.socket?.close(E);this.state.left=!0;this.emit("leave",E)}clearInterval(this.updateIntervalId);this.#J=[];this.state.inGame=!1;this.state.chatLines=0;this.state.reloading=!1;this.state.swappingGun=!1;this.state.usingMelee=!1;this.state.stateIdx=0;this.state.serverStateIdx=0;this.state.shotsFired=0;this.state.buffer=[];this.players={};this.me=new T({});this.game=this.#U;this.ping=0;this.lastPingTime=-1;this.lastDeathTime=-1;this.lastUpdateTick=0;this.pathing={nodeList:null,followingPath:!1,activePath:null,activeNode:null,activeNodeIdx:0}}logout(){this.account=this.#E;if(this.intents.includes(this.Intents.RENEW_SESSION))clearInterval(this.renewSessionInterval)}quit(E=!1){if(this.hasQuit)return;this.leave();if(this.matchmaker){this.matchmaker.close();if(!E)delete this.matchmaker}if(!E){delete this.account;delete this.api;delete this.game;delete this.me;delete this.pathing;delete this.players;delete this.state;this.#E={};this.#U={};this.#j={};this.#Q=[];this.#J=[]}if(this.intents.includes(this.Intents.NO_AFK_KICK))clearInterval(this.afkKickInterval);if(this.intents.includes(this.Intents.RENEW_SESSION))clearInterval(this.renewSessionInterval);this.hasQuit=!0}}export default Bot;
|
|
1
|
+
import y from"./api.js";import J from"./comm/CommIn.js";import R from"./comm/CommOut.js";import d from"./constants/CloseCode.js";import $ from"./constants/CommCode.js";import T from"./bot/GamePlayer.js";import s from"./matchmaker.js";import n from"./socket.js";import{ChiknWinnerDailyLimit as t,CollectType as C,CoopState as k,findItemById as V,FramesBetweenSyncs as z,GameAction as x,GameMode as O,GameOptionFlag as o,GunList as p,ItemType as r,Movement as B,PlayType as v,ShellStreak as K,StateBufferSize as b}from"./constants/index.js";import h from"./dispatches/LookAtPosDispatch.js";import D from"./dispatches/MovementDispatch.js";import l from"./env/globals.js";import{NodeList as a}from"./pathing/mapnode.js";import{coords as e}from"./wasm/direct.js";import{fetchMap as jj,initKotcZones as Ej}from"./util.js";import{Challenges as Jj}from"./constants/challenges.js";import{Maps as I}from"./constants/maps.js";import{Regions as u}from"./constants/regions.js";const c=Object.fromEntries(Object.entries(O).map(([E,j])=>[j,E])),m=Object.fromEntries(Object.entries(o).map(([E,j])=>[E[0].toLowerCase()+E.slice(1),j])),g={CHALLENGES:1,BOT_STATS:2,PATHFINDING:3,PING:5,COSMETIC_DATA:6,PLAYER_HEALTH:7,PACKET_HOOK:8,LOG_PACKETS:10,NO_LOGIN:11,DEBUG_BUFFER:12,NO_AFK_KICK:16,LOAD_MAP:17,OBSERVE_GAME:18,NO_REGION_CHECK:19,NO_EXIT_ON_ERROR:20,RENEW_SESSION:21,VIP_HIDE_BADGE:22},f=(E,j)=>(E%j+j)%j;export class Bot{static Intents=g;Intents=g;#J=[];#j={};#Q=[];#E;#U;constructor(E={}){if(E.proxy&&l.isBrowser)this.processError("proxies do not work and hence are not supported in the browser");this.intents=E.intents||[];if(this.intents.includes(this.Intents.COSMETIC_DATA)){if(!V(1001))this.processError("you cannot use the COSMETIC_DATA intent inside of the singlefile browser bundles")}this.instance=E.instance||"shellshock.io";this.protocol=E.protocol||"wss";this.proxy=E.proxy||"";this.connectionTimeout=E.connectionTimeout||5000;this.state={name:"yolkbot",weaponIdx:0,useAltGameURL:!1,inGame:!1,chatLines:0,yaw:0,pitch:0,controlKeys:0,reloading:!1,swappingGun:!1,usingMelee:!1,stateIdx:0,serverStateIdx:0,shotsFired:0,buffer:[],left:!1};this.players={};this.me=new T({});this.game={raw:{},code:"",socket:null,gameModeId:0,gameMode:c[0],mapIdx:0,map:{filename:"",hash:"",name:"",modes:{FFA:!1,Teams:!1,Spatula:!1,King:!1},availability:"both",numPlayers:"18",raw:{},nodes:{},zones:[]},playerLimit:0,isGameOwner:!1,isPrivate:!0,options:{gravity:1,damage:1,healthRegen:1,locked:!1,noTeamChange:!1,noTeamShuffle:!1,weaponsDisabled:Array(7).fill(!1),mustUseSecondary:!1},collectables:[[],[]],teamScore:[0,0,0],spatula:{coords:{x:0,y:0,z:0},controlledBy:0,controlledByTeam:0},stage:k.Capturing,zoneNumber:0,activeZone:[],capturing:0,captureProgress:0,numCapturing:0,capturePercent:0};this.#U=this.game;this.account={id:0,firebase:{idToken:"",refreshToken:"",expiresIn:"3600",localId:""},firebaseId:"",sessionId:"",session:0,email:"",password:"",cw:{atLimit:!1,limit:0,secondsUntilPlay:0,canPlayAgain:Date.now()},loadout:{hatId:null,meleeId:0,stampId:null,classIdx:0,colorIdx:0,grenadeId:0,primaryId:[3100,3600,3400,3800,4000,4200,4500],secondaryId:Array(7).fill(3000),stampPositionX:0,stampPositionY:0},ownedItemIds:[],vip:!1,emailVerified:!1,isAged:!1,eggBalance:0,adminRoles:0,rawLoginData:{},isDoubleEggWeeknd:()=>{const j=new Date().getUTCDay(),M=new Date().getUTCHours();return j>=5&&M>=20||j===6||j===0}};this.#E=this.account;this.matchmaker=null;this.api=new y({proxy:this.proxy,protocol:this.protocol,instance:this.instance,maxRetries:E?.apiMaxRetries,connectionTimeout:this.connectionTimeout});this.ping=0;this.lastPingTime=-1;this.lastDeathTime=-1;this.lastUpdateTick=0;this.pathing={nodeList:null,followingPath:!1,activePath:null,activeNode:null,activeNodeIdx:0};this.hasQuit=!1;if(this.intents.includes(this.Intents.NO_AFK_KICK))this.afkKickInterval=0;if(this.intents.includes(this.Intents.RENEW_SESSION))this.renewSessionInterval=0}dispatch(E){if(E.validate(this)){if(E.check(this))E.execute(this);else this.#J.push(E);return!0}return!1}async createAccount(E,j){this.account=this.#E;this.account.email=E;this.account.password=j;const M=await this.api.createAccount(E,j);return this.processLoginData(M)}async login(E,j){this.account=this.#E;this.account.email=E;this.account.password=j;const M=await this.api.loginWithCredentials(E,j);return this.processLoginData(M)}async loginWithRefreshToken(E){this.account=this.#E;const j=await this.api.loginWithRefreshToken(E);return this.processLoginData(j)}async loginAnonymously(){this.account=this.#E;const E=await this.api.loginAnonymously();return this.processLoginData(E)}processLoginData(E){if(typeof E!=="object"){this.emit("authFail",E);return E}if(E.banRemaining){this.emit("banned",E.banRemaining);return"account_banned"}if(!E.playerOutput){this.emit("authFail",E);return E}this.account.firebase=E.firebase||{};E=E.playerOutput;this.account.rawLoginData=E;this.account.adminRoles=E.adminRoles||0;this.account.eggBalance=E.currentBalance;this.account.emailVerified=E.emailVerified;this.account.firebaseId=E.firebaseId;this.account.id=E.id;this.account.isAged=new Date(E.dateCreated).getTime()<1714546800000;this.account.loadout=E.loadout;this.account.ownedItemIds=E.ownedItemIds;this.account.session=E.session;this.account.sessionId=E.sessionId;this.account.vip=E.active_sub==="IsVIP";if(this.intents.includes(this.Intents.BOT_STATS))this.account.stats={lifetime:E.statsLifetime,monthly:E.statsCurrent};if(this.intents.includes(this.Intents.CHALLENGES))this.#M(E.challenges);this.emit("authSuccess",this.account);if(this.intents.includes(this.Intents.RENEW_SESSION))this.renewSessionInterval=setInterval(async()=>{if(!this.account?.sessionId)return clearInterval(this.renewSessionInterval);if((await this.api.queryServices({cmd:"renewSession",sessionId:this.account.sessionId})).data!=="renewed")this.emit("sessionExpired")},600000);return this.account}#M(E){this.account.challenges=[];for(const j of E){const M=Jj.find((Q)=>Q.id===j.challengeId);if(!M)continue;delete j.playerId;this.account.challenges.push({raw:{challengeInfo:M,challengeData:j},id:j.challengeId,name:M.loc.title,desc:M.loc.desc,rewardEggs:M.reward,isRerolled:!!j.reset,isClaimed:!!j.claimed,isCompleted:!!j.completed,progressNum:j.progress,goalNum:M.goal})}}async initMatchmaker(){if(!this.account.sessionId&&!this.intents.includes(this.Intents.NO_LOGIN)){const E=await this.loginAnonymously();if(typeof E!=="object")return E}if(!this.matchmaker){this.matchmaker=new s({api:this.api,proxy:this.proxy,protocol:this.protocol,instance:this.instance,sessionId:this.account.sessionId,connectionTimeout:this.connectionTimeout,noLogin:this.intents.includes(this.Intents.NO_LOGIN)});if(!await this.matchmaker.ws.tryConnect())return"matchmaker_tryconnect_failed";this.matchmaker.on("authFail",(j)=>this.emit("authFail",j));this.matchmaker.on("error",(j)=>this.processError(j))}return!0}async findPublicGame(E,j){if(typeof E!=="string")return"no_region_passed";if(!u.find((Q)=>Q.id===E)&&!this.intents.includes(this.Intents.NO_REGION_CHECK))return"invalid_region_passed";if(typeof j!=="number")return"no_mode_passed";if(Object.values(O).indexOf(j)===-1)return"invalid_mode_passed";if(!await this.initMatchmaker())return"matchmaker_init_fail";return await new Promise((Q)=>{const _=(U)=>{if(U.command==="notice")return;this.matchmaker.off("msg",_);if(U.command==="gameFound"){if(U.useAltGameURL)this.state.useAltGameURL=!0;return Q(U)}if(U.error==="sessionNotFound")return Q("internal_session_error");this.processError("unknown matchmaker response",JSON.stringify(U))};this.matchmaker.on("msg",_);this.matchmaker.send({command:"findGame",region:E,playType:v.JoinPublic,gameType:j,sessionId:this.account.sessionId})})}async createPrivateGame(E,j,M){if(typeof E!=="string")return"no_region_passed";if(!u.find((U)=>U.id===E)&&!this.intents.includes(this.Intents.NO_REGION_CHECK))return"invalid_region_passed";if(typeof j!=="number")return"no_mode_passed";if(Object.values(O).indexOf(j)===-1)return"invalid_mode_passed";if(typeof M!=="string")return"no_map_passed";const Q=I.findIndex((U)=>U.name.toLowerCase()===M.toLowerCase());if(Q===-1)return"invalid_map_passed";if(!await this.initMatchmaker())return"matchmaker_init_fail";return await new Promise((U)=>{const q=(L)=>{if(L.command==="notice")return;this.matchmaker.off("msg",q);if(L.command==="gameFound"){if(L.useAltGameURL)this.state.useAltGameURL=!0;return U(L)}if(L.error==="sessionNotFound")return U("internal_session_error");this.processError("unknown matchmaker response",JSON.stringify(L))};this.matchmaker.on("msg",q);this.matchmaker.send({command:"findGame",region:E,playType:v.CreatePrivate,gameType:j,sessionId:this.account.sessionId,noobLobby:!1,map:Q})})}async join(E,j){this.state.name=E||"yolkbot";if(typeof j==="string"){if(j.includes("#"))j=j.split("#")[1];if(!await this.initMatchmaker())return"matchmaker_init_fail";if(await new Promise((U)=>{const q=(L)=>{if(L.command==="gameFound"){this.matchmaker.off("msg",q);this.game.raw=L;this.game.code=L.id;U(L.id)}if(L.error&&L.error==="gameNotFound"){this.processError(`game "${j}" not found, it may have expired.`);this.leave();return"gameNotFound"}};this.matchmaker.on("msg",q);this.matchmaker.send({command:"joinGame",id:j,observe:!1,sessionId:this.account.sessionId})})==="gameNotFound")return"game_not_found";if(!this.game.raw.id)return this.processError("an internal error occured while joining the game, please report this to developers")}if(typeof j==="object"){if(this.account.id===0)await this.loginAnonymously();this.game.raw=j;this.game.code=this.game.raw.id;if(!this.game.raw.id)return"invalid_game_object";if(!this.game.raw.subdomain)return"invalid_game_object";if(!this.game.raw.uuid)return"invalid_game_object"}const M=this.state.useAltGameURL?`${this.instance}/servers/${this.game.raw.subdomain}`:`${this.game.raw.subdomain}.${this.instance}`;this.game.socket=new n(`${this.protocol}://${M}/game/${this.game.raw.id}`,this.proxy);this.game.socket.binaryType="arraybuffer";this.game.socket.connectionTimeout=this.connectionTimeout;this.game.socket.onBeforeConnect=()=>{this.game.socket.onmessage=(_)=>this.processPacket(_.data);this.game.socket.onclose=(_)=>{if(this.state.left)this.state.left=!1;else{this.emit("close",_.code);this.leave(-1)}}};if(!await this.game.socket.tryConnect())return"websocket_tryconnect_fail";return!0}#_(){if(Object.entries(this.me.position).map((j)=>Math.floor(j[1])).join(",")===this.pathing.activePath[this.pathing.activePath.length-1].positionStr){this.pathing.followingPath=!1;this.pathing.activePath=null;this.pathing.activeNode=null;this.pathing.activeNodeIdx=0;this.dispatch(new D(0))}else{let j;if(this.pathing.activeNodeIdx<this.pathing.activePath.length-1){j=this.pathing.activePath[this.pathing.activeNodeIdx+1].flatCenter();this.dispatch(new h(j))}else{j=this.pathing.activePath[this.pathing.activeNodeIdx].flatCenter();this.dispatch(new h(j))}for(const M of this.pathing.activePath)if(M.flatRadialDistance(this.me.position)<0.1&&M.position.y===Math.floor(this.me.position.y)){if(this.pathing.activePath.indexOf(M)>=this.pathing.activeNodeIdx){this.pathing.activeNodeIdx=this.pathing.activePath.indexOf(M)+1;this.pathing.activeNode=this.pathing.activePath[this.pathing.activeNodeIdx];break}}if(!(this.state.controlKeys&B.Forward))this.dispatch(new D(B.Forward))}}update(){if(this.hasQuit)return;if(this.pathing.followingPath&&this.intents.includes(this.Intents.PATHFINDING))this.#_();for(let j=0;j<this.#J.length;j++){const M=this.#J[j];if(M.check(this)){M.execute(this);this.#J.splice(j,1)}}this.state.chatLines=Math.max(0,this.state.chatLines-0.008333333333333333);if(this.me.playing){const j=this.state.stateIdx;if(this.intents.includes(this.Intents.DEBUG_BUFFER)){console.log("setting buffer for idx",j);console.log("checking...shotsFired",this.state.shotsFired)}this.me.jumping=!!(this.state.controlKeys&B.Jump);this.state.buffer[j]={controlKeys:this.state.controlKeys,yaw:this.state.yaw,pitch:this.state.pitch,shotsFired:this.state.shotsFired};this.state.shotsFired=0;if(this.lastUpdateTick>=2){this.emit("tick");const M=new R;M.packInt8($.syncMe);M.packInt8(this.state.stateIdx);M.packInt8(this.state.serverStateIdx);const Q=f(this.state.stateIdx-z+1,b);for(let _=0;_<z;_++){const U=f(Q+_,b),q=this.state.buffer[U]||{},L=q.controlKeys||0,N=q.shotsFired||0,H=q.yaw??this.state.yaw,S=q.pitch??this.state.pitch;if(this.intents.includes(this.Intents.DEBUG_BUFFER))console.log("going with",this.state.stateIdx,Q,U,q);M.packInt8(L);M.packInt8(N);M.packString(e(H,S));M.packInt8(100)}M.send(this.game.socket);this.state.buffer=[];this.lastUpdateTick=0}else this.lastUpdateTick++;this.state.stateIdx=f(this.state.stateIdx+1,b)}if(!this.intents.includes(this.Intents.PLAYER_HEALTH))return;const E=0.1*(this.game.isPrivate?this.game.options.healthRegen:1);for(const j of Object.values(this.players)){if(j.playing&&j.hp>0){const M=j.streakRewards.includes(K.OverHeal);j.hp+=M?-E:E;j.hp=M?Math.max(100,j.hp):Math.min(100,j.hp)}if(j.spawnShield>0)j.spawnShield-=6}}on(E,j){if(Object.keys(this.#j).includes(E))this.#j[E].push(j);else this.#j[E]=[j]}once(E,j){const M=(...Q)=>{j(...Q);this.off(E,M)};this.on(E,M)}onAny(E){this.#Q.push(E)}off(E,j){if(j)this.#j[E]=this.#j[E].filter((M)=>M!==j);else this.#j[E]=[]}emit(E,...j){if(this.hasQuit)return;if(this.#j[E])for(const M of this.#j[E])M(...j);for(const M of this.#Q)M(E,...j)}#$(){const E=J.unPackInt8U(),j=J.unPackInt8U(),M=J.unPackString().valueOf(),Q=this.players[E];this.emit("chat",Q,M,j)}#q(){const E=J.unPackInt8U(),j=this.intents.includes(this.Intents.COSMETIC_DATA),M={id:E,uniqueId:J.unPackString(),name:J.unPackString(),safeName:J.unPackString(),charClass:J.unPackInt8U(),team:J.unPackInt8U(),primaryWeaponItem:j?V(J.unPackInt16U()):J.unPackInt16U(),secondaryWeaponItem:j?V(J.unPackInt16U()):J.unPackInt16U(),shellColor:J.unPackInt8U(),hatItem:j?V(J.unPackInt16U()):J.unPackInt16U(),stampItem:j?V(J.unPackInt16U()):J.unPackInt16U(),stampPosX:J.unPackInt8(),stampPosY:J.unPackInt8(),grenadeItem:j?V(J.unPackInt16U()):J.unPackInt16U(),meleeItem:j?V(J.unPackInt16U()):J.unPackInt16U(),x:J.unPackFloat(),y:J.unPackFloat(),z:J.unPackFloat(),$dx:J.unPackFloat(),$dy:J.unPackFloat(),$dz:J.unPackFloat(),yaw:J.unPackRadU(),pitch:J.unPackRad(),score:J.unPackInt32U(),$kills:J.unPackInt16U(),$deaths:J.unPackInt16U(),$streak:J.unPackInt16U(),totalKills:J.unPackInt32U(),totalDeaths:J.unPackInt32U(),bestStreak:J.unPackInt16U(),$bestOverallStreak:J.unPackInt16U(),shield:J.unPackInt8U(),hp:J.unPackInt8U(),playing:J.unPackInt8U(),weaponIdx:J.unPackInt8U(),$controlKeys:J.unPackInt8U(),upgradeProductId:J.unPackInt8U(),activeShellStreaks:J.unPackInt8U(),social:J.unPackLongString(),hideBadge:J.unPackInt8U()};this.game.mapIdx=J.unPackInt8U();this.game.isPrivate=J.unPackInt8U()===1;this.game.gameModeId=J.unPackInt8U();const Q=new T(M,this.game.gameMode===O.KOTC?this.game.activeZone:null);if(!this.players[M.id])this.players[M.id]=Q;this.emit("playerJoin",Q);if(this.me.id===M.id){this.me=Q;this.emit("botJoin",this.me)}}#L(){const E=J.unPackInt8U(),j=J.unPackInt16U(),M=J.unPackFloat(),Q=J.unPackFloat(),_=J.unPackFloat(),U=J.unPackInt8U(),q=J.unPackInt8U(),L=J.unPackInt8U(),N=J.unPackInt8U(),H=J.unPackInt8U(),S=this.players[E];if(S){S.playing=!0;S.randomSeed=j;if(S.weapons[0]&&S.weapons[0].ammo)S.weapons[0].ammo.rounds=U;if(S.weapons[0]&&S.weapons[0].ammo)S.weapons[0].ammo.store=q;if(S.weapons[1]&&S.weapons[1].ammo)S.weapons[1].ammo.rounds=L;if(S.weapons[1]&&S.weapons[1].ammo)S.weapons[1].ammo.store=N;S.grenades=H;S.position={x:M,y:Q,z:_};S.spawnShield=120;this.emit("playerRespawn",S)}}#S(){const E=J.unPackInt8U(),j=J.unPackFloat(),M=J.unPackFloat(),Q=J.unPackFloat(),_=J.unPackInt8U(),U=this.players[E];if(!U||U.id===this.me.id){for(let X=0;X<z;X++){J.unPackInt8U();J.unPackRadU();J.unPackRad();J.unPackInt8U()}return}for(let X=0;X<z;X++){const P=J.unPackInt8U();if(P&B.Jump)U.jumping=!0;else U.jumping=!1;if(P&B.Scope)U.scoping=!0;else U.scoping=!1;const Z={...U.view};U.view.yaw=J.unPackRadU();U.view.pitch=J.unPackRad();if(U.view.yaw!==Z.yaw||U.view.pitch!==Z.pitch)this.emit("playerRotate",U,Z,U.view);U.scale=J.unPackInt8U()}const q=U.position,L=q.x!==j||q.y!==M||q.z!==Q,N=U.climbing!==_,H=L||N,S=H?{...q}:null;if(q.x!==j)q.x=j;if(q.z!==Q)q.z=Q;if(!U.jumping||Math.abs(q.y-M)>0.5)q.y=M;if(N)U.climbing=_;if(!H)return;this.emit("playerMove",U,S,q);if(this.game.gameModeId!==O.KOTC)return;const F=this.game.activeZone,A=!!U.inKotcZone;if(!F&&A){U.inKotcZone=!1;this.emit("playerLeaveZone",U);return}U.updateKotcZone(F);const Y=!!U.inKotcZone;if(A!==Y){U.inKotcZone=Y;this.emit(Y?"playerEnterZone":"playerLeaveZone",U)}}#G(){const E=J.unPackInt8U(),j=this.players[E];if(j){j.playing=!1;if(j.streakRewards)j.streakRewards=[];this.emit("playerPause",j);if(j.inKotcZone){j.inKotcZone=!1;this.emit("playerLeaveZone",j)}}}#K(){const E=J.unPackInt8U(),j=J.unPackInt8U(),M=this.players[E];if(M){M.activeGun=j;this.emit("playerSwapWeapon",M,j)}}#O(){const E=J.unPackInt8U(),j=J.unPackInt8U();J.unPackInt8U();J.unPackInt8U();const M=J.unPackInt8U(),Q=this.players[E],_=this.players[j],U=Q?{...Q}:null;if(Q){if(Q.id===this.me.id)this.lastDeathTime=Date.now();Q.playing=!1;Q.streak=0;Q.hp=100;Q.spawnShield=0;Q.stats.totalDeaths++;Q.inKotcZone=!1;this.emit("playerLeaveZone",Q)}if(_){_.streak++;_.stats.totalKills++;if(_.streak>_.stats.bestStreak)_.stats.bestStreak=_.streak}this.emit("playerDeath",Q,_,U,M)}#V(){const E=J.unPackInt8U(),j={posX:J.unPackFloat(),posY:J.unPackFloat(),posZ:J.unPackFloat(),dirX:J.unPackFloat(),dirY:J.unPackFloat(),dirZ:J.unPackFloat()},M=this.players[E];if(!M)return;const Q=M.weapons[M.activeGun];if(Q&&Q.ammo){Q.ammo.rounds--;this.emit("playerFire",M,Q,j)}}#N(){const E=J.unPackInt16U(),j=J.unPackInt8U(),M=J.unPackFloat(),Q=J.unPackFloat(),_=J.unPackFloat();this.game.collectables[j].push({id:E,x:M,y:Q,z:_});this.emit("spawnItem",j,{x:M,y:Q,z:_},E)}#F(){const E=J.unPackInt8U(),j=J.unPackInt8U(),M=J.unPackInt8U(),Q=J.unPackInt16U(),_=this.players[E];if(!_)return;this.game.collectables[j]=this.game.collectables[j].filter((U)=>U.id!==Q);if(j===C.Ammo){const U=_.weapons[M];if(U&&U.ammo){U.ammo.store=Math.min(U.ammo.storeMax,U.ammo.store+U.ammo.pickup);this.emit("playerCollectAmmo",_,U,Q)}}if(j===C.Grenade){_.grenades++;if(_.grenades>3)_.grenades=3;this.emit("playerCollectGrenade",_,Q)}}#H(){const E=J.unPackInt8U(),j=J.unPackInt8U(),M=this.players[E];if(!M)return;const Q=M.hp;M.hp=j;this.emit("playerDamage",M,Q,M.hp)}#R(){const E=J.unPackInt8U();J.unPackFloat();J.unPackFloat();const j=this.me.hp;this.me.hp=E;this.emit("playerDamage",this.me,j,this.me.hp)}#X(){const E=J.unPackInt8U(),j=this.players[E];J.unPackInt8U();const M=J.unPackInt8U(),Q=J.unPackFloat(),_=J.unPackFloat(),U=J.unPackFloat();this.me.climbing=!!J.unPackInt8U();J.unPackInt8U();J.unPackInt8U();if(!j)return;this.state.serverStateIdx=M;const q=j.position.x,L=j.position.y,N=j.position.z;j.position.x=Q;j.position.y=_;j.position.z=U;if(q!==Q||L!==_||N!==U)this.emit("playerMove",j,{x:q,y:L,z:N},{x:Q,y:_,z:U})}#Y(){const E=new R;E.packInt8($.eventModifier);E.send(this.game.socket)}#Z(){const E=J.unPackInt8U(),j={...this.players[E]};delete this.players[E];this.emit("playerLeave",j)}#B(){if(this.game.gameModeId===O.Spatula){const E={...this.game};this.game.teamScore[1]=J.unPackInt16U();this.game.teamScore[2]=J.unPackInt16U();const j={x:J.unPackFloat(),y:J.unPackFloat(),z:J.unPackFloat()},M=J.unPackInt8U(),Q=J.unPackInt8U();this.game.spatula={coords:j,controlledBy:M,controlledByTeam:Q};this.emit("gameStateChange",E,this.game)}else if(this.game.gameModeId===O.KOTC){const E={...this.game};this.game.stage=J.unPackInt8U();this.game.zoneNumber=J.unPackInt8U();this.game.capturing=J.unPackInt8U();this.game.captureProgress=J.unPackInt16U();this.game.numCapturing=J.unPackInt8U();this.game.teamScore[1]=J.unPackInt8U();this.game.teamScore[2]=J.unPackInt8U();this.game.capturePercent=this.game.captureProgress/1000;this.game.activeZone=this.game.map.zones?this.game.map.zones[this.game.zoneNumber-1]:null;const j=Object.values(this.players).filter((M)=>M.inKotcZone&&M.playing);if(this.game.activeZone)Object.values(this.players).forEach((M)=>M.updateKotcZone(this.game.activeZone));if(this.game.numCapturing<=0)Object.values(this.players).forEach((M)=>{M.inKotcZone=!1;this.emit("playerLeaveZone",M)});this.emit("gameStateChange",E,this.game,j)}else if(this.game.gameModeId===O.Team){this.game.teamScore[1]=J.unPackInt16U();this.game.teamScore[2]=J.unPackInt16U()}if(this.game.gameModeId!==O.Spatula)delete this.game.spatula;if(this.game.gameModeId!==O.KOTC){delete this.game.stage;delete this.game.zoneNumber;delete this.game.capturing;delete this.game.captureProgress;delete this.game.numCapturing;delete this.game.numCapturing;delete this.game.activeZone}if(this.game.gameModeId===O.FFA)delete this.game.teamScore}#A(){const E=J.unPackInt8U(),j=J.unPackInt8U(),M=this.players[E];if(!M)return;switch(j){case K.HardBoiled:if(E===this.me.id)this.me.shieldHp=100;M.streakRewards.push(K.HardBoiled);break;case K.EggBreaker:M.streakRewards.push(K.EggBreaker);break;case K.Restock:{M.grenades=3;if(M.weapons[0]&&M.weapons[0].ammo){M.weapons[0].ammo.rounds=M.weapons[0].ammo.capacity;M.weapons[0].ammo.store=M.weapons[0].ammo.storeMax}if(M.weapons[1]&&M.weapons[1].ammo){M.weapons[1].ammo.rounds=M.weapons[1].ammo.capacity;M.weapons[1].ammo.store=M.weapons[1].ammo.storeMax}break}case K.OverHeal:M.hp=Math.min(200,M.hp+100);M.streakRewards.push(K.OverHeal);break;case K.DoubleEggs:M.streakRewards.push(K.DoubleEggs);break;case K.MiniEgg:M.scale=0.5;M.streakRewards.push(K.MiniEgg);break}this.emit("playerBeginStreak",M,j)}#P(){const E=J.unPackInt8U(),j=J.unPackInt8U(),M=this.players[E];if(!M)return;if([K.EggBreaker,K.OverHeal,K.DoubleEggs,K.MiniEgg].includes(j)&&M.streakRewards.includes(j))M.streakRewards=M.streakRewards.filter((_)=>_!==j);if(j===K.MiniEgg)M.scale=1;this.emit("playerEndStreak",M,j)}#z(){const E=J.unPackInt8U(),j=J.unPackInt8U(),M=J.unPackFloat(),Q=J.unPackFloat();if(!this.me)return;this.me.shieldHp=E;this.me.hp=j;if(this.me.shieldHp<=0){this.me.streakRewards=this.me.streakRewards.filter((_)=>_!==K.HardBoiled);this.emit("selfShieldLost",this.me.hp,{dx:M,dz:Q})}else this.emit("selfShieldHit",this.me.shieldHp,this.me.hp,{dx:M,dz:Q})}#T(){const E={...this.game.options};let j=J.unPackInt8U(),M=J.unPackInt8U(),Q=J.unPackInt8U();if(j<1||j>4)j=4;if(M<0||M>8)M=4;if(Q>16)Q=4;this.game.options.gravity=j/4;this.game.options.damage=M/4;this.game.options.healthRegen=Q/4;const _=J.unPackInt8U();Object.keys(m).forEach((U)=>{const q=_&m[U]?1:0;this.game.options[U]=q});this.game.options.weaponsDisabled=Array.from({length:7},()=>J.unPackInt8U()===1);this.game.options.mustUseSecondary=this.game.options.weaponsDisabled.every((U)=>U);this.emit("gameOptionsChange",E,this.game.options)}#b(){const E=J.unPackInt8U();if(E===x.Pause){this.emit("gameForcePause");setTimeout(()=>this.me.playing=!1,3000)}if(E===x.Reset){Object.values(this.players).forEach((j)=>j.streak=0);if(this.game.gameModeId!==O.FFA)this.game.teamScore=[0,0,0];if(this.game.gameModeId===O.Spatula){this.game.spatula.controlledBy=0;this.game.spatula.controlledByTeam=0;this.game.spatula.coords={x:0,y:0,z:0}}if(this.game.gameModeId===O.KOTC){this.game.stage=k.Capturing;this.game.zoneNumber=0;this.game.activeZone=null;this.game.capturing=0;this.game.captureProgress=0;this.game.numCapturing=0;this.game.capturePercent=0}this.emit("gameReset")}}#f(){if(!this.intents.includes(this.Intents.PING))return;const E=this.ping;this.ping=Date.now()-this.lastPingTime;this.emit("pingUpdate",E,this.ping);setTimeout(()=>{const j=new R;j.packInt8($.ping);j.send(this.game.socket);this.lastPingTime=Date.now()},1000)}#W(){const E=J.unPackInt8U(),j=J.unPackInt8U(),M=this.players[E];if(!M)return;const Q=M.team;M.team=j;M.streak=0;this.emit("playerSwitchTeam",M,Q,j)}#w(){const E=J.unPackInt8U(),j=J.unPackInt8U(),M=J.unPackInt16U(),Q=J.unPackInt16U(),_=J.unPackInt8U(),U=J.unPackInt16U(),q=J.unPackInt16U(),L=J.unPackInt16U(),N=J.unPackInt16U(),H=J.unPackInt8(),S=J.unPackInt8(),F=this.intents.includes(this.Intents.COSMETIC_DATA),A=F?V(M):M,Y=F?V(Q):Q,X=F?V(U):U,P=F?V(q):q,Z=F?V(L):L,i=F?V(N):N,G=this.players[E];if(G){const W={...G.character},w=G.selectedGun;G.character.eggColor=_;G.character.primaryGun=A;G.character.secondaryGun=Y;G.character.stamp=P;G.character.hat=X;G.character.grenade=Z;G.character.melee=i;G.character.stampPos.x=H;G.character.stampPos.y=S;G.selectedGun=j;G.weapons[0]=new p[j];if(w!==G.selectedGun)this.emit("playerChangeGun",G,w,G.selectedGun);if(W!==G.character)this.emit("playerChangeCharacter",G,W,G.character)}}#C(){const E=J.unPackInt32U(),j=this.account.eggBalance;this.account.eggBalance=E;this.emit("balanceUpdate",j,E)}#k(){this.me.playing=!1;this.emit("respawnDenied")}#x(){const E=J.unPackInt8U(),j=this.players[E];if(j)this.emit("playerMelee",j)}#v(){const E=J.unPackInt8U(),j=this.players[E];if(!j)return;const M=j.weapons[j.activeGun];if(M.ammo){const Q=Math.min(Math.min(M.ammo.capacity,M.ammo.reload)-M.ammo.rounds,M.ammo.store);M.ammo.rounds+=Q;M.ammo.store-=Q}this.emit("playerReload",j,M)}updateGameOptions(){const E=new R;E.packInt8($.gameOptions);E.packInt8(this.game.options.gravity*4);E.packInt8(this.game.options.damage*4);E.packInt8(this.game.options.healthRegen*4);const j=(this.game.options.locked?1:0)|(this.game.options.noTeamChange?2:0)|(this.game.options.noTeamShuffle?4:0);E.packInt8(j);this.game.options.weaponsDisabled.forEach((M)=>{E.packInt8(M?1:0)});E.send(this.game.socket)}#h(){this.game.isPrivate=!0;this.updateGameOptions()}#D(){const E=J.unPackInt8U();let j=J.unPackInt16U();const M=J.unPackFloat(),Q=J.unPackFloat(),_=J.unPackFloat(),U=J.unPackInt8U(),q=J.unPackFloat();if(this.intents.includes(this.Intents.COSMETIC_DATA))j=V(j);if(E===r.Grenade)this.emit("grenadeExplode",j,{x:M,y:Q,z:_},U,q);else this.emit("rocketHit",{x:M,y:Q,z:_},U,q)}#I(){const E=J.unPackInt8U(),j=J.unPackFloat(),M=J.unPackFloat(),Q=J.unPackFloat(),_=J.unPackFloat(),U=J.unPackFloat(),q=J.unPackFloat(),L=this.players[E];if(L){L.grenades--;this.emit("playerThrowGrenade",L,{x:j,y:M,z:Q},{x:_,y:U,z:q})}}#u(){const E=J.unPackInt8U(),j=J.unPackInt8U(),M=this.players[E];if(!M)return;if(!this.intents.includes(this.Intents.CHALLENGES))return this.emit("challengeComplete",M,j);const Q=this.account.challenges.find((_)=>_.id===j);this.emit("challengeComplete",M,Q);if(M.id===this.me.id)this.refreshChallenges()}#c(){const E=new R;E.packInt8(this.intents.includes(this.Intents.OBSERVE_GAME)?$.observeGame:$.joinGame);E.packString(this.game.raw.uuid);E.packInt8(+this.intents.includes(this.Intents.VIP_HIDE_BADGE));E.packInt8(this.state.weaponIdx||this.account?.loadout?.classIdx||0);E.packString(this.state.name);E.packInt32(this.account.session);E.packString(this.account.sessionId);E.packString(this.account.firebaseId);E.send(this.game.socket)}async#m(){this.me.id=J.unPackInt8U();this.me.team=J.unPackInt8U();this.game.gameModeId=J.unPackInt8U();this.game.gameMode=c[this.game.gameModeId];this.game.mapIdx=J.unPackInt8U();this.game.map=I[this.game.mapIdx];this.game.playerLimit=J.unPackInt8U();this.game.isGameOwner=J.unPackInt8U()===1;this.game.isPrivate=J.unPackInt8U()===1||this.game.isGameOwner;J.unPackInt8U();if(this.intents.includes(this.Intents.LOAD_MAP)||this.intents.includes(this.Intents.PATHFINDING)){this.game.map.raw=await jj(this.game.map.filename,this.game.map.hash);this.emit("mapLoad",this.game.map.raw);if(this.game.gameModeId===O.KOTC){const j=this.game.map.raw.data["DYNAMIC.capture-zone.none"];if(j){this.game.map.zones=Ej(j);if(!this.game.activeZone)this.game.activeZone=this.game.map.zones[this.game.zoneNumber-1]}else delete this.game.map.zones}if(this.intents.includes(this.Intents.PATHFINDING))this.pathing.nodeList=new a(this.game.map.raw)}this.state.inGame=!0;this.lastDeathTime=Date.now();const E=new R;E.packInt8($.clientReady);E.send(this.game.socket);this.updateIntervalId=setInterval(()=>this.update(),33.333333333333336);if(this.intents.includes(this.Intents.PING)){this.lastPingTime=Date.now();const j=new R;j.packInt8($.ping);j.send(this.game.socket)}if(this.intents.includes(this.Intents.NO_AFK_KICK))this.afkKickInterval=setInterval(()=>{if(this.state.inGame&&!this.me.playing&&Date.now()-this.lastDeathTime>=15000){const j=new R;j.packInt8($.keepAlive);j.send(this.game.socket)}},15000);this.emit("gameReady")}#g(){const E=J.unPackInt8U(),j=J.unPackString(128),M=J.unPackString(32),Q=this.players[E];if(!Q)return;Q.admin={ip:M,dbId:j};this.emit("playerInfo",Q,M,j)}packetHandlers={[$.syncThem]:()=>this.#S(),[$.fire]:()=>this.#V(),[$.hitThem]:()=>this.#H(),[$.syncMe]:()=>this.#X(),[$.hitMe]:()=>this.#R(),[$.swapWeapon]:()=>this.#K(),[$.collectItem]:()=>this.#F(),[$.respawn]:()=>this.#L(),[$.die]:()=>this.#O(),[$.pause]:()=>this.#G(),[$.chat]:()=>this.#$(),[$.addPlayer]:()=>this.#q(),[$.removePlayer]:()=>this.#Z(),[$.eventModifier]:()=>this.#Y(),[$.metaGameState]:()=>this.#B(),[$.beginShellStreak]:()=>this.#A(),[$.endShellStreak]:()=>this.#P(),[$.hitMeHardBoiled]:()=>this.#z(),[$.gameOptions]:()=>this.#T(),[$.ping]:()=>this.#f(),[$.switchTeam]:()=>this.#W(),[$.changeCharacter]:()=>this.#w(),[$.reload]:()=>this.#v(),[$.explode]:()=>this.#D(),[$.throwGrenade]:()=>this.#I(),[$.spawnItem]:()=>this.#N(),[$.melee]:()=>this.#x(),[$.updateBalance]:()=>this.#C(),[$.challengeCompleted]:()=>this.#u(),[$.socketReady]:()=>this.#c(),[$.gameJoined]:()=>this.#m(),[$.gameAction]:()=>this.#b(),[$.requestGameOptions]:()=>this.#h(),[$.respawnDenied]:()=>this.#k(),[$.playerInfo]:()=>this.#g(),[$.expireUpgrade]:()=>{},[$.clientReady]:()=>{},[$.musicInfo]:()=>J.unPackLongString()};processPacket(E){J.init(E);if(this.intents.includes(this.Intents.PACKET_HOOK))this.emit("packet",E);let j=0,M=0,Q=!1;while(J.isMoreDataAvailable()&&!Q){const _=J.unPackInt8U(),U=this.packetHandlers[_];if(U)U();else{console.error(`processPacket: I got but couldn't identify a: ${Object.keys($).find((q)=>$[q]===_)} ${_}`);if(j)console.error(`processPacket: It may be a result of the ${j} command (${M}).`);Q=!0;break}j=Object.keys($).find((q)=>$[q]===_);M=_;if(this.intents.includes(this.Intents.LOG_PACKETS))console.log(`[LOG_PACKETS] Packet ${j}: ${M}`)}}async checkChiknWinner(){const E=await this.api.queryServices({cmd:"chicknWinnerReady",id:this.account.id,sessionId:this.account.sessionId});if(typeof E==="string")return E;this.account.cw.limit=E.limit;this.account.cw.atLimit=E.limit>=4;this.account.cw.secondsUntilPlay=(this.account.cw.atLimit?E.period:E.span)||0;this.account.cw.canPlayAgain=Date.now()+this.account.cw.secondsUntilPlay*1000;return this.account.cw}async playChiknWinner(E=!0){if(this.account.cw.atLimit||this.account.cw.limit>t)return"hit_daily_limit";if(this.account.cw.canPlayAgain>Date.now()&&E)return"on_cooldown";const j=await this.api.queryServices({cmd:"incentivizedVideoReward",firebaseId:this.account.firebaseId,id:this.account.id,sessionId:this.account.sessionId,token:null});if(typeof j==="string")return j;if(j.error){if(j.error==="RATELIMITED"||j.error==="RATELMITED"){await this.checkChiknWinner();return"on_cooldown"}else if(j.error==="SESSION_EXPIRED"){this.emit("sessionExpired");return"session_expired"}console.error("Unknown Chikn Winner response, report this on Github:",j);return"unknown_error"}if(j.reward){this.account.eggBalance+=j.reward.eggsGiven;j.reward.itemIds.forEach((M)=>this.account.ownedItemIds.push(M));await this.checkChiknWinner();return j.reward}console.error("Unknown Chikn Winner response, report this on Github:",j);return"unknown_error"}async resetChiknWinner(){if(this.account.eggBalance<200)return"not_enough_eggs";if(!this.account.cw.atLimit)return"not_at_limit";const E=await this.api.queryServices({cmd:"chwReset",sessionId:this.account.sessionId});if(typeof E==="string")return E;if(E.result!=="SUCCESS"){console.error("Unknown Chikn Winner reset response, report this on Github:",E);return"unknown_error"}this.account.eggBalance-=200;await this.checkChiknWinner();return this.account.cw}canSee(E){if(!this.intents.includes(this.Intents.PATHFINDING))return this.processError("You must have the PATHFINDING intent to use this method.");return this.pathing.nodeList.hasLineOfSight(this.me.position,E.position)}async refreshChallenges(){const E=await this.api.queryServices({cmd:"challengeGetDaily",sessionId:this.account.sessionId,playerId:this.account.id});if(typeof E==="string")return E;this.#M(E);return this.account.challenges}async rerollChallenge(E){const j=await this.api.queryServices({cmd:"challengeRerollSlot",sessionId:this.account.sessionId,slotId:E});if(typeof j==="string")return j;this.#M(j);return this.account.challenges}async claimChallenge(E){const j=await this.api.queryServices({cmd:"challengeClaimReward",sessionId:this.account.sessionId,slotId:E});if(typeof j==="string")return j;this.#M(j.challenges);if(j.reward>0)this.account.eggBalance+=j.reward;return{eggReward:j.reward,updatedChallenges:this.account.challenges}}async refreshBalance(){const E=await this.api.queryServices({cmd:"checkBalance",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId});if(typeof E==="string")return E;this.account.eggBalance=E.currentBalance;return E.currentBalance}async redeemCode(E){const j=await this.api.queryServices({cmd:"redeem",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,id:this.account.id,code:E});if(typeof j==="string")return j;if(j.result==="SUCCESS"){this.account.eggBalance=j.eggs_given;j.item_ids.forEach((M)=>this.account.ownedItemIds.push(M));return{result:j,eggsGiven:j.eggs_given,itemIds:j.item_ids}}return j}async claimURLReward(E){const j=await this.api.queryServices({cmd:"urlRewardParams",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,reward:E});if(typeof j==="string")return j;if(j.result==="SUCCESS"){this.account.eggBalance+=j.eggsGiven;j.itemIds.forEach((M)=>this.account.ownedItemIds.push(M))}return j}async claimSocialReward(E){const j=await this.api.queryServices({cmd:"reward",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,rewardTag:E});if(typeof j==="string")return j;if(j.result==="SUCCESS"){this.account.eggBalance+=j.eggsGiven;j.itemIds.forEach((M)=>this.account.ownedItemIds.push(M))}return j}async buyItem(E){const j=await this.api.queryServices({cmd:"buy",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,itemId:E,save:!0});if(typeof j==="string")return j;if(j.result==="SUCCESS"){this.account.eggBalance=j.currentBalance;this.account.ownedItemIds.push(j.itemId)}return j}processError(...E){const j=E.join(" ");if(this.#j.error&&this.#j.error.length)this.emit("error",j);else if(this.intents.includes(this.Intents.NO_EXIT_ON_ERROR))console.error(j);else throw Error(j)}leave(E=d.mainMenu){if(this.hasQuit)return;if(E>-1){this.game?.socket?.close(E);this.state.left=!0;this.emit("leave",E)}clearInterval(this.updateIntervalId);this.#J=[];this.state.inGame=!1;this.state.chatLines=0;this.state.reloading=!1;this.state.swappingGun=!1;this.state.usingMelee=!1;this.state.stateIdx=0;this.state.serverStateIdx=0;this.state.shotsFired=0;this.state.buffer=[];this.players={};this.me=new T({});this.game=this.#U;this.ping=0;this.lastPingTime=-1;this.lastDeathTime=-1;this.lastUpdateTick=0;this.pathing={nodeList:null,followingPath:!1,activePath:null,activeNode:null,activeNodeIdx:0}}logout(){this.account=this.#E;if(this.intents.includes(this.Intents.RENEW_SESSION))clearInterval(this.renewSessionInterval)}quit(E=!1){if(this.hasQuit)return;this.leave();if(this.matchmaker){this.matchmaker.close();if(!E)delete this.matchmaker}if(!E){delete this.account;delete this.api;delete this.game;delete this.me;delete this.pathing;delete this.players;delete this.state;this.#E={};this.#U={};this.#j={};this.#Q=[];this.#J=[]}if(this.intents.includes(this.Intents.NO_AFK_KICK))clearInterval(this.afkKickInterval);if(this.intents.includes(this.Intents.RENEW_SESSION))clearInterval(this.renewSessionInterval);this.hasQuit=!0}}export default Bot;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yolkbot",
|
|
3
3
|
"description": "create a shell shockers bot in under 10 lines.",
|
|
4
|
-
"version": "1.4.
|
|
4
|
+
"version": "1.4.4",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"shell shockers",
|
|
7
7
|
"shellshock.io",
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
}
|
|
134
134
|
},
|
|
135
135
|
"dependencies": {
|
|
136
|
-
"wwws": "^1.1.
|
|
136
|
+
"wwws": "^1.1.4"
|
|
137
137
|
},
|
|
138
138
|
"devDependencies": {
|
|
139
139
|
"@stylistic/eslint-plugin": "^4.4.1",
|