yolkbot 0.1.5-alpha.9 → 1.0.1

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.
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- import{GunList as o,ShellStreaks as n,SocialMedias as h}from"../constants/index.js";import{Cluck9mm as c}from"../constants/guns.js";class m{constructor(e=-1,t=0,s){this.id=e,this.team=t,this.raw=s,this.name=s.name_,this.uniqueId=s.uniqueId_,this.playing=s.playing_,this.socials=s.social_&&JSON.parse(s.social_),this.socials&&this.socials.forEach(i=>i.type=h[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=!1,this.climbing=!1,this.view={yaw:s.yaw_,pitch:s.pitch_},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.activeGun=s.weaponIdx_,this.selectedGun=s.charClass_,this.weapons=[{},{}],this.character.primaryGun&&(this.weapons[0]=new o[this.selectedGun],this.weapons[1]=new c),this.grenades=1,this.buffer={0:{},1:{},2:{}},this.streak=s.score_,this.hp=s.hp_,this.hpShield=s.shield_,this.streakRewards=Object.values(n).filter(i=>s.activeShellStreaks_&i),this.randomSeed=0,this.serverStateIdx=0}dispatch(){throw new Error("you cannot call this function from a GamePlayer. call dispatch() on an instance of Bot instead.")}join(){throw new Error("you cannot call this function from a GamePlayer. call join() on an instance of Bot instead.")}update(){throw new Error("you cannot call this function from a GamePlayer. call update() on an instance of Bot instead.")}}var _=m;export{m as GamePlayer,_ as default};
3
+ import{GunList as e,ShellStreaks as t,SocialMedias as h}from"../constants/index.js";import{Cluck9mm as o}from"../constants/guns.js";class m{constructor(s){this.id=s.id,this.name=s.name,this.uniqueId=s.uniqueId,this.team=s.team,this.playing=s.playing,this.socials=s.social&&JSON.parse(s.social),this.socials&&this.socials.forEach(i=>i.type=h[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=!1,this.climbing=!1,this.view={yaw:s.yaw,pitch:s.pitch},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={killsInGame:s.kills,deathsInGame:s.deaths,streak:s.streak,totalKills:s.totalKills,totalDeaths:s.totalDeaths,bestGameStreak:s.bestGameStreak,bestOverallStreak:s.bestOverallStreak},this.activeGun=s.weaponIdx,this.selectedGun=s.charClass,this.weapons=[],this.character.primaryGun&&(this.weapons[0]=new e[this.selectedGun],this.weapons[1]=new o),this.grenades=1,this.streak=s.score,this.streakRewards=Object.values(t).filter(i=>s.activeShellStreaks&i),this.hp=s.hp,this.hpShield=0,this.spawnShield=s.shield,this.randomSeed=0}}var u=m;export{m as GamePlayer,u as default};
package/dist/bot.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- import{createAccount as D,loginAnonymously as $,loginWithCredentials as z,loginWithRefreshToken as W,queryServices as k}from"./api.js";import s from"./comm/CommIn.js";import f from"./comm/CommOut.js";import{CommCode as c}from"./constants/codes.js";import C from"./bot/GamePlayer.js";import H from"./matchmaker.js";import j from"./socket.js";import{ChiknWinnerDailyLimit as K,CollectTypes as v,CoopStates as y,findItemById as p,FramesBetweenSyncs as w,GameActions as x,GameModes as g,GameOptionFlags as T,GunList as q,ItemTypes as Y,Movements as _,PlayTypes as Z,ProxiesEnabled as X,ShellStreaks as d}from"./constants/index.js";import R from"./dispatches/LookAtPosDispatch.js";import M from"./dispatches/MovementDispatch.js";import{NodeList as V}from"./pathing/mapnode.js";import{fetchMap as J,initKotcZones as Q}from"./util.js";import{Challenges as tt}from"./constants/challenges.js";import{Maps as U}from"./constants/maps.js";const E=Object.fromEntries(Object.entries(y).map(([P,e])=>[e,P])),O=Object.fromEntries(Object.entries(g).map(([P,e])=>[e,P])),F={CHALLENGES:1,STATS:2,PATHFINDING:3,BUFFERS:4,PING:5,COSMETIC_DATA:6,PLAYER_HEALTH:7,PACKET_HOOK:8,MONITOR:9,LOG_PACKETS:10,NO_LOGIN:11};class et{static Intents=F;Intents=F;#t=[];#s=[];#e={};#o=[];#a=[];constructor(e={}){if(e.proxy&&!X)throw new Error("proxies do not work and hence are not supported in the browser");this.intents=e.intents||[],this.instance=e.instance||"shellshock.io",this.protocol=e.protocol||"wss",this.proxy=e.proxy||"",this.autoUpdate=e.doUpdate||!0,this.updateInterval=e.updateInterval||16.5,this.state={name:"",weaponIdx:0,reloading:!1,swappingGun:!1,usingMelee:!1,shotsFired:0,quit:!1},this.players={},this.me=new C(this.id,0,{}),this.game={raw:{},code:"",socket:null,gameModeId:0,gameMode:O[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.account={id:0,firebaseId:"",sessionId:"",session:"",email:"",password:"",cw:{atLimit:!1,limit:0,secondsUntilPlay:0,canPlayAgain:Date.now()},loadout:{hatId:null,meleeId:0,stampId:null,classIdx:0,colorIdx:0,grenadeId:0,primaryId:[3100,3600,3400,3800,4e3,4200,4500],secondaryId:new Array(7).fill(3e3),stampPositionX:0,stampPositionY:0},ownedItemIds:[],vip:!1,accountAge:0,emailVerified:!1,eggBalance:0,rawLoginData:{}},this.matchmaker=null,this.ping=0,this.lastPingTime=-1,this.lastDeathTime=-1,this.lastChatTime=-1,this.lastUpdateTime=-1,this.controlKeys=0,this.pathing={nodeList:null,followingPath:!1,activePath:null,activeNode:null,activeNodeIdx:0},this.intents.includes(this.Intents.PLAYER_HEALTH)&&(this.healthIntervalId=setInterval(()=>{if(this.players){for(const t of Object.values(this.players))if(t.playing&&t.hp>0){const a=.1*(this.game.isPrivate?this.game.options.healthRegen:1);t.streakRewards.includes(d.OverHeal)?t.hp=Math.max(100,t.hp-a):t.hp=Math.min(100,t.hp+a)}}},33))}dispatch(e){this.#t.push(e)}async createAccount(e,t){this.account.email=e,this.account.password=t;const a=await D(e,t,this.proxy,`${this.protocol}://${this.instance}`);return await this.#n(a)}async login(e,t){this.account.email=e,this.account.password=t;const a=await z(e,t,this.proxy,`${this.protocol}://${this.instance}`);return await this.#n(a)}async loginWithRefreshToken(e){const t=await W(e,this.proxy,`${this.protocol}://${this.instance}`);return await this.#n(t)}async loginAnonymously(){delete this.account.email,delete this.account.password;const e=await $(this.proxy,`${this.protocol}://${this.instance}`);return await this.#n(e)}async#n(e){return typeof e!="object"?(this.emit("authFail",e),!1):e.banRemaining?(this.emit("banned",e.banRemaining),!1):e.playerOutput?(e=e.playerOutput,this.account.rawLoginData=e,this.account.accountAge=e.accountAge,this.account.eggBalance=e.currentBalance,this.account.emailVerified=e.emailVerified,this.account.firebaseId=e.firebaseId,this.account.id=e.id,this.account.loadout=e.loadout,this.account.ownedItemIds=e.ownedItemIds,this.account.session=e.session,this.account.sessionId=e.sessionId,this.account.vip=e.upgradeProductId&&!e.upgradeIsExpired,this.intents.includes(this.Intents.STATS)&&(this.account.stats={lifetime:e.statsLifetime,monthly:e.statsCurrent}),this.intents.includes(this.Intents.CHALLENGES)&&this.#i(e.challenges),this.emit("authSuccess",this.account),this.account):(this.emit("authFail",e),!1)}#i(e){this.account.challenges=[];for(const t of e){const a=tt.find(n=>n.id==t.challengeId);a&&(delete t.playerId,this.account.challenges.push({raw:{challengeInfo:a,challengeData:t},id:t.challengeId,name:a.loc.title,desc:a.loc.desc,rewardEggs:a.reward,isRerolled:!!t.reset,isClaimed:!!t.claimed,isCompleted:!!t.completed,progressNum:t.progress,goalNum:a.goal}))}}async initMatchmaker(){return!this.account.sessionId&&!this.intents.includes(this.Intents.NO_LOGIN)&&!await this.loginAnonymously()?!1:(this.matchmaker||(this.matchmaker=new H({sessionId:this.account.sessionId,proxy:this.proxy,instance:this.instance,protocol:this.protocol,noLogin:this.intents.includes(this.Intents.NO_LOGIN)}),this.matchmaker.on("authFail",e=>this.emit("authFail",e)),await this.matchmaker.getRegions()),!0)}async#r(e){return await this.initMatchmaker()?await new Promise(t=>{const a=n=>{if(n.command=="gameFound"&&(this.matchmaker.off("msg",a),this.game.raw=n,this.game.code=n.id,t()),n.error&&n.error=="gameNotFound")throw new Error(`Game ${e} not found (likely expired).`)};this.matchmaker.on("msg",a),this.matchmaker.send({command:"joinGame",id:e,observe:!1,sessionId:this.account.sessionId})}):!1}async createPrivateGame(e={}){if(!await this.initMatchmaker())return!1;if(!e.region)throw new Error('pass a region: createPrivateGame({ region: "useast", ... })');if(!this.matchmaker.regionList.find(n=>n.id==e.region))throw new Error('invalid region, see <bot>.matchmaker.regionList for a region list (pass an "id")');if(!e.mode)throw new Error('pass a mode: createPrivateGame({ mode: "ffa", ... })');if(g[e.mode]==null)throw new Error("invalid mode, see GameModes for a list");if(!e.map)throw new Error('pass a map: createPrivateGame({ map: "downfall", ... })');const t=U.find(n=>n.name.toLowerCase()==e.map.toLowerCase()),a=U.indexOf(t);if(a==-1)throw new Error("invalid map, see the Maps constant for a list");return await new Promise(n=>{const i=o=>{o.command=="gameFound"&&(this.matchmaker.off("msg",i),this.game.raw=o,this.game.code=this.game.raw.id,n())};this.matchmaker.on("msg",i),this.matchmaker.send({command:"findGame",region:e.region,playType:Z.createPrivate,gameType:g[e.mode],sessionId:this.account.sessionId,noobLobby:!1,map:a})}),this.game.raw}async join(e,t){if(this.state.name=e||"yolkbot",typeof t=="string"?(t.includes("#")&&(t=t.split("#")[1]),await this.#r(t)):typeof t=="object"&&(this.account.id==0&&await this.loginAnonymously(),this.game.raw=t,this.game.code=this.game.raw.id),!this.game.raw.id)throw new Error("invalid game data passed to <bot>.join");const a=async()=>{try{const n=this.instance.startsWith("localhost:")?this.instance:`${this.game.raw.subdomain}.${this.instance}`;this.game.socket=new j(`${this.protocol}://${n}/game/${this.game.raw.id}`,this.proxy),this.game.socket.onerror=async i=>(console.error(i),await new Promise(o=>setTimeout(o,100)),await a())}catch{await new Promise(n=>setTimeout(n,100)),await a()}};await a(),this.game.socket.binaryType="arraybuffer",this.game.socket.onopen=()=>this.game.socket.onerror=null,this.game.socket.onmessage=n=>this.processPacket(n.data),this.game.socket.onclose=n=>{this.emit("close",n.code),this.quit(!0,!0)}}#h(){if(Object.entries(this.me.position).map(t=>Math.floor(t[1])).join(",")==this.pathing.activePath[this.pathing.activePath.length-1].positionStr)this.pathing.followingPath=!1,this.pathing.activePath=null,this.pathing.activeNode=null,this.pathing.activeNodeIdx=0,this.dispatch(new M(0));else{let t;this.pathing.activeNodeIdx<this.pathing.activePath.length-1?(t=this.pathing.activePath[this.pathing.activeNodeIdx+1].flatCenter(),this.dispatch(new R(t))):(t=this.pathing.activePath[this.pathing.activeNodeIdx].flatCenter(),this.dispatch(new R(t)));for(const a of this.pathing.activePath)if(a.flatRadialDistance(this.me.position)<.1&&a.position.y==Math.floor(this.me.position.y)&&this.pathing.activePath.indexOf(a)>=this.pathing.activeNodeIdx){this.pathing.activeNodeIdx=this.pathing.activePath.indexOf(a)+1,this.pathing.activeNode=this.pathing.activePath[this.pathing.activeNodeIdx];break}this.controlKeys&_.FORWARD||this.dispatch(new M(_.FORWARD))}}update(){if(!this.state.joinedGame)throw new Error("You cannot call update() if the bot is not in a game.");if(this.state.quit)return;for(this.pathing.followingPath&&this.intents.includes(this.Intents.PATHFINDING)&&this.#h();this.#s.length>0;)this.processPacket(this.#s.shift());if(this.#t.length>0)for(let t=0;t<this.#t.length;t++){const a=this.#t[t];if(a.check(this)){a.execute(this),this.#t.splice(t,1);break}}const e=Date.now();if(e-this.lastUpdateTime>=50){if(this.emit("tick"),!this.intents.includes(this.Intents.MONITOR)){const t=f.getBuffer();t.packInt8(c.syncMe),t.packInt8(Math.random()*128|0),t.packInt8(this.me.serverStateIdx);for(let a=0;a<w;a++)t.packInt8(this.controlKeys),t.packInt8(this.state.shotsFired),t.packRadU(this.me.view.yaw),t.packRad(this.me.view.pitch),t.packInt8(100);t.send(this.game.socket)}this.lastUpdateTime=e,this.state.shotsFired=0}for(;this.#a.length>0;)this.#a.shift()()}on(e,t){Object.keys(this.#e).includes(e)?this.#e[e].push(t):this.#e[e]=[t]}onAny(e){this.#o.push(e)}#c=["authSuccess","authFail","banned","gameReady","quit"];emit(e,...t){if(!this.state.quit){if(this.#e[e])for(const a of this.#e[e])this.#c.includes(e)?a(...t):this.#a.push(()=>a(...t));for(const a of this.#o)this.#c.includes(e)?a(e,...t):this.#a.push(()=>a(e,...t))}}#l(){const e=s.unPackInt8U(),t=s.unPackInt8U(),a=s.unPackString().valueOf(),n=this.players[e];this.emit("chat",n,a,t)}#m(){const e=s.unPackInt8U(),t=this.intents.includes(this.Intents.COSMETIC_DATA),a={id_:e,uniqueId_:s.unPackString(),name_:s.unPackString(),safename_:s.unPackString(),charClass_:s.unPackInt8U(),team_:s.unPackInt8U(),primaryWeaponItem_:t?p(s.unPackInt16U()):s.unPackInt16U(),secondaryWeaponItem_:t?p(s.unPackInt16U()):s.unPackInt16U(),shellColor_:s.unPackInt8U(),hatItem_:t?p(s.unPackInt16U()):s.unPackInt16U(),stampItem_:t?p(s.unPackInt16U()):s.unPackInt16U(),stampPosX_:s.unPackInt8(),stampPosY_:s.unPackInt8(),grenadeItem_:t?p(s.unPackInt16U()):s.unPackInt16U(),meleeItem_:t?p(s.unPackInt16U()):s.unPackInt16U(),x_:s.unPackFloat(),y_:s.unPackFloat(),z_:s.unPackFloat(),dx_:s.unPackFloat(),dy_:s.unPackFloat(),dz_:s.unPackFloat(),yaw_:s.unPackRadU(),pitch_:s.unPackRad(),score_:s.unPackInt32U(),kills_:s.unPackInt16U(),deaths_:s.unPackInt16U(),streak_:s.unPackInt16U(),totalKills_:s.unPackInt32U(),totalDeaths_:s.unPackInt32U(),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()};a.gameData_={},a.gameData_.mapIdx=s.unPackInt8U(),a.gameData_.private=s.unPackInt8U(),a.gameData_.gameType=s.unPackInt8U(),this.players[a.id_]||(this.players[a.id_]=new C(a.id_,a.team_,a)),this.me.id==a.id_&&(this.me=this.players[a.id_]),this.emit("playerJoin",this.players[a.id_])}#d(){const e=s.unPackInt8U(),t=s.unPackInt16U(),a=s.unPackFloat(),n=s.unPackFloat(),i=s.unPackFloat(),o=s.unPackInt8U(),r=s.unPackInt8U(),m=s.unPackInt8U(),u=s.unPackInt8U(),I=s.unPackInt8U(),h=this.players[e];h&&(h.playing=!0,h.randomSeed=t,h.weapons[0]&&h.weapons[0].ammo&&(h.weapons[0].ammo.rounds=o),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=u),h.grenades=I,h.position={x:a,y:n,z:i},this.emit("playerRespawn",h))}#u(){const e=s.unPackInt8U(),t=s.unPackFloat(),a=s.unPackFloat(),n=s.unPackFloat(),i=s.unPackInt8U(),o=this.players[e];if(!o||o.id==this.me.id){for(let r=0;r<w;r++)s.unPackInt8U(),s.unPackRadU(),s.unPackRad(),s.unPackInt8U();return}if(o.position.x!==t&&(o.position.x=t),o.position.z!==n&&(o.position.z=n),(!o.jumping||Math.abs(o.position.y-a)>.5&&o.position.y!==a)&&(o.position.y=a),o.climbing!==i&&(o.climbing=i),this.intents.includes(this.Intents.BUFFERS)){if(!o.buffer)return;for(let r=0;r<w;r++){o.buffer[r].controlKeys=s.unPackInt8U();const m=s.unPackRadU();isNaN(m)||(o.buffer[r].yaw_=m);const u=s.unPackRad();isNaN(u)||(o.buffer[r].pitch_=u),s.unPackInt8U()}o.buffer[0].x=t,o.buffer[0].y=a,o.buffer[0].z=n}else for(let r=0;r<w;r++)s.unPackInt8U(),s.unPackRadU(),s.unPackRad(),s.unPackInt8U()}#p(){const e=s.unPackInt8U(),t=this.players[e];t&&(t.playing=!1,this.emit("playerPause",t))}#g(){const e=s.unPackInt8U(),t=s.unPackInt8U(),a=this.players[e];a&&(a.activeGun=t,this.emit("playerSwapWeapon",a,t))}#k(){const e=s.unPackInt8U(),t=s.unPackInt8U();s.unPackInt8U(),s.unPackInt8U(),s.unPackInt8U();const a=this.players[e],n=this.players[t];a&&(a.playing=!1,a.streak=0,a.lastDeathTime=Date.now(),a.hp=100,a.hpShield=0),n&&n.streak++,this.emit("playerDeath",a,n)}#I(){const e=s.unPackInt8U();for(let n=0;n<6;n++)s.unPackFloat();const t=this.players[e],a=t.weapons[t.activeGun];a&&a.ammo&&(a.ammo.rounds--,this.emit("playerFire",t,a))}#f(){const e=s.unPackInt16U(),t=s.unPackInt8U(),a=s.unPackFloat(),n=s.unPackFloat(),i=s.unPackFloat();this.game.collectables[t].push({id:e,x:a,y:n,z:i}),this.emit("spawnItem",t,e,{x:a,y:n,z:i})}#P(){const e=s.unPackInt8U(),t=s.unPackInt8U(),a=s.unPackInt8U(),n=s.unPackInt16U(),i=this.players[e];if(this.game.collectables[t]=this.game.collectables[t].filter(o=>o.id!=n),t==v.AMMO){const o=i.weapons[a];o&&o.ammo&&(o.ammo.store=Math.min(o.ammo.storeMax,o.ammo.store+o.ammo.pickup),this.emit("collectAmmo",i,o))}t==v.GRENADE&&(i.grenades++,i.grenades>3&&(i.grenades=3),this.emit("collectGrenade",i))}#y(){const e=s.unPackInt8U(),t=s.unPackInt8U(),a=this.players[e];if(!a)return;const n=a.hp;a.hp=t,this.emit("playerDamaged",a,n,a.hp)}#w(){const e=s.unPackInt8U();s.unPackFloat(),s.unPackFloat();const t=this.me.hp;this.me.hp=e,this.emit("selfDamaged",t,this.me.hp)}#U(){const e=s.unPackInt8U(),t=this.players[e];s.unPackInt8U();const a=s.unPackInt8U(),n=s.unPackFloat(),i=s.unPackFloat(),o=s.unPackFloat();if(s.unPackInt8U(),s.unPackInt8U(),s.unPackInt8U(),!t)return;t.serverStateIdx=a;const r=t.position.x,m=t.position.y,u=t.position.z;t.position.x=n,t.position.y=i,t.position.z=o,(r!=n||m!=i||u!=o)&&this.emit("selfMoved",t,{x:r,y:m,z:u},{x:n,y:i,z:o})}#b(){if(!this.intents.includes(this.Intents.MONITOR)){const e=f.getBuffer();e.packInt8(c.eventModifier),e.send(this.game.socket)}}#S(){const e=s.unPackInt8U(),t={...this.players[e]};delete this.players[e.toString()],this.emit("playerLeave",t)}#C(){if(this.game.gameModeId==g.spatula){this.game.teamScore[1]=s.unPackInt16U(),this.game.teamScore[2]=s.unPackInt16U();const e={x:s.unPackFloat(),y:s.unPackFloat(),z:s.unPackFloat()},t=s.unPackInt8U(),a=s.unPackInt8U();this.game.spatula={coords:e,controlledBy:t,controlledByTeam:a},this.emit("gameStateChange",this.game)}else this.game.gameModeId==g.kotc?(this.game.stage=s.unPackInt8U(),this.game.zoneNumber=s.unPackInt8U(),this.game.capturing=s.unPackInt8U(),this.game.captureProgress=s.unPackInt16U(),this.game.numCapturing=s.unPackInt8U(),this.game.teamScore[1]=s.unPackInt8U(),this.game.teamScore[2]=s.unPackInt8U(),this.game.stageName=E[this.game.stage],this.game.capturePercent=this.game.captureProgress/1e3,this.game.activeZone=this.game.map.zones?this.game.map.zones[this.game.zoneNumber-1]:null,this.emit("gameStateChange",this.game)):this.game.gameModeId==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 e=s.unPackInt8U(),t=s.unPackInt8U(),a=this.players[e];switch(t){case d.HardBoiled:a.hpShield=100,a.streakRewards.push(d.HardBoiled);break;case d.EggBreaker:a.streakRewards.push(d.EggBreaker);break;case d.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 d.OverHeal:a.hp=Math.min(200,a.hp+100),a.streakRewards.push(d.OverHeal);break;case d.DoubleEggs:a.streakRewards.push(d.DoubleEggs);break;case d.MiniEgg:a.streakRewards.push(d.MiniEgg);break}this.emit("playerBeginStreak",a,t)}#x(){const e=s.unPackInt8U(),t=s.unPackInt8U(),a=this.players[e];[d.EggBreaker,d.OverHeal,d.DoubleEggs,d.MiniEgg].includes(t)&&a.streakRewards.includes(t)&&(a.streakRewards=a.streakRewards.filter(i=>i!=t)),this.emit("playerEndStreak",t,a)}#T(){const e=s.unPackInt8U(),t=s.unPackInt8U();s.unPackFloat(),s.unPackFloat(),this.me.hpShield=e,this.me.hp=t,this.me.hpShield<=0?(this.me.streakRewards=this.me.streakRewards.filter(a=>a!=d.HardBoiled),this.emit("selfShieldLost")):this.emit("selfShieldHit",this.me.hpShield)}#_(){const e={...this.game.options};let t=s.unPackInt8U(),a=s.unPackInt8U(),n=s.unPackInt8U();(t<1||t>4)&&(t=4),(a<0||a>8)&&(a=4),n>16&&(n=4),this.game.options.gravity=t/4,this.game.options.damage=a/4,this.game.options.healthRegen=n/4;const i=s.unPackInt8U();return Object.keys(T).forEach(o=>{const r=i&T[o]?1:0;this.game.options[o]=r}),this.game.options.weaponsDisabled=Array.from({length:7},()=>s.unPackInt8U()===1),this.game.options.mustUseSecondary=this.game.options.weaponsDisabled.every(o=>o),this.emit("gameOptionsChange",e,this.game.options),!1}#R(){const e=s.unPackInt8U();e==x.pause&&(this.emit("gameForcePause"),setTimeout(()=>this.me.playing=!1,3e3)),e==x.reset&&(Object.values(this.players).forEach(t=>t.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=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=E[y.capturing],this.game.capturePercent=0),this.emit("gameReset"))}#M(){if(!this.intents.includes(this.Intents.PING))return;const e=this.ping;this.ping=Date.now()-this.lastPingTime,this.emit("pingUpdate",e,this.ping),this.intents.includes(this.Intents.MONITOR)||setTimeout(()=>{const t=f.getBuffer();t.packInt8(c.ping),t.send(this.game.socket),this.lastPingTime=Date.now()},this.pingInterval)}#E(){const e=s.unPackInt8U(),t=s.unPackInt8U(),a=this.players[e];if(!a)return;const n=a.team;a.team=t,a.streak=0,this.emit("playerSwitchTeam",a,n,t)}#O(){const e=s.unPackInt8U(),t=s.unPackInt8U(),a=s.unPackInt16U(),n=s.unPackInt16U(),i=s.unPackInt8U(),o=s.unPackInt16U(),r=s.unPackInt16U(),m=s.unPackInt16U(),u=s.unPackInt16U();s.unPackInt8(),s.unPackInt8();const I=this.intents.includes(this.Intents.COSMETIC_DATA),h=I?p(a):a,G=I?p(n):n,A=I?p(o):o,N=I?p(r):r,B=I?p(m):m,L=I?p(u):u,l=this.players[e];if(l){const b={...l.character},S=l.selectedGun;l.character.eggColor=i,l.character.primaryGun=h,l.character.secondaryGun=G,l.character.stamp=N,l.character.hat=A,l.character.grenade=B,l.character.melee=L,l.selectedGun=t,l.weapons[0]=new q[t],S!==l.selectedGun&&this.emit("playerChangeGun",l,S,l.selectedGun),b!==l.character&&this.emit("playerChangeCharacter",l,b,l.character)}}#F(){const e=s.unPackInt32U(),t=this.account.eggBalance;this.account.eggBalance=e,this.emit("balanceUpdate",e-t,e)}#G(){this.me.playing=!1,this.emit("selfRespawnFail")}#A(){const e=s.unPackInt8U(),t=this.players[e];t&&this.emit("playerMelee",t)}#N(){const e=s.unPackInt8U(),t=this.players[e];if(!t)return;const a=t.weapons[t.activeGun];if(a.ammo){const n=Math.min(Math.min(a.ammo.capacity,a.ammo.reload)-a.ammo.rounds,a.ammo.store);a.ammo.rounds+=n,a.ammo.store-=n}this.emit("playerReload",t,a)}#B(){if(!this.intents.includes(this.Intents.MONITOR)){const e=f.getBuffer();e.packInt8(c.gameOptions),e.packInt8(this.game.options.gravity*4),e.packInt8(this.game.options.damage*4),e.packInt8(this.game.options.healthRegen*4);const t=(this.game.options.locked?1:0)|(this.game.options.noTeamChange?2:0)|(this.game.options.noTeamShuffle?4:0);e.packInt8(t),this.game.options.weaponsDisabled.forEach(a=>{e.packInt8(a?1:0)}),e.send(this.game.socket)}}#L(){const e=s.unPackInt8U();let t=s.unPackInt16U();const a=s.unPackFloat(),n=s.unPackFloat(),i=s.unPackFloat(),o=s.unPackInt8U(),r=s.unPackFloat();this.intents.includes(this.Intents.COSMETIC_DATA)&&(t=p(t)),e==Y.Grenade?this.emit("grenadeExploded",t,{x:a,y:n,z:i},o,r):this.emit("rocketHit",{x:a,y:n,z:i},o,r)}#D(){const e=s.unPackInt8U(),t=s.unPackFloat(),a=s.unPackFloat(),n=s.unPackFloat(),i=s.unPackFloat(),o=s.unPackFloat(),r=s.unPackFloat(),m=this.players[e];m&&(m.grenades--,this.emit("playerThrowGrenade",m,{x:t,y:a,z:n},{x:i,y:o,z:r}))}#$(){const e=s.unPackInt8U(),t=s.unPackInt8U(),a=this.players[e];if(!a)return;if(!this.intents.includes(this.Intents.CHALLENGES))return this.emit("challengeComplete",a,t);const n=this.account.challenges.find(i=>i.id==t);this.emit("challengeComplete",a,n),a.id==this.me.id&&this.refreshChallenges()}#z(){if(!this.intents.includes(this.Intents.MONITOR)){const e=f.getBuffer();e.packInt8(c.joinGame),e.packString(this.state.name),e.packString(this.game.raw.uuid),e.packInt8(0),e.packInt8(this.state.weaponIdx||0),e.packInt32(this.account.session),e.packString(this.account.firebaseId),e.packString(this.account.sessionId),e.send(this.game.socket)}}async#W(){if(this.me.id=s.unPackInt8U(),this.me.team=s.unPackInt8U(),this.game.gameModeId=s.unPackInt8U(),this.game.gameMode=O[this.game.gameModeId],this.game.mapIdx=s.unPackInt8U(),this.game.map=U[this.game.mapIdx],this.intents.includes(this.Intents.PATHFINDING)&&(this.game.map.raw=await J(this.game.map.filename,this.game.map.hash),this.pathing.nodeList=new V(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=Q(e):delete this.game.map.zones}if(this.game.playerLimit=s.unPackInt8U(),this.game.isGameOwner=s.unPackInt8U()==1,this.game.isPrivate=s.unPackInt8U()==1,s.unPackInt8U(),this.state.joinedGame=!0,this.lastDeathTime=Date.now(),!this.intents.includes(this.Intents.MONITOR)){const e=f.getBuffer();e.packInt8(c.clientReady),e.send(this.game.socket),this.game.socket.onmessage=t=>this.#s.push(t.data)}if(this.autoUpdate&&(this.updateIntervalId=setInterval(()=>this.update(),this.updateInterval)),this.intents.includes(this.Intents.PING)&&(this.lastPingTime=Date.now(),!this.intents.includes(this.Intents.MONITOR))){const e=f.getBuffer();e.packInt8(c.ping),e.send(this.game.socket)}this.emit("gameReady")}processPacket(e){s.init(e),this.intents.includes(this.Intents.PACKET_HOOK)&&this.emit("packet",e);let t=0,a=0,n=!1;for(;s.isMoreDataAvailable()&&!n;){const i=s.unPackInt8U();switch(i){case c.syncThem:this.#u();break;case c.fire:this.#I();break;case c.hitThem:this.#y();break;case c.syncMe:this.#U();break;case c.hitMe:this.#w();break;case c.swapWeapon:this.#g();break;case c.collectItem:this.#P();break;case c.respawn:this.#d();break;case c.die:this.#k();break;case c.pause:this.#p();break;case c.chat:this.#l();break;case c.addPlayer:this.#m();break;case c.removePlayer:this.#S();break;case c.eventModifier:this.#b();break;case c.metaGameState:this.#C();break;case c.beginShellStreak:this.#v();break;case c.endShellStreak:this.#x();break;case c.hitMeHardBoiled:this.#T();break;case c.gameOptions:this.#_();break;case c.ping:this.#M();break;case c.switchTeam:this.#E();break;case c.changeCharacter:this.#O();break;case c.reload:this.#N();break;case c.explode:this.#L();break;case c.throwGrenade:this.#D();break;case c.spawnItem:this.#f();break;case c.melee:this.#A();break;case c.updateBalance:this.#F();break;case c.challengeCompleted:this.#$();break;case c.socketReady:this.#z();break;case c.gameJoined:this.#W();break;case c.gameAction:this.#R();break;case c.requestGameOptions:this.#B();break;case c.respawnDenied:this.#G();break;case c.expireUpgrade:case c.clientReady:break;case c.musicInfo:s.unPackLongString();break;default:console.error(`handlePacket: I got but did not handle a: ${Object.keys(c).find(o=>c[o]===i)} ${i}`),t&&console.error(`handlePacket: It may be a result of the ${t} command (${a}).`),n=!0;break}t=Object.keys(c).find(o=>c[o]===i),a=i,this.intents.includes(this.Intents.LOG_PACKETS)&&console.log(`[LOG_PACKETS] Packet ${t}: ${a}`)}}async checkChiknWinner(){const e=await k({cmd:"chicknWinnerReady",id:this.account.id,sessionId:this.account.sessionId});return typeof e=="string"?e:(this.account.cw.limit=e.limit,this.account.cw.atLimit=e.limit>=4,this.account.cw.secondsUntilPlay=(this.account.cw.atLimit?e.period:e.span)||0,this.account.cw.canPlayAgain=Date.now()+this.account.cw.secondsUntilPlay*1e3,this.account.cw)}async playChiknWinner(e=!0){if(this.account.cw.atLimit||this.account.cw.limit>K)return"hit_daily_limit";if(this.account.cw.canPlayAgain>Date.now()&&e)return"on_cooldown";const t=await k({cmd:"incentivizedVideoReward",firebaseId:this.account.firebaseId,id:this.account.id,sessionId:this.account.sessionId,token:null},this.proxy,`${this.protocol}://${this.instance}`);return typeof t=="string"?t:t.error?t.error=="RATELIMITED"||t.error=="RATELMITED"?(await this.checkChiknWinner(),"on_cooldown"):t.error=="SESSION_EXPIRED"?"session_expired":(console.error("Unknown Chikn Winner response",t),"unknown_error"):t.reward?(this.account.eggBalance+=t.reward.eggsGiven,t.reward.itemIds.forEach(a=>this.account.ownedItemIds.push(a)),await this.checkChiknWinner(),t.reward):(console.error("Unknown Chikn Winner response",t),"unknown_error")}async resetChiknWinner(){if(this.account.eggBalance<200)return"not_enough_eggs";if(!this.account.cw.atLimit)return"not_at_limit";const e=await k({cmd:"chwReset",sessionId:this.account.sessionId});return typeof e=="string"?e:e.result!=="SUCCESS"?(console.error("Unknown Chikn Winner reset response",e),"unknown_error"):(this.account.eggBalance-=200,await this.checkChiknWinner(),this.account.cw)}canSee(e){if(!this.intents.includes(this.Intents.PATHFINDING))throw new Error("You must have the PATHFINDING intent to use this method.");return this.pathing.nodeList.hasLineOfSight(this.me.position,e.position)}getBestTarget(e=()=>!0){const t=Object.values(this.players).filter(i=>i).filter(i=>i!==this.me).filter(i=>i.playing).filter(i=>i.hp>0).filter(i=>i.name!==this.me.name).filter(i=>this.me.team===0||i.team!==this.me.team).filter(i=>this.canSee(i)).filter(i=>!!e(i));let a=200,n=null;for(const i of t){const o=i.position.x-this.me.position.x,r=i.position.y-this.me.position.y,m=i.position.z-this.me.position.z,u=Math.sqrt(o*o+r*r+m*m);u<a&&(a=u,n=i)}return n}async refreshChallenges(){const e=await k({cmd:"challengeGetDaily",sessionId:this.account.sessionId,playerId:this.account.id},this.proxy,`${this.protocol}://${this.instance}`);return this.#i(e),this.account.challenges}async rerollChallenge(e){const t=await k({cmd:"challengeRerollSlot",sessionId:this.account.sessionId,slotId:e},this.proxy,`${this.protocol}://${this.instance}`);return this.#i(t),this.account.challenges}async claimChallenge(e){const t=await k({cmd:"challengeClaimReward",sessionId:this.account.sessionId,slotId:e},this.proxy,`${this.protocol}://${this.instance}`);return this.#i(t.challenges),t.reward>0&&(this.account.eggBalance+=t.reward),{eggReward:t.reward,updatedChallenges:this.account.challenges}}async refreshBalance(){const e=await k({cmd:"checkBalance",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId},this.proxy,`${this.protocol}://${this.instance}`);return this.account.eggBalance=e.currentBalance,e.currentBalance}async redeemCode(e){const t=await k({cmd:"redeem",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,id:this.account.id,code:e},this.proxy,`${this.protocol}://${this.instance}`);return t.result==="SUCCESS"?(this.account.eggBalance=t.eggs_given,t.item_ids.forEach(a=>this.account.ownedItemIds.push(a)),{result:t,eggsGiven:t.eggs_given,itemIds:t.item_ids}):t}async claimURLReward(e){const t=await k({cmd:"urlRewardParams",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,reward:e},this.proxy,`${this.protocol}://${this.instance}`);return t.result==="SUCCESS"&&(this.account.eggBalance+=t.eggsGiven,t.itemIds.forEach(a=>this.account.ownedItemIds.push(a))),t}async claimSocialReward(e){const t=await k({cmd:"reward",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,rewardTag:e},this.proxy,`${this.protocol}://${this.instance}`);return t.result==="SUCCESS"&&(this.account.eggBalance+=t.eggsGiven,t.itemIds.forEach(a=>this.account.ownedItemIds.push(a))),t}async buyItem(e){const t=await k({cmd:"buy",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,itemId:e,save:!0},this.proxy,`${this.protocol}://${this.instance}`);return t.result==="SUCCESS"&&(this.account.eggBalance=t.currentBalance,this.account.ownedItemIds.push(t.itemId)),t}quit(e=!1,t=!1){this.state.quit||(this.intents.includes(this.Intents.PLAYER_HEALTH)&&clearInterval(this.healthIntervalId),clearInterval(this.updateIntervalId),this.game?.socket&&this.game.socket.close(),this.matchmaker&&this.matchmaker.close(),t||(this.#t=[]),this.#s=[],e||(delete this.account,delete this.game,delete this.me,delete this.players),this.state.quit=!0,this.emit("quit"))}}var kt=et;export{et as Bot,kt as default};
3
+ import{createAccount as z,loginAnonymously as H,loginWithCredentials as W,loginWithRefreshToken as j,queryServices as g}from"./api.js";import s from"./comm/CommIn.js";import f from"./comm/CommOut.js";import{CloseCode as K}from"./comm/Codes.js";import{CommCode as c}from"./constants/codes.js";import U from"./bot/GamePlayer.js";import q from"./matchmaker.js";import Y from"./socket.js";import{ChiknWinnerDailyLimit as Z,CollectTypes as T,CoopStates as y,findItemById as d,FramesBetweenSyncs as w,GameActions as E,GameModes as u,GameOptionFlags as G,GunList as X,ItemTypes as V,Movements as F,PlayTypes as J,ProxiesEnabled as Q,ShellStreaks as m,StateBufferSize as b}from"./constants/index.js";import R from"./dispatches/LookAtPosDispatch.js";import M from"./dispatches/MovementDispatch.js";import{NodeList as tt}from"./pathing/mapnode.js";import{fetchMap as et,initKotcZones as st}from"./util.js";import{Challenges as at}from"./constants/challenges.js";import{Maps as S}from"./constants/maps.js";const B=Object.fromEntries(Object.entries(y).map(([P,t])=>[t,P])),A=Object.fromEntries(Object.entries(u).map(([P,t])=>[t,P])),O={CHALLENGES:1,STATS:2,PATHFINDING:3,PING:5,COSMETIC_DATA:6,PLAYER_HEALTH:7,PACKET_HOOK:8,LOG_PACKETS:10,NO_LOGIN:11,DEBUG_BUFFER:12,DEBUG_BEST_TARGET:14},x=(P,t)=>(P%t+t)%t;class it{static Intents=O;Intents=O;#e=[];#t={};#i=[];#n;#o;constructor(t={}){if(t.proxy&&!Q)throw new Error("proxies do not work and hence are not supported in the browser");this.intents=t.intents||[],this.instance=t.instance||"shellshock.io",this.protocol=t.protocol||"wss",this.proxy=t.proxy||"",this.state={name:"yolkbot",weaponIdx:0,reloading:!1,swappingGun:!1,usingMelee:!1,stateIdx:0,serverStateIdx:0,shotsFired:0,buffer:[],left:!1,quit:!1},this.players={},this.me=new U({}),this.game={raw:{},code:"",socket:null,gameModeId:0,gameMode:A[0],mapIdx:0,map:{filename:"",hash:"",name:"",modes:{FFA:!1,Teams:!1,Spatula:!1,King:!1},availability:"both",numPlayers:"18",raw:{},nodes:{},zones:[]},playerLimit:0,isGameOwner:!1,isPrivate:!0,options:{gravity:1,damage:1,healthRegen:1,locked:!1,noTeamChange:!1,noTeamShuffle:!1,weaponsDisabled:Array(7).fill(!1),mustUseSecondary:!1},collectables:[[],[]],teamScore:[0,0,0],spatula:{coords:{x:0,y:0,z:0},controlledBy:0,controlledByTeam:0},stage:y.capturing,zoneNumber:0,activeZone:[],capturing:0,captureProgress:0,numCapturing:0,stageName:"",capturePercent:0},this.#o=this.game,this.account={id:0,firebaseId:"",sessionId:"",session:"",email:"",password:"",cw:{atLimit:!1,limit:0,secondsUntilPlay:0,canPlayAgain:Date.now()},loadout:{hatId:null,meleeId:0,stampId:null,classIdx:0,colorIdx:0,grenadeId:0,primaryId:[3100,3600,3400,3800,4e3,4200,4500],secondaryId:new Array(7).fill(3e3),stampPositionX:0,stampPositionY:0},ownedItemIds:[],vip:!1,accountAge:0,emailVerified:!1,eggBalance:0,rawLoginData:{}},this.#n=this.account,this.matchmaker=null,this.ping=0,this.lastPingTime=-1,this.lastDeathTime=-1,this.lastChatTime=-1,this.lastUpdateTick=0,this.controlKeys=0,this.pathing={nodeList:null,followingPath:!1,activePath:null,activeNode:null,activeNodeIdx:0}}dispatch(t){t.check(this)?t.execute(this):this.#e.push(t)}async createAccount(t,e){this.account.email=t,this.account.password=e;const a=await z(t,e,this.proxy,`${this.protocol}://${this.instance}`);return await this.#s(a)}async login(t,e){this.account.email=t,this.account.password=e;const a=await W(t,e,this.proxy,`${this.protocol}://${this.instance}`);return await this.#s(a)}async loginWithRefreshToken(t){const e=await j(t,this.proxy,`${this.protocol}://${this.instance}`);return await this.#s(e)}async loginAnonymously(){delete this.account.email,delete this.account.password;const t=await H(this.proxy,`${this.protocol}://${this.instance}`);return await this.#s(t)}async#s(t){return typeof t!="object"?(this.emit("authFail",t),!1):t.banRemaining?(this.emit("banned",t.banRemaining),!1):t.playerOutput?(t=t.playerOutput,this.account.rawLoginData=t,this.account.accountAge=t.accountAge,this.account.eggBalance=t.currentBalance,this.account.emailVerified=t.emailVerified,this.account.firebaseId=t.firebaseId,this.account.id=t.id,this.account.loadout=t.loadout,this.account.ownedItemIds=t.ownedItemIds,this.account.session=t.session,this.account.sessionId=t.sessionId,this.account.vip=t.upgradeProductId&&!t.upgradeIsExpired,this.intents.includes(this.Intents.STATS)&&(this.account.stats={lifetime:t.statsLifetime,monthly:t.statsCurrent}),this.intents.includes(this.Intents.CHALLENGES)&&this.#a(t.challenges),this.emit("authSuccess",this.account),this.account):(this.emit("authFail",t),!1)}#a(t){this.account.challenges=[];for(const e of t){const a=at.find(i=>i.id==e.challengeId);a&&(delete e.playerId,this.account.challenges.push({raw:{challengeInfo:a,challengeData:e},id:e.challengeId,name:a.loc.title,desc:a.loc.desc,rewardEggs:a.reward,isRerolled:!!e.reset,isClaimed:!!e.claimed,isCompleted:!!e.completed,progressNum:e.progress,goalNum:a.goal}))}}async initMatchmaker(){return!this.account.sessionId&&!this.intents.includes(this.Intents.NO_LOGIN)&&!await this.loginAnonymously()?!1:(this.matchmaker||(this.matchmaker=new q({sessionId:this.account.sessionId,proxy:this.proxy,instance:this.instance,protocol:this.protocol,noLogin:this.intents.includes(this.Intents.NO_LOGIN)}),this.matchmaker.on("authFail",t=>this.emit("authFail",t)),await this.matchmaker.getRegions()),!0)}async#c(t){return await this.initMatchmaker()?await new Promise(e=>{const a=i=>{if(i.command=="gameFound"&&(this.matchmaker.off("msg",a),this.game.raw=i,this.game.code=i.id,e()),i.error&&i.error=="gameNotFound")throw new Error(`Game ${t} not found (likely expired).`)};this.matchmaker.on("msg",a),this.matchmaker.send({command:"joinGame",id:t,observe:!1,sessionId:this.account.sessionId})}):!1}async createPrivateGame(t={}){if(!await this.initMatchmaker())return!1;if(!t.region)throw new Error('pass a region: createPrivateGame({ region: "useast", ... })');if(!this.matchmaker.regionList.find(i=>i.id==t.region))throw new Error('invalid region, see <bot>.matchmaker.regionList for a region list (pass an "id")');if(!t.mode)throw new Error('pass a mode: createPrivateGame({ mode: "ffa", ... })');if(u[t.mode]==null)throw new Error("invalid mode, see GameModes for a list");if(!t.map)throw new Error('pass a map: createPrivateGame({ map: "downfall", ... })');const e=S.find(i=>i.name.toLowerCase()==t.map.toLowerCase()),a=S.indexOf(e);if(a==-1)throw new Error("invalid map, see the Maps constant for a list");return await new Promise(i=>{const n=o=>{o.command=="gameFound"&&(this.matchmaker.off("msg",n),this.game.raw=o,this.game.code=this.game.raw.id,i())};this.matchmaker.on("msg",n),this.matchmaker.send({command:"findGame",region:t.region,playType:J.createPrivate,gameType:u[t.mode],sessionId:this.account.sessionId,noobLobby:!1,map:a})}),this.game.raw}async join(t,e){if(this.state.name=t||"yolkbot",typeof e=="string"?(e.includes("#")&&(e=e.split("#")[1]),await this.#c(e)):typeof e=="object"&&(this.account.id==0&&await this.loginAnonymously(),this.game.raw=e,this.game.code=this.game.raw.id),!this.game.raw.id)throw new Error("invalid game data passed to <bot>.join");const a=async()=>{try{const i=this.instance.startsWith("localhost:")?this.instance:`${this.game.raw.subdomain}.${this.instance}`;this.game.socket=new Y(`${this.protocol}://${i}/game/${this.game.raw.id}`,this.proxy),this.game.socket.onerror=async n=>(console.error(n),await new Promise(o=>setTimeout(o,100)),await a())}catch{await new Promise(i=>setTimeout(i,100)),await a()}};await a(),this.game.socket.binaryType="arraybuffer",this.game.socket.onopen=()=>this.game.socket.onerror=null,this.game.socket.onmessage=i=>this.processPacket(i.data),this.game.socket.onclose=i=>{this.state.left?this.state.left=!1:(this.emit("close",i.code),this.leave(-1))}}#r(){if(Object.entries(this.me.position).map(e=>Math.floor(e[1])).join(",")==this.pathing.activePath[this.pathing.activePath.length-1].positionStr)this.pathing.followingPath=!1,this.pathing.activePath=null,this.pathing.activeNode=null,this.pathing.activeNodeIdx=0,this.dispatch(new M(0));else{let e;this.pathing.activeNodeIdx<this.pathing.activePath.length-1?(e=this.pathing.activePath[this.pathing.activeNodeIdx+1].flatCenter(),this.dispatch(new R(e))):(e=this.pathing.activePath[this.pathing.activeNodeIdx].flatCenter(),this.dispatch(new R(e)));for(const a of this.pathing.activePath)if(a.flatRadialDistance(this.me.position)<.1&&a.position.y==Math.floor(this.me.position.y)&&this.pathing.activePath.indexOf(a)>=this.pathing.activeNodeIdx){this.pathing.activeNodeIdx=this.pathing.activePath.indexOf(a)+1,this.pathing.activeNode=this.pathing.activePath[this.pathing.activeNodeIdx];break}this.controlKeys&F.FORWARD||this.dispatch(new M(F.FORWARD))}}update(){if(!this.state.quit){if(this.pathing.followingPath&&this.intents.includes(this.Intents.PATHFINDING)&&this.#r(),this.#e.length>0)for(let t=0;t<this.#e.length;t++){const e=this.#e[t];e.check(this)&&(e.execute(this),this.#e.splice(t,1))}if(this.me.playing){const t=this.state.stateIdx;if(this.intents.includes(this.Intents.DEBUG_BUFFER)&&(console.log("setting buffer for idx",t),console.log("checking...shotsFired",this.state.shotsFired)),this.state.buffer[t]={controlKeys:this.controlKeys,yaw:this.me.view.yaw,pitch:this.me.view.pitch,shotsFired:this.state.shotsFired},this.state.shotsFired=0,this.lastUpdateTick>=2){this.emit("tick");const e=f.getBuffer();e.packInt8(c.syncMe),e.packInt8(this.state.stateIdx),e.packInt8(this.state.serverStateIdx);const a=x(this.state.stateIdx-w+1,b);for(let i=0;i<w;i++){const n=x(a+i,b);this.intents.includes(this.Intents.DEBUG_BUFFER)&&console.log("going with",this.state.stateIdx,a,n,this.state.buffer[n]),e.packInt8(this.state.buffer[n]?.controlKeys||0),e.packInt8(this.state.buffer[n]?.shotsFired||0),e.packRadU(this.state.buffer[n]?.yaw||this.me.view.yaw),e.packRad(this.state.buffer[n]?.pitch||this.me.view.pitch),e.packInt8(100)}e.send(this.game.socket),this.state.buffer=[],this.lastUpdateTick=0}else this.lastUpdateTick++;this.state.stateIdx=x(this.state.stateIdx+1,b)}if(this.intents.includes(this.Intents.PLAYER_HEALTH))for(const t of Object.values(this.players)){if(t.playing&&t.hp>0){const e=.1*(this.game.isPrivate?this.game.options.healthRegen:1);t.streakRewards.includes(m.OverHeal)?t.hp=Math.max(100,t.hp-e):t.hp=Math.min(100,t.hp+e)}t.spawnShield>0&&(t.spawnShield-=6)}}}on(t,e){Object.keys(this.#t).includes(t)?this.#t[t].push(e):this.#t[t]=[e]}onAny(t){this.#i.push(t)}off(t,e){this.#t[t]=this.#t[t].filter(a=>a!==e)}emit(t,...e){if(!this.state.quit){if(this.#t[t])for(const a of this.#t[t])a(...e);for(const a of this.#i)a(t,...e)}}#h(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=s.unPackString().valueOf(),i=this.players[t];this.emit("chat",i,a,e)}#l(){const t=s.unPackInt8U(),e=this.intents.includes(this.Intents.COSMETIC_DATA),a={id:t,uniqueId:s.unPackString(),name:s.unPackString(),safename:s.unPackString(),charClass:s.unPackInt8U(),team:s.unPackInt8U(),primaryWeaponItem:e?d(s.unPackInt16U()):s.unPackInt16U(),secondaryWeaponItem:e?d(s.unPackInt16U()):s.unPackInt16U(),shellColor:s.unPackInt8U(),hatItem:e?d(s.unPackInt16U()):s.unPackInt16U(),stampItem:e?d(s.unPackInt16U()):s.unPackInt16U(),stampPosX:s.unPackInt8(),stampPosY:s.unPackInt8(),grenadeItem:e?d(s.unPackInt16U()):s.unPackInt16U(),meleeItem:e?d(s.unPackInt16U()):s.unPackInt16U(),x:s.unPackFloat(),y:s.unPackFloat(),z:s.unPackFloat(),$dx:s.unPackFloat(),$dy:s.unPackFloat(),$dz:s.unPackFloat(),yaw:s.unPackRadU(),pitch:s.unPackRad(),score:s.unPackInt32U(),kills:s.unPackInt16U(),deaths:s.unPackInt16U(),streak:s.unPackInt16U(),totalKills:s.unPackInt32U(),totalDeaths:s.unPackInt32U(),bestGameStreak:s.unPackInt16U(),bestOverallStreak:s.unPackInt16U(),shield:s.unPackInt8U(),hp:s.unPackInt8U(),playing:s.unPackInt8U(),weaponIdx:s.unPackInt8U(),$controlKeys:s.unPackInt8U(),upgradeProductId:s.unPackInt8U(),activeShellStreaks:s.unPackInt8U(),social:s.unPackLongString(),hideBadge:s.unPackInt8U()};s.unPackInt8U(),s.unPackInt8U(),s.unPackInt8U(),this.players[a.id]||(this.players[a.id]=new U(a)),this.me.id==a.id&&(this.me=this.players[a.id]),this.emit("playerJoin",this.players[a.id])}#m(){const t=s.unPackInt8U(),e=s.unPackInt16U(),a=s.unPackFloat(),i=s.unPackFloat(),n=s.unPackFloat(),o=s.unPackInt8U(),h=s.unPackInt8U(),p=s.unPackInt8U(),I=s.unPackInt8U(),k=s.unPackInt8U(),r=this.players[t];r&&(r.playing=!0,r.randomSeed=e,r.weapons[0]&&r.weapons[0].ammo&&(r.weapons[0].ammo.rounds=o),r.weapons[0]&&r.weapons[0].ammo&&(r.weapons[0].ammo.store=h),r.weapons[1]&&r.weapons[1].ammo&&(r.weapons[1].ammo.rounds=p),r.weapons[1]&&r.weapons[1].ammo&&(r.weapons[1].ammo.store=I),r.grenades=k,r.position={x:a,y:i,z:n},r.spawnShield=120,this.emit("playerRespawn",r))}#d(){const t=s.unPackInt8U(),e=s.unPackFloat(),a=s.unPackFloat(),i=s.unPackFloat(),n=s.unPackInt8U(),o=this.players[t];if(!o||o.id==this.me.id){for(let h=0;h<w;h++)s.unPackInt8U(),s.unPackRadU(),s.unPackRad(),s.unPackInt8U();return}o.position.x!==e&&(o.position.x=e),o.position.z!==i&&(o.position.z=i),(!o.jumping||Math.abs(o.position.y-a)>.5&&o.position.y!==a)&&(o.position.y=a),o.climbing!==n&&(o.climbing=n);for(let h=0;h<w;h++)s.unPackInt8U(),s.unPackRadU(),s.unPackRad(),s.unPackInt8U()}#u(){const t=s.unPackInt8U(),e=this.players[t];e&&(e.playing=!1,this.emit("playerPause",e))}#p(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=this.players[t];a&&(a.activeGun=e,this.emit("playerSwapWeapon",a,e))}#g(){const t=s.unPackInt8U(),e=s.unPackInt8U();s.unPackInt8U(),s.unPackInt8U(),s.unPackInt8U();const a=this.players[t],i=this.players[e];a&&(a.playing=!1,a.streak=0,a.lastDeathTime=Date.now(),a.hp=100,a.spawnShield=0),i&&i.streak++,this.emit("playerDeath",a,i)}#k(){const t=s.unPackInt8U();for(let i=0;i<6;i++)s.unPackFloat();const e=this.players[t],a=e.weapons[e.activeGun];a&&a.ammo&&(a.ammo.rounds--,this.emit("playerFire",e,a))}#I(){const t=s.unPackInt16U(),e=s.unPackInt8U(),a=s.unPackFloat(),i=s.unPackFloat(),n=s.unPackFloat();this.game.collectables[e].push({id:t,x:a,y:i,z:n}),this.emit("spawnItem",e,t,{x:a,y:i,z:n})}#f(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=s.unPackInt8U(),i=s.unPackInt16U(),n=this.players[t];if(this.game.collectables[e]=this.game.collectables[e].filter(o=>o.id!=i),e==T.AMMO){const o=n.weapons[a];o&&o.ammo&&(o.ammo.store=Math.min(o.ammo.storeMax,o.ammo.store+o.ammo.pickup),this.emit("collectAmmo",n,o))}e==T.GRENADE&&(n.grenades++,n.grenades>3&&(n.grenades=3),this.emit("collectGrenade",n))}#P(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=this.players[t];if(!a)return;const i=a.hp;a.hp=e,this.emit("playerDamaged",a,i,a.hp)}#y(){const t=s.unPackInt8U();s.unPackFloat(),s.unPackFloat();const e=this.me.hp;this.me.hp=t,this.emit("selfDamaged",e,this.me.hp)}#w(){const t=s.unPackInt8U(),e=this.players[t];s.unPackInt8U();const a=s.unPackInt8U(),i=s.unPackFloat(),n=s.unPackFloat(),o=s.unPackFloat();if(s.unPackInt8U(),s.unPackInt8U(),s.unPackInt8U(),!e)return;this.state.serverStateIdx=a;const h=e.position.x,p=e.position.y,I=e.position.z;e.position.x=i,e.position.y=n,e.position.z=o,(h!=i||p!=n||I!=o)&&this.emit("selfMoved",e,{x:h,y:p,z:I},{x:i,y:n,z:o})}#U(){const t=f.getBuffer();t.packInt8(c.eventModifier),t.send(this.game.socket)}#b(){const t=s.unPackInt8U(),e={...this.players[t]};delete this.players[t.toString()],this.emit("playerLeave",e)}#S(){if(this.game.gameModeId==u.spatula){this.game.teamScore[1]=s.unPackInt16U(),this.game.teamScore[2]=s.unPackInt16U();const t={x:s.unPackFloat(),y:s.unPackFloat(),z:s.unPackFloat()},e=s.unPackInt8U(),a=s.unPackInt8U();this.game.spatula={coords:t,controlledBy:e,controlledByTeam:a},this.emit("gameStateChange",this.game)}else this.game.gameModeId==u.kotc?(this.game.stage=s.unPackInt8U(),this.game.zoneNumber=s.unPackInt8U(),this.game.capturing=s.unPackInt8U(),this.game.captureProgress=s.unPackInt16U(),this.game.numCapturing=s.unPackInt8U(),this.game.teamScore[1]=s.unPackInt8U(),this.game.teamScore[2]=s.unPackInt8U(),this.game.stageName=B[this.game.stage],this.game.capturePercent=this.game.captureProgress/1e3,this.game.activeZone=this.game.map.zones?this.game.map.zones[this.game.zoneNumber-1]:null,this.emit("gameStateChange",this.game)):this.game.gameModeId==u.team&&(this.game.teamScore[1]=s.unPackInt16U(),this.game.teamScore[2]=s.unPackInt16U());this.game.gameModeId!==u.spatula&&delete this.game.spatula,this.game.gameModeId!==u.kotc&&(delete this.game.stage,delete this.game.zoneNumber,delete this.game.capturing,delete this.game.captureProgress,delete this.game.numCapturing,delete this.game.stageName,delete this.game.numCapturing,delete this.game.activeZone),this.game.gameModeId==u.ffa&&delete this.game.teamScore}#x(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=this.players[t];switch(e){case m.HardBoiled:t===this.me.id&&(this.me.shieldHp=100),a.streakRewards.push(m.HardBoiled);break;case m.EggBreaker:a.streakRewards.push(m.EggBreaker);break;case m.Restock:{a.grenades=3,a.weapons[0]&&a.weapons[0].ammo&&(a.weapons[0].ammo.rounds=a.weapons[0].ammo.capacity,a.weapons[0].ammo.store=a.weapons[0].ammo.storeMax),a.weapons[1]&&a.weapons[1].ammo&&(a.weapons[1].ammo.rounds=a.weapons[1].ammo.capacity,a.weapons[1].ammo.store=a.weapons[1].ammo.storeMax);break}case m.OverHeal:a.hp=Math.min(200,a.hp+100),a.streakRewards.push(m.OverHeal);break;case m.DoubleEggs:a.streakRewards.push(m.DoubleEggs);break;case m.MiniEgg:a.streakRewards.push(m.MiniEgg);break}this.emit("playerBeginStreak",a,e)}#v(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=this.players[t];[m.EggBreaker,m.OverHeal,m.DoubleEggs,m.MiniEgg].includes(e)&&a.streakRewards.includes(e)&&(a.streakRewards=a.streakRewards.filter(n=>n!=e)),this.emit("playerEndStreak",e,a)}#C(){const t=s.unPackInt8U(),e=s.unPackInt8U();s.unPackFloat(),s.unPackFloat(),this.me.shieldHp=t,this.me.hp=e,this.me.shieldHp<=0?(this.me.streakRewards=this.me.streakRewards.filter(a=>a!=m.HardBoiled),this.emit("selfShieldLost")):this.emit("selfShieldHit",this.me.shieldHp)}#T(){const t={...this.game.options};let e=s.unPackInt8U(),a=s.unPackInt8U(),i=s.unPackInt8U();(e<1||e>4)&&(e=4),(a<0||a>8)&&(a=4),i>16&&(i=4),this.game.options.gravity=e/4,this.game.options.damage=a/4,this.game.options.healthRegen=i/4;const n=s.unPackInt8U();return Object.keys(G).forEach(o=>{const h=n&G[o]?1:0;this.game.options[o]=h}),this.game.options.weaponsDisabled=Array.from({length:7},()=>s.unPackInt8U()===1),this.game.options.mustUseSecondary=this.game.options.weaponsDisabled.every(o=>o),this.emit("gameOptionsChange",t,this.game.options),!1}#E(){const t=s.unPackInt8U();t==E.pause&&(this.emit("gameForcePause"),setTimeout(()=>this.me.playing=!1,3e3)),t==E.reset&&(Object.values(this.players).forEach(e=>e.streak=0),this.game.gameModeId!==u.ffa&&(this.game.teamScore=[0,0,0]),this.game.gameModeId===u.spatula&&(this.game.spatula.controlledBy=0,this.game.spatula.controlledByTeam=0,this.game.spatula.coords={x:0,y:0,z:0}),this.game.gameModeId===u.kotc&&(this.game.stage=y.capturing,this.game.zoneNumber=0,this.game.activeZone=null,this.game.capturing=0,this.game.captureProgress=0,this.game.numCapturing=0,this.game.stageName=B[y.capturing],this.game.capturePercent=0),this.emit("gameReset"))}#G(){if(!this.intents.includes(this.Intents.PING))return;const t=this.ping;this.ping=Date.now()-this.lastPingTime,this.emit("pingUpdate",t,this.ping),setTimeout(()=>{const e=f.getBuffer();e.packInt8(c.ping),e.send(this.game.socket),this.lastPingTime=Date.now()},this.pingInterval)}#F(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=this.players[t];if(!a)return;const i=a.team;a.team=e,a.streak=0,this.emit("playerSwitchTeam",a,i,e)}#R(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=s.unPackInt16U(),i=s.unPackInt16U(),n=s.unPackInt8U(),o=s.unPackInt16U(),h=s.unPackInt16U(),p=s.unPackInt16U(),I=s.unPackInt16U();s.unPackInt8(),s.unPackInt8();const k=this.intents.includes(this.Intents.COSMETIC_DATA),r=k?d(a):a,L=k?d(i):i,N=k?d(o):o,D=k?d(h):h,$=k?d(p):p,_=k?d(I):I,l=this.players[t];if(l){const v={...l.character},C=l.selectedGun;l.character.eggColor=n,l.character.primaryGun=r,l.character.secondaryGun=L,l.character.stamp=D,l.character.hat=N,l.character.grenade=$,l.character.melee=_,l.selectedGun=e,l.weapons[0]=new X[e],C!==l.selectedGun&&this.emit("playerChangeGun",l,C,l.selectedGun),v!==l.character&&this.emit("playerChangeCharacter",l,v,l.character)}}#M(){const t=s.unPackInt32U(),e=this.account.eggBalance;this.account.eggBalance=t,this.emit("balanceUpdate",t-e,t)}#B(){this.me.playing=!1,this.emit("selfRespawnFail")}#A(){const t=s.unPackInt8U(),e=this.players[t];e&&this.emit("playerMelee",e)}#O(){const t=s.unPackInt8U(),e=this.players[t];if(!e)return;const a=e.weapons[e.activeGun];if(a.ammo){const i=Math.min(Math.min(a.ammo.capacity,a.ammo.reload)-a.ammo.rounds,a.ammo.store);a.ammo.rounds+=i,a.ammo.store-=i}this.emit("playerReload",e,a)}#L(){const t=f.getBuffer();t.packInt8(c.gameOptions),t.packInt8(this.game.options.gravity*4),t.packInt8(this.game.options.damage*4),t.packInt8(this.game.options.healthRegen*4);const e=(this.game.options.locked?1:0)|(this.game.options.noTeamChange?2:0)|(this.game.options.noTeamShuffle?4:0);t.packInt8(e),this.game.options.weaponsDisabled.forEach(a=>{t.packInt8(a?1:0)}),t.send(this.game.socket)}#N(){const t=s.unPackInt8U();let e=s.unPackInt16U();const a=s.unPackFloat(),i=s.unPackFloat(),n=s.unPackFloat(),o=s.unPackInt8U(),h=s.unPackFloat();this.intents.includes(this.Intents.COSMETIC_DATA)&&(e=d(e)),t==V.Grenade?this.emit("grenadeExploded",e,{x:a,y:i,z:n},o,h):this.emit("rocketHit",{x:a,y:i,z:n},o,h)}#D(){const t=s.unPackInt8U(),e=s.unPackFloat(),a=s.unPackFloat(),i=s.unPackFloat(),n=s.unPackFloat(),o=s.unPackFloat(),h=s.unPackFloat(),p=this.players[t];p&&(p.grenades--,this.emit("playerThrowGrenade",p,{x:e,y:a,z:i},{x:n,y:o,z:h}))}#$(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=this.players[t];if(!a)return;if(!this.intents.includes(this.Intents.CHALLENGES))return this.emit("challengeComplete",a,e);const i=this.account.challenges.find(n=>n.id==e);this.emit("challengeComplete",a,i),a.id==this.me.id&&this.refreshChallenges()}#_(){const t=f.getBuffer();t.packInt8(c.joinGame),t.packString(this.state.name),t.packString(this.game.raw.uuid),t.packInt8(0),t.packInt8(this.state.weaponIdx||this.account?.loadout?.classIdx||0),t.packInt32(this.account.session),t.packString(this.account.firebaseId),t.packString(this.account.sessionId),t.send(this.game.socket)}async#z(){if(this.me.id=s.unPackInt8U(),this.me.team=s.unPackInt8U(),this.game.gameModeId=s.unPackInt8U(),this.game.gameMode=A[this.game.gameModeId],this.game.mapIdx=s.unPackInt8U(),this.game.map=S[this.game.mapIdx],this.intents.includes(this.Intents.PATHFINDING)&&(this.game.map.raw=await et(this.game.map.filename,this.game.map.hash),this.pathing.nodeList=new tt(this.game.map.raw),this.game.gameModeId===u.kotc)){const e=this.game.map.raw.data["DYNAMIC.capture-zone.none"];e?this.game.map.zones=st(e):delete this.game.map.zones}this.game.playerLimit=s.unPackInt8U(),this.game.isGameOwner=s.unPackInt8U()==1,this.game.isPrivate=s.unPackInt8U()==1,s.unPackInt8U(),this.state.joinedGame=!0,this.lastDeathTime=Date.now();const t=f.getBuffer();if(t.packInt8(c.clientReady),t.send(this.game.socket),this.game.socket.onmessage=e=>this.processPacket(e.data),this.updateIntervalId=setInterval(()=>this.update(),100/3),this.intents.includes(this.Intents.PING)){this.lastPingTime=Date.now();const e=f.getBuffer();e.packInt8(c.ping),e.send(this.game.socket)}this.emit("gameReady")}processPacket(t){s.init(t),this.intents.includes(this.Intents.PACKET_HOOK)&&this.emit("packet",t);let e=0,a=0,i=!1;for(;s.isMoreDataAvailable()&&!i;){const n=s.unPackInt8U();switch(n){case c.syncThem:this.#d();break;case c.fire:this.#k();break;case c.hitThem:this.#P();break;case c.syncMe:this.#w();break;case c.hitMe:this.#y();break;case c.swapWeapon:this.#p();break;case c.collectItem:this.#f();break;case c.respawn:this.#m();break;case c.die:this.#g();break;case c.pause:this.#u();break;case c.chat:this.#h();break;case c.addPlayer:this.#l();break;case c.removePlayer:this.#b();break;case c.eventModifier:this.#U();break;case c.metaGameState:this.#S();break;case c.beginShellStreak:this.#x();break;case c.endShellStreak:this.#v();break;case c.hitMeHardBoiled:this.#C();break;case c.gameOptions:this.#T();break;case c.ping:this.#G();break;case c.switchTeam:this.#F();break;case c.changeCharacter:this.#R();break;case c.reload:this.#O();break;case c.explode:this.#N();break;case c.throwGrenade:this.#D();break;case c.spawnItem:this.#I();break;case c.melee:this.#A();break;case c.updateBalance:this.#M();break;case c.challengeCompleted:this.#$();break;case c.socketReady:this.#_();break;case c.gameJoined:this.#z();break;case c.gameAction:this.#E();break;case c.requestGameOptions:this.#L();break;case c.respawnDenied:this.#B();break;case c.expireUpgrade:case c.clientReady:break;case c.musicInfo:s.unPackLongString();break;default:console.error(`handlePacket: I got but did not handle a: ${Object.keys(c).find(o=>c[o]===n)} ${n}`),e&&console.error(`handlePacket: It may be a result of the ${e} command (${a}).`),i=!0;break}e=Object.keys(c).find(o=>c[o]===n),a=n,this.intents.includes(this.Intents.LOG_PACKETS)&&console.log(`[LOG_PACKETS] Packet ${e}: ${a}`)}}async checkChiknWinner(){const t=await g({cmd:"chicknWinnerReady",id:this.account.id,sessionId:this.account.sessionId});return typeof t=="string"?t:(this.account.cw.limit=t.limit,this.account.cw.atLimit=t.limit>=4,this.account.cw.secondsUntilPlay=(this.account.cw.atLimit?t.period:t.span)||0,this.account.cw.canPlayAgain=Date.now()+this.account.cw.secondsUntilPlay*1e3,this.account.cw)}async playChiknWinner(t=!0){if(this.account.cw.atLimit||this.account.cw.limit>Z)return"hit_daily_limit";if(this.account.cw.canPlayAgain>Date.now()&&t)return"on_cooldown";const e=await g({cmd:"incentivizedVideoReward",firebaseId:this.account.firebaseId,id:this.account.id,sessionId:this.account.sessionId,token:null},this.proxy,`${this.protocol}://${this.instance}`);return typeof e=="string"?e:e.error?e.error=="RATELIMITED"||e.error=="RATELMITED"?(await this.checkChiknWinner(),"on_cooldown"):e.error=="SESSION_EXPIRED"?"session_expired":(console.error("Unknown Chikn Winner response",e),"unknown_error"):e.reward?(this.account.eggBalance+=e.reward.eggsGiven,e.reward.itemIds.forEach(a=>this.account.ownedItemIds.push(a)),await this.checkChiknWinner(),e.reward):(console.error("Unknown Chikn Winner response",e),"unknown_error")}async resetChiknWinner(){if(this.account.eggBalance<200)return"not_enough_eggs";if(!this.account.cw.atLimit)return"not_at_limit";const t=await g({cmd:"chwReset",sessionId:this.account.sessionId});return typeof t=="string"?t:t.result!=="SUCCESS"?(console.error("Unknown Chikn Winner reset response",t),"unknown_error"):(this.account.eggBalance-=200,await this.checkChiknWinner(),this.account.cw)}canSee(t){if(!this.intents.includes(this.Intents.PATHFINDING))throw new Error("You must have the PATHFINDING intent to use this method.");return this.pathing.nodeList.hasLineOfSight(this.me.position,t.position)}getBestTarget(t=()=>!0){const a=Object.values(this.players).filter(n=>n?.playing).filter(n=>n.hp>0).filter(n=>n.id!==this.me.id).filter(n=>this.me.team===0||n.team!==this.me.team).filter(n=>!!t(n)).map(n=>({player:n,distance:Math.sqrt(Math.pow(n.position.x-this.me.position.x,2)+Math.pow(n.position.y-this.me.position.y,2)+Math.pow(n.position.z-this.me.position.z,2))})).sort((n,o)=>n.distance-o.distance);if(!a.length)return this.intents.includes(this.Intents.DEBUG_BEST_TARGET)&&console.log("no targets found"),null;const i=a.find(n=>this.canSee(n.player));return this.intents.includes(this.Intents.DEBUG_BEST_TARGET)&&(console.log("detected ",a.length,"targets"),console.log("closest target: ",a[0].player.name),console.log("all targets (ordered): ",a.map(n=>n.player.name)),console.log("found LoS player?",!!i),i&&console.log("closest LoS player: ",i.player.name)),i?{player:i.player,inLoS:!0}:{player:a[0].player,inLoS:!1}}async refreshChallenges(){const t=await g({cmd:"challengeGetDaily",sessionId:this.account.sessionId,playerId:this.account.id},this.proxy,`${this.protocol}://${this.instance}`);return this.#a(t),this.account.challenges}async rerollChallenge(t){const e=await g({cmd:"challengeRerollSlot",sessionId:this.account.sessionId,slotId:t},this.proxy,`${this.protocol}://${this.instance}`);return this.#a(e),this.account.challenges}async claimChallenge(t){const e=await g({cmd:"challengeClaimReward",sessionId:this.account.sessionId,slotId:t},this.proxy,`${this.protocol}://${this.instance}`);return this.#a(e.challenges),e.reward>0&&(this.account.eggBalance+=e.reward),{eggReward:e.reward,updatedChallenges:this.account.challenges}}async refreshBalance(){const t=await g({cmd:"checkBalance",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId},this.proxy,`${this.protocol}://${this.instance}`);return this.account.eggBalance=t.currentBalance,t.currentBalance}async redeemCode(t){const e=await g({cmd:"redeem",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,id:this.account.id,code:t},this.proxy,`${this.protocol}://${this.instance}`);return e.result==="SUCCESS"?(this.account.eggBalance=e.eggs_given,e.item_ids.forEach(a=>this.account.ownedItemIds.push(a)),{result:e,eggsGiven:e.eggs_given,itemIds:e.item_ids}):e}async claimURLReward(t){const e=await g({cmd:"urlRewardParams",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,reward:t},this.proxy,`${this.protocol}://${this.instance}`);return e.result==="SUCCESS"&&(this.account.eggBalance+=e.eggsGiven,e.itemIds.forEach(a=>this.account.ownedItemIds.push(a))),e}async claimSocialReward(t){const e=await g({cmd:"reward",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,rewardTag:t},this.proxy,`${this.protocol}://${this.instance}`);return e.result==="SUCCESS"&&(this.account.eggBalance+=e.eggsGiven,e.itemIds.forEach(a=>this.account.ownedItemIds.push(a))),e}async buyItem(t){const e=await g({cmd:"buy",firebaseId:this.account.firebaseId,sessionId:this.account.sessionId,itemId:t,save:!0},this.proxy,`${this.protocol}://${this.instance}`);return e.result==="SUCCESS"&&(this.account.eggBalance=e.currentBalance,this.account.ownedItemIds.push(e.itemId)),e}leave(t=K.mainMenu){this.state.quit||(t>-1&&(this.game?.socket?.close(t),this.state.left=!0,this.emit("leave")),clearInterval(this.updateIntervalId),this.#e=[],this.state.reloading=!1,this.state.swappingGun=!1,this.state.usingMelee=!1,this.state.stateIdx=0,this.state.serverStateIdx=0,this.state.shotsFired=0,this.state.buffer=[],this.players={},this.me=new U({}),this.game=this.#o,this.ping=0,this.lastPingTime=-1,this.lastDeathTime=-1,this.lastChatTime=-1,this.lastUpdateTick=0,this.controlKeys=0,this.pathing={nodeList:null,followingPath:!1,activePath:null,activeNode:null,activeNodeIdx:0})}logout(){this.account=this.#n}quit(t=!1){this.state.quit||(this.leave(),this.matchmaker&&(this.matchmaker.close(),this.matchmaker=null),t||(delete this.account,delete this.game,delete this.me,delete this.players),this.state.quit=!0,this.emit("quit"))}}var yt=it;export{it as Bot,yt as default};
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- import{AUG as r,CSG1 as n,DozenGauge as a,Eggk47 as s,M24 as c,RPEGG as i,SMG as p}from"./guns.js";import{Items as l}from"./items.js";const x=t=>l.find(o=>o.id===t),k={none:0,pinned:2,team:4},g=3,S={AMMO:0,GRENADE:1},M={start:0,score:1,win:2,capturing:3,contested:4,takeover:5,abandoned:6,unclaimed:7},u="AIzaSyDP4SIjKaw6A4c-zvfYxICpbEjn1rRnN50",d=10,f=Math.ceil(30/d),E={reset:1,pause:2},G={ffa:0,team:1,spatula:2,kotc:3},R={locked:1,noTeamChange:2,noTeamShuffle:4},T=[s,a,n,i,p,c,r],e=typeof window<"u",y={Hat:1,Stamp:2,Primary:3,Secondary:4,Grenade:6,Melee:7},I={FORWARD:1,BACK:2,LEFT:4,RIGHT:8,JUMP:16,FIRE:32,MELEE:64,SCOPE:128},h={joinPublic:0,createPrivate:1,joinPrivate:2},b=!e&&typeof Bun>"u",B={HardBoiled:1,EggBreaker:2,Restock:4,OverHeal:8,DoubleEggs:16,MiniEgg:32},A={0:"Facebook",1:"Instagram",2:"Tiktok",3:"Discord",4:"Youtube",5:"Twitter",6:"Twitch"},C={Discord:"rew_1200",Tiktok:"rew_1208",Instagram:"rew_1219",Steam:"rew_1223",Facebook:"rew_1227",Twitter:"rew_1234",Twitch:"rew_twitch_social"},F={blue:1,red:2},P=["giveBasketBrosReward","mercZoneFinalGift","midMonthGiveMeEggs","newYolkerSignupReward","newYolkerItemReward","newYolkerWelcomeBack","WelcomeBack"],_=e?void 0:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36";export{k as ChatFlags,g as ChiknWinnerDailyLimit,S as CollectTypes,M as CoopStates,u as FirebaseKey,f as FramesBetweenSyncs,E as GameActions,G as GameModes,R as GameOptionFlags,T as GunList,e as IsBrowser,y as ItemTypes,I as Movements,h as PlayTypes,b as ProxiesEnabled,B as ShellStreaks,A as SocialMedias,C as SocialRewards,d as SyncRate,F as Teams,P as URLRewards,_ as UserAgent,x as findItemById};
3
+ import{AUG as r,CSG1 as n,DozenGauge as a,Eggk47 as s,M24 as c,RPEGG as i,SMG as p}from"./guns.js";import{Items as l}from"./items.js";const x=t=>l.find(o=>o.id===t),k={none:0,pinned:2,team:4},S=3,g={AMMO:0,GRENADE:1},f={start:0,score:1,win:2,capturing:3,contested:4,takeover:5,abandoned:6,unclaimed:7},u="AIzaSyDP4SIjKaw6A4c-zvfYxICpbEjn1rRnN50",d=10,M=Math.ceil(30/d),E={reset:1,pause:2},G={ffa:0,team:1,spatula:2,kotc:3},R={locked:1,noTeamChange:2,noTeamShuffle:4},T=[s,a,n,i,p,c,r],e=typeof window<"u",y={Hat:1,Stamp:2,Primary:3,Secondary:4,Grenade:6,Melee:7},I={FORWARD:1,BACK:2,LEFT:4,RIGHT:8,JUMP:16,FIRE:32,MELEE:64,SCOPE:128},h={joinPublic:0,createPrivate:1,joinPrivate:2},B=!e&&typeof Bun>"u",b={HardBoiled:1,EggBreaker:2,Restock:4,OverHeal:8,DoubleEggs:16,MiniEgg:32},A={0:"Facebook",1:"Instagram",2:"Tiktok",3:"Discord",4:"Youtube",5:"Twitter",6:"Twitch"},C={Discord:"rew_1200",Tiktok:"rew_1208",Instagram:"rew_1219",Steam:"rew_1223",Facebook:"rew_1227",Twitter:"rew_1234",Twitch:"rew_twitch_social"},F=256,P={blue:1,red:2},_=["giveBasketBrosReward","mercZoneFinalGift","midMonthGiveMeEggs","newYolkerSignupReward","newYolkerItemReward","newYolkerWelcomeBack","WelcomeBack"],v=e?void 0:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36";export{k as ChatFlags,S as ChiknWinnerDailyLimit,g as CollectTypes,f as CoopStates,u as FirebaseKey,M as FramesBetweenSyncs,E as GameActions,G as GameModes,R as GameOptionFlags,T as GunList,e as IsBrowser,y as ItemTypes,I as Movements,h as PlayTypes,B as ProxiesEnabled,b as ShellStreaks,A as SocialMedias,C as SocialRewards,F as StateBufferSize,d as SyncRate,P as Teams,_ as URLRewards,v as UserAgent,x as findItemById};
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- const t=[{active:!0,link:"https://www.youtube.com/watch?v=7afD9QxU_vA",desc:"",imageExt:"",id:"7afD9QxU_vA",author:"Godric Gryffindor",title:"I Play a Game of BINGO!",externalImg:"https://i.ytimg.com/vi/7afD9QxU_vA/hqdefault.jpg"},{active:!0,link:"https://www.youtube.com/watch?v=RQ1zgGzCkm0",desc:"",imageExt:"",id:"RQ1zgGzCkm0",author:"Clingzter ",title:"The Golden Dragon Side of Shell",externalImg:"https://i.ytimg.com/vi/RQ1zgGzCkm0/hqdefault.jpg"},{active:!0,link:"https://www.youtube.com/watch?v=I7MEVsuYVkY",desc:"",imageExt:"",id:"I7MEVsuYVkY",author:"Galactic",title:"Smooth Lofi gameplay w/Phoenix Yt",externalImg:"https://i.ytimg.com/vi/I7MEVsuYVkY/hqdefault.jpg"},{active:!0,link:"https://www.youtube.com/watch?v=LrfhRAK-nDs",desc:"",imageExt:"",id:"LrfhRAK-nDs",author:"Meep ",title:"10 KS w/ Golden Dragon Guns!",externalImg:"https://i.ytimg.com/vi/LrfhRAK-nDs/hqdefault.jpg"},{active:!0,link:"https://www.youtube.com/watch?v=vh39ORIN8L0",desc:"",imageExt:"",id:"vh39ORIN8L0",author:"ObviouslyNotJake",title:"Fight For The Masters!",externalImg:"https://i.ytimg.com/vi/vh39ORIN8L0/hqdefault.jpg"},{active:!0,link:"https://www.youtube.com/watch?v=S3pbYxiDl2E",desc:"",imageExt:"",id:"S3pbYxiDl2E",author:"The Rogue Contractor ",title:" \u{1F3AF}Snipes & Clutch Plays & 200 IQ Shots\u{1F525}",externalImg:"https://i.ytimg.com/vi/S3pbYxiDl2E/hqdefault.jpg"},{active:!0,link:"https://www.youtube.com/watch?v=w-YpgP2adGI",desc:"",imageExt:"",id:"w-YpgP2adGI",author:"Godric Gryffindor",title:"Into the Shadows Update",externalImg:"https://i.ytimg.com/vi/w-YpgP2adGI/hqdefault.jpg"},{active:!0,link:"https://www.youtube.com/watch?v=sS7lZxdobug",desc:"",imageExt:"",id:"sS7lZxdobug",author:"Sharkbucks",title:"Egg Org Went TOO FAR!",externalImg:"https://i.ytimg.com/vi/sS7lZxdobug/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};
3
+ const t=[{active:!0,link:"https://www.youtube.com/watch?v=6z9KKTk4kdw",desc:"",imageExt:"",id:"6z9KKTk4kdw",author:"TheKingmanYT",title:"1v1ing THE GOAT KT_VEI",externalImg:"https://i.ytimg.com/vi/6z9KKTk4kdw/hqdefault.jpg"},{active:!0,link:"https://www.youtube.com/watch?v=Jn1cT1PEi0s",desc:"",imageExt:"",id:"Jn1cT1PEi0s",author:"Meep ",title:"10 Kill Streak /w Ancient Guns! | New Update",externalImg:"https://i.ytimg.com/vi/Jn1cT1PEi0s/hqdefault.jpg"},{active:!0,link:"https://www.youtube.com/watch?v=iKx-xz5T_T8",desc:"",imageExt:"",id:"iKx-xz5T_T8",author:"Bubbleaxe",title:"WALKIN | Montage",externalImg:"https://i.ytimg.com/vi/iKx-xz5T_T8/hqdefault.jpg"},{active:!0,link:"https://www.youtube.com/watch?v=7afD9QxU_vA",desc:"",imageExt:"",id:"7afD9QxU_vA",author:"Godric Gryffindor",title:"I Play a Game of BINGO!",externalImg:"https://i.ytimg.com/vi/7afD9QxU_vA/hqdefault.jpg"},{active:!0,link:"https://www.youtube.com/watch?v=I7MEVsuYVkY",desc:"",imageExt:"",id:"I7MEVsuYVkY",author:"Galactic",title:"Smooth Lofi gameplay w/Phoenix Yt",externalImg:"https://i.ytimg.com/vi/I7MEVsuYVkY/hqdefault.jpg"},{active:!0,link:"https://www.youtube.com/watch?v=LrfhRAK-nDs",desc:"",imageExt:"",id:"LrfhRAK-nDs",author:"Meep ",title:"10 KS w/ Golden Dragon Guns!",externalImg:"https://i.ytimg.com/vi/LrfhRAK-nDs/hqdefault.jpg"},{active:!0,link:"https://www.youtube.com/watch?v=S3pbYxiDl2E",desc:"",imageExt:"",id:"S3pbYxiDl2E",author:"The Rogue Contractor ",title:" \u{1F3AF}Snipes & Clutch Plays & 200 IQ Shots\u{1F525}",externalImg:"https://i.ytimg.com/vi/S3pbYxiDl2E/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};
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- class t{constructor(e){this.amount=e||1}check(e){return e.me.playing&&!e.state.reloading&!e.state.swappingGun&&!e.state.usingMelee&&this.amount>=1&&e.me.weapons[e.me.activeGun].ammo.rounds>=this.amount}execute(e){e.state.shotsFired+=this.amount||1}}var a=t;export{t as FireDispatch,a as default};
3
+ class t{constructor(e){this.amount=e||1}check(e){return e.me.playing&&!e.state.reloading&&!e.state.swappingGun&&!e.state.usingMelee&&this.amount>=1&&e.me.weapons[e.me.activeGun].ammo.rounds>=this.amount}execute(e){e.state.shotsFired+=this.amount||1}}var a=t;export{t as FireDispatch,a as default};
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable */
2
2
 
3
- import a from"../comm/CommOut.js";import{CommCode as r}from"../constants/codes.js";class m{check(e){return!e.me.playing&&e.lastDeathTime+6e3<Date.now()}execute(e){const t=a.getBuffer();t.packInt8(r.requestRespawn),t.send(e.game.socket),e.lastSpawnedTime=Date.now(),e.me.playing=!0}}var s=m;export{m as SpawnDispatch,s as default};
3
+ import r from"../comm/CommOut.js";import{CommCode as a}from"../constants/codes.js";class m{check(e){return!e.me.playing&&e.lastDeathTime+6e3<Date.now()}execute(e){const t=r.getBuffer();t.packInt8(a.requestRespawn),t.send(e.game.socket),e.state.buffer=[]}}var f=m;export{m as SpawnDispatch,f as default};
@@ -1,17 +1,9 @@
1
1
  export interface QueryRequest {
2
2
  cmd: string;
3
- firebaseToken?: string;
3
+ [key: string]: any;
4
4
  }
5
5
 
6
6
  export interface QueryResponse {
7
- id?: number;
8
- firebaseId?: string;
9
- sessionId?: string;
10
- session?: number;
11
- kills?: number;
12
- deaths?: number;
13
- currentBalance?: number;
14
- // theres more that we don't use and don't type
15
7
  [key: string]: any;
16
8
  }
17
9
 
@@ -1,4 +1,4 @@
1
- import { AnyGun } from '../constants/guns';
1
+ import { AnyGun, Cluck9mm } from '../constants/guns';
2
2
  import { Item } from '../constants/items';
3
3
 
4
4
  export interface Position {
@@ -26,53 +26,57 @@ export interface Character {
26
26
  }
27
27
  }
28
28
 
29
- export interface Buffer {
30
- // not sure how buffers work
31
- // users dont need to access anyways
32
- [key: number]: any;
29
+ export interface PlayerStats {
30
+ killsInGame: number;
31
+ deathsInGame: number;
32
+ streak: number;
33
+ totalKills: number;
34
+ totalDeaths: number;
35
+ bestGameStreak: number;
36
+ bestOverallStreak: number;
33
37
  }
34
38
 
35
39
  export interface PlayerData {
36
- id_: string;
37
- uniqueId_: string;
38
- name_: string;
39
- safename_: string;
40
- charClass_: number;
41
- team_: 0 | 1 | 2;
42
- primaryWeaponItem_: Item | number;
43
- secondaryWeaponItem_: Item | number;
44
- shellColor_: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13;
45
- hatItem_: Item | number;
46
- stampItem_: Item | number;
47
- stampPosX_: number;
48
- stampPosY_: number;
49
- grenadeItem_: Item | number;
50
- meleeItem_: Item | number;
51
- x_: number;
52
- y_: number;
53
- z_: number;
54
- dx_: number;
55
- dy_: number;
56
- dz_: number;
57
- yaw_: number;
58
- pitch_: number;
59
- score_: number;
60
- kills_: number;
61
- deaths_: number;
62
- streak_: number;
63
- totalKills_: number;
64
- totalDeaths_: number;
65
- bestGameStreak_: number;
66
- bestOverallStreak_: number;
67
- shield_: number;
68
- hp_: number;
69
- playing_: boolean;
70
- weaponIdx_: number;
71
- controlKeys_: number;
72
- upgradeProductId_: number;
73
- activeShellStreaks_: number;
74
- social_: string;
75
- hideBadge_: boolean;
40
+ id: string;
41
+ uniqueId: string;
42
+ name: string;
43
+ safename: string;
44
+ charClass: number;
45
+ team: 0 | 1 | 2;
46
+ primaryWeaponItem: Item | number;
47
+ secondaryWeaponItem: Item | number;
48
+ shellColor: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13;
49
+ hatItem: Item | number;
50
+ stampItem: Item | number;
51
+ stampPosX: number;
52
+ stampPosY: number;
53
+ grenadeItem: Item | number;
54
+ meleeItem: Item | number;
55
+ x: number;
56
+ y: number;
57
+ z: number;
58
+ $dx: number;
59
+ $dy: number;
60
+ $dz: number;
61
+ yaw: number;
62
+ pitch: number;
63
+ score: number;
64
+ kills: number;
65
+ deaths: number;
66
+ streak: number;
67
+ totalKills: number;
68
+ totalDeaths: number;
69
+ bestGameStreak: number;
70
+ bestOverallStreak: number;
71
+ shield: number;
72
+ hp: number;
73
+ playing: boolean;
74
+ weaponIdx: number;
75
+ $controlKeys: number;
76
+ upgradeProductId: number;
77
+ activeShellStreaks: number;
78
+ social: string;
79
+ hideBadge: boolean;
76
80
  }
77
81
 
78
82
  export interface Social {
@@ -97,19 +101,19 @@ export class GamePlayer {
97
101
  climbing: boolean;
98
102
  view: View;
99
103
  character: Character;
104
+ stats: PlayerStats;
100
105
  activeGun: number;
101
106
  selectedGun: number;
102
- weapons: AnyGun[];
107
+ weapons: [AnyGun, Cluck9mm];
103
108
  grenades: number;
104
- buffer: Buffer;
105
109
  streak: number;
106
110
  hp: number;
107
111
  hpShield: number;
112
+ spawnShield: number;
108
113
  streakRewards: number[];
109
114
  randomSeed: number;
110
- serverStateIdx: number;
111
115
 
112
- constructor(id: string, team: string, playerData: PlayerData);
116
+ constructor(playerData: PlayerData);
113
117
  }
114
118
 
115
119
  export default GamePlayer;
@@ -1,3 +1,17 @@
1
+ type intents = {
2
+ CHALLENGES: 1,
3
+ STATS: 2,
4
+ PATHFINDING: 3,
5
+ PING: 5,
6
+ COSMETIC_DATA: 6,
7
+ PLAYER_HEALTH: 7,
8
+ PACKET_HOOK: 8,
9
+ LOG_PACKETS: 10,
10
+ NO_LOGIN: 11,
11
+ DEBUG_BUFFER: 12,
12
+ DEBUG_BEST_TARGET: 14
13
+ }
14
+
1
15
  import { NodeList } from '../pathing/mapnode.js';
2
16
 
3
17
  import { Character, GamePlayer } from './bot/GamePlayer';
@@ -115,7 +129,7 @@ export interface Account {
115
129
  monthly: Stats;
116
130
  }
117
131
  challenges: Challenges[];
118
- rawLoginData: any; // i ain't typing allat
132
+ rawLoginData: any; // someday i'll type it
119
133
  }
120
134
 
121
135
  export interface GameOptions {
@@ -210,20 +224,6 @@ export interface ChiknWinnerResponse {
210
224
  rewardTier: number;
211
225
  }
212
226
 
213
- type intents = {
214
- CHALLENGES: 1,
215
- STATS: 2,
216
- PATHFINDING: 3,
217
- BUFFERS: 4,
218
- PING: 5,
219
- COSMETIC_DATA: 6,
220
- PLAYER_HEALTH: 7,
221
- PACKET_HOOK: 8,
222
- MONITOR: 9,
223
- LOG_PACKETS: 10,
224
- NO_LOGIN: 11
225
- }
226
-
227
227
  export class Bot {
228
228
  static Intents: intents;
229
229
  Intents: intents;
@@ -264,9 +264,10 @@ export class Bot {
264
264
  update(): void;
265
265
 
266
266
  canSee(player: GamePlayer): boolean;
267
- getBestTarget(customFilter?: (player: GamePlayer) => boolean): GamePlayer | undefined;
267
+ getBestTarget(customFilter?: (player: GamePlayer) => boolean): { player: GamePlayer, inLoS: boolean } | undefined;
268
268
 
269
269
  onAny(cb: Function): void;
270
+ off(event: string, cb: Function): void;
270
271
 
271
272
  on(event: 'authFail', cb: (reason: string) => void): void;
272
273
  on(event: 'authSuccess', cb: (account: Account) => void): void;
@@ -282,6 +283,8 @@ export class Bot {
282
283
  on(event: 'gameReset', cb: () => void): void;
283
284
  on(event: 'gameStateChange', cb: (oldState: Game, newState: Game) => void): void;
284
285
  on(event: 'grenadeExploded', cb: (item: Item | number, pos: { x: number; y: number; z: number }, damage: number, radius: number) => void): void;
286
+ on(event: 'leave', cb: () => void): void;
287
+ on(event: 'packet', cb: (packet: ArrayBuffer) => void): void;
285
288
  on(event: 'pingUpdate', cb: (oldPing: number, newPing: number) => void): void;
286
289
  on(event: 'playerBeginStreak', cb: (player: GamePlayer, streak: number) => void): void;
287
290
  on(event: 'playerChangeCharacter', cb: (player: GamePlayer, oldCharacter: Character, newCharacter: Character) => void): void;
@@ -321,6 +324,7 @@ export class Bot {
321
324
  claimSocialReward(rewardTag: string): Promise<{ result: string; eggsGiven: number; itemIds: number[]; }>;
322
325
  buyItem(itemId: number): Promise<{ result: string; currentBalance: number; itemId: number; }>;
323
326
 
327
+ leave(code?: number): void;
324
328
  quit(noCleanup?: boolean): void;
325
329
  }
326
330
 
@@ -111,6 +111,8 @@ export declare const SocialRewards: {
111
111
  Twitch: string;
112
112
  }
113
113
 
114
+ export declare const StateBufferSize: number;
115
+
114
116
  export declare const Teams: {
115
117
  blue: number;
116
118
  red: number;
@@ -16,15 +16,17 @@ export interface Map {
16
16
  numPlayers: string;
17
17
  }
18
18
 
19
+ export interface MapCell {
20
+ x: number;
21
+ y: number;
22
+ z: number;
23
+ rx?: number;
24
+ ry?: number;
25
+ rz?: number;
26
+ }
27
+
19
28
  export interface MapData {
20
- [type: string]: {
21
- x: number;
22
- y: number;
23
- z: number;
24
- rx?: number;
25
- ry?: number;
26
- rz?: number;
27
- }[];
29
+ [type: string]: MapCell[];
28
30
  }
29
31
 
30
32
  export interface MapSun {
@@ -7,7 +7,6 @@ type Position = {
7
7
  }
8
8
 
9
9
  export declare class LookAtPosDispatch {
10
- idOrName: any;
11
10
  pos: Position;
12
11
 
13
12
  constructor(pos: Position);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "yolkbot",
3
3
  "description": "create a shell shockers bot in under 10 lines.",
4
- "version": "0.1.5-alpha.9",
4
+ "version": "1.0.1",
5
5
  "keywords": [
6
6
  "shell shockers",
7
7
  "shellshock.io",
@@ -16,7 +16,7 @@
16
16
  "author": "1ust",
17
17
  "repository": {
18
18
  "type": "git",
19
- "url": "https://github.com/yolkorg/yolkbot.git"
19
+ "url": "git+https://github.com/yolkorg/yolkbot.git"
20
20
  },
21
21
  "type": "module",
22
22
  "files": [