Giving Build Actions To Units Other Than Builders

bdp612

Chieftain
Joined
Feb 25, 2017
Messages
13
Tried to search for answers to this before posting! I've just started to make a new civilization. So far I've gotten used to editing the XML files successfully, but I'm afraid I've reached a limit of that method for what I want to do, and so I'm looking for alternatives.

I'm hoping to replace a Missionary unit. It would lose the ability to spread religion, and gain the ability to plant a Forest tile (like a builder after achieving the Conservation civic). I was hoping to find a place in the XML where unit operations are granted to units, but I had no luck after a lot of searching. Does anyone have a method to achieve something like this?

I know that I could make the Builder unit gain the ability to add Forest tiles earlier, and give it attributes like that of a Missionary, but I would then hope to remove all of the other Build actions associated with the Builder.

Thanks in advance for any help!
 
Build actions are assigned in Improvements.xml, like so:

Code:
    <Improvement_ValidBuildUnits>
        <Row ImprovementType="IMPROVEMENT_FARM" UnitType="UNIT_BUILDER"/>
        <Row ImprovementType="IMPROVEMENT_MINE" UnitType="UNIT_BUILDER"/>
        <Row ImprovementType="IMPROVEMENT_QUARRY" UnitType="UNIT_BUILDER"/>
        <Row ImprovementType="IMPROVEMENT_FISHING_BOATS" UnitType="UNIT_BUILDER"/>
        <Row ImprovementType="IMPROVEMENT_PASTURE" UnitType="UNIT_BUILDER"/>
ETC.
    </Improvement_ValidBuildUnits>

Failing to assign any of the listed build actions to your new unit (missionary) should result in said unit being unable to construct farms, mines, pastures, etc. However, as far as I can tell, the ability to plant forests is a hardcoded element and integral to build charges. In other words, any unit with build charges should be capable of planting forests, once the required civic is researched. However, the ability to remove features and improvements is also hardcorded into build charges. So, a unit capable of planting forests is also capable of removing features & improvements as long as it has at least one build charge. I don't know of a way around this using xml.

So, all you have to do is give the missionary a number of build charges, as, for example, in sql:

UPDATE Units SET BuildCharges=10, WHERE UnitType='UNIT_MISSIONARY';

and voila. You would also want to remove the missionary's SpreadCharges and other elements of its former role (i.e. ReligiousStrength="100" SpreadCharges="3" PurchaseYield="YIELD_FAITH") and change the CostProgressionModel="COST_PROGRESSION_PREVIOUS_COPIES". You may also want to remove the CanCapture="False".

A MINOR CLARIFICATION: A military engineer also has "BuildCharges", but is not capable of planting forests. As far as I can tell, the key distinction between a builder and an engineer is in their FormationClasses. The engineer is tagged as FORMATION_CLASS_SUPPORT, while the builder is identified as FORMATION_CLASS_CIVILIAN. So, as long as the unit you are giving the charges is a civilian unit, the above should work. The missionary is a civilian unit.

UPDATE: I tested the above quickly by inserting the relevant values into Units.xml, and the method works.

Good luck!
 
That's the exact type of assignment that I was hoping to find but must have just looked over, over and over. And thanks so much for the extra tips about builds v spreads, military engineers, etc. Thanks so much!
 
You are most welcome! Frankly, the forest-planting mechanic (like many others) is virtually undocumented, so there is nowhere to look for an explanation. I saw the connection by pure accident when a mod I was using (that gave settlers build charges to make roads) also turned them into unintentional foresters. I must have clicked the button by mistake and was duly surprised.

Actually, I have a suggestion... you may have good reasons to eliminate the missionary unit (e.g. the "religious carpet of doom"), but I think there may be an even better candidate for the role. I find that the most useless unit in the game is the Naturalist. One park charge and it's history. What about giving it the build charges instead? Frankly, in my own games, I've modded the Naturalist to have several park charges:

