Restrict movement of unit



  • 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!


  • Admin

    @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



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


  • Admin

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



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


  • Admin

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


  • 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."


  • Admin

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


  • Admin

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


  • Admin

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


  • Admin

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


  • Admin

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


  • Admin

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



  • 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" ;)


  • Admin

    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.


  • Admin

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


Log in to reply
 

Looks like your connection to TripleA Forum was lost, please wait while we try to reconnect.