Added class GameData::TerrainTag

This commit is contained in:
Maruno17
2021-03-29 17:19:05 +01:00
parent e1ffd44e67
commit cd62ba840c
17 changed files with 336 additions and 260 deletions

View File

@@ -147,8 +147,7 @@ class Game_Map
bit = (1 << (d / 2 - 1)) & 0x0f
for event in events.values
next if event.tile_id <= 0
terrain = @terrain_tags[event.tile_id]
next if terrain == PBTerrain::Neutral
next if GameData::TerrainTag.try_get(@terrain_tags[event.tile_id]).ignore_passability
next if event == self_event
next if event.x != x || event.y != y
next if event.through
@@ -185,48 +184,35 @@ class Game_Map
return false if !valid?(newx, newy)
for i in [2, 1, 0]
tile_id = data[x, y, i]
terrain = @terrain_tags[tile_id]
terrain = GameData::TerrainTag.try_get(@terrain_tags[tile_id])
passage = @passages[tile_id]
# If already on water, only allow movement to another water tile
if self_event!=nil && PBTerrain.isJustWater?(terrain)
if self_event != nil && terrain.can_surf_freely
for j in [2, 1, 0]
facing_tile_id = data[newx, newy, j]
return false if facing_tile_id==nil
facing_terrain = @terrain_tags[facing_tile_id]
if facing_terrain!=0 && facing_terrain!=PBTerrain::Neutral
return PBTerrain.isJustWater?(facing_terrain)
return false if facing_tile_id == nil
facing_terrain = GameData::TerrainTag.try_get(@terrain_tags[facing_tile_id])
if facing_terrain.id != :None && !facing_terrain.ignore_passability
return facing_terrain.can_surf_freely
end
end
return false
# Can't walk onto ice
elsif PBTerrain.isIce?(terrain)
elsif terrain.ice
return false
elsif self_event!=nil && self_event.x==x && self_event.y==y
elsif self_event != nil && self_event.x == x && self_event.y == y
# Can't walk onto ledges
for j in [2, 1, 0]
facing_tile_id = data[newx, newy, j]
return false if facing_tile_id==nil
facing_terrain = @terrain_tags[facing_tile_id]
if facing_terrain!=0 && facing_terrain!=PBTerrain::Neutral
return false if PBTerrain.isLedge?(facing_terrain)
break
end
end
# Regular passability checks
if terrain!=PBTerrain::Neutral
if passage & bit != 0 || passage & 0x0f == 0x0f
return false
elsif @priorities[tile_id] == 0
return true
end
return false if facing_tile_id == nil
return false if GameData::TerrainTag.try_get(@terrain_tags[facing_tile_id]).ledge
break
end
end
# Regular passability checks
elsif terrain!=PBTerrain::Neutral
if passage & bit != 0 || passage & 0x0f == 0x0f
return false
elsif @priorities[tile_id] == 0
return true
end
if !terrain || !terrain.ignore_passability
return false if passage & bit != 0 || passage & 0x0f == 0x0f
return true if @priorities[tile_id] == 0
end
end
return true
@@ -236,27 +222,25 @@ class Game_Map
bit = (1 << (d / 2 - 1)) & 0x0f
for i in [2, 1, 0]
tile_id = data[x, y, i]
terrain = @terrain_tags[tile_id]
terrain = GameData::TerrainTag.try_get(@terrain_tags[tile_id])
passage = @passages[tile_id]
# Ignore bridge tiles if not on a bridge
next if PBTerrain.isBridge?(terrain) && $PokemonGlobal.bridge==0
# Make water tiles passable if player is surfing
if $PokemonGlobal.surfing && PBTerrain.isPassableWater?(terrain)
return true
# Prevent cycling in really tall grass/on ice
elsif $PokemonGlobal.bicycle && PBTerrain.onlyWalk?(terrain)
return false
# Depend on passability of bridge tile if on bridge
elsif PBTerrain.isBridge?(terrain) && $PokemonGlobal.bridge>0
return (passage & bit == 0 && passage & 0x0f != 0x0f)
# Regular passability checks
elsif terrain!=PBTerrain::Neutral
if passage & bit != 0 || passage & 0x0f == 0x0f
return false
elsif @priorities[tile_id] == 0
return true
if terrain
# Ignore bridge tiles if not on a bridge
next if terrain.bridge && $PokemonGlobal.bridge == 0
# Make water tiles passable if player is surfing
return true if $PokemonGlobal.surfing && terrain.can_surf && !terrain.waterfall
# Prevent cycling in really tall grass/on ice
return false if $PokemonGlobal.bicycle && terrain.must_walk
# Depend on passability of bridge tile if on bridge
if terrain.bridge && $PokemonGlobal.bridge > 0
return (passage & bit == 0 && passage & 0x0f != 0x0f)
end
end
# Regular passability checks
if !terrain || !terrain.ignore_passability
return false if passage & bit != 0 || passage & 0x0f == 0x0f
return true if @priorities[tile_id] == 0
end
end
return true
end
@@ -268,15 +252,13 @@ class Game_Map
for event in events.values
next if event == self_event || event.tile_id < 0 || event.through
next if event.x != x || event.y != y
terrain = @terrain_tags[event.tile_id]
next if terrain == PBTerrain::Neutral
next if GameData::TerrainTag.try_get(@terrain_tags[event.tile_id]).ignore_passability
return false if @passages[event.tile_id] & 0x0f != 0
return true if @priorities[event.tile_id] == 0
end
for i in [2, 1, 0]
tile_id = data[x, y, i]
terrain = @terrain_tags[tile_id]
next if terrain == PBTerrain::Neutral
next if GameData::TerrainTag.try_get(@terrain_tags[tile_id]).ignore_passability
return false if @passages[tile_id] & 0x0f != 0
return true if @priorities[tile_id] == 0
end
@@ -286,7 +268,8 @@ class Game_Map
def bush?(x,y)
for i in [2, 1, 0]
tile_id = data[x, y, i]
return false if PBTerrain.isBridge?(@terrain_tags[tile_id]) && $PokemonGlobal.bridge>0
return false if GameData::TerrainTag.try_get(@terrain_tags[tile_id]).bridge &&
$PokemonGlobal.bridge > 0
return true if @passages[tile_id] & 0x40 == 0x40
end
return false
@@ -295,9 +278,9 @@ class Game_Map
def deepBush?(x,y)
for i in [2, 1, 0]
tile_id = data[x, y, i]
terrain = @terrain_tags[tile_id]
return false if $PokemonGlobal.bridge>0 && PBTerrain.isBridge?(terrain)
return true if terrain==PBTerrain::TallGrass && @passages[tile_id] & 0x40 == 0x40
terrain = GameData::TerrainTag.try_get(@terrain_tags[tile_id])
return false if terrain.bridge && $PokemonGlobal.bridge > 0
return true if terrain.deep_bush && @passages[tile_id] & 0x40 == 0x40
end
return false
end
@@ -312,14 +295,16 @@ class Game_Map
end
def terrain_tag(x,y,countBridge=false)
return 0 if !valid?(x, y)
for i in [2, 1, 0]
tile_id = data[x, y, i]
terrain = @terrain_tags[tile_id]
next if !countBridge && PBTerrain.isBridge?(terrain) && $PokemonGlobal.bridge==0
return terrain if terrain > 0 && terrain!=PBTerrain::Neutral
if valid?(x, y)
for i in [2, 1, 0]
tile_id = data[x, y, i]
terrain = GameData::TerrainTag.try_get(@terrain_tags[tile_id])
next if terrain.id == :None || terrain.ignore_passability
next if !countBridge && terrain.bridge && $PokemonGlobal.bridge == 0
return terrain
end
end
return 0
return GameData::TerrainTag.get(:None)
end
def check_event(x,y)

