
Updated guide for simple automation in Mr. Mine, heavily inspired by others work but fixes most of the problems introduces with the recent updates. Intro I in no way take credit for most of the work, just fixing what was broken. Make sure you back up your files before making any changes so that you can always revert back to the original in need, or comment the old code with "//" or "/* */". Files are located in your steam game folder. Probably in "C: Program Files (x86) Steam steamapps common MrMine". Resources Automatically sell resources when full Auto Sell File to modify: resources/app/Shared/mineralmanagement.js Function to modify: getUsedMineralCapacity() Replace: function getUsedMineralCapacity() { capacity = cachedCountsTowardsCapacityAndValue.reduce((sum, resource) => sum + resource.numOwned, 0) if(!isSimulating) { if(mutecapacity == 0 && isCapacityFull()) { capacityFullAudio.play(); } } } With: function getUsedMineralCapacity() { capacity = cachedCountsTowardsCapacityAndValue.reduce((sum, resource) => sum + resource.numOwned, 0) if(!isSimulating) { if(mutecapacity == 0 && isCapacityFull()) { capacityFullAudio.play(); } if(mutecapacity == 1 && isCapacityFull()) { sellAllMinerals(0); } } } TLDR: Add an "if" statement that checks if resources are full and alarms is set to off, then sells everything. Auto Sell Moon Resources File to modify: resources/app/Shared/mineralmanagement.js Function to modify: sellAllMinerals() Replace: function sellAllMinerals(tab) { //need to set up for isotopes? var moneyPriorToSale = money; if(tab == 0) { for(var i = 1; i < 13; i++) { sellMineral(i); } } else if(tab == 1) { for(var i = 18; i < 27; i++) { sellMineral(i); } } var totalSaleProceeds = money - moneyPriorToSale; if(totalSaleProceeds > 100000000000000000n) { questManager.getQuest(55).markComplete(); } } With: function sellAllMinerals(tab) { //need to set up for isotopes? var moneyPriorToSale = money; if(tab == 0) { for(var i = 1; i <= 17; i++) { sellMineral(i); } } else if(tab == 1) { for(var i = 18; i < 27; i++) { sellMineral(i); } } var totalSaleProceeds = money - moneyPriorToSale; if(totalSaleProceeds > 100000000000000000n) { questManager.getQuest(55).markComplete(); } } TLDR: Change the index range to include the moon resources when selling all by changing the condition from "< 13" to "<= 17". Combat Battle automation IMPORTANT FOR BOSS FIGHTS: If you have the "Auto collect chest reward" configured, you will need to hold the "SHIFT" key when you kill the boss to collect the chest normally and move on to the next stage of digging, else you will not move on and you will loop and need to fight the boss again. Auto Attack File to modify: resources/app/popups/BattleWindow.js Function to modify: render() Replace: this.context.fillStyle = "#dddddd"; this.context.globalAlpha = 0.8; this.context.fillRect(weaponChargeX, weaponChargeY, (weaponChargeWidth * pcentAtk), this.boundingBox.height * .05); this.context.globalAlpha = 1; With: this.context.fillStyle = "#dddddd"; this.context.globalAlpha = 0.8; this.context.fillRect(weaponChargeX, weaponChargeY, (weaponChargeWidth * pcentAtk), this.boundingBox.height * .05); this.context.globalAlpha = 1; atk(bi); TLDR: Add a line "atk(bi);" to automate attack with each weapon when ready. Auto start fight File to modify: resources/app/Shared/battle.js Function to modify:spawnBattleOnFloor() Replace: function spawnBattleOnFloor(spawnY, spawnX) { if(battleWaiting.length == 0 && depth > 303) { if(!isDepthWithoutWorkers(spawnY)) { newNews(_("Miner #{0} is being attacked at Depth {1}km!", spawnX, spawnY), true); var somePrand = battleSpawnRoller.rand(0, 100); var whichFromTable = 0; if(somePrand < 5) { whichFromTable = 2; } else if(somePrand < 25) { whichFromTable = 1; } var spawnMonDetails = monstersOnLevels[Math.floor((spawnY - 300) / 10)][whichFromTable]; battleWaiting = [spawnX, spawnY, spawnMonDetails[0], spawnMonDetails[1]]; } } } With: function spawnBattleOnFloor(spawnY, spawnX) { if(battleWaiting.length == 0 && depth > 303) { if(!isDepthWithoutWorkers(spawnY)) { newNews(_("Miner #{0} is being attacked at Depth {1}km!", spawnX, spawnY), true); var somePrand = battleSpawnRoller.rand(0, 100); var whichFromTable = 0; if(somePrand < 5) { whichFromTable = 2; } else if(somePrand < 25) { whichFromTable = 1; } var spawnMonDetails = monstersOnLevels[Math.floor((spawnY - 300) / 10)][whichFromTable]; battleWaiting = [spawnX, spawnY, spawnMonDetails[0], spawnMonDetails[1]]; onWorkerClicked((battleWaiting[1] + 5 - currentlyViewedDepth), battleWaiting[0]); } } } TLDR: Simulates clicking on the attacked worker by adding the line "onWorkerClicked((battleWaiting[1] + 5 - currentlyViewedDepth), battleWaiting[0]);" Chest automation Chest collection automation Auto open new chest File to modify: resources/app/Shared/src/chest/ChestService.js Function to modify: spawnChest() Replace: spawnChest(spawnDepth, source = Chest.natural, type = ChestType.basic, miner = -1) { var isCollectable = (source == Chest.natural || source == Chest.superminer) && !this.isChestCollectorFull(); var collectionRoll = (chestSpawnRoller.rand(1, 100) <= this.getStoredChestsChance()); let chanceOfCollision = (this.chests.length + 1) / (depth / 10); //this is here to simulate how chest spawns acted in the old system. var canSpawnInWorld = source != Chest.natural || !chestSpawnRoller.boolean(chanceOfCollision); console.log("spawnChest - "+canSpawnInWorld+" - "+chanceOfCollision+" - "+collectionRoll); if(isCollectable && collectionRoll) { this.storeChest(type); return true; } else if(canSpawnInWorld) { //check if miner already has a chest or is an invalid index if(miner < 0 || this.getChest(spawnDepth, miner) || miner > workersHiredAtDepth(spawnDepth)) { var availableMiners = this.getAvailableMiners(spawnDepth); var minerIndex = rand(0, availableMiners.length - 1); miner = availableMiners[minerIndex]; } var newChest = source.new(source, spawnDepth, miner, type); this.chests.push(newChest); return newChest; } return false; } With: spawnChest(spawnDepth, source = Chest.natural, type = ChestType.basic, miner = -1) { var isCollectable = (source == Chest.natural || source == Chest.superminer) && !this.isChestCollectorFull(); var collectionRoll = (chestSpawnRoller.rand(1, 100) <= this.getStoredChestsChance()); let chanceOfCollision = (this.chests.length + 1) / (depth / 10); //this is here to simulate how chest spawns acted in the old system. var canSpawnInWorld = source != Chest.natural || !chestSpawnRoller.boolean(chanceOfCollision); console.log("spawnChest - "+canSpawnInWorld+" - "+chanceOfCollision+" - "+collectionRoll); if(isCollectable && collectionRoll) { this.storeChest(type); return true; } else if(canSpawnInWorld) { //check if miner already has a chest or is an invalid index if(miner < 0 || this.getChest(spawnDepth, miner) || miner > workersHiredAtDepth(spawnDepth)) { var availableMiners = this.getAvailableMiners(spawnDepth); var minerIndex = rand(0, availableMiners.length - 1); miner = availableMiners[minerIndex]; } var newChest = source.new(source, spawnDepth, miner, type); this.chests.push(newChest); this.presentChest(spawnDepth); return newChest; } return false; } TLDR: Add a line "this.presentChest(spawnDepth);;" to automatically click a new chest. Auto collect chest reward File to modify: resources/app/Shared/src/chest/ChestService.js Function to modify: presentChest() Replace: presentChest(spawnDepth, workerNum = -1) { let chest = this.getChest(spawnDepth, workerNum); if(typeof chest == "undefined" && metalDetectorStructure.level >= 5) { chest = this.getChestsAtDepth(spawnDepth)[0]; } if(!isSimulating && !keysPressed["Shift"] && chestService.chestPopupEnabled) { openUiWithoutClosing(ChestWindow, null, chest); } else { this.giveChestReward(chest); newNews(_("You got {0} from a Chest!", chestService.getChestRewardText()), true); } trackEvent_FoundChest(chest.type) } With: presentChest(spawnDepth, workerNum = -1) { let chest = this.getChest(spawnDepth, workerNum); if(typeof chest == "undefined" && metalDetectorStructure.level >= 5) { chest = this.getChestsAtDepth(spawnDepth)[0]; } if(keysPressed["Shift"]) { openUiWithoutClosing(ChestWindow, null, chest); } else { this.giveChestReward(chest); newNews(_("You got {0} from a Chest!", chestService.getChestRewardText()), true); } trackEvent_FoundChest(chest.type) } TLDR: Modify the condition " if(keysPressed["Shift"])" so that it will always give the reward automatically unless you hold the "SHIFT" key. This fixes the treasures chests that will collect infinitely if you click on them, using the "SHIFT" key allows you to open the popup normally (cave, scientists, monsters...). Credit Thank you for getting me on the right track, feel free to steal my stuff or make it better. https://steamcommunity.com/sharedfiles/filedetails/?id=2573032703
2026-02-20 10:00:08 发布在
Mr.Mine
说点好听的...
收藏
0
0
