diff --git a/Data/Scripts/011_Data/001_Data_Cache.rb b/Data/Scripts/011_Data/001_Data_Cache.rb new file mode 100644 index 000000000..a996c420a --- /dev/null +++ b/Data/Scripts/011_Data/001_Data_Cache.rb @@ -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 diff --git a/Data/Scripts/011_Data/001_MiscData.rb b/Data/Scripts/011_Data/002_Misc_Data.rb similarity index 55% rename from Data/Scripts/011_Data/001_MiscData.rb rename to Data/Scripts/011_Data/002_Misc_Data.rb index cb9fe83ea..2f6afec2b 100644 --- a/Data/Scripts/011_Data/001_MiscData.rb +++ b/Data/Scripts/011_Data/002_Misc_Data.rb @@ -23,8 +23,6 @@ class PhoneDatabase end end - - module PhoneMsgType Generic = 0 Greeting = 1 @@ -32,8 +30,6 @@ module PhoneMsgType BattleRequest = 3 end - - #=============================================================================== # Global and map metadata #=============================================================================== @@ -75,8 +71,6 @@ MetadataMapWildCaptureME = 18 MetadataMapSize = 19 MetadataEnvironment = 20 - - module PokemonMetadata GlobalTypes = { "Home" => [MetadataHome, "uuuu"], @@ -120,8 +114,6 @@ module PokemonMetadata } end - - #=============================================================================== # Pokémon data #=============================================================================== @@ -161,8 +153,6 @@ MetricBattlerAltitude = 4 MetricBattlerShadowX = 5 MetricBattlerShadowSize = 6 - - module PokemonSpeciesData def self.requiredValues(compilingForms=false) ret = { @@ -225,248 +215,3 @@ module PokemonSpeciesData return ret 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 diff --git a/Data/Scripts/011_Data/002_PBMove.rb b/Data/Scripts/011_Data/002_PBMove.rb deleted file mode 100644 index 14ae13f05..000000000 --- a/Data/Scripts/011_Data/002_PBMove.rb +++ /dev/null @@ -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 diff --git a/Data/Scripts/011_Data/003_PBMove.rb b/Data/Scripts/011_Data/003_PBMove.rb new file mode 100644 index 000000000..7e0b3f3fd --- /dev/null +++ b/Data/Scripts/011_Data/003_PBMove.rb @@ -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 diff --git a/Data/Scripts/011_Data/003_PBStatuses.rb b/Data/Scripts/011_Data/004_PBStatuses.rb similarity index 100% rename from Data/Scripts/011_Data/003_PBStatuses.rb rename to Data/Scripts/011_Data/004_PBStatuses.rb diff --git a/Data/Scripts/011_Data/004_PBTypes_Extra.rb b/Data/Scripts/011_Data/005_PBTypes_Extra.rb similarity index 100% rename from Data/Scripts/011_Data/004_PBTypes_Extra.rb rename to Data/Scripts/011_Data/005_PBTypes_Extra.rb diff --git a/Data/Scripts/011_Data/005_PBNatures.rb b/Data/Scripts/011_Data/006_PBNatures.rb similarity index 100% rename from Data/Scripts/011_Data/005_PBNatures.rb rename to Data/Scripts/011_Data/006_PBNatures.rb diff --git a/Data/Scripts/011_Data/006_PBGenderRates.rb b/Data/Scripts/011_Data/007_PBGenderRates.rb similarity index 100% rename from Data/Scripts/011_Data/006_PBGenderRates.rb rename to Data/Scripts/011_Data/007_PBGenderRates.rb diff --git a/Data/Scripts/011_Data/007_PBExperience.rb b/Data/Scripts/011_Data/008_PBExperience.rb similarity index 100% rename from Data/Scripts/011_Data/007_PBExperience.rb rename to Data/Scripts/011_Data/008_PBExperience.rb diff --git a/Data/Scripts/011_Data/008_PBStats.rb b/Data/Scripts/011_Data/009_PBStats.rb similarity index 100% rename from Data/Scripts/011_Data/008_PBStats.rb rename to Data/Scripts/011_Data/009_PBStats.rb diff --git a/Data/Scripts/011_Data/009_PBRibbons.rb b/Data/Scripts/011_Data/013_PBRibbons.rb similarity index 100% rename from Data/Scripts/011_Data/009_PBRibbons.rb rename to Data/Scripts/011_Data/013_PBRibbons.rb diff --git a/Data/Scripts/014_Trainers/002_PTrainer_NPCTrainers.rb b/Data/Scripts/014_Trainers/002_PTrainer_NPCTrainers.rb index 52362698b..3d0c2ace5 100644 --- a/Data/Scripts/014_Trainers/002_PTrainer_NPCTrainers.rb +++ b/Data/Scripts/014_Trainers/002_PTrainer_NPCTrainers.rb @@ -1,3 +1,6 @@ +#=============================================================================== +# Trainers data +#=============================================================================== TPSPECIES = 0 TPLEVEL = 1 TPITEM = 2 @@ -15,6 +18,32 @@ TPBALL = 13 TPEV = 14 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) if trainerid.is_a?(String) || trainerid.is_a?(Symbol) if !hasConst?(PBTrainers,trainerid) diff --git a/Data/Scripts/022_Compiler/002_Compiler_PBS.rb b/Data/Scripts/022_Compiler/002_Compiler_PBS.rb index db0432233..9830be8fe 100644 --- a/Data/Scripts/022_Compiler/002_Compiler_PBS.rb +++ b/Data/Scripts/022_Compiler/002_Compiler_PBS.rb @@ -1394,26 +1394,7 @@ end # Compile individual trainers #=============================================================================== def pbCompileTrainers - nonglobaltypes = { - "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"] - } + trainer_info_types = TrainersMetadata::InfoTypes mLevel = PBExperience.maxLevel trainerindex = -1 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) end settingname = $~[1] - schema = nonglobaltypes[settingname] + schema = trainer_info_types[settingname] next if !schema record = pbGetCsvRecord($~[2],lineno,schema) # Error checking in XXX=YYY lines