From 241851a75b4c17e0409155c23dd1fa03822ddccb Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Sat, 11 Dec 2021 13:25:23 +0000 Subject: [PATCH] =?UTF-8?q?Fixed=20crash=20when=20using=20upgradeRibbon,?= =?UTF-8?q?=20fixed=20crash=20when=20trading=20Pok=C3=A9mon,=20fixed=20cra?= =?UTF-8?q?sh=20when=20trying=20to=20play=20Triple=20Triad,=20fixed=20cras?= =?UTF-8?q?h=20when=20generating=20Battle=20Frontier=20data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Data/Scripts/014_Pokemon/001_Pokemon.rb | 12 ++++++------ .../016_UI/001_Non-interactive UI/005_UI_Trading.rb | 11 +++++------ .../017_Minigames/002_Minigame_TripleTriad.rb | 4 ++-- .../001_ChallengeGenerator_Data.rb | 6 +++--- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/Data/Scripts/014_Pokemon/001_Pokemon.rb b/Data/Scripts/014_Pokemon/001_Pokemon.rb index 90bfa25a5..280a75c8e 100644 --- a/Data/Scripts/014_Pokemon/001_Pokemon.rb +++ b/Data/Scripts/014_Pokemon/001_Pokemon.rb @@ -740,20 +740,20 @@ class Pokemon # Replaces one ribbon with the next one along, if possible. If none of the # given ribbons are owned, give the first one. # @return [Symbol, String, GameData::Ribbon] ID of the ribbon that was gained - def upgradeRibbon(*arg) - for i in 0...arg.length - 1 - this_ribbon_data = GameData::Ribbon.try_get(i) + def upgradeRibbon(*args) + args.each_with_index do |ribbon, i| + this_ribbon_data = GameData::Ribbon.try_get(ribbon) next if !this_ribbon_data for j in 0...@ribbons.length next if @ribbons[j] != this_ribbon_data.id - next_ribbon_data = GameData::Ribbon.try_get(arg[i + 1]) + next_ribbon_data = GameData::Ribbon.try_get(args[i + 1]) next if !next_ribbon_data @ribbons[j] = next_ribbon_data.id return @ribbons[j] end end - first_ribbon_data = GameData::Ribbon.try_get(arg[0]) - last_ribbon_data = GameData::Ribbon.try_get(arg[arg.length - 1]) + first_ribbon_data = GameData::Ribbon.try_get(args.first) + last_ribbon_data = GameData::Ribbon.try_get(args.last) if first_ribbon_data && last_ribbon_data && !hasRibbon?(last_ribbon_data.id) giveRibbon(first_ribbon_data.id) return first_ribbon_data.id diff --git a/Data/Scripts/016_UI/001_Non-interactive UI/005_UI_Trading.rb b/Data/Scripts/016_UI/001_Non-interactive UI/005_UI_Trading.rb index 3f49c5c73..1f3d2e870 100644 --- a/Data/Scripts/016_UI/001_Non-interactive UI/005_UI_Trading.rb +++ b/Data/Scripts/016_UI/001_Non-interactive UI/005_UI_Trading.rb @@ -200,18 +200,17 @@ end def pbStartTrade(pokemonIndex,newpoke,nickname,trainerName,trainerGender=0) $stats.trade_count += 1 myPokemon = $player.party[pokemonIndex] - opponent = NPCTrainer.new(trainerName,trainerGender) - opponent.id = $player.make_foreign_ID yourPokemon = nil resetmoves = true if newpoke.is_a?(Pokemon) - newpoke.owner = Pokemon::Owner.new_from_trainer(opponent) + newpoke.owner = Pokemon::Owner.new_foreign(trainerName, trainerGender) yourPokemon = newpoke resetmoves = false else species_data = GameData::Species.try_get(newpoke) - raise _INTL("Species does not exist ({1}).", newpoke) if !species_data - yourPokemon = Pokemon.new(species_data.id, myPokemon.level, opponent) + raise _INTL("Species {1} does not exist.", newpoke) if !species_data + yourPokemon = Pokemon.new(species_data.id, myPokemon.level) + yourPokemon.owner = Pokemon::Owner.new_foreign(trainerName, trainerGender) end yourPokemon.name = nickname yourPokemon.obtain_method = 2 # traded @@ -221,7 +220,7 @@ def pbStartTrade(pokemonIndex,newpoke,nickname,trainerName,trainerGender=0) $player.pokedex.set_owned(yourPokemon.species) pbFadeOutInWithMusic { evo = PokemonTrade_Scene.new - evo.pbStartScreen(myPokemon, yourPokemon, $player.name, opponent.name) + evo.pbStartScreen(myPokemon, yourPokemon, $player.name, trainerName) evo.pbTrade evo.pbEndScreen } diff --git a/Data/Scripts/017_Minigames/002_Minigame_TripleTriad.rb b/Data/Scripts/017_Minigames/002_Minigame_TripleTriad.rb index d6c430b50..e2cdfac2d 100644 --- a/Data/Scripts/017_Minigames/002_Minigame_TripleTriad.rb +++ b/Data/Scripts/017_Minigames/002_Minigame_TripleTriad.rb @@ -730,7 +730,7 @@ class TriadScreen square = TriadSquare.new if @elements loop do - trial_type = type_keys[type_keys.sample] + trial_type = type_keys.sample type_data = GameData::Type.get(trial_type) next if type_data.pseudo_type square.type = type_data.id @@ -774,7 +774,7 @@ class TriadScreen species_keys = GameData::Species.keys candidates = [] while candidates.length < 200 - card = species_keys[species_keys.sample] + card = species_keys.sample card_data = GameData::Species.get(card) card = card_data.id # Make sure it's a symbol triad = TriadCard.new(card) diff --git a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/001_ChallengeGenerator_Data.rb b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/001_ChallengeGenerator_Data.rb index 579738de4..901edae3f 100644 --- a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/001_ChallengeGenerator_Data.rb +++ b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/001_ChallengeGenerator_Data.rb @@ -132,10 +132,10 @@ def isBattlePokemonDuplicate(pk, pk2) moves1.push((pk.moves[i]) ? pk.moves[i].id : nil) moves2.push((pk2.moves[i]) ? pk2.moves[i].id : nil) end - moves1.sort! - moves2.sort! + moves1.compact.sort + moves2.compact.sort # Accept as same if moves are same and there are MAX_MOVES number of moves each - return true if moves1 == moves2 && moves1[Pokemon::MAX_MOVES - 1] + return true if moves1 == moves2 && moves1.length == Pokemon::MAX_MOVES same_evs = true GameData::Stat.each_main { |s| same_evs = false if pk.ev[s.id] != pk2.ev[s.id] } return pk.item_id == pk2.item_id && pk.nature_id == pk2.nature_id && same_evs