After some success, I figured that it might be educational for modders, both new and experienced, to see how this is done, and thus gain a glimpse into how to mod for UaW. So, in this topic I will describe, as I progress, my quest towards the goal of getting Military working as a faction in skirmish, for all game modes and options, eventually including research.
At this point I don't know if I will succeed or not, or how easy it will be. But either way, it will educational and possibly entertaining (if you like seeing me slave over XML and Lua
Now, in case you've tried to create a mod for UaW (with patch 2) yourself, you might know that the game crashes when you hit the "Live" button, so enabling Military for multiplayer is not being considered right now as I can't test it. I'll get to that when the game is patched.
I will now post the prefix and chapter 1, so do let me know what you think of this idea and if I'm being clear enough, or perhaps if you want more details.
Note: this is NOT a tutorial on the syntax of XML or Lua. I assume you know how to use both of these. This tutorial will deal purely with figuring out what values to set where to get the behavior we want.
Prefix - Getting Started
First, the administrative business of setting up the mod:
- Created a directory "Mods" in C:\Program Files\Sega\Universe At War Earth Assault which will house all mods.
- In Mods, created a directory "Military" which will contain this Military mod.
- In Military, created a Launch.bat file with "..\..\LaunchUAW.exe MODPATH=Mods\Military" which will launch the mod.
- In Military, created a directory "Data" which will house all the data files of the mod.
Also, for future reference, when I talk about modifying some value in some file, I mean copying that file into the proper subdirectory in Mods\Military\Data, and then modifying the value in the copy.
So, for example, when I say I changed XML\Factions.xml, I mean I copied XML\Factions.xml from the mod tools to Mods\Military\Data\XML\Factions.xml and then changed the copied file. The same goes for Lua files (which live in the Scripts directory).
A more advanced tip, one that is very useful, is grep. It's a Linux tool that allows one to search through many files (even in multiple directories) for the occurance of some text. I use this to find definitions, references or usages of objects or names I might encounter.
As grep is not supplied on a Windows system, you can either install Cygwin, or get Grep for Windows. I can recommend the former if you have Linux shell experience.
So, with the framework set, it's time to enable the Military faction.
Chapter 1 - Enabling Military
As you might know, the Military faction has been developed by Petroglyph, but just disabled and left unfinished as the game design changed. My hope was that enabling the faction was a quick and straightforward process.
The first thing I did was take a look at XML\Factions.xml. Here I found the Military faction. It has its <Is_Human_Playable> property set to No, so I changed it to Yes and checked the game. No luck, still just three factions in the skirmish setup dialog.
With UaW's move to more Lua, I figured that there must be some Lua code that fills these selection boxes with a list of factions, so I looked in Scripts\GUI and, as expected, found a file Skirmish_Setup_Dialog.lua (there seems to be a file for every dialog in the game). In the initialization code I noticed event handlers for the user clicking the "up" and "down" button for a faction scroller:
this.Register_Event_Handler("Ready_Clicked", nil, On_Ready_Clicked)
this.Register_Event_Handler("Player_Faction_Up_Clicked", nil, On_Player_Faction_Up_Clicked)
this.Register_Event_Handler("Player_Faction_Down_Clicked", nil, On_Player_Faction_Down_Clicked)
this.Register_Event_Handler("Player_Team_Up_Clicked", nil, On_Player_Team_Up_Clicked)
this.Register_Event_Handler("Player_Team_Down_Clicked", nil, On_Player_Team_Down_Clicked)
this.Register_Event_Handler("Player_Color_Up_Clicked", nil, On_Player_Color_Up_Clicked)
this.Register_Event_Handler("Player_Color_Down_Clicked", nil, On_Player_Color_Down_Clicked)
this.Register_Event_Handler("Player_Difficulty_Up_Clicked", nil, On_Player_Difficulty_Up_Clicked)
this.Register_Event_Handler("Player_Difficulty_Down_Clicked", nil, On_Player_Difficulty_Down_Clicked)
The "up" handler (the function On_Player_Faction_Up_Clicked) contained, among others, the following code:
-- THE BIG FACTIONS
PG_FACTION_ALL = Declare_Enum(1)
PG_FACTION_NOVUS = Declare_Enum()
PG_FACTION_ALIEN = Declare_Enum()
PG_FACTION_MASARI = Declare_Enum()
PG_FACTION_MILITARY = Declare_Enum()
PG_FACTION_NEUTRAL = Declare_Enum()
PG_SELECTABLE_FACTION_MIN = PG_FACTION_NOVUS
PG_SELECTABLE_FACTION_MAX = PG_FACTION_MASARI
-- String form factions for networking
PG_FACTION_NOVUS_STRING = "Novus"
PG_FACTION_ALIEN_STRING = "Alien"
PG_FACTION_MASARI_STRING = "Masari"
PGFactionStringLookup = {}
PGFactionStringLookup[PG_FACTION_NOVUS] = PG_FACTION_NOVUS_STRING
PGFactionStringLookup[PG_FACTION_ALIEN] = PG_FACTION_ALIEN_STRING
PGFactionStringLookup[PG_FACTION_MASARI] = PG_FACTION_MASARI_STRING
-- Localized wide strings for user display.
PGFactionLocalizedLookup = {}
PGFactionLocalizedLookup[PG_FACTION_NOVUS] = Get_Game_Text("TEXT_FACTION_NOVUS")
PGFactionLocalizedLookup[PG_FACTION_ALIEN] = Get_Game_Text("TEXT_FACTION_ALIEN")
PGFactionLocalizedLookup[PG_FACTION_MASARI] = Get_Game_Text("TEXT_FACTION_MASARI")
PGFactionLocalizedLookup[PG_FACTION_MILITARY] = Get_Game_Text("TEXT_FACTION_MILITARY")
PGFactionLocalizedLookup[PG_FACTION_NEUTRAL] = Get_Game_Text("TEXT_FACTION_NEUTRAL")
-- Textures
PGFactionTextures = {}
PGFactionTextures[PG_FACTION_NOVUS] = "i_logo_novus.tga"
PGFactionTextures[PG_FACTION_ALIEN] = "i_logo_aliens.tga"
PGFactionTextures[PG_FACTION_MASARI] = "i_logo_masari.tga"
-- Maria 07.03.2007
PGFactionNameToFactionTexture = {}
PGFactionNameToFactionTexture["NOVUS"] = PGFactionTextures[PG_FACTION_NOVUS]
PGFactionNameToFactionTexture["ALIEN"] = PGFactionTextures[PG_FACTION_ALIEN]
PGFactionNameToFactionTexture["MASARI"] = PGFactionTextures[PG_FACTION_MASARI]
I changed PG_SELECTABLE_FACTION_MAX from PG_FACTION_MASARI to PG_FACTION_MILITARY. It immediately followed Masari in the list, so the four factions would still form a contiguous range, which is important, otherwise you'd get other factions in the selection box.The following modifications on this code were also done on the principle that "it was done for the other three playable factions, so I'd better do it for Military as well":
- Defined PG_FACTION_MILITARY_STRING as "Military"
- Put PG_FACTION_MILITARY_STRING in the PGFactionStringLookup array.
- Added "i_logo_military.tga" to the PGFactionTextures array. I checked Art\Textures\MT_CommandBar.mtd to confirm that this file exists.
- Finally, I also added Military to the PGFactionNameToFactionTexture array.

Aha! We can now select Military as a faction. But would the game actually start?

Promising! I wonder what happens next!

Success! Note that we have a complete Military command bar! It seems we start with 3 Humvees instead of a command center of sorts, but at least we can play Military.
Next chapter I'll try to get it to start with a command center of sorts and see if we can build stuff!
(Do let me know if you're interested or if I'm wasting my time)























