mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Fixed code assuming map metadata exists, fixed misplaced species data methods, rewrote class PokeBattle_Pokemon
This commit is contained in:
@@ -449,9 +449,10 @@ def pbCancelVehicles(destination=nil)
|
||||
end
|
||||
|
||||
def pbCanUseBike?(map_id)
|
||||
return true if GameData::MapMetadata.get(map_id).always_bicycle
|
||||
val = GameData::MapMetadata.get(map_id).can_bicycle
|
||||
val = GameData::MapMetadata.get(map_id).outdoor_map if val.nil?
|
||||
map_metadata = GameData::MapMetadata.try_get(map_id)
|
||||
return false if !map_metadata
|
||||
return true if map_metadata.always_bicycle
|
||||
val = map_metadata.can_bicycle || map_metadata.outdoor_map
|
||||
return (val) ? true : false
|
||||
end
|
||||
|
||||
|
||||
@@ -330,7 +330,7 @@ class Game_Map
|
||||
|
||||
def display_x=(value)
|
||||
@display_x = value
|
||||
if GameData::MapMetadata.get(self.map_id).snap_edges
|
||||
if GameData::MapMetadata.exists?(self.map_id) && GameData::MapMetadata.get(self.map_id).snap_edges
|
||||
max_x = (self.width - Graphics.width*1.0/TILE_WIDTH) * REAL_RES_X
|
||||
@display_x = [0, [@display_x, max_x].min].max
|
||||
end
|
||||
@@ -339,7 +339,7 @@ class Game_Map
|
||||
|
||||
def display_y=(value)
|
||||
@display_y = value
|
||||
if GameData::MapMetadata.get(self.map_id).snap_edges
|
||||
if GameData::MapMetadata.exists?(self.map_id) && GameData::MapMetadata.get(self.map_id).snap_edges
|
||||
max_y = (self.height - Graphics.height*1.0/TILE_HEIGHT) * REAL_RES_Y
|
||||
@display_y = [0, [@display_y, max_y].min].max
|
||||
end
|
||||
|
||||
@@ -195,7 +195,6 @@ module GameData
|
||||
def pokedex_entry
|
||||
return pbGetMessage(MessageTypes::Entries, @id_number)
|
||||
end
|
||||
end
|
||||
|
||||
def apply_metrics_to_sprite(sprite, index, shadow = false)
|
||||
if shadow
|
||||
@@ -218,6 +217,7 @@ module GameData
|
||||
return true
|
||||
# return @front_sprite_altitude > 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
|
||||
@@ -406,94 +406,85 @@ end
|
||||
#===============================================================================
|
||||
# Checks when moving between maps
|
||||
#===============================================================================
|
||||
# Clears the weather of the old map, if the old and new maps have different
|
||||
# names or defined weather
|
||||
Events.onMapChanging += proc { |_sender,e|
|
||||
newMapID = e[0]
|
||||
if newMapID>0
|
||||
mapinfos = load_data("Data/MapInfos.rxdata")
|
||||
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 = GameData::MapMetadata.get(newMapID).weather
|
||||
$game_screen.weather(0,0,0) if oldWeather && !newWeather
|
||||
end
|
||||
# Clears the weather of the old map, if the old map has defined weather and the
|
||||
# new map either has the same name as the old map or doesn't have defined
|
||||
# weather.
|
||||
Events.onMapChanging += proc { |_sender, e|
|
||||
new_map_ID = e[0]
|
||||
next if new_map_ID == 0
|
||||
old_map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||
next if !old_map_metadata || !old_map_metadata.weather
|
||||
map_infos = load_data("Data/MapInfos.rxdata")
|
||||
if $game_map.name == map_infos[new_map_ID].name
|
||||
new_map_metadata = GameData::MapMetadata.try_get(new_map_ID)
|
||||
next if new_map_metadata && new_map_metadata.weather
|
||||
end
|
||||
$game_screen.weather(0, 0, 0)
|
||||
}
|
||||
|
||||
# Set up various data related to the new map
|
||||
Events.onMapChange += proc { |_sender,e|
|
||||
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
|
||||
Events.onMapChange += proc { |_sender, e|
|
||||
old_map_ID = e[0] # previous map ID, is 0 if no map ID
|
||||
new_map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||
if new_map_metadata && new_map_metadata.teleport_destination
|
||||
$PokemonGlobal.healingSpot = new_map_metadata.teleport_destination
|
||||
end
|
||||
$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 = load_data("Data/MapInfos.rxdata")
|
||||
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 = GameData::MapMetadata.get(oldid).weather
|
||||
$game_screen.weather(weather[0],8,20) if weather && !oldweather && rand(100)<weather[1]
|
||||
end
|
||||
next if old_map_ID == 0 || old_map_ID == $game_map.map_id
|
||||
next if !new_map_metadata || !new_map_metadata.weather
|
||||
map_infos = load_data("Data/MapInfos.rxdata")
|
||||
if $game_map.name == map_infos[old_map_ID].name
|
||||
old_map_metadata = GameData::MapMetadata.try_get(old_map_ID)
|
||||
next if old_map_metadata && old_map_metadata.weather
|
||||
end
|
||||
new_weather = new_map_metadata.weather
|
||||
$game_screen.weather(new_weather[0], 8, 20) if rand(100) < new_weather[1]
|
||||
}
|
||||
|
||||
Events.onMapSceneChange += proc { |_sender,e|
|
||||
Events.onMapSceneChange += proc { |_sender, e|
|
||||
scene = e[0]
|
||||
mapChanged = e[1]
|
||||
next if !scene || !scene.spriteset
|
||||
# Update map trail
|
||||
if $game_map
|
||||
$PokemonGlobal.mapTrail = [] if !$PokemonGlobal.mapTrail
|
||||
if $PokemonGlobal.mapTrail[0]!=$game_map.map_id
|
||||
$PokemonGlobal.mapTrail[3] = $PokemonGlobal.mapTrail[2] if $PokemonGlobal.mapTrail[2]
|
||||
$PokemonGlobal.mapTrail[2] = $PokemonGlobal.mapTrail[1] if $PokemonGlobal.mapTrail[1]
|
||||
$PokemonGlobal.mapTrail[1] = $PokemonGlobal.mapTrail[0] if $PokemonGlobal.mapTrail[0]
|
||||
if $PokemonGlobal.mapTrail[0] != $game_map.map_id
|
||||
$PokemonGlobal.mapTrail.pop if $PokemonGlobal.mapTrail.length >= 4
|
||||
end
|
||||
$PokemonGlobal.mapTrail[0] = $game_map.map_id
|
||||
$PokemonGlobal.mapTrail = [$game_map.map_id] + $PokemonGlobal.mapTrail
|
||||
end
|
||||
# Display darkness circle on dark maps
|
||||
darkmap = GameData::MapMetadata.get($game_map.map_id).dark_map
|
||||
if darkmap
|
||||
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||
if map_metadata && map_metadata.dark_map
|
||||
$PokemonTemp.darknessSprite = DarknessSprite.new
|
||||
scene.spriteset.addUserSprite($PokemonTemp.darknessSprite)
|
||||
if $PokemonGlobal.flashUsed
|
||||
$PokemonTemp.darknessSprite = DarknessSprite.new
|
||||
scene.spriteset.addUserSprite($PokemonTemp.darknessSprite)
|
||||
darkness = $PokemonTemp.darknessSprite
|
||||
darkness.radius = darkness.radiusMax
|
||||
else
|
||||
$PokemonTemp.darknessSprite = DarknessSprite.new
|
||||
scene.spriteset.addUserSprite($PokemonTemp.darknessSprite)
|
||||
$PokemonTemp.darknessSprite.radius = $PokemonTemp.darknessSprite.radiusMax
|
||||
end
|
||||
elsif !darkmap
|
||||
else
|
||||
$PokemonGlobal.flashUsed = false
|
||||
if $PokemonTemp.darknessSprite
|
||||
$PokemonTemp.darknessSprite.dispose
|
||||
$PokemonTemp.darknessSprite.dispose if $PokemonTemp.darknessSprite
|
||||
$PokemonTemp.darknessSprite = nil
|
||||
end
|
||||
end
|
||||
# Show location signpost
|
||||
if mapChanged
|
||||
if GameData::MapMetadata.get($game_map.map_id).announce_location
|
||||
if mapChanged && map_metadata && map_metadata.announce_location
|
||||
nosignpost = false
|
||||
if $PokemonGlobal.mapTrail[1]
|
||||
for i in 0...NO_SIGNPOSTS.length/2
|
||||
nosignpost = true if NO_SIGNPOSTS[2*i]==$PokemonGlobal.mapTrail[1] && NO_SIGNPOSTS[2*i+1]==$game_map.map_id
|
||||
nosignpost = true if NO_SIGNPOSTS[2*i+1]==$PokemonGlobal.mapTrail[1] && NO_SIGNPOSTS[2*i]==$game_map.map_id
|
||||
for i in 0...NO_SIGNPOSTS.length / 2
|
||||
nosignpost = true if NO_SIGNPOSTS[2 * i] == $PokemonGlobal.mapTrail[1] && NO_SIGNPOSTS[2 * i + 1] == $game_map.map_id
|
||||
nosignpost = true if NO_SIGNPOSTS[2 * i + 1] == $PokemonGlobal.mapTrail[1] && NO_SIGNPOSTS[2 * i] == $game_map.map_id
|
||||
break if nosignpost
|
||||
end
|
||||
mapinfos = load_data("Data/MapInfos.rxdata")
|
||||
oldmapname = mapinfos[$PokemonGlobal.mapTrail[1]].name
|
||||
nosignpost = true if $game_map.name==oldmapname
|
||||
nosignpost = true if $game_map.name == oldmapname
|
||||
end
|
||||
scene.spriteset.addUserSprite(LocationWindow.new($game_map.name)) if !nosignpost
|
||||
end
|
||||
end
|
||||
# Force cycling/walking
|
||||
if GameData::MapMetadata.get($game_map.map_id).always_bicycle
|
||||
if map_metadata && map_metadata.always_bicycle
|
||||
pbMountBike
|
||||
elsif !pbCanUseBike?($game_map.map_id)
|
||||
pbDismountBike
|
||||
|
||||
@@ -46,7 +46,8 @@ def pbBattleAnimation(bgm=nil,battletype=0,foe=nil)
|
||||
location = 3
|
||||
elsif $PokemonEncounters.isCave?
|
||||
location = 2
|
||||
elsif !GameData::MapMetadata.get($game_map.map_id).outdoor_map
|
||||
elsif !GameData::MapMetadata.exists?($game_map.map_id) ||
|
||||
!GameData::MapMetadata.get($game_map.map_id).outdoor_map
|
||||
location = 1
|
||||
end
|
||||
anim = ""
|
||||
|
||||
@@ -130,9 +130,9 @@ def pbPrepareBattle(battle)
|
||||
backdrop = $PokemonGlobal.nextBattleBack
|
||||
elsif $PokemonGlobal.surfing
|
||||
backdrop = "water" # This applies wherever you are, including in caves
|
||||
else
|
||||
elsif GameData::MapMetadata.exists?($game_map.map_id)
|
||||
back = GameData::MapMetadata.get($game_map.map_id).battle_background
|
||||
backdrop = back if back && back!=""
|
||||
backdrop = back if back && back != ""
|
||||
end
|
||||
backdrop = "indoor1" if !backdrop
|
||||
battle.backdrop = backdrop
|
||||
@@ -158,7 +158,8 @@ def pbPrepareBattle(battle)
|
||||
end
|
||||
battle.backdropBase = base if base
|
||||
# Time of day
|
||||
if GameData::MapMetadata.get($game_map.map_id).battle_environment == PBEnvironment::Cave
|
||||
if GameData::MapMetadata.exists?($game_map.map_id) &&
|
||||
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
|
||||
@@ -172,8 +173,9 @@ end
|
||||
# Used to determine the environment in battle, and also the form of Burmy/
|
||||
# Wormadam.
|
||||
def pbGetEnvironment
|
||||
ret = GameData::MapMetadata.get($game_map.map_id).battle_environment
|
||||
ret = PBEnvironment::None if !ret
|
||||
ret = PBEnvironment::None
|
||||
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||
ret = map_metadata.battle_environment if map_metadata && map_metadata.battle_environment
|
||||
if $PokemonTemp.encounterType == EncounterTypes::OldRod ||
|
||||
$PokemonTemp.encounterType == EncounterTypes::GoodRod ||
|
||||
$PokemonTemp.encounterType == EncounterTypes::SuperRod
|
||||
|
||||
@@ -178,8 +178,9 @@ EncounterModifier.register(proc { |encounter|
|
||||
# are in the same region
|
||||
if roamerMap!=$game_map.map_id
|
||||
currentRegion = pbGetCurrentRegion
|
||||
map_position = GameData::MapMetadata.get(roamerMap).town_map_position
|
||||
next if !map_position || map_position[0] != currentRegion
|
||||
map_metadata = GameData::MapMetadata.try_get(roamerMap)
|
||||
next if !map_metadata || !map_metadata.town_map_position ||
|
||||
map_metadata.town_map_position[0] != currentRegion
|
||||
currentMapName = pbGetMessage(MessageTypes::MapNames,$game_map.map_id)
|
||||
next if pbGetMessage(MessageTypes::MapNames,roamerMap)!=currentMapName
|
||||
end
|
||||
|
||||
@@ -562,9 +562,10 @@ def pbRandomRoomTile(dungeon,tiles)
|
||||
end
|
||||
|
||||
Events.onMapCreate += proc { |_sender, e|
|
||||
mapID=e[0]
|
||||
map=e[1]
|
||||
if GameData::MapMetadata.get(mapID).random_dungeon
|
||||
mapID = e[0]
|
||||
map = e[1]
|
||||
next if !GameData::MapMetadata.exists?(mapID) ||
|
||||
!GameData::MapMetadata.get(mapID).random_dungeon
|
||||
# this map is a randomly generated dungeon
|
||||
dungeon=Dungeon.new(map.width,map.height)
|
||||
dungeon.generate
|
||||
@@ -584,5 +585,4 @@ Events.onMapCreate += proc { |_sender, e|
|
||||
$game_temp.player_new_x=tile[0]
|
||||
$game_temp.player_new_y=tile[1]
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
@@ -294,8 +294,8 @@ HiddenMoveHandlers::UseMove.add(:DIG,proc { |move,pokemon|
|
||||
# Dive
|
||||
#===============================================================================
|
||||
def pbDive
|
||||
divemap = GameData::MapMetadata.get($game_map.map_id).dive_map_id
|
||||
return false if !divemap
|
||||
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||
return false if !map_metadata || !map_metadata.dive_map_id
|
||||
move = :DIVE
|
||||
movefinder = pbCheckMove(move)
|
||||
if !pbCheckHiddenMoveBadge(BADGE_FOR_DIVE,false) || (!$DEBUG && !movefinder)
|
||||
@@ -307,7 +307,7 @@ def pbDive
|
||||
pbMessage(_INTL("{1} used {2}!",speciesname,GameData::Move.get(move).name))
|
||||
pbHiddenMoveAnimation(movefinder)
|
||||
pbFadeOutIn {
|
||||
$game_temp.player_new_map_id = divemap
|
||||
$game_temp.player_new_map_id = map_metadata.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
|
||||
@@ -404,7 +404,8 @@ HiddenMoveHandlers::CanUseMove.add(:DIVE,proc { |move,pkmn,showmsg|
|
||||
next false
|
||||
end
|
||||
else
|
||||
if !GameData::MapMetadata.get($game_map.map_id).dive_map_id
|
||||
if !GameData::MapMetadata.exists?($game_map.map_id) ||
|
||||
!GameData::MapMetadata.get($game_map.map_id).dive_map_id
|
||||
pbMessage(_INTL("Can't use that here.")) if showmsg
|
||||
next false
|
||||
end
|
||||
@@ -426,7 +427,8 @@ HiddenMoveHandlers::UseMove.add(:DIVE,proc { |move,pokemon|
|
||||
break
|
||||
end
|
||||
else
|
||||
dive_map_id = GameData::MapMetadata.get($game_map.map_id).dive_map_id
|
||||
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||
dive_map_id = map_metadata.dive_map_id if map_metadata
|
||||
end
|
||||
next false if !dive_map_id
|
||||
if !pbHiddenMoveAnimation(pokemon)
|
||||
@@ -454,7 +456,8 @@ HiddenMoveHandlers::UseMove.add(:DIVE,proc { |move,pokemon|
|
||||
#===============================================================================
|
||||
HiddenMoveHandlers::CanUseMove.add(:FLASH,proc { |move,pkmn,showmsg|
|
||||
next false if !pbCheckHiddenMoveBadge(BADGE_FOR_FLASH,showmsg)
|
||||
if !GameData::MapMetadata.get($game_map.map_id).dark_map
|
||||
if !GameData::MapMetadata.exists?($game_map.map_id) ||
|
||||
!GameData::MapMetadata.get($game_map.map_id).dark_map
|
||||
pbMessage(_INTL("Can't use that here.")) if showmsg
|
||||
next false
|
||||
end
|
||||
@@ -494,7 +497,8 @@ 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 !GameData::MapMetadata.get($game_map.map_id).outdoor_map
|
||||
if !GameData::MapMetadata.exists?($game_map.map_id) ||
|
||||
!GameData::MapMetadata.get($game_map.map_id).outdoor_map
|
||||
pbMessage(_INTL("Can't use that here.")) if showmsg
|
||||
next false
|
||||
end
|
||||
@@ -753,7 +757,8 @@ end
|
||||
|
||||
Events.onAction += proc { |_sender,_e|
|
||||
next if $PokemonGlobal.surfing
|
||||
next if GameData::MapMetadata.get($game_map.map_id).always_bicycle
|
||||
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 !$game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player)
|
||||
pbSurf
|
||||
@@ -769,7 +774,8 @@ 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 GameData::MapMetadata.get($game_map.map_id).always_bicycle
|
||||
if GameData::MapMetadata.exists?($game_map.map_id) &&
|
||||
GameData::MapMetadata.get($game_map.map_id).always_bicycle
|
||||
pbMessage(_INTL("Let's enjoy cycling!")) if showmsg
|
||||
next false
|
||||
end
|
||||
@@ -850,7 +856,8 @@ HiddenMoveHandlers::UseMove.add(:SWEETSCENT,proc { |move,pokemon|
|
||||
# Teleport
|
||||
#===============================================================================
|
||||
HiddenMoveHandlers::CanUseMove.add(:TELEPORT,proc { |move,pkmn,showmsg|
|
||||
if !GameData::MapMetadata.get($game_map.map_id).outdoor_map
|
||||
if !GameData::MapMetadata.exists?($game_map.map_id) ||
|
||||
!GameData::MapMetadata.get($game_map.map_id).outdoor_map
|
||||
pbMessage(_INTL("Can't use that here.")) if showmsg
|
||||
next false
|
||||
end
|
||||
|
||||
@@ -117,7 +117,8 @@ end
|
||||
|
||||
def pbDayNightTint(object)
|
||||
return if !$scene.is_a?(Scene_Map)
|
||||
if TIME_SHADING && GameData::MapMetadata.get($game_map.map_id).outdoor_map
|
||||
if TIME_SHADING && GameData::MapMetadata.exists?($game_map.map_id) &&
|
||||
GameData::MapMetadata.get($game_map.map_id).outdoor_map
|
||||
tone = PBDayNight.getTone
|
||||
object.tone.set(tone.red,tone.green,tone.blue,tone.gray)
|
||||
else
|
||||
|
||||
@@ -358,16 +358,15 @@ def pbBikeCheck
|
||||
pbMessage(_INTL("It can't be used when you have someone with you."))
|
||||
return false
|
||||
end
|
||||
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||
if $PokemonGlobal.bicycle
|
||||
if GameData::MapMetadata.get($game_map.map_id).always_bicycle
|
||||
if map_metadata && map_metadata.always_bicycle
|
||||
pbMessage(_INTL("You can't dismount your Bike here."))
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
val = GameData::MapMetadata.get($game_map.map_id).can_bicycle
|
||||
val = GameData::MapMetadata.get($game_map.map_id).outdoor_map if val.nil?
|
||||
if !val
|
||||
if !map_metadata || (!map_metadata.can_bicycle && !map_metadata.outdoor_map)
|
||||
pbMessage(_INTL("Can't use that here."))
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -64,14 +64,16 @@ end
|
||||
def pbRandomPhoneTrainer
|
||||
$PokemonGlobal.phoneNumbers = [] if !$PokemonGlobal.phoneNumbers
|
||||
temparray = []
|
||||
currentRegion = GameData::MapMetadata.get($game_map.map_id).town_map_position
|
||||
return nil if !currentRegion
|
||||
this_map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||
return nil if !this_map_metadata || !this_map_metadata.town_map_position
|
||||
currentRegion = this_map_metadata.town_map_position[0]
|
||||
for num in $PokemonGlobal.phoneNumbers
|
||||
next if !num[0] || num.length!=8 # if not visible or not a trainer
|
||||
next if $game_map.map_id==num[6] # Can't call if on same map
|
||||
callerRegion = GameData::MapMetadata.get(num[6]).town_map_position
|
||||
next if !num[0] || num.length != 8 # if not visible or not a trainer
|
||||
next if $game_map.map_id == num[6] # Can't call if on same map
|
||||
caller_map_metadata = GameData::MapMetadata.try_get(num[6])
|
||||
next if !caller_map_metadata || !caller_map_metadata.town_map_position
|
||||
# Can't call if in different region
|
||||
next if !callerRegion || callerRegion[0] != currentRegion[0]
|
||||
next if caller_map_metadata.town_map_position[0] != currentRegion
|
||||
temparray.push(num)
|
||||
end
|
||||
return nil if temparray.length==0
|
||||
@@ -190,9 +192,11 @@ def pbCallTrainer(trtype,trname)
|
||||
pbMessage(_INTL("The Trainer is close by.\nTalk to the Trainer in person!"))
|
||||
return
|
||||
end
|
||||
callerregion = GameData::MapMetadata.get(trainer[6]).town_map_position
|
||||
currentregion = GameData::MapMetadata.get($game_map.map_id).town_map_position
|
||||
if !callerregion || !currentregion || callerregion[0] != currentregion[0]
|
||||
caller_map_metadata = GameData::MapMetadata.try_get(trainer[6])
|
||||
this_map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||
if !caller_map_metadata || !caller_map_metadata.town_map_position ||
|
||||
!this_map_metadata || !this_map_metadata.town_map_position ||
|
||||
caller_map_metadata.town_map_position[0] != this_map_metadata.town_map_position[0]
|
||||
pbMessage(_INTL("The Trainer is out of range."))
|
||||
return # Can't call if in different region
|
||||
end
|
||||
|
||||
@@ -59,7 +59,7 @@ class Pokemon
|
||||
attr_reader :status
|
||||
# @return [Integer] sleep count / toxic flag / 0:
|
||||
# sleep (number of rounds before waking up), toxic (0 = regular poison, 1 = toxic)
|
||||
attr_reader :statusCount
|
||||
attr_accessor :statusCount
|
||||
# Another Pokémon which has been fused with this Pokémon (or nil if there is none).
|
||||
# Currently only used by Kyurem, to record a fused Reshiram or Zekrom.
|
||||
# @return [Pokemon, nil] the Pokémon fused into this one (nil if there is none)
|
||||
@@ -751,12 +751,6 @@ class Pokemon
|
||||
@status = new_status
|
||||
end
|
||||
|
||||
# Sets a new status count. See {#statusCount} for more information.
|
||||
# @param new_status_count [Integer] new sleep count / toxic flag
|
||||
def statusCount=(new_status_count)
|
||||
@statusCount = new_status_count
|
||||
end
|
||||
|
||||
# @return [Boolean] whether the Pokémon is not fainted and not an egg
|
||||
def able?
|
||||
return !egg? && @hp > 0
|
||||
@@ -824,7 +818,8 @@ class Pokemon
|
||||
# @param check_species [Integer, Symbol, String] id of the species to check for
|
||||
# @return [Boolean] whether this Pokémon is of the specified species
|
||||
def isSpecies?(check_species)
|
||||
return @species == check_species || @species == GameData::Species.get(check_species).species
|
||||
return @species == check_species || (GameData::Species.exists?(check_species) &&
|
||||
@species == GameData::Species.get(check_species).species)
|
||||
end
|
||||
|
||||
def form
|
||||
|
||||
@@ -582,8 +582,9 @@ MultipleForms.register(:NECROZMA,{
|
||||
MultipleForms.register(:PIKACHU, {
|
||||
"getForm" => proc { |pkmn|
|
||||
next if pkmn.formSimple >= 2
|
||||
mapPos = GameData::MapMetadata.get($game_map.map_id).town_map_position
|
||||
next 1 if mapPos && mapPos[0] == 1 # Tiall region
|
||||
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||
next 1 if map_metadata && map_metadata.town_map_position &&
|
||||
map_metadata.town_map_position[0] == 1 # Tiall region
|
||||
next 0
|
||||
}
|
||||
})
|
||||
|
||||
@@ -401,7 +401,8 @@ PBEvolution.register(:LevelDiving, {
|
||||
|
||||
PBEvolution.register(:LevelDarkness, {
|
||||
"levelUpCheck" => proc { |pkmn, parameter|
|
||||
next pkmn.level >= parameter && GameData::MapMetadata.get($game_map.map_id).dark_map
|
||||
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||
next pkmn.level >= parameter && map_metadata && map_metadata.dark_map
|
||||
}
|
||||
})
|
||||
|
||||
@@ -660,8 +661,9 @@ PBEvolution.register(:Location, {
|
||||
PBEvolution.register(:Region, {
|
||||
"minimumLevel" => 1, # Needs any level up
|
||||
"levelUpCheck" => proc { |pkmn, parameter|
|
||||
mapPos = GameData::MapMetadata.get($game_map.map_id).town_map_position
|
||||
next mapPos && mapPos[0] == parameter
|
||||
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||
next map_metadata && map_metadata.town_map_position &&
|
||||
map_metadata.town_map_position[0] == parameter
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -3,11 +3,85 @@
|
||||
# These will be removed in a future Essentials version.
|
||||
#===============================================================================
|
||||
|
||||
# @deprecated Use {Pokemon} instead. PokeBattle_Pokemon has been turned into an alias
|
||||
# and is slated to be removed in v20.
|
||||
class PokeBattle_Pokemon; end
|
||||
# @deprecated Use {Pokemon} instead. PokeBattle_Pokemon is slated to be removed
|
||||
# in v20.
|
||||
class PokeBattle_Pokemon
|
||||
attr_reader :name, :species, :form, :formTime, :forcedForm, :fused
|
||||
attr_reader :personalID, :exp, :hp, :status, :statusCount
|
||||
attr_reader :abilityflag, :genderflag, :natureflag, :natureOverride, :shinyflag
|
||||
attr_reader :moves, :firstmoves
|
||||
attr_reader :item, :mail
|
||||
attr_reader :iv, :ivMaxed, :ev
|
||||
attr_reader :happiness, :eggsteps, :pokerus
|
||||
attr_reader :ballused, :markings, :ribbons
|
||||
attr_reader :obtainMode, :obtainMap, :obtainText, :obtainLevel, :hatchedMap
|
||||
attr_reader :timeReceived, :timeEggHatched
|
||||
attr_reader :cool, :beauty, :cute, :smart, :tough, :sheen
|
||||
attr_reader :trainerID, :ot, :otgender, :language
|
||||
attr_reader :shadow, :heartgauge, :savedexp, :savedev, :hypermode
|
||||
attr_reader :shadowmoves, :shadowmovenum
|
||||
|
||||
PokeBattle_Pokemon = Pokemon
|
||||
def initialise
|
||||
raise "PokeBattle_Pokemon.new is deprecated. Use Pokemon.new instead."
|
||||
end
|
||||
|
||||
def self.copy(pkmn)
|
||||
owner = Pokemon::Owner.new(pkmn.trainerID, pkmn.ot, pkmn.otgender, pkmn.language)
|
||||
ret = Pokemon.new(pkmn.species, pkmn.level, owner, false)
|
||||
ret.name = pkmn.name
|
||||
ret.exp = pkmn.exp
|
||||
ret.formTime = pkmn.formTime
|
||||
ret.forcedForm = pkmn.forcedForm
|
||||
ret.hp = pkmn.hp
|
||||
ret.abilityflag = pkmn.abilityflag
|
||||
ret.genderflag = pkmn.genderflag
|
||||
ret.natureflag = pkmn.natureflag
|
||||
ret.natureOverride = pkmn.natureOverride
|
||||
ret.shinyflag = pkmn.shinyflag
|
||||
ret.item_id = pkmn.item
|
||||
ret.mail = pkmn.mail
|
||||
ret.moves = pkmn.moves
|
||||
ret.firstmoves = pkmn.firstmoves.clone
|
||||
ret.status = pkmn.status
|
||||
ret.statusCount = pkmn.statusCount
|
||||
ret.iv = pkmn.iv.clone
|
||||
ret.ev = pkmn.ev.clone
|
||||
ret.ivMaxed = pkmn.ivMaxed if pkmn.ivMaxed
|
||||
ret.happiness = pkmn.happiness
|
||||
ret.ballused = pkmn.ballused
|
||||
ret.eggsteps = pkmn.eggsteps
|
||||
ret.markings = pkmn.markings if pkmn.markings
|
||||
ret.ribbons = pkmn.ribbons.clone
|
||||
ret.pokerus = pkmn.pokerus
|
||||
ret.personalID = pkmn.personalID
|
||||
ret.obtainMode = pkmn.obtainMode
|
||||
ret.obtainMap = pkmn.obtainMap
|
||||
ret.obtainText = pkmn.obtainText
|
||||
ret.obtainLevel = pkmn.obtainLevel if pkmn.obtainLevel
|
||||
ret.hatchedMap = pkmn.hatchedMap
|
||||
ret.timeReceived = pkmn.timeReceived
|
||||
ret.timeEggHatched = pkmn.timeEggHatched
|
||||
ret.cool = pkmn.cool if pkmn.cool
|
||||
ret.beauty = pkmn.beauty if pkmn.beauty
|
||||
ret.cute = pkmn.cute if pkmn.cute
|
||||
ret.smart = pkmn.smart if pkmn.smart
|
||||
ret.tough = pkmn.tough if pkmn.tough
|
||||
ret.sheen = pkmn.sheen if pkmn.sheen
|
||||
if pkmn.fused
|
||||
ret.fused = PokeBattle_Pokemon.copy(pkmn.fused) if pkmn.fused.is_a?(PokeBattle_Pokemon)
|
||||
ret.fused = pkmn.fused if pkmn.fused.is_a?(Pokemon)
|
||||
end
|
||||
ret.shadow = pkmn.shadow
|
||||
ret.heartgauge = pkmn.heartgauge
|
||||
ret.savedexp = pkmn.savedexp
|
||||
ret.savedev = pkmn.savedev.clone
|
||||
ret.hypermode = pkmn.hypermode
|
||||
ret.shadowmoves = pkmn.shadowmoves.clone
|
||||
ret.shadowmovenum = pkmn.shadowmovenum
|
||||
# NOTE: Intentionally set last, as it recalculates stats.
|
||||
ret.formSimple = pkmn.form
|
||||
end
|
||||
end
|
||||
|
||||
class Pokemon
|
||||
# @deprecated Use {MAX_NAME_SIZE} instead. This alias is slated to be removed in v20.
|
||||
|
||||
@@ -17,8 +17,9 @@ class PokemonPokedexInfo_Scene
|
||||
@sprites["infosprite"].x = 104
|
||||
@sprites["infosprite"].y = 136
|
||||
@mapdata = pbLoadTownMapData
|
||||
mappos = ($game_map) ? GameData::MapMetadata.get($game_map.map_id).town_map_position : nil
|
||||
if @region<0 # Use player's current region
|
||||
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||
mappos = (map_metadata) ? map_metadata.town_map_position : nil
|
||||
if @region < 0 # Use player's current region
|
||||
@region = (mappos) ? mappos[0] : 0 # Region 0 default
|
||||
end
|
||||
@sprites["areamap"] = IconSprite.new(0,0,@viewport)
|
||||
@@ -300,16 +301,17 @@ class PokemonPokedexInfo_Scene
|
||||
encdata = pbLoadEncountersData
|
||||
for enc in encdata.keys
|
||||
enctypes = encdata[enc][1]
|
||||
if pbFindEncounter(enctypes,@species)
|
||||
mappos = GameData::MapMetadata.get(enc).town_map_position
|
||||
if mappos && mappos[0]==@region
|
||||
next if !pbFindEncounter(enctypes, @species)
|
||||
map_metadata = GameData::MapMetadata.try_get(enc)
|
||||
mappos = (map_metadata) ? map_metadata.town_map_position : nil
|
||||
next if !mappos || mappos[0] != @region
|
||||
showpoint = true
|
||||
for loc in @mapdata[@region][2]
|
||||
showpoint = false if loc[0]==mappos[1] && loc[1]==mappos[2] &&
|
||||
loc[7] && !$game_switches[loc[7]]
|
||||
end
|
||||
if showpoint
|
||||
mapsize = GameData::MapMetadata.get(enc).town_map_size
|
||||
next if !showpoint
|
||||
mapsize = map_metadata.town_map_size
|
||||
if mapsize && mapsize[0] && mapsize[0]>0
|
||||
sqwidth = mapsize[0]
|
||||
sqheight = (mapsize[1].length*1.0/mapsize[0]).ceil
|
||||
@@ -324,9 +326,6 @@ class PokemonPokedexInfo_Scene
|
||||
points[mappos[1]+mappos[2]*mapwidth] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# Draw coloured squares on each square of the region map with a nest
|
||||
pointcolor = Color.new(0,248,248)
|
||||
pointcolorhl = Color.new(192,248,248)
|
||||
|
||||
@@ -81,7 +81,8 @@ class PokemonRegionMap_Scene
|
||||
@viewport.z = 99999
|
||||
@sprites = {}
|
||||
@mapdata = pbLoadTownMapData
|
||||
playerpos = (!$game_map) ? nil : GameData::MapMetadata.get($game_map.map_id).town_map_position
|
||||
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||
playerpos = (map_metadata) ? map_metadata.town_map_position : nil
|
||||
if !playerpos
|
||||
mapindex = 0
|
||||
@map = @mapdata[0]
|
||||
@@ -97,7 +98,7 @@ class PokemonRegionMap_Scene
|
||||
@map = @mapdata[playerpos[0]]
|
||||
@mapX = playerpos[1]
|
||||
@mapY = playerpos[2]
|
||||
mapsize = (!$game_map) ? nil : GameData::MapMetadata.get($game_map.map_id).town_map_size
|
||||
mapsize = map_metadata.town_map_size
|
||||
if mapsize && mapsize[0] && mapsize[0]>0
|
||||
sqwidth = mapsize[0]
|
||||
sqheight = (mapsize[1].length*1.0/mapsize[0]).ceil
|
||||
|
||||
@@ -61,8 +61,9 @@ def pbInSafari?
|
||||
# Reception map is handled separately from safari map since the reception
|
||||
# map can be outdoors, with its own grassy patches.
|
||||
reception = pbSafariState.pbReceptionMap
|
||||
return true if $game_map.map_id==reception
|
||||
return true if GameData::MapMetadata.get($game_map.map_id).safari_map
|
||||
return true if $game_map.map_id == reception
|
||||
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||
return true if map_metadata && map_metadata.safari_map
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -8,8 +8,9 @@ def pbGetWildBattleBGM(_wildParty) # wildParty is an array of Pokémon objects
|
||||
ret = nil
|
||||
if !ret
|
||||
# Check map metadata
|
||||
music = GameData::MapMetadata.get($game_map.map_id).wild_battle_BGM
|
||||
ret = pbStringToAudioFile(music) if music && music!=""
|
||||
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||
music = (map_metadata) ? map_metadata.wild_battle_BGM : nil
|
||||
ret = pbStringToAudioFile(music) if music && music != ""
|
||||
end
|
||||
if !ret
|
||||
# Check global metadata
|
||||
@@ -27,8 +28,9 @@ def pbGetWildVictoryME
|
||||
ret = nil
|
||||
if !ret
|
||||
# Check map metadata
|
||||
music = GameData::MapMetadata.get($game_map.map_id).wild_victory_ME
|
||||
ret = pbStringToAudioFile(music) if music && music!=""
|
||||
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||
music = (map_metadata) ? map_metadata.wild_victory_ME : nil
|
||||
ret = pbStringToAudioFile(music) if music && music != ""
|
||||
end
|
||||
if !ret
|
||||
# Check global metadata
|
||||
@@ -47,8 +49,9 @@ def pbGetWildCaptureME
|
||||
ret = nil
|
||||
if !ret
|
||||
# Check map metadata
|
||||
music = GameData::MapMetadata.get($game_map.map_id).wild_capture_ME
|
||||
ret = pbStringToAudioFile(music) if music && music!=""
|
||||
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||
music = (map_metadata) ? map_metadata.wild_capture_ME : nil
|
||||
ret = pbStringToAudioFile(music) if music && music != ""
|
||||
end
|
||||
if !ret
|
||||
# Check global metadata
|
||||
@@ -84,10 +87,9 @@ def pbGetTrainerBattleBGM(trainer) # can be a PokeBattle_Trainer or an array o
|
||||
ret = pbStringToAudioFile(music) if music && music!=""
|
||||
if !ret
|
||||
# Check map metadata
|
||||
music = GameData::MapMetadata.get($game_map.map_id).trainer_battle_BGM
|
||||
if music && music!=""
|
||||
ret = pbStringToAudioFile(music)
|
||||
end
|
||||
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||
music = (map_metadata) ? map_metadata.trainer_battle_BGM : nil
|
||||
ret = pbStringToAudioFile(music) if music && music != ""
|
||||
end
|
||||
if !ret
|
||||
# Check global metadata
|
||||
@@ -108,8 +110,9 @@ def pbGetTrainerBattleBGMFromType(trainertype)
|
||||
ret = trainer_type_data.battle_BGM if trainer_type_data.battle_BGM
|
||||
if !ret
|
||||
# Check map metadata
|
||||
music = GameData::MapMetadata.get($game_map.map_id).trainer_battle_BGM
|
||||
ret = pbStringToAudioFile(music) if music && music!=""
|
||||
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||
music = (map_metadata) ? map_metadata.trainer_battle_BGM : nil
|
||||
ret = pbStringToAudioFile(music) if music && music != ""
|
||||
end
|
||||
if !ret
|
||||
# Check global metadata
|
||||
@@ -136,10 +139,9 @@ def pbGetTrainerVictoryME(trainer) # can be a PokeBattle_Trainer or an array o
|
||||
end
|
||||
if !ret
|
||||
# Check map metadata
|
||||
music = GameData::MapMetadata.get($game_map.map_id).trainer_victory_ME
|
||||
if music && music!=""
|
||||
ret = pbStringToAudioFile(music)
|
||||
end
|
||||
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||
music = (map_metadata) ? map_metadata.trainer_victory_ME : nil
|
||||
ret = pbStringToAudioFile(music) if music && music != ""
|
||||
end
|
||||
if !ret
|
||||
# Check global metadata
|
||||
|
||||
@@ -79,7 +79,7 @@ def pbAddPokemon(pkmn, level = 1, see_form = true)
|
||||
end
|
||||
|
||||
def pbAddPokemonSilent(pkmn, level = 1, see_form = true)
|
||||
return false if !pokemon || pbBoxesFull?
|
||||
return false if !pkmn || pbBoxesFull?
|
||||
pkmn = Pokemon.new(pkmn, level) if !pkmn.is_a?(Pokemon)
|
||||
$Trainer.seen[pkmn.species] = true
|
||||
$Trainer.owned[pkmn.species] = true
|
||||
|
||||
@@ -392,7 +392,9 @@ end
|
||||
# Returns the ID number of the region containing the player's current location,
|
||||
# as determined by the current map's metadata.
|
||||
def pbGetCurrentRegion(default = -1)
|
||||
map_pos = ($game_map) ? GameData::MapMetadata.get($game_map.map_id).town_map_position : nil
|
||||
return default if !$game_map
|
||||
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||
map_pos = (map_metadata) ? map_metadata.town_map_position : nil
|
||||
return (map_pos) ? map_pos[0] : default
|
||||
end
|
||||
|
||||
|
||||
@@ -612,7 +612,8 @@ def pbEditMetadata(map_id = 0)
|
||||
properties = GameData::Metadata.editor_properties
|
||||
else # Map metadata
|
||||
map_name = mapinfos[map_id].name
|
||||
metadata = GameData::MapMetadata.get(map_id)
|
||||
metadata = GameData::MapMetadata.try_get(map_id)
|
||||
metadata = GameData::Metadata.new({}) if !metadata
|
||||
properties = GameData::MapMetadata.editor_properties
|
||||
end
|
||||
properties.each do |property|
|
||||
|
||||
Reference in New Issue
Block a user