From 5bef70fb3a09ac81256cdc6ed415de29a8a443ca Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Tue, 14 May 2024 20:37:32 +0100 Subject: [PATCH] =?UTF-8?q?Moves=20fail=20because=20of=20semi-invulnerabil?= =?UTF-8?q?ity=20instead=20of=20other=20immunities,=20fixed=20Pok=C3=A9dex?= =?UTF-8?q?=20not=20registering=20Pok=C3=A9mon=20in=20Safari=20battles,=20?= =?UTF-8?q?other=20things?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../009_Battler_UseMoveSuccessChecks.rb | 89 ++++++++++--------- .../001_SafariBattle.rb | 4 +- Data/Scripts/016_UI/013_UI_Load.rb | 6 +- Data/Scripts/019_Utilities/001_Utilities.rb | 2 +- 4 files changed, 56 insertions(+), 45 deletions(-) diff --git a/Data/Scripts/011_Battle/002_Battler/009_Battler_UseMoveSuccessChecks.rb b/Data/Scripts/011_Battle/002_Battler/009_Battler_UseMoveSuccessChecks.rb index 5151500dd..66686e67c 100644 --- a/Data/Scripts/011_Battle/002_Battler/009_Battler_UseMoveSuccessChecks.rb +++ b/Data/Scripts/011_Battle/002_Battler/009_Battler_UseMoveSuccessChecks.rb @@ -306,6 +306,12 @@ class Battle::Battler target.damageState.typeMod = typeMod # Two-turn attacks can't fail here in the charging turn return true if user.effects[PBEffects::TwoTurnAttack] + # Semi-invulnerable target + if !pbSuccessCheckSemiInvulnerable(move, user, target) + PBDebug.log("[Move failed] Target is semi-invulnerable") + target.damageState.invulnerable = true + return true # Succeeds here but fails in def pbSuccessCheckPerHit + end # Move-specific failures if move.pbFailsAgainstTarget?(user, target, show_message) PBDebug.log(sprintf("[Move failed] In function code %s's def pbFailsAgainstTarget?", move.function_code)) @@ -525,6 +531,42 @@ class Battle::Battler return true end + # Returns true if the target is not semi-invulnerable, or if the user can hit + # the target even though the target is semi-invulnerable. + def pbSuccessCheckSemiInvulnerable(move, user, target) + # Lock-On + return true if user.effects[PBEffects::LockOn] > 0 && + user.effects[PBEffects::LockOnPos] == target.index + # Toxic + return true if move.pbOverrideSuccessCheckPerHit(user, target) + # No Guard + return true if user.hasActiveAbility?(:NOGUARD) || + target.hasActiveAbility?(:NOGUARD) + # Future Sight + return true if @battle.futureSight + # Helping Hand + return true if move.function_code == "PowerUpAllyMove" + # Semi-invulnerable moves + if target.effects[PBEffects::TwoTurnAttack] + if target.inTwoTurnAttack?("TwoTurnAttackInvulnerableInSky", + "TwoTurnAttackInvulnerableInSkyParalyzeTarget", + "TwoTurnAttackInvulnerableInSkyTargetCannotAct") + return move.hitsFlyingTargets? + elsif target.inTwoTurnAttack?("TwoTurnAttackInvulnerableUnderground") + return move.hitsDiggingTargets? + elsif target.inTwoTurnAttack?("TwoTurnAttackInvulnerableUnderwater") + return move.hitsDivingTargets? + elsif target.inTwoTurnAttack?("TwoTurnAttackInvulnerableRemoveProtections") + return false + end + end + if target.effects[PBEffects::SkyDrop] >= 0 && + target.effects[PBEffects::SkyDrop] != user.index && !move.hitsFlyingTargets? + return false + end + return true + end + #============================================================================= # Per-hit success check against the target. # Includes semi-invulnerable move use and accuracy calculation. @@ -537,46 +579,13 @@ class Battle::Battler user.effects[PBEffects::LockOnPos] == target.index # Toxic return true if move.pbOverrideSuccessCheckPerHit(user, target) - miss = false - hitsInvul = false - # No Guard - hitsInvul = true if user.hasActiveAbility?(:NOGUARD) || - target.hasActiveAbility?(:NOGUARD) - # Future Sight - hitsInvul = true if @battle.futureSight - # Helping Hand - hitsInvul = true if move.function_code == "PowerUpAllyMove" - if !hitsInvul - # Semi-invulnerable moves - if target.effects[PBEffects::TwoTurnAttack] - if target.inTwoTurnAttack?("TwoTurnAttackInvulnerableInSky", - "TwoTurnAttackInvulnerableInSkyParalyzeTarget", - "TwoTurnAttackInvulnerableInSkyTargetCannotAct") - miss = true if !move.hitsFlyingTargets? - elsif target.inTwoTurnAttack?("TwoTurnAttackInvulnerableUnderground") - miss = true if !move.hitsDiggingTargets? - elsif target.inTwoTurnAttack?("TwoTurnAttackInvulnerableUnderwater") - miss = true if !move.hitsDivingTargets? - elsif target.inTwoTurnAttack?("TwoTurnAttackInvulnerableRemoveProtections") - miss = true - end - end - if target.effects[PBEffects::SkyDrop] >= 0 && - target.effects[PBEffects::SkyDrop] != user.index && !move.hitsFlyingTargets? - miss = true - end - end - if miss - target.damageState.invulnerable = true - PBDebug.log("[Move failed] Target is semi-invulnerable") - else - # Called by another move - return true if skipAccuracyCheck - # Accuracy check - return true if move.pbAccuracyCheck(user, target) # Includes Counter/Mirror Coat - PBDebug.log("[Move failed] Failed pbAccuracyCheck") - end - # Missed + # Semi-invulnerable target + return false if target.damageState.invulnerable + # Called by another move + return true if skipAccuracyCheck + # Accuracy check + return true if move.pbAccuracyCheck(user, target) # Includes Counter/Mirror Coat + PBDebug.log("[Move failed] Failed pbAccuracyCheck") return false end diff --git a/Data/Scripts/011_Battle/008_Other battle types/001_SafariBattle.rb b/Data/Scripts/011_Battle/008_Other battle types/001_SafariBattle.rb index 91d69682f..228463d9d 100644 --- a/Data/Scripts/011_Battle/008_Other battle types/001_SafariBattle.rb +++ b/Data/Scripts/011_Battle/008_Other battle types/001_SafariBattle.rb @@ -342,7 +342,7 @@ class SafariBattle def pbGetOwnerFromBattlerIndex(idxBattler); return pbPlayer; end def pbSetSeen(battler) - return if !battler || !@internalBattle + return if !battler if battler.is_a?(Battle::Battler) pbPlayer.pokedex.register(battler.displaySpecies, battler.displayGender, battler.displayForm, battler.shiny?) @@ -352,7 +352,7 @@ class SafariBattle end def pbSetCaught(battler) - return if !battler || !@internalBattle + return if !battler if battler.is_a?(Battle::Battler) pbPlayer.pokedex.register_caught(battler.displaySpecies) else diff --git a/Data/Scripts/016_UI/013_UI_Load.rb b/Data/Scripts/016_UI/013_UI_Load.rb index 225cad94a..9d15a685d 100644 --- a/Data/Scripts/016_UI/013_UI_Load.rb +++ b/Data/Scripts/016_UI/013_UI_Load.rb @@ -117,6 +117,7 @@ class PokemonLoad_Scene @sprites["cmdwindow"] = Window_CommandPokemon.new([]) @sprites["cmdwindow"].viewport = @viewport @sprites["cmdwindow"].visible = false + @max_party_index = 0 end def pbStartScene2 @@ -143,7 +144,7 @@ class PokemonLoad_Scene @commands.length.times do |i| @sprites["panel#{i}"].y -= 48 end - 6.times do |i| + (@max_party_index + 1).times do |i| break if !@sprites["party#{i}"] @sprites["party#{i}"].y -= 48 end @@ -153,7 +154,7 @@ class PokemonLoad_Scene @commands.length.times do |i| @sprites["panel#{i}"].y += 48 end - 6.times do |i| + (@max_party_index + 1).times do |i| break if !@sprites["party#{i}"] @sprites["party#{i}"].y += 48 end @@ -183,6 +184,7 @@ class PokemonLoad_Scene @sprites["party#{i}"].x = 334 + (66 * (i % 2)) @sprites["party#{i}"].y = 112 + (50 * (i / 2)) @sprites["party#{i}"].z = 99999 + @max_party_index = i end end diff --git a/Data/Scripts/019_Utilities/001_Utilities.rb b/Data/Scripts/019_Utilities/001_Utilities.rb index f79153ed8..7944ea7c6 100644 --- a/Data/Scripts/019_Utilities/001_Utilities.rb +++ b/Data/Scripts/019_Utilities/001_Utilities.rb @@ -616,5 +616,5 @@ def pbScreenCapture capturefile = RTP.getSaveFileName(sprintf("%s.png", filestart)) Graphics.screenshot(capturefile) end - pbSEPlay("Pkmn exp full") if FileTest.audio_exist?("Audio/SE/Pkmn exp full") + pbSEPlay("Screenshot") if FileTest.audio_exist?("Audio/SE/Screenshot") end