Gal*Gun: Double Peace

Gal*Gun: Double Peace

Not enough ratings
Modding Guide - Gal*Gun Double Peace
By darkhawk02
The tools and info you need to mod Gal*Gun to your heart's content!
   
Award
Favorite
Favorited
Unfavorite
Introduction
This guide is currently a work in progress, but I wanted to open it up so I can start to share what I've learned with everyone. Note that my current situation is fairly busy and update progress will be slow. Please excuse the mess while I get things in order. I appreciate your patience as I work on this.

The goal of this guide is to provide tutorials and other information regarding modding Gal*Gun Double Peace. GG:DP runs on Unreal Engine 3, which both helps and hinders us.

The good news is that many resources are external and there are programs out there to help decipher and extract data, as well modify it.

The bad news is that UE files are very intricately linked, and a misstep can easily break things. So back up your files! And remember in the worst case scenarios you can always verify your files in Steam to revert everything back to standard.

Important references

I'd like to give my thanks to the XCOM modding community. The progress they've made in modding XCOM has given me the information needed to accomplish all this. Below are links to helpful resources that I recommend reading when you get the chance. I will be adding more detailed explanations of certain concepts within them later.

Hex values XCOM Modding
http://wiki.tesnexus.com/index.php/Hex_values_XCOM_Modding

Invaluable resource for inspecting the hex data for UnrealScript. When you're trying to change an "Equal to" statement to a "Not Equal to" statement, this will show you the values you need.

Hex Editing UPK Files
http://wiki.tesnexus.com/index.php/Hex_editing_UPK_files

A great way to learn some of the basics of editing UPK files.
Discord server
We have a Gal*Gun Discord server set up at - https://discord.io/galgun

Feel free to join up. It's the best way to get the latest info on modding/patches, or just chatting about the game in general.
Modding Tools
Below is the list of tools you'll need for modding GG:DP.

UE Explorer

http://eliotvu.com/portfolio/view/21/ue-explorer

UE Explorer is an UnrealScript decompiler. This program lets you open a decompressed Unreal file to see the information it contains- UnrealScript classes, Texture information, and much more.

uModel, Unreal Package Decompressor, Unreal Package Extractor

http://www.gildor.org/downloads

uModel is important for texture modification as it will allow you to rip the necessary textures from upk/umap files.

The Decompressor and Extractor decompress and extract files from Unreal files. In particular, every file that you plan on modding *must* be decompressed first, so it's good to put it in an easily accessible place.

HxD

https://mh-nexus.de/en/hxd/

There are many hex editors out there, this is the one I use.

Notepad++

https://notepad-plus-plus.org/

Notepad++ is useful to have around. It's a great place to store code/hex values while you're playing around with things.

Unreal Development Kit(UDK)

http://www.moddb.com/engines/unreal-development-kit/downloads/february-2015-unreal-development-kit-udk

Specifically the 2015-02 version. At least, that's the one I'm using currently. We don't have access to the version used by GG:DP, but this will allow us to create custom texture file cache(tfc) files. They are key to using custom textures.
Custom Textures Introduction(WIP)
This is to be considered expert level material. It's not easy. I will be doing my best to write instructions that are as easy to follow and understand as possible. Currently a major WIP. The basics are there, but I plan on better clarifying things later.

Basic process

The current method of adding custom textures into GG:DP is by creating a new Texture File Cache(.tfc file), and redirecting one or more of the game's texture resources to your custom file, instead of the game's own tfc.

Before moving forward

I highly recommend you create a new folder as your workspace for this. I've called mine Workspace unoriginally enough. This is a measure twice, cut once sort of thing. You want to make sure you're doing everything correctly the first time; mistakes usually mean it's best to start over than try to fix them.

Your workspace folder should contain both extract.exe and decompress.exe for easy access.

---
Choosing texture files to replace
You need to locate the game files containing textures so you can-

A) Extract the textures from the game file for modificaiton
B) Later edit the file to redirect it to your new texture

Most of the game's files make it easy to figure out what file contains the textures you want to mod, but you can always use UE Explorer to make certain of a texture's location.Almost all character textures will be located here-

C:\Program Files (x86)\Steam\steamapps\common\GalGun Double Peace\GG2Game\CookedPC\Object\GG2Girl

Characters generally have three categories for textures:

  • Body - contains clothing textures(including uniform, socks, underwear, etc.)
  • Face - contains eye textures, mostly. The actual face textures are elsewhere(noted below).
  • Hair - contains hair and hair accessory textures.

