Navigation

    TripleA Logo

    TripleA Forum

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

    Change Unit Ownership? [Re-opened]

    Maps & Mods
    5
    23
    2254
    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.
    • SlendyMcTendies
      SlendyMcTendies last edited by SlendyMcTendies

      I'm trying to create a trigger that takes all of one player's territories and changes their ownership to another player. This is supposed to be part of a "Surrender" system I'm implementing to my map.

      Is there a way I can grab all owned territories by a player and then convert them to the other player's ownership in one line? Or at least not over 200 lines (because I have over 200 possibly owned territories)?


      NEW QUESTION: Is there a way to transfer ownership of UNITS

      (I don't need to figure out territory transfer anymore, that has been resolved.)

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

        @slendymctendies You don't need 200 separate triggers. You can use a loop.

        <!-- variableList provides a way to define "variables" which represent a list of elements in order to manage that list in a single place and avoid copying-pasting it multiple times. Whenever the variable name is specified in attachments using $nameOfVariable$, its replaced with a colon delimited string of the elements (ex. "$russianAntiAirTargets$" would be replaced by "russianFighter:russianTacticalBomber". They can be used in attachment "foreach" attributes as well to allow having an attachment "template" which then generates multiple attachments by looping over the elements and replacing each element into @nameOfVariable@. This is particularly useful for repetitive attachments where only a few values change across them (see "foreach" below in attachments for more detail/examples). -->
          
        
        RogerCooper 1 Reply Last reply Reply Quote 0
        • RogerCooper
          RogerCooper @RogerCooper last edited by

          @rogercooper That didn't display well. The code is from Pact of Steel 2.

          <!-- variableList provides a way to define "variables" which represent a list of elements in order to manage that list in a single place and avoid copying-pasting it multiple times. Whenever the variable name is specified in attachments using $nameOfVariable$, its replaced with a colon delimited string of the elements (ex. "$russianAntiAirTargets$" would be replaced by "russianFighter:russianTacticalBomber". They can be used in attachment "foreach" attributes as well to allow having an attachment "template" which then generates multiple attachments by looping over the elements and replacing each element into @nameOfVariable@. This is particularly useful for repetitive attachments where only a few values change across them (see "foreach" below in attachments for more detail/examples). -->

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

            @rogercooper Not working

            <variable name="Territory">			<!-- 227 territories -->
            
            <element name="Western Germany"/>
            <element name="Holland Belgium"/>
            <element name="Poland"/>
            <element name="Romania"/>
            <element name="Slovakia Hungary"/>
            <element name="Germany"/>
            <element name="Austria"/>
            
            [...]
            
            </variable>
            
            <attachment foreach="$Territory$" name="triggerAttachment_Germans_SurrenderTo_Russians" attachTo="Germans" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
            	<option name="trigger" value="conditionAttachment_Germans_SurrenderTo_Russians"/>
            	<option name="when" value="after:germansPolitics"/>
            	<option name="changeOwnership" value="@Territory@:Germans:Russians:true"/>
            </attachment>
            

            Full XML file at time of writing attached: ww2_risk_of_defeat.xml

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

              @slendymctendies

              @RogerCooper is right, "foreach" is very powerful. And in some cases can be very tricky to use. "changeOwnership" is one such example. Here there three list that might change "ConqueringPlayer", "ConqueredPlayer" and "SurrenderedTerritories". For example "Spain" is a "Neutral" country with "Madrid" as its capital, so when "Madrid" falls, all "Spain" territories held by "Neutral" surrendered.
              "foreach"="@AllConqueringPlayers@" (Needs to be in "triggerAttachment" name and conditions)
              "changeOwnership"="$AllConqueringPlayers$":"NeutralPlayer":"SurrenderedTerritory1" (Just 1 territory here not a list)
              "changeOwnership"="$AllConqueringPlayers$":"NeutralPlayer":"SurrenderedTerritory2" (Another territory)

              "Spain" surrenders territories when "Madrid" is captured from ConqueredPlayer.
              "foreach"="@AllConqueringPlayers@^@AllConqueredPlayers@"
              "changeOwnership"="$AllConqueringPlayers$":$AllConqueredPlayers$:"SurrenderedTerritory1" (Just 1 territory here not a list)
              "changeOwnership"="$AllConqueringPlayers$":$AllConqueredPlayers$:"SurrenderedTerritory2" (Another territory)

              Now the tricky part, ConqueredPlayer capital is conquered. Now SurrenderedTerritories becomes a list of all land territories and "foreach" cannot double nest: "@AllConqueringPlayers@^@AllConqueredPlayers@^@AllSurrenderedTerritories@". One list has to not change for "foreach" to work.
              "foreach"="@AllConqueringPlayers@^@AllSurrenderedTerritories@" (ConqueredPlayer does not change)
              "changeOwnership"="$AllConqueringPlayers$":ConqueredPlayer1:"$AllSurrenderedTerritories$"
              Only do 1 ConqueredPlayer per attachment.

              Cheers...

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

                @slendymctendies

                $Territory$ need to appear in the attachments name: "triggerAttachment_Germans_SurrenderTo_Russians_@Territroy@"

                This is creating an attachment for each territory, so the attachment names have to be different.

                Cheers...

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

                  @wc_sumpton PLEASE SEE BOTTOM OF THIS POST FOR NEW QUESTION

                  Ok, so I got this to almost work. The game log shows that the trigger fires and supposedly the German territories get converted to Russia's control, but in actuality they have not. The territory "team color" does not change, nor can the Russia player do anything with those territories (such as deploy units or non-combat move through them).

                  <attachment foreach="$Territory$" name="triggerAttachment_Germans_SurrenderTo_Russians_@Territory@_ChangeOwnership" attachTo="Germans" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                  	<option name="trigger" value="conditionAttachment_Germans_SurrenderTo_Russians"/>
                  	<option name="when" value="before:germansEndTurn"/>
                  	<option name="changeOwnership" value="@Territory@:Germans:Russians:true"/>
                  </attachment>
                  

                  EDIT: For some reason, the "Conquered" boolean at the end needed to be False. I don't really understand why, but that seems to have worked for territory conversion.

                  However, with just this, the German's units are still present on the territories that were surrendered.


                  NEW QUESTION:

                  Is there a way to convert ownership of units?

                  W 2 Replies Last reply Reply Quote 0
                  • W
                    wc_sumpton @SlendyMcTendies last edited by

                    @slendymctendies said in changeOwnership Trigger - Filter by owned territories?:

                    EDIT: For some reason, the "Conquered" boolean at the end needed to be False. I don't really understand why, but that seems to have worked for territory conversion.

                    The difference between endTurn and now. "true" mean "battle" and change happens at the conquering players endTurn (Russian)

                    Cheers...

                    SlendyMcTendies 1 Reply Last reply Reply Quote 1
                    • SlendyMcTendies
                      SlendyMcTendies @wc_sumpton last edited by

                      @wc_sumpton No, I'm talking about this line:

                      <option name="changeOwnership" value="@Territory@:Germans:Russians:true"/>
                      

                      I had to switch from "true" to "false" at the end of this line. To quote the documentation:

                      <!-- changeOwnership must have 4 fields: 
                      territory:oldOwner:newOwner:booleanConquered -->
                      

                      Whatever "BooleanConquered" does when set to "True" is not clear to me. It does not affect when the trigger fires

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

                        @slendymctendies

                        But it does effect when the ownership is changed. "false" means change now. "true" means this is a "battle" and is treated as if a battle happened, and ownership changes at the end of turn.

                        Cheers...

                        SlendyMcTendies 1 Reply Last reply Reply Quote 1
                        • SlendyMcTendies
                          SlendyMcTendies @wc_sumpton last edited by

                          @wc_sumpton Ah, ok. Thank you for that clarification

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

                            @slendymctendies said in changeOwnership Trigger - Filter by owned territories?:

                            Is there a way to convert ownership of units?

                            "canBeGivenByTerritoryTo" and "changeUnitOwners" and "giveUnitControlInAllTerritories" with some trigger work.

                            Cheers...

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

                              @wc_sumpton I keep getting an error when trying to use any of those options in a trigger. This is my latest attempt:

                              <attachment name="triggerAttachment_Germans_SurrenderTo_Russians_UnitControl" attachTo="Germans" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                              	<option name="trigger" value="conditionAttachment_Germans_SurrenderTo_Russians"/>
                              	<option name="when" value="after:germansPolitics"/>
                              	<option name="players" value="Russians"/>
                              	<option name="giveUnitControlInAllTerritories" value="true"/>
                              </attachment>
                              

                              None of the options seem to be valid TriggerAttachments though?

                              "canBeGivenByTerritoryTo" is a Unit Attachment
                              "changeUnitOwners" is a Territory Attachment
                              "giveUnitControlInAllTerritories" is a PlayerAttachment

                              How do I use these in a trigger?

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

                                @slendymctendies

                                Every unit attachment will need the following: "canBeGivenByTerritoryTo", and value need to equal one players, "Russians" at this point it doesn't matter what's here, it's just priming the pump. Some triggers do not work if there is no original entry to certain options.

                                Next add "giveUnitControlInAllTerritories" to the "playerAttachment" and set it to "false".

                                <!-- change military units canBeGivenByTerritoryTo-->
                                <attachment name="triggerAttachment_canBeGivenByTerritoryTo_GermansToRussians" attachTo="Germany" javaClass="TriggerAttachment" type="player">
                                	<option name="conditions" value="conditionAttachment_Germans_SurrenderTo_Russians"/>
                                	<option name="unitAttachmentName" value="UnitAttachment" count="unitAttachment"/>
                                	<option name="unitType" value="$AllUnits$"/>
                                	<option name="unitProperty" value="canBeGivenByTerritoryTo" count="Russians"/>
                                	<option name="when" value="before:germansEndTurn"/>
                                </attachment>
                                
                                <!-- Give by territories Germans to Russians -->
                                <!-- Should not need to reset this because Germans are out of the Game -->
                                <attachment name="triggerAttachment_GiveByTerritory_GermansToRussians" attachTo="Germany" javaClass="TriggerAttachment" type="player">
                                	<option name="conditions" value="conditionAttachment_Germans_SurrenderTo_Russians"/>
                                	<option name="playerAttachmentName" value="PlayerAttachment" count="playerAttachment"/>
                                	<option name="players" value="Germans"/>
                                	<option name="playerProperty" value="giveUnitControlInAllTerritories" count="true"/>
                                	<option name="when" value="before:germansEndTurn"/>
                                </attachment>
                                
                                <!-- reset military units canBeGivenByTerritoryTo -->
                                <attachment name="triggerAttachment_Reset_canBeGivenByTerritoryTo" attachTo="Germany" javaClass="TriggerAttachment" type="player">
                                	<option name="conditions" value="conditionAttachment_AlwaysTrue"/>
                                	<option name="unitAttachmentName" value="UnitAttachment" count="unitAttachment"/>
                                	<option name="unitType" value="$AllUnits$"/>
                                	<option name="unitProperty" value="canBeGivenByTerritoryTo" count="-reset-"/>
                                	<option name="when" value="after:germansEndTurn"/>
                                </attachment>
                                SlendyMcTendies 1 Reply Last reply Reply Quote 1
                                • SlendyMcTendies
                                  SlendyMcTendies @wc_sumpton last edited by

                                  @wc_sumpton This isn't working either. Did a lot of testing and for some reason can't get it to work.

                                  Latest xml attached:

                                  ww2_risk_of_defeat.xml

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

                                    @slendymctendies

                                    The following seems to work:

                                    <!-- Remove Capital Requirement -->
                                    <attachment foreach="$AllPlayers$" name="playerAttachment" attachTo="@AllPlayers@" javaClass="games.strategy.triplea.attachments.PlayerAttachment" type="player">
                                    	<option name="retainCapitalNumber" value="0"/>
                                    	<option name="retainCapitalProduceNumber" value="0"/>
                                    	<option name="giveUnitControl" value="$AllPlayers$"/>
                                    	<option name="giveUnitControlInAllTerritories" value="false"/>
                                    </attachment>
                                    <attachment foreach="$Territory$" name="triggerAttachment_Germans_SurrenderTo_Russians_@Territory@_ChangeOwnership" attachTo="Germans" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                                    	<option name="trigger" value="conditionAttachment_Germans_SurrenderTo_Russians"/>
                                    	<option name="when" value="before:germansEndTurn"/>
                                    	<option name="changeOwnership" value="@Territory@:Germans:Russians:false"/>
                                    	<option name="uses" value="1"/>
                                    </attachment>
                                    <!--  change military units canBeGivenByTerritoryTo -->
                                    <attachment name="triggerAttachment_canBeGivenByTerritoryTo_GermansToRussians" attachTo="Germans" javaClass="TriggerAttachment" type="player">
                                    	<option name="conditions" value="conditionAttachment_Germans_SurrenderTo_Russians"/>
                                    	<option name="unitAttachmentName" value="UnitAttachment" count="unitAttachment"/>
                                    	<option name="unitType" value="$AllUnits$"/>
                                    	<option name="unitProperty" value="canBeGivenByTerritoryTo" count="-reset-Russians"/>
                                    	<option name="when" value="after:germansPolitics"/>
                                    	<option name="uses" value="1"/>
                                    </attachment>
                                    <!--  Give unit control Germans to Russians  -->
                                    <attachment name="triggerAttachment_GiveUnitControl_GermansToRussians" attachTo="Germans" javaClass="TriggerAttachment" type="player">
                                    	<option name="conditions" value="conditionAttachment_Germans_SurrenderTo_Russians"/>
                                    	<option name="playerAttachmentName" value="PlayerAttachment" count="playerAttachment"/>
                                    	<option name="playerProperty" value="giveUnitControl" count="-reset-Russians"/>
                                    	<option name="when" value="after:germansPolitics"/>
                                    	<option name="uses" value="1"/>
                                    </attachment>
                                     <!--  Give give captured units Germans to Russians  -->
                                    <attachment name="triggerAttachment_GiveUnitControlInAllTerritories_GermansToRussians" attachTo="Germans" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
                                    	<option name="trigger" value="conditionAttachment_Germans_SurrenderTo_Russians"/>
                                    	<option name="when" value="after:germansPolitics"/>
                                    	<option name="playerAttachmentName" value="PlayerAttachment" count="playerAttachment"/>
                                    	<option name="playerProperty" value="giveUnitControlInAllTerritories" count="true"/>
                                    	<option name="uses" value="1"/>
                                    </attachment>
                                    

                                    Cheers...

                                    SlendyMcTendies 3 Replies Last reply Reply Quote 2
                                    • SlendyMcTendies
                                      SlendyMcTendies @wc_sumpton last edited by

                                      @wc_sumpton Ok, when I have a moment to try this myself I will let you know how it goes. Thank you for your help!

                                      TheDog 1 Reply Last reply Reply Quote 0
                                      • TheDog
                                        TheDog @SlendyMcTendies last edited by TheDog

                                        In my experimenting/coding with playerAttachment I suspect the following maybe true;

                                        * playerAttachment must be the last attachment in </attachmentList> EDIT: It does not need to be the last attachment.

                                        • Only One playerAttachment per Player is allowed
                                        Jason Green-Lowe 1 Reply Last reply Reply Quote 2
                                        • SlendyMcTendies
                                          SlendyMcTendies @wc_sumpton last edited by

                                          @wc_sumpton Perfect! Works beautifully! Thank you again!

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

                                            @thedog I had a problem with playerAttachment that was fixed by making sure that there was only one playerAttachment per Player. Thank you very much for the tip!

                                            For whatever it's worth, I have other attachments after the playerAttachments in my attachmentList, and it does not currently seem to be causing me problems.

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