Issue assigning abilities to a custom unit

ColdPR

Chieftain
Joined
Mar 17, 2017
Messages
6
Edit: Managed to resolve it somehow

I've been trying to create unique land units for Germany and Brazil since I dislike their naval uniques. I started to create a Landsknecht unit to replace the Pikeman for Germany. I had no trouble creating the unit and it appears in game and it works and everything is dandy except trying to give it abilities has resulted in me hitting a wall over and over and over trying to figure out what I'm doing wrong.

I'm hoping someone might be willing to lend another pair of eyes for the code to check if I'm just missing something silly in the syntax or something else. I've been referencing the Firaxis code for unit abilities and I even checked some other mods for the syntax and it seems like it's all correct but obviously I'm doing something wrong because neither ability functions on the unit.

<Types>
<Row Type="UNIT_LANDSKNECHT" Kind="KIND_UNIT" />
<Row Type="ABILITY_BONUS_VERSUS_CAVALRY" Kind="KIND_ABILITY"/>
<Row Type="ABILITY_CONSTANTHEAL" Kind="KIND_ABILITY"/>
</Types>

<Units>
<Row UnitType="UNIT_LANDSKNECHT" BaseMoves="3" Cost="1" AdvisorType="ADVISOR_CONQUEST" BaseSightRange="10" ZoneOfControl="true" Domain="DOMAIN_LAND" FormationClass="FORMATION_CLASS_LAND_COMBAT" Name="LOC_UNIT_LANDSKNECHT_NAME" Description="LOC_UNIT_LANDSKNECHT_DESCRIPTION" PurchaseYield="YIELD_GOLD" PromotionClass="PROMOTION_CLASS_ANTI_CAVALRY" Maintenance="3" Combat="41" MandatoryObsoleteTech="TECH_COMPOSITES" PrereqTech="TECH_POTTERY" TraitType="TRAIT_CIVILIZATION_UNIT_LANDSKNECHT"/>
</Units>

<Types>
<Row Type="TRAIT_CIVILIZATION_UNIT_LANDSKNECHT" Kind="KIND_TRAIT"/>
</Types>

<Traits>
<Row TraitType="TRAIT_CIVILIZATION_UNIT_LANDSKNECHT" Name="LOC_UNIT_LANDSKNECHT_NAME" Description="LOC_UNIT_LANDSKNECHT_DESCRIPTION"/>
</Traits>

<CivilizationTraits>
<Row CivilizationType="CIVILIZATION_GERMANY" TraitType="TRAIT_CIVILIZATION_UNIT_LANDSKNECHT"/>
</CivilizationTraits>

<UnitUpgrades>
<Row Unit="UNIT_LANDSKNECHT" UpgradeUnit="UNIT_AT_CREW"/>
</UnitUpgrades>

<UnitAiInfos>
<Row UnitType="UNIT_LANDSKNECHT" AiType="UNITAI_COMBAT"/>
<Row UnitType="UNIT_LANDSKNECHT" AiType="UNITAI_EXPLORE"/>
<Row UnitType="UNIT_LANDSKNECHT" AiType="UNITTYPE_MELEE"/>
<Row UnitType="UNIT_LANDSKNECHT" AiType="UNITTYPE_LAND_COMBAT"/>
</UnitAiInfos>

<UnitReplaces>
<Row CivUniqueUnitType="UNIT_LANDSKNECHT" ReplacesUnitType="UNIT_PIKEMAN"/>
</UnitReplaces>

<PlayerItems>
<Row Domain="StandardPlayers" CivilizationType="CIVILIZATION_GERMANY" LeaderType="LEADER_BARBAROSSA" Type="UNIT_LANDSKNECHT" Icon="ICON_UNIT_LANDSKNECHT" Name="LOC_UNIT_LANDSKNECHT_NAME" Description="LOC_UNIT_LANDSKNECHT_DESCRIPTION" SortIndex="1"/>
</PlayerItems>

<Tags>
<Row Tag="CLASS_LANDSKNECHT" Vocabulary="ABILITY_CLASS"/>
</Tags>

