yolkbot 1.0.6 → 1.0.8

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.
Files changed (37) hide show
  1. package/browser/build/global.js +1 -1
  2. package/browser/build/module.js +1 -1
  3. package/dist/api.js +1 -1
  4. package/dist/bot.js +1 -1
  5. package/dist/comm/CommIn.js +1 -1
  6. package/dist/comm/CommOut.js +1 -1
  7. package/dist/comm/Pool.js +1 -1
  8. package/dist/constants/index.js +1 -1
  9. package/dist/dispatches/BootPlayerDispatch.js +1 -1
  10. package/dist/dispatches/GoToAmmoDispatch.js +1 -1
  11. package/dist/dispatches/GoToCoopDispatch.js +1 -1
  12. package/dist/dispatches/GoToGrenadeDispatch.js +1 -1
  13. package/dist/dispatches/GoToPlayerDispatch.js +1 -1
  14. package/dist/dispatches/GoToSpatulaDispatch.js +1 -1
  15. package/dist/dispatches/LookAtDispatch.js +1 -1
  16. package/dist/dispatches/ReportPlayerDispatch.js +1 -1
  17. package/dist/dispatches/SaveLoadoutDispatch.js +1 -1
  18. package/dist/dispatches/SwitchTeamDispatch.js +1 -1
  19. package/dist/globals.js +1 -1
  20. package/dist/matchmaker.js +1 -1
  21. package/dist/pathing/astar.js +1 -1
  22. package/dist/pathing/binaryheap.js +1 -1
  23. package/dist/pathing/mapnode.js +1 -1
  24. package/dist/types/api.d.ts +26 -5
  25. package/dist/types/bot.d.ts +20 -9
  26. package/dist/types/matchmaker.d.ts +6 -7
  27. package/dist/types/pathing/astar.d.ts +25 -0
  28. package/dist/types/pathing/binaryheap.d.ts +18 -0
  29. package/dist/types/pathing/mapnode.d.ts +44 -0
  30. package/dist/types/wasm/wrapper.d.ts +1 -0
  31. package/dist/util.js +1 -1
  32. package/dist/wasm/bytes.js +1 -1
  33. package/dist/wasm/imports.js +1 -1
  34. package/dist/wasm/utils.js +1 -1
  35. package/dist/wasm/wasm_loader.wasm +0 -0
  36. package/dist/wasm/wrapper.js +1 -1
  37. package/package.json +6 -3
