Making a unit ignore borders

Daenvil

Chieftain
Joined
Nov 8, 2017
Messages
4
Location
Galiza
Edit: I solved it, it was a silly mistake in the code.

I am new to modding and I'm stuck in this. It should be easy, I just want my unique unit (which replaces the settler) to be able to enter any territory, just like missionaries do. I tried to copy the code in the game files and after several tries I have this:

Code:
<GameData>
    <Types>
        <Row Type="UNIT_GZ_MIGRANT" Kind="KIND_UNIT"/>
        <Row Type="ABILITY_GZ_MIGRANT_ENTER_FOREIGN_LANDS" Kind="KIND_ABILITY"/>
    </Types>
    <TypeTags>
        <Row Type="UNIT_GZ_MIGRANT" Tag="CLASS_LANDCIVILIAN"/>
        <Row Type="UNIT_GZ_MIGRANT" Tag="CLASS_GZ_MIGRANT"/>
        <Row Type="ABILITY_GZ_MIGRANT_ENTER_FOREIGN_LANDS" Tag="CLASS_GZ_MIGRANT"/>
    </TypeTags>
    <Tags>
        <Row Tag="CLASS_GZ_MIGRANT" Vocabulary="ABILITY_CLASS"/>
    </Tags>
    <UnitAiInfos>
        <Row UnitType="UNIT_GZ_MIGRANT" AiType="UNITAI_SETTLE"/>
        <Row UnitType="UNIT_GZ_MIGRANT" AiType="UNITTYPE_CIVILIAN"/>
    </UnitAiInfos>
    <UnitCaptures>
        <Row CapturedUnitType="UNIT_GZ_MIGRANT" BecomesUnitType="UNIT_BUILDER"/>
    </UnitCaptures>
    <UnitAbilities>
        <Row UnitAbilityType="ABILITY_GZ_MIGRANT_ENTER_FOREIGN_LANDS" Name="LOC_ABILITY_ARCHAEOLOGIST_ENTER_FOREIGN_LANDS_NAME" Description="LOC_ABILITY_ARCHAEOLOGIST_ENTER_FOREIGN_LANDS_DESCRIPTION" Inactive="true"/>
    </UnitAbilities>
    <UnitAbilityModifiers>
        <Row>
            <UnitAbilityType>ABILITY_GZ_MIGRANT_ENTER_FOREIGN_LANDS</UnitAbilityType>
            <ModifierId>GZ_ENTER_FOREIGN_LANDS</ModifierId>
        </Row>
    </UnitAbilityModifiers>
    <Modifiers>
        <Row>
            <ModifierId>GZ_ENTER_FOREIGN_LANDS</ModifierId>
            <ModifierType>MODIFIER_PLAYER_UNIT_ADJUST_ENTER_FOREIGN_LANDS</ModifierType>
        </Row>
    </Modifiers>
    <ModifierArguments>
        <Row>
            <ModifierId>GZ_ENTER_FOREIGN_LANDS</ModifierId>
            <Name>Enter</Name>
            <Value>true</Value>
        </Row>
    </ModifierArguments>
    <ModifierStrings>
        <Row ModifierId="GZ_ENTER_FOREIGN_LANDS" Context="Preview" Text="LOC_ABILITY_ENTER_FOREIGN_LANDS_MODIFIER_DESCRIPTION"/>
    </ModifierStrings>
    <Units>
        <Row UnitType="UNIT_GZ_MIGRANT" BaseMoves="4" Cost="80" AdvisorType="ADVISOR_GENERIC" BaseSightRange="3" ZoneOfControl="false" Domain="DOMAIN_LAND" FormationClass="FORMATION_CLASS_CIVILIAN" FoundCity="true" PopulationCost="1" PrereqPopulation="2" Name="LOC_UNIT_GZ_MIGRANT_NAME" Description="LOC_UNIT_GZ_MIGRANT_DESCRIPTION" CanCapture="False" CostProgressionModel="COST_PROGRESSION_PREVIOUS_COPIES" CostProgressionParam1="30" PurchaseYield="YIELD_GOLD" TraitType="TRAIT_CIVILIZATION_GZ_MIGRANT" PseudoYieldType="PSEUDOYIELD_UNIT_SETTLER"/>
    </Units>
    <UnitReplaces>
        <Row CivUniqueUnitType="UNIT_GZ_MIGRANT" ReplacesUnitType="UNIT_SETTLER"/>
    </UnitReplaces>
</GameData>
 
Last edited:
Nice! any idea if this could work with any unit type / ai type?

EDIT: kind of a stupid question turns out. It looks like using the type tags, we can give any unit class this ability.

But I do have a question for you. Could your code simply be this? (under UnitAbilityModifiers, just set the modifier ID to "MOD_ENTER_FOREIGN_LANDS", and let the base code handle the rest from there?)

