[RESOLVED] Granting UAs and UUs to additional civilizations

maconnolly

Warlord
Joined
Jun 3, 2019
Messages
210
This is a fairly simple question - is it possible to grant an existing Unique Ability and/or a Unique Unit to additional civilizations?

As a simple example, could I grant the Aztec Eagle Warrior to, say, England?

I thought I would be able to do this, simply by assigning the relevant trait as a Civilization Trait (or, indeed, a Leader Trait).

The same thinking applies for Unique Abilities.

However, in testing, simply assigning the traits does not have the desired effect. There are no errors to suggest anything hasn't been executed - but to use my favoured, simple example, England does not start the game with the Eagle Warrior.

I know there is not a limit on UUs applied to a civilization - but is there a hard-coded limit of the number of civilizations to which a single UU can be applied? If not hard-coded, is this exposed in the code and, if so, where? For units, I thought all of the 'replacement' logic was built into the unit, hence the idea that granting the trait could make this nice and simple.

Same questions for Unique Abilities, too, essentially. I thought you could use traits in a modular way to grant different civilizations existing abilities.

Edit: I should add, I understand that the workaround for UAs would be to create a new entry in the Traits table and link that new trait to the same ModifierId under the TraitModifiers table as the original.

I am less clear as to whether the TraitType variable in the Units table can hold multiple references simultaneously (not tested yet), as if it cannot, I see that the workaround would require making a complete copy of the unit itself in order to apply the second TraitType that is then linked to the second civilization (and, in the case of a scenario where you want to link one unit to, say, five different civilizations as a 'partially-common unique', you need to do this once for each civ).
 
Last edited:
I have seen a few mods on the steam workshop that grant all uniques to certain civilizations (Brazil/Germany). Took a quick look at their code and all they seem to do is assign the existing civilization treats or leader traits as you said. For a few select UAs it looks like they had to add some TraitModifiers.

https://steamcommunity.com/sharedfiles/filedetails/?id=870835553
https://steamcommunity.com/sharedfiles/filedetails/?id=1217799314

If you start getting into unique buildings and improvements there is more involved. In some cases in the art files the UBs or UIs were specified to only be valid for certain civilizations, and from what I read a red exclamation mark can appear in place of the improvement or building. The Brazil All Uniques mod has tried to fix some of those issues.

I have looked into this because I am working on a mod that unlocks UUs, UBs, UIs for other civilizations under certain circumstances using LUA. I have to do things a different way because you cannot add new traits using LUA, and I don't want them always unlocked so I can't do it in SQL/XML.
 
I have seen a few mods on the steam workshop that grant all uniques to certain civilizations (Brazil/Germany). Took a quick look at their code and all they seem to do is assign the existing civilization treats or leader traits as you said. For a few select UAs it looks like they had to add some TraitModifiers.

https://steamcommunity.com/sharedfiles/filedetails/?id=870835553
https://steamcommunity.com/sharedfiles/filedetails/?id=1217799314

That sounds pretty decisive and clear - and fits with what I thought should happen, to be honest. I'm going to take another look at the code I've had this implemented in, there is no doubt either an issue with the logic or a perception problem in-game. I feel pretty lazy only mentioning this now - but it's actually someone else's mod, with which I've been helping, so I'm one-step-removed from it a lot of the time. But, I had been sent the files and had a quick glance and it appeared to be sound.

I'll stop being lazy, build it, run it and test it properly myself before going any further.
 
I've created some custom buildings in my private mods where both Rome and England have the same Replacement Building as a unique building. Attaching the trait for the unique building to the civilization works fine for me so there must be an error in the code or the logic of the code you are using.

