Adding a new faction - UberWaffe/OpenRA GitHub Wiki

This guide was created 2013-09-06 and works for the 2013-0902 release.

This is a step by step guide on how to add a new faction to your mod. I will try to go into as much detail as possible.

I also strongly recommend using Notepad++ to edit the .yaml files. The easiest way to create a new faction (and anything else for that mather) is to copy something that already works and use that as a base. Lets begin! (I assume you already made a copied of a mod to start from, in this example we use Red Alert). In this example mod we will add Great Britain (the Brits) as a playable faction.

The files we will edit are.

  • system.yaml
  • chrome.yaml
  • voice.yaml

I will also go into how to add some units to your faction.

System.yaml

Step one of this guide is to edit the system.yaml file. It's located in your mod folder under the rules directory. (i.ex. OpenRA/mods/your mod/rules/system.yaml). WITHOUT THIS CODE THE GAME WILL CRASH.

search after this code:

Country@0:
	Name: Allies
	Race: allies
Country@1:
	Name: Soviet
	Race: soviet

Copy the Country@1 and paste it under the soviet part. Replace the @1 with a @2 Replace the Name trait with the faction name, this should be the name that you want to show up ingame (i.ex. "Great Britain") and replace the Race trait with the interior code name, this should be something more simple for code sake (i.ex. "brits"). The final code should look like this.

Country@0:
	Name: Allies
	Race: allies
Country@1:
	Name: Soviet
	Race: soviet
Country@2:
	Name: Great Britain
	Race: brits

Now we need to fix the starting units for our new faction. Search for this code now.

MPStartUnits@mcvonly:
	Class: none
	Races: soviet, allies
	BaseActor: mcv
MPStartUnits@lightallies:
	Class: light
	Races: allies
	BaseActor: mcv
	SupportActors: e1,e1,e1,e3,e3,jeep,1tnk
	InnerSupportRadius: 3
	OuterSupportRadius: 5

Under MPStartUnits@mcvonly: add your faction in the races trait. Now if you clone allies or soviet, copy the MPStartUnit@light(soviet/allies) and heavy(soviet/allies). Replace the name with your faction, in this example we would write brits instead, replace the race trait with our faction (again, brits). the BaseActor is our main unit, the MCV. The Support Actors are the support units. In the light starting unit class we start with 3 rifle infantry (e1), 2 rocket infantry (e3), one ranger (jeep), and a light tank (1tnk). These codes can be found under rules directory, check infantry, vehicles, ships and aircraft.yaml to get the unit codes. The editet code should look like this.

MPStartUnits@mcvonly:
	Class: none
	Races: soviet, allies, brits
	BaseActor: mcv
MPStartUnits@lightbrits:
	Class: light
	Races: brits
	BaseActor: mcv
	SupportActors: e1,e1,e1,e3,e3,jeep,1tnk
	InnerSupportRadius: 3
	OuterSupportRadius: 5
MPStartUnits@heavybrits:
	Class: heavy
	Races: brits
	BaseActor: mcv
	SupportActors: e1,e1,e1,e3,e3,jeep,1tnk,2tnk,2tnk,2tnk
	InnerSupportRadius: 3
	OuterSupportRadius: 5

I dident have the allies and soviet heavy and light starting options. DO NOT remove these tho, just add the brits heavy/light option under allies/soviets light and heavy option. DO NOT create a new MCVonly entry. Just add your new faction to it instead, so if we wanted a 4th faction (i.ex. Japan), just write japan after brits et.c.

What have we accomplished?

The base code to prepare our faction for the game.

Thats it for the system.yaml code. Save it and close it down.

Chrome.yaml

Step two of this guide, if you haven't figured it out we need to open the chrome.yaml file now. its located in the root mod folder. This part will fix the UI (interface) for your faction. WITHOUT THIS CODE THE GAME WILL CRASH.

Start by copy paste this code.

chrome-allies: chrome-allies.png
	specialbin-top: 0,0,30,51
	specialbin-middle: 0,51,30,51
	specialbin-bottom: 0,153,30,39
	moneybin: 192,0,320,31
	radar: 297,31,210,222
	tooltip-bg: 0,288,272,136

power-allies: chrome-allies.png
	power-indicator: 187,4,4,7

palette-allies: chrome-allies.png
	top: 297,288,201,9
	dock-top: 498,274,14,23
	bottom: 297,489,201,9
	dock-bottom: 498,489,14,23
	bg-0: 297,297,201,48
	dock-0: 498,297,14,48
	bg-1: 297,345,201,48
	dock-1: 498,345,14,48
	bg-2: 297,393,201,48
	dock-2: 498,393,14,48
	bg-3: 297,441,201,48
	dock-3: 498,441,14,48

