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

    Change Unit Ownership? [Re-opened]

    Scheduled Pinned Locked Moved Maps & Mods
    23 Posts 5 Posters 6.5k Views 5 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.
    • wc_sumptonW Offline
      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...

      SlendyMcTendiesS 1 Reply Last reply Reply Quote 0
      • SlendyMcTendiesS Offline
        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?

        wc_sumptonW 1 Reply Last reply Reply Quote 0
        • wc_sumptonW Offline
          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>
          SlendyMcTendiesS 1 Reply Last reply Reply Quote 1
          • SlendyMcTendiesS Offline
            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

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

              SlendyMcTendiesS 3 Replies Last reply Reply Quote 2
              • SlendyMcTendiesS Offline
                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!

                TheDogT 1 Reply Last reply Reply Quote 0
                • TheDogT Online
                  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

                  https://forums.triplea-game.org/tags/thedog
                  https://forums.triplea-game.org/topic/3741/curated-best-top-maps-triplea-guides

                  Jason Green-LoweJ 1 Reply Last reply Reply Quote 2
                  • SlendyMcTendiesS Offline
                    SlendyMcTendies @wc_sumpton
                    last edited by

                    @wc_sumpton Perfect! Works beautifully! Thank you again!

                    1 Reply Last reply Reply Quote 0
                    • Jason Green-LoweJ Offline
                      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
                      • SlendyMcTendiesS Offline
                        SlendyMcTendies @wc_sumpton
                        last edited by

                        @wc_sumpton Does the value of PlayerAttachmentName need to be unique for each action? Because for some reason the unit control transfer stopped working when I added this code to the other 7 players (Russians, Japanese, Americans, etc)

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

                          @slendymctendies

                          Each player should have only one "playerAttachment", having more will cause problems. Thus 'PlayerAttachmentName' will not be unique. If problems persist, try adding 'players' <option>.

                          Cheers...

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

                            @wc_sumpton I'm confused about what you mean by players only being allowed "one" player attachment. You have two in your code example, yet it worked at the time.

                            @wc_sumpton said in Change Unit Ownership? [Resolved]:

                            @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...

                            So what do you mean by players only having one player attachment?

                            1 Reply Last reply Reply Quote 0

                            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
                            • 2
                            • 2 / 2
                            • First post
                              Last post
                            Copyright © 2016-2018 TripleA-Devs | Powered by NodeBB Forums