From d3ec5c2c53072cc54ce7787ac9b0cb2bd45d72d5 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Sat, 17 Oct 2020 00:17:40 +0100 Subject: [PATCH] Moved species data constants into module SpeciesData --- Data/Scripts/011_Data/001_Data_Cache.rb | 9 +- Data/Scripts/011_Data/002_Misc_Data.rb | 162 ++++++++--------- .../003_Battle/001_PokeBattle_BattleCommon.rb | 2 +- .../002_PokeBattle_SafariZone.rb | 2 +- .../012_Battle/009_PokeBall_CatchEffects.rb | 2 +- .../013_Overworld/007_PField_Encounters.rb | 4 +- .../013_Overworld/013_PField_DayCare.rb | 8 +- Data/Scripts/016_Pokemon/001_Pokemon.rb | 58 +++--- .../016_Pokemon/003_Pokemon_MegaEvolution.rb | 8 +- .../016_Pokemon/005_Pokemon_Evolution.rb | 2 +- .../016_Pokemon/007_Pokemon_Sprites.rb | 14 +- .../Scripts/017_UI/003_PScreen_PokedexMain.rb | 12 +- .../017_UI/004_PScreen_PokedexEntry.rb | 12 +- .../002_PMinigame_TripleTriad.rb | 6 +- .../002_PBattle_BugContest.rb | 2 +- .../004_PBattle_OrgBattleRules.rb | 10 +- .../005_PBattle_OrgBattleGenerator.rb | 10 +- .../003_PSystem_FileUtilities.rb | 2 +- .../004_PSystem_PokemonUtilities.rb | 10 +- Data/Scripts/021_Debug/001_Debug_Menu.rb | 2 +- Data/Scripts/021_Debug/003_Debug_Pokemon.rb | 2 +- Data/Scripts/021_Debug/004_Editor_Screens.rb | 90 ++++----- Data/Scripts/021_Debug/005_Editor_SaveData.rb | 172 +++++++++--------- .../021_Debug/011_Editor_SpritePosEditor.rb | 76 ++++---- Data/Scripts/022_Compiler/002_Compiler_PBS.rb | 18 +- 25 files changed, 348 insertions(+), 347 deletions(-) diff --git a/Data/Scripts/011_Data/001_Data_Cache.rb b/Data/Scripts/011_Data/001_Data_Cache.rb index a996c420a..cd5738d8f 100644 --- a/Data/Scripts/011_Data/001_Data_Cache.rb +++ b/Data/Scripts/011_Data/001_Data_Cache.rb @@ -134,10 +134,11 @@ def pbGetSpeciesData(species, form = 0, species_data_type = -1) 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 + when SpeciesData::TYPE2; return nil + when SpeciesData::BASE_STATS; return [1, 1, 1, 1, 1, 1] + when SpeciesData::EFFORT_POINTS; return [0, 0, 0, 0, 0, 0] + when SpeciesData::STEPS_TO_HATCH, SpeciesData::HEIGHT, SpeciesData::WEIGHT + return 1 end return 0 end diff --git a/Data/Scripts/011_Data/002_Misc_Data.rb b/Data/Scripts/011_Data/002_Misc_Data.rb index 9a71da1e9..def267eb5 100644 --- a/Data/Scripts/011_Data/002_Misc_Data.rb +++ b/Data/Scripts/011_Data/002_Misc_Data.rb @@ -31,7 +31,7 @@ module PhoneMsgType end #=============================================================================== -# Global and map metadata +# Global metadata #=============================================================================== module Metadata HOME = 1 @@ -123,100 +123,100 @@ end #=============================================================================== # Pokémon data #=============================================================================== -SpeciesType1 = 0 -SpeciesType2 = 1 -SpeciesBaseStats = 2 -SpeciesGenderRate = 3 -SpeciesGrowthRate = 4 -SpeciesBaseExp = 5 -SpeciesEffortPoints = 6 -SpeciesRareness = 7 -SpeciesHappiness = 8 -SpeciesAbilities = 9 -SpeciesHiddenAbility = 10 -SpeciesCompatibility = 11 -SpeciesStepsToHatch = 12 -SpeciesHeight = 13 -SpeciesWeight = 14 -SpeciesColor = 15 -SpeciesShape = 16 -SpeciesHabitat = 17 -SpeciesWildItemCommon = 18 -SpeciesWildItemUncommon = 19 -SpeciesWildItemRare = 20 -SpeciesIncense = 21 -SpeciesPokedexForm = 22 # For alternate forms -SpeciesMegaStone = 23 # For alternate forms -SpeciesMegaMove = 24 # For alternate forms -SpeciesUnmegaForm = 25 # For alternate forms -SpeciesMegaMessage = 26 # For alternate forms +module SpeciesData + TYPE1 = 0 + TYPE2 = 1 + BASE_STATS = 2 + GENDER_RATE = 3 + GROWTH_RATE = 4 + BASE_EXP = 5 + EFFORT_POINTS = 6 + RARENESS = 7 + HAPPINESS = 8 + ABILITIES = 9 + HIDDEN_ABILITY = 10 + COMPATIBILITY = 11 + STEPS_TO_HATCH = 12 + HEIGHT = 13 + WEIGHT = 14 + COLOR = 15 + SHAPE = 16 + HABITAT = 17 + WILD_ITEM_COMMON = 18 + WILD_ITEM_UNCOMMON = 19 + WILD_ITEM_RARE = 20 + INCENSE = 21 + POKEDEX_FORM = 22 # For alternate forms + MEGA_STONE = 23 # For alternate forms + MEGA_MOVE = 24 # For alternate forms + UNMEGA_FORM = 25 # For alternate forms + MEGA_MESSAGE = 26 # For alternate forms -MetricBattlerPlayerX = 0 -MetricBattlerPlayerY = 1 -MetricBattlerEnemyX = 2 -MetricBattlerEnemyY = 3 -MetricBattlerAltitude = 4 -MetricBattlerShadowX = 5 -MetricBattlerShadowSize = 6 + METRIC_PLAYER_X = 0 + METRIC_PLAYER_Y = 1 + METRIC_ENEMY_X = 2 + METRIC_ENEMY_Y = 3 + METRIC_ALTITUDE = 4 + METRIC_SHADOW_X = 5 + METRIC_SHADOW_SIZE = 6 -module PokemonSpeciesData - def self.requiredValues(compilingForms=false) + def self.requiredValues(compilingForms = false) ret = { - "Type1" => [SpeciesType1, "e", :PBTypes], - "BaseStats" => [SpeciesBaseStats, "vvvvvv"], - "BaseEXP" => [SpeciesBaseExp, "v"], - "EffortPoints" => [SpeciesEffortPoints, "uuuuuu"], - "Rareness" => [SpeciesRareness, "u"], - "Happiness" => [SpeciesHappiness, "u"], - "Compatibility" => [SpeciesCompatibility, "eE", :PBEggGroups, :PBEggGroups], - "StepsToHatch" => [SpeciesStepsToHatch, "v"], - "Height" => [SpeciesHeight, "f"], - "Weight" => [SpeciesWeight, "f"], - "Color" => [SpeciesColor, "e", :PBColors], - "Shape" => [SpeciesShape, "u"], - "Moves" => [0, "*ue", nil, :PBMoves], - "Kind" => [0, "s"], - "Pokedex" => [0, "q"] + "Type1" => [TYPE1, "e", :PBTypes], + "BaseStats" => [BASE_STATS, "vvvvvv"], + "BaseEXP" => [BASE_EXP, "v"], + "EffortPoints" => [EFFORT_POINTS, "uuuuuu"], + "Rareness" => [RARENESS, "u"], + "Happiness" => [HAPPINESS, "u"], + "Compatibility" => [COMPATIBILITY, "eE", :PBEggGroups, :PBEggGroups], + "StepsToHatch" => [STEPS_TO_HATCH, "v"], + "Height" => [HEIGHT, "f"], + "Weight" => [WEIGHT, "f"], + "Color" => [COLOR, "e", :PBColors], + "Shape" => [SHAPE, "u"], + "Moves" => [0, "*ue", nil, :PBMoves], + "Kind" => [0, "s"], + "Pokedex" => [0, "q"] } if !compilingForms - ret["GenderRate"] = [SpeciesGenderRate, "e", :PBGenderRates] - ret["GrowthRate"] = [SpeciesGrowthRate, "e", :PBGrowthRates] - ret["Name"] = [0, "s"] - ret["InternalName"] = [0, "n"] + ret["GenderRate"] = [GENDER_RATE, "e", :PBGenderRates] + ret["GrowthRate"] = [GROWTH_RATE, "e", :PBGrowthRates] + ret["Name"] = [0, "s"] + ret["InternalName"] = [0, "n"] end return ret end def self.optionalValues(compilingForms = false) ret = { - "Type2" => [SpeciesType2, "e", :PBTypes], - "Abilities" => [SpeciesAbilities, "eE", :PBAbilities, :PBAbilities], - "HiddenAbility" => [SpeciesHiddenAbility, "eEEE", :PBAbilities, :PBAbilities, - :PBAbilities, :PBAbilities], - "Habitat" => [SpeciesHabitat, "e", :PBHabitats], - "WildItemCommon" => [SpeciesWildItemCommon, "e", :PBItems], - "WildItemUncommon" => [SpeciesWildItemUncommon, "e", :PBItems], - "WildItemRare" => [SpeciesWildItemRare, "e", :PBItems], - "BattlerPlayerX" => [MetricBattlerPlayerX, "i"], - "BattlerPlayerY" => [MetricBattlerPlayerY, "i"], - "BattlerEnemyX" => [MetricBattlerEnemyX, "i"], - "BattlerEnemyY" => [MetricBattlerEnemyY, "i"], - "BattlerAltitude" => [MetricBattlerAltitude, "i"], - "BattlerShadowX" => [MetricBattlerShadowX, "i"], - "BattlerShadowSize" => [MetricBattlerShadowSize, "u"], - "EggMoves" => [0, "*e", :PBMoves], - "FormName" => [0, "q"], - "Evolutions" => [0, "*ses", nil, :PBEvolution, nil] + "Type2" => [TYPE2, "e", :PBTypes], + "Abilities" => [ABILITIES, "eE", :PBAbilities, :PBAbilities], + "HiddenAbility" => [HIDDEN_ABILITY, "eEEE", :PBAbilities, :PBAbilities, + :PBAbilities, :PBAbilities], + "Habitat" => [HABITAT, "e", :PBHabitats], + "WildItemCommon" => [WILD_ITEM_COMMON, "e", :PBItems], + "WildItemUncommon" => [WILD_ITEM_UNCOMMON, "e", :PBItems], + "WildItemRare" => [WILD_ITEM_RARE, "e", :PBItems], + "BattlerPlayerX" => [METRIC_PLAYER_X, "i"], + "BattlerPlayerY" => [METRIC_PLAYER_Y, "i"], + "BattlerEnemyX" => [METRIC_ENEMY_X, "i"], + "BattlerEnemyY" => [METRIC_ENEMY_Y, "i"], + "BattlerAltitude" => [METRIC_ALTITUDE, "i"], + "BattlerShadowX" => [METRIC_SHADOW_X, "i"], + "BattlerShadowSize" => [METRIC_SHADOW_SIZE, "u"], + "EggMoves" => [0, "*e", :PBMoves], + "FormName" => [0, "q"], + "Evolutions" => [0, "*ses", nil, :PBEvolution, nil] } if compilingForms - ret["PokedexForm"] = [SpeciesPokedexForm, "u"] - ret["MegaStone"] = [SpeciesMegaStone, "e", :PBItems] - ret["MegaMove"] = [SpeciesMegaMove, "e", :PBMoves] - ret["UnmegaForm"] = [SpeciesUnmegaForm, "u"] - ret["MegaMessage"] = [SpeciesMegaMessage, "u"] + ret["PokedexForm"] = [POKEDEX_FORM, "u"] + ret["MegaStone"] = [MEGA_STONE, "e", :PBItems] + ret["MegaMove"] = [MEGA_MOVE, "e", :PBMoves] + ret["UnmegaForm"] = [UNMEGA_FORM, "u"] + ret["MegaMessage"] = [MEGA_MESSAGE, "u"] else - ret["Incense"] = [SpeciesIncense, "e", :PBItems] - ret["RegionalNumbers"] = [0, "*u"] + ret["Incense"] = [INCENSE, "e", :PBItems] + ret["RegionalNumbers"] = [0, "*u"] end return ret end diff --git a/Data/Scripts/012_Battle/003_Battle/001_PokeBattle_BattleCommon.rb b/Data/Scripts/012_Battle/003_Battle/001_PokeBattle_BattleCommon.rb index 7abda421a..2baac23be 100644 --- a/Data/Scripts/012_Battle/003_Battle/001_PokeBattle_BattleCommon.rb +++ b/Data/Scripts/012_Battle/003_Battle/001_PokeBattle_BattleCommon.rb @@ -167,7 +167,7 @@ module PokeBattle_BattleCommon return 4 if $DEBUG && Input.press?(Input::CTRL) # Get a rareness if one wasn't provided if !rareness - rareness = pbGetSpeciesData(pkmn.species,pkmn.form,SpeciesRareness) + rareness = pbGetSpeciesData(pkmn.species,pkmn.form,SpeciesData::RARENESS) end # Modify rareness depending on the Poké Ball's effect ultraBeast = (battler.isSpecies?(:NIHILEGO) || diff --git a/Data/Scripts/012_Battle/006_Other battle types/002_PokeBattle_SafariZone.rb b/Data/Scripts/012_Battle/006_Other battle types/002_PokeBattle_SafariZone.rb index 6ab9c6cf9..69ffb6dce 100644 --- a/Data/Scripts/012_Battle/006_Other battle types/002_PokeBattle_SafariZone.rb +++ b/Data/Scripts/012_Battle/006_Other battle types/002_PokeBattle_SafariZone.rb @@ -428,7 +428,7 @@ class PokeBattle_SafariZone @scene.pbSafariStart @scene.pbCommonAnimation(PBWeather.animationName(@weather)) safariBall = getConst(PBItems,:SAFARIBALL) - rareness = pbGetSpeciesData(wildpoke.species,wildpoke.form,SpeciesRareness) + rareness = pbGetSpeciesData(wildpoke.species,wildpoke.form,SpeciesData::RARENESS) catchFactor = (rareness*100)/1275 catchFactor = [[catchFactor,3].max,20].min escapeFactor = (pbEscapeRate(rareness)*100)/1275 diff --git a/Data/Scripts/012_Battle/009_PokeBall_CatchEffects.rb b/Data/Scripts/012_Battle/009_PokeBall_CatchEffects.rb index 4c805b321..d4fe0a695 100644 --- a/Data/Scripts/012_Battle/009_PokeBall_CatchEffects.rb +++ b/Data/Scripts/012_Battle/009_PokeBall_CatchEffects.rb @@ -147,7 +147,7 @@ BallHandlers::ModifyCatchRate.add(:QUICKBALL,proc { |ball,catchRate,battle,battl }) BallHandlers::ModifyCatchRate.add(:FASTBALL,proc { |ball,catchRate,battle,battler,ultraBeast| - baseStats = pbGetSpeciesData(battler.species,battler.form,SpeciesBaseStats) + baseStats = pbGetSpeciesData(battler.species,battler.form,SpeciesData::BASE_STATS) baseSpeed = baseStats[PBStats::SPEED] catchRate *= 4 if baseSpeed>=100 next [catchRate,255].min diff --git a/Data/Scripts/013_Overworld/007_PField_Encounters.rb b/Data/Scripts/013_Overworld/007_PField_Encounters.rb index cca9346b6..39ae7ede5 100644 --- a/Data/Scripts/013_Overworld/007_PField_Encounters.rb +++ b/Data/Scripts/013_Overworld/007_PField_Encounters.rb @@ -253,8 +253,8 @@ class PokemonEncounters newChances = [] speciesData = pbLoadSpeciesData for i in 0...encList.length - t1 = speciesData[encList[i][0]][SpeciesType1] - t2 = speciesData[encList[i][0]][SpeciesType2] + t1 = speciesData[encList[i][0]][SpeciesData::TYPE1] + t2 = speciesData[encList[i][0]][SpeciesData::TYPE2] next if t1!=favoredType && (!t2 || t2!=favoredType) newEncList.push(encList[i]) newChances.push(chances[i]) diff --git a/Data/Scripts/013_Overworld/013_PField_DayCare.rb b/Data/Scripts/013_Overworld/013_PField_DayCare.rb index 25bd5b0e1..39d2bc2e1 100644 --- a/Data/Scripts/013_Overworld/013_PField_DayCare.rb +++ b/Data/Scripts/013_Overworld/013_PField_DayCare.rb @@ -105,7 +105,7 @@ end # Check compatibility of Pokémon in the Day Care. #=============================================================================== def pbIsDitto?(pkmn) - compat = pbGetSpeciesData(pkmn.species,pkmn.form,SpeciesCompatibility) + compat = pbGetSpeciesData(pkmn.species,pkmn.form,SpeciesData::COMPATIBILITY) if compat.is_a?(Array) return compat.include?(getConst(PBEggGroups,:Ditto)) end @@ -129,14 +129,14 @@ def pbDayCareGetCompat return 0 if pkmn1.shadowPokemon? return 0 if pkmn2.shadowPokemon? # Insert code here if certain forms of certain species cannot breed - compat1 = pbGetSpeciesData(pkmn1.species,pkmn1.form,SpeciesCompatibility) + compat1 = pbGetSpeciesData(pkmn1.species,pkmn1.form,SpeciesData::COMPATIBILITY) if compat1.is_a?(Array) compat10 = compat1[0] || 0 compat11 = compat1[1] || compat10 else compat10 = compat11 = compat || 0 end - compat2 = pbGetSpeciesData(pkmn2.species,pkmn2.form,SpeciesCompatibility) + compat2 = pbGetSpeciesData(pkmn2.species,pkmn2.form,SpeciesData::COMPATIBILITY) if compat2.is_a?(Array) compat20 = compat2[0] || 0 compat21 = compat2[1] || compat20 @@ -396,7 +396,7 @@ def pbDayCareGenerateEgg egg.calcStats egg.obtainText = _INTL("Day-Care Couple") egg.name = _INTL("Egg") - eggSteps = pbGetSpeciesData(babyspecies,egg.form,SpeciesStepsToHatch) + eggSteps = pbGetSpeciesData(babyspecies,egg.form,SpeciesData::STEPS_TO_HATCH) egg.eggsteps = eggSteps egg.givePokerus if rand(65536)