Another python supported flashgame

Sat 26 January 2013
By balrok

Another flashgame which I automated a bit through python. My old blog entry is here. This entry again will just show my experiences even if there aren't that much :)

What is the game

It is realm of the mad god. A RPG with perma death. Perma death means it adds a lot of fun through repeated upleveling your chars.. You can avoid dieing by simply drinking healthpotions, casting healthspells or teleporting home.. So if you watch the healthbar often or avoid getting hit you don't need to die.

What got automated

I wanted something, which watches my healthbar and drinks potions + teleports home when I don't have enough. This works quite well (while my previous record was \~100 fame now I get at minimum 300 fame with each char). But it has a disadvantage, that you run pretty fast out of potions and makes the game a boring grind for potions :/

How it was implemented

Based on my previous attempt I had already a quite good library for this.. I think the introduction of subwindows is pretty cool and helps to save cpu cycles when capturing the screen.

So like in the previous project I just grab the whole kongregate gaming area by its black background. After that I get the health,mana -bar and health,mana -pot. Since the coordinates (relative to the gaming area) are always the same, I hardcoded them.

Now I have a mainloop, which looks at the healthbar and drinks a potion if it is below 50 percent or teleports home when no potions left. Also some other logic to not waste so much potions (for example don't drink more than 2 potions in 2 seconds in case I receive heavy damage).

What is new

Although I mostly just copied from my old project I had an endeavor finding a linux keyboard simulator. Although stackoverflow gives many answers what to use. None of them seemed to work or was nicely documented. Luckily also pykey was mentioned. This worked out of the box but had the disadvantage to have a bit of a bad api. To bad, that since 2008 when it was released no one created an official project for this. Some implemented pykey into their projects and nearly all corrected the api. So I took my pykey version just from another project.

What would I loved to do

As always I can't come to end my projects (lost interest in the game due to too much repetition). I thought long about how to implement an autolooter (first only potions, but then maybe also stuff). I thought about how to detect most efficiently smaller pictures there by taking just a few distinctive pixels and compare them.

Also I'd loved to make this script a proxy, which would look at all the incoming and outgoing traffic and could therefore (maybe) monitor how much hp I have, how much hp the enemy has, incoming damage. There was already a java client for this game with the name jOryx which mostly exists only as forks on github, since the main project was banned through the rotmg admins.

Where can I download/look at it

I just post it to github - you might change some constants and the keys which are pressed.. But anyway if you wanted a good autohealer you better play on windows and use some of the other projects at github for this ;) github repo


I've found the cool library autopy which does keyboard,mouse,screengrabbing. With this library my code got a bit simplified (through not having 3 different dependencies). Now it is also possible for me to build an autolooter. This library already had a method to scan for an image inside an image. I only had to extend it to support the transparency bit. My changes for that are in balrok/autopy.