Code:
<GameData>
   <Types>
        <Row Type="UNIT_GZ_MIGRANT" Kind="KIND_UNIT"/>
        <Row Type="ABILITY_GZ_MIGRANT_ENTER_FOREIGN_LANDS" Kind="KIND_ABILITY"/>
    </Types>
    <TypeTags>
        <Row Type="UNIT_GZ_MIGRANT" Tag="CLASS_LANDCIVILIAN"/>
        <Row Type="UNIT_GZ_MIGRANT" Tag="CLASS_GZ_MIGRANT"/>
        <Row Type="ABILITY_GZ_MIGRANT_ENTER_FOREIGN_LANDS" Tag="CLASS_GZ_MIGRANT"/>
    </TypeTags>
    <Tags>
        <Row Tag="CLASS_GZ_MIGRANT" Vocabulary="ABILITY_CLASS"/>
    </Tags>
    <UnitAiInfos>
        <Row UnitType="UNIT_GZ_MIGRANT" AiType="UNITAI_SETTLE"/>
        <Row UnitType="UNIT_GZ_MIGRANT" AiType="UNITTYPE_CIVILIAN"/>
    </UnitAiInfos>
    <UnitCaptures>
        <Row CapturedUnitType="UNIT_GZ_MIGRANT" BecomesUnitType="UNIT_BUILDER"/>
    </UnitCaptures>
    <UnitAbilities>
        <Row UnitAbilityType="ABILITY_GZ_MIGRANT_ENTER_FOREIGN_LANDS" Name="LOC_ABILITY_ARCHAEOLOGIST_ENTER_FOREIGN_LANDS_NAME" Description="LOC_ABILITY_ARCHAEOLOGIST_ENTER_FOREIGN_LANDS_DESCRIPTION" Inactive="true"/>
    </UnitAbilities>
    <UnitAbilityModifiers>
        <Row>
            <UnitAbilityType>ABILITY_GZ_MIGRANT_ENTER_FOREIGN_LANDS</UnitAbilityType>
            <ModifierId>MOD_ENTER_FOREIGN_LANDS</ModifierId>
        </Row>
    </UnitAbilityModifiers>
            [snip]
    <Units>
        <Row UnitType="UNIT_GZ_MIGRANT" BaseMoves="4" Cost="80" AdvisorType="ADVISOR_GENERIC" BaseSightRange="3" ZoneOfControl="false" Domain="DOMAIN_LAND" FormationClass="FORMATION_CLASS_CIVILIAN" FoundCity="true" PopulationCost="1" PrereqPopulation="2" Name="LOC_UNIT_GZ_MIGRANT_NAME" Description="LOC_UNIT_GZ_MIGRANT_DESCRIPTION" CanCapture="False" CostProgressionModel="COST_PROGRESSION_PREVIOUS_COPIES" CostProgressionParam1="30" PurchaseYield="YIELD_GOLD" TraitType="TRAIT_CIVILIZATION_GZ_MIGRANT" PseudoYieldType="PSEUDOYIELD_UNIT_SETTLER"/>
    </Units>
    <UnitReplaces>
        <Row CivUniqueUnitType="UNIT_GZ_MIGRANT" ReplacesUnitType="UNIT_SETTLER"/>
    </UnitReplaces>
</GameData>
 
Last edited:
Sorry to resuscitate an old thread but I've been trying to do a similar thing and encountered issues as it "half" works. I can enter ennemy territory, but next turn if I move inside ennemy territory I have the "Do you want to declare war?" dialog popping. :sad:

Code:
<?xml version="1.0" encoding="utf-8"?>
<GameData>
   
    <!-- Ignore borders -->
    <Types>
        <Row Type="ABILITY_IGNORE_BORDERS" Kind="KIND_ABILITY"/>
    </Types>
    <Tags>
        <Row Tag="CLASS_IGNOREBORDERS" Vocabulary="ABILITY_CLASS"/>
    </Tags>
    <TypeTags>
        <Row Type="ABILITY_IGNORE_BORDERS" Tag="CLASS_IGNOREBORDERS"/>
    </TypeTags>
    <UnitAbilities>
        <Row UnitAbilityType="ABILITY_IGNORE_BORDERS" Name="LOC_IGNORE_BORDERS_NAME" Description="LOC_IGNORE_BORDERS_DESCRIPTION"/>
    </UnitAbilities>
    <UnitAbilityModifiers>
        <Row>
            <UnitAbilityType>ABILITY_IGNORE_BORDERS</UnitAbilityType>
            <ModifierId>MOD_ENTER_FOREIGN_LANDS</ModifierId>
        </Row>
    </UnitAbilityModifiers>

    <!-- Walker -->
    <Types>
        <Row Type="UNIT_WALKER" Kind="KIND_UNIT" />
    </Types>
   
    <TypeTags>
        <Row Type="UNIT_WALKER" Tag="CLASS_RECON"/>
        <Row Type="UNIT_WALKER" Tag="CLASS_REVEAL_STEALTH"/>
        <Row Type="UNIT_WALKER" Tag="CLASS_IGNOREBORDERS"/>
    </TypeTags>

    <UnitAiInfos>
        <!-- Melee-->
        <Row UnitType="UNIT_WALKER" AiType="UNITAI_EXPLORE"/>
        <Row UnitType="UNIT_WALKER" AiType="UNITTYPE_LAND_COMBAT"/>
    </UnitAiInfos>
   
    <UnitReplaces>
        <Row CivUniqueUnitType="UNIT_WALKER" ReplacesUnitType="UNIT_SCOUT"/>
    </UnitReplaces>

    <UnitUpgrades>
        <Row Unit="UNIT_WALKER" UpgradeUnit="UNIT_RANGER"/>
    </UnitUpgrades>

    <Units>
        <Row 
            UnitType="UNIT_WALKER" 
            Cost="30" BaseMoves="3" 
            BaseSightRange="2" 
            ZoneOfControl="true" 
            Domain="DOMAIN_LAND" 
            Combat="10" 
            FormationClass="FORMATION_CLASS_LAND_COMBAT"
            PromotionClass="PROMOTION_CLASS_RECON" 
            AdvisorType="ADVISOR_GENERIC" 
            Name="LOC_UNIT_WALKER_NAME" 
            Description="LOC_UNIT_WALKER_DESCRIPTION" 
            PurchaseYield="YIELD_GOLD" 
            PseudoYieldType="PSEUDOYIELD_UNIT_EXPLORER"
            TraitType="TRAIT_CIVILIZATION_UNIT_WALKER"
        />
    </Units>
       
</GameData>
 
Top Bottom