Moved global/map metadata constants and schema into modules

This commit is contained in:
Maruno17
2020-10-16 22:05:38 +01:00
parent 71a4d09224
commit e82b5409fb
25 changed files with 170 additions and 164 deletions

View File

@@ -399,11 +399,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,MetadataWeather)
oldWeather = pbGetMetadata($game_map.map_id,MapMetadata::WEATHER)
if $game_map.name!=mapinfos[newMapID].name
$game_screen.weather(0,0,0) if oldWeather
else
newWeather = pbGetMetadata(newMapID,MetadataWeather)
newWeather = pbGetMetadata(newMapID,MapMetadata::WEATHER)
$game_screen.weather(0,0,0) if oldWeather && !newWeather
end
end
@@ -412,18 +412,18 @@ 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,MetadataHealingSpot)
healing = pbGetMetadata($game_map.map_id,MapMetadata::HEALING_SPOT)
$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,MetadataWeather)
weather = pbGetMetadata($game_map.map_id,MapMetadata::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,MetadataWeather)
oldweather = pbGetMetadata(oldid,MapMetadata::WEATHER)
$game_screen.weather(weather[0],8,20) if weather && !oldweather && rand(100)<weather[1]
end
end
@@ -444,7 +444,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,MetadataDarkMap)
darkmap = pbGetMetadata($game_map.map_id,MapMetadata::DARK_MAP)
if darkmap
if $PokemonGlobal.flashUsed
$PokemonTemp.darknessSprite = DarknessSprite.new
@@ -464,7 +464,7 @@ Events.onMapSceneChange += proc { |_sender,e|
end
# Show location signpost
if mapChanged
if pbGetMetadata($game_map.map_id,MetadataShowArea)
if pbGetMetadata($game_map.map_id,MapMetadata::SHOW_AREA)
nosignpost = false
if $PokemonGlobal.mapTrail[1]
for i in 0...NO_SIGNPOSTS.length/2
@@ -480,7 +480,7 @@ Events.onMapSceneChange += proc { |_sender,e|
end
end
# Force cycling/walking
if pbGetMetadata($game_map.map_id,MetadataBicycleAlways)
if pbGetMetadata($game_map.map_id,MapMetadata::BICYCLE_ALWAYS)
pbMountBike
elsif !pbCanUseBike?($game_map.map_id)
pbDismountBike
@@ -698,7 +698,7 @@ def pbFishingBegin
$PokemonGlobal.fishing = true
if !pbCommonEvent(FISHING_BEGIN_COMMON_EVENT)
patternb = 2*$game_player.direction - 1
meta = pbGetMetadata(0,MetadataPlayerA+$PokemonGlobal.playerID)
meta = pbGetMetadata(0,Metadata::PLAYER_A+$PokemonGlobal.playerID)
num = ($PokemonGlobal.surfing) ? 7 : 6
if meta && meta[num] && meta[num]!=""
charset = pbGetPlayerCharset(meta,num)
@@ -717,7 +717,7 @@ end
def pbFishingEnd
if !pbCommonEvent(FISHING_END_COMMON_EVENT)
patternb = 2*($game_player.direction - 2)
meta = pbGetMetadata(0,MetadataPlayerA+$PokemonGlobal.playerID)
meta = pbGetMetadata(0,Metadata::PLAYER_A+$PokemonGlobal.playerID)
num = ($PokemonGlobal.surfing) ? 7 : 6
if meta && meta[num] && meta[num]!=""
charset = pbGetPlayerCharset(meta,num)
@@ -1223,7 +1223,7 @@ def pbCueBGM(bgm,seconds,volume=nil,pitch=nil)
end
def pbAutoplayOnTransition
surfbgm = pbGetMetadata(0,MetadataSurfBGM)
surfbgm = pbGetMetadata(0,Metadata::SURF_BGM)
if $PokemonGlobal.surfing && surfbgm
pbBGMPlay(surfbgm)
else
@@ -1232,7 +1232,7 @@ def pbAutoplayOnTransition
end
def pbAutoplayOnSave
surfbgm = pbGetMetadata(0,MetadataSurfBGM)
surfbgm = pbGetMetadata(0,Metadata::SURF_BGM)
if $PokemonGlobal.surfing && surfbgm
pbBGMPlay(surfbgm)
else

View File

@@ -276,7 +276,7 @@ def pbBattleAnimation(bgm=nil,battletype=0,foe=nil)
location = 3
elsif $PokemonEncounters.isCave?
location = 2
elsif !pbGetMetadata($game_map.map_id,MetadataOutdoor)
elsif !pbGetMetadata($game_map.map_id,MapMetadata::OUTDOOR)
location = 1
end
anim = ""
@@ -653,7 +653,7 @@ def pbStartOver(gameover=false)
$scene.transfer_player if $scene.is_a?(Scene_Map)
$game_map.refresh
else
homedata = pbGetMetadata(0,MetadataHome)
homedata = pbGetMetadata(0,Metadata::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

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

View File

@@ -183,7 +183,7 @@ EncounterModifier.register(proc { |encounter|
# are in the same region
if roamerMap!=$game_map.map_id
currentRegion = pbGetCurrentRegion
next if pbGetMetadata(roamerMap,MetadataMapPosition)[0]!=currentRegion
next if pbGetMetadata(roamerMap,MapMetadata::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,MetadataDungeon)
if pbGetMetadata(mapID,MapMetadata::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,MetadataDiveMap)
divemap = pbGetMetadata($game_map.map_id,MapMetadata::DIVE_MAP)
return false if !divemap
move = getID(PBMoves,:DIVE)
movefinder = pbCheckMove(move)
@@ -336,7 +336,7 @@ def pbSurfacing
divemap = nil
meta = pbLoadMetadata
for i in 0...meta.length
if meta[i] && meta[i][MetadataDiveMap] && meta[i][MetadataDiveMap]==$game_map.map_id
if meta[i] && meta[i][MapMetadata::DIVE_MAP] && meta[i][MapMetadata::DIVE_MAP]==$game_map.map_id
divemap = i; break
end
end
@@ -360,7 +360,7 @@ def pbSurfacing
$PokemonGlobal.diving = false
pbUpdateVehicle
$scene.transfer_player(false)
surfbgm = pbGetMetadata(0,MetadataSurfBGM)
surfbgm = pbGetMetadata(0,Metadata::SURF_BGM)
(surfbgm) ? pbBGMPlay(surfbgm) : $game_map.autoplayAsCue
$game_map.refresh
}
@@ -389,7 +389,7 @@ Events.onAction += proc { |_sender,_e|
divemap = nil
meta = pbLoadMetadata
for i in 0...meta.length
if meta[i] && meta[i][MetadataDiveMap] && meta[i][MetadataDiveMap]==$game_map.map_id
if meta[i] && meta[i][MapMetadata::DIVE_MAP] && meta[i][MapMetadata::DIVE_MAP]==$game_map.map_id
divemap = i; break
end
end
@@ -409,7 +409,7 @@ HiddenMoveHandlers::CanUseMove.add(:DIVE,proc { |move,pkmn,showmsg|
divemap = nil
meta = pbLoadMetadata
for i in 0...meta.length
if meta[i] && meta[i][MetadataDiveMap] && meta[i][MetadataDiveMap]==$game_map.map_id
if meta[i] && meta[i][MapMetadata::DIVE_MAP] && meta[i][MapMetadata::DIVE_MAP]==$game_map.map_id
divemap = i; break
end
end
@@ -418,7 +418,7 @@ HiddenMoveHandlers::CanUseMove.add(:DIVE,proc { |move,pkmn,showmsg|
next false
end
else
if !pbGetMetadata($game_map.map_id,MetadataDiveMap)
if !pbGetMetadata($game_map.map_id,MapMetadata::DIVE_MAP)
pbMessage(_INTL("Can't use that here.")) if showmsg
next false
end
@@ -436,12 +436,12 @@ HiddenMoveHandlers::UseMove.add(:DIVE,proc { |move,pokemon|
divemap = nil
meta = pbLoadMetadata
for i in 0...meta.length
if meta[i] && meta[i][MetadataDiveMap] && meta[i][MetadataDiveMap]==$game_map.map_id
if meta[i] && meta[i][MapMetadata::DIVE_MAP] && meta[i][MapMetadata::DIVE_MAP]==$game_map.map_id
divemap = i; break
end
end
else
divemap = pbGetMetadata($game_map.map_id,MetadataDiveMap)
divemap = pbGetMetadata($game_map.map_id,MapMetadata::DIVE_MAP)
end
next false if !divemap
if !pbHiddenMoveAnimation(pokemon)
@@ -469,7 +469,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,MetadataDarkMap)
if !pbGetMetadata($game_map.map_id,MapMetadata::DARK_MAP)
pbMessage(_INTL("Can't use that here.")) if showmsg
next false
end
@@ -509,7 +509,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,MetadataOutdoor)
if !pbGetMetadata($game_map.map_id,MapMetadata::OUTDOOR)
pbMessage(_INTL("Can't use that here.")) if showmsg
next false
end
@@ -715,7 +715,7 @@ def pbSurf
pbMessage(_INTL("{1} used {2}!",speciesname,PBMoves.getName(move)))
pbCancelVehicles
pbHiddenMoveAnimation(movefinder)
surfbgm = pbGetMetadata(0,MetadataSurfBGM)
surfbgm = pbGetMetadata(0,Metadata::SURF_BGM)
pbCueBGM(surfbgm,0.5) if surfbgm
pbStartSurfing
return true
@@ -768,7 +768,7 @@ end
Events.onAction += proc { |_sender,_e|
next if $PokemonGlobal.surfing
next if pbGetMetadata($game_map.map_id,MetadataBicycleAlways)
next if pbGetMetadata($game_map.map_id,MapMetadata::BICYCLE_ALWAYS)
next if !PBTerrain.isSurfable?(pbFacingTerrainTag)
next if !$game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player)
pbSurf
@@ -784,7 +784,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,MetadataBicycleAlways)
if pbGetMetadata($game_map.map_id,MapMetadata::BICYCLE_ALWAYS)
pbMessage(_INTL("Let's enjoy cycling!")) if showmsg
next false
end
@@ -802,7 +802,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,MetadataSurfBGM)
surfbgm = pbGetMetadata(0,Metadata::SURF_BGM)
pbCueBGM(surfbgm,0.5) if surfbgm
pbStartSurfing
next true
@@ -865,12 +865,12 @@ HiddenMoveHandlers::UseMove.add(:SWEETSCENT,proc { |move,pokemon|
# Teleport
#===============================================================================
HiddenMoveHandlers::CanUseMove.add(:TELEPORT,proc { |move,pkmn,showmsg|
if !pbGetMetadata($game_map.map_id,MetadataOutdoor)
if !pbGetMetadata($game_map.map_id,MapMetadata::OUTDOOR)
pbMessage(_INTL("Can't use that here.")) if showmsg
next false
end
healing = $PokemonGlobal.healingSpot
healing = pbGetMetadata(0,MetadataHome) if !healing # Home
healing = pbGetMetadata(0,Metadata::HOME) if !healing # Home
if !healing
pbMessage(_INTL("Can't use that here.")) if showmsg
next false
@@ -884,7 +884,7 @@ HiddenMoveHandlers::CanUseMove.add(:TELEPORT,proc { |move,pkmn,showmsg|
HiddenMoveHandlers::ConfirmUseMove.add(:TELEPORT,proc { |move,pkmn|
healing = $PokemonGlobal.healingSpot
healing = pbGetMetadata(0,MetadataHome) if !healing # Home
healing = pbGetMetadata(0,Metadata::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 +892,7 @@ HiddenMoveHandlers::ConfirmUseMove.add(:TELEPORT,proc { |move,pkmn|
HiddenMoveHandlers::UseMove.add(:TELEPORT,proc { |move,pokemon|
healing = $PokemonGlobal.healingSpot
healing = pbGetMetadata(0,MetadataHome) if !healing # Home
healing = pbGetMetadata(0,Metadata::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,MetadataOutdoor)
if TIME_SHADING && pbGetMetadata($game_map.map_id,MapMetadata::OUTDOOR)
tone = PBDayNight.getTone
object.tone.set(tone.red,tone.green,tone.blue,tone.gray)
else