TripleA Logo TripleA Forum
    • TripleA Website
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Tags
    • Register
    • Login

    Transferring Unit Control

    Scheduled Pinned Locked Moved Map Making
    19 Posts 3 Posters 646 Views 3 Watching
    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.
    • RogerCooperR Offline
      RogerCooper @RogerCooper
      last edited by

      I tried the code and it doesn't seem to work. I will use "removeUnits" and "placement".

      wc_sumptonW 1 Reply Last reply Reply Quote 0
      • wc_sumptonW Offline
        wc_sumpton @RogerCooper
        last edited by wc_sumpton

        @rogercooper

        I don't understand the problem. In "World War II Global 1940 2nd Edition" all UK_Pacific are changed into British units, also if Japanese attack Russians then all Mongolians territories change to Russians along with their units.
        Do units/infantry have "canBeGivenByTerritoryTo"?
        Do territories/Spain have "changeUnitOwners"?
        Do Non_Aligned have "playerAttachment" with "giveUnitControl"?
        Is "Give Units By Territory" true"?
        Is "changeOwnership" combat value true?

        If you are more problems post some code.

        Cheers...

        RogerCooperR 1 Reply Last reply Reply Quote 2
        • RogerCooperR Offline
          RogerCooper @wc_sumpton
          last edited by

          @wc_sumpton said in Transferring Unit Control:

          @rogercooper

          I don't understand the problem. In "World War II Global 1940 2nd Edition" all UK_Pacific are changed into British units, also if Japanese attack Russians then all Mongolians territories change to Russians along with their units.
          Do units/infantry have "canBeGivenByTerritoryTo"?
          Do territories/Spain have "changeUnitOwners"?
          Do Non_Aligned have "playerAttachment" with "giveUnitControl"?
          Is "Give Units By Territory" true"?
          Is "changeOwnership" combat value true?

          If you are more problems post some code.

          Cheers...

          I tried all of those things, and the units do not change ownership.

          <attachment name="unitAttachment" attachTo="infantry" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType">
          <option name="movement" value="1"/>
          <option name="transportCost" value="1"/>
          <option name="attack" value="1"/>
          <option name="defense" value="2"/>
          <option name="isLandTransportable" value="true"/>
          <option name="artillerySupportable" value="true"/>
          <option name="canBeGivenByTerritoryTo" value="Soviet_Union"/>
          </attachment>
          
          <attachment name="territoryAttachment" attachTo="Ireland" javaClass="games.strategy.triplea.attachments.TerritoryAttachment" type="territory">
          <option name="production" value="1"/>
          <option name="changeUnitOwners" value="Soviet_Union"/>
          </attachment>
          
          <attachment name="playerAttachment" attachTo="Non_Aligned" javaClass="games.strategy.triplea.attachments.PlayerAttachment" type="player">
            <option name="giveUnitControl" value="Soviet_Union"/>
          </attachment>
          
          <property name="Give Units By Territory" value="true" editable="false">
            <boolean/>
          </property>
          
          <attachment name="triggerAttachmentIrelandSoviet_Union" attachTo="Soviet_Union" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
          <option name="conditions" value="conditionAttachmentEveryTurn"/>
          <option name="conditions" value="conditionAttachmentIrelandNon_Aligned"/>
          <option name="players" value="Soviet_Union"/>
          <option name="chance" value="80:80"/>
          <option name="chanceIncrementOnFailure" value="1"/>
          <option name="when" value="before:Soviet_UnionPurchase"/>
          <option name="changeOwnership" value="Ireland:Non_Aligned:Soviet_Union:true"/>
          <option name="changeOwnership" value="Ireland:Non_Aligned:Soviet_Union:false"/>
          <option name="uses" value="1"/>
          </attachment>
          

          Ireland changes ownership, but the unit remains Non_Aligned

          B wc_sumptonW 2 Replies Last reply Reply Quote 0
          • B Offline
            beelee @RogerCooper
            last edited by beelee

            @rogercooper said in Transferring Unit Control:

            Screenshot from 2026-03-03 16-45-33.png

            these seem at odds with one another

            Edit
            Maybe you need to add this or the by TTy not all TTys

            Screenshot from 2026-03-03 16-53-17.png

            1 Reply Last reply Reply Quote 1
            • wc_sumptonW Offline
              wc_sumpton @RogerCooper
              last edited by wc_sumpton

              @rogercooper

              Does Non_Aligned have "canTakeOverOwnedTerritory" as part of it relationshipTypeAttachment?

              <option name="changeOwnership" value="Ireland:Non_Aligned:Soviet_Union:true"/>
              <option name="changeOwnership" value="Ireland:Non_Aligned:Soviet_Union:false"/>
              

              Will not work because Ireland is not Non_Aligned for the second call because it is owned by Soviet_Union.

              Cheers...

              RogerCooperR 1 Reply Last reply Reply Quote 2
              • RogerCooperR Offline
                RogerCooper @wc_sumpton
                last edited by

                @wc_sumpton said in Transferring Unit Control:

                @rogercooper

                Does Non_Aligned have "canTakeOverOwnedTerritory" as part of it relationshipTypeAttachment?

                <option name="changeOwnership" value="Ireland:Non_Aligned:Soviet_Union:true"/>
                <option name="changeOwnership" value="Ireland:Non_Aligned:Soviet_Union:false"/>
                

                Will not work because Ireland is not Non_Aligned for the second call because it is owned by Soviet_Union.

                Cheers...

                I tried reversing the order, but the result is the same, the territory changed ownership but not the units.

                I also tried to remove and place. It doesn't work because the program assumes that the units to be removed are from the attached player. I would need to have a separate trigger for that.

                wc_sumptonW 1 Reply Last reply Reply Quote 0
                • wc_sumptonW Offline
                  wc_sumpton @RogerCooper
                  last edited by

                  @rogercooper

                  The order does not matter.

                  <option name="changeOwnership" value="Ireland:Non_Aligned:Soviet_Union:true"/>
                   <!-- <option name="changeOwnership" value="Ireland:Non_Aligned:Soviet_Union:false"/>Non_Aligned no longer own Ireland, Soviet_Union does, so this will not run -->
                  <option name="changeOwnership" value="Ireland:any:Soviet_Union:false"/> <!-- Uses 'any' for old owner  -->
                  

                  @rogercooper said in Transferring Unit Control:

                  Ireland changes ownership, but the unit remains Non_Aligned

                  I'm going to setup a test map.

                  Cheers...

                  RogerCooperR 1 Reply Last reply Reply Quote 2
                  • wc_sumptonW Offline
                    wc_sumpton
                    last edited by

                    @RogerCooper

                    There are two different settings. Both have unit, territory, player, and options.
                    canBeGivenByTerritoryTo is used to give control of a unit to another player when the unit enters a territory with changeUnitOwners unless giveUnitControlInAllTerritories is set in playerAttachment. playerAttachment should contain giveUnitControl and option "Give Units By Territory" should also be set.

                    But what I think you want capture.
                    canBeCapturedOnEnteringBy is used to gain control of the unit when a territory with captureUnitOnEnteringBy is captured. playerAttachment should contain captureUnitOnEnteringBy and option "Capture Units On Entering Territory" should also be set.

                    Cheers...

                    1 Reply Last reply Reply Quote 2
                    • RogerCooperR Offline
                      RogerCooper @wc_sumpton
                      last edited by

                      @wc_sumpton said in Transferring Unit Control:

                      @rogercooper

                      The order does not matter.

                      <option name="changeOwnership" value="Ireland:Non_Aligned:Soviet_Union:true"/>
                       <!-- <option name="changeOwnership" value="Ireland:Non_Aligned:Soviet_Union:false"/>Non_Aligned no longer own Ireland, Soviet_Union does, so this will not run -->
                      <option name="changeOwnership" value="Ireland:any:Soviet_Union:false"/> <!-- Uses 'any' for old owner  -->
                      

                      @rogercooper said in Transferring Unit Control:

                      Ireland changes ownership, but the unit remains Non_Aligned

                      I'm going to setup a test map.

                      Cheers...

                      Neither is what I want. I want to change control of the territory and units without any requirement for entry.

                      wc_sumptonW 1 Reply Last reply Reply Quote 0
                      • wc_sumptonW Offline
                        wc_sumpton @RogerCooper
                        last edited by wc_sumpton

                        @rogercooper said in Transferring Unit Control:

                        Neither is what I want. I want to change control of the territory and units without any requirement for entry.

                        Yes, and I understand that. That is why I pointed to "World War II Global 1940 2nd Edition" all the Mongolian territories as well as their infantry units change to Russian control on Japan's turn. Russia did not have to enter those territories.
                        I also understand that you want to keep your project to yourself, but there is not enough information to debug what the problem might be.
                        I'm sorry, what you are describing seem doable. But I'm not able to figure the disconnect. The problem is probably on my side.
                        Again sorry.

                        Cheers...

                        P.S.

                        You could try adding canBeCapturedOnEnteringBy to the infantry, captureUnitOnEnteringBy to Ireland and to Non_Aligned playerAttachment and setting "Capture Units On Entering Territory". What could it hurt since nothing else has worked.

                        Cheers...

                        RogerCooperR 1 Reply Last reply Reply Quote 2
                        • RogerCooperR Offline
                          RogerCooper @wc_sumpton
                          last edited by

                          @wc_sumpton I am trying a different approach.

                          <attachment name="triggerAttachmentIrelandSoviet_Union" attachTo="Soviet_Union" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                          <option name="conditions" value="conditionAttachmentEveryTurn"/>
                          <option name="conditions" value="conditionAttachmentIrelandNon_Aligned"/>
                          <option name="players" value="Soviet_Union"/>
                          <option name="chance" value="80:80"/>
                          <option name="chanceIncrementOnFailure" value="1"/>
                          <option name="when" value="before:Soviet_UnionPurchase"/>
                          <option name="placement" value="Ireland:infantry" />
                          <option name="changeOwnership" value="Ireland:Non_Aligned:Soviet_Union:false"/>
                          <option name="activateTrigger" value="triggerAttachmentIrelandSoviet_Union2:1:false:false:false:false"/>
                          <option name="uses" value="1"/>
                          </attachment>
                          <attachment name="triggerAttachmentIrelandSoviet_Union2" attachTo="Non_Aligned" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                          <option name="players" value="Non_Aligned"/>
                          <option name="uses" value="1"/>
                          <option name="removeUnits" value="Ireland:All"/>
                          </attachment>
                          
                          <attachment name="triggerAttachmentIrelandAligned" attachTo="Non_Aligned" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                          <option name="players" value="Non_Aligned"/>
                          <option name="uses" value="1"/>
                          <option name="removeUnits" value="Ireland:All"/>
                          </attachment>
                          

                          Without the activateTrigger it changes control and adds a Soviet unit. With the activate trigger, I get the error

                          Could not parse:C:\Users\Roger\triplea\downloadedMaps\East_and_West\games\East_and_West-Automated-7p.xml, map name: ''C:\Users\Roger\triplea\downloadedMaps\East_and_West\games\East_and_West-Automated-7p.xml'', unexpected exception while setting values for attachment: TriggerAttachment attached to: PlayerId named: Soviet_Union with name: triggerAttachmentIrelandSoviet_Union, failed to set string property value to 'triggerAttachmentIrelandSoviet_Union2:1:false:false:false:false'

                          GameParseException: map name: ''C:\Users\Roger\triplea\downloadedMaps\East_and_West\games\East_and_West-Automated-7p.xml'', unexpected exception while setting values for attachment: TriggerAttachment attached to: PlayerId named: Soviet_Union with name: triggerAttachmentIrelandSoviet_Union, failed to set string property value to 'triggerAttachmentIrelandSoviet_Union2:1:false:false:false:false'

                          MutableProperty$InvalidValueException: failed to set string property value to 'triggerAttachmentIrelandSoviet_Union2:1:false:false:false:false'

                          GameParseException: No TriggerAttachment named: triggerAttachmentIrelandSoviet_Union2, for: TriggerAttachment attached to: PlayerId named: Soviet_Union with name: triggerAttachmentIrelandSoviet_Union

                          I am not sure why "triggerAttachmentIrelandSoviet_Union2" is not being recognized by the parser. I am using "activateTrigger" incorrectly? The example in Pact of Steel 2 is

                          <option name="activateTrigger" value="triggerAttachment_Americans_Aid_UK:1:false:false:false:false"/>
                          

                          and I have followed the same format.

                          wc_sumptonW 1 Reply Last reply Reply Quote 0
                          • wc_sumptonW Offline
                            wc_sumpton @RogerCooper
                            last edited by

                            @rogercooper

                            Put the called trigger triggerAttachmentIrelandSoviet_Union2 above the calling trigger.

                            <attachment name="triggerAttachmentIrelandSoviet_Union2" attachTo="Non_Aligned" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                            <option name="players" value="Non_Aligned"/>
                            <option name="uses" value="1"/>
                            <option name="removeUnits" value="Ireland:All"/>
                            </attachment>
                            
                            <attachment name="triggerAttachmentIrelandSoviet_Union" attachTo="Soviet_Union" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                            <option name="conditions" value="conditionAttachmentEveryTurn"/>
                            <option name="conditions" value="conditionAttachmentIrelandNon_Aligned"/>
                            <option name="players" value="Soviet_Union"/>
                            <option name="chance" value="80:80"/>
                            <option name="chanceIncrementOnFailure" value="1"/>
                            <option name="when" value="before:Soviet_UnionPurchase"/>
                            <option name="placement" value="Ireland:infantry" />
                            <option name="changeOwnership" value="Ireland:Non_Aligned:Soviet_Union:false"/>
                            <option name="activateTrigger" value="triggerAttachmentIrelandSoviet_Union2:1:false:false:false:false"/>
                            <option name="uses" value="1"/>
                            </attachment>
                            

                            Cheers...

                            RogerCooperR 1 Reply Last reply Reply Quote 3
                            • RogerCooperR Offline
                              RogerCooper @wc_sumpton
                              last edited by RogerCooper

                              @wc_sumpton That did it! Thank you for your help.

                              8d6f6a63-79ef-4c82-a6d7-5394b8877b07-image.png

                              To recap this for anyone looking at this in the future.

                              <attachment name="triggerAttachmentIrelandSoviet_Union2" attachTo="Non_Aligned" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                              <option name="players" value="Non_Aligned"/>
                              <option name="uses" value="1"/>
                              <option name="removeUnits" value="Ireland:All"/>
                              </attachment>
                              <attachment name="triggerAttachmentIrelandSoviet_Union" attachTo="Soviet_Union" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                              <option name="conditions" value="conditionAttachmentEveryTurn"/>
                              <option name="conditions" value="conditionAttachmentIrelandNon_Aligned"/>
                              <option name="players" value="Soviet_Union"/>
                              <option name="chance" value="80:80"/>
                              <option name="chanceIncrementOnFailure" value="1"/>
                              <option name="when" value="before:Soviet_UnionPurchase"/>
                              <option name="placement" value="Ireland:infantry" />
                              <option name="changeOwnership" value="Ireland:Non_Aligned:Soviet_Union:false"/>
                              <option name="activateTrigger" value="triggerAttachmentIrelandSoviet_Union2:1:false:false:false:false"/>
                              <option name="uses" value="1"/>
                              </attachment>
                              

                              No need make changes anywhere outside of the triggers.

                              1 Reply Last reply Reply Quote 0
                              • wc_sumptonW Offline
                                wc_sumpton
                                last edited by

                                @RogerCooper

                                As I stated above, there are two methods, a player can give control of their units to another player, or a player can take control of another players units.
                                Germany wants to give Italians infantry in Venice.
                                Screenshot 2026-03-06 153247.png
                                In the unitAttachment for infantry add <option name="canBeGivenByTerritoryTo" value="Italians"/>.
                                In the territoryAttachment for Venice add <option name="changeUnitOwners" value="Italians"/>.
                                In the playerAttachment for Germany add <option name="giveUnitControl" value="Italians"/>.
                                And set <property name="Give Units By Territory" value="true" editable="false"/>
                                Now German infantry can be given to Italians either by trigger or movement.
                                Screenshot 2026-03-06 153734.png
                                At the end of Germany's noncombat move there are 2 German infantry in Venice. One moved from Wittenberg another placed by trigger.
                                At Germany's endTurn the units will switch to Italian control.
                                Screenshot 2026-03-06 154122.png
                                There are two things to remember when giving unit control. Territory ownership does not matter. If Germany owns Venice, Italians will still gain control. Change of control only happens on the Giving Player's endTurn.

                                Using "canBeGivenByTerritoryTo" to give a Neutral players unit will not work unless the Neutral player has an endTurn/endTurnNoPU step.

                                Cheers...

                                1 Reply Last reply Reply Quote 2
                                • wc_sumptonW Offline
                                  wc_sumpton
                                  last edited by

                                  @RogerCooper

                                  The second method is to take control of another players units.
                                  Screenshot 2026-03-06 153311.png
                                  To let Germany take control of the 4 units in Bulgaria and the one unit in Varna.
                                  In the unitAttachment for infantry add <option name="canBeCapturedOnEnteringBy" value="Germans"/>.
                                  In the territoryAttachment for Bulgaria and Varna add <option name="captureUnitOnEnteringBy" value="Germans"/>.
                                  In the playerAttachment for Neutral_Player add <option name="captureUnitOnEnteringBy" value="Germans"/>.
                                  And set <property name="Capture Units On Entering Territory" value="true"/>.
                                  Then this <option name="changeOwnership" value="Bulgaria:any:Germans:true"/> in a trigger, the 'when' can be any step.
                                  After Germany's noncombat move.
                                  Screenshot 2026-03-06 171112.png
                                  The 4 units changed, but not factory or the Territory and because Germany moved into Varna during noncombat the unit and territory does not change.
                                  Adding <option name="canTakeOverOwnedTerritory" value="true"/> to the relationshipTypeAttachment between Germany and Neutral_Player to get this.
                                  Screenshot 2026-03-06 154000.png
                                  Control of the units happens on the 'true' setting of 'changeOwnership' and changes at the 'when'.

                                  Cheers...

                                  1 Reply Last reply Reply Quote 2

                                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                  With your input, this post could be even better 💗

                                  Register Login
                                  • 1 / 1
                                  • First post
                                    Last post
                                  Copyright © 2016-2018 TripleA-Devs | Powered by NodeBB Forums