mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-08 05:34:58 +00:00
Moves fail because of semi-invulnerability instead of other immunities, fixed Pokédex not registering Pokémon in Safari battles, other things
This commit is contained in:
@@ -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
|
||||
# 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")
|
||||
end
|
||||
# Missed
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user