diff --git a/Data/Scripts/011_Battle/001_Battle/002_Battle_StartAndEnd.rb b/Data/Scripts/011_Battle/001_Battle/002_Battle_StartAndEnd.rb index d88b34e96..0cfcc6652 100644 --- a/Data/Scripts/011_Battle/001_Battle/002_Battle_StartAndEnd.rb +++ b/Data/Scripts/011_Battle/001_Battle/002_Battle_StartAndEnd.rb @@ -258,6 +258,8 @@ class Battle logMsg += "#{@opponent.length} trainer(s))" if trainerBattle? PBDebug.log(logMsg) pbEnsureParticipants + pbParty(0).each { |pkmn| @peer.pbOnStartingBattle(self, pkmn, wildBattle?) if pkmn } + pbParty(1).each { |pkmn| @peer.pbOnStartingBattle(self, pkmn, wildBattle?) if pkmn } begin pbStartBattleCore rescue BattleAbortedException diff --git a/Data/Scripts/011_Battle/006_Other battle code/004_Battle_Peers.rb b/Data/Scripts/011_Battle/006_Other battle code/004_Battle_Peers.rb index 32f4767b6..785d364a1 100644 --- a/Data/Scripts/011_Battle/006_Other battle code/004_Battle_Peers.rb +++ b/Data/Scripts/011_Battle/006_Other battle code/004_Battle_Peers.rb @@ -36,6 +36,12 @@ class Battle::Peer return (box < 0) ? "" : $PokemonStorage[box].name end + def pbOnStartingBattle(battle, pkmn, wild = false) + f = MultipleForms.call("getFormOnStartingBattle", pkmn, wild) + pkmn.form = f if f + MultipleForms.call("changePokemonOnStartingBattle", pkmn, battle) + end + def pbOnEnteringBattle(battle, battler, pkmn, wild = false) f = MultipleForms.call("getFormOnEnteringBattle", pkmn, wild) pkmn.form = f if f diff --git a/Data/Scripts/014_Pokemon/001_Pokemon-related/001_FormHandlers.rb b/Data/Scripts/014_Pokemon/001_Pokemon-related/001_FormHandlers.rb index 5ff9f7206..fc602f988 100644 --- a/Data/Scripts/014_Pokemon/001_Pokemon-related/001_FormHandlers.rb +++ b/Data/Scripts/014_Pokemon/001_Pokemon-related/001_FormHandlers.rb @@ -454,11 +454,11 @@ MultipleForms.register(:PUMPKABOO, { MultipleForms.copy(:PUMPKABOO, :GOURGEIST) MultipleForms.register(:XERNEAS, { - "getFormOnEnteringBattle" => proc { |pkmn, wild| + "getFormOnStartingBattle" => proc { |pkmn, wild| next 1 }, "getFormOnLeavingBattle" => proc { |pkmn, battle, usedInBattle, endBattle| - next 0 + next 0 if endBattle } }) @@ -647,52 +647,42 @@ MultipleForms.register(:MORPEKO, { }) MultipleForms.register(:ZACIAN, { - "getFormOnEnteringBattle" => proc { |pkmn, wild| + "getFormOnStartingBattle" => proc { |pkmn, wild| next 1 if pkmn.hasItem?(:RUSTEDSWORD) next 0 }, - "changePokemonOnEnteringBattle" => proc { |battler, pkmn, battle| + "changePokemonOnStartingBattle" => proc { |pkmn, battle| if GameData::Move.exists?(:BEHEMOTHBLADE) && pkmn.hasItem?(:RUSTEDSWORD) - pkmn.moves.each do |move| - next if move.id != :IRONHEAD - move.id = :BEHEMOTHBLADE - battler.moves.each_with_index do |b_move, i| - next if b_move.id != :IRONHEAD - battler.moves[i] = Battle::Move.from_pokemon_move(battle, move) - end - end + pkmn.moves.each { |move| move.id = :BEHEMOTHBLADE if move.id == :IRONHEAD } end }, "getFormOnLeavingBattle" => proc { |pkmn, battle, usedInBattle, endBattle| - next 0 + next 0 if endBattle }, "changePokemonOnLeavingBattle" => proc { |pkmn, battle, usedInBattle, endBattle| - pkmn.moves.each { |move| move.id = :IRONHEAD if move.id == :BEHEMOTHBLADE } + if endBattle + pkmn.moves.each { |move| move.id = :IRONHEAD if move.id == :BEHEMOTHBLADE } + end } }) MultipleForms.register(:ZAMAZENTA, { - "getFormOnEnteringBattle" => proc { |pkmn, wild| + "getFormOnStartingBattle" => proc { |pkmn, wild| next 1 if pkmn.hasItem?(:RUSTEDSHIELD) next 0 }, - "changePokemonOnEnteringBattle" => proc { |battler, pkmn, battle| + "changePokemonOnStartingBattle" => proc { |pkmn, battle| if GameData::Move.exists?(:BEHEMOTHBASH) && pkmn.hasItem?(:RUSTEDSHIELD) - pkmn.moves.each do |move| - next if move.id != :IRONHEAD - move.id = :BEHEMOTHBASH - battler.moves.each_with_index do |b_move, i| - next if b_move.id != :IRONHEAD - battler.moves[i] = Battle::Move.from_pokemon_move(battle, move) - end - end + pkmn.moves.each { |move| move.id = :BEHEMOTHBASH if move.id == :IRONHEAD } end }, "getFormOnLeavingBattle" => proc { |pkmn, battle, usedInBattle, endBattle| - next 0 + next 0 if endBattle }, "changePokemonOnLeavingBattle" => proc { |pkmn, battle, usedInBattle, endBattle| - pkmn.moves.each { |move| move.id = :IRONHEAD if move.id == :BEHEMOTHBASH } + if endBattle + pkmn.moves.each { |move| move.id = :IRONHEAD if move.id == :BEHEMOTHBASH } + end } })