
Part 0. How it all began
I once wanted to delve into the scripts of Angry Birds with one known to me goals. Of course, I expected to stumble inside for some interesting things, but I couldn’t even think that among them there would be quite a 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 of including the editor.
Part 1. Process
Cooking
For further work we will 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 will be bored to read the first part of the article, scroll to the second, you will like it more.')
Our goal is to select the data \ scripts \ options.lua file, since its contents are simply a list of variables that we can freely change. Let's look at the file and understand nothing. The file is probably encrypted.
Decipher
From a certain version of the game, all files are encrypted with a 256-bit AES CBC algorithm with a blank initial vector and keys embedded in the code. If anyone wants to tinker with the debager, a detailed description of the process is available
at this link .
For decryption, I used OpenSSL.
Sample batch files for decryptingAngry Birds Rio:
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
To encrypt, respectively, remove the key-d.
After this procedure, we will have a quite readable lua-script, it is a pity that it is compiled. Let's look at the title, see LuaQ, therefore, it is Lua 5.1.
Decompile
It would seem that easier. Download one of the decompilers and set it on the resulting file. But no. Let's try to get the listing of compiled options.lua using luac -l.
luac: options.luadec.lua: bad header in precompiled chunk
As you can see, the header is damaged. Perhaps another 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, we change it to 04 and try to get a listing. Voila:
main <?:0,0> (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 quote 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 such content, correct the title and encrypt. But somehow it did not work out, the game did not want to take my file for options.lua. The solution was found simple - fix the original file with a hex editor. Not so hot which method, but for our purposes will fit. So, correct, check the listing, return the title, encrypt, throw back into the game.
Part 2. Result
We go into the game and immediately see some changes in the main menu:

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

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


Sparsely, I must say. From the interface only a few labels and symbols. The main work is done using hotkeys. 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 | place the scenery |
34 | place the birds |
Ty | place enemies and locked birds (for game mechanics the same thing) |
Ui | place active objects |
OP | place awards |
delete | delete object |
shift + r | rotate object |
Camera |
---|
ctrl + shift + c | center the camera |
ctrl + shift + b | show full level |
Other |
---|
tab | enable / disable physics |
shift + t | change background |
shift + s | freeze (???) |
ctrl + s | keep level |
end | quick end (???) |
Most likely this is not all hotkeys, you can search for others.
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 end abruptly. At least in the Rio version, the editor saves the levels in an uncompiled form, so in order to see the level in the game, you must first compile it with the correct version of the compiler and encrypt it. With due diligence, you can try to correct the game so that it uses the levels in an uncompiled form, but this goes far beyond the scope of this article. I also did not find a way to move the slingshot inside the editor. This can probably be done only by direct editing of the level file.
Angry birds space
In this version, the editor has been significantly improved, the object properties menu now works, sensors have appeared, it has become more convenient to work with the editor, a special object editor has appeared. However, the editors regularly podglyuchivayut. I did not check if the level preservation was repaired in this version, I leave it to the reader.
Some screenshots of the Space version:


Velvet path
I do not suggest the reader to repeat my work independently. To enable the editor, just download
this archive and replace the options.lua file with the corresponding file from the archive. Versions of the game on which these files are checked: Angry Birds Space 1.2.0 and Angry Birds Rio 1.4.4
ATTENTIONBefore carrying out any operations, it is strongly recommended to save backup copies of the game files, including saving. Firstly, you can spoil 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 who immediately go through the whole game or give all the rewards. If you do not want to lose all your passage, make backup copies.