Modifying Textures - XCOM:EU 2012

From Nexus Mods Wiki
Jump to: navigation, search


Overview

(The following is derived from an investigation by Dracous79, posted in the Nexus XCOM Mod Talk forum Enemy Within Discovery thread, with additional material from the thread Expanding Nationalities.)

At present (Dec 2013) there is no practical method to alter or insert new textures into the existing XCOM game art assets in maps or UPKs, because we lack a compiler that doesn't depend upon access to the Firaxis proprietary library of resources. However, progress on using the UDK is being made all the time. See the wiki article Modding with the UDK - XCOM:EU 2012 and the forum threads linked there for current status of that progress.

Instead, a shell environment must be created that loads before the game executable, which then proceeds to intercept calls to the art assets and substitutes modified textures on the fly from external files. The primary tool for this purpose is a third-party utility to find, save, and modify textures in Direct3D 9 applications, called TexMod. A video showing how to use TexMod with the original release of XCOM:EU 2012 is available on the Nexus.

However, development of TexMod stopped with it's release (v0.9b). An open source project was forked to continue development, originally called Open TexMod but later changed to Universal Modding Engine (uMod). (Source: Open Texmod/uMod Project page.) While it is expected that uMod should work with XCOM, at present the community has stuck with TexMod as the tool proven to be sufficiently effective. Consequently, we use TexMod in the following discussion as a surrogate for either tool.

Programs and Tools

Details

Background

While not necessary to simply use TexMod and the related TPF files, the following is provided for the benefit of those desiring to understand where to find such textures.

The following was disclosed by Amineri, the principal programmer for the "Long War" mod.

The human code works like so :

  • The base pawn is a headless body -- this base pawn is entirely determined by armor and gender (see XGBattleDesc.MapSoldierToPawn, which we've modded in Long War to turn the Genemod armor meshes into entirely new armor items)
  • The head is an "attachment" mesh defined by the TAppearance structure stored in TSoldier. In the tactical game this is stored in XGCharacter_Soldier. In strategy it is stored in XGStrategySoldier.
  • Armor Decos and Weapons are also attached meshes added separately.

Alien pawns on the other hand are pretty much a single mesh which already includes the head. The easiest way to get a sense of this is to decompress Soldier_MaleKevlar_SF.upk (which contains the male non-genemod Kevlar body mesh) and GameUnit_XComSectoid_SF.upk (which contains the Sectoid body mesh).

Head-swapping for aliens just isn't going to work. If there were a good 3D modeler out there (I'm not one) it might be possible to create the equivalent of armor deco overlays for aliens to visually show different alien types, but it would require some significant UPK restructuring to make it work. At which point it might be easier to simply create brand new alien textures instead.

The UIFlags are stored as part gfxXComIcons, the active copy of which is stored in UICollection_Common_SF.upk. There are copies of gfxXComIcons in Command1.upk and UICollection_Strategy_SF.upk, but these appear to be inactive.

There are UIFlags for all 36 countries defined, although some flag names have typos (e.g. "UIFlag_isreal" (sic)). However these UIFlag elements are only utilized for Flash / GFX interface elements, as you've seen.

The pawn texture flags are drawn from somewhere else completely. The reason it defaults to the USA flag is because the ECountry enum is unusual in that there is no "None" value at 0 -- instead it starts with enum value 0 = USA.

Initially one would think the most likely place to start looking at pawn flag textures is in XComHumanPawn.UpdateFlagMaterial:

simulated function UpdateFlagMaterial(MaterialInstanceConstant MIC)
{
   local CountryFlag Flag;
   // End:0x129
   if(m_kAppearance.iFlag != -1)
   {
       XComContentManager(class'Engine'.static.GetEngine().GetContentManager()).GetCountryFlag(byte(m_kAppearance.iFlag), Flag);
       MIC.SetScalarParameterValue('UOffset', Flag.U);
       MIC.SetScalarParameterValue('vOffset', Flag.V);
   }
   //return;    
}

However this only appears to be altering the characteristics of the texture, as advertised, since DefaultContent.ini only has:

