
Angry Birds. Looking for a built-in level editor

Part 0. How it all began
I once wanted to delve into the Angry Birds scripts for one thing I know of. Of course, I expected to stumble on some interesting things inside, but I could not even think that among them there would be a quite working level editor. First, I will explain how I got such a result, and at the end of the article I will give a description and screenshots of the editor, I will describe a simple way to enable the editor.
Part 1. The process
Cooking
For further work, we need the following tools:
- LUA Compiler
- Openssl
- Hex editor
We will work with Angry Birds Rio or Angry Birds Space, because they contain almost all the files necessary for the editor.
If all this is available, then go. If you are bored of reading the first part of the article, scroll to the second, you will like it more.
As our goal, we will choose the file data \ scripts \ options.lua, because its contents are just a list of variables that we can freely change. Let's look at the file and understand nothing. The file is probably encrypted.
Decrypt
From a certain version of the game, all files are encrypted with the 256-bit AES CBC algorithm with an empty initial vector and keys embedded in the code. If anyone wants to tinker with the debugger, a detailed description of the process is here .
For decryption, I used OpenSSL.
Sample batch files for decryption
Angry Birds Rio:
Angry Birds Space:
Angry Birds Seasons:
openssl enc -K 55534361505170413454534E56784D49317639534B39554330795A75416E6232 -iv 00 -d -aes-256-cbc -in %1 -out %1dec.lua
Angry Birds Space:
openssl enc -K 526D67645A304A656E4C466757776B5976434C326C5361684662456846656334 -iv 00 -d -aes-256-cbc -in %1 -out %1dec.lua
Angry Birds Seasons:
openssl enc -K 7A65506865737435666151755832533241707265403472654368417445765574 -iv 00 -d -aes-256-cbc -in %1 -out %1dec.lua
For encryption, respectively, remove the -d switch.
After this procedure, we get a completely readable lua-script, it is a pity that it is compiled. Take a look at the header, see LuaQ, therefore, this is Lua 5.1.
Decompile
It would seem easier. Download one of the decompilers and set it on the resulting file. Oh no. Let's try to get a compiled options.lua listing using luac -l.
luac: options.luadec.lua: bad header in precompiled chunk
As you can see, the header is corrupted. Perhaps a different version of the compiler is required, maybe something else that I did not take into account, because under lua almost did not code. The fact remains. Compare the header of our file with the header of any other compiled lua:

Without going into details what this 08 means, change it to 04 and try to get a listing. Voila:
main (31 instructions, 124 bytes at 00346070)
0+ params, 2 slots, 0 upvalues, 0 locals, 22 constants, 0 functions
1 [-] GETGLOBAL 0 -1 ; gamelua
2 [-] SETTABLE 0 -2 -3 ; "releaseBuild" true
3 [-] GETGLOBAL 0 -1 ; gamelua
4 [-] SETTABLE 0 -4 -5 ; "showEditor" false
...
I bring the same file in a more readable form:
gamelua.releaseBuild = true
gamelua.showEditor = false
gamelua.cheatsEnabled = false
gamelua.useDynamicAssets = false
gamelua.isPremium = false
gamelua.isKorea = false
gamelua.applyChinaRestictions = false
gamelua.gameVersionNumber = "1.4.4"
gamelua.customerString = "rovio"
gamelua.svnRevisionNumber = "93049"
gamelua.isSeasonsAvailable = true
gamelua.g_registrationEnabled = true
gamelua.g_updateCheckEnabled = true
gamelua.loadMightyEagle = true
filename = "options.lua"
Here we already see some interesting variables, namely: releaseBuild, showEditor and cheatsEnabled. We change them and collect everything back.
Collect as it was
Initially, I just wanted to compile my own script with this content, tweak the title and encrypt it. But somehow it didn’t work out, the game didn’t want to take my file for options.lua. The solution was found simple - fix the original file with a hex editor. Not so hot what method, but for our purposes it will do. So, we fix it, check the listing, return the title, encrypt it, throw it back into the game.
Part 2. Result
We go into the game and immediately see some changes in the main menu:

Click on “Editor” and see a list of levels that can be changed. The arrows below scroll through the level packages, so that you can easily create your levels in one of the unoccupied packages:

Now click on one of the levels and go directly to the editor:


Not good, I must say. From the interface there are only a few labels and notations. The main work is done using hot keys. Having poked all kinds of keys for half an hour, I made a brief description of them:
Work with objects | |
---|---|
12 | place stone structures |
QW | place wooden structures |
As | place glass constructions |
NM | place sand blocks |
ZX, JK | post scenery |
34 | place birds |
Ty | place enemies and locked birds (the same thing for game mechanics) |
UI | place active objects |
OP | post awards |
delete | delete object |
shift + r | rotate object |
Camera | |
ctrl + shift + c | center camera |
ctrl + shift + b | show full level |
Other | |
tab | enable / disable physics |
shift + t | change background |
shift + s | freezing (???) |
ctrl + s | save level |
end | quick end (???) |
Underwater rocks
The editor is far from perfect. Some of the editor’s resources are missing, so when you press certain keys, the game may suddenly end. At least in the Rio version, the editor saves the levels in an uncompiled form, therefore, to see the level in the game, you must first compile it with the necessary version of the compiler and encrypt it. With due diligence, you can try to tweak the game so that it uses the levels in an uncompiled form, but this goes far beyond the scope of this article. Also, I did not find a way to move the slingshot inside the editor. This can probably be done only by directly editing the level file.
Angry birds space
In this version, the editor is significantly improved, now the menu of object properties is working, sensors have appeared, it has become more convenient to work with the editor, and a special object editor has appeared. However, editors regularly buggy. I did not check if the preservation of the levels was repaired in this version, I leave it to the reader.
A few screenshots of the Space version:


Velvet path
I do not suggest the reader to repeat my work on their own. To enable the editor, just download this archive and replace the options.lua file with the corresponding file from the archive. The versions of the game on which these files are checked are: Angry Birds Space 1.2.0 and Angry Birds Rio 1.4.4
ATTENTION
Before any operations, it is strongly recommended that you back up the game files, including the save. Firstly, you can ruin the original levels of the game, and secondly, this replacement also includes cheats. To use cheats, press the number keys. Among the cheats there are, for example, those that immediately go through the whole game or give all the rewards. If you do not want to lose all your progress, make backups.