<Row UnitType="UNIT_NATURALIST" BaseMoves="4" Cost="800" BaseSightRange="3" ZoneOfControl="false" Domain="DOMAIN_LAND" FormationClass="FORMATION_CLASS_CIVILIAN" Name="LOC_UNIT_NATURALIST_NAME" Description="LOC_UNIT_NATURALIST_DESCRIPTION" CanCapture="False" CostProgressionModel="COST_PROGRESSION_PREVIOUS_COPIES" CostProgressionParam1="100" PurchaseYield="YIELD_FAITH" PseudoYieldType="PSEUDOYIELD_UNIT_RELIGIOUS" PrereqCivic="CIVIC_CONSERVATION" MustPurchase="TRUE" CanRetreatWhenCaptured="True" ParkCharges="5"/>

You just have to change this variable:

ParkCharges="5"

That way, the Naturalist actually makes some senses. Anyways, just an idea. If you make whatever you are changing into a mod, I'd be interested in taking a look!

GB
 
Build actions are assigned in Improvements.xml, like so:

Code:
<Improvement_ValidBuildUnits>
<Row ImprovementType="IMPROVEMENT_FARM" UnitType="UNIT_BUILDER"/>
<Row ImprovementType="IMPROVEMENT_MINE" UnitType="UNIT_BUILDER"/>
<Row ImprovementType="IMPROVEMENT_QUARRY" UnitType="UNIT_BUILDER"/>
<Row ImprovementType="IMPROVEMENT_FISHING_BOATS" UnitType="UNIT_BUILDER"/>
<Row ImprovementType="IMPROVEMENT_PASTURE" UnitType="UNIT_BUILDER"/>
ETC.
</Improvement_ValidBuildUnits>
Failing to assign any of the listed build actions to your new unit (missionary) should result in said unit being unable to construct farms, mines, pastures, etc.

Just wondering, but do you know if its possible to make it so a new custom unit can build the exact same things a a builder can without changing the games files? I'm just wondering because other wise (Unless I'm wrong about it.) you could not upload it as a mod to the Steam Workshop.

Also, my apologies for asking a question on this thread that is only semi-related.
 
I think all the answers as to why Planting a Forest works the way it does are here:
Code:
<Row CivicType="CIVIC_CONSERVATION" Name="LOC_CIVIC_CONSERVATION_NAME" Description="LOC_CIVIC_CONSERVATION_DESCRIPTION"
	Cost="1255" AdvisorType="ADVISOR_CULTURE" EraType="ERA_MODERN" UITreeRow="-3"/>

<Row FeatureType="FEATURE_FOREST" Name="LOC_FEATURE_FOREST_NAME" RemoveTech="TECH_MINING" Removable="true" Forest="true"
	AddCivic="CIVIC_CONSERVATION" SightThroughModifier="1" DefenseModifier="3" MovementChange="1" Appeal="+1" AntiquityPriority="2"/>

<Row FeatureType="FEATURE_JUNGLE" Name="LOC_FEATURE_JUNGLE_NAME" RemoveTech="TECH_BRONZE_WORKING" Removable="true" Forest="true"
	SightThroughModifier="1" DefenseModifier="3" MovementChange="1" Appeal="-1" AntiquityPriority="5"/>

<Row UnitType="UNIT_BUILDER" BaseMoves="2" Cost="50" AdvisorType="ADVISOR_GENERIC" BaseSightRange="2" ZoneOfControl="false" Domain="DOMAIN_LAND"
	FormationClass="FORMATION_CLASS_CIVILIAN" Name="LOC_UNIT_BUILDER_NAME" Description="LOC_UNIT_BUILDER_DESCRIPTION" CanCapture="False"
	CostProgressionModel="COST_PROGRESSION_PREVIOUS_COPIES" CostProgressionParam1="4" PurchaseYield="YIELD_GOLD" BuildCharges="3"/>

