• We are currently performing site maintenance, parts of civfanatics are currently offline, but will come back online in the coming days. For more updates please see here.

Guide for civ5units.xml?

SeptimusH

Chieftain
Joined
May 6, 2011
Messages
97
Is there a guide out there that shows what each of the tags do in civ5units.xml? I'm new to modding, and civ 5.
 
No. The wiki has some information, but generally speaking you have to either ask people what they do or try it out yourself.

So what, specifically, did you want to know?
 
No. The wiki has some information, but generally speaking you have to either ask people what they do or try it out yourself.

So what, specifically, did you want to know?

Well, the ones I don't know are:

CombatClass (Is that what type the unit is, like gunpowder or mounted? Could I create a new one?)
DefaultUnitAI
GoodyHutUpgradeUnitClass (What's a goody hut, a village?)
MilitarySupport
MilitaryProduction
IgnoreBuildingDefense
Conscription

Also, is there a way to make a unit better at defending or attacking?
 
CombatClass - it's the unit type, it determines what promotions the unit can get, and the bonuses other units get against it (like Spearmen and Pikemen that get a bonus against Mounted units). These types are defined in BasicInfos\CIV5UnitCombatInfos.xml. You can add new types there, but I don't know what kind of problems it could cause (I haven't done it in my mod yet).

DefaultUnitAI - determines what the AI will normally use the unit for. Units can have multiple AI types, defined in Unit_AITypes (so the AI can use them for other things than default if needed). All AI types are listed in BasicInfos\CIV5UnitAIInfos.

GoodyHutUpgradeUnitClass - Goody Huts are Ancient Ruins, this defines what unit class you will get when the unit gets the upgrade effect when exploring Ancient Ruins.

MilitarySupport, MilitaryProduction, IgnoreBuildingDefense, Conscription - AFAIK these are obsolete tags from Civ4, not used in Civ5 (but probably MilitaryProduction can be used if you set a MilitaryProductionModifier for a building, which should modify the production rate of all units with MilitaryProduction set to true).

Also, is there a way to make a unit better at defending or attacking?

You can do it using promotions - create a promotion with AttackMod or DefenseMod, and give it to the unit in Unit_FreePromotions.
 
You can add new types there, but I don't know what kind of problems it could cause (I haven't done it in my mod yet).

Adding a new Combat Class has no real problems mechanically, but there's one little issue: apparently, all of the combat animations and visual and sound effects are tied to combat class somehow. So if you create a new one, you won't see any explosions when it fights, no watching your swordsmen charge into his ranks.
Depending on your perspective, this can be an advantage as it makes combats take a LOT less time.
 
How would I make a promotion that adds AttackMod or DefenseMod, and what would I do for the value?

I'm trying to make a sniper unit, I want it to be like a modern/industrial era archer unit, that can defend very well, especially on hills, forests, or jungles, but cannot attack. (Or possibly the other way around)
 
Check the units that are already in the game - Lancer has a defense penalty, and Janissary an attack bonus. Use the promotions that these units have or create similar ones (for example a promotion with positive value of DefenseMod will give a bonus to defense).

To make a unit that can't attack, use PROMOTION_ONLY_DEFENSIVE.
 
Thanks. Is there a way to make it so the sniper couldn't get certain promotions?

And that they are invisible to most units?

What does PROMOTION_MUST_SET_UP do?
 
Thanks. Is there a way to make it so the sniper couldn't get certain promotions?

Selectable promotions are tied to Combat Class. So the only way to prevent the sniper from getting the promtions that, say, a Rifleman gets, would be to have the sniper not count as a Gunpowder unit. This has quite a few drawbacks.

And that they are invisible to most units?

There are a series of promotions related to invisibility and detecting invisibility. The only example of this in the core game is the submarine: invisible to most units, but visible to the destroyer and such.

What does PROMOTION_MUST_SET_UP do?

It's what the artillery units have that says they need to set up before firing.

Look, instead of asking us, just look through the Units xml and see what units have a promotion already. The "set up" thing, for instance, should have been completely obvious once you noticed which units already had it.
If there's no unit that has a certain ability, then it MIGHT just be something the devs didn't end up using, or it might be completely nonfunctional. It's not easy to tell the difference.
 
Selectable promotions are tied to Combat Class. So the only way to prevent the sniper from getting the promtions that, say, a Rifleman gets, would be to have the sniper not count as a Gunpowder unit. This has quite a few drawbacks.



There are a series of promotions related to invisibility and detecting invisibility. The only example of this in the core game is the submarine: invisible to most units, but visible to the destroyer and such.



It's what the artillery units have that says they need to set up before firing.

Look, instead of asking us, just look through the Units xml and see what units have a promotion already. The "set up" thing, for instance, should have been completely obvious once you noticed which units already had it.
If there's no unit that has a certain ability, then it MIGHT just be something the devs didn't end up using, or it might be completely nonfunctional. It's not easy to tell the difference.

So, how do I create a new promotion? Do I need to do anything with <UnitPromotions_UnitCombats> or </UnitPromotions_Domains> or </UnitPromotions_UnitCombatMods> or </UnitPromotions_UnitClasses> or anything else? I'm just doing this for new invisible promotions:

Code:
<GameData>
	<UnitPromotions>
		<Row>
			<Type>PROMOTION_INVISIBLE_SNIPER</Type>
			<Description>TXT_KEY_PROMOTION_INVISIBLE_SUBMARINE</Description>
			<Help>TXT_KEY_PROMOTION_INVISIBLE_SUBMARINE</Help>
			<Sound>AS2D_IF_LEVELUP</Sound>
			<Invisible>INVISIBLE_SNIPER</Invisible>
			<PortraitIndex>59</PortraitIndex>
			<IconAtlas>ABILITY_ATLAS</IconAtlas>
			<PediaType>PEDIA_ATTRIBUTES</PediaType>
			<PediaEntry>TXT_KEY_PEDIA_PROMOTION_INVISIBLE_SUBMARINE</PediaEntry>

		</Row>
		<Row>
			<Type>PROMOTION_SEE_INVISIBLE_SNIPER</Type>
			<Description>TXT_KEY_PROMOTION_SEE_INVISIBLE_SUBMARINE</Description>
			<Help>TXT_KEY_PROMOTION_SEE_INVISIBLE_SUBMARINE</Help>
			<Sound>AS2D_IF_LEVELUP</Sound>
			<SeeInvisible>INVISIBLE_SNIPER</SeeInvisible>
			<PortraitIndex>58</PortraitIndex>
			<IconAtlas>ABILITY_ATLAS</IconAtlas>
			<PediaType>PEDIA_ATTRIBUTES</PediaType>
			<PediaEntry>TXT_KEY_PEDIA_PROMOTION_SEE_INVISIBLE_SUBMARINE</PediaEntry>
		</Row>
	</UnitPromotions>
</GameData>
 
So, how do I create a new promotion? Do I need to do anything with <UnitPromotions_UnitCombats> or </UnitPromotions_Domains> or </UnitPromotions_UnitCombatMods> or </UnitPromotions_UnitClasses> or anything else?

UnitPromotions_UnitCombats governs two things:
1> Which combat classes can select the promotion when they level up (unless you also set <CannotBeChosen>)
2> Which combat classes gain the promotion from Wonders or Buildings.
If your promotion is only ever going to be given to a unit explicitly through the Unit_FreePromotions table, then you don't need this.

UnitPromotions_Domains is an OFFENSIVE set. As in, "+20% vs Land units". So unless your promotion has an effect like that, you don't put anything in there. Same goes for the others you listed.
And again, instead of asking, all you needed to do was look at the promotions it listed and see what they do. The first promotion listed in UnitPromotions_Domains, for instance, is
Code:
<Row>
  <PromotionType>PROMOTION_TARGETING_1</PromotionType>
  <DomainType>DOMAIN_SEA</DomainType>
  <Modifier>20</Modifier>
</Row>
Since the help text for Targeting I says "+20% vs. Sea units", it's pretty obvious what that table does. Same for most of the others. So get into the habit of checking things this way; we're willing to answer questions, but if you stop modding to ask a question on the boards every time, you'll never get done, because we're just not active here 24/7 and there are a LOT of tables.
 
For the unit flavors, do I need to put all flavors? Or can I just put defense?

Also, can I put units and unit flavors in teh same file, IDK if that's how it works in modbuddy.
 
For the unit flavors, do I need to put all flavors? Or can I just put defense?

Flavors are optional, for units/buildings/etc. If you don't specify them, the games assumes a zero value. The ONLY place where Flavors are mandatory is when you're adding a new civilization and set the leader's flavors, because you're not actually setting flavors there, you're setting MULTIPLIERS. As in "weight all flavors of type X heavier"

Also, can I put units and unit flavors in teh same file, IDK if that's how it works in modbuddy.

You can put every single thing in one file and name it "Bob.xml" if you want. The game doesn't care, because when Civ5 starts a game, what it does is translate all of your XML to SQL, modifies the core database, and then links the savegame to that modified database. As long as you have the usual OnModActivated command for every gamedata XML file, it'll work the same regardless of how many files you use.

But, if you have any error in your XML, the ENTIRE FILE containing that error is ignored. It doesn't matter whether the first 99 lines worked just fine, if line 100 fails then the entire file is tossed out. So it pays to not stick everything into a single file, but as long as you remember to check your log files periodically, you shouldn't be having problems with this.
 
I don't know how to use it, or much lua :/

Tutorial or something? I want to test my unit without playing a whole game, like worldbuilder.
 
You don't have to know LUA to use some functions of the FireTuner - using one of the tabs you can place units on the map, much like in the Civ4 World Builder.
 
Back
Top Bottom