yolkbot 1.2.2 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- var p=Object.defineProperty;var n=(l,e)=>p(l,"name",{value:e,configurable:!0});import a from"./globals.js";import f from"./socket.js";import{FirebaseKey as h,UserAgent as u}from"./constants/index.js";const d={origin:"https://shellshock.io","user-agent":u,"x-client-version":"Chrome/JsCore/9.17.2/FirebaseCore-web","x-firebase-locale":"en"};class y{static{n(this,"API")}constructor(e={}){this.instance=e.instance||"shellshock.io",this.protocol=e.protocol||"wss",this.httpProxy=e.httpProxy||e.proxy?.replace(/socks([4|5|4a|5h]+):\/\//g,"https://")||void 0,this.socksProxy=e.proxy,this.maxRetries=e.maxRetries||5,this.suppressErrors=e.suppressErrors||!1}queryServices=n(async e=>{const r=new f(`${this.protocol}://${this.instance}/services/`,this.socksProxy);return!await r.tryConnect(-2)||r.socket.readyState<1?"websocket_connect_fail":new Promise(s=>{let o=!1;r.onmessage=i=>{o=!0;try{const c=JSON.parse(i.data);s(c)}catch{this.suppressErrors||(console.error("queryServices: Bad API JSON response with call: "+e.cmd+" and data:",JSON.stringify(e)),console.error("queryServices: Full data sent: ",JSON.stringify(e))),s("bad_json")}r.close()},r.onerror=()=>!o&&s("unknown_socket_error"),r.onclose=()=>!o&&s("services_closed_early"),r.send(JSON.stringify(e))})},"queryServices");#e=n(async(e,r,t)=>{if(!e||!r)return"firebase_no_credentials";let s,o;try{s=await(await a.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:${t}?key=${h}`,{method:"POST",body:JSON.stringify({email:e,password:r,returnSecureToken:!0}),headers:{...d,"content-type":"application/json"},dispatcher:this.httpProxy?new a.ProxyAgent(this.httpProxy):void 0})).json(),o=s.idToken}catch(c){return c.code==="auth/network-request-failed"?(this.suppressErrors||console.error("loginWithCredentials: Network req failed (auth/network-request-failed)"),"firebase_network_failed"):c.code==="auth/missing-email"?"firebase_no_credentials":c.code==="ERR_BAD_REQUEST"?(this.suppressErrors||console.error("loginWithCredentials: Error:",e,r),this.suppressErrors||console.error("loginWithCredentials: Error:",s||c),"firebase_bad_request"):(this.suppressErrors||console.error("loginWithCredentials: Error:",e,r,c),"firebase_unknown_error")}if(!o)return this.suppressErrors||console.error("loginWithCredentials: the game sent no idToken",s),"firebase_no_token";this.idToken=o;const i=await this.queryServices({cmd:"auth",firebaseToken:o});return typeof i=="object"?{firebase:s,...i}:i},"#authWithEmailPass");createAccount=n(async(e,r)=>await this.#e(e,r,"signUp"),"createAccount");loginWithCredentials=n(async(e,r)=>await this.#e(e,r,"signInWithPassword"),"loginWithCredentials");loginWithRefreshToken=n(async e=>{if(!e)return"firebase_no_credentials";const r=new URLSearchParams;r.append("grant_type","refresh_token"),r.append("refresh_token",e);let t,s;try{t=await(await a.fetch(`https://securetoken.googleapis.com/v1/token?key=${h}`,{method:"POST",body:r,headers:{...d,"content-type":"application/x-www-form-urlencoded"},dispatcher:this.httpProxy?new a.ProxyAgent(this.httpProxy):void 0})).json(),s=t.id_token}catch(i){return i.code==="auth/network-request-failed"?(this.suppressErrors||console.error("loginWithRefreshToken: Network req failed (auth/network-request-failed)"),"firebase_network_failed"):i.code==="auth/missing-email"?"firebase_no_credentials":(this.suppressErrors||console.error("loginWithRefreshToken: Error:",i,e),"firebase_unknown_error")}if(!s)return this.suppressErrors||console.error("loginWithRefreshToken: the game sent no idToken",t),"firebase_no_token";this.idToken=s;const o=await this.queryServices({cmd:"auth",firebaseToken:s});return typeof o=="object"?{firebase:t,...o}:o},"loginWithRefreshToken");loginAnonymously=n(async()=>{const r=await(await a.fetch("https://identitytoolkit.googleapis.com/v1/accounts:signUp?key="+h,{method:"POST",body:JSON.stringify({returnSecureToken:!0}),headers:{...d,"content-type":"application/json"},dispatcher:this.httpProxy?new a.ProxyAgent(this.httpProxy):void 0})).json(),t=r.idToken;if(!t)return this.suppressErrors||console.error("loginAnonymously: the game sent no idToken",r),"firebase_no_token";this.idToken=t;const s=await this.queryServices({cmd:"auth",firebaseToken:t});return typeof s=="object"?{firebase:r,...s}:s},"loginAnonymously");sendEmailVerification=n(async(e=this.idToken)=>{if(!e)return"no_idtoken_passed";const t=await(await a.fetch("https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode?key="+h,{method:"POST",body:JSON.stringify({requestType:"VERIFY_EMAIL",idToken:e}),headers:{...d,"content-type":"application/json"},dispatcher:this.httpProxy?new a.ProxyAgent(this.httpProxy):void 0})).json();return t.kind!=="identitytoolkit#GetOobConfirmationCodeResponse"?(this.suppressErrors||console.error("sendEmailVerification: the game sent an invalid response",t),"firebase_invalid_response"):{email:t.email}},"sendEmailVerification");verifyOobCode=n(async e=>{if(!e)return"no_oob_code_passed";const t=await(await a.fetch("https://www.googleapis.com/identitytoolkit/v3/relyingparty/setAccountInfo?key="+h,{method:"POST",body:JSON.stringify({oobCode:e}),headers:{...d,"x-client-version":"Chrome/JsCore/3.7.5/FirebaseCore-web",referer:"https://shellshockio-181719.firebaseapp.com/","content-type":"application/json"},dispatcher:this.httpProxy?new a.ProxyAgent(this.httpProxy):void 0})).json();return t.emailVerified?t.email:(this.suppressErrors||console.error("verifyOobCode: the game sent an invalid response",t),"firebase_invalid_response")},"verifyOobCode")}var w=y;export{y as API,w as default};
3
+ var p=Object.defineProperty;var n=(d,e)=>p(d,"name",{value:e,configurable:!0});import c from"./env/globals.js";import f from"./socket.js";import{FirebaseKey as l,UserAgent as u}from"./constants/index.js";const h={origin:"https://shellshock.io","user-agent":u,"x-client-version":"Chrome/JsCore/9.17.2/FirebaseCore-web","x-firebase-locale":"en"};class y{static{n(this,"API")}constructor(e={}){this.instance=e.instance||"shellshock.io",this.protocol=e.protocol||"wss",this.proxy=e.proxy,this.maxRetries=e.maxRetries||5,this.suppressErrors=e.suppressErrors||!1}queryServices=n(async e=>{const r=new f(`${this.protocol}://${this.instance}/services/`,this.proxy);return!await r.tryConnect(-2)||r.socket.readyState<1?"websocket_connect_fail":new Promise(s=>{let t=!1;r.onmessage=i=>{t=!0;try{const a=JSON.parse(i.data);s(a)}catch{this.suppressErrors||(console.error("queryServices: Bad API JSON response with call: "+e.cmd+" and data:",JSON.stringify(e)),console.error("queryServices: Full data sent: ",JSON.stringify(e))),s("bad_json")}r.close()},r.onerror=()=>!t&&s("unknown_socket_error"),r.onclose=()=>!t&&s("services_closed_early"),r.send(JSON.stringify(e))})},"queryServices");#e=n(async(e,r,o)=>{if(!e||!r)return"firebase_no_credentials";let s,t;try{s=await(await c.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:${o}?key=${l}`,{method:"POST",body:JSON.stringify({email:e,password:r,returnSecureToken:!0}),headers:{...h,"content-type":"application/json"},proxy:this.proxy})).json(),t=s.idToken}catch(a){return a.code==="auth/network-request-failed"?(this.suppressErrors||console.error("loginWithCredentials: Network req failed (auth/network-request-failed)"),"firebase_network_failed"):a.code==="auth/missing-email"?"firebase_no_credentials":a.code==="ERR_BAD_REQUEST"?(this.suppressErrors||console.error("loginWithCredentials: Error:",e,r),this.suppressErrors||console.error("loginWithCredentials: Error:",s||a),"firebase_bad_request"):(this.suppressErrors||console.error("loginWithCredentials: Error:",e,r,a),"firebase_unknown_error")}if(!t)return this.suppressErrors||console.error("loginWithCredentials: the game sent no idToken",s),"firebase_no_token";this.idToken=t;const i=await this.queryServices({cmd:"auth",firebaseToken:t});return typeof i=="object"?{firebase:s,...i}:i},"#authWithEmailPass");createAccount=n(async(e,r)=>await this.#e(e,r,"signUp"),"createAccount");loginWithCredentials=n(async(e,r)=>await this.#e(e,r,"signInWithPassword"),"loginWithCredentials");loginWithRefreshToken=n(async e=>{if(!e)return"firebase_no_credentials";const r=new URLSearchParams;r.append("grant_type","refresh_token"),r.append("refresh_token",e);let o,s;try{o=await(await c.fetch(`https://securetoken.googleapis.com/v1/token?key=${l}`,{method:"POST",body:r,headers:{...h,"content-type":"application/x-www-form-urlencoded"},proxy:this.proxy})).json(),s=o.id_token}catch(i){return i.code==="auth/network-request-failed"?(this.suppressErrors||console.error("loginWithRefreshToken: Network req failed (auth/network-request-failed)"),"firebase_network_failed"):i.code==="auth/missing-email"?"firebase_no_credentials":(this.suppressErrors||console.error("loginWithRefreshToken: Error:",i,e),"firebase_unknown_error")}if(!s)return this.suppressErrors||console.error("loginWithRefreshToken: the game sent no idToken",o),"firebase_no_token";this.idToken=s;const t=await this.queryServices({cmd:"auth",firebaseToken:s});return typeof t=="object"?{firebase:o,...t}:t},"loginWithRefreshToken");loginAnonymously=n(async()=>{const r=await(await c.fetch("https://identitytoolkit.googleapis.com/v1/accounts:signUp?key="+l,{method:"POST",body:JSON.stringify({returnSecureToken:!0}),headers:{...h,"content-type":"application/json"},proxy:this.proxy})).json(),o=r.idToken;if(!o)return this.suppressErrors||console.error("loginAnonymously: the game sent no idToken",r),"firebase_no_token";this.idToken=o;const s=await this.queryServices({cmd:"auth",firebaseToken:o});return typeof s=="object"?{firebase:r,...s}:s},"loginAnonymously");sendEmailVerification=n(async(e=this.idToken)=>{if(!e)return"no_idtoken_passed";const o=await(await c.fetch("https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode?key="+l,{method:"POST",body:JSON.stringify({requestType:"VERIFY_EMAIL",idToken:e}),headers:{...h,"content-type":"application/json"},proxy:this.proxy})).json();return o.kind!=="identitytoolkit#GetOobConfirmationCodeResponse"?(this.suppressErrors||console.error("sendEmailVerification: the game sent an invalid response",o),"firebase_invalid_response"):{email:o.email}},"sendEmailVerification");verifyOobCode=n(async e=>{if(!e)return"no_oob_code_passed";const o=await(await c.fetch("https://www.googleapis.com/identitytoolkit/v3/relyingparty/setAccountInfo?key="+l,{method:"POST",body:JSON.stringify({oobCode:e}),headers:{...h,"x-client-version":"Chrome/JsCore/3.7.5/FirebaseCore-web",referer:"https://shellshockio-181719.firebaseapp.com/","content-type":"application/json"},proxy:this.proxy})).json();return o.emailVerified?o.email:(this.suppressErrors||console.error("verifyOobCode: the game sent an invalid response",o),"firebase_invalid_response")},"verifyOobCode")}var m=y;export{y as API,m as default};
package/dist/bot.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- var j=Object.defineProperty;var P=(k,e)=>j(k,"name",{value:e,configurable:!0});import Z from"./api.js";import s from"./comm/CommIn.js";import y from"./comm/CommOut.js";import $ from"./constants/CloseCode.js";import c from"./constants/CommCode.js";import _ from"./bot/GamePlayer.js";import q from"./matchmaker.js";import Y from"./socket.js";import{ChiknWinnerDailyLimit as V,CollectType as R,CoopState as G,findItemById as p,FramesBetweenSyncs as E,GameAction as N,GameMode as d,GameOptionFlag as X,GunList as J,ItemType as Q,Movement as S,PlayType as A,ProxiesEnabled as tt,ShellStreak as u,StateBufferSize as x}from"./constants/index.js";import M from"./dispatches/LookAtPosDispatch.js";import L from"./dispatches/MovementDispatch.js";import{NodeList as et}from"./pathing/mapnode.js";import{coords as st}from"./wasm/wrapper.js";import{fetchMap as at,initKotcZones as it}from"./util.js";import{Challenges as nt}from"./constants/challenges.js";import{Maps as B}from"./constants/maps.js";import{Regions as D}from"./constants/regions.js";const K=Object.fromEntries(Object.entries(d).map(([k,e])=>[e,k])),H=Object.fromEntries(Object.entries(X).map(([k,e])=>[k[0].toLowerCase()+k.slice(1),e])),z={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},O=P((k,e)=>(k%e+e)%e,"mod");class ot{static{P(this,"Bot")}static Intents=z;Intents=z;#s=[];#t={};#i=[];#e;#n;constructor(e={}){(e.proxy||e.httpProxy)&&!tt&&this.processError("proxies do not work and hence are not supported in the browser"),this.intents=e.intents||[],this.intents.includes(this.Intents.COSMETIC_DATA)&&(p(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.httpProxy=e.httpProxy||"",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 _({}),this.game={raw:{},code:"",socket:null,gameModeId:0,gameMode:K[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:G.Capturing,zoneNumber:0,activeZone:[],capturing:0,captureProgress:0,numCapturing:0,capturePercent:0},this.#n=this.game,this.account={id:0,firebase:{idToken:"",refreshToken:"",expiresIn:"3600",localId:""},firebaseId:"",sessionId:"",session:"",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,4e3,4200,4500],secondaryId:new Array(7).fill(3e3),stampPositionX:0,stampPositionY:0},ownedItemIds:[],vip:!1,emailVerified:!1,isAged:!1,eggBalance:0,adminRoles:0,rawLoginData:{},isDoubleEggWeeknd:P(()=>{const t=new Date().getUTCDay(),a=new Date().getUTCHours();return t>=5&&a>=20||t===6||t===0},"isDoubleEggWeeknd")},this.#e=this.account,this.matchmaker=null,this.api=new Z({instance:this.instance,protocol:this.protocol,proxy:this.proxy,httpProxy:this.httpProxy,maxRetries:e?.apiMaxRetries}),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),this.intents.includes(this.Intents.RENEW_SESSION)&&(this.renewSessionInterval=0)}dispatch(e){return e.validate(this)?(e.check(this)?e.execute(this):this.#s.push(e),!0):!1}async createAccount(e,t){this.account=this.#e,this.account.email=e,this.account.password=t;const a=await this.api.createAccount(e,t);return this.processLoginData(a)}async login(e,t){this.account=this.#e,this.account.email=e,this.account.password=t;const a=await this.api.loginWithCredentials(e,t);return this.processLoginData(a)}async loginWithRefreshToken(e){this.account=this.#e;const t=await this.api.loginWithRefreshToken(e);return this.processLoginData(t)}async loginAnonymously(){this.account=this.#e;const e=await this.api.loginAnonymously();return this.processLoginData(e)}processLoginData(e){return typeof e!="object"?(this.emit("authFail",e),e):e.banRemaining?(this.emit("banned",e.banRemaining),"account_banned"):e.playerOutput?(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()<17145468e5,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",this.intents.includes(this.Intents.BOT_STATS)&&(this.account.stats={lifetime:e.statsLifetime,monthly:e.statsCurrent}),this.intents.includes(this.Intents.CHALLENGES)&&this.#a(e.challenges),this.emit("authSuccess",this.account),this.intents.includes(this.Intents.RENEW_SESSION)&&(this.renewSessionInterval=setInterval(async()=>{if(!this.account?.sessionId)return clearInterval(this.renewSessionInterval);(await this.api.queryServices({cmd:"renewSession",sessionId:this.account.sessionId})).data!=="renewed"&&this.emit("sessionExpired")},6e5)),this.account):(this.emit("authFail",e),e)}#a(e){this.account.challenges=[];for(const t of e){const a=nt.find(i=>i.id===t.challengeId);a&&(delete t.playerId,this.account.challenges.push({raw:{challengeInfo:a,challengeData:t},id:t.challengeId,name:a.loc.title,desc:a.loc.desc,rewardEggs:a.reward,isRerolled:!!t.reset,isClaimed:!!t.claimed,isCompleted:!!t.completed,progressNum:t.progress,goalNum:a.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){if(this.matchmaker=new q({sessionId:this.account.sessionId,proxy:this.proxy,instance:this.instance,protocol:this.protocol,noLogin:this.intents.includes(this.Intents.NO_LOGIN),api:this.api}),!await this.matchmaker.ws.tryConnect())return"matchmaker_tryconnect_failed";this.matchmaker.on("authFail",t=>this.emit("authFail",t)),this.matchmaker.on("error",t=>this.processError(t))}return!0}async findPublicGame(e,t){return typeof e!="string"?"no_region_passed":!D.find(i=>i.id===e)&&!this.intents.includes(this.Intents.NO_REGION_CHECK)?"invalid_region_passed":typeof t!="number"?"no_mode_passed":Object.values(d).indexOf(t)===-1?"invalid_mode_passed":await this.initMatchmaker()?await new Promise(i=>{const o=P(n=>{if(n.command!=="notice"){if(this.matchmaker.off("msg",o),n.command==="gameFound")return i(n);if(n.error==="sessionNotFound")return i("internal_session_error");this.processError("unknown matchmaker response "+JSON.stringify(n))}},"listener");this.matchmaker.on("msg",o),this.matchmaker.send({command:"findGame",region:e,playType:A.JoinPublic,gameType:t,sessionId:this.account.sessionId})}):"matchmaker_init_fail"}async createPrivateGame(e,t,a){if(typeof e!="string")return"no_region_passed";if(!D.find(n=>n.id===e)&&!this.intents.includes(this.Intents.NO_REGION_CHECK))return"invalid_region_passed";if(typeof t!="number")return"no_mode_passed";if(Object.values(d).indexOf(t)===-1)return"invalid_mode_passed";if(typeof a!="string")return"no_map_passed";const i=B.findIndex(n=>n.name.toLowerCase()===a.toLowerCase());return i===-1?"invalid_map_passed":await this.initMatchmaker()?await new Promise(n=>{const r=P(h=>{if(h.command!=="notice"){if(this.matchmaker.off("msg",r),h.command==="gameFound")return n(h);if(h.error==="sessionNotFound")return n("internal_session_error");this.processError("unknown matchmaker response "+JSON.stringify(h))}},"listener");this.matchmaker.on("msg",r),this.matchmaker.send({command:"findGame",region:e,playType:A.CreatePrivate,gameType:t,sessionId:this.account.sessionId,noobLobby:!1,map:i})}):"matchmaker_init_fail"}async join(e,t){if(this.state.name=e||"yolkbot",typeof t=="string"){if(t.includes("#")&&(t=t.split("#")[1]),!await this.initMatchmaker())return"matchmaker_init_fail";if(await new Promise(n=>{const r=P(h=>{if(h.command==="gameFound"&&(this.matchmaker.off("msg",r),this.game.raw=h,this.game.code=h.id,n(h.id)),h.error&&h.error==="gameNotFound")return this.processError(`game "${t}" not found, it may have expired.`),this.leave(),"gameNotFound"},"listener");this.matchmaker.on("msg",r),this.matchmaker.send({command:"joinGame",id:t,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 t=="object"&&(this.account.id===0&&await this.loginAnonymously(),this.game.raw=t,this.game.code=this.game.raw.id,!this.game.raw.id||!this.game.raw.subdomain||!this.game.raw.uuid))return"invalid_game_object";const a=this.game.raw.host||(this.instance.startsWith("localhost:")?this.instance:`${this.game.raw.subdomain}.${this.instance}`);return this.game.socket=new Y(`${this.protocol}://${a}/game/${this.game.raw.id}`,this.proxy),this.game.socket.binaryType="arraybuffer",await this.game.socket.tryConnect()?(this.game.socket.onmessage=o=>this.processPacket(o.data),this.game.socket.onclose=o=>{this.state.left?this.state.left=!1:(this.emit("close",o.code),this.leave(-1))},!0):"websocket_tryconnect_fail"}#o(){if(Object.entries(this.me.position).map(t=>Math.floor(t[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 L(0));else{let t;this.pathing.activeNodeIdx<this.pathing.activePath.length-1?(t=this.pathing.activePath[this.pathing.activeNodeIdx+1].flatCenter(),this.dispatch(new M(t))):(t=this.pathing.activePath[this.pathing.activeNodeIdx].flatCenter(),this.dispatch(new M(t)));for(const a of this.pathing.activePath)if(a.flatRadialDistance(this.me.position)<.1&&a.position.y===Math.floor(this.me.position.y)&&this.pathing.activePath.indexOf(a)>=this.pathing.activeNodeIdx){this.pathing.activeNodeIdx=this.pathing.activePath.indexOf(a)+1,this.pathing.activeNode=this.pathing.activePath[this.pathing.activeNodeIdx];break}this.state.controlKeys&S.Forward||this.dispatch(new L(S.Forward))}}update(){if(this.hasQuit)return;this.pathing.followingPath&&this.intents.includes(this.Intents.PATHFINDING)&&this.#o();for(let t=0;t<this.#s.length;t++){const a=this.#s[t];a.check(this)&&(a.execute(this),this.#s.splice(t,1))}if(this.state.chatLines=Math.max(0,this.state.chatLines-1/(30*4)),this.me.playing){const t=this.state.stateIdx;if(this.intents.includes(this.Intents.DEBUG_BUFFER)&&(console.log("setting buffer for idx",t),console.log("checking...shotsFired",this.state.shotsFired)),this.me.jumping=!!(this.state.controlKeys&S.Jump),this.state.buffer[t]={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");const a=new y;a.packInt8(c.syncMe),a.packInt8(this.state.stateIdx),a.packInt8(this.state.serverStateIdx);const i=O(this.state.stateIdx-E+1,x);for(let o=0;o<E;o++){const n=O(i+o,x),r=this.state.buffer[n]||{},h=r.controlKeys||0,g=r.shotsFired||0,f=r.yaw??this.state.yaw,l=r.pitch??this.state.pitch;this.intents.includes(this.Intents.DEBUG_BUFFER)&&console.log("going with",this.state.stateIdx,i,n,r),a.packInt8(h),a.packInt8(g),a.packString(st(f,l)),a.packInt8(100)}a.send(this.game.socket),this.state.buffer=[],this.lastUpdateTick=0}else this.lastUpdateTick++;this.state.stateIdx=O(this.state.stateIdx+1,x)}if(!this.intents.includes(this.Intents.PLAYER_HEALTH))return;const e=.1*(this.game.isPrivate?this.game.options.healthRegen:1);for(const t of Object.values(this.players)){if(t.playing&&t.hp>0){const a=t.streakRewards.includes(u.OverHeal);t.hp+=a?-e:e,t.hp=a?Math.max(100,t.hp):Math.min(100,t.hp)}t.spawnShield>0&&(t.spawnShield-=6)}}on(e,t){Object.keys(this.#t).includes(e)?this.#t[e].push(t):this.#t[e]=[t]}once(e,t){const a=P((...i)=>{t(...i),this.off(e,a)},"onceCb");this.on(e,a)}onAny(e){this.#i.push(e)}off(e,t){t?this.#t[e]=this.#t[e].filter(a=>a!==t):this.#t[e]=[]}emit(e,...t){if(!this.hasQuit){if(this.#t[e])for(const a of this.#t[e])a(...t);for(const a of this.#i)a(e,...t)}}#c(){const e=s.unPackInt8U(),t=s.unPackInt8U(),a=s.unPackString().valueOf(),i=this.players[e];this.emit("chat",i,a,t)}#r(){const e=s.unPackInt8U(),t=this.intents.includes(this.Intents.COSMETIC_DATA),a={id:e,uniqueId:s.unPackString(),name:s.unPackString(),safeName:s.unPackString(),charClass:s.unPackInt8U(),team:s.unPackInt8U(),primaryWeaponItem:t?p(s.unPackInt16U()):s.unPackInt16U(),secondaryWeaponItem:t?p(s.unPackInt16U()):s.unPackInt16U(),shellColor:s.unPackInt8U(),hatItem:t?p(s.unPackInt16U()):s.unPackInt16U(),stampItem:t?p(s.unPackInt16U()):s.unPackInt16U(),stampPosX:s.unPackInt8(),stampPosY:s.unPackInt8(),grenadeItem:t?p(s.unPackInt16U()):s.unPackInt16U(),meleeItem:t?p(s.unPackInt16U()):s.unPackInt16U(),x:s.unPackFloat(),y:s.unPackFloat(),z:s.unPackFloat(),$dx:s.unPackFloat(),$dy:s.unPackFloat(),$dz:s.unPackFloat(),yaw:s.unPackRadU(),pitch:s.unPackRad(),score:s.unPackInt32U(),$kills:s.unPackInt16U(),$deaths:s.unPackInt16U(),$streak:s.unPackInt16U(),totalKills:s.unPackInt32U(),totalDeaths:s.unPackInt32U(),bestStreak:s.unPackInt16U(),$bestOverallStreak:s.unPackInt16U(),shield:s.unPackInt8U(),hp:s.unPackInt8U(),playing:s.unPackInt8U(),weaponIdx:s.unPackInt8U(),$controlKeys:s.unPackInt8U(),upgradeProductId:s.unPackInt8U(),activeShellStreaks:s.unPackInt8U(),social:s.unPackLongString(),hideBadge:s.unPackInt8U()};this.game.mapIdx=s.unPackInt8U(),this.game.isPrivate=s.unPackInt8U()===1,this.game.gameModeId=s.unPackInt8U();const i=new _(a,this.game.gameMode===d.KOTC?this.game.activeZone:null);this.players[a.id]||(this.players[a.id]=i),this.emit("playerJoin",i),this.me.id===a.id&&(this.me=i,this.emit("botJoin",this.me))}#h(){const e=s.unPackInt8U(),t=s.unPackInt16U(),a=s.unPackFloat(),i=s.unPackFloat(),o=s.unPackFloat(),n=s.unPackInt8U(),r=s.unPackInt8U(),h=s.unPackInt8U(),g=s.unPackInt8U(),f=s.unPackInt8U(),l=this.players[e];l&&(l.playing=!0,l.randomSeed=t,l.weapons[0]&&l.weapons[0].ammo&&(l.weapons[0].ammo.rounds=n),l.weapons[0]&&l.weapons[0].ammo&&(l.weapons[0].ammo.store=r),l.weapons[1]&&l.weapons[1].ammo&&(l.weapons[1].ammo.rounds=h),l.weapons[1]&&l.weapons[1].ammo&&(l.weapons[1].ammo.store=g),l.grenades=f,l.position={x:a,y:i,z:o},l.spawnShield=120,this.emit("playerRespawn",l))}#l(){const e=s.unPackInt8U(),t=s.unPackFloat(),a=s.unPackFloat(),i=s.unPackFloat(),o=s.unPackInt8U(),n=this.players[e];if(!n||n.id===this.me.id){for(let w=0;w<E;w++)s.unPackInt8U(),s.unPackRadU(),s.unPackRad(),s.unPackInt8U();return}for(let w=0;w<E;w++){const C=s.unPackInt8U();C&S.Jump?n.jumping=!0:n.jumping=!1,C&S.Scope?n.scoping=!0:n.scoping=!1;const U={...n.view};n.view.yaw=s.unPackRadU(),n.view.pitch=s.unPackRad(),(n.view.yaw!==U.yaw||n.view.pitch!==U.pitch)&&this.emit("playerRotate",n,U,n.view),n.scale=s.unPackInt8U()}const r=n.position,h=r.x!==t||r.y!==a||r.z!==i,g=n.climbing!==o,f=h||g,l=f?{...r}:null;if(r.x!==t&&(r.x=t),r.z!==i&&(r.z=i),(!n.jumping||Math.abs(r.y-a)>.5)&&(r.y=a),g&&(n.climbing=o),!f||(this.emit("playerMove",n,l,r),this.game.gameModeId!==d.KOTC))return;const I=this.game.activeZone,v=!!n.inKotcZone;if(!I&&v){n.inKotcZone=!1,this.emit("playerLeaveZone",n);return}n.updateKotcZone(I);const b=!!n.inKotcZone;v!==b&&(n.inKotcZone=b,this.emit(b?"playerEnterZone":"playerLeaveZone",n))}#m(){const e=s.unPackInt8U(),t=this.players[e];t&&(t.playing=!1,t.streakRewards&&(t.streakRewards=[]),this.emit("playerPause",t),t.inKotcZone&&(t.inKotcZone=!1,this.emit("playerLeaveZone",t)))}#u(){const e=s.unPackInt8U(),t=s.unPackInt8U(),a=this.players[e];a&&(a.activeGun=t,this.emit("playerSwapWeapon",a,t))}#d(){const e=s.unPackInt8U(),t=s.unPackInt8U();s.unPackInt8U(),s.unPackInt8U(),s.unPackInt8U();const a=this.players[e],i=this.players[t];a&&(a.id===this.me.id&&(this.lastDeathTime=Date.now()),a.playing=!1,a.streak=0,a.hp=100,a.spawnShield=0,a.stats.totalDeaths++,a.inKotcZone=!1,this.emit("playerLeaveZone",a)),i&&(i.streak++,i.stats.totalKills++,i.streak>i.stats.bestStreak&&(i.stats.bestStreak=i.streak)),this.emit("playerDeath",a,i)}#p(){const e=s.unPackInt8U(),t={posX:s.unPackFloat(),posY:s.unPackFloat(),posZ:s.unPackFloat(),dirX:s.unPackFloat(),dirY:s.unPackFloat(),dirZ:s.unPackFloat()},a=this.players[e];if(!a)return;const i=a.weapons[a.activeGun];i&&i.ammo&&(i.ammo.rounds--,this.emit("playerFire",a,i,t))}#g(){const e=s.unPackInt16U(),t=s.unPackInt8U(),a=s.unPackFloat(),i=s.unPackFloat(),o=s.unPackFloat();this.game.collectables[t].push({id:e,x:a,y:i,z:o}),this.emit("spawnItem",t,{x:a,y:i,z:o},e)}#k(){const e=s.unPackInt8U(),t=s.unPackInt8U(),a=s.unPackInt8U(),i=s.unPackInt16U(),o=this.players[e];if(o){if(this.game.collectables[t]=this.game.collectables[t].filter(n=>n.id!==i),t===R.Ammo){const n=o.weapons[a];n&&n.ammo&&(n.ammo.store=Math.min(n.ammo.storeMax,n.ammo.store+n.ammo.pickup),this.emit("playerCollectAmmo",o,n,i))}t===R.Grenade&&(o.grenades++,o.grenades>3&&(o.grenades=3),this.emit("playerCollectGrenade",o,i))}}#I(){const e=s.unPackInt8U(),t=s.unPackInt8U(),a=this.players[e];if(!a)return;const i=a.hp;a.hp=t,this.emit("playerDamage",a,i,a.hp)}#f(){const e=s.unPackInt8U();s.unPackFloat(),s.unPackFloat();const t=this.me.hp;this.me.hp=e,this.emit("playerDamage",this.me,t,this.me.hp)}#P(){const e=s.unPackInt8U(),t=this.players[e];s.unPackInt8U();const a=s.unPackInt8U(),i=s.unPackFloat(),o=s.unPackFloat(),n=s.unPackFloat();if(this.me.climbing=!!s.unPackInt8U(),s.unPackInt8U(),s.unPackInt8U(),!t)return;this.state.serverStateIdx=a;const r=t.position.x,h=t.position.y,g=t.position.z;t.position.x=i,t.position.y=o,t.position.z=n,(r!==i||h!==o||g!==n)&&this.emit("playerMove",t,{x:r,y:h,z:g},{x:i,y:o,z:n})}#y(){const e=new y;e.packInt8(c.eventModifier),e.send(this.game.socket)}#w(){const e=s.unPackInt8U(),t={...this.players[e]};delete this.players[e.toString()],this.emit("playerLeave",t)}#b(){if(this.game.gameModeId===d.Spatula){const e={...this.game};this.game.teamScore[1]=s.unPackInt16U(),this.game.teamScore[2]=s.unPackInt16U();const t={x:s.unPackFloat(),y:s.unPackFloat(),z:s.unPackFloat()},a=s.unPackInt8U(),i=s.unPackInt8U();this.game.spatula={coords:t,controlledBy:a,controlledByTeam:i},this.emit("gameStateChange",e,this.game)}else if(this.game.gameModeId===d.KOTC){const e={...this.game};this.game.stage=s.unPackInt8U(),this.game.zoneNumber=s.unPackInt8U(),this.game.capturing=s.unPackInt8U(),this.game.captureProgress=s.unPackInt16U(),this.game.numCapturing=s.unPackInt8U(),this.game.teamScore[1]=s.unPackInt8U(),this.game.teamScore[2]=s.unPackInt8U(),this.game.capturePercent=this.game.captureProgress/1e3,this.game.activeZone=this.game.map.zones?this.game.map.zones[this.game.zoneNumber-1]:null;const t=Object.values(this.players).filter(a=>a.inKotcZone&&a.playing);this.game.activeZone&&Object.values(this.players).forEach(a=>a.updateKotcZone(this.game.activeZone)),this.game.numCapturing<=0&&Object.values(this.players).forEach(a=>{a.inKotcZone=!1,this.emit("playerLeaveZone",a)}),this.emit("gameStateChange",e,this.game,t)}else this.game.gameModeId===d.Team&&(this.game.teamScore[1]=s.unPackInt16U(),this.game.teamScore[2]=s.unPackInt16U());this.game.gameModeId!==d.Spatula&&delete this.game.spatula,this.game.gameModeId!==d.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),this.game.gameModeId===d.FFA&&delete this.game.teamScore}#U(){const e=s.unPackInt8U(),t=s.unPackInt8U(),a=this.players[e];if(a){switch(t){case u.HardBoiled:e===this.me.id&&(this.me.shieldHp=100),a.streakRewards.push(u.HardBoiled);break;case u.EggBreaker:a.streakRewards.push(u.EggBreaker);break;case u.Restock:{a.grenades=3,a.weapons[0]&&a.weapons[0].ammo&&(a.weapons[0].ammo.rounds=a.weapons[0].ammo.capacity,a.weapons[0].ammo.store=a.weapons[0].ammo.storeMax),a.weapons[1]&&a.weapons[1].ammo&&(a.weapons[1].ammo.rounds=a.weapons[1].ammo.capacity,a.weapons[1].ammo.store=a.weapons[1].ammo.storeMax);break}case u.OverHeal:a.hp=Math.min(200,a.hp+100),a.streakRewards.push(u.OverHeal);break;case u.DoubleEggs:a.streakRewards.push(u.DoubleEggs);break;case u.MiniEgg:a.scale=.5,a.streakRewards.push(u.MiniEgg);break}this.emit("playerBeginStreak",a,t)}}#S(){const e=s.unPackInt8U(),t=s.unPackInt8U(),a=this.players[e];if(!a)return;[u.EggBreaker,u.OverHeal,u.DoubleEggs,u.MiniEgg].includes(t)&&a.streakRewards.includes(t)&&(a.streakRewards=a.streakRewards.filter(o=>o!==t)),t===u.MiniEgg&&(a.scale=1),this.emit("playerEndStreak",a,t)}#v(){const e=s.unPackInt8U(),t=s.unPackInt8U(),a=s.unPackFloat(),i=s.unPackFloat();this.me&&(this.me.shieldHp=e,this.me.hp=t,this.me.shieldHp<=0?(this.me.streakRewards=this.me.streakRewards.filter(o=>o!==u.HardBoiled),this.emit("selfShieldLost",this.me.hp,{dx:a,dz:i})):this.emit("selfShieldHit",this.me.shieldHp,this.me.hp,{dx:a,dz:i}))}#C(){const e={...this.game.options};let t=s.unPackInt8U(),a=s.unPackInt8U(),i=s.unPackInt8U();(t<1||t>4)&&(t=4),(a<0||a>8)&&(a=4),i>16&&(i=4),this.game.options.gravity=t/4,this.game.options.damage=a/4,this.game.options.healthRegen=i/4;const o=s.unPackInt8U();Object.keys(H).forEach(n=>{const r=o&H[n]?1:0;this.game.options[n]=r}),this.game.options.weaponsDisabled=Array.from({length:7},()=>s.unPackInt8U()===1),this.game.options.mustUseSecondary=this.game.options.weaponsDisabled.every(n=>n),this.emit("gameOptionsChange",e,this.game.options)}#E(){const e=s.unPackInt8U();e===N.Pause&&(this.emit("gameForcePause"),setTimeout(()=>this.me.playing=!1,3e3)),e===N.Reset&&(Object.values(this.players).forEach(t=>t.streak=0),this.game.gameModeId!==d.FFA&&(this.game.teamScore=[0,0,0]),this.game.gameModeId===d.Spatula&&(this.game.spatula.controlledBy=0,this.game.spatula.controlledByTeam=0,this.game.spatula.coords={x:0,y:0,z:0}),this.game.gameModeId===d.KOTC&&(this.game.stage=G.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"))}#_(){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 t=new y;t.packInt8(c.ping),t.send(this.game.socket),this.lastPingTime=Date.now()},1e3)}#x(){const e=s.unPackInt8U(),t=s.unPackInt8U(),a=this.players[e];if(!a)return;const i=a.team;a.team=t,a.streak=0,this.emit("playerSwitchTeam",a,i,t)}#O(){const e=s.unPackInt8U(),t=s.unPackInt8U(),a=s.unPackInt16U(),i=s.unPackInt16U(),o=s.unPackInt8U(),n=s.unPackInt16U(),r=s.unPackInt16U(),h=s.unPackInt16U(),g=s.unPackInt16U(),f=s.unPackInt8(),l=s.unPackInt8(),I=this.intents.includes(this.Intents.COSMETIC_DATA),v=I?p(a):a,b=I?p(i):i,w=I?p(n):n,C=I?p(r):r,U=I?p(h):h,W=I?p(g):g,m=this.players[e];if(m){const T={...m.character},F=m.selectedGun;m.character.eggColor=o,m.character.primaryGun=v,m.character.secondaryGun=b,m.character.stamp=C,m.character.hat=w,m.character.grenade=U,m.character.melee=W,m.character.stampPos.x=f,m.character.stampPos.y=l,m.selectedGun=t,m.weapons[0]=new J[t],F!==m.selectedGun&&this.emit("playerChangeGun",m,F,m.selectedGun),T!==m.character&&this.emit("playerChangeCharacter",m,T,m.character)}}#T(){const e=s.unPackInt32U(),t=this.account.eggBalance;this.account.eggBalance=e,this.emit("balanceUpdate",t,e)}#F(){this.me.playing=!1,this.emit("respawnDenied")}#R(){const e=s.unPackInt8U(),t=this.players[e];t&&this.emit("playerMelee",t)}#G(){const e=s.unPackInt8U(),t=this.players[e];if(!t)return;const a=t.weapons[t.activeGun];if(a.ammo){const i=Math.min(Math.min(a.ammo.capacity,a.ammo.reload)-a.ammo.rounds,a.ammo.store);a.ammo.rounds+=i,a.ammo.store-=i}this.emit("playerReload",t,a)}updateGameOptions(){const e=new y;e.packInt8(c.gameOptions),e.packInt8(this.game.options.gravity*4),e.packInt8(this.game.options.damage*4),e.packInt8(this.game.options.healthRegen*4);const t=(this.game.options.locked?1:0)|(this.game.options.noTeamChange?2:0)|(this.game.options.noTeamShuffle?4:0);e.packInt8(t),this.game.options.weaponsDisabled.forEach(a=>{e.packInt8(a?1:0)}),e.send(this.game.socket)}#N(){this.game.isPrivate=!0,this.updateGameOptions()}#A(){const e=s.unPackInt8U();let t=s.unPackInt16U();const a=s.unPackFloat(),i=s.unPackFloat(),o=s.unPackFloat(),n=s.unPackInt8U(),r=s.unPackFloat();this.intents.includes(this.Intents.COSMETIC_DATA)&&(t=p(t)),e===Q.Grenade?this.emit("grenadeExplode",t,{x:a,y:i,z:o},n,r):this.emit("rocketHit",{x:a,y:i,z:o},n,r)}#M(){const e=s.unPackInt8U(),t=s.unPackFloat(),a=s.unPackFloat(),i=s.unPackFloat(),o=s.unPackFloat(),n=s.unPackFloat(),r=s.unPackFloat(),h=this.players[e];h&&(h.grenades--,this.emit("playerThrowGrenade",h,{x:t,y:a,z:i},{x:o,y:n,z:r}))}#L(){const e=s.unPackInt8U(),t=s.unPackInt8U(),a=this.players[e];if(!a)return;if(!this.intents.includes(this.Intents.CHALLENGES))return this.emit("challengeComplete",a,t);const i=this.account.challenges.find(o=>o.id===t);this.emit("challengeComplete",a,i),a.id===this.me.id&&this.refreshChallenges()}#B(){const e=new y;e.packInt8(this.intents.includes(this.Intents.OBSERVE_GAME)?c.observeGame:c.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#D(){if(this.me.id=s.unPackInt8U(),this.me.team=s.unPackInt8U(),this.game.gameModeId=s.unPackInt8U(),this.game.gameMode=K[this.game.gameModeId],this.game.mapIdx=s.unPackInt8U(),this.game.map=B[this.game.mapIdx],this.game.playerLimit=s.unPackInt8U(),this.game.isGameOwner=s.unPackInt8U()===1,this.game.isPrivate=s.unPackInt8U()===1||this.game.isGameOwner,s.unPackInt8U(),this.intents.includes(this.Intents.LOAD_MAP)||this.intents.includes(this.Intents.PATHFINDING)){if(this.game.map.raw=await at(this.game.map.filename,this.game.map.hash),this.emit("mapLoad",this.game.map.raw),this.game.gameModeId===d.KOTC){const t=this.game.map.raw.data["DYNAMIC.capture-zone.none"];t?(this.game.map.zones=it(t),this.game.activeZone||(this.game.activeZone=this.game.map.zones[this.game.zoneNumber-1])):delete this.game.map.zones}this.intents.includes(this.Intents.PATHFINDING)&&(this.pathing.nodeList=new et(this.game.map.raw))}this.state.inGame=!0,this.lastDeathTime=Date.now();const e=new y;if(e.packInt8(c.clientReady),e.send(this.game.socket),this.updateIntervalId=setInterval(()=>this.update(),100/3),this.intents.includes(this.Intents.PING)){this.lastPingTime=Date.now();const t=new y;t.packInt8(c.ping),t.send(this.game.socket)}this.intents.includes(this.Intents.NO_AFK_KICK)&&(this.afkKickInterval=setInterval(()=>{if(this.state.inGame&&!this.me.playing&&Date.now()-this.lastDeathTime>=15e3){const t=new y;t.packInt8(c.keepAlive),t.send(this.game.socket)}},15e3)),this.emit("gameReady")}#K(){const e=s.unPackInt8U(),t=s.unPackString(128),a=s.unPackString(32),i=this.players[e];i&&(i.admin={ip:a,dbId:t},this.emit("playerInfo",i,a,t))}processPacket(e){s.init(e),this.intents.includes(this.Intents.PACKET_HOOK)&&this.emit("packet",e);let t=0,a=0,i=!1;for(;s.isMoreDataAvailable()&&!i;){const o=s.unPackInt8U();switch(o){case c.syncThem:this.#l();break;case c.fire:this.#p();break;case c.hitThem:this.#I();break;case c.syncMe:this.#P();break;case c.hitMe:this.#f();break;case c.swapWeapon:this.#u();break;case c.collectItem:this.#k();break;case c.respawn:this.#h();break;case c.die:this.#d();break;case c.pause:this.#m();break;case c.chat:this.#c();break;case c.addPlayer:this.#r();break;case c.removePlayer:this.#w();break;case c.eventModifier:this.#y();break;case c.metaGameState:this.#b();break;case c.beginShellStreak:this.#U();break;case c.endShellStreak:this.#S();break;case c.hitMeHardBoiled:this.#v();break;case c.gameOptions:this.#C();break;case c.ping:this.#_();break;case c.switchTeam:this.#x();break;case c.changeCharacter:this.#O();break;case c.reload:this.#G();break;case c.explode:this.#A();break;case c.throwGrenade:this.#M();break;case c.spawnItem:this.#g();break;case c.melee:this.#R();break;case c.updateBalance:this.#T();break;case c.challengeCompleted:this.#L();break;case c.socketReady:this.#B();break;case c.gameJoined:this.#D();break;case c.gameAction:this.#E();break;case c.requestGameOptions:this.#N();break;case c.respawnDenied:this.#F();break;case c.playerInfo:this.#K();break;case c.expireUpgrade:case c.clientReady:break;case c.musicInfo:s.unPackLongString();break;default:console.error(`processPacket: I got but couldn't identify a: ${Object.keys(c).find(n=>c[n]===o)} ${o}`),t&&console.error(`processPacket: It may be a result of the ${t} command (${a}).`),i=!0;break}t=Object.keys(c).find(n=>c[n]===o),a=o,this.intents.includes(this.Intents.LOG_PACKETS)&&console.log(`[LOG_PACKETS] Packet ${t}: ${a}`)}}async checkChiknWinner(){const e=await this.api.queryServices({cmd:"chicknWinnerReady",id:this.account.id,sessionId:this.account.sessionId});return typeof e=="string"?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*1e3,this.account.cw)}async playChiknWinner(e=!0){if(this.account.cw.atLimit||this.account.cw.limit>V)return"hit_daily_limit";if(this.account.cw.canPlayAgain>Date.now()&&e)return"on_cooldown";const t=await this.api.queryServices({cmd:"incentivizedVideoReward",firebaseId:this.account.firebaseId,id:this.account.id,sessionId:this.account.sessionId,token:null});return typeof t=="string"?t:t.error?t.error==="RATELIMITED"||t.error==="RATELMITED"?(await this.checkChiknWinner(),"on_cooldown"):t.error==="SESSION_EXPIRED"?(this.emit("sessionExpired"),"session_expired"):(console.error("Unknown Chikn Winner response, report this on Github:",t),"unknown_error"):t.reward?(this.account.eggBalance+=t.reward.eggsGiven,t.reward.itemIds.forEach(a=>this.account.ownedItemIds.push(a)),await this.checkChiknWinner(),t.reward):(console.error("Unknown Chikn Winner response, report this on Github:",t),"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});return typeof e=="string"?e:e.result!=="SUCCESS"?(console.error("Unknown Chikn Winner reset response, report this on Github:",e),"unknown_error"):(this.account.eggBalance-=200,await this.checkChiknWinner(),this.account.cw)}canSee(e){return this.intents.includes(this.Intents.PATHFINDING)?this.pathing.nodeList.hasLineOfSight(this.me.position,e.position):this.processError("You must have the PATHFINDING intent to use this method.")}async refreshChallenges(){const e=await this.api.queryServices({cmd:"challengeGetDaily",sessionId:this.account.sessionId,playerId:this.account.id});return typeof e=="string"?e:(this.#a(e),this.account.challenges)}async rerollChallenge(e){const t=await this.api.queryServices({cmd:"challengeRerollSlot",sessionId:this.account.sessionId,slotId:e});return typeof t=="string"?t:(this.#a(t),this.account.challenges)}async claimChallenge(e){const t=await this.api.queryServices({cmd:"challengeClaimReward",sessionId:this.account.sessionId,slotId:e});return typeof t=="string"?t:(this.#a(t.challenges),t.reward>0&&(this.account.eggBalance+=t.reward),{eggReward:t.reward,updatedChallenges:this.account.challenges})}async refreshBalance(){const e=await this.api.queryServices({cmd:"checkBalance",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId});return typeof e=="string"?e:(this.account.eggBalance=e.currentBalance,e.currentBalance)}async redeemCode(e){const t=await this.api.queryServices({cmd:"redeem",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,id:this.account.id,code:e});return typeof t=="string"?t:t.result==="SUCCESS"?(this.account.eggBalance=t.eggs_given,t.item_ids.forEach(a=>this.account.ownedItemIds.push(a)),{result:t,eggsGiven:t.eggs_given,itemIds:t.item_ids}):t}async claimURLReward(e){const t=await this.api.queryServices({cmd:"urlRewardParams",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,reward:e});return typeof t=="string"||t.result==="SUCCESS"&&(this.account.eggBalance+=t.eggsGiven,t.itemIds.forEach(a=>this.account.ownedItemIds.push(a))),t}async claimSocialReward(e){const t=await this.api.queryServices({cmd:"reward",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,rewardTag:e});return typeof t=="string"||t.result==="SUCCESS"&&(this.account.eggBalance+=t.eggsGiven,t.itemIds.forEach(a=>this.account.ownedItemIds.push(a))),t}async buyItem(e){const t=await this.api.queryServices({cmd:"buy",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,itemId:e,save:!0});return typeof t=="string"||t.result==="SUCCESS"&&(this.account.eggBalance=t.currentBalance,this.account.ownedItemIds.push(t.itemId)),t}processError(e){this.#t.error&&this.#t.error.length?this.emit("error",e):(console.error(e),this.intents.includes(this.Intents.NO_EXIT_ON_ERROR)||process.exit(1))}leave(e=$.mainMenu){this.hasQuit||(e>-1&&(this.game?.socket?.close(e),this.state.left=!0,this.emit("leave",e)),clearInterval(this.updateIntervalId),this.#s=[],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 _({}),this.game=this.#n,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,this.intents.includes(this.Intents.RENEW_SESSION)&&clearInterval(this.renewSessionInterval)}quit(e=!1){this.hasQuit||(this.leave(),this.matchmaker&&(this.matchmaker.close(),e||delete this.matchmaker),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.#n={},this.#t={},this.#i=[],this.#s=[]),this.intents.includes(this.Intents.NO_AFK_KICK)&&clearInterval(this.afkKickInterval),this.intents.includes(this.Intents.RENEW_SESSION)&&clearInterval(this.renewSessionInterval),this.hasQuit=!0)}}var vt=ot;export{ot as Bot,vt as default};
3
+ var j=Object.defineProperty;var P=(k,e)=>j(k,"name",{value:e,configurable:!0});import Z from"./api.js";import s from"./comm/CommIn.js";import y from"./comm/CommOut.js";import $ from"./constants/CloseCode.js";import c from"./constants/CommCode.js";import _ from"./bot/GamePlayer.js";import q from"./matchmaker.js";import Y from"./socket.js";import{ChiknWinnerDailyLimit as V,CollectType as R,CoopState as G,findItemById as p,FramesBetweenSyncs as E,GameAction as N,GameMode as d,GameOptionFlag as X,GunList as J,ItemType as Q,Movement as S,PlayType as A,ProxiesEnabled as tt,ShellStreak as u,StateBufferSize as x}from"./constants/index.js";import M from"./dispatches/LookAtPosDispatch.js";import L from"./dispatches/MovementDispatch.js";import{NodeList as et}from"./pathing/mapnode.js";import{coords as st}from"./wasm/wrapper.js";import{fetchMap as at,initKotcZones as it}from"./util.js";import{Challenges as nt}from"./constants/challenges.js";import{Maps as B}from"./constants/maps.js";import{Regions as D}from"./constants/regions.js";const K=Object.fromEntries(Object.entries(d).map(([k,e])=>[e,k])),H=Object.fromEntries(Object.entries(X).map(([k,e])=>[k[0].toLowerCase()+k.slice(1),e])),z={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},O=P((k,e)=>(k%e+e)%e,"mod");class ot{static{P(this,"Bot")}static Intents=z;Intents=z;#s=[];#t={};#i=[];#e;#n;constructor(e={}){e.proxy&&!tt&&this.processError("proxies do not work and hence are not supported in the browser"),this.intents=e.intents||[],this.intents.includes(this.Intents.COSMETIC_DATA)&&(p(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.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 _({}),this.game={raw:{},code:"",socket:null,gameModeId:0,gameMode:K[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:G.Capturing,zoneNumber:0,activeZone:[],capturing:0,captureProgress:0,numCapturing:0,capturePercent:0},this.#n=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,4e3,4200,4500],secondaryId:new Array(7).fill(3e3),stampPositionX:0,stampPositionY:0},ownedItemIds:[],vip:!1,emailVerified:!1,isAged:!1,eggBalance:0,adminRoles:0,rawLoginData:{},isDoubleEggWeeknd:P(()=>{const t=new Date().getUTCDay(),a=new Date().getUTCHours();return t>=5&&a>=20||t===6||t===0},"isDoubleEggWeeknd")},this.#e=this.account,this.matchmaker=null,this.api=new Z({instance:this.instance,protocol:this.protocol,proxy:this.proxy,maxRetries:e?.apiMaxRetries}),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),this.intents.includes(this.Intents.RENEW_SESSION)&&(this.renewSessionInterval=0)}dispatch(e){return e.validate(this)?(e.check(this)?e.execute(this):this.#s.push(e),!0):!1}async createAccount(e,t){this.account=this.#e,this.account.email=e,this.account.password=t;const a=await this.api.createAccount(e,t);return this.processLoginData(a)}async login(e,t){this.account=this.#e,this.account.email=e,this.account.password=t;const a=await this.api.loginWithCredentials(e,t);return this.processLoginData(a)}async loginWithRefreshToken(e){this.account=this.#e;const t=await this.api.loginWithRefreshToken(e);return this.processLoginData(t)}async loginAnonymously(){this.account=this.#e;const e=await this.api.loginAnonymously();return this.processLoginData(e)}processLoginData(e){return typeof e!="object"?(this.emit("authFail",e),e):e.banRemaining?(this.emit("banned",e.banRemaining),"account_banned"):e.playerOutput?(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()<17145468e5,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",this.intents.includes(this.Intents.BOT_STATS)&&(this.account.stats={lifetime:e.statsLifetime,monthly:e.statsCurrent}),this.intents.includes(this.Intents.CHALLENGES)&&this.#a(e.challenges),this.emit("authSuccess",this.account),this.intents.includes(this.Intents.RENEW_SESSION)&&(this.renewSessionInterval=setInterval(async()=>{if(!this.account?.sessionId)return clearInterval(this.renewSessionInterval);(await this.api.queryServices({cmd:"renewSession",sessionId:this.account.sessionId})).data!=="renewed"&&this.emit("sessionExpired")},6e5)),this.account):(this.emit("authFail",e),e)}#a(e){this.account.challenges=[];for(const t of e){const a=nt.find(i=>i.id===t.challengeId);a&&(delete t.playerId,this.account.challenges.push({raw:{challengeInfo:a,challengeData:t},id:t.challengeId,name:a.loc.title,desc:a.loc.desc,rewardEggs:a.reward,isRerolled:!!t.reset,isClaimed:!!t.claimed,isCompleted:!!t.completed,progressNum:t.progress,goalNum:a.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){if(this.matchmaker=new q({sessionId:this.account.sessionId,proxy:this.proxy,instance:this.instance,protocol:this.protocol,noLogin:this.intents.includes(this.Intents.NO_LOGIN),api:this.api}),!await this.matchmaker.ws.tryConnect())return"matchmaker_tryconnect_failed";this.matchmaker.on("authFail",t=>this.emit("authFail",t)),this.matchmaker.on("error",t=>this.processError(t))}return!0}async findPublicGame(e,t){return typeof e!="string"?"no_region_passed":!D.find(i=>i.id===e)&&!this.intents.includes(this.Intents.NO_REGION_CHECK)?"invalid_region_passed":typeof t!="number"?"no_mode_passed":Object.values(d).indexOf(t)===-1?"invalid_mode_passed":await this.initMatchmaker()?await new Promise(i=>{const o=P(n=>{if(n.command!=="notice"){if(this.matchmaker.off("msg",o),n.command==="gameFound")return i(n);if(n.error==="sessionNotFound")return i("internal_session_error");this.processError("unknown matchmaker response "+JSON.stringify(n))}},"listener");this.matchmaker.on("msg",o),this.matchmaker.send({command:"findGame",region:e,playType:A.JoinPublic,gameType:t,sessionId:this.account.sessionId})}):"matchmaker_init_fail"}async createPrivateGame(e,t,a){if(typeof e!="string")return"no_region_passed";if(!D.find(n=>n.id===e)&&!this.intents.includes(this.Intents.NO_REGION_CHECK))return"invalid_region_passed";if(typeof t!="number")return"no_mode_passed";if(Object.values(d).indexOf(t)===-1)return"invalid_mode_passed";if(typeof a!="string")return"no_map_passed";const i=B.findIndex(n=>n.name.toLowerCase()===a.toLowerCase());return i===-1?"invalid_map_passed":await this.initMatchmaker()?await new Promise(n=>{const r=P(h=>{if(h.command!=="notice"){if(this.matchmaker.off("msg",r),h.command==="gameFound")return n(h);if(h.error==="sessionNotFound")return n("internal_session_error");this.processError("unknown matchmaker response "+JSON.stringify(h))}},"listener");this.matchmaker.on("msg",r),this.matchmaker.send({command:"findGame",region:e,playType:A.CreatePrivate,gameType:t,sessionId:this.account.sessionId,noobLobby:!1,map:i})}):"matchmaker_init_fail"}async join(e,t){if(this.state.name=e||"yolkbot",typeof t=="string"){if(t.includes("#")&&(t=t.split("#")[1]),!await this.initMatchmaker())return"matchmaker_init_fail";if(await new Promise(n=>{const r=P(h=>{if(h.command==="gameFound"&&(this.matchmaker.off("msg",r),this.game.raw=h,this.game.code=h.id,n(h.id)),h.error&&h.error==="gameNotFound")return this.processError(`game "${t}" not found, it may have expired.`),this.leave(),"gameNotFound"},"listener");this.matchmaker.on("msg",r),this.matchmaker.send({command:"joinGame",id:t,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 t=="object"&&(this.account.id===0&&await this.loginAnonymously(),this.game.raw=t,this.game.code=this.game.raw.id,!this.game.raw.id||!this.game.raw.subdomain||!this.game.raw.uuid))return"invalid_game_object";const a=this.game.raw.host||(this.instance.startsWith("localhost:")?this.instance:`${this.game.raw.subdomain}.${this.instance}`);return this.game.socket=new Y(`${this.protocol}://${a}/game/${this.game.raw.id}`,this.proxy),this.game.socket.binaryType="arraybuffer",this.game.socket.onBeforeConnect=()=>{this.game.socket.onmessage=o=>this.processPacket(o.data),this.game.socket.onclose=o=>{this.state.left?this.state.left=!1:(this.emit("close",o.code),this.leave(-1))}},await this.game.socket.tryConnect()?!0:"websocket_tryconnect_fail"}#o(){if(Object.entries(this.me.position).map(t=>Math.floor(t[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 L(0));else{let t;this.pathing.activeNodeIdx<this.pathing.activePath.length-1?(t=this.pathing.activePath[this.pathing.activeNodeIdx+1].flatCenter(),this.dispatch(new M(t))):(t=this.pathing.activePath[this.pathing.activeNodeIdx].flatCenter(),this.dispatch(new M(t)));for(const a of this.pathing.activePath)if(a.flatRadialDistance(this.me.position)<.1&&a.position.y===Math.floor(this.me.position.y)&&this.pathing.activePath.indexOf(a)>=this.pathing.activeNodeIdx){this.pathing.activeNodeIdx=this.pathing.activePath.indexOf(a)+1,this.pathing.activeNode=this.pathing.activePath[this.pathing.activeNodeIdx];break}this.state.controlKeys&S.Forward||this.dispatch(new L(S.Forward))}}update(){if(this.hasQuit)return;this.pathing.followingPath&&this.intents.includes(this.Intents.PATHFINDING)&&this.#o();for(let t=0;t<this.#s.length;t++){const a=this.#s[t];a.check(this)&&(a.execute(this),this.#s.splice(t,1))}if(this.state.chatLines=Math.max(0,this.state.chatLines-1/120),this.me.playing){const t=this.state.stateIdx;if(this.intents.includes(this.Intents.DEBUG_BUFFER)&&(console.log("setting buffer for idx",t),console.log("checking...shotsFired",this.state.shotsFired)),this.me.jumping=!!(this.state.controlKeys&S.Jump),this.state.buffer[t]={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");const a=new y;a.packInt8(c.syncMe),a.packInt8(this.state.stateIdx),a.packInt8(this.state.serverStateIdx);const i=O(this.state.stateIdx-E+1,x);for(let o=0;o<E;o++){const n=O(i+o,x),r=this.state.buffer[n]||{},h=r.controlKeys||0,g=r.shotsFired||0,f=r.yaw??this.state.yaw,l=r.pitch??this.state.pitch;this.intents.includes(this.Intents.DEBUG_BUFFER)&&console.log("going with",this.state.stateIdx,i,n,r),a.packInt8(h),a.packInt8(g),a.packString(st(f,l)),a.packInt8(100)}a.send(this.game.socket),this.state.buffer=[],this.lastUpdateTick=0}else this.lastUpdateTick++;this.state.stateIdx=O(this.state.stateIdx+1,x)}if(!this.intents.includes(this.Intents.PLAYER_HEALTH))return;const e=.1*(this.game.isPrivate?this.game.options.healthRegen:1);for(const t of Object.values(this.players)){if(t.playing&&t.hp>0){const a=t.streakRewards.includes(u.OverHeal);t.hp+=a?-e:e,t.hp=a?Math.max(100,t.hp):Math.min(100,t.hp)}t.spawnShield>0&&(t.spawnShield-=6)}}on(e,t){Object.keys(this.#t).includes(e)?this.#t[e].push(t):this.#t[e]=[t]}once(e,t){const a=P((...i)=>{t(...i),this.off(e,a)},"onceCb");this.on(e,a)}onAny(e){this.#i.push(e)}off(e,t){t?this.#t[e]=this.#t[e].filter(a=>a!==t):this.#t[e]=[]}emit(e,...t){if(!this.hasQuit){if(this.#t[e])for(const a of this.#t[e])a(...t);for(const a of this.#i)a(e,...t)}}#c(){const e=s.unPackInt8U(),t=s.unPackInt8U(),a=s.unPackString().valueOf(),i=this.players[e];this.emit("chat",i,a,t)}#r(){const e=s.unPackInt8U(),t=this.intents.includes(this.Intents.COSMETIC_DATA),a={id:e,uniqueId:s.unPackString(),name:s.unPackString(),safeName:s.unPackString(),charClass:s.unPackInt8U(),team:s.unPackInt8U(),primaryWeaponItem:t?p(s.unPackInt16U()):s.unPackInt16U(),secondaryWeaponItem:t?p(s.unPackInt16U()):s.unPackInt16U(),shellColor:s.unPackInt8U(),hatItem:t?p(s.unPackInt16U()):s.unPackInt16U(),stampItem:t?p(s.unPackInt16U()):s.unPackInt16U(),stampPosX:s.unPackInt8(),stampPosY:s.unPackInt8(),grenadeItem:t?p(s.unPackInt16U()):s.unPackInt16U(),meleeItem:t?p(s.unPackInt16U()):s.unPackInt16U(),x:s.unPackFloat(),y:s.unPackFloat(),z:s.unPackFloat(),$dx:s.unPackFloat(),$dy:s.unPackFloat(),$dz:s.unPackFloat(),yaw:s.unPackRadU(),pitch:s.unPackRad(),score:s.unPackInt32U(),$kills:s.unPackInt16U(),$deaths:s.unPackInt16U(),$streak:s.unPackInt16U(),totalKills:s.unPackInt32U(),totalDeaths:s.unPackInt32U(),bestStreak:s.unPackInt16U(),$bestOverallStreak:s.unPackInt16U(),shield:s.unPackInt8U(),hp:s.unPackInt8U(),playing:s.unPackInt8U(),weaponIdx:s.unPackInt8U(),$controlKeys:s.unPackInt8U(),upgradeProductId:s.unPackInt8U(),activeShellStreaks:s.unPackInt8U(),social:s.unPackLongString(),hideBadge:s.unPackInt8U()};this.game.mapIdx=s.unPackInt8U(),this.game.isPrivate=s.unPackInt8U()===1,this.game.gameModeId=s.unPackInt8U();const i=new _(a,this.game.gameMode===d.KOTC?this.game.activeZone:null);this.players[a.id]||(this.players[a.id]=i),this.emit("playerJoin",i),this.me.id===a.id&&(this.me=i,this.emit("botJoin",this.me))}#h(){const e=s.unPackInt8U(),t=s.unPackInt16U(),a=s.unPackFloat(),i=s.unPackFloat(),o=s.unPackFloat(),n=s.unPackInt8U(),r=s.unPackInt8U(),h=s.unPackInt8U(),g=s.unPackInt8U(),f=s.unPackInt8U(),l=this.players[e];l&&(l.playing=!0,l.randomSeed=t,l.weapons[0]&&l.weapons[0].ammo&&(l.weapons[0].ammo.rounds=n),l.weapons[0]&&l.weapons[0].ammo&&(l.weapons[0].ammo.store=r),l.weapons[1]&&l.weapons[1].ammo&&(l.weapons[1].ammo.rounds=h),l.weapons[1]&&l.weapons[1].ammo&&(l.weapons[1].ammo.store=g),l.grenades=f,l.position={x:a,y:i,z:o},l.spawnShield=120,this.emit("playerRespawn",l))}#l(){const e=s.unPackInt8U(),t=s.unPackFloat(),a=s.unPackFloat(),i=s.unPackFloat(),o=s.unPackInt8U(),n=this.players[e];if(!n||n.id===this.me.id){for(let w=0;w<E;w++)s.unPackInt8U(),s.unPackRadU(),s.unPackRad(),s.unPackInt8U();return}for(let w=0;w<E;w++){const C=s.unPackInt8U();C&S.Jump?n.jumping=!0:n.jumping=!1,C&S.Scope?n.scoping=!0:n.scoping=!1;const U={...n.view};n.view.yaw=s.unPackRadU(),n.view.pitch=s.unPackRad(),(n.view.yaw!==U.yaw||n.view.pitch!==U.pitch)&&this.emit("playerRotate",n,U,n.view),n.scale=s.unPackInt8U()}const r=n.position,h=r.x!==t||r.y!==a||r.z!==i,g=n.climbing!==o,f=h||g,l=f?{...r}:null;if(r.x!==t&&(r.x=t),r.z!==i&&(r.z=i),(!n.jumping||Math.abs(r.y-a)>.5)&&(r.y=a),g&&(n.climbing=o),!f||(this.emit("playerMove",n,l,r),this.game.gameModeId!==d.KOTC))return;const I=this.game.activeZone,v=!!n.inKotcZone;if(!I&&v){n.inKotcZone=!1,this.emit("playerLeaveZone",n);return}n.updateKotcZone(I);const b=!!n.inKotcZone;v!==b&&(n.inKotcZone=b,this.emit(b?"playerEnterZone":"playerLeaveZone",n))}#m(){const e=s.unPackInt8U(),t=this.players[e];t&&(t.playing=!1,t.streakRewards&&(t.streakRewards=[]),this.emit("playerPause",t),t.inKotcZone&&(t.inKotcZone=!1,this.emit("playerLeaveZone",t)))}#u(){const e=s.unPackInt8U(),t=s.unPackInt8U(),a=this.players[e];a&&(a.activeGun=t,this.emit("playerSwapWeapon",a,t))}#d(){const e=s.unPackInt8U(),t=s.unPackInt8U();s.unPackInt8U(),s.unPackInt8U(),s.unPackInt8U();const a=this.players[e],i=this.players[t];a&&(a.id===this.me.id&&(this.lastDeathTime=Date.now()),a.playing=!1,a.streak=0,a.hp=100,a.spawnShield=0,a.stats.totalDeaths++,a.inKotcZone=!1,this.emit("playerLeaveZone",a)),i&&(i.streak++,i.stats.totalKills++,i.streak>i.stats.bestStreak&&(i.stats.bestStreak=i.streak)),this.emit("playerDeath",a,i)}#p(){const e=s.unPackInt8U(),t={posX:s.unPackFloat(),posY:s.unPackFloat(),posZ:s.unPackFloat(),dirX:s.unPackFloat(),dirY:s.unPackFloat(),dirZ:s.unPackFloat()},a=this.players[e];if(!a)return;const i=a.weapons[a.activeGun];i&&i.ammo&&(i.ammo.rounds--,this.emit("playerFire",a,i,t))}#g(){const e=s.unPackInt16U(),t=s.unPackInt8U(),a=s.unPackFloat(),i=s.unPackFloat(),o=s.unPackFloat();this.game.collectables[t].push({id:e,x:a,y:i,z:o}),this.emit("spawnItem",t,{x:a,y:i,z:o},e)}#k(){const e=s.unPackInt8U(),t=s.unPackInt8U(),a=s.unPackInt8U(),i=s.unPackInt16U(),o=this.players[e];if(o){if(this.game.collectables[t]=this.game.collectables[t].filter(n=>n.id!==i),t===R.Ammo){const n=o.weapons[a];n&&n.ammo&&(n.ammo.store=Math.min(n.ammo.storeMax,n.ammo.store+n.ammo.pickup),this.emit("playerCollectAmmo",o,n,i))}t===R.Grenade&&(o.grenades++,o.grenades>3&&(o.grenades=3),this.emit("playerCollectGrenade",o,i))}}#I(){const e=s.unPackInt8U(),t=s.unPackInt8U(),a=this.players[e];if(!a)return;const i=a.hp;a.hp=t,this.emit("playerDamage",a,i,a.hp)}#f(){const e=s.unPackInt8U();s.unPackFloat(),s.unPackFloat();const t=this.me.hp;this.me.hp=e,this.emit("playerDamage",this.me,t,this.me.hp)}#P(){const e=s.unPackInt8U(),t=this.players[e];s.unPackInt8U();const a=s.unPackInt8U(),i=s.unPackFloat(),o=s.unPackFloat(),n=s.unPackFloat();if(this.me.climbing=!!s.unPackInt8U(),s.unPackInt8U(),s.unPackInt8U(),!t)return;this.state.serverStateIdx=a;const r=t.position.x,h=t.position.y,g=t.position.z;t.position.x=i,t.position.y=o,t.position.z=n,(r!==i||h!==o||g!==n)&&this.emit("playerMove",t,{x:r,y:h,z:g},{x:i,y:o,z:n})}#y(){const e=new y;e.packInt8(c.eventModifier),e.send(this.game.socket)}#w(){const e=s.unPackInt8U(),t={...this.players[e]};delete this.players[e.toString()],this.emit("playerLeave",t)}#b(){if(this.game.gameModeId===d.Spatula){const e={...this.game};this.game.teamScore[1]=s.unPackInt16U(),this.game.teamScore[2]=s.unPackInt16U();const t={x:s.unPackFloat(),y:s.unPackFloat(),z:s.unPackFloat()},a=s.unPackInt8U(),i=s.unPackInt8U();this.game.spatula={coords:t,controlledBy:a,controlledByTeam:i},this.emit("gameStateChange",e,this.game)}else if(this.game.gameModeId===d.KOTC){const e={...this.game};this.game.stage=s.unPackInt8U(),this.game.zoneNumber=s.unPackInt8U(),this.game.capturing=s.unPackInt8U(),this.game.captureProgress=s.unPackInt16U(),this.game.numCapturing=s.unPackInt8U(),this.game.teamScore[1]=s.unPackInt8U(),this.game.teamScore[2]=s.unPackInt8U(),this.game.capturePercent=this.game.captureProgress/1e3,this.game.activeZone=this.game.map.zones?this.game.map.zones[this.game.zoneNumber-1]:null;const t=Object.values(this.players).filter(a=>a.inKotcZone&&a.playing);this.game.activeZone&&Object.values(this.players).forEach(a=>a.updateKotcZone(this.game.activeZone)),this.game.numCapturing<=0&&Object.values(this.players).forEach(a=>{a.inKotcZone=!1,this.emit("playerLeaveZone",a)}),this.emit("gameStateChange",e,this.game,t)}else this.game.gameModeId===d.Team&&(this.game.teamScore[1]=s.unPackInt16U(),this.game.teamScore[2]=s.unPackInt16U());this.game.gameModeId!==d.Spatula&&delete this.game.spatula,this.game.gameModeId!==d.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),this.game.gameModeId===d.FFA&&delete this.game.teamScore}#U(){const e=s.unPackInt8U(),t=s.unPackInt8U(),a=this.players[e];if(a){switch(t){case u.HardBoiled:e===this.me.id&&(this.me.shieldHp=100),a.streakRewards.push(u.HardBoiled);break;case u.EggBreaker:a.streakRewards.push(u.EggBreaker);break;case u.Restock:{a.grenades=3,a.weapons[0]&&a.weapons[0].ammo&&(a.weapons[0].ammo.rounds=a.weapons[0].ammo.capacity,a.weapons[0].ammo.store=a.weapons[0].ammo.storeMax),a.weapons[1]&&a.weapons[1].ammo&&(a.weapons[1].ammo.rounds=a.weapons[1].ammo.capacity,a.weapons[1].ammo.store=a.weapons[1].ammo.storeMax);break}case u.OverHeal:a.hp=Math.min(200,a.hp+100),a.streakRewards.push(u.OverHeal);break;case u.DoubleEggs:a.streakRewards.push(u.DoubleEggs);break;case u.MiniEgg:a.scale=.5,a.streakRewards.push(u.MiniEgg);break}this.emit("playerBeginStreak",a,t)}}#S(){const e=s.unPackInt8U(),t=s.unPackInt8U(),a=this.players[e];if(!a)return;[u.EggBreaker,u.OverHeal,u.DoubleEggs,u.MiniEgg].includes(t)&&a.streakRewards.includes(t)&&(a.streakRewards=a.streakRewards.filter(o=>o!==t)),t===u.MiniEgg&&(a.scale=1),this.emit("playerEndStreak",a,t)}#v(){const e=s.unPackInt8U(),t=s.unPackInt8U(),a=s.unPackFloat(),i=s.unPackFloat();this.me&&(this.me.shieldHp=e,this.me.hp=t,this.me.shieldHp<=0?(this.me.streakRewards=this.me.streakRewards.filter(o=>o!==u.HardBoiled),this.emit("selfShieldLost",this.me.hp,{dx:a,dz:i})):this.emit("selfShieldHit",this.me.shieldHp,this.me.hp,{dx:a,dz:i}))}#C(){const e={...this.game.options};let t=s.unPackInt8U(),a=s.unPackInt8U(),i=s.unPackInt8U();(t<1||t>4)&&(t=4),(a<0||a>8)&&(a=4),i>16&&(i=4),this.game.options.gravity=t/4,this.game.options.damage=a/4,this.game.options.healthRegen=i/4;const o=s.unPackInt8U();Object.keys(H).forEach(n=>{const r=o&H[n]?1:0;this.game.options[n]=r}),this.game.options.weaponsDisabled=Array.from({length:7},()=>s.unPackInt8U()===1),this.game.options.mustUseSecondary=this.game.options.weaponsDisabled.every(n=>n),this.emit("gameOptionsChange",e,this.game.options)}#E(){const e=s.unPackInt8U();e===N.Pause&&(this.emit("gameForcePause"),setTimeout(()=>this.me.playing=!1,3e3)),e===N.Reset&&(Object.values(this.players).forEach(t=>t.streak=0),this.game.gameModeId!==d.FFA&&(this.game.teamScore=[0,0,0]),this.game.gameModeId===d.Spatula&&(this.game.spatula.controlledBy=0,this.game.spatula.controlledByTeam=0,this.game.spatula.coords={x:0,y:0,z:0}),this.game.gameModeId===d.KOTC&&(this.game.stage=G.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"))}#_(){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 t=new y;t.packInt8(c.ping),t.send(this.game.socket),this.lastPingTime=Date.now()},1e3)}#x(){const e=s.unPackInt8U(),t=s.unPackInt8U(),a=this.players[e];if(!a)return;const i=a.team;a.team=t,a.streak=0,this.emit("playerSwitchTeam",a,i,t)}#O(){const e=s.unPackInt8U(),t=s.unPackInt8U(),a=s.unPackInt16U(),i=s.unPackInt16U(),o=s.unPackInt8U(),n=s.unPackInt16U(),r=s.unPackInt16U(),h=s.unPackInt16U(),g=s.unPackInt16U(),f=s.unPackInt8(),l=s.unPackInt8(),I=this.intents.includes(this.Intents.COSMETIC_DATA),v=I?p(a):a,b=I?p(i):i,w=I?p(n):n,C=I?p(r):r,U=I?p(h):h,W=I?p(g):g,m=this.players[e];if(m){const T={...m.character},F=m.selectedGun;m.character.eggColor=o,m.character.primaryGun=v,m.character.secondaryGun=b,m.character.stamp=C,m.character.hat=w,m.character.grenade=U,m.character.melee=W,m.character.stampPos.x=f,m.character.stampPos.y=l,m.selectedGun=t,m.weapons[0]=new J[t],F!==m.selectedGun&&this.emit("playerChangeGun",m,F,m.selectedGun),T!==m.character&&this.emit("playerChangeCharacter",m,T,m.character)}}#T(){const e=s.unPackInt32U(),t=this.account.eggBalance;this.account.eggBalance=e,this.emit("balanceUpdate",t,e)}#F(){this.me.playing=!1,this.emit("respawnDenied")}#R(){const e=s.unPackInt8U(),t=this.players[e];t&&this.emit("playerMelee",t)}#G(){const e=s.unPackInt8U(),t=this.players[e];if(!t)return;const a=t.weapons[t.activeGun];if(a.ammo){const i=Math.min(Math.min(a.ammo.capacity,a.ammo.reload)-a.ammo.rounds,a.ammo.store);a.ammo.rounds+=i,a.ammo.store-=i}this.emit("playerReload",t,a)}updateGameOptions(){const e=new y;e.packInt8(c.gameOptions),e.packInt8(this.game.options.gravity*4),e.packInt8(this.game.options.damage*4),e.packInt8(this.game.options.healthRegen*4);const t=(this.game.options.locked?1:0)|(this.game.options.noTeamChange?2:0)|(this.game.options.noTeamShuffle?4:0);e.packInt8(t),this.game.options.weaponsDisabled.forEach(a=>{e.packInt8(a?1:0)}),e.send(this.game.socket)}#N(){this.game.isPrivate=!0,this.updateGameOptions()}#A(){const e=s.unPackInt8U();let t=s.unPackInt16U();const a=s.unPackFloat(),i=s.unPackFloat(),o=s.unPackFloat(),n=s.unPackInt8U(),r=s.unPackFloat();this.intents.includes(this.Intents.COSMETIC_DATA)&&(t=p(t)),e===Q.Grenade?this.emit("grenadeExplode",t,{x:a,y:i,z:o},n,r):this.emit("rocketHit",{x:a,y:i,z:o},n,r)}#M(){const e=s.unPackInt8U(),t=s.unPackFloat(),a=s.unPackFloat(),i=s.unPackFloat(),o=s.unPackFloat(),n=s.unPackFloat(),r=s.unPackFloat(),h=this.players[e];h&&(h.grenades--,this.emit("playerThrowGrenade",h,{x:t,y:a,z:i},{x:o,y:n,z:r}))}#L(){const e=s.unPackInt8U(),t=s.unPackInt8U(),a=this.players[e];if(!a)return;if(!this.intents.includes(this.Intents.CHALLENGES))return this.emit("challengeComplete",a,t);const i=this.account.challenges.find(o=>o.id===t);this.emit("challengeComplete",a,i),a.id===this.me.id&&this.refreshChallenges()}#B(){const e=new y;e.packInt8(this.intents.includes(this.Intents.OBSERVE_GAME)?c.observeGame:c.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#D(){if(this.me.id=s.unPackInt8U(),this.me.team=s.unPackInt8U(),this.game.gameModeId=s.unPackInt8U(),this.game.gameMode=K[this.game.gameModeId],this.game.mapIdx=s.unPackInt8U(),this.game.map=B[this.game.mapIdx],this.game.playerLimit=s.unPackInt8U(),this.game.isGameOwner=s.unPackInt8U()===1,this.game.isPrivate=s.unPackInt8U()===1||this.game.isGameOwner,s.unPackInt8U(),this.intents.includes(this.Intents.LOAD_MAP)||this.intents.includes(this.Intents.PATHFINDING)){if(this.game.map.raw=await at(this.game.map.filename,this.game.map.hash),this.emit("mapLoad",this.game.map.raw),this.game.gameModeId===d.KOTC){const t=this.game.map.raw.data["DYNAMIC.capture-zone.none"];t?(this.game.map.zones=it(t),this.game.activeZone||(this.game.activeZone=this.game.map.zones[this.game.zoneNumber-1])):delete this.game.map.zones}this.intents.includes(this.Intents.PATHFINDING)&&(this.pathing.nodeList=new et(this.game.map.raw))}this.state.inGame=!0,this.lastDeathTime=Date.now();const e=new y;if(e.packInt8(c.clientReady),e.send(this.game.socket),this.updateIntervalId=setInterval(()=>this.update(),100/3),this.intents.includes(this.Intents.PING)){this.lastPingTime=Date.now();const t=new y;t.packInt8(c.ping),t.send(this.game.socket)}this.intents.includes(this.Intents.NO_AFK_KICK)&&(this.afkKickInterval=setInterval(()=>{if(this.state.inGame&&!this.me.playing&&Date.now()-this.lastDeathTime>=15e3){const t=new y;t.packInt8(c.keepAlive),t.send(this.game.socket)}},15e3)),this.emit("gameReady")}#K(){const e=s.unPackInt8U(),t=s.unPackString(128),a=s.unPackString(32),i=this.players[e];i&&(i.admin={ip:a,dbId:t},this.emit("playerInfo",i,a,t))}processPacket(e){s.init(e),this.intents.includes(this.Intents.PACKET_HOOK)&&this.emit("packet",e);let t=0,a=0,i=!1;for(;s.isMoreDataAvailable()&&!i;){const o=s.unPackInt8U();switch(o){case c.syncThem:this.#l();break;case c.fire:this.#p();break;case c.hitThem:this.#I();break;case c.syncMe:this.#P();break;case c.hitMe:this.#f();break;case c.swapWeapon:this.#u();break;case c.collectItem:this.#k();break;case c.respawn:this.#h();break;case c.die:this.#d();break;case c.pause:this.#m();break;case c.chat:this.#c();break;case c.addPlayer:this.#r();break;case c.removePlayer:this.#w();break;case c.eventModifier:this.#y();break;case c.metaGameState:this.#b();break;case c.beginShellStreak:this.#U();break;case c.endShellStreak:this.#S();break;case c.hitMeHardBoiled:this.#v();break;case c.gameOptions:this.#C();break;case c.ping:this.#_();break;case c.switchTeam:this.#x();break;case c.changeCharacter:this.#O();break;case c.reload:this.#G();break;case c.explode:this.#A();break;case c.throwGrenade:this.#M();break;case c.spawnItem:this.#g();break;case c.melee:this.#R();break;case c.updateBalance:this.#T();break;case c.challengeCompleted:this.#L();break;case c.socketReady:this.#B();break;case c.gameJoined:this.#D();break;case c.gameAction:this.#E();break;case c.requestGameOptions:this.#N();break;case c.respawnDenied:this.#F();break;case c.playerInfo:this.#K();break;case c.expireUpgrade:case c.clientReady:break;case c.musicInfo:s.unPackLongString();break;default:console.error(`processPacket: I got but couldn't identify a: ${Object.keys(c).find(n=>c[n]===o)} ${o}`),t&&console.error(`processPacket: It may be a result of the ${t} command (${a}).`),i=!0;break}t=Object.keys(c).find(n=>c[n]===o),a=o,this.intents.includes(this.Intents.LOG_PACKETS)&&console.log(`[LOG_PACKETS] Packet ${t}: ${a}`)}}async checkChiknWinner(){const e=await this.api.queryServices({cmd:"chicknWinnerReady",id:this.account.id,sessionId:this.account.sessionId});return typeof e=="string"?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*1e3,this.account.cw)}async playChiknWinner(e=!0){if(this.account.cw.atLimit||this.account.cw.limit>V)return"hit_daily_limit";if(this.account.cw.canPlayAgain>Date.now()&&e)return"on_cooldown";const t=await this.api.queryServices({cmd:"incentivizedVideoReward",firebaseId:this.account.firebaseId,id:this.account.id,sessionId:this.account.sessionId,token:null});return typeof t=="string"?t:t.error?t.error==="RATELIMITED"||t.error==="RATELMITED"?(await this.checkChiknWinner(),"on_cooldown"):t.error==="SESSION_EXPIRED"?(this.emit("sessionExpired"),"session_expired"):(console.error("Unknown Chikn Winner response, report this on Github:",t),"unknown_error"):t.reward?(this.account.eggBalance+=t.reward.eggsGiven,t.reward.itemIds.forEach(a=>this.account.ownedItemIds.push(a)),await this.checkChiknWinner(),t.reward):(console.error("Unknown Chikn Winner response, report this on Github:",t),"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});return typeof e=="string"?e:e.result!=="SUCCESS"?(console.error("Unknown Chikn Winner reset response, report this on Github:",e),"unknown_error"):(this.account.eggBalance-=200,await this.checkChiknWinner(),this.account.cw)}canSee(e){return this.intents.includes(this.Intents.PATHFINDING)?this.pathing.nodeList.hasLineOfSight(this.me.position,e.position):this.processError("You must have the PATHFINDING intent to use this method.")}async refreshChallenges(){const e=await this.api.queryServices({cmd:"challengeGetDaily",sessionId:this.account.sessionId,playerId:this.account.id});return typeof e=="string"?e:(this.#a(e),this.account.challenges)}async rerollChallenge(e){const t=await this.api.queryServices({cmd:"challengeRerollSlot",sessionId:this.account.sessionId,slotId:e});return typeof t=="string"?t:(this.#a(t),this.account.challenges)}async claimChallenge(e){const t=await this.api.queryServices({cmd:"challengeClaimReward",sessionId:this.account.sessionId,slotId:e});return typeof t=="string"?t:(this.#a(t.challenges),t.reward>0&&(this.account.eggBalance+=t.reward),{eggReward:t.reward,updatedChallenges:this.account.challenges})}async refreshBalance(){const e=await this.api.queryServices({cmd:"checkBalance",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId});return typeof e=="string"?e:(this.account.eggBalance=e.currentBalance,e.currentBalance)}async redeemCode(e){const t=await this.api.queryServices({cmd:"redeem",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,id:this.account.id,code:e});return typeof t=="string"?t:t.result==="SUCCESS"?(this.account.eggBalance=t.eggs_given,t.item_ids.forEach(a=>this.account.ownedItemIds.push(a)),{result:t,eggsGiven:t.eggs_given,itemIds:t.item_ids}):t}async claimURLReward(e){const t=await this.api.queryServices({cmd:"urlRewardParams",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,reward:e});return typeof t=="string"||t.result==="SUCCESS"&&(this.account.eggBalance+=t.eggsGiven,t.itemIds.forEach(a=>this.account.ownedItemIds.push(a))),t}async claimSocialReward(e){const t=await this.api.queryServices({cmd:"reward",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,rewardTag:e});return typeof t=="string"||t.result==="SUCCESS"&&(this.account.eggBalance+=t.eggsGiven,t.itemIds.forEach(a=>this.account.ownedItemIds.push(a))),t}async buyItem(e){const t=await this.api.queryServices({cmd:"buy",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,itemId:e,save:!0});return typeof t=="string"||t.result==="SUCCESS"&&(this.account.eggBalance=t.currentBalance,this.account.ownedItemIds.push(t.itemId)),t}processError(e){this.#t.error&&this.#t.error.length?this.emit("error",e):(console.error(e),this.intents.includes(this.Intents.NO_EXIT_ON_ERROR)||process.exit(1))}leave(e=$.mainMenu){this.hasQuit||(e>-1&&(this.game?.socket?.close(e),this.state.left=!0,this.emit("leave",e)),clearInterval(this.updateIntervalId),this.#s=[],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 _({}),this.game=this.#n,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,this.intents.includes(this.Intents.RENEW_SESSION)&&clearInterval(this.renewSessionInterval)}quit(e=!1){this.hasQuit||(this.leave(),this.matchmaker&&(this.matchmaker.close(),e||delete this.matchmaker),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.#n={},this.#t={},this.#i=[],this.#s=[]),this.intents.includes(this.Intents.NO_AFK_KICK)&&clearInterval(this.afkKickInterval),this.intents.includes(this.Intents.RENEW_SESSION)&&clearInterval(this.renewSessionInterval),this.hasQuit=!0)}}var vt=ot;export{ot as Bot,vt as default};
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- import{AUG as t,CSG1 as o,DozenGauge as n,Eggk47 as r,M24 as a,RPEGG as i,SMG as l}from"./guns.js";import{findItemById as W}from"./findItemById.js";const s={FiveMinutes:0,FifteenMinutes:1,OneHour:2},p={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},m={Kill:0,Damage:1,Death:2,Movement:3,Collect:4,Time:5,KOTC:6,Spatula:7},d={None:0,Pinned:2,Team:4,Mod:254,Server:255},u=3,x={Ammo:0,Grenade:1},S={Start:0,Score:1,Win:2,Capturing:3,Contested:4,Takeover:5,Abandoned:6,Unclaimed:7},w="AIzaSyDP4SIjKaw6A4c-zvfYxICpbEjn1rRnN50",T=3,g={Reset:1,Pause:2},k={FFA:0,Team:1,Spatula:2,KOTC:3},C={Locked:1,NoTeamChange:2,NoTeamShuffle:4},h=13,M=[r,n,o,i,l,a,t],e=typeof window<"u",f={Hat:1,Stamp:2,Primary:3,Secondary:4,Grenade:6,Melee:7},y={Forward:1,Backward:2,Left:4,Right:8,Jump:16,Fire:32,Melee:64,Scope:128},G={JoinPublic:0,CreatePrivate:1,JoinPrivate:2},v=!e&&typeof Bun>"u",B={HardBoiled:1,EggBreaker:2,Restock:4,OverHeal:8,DoubleEggs:16,MiniEgg:32},F={Facebook:0,Instagram:1,Tiktok:2,Discord:3,Youtube:4,Twitter:5,Twitch:6},K={Discord:"rew_1200",Tiktok:"rew_1208",Instagram:"rew_1219",Steam:"rew_1223",Facebook:"rew_1227",Twitter:"rew_1234",Twitch:"rew_twitch_social"},R=256,b={Blue:1,Red:2},I=["giveBasketBrosReward","mercZoneFinalGift","midMonthGiveMeEggs","newYolkerSignupReward","newYolkerItemReward","newYolkerWelcomeBack","WelcomeBack"],P=e?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";export{s as BanDuration,p as ChallengeSubType,m as ChallengeType,d as ChatFlag,u as ChiknWinnerDailyLimit,x as CollectType,S as CoopState,w as FirebaseKey,T as FramesBetweenSyncs,g as GameAction,k as GameMode,C as GameOptionFlag,h as GunEquipTime,M as GunList,e as IsBrowser,f as ItemType,y as Movement,G as PlayType,v as ProxiesEnabled,B as ShellStreak,F as SocialMedia,K as SocialReward,R as StateBufferSize,b as Team,I as URLRewards,P as UserAgent,W as findItemById};
3
+ import{AUG as t,CSG1 as o,DozenGauge as n,Eggk47 as r,M24 as a,RPEGG as i,SMG as l}from"./guns.js";import{findItemById as D}from"./findItemById.js";const s={FiveMinutes:0,FifteenMinutes:1,OneHour:2},p={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},m={Kill:0,Damage:1,Death:2,Movement:3,Collect:4,Time:5,KOTC:6,Spatula:7},d={None:0,Pinned:2,Team:4,Mod:254,Server:255},u=3,S={Ammo:0,Grenade:1},x={Start:0,Score:1,Win:2,Capturing:3,Contested:4,Takeover:5,Abandoned:6,Unclaimed:7},w="AIzaSyDP4SIjKaw6A4c-zvfYxICpbEjn1rRnN50",T=3,g={Reset:1,Pause:2},k={FFA:0,Team:1,Spatula:2,KOTC:3},f={Locked:1,NoTeamChange:2,NoTeamShuffle:4},C=13,h=[r,n,o,i,l,a,t],e=typeof window<"u"||typeof WebSocketPair<"u",M={Hat:1,Stamp:2,Primary:3,Secondary:4,Grenade:6,Melee:7},y={Forward:1,Backward:2,Left:4,Right:8,Jump:16,Fire:32,Melee:64,Scope:128},G={JoinPublic:0,CreatePrivate:1,JoinPrivate:2},v=!e&&typeof Bun>"u",B={HardBoiled:1,EggBreaker:2,Restock:4,OverHeal:8,DoubleEggs:16,MiniEgg:32},F={Facebook:0,Instagram:1,Tiktok:2,Discord:3,Youtube:4,Twitter:5,Twitch:6},K={Discord:"rew_1200",Tiktok:"rew_1208",Instagram:"rew_1219",Steam:"rew_1223",Facebook:"rew_1227",Twitter:"rew_1234",Twitch:"rew_twitch_social"},b=256,P={Blue:1,Red:2},R=["giveBasketBrosReward","mercZoneFinalGift","midMonthGiveMeEggs","newYolkerSignupReward","newYolkerItemReward","newYolkerWelcomeBack","WelcomeBack"],I=e?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";export{s as BanDuration,p as ChallengeSubType,m as ChallengeType,d as ChatFlag,u as ChiknWinnerDailyLimit,S as CollectType,x as CoopState,w as FirebaseKey,T as FramesBetweenSyncs,g as GameAction,k as GameMode,f as GameOptionFlag,C as GunEquipTime,h as GunList,e as IsBrowser,M as ItemType,y as Movement,G as PlayType,v as ProxiesEnabled,B as ShellStreak,F as SocialMedia,K as SocialReward,b as StateBufferSize,P as Team,R as URLRewards,I as UserAgent,D as findItemById};