<Row UnitType="UNIT_NATURALIST" BaseMoves="4" Cost="800" BaseSightRange="3" ZoneOfControl="false" Domain="DOMAIN_LAND"
	FormationClass="FORMATION_CLASS_CIVILIAN" Name="LOC_UNIT_NATURALIST_NAME" Description="LOC_UNIT_NATURALIST_DESCRIPTION" CanCapture="False"
	CostProgressionModel="COST_PROGRESSION_PREVIOUS_COPIES" CostProgressionParam1="100" PurchaseYield="YIELD_FAITH"
	PseudoYieldType="PSEUDOYIELD_UNIT_RELIGIOUS" PrereqCivic="CIVIC_CONSERVATION" MustPurchase="TRUE" CanRetreatWhenCaptured="True" ParkCharges="1"/>

<Row UnitType="UNIT_MILITARY_ENGINEER" BaseMoves="2" Cost="170" AdvisorType="ADVISOR_CONQUEST" BaseSightRange="2" ZoneOfControl="false"
	Domain="DOMAIN_LAND" FormationClass="FORMATION_CLASS_SUPPORT" Name="LOC_UNIT_MILITARY_ENGINEER_NAME" Description="LOC_UNIT_MILITARY_ENGINEER_DESCRIPTION"
	PurchaseYield="YIELD_GOLD" BuildCharges="2" PromotionClass="PROMOTION_CLASS_SUPPORT" Maintenance="4" PrereqTech="TECH_MILITARY_ENGINEERING"/>

<Row OperationType="UNITOPERATION_PLANT_FOREST" VisibleInUI="true" HoldCycling="true" CategoryInUI="BUILD" Icon="ICON_UNITOPERATION_PLANT_FOREST"
	Description="LOC_UNITOPERATION_PLANT_FOREST_DESCRIPTION"/>

<Row OperationType="UNITOPERATION_REMOVE_FEATURE" VisibleInUI="true" HoldCycling="true" CategoryInUI="BUILD" Icon="ICON_UNITOPERATION_REMOVE_FEATURE"
	Description="LOC_UNITOPERATION_REMOVE_FEATURE_DESCRIPTION"/>
CategoryInUI="BUILD" and BuildCharges="3", BuildCharges="2". BuildCharges are being treated differently from ParkCharges. They are tied to the "BUILD" category for misc UnitOperations like Plant Forest that are spec'd as "BUILD" for CategoryInUI. The game's UnitPanel UI lua file then determines if the button or ability for the operation can appear for the human player. And for the AI this seems to be directly controlled from the dll and the AI code therein so far as I can figure from chasing stuff in the lua files. (Lua files for the UI we the players see often does not contain anything for the AI, since they don't need UI panels to make decisions and send commands to the rest of the game).

----------------------------------------------------
Just wondering, but do you know if its possible to make it so a new custom unit can build the exact same things a a builder can without changing the games files? I'm just wondering because other wise (Unless I'm wrong about it.) you could not upload it as a mod to the Steam Workshop.

Also, my apologies for asking a question on this thread that is only semi-related.
It isn't clear whether the <Improvement_ValidBuildUnits> table will allow more than one unit to build the same improvement. But from reading the definition and requirements of the table it looks like you could do something like
Code:
<GameInfo>
	<Improvement_ValidBuildUnits>
		<Row ImprovementType="IMPROVEMENT_FARM" UnitType="UNIT_SOMETHING_ELSE"/>
		<Row ImprovementType="IMPROVEMENT_MINE" UnitType="UNIT_SOMETHING_ELSE"/>
		<Row ImprovementType="IMPROVEMENT_QUARRY" UnitType="UNIT_SOMETHING_ELSE"/>
		<Row ImprovementType="IMPROVEMENT_FISHING_BOATS" UnitType="UNIT_SOMETHING_ELSE"/>
		<Row ImprovementType="IMPROVEMENT_PASTURE" UnitType="UNIT_SOMETHING_ELSE"/>
		<Row ImprovementType="IMPROVEMENT_PLANTATION" UnitType="UNIT_SOMETHING_ELSE"/>
		<Row ImprovementType="IMPROVEMENT_CAMP" UnitType="UNIT_SOMETHING_ELSE"/>
		<Row ImprovementType="IMPROVEMENT_LUMBER_MILL" UnitType="UNIT_SOMETHING_ELSE"/>
		<Row ImprovementType="IMPROVEMENT_OIL_WELL" UnitType="UNIT_SOMETHING_ELSE"/>
		<Row ImprovementType="IMPROVEMENT_OFFSHORE_OIL_RIG" UnitType="UNIT_SOMETHING_ELSE"/>
		<Row ImprovementType="IMPROVEMENT_BEACH_RESORT" UnitType="UNIT_SOMETHING_ELSE"/>
	</Improvement_ValidBuildUnits>
