How to make an improvement human-only?

NTR Unstoppable

Chieftain
Joined
Feb 8, 2024
Messages
5
Recently I made a mod that allows worker to build Tribal Village. Problem is, AI seems to build way too much Tribal Village that they won't build any other improvements. So how can I define the improvement to make Tribal Village Human-only or somehow lower the desire of AI building Tribal Village?

XML:
<GameData>
    <Improvements>
        <Update>
            <Where ImprovementType="IMPROVEMENT_GOODY_HUT"/>
            <Set CanBuildOutsideTerritory="true"/>
        </Update>
    </Improvements>
    <Improvement_ValidBuildUnits>
        <Row ImprovementType="IMPROVEMENT_GOODY_HUT" UnitType="UNIT_BUILDER"/>
    </Improvement_ValidBuildUnits>
</GameData>
 
If you restrict it to certain terrain types, the AI will build fewer of them. But that won't solve your core question of restricting the improvement to only human players.
Are you intending this for single player, multi-player, or both?
 
There is a requirement to check for whether a player is Human. Make a "unique" unit assigned to "no_player" and enable it via modifier with the aforementioned requirement for human players. The Nihang is an example for such modifier-based unit activation.

Alternatively, make a unique improvement, also unlocked like City State improvements just for human players, and replace it with a Goody Hut via lua script when built.

Yet another alternative: go the lua route entirely, adding a custom button to whichever unit you want and have clicking that button spawn the goodie hut. With the functionality triggered by a custom UI hook, there's no way for the AI to make use of it.
 
If you restrict it to certain terrain types, the AI will build fewer of them. But that won't solve your core question of restricting the improvement to only human players.
Are you intending this for single player, multi-player, or both?
Both...... I guess? I want this work both single or multiplayer or at least multiplayer for I was going to use this with my friend.
 
There is a requirement to check for whether a player is Human. Make a "unique" unit assigned to "no_player" and enable it via modifier with the aforementioned requirement for human players. The Nihang is an example for such modifier-based unit activation.

Alternatively, make a unique improvement, also unlocked like City State improvements just for human players, and replace it with a Goody Hut via lua script when built.

Yet another alternative: go the lua route entirely, adding a custom button to whichever unit you want and have clicking that button spawn the goodie hut. With the functionality triggered by a custom UI hook, there's no way for the AI to make use of it.
Thanks! I totally forgot about Nihang. I'll try to make Tribal Village can be built only by human-only Units first.
 
There is a requirement to check for whether a player is Human. Make a "unique" unit assigned to "no_player" and enable it via modifier with the aforementioned requirement for human players. The Nihang is an example for such modifier-based unit activation.

Alternatively, make a unique improvement, also unlocked like City State improvements just for human players, and replace it with a Goody Hut via lua script when built.

Yet another alternative: go the lua route entirely, adding a custom button to whichever unit you want and have clicking that button spawn the goodie hut. With the functionality triggered by a custom UI hook, there's no way for the AI to make use of it.
I've solved it by a better way...... I think? I don't know how to use SQL or LUA :(
XML:
    <Types>
        <Row Type="TRAIT_LEADER_HUMAN_WBTV" Kind="KIND_TRAIT"/>
        <Row Type="TRAIT_LEADER_NOBODY_WBTV" Kind="KIND_TRAIT"/>
    </Types>
    <Traits>
        <Row TraitType="TRAIT_LEADER_HUMAN_WBTV" InternalOnly="true"/>
        <Row TraitType="TRAIT_LEADER_NOBODY_WBTV" InternalOnly="true"/>
    </Traits>
    <LeaderTraits>
        <Row LeaderType="LEADER_DEFAULT" TraitType="TRAIT_LEADER_HUMAN_WBTV"/>
    </LeaderTraits>
    <TraitModifiers>
        <Row TraitType="TRAIT_LEADER_HUMAN_WBTV" ModifierId="WORKER_BUILDABLE_TRIBAL_VILLAGE"/>
    </TraitModifiers>
    <Modifiers>
        <Row>
            <ModifierId>WORKER_BUILDABLE_TRIBAL_VILLAGE</ModifierId>
            <ModifierType>MODIFIER_PLAYER_ADJUST_VALID_IMPROVEMENT</ModifierType>
            <OwnerRequirementSetId>PLAYER_IS_HUMAN</OwnerRequirementSetId>
        </Row>
    </Modifiers>
    <ModifierArguments>
        <Row>
            <ModifierId>WORKER_BUILDABLE_TRIBAL_VILLAGE</ModifierId>
            <Name>ImprovementType</Name>
            <Value>IMPROVEMENT_GOODY_HUT</Value>
        </Row>
    </ModifierArguments>
    <Improvements>
        <Update>
            <Where ImprovementType="IMPROVEMENT_GOODY_HUT"/>
            <Set CanBuildOutsideTerritory="true"/>
        </Update>
        <Update>
            <Where ImprovementType="IMPROVEMENT_GOODY_HUT"/>
            <Set TraitType="TRAIT_LEADER_NOBODY_WBTV"/>
        </Update>
    </Improvements>
    <Improvement_ValidBuildUnits>
        <Row ImprovementType="IMPROVEMENT_GOODY_HUT" UnitType="UNIT_BUILDER"/>
    </Improvement_ValidBuildUnits>
 
Top Bottom