The other main location for textures is GG2Game.u, which is directly located in the CookedPC folder.

For this example, we're going to replace the texture for Kurona's default uniform. The default directory for Kurona's files is-

C:\Program Files (x86)\Steam\steamapps\common\GalGun Double Peace\GG2Game\CookedPC\Object\GG2Girl\kurona\model

The file in particular is kr_body_00_SF.upk. Copy the upk over to your workspacefolder, the drag it over the decompress.exe to create a decompressed version, which will show up in the "unpacked" folder within your workspace.
Exporting textures with uModel
Extracting textures with uModel

uModel is the program I use to extract the textures from the game files for use in creating custom textures.

After downloading and extracting the files for uModel, when you open it, a uModel Startup Options window will appear. In the "Path to game files" box, we need to entire the folder path to Gal*Gun's resource files. The default path is-

C:\Program Files (x86)\Steam\steamapps\common\GalGun Double Peace\GG2Game\CookedPC

Uncheck all boxes under "Engine Classes to Load" except for Texture. Other classes can cause uModel to crash while you try to export textures. Click Ok to start uModel.

---
---

Using the folder directory on the left-hand side, locate the package you want to modify. Click on it to select it, then click "Export." This will export all textures within the upk file to a folder called "UmodelExport" within uModel's folder.

---
---

Navigate to the UmodelExport folder and you'll find a new folder with the same name as the upk. Most of the time the texture you want will be in the "Texture2d" folder within. Once you find it, copy it over to your workspace folder. In this instance, kr_body_00.tga is our goal.

---
Editing Textures
Editing textures

Have a blast and change it up however you like! Change colors, add logos, sky's the limit. Just don't mess with the size(as in length/width) of the thing. If the dimensions of the picture are different, you will be unable to update the texture offset data later on.

Specifics on how to edit the texture files is beyond the scope of this article, but I generally use GIMP for editing. For this example, I've added a bit of Dragon Warrior flair to her dress-

Importing the texture into UDK
Once your custom texture is all set, it's time to create the tfc file you need. First things first, open up UE Explorer and open the upk from the unpacked folder in your workspace. We need some info from there to make sure everything goes well. Navigate to the texture you're replacing, it should be under the Objects > Content tabs.

You're looking for image properties to maintain when importing it into UDK to make sure they're the same.


  • CompressionNoAlpha may not be there. If it is not, then it is false and we will not check the entry during import.
  • LODGroup - this will always be there, and is important for setting the characteristics of the texture when it is processed for use, or "cooked."

Next, fire up UDK Editor, and open the Content Explorer window if it isn't already. Click Import, and locate your custom texture. A window will pop up allowing you to change the import settings. Here is where you'll make changes according to the properties you looked at earlier. Most of the time, it'll look like this-


You won't need to change anything else. Click ok. A new package should be created with your texture in it. From witihn the Content Manager, right-click the package title and select "Save." A window will pop up to name and save the file. Name it whatever you wish and save it. When that's done, exit UDK Editor.

2.1 Cooking preparations

Next we're going to perform a process called "Cooking." This will create both our new upk file as well as the tfc we need.

But first, we need to change some settings to make sure it cooks properly. Navigate to-

C:\Program Files (x86)\Steam\steamapps\common\GalGun Double Peace\GG2Game\Config

and open up GG2SystemSettings.ini. We're going to copy the TextureGroup settings from there so that our newly cooked files match up. The line you're looking to copy is-

TEXTUREGROUP_Character=(MinLODSize=32,MaxLODSize=2048,LODBias=0,MinMagFilter=aniso,MipFilter=Point)

Note: the line provided here is the exact one you need, so you can also feel free to copy this. But keep this method in mind if another texture is part of a different texture group.

Now we need to open up UDKSystemSettings.ini within your UDK directory, default-

C:\UDK\Custom\UDKGame\Config

Locate the same line, and copy over it with the information from GG2SystemSettings.ini.

From the same directory, open DefaultEngine.ini. We have one last edit to make before we cook everything. At the end of the file, hit enter a few times to add some space, then type-

[Engine.PackagesToAlwaysCook] +SeekFreePackage=MyPackage

Replace the name "MyPackage" with whatever you named your package earlier.
Creating the tfc file
Cooking the goods

Time to turn on the oven. Fire up Unreal Frontend. Click "Cook" to start the cooking process. If it asks for a game name, give it anything, it doesn't matter what the name is. When it finishes up, navigate to the CookedPC directory, default-