digits-allies: chrome-allies.png
	0: 32,0,13,17
	1: 45,0,13,17
	2: 58,0,13,17
	3: 71,0,13,17
	4: 84,0,13,17
	5: 97,0,13,17
	6: 110,0,13,17
	7: 123,0,13,17
	8: 136,0,13,17
	9: 149,0,13,17

Replace all "allies" text with your faction name (brits). DO NOT replace the allies text infront of .png. If you look in the uibits folder you can see all the pictures used for the UI. You can use any program that support transparency to edit these files (i.ex. Photoshop/Gimp). If you want to make your own UI (interface) just create some pngs and save them under uibits folder and then point your faction to use your custom UI instead. (i.ex. chrome-brits.png) I wont post the finished code for this (for sake of page size) but this part should be pretty straight forward.

next part to edit in this file is this part of the code.

tabs-selected: tabs.png
	allies-Building: 0,0,27,41
	allies-Defense: 0,40,27,41
	allies-Infantry: 0,80,27,41
	allies-Vehicle: 0,120,27,41
	allies-Plane: 80,160,27,41
	allies-Helicopter: 0,160,27,41
	allies-Ship: 0,200,27,41
	soviet-Building: 80,0,27,41
	soviet-Defense: 80,40,27,41
	soviet-Infantry: 80,80,27,41
	soviet-Vehicle: 80,120,27,41
	soviet-Plane: 80,160,27,41
	soviet-Helicopter: 0,160,27,41
	soviet-Ship: 80,200,27,41

tabs-ready: tabs.png
	allies-Building: 27,0,27,41
	allies-Defense: 27,40,27,41
	allies-Infantry: 27,80,27,41
	allies-Vehicle: 27,120,27,41
	allies-Plane: 107,160,27,41
	allies-Helicopter: 27,160,27,41
	allies-Ship: 27,200,27,41
	soviet-Building: 107,0,27,41
	soviet-Defense: 107,40,27,41
	soviet-Infantry: 107,80,27,41
	soviet-Vehicle: 107,120,27,41
	soviet-Plane: 107,160,27,41
	soviet-Helicopter: 27,160,27,41
	soviet-Ship: 107,200,27,41

tabs-normal: tabs.png
	allies-Building: 54,0,27,41
	allies-Defense: 54,40,27,41
	allies-Infantry: 54,80,27,41
	allies-Vehicle: 54,120,27,41
	allies-Plane: 134,160,27,41
	allies-Helicopter: 54,160,27,41
	allies-Ship: 54,200,27,41
	soviet-Building: 134,0,27,41
	soviet-Defense: 134,40,27,41
	soviet-Infantry: 134,80,27,41
	soviet-Vehicle: 134,120,27,41
	soviet-Plane: 134,160,27,41
	soviet-Helicopter: 54,160,27,41
	soviet-Ship: 134,200,27,41

Just to keep it simple, you can add your own tabs to your faction, but we will use the allies one for now. For all three tabs entry just add this code.

tabs-selected: tabs.png
	allies-Building: 0,0,27,41
	allies-Defense: 0,40,27,41
	allies-Infantry: 0,80,27,41
	allies-Vehicle: 0,120,27,41
	allies-Plane: 80,160,27,41
	allies-Helicopter: 0,160,27,41
	allies-Ship: 0,200,27,41
	soviet-Building: 80,0,27,41
	soviet-Defense: 80,40,27,41
	soviet-Infantry: 80,80,27,41
	soviet-Vehicle: 80,120,27,41
	soviet-Plane: 80,160,27,41
	soviet-Helicopter: 0,160,27,41
	soviet-Ship: 80,200,27,41
	brits-Building: 0,0,27,41
	brits-Defense: 0,40,27,41
	brits-Infantry: 0,80,27,41
	brits-Vehicle: 0,120,27,41
	brits-Plane: 80,160,27,41
	brits-Helicopter: 0,160,27,41
	brits-Ship: 0,200,27,41

The first 2 combination of digits are the starting pixel (from top-left), the second two is how large the button is in pixel (from top-left). Easy enough we can see that all buttons are 27 pixel in width and 41 in height. with diffrent location in the ui. Tabs-selected are for the selected tab ingame. Tabs-ready is for the tabs that have a completed unit/structure. And Tabs-normal is how it looks when its just sitting there, normaly and not selected.

Almost done here. The last bit of code to change is the flags.

