FindPathExplanation

From The Battle for Wesnoth Wiki
Revision as of 11:32, 22 July 2019 by Octalot (talk | contribs) (Illustration of [find_path]'s results, with image hotlinked from Github)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

An illustrated example of the [find_path] WML tag's results.

61628440-92323280-ac82-11e9-87b3-a6fc4e5442cc.png

Imagine an Elvish Scout standing on the Player 1 start, this unit has 9MP and needs 3MP for each shallow water tile, so it can reach every village without needing a multi-turn move.

If [find_path] is used with a terrain filter that matches villages, each of these villages might be considered to be the "nearest":

  • "lake" is 3 hexes, 7 MP and 4 steps away
  • "spur" is 5 hexes, 5 MP and 6 steps away
  • "u_turn" is 2 hexes, 8 MP and 9 steps away

The hexes is best explained by the U-turn village - although it needs a lot of movement points, the village is only 2 hexes away from Player 1's start.

The steps is the length of the path.step array, which always includes the starting hex.