Merge branch 'dev' into ai

This commit is contained in:
Maruno17
2022-10-04 22:56:27 +01:00
56 changed files with 2341 additions and 912 deletions

View File

@@ -21,6 +21,36 @@ class Battle
return true
end
# Return values:
# -1: Chose not to end the battle via Debug means
# 0: Couldn't end the battle via Debug means; carry on trying to run
# 1: Ended the battle via Debug means
def pbDebugRun
return 0 if !$DEBUG || !Input.press?(Input::CTRL)
commands = [_INTL("Treat as a win"), _INTL("Treat as a loss"),
_INTL("Treat as a draw"), _INTL("Treat as running away/forfeit")]
commands.push(_INTL("Treat as a capture")) if wildBattle?
commands.push(_INTL("Cancel"))
case pbShowCommands(_INTL("Choose the outcome of this battle."), commands)
when 0 # Win
@decision = 1
when 1 # Loss
@decision = 2
when 2 # Draw
@decision = 5
when 3 # Run away/forfeit
pbSEPlay("Battle flee")
pbDisplayPaused(_INTL("You got away safely!"))
@decision = 3
when 4 # Capture
return -1 if trainerBattle?
@decision = 4
else
return -1
end
return 1
end
# Return values:
# -1: Failed fleeing
# 0: Wasn't possible to attempt fleeing, continue choosing action for the round
@@ -36,17 +66,12 @@ class Battle
@choices[idxBattler][2] = nil
return -1
end
# Fleeing from trainer battles
# Debug ending the battle
debug_ret = pbDebugRun
return debug_ret if debug_ret != 0
# Running from trainer battles
if trainerBattle?
if $DEBUG && Input.press?(Input::CTRL)
if pbDisplayConfirm(_INTL("Treat this battle as a win?"))
@decision = 1
return 1
elsif pbDisplayConfirm(_INTL("Treat this battle as a loss?"))
@decision = 2
return 1
end
elsif @internalBattle
if @internalBattle
pbDisplayPaused(_INTL("No! There's no running from a Trainer battle!"))
elsif pbDisplayConfirm(_INTL("Would you like to forfeit the match and quit now?"))
pbSEPlay("Battle flee")
@@ -56,13 +81,6 @@ class Battle
end
return 0
end
# Fleeing from wild battles
if $DEBUG && Input.press?(Input::CTRL)
pbSEPlay("Battle flee")
pbDisplayPaused(_INTL("You got away safely!"))
@decision = 3
return 1
end
if !@canRun
pbDisplayPaused(_INTL("You can't escape!"))
return 0

View File

@@ -36,6 +36,9 @@ class Battle
end
def pbCall(idxBattler)
# Debug ending the battle
return if pbDebugRun != 0
# Call the battler
battler = @battlers[idxBattler]
trainerName = pbGetOwnerName(idxBattler)
pbDisplay(_INTL("{1} called {2}!", trainerName, battler.pbThis(true)))

View File

@@ -24,7 +24,7 @@ class Battle::Battler
def pbCanInflictStatus?(newStatus, user, showMessages, move = nil, ignoreStatus = false)
return false if fainted?
selfInflicted = (user && user.index == @index)
self_inflicted = (user && user.index == @index) # Rest and Flame Orb/Toxic Orb only
# Already have that status problem
if self.status == newStatus && !ignoreStatus
if showMessages
@@ -41,13 +41,13 @@ class Battle::Battler
return false
end
# Trying to replace a status problem with another one
if self.status != :NONE && !ignoreStatus && !selfInflicted
if self.status != :NONE && !ignoreStatus && !(self_inflicted && move) # Rest can replace a status problem
@battle.pbDisplay(_INTL("It doesn't affect {1}...", pbThis(true))) if showMessages
return false
end
# Trying to inflict a status problem on a Pokémon behind a substitute
if @effects[PBEffects::Substitute] > 0 && !(move && move.ignoresSubstitute?(user)) &&
!selfInflicted
!self_inflicted
@battle.pbDisplay(_INTL("It doesn't affect {1}...", pbThis(true))) if showMessages
return false
end
@@ -105,7 +105,7 @@ class Battle::Battler
immAlly = nil
if Battle::AbilityEffects.triggerStatusImmunityNonIgnorable(self.ability, self, newStatus)
immuneByAbility = true
elsif selfInflicted || !@battle.moldBreaker
elsif self_inflicted || !@battle.moldBreaker
if abilityActive? && Battle::AbilityEffects.triggerStatusImmunity(self.ability, self, newStatus)
immuneByAbility = true
else
@@ -163,7 +163,7 @@ class Battle::Battler
return false
end
# Safeguard immunity
if pbOwnSide.effects[PBEffects::Safeguard] > 0 && !selfInflicted && move &&
if pbOwnSide.effects[PBEffects::Safeguard] > 0 && !self_inflicted && move &&
!(user && user.hasActiveAbility?(:INFILTRATOR))
@battle.pbDisplay(_INTL("{1}'s team is protected by Safeguard!", pbThis)) if showMessages
return false

View File

@@ -496,6 +496,12 @@ Battle::AbilityEffects::StatusImmunityFromAlly.add(:FLOWERVEIL,
}
)
Battle::AbilityEffects::StatusImmunityFromAlly.add(:PASTELVEIL,
proc { |ability, battler, status|
next true if status == :POISON
}
)
Battle::AbilityEffects::StatusImmunityFromAlly.add(:SWEETVEIL,
proc { |ability, battler, status|
next true if status == :SLEEP
@@ -561,6 +567,8 @@ Battle::AbilityEffects::StatusCure.add(:IMMUNITY,
}
)
Battle::AbilityEffects::StatusCure.copy(:IMMUNITY, :PASTELVEIL)
Battle::AbilityEffects::StatusCure.add(:INSOMNIA,
proc { |ability, battler|
next if battler.status != :SLEEP