flags: buttons.png
	allies: 30,84,30,15
	soviet: 0,84,30,15
	random: 60,84,30,15
	spectator: 60,84,30,15

You can use your program of choice to add a flag to the buttons.png, and then add it to the code. Make sure you take note on the top-left pixel position and write it in the code. The flag should be the same size as the other flags (standard size: 30px - 15px). The code should look something like this when its done.

flags: buttons.png
	allies: 30,84,30,15
	soviet: 0,84,30,15
	brits: 30,84,30,15
	random: 60,84,30,15
	spectator: 60,84,30,15

I'm using the allies flag for the brits faction in this example code. Something you can do to make it easier if you play to add alot of factions, is to make a new flags.png and just point the flags to that instead, but that won't be needed for this example guide.

What have we accomplished?

Making the UI (Interface) for our faction.

No reason to stay here anylonger, save chrome.yaml and close it down.

Voices.yaml

Voices.yaml is also located in the root mod folder, just open it open and lets get to work (Don't worry, not much left to do). CODE WILL WORK WITHOUT EDITING THIS FILE. ,do note tho. Your units will be silent if you do.

The code we want is right on the top of the file. looks like this.

GenericVoice:
	Variants:
		soviet: .r01,.r03
		allies: .v01,.v03
	Voices:
		Select: await1,ready,report1,yessir1
		Move: ackno,affirm1,noprob,overout,ritaway,roger,ugotit
		Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10
	DisableVariants: Die

VehicleVoice:
	Variants:
		soviet: .r00,.r02
		allies: .v00,.v02
	Voices:
		Select: vehic1,yessir1,report1,await1
		Move: ackno,affirm1

GenericVoice is for infantry units, and VehicleVoice is for vehicles/aircraft/boats. Now do we want our faction to speak like Americans or like Russians? Make your choice and copy the allies: .v01,.v03 in GenericVoices and add it under allies and replace it with the name of your faction. do the same with VehicleVoice (.v00,.v02). The code should look like this now.

GenericVoice:
	Variants:
		soviet: .r01,.r03
		allies: .v01,.v03
		brits: .v01,.v03
	Voices:
		Select: await1,ready,report1,yessir1
		Move: ackno,affirm1,noprob,overout,ritaway,roger,ugotit
		Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10
	DisableVariants: Die

VehicleVoice:
	Variants:
		soviet: .r00,.r02
		allies: .v00,.v02
		brits: .v00,.v02
	Voices:
		Select: vehic1,yessir1,report1,await1
		Move: ackno,affirm1

What have we accomplished?

Freedom of speech. Our units will now talk when you select and order them around! Yay!

Our faction is now actully ready, but we should flesh it out abit and i'm gonna explain real fast how to do this.

Adding some basic units to your new faction

Now that we have our faction it would be good if the faction had anything to fight with. I wont go into to much detail here about how to create units and such here.

Open up the rules folder. First thing first is to open structures.yaml. What do we got here? every structure in the game thats what. It's built in a very simple manner. Just find a structure. The easiest way is to find the name tag.

GAP:
	Inherits: ^Building
	RequiresPower:
	CanPowerDown:
	Valued:
		Cost: 1000
	Tooltip:
		Name: Gap Generator
		Description: Regenerates the shroud nearby, \nobscuring the area.\n  Unarmed

As you can see, the ingame code name is GAP. But you can be 100% sure its the right building in the tooltip name tag. Now we know for sure this is the allied Gap Generator.

If you copied your faction from allies i do recommend that you use all allies buildings as base, and leave the soviet building out of it. This is mainly becuase of each building have its own prerequisites (a building you have to own to get the right to build this unit), if you mix the soviet tech center in your faction and have the gap you wont be able to build it becuase the Gap Generator needs the allied Tech center to be built.

So hard part here, i want you to go through the whole structures.yaml file, and add ,brits after allies part to unlock that building to your faction. Becuase i'm such a decent guy i will also help you with the pillboxes, in OpenRA pillboxes works in a diffrent manner, you can kick out the infantry in it and garrison it with something else (i.ex. A flame thrower to create a flame pillbox) so if you want the pillbox as a defensive building just add your faction the PBOX.E1 / HBOX.E1 to make it work.

Now do exacly this to the rest of the diffrent unit yaml files in the rules folder. These are the yaml files you should edit.

  • Buildings.yaml
  • Infantry.yaml
  • Vehicle.yaml
  • Aircraft.yaml
  • Ships.yaml

Add the units you want to your faction and then your done.

What now?

Start the game and test your new faction, it should work flawlessly.

In depth guide by HSFOutcast.