Unit XML Questions

Flak Fox

Radioactive Vulpine
Joined
Apr 10, 2004
Messages
260
Location
USA
So I'm quite excited about the SDK and immediately dove into learning how modding works for this new game.

A couple of questions immediately arose that I could not find any answer to.

<Row>
<Class>UNITCLASS_MECH</Class>
<Type>UNIT_MECH</Type>
<PrereqTech>TECH_NUCLEAR_FUSION</PrereqTech>
<Combat>150</Combat>
<Cost>1000</Cost>
<Moves>3</Moves>
<CombatClass>UNITCOMBAT_ARMOR</CombatClass>
<Domain>DOMAIN_LAND</Domain>
<DefaultUnitAI>UNITAI_ATTACK</DefaultUnitAI>
<Description>TXT_KEY_UNIT_MECH</Description>
<Civilopedia>TXT_KEY_CIVILOPEDIA_UNITS_MODERN_MECH_TEXT</Civilopedia>
<Strategy>TXT_KEY_UNIT_MECH_STRATEGY</Strategy>
<Help>TXT_KEY_UNIT_HELP_MECH</Help>
<MilitarySupport>true</MilitarySupport>
<MilitaryProduction>true</MilitaryProduction>
<Pillage>true</Pillage>
<IgnoreBuildingDefense>true</IgnoreBuildingDefense>
<Mechanized>true</Mechanized>
<AdvancedStartCost>80</AdvancedStartCost>
<XPValueAttack>3</XPValueAttack>
<XPValueDefense>3</XPValueDefense>
<UnitArtInfo>ART_DEF_UNIT_MECH</UnitArtInfo>
<UnitFlagIconOffset>83</UnitFlagIconOffset>
<IconAtlas>UNIT_ATLAS_2</IconAtlas>
<PortraitIndex>36</PortraitIndex>
<MoveRate>ROBOT</MoveRate>
</Row>


In the following code I can't figure out exactly where one modifies what resource (if any) is required to build said unit, or where the unit's name information is displayed in the game.

I'm working on a mod that is going to involve several different classes/types of mechs with different abilities and what not so figuring these things out is going to be pretty vital. Most everything else seems to be common sense.

Thanks for reading.
 
Scroll down to the Unit_ResourceQuantityRequirements table in the Civ5Units.xml to see where you add resources.

As for the "name" of the unit, that would be TXT_KEY_UNIT_MECH

That's defined in CIV5GameTextInfos_Units.xml
 
Ah, I think I've got that figured out then. I'll dig into that a bit.

Another quick question, would you happen to know why the settler doesn't have a cost value set by default?

Thanks for your reply.
 
Another XML unit based question.

<Row>
<UnitType>UNIT_NUCLEAR_MISSILE</UnitType>
<ResourceType>RESOURCE_URANIUM</ResourceType>
<Cost>2</Cost>
</Row>


If one were to want a unit to require two resources, I would assume the following code would not work:

<Row>
<UnitType>UNIT_NUCLEAR_MISSILE</UnitType>
<ResourceType>RESOURCE_URANIUM</ResourceType>
<Cost>2</Cost>
<ResourceType>RESOURCE_OIL</ResourceType>
<Cost>1</Cost>
</Row>


Is there any known way to make a unit use two resources or is the game limited in that way?

Thanks again.


Tested it out and found my answer :p
 
Ah, I think I've got that figured out then. I'll dig into that a bit.

Another quick question, would you happen to know why the settler doesn't have a cost value set by default?

Thanks for your reply.

I can't answer the question of why the settler doesn't have a cost value, but I've done some testing, so I figured I'd share what I found.

The settler has a cost of 89:hammers: on normal speed. I cannot find this value defined anywhere in the XML, so I surmise that it may well be hard-coded somewhere. In fact, if you increase speed to marathon, the cost goes up to 268 instead of 267. I only did a rather cursory check of other units and buildings, but they all seemed to be multiplying up correctly, which suggests that there is some manner of hacky bodge job going on there, resulting in rounding errors or some other such nonsense.

If you define a cost value for the settler in a mod, this cost will have 89:hammers: added on to it. The minimum 2 population requirement for building settlers also appears to be hard-coded.

Basically, it's a crack-addled mess. If you're making a mod and need to alter the settler in any way, you're probably better off scrapping the default unit and making a new one from scratch with a different unitclass. And then probably breaking half a dozen other things, because who knows what else might be hard-coded in somewhere.
 
Top Bottom