[Vanilla] Adding a Unique Unit.

Joined
Jan 10, 2019
Messages
2,536
In addition to make unit itself manifest at Units.xml. Do I need to create Civ.xml to tie a unit with specific civ?
What does this string actually do? Does it ties UNIT_ROMAN_LEGION With civilization Rome?
Code:
<CivilizationTraits>
....
        <Row CivilizationType="CIVILIZATION_ROME" TraitType="TRAIT_CIVILIZATION_UNIT_ROMAN_LEGION"/>
...
</CivilizationTraits>

For example. Creating Legion Spearmen as Anticavalry and tie this unit with Rome using the same technology.
 
if you have it, the babylon dlc is a classic example of how to add a unit for a civ, sabuum kittibum or whatever
 
<?xml version="1.0" encoding="utf-8"?>
<GameData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="DataSchema.xsd">

<!-- Unit Definition -->
<Units>
<Row>
<UnitType>UNIT_LEGION_SPEARMAN</UnitType>
<Name>LOC_UNIT_LEGION_SPEARMAN_NAME</Name>
<Description>LOC_UNIT_LEGION_SPEARMAN_DESCRIPTION</Description>
<Domain>DOMAIN_LAND</Domain>
<BaseMoves>2</BaseMoves>
<Cost>100</Cost>
<AdvisorType>ADVISOR_CONQUEST</AdvisorType>
<PromotionClass>PROMOTION_CLASS_ANTI_CAVALRY</PromotionClass> <!-- Anti-cavalry class -->
<Maintenance>2</Maintenance>
<Combat>35</Combat>
<PrereqTech>TECH_IRON_WORKING</PrereqTech> <!-- Requires Iron Working -->
<ObsoleteTech>TECH_CIVIL_ENGINEERING</ObsoleteTech> <!-- Obsoletes with Civil Engineering -->
<FormationClass>FORMATION_CLASS_LAND_COMBAT</FormationClass>
<CanCapture>true</CanCapture>
<CanRetreatWhenDefeated>false</CanRetreatWhenDefeated>
<PrereqStrategicResource>RESOURCE_IRON</PrereqStrategicResource> <!-- Requires Iron -->
<UnitFlagIcon>ICON_UNIT_LEGION</UnitFlagIcon>
<UnitPortrait>PORTRAIT_UNIT_LEGION</UnitPortrait>
<Class>UNITCLASS_LEGION_SPEARMAN</Class>
<Specialized>true</Specialized>
</Row>
</Units>

<!-- Unit Upgrades -->
<UnitUpgrades>
<Row>
<Unit>UNIT_LEGION_SPEARMAN</Unit>
<PrereqUnit>UNIT_WARRIOR</PrereqUnit> <!-- Upgrades from Warrior -->
</Row>
</UnitUpgrades>

<!-- Unit Promotion Class -->
<UnitPromotionClasses>
<Row>
<PromotionClassType>PROMOTION_CLASS_ANTI_CAVALRY</PromotionClassType>
<UnitType>UNIT_LEGION_SPEARMAN</UnitType>
</Row>
</UnitPromotionClasses>

<!-- Fort Improvement Compatibility -->
<Improvement_ValidBuildUnits>
<Row>
<ImprovementType>IMPROVEMENT_FORT</ImprovementType> <!-- Reuse existing Fort improvement -->
<UnitType>UNIT_LEGION_SPEARMAN</UnitType>
</Row>
</Improvement_ValidBuildUnits>

<!-- Unit Abilities -->
<UnitAbilities>
<Row>
<UnitAbilityType>UNITABILITY_ANTI_CAVALRY_BONUS</UnitAbilityType>
<Name>LOC_UNITABILITY_ANTI_CAVALRY_BONUS_NAME</Name>
<Description>LOC_UNITABILITY_ANTI_CAVALRY_BONUS_DESCRIPTION</Description>
</Row>
</UnitAbilities>