</GameInfo>
As a general rule you would probably not want to allow a customized unit specific to a new civilization to be able to construct the improvements that are meant to be only for China, or only for Egypt.
 
It isn't clear whether the <Improvement_ValidBuildUnits> table will allow more than one unit to build the same improvement. But from reading the definition and requirements of the table it looks like you could do something like
Code:
<GameInfo>
<Improvement_ValidBuildUnits>
<Row ImprovementType="IMPROVEMENT_FARM" UnitType="UNIT_SOMETHING_ELSE"/>
<Row ImprovementType="IMPROVEMENT_MINE" UnitType="UNIT_SOMETHING_ELSE"/>
<Row ImprovementType="IMPROVEMENT_QUARRY" UnitType="UNIT_SOMETHING_ELSE"/>
<Row ImprovementType="IMPROVEMENT_FISHING_BOATS" UnitType="UNIT_SOMETHING_ELSE"/>
<Row ImprovementType="IMPROVEMENT_PASTURE" UnitType="UNIT_SOMETHING_ELSE"/>
<Row ImprovementType="IMPROVEMENT_PLANTATION" UnitType="UNIT_SOMETHING_ELSE"/>
<Row ImprovementType="IMPROVEMENT_CAMP" UnitType="UNIT_SOMETHING_ELSE"/>
<Row ImprovementType="IMPROVEMENT_LUMBER_MILL" UnitType="UNIT_SOMETHING_ELSE"/>
<Row ImprovementType="IMPROVEMENT_OIL_WELL" UnitType="UNIT_SOMETHING_ELSE"/>
<Row ImprovementType="IMPROVEMENT_OFFSHORE_OIL_RIG" UnitType="UNIT_SOMETHING_ELSE"/>
<Row ImprovementType="IMPROVEMENT_BEACH_RESORT" UnitType="UNIT_SOMETHING_ELSE"/>
</Improvement_ValidBuildUnits>
</GameInfo>
As a general rule you would probably not want to allow a customized unit specific to a new civilization to be able to construct the improvements that are meant to be only for China, or only for Egypt.

Okay, thank you for the reply.
 
In-Game Valid tables and their valid columns are defined here C:\Program Files (x86)\Steam\SteamApps\common\Sid Meier's Civilization VI\Base\Assets\Gameplay\Data\Schema/01_GameplaySchema.sql

Front-End (ie, game set-up menus) valid tables and their valid columns are defined here C:\Program Files (x86)\Steam\SteamApps\common\Sid Meier's Civilization VI\Base\Assets\Configuration\Data\Schema/. There are two files in this folder which are of interest in knowing what is valid in pre-game menus and in other pre-game stuff, such as items to display for a custom civilization.

-----------------------------------------

You cannot try to use a table that is invalid for its context (ie, trying to use a table defined for "FrontEnd" in the "In-Game" side or vice versa), nor can you invent new table names without first defining them, and creating a method to implement the effects of the new table such as an lua script.
 
So could <Improvement_ValidBuildUnits> become a trait of a civ? Say allows a certain civ's galleys to have 2 build charges and build fishing boat improvement?

Yes, you can see roman legion for example.
 
Back
Top Bottom