yolkbot 1.0.17 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/build/global.js +2 -2
- package/browser/build/module.js +2 -2
- package/dist/bot/GamePlayer.js +1 -1
- package/dist/bot.js +1 -1
- package/dist/constants/changelog.js +1 -1
- package/dist/constants/shellYoutube.js +1 -1
- package/dist/types/bot.d.ts +25 -16
- package/dist/wasm/imports.js +2 -2
- package/dist/wasm/utils.js +1 -1
- package/dist/wasm/wrapper.js +1 -1
- package/package.json +1 -1
package/dist/bot/GamePlayer.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
import{GunList as
|
|
3
|
+
import{GunList as o,Movement as n,ReverseSocialMedia as m,ShellStreak as c}from"../constants/index.js";import{Cluck9mm as d}from"../constants/guns.js";class u{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=m[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&n.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={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 o[this.selectedGun],this.weapons[1]=new d),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 g=u;export{u as GamePlayer,g as default};
|
package/dist/bot.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
import H 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 C from"./bot/GamePlayer.js";import j from"./matchmaker.js";import W from"./socket.js";import{ChiknWinnerDailyLimit as Z,CollectType as G,CoopState as U,findItemById as d,FramesBetweenSyncs as b,GameAction as F,GameMode as p,GunList as q,ItemType as $,Movement as S,PlayType as Y,ProxiesEnabled as J,RawGameModes as M,RawGameOptionFlags as R,ShellStreak as u,StateBufferSize as v}from"./constants/index.js";import O from"./dispatches/LookAtPosDispatch.js";import A from"./dispatches/MovementDispatch.js";import{NodeList as Q}from"./pathing/mapnode.js";import{coords as X}from"./wasm/wrapper.js";import{fetchMap as V,initKotcZones as tt}from"./util.js";import{Challenges as et}from"./constants/challenges.js";import{Maps as y}from"./constants/maps.js";const B=Object.fromEntries(Object.entries(U).map(([I,t])=>[t,I.toLowerCase()])),L=Object.fromEntries(Object.entries(p).map(([I,t])=>[t,I])),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,KOTC_ZONES:15},x=(I,t)=>(I%t+t)%t;class st{static Intents=N;Intents=N;#e=[];#t={};#i=[];#n;#o;constructor(t={}){t.proxy&&!J&&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)&&(d(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 C({}),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:U.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 H({instance:this.instance,protocol:this.protocol,proxy:this.proxy,httpProxy:this.httpProxy,maxRetries:t?.apiMaxRetries}),this.ping=0,this.lastPingTime=-1,this.lastDeathTime=-1,this.lastUpdateTick=0,this.pathing={nodeList:null,followingPath:!1,activePath:null,activeNode:null,activeNodeIdx:0},this.hasQuit=!1}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=et.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 j({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 M[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=l=>{l.command==="gameFound"&&(this.matchmaker.off("msg",n),o(l))};this.matchmaker.on("msg",n),this.matchmaker.send({command:"findGame",region:t.region,playType:Y.CreatePrivate,gameType:M[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 W(`${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 O(e))):(e=this.pathing.activePath[this.pathing.activeNodeIdx].flatCenter(),this.dispatch(new O(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&S.Forward||this.dispatch(new A(S.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&S.Jump),this.state.buffer[t]={controlKeys:this.state.controlKeys,yaw:this.state.yaw,pitch:this.state.pitch,shotsFired:this.state.shotsFired},this.state.shotsFired=0,this.lastUpdateTick>=2){this.emit("tick");const e=f.getBuffer();e.packInt8(c.syncMe),e.packInt8(this.state.stateIdx),e.packInt8(this.state.serverStateIdx);const a=x(this.state.stateIdx-b+1,v);for(let i=0;i<b;i++){const o=x(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,l=this.state.buffer[o]?.pitch||this.state.pitch,r=X(n,l);e.packString(r),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,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(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]}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?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();const i=new C(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("botJoined",this.me))}#m(){const t=s.unPackInt8U(),e=s.unPackInt16U(),a=s.unPackFloat(),i=s.unPackFloat(),o=s.unPackFloat(),n=s.unPackInt8U(),l=s.unPackInt8U(),r=s.unPackInt8U(),g=s.unPackInt8U(),k=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=l),h.weapons[1]&&h.weapons[1].ammo&&(h.weapons[1].ammo.rounds=r),h.weapons[1]&&h.weapons[1].ammo&&(h.weapons[1].ammo.store=g),h.grenades=k,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 r=0;r<b;r++)s.unPackInt8U(),s.unPackRadU(),s.unPackRad(),s.unPackInt8U();return}for(let r=0;r<b;r++)s.unPackInt8U()&S.Jump?n.jumping=!0:n.jumping=!1,n.view.yaw=s.unPackRadU(),n.view.pitch=s.unPackRad(),s.unPackInt8U();const l=n.position.x!==e||n.position.y!==a||n.position.z!==i||n.climbing!==o;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),l&&(this.emit("playerMove",n,n.position),this.game.gameModeId===p.KOTC)){const r=this.game.activeZone;if(!r){n.inKotcZone&&(n.inKotcZone=!1,this.emit("playerLeaveZone",n,r));return}const g=Math.round(e),k=Math.floor(a),h=Math.round(i),w=r.some(P=>P.x===g&&P.y===k&&P.z===h);n.inKotcZone&&!w?(n.inKotcZone=!1,this.emit("playerLeaveZone",n)):!n.inKotcZone&&w&&(n.inKotcZone=!0,this.emit("playerEnterZone",n))}}#d(){const t=s.unPackInt8U(),e=this.players[t];e&&(e.playing=!1,this.emit("playerPause",e))}#p(){const t=s.unPackInt8U(),e=s.unPackInt8U(),a=this.players[t];a&&(a.activeGun=e,this.emit("playerSwapWeapon",a,e))}#g(){const t=s.unPackInt8U(),e=s.unPackInt8U();s.unPackInt8U(),s.unPackInt8U(),s.unPackInt8U();const a=this.players[t],i=this.players[e];a&&(a.playing=!1,a.streak=0,a.lastDeathTime=Date.now(),a.hp=100,a.spawnShield=0,a.stats.deathsInGame++,a.stats.totalDeaths++),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();for(let i=0;i<6;i++)s.unPackFloat();const e=this.players[t];if(!e)return;const a=e.weapons[e.activeGun];a&&a.ammo&&(a.ammo.rounds--,this.emit("playerFire",e,a))}#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,t,{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("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(),o=s.unPackFloat(),n=s.unPackFloat();if(this.me.climbing=!!s.unPackInt8U(),s.unPackInt8U(),s.unPackInt8U(),!e)return;this.state.serverStateIdx=a;const l=e.position.x,r=e.position.y,g=e.position.z;e.position.x=i,e.position.y=o,e.position.z=n,(l!==i||r!==o||g!==n)&&this.emit("selfMoved",e,{x:l,y:r,z:g},{x:i,y:o,z:n})}#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===p.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===p.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===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}#C(){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)}#v(){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)}#x(){const t=s.unPackInt8U(),e=s.unPackInt8U();s.unPackFloat(),s.unPackFloat(),this.me.shieldHp=t,this.me.hp=e,this.me.shieldHp<=0?(this.me.streakRewards=this.me.streakRewards.filter(a=>a!==u.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 o=s.unPackInt8U();return Object.keys(R).forEach(n=>{const l=o&R[n]?1:0;this.game.options[n]=l}),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}#E(){const t=s.unPackInt8U();t===F.Pause&&(this.emit("gameForcePause"),setTimeout(()=>this.me.playing=!1,3e3)),t===F.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=U.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[U.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()},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(),l=s.unPackInt16U(),r=s.unPackInt16U(),g=s.unPackInt16U();s.unPackInt8(),s.unPackInt8();const k=this.intents.includes(this.Intents.COSMETIC_DATA),h=k?d(a):a,w=k?d(i):i,P=k?d(n):n,D=k?d(l):l,_=k?d(r):r,z=k?d(g):g,m=this.players[t];if(m){const T={...m.character},E=m.selectedGun;m.character.eggColor=o,m.character.primaryGun=h,m.character.secondaryGun=w,m.character.stamp=D,m.character.hat=P,m.character.grenade=_,m.character.melee=z,m.selectedGun=e,m.weapons[0]=new q[e],E!==m.selectedGun&&this.emit("playerChangeGun",m,E,m.selectedGun),T!==m.character&&this.emit("playerChangeCharacter",m,T,m.character)}}#R(){const t=s.unPackInt32U(),e=this.account.eggBalance;this.account.eggBalance=t,this.emit("balanceUpdate",t-e,t)}#O(){this.me.playing=!1,this.emit("selfRespawnFail")}#A(){const t=s.unPackInt8U(),e=this.players[t];e&&this.emit("playerMelee",e)}#B(){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=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)}#L(){this.updateGameOptions()}#N(){const t=s.unPackInt8U();let e=s.unPackInt16U();const a=s.unPackFloat(),i=s.unPackFloat(),o=s.unPackFloat(),n=s.unPackInt8U(),l=s.unPackFloat();this.intents.includes(this.Intents.COSMETIC_DATA)&&(e=d(e)),t===$.Grenade?this.emit("grenadeExploded",e,{x:a,y:i,z:o},n,l):this.emit("rocketHit",{x:a,y:i,z:o},n,l)}#D(){const t=s.unPackInt8U(),e=s.unPackFloat(),a=s.unPackFloat(),i=s.unPackFloat(),o=s.unPackFloat(),n=s.unPackFloat(),l=s.unPackFloat(),r=this.players[t];r&&(r.grenades--,this.emit("playerThrowGrenade",r,{x:e,y:a,z:i},{x:o,y:n,z:l}))}#_(){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()}#z(){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#H(){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.intents.includes(this.Intents.KOTC_ZONES)||this.intents.includes(this.Intents.PATHFINDING)){if(this.game.map.raw=await V(this.game.map.filename,this.game.map.hash),this.game.gameModeId===p.KOTC){const e=this.game.map.raw.data["DYNAMIC.capture-zone.none"];e?this.game.map.zones=tt(e):delete this.game.map.zones}this.intents.includes(this.Intents.PATHFINDING)&&(this.pathing.nodeList=new Q(this.game.map.raw))}this.game.playerLimit=s.unPackInt8U(),this.game.isGameOwner=s.unPackInt8U()===1,this.game.isPrivate=s.unPackInt8U()===1,s.unPackInt8U(),this.state.inGame=!0,this.lastDeathTime=Date.now();const t=f.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=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 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.#C();break;case c.endShellStreak:this.#v();break;case c.hitMeHardBoiled:this.#x();break;case c.gameOptions:this.#T();break;case c.ping:this.#G();break;case c.switchTeam:this.#F();break;case c.changeCharacter:this.#M();break;case c.reload:this.#B();break;case c.explode:this.#N();break;case c.throwGrenade:this.#D();break;case c.spawnItem:this.#f();break;case c.melee:this.#A();break;case c.updateBalance:this.#R();break;case c.challengeCompleted:this.#_();break;case c.socketReady:this.#z();break;case c.gameJoined:this.#H();break;case c.gameAction:this.#E();break;case c.requestGameOptions:this.#L();break;case c.respawnDenied:this.#O();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>Z)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=K.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 C({}),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),this.hasQuit=!0)}}var Pt=st;export{st as Bot,Pt as default};
|
|
3
|
+
import H 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 E,CoopState as w,findItemById as p,FramesBetweenSyncs as U,GameAction as G,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 O 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 A=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,KOTC_ZONES:15,NO_AFK_KICK:16},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 H({instance:this.instance,protocol:this.protocol,proxy:this.proxy,httpProxy:this.httpProxy,maxRetries:t?.apiMaxRetries}),this.ping=0,this.lastPingTime=-1,this.lastDeathTime=-1,this.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 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 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 O(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===E.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===E.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=A[this.game.stage],this.game.capturePercent=this.game.captureProgress/1e3,this.game.activeZone=this.game.map.zones?this.game.map.zones[this.game.zoneNumber-1]:null,this.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}#E(){const t=s.unPackInt8U();t===G.Pause&&(this.emit("gameForcePause"),setTimeout(()=>this.me.playing=!1,3e3)),t===G.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=A[w.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=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,K=P?p(i):i,_=P?p(n):n,D=P?p(r):r,Z=P?p(d):d,z=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=K,l.character.stamp=D,l.character.hat=_,l.character.grenade=Z,l.character.melee=z,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)}#O(){this.me.playing=!1,this.emit("respawnDenied")}#A(){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)}#K(){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}))}#_(){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()}#D(){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.KOTC_ZONES)||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.#G();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.#K();break;case c.spawnItem:this.#f();break;case c.melee:this.#A();break;case c.updateBalance:this.#R();break;case c.challengeCompleted:this.#_();break;case c.socketReady:this.#D();break;case c.gameJoined:this.#Z();break;case c.gameAction:this.#E();break;case c.requestGameOptions:this.#B();break;case c.respawnDenied:this.#O();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};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
const e=[{version:"1.0.
|
|
3
|
+
const e=[{version:"1.0.8",date:"May 3 2025",content:["Hit the gas with the latest Shell Shockers update introducing our smash new game - Kartbros.io.","Enjoy the new Kart Bros items, plus some of the other faves from the Kart and Bros sets in-store now.","Start your engines - a new VIP item has entered the store - Try the Premium Banana Grenade!","The Ridge Racer Bundle features The slick F1 racer Melee - wipe out your frenemies!","So we kinda broke controllers a little bit - fixed for all the joystick jockeys.","Another range of bug fixes, optimizations, ratchet tightening and squeegeeing has taken place behind the scenes.","Buckle up for the eggsciting new map: Zoomies - in public & private lobbies.","The Public Map pool has been switched and now contains 15 of your favorite Shell Shockers Maps."]}];export{e as Changelog};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
const t=[{active:!0,link:"https://www.youtube.com/watch?v=pFWVehYYD6c",desc:"",imageExt:"",id:"pFWVehYYD6c",author:"Clingzter ",title:"The Ancient Side of Shell Shockers",externalImg:"https://i.ytimg.com/vi/pFWVehYYD6c/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=hp7WXq1PjeM",desc:"",imageExt:"",id:"hp7WXq1PjeM",author:"Godric Gryffindor",title:"Top 5 Most Popular Maps",externalImg:"https://i.ytimg.com/vi/hp7WXq1PjeM/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=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=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=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=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=pFWVehYYD6c",desc:"",imageExt:"",id:"pFWVehYYD6c",author:"Clingzter ",title:"The Ancient Side of Shell Shockers",externalImg:"https://i.ytimg.com/vi/pFWVehYYD6c/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=hp7WXq1PjeM",desc:"",imageExt:"",id:"hp7WXq1PjeM",author:"Godric Gryffindor",title:"Top 5 Most Popular Maps",externalImg:"https://i.ytimg.com/vi/hp7WXq1PjeM/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=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=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=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};
|
package/dist/types/bot.d.ts
CHANGED
|
@@ -10,13 +10,14 @@ type intents = {
|
|
|
10
10
|
NO_LOGIN: 11,
|
|
11
11
|
DEBUG_BUFFER: 12,
|
|
12
12
|
DEBUG_BEST_TARGET: 14,
|
|
13
|
-
KOTC_ZONES: 15
|
|
13
|
+
KOTC_ZONES: 15,
|
|
14
|
+
NO_AFK_KICK: 16
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
import { Character, GamePlayer, Position } from './bot/GamePlayer';
|
|
17
18
|
import { Challenge } from './constants/challenges';
|
|
18
19
|
import { AnyGun } from './constants/guns';
|
|
19
|
-
import {
|
|
20
|
+
import { MapJSON } from './constants/maps';
|
|
20
21
|
import { Item } from './constants/items';
|
|
21
22
|
import { ADispatch } from './dispatches/index';
|
|
22
23
|
import { NodeList } from './pathing/mapnode';
|
|
@@ -177,7 +178,7 @@ export interface GameMap {
|
|
|
177
178
|
};
|
|
178
179
|
availability: string;
|
|
179
180
|
numPlayers: string;
|
|
180
|
-
raw:
|
|
181
|
+
raw: MapJSON;
|
|
181
182
|
zones: Zone[][];
|
|
182
183
|
}
|
|
183
184
|
|
|
@@ -250,6 +251,15 @@ export interface ChiknWinnerResponse {
|
|
|
250
251
|
rewardTier: number;
|
|
251
252
|
}
|
|
252
253
|
|
|
254
|
+
export interface FireBullet {
|
|
255
|
+
posX: number;
|
|
256
|
+
posY: number;
|
|
257
|
+
posZ: number;
|
|
258
|
+
dirX: number;
|
|
259
|
+
dirY: number;
|
|
260
|
+
dirZ: number;
|
|
261
|
+
}
|
|
262
|
+
|
|
253
263
|
export class Bot {
|
|
254
264
|
static Intents: intents;
|
|
255
265
|
Intents: intents;
|
|
@@ -303,7 +313,7 @@ export class Bot {
|
|
|
303
313
|
on(event: 'authSuccess', cb: (account: Account) => void): void;
|
|
304
314
|
on(event: 'balanceUpdate', cb: (oldBalance: number, newBalance: number) => void): void;
|
|
305
315
|
on(event: 'banned', cb: (banRemaining: string) => void): void;
|
|
306
|
-
on(event: '
|
|
316
|
+
on(event: 'botJoin', cb: (botPlayer: GamePlayer) => void): void;
|
|
307
317
|
on(event: 'challengeComplete', cb: (player: GamePlayer, challengeId: number) => void): void;
|
|
308
318
|
on(event: 'chat', cb: (player: GamePlayer | undefined, message: string, flags: number) => void): void;
|
|
309
319
|
on(event: 'close', cb: (code: number) => void): void;
|
|
@@ -315,35 +325,34 @@ export class Bot {
|
|
|
315
325
|
on(event: 'gameReady', cb: () => void): void;
|
|
316
326
|
on(event: 'gameReset', cb: () => void): void;
|
|
317
327
|
on(event: 'gameStateChange', cb: (oldState: Game, newState: Game) => void): void;
|
|
318
|
-
on(event: '
|
|
328
|
+
on(event: 'grenadeExplode', cb: (item: Item | number, pos: Position, damage: number, radius: number) => void): void;
|
|
319
329
|
on(event: 'leave', cb: (closeCode: number) => void): void;
|
|
330
|
+
on(event: 'mapLoad', cb: (map: MapJSON) => void): void;
|
|
320
331
|
on(event: 'packet', cb: (packet: ArrayBuffer) => void): void;
|
|
321
332
|
on(event: 'pingUpdate', cb: (oldPing: number, newPing: number) => void): void;
|
|
322
333
|
on(event: 'playerBeginStreak', cb: (player: GamePlayer, streakType: number) => void): void;
|
|
323
334
|
on(event: 'playerChangeCharacter', cb: (player: GamePlayer, oldCharacter: Character, newCharacter: Character) => void): void;
|
|
324
|
-
on(event: 'playerChangeGun', cb: (player: GamePlayer,
|
|
325
|
-
on(event: '
|
|
326
|
-
on(event: 'playerDeath', cb: (
|
|
335
|
+
on(event: 'playerChangeGun', cb: (player: GamePlayer, oldGunId: number, newGunId: number) => void): void;
|
|
336
|
+
on(event: 'playerDamage', cb: (player: GamePlayer, oldHp: number, newHp: number) => void): void;
|
|
337
|
+
on(event: 'playerDeath', cb: (killed: GamePlayer, killer: GamePlayer) => void): void;
|
|
327
338
|
on(event: 'playerEndStreak', cb: (player: GamePlayer, streakType: number) => void): void;
|
|
328
339
|
on(event: 'playerEnterZone', cb: (player: GamePlayer) => void): void;
|
|
329
|
-
on(event: 'playerFire', cb: (player: GamePlayer, weapon: AnyGun) => void): void;
|
|
340
|
+
on(event: 'playerFire', cb: (player: GamePlayer, weapon: AnyGun, bullet: FireBullet) => void): void;
|
|
330
341
|
on(event: 'playerJoin', cb: (player: GamePlayer) => void): void;
|
|
331
342
|
on(event: 'playerLeave', cb: (player: GamePlayer) => void): void;
|
|
332
343
|
on(event: 'playerLeaveZone', cb: (player: GamePlayer) => void): void;
|
|
333
344
|
on(event: 'playerMelee', cb: (player: GamePlayer) => void): void;
|
|
334
|
-
on(event: 'playerMove', cb: (player: GamePlayer,
|
|
345
|
+
on(event: 'playerMove', cb: (player: GamePlayer, oldPosition: Position, newPosition: Position) => void): void;
|
|
335
346
|
on(event: 'playerPause', cb: (player: GamePlayer) => void): void;
|
|
336
347
|
on(event: 'playerReload', cb: (player: GamePlayer, weapon: AnyGun) => void): void;
|
|
337
348
|
on(event: 'playerRespawn', cb: (player: GamePlayer) => void): void;
|
|
338
349
|
on(event: 'playerSwapWeapon', cb: (player: GamePlayer, nowActive: number) => void): void;
|
|
339
350
|
on(event: 'playerSwitchTeam', cb: (player: GamePlayer, oldTeam: number, newTeam: number) => void): void;
|
|
351
|
+
on(event: 'respawnDenied', cb: () => void): void;
|
|
340
352
|
on(event: 'rocketHit', cb: (pos: Position, damage: number, blastRadius: number) => void): void;
|
|
341
|
-
on(event: '
|
|
342
|
-
on(event: '
|
|
343
|
-
on(event: '
|
|
344
|
-
on(event: 'selfShieldHit', cb: (oldShieldHealth: number, newShieldHealth: number) => void): void;
|
|
345
|
-
on(event: 'selfShieldLost', cb: () => void): void;
|
|
346
|
-
on(event: 'spawnItem', cb: (itemType: number, uniqueItemId: number, itemPosition: Position) => void): void;
|
|
353
|
+
on(event: 'selfShieldHit', cb: (newShieldHealth: number, newPlayerHealth: number, dir: { dx: number, dz: number }) => void): void;
|
|
354
|
+
on(event: 'selfShieldLost', cb: (newPlayerHealth: number, dir: { dx: number, dz: number }) => void): void;
|
|
355
|
+
on(event: 'spawnItem', cb: (itemType: number, itemPosition: Position) => void): void;
|
|
347
356
|
on(event: 'tick', cb: () => void): void;
|
|
348
357
|
|
|
349
358
|
checkChiknWinner(): Promise<ChiknWinnerStatus>;
|
package/dist/wasm/imports.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
import{
|
|
3
|
+
import{addToExternrefTable as r,getStringFromWasm as g,passStringToWasm as f}from"./utils.js";const p=`
|
|
4
4
|
var comp_spinner_overlay = {
|
|
5
5
|
template: '#spinner-overlay-template',
|
|
6
6
|
components: {
|
|
@@ -122,4 +122,4 @@ var comp_spinner_overlay = {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
|
-
`,
|
|
125
|
+
`,m={},a={textContent:""},S=(_,b)=>{const h=new FinalizationRegistry(t=>{_().__wbindgen_export_5.get(t.dtor)(t.a,t.b)}),l=(t,e,i,o)=>{const n={a:t,b:e,cnt:1,dtor:i},s=(...u)=>{n.cnt++;const d=n.a;n.a=0;try{return o(d,n.b,...u)}finally{--n.cnt===0?(_().__wbindgen_export_5.get(n.dtor)(d,n.b),h.unregister(n)):n.a=d}};return s.original=n,h.register(s,n,n),s},w=(t,e,i)=>_().closure30_externref_shim(t,e,i);let c=1;return{wbg:{__wbg_addEventListener_90e553fdce254421:(t,e,i,o)=>m[g(_(),e,i)]=o,__wbg_appendChild_8204974b7328bf98:()=>{},__wbg_axes_b1da727bd9ea422d:()=>{},__wbg_body_942ea927546a04ba:()=>r(_(),null),__wbg_call_672a4d21634d4a24:()=>{},__wbg_childNodes_c4423003f3a9441f:()=>[],__wbg_createElement_8c9931a732ee2fea:()=>a,__wbg_document_d249400bd7bd996d:()=>r(_(),{}),__wbg_from_2a5d3e218e67aa85:(...t)=>Array.from(t[0]),__wbg_getElementById_f827f0d6648718a8:()=>r(_(),{}),__wbg_getGamepads_1f997cef580c9088:(...t)=>t[0].getGamepads(),__wbg_get_67b2ba62fc30de12:(...t)=>Reflect.get(t[0],t[1]),__wbg_get_b9b93047fe3cf45b:(...t)=>t[0][t[1]>>>0],__wbg_instanceof_Gamepad_365ec8404255ce00:()=>!0,__wbg_instanceof_HtmlCanvasElement_2ea67072a7624ac5:()=>!0,__wbg_instanceof_Window_def73ea0955fc569:()=>!0,__wbg_isTrusted_cc994b7949c53593:()=>!0,__wbg_item_8be407c958853a13:(...t)=>r(_(),t[0][t[1]>>>0]),__wbg_length_49b2ba67f0897e97:()=>(c--,c<=0?(c=1,0):c),__wbg_length_e2d2a49132c1b256:(...t)=>t[0].length,__wbg_movementX_1aa05f864931369b:(...t)=>t[0].movementX,__wbg_movementY_8acfedb38a70e624:(...t)=>t[0].movementY,__wbg_navigator_1577371c070c8947:(...t)=>t[0].navigator,__wbg_new_405e22f390576ce2:()=>new Object,__wbg_newnoargs_105ed471475aaf50:()=>{},__wbg_nodeType_5e1153141daac26a:()=>3,__wbg_now_807e54c39636c349:()=>b.processDate||Date.now(),__wbg_set_bb8cecf6a62b9f46:(...t)=>Reflect.set(t[0],t[1],t[2]),__wbg_settextContent_d29397f7b994d314:async(...t)=>{a.textContent=g(_(),t[1],t[2]),b.processListeners.forEach(e=>e(a.textContent))},__wbg_static_accessor_GLOBAL_88a902d13a557d07:()=>{},__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0:()=>{},__wbg_static_accessor_SELF_37c5d418e4bf5819:()=>r(_(),{}),__wbg_static_accessor_WINDOW_5de37043a91a9c40:()=>{},__wbg_textContent_215d0f87d539368a:(t,e)=>{const[i,o]=f(_(),e===a?a.textContent:p),n=new DataView(_().memory.buffer);n.setInt32(t+4*1,o,!0),n.setInt32(t+4*0,i,!0)},__wbindgen_debug_string:()=>{},__wbindgen_init_externref_table:()=>{},__wbindgen_throw:()=>{},__wbindgen_number_new:t=>t,__wbindgen_string_new:(t,e)=>g(_(),t,e),__wbindgen_string_get:(t,e)=>{const i=g(_(),t,e),[o,n]=f(_(),i),s=new DataView(_().memory.buffer);s.setInt32(t+4*1,n,!0),s.setInt32(t+4*0,o,!0)},__wbindgen_is_undefined:t=>t===void 0?1:0,__wbindgen_is_null:t=>t===null?1:0,__wbindgen_boolean_get:t=>{const e=t;return typeof e=="boolean"?e?1:0:2},__wbindgen_closure_wrapper94:(t,e)=>l(t,e,31,w),__wbindgen_closure_wrapper95:(t,e)=>l(t,e,31,w),__wbindgen_number_get:(t,e)=>{const i=e,o=typeof i=="number"?i:void 0,n=new DataView(_().memory.buffer);n.setFloat64(t+8*1,o,!0),n.setInt32(t+4*0,1,!0)}}}};export{m as canvasListeners,S as getImports};
|
package/dist/wasm/utils.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const o=(r,n,e)=>(n>>>=0,new TextDecoder().decode(new Uint8Array(r.memory.buffer).subarray(n,n+e))),a=(r,n)=>{const e=new TextEncoder().encode(n),t=r.__wbindgen_malloc(e.length,1)>>>0;return new Uint8Array(r.memory.buffer).subarray(t,t+e.length).set(e),[t,e.length]},c=(r,n)=>{const e=r.__externref_table_alloc();return r.__wbindgen_export_2.set(e,n),e};export{c as addToExternrefTable,o as getStringFromWasm,a as passStringToWasm};
|
package/dist/wasm/wrapper.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
|
-
import{canvasListeners as
|
|
3
|
+
import{canvasListeners as p,getImports as g}from"./imports.js";import{getStringFromWasm as M,passStringToWasm as c}from"./utils.js";import{wasmBytes as P}from"./bytes.js";const m={processListeners:[],processDate:null},l={};let e;Object.assign(l,g(()=>e,m));const Y=await WebAssembly.instantiate(P,l);e=Y.instance.exports;const y=async(t,s)=>{s&&(m.processDate=s);const n=new Promise(a=>m.processListeners.push(a)),[o,i]=c(e,t);return e.process(o,i),n},_=t=>{let s,n;try{const[o,i]=c(e,t),a=e.validate(o,i);return s=a[0],n=a[1],M(e,s,n)}finally{e.__wbindgen_free(s,n,1)}},h=t=>{for(;t<0;)t+=2*Math.PI;for(;t>=2*Math.PI;)t-=2*Math.PI;return t},I=(t,s,n,o)=>{const i=h(t);let r=h(n)-i;Math.abs(r)>Math.PI&&(r=r>0?r-2*Math.PI:r+2*Math.PI);const w=o-s,u=.0025,v=.0025,f=Math.round(-r/u),d=Math.round(-w/v);return{movementX:f,movementY:d}},b=(t,s)=>{if(!p.pointermove){e.start();const[a,r]=c(e,[...Array(14)].map(()=>Math.random().toString(36)[2]).join(""));e.set_mouse_params(50,1,.9,!1,a,r)}const n=e.get_yaw_pitch(),o=I(n.yaw,n.pitch,t,s);return p.pointermove({isTrusted:!0,movementX:o.movementX,movementY:o.movementY}),e.get_yaw_pitch().coords};export{b as coords,y as process,_ as validate};
|