mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-08 05:34:58 +00:00
Rearranged some code relating to data and its caching
This commit is contained in:
281
Data/Scripts/011_Data/001_Data_Cache.rb
Normal file
281
Data/Scripts/011_Data/001_Data_Cache.rb
Normal file
@@ -0,0 +1,281 @@
|
|||||||
|
#===============================================================================
|
||||||
|
# Data caches.
|
||||||
|
#===============================================================================
|
||||||
|
class PokemonTemp
|
||||||
|
attr_accessor :metadata
|
||||||
|
attr_accessor :townMapData
|
||||||
|
attr_accessor :encountersData
|
||||||
|
attr_accessor :phoneData
|
||||||
|
attr_accessor :regionalDexes
|
||||||
|
attr_accessor :speciesData
|
||||||
|
attr_accessor :speciesEggMoves
|
||||||
|
attr_accessor :speciesMetrics
|
||||||
|
attr_accessor :speciesMovesets
|
||||||
|
attr_accessor :speciesTMData
|
||||||
|
attr_accessor :speciesShadowMovesets
|
||||||
|
attr_accessor :pokemonFormToSpecies
|
||||||
|
attr_accessor :trainerTypesData
|
||||||
|
attr_accessor :trainersData
|
||||||
|
attr_accessor :moveToAnim
|
||||||
|
attr_accessor :battleAnims
|
||||||
|
end
|
||||||
|
|
||||||
|
def pbClearData
|
||||||
|
if $PokemonTemp
|
||||||
|
$PokemonTemp.metadata = nil
|
||||||
|
$PokemonTemp.townMapData = nil
|
||||||
|
$PokemonTemp.encountersData = nil
|
||||||
|
$PokemonTemp.phoneData = nil
|
||||||
|
$PokemonTemp.regionalDexes = nil
|
||||||
|
$PokemonTemp.speciesData = nil
|
||||||
|
$PokemonTemp.speciesEggMoves = nil
|
||||||
|
$PokemonTemp.speciesMetrics = nil
|
||||||
|
$PokemonTemp.speciesMovesets = nil
|
||||||
|
$PokemonTemp.speciesTMData = nil
|
||||||
|
$PokemonTemp.speciesShadowMovesets = nil
|
||||||
|
$PokemonTemp.pokemonFormToSpecies = nil
|
||||||
|
$PokemonTemp.trainerTypesData = nil
|
||||||
|
$PokemonTemp.trainersData = nil
|
||||||
|
$PokemonTemp.moveToAnim = nil
|
||||||
|
$PokemonTemp.battleAnims = nil
|
||||||
|
end
|
||||||
|
MapFactoryHelper.clear
|
||||||
|
$PokemonEncounters.setup($game_map.map_id) if $game_map && $PokemonEncounters
|
||||||
|
if pbRgssExists?("Data/Tilesets.rxdata")
|
||||||
|
$data_tilesets = load_data("Data/Tilesets.rxdata")
|
||||||
|
end
|
||||||
|
if pbRgssExists?("Data/Tilesets.rvdata")
|
||||||
|
$data_tilesets = load_data("Data/Tilesets.rvdata")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# Methods to get metadata.
|
||||||
|
#===============================================================================
|
||||||
|
def pbLoadMetadata
|
||||||
|
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
||||||
|
if !$PokemonTemp.metadata
|
||||||
|
$PokemonTemp.metadata = load_data("Data/metadata.dat") || []
|
||||||
|
end
|
||||||
|
return $PokemonTemp.metadata
|
||||||
|
end
|
||||||
|
|
||||||
|
def pbGetMetadata(map_id, metadata_type)
|
||||||
|
meta = pbLoadMetadata
|
||||||
|
return meta[map_id][metadata_type] if meta[map_id]
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# Method to get Town Map data.
|
||||||
|
#===============================================================================
|
||||||
|
def pbLoadTownMapData
|
||||||
|
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
||||||
|
if !$PokemonTemp.townMapData
|
||||||
|
$PokemonTemp.townMapData = load_data("Data/town_map.dat")
|
||||||
|
end
|
||||||
|
return $PokemonTemp.townMapData
|
||||||
|
end
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# Method to get wild encounter data.
|
||||||
|
#===============================================================================
|
||||||
|
def pbLoadEncountersData
|
||||||
|
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
||||||
|
if !$PokemonTemp.encountersData
|
||||||
|
if pbRgssExists?("Data/encounters.dat")
|
||||||
|
$PokemonTemp.encountersData = load_data("Data/encounters.dat")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return $PokemonTemp.encountersData
|
||||||
|
end
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# Method to get phone call data.
|
||||||
|
#===============================================================================
|
||||||
|
def pbLoadPhoneData
|
||||||
|
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
||||||
|
if !$PokemonTemp.phoneData
|
||||||
|
if pbRgssExists?("Data/phone.dat")
|
||||||
|
$PokemonTemp.phoneData = load_data("Data/phone.dat")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return $PokemonTemp.phoneData
|
||||||
|
end
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# Method to get Regional Dexes data.
|
||||||
|
#===============================================================================
|
||||||
|
def pbLoadRegionalDexes
|
||||||
|
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
||||||
|
if !$PokemonTemp.regionalDexes
|
||||||
|
$PokemonTemp.regionalDexes = load_data("Data/regional_dexes.dat")
|
||||||
|
end
|
||||||
|
return $PokemonTemp.regionalDexes
|
||||||
|
end
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# Methods to get Pokémon species data.
|
||||||
|
#===============================================================================
|
||||||
|
def pbLoadSpeciesData
|
||||||
|
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
||||||
|
if !$PokemonTemp.speciesData
|
||||||
|
$PokemonTemp.speciesData = load_data("Data/species.dat") || []
|
||||||
|
end
|
||||||
|
return $PokemonTemp.speciesData
|
||||||
|
end
|
||||||
|
|
||||||
|
def pbGetSpeciesData(species, form = 0, species_data_type = -1)
|
||||||
|
species = getID(PBSpecies, species)
|
||||||
|
s = pbGetFSpeciesFromForm(species, form)
|
||||||
|
species_data = pbLoadSpeciesData
|
||||||
|
if species_data_type < 0
|
||||||
|
return species_data[s] || []
|
||||||
|
end
|
||||||
|
return species_data[s][species_data_type] if species_data[s] && species_data[s][species_data_type]
|
||||||
|
case species_data_type
|
||||||
|
when SpeciesType2; return nil
|
||||||
|
when SpeciesBaseStats; return [1, 1, 1, 1, 1, 1]
|
||||||
|
when SpeciesEffortPoints; return [0, 0, 0, 0, 0, 0]
|
||||||
|
when SpeciesStepsToHatch, SpeciesHeight, SpeciesWeight; return 1
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# Methods to get egg moves data.
|
||||||
|
#===============================================================================
|
||||||
|
def pbLoadEggMovesData
|
||||||
|
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
||||||
|
if !$PokemonTemp.speciesEggMoves
|
||||||
|
$PokemonTemp.speciesEggMoves = load_data("Data/species_eggmoves.dat") || []
|
||||||
|
end
|
||||||
|
return $PokemonTemp.speciesEggMoves
|
||||||
|
end
|
||||||
|
|
||||||
|
def pbGetSpeciesEggMoves(species, form = 0)
|
||||||
|
species = getID(PBSpecies, species)
|
||||||
|
s = pbGetFSpeciesFromForm(species, form)
|
||||||
|
egg_moves_data = pbLoadEggMovesData
|
||||||
|
return egg_moves_data[s] || []
|
||||||
|
end
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# Method to get Pokémon species metrics (sprite positioning) data.
|
||||||
|
#===============================================================================
|
||||||
|
def pbLoadSpeciesMetrics
|
||||||
|
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
||||||
|
if !$PokemonTemp.speciesMetrics
|
||||||
|
$PokemonTemp.speciesMetrics = load_data("Data/species_metrics.dat") || []
|
||||||
|
end
|
||||||
|
return $PokemonTemp.speciesMetrics
|
||||||
|
end
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# Methods to get Pokémon moveset data.
|
||||||
|
#===============================================================================
|
||||||
|
def pbLoadMovesetsData
|
||||||
|
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
||||||
|
if !$PokemonTemp.speciesMovesets
|
||||||
|
$PokemonTemp.speciesMovesets = load_data("Data/species_movesets.dat") || []
|
||||||
|
end
|
||||||
|
return $PokemonTemp.speciesMovesets
|
||||||
|
end
|
||||||
|
|
||||||
|
def pbGetSpeciesMoveset(species, form = 0)
|
||||||
|
species = getID(PBSpecies, species)
|
||||||
|
s = pbGetFSpeciesFromForm(species, form)
|
||||||
|
movesets_data = pbLoadMovesetsData
|
||||||
|
return movesets_data[s] || []
|
||||||
|
end
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# Method to get TM/Move Tutor compatibility data.
|
||||||
|
#===============================================================================
|
||||||
|
def pbLoadSpeciesTMData
|
||||||
|
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
||||||
|
if !$PokemonTemp.speciesTMData
|
||||||
|
$PokemonTemp.speciesTMData = load_data("Data/tm.dat") || []
|
||||||
|
end
|
||||||
|
return $PokemonTemp.speciesTMData
|
||||||
|
end
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# Method to get Shadow Pokémon moveset data.
|
||||||
|
#===============================================================================
|
||||||
|
def pbLoadShadowMovesets
|
||||||
|
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
||||||
|
if !$PokemonTemp.speciesShadowMovesets
|
||||||
|
$PokemonTemp.speciesShadowMovesets = load_data("Data/shadow_movesets.dat") || []
|
||||||
|
end
|
||||||
|
return $PokemonTemp.speciesShadowMovesets
|
||||||
|
end
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# Method to get array that converts species + form to and from fSpecies values.
|
||||||
|
#===============================================================================
|
||||||
|
def pbLoadFormToSpecies
|
||||||
|
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
||||||
|
if !$PokemonTemp.pokemonFormToSpecies
|
||||||
|
$PokemonTemp.pokemonFormToSpecies = load_data("Data/form2species.dat")
|
||||||
|
end
|
||||||
|
return $PokemonTemp.pokemonFormToSpecies
|
||||||
|
end
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# Methods to get trainer type data.
|
||||||
|
#===============================================================================
|
||||||
|
def pbLoadTrainerTypesData
|
||||||
|
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
||||||
|
if !$PokemonTemp.trainerTypesData
|
||||||
|
$PokemonTemp.trainerTypesData = load_data("Data/trainer_types.dat") || []
|
||||||
|
end
|
||||||
|
return $PokemonTemp.trainerTypesData
|
||||||
|
end
|
||||||
|
|
||||||
|
def pbGetTrainerTypeData(trainer_type)
|
||||||
|
trainer_type_data = pbLoadTrainerTypesData
|
||||||
|
return trainer_type_data[trainer_type] if trainer_type_data
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# Methods to get data about individual trainers.
|
||||||
|
#===============================================================================
|
||||||
|
def pbLoadTrainersData
|
||||||
|
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
||||||
|
if !$PokemonTemp.trainersData
|
||||||
|
$PokemonTemp.trainersData = load_data("Data/trainers.dat") || []
|
||||||
|
end
|
||||||
|
return $PokemonTemp.trainersData
|
||||||
|
end
|
||||||
|
|
||||||
|
def pbGetTrainerData(trainer_id, trainer_name, party_id = 0)
|
||||||
|
trainers_data = pbLoadTrainersData
|
||||||
|
for t in trainers_data
|
||||||
|
next if t[0] != trainer_id || t[1] != trainer_name || t[4] != party_id
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# Methods relating to battle animations data.
|
||||||
|
#===============================================================================
|
||||||
|
def pbLoadMoveToAnim
|
||||||
|
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
||||||
|
if !$PokemonTemp.moveToAnim
|
||||||
|
$PokemonTemp.moveToAnim = load_data("Data/move2anim.dat") || []
|
||||||
|
end
|
||||||
|
return $PokemonTemp.moveToAnim
|
||||||
|
end
|
||||||
|
|
||||||
|
def pbLoadBattleAnimations
|
||||||
|
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
||||||
|
if !$PokemonTemp.battleAnims
|
||||||
|
if pbRgssExists?("Data/PkmnAnimations.rxdata")
|
||||||
|
$PokemonTemp.battleAnims = load_data("Data/PkmnAnimations.rxdata")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return $PokemonTemp.battleAnims
|
||||||
|
end
|
||||||
@@ -23,8 +23,6 @@ class PhoneDatabase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module PhoneMsgType
|
module PhoneMsgType
|
||||||
Generic = 0
|
Generic = 0
|
||||||
Greeting = 1
|
Greeting = 1
|
||||||
@@ -32,8 +30,6 @@ module PhoneMsgType
|
|||||||
BattleRequest = 3
|
BattleRequest = 3
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# Global and map metadata
|
# Global and map metadata
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
@@ -75,8 +71,6 @@ MetadataMapWildCaptureME = 18
|
|||||||
MetadataMapSize = 19
|
MetadataMapSize = 19
|
||||||
MetadataEnvironment = 20
|
MetadataEnvironment = 20
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module PokemonMetadata
|
module PokemonMetadata
|
||||||
GlobalTypes = {
|
GlobalTypes = {
|
||||||
"Home" => [MetadataHome, "uuuu"],
|
"Home" => [MetadataHome, "uuuu"],
|
||||||
@@ -120,8 +114,6 @@ module PokemonMetadata
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# Pokémon data
|
# Pokémon data
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
@@ -161,8 +153,6 @@ MetricBattlerAltitude = 4
|
|||||||
MetricBattlerShadowX = 5
|
MetricBattlerShadowX = 5
|
||||||
MetricBattlerShadowSize = 6
|
MetricBattlerShadowSize = 6
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module PokemonSpeciesData
|
module PokemonSpeciesData
|
||||||
def self.requiredValues(compilingForms=false)
|
def self.requiredValues(compilingForms=false)
|
||||||
ret = {
|
ret = {
|
||||||
@@ -225,248 +215,3 @@ module PokemonSpeciesData
|
|||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#===============================================================================
|
|
||||||
# Manipulation methods for metadata, phone data and Pokémon species data
|
|
||||||
#===============================================================================
|
|
||||||
class PokemonTemp
|
|
||||||
attr_accessor :metadata
|
|
||||||
attr_accessor :townMapData
|
|
||||||
attr_accessor :encountersData
|
|
||||||
attr_accessor :phoneData
|
|
||||||
attr_accessor :regionalDexes
|
|
||||||
attr_accessor :speciesData
|
|
||||||
attr_accessor :speciesEggMoves
|
|
||||||
attr_accessor :speciesMetrics
|
|
||||||
attr_accessor :speciesMovesets
|
|
||||||
attr_accessor :speciesTMData
|
|
||||||
attr_accessor :speciesShadowMovesets
|
|
||||||
attr_accessor :pokemonFormToSpecies
|
|
||||||
attr_accessor :trainerTypesData
|
|
||||||
attr_accessor :trainersData
|
|
||||||
attr_accessor :moveToAnim
|
|
||||||
attr_accessor :battleAnims
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def pbLoadMetadata
|
|
||||||
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
|
||||||
if !$PokemonTemp.metadata
|
|
||||||
$PokemonTemp.metadata = load_data("Data/metadata.dat") || []
|
|
||||||
end
|
|
||||||
return $PokemonTemp.metadata
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbGetMetadata(mapid,metadataType)
|
|
||||||
meta = pbLoadMetadata
|
|
||||||
return meta[mapid][metadataType] if meta[mapid]
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbLoadTownMapData
|
|
||||||
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
|
||||||
if !$PokemonTemp.townMapData
|
|
||||||
$PokemonTemp.townMapData = load_data("Data/town_map.dat")
|
|
||||||
end
|
|
||||||
return $PokemonTemp.townMapData
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbLoadEncountersData
|
|
||||||
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
|
||||||
if !$PokemonTemp.encountersData
|
|
||||||
if pbRgssExists?("Data/encounters.dat")
|
|
||||||
$PokemonTemp.encountersData = load_data("Data/encounters.dat")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return $PokemonTemp.encountersData
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbLoadPhoneData
|
|
||||||
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
|
||||||
if !$PokemonTemp.phoneData
|
|
||||||
if pbRgssExists?("Data/phone.dat")
|
|
||||||
$PokemonTemp.phoneData = load_data("Data/phone.dat")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return $PokemonTemp.phoneData
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbLoadRegionalDexes
|
|
||||||
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
|
||||||
if !$PokemonTemp.regionalDexes
|
|
||||||
$PokemonTemp.regionalDexes = load_data("Data/regional_dexes.dat")
|
|
||||||
end
|
|
||||||
return $PokemonTemp.regionalDexes
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbLoadSpeciesData
|
|
||||||
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
|
||||||
if !$PokemonTemp.speciesData
|
|
||||||
$PokemonTemp.speciesData = load_data("Data/species.dat") || []
|
|
||||||
end
|
|
||||||
return $PokemonTemp.speciesData
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbGetSpeciesData(species,form=0,speciesDataType=-1)
|
|
||||||
species = getID(PBSpecies,species)
|
|
||||||
s = pbGetFSpeciesFromForm(species,form)
|
|
||||||
speciesData = pbLoadSpeciesData
|
|
||||||
if speciesDataType<0
|
|
||||||
return speciesData[s] || []
|
|
||||||
end
|
|
||||||
return speciesData[s][speciesDataType] if speciesData[s] && speciesData[s][speciesDataType]
|
|
||||||
case speciesDataType
|
|
||||||
when SpeciesType2; return nil
|
|
||||||
when SpeciesBaseStats; return [1,1,1,1,1,1]
|
|
||||||
when SpeciesEffortPoints; return [0,0,0,0,0,0]
|
|
||||||
when SpeciesStepsToHatch, SpeciesHeight, SpeciesWeight; return 1
|
|
||||||
end
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbLoadEggMovesData
|
|
||||||
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
|
||||||
if !$PokemonTemp.speciesEggMoves
|
|
||||||
$PokemonTemp.speciesEggMoves = load_data("Data/species_eggmoves.dat") || []
|
|
||||||
end
|
|
||||||
return $PokemonTemp.speciesEggMoves
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbGetSpeciesEggMoves(species,form=0)
|
|
||||||
species = getID(PBSpecies,species)
|
|
||||||
s = pbGetFSpeciesFromForm(species,form)
|
|
||||||
eggMovesData = pbLoadEggMovesData
|
|
||||||
return eggMovesData[s] if eggMovesData[s]
|
|
||||||
return []
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbLoadSpeciesMetrics
|
|
||||||
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
|
||||||
if !$PokemonTemp.speciesMetrics
|
|
||||||
$PokemonTemp.speciesMetrics = load_data("Data/species_metrics.dat") || []
|
|
||||||
end
|
|
||||||
return $PokemonTemp.speciesMetrics
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbLoadMovesetsData
|
|
||||||
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
|
||||||
if !$PokemonTemp.speciesMovesets
|
|
||||||
$PokemonTemp.speciesMovesets = load_data("Data/species_movesets.dat") || []
|
|
||||||
end
|
|
||||||
return $PokemonTemp.speciesMovesets
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbGetSpeciesMoveset(species,form=0)
|
|
||||||
species = getID(PBSpecies,species)
|
|
||||||
s = pbGetFSpeciesFromForm(species,form)
|
|
||||||
movesetsData = pbLoadMovesetsData
|
|
||||||
return movesetsData[s] if movesetsData[s]
|
|
||||||
return []
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbLoadSpeciesTMData
|
|
||||||
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
|
||||||
if !$PokemonTemp.speciesTMData
|
|
||||||
$PokemonTemp.speciesTMData = load_data("Data/tm.dat") || []
|
|
||||||
end
|
|
||||||
return $PokemonTemp.speciesTMData
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbLoadShadowMovesets
|
|
||||||
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
|
||||||
if !$PokemonTemp.speciesShadowMovesets
|
|
||||||
$PokemonTemp.speciesShadowMovesets = load_data("Data/shadow_movesets.dat") || []
|
|
||||||
end
|
|
||||||
return $PokemonTemp.speciesShadowMovesets
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbLoadFormToSpecies
|
|
||||||
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
|
||||||
if !$PokemonTemp.pokemonFormToSpecies
|
|
||||||
$PokemonTemp.pokemonFormToSpecies = load_data("Data/form2species.dat")
|
|
||||||
end
|
|
||||||
return $PokemonTemp.pokemonFormToSpecies
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbLoadTrainerTypesData
|
|
||||||
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
|
||||||
if !$PokemonTemp.trainerTypesData
|
|
||||||
$PokemonTemp.trainerTypesData = load_data("Data/trainer_types.dat") || []
|
|
||||||
end
|
|
||||||
return $PokemonTemp.trainerTypesData
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbGetTrainerTypeData(type)
|
|
||||||
data = pbLoadTrainerTypesData
|
|
||||||
return data[type] if data
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbLoadTrainersData
|
|
||||||
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
|
||||||
if !$PokemonTemp.trainersData
|
|
||||||
$PokemonTemp.trainersData = load_data("Data/trainers.dat") || []
|
|
||||||
end
|
|
||||||
return $PokemonTemp.trainersData
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbGetTrainerData(trainerID,trainerName,partyID=0)
|
|
||||||
trainersData = pbLoadTrainersData
|
|
||||||
ret = nil
|
|
||||||
for t in trainersData
|
|
||||||
next if t[0]!=trainerID || t[1]!=trainerName || t[4]!=partyID
|
|
||||||
ret = t
|
|
||||||
break
|
|
||||||
end
|
|
||||||
return ret
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbLoadMoveToAnim
|
|
||||||
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
|
||||||
if !$PokemonTemp.moveToAnim
|
|
||||||
$PokemonTemp.moveToAnim = load_data("Data/move2anim.dat") || []
|
|
||||||
end
|
|
||||||
return $PokemonTemp.moveToAnim
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbLoadBattleAnimations
|
|
||||||
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
|
||||||
if !$PokemonTemp.battleAnims
|
|
||||||
if pbRgssExists?("Data/PkmnAnimations.rxdata")
|
|
||||||
$PokemonTemp.battleAnims = load_data("Data/PkmnAnimations.rxdata")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return $PokemonTemp.battleAnims
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbClearData
|
|
||||||
if $PokemonTemp
|
|
||||||
$PokemonTemp.metadata = nil
|
|
||||||
$PokemonTemp.townMapData = nil
|
|
||||||
$PokemonTemp.encountersData = nil
|
|
||||||
$PokemonTemp.phoneData = nil
|
|
||||||
$PokemonTemp.regionalDexes = nil
|
|
||||||
$PokemonTemp.speciesData = nil
|
|
||||||
$PokemonTemp.speciesEggMoves = nil
|
|
||||||
$PokemonTemp.speciesMetrics = nil
|
|
||||||
$PokemonTemp.speciesMovesets = nil
|
|
||||||
$PokemonTemp.speciesTMData = nil
|
|
||||||
$PokemonTemp.speciesShadowMovesets = nil
|
|
||||||
$PokemonTemp.pokemonFormToSpecies = nil
|
|
||||||
$PokemonTemp.trainerTypesData = nil
|
|
||||||
$PokemonTemp.trainersData = nil
|
|
||||||
$PokemonTemp.moveToAnim = nil
|
|
||||||
$PokemonTemp.battleAnims = nil
|
|
||||||
end
|
|
||||||
MapFactoryHelper.clear
|
|
||||||
$PokemonEncounters.setup($game_map.map_id) if $game_map && $PokemonEncounters
|
|
||||||
if pbRgssExists?("Data/Tilesets.rxdata")
|
|
||||||
$data_tilesets = load_data("Data/Tilesets.rxdata")
|
|
||||||
end
|
|
||||||
if pbRgssExists?("Data/Tilesets.rvdata")
|
|
||||||
$data_tilesets = load_data("Data/Tilesets.rvdata")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
MOVE_ID = 0
|
|
||||||
MOVE_INTERNAL_NAME = 1
|
|
||||||
MOVE_NAME = 2
|
|
||||||
MOVE_FUNCTION_CODE = 3
|
|
||||||
MOVE_BASE_DAMAGE = 4
|
|
||||||
MOVE_TYPE = 5
|
|
||||||
MOVE_CATEGORY = 6
|
|
||||||
MOVE_ACCURACY = 7
|
|
||||||
MOVE_TOTAL_PP = 8
|
|
||||||
MOVE_EFFECT_CHANCE = 9
|
|
||||||
MOVE_TARGET = 10
|
|
||||||
MOVE_PRIORITY = 11
|
|
||||||
MOVE_FLAGS = 12
|
|
||||||
MOVE_DESCRIPTION = 13
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PokemonTemp
|
|
||||||
attr_accessor :movesData
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def pbLoadMovesData
|
|
||||||
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
|
||||||
if !$PokemonTemp.movesData
|
|
||||||
if pbRgssExists?("Data/moves.dat")
|
|
||||||
$PokemonTemp.movesData = load_data("Data/moves.dat")
|
|
||||||
else
|
|
||||||
$PokemonTemp.movesData = []
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return $PokemonTemp.movesData
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbGetMoveData(moveID,moveDataType=-1)
|
|
||||||
meta = pbLoadMovesData
|
|
||||||
if moveDataType<0
|
|
||||||
return meta[moveID] || []
|
|
||||||
end
|
|
||||||
return meta[moveID][moveDataType] if meta[moveID]
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
alias __moveData__pbClearData pbClearData
|
|
||||||
def pbClearData
|
|
||||||
$PokemonTemp.movesData = nil if $PokemonTemp
|
|
||||||
__moveData__pbClearData
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PBMoveData
|
|
||||||
attr_reader :function,:basedamage,:type,:accuracy,:category
|
|
||||||
attr_reader :totalpp,:addlEffect,:target,:priority,:flags
|
|
||||||
|
|
||||||
def initialize(move_id)
|
|
||||||
moveData = pbGetMoveData(move_id)
|
|
||||||
@function = moveData[MOVE_FUNCTION_CODE]
|
|
||||||
@basedamage = moveData[MOVE_BASE_DAMAGE]
|
|
||||||
@type = moveData[MOVE_TYPE]
|
|
||||||
@category = moveData[MOVE_CATEGORY]
|
|
||||||
@accuracy = moveData[MOVE_ACCURACY]
|
|
||||||
@totalpp = moveData[MOVE_TOTAL_PP]
|
|
||||||
@addlEffect = moveData[MOVE_EFFECT_CHANCE]
|
|
||||||
@target = moveData[MOVE_TARGET]
|
|
||||||
@priority = moveData[MOVE_PRIORITY]
|
|
||||||
@flags = moveData[MOVE_FLAGS]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PBMove
|
|
||||||
attr_reader(:id) # This move's ID
|
|
||||||
attr_accessor(:pp) # The amount of PP remaining for this move
|
|
||||||
attr_accessor(:ppup) # The number of PP Ups used for this move
|
|
||||||
|
|
||||||
# Initializes this object to the specified move ID.
|
|
||||||
def initialize(moveID)
|
|
||||||
@id = moveID
|
|
||||||
@pp = pbGetMoveData(moveID,MOVE_TOTAL_PP) || 0
|
|
||||||
@ppup = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
# Changes this move's ID, and caps the PP amount if it is now greater than the
|
|
||||||
# new move's total PP.
|
|
||||||
def id=(value)
|
|
||||||
oldID = @id
|
|
||||||
@id = value
|
|
||||||
@pp = [@pp,self.totalpp].min if oldID>0
|
|
||||||
end
|
|
||||||
|
|
||||||
# Gets this move's type.
|
|
||||||
def type
|
|
||||||
return pbGetMoveData(@id,MOVE_TYPE) || 0
|
|
||||||
end
|
|
||||||
|
|
||||||
# Gets the maximum PP for this move.
|
|
||||||
def totalpp
|
|
||||||
maxPP = pbGetMoveData(@id,MOVE_TOTAL_PP) || 0
|
|
||||||
return maxPP+maxPP*@ppup/5
|
|
||||||
end
|
|
||||||
end
|
|
||||||
102
Data/Scripts/011_Data/003_PBMove.rb
Normal file
102
Data/Scripts/011_Data/003_PBMove.rb
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
MOVE_ID = 0
|
||||||
|
MOVE_INTERNAL_NAME = 1
|
||||||
|
MOVE_NAME = 2
|
||||||
|
MOVE_FUNCTION_CODE = 3
|
||||||
|
MOVE_BASE_DAMAGE = 4
|
||||||
|
MOVE_TYPE = 5
|
||||||
|
MOVE_CATEGORY = 6
|
||||||
|
MOVE_ACCURACY = 7
|
||||||
|
MOVE_TOTAL_PP = 8
|
||||||
|
MOVE_EFFECT_CHANCE = 9
|
||||||
|
MOVE_TARGET = 10
|
||||||
|
MOVE_PRIORITY = 11
|
||||||
|
MOVE_FLAGS = 12
|
||||||
|
MOVE_DESCRIPTION = 13
|
||||||
|
|
||||||
|
class PokemonTemp
|
||||||
|
attr_accessor :movesData
|
||||||
|
end
|
||||||
|
|
||||||
|
def pbLoadMovesData
|
||||||
|
$PokemonTemp = PokemonTemp.new if !$PokemonTemp
|
||||||
|
if !$PokemonTemp.movesData
|
||||||
|
if pbRgssExists?("Data/moves.dat")
|
||||||
|
$PokemonTemp.movesData = load_data("Data/moves.dat")
|
||||||
|
else
|
||||||
|
$PokemonTemp.movesData = []
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return $PokemonTemp.movesData
|
||||||
|
end
|
||||||
|
|
||||||
|
def pbGetMoveData(move_id, move_data_type = -1)
|
||||||
|
meta = pbLoadMovesData
|
||||||
|
if move_data_type < 0
|
||||||
|
return meta[move_id] || []
|
||||||
|
end
|
||||||
|
return meta[move_id][move_data_type] if meta[move_id]
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
alias __moveData__pbClearData pbClearData
|
||||||
|
def pbClearData
|
||||||
|
$PokemonTemp.movesData = nil if $PokemonTemp
|
||||||
|
__moveData__pbClearData
|
||||||
|
end
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# Move objects known by PokeBattle_Pokemon.
|
||||||
|
#===============================================================================
|
||||||
|
class PBMove
|
||||||
|
attr_reader(:id) # This move's ID
|
||||||
|
attr_accessor(:pp) # The amount of PP remaining for this move
|
||||||
|
attr_accessor(:ppup) # The number of PP Ups used for this move
|
||||||
|
|
||||||
|
# Initializes this object to the specified move ID.
|
||||||
|
def initialize(move_id)
|
||||||
|
@id = move_id
|
||||||
|
@pp = pbGetMoveData(move_id, MOVE_TOTAL_PP) || 0
|
||||||
|
@ppup = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
# Changes this move's ID, and caps the PP amount if it is now greater than the
|
||||||
|
# new move's total PP.
|
||||||
|
def id=(value)
|
||||||
|
old_id = @id
|
||||||
|
@id = value
|
||||||
|
@pp = [@pp, totalpp].min if old_id > 0
|
||||||
|
end
|
||||||
|
|
||||||
|
# Gets this move's type.
|
||||||
|
def type
|
||||||
|
return pbGetMoveData(@id, MOVE_TYPE) || 0
|
||||||
|
end
|
||||||
|
|
||||||
|
# Gets the maximum PP for this move.
|
||||||
|
def totalpp
|
||||||
|
max_pp = pbGetMoveData(@id, MOVE_TOTAL_PP) || 0
|
||||||
|
return max_pp + max_pp * @ppup / 5
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# Object containing move data. Not used for much.
|
||||||
|
#===============================================================================
|
||||||
|
class PBMoveData
|
||||||
|
attr_reader :function, :basedamage, :type, :accuracy, :category
|
||||||
|
attr_reader :totalpp, :addlEffect, :target, :priority, :flags
|
||||||
|
|
||||||
|
def initialize(move_id)
|
||||||
|
move_data = pbGetMoveData(move_id)
|
||||||
|
@function = move_data[MOVE_FUNCTION_CODE]
|
||||||
|
@basedamage = move_data[MOVE_BASE_DAMAGE]
|
||||||
|
@type = move_data[MOVE_TYPE]
|
||||||
|
@category = move_data[MOVE_CATEGORY]
|
||||||
|
@accuracy = move_data[MOVE_ACCURACY]
|
||||||
|
@totalpp = move_data[MOVE_TOTAL_PP]
|
||||||
|
@addlEffect = move_data[MOVE_EFFECT_CHANCE]
|
||||||
|
@target = move_data[MOVE_TARGET]
|
||||||
|
@priority = move_data[MOVE_PRIORITY]
|
||||||
|
@flags = move_data[MOVE_FLAGS]
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
|
#===============================================================================
|
||||||
|
# Trainers data
|
||||||
|
#===============================================================================
|
||||||
TPSPECIES = 0
|
TPSPECIES = 0
|
||||||
TPLEVEL = 1
|
TPLEVEL = 1
|
||||||
TPITEM = 2
|
TPITEM = 2
|
||||||
@@ -15,6 +18,32 @@ TPBALL = 13
|
|||||||
TPEV = 14
|
TPEV = 14
|
||||||
TPLOSETEXT = 15
|
TPLOSETEXT = 15
|
||||||
|
|
||||||
|
module TrainersMetadata
|
||||||
|
InfoTypes = {
|
||||||
|
"Items" => [0, "eEEEEEEE", PBItems, PBItems, PBItems, PBItems,
|
||||||
|
PBItems, PBItems, PBItems, PBItems],
|
||||||
|
"Pokemon" => [TPSPECIES, "ev", PBSpecies,nil], # Species, level
|
||||||
|
"Item" => [TPITEM, "e", PBItems],
|
||||||
|
"Moves" => [TPMOVES, "eEEE", PBMoves, PBMoves, PBMoves, PBMoves],
|
||||||
|
"Ability" => [TPABILITY, "u"],
|
||||||
|
"Gender" => [TPGENDER, "e", { "M" => 0, "m" => 0, "Male" => 0, "male" => 0, "0" => 0,
|
||||||
|
"F" => 1, "f" => 1, "Female" => 1, "female" => 1, "1" => 1 }],
|
||||||
|
"Form" => [TPFORM, "u"],
|
||||||
|
"Shiny" => [TPSHINY, "b"],
|
||||||
|
"Nature" => [TPNATURE, "e", PBNatures],
|
||||||
|
"IV" => [TPIV, "uUUUUU"],
|
||||||
|
"Happiness" => [TPHAPPINESS, "u"],
|
||||||
|
"Name" => [TPNAME, "s"],
|
||||||
|
"Shadow" => [TPSHADOW, "b"],
|
||||||
|
"Ball" => [TPBALL, "u"],
|
||||||
|
"EV" => [TPEV, "uUUUUU"],
|
||||||
|
"LoseText" => [TPLOSETEXT, "s"]
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
#
|
||||||
|
#===============================================================================
|
||||||
def pbLoadTrainer(trainerid,trainername,partyid=0)
|
def pbLoadTrainer(trainerid,trainername,partyid=0)
|
||||||
if trainerid.is_a?(String) || trainerid.is_a?(Symbol)
|
if trainerid.is_a?(String) || trainerid.is_a?(Symbol)
|
||||||
if !hasConst?(PBTrainers,trainerid)
|
if !hasConst?(PBTrainers,trainerid)
|
||||||
|
|||||||
@@ -1394,26 +1394,7 @@ end
|
|||||||
# Compile individual trainers
|
# Compile individual trainers
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
def pbCompileTrainers
|
def pbCompileTrainers
|
||||||
nonglobaltypes = {
|
trainer_info_types = TrainersMetadata::InfoTypes
|
||||||
"Items" => [0, "eEEEEEEE",PBItems,PBItems,PBItems,PBItems,
|
|
||||||
PBItems,PBItems,PBItems,PBItems],
|
|
||||||
"Pokemon" => [TPSPECIES, "ev",PBSpecies], # Species, level
|
|
||||||
"Item" => [TPITEM, "e",PBItems],
|
|
||||||
"Moves" => [TPMOVES, "eEEE",PBMoves,PBMoves,PBMoves,PBMoves],
|
|
||||||
"Ability" => [TPABILITY, "u"],
|
|
||||||
"Gender" => [TPGENDER, "e",{"M"=>0,"m"=>0,"Male"=>0,"male"=>0,"0"=>0,
|
|
||||||
"F"=>1,"f"=>1,"Female"=>1,"female"=>1,"1"=>1}],
|
|
||||||
"Form" => [TPFORM, "u"],
|
|
||||||
"Shiny" => [TPSHINY, "b"],
|
|
||||||
"Nature" => [TPNATURE, "e",PBNatures],
|
|
||||||
"IV" => [TPIV, "uUUUUU"],
|
|
||||||
"Happiness" => [TPHAPPINESS, "u"],
|
|
||||||
"Name" => [TPNAME, "s"],
|
|
||||||
"Shadow" => [TPSHADOW, "b"],
|
|
||||||
"Ball" => [TPBALL, "u"],
|
|
||||||
"EV" => [TPEV, "uUUUUU"],
|
|
||||||
"LoseText" => [TPLOSETEXT, "s"]
|
|
||||||
}
|
|
||||||
mLevel = PBExperience.maxLevel
|
mLevel = PBExperience.maxLevel
|
||||||
trainerindex = -1
|
trainerindex = -1
|
||||||
trainers = []
|
trainers = []
|
||||||
@@ -1448,7 +1429,7 @@ def pbCompileTrainers
|
|||||||
raise _INTL("Previous trainer not defined with as many Pokémon as expected\r\n{1}",FileLineData.linereport)
|
raise _INTL("Previous trainer not defined with as many Pokémon as expected\r\n{1}",FileLineData.linereport)
|
||||||
end
|
end
|
||||||
settingname = $~[1]
|
settingname = $~[1]
|
||||||
schema = nonglobaltypes[settingname]
|
schema = trainer_info_types[settingname]
|
||||||
next if !schema
|
next if !schema
|
||||||
record = pbGetCsvRecord($~[2],lineno,schema)
|
record = pbGetCsvRecord($~[2],lineno,schema)
|
||||||
# Error checking in XXX=YYY lines
|
# Error checking in XXX=YYY lines
|
||||||
|
|||||||
Reference in New Issue
Block a user