Questions on Custom Units

greenlamb

Chieftain
Joined
Jun 24, 2014
Messages
26
Hi, I'm new to modding Civ5, really appreciated all the tutorials available here, you guys rock. I'm creating a mod with a new civilization.

I do have 2 questions I couldn't really find a definite answer to:

1. If I wanted to create an unique unit that does NOT replace an existing unit, is that possible? Maybe by just omitting the <Class>UNITCLASS_xxx</Class> line? And if this works, does this count towards the requirement of having at 2 unique units/buildings etc?

2. Is it possible to make an unique unit than has the ability to change the terrain it's standing on, e.g. anything to tundra.
 
Define a new class in this way:
Code:
<UnitClasses>
    <Row>
	<Type>UNITCLASS_MYNEWCLASS</Type>
	<Description>TXT_KEY_UNIT_MYNEWCLASS</Description>
	<DefaultUnit>UNIT_MYNEWUNIT</DefaultUnit>
    </Row>
</UnitClasses>

then define your unit with this class and finally:

Code:
<Civilization_UnitClassOverrides>
   <Row>
	<CivilizationType>CIVILIZATION_MYCIV</CivilizationType>
	<UnitClassType>UNITCLASS_MYNEWCLASS</UnitClassType>
	<UnitType>UNIT_MYNEWUNIT</UnitType>
   </Row>
</Civilization_UnitClassOverrides>
 
2. Is it possible to make an unique unit than has the ability to change the terrain it's standing on, e.g. anything to tundra.

Ignoring the question of "how to", terraforming is a PITA as the 3D map will not update the graphics for the tile until the game is saved/reloaded. But the SV map will update instantly. This may be a show-stopper for you.
 
Define a new class in this way:
Code:
<UnitClasses>
    <Row>
	<Type>UNITCLASS_MYNEWCLASS</Type>
	<Description>TXT_KEY_UNIT_MYNEWCLASS</Description>
	<DefaultUnit>UNIT_MYNEWUNIT</DefaultUnit>
    </Row>
</UnitClasses>

then define your unit with this class and finally:

Code:
<Civilization_UnitClassOverrides>
   <Row>
	<CivilizationType>CIVILIZATION_MYCIV</CivilizationType>
	<UnitClassType>UNITCLASS_MYNEWCLASS</UnitClassType>
	<UnitType>UNIT_MYNEWUNIT</UnitType>
   </Row>
</Civilization_UnitClassOverrides>

Thanks a lot Jamforce! Appreciate it :)

Ignoring the question of "how to", terraforming is a PITA as the 3D map will not update the graphics for the tile until the game is saved/reloaded. But the SV map will update instantly. This may be a show-stopper for you.

Thanks whoward69, I suspected it from the Modding Limitations sticky, but wanted to confirm it. It is a blow, but I thought of a workaround, sort of.

I was also initially thinking of making the unit able to change water/ocean tiles to ice tiles (along with the tundra change), but although I'll scrap the tundra change, I might still be able to implement the water/ocean to ice, by creating a dummy unit called ice floes. It can be spawned on water/ocean tiles, blocking movement for all sea (even own units) & enemy units but allowing own land units to travel on them without embarking. Other civilizations have to attack it (declaring war) to remove it. No upkeep required, no movement, can't be built in a city, can be removed by disbanding.

Now I'll just have to figure out how to code it...

BTW thanks whoward69 for your two posts on XML reference files and DDS tutorial, it really helped me :)
 
Define a new class in this way:
Code:
<UnitClasses>
    <Row>
	<Type>UNITCLASS_MYNEWCLASS</Type>
	<Description>TXT_KEY_UNIT_MYNEWCLASS</Description>
	<DefaultUnit>UNIT_MYNEWUNIT</DefaultUnit>
    </Row>
</UnitClasses>

then define your unit with this class and finally:

Code:
<Civilization_UnitClassOverrides>
   <Row>
	<CivilizationType>CIVILIZATION_MYCIV</CivilizationType>
	<UnitClassType>UNITCLASS_MYNEWCLASS</UnitClassType>
	<UnitType>UNIT_MYNEWUNIT</UnitType>
   </Row>
</Civilization_UnitClassOverrides>

Actually, if you want the unit to be buildable only by a specific civ, you should set the DefaultUnit to NONE, like it's done with the Galley in the base game, to make it available only to the barbarians.

So instead of:

Code:
<DefaultUnit>UNIT_MYNEWUNIT</DefaultUnit>

You should have:

Code:
<DefaultUnit>NONE</DefaultUnit>

(The rest of Jamforce's code remains unchanged.)
 
Thanks PowelS! I tested it out and it worked. Yesterday I searched through the forum and thought that I had to create a lot of SQL code and dummy units, as described by Nutty in this thread. Your method is definitely much easier for me as I'm more familiar with XML. Thanks again.
 
This is what I do. I use the RED modpack to make my units diverse. However, I wanted to add in dive bombers for a new unit class, for my Pacific scenario. How would I do this? If I can figure this out, motorized infantry and tank destroyers sound awesome too. If you could help me get the ball rolling I'd really appreciate it.
 
Hi nokmirt, I think you've been around much longer than I have obviously, but what I did was to create a new unit class that is not buildable by other civilizations, by using the method described by PowelS. Then I just add a new unique unit using this new unit class. Quite straightforward. For your case you can also use the generic 3d model art made by someone on this forum (sorry on mobile can't search now).
 
I think nokmirt means creating a new combat class. This is possible by adding a new row to the UnitCombatInfos table. But, last time I checked (I think it was in G&K times), no combat animations were played for units that were assigned to the new combat class. If it's still true in the current version, the only option is to use combat classes that aren't used in the mod (like melee units in a modern scenario) for new purposes.
 
Back
Top Bottom