Flags=(Country=eCountry_USA, U=0.0, V=0.0)
Flags=(Country=eCountry_Russia, U=0.25, V=0.0)
Flags=(Country=eCountry_China, U=0.5, V=0.0)
Flags=(Country=eCountry_UK, U=0.75, V=0.0)
Flags=(Country=eCountry_Germany, U=0.0, V=0.125)
Flags=(Country=eCountry_France, U=0.25, V=0.125)
Flags=(Country=eCountry_Japan, U=0.5, V=0.125)
Flags=(Country=eCountry_India, U=0.75, V=0.125)
Flags=(Country=eCountry_Australia, U=0.0, V=0.25)
Flags=(Country=eCountry_Italy, U=0.25, V=0.25)
Flags=(Country=eCountry_SouthKorea, U=0.5, V=0.25)
Flags=(Country=eCountry_Ireland, U=0.75, V=0.25)
Flags=(Country=eCountry_Sweden, U=0.0, V=0.375)
Flags=(Country=eCountry_Spain, U=0.25, V=0.375)
Flags=(Country=eCountry_Norway, U=0.5, V=0.375)
Flags=(Country=eCountry_Canada, U=0.75, V=0.375)
Flags=(Country=eCountry_Netherlands, U=0.0, V=0.5)
Flags=(Country=eCountry_Israel, U=0.25, V=0.5)
Flags=(Country=eCountry_Egypt, U=0.5, V=0.5)
Flags=(Country=eCountry_Egypt, U=0.5, V=0.5)
Flags=(Country=eCountry_Brazil, U=0.75, V=0.5)
Flags=(Country=eCountry_Argentina, U=0.0, V=0.625)
Flags=(Country=eCountry_Mexico, U=0.25, V=0.625)
Flags=(Country=eCountry_SouthAfrica, U=0.5, V=0.625)
Flags=(Country=eCountry_Poland, U=0.75, V=0.625)
Flags=(Country=eCountry_Ukraine, U=0.0, V=0.75)
Flags=(Country=eCountry_Nigeria, U=0.25, V=0.75)
Flags=(Country=eCountry_Scotland, U=0.5, V=0.75)
Flags=(Country=eCountry_Greece, U=0.75, V=0.75)
Flags=(Country=eCountry_Belgium, U=0.0, V=0.875)

This also includes texture info for all 36 country flags.

The nationality is stored as part of the TAppearance structure (in iFlag element) in the TSoldier structure. In the strategy game m_kSoldier in XGStrategySoldier is of type TSoldier, while in the tactical game there is an m_kSoldier member of XGCharacter_Soldier, which is in turn stored in XGUnit.m_kCharacter. XComUnitPawn.SetAppearance copies the entire TAppearance structure into XComUnitPawn.m_kAppearance.

This info is set in XGCharacterGenerator.CreateTSoldier:

   if(iCountry == -1)
   {
       iCountry = PickOriginCountry();
   }
   kSoldier.iCountry = iCountry;
   kSoldier.kAppearance.iFlag = kSoldier.iCountry;

The pawn flags themselves appear to be defined in as a part of each individual soldier model. After decompressing Soldier_MaleKevlar_SF.upk and opening it in Umodel, I found there are the textures CHH_Flags, MINST_Flags, Flags_DIF defined there that contains 8 x 4 "array" for flags. This means that the model itself is limited to containing only 32 flags from the 36 total countries (as opposed to the UIFlags which have all 36 flags). The USA flag is in the upper left corner of the texture and appears to be the default displayed.

Based on visual appearance, the flags appear to be:

  • USA, Russia, China, Great Britain
  • Germany, France, Japan, India
  • Australia, Italy, South Korea, Ireland
  • Sweden, Spain, Norway, Canada
  • Netherlands, Israel, Egypt, Brazil
  • Argentina, Mexico, South Africa, Poland
  • Ukraine, Nigeria, Scotland, Greece
  • Belgium, Honduras, Blank, Bosnia

So only 29 of the actual slots are filled, meaning that 7 country flags available as UIFlags are not available in this texture:

  • Zimbabwe
  • Venezuala
  • Turkey
  • Saudi Arabia
  • Portugal
  • Kenya
  • Columbia

These 7 UIFlags also don't match up with the 7 "extra" countries for the ECountry enum list :

  • Turkey
  • Indonesia
  • Pakistan
  • Iran
  • Venezuela
  • Columbia
  • Portugal

Portugal, Columbia, Venezuela, and Turkey have UI flags and are in the ECountry enum list, but have no Pawn texture flags.

Indonesia, Pakistan, and Iran are defined in the ECountry enum list, but don't have either UI flags or pawn texture flags.

Saudi Arabia, Zimbabwe, and Kenya have UIFlags, but no Pawn flags and aren't on the ECountry enum' list.

