Give and remove trigger added “unitProperty”?


  • Admin

    I need help with some triggering 😕

    I have a trigger (with conditions) that, when player “Trolls” owns the building/unit called “Dragon-Den” + there is no unit type "Dragon" on the map, then the Dragon-Den building spawns a Dragon for Trolls at the end of Trolls turn via createsUnitList.

    I also have a trigger (with conditions) that removes the Dragon spawning again as there should only be one Dragon unit on the map. So the Dragon-Den building must have its given unitProperty removed again (<option name="unitProperty" value="createsUnitsList" count="1:Dragon"/> must be set out of action)

    The problem is that the engine gives errors when I try to give the Dragon-Den...
    <option name="unitProperty" value="createsUnitsList" count="0:Dragon"/>
    I have also tried using -reset- instead of 0, but that also gives errors in the console. I dont understand the -reset- feature, but i tried it anyway.

    How can I remove something like…
    <option name="unitProperty" value="createsUnitsList" count="1:Dragon"/>
    … from a unit after it havs been added to the unit's properties?

    Here is the code I have been using:

            <attachment name="conditionAttachment_There_is_no_Dragon_on_the_map" attachTo="Nature" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
                <option name="directPresenceTerritories" value="map" count="1"/>
                <option name="unitPresence" value="Dragon" count="1"/>
                <option name="invert" value="true"/>
                <option name="players" value="Humans:Dwarves:Gnomes:Night-Elves:Orcs:Tauren:Undead:Trolls"/>
            </attachment>
    
            <attachment name="conditionAttachment_Trolls_control_the_Dragon-Den" attachTo="Trolls" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
                <option name="directPresenceTerritories" value="map" count="1"/>
                <option name="unitPresence" value="Dragon-Den" count="1"/>
            </attachment>
    
            <attachment name="triggerAttachment_The_Dragon-Den_spawns_a_dragon_for_the_Trolls" attachTo="Trolls" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                <option name="conditions" value="conditionAttachment_Trolls_control_the_Dragon-Den:conditionAttachment_There_is_no_Dragon_on_the_map"/>
                <option name="unitType" value="Dragon-Den"/>
                <option name="unitProperty" value="createsUnitsList" count="1:Dragon"/>
                <option name="when" value="before:TrollsEndTurn"/>
            </attachment>
    
    
    
    
            <attachment name="conditionAttachment_There_is_a_Dragon_on_the_map" attachTo="Nature" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
                <option name="directPresenceTerritories" value="map" count="1"/>
                <option name="unitPresence" value="Dragon" count="1"/>
                <option name="players" value="Humans:Dwarves:Gnomes:Night-Elves:Orcs:Tauren:Undead:Trolls"/>
            </attachment>
    
            <attachment name="triggerAttachment_The_Dragon-Den_already_has_a_Dragon" attachTo="Nature" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                <option name="conditions" value="conditionAttachment_There_is_a_Dragon_on_the_map"/>
                <option name="unitType" value="Dragon-Den"/>
                <option name="unitProperty" value="createsUnitsList" count="-reset-:Dragon"/>
                <option name="when" value="before:HumansEndTurn"/>
                <option name="when" value="before:DwarvesEndTurn"/>
                <option name="when" value="before:GnomesEndTurn"/>
                <option name="when" value="before:Night-ElvesEndTurn"/>
                <option name="when" value="before:OrcsEndTurn"/>
                <option name="when" value="before:TaurenEndTurn"/>
                <option name="when" value="before:UndeadEndTurn"/>
                <option name="when" value="before:TrollsEndTurn"/>
            </attachment>
    
    

  • Admin

    @Frostion said in Give and remove trigger added “unitProperty”?:

    <option name="unitProperty" value="createsUnitsList" count="-reset-:Dragon"/>

    I think you should be able to just use -reset-. So something like this:

    <option name="unitProperty" value="createsUnitsList" count="-reset-"/>
    

    -reset- is used to clear any property that is actually a list of things. So createsUnitsList is a list of unit types with quantity. You could have a building generate multiple different types of units with different quantities. When you use -reset- it clears everything in that list. In your case, you only would have a single item in the list "1:Dragon" which would then be cleared.

    But in theory you could have something like this in the createsUnitsList:
    1:Dragon
    3:DragonGuardians
    10:DragonEggs

    And you could clear all of those using -reset-.

    For reference this list outlines which properties are lists (need reset) and which are single instance and would just override: https://github.com/triplea-maps/the_pact_of_steel/blob/master/map/games/pact_of_steel_2.xml#L3262


  • Admin

    Thank you @redrum for the explanation, and the "-reset-" worked 🙂


Log in to reply
 

24061
1333
1545
Who's Online
Visitors Today