<TypeTags>
<Row Type="UNIT_LANDSKNECHT" Tag="CLASS_ANTI_CAVALRY"/>
<Row Type="UNIT_LANDSKNECHT" Tag="CLASS_LANDSKNECHT"/>
<Row Type="ABILITY_CONSTANTHEAL" Tag="CLASS_LANDSKNECHT"/>
<Row Type="ABILITY_BONUS_VERSUS_CAVALRY" Tag="CLASS_LANDSKNECHT"/>
</TypeTags>

<UnitAbilities>

<Row UnitAbilityType="ABILITY_CONSTANTHEAL" Name="LOC_ABILITY_CONSTANTHEAL_NAME" Description="LOC_ABILITY_CONSTANTHEAL_DESCRIPTION"/>

<Row UnitAbilityType="ABILITY_BONUS_VERSUS_CAVALRY" Name="LOC_ABILITY_BONUS_VERSUS_CAVALRY_NAME" Description="LOC_ABILITY_BONUS_VERSUS_CAVALRY_DESCRIPTION"/>

</UnitAbilities>

<UnitAbilityModifiers>
<Row>
<UnitAbilityType>ABILITY_CONSTANTHEAL</UnitAbilityType>
<ModifierId>CONSTANT_HEAL_EVERY_MOVE</ModifierId>
</Row>
<Row>
<UnitAbilityType>ABILITY_BONUS_VERSUS_CAVALRY</UnitAbilityType>
<ModifierId>GERMANPIKE_CAVALRY_BONUS</ModifierId>
</Row>
</UnitAbilityModifiers>

<Modifiers>
<Row>
<ModifierId>GERMANPIKE_CAVALRY_BONUS</ModifierId>
<ModifierType>MODIFIER_UNIT_ADJUST_COMBAT_STRENGTH</ModifierType> <SubjectRequirementSetId>GERMANPIKE_OPPONENT_IS_CAVALRY_REQUIREMENTS</SubjectRequirementSetId>
</Row>

<Row>
<ModifierId>CONSTANT_HEAL_EVERY_MOVE</ModifierId>
<ModifierType>MODIFIER_PLAYER_UNIT_GRANT_HEAL_AFTER_ACTION</ModifierType>
</Row>
</Modifiers>

<ModifierArguments>
<Row>
<ModifierId>GERMANPIKE_CAVALRY_BONUS</ModifierId>
<Name>Amount</Name>
<Value>13</Value>
</Row>
</ModifierArguments>

<RequirementSets>
<Row>
<RequirementSetId>GERMANPIKE_OPPONENT_IS_CAVALRY_REQUIREMENTS</RequirementSetId>
<RequirementSetType>REQUIREMENTSET_TEST_ANY</RequirementSetType>
</Row>
</RequirementSets>

<RequirementSetRequirements>
<Row>
<RequirementSetId>GERMANPIKE_OPPONENT_IS_CAVALRY_REQUIREMENTS</RequirementSetId>
<RequirementId>OPPONENT_IS_LIGHT_CAVALRY_UNIT_REQUIREMENTS</RequirementId>
</Row>
<Row>
<RequirementSetId>GERMANPIKE_OPPONENT_IS_CAVALRY_REQUIREMENTS</RequirementSetId>
<RequirementId>OPPONENT_IS_HEAVY_CAVALRY_UNIT_REQUIREMENTS</RequirementId>
</Row>
</RequirementSetRequirements>

<Requirements>
<Row>
<RequirementId>OPPONENT_IS_LIGHT_CAVALRY_UNIT_REQUIREMENTS</RequirementId>
<RequirementType>REQUIREMENT_OPPONENT_UNIT_TAG_MATCHES</RequirementType>
</Row>
<Row>
<RequirementId>OPPONENT_IS_HEAVY_CAVALRY_UNIT_REQUIREMENTS</RequirementId>
<RequirementType>REQUIREMENT_OPPONENT_UNIT_TAG_MATCHES</RequirementType>
</Row>
</Requirements>