View File

@@ -223,13 +223,13 @@ class PokemonMapFactory
def getFacingTerrainTag(dir=nil,event=nil)
tile = getFacingTile(dir,event)
return 0 if !tile
return GameData::TerrainTag.get(:None) if !tile
return getTerrainTag(tile[0],tile[1],tile[2])
end
def getTerrainTagFromCoords(mapid,x,y,countBridge=false)
tile = getRealTilePos(mapid,x,y)
return 0 if !tile
return GameData::TerrainTag.get(:None) if !tile
return getTerrainTag(tile[0],tile[1],tile[2])
end

View File

@@ -23,11 +23,10 @@ class Game_Player < Game_Character
return false if $game_temp.in_menu || $game_temp.in_battle ||
@move_route_forcing || $game_temp.message_window_showing ||
pbMapInterpreterRunning?
terrain = pbGetTerrainTag
input = ($PokemonSystem.runstyle == 1) ^ Input.press?(Input::SPECIAL)
return input && $PokemonGlobal.runningShoes && !jumping? &&
!$PokemonGlobal.diving && !$PokemonGlobal.surfing &&
!$PokemonGlobal.bicycle && !PBTerrain.onlyWalk?(terrain)
!$PokemonGlobal.bicycle && !pbGetTerrainTag.must_walk
end
def pbIsRunning?
@@ -53,7 +52,7 @@ class Game_Player < Game_Character
end
def update_command
if PBTerrain.isIce?(pbGetTerrainTag)
if pbGetTerrainTag.ice
self.move_speed = 4 # Sliding on ice
elsif !moving? && !@move_route_forcing && $PokemonGlobal
if $PokemonGlobal.bicycle

View File

