yolkbot 1.0.19 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/browser/build/global.js +2 -2
- package/browser/build/module.js +2 -2
- package/dist/api.js +1 -1
- package/dist/bot/GamePlayer.js +1 -1
- package/dist/bot.js +1 -1
- package/dist/comm/CommIn.js +1 -1
- package/dist/comm/CommOut.js +1 -1
- package/dist/comm/index.js +1 -1
- package/dist/constants/CloseCode.js +3 -0
- package/dist/constants/{codes.js → CommCode.js} +1 -1
- package/dist/constants/guns.js +1 -1
- package/dist/constants/index.js +1 -1
- package/dist/constants/notices.js +3 -0
- package/dist/constants/regions.js +3 -0
- package/dist/constants/shellYoutube.js +1 -1
- package/dist/dispatches/BanPlayerDispatch.js +3 -0
- package/dist/dispatches/BootPlayerDispatch.js +1 -1
- package/dist/dispatches/ChatDispatch.js +1 -1
- package/dist/dispatches/MeleeDispatch.js +1 -1
- package/dist/dispatches/PauseDispatch.js +1 -1
- package/dist/dispatches/ReloadDispatch.js +1 -1
- package/dist/dispatches/ReportPlayerDispatch.js +1 -1
- package/dist/dispatches/SaveLoadoutDispatch.js +1 -1
- package/dist/dispatches/SpawnDispatch.js +1 -1
- package/dist/dispatches/SwapWeaponDispatch.js +1 -1
- package/dist/dispatches/SwitchTeamDispatch.js +1 -1
- package/dist/dispatches/ThrowGrenadeDispatch.js +1 -1
- package/dist/dispatches/index.js +1 -1
- package/dist/matchmaker.js +1 -1
- package/dist/socket.js +1 -1
- package/dist/types/bot/GamePlayer.d.ts +12 -10
- package/dist/types/bot.d.ts +89 -8
- package/dist/types/comm/CommIn.d.ts +5 -2
- package/dist/types/comm/CommOut.d.ts +19 -6
- package/dist/types/comm/index.d.ts +2 -6
- package/dist/types/{comm/Codes.d.ts → constants/CloseCode.d.ts} +3 -1
- package/dist/types/constants/{codes.d.ts → CommCode.d.ts} +3 -1
- package/dist/types/constants/guns.d.ts +17 -150
- package/dist/types/constants/index.d.ts +34 -17
- package/dist/types/constants/items.d.ts +1 -1
- package/dist/types/constants/notices.d.ts +4 -0
- package/dist/types/constants/regions.d.ts +6 -0
- package/dist/types/dispatches/BanPlayerDispatch.d.ts +15 -0
- package/dist/types/dispatches/index.d.ts +8 -0
- package/dist/types/matchmaker.d.ts +1 -25
- package/package.json +2 -2
- package/dist/comm/Codes.js +0 -3
- package/dist/comm/OutBuffer.js +0 -3
- package/dist/comm/Pool.js +0 -3
- package/dist/types/comm/OutBuffer.d.ts +0 -24
- package/dist/types/comm/Pool.d.ts +0 -20
package/dist/api.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import n from"./globals.js";import d from"./socket.js";import{FirebaseKey as c,UserAgent as p}from"./constants/index.js";const h={origin:"https://shellshock.io","user-agent":p,"x-client-version":"Chrome/JsCore/9.17.2/FirebaseCore-web","x-firebase-locale":"en"};class f{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,this.suppressErrors=e.suppressErrors||!1}queryServices=async e=>{let r,t=0;const s=async()=>{try{r=new d(`${this.protocol}://${this.instance}/services/`,this.socksProxy),r.onerror=async o=>(t++,console.error(o),await new Promise(i=>setTimeout(i,100)),await s())}catch{if(t>this.maxRetries)return"max_retries_exceeded";await new Promise(o=>setTimeout(o,100)),await s()}};return await s(),new Promise(o=>{r.onopen=()=>{r.onerror=null,r.send(JSON.stringify(e))};let i=!1;r.onmessage=a=>{i=!0;try{const l=JSON.parse(a.data);o(l)}catch{this.suppressErrors||(console.error("queryServices: Bad API JSON response with call: "+e.cmd+" and data:",JSON.stringify(e)),console.error("queryServices: Full data sent: ",JSON.stringify(e))),o("bad_json")}r.close()},r.onerror=()=>!i&&o("unknown_socket_error"),r.onclose=()=>!i&&o("services_closed_early")})};#e=async(e,r,t)=>{if(!e||!r)return"firebase_no_credentials";let s,o;try{s=await(await n.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:${t}?key=${c}`,{method:"POST",body:JSON.stringify({email:e,password:r,returnSecureToken:!0}),headers:{...h,"content-type":"application/json"},dispatcher:this.httpProxy?new n.ProxyAgent(this.httpProxy):void 0})).json(),o=s.idToken}catch(a){return a.code==="auth/network-request-failed"?(this.suppressErrors||console.error("loginWithCredentials: Network req failed (auth/network-request-failed)"),"firebase_network_failed"):a.code==="auth/missing-email"?"firebase_no_credentials":a.code==="ERR_BAD_REQUEST"?(this.suppressErrors||console.error("loginWithCredentials: Error:",e,r),this.suppressErrors||console.error("loginWithCredentials: Error:",a.response?.data||a),"firebase_bad_request"):(this.suppressErrors||console.error("loginWithCredentials: Error:",e,r,a),"firebase_unknown_error")}if(!o)return this.suppressErrors||console.error("loginWithCredentials: the game sent no idToken",s),"firebase_no_token";this.idToken=o;const i=await this.queryServices({cmd:"auth",firebaseToken:o});return typeof i=="object"?{firebase:s,...i}:i};createAccount=async(e,r)=>await this.#e(e,r,"signUp");loginWithCredentials=async(e,r)=>await this.#e(e,r,"signInWithPassword");loginWithRefreshToken=async e=>{if(!e)return"firebase_no_credentials";const r=new URLSearchParams;r.append("grant_type","refresh_token"),r.append("refresh_token",e);let t,s;try{t=await(await n.fetch(`https://securetoken.googleapis.com/v1/token?key=${c}`,{method:"POST",body:r,headers:{...h,"content-type":"application/x-www-form-urlencoded"},dispatcher:this.httpProxy?new n.ProxyAgent(this.httpProxy):void 0})).json(),s=t.id_token}catch(i){return i.code==="auth/network-request-failed"?(this.suppressErrors||console.error("loginWithRefreshToken: Network req failed (auth/network-request-failed)"),"firebase_network_failed"):i.code==="auth/missing-email"?"firebase_no_credentials":(this.suppressErrors||console.error("loginWithRefreshToken: Error:",i,e),"firebase_unknown_error")}if(!s)return this.suppressErrors||console.error("loginWithRefreshToken: the game sent no idToken",t),"firebase_no_token";this.idToken=s;const o=await this.queryServices({cmd:"auth",firebaseToken:s});return typeof o=="object"?{firebase:t,...o}:o};loginAnonymously=async()=>{const r=await(await n.fetch("https://identitytoolkit.googleapis.com/v1/accounts:signUp?key="+c,{method:"POST",body:JSON.stringify({returnSecureToken:!0}),headers:{...h,"content-type":"application/json"},dispatcher:this.httpProxy?new n.ProxyAgent(this.httpProxy):void 0})).json(),t=r.idToken;if(!t)return this.suppressErrors||console.error("loginAnonymously: the game sent no idToken",r),"firebase_no_token";this.idToken=t;const s=await this.queryServices({cmd:"auth",firebaseToken:t});return typeof s=="object"?{firebase:r,...s}:s};sendEmailVerification=async(e=this.idToken)=>{if(!e)return"no_idtoken_passed";const t=await(await n.fetch("https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode?key="+c,{method:"POST",body:JSON.stringify({requestType:"VERIFY_EMAIL",idToken:e}),headers:{...h,"content-type":"application/json"},dispatcher:this.httpProxy?new n.ProxyAgent(this.httpProxy):void 0})).json();return t.kind!=="identitytoolkit#GetOobConfirmationCodeResponse"?(this.suppressErrors||console.error("sendEmailVerification: the game sent an invalid response",t),"firebase_invalid_response"):t.email};verifyOobCode=async e=>{if(!e)return"no_oob_code_passed";const t=await(await n.fetch("https://www.googleapis.com/identitytoolkit/v3/relyingparty/setAccountInfo?key="+c,{method:"POST",body:JSON.stringify({oobCode:e}),headers:{...h,"x-client-version":"Chrome/JsCore/3.7.5/FirebaseCore-web",referer:"https://shellshockio-181719.firebaseapp.com/","content-type":"application/json"},dispatcher:this.httpProxy?new n.ProxyAgent(this.httpProxy):void 0})).json();return t.emailVerified?t.email:(this.suppressErrors||console.error("verifyOobCode: the game sent an invalid response",t),"firebase_invalid_response")}}var w=f;export{f as API,w as default};
|
package/dist/bot/GamePlayer.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
import{GunList as
|
|
3
|
+
import{GunList as n,Movement as m,ShellStreak as c,SocialMedia as d}from"../constants/index.js";import{Cluck9mm as u}from"../constants/guns.js";const f=Object.fromEntries(Object.entries(d).map(([o,s])=>[s,o.toLowerCase()]));class l{constructor(s,t=null){this.id=s.id,this.uniqueId=s.uniqueId,this.name=s.name,this.safeName=s.safeName,this.team=s.team,this.playing=s.playing,this.socials=s.social&&JSON.parse(s.social),this.socials&&this.socials.forEach(i=>i.type=f[i.id]),this.isVip=s.upgradeProductId>0,this.showBadge=!s.hideBadge||!1,this.position={x:s.x,y:s.y,z:s.z},this.jumping=s.$controlKeys&m.Jump,this.climbing=!1,this.view={yaw:s.yaw,pitch:s.pitch},this.updateKotcZone(t),this.character={eggColor:s.shellColor,primaryGun:s.primaryWeaponItem,secondaryGun:s.secondaryWeaponItem,stamp:s.stampItem,hat:s.hatItem,grenade:s.grenadeItem,melee:s.meleeItem,stampPos:{x:s.stampPosX,y:s.stampPosY}},this.stats={totalKills:s.totalKills,totalDeaths:s.totalDeaths,bestStreak:s.bestStreak},this.activeGun=s.weaponIdx,this.selectedGun=s.charClass,this.weapons=[],this.character.primaryGun&&(this.weapons[0]=new n[this.selectedGun],this.weapons[1]=new u),this.grenades=1,this.streak=s.score,this.streakRewards=Object.values(c).filter(i=>s.activeShellStreaks&i),this.hp=s.hp,this.hpShield=0,this.spawnShield=s.shield,this.randomSeed=0}updateKotcZone(s){if(!s)return this.inKotcZone=!1;const t=Math.floor(this.position.x),i=Math.floor(this.position.y),h=Math.floor(this.position.z);this.inKotcZone=s.some(e=>e.x===t&&e.y===i&&e.z===h)&&this.playing}}var w=l;export{l as GamePlayer,w as default};
|
package/dist/bot.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
import Z from"./api.js";import s from"./comm/CommIn.js";import k from"./comm/CommOut.js";import{CloseCode as j}from"./comm/Codes.js";import{CommCode as c}from"./constants/codes.js";import S from"./bot/GamePlayer.js";import W from"./matchmaker.js";import q from"./socket.js";import{ChiknWinnerDailyLimit as $,CollectType as G,CoopState as w,findItemById as p,FramesBetweenSyncs as U,GameAction as E,GameMode as g,GunList as Y,ItemType as X,Movement as b,PlayType as J,ProxiesEnabled as Q,RawGameModes as F,RawGameOptionFlags as M,ShellStreak as m,StateBufferSize as v}from"./constants/index.js";import R from"./dispatches/LookAtPosDispatch.js";import A from"./dispatches/MovementDispatch.js";import{NodeList as V}from"./pathing/mapnode.js";import{coords as tt}from"./wasm/wrapper.js";import{fetchMap as et,initKotcZones as st}from"./util.js";import{Challenges as at}from"./constants/challenges.js";import{Maps as y}from"./constants/maps.js";const O=Object.fromEntries(Object.entries(w).map(([I,t])=>[t,I.toLowerCase()])),L=Object.fromEntries(Object.entries(g).map(([I,t])=>[t,I])),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,NO_AFK_KICK:16,LOAD_MAP:17},C=(I,t)=>(I%t+t)%t;class it{static Intents=B;Intents=B;#e=[];#t={};#i=[];#n;#o;constructor(t={}){t.proxy&&!Q&&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)&&(p(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,inGame:!1,chatLines:0,yaw:0,pitch:0,controlKeys:0,reloading:!1,swappingGun:!1,usingMelee:!1,stateIdx:0,serverStateIdx:0,shotsFired:0,buffer:[],left:!1},this.players={},this.me=new S({}),this.game={raw:{},code:"",socket:null,gameModeId:0,gameMode:L[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:w.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,emailVerified:!1,isAged:!1,eggBalance:0,rawLoginData:{}},this.#n=this.account,this.matchmaker=null,this.api=new Z({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.lastUpdateTick=0,this.pathing={nodeList:null,followingPath:!1,activePath:null,activeNode:null,activeNodeIdx:0},this.hasQuit=!1,this.intents.includes(this.Intents.NO_AFK_KICK)&&(this.afkKickInterval=0)}dispatch(t){return t.validate(this)?(t.check(this)?t.execute(this):this.#e.push(t),!0):!1}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.eggBalance=t.currentBalance,this.account.emailVerified=t.emailVerified,this.account.firebaseId=t.firebaseId,this.account.id=t.id,this.account.isAged=new Date(t.dateCreated).getTime()<17145468e5,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 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 this.matchmaker.waitForConnect(),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.id)),i.error&&i.error==="gameNotFound")return this.processError(`Game ${t} not found (likely expired).`),this.leave(),"gameNotFound"};this.matchmaker.on("msg",a),this.matchmaker.send({command:"joinGame",id:t,observe:!1,sessionId:this.account.sessionId})})):"matchmakerInitFail"}async findPublicGame(t){return this.matchmaker||this.initMatchmaker(),this.matchmaker?await this.matchmaker.findPublicGame(t):!1}async createPrivateGame(t={}){if(!await this.initMatchmaker())return!1;if(!t.region&&!this.matchmaker.regionList&&!this.matchmaker.regionList.length)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(typeof F[t.mode]!="number")return this.processError("invalid mode passed to createPrivateGame");t.map||(t.map=y[y.length*Math.random()|0].name);const e=y.find(o=>o.name.toLowerCase()===t.map.toLowerCase()),a=y.indexOf(e);return a===-1?this.processError("invalid map, see the Maps constant for a list"):(await this.matchmaker.waitForConnect(),await new Promise(o=>{const n=r=>{r.command==="gameFound"&&(this.matchmaker.off("msg",n),o(r))};this.matchmaker.on("msg",n),this.matchmaker.send({command:"findGame",region:t.region,playType:J.CreatePrivate,gameType:F[t.mode],sessionId:this.account.sessionId,noobLobby:!1,map:a})}))}async join(t,e){if(this.state.name=t||"yolkbot",typeof e=="string"){e.includes("#")&&(e=e.split("#")[1]);const i=await this.#c(e);if(i==="matchmakerInitFail")return this.processError("failed to create matchmaker, you may be ratelimited (try a vpn?)");if(i==="gameNotFound")return this.processError("game not found, it may have expired or been deleted");if(!this.game.raw.id)return this.processError("an internal error occured while joining the game, please report this to developers")}if(typeof e=="object"){if(this.account.id===0&&await this.loginAnonymously(),this.game.raw=e,this.game.code=this.game.raw.id,!this.game.raw.id)return this.processError("invalid game object passed to join (missing id)");if(!this.game.raw.subdomain)return this.processError("invalid game object passed to join (missing subdomain)");if(!this.game.raw.uuid)return this.processError("invalid game object passed to join (missing uuid)")}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 o=>(this.processError(o),await new Promise(n=>setTimeout(n,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 A(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.state.controlKeys&b.Forward||this.dispatch(new A(b.Forward))}}update(){if(!this.hasQuit){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.state.chatLines=Math.max(0,this.state.chatLines-1/(30*4)),this.me.playing){const t=this.state.stateIdx;if(this.intents.includes(this.Intents.DEBUG_BUFFER)&&(console.log("setting buffer for idx",t),console.log("checking...shotsFired",this.state.shotsFired)),this.me.jumping=!!(this.state.controlKeys&b.Jump),this.state.buffer[t]={controlKeys:this.state.controlKeys,yaw:this.state.yaw,pitch:this.state.pitch,shotsFired:this.state.shotsFired},this.state.shotsFired=0,this.lastUpdateTick>=2){this.emit("tick");const e=k.getBuffer();e.packInt8(c.syncMe),e.packInt8(this.state.stateIdx),e.packInt8(this.state.serverStateIdx);const a=C(this.state.stateIdx-U+1,v);for(let i=0;i<U;i++){const o=C(a+i,v);this.intents.includes(this.Intents.DEBUG_BUFFER)&&console.log("going with",this.state.stateIdx,a,o,this.state.buffer[o]),e.packInt8(this.state.buffer[o]?.controlKeys||0),e.packInt8(this.state.buffer[o]?.shotsFired||0);const n=this.state.buffer[o]?.yaw||this.state.yaw,r=this.state.buffer[o]?.pitch||this.state.pitch,d=tt(n,r);e.packString(d),e.packInt8(100)}e.send(this.game.socket),this.state.buffer=[],this.lastUpdateTick=0}else this.lastUpdateTick++;this.state.stateIdx=C(this.state.stateIdx+1,v)}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){e?this.#t[t]=this.#t[t].filter(a=>a!==e):this.#t[t]=[]}emit(t,...e){if(!this.hasQuit){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?p(s.unPackInt16U()):s.unPackInt16U(),secondaryWeaponItem:e?p(s.unPackInt16U()):s.unPackInt16U(),shellColor:s.unPackInt8U(),hatItem:e?p(s.unPackInt16U()):s.unPackInt16U(),stampItem:e?p(s.unPackInt16U()):s.unPackInt16U(),stampPosX:s.unPackInt8(),stampPosY:s.unPackInt8(),grenadeItem:e?p(s.unPackInt16U()):s.unPackInt16U(),meleeItem:e?p(s.unPackInt16U()):s.unPackInt16U(),x:s.unPackFloat(),y:s.unPackFloat(),z:s.unPackFloat(),$dx:s.unPackFloat(),$dy:s.unPackFloat(),$dz:s.unPackFloat(),yaw:s.unPackRadU(),pitch:s.unPackRad(),score:s.unPackInt32U(),kills:s.unPackInt16U(),deaths:s.unPackInt16U(),streak:s.unPackInt16U(),totalKills:s.unPackInt32U(),totalDeaths:s.unPackInt32U(),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()};this.game.mapIdx=s.unPackInt8U(),this.game.isPrivate=s.unPackInt8U()===1,this.game.gameModeId=s.unPackInt8U();const i=new S(a,this.game.gameMode===g.KOTC?this.game.activeZone:null);this.players[a.id]||(this.players[a.id]=i),this.emit("playerJoin",i),this.me.id===a.id&&(this.me=i,this.emit("botJoin",this.me))}#m(){const t=s.unPackInt8U(),e=s.unPackInt16U(),a=s.unPackFloat(),i=s.unPackFloat(),o=s.unPackFloat(),n=s.unPackInt8U(),r=s.unPackInt8U(),d=s.unPackInt8U(),u=s.unPackInt8U(),f=s.unPackInt8U(),h=this.players[t];h&&(h.playing=!0,h.randomSeed=e,h.weapons[0]&&h.weapons[0].ammo&&(h.weapons[0].ammo.rounds=n),h.weapons[0]&&h.weapons[0].ammo&&(h.weapons[0].ammo.store=r),h.weapons[1]&&h.weapons[1].ammo&&(h.weapons[1].ammo.rounds=d),h.weapons[1]&&h.weapons[1].ammo&&(h.weapons[1].ammo.store=u),h.grenades=f,h.position={x:a,y:i,z:o},h.spawnShield=120,this.emit("playerRespawn",h))}#u(){const t=s.unPackInt8U(),e=s.unPackFloat(),a=s.unPackFloat(),i=s.unPackFloat(),o=s.unPackInt8U(),n=this.players[t];if(!n||n.id===this.me.id){for(let u=0;u<U;u++)s.unPackInt8U(),s.unPackRadU(),s.unPackRad(),s.unPackInt8U();return}for(let u=0;u<U;u++)s.unPackInt8U()&b.Jump?n.jumping=!0:n.jumping=!1,n.view.yaw=s.unPackRadU(),n.view.pitch=s.unPackRad(),s.unPackInt8U();const r=n.position.x!==e||n.position.y!==a||n.position.z!==i||n.climbing!==o,d=r?{...n.position}:null;if(n.position.x!==e&&(n.position.x=e),n.position.z!==i&&(n.position.z=i),(!n.jumping||Math.abs(n.position.y-a)>.5&&n.position.y!==a)&&(n.position.y=a),n.climbing!==o&&(n.climbing=o),r&&(this.emit("playerMove",n,d,n.position),this.game.gameModeId===g.KOTC)){const u=this.game.activeZone;if(!u){n.inKotcZone&&(n.inKotcZone=!1,this.emit("playerLeaveZone",n));return}const f=!!n.inKotcZone;n.updateKotcZone(u),!n.inKotcZone&&f?(n.inKotcZone=!1,this.emit("playerLeaveZone",n)):n.inKotcZone&&!f&&(n.inKotcZone=!0,this.emit("playerEnterZone",n))}}#d(){const t=s.unPackInt8U(),e=this.players[t];e&&(e.playing=!1,e.streakRewards&&(e.streakRewards=[]),this.emit("playerPause",e),e.inKotcZone&&(e.inKotcZone=!1,this.emit("playerLeaveZone",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.id===this.me.id&&(this.lastDeathTime=Date.now()),a.playing=!1,a.streak=0,a.hp=100,a.spawnShield=0,a.stats.deathsInGame++,a.stats.totalDeaths++,a.inKotcZone=!1,this.emit("playerLeaveZone",a)),i&&(i.streak++,i.stats.killsInGame++,i.stats.totalKills++,i.stats.streak=i.streak,i.streak>i.stats.bestGameStreak&&(i.stats.bestGameStreak=i.streak),i.streak>i.stats.bestOverallStreak&&(i.stats.bestOverallStreak=i.streak)),this.emit("playerDeath",a,i)}#k(){const t=s.unPackInt8U(),e={posX:s.unPackFloat(),posY:s.unPackFloat(),posZ:s.unPackFloat(),dirX:s.unPackFloat(),dirY:s.unPackFloat(),dirZ:s.unPackFloat()},a=this.players[t];if(!a)return;const i=a.weapons[a.activeGun];i&&i.ammo&&(i.ammo.rounds--,this.emit("playerFire",a,i,e))}#f(){const t=s.unPackInt16U(),e=s.unPackInt8U(),a=s.unPackFloat(),i=s.unPackFloat(),o=s.unPackFloat();this.game.collectables[e].push({id:t,x:a,y:i,z:o}),this.emit("spawnItem",e,{x:a,y:i,z:o})}#I(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=s.unPackInt8U(),i=s.unPackInt16U(),o=this.players[t];if(this.game.collectables[e]=this.game.collectables[e].filter(n=>n.id!==i),e===G.Ammo){const n=o.weapons[a];n&&n.ammo&&(n.ammo.store=Math.min(n.ammo.storeMax,n.ammo.store+n.ammo.pickup),this.emit("collectAmmo",o,n))}e===G.Grenade&&(o.grenades++,o.grenades>3&&(o.grenades=3),this.emit("collectGrenade",o))}#P(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=this.players[t];if(!a)return;const i=a.hp;a.hp=e,this.emit("playerDamage",a,i,a.hp)}#y(){const t=s.unPackInt8U();s.unPackFloat(),s.unPackFloat();const e=this.me.hp;this.me.hp=t,this.emit("playerDamage",this.me,e,this.me.hp)}#w(){const t=s.unPackInt8U(),e=this.players[t];s.unPackInt8U();const a=s.unPackInt8U(),i=s.unPackFloat(),o=s.unPackFloat(),n=s.unPackFloat();if(this.me.climbing=!!s.unPackInt8U(),s.unPackInt8U(),s.unPackInt8U(),!e)return;this.state.serverStateIdx=a;const r=e.position.x,d=e.position.y,u=e.position.z;e.position.x=i,e.position.y=o,e.position.z=n,(r!==i||d!==o||u!==n)&&this.emit("playerMove",e,{x:r,y:d,z:u},{x:i,y:o,z:n})}#U(){const t=k.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===g.Spatula){const t={...this.game};this.game.teamScore[1]=s.unPackInt16U(),this.game.teamScore[2]=s.unPackInt16U();const e={x:s.unPackFloat(),y:s.unPackFloat(),z:s.unPackFloat()},a=s.unPackInt8U(),i=s.unPackInt8U();this.game.spatula={coords:e,controlledBy:a,controlledByTeam:i},this.emit("gameStateChange",t,this.game)}else if(this.game.gameModeId===g.KOTC){const t={...this.game};this.game.stage=s.unPackInt8U(),this.game.zoneNumber=s.unPackInt8U(),this.game.capturing=s.unPackInt8U(),this.game.captureProgress=s.unPackInt16U(),this.game.numCapturing=s.unPackInt8U(),this.game.teamScore[1]=s.unPackInt8U(),this.game.teamScore[2]=s.unPackInt8U(),this.game.stageName=O[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.game.activeZone&&Object.values(this.players).forEach(e=>e.updateKotcZone(this.game.activeZone)),this.game.numCapturing<=0&&Object.values(this.players).forEach(e=>{e.inKotcZone=!1,this.emit("playerLeaveZone",e)}),this.emit("gameStateChange",t,this.game)}else this.game.gameModeId===g.Team&&(this.game.teamScore[1]=s.unPackInt16U(),this.game.teamScore[2]=s.unPackInt16U());this.game.gameModeId!==g.Spatula&&delete this.game.spatula,this.game.gameModeId!==g.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===g.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(o=>o!==e)),this.emit("playerEndStreak",a,e)}#x(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=s.unPackFloat(),i=s.unPackFloat();this.me.shieldHp=t,this.me.hp=e,this.me.shieldHp<=0?(this.me.streakRewards=this.me.streakRewards.filter(o=>o!==m.HardBoiled),this.emit("selfShieldLost",this.me.hp,{dx:a,dz:i})):this.emit("selfShieldHit",this.me.shieldHp,this.me.hp,{dx:a,dz:i})}#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 o=s.unPackInt8U();return Object.keys(M).forEach(n=>{const r=o&M[n]?1:0;this.game.options[n]=r}),this.game.options.weaponsDisabled=Array.from({length:7},()=>s.unPackInt8U()===1),this.game.options.mustUseSecondary=this.game.options.weaponsDisabled.every(n=>n),this.emit("gameOptionsChange",t,this.game.options),!1}#G(){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!==g.FFA&&(this.game.teamScore=[0,0,0]),this.game.gameModeId===g.Spatula&&(this.game.spatula.controlledBy=0,this.game.spatula.controlledByTeam=0,this.game.spatula.coords={x:0,y:0,z:0}),this.game.gameModeId===g.KOTC&&(this.game.stage=w.Capturing,this.game.zoneNumber=0,this.game.activeZone=null,this.game.capturing=0,this.game.captureProgress=0,this.game.numCapturing=0,this.game.stageName=O[w.Capturing],this.game.capturePercent=0),this.emit("gameReset"))}#E(){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=k.getBuffer();e.packInt8(c.ping),e.send(this.game.socket),this.lastPingTime=Date.now()},1e3)}#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(),o=s.unPackInt8U(),n=s.unPackInt16U(),r=s.unPackInt16U(),d=s.unPackInt16U(),u=s.unPackInt16U(),f=s.unPackInt8(),h=s.unPackInt8(),P=this.intents.includes(this.Intents.COSMETIC_DATA),N=P?p(a):a,D=P?p(i):i,K=P?p(n):n,_=P?p(r):r,z=P?p(d):d,H=P?p(u):u,l=this.players[t];if(l){const x={...l.character},T=l.selectedGun;l.character.eggColor=o,l.character.primaryGun=N,l.character.secondaryGun=D,l.character.stamp=_,l.character.hat=K,l.character.grenade=z,l.character.melee=H,l.character.stampPos.x=f,l.character.stampPos.y=h,l.selectedGun=e,l.weapons[0]=new Y[e],T!==l.selectedGun&&this.emit("playerChangeGun",l,T,l.selectedGun),x!==l.character&&this.emit("playerChangeCharacter",l,x,l.character)}}#R(){const t=s.unPackInt32U(),e=this.account.eggBalance;this.account.eggBalance=t,this.emit("balanceUpdate",e,t)}#A(){this.me.playing=!1,this.emit("respawnDenied")}#O(){const t=s.unPackInt8U(),e=this.players[t];e&&this.emit("playerMelee",e)}#L(){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)}updateGameOptions(){const t=k.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)}#B(){this.game.isPrivate=!0,this.updateGameOptions()}#N(){const t=s.unPackInt8U();let e=s.unPackInt16U();const a=s.unPackFloat(),i=s.unPackFloat(),o=s.unPackFloat(),n=s.unPackInt8U(),r=s.unPackFloat();this.intents.includes(this.Intents.COSMETIC_DATA)&&(e=p(e)),t===X.Grenade?this.emit("grenadeExplode",e,{x:a,y:i,z:o},n,r):this.emit("rocketHit",{x:a,y:i,z:o},n,r)}#D(){const t=s.unPackInt8U(),e=s.unPackFloat(),a=s.unPackFloat(),i=s.unPackFloat(),o=s.unPackFloat(),n=s.unPackFloat(),r=s.unPackFloat(),d=this.players[t];d&&(d.grenades--,this.emit("playerThrowGrenade",d,{x:e,y:a,z:i},{x:o,y:n,z:r}))}#K(){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(o=>o.id===e);this.emit("challengeComplete",a,i),a.id===this.me.id&&this.refreshChallenges()}#_(){const t=k.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=L[this.game.gameModeId],this.game.mapIdx=s.unPackInt8U(),this.game.map=y[this.game.mapIdx],this.game.playerLimit=s.unPackInt8U(),this.game.isGameOwner=s.unPackInt8U()===1,this.game.isPrivate=s.unPackInt8U()===1||this.game.isGameOwner,s.unPackInt8U(),this.intents.includes(this.Intents.LOAD_MAP)||this.intents.includes(this.Intents.PATHFINDING)){if(this.game.map.raw=await et(this.game.map.filename,this.game.map.hash),this.emit("mapLoad",this.game.map.raw),this.game.gameModeId===g.KOTC){const e=this.game.map.raw.data["DYNAMIC.capture-zone.none"];e?(this.game.map.zones=st(e),this.game.activeZone||(this.game.activeZone=this.game.map.zones[this.game.zoneNumber-1])):delete this.game.map.zones}this.intents.includes(this.Intents.PATHFINDING)&&(this.pathing.nodeList=new V(this.game.map.raw))}this.state.inGame=!0,this.lastDeathTime=Date.now();const t=k.getBuffer();if(t.packInt8(c.clientReady),t.send(this.game.socket),this.updateIntervalId=setInterval(()=>this.update(),100/3),this.intents.includes(this.Intents.PING)){this.lastPingTime=Date.now();const e=k.getBuffer();e.packInt8(c.ping),e.send(this.game.socket)}this.afkKickInterval=setInterval(()=>{if(this.state.inGame&&!this.me.playing&&Date.now()-this.lastDeathTime>=15e3){const e=k.getBuffer();e.packInt8(c.keepAlive),e.send(this.game.socket)}},15e3),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 o=s.unPackInt8U();switch(o){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.#I();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.#E();break;case c.switchTeam:this.#F();break;case c.changeCharacter:this.#M();break;case c.reload:this.#L();break;case c.explode:this.#N();break;case c.throwGrenade:this.#D();break;case c.spawnItem:this.#f();break;case c.melee:this.#O();break;case c.updateBalance:this.#R();break;case c.challengeCompleted:this.#K();break;case c.socketReady:this.#_();break;case c.gameJoined:this.#z();break;case c.gameAction:this.#G();break;case c.requestGameOptions:this.#B();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(n=>c[n]===o)} ${o}`),e&&console.error(`processPacket: It may be a result of the ${e} command (${a}).`),i=!0;break}e=Object.keys(c).find(n=>c[n]===o),a=o,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>$)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(o=>o?.playing).filter(o=>o.hp>0).filter(o=>o.id!==this.me.id).filter(o=>this.me.team===0||o.team!==this.me.team).filter(o=>!!t(o)).map(o=>({player:o,distance:Math.sqrt(Math.pow(o.position.x-this.me.position.x,2)+Math.pow(o.position.y-this.me.position.y,2)+Math.pow(o.position.z-this.me.position.z,2))})).sort((o,n)=>o.distance-n.distance);if(!a.length)return this.intents.includes(this.Intents.DEBUG_BEST_TARGET)&&console.log("no targets found"),null;const i=a.find(o=>this.canSee(o.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(o=>o.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.#t.error.length)this.emit("error",t);else throw t}leave(t=j.mainMenu){this.hasQuit||(t>-1&&(this.game?.socket?.close(t),this.state.left=!0,this.emit("leave",t)),clearInterval(this.updateIntervalId),this.#e=[],this.state.inGame=!1,this.state.chatLines=0,this.state.reloading=!1,this.state.swappingGun=!1,this.state.usingMelee=!1,this.state.stateIdx=0,this.state.serverStateIdx=0,this.state.shotsFired=0,this.state.buffer=[],this.players={},this.me=new S({}),this.game=this.#o,this.ping=0,this.lastPingTime=-1,this.lastDeathTime=-1,this.lastUpdateTick=0,this.pathing={nodeList:null,followingPath:!1,activePath:null,activeNode:null,activeNodeIdx:0})}logout(){this.account=this.#n}quit(t=!1){this.hasQuit||(this.leave(),this.matchmaker&&(this.matchmaker.close(),t||(this.matchmaker=null)),t||(delete this.account,delete this.api,delete this.game,delete this.me,delete this.players,delete this.state),clearInterval(this.afkKickInterval),this.hasQuit=!0)}}var wt=it;export{it as Bot,wt as default};
|
|
3
|
+
import Z from"./api.js";import s from"./comm/CommIn.js";import f from"./comm/CommOut.js";import W from"./constants/CloseCode.js";import c from"./constants/CommCode.js";import U from"./bot/GamePlayer.js";import $ from"./matchmaker.js";import q from"./socket.js";import{ChiknWinnerDailyLimit as Y,CollectType as T,CoopState as y,findItemById as g,FramesBetweenSyncs as w,GameAction as E,GameMode as p,GameOptionFlag as X,GunList as J,ItemType as V,Movement as b,PlayType as F,ProxiesEnabled as Q,ShellStreak as u,StateBufferSize as S}from"./constants/index.js";import G from"./dispatches/LookAtPosDispatch.js";import O from"./dispatches/MovementDispatch.js";import{NodeList as tt}from"./pathing/mapnode.js";import{coords as et}from"./wasm/wrapper.js";import{fetchMap as st,initKotcZones as at}from"./util.js";import{Challenges as it}from"./constants/challenges.js";import{Maps as R}from"./constants/maps.js";import{Regions as _}from"./constants/regions.js";const M=Object.fromEntries(Object.entries(y).map(([k,t])=>[t,k.toLowerCase()])),A=Object.fromEntries(Object.entries(p).map(([k,t])=>[t,k])),L=Object.fromEntries(Object.entries(X).map(([k,t])=>[k[0].toLowerCase()+k.slice(1),t])),N={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,NO_AFK_KICK:16,LOAD_MAP:17,OBSERVE_GAME:18,NO_REGION_CHECK:19},v=(k,t)=>(k%t+t)%t;class nt{static Intents=N;Intents=N;#e=[];#t={};#i=[];#s;#n;constructor(t={}){t.proxy&&!Q&&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)&&(g(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,inGame:!1,chatLines:0,yaw:0,pitch:0,controlKeys:0,reloading:!1,swappingGun:!1,usingMelee:!1,stateIdx:0,serverStateIdx:0,shotsFired:0,buffer:[],left:!1},this.players={},this.me=new 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.#n=this.game,this.account={id:0,firebase:{idToken:"",refreshToken:"",expiresIn:"3600",localId:""},firebaseId:"",sessionId:"",session:"",email:"",password:"",cw:{atLimit:!1,limit:0,secondsUntilPlay:0,canPlayAgain:Date.now()},loadout:{hatId:null,meleeId:0,stampId:null,classIdx:0,colorIdx:0,grenadeId:0,primaryId:[3100,3600,3400,3800,4e3,4200,4500],secondaryId:new Array(7).fill(3e3),stampPositionX:0,stampPositionY:0},ownedItemIds:[],vip:!1,emailVerified:!1,isAged:!1,eggBalance:0,adminRoles:0,rawLoginData:{},isDoubleEggWeeknd:()=>{const e=new Date().getUTCDay(),a=new Date().getUTCHours();return e>=5&&a>=20||e===6||e===0}},this.#s=this.account,this.matchmaker=null,this.api=new Z({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.lastUpdateTick=0,this.pathing={nodeList:null,followingPath:!1,activePath:null,activeNode:null,activeNodeIdx:0},this.hasQuit=!1,this.intents.includes(this.Intents.NO_AFK_KICK)&&(this.afkKickInterval=0)}dispatch(t){return t.validate(this)?(t.check(this)?t.execute(this):this.#e.push(t),!0):!1}async createAccount(t,e){this.account=this.#s,this.account.email=t,this.account.password=e;const a=await this.api.createAccount(t,e);return this.processLoginData(a)}async login(t,e){this.account=this.#s,this.account.email=t,this.account.password=e;const a=await this.api.loginWithCredentials(t,e);return this.processLoginData(a)}async loginWithRefreshToken(t){this.account=this.#s;const e=await this.api.loginWithRefreshToken(t);return this.processLoginData(e)}async loginAnonymously(){this.account=this.#s;const t=await this.api.loginAnonymously();return this.processLoginData(t)}processLoginData(t){return typeof t!="object"?(this.emit("authFail",t),t):t.banRemaining?(this.emit("banned",t.banRemaining),"account_banned"):t.playerOutput?(this.account.firebase=t.firebase||{},t=t.playerOutput,this.account.rawLoginData=t,this.account.adminRoles=t.adminRoles||0,this.account.eggBalance=t.currentBalance,this.account.emailVerified=t.emailVerified,this.account.firebaseId=t.firebaseId,this.account.id=t.id,this.account.isAged=new Date(t.dateCreated).getTime()<17145468e5,this.account.loadout=t.loadout,this.account.ownedItemIds=t.ownedItemIds,this.account.session=t.session,this.account.sessionId=t.sessionId,this.account.vip=t.active_sub==="IsVIP",this.intents.includes(this.Intents.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),t)}#a(t){this.account.challenges=[];for(const e of t){const a=it.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(){if(!this.account.sessionId&&!this.intents.includes(this.Intents.NO_LOGIN)){const t=await this.loginAnonymously();if(typeof t!="object")return t}return this.matchmaker||(this.matchmaker=new $({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 findPublicGame(t,e){return typeof t!="string"?"no_region_passed":!_.find(i=>i.id===t)&&!this.intents.includes(this.Intents.NO_REGION_CHECK)?"invalid_region_passed":typeof e!="number"?"no_mode_passed":Object.values(p).indexOf(e)===-1?"invalid_mode_passed":await this.initMatchmaker()?await new Promise(i=>{const o=n=>{n.command==="gameFound"&&(this.matchmaker.off("msg",o),i(n))};this.matchmaker.on("msg",o),this.matchmaker.send({command:"findGame",region:t,playType:F.JoinPublic,gameType:e,sessionId:this.sessionId})}):"matchmaker_init_fail"}async createPrivateGame(t,e,a){if(typeof t!="string")return"no_region_passed";if(!_.find(n=>n.id===t)&&!this.intents.includes(this.Intents.NO_REGION_CHECK))return"invalid_region_passed";if(typeof e!="number")return"no_mode_passed";if(Object.values(p).indexOf(e)===-1)return"invalid_mode_passed";if(typeof a!="string")return"no_map_passed";const i=R.findIndex(n=>n.name.toLowerCase()===a.toLowerCase());return i===-1?"invalid_map_passed":(await this.matchmaker.waitForConnect(),await new Promise(n=>{const r=m=>{m.command==="gameFound"&&(this.matchmaker.off("msg",r),n(m))};this.matchmaker.on("msg",r),this.matchmaker.send({command:"findGame",region:t,playType:F.CreatePrivate,gameType:e,sessionId:this.account.sessionId,noobLobby:!1,map:i})}))}async join(t,e){if(this.state.name=t||"yolkbot",typeof e=="string"){if(e.includes("#")&&(e=e.split("#")[1]),!await this.initMatchmaker())return"matchmakerInitFail";await this.matchmaker.waitForConnect();const i=await new Promise(o=>{const n=r=>{if(r.command==="gameFound"&&(this.matchmaker.off("msg",n),this.game.raw=r,this.game.code=r.id,o(r.id)),r.error&&r.error==="gameNotFound")return this.processError(`game "${e}" not found, it may have expired.`),this.leave(),"gameNotFound"};this.matchmaker.on("msg",n),this.matchmaker.send({command:"joinGame",id:e,observe:!1,sessionId:this.account.sessionId})});if(i==="matchmakerInitFail")return this.processError("failed to create matchmaker, you may be ratelimited (try a vpn?)");if(i==="gameNotFound")return this.processError("game not found, it may have expired or been deleted");if(!this.game.raw.id)return this.processError("an internal error occured while joining the game, please report this to developers")}if(typeof e=="object"){if(this.account.id===0&&await this.loginAnonymously(),this.game.raw=e,this.game.code=this.game.raw.id,!this.game.raw.id)return this.processError("invalid game object passed to join (missing id)");if(!this.game.raw.subdomain)return this.processError("invalid game object passed to join (missing subdomain)");if(!this.game.raw.uuid)return this.processError("invalid game object passed to join (missing uuid)")}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 o=>(this.processError(o),await new Promise(n=>setTimeout(n,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))}}#o(){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 O(0));else{let e;this.pathing.activeNodeIdx<this.pathing.activePath.length-1?(e=this.pathing.activePath[this.pathing.activeNodeIdx+1].flatCenter(),this.dispatch(new G(e))):(e=this.pathing.activePath[this.pathing.activeNodeIdx].flatCenter(),this.dispatch(new G(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.state.controlKeys&b.Forward||this.dispatch(new O(b.Forward))}}update(){if(!this.hasQuit){if(this.pathing.followingPath&&this.intents.includes(this.Intents.PATHFINDING)&&this.#o(),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.state.chatLines=Math.max(0,this.state.chatLines-1/(30*4)),this.me.playing){const t=this.state.stateIdx;if(this.intents.includes(this.Intents.DEBUG_BUFFER)&&(console.log("setting buffer for idx",t),console.log("checking...shotsFired",this.state.shotsFired)),this.me.jumping=!!(this.state.controlKeys&b.Jump),this.state.buffer[t]={controlKeys:this.state.controlKeys,yaw:this.state.yaw,pitch:this.state.pitch,shotsFired:this.state.shotsFired},this.state.shotsFired=0,this.lastUpdateTick>=2){this.emit("tick");const e=new f;e.packInt8(c.syncMe),e.packInt8(this.state.stateIdx),e.packInt8(this.state.serverStateIdx);const a=v(this.state.stateIdx-w+1,S);for(let i=0;i<w;i++){const o=v(a+i,S);this.intents.includes(this.Intents.DEBUG_BUFFER)&&console.log("going with",this.state.stateIdx,a,o,this.state.buffer[o]),e.packInt8(this.state.buffer[o]?.controlKeys||0),e.packInt8(this.state.buffer[o]?.shotsFired||0);const n=this.state.buffer[o]?.yaw||this.state.yaw,r=this.state.buffer[o]?.pitch||this.state.pitch,m=et(n,r);e.packString(m),e.packInt8(100)}e.send(this.game.socket),this.state.buffer=[],this.lastUpdateTick=0}else this.lastUpdateTick++;this.state.stateIdx=v(this.state.stateIdx+1,S)}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(u.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]}once(t,e){const a=(...i)=>{e(...i),this.off(t,a)};this.on(t,a)}onAny(t){this.#i.push(t)}off(t,e){e?this.#t[t]=this.#t[t].filter(a=>a!==e):this.#t[t]=[]}emit(t,...e){if(!this.hasQuit){if(this.#t[t])for(const a of this.#t[t])a(...e);for(const a of this.#i)a(t,...e)}}#c(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=s.unPackString().valueOf(),i=this.players[t];this.emit("chat",i,a,e)}#r(){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?g(s.unPackInt16U()):s.unPackInt16U(),secondaryWeaponItem:e?g(s.unPackInt16U()):s.unPackInt16U(),shellColor:s.unPackInt8U(),hatItem:e?g(s.unPackInt16U()):s.unPackInt16U(),stampItem:e?g(s.unPackInt16U()):s.unPackInt16U(),stampPosX:s.unPackInt8(),stampPosY:s.unPackInt8(),grenadeItem:e?g(s.unPackInt16U()):s.unPackInt16U(),meleeItem:e?g(s.unPackInt16U()):s.unPackInt16U(),x:s.unPackFloat(),y:s.unPackFloat(),z:s.unPackFloat(),$dx:s.unPackFloat(),$dy:s.unPackFloat(),$dz:s.unPackFloat(),yaw:s.unPackRadU(),pitch:s.unPackRad(),score:s.unPackInt32U(),$kills:s.unPackInt16U(),$deaths:s.unPackInt16U(),$streak:s.unPackInt16U(),totalKills:s.unPackInt32U(),totalDeaths:s.unPackInt32U(),bestStreak:s.unPackInt16U(),$bestOverallStreak:s.unPackInt16U(),shield:s.unPackInt8U(),hp:s.unPackInt8U(),playing:s.unPackInt8U(),weaponIdx:s.unPackInt8U(),$controlKeys:s.unPackInt8U(),upgradeProductId:s.unPackInt8U(),activeShellStreaks:s.unPackInt8U(),social:s.unPackLongString(),hideBadge:s.unPackInt8U()};this.game.mapIdx=s.unPackInt8U(),this.game.isPrivate=s.unPackInt8U()===1,this.game.gameModeId=s.unPackInt8U();const i=new U(a,this.game.gameMode===p.KOTC?this.game.activeZone:null);this.players[a.id]||(this.players[a.id]=i),this.emit("playerJoin",i),this.me.id===a.id&&(this.me=i,this.emit("botJoin",this.me))}#h(){const t=s.unPackInt8U(),e=s.unPackInt16U(),a=s.unPackFloat(),i=s.unPackFloat(),o=s.unPackFloat(),n=s.unPackInt8U(),r=s.unPackInt8U(),m=s.unPackInt8U(),d=s.unPackInt8U(),I=s.unPackInt8U(),h=this.players[t];h&&(h.playing=!0,h.randomSeed=e,h.weapons[0]&&h.weapons[0].ammo&&(h.weapons[0].ammo.rounds=n),h.weapons[0]&&h.weapons[0].ammo&&(h.weapons[0].ammo.store=r),h.weapons[1]&&h.weapons[1].ammo&&(h.weapons[1].ammo.rounds=m),h.weapons[1]&&h.weapons[1].ammo&&(h.weapons[1].ammo.store=d),h.grenades=I,h.position={x:a,y:i,z:o},h.spawnShield=120,this.emit("playerRespawn",h))}#l(){const t=s.unPackInt8U(),e=s.unPackFloat(),a=s.unPackFloat(),i=s.unPackFloat(),o=s.unPackInt8U(),n=this.players[t];if(!n||n.id===this.me.id){for(let d=0;d<w;d++)s.unPackInt8U(),s.unPackRadU(),s.unPackRad(),s.unPackInt8U();return}for(let d=0;d<w;d++)s.unPackInt8U()&b.Jump?n.jumping=!0:n.jumping=!1,n.view.yaw=s.unPackRadU(),n.view.pitch=s.unPackRad(),s.unPackInt8U();const r=n.position.x!==e||n.position.y!==a||n.position.z!==i||n.climbing!==o,m=r?{...n.position}:null;if(n.position.x!==e&&(n.position.x=e),n.position.z!==i&&(n.position.z=i),(!n.jumping||Math.abs(n.position.y-a)>.5&&n.position.y!==a)&&(n.position.y=a),n.climbing!==o&&(n.climbing=o),r&&(this.emit("playerMove",n,m,n.position),this.game.gameModeId===p.KOTC)){const d=this.game.activeZone;if(!d){n.inKotcZone&&(n.inKotcZone=!1,this.emit("playerLeaveZone",n));return}const I=!!n.inKotcZone;n.updateKotcZone(d),!n.inKotcZone&&I?(n.inKotcZone=!1,this.emit("playerLeaveZone",n)):n.inKotcZone&&!I&&(n.inKotcZone=!0,this.emit("playerEnterZone",n))}}#m(){const t=s.unPackInt8U(),e=this.players[t];e&&(e.playing=!1,e.streakRewards&&(e.streakRewards=[]),this.emit("playerPause",e),e.inKotcZone&&(e.inKotcZone=!1,this.emit("playerLeaveZone",e)))}#u(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=this.players[t];a&&(a.activeGun=e,this.emit("playerSwapWeapon",a,e))}#d(){const t=s.unPackInt8U(),e=s.unPackInt8U();s.unPackInt8U(),s.unPackInt8U(),s.unPackInt8U();const a=this.players[t],i=this.players[e];a&&(a.id===this.me.id&&(this.lastDeathTime=Date.now()),a.playing=!1,a.streak=0,a.hp=100,a.spawnShield=0,a.stats.totalDeaths++,a.inKotcZone=!1,this.emit("playerLeaveZone",a)),i&&(i.streak++,i.stats.totalKills++,i.streak>i.stats.bestStreak&&(i.stats.bestStreak=i.streak)),this.emit("playerDeath",a,i)}#p(){const t=s.unPackInt8U(),e={posX:s.unPackFloat(),posY:s.unPackFloat(),posZ:s.unPackFloat(),dirX:s.unPackFloat(),dirY:s.unPackFloat(),dirZ:s.unPackFloat()},a=this.players[t];if(!a)return;const i=a.weapons[a.activeGun];i&&i.ammo&&(i.ammo.rounds--,this.emit("playerFire",a,i,e))}#g(){const t=s.unPackInt16U(),e=s.unPackInt8U(),a=s.unPackFloat(),i=s.unPackFloat(),o=s.unPackFloat();this.game.collectables[e].push({id:t,x:a,y:i,z:o}),this.emit("spawnItem",e,{x:a,y:i,z:o})}#k(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=s.unPackInt8U(),i=s.unPackInt16U(),o=this.players[t];if(this.game.collectables[e]=this.game.collectables[e].filter(n=>n.id!==i),e===T.Ammo){const n=o.weapons[a];n&&n.ammo&&(n.ammo.store=Math.min(n.ammo.storeMax,n.ammo.store+n.ammo.pickup),this.emit("collectAmmo",o,n))}e===T.Grenade&&(o.grenades++,o.grenades>3&&(o.grenades=3),this.emit("collectGrenade",o))}#f(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=this.players[t];if(!a)return;const i=a.hp;a.hp=e,this.emit("playerDamage",a,i,a.hp)}#I(){const t=s.unPackInt8U();s.unPackFloat(),s.unPackFloat();const e=this.me.hp;this.me.hp=t,this.emit("playerDamage",this.me,e,this.me.hp)}#P(){const t=s.unPackInt8U(),e=this.players[t];s.unPackInt8U();const a=s.unPackInt8U(),i=s.unPackFloat(),o=s.unPackFloat(),n=s.unPackFloat();if(this.me.climbing=!!s.unPackInt8U(),s.unPackInt8U(),s.unPackInt8U(),!e)return;this.state.serverStateIdx=a;const r=e.position.x,m=e.position.y,d=e.position.z;e.position.x=i,e.position.y=o,e.position.z=n,(r!==i||m!==o||d!==n)&&this.emit("playerMove",e,{x:r,y:m,z:d},{x:i,y:o,z:n})}#y(){const t=new f;t.packInt8(c.eventModifier),t.send(this.game.socket)}#w(){const t=s.unPackInt8U(),e={...this.players[t]};delete this.players[t.toString()],this.emit("playerLeave",e)}#b(){if(this.game.gameModeId===p.Spatula){const t={...this.game};this.game.teamScore[1]=s.unPackInt16U(),this.game.teamScore[2]=s.unPackInt16U();const e={x:s.unPackFloat(),y:s.unPackFloat(),z:s.unPackFloat()},a=s.unPackInt8U(),i=s.unPackInt8U();this.game.spatula={coords:e,controlledBy:a,controlledByTeam:i},this.emit("gameStateChange",t,this.game)}else if(this.game.gameModeId===p.KOTC){const t={...this.game};this.game.stage=s.unPackInt8U(),this.game.zoneNumber=s.unPackInt8U(),this.game.capturing=s.unPackInt8U(),this.game.captureProgress=s.unPackInt16U(),this.game.numCapturing=s.unPackInt8U(),this.game.teamScore[1]=s.unPackInt8U(),this.game.teamScore[2]=s.unPackInt8U(),this.game.stageName=M[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.game.activeZone&&Object.values(this.players).forEach(e=>e.updateKotcZone(this.game.activeZone)),this.game.numCapturing<=0&&Object.values(this.players).forEach(e=>{e.inKotcZone=!1,this.emit("playerLeaveZone",e)}),this.emit("gameStateChange",t,this.game)}else this.game.gameModeId===p.Team&&(this.game.teamScore[1]=s.unPackInt16U(),this.game.teamScore[2]=s.unPackInt16U());this.game.gameModeId!==p.Spatula&&delete this.game.spatula,this.game.gameModeId!==p.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===p.FFA&&delete this.game.teamScore}#U(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=this.players[t];switch(e){case u.HardBoiled:t===this.me.id&&(this.me.shieldHp=100),a.streakRewards.push(u.HardBoiled);break;case u.EggBreaker:a.streakRewards.push(u.EggBreaker);break;case u.Restock:{a.grenades=3,a.weapons[0]&&a.weapons[0].ammo&&(a.weapons[0].ammo.rounds=a.weapons[0].ammo.capacity,a.weapons[0].ammo.store=a.weapons[0].ammo.storeMax),a.weapons[1]&&a.weapons[1].ammo&&(a.weapons[1].ammo.rounds=a.weapons[1].ammo.capacity,a.weapons[1].ammo.store=a.weapons[1].ammo.storeMax);break}case u.OverHeal:a.hp=Math.min(200,a.hp+100),a.streakRewards.push(u.OverHeal);break;case u.DoubleEggs:a.streakRewards.push(u.DoubleEggs);break;case u.MiniEgg:a.streakRewards.push(u.MiniEgg);break}this.emit("playerBeginStreak",a,e)}#S(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=this.players[t];[u.EggBreaker,u.OverHeal,u.DoubleEggs,u.MiniEgg].includes(e)&&a.streakRewards.includes(e)&&(a.streakRewards=a.streakRewards.filter(o=>o!==e)),this.emit("playerEndStreak",a,e)}#v(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=s.unPackFloat(),i=s.unPackFloat();this.me.shieldHp=t,this.me.hp=e,this.me.shieldHp<=0?(this.me.streakRewards=this.me.streakRewards.filter(o=>o!==u.HardBoiled),this.emit("selfShieldLost",this.me.hp,{dx:a,dz:i})):this.emit("selfShieldHit",this.me.shieldHp,this.me.hp,{dx:a,dz:i})}#C(){const 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 o=s.unPackInt8U();Object.keys(L).forEach(n=>{const r=o&L[n]?1:0;this.game.options[n]=r}),this.game.options.weaponsDisabled=Array.from({length:7},()=>s.unPackInt8U()===1),this.game.options.mustUseSecondary=this.game.options.weaponsDisabled.every(n=>n),this.emit("gameOptionsChange",t,this.game.options)}#x(){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!==p.FFA&&(this.game.teamScore=[0,0,0]),this.game.gameModeId===p.Spatula&&(this.game.spatula.controlledBy=0,this.game.spatula.controlledByTeam=0,this.game.spatula.coords={x:0,y:0,z:0}),this.game.gameModeId===p.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=M[y.Capturing],this.game.capturePercent=0),this.emit("gameReset"))}#T(){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=new f;e.packInt8(c.ping),e.send(this.game.socket),this.lastPingTime=Date.now()},1e3)}#E(){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)}#F(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=s.unPackInt16U(),i=s.unPackInt16U(),o=s.unPackInt8U(),n=s.unPackInt16U(),r=s.unPackInt16U(),m=s.unPackInt16U(),d=s.unPackInt16U(),I=s.unPackInt8(),h=s.unPackInt8(),P=this.intents.includes(this.Intents.COSMETIC_DATA),B=P?g(a):a,D=P?g(i):i,K=P?g(n):n,H=P?g(r):r,j=P?g(m):m,z=P?g(d):d,l=this.players[t];if(l){const C={...l.character},x=l.selectedGun;l.character.eggColor=o,l.character.primaryGun=B,l.character.secondaryGun=D,l.character.stamp=H,l.character.hat=K,l.character.grenade=j,l.character.melee=z,l.character.stampPos.x=I,l.character.stampPos.y=h,l.selectedGun=e,l.weapons[0]=new J[e],x!==l.selectedGun&&this.emit("playerChangeGun",l,x,l.selectedGun),C!==l.character&&this.emit("playerChangeCharacter",l,C,l.character)}}#G(){const t=s.unPackInt32U(),e=this.account.eggBalance;this.account.eggBalance=t,this.emit("balanceUpdate",e,t)}#O(){this.me.playing=!1,this.emit("respawnDenied")}#R(){const t=s.unPackInt8U(),e=this.players[t];e&&this.emit("playerMelee",e)}#_(){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)}updateGameOptions(){const t=new f;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)}#M(){this.game.isPrivate=!0,this.updateGameOptions()}#A(){const t=s.unPackInt8U();let e=s.unPackInt16U();const a=s.unPackFloat(),i=s.unPackFloat(),o=s.unPackFloat(),n=s.unPackInt8U(),r=s.unPackFloat();this.intents.includes(this.Intents.COSMETIC_DATA)&&(e=g(e)),t===V.Grenade?this.emit("grenadeExplode",e,{x:a,y:i,z:o},n,r):this.emit("rocketHit",{x:a,y:i,z:o},n,r)}#L(){const t=s.unPackInt8U(),e=s.unPackFloat(),a=s.unPackFloat(),i=s.unPackFloat(),o=s.unPackFloat(),n=s.unPackFloat(),r=s.unPackFloat(),m=this.players[t];m&&(m.grenades--,this.emit("playerThrowGrenade",m,{x:e,y:a,z:i},{x:o,y:n,z:r}))}#N(){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(o=>o.id===e);this.emit("challengeComplete",a,i),a.id===this.me.id&&this.refreshChallenges()}#B(){const t=new f;t.packInt8(this.intents.includes(this.Intents.OBSERVE_GAME)?c.observeGame: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#D(){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=R[this.game.mapIdx],this.game.playerLimit=s.unPackInt8U(),this.game.isGameOwner=s.unPackInt8U()===1,this.game.isPrivate=s.unPackInt8U()===1||this.game.isGameOwner,s.unPackInt8U(),this.intents.includes(this.Intents.LOAD_MAP)||this.intents.includes(this.Intents.PATHFINDING)){if(this.game.map.raw=await st(this.game.map.filename,this.game.map.hash),this.emit("mapLoad",this.game.map.raw),this.game.gameModeId===p.KOTC){const e=this.game.map.raw.data["DYNAMIC.capture-zone.none"];e?(this.game.map.zones=at(e),this.game.activeZone||(this.game.activeZone=this.game.map.zones[this.game.zoneNumber-1])):delete this.game.map.zones}this.intents.includes(this.Intents.PATHFINDING)&&(this.pathing.nodeList=new tt(this.game.map.raw))}this.state.inGame=!0,this.lastDeathTime=Date.now();const t=new f;if(t.packInt8(c.clientReady),t.send(this.game.socket),this.updateIntervalId=setInterval(()=>this.update(),100/3),this.intents.includes(this.Intents.PING)){this.lastPingTime=Date.now();const e=new f;e.packInt8(c.ping),e.send(this.game.socket)}this.afkKickInterval=setInterval(()=>{if(this.state.inGame&&!this.me.playing&&Date.now()-this.lastDeathTime>=15e3){const e=new f;e.packInt8(c.keepAlive),e.send(this.game.socket)}},15e3),this.emit("gameReady")}#K(){const t=s.unPackInt8U(),e=s.unPackString(128),a=s.unPackString(32);if(!this.players[t])return;const i=this.players[t];i.admin={ip:a,dbId:e},this.emit("playerInfo",i,a,e)}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 o=s.unPackInt8U();switch(o){case c.syncThem:this.#l();break;case c.fire:this.#p();break;case c.hitThem:this.#f();break;case c.syncMe:this.#P();break;case c.hitMe:this.#I();break;case c.swapWeapon:this.#u();break;case c.collectItem:this.#k();break;case c.respawn:this.#h();break;case c.die:this.#d();break;case c.pause:this.#m();break;case c.chat:this.#c();break;case c.addPlayer:this.#r();break;case c.removePlayer:this.#w();break;case c.eventModifier:this.#y();break;case c.metaGameState:this.#b();break;case c.beginShellStreak:this.#U();break;case c.endShellStreak:this.#S();break;case c.hitMeHardBoiled:this.#v();break;case c.gameOptions:this.#C();break;case c.ping:this.#T();break;case c.switchTeam:this.#E();break;case c.changeCharacter:this.#F();break;case c.reload:this.#_();break;case c.explode:this.#A();break;case c.throwGrenade:this.#L();break;case c.spawnItem:this.#g();break;case c.melee:this.#R();break;case c.updateBalance:this.#G();break;case c.challengeCompleted:this.#N();break;case c.socketReady:this.#B();break;case c.gameJoined:this.#D();break;case c.gameAction:this.#x();break;case c.requestGameOptions:this.#M();break;case c.respawnDenied:this.#O();break;case c.playerInfo:this.#K();break;case c.expireUpgrade:case c.clientReady:break;case c.musicInfo:s.unPackLongString();break;default:console.error(`processPacket: I got but couldn't identify a: ${Object.keys(c).find(n=>c[n]===o)} ${o}`),e&&console.error(`processPacket: It may be a result of the ${e} command (${a}).`),i=!0;break}e=Object.keys(c).find(n=>c[n]===o),a=o,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>Y)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(o=>o?.playing).filter(o=>o.hp>0).filter(o=>o.id!==this.me.id).filter(o=>this.me.team===0||o.team!==this.me.team).filter(o=>!!t(o)).map(o=>({player:o,distance:Math.sqrt(Math.pow(o.position.x-this.me.position.x,2)+Math.pow(o.position.y-this.me.position.y,2)+Math.pow(o.position.z-this.me.position.z,2))})).sort((o,n)=>o.distance-n.distance);if(!a.length)return this.intents.includes(this.Intents.DEBUG_BEST_TARGET)&&console.log("no targets found"),null;const i=a.find(o=>this.canSee(o.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(o=>o.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.#t.error.length)this.emit("error",t);else throw t}leave(t=W.mainMenu){this.hasQuit||(t>-1&&(this.game?.socket?.close(t),this.state.left=!0,this.emit("leave",t)),clearInterval(this.updateIntervalId),this.#e=[],this.state.inGame=!1,this.state.chatLines=0,this.state.reloading=!1,this.state.swappingGun=!1,this.state.usingMelee=!1,this.state.stateIdx=0,this.state.serverStateIdx=0,this.state.shotsFired=0,this.state.buffer=[],this.players={},this.me=new U({}),this.game=this.#n,this.ping=0,this.lastPingTime=-1,this.lastDeathTime=-1,this.lastUpdateTick=0,this.pathing={nodeList:null,followingPath:!1,activePath:null,activeNode:null,activeNodeIdx:0})}logout(){this.account=this.#s}quit(t=!1){this.hasQuit||(this.leave(),this.matchmaker&&(this.matchmaker.close(),t||delete this.matchmaker),t||(delete this.account,delete this.api,delete this.game,delete this.me,delete this.pathing,delete this.players,delete this.state,this.#s={},this.#n={},this.#t={},this.#i=[],this.#e=[]),clearInterval(this.afkKickInterval),this.hasQuit=!0)}}var Ut=nt;export{nt as Bot,Ut as default};
|
package/dist/comm/CommIn.js
CHANGED
|
@@ -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
|
|
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 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{a as CommIn,u as default};
|
package/dist/comm/CommOut.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
class h{constructor(t=16384){this.idx=0,this.arrayBuffer=new ArrayBuffer(t),this.buffer=new Uint8Array(this.arrayBuffer,0,t)}send(t){const i=new Uint8Array(this.arrayBuffer,0,this.idx);t.send(i)}packInt8(t){this.buffer[this.idx]=t&255,this.idx++}packInt16(t){this.buffer[this.idx]=t&255,this.buffer[this.idx+1]=t>>8&255,this.idx+=2}packInt24(t){this.buffer[this.idx]=t&255,this.buffer[this.idx+1]=t>>8&255,this.buffer[this.idx+2]=t>>16&255,this.idx+=3}packInt32(t){this.buffer[this.idx]=t&255,this.buffer[this.idx+1]=t>>8&255,this.buffer[this.idx+2]=t>>16&255,this.buffer[this.idx+3]=t>>24&255,this.idx+=4}packRadU(t){this.packInt24(t*2097152)}packRad(t){this.packInt16((t+Math.PI)*8192)}packFloat(t){this.packInt16(t*256)}packDouble(t){this.packInt32(t*1048576)}packString(t){typeof t!="string"&&(t=""),this.packInt8(t.length);for(let i=0;i<t.length;i++)this.packInt16(t.charCodeAt(i))}packLongString(t){typeof t!="string"&&(t=""),this.packInt16(t.length);for(let i=0;i<t.length;i++)this.packInt16(t.charCodeAt(i))}}var s=h;export{h as CommOut,s as default};
|
package/dist/comm/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
import o from"./CommIn.js";import m from"./CommOut.js";import r from"
|
|
3
|
+
import o from"./CommIn.js";import m from"./CommOut.js";import r from"../constants/CommCode.js";import t from"../constants/CloseCode.js";export{t as CloseCode,r as CommCode,o as CommIn,m as CommOut};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
|
|
3
|
+
const e={gameNotFound:4e3,gameFull:4001,badName:4002,mainMenu:4003,gameIdleExceeded:4004,corruptedLoginData0:4005,corruptedLoginData1:4006,corruptedLoginData2:4007,corruptedLoginData3:4008,corruptedLoginData4:4009,corruptedLoginData5:4010,gameMaxPlayersExceeded:4011,gameDestroyUser:4012,joinGameOutOfOrder:4013,gameShuttingDown:4014,readyBeforeReady:4015,booted:4016,gameErrorOnUserSocket:4017,uuidNotFound:4018,sessionNotFound:4019,clusterFullCpu:4020,clusterFullMem:4021,noClustersAvailable:4022,locked:4023};var o=e;export{e as CloseCode,o as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
const e={swapWeapon:0,joinGame:1,refreshGameState:2,spawnItem:3,observeGame:4,ping:5,bootPlayer:6,banPlayer:7,loginRequired:8,gameLocked:9,reportPlayer:10,switchTeam:13,changeCharacter:14,pause:15,gameOptions:16,gameAction:17,requestGameOptions:18,gameJoined:19,socketReady:20,addPlayer:21,removePlayer:22,fire:23,melee:24,throwGrenade:25,eventModifier:27,hitThem:28,hitMe:29,collectItem:30,challengeResetInGame:31,chat:34,syncThem:35,die:37,beginShellStreak:38,endShellStreak:39,updateBalance:42,reload:43,respawn:44,respawnDenied:45,clientReady:47,requestRespawn:48,switchTeamFail:51,expireUpgrade:52,metaGameState:53,syncMe:54,explode:55,keepAlive:56,musicInfo:57,hitMeHardBoiled:58,playerInfo:59,challengeCompleted:60};export{e as CommCode};
|
|
3
|
+
const e={swapWeapon:0,joinGame:1,refreshGameState:2,spawnItem:3,observeGame:4,ping:5,bootPlayer:6,banPlayer:7,loginRequired:8,gameLocked:9,reportPlayer:10,switchTeam:13,changeCharacter:14,pause:15,gameOptions:16,gameAction:17,requestGameOptions:18,gameJoined:19,socketReady:20,addPlayer:21,removePlayer:22,fire:23,melee:24,throwGrenade:25,eventModifier:27,hitThem:28,hitMe:29,collectItem:30,challengeResetInGame:31,chat:34,syncThem:35,die:37,beginShellStreak:38,endShellStreak:39,updateBalance:42,reload:43,respawn:44,respawnDenied:45,clientReady:47,requestRespawn:48,switchTeamFail:51,expireUpgrade:52,metaGameState:53,syncMe:54,explode:55,keepAlive:56,musicInfo:57,hitMeHardBoiled:58,playerInfo:59,challengeCompleted:60};var a=e;export{e as CommCode,a as default};
|
package/dist/constants/guns.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
const t=class{constructor(){this.
|
|
3
|
+
const t=class{constructor(){this.adsMod=.5,this.burst=0,this.burstRof=0,this.movementAccuracyMod=1,this.radius=0,this.reloadBloom=!0,this.reloadTimeMod=1,this.tracer=0}},a=class extends t{constructor(){super(),this.ammo={rounds:30,capacity:30,reload:30,store:240,storeMax:240,pickup:30},this.longReloadTime=205,this.shortReloadTime=160,this.weaponName="EggK-47",this.internalName="Eggk47",this.standardMeshName="eggk47",this.automatic=!0,this.damage=30,this.range=20,this.recoil=7,this.rof=3,this.totalDamage=30,this.velocity=1.5,this.accuracyMin=.15,this.accuracyMax=.03,this.accuracyLoss=.05,this.accuracyRecover=.025,this.tracer=1}},i=class extends t{constructor(){super(),this.ammo={rounds:2,capacity:2,reload:2,store:24,storeMax:24,pickup:8},this.longReloadTime=155,this.shortReloadTime=155,this.weaponName="Scrambler",this.internalName="Dozen Gauge",this.standardMeshName="dozenGauge",this.automatic=!1,this.damage=8.5,this.range=8,this.recoil=10,this.rof=8,this.totalDamage=170,this.velocity=1,this.accuracyMin=.16,this.accuracyMax=.13,this.accuracyLoss=.17,this.accuracyRecover=.02,this.adsMod=.6,this.movementAccuracyMod=.2,this.tracer=0}},e=class extends t{constructor(){super(),this.ammo={rounds:15,capacity:15,reload:15,store:60,storeMax:60,pickup:15},this.longReloadTime=225,this.shortReloadTime=165,this.weaponName="Free Ranger",this.internalName="CSG-1",this.standardMeshName="csg1",this.automatic=!1,this.damage=105,this.range=50,this.recoil=13,this.rof=13,this.totalDamage=105,this.velocity=1.75,this.accuracyMin=.3,this.accuracyMax=.004,this.accuracyLoss=.3,this.accuracyRecover=.025,this.tracer=0}},c=class extends t{constructor(){super(),this.ammo={rounds:15,capacity:15,reload:15,store:60,storeMax:60,pickup:15},this.longReloadTime=195,this.shortReloadTime=160,this.weaponName="Cluck 9mm",this.internalName="Cluck 9mm",this.standardMeshName="cluck9mm",this.automatic=!1,this.damage=26,this.range=15,this.recoil=6,this.rof=4,this.totalDamage=26,this.velocity=1,this.accuracyMin=.15,this.accuracyMax=.035,this.accuracyLoss=.09,this.accuracyRecover=.08,this.adsMod=.8,this.movementAccuracyMod=.6,this.tracer=0}},o=class extends t{constructor(){super(),this.ammo={rounds:1,capacity:1,reload:1,store:3,storeMax:3,pickup:1},this.longReloadTime=170,this.shortReloadTime=170,this.weaponName="RPEGG",this.internalName="Eggsploder",this.standardMeshName="rpegg",this.automatic=!1,this.damage=140,this.range=45,this.recoil=60,this.rof=40,this.totalDamage=192.5,this.velocity=.4,this.accuracyMin=.3,this.accuracyMax=.015,this.accuracyLoss=.3,this.accuracyRecover=.02,this.radius=2.75}},r=class extends t{constructor(){super(),this.ammo={rounds:40,capacity:40,reload:40,store:200,storeMax:200,pickup:40},this.longReloadTime=225,this.shortReloadTime=190,this.weaponName="Whipper",this.internalName="SMEGG",this.standardMeshName="smg",this.automatic=!0,this.damage=23,this.range=20,this.recoil=7,this.rof=2,this.totalDamage=23,this.velocity=1.25,this.accuracyMin=.19,this.accuracyMax=.06,this.accuracyLoss=.045,this.accuracyRecover=.05,this.adsMod=.6,this.movementAccuracyMod=.7,this.tracer=2}},h=class extends t{constructor(){super(),this.ammo={rounds:1,capacity:1,reload:1,store:12,storeMax:12,pickup:4},this.longReloadTime=144,this.shortReloadTime=144,this.weaponName="Crackshot",this.internalName="M2DZ",this.standardMeshName="m24",this.automatic=!0,this.damage=170,this.range=60,this.recoil=20,this.rof=15,this.totalDamage=170,this.velocity=2,this.accuracyMin=.35,this.accuracyMax=0,this.accuracyLoss=.1,this.accuracyRecover=.023,this.movementAccuracyMod=1.3,this.reloadBloom=!1,this.reloadTimeMod=.8,this.tracer=0}},m=class extends t{constructor(){super(),this.ammo={rounds:24,capacity:24,reload:24,store:150,storeMax:150,pickup:24},this.longReloadTime=205,this.shortReloadTime=160,this.weaponName="Tri-Hard",this.internalName="AUG",this.standardMeshName="aug",this.automatic=!1,this.damage=32,this.range=20,this.recoil=18,this.rof=15,this.totalDamage=34,this.velocity=1.5,this.accuracyMin=.15,this.accuracyMax=.03,this.accuracyLoss=.037,this.accuracyRecover=.03,this.adsMod=.6,this.burst=3,this.burstRof=3,this.movementAccuracyMod=.8,this.movementInstability=2,this.tracer=0}};export{m as AUG,e as CSG1,c as Cluck9mm,i as DozenGauge,a as Eggk47,h as M24,o as RPEGG,r as SMG};
|
package/dist/constants/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
import{AUG as
|
|
3
|
+
import{AUG as t,CSG1 as o,DozenGauge as n,Eggk47 as r,M24 as a,RPEGG as i,SMG as l}from"./guns.js";import{findItemById as W}from"./findItemById.js";const s={FiveMinutes:0,FifteenMinutes:1,OneHour:2},p={Killstreak:0,KillWithWeapon:1,MovementDistance:3,Jumping:4,TimePlayed:6,TimeAlive:7,KillWithCondition:8,TotalKills:10,SpatulaKills:10,Collecting:18,FromTheCoop:20,SpecialOffensive:21,WinKOTC:23,KillWithSpatula:23},m={Kill:0,Damage:1,Death:2,Movement:3,Collect:4,Time:5,KOTC:6,Spatula:7},d={None:0,Pinned:2,Team:4,Mod:254,Server:255},u=3,x={Ammo:0,Grenade:1},S={Start:0,Score:1,Win:2,Capturing:3,Contested:4,Takeover:5,Abandoned:6,Unclaimed:7},w="AIzaSyDP4SIjKaw6A4c-zvfYxICpbEjn1rRnN50",T=3,g={Reset:1,Pause:2},k={FFA:0,Team:1,Spatula:2,KOTC:3},C={Locked:1,NoTeamChange:2,NoTeamShuffle:4},h=13,M=[r,n,o,i,l,a,t],e=typeof window<"u",f={Hat:1,Stamp:2,Primary:3,Secondary:4,Grenade:6,Melee:7},y={Forward:1,Backward:2,Left:4,Right:8,Jump:16,Fire:32,Melee:64,Scope:128},G={JoinPublic:0,CreatePrivate:1,JoinPrivate:2},v=!e&&typeof Bun>"u",B={HardBoiled:1,EggBreaker:2,Restock:4,OverHeal:8,DoubleEggs:16,MiniEgg:32},F={Facebook:0,Instagram:1,Tiktok:2,Discord:3,Youtube:4,Twitter:5,Twitch:6},K={Discord:"rew_1200",Tiktok:"rew_1208",Instagram:"rew_1219",Steam:"rew_1223",Facebook:"rew_1227",Twitter:"rew_1234",Twitch:"rew_twitch_social"},R=256,b={Blue:1,Red:2},I=["giveBasketBrosReward","mercZoneFinalGift","midMonthGiveMeEggs","newYolkerSignupReward","newYolkerItemReward","newYolkerWelcomeBack","WelcomeBack"],P=e?null:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36";export{s as BanDuration,p as ChallengeSubType,m as ChallengeType,d as ChatFlag,u as ChiknWinnerDailyLimit,x as CollectType,S as CoopState,w as FirebaseKey,T as FramesBetweenSyncs,g as GameAction,k as GameMode,C as GameOptionFlag,h as GunEquipTime,M as GunList,e as IsBrowser,f as ItemType,y as Movement,G as PlayType,v as ProxiesEnabled,B as ShellStreak,F as SocialMedia,K as SocialReward,R as StateBufferSize,b as Team,I as URLRewards,P as UserAgent,W as findItemById};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
|
|
3
|
+
const s=[{id:"germany",sub:"egs-static-live-germany-287o43bv"},{id:"santiago",sub:"egs-static-live-santiago-1s5w3cdc"},{id:"singapore",sub:"egs-static-live-singapore-5r545eei"},{id:"sydney",sub:"egs-static-live-sydney-302pa99o"},{id:"uscentral",sub:"egs-static-live-uscentral-451sa2ap"},{id:"useast",sub:"egs-static-live-useast-191w3fe4"},{id:"uswest",sub:"egs-static-live-uswest-192r5xds"}];export{s as Regions};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
const t=[{active:!0,link:"https://www.youtube.com/watch?v=
|
|
3
|
+
const t=[{active:!0,link:"https://www.youtube.com/watch?v=f-Q_P0CnHQU",desc:"",imageExt:"",id:"f-Q_P0CnHQU",author:"Blue Panda",title:"50 Kills, No One Stands a Chance",externalImg:"https://i.ytimg.com/vi/f-Q_P0CnHQU/hqdefault.jpg"},{active:!0,link:"https://www.youtube.com/watch?v=4w5Jr6s9Pds",desc:"",imageExt:"",id:"4w5Jr6s9Pds",author:"Duier",title:"1v1ing Rogue! A close 1v1!",externalImg:"https://i.ytimg.com/vi/4w5Jr6s9Pds/hqdefault.jpg"},{active:!0,link:"https://www.youtube.com/watch?v=c6mWE1a6sro",desc:"",imageExt:"",id:"c6mWE1a6sro",author:"Blue Panda",title:"Calm 21 Streak \u263A\uFE0F",externalImg:"https://i.ytimg.com/vi/c6mWE1a6sro/hqdefault.jpg"},{active:!0,link:"https://www.youtube.com/watch?v=cHULiapM2-A",desc:"",imageExt:"",id:"cHULiapM2-A",author:"Clingzter ",title:"The CRACKSHOT that traveled through time!",externalImg:"https://i.ytimg.com/vi/cHULiapM2-A/hqdefault.jpg"},{active:!0,link:"https://www.youtube.com/watch?v=9Eq-jX5XNP4",desc:"",imageExt:"",id:"9Eq-jX5XNP4",author:"sword",title:"Private Lobby Highlights",externalImg:"https://i.ytimg.com/vi/9Eq-jX5XNP4/hqdefault.jpg"},{active:!0,link:"https://www.youtube.com/watch?v=JkJxzLX4APw",desc:"",imageExt:"",id:"JkJxzLX4APw",author:"Clingzter ",title:"The Kart Side of Shell Shockers!",externalImg:"https://i.ytimg.com/vi/JkJxzLX4APw/hqdefault.jpg"},{active:!0,link:"https://www.youtube.com/watch?v=anQRwlO4azw",desc:"",imageExt:"",id:"anQRwlO4azw",author:"Meep ",title:"10 Kill Streak with Kart Guns! ",externalImg:"https://i.ytimg.com/vi/anQRwlO4azw/hqdefault.jpg"},{active:!0,link:"https://www.youtube.com/watch?v=T_ruSSXomxE",desc:"",imageExt:"",id:"T_ruSSXomxE",author:"Godric Gryffindor",title:"Kart Bros Update",externalImg:"https://i.ytimg.com/vi/T_ruSSXomxE/hqdefault.jpg"},{active:!0,link:"https://www.youtube.com/watch?v=7j7kSrF2Viw",desc:"",imageExt:"",id:"7j7kSrF2Viw",author:"Fire Dragon",title:"Cracking The Killstreak shotgun\u{1F52B}",externalImg:"https://i.ytimg.com/vi/7j7kSrF2Viw/hqdefault.jpg"},{active:!0,link:"https://www.youtube.com/watch?v=-Pj2j-PC020",desc:"",imageExt:"",id:"-Pj2j-PC020",author:"Shell League",title:"CRAZY KotC match Highlights",externalImg:"https://i.ytimg.com/vi/-Pj2j-PC020/hqdefault.jpg"},{active:!0,link:"https://www.youtube.com/watch?v=Xs5OLOpfHcc",desc:"",imageExt:"",id:"Xs5OLOpfHcc",author:"Clingzter ",title:"The Eggstra Value Pack is LOADED!!",externalImg:"https://i.ytimg.com/vi/Xs5OLOpfHcc/hqdefault.jpg"}];export{t as ShellYoutube};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
|
|
3
|
+
import n from"../comm/CommOut.js";import i from"../constants/CommCode.js";import{BanDuration as o}from"../constants/index.js";class a{constructor(e,t,r=""){this.uniqueId=e,this.duration=t,this.reason=r}validate(e){return!(typeof this.uniqueId!="string"||typeof this.reason!="string"||typeof this.duration!="number"||!Object.values(o).some(t=>this.duration===t)||!(e.account.adminRoles&4))}check(){return!0}execute(e){const t=new n;t.packInt8(i.banPlayer),t.packString(this.uniqueId),t.packString(this.reason),t.packInt8(this.duration),t.send(e.game.socket)}}var f=a;export{a as BanPlayerDispatch,f as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
import r from"../comm/CommOut.js";import
|
|
3
|
+
import r from"../comm/CommOut.js";import u from"../constants/CommCode.js";class o{constructor(e){this.uniqueId=e}validate(e){return typeof this.uniqueId=="string"&&e.game.isGameOwner&&Object.values(e.players).find(t=>t.uniqueId===this.uniqueId)}check(){return!0}execute(e){const t=new r;t.packInt8(u.bootPlayer),t.packString(this.uniqueId),t.send(e.game.socket)}}var a=o;export{o as BootPlayerDispatch,a as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
import s from"../comm/CommOut.js";import
|
|
3
|
+
import s from"../comm/CommOut.js";import a from"../constants/CommCode.js";class r{constructor(e){this.msg=e}validate(){return!(typeof this.msg!="string"||this.msg.length<1||this.msg.length>64)}check(e){return!(!e.state.inGame||!e.game.isPrivate&&!e.account.adminRoles&&e.state.chatLines>=2||!e.game.isPrivate&&!e.account.emailVerified&&!e.account.isAged)}execute(e){e.state.chatLines++;const t=new s;t.packInt8(a.chat),t.packString(this.msg),t.send(e.game.socket)}}var m=r;export{r as ChatDispatch,m as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import s from"../comm/CommOut.js";import u from"../constants/CommCode.js";import{GunEquipTime as n}from"../constants/index.js";class a{validate(){return!0}check(e){return e.me.playing&&!e.state.reloading&&!e.state.swappingGun&&!e.state.usingMelee}execute(e){const t=new s;t.packInt8(u.melee),t.send(e.game.socket),e.usingMelee=!0,setTimeout(()=>{e.usingMelee=!1,e.swappingGun=!0,setTimeout(()=>{e.swappingGun=!1},.5*n)},100/3*17)}}var l=a;export{a as MeleeDispatch,l as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
import a from"../comm/CommOut.js";import
|
|
3
|
+
import a from"../comm/CommOut.js";import m from"../constants/CommCode.js";class o{validate(){return!0}check(e){return e.me.playing}execute(e){const t=new a;t.packInt8(m.pause),t.send(e.game.socket),setTimeout(()=>e.me.playing=!1,3e3)}}var p=o;export{o as PauseDispatch,p as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
import s from"../comm/CommOut.js";import
|
|
3
|
+
import s from"../comm/CommOut.js";import r from"../constants/CommCode.js";class i{validate(){return!0}check(e){return e.me.playing&&!e.state.reloading&&!e.state.swappingGun&&!e.state.usingMelee}execute(e){const o=new s;o.packInt8(r.reload),o.send(e.game.socket);const a=e.me.weapons[e.me.activeGun];if(a.ammo){const t=Math.min(Math.min(a.ammo.capacity,a.ammo.reload)-a.ammo.rounds,a.ammo.store);a.ammo.rounds+=t,a.ammo.store-=t}e.emit("playerReload",e.me,a);const m=e.me.weapons[e.me.activeGun],n=m.ammo.rounds<1;e.state.reloading=!0,setTimeout(()=>e.state.reloading=!1,n?m.longReloadTime:m.shortReloadTime)}}var u=i;export{i as ReloadDispatch,u as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
import a from"../comm/CommOut.js";import
|
|
3
|
+
import a from"../comm/CommOut.js";import i from"../constants/CommCode.js";class n{constructor(r,e={}){this.idOrName=r,this.reasons=[!!e.cheating,!!e.harassment,!!e.offensive,!!e.other],this.reasons.includes(!0)||(this.reasons[3]=!0);for(let t=0;t<this.reasons.length;t++)this.reasons[t]===!0&&(this.reasonInt|=1<<t)}validate(){return!(this.reasons.every(e=>e===!1)||!(bot.players[this.idOrName.toString()]||bot.players.find(e=>e.name===this.idOrName)))}check(r){return r.state.inGame?!!(r.players[this.idOrName.toString()]||r.players.find(t=>t.name===this.idOrName)):!1}execute(r){const e=r.players[this.idOrName.toString()]||r.players.find(s=>s.name===this.idOrName),t=new a;t.packInt8(i.reportPlayer),t.packString(e.uniqueId),t.packInt8(this.reasonInt),t.send(r.game.socket)}}var f=n;export{n as ReportPlayerDispatch,f as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import l from"../comm/CommOut.js";import o from"../constants/CommCode.js";import{findItemById as t,GunList as f,ItemType as m}from"../constants/index.js";const i=n=>t(n)&&t(n).unlock==="default",I=(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))}validate(e){const s=this.changes;if(s.colorIdx&&s.colorIdx>=7&&!e.account.vip||s.colorIdx&&s.colorIdx>=14||I(s.hatId,m.Hat)&&!i(s.hatId)&&!e.account.ownedItemIds.includes(s.hatId)||I(s.stampId,m.Stamp)&&!i(s.stampId)&&!e.account.ownedItemIds.includes(s.stampId)||I(s.grenadeId,m.Grenade)&&!i(s.grenadeId)&&!e.account.ownedItemIds.includes(s.grenadeId)||I(s.meleeId,m.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(!I(d,ItemTypes.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(!I(d,ItemTypes.Secondary)||!i(d)&&!e.account.ownedItemIds.includes(d))return!1}return!0}check(e){return!e.me.playing}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},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.inGame){const r=new l;r.packInt8(o.changeCharacter),r.packInt8(this.changes?.classIdx||e.me.selectedGun),r.send(e.game.socket)}const d=e.intents.includes(e.Intents.COSMETIC_DATA);Object.entries(this.changes).forEach(([r,a])=>{r==="classIdx"?e.me.selectedGun=a:r==="hatId"?e.me.character.hat=d?t(a):a:r==="stampId"?e.me.character.stamp=d?t(a):a:r==="grenadeId"?e.me.character.grenade=d?t(a):a:r==="meleeId"?e.me.character.melee=d?t(a):a:r==="colorIdx"?e.me.character.eggColor=a:r==="primaryId"?e.me.character.primaryGun=d?t(a[e.me.selectedGun]):a:r==="secondaryId"&&(e.me.character.secondaryGun=d?t(a[e.me.selectedGun]):a)})})}}var y=u;export{u as SaveLoadoutDispatch,y as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
import r from"../comm/CommOut.js";import
|
|
3
|
+
import r from"../comm/CommOut.js";import n from"../constants/CommCode.js";class a{validate(){return!0}check(e){return!(e.me.playing||e.lastDeathTime+6e3<Date.now()||e.intents.includes(e.Intents.OBSERVE_GAME))}execute(e){const t=new r;t.packInt8(n.requestRespawn),t.send(e.game.socket),e.state.buffer=[]}}var i=a;export{a as SpawnDispatch,i as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
import t from"../comm/CommOut.js";import
|
|
3
|
+
import t from"../comm/CommOut.js";import p from"../constants/CommCode.js";class m{constructor(e){this.manualWeapon=e}validate(){return typeof this.manualWeapon=="number"||this.manualWeapon===void 0}check(e){return e.me.playing&&!e.state.reloading&&!e.state.swappingGun&&!e.state.usingMelee}execute(e){let n=+!e.me.activeGun;typeof this.manualWeapon=="number"&&(n=this.manualWeapon),e.me.activeGun=n;const a=new t;a.packInt8(p.swapWeapon),a.packInt8(e.me.activeGun),a.send(e.game.socket)}}var i=m;export{m as SwapWeaponDispatch,i as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import m from"../comm/CommOut.js";import i from"../constants/CommCode.js";class l{validate(){return!0}check(e){if(!e.state.inGame||e.me.playing||e.game.gameModeId===0||e.intents.includes(e.Intents.OBSERVE_GAME))return!1;if(e.game.isPrivate)return!e.game.options.noTeamChange;const t=e.players,r=e.me.team,n=t.filter(a=>a.team===r).length,s=t.filter(a=>a.team!==r).length;return!(s>n||n===s)}execute(e){const t=new m;t.packInt8(i.switchTeam),t.send(e.game.socket)}}var o=l;export{l as SwitchTeamDispatch,o as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
import r from"../comm/CommOut.js";import
|
|
3
|
+
import r from"../comm/CommOut.js";import o from"../constants/CommCode.js";class a{constructor(e=1){this.power=e}validate(){return typeof this.power=="number"&&this.power>=0&&this.power<=1}check(e){return e.me.playing&&!e.state.reloading&&!e.state.swappingGun&&!e.state.usingMelee}execute(e){const t=new r;t.packInt8(o.throwGrenade),t.packFloat(this.power),t.send(e.game.socket)}}var i=a;export{a as ThrowGrenadeDispatch,i as default};
|
package/dist/dispatches/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
import o from"./
|
|
3
|
+
import o from"./BanPlayerDispatch.js";import t from"./BootPlayerDispatch.js";import r from"./ChatDispatch.js";import p from"./FireDispatch.js";import m from"./GameOptionsDispatch.js";import i from"./GoToAmmoDispatch.js";import a from"./GoToCoopDispatch.js";import h from"./GoToGrenadeDispatch.js";import s from"./GoToPlayerDispatch.js";import e from"./GoToSpatulaDispatch.js";import c from"./LookAtDispatch.js";import f from"./LookAtPosDispatch.js";import D from"./MeleeDispatch.js";import l from"./MovementDispatch.js";import G from"./PauseDispatch.js";import n from"./ReloadDispatch.js";import T from"./ReportPlayerDispatch.js";import P from"./SaveLoadoutDispatch.js";import d from"./SpawnDispatch.js";import S from"./SwapWeaponDispatch.js";import u from"./SwitchTeamDispatch.js";import w from"./ThrowGrenadeDispatch.js";var K={BanPlayerDispatch:o,BootPlayerDispatch:t,ChatDispatch:r,FireDispatch:p,GameOptionsDispatch:m,GoToAmmoDispatch:i,GoToCoopDispatch:a,GoToGrenadeDispatch:h,GoToPlayerDispatch:s,GoToSpatulaDispatch:e,LookAtDispatch:c,LookAtPosDispatch:f,MeleeDispatch:D,MovementDispatch:l,PauseDispatch:G,ReloadDispatch:n,ReportPlayerDispatch:T,SaveLoadoutDispatch:P,SpawnDispatch:d,SwapWeaponDispatch:S,SwitchTeamDispatch:u,ThrowGrenadeDispatch:w};export{o as BanPlayerDispatch,t as BootPlayerDispatch,r as ChatDispatch,p as FireDispatch,m as GameOptionsDispatch,i as GoToAmmoDispatch,a as GoToCoopDispatch,h as GoToGrenadeDispatch,s as GoToPlayerDispatch,e as GoToSpatulaDispatch,c as LookAtDispatch,f as LookAtPosDispatch,D as MeleeDispatch,l as MovementDispatch,G as PauseDispatch,n as ReloadDispatch,T as ReportPlayerDispatch,P as SaveLoadoutDispatch,d as SpawnDispatch,S as SwapWeaponDispatch,u as SwitchTeamDispatch,w as ThrowGrenadeDispatch,K as default};
|
package/dist/matchmaker.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import r from"./api.js";import{ProxiesEnabled as h}from"./constants/index.js";import{validate as c}from"./wasm/wrapper.js";import f from"./socket.js";class a{connected=!1;onceConnected=[];regionList=[];proxy=null;sessionId="";onListeners=new Map;onceListeners=new Map;#t=!1;constructor(s={}){s.instance||(s.instance="shellshock.io"),s.protocol||(s.protocol="wss"),s.api?this.api=s.api:this.api=new r({instance:s.instance,protocol:s.protocol,proxy:s.proxy}),s.sessionId||s.noLogin?this.sessionId=s.sessionId:this.#o(),s.proxy&&!h?this.#i("proxies do not work and hence are not supported in the browser"):s.proxy&&(this.proxy=s.proxy),this.#e(s.instance,s.protocol,s.noLogin)}async#e(s,i,t){const e=async()=>{try{this.ws=new f(`${i}://${s}/matchmaker/`,this.proxy),this.ws.onerror=async o=>(this.#i(o),await new Promise(n=>setTimeout(n,100)),await e())}catch{await new Promise(o=>setTimeout(o,100)),await e()}};await e(),this.ws.onopen=()=>{this.connected=!0,this.ws.onerror=null,(this.sessionId||t)&&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:c(n.uuid)})),this.#s("msg",n)},this.ws.onclose=()=>{this.connected=!1,this.#t||this.#e(s)}}async#o(){const s=await this.api.loginAnonymously();(!s||typeof s=="string")&&this.#s("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 t=e=>{e.command==="regionList"&&(this.regionList=e.regionList,this.off("msg",t),i(e.regionList))};this.on("msg",t),this.ws.onerror=e=>s.#i("failed to get regions",e),this.ws.send(JSON.stringify({command:"regionList"}))})}close(){this.#t=!0,this.connected=!1,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(t=>t!==i)),this.onceListeners.has(s)&&this.onceListeners.set(s,this.onceListeners.get(s).filter(t=>t!==i))}#s(s,...i){this.onListeners.has(s)&&this.onListeners.get(s).forEach(t=>t(...i)),this.onceListeners.has(s)&&(this.onceListeners.get(s).forEach(t=>t(...i)),this.onceListeners.delete(s))}#i(s){if(this.onListeners.has("error"))this.#s("error",s);else throw s}}var y=a;export{a as Matchmaker,y as default};
|
package/dist/socket.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import s from"./globals.js";import{IsBrowser as n,UserAgent as o}from"./constants/index.js";class c extends s.WebSocket{constructor(e,t){n?super(e):super(e,{agent:t?new s.SocksProxyAgent(t):void 0,headers:{"accept-encoding":"gzip, deflate, br, zstd","accept-language":"en-US,en;q=0.9","cache-control":"no-cache",connection:"Upgrade",host:e.split("/")[2],origin:(e.split("/")[0]+"//"+e.split("/")[2]).replace("ws","http"),pragma:"no-cache","sec-websocket-extensions":"permessage-deflate; client_max_window_bits",upgrade:"websocket","user-agent":o}})}}var p=c;export{p as default};
|
|
@@ -29,13 +29,9 @@ export interface Character {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export interface PlayerStats {
|
|
32
|
-
killsInGame: number;
|
|
33
|
-
deathsInGame: number;
|
|
34
|
-
streak: number;
|
|
35
32
|
totalKills: number;
|
|
36
33
|
totalDeaths: number;
|
|
37
|
-
|
|
38
|
-
bestOverallStreak: number;
|
|
34
|
+
bestStreak: number;
|
|
39
35
|
}
|
|
40
36
|
|
|
41
37
|
export type PlayerTeam = 0 | 1 | 2;
|
|
@@ -66,13 +62,13 @@ export interface PlayerData {
|
|
|
66
62
|
yaw: number;
|
|
67
63
|
pitch: number;
|
|
68
64
|
score: number;
|
|
69
|
-
kills: number;
|
|
70
|
-
deaths: number;
|
|
71
|
-
streak: number;
|
|
65
|
+
$kills: number;
|
|
66
|
+
$deaths: number;
|
|
67
|
+
$streak: number;
|
|
72
68
|
totalKills: number;
|
|
73
69
|
totalDeaths: number;
|
|
74
|
-
|
|
75
|
-
bestOverallStreak: number;
|
|
70
|
+
bestStreak: number;
|
|
71
|
+
$bestOverallStreak: number;
|
|
76
72
|
shield: number;
|
|
77
73
|
hp: number;
|
|
78
74
|
playing: boolean;
|
|
@@ -93,6 +89,11 @@ export interface Social {
|
|
|
93
89
|
|
|
94
90
|
export type PlayerWeapons = [AnyGun, Cluck9mm];
|
|
95
91
|
|
|
92
|
+
export interface PlayerAdminData {
|
|
93
|
+
ip: string;
|
|
94
|
+
dbId: string;
|
|
95
|
+
}
|
|
96
|
+
|
|
96
97
|
export class GamePlayer {
|
|
97
98
|
id: string;
|
|
98
99
|
uniqueId: string;
|
|
@@ -120,6 +121,7 @@ export class GamePlayer {
|
|
|
120
121
|
hpShield: number;
|
|
121
122
|
spawnShield: number;
|
|
122
123
|
randomSeed: number;
|
|
124
|
+
admin?: PlayerAdminData;
|
|
123
125
|
|
|
124
126
|
constructor(playerData: PlayerData);
|
|
125
127
|
}
|