<!-- Attach Abilities to Unit -->
<UnitAbilities_XP2>
<Row>
<UnitType>UNIT_LEGION_SPEARMAN</UnitType>
<UnitAbilityType>UNITABILITY_ANTI_CAVALRY_BONUS</UnitAbilityType>
</Row>
</UnitAbilities_XP2>

<!-- Prereq Tech and Resource for Fort -->
<Improvement_PrereqTechs>
<Row>
<ImprovementType>IMPROVEMENT_FORT</ImprovementType>
<TechType>TECH_ENGINEERING</TechType> <!-- Forts unlock with Engineering -->
</Row>
</Improvement_PrereqTechs>

<!-- Unit Strategic Resource Requirements -->
<UnitStrategicResourceRequirements>
<Row>
<UnitType>UNIT_LEGION_SPEARMAN</UnitType>
<ResourceType>RESOURCE_IRON</ResourceType> <!-- Requires Iron to build -->
<Amount>1</Amount>
</Row>
</UnitStrategicResourceRequirements>

<!-- Localization -->
<LocalizedText>
<!-- Unit Name -->
<Row Tag="LOC_UNIT_LEGION_SPEARMAN_NAME" Language="en_US">
<Text>Legion Spearman</Text>
</Row>
<!-- Unit Description -->
<Row Tag="LOC_UNIT_LEGION_SPEARMAN_DESCRIPTION" Language="en_US">
<Text>A Roman anti-cavalry unit that can construct forts and perform other Legionnaire duties.</Text>
</Row>
<!-- Ability Name -->
<Row Tag="LOC_UNITABILITY_ANTI_CAVALRY_BONUS_NAME" Language="en_US">
<Text>Anti-Cavalry Bonus</Text>
</Row>
<!-- Ability Description -->
<Row Tag="LOC_UNITABILITY_ANTI_CAVALRY_BONUS_DESCRIPTION" Language="en_US">
<Text>This unit has additional combat strength against cavalry units.</Text>
</Row>
</LocalizedText>

</GameData>
 
And do I have to override 'Civilizations.xml' ?

Tell me about this code. is it a coupling code that hook Roman Legion with Civilization Rome?

Code:
....
<Types>
<Row Type="TRAIT_CIVILIZATION_UNIT_ROMAN_LEGION" Kind=KIND_TRAIT />
</Types> 
....
<CivilizationTraits>
<Row CivilizationTraits="CIVILIZATION_ROME" TraitType="TRAIT_CIVILIZATION_UNIT_ROMAN_LEGION" />
</CivilizationTraits>
....

In addition to UNITS.XML , do I have to write this in addition?

Code:
....
<Types>
<Row Type="TRAIT_CIVILIZATION_UNIT_ROMAN_LEGION_SPEARMAN" Kind=KIND_TRAIT />
</Types> 
....
<Traits>
<Row TraitType="TRAIT_CIVILIZATION_UNIT_ROMAN_LEGION_SPEARMAN" Name="LOC_TRAIT_CIVILIZATION_UNIT_ROMAN_LEGION_SPEARMAN_NAME" />
</Traits>
...
<CivilizationTraits>
<Row CivilizationTraits="CIVILIZATION_ROME" TraitType="TRAIT_CIVILIZATION_UNIT_ROMAN_LEGION_SPEARMAN" />
</CivilizationTraits>
 
Not recommended to override files, you open modbuddy create a new project, add those files you need (yes you are right on the additional file, you need it to assign to Rome), in properties updateDatabase in the frontend or in-game properties, and add your previous files. Then build and you got to go
 
Not recommended to override files, you open modbuddy create a new project, add those files you need (yes you are right on the additional file, you need it to assign to Rome), in properties updateDatabase in the frontend or in-game properties, and add your previous files. Then build and you got to go
I mean create a mod file for those syntaxes.
 
Top Bottom