manuelVo / foundryvtt-routinglib

A Foundry VTT library that allows other modules perform pathfinding within the scene

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Remove/Reduce Size Check/Squeeze Control

tjlanza opened this issue · comments

Foundry VTT v10.291, Drag Ruler 1.13.1, RoutingLib 1.0.6

According to the documentation (copied below - third column, last item), token size is taken into account when attempting to find a path on a gridless scenes - i.e. tokens cannot "squeeze" through small spaces. Presumably, there is some place in the logic where whether or not there is sufficient space between two walls is evaluated,

I would like the ability to disable (or reduce) the squeezing mechanic size check. The concept and implementation of "squeezing" is very specific to a certain style of game. For games with less rigid movement mechanics, it is not as appropriate and certainly not as a hard limit.

image

I can see a few options here:

  1. Add a hotkey to remove squeeze/size restrictions while dragging. (ALT suppresses pathfinding completely.)
  2. Add a setting to disable squeeze/size restrictions completely.
  3. Add a setting to influence the degree of size control. Admittedly, I'd like to be able to have paths that are too small for some characters to move through (while others can), but I don't want to be bound to a specific games' interpretation of what "enough space" is.

I guess the documentation is a bit misleading here and should be adjusted. In reality, there is no explicit squeezing prevention. Routinglib encourages tokens to keep a certain distance from walls. If it wasn't doing this, routinglib would often calculate paths that walk along the very edge of the wall, which probably isn't what most players want:

A path calculated by routinglib which instructs the tokens to walk extremely close to the wall

As a side effect of forcing tokens to keep a certain distance from walls, if there's a wall to the left that the token needs to keep distance from and a wall to the right the token needs to keep a distance from, there might be space left to move through. This can prevent a token from "squeezing" through a narrow hallway. However, this distance restriction is only enforced around the end points of walls so depending on how the map has been walled the token might be able to squeeze through after all.

I think 1 and 2 aren't the way to go, since you would end up with a path as showin in the image above. 3 seems feasible. IIRC the pathfinder had a hidden setting accomplishing that exact thing when it still was a part of Drag Ruler, but somehow it got lost during the process of converting the pathfinder into a separate module. Also, with 3 in place, you could do 2 by just setting the setting to the right value.

I'd find 2 rather useful honestly. My maps are usually hex grid and mostly outside. On the occasion that I'm inside the hexes don't align real well with walls on the map and I don't necessarily end up with openings for doors and hallways exactly where they need to be for the grid to work properly. My players have basically just gotten used to asking me to move them through a doorway half the time instead of trying to get it to route correctly.

It's important to note that the feature I was discussing before is only present on gridless maps. For gridded maps (whether they are hex or square), the pathfinder works entirely differently and has no feature to keep distance from walls at all. On gridded maps, tokens strictly move from one grid space to the next adjacent space. A collision check is made from the old central location of the token to the new central location and if there is no wall detected for that single check, the move is legal. This means on girdded maps, tokens can already squeeze through infinitely small gaps if the gaps align with the movement of the token. In that sense suggestion 2 is already in place for girdded maps.

3 seems feasible. IIRC the pathfinder had a hidden setting accomplishing that exact thing when it still was a part of Drag Ruler, but somehow it got lost during the process of converting the pathfinder into a separate module.

Oh, good... I would have sworn there was already a setting for it, but couldn't find it so I figured I was wrong. It means I'm not (that particular kind of) crazy.

As a specific case example, I have an elevators prefab that I reuse across a variety of maps, all designed in the same style. The door is sized appropriately for the rest of the scene (visually, line-of-sight, etc), but ends up being too narrow for tokens to get out of with pathfinding. The doorway is somewhat smaller than token set to 1×1, so it very much appears to be functioning as the documentation describes.

Being able to tweak the standoff distance would likely resolve my issue completely.

This feature will be available as a hidden setting starting with routinglib v1.1.0. It can be adjusted by entering game.settings.set("routinglib", "gridlessTokenSizeRatio", NEW_RATIO) into the console. Token sizes will be multiplied by this ratio prior to pathfinding. The setting defaults to 0.9, which matches the previous behavior of routinglib.