Trigger when units are present on map?


  • Admin

    I have a question about how to set off a trigger when a player own 5 units of a specific type.

    I can’t get the condition to work. If it was only 1 unit allowed, it works well, but how should the condition look like if it is 5 units are on the map?

    Player is “Humans” must have the ability to buy “Workboat” removed when Humans have 5 units of “Workboat”. The Workboats can sail around and can be anywhere on the map.

    This is my not working trigger that is not triggering:

        <attachment name="conditionAttachment_Humans_have_5_Workboats" attachTo="Humans" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
            <option name="directPresenceTerritories" value="map" count="5"/>
            <option name="unitPresence" value="Workboat" count="1"/>
        </attachment>
    
        <attachment name="triggerAttachment_Humans_can_no_longer_buy_Workboats" attachTo="Humans" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
            <option name="conditions" value="conditionAttachment_Humans_have_5_Workboats"/>
            <option name="productionRule" value="production_Humans:-buyWorkboat"/>
            <option name="when" value="before:HumansPurchase"/>
        </attachment>

  • Moderators Admin

    @Frostion You may want to make a feature request out of this, because it is simply not possible to look at units in the whole map, only per territory.

    What that condition is doing, is that you have at least 5 territories with at least 1 "Workboat" each.

    Theorically, you could hack it by making a complex set o triggers in which you test all the possible combinations of 1 to 5 units per territory so to assure you have at least 5 units in total. Basically, an OR codition related to have 5+ territories with 1 each, or 1+ territories with 5 each, and so on all possible combinations in between.


  • Admin

    Or you are ok with forcing only 1 workboat per territory (like classic AA guns) and then just count the territories like you are.


  • Admin

    Hmmm disappointing. I will have to rethink this concept 🙂


  • Admin

    @Frostion Yeah, as @Cernel pointed out not a bad feature request.


  • Moderators Admin

    @redrum said in Trigger when units are present on map?:

    @Frostion Yeah, as @Cernel pointed out not a bad feature request.

    @Frostion Not a wonderful solution but, for now, one might do this with a limited amount of coding by using "eaches" on the conditions, then having as many same conditions assigned to the trigger as the number of units specified in the conditions themselves, then a condition type equal to the minimum number you want (in your case, 5), if you are following me. However, I'm not sure if it would work, as eaches are normally used to make the trigger firing that many times.

    EDIT: Nevermind, checked pos2 it says that eaches are just 1s, condition wise.


Log in to reply
 

42186
2038
2282
Who's Online
Visitors Today