package/dist/api.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- import d from"./globals.js";import y from"./socket.js";import{FirebaseKey as k,UserAgent as g}from"./constants/index.js";const f=async(o,r="",i="wss://shellshock.io")=>{let e;const s=async()=>{try{e=new y(`${i}/services/`,r),e.onerror=async t=>(console.error(t),await new Promise(n=>setTimeout(n,100)),await s())}catch{await new Promise(t=>setTimeout(t,100)),await s()}};return await s(),new Promise(t=>{e.onopen=()=>{e.onerror=null,e.send(JSON.stringify(o))};let n=!1;e.onmessage=c=>{n=!0;try{const a=JSON.parse(c.data);t(a)}catch{console.error("queryServices: Bad API JSON response with call: "+o.cmd+" and data:",JSON.stringify(o)),console.error("queryServices: Full data sent: ",JSON.stringify(o)),t("bad_json")}e.close()},e.onerror=()=>!n&&t("unknown_socket_error"),e.onclose=()=>!n&&t("services_closed_early")})};async function _(o,r,i="",e="wss://shellshock.io"){return await p(o,r,i,e,!0)}async function p(o,r,i="",e="wss://shellshock.io",s){if(!o||!r)return"firebase_no_credentials";const t=s?"signUp":"signInWithPassword";let n=!1,c,a,u,l=0;for(;!n;)try{c=await d.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:${t}?key=${k}`,{method:"POST",body:JSON.stringify({email:o,password:r,returnSecureToken:!0}),headers:{"content-type":"application/json",origin:"https://shellshock.io","user-agent":g,"x-client-version":"Chrome/JsCore/9.17.2/FirebaseCore-web","x-firebase-locale":"en"},dispatcher:i?new d.ProxyAgent(i.replace(/socks([4|5|4a|5h]+)/g,"https")):void 0}),a=await c.json(),u=a.idToken,n=!0}catch(h){if(++l,h.code=="auth/network-request-failed")console.error("loginWithCredentials: Network req failed (auth/network-request-failed), retrying, k =",l);else{if(h.code=="auth/missing-email")return"firebase_no_credentials";h.code=="ERR_BAD_REQUEST"?(console.error("loginWithCredentials: Error:",o,r),console.error("loginWithCredentials: Error:",h.response?.data||h,"k =",l)):(console.error("loginWithCredentials: Error:",o,r),console.error("loginWithCredentials: Error:",h,"k =",l))}if(l>5)return"firebase_too_many_retries";await new Promise(m=>setTimeout(m,100))}return u?await f({cmd:"auth",firebaseToken:u},i,e):(console.error("loginWithCredentials: the game sent no idToken",a),"firebase_no_token")}async function b(o,r="",i="wss://shellshock.io"){if(!o)return"firebase_no_credentials";const e=new URLSearchParams;e.append("grant_type","refresh_token"),e.append("refresh_token",o);let s=!1,t,n,c,a=0;for(;!s;)try{t=await d.fetch(`https://securetoken.googleapis.com/v1/token?key=${k}`,{method:"POST",body:e,headers:{"content-type":"application/x-www-form-urlencoded",origin:"https://shellshock.io","user-agent":g,"x-client-version":"Chrome/JsCore/9.17.2/FirebaseCore-web","x-firebase-locale":"en"},dispatcher:r?new d.ProxyAgent(r.replace(/socks([4|5|4a|5h]+)/g,"https")):void 0}),n=await t.json(),c=n.id_token,s=!0}catch(l){if(++a,l.code=="auth/network-request-failed")console.error("loginWithRefreshToken: Network req failed (auth/network-request-failed), retrying, k =",a);else{if(l.code=="auth/missing-email")return"firebase_no_credentials";console.error("loginWithRefreshToken: Error:",o),console.error("loginWithRefreshToken: Error:",l,"k =",a)}if(a>5)return"firebase_too_many_retries";await new Promise(w=>setTimeout(w,100))}return c?await f({cmd:"auth",firebaseToken:c},r,i):(console.error("loginWithRefreshToken: the game sent no idToken",n),"firebase_no_token")}async function S(o="",r="wss://shellshock.io"){const e=await(await d.fetch("https://identitytoolkit.googleapis.com/v1/accounts:signUp?key="+k,{method:"POST",body:JSON.stringify({returnSecureToken:!0}),headers:{"content-type":"application/json",origin:"https://shellshock.io","user-agent":g,"x-client-version":"Chrome/JsCore/9.17.2/FirebaseCore-web","x-firebase-locale":"en"},dispatcher:o?new d.ProxyAgent(o.replace(/socks([4|5|4a|5h]+)/g,"https")):void 0})).json(),s=e.idToken;return s?await f({cmd:"auth",firebaseToken:s},o,r):(console.error("loginAnonymously: the game sent no idToken",e),"firebase_no_token")}export{_ as createAccount,S as loginAnonymously,p as loginWithCredentials,b as loginWithRefreshToken,f as queryServices};
3
+ import i from"./globals.js";import d from"./socket.js";import{FirebaseKey as a,UserAgent as u}from"./constants/index.js";const c={origin:"https://shellshock.io","user-agent":u,"x-client-version":"Chrome/JsCore/9.17.2/FirebaseCore-web","x-firebase-locale":"en"};class y{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://")||"",this.socksProxy=e.proxy,this.maxRetries=e.maxRetries||5}queryServices=async e=>{let t,n=0;const s=async()=>{try{t=new d(`${this.protocol}://${this.instance}/services/`,this.socksProxy),t.onerror=async o=>(n++,console.error(o),await new Promise(r=>setTimeout(r,100)),await s())}catch{if(n>this.maxRetries)return"max_retries_exceeded";await new Promise(o=>setTimeout(o,100)),await s()}};return await s(),new Promise(o=>{t.onopen=()=>{t.onerror=null,t.send(JSON.stringify(e))};let r=!1;t.onmessage=l=>{r=!0;try{const h=JSON.parse(l.data);o(h)}catch{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)),o("bad_json")}t.close()},t.onerror=()=>!r&&o("unknown_socket_error"),t.onclose=()=>!r&&o("services_closed_early")})};#e=async(e,t,n)=>{if(!e||!t)return"firebase_no_credentials";let s,o;try{s=await(await i.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:${n}?key=${a}`,{method:"POST",body:JSON.stringify({email:e,password:t,returnSecureToken:!0}),headers:{...c,"content-type":"application/json"},dispatcher:this.httpProxy?new i.ProxyAgent(this.httpProxy):void 0})).json(),o=s.idToken}catch(r){return r.code==="auth/network-request-failed"?(console.error("loginWithCredentials: Network req failed (auth/network-request-failed)"),"firebase_network_failed"):r.code==="auth/missing-email"?"firebase_no_credentials":r.code==="ERR_BAD_REQUEST"?(console.error("loginWithCredentials: Error:",e,t),console.error("loginWithCredentials: Error:",r.response?.data||r),"firebase_bad_request"):(console.error("loginWithCredentials: Error:",e,t,r),"firebase_unknown_error")}return o?await this.queryServices({cmd:"auth",firebaseToken:o}):(console.error("loginWithCredentials: the game sent no idToken",s),"firebase_no_token")};createAccount=async(e,t)=>await this.#e(e,t,"signUp");loginWithCredentials=async(e,t)=>await this.#e(e,t,"signInWithPassword");loginWithRefreshToken=async e=>{if(!e)return"firebase_no_credentials";const t=new URLSearchParams;t.append("grant_type","refresh_token"),t.append("refresh_token",e);let n,s;try{n=await(await i.fetch(`https://securetoken.googleapis.com/v1/token?key=${a}`,{method:"POST",body:t,headers:{...c,"content-type":"application/x-www-form-urlencoded"},dispatcher:this.httpProxy?new i.ProxyAgent(this.httpProxy):void 0})).json(),s=n.id_token}catch(r){return r.code==="auth/network-request-failed"?(console.error("loginWithRefreshToken: Network req failed (auth/network-request-failed)"),"firebase_network_failed"):r.code==="auth/missing-email"?"firebase_no_credentials":(console.error("loginWithRefreshToken: Error:",r,e),"firebase_unknown_error")}return s?await this.queryServices({cmd:"auth",firebaseToken:s}):(console.error("loginWithRefreshToken: the game sent no idToken",n),"firebase_no_token")};loginAnonymously=async()=>{const t=await(await i.fetch("https://identitytoolkit.googleapis.com/v1/accounts:signUp?key="+a,{method:"POST",body:JSON.stringify({returnSecureToken:!0}),headers:{...c,"content-type":"application/json"},dispatcher:this.httpProxy?new i.ProxyAgent(this.httpProxy):void 0})).json(),n=t.idToken;return n?await this.queryServices({cmd:"auth",firebaseToken:n}):(console.error("loginAnonymously: the game sent no idToken",t),"firebase_no_token")}}var w=y;export{y as API,w as default};
package/dist/bot.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- import{createAccount as z,loginAnonymously as H,loginWithCredentials as W,loginWithRefreshToken as j,queryServices as g}from"./api.js";import s from"./comm/CommIn.js";import f from"./comm/CommOut.js";import{CloseCode as K}from"./comm/Codes.js";import{CommCode as c}from"./constants/codes.js";import U from"./bot/GamePlayer.js";import q from"./matchmaker.js";import Y from"./socket.js";import{ChiknWinnerDailyLimit as Z,CollectTypes as T,CoopStates as y,findItemById as d,FramesBetweenSyncs as w,GameActions as E,GameModes as u,GameOptionFlags as G,GunList as X,ItemTypes as V,Movements as F,PlayTypes as J,ProxiesEnabled as Q,ShellStreaks as m,StateBufferSize as b}from"./constants/index.js";import M from"./dispatches/LookAtPosDispatch.js";import R from"./dispatches/MovementDispatch.js";import{NodeList as tt}from"./pathing/mapnode.js";import{fetchMap as et,initKotcZones as st}from"./util.js";import{Challenges as at}from"./constants/challenges.js";import{Maps as S}from"./constants/maps.js";const A=Object.fromEntries(Object.entries(y).map(([P,t])=>[t,P])),B=Object.fromEntries(Object.entries(u).map(([P,t])=>[t,P])),O={CHALLENGES:1,STATS:2,PATHFINDING:3,PING:5,COSMETIC_DATA:6,PLAYER_HEALTH:7,PACKET_HOOK:8,LOG_PACKETS:10,NO_LOGIN:11,DEBUG_BUFFER:12,DEBUG_BEST_TARGET:14},x=(P,t)=>(P%t+t)%t;class it{static Intents=O;Intents=O;#e=[];#t={};#i=[];#n;#o;constructor(t={}){if(t.proxy&&!Q)throw new Error("proxies do not work and hence are not supported in the browser");if(this.intents=t.intents||[],this.intents.includes(this.Intents.COSMETIC_DATA)&&!d(1001))throw new Error("you cannot use the COSMETIC_DATA intent inside of the singlefile browser bundles");this.instance=t.instance||"shellshock.io",this.protocol=t.protocol||"wss",this.proxy=t.proxy||"",this.state={name:"yolkbot",weaponIdx:0,reloading:!1,swappingGun:!1,usingMelee:!1,stateIdx:0,serverStateIdx:0,shotsFired:0,buffer:[],left:!1,quit:!1},this.players={},this.me=new U({}),this.game={raw:{},code:"",socket:null,gameModeId:0,gameMode:B[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:y.capturing,zoneNumber:0,activeZone:[],capturing:0,captureProgress:0,numCapturing:0,stageName:"",capturePercent:0},this.#o=this.game,this.account={id:0,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,accountAge:0,emailVerified:!1,eggBalance:0,rawLoginData:{}},this.#n=this.account,this.matchmaker=null,this.ping=0,this.lastPingTime=-1,this.lastDeathTime=-1,this.lastChatTime=-1,this.lastUpdateTick=0,this.controlKeys=0,this.pathing={nodeList:null,followingPath:!1,activePath:null,activeNode:null,activeNodeIdx:0}}dispatch(t){t.check(this)?t.execute(this):this.#e.push(t)}async createAccount(t,e){this.account.email=t,this.account.password=e;const a=await z(t,e,this.proxy,`${this.protocol}://${this.instance}`);return await this.#s(a)}async login(t,e){this.account.email=t,this.account.password=e;const a=await W(t,e,this.proxy,`${this.protocol}://${this.instance}`);return await this.#s(a)}async loginWithRefreshToken(t){const e=await j(t,this.proxy,`${this.protocol}://${this.instance}`);return await this.#s(e)}async loginAnonymously(){delete this.account.email,delete this.account.password;const t=await H(this.proxy,`${this.protocol}://${this.instance}`);return await this.#s(t)}async#s(t){return typeof t!="object"?(this.emit("authFail",t),!1):t.banRemaining?(this.emit("banned",t.banRemaining),!1):t.playerOutput?(t=t.playerOutput,this.account.rawLoginData=t,this.account.accountAge=t.accountAge,this.account.eggBalance=t.currentBalance,this.account.emailVerified=t.emailVerified,this.account.firebaseId=t.firebaseId,this.account.id=t.id,this.account.loadout=t.loadout,this.account.ownedItemIds=t.ownedItemIds,this.account.session=t.session,this.account.sessionId=t.sessionId,this.account.vip=t.upgradeProductId&&!t.upgradeIsExpired,this.intents.includes(this.Intents.STATS)&&(this.account.stats={lifetime:t.statsLifetime,monthly:t.statsCurrent}),this.intents.includes(this.Intents.CHALLENGES)&&this.#a(t.challenges),this.emit("authSuccess",this.account),this.account):(this.emit("authFail",t),!1)}#a(t){this.account.challenges=[];for(const e of t){const a=at.find(i=>i.id==e.challengeId);a&&(delete e.playerId,this.account.challenges.push({raw:{challengeInfo:a,challengeData:e},id:e.challengeId,name:a.loc.title,desc:a.loc.desc,rewardEggs:a.reward,isRerolled:!!e.reset,isClaimed:!!e.claimed,isCompleted:!!e.completed,progressNum:e.progress,goalNum:a.goal}))}}async initMatchmaker(){return!this.account.sessionId&&!this.intents.includes(this.Intents.NO_LOGIN)&&!await this.loginAnonymously()?!1:(this.matchmaker||(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)}),this.matchmaker.on("authFail",t=>this.emit("authFail",t)),await this.matchmaker.getRegions()),!0)}async#c(t){return await this.initMatchmaker()?await new Promise(e=>{const a=i=>{if(i.command=="gameFound"&&(this.matchmaker.off("msg",a),this.game.raw=i,this.game.code=i.id,e()),i.error&&i.error=="gameNotFound")throw new Error(`Game ${t} not found (likely expired).`)};this.matchmaker.on("msg",a),this.matchmaker.send({command:"joinGame",id:t,observe:!1,sessionId:this.account.sessionId})}):!1}async createPrivateGame(t={}){if(!await this.initMatchmaker())return!1;if(!t.region)throw new Error('pass a region: createPrivateGame({ region: "useast", ... })');if(!this.matchmaker.regionList.find(i=>i.id==t.region))throw new Error('invalid region, see <bot>.matchmaker.regionList for a region list (pass an "id")');if(!t.mode)throw new Error('pass a mode: createPrivateGame({ mode: "ffa", ... })');if(u[t.mode]==null)throw new Error("invalid mode, see GameModes for a list");if(!t.map)throw new Error('pass a map: createPrivateGame({ map: "downfall", ... })');const e=S.find(i=>i.name.toLowerCase()==t.map.toLowerCase()),a=S.indexOf(e);if(a==-1)throw new Error("invalid map, see the Maps constant for a list");return await new Promise(i=>{const n=o=>{o.command=="gameFound"&&(this.matchmaker.off("msg",n),this.game.raw=o,this.game.code=this.game.raw.id,i())};this.matchmaker.on("msg",n),this.matchmaker.send({command:"findGame",region:t.region,playType:J.createPrivate,gameType:u[t.mode],sessionId:this.account.sessionId,noobLobby:!1,map:a})}),this.game.raw}async join(t,e){if(this.state.name=t||"yolkbot",typeof e=="string"?(e.includes("#")&&(e=e.split("#")[1]),await this.#c(e)):typeof e=="object"&&(this.account.id==0&&await this.loginAnonymously(),this.game.raw=e,this.game.code=this.game.raw.id),!this.game.raw.id)throw new Error("invalid game data passed to <bot>.join");const a=async()=>{try{const i=this.instance.startsWith("localhost:")?this.instance:`${this.game.raw.subdomain}.${this.instance}`;this.game.socket=new Y(`${this.protocol}://${i}/game/${this.game.raw.id}`,this.proxy),this.game.socket.onerror=async n=>(console.error(n),await new Promise(o=>setTimeout(o,100)),await a())}catch{await new Promise(i=>setTimeout(i,100)),await a()}};await a(),this.game.socket.binaryType="arraybuffer",this.game.socket.onopen=()=>this.game.socket.onerror=null,this.game.socket.onmessage=i=>this.processPacket(i.data),this.game.socket.onclose=i=>{this.state.left?this.state.left=!1:(this.emit("close",i.code),this.leave(-1))}}#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 R(0));else{let e;this.pathing.activeNodeIdx<this.pathing.activePath.length-1?(e=this.pathing.activePath[this.pathing.activeNodeIdx+1].flatCenter(),this.dispatch(new M(e))):(e=this.pathing.activePath[this.pathing.activeNodeIdx].flatCenter(),this.dispatch(new M(e)));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.controlKeys&F.FORWARD||this.dispatch(new R(F.FORWARD))}}update(){if(!this.state.quit){if(this.pathing.followingPath&&this.intents.includes(this.Intents.PATHFINDING)&&this.#r(),this.#e.length>0)for(let t=0;t<this.#e.length;t++){const e=this.#e[t];e.check(this)&&(e.execute(this),this.#e.splice(t,1))}if(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.state.buffer[t]={controlKeys:this.controlKeys,yaw:this.me.view.yaw,pitch:this.me.view.pitch,shotsFired:this.state.shotsFired},this.state.shotsFired=0,this.lastUpdateTick>=2){this.emit("tick");const e=f.getBuffer();e.packInt8(c.syncMe),e.packInt8(this.state.stateIdx),e.packInt8(this.state.serverStateIdx);const a=x(this.state.stateIdx-w+1,b);for(let i=0;i<w;i++){const n=x(a+i,b);this.intents.includes(this.Intents.DEBUG_BUFFER)&&console.log("going with",this.state.stateIdx,a,n,this.state.buffer[n]),e.packInt8(this.state.buffer[n]?.controlKeys||0),e.packInt8(this.state.buffer[n]?.shotsFired||0),e.packRadU(this.state.buffer[n]?.yaw||this.me.view.yaw),e.packRad(this.state.buffer[n]?.pitch||this.me.view.pitch),e.packInt8(100)}e.send(this.game.socket),this.state.buffer=[],this.lastUpdateTick=0}else this.lastUpdateTick++;this.state.stateIdx=x(this.state.stateIdx+1,b)}if(this.intents.includes(this.Intents.PLAYER_HEALTH))for(const t of Object.values(this.players)){if(t.playing&&t.hp>0){const e=.1*(this.game.isPrivate?this.game.options.healthRegen:1);t.streakRewards.includes(m.OverHeal)?t.hp=Math.max(100,t.hp-e):t.hp=Math.min(100,t.hp+e)}t.spawnShield>0&&(t.spawnShield-=6)}}}on(t,e){Object.keys(this.#t).includes(t)?this.#t[t].push(e):this.#t[t]=[e]}onAny(t){this.#i.push(t)}off(t,e){this.#t[t]=this.#t[t].filter(a=>a!==e)}emit(t,...e){if(!this.state.quit){if(this.#t[t])for(const a of this.#t[t])a(...e);for(const a of this.#i)a(t,...e)}}#h(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=s.unPackString().valueOf(),i=this.players[t];this.emit("chat",i,a,e)}#l(){const t=s.unPackInt8U(),e=this.intents.includes(this.Intents.COSMETIC_DATA),a={id:t,uniqueId:s.unPackString(),name:s.unPackString(),safename:s.unPackString(),charClass:s.unPackInt8U(),team:s.unPackInt8U(),primaryWeaponItem:e?d(s.unPackInt16U()):s.unPackInt16U(),secondaryWeaponItem:e?d(s.unPackInt16U()):s.unPackInt16U(),shellColor:s.unPackInt8U(),hatItem:e?d(s.unPackInt16U()):s.unPackInt16U(),stampItem:e?d(s.unPackInt16U()):s.unPackInt16U(),stampPosX:s.unPackInt8(),stampPosY:s.unPackInt8(),grenadeItem:e?d(s.unPackInt16U()):s.unPackInt16U(),meleeItem:e?d(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(),bestGameStreak: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()};s.unPackInt8U(),s.unPackInt8U(),s.unPackInt8U(),this.players[a.id]||(this.players[a.id]=new U(a)),this.me.id==a.id&&(this.me=this.players[a.id]),this.emit("playerJoin",this.players[a.id])}#m(){const t=s.unPackInt8U(),e=s.unPackInt16U(),a=s.unPackFloat(),i=s.unPackFloat(),n=s.unPackFloat(),o=s.unPackInt8U(),h=s.unPackInt8U(),p=s.unPackInt8U(),I=s.unPackInt8U(),k=s.unPackInt8U(),r=this.players[t];r&&(r.playing=!0,r.randomSeed=e,r.weapons[0]&&r.weapons[0].ammo&&(r.weapons[0].ammo.rounds=o),r.weapons[0]&&r.weapons[0].ammo&&(r.weapons[0].ammo.store=h),r.weapons[1]&&r.weapons[1].ammo&&(r.weapons[1].ammo.rounds=p),r.weapons[1]&&r.weapons[1].ammo&&(r.weapons[1].ammo.store=I),r.grenades=k,r.position={x:a,y:i,z:n},r.spawnShield=120,this.emit("playerRespawn",r))}#d(){const t=s.unPackInt8U(),e=s.unPackFloat(),a=s.unPackFloat(),i=s.unPackFloat(),n=s.unPackInt8U(),o=this.players[t];if(!o||o.id==this.me.id){for(let h=0;h<w;h++)s.unPackInt8U(),s.unPackRadU(),s.unPackRad(),s.unPackInt8U();return}o.position.x!==e&&(o.position.x=e),o.position.z!==i&&(o.position.z=i),(!o.jumping||Math.abs(o.position.y-a)>.5&&o.position.y!==a)&&(o.position.y=a),o.climbing!==n&&(o.climbing=n);for(let h=0;h<w;h++)s.unPackInt8U(),s.unPackRadU(),s.unPackRad(),s.unPackInt8U()}#u(){const t=s.unPackInt8U(),e=this.players[t];e&&(e.playing=!1,this.emit("playerPause",e))}#p(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=this.players[t];a&&(a.activeGun=e,this.emit("playerSwapWeapon",a,e))}#g(){const t=s.unPackInt8U(),e=s.unPackInt8U();s.unPackInt8U(),s.unPackInt8U(),s.unPackInt8U();const a=this.players[t],i=this.players[e];a&&(a.playing=!1,a.streak=0,a.lastDeathTime=Date.now(),a.hp=100,a.spawnShield=0),i&&i.streak++,this.emit("playerDeath",a,i)}#k(){const t=s.unPackInt8U();for(let i=0;i<6;i++)s.unPackFloat();const e=this.players[t];if(!e)return;const a=e.weapons[e.activeGun];a&&a.ammo&&(a.ammo.rounds--,this.emit("playerFire",e,a))}#I(){const t=s.unPackInt16U(),e=s.unPackInt8U(),a=s.unPackFloat(),i=s.unPackFloat(),n=s.unPackFloat();this.game.collectables[e].push({id:t,x:a,y:i,z:n}),this.emit("spawnItem",e,t,{x:a,y:i,z:n})}#f(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=s.unPackInt8U(),i=s.unPackInt16U(),n=this.players[t];if(this.game.collectables[e]=this.game.collectables[e].filter(o=>o.id!=i),e==T.AMMO){const o=n.weapons[a];o&&o.ammo&&(o.ammo.store=Math.min(o.ammo.storeMax,o.ammo.store+o.ammo.pickup),this.emit("collectAmmo",n,o))}e==T.GRENADE&&(n.grenades++,n.grenades>3&&(n.grenades=3),this.emit("collectGrenade",n))}#P(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=this.players[t];if(!a)return;const i=a.hp;a.hp=e,this.emit("playerDamaged",a,i,a.hp)}#y(){const t=s.unPackInt8U();s.unPackFloat(),s.unPackFloat();const e=this.me.hp;this.me.hp=t,this.emit("selfDamaged",e,this.me.hp)}#w(){const t=s.unPackInt8U(),e=this.players[t];s.unPackInt8U();const a=s.unPackInt8U(),i=s.unPackFloat(),n=s.unPackFloat(),o=s.unPackFloat();if(s.unPackInt8U(),s.unPackInt8U(),s.unPackInt8U(),!e)return;this.state.serverStateIdx=a;const h=e.position.x,p=e.position.y,I=e.position.z;e.position.x=i,e.position.y=n,e.position.z=o,(h!=i||p!=n||I!=o)&&this.emit("selfMoved",e,{x:h,y:p,z:I},{x:i,y:n,z:o})}#U(){const t=f.getBuffer();t.packInt8(c.eventModifier),t.send(this.game.socket)}#b(){const t=s.unPackInt8U(),e={...this.players[t]};delete this.players[t.toString()],this.emit("playerLeave",e)}#S(){if(this.game.gameModeId==u.spatula){this.game.teamScore[1]=s.unPackInt16U(),this.game.teamScore[2]=s.unPackInt16U();const t={x:s.unPackFloat(),y:s.unPackFloat(),z:s.unPackFloat()},e=s.unPackInt8U(),a=s.unPackInt8U();this.game.spatula={coords:t,controlledBy:e,controlledByTeam:a},this.emit("gameStateChange",this.game)}else this.game.gameModeId==u.kotc?(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.stageName=A[this.game.stage],this.game.capturePercent=this.game.captureProgress/1e3,this.game.activeZone=this.game.map.zones?this.game.map.zones[this.game.zoneNumber-1]:null,this.emit("gameStateChange",this.game)):this.game.gameModeId==u.team&&(this.game.teamScore[1]=s.unPackInt16U(),this.game.teamScore[2]=s.unPackInt16U());this.game.gameModeId!==u.spatula&&delete this.game.spatula,this.game.gameModeId!==u.kotc&&(delete this.game.stage,delete this.game.zoneNumber,delete this.game.capturing,delete this.game.captureProgress,delete this.game.numCapturing,delete this.game.stageName,delete this.game.numCapturing,delete this.game.activeZone),this.game.gameModeId==u.ffa&&delete this.game.teamScore}#x(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=this.players[t];switch(e){case m.HardBoiled:t===this.me.id&&(this.me.shieldHp=100),a.streakRewards.push(m.HardBoiled);break;case m.EggBreaker:a.streakRewards.push(m.EggBreaker);break;case m.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 m.OverHeal:a.hp=Math.min(200,a.hp+100),a.streakRewards.push(m.OverHeal);break;case m.DoubleEggs:a.streakRewards.push(m.DoubleEggs);break;case m.MiniEgg:a.streakRewards.push(m.MiniEgg);break}this.emit("playerBeginStreak",a,e)}#C(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=this.players[t];[m.EggBreaker,m.OverHeal,m.DoubleEggs,m.MiniEgg].includes(e)&&a.streakRewards.includes(e)&&(a.streakRewards=a.streakRewards.filter(n=>n!=e)),this.emit("playerEndStreak",e,a)}#v(){const t=s.unPackInt8U(),e=s.unPackInt8U();s.unPackFloat(),s.unPackFloat(),this.me.shieldHp=t,this.me.hp=e,this.me.shieldHp<=0?(this.me.streakRewards=this.me.streakRewards.filter(a=>a!=m.HardBoiled),this.emit("selfShieldLost")):this.emit("selfShieldHit",this.me.shieldHp)}#T(){const t={...this.game.options};let e=s.unPackInt8U(),a=s.unPackInt8U(),i=s.unPackInt8U();(e<1||e>4)&&(e=4),(a<0||a>8)&&(a=4),i>16&&(i=4),this.game.options.gravity=e/4,this.game.options.damage=a/4,this.game.options.healthRegen=i/4;const n=s.unPackInt8U();return Object.keys(G).forEach(o=>{const h=n&G[o]?1:0;this.game.options[o]=h}),this.game.options.weaponsDisabled=Array.from({length:7},()=>s.unPackInt8U()===1),this.game.options.mustUseSecondary=this.game.options.weaponsDisabled.every(o=>o),this.emit("gameOptionsChange",t,this.game.options),!1}#E(){const t=s.unPackInt8U();t==E.pause&&(this.emit("gameForcePause"),setTimeout(()=>this.me.playing=!1,3e3)),t==E.reset&&(Object.values(this.players).forEach(e=>e.streak=0),this.game.gameModeId!==u.ffa&&(this.game.teamScore=[0,0,0]),this.game.gameModeId===u.spatula&&(this.game.spatula.controlledBy=0,this.game.spatula.controlledByTeam=0,this.game.spatula.coords={x:0,y:0,z:0}),this.game.gameModeId===u.kotc&&(this.game.stage=y.capturing,this.game.zoneNumber=0,this.game.activeZone=null,this.game.capturing=0,this.game.captureProgress=0,this.game.numCapturing=0,this.game.stageName=A[y.capturing],this.game.capturePercent=0),this.emit("gameReset"))}#G(){if(!this.intents.includes(this.Intents.PING))return;const t=this.ping;this.ping=Date.now()-this.lastPingTime,this.emit("pingUpdate",t,this.ping),setTimeout(()=>{const e=f.getBuffer();e.packInt8(c.ping),e.send(this.game.socket),this.lastPingTime=Date.now()},this.pingInterval)}#F(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=this.players[t];if(!a)return;const i=a.team;a.team=e,a.streak=0,this.emit("playerSwitchTeam",a,i,e)}#M(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=s.unPackInt16U(),i=s.unPackInt16U(),n=s.unPackInt8U(),o=s.unPackInt16U(),h=s.unPackInt16U(),p=s.unPackInt16U(),I=s.unPackInt16U();s.unPackInt8(),s.unPackInt8();const k=this.intents.includes(this.Intents.COSMETIC_DATA),r=k?d(a):a,L=k?d(i):i,N=k?d(o):o,D=k?d(h):h,_=k?d(p):p,$=k?d(I):I,l=this.players[t];if(l){const C={...l.character},v=l.selectedGun;l.character.eggColor=n,l.character.primaryGun=r,l.character.secondaryGun=L,l.character.stamp=D,l.character.hat=N,l.character.grenade=_,l.character.melee=$,l.selectedGun=e,l.weapons[0]=new X[e],v!==l.selectedGun&&this.emit("playerChangeGun",l,v,l.selectedGun),C!==l.character&&this.emit("playerChangeCharacter",l,C,l.character)}}#R(){const t=s.unPackInt32U(),e=this.account.eggBalance;this.account.eggBalance=t,this.emit("balanceUpdate",t-e,t)}#A(){this.me.playing=!1,this.emit("selfRespawnFail")}#B(){const t=s.unPackInt8U(),e=this.players[t];e&&this.emit("playerMelee",e)}#O(){const t=s.unPackInt8U(),e=this.players[t];if(!e)return;const a=e.weapons[e.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",e,a)}#L(){const t=f.getBuffer();t.packInt8(c.gameOptions),t.packInt8(this.game.options.gravity*4),t.packInt8(this.game.options.damage*4),t.packInt8(this.game.options.healthRegen*4);const 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(a=>{t.packInt8(a?1:0)}),t.send(this.game.socket)}#N(){const t=s.unPackInt8U();let e=s.unPackInt16U();const a=s.unPackFloat(),i=s.unPackFloat(),n=s.unPackFloat(),o=s.unPackInt8U(),h=s.unPackFloat();this.intents.includes(this.Intents.COSMETIC_DATA)&&(e=d(e)),t==V.Grenade?this.emit("grenadeExploded",e,{x:a,y:i,z:n},o,h):this.emit("rocketHit",{x:a,y:i,z:n},o,h)}#D(){const t=s.unPackInt8U(),e=s.unPackFloat(),a=s.unPackFloat(),i=s.unPackFloat(),n=s.unPackFloat(),o=s.unPackFloat(),h=s.unPackFloat(),p=this.players[t];p&&(p.grenades--,this.emit("playerThrowGrenade",p,{x:e,y:a,z:i},{x:n,y:o,z:h}))}#_(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=this.players[t];if(!a)return;if(!this.intents.includes(this.Intents.CHALLENGES))return this.emit("challengeComplete",a,e);const i=this.account.challenges.find(n=>n.id==e);this.emit("challengeComplete",a,i),a.id==this.me.id&&this.refreshChallenges()}#$(){const t=f.getBuffer();t.packInt8(c.joinGame),t.packString(this.state.name),t.packString(this.game.raw.uuid),t.packInt8(0),t.packInt8(this.state.weaponIdx||this.account?.loadout?.classIdx||0),t.packInt32(this.account.session),t.packString(this.account.firebaseId),t.packString(this.account.sessionId),t.send(this.game.socket)}async#z(){if(this.me.id=s.unPackInt8U(),this.me.team=s.unPackInt8U(),this.game.gameModeId=s.unPackInt8U(),this.game.gameMode=B[this.game.gameModeId],this.game.mapIdx=s.unPackInt8U(),this.game.map=S[this.game.mapIdx],this.intents.includes(this.Intents.PATHFINDING)&&(this.game.map.raw=await et(this.game.map.filename,this.game.map.hash),this.pathing.nodeList=new tt(this.game.map.raw),this.game.gameModeId===u.kotc)){const e=this.game.map.raw.data["DYNAMIC.capture-zone.none"];e?this.game.map.zones=st(e):delete this.game.map.zones}this.game.playerLimit=s.unPackInt8U(),this.game.isGameOwner=s.unPackInt8U()==1,this.game.isPrivate=s.unPackInt8U()==1,s.unPackInt8U(),this.state.joinedGame=!0,this.lastDeathTime=Date.now();const t=f.getBuffer();if(t.packInt8(c.clientReady),t.send(this.game.socket),this.game.socket.onmessage=e=>this.processPacket(e.data),this.updateIntervalId=setInterval(()=>this.update(),100/3),this.intents.includes(this.Intents.PING)){this.lastPingTime=Date.now();const e=f.getBuffer();e.packInt8(c.ping),e.send(this.game.socket)}this.emit("gameReady")}processPacket(t){s.init(t),this.intents.includes(this.Intents.PACKET_HOOK)&&this.emit("packet",t);let e=0,a=0,i=!1;for(;s.isMoreDataAvailable()&&!i;){const n=s.unPackInt8U();switch(n){case c.syncThem:this.#d();break;case c.fire:this.#k();break;case c.hitThem:this.#P();break;case c.syncMe:this.#w();break;case c.hitMe:this.#y();break;case c.swapWeapon:this.#p();break;case c.collectItem:this.#f();break;case c.respawn:this.#m();break;case c.die:this.#g();break;case c.pause:this.#u();break;case c.chat:this.#h();break;case c.addPlayer:this.#l();break;case c.removePlayer:this.#b();break;case c.eventModifier:this.#U();break;case c.metaGameState:this.#S();break;case c.beginShellStreak:this.#x();break;case c.endShellStreak:this.#C();break;case c.hitMeHardBoiled:this.#v();break;case c.gameOptions:this.#T();break;case c.ping:this.#G();break;case c.switchTeam:this.#F();break;case c.changeCharacter:this.#M();break;case c.reload:this.#O();break;case c.explode:this.#N();break;case c.throwGrenade:this.#D();break;case c.spawnItem:this.#I();break;case c.melee:this.#B();break;case c.updateBalance:this.#R();break;case c.challengeCompleted:this.#_();break;case c.socketReady:this.#$();break;case c.gameJoined:this.#z();break;case c.gameAction:this.#E();break;case c.requestGameOptions:this.#L();break;case c.respawnDenied:this.#A();break;case c.expireUpgrade:case c.clientReady:break;case c.musicInfo:s.unPackLongString();break;default:console.error(`handlePacket: I got but did not handle a: ${Object.keys(c).find(o=>c[o]===n)} ${n}`),e&&console.error(`handlePacket: It may be a result of the ${e} command (${a}).`),i=!0;break}e=Object.keys(c).find(o=>c[o]===n),a=n,this.intents.includes(this.Intents.LOG_PACKETS)&&console.log(`[LOG_PACKETS] Packet ${e}: ${a}`)}}async checkChiknWinner(){const t=await g({cmd:"chicknWinnerReady",id:this.account.id,sessionId:this.account.sessionId});return typeof t=="string"?t:(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*1e3,this.account.cw)}async playChiknWinner(t=!0){if(this.account.cw.atLimit||this.account.cw.limit>Z)return"hit_daily_limit";if(this.account.cw.canPlayAgain>Date.now()&&t)return"on_cooldown";const e=await g({cmd:"incentivizedVideoReward",firebaseId:this.account.firebaseId,id:this.account.id,sessionId:this.account.sessionId,token:null},this.proxy,`${this.protocol}://${this.instance}`);return typeof e=="string"?e:e.error?e.error=="RATELIMITED"||e.error=="RATELMITED"?(await this.checkChiknWinner(),"on_cooldown"):e.error=="SESSION_EXPIRED"?"session_expired":(console.error("Unknown Chikn Winner response",e),"unknown_error"):e.reward?(this.account.eggBalance+=e.reward.eggsGiven,e.reward.itemIds.forEach(a=>this.account.ownedItemIds.push(a)),await this.checkChiknWinner(),e.reward):(console.error("Unknown Chikn Winner response",e),"unknown_error")}async resetChiknWinner(){if(this.account.eggBalance<200)return"not_enough_eggs";if(!this.account.cw.atLimit)return"not_at_limit";const t=await g({cmd:"chwReset",sessionId:this.account.sessionId});return typeof t=="string"?t:t.result!=="SUCCESS"?(console.error("Unknown Chikn Winner reset response",t),"unknown_error"):(this.account.eggBalance-=200,await this.checkChiknWinner(),this.account.cw)}canSee(t){if(!this.intents.includes(this.Intents.PATHFINDING))throw new Error("You must have the PATHFINDING intent to use this method.");return this.pathing.nodeList.hasLineOfSight(this.me.position,t.position)}getBestTarget(t=()=>!0){const a=Object.values(this.players).filter(n=>n?.playing).filter(n=>n.hp>0).filter(n=>n.id!==this.me.id).filter(n=>this.me.team===0||n.team!==this.me.team).filter(n=>!!t(n)).map(n=>({player:n,distance:Math.sqrt(Math.pow(n.position.x-this.me.position.x,2)+Math.pow(n.position.y-this.me.position.y,2)+Math.pow(n.position.z-this.me.position.z,2))})).sort((n,o)=>n.distance-o.distance);if(!a.length)return this.intents.includes(this.Intents.DEBUG_BEST_TARGET)&&console.log("no targets found"),null;const i=a.find(n=>this.canSee(n.player));return this.intents.includes(this.Intents.DEBUG_BEST_TARGET)&&(console.log("detected ",a.length,"targets"),console.log("closest target: ",a[0].player.name),console.log("all targets (ordered): ",a.map(n=>n.player.name)),console.log("found LoS player?",!!i),i&&console.log("closest LoS player: ",i.player.name)),i?{player:i.player,inLoS:!0}:{player:a[0].player,inLoS:!1}}async refreshChallenges(){const t=await g({cmd:"challengeGetDaily",sessionId:this.account.sessionId,playerId:this.account.id},this.proxy,`${this.protocol}://${this.instance}`);return this.#a(t),this.account.challenges}async rerollChallenge(t){const e=await g({cmd:"challengeRerollSlot",sessionId:this.account.sessionId,slotId:t},this.proxy,`${this.protocol}://${this.instance}`);return this.#a(e),this.account.challenges}async claimChallenge(t){const e=await g({cmd:"challengeClaimReward",sessionId:this.account.sessionId,slotId:t},this.proxy,`${this.protocol}://${this.instance}`);return this.#a(e.challenges),e.reward>0&&(this.account.eggBalance+=e.reward),{eggReward:e.reward,updatedChallenges:this.account.challenges}}async refreshBalance(){const t=await g({cmd:"checkBalance",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId},this.proxy,`${this.protocol}://${this.instance}`);return this.account.eggBalance=t.currentBalance,t.currentBalance}async redeemCode(t){const e=await g({cmd:"redeem",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,id:this.account.id,code:t},this.proxy,`${this.protocol}://${this.instance}`);return e.result==="SUCCESS"?(this.account.eggBalance=e.eggs_given,e.item_ids.forEach(a=>this.account.ownedItemIds.push(a)),{result:e,eggsGiven:e.eggs_given,itemIds:e.item_ids}):e}async claimURLReward(t){const e=await g({cmd:"urlRewardParams",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,reward:t},this.proxy,`${this.protocol}://${this.instance}`);return e.result==="SUCCESS"&&(this.account.eggBalance+=e.eggsGiven,e.itemIds.forEach(a=>this.account.ownedItemIds.push(a))),e}async claimSocialReward(t){const e=await g({cmd:"reward",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,rewardTag:t},this.proxy,`${this.protocol}://${this.instance}`);return e.result==="SUCCESS"&&(this.account.eggBalance+=e.eggsGiven,e.itemIds.forEach(a=>this.account.ownedItemIds.push(a))),e}async buyItem(t){const e=await g({cmd:"buy",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,itemId:t,save:!0},this.proxy,`${this.protocol}://${this.instance}`);return e.result==="SUCCESS"&&(this.account.eggBalance=e.currentBalance,this.account.ownedItemIds.push(e.itemId)),e}leave(t=K.mainMenu){this.state.quit||(t>-1&&(this.game?.socket?.close(t),this.state.left=!0,this.emit("leave")),clearInterval(this.updateIntervalId),this.#e=[],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 U({}),this.game=this.#o,this.ping=0,this.lastPingTime=-1,this.lastDeathTime=-1,this.lastChatTime=-1,this.lastUpdateTick=0,this.controlKeys=0,this.pathing={nodeList:null,followingPath:!1,activePath:null,activeNode:null,activeNodeIdx:0})}logout(){this.account=this.#n}quit(t=!1){this.state.quit||(this.leave(),this.matchmaker&&(this.matchmaker.close(),this.matchmaker=null),t||(delete this.account,delete this.game,delete this.me,delete this.players),this.state.quit=!0,this.emit("quit"))}}var yt=it;export{it as Bot,yt as default};
3
+ import H from"./api.js";import s from"./comm/CommIn.js";import I from"./comm/CommOut.js";import{CloseCode as z}from"./comm/Codes.js";import{CommCode as c}from"./constants/codes.js";import U from"./bot/GamePlayer.js";import W from"./matchmaker.js";import q from"./socket.js";import{ChiknWinnerDailyLimit as j,CollectTypes as x,CoopStates as y,findItemById as u,FramesBetweenSyncs as w,GameActions as T,GameModes as d,GameOptionFlags as E,GunList as K,ItemTypes as $,Movements as G,PlayTypes as Y,ProxiesEnabled as Z,ShellStreaks as m,StateBufferSize as b}from"./constants/index.js";import R from"./dispatches/LookAtPosDispatch.js";import M from"./dispatches/MovementDispatch.js";import{NodeList as X}from"./pathing/mapnode.js";import{fetchMap as V,initKotcZones as J}from"./util.js";import{Challenges as Q}from"./constants/challenges.js";import{Maps as P}from"./constants/maps.js";const F=Object.fromEntries(Object.entries(y).map(([f,t])=>[t,f])),A=Object.fromEntries(Object.entries(d).map(([f,t])=>[t,f])),B={CHALLENGES:1,STATS:2,PATHFINDING:3,PING:5,COSMETIC_DATA:6,PLAYER_HEALTH:7,PACKET_HOOK:8,LOG_PACKETS:10,NO_LOGIN:11,DEBUG_BUFFER:12,DEBUG_BEST_TARGET:14},S=(f,t)=>(f%t+t)%t;class tt{static Intents=B;Intents=B;#e=[];#t={};#i=[];#n;#o;constructor(t={}){t.proxy&&!Z&&this.processError("proxies do not work and hence are not supported in the browser"),this.intents=t.intents||[],this.intents.includes(this.Intents.COSMETIC_DATA)&&(u(1001)||this.processError("you cannot use the COSMETIC_DATA intent inside of the singlefile browser bundles")),this.instance=t.instance||"shellshock.io",this.protocol=t.protocol||"wss",this.proxy=t.proxy||"",this.httpProxy=t.httpProxy||"",this.state={name:"yolkbot",weaponIdx:0,reloading:!1,swappingGun:!1,usingMelee:!1,stateIdx:0,serverStateIdx:0,shotsFired:0,buffer:[],left:!1,quit:!1},this.players={},this.me=new U({}),this.game={raw:{},code:"",socket:null,gameModeId:0,gameMode:A[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:y.capturing,zoneNumber:0,activeZone:[],capturing:0,captureProgress:0,numCapturing:0,stageName:"",capturePercent:0},this.#o=this.game,this.account={id:0,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,accountAge:0,emailVerified:!1,eggBalance:0,rawLoginData:{}},this.#n=this.account,this.matchmaker=null,this.api=new H({instance:this.instance,protocol:this.protocol,proxy:this.proxy,httpProxy:this.httpProxy,maxRetries:t?.apiMaxRetries}),this.ping=0,this.lastPingTime=-1,this.lastDeathTime=-1,this.lastChatTime=-1,this.lastUpdateTick=0,this.controlKeys=0,this.pathing={nodeList:null,followingPath:!1,activePath:null,activeNode:null,activeNodeIdx:0}}dispatch(t){t.check(this)?t.execute(this):this.#e.push(t)}async createAccount(t,e){this.account.email=t,this.account.password=e;const a=await this.api.createAccount(t,e);return this.#s(a)}async login(t,e){this.account.email=t,this.account.password=e;const a=await this.api.loginWithCredentials(t,e);return this.#s(a)}async loginWithRefreshToken(t){const e=await this.api.loginWithRefreshToken(t);return this.#s(e)}async loginAnonymously(){delete this.account.email,delete this.account.password;const t=await this.api.loginAnonymously();return this.#s(t)}#s(t){return typeof t!="object"?(this.emit("authFail",t),!1):t.banRemaining?(this.emit("banned",t.banRemaining),!1):t.playerOutput?(t=t.playerOutput,this.account.rawLoginData=t,this.account.accountAge=t.accountAge,this.account.eggBalance=t.currentBalance,this.account.emailVerified=t.emailVerified,this.account.firebaseId=t.firebaseId,this.account.id=t.id,this.account.loadout=t.loadout,this.account.ownedItemIds=t.ownedItemIds,this.account.session=t.session,this.account.sessionId=t.sessionId,this.account.vip=t.upgradeProductId&&!t.upgradeIsExpired,this.intents.includes(this.Intents.STATS)&&(this.account.stats={lifetime:t.statsLifetime,monthly:t.statsCurrent}),this.intents.includes(this.Intents.CHALLENGES)&&this.#a(t.challenges),this.emit("authSuccess",this.account),this.account):(this.emit("authFail",t),!1)}#a(t){this.account.challenges=[];for(const e of t){const a=Q.find(i=>i.id===e.challengeId);a&&(delete e.playerId,this.account.challenges.push({raw:{challengeInfo:a,challengeData:e},id:e.challengeId,name:a.loc.title,desc:a.loc.desc,rewardEggs:a.reward,isRerolled:!!e.reset,isClaimed:!!e.claimed,isCompleted:!!e.completed,progressNum:e.progress,goalNum:a.goal}))}}async initMatchmaker(){return!this.account.sessionId&&!this.intents.includes(this.Intents.NO_LOGIN)&&!await this.loginAnonymously()?!1:(this.matchmaker||(this.matchmaker=new W({sessionId:this.account.sessionId,proxy:this.proxy,instance:this.instance,protocol:this.protocol,noLogin:this.intents.includes(this.Intents.NO_LOGIN),api:this.api}),this.matchmaker.on("authFail",t=>this.emit("authFail",t)),this.matchmaker.on("error",t=>this.processError(t)),await this.matchmaker.getRegions()),!0)}async#c(t){return await this.initMatchmaker()?await new Promise(e=>{const a=i=>{i.command==="gameFound"&&(this.matchmaker.off("msg",a),this.game.raw=i,this.game.code=i.id,e()),i.error&&i.error==="gameNotFound"&&(this.processError(`Game ${t} not found (likely expired).`),this.leave())};this.matchmaker.on("msg",a),this.matchmaker.send({command:"joinGame",id:t,observe:!1,sessionId:this.account.sessionId})}):!1}async createPrivateGame(t={}){if(!await this.initMatchmaker())return!1;if(!t.region&&!this.matchmaker.regionList)return this.processError("pass a region to createPrivateGame or call getRegions() for a random one");if(t.region||(t.region=this.matchmaker.getRandomRegion()),!t.mode)return this.processError("pass a mode to createPrivateGame");if(!d[t.mode])return this.processError("invalid mode passed to createPrivateGame, see GameModes for a list");t.map||(t.map=P[P.length*Math.random()|0].name);const e=P.find(i=>i.name.toLowerCase()===t.map.toLowerCase()),a=P.indexOf(e);return a===-1?this.processError("invalid map, see the Maps constant for a list"):(await new Promise(i=>{const n=o=>{o.command==="gameFound"&&(this.matchmaker.off("msg",n),this.game.raw=o,this.game.code=this.game.raw.id,i())};this.matchmaker.on("msg",n),this.matchmaker.send({command:"findGame",region:t.region,playType:Y.createPrivate,gameType:d[t.mode],sessionId:this.account.sessionId,noobLobby:!1,map:a})}),this.game.raw)}async join(t,e){if(this.state.name=t||"yolkbot",typeof e=="string"?(e.includes("#")&&(e=e.split("#")[1]),await this.#c(e)):typeof e=="object"&&(this.account.id===0&&await this.loginAnonymously(),this.game.raw=e,this.game.code=this.game.raw.id),!this.game.raw.id)return this.processError("invalid game data passed to <bot>.join");const a=async()=>{try{const i=this.instance.startsWith("localhost:")?this.instance:`${this.game.raw.subdomain}.${this.instance}`;this.game.socket=new q(`${this.protocol}://${i}/game/${this.game.raw.id}`,this.proxy),this.game.socket.onerror=async n=>(this.processError(n),await new Promise(o=>setTimeout(o,100)),await a())}catch{await new Promise(i=>setTimeout(i,100)),await a()}};await a(),this.game.socket.binaryType="arraybuffer",this.game.socket.onopen=()=>this.game.socket.onerror=null,this.game.socket.onmessage=i=>this.processPacket(i.data),this.game.socket.onclose=i=>{this.state.left?this.state.left=!1:(this.emit("close",i.code),this.leave(-1))}}#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 M(0));else{let e;this.pathing.activeNodeIdx<this.pathing.activePath.length-1?(e=this.pathing.activePath[this.pathing.activeNodeIdx+1].flatCenter(),this.dispatch(new R(e))):(e=this.pathing.activePath[this.pathing.activeNodeIdx].flatCenter(),this.dispatch(new R(e)));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.controlKeys&G.FORWARD||this.dispatch(new M(G.FORWARD))}}update(){if(!this.state.quit){if(this.pathing.followingPath&&this.intents.includes(this.Intents.PATHFINDING)&&this.#r(),this.#e.length>0)for(let t=0;t<this.#e.length;t++){const e=this.#e[t];e.check(this)&&(e.execute(this),this.#e.splice(t,1))}if(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.state.buffer[t]={controlKeys:this.controlKeys,yaw:this.me.view.yaw,pitch:this.me.view.pitch,shotsFired:this.state.shotsFired},this.state.shotsFired=0,this.lastUpdateTick>=2){this.emit("tick");const e=I.getBuffer();e.packInt8(c.syncMe),e.packInt8(this.state.stateIdx),e.packInt8(this.state.serverStateIdx);const a=S(this.state.stateIdx-w+1,b);for(let i=0;i<w;i++){const n=S(a+i,b);this.intents.includes(this.Intents.DEBUG_BUFFER)&&console.log("going with",this.state.stateIdx,a,n,this.state.buffer[n]),e.packInt8(this.state.buffer[n]?.controlKeys||0),e.packInt8(this.state.buffer[n]?.shotsFired||0),e.packRadU(this.state.buffer[n]?.yaw||this.me.view.yaw),e.packRad(this.state.buffer[n]?.pitch||this.me.view.pitch),e.packInt8(100)}e.send(this.game.socket),this.state.buffer=[],this.lastUpdateTick=0}else this.lastUpdateTick++;this.state.stateIdx=S(this.state.stateIdx+1,b)}if(this.intents.includes(this.Intents.PLAYER_HEALTH))for(const t of Object.values(this.players)){if(t.playing&&t.hp>0){const e=.1*(this.game.isPrivate?this.game.options.healthRegen:1);t.streakRewards.includes(m.OverHeal)?t.hp=Math.max(100,t.hp-e):t.hp=Math.min(100,t.hp+e)}t.spawnShield>0&&(t.spawnShield-=6)}}}on(t,e){Object.keys(this.#t).includes(t)?this.#t[t].push(e):this.#t[t]=[e]}onAny(t){this.#i.push(t)}off(t,e){this.#t[t]=this.#t[t].filter(a=>a!==e)}emit(t,...e){if(!this.state.quit){if(this.#t[t])for(const a of this.#t[t])a(...e);for(const a of this.#i)a(t,...e)}}#h(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=s.unPackString().valueOf(),i=this.players[t];this.emit("chat",i,a,e)}#l(){const t=s.unPackInt8U(),e=this.intents.includes(this.Intents.COSMETIC_DATA),a={id:t,uniqueId:s.unPackString(),name:s.unPackString(),safename:s.unPackString(),charClass:s.unPackInt8U(),team:s.unPackInt8U(),primaryWeaponItem:e?u(s.unPackInt16U()):s.unPackInt16U(),secondaryWeaponItem:e?u(s.unPackInt16U()):s.unPackInt16U(),shellColor:s.unPackInt8U(),hatItem:e?u(s.unPackInt16U()):s.unPackInt16U(),stampItem:e?u(s.unPackInt16U()):s.unPackInt16U(),stampPosX:s.unPackInt8(),stampPosY:s.unPackInt8(),grenadeItem:e?u(s.unPackInt16U()):s.unPackInt16U(),meleeItem:e?u(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(),bestGameStreak: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()};s.unPackInt8U(),s.unPackInt8U(),s.unPackInt8U(),this.players[a.id]||(this.players[a.id]=new U(a)),this.me.id===a.id&&(this.me=this.players[a.id]),this.emit("playerJoin",this.players[a.id])}#m(){const t=s.unPackInt8U(),e=s.unPackInt16U(),a=s.unPackFloat(),i=s.unPackFloat(),n=s.unPackFloat(),o=s.unPackInt8U(),h=s.unPackInt8U(),p=s.unPackInt8U(),k=s.unPackInt8U(),g=s.unPackInt8U(),r=this.players[t];r&&(r.playing=!0,r.randomSeed=e,r.weapons[0]&&r.weapons[0].ammo&&(r.weapons[0].ammo.rounds=o),r.weapons[0]&&r.weapons[0].ammo&&(r.weapons[0].ammo.store=h),r.weapons[1]&&r.weapons[1].ammo&&(r.weapons[1].ammo.rounds=p),r.weapons[1]&&r.weapons[1].ammo&&(r.weapons[1].ammo.store=k),r.grenades=g,r.position={x:a,y:i,z:n},r.spawnShield=120,this.emit("playerRespawn",r))}#u(){const t=s.unPackInt8U(),e=s.unPackFloat(),a=s.unPackFloat(),i=s.unPackFloat(),n=s.unPackInt8U(),o=this.players[t];if(!o||o.id===this.me.id){for(let h=0;h<w;h++)s.unPackInt8U(),s.unPackRadU(),s.unPackRad(),s.unPackInt8U();return}o.position.x!==e&&(o.position.x=e),o.position.z!==i&&(o.position.z=i),(!o.jumping||Math.abs(o.position.y-a)>.5&&o.position.y!==a)&&(o.position.y=a),o.climbing!==n&&(o.climbing=n);for(let h=0;h<w;h++)s.unPackInt8U(),s.unPackRadU(),s.unPackRad(),s.unPackInt8U()}#d(){const t=s.unPackInt8U(),e=this.players[t];e&&(e.playing=!1,this.emit("playerPause",e))}#p(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=this.players[t];a&&(a.activeGun=e,this.emit("playerSwapWeapon",a,e))}#g(){const t=s.unPackInt8U(),e=s.unPackInt8U();s.unPackInt8U(),s.unPackInt8U(),s.unPackInt8U();const a=this.players[t],i=this.players[e];a&&(a.playing=!1,a.streak=0,a.lastDeathTime=Date.now(),a.hp=100,a.spawnShield=0),i&&i.streak++,this.emit("playerDeath",a,i)}#k(){const t=s.unPackInt8U();for(let i=0;i<6;i++)s.unPackFloat();const e=this.players[t];if(!e)return;const a=e.weapons[e.activeGun];a&&a.ammo&&(a.ammo.rounds--,this.emit("playerFire",e,a))}#I(){const t=s.unPackInt16U(),e=s.unPackInt8U(),a=s.unPackFloat(),i=s.unPackFloat(),n=s.unPackFloat();this.game.collectables[e].push({id:t,x:a,y:i,z:n}),this.emit("spawnItem",e,t,{x:a,y:i,z:n})}#f(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=s.unPackInt8U(),i=s.unPackInt16U(),n=this.players[t];if(this.game.collectables[e]=this.game.collectables[e].filter(o=>o.id!==i),e===x.AMMO){const o=n.weapons[a];o&&o.ammo&&(o.ammo.store=Math.min(o.ammo.storeMax,o.ammo.store+o.ammo.pickup),this.emit("collectAmmo",n,o))}e===x.GRENADE&&(n.grenades++,n.grenades>3&&(n.grenades=3),this.emit("collectGrenade",n))}#P(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=this.players[t];if(!a)return;const i=a.hp;a.hp=e,this.emit("playerDamaged",a,i,a.hp)}#y(){const t=s.unPackInt8U();s.unPackFloat(),s.unPackFloat();const e=this.me.hp;this.me.hp=t,this.emit("selfDamaged",e,this.me.hp)}#w(){const t=s.unPackInt8U(),e=this.players[t];s.unPackInt8U();const a=s.unPackInt8U(),i=s.unPackFloat(),n=s.unPackFloat(),o=s.unPackFloat();if(s.unPackInt8U(),s.unPackInt8U(),s.unPackInt8U(),!e)return;this.state.serverStateIdx=a;const h=e.position.x,p=e.position.y,k=e.position.z;e.position.x=i,e.position.y=n,e.position.z=o,(h!==i||p!==n||k!==o)&&this.emit("selfMoved",e,{x:h,y:p,z:k},{x:i,y:n,z:o})}#U(){const t=I.getBuffer();t.packInt8(c.eventModifier),t.send(this.game.socket)}#b(){const t=s.unPackInt8U(),e={...this.players[t]};delete this.players[t.toString()],this.emit("playerLeave",e)}#S(){if(this.game.gameModeId===d.spatula){this.game.teamScore[1]=s.unPackInt16U(),this.game.teamScore[2]=s.unPackInt16U();const t={x:s.unPackFloat(),y:s.unPackFloat(),z:s.unPackFloat()},e=s.unPackInt8U(),a=s.unPackInt8U();this.game.spatula={coords:t,controlledBy:e,controlledByTeam:a},this.emit("gameStateChange",this.game)}else this.game.gameModeId===d.kotc?(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.stageName=F[this.game.stage],this.game.capturePercent=this.game.captureProgress/1e3,this.game.activeZone=this.game.map.zones?this.game.map.zones[this.game.zoneNumber-1]:null,this.emit("gameStateChange",this.game)):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.stageName,delete this.game.numCapturing,delete this.game.activeZone),this.game.gameModeId===d.ffa&&delete this.game.teamScore}#v(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=this.players[t];switch(e){case m.HardBoiled:t===this.me.id&&(this.me.shieldHp=100),a.streakRewards.push(m.HardBoiled);break;case m.EggBreaker:a.streakRewards.push(m.EggBreaker);break;case m.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 m.OverHeal:a.hp=Math.min(200,a.hp+100),a.streakRewards.push(m.OverHeal);break;case m.DoubleEggs:a.streakRewards.push(m.DoubleEggs);break;case m.MiniEgg:a.streakRewards.push(m.MiniEgg);break}this.emit("playerBeginStreak",a,e)}#C(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=this.players[t];[m.EggBreaker,m.OverHeal,m.DoubleEggs,m.MiniEgg].includes(e)&&a.streakRewards.includes(e)&&(a.streakRewards=a.streakRewards.filter(n=>n!==e)),this.emit("playerEndStreak",e,a)}#x(){const t=s.unPackInt8U(),e=s.unPackInt8U();s.unPackFloat(),s.unPackFloat(),this.me.shieldHp=t,this.me.hp=e,this.me.shieldHp<=0?(this.me.streakRewards=this.me.streakRewards.filter(a=>a!==m.HardBoiled),this.emit("selfShieldLost")):this.emit("selfShieldHit",this.me.shieldHp)}#T(){const t={...this.game.options};let e=s.unPackInt8U(),a=s.unPackInt8U(),i=s.unPackInt8U();(e<1||e>4)&&(e=4),(a<0||a>8)&&(a=4),i>16&&(i=4),this.game.options.gravity=e/4,this.game.options.damage=a/4,this.game.options.healthRegen=i/4;const n=s.unPackInt8U();return Object.keys(E).forEach(o=>{const h=n&E[o]?1:0;this.game.options[o]=h}),this.game.options.weaponsDisabled=Array.from({length:7},()=>s.unPackInt8U()===1),this.game.options.mustUseSecondary=this.game.options.weaponsDisabled.every(o=>o),this.emit("gameOptionsChange",t,this.game.options),!1}#E(){const t=s.unPackInt8U();t===T.pause&&(this.emit("gameForcePause"),setTimeout(()=>this.me.playing=!1,3e3)),t===T.reset&&(Object.values(this.players).forEach(e=>e.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=y.capturing,this.game.zoneNumber=0,this.game.activeZone=null,this.game.capturing=0,this.game.captureProgress=0,this.game.numCapturing=0,this.game.stageName=F[y.capturing],this.game.capturePercent=0),this.emit("gameReset"))}#G(){if(!this.intents.includes(this.Intents.PING))return;const t=this.ping;this.ping=Date.now()-this.lastPingTime,this.emit("pingUpdate",t,this.ping),setTimeout(()=>{const e=I.getBuffer();e.packInt8(c.ping),e.send(this.game.socket),this.lastPingTime=Date.now()},this.pingInterval)}#R(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=this.players[t];if(!a)return;const i=a.team;a.team=e,a.streak=0,this.emit("playerSwitchTeam",a,i,e)}#M(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=s.unPackInt16U(),i=s.unPackInt16U(),n=s.unPackInt8U(),o=s.unPackInt16U(),h=s.unPackInt16U(),p=s.unPackInt16U(),k=s.unPackInt16U();s.unPackInt8(),s.unPackInt8();const g=this.intents.includes(this.Intents.COSMETIC_DATA),r=g?u(a):a,O=g?u(i):i,L=g?u(o):o,N=g?u(h):h,D=g?u(p):p,_=g?u(k):k,l=this.players[t];if(l){const v={...l.character},C=l.selectedGun;l.character.eggColor=n,l.character.primaryGun=r,l.character.secondaryGun=O,l.character.stamp=N,l.character.hat=L,l.character.grenade=D,l.character.melee=_,l.selectedGun=e,l.weapons[0]=new K[e],C!==l.selectedGun&&this.emit("playerChangeGun",l,C,l.selectedGun),v!==l.character&&this.emit("playerChangeCharacter",l,v,l.character)}}#F(){const t=s.unPackInt32U(),e=this.account.eggBalance;this.account.eggBalance=t,this.emit("balanceUpdate",t-e,t)}#A(){this.me.playing=!1,this.emit("selfRespawnFail")}#B(){const t=s.unPackInt8U(),e=this.players[t];e&&this.emit("playerMelee",e)}#O(){const t=s.unPackInt8U(),e=this.players[t];if(!e)return;const a=e.weapons[e.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",e,a)}#L(){const t=I.getBuffer();t.packInt8(c.gameOptions),t.packInt8(this.game.options.gravity*4),t.packInt8(this.game.options.damage*4),t.packInt8(this.game.options.healthRegen*4);const 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(a=>{t.packInt8(a?1:0)}),t.send(this.game.socket)}#N(){const t=s.unPackInt8U();let e=s.unPackInt16U();const a=s.unPackFloat(),i=s.unPackFloat(),n=s.unPackFloat(),o=s.unPackInt8U(),h=s.unPackFloat();this.intents.includes(this.Intents.COSMETIC_DATA)&&(e=u(e)),t===$.Grenade?this.emit("grenadeExploded",e,{x:a,y:i,z:n},o,h):this.emit("rocketHit",{x:a,y:i,z:n},o,h)}#D(){const t=s.unPackInt8U(),e=s.unPackFloat(),a=s.unPackFloat(),i=s.unPackFloat(),n=s.unPackFloat(),o=s.unPackFloat(),h=s.unPackFloat(),p=this.players[t];p&&(p.grenades--,this.emit("playerThrowGrenade",p,{x:e,y:a,z:i},{x:n,y:o,z:h}))}#_(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=this.players[t];if(!a)return;if(!this.intents.includes(this.Intents.CHALLENGES))return this.emit("challengeComplete",a,e);const i=this.account.challenges.find(n=>n.id===e);this.emit("challengeComplete",a,i),a.id===this.me.id&&this.refreshChallenges()}#H(){const t=I.getBuffer();t.packInt8(c.joinGame),t.packString(this.state.name),t.packString(this.game.raw.uuid),t.packInt8(0),t.packInt8(this.state.weaponIdx||this.account?.loadout?.classIdx||0),t.packInt32(this.account.session),t.packString(this.account.firebaseId),t.packString(this.account.sessionId),t.send(this.game.socket)}async#z(){if(this.me.id=s.unPackInt8U(),this.me.team=s.unPackInt8U(),this.game.gameModeId=s.unPackInt8U(),this.game.gameMode=A[this.game.gameModeId],this.game.mapIdx=s.unPackInt8U(),this.game.map=P[this.game.mapIdx],this.intents.includes(this.Intents.PATHFINDING)&&(this.game.map.raw=await V(this.game.map.filename,this.game.map.hash),this.pathing.nodeList=new X(this.game.map.raw),this.game.gameModeId===d.kotc)){const e=this.game.map.raw.data["DYNAMIC.capture-zone.none"];e?this.game.map.zones=J(e):delete this.game.map.zones}this.game.playerLimit=s.unPackInt8U(),this.game.isGameOwner=s.unPackInt8U()===1,this.game.isPrivate=s.unPackInt8U()===1,s.unPackInt8U(),this.state.joinedGame=!0,this.lastDeathTime=Date.now();const t=I.getBuffer();if(t.packInt8(c.clientReady),t.send(this.game.socket),this.game.socket.onmessage=e=>this.processPacket(e.data),this.updateIntervalId=setInterval(()=>this.update(),100/3),this.intents.includes(this.Intents.PING)){this.lastPingTime=Date.now();const e=I.getBuffer();e.packInt8(c.ping),e.send(this.game.socket)}this.emit("gameReady")}processPacket(t){s.init(t),this.intents.includes(this.Intents.PACKET_HOOK)&&this.emit("packet",t);let e=0,a=0,i=!1;for(;s.isMoreDataAvailable()&&!i;){const n=s.unPackInt8U();switch(n){case c.syncThem:this.#u();break;case c.fire:this.#k();break;case c.hitThem:this.#P();break;case c.syncMe:this.#w();break;case c.hitMe:this.#y();break;case c.swapWeapon:this.#p();break;case c.collectItem:this.#f();break;case c.respawn:this.#m();break;case c.die:this.#g();break;case c.pause:this.#d();break;case c.chat:this.#h();break;case c.addPlayer:this.#l();break;case c.removePlayer:this.#b();break;case c.eventModifier:this.#U();break;case c.metaGameState:this.#S();break;case c.beginShellStreak:this.#v();break;case c.endShellStreak:this.#C();break;case c.hitMeHardBoiled:this.#x();break;case c.gameOptions:this.#T();break;case c.ping:this.#G();break;case c.switchTeam:this.#R();break;case c.changeCharacter:this.#M();break;case c.reload:this.#O();break;case c.explode:this.#N();break;case c.throwGrenade:this.#D();break;case c.spawnItem:this.#I();break;case c.melee:this.#B();break;case c.updateBalance:this.#F();break;case c.challengeCompleted:this.#_();break;case c.socketReady:this.#H();break;case c.gameJoined:this.#z();break;case c.gameAction:this.#E();break;case c.requestGameOptions:this.#L();break;case c.respawnDenied:this.#A();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(o=>c[o]===n)} ${n}`),e&&console.error(`processPacket: It may be a result of the ${e} command (${a}).`),i=!0;break}e=Object.keys(c).find(o=>c[o]===n),a=n,this.intents.includes(this.Intents.LOG_PACKETS)&&console.log(`[LOG_PACKETS] Packet ${e}: ${a}`)}}async checkChiknWinner(){const t=await this.api.queryServices({cmd:"chicknWinnerReady",id:this.account.id,sessionId:this.account.sessionId});return typeof t=="string"?t:(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*1e3,this.account.cw)}async playChiknWinner(t=!0){if(this.account.cw.atLimit||this.account.cw.limit>j)return"hit_daily_limit";if(this.account.cw.canPlayAgain>Date.now()&&t)return"on_cooldown";const e=await this.api.queryServices({cmd:"incentivizedVideoReward",firebaseId:this.account.firebaseId,id:this.account.id,sessionId:this.account.sessionId,token:null});return typeof e=="string"?e:e.error?e.error==="RATELIMITED"||e.error==="RATELMITED"?(await this.checkChiknWinner(),"on_cooldown"):e.error==="SESSION_EXPIRED"?"session_expired":(console.error("Unknown Chikn Winner response, report this on Github:",e),"unknown_error"):e.reward?(this.account.eggBalance+=e.reward.eggsGiven,e.reward.itemIds.forEach(a=>this.account.ownedItemIds.push(a)),await this.checkChiknWinner(),e.reward):(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";const t=await this.api.queryServices({cmd:"chwReset",sessionId:this.account.sessionId});return typeof t=="string"?t:t.result!=="SUCCESS"?(console.error("Unknown Chikn Winner reset response, report this on Github:",t),"unknown_error"):(this.account.eggBalance-=200,await this.checkChiknWinner(),this.account.cw)}canSee(t){return this.intents.includes(this.Intents.PATHFINDING)?this.pathing.nodeList.hasLineOfSight(this.me.position,t.position):this.processError("You must have the PATHFINDING intent to use this method.")}getBestTarget(t=()=>!0){const a=Object.values(this.players).filter(n=>n?.playing).filter(n=>n.hp>0).filter(n=>n.id!==this.me.id).filter(n=>this.me.team===0||n.team!==this.me.team).filter(n=>!!t(n)).map(n=>({player:n,distance:Math.sqrt(Math.pow(n.position.x-this.me.position.x,2)+Math.pow(n.position.y-this.me.position.y,2)+Math.pow(n.position.z-this.me.position.z,2))})).sort((n,o)=>n.distance-o.distance);if(!a.length)return this.intents.includes(this.Intents.DEBUG_BEST_TARGET)&&console.log("no targets found"),null;const i=a.find(n=>this.canSee(n.player));return this.intents.includes(this.Intents.DEBUG_BEST_TARGET)&&(console.log("detected ",a.length,"targets"),console.log("closest target: ",a[0].player.name),console.log("all targets (ordered): ",a.map(n=>n.player.name)),console.log("found LoS player?",!!i),i&&console.log("closest LoS player: ",i.player.name)),i?{player:i.player,inLoS:!0}:{player:a[0].player,inLoS:!1}}async refreshChallenges(){const t=await this.api.queryServices({cmd:"challengeGetDaily",sessionId:this.account.sessionId,playerId:this.account.id});return this.#a(t),this.account.challenges}async rerollChallenge(t){const e=await this.api.queryServices({cmd:"challengeRerollSlot",sessionId:this.account.sessionId,slotId:t});return this.#a(e),this.account.challenges}async claimChallenge(t){const e=await this.api.queryServices({cmd:"challengeClaimReward",sessionId:this.account.sessionId,slotId:t});return this.#a(e.challenges),e.reward>0&&(this.account.eggBalance+=e.reward),{eggReward:e.reward,updatedChallenges:this.account.challenges}}async refreshBalance(){const t=await this.api.queryServices({cmd:"checkBalance",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId});return this.account.eggBalance=t.currentBalance,t.currentBalance}async redeemCode(t){const e=await this.api.queryServices({cmd:"redeem",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,id:this.account.id,code:t});return e.result==="SUCCESS"?(this.account.eggBalance=e.eggs_given,e.item_ids.forEach(a=>this.account.ownedItemIds.push(a)),{result:e,eggsGiven:e.eggs_given,itemIds:e.item_ids}):e}async claimURLReward(t){const e=await this.api.queryServices({cmd:"urlRewardParams",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,reward:t});return e.result==="SUCCESS"&&(this.account.eggBalance+=e.eggsGiven,e.itemIds.forEach(a=>this.account.ownedItemIds.push(a))),e}async claimSocialReward(t){const e=await this.api.queryServices({cmd:"reward",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,rewardTag:t});return e.result==="SUCCESS"&&(this.account.eggBalance+=e.eggsGiven,e.itemIds.forEach(a=>this.account.ownedItemIds.push(a))),e}async buyItem(t){const e=await this.api.queryServices({cmd:"buy",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,itemId:t,save:!0});return e.result==="SUCCESS"&&(this.account.eggBalance=e.currentBalance,this.account.ownedItemIds.push(e.itemId)),e}processError(t){if(this.#t.error)this.emit("error",t);else throw t}leave(t=z.mainMenu){this.state.quit||(t>-1&&(this.game?.socket?.close(t),this.state.left=!0,this.emit("leave")),clearInterval(this.updateIntervalId),this.#e=[],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 U({}),this.game=this.#o,this.ping=0,this.lastPingTime=-1,this.lastDeathTime=-1,this.lastChatTime=-1,this.lastUpdateTick=0,this.controlKeys=0,this.pathing={nodeList:null,followingPath:!1,activePath:null,activeNode:null,activeNodeIdx:0})}logout(){this.account=this.#n}quit(t=!1){this.state.quit||(this.leave(),this.matchmaker&&(this.matchmaker.close(),this.matchmaker=null),t||(delete this.account,delete this.game,delete this.me,delete this.players),this.state.quit=!0,this.emit("quit"))}}var kt=tt;export{tt as Bot,kt as default};
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- class a{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 peekInt8U(){return this.buffer[this.idx]}static unPackInt8U(){const t=this.idx;return this.idx++,this.buffer[t]}static unPackInt8(){return(this.unPackInt8U()+128)%256-128}static unPackInt16U(){const t=this.idx;return this.idx+=2,this.buffer[t]+this.buffer[t+1]*256}static unPackInt24U(){const t=this.idx;return this.idx+=3,this.buffer[t]+this.buffer[t+1]*256+this.buffer[t+2]*65536}static unPackInt32U(){const 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;const i=Math.min(this.unPackInt8U(),t);return this.unPackStringHelper(i)}static unPackLongString(t){t=t||16383;const i=Math.min(this.unPackInt16U(),t);return this.unPackStringHelper(i)}static unPackStringHelper(t){if(this.isMoreDataAvailable()<t)return 0;let n=new String;for(let s=0;s<t;s++){const r=this.unPackInt16U();r>0&&(n+=String.fromCodePoint(r))}return n}}var u=a;export{u as default};
3
+ class a{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 peekInt8U(){return this.buffer[this.idx]}static unPackInt8U(){const t=this.idx;return this.idx++,this.buffer[t]}static unPackInt8(){return(this.unPackInt8U()+128)%256-128}static unPackInt16U(){const t=this.idx;return this.idx+=2,this.buffer[t]+this.buffer[t+1]*256}static unPackInt24U(){const t=this.idx;return this.idx+=3,this.buffer[t]+this.buffer[t+1]*256+this.buffer[t+2]*65536}static unPackInt32U(){const 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;const i=Math.min(this.unPackInt8U(),t);return this.unPackStringHelper(i)}static unPackLongString(t){t=t||16383;const i=Math.min(this.unPackInt16U(),t);return this.unPackStringHelper(i)}static unPackStringHelper(t){if(this.isMoreDataAvailable()<t)return 0;let n="";for(let s=0;s<t;s++){const r=this.unPackInt16U();r>0&&(n+=String.fromCodePoint(r))}return n}}var u=a;export{u as default};
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- import r from"./OutBuffer.js";import e from"./Pool.js";class f{static buffer=null;static bufferPool=new e(()=>new r(16384),2);static getBuffer(){const t=this.bufferPool.retrieve();return t.idx=0,t}}var l=f;export{l as default};
3
+ import e from"./OutBuffer.js";import r from"./Pool.js";class f{static buffer=null;static bufferPool=new r(()=>new e(16384),2);static getBuffer(){const t=this.bufferPool.retrieve();return t.idx=0,t}}var l=f;export{l as default};
package/dist/comm/Pool.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- class s{constructor(i,t){this.size=0,this.originalSize=t,this.constructorFn=i,this.objects=[],this.idx=0,this.numActive=0,this.expand(t)}expand(i){for(let t=0;t<i;t++){const e=this.constructorFn();e.id=t+this.size,e.active=!1,this.objects.push(e)}this.size+=i}retrieve(i){if(i!=null){for(;i>=this.size;)this.expand(this.originalSize);return this.numActive++,this.objects[i].active=!0,this.objects[i]}let t=this.idx;do{t=(t+1)%this.size;const e=this.objects[t];if(!e.active)return this.idx=t,this.numActive++,e.active=!0,e}while(t!=this.idx);return this.expand(this.originalSize),this.retrieve()}recycle(i){i.active=!1,this.numActive--}forEachActive(i){for(let t=0;t<this.size;t++){const e=this.objects[t];e.active===!0&&i(e,t)}}}var c=s;export{c as default};
3
+ class s{constructor(i,t){this.size=0,this.originalSize=t,this.constructorFn=i,this.objects=[],this.idx=0,this.numActive=0,this.expand(t)}expand(i){for(let t=0;t<i;t++){const e=this.constructorFn();e.id=t+this.size,e.active=!1,this.objects.push(e)}this.size+=i}retrieve(i){if(i){for(;i>=this.size;)this.expand(this.originalSize);return this.numActive++,this.objects[i].active=!0,this.objects[i]}let t=this.idx;do{t=(t+1)%this.size;const e=this.objects[t];if(!e.active)return this.idx=t,this.numActive++,e.active=!0,e}while(t!==this.idx);return this.expand(this.originalSize),this.retrieve()}recycle(i){i.active=!1,this.numActive--}forEachActive(i){for(let t=0;t<this.size;t++){const e=this.objects[t];e.active===!0&&i(e,t)}}}var c=s;export{c as default};
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- import{AUG as t,CSG1 as o,DozenGauge as r,Eggk47 as n,M24 as a,RPEGG as s,SMG as c}from"./guns.js";import{findItemById as P}from"./findItemById.js";const l={none:0,pinned:2,team:4},d=3,m={AMMO:0,GRENADE:1},w={start:0,score:1,win:2,capturing:3,contested:4,takeover:5,abandoned:6,unclaimed:7},x="AIzaSyDP4SIjKaw6A4c-zvfYxICpbEjn1rRnN50",i=10,k=Math.ceil(30/i),S={reset:1,pause:2},g={ffa:0,team:1,spatula:2,kotc:3},u={locked:1,noTeamChange:2,noTeamShuffle:4},M=[n,r,o,s,c,a,t],e=typeof window<"u",f={Hat:1,Stamp:2,Primary:3,Secondary:4,Grenade:6,Melee:7},E={FORWARD:1,BACK:2,LEFT:4,RIGHT:8,JUMP:16,FIRE:32,MELEE:64,SCOPE:128},G={joinPublic:0,createPrivate:1,joinPrivate:2},R=!e&&typeof Bun>"u",T={HardBoiled:1,EggBreaker:2,Restock:4,OverHeal:8,DoubleEggs:16,MiniEgg:32},y={0:"Facebook",1:"Instagram",2:"Tiktok",3:"Discord",4:"Youtube",5:"Twitter",6:"Twitch"},I={Discord:"rew_1200",Tiktok:"rew_1208",Instagram:"rew_1219",Steam:"rew_1223",Facebook:"rew_1227",Twitter:"rew_1234",Twitch:"rew_twitch_social"},h=256,B={blue:1,red:2},b=["giveBasketBrosReward","mercZoneFinalGift","midMonthGiveMeEggs","newYolkerSignupReward","newYolkerItemReward","newYolkerWelcomeBack","WelcomeBack"],A=e?void 0:"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{l as ChatFlags,d as ChiknWinnerDailyLimit,m as CollectTypes,w as CoopStates,x as FirebaseKey,k as FramesBetweenSyncs,S as GameActions,g as GameModes,u as GameOptionFlags,M as GunList,e as IsBrowser,f as ItemTypes,E as Movements,G as PlayTypes,R as ProxiesEnabled,T as ShellStreaks,y as SocialMedias,I as SocialRewards,h as StateBufferSize,i as SyncRate,B as Teams,b as URLRewards,A as UserAgent,P as findItemById};
3
+ import{AUG as t,CSG1 as o,DozenGauge as r,Eggk47 as n,M24 as a,RPEGG as s,SMG as c}from"./guns.js";import{findItemById as P}from"./findItemById.js";const l={none:0,pinned:2,team:4},d=3,m={AMMO:0,GRENADE:1},w={start:0,score:1,win:2,capturing:3,contested:4,takeover:5,abandoned:6,unclaimed:7},x="AIzaSyDP4SIjKaw6A4c-zvfYxICpbEjn1rRnN50",i=10,k=Math.ceil(30/i),S={reset:1,pause:2},g={ffa:0,team:1,spatula:2,kotc:3},u={locked:1,noTeamChange:2,noTeamShuffle:4},M=[n,r,o,s,c,a,t],e=typeof window<"u",f={Hat:1,Stamp:2,Primary:3,Secondary:4,Grenade:6,Melee:7},E={FORWARD:1,BACK:2,LEFT:4,RIGHT:8,JUMP:16,FIRE:32,MELEE:64,SCOPE:128},G={joinPublic:0,createPrivate:1,joinPrivate:2},R=!e&&typeof Bun>"u",T={HardBoiled:1,EggBreaker:2,Restock:4,OverHeal:8,DoubleEggs:16,MiniEgg:32},y={0:"Facebook",1:"Instagram",2:"Tiktok",3:"Discord",4:"Youtube",5:"Twitter",6:"Twitch"},I={Discord:"rew_1200",Tiktok:"rew_1208",Instagram:"rew_1219",Steam:"rew_1223",Facebook:"rew_1227",Twitter:"rew_1234",Twitch:"rew_twitch_social"},h=256,B={blue:1,red:2},b=["giveBasketBrosReward","mercZoneFinalGift","midMonthGiveMeEggs","newYolkerSignupReward","newYolkerItemReward","newYolkerWelcomeBack","WelcomeBack"],A=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{l as ChatFlags,d as ChiknWinnerDailyLimit,m as CollectTypes,w as CoopStates,x as FirebaseKey,k as FramesBetweenSyncs,S as GameActions,g as GameModes,u as GameOptionFlags,M as GunList,e as IsBrowser,f as ItemTypes,E as Movements,G as PlayTypes,R as ProxiesEnabled,T as ShellStreaks,y as SocialMedias,I as SocialRewards,h as StateBufferSize,i as SyncRate,B as Teams,b as URLRewards,A as UserAgent,P as findItemById};
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- import o from"../comm/CommOut.js";import{CommCode as r}from"../constants/codes.js";class u{constructor(e){this.uniqueId=e}check(e){return typeof this.uniqueId=="string"&&e.game.isGameOwner&&e.players.find(t=>t.uniqueId==this.uniqueId)}execute(e){const t=o.getBuffer();t.packInt8(r.bootPlayer),t.packString(this.uniqueId),t.send(e.game.socket)}}var a=u;export{u as BootPlayerDispatch,a as default};
3
+ import o from"../comm/CommOut.js";import{CommCode as r}from"../constants/codes.js";class u{constructor(e){this.uniqueId=e}check(e){return typeof this.uniqueId=="string"&&e.game.isGameOwner&&e.players.find(t=>t.uniqueId===this.uniqueId)}execute(e){const t=o.getBuffer();t.packInt8(r.bootPlayer),t.packString(this.uniqueId),t.send(e.game.socket)}}var a=u;export{u as BootPlayerDispatch,a as default};
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- import m from"../pathing/astar.js";class g{check(t){return t.me.playing&&t.game.collectables[0].length&&t.intents.includes(t.Intents.PATHFINDING)}execute(t){this.pather=new m(t.pathing.nodeList);let n=200,a=null;for(const e of t.game.collectables[0]){const i=e.x-t.me.position.x,o=e.y-t.me.position.y,s=e.z-t.me.position.z,c=Math.sqrt(i*i+o*o+s*s);c<n&&(n=c,a=e)}const h=Object.entries(t.me.position).map(e=>Math.floor(e[1])),r=Object.entries(a).map(e=>Math.floor(e[1])),p=t.pathing.nodeList.at(...h),l=t.pathing.nodeList.at(...r);if(t.pathing.activePath=this.pather.path(p,l),!t.pathing.activePath)return console.error("no path found");if(t.pathing.activePath.length<2)return console.error("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var u=g;export{g as GoToAmmoDispatch,u as default};
3
+ import m from"../pathing/astar.js";class g{check(t){return t.me.playing&&t.game.collectables[0].length&&t.intents.includes(t.Intents.PATHFINDING)}execute(t){this.pather=new m(t.pathing.nodeList);let n=200,a=null;for(const e of t.game.collectables[0]){const i=e.x-t.me.position.x,s=e.y-t.me.position.y,o=e.z-t.me.position.z,c=Math.sqrt(i*i+s*s+o*o);c<n&&(n=c,a=e)}const r=Object.entries(t.me.position).map(e=>Math.floor(e[1])),h=Object.entries(a).map(e=>Math.floor(e[1])),p=t.pathing.nodeList.at(...r),l=t.pathing.nodeList.at(...h);if(t.pathing.activePath=this.pather.path(p,l),!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 u=g;export{g as GoToAmmoDispatch,u as default};
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- import l from"../pathing/astar.js";class d{check(t){return t.me.playing&&t.game.zoneNumber&&t.game.activeZone&&t.intents.includes(t.Intents.PATHFINDING)}execute(t){this.pather=new l(t.pathing.nodeList);let n=200,a=null;for(const e of t.game.activeZone){const i=e.x-t.me.position.x,o=e.y-t.me.position.y,s=e.z-t.me.position.z,c=Math.sqrt(i*i+o*o+s*s);c<n&&(n=c,a=e)}const r=Object.entries(t.me.position).map(e=>Math.floor(e[1])),h=Object.entries(a).map(e=>Math.floor(e[1])),p=t.pathing.nodeList.at(...r),g=t.pathing.nodeList.at(...h);if(t.pathing.activePath=this.pather.path(p,g),!t.pathing.activePath)return console.error("no path found");if(t.pathing.activePath.length<2)return console.error("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var u=d;export{d as GoToCoopDispatch,u as default};
3
+ import d from"../pathing/astar.js";class m{check(t){return t.me.playing&&t.game.zoneNumber&&t.game.activeZone&&t.intents.includes(t.Intents.PATHFINDING)}execute(t){this.pather=new d(t.pathing.nodeList);let n=200,a=null;for(const e of t.game.activeZone){const i=e.x-t.me.position.x,o=e.y-t.me.position.y,s=e.z-t.me.position.z,r=Math.sqrt(i*i+o*o+s*s);r<n&&(n=r,a=e)}const c=Object.entries(t.me.position).map(e=>Math.floor(e[1])),p=Object.entries(a).map(e=>Math.floor(e[1])),h=t.pathing.nodeList.at(...c),g=t.pathing.nodeList.at(...p);if(t.pathing.activePath=this.pather.path(h,g),!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 u=m;export{m as GoToCoopDispatch,u as default};
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- import g from"../pathing/astar.js";class d{check(t){return t.me.playing&&t.game.collectables[1].length&&t.intents.includes(t.Intents.PATHFINDING)}execute(t){this.pather=new g(t.pathing.nodeList);let n=200,a=null;for(const e of t.game.collectables[1]){const i=e.x-t.me.position.x,o=e.y-t.me.position.y,s=e.z-t.me.position.z,c=Math.sqrt(i*i+o*o+s*s);c<n&&(n=c,a=e)}const r=Object.entries(t.me.position).map(e=>Math.floor(e[1])),h=Object.entries(a).map(e=>Math.floor(e[1])),p=t.pathing.nodeList.at(...r),l=t.pathing.nodeList.at(...h);if(t.pathing.activePath=this.pather.path(p,l),!t.pathing.activePath)return console.error("no path found");if(t.pathing.activePath.length<2)return console.error("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var u=d;export{d as GoToGrenadeDispatch,u as default};
3
+ import g from"../pathing/astar.js";class d{check(t){return t.me.playing&&t.game.collectables[1].length&&t.intents.includes(t.Intents.PATHFINDING)}execute(t){this.pather=new g(t.pathing.nodeList);let n=200,a=null;for(const e of t.game.collectables[1]){const i=e.x-t.me.position.x,s=e.y-t.me.position.y,o=e.z-t.me.position.z,r=Math.sqrt(i*i+s*s+o*o);r<n&&(n=r,a=e)}const c=Object.entries(t.me.position).map(e=>Math.floor(e[1])),h=Object.entries(a).map(e=>Math.floor(e[1])),p=t.pathing.nodeList.at(...c),l=t.pathing.nodeList.at(...h);if(t.pathing.activePath=this.pather.path(p,l),!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 u=d;export{d as GoToGrenadeDispatch,u as default};
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- import h from"../pathing/astar.js";class o{constructor(t){this.target=t}check(t){return t.me.playing&&this.target&&this.target.playing&&this.target.position&&t.intents.includes(t.Intents.PATHFINDING)}execute(t){this.pather=new h(t.pathing.nodeList);const a=Object.entries(t.me.position).map(e=>Math.floor(e[1])),i=Object.entries(this.target.position).map(e=>Math.floor(e[1])),n=t.pathing.nodeList.at(...a),r=t.pathing.nodeList.at(...i);if(t.pathing.activePath=this.pather.path(n,r),!t.pathing.activePath)return console.error("no path found");if(t.pathing.activePath.length<2)return console.error("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var c=o;export{o as GoToPlayerDispatch,c as default};
3
+ import h from"../pathing/astar.js";class s{constructor(t){this.target=t}check(t){return t.me.playing&&this.target&&this.target.playing&&this.target.position&&t.intents.includes(t.Intents.PATHFINDING)}execute(t){this.pather=new h(t.pathing.nodeList);const a=Object.entries(t.me.position).map(e=>Math.floor(e[1])),i=Object.entries(this.target.position).map(e=>Math.floor(e[1])),n=t.pathing.nodeList.at(...a),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 c=s;export{s as GoToPlayerDispatch,c as default};
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- import o from"../pathing/astar.js";class r{check(t){return t.me.playing&&t.game.spatula&&t.game.spatula.coords&&t.game.spatula.coords.x&&t.intents.includes(t.Intents.PATHFINDING)}execute(t){this.pather=new o(t.pathing.nodeList);const e=Object.entries(t.me.position).map(a=>Math.floor(a[1])),n=Object.entries(this.game.spatula.coords).map(a=>Math.floor(a[1])),i=t.pathing.nodeList.at(...e),s=t.pathing.nodeList.at(...n);if(t.pathing.activePath=this.pather.path(i,s),!t.pathing.activePath)return console.error("no path found");if(t.pathing.activePath.length<2)return console.error("path too short");t.pathing.followingPath=!0,t.pathing.activeNode=t.pathing.activePath[1],t.pathing.activeNodeIdx=1}}var c=r;export{r as GoToSpatulaDispatch,c as default};
3
+ import r from"../pathing/astar.js";class p{check(t){return t.me.playing&&t.game.spatula&&t.game.spatula.coords&&t.game.spatula.coords.x&&t.intents.includes(t.Intents.PATHFINDING)}execute(t){this.pather=new r(t.pathing.nodeList);const e=Object.entries(t.me.position).map(a=>Math.floor(a[1])),i=Object.entries(this.game.spatula.coords).map(a=>Math.floor(a[1])),n=t.pathing.nodeList.at(...e),s=t.pathing.nodeList.at(...i);if(t.pathing.activePath=this.pather.path(n,s),!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 c=p;export{p as GoToSpatulaDispatch,c as default};
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- const h=(e,t)=>(e%t+t)%t,r=Math.PI*2,s=e=>Math.round(e*8192)/8192,d=e=>s(h(Math.atan2(-e.x,-e.z),r)),f=e=>s(Math.atan2(e.y,Math.hypot(e.x,e.z)));class l{idOrName;constructor(t){typeof t=="number"?this.id=t:typeof t=="string"&&(this.name=t)}check(t){if(!t.me.playing)return!1;let i;return this.id!==void 0?i=t.players[this.id.toString()]:this.name!==void 0&&(i=t.players.find(n=>n.name==this.name)),!!i}execute(t){let i;this.id!==void 0?i=t.players[this.id.toString()]:this.name!==void 0&&(i=t.players.find(o=>o.name==this.name));const n={x:i.position.x-t.me.position.x,y:i.position.y-t.me.position.y-.05,z:i.position.z-t.me.position.z},a=d(n),c=f(n);t.me.view.yaw=a,t.me.view.pitch=c}}var p=l;export{l as LookAtDispatch,p as default};
3
+ const h=(i,t)=>(i%t+t)%t,r=Math.PI*2,s=i=>Math.round(i*8192)/8192,l=i=>s(h(Math.atan2(-i.x,-i.z),r)),p=i=>s(Math.atan2(i.y,Math.hypot(i.x,i.z)));class y{idOrName;constructor(t){typeof t=="number"?this.id=t:typeof t=="string"&&(this.name=t)}check(t){if(!t.me.playing)return!1;let e;return this.id?e=t.players[this.id.toString()]:this.name&&(e=t.players.find(n=>n.name===this.name)),!!e}execute(t){let e;this.id?e=t.players[this.id.toString()]:this.name&&(e=t.players.find(o=>o.name===this.name));const n={x:e.position.x-t.me.position.x,y:e.position.y-t.me.position.y-.05,z:e.position.z-t.me.position.z},a=l(n),c=p(n);t.me.view.yaw=a,t.me.view.pitch=c}}var f=y;export{y as LookAtDispatch,f as default};
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- import s from"../comm/CommOut.js";import{CommCode as n}from"../constants/codes.js";class a{constructor(t,e={}){typeof t=="number"?this.id=t:typeof t=="string"&&(this.name=t),this.reasons=[!!e.cheating,!!e.harassment,!!e.offensive,!!e.other],this.reasons.includes(!0)||(this.reasons[3]=!0);for(let i=0;i<this.reasons.length;i++)this.reasons[i]==!0&&(this.reasonInt|=1<<i)}check(t){if(!t.state.joinedGame)return!1;let e;return this.id!==void 0?e=t.players[this.id.toString()]:this.name!==void 0&&(e=t.players.find(i=>i.name==this.name)),!!e}execute(t){let e;if(this.id!=="undefined"?e=t.players[this.id.toString()]:this.name!=="undefined"&&(e=t.players.find(r=>r.name==this.name)),!e)throw new Error("target player for ReportPlayerDispatch not found");const i=s.getBuffer();i.packInt8(n.reportPlayer),i.packString(e),i.packInt8(this.reasonInt),i.send(t.game.socket)}}var l=a;export{a as ReportPlayerDispatch,l as default};
3
+ import r from"../comm/CommOut.js";import{CommCode as n}from"../constants/codes.js";class a{constructor(e,t={}){typeof e=="number"?this.id=e:typeof e=="string"&&(this.name=e),this.reasons=[!!t.cheating,!!t.harassment,!!t.offensive,!!t.other],this.reasons.includes(!0)||(this.reasons[3]=!0);for(let s=0;s<this.reasons.length;s++)this.reasons[s]===!0&&(this.reasonInt|=1<<s)}check(e){if(!e.state.joinedGame)return!1;let t;return this.id?t=e.players[this.id.toString()]:this.name&&(t=e.players.find(s=>s.name===this.name)),!!t}execute(e){let t;this.id?t=e.players[this.id.toString()]:this.name&&(t=e.players.find(i=>i.name===this.name));const s=r.getBuffer();s.packInt8(n.reportPlayer),s.packString(t.uniqueId),s.packInt8(this.reasonInt),s.send(e.game.socket)}}var l=a;export{a as ReportPlayerDispatch,l as default};
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- import{queryServices as l}from"../api.js";import{findItemById as n,GunList as f,ItemTypes as i}from"../constants/index.js";import o from"../comm/CommOut.js";import{CommCode as u}from"../constants/codes.js";const I=c=>n(c)&&n(c).unlock=="default",m=(c,e)=>n(c)&&n(c).item_type_id==e;class h{constructor(e){this.changes={classIdx:e.gunId,hatId:e.hatId,stampId:e.stampId,grenadeId:e.grenadeId,meleeId:e.meleeId,colorIdx:e.eggColor,primaryId:e.primaryIds,secondaryId:e.secondaryIds},this.changes=Object.fromEntries(Object.entries(this.changes).filter(([,s])=>s!==void 0))}check(e){if(e.me.playing)return!1;const s=this.changes;if(s.colorIdx!==void 0&&s.colorIdx>=7&&!e.account.vip||s.colorIdx!==void 0&&s.colorIdx>=14||m(s.hatId,i.Hat)&&!I(s.hatId)&&!e.account.ownedItemIds.includes(s.hatId)||m(s.stampId,i.Stamp)&&!I(s.stampId)&&!e.account.ownedItemIds.includes(s.stampId)||m(s.grenadeId,i.Grenade)&&!I(s.grenadeId)&&!e.account.ownedItemIds.includes(s.grenadeId)||m(s.meleeId,i.Melee)&&!I(s.meleeId)&&!e.account.ownedItemIds.includes(s.meleeId)||typeof s.classIdx=="number"&&s.classIdx>6||s.classIdx<0)return!1;if(this.changes.primaryId)for(let t=0;t<7;t++){const d=this.changes.primaryId[t];if(!m(d,i.Primary)||!I(d)&&!e.account.ownedItemIds.includes(d))return!1}if(this.changes.secondaryId)for(let t=0;t<7;t++){const d=this.changes.secondaryId[t];if(!m(d,i.Secondary)||!I(d)&&!e.account.ownedItemIds.includes(d))return!1}return!0}execute(e){e.me&&this.changes.classIdx&&this.changes.classIdx!==e.me.selectedGun&&(e.me.weapons[0]=new f[this.changes.classIdx]),e.state.weaponIdx=this.changes.classIdx||e.state.weaponIdx;const s={...e.account.loadout,...this.changes},t=l({cmd:"saveLoadout",save:!0,firebaseId:e.account.firebaseId,sessionId:e.account.sessionId,loadout:s},e.proxy,`${e.protocol}://${e.instance}`);e.account.loadout=s,e.me&&t.then(()=>{if(e.state.joinedGame){const a=o.getBuffer();a.packInt8(u.changeCharacter),a.packInt8(this.changes?.classIdx||e.me.selectedGun),a.send(e.game.socket)}const d=e.intents.includes(e.Intents.COSMETIC_DATA);Object.entries(this.changes).forEach(([a,r])=>{a==="classIdx"?e.me.selectedGun=r:a==="hatId"?e.me.character.hat=d?n(r):r:a==="stampId"?e.me.character.stamp=d?n(r):r:a==="grenadeId"?e.me.character.grenade=d?n(r):r:a==="meleeId"?e.me.character.melee=d?n(r):r:a==="colorIdx"?e.me.character.eggColor=r:a==="primaryId"?e.me.character.primaryGun=d?n(r[e.me.selectedGun]):r:a==="secondaryId"&&(e.me.character.secondaryGun=d?n(r[e.me.selectedGun]):r)})})}}var w=h;export{h as SaveLoadoutDispatch,w as default};
3
+ import{findItemById as t,GunList as l,ItemTypes as i}from"../constants/index.js";import f from"../comm/CommOut.js";import{CommCode as o}from"../constants/codes.js";const I=n=>t(n)&&t(n).unlock==="default",m=(n,e)=>t(n)&&t(n).item_type_id===e;class u{constructor(e){this.changes={classIdx:e.gunId,hatId:e.hatId,stampId:e.stampId,grenadeId:e.grenadeId,meleeId:e.meleeId,colorIdx:e.eggColor,primaryId:e.primaryIds,secondaryId:e.secondaryIds},this.changes=Object.fromEntries(Object.entries(this.changes).filter(([,s])=>!!s))}check(e){if(e.me.playing)return!1;const s=this.changes;if(s.colorIdx&&s.colorIdx>=7&&!e.account.vip||s.colorIdx&&s.colorIdx>=14||m(s.hatId,i.Hat)&&!I(s.hatId)&&!e.account.ownedItemIds.includes(s.hatId)||m(s.stampId,i.Stamp)&&!I(s.stampId)&&!e.account.ownedItemIds.includes(s.stampId)||m(s.grenadeId,i.Grenade)&&!I(s.grenadeId)&&!e.account.ownedItemIds.includes(s.grenadeId)||m(s.meleeId,i.Melee)&&!I(s.meleeId)&&!e.account.ownedItemIds.includes(s.meleeId)||typeof s.classIdx=="number"&&s.classIdx>6||s.classIdx<0)return!1;if(this.changes.primaryId)for(let c=0;c<7;c++){const d=this.changes.primaryId[c];if(!m(d,i.Primary)||!I(d)&&!e.account.ownedItemIds.includes(d))return!1}if(this.changes.secondaryId)for(let c=0;c<7;c++){const d=this.changes.secondaryId[c];if(!m(d,i.Secondary)||!I(d)&&!e.account.ownedItemIds.includes(d))return!1}return!0}execute(e){e.me&&this.changes.classIdx&&this.changes.classIdx!==e.me.selectedGun&&(e.me.weapons[0]=new l[this.changes.classIdx]),e.state.weaponIdx=this.changes.classIdx||e.state.weaponIdx;const s={...e.account.loadout,...this.changes},c=e.api.queryServices({cmd:"saveLoadout",save:!0,firebaseId:e.account.firebaseId,sessionId:e.account.sessionId,loadout:s});e.account.loadout=s,e.me&&c.then(()=>{if(e.state.joinedGame){const a=f.getBuffer();a.packInt8(o.changeCharacter),a.packInt8(this.changes?.classIdx||e.me.selectedGun),a.send(e.game.socket)}const d=e.intents.includes(e.Intents.COSMETIC_DATA);Object.entries(this.changes).forEach(([a,r])=>{a==="classIdx"?e.me.selectedGun=r:a==="hatId"?e.me.character.hat=d?t(r):r:a==="stampId"?e.me.character.stamp=d?t(r):r:a==="grenadeId"?e.me.character.grenade=d?t(r):r:a==="meleeId"?e.me.character.melee=d?t(r):r:a==="colorIdx"?e.me.character.eggColor=r:a==="primaryId"?e.me.character.primaryGun=d?t(r[e.me.selectedGun]):r:a==="secondaryId"&&(e.me.character.secondaryGun=d?t(r[e.me.selectedGun]):r)})})}}var y=u;export{u as SaveLoadoutDispatch,y as default};
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- import n from"../comm/CommOut.js";import{CommCode as i}from"../constants/codes.js";class f{check(e){if(!e.state.joinedGame||e.me.playing||e.game.gameModeId==0)return!1;if(e.game.isPrivate)return!e.game.options.noTeamChange;const t=e.players,r=e.me.team,m=t.filter(a=>a.team==r).length,s=t.filter(a=>a.team!=r).length;return!(s>m||m==s)}execute(e){const t=n.getBuffer();t.packInt8(i.switchTeam),t.send(e.game.socket)}}var u=f;export{f as SwitchTeamDispatch,u as default};
3
+ import n from"../comm/CommOut.js";import{CommCode as i}from"../constants/codes.js";class f{check(e){if(!e.state.joinedGame||e.me.playing||e.game.gameModeId===0)return!1;if(e.game.isPrivate)return!e.game.options.noTeamChange;const t=e.players,r=e.me.team,m=t.filter(a=>a.team===r).length,s=t.filter(a=>a.team!==r).length;return!(s>m||m===s)}execute(e){const t=n.getBuffer();t.packInt8(i.switchTeam),t.send(e.game.socket)}}var u=f;export{f as SwitchTeamDispatch,u as default};
package/dist/globals.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- const e={};if(typeof process<"u")e.fetch=(await import("undici")).fetch,e.SocksProxyAgent=(await import("smallsocks")).SocksProxyAgent,e.ProxyAgent=(await import("undici")).ProxyAgent,e.WebSocket=(await import("ws")).default;else if(typeof window<"u")e.fetch=fetch.bind(window),e.SocksProxyAgent=void 0,e.ProxyAgent=class{},e.WebSocket=WebSocket;else throw new Error("unknown environment...could not detect node.js or browser...open an issue in the yolkbot github");var o=e;export{o as default};
3
+ const e={};if(typeof process<"u")e.fetch=(await import("undici")).fetch,e.SocksProxyAgent=(await import("smallsocks")).SocksProxyAgent,e.ProxyAgent=(await import("undici")).ProxyAgent,e.WebSocket=(await import("ws")).default;else if(typeof window<"u")e.fetch=fetch.bind(window),e.SocksProxyAgent=null,e.ProxyAgent=class{},e.WebSocket=WebSocket;else throw new Error("unknown environment...could not detect node.js or browser...open an issue in the yolkbot github");var o=e;export{o as default};
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- import{loginAnonymously as h}from"./api.js";import{GameModes as r,PlayTypes as c,ProxiesEnabled as d}from"./constants/index.js";import{validate as a}from"./wasm/wrapper.js";import f from"./socket.js";class g{connected=!1;onceConnected=[];proxy=null;sessionId="";onListeners=new Map;onceListeners=new Map;#e=!1;constructor(e={}){if(e.instance||(e.instance="shellshock.io"),e.protocol||(e.protocol="wss"),e.sessionId||e.noLogin?this.sessionId=e.sessionId:this.#o(e.instance),e.proxy&&!d)throw new Error("proxies do not work and hence are not supported in the browser");e.proxy&&(this.proxy=e.proxy),this.#i(e.instance,e.protocol,e.noLogin)}async#i(e,i,s){const t=async()=>{try{this.ws=new f(`${i}://${e}/matchmaker/`,this.proxy),this.ws.onerror=async o=>(console.error(o),await new Promise(n=>setTimeout(n,100)),await t())}catch{await new Promise(o=>setTimeout(o,100)),await t()}};await t(),this.ws.onopen=()=>{this.connected=!0,this.ws.onerror=null,(this.sessionId||s)&&this.onceConnected.forEach(o=>o())},this.ws.onmessage=o=>{const n=JSON.parse(o.data);n.command==="validateUUID"&&this.ws.send(JSON.stringify({command:"validateUUID",hash:a(n.uuid)})),this.#s("msg",n)},this.ws.onclose=()=>{this.#e||(this.connected=!1,this.#i(e))}}async#o(e){const i=await h(this.proxy,e);(!i||typeof i=="string")&&this.#s("authFail",i),this.sessionId=i.sessionId,this.connected&&this.onceConnected.forEach(s=>s())}send(e){this.ws.send(JSON.stringify(e))}async waitForConnect(){return new Promise(e=>{this.connected?e():this.onceConnected.push(e)})}async getRegions(){return await this.waitForConnect(),new Promise(e=>{const i=s=>{s.command=="regionList"&&(this.regionList=s.regionList,this.off("msg",i),e(s.regionList))};this.on("msg",i),this.ws.onerror=s=>{throw new Error("failed to get regions",s)},this.ws.send(JSON.stringify({command:"regionList"}))})}async findPublicGame(e={}){if(await this.waitForConnect(),!e.region)throw new Error("did not specify a region in findGame, use <Matchmaker>.getRegions() for a list");if(this.regionList&&!this.regionList.find(s=>s.id==e.region))throw new Error("did not find region in regionList, if you are attempting to force a region, avoid calling getRegions()");if(!e.mode)throw new Error("did not specify a mode in findGame");if(r[e.mode]===void 0)throw new Error("invalid mode in findGame, see GameModes for a list");return new Promise(i=>{const s={command:"findGame",region:e.region,playType:c.joinPublic,gameType:r[e.mode],sessionId:this.sessionId},t=o=>{o.command=="gameFound"&&(this.off("msg",t),i(o))};this.on("msg",t),this.ws.send(JSON.stringify(s))})}getRandomRegion(){if(!this.regionList)throw new Error("called getRandomRegion() without region list cached, use <Matchmaker>.getRegions() before getRandomRegion()");return this.regionList[Math.floor(Math.random()*this.regionList.length)].id}getRandomGameMode(){const e=Object.keys(r);return e[Math.floor(Math.random()*e.length)]}close(){this.#e=!0,this.ws.close()}on(e,i){this.onListeners.has(e)||this.onListeners.set(e,[]),this.onListeners.get(e).push(i)}once(e,i){this.onceListeners.has(e)||this.onceListeners.set(e,[]),this.onceListeners.get(e).push(i)}off(e,i){this.onListeners.has(e)&&this.onListeners.set(e,this.onListeners.get(e).filter(s=>s!==i)),this.onceListeners.has(e)&&this.onceListeners.set(e,this.onceListeners.get(e).filter(s=>s!==i))}#s(e,...i){this.onListeners.has(e)&&this.onListeners.get(e).forEach(s=>s(...i)),this.onceListeners.has(e)&&(this.onceListeners.get(e).forEach(s=>s(...i)),this.onceListeners.delete(e))}}var u=g;export{g as Matchmaker,u as default};
3
+ import h from"./api.js";import{GameModes as r,PlayTypes as c,ProxiesEnabled as a}from"./constants/index.js";import{validate as d}from"./wasm/wrapper.js";import f from"./socket.js";class g{connected=!1;onceConnected=[];proxy=null;sessionId="";onListeners=new Map;onceListeners=new Map;#e=!1;constructor(s={}){s.instance||(s.instance="shellshock.io"),s.protocol||(s.protocol="wss"),s.api?this.api=s.api:this.api=new h({instance:s.instance,protocol:s.protocol,proxy:s.proxy}),s.sessionId||s.noLogin?this.sessionId=s.sessionId:this.#o(),s.proxy&&!a?this.#s("proxies do not work and hence are not supported in the browser"):s.proxy&&(this.proxy=s.proxy),this.#t(s.instance,s.protocol,s.noLogin)}async#t(s,i,e){const t=async()=>{try{this.ws=new f(`${i}://${s}/matchmaker/`,this.proxy),this.ws.onerror=async o=>(this.#s(o),await new Promise(n=>setTimeout(n,100)),await t())}catch{await new Promise(o=>setTimeout(o,100)),await t()}};await t(),this.ws.onopen=()=>{this.connected=!0,this.ws.onerror=null,(this.sessionId||e)&&this.onceConnected.forEach(o=>o())},this.ws.onmessage=o=>{const n=JSON.parse(o.data);n.command==="validateUUID"&&this.ws.send(JSON.stringify({command:"validateUUID",hash:d(n.uuid)})),this.#i("msg",n)},this.ws.onclose=()=>{this.#e||(this.connected=!1,this.#t(s))}}async#o(){const s=await this.api.loginAnonymously();(!s||typeof s=="string")&&this.#i("authFail",s),this.sessionId=s.sessionId,this.connected&&this.onceConnected.forEach(i=>i())}send(s){this.ws.send(JSON.stringify(s))}async waitForConnect(){return new Promise(s=>{this.connected?s():this.onceConnected.push(s)})}async getRegions(){await this.waitForConnect();const s=this;return new Promise(i=>{const e=t=>{t.command==="regionList"&&(this.regionList=t.regionList,this.off("msg",e),i(t.regionList))};this.on("msg",e),this.ws.onerror=t=>s.#s("failed to get regions",t),this.ws.send(JSON.stringify({command:"regionList"}))})}async findPublicGame(s={}){return await this.waitForConnect(),!s.region&&!this.regionList?this.#s("pass a region to createPrivateGame or call getRegions() for a random one"):(s.region||(opts.region=this.getRandomRegion()),this.regionList&&!this.regionList.find(i=>i.id===s.region)?this.#s("did not find region in regionList"):s.mode?r[s.mode]?new Promise(i=>{const e={command:"findGame",region:s.region,playType:c.joinPublic,gameType:r[s.mode],sessionId:this.sessionId},t=o=>{o.command==="gameFound"&&(this.off("msg",t),i(o))};this.on("msg",t),this.ws.send(JSON.stringify(e))}):this.#s("invalid mode passed to findPublicGame, see GameModes for a list"):this.#s("pass a mode to findPublicGame"))}getRandomRegion(){if(!this.regionList)this.#s("use <Matchmaker>.getRegions() before getRandomRegion()");else return this.regionList[Math.floor(Math.random()*this.regionList.length)].id}getRandomGameMode(){const s=Object.keys(r);return s[Math.floor(Math.random()*s.length)]}close(){this.#e=!0,this.ws.close()}on(s,i){this.onListeners.has(s)||this.onListeners.set(s,[]),this.onListeners.get(s).push(i)}once(s,i){this.onceListeners.has(s)||this.onceListeners.set(s,[]),this.onceListeners.get(s).push(i)}off(s,i){this.onListeners.has(s)&&this.onListeners.set(s,this.onListeners.get(s).filter(e=>e!==i)),this.onceListeners.has(s)&&this.onceListeners.set(s,this.onceListeners.get(s).filter(e=>e!==i))}#i(s,...i){this.onListeners.has(s)&&this.onListeners.get(s).forEach(e=>e(...i)),this.onceListeners.has(s)&&(this.onceListeners.get(s).forEach(e=>e(...i)),this.onceListeners.delete(s))}#s(s){if(this.onListeners.has("error"))this.#i("error",s);else throw s}}var y=g;export{g as Matchmaker,y as default};
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- import{BinaryHeap as u}from"./binaryheap.js";class a{constructor(e){this.list=e}heuristic(e,i){return Math.abs(e.x-i.x)+Math.abs(e.y-i.y)+Math.abs(e.z-i.z)}reversePath(e){const i=[];for(;e.parent;)i.push(e),e=e.parent;return i.reverse(),i}path(e,i){this.list.clean();const r=new u(s=>s.f),n=[];for(e.h=this.heuristic(e,i),e.g=0,e.f=e.g+e.h,r.push(e);r.size()!=0;){const s=r.pop();if(s===i)return this.reversePath(s);n.push(s);const c=s.links;for(let h=0;h<c.length;h++){const t=c[h];if(n.includes(t))continue;const o=s.g+1,l=t.visited;(!l||o<t.g)&&(t.visited=!0,t.parent=s,t.g=o,t.h=this.heuristic(t.position,i.position),t.f=t.g+t.h,l?r.rescoreElement(t):r.push(t))}}return null}}export{a as default};
3
+ import{BinaryHeap as u}from"./binaryheap.js";class a{constructor(e){this.list=e}heuristic(e,i){return Math.abs(e.x-i.x)+Math.abs(e.y-i.y)+Math.abs(e.z-i.z)}reversePath(e){const i=[];for(;e.parent;)i.push(e),e=e.parent;return i.reverse(),i}path(e,i){this.list.clean();const r=new u(s=>s.f),n=[];for(e.h=this.heuristic(e,i),e.g=0,e.f=e.g+e.h,r.push(e);r.size()!==0;){const s=r.pop();if(s===i)return this.reversePath(s);n.push(s);const c=s.links;for(let h=0;h<c.length;h++){const t=c[h];if(n.includes(t))continue;const o=s.g+1,l=t.visited;(!l||o<t.g)&&(t.visited=!0,t.parent=s,t.g=o,t.h=this.heuristic(t.position,i.position),t.f=t.g+t.h,l?r.rescoreElement(t):r.push(t))}}return null}}export{a as default};
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- class r{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(){const t=this.content[0],e=this.content.pop();return this.content.length>0&&(this.content[0]=e,this.sinkDown(0)),t}remove(t){const e=this.content.length;for(let n=0;n<e;n++){if(this.content[n]!=t)continue;const i=this.content.pop();if(n==e-1)break;this.content[n]=i,this.bubbleUp(n),this.sinkDown(n);break}}size(){return this.content.length}bubbleUp(t){const e=this.content[t],n=this.scoreFunction(e);for(;t>0;){const i=Math.floor((t+1)/2)-1,o=this.content[i];if(n>=this.scoreFunction(o))break;this.content[i]=e,this.content[t]=o,t=i}}includes(t){return this.content.includes(t)}sinkDown(t){const e=this.content.length,n=this.content[t],i=this.scoreFunction(n);for(;;){const o=(t+1)*2,c=o-1;let s=null,h;if(c<e){const l=this.content[c];h=this.scoreFunction(l),h<i&&(s=c)}if(o<e){const l=this.content[o];this.scoreFunction(l)<(s==null?i:h)&&(s=o)}if(s==null)break;this.content[t]=this.content[s],this.content[s]=n,t=s}}}var b=r;export{r as BinaryHeap,b as default};
3
+ class r{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(){const t=this.content[0],e=this.content.pop();return this.content.length>0&&(this.content[0]=e,this.sinkDown(0)),t}remove(t){const e=this.content.length;for(let n=0;n<e;n++){if(this.content[n]!==t)continue;const i=this.content.pop();if(n===e-1)break;this.content[n]=i,this.bubbleUp(n),this.sinkDown(n);break}}size(){return this.content.length}bubbleUp(t){const e=this.content[t],n=this.scoreFunction(e);for(;t>0;){const i=Math.floor((t+1)/2)-1,o=this.content[i];if(n>=this.scoreFunction(o))break;this.content[i]=e,this.content[t]=o,t=i}}includes(t){return this.content.includes(t)}sinkDown(t){const e=this.content.length,n=this.content[t],i=this.scoreFunction(n);for(;;){const o=(t+1)*2,c=o-1;let s=null,h;if(c<e){const l=this.content[c];h=this.scoreFunction(l),h<i&&(s=c)}if(o<e){const l=this.content[o];this.scoreFunction(l)<(s===null?i:h)&&(s=o)}if(s===null)break;this.content[t]=this.content[s],this.content[s]=n,t=s}}}var b=r;export{r as BinaryHeap,b as default};
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- class d{list=[];constructor(t){const i={};for(const s of Object.keys(t.data))for(const e of t.data[s])i[e.x<<16|e.y<<8|e.z]=!0,this.list.push(new c(s,e));for(let s=0;s<t.width;s++)for(let e=0;e<t.height;e++)for(let h=0;h<t.depth;h++)i[s<<16|e<<8|h]||this.list.push(new c("SPECIAL.air.none",{x:s,y:e,z:h}));const n=new Map;for(const s of this.list)n.set(s.positionStr,s);for(const s of this.list){const e=[{x:s.x+1,y:s.y,z:s.z},{x:s.x-1,y:s.y,z:s.z},{x:s.x,y:s.y+1,z:s.z},{x:s.x,y:s.y-1,z:s.z},{x:s.x,y:s.y,z:s.z+1},{x:s.x,y:s.y,z:s.z-1}];for(const h of e){const r=`${h.x},${h.y},${h.z}`,a=n.get(r);a&&s.canLink(a,this)&&s.links.push(a)}}}at(t,i,n){if(!this.nodeMap){this.nodeMap=new Map;for(const e of this.list){const h=`${e.x},${e.y},${e.z}`;this.nodeMap.set(h,e)}}const s=`${t},${i},${n}`;return this.nodeMap.get(s)}clean(){for(const t of this.list)t.f=0,t.g=0,t.h=0,t.visited=void 0,t.parent=void 0,t.closed=void 0}hasLineOfSight(t,i){const n=i.x-t.x,s=i.y-t.y,e=i.z-t.z,h=Math.max(Math.abs(n),Math.abs(s),Math.abs(e)),r=n/h,a=s/h,y=e/h;let l=t.x,o=t.y,f=t.z;for(let u=0;u<=h;u++){const x=this.at(Math.round(l),Math.round(o),Math.round(f));if(x&&x.isSolid())return!1;l+=r,o+=a,f+=y}return!0}}class c{constructor(t,i){this.x=i.x,this.y=i.y,this.z=i.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=void 0,this.parent=void 0,this.closed=void 0,this.links=[],this.isStair()&&(i.ry?this.ry=i.ry:this.ry=0)}isSolid(){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,i){const n=this.x-t.x,s=this.z-t.z,e=this.y-t.y,h=Math.abs(n),r=Math.abs(e),a=Math.abs(s);if(h+r+a===0||h+a>1||this.isSolid()||t.isSolid())return!1;const y=i.at(this.x,this.y-1,this.z),l=i.at(t.x,t.y-1,t.z);if(!y||!l)return!1;const o={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":return!!(e===1&&t.canWalkThrough()||(y.canWalkOn()||y.isLadder())&&(t.meshType==="none"||t.meshType==="ladder"&&r===0||t.meshType==="wedge"&&e===0&&n===-o[t.ry].x&&s===-o[t.ry].z));case"ladder":return!!(r===1&&t.canWalkThrough()||r===0&&y.canWalkOn()||t.meshType==="ladder"&&(r===1||y.canWalkOn()&&l.canWalkOn()));case"wedge":return this.x+o[this.ry].x===t.x&&this.z+o[this.ry].z===t.z&&this.y+1===t.y||this.x-o[this.ry].x===t.x&&this.z-o[this.ry].z===t.z&&(this.y===t.y||this.y-1===t.y);default:return!1}}flatCenter(){return{x:this.x+.5,y:this.y+0,z:this.z+.5}}flatRadialDistance(t){const i=this.flatCenter();return Math.hypot(i.x-t.x,i.z-t.z)}}var p=c;export{c as MapNode,d as NodeList,p as default};
3
+ class u{constructor(t,i){this.x=i.x,this.y=i.y,this.z=i.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()&&(i.ry?this.ry=i.ry: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,i){const r=this.x-t.x,s=this.z-t.z,e=this.y-t.y,h=Math.abs(r),n=Math.abs(e),l=Math.abs(s);if(h+n+l===0||h+l>1||this.isFull()||t.isFull())return!1;const o=i.at(this.x,this.y-1,this.z),y=i.at(t.x,t.y-1,t.z);if(!o||!y)return!1;const a={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":return!!(e===1&&t.canWalkThrough()||(o.canWalkOn()||o.isLadder())&&(t.meshType==="none"||t.meshType==="ladder"&&n===0||t.meshType==="wedge"&&e===0&&r===-a[t.ry].x&&s===-a[t.ry].z));case"ladder":return!!(n===1&&t.canWalkThrough()||n===0&&o.canWalkOn()||t.meshType==="ladder"&&(n===1||o.canWalkOn()&&y.canWalkOn()));case"wedge":return this.x+a[this.ry].x===t.x&&this.z+a[this.ry].z===t.z&&this.y+1===t.y||this.x-a[this.ry].x===t.x&&this.z-a[this.ry].z===t.z&&(this.y===t.y||this.y-1===t.y);default:return!1}}flatCenter(){return{x:this.x+.5,y:this.y+0,z:this.z+.5}}flatRadialDistance(t){const i=this.flatCenter();return Math.hypot(i.x-t.x,i.z-t.z)}}class p{list=[];constructor(t){const i={};for(const s of Object.keys(t.data))for(const e of t.data[s])i[e.x<<16|e.y<<8|e.z]=!0,this.list.push(new u(s,e));for(let s=0;s<t.width;s++)for(let e=0;e<t.height;e++)for(let h=0;h<t.depth;h++)i[s<<16|e<<8|h]||this.list.push(new u("SPECIAL.air.none",{x:s,y:e,z:h}));const r=new Map;for(const s of this.list)r.set(s.positionStr,s);for(const s of this.list){const e=[{x:s.x+1,y:s.y,z:s.z},{x:s.x-1,y:s.y,z:s.z},{x:s.x,y:s.y+1,z:s.z},{x:s.x,y:s.y-1,z:s.z},{x:s.x,y:s.y,z:s.z+1},{x:s.x,y:s.y,z:s.z-1}];for(const h of e){const n=`${h.x},${h.y},${h.z}`,l=r.get(n);l&&s.canLink(l,this)&&s.links.push(l)}}}at(t,i,r){if(!this.nodeMap){this.nodeMap=new Map;for(const e of this.list){const h=`${e.x},${e.y},${e.z}`;this.nodeMap.set(h,e)}}const s=`${t},${i},${r}`;return this.nodeMap.get(s)}clean(){for(const t of this.list)t.f=0,t.g=0,t.h=0,t.visited=null,t.parent=null,t.closed=null}hasLineOfSight(t,i){const r=i.x-t.x,s=i.y-t.y,e=i.z-t.z,h=Math.max(Math.abs(r),Math.abs(s),Math.abs(e)),n=r/h,l=s/h,o=e/h;let y=t.x,a=t.y,c=t.z;for(let f=0;f<=h;f++){const x=this.at(Math.round(y),Math.round(a),Math.round(c));if(x&&x.isFull())return!1;y+=n,a+=l,c+=o}return!0}}var d=u;export{u as MapNode,p as NodeList,d as default};
@@ -7,8 +7,29 @@ export interface QueryResponse {
7
7
  [key: string]: any;
8
8
  }
9
9
 
10
- export function queryServices(request: QueryRequest, proxy?: string, instance?: string): Promise<QueryResponse | string>;
11
- export function loginWithCredentials(email: string, password: string, proxy?: string, instance?: string): Promise<QueryResponse | string>;
12
- export function loginWithRefreshToken(refreshToken: string, proxy?: string, instance?: string): Promise<QueryResponse | string>;
13
- export function loginAnonymously(proxy?: string, instance?: string): Promise<QueryResponse | string>;
14
- export function createAccount(email: string, password: string, proxy?: string, instance?: string): Promise<QueryResponse | string>;
10
+ interface APIParams {
11
+ instance?: string;
12
+ protocol?: string;
13
+ httpProxy?: string;
14
+ socksProxy?: string;
15
+ maxRetries?: number;
16
+ }
17
+
18
+ export class API {
19
+ instance: string;
20
+ protocol: string;
21
+
22
+ httpProxy: string;
23
+ socksProxy: string;
24
+
25
+ maxRetries: number;
26
+
27
+ constructor(params?: APIParams);
28
+
29
+ queryServices(request: QueryRequest): Promise<QueryResponse | string>;
30
+
31
+ loginWithCredentials(email: string, password: string): Promise<QueryResponse | string>;
32
+ loginWithRefreshToken(refreshToken: string): Promise<QueryResponse | string>;
33
+ loginAnonymously(): Promise<QueryResponse | string>;
34
+ createAccount(email: string, password: string): Promise<QueryResponse | string>;
35
+ }
@@ -12,23 +12,23 @@ type intents = {
12
12
  DEBUG_BEST_TARGET: 14
13
13
  }
14
14
 
15
- import { NodeList } from '../pathing/mapnode.js';
16
-
17
15
  import { Character, GamePlayer, Position } from './bot/GamePlayer';
18
16
  import { Challenge } from './constants/challenges';
19
17
  import { AnyGun } from './constants/guns';
20
18
  import { Map } from './constants/maps';
21
19
  import { ADispatch } from './dispatches/index';
20
+ import { NodeList } from './pathing/mapnode';
21
+ import { API } from './api';
22
22
  import { Matchmaker, RawGameData } from './matchmaker';
23
23
  import yolkws from './socket';
24
24
 
25
25
  export interface BotParams {
26
26
  intents?: number[];
27
- doUpdate?: boolean;
28
- updateInterval?: number;
29
27
  proxy?: string;
28
+ httpProxy?: string;
30
29
  instance?: string;
31
30
  protocol?: string;
31
+ apiMaxRetries?: number;
32
32
  }
33
33
 
34
34
  export interface ChiknWinnerStatus {
@@ -218,13 +218,23 @@ export interface Pathing {
218
218
  activeNodeIdx: number;
219
219
  }
220
220
 
221
+ export interface BufferFrame {
222
+ controlKeys: number;
223
+ yaw: number;
224
+ pitch: number;
225
+ shotsFired: number;
226
+ }
227
+
221
228
  export interface BotState {
222
229
  name: string;
223
230
  weaponIdx: number;
224
231
  reloading: boolean;
225
232
  swappingGun: boolean;
226
233
  usingMelee: boolean;
234
+ stateIdx: number;
235
+ serverStateIdx: number;
227
236
  shotsFired: number;
237
+ buffer: BufferFrame[];
228
238
  quit: boolean;
229
239
  }
230
240
 
@@ -237,25 +247,26 @@ export interface ChiknWinnerResponse {
237
247
  export class Bot {
238
248
  static Intents: intents;
239
249
  Intents: intents;
250
+ intents: number[];
240
251
 
241
252
  proxy: string;
242
- autoUpdate: boolean;
243
- disablePathing: boolean;
244
- updateInterval: number;
253
+ httpProxy: string;
245
254
  instance: string;
246
255
  protocol: string;
256
+
247
257
  state: BotState;
248
258
  players: Record<string, GamePlayer>;
249
259
  me: GamePlayer;
250
260
  game: Game;
251
261
  account: Account;
262
+
252
263
  ping: number;
253
264
  lastPingTime: number;
254
265
  lastDeathTime: number;
255
266
  lastChatTime: number;
256
- lastUpdateTime: number;
257
- controlKeys: number;
258
267
  pathing: Pathing;
268
+
269
+ api: API;
259
270
  matchmaker: Matchmaker | null;
260
271
 
261
272
  constructor(params?: BotParams);
@@ -1,5 +1,6 @@
1
- import { GameModes, PlayTypes } from './constants/index.js';
2
- import yolkws from './socket.js';
1
+ import { API } from './api';
2
+ import { GameModes } from './constants/index';
3
+ import yolkws from './socket';
3
4
 
4
5
  type MatchmakerParams = {
5
6
  instance?: string;
@@ -7,6 +8,7 @@ type MatchmakerParams = {
7
8
  proxy?: string;
8
9
  sessionId?: string;
9
10
  noLogin?: boolean;
11
+ api?: API;
10
12
  };
11
13
 
12
14
  type Region = {
@@ -19,11 +21,6 @@ type FindGameParams = {
19
21
  mode: keyof typeof GameModes;
20
22
  };
21
23
 
22
- type RegionListResponse = {
23
- command: 'regionList';
24
- regionList: Region[];
25
- };
26
-
27
24
  export interface RawGameData {
28
25
  command: 'gameFound';
29
26
  region: string;
@@ -43,6 +40,8 @@ export declare class Matchmaker {
43
40
  connected: boolean;
44
41
  onceConnected: Function[];
45
42
 
43
+ api: API;
44
+
46
45
  proxy: string | null;
47
46
  sessionId: string;
48
47
  onListeners: Map<string, Function[]>;
@@ -0,0 +1,25 @@
1
+ import { Position } from '../bot/GamePlayer';
2
+
3
+ interface Node {
4
+ position: Position;
5
+ links: Node[];
6
+ visited: boolean;
7
+ parent: Node | null;
8
+ g: number;
9
+ h: number;
10
+ f: number;
11
+ }
12
+
13
+ interface List {
14
+ clean(): void;
15
+ }
16
+
17
+ declare class AStar {
18
+ constructor(list: List);
19
+ list: List;
20
+ heuristic(pos1: Position, pos2: Position): number;
21
+ reversePath(node: Node): Node[];
22
+ path(start: Node, end: Node): Node[] | null;
23
+ }
24
+
25
+ export default AStar;