# Tropico 5 Small modding tutorial



## Zur13 (Jun 2, 2014)

El Presidente our scientists discovered a new tech! Now those pesky oponents of El Presidente will not have any chances to win an elections.

Requirements:
HPK Archiver http://www.techpowerup.com/forums/threads/tropico-3-4-hpk-archiver.113705/ (Don't forget to thanks to the author)
iGO LUA (203.150.228.132/basic/navthai/Primo/tool/iGOLua.rar)
Lua 5.1 decompiller (http://sourceforge.net/projects/unluac/)
Installed Java (latest JRE could be found there http://www.oracle.com/technetwork/java/javase/downloads/index.html?ssSourceSiteId=otnjp).
Basic programming skills.

Disclaimer
The author reserves the right not to be responsible for the topicality, correctness, completeness, quality of the information provided or any damage done to your programs, reputation, hardware, brains, mind etc.

Don't play modded game online! Only singleplayer! Or you may get banned or cursed!

El Presidente our glorious plan is to uberpower election cheat option.

Stage 0. Backup
If something going wrong backups are our oportunities to fix the game. In the Tropico 5 install folder you can find subfolder named Packs. There are a lot of .hpk files.

Make copy of all .hpk files from Packs folder before you'll made any changes. Or you can make copy of entire Packs folder.

Stage 1. Unpack

Launch HPK Archiver
In Game section chose Tropico 4 / Tropico 5
In the Extract section choose to open Lua.hpk file which can be find in Packs subfolder of Tropico 5 install folder
Create your working folder ( My working folder is G:\Tropico 5\Packs\Unpacked\) and subloders for unpacked files ( for this tutorial I will use G:\Tropico 5\Packs\Unpacked\Lua.hpk\ folder)

In the Extract section choose folder to unpack the files (I will use G:\Tropico 5\Packs\Unpacked\Lua.hpk\). Use different folders for different .hpk files.

Hit Extract button.
Stage 2. Decompile
In the folder where you unpacked the Lua.hpk you can find a lot of .lua files. We are interested in Tropico 5\Packs\Unpacked\Lua.hpk\Lua\Game\CityElections.lua. Some files could be decompilled with iGO decompiller but if you see the error log with decompilled files this is not the option. So we will use unluac.

Extract unluacv1.2.2.zip to your working subfolder
Using windows Explorer navigate to folder where you created the working subfolder shift right click on the working subfolder and choose the Open Command Window Here option from context menu
In the console window type this command 
	
	



```
java -jar unluac.jar Lua.hpk\Lua\Game\CityElections.lua > Lua.hpk\Lua\Game\CityElections.luad
```

The file Lua.hpk\Lua\Game\CityElections.luad is the source code. You can use any text editor to modify it.
Don't close the console window you'll need it on Stage 4
Stage 3. Make election fraud uber

Open CityElections.luad with any text editor.
We are interested in function City:GetElectionSupport(cheat). Find that line 

Few lines under you can see interesting line 
	
	



```
local converted = Min(against, Random(3 * self.VoteFraud, 7 * self.VoteFraud, "election_support"))
```

Change it so we have more percents 
	
	



```
local converted = Min(against, Random(53 * self.VoteFraud, 57 * self.VoteFraud, "election_support"))
```

Save changes
Stage 4. Compile

Lauch iGO tool
Hit compile button and choose Lua.hpk\Lua\Game\CityElections.luad
If there is appeared 2_CityElections.lua then delete the original CityElections.lua
Rename 2_CityElections.lua into CityElections.lua
*If 2_CityElections.lua not appeared then there is some compilation errors

Stage 5. Pack

In the HPK Archiver in Acrchive section in the firt field choose the directory where you have unpacked the files (im my case is G:\Tropico 5\Packs\Unpacked\Lua.hpk\)

In save file field coose file to pack (in my case is G:\Tropico 5\Packs\Lua.hpk)
Don't forget to make backup before overwrite the original file
Untick Compress It checkbox
Hit Archive button
BTW it seems it is possible to mod the game without repack http://forum.kalypsomedia.com/showthread.php?tid=22981


----------

