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

    Restrict movement of unit

    Scheduled Pinned Locked Moved Map Making
    16 Posts 4 Posters 4.9k Views 4 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.
    • P Offline
      Prussia
      last edited by

      Hi Devs, is there any current engine feature that support XML code which would allow me to restrict a unit to specific territories?

      I seem to recall Veqryn has enabled this before but there had been so many changes since I last followed the engine features I no longer remember.

      Thanks!

      redrumR 1 Reply Last reply Reply Quote 0
      • redrumR Offline
        redrum Admin @Prussia
        last edited by

        @prussia Yeah, you can restrict units to certain territories using "movementRestrictionTerritories". An example of this is China in many games which can only move its units within Chinese territories.

        You can also you territoryEffect to limit which units can move into various territories. So really depends exactly what you are trying to achieve to the best XML approach.

        I'd recommend taking a look at POS2 XML: https://github.com/triplea-maps/the_pact_of_steel/blob/master/map/games/pact_of_steel_2.xml

        TripleA Developer with a Passion for AI: https://forums.triplea-game.org/topic/105/ai-development-discussion-and-feedback

        1 Reply Last reply Reply Quote 0
        • P Offline
          Prussia
          last edited by

          Thanks, Redrum.

          If I recall correctly, movementRestrictionTerritories restricts all units belonging to a country to a certain territory.

          I only want to restrict a specific unit belonging to a country to certain territories.

          redrumR 1 Reply Last reply Reply Quote 0
          • redrumR Offline
            redrum Admin @Prussia
            last edited by

            @prussia Correct. I believe using territoryEffects is the way to achieve limiting specific units to certain territories (say tanks can't move through mountains, etc).

            TripleA Developer with a Passion for AI: https://forums.triplea-game.org/topic/105/ai-development-discussion-and-feedback

            P 1 Reply Last reply Reply Quote 0
            • P Offline
              Prussia @redrum
              last edited by

              @redrum

              Is there any examples of terrain effect that only allow certain units on specific terrains?

              I'm trying to restrict the movement of certain units to a few terrain while not impacting other units.

              redrumR 1 Reply Last reply Reply Quote 0
              • redrumR Offline
                redrum Admin @Prussia
                last edited by

                @prussia Hmm. I can't think of any maps that use terrain to only allow units on specific terrains of the top of my head. One of the only maps that uses territoryEffects extensively is Total World War (TWW). It may help if you describe in more detail what you are looking to accomplish with some examples.

                You should be able to do something like this for terrain that they can't enter and add this to all territories you don't want them in:

                	<attachment name="territoryEffectAttachment" attachTo="mountain" javaClass="games.strategy.triplea.attachments.TerritoryEffectAttachment" type="territoryEffect">
                		<option name="unitsNotAllowed" value="armour"/>
                	</attachment>
                

                There is also a new engine option that was developed for trains/roads/etc where you can instead require units like rails/roads/etc for certain units to move.

                <attachment name="unitAttachment" attachTo="Train" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType">
                  <option name="requiresUnitsToMove" value="Rail"/>
                </attachment>
                <attachment name="unitAttachment" attachTo="Rail" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType">
                  <option name="isInfrastructure" value="true"/>
                </attachment>
                

                TripleA Developer with a Passion for AI: https://forums.triplea-game.org/topic/105/ai-development-discussion-and-feedback

                1 Reply Last reply Reply Quote 0
                • P Offline
                  Prussia
                  last edited by

                  I'm trying to do Japanese Kamikazes

                  I want the only land territory Kamiz could land on be Tokyo.

                  Then I will restrict the kamiz's movement to seazones surrounding japan.

                  However, I do not want to code every territory that the Kamiz cannot enter (since that would be way too many).

                  The kamiz could only enter 10 territories or so, I'm hoping I could simply say "Allow Kamiz to only move within these 10 territories."

                  redrumR HeppsH 2 Replies Last reply Reply Quote 0
                  • redrumR Offline
                    redrum Admin @Prussia
                    last edited by

                    @prussia Unfortunately, I don't think there is currently an inverse territoryEffect option to unitsNotAllowed. The best way to achieve what you want is to add a territoryEffectAttachment to all other territories but those 10 that doesn't allow Kamikaze units (Tokyo and the nearby sea zones). Probably could argue creating the inverse territoryEffect option would be useful.

                    TripleA Developer with a Passion for AI: https://forums.triplea-game.org/topic/105/ai-development-discussion-and-feedback

                    1 Reply Last reply Reply Quote 0
                    • HeppsH Offline
                      Hepps Moderators @Prussia
                      last edited by Hepps

                      @prussia You could acheive what you want using the new "RequiresUnitToMove" attachment.

                      You could simply make a unit that the Kamikazes require to move... then place one of those in all 10 of the SZ and on Tokyo. Then those would be the only places the Kamiz's could move.

                      Just make a unit image that defines the terr. or SZ as a move for the Kamiz. A Katana... or the Japanese character for suicide...

                      "A joyous heart sours with the burden of expectation"
                      Hepster

                      redrumR 1 Reply Last reply Reply Quote 1
                      • redrumR Offline
                        redrum Admin @Hepps
                        last edited by

                        @hepps I don't think that will work currently as I believe we made "requiresUnitsToMove" units have to be ALLIED to allow movement. This would need to be changed to ALL so if an enemy fleet moves into a sea zone the kamikaze could still move there.

                        TripleA Developer with a Passion for AI: https://forums.triplea-game.org/topic/105/ai-development-discussion-and-feedback

                        HeppsH 1 Reply Last reply Reply Quote 0
                        • HeppsH Offline
                          Hepps Moderators @redrum
                          last edited by Hepps

                          @redrum Yes you would just need to add triggers before Japans combat move to change the unit back to a Japanese unit if the Terr. or SZ were caputred... then a trigger to change it back at the end of the combat moves.

                          Little bit of work for all 11 territories and SZ.... but it would still be less than having to do a limiting definition to every other Terr. and SZ on the entire map.

                          "A joyous heart sours with the burden of expectation"
                          Hepster

                          redrumR 1 Reply Last reply Reply Quote 0
                          • redrumR Offline
                            redrum Admin @Hepps
                            last edited by

                            @hepps Yeah. It does bring up the question on whether "requiresUnitsToMove" should consider ALL instead of ALLIED though. Which I'm starting to think would be better as the default. Could also add a new parameter to it that specifies either OWN/ALLIED/ENEMY/ALL.

                            TripleA Developer with a Passion for AI: https://forums.triplea-game.org/topic/105/ai-development-discussion-and-feedback

                            HeppsH 1 Reply Last reply Reply Quote 1
                            • HeppsH Offline
                              Hepps Moderators @redrum
                              last edited by

                              @redrum Yes. I do like the idea of being able to set the parameter for the property.

                              "A joyous heart sours with the burden of expectation"
                              Hepster

                              1 Reply Last reply Reply Quote 0
                              • P Offline
                                Prussia
                                last edited by

                                We should request the following feature:

                                add a new "movementRestriction" property to units without terrain effect being needed.

                                We already have "placement restriction" so it can't be that more difficult to add "movementRestriction" 😉

                                1 Reply Last reply Reply Quote 0
                                • General_ZodG Offline
                                  General_Zod Moderators
                                  last edited by

                                  You can get away with using territory effects to restrict the unit access and not code every territory on the map. Just give this effect to places that the kamikaze can actually reach from the allowable territories. The amount of territories will depend on the movement your kamikaze have.

                                  redrumR 1 Reply Last reply Reply Quote 2
                                  • redrumR Offline
                                    redrum Admin @General_Zod
                                    last edited by

                                    @general_zod Good idea. That should make it so you can create a ring of territories with the territoryEffect preventing movement around the 10 or so you want them to be able to move to.

                                    TripleA Developer with a Passion for AI: https://forums.triplea-game.org/topic/105/ai-development-discussion-and-feedback

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