AI Pathfinding

From RPTools Wiki
(Redirected from Movement Blocking Layer)
Jump to navigation Jump to search

Languages:  English  • 日本語

MapTool has a built in AI pathfinding feature. When activated by a GM via the ‘AI’ toggle button on the toolbar, tokens will find the shortest path to its destination as you drag them on the token or hidden layers. The movement takes into account the Movement Blocking Layer (MBL) and terrain modifiers configured on intervening tokens. This means your tokens will not move through walls, and will find an efficient path past obstacles and around or through difficult terrain. AI Pathfinding correctly accounts for a game's diagonal movement settings as well. Optionally, movement can also be restricted by the Vision Blocking Layer (VBL).

The AI setting can be toggled by clicking the 'AI' button on the toolbar so that it shows green text. When the text is gray, AI is disabled.

Turning On AI Pathfinding

AI toggle buttons are grouped next to the the other Interaction tools. AI Pathfinding can be set to block movement on MBL, VBL, or both. When hosting a game on MapTool 1.6 and above, only GMs may change this setting and the setting is the same for all connected players. On prior versions with AI, the toggle is available to players on a per-client basis.

Tokens with terrain modifiers are always considered in movement calculations when AI Pathfinding is enabled.

Adding Movement and Vision Blocking to maps

Example map view while editing blocking layers. Note the yellow token VBL is visible when editing MBL/VBL.

To add movement blocking to your maps, use the Blocking Layer drawing tools on the toolbar. Once selected, you must choose which blocking layer you are affecting with your drawing: Movement, Vision, or Both. MBL and VBL are only visible when this drawing mode is engaged, and render with very bright colors over all other graphics in the Map View to be as clear as possible. Note that Undo/Redo does not work with Vision/Movement blocking tools.

Here are some ideas for using these different modes in your maps:

  • Vision Blocking: Useful for curtains and other elements which may block vision, but not restrict movement.
  • Movement: Useful for pits, lava, and other terrain that should be normally impossible to enter (but see below).
  • Both: Useful for walls, rocks, and pillars, which block both vision and movement.

Token VBL is another way to place VBL in your maps which allows the object to be itself visible over fog. This can make bushes, fog, and other vision blocking effects which need to be visible to players. Combined with Terrain Modifiers such tokens can also block movement, allowing mobile objects such as statues or boulders which the player can see but not move through.

Using Terrain Modifiers

Editing a stamp's terrain modifier

A stamp or token may have a Terrain Modifier assigned to it that impacts the movement of tokens that move across it. There are four types of Terrain Modifiers:

  • NONE - No change to movement cost.
  • ADD - Adds the amount to the cost to move into the cell. If the Units per Cell are set to 5 (for 5' per grid) and a stamp has ADD 3 Terrain Modifier then movement onto that stamp will cost either 8 or 10 depending on the AI Cell Rounding setting in Map Properties.
  • MULTIPLY - Multiplies the movement cost by the Terrain Modifier amount. If it would normally cost 5 to move into a cell and the Terrain Modifier is MULTIPLY 2 then the cost will be 10. Fractional modifiers are allowed and will decrease the movement cost for values less than 1.0 and increase the cost for values greater than 1.0. Costs are modified depending on the setting of the AI Cell Rounding setting for the map.
  • BLOCK - Blocks movement entirely.
  • FREE - Sets the movement cost for the cell to zero(0.0).

Using the BLOCK Terrain Modifier Type, or setting Token Modifier value for the ADD and MULTIPLY types to a sufficiently high number, will effectively block movement and make tokens go around the obstacle. This is useful for things like an arrow slit, window, lava, etc. Any token can have this modifier which means you can set NPC tokens so PCs must go around them or stamp tokens on the object layer like oil or water. You can also place tokens on the hidden layer to denote difficult terrain.

To set the terrain modifier of a token, open the Token Editor by double clicking the token or accessing it via the right-click menu. Navigate to the Config tab and set the Terrain Modifier value and type. You can also set the token opacity from here, which may be useful for creating translucent terrain markers.

Once created, tokens with Terrain Modifiers can be placed on any layer (including the hidden layer) and still affect the movement of other tokens.

Ignoring Terrain Modifiers

Tokens representing characters or other things that move can also be set to ignore one or more Terrain Modifier Types. On the same Config tab is a list of the Terrain Modifier Types that can be selected which will be ignored by that token. Hold down the Ctrl key while clicking to select more than one type to ignore.

Example map using AI

Left: Setting up a map with vision blocking and terrain modifiers for use with AI pathfinding. Right: A token being moved across the sample map with AI enabled.

The sample map pictured was created by creating a large block of VBL (the blue area) and removing squares of it by holding down the shift key while placing rectangles of VBL. There is also VBL on the stamped steps as well to make the PCs navigate them as they should.

The Map Units are set to '1' on this map to make it easy to see the multiplier at work. The staircase stamp has a terrain value of 2 as do the other steps in the horizontal corridor (note the image under 'Using Terrain Modifiers'). If the map units were set to '5', a terrain modifier of 2 would make the steps cost 10 units to enter.

With the movement AI enabled, the PC can be dragged anywhere but should go around VBL and suffer appropriate movement penalties when passing over tokens with a Movement Modifier.

Overriding AI

But I want to jump in the lava pit!

If you absolutely, positively, despite all warnings to the contrary want to enter difficult terrain, you can use the spacebar to set a waypoint to force the path. You can also use this to get into a more advantageous attack position even over difficult terrain.

Limitations

There are a few limitations to the movement AI:

  • Pathfinding only works on maps with a grid type set.
  • The token being moved cannot be free-size and must be snap to grid.
  • Tokens with Terrain Modifiers must be set to a named size (e.g. Medium or Large) and cannot be set to Free Size or they will not work.
  • You can't block movement unless you use both MBL and VBL.
  • No macros exist to access AI features, nor server options to force players to use this mode of moving tokens.
  • There are no fractional (e.g. 2.5x) or arbitrary (e.g. +5 units) terrain modifiers at this time, only an integer multiplier. As of 1.5.11, fractional modifiers can be used for both Multiply and Add types.
  • If your rule system states that the square on either side must be open in order to move diagonally then you will need to use the spacebar to set a waypoint to navigate corners.
  • If a token is dragged to an area to which no path can be found then no path at all will be shown. You can still move your token to the new location, but if the token is dropped by a player into such a square it might become invisible to them, and number of cells moved will show as 0.
  • With MapTool allowing unbounded/nearly infinite map space, we had to include a timeout to prevent an infinite search. When moving a token on a very complex path or where no path is available, MapTool may seemingly hang several seconds as it searches for a path before placing a token.

Languages:  English  • 日本語