Our target for this lesson will be Urban Terror 4.3.4.
Our goal in this lesson is to determine how Urban Terror stores its resources and how to unpack them. Then, we will modify a texture in the game and recompile the textures.
From a previous lesson, we know that resources must be stored on the file system. Due to their size, these resources are most likely packed into some sort of archive. Because the game must know how to unpack these resources, it must be possible for us to also unpack them. If we can identify where these resources are stored and how they are packed, we can unpack them, modify them, and repack them.
After downloading the game through the updater, the q3ut4 directory is created and populated with data. If we navigate into this directory, we can see a variety of files. By choosing View -> Group By -> Type, we can see all the files grouped by their file type:
The size of the highlighted pk3 files indicate that these may store the game’s resources. To quickly examine the contents of these files, we can use the following Powershell command:
type .\zUrT43_001.pk3 | select -first 10
The type command prints out the content of a file. However, we only want to see the beginning of the file to see if there is anything in there that may indicate how the file is packed. The select command accomplishes this by only displaying the first 10 lines it receives. The | operator passes the results of the type command to the select command:
The highlighted PK text and the strings of text (botfiles) indicates that this is a ZIP file. While we could use Windows default ZIP viewer to view this file, for this lesson, we will use 7zip. This can be installed via:
With 7zip installed, we can easily explore this pk3 file by right-clicking and choosing 7zip -> Open archive. Upon doing so, we see several folders. The names of these folders are related to resources required by the game:
If we explore the botfiles directory, we see that this game contains code that controls how each bot operates in its resources:
If we explore the env directory, we see several directories for different map names. If we look inside the directory for the map austria, we see several static images:
If you go in-game and load the austria map, we can see that these images make up the skybox of the map:
If we modify these images, we should be able to modify the skybox of the level.
Now that we have located the resources, let’s extract them and modify them. Right-click on the zUrT43_001.pk3 file and choose 7zip -> Extract to. In the extracted file, navigate to the env/austria folder. For this lesson, we will replace the top of the skybox with the bottom of the skybox. To do this, first delete the austriasky_up.jpg file, then create a copy of the austriasky_dw.jpg file and rename it to austriasky_up.jpg:
With this change made, navigate to the root of the extracted pk3 directory, select all folders (botfiles, env, fonts, etc.) and choose 7zip -> Add to archive. Keep the default options and change the name of the new archive to zUrT43_001.pk3. After 7zip finishes, replace the zUrT43_001.pk3 file in the q3ut4 directory with this new archive. If you start Urban Terror and start a match on the austria map, you should instantly observe that our change was successful:
If you explore the other pk3 files, you should observe that all maps, player models, weapons, and sounds are contained within these files. You can use the same technique discussed above to modify any of the resources in the game.