Implemented GameData::Metadata and GameData::MapMetadata

This commit is contained in:
Maruno17
2020-11-15 18:59:07 +00:00
parent d8476d1fa4
commit 52ffae9e8a
45 changed files with 803 additions and 540 deletions

View File

@@ -412,11 +412,11 @@ Events.onMapChanging += proc { |_sender,e|
newMapID = e[0]
if newMapID>0
mapinfos = ($RPGVX) ? load_data("Data/MapInfos.rvdata") : load_data("Data/MapInfos.rxdata")
oldWeather = pbGetMetadata($game_map.map_id,MapMetadata::WEATHER)
oldWeather = GameData::MapMetadata.get($game_map.map_id).weather
if $game_map.name!=mapinfos[newMapID].name
$game_screen.weather(0,0,0) if oldWeather
else
newWeather = pbGetMetadata(newMapID,MapMetadata::WEATHER)
newWeather = GameData::MapMetadata.get(newMapID).weather
$game_screen.weather(0,0,0) if oldWeather && !newWeather
end
end
@@ -424,19 +424,19 @@ Events.onMapChanging += proc { |_sender,e|
# Set up various data related to the new map
Events.onMapChange += proc { |_sender,e|
oldid = e[0] # previous map ID, 0 if no map ID
healing = pbGetMetadata($game_map.map_id,MapMetadata::HEALING_SPOT)
oldid = e[0] # previous map ID, is 0 if no map ID
healing = GameData::MapMetadata.get($game_map.map_id).teleport_destination
$PokemonGlobal.healingSpot = healing if healing
$PokemonMap.clear if $PokemonMap
$PokemonEncounters.setup($game_map.map_id) if $PokemonEncounters
$PokemonGlobal.visitedMaps[$game_map.map_id] = true
if oldid!=0 && oldid!=$game_map.map_id
mapinfos = ($RPGVX) ? load_data("Data/MapInfos.rvdata") : load_data("Data/MapInfos.rxdata")
weather = pbGetMetadata($game_map.map_id,MapMetadata::WEATHER)
weather = GameData::MapMetadata.get($game_map.map_id).weather
if $game_map.name!=mapinfos[oldid].name
$game_screen.weather(weather[0],8,20) if weather && rand(100)<weather[1]
else
oldweather = pbGetMetadata(oldid,MapMetadata::WEATHER)
oldweather = GameData::MapMetadata.get(oldid).weather
$game_screen.weather(weather[0],8,20) if weather && !oldweather && rand(100)<weather[1]
end
end
@@ -457,7 +457,7 @@ Events.onMapSceneChange += proc { |_sender,e|
$PokemonGlobal.mapTrail[0] = $game_map.map_id
end
# Display darkness circle on dark maps
darkmap = pbGetMetadata($game_map.map_id,MapMetadata::DARK_MAP)
darkmap = GameData::MapMetadata.get($game_map.map_id).dark_map
if darkmap
if $PokemonGlobal.flashUsed
$PokemonTemp.darknessSprite = DarknessSprite.new
@@ -477,7 +477,7 @@ Events.onMapSceneChange += proc { |_sender,e|
end
# Show location signpost
if mapChanged
if pbGetMetadata($game_map.map_id,MapMetadata::SHOW_AREA)
if GameData::MapMetadata.get($game_map.map_id).announce_location
nosignpost = false
if $PokemonGlobal.mapTrail[1]
for i in 0...NO_SIGNPOSTS.length/2
@@ -493,7 +493,7 @@ Events.onMapSceneChange += proc { |_sender,e|
end
end
# Force cycling/walking
if pbGetMetadata($game_map.map_id,MapMetadata::BICYCLE_ALWAYS)
if GameData::MapMetadata.get($game_map.map_id).always_bicycle
pbMountBike
elsif !pbCanUseBike?($game_map.map_id)
pbDismountBike
@@ -830,7 +830,7 @@ def pbCueBGM(bgm,seconds,volume=nil,pitch=nil)
end
def pbAutoplayOnTransition
surfbgm = pbGetMetadata(0,Metadata::SURF_BGM)
surfbgm = GameData::Metadata.get.surf_BGM
if $PokemonGlobal.surfing && surfbgm
pbBGMPlay(surfbgm)
else
@@ -839,7 +839,7 @@ def pbAutoplayOnTransition
end
def pbAutoplayOnSave
surfbgm = pbGetMetadata(0,Metadata::SURF_BGM)
surfbgm = GameData::Metadata.get.surf_BGM
if $PokemonGlobal.surfing && surfbgm
pbBGMPlay(surfbgm)
else
@@ -1126,7 +1126,7 @@ def pbFishingBegin
$PokemonGlobal.fishing = true
if !pbCommonEvent(FISHING_BEGIN_COMMON_EVENT)
patternb = 2*$game_player.direction - 1
meta = pbGetMetadata(0,Metadata::PLAYER_A+$PokemonGlobal.playerID)
meta = GameData::Metadata.get_player($PokemonGlobal.playerID)
num = ($PokemonGlobal.surfing) ? 7 : 6
if meta && meta[num] && meta[num]!=""
charset = pbGetPlayerCharset(meta,num)
@@ -1145,7 +1145,7 @@ end
def pbFishingEnd
if !pbCommonEvent(FISHING_END_COMMON_EVENT)
patternb = 2*($game_player.direction - 2)
meta = pbGetMetadata(0,Metadata::PLAYER_A+$PokemonGlobal.playerID)
meta = GameData::Metadata.get_player($PokemonGlobal.playerID)
num = ($PokemonGlobal.surfing) ? 7 : 6
if meta && meta[num] && meta[num]!=""
charset = pbGetPlayerCharset(meta,num)

View File

@@ -52,7 +52,7 @@ def pbBattleAnimation(bgm=nil,battletype=0,foe=nil)
location = 3
elsif $PokemonEncounters.isCave?
location = 2
elsif !pbGetMetadata($game_map.map_id,MapMetadata::OUTDOOR)
elsif !GameData::MapMetadata.get($game_map.map_id).outdoor_map
location = 1
end
anim = ""
@@ -654,7 +654,7 @@ def pbStartOver(gameover=false)
$scene.transfer_player if $scene.is_a?(Scene_Map)
$game_map.refresh
else
homedata = pbGetMetadata(0,Metadata::HOME)
homedata = GameData::Metadata.get.home
if homedata && !pbRxdataExists?(sprintf("Data/Map%03d",homedata[0]))
if $DEBUG
pbMessage(_ISPRINTF("Can't find the map 'Map{1:03d}' in the Data folder. The game will resume at the player's position.",homedata[0]))

View File

@@ -131,7 +131,7 @@ def pbPrepareBattle(battle)
elsif $PokemonGlobal.surfing
backdrop = "water" # This applies wherever you are, including in caves
else
back = pbGetMetadata($game_map.map_id,MapMetadata::BATTLE_BACK)
back = GameData::MapMetadata.get($game_map.map_id).battle_background
backdrop = back if back && back!=""
end
backdrop = "indoor1" if !backdrop
@@ -152,7 +152,7 @@ def pbPrepareBattle(battle)
end
battle.backdropBase = base if base
# Time of day
if pbGetMetadata($game_map.map_id,MapMetadata::ENVIRONMENT)==PBEnvironment::Cave
if GameData::MapMetadata.get($game_map.map_id).battle_environment == PBEnvironment::Cave
battle.time = 2 # This makes Dusk Balls work properly in caves
elsif TIME_SHADING
timeNow = pbGetTimeNow
@@ -166,7 +166,7 @@ end
# Used to determine the environment in battle, and also the form of Burmy/
# Wormadam.
def pbGetEnvironment
ret = pbGetMetadata($game_map.map_id,MapMetadata::ENVIRONMENT)
ret = GameData::MapMetadata.get($game_map.map_id).battle_environment
ret = PBEnvironment::None if !ret
if $PokemonTemp.encounterType==EncounterTypes::OldRod ||
$PokemonTemp.encounterType==EncounterTypes::GoodRod ||

View File

@@ -183,7 +183,8 @@ EncounterModifier.register(proc { |encounter|
# are in the same region
if roamerMap!=$game_map.map_id
currentRegion = pbGetCurrentRegion
next if pbGetMetadata(roamerMap,MapMetadata::MAP_POSITION)[0]!=currentRegion
map_position = GameData::MapMetadata.get(roamerMap).town_map_position
next if !map_position || map_position[0] != currentRegion
currentMapName = pbGetMessage(MessageTypes::MapNames,$game_map.map_id)
next if pbGetMessage(MessageTypes::MapNames,roamerMap)!=currentMapName
end

View File

@@ -555,7 +555,7 @@ end
Events.onMapCreate += proc { |_sender, e|
mapID=e[0]
map=e[1]
if pbGetMetadata(mapID,MapMetadata::DUNGEON)
if GameData::MapMetadata.get(mapID).random_dungeon
# this map is a randomly generated dungeon
dungeon=Dungeon.new(map.width,map.height)
dungeon.generate

View File

@@ -302,7 +302,7 @@ HiddenMoveHandlers::UseMove.add(:DIG,proc { |move,pokemon|
# Dive
#===============================================================================
def pbDive
divemap = pbGetMetadata($game_map.map_id,MapMetadata::DIVE_MAP)
divemap = GameData::MapMetadata.get($game_map.map_id).dive_map_id
return false if !divemap
move = getID(PBMoves,:DIVE)
movefinder = pbCheckMove(move)
@@ -333,14 +333,13 @@ end
def pbSurfacing
return if !$PokemonGlobal.diving
divemap = nil
meta = pbLoadMetadata
for i in 0...meta.length
if meta[i] && meta[i][MapMetadata::DIVE_MAP] && meta[i][MapMetadata::DIVE_MAP]==$game_map.map_id
divemap = i; break
end
surface_map_id = nil
GameData::MapMetadata.each do |map_data|
next if !map_data.dive_map_id || map_data.dive_map_id != $game_map.map_id
surface_map_id = map_data.id
break
end
return if !divemap
return if !surface_map_id
move = getID(PBMoves,:DIVE)
movefinder = pbCheckMove(move)
if !pbCheckHiddenMoveBadge(BADGE_FOR_DIVE,false) || (!$DEBUG && !movefinder)
@@ -352,7 +351,7 @@ def pbSurfacing
pbMessage(_INTL("{1} used {2}!",speciesname,PBMoves.getName(move)))
pbHiddenMoveAnimation(movefinder)
pbFadeOutIn {
$game_temp.player_new_map_id = divemap
$game_temp.player_new_map_id = surface_map_id
$game_temp.player_new_x = $game_player.x
$game_temp.player_new_y = $game_player.y
$game_temp.player_new_direction = $game_player.direction
@@ -360,7 +359,7 @@ def pbSurfacing
$PokemonGlobal.diving = false
pbUpdateVehicle
$scene.transfer_player(false)
surfbgm = pbGetMetadata(0,Metadata::SURF_BGM)
surfbgm = GameData::Metadata.get.surf_BGM
(surfbgm) ? pbBGMPlay(surfbgm) : $game_map.autoplayAsCue
$game_map.refresh
}
@@ -381,19 +380,19 @@ def pbTransferUnderwater(mapid,x,y,direction=$game_player.direction)
}
end
Events.onAction += proc { |_sender,_e|
Events.onAction += proc { |_sender, _e|
if $PokemonGlobal.diving
if DIVING_SURFACE_ANYWHERE
pbSurfacing
else
divemap = nil
meta = pbLoadMetadata
for i in 0...meta.length
if meta[i] && meta[i][MapMetadata::DIVE_MAP] && meta[i][MapMetadata::DIVE_MAP]==$game_map.map_id
divemap = i; break
end
surface_map_id = nil
GameData::MapMetadata.each do |map_data|
next if !map_data.dive_map_id || map_data.dive_map_id != $game_map.map_id
surface_map_id = map_data.id
break
end
if divemap && PBTerrain.isDeepWater?($MapFactory.getTerrainTag(divemap,$game_player.x,$game_player.y))
if surface_map_id &&
PBTerrain.isDeepWater?($MapFactory.getTerrainTag(surface_map_id, $game_player.x, $game_player.y))
pbSurfacing
end
end
@@ -406,19 +405,19 @@ HiddenMoveHandlers::CanUseMove.add(:DIVE,proc { |move,pkmn,showmsg|
next false if !pbCheckHiddenMoveBadge(BADGE_FOR_DIVE,showmsg)
if $PokemonGlobal.diving
next true if DIVING_SURFACE_ANYWHERE
divemap = nil
meta = pbLoadMetadata
for i in 0...meta.length
if meta[i] && meta[i][MapMetadata::DIVE_MAP] && meta[i][MapMetadata::DIVE_MAP]==$game_map.map_id
divemap = i; break
end
surface_map_id = nil
GameData::MapMetadata.each do |map_data|
next if !map_data.dive_map_id || map_data.dive_map_id != $game_map.map_id
surface_map_id = map_data.id
break
end
if !PBTerrain.isDeepWater?($MapFactory.getTerrainTag(divemap,$game_player.x,$game_player.y))
if !surface_map_id ||
!PBTerrain.isDeepWater?($MapFactory.getTerrainTag(surface_map_id, $game_player.x, $game_player.y))
pbMessage(_INTL("Can't use that here.")) if showmsg
next false
end
else
if !pbGetMetadata($game_map.map_id,MapMetadata::DIVE_MAP)
if !GameData::MapMetadata.get($game_map.map_id).dive_map_id
pbMessage(_INTL("Can't use that here.")) if showmsg
next false
end
@@ -433,22 +432,21 @@ HiddenMoveHandlers::CanUseMove.add(:DIVE,proc { |move,pkmn,showmsg|
HiddenMoveHandlers::UseMove.add(:DIVE,proc { |move,pokemon|
wasdiving = $PokemonGlobal.diving
if $PokemonGlobal.diving
divemap = nil
meta = pbLoadMetadata
for i in 0...meta.length
if meta[i] && meta[i][MapMetadata::DIVE_MAP] && meta[i][MapMetadata::DIVE_MAP]==$game_map.map_id
divemap = i; break
end
dive_map_id = nil
GameData::MapMetadata.each do |map_data|
next if !map_data.dive_map_id || map_data.dive_map_id != $game_map.map_id
dive_map_id = map_data.id
break
end
else
divemap = pbGetMetadata($game_map.map_id,MapMetadata::DIVE_MAP)
dive_map_id = GameData::MapMetadata.get($game_map.map_id).dive_map_id
end
next false if !divemap
next false if !dive_map_id
if !pbHiddenMoveAnimation(pokemon)
pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move)))
end
pbFadeOutIn {
$game_temp.player_new_map_id = divemap
$game_temp.player_new_map_id = dive_map_id
$game_temp.player_new_x = $game_player.x
$game_temp.player_new_y = $game_player.y
$game_temp.player_new_direction = $game_player.direction
@@ -469,7 +467,7 @@ HiddenMoveHandlers::UseMove.add(:DIVE,proc { |move,pokemon|
#===============================================================================
HiddenMoveHandlers::CanUseMove.add(:FLASH,proc { |move,pkmn,showmsg|
next false if !pbCheckHiddenMoveBadge(BADGE_FOR_FLASH,showmsg)
if !pbGetMetadata($game_map.map_id,MapMetadata::DARK_MAP)
if !GameData::MapMetadata.get($game_map.map_id).dark_map
pbMessage(_INTL("Can't use that here.")) if showmsg
next false
end
@@ -509,7 +507,7 @@ HiddenMoveHandlers::CanUseMove.add(:FLY,proc { |move,pkmn,showmsg|
pbMessage(_INTL("It can't be used when you have someone with you.")) if showmsg
next false
end
if !pbGetMetadata($game_map.map_id,MapMetadata::OUTDOOR)
if !GameData::MapMetadata.get($game_map.map_id).outdoor_map
pbMessage(_INTL("Can't use that here.")) if showmsg
next false
end
@@ -715,7 +713,7 @@ def pbSurf
pbMessage(_INTL("{1} used {2}!",speciesname,PBMoves.getName(move)))
pbCancelVehicles
pbHiddenMoveAnimation(movefinder)
surfbgm = pbGetMetadata(0,Metadata::SURF_BGM)
surfbgm = GameData::Metadata.get.surf_BGM
pbCueBGM(surfbgm,0.5) if surfbgm
pbStartSurfing
return true
@@ -768,7 +766,7 @@ end
Events.onAction += proc { |_sender,_e|
next if $PokemonGlobal.surfing
next if pbGetMetadata($game_map.map_id,MapMetadata::BICYCLE_ALWAYS)
next if GameData::MapMetadata.get($game_map.map_id).always_bicycle
next if !PBTerrain.isSurfable?(pbFacingTerrainTag)
next if !$game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player)
pbSurf
@@ -784,7 +782,7 @@ HiddenMoveHandlers::CanUseMove.add(:SURF,proc { |move,pkmn,showmsg|
pbMessage(_INTL("It can't be used when you have someone with you.")) if showmsg
next false
end
if pbGetMetadata($game_map.map_id,MapMetadata::BICYCLE_ALWAYS)
if GameData::MapMetadata.get($game_map.map_id).always_bicycle
pbMessage(_INTL("Let's enjoy cycling!")) if showmsg
next false
end
@@ -802,7 +800,7 @@ HiddenMoveHandlers::UseMove.add(:SURF,proc { |move,pokemon|
if !pbHiddenMoveAnimation(pokemon)
pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move)))
end
surfbgm = pbGetMetadata(0,Metadata::SURF_BGM)
surfbgm = GameData::Metadata.get.surf_BGM
pbCueBGM(surfbgm,0.5) if surfbgm
pbStartSurfing
next true
@@ -865,12 +863,12 @@ HiddenMoveHandlers::UseMove.add(:SWEETSCENT,proc { |move,pokemon|
# Teleport
#===============================================================================
HiddenMoveHandlers::CanUseMove.add(:TELEPORT,proc { |move,pkmn,showmsg|
if !pbGetMetadata($game_map.map_id,MapMetadata::OUTDOOR)
if !GameData::MapMetadata.get($game_map.map_id).outdoor_map
pbMessage(_INTL("Can't use that here.")) if showmsg
next false
end
healing = $PokemonGlobal.healingSpot
healing = pbGetMetadata(0,Metadata::HOME) if !healing # Home
healing = GameData::Metadata.get.home if !healing # Home
if !healing
pbMessage(_INTL("Can't use that here.")) if showmsg
next false
@@ -884,7 +882,7 @@ HiddenMoveHandlers::CanUseMove.add(:TELEPORT,proc { |move,pkmn,showmsg|
HiddenMoveHandlers::ConfirmUseMove.add(:TELEPORT,proc { |move,pkmn|
healing = $PokemonGlobal.healingSpot
healing = pbGetMetadata(0,Metadata::HOME) if !healing # Home
healing = GameData::Metadata.get.home if !healing # Home
next false if !healing
mapname = pbGetMapNameFromId(healing[0])
next pbConfirmMessage(_INTL("Want to return to the healing spot used last in {1}?",mapname))
@@ -892,7 +890,7 @@ HiddenMoveHandlers::ConfirmUseMove.add(:TELEPORT,proc { |move,pkmn|
HiddenMoveHandlers::UseMove.add(:TELEPORT,proc { |move,pokemon|
healing = $PokemonGlobal.healingSpot
healing = pbGetMetadata(0,Metadata::HOME) if !healing # Home
healing = GameData::Metadata.get.home if !healing # Home
next false if !healing
if !pbHiddenMoveAnimation(pokemon)
pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move)))

View File

@@ -117,7 +117,7 @@ end
def pbDayNightTint(object)
return if !$scene.is_a?(Scene_Map)
if TIME_SHADING && pbGetMetadata($game_map.map_id,MapMetadata::OUTDOOR)
if TIME_SHADING && GameData::MapMetadata.get($game_map.map_id).outdoor_map
tone = PBDayNight.getTone
object.tone.set(tone.red,tone.green,tone.blue,tone.gray)
else