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
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
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); } } }
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]); } } }
Chest 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) }
Thanks to Myst03 for his excellent guide, all credits belong to his effort. if this guide helps you, please support and rate it via Steam Community. enjoy the game.
Related Posts:
- Mr.Mine: Automated Chest Grabbing (V.018)
- Mr.Mine: Quickly 100% Achievements (In 1 Hour)
- Mr.Mine: Everything You’ll Need to Know