The actual flag textures are almost certainly stored in one of the TFC files, probably in CharTextures.tfc.

Currently countries are divided into Council countries and non-Council countries. There are 16 Council countries out of the 36 countries defined in ECountry enum.

In theory it's possible to simply change the booleans to turn some of the non-Council countries into Council. However, this would require some significant UI rework :

  • The Situation Room UI is designed around 16 slots for countries, and would need substantial rework to accommodate more countries.
  • Geoscape and Situation room has country sprites only for the 16 Council countries, so additional country shape sprite artwork would have to be developed and integrated into the game.

Needless to say this is a lot of work.

General Process

In general, use of TexMod requires launching it first, and telling it to then launch the (renamed) original game executable. In the case of XCOM:EU 2012 the game executable is XComGame.EXE. The general process consists of the following steps:

  1. Install TexMod to any location.
  2. Install any TexMod Package File (TPF)s for use with TexMod to the same location.
    (The TPFs are simple re-texturing packages that must be loaded at run-time by TexMod.)
  3. Install all mods that modify the game executable first.
  4. Rename the game executable to something else (i.e. XComGame.EXE to XComGame-modded.EXE).
  5. Copy the TexMod executable to the same location as the original game executable. TexMod expects the full, straight path to the renamed executable, so double check you have it copied to the correct folder if you have Enemy Within installed.
    • EU: <Steam install path>\steamapps\common\XCom-Enemy-Unknown\Binaries\Win32
    • EW: <Steam install path>\steamapps\common\XCom-Enemy-Unknown\XEW\Binaries\Win32
  6. Rename the TexMod executable to that of the original game (i.e. TexMod.EXE to XComGame.EXE).
  7. Start the game executable (which is now the renamed TexMod) as normal.
  8. The auto-loading feature within TexMod only requires you to Open (and thus, browse) any of the wanted TPF files from the left-side box while being in the "First Tab" functions block.
  9. Use the "Browse" option within the upper section of TexMod to locate the renamed actual game executable (i.e. XComGame-modded.EXE).
  10. Finish configuring TexMod: Select whatever TPF packages desired in the "Package Mode" function by opening the files from a folder.
  11. Click RUN -!- ... The properly allocated game EXE (previously entered in the top-banner section) will then execute and the textures are "transferred" from the TPF temporarily into the memory stack for use in your current game session.

Any mods to the game executable that need to be applied later will require reversing the above steps and then repeating them after modifying the actual game executable.

This same general process will also have to be repeated after every official game patch from Firaxis/Steam, as such will replace the TexMod executable with a new version of the game executable.

Enemy Within Process Alterations

However, the release of the Enemy Within expansion added a new wrinkle to the general process of inserting Texmod into the launch process: the XCOMLauncher.exe app. This was a result of the decision to make EU and EW operate as if separate games, with EW content under the \XEW folder. Now the launch process appears to be as follows:

  1. The game is started (via Steam or by directly running one of the XCOM executable files). If XComEW.EXE or XCOMLauncher.EXE is missing, XCOM EU starts. In all cases XComGame.EXE is called.
    • Steam (Play button in Steam Library or desktop icon created by Steam) calls XComGame.EXE; or
    • XComGame.EXE calls itself.
    • XComEW.EXE calls XComGame.EXE.
    • XCOMLauncher.EXE calls XComGame.EXE.
  2. XComGame.EXE calls XCOMLauncher.EXE.
    • XCOMLauncher is started.
  3. XCOMLauncher is closed upon selecting either EU or EW. Chosen version is launched.
    • XCOMLauncher.EXE calls the appropriate game executable with additional parameters like -FROMLAUNCHER or -LANGUAGE=INT (FRA, ITA, DEU, ESN, RUS, POL, KOR, JPN, CHT). The language switch is used for XCOM EW.

Texmod installation for XCOM EU with EW expansion

For EU, use the executable file for Texmod swap as in the previous general process. Rename XCOMLauncher.exe to something else to avoid loops. Start the game with XCOM desktop shortcut or with the Play button in the Steam Library to avoid multiple Texmod loop runs. Restore XCOMLauncher.exe's name, when you want to play the EW expansion again.

  1. Rename XCom-Enemy-Unknown\XEW\Binaries\Win32\XCOMLauncher.exe (i.e. to XCOMLauncherTemp.exe).
  2. Rename XCom-Enemy-Unknown\Binaries\Win32\XComGame.exe (i.e to XComGameReal.exe).
  3. Copy Texmod executable into XCom-Enemy-Unknown\Binaries\Win32\ and rename it to XComGame.exe.
  4. Start the game with a desktop shortcut to the EU game executable or with the Play button in the Steam Library.
  5. Browse... for target application (i.e. XComGameReal.exe) after Texmod starts.
  6. Set up Texmod and hit the Run button.

