Mr.Mine

Mr.Mine

30 ratings
Updated Automation V0.4
By Myst03
Updated guide for simple automation in Mr. Mine, heavily inspired by others work but fixes most of the problems introduces with the recent updates.
2
   
Award
Favorite
Favorited
Unfavorite
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://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2573032703
18 Comments
uBielzinhu 17 Nov, 2024 @ 7:03am 
could you help me?
Primordial 20 Jun, 2024 @ 8:48am 
Can't you find a way to prevent unlimited chests from excavations, caves and scientist?
$cloxx$ 30 Mar, 2024 @ 11:40am 
WARNING! Carry on reading! Or you will die, even if you only looked at the word warning! Once there was a little boy called Joey, he was ten-years-old and he lived in a mental hospital because he posted a shitty copypasta onto a People Playground mod's comment section. He got so bad he went to kill all the staff in the hospital so the Feds decided that best idea was to get rid of him so they set up a special room to kill him, as inhumane as possible. And he sat there in agony for hours until he died. Now every week on the day of his death he returns to the person that reads this letter, on a monday night at 12:00 a.m. He creeps into your room and kills you slowly, by pegging you and watching you bleed to death. Now send this to ten other profiles on this one site, and he will haunt someone else who doesn't. This isn't fake. apparently if u copy and paste this to ten comments in the next ten minutes nothing will happen
Perflexed 3 Jan, 2024 @ 2:56pm 
For Auto Sell Moon section, replace with this instead to sell ALL minerals & iso for ALL 3 areas:

function sellAllMinerals(tab)
{
var moneyPriorToSale = money;

if(tab == 0 || tab == 1 || tab == 2)
{
for(var i = 1; i <= 12; i++) //EARTH MINS
{
sellMineral(i);
}
for(var i = 18; i <= 26; i++) //EARTH ISO
{
sellMineral(i);
}

for(var i = 13; i <= 17; i++) //MOON MINS (1-5)
{
sellMineral(i);
}
for(var i = 34; i <= 37; i++) //MOON MINS (6-9)
{
sellMineral(i);
}
for(var i = 27; i <= 32; i++) //MOON ISO (excluding reactor iso)
{
sellMineral(i);
}

for(var i = 52; i <= 60; i++) //TITAN MINS
{
sellMineral(i);
}
for(var i = 61; i <= 66; i++) //TITAN ISO
{
sellMineral(i);
}

}
Jaybone 6 Jun, 2023 @ 1:47pm 
for the neverending chest thing, you can just hold shift click and the chest will go away.
ko0ky 29 Mar, 2023 @ 4:45pm 
hate to admit it, this ended up ruining the game. If you enjoy the game DON'T DO ANY of these. I don't blame the author 1 bit and even gave an award but after doing "resource sell automation" and then the big oopsie was the auto open chests. This opened a cheat where you could get a chest in your "cave" building for example and just click on it endlessly gathering the awards while still keeping the chest. Worked with golden chests as well. With those, you could really advance time, get building materials and more. i played legit till about 800km and around 865km I accident sold all my isotopes .. im done. was fun while it lasted, I even spent 5 bucks in game.

tldn: don't do this unless you wanna cheat yourself from a pretty good (BUT YES, grinding game)

(author - not dogging you in any way, thx for gathering the info)
A'den 28 Mar, 2023 @ 12:53pm 
Okay, so chest auto clicker prevents chests from disappearing after clicking in excavation rewards, caves rewards and traders options
Mangogh 6 Mar, 2023 @ 9:17am 
Moon resources only sell to Magnesium. Titanium, Silicon, Promethium, and whatever the other 2 are (haven't unlocked them yet) don't get sold when full capacity is reached
Mangogh 21 Feb, 2023 @ 6:38pm 
Update: It does not sell what is protected. Also, it seems the auto open battles does not work, but once you open it, the battle starts immediately
Mangogh 21 Feb, 2023 @ 6:14pm 
Trader needs to be added to the shift bypass thing. But everything works!