<RequirementArguments>
<Row>
<RequirementId>OPPONENT_IS_LIGHT_CAVALRY_UNIT_REQUIREMENTS</RequirementId>
<Name>Tag</Name>
<Value>CLASS_LIGHT_CAVALRY</Value>
</Row>
<Row>
<RequirementId>OPPONENT_IS_HEAVY_CAVALRY_UNIT_REQUIREMENTS</RequirementId>
<Name>Tag</Name>
<Value>CLASS_HEAVY_CAVALRY</Value>
</Row>
</RequirementArguments>

<ModifierStrings>
<Row ModifierId="GERMANPIKE_CAVALRY_BONUS" Context="Preview" Text="LOC_UNIT_GERMANPIKE_CAVALRY_BONUS_PREVIEW"/>
</ModifierStrings>
 
Last edited:
The attempt being made is to give the unit I created two abilities. Ability one is supposed to just be the generic kind anti-cavalry combat bonus that Spearmen/Pikemen get but stronger. Ability two was supposed to allow the unit to heal every turn like the Mamluke unit even when actions are taken.
 
Don't you have database errors by chance? Did you check database.log? The below fragment:

<Row Type="TRAIT_CIVILIZATION_UNIT_LANDSKNECHT" Kind="KIND_TRAIT"/>

Should be before unit definition - you are using trait that has not yet been defined in Types.
 
Thanks for the tip I fixed that. Strangely enough I actually got the abilities working by doing something else though. I'm not really sure exactly what I did that fixed it because it was mostly just deleting and retyping but something I did finally made the abilities attach properly. I'll edit my original post to say this is resolved. Thanks for taking the time to help me out.
 
@ColdPR
So what did you do to get it working?
Update dont worry I also got it working.

I wanted to make the heal more powerful then the 10 it gives so I added this but it dont work, any clues why?

<UnitAbilityModifiers>
<Row>
<UnitAbilityType>ABILITY_CONSTANTHEAL</UnitAbilityType>
<ModifierId>CONSTANT_HEAL_EVERY_MOVE</ModifierId>
</Row>
</UnitAbilityModifiers>
<Modifiers>
<Row>
<ModifierId>CONSTANT_HEAL_EVERY_MOVE</ModifierId>
<ModifierType>MODIFIER_PLAYER_UNIT_GRANT_HEAL_AFTER_ACTION</ModifierType>
</Row>
</Modifiers>
<ModifierArguments>
<Row>
<ModifierId>CONSTANT_HEAL_EVERY_MOVE</ModifierId>
<Name>Amount</Name>
<Value>20</Value>
</Row>
</ModifierArguments>
 
Last edited:
@Infixo or @LeeS
Could you please take a look at the above code and let me know why this is not healing my unit 20 points per turn?
It is healing the standard 10.
Thanks.
 
I'm not finding any modifier that uses MODIFIER_PLAYER_UNIT_GRANT_HEAL_AFTER_ACTION and that also has modifier arguments to set the amount of healing. (I could be missing it I suppose from not correctly tracking-through the reference rabbit-hole-path the modifiers use)

I'm guessing it is using the standard heal amount from one of these global parameters
Code:
		<Row Name="COMBAT_HEAL_LAND_ENEMY" Value="5" />
		
		<Row Name="COMBAT_HEAL_LAND_FRIENDLY" Value="15" />
		
		<Row Name="COMBAT_HEAL_LAND_NEUTRAL" Value="10" />
		
		<Row Name="COMBAT_HEAL_NAVAL_ENEMY" Value="0" />
		
		<Row Name="COMBAT_HEAL_NAVAL_FRIENDLY" Value="20" />
		
		<Row Name="COMBAT_HEAL_NAVAL_NEUTRAL" Value="0" />
Most likely it is pulling the amount to heal every turn from COMBAT_HEAL_LAND_NEUTRAL or else the effect itself for EFFECT_GRANT_HEAL_AFTER_ACTION is simply hard-coded to "10".
 
Thanks LeeS I will try the <Row Name="COMBAT_HEAL_LAND_ENEMY" Value="5" /> route and see what happens. :)
 
Back
Top Bottom