diff options
author | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-03-01 21:25:13 +0800 |
---|---|---|
committer | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-03-01 21:25:13 +0800 |
commit | c71b4f83abb2697781f8e6eafa8ad35f924fbdf7 (patch) | |
tree | 7e992f047e1b19864cea8cee1671573a44cf20de /features/dungeonMap/index.js | |
parent | 556eedeb7d58909cb716abe16d2c40910acdc43c (diff) | |
download | SoopyV2-c71b4f83abb2697781f8e6eafa8ad35f924fbdf7.tar.gz SoopyV2-c71b4f83abb2697781f8e6eafa8ad35f924fbdf7.tar.bz2 SoopyV2-c71b4f83abb2697781f8e6eafa8ad35f924fbdf7.zip |
many changes (will list in a bit)
Diffstat (limited to 'features/dungeonMap/index.js')
-rw-r--r-- | features/dungeonMap/index.js | 302 |
1 files changed, 244 insertions, 58 deletions
diff --git a/features/dungeonMap/index.js b/features/dungeonMap/index.js index dadfef2..95369dc 100644 --- a/features/dungeonMap/index.js +++ b/features/dungeonMap/index.js @@ -8,6 +8,10 @@ import { f, m } from "../../../mappings/mappings"; import renderLibs from "../../../guimanager/renderLibs"; import ToggleSetting from "../settings/settingThings/toggle"; import { drawBoxAtBlock } from "../../utils/renderUtils"; +import { SoopyGui, SoopyRenderEvent } from "../../../guimanager"; +import SoopyGuiElement from "../../../guimanager/GuiElement/SoopyGuiElement"; +import SoopyMouseClickEvent from "../../../guimanager/EventListener/SoopyMouseClickEvent"; +import ButtonWithArrow from "../../../guimanager/GuiElement/ButtonWithArrow"; const BufferedImage = Java.type("java.awt.image.BufferedImage") class DungeonMap extends Feature { @@ -24,6 +28,7 @@ class DungeonMap extends Feature { this.renderMap = new ToggleSetting("Render Map", "Toggles Rendering the map on the hud (scuffed)", false, "dmap_render", this) this.brBox = new ToggleSetting("Box around doors in br", "In map category because it uses map to find location (no esp)", true, "dmap_door", this) + this.spiritLeapOverlay = new ToggleSetting("Spirit leap overlay", "Cool overlay for the spirit leap menu", true, "spirit_leap_overlay", this) this.MAP_QUALITY_SCALE = 2 this.IMAGE_SIZE = 128*this.MAP_QUALITY_SCALE @@ -32,6 +37,7 @@ class DungeonMap extends Feature { this.playerImages = {} this.mapDataPlayers = {} this.offset = [] + this.people = [] this.mapScale = 1 this.puzzles = {} this.puzzlesTab = [] @@ -46,11 +52,17 @@ class DungeonMap extends Feature { this.mapLocation = [10,10] this.mapRenderScale = 128/this.IMAGE_SIZE + this.spiritLeapOverlayGui = new SpiritLeapOverlay(this) + // this.registerEvent("tick", this.tick) this.registerStep(true, 3, this.step) this.registerEvent("renderOverlay", this.renderOverlay) this.registerEvent("renderWorld", this.renderWorld) this.registerEvent("worldLoad", this.worldLoad) + + this.registerEvent("guiOpened", (event)=>{ + if(this.spiritLeapOverlay.getValue()) this.spiritLeapOverlayGui.guiOpened.call(this.spiritLeapOverlayGui, event) + }) this.running = true this.registerEvent("gameUnload", ()=>{ @@ -86,7 +98,6 @@ class DungeonMap extends Feature { this.mapScale = 1 this.puzzles = {} this.puzzlesTab = [] - this.newPuzzlesTab = [] this.brBoxLoc = undefined this.mortLocationOnMap = undefined } @@ -101,52 +112,58 @@ class DungeonMap extends Feature { renderOverlay(){ if(this.isInDungeon() && this.renderMap.getValue()){ - if(this.mapImage){ - this.mapImage.draw(...this.mapLocation, this.mapRenderScale*this.IMAGE_SIZE, this.mapRenderScale*this.IMAGE_SIZE) - - this.drawOtherMisc() - - this.drawPlayersLocations() - } + this.drawMap(...this.mapLocation, this.mapRenderScale*this.IMAGE_SIZE, this.mapRenderScale) + } + } + + drawMap(x, y, size, scale){ + if(this.mapImage){ + this.mapImage.draw(x, y, size, size) + + this.drawOtherMisc(x, y, size, scale) + + this.drawPlayersLocations(x, y, size, scale) } } - drawOtherMisc(){ + drawOtherMisc(x2, y2, size2, scale){ Object.keys(this.puzzles).forEach(loc=>{ + if(!this.puzzles[loc]) return let x = loc%128 let y = Math.floor(loc/128) let lines = this.puzzles[loc].split(" ") lines.forEach((l, i)=>{ - renderLibs.drawStringCentered("&0&l" + l, x+this.mapLocation[0]+this.roomWidth/2*this.mapRenderScale*2-l.length/2*this.mapRenderScale*2, y+this.mapLocation[1]+this.roomWidth/3*this.mapRenderScale*2+i*6*this.mapRenderScale*2-((lines.length-1)*3+4)*this.mapRenderScale*2, this.mapRenderScale*2) + renderLibs.drawStringCentered("&0&l" + l, x*scale*2+x2+this.roomWidth/2*scale*2-l.length/2*scale*2, y*scale*2+y2+this.roomWidth/3*scale*2+i*6*scale*2-((lines.length-1)*3+4)*scale*2, scale*2) }) }) } - drawPlayersLocations(){ + drawPlayersLocations(x, y, size, scale){ let uuidToPlayer = {} World.getAllPlayers().forEach(player=>{ + if(player.getPing()===-1)return + if(!this.people.includes(player.getName())) return uuidToPlayer[player.getUUID().toString()] = player + this.mapDataPlayers[player.getUUID().toString()] = { + x: player.getX(), + y: player.getZ(), + rot: player.getYaw()+180, + username: player.getName(), + uuid: player.getUUID().toString() + } }) Object.keys(this.mapDataPlayers).forEach((uuid)=>{ - let player = uuidToPlayer[uuid] - if(player){ - this.mapDataPlayers[uuid] = { - x: player.getX()/this.mapScale, - y: player.getZ()/this.mapScale, - rot: player.getYaw()+180 - } - } - - let renderX = this.mapDataPlayers[uuid].x/128*this.mapRenderScale*this.IMAGE_SIZE//*16/this.roomWidth - let renderY = this.mapDataPlayers[uuid].y/128*this.mapRenderScale*this.IMAGE_SIZE//*16/this.roomWidth + let renderX = this.mapDataPlayers[uuid].x/this.mapScale/128*size//*16/this.roomWidth + let renderY = this.mapDataPlayers[uuid].y/this.mapScale/128*size//*16/this.roomWidth - Renderer.translate(renderX+this.mapLocation[0]+this.offset[0]/128*this.mapRenderScale*this.IMAGE_SIZE, renderY+this.mapLocation[1]+this.offset[1]/128*this.mapRenderScale*this.IMAGE_SIZE) + Renderer.translate(renderX+x+this.offset[0]/128*size, renderY+y+this.offset[1]/128*size) + Renderer.scale(scale*2, scale*2) Renderer.rotate(this.mapDataPlayers[uuid].rot) this.getImageForPlayer(uuid).draw(-5,-5, 10, 10) }) @@ -155,27 +172,51 @@ class DungeonMap extends Feature { step(){ if(!World.getWorld()) return // console.log("asjbfoasbgp") - TabList.getNames().forEach(name=>{ - name = ChatLib.removeFormatting(name).trim().split(" ") + this.people = [] + this.puzzlesTab = [] + TabList.getNames().forEach(nameo=>{ + + +// Party (2) | Soopyboo32 (Mage XXXVI) | Ultimate: Ready | Revive Stones: 1 | | zZzJAKE ♲ (DEAD) | Ultimate: 00m 45s | Revive Stones: 0 | | | | | | | | | | | | | Player Stats | Downed: zZzJAKE | Time: 00m 47s | Revive: 01m 40s | | Deaths: (2) | Damage Dealt: 4.7M❤ | Healing Done: 718❤ | Milestone: ☠❸ | | Discoveries: (0) | Secrets Found: 0 | Crypts: 0 | | | | | | | | Dungeon Stats | Dungeon: Catacombs | Opened Rooms: 13 | Completed Rooms: 12 | Secrets Found: 0% | Time: 01m 51s | | Puzzles: (3) | ???: [✦] | ???: [✦] | ???: [✦] | | | | | | | | | | Account Info | Profile: Pomegranate | Pet Sitter: N/A | Bank: 57M/11M | Interest: 04h 19m 10s | | Skills: Combat 60: MAX | Speed: ✦457 | Strength: ❁859 | Crit Chance: ☣62 | Crit Damage: ☠1479 | Attack Speed: ⚔92 | | Event: Election Over! | Starts In: 2h 39m 10s | | Election: 0d 2h 39m 10s | Aatrox: |||||||||| (79%) | Marina: |||||||||| (7%) | Cole: |||||||||| (6%) | Soopyboo32 + let line = ChatLib.removeFormatting(nameo).trim().replace("♲ ","") //TODO: Remove bingo symbol + if(line.endsWith(")") && line.includes(" (") && line.split(" (").length === 2 && line.split(" (")[0].split(" ").length === 1 && line.split(" (")[1].length>5){ + this.people.push(line.split(" ")[0]) + } + + name = ChatLib.removeFormatting(nameo).trim().split(" ") let end = name.pop() - if(end !== "[✦]") return + // console.log(end) Water Board: [✔] + if(end !== "[✦]" && end !== "[✔]") return name = name.join(" ").trim().replace(":", "") - if(name.length > 1 && !name.includes("?") && !this.puzzlesTab.includes(name)){ - this.newPuzzlesTab.push(name) + if(name.length > 1 && !name.includes("?")){ this.puzzlesTab.push(name) } + // console.log(name) + }) + let puzzlesTab2 = this.puzzlesTab.map(a=>a) + // console.log(this.puzzlesTab.length) + Object.keys(this.puzzles).forEach(key=>{ + this.puzzles[key] = puzzlesTab2.shift() + // console.log(key, this.puzzles[key], this.puzzlesTab.length) }) + + this.spiritLeapOverlayGui.tick() } updateMapImage(){ World.getAllPlayers().forEach(player=>{ + if(player.getPing()===-1)return + if(!this.people.includes(player.getName())) return this.mapDataPlayers[Player.getUUID().toString()] = { - x: player.getX()/this.mapScale, - y: player.getZ()/this.mapScale, - rot: player.getYaw()+180 + x: player.getX(), + y: player.getZ(), + rot: player.getYaw()+180, + username: player.getName(), + uuid: player.getUUID().toString() } }) if(!this.mortLocation){ + try{ World.getAllEntities().forEach(entity=>{ if(ChatLib.removeFormatting(entity.getName()) === ("Mort")){ this.mortLocation = [ @@ -184,6 +225,7 @@ class DungeonMap extends Feature { ] } }) + }catch(e){} } let graphics = this.renderImage.getGraphics() @@ -198,29 +240,6 @@ class DungeonMap extends Feature { } catch (error) { } if(mapData){ - let deco = mapData[f.mapDecorations] - deco.forEach((icon, vec4b) => { - let x = vec4b.func_176112_b() - let y = vec4b.func_176113_c() - let rot = vec4b.func_176111_d() - - //wtf is this - - //vec4b.func_176110_a() - - let closestP = undefined - let closestDistance = Infinity - Object.keys(this.mapDataPlayers).forEach((uuid)=>{ - if((x-this.mapDataPlayers[uuid].x)**2+(y-this.mapDataPlayers[uuid].y)**2 < closestDistance){ - closestDistance = (x-this.mapDataPlayers[uuid].x)**2+(y-this.mapDataPlayers[uuid].y)**2 - closestP = uuid - } - }) - - this.mapDataPlayers[closestP].x = x - this.mapDataPlayers[closestP].y = y - this.mapDataPlayers[closestP].rot = rot - }); // console.log("has map data poggies") let bytes = mapData[f.colors.MapData] @@ -320,8 +339,8 @@ class DungeonMap extends Feature { } // mortLocationOnMap = mortLocationOnMap*16/this.roomWidth if(bytes[x+y*128] === 66 && bytes[(x-1)+(y)*128] === 0 && bytes[(x)+(y-1)*128] === 0){ - if(!this.puzzles[x+y*128] && this.newPuzzlesTab.length > 0){ - this.puzzles[x+y*128] = this.newPuzzlesTab.shift() + if(!this.puzzles[x+y*128]){ + this.puzzles[x+y*128] = "Loading" } } @@ -398,11 +417,51 @@ class DungeonMap extends Feature { this.roomWidth = roomWidth this.mortLocationOnMap = this.mortLocationOnMap + + if(this.mortLocation && mortLocationOnMap && roomWidth){ + let deco = mapData[f.mapDecorations] + this.extraDeco = [] + try{ + deco.forEach((icon, vec4b) => { + let x = vec4b.func_176112_b() + let y = vec4b.func_176113_c() + let rot = vec4b.func_176111_d() + x = x/2+64 + y = y/2+64 + rot=rot*360/16+180 + + + x= (x-mortLocationOnMap[0])/roomWidth*32+this.mortLocation[0] + y= (y-mortLocationOnMap[1])/roomWidth*32+this.mortLocation[1] + + + //wtf is this + + //vec4b.func_176110_a() + + + let closestP = undefined + let closestDistance = Infinity + Object.keys(this.mapDataPlayers).forEach((uuid)=>{ + if((x-this.mapDataPlayers[uuid].x)**2+(y-this.mapDataPlayers[uuid].y)**2 < closestDistance){ + closestDistance = (x-this.mapDataPlayers[uuid].x)**2+(y-this.mapDataPlayers[uuid].y)**2 + closestP = uuid + } + }) + if(closestP){ + // console.log(closestP, x, y) + this.mapDataPlayers[closestP].x = x + this.mapDataPlayers[closestP].y = y + this.mapDataPlayers[closestP].rot = rot + } + }); + }catch(e){} + } + let newMapImageThing = new Image(this.renderImage) + this.mapImage = newMapImageThing } - let newMapImageThing = new Image(this.renderImage) - this.mapImage = newMapImageThing // this.mapImage.setImage(this.renderImage) } @@ -440,4 +499,131 @@ class DungeonMap extends Feature { module.exports = { class: new DungeonMap() +} + +const ContainerChest = Java.type("net.minecraft.inventory.ContainerChest") +class SpiritLeapOverlay { + constructor(parent){ + this.parent = parent + + this.soopyGui = new SoopyGui() + + let renderThing = new soopyGuiMapRendererThing(this).setLocation(0,0,1,1) + this.soopyGui.element.addChild(renderThing) + + this.buttonsContainer = new SoopyGuiElement().setLocation(0.25,0.6, 0.5, 0.4) + this.soopyGui.element.addChild(this.buttonsContainer) + + this.items = {} + } + + guiOpened(event){ + if(event.gui && event.gui.field_147002_h instanceof ContainerChest){ + name = event.gui.field_147002_h.func_85151_d().func_145748_c_().func_150260_c() + if(name === "Spirit Leap"){ + this.soopyGui.open() + } + } + } + + tick(){ + let itemsNew = {} + + if(Player.getOpenedInventory()?.getName() === "Spirit Leap"){ + for(let i = 1;i<9*3;i++){ + let item = Player.getOpenedInventory().getStackInSlot(i) + if(item && item.getID()!==160){ + itemsNew[item.getName()] = i + } + } + } + + if(JSON.stringify(this.items) !== JSON.stringify(itemsNew)){ + this.items = itemsNew + this.buttonsContainer.clearChildren() + Object.keys(this.items).forEach((name, i)=>{ //TODO: make the button to leap to the last person to open a door a diff color AND MAKE IT UPDATE LIVE + let button = new ButtonWithArrow().setText(name).addEvent(new SoopyMouseClickEvent().setHandler(()=>{ + Player.getOpenedInventory().click(itemsNew[name]) + ChatLib.chat("Leaping to " + name) + })).setLocation(0,i/5,1,1/5) + this.buttonsContainer.addChild(button) + }) + } + } +} + +class soopyGuiMapRendererThing extends SoopyGuiElement { + constructor(parent){ + super() + + this.parentE = parent + + this.addEvent(new SoopyRenderEvent().setHandler((mouseX, mouseY)=>{ + let size2 = Math.min(Renderer.screen.getWidth()/2, Renderer.screen.getHeight()/2) + + let [x, y, size, scale] = [Renderer.screen.getWidth()/2-size2/2,Renderer.screen.getHeight()/3-size2/2, size2, size2/this.parentE.parent.IMAGE_SIZE] + + this.parentE.parent.drawMap(x, y, size, scale) + + if(mouseY>y+size2) return + let closestPlayer = this.getClosestPlayerTo(x, y, size, scale, mouseX, mouseY) + + if(closestPlayer){ + let renderX = closestPlayer.x/this.parentE.parent.mapScale/128*size//*16/this.roomWidth + let renderY = closestPlayer.y/this.parentE.parent.mapScale/128*size//*16/this.roomWidth + + Renderer.translate(renderX+x+this.parentE.parent.offset[0]/128*size, renderY+y+this.parentE.parent.offset[1]/128*size) + renderLibs.drawStringCentered("&a" + closestPlayer.username, 0,-10*scale*3, 2) + Renderer.translate(renderX+x+this.parentE.parent.offset[0]/128*size, renderY+y+this.parentE.parent.offset[1]/128*size) + Renderer.scale(scale*3, scale*3) + Renderer.rotate(closestPlayer.rot) + this.parentE.parent.getImageForPlayer(closestPlayer.uuid).draw(-5,-5, 10, 10) + } + })) + this.addEvent(new SoopyMouseClickEvent().setHandler((mouseX, mouseY)=>{ + let size2 = Math.min(Renderer.screen.getWidth()/2, Renderer.screen.getHeight()/2) + + let [x, y, size, scale] = [Renderer.screen.getWidth()/2-size2/2,Renderer.screen.getHeight()/3-size2/2, size2, size2/this.parentE.parent.IMAGE_SIZE] + + if(mouseY>y+size2) return + + let closestPlayer = this.getClosestPlayerTo(x, y, size, scale, mouseX, mouseY) + + if(closestPlayer){ + if(Player.getOpenedInventory()?.getName() === "Spirit Leap"){ + for(let i = 1;i<9*3;i++){ + let item = Player.getOpenedInventory().getStackInSlot(i) + if(item && item.getID()!==160){ + if(ChatLib.removeFormatting(item.getName()) === closestPlayer.username){ + Player.getOpenedInventory().click(i) + ChatLib.chat("Leaping to " + closestPlayer.username) + } + } + } + } + } + })) + } + + getClosestPlayerTo(x, y, size, scale, scanX, scanY){ + + let closest = null + let closestD = Infinity + Object.keys(this.parentE.parent.mapDataPlayers).forEach((uuid)=>{ + + if(uuid === Player.getUUID()) return + + let renderX = this.parentE.parent.mapDataPlayers[uuid].x/this.parentE.parent.mapScale/128*size//*16/this.roomWidth + let renderY = this.parentE.parent.mapDataPlayers[uuid].y/this.parentE.parent.mapScale/128*size//*16/this.roomWidth + + let distance = (renderX+x+this.parentE.parent.offset[0]/128*size-scanX)**2+ (renderY+y+this.parentE.parent.offset[1]/128*size-scanY)**2 + + if(distance < closestD){ + closestD = distance + closest = this.parentE.parent.mapDataPlayers[uuid] + } + }) + + return closest + } }
\ No newline at end of file |