Navigation

    TripleA Logo

    TripleA Forum

    • Register
    • Login
    • Search
    • TripleA Website
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Tags

    Can unitPresence count total number of units that belong to any of a few types?

    Map Making
    2
    5
    266
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Jason Green-Lowe
      Jason Green-Lowe last edited by

      I am trying to sometimes allow ships to pass through each others' sea zones, so that one Japanese destroyer can't block the entire US Pacific Fleet.

      However, I'm running into a problem with unitPresence -- it looks like if I use a list of more than one type of unit and have a count greater than 1, then the option will check to see if any one of those unit types has at least that many units in the same sea zone. For example, with

              <attachment foreach="$Players$^$SeaZones$" name="conditionAttachment_@Players@_No_Double_Naval_Obstacle_In_@SeaZones@" attachTo="@Players@" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
                <option name="enemyExclusionTerritories" value="@SeaZones@" count="1"/>
                <option name="unitPresence" value="carrier:battleship:cruiser:destroyer" count="2"/>
              </attachment>  
      

      the engine will check and see if there are at least 2 destroyers in the sea zone, and/or at least 2 cruisers in the sea zone, and/or at least 2 battleships in the sea zone, but what I'm really looking for is to see if there are at least 2 surface warships in the sea zone. So, if there is 1 destroyer and 1 cruiser in the sea zone, then this condition should be violated...but the engine is still marking the condition as true.

      Any way to get the result I'm looking for?

      W 1 Reply Last reply Reply Quote 0
      • W
        wc_sumpton @Jason Green-Lowe last edited by

        @jason-green-lowe

        pack_of_steel_2.xml: "unitPresence can be put in multiple times. ...
        "For an "AND" relationship between the required units, put them in separately. For an "OR" relationship, put them in on one line with a colon separating them
        ."

        So, 'value="carrier:battleship:cruiser:destroyer" count="2"', means any combination of 2 units, not any 2 of the same units, where as value="carrier" count="2"... value="battleship" count="2"... means 2 of each. From what I understand this not what you want. You'll need to create a separate condition for each unit, and then or the conditions together.

        Hope this helps.

        Cheers...

        Jason Green-Lowe 1 Reply Last reply Reply Quote 0
        • Jason Green-Lowe
          Jason Green-Lowe @wc_sumpton last edited by

          @wc_sumpton Yes, I agree with all of that, but for some reason my code does not seem to be behaving the way you describe.

          Here is a chart showing my desired behavior:
          No enemy warships in sea zone --> PASSABLE
          1 enemy warship in sea zone, and also 3+ friendly warships in sea zone --> PASSABLE
          1 enemy warship in sea zone, with 0-2 friendly warships in sea zone --> BLOCKED
          2 enemy warships in sea zone --> BLOCKED

          Note that should does not matter at all what type or type(s) of warships are used. For example, my desired behavior is...

          1 enemy destroyer + 1 enemy cruiser in sea zone --> BLOCKED
          2 enemy destroyers in sea zone --> BLOCKED

          Unfortunately, the code below instead gives me the behavior...

          1 enemy destroyer + 1 enemy cruiser in sea zone --> PASSABLE
          2 enemy destroyers in sea zone --> BLOCKED

          I do not know what the problem is here. Presumably I have made an error, but I can't find it.

                  <attachment foreach="$Players$^$SeaZones$" name="conditionAttachment_@Players@_Naval_Obstacle_In_@SeaZones@" attachTo="@Players@" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
                    <option name="enemyPresenceTerritories" value="@SeaZones@" count="1"/>
                    <option name="unitPresence" value="carrier:battleship:cruiser:destroyer" count="1"/>
                  </attachment>
                  <attachment foreach="$Players$^$SeaZones$" name="conditionAttachment_@Players@_No_Double_Naval_Obstacle_In_@SeaZones@" attachTo="@Players@" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
                    <option name="enemyExclusionTerritories" value="@SeaZones@" count="1"/>
                    <option name="unitPresence" value="carrier:battleship:cruiser:destroyer" count="2"/>
                  </attachment>    
                  <attachment foreach="$Players$^$SeaZones$" name="conditionAttachment_@Players@_Naval_Screen_In_@SeaZones@" attachTo="@Players@" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
                    <option name="alliedPresenceTerritories" value="@SeaZones@" count="1"/>
                    <option name="unitPresence" value="carrier:battleship:cruiser:destroyer" count="3"/>
                  </attachment>
                  <attachment foreach="$SeaZones$^$Players$:$LCPlayers$" name="triggerAttachment_Naval_Penetration_In_@SeaZones@" attachTo="@Players@" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                    <option name="conditions" value="conditionAttachment_@Players@_Naval_Obstacle_In_@SeaZones@:conditionAttachment_@Players@_Naval_Screen_In_@SeaZones@:conditionAttachment_@Players@_No_Double_Naval_Obstacle_In_@SeaZones@"/>
                    <option name="when" value="after:@LCPlayers@CombatMove"/>
                    <option name='unitAttachmentName' value='UnitAttachment' count='unitAttachment'/>          
                    <option name="unitType" value="carrier:battleship:cruiser:destroyer"/>
                    <option name="unitProperty" value="canBeMovedThroughByEnemies" count="true"/>
                  </attachment>
          
          W 1 Reply Last reply Reply Quote 0
          • W
            wc_sumpton @Jason Green-Lowe last edited by wc_sumpton

            @jason-green-lowe

            count="X" is not an exact count. To be true count can be equal to or greater than "X", so think of count as '>=' and not just '='.

            So, to check for just a single unit two conditions are needed, count="1" and an invert of count="2". To check for 2 units, count="2" and an invert of count="3".

            Cheers...

            P.S. Sorry I got caught up in the coding and not the problem. If 'canBeMovedThroughByEnemies' is set on 'carrier:battleship:cruiser:destroyer' every one of those units, enemy, allied, British, Japanese, etc... will be set. Not just in sea zones with just 1 enemy unit, but also in sea zones with 100 units. This type of rule would be better done with a 'supportAttachment' where units stacked together will nullify the ability.

            Try asking for a Feature Request to support the idea.

            Again Cheers...

            Jason Green-Lowe 1 Reply Last reply Reply Quote 1
            • Jason Green-Lowe
              Jason Green-Lowe @wc_sumpton last edited by

              @wc_sumpton Well, yes, I agree that the way I'm creating the feature is far from ideal. I've got a cleanup trigger that resets the canBeMovedThroughByEnemies back to false at the end of each combat move.

              I would indeed prefer to have a supportAttachment, but my understanding is that those wouldn't work right now with the existing code, and I think tripleA is short enough on developers right now that it's not practical to request special features just for my map.

              I tried switching from directExclusion to (directPresence + invert), and that did the trick. Thanks again for the help!

              1 Reply Last reply Reply Quote 1
              • 1 / 1
              • First post
                Last post
              Copyright © 2016-2018 TripleA-Devs | Powered by NodeBB Forums