Essentials Docs Wiki

The Essentials wiki has moved and is now at: Essentials Engine wiki

This wiki will no longer be updated.

READ MORE

Essentials Docs Wiki
Advertisement
Bridge

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; you can use pbBridgeOn(3) to set it to a different number). 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 $PokemonGlobal.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 pbBridgeOn event.

The value of $PokemonGlobal.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.
  • While not 0, the player's reflection 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.

Bridge tiles

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 (although if you put them over other tiles with their own terrain tags, e.g. water, you will need to give the bridge tiles an unused terrain tag such as 42 to override that of the tiles beneath).

Limitations and bugs

The following only apply to bridges which can be passed both over and under.

  • 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.

Tips

  • 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, 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.
Advertisement