C:\UDK\Custom\UDKGame\CookedPC

Once there, locate both the CharTextures.tfc and your upk file and copy them both to your workspace folder.

Note: In this example, the tfc is CharTextures but depending on the TextureGroup you chose earlier, they may be in a different tfc.

So you have your tfc and the upk you just cooked up. Drag your upk file over decompress.exe to make a decompresed copy. Now, open up the decompressed upk in the hex editor of your choice(I'll be using HxD).
Locating texture offset information in UPK files
Note: the screenshots in this section are from a different UPK file than the one I'm using in the guide, but provides better clarity for explanation.

Most of the art resources in the game rely on a texture cache file(tfc) for rendering textures in-game. Every texture contains information that tells the game where its texture is located in that file. These are called offsets, and there are two - one that tells the game where the texture info is located, and another telling it how large that info is(the size in hex).

To find the beginning of the texture offset data, open the UPK in EU Explorer. Click View > View Buffer from the upper right menu. After it opens, the beginning of the data starts a bit after the end of the last colored portion, and it's the first non 00 byte after that. See the picture below-

---

Now, open up the UPK in HxD. Search for the same section of hex. The easiest way to do this is to perform a search for a "text string" using the name of the texture.

---
---

To find the end of the offset data, you will need to find a pattern of bytes pertaining to the last piece of mip information. There are twelve bytes of information to locate- eight of them will follow a similar pattern among all textures, with the four bytes following it. The exact pattern will depend on how many mips a texture has(or if it has none at all). The most likely patterns are these-

00 08 00 00 00 08 00 00 XX XX XX XX 00 10 00 00 00 10 00 00 XX XX XX XX

In order to show the basic format of this information, I created a screenshot with all of the relevant areas highlighted-

---

Backup reminder

The goal is to copy the entire texture offset data block from the from your newly created UPK file.

Then paste it over the texture offset data block of the decompressed copy of the game's original file.

Keep copies of each just in case!

Copy the texture offset data block from your newly created UPK.

Now open up the game's decompressed UPK file from the unpacked folder in your workspace in HxD. Locate the same section as before by searching by text string. Use the steps from the previous section to locate the texture file offset block and select it.

---

Now simply paste your copied data over the game's data and save. The game upk is now pointing towards your tfc's offset data. But it doesn't yet point to your tfc file.
Custom Textures 2(WIP)
WIP. WIP it good.

Finishing up

Open up UE Explorer if it isn't already and open the game's upk file. Locate the texture info from before.

---

Now, open the buffer using the View > View buffer option.

---
---

You want to locate the byte containing the same Name information as the TextureFileCacheName in the properties(CharTextures, in this case). Texture file properties follow similar patterns, so it will be easy to spot after a couple times. Basically, one of the non-colored areas contains the byte you want to change, and it will be the very first byte of that area. When you click on a byte, the "Name" field will populate on the lefthand side. Once you find the byte with the Name CharTextures, you're ready for the next step.

It is important at this time to note that our goal is to change the byte's "Name" value into something we can use to rename our tfc file. We cannot manually change this value to read however we like. We're stuck with the options we have, and it's all going to be based on changing the value until you reach something usable.

Double-click the byte to modify it. Start by incrementing it by one. In this case we'll change 17 > 18. Click on the byte again to see what the name has changed to become.

---
---

In this case, it now reads "Class" which we don't want, as classes are specific structures witihn UE3. We'll increment again to 19.


Now it reads "ClothingAssets." That's a name we can use. Press Ctrl + S to save the change, then close out of UE Explorer.

Rename you tfc file to the name you found, in our case it will be ClothingAssets.tfc. Move it to Gal Gun's CookedPC folder. Then, copy over the modified upk(kr_body_00_SF in our case) over to the original file's location.

And that's it, if everything went well, you can load up your game and see your new texture in action!

Relocating objects in upk files
While there is a lot you can do without changing the UPK files too drastically, sometimes you simply need more space to work with. This section will demonstrate how to relocate and object to the end of the UPK file. For example, in order to replace the current textures with higher resolution ones, you will need to relocate the texture object in order to do so.

Regarding basic UPK format

From the Nexus Wiki, here is their page on the UPK file format-

http://wiki.tesnexus.com/index.php/UPK_File_Format_-_XCOM:EU_2012

The main aspects of a UPK file to be aware of are three tables that all appear at the beginning of the file-
  • Name Table
  • Export Table
  • Import Table
The Name table determines the "names" given to objects, as well as determining what number is used to represent that name.

The Export Table represents objects within the UPK file itself.

The Import Table represents objects that the UPK requires from external files.

For this procedure, the Export Table is the main concern for us.

Export Table Entries

Here is an example of an export table entry-


The two main things to focus on are ObjectFileSize and DataOffset. ObjectFileSize lets the game know how large a particular object will be, and DataOffset tells it where it can find that object. Which is important, as we're going to relocate that object somewhere else.

Relocating the object

First, load up the UPK file you want to modify in UE Explorer, as well as open it up in HxD. You'll also want notepad open for taking notes.

For this example, I'm going to relocate Ekoro's default body texture, located in ek_body_00.


Use the View > View Buffer command to open up the ek_body_00 object's hex data.

In the new window that appears, select Edit > Copy Address from the menu in the top left.


If you paste the result into notepad, you'll get this -

0x00133396

This is the offset of the object from the beginning of the file. Note, however, the UPK files are little endian, which means when you're looking for this offset in the Export Table object, it will be represented in reverse order-

96 33 13 00

In HxD, use the Find function to locate the offset using the code above. I've highlighted the object in full below-


Now that you know what the Export Table entry looks like, scroll down all the way to the bottom of the file, and select the very end such that the blinking cursor is to the right edge of the last byte.

At the bottom left of HxD, you'll see the offset of the current location. We'll be putting the object right here, so write down that offset in Notepad and then reverse the order of the bytes.

The actual offset - 13 FA 3B The offset in little endian - 3B FA 13

Now, go back to UE Explorer, and in the buffer window, select Edit > Dump Bytes from the menu. This will copy the entire object data to your clipboard. Back in HxD, paste the info right at the end of the file.

After that's done, go back up to the Export Table entry by using the Find function again. Once you've located the four bytes of data, copy the offset data you typed up, right click the highlighted data in HxD, and select "Paste Write." This will make sure you overwrite the data, but don't accidentally make the file larger or smaller.

Once that's done, save the file in HxD. Close the buffer window in UE Explorer, then use the Tools > Reload option to reload the file. If all goes well, you won't see any difference. If you really want to play it safe before modifying anything else, swap out your game file with this one, and if it still works just as well, you're all set.
Revision Info
12/29/2017
Separated out and refined sections - Choosing textures to replace, Exporting textures with uModel, Editing textures.

12/26/2017

Added a separate section for locating texture offset data within UPK files.

12/24/2017

Added Introduction, Tools, and Custom Texture sections. Released guide to the open world.
The Name Table(WIP)
The Name Table is one of the vital structures of UE3 files that declares the names for all of the objects within the file as well as assiging a number to represent each name.
7 Comments
Marathon Feb 5, 2018 @ 11:06am 
alright, thank you, i hope you guys figure it out ^^
darkhawk02  [author] Feb 5, 2018 @ 8:40am 
Unfortunately, we have yet to figure out how to replace/add meshes, in particular any mesh with animations. There's some progress on replacing static objects(like accessories), but that's about it at the moment.

I love the idea of adding extra characters myself, but this is a hard nut to crack. Believe me, we'll be making a big announcement if we make a breakthrough with this.
Marathon Feb 3, 2018 @ 1:34pm 
quick question, is there a place where you can see texture/Character based mods? i.e maybe a mod that adds Neptune from Hyperdimension Neptunia? (if thats impossible you can just ignore this)
darkhawk02  [author] Dec 26, 2017 @ 10:42am 
Sure thing. Feel free to post anything if you think it will help people out with this. I will also be working on this over the next week to clarify/add information as well.
Steilon Dec 26, 2017 @ 7:43am 
Interesting, I will look into those, if I find those thing's and it fixes the issues would it be okay to post it in the comment's for people to see to help along? and thank you for the info dood. :D
darkhawk02  [author] Dec 26, 2017 @ 6:57am 
Not certain. I'm on Windows 10 myself and the editor works properly. I do know that certain programs can cause issues with it opening. Namely, anything that modifies the behavior of DirectX, or tries to hook into the loading process.

I know that the Special K program will kill it. Possibly GeDoSaTo, but I can't recall offhand.
Steilon Dec 26, 2017 @ 3:42am 
So an interesting question, I downloaded the unreal development kit but when I try to open it up it just pops up for a second and then dissapears, is it because of windows 10 or is something else killing it off or defying all expectations is it just meant to be like that and will work with the rest of what I downloaded automatically?