@@ -502,9 +502,10 @@ class CustomTilemap
sprite.color = @color
getAutotile(sprite,id)
end
if PBTerrain.hasReflections?(terrain)
terrain_tag_data = GameData::TerrainTag.try_get(terrain)
if terrain_tag_data.shows_reflections
spriteZ = -100
elsif $PokemonGlobal.bridge>0 && PBTerrain.isBridge?(terrain)
elsif $PokemonGlobal.bridge > 0 && terrain_tag_data.bridge
spriteZ = 1
else
spriteZ = (priority==0) ? 0 : ypos+priority*32+32
@@ -610,7 +611,7 @@ class CustomTilemap
for x in 0...xsize
id = @map_data[x, y, z]
next if id == 0
next if @priorities[id] == 0 && !PBTerrain.hasReflections?(@terrain_tags[id])
next if @priorities[id] == 0 && !GameData::TerrainTag.try_get(@terrain_tags[id]).shows_reflections
@priotiles[[x, y]] = [] if !@priotiles[[x, y]]
@priotiles[[x, y]].push([z, id])
end
@@ -662,7 +663,7 @@ class CustomTilemap
for z in 0...zsize
id = @map_data[x, y, z]
next if id == 0 || id >= 384 # Skip non-autotiles
next if @priorities[id] != 0 || PBTerrain.hasReflections?(@terrain_tags[id])
next if @priorities[id] != 0 || GameData::TerrainTag.try_get(@terrain_tags[id]).shows_reflections
next if @framecount[id / 48 - 1] < 2
@prioautotiles[[x, y]] = true
break
@@ -727,7 +728,7 @@ class CustomTilemap
id = mapdata[x, y, z]
next if !id || id < 48 || id >= 384 # Skip non-autotiles
prioid = @priorities[id]
next if prioid != 0 || PBTerrain.hasReflections?(@terrain_tags[id])
next if prioid != 0 || GameData::TerrainTag.try_get(@terrain_tags[id]).shows_reflections
fcount = @framecount[id / 48 - 1]
next if !fcount || fcount < 2
overallcount += 1
@@ -740,7 +741,7 @@ class CustomTilemap
id = mapdata[x, y, z]
next if !id || id < 48
prioid = @priorities[id]
next if prioid != 0 || PBTerrain.hasReflections?(@terrain_tags[id])
next if prioid != 0 || GameData::TerrainTag.try_get(@terrain_tags[id]).shows_reflections
if overallcount > 2000
xpos = (x * twidth) - @oxLayer0
ypos = (y * theight) - @oyLayer0
@@ -798,7 +799,7 @@ class CustomTilemap
z += 1
next if !id || id < 48
prioid = @priorities[id]
next if prioid != 0 || PBTerrain.hasReflections?(@terrain_tags[id])
next if prioid != 0 || GameData::TerrainTag.try_get(@terrain_tags[id]).shows_reflections
if id >= 384 # Tileset tiles
temprect.set(((id - 384) & 7) * @tileSrcWidth,
((id - 384) >> 3) * @tileSrcHeight,
@@ -859,7 +860,7 @@ class CustomTilemap
for x in xrange
xpos = (x * twidth) - @oxLayer0
id = mapdata[x, y, z]
next if id == 0 || @priorities[id] != 0 || PBTerrain.hasReflections?(@terrain_tags[id])
next if id == 0 || @priorities[id] != 0 || GameData::TerrainTag.try_get(@terrain_tags[id]).shows_reflections
if id >= 384 # Tileset tiles
tmprect.set(((id - 384) & 7) * @tileSrcWidth,
((id - 384) >> 3) * @tileSrcHeight,
@@ -930,7 +931,7 @@ class CustomTilemap
for x in minX..maxX
id = @map_data[x, y, z]
next if id == 0
next if @priorities[id] == 0 && !PBTerrain.hasReflections?(@terrain_tags[id])
next if @priorities[id] == 0 && !GameData::TerrainTag.try_get(@terrain_tags[id]).shows_reflections
@priotilesfast.push([x, y, z, id])
end
end

View File

@@ -490,7 +490,7 @@ class Interpreter
when 2 then value = character.direction # direction
when 3 then value = character.screen_x # screen x-coordinate
when 4 then value = character.screen_y # screen y-coordinate
when 5 then value = character.terrain_tag # terrain tag
when 5 then value = character.terrain_tag.id_number # terrain tag
end
end
when 7 # other

View File

@@ -1,80 +0,0 @@
#===============================================================================
# Terrain tags
#===============================================================================
module PBTerrain
None = 0
Ledge = 1
Grass = 2
Sand = 3
Rock = 4
DeepWater = 5
StillWater = 6
Water = 7
Waterfall = 8
WaterfallCrest = 9
TallGrass = 10
UnderwaterGrass = 11
Ice = 12
Neutral = 13
SootGrass = 14
Bridge = 15
Puddle = 16
module_function
def isSurfable?(tag)
return isWater?(tag)
end
def isWater?(tag)
return [Water, StillWater, DeepWater, WaterfallCrest, Waterfall].include?(tag)
end
def isPassableWater?(tag)
return [Water, StillWater, DeepWater, WaterfallCrest].include?(tag)
end
def isJustWater?(tag)
return [Water, StillWater, DeepWater].include?(tag)
end
def isDeepWater?(tag)
return tag == DeepWater
end
def isWaterfall?(tag)
return [WaterfallCrest, Waterfall].include?(tag)
end
def isGrass?(tag)
return [Grass, TallGrass, UnderwaterGrass, SootGrass].include?(tag)
end
def isJustGrass?(tag) # The Poké Radar only works in these tiles
return [Grass, SootGrass].include?(tag)
end
def isLedge?(tag)
return tag == Ledge
end
def isIce?(tag)
return tag == Ice
end
def isBridge?(tag)
return tag == Bridge
end
def hasReflections?(tag)
return [StillWater, Puddle].include?(tag)
end
def onlyWalk?(tag)
return [TallGrass, Ice].include?(tag)
end
def isDoubleWildBattle?(tag)
return tag == TallGrass
end
end

View File

@@ -0,0 +1,194 @@
module GameData
class TerrainTag
attr_reader :id
attr_reader :id_number
attr_reader :real_name
attr_reader :can_surf
attr_reader :waterfall # The main part only, not the crest
attr_reader :waterfall_crest
attr_reader :can_fish
attr_reader :can_dive
attr_reader :deep_bush
attr_reader :shows_grass_rustle
attr_reader :land_wild_encounters
attr_reader :double_wild_encounters
attr_reader :battle_environment
attr_reader :ledge
attr_reader :ice
attr_reader :bridge
attr_reader :shows_reflections
attr_reader :must_walk
attr_reader :ignore_passability
DATA = {}
extend ClassMethods
include InstanceMethods
# @param other [Symbol, self, String, Integer]
# @return [self]
def self.try_get(other)
return self.get(:None) if other.nil?
validate other => [Symbol, self, String, Integer]
return other if other.is_a?(self)
other = other.to_sym if other.is_a?(String)
return (self::DATA.has_key?(other)) ? self::DATA[other] : self.get(:None)
end
def self.load; end
def self.save; end
def initialize(hash)
@id = hash[:id]
@id_number = hash[:id_number]
@real_name = hash[:id].to_s || "Unnamed"
@can_surf = hash[:can_surf] || false
@waterfall = hash[:waterfall] || false
@waterfall_crest = hash[:waterfall_crest] || false
@can_fish = hash[:can_fish] || false
@can_dive = hash[:can_dive] || false
@deep_bush = hash[:deep_bush] || false
@shows_grass_rustle = hash[:shows_grass_rustle] || false
@land_wild_encounters = hash[:land_wild_encounters] || false
@double_wild_encounters = hash[:double_wild_encounters] || false
@battle_environment = hash[:battle_environment]
@ledge = hash[:ledge] || false
@ice = hash[:ice] || false
@bridge = hash[:bridge] || false
@shows_reflections = hash[:shows_reflections] || false
@must_walk = hash[:must_walk] || false
@ignore_passability = hash[:ignore_passability] || false
end
def can_surf_freely
return @can_surf && !@waterfall && !@waterfall_crest
end
end
end
#===============================================================================
GameData::TerrainTag.register({
:id => :None,
:id_number => 0
})
GameData::TerrainTag.register({
:id => :Ledge,
:id_number => 1,
:ledge => true
})
GameData::TerrainTag.register({
:id => :Grass,
:id_number => 2,
:shows_grass_rustle => true,
:land_wild_encounters => true,
:battle_environment => :Grass
})
GameData::TerrainTag.register({
:id => :Sand,
:id_number => 3,
:battle_environment => :Sand
})
GameData::TerrainTag.register({
:id => :Rock,
:id_number => 4,
:battle_environment => :Rock
})
GameData::TerrainTag.register({
:id => :DeepWater,
:id_number => 5,
:can_surf => true,
:can_fish => true,
:can_dive => true,
:battle_environment => :MovingWater
})
GameData::TerrainTag.register({
:id => :StillWater,
:id_number => 6,
:can_surf => true,
:can_fish => true,
:battle_environment => :StillWater,
:shows_reflections => true
})
GameData::TerrainTag.register({
:id => :Water,
:id_number => 7,
:can_surf => true,
:can_fish => true,
:battle_environment => :MovingWater
})
GameData::TerrainTag.register({
:id => :Waterfall,
:id_number => 8,
:can_surf => true,
:waterfall => true
})
GameData::TerrainTag.register({
:id => :WaterfallCrest,
:id_number => 9,
:can_surf => true,
:can_fish => true,
:waterfall_crest => true
})
GameData::TerrainTag.register({
:id => :TallGrass,
:id_number => 10,
:deep_bush => true,
:land_wild_encounters => true,
:double_wild_encounters => true,
:battle_environment => :TallGrass,
:must_walk => true
})
GameData::TerrainTag.register({
:id => :UnderwaterGrass,
:id_number => 11,
:land_wild_encounters => true
})
GameData::TerrainTag.register({
:id => :Ice,
:id_number => 12,
:battle_environment => :Ice,
:ice => true,
:must_walk => true
})
GameData::TerrainTag.register({
:id => :Neutral,
:id_number => 13,
:ignore_passability => true
})
# NOTE: This is referenced by ID in an Events.onStepTakenFieldMovement proc that
# adds soot to the Soot Sack if the player walks over one of these tiles.
GameData::TerrainTag.register({
:id => :SootGrass,
:id_number => 14,
:shows_grass_rustle => true,
:land_wild_encounters => true,
:battle_environment => :Grass
})
GameData::TerrainTag.register({
:id => :Bridge,
:id_number => 15,
:bridge => true
})
GameData::TerrainTag.register({
:id => :Puddle,
:id_number => 16,
:battle_environment => :Puddle,
:shows_reflections => true
})

View File

@@ -304,40 +304,34 @@ end
# Gather soot from soot grass
Events.onStepTakenFieldMovement += proc { |_sender,e|
event = e[0] # Get the event affected by field movement
event = e[0] # Get the event affected by field movement
thistile = $MapFactory.getRealTilePos(event.map.map_id,event.x,event.y)
map = $MapFactory.getMap(thistile[0])
sootlevel = -1
for i in [2, 1, 0]
tile_id = map.data[thistile[1],thistile[2],i]
next if tile_id==nil
if map.terrain_tags[tile_id]==PBTerrain::SootGrass
sootlevel = i
break
end
end
if sootlevel>=0 && GameData::Item.exists?(:SOOTSACK)
$PokemonGlobal.sootsack = 0 if !$PokemonGlobal.sootsack
# map.data[thistile[1],thistile[2],sootlevel]=0
if event==$game_player && $PokemonBag.pbHasItem?(:SOOTSACK)
next if tile_id == nil
next if GameData::TerrainTag.try_get(map.terrain_tags[tile_id]).id != :SootGrass
if event == $game_player && GameData::Item.exists?(:SOOTSACK) && $PokemonBag.pbHasItem?(:SOOTSACK)
$PokemonGlobal.sootsack = 0 if !$PokemonGlobal.sootsack
$PokemonGlobal.sootsack += 1
end
# map.data[thistile[1], thistile[2], i] = 0
# $scene.createSingleSpriteset(map.map_id)
break
end
}
# Show grass rustle animation, and auto-move the player over waterfalls and ice
Events.onStepTakenFieldMovement += proc { |_sender,e|
event = e[0] # Get the event affected by field movement
Events.onStepTakenFieldMovement += proc { |_sender, e|
event = e[0] # Get the event affected by field movement
if $scene.is_a?(Scene_Map)
currentTag = pbGetTerrainTag(event)
if PBTerrain.isJustGrass?(pbGetTerrainTag(event,true)) # Won't show if under bridge
$scene.spriteset.addUserAnimation(Settings::GRASS_ANIMATION_ID,event.x,event.y,true,1)
elsif event==$game_player
if currentTag==PBTerrain::WaterfallCrest
# Descend waterfall, but only if this event is the player
if pbGetTerrainTag(event, true).shows_grass_rustle # Won't show if under bridge
$scene.spriteset.addUserAnimation(Settings::GRASS_ANIMATION_ID, event.x, event.y, true, 1)
elsif event == $game_player
currentTag = pbGetTerrainTag(event)
if currentTag.waterfall_crest
pbDescendWaterfall(event)
elsif PBTerrain.isIce?(currentTag) && !$PokemonGlobal.sliding
elsif currentTag.ice && !$PokemonGlobal.sliding
pbSlideOnIce(event)
end
end
@@ -599,19 +593,17 @@ end
def pbGetTerrainTag(event=nil,countBridge=false)
event = $game_player if !event
return 0 if !event
return GameData::TerrainTag.get(:None) if !event
if $MapFactory
return $MapFactory.getTerrainTag(event.map.map_id,event.x,event.y,countBridge)
end
$game_map.terrain_tag(event.x,event.y,countBridge)
return $game_map.terrain_tag(event.x,event.y,countBridge)
end
def pbFacingTerrainTag(event=nil,dir=nil)
if $MapFactory
return $MapFactory.getFacingTerrainTag(dir,event)
end
return $MapFactory.getFacingTerrainTag(dir,event) if $MapFactory
event = $game_player if !event
return 0 if !event
return GameData::TerrainTag.get(:None) if !event
facing = pbFacingTile(dir,event)
return $game_map.terrain_tag(facing[1],facing[2])
end
@@ -762,7 +754,7 @@ end
# Player/event movement in the field
#===============================================================================
def pbLedge(_xOffset,_yOffset)
if PBTerrain.isLedge?(pbFacingTerrainTag)
if pbFacingTerrainTag.ledge
if pbJumpToward(2,true)
$scene.spriteset.addUserAnimation(Settings::DUST_ANIMATION_ID,$game_player.x,$game_player.y,true,1)
$game_player.increase_steps
@@ -776,7 +768,7 @@ end
def pbSlideOnIce(event=nil)
event = $game_player if !event
return if !event
return if !PBTerrain.isIce?(pbGetTerrainTag(event))
return if !pbGetTerrainTag(event).ice
$PokemonGlobal.sliding = true
direction = event.direction
oldwalkanime = event.walk_anime
@@ -784,7 +776,7 @@ def pbSlideOnIce(event=nil)
event.walk_anime = false
loop do
break if !event.passable?(event.x,event.y,direction)
break if !PBTerrain.isIce?(pbGetTerrainTag(event))
break if !pbGetTerrainTag(event).ice
event.move_forward
while event.moving?
pbUpdateSceneMap

View File

@@ -174,17 +174,11 @@ def pbGetEnvironment
else
terrainTag = $game_player.terrain_tag
end
case terrainTag
when PBTerrain::Grass, PBTerrain::SootGrass
ret = (ret == :Forest) ? :ForestGrass : :Grass
when PBTerrain::TallGrass
ret = (ret == :Forest) ? :ForestGrass : :TallGrass
when PBTerrain::Rock then ret = :Rock
when PBTerrain::Sand then ret = :Sand
when PBTerrain::DeepWater, PBTerrain::Water then ret = :MovingWater
when PBTerrain::StillWater then ret = :StillWater
when PBTerrain::Puddle then ret = :Puddle
when PBTerrain::Ice then ret = :Ice
tile_environment = terrainTag.battle_environment
if ret == :Forest && [:Grass, :TallGrass].include?(tile_environment)
ret = :ForestGrass
else
ret = tile_environment if tile_environment
end
return ret
end

View File

@@ -91,9 +91,9 @@ class PokemonEncounters
def encounter_possible_here?
return true if $PokemonGlobal.surfing
terrain_tag = $game_map.terrain_tag($game_player.x, $game_player.y)
return false if PBTerrain.isIce?(terrain_tag)
return false if terrain_tag.ice
return true if has_cave_encounters? # i.e. this map is a cave
return true if PBTerrain.isGrass?(terrain_tag) && has_land_encounters?
return true if has_land_encounters? && terrain_tag.land_wild_encounters
return false
end
@@ -203,7 +203,7 @@ class PokemonEncounters
return false if pbInSafari?
return true if $PokemonGlobal.partner
return false if $Trainer.able_pokemon_count <= 1
return true if PBTerrain.isDoubleWildBattle?(pbGetTerrainTag) && rand(100) < 30
return true if pbGetTerrainTag.double_wild_encounters && rand(100) < 30
return false
end
@@ -242,7 +242,7 @@ class PokemonEncounters
if $PokemonGlobal.surfing
ret = find_valid_encounter_type_for_time(:Water, time)
else # Land/Cave (can have both in the same map)
if has_land_encounters? && PBTerrain.isGrass?($game_map.terrain_tag($game_player.x, $game_player.y))
if has_land_encounters? && $game_map.terrain_tag($game_player.x, $game_player.y).land_wild_encounters
ret = :BugContest if pbInBugContest? && has_encounter_type?(:BugContest)
ret = find_valid_encounter_type_for_time(:Land, time) if !ret
end

View File

@@ -381,11 +381,11 @@ Events.onAction += proc { |_sender, _e|
break
end
if surface_map_id &&
PBTerrain.isDeepWater?($MapFactory.getTerrainTag(surface_map_id, $game_player.x, $game_player.y))
$MapFactory.getTerrainTag(surface_map_id, $game_player.x, $game_player.y).can_dive
pbSurfacing
end
else
pbDive if PBTerrain.isDeepWater?($game_player.terrain_tag)
pbDive if $game_player.terrain_tag.can_dive
end
}
@@ -399,7 +399,7 @@ HiddenMoveHandlers::CanUseMove.add(:DIVE,proc { |move,pkmn,showmsg|
break
end
if !surface_map_id ||
!PBTerrain.isDeepWater?($MapFactory.getTerrainTag(surface_map_id, $game_player.x, $game_player.y))
!$MapFactory.getTerrainTag(surface_map_id, $game_player.x, $game_player.y).can_dive
pbMessage(_INTL("Can't use that here.")) if showmsg
next false
end
@@ -409,7 +409,7 @@ HiddenMoveHandlers::CanUseMove.add(:DIVE,proc { |move,pkmn,showmsg|
pbMessage(_INTL("Can't use that here.")) if showmsg
next false
end
if !PBTerrain.isDeepWater?($game_player.terrain_tag)
if !$game_player.terrain_tag.can_dive
pbMessage(_INTL("Can't use that here.")) if showmsg
next false
end
@@ -727,9 +727,7 @@ def pbEndSurf(_xOffset,_yOffset)
return false if !$PokemonGlobal.surfing
x = $game_player.x
y = $game_player.y
currentTag = $game_map.terrain_tag(x,y)
facingTag = pbFacingTerrainTag
if PBTerrain.isSurfable?(currentTag) && !PBTerrain.isSurfable?(facingTag)
if $game_map.terrain_tag(x,y).can_surf && !pbFacingTerrainTag.can_surf
$PokemonTemp.surfJump = [x,y]
if pbJumpToward(1,false,true)
$game_map.autoplayAsCue
@@ -759,7 +757,7 @@ Events.onAction += proc { |_sender,_e|
next if $PokemonGlobal.surfing
next if GameData::MapMetadata.exists?($game_map.map_id) &&
GameData::MapMetadata.get($game_map.map_id).always_bicycle
next if !PBTerrain.isSurfable?(pbFacingTerrainTag)
next if !pbFacingTerrainTag.can_surf_freely
next if !$game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player)
pbSurf
}
@@ -779,7 +777,7 @@ HiddenMoveHandlers::CanUseMove.add(:SURF,proc { |move,pkmn,showmsg|
pbMessage(_INTL("Let's enjoy cycling!")) if showmsg
next false
end
if !PBTerrain.isSurfable?(pbFacingTerrainTag) ||
if !pbFacingTerrainTag.can_surf_freely ||
!$game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player)
pbMessage(_INTL("No surfing here!")) if showmsg
next false
@@ -914,13 +912,13 @@ def pbAscendWaterfall(event=nil)
oldthrough = event.through
oldmovespeed = event.move_speed
terrain = pbFacingTerrainTag
return if !PBTerrain.isWaterfall?(terrain)
return if !terrain.waterfall && !terrain.waterfall_crest
event.through = true
event.move_speed = 2
loop do
event.move_up
terrain = pbGetTerrainTag(event)
break if !PBTerrain.isWaterfall?(terrain)
break if !terrain.waterfall && !terrain.waterfall_crest
end
event.through = oldthrough
event.move_speed = oldmovespeed
@@ -933,13 +931,13 @@ def pbDescendWaterfall(event=nil)
oldthrough = event.through
oldmovespeed = event.move_speed
terrain = pbFacingTerrainTag
return if !PBTerrain.isWaterfall?(terrain)
return if !terrain.waterfall && !terrain.waterfall_crest
event.through = true
event.move_speed = 2
loop do
event.move_down
terrain = pbGetTerrainTag(event)
break if !PBTerrain.isWaterfall?(terrain)
break if !terrain.waterfall && !terrain.waterfall_crest
end
event.through = oldthrough
event.move_speed = oldmovespeed
@@ -964,16 +962,16 @@ end
Events.onAction += proc { |_sender,_e|
terrain = pbFacingTerrainTag
if terrain==PBTerrain::Waterfall
if terrain.waterfall
pbWaterfall
elsif terrain==PBTerrain::WaterfallCrest
elsif terrain.waterfall_crest
pbMessage(_INTL("A wall of water is crashing down with a mighty roar."))
end
}
HiddenMoveHandlers::CanUseMove.add(:WATERFALL,proc { |move,pkmn,showmsg|
next false if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_WATERFALL,showmsg)
if pbFacingTerrainTag!=PBTerrain::Waterfall
if !pbFacingTerrainTag.waterfall
pbMessage(_INTL("Can't use that here.")) if showmsg
next false
end

View File

@@ -229,7 +229,7 @@ class DependentEvents
tile=$MapFactory.getFacingTile(facing,leader)
passable=tile && $MapFactory.isPassableStrict?(tile[0],tile[1],tile[2],follower)
if i==0 && !passable && tile &&
PBTerrain.isLedge?($MapFactory.getTerrainTag(tile[0],tile[1],tile[2]))
$MapFactory.getTerrainTag(tile[0],tile[1],tile[2]).ledge
# If the tile isn't passable and the tile is a ledge,
# get tile from further behind
tile=$MapFactory.getFacingTileFromPos(tile[0],tile[1],tile[2],facing)

View File

@@ -335,8 +335,8 @@ end
# Decide whether the player is able to ride/dismount their Bicycle
#===============================================================================
def pbBikeCheck
if $PokemonGlobal.surfing ||
(!$PokemonGlobal.bicycle && PBTerrain.onlyWalk?(pbGetTerrainTag))
if $PokemonGlobal.surfing || $PokemonGlobal.diving ||
(!$PokemonGlobal.bicycle && pbGetTerrainTag.must_walk)
pbMessage(_INTL("Can't use that here."))
return false
end

View File

@@ -41,12 +41,8 @@ ItemHandlers::UseFromBag.add(:BICYCLE,proc { |item|
ItemHandlers::UseFromBag.copy(:BICYCLE,:MACHBIKE,:ACROBIKE)
ItemHandlers::UseFromBag.add(:OLDROD,proc { |item|
terrain = pbFacingTerrainTag
notCliff = $game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player)
if (PBTerrain.isWater?(terrain) && !$PokemonGlobal.surfing && notCliff) ||
(PBTerrain.isWater?(terrain) && $PokemonGlobal.surfing)
next 2
end
next 2 if pbFacingTerrainTag.can_fish && ($PokemonGlobal.surfing || notCliff)
pbMessage(_INTL("Can't use that here."))
next 0
})
@@ -113,27 +109,25 @@ ItemHandlers::UseInField.add(:MAXREPEL,proc { |item|
})
Events.onStepTaken += proc {
if $PokemonGlobal.repel>0
if !PBTerrain.isIce?($game_player.terrain_tag) # Shouldn't count down if on ice
$PokemonGlobal.repel -= 1
if $PokemonGlobal.repel<=0
if $PokemonBag.pbHasItem?(:REPEL) ||
$PokemonBag.pbHasItem?(:SUPERREPEL) ||
$PokemonBag.pbHasItem?(:MAXREPEL)
if pbConfirmMessage(_INTL("The repellent's effect wore off! Would you like to use another one?"))
ret = nil
pbFadeOutIn {
scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene,$PokemonBag)
ret = screen.pbChooseItemScreen(Proc.new { |item|
[:REPEL, :SUPERREPEL, :MAXREPEL].include?(item)
})
}
pbUseItem($PokemonBag,ret) if ret
end
else
pbMessage(_INTL("The repellent's effect wore off!"))
if $PokemonGlobal.repel > 0 && !$game_player.terrain_tag.ice # Shouldn't count down if on ice
$PokemonGlobal.repel -= 1
if $PokemonGlobal.repel <= 0
if $PokemonBag.pbHasItem?(:REPEL) ||
$PokemonBag.pbHasItem?(:SUPERREPEL) ||
$PokemonBag.pbHasItem?(:MAXREPEL)
if pbConfirmMessage(_INTL("The repellent's effect wore off! Would you like to use another one?"))
ret = nil
pbFadeOutIn {
scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene,$PokemonBag)
ret = screen.pbChooseItemScreen(Proc.new { |item|
[:REPEL, :SUPERREPEL, :MAXREPEL].include?(item)
})
}
pbUseItem($PokemonBag,ret) if ret
end
else
pbMessage(_INTL("The repellent's effect wore off!"))
end
end
end
@@ -236,9 +230,8 @@ ItemHandlers::UseInField.add(:BICYCLE,proc { |item|
ItemHandlers::UseInField.copy(:BICYCLE,:MACHBIKE,:ACROBIKE)
ItemHandlers::UseInField.add(:OLDROD,proc { |item|
terrain = pbFacingTerrainTag
notCliff = $game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player)
if !PBTerrain.isWater?(terrain) || (!notCliff && !$PokemonGlobal.surfing)
if !pbFacingTerrainTag.can_fish || (!$PokemonGlobal.surfing && !notCliff)
pbMessage(_INTL("Can't use that here."))
next 0
end
@@ -250,9 +243,8 @@ ItemHandlers::UseInField.add(:OLDROD,proc { |item|
})
ItemHandlers::UseInField.add(:GOODROD,proc { |item|
terrain = pbFacingTerrainTag
notCliff = $game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player)
if !PBTerrain.isWater?(terrain) || (!notCliff && !$PokemonGlobal.surfing)
if !pbFacingTerrainTag.can_fish || (!$PokemonGlobal.surfing && !notCliff)
pbMessage(_INTL("Can't use that here."))
next 0
end
@@ -264,9 +256,8 @@ ItemHandlers::UseInField.add(:GOODROD,proc { |item|
})
ItemHandlers::UseInField.add(:SUPERROD,proc { |item|
terrain = pbFacingTerrainTag
notCliff = $game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player)
if !PBTerrain.isWater?(terrain) || (!notCliff && !$PokemonGlobal.surfing)
if !pbFacingTerrainTag.can_fish || (!$PokemonGlobal.surfing && !notCliff)
pbMessage(_INTL("Can't use that here."))
next 0
end

View File

@@ -15,7 +15,8 @@ end
################################################################################
def pbCanUsePokeRadar?
# Can't use Radar if not in tall grass
if !PBTerrain.isJustGrass?($game_map.terrain_tag($game_player.x,$game_player.y))
terrain = $game_map.terrain_tag($game_player.x,$game_player.y)
if !terrain.land_wild_encounters || !terrain.shows_grass_rustle
pbMessage(_INTL("Can't use that here."))
return false
end
@@ -73,7 +74,8 @@ def pbPokeRadarHighlightGrass(showmessage=true)
# Add tile to grasses array if it's a valid grass tile
if x>=0 && x<$game_map.width &&
y>=0 && y<$game_map.height
if PBTerrain.isJustGrass?($game_map.terrain_tag(x,y))
terrain = $game_map.terrain_tag(x, y)
if terrain.land_wild_encounters && terrain.shows_grass_rustle
# Choose a rarity for the grass (0=normal, 1=rare, 2=shiny)
s = (rand(100) < 25) ? 1 : 0
if $PokemonTemp.pokeradar && $PokemonTemp.pokeradar[2] > 0
@@ -216,7 +218,8 @@ Events.onStepTaken += proc { |_sender,_e|
!$PokemonTemp.pokeradar
$PokemonGlobal.pokeradarBattery -= 1
end
if !PBTerrain.isJustGrass?($game_map.terrain_tag($game_player.x, $game_player.y))
terrain = $game_map.terrain_tag($game_player.x,$game_player.y)
if !terrain.land_wild_encounters || !terrain.shows_grass_rustle
pbPokeRadarCancel
end
}

View File

@@ -77,11 +77,10 @@ class PokemonTilesetScene
overlay.fill_rect(tile_x + TILE_SIZE * 2, tile_y - 1, 1, TILE_SIZE * 2 + 2, Color.new(255, 255, 255))
# Write terrain tag info about selected tile
terrain_tag = @tileset.terrain_tags[tile_id] || 0
terrain_tag_name = getConstantNameOrValue(PBTerrain, terrain_tag)
if terrain_tag_name == terrain_tag.to_s
terrain_tag_name = terrain_tag.to_s
if GameData::TerrainTag.exists?(terrain_tag)
terrain_tag_name = sprintf("%d: %s", terrain_tag, GameData::TerrainTag.get(terrain_tag).real_name)
else
terrain_tag_name = sprintf("%d: %s", terrain_tag, terrain_tag_name)
terrain_tag_name = terrain_tag.to_s
end
textpos = [
[_INTL("Terrain Tag:"), tile_x + TILE_SIZE, tile_y + TILE_SIZE * 2 + 10, 2, Color.new(248, 248, 248), Color.new(40, 40, 40)],