From cc7ecf03267a8c0afa34621b99912a3d6859d8a3 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Fri, 20 May 2022 17:35:02 +0100 Subject: [PATCH 01/14] =?UTF-8?q?Fixed=20incorrect=20message=20when=20choo?= =?UTF-8?q?sing=20a=20Pok=C3=A9mon=20to=20withdraw=20from=20Day=20Care?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Data/Scripts/012_Overworld/007_Overworld_DayCare.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Data/Scripts/012_Overworld/007_Overworld_DayCare.rb b/Data/Scripts/012_Overworld/007_Overworld_DayCare.rb index 58b4dd7fb..a32cfc714 100644 --- a/Data/Scripts/012_Overworld/007_Overworld_DayCare.rb +++ b/Data/Scripts/012_Overworld/007_Overworld_DayCare.rb @@ -463,7 +463,7 @@ class DayCare day_care.reset_egg_counters end - def self.choose(text, choice_var) + def self.choose(message, choice_var) day_care = $PokemonGlobal.day_care case day_care.count when 0 @@ -474,13 +474,13 @@ class DayCare commands = [] indices = [] day_care.slots.each_with_index do |slot, i| - text = slot.choice_text - next if !text - commands.push(text) + choice_text = slot.choice_text + next if !choice_text + commands.push(choice_text) indices.push(i) end commands.push(_INTL("CANCEL")) - command = pbMessage(text, commands, commands.length) + command = pbMessage(message, commands, commands.length) $game_variables[choice_var] = (command == commands.length - 1) ? -1 : indices[command] end end From b344cb7fcc45a98ba45fd32fd815aacef1f248cc Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Fri, 20 May 2022 17:36:39 +0100 Subject: [PATCH 02/14] Fixed event evolutions not working --- Data/Scripts/014_Pokemon/001_Pokemon.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Data/Scripts/014_Pokemon/001_Pokemon.rb b/Data/Scripts/014_Pokemon/001_Pokemon.rb index 08b9a2da5..a2eb88e22 100644 --- a/Data/Scripts/014_Pokemon/001_Pokemon.rb +++ b/Data/Scripts/014_Pokemon/001_Pokemon.rb @@ -1009,7 +1009,7 @@ class Pokemon # @param value [Integer] a value that may be used by the evolution method # @return [Symbol, nil] the ID of the species to evolve into def check_evolution_by_event(value = 0) - return check_evolution_internal { |pkmn, new_species, method, parameter, value| + return check_evolution_internal { |pkmn, new_species, method, parameter| success = GameData::Evolution.get(method).call_event(pkmn, parameter, value) next (success) ? new_species : nil } From d28ccd13e14a60581cdcf9099ec6606aa8579796 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Fri, 20 May 2022 17:39:17 +0100 Subject: [PATCH 03/14] =?UTF-8?q?Fixed=20incorrect=20status=20condition=20?= =?UTF-8?q?icon=20used=20for=20fainted=20Pok=C3=A9mon=20and=20Pok=C3=A9mon?= =?UTF-8?q?=20with=20Pok=C3=A9rus?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Data/Scripts/016_UI/005_UI_Party.rb | 4 ++-- Data/Scripts/016_UI/006_UI_Summary.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Data/Scripts/016_UI/005_UI_Party.rb b/Data/Scripts/016_UI/005_UI_Party.rb index 89466a525..f5e59eeed 100644 --- a/Data/Scripts/016_UI/005_UI_Party.rb +++ b/Data/Scripts/016_UI/005_UI_Party.rb @@ -383,11 +383,11 @@ class PokemonPartyPanel < SpriteWrapper # Draw status status = -1 if @pokemon.fainted? - status = GameData::Status.count + status = GameData::Status.count - 1 elsif @pokemon.status != :NONE status = GameData::Status.get(@pokemon.status).icon_position elsif @pokemon.pokerusStage == 1 - status = GameData::Status.count + 1 + status = GameData::Status.count end if status >= 0 statusrect = Rect.new(0, 16 * status, 44, 16) diff --git a/Data/Scripts/016_UI/006_UI_Summary.rb b/Data/Scripts/016_UI/006_UI_Summary.rb index a9a55bf22..b6d957f68 100644 --- a/Data/Scripts/016_UI/006_UI_Summary.rb +++ b/Data/Scripts/016_UI/006_UI_Summary.rb @@ -314,11 +314,11 @@ class PokemonSummary_Scene # Show status/fainted/Pokérus infected icon status = -1 if @pokemon.fainted? - status = GameData::Status.count + status = GameData::Status.count - 1 elsif @pokemon.status != :NONE status = GameData::Status.get(@pokemon.status).icon_position elsif @pokemon.pokerusStage == 1 - status = GameData::Status.count + 1 + status = GameData::Status.count end if status >= 0 imagepos.push(["Graphics/Pictures/statuses", 124, 100, 0, 16 * status, 44, 16]) From 0ab1e6242d65d12235f098306a00c8e6b894db7f Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Fri, 20 May 2022 17:44:35 +0100 Subject: [PATCH 04/14] Added some more outdated script replacements to the Compiler --- Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb b/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb index 74c3d1972..f719b1205 100644 --- a/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb +++ b/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb @@ -31,7 +31,10 @@ module Compiler ["pbEggGenerated?", "DayCare.egg_generated?"], ["pbDayCareGenerateEgg", "DayCare.collect_egg"], ["get_character(0)", "get_self"], - ["get_character(-1)", "get_player"] + ["get_character(-1)", "get_player"], + ["pbCheckAble", "$player.has_other_able_pokemon?"], + ["$PokemonTemp.lastbattle", "$game_temp.last_battle_record"], + ["calcStats", "calc_stats"] ] module_function From d5e26d13f796e8f1e704560c4865fa105aa340f5 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Fri, 20 May 2022 17:45:03 +0100 Subject: [PATCH 05/14] Renamed VictoryME to VictoryBGM in trainer_types.txt --- PBS/trainer_types.txt | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/PBS/trainer_types.txt b/PBS/trainer_types.txt index d414097af..68e2e7280 100644 --- a/PBS/trainer_types.txt +++ b/PBS/trainer_types.txt @@ -314,88 +314,88 @@ Name = Gym Leader Gender = Male BaseMoney = 100 BattleBGM = Battle Gym Leader -VictoryME = Battle victory leader +VictoryBGM = Battle victory leader #------------------------------- [LEADER_Misty] Name = Gym Leader Gender = Female BaseMoney = 100 BattleBGM = Battle Gym Leader -VictoryME = Battle victory leader +VictoryBGM = Battle victory leader #------------------------------- [LEADER_Surge] Name = Gym Leader Gender = Male BaseMoney = 100 BattleBGM = Battle Gym Leader -VictoryME = Battle victory leader +VictoryBGM = Battle victory leader #------------------------------- [LEADER_Erika] Name = Gym Leader Gender = Female BaseMoney = 100 BattleBGM = Battle Gym Leader -VictoryME = Battle victory leader +VictoryBGM = Battle victory leader #------------------------------- [LEADER_Koga] Name = Gym Leader Gender = Male BaseMoney = 100 BattleBGM = Battle Gym Leader -VictoryME = Battle victory leader +VictoryBGM = Battle victory leader #------------------------------- [LEADER_Sabrina] Name = Gym Leader Gender = Female BaseMoney = 100 BattleBGM = Battle Gym Leader -VictoryME = Battle victory leader +VictoryBGM = Battle victory leader #------------------------------- [LEADER_Blaine] Name = Gym Leader Gender = Male BaseMoney = 100 BattleBGM = Battle Gym Leader -VictoryME = Battle victory leader +VictoryBGM = Battle victory leader #------------------------------- [LEADER_Giovanni] Name = Gym Leader Gender = Male BaseMoney = 100 BattleBGM = Battle Gym Leader -VictoryME = Battle victory leader +VictoryBGM = Battle victory leader #------------------------------- [ELITEFOUR_Lorelei] Name = Elite Four Gender = Female BaseMoney = 100 BattleBGM = Battle Elite -VictoryME = Battle victory leader +VictoryBGM = Battle victory leader #------------------------------- [ELITEFOUR_Bruno] Name = Elite Four Gender = Male BaseMoney = 100 BattleBGM = Battle Elite -VictoryME = Battle victory leader +VictoryBGM = Battle victory leader #------------------------------- [ELITEFOUR_Agatha] Name = Elite Four Gender = Female BaseMoney = 100 BattleBGM = Battle Elite -VictoryME = Battle victory leader +VictoryBGM = Battle victory leader #------------------------------- [ELITEFOUR_Lance] Name = Elite Four Gender = Male BaseMoney = 100 BattleBGM = Battle Elite -VictoryME = Battle victory leader +VictoryBGM = Battle victory leader #------------------------------- [CHAMPION] Name = Champion Gender = Male BaseMoney = 100 BattleBGM = Battle Champion -VictoryME = Battle victory leader +VictoryBGM = Battle victory leader From ce5d68a904dbc27ea81b095c2d624a732e4293d9 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Fri, 20 May 2022 19:11:12 +0100 Subject: [PATCH 06/14] =?UTF-8?q?Fixed=20incorrect=20Pok=C3=A9mon=20icons?= =?UTF-8?q?=20shown=20in=20Ready=20Menu=20if=20there=20are=20eggs=20in=20t?= =?UTF-8?q?he=20party?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Data/Scripts/016_UI/016_UI_ReadyMenu.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Data/Scripts/016_UI/016_UI_ReadyMenu.rb b/Data/Scripts/016_UI/016_UI_ReadyMenu.rb index cc878efce..3c3ad1918 100644 --- a/Data/Scripts/016_UI/016_UI_ReadyMenu.rb +++ b/Data/Scripts/016_UI/016_UI_ReadyMenu.rb @@ -305,8 +305,8 @@ def pbUseKeyItem :WATERFALL, :WHIRLPOOL] real_moves = [] moves.each do |move| - $player.pokemon_party.each_with_index do |pkmn, i| - next if !pkmn.hasMove?(move) + $player.party.each_with_index do |pkmn, i| + next if pkmn.egg? || !pkmn.hasMove?(move) real_moves.push([move, i]) if pbCanUseHiddenMove?(pkmn, move, false) end end From 38d551f72bbc3d5496000ab1f546cb320e2c6604 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Fri, 20 May 2022 20:22:47 +0100 Subject: [PATCH 07/14] =?UTF-8?q?Fixed=20not=20registering=20a=20gifted=20?= =?UTF-8?q?Pok=C3=A9mon=20as=20seen/owned=20before=20looking=20at=20its=20?= =?UTF-8?q?Pok=C3=A9dex=20entry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Data/Scripts/019_Utilities/002_Utilities_Pokemon.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Data/Scripts/019_Utilities/002_Utilities_Pokemon.rb b/Data/Scripts/019_Utilities/002_Utilities_Pokemon.rb index e67702065..1a1a90b55 100644 --- a/Data/Scripts/019_Utilities/002_Utilities_Pokemon.rb +++ b/Data/Scripts/019_Utilities/002_Utilities_Pokemon.rb @@ -56,6 +56,8 @@ def pbAddPokemon(pkmn, level = 1, see_form = true) species_name = pkmn.speciesName pbMessage(_INTL("{1} obtained {2}!\\me[Pkmn get]\\wtnp[80]\1", $player.name, species_name)) was_owned = $player.owned?(pkmn.species) + $player.pokedex.set_seen(pkmn.species) + $player.pokedex.set_owned(pkmn.species) $player.pokedex.register(pkmn) if see_form # Show Pokédex entry for new species if it hasn't been owned before if Settings::SHOW_NEW_SPECIES_POKEDEX_ENTRY_MORE_OFTEN && !was_owned && $player.has_pokedex @@ -75,8 +77,9 @@ end def pbAddPokemonSilent(pkmn, level = 1, see_form = true) return false if !pkmn || pbBoxesFull? pkmn = Pokemon.new(pkmn, level) if !pkmn.is_a?(Pokemon) - $player.pokedex.register(pkmn) if see_form + $player.pokedex.set_seen(pkmn.species) $player.pokedex.set_owned(pkmn.species) + $player.pokedex.register(pkmn) if see_form pkmn.record_first_moves if $player.party_full? $PokemonStorage.pbStoreCaught(pkmn) @@ -95,6 +98,8 @@ def pbAddToParty(pkmn, level = 1, see_form = true) species_name = pkmn.speciesName pbMessage(_INTL("{1} obtained {2}!\\me[Pkmn get]\\wtnp[80]\1", $player.name, species_name)) was_owned = $player.owned?(pkmn.species) + $player.pokedex.set_seen(pkmn.species) + $player.pokedex.set_owned(pkmn.species) $player.pokedex.register(pkmn) if see_form # Show Pokédex entry for new species if it hasn't been owned before if Settings::SHOW_NEW_SPECIES_POKEDEX_ENTRY_MORE_OFTEN && !was_owned && $player.has_pokedex @@ -133,8 +138,9 @@ def pbAddForeignPokemon(pkmn, level = 1, owner_name = nil, nickname = nil, owner pbMessage(_INTL("\\me[Pkmn get]{1} received a Pokémon.\1", $player.name)) end was_owned = $player.owned?(pkmn.species) - $player.pokedex.register(pkmn) if see_form + $player.pokedex.set_seen(pkmn.species) $player.pokedex.set_owned(pkmn.species) + $player.pokedex.register(pkmn) if see_form # Show Pokédex entry for new species if it hasn't been owned before if Settings::SHOW_NEW_SPECIES_POKEDEX_ENTRY_MORE_OFTEN && !was_owned && $player.has_pokedex pbMessage(_INTL("The Pokémon's data was added to the Pokédex.")) From 98aeff01c5c5dfc3fe09cb917cc8eb867a6d8e7c Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Fri, 20 May 2022 20:32:16 +0100 Subject: [PATCH 08/14] =?UTF-8?q?Pok=C3=A9dex=20entry=20won't=20appear=20f?= =?UTF-8?q?or=20gifted=20Pok=C3=A9mon=20if=20you=20don't=20want=20to=20rec?= =?UTF-8?q?ord=20its=20form=20in=20the=20Pok=C3=A9dex?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Data/Scripts/019_Utilities/002_Utilities_Pokemon.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Data/Scripts/019_Utilities/002_Utilities_Pokemon.rb b/Data/Scripts/019_Utilities/002_Utilities_Pokemon.rb index 1a1a90b55..9bbc595b8 100644 --- a/Data/Scripts/019_Utilities/002_Utilities_Pokemon.rb +++ b/Data/Scripts/019_Utilities/002_Utilities_Pokemon.rb @@ -60,7 +60,7 @@ def pbAddPokemon(pkmn, level = 1, see_form = true) $player.pokedex.set_owned(pkmn.species) $player.pokedex.register(pkmn) if see_form # Show Pokédex entry for new species if it hasn't been owned before - if Settings::SHOW_NEW_SPECIES_POKEDEX_ENTRY_MORE_OFTEN && !was_owned && $player.has_pokedex + if Settings::SHOW_NEW_SPECIES_POKEDEX_ENTRY_MORE_OFTEN && see_form && !was_owned && $player.has_pokedex pbMessage(_INTL("{1}'s data was added to the Pokédex.", species_name)) $player.pokedex.register_last_seen(pkmn) pbFadeOutIn { @@ -102,7 +102,7 @@ def pbAddToParty(pkmn, level = 1, see_form = true) $player.pokedex.set_owned(pkmn.species) $player.pokedex.register(pkmn) if see_form # Show Pokédex entry for new species if it hasn't been owned before - if Settings::SHOW_NEW_SPECIES_POKEDEX_ENTRY_MORE_OFTEN && !was_owned && $player.has_pokedex + if Settings::SHOW_NEW_SPECIES_POKEDEX_ENTRY_MORE_OFTEN && see_form && !was_owned && $player.has_pokedex pbMessage(_INTL("{1}'s data was added to the Pokédex.", species_name)) $player.pokedex.register_last_seen(pkmn) pbFadeOutIn { @@ -142,7 +142,7 @@ def pbAddForeignPokemon(pkmn, level = 1, owner_name = nil, nickname = nil, owner $player.pokedex.set_owned(pkmn.species) $player.pokedex.register(pkmn) if see_form # Show Pokédex entry for new species if it hasn't been owned before - if Settings::SHOW_NEW_SPECIES_POKEDEX_ENTRY_MORE_OFTEN && !was_owned && $player.has_pokedex + if Settings::SHOW_NEW_SPECIES_POKEDEX_ENTRY_MORE_OFTEN && see_form && !was_owned && $player.has_pokedex pbMessage(_INTL("The Pokémon's data was added to the Pokédex.")) $player.pokedex.register_last_seen(pkmn) pbFadeOutIn { From a280fea09316daa7abf8fd11ab96186f2696d2b4 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Sat, 21 May 2022 19:20:35 +0100 Subject: [PATCH 09/14] Fixed console message colouring breaking when loading a plugin whose name contains an apostrophe --- Data/Scripts/001_Technical/001_Debugging/002_DebugConsole.rb | 2 +- Data/Scripts/001_Technical/005_PluginManager.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Data/Scripts/001_Technical/001_Debugging/002_DebugConsole.rb b/Data/Scripts/001_Technical/001_Debugging/002_DebugConsole.rb index 775afb84c..45884ec35 100644 --- a/Data/Scripts/001_Technical/001_Debugging/002_DebugConsole.rb +++ b/Data/Scripts/001_Technical/001_Debugging/002_DebugConsole.rb @@ -152,7 +152,7 @@ module Console # Text markup that turns text between them a certain color def markup_colors { - "`" => :cyan, '"' => :purple, "'" => :purple, "$" => :green, "~" => :red + "`" => :cyan, '"' => :purple, "==" => :purple, "$" => :green, "~" => :red } end diff --git a/Data/Scripts/001_Technical/005_PluginManager.rb b/Data/Scripts/001_Technical/005_PluginManager.rb index 234d0886a..2c2a56578 100644 --- a/Data/Scripts/001_Technical/005_PluginManager.rb +++ b/Data/Scripts/001_Technical/005_PluginManager.rb @@ -651,7 +651,7 @@ module PluginManager # try to run the code begin eval(code, TOPLEVEL_BINDING, fname) - Console.echoln_li "Loaded plugin: '#{name}' (ver. #{meta[:version]})" if !echoed_plugins.include?(name) + Console.echoln_li "Loaded plugin: ==#{name}== (ver. #{meta[:version]})" if !echoed_plugins.include?(name) echoed_plugins.push(name) rescue Exception # format error message to display self.pluginErrorMsg(name, sname) From 41479fac04f8d2cca6156e7a87401263f356b99a Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Mon, 23 May 2022 23:29:23 +0100 Subject: [PATCH 10/14] Fixed the player animating super-fast for a while after surfing --- Data/Scripts/004_Game classes/009_Game_Player.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/Data/Scripts/004_Game classes/009_Game_Player.rb b/Data/Scripts/004_Game classes/009_Game_Player.rb index 9bceb6e22..227cdc528 100644 --- a/Data/Scripts/004_Game classes/009_Game_Player.rb +++ b/Data/Scripts/004_Game classes/009_Game_Player.rb @@ -517,6 +517,7 @@ class Game_Player < Game_Character @pattern = p if !@lock_pattern @pattern_surf = p @bob_height = (p >= 2) ? 2 : 0 + @anime_count = 0 else @bob_height = 0 super From d94d1836c6f039711910f9fed5f95ae65733b5db Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Tue, 24 May 2022 13:43:01 +0100 Subject: [PATCH 11/14] Fixed Howl always failing --- .../Scripts/011_Battle/003_Move/006_MoveEffects_BattlerStats.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Data/Scripts/011_Battle/003_Move/006_MoveEffects_BattlerStats.rb b/Data/Scripts/011_Battle/003_Move/006_MoveEffects_BattlerStats.rb index b9f937319..25696bcb9 100644 --- a/Data/Scripts/011_Battle/003_Move/006_MoveEffects_BattlerStats.rb +++ b/Data/Scripts/011_Battle/003_Move/006_MoveEffects_BattlerStats.rb @@ -741,7 +741,7 @@ class Battle::Move::RaiseTargetAttack1 < Battle::Move return false if damagingMove? failed = true targets.each do |b| - next if b.pbCanRaiseStatStage?(:ATTACK, user, self) + next if !b.pbCanRaiseStatStage?(:ATTACK, user, self) failed = false break end From eab69f213ab2656fa78405c0253ffcbf6f36fb13 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Tue, 24 May 2022 13:44:12 +0100 Subject: [PATCH 12/14] Fixed error when using Rotom Catalog --- Data/Scripts/013_Items/002_Item_Effects.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Data/Scripts/013_Items/002_Item_Effects.rb b/Data/Scripts/013_Items/002_Item_Effects.rb index 94635e7d2..76989c02e 100644 --- a/Data/Scripts/013_Items/002_Item_Effects.rb +++ b/Data/Scripts/013_Items/002_Item_Effects.rb @@ -1210,7 +1210,7 @@ ItemHandlers::UseOnPokemon.add(:ROTOMCATALOG, proc { |item, qty, pkmn, scene| _INTL("Cancel") ] new_form = scene.pbShowCommands(_INTL("Which appliance would you like to order?"), - commands, pkmn.form) + choices, pkmn.form) if new_form == pkmn.form scene.pbDisplay(_INTL("It won't have any effect.")) next false From ebf83649ec3261f27e16ddf759b9d409ad466112 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Tue, 24 May 2022 18:56:33 +0100 Subject: [PATCH 13/14] Fixed error when the Compiler tries to convert some pbTrainerBattle code to TrainerBattle.start --- .../004_Compiler_MapsAndEvents.rb | 140 ++++++++++-------- 1 file changed, 80 insertions(+), 60 deletions(-) diff --git a/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb b/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb index f719b1205..68dd87263 100644 --- a/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb +++ b/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb @@ -908,12 +908,33 @@ module Compiler return ret end + # Splits the given code string into an array of parameters (all strings), + # using "," as the delimiter. It will not split in the middle of a string + # parameter. Used to extract parameters from a script call in an event. + def split_string_with_quotes(str) + ret = [] + new_str = "" + in_msg = false + str.scan(/./) do |s| + if s == "," && !in_msg + ret.push(new_str.strip) + new_str = "" + else + in_msg = !in_msg if s == "\"" + new_str += s + end + end + new_str.strip! + ret.push(new_str) if !new_str.empty? + return ret + end + def replace_old_battle_scripts(event, list, index) changed = false script = list[index].parameters[1] if script[/^\s*pbWildBattle\((.+)\)\s*$/] - battle_params = $1.split(",") - list[index].parameters[1] = sprintf("WildBattle.start(#{battle_params[0].strip}, #{battle_params[1].strip})") + battle_params = split_string_with_quotes($1) # Split on commas + list[index].parameters[1] = sprintf("WildBattle.start(#{battle_params[0]}, #{battle_params[1]})") old_indent = list[index].indent new_events = [] if battle_params[3] && battle_params[3][/false/] @@ -922,15 +943,15 @@ module Compiler if battle_params[4] && battle_params[4][/true/] push_script(new_events, "setBattleRule(\"canLose\")", old_indent) end - if battle_params[2] && battle_params[2].strip != "1" - push_script(new_events, "setBattleRule(\"outcome\", #{battle_params[2].strip})", old_indent) + if battle_params[2] && battle_params[2] != "1" + push_script(new_events, "setBattleRule(\"outcome\", #{battle_params[2]})", old_indent) end list[index, 0] = new_events if new_events.length > 0 changed = true elsif script[/^\s*pbDoubleWildBattle\((.+)\)\s*$/] - battle_params = $1.split(",") - pkmn1 = "#{battle_params[0].strip}, #{battle_params[1].strip}" - pkmn2 = "#{battle_params[2].strip}, #{battle_params[3].strip}" + battle_params = split_string_with_quotes($1) # Split on commas + pkmn1 = "#{battle_params[0]}, #{battle_params[1]}" + pkmn2 = "#{battle_params[2]}, #{battle_params[3]}" list[index].parameters[1] = sprintf("WildBattle.start(#{pkmn1}, #{pkmn2})") old_indent = list[index].indent new_events = [] @@ -940,16 +961,16 @@ module Compiler if battle_params[4] && battle_params[6][/true/] push_script(new_events, "setBattleRule(\"canLose\")", old_indent) end - if battle_params[2] && battle_params[4].strip != "1" - push_script(new_events, "setBattleRule(\"outcome\", #{battle_params[4].strip})", old_indent) + if battle_params[2] && battle_params[4] != "1" + push_script(new_events, "setBattleRule(\"outcome\", #{battle_params[4]})", old_indent) end list[index, 0] = new_events if new_events.length > 0 changed = true elsif script[/^\s*pbTripleWildBattle\((.+)\)\s*$/] - battle_params = $1.split(",") - pkmn1 = "#{battle_params[0].strip}, #{battle_params[1].strip}" - pkmn2 = "#{battle_params[2].strip}, #{battle_params[3].strip}" - pkmn3 = "#{battle_params[4].strip}, #{battle_params[5].strip}" + battle_params = split_string_with_quotes($1) # Split on commas + pkmn1 = "#{battle_params[0]}, #{battle_params[1]}" + pkmn2 = "#{battle_params[2]}, #{battle_params[3]}" + pkmn3 = "#{battle_params[4]}, #{battle_params[5]}" list[index].parameters[1] = sprintf("WildBattle.start(#{pkmn1}, #{pkmn2}, #{pkmn3})") old_indent = list[index].indent new_events = [] @@ -959,22 +980,26 @@ module Compiler if battle_params[4] && battle_params[8][/true/] push_script(new_events, "setBattleRule(\"canLose\")", old_indent) end - if battle_params[2] && battle_params[6].strip != "1" - push_script(new_events, "setBattleRule(\"outcome\", #{battle_params[6].strip})", old_indent) + if battle_params[2] && battle_params[6] != "1" + push_script(new_events, "setBattleRule(\"outcome\", #{battle_params[6]})", old_indent) end list[index, 0] = new_events if new_events.length > 0 changed = true elsif script[/^\s*pbTrainerBattle\((.+)\)\s*$/] - battle_params = $1.split(",") - trainer1 = "#{battle_params[0].strip}, #{battle_params[1].strip}" - trainer1 += ", #{battle_params[4].strip}" if battle_params[4] && battle_params[4].strip != "nil" + echoln "" + echoln $1 + battle_params = split_string_with_quotes($1) # Split on commas + echoln battle_params + trainer1 = "#{battle_params[0]}, #{battle_params[1]}" + trainer1 += ", #{battle_params[4]}" if battle_params[4] && battle_params[4] != "nil" list[index].parameters[1] = "TrainerBattle.start(#{trainer1})" old_indent = list[index].indent new_events = [] - if battle_params[2] && !battle_params[2].strip.empty? && battle_params[2].strip != "nil" - speech = battle_params[2].gsub(/^\s*_I\(\s*"\s*/, "") - speech.gsub!(/\"\s*\)\s*$/, "").strip - push_comment(new_events, "EndSpeech: #{speech}", old_indent) + if battle_params[2] && !battle_params[2].empty? && battle_params[2] != "nil" + echoln battle_params[2] + speech = battle_params[2].gsub(/^\s*_I\(\s*"\s*/, "").gsub(/\"\s*\)\s*$/, "") + echoln speech + push_comment(new_events, "EndSpeech: #{speech.strip}", old_indent) end if battle_params[3] && battle_params[3][/true/] push_script(new_events, "setBattleRule(\"double\")", old_indent) @@ -982,69 +1007,64 @@ module Compiler if battle_params[5] && battle_params[5][/true/] push_script(new_events, "setBattleRule(\"canLose\")", old_indent) end - if battle_params[6] && battle_params[6].strip != "1" - push_script(new_events, "setBattleRule(\"outcome\", #{battle_params[6].strip})", old_indent) + if battle_params[6] && battle_params[6] != "1" + push_script(new_events, "setBattleRule(\"outcome\", #{battle_params[6]})", old_indent) end list[index, 0] = new_events if new_events.length > 0 changed = true elsif script[/^\s*pbDoubleTrainerBattle\((.+)\)\s*$/] - battle_params = $1.split(",") - trainer1 = "#{battle_params[0].strip}, #{battle_params[1].strip}" - trainer1 += ", #{battle_params[2].strip}" if battle_params[2] && battle_params[2].strip != "nil" - trainer2 = "#{battle_params[4].strip}, #{battle_params[5].strip}" - trainer2 += ", #{battle_params[6].strip}" if battle_params[6] && battle_params[6].strip != "nil" + battle_params = split_string_with_quotes($1) # Split on commas + trainer1 = "#{battle_params[0]}, #{battle_params[1]}" + trainer1 += ", #{battle_params[2]}" if battle_params[2] && battle_params[2] != "nil" + trainer2 = "#{battle_params[4]}, #{battle_params[5]}" + trainer2 += ", #{battle_params[6]}" if battle_params[6] && battle_params[6] != "nil" list[index].parameters[1] = "TrainerBattle.start(#{trainer1}, #{trainer2})" old_indent = list[index].indent new_events = [] - if battle_params[3] && !battle_params[3].strip.empty? && battle_params[3].strip != "nil" - speech = battle_params[3].gsub(/^\s*_I\(\s*"\s*/, "") - speech.gsub!(/\"\s*\)\s*$/, "").strip - push_comment(new_events, "EndSpeech1: #{speech}", old_indent) + if battle_params[3] && !battle_params[3].empty? && battle_params[3] != "nil" + speech = battle_params[3].gsub(/^\s*_I\(\s*"\s*/, "").gsub(/\"\s*\)\s*$/, "") + push_comment(new_events, "EndSpeech1: #{speech.strip}", old_indent) end - if battle_params[7] && !battle_params[7].strip.empty? && battle_params[7].strip != "nil" - speech = battle_params[7].gsub(/^\s*_I\(\s*"\s*/, "") - speech.gsub!(/\"\s*\)\s*$/, "").strip - push_comment(new_events, "EndSpeech2: #{speech}", old_indent) + if battle_params[7] && !battle_params[7].empty? && battle_params[7] != "nil" + speech = battle_params[7].gsub(/^\s*_I\(\s*"\s*/, "").gsub(/\"\s*\)\s*$/, "") + push_comment(new_events, "EndSpeech2: #{speech.strip}", old_indent) end if battle_params[8] && battle_params[8][/true/] push_script(new_events, "setBattleRule(\"canLose\")", old_indent) end - if battle_params[9] && battle_params[9].strip != "1" - push_script(new_events, "setBattleRule(\"outcome\", #{battle_params[9].strip})", old_indent) + if battle_params[9] && battle_params[9] != "1" + push_script(new_events, "setBattleRule(\"outcome\", #{battle_params[9]})", old_indent) end list[index, 0] = new_events if new_events.length > 0 changed = true elsif script[/^\s*pbTripleTrainerBattle\((.+)\)\s*$/] - battle_params = $1.split(",") - trainer1 = "#{battle_params[0].strip}, #{battle_params[1].strip}" - trainer1 += ", #{battle_params[2].strip}" if battle_params[2] && battle_params[2].strip != "nil" - trainer2 = "#{battle_params[4].strip}, #{battle_params[5].strip}" - trainer2 += ", #{battle_params[6].strip}" if battle_params[6] && battle_params[6].strip != "nil" - trainer3 = "#{battle_params[8].strip}, #{battle_params[9].strip}" - trainer3 += ", #{battle_params[10].strip}" if battle_params[10] && battle_params[10].strip != "nil" + battle_params = split_string_with_quotes($1) # Split on commas + trainer1 = "#{battle_params[0]}, #{battle_params[1]}" + trainer1 += ", #{battle_params[2]}" if battle_params[2] && battle_params[2] != "nil" + trainer2 = "#{battle_params[4]}, #{battle_params[5]}" + trainer2 += ", #{battle_params[6]}" if battle_params[6] && battle_params[6] != "nil" + trainer3 = "#{battle_params[8]}, #{battle_params[9]}" + trainer3 += ", #{battle_params[10]}" if battle_params[10] && battle_params[10] != "nil" list[index].parameters[1] = "TrainerBattle.start(#{trainer1}, #{trainer2}, #{trainer3})" old_indent = list[index].indent new_events = [] - if battle_params[3] && !battle_params[3].strip.empty? && battle_params[3].strip != "nil" - speech = battle_params[3].gsub(/^\s*_I\(\s*"\s*/, "") - speech.gsub!(/\"\s*\)\s*$/, "").strip - push_comment(new_events, "EndSpeech1: #{speech}", old_indent) + if battle_params[3] && !battle_params[3].empty? && battle_params[3] != "nil" + speech = battle_params[3].gsub(/^\s*_I\(\s*"\s*/, "").gsub(/\"\s*\)\s*$/, "") + push_comment(new_events, "EndSpeech1: #{speech.strip}", old_indent) end - if battle_params[7] && !battle_params[7].strip.empty? && battle_params[7].strip != "nil" - speech = battle_params[7].gsub(/^\s*_I\(\s*"\s*/, "") - speech.gsub!(/\"\s*\)\s*$/, "").strip - push_comment(new_events, "EndSpeech2: #{speech}", old_indent) + if battle_params[7] && !battle_params[7].empty? && battle_params[7] != "nil" + speech = battle_params[7].gsub(/^\s*_I\(\s*"\s*/, "").gsub(/\"\s*\)\s*$/, "") + push_comment(new_events, "EndSpeech2: #{speech.strip}", old_indent) end - if battle_params[7] && !battle_params[7].strip.empty? && battle_params[11].strip != "nil" - speech = battle_params[11].gsub(/^\s*_I\(\s*"\s*/, "") - speech.gsub!(/\"\s*\)\s*$/, "").strip - push_comment(new_events, "EndSpeech3: #{speech}", old_indent) + if battle_params[7] && !battle_params[7].empty? && battle_params[11] != "nil" + speech = battle_params[11].gsub(/^\s*_I\(\s*"\s*/, "").gsub(/\"\s*\)\s*$/, "") + push_comment(new_events, "EndSpeech3: #{speech.strip}", old_indent) end if battle_params[12] && battle_params[12][/true/] push_script(new_events, "setBattleRule(\"canLose\")", old_indent) end - if battle_params[13] && battle_params[13].strip != "1" - push_script(new_events, "setBattleRule(\"outcome\", #{battle_params[13].strip})", old_indent) + if battle_params[13] && battle_params[13] != "1" + push_script(new_events, "setBattleRule(\"outcome\", #{battle_params[13]})", old_indent) end list[index, 0] = new_events if new_events.length > 0 changed = true From 0d567db2cd3e3b543229db691d7966b543ceb0c4 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Tue, 24 May 2022 19:07:22 +0100 Subject: [PATCH 14/14] Updated README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index de285f6de..63ec72ee9 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ -# Pokémon Essentials +# Pokémon Essentials -Based on Essentials v19. +Based on Essentials v20. You can build your fangame on top of a fork of this repository. Doing so will let you update your fangame with improvements made to this repo as soon as they are made. ## Usage 1. Fork this repo. -2. Get a copy of Essentials v19 (a download link cannot be provided here). -3. Clone your forked repo into the Essentials v19 folder, replacing the existing files with the ones from the repo. +2. Get a copy of Essentials v20 (a download link cannot be provided here). +3. Clone your forked repo into the Essentials v20 folder, replacing the existing files with the ones from the repo. From here, you can edit this project to turn it into your fangame/develop mods. When this repo is updated, you can pull the changes to update your fork and get the updates into your fangame/modding environment.