This article describes bridges, specifically the type where the player can pass over them and underneath them.
Bridges used as decoration only (i.e. ones which can either only be walked over or only be walked under) can easily be mapped without any special consideration, and this article does not apply to them.
How bridges work
Any bridge which can be passed both over and under should have a set of events at both ends of it, which change the bridge's properties depending on whether the player is about to travel over the bridge. These events should each run one of two methods, and should trigger when the player steps on them.
If the player is about to pass over a bridge, the method
pbBridgeOn should be run. This sets the priority of the bridge tiles to 0 (i.e. they appear below the player), and sets
$PokemonMap.bridge to a number which represents the height of the bridge in tiles (default 2). The bridge in the screenshot above is 2 tiles high.
If the player has finished passing over a bridge, the method
pbBridgeOff should be run. This resets the priority of the bridge tiles to 4 (i.e. they appear above the player), and sets
$PokemonMap.bridge to 0.
For convenience, each end of a bridge should have two sets of events, one nearer the bridge which runs
pbBridgeOn, and one further away which runs
pbBridgeOff. They should be positioned in such a way that it is impossible for the player to not step on one of each type of event, and also be impossible for the player to approach the bridge without having last stepped on a
The value of
$PokemonMap.bridge has a number of effects, as follows:
- While 0, the passability of tiles with the terrain tag "Bridge" is ignored. This allows movement beneath the bridge as if it didn't exist.
- While 0, certain methods which check the terrain tag of a tile where a bridge is will ignore tiles with the terrain tag "Bridge". This allows the player to surf on water beneath bridges, have wild encounters in tall grass beneath bridges, etc.
Any map transfers will call the method
The terrain tag "Bridge" is number 15. Any tile being used for a bridge which you can pass both over and under should have this terrain tag.
Bridge tiles default to appearing above the player, and are only affected when the player tries to pass over them. The priority of these bridge tiles should be a high number, preferably 4 (which is what the scripts revert bridge tiles to).
These bridge tiles can also be used for bridges which can only be passed underneath. Simply don't put any of the above-mentioned events near them.
Bridge tiles you can only pass over are just like any other normal floor tile. Their terrain tag is irrelevant.
Limitations and bugs
The following only apply to bridges which can be passed both over and under.
- Bridges should not span multiple maps, as the changes made to bridge tiles on one map do not carry over to the next map. The events affecting a particular bridge should be on the same map as that bridge.
- The player's reflection in still water while the player is standing on a bridge is incorrectly positioned/shaded.
- The reflection is only shown if the player is standing on the south-most tiles of that bridge.
- Events will appear above or below bridges depending on whether the player is on a bridge. This will result in a visual glitch if the event is ever on-screen while the player is in the opposite position to it (i.e. the player is on a bridge if the event is beneath one, or the player is off a bridge while the event is on one).
- Events will always ignore bridge tiles for the purpose of moving around, and will instead use the passages of the tiles below the bridge. This can lead to events walking off the sides of bridges, or being unable to move even if they are wanted to.
- Using move routes to control events going over bridges is a solution to this, albeit a limited one. Remember that there may still be a visual glitch as mentioned above, so you probably won't want to do this anyway.
- Since the player is greater than 1 tile tall, bridges should be at least 2 tiles "high".
- A bridge running vertically will be connected to a cliff edge at the southern end, whose tiles will have limited passability (i.e. you couldn't normally walk northwards off them even if there are passable tiles beyond). To get around this, place an invisible tile with terrain tag "Neutral" over those cliff-edge tiles, so that the passability of that invisible tile is considered instead of the cliff-edge tiles. The invisible tile should be fully passable.
- The invisible tiles will be difficult to keep track of, so be very careful when using them and editing maps. If you prefer, you can instead use copies of the cliff-edge tiles which are fully passable, and remember which tile is which.
- Alternatively, use bridge tiles which overlap the land rather than just touch its edge.