diff --git a/Data/Scripts/001_Technical/005_PluginManager.rb b/Data/Scripts/001_Technical/005_PluginManager.rb index b5663c25c..04c942b79 100644 --- a/Data/Scripts/001_Technical/005_PluginManager.rb +++ b/Data/Scripts/001_Technical/005_PluginManager.rb @@ -356,7 +356,7 @@ module PluginManager Graphics.update t = Thread.new do Console.echo_error "Plugin Error:\r\n#{msg}" - p "Plugin Error: #{msg}" + print("Plugin Error:\r\n#{msg}") Thread.exit end while t.status diff --git a/Data/Scripts/011_Battle/001_Battle/001_Battle.rb b/Data/Scripts/011_Battle/001_Battle/001_Battle.rb index 4330e67fb..bd48e3ada 100644 --- a/Data/Scripts/011_Battle/001_Battle/001_Battle.rb +++ b/Data/Scripts/011_Battle/001_Battle/001_Battle.rb @@ -54,6 +54,7 @@ class Battle attr_reader :player # Player trainer (or array of trainers) attr_reader :opponent # Opponent trainer (or array of trainers) attr_accessor :items # Items held by opponents + attr_accessor :ally_items # Items held by allies attr_accessor :endSpeeches attr_accessor :endSpeechesWin attr_accessor :party1starts # Array of start indexes for each player-side trainer's party @@ -119,6 +120,7 @@ class Battle @player = player # Array of Player/NPCTrainer objects, or nil @opponent = opponent # Array of NPCTrainer objects, or nil @items = nil + @ally_items = nil # Array of items held by ally. This is just used for Mega Evolution for now. @endSpeeches = [] @endSpeechesWin = [] @party1 = p1 @@ -167,6 +169,8 @@ class Battle else @struggle = Move::Struggle.new(self, nil) end + @mega_rings = [] + GameData::Item.each { |item| @mega_rings.push(item.id) if item.has_flag?("MegaRing") } end #============================================================================= @@ -259,8 +263,14 @@ class Battle end def pbGetOwnerItems(idxBattler) - return [] if !@items || !opposes?(idxBattler) - return @items[pbGetOwnerIndexFromBattlerIndex(idxBattler)] + if opposes?(idxBattler) + return [] if !@items + return @items[pbGetOwnerIndexFromBattlerIndex(idxBattler)] + else + return [] if !@ally_items + return @ally_items[pbGetOwnerIndexFromBattlerIndex(idxBattler)] + end + return [] end # Returns whether the battler in position idxBattler is owned by the same diff --git a/Data/Scripts/011_Battle/001_Battle/008_Battle_ActionOther.rb b/Data/Scripts/011_Battle/001_Battle/008_Battle_ActionOther.rb index 0474a84e6..390d0c798 100644 --- a/Data/Scripts/011_Battle/001_Battle/008_Battle_ActionOther.rb +++ b/Data/Scripts/011_Battle/001_Battle/008_Battle_ActionOther.rb @@ -62,21 +62,25 @@ class Battle # Choosing to Mega Evolve a battler #============================================================================= def pbHasMegaRing?(idxBattler) - return true if !pbOwnedByPlayer?(idxBattler) # Assume AI trainer have a ring - Settings::MEGA_RINGS.each { |item| return true if $bag.has?(item) } + if pbOwnedByPlayer?(idxBattler) + @mega_rings.each { |item| return true if $bag.has?(item) } + else + trainer_items = pbGetOwnerItems(idxBattler) + return false if !trainer_items + @mega_rings.each { |item| return true if trainer_items.include?(item) } + end return false end def pbGetMegaRingName(idxBattler) - if pbOwnedByPlayer?(idxBattler) - Settings::MEGA_RINGS.each do |item| - return GameData::Item.get(item).name if $bag.has?(item) + if !@mega_rings.empty? + if pbOwnedByPlayer?(idxBattler) + @mega_rings.each { |item| return GameData::Item.get(item).name if $bag.has?(item) } + else + trainer_items = pbGetOwnerItems(idxBattler) + @mega_rings.each { |item| return GameData::Item.get(item).name if trainer_items&.include?(item) } end end - # NOTE: Add your own Mega objects for particular NPC trainers here. -# if pbGetOwnerFromBattlerIndex(idxBattler).trainer_type == :BUGCATCHER -# return _INTL("Mega Net") -# end return _INTL("Mega Ring") end diff --git a/Data/Scripts/012_Overworld/002_Battle triggering/001_Overworld_BattleStarting.rb b/Data/Scripts/012_Overworld/002_Battle triggering/001_Overworld_BattleStarting.rb index 546ae1178..f0a2e8e2c 100644 --- a/Data/Scripts/012_Overworld/002_Battle triggering/001_Overworld_BattleStarting.rb +++ b/Data/Scripts/012_Overworld/002_Battle triggering/001_Overworld_BattleStarting.rb @@ -406,6 +406,7 @@ def pbTrainerBattleCore(*args) end # Calculate who the player trainer(s) and their party are playerTrainers = [$player] + allyItems = [] playerParty = $player.party playerPartyStarts = [0] room_for_partner = (foeParty.length > 1) @@ -417,6 +418,7 @@ def pbTrainerBattleCore(*args) ally = NPCTrainer.new($PokemonGlobal.partner[1], $PokemonGlobal.partner[0]) ally.id = $PokemonGlobal.partner[2] ally.party = $PokemonGlobal.partner[3] + allyItems[1] = ally.items.clone playerTrainers.push(ally) playerParty = [] $player.party.each { |pkmn| playerParty.push(pkmn) } @@ -431,6 +433,7 @@ def pbTrainerBattleCore(*args) battle.party1starts = playerPartyStarts battle.party2starts = foePartyStarts battle.items = foeItems + battle.ally_items = allyItems battle.endSpeeches = foeEndSpeeches # Set various other properties in the battle class pbPrepareBattle(battle) diff --git a/Data/Scripts/012_Overworld/006_Overworld_BerryPlants.rb b/Data/Scripts/012_Overworld/006_Overworld_BerryPlants.rb index ab6ebb39c..1b692e018 100644 --- a/Data/Scripts/012_Overworld/006_Overworld_BerryPlants.rb +++ b/Data/Scripts/012_Overworld/006_Overworld_BerryPlants.rb @@ -445,9 +445,9 @@ def pbPickBerry(berry, qty = 1) end $bag.add(berry, qty) if qty > 1 - pbMessage(_INTL("You picked the {1} \\c[1]{2}\\c[0].\\wtnp[30]", qty, berry_name)) + pbMessage(_INTL("\\me[Berry get]You picked the {1} \\c[1]{2}\\c[0].\\wtnp[30]", qty, berry_name)) else - pbMessage(_INTL("You picked the \\c[1]{1}\\c[0].\\wtnp[30]", berry_name)) + pbMessage(_INTL("\\me[Berry get]You picked the \\c[1]{1}\\c[0].\\wtnp[30]", berry_name)) end pocket = berry.pocket pbMessage(_INTL("{1} put the \\c[1]{2}\\c[0] in the \\c[1]{4}\\c[0] Pocket.\1", diff --git a/Data/Scripts/013_Items/001_Item_Utilities.rb b/Data/Scripts/013_Items/001_Item_Utilities.rb index 07ffb79ba..9b628f024 100644 --- a/Data/Scripts/013_Items/001_Item_Utilities.rb +++ b/Data/Scripts/013_Items/001_Item_Utilities.rb @@ -638,23 +638,7 @@ end def pbUseItem(bag, item, bagscene = nil) itm = GameData::Item.get(item) useType = itm.field_use - if itm.is_machine? # TM or TR or HM - if $player.pokemon_count == 0 - pbMessage(_INTL("There is no Pokémon.")) - return 0 - end - machine = itm.move - return 0 if !machine - movename = GameData::Move.get(machine).name - pbMessage(_INTL("\\se[PC access]You booted up {1}.\1", itm.name)) - if !pbConfirmMessage(_INTL("Do you want to teach {1} to a Pokémon?", movename)) - return 0 - elsif pbMoveTutorChoose(machine, nil, true, itm.is_TR?) - bag.remove(item) if itm.consumed_after_use? - return 1 - end - return 0 - elsif useType == 1 # Item is usable on a Pokémon + if useType == 1 # Item is usable on a Pokémon if $player.pokemon_count == 0 pbMessage(_INTL("There is no Pokémon.")) return 0 @@ -705,7 +689,7 @@ def pbUseItem(bag, item, bagscene = nil) bagscene&.pbRefresh } return (ret) ? 1 : 0 - elsif useType == 2 # Item is usable from Bag + elsif useType == 2 || itm.is_machine? # Item is usable from Bag or teaches a move intret = ItemHandlers.triggerUseFromBag(item) if intret >= 0 bag.remove(item) if intret == 1 && itm.consumed_after_use? diff --git a/Data/Scripts/013_Items/002_Item_Effects.rb b/Data/Scripts/013_Items/002_Item_Effects.rb index 0d70f927a..644b0a2cf 100644 --- a/Data/Scripts/013_Items/002_Item_Effects.rb +++ b/Data/Scripts/013_Items/002_Item_Effects.rb @@ -13,7 +13,7 @@ ItemHandlers::UseText.copy(:BICYCLE, :MACHBIKE, :ACROBIKE) # 1 = used # 2 = close the Bag to use # If there is no UseFromBag handler for an item being used from the Bag (not on -# a Pokémon and not a TM/HM), calls the UseInField handler for it instead. +# a Pokémon), calls the UseInField handler for it instead. #=============================================================================== ItemHandlers::UseFromBag.add(:HONEY, proc { |item| @@ -64,6 +64,23 @@ ItemHandlers::UseFromBag.add(:TOWNMAP, proc { |item| next ($game_temp.fly_destination) ? 2 : 0 }) +ItemHandlers::UseFromBag.addIf(proc { |item| GameData::Item.get(item).is_machine? }, + proc { |item| + if $player.pokemon_count == 0 + pbMessage(_INTL("There is no Pokémon.")) + next 0 + end + item_data = GameData::Item.get(item) + move = item_data.move + next 0 if !move + pbMessage(_INTL("\\se[PC access]You booted up {1}.\1", item_data.name)) + next 0 if !pbConfirmMessage(_INTL("Do you want to teach {1} to a Pokémon?", + GameData::Move.get(move).name)) + next 1 if pbMoveTutorChoose(move, nil, true, item_data.is_TR?) + next 0 + } +) + #=============================================================================== # ConfirmUseInField handlers # Return values: true/false diff --git a/Data/Scripts/016_UI/020_UI_PokeMart.rb b/Data/Scripts/016_UI/020_UI_PokeMart.rb index 09b72167d..3e3fd894b 100644 --- a/Data/Scripts/016_UI/020_UI_PokeMart.rb +++ b/Data/Scripts/016_UI/020_UI_PokeMart.rb @@ -186,6 +186,9 @@ class PokemonMart_Scene @sprites["icon"].item = itemwindow.item @sprites["itemtextwindow"].text = (itemwindow.item) ? @adapter.getDescription(itemwindow.item) : _INTL("Quit shopping.") + @sprites["qtywindow"].visible = !itemwindow.item.nil? + @sprites["qtywindow"].text = _INTL("In Bag:x{1}", @adapter.getQuantity(itemwindow.item)) + @sprites["qtywindow"].y = Graphics.height - 108 - @sprites["qtywindow"].height itemwindow.refresh end @sprites["moneywindow"].text = _INTL("Money:\r\n{1}", @adapter.getMoneyString) @@ -232,6 +235,16 @@ class PokemonMart_Scene @sprites["moneywindow"].height = 96 @sprites["moneywindow"].baseColor = Color.new(88, 88, 80) @sprites["moneywindow"].shadowColor = Color.new(168, 184, 184) + @sprites["qtywindow"] = Window_AdvancedTextPokemon.new("") + pbPrepareWindow(@sprites["qtywindow"]) + @sprites["qtywindow"].setSkin("Graphics/Windowskins/goldskin") + @sprites["qtywindow"].viewport = @viewport + @sprites["qtywindow"].width = 190 + @sprites["qtywindow"].height = 64 + @sprites["qtywindow"].baseColor = Color.new(88, 88, 80) + @sprites["qtywindow"].shadowColor = Color.new(168, 184, 184) + @sprites["qtywindow"].text = _INTL("In Bag:x{1}", @adapter.getQuantity(@sprites["itemwindow"].item)) + @sprites["qtywindow"].y = Graphics.height - 108 - @sprites["qtywindow"].height pbDeactivateWindows(@sprites) @buying = buying pbRefresh @@ -328,6 +341,16 @@ class PokemonMart_Scene @sprites["moneywindow"].visible = false end + def pbShowQuantity + pbRefresh + @sprites["qtywindow"].visible = true + end + + def pbHideQuantity + pbRefresh + @sprites["qtywindow"].visible = false + end + def pbDisplay(msg, brief = false) cw = @sprites["helpwindow"] cw.letterbyletter = true @@ -490,11 +513,7 @@ class PokemonMart_Scene Input.update olditem = itemwindow.item self.update - if itemwindow.item != olditem - @sprites["icon"].item = itemwindow.item - @sprites["itemtextwindow"].text = - (itemwindow.item) ? @adapter.getDescription(itemwindow.item) : _INTL("Quit shopping.") - end + pbRefresh if itemwindow.item != olditem if Input.trigger?(Input::BACK) pbPlayCloseMenuSE return nil diff --git a/Data/Scripts/019_Utilities/001_Utilities.rb b/Data/Scripts/019_Utilities/001_Utilities.rb index 49dcfe189..f026e7453 100644 --- a/Data/Scripts/019_Utilities/001_Utilities.rb +++ b/Data/Scripts/019_Utilities/001_Utilities.rb @@ -421,10 +421,8 @@ end def pbMoveTutorChoose(move, movelist = nil, bymachine = false, oneusemachine = false) ret = false move = GameData::Move.get(move).id - if movelist != nil && movelist.is_a?(Array) - movelist.length.times do |i| - movelist[i] = GameData::Move.get(movelist[i]).id - end + if movelist.is_a?(Array) + movelist.map! { |m| GameData::Move.get(m).id } end pbFadeOutIn { movename = GameData::Move.get(move).name diff --git a/PBS/items.txt b/PBS/items.txt index a85867ffc..057981960 100644 --- a/PBS/items.txt +++ b/PBS/items.txt @@ -1,4 +1,4 @@ -# See the documentation on the wiki to learn how to edit this file. +# See the documentation on the wiki to learn how to edit this file. #------------------------------- [REPEL] Name = Repel @@ -5623,7 +5623,7 @@ Name = Mega Ring NamePlural = Mega Rings Pocket = 8 Price = 0 -Flags = KeyItem +Flags = KeyItem, MegaRing Description = This ring contains an untold power that somehow enables Pokémon carrying Mega Stones to Mega Evolve. #------------------------------- [POKEMONBOXLINK] @@ -5648,4 +5648,4 @@ NamePlural = Old Sea Maps Pocket = 8 Price = 0 Flags = KeyItem -Description = A faded sea chart that shows the way to a certain island. +Description = A faded sea chart that shows the way to a certain island. \ No newline at end of file diff --git a/PBS/trainers.txt b/PBS/trainers.txt index 3462379db..6b91d2a0e 100644 --- a/PBS/trainers.txt +++ b/PBS/trainers.txt @@ -1,4 +1,4 @@ -# See the documentation on the wiki to learn how to edit this file. +# See the documentation on the wiki to learn how to edit this file. #------------------------------- [CAMPER,Liam] LoseText = A very good battle, indeed!