let wasmbuffers; let wasmmodule = async () => { const Module = { repeater: 0 };…
- User
let wasmbuffers;
let wasmmodule = async () => { const Module = { repeater: 0 };
Module.decodeBlendInternal = blended => { Module.asm.j(24, 132); const pos = Module.asm.j(228, 132); const extra = new Uint8Array(blended); for (let i = 0; i < 132; i++) { Module.HEAPU8[pos + i] = extra[i + 1]; } Module.asm.j(172, 36); const index = Module.asm.j(4, 152); const arraybuffer = new ArrayBuffer(64); const list = new Uint8Array(arraybuffer); for (let i = 0; i < 64; i++) { list[i] = Module.HEAPU8[index + i]; } return arraybuffer; }; Module.onDecodeOpcode5 = (blended, hostname, callback) => { Module.blended = blended; Module.hostname = hostname; if (!Module.ready) return (Module.opcode5Callback = callback); Module.asm.j(255, 140); const decoded = Module.decodeBlendInternal(blended); const mcs = Module.asm.j(187, 22); const opcode6Data = [6]; for (let i = 0; i < 16; i++) { opcode6Data.push(Module.HEAPU8[mcs + i]); } callback({ 5: decoded, 6: new Uint8Array(opcode6Data) }); }; Module.finalizeOpcode10 = blended => { const decoded = Module.decodeBlendInternal(blended); const list = new Uint8Array(decoded); const data = [10]; for (let i = 0; i < decoded.byteLength; i++) { data.push(list[i]); } return new Uint8Array(data); }; const instantiate = async (wasmbuffers) => { const asm = await WebAssembly.instantiate(wasmbuffers, { "a": { 'd': () => { }, 'f': () => { }, 'c': () => { }, 'e': () => { }, 'b': () => [0, 0, 1, 0, 24][(Module.repeater %= 5, Module.repeater++)], 'a': () => (Module.HEAPU8.set(new Uint8Array([...new TextEncoder().encode(Module.hostname)]), 200), 200) } }); Module.asm = asm.instance.exports; Module.HEAPU8 = new Uint8Array(Module.asm.g.buffer); Module.asm.h(); Module.asm.i(0, 0); Module.ready = true; if (Module.opcode5Callback) Module.onDecodeOpcode5(Module.blended, Module.hostname, Module.opcode5Callback); }; if (wasmbuffers) { await instantiate(wasmbuffers); } else { const response = await fetch("https://cdn.glitch.global/ac6cfcd4-73cc-46ca-87ec-b913932b390f/zombs_wasm%20(4).wasm?v=1705666953205"); const buffer = await response.arrayBuffer(); wasmbuffers = new Uint8Array(buffer); await instantiate(wasmbuffers); } return Module;};
class Bot { constructor(name = "", sid = "") { this.name = name; this.ws = null; this.serverId = sid || game.options.serverId; this.server = game.options.servers[this.serverId]; this.codec = null; this.Module = null; this.enterworld2 = null; }
async initialize() { this.ws = new WebSocket(`wss://${this.server.hostname}:443/`); this.ws.binaryType = "arraybuffer"; this.ws.onmessage = this.onMessage.bind(this); this.codec = new game.networkType().codec; this.Module = await wasmmodule(); } sendPacket(event, data) { if (this.ws && this.ws.readyState === 1) { this.ws.send(this.codec.encode(event, data)); } } async onMessage(msg) { const opcode = new Uint8Array(msg.data)[0]; if (opcode == 5) { this.Module.onDecodeOpcode5(new Uint8Array(msg.data), this.server.ipAddress, e => { this.sendPacket(4, { displayName: this.name, extra: e[5] }); this.enterworld2 = e[6]; }); return; } if (opcode == 10) { this.ws.send(this.Module.finalizeOpcode10(new Uint8Array(msg.data))); return; } const data = this.codec.decode(msg.data); switch (opcode) { case 4: this.onEnterWorldHandler(data); break; } } onEnterWorldHandler(data) { if (!data.allowed) return; this.uid = data.uid; this.enterworld2 && this.ws.send(this.enterworld2); this.sendPacket(9, { name: "JoinPartyByShareKey", partyShareKey: game.ui.playerPartyShareKey }); for (let i = 0; i < 26; i++) this.ws.send(new Uint8Array([3, 17, 123, 34, 117, 112, 34, 58, 49, 44, 34, 100, 111, 119, 110, 34, 58, 48, 125])); this.ws.send(new Uint8Array([7, 0])); this.ws.send(new Uint8Array([9, 6, 0, 0, 0, 126, 8, 0, 0, 108, 27, 0, 0, 146, 23, 0, 0, 82, 23, 0, 0, 8, 91, 11, 0, 8, 91, 11, 0, 0, 0, 0, 0, 32, 78, 0, 0, 76, 79, 0, 0, 172, 38, 0, 0, 120, 155, 0, 0, 166, 39, 0, 0, 140, 35, 0, 0, 36, 44, 0, 0, 213, 37, 0, 0, 100, 0, 0, 0, 120, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 134, 6, 0, 0])); console.log("bot in game"); } - Assistant
- User
Promises and async/await, implement this option
- Assistant