Adding a voxel unit ingame - UberWaffe/OpenRA GitHub Wiki

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

This will be a step by step in depth guide on how to add a voxel unit to your game. As with all my guides i recommend using Notepad++ to edit the yaml file. I will not write a guide how you make a voxel, just how you add a finished voxel into the game. In this guide i will add a voxel Apache helicopter and we will add it to a mod based on Red Alert.

The files we will edit are.

  • A unit yaml file (i.ex. rules/aircraft.yaml)
  • A Sequence yaml file (i.ex. sequences/aircraft.yaml)
  • voxels.yaml (i.ex. sequences/voxels.yaml)
  • system.yaml
  • mod.yaml

All these files should be added to the mod.yaml file. Otherwise our game will crash when we try out the unit.

unit.yaml

Before we start editing our unit (i.ex. our helicopter) we need to add the voxel to the game. Put the finished vxl into the bits folder. we also need a cameo (icon) for our unit, it should be named the same as the unit with icon writen at the end.

Example:
Apache.vxl
Apache.hva
Apacheicon.shp

Lets start with the code for the unit. Open up our unit yaml file, in this example we would open the aircraft.yaml inside the rules folder. For simplicity you can just add this code at the bottom of the file, The most important part is that the name APACHE is the same name as the voxel.

APACHE:
	Inherits: ^Helicopter
	Valued:
		Cost: 2000
	Tooltip:
		Name: Apache Longbow
		Description: Gunship armed with Missiles.\n  Strong vs Tanks\n  Weak vs Infantry
	Buildable:
		Queue: Air
		BuildPaletteOrder: 20
		Prerequisites: hpad, atek
		Owner: allies
	Selectable:
		Bounds: 30,24
	Helicopter:
		RearmBuildings: hpad
		LandWhenIdle: false
		InitialFacing: 20
		ROT: 4
		Speed: 16
	Health:
		HP: 200
	Armor:
		Type: Light
	RevealsShroud:
		Range: 12
	Armament@PRIMARY:
		Weapon: HellfireAA
		LocalOffset: 0,-213,-85
	Armament@SECONDARY:
		Weapon: HellfireAG
		LocalOffset: 0,213,-85
	AttackHeli:
		FacingTolerance: 20
	LimitedAmmo:
		Ammo: 12
		PipCount: 4
	AutoTarget:
	WithRotor:
		Offset: 85,0,384
	RenderSprites:
	RenderVoxels:
		PlayerPalette:tibsun
		Scale: 8
		LightAmbientColor: 0.2, 0.2, 0.2
		LightDiffuseColor: 0.6, 0.6, 0.6
	WithVoxelBody:

It's important that the code name of the unit is the same name as the voxel. Thats it for the unit, you might need to play around with the Scale trait to get your unit in the right size, and play around with the rotor offset to get the rotor(s) in the correct position. Everything else here should be straight forward. If something is unclear you can always check my creating a new unit guide here.

What have we accomplished?

Added the base code for the unit. What building does ited, how much should it cost, what weapon to use et.c.

Save the file and close it down. Time to move on.

Sequences yaml

Now lets open up the Aircraft.yaml file in the sequences folder for our Apache Helicopter.

We need to add this line of code inside the aircraft.yaml (at the top, bottom or somewhere in the middle. Your choice)

apache:
	icon: apacheicon
		Start: 0
	rotor: lrotor
		Start: 0
		Length: 4
	slow-rotor: lrotor
		Start: 4
		Length: 8

What have we accomplished?

Added the icon (cameo) for our unit and gaved it a rotor so it wont look stupid when it flies. :)

Save the aircraft.yaml file in sequences and close it down. Lets head on.

Voxels.yaml

Create a new file if you do not have a voxels.yaml and name it exactly that. Adding voxel is a rather new function and this file is needed for voxel. in the voxels.yaml you add all your voxels. If we did a tank we would add the tank voxel first, then bind it together with the turret voxel and the turret voxel with the barrel voxel.

Luckily for us, we aren't doing a tank, we are doing a helicopter so all we need to add is this.

apache:
	idle:

If you are interested in how the code for a tank should look like then here's an example.

4tnk:
	idle:
	turret: 4tnktur
	barrel: 4tnkbarl

That would be the code for Tibsun Mammoth tank.

What have we accomplished?

We just made the game understand that our helicopter is a voxel and not a shp. If we made a tank we also made it understand what is what. (what voxel is the body, the turret and the barrel)

Save and close voxels.yaml down. It's time to move on.

System.yaml

The absolut first thing we will do is to insert the palette under the player: trait. Right after Player: insert this code:

	PlayerColorPalette@tibsun:
		BasePalette: tibsun
		BaseName: tibsun
		RemapIndex: 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31

Your code should look something like something like this in system.yaml (From the beginning of the file):

Player:
	PlayerColorPalette@tibsun:
		BasePalette: tibsun
		BaseName: tibsun
		RemapIndex: 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
	TechTree:
	ClassicProductionQueue@Building:
		Type: Building
		...

Okay, open up system.yaml inside the rules folder. inside this file search for "Country@0". Depending on what game the first country will be diffrent for RA it would be Allies. Above this post this little bit of code in.

	PaletteFromFile@tibsun:
		Name:tibsun
		Filename: unittem.pal
		ShadowIndex: 4
		AllowModifiers: false
	VoxelNormalsPalette@normals:
		Name: normals
		Type: TiberianSun

Your code should look like this when its done.

	PaletteFromFile@tibsun:
		Name:tibsun
		Filename: unittem.pal
		ShadowIndex: 4
		AllowModifiers: false
	VoxelNormalsPalette@normals:
		Name: normals
		Type: TiberianSun
	Country@0:
		Name: Allies
		Race: allies
	Country@1:
		Name: Soviet
		Race: soviet

As long as this code is under the world: trait you should be good, by putting the code right above the first country it will be in the very end of the palette code under the world: trait.

What have we accomplished?

We fixed the normals palette so your voxel unit wont turn up colored like a rainbow... And thats a good thing.

Lets save the system.yaml file and close it down. Almost done here.

Mod.yaml

The Mod.yaml file is a very important file, the game reads this and the file tells the game what files to read, so you need to add all the files that are new. Search after sequences, something like this should pop up:

Sequences:
	mods/yourmod/sequences/ships.yaml
	mods/yourmod/sequences/vehicles.yaml
	mods/yourmod/sequences/structures.yaml
	mods/yourmod/sequences/infantry.yaml
	mods/yourmod/sequences/aircraft.yaml
	mods/yourmod/sequences/misc.yaml
	mods/yourmod/sequences/decorations.yaml

Create this under sequences but above cursors:

VoxelSequences:
	mods/yormod/sequences/voxels.yaml

Your code should look like this:

	...s/ra/sequences/decorations.yaml

	VoxelSequences:
		mods/yourmod/sequences/voxels.yaml

	Cursors:
		mods/yourmod/cursors.yaml

	Chrome:
		mods/yourmod/ch...

What have we accomplished?

We added the voxels sequences file to the mod.yaml file. The game will now load that file when it starts up!

Save and close down mod.yaml.

What now?

Start the game and test your new voxel unit.

In depth guide by HSFOutcast.