Showing posts with label robominer. Show all posts
Showing posts with label robominer. Show all posts

Thursday, January 23, 2014

Python Script to Remove Unbreakable Blocks in Robominer


Robominer is an Android game where you use a robot to drill around searching for a diamond. There are blocks that can't be drilled, so you have to either go around them or use dynamite to blow them up. After a while, I got really annoyed dealing with these blocks. So I poked around and found a way to replace them with other blocks.

Basically, when you save a game, it saves the entire map too. This includes the types and locations of all of the blocks. The save file can be modified to remove the unbreakable blocks.

I have SL4A and Python installed on my Android device, so I wrote a Python script I can run on my device to make the changes for me. If needed, you can also copy the file to a PC, run the script, and then copy it back. Note, however, that the script has to be run on every new level. Being able to run the script on the device is a lot more convenient.

Here is the script. It assumes your saved game file is on the SD card. I don't think you can modify the save file in the "Phone" slot unless your device is rooted.



#!/usr/bin/python
# Replace gray blocks with regular blocks on Android app Robominer
#
# 01-15-2013: Created by BitJunkie
# 01-16-2013: For gray blocks, generate random mineral type
# 01-22-2013: Block info starts 3 bytes before 0x3f80, adjust file pointer info
import random 

count=0
random.seed()
# Open the file in binary mode for reading and writing
fh=open("/sdcard/Android/data/com.rnet.robominer/files/last_1.sav","rb+")

# Go to the beginning of the block info +3 bytes, from the beginning of the file
fh.seek(0x30, 0)
header = fh.read(2)

while header == b"\x3f\x80": 
  fh.seek(-4,1)  # Move file pointer to start of block info
  blk = fh.read(1)
  if blk == b"\x01": # if block is gray
    fh.seek(-1,1)
    fh.write(b"\x02")  # Make it regular 
    r = random.sample(["\x01","\x02","\x03","\x04","\x05","\x06","\x07","\x08","\x09","\x0a","\x0b","\x0c","\x0d","\x0e","\x0f","\x10","\x11","\x12"],1)
    fh.write(r[0])  # Add random mineral/element
    fh.seek(13,1)  # Go to next block
    count+=1  # Count how many blocks are changed
  else:
  # Go to next block header
    fh.seek(14,1)
  header = fh.read(2)

print "Blocks changed: %d" % count

I have only used this for games on the "Easy" level. I'm sure the script would have to be modified for the higher difficulties.

Have fun!