From f4821f212f1155b829a9375d90d12510792c24fa Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Wed, 30 Dec 2020 01:02:18 +0000 Subject: [PATCH] Rewrote Debug menus to store options in self-contained handlers --- .../006_Game processing/003_Event_Handlers.rb | 77 +- .../017_UI/017_PScreen_PokemonStorage.rb | 1 + Data/Scripts/021_Debug/001_Debug_Menu.rb | 858 ------------- Data/Scripts/021_Debug/001_Debug_Menus.rb | 185 +++ .../021_Debug/001b_Debug_MenuCommands.rb | 1096 +++++++++++++++++ ..._Actions.rb => 002_Debug_MenuExtraCode.rb} | 44 - Data/Scripts/021_Debug/003_Debug_Pokemon.rb | 873 ------------- .../021_Debug/003_Debug_PokemonCommands.rb | 1084 ++++++++++++++++ .../011_Editor_MapConnectionEditor.rb | 4 +- .../021_Debug/012_Editor_SpritePosEditor.rb | 1 - 10 files changed, 2435 insertions(+), 1788 deletions(-) delete mode 100644 Data/Scripts/021_Debug/001_Debug_Menu.rb create mode 100644 Data/Scripts/021_Debug/001_Debug_Menus.rb create mode 100644 Data/Scripts/021_Debug/001b_Debug_MenuCommands.rb rename Data/Scripts/021_Debug/{002_Debug_Actions.rb => 002_Debug_MenuExtraCode.rb} (95%) delete mode 100644 Data/Scripts/021_Debug/003_Debug_Pokemon.rb create mode 100644 Data/Scripts/021_Debug/003_Debug_PokemonCommands.rb diff --git a/Data/Scripts/006_Game processing/003_Event_Handlers.rb b/Data/Scripts/006_Game processing/003_Event_Handlers.rb index babf2d59a..58129853f 100644 --- a/Data/Scripts/006_Game processing/003_Event_Handlers.rb +++ b/Data/Scripts/006_Game processing/003_Event_Handlers.rb @@ -1,4 +1,6 @@ +#=============================================================================== # Defines an event that procedures can subscribe to. +#=============================================================================== class Event def initialize @callbacks = [] @@ -63,8 +65,9 @@ class Event end end - - +#=============================================================================== +# +#=============================================================================== class HandlerHash def initialize(mod) @mod = mod @@ -145,10 +148,10 @@ class HandlerHash end end - - +#=============================================================================== # A stripped-down version of class HandlerHash which only deals with symbols and # doesn't care about whether those symbols actually relate to a defined thing. +#=============================================================================== class HandlerHash2 def initialize @hash = {} @@ -197,22 +200,76 @@ class HandlerHash2 end end +#=============================================================================== +# An even more stripped down version of class HandlerHash which just takes +# hashes with keys, no matter what the keys are. +#=============================================================================== +class HandlerHashBasic + def initialize + @ordered_keys = [] + @hash = {} + @addIfs = [] + end + def [](entry) + ret = nil + ret = @hash[entry] if entry && @hash[entry] + unless ret + for addif in @addIfs + return addif[1] if addif[0].call(entry) + end + end + return ret + end -class SpeciesHandlerHash < HandlerHash2 + def each + @ordered_keys.each { |key| yield key, @hash[key] } + end + + def add(entry, handler = nil, &handlerBlock) + if ![Proc,Hash].include?(handler.class) && !block_given? + raise ArgumentError, "#{self.class.name} for #{entry.inspect} has no valid handler (#{handler.inspect} was given)" + end + return if !entry || entry.empty? + @ordered_keys.push(entry) if !@ordered_keys.include?(entry) + @hash[entry] = handler || handlerBlock + end + + def addIf(conditionProc, handler = nil, &handlerBlock) + if ![Proc, Hash].include?(handler.class) && !block_given? + raise ArgumentError, "addIf call for #{self.class.name} has no valid handler (#{handler.inspect} was given)" + end + @addIfs.push([conditionProc, handler || handlerBlock]) + end + + def copy(src, *dests) + handler = self[src] + return if !handler + dests.each { |dest| self.add(dest, handler) } + end + + def clear + @hash.clear + @ordered_keys.clear + end + + def trigger(entry, *args) + handler = self[entry] + return (handler) ? handler.call(*args) : nil + end end - +#=============================================================================== +# +#=============================================================================== +class SpeciesHandlerHash < HandlerHash2 +end class AbilityHandlerHash < HandlerHash2 end - - class ItemHandlerHash < HandlerHash2 end - - class MoveHandlerHash < HandlerHash2 end diff --git a/Data/Scripts/017_UI/017_PScreen_PokemonStorage.rb b/Data/Scripts/017_UI/017_PScreen_PokemonStorage.rb index 2f8d55b7c..dde200a15 100644 --- a/Data/Scripts/017_UI/017_PScreen_PokemonStorage.rb +++ b/Data/Scripts/017_UI/017_PScreen_PokemonStorage.rb @@ -1449,6 +1449,7 @@ end class PokemonStorageScreen attr_reader :scene attr_reader :storage + attr_accessor :heldpkmn def initialize(scene,storage) @scene = scene diff --git a/Data/Scripts/021_Debug/001_Debug_Menu.rb b/Data/Scripts/021_Debug/001_Debug_Menu.rb deleted file mode 100644 index a8164e7e3..000000000 --- a/Data/Scripts/021_Debug/001_Debug_Menu.rb +++ /dev/null @@ -1,858 +0,0 @@ -class CommandMenuList - attr_accessor :currentList - - def initialize - @commands = [] - @currentList = "main" - end - - def add(parent,cmd,name,desc=nil) - @commands.push([parent,cmd,name,desc]) - end - - def list - ret = [] - for i in @commands - ret.push(i[2]) if i[0]==@currentList - end - return ret - end - - def getCommand(index) - count = 0 - for i in @commands - if i[0]==@currentList - return i[1] if count==index - count += 1 - end - end - return nil - end - - def getDesc(index) - count = 0 - for i in @commands - if i[0]==@currentList - return i[3] if count==index && i[3] - count += 1 - end - end - return "" - end - - def hasSubMenu?(cmd) - for i in @commands - return true if i[0]==cmd - end - return false - end - - def getParent - ret = nil - for i in @commands - if i[1]==@currentList - ret = i[0]; break - end - end - if ret - count = 0 - for i in @commands - if i[0]==ret - return [ret,count] if i[1]==@currentList - count += 1 - end - end - return [ret,0] - end - return nil - end -end - - -def pbDebugMenuCommands(showall=true) - commands = CommandMenuList.new - if showall - commands.add("main","fieldmenu",_INTL("Field options..."), - _INTL("Warp to maps, edit switches/variables, use the PC, edit Day Care, etc.")) - commands.add("fieldmenu","warp",_INTL("Warp to Map"), - _INTL("Instantly warp to another map of your choice.")) - # - Optional coordinates - commands.add("fieldmenu","refreshmap",_INTL("Refresh Map"), - _INTL("Make all events on this map, and common events, refresh themselves.")) - commands.add("fieldmenu","switches",_INTL("Switches"), - _INTL("Edit all Game Switches (except Script Switches).")) - commands.add("fieldmenu","variables",_INTL("Variables"), - _INTL("Edit all Game Variables. Can set them to numbers or text.")) - commands.add("fieldmenu","usepc",_INTL("Use PC"), - _INTL("Use a PC to access Pokémon storage and player's PC.")) - commands.add("fieldmenu","togglewallpapers",_INTL("Toggle Storage Wallpapers"), - _INTL("Unlock and lock special wallpapers used in Pokémon storage.")) - commands.add("fieldmenu","daycare",_INTL("Day Care"), - _INTL("View Pokémon in the Day Care and edit them.")) - commands.add("fieldmenu","relicstone",_INTL("Use Relic Stone"), - _INTL("Shadow Pokémon. Choose a Pokémon to show to the Relic Stone for purification.")) - commands.add("fieldmenu","purifychamber",_INTL("Use Purify Chamber"), - _INTL("Shadow Pokémon. Open the Purify Chamber for purification.")) - - commands.add("main","battlemenu",_INTL("Battle options..."), - _INTL("Start battles, reset this map's trainers, ready rematches, edit roamers, etc.")) - commands.add("battlemenu","testwildbattle",_INTL("Test Wild Battle"), - _INTL("Start a single battle against a wild Pokémon. You choose the species/level.")) - commands.add("battlemenu","testwildbattleadvanced",_INTL("Test Wild Battle Advanced"), - _INTL("Start a battle against 1 or more wild Pokémon. Battle size is your choice.")) - commands.add("battlemenu","testtrainerbattle",_INTL("Test Trainer Battle"), - _INTL("Start a single battle against a trainer of your choice.")) - commands.add("battlemenu","testtrainerbattleadvanced",_INTL("Test Trainer Battle Advanced"), - _INTL("Start a battle against 1 or more trainers with a battle size of your choice.")) - commands.add("battlemenu","togglelogging",_INTL("Toggle Battle Logging"), - _INTL("Record debug logs for battles in Data/debuglog.txt.")) - commands.add("battlemenu","resettrainers",_INTL("Reset Map's Trainers"), - _INTL("Turn off Self Switches A and B for all events with \"Trainer\" in their name.")) - commands.add("battlemenu","readyrematches",_INTL("Ready All Phone Rematches"), - _INTL("Make all trainers in the phone ready for rematches.")) - commands.add("battlemenu","roamers",_INTL("Roaming Pokémon"), - _INTL("Toggle and edit all roaming Pokémon.")) - - commands.add("main","itemsmenu",_INTL("Item options..."), - _INTL("Give and take items.")) - commands.add("itemsmenu","additem",_INTL("Add Item"), - _INTL("Choose an item and a quantity of it to add to the Bag.")) - commands.add("itemsmenu","fillbag",_INTL("Fill Bag"), - _INTL("Add a certain number of every item to the Bag.")) - commands.add("itemsmenu","emptybag",_INTL("Empty Bag"), - _INTL("Remove all items from the Bag.")) - - commands.add("main","pokemonmenu",_INTL("Pokémon options..."), - _INTL("Give Pokémon, heal party, fill/empty PC storage, etc.")) - commands.add("pokemonmenu","addpokemon",_INTL("Add Pokémon"), - _INTL("Give yourself a Pokémon of a chosen species/level. Goes to PC if party is full.")) - commands.add("pokemonmenu","demoparty",_INTL("Give Demo Party"), - _INTL("Give yourself 6 preset Pokémon. They overwrite the current party.")) - commands.add("pokemonmenu","healparty",_INTL("Heal Party"), - _INTL("Fully heal the HP/status/PP of all Pokémon in the party.")) - commands.add("pokemonmenu","quickhatch",_INTL("Quick Hatch"), - _INTL("Make all eggs in the party require just one more step to hatch.")) - commands.add("pokemonmenu","fillboxes",_INTL("Fill Storage Boxes"), - _INTL("Add one Pokémon of each species (at Level 50) to storage.")) - commands.add("pokemonmenu","clearboxes",_INTL("Clear Storage Boxes"), - _INTL("Remove all Pokémon in storage.")) - commands.add("pokemonmenu","openstorage",_INTL("Access Pokémon Storage"), - _INTL("Opens the Pokémon storage boxes in Organize Boxes mode.")) - - commands.add("main","playermenu",_INTL("Player options..."), - _INTL("Set money, badges, Pokédexes, player's appearance and name, etc.")) - commands.add("playermenu","setbadges",_INTL("Set Badges"), - _INTL("Toggle possession of each Gym Badge.")) - commands.add("playermenu","setmoney",_INTL("Set Money"), - _INTL("Edit how much money you have.")) - commands.add("playermenu","setcoins",_INTL("Set Coins"), - _INTL("Edit how many Game Corner Coins you have.")) - commands.add("playermenu","toggleshoes",_INTL("Toggle Running Shoes"), - _INTL("Toggle possession of running shoes.")) - commands.add("playermenu","togglepokegear",_INTL("Toggle Pokégear"), - _INTL("Toggle possession of the Pokégear.")) - commands.add("playermenu","dexlists",_INTL("Toggle Pokédex and Dexes"), - _INTL("Toggle possession of the Pokédex, and edit Regional Dex accessibility.")) - commands.add("playermenu","setplayer",_INTL("Set Player Character"), - _INTL("Edit the player's character, as defined in \"metadata.txt\".")) - commands.add("playermenu","changeoutfit",_INTL("Set Player Outfit"), - _INTL("Edit the player's outfit number.")) - commands.add("playermenu","renameplayer",_INTL("Set Player Name"), - _INTL("Rename the player.")) - commands.add("playermenu","randomid",_INTL("Randomise Player ID"), - _INTL("Generate a random new ID for the player.")) - end - - commands.add("main","editorsmenu",_INTL("Information editors..."), - _INTL("Edit information in the PBS files, terrain tags, battle animations, etc.")) - commands.add("editorsmenu","setmetadata",_INTL("Edit Metadata"), - _INTL("Edit global and map metadata.")) - commands.add("editorsmenu","mapconnections",_INTL("Edit Map Connections"), - _INTL("Connect maps using a visual interface. Can also edit map encounters/metadata.")) - commands.add("editorsmenu","terraintags",_INTL("Edit Terrain Tags"), - _INTL("Edit the terrain tags of tiles in tilesets. Required for tags 8+.")) - commands.add("editorsmenu","setencounters",_INTL("Edit Wild Encounters"), - _INTL("Edit the wild Pokémon that can be found on maps, and how they are encountered.")) - commands.add("editorsmenu","trainertypes",_INTL("Edit Trainer Types"), - _INTL("Edit the properties of trainer types.")) - commands.add("editorsmenu","edittrainers",_INTL("Edit Individual Trainers"), - _INTL("Edit individual trainers, their Pokémon and items.")) - commands.add("editorsmenu","edititems",_INTL("Edit Items"), - _INTL("Edit item data.")) - commands.add("editorsmenu","editpokemon",_INTL("Edit Pokémon"), - _INTL("Edit Pokémon species data.")) - commands.add("editorsmenu","editdexes",_INTL("Edit Regional Dexes"), - _INTL("Create, rearrange and delete Regional Pokédex lists.")) - commands.add("editorsmenu","positionsprites",_INTL("Edit Pokémon Sprite Positions"), - _INTL("Reposition Pokémon sprites in battle.")) - commands.add("editorsmenu","autopositionsprites",_INTL("Auto-Position All Sprites"), - _INTL("Automatically reposition all Pokémon sprites in battle. Don't use lightly.")) - commands.add("editorsmenu","animeditor",_INTL("Battle Animation Editor"), - _INTL("Edit the battle animations.")) - commands.add("editorsmenu","animorganiser",_INTL("Battle Animation Organiser"), - _INTL("Rearrange/add/delete battle animations.")) - commands.add("editorsmenu","importanims",_INTL("Import All Battle Animations"), - _INTL("Import all battle animations from the \"Animations\" folder.")) - commands.add("editorsmenu","exportanims",_INTL("Export All Battle Animations"), - _INTL("Export all battle animations individually to the \"Animations\" folder.")) - - commands.add("main","othermenu",_INTL("Other options..."), - _INTL("Mystery Gifts, translations, compile data, etc.")) - commands.add("othermenu","mysterygift",_INTL("Manage Mystery Gifts"), - _INTL("Edit and enable/disable Mystery Gifts.")) - commands.add("othermenu","extracttext",_INTL("Extract Text"), - _INTL("Extract all text in the game to a single file for translating.")) - commands.add("othermenu","compiletext",_INTL("Compile Text"), - _INTL("Import text and converts it into a language file.")) - commands.add("othermenu","compiledata",_INTL("Compile Data"), - _INTL("Fully compile all data.")) - commands.add("othermenu","debugconsole",_INTL("Debug Console"), - _INTL("Open the Debug Console.")) - commands.add("othermenu","invalidtiles",_INTL("Fix Invalid Tiles"), - _INTL("Scans all maps and erases non-existent tiles.")) - - return commands -end - -def pbDebugMenuActions(cmd="",sprites=nil,viewport=nil) - case cmd - #============================================================================= - # Field options - #============================================================================= - when "warp" - map = pbWarpToMap - if map - pbFadeOutAndHide(sprites) - pbDisposeMessageWindow(sprites["textbox"]) - pbDisposeSpriteHash(sprites) - viewport.dispose - if $scene.is_a?(Scene_Map) - $game_temp.player_new_map_id = map[0] - $game_temp.player_new_x = map[1] - $game_temp.player_new_y = map[2] - $game_temp.player_new_direction = 2 - $scene.transfer_player - $game_map.refresh - else - pbCancelVehicles - $MapFactory.setup(map[0]) - $game_player.moveto(map[1],map[2]) - $game_player.turn_down - $game_map.update - $game_map.autoplay - $game_map.refresh - end - return true # Closes the debug menu to allow the warp - end - when "refreshmap" - $game_map.need_refresh = true - pbMessage(_INTL("The map will refresh.")) - when "switches" - pbDebugVariables(0) - when "variables" - pbDebugVariables(1) - when "usepc" - pbPokeCenterPC - when "togglewallpapers" - w = $PokemonStorage.allWallpapers - if w.length<=PokemonStorage::BASICWALLPAPERQTY - pbMessage(_INTL("There are no special wallpapers defined.")) - else - paperscmd = 0 - unlockarray = $PokemonStorage.unlockedWallpapers - loop do - paperscmds = [] - paperscmds.push(_INTL("Unlock all")) - paperscmds.push(_INTL("Lock all")) - for i in PokemonStorage::BASICWALLPAPERQTY...w.length - paperscmds.push(_INTL("{1} {2}",unlockarray[i] ? "[Y]" : "[ ]",w[i])) - end - paperscmd = pbShowCommands(nil,paperscmds,-1,paperscmd) - break if paperscmd<0 - if paperscmd==0 # Unlock all - for i in PokemonStorage::BASICWALLPAPERQTY...w.length - unlockarray[i] = true - end - elsif paperscmd==1 # Lock all - for i in PokemonStorage::BASICWALLPAPERQTY...w.length - unlockarray[i] = false - end - else - paperindex = paperscmd-2+PokemonStorage::BASICWALLPAPERQTY - unlockarray[paperindex] = !$PokemonStorage.unlockedWallpapers[paperindex] - end - end - end - when "daycare" - pbDebugDayCare - when "relicstone" - pbRelicStone - when "purifychamber" - pbPurifyChamber - #============================================================================= - # Battle options - #============================================================================= - when "testwildbattle" - species = pbChooseSpeciesList - if species - params = ChooseNumberParams.new - params.setRange(1,PBExperience.maxLevel) - params.setInitialValue(5) - params.setCancelValue(0) - level = pbMessageChooseNumber(_INTL("Set the wild {1}'s level.", GameData::Species.get(species).name), params) - if level>0 - $PokemonTemp.encounterType = -1 - pbWildBattle(species,level) - end - end - when "testwildbattleadvanced" - pkmn = [] - size0 = 1 - pkmnCmd = 0 - loop do - pkmnCmds = [] - pkmn.each do |p| - pkmnCmds.push(sprintf("%s Lv.%d",p.name,p.level)) - end - pkmnCmds.push(_INTL("[Add Pokémon]")) - pkmnCmds.push(_INTL("[Set player side size]")) - pkmnCmds.push(_INTL("[Start {1}v{2} battle]",size0,pkmn.length)) - pkmnCmd = pbShowCommands(nil,pkmnCmds,-1,pkmnCmd) - break if pkmnCmd<0 - if pkmnCmd==pkmnCmds.length-1 # Start battle - if pkmn.length==0 - pbMessage(_INTL("No Pokémon were chosen, cannot start battle.")) - next - end - setBattleRule(sprintf("%dv%d",size0,pkmn.length)) - $PokemonTemp.encounterType = -1 - pbWildBattleCore(*pkmn) - break - elsif pkmnCmd==pkmnCmds.length-2 # Set player side size - if !pbCanDoubleBattle? - pbMessage(_INTL("You only have one Pokémon.")) - next - end - maxVal = (pbCanTripleBattle?) ? 3 : 2 - params = ChooseNumberParams.new - params.setRange(1,maxVal) - params.setInitialValue(size0) - params.setCancelValue(0) - newSize = pbMessageChooseNumber( - _INTL("Choose the number of battlers on the player's side (max. {1}).",maxVal),params) - size0 = newSize if newSize>0 - elsif pkmnCmd==pkmnCmds.length-3 # Add Pokémon - species = pbChooseSpeciesList - if species - params = ChooseNumberParams.new - params.setRange(1,PBExperience.maxLevel) - params.setInitialValue(5) - params.setCancelValue(0) - level = pbMessageChooseNumber(_INTL("Set the wild {1}'s level.", GameData::Species.get(species).name), params) - if level>0 - pkmn.push(Pokemon.new(species,level)) - end - end - else # Edit a Pokémon - if pbConfirmMessage(_INTL("Change this Pokémon?")) - scr = PokemonDebugPartyScreen.new - scr.pbPokemonDebug(pkmn[pkmnCmd],-1,nil,true) - scr.pbEndScreen - elsif pbConfirmMessage(_INTL("Delete this Pokémon?")) - pkmn[pkmnCmd] = nil - pkmn.compact! - end - end - end - when "testtrainerbattle" - battle = pbListScreen(_INTL("SINGLE TRAINER"),TrainerBattleLister.new(0,false)) - if battle - trainerdata = battle[1] - pbTrainerBattle(trainerdata[0],trainerdata[1],nil,false,trainerdata[4],true) - end - when "testtrainerbattleadvanced" - trainers = [] - size0 = 1 - size1 = 1 - trainerCmd = 0 - loop do - trainerCmds = [] - trainers.each do |t| - trainerCmds.push(sprintf("%s x%d",t[1][0].fullname,t[1][2].length)) - end - trainerCmds.push(_INTL("[Add trainer]")) - trainerCmds.push(_INTL("[Set player side size]")) - trainerCmds.push(_INTL("[Set opponent side size]")) - trainerCmds.push(_INTL("[Start {1}v{2} battle]",size0,size1)) - trainerCmd = pbShowCommands(nil,trainerCmds,-1,trainerCmd) - break if trainerCmd<0 - if trainerCmd==trainerCmds.length-1 # Start battle - if trainers.length==0 - pbMessage(_INTL("No trainers were chosen, cannot start battle.")) - next - elsif size1trainers.length && trainers[0][1][2].length==1 - pbMessage( - _INTL("Opposing side size cannot be {1}, as that requires the first trainer to have 2 or more Pokémon, which they don't.", - size1)) - next - end - setBattleRule(sprintf("%dv%d",size0,size1)) - battleArgs = [] - trainers.each do |t| - battleArgs.push([t[1][0],t[1][2],t[1][3],t[1][1]]) - end - pbTrainerBattleCore(*battleArgs) - break - elsif trainerCmd==trainerCmds.length-2 # Set opponent side size - if trainers.length==0 || (trainers.length==1 && trainers[0][1][2].length==1) - pbMessage(_INTL("No trainers were chosen or trainer only has one Pokémon.")) - next - end - maxVal = 2 - maxVal = 3 if trainers.length>=3 || - (trainers.length==2 && trainers[0][1][2].length>=2) || - trainers[0][1][2].length>=3 - params = ChooseNumberParams.new - params.setRange(1,maxVal) - params.setInitialValue(size1) - params.setCancelValue(0) - newSize = pbMessageChooseNumber( - _INTL("Choose the number of battlers on the opponent's side (max. {1}).",maxVal),params) - size1 = newSize if newSize>0 - elsif trainerCmd==trainerCmds.length-3 # Set player side size - if !pbCanDoubleBattle? - pbMessage(_INTL("You only have one Pokémon.")) - next - end - maxVal = (pbCanTripleBattle?) ? 3 : 2 - params = ChooseNumberParams.new - params.setRange(1,maxVal) - params.setInitialValue(size0) - params.setCancelValue(0) - newSize = pbMessageChooseNumber( - _INTL("Choose the number of battlers on the player's side (max. {1}).",maxVal),params) - size0 = newSize if newSize>0 - elsif trainerCmd==trainerCmds.length-4 # Add trainer - battle = pbListScreen(_INTL("CHOOSE A TRAINER"),TrainerBattleLister.new(0,false)) - if battle - trainerdata = battle[1] - tr = pbLoadTrainer(trainerdata[0],trainerdata[1],trainerdata[4]) - trainers.push([battle[0],tr]) - end - else # Edit a trainer - if pbConfirmMessage(_INTL("Change this trainer?")) - battle = pbListScreen(_INTL("CHOOSE A TRAINER"), - TrainerBattleLister.new(trainers[trainerCmd][0],false)) - if battle - trainerdata = battle[1] - tr = pbLoadTrainer(trainerdata[0],trainerdata[1],trainerdata[4]) - trainers[trainerCmd] = [battle[0],tr] - end - elsif pbConfirmMessage(_INTL("Delete this trainer?")) - trainers[trainerCmd] = nil - trainers.compact! - end - end - end - when "togglelogging" - $INTERNAL = !$INTERNAL - pbMessage(_INTL("Debug logs for battles will be made in the Data folder.")) if $INTERNAL - pbMessage(_INTL("Debug logs for battles will not be made.")) if !$INTERNAL - when "resettrainers" - if $game_map - for event in $game_map.events.values - if event.name[/trainer/i] - $game_self_switches[[$game_map.map_id,event.id,"A"]] = false - $game_self_switches[[$game_map.map_id,event.id,"B"]] = false - end - end - $game_map.need_refresh = true - pbMessage(_INTL("All Trainers on this map were reset.")) - else - pbMessage(_INTL("This command can't be used here.")) - end - when "readyrematches" - if !$PokemonGlobal.phoneNumbers || $PokemonGlobal.phoneNumbers.length==0 - pbMessage(_INTL("There are no trainers in the Phone.")) - else - for i in $PokemonGlobal.phoneNumbers - if i.length==8 # A trainer with an event - i[4] = 2 - pbSetReadyToBattle(i) - end - end - pbMessage(_INTL("All trainers in the Phone are now ready to rebattle.")) - end - when "roamers" - pbDebugRoamers - #============================================================================= - # Item options - #============================================================================= - when "additem" - pbListScreenBlock(_INTL("ADD ITEM"),ItemLister.new) { |button,item| - if button==Input::C && item - params = ChooseNumberParams.new - params.setRange(1,BAG_MAX_PER_SLOT) - params.setInitialValue(1) - params.setCancelValue(0) - qty = pbMessageChooseNumber(_INTL("Add how many {1}?", - GameData::Item.get(item).name_plural), params) - if qty>0 - $PokemonBag.pbStoreItem(item,qty) - pbMessage(_INTL("Gave {1}x {2}.",qty,GameData::Item.get(item).name)) - end - end - } - when "fillbag" - params = ChooseNumberParams.new - params.setRange(1,BAG_MAX_PER_SLOT) - params.setInitialValue(1) - params.setCancelValue(0) - qty = pbMessageChooseNumber(_INTL("Choose the number of items."),params) - if qty>0 - GameData::Item.each { |i| $PokemonBag.pbStoreItem(i.id, qty) } - pbMessage(_INTL("The Bag was filled with {1} of each item.",qty)) - end - when "emptybag" - $PokemonBag.clear - pbMessage(_INTL("The Bag was cleared.")) - #============================================================================= - # Pokémon options - #============================================================================= - when "addpokemon" - species = pbChooseSpeciesList - if species - params = ChooseNumberParams.new - params.setRange(1,PBExperience.maxLevel) - params.setInitialValue(5) - params.setCancelValue(0) - level = pbMessageChooseNumber(_INTL("Set the Pokémon's level."),params) - if level>0 - pbAddPokemon(species,level) - end - end - when "demoparty" - pbCreatePokemon - pbMessage(_INTL("Filled party with demo Pokémon.")) - when "healparty" - for i in $Trainer.party - i.heal - end - pbMessage(_INTL("Your Pokémon were fully healed.")) - when "quickhatch" - for pokemon in $Trainer.party - pokemon.eggsteps = 1 if pokemon.egg? - end - pbMessage(_INTL("All eggs in your party now require one step to hatch.")) - when "fillboxes" - $Trainer.formseen = {} if !$Trainer.formseen - $Trainer.formlastseen = {} if !$Trainer.formlastseen - added = 0 - box_qty = $PokemonStorage.maxPokemon(0) - completed = true - GameData::Species.each do |species_data| - sp = species_data.species - f = species_data.form - # Record each form of each species as seen and owned - $Trainer.formseen[sp] = [[], []] if !$Trainer.formseen[sp] - if f == 0 - $Trainer.seen[sp] = true - $Trainer.owned[sp] = true - if [PBGenderRates::AlwaysMale, PBGenderRates::AlwaysFemale, - PBGenderRates::Genderless].include?(species_data.gender_rate) - g = (species_data.gender_rate == PBGenderRates::AlwaysFemale) ? 1 : 0 - $Trainer.formseen[sp][g][f] = true - $Trainer.formlastseen[sp] = [g, f] if f == 0 - else # Both male and female - $Trainer.formseen[sp][0][f] = true - $Trainer.formseen[sp][1][f] = true - $Trainer.formlastseen[i] = [0, f] if f == 0 - end - elsif species_data.real_form_name && !species_data.real_form_name.empty? - g = (species_data.gender_rate == PBGenderRates::AlwaysFemale) ? 1 : 0 - $Trainer.formseen[sp][g][f] = true - end - # Add Pokémon (if form 0) - next if f != 0 - if added >= NUM_STORAGE_BOXES * box_qty - completed = false - next - end - added += 1 - $PokemonStorage[(added - 1) / box_qty, (added - 1) % box_qty] = Pokemon.new(sp, 50) - end - pbMessage(_INTL("Storage boxes were filled with one Pokémon of each species.")) - if !completed - pbMessage(_INTL("Note: The number of storage spaces ({1} boxes of 30) is less than the number of species.",NUM_STORAGE_BOXES)) - end - when "clearboxes" - for i in 0...$PokemonStorage.maxBoxes - for j in 0...$PokemonStorage.maxPokemon(i) - $PokemonStorage[i,j] = nil - end - end - pbMessage(_INTL("The storage boxes were cleared.")) - when "openstorage" - pbFadeOutIn { - scene = PokemonStorageScene.new - screen = PokemonStorageScreen.new(scene,$PokemonStorage) - screen.pbStartScreen(0) - } - #============================================================================= - # Player options - #============================================================================= - when "setbadges" - badgecmd = 0 - loop do - badgecmds = [] - badgecmds.push(_INTL("Give all")) - badgecmds.push(_INTL("Remove all")) - for i in 0...24 - badgecmds.push(_INTL("{1} Badge {2}",$Trainer.badges[i] ? "[Y]" : "[ ]",i+1)) - end - badgecmd = pbShowCommands(nil,badgecmds,-1,badgecmd) - break if badgecmd<0 - if badgecmd==0 # Give all - for i in 0...24; $Trainer.badges[i] = true; end - elsif badgecmd==1 # Remove all - for i in 0...24; $Trainer.badges[i] = false; end - else - $Trainer.badges[badgecmd-2] = !$Trainer.badges[badgecmd-2] - end - end - when "setmoney" - params = ChooseNumberParams.new - params.setRange(0,MAX_MONEY) - params.setDefaultValue($Trainer.money) - $Trainer.money = pbMessageChooseNumber(_INTL("Set the player's money."),params) - pbMessage(_INTL("You now have ${1}.",$Trainer.money.to_s_formatted)) - when "setcoins" - params = ChooseNumberParams.new - params.setRange(0,MAX_COINS) - params.setDefaultValue($PokemonGlobal.coins) - $PokemonGlobal.coins = pbMessageChooseNumber(_INTL("Set the player's Coin amount."),params) - pbMessage(_INTL("You now have {1} Coins.",$PokemonGlobal.coins.to_s_formatted)) - when "toggleshoes" - $PokemonGlobal.runningShoes = !$PokemonGlobal.runningShoes - pbMessage(_INTL("Gave Running Shoes.")) if $PokemonGlobal.runningShoes - pbMessage(_INTL("Lost Running Shoes.")) if !$PokemonGlobal.runningShoes - when "togglepokegear" - $Trainer.pokegear = !$Trainer.pokegear - pbMessage(_INTL("Gave Pokégear.")) if $Trainer.pokegear - pbMessage(_INTL("Lost Pokégear.")) if !$Trainer.pokegear - when "dexlists" - dexescmd = 0 - loop do - dexescmds = [] - dexescmds.push(_INTL("Have Pokédex: {1}",$Trainer.pokedex ? "[YES]" : "[NO]")) - d = pbDexNames - for i in 0...d.length - name = d[i] - name = name[0] if name.is_a?(Array) - dexindex = i - unlocked = $PokemonGlobal.pokedexUnlocked[dexindex] - dexescmds.push(_INTL("{1} {2}",unlocked ? "[Y]" : "[ ]",name)) - end - dexescmd = pbShowCommands(nil,dexescmds,-1,dexescmd) - break if dexescmd<0 - dexindex = dexescmd-1 - if dexindex<0 # Toggle Pokédex ownership - $Trainer.pokedex = !$Trainer.pokedex - else # Toggle Regional Dex accessibility - if $PokemonGlobal.pokedexUnlocked[dexindex] - pbLockDex(dexindex) - else - pbUnlockDex(dexindex) - end - end - end - when "setplayer" - limit = 0 - for i in 0...8 - meta = GameData::Metadata.get_player(i) - if !meta - limit = i; break - end - end - if limit<=1 - pbMessage(_INTL("There is only one player defined.")) - else - params = ChooseNumberParams.new - params.setRange(0,limit-1) - params.setDefaultValue($PokemonGlobal.playerID) - newid = pbMessageChooseNumber(_INTL("Choose the new player character."),params) - if newid!=$PokemonGlobal.playerID - pbChangePlayer(newid) - pbMessage(_INTL("The player character was changed.")) - end - end - when "changeoutfit" - oldoutfit = $Trainer.outfit - params = ChooseNumberParams.new - params.setRange(0,99) - params.setDefaultValue(oldoutfit) - $Trainer.outfit = pbMessageChooseNumber(_INTL("Set the player's outfit."),params) - pbMessage(_INTL("Player's outfit was changed.")) if $Trainer.outfit!=oldoutfit - when "renameplayer" - trname = pbEnterPlayerName("Your name?",0,MAX_PLAYER_NAME_SIZE,$Trainer.name) - if trname=="" && pbConfirmMessage(_INTL("Give yourself a default name?")) - trainertype = pbGetPlayerTrainerType - gender = pbGetTrainerTypeGender(trainertype) - trname = pbSuggestTrainerName(gender) - end - if trname=="" - pbMessage(_INTL("The player's name remained {1}.",$Trainer.name)) - else - $Trainer.name = trname - pbMessage(_INTL("The player's name was changed to {1}.",$Trainer.name)) - end - when "randomid" - $Trainer.id = rand(256) - $Trainer.id |= rand(256)<<8 - $Trainer.id |= rand(256)<<16 - $Trainer.id |= rand(256)<<24 - pbMessage(_INTL("The player's ID was changed to {1} (full ID: {2}).",$Trainer.publicID,$Trainer.id)) - #============================================================================= - # Information editors - #============================================================================= - when "setmetadata" - pbMetadataScreen(pbDefaultMap) - # TODO: Only need to reload the metadata. - pbClearData - when "mapconnections" - pbFadeOutIn { pbConnectionsEditor } - when "terraintags" - pbFadeOutIn { pbTilesetScreen } - when "setencounters" - encdata = pbLoadEncountersData - map = pbDefaultMap - loop do - map = pbListScreen(_INTL("SET ENCOUNTERS"),MapLister.new(map)) - break if map<=0 - pbEncounterEditorMap(encdata,map) - end - save_data(encdata,"Data/encounters.dat") - # TODO: Only need to reload the encounters data. - pbClearData - pbSaveEncounterData # Rewrite PBS file encounters.txt - when "trainertypes" - pbFadeOutIn { pbTrainerTypeEditor } - when "edittrainers" - pbFadeOutIn { pbTrainerBattleEditor } - when "edititems" - pbFadeOutIn { pbItemEditor } - when "editpokemon" - pbFadeOutIn { pbPokemonEditor } - when "editdexes" - pbFadeOutIn { pbRegionalDexEditorMain } - when "positionsprites" - pbFadeOutIn { - sp = SpritePositioner.new - sps = SpritePositionerScreen.new(sp) - sps.pbStart - } - when "autopositionsprites" - if pbConfirmMessage(_INTL("Are you sure you want to reposition all sprites?")) - msgwindow = pbCreateMessageWindow - pbMessageDisplay(msgwindow,_INTL("Repositioning all sprites. Please wait."),false) - Graphics.update - pbAutoPositionAll - pbDisposeMessageWindow(msgwindow) - end - when "animeditor" - pbFadeOutIn { pbAnimationEditor } - when "animorganiser" - pbFadeOutIn { pbAnimationsOrganiser } - when "importanims" - pbImportAllAnimations - when "exportanims" - pbExportAllAnimations - #============================================================================= - # Other options - #============================================================================= - when "mysterygift" - pbManageMysteryGifts - when "extracttext" - pbExtractText - when "compiletext" - pbCompileTextUI - when "compiledata" - msgwindow = pbCreateMessageWindow - Compiler.compile_all(true) { |msg| pbMessageDisplay(msgwindow,msg,false) } - pbMessageDisplay(msgwindow,_INTL("All game data was compiled.")) - pbDisposeMessageWindow(msgwindow) - when "debugconsole" - Console::setup_console - when "invalidtiles" - pbDebugFixInvalidTiles - end - return false -end - -def pbDebugMenu(showall=true) - commands = pbDebugMenuCommands(showall) - viewport = Viewport.new(0,0,Graphics.width,Graphics.height) - viewport.z = 99999 - sprites = {} - sprites["textbox"] = pbCreateMessageWindow - sprites["textbox"].letterbyletter = false - sprites["cmdwindow"] = Window_CommandPokemonEx.new(commands.list) - cmdwindow = sprites["cmdwindow"] - cmdwindow.x = 0 - cmdwindow.y = 0 - cmdwindow.width = Graphics.width - cmdwindow.height = Graphics.height-sprites["textbox"].height - cmdwindow.viewport = viewport - cmdwindow.visible = true - sprites["textbox"].text = commands.getDesc(cmdwindow.index) - pbFadeInAndShow(sprites) - ret = -1 - refresh = true - loop do - loop do - oldindex = cmdwindow.index - cmdwindow.update - if refresh || cmdwindow.index!=oldindex - sprites["textbox"].text = commands.getDesc(cmdwindow.index) - refresh = false - end - Graphics.update - Input.update - if Input.trigger?(Input::B) - parent = commands.getParent - if parent - pbPlayCancelSE - commands.currentList = parent[0] - cmdwindow.commands = commands.list - cmdwindow.index = parent[1] - refresh = true - else - ret = -1 - break - end - elsif Input.trigger?(Input::C) - pbPlayDecisionSE - ret = cmdwindow.index - break - end - end - break if ret<0 - cmd = commands.getCommand(ret) - if commands.hasSubMenu?(cmd) - commands.currentList = cmd - cmdwindow.commands = commands.list - cmdwindow.index = 0 - refresh = true - else - return if pbDebugMenuActions(cmd,sprites,viewport) - end - end - pbPlayCloseMenuSE - pbFadeOutAndHide(sprites) - pbDisposeMessageWindow(sprites["textbox"]) - pbDisposeSpriteHash(sprites) - viewport.dispose -end diff --git a/Data/Scripts/021_Debug/001_Debug_Menus.rb b/Data/Scripts/021_Debug/001_Debug_Menus.rb new file mode 100644 index 000000000..7087ada69 --- /dev/null +++ b/Data/Scripts/021_Debug/001_Debug_Menus.rb @@ -0,0 +1,185 @@ +#=============================================================================== +# +#=============================================================================== +class CommandMenuList + attr_accessor :currentList + + def initialize + @commands = [] + @currentList = "main" + end + + def add(option, hash) + @commands.push([option, hash["parent"], hash["name"], hash["description"]]) + end + + def list + ret = [] + @commands.each { |cmd| ret.push(cmd[2]) if cmd[1] == @currentList } + return ret + end + + def getCommand(index) + count = 0 + @commands.each do |cmd| + next if cmd[1] != @currentList + return cmd[0] if count == index + count += 1 + end + return nil + end + + def getDesc(index) + count = 0 + @commands.each do |cmd| + next if cmd[1] != @currentList + return cmd[3] if count == index && cmd[3] + break if count == index + count += 1 + end + return "" + end + + def hasSubMenu?(check_cmd) + @commands.each { |cmd| return true if cmd[1] == check_cmd } + return false + end + + def getParent + ret = nil + @commands.each do |cmd| + next if cmd[0] != @currentList + ret = cmd[1] + break + end + return nil if !ret + count = 0 + @commands.each do |cmd| + next if cmd[1] != ret + return [ret, count] if cmd[0] == @currentList + count += 1 + end + return [ret, 0] + end +end + +#=============================================================================== +# +#=============================================================================== +def pbDebugMenu(show_all = true) + commands = CommandMenuList.new + DebugMenuCommands.each do |option, hash| + commands.add(option, hash) if show_all || hash["always_show"] + end + viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) + viewport.z = 99999 + sprites = {} + sprites["textbox"] = pbCreateMessageWindow + sprites["textbox"].letterbyletter = false + sprites["cmdwindow"] = Window_CommandPokemonEx.new(commands.list) + cmdwindow = sprites["cmdwindow"] + cmdwindow.x = 0 + cmdwindow.y = 0 + cmdwindow.width = Graphics.width + cmdwindow.height = Graphics.height - sprites["textbox"].height + cmdwindow.viewport = viewport + cmdwindow.visible = true + sprites["textbox"].text = commands.getDesc(cmdwindow.index) + pbFadeInAndShow(sprites) + ret = -1 + refresh = true + loop do + loop do + oldindex = cmdwindow.index + cmdwindow.update + if refresh || cmdwindow.index != oldindex + sprites["textbox"].text = commands.getDesc(cmdwindow.index) + refresh = false + end + Graphics.update + Input.update + if Input.trigger?(Input::B) + parent = commands.getParent + if parent + pbPlayCancelSE + commands.currentList = parent[0] + cmdwindow.commands = commands.list + cmdwindow.index = parent[1] + refresh = true + else + ret = -1 + break + end + elsif Input.trigger?(Input::C) + pbPlayDecisionSE + ret = cmdwindow.index + break + end + end + break if ret < 0 + cmd = commands.getCommand(ret) + if commands.hasSubMenu?(cmd) + commands.currentList = cmd + cmdwindow.commands = commands.list + cmdwindow.index = 0 + refresh = true + elsif cmd == "warp" + return if DebugMenuCommands.call(cmd, "effect", sprites, viewport) + else + return if DebugMenuCommands.call(cmd, "effect") + end + end + pbPlayCloseMenuSE + pbFadeOutAndHide(sprites) + pbDisposeMessageWindow(sprites["textbox"]) + pbDisposeSpriteHash(sprites) + viewport.dispose +end + +#=============================================================================== +# +#=============================================================================== +module PokemonDebugMixin + def pbPokemonDebug(pkmn, pkmnid, heldpoke = nil, settingUpBattle = false) + command = 0 + commands = CommandMenuList.new + PokemonDebugMenuCommands.each do |option, hash| + commands.add(option, hash) if !settingUpBattle || hash["always_show"] + end + loop do + command = pbShowCommands(_INTL("Do what with {1}?", pkmn.name), commands.list, command) + if command < 0 + parent = commands.getParent + if parent + commands.currentList = parent[0] + command = parent[1] + else + break + end + else + cmd = commands.getCommand(command) + if commands.hasSubMenu?(cmd) + commands.currentList = cmd + command = 0 + elsif PokemonDebugMenuCommands.call(cmd, "effect", pkmn, pkmnid, heldpoke, settingUpBattle, self) + break + end + end + end + end +end + +#=============================================================================== +# +#=============================================================================== +class PokemonPartyScreen + include PokemonDebugMixin +end + +class PokemonStorageScreen + include PokemonDebugMixin +end + +class PokemonDebugPartyScreen + include PokemonDebugMixin +end diff --git a/Data/Scripts/021_Debug/001b_Debug_MenuCommands.rb b/Data/Scripts/021_Debug/001b_Debug_MenuCommands.rb new file mode 100644 index 000000000..37711a913 --- /dev/null +++ b/Data/Scripts/021_Debug/001b_Debug_MenuCommands.rb @@ -0,0 +1,1096 @@ +#=============================================================================== +# +#=============================================================================== +module DebugMenuCommands + @@commands = HandlerHashBasic.new + + def self.register(option, hash) + @@commands.add(option, hash) + end + + def self.registerIf(condition, hash) + @@commands.addIf(condition, hash) + end + + def self.copy(option, *new_options) + @@commands.copy(option, *new_options) + end + + def self.each + @@commands.each { |key, hash| yield key, hash } + end + + def self.hasFunction?(option, function) + option_hash = @@commands[option] + return option_hash && option_hash.keys.include?(function) + end + + def self.getFunction(option, function) + option_hash = @@commands[option] + return (option_hash && option_hash[function]) ? option_hash[function] : nil + end + + def self.call(function, option, *args) + option_hash = @@commands[option] + return nil if !option_hash || !option_hash[function] + return option_hash[function].call(*args) + end +end + +#=============================================================================== +# Field options +#=============================================================================== +DebugMenuCommands.register("fieldmenu", { + "parent" => "main", + "name" => _INTL("Field options..."), + "description" => _INTL("Warp to maps, edit switches/variables, use the PC, edit Day Care, etc.") +}) + +DebugMenuCommands.register("warp", { + "parent" => "fieldmenu", + "name" => _INTL("Warp to Map"), + "description" => _INTL("Instantly warp to another map of your choice."), + "effect" => proc { |sprites, viewport| + map = pbWarpToMap + if map + pbFadeOutAndHide(sprites) + pbDisposeMessageWindow(sprites["textbox"]) + pbDisposeSpriteHash(sprites) + viewport.dispose + if $scene.is_a?(Scene_Map) + $game_temp.player_new_map_id = map[0] + $game_temp.player_new_x = map[1] + $game_temp.player_new_y = map[2] + $game_temp.player_new_direction = 2 + $scene.transfer_player + else + pbCancelVehicles + $MapFactory.setup(map[0]) + $game_player.moveto(map[1], map[2]) + $game_player.turn_down + $game_map.update + $game_map.autoplay + end + $game_map.refresh + next true # Closes the debug menu to allow the warp + end + ) +}) + +DebugMenuCommands.register("refreshmap", { + "parent" => "fieldmenu", + "name" => _INTL("Refresh Map"), + "description" => _INTL("Make all events on this map, and common events, refresh themselves."), + "effect" => proc { + $game_map.need_refresh = true + pbMessage(_INTL("The map will refresh.")) + ) +}) + +DebugMenuCommands.register("switches", { + "parent" => "fieldmenu", + "name" => _INTL("Switches"), + "description" => _INTL("Edit all Game Switches (except Script Switches)."), + "effect" => proc { + pbDebugVariables(0) + ) +}) + +DebugMenuCommands.register("variables", { + "parent" => "fieldmenu", + "name" => _INTL("Variables"), + "description" => _INTL("Edit all Game Variables. Can set them to numbers or text."), + "effect" => proc { + pbDebugVariables(1) + ) +}) + +DebugMenuCommands.register("usepc", { + "parent" => "fieldmenu", + "name" => _INTL("Use PC"), + "description" => _INTL("Use a PC to access Pokémon storage and player's PC."), + "effect" => proc { + pbPokeCenterPC + ) +}) + +DebugMenuCommands.register("togglewallpapers", { + "parent" => "fieldmenu", + "name" => _INTL("Toggle Storage Wallpapers"), + "description" => _INTL("Unlock and lock special wallpapers used in Pokémon storage."), + "effect" => proc { + w = $PokemonStorage.allWallpapers + if w.length <= PokemonStorage::BASICWALLPAPERQTY + pbMessage(_INTL("There are no special wallpapers defined.")) + else + paperscmd = 0 + unlockarray = $PokemonStorage.unlockedWallpapers + loop do + paperscmds = [] + paperscmds.push(_INTL("Unlock all")) + paperscmds.push(_INTL("Lock all")) + for i in PokemonStorage::BASICWALLPAPERQTY...w.length + paperscmds.push(_INTL("{1} {2}", unlockarray[i] ? "[Y]" : "[ ]", w[i])) + end + paperscmd = pbShowCommands(nil, paperscmds, -1, paperscmd) + break if paperscmd < 0 + if paperscmd == 0 # Unlock all + for i in PokemonStorage::BASICWALLPAPERQTY...w.length + unlockarray[i] = true + end + elsif paperscmd == 1 # Lock all + for i in PokemonStorage::BASICWALLPAPERQTY...w.length + unlockarray[i] = false + end + else + paperindex = paperscmd - 2 + PokemonStorage::BASICWALLPAPERQTY + unlockarray[paperindex] = !$PokemonStorage.unlockedWallpapers[paperindex] + end + end + end + ) +}) + +DebugMenuCommands.register("daycare", { + "parent" => "fieldmenu", + "name" => _INTL("Day Care"), + "description" => _INTL("View Pokémon in the Day Care and edit them."), + "effect" => proc { + pbDebugDayCare + ) +}) + +DebugMenuCommands.register("relicstone", { + "parent" => "fieldmenu", + "name" => _INTL("Use Relic Stone"), + "description" => _INTL("Shadow Pokémon. Choose a Pokémon to show to the Relic Stone for purification."), + "effect" => proc { + pbRelicStone + ) +}) + +DebugMenuCommands.register("purifychamber", { + "parent" => "fieldmenu", + "name" => _INTL("Use Relic Stone"), + "description" => _INTL("Shadow Pokémon. Open the Purify Chamber for purification."), + "effect" => proc { + pbPurifyChamber + ) +}) + +#=============================================================================== +# Battle options +#=============================================================================== +DebugMenuCommands.register("battlemenu", { + "parent" => "main", + "name" => _INTL("Battle options..."), + "description" => _INTL("Start battles, reset this map's trainers, ready rematches, edit roamers, etc.") +}) + +DebugMenuCommands.register("testwildbattle", { + "parent" => "battlemenu", + "name" => _INTL("Test Wild Battle"), + "description" => _INTL("Start a single battle against a wild Pokémon. You choose the species/level."), + "effect" => proc { + species = pbChooseSpeciesList + if species + params = ChooseNumberParams.new + params.setRange(1, PBExperience.maxLevel) + params.setInitialValue(5) + params.setCancelValue(0) + level = pbMessageChooseNumber(_INTL("Set the wild {1}'s level.", + GameData::Species.get(species).name), params) + if level > 0 + $PokemonTemp.encounterType = -1 + pbWildBattle(species, level) + end + end + ) +}) + +DebugMenuCommands.register("testwildbattleadvanced", { + "parent" => "battlemenu", + "name" => _INTL("Test Wild Battle Advanced"), + "description" => _INTL("Start a battle against 1 or more wild Pokémon. Battle size is your choice."), + "effect" => proc { + pkmn = [] + size0 = 1 + pkmnCmd = 0 + loop do + pkmnCmds = [] + pkmn.each { |p| pkmnCmds.push(sprintf("%s Lv.%d", p.name, p.level)) } + pkmnCmds.push(_INTL("[Add Pokémon]")) + pkmnCmds.push(_INTL("[Set player side size]")) + pkmnCmds.push(_INTL("[Start {1}v{2} battle]", size0, pkmn.length)) + pkmnCmd = pbShowCommands(nil, pkmnCmds, -1, pkmnCmd) + break if pkmnCmd < 0 + if pkmnCmd == pkmnCmds.length - 1 # Start battle + if pkmn.length == 0 + pbMessage(_INTL("No Pokémon were chosen, cannot start battle.")) + next + end + setBattleRule(sprintf("%dv%d", size0, pkmn.length)) + $PokemonTemp.encounterType = -1 + pbWildBattleCore(*pkmn) + break + elsif pkmnCmd == pkmnCmds.length - 2 # Set player side size + if !pbCanDoubleBattle? + pbMessage(_INTL("You only have one Pokémon.")) + next + end + maxVal = (pbCanTripleBattle?) ? 3 : 2 + params = ChooseNumberParams.new + params.setRange(1, maxVal) + params.setInitialValue(size0) + params.setCancelValue(0) + newSize = pbMessageChooseNumber( + _INTL("Choose the number of battlers on the player's side (max. {1}).", maxVal), params) + size0 = newSize if newSize > 0 + elsif pkmnCmd == pkmnCmds.length - 3 # Add Pokémon + species = pbChooseSpeciesList + if species + params = ChooseNumberParams.new + params.setRange(1, PBExperience.maxLevel) + params.setInitialValue(5) + params.setCancelValue(0) + level = pbMessageChooseNumber(_INTL("Set the wild {1}'s level.", + GameData::Species.get(species).name), params) + pkmn.push(Pokemon.new(species, level)) if level > 0 + end + else # Edit a Pokémon + if pbConfirmMessage(_INTL("Change this Pokémon?")) + scr = PokemonDebugPartyScreen.new + scr.pbPokemonDebug(pkmn[pkmnCmd], -1, nil, true) + scr.pbEndScreen + elsif pbConfirmMessage(_INTL("Delete this Pokémon?")) + pkmn[pkmnCmd] = nil + pkmn.compact! + end + end + end + ) +}) + +DebugMenuCommands.register("testtrainerbattle", { + "parent" => "battlemenu", + "name" => _INTL("Test Trainer Battle"), + "description" => _INTL("Start a single battle against a trainer of your choice."), + "effect" => proc { + battle = pbListScreen(_INTL("SINGLE TRAINER"), TrainerBattleLister.new(0, false)) + if battle + trainerdata = battle[1] + pbTrainerBattle(trainerdata[0], trainerdata[1], nil, false, trainerdata[4], true) + end + ) +}) + +DebugMenuCommands.register("testtrainerbattleadvanced", { + "parent" => "battlemenu", + "name" => _INTL("Test Trainer Battle Advanced"), + "description" => _INTL("Start a battle against 1 or more trainers with a battle size of your choice."), + "effect" => proc { + trainers = [] + size0 = 1 + size1 = 1 + trainerCmd = 0 + loop do + trainerCmds = [] + trainers.each { |t| trainerCmds.push(sprintf("%s x%d", t[1][0].fullname, t[1][2].length)) } + end + trainerCmds.push(_INTL("[Add trainer]")) + trainerCmds.push(_INTL("[Set player side size]")) + trainerCmds.push(_INTL("[Set opponent side size]")) + trainerCmds.push(_INTL("[Start {1}v{2} battle]", size0, size1)) + trainerCmd = pbShowCommands(nil, trainerCmds, -1, trainerCmd) + break if trainerCmd < 0 + if trainerCmd == trainerCmds.length - 1 # Start battle + if trainers.length == 0 + pbMessage(_INTL("No trainers were chosen, cannot start battle.")) + next + elsif size1 < trainers.length + pbMessage(_INTL("Opposing side size is invalid. It should be at least {1}", trainers.length)) + next + elsif size1 > trainers.length && trainers[0][1][2].length == 1 + pbMessage( + _INTL("Opposing side size cannot be {1}, as that requires the first trainer to have 2 or more Pokémon, which they don't.", + size1)) + next + end + setBattleRule(sprintf("%dv%d", size0, size1)) + battleArgs = [] + trainers.each { |t| battleArgs.push([t[1][0], t[1][2], t[1][3], t[1][1]]) } + pbTrainerBattleCore(*battleArgs) + break + elsif trainerCmd == trainerCmds.length - 2 # Set opponent side size + if trainers.length == 0 || (trainers.length == 1 && trainers[0][1][2].length == 1) + pbMessage(_INTL("No trainers were chosen or trainer only has one Pokémon.")) + next + end + maxVal = 2 + maxVal = 3 if trainers.length >= 3 || + (trainers.length == 2 && trainers[0][1][2].length >= 2) || + trainers[0][1][2].length >= 3 + params = ChooseNumberParams.new + params.setRange(1, maxVal) + params.setInitialValue(size1) + params.setCancelValue(0) + newSize = pbMessageChooseNumber( + _INTL("Choose the number of battlers on the opponent's side (max. {1}).", maxVal), params) + size1 = newSize if newSize > 0 + elsif trainerCmd == trainerCmds.length - 3 # Set player side size + if !pbCanDoubleBattle? + pbMessage(_INTL("You only have one Pokémon.")) + next + end + maxVal = (pbCanTripleBattle?) ? 3 : 2 + params = ChooseNumberParams.new + params.setRange(1, maxVal) + params.setInitialValue(size0) + params.setCancelValue(0) + newSize = pbMessageChooseNumber( + _INTL("Choose the number of battlers on the player's side (max. {1}).", maxVal), params) + size0 = newSize if newSize > 0 + elsif trainerCmd == trainerCmds.length - 4 # Add trainer + battle = pbListScreen(_INTL("CHOOSE A TRAINER"), TrainerBattleLister.new(0, false)) + if battle + trainerdata = battle[1] + tr = pbLoadTrainer(trainerdata[0], trainerdata[1], trainerdata[4]) + trainers.push([battle[0], tr]) + end + else # Edit a trainer + if pbConfirmMessage(_INTL("Change this trainer?")) + battle = pbListScreen(_INTL("CHOOSE A TRAINER"), + TrainerBattleLister.new(trainers[trainerCmd][0], false)) + if battle + trainerdata = battle[1] + tr = pbLoadTrainer(trainerdata[0], trainerdata[1], trainerdata[4]) + trainers[trainerCmd] = [battle[0], tr] + end + elsif pbConfirmMessage(_INTL("Delete this trainer?")) + trainers[trainerCmd] = nil + trainers.compact! + end + end + end + ) +}) + +DebugMenuCommands.register("togglelogging", { + "parent" => "battlemenu", + "name" => _INTL("Toggle Battle Logging"), + "description" => _INTL("Record debug logs for battles in Data/debuglog.txt."), + "effect" => proc { + $INTERNAL = !$INTERNAL + pbMessage(_INTL("Debug logs for battles will be made in the Data folder.")) if $INTERNAL + pbMessage(_INTL("Debug logs for battles will not be made.")) if !$INTERNAL + ) +}) + +DebugMenuCommands.register("resettrainers", { + "parent" => "battlemenu", + "name" => _INTL("Reset Map's Trainers"), + "description" => _INTL("Turn off Self Switches A and B for all events with \"Trainer\" in their name."), + "effect" => proc { + if $game_map + for event in $game_map.events.values + if event.name[/trainer/i] + $game_self_switches[[$game_map.map_id, event.id, "A"]] = false + $game_self_switches[[$game_map.map_id, event.id, "B"]] = false + end + end + $game_map.need_refresh = true + pbMessage(_INTL("All Trainers on this map were reset.")) + else + pbMessage(_INTL("This command can't be used here.")) + end + ) +}) + +DebugMenuCommands.register("readyrematches", { + "parent" => "battlemenu", + "name" => _INTL("Ready All Phone Rematches"), + "description" => _INTL("Make all trainers in the phone ready for rematches."), + "effect" => proc { + if !$PokemonGlobal.phoneNumbers || $PokemonGlobal.phoneNumbers.length == 0 + pbMessage(_INTL("There are no trainers in the Phone.")) + else + for i in $PokemonGlobal.phoneNumbers + next if i.length != 8 # Isn't a trainer with an event + i[4] = 2 + pbSetReadyToBattle(i) + end + pbMessage(_INTL("All trainers in the Phone are now ready to rebattle.")) + end + ) +}) + +DebugMenuCommands.register("roamers", { + "parent" => "battlemenu", + "name" => _INTL("Roaming Pokémon"), + "description" => _INTL("Toggle and edit all roaming Pokémon."), + "effect" => proc { + pbDebugRoamers + ) +}) + +#=============================================================================== +# Item options +#=============================================================================== +DebugMenuCommands.register("itemsmenu", { + "parent" => "main", + "name" => _INTL("Item options..."), + "description" => _INTL("Give and take items.") +}) + +DebugMenuCommands.register("additem", { + "parent" => "itemsmenu", + "name" => _INTL("Add Item"), + "description" => _INTL("Choose an item and a quantity of it to add to the Bag."), + "effect" => proc { + pbListScreenBlock(_INTL("ADD ITEM"), ItemLister.new) { |button, item| + if button == Input::C && item + params = ChooseNumberParams.new + params.setRange(1, BAG_MAX_PER_SLOT) + params.setInitialValue(1) + params.setCancelValue(0) + qty = pbMessageChooseNumber(_INTL("Add how many {1}?", + GameData::Item.get(item).name_plural), params) + if qty > 0 + $PokemonBag.pbStoreItem(item, qty) + pbMessage(_INTL("Gave {1}x {2}.", qty, GameData::Item.get(item).name)) + end + end + } + ) +}) + +DebugMenuCommands.register("fillbag", { + "parent" => "itemsmenu", + "name" => _INTL("Fill Bag"), + "description" => _INTL("Add a certain number of every item to the Bag."), + "effect" => proc { + params = ChooseNumberParams.new + params.setRange(1, BAG_MAX_PER_SLOT) + params.setInitialValue(1) + params.setCancelValue(0) + qty = pbMessageChooseNumber(_INTL("Choose the number of items."), params) + if qty > 0 + GameData::Item.each { |i| $PokemonBag.pbStoreItem(i.id, qty) } + pbMessage(_INTL("The Bag was filled with {1} of each item.", qty)) + end + ) +}) + +DebugMenuCommands.register("emptybag", { + "parent" => "itemsmenu", + "name" => _INTL("Empty Bag"), + "description" => _INTL("Remove all items from the Bag."), + "effect" => proc { + $PokemonBag.clear + pbMessage(_INTL("The Bag was cleared.")) + ) +}) + +#=============================================================================== +# Pokémon options +#=============================================================================== +DebugMenuCommands.register("pokemonmenu", { + "parent" => "main", + "name" => _INTL("Pokémon options..."), + "description" => _INTL("Give Pokémon, heal party, fill/empty PC storage, etc.") +}) + +DebugMenuCommands.register("addpokemon", { + "parent" => "pokemonmenu", + "name" => _INTL("Add Pokémon"), + "description" => _INTL("Give yourself a Pokémon of a chosen species/level. Goes to PC if party is full."), + "effect" => proc { + species = pbChooseSpeciesList + if species + params = ChooseNumberParams.new + params.setRange(1, PBExperience.maxLevel) + params.setInitialValue(5) + params.setCancelValue(0) + level = pbMessageChooseNumber(_INTL("Set the Pokémon's level."), params) + pbAddPokemon(species, level) if level > 0 + end + ) +}) + +DebugMenuCommands.register("demoparty", { + "parent" => "pokemonmenu", + "name" => _INTL("Give Demo Party"), + "description" => _INTL("Give yourself 6 preset Pokémon. They overwrite the current party."), + "effect" => proc { + party = [] + species = [:PIKACHU, :PIDGEOTTO, :KADABRA, :GYARADOS, :DIGLETT, :CHANSEY] + for id in species + party.push(id) if GameData::Species.exists?(id) + end + # Generate Pokémon of each species at level 20 + party.each do |species| + pkmn = Pokemon.new(species, 20) + $Trainer.party.push(pkmn) + $Trainer.seen[species] = true + $Trainer.owned[species] = true + pbSeenForm(pkmn) + case species + when :PIDGEOTTO + pkmn.pbLearnMove(:FLY) + when :KADABRA + pkmn.pbLearnMove(:FLASH) + pkmn.pbLearnMove(:TELEPORT) + when :GYARADOS + pkmn.pbLearnMove(:SURF) + pkmn.pbLearnMove(:DIVE) + pkmn.pbLearnMove(:WATERFALL) + when :DIGLETT + pkmn.pbLearnMove(:DIG) + pkmn.pbLearnMove(:CUT) + pkmn.pbLearnMove(:HEADBUTT) + pkmn.pbLearnMove(:ROCKSMASH) + when :CHANSEY + pkmn.pbLearnMove(:SOFTBOILED) + pkmn.pbLearnMove(:STRENGTH) + pkmn.pbLearnMove(:SWEETSCENT) + end + pkmn.pbRecordFirstMoves + end + pbMessage(_INTL("Filled party with demo Pokémon.")) + ) +}) + +DebugMenuCommands.register("healparty", { + "parent" => "pokemonmenu", + "name" => _INTL("Heal Party"), + "description" => _INTL("Fully heal the HP/status/PP of all Pokémon in the party."), + "effect" => proc { + $Trainer.party.each { |pkmn| pkmn.heal } + pbMessage(_INTL("Your Pokémon were fully healed.")) + ) +}) + +DebugMenuCommands.register("quickhatch", { + "parent" => "pokemonmenu", + "name" => _INTL("Quick Hatch"), + "description" => _INTL("Make all eggs in the party require just one more step to hatch."), + "effect" => proc { + $Trainer.party.each { |pkmn| pkmn.eggsteps = 1 if pkmn.egg? } + pbMessage(_INTL("All eggs in your party now require one step to hatch.")) + ) +}) + +DebugMenuCommands.register("fillboxes", { + "parent" => "pokemonmenu", + "name" => _INTL("Fill Storage Boxes"), + "description" => _INTL("Add one Pokémon of each species (at Level 50) to storage."), + "effect" => proc { + $Trainer.formseen = {} if !$Trainer.formseen + $Trainer.formlastseen = {} if !$Trainer.formlastseen + added = 0 + box_qty = $PokemonStorage.maxPokemon(0) + completed = true + GameData::Species.each do |species_data| + sp = species_data.species + f = species_data.form + # Record each form of each species as seen and owned + $Trainer.formseen[sp] = [[], []] if !$Trainer.formseen[sp] + if f == 0 + $Trainer.seen[sp] = true + $Trainer.owned[sp] = true + if [PBGenderRates::AlwaysMale, PBGenderRates::AlwaysFemale, + PBGenderRates::Genderless].include?(species_data.gender_rate) + g = (species_data.gender_rate == PBGenderRates::AlwaysFemale) ? 1 : 0 + $Trainer.formseen[sp][g][f] = true + $Trainer.formlastseen[sp] = [g, f] if f == 0 + else # Both male and female + $Trainer.formseen[sp][0][f] = true + $Trainer.formseen[sp][1][f] = true + $Trainer.formlastseen[i] = [0, f] if f == 0 + end + elsif species_data.real_form_name && !species_data.real_form_name.empty? + g = (species_data.gender_rate == PBGenderRates::AlwaysFemale) ? 1 : 0 + $Trainer.formseen[sp][g][f] = true + end + # Add Pokémon (if form 0) + next if f != 0 + if added >= NUM_STORAGE_BOXES * box_qty + completed = false + next + end + added += 1 + $PokemonStorage[(added - 1) / box_qty, (added - 1) % box_qty] = Pokemon.new(sp, 50) + end + pbMessage(_INTL("Storage boxes were filled with one Pokémon of each species.")) + if !completed + pbMessage(_INTL("Note: The number of storage spaces ({1} boxes of {2}) is less than the number of species.", NUM_STORAGE_BOXES, box_qty)) + end + ) +}) + +DebugMenuCommands.register("clearboxes", { + "parent" => "pokemonmenu", + "name" => _INTL("Clear Storage Boxes"), + "description" => _INTL("Remove all Pokémon in storage."), + "effect" => proc { + for i in 0...$PokemonStorage.maxBoxes + for j in 0...$PokemonStorage.maxPokemon(i) + $PokemonStorage[i, j] = nil + end + end + pbMessage(_INTL("The storage boxes were cleared.")) + ) +}) + +DebugMenuCommands.register("openstorage", { + "parent" => "pokemonmenu", + "name" => _INTL("Access Pokémon Storage"), + "description" => _INTL("Opens the Pokémon storage boxes in Organize Boxes mode."), + "effect" => proc { + pbFadeOutIn { + scene = PokemonStorageScene.new + screen = PokemonStorageScreen.new(scene, $PokemonStorage) + screen.pbStartScreen(0) + } + ) +}) + +#=============================================================================== +# Player options +#=============================================================================== +DebugMenuCommands.register("playermenu", { + "parent" => "main", + "name" => _INTL("Player options..."), + "description" => _INTL("Set money, badges, Pokédexes, player's appearance and name, etc.") +}) + +DebugMenuCommands.register("setbadges", { + "parent" => "playermenu", + "name" => _INTL("Set Badges"), + "description" => _INTL("Toggle possession of each Gym Badge."), + "effect" => proc { + badgecmd = 0 + loop do + badgecmds = [] + badgecmds.push(_INTL("Give all")) + badgecmds.push(_INTL("Remove all")) + for i in 0...24 + badgecmds.push(_INTL("{1} Badge {2}", $Trainer.badges[i] ? "[Y]" : "[ ]", i + 1)) + end + badgecmd = pbShowCommands(nil, badgecmds, -1, badgecmd) + break if badgecmd < 0 + if badgecmd == 0 # Give all + 24.times { |i| $Trainer.badges[i] = true } + elsif badgecmd==1 # Remove all + 24.times { |i| $Trainer.badges[i] = false } + else + $Trainer.badges[badgecmd - 2] = !$Trainer.badges[badgecmd - 2] + end + end + ) +}) + +DebugMenuCommands.register("setmoney", { + "parent" => "playermenu", + "name" => _INTL("Set Money"), + "description" => _INTL("Edit how much money you have."), + "effect" => proc { + params = ChooseNumberParams.new + params.setRange(0, MAX_MONEY) + params.setDefaultValue($Trainer.money) + $Trainer.money = pbMessageChooseNumber(_INTL("Set the player's money."), params) + pbMessage(_INTL("You now have ${1}.", $Trainer.money.to_s_formatted)) + ) +}) + +DebugMenuCommands.register("setcoins", { + "parent" => "playermenu", + "name" => _INTL("Set Coins"), + "description" => _INTL("Edit how many Game Corner Coins you have."), + "effect" => proc { + params = ChooseNumberParams.new + params.setRange(0, MAX_COINS) + params.setDefaultValue($PokemonGlobal.coins) + $PokemonGlobal.coins = pbMessageChooseNumber(_INTL("Set the player's Coin amount."), params) + pbMessage(_INTL("You now have {1} Coins.", $PokemonGlobal.coins.to_s_formatted)) + ) +}) + +DebugMenuCommands.register("toggleshoes", { + "parent" => "playermenu", + "name" => _INTL("Toggle Running Shoes"), + "description" => _INTL("Toggle possession of running shoes."), + "effect" => proc { + $PokemonGlobal.runningShoes = !$PokemonGlobal.runningShoes + pbMessage(_INTL("Gave Running Shoes.")) if $PokemonGlobal.runningShoes + pbMessage(_INTL("Lost Running Shoes.")) if !$PokemonGlobal.runningShoes + ) +}) + +DebugMenuCommands.register("togglepokegear", { + "parent" => "playermenu", + "name" => _INTL("Toggle Pokégear"), + "description" => _INTL("Toggle possession of the Pokégear."), + "effect" => proc { + $Trainer.pokegear = !$Trainer.pokegear + pbMessage(_INTL("Gave Pokégear.")) if $Trainer.pokegear + pbMessage(_INTL("Lost Pokégear.")) if !$Trainer.pokegear + ) +}) + +DebugMenuCommands.register("dexlists", { + "parent" => "playermenu", + "name" => _INTL("Toggle Pokédex and Dexes"), + "description" => _INTL("Toggle possession of the Pokédex, and edit Regional Dex accessibility."), + "effect" => proc { + dexescmd = 0 + loop do + dexescmds = [] + dexescmds.push(_INTL("Have Pokédex: {1}", $Trainer.pokedex ? "[YES]" : "[NO]")) + d = pbDexNames + for i in 0...d.length + name = d[i] + name = name[0] if name.is_a?(Array) + dexindex = i + unlocked = $PokemonGlobal.pokedexUnlocked[dexindex] + dexescmds.push(_INTL("{1} {2}", unlocked ? "[Y]" : "[ ]", name)) + end + dexescmd = pbShowCommands(nil, dexescmds, -1, dexescmd) + break if dexescmd < 0 + dexindex = dexescmd - 1 + if dexindex < 0 # Toggle Pokédex ownership + $Trainer.pokedex = !$Trainer.pokedex + else # Toggle Regional Dex accessibility + if $PokemonGlobal.pokedexUnlocked[dexindex] + pbLockDex(dexindex) + else + pbUnlockDex(dexindex) + end + end + end + ) +}) + +DebugMenuCommands.register("setplayer", { + "parent" => "playermenu", + "name" => _INTL("Set Player Character"), + "description" => _INTL("Edit the player's character, as defined in \"metadata.txt\"."), + "effect" => proc { + limit = 0 + for i in 0...8 + meta = GameData::Metadata.get_player(i) + if !meta + limit = i + break + end + end + if limit <= 1 + pbMessage(_INTL("There is only one player defined.")) + else + params = ChooseNumberParams.new + params.setRange(0, limit - 1) + params.setDefaultValue($PokemonGlobal.playerID) + newid = pbMessageChooseNumber(_INTL("Choose the new player character."), params) + if newid != $PokemonGlobal.playerID + pbChangePlayer(newid) + pbMessage(_INTL("The player character was changed.")) + end + end + ) +}) + +DebugMenuCommands.register("changeoutfit", { + "parent" => "playermenu", + "name" => _INTL("Set Player Outfit"), + "description" => _INTL("Edit the player's outfit number."), + "effect" => proc { + oldoutfit = $Trainer.outfit + params = ChooseNumberParams.new + params.setRange(0, 99) + params.setDefaultValue(oldoutfit) + $Trainer.outfit = pbMessageChooseNumber(_INTL("Set the player's outfit."), params) + pbMessage(_INTL("Player's outfit was changed.")) if $Trainer.outfit != oldoutfit + ) +}) + +DebugMenuCommands.register("renameplayer", { + "parent" => "playermenu", + "name" => _INTL("Set Player Name"), + "description" => _INTL("Rename the player."), + "effect" => proc { + trname = pbEnterPlayerName("Your name?", 0, MAX_PLAYER_NAME_SIZE, $Trainer.name) + if trname == "" && pbConfirmMessage(_INTL("Give yourself a default name?")) + trainertype = pbGetPlayerTrainerType + gender = pbGetTrainerTypeGender(trainertype) + trname = pbSuggestTrainerName(gender) + end + if trname == "" + pbMessage(_INTL("The player's name remained {1}.", $Trainer.name)) + else + $Trainer.name = trname + pbMessage(_INTL("The player's name was changed to {1}.", $Trainer.name)) + end + ) +}) + +DebugMenuCommands.register("randomid", { + "parent" => "playermenu", + "name" => _INTL("Randomize Player ID"), + "description" => _INTL("Generate a random new ID for the player."), + "effect" => proc { + $Trainer.id = rand(2 ** 16) | rand(2 ** 16) << 16 + pbMessage(_INTL("The player's ID was changed to {1} (full ID: {2}).", $Trainer.publicID, $Trainer.id)) + ) +}) + +#=============================================================================== +# Information options +#=============================================================================== +DebugMenuCommands.register("editorsmenu", { + "parent" => "main", + "name" => _INTL("Information options..."), + "description" => _INTL("Edit information in the PBS files, terrain tags, battle animations, etc."), + "always_show" => true +}) + +DebugMenuCommands.register("setmetadata", { + "parent" => "editorsmenu", + "name" => _INTL("Edit Metadata"), + "description" => _INTL("Edit global and map metadata."), + "always_show" => true, + "effect" => proc { + pbMetadataScreen(pbDefaultMap) + ) +}) + +DebugMenuCommands.register("mapconnections", { + "parent" => "editorsmenu", + "name" => _INTL("Edit Map Connections"), + "description" => _INTL("Connect maps using a visual interface. Can also edit map encounters/metadata."), + "always_show" => true, + "effect" => proc { + pbFadeOutIn { pbConnectionsEditor } + ) +}) + +DebugMenuCommands.register("terraintags", { + "parent" => "editorsmenu", + "name" => _INTL("Edit Terrain Tags"), + "description" => _INTL("Edit the terrain tags of tiles in tilesets. Required for tags 8+."), + "always_show" => true, + "effect" => proc { + pbFadeOutIn { pbTilesetScreen } + ) +}) + +DebugMenuCommands.register("setencounters", { + "parent" => "editorsmenu", + "name" => _INTL("Edit Wild Encounters"), + "description" => _INTL("Edit the wild Pokémon that can be found on maps, and how they are encountered."), + "always_show" => true, + "effect" => proc { + encdata = pbLoadEncountersData + map = pbDefaultMap + loop do + map = pbListScreen(_INTL("SET ENCOUNTERS"), MapLister.new(map)) + break if map <= 0 + pbEncounterEditorMap(encdata, map) + end + save_data(encdata, "Data/encounters.dat") + $PokemonTemp.encountersData = nil + pbSaveEncounterData # Rewrite PBS file encounters.txt + ) +}) + +DebugMenuCommands.register("trainertypes", { + "parent" => "editorsmenu", + "name" => _INTL("Edit Trainer Types"), + "description" => _INTL("Edit the properties of trainer types."), + "always_show" => true, + "effect" => proc { + pbFadeOutIn { pbTrainerTypeEditor } + ) +}) + +DebugMenuCommands.register("edittrainers", { + "parent" => "editorsmenu", + "name" => _INTL("Edit Individual Trainers"), + "description" => _INTL("Edit individual trainers, their Pokémon and items."), + "always_show" => true, + "effect" => proc { + pbFadeOutIn { pbTrainerBattleEditor } + ) +}) + +DebugMenuCommands.register("edititems", { + "parent" => "editorsmenu", + "name" => _INTL("Edit Items"), + "description" => _INTL("Edit item data."), + "always_show" => true, + "effect" => proc { + pbFadeOutIn { pbItemEditor } + ) +}) + +DebugMenuCommands.register("editpokemon", { + "parent" => "editorsmenu", + "name" => _INTL("Edit Pokémon"), + "description" => _INTL("Edit Pokémon species data."), + "always_show" => true, + "effect" => proc { + pbFadeOutIn { pbPokemonEditor } + ) +}) + +DebugMenuCommands.register("editdexes", { + "parent" => "editorsmenu", + "name" => _INTL("Edit Regional Dexes"), + "description" => _INTL("Create, rearrange and delete Regional Pokédex lists."), + "always_show" => true, + "effect" => proc { + pbFadeOutIn { pbRegionalDexEditorMain } + ) +}) + +DebugMenuCommands.register("positionsprites", { + "parent" => "editorsmenu", + "name" => _INTL("Edit Pokémon Sprite Positions"), + "description" => _INTL("Reposition Pokémon sprites in battle."), + "always_show" => true, + "effect" => proc { + pbFadeOutIn { + sp = SpritePositioner.new + sps = SpritePositionerScreen.new(sp) + sps.pbStart + } + ) +}) + +DebugMenuCommands.register("autopositionsprites", { + "parent" => "editorsmenu", + "name" => _INTL("Auto-Position All Sprites"), + "description" => _INTL("Automatically reposition all Pokémon sprites in battle. Don't use lightly."), + "always_show" => true, + "effect" => proc { + if pbConfirmMessage(_INTL("Are you sure you want to reposition all sprites?")) + msgwindow = pbCreateMessageWindow + pbMessageDisplay(msgwindow, _INTL("Repositioning all sprites. Please wait."), false) + Graphics.update + pbAutoPositionAll + pbDisposeMessageWindow(msgwindow) + end + ) +}) + +DebugMenuCommands.register("animeditor", { + "parent" => "editorsmenu", + "name" => _INTL("Battle Animation Editor"), + "description" => _INTL("Edit the battle animations."), + "always_show" => true, + "effect" => proc { + pbFadeOutIn { pbAnimationEditor } + ) +}) + +DebugMenuCommands.register("animorganiser", { + "parent" => "editorsmenu", + "name" => _INTL("Battle Animation Organiser"), + "description" => _INTL("Rearrange/add/delete battle animations."), + "always_show" => true, + "effect" => proc { + pbFadeOutIn { pbAnimationsOrganiser } + ) +}) + +DebugMenuCommands.register("importanims", { + "parent" => "editorsmenu", + "name" => _INTL("Import All Battle Animations"), + "description" => _INTL("Import all battle animations from the \"Animations\" folder."), + "always_show" => true, + "effect" => proc { + pbImportAllAnimations + ) +}) + +DebugMenuCommands.register("exportanims", { + "parent" => "editorsmenu", + "name" => _INTL("Export All Battle Animations"), + "description" => _INTL("Export all battle animations individually to the \"Animations\" folder."), + "always_show" => true, + "effect" => proc { + pbExportAllAnimations + ) +}) + +#=============================================================================== +# Other options +#=============================================================================== +DebugMenuCommands.register("othermenu", { + "parent" => "main", + "name" => _INTL("Other options..."), + "description" => _INTL("Mystery Gifts, translations, compile data, etc."), + "always_show" => true +}) + +DebugMenuCommands.register("mysterygift", { + "parent" => "othermenu", + "name" => _INTL("Manage Mystery Gifts"), + "description" => _INTL("Edit and enable/disable Mystery Gifts."), + "always_show" => true, + "effect" => proc { + pbManageMysteryGifts + ) +}) + +DebugMenuCommands.register("extracttext", { + "parent" => "othermenu", + "name" => _INTL("Extract Text"), + "description" => _INTL("Extract all text in the game to a single file for translating."), + "always_show" => true, + "effect" => proc { + pbExtractText + ) +}) + +DebugMenuCommands.register("compiletext", { + "parent" => "othermenu", + "name" => _INTL("Compile Text"), + "description" => _INTL("Import text and converts it into a language file."), + "always_show" => true, + "effect" => proc { + pbCompileTextUI + ) +}) + +DebugMenuCommands.register("compiledata", { + "parent" => "othermenu", + "name" => _INTL("Compile Data"), + "description" => _INTL("Fully compile all data."), + "always_show" => true, + "effect" => proc { + msgwindow = pbCreateMessageWindow + Compiler.compile_all(true) { |msg| pbMessageDisplay(msgwindow, msg, false) } + pbMessageDisplay(msgwindow, _INTL("All game data was compiled.")) + pbDisposeMessageWindow(msgwindow) + ) +}) + +DebugMenuCommands.register("debugconsole", { + "parent" => "othermenu", + "name" => _INTL("Debug Console"), + "description" => _INTL("Open the Debug Console."), + "always_show" => true, + "effect" => proc { + Console::setup_console + ) +}) + +DebugMenuCommands.register("invalidtiles", { + "parent" => "othermenu", + "name" => _INTL("Fix Invalid Tiles"), + "description" => _INTL("Scans all maps and erases non-existent tiles."), + "always_show" => true, + "effect" => proc { + pbDebugFixInvalidTiles + ) +}) diff --git a/Data/Scripts/021_Debug/002_Debug_Actions.rb b/Data/Scripts/021_Debug/002_Debug_MenuExtraCode.rb similarity index 95% rename from Data/Scripts/021_Debug/002_Debug_Actions.rb rename to Data/Scripts/021_Debug/002_Debug_MenuExtraCode.rb index e433078df..89c322817 100644 --- a/Data/Scripts/021_Debug/002_Debug_Actions.rb +++ b/Data/Scripts/021_Debug/002_Debug_MenuExtraCode.rb @@ -521,50 +521,6 @@ def pbDebugRoamers viewport.dispose end -#=============================================================================== -# Give the player a party of Pokémon. -# For demonstration purposes only, not to be used in a real game. -#=============================================================================== -def pbCreatePokemon - party = [] - species = [:PIKACHU, :PIDGEOTTO, :KADABRA, :GYARADOS, :DIGLETT, :CHANSEY] - for id in species - party.push(id) if GameData::Species.exists?(id) - end - # Species IDs of the Pokémon to be created - for i in 0...party.length - species = party[i] - # Generate Pokémon with species and level 20 - $Trainer.party[i] = Pokemon.new(species, 20) - $Trainer.seen[species] = true - $Trainer.owned[species] = true - pbSeenForm($Trainer.party[i]) - case species - when :PIDGEOTTO - $Trainer.party[i].pbLearnMove(:FLY) - when :KADABRA - $Trainer.party[i].pbLearnMove(:FLASH) - $Trainer.party[i].pbLearnMove(:TELEPORT) - when :GYARADOS - $Trainer.party[i].pbLearnMove(:SURF) - $Trainer.party[i].pbLearnMove(:DIVE) - $Trainer.party[i].pbLearnMove(:WATERFALL) - when :DIGLETT - $Trainer.party[i].pbLearnMove(:DIG) - $Trainer.party[i].pbLearnMove(:CUT) - $Trainer.party[i].pbLearnMove(:HEADBUTT) - $Trainer.party[i].pbLearnMove(:ROCKSMASH) - when :CHANSEY - $Trainer.party[i].pbLearnMove(:SOFTBOILED) - $Trainer.party[i].pbLearnMove(:STRENGTH) - $Trainer.party[i].pbLearnMove(:SWEETSCENT) - end - end - for i in 0...party.length - $Trainer.party[i].pbRecordFirstMoves - end -end - #=============================================================================== diff --git a/Data/Scripts/021_Debug/003_Debug_Pokemon.rb b/Data/Scripts/021_Debug/003_Debug_Pokemon.rb deleted file mode 100644 index 9b5a510a3..000000000 --- a/Data/Scripts/021_Debug/003_Debug_Pokemon.rb +++ /dev/null @@ -1,873 +0,0 @@ -module PokemonDebugMixin - def pbPokemonDebugCommands(settingUpBattle=false) - commands = CommandMenuList.new - commands.add("main","hpstatusmenu",_INTL("HP/Status...")) - commands.add("hpstatusmenu","sethp",_INTL("Set HP")) - commands.add("hpstatusmenu","setstatus",_INTL("Set status")) - commands.add("hpstatusmenu","fullheal",_INTL("Fully heal")) - commands.add("hpstatusmenu","makefainted",_INTL("Make fainted")) - commands.add("hpstatusmenu","setpokerus",_INTL("Set Pokérus")) - - commands.add("main","levelstats",_INTL("Level/stats...")) - commands.add("levelstats","setlevel",_INTL("Set level")) - commands.add("levelstats","setexp",_INTL("Set Exp")) - commands.add("levelstats","hiddenvalues",_INTL("EV/IV/pID...")) - commands.add("levelstats","sethappiness",_INTL("Set happiness")) - commands.add("levelstats","conteststats",_INTL("Contest stats...")) - commands.add("conteststats","setbeauty",_INTL("Set Beauty")) - commands.add("conteststats","setcool",_INTL("Set Cool")) - commands.add("conteststats","setcute",_INTL("Set Cute")) - commands.add("conteststats","setsmart",_INTL("Set Smart")) - commands.add("conteststats","settough",_INTL("Set Tough")) - commands.add("conteststats","setsheen",_INTL("Set Sheen")) - - commands.add("main","moves",_INTL("Moves...")) - commands.add("moves","teachmove",_INTL("Teach move")) - commands.add("moves","forgetmove",_INTL("Forget move")) - commands.add("moves","resetmoves",_INTL("Reset moves")) - commands.add("moves","setmovepp",_INTL("Set move PP")) - commands.add("moves","setinitialmoves",_INTL("Reset initial moves")) - - commands.add("main","setability",_INTL("Set ability")) - commands.add("main","setnature",_INTL("Set nature")) - commands.add("main","setgender",_INTL("Set gender")) - commands.add("main","speciesform",_INTL("Species/form...")) - - commands.add("main","cosmetic",_INTL("Cosmetic info...")) - commands.add("cosmetic","setshininess",_INTL("Set shininess")) - commands.add("cosmetic","setpokeball",_INTL("Set Poké Ball")) - commands.add("cosmetic","setribbons",_INTL("Set ribbons")) - commands.add("cosmetic","setnickname",_INTL("Set nickname")) - commands.add("cosmetic","ownership",_INTL("Ownership...")) - - commands.add("main","setegg",_INTL("Set egg")) - commands.add("main","shadowpkmn",_INTL("Shadow Pkmn...")) - if !settingUpBattle - commands.add("main","mysterygift",_INTL("Mystery Gift")) - commands.add("main","duplicate",_INTL("Duplicate")) - commands.add("main","delete",_INTL("Delete")) - end - return commands - end - - def pbPokemonDebugActions(command,pkmn,pkmnid,heldpoke=nil,settingUpBattle=false) - case command - #=========================================================================== - when "sethp" - if pkmn.egg? - pbDisplay(_INTL("{1} is an egg.",pkmn.name)) - else - params = ChooseNumberParams.new - params.setRange(0,pkmn.totalhp) - params.setDefaultValue(pkmn.hp) - newhp = pbMessageChooseNumber( - _INTL("Set {1}'s HP (max. {2}).",pkmn.name,pkmn.totalhp),params) { pbUpdate } - if newhp!=pkmn.hp - pkmn.hp = newhp - pbRefreshSingle(pkmnid) - end - end - #=========================================================================== - when "setstatus" - if pkmn.egg? - pbDisplay(_INTL("{1} is an egg.",pkmn.name)) - elsif pkmn.hp<=0 - pbDisplay(_INTL("{1} is fainted, can't change status.",pkmn.name)) - else - cmd = 0 - loop do - cmd = pbShowCommands(_INTL("Set {1}'s status.",pkmn.name),[ - _INTL("[Cure]"), - _INTL("Sleep"), - _INTL("Poison"), - _INTL("Burn"), - _INTL("Paralysis"), - _INTL("Frozen") - ],cmd) - break if cmd<0 - case cmd - when 0 # Cure - pkmn.healStatus - pbDisplay(_INTL("{1}'s status was cured.",pkmn.name)) - pbRefreshSingle(pkmnid) - else # Give status problem - count = 0 - cancel = false - if cmd==PBStatuses::SLEEP - params = ChooseNumberParams.new - params.setRange(0,9) - params.setDefaultValue(3) - count = pbMessageChooseNumber( - _INTL("Set the Pokémon's sleep count."),params) { pbUpdate } - cancel = true if count<=0 - end - if !cancel - pkmn.status = cmd - pkmn.statusCount = count - pbRefreshSingle(pkmnid) - end - end - end - end - #=========================================================================== - when "fullheal" - if pkmn.egg? - pbDisplay(_INTL("{1} is an egg.",pkmn.name)) - else - pkmn.heal - pbDisplay(_INTL("{1} was fully healed.",pkmn.name)) - pbRefreshSingle(pkmnid) - end - #=========================================================================== - when "makefainted" - if pkmn.egg? - pbDisplay(_INTL("{1} is an egg.",pkmn.name)) - else - pkmn.hp = 0 - pbRefreshSingle(pkmnid) - end - #=========================================================================== - when "setpokerus" - cmd = 0 - loop do - pokerus = (pkmn.pokerus) ? pkmn.pokerus : 0 - msg = [_INTL("{1} doesn't have Pokérus.",pkmn.name), - _INTL("Has strain {1}, infectious for {2} more days.",pokerus/16,pokerus%16), - _INTL("Has strain {1}, not infectious.",pokerus/16)][pkmn.pokerusStage] - cmd = pbShowCommands(msg,[ - _INTL("Give random strain"), - _INTL("Make not infectious"), - _INTL("Clear Pokérus")],cmd) - break if cmd<0 - case cmd - when 0 # Give random strain - pkmn.givePokerus - pbRefreshSingle(pkmnid) - when 1 # Make not infectious - if pokerus>0 - strain = pokerus/16 - p = strain << 4 - pkmn.pokerus = p - pbRefreshSingle(pkmnid) - end - when 2 # Clear Pokérus - pkmn.pokerus = 0 - pbRefreshSingle(pkmnid) - end - end - #=========================================================================== - when "setlevel" - if pkmn.egg? - pbDisplay(_INTL("{1} is an egg.",pkmn.name)) - else - mLevel = PBExperience.maxLevel - params = ChooseNumberParams.new - params.setRange(1,mLevel) - params.setDefaultValue(pkmn.level) - level = pbMessageChooseNumber( - _INTL("Set the Pokémon's level (max. {1}).",mLevel),params) { pbUpdate } - if level!=pkmn.level - pkmn.level = level - pkmn.calcStats - pbRefreshSingle(pkmnid) - end - end - #=========================================================================== - when "setexp" - if pkmn.egg? - pbDisplay(_INTL("{1} is an egg.",pkmn.name)) - else - minxp = PBExperience.pbGetStartExperience(pkmn.level,pkmn.growthrate) - maxxp = PBExperience.pbGetStartExperience(pkmn.level+1,pkmn.growthrate) - if minxp==maxxp - pbDisplay(_INTL("{1} is at the maximum level.",pkmn.name)) - else - params = ChooseNumberParams.new - params.setRange(minxp,maxxp-1) - params.setDefaultValue(pkmn.exp) - newexp = pbMessageChooseNumber( - _INTL("Set the Pokémon's Exp (range {1}-{2}).",minxp,maxxp-1),params) { pbUpdate } - if newexp!=pkmn.exp - pkmn.exp = newexp - pkmn.calcStats - pbRefreshSingle(pkmnid) - end - end - end - #=========================================================================== - when "hiddenvalues" - numstats = 6 - cmd = 0 - loop do - persid = sprintf("0x%08X",pkmn.personalID) - cmd = pbShowCommands(_INTL("Personal ID is {1}.",persid),[ - _INTL("Set EVs"), - _INTL("Set IVs"), - _INTL("Randomise pID")],cmd) - break if cmd<0 - case cmd - when 0 # Set EVs - cmd2 = 0 - loop do - totalev = 0 - evcommands = [] - for i in 0...numstats - evcommands.push(PBStats.getName(i)+" (#{pkmn.ev[i]})") - totalev += pkmn.ev[i] - end - evcommands.push(_INTL("Randomise all")) - evcommands.push(_INTL("Max randomise all")) - cmd2 = pbShowCommands(_INTL("Change which EV?\nTotal: {1}/{2} ({3}%)", - totalev, Pokemon::EV_LIMIT, - 100*totalev/Pokemon::EV_LIMIT), evcommands, cmd2) - break if cmd2<0 - if cmd20 - r = rand(numstats) - next if pkmn.ev[r]>=Pokemon::EV_STAT_LIMIT - addVal = 1+rand(Pokemon::EV_STAT_LIMIT/4) - addVal = evTotalTarget if addVal>evTotalTarget - addVal = [addVal, Pokemon::EV_STAT_LIMIT-pkmn.ev[r]].min - next if addVal==0 - pkmn.ev[r] += addVal - evTotalTarget -= addVal - end - pkmn.calcStats - pbRefreshSingle(pkmnid) - end - end - when 1 # Set IVs - cmd2 = 0 - loop do - hiddenpower = pbHiddenPower(pkmn) - totaliv = 0 - ivcommands = [] - for i in 0...numstats - ivcommands.push(PBStats.getName(i)+" (#{pkmn.iv[i]})") - totaliv += pkmn.iv[i] - end - msg = _INTL("Change which IV?\nHidden Power:\n{1}, power {2}\nTotal: {3}/{4} ({5}%)", - GameData::Type.get(hiddenpower[0]).name,hiddenpower[1],totaliv,numstats*31, - 100*totaliv/(numstats*31)) - ivcommands.push(_INTL("Randomise all")) - cmd2 = pbShowCommands(msg,ivcommands,cmd2) - break if cmd2<0 - if cmd2=0 - movename = pkmn.moves[moveindex].name - pkmn.pbDeleteMoveAtIndex(moveindex) - pbDisplay(_INTL("{1} forgot {2}.",pkmn.name,movename)) - pbRefreshSingle(pkmnid) - end - #=========================================================================== - when "resetmoves" - pkmn.resetMoves - pbDisplay(_INTL("{1}'s moves were reset.",pkmn.name)) - pbRefreshSingle(pkmnid) - #=========================================================================== - when "setmovepp" - cmd = 0 - loop do - commands = [] - for i in pkmn.moves - break if !i.id - if i.total_pp<=0 - commands.push(_INTL("{1} (PP: ---)",i.name)) - else - commands.push(_INTL("{1} (PP: {2}/{3})",i.name,i.pp,i.total_pp)) - end - end - commands.push(_INTL("Restore all PP")) - cmd = pbShowCommands(_INTL("Alter PP of which move?"),commands,cmd) - break if cmd<0 - if cmd>=0 && cmdmove.total_pp - end - end - end - elsif cmd==commands.length-1 # Restore all PP - pkmn.healPP - end - end - #=========================================================================== - when "setinitialmoves" - pkmn.pbRecordFirstMoves - pbDisplay(_INTL("{1}'s moves were set as its first-known moves.",pkmn.name)) - pbRefreshSingle(pkmnid) - #=========================================================================== - when "setability" - cmd = 0 - loop do - abils = pkmn.getAbilityList - oldabil = (pkmn.ability) ? pkmn.ability.name : "No ability" - commands = [] - for i in abils - commands.push(((i[1]<2) ? "" : "(H) ") + GameData::Ability.get(i[0]).name) - end - commands.push(_INTL("Remove override")) - msg = [_INTL("Ability {1} is natural.",oldabil), - _INTL("Ability {1} is being forced.",oldabil)][pkmn.abilityflag!=nil ? 1 : 0] - cmd = pbShowCommands(msg,commands,cmd) - break if cmd<0 - if cmd>=0 && cmd=0 && cmdb[1] } - cmd = 0 - for i in 0...balls.length - if balls[i][0]==pkmn.ballused - cmd = i; break - end - end - for i in balls - commands.push(i[1]) - end - loop do - oldball = pbBallTypeToItem(pkmn.ballused).name - cmd = pbShowCommands(_INTL("{1} used.",oldball),commands,cmd) - break if cmd<0 - pkmn.ballused = balls[cmd][0] - end - #=========================================================================== - when "setribbons" - cmd = 0 - loop do - commands = [] - for i in 1..PBRibbons.maxValue - commands.push(_INTL("{1} {2}", - (pkmn.hasRibbon?(i)) ? "[Y]" : "[ ]",PBRibbons.getName(i))) - end - commands.push(_INTL("Give all")) - commands.push(_INTL("Clear all")) - cmd = pbShowCommands(_INTL("{1} ribbons.",pkmn.ribbonCount),commands,cmd) - break if cmd<0 - if cmd>=0 && cmd=0 - when 3 # Random foreign ID - pkmn.owner.id = $Trainer.getForeignID - when 4 # Set foreign ID - params = ChooseNumberParams.new - params.setRange(0,65535) - params.setDefaultValue(pkmn.owner.public_id) - val = pbMessageChooseNumber( - _INTL("Set the new ID (max. 65535)."),params) { pbUpdate } - pkmn.owner.id = val - pkmn.owner.id |= val << 16 - end - end - #=========================================================================== - when "setegg" - cmd = 0 - loop do - msg = [_INTL("Not an egg"), - _INTL("Egg with eggsteps: {1}.",pkmn.eggsteps)][pkmn.egg? ? 1 : 0] - cmd = pbShowCommands(msg,[ - _INTL("Make egg"), - _INTL("Make Pokémon"), - _INTL("Set eggsteps to 1")],cmd) - break if cmd<0 - case cmd - when 0 # Make egg - if !pkmn.egg? && (pbHasEgg?(pkmn.species) || - pbConfirm(_INTL("{1} cannot legally be an egg. Make egg anyway?", pkmn.speciesName))) - pkmn.level = EGG_LEVEL - pkmn.calcStats - pkmn.name = _INTL("Egg") - pkmn.eggsteps = pkmn.species_data.hatch_steps - pkmn.hatchedMap = 0 - pkmn.obtainMode = 1 - pbRefreshSingle(pkmnid) - end - when 1 # Make Pokémon - if pkmn.egg? - pkmn.name = pkmn.speciesName - pkmn.eggsteps = 0 - pkmn.hatchedMap = 0 - pkmn.obtainMode = 0 - pbRefreshSingle(pkmnid) - end - when 2 # Set eggsteps to 1 - pkmn.eggsteps = 1 if pkmn.egg? - end - end - #=========================================================================== - when "shadowpkmn" - cmd = 0 - loop do - msg = [_INTL("Not a Shadow Pokémon."), - _INTL("Heart gauge is {1} (stage {2}).",pkmn.heartgauge,pkmn.heartStage) - ][pkmn.shadowPokemon? ? 1 : 0] - cmd = pbShowCommands(msg,[ - _INTL("Make Shadow"), - _INTL("Set heart gauge")],cmd) - break if cmd<0 - case cmd - when 0 # Make Shadow - if !pkmn.shadowPokemon? - pkmn.makeShadow - pbRefreshSingle(pkmnid) - else - pbDisplay(_INTL("{1} is already a Shadow Pokémon.",pkmn.name)) - end - when 1 # Set heart gauge - if pkmn.shadowPokemon? - oldheart = pkmn.heartgauge - params = ChooseNumberParams.new - params.setRange(0, Pokemon::HEARTGAUGESIZE) - params.setDefaultValue(pkmn.heartgauge) - val = pbMessageChooseNumber( - _INTL("Set the heart gauge (max. {1}).", Pokemon::HEARTGAUGESIZE), - params) { pbUpdate } - if val!=oldheart - pkmn.adjustHeart(val-oldheart) - pbReadyToPurify(pkmn) - end - else - pbDisplay(_INTL("{1} is not a Shadow Pokémon.",pkmn.name)) - end - end - end - #=========================================================================== - when "mysterygift" - pbCreateMysteryGift(0,pkmn) - #=========================================================================== - when "duplicate" - if pbConfirm(_INTL("Are you sure you want to copy this Pokémon?")) - clonedpkmn = pkmn.clone - if self.is_a?(PokemonPartyScreen) - pbStorePokemon(clonedpkmn) - pbHardRefresh - pbDisplay(_INTL("The Pokémon was duplicated.")) - elsif self.is_a?(PokemonStorageScreen) - if @storage.pbMoveCaughtToParty(clonedpkmn) - if pkmnid[0]!=-1 - pbDisplay(_INTL("The duplicated Pokémon was moved to your party.")) - end - else - oldbox = @storage.currentBox - newbox = @storage.pbStoreCaught(clonedpkmn) - if newbox<0 - pbDisplay(_INTL("All boxes are full.")) - elsif newbox!=oldbox - pbDisplay(_INTL("The duplicated Pokémon was moved to box \"{1}.\"",@storage[newbox].name)) - @storage.currentBox = oldbox - end - end - pbHardRefresh - end - return false - end - #=========================================================================== - when "delete" - if pbConfirm(_INTL("Are you sure you want to delete this Pokémon?")) - if self.is_a?(PokemonPartyScreen) - @party[pkmnid] = nil - @party.compact! - pbHardRefresh - elsif self.is_a?(PokemonStorageScreen) - @scene.pbRelease(pkmnid,heldpoke) - (heldpoke) ? @heldpkmn = nil : @storage.pbDelete(pkmnid[0],pkmnid[1]) - @scene.pbRefresh - end - return false - end - end - return true - end - - def pbPokemonDebug(pkmn,pkmnid,heldpoke=nil,settingUpBattle=false) - command = 0 - commands = pbPokemonDebugCommands(settingUpBattle) - loop do - command = pbShowCommands(_INTL("Do what with {1}?",pkmn.name),commands.list,command) - if command<0 - parent = commands.getParent - if parent - commands.currentList = parent[0] - command = parent[1] - else - break - end - else - cmd = commands.getCommand(command) - if commands.hasSubMenu?(cmd) - commands.currentList = cmd - command = 0 - else - cont = pbPokemonDebugActions(cmd,pkmn,pkmnid,heldpoke,settingUpBattle) - break if !cont - end - end - end - end -end - - - -class PokemonPartyScreen - include PokemonDebugMixin -end - - - -class PokemonStorageScreen - include PokemonDebugMixin -end - - - -class PokemonDebugPartyScreen - include PokemonDebugMixin -end diff --git a/Data/Scripts/021_Debug/003_Debug_PokemonCommands.rb b/Data/Scripts/021_Debug/003_Debug_PokemonCommands.rb new file mode 100644 index 000000000..5fddcf3da --- /dev/null +++ b/Data/Scripts/021_Debug/003_Debug_PokemonCommands.rb @@ -0,0 +1,1084 @@ +#=============================================================================== +# +#=============================================================================== +module PokemonDebugMenuCommands + @@commands = HandlerHashBasic.new + + def self.register(option, hash) + @@commands.add(option, hash) + end + + def self.registerIf(condition, hash) + @@commands.addIf(condition, hash) + end + + def self.copy(option, *new_options) + @@commands.copy(option, *new_options) + end + + def self.each + @@commands.each { |key, hash| yield key, hash } + end + + def self.hasFunction?(option, function) + option_hash = @@commands[option] + return option_hash && option_hash.keys.include?(function) + end + + def self.getFunction(option, function) + option_hash = @@commands[option] + return (option_hash && option_hash[function]) ? option_hash[function] : nil + end + + def self.call(function, option, *args) + option_hash = @@commands[option] + return nil if !option_hash || !option_hash[function] + return option_hash[function].call(*args) + end +end + +#=============================================================================== +# HP/Status options +#=============================================================================== +PokemonDebugMenuCommands.register("hpstatusmenu", { + "parent" => "main", + "name" => _INTL("HP/Status..."), + "always_show" => true +}) + +PokemonDebugMenuCommands.register("sethp", { + "parent" => "hpstatusmenu", + "name" => _INTL("Set HP"), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + if pkmn.egg? + screen.pbDisplay(_INTL("{1} is an egg.", pkmn.name)) + else + params = ChooseNumberParams.new + params.setRange(0, pkmn.totalhp) + params.setDefaultValue(pkmn.hp) + newhp = pbMessageChooseNumber( + _INTL("Set {1}'s HP (max. {2}).", pkmn.name, pkmn.totalhp), params) { screen.pbUpdate } + if newhp != pkmn.hp + pkmn.hp = newhp + screen.pbRefreshSingle(pkmnid) + end + end + ) +}) + +PokemonDebugMenuCommands.register("setstatus", { + "parent" => "hpstatusmenu", + "name" => _INTL("Set status"), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + if pkmn.egg? + screen.pbDisplay(_INTL("{1} is an egg.", pkmn.name)) + elsif pkmn.hp<=0 + screen.pbDisplay(_INTL("{1} is fainted, can't change status.", pkmn.name)) + else + cmd = 0 + loop do + cmd = screen.pbShowCommands(_INTL("Set {1}'s status.", pkmn.name), [ + _INTL("[Cure]"), + _INTL("Sleep"), + _INTL("Poison"), + _INTL("Burn"), + _INTL("Paralysis"), + _INTL("Frozen") + ], cmd) + break if cmd < 0 + case cmd + when 0 # Cure + pkmn.healStatus + screen.pbDisplay(_INTL("{1}'s status was cured.", pkmn.name)) + screen.pbRefreshSingle(pkmnid) + else # Give status problem + count = 0 + cancel = false + if cmd == PBStatuses::SLEEP + params = ChooseNumberParams.new + params.setRange(0, 9) + params.setDefaultValue(3) + count = pbMessageChooseNumber( + _INTL("Set the Pokémon's sleep count."), params) { screen.pbUpdate } + cancel = true if count <= 0 + end + if !cancel + pkmn.status = cmd + pkmn.statusCount = count + screen.pbRefreshSingle(pkmnid) + end + end + end + end + ) +}) + +PokemonDebugMenuCommands.register("fullheal", { + "parent" => "hpstatusmenu", + "name" => _INTL("Fully heal"), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + if pkmn.egg? + screen.pbDisplay(_INTL("{1} is an egg.", pkmn.name)) + else + pkmn.heal + screen.pbDisplay(_INTL("{1} was fully healed.", pkmn.name)) + screen.pbRefreshSingle(pkmnid) + end + ) +}) + +PokemonDebugMenuCommands.register("makefainted", { + "parent" => "hpstatusmenu", + "name" => _INTL("Make fainted"), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + if pkmn.egg? + screen.pbDisplay(_INTL("{1} is an egg.", pkmn.name)) + else + pkmn.hp = 0 + screen.pbRefreshSingle(pkmnid) + end + ) +}) + +PokemonDebugMenuCommands.register("setpokerus", { + "parent" => "hpstatusmenu", + "name" => _INTL("Set Pokérus"), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + cmd = 0 + loop do + pokerus = (pkmn.pokerus) ? pkmn.pokerus : 0 + msg = [_INTL("{1} doesn't have Pokérus.", pkmn.name), + _INTL("Has strain {1}, infectious for {2} more days.", pokerus / 16, pokerus % 16), + _INTL("Has strain {1}, not infectious.", pokerus / 16)][pkmn.pokerusStage] + cmd = screen.pbShowCommands(msg,[ + _INTL("Give random strain"), + _INTL("Make not infectious"), + _INTL("Clear Pokérus")], cmd) + break if cmd < 0 + case cmd + when 0 # Give random strain + pkmn.givePokerus + screen.pbRefreshSingle(pkmnid) + when 1 # Make not infectious + if pokerus > 0 + strain = pokerus / 16 + p = strain << 4 + pkmn.pokerus = p + screen.pbRefreshSingle(pkmnid) + end + when 2 # Clear Pokérus + pkmn.pokerus = 0 + screen.pbRefreshSingle(pkmnid) + end + end + ) +}) + +#=============================================================================== +# Level/stats options +#=============================================================================== +PokemonDebugMenuCommands.register("levelstats", { + "parent" => "main", + "name" => _INTL("Level/stats..."), + "always_show" => true +}) + +PokemonDebugMenuCommands.register("setlevel", { + "parent" => "levelstats", + "name" => _INTL("Set level"), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + if pkmn.egg? + screen.pbDisplay(_INTL("{1} is an egg.", pkmn.name)) + else + mLevel = PBExperience.maxLevel + params = ChooseNumberParams.new + params.setRange(1, mLevel) + params.setDefaultValue(pkmn.level) + level = pbMessageChooseNumber( + _INTL("Set the Pokémon's level (max. {1}).", mLevel), params) { screen.pbUpdate } + if level != pkmn.level + pkmn.level = level + pkmn.calcStats + screen.pbRefreshSingle(pkmnid) + end + end + ) +}) + +PokemonDebugMenuCommands.register("setexp", { + "parent" => "levelstats", + "name" => _INTL("Set Exp"), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + if pkmn.egg? + screen.pbDisplay(_INTL("{1} is an egg.", pkmn.name)) + else + minxp = PBExperience.pbGetStartExperience(pkmn.level, pkmn.growthrate) + maxxp = PBExperience.pbGetStartExperience(pkmn.level + 1, pkmn.growthrate) + if minxp == maxxp + screen.pbDisplay(_INTL("{1} is at the maximum level.", pkmn.name)) + else + params = ChooseNumberParams.new + params.setRange(minxp, maxxp - 1) + params.setDefaultValue(pkmn.exp) + newexp = pbMessageChooseNumber( + _INTL("Set the Pokémon's Exp (range {1}-{2}).",minxp, maxxp - 1), params) { screen.pbUpdate } + if newexp != pkmn.exp + pkmn.exp = newexp + pkmn.calcStats + screen.pbRefreshSingle(pkmnid) + end + end + end + ) +}) + +PokemonDebugMenuCommands.register("hiddenvalues", { + "parent" => "levelstats", + "name" => _INTL("EV/IV/pID..."), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + numstats = 6 + cmd = 0 + loop do + persid = sprintf("0x%08X", pkmn.personalID) + cmd = screen.pbShowCommands(_INTL("Personal ID is {1}.", persid),[ + _INTL("Set EVs"), + _INTL("Set IVs"), + _INTL("Randomise pID")], cmd) + break if cmd < 0 + case cmd + when 0 # Set EVs + cmd2 = 0 + loop do + totalev = 0 + evcommands = [] + for i in 0...numstats + evcommands.push(PBStats.getName(i) + " (#{pkmn.ev[i]})") + totalev += pkmn.ev[i] + end + evcommands.push(_INTL("Randomise all")) + evcommands.push(_INTL("Max randomise all")) + cmd2 = screen.pbShowCommands(_INTL("Change which EV?\nTotal: {1}/{2} ({3}%)", + totalev, Pokemon::EV_LIMIT, + 100 * totalev / Pokemon::EV_LIMIT), evcommands, cmd2) + break if cmd2 < 0 + if cmd2 < numstats + params = ChooseNumberParams.new + upperLimit = 0 + for i in 0...numstats + upperLimit += pkmn.ev[i] if i != cmd2 + end + upperLimit = Pokemon::EV_LIMIT - upperLimit + upperLimit = [upperLimit, Pokemon::EV_STAT_LIMIT].min + thisValue = [pkmn.ev[cmd2], upperLimit].min + params.setRange(0, upperLimit) + params.setDefaultValue(thisValue) + params.setCancelValue(thisValue) + f = pbMessageChooseNumber(_INTL("Set the EV for {1} (max. {2}).", + PBStats.getName(cmd2), upperLimit), params) { screen.pbUpdate } + if f != pkmn.ev[cmd2] + pkmn.ev[cmd2] = f + pkmn.calcStats + screen.pbRefreshSingle(pkmnid) + end + elsif cmd2 < evcommands.length # Randomise + evTotalTarget = Pokemon::EV_LIMIT + if cmd2 == evcommands.length - 2 + evTotalTarget = rand(Pokemon::EV_LIMIT) + end + for i in 0...numstats + pkmn.ev[i] = 0 + end + while evTotalTarget > 0 + r = rand(numstats) + next if pkmn.ev[r] >= Pokemon::EV_STAT_LIMIT + addVal = 1 + rand(Pokemon::EV_STAT_LIMIT/4) + addVal = evTotalTarget if addVal > evTotalTarget + addVal = [addVal, Pokemon::EV_STAT_LIMIT - pkmn.ev[r]].min + next if addVal == 0 + pkmn.ev[r] += addVal + evTotalTarget -= addVal + end + pkmn.calcStats + screen.pbRefreshSingle(pkmnid) + end + end + when 1 # Set IVs + cmd2 = 0 + loop do + hiddenpower = pbHiddenPower(pkmn) + totaliv = 0 + ivcommands = [] + for i in 0...numstats + ivcommands.push(PBStats.getName(i) + " (#{pkmn.iv[i]})") + totaliv += pkmn.iv[i] + end + msg = _INTL("Change which IV?\nHidden Power:\n{1}, power {2}\nTotal: {3}/{4} ({5}%)", + GameData::Type.get(hiddenpower[0]).name, hiddenpower[1], totaliv, numstats * 31, + 100 * totaliv / (numstats * 31)) + ivcommands.push(_INTL("Randomise all")) + cmd2 = screen.pbShowCommands(msg, ivcommands, cmd2) + break if cmd2 < 0 + if cmd2 < numstats + params = ChooseNumberParams.new + params.setRange(0, 31) + params.setDefaultValue(pkmn.iv[cmd2]) + params.setCancelValue(pkmn.iv[cmd2]) + f = pbMessageChooseNumber(_INTL("Set the IV for {1} (max. 31).", + PBStats.getName(cmd2)), params) { screen.pbUpdate } + if f != pkmn.iv[cmd2] + pkmn.iv[cmd2] = f + pkmn.calcStats + screen.pbRefreshSingle(pkmnid) + end + elsif cmd2 == ivcommands.length - 1 # Randomise + for i in 0...numstats + pkmn.iv[i] = rand(Pokemon::IV_STAT_LIMIT + 1) + end + pkmn.calcStats + screen.pbRefreshSingle(pkmnid) + end + end + when 2 # Randomise pID + pkmn.personalID = rand(2 ** 16) | rand(2 ** 16) << 16 + pkmn.calcStats + screen.pbRefreshSingle(pkmnid) + end + end + ) +}) + +PokemonDebugMenuCommands.register("sethappiness", { + "parent" => "levelstats", + "name" => _INTL("Set happiness"), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + params = ChooseNumberParams.new + params.setRange(0, 255) + params.setDefaultValue(pkmn.happiness) + h = pbMessageChooseNumber( + _INTL("Set the Pokémon's happiness (max. 255)."), params) { screen.pbUpdate } + if h != pkmn.happiness + pkmn.happiness = h + screen.pbRefreshSingle(pkmnid) + end + ) +}) + +PokemonDebugMenuCommands.register("conteststats", { + "parent" => "levelstats", + "name" => _INTL("Contest stats..."), + "always_show" => true +}) + +PokemonDebugMenuCommands.register("setbeauty", { + "parent" => "conteststats", + "name" => _INTL("Set Beauty"), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + params = ChooseNumberParams.new + params.setRange(0, 255) + params.setDefaultValue(pkmn.beauty) + newval = pbMessageChooseNumber( + _INTL("Set the Pokémon's Beauty (max. 255)."), params) { screen.pbUpdate } + if newval != pkmn.beauty + pkmn.beauty = newval + screen.pbRefreshSingle(pkmnid) + end + ) +}) + +PokemonDebugMenuCommands.register("setcool", { + "parent" => "conteststats", + "name" => _INTL("Set Cool"), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + params = ChooseNumberParams.new + params.setRange(0, 255) + params.setDefaultValue(pkmn.cool) + newval = pbMessageChooseNumber( + _INTL("Set the Pokémon's Cool (max. 255)."), params) { screen.pbUpdate } + if newval != pkmn.cool + pkmn.cool = newval + screen.pbRefreshSingle(pkmnid) + end + ) +}) + +PokemonDebugMenuCommands.register("setcute", { + "parent" => "conteststats", + "name" => _INTL("Set Cute"), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + params = ChooseNumberParams.new + params.setRange(0, 255) + params.setDefaultValue(pkmn.cute) + newval = pbMessageChooseNumber( + _INTL("Set the Pokémon's Cute (max. 255)."), params) { screen.pbUpdate } + if newval != pkmn.cute + pkmn.cute = newval + screen.pbRefreshSingle(pkmnid) + end + ) +}) + +PokemonDebugMenuCommands.register("setsmart", { + "parent" => "conteststats", + "name" => _INTL("Set Smart"), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + params = ChooseNumberParams.new + params.setRange(0, 255) + params.setDefaultValue(pkmn.smart) + newval = pbMessageChooseNumber( + _INTL("Set the Pokémon's Smart (max. 255)."), params) { screen.pbUpdate } + if newval != pkmn.smart + pkmn.smart = newval + screen.pbRefreshSingle(pkmnid) + end + ) +}) + +PokemonDebugMenuCommands.register("settough", { + "parent" => "conteststats", + "name" => _INTL("Set Tough"), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + params = ChooseNumberParams.new + params.setRange(0, 255) + params.setDefaultValue(pkmn.tough) + newval = pbMessageChooseNumber( + _INTL("Set the Pokémon's Tough (max. 255)."), params) { screen.pbUpdate } + if newval != pkmn.tough + pkmn.tough = newval + screen.pbRefreshSingle(pkmnid) + end + ) +}) + +PokemonDebugMenuCommands.register("setsheen", { + "parent" => "conteststats", + "name" => _INTL("Set Sheen"), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + params = ChooseNumberParams.new + params.setRange(0, 255) + params.setDefaultValue(pkmn.sheen) + newval = pbMessageChooseNumber( + _INTL("Set the Pokémon's Sheen (max. 255)."), params) { screen.pbUpdate } + if newval != pkmn.sheen + pkmn.sheen = newval + screen.pbRefreshSingle(pkmnid) + end + ) +}) + +#=============================================================================== +# Moves options +#=============================================================================== +PokemonDebugMenuCommands.register("moves", { + "parent" => "main", + "name" => _INTL("Moves..."), + "always_show" => true +}) + +PokemonDebugMenuCommands.register("teachmove", { + "parent" => "moves", + "name" => _INTL("Teach move"), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + move = pbChooseMoveList + if move + pbLearnMove(pkmn, move) + screen.pbRefreshSingle(pkmnid) + end + ) +}) + +PokemonDebugMenuCommands.register("forgetmove", { + "parent" => "moves", + "name" => _INTL("Forget move"), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + moveindex = screen.pbChooseMove(pkmn, _INTL("Choose move to forget.")) + if moveindex >= 0 + movename = pkmn.moves[moveindex].name + pkmn.pbDeleteMoveAtIndex(moveindex) + screen.pbDisplay(_INTL("{1} forgot {2}.", pkmn.name, movename)) + screen.pbRefreshSingle(pkmnid) + end + ) +}) + +PokemonDebugMenuCommands.register("resetmoves", { + "parent" => "moves", + "name" => _INTL("Reset moves"), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + pkmn.resetMoves + screen.pbDisplay(_INTL("{1}'s moves were reset.", pkmn.name)) + screen.pbRefreshSingle(pkmnid) + ) +}) + +PokemonDebugMenuCommands.register("setmovepp", { + "parent" => "moves", + "name" => _INTL("Set move PP"), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + cmd = 0 + loop do + commands = [] + for i in pkmn.moves + break if !i.id + if i.total_pp <= 0 + commands.push(_INTL("{1} (PP: ---)", i.name)) + else + commands.push(_INTL("{1} (PP: {2}/{3})", i.name, i.pp, i.total_pp)) + end + end + commands.push(_INTL("Restore all PP")) + cmd = screen.pbShowCommands(_INTL("Alter PP of which move?"), commands, cmd) + break if cmd < 0 + if cmd >= 0 && cmd < commands.length - 1 # Move + move = pkmn.moves[cmd] + movename = move.name + if move.total_pp <= 0 + screen.pbDisplay(_INTL("{1} has infinite PP.", movename)) + else + cmd2 = 0 + loop do + msg = _INTL("{1}: PP {2}/{3} (PP Up {4}/3)", movename, move.pp, move.total_pp, move.ppup) + cmd2 = screen.pbShowCommands(msg, [ + _INTL("Set PP"), + _INTL("Full PP"), + _INTL("Set PP Up")], cmd2) + break if cmd2 < 0 + case cmd2 + when 0 # Change PP + params = ChooseNumberParams.new + params.setRange(0, move.total_pp) + params.setDefaultValue(move.pp) + h = pbMessageChooseNumber( + _INTL("Set PP of {1} (max. {2}).", movename, move.total_pp), params) { screen.pbUpdate } + move.pp = h + when 1 # Full PP + move.pp = move.total_pp + when 2 # Change PP Up + params = ChooseNumberParams.new + params.setRange(0, 3) + params.setDefaultValue(move.ppup) + h = pbMessageChooseNumber( + _INTL("Set PP Up of {1} (max. 3).", movename), params) { screen.pbUpdate } + move.ppup = h + move.pp = move.total_pp if move.pp > move.total_pp + end + end + end + elsif cmd == commands.length - 1 # Restore all PP + pkmn.healPP + end + end + ) +}) + +PokemonDebugMenuCommands.register("setinitialmoves", { + "parent" => "moves", + "name" => _INTL("Reset initial moves"), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + pkmn.pbRecordFirstMoves + screen.pbDisplay(_INTL("{1}'s moves were set as its first-known moves.", pkmn.name)) + screen.pbRefreshSingle(pkmnid) + ) +}) + +#=============================================================================== +# Other options +#=============================================================================== +PokemonDebugMenuCommands.register("setability", { + "parent" => "main", + "name" => _INTL("Set ability"), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + cmd = 0 + loop do + abils = pkmn.getAbilityList + oldabil = (pkmn.ability) ? pkmn.ability.name : "No ability" + commands = [] + for i in abils + commands.push(((i[1] < 2) ? "" : "(H) ") + GameData::Ability.get(i[0]).name) + end + commands.push(_INTL("Remove override")) + msg = [_INTL("Ability {1} is natural.", oldabil), + _INTL("Ability {1} is being forced.", oldabil)][pkmn.abilityflag != nil ? 1 : 0] + cmd = screen.pbShowCommands(msg, commands, cmd) + break if cmd < 0 + if cmd >= 0 && cmd < abils.length # Set ability override + pkmn.setAbility(abils[cmd][1]) + elsif cmd == abils.length # Remove override + pkmn.abilityflag = nil + end + screen.pbRefreshSingle(pkmnid) + end + ) +}) + +PokemonDebugMenuCommands.register("setnature", { + "parent" => "main", + "name" => _INTL("Set nature"), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + commands = [] + (PBNatures.getCount).times do |i| + statUp = PBNatures.getStatRaised(i) + statDown = PBNatures.getStatLowered(i) + if statUp != statDown + text = _INTL("{1} (+{2}, -{3})", PBNatures.getName(i), + PBStats.getNameBrief(statUp), PBStats.getNameBrief(statDown)) + else + text = _INTL("{1} (---)", PBNatures.getName(i)) + end + commands.push(text) + end + commands.push(_INTL("[Remove override]")) + cmd = pkmn.nature + loop do + oldnature = PBNatures.getName(pkmn.nature) + msg = [_INTL("Nature {1} is natural.", oldnature), + _INTL("Nature {1} is being forced.", oldnature)][pkmn.natureflag ? 1 : 0] + cmd = screen.pbShowCommands(msg, commands, cmd) + break if cmd < 0 + if cmd >= 0 && cmd < PBNatures.getCount # Set nature override + pkmn.setNature(cmd) + pkmn.calcStats + elsif cmd == PBNatures.getCount # Remove override + pkmn.natureflag = nil + end + screen.pbRefreshSingle(pkmnid) + end + ) +}) + +PokemonDebugMenuCommands.register("setgender", { + "parent" => "main", + "name" => _INTL("Set gender"), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + if pkmn.singleGendered? + screen.pbDisplay(_INTL("{1} is single-gendered or genderless.", pkmn.speciesName)) + else + cmd = 0 + loop do + oldgender = (pkmn.male?) ? _INTL("male") : _INTL("female") + msg = [_INTL("Gender {1} is natural.", oldgender), + _INTL("Gender {1} is being forced.", oldgender)][pkmn.genderflag ? 1 : 0] + cmd = pbShowCommands(msg, [ + _INTL("Make male"), + _INTL("Make female"), + _INTL("Remove override")], cmd) + break if cmd < 0 + case cmd + when 0 # Make male + pkmn.makeMale + if !pkmn.male? + screen.pbDisplay(_INTL("{1}'s gender couldn't be changed.", pkmn.name)) + end + when 1 # Make female + pkmn.makeFemale + if !pkmn.female? + screen.pbDisplay(_INTL("{1}'s gender couldn't be changed.", pkmn.name)) + end + when 2 # Remove override + pkmn.genderflag = nil + end + pbSeenForm(pkmn) if !settingUpBattle + screen.pbRefreshSingle(pkmnid) + end + end + ) +}) + +PokemonDebugMenuCommands.register("speciesform", { + "parent" => "main", + "name" => _INTL("Species/form..."), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + cmd = 0 + loop do + msg = [_INTL("Species {1}, form {2}.", pkmn.speciesName, pkmn.form), + _INTL("Species {1}, form {2} (forced).", pkmn.speciesName, pkmn.form)][(pkmn.forcedForm != nil) ? 1 : 0] + cmd = screen.pbShowCommands(msg, [ + _INTL("Set species"), + _INTL("Set form"), + _INTL("Remove override")], cmd) + break if cmd < 0 + case cmd + when 0 # Set species + species = pbChooseSpeciesList(pkmn.species) + if species && species != pkmn.species + pkmn.species = species + pkmn.calcStats + pbSeenForm(pkmn) if !settingUpBattle + screen.pbRefreshSingle(pkmnid) + end + when 1 # Set form + cmd2 = 0 + formcmds = [[], []] + GameData::Species.each do |sp| + next if sp.species != pkmn.species + form_name = sp.form_name + form_name = _INTL("Unnamed form") if !form_name || form_name.empty? + form_name = sprintf("%d: %s", sp.form, form_name) + formcmds[0].push(sp.form) + formcmds[1].push(form_name) + cmd2 = sp.form if pkmn.form == sp.form + end + if formcmds[0].length <= 1 + screen.pbDisplay(_INTL("Species {1} only has one form.", pkmn.speciesName)) + else + cmd2 = screen.pbShowCommands(_INTL("Set the Pokémon's form."), formcmds[1], cmd2) + next if cmd2 < 0 + f = formcmds[0][cmd2] + if f != pkmn.form + if MultipleForms.hasFunction?(pkmn, "getForm") + next if !screen.pbConfirm(_INTL("This species decides its own form. Override?")) + pkmn.forcedForm = f + end + pkmn.form = f + pbSeenForm(pkmn) if !settingUpBattle + screen.pbRefreshSingle(pkmnid) + end + end + when 2 # Remove override + pkmn.forcedForm = nil + screen.pbRefreshSingle(pkmnid) + end + end + ) +}) + +#=============================================================================== +# Cosmetic options +#=============================================================================== +PokemonDebugMenuCommands.register("cosmetic", { + "parent" => "main", + "name" => _INTL("Cosmetic info..."), + "always_show" => true +}) + +PokemonDebugMenuCommands.register("setshininess", { + "parent" => "cosmetic", + "name" => _INTL("Set shininess"), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + cmd = 0 + loop do + oldshiny = (pkmn.shiny?) ? _INTL("shiny") : _INTL("normal") + msg = [_INTL("Shininess ({1}) is natural.", oldshiny), + _INTL("Shininess ({1}) is being forced.", oldshiny)][pkmn.shinyflag != nil ? 1 : 0] + cmd = screen.pbShowCommands(msg, [ + _INTL("Make shiny"), + _INTL("Make normal"), + _INTL("Remove override")], cmd) + break if cmd < 0 + case cmd + when 0 # Make shiny + pkmn.makeShiny + when 1 # Make normal + pkmn.makeNotShiny + when 2 # Remove override + pkmn.shinyflag = nil + end + screen.pbRefreshSingle(pkmnid) + end + ) +}) + +PokemonDebugMenuCommands.register("setpokeball", { + "parent" => "cosmetic", + "name" => _INTL("Set Poké Ball"), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + commands = [] + balls = [] + for key in $BallTypes.keys + item = GameData::Item.try_get($BallTypes[key]) + balls.push([key.to_i, item.name]) if item + end + balls.sort! { |a, b| a[1] <=> b[1] } + cmd = 0 + for i in 0...balls.length + next if balls[i][0] != pkmn.ballused + cmd = i + break + end + balls.each { |ball| commands.push(ball[1]) } + loop do + oldball = pbBallTypeToItem(pkmn.ballused).name + cmd = screen.pbShowCommands(_INTL("{1} used.", oldball), commands, cmd) + break if cmd < 0 + pkmn.ballused = balls[cmd][0] + end + ) +}) + +PokemonDebugMenuCommands.register("setribbons", { + "parent" => "cosmetic", + "name" => _INTL("Set ribbons"), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + cmd = 0 + loop do + commands = [] + for i in 1..PBRibbons.maxValue + commands.push(_INTL("{1} {2}", + (pkmn.hasRibbon?(i)) ? "[Y]" : "[ ]", PBRibbons.getName(i))) + end + commands.push(_INTL("Give all")) + commands.push(_INTL("Clear all")) + cmd = screen.pbShowCommands(_INTL("{1} ribbons.", pkmn.ribbonCount), commands, cmd) + break if cmd < 0 + if cmd >= 0 && cmd < PBRibbons.maxValue # Toggle ribbon + if pkmn.hasRibbon?(cmd + 1) + pkmn.takeRibbon(cmd + 1) + else + pkmn.giveRibbon(cmd + 1) + end + elsif cmd == commands.length - 2 # Give all + for i in 1..PBRibbons.maxValue + pkmn.giveRibbon(i) + end + elsif cmd == commands.length - 1 # Clear all + for i in 1..PBRibbons.maxValue + pkmn.takeRibbon(i) + end + end + end + ) +}) + +PokemonDebugMenuCommands.register("setnickname", { + "parent" => "cosmetic", + "name" => _INTL("Set nickname"), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + cmd = 0 + loop do + speciesname = pkmn.speciesName + msg = [_INTL("{1} has the nickname {2}.", speciesname, pkmn.name), + _INTL("{1} has no nickname.", speciesname)][pkmn.name == speciesname ? 1 : 0] + cmd = screen.pbShowCommands(msg, [ + _INTL("Rename"), + _INTL("Erase name")], cmd) + break if cmd < 0 + case cmd + when 0 # Rename + oldname = (pkmn.name && pkmn.name != speciesname) ? pkmn.name : "" + newname = pbEnterPokemonName(_INTL("{1}'s nickname?", speciesname), + 0, Pokemon::MAX_NAME_SIZE, oldname, pkmn) + if newname && newname != "" + pkmn.name = newname + screen.pbRefreshSingle(pkmnid) + end + when 1 # Erase name + pkmn.name = speciesname + screen.pbRefreshSingle(pkmnid) + end + end + ) +}) + +PokemonDebugMenuCommands.register("ownership", { + "parent" => "cosmetic", + "name" => _INTL("Ownership..."), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + cmd = 0 + loop do + gender = [_INTL("Male"), _INTL("Female"), _INTL("Unknown")][pkmn.owner.gender] + msg = [_INTL("Player's Pokémon\n{1}\n{2}\n{3} ({4})", pkmn.owner.name, gender, pkmn.owner.public_id, pkmn.owner.id), + _INTL("Foreign Pokémon\n{1}\n{2}\n{3} ({4})", pkmn.owner.name, gender, pkmn.owner.public_id, pkmn.owner.id) + ][pkmn.foreign?($Trainer) ? 1 : 0] + cmd = screen.pbShowCommands(msg, [ + _INTL("Make player's"), + _INTL("Set OT's name"), + _INTL("Set OT's gender"), + _INTL("Random foreign ID"), + _INTL("Set foreign ID")], cmd) + break if cmd < 0 + case cmd + when 0 # Make player's + pkmn.owner = Pokemon::Owner.new_from_trainer($Trainer) + when 1 # Set OT's name + pkmn.owner.name = pbEnterPlayerName(_INTL("{1}'s OT's name?", pkmn.name), 1, MAX_PLAYER_NAME_SIZE) + when 2 # Set OT's gender + cmd2 = screen.pbShowCommands(_INTL("Set OT's gender."), + [_INTL("Male"), _INTL("Female"), _INTL("Unknown")], pkmn.owner.gender) + pkmn.owner.gender = cmd2 if cmd2 >= 0 + when 3 # Random foreign ID + pkmn.owner.id = $Trainer.getForeignID + when 4 # Set foreign ID + params = ChooseNumberParams.new + params.setRange(0, 65535) + params.setDefaultValue(pkmn.owner.public_id) + val = pbMessageChooseNumber( + _INTL("Set the new ID (max. 65535)."), params) { screen.pbUpdate } + pkmn.owner.id = val | val << 16 + end + end + ) +}) + +#=============================================================================== +# Other options +#=============================================================================== +PokemonDebugMenuCommands.register("setegg", { + "parent" => "main", + "name" => _INTL("Set egg"), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + cmd = 0 + loop do + msg = [_INTL("Not an egg"), + _INTL("Egg with eggsteps: {1}.", pkmn.eggsteps)][pkmn.egg? ? 1 : 0] + cmd = screen.pbShowCommands(msg, [ + _INTL("Make egg"), + _INTL("Make Pokémon"), + _INTL("Set eggsteps to 1")], cmd) + break if cmd < 0 + case cmd + when 0 # Make egg + if !pkmn.egg? && (pbHasEgg?(pkmn.species) || + screen.pbConfirm(_INTL("{1} cannot legally be an egg. Make egg anyway?", pkmn.speciesName))) + pkmn.level = EGG_LEVEL + pkmn.calcStats + pkmn.name = _INTL("Egg") + pkmn.eggsteps = pkmn.species_data.hatch_steps + pkmn.hatchedMap = 0 + pkmn.obtainMode = 1 + screen.pbRefreshSingle(pkmnid) + end + when 1 # Make Pokémon + if pkmn.egg? + pkmn.name = pkmn.speciesName + pkmn.eggsteps = 0 + pkmn.hatchedMap = 0 + pkmn.obtainMode = 0 + screen.pbRefreshSingle(pkmnid) + end + when 2 # Set eggsteps to 1 + pkmn.eggsteps = 1 if pkmn.egg? + end + end + ) +}) + +PokemonDebugMenuCommands.register("shadowpkmn", { + "parent" => "main", + "name" => _INTL("Shadow Pkmn..."), + "always_show" => true, + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + cmd = 0 + loop do + msg = [_INTL("Not a Shadow Pokémon."), + _INTL("Heart gauge is {1} (stage {2}).", pkmn.heartgauge, pkmn.heartStage) + ][pkmn.shadowPokemon? ? 1 : 0] + cmd = screen.pbShowCommands(msg, [ + _INTL("Make Shadow"), + _INTL("Set heart gauge")], cmd) + break if cmd < 0 + case cmd + when 0 # Make Shadow + if !pkmn.shadowPokemon? + pkmn.makeShadow + screen.pbRefreshSingle(pkmnid) + else + screen.pbDisplay(_INTL("{1} is already a Shadow Pokémon.", pkmn.name)) + end + when 1 # Set heart gauge + if pkmn.shadowPokemon? + oldheart = pkmn.heartgauge + params = ChooseNumberParams.new + params.setRange(0, Pokemon::HEARTGAUGESIZE) + params.setDefaultValue(pkmn.heartgauge) + val = pbMessageChooseNumber( + _INTL("Set the heart gauge (max. {1}).", Pokemon::HEARTGAUGESIZE), + params) { screen.pbUpdate } + if val != oldheart + pkmn.adjustHeart(val - oldheart) + pbReadyToPurify(pkmn) + end + else + screen.pbDisplay(_INTL("{1} is not a Shadow Pokémon.", pkmn.name)) + end + end + end + ) +}) + +PokemonDebugMenuCommands.register("mysterygift", { + "parent" => "main", + "name" => _INTL("Mystery Gift"), + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + pbCreateMysteryGift(0, pkmn) + ) +}) + +PokemonDebugMenuCommands.register("duplicate", { + "parent" => "main", + "name" => _INTL("Duplicate"), + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + if screen.pbConfirm(_INTL("Are you sure you want to copy this Pokémon?")) + clonedpkmn = pkmn.clone + if screen.is_a?(PokemonPartyScreen) + pbStorePokemon(clonedpkmn) + screen.pbHardRefresh + screen.pbDisplay(_INTL("The Pokémon was duplicated.")) + elsif screen.is_a?(PokemonStorageScreen) + if screen.storage.pbMoveCaughtToParty(clonedpkmn) + if pkmnid[0] != -1 + screen.pbDisplay(_INTL("The duplicated Pokémon was moved to your party.")) + end + else + oldbox = screen.storage.currentBox + newbox = screen.storage.pbStoreCaught(clonedpkmn) + if newbox < 0 + screen.pbDisplay(_INTL("All boxes are full.")) + elsif newbox != oldbox + screen.pbDisplay(_INTL("The duplicated Pokémon was moved to box \"{1}.\"", screen.storage[newbox].name)) + screen.storage.currentBox = oldbox + end + end + screen.pbHardRefresh + end + next true + end + ) +}) + +PokemonDebugMenuCommands.register("delete", { + "parent" => "main", + "name" => _INTL("Delete"), + "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| + if screen.pbConfirm(_INTL("Are you sure you want to delete this Pokémon?")) + if screen.is_a?(PokemonPartyScreen) + screen.party[pkmnid] = nil + screen.party.compact! + screen.pbHardRefresh + elsif screen.is_a?(PokemonStorageScreen) + screen.scene.pbRelease(pkmnid, heldpoke) + (heldpoke) ? screen.heldpkmn = nil : screen.storage.pbDelete(pkmnid[0],pkmnid[1]) + screen.scene.pbRefresh + end + next true + end + ) +}) diff --git a/Data/Scripts/021_Debug/011_Editor_MapConnectionEditor.rb b/Data/Scripts/021_Debug/011_Editor_MapConnectionEditor.rb index 8c9570f31..70455d7ff 100644 --- a/Data/Scripts/021_Debug/011_Editor_MapConnectionEditor.rb +++ b/Data/Scripts/021_Debug/011_Editor_MapConnectionEditor.rb @@ -572,9 +572,9 @@ class MapScreenScene if Input.trigger?(Input::B) if pbConfirmMessage(_INTL("Save changes?")) serializeConnectionData + MapFactoryHelper.clear save_data(@encdata,"Data/encounters.dat") - # TODO: Only need to reload connections and encounter data. - pbClearData + $PokemonTemp.encountersData = nil pbSaveEncounterData end break if pbConfirmMessage(_INTL("Exit from the editor?")) diff --git a/Data/Scripts/021_Debug/012_Editor_SpritePosEditor.rb b/Data/Scripts/021_Debug/012_Editor_SpritePosEditor.rb index 8c1c89593..435a82a3a 100644 --- a/Data/Scripts/021_Debug/012_Editor_SpritePosEditor.rb +++ b/Data/Scripts/021_Debug/012_Editor_SpritePosEditor.rb @@ -159,7 +159,6 @@ class SpritePositioner frm = species_data.form @sprites["pokemon_0"].setSpeciesBitmap(spe, 0, frm, false, false, true) @sprites["pokemon_1"].setSpeciesBitmap(spe, 0, frm) - # TODO @sprites["shadow_1"].setBitmap(GameData::Species.shadow_filename(spe, frm)) end