Bridges over water

44tim44

Blaze Red & Lush Green Developer
Member
Joined
Apr 4, 2017
Posts
9
I'm unsure if this is a bug or intended behavior, but I'm having troubles with bridges over water.
Despite having Terrain Tag: 13 on the bridge, the water on the layer below still takes priority, which means all bridges are surfable.
(I know there's a workaround by not having water on the layer beneath the bridge, but I am using multiple animated tiles for my water, and my bridges are semi transparent, so it'd require a ridiculous amount of work to create jigsawed tiles for every possible combination of "bridge+animated water"-tile.)


This part of Game_Map has a check for the Neutral Terrain Tag, but the engine seems to ignore it.
Code:
# If already on water, only allow movement to another water tile
elsif self_event!=nil && PBTerrain.isJustWater?(@terrain_tags[tile_id])
	for j in [2, 1, 0]
		facing_tile_id=data[newx, newy, j]
		return false if facing_tile_id==nil
							#Right Here VVVVV
		if @terrain_tags[facing_tile_id]!=0 && @terrain_tags[facing_tile_id]!=PBTerrain::Neutral
			return PBTerrain.isJustWater?(@terrain_tags[facing_tile_id])
		end
	end
	return false

EDIT:

I also found the potential fix, since it seems this bug did not occur in v15 and earlier:
The line I've commented out is the culprit. By commenting the line out, the behavior I expected returned. The player could no longer surf on the bridge on a higher layer with Terrain Tag: 13
Code:
def terrain_tag(x, y, countBridge=false)
	if @map_id != 0
		for i in [2, 1, 0]
			tile_id = data[x, y, i]
			next if tile_id && PBTerrain.isBridge?(@terrain_tags[tile_id]) && $PokemonGlobal && $PokemonGlobal.bridge==0 && !countBridge
			if tile_id == nil
				return 0
			elsif @terrain_tags[tile_id] && @terrain_tags[tile_id] > 0 #&& @terrain_tags[tile_id]!=PBTerrain::Neutral #44tim44 Edit
				return @terrain_tags[tile_id]
			end
		end
	end
	return 0
end

Basically it seems to be like this:
If the Terrain Tag: 13 is detected, the above code returns 0 instead of 13, which makes the code in the top box never run into having to consider TT13, it therefor never stops the player from surfing onto the tile.
 
Last edited:

44tim44

Blaze Red & Lush Green Developer
Member
Joined
Apr 4, 2017
Posts
9
Ah, okay, so any terrain tag outside the reserved ones already in use, will work, to override a lower layer terrain tag?
Awesome, thank you!
 
Top