I am not however creating buildings with any 3d models so I don't have to worry about giant red exclamation points on the map.
Code:
	<Types>
		<Row Type="BUILDING_BATHHOUSE" Kind="KIND_BUILDING"/>
		<Row Type="TRAIT_CIVILIZATION_BUILDING_ROMAN_THERMAE" Kind="KIND_TRAIT" />
		<Row Type="BUILDING_ROMAN_THERMAE" Kind="KIND_BUILDING"/>
	</Types>
	<Traits>
		<Row TraitType="TRAIT_CIVILIZATION_BUILDING_ROMAN_THERMAE" Name="LOC_TRAIT_CIVILIZATION_BUILDING_ROMAN_THERMAE_NAME"/>
	</Traits>
	<CivilizationTraits>
		<Row CivilizationType="CIVILIZATION_ROME" TraitType="TRAIT_CIVILIZATION_BUILDING_ROMAN_THERMAE"/>
		<Row CivilizationType="CIVILIZATION_ENGLAND" TraitType="TRAIT_CIVILIZATION_BUILDING_ROMAN_THERMAE"/>
	</CivilizationTraits>
	<BuildingReplaces>
		<Row CivUniqueBuildingType="BUILDING_ROMAN_THERMAE" ReplacesBuildingType="BUILDING_BATHHOUSE"/>
	</BuildingReplaces>
	<Buildings>
		<Row BuildingType="BUILDING_BATHHOUSE" Name="LOC_BUILDING_BATHHOUSE_NAME" PrereqTech="TECH_ENGINEERING"
			PrereqDistrict="DISTRICT_AQUEDUCT" PurchaseYield="YIELD_GOLD" Cost="155" AdvisorType="ADVISOR_CULTURE" Entertainment="2" Maintenance="2"/>
		<Row BuildingType="BUILDING_ROMAN_THERMAE" Name="LOC_BUILDING_ROMAN_THERMAE_NAME" PrereqTech="TECH_ENGINEERING"
			Description="LOC_BUILDING_ROMAN_THERMAE_DESCRIPTION"
			PrereqDistrict="DISTRICT_AQUEDUCT" PurchaseYield="YIELD_GOLD" Cost="115" AdvisorType="ADVISOR_CULTURE" Entertainment="3" Maintenance="1"
			TraitType="TRAIT_CIVILIZATION_BUILDING_ROMAN_THERMAE"/>
	</Buildings>
And then here I'm piling on some more OP stuff just for the funs and the experimentation practicum
Code:
		<!-- this should not end up applying to LEADER_ELEANOR_FRANCE since CIVILIZATION_ENGLAND is also required for the Thermae -->
	<Modifiers>
		<Row ModifierId="ELEANOR_THERMAE_FOOD" ModifierType="MODIFIER_PLAYER_CITIES_ADJUST_BUILDING_YIELD_CHANGE" Permanent="true" />
	</Modifiers>
	<ModifierArguments>
		<Row ModifierId="ELEANOR_THERMAE_FOOD" Name="Amount" Value="2" />
		<Row ModifierId="ELEANOR_THERMAE_FOOD" Name="BuildingType" Value="BUILDING_ROMAN_THERMAE" />
		<Row ModifierId="ELEANOR_THERMAE_FOOD" Name="YieldType" Value="YIELD_FOOD" />
	</ModifierArguments>
	<TraitModifiers>
		<Row TraitType="TRAIT_LEADER_ELEANOR_LOYALTY" ModifierId="ELEANOR_THERMAE_FOOD"/>
		<Row TraitType="TRAJANS_COLUMN_TRAIT" ModifierId="ELEANOR_THERMAE_FOOD"/>
	</TraitModifiers>
 
Thanks for the extra confirmation that this can be applied to buildings, too - it is, as I suspected, possible.

I should apologise for laziness in posting initially, really - as soon as I took a look at the files properly and tested it, I realised the mistake.

In this case, the person I'm helping is trying to re-use an existing leader to lead their civilization. Essentially, their feedback was "I'm able to select my civilization, but the things we tied to the Civilization as unique traits aren't working."

When I loaded the same mod, I noted that the civilization they were selecting was, in fact, the leader's original civilization. In plain English, they were selecting China, not CustomCiv, to lead. The fix was to make a duplicate entry into the Leaders table for the leader they wanted to use - essentially creating the same setup as for Eleanor.

With the civilization actually selected and being used, the re-used traits work exactly as expected.
 
HEY! that person with the mod is me!!! :cool:
Oh and I am getting an red exclamation point for the nubian pyramids ;)
 
It's because Nubian Pyramid is attached to CIVILIZATION_NUBIA in Landmarks.artfed here:
Code:
<Element class="AssetObjects..ArtDefReferenceValue">
                                        <m_ElementName text="CIVILIZATION_NUBIA"/>
                                        <m_RootCollectionName text="Civilization"/>
                                        <m_ArtDefPath text="Civilizations.artdef"/>
                                        <m_CollectionIsLocked>true</m_CollectionIsLocked>
                                        <m_TemplateName text="Civilizations"/>
                                        <m_ParamName text="Tag_Culture"/>
                                    </Element>
To work with anyone else You would have to replace that code with:
Code:
<Element class="AssetObjects..ArtDefReferenceValue">
                                        <m_ElementName text="DEFAULT"/>
                                        <m_RootCollectionName text="Culture"/>
                                        <m_ArtDefPath text="Cultures.artdef"/>
                                        <m_CollectionIsLocked>true</m_CollectionIsLocked>
                                        <m_TemplateName text=""/>
                                        <m_ParamName text="Tag_Culture"/>
                                    </Element>
Or create new improvement that references to Nubian Pyramid artdef in dep file then create landmarks.artdef and improvements.artdef for it. Basically coping sections from it but with the change of Tag_Culture.
 
Back
Top Bottom