FANDOM


Bridge

A bridge which the player can pass over and under.

This page describes bridges, specifically the type where the player can pass over them and underneath them.

Types of bridges

A bridge is one or more tiles which can appear either over or under the player, and this can be altered mid-game by the player's actions (namely, whether they try to walk underneath or across them - events are used to trigger changes in bridge behaviour to allow this). The key is that you can move both above and below a bridge.

If you can only move below the bridge and never on top of it, then that kind of bridge is simply made up of tiles with a high priority (to appear above the player) and terrain tag 13, "Neutral" (to make the game ignore the passability and terrain tag of those tiles).

If you can only move on top of the bridge and never below it, then that kind of bridge is simply the ground. They have priority 0 and terrain tag 0. Note that, if you put one of these bridge tiles on top of another tile which has a non-zero terrain tag (e.g. Surfable water), then you will need to set the terrain tag of the bridge tiles to a non-zero value (except 13, "Neutral") to ensure that the water's terrain tag doesn't "bleed through" the bridge tile and make it behave oddly. Remember that you can use any number as a terrain tag, not just the ones that have special effects, and because it is non-zero and not 13 ("Neutral"), it will be used instead of the water tile's terrain tag.

The rest of this page describes "proper" bridges, i.e. one you can pass both over and under.

Bridge tiles

A bridge which can be passed both over and under needs to appear below or above the player (respectively). What this means is that the bridge tiles need to change their priority mid-game, from 0 (underneath the player) to a high number (above the player; priority 4 is used for this) and back depending on a trigger (see below). This should also affect whether the player obeys or ignores the passability of the bridge tiles.

To achieve this, all bridge tiles should be given terrain tag 15 ("Bridge"). The trigger which changes their priorities (see below) affects any tiles with this terrain tag.

Bridge tiles should be set up in the Database to appear above the player (i.e. priority 4). However, their passability should be set up as though the player is walking over them and is affected by how the bridge tiles say the player is allowed to move. Be sure to make the bridge tiles not passable in the directions off the sides of the bridge - you shouldn't be able to walk off the bridge except at the ends which connect to land.

The above means that, by default and without any triggers to alter bridge behaviour, bridge tiles appear above the player and are completely ignored when it comes to deciding passability or terrain tag. It is the tiles beneath the bridge that matter when deciding these things.

This also means that, to save tileset space, you can also use these bridge tiles to draw bridges that can only be passed beneath - simply don't have any bridge behaviour-altering triggers for them (see below).

Bridge trigger events

The trigger that causes bridge tiles to change their behaviour is to step on an event which runs a particular script. In fact, there are two such scripts:

  • pbBridgeOn - Tells the game that the player is about to move over a bridge. Makes bridge tiles have priority 0 and their passability enabled.
  • pbBridgeOff - Tells the game that the player is no longer moving over a bridge. Makes the bridge tiles have priority 4 and their passability ignored.

These scripts go into events which are triggered by Player Touch, i.e. when the player walks over it.

The exact positioning of these events will depend on how the map containing the bridge is laid out. They should be positioned to obey these rules:

  • The most recent script to be run before attempting to go over a bridge must be pbBridgeOn.
  • The most recent script to be run before attempting to go under a bridge must be pbBridgeOff.

In practice, each bridge trigger event will only have one or the other script in it. The pbBridgeOn events will be clustered around the ends of the bridge and make it impossible to approach it without stepping on at least one of them. There will then be a cluster of pbBridgeOff events outside those, making it impossible to walk away from the ends of the bridge without stepping on at least one of them after any of the pbBridgeOn events you will also step on.

There is no harm in stepping on a pbBridgeOn event if you have already most recently stepped on another (or the same) pbBridgeOn event. The same goes for pbBridgeOff.

The code behind bridges

The scripts pbBridgeOn and pbBridgeOff both affect the value of the variable $PokemonGlobal.bridge. If this is 0, then bridges appear above the player and can be passed under. IF this is 1 or greater, then bridges appear below the player and can be passed over.

This variable is a number rather than true/false because it represents the height of the bridge. Typically this height is the number of cliff layers between the bridge's level and the level of the ground beneath it. The default is 2, but you can change it by using pbBridgeOn(3) or similar. The height of the bridge in the screenshot above is 2.

The value of $PokemonGlobal.bridge has a number of effects, as follows:

  • While 0, tiles with the terrain tag "Bridge" have priority 4, and their passabilities are ignored. This allows movement beneath the bridge as if it didn't exist.
  • While greater than 0, tiles with the terrain tag "Bridge" have priority 0, and their passabilities do matter. This allows movement over the bridge.
  • While 0, certain methods which check what the terrain tag of a map tile is will ignore any 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.
  • While greater than 0, the player's reflection in still water will be coloured a solid blue and be shifted south by half a tile times the bridge's height. This only applies if the setting ENABLESHADING is false; if it is true, then the player's reflection disappears instead (due to a clash between making the reflection solid blue and tinting it according to the time of day).

Any map transfers will call the method pbBridgeOff.

Limitations and bugs

  • 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 while 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 you want them 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.

Tips

  • Since the player is more than 1 tile tall, bridges should be at least 2 tiles "high". This is why the default bridge height is 2.
  • 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, either use duplicates of northern cliff-edge tiles which are passable to the north, or draw over the impassable cliff-edge tiles with an invisible tile that is passable.
    • Be sure to keep track of these tiles. You will need to either ensure you're using the correct cliff tiles, or be very careful when placing the invisible tiles.
Community content is available under CC-BY-SA unless otherwise noted.