Texmod installation for XCOM EW

  1. Make sure there is a XCom-Enemy-Unknown\XEW\Binaries\Win32\XCOMLauncher.exe program.
  2. Rename XCom-Enemy-Unknown\XEW\Binaries\Win32\XComEW.exe (i.e. to XComEWReal.exe)
  3. Copy Texmod executable into XCom-Enemy-Unknown\XEW\Binaries\Win32\ and rename it to XComEW.exe.
  4. Start the game and select Enemy Within (i.e. XComEW.exe).
    • In case of XComEW.exe being actually Texmod, just select XComEWReal.exe (or whatever you named it) and hit the Run button; or
    • Browse... for target application (i.e. XComEWReal.exe) after Texmod starts.
  5. Set up Texmod and hit the Run button.

How to use TexMod with a language other than English

[using French (FRA) in EW as an example.]
Thanks to Drakous79 on the Nexus XCOM Mod Troubleshooting forum for the following tip.

TexMod discards all command line switches. In this instance it would be the "-language" switch.

Method 1:

  1. Note the name of your renamed "XComEW.exe" (i.e. "XComEWReal.exe" in this example).
  2. Create a batch file in XEW\Binaries\Win32\ folder. Name it as you want, for example as "XComEWReal.bat", and edit it. It should contain the command line:
    "XComEWReal.exe -language=FRA"
  3. Point TexMod to that batch file (Target application | Browse | Use dropdown menu to see all files | Select "*.bat" or "*.*" as the file type and then the batch file you created).

Note this method has a spotty record of success. It has been reported to suddenly stop loading TexMod for no apparent reason.

Method 2:

  1. In the C:\Users\<youraccount>\Documents\My Games\XCOM - Enemy Unknown\XEW\XComGame\Config\ folder, in the following files:
    • XComEngine.ini
    • DefaultEngine.ini
    • BaseEngine.ini
    find the section [Engine.Engine] and change:
    "Language=INT"
    to
    "Language=FRA"
  2. Save the file.
  3. Rename "XComEW.exe" to "XComEWReal.exe".
  4. Rename "TexMod.exe" to "XComEW.exe".
  5. Run the launcher and point "TexMod" to "XComEWReal.exe".

Enjoy.

The following "Language=" codes are supported:

  • INT (Default: English)
  • RUS
  • DEU
  • ESN
  • FRA
  • ITA
  • JPN
  • KOR
  • POL

The most persistent place for the change appears to be "DefaultEngine.ini". The following explains why this is so.

In theory the language can be added to DLC XComEngine.ini, but it is hard to tell what DLC a user has installed. Note the usage of "-+" marks for merge purposes in the following real-world example:

  • XComEngine.ini in the latest DLC folder
-Language=INT
+Language=FRA


The "<prefix->Engine.ini" files are located in the "XComGame\Config" subfolders. There are several possible locations for these Config folders, depending upon the version or DLC with which you are concerned. See the Loose Files section of the "Basic Guide for installing mods" wiki article for these locations.

The "<prefix->Engine" files are:

  • Base: initial settings
Can be overridden by default settings (Default-prefix) and DLC settings (XCom-prefix) Engine files.
  • Default: default settings
Can override initial settings (Base-prefix) Engine file.
Used to create user settings (XCom-prefix) Engine file.
  • XCom: user settings
Derived from default settings (Default-prefix) Engine file.
Re-created after every change to default settings (Default-prefix) Engine file.
If DLC are available, DLC user settings (XCom-prefix) from the DLC folder are merged into user settings (XCom-prefix) from the base game folder as "XComEngine.ini" under your local Windows account <My Games path>\XCOM folder.

In the following example, the language will be INT because "BaseEngine.ini" is overridden by "DefaultEngine.ini".

  • BaseEngine.ini
Language=FRA
  • DefaultEngine.ini
Language=INT

Setting the language in "XComEngine.ini" should work as long as "DefaultEngine.ini" is not altered (changed and saved). But you will need to to remember that this change may not be persistent.

  • XComEngine.ini
Language=FRA

Separate Content


References

Referred to by this article:



That refer to this article: