diff --git a/Data/Scripts/003_Game processing/001_StartGame.rb b/Data/Scripts/003_Game processing/001_StartGame.rb index 49f4b6f4f..983349abc 100644 --- a/Data/Scripts/003_Game processing/001_StartGame.rb +++ b/Data/Scripts/003_Game processing/001_StartGame.rb @@ -28,8 +28,8 @@ module Game # Set resize factor pbSetResizeFactor([$PokemonSystem.screensize, 4].min) # Set language (and choose language if there is no save file) - if Settings::LANGUAGES.length >= 2 - $PokemonSystem.language = pbChooseLanguage if save_data.empty? + if !Settings::LANGUAGES.empty? + $PokemonSystem.language = pbChooseLanguage if save_data.empty? && Settings::LANGUAGES.length >= 2 MessageTypes.load_message_files(Settings::LANGUAGES[$PokemonSystem.language][1]) end end diff --git a/Data/Scripts/007_Objects and windows/005_SpriteWindow_text.rb b/Data/Scripts/007_Objects and windows/005_SpriteWindow_text.rb index 1e0297ede..ae8530dc4 100644 --- a/Data/Scripts/007_Objects and windows/005_SpriteWindow_text.rb +++ b/Data/Scripts/007_Objects and windows/005_SpriteWindow_text.rb @@ -588,6 +588,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base if System.uptime - @wait_timer_start >= @waitcount @wait_timer_start = nil @waitcount = 0 + @display_last_updated = nil end return if @wait_timer_start end diff --git a/Data/Scripts/011_Battle/001_Battle/001_Battle.rb b/Data/Scripts/011_Battle/001_Battle/001_Battle.rb index 9f27e80e4..a2b875816 100644 --- a/Data/Scripts/011_Battle/001_Battle/001_Battle.rb +++ b/Data/Scripts/011_Battle/001_Battle/001_Battle.rb @@ -61,6 +61,7 @@ class Battle attr_accessor :debug # Debug flag attr_accessor :canRun # True if player can run from battle attr_accessor :canLose # True if player won't black out if they lose + attr_accessor :canSwitch # True if player is allowed to switch Pokémon attr_accessor :switchStyle # Switch/Set "battle style" option attr_accessor :showAnims # "Battle Effects" option attr_accessor :controlPlayer # Whether player's Pokémon are AI controlled @@ -131,6 +132,7 @@ class Battle @debug = false @canRun = true @canLose = false + @canSwitch = true @switchStyle = true @showAnims = true @controlPlayer = false diff --git a/Data/Scripts/011_Battle/004_Scene/003_Scene_ChooseCommands.rb b/Data/Scripts/011_Battle/004_Scene/003_Scene_ChooseCommands.rb index a22a5fc1d..3b61c5afa 100644 --- a/Data/Scripts/011_Battle/004_Scene/003_Scene_ChooseCommands.rb +++ b/Data/Scripts/011_Battle/004_Scene/003_Scene_ChooseCommands.rb @@ -165,7 +165,8 @@ class Battle::Scene cmdBoxes = -1 cmdSummary = -1 commands = [] - commands[cmdSwitch = commands.length] = _INTL("Switch In") if mode == 0 && modParty[idxParty].able? + commands[cmdSwitch = commands.length] = _INTL("Switch In") if mode == 0 && modParty[idxParty].able? && + (@battle.canSwitch || !canCancel) commands[cmdBoxes = commands.length] = _INTL("Send to Boxes") if mode == 1 commands[cmdSummary = commands.length] = _INTL("Summary") commands[commands.length] = _INTL("Cancel") diff --git a/Data/Scripts/011_Battle/005_AI/002_AI_Switch.rb b/Data/Scripts/011_Battle/005_AI/002_AI_Switch.rb index eccb8534b..2a2e8b2af 100644 --- a/Data/Scripts/011_Battle/005_AI/002_AI_Switch.rb +++ b/Data/Scripts/011_Battle/005_AI/002_AI_Switch.rb @@ -3,9 +3,10 @@ #=============================================================================== class Battle::AI # Called by the AI's def pbDefaultChooseEnemyCommand, and by def pbChooseMove - # if the only moves known are bad ones (the latter forces a switch). Also - # aliased by the Battle Palace and Battle Arena. - def pbChooseToSwitchOut(force_switch = false) + # if the only moves known are bad ones (the latter forces a switch if + # possible). Also aliased by the Battle Palace and Battle Arena. + def pbChooseToSwitchOut(terrible_moves = false) + return false if !@battle.canSwitch # Battle rule return false if @user.wild? return false if !@battle.pbCanSwitchOut?(@user.index) # Don't switch if all foes are unable to do anything, e.g. resting after @@ -20,7 +21,7 @@ class Battle::AI return false if !foe_can_act end # Various calculations to decide whether to switch - if force_switch + if terrible_moves PBDebug.log_ai("#{@user.name} is being forced to switch out") else return false if !@trainer.has_skill_flag?("ConsiderSwitching") @@ -33,7 +34,7 @@ class Battle::AI return false if !should_switch end # Want to switch; find the best replacement Pokémon - idxParty = choose_best_replacement_pokemon(@user.index, force_switch) + idxParty = choose_best_replacement_pokemon(@user.index, terrible_moves) if idxParty < 0 # No good replacement Pokémon found PBDebug.log(" => no good replacement Pokémon, will not switch after all") return false @@ -66,14 +67,14 @@ class Battle::AI #----------------------------------------------------------------------------- - def choose_best_replacement_pokemon(idxBattler, mandatory = false) + def choose_best_replacement_pokemon(idxBattler, terrible_moves = false) # Get all possible replacement Pokémon party = @battle.pbParty(idxBattler) idxPartyStart, idxPartyEnd = @battle.pbTeamIndexRangeFromBattlerIndex(idxBattler) reserves = [] party.each_with_index do |_pkmn, i| next if !@battle.pbCanSwitchIn?(idxBattler, i) - if !mandatory # Not mandatory means choosing an action for the round + if !terrible_moves # Not terrible_moves means choosing an action for the round ally_will_switch_with_i = false @battle.allSameSideBattlers(idxBattler).each do |b| next if @battle.choices[b.index][0] != :SwitchOut || @battle.choices[b.index][1] != i @@ -84,7 +85,7 @@ class Battle::AI end # Ignore ace if possible if @trainer.has_skill_flag?("ReserveLastPokemon") && i == idxPartyEnd - 1 - next if !mandatory || reserves.length > 0 + next if !terrible_moves || reserves.length > 0 end reserves.push([i, 100]) break if @trainer.has_skill_flag?("UsePokemonInOrder") && reserves.length > 0 @@ -96,7 +97,7 @@ class Battle::AI end reserves.sort! { |a, b| b[1] <=> a[1] } # Sort from highest to lowest rated # Don't bother choosing to switch if all replacements are poorly rated - if @trainer.high_skill? && !mandatory + if @trainer.high_skill? && !terrible_moves return -1 if reserves[0][1] < 100 # If best replacement rated at <100, don't switch end # Return the party index of the best rated replacement Pokémon 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 6051de90f..185c26b08 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 @@ -38,6 +38,8 @@ class Game_Temp when "canrun" then rules["canRun"] = true when "cannotrun" then rules["canRun"] = false when "roamerflees" then rules["roamerFlees"] = true + when "canswitch" then rules["canSwitch"] = true + when "cannotswitch" then rules["canSwitch"] = false when "noexp" then rules["expGain"] = false when "nomoney" then rules["moneyGain"] = false when "disablepokeballs" then rules["disablePokeBalls"] = true @@ -211,6 +213,8 @@ module BattleCreationHelperMethods battle.canLose = battleRules["canLose"] if !battleRules["canLose"].nil? # Whether the player can choose to run from the battle (default: true) battle.canRun = battleRules["canRun"] if !battleRules["canRun"].nil? + # Whether the player can manually choose to switch out Pokémon (default: true) + battle.canSwitch = battleRules["canSwitch"] if !battleRules["canSwitch"].nil? # Whether wild Pokémon always try to run from battle (default: nil) battle.rules["alwaysflee"] = battleRules["roamerFlees"] # Whether Pokémon gain Exp/EVs from defeating/catching a Pokémon (default: true)