Navigation

    TripleA Logo

    TripleA Forum

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

    Transferring Unit Control

    Map Making
    3
    13
    145
    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.
    • RogerCooper
      RogerCooper last edited by

      I am working on a mod where major powers gain control of unaligned nations through random events. For example

      <attachment name="triggerAttachmentSpainUnited_States" attachTo="United_States" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
      <option name="conditions" value="conditionAttachmentEveryTurn"/>
      <option name="players" value="United_States"/>
      <option name="chance" value="1:80"/>
      <option name="chanceIncrementOnFailure" value="1"/>
      <option name="when" value="before:United_StatesPurchase"/>
      <option name="changeOwnership" value="Spain:Non_Aligned:United_States:false"/>
      <option name="uses" value="1"/>
      </attachment>
      

      Is there any way to change the ownership of the units directly. I would rather avoid having to specify for each territory removing each unit and adding a new units.

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

        @rogercooper

        Hi Roger

        What I did was a little different as I had all units from all their TTys change at once and I don't remember 100% of how I did it but you already have the "changeOwnership" .

        You need to use "GiveUnitControl" and then specify the TTy. So you'd still need a trigger for each TTy but not individual units. You need to add it in multiple places.

        From POS2

        Screenshot from 2026-03-01 10-09-55.png

        @wc_sumpton may know of a better way.

        Edit

        Screenshot from 2026-03-01 10-03-25.png

        Idk. Maybe that won't work as it Might activate all the TTys that have that attachment

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

          @rogercooper

          Try reviewing here.

          @beelee is pointing you in the right direction.

          Cheers...

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

            @wc_sumpton said in Transferring Unit Control:

            @rogercooper

            Try reviewing here.

            @beelee is pointing you in the right direction.

            Cheers...

            Thanks. I will give that a try.

            RogerCooper 1 Reply Last reply Reply Quote 1
            • RogerCooper
              RogerCooper @RogerCooper last edited by

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

              W 1 Reply Last reply Reply Quote 0
              • W
                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...

                RogerCooper 1 Reply Last reply Reply Quote 1
                • RogerCooper
                  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 W 2 Replies Last reply Reply Quote 0
                  • B
                    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
                    • W
                      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...

                      RogerCooper 1 Reply Last reply Reply Quote 1
                      • RogerCooper
                        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.

                        W 1 Reply Last reply Reply Quote 0
                        • W
                          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...

                          RogerCooper 1 Reply Last reply Reply Quote 1
                          • W
                            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
                            • RogerCooper
                              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.

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