Snowstorm, forfeiting trainer battles, battle outcome values

This commit is contained in:
Maruno17
2024-06-15 21:29:00 +01:00
parent 22b33ca6c2
commit 8e9417c3b7
41 changed files with 284 additions and 214 deletions

View File

@@ -14,7 +14,7 @@ module Settings
# Note that this isn't perfect. Essentials doesn't accurately replicate every # Note that this isn't perfect. Essentials doesn't accurately replicate every
# single generation's mechanics. It's considered to be good enough. Only # single generation's mechanics. It's considered to be good enough. Only
# generations 5 and later are reasonably supported. # generations 5 and later are reasonably supported.
MECHANICS_GENERATION = 8 MECHANICS_GENERATION = 9
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Credits # Credits

View File

@@ -52,20 +52,23 @@ module Settings
NUM_BADGES_BOOST_SPEED = (MECHANICS_GENERATION >= 4) ? 999 : 3 NUM_BADGES_BOOST_SPEED = (MECHANICS_GENERATION >= 4) ? 999 : 3
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Ability and item effects # Move, ability and item effects
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Whether the in-battle hail weather is replaced by Snowstorm (from Gen 9+)
# instead.
USE_SNOWSTORM_WEATHER_INSTEAD_OF_HAIL = (MECHANICS_GENERATION >= 9)
# Whether weather caused by an ability lasts 5 rounds (true) or forever (false). # Whether weather caused by an ability lasts 5 rounds (true) or forever (false).
FIXED_DURATION_WEATHER_FROM_ABILITY = (MECHANICS_GENERATION >= 6) FIXED_DURATION_WEATHER_FROM_ABILITY = (MECHANICS_GENERATION >= 6)
# Whether X items (X Attack, etc.) raise their stat by 2 stages (true) or 1 # Whether X items (X Attack, etc.) raise their stat by 2 stages (true) or 1
# (false). # (false).
X_STAT_ITEMS_RAISE_BY_TWO_STAGES = (MECHANICS_GENERATION >= 7) X_STAT_ITEMS_RAISE_BY_TWO_STAGES = (MECHANICS_GENERATION >= 7)
# Whether some Poké Balls have catch rate multipliers from Gen 7 (true) or # Whether some Poké Balls have catch rate multipliers from Gen 7 (true) or
# from earlier generations (false). # from earlier generations (false).
NEW_POKE_BALL_CATCH_RATES = (MECHANICS_GENERATION >= 7) NEW_POKE_BALL_CATCH_RATES = (MECHANICS_GENERATION >= 7)
# Whether Soul Dew powers up Psychic and Dragon-type moves by 20% (true) or # Whether Soul Dew powers up Psychic and Dragon-type moves by 20% (true) or
# raises the holder's Special Attack and Special Defense by 50% (false). # raises the holder's Special Attack and Special Defense by 50% (false).
SOUL_DEW_POWERS_UP_TYPES = (MECHANICS_GENERATION >= 7) SOUL_DEW_POWERS_UP_TYPES = (MECHANICS_GENERATION >= 7)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Affection # Affection
@@ -120,6 +123,7 @@ module Settings
# End of battle # End of battle
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
CAN_FORFEIT_TRAINER_BATTLES = (MECHANICS_GENERATION >= 9)
# The Game Switch which, while ON, prevents the player from losing money if # The Game Switch which, while ON, prevents the player from losing money if
# they lose a battle (they can still gain money from trainers for winning). # they lose a battle (they can still gain money from trainers for winning).
NO_MONEY_LOSS = 33 NO_MONEY_LOSS = 33

View File

@@ -56,6 +56,12 @@ GameData::BattleWeather.register({
:animation => "Hail" :animation => "Hail"
}) })
GameData::BattleWeather.register({
:id => :Snowstorm,
:name => _INTL("Snowstorm"),
:animation => "Snowstorm"
})
GameData::BattleWeather.register({ GameData::BattleWeather.register({
:id => :HarshSun, :id => :HarshSun,
:name => _INTL("Harsh Sun"), :name => _INTL("Harsh Sun"),

View File

@@ -1,4 +1,4 @@
# Results of battle: # Results of battle (see module Outcome):
# 0 - Undecided or aborted # 0 - Undecided or aborted
# 1 - Player won # 1 - Player won
# 2 - Player lost # 2 - Player lost
@@ -38,6 +38,29 @@
# (There is no guarantee that this list is complete.) # (There is no guarantee that this list is complete.)
class Battle class Battle
module Outcome
UNDECIDED = 0
WIN = 1
LOSE = 2 # Also used when player forfeits a trainer battle
FLEE = 3 # Player or wild Pokémon ran away, count as a win
CATCH = 4 # Counts as a win
DRAW = 5
def self.decided?(decision)
return decision != UNDECIDED
end
def self.should_black_out?(decision)
return decision == LOSE || decision == DRAW
end
def self.success?(decision)
return !self.should_black_out?(decision)
end
end
#-----------------------------------------------------------------------------
attr_reader :scene # Scene object for this battle attr_reader :scene # Scene object for this battle
attr_reader :peer attr_reader :peer
attr_reader :field # Effects common to the whole of a battle attr_reader :field # Effects common to the whole of a battle
@@ -50,7 +73,7 @@ class Battle
attr_accessor :time # Time of day (0=day, 1=eve, 2=night) attr_accessor :time # Time of day (0=day, 1=eve, 2=night)
attr_accessor :environment # Battle surroundings (for mechanics purposes) attr_accessor :environment # Battle surroundings (for mechanics purposes)
attr_reader :turnCount attr_reader :turnCount
attr_accessor :decision # Decision: 0=undecided; 1=win; 2=loss; 3=escaped; 4=caught attr_accessor :decision # Outcome of battle
attr_reader :player # Player trainer (or array of trainers) attr_reader :player # Player trainer (or array of trainers)
attr_reader :opponent # Opponent trainer (or array of trainers) attr_reader :opponent # Opponent trainer (or array of trainers)
attr_accessor :items # Items held by opponents attr_accessor :items # Items held by opponents
@@ -114,7 +137,7 @@ class Battle
@time = 0 @time = 0
@environment = :None # e.g. Tall grass, cave, still water @environment = :None # e.g. Tall grass, cave, still water
@turnCount = 0 @turnCount = 0
@decision = 0 @decision = Outcome::UNDECIDED
@caughtPokemon = [] @caughtPokemon = []
player = [player] if !player.nil? && !player.is_a?(Array) player = [player] if !player.nil? && !player.is_a?(Array)
opponent = [opponent] if !opponent.nil? && !opponent.is_a?(Array) opponent = [opponent] if !opponent.nil? && !opponent.is_a?(Array)
@@ -173,6 +196,10 @@ class Battle
@battleAI = AI.new(self) @battleAI = AI.new(self)
end end
def decided?
return Outcome.decided?(@decision)
end
#============================================================================= #=============================================================================
# Information about the type and size of the battle # Information about the type and size of the battle
#============================================================================= #=============================================================================
@@ -730,6 +757,7 @@ class Battle
when :Rain then pbDisplay(_INTL("It started to rain!")) when :Rain then pbDisplay(_INTL("It started to rain!"))
when :Sandstorm then pbDisplay(_INTL("A sandstorm brewed!")) when :Sandstorm then pbDisplay(_INTL("A sandstorm brewed!"))
when :Hail then pbDisplay(_INTL("It started to hail!")) when :Hail then pbDisplay(_INTL("It started to hail!"))
when :Snowstorm then pbDisplay(_INTL("It started to snow!"))
when :HarshSun then pbDisplay(_INTL("The sunlight turned extremely harsh!")) when :HarshSun then pbDisplay(_INTL("The sunlight turned extremely harsh!"))
when :HeavyRain then pbDisplay(_INTL("A heavy rain began to fall!")) when :HeavyRain then pbDisplay(_INTL("A heavy rain began to fall!"))
when :StrongWinds then pbDisplay(_INTL("Mysterious strong winds are protecting Flying-type Pokémon!")) when :StrongWinds then pbDisplay(_INTL("Mysterious strong winds are protecting Flying-type Pokémon!"))

View File

@@ -270,7 +270,7 @@ class Battle
begin begin
pbStartBattleCore pbStartBattleCore
rescue BattleAbortedException rescue BattleAbortedException
@decision = 0 @decision = Outcome::UNDECIDED
@scene.pbEndBattle(@decision) @scene.pbEndBattle(@decision)
end end
return @decision return @decision
@@ -292,6 +292,7 @@ class Battle
when :Rain then pbDisplay(_INTL("It is raining.")) when :Rain then pbDisplay(_INTL("It is raining."))
when :Sandstorm then pbDisplay(_INTL("A sandstorm is raging.")) when :Sandstorm then pbDisplay(_INTL("A sandstorm is raging."))
when :Hail then pbDisplay(_INTL("Hail is falling.")) when :Hail then pbDisplay(_INTL("Hail is falling."))
when :Snowstorm then pbDisplay(_INTL("It is snowing."))
when :HarshSun then pbDisplay(_INTL("The sunlight is extremely harsh.")) when :HarshSun then pbDisplay(_INTL("The sunlight is extremely harsh."))
when :HeavyRain then pbDisplay(_INTL("It is raining heavily.")) when :HeavyRain then pbDisplay(_INTL("It is raining heavily."))
when :StrongWinds then pbDisplay(_INTL("The wind is strong.")) when :StrongWinds then pbDisplay(_INTL("The wind is strong."))
@@ -334,13 +335,13 @@ class Battle
PBDebug.log("") PBDebug.log("")
# Command phase # Command phase
PBDebug.logonerr { pbCommandPhase } PBDebug.logonerr { pbCommandPhase }
break if @decision > 0 break if decided?
# Attack phase # Attack phase
PBDebug.logonerr { pbAttackPhase } PBDebug.logonerr { pbAttackPhase }
break if @decision > 0 break if decided?
# End of round phase # End of round phase
PBDebug.logonerr { pbEndOfRoundPhase } PBDebug.logonerr { pbEndOfRoundPhase }
break if @decision > 0 break if decided?
@turnCount += 1 @turnCount += 1
end end
pbEndOfBattle pbEndOfBattle
@@ -404,10 +405,9 @@ class Battle
def pbEndOfBattle def pbEndOfBattle
oldDecision = @decision oldDecision = @decision
@decision = 4 if @decision == 1 && wildBattle? && @caughtPokemon.length > 0 @decision = Outcome::CATCH if @decision == Outcome::WIN && wildBattle? && @caughtPokemon.length > 0
case oldDecision case oldDecision
##### WIN ##### when Outcome::WIN
when 1
PBDebug.log("") PBDebug.log("")
PBDebug.log_header("===== Player won =====") PBDebug.log_header("===== Player won =====")
PBDebug.log("") PBDebug.log("")
@@ -432,33 +432,34 @@ class Battle
PBDebug.log("") PBDebug.log("")
end end
# Gain money from winning a trainer battle, and from Pay Day # Gain money from winning a trainer battle, and from Pay Day
pbGainMoney if @decision != 4 pbGainMoney if @decision != Outcome::CATCH
# Hide remaining trainer # Hide remaining trainer
@scene.pbShowOpponent(@opponent.length) if trainerBattle? && @caughtPokemon.length > 0 @scene.pbShowOpponent(@opponent.length) if trainerBattle? && @caughtPokemon.length > 0
##### LOSE, DRAW ##### when Outcome::LOSE, Outcome::DRAW
when 2, 5
PBDebug.log("") PBDebug.log("")
PBDebug.log_header("===== Player lost =====") if @decision == 2 PBDebug.log_header("===== Player lost =====") if @decision == Outcome::LOSE
PBDebug.log_header("===== Player drew with opponent =====") if @decision == 5 PBDebug.log_header("===== Player drew with opponent =====") if @decision == Outcome::DRAW
PBDebug.log("") PBDebug.log("")
if @internalBattle if @internalBattle
pbDisplayPaused(_INTL("You have no more Pokémon that can fight!")) if pbPlayerBattlerCount == 0
if trainerBattle? pbDisplayPaused(_INTL("You have no more Pokémon that can fight!"))
case @opponent.length if trainerBattle?
when 1 case @opponent.length
pbDisplayPaused(_INTL("You lost against {1}!", @opponent[0].full_name)) when 1
when 2 pbDisplayPaused(_INTL("You lost against {1}!", @opponent[0].full_name))
pbDisplayPaused(_INTL("You lost against {1} and {2}!", when 2
@opponent[0].full_name, @opponent[1].full_name)) pbDisplayPaused(_INTL("You lost against {1} and {2}!",
when 3 @opponent[0].full_name, @opponent[1].full_name))
pbDisplayPaused(_INTL("You lost against {1}, {2} and {3}!", when 3
@opponent[0].full_name, @opponent[1].full_name, @opponent[2].full_name)) pbDisplayPaused(_INTL("You lost against {1}, {2} and {3}!",
@opponent[0].full_name, @opponent[1].full_name, @opponent[2].full_name))
end
end end
end end
# Lose money from losing a battle # Lose money from losing a battle
pbLoseMoney pbLoseMoney
pbDisplayPaused(_INTL("You blacked out!")) if !@canLose pbDisplayPaused(_INTL("You blacked out!")) if !@canLose && pbPlayerBattlerCount == 0
elsif @decision == 2 # Lost in a Battle Frontier battle elsif @decision == Outcome::LOSE # Lost in a Battle Frontier battle
if @opponent if @opponent
@opponent.each_with_index do |trainer, i| @opponent.each_with_index do |trainer, i|
@scene.pbShowOpponent(i) @scene.pbShowOpponent(i)
@@ -469,8 +470,7 @@ class Battle
PBDebug.log("") PBDebug.log("")
end end
end end
##### CAUGHT WILD POKÉMON ##### when Outcome::CATCH
when 4
PBDebug.log("") PBDebug.log("")
PBDebug.log_header("===== Pokémon caught =====") PBDebug.log_header("===== Pokémon caught =====")
PBDebug.log("") PBDebug.log("")
@@ -479,7 +479,7 @@ class Battle
# Register captured Pokémon in the Pokédex, and store them # Register captured Pokémon in the Pokédex, and store them
pbRecordAndStoreCaughtPokemon pbRecordAndStoreCaughtPokemon
# Collect Pay Day money in a wild battle that ended in a capture # Collect Pay Day money in a wild battle that ended in a capture
pbGainMoney if @decision == 4 pbGainMoney if @decision == Outcome::CATCH
# Pass on Pokérus within the party # Pass on Pokérus within the party
if @internalBattle if @internalBattle
infected = [] infected = []
@@ -526,11 +526,11 @@ class Battle
hpTotals[side] += pkmn.hp hpTotals[side] += pkmn.hp
end end
end end
return 1 if counts[0] > counts[1] # Win (player has more able Pokémon) return Outcome::WIN if counts[0] > counts[1] # Win (player has more able Pokémon)
return 2 if counts[0] < counts[1] # Loss (foe has more able Pokémon) return Outcome::LOSE if counts[0] < counts[1] # Loss (foe has more able Pokémon)
return 1 if hpTotals[0] > hpTotals[1] # Win (player has more HP in total) return Outcome::WIN if hpTotals[0] > hpTotals[1] # Win (player has more HP in total)
return 2 if hpTotals[0] < hpTotals[1] # Loss (foe has more HP in total) return Outcome::LOSE if hpTotals[0] < hpTotals[1] # Loss (foe has more HP in total)
return 5 # Draw return Outcome::DRAW
end end
# Unused # Unused
@@ -545,24 +545,24 @@ class Battle
end end
hpTotals[side] /= counts[side] if counts[side] > 1 hpTotals[side] /= counts[side] if counts[side] > 1
end end
return 1 if counts[0] > counts[1] # Win (player has more able Pokémon) return Outcome::WIN if counts[0] > counts[1] # Win (player has more able Pokémon)
return 2 if counts[0] < counts[1] # Loss (foe has more able Pokémon) return Outcome::LOSE if counts[0] < counts[1] # Loss (foe has more able Pokémon)
return 1 if hpTotals[0] > hpTotals[1] # Win (player has a bigger average HP %) return Outcome::WIN if hpTotals[0] > hpTotals[1] # Win (player has a bigger average HP %)
return 2 if hpTotals[0] < hpTotals[1] # Loss (foe has a bigger average HP %) return Outcome::LOSE if hpTotals[0] < hpTotals[1] # Loss (foe has a bigger average HP %)
return 5 # Draw return Outcome::DRAW
end end
def pbDecisionOnDraw; return 5; end # Draw def pbDecisionOnDraw; return Outcome::DRAW; end # Draw
def pbJudge def pbJudge
fainted1 = pbAllFainted?(0) fainted1 = pbAllFainted?(0)
fainted2 = pbAllFainted?(1) fainted2 = pbAllFainted?(1)
if fainted1 && fainted2 if fainted1 && fainted2
@decision = pbDecisionOnDraw # Draw @decision = pbDecisionOnDraw
elsif fainted1 elsif fainted1
@decision = 2 # Loss @decision = Outcome::LOSE
elsif fainted2 elsif fainted2
@decision = 1 # Win @decision = Outcome::WIN
end end
end end
end end

View File

@@ -140,10 +140,10 @@ class Battle
# General switching method that checks if any Pokémon need to be sent out and, # General switching method that checks if any Pokémon need to be sent out and,
# if so, does. Called at the end of each round. # if so, does. Called at the end of each round.
def pbEORSwitch(favorDraws = false) def pbEORSwitch(favorDraws = false)
return if @decision > 0 && !favorDraws return if decided? && !favorDraws
return if @decision == 5 && favorDraws return if @decision == Outcome::DRAW && favorDraws
pbJudge pbJudge
return if @decision > 0 return if decided?
# Check through each fainted battler to see if that spot can be filled. # Check through each fainted battler to see if that spot can be filled.
switched = [] switched = []
loop do loop do

View File

@@ -32,19 +32,19 @@ class Battle
commands.push(_INTL("Treat as a capture")) if wildBattle? commands.push(_INTL("Treat as a capture")) if wildBattle?
commands.push(_INTL("Cancel")) commands.push(_INTL("Cancel"))
case pbShowCommands(_INTL("Choose the outcome of this battle."), commands) case pbShowCommands(_INTL("Choose the outcome of this battle."), commands)
when 0 # Win when 0
@decision = 1 @decision = Outcome::WIN
when 1 # Loss when 1
@decision = 2 @decision = Outcome::LOSE
when 2 # Draw when 2
@decision = 5 @decision = Outcome::DRAW
when 3 # Run away/forfeit when 3
pbSEPlay("Battle flee") pbSEPlay("Battle flee")
pbDisplayPaused(_INTL("You got away safely!")) pbDisplayPaused(_INTL("You got away safely!"))
@decision = 3 @decision = Outcome::FLEE
when 4 # Capture when 4
return -1 if trainerBattle? return -1 if trainerBattle?
@decision = 4 @decision = Outcome::CATCH
else else
return -1 return -1
end end
@@ -72,11 +72,19 @@ class Battle
# Running from trainer battles # Running from trainer battles
if trainerBattle? if trainerBattle?
if @internalBattle if @internalBattle
pbDisplayPaused(_INTL("No! There's no running from a Trainer battle!")) if Settings::CAN_FORFEIT_TRAINER_BATTLES
pbDisplayPaused(_INTL("Would you like to give up on this battle and quit now?"))
if pbDisplayConfirm(_INTL("Quitting the battle is the same as losing the battle."))
@decision = Outcome::LOSE # Treated as a loss
return 1
end
else
pbDisplayPaused(_INTL("No! There's no running from a Trainer battle!"))
end
elsif pbDisplayConfirm(_INTL("Would you like to forfeit the match and quit now?")) elsif pbDisplayConfirm(_INTL("Would you like to forfeit the match and quit now?"))
pbSEPlay("Battle flee") pbSEPlay("Battle flee")
pbDisplay(_INTL("{1} forfeited the match!", self.pbPlayer.name)) pbDisplay(_INTL("{1} forfeited the match!", self.pbPlayer.name))
@decision = 3 @decision = Outcome::FLEE
return 1 return 1
end end
return 0 return 0
@@ -89,7 +97,7 @@ class Battle
if battler.pbHasType?(:GHOST) && Settings::MORE_TYPE_EFFECTS if battler.pbHasType?(:GHOST) && Settings::MORE_TYPE_EFFECTS
pbSEPlay("Battle flee") pbSEPlay("Battle flee")
pbDisplayPaused(_INTL("You got away safely!")) pbDisplayPaused(_INTL("You got away safely!"))
@decision = 3 @decision = Outcome::FLEE
return 1 return 1
end end
# Abilities that guarantee escape # Abilities that guarantee escape
@@ -99,7 +107,7 @@ class Battle
pbHideAbilitySplash(battler) pbHideAbilitySplash(battler)
pbSEPlay("Battle flee") pbSEPlay("Battle flee")
pbDisplayPaused(_INTL("You got away safely!")) pbDisplayPaused(_INTL("You got away safely!"))
@decision = 3 @decision = Outcome::FLEE
return 1 return 1
end end
# Held items that guarantee escape # Held items that guarantee escape
@@ -107,7 +115,7 @@ class Battle
Battle::ItemEffects.triggerCertainEscapeFromBattle(battler.item, battler) Battle::ItemEffects.triggerCertainEscapeFromBattle(battler.item, battler)
pbSEPlay("Battle flee") pbSEPlay("Battle flee")
pbDisplayPaused(_INTL("{1} fled using its {2}!", battler.pbThis, battler.itemName)) pbDisplayPaused(_INTL("{1} fled using its {2}!", battler.pbThis, battler.itemName))
@decision = 3 @decision = Outcome::FLEE
return 1 return 1
end end
# Other certain trapping effects # Other certain trapping effects
@@ -151,7 +159,7 @@ class Battle
if rate >= 256 || @battleAI.pbAIRandom(256) < rate if rate >= 256 || @battleAI.pbAIRandom(256) < rate
pbSEPlay("Battle flee") pbSEPlay("Battle flee")
pbDisplayPaused(_INTL("You got away safely!")) pbDisplayPaused(_INTL("You got away safely!"))
@decision = 3 @decision = Outcome::FLEE
return 1 return 1
end end
pbDisplayPaused(_INTL("You couldn't get away!")) pbDisplayPaused(_INTL("You couldn't get away!"))

View File

@@ -187,7 +187,7 @@ class Battle
end end
# Choose actions for the round (player first, then AI) # Choose actions for the round (player first, then AI)
pbCommandPhaseLoop(true) # Player chooses their actions pbCommandPhaseLoop(true) # Player chooses their actions
if @decision != 0 # Battle ended, stop choosing actions if decided? # Battle ended, stop choosing actions
@command_phase = false @command_phase = false
return return
end end
@@ -201,7 +201,7 @@ class Battle
actioned = [] actioned = []
idxBattler = -1 idxBattler = -1
loop do loop do
break if @decision != 0 # Battle ended, stop choosing actions break if decided? # Battle ended, stop choosing actions
idxBattler += 1 idxBattler += 1
break if idxBattler >= @battlers.length break if idxBattler >= @battlers.length
next if !@battlers[idxBattler] || pbOwnedByPlayer?(idxBattler) != isPlayer next if !@battlers[idxBattler] || pbOwnedByPlayer?(idxBattler) != isPlayer

View File

@@ -40,7 +40,7 @@ class Battle
# Use Pursuit # Use Pursuit
@choices[b.index][3] = idxSwitcher # Change Pursuit's target @choices[b.index][3] = idxSwitcher # Change Pursuit's target
b.pbProcessTurn(@choices[b.index], false) b.pbProcessTurn(@choices[b.index], false)
break if @decision > 0 || @battlers[idxSwitcher].fainted? break if decided? || @battlers[idxSwitcher].fainted?
end end
@switching = false @switching = false
end end
@@ -55,7 +55,7 @@ class Battle
pbMessageOnRecall(b) pbMessageOnRecall(b)
# Pursuit interrupts switching # Pursuit interrupts switching
pbPursuit(b.index) pbPursuit(b.index)
return if @decision > 0 return if decided?
# Switch Pokémon # Switch Pokémon
allBattlers.each do |b2| allBattlers.each do |b2|
b2.droppedBelowHalfHP = false b2.droppedBelowHalfHP = false
@@ -84,7 +84,7 @@ class Battle
else else
next next
end end
return if @decision > 0 return if decided?
end end
pbCalculatePriority if Settings::RECALCULATE_TURN_ORDER_AFTER_SPEED_CHANGES pbCalculatePriority if Settings::RECALCULATE_TURN_ORDER_AFTER_SPEED_CHANGES
end end
@@ -118,7 +118,7 @@ class Battle
advance = b.pbProcessTurn(@choices[b.index]) advance = b.pbProcessTurn(@choices[b.index])
break if advance break if advance
end end
return if @decision > 0 return if decided?
next if advance next if advance
# Regular priority order # Regular priority order
priority.each do |b| priority.each do |b|
@@ -128,7 +128,7 @@ class Battle
advance = b.pbProcessTurn(@choices[b.index]) advance = b.pbProcessTurn(@choices[b.index])
break if advance break if advance
end end
return if @decision > 0 return if decided?
next if advance next if advance
# Quashed # Quashed
if Settings::MECHANICS_GENERATION >= 8 if Settings::MECHANICS_GENERATION >= 8
@@ -155,7 +155,7 @@ class Battle
break if advance || !moreQuash break if advance || !moreQuash
end end
end end
return if @decision > 0 return if decided?
next if advance next if advance
# Check for all done # Check for all done
priority.each do |b| priority.each do |b|
@@ -193,9 +193,9 @@ class Battle
pbAttackPhasePriorityChangeMessages pbAttackPhasePriorityChangeMessages
pbAttackPhaseCall pbAttackPhaseCall
pbAttackPhaseSwitch pbAttackPhaseSwitch
return if @decision > 0 return if decided?
pbAttackPhaseItems pbAttackPhaseItems
return if @decision > 0 return if decided?
pbAttackPhaseMegaEvolution pbAttackPhaseMegaEvolution
pbAttackPhaseMoves pbAttackPhaseMoves
end end

View File

@@ -14,6 +14,7 @@ class Battle
when :Rain then pbDisplay(_INTL("The rain stopped.")) when :Rain then pbDisplay(_INTL("The rain stopped."))
when :Sandstorm then pbDisplay(_INTL("The sandstorm subsided.")) when :Sandstorm then pbDisplay(_INTL("The sandstorm subsided."))
when :Hail then pbDisplay(_INTL("The hail stopped.")) when :Hail then pbDisplay(_INTL("The hail stopped."))
when :Snowstorm then pbDisplay(_INTL("The snow stopped."))
when :ShadowSky then pbDisplay(_INTL("The shadow sky faded.")) when :ShadowSky then pbDisplay(_INTL("The shadow sky faded."))
end end
@field.weather = :None @field.weather = :None
@@ -31,6 +32,7 @@ class Battle
when :Rain then pbDisplay(_INTL("Rain continues to fall.")) when :Rain then pbDisplay(_INTL("Rain continues to fall."))
when :Sandstorm then pbDisplay(_INTL("The sandstorm is raging.")) when :Sandstorm then pbDisplay(_INTL("The sandstorm is raging."))
when :Hail then pbDisplay(_INTL("The hail is crashing down.")) when :Hail then pbDisplay(_INTL("The hail is crashing down."))
when :Snowstorm then pbDisplay(_INTL("The snow is blowing about!"))
when :HarshSun then pbDisplay(_INTL("The sunlight is extremely harsh.")) when :HarshSun then pbDisplay(_INTL("The sunlight is extremely harsh."))
when :HeavyRain then pbDisplay(_INTL("It is raining heavily.")) when :HeavyRain then pbDisplay(_INTL("It is raining heavily."))
when :StrongWinds then pbDisplay(_INTL("The wind is strong.")) when :StrongWinds then pbDisplay(_INTL("The wind is strong."))
@@ -390,7 +392,6 @@ class Battle
(perishSongUsers.find_all { |idxBattler| !opposes?(idxBattler) }.length == perishSongUsers.length)) (perishSongUsers.find_all { |idxBattler| !opposes?(idxBattler) }.length == perishSongUsers.length))
pbJudgeCheckpoint(@battlers[perishSongUsers[0]]) pbJudgeCheckpoint(@battlers[perishSongUsers[0]])
end end
return if @decision > 0
end end
#============================================================================= #=============================================================================
@@ -675,7 +676,7 @@ class Battle
# Effects that apply to a battler that wear off after a number of rounds # Effects that apply to a battler that wear off after a number of rounds
pbEOREndBattlerEffects(priority) pbEOREndBattlerEffects(priority)
# Check for end of battle (i.e. because of Perish Song) # Check for end of battle (i.e. because of Perish Song)
if @decision > 0 if decided?
pbGainExp pbGainExp
return return
end end
@@ -702,12 +703,12 @@ class Battle
end end
end end
pbGainExp pbGainExp
return if @decision > 0 return if decided?
# Form checks # Form checks
priority.each { |battler| battler.pbCheckForm(true) } priority.each { |battler| battler.pbCheckForm(true) }
# Switch Pokémon in if possible # Switch Pokémon in if possible
pbEORSwitch pbEORSwitch
return if @decision > 0 return if decided?
# In battles with at least one side of size 3+, move battlers around if none # In battles with at least one side of size 3+, move battlers around if none
# are near to any foes # are near to any foes
pbEORShiftDistantBattlers pbEORShiftDistantBattlers

View File

@@ -190,7 +190,7 @@ class Battle::Battler
case effectiveWeather case effectiveWeather
when :Sun, :HarshSun then newForm = 1 when :Sun, :HarshSun then newForm = 1
when :Rain, :HeavyRain then newForm = 2 when :Rain, :HeavyRain then newForm = 2
when :Hail then newForm = 3 when :Hail, :Snowstorm then newForm = 3
end end
if @form != newForm if @form != newForm
@battle.pbShowAbilitySplash(self, true) @battle.pbShowAbilitySplash(self, true)
@@ -217,7 +217,7 @@ class Battle::Battler
end end
# Eiscue - Ice Face # Eiscue - Ice Face
if !ability_changed && isSpecies?(:EISCUE) && self.ability == :ICEFACE && if !ability_changed && isSpecies?(:EISCUE) && self.ability == :ICEFACE &&
@form == 1 && effectiveWeather == :Hail @form == 1 && [:Hail, :Snowstorm].include?(effectiveWeather)
@canRestoreIceFace = true # Changed form at end of round @canRestoreIceFace = true # Changed form at end of round
end end
end end

View File

@@ -10,7 +10,7 @@ class Battle::Battler
pbBeginTurn(choice) pbBeginTurn(choice)
pbSEPlay("Battle flee") pbSEPlay("Battle flee")
@battle.pbDisplay(_INTL("{1} fled from battle!", pbThis)) @battle.pbDisplay(_INTL("{1} fled from battle!", pbThis))
@battle.decision = 3 @battle.decision = Battle::Outcome::FLEE
pbEndTurn(choice) pbEndTurn(choice)
return true return true
end end
@@ -537,7 +537,7 @@ class Battle::Battler
end end
b.lastRoundMoved = oldLastRoundMoved b.lastRoundMoved = oldLastRoundMoved
@battle.pbJudge @battle.pbJudge
return if @battle.decision > 0 return if @battle.decided?
end end
b.effects[PBEffects::Instructed] = false b.effects[PBEffects::Instructed] = false
end end
@@ -573,7 +573,7 @@ class Battle::Battler
nextUser.effects[PBEffects::Outrage] = oldOutrage nextUser.effects[PBEffects::Outrage] = oldOutrage
nextUser.currentMove = oldCurrentMove nextUser.currentMove = oldCurrentMove
@battle.pbJudge @battle.pbJudge
return if @battle.decision > 0 return if @battle.decided?
end end
nextUser.effects[PBEffects::Dancer] = false nextUser.effects[PBEffects::Dancer] = false
end end

View File

@@ -261,7 +261,7 @@ end
class Battle::Move::StartHailWeather < Battle::Move::WeatherMove class Battle::Move::StartHailWeather < Battle::Move::WeatherMove
def initialize(battle, move) def initialize(battle, move)
super super
@weatherType = :Hail @weatherType = (Settings::USE_SNOWSTORM_WEATHER_INSTEAD_OF_HAIL) ? :Snowstorm : :Hail
end end
end end

View File

@@ -317,7 +317,7 @@ end
#=============================================================================== #===============================================================================
class Battle::Move::FreezeTargetAlwaysHitsInHail < Battle::Move::FreezeTarget class Battle::Move::FreezeTargetAlwaysHitsInHail < Battle::Move::FreezeTarget
def pbBaseAccuracy(user, target) def pbBaseAccuracy(user, target)
return 0 if target.effectiveWeather == :Hail return 0 if [:Hail, :Snowstorm].include?(target.effectiveWeather)
return super return super
end end
end end

View File

@@ -821,7 +821,7 @@ class Battle::Move::StartWeakenDamageAgainstUserSideIfHail < Battle::Move
def canSnatch?; return true; end def canSnatch?; return true; end
def pbMoveFailed?(user, targets) def pbMoveFailed?(user, targets)
if user.effectiveWeather != :Hail if ![:Hail, :Snowstorm].include?(user.effectiveWeather)
@battle.pbDisplay(_INTL("But it failed!")) @battle.pbDisplay(_INTL("But it failed!"))
return true return true
end end
@@ -1561,7 +1561,7 @@ class Battle::Move::TypeAndPowerDependOnWeather < Battle::Move
ret = :WATER if GameData::Type.exists?(:WATER) ret = :WATER if GameData::Type.exists?(:WATER)
when :Sandstorm when :Sandstorm
ret = :ROCK if GameData::Type.exists?(:ROCK) ret = :ROCK if GameData::Type.exists?(:ROCK)
when :Hail when :Hail, :Snowstorm
ret = :ICE if GameData::Type.exists?(:ICE) ret = :ICE if GameData::Type.exists?(:ICE)
when :ShadowSky when :ShadowSky
ret = :NONE ret = :NONE

View File

@@ -12,7 +12,7 @@ class Battle::Move::FleeFromBattle < Battle::Move
def pbEffectGeneral(user) def pbEffectGeneral(user)
@battle.pbDisplay(_INTL("{1} fled from battle!", user.pbThis)) @battle.pbDisplay(_INTL("{1} fled from battle!", user.pbThis))
@battle.decision = 3 # Escaped @battle.decision = Battle::Outcome::FLEE
end end
end end
@@ -52,7 +52,7 @@ class Battle::Move::SwitchOutUserStatusMove < Battle::Move
def pbEffectGeneral(user) def pbEffectGeneral(user)
if user.wild? if user.wild?
@battle.pbDisplay(_INTL("{1} fled from battle!", user.pbThis)) @battle.pbDisplay(_INTL("{1} fled from battle!", user.pbThis))
@battle.decision = 3 # Escaped @battle.decision = Battle::Outcome::FLEE
end end
end end
end end
@@ -196,7 +196,7 @@ class Battle::Move::SwitchOutTargetStatusMove < Battle::Move
end end
def pbEffectAgainstTarget(user, target) def pbEffectAgainstTarget(user, target)
@battle.decision = 3 if target.wild? # Escaped from battle @battle.decision = Battle::Outcome::FLEE if target.wild?
end end
def pbSwitchOutTargetEffect(user, targets, numHits, switched_battlers) def pbSwitchOutTargetEffect(user, targets, numHits, switched_battlers)
@@ -230,7 +230,7 @@ class Battle::Move::SwitchOutTargetDamagingMove < Battle::Move
if target.wild? && target.allAllies.length == 0 && @battle.canRun && if target.wild? && target.allAllies.length == 0 && @battle.canRun &&
target.level <= user.level && target.level <= user.level &&
(target.effects[PBEffects::Substitute] == 0 || ignoresSubstitute?(user)) (target.effects[PBEffects::Substitute] == 0 || ignoresSubstitute?(user))
@battle.decision = 3 # Escaped from battle @battle.decision = Battle::Outcome::FLEE
end end
end end

View File

@@ -593,7 +593,8 @@ class Battle::AI
:Sun => :HEATROCK, :Sun => :HEATROCK,
:Rain => :DAMPROCK, :Rain => :DAMPROCK,
:Sandstorm => :SMOOTHROCK, :Sandstorm => :SMOOTHROCK,
:Hail => :ICYROCK :Hail => :ICYROCK,
:Snowstorm => :ICYROCK
}[weather] }[weather]
ret += 4 if weather_extender && move_user.has_active_item?(weather_extender) ret += 4 if weather_extender && move_user.has_active_item?(weather_extender)
end end
@@ -635,6 +636,8 @@ class Battle::AI
if b.battler.takesHailDamage? # End of round damage if b.battler.takesHailDamage? # End of round damage
ret += (b.opposes?(move_user)) ? 10 : -10 ret += (b.opposes?(move_user)) ? 10 : -10
end end
when :Snowstorm
# TODO: Snowstorm AI.
when :ShadowSky when :ShadowSky
# Check for battlers affected by Shadow Sky's effects # Check for battlers affected by Shadow Sky's effects
if b.has_damaging_move_of_type?(:SHADOW) if b.has_damaging_move_of_type?(:SHADOW)
@@ -650,13 +653,14 @@ class Battle::AI
:Sun => [:CHLOROPHYLL, :FLOWERGIFT, :FORECAST, :HARVEST, :LEAFGUARD, :SOLARPOWER], :Sun => [:CHLOROPHYLL, :FLOWERGIFT, :FORECAST, :HARVEST, :LEAFGUARD, :SOLARPOWER],
:Rain => [:DRYSKIN, :FORECAST, :HYDRATION, :RAINDISH, :SWIFTSWIM], :Rain => [:DRYSKIN, :FORECAST, :HYDRATION, :RAINDISH, :SWIFTSWIM],
:Sandstorm => [:SANDFORCE, :SANDRUSH, :SANDVEIL], :Sandstorm => [:SANDFORCE, :SANDRUSH, :SANDVEIL],
:Hail => [:FORECAST, :ICEBODY, :SLUSHRUSH, :SNOWCLOAK] :Hail => [:FORECAST, :ICEBODY, :SLUSHRUSH, :SNOWCLOAK],
:Snowstorm => [:FORECAST, :ICEBODY, :SLUSHRUSH, :SNOWCLOAK]
}[weather] }[weather]
if beneficial_abilities && beneficial_abilities.length > 0 && if beneficial_abilities && beneficial_abilities.length > 0 &&
b.has_active_ability?(beneficial_abilities) b.has_active_ability?(beneficial_abilities)
ret += (b.opposes?(move_user)) ? -5 : 5 ret += (b.opposes?(move_user)) ? -5 : 5
end end
if weather == :Hail && b.ability == :ICEFACE if [:Hail, :Snowstorm].include?(weather) && b.ability == :ICEFACE
ret += (b.opposes?(move_user)) ? -5 : 5 ret += (b.opposes?(move_user)) ? -5 : 5
end end
negative_abilities = { negative_abilities = {
@@ -679,6 +683,9 @@ class Battle::AI
:Hail => ["FreezeTargetAlwaysHitsInHail", :Hail => ["FreezeTargetAlwaysHitsInHail",
"StartWeakenDamageAgainstUserSideIfHail", "StartWeakenDamageAgainstUserSideIfHail",
"TypeAndPowerDependOnWeather"], "TypeAndPowerDependOnWeather"],
:Snowstorm => ["FreezeTargetAlwaysHitsInHail",
"StartWeakenDamageAgainstUserSideIfHail",
"TypeAndPowerDependOnWeather"],
:ShadowSky => ["TypeAndPowerDependOnWeather"] :ShadowSky => ["TypeAndPowerDependOnWeather"]
}[weather] }[weather]
if beneficial_moves && beneficial_moves.length > 0 && if beneficial_moves && beneficial_moves.length > 0 &&
@@ -693,6 +700,8 @@ class Battle::AI
:Sandstorm => ["HealUserDependingOnWeather", :Sandstorm => ["HealUserDependingOnWeather",
"TwoTurnAttackOneTurnInSun"], "TwoTurnAttackOneTurnInSun"],
:Hail => ["HealUserDependingOnWeather", :Hail => ["HealUserDependingOnWeather",
"TwoTurnAttackOneTurnInSun"],
:Snowstorm => ["HealUserDependingOnWeather",
"TwoTurnAttackOneTurnInSun"] "TwoTurnAttackOneTurnInSun"]
}[weather] }[weather]
if negative_moves && negative_moves.length > 0 && if negative_moves && negative_moves.length > 0 &&

View File

@@ -76,7 +76,7 @@ class Battle::AI::AIBattler
ret += [self.totalhp / 8, 1].max if [:Sun, :HarshSun].include?(weather) && battler.takesIndirectDamage? ret += [self.totalhp / 8, 1].max if [:Sun, :HarshSun].include?(weather) && battler.takesIndirectDamage?
ret -= [self.totalhp / 8, 1].max if [:Rain, :HeavyRain].include?(weather) && battler.canHeal? ret -= [self.totalhp / 8, 1].max if [:Rain, :HeavyRain].include?(weather) && battler.canHeal?
when :ICEBODY when :ICEBODY
ret -= [self.totalhp / 16, 1].max if weather == :Hail && battler.canHeal? ret -= [self.totalhp / 16, 1].max if [:Hail, :Snowstorm].include?(weather) && battler.canHeal?
when :RAINDISH when :RAINDISH
ret -= [self.totalhp / 16, 1].max if [:Rain, :HeavyRain].include?(weather) && battler.canHeal? ret -= [self.totalhp / 16, 1].max if [:Rain, :HeavyRain].include?(weather) && battler.canHeal?
when :SOLARPOWER when :SOLARPOWER

View File

@@ -245,7 +245,7 @@ Battle::AI::Handlers::MoveEffectScore.add("StartHailWeather",
if ai.trainer.high_skill? && battle.field.weather != :None if ai.trainer.high_skill? && battle.field.weather != :None
score -= ai.get_score_for_weather(battle.field.weather, user) score -= ai.get_score_for_weather(battle.field.weather, user)
end end
score += ai.get_score_for_weather(:Hail, user, true) score += ai.get_score_for_weather((Settings::USE_SNOWSTORM_WEATHER_INSTEAD_OF_HAIL ? :Snowstorm : :Hail), user, true)
next score next score
} }
) )

View File

@@ -706,7 +706,7 @@ Battle::AI::Handlers::MoveEffectScore.add("StartWeakenSpecialDamageAgainstUserSi
Battle::AI::Handlers::MoveFailureCheck.add("StartWeakenDamageAgainstUserSideIfHail", Battle::AI::Handlers::MoveFailureCheck.add("StartWeakenDamageAgainstUserSideIfHail",
proc { |move, user, ai, battle| proc { |move, user, ai, battle|
next true if user.pbOwnSide.effects[PBEffects::AuroraVeil] > 0 next true if user.pbOwnSide.effects[PBEffects::AuroraVeil] > 0
next true if user.battler.effectiveWeather != :Hail next true if ![:Hail, :Snowstorm].include?(user.battler.effectiveWeather)
next false next false
} }
) )

View File

@@ -170,7 +170,7 @@ module Battle::CatchAndStoreMixin
end end
battler.pbReset battler.pbReset
if pbAllFainted?(battler.index) if pbAllFainted?(battler.index)
@decision = (trainerBattle?) ? 1 : 4 # Battle ended by win/capture @decision = (trainerBattle?) ? Battle::Outcome::WIN : Battle::Outcome::CATCH
end end
# Modify the Pokémon's properties because of the capture # Modify the Pokémon's properties because of the capture
if GameData::Item.get(ball).is_snag_ball? if GameData::Item.get(ball).is_snag_ball?

View File

@@ -12,11 +12,11 @@ class Battle
if @rules["selfkoclause"] if @rules["selfkoclause"]
if self.lastMoveUser < 0 if self.lastMoveUser < 0
# in extreme cases there may be no last move user # in extreme cases there may be no last move user
return 5 # game is a draw return Outcome::DRAW
elsif opposes?(self.lastMoveUser) elsif opposes?(self.lastMoveUser)
return 2 # loss return Outcome::LOSE
else else
return 1 # win return Outcome::WIN
end end
end end
return __clauses__pbDecisionOnDraw return __clauses__pbDecisionOnDraw
@@ -27,11 +27,11 @@ class Battle
if @rules["drawclause"] # NOTE: Also includes Life Orb (not implemented) if @rules["drawclause"] # NOTE: Also includes Life Orb (not implemented)
if !(move && move.function_code == "HealUserByHalfOfDamageDone") if !(move && move.function_code == "HealUserByHalfOfDamageDone")
# Not a draw if fainting occurred due to Liquid Ooze # Not a draw if fainting occurred due to Liquid Ooze
@decision = (user.opposes?) ? 1 : 2 # win / loss @decision = (user.opposes?) ? Outcome::WIN : Outcome::LOSE
end end
elsif @rules["modifiedselfdestructclause"] elsif @rules["modifiedselfdestructclause"]
if move && move.function_code == "UserFaintsExplosive" # Self-Destruct if move && move.function_code == "UserFaintsExplosive" # Self-Destruct
@decision = (user.opposes?) ? 1 : 2 # win / loss @decision = (user.opposes?) ? Outcome::WIN : Outcome::LOSE
end end
end end
end end
@@ -39,13 +39,13 @@ class Battle
def pbEndOfRoundPhase def pbEndOfRoundPhase
__clauses__pbEndOfRoundPhase __clauses__pbEndOfRoundPhase
if @rules["suddendeath"] && @decision == 0 if @rules["suddendeath"] && !decided?
p1able = pbAbleCount(0) p1able = pbAbleCount(0)
p2able = pbAbleCount(1) p2able = pbAbleCount(1)
if p1able > p2able if p1able > p2able
@decision = 1 # loss @decision = Outcome::WIN
elsif p1able < p2able elsif p1able < p2able
@decision = 2 # win @decision = Outcome::LOSE
end end
end end
end end
@@ -261,7 +261,7 @@ class Battle::Move::UserFaintsExplosive
count += @battle.pbAbleNonActiveCount(user.idxOpposingSide) count += @battle.pbAbleNonActiveCount(user.idxOpposingSide)
if count == 0 if count == 0
@battle.pbDisplay(_INTL("{1}'s team was disqualified!", user.pbThis)) @battle.pbDisplay(_INTL("{1}'s team was disqualified!", user.pbThis))
@battle.decision = (user.opposes?) ? 1 : 2 @battle.decision = (user.opposes?) ? Outcome::WIN : Outcome::LOSE
return false return false
end end
end end

View File

@@ -322,7 +322,7 @@ Battle::AbilityEffects::SpeedCalc.add(:SLOWSTART,
Battle::AbilityEffects::SpeedCalc.add(:SLUSHRUSH, Battle::AbilityEffects::SpeedCalc.add(:SLUSHRUSH,
proc { |ability, battler, mult| proc { |ability, battler, mult|
next mult * 2 if [:Hail].include?(battler.effectiveWeather) next mult * 2 if [:Hail, :Snowstorm].include?(battler.effectiveWeather)
} }
) )
@@ -376,7 +376,7 @@ Battle::AbilityEffects::OnHPDroppedBelowHalf.add(:EMERGENCYEXIT,
battle.pbHideAbilitySplash(battler) battle.pbHideAbilitySplash(battler)
pbSEPlay("Battle flee") pbSEPlay("Battle flee")
battle.pbDisplay(_INTL("{1} fled from battle!", battler.pbThis)) battle.pbDisplay(_INTL("{1} fled from battle!", battler.pbThis))
battle.decision = 3 # Escaped battle.decision = Battle::Outcome::FLEE
next true next true
end end
# In trainer battles # In trainer battles
@@ -1204,7 +1204,7 @@ Battle::AbilityEffects::AccuracyCalcFromTarget.add(:SANDVEIL,
Battle::AbilityEffects::AccuracyCalcFromTarget.add(:SNOWCLOAK, Battle::AbilityEffects::AccuracyCalcFromTarget.add(:SNOWCLOAK,
proc { |ability, mods, user, target, move, type| proc { |ability, mods, user, target, move, type|
mods[:evasion_multiplier] *= 1.25 if target.effectiveWeather == :Hail mods[:evasion_multiplier] *= 1.25 if [:Hail, :Snowstorm].include?(target.effectiveWeather)
} }
) )
@@ -2391,7 +2391,7 @@ Battle::AbilityEffects::EndOfRoundWeather.add(:DRYSKIN,
Battle::AbilityEffects::EndOfRoundWeather.add(:ICEBODY, Battle::AbilityEffects::EndOfRoundWeather.add(:ICEBODY,
proc { |ability, weather, battler, battle| proc { |ability, weather, battler, battle|
next unless weather == :Hail next if ![:Hail, :Snowstorm].include?(weather)
next if !battler.canHeal? next if !battler.canHeal?
battle.pbShowAbilitySplash(battler) battle.pbShowAbilitySplash(battler)
battler.pbRecoverHP(battler.totalhp / 16) battler.pbRecoverHP(battler.totalhp / 16)
@@ -2406,7 +2406,7 @@ Battle::AbilityEffects::EndOfRoundWeather.add(:ICEBODY,
Battle::AbilityEffects::EndOfRoundWeather.add(:ICEFACE, Battle::AbilityEffects::EndOfRoundWeather.add(:ICEFACE,
proc { |ability, weather, battler, battle| proc { |ability, weather, battler, battle|
next if weather != :Hail next if ![:Hail, :Snowstorm].include?(weather)
next if !battler.canRestoreIceFace || battler.form != 1 next if !battler.canRestoreIceFace || battler.form != 1
battle.pbShowAbilitySplash(battler) battle.pbShowAbilitySplash(battler)
if !Battle::Scene::USE_ABILITY_SPLASH if !Battle::Scene::USE_ABILITY_SPLASH
@@ -2936,7 +2936,7 @@ Battle::AbilityEffects::OnSwitchIn.add(:GRASSYSURGE,
Battle::AbilityEffects::OnSwitchIn.add(:ICEFACE, Battle::AbilityEffects::OnSwitchIn.add(:ICEFACE,
proc { |ability, battler, battle, switch_in| proc { |ability, battler, battle, switch_in|
next if !battler.isSpecies?(:EISCUE) || battler.form != 1 next if !battler.isSpecies?(:EISCUE) || battler.form != 1
next if battler.effectiveWeather != :Hail next if ![:Hail, :Snowstorm].include?(battler.effectiveWeather)
battle.pbShowAbilitySplash(battler) battle.pbShowAbilitySplash(battler)
if !Battle::Scene::USE_ABILITY_SPLASH if !Battle::Scene::USE_ABILITY_SPLASH
battle.pbDisplay(_INTL("{1}'s {2} activated!", battler.pbThis, battler.abilityName)) battle.pbDisplay(_INTL("{1}'s {2} activated!", battler.pbThis, battler.abilityName))
@@ -3145,7 +3145,7 @@ Battle::AbilityEffects::OnSwitchIn.add(:SLOWSTART,
Battle::AbilityEffects::OnSwitchIn.add(:SNOWWARNING, Battle::AbilityEffects::OnSwitchIn.add(:SNOWWARNING,
proc { |ability, battler, battle, switch_in| proc { |ability, battler, battle, switch_in|
battle.pbStartWeatherAbility(:Hail, battler) battle.pbStartWeatherAbility((Settings::USE_SNOWSTORM_WEATHER_INSTEAD_OF_HAIL ? :Snowstorm : :Hail), battler)
} }
) )

View File

@@ -1805,7 +1805,7 @@ Battle::ItemEffects::WeatherExtender.add(:HEATROCK,
Battle::ItemEffects::WeatherExtender.add(:ICYROCK, Battle::ItemEffects::WeatherExtender.add(:ICYROCK,
proc { |item, weather, duration, battler, battle| proc { |item, weather, duration, battler, battle|
next 8 if weather == :Hail next 8 if [:Hail, :Snowstorm].include?(weather)
} }
) )

View File

@@ -305,7 +305,7 @@ class SafariBattle
@time = 0 @time = 0
@environment = :None # e.g. Tall grass, cave, still water @environment = :None # e.g. Tall grass, cave, still water
@weather = :None @weather = :None
@decision = 0 @decision = Battle::Outcome::UNDECIDED
@caughtPokemon = [] @caughtPokemon = []
@player = [player] @player = [player]
@party2 = party2 @party2 = party2
@@ -316,6 +316,10 @@ class SafariBattle
@ballCount = 0 @ballCount = 0
end end
def decided?
return Battle::Outcome.decided?(@decision)
end
def disablePokeBalls=(value); end def disablePokeBalls=(value); end
def sendToBoxes=(value); end def sendToBoxes=(value); end
def defaultWeather=(value); @weather = value; end def defaultWeather=(value); @weather = value; end
@@ -447,7 +451,7 @@ class SafariBattle
pbThrowPokeBall(1, safariBall, rare, true) pbThrowPokeBall(1, safariBall, rare, true)
if @caughtPokemon.length > 0 if @caughtPokemon.length > 0
pbRecordAndStoreCaughtPokemon pbRecordAndStoreCaughtPokemon
@decision = 4 @decision = Battle::Outcome::CATCH
end end
end end
when 1 # Bait when 1 # Bait
@@ -463,22 +467,22 @@ class SafariBattle
when 3 # Run when 3 # Run
pbSEPlay("Battle flee") pbSEPlay("Battle flee")
pbDisplayPaused(_INTL("You got away safely!")) pbDisplayPaused(_INTL("You got away safely!"))
@decision = 3 @decision = Battle::Outcome::FLEE
else else
next next
end end
catchFactor = [[catchFactor, 3].max, 20].min catchFactor = [[catchFactor, 3].max, 20].min
escapeFactor = [[escapeFactor, 2].max, 20].min escapeFactor = [[escapeFactor, 2].max, 20].min
# End of round # End of round
if @decision == 0 if !decided?
if @ballCount <= 0 if @ballCount <= 0
pbSEPlay("Safari Zone end") pbSEPlay("Safari Zone end")
pbDisplay(_INTL("PA: You have no Safari Balls left! Game over!")) pbDisplay(_INTL("PA: You have no Safari Balls left! Game over!"))
@decision = 2 @decision = Battle::Outcome::LOSE
elsif pbRandom(100) < 5 * escapeFactor elsif pbRandom(100) < 5 * escapeFactor
pbSEPlay("Battle flee") pbSEPlay("Battle flee")
pbDisplay(_INTL("{1} fled!", pkmn.name)) pbDisplay(_INTL("{1} fled!", pkmn.name))
@decision = 3 @decision = Battle::Outcome::FLEE
elsif cmd == 1 # Bait elsif cmd == 1 # Bait
pbDisplay(_INTL("{1} is eating!", pkmn.name)) pbDisplay(_INTL("{1} is eating!", pkmn.name))
elsif cmd == 2 # Rock elsif cmd == 2 # Rock
@@ -490,11 +494,11 @@ class SafariBattle
weather_data = GameData::BattleWeather.try_get(@weather) weather_data = GameData::BattleWeather.try_get(@weather)
@scene.pbCommonAnimation(weather_data.animation) if weather_data @scene.pbCommonAnimation(weather_data.animation) if weather_data
end end
break if @decision > 0 break if decided?
end end
@scene.pbEndBattle(@decision) @scene.pbEndBattle(@decision)
rescue BattleAbortedException rescue BattleAbortedException
@decision = 0 @decision = Battle::Outcome::UNDECIDED
@scene.pbEndBattle(@decision) @scene.pbEndBattle(@decision)
end end
return @decision return @decision

View File

@@ -78,6 +78,6 @@ class BugContestBattle < Battle
def pbEndOfRoundPhase def pbEndOfRoundPhase
super super
@decision = 3 if @ballCount <= 0 && @decision == 0 @decision = Battle::Outcome::FLEE if @ballCount <= 0 && !decided?
end end
end end

View File

@@ -159,7 +159,7 @@ class BattlePalaceBattle < Battle
def pbEndOfRoundPhase def pbEndOfRoundPhase
super super
return if @decision != 0 return if decided?
allBattlers.each { |b| pbPinchChange(b) } allBattlers.each { |b| pbPinchChange(b) }
end end
end end

View File

@@ -56,10 +56,10 @@ class BattleArenaBattle < Battle
end end
def pbEORSwitch(favorDraws = false) def pbEORSwitch(favorDraws = false)
return if favorDraws && @decision == 5 return if favorDraws && @decision == Battle::Outcome::DRAW
return if !favorDraws && @decision > 0 return if !favorDraws && decided?
pbJudge pbJudge
return if @decision > 0 return if decided?
2.times do |side| 2.times do |side|
next if !@battlers[side].fainted? next if !@battlers[side].fainted?
next if @partyindexes[side] + 1 >= self.pbParty(side).length next if @partyindexes[side] + 1 >= self.pbParty(side).length
@@ -115,7 +115,7 @@ class BattleArenaBattle < Battle
@count = 0 @count = 0
end end
super super
return if @decision != 0 return if decided?
# Update mind rating (asserting that a move was chosen) # Update mind rating (asserting that a move was chosen)
2.times do |side| 2.times do |side|
if @choices[side][2] && @choices[side][0] == :UseMove if @choices[side][2] && @choices[side][0] == :UseMove
@@ -126,7 +126,7 @@ class BattleArenaBattle < Battle
def pbEndOfRoundPhase def pbEndOfRoundPhase
super super
return if @decision != 0 return if decided?
# Update skill rating # Update skill rating
2.times do |side| 2.times do |side|
@skill[side] += self.successStates[side].skill @skill[side] += self.successStates[side].skill

View File

@@ -77,7 +77,7 @@ end
#=============================================================================== #===============================================================================
# Blacking out animation # Blacking out animation
#=============================================================================== #===============================================================================
def pbStartOver(gameover = false) def pbStartOver(game_over = false)
if pbInBugContest? if pbInBugContest?
pbBugContestStartOver pbBugContestStartOver
return return
@@ -85,12 +85,15 @@ def pbStartOver(gameover = false)
$stats.blacked_out_count += 1 $stats.blacked_out_count += 1
$player.heal_party $player.heal_party
if $PokemonGlobal.pokecenterMapId && $PokemonGlobal.pokecenterMapId >= 0 if $PokemonGlobal.pokecenterMapId && $PokemonGlobal.pokecenterMapId >= 0
if gameover if game_over
pbMessage("\\w[]\\wm\\c[8]\\l[3]" + pbMessage("\\w[]\\wm\\c[8]\\l[3]" +
_INTL("After the unfortunate defeat, you scurry back to a Pokémon Center.")) _INTL("After the unfortunate defeat, you hurry to the Pokémon Center."))
else elsif $player.all_fainted?
pbMessage("\\w[]\\wm\\c[8]\\l[3]" + pbMessage("\\w[]\\wm\\c[8]\\l[3]" +
_INTL("You scurry back to a Pokémon Center, protecting your exhausted Pokémon from any further harm...")) _INTL("You hurry to the Pokémon Center, shielding your exhausted Pokémon from any further harm..."))
else # Forfeited a trainer battle
pbMessage("\\w[]\\wm\\c[8]\\l[3]" +
_INTL("You went running to the Pokémon Center to regroup and reconsider your battle strategy..."))
end end
pbCancelVehicles pbCancelVehicles
Followers.clear Followers.clear
@@ -112,12 +115,15 @@ def pbStartOver(gameover = false)
$player.heal_party $player.heal_party
return return
end end
if gameover if game_over
pbMessage("\\w[]\\wm\\c[8]\\l[3]" + pbMessage("\\w[]\\wm\\c[8]\\l[3]" +
_INTL("After the unfortunate defeat, you scurry back home.")) _INTL("After the unfortunate defeat, you hurry back home."))
else elsif $player.all_fainted?
pbMessage("\\w[]\\wm\\c[8]\\l[3]" + pbMessage("\\w[]\\wm\\c[8]\\l[3]" +
_INTL("You scurry back home, protecting your exhausted Pokémon from any further harm...")) _INTL("You hurry back home, shielding your exhausted Pokémon from any further harm..."))
else # Forfeited a trainer battle
pbMessage("\\w[]\\wm\\c[8]\\l[3]" +
_INTL("You went running back home to regroup and reconsider your battle strategy..."))
end end
if homedata if homedata
pbCancelVehicles pbCancelVehicles

View File

@@ -156,8 +156,8 @@ module BattleCreationHelperMethods
$PokemonGlobal.nextBattleCaptureME = nil $PokemonGlobal.nextBattleCaptureME = nil
$PokemonGlobal.nextBattleBack = nil $PokemonGlobal.nextBattleBack = nil
$PokemonEncounters.reset_step_count $PokemonEncounters.reset_step_count
outcome = 1 # Win outcome = Battle::Outcome::WIN
outcome = 0 if trainer_battle && $player.able_pokemon_count == 0 # Undecided outcome = Battle::Outcome::UNDECIDED if trainer_battle && $player.all_fainted?
pbSet(outcome_variable, outcome) pbSet(outcome_variable, outcome)
return outcome return outcome
end end
@@ -246,7 +246,7 @@ module BattleCreationHelperMethods
when :Rain, :Storm when :Rain, :Storm
battle.defaultWeather = :Rain battle.defaultWeather = :Rain
when :Hail when :Hail
battle.defaultWeather = :Hail battle.defaultWeather = (Settings::USE_SNOWSTORM_WEATHER_INSTEAD_OF_HAIL ? :Snowstorm : :Hail)
when :Sandstorm when :Sandstorm
battle.defaultWeather = :Sandstorm battle.defaultWeather = :Sandstorm
when :Sun when :Sun
@@ -311,7 +311,7 @@ module BattleCreationHelperMethods
pkmn.makeUnprimal pkmn.makeUnprimal
end end
end end
if [2, 5].include?(outcome) && can_lose # if loss or draw if Battle::Outcome.should_black_out?(outcome) && can_lose
$player.party.each { |pkmn| pkmn.heal } $player.party.each { |pkmn| pkmn.heal }
timer_start = System.uptime timer_start = System.uptime
until System.uptime - timer_start >= 0.25 until System.uptime - timer_start >= 0.25
@@ -331,10 +331,10 @@ module BattleCreationHelperMethods
# 5 - Draw # 5 - Draw
def set_outcome(outcome, outcome_variable = 1, trainer_battle = false) def set_outcome(outcome, outcome_variable = 1, trainer_battle = false)
case outcome case outcome
when 1, 4 # Won, caught when Battle::Outcome::WIN, Battle::Outcome::CATCH
$stats.wild_battles_won += 1 if !trainer_battle $stats.wild_battles_won += 1 if !trainer_battle
$stats.trainer_battles_won += 1 if trainer_battle $stats.trainer_battles_won += 1 if trainer_battle
when 2, 3, 5 # Lost, fled, draw when Battle::Outcome::LOSE, Battle::Outcome::FLEE, Battle::Outcome::DRAW
$stats.wild_battles_lost += 1 if !trainer_battle $stats.wild_battles_lost += 1 if !trainer_battle
$stats.trainer_battles_lost += 1 if trainer_battle $stats.trainer_battles_lost += 1 if trainer_battle
end end
@@ -363,7 +363,7 @@ class WildBattle
EventHandlers.trigger(:on_wild_battle_end, foe_party[0].species, foe_party[0].level, outcome) EventHandlers.trigger(:on_wild_battle_end, foe_party[0].species, foe_party[0].level, outcome)
end end
# Return false if the player lost or drew the battle, and true if any other result # Return false if the player lost or drew the battle, and true if any other result
return outcome != 2 && outcome != 5 return !Battle::Outcome.should_black_out?(outcome)
end end
def self.start_core(*args) def self.start_core(*args)
@@ -391,7 +391,7 @@ class WildBattle
BattleCreationHelperMethods.prepare_battle(battle) BattleCreationHelperMethods.prepare_battle(battle)
$game_temp.clear_battle_rules $game_temp.clear_battle_rules
# Perform the battle itself # Perform the battle itself
outcome = 0 outcome = Battle::Outcome::UNDECIDED
pbBattleAnimation(pbGetWildBattleBGM(foe_party), (foe_party.length == 1) ? 0 : 2, foe_party) do pbBattleAnimation(pbGetWildBattleBGM(foe_party), (foe_party.length == 1) ? 0 : 2, foe_party) do
pbSceneStandby { outcome = battle.pbStartBattle } pbSceneStandby { outcome = battle.pbStartBattle }
BattleCreationHelperMethods.after_battle(outcome, can_lose) BattleCreationHelperMethods.after_battle(outcome, can_lose)
@@ -481,7 +481,7 @@ class TrainerBattle
outcome = TrainerBattle.start_core(*args) outcome = TrainerBattle.start_core(*args)
end end
# Return true if the player won the battle, and false if any other result # Return true if the player won the battle, and false if any other result
return outcome == 1 return outcome == Battle::Outcome::WIN
end end
def self.start_core(*args) def self.start_core(*args)
@@ -511,7 +511,7 @@ class TrainerBattle
BattleCreationHelperMethods.prepare_battle(battle) BattleCreationHelperMethods.prepare_battle(battle)
$game_temp.clear_battle_rules $game_temp.clear_battle_rules
# Perform the battle itself # Perform the battle itself
outcome = 0 outcome = Battle::Outcome::UNDECIDED
pbBattleAnimation(pbGetTrainerBattleBGM(foe_trainers), (battle.singleBattle?) ? 1 : 3, foe_trainers) do pbBattleAnimation(pbGetTrainerBattleBGM(foe_trainers), (battle.singleBattle?) ? 1 : 3, foe_trainers) do
pbSceneStandby { outcome = battle.pbStartBattle } pbSceneStandby { outcome = battle.pbStartBattle }
BattleCreationHelperMethods.after_battle(outcome, can_lose) BattleCreationHelperMethods.after_battle(outcome, can_lose)
@@ -600,20 +600,20 @@ end
# After battles # After battles
#=============================================================================== #===============================================================================
EventHandlers.add(:on_end_battle, :evolve_and_black_out, EventHandlers.add(:on_end_battle, :evolve_and_black_out,
proc { |decision, canLose| proc { |outcome, canLose|
# Check for evolutions # Check for evolutions
pbEvolutionCheck if Settings::CHECK_EVOLUTION_AFTER_ALL_BATTLES || pbEvolutionCheck if Settings::CHECK_EVOLUTION_AFTER_ALL_BATTLES ||
(decision != 2 && decision != 5) # not a loss or a draw !Battle::Outcome.should_black_out?(outcome)
$game_temp.party_levels_before_battle = nil $game_temp.party_levels_before_battle = nil
# Check for blacking out or gaining Pickup/Huney Gather items # Check for blacking out or gaining Pickup/Huney Gather items
case decision case outcome
when 1, 4 # Win, capture when Battle::Outcome::WIN, Battle::Outcome::CATCH
$player.pokemon_party.each do |pkmn| $player.pokemon_party.each do |pkmn|
pbPickup(pkmn) pbPickup(pkmn)
pbHoneyGather(pkmn) pbHoneyGather(pkmn)
end end
when 2, 5 # Lose, draw else
if !canLose if Battle::Outcome.should_black_out?(outcome) && !canLose
$game_system.bgm_unpause $game_system.bgm_unpause
$game_system.bgs_unpause $game_system.bgs_unpause
pbStartOver pbStartOver

View File

@@ -386,7 +386,9 @@ def pbGenerateWildPokemon(species, level, isRoamer = false)
items = genwildpoke.wildHoldItems items = genwildpoke.wildHoldItems
first_pkmn = $player.first_pokemon first_pkmn = $player.first_pokemon
chances = [50, 5, 1] chances = [50, 5, 1]
if first_pkmn if Settings::MECHANICS_GENERATION >= 9
chances[0] = 30
elsif first_pkmn
case first_pkmn.ability_id case first_pkmn.ability_id
when :COMPOUNDEYES when :COMPOUNDEYES
chances = [60, 20, 5] chances = [60, 20, 5]

View File

@@ -212,17 +212,17 @@ def pbRoamingPokemonBattle(pkmn, level = 1)
setBattleRule("single") setBattleRule("single")
setBattleRule("roamerFlees") setBattleRule("roamerFlees")
# Perform the battle # Perform the battle
decision = WildBattle.start_core($PokemonGlobal.roamPokemon[idxRoamer]) outcome = WildBattle.start_core($PokemonGlobal.roamPokemon[idxRoamer])
# Update Roaming Pokémon data based on result of battle # Update Roaming Pokémon data based on result of battle
if [1, 4].include?(decision) # Defeated or caught if [Battle::Outcome::WIN, Battle::Outcome::CATCH].include?(outcome) # Defeated or caught
$PokemonGlobal.roamPokemon[idxRoamer] = true $PokemonGlobal.roamPokemon[idxRoamer] = true
$PokemonGlobal.roamPokemonCaught[idxRoamer] = (decision == 4) $PokemonGlobal.roamPokemonCaught[idxRoamer] = (outcome == Battle::Outcome::CATCH)
end end
$PokemonGlobal.roamEncounter = nil $PokemonGlobal.roamEncounter = nil
$PokemonGlobal.roamedAlready = true $PokemonGlobal.roamedAlready = true
$game_temp.roamer_index_for_encounter = nil $game_temp.roamer_index_for_encounter = nil
# Used by the Poké Radar to update/break the chain # Used by the Poké Radar to update/break the chain
EventHandlers.trigger(:on_wild_battle_end, pkmn.species_data.id, pkmn.level, decision) EventHandlers.trigger(:on_wild_battle_end, pkmn.species_data.id, pkmn.level, outcome)
# Return false if the player lost or drew the battle, and true if any other result # Return false if the player lost or drew the battle, and true if any other result
return (decision != 2 && decision != 5) return !Battle::Outcome.should_black_out?(outcome)
end end

View File

@@ -52,11 +52,7 @@ ItemHandlers::CanUseInBattle.addIf(:poke_balls,
# this case, but only in trainer battles, and the trainer will deflect # this case, but only in trainer battles, and the trainer will deflect
# them if they are trying to catch a non-Shadow Pokémon.) # them if they are trying to catch a non-Shadow Pokémon.)
if battle.pbOpposingBattlerCount > 1 && !(GameData::Item.get(item).is_snag_ball? && battle.trainerBattle?) if battle.pbOpposingBattlerCount > 1 && !(GameData::Item.get(item).is_snag_ball? && battle.trainerBattle?)
if battle.pbOpposingBattlerCount == 2 scene.pbDisplay(_INTL("It's no good! It's impossible to aim unless there is only one Pokémon!")) if showMessages
scene.pbDisplay(_INTL("It's no good! It's impossible to aim when there are two Pokémon!")) if showMessages
elsif showMessages
scene.pbDisplay(_INTL("It's no good! It's impossible to aim when there is more than one Pokémon!"))
end
next false next false
end end
next true next true
@@ -306,7 +302,7 @@ ItemHandlers::UseInBattle.add(:GUARDSPEC, proc { |item, battler, battle|
}) })
ItemHandlers::UseInBattle.add(:POKEDOLL, proc { |item, battler, battle| ItemHandlers::UseInBattle.add(:POKEDOLL, proc { |item, battler, battle|
battle.decision = 3 battle.decision = Battle::Outcome::FLEE
battle.pbDisplayPaused(_INTL("You got away safely!")) battle.pbDisplayPaused(_INTL("You got away safely!"))
}) })

View File

@@ -221,14 +221,14 @@ EventHandlers.add(:on_wild_pokemon_created, :poke_radar_shiny,
) )
EventHandlers.add(:on_wild_battle_end, :poke_radar_continue_chain, EventHandlers.add(:on_wild_battle_end, :poke_radar_continue_chain,
proc { |species, level, decision| proc { |species, level, outcome|
if $game_temp.poke_radar_data && [1, 4].include?(decision) # Defeated/caught if $game_temp.poke_radar_data && [Battle::Outcome::WIN, Battle::Outcome::CATCH].include?(outcome)
$game_temp.poke_radar_data[0] = species $game_temp.poke_radar_data[0] = species
$game_temp.poke_radar_data[1] = level $game_temp.poke_radar_data[1] = level
$game_temp.poke_radar_data[2] += 1 $game_temp.poke_radar_data[2] += 1
$stats.poke_radar_longest_chain = [$game_temp.poke_radar_data[2], $stats.poke_radar_longest_chain].max $stats.poke_radar_longest_chain = [$game_temp.poke_radar_data[2], $stats.poke_radar_longest_chain].max
# Catching makes the next Radar encounter more likely to continue the chain # Catching makes the next Radar encounter more likely to continue the chain
$game_temp.poke_radar_data[4] = (decision == 4) $game_temp.poke_radar_data[4] = (outcome == Battle::Outcome::CATCH)
pbPokeRadarHighlightGrass(false) pbPokeRadarHighlightGrass(false)
else else
pbPokeRadarCancel pbPokeRadarCancel

View File

@@ -747,6 +747,12 @@ MultipleForms.register(:CALYREX, {
} }
}) })
MultipleForms.register(:BASCULEGION, {
"getForm" => proc { |pkmn|
next (pkmn.female?) ? 3 : 2
}
})
MultipleForms.register(:LECHONK, { MultipleForms.register(:LECHONK, {
"getForm" => proc { |pkmn| "getForm" => proc { |pkmn|
next pkmn.gender next pkmn.gender

View File

@@ -432,7 +432,7 @@ EventHandlers.add(:on_start_battle, :record_party_heart_gauges,
) )
EventHandlers.add(:on_end_battle, :check_ready_to_purify, EventHandlers.add(:on_end_battle, :check_ready_to_purify,
proc { |_decision, _canLose| proc { |_outcome, _canLose|
$game_temp.party_heart_gauges_before_battle.each_with_index do |value, i| $game_temp.party_heart_gauges_before_battle.each_with_index do |value, i|
pkmn = $player.party[i] pkmn = $player.party[i]
next if !pkmn || !value || value == 0 next if !pkmn || !value || value == 0

View File

@@ -205,7 +205,7 @@ class BattleChallengeData
def pbStart(t, numRounds) def pbStart(t, numRounds)
@inProgress = true @inProgress = true
@resting = false @resting = false
@decision = 0 @decision = Battle::Outcome::UNDECIDED
@swaps = t.currentSwaps @swaps = t.currentSwaps
@wins = t.currentWins @wins = t.currentWins
@battleNumber = 1 @battleNumber = 1
@@ -251,7 +251,7 @@ class BattleChallengeData
end end
def pbMatchOver? def pbMatchOver?
return true if !@inProgress || @decision != 0 return true if !@inProgress || @decision != Battle::Outcome::UNDECIDED
return @battleNumber > @numRounds return @battleNumber > @numRounds
end end
@@ -275,7 +275,7 @@ class BattleChallengeData
def pbEnd def pbEnd
$player.party = @oldParty $player.party = @oldParty
return if !@inProgress return if !@inProgress
save = (@decision != 0) save = (@decision != Battle::Outcome::UNDECIDED)
reset reset
$game_map.need_refresh = true $game_map.need_refresh = true
Game.save(safe: true) if save Game.save(safe: true) if save
@@ -293,7 +293,7 @@ class BattleChallengeData
@inProgress = false @inProgress = false
@resting = false @resting = false
@start = nil @start = nil
@decision = 0 @decision = Battle::Outcome::UNDECIDED
@wins = 0 @wins = 0
@swaps = 0 @swaps = 0
@battleNumber = 0 @battleNumber = 0
@@ -343,11 +343,11 @@ class BattleChallengeType
end end
def saveWins(challenge) def saveWins(challenge)
if challenge.decision == 0 # if undecided if challenge.decision == Battle::Outcome::UNDECIDED
@currentWins = 0 @currentWins = 0
@currentSwaps = 0 @currentSwaps = 0
else else
if challenge.decision == 1 # if won if challenge.decision == Battle::Outcome::WIN
@currentWins = challenge.wins @currentWins = challenge.wins
@currentSwaps = challenge.swaps @currentSwaps = challenge.swaps
else # if lost else # if lost

View File

@@ -61,9 +61,9 @@ def pbOrganizedBattleEx(opponent, challengedata)
# Set various other properties in the battle class # Set various other properties in the battle class
BattleCreationHelperMethods.prepare_battle(battle) BattleCreationHelperMethods.prepare_battle(battle)
# Perform the battle itself # Perform the battle itself
decision = 0 outcome = Battle::Outcome::UNDECIDED
pbBattleAnimation(pbGetTrainerBattleBGM(opponent)) do pbBattleAnimation(pbGetTrainerBattleBGM(opponent)) do
pbSceneStandby { decision = battle.pbStartBattle } pbSceneStandby { outcome = battle.pbStartBattle }
end end
Input.update Input.update
# Restore both parties to their original levels # Restore both parties to their original levels
@@ -83,17 +83,17 @@ def pbOrganizedBattleEx(opponent, challengedata)
end end
# Save the record of the battle # Save the record of the battle
$game_temp.last_battle_record = nil $game_temp.last_battle_record = nil
if [1, 2, 5].include?(decision) # if win, loss or draw if [Battle::Outcome::WIN, Battle::Outcome::LOSE, Battle::Outcome::DRAW].include?(outcome)
$game_temp.last_battle_record = battle.pbDumpRecord $game_temp.last_battle_record = battle.pbDumpRecord
end end
case decision case outcome
when 1 # Won when Battle::Outcome::WIN # Won
$stats.trainer_battles_won += 1 $stats.trainer_battles_won += 1
when 2, 3, 5 # Lost, fled, draw when Battle::Outcome::LOSE, Battle::Outcome::FLEE, Battle::Outcome::DRAW
$stats.trainer_battles_lost += 1 $stats.trainer_battles_lost += 1
end end
# Return true if the player won the battle, and false if any other result # Return true if the player won the battle, and false if any other result
return (decision == 1) return (outcome == Battle::Outcome::WIN)
end end
#=============================================================================== #===============================================================================

View File

@@ -128,15 +128,15 @@ def pbSafariBattle(pkmn, level = 1)
battle.ballCount = pbSafariState.ballcount battle.ballCount = pbSafariState.ballcount
BattleCreationHelperMethods.prepare_battle(battle) BattleCreationHelperMethods.prepare_battle(battle)
# Perform the battle itself # Perform the battle itself
decision = 0 outcome = Battle::Outcome::UNDECIDED
pbBattleAnimation(pbGetWildBattleBGM(foeParty), 0, foeParty) do pbBattleAnimation(pbGetWildBattleBGM(foeParty), 0, foeParty) do
pbSceneStandby { decision = battle.pbStartBattle } pbSceneStandby { outcome = battle.pbStartBattle }
end end
Input.update Input.update
# Update Safari game data based on result of battle # Update Safari game data based on result of battle
pbSafariState.ballcount = battle.ballCount pbSafariState.ballcount = battle.ballCount
if pbSafariState.ballcount <= 0 if pbSafariState.ballcount <= 0
if decision != 2 # Last Safari Ball was used to catch the wild Pokémon if outcome != Battle::Outcome::LOSE # Last Safari Ball was used to catch the wild Pokémon
pbMessage(_INTL("Announcer: You're out of Safari Balls! Game over!")) pbMessage(_INTL("Announcer: You're out of Safari Balls! Game over!"))
end end
pbSafariState.decision = 1 pbSafariState.decision = 1
@@ -147,16 +147,16 @@ def pbSafariBattle(pkmn, level = 1)
# 2 - Player ran out of Safari Balls # 2 - Player ran out of Safari Balls
# 3 - Player or wild Pokémon ran from battle, or player forfeited the match # 3 - Player or wild Pokémon ran from battle, or player forfeited the match
# 4 - Wild Pokémon was caught # 4 - Wild Pokémon was caught
if decision == 4 if outcome == Battle::Outcome::CATCH
$stats.safari_pokemon_caught += 1 $stats.safari_pokemon_caught += 1
pbSafariState.captures += 1 pbSafariState.captures += 1
$stats.most_captures_per_safari_game = [$stats.most_captures_per_safari_game, pbSafariState.captures].max $stats.most_captures_per_safari_game = [$stats.most_captures_per_safari_game, pbSafariState.captures].max
end end
pbSet(1, decision) pbSet(1, outcome)
# Used by the Poké Radar to update/break the chain # Used by the Poké Radar to update/break the chain
EventHandlers.trigger(:on_wild_battle_end, pkmn.species_data.id, pkmn.level, decision) EventHandlers.trigger(:on_wild_battle_end, pkmn.species_data.id, pkmn.level, outcome)
# Return the outcome of the battle # Return the outcome of the battle
return decision return outcome
end end
#=============================================================================== #===============================================================================

View File

@@ -378,11 +378,11 @@ def pbBugContestBattle(pkmn, level = 1)
setBattleRule("single") setBattleRule("single")
BattleCreationHelperMethods.prepare_battle(battle) BattleCreationHelperMethods.prepare_battle(battle)
# Perform the battle itself # Perform the battle itself
decision = 0 outcome = Battle::Outcome::UNDECIDED
pbBattleAnimation(pbGetWildBattleBGM(foeParty), 0, foeParty) do pbBattleAnimation(pbGetWildBattleBGM(foeParty), 0, foeParty) do
decision = battle.pbStartBattle outcome = battle.pbStartBattle
BattleCreationHelperMethods.after_battle(decision, true) BattleCreationHelperMethods.after_battle(outcome, true)
if [2, 5].include?(decision) # Lost or drew if Battle::Outcome.should_black_out?(outcome)
$game_system.bgm_unpause $game_system.bgm_unpause
$game_system.bgs_unpause $game_system.bgs_unpause
pbBugContestStartOver pbBugContestStartOver
@@ -392,15 +392,15 @@ def pbBugContestBattle(pkmn, level = 1)
# Update Bug Contest game data based on result of battle # Update Bug Contest game data based on result of battle
pbBugContestState.ballcount = battle.ballCount pbBugContestState.ballcount = battle.ballCount
if pbBugContestState.ballcount == 0 if pbBugContestState.ballcount == 0
pbMessage(_INTL("ANNOUNCER: The Bug-Catching Contest is over!")) pbMessage(_INTL("ANNOUNCER: The Bug-Catching Contest is over!"))
pbBugContestState.pbStartJudging pbBugContestState.pbStartJudging
end end
# Save the result of the battle in Game Variable 1 # Save the result of the battle in Game Variable 1
BattleCreationHelperMethods.set_outcome(decision, 1) BattleCreationHelperMethods.set_outcome(outcome, 1)
# Used by the Poké Radar to update/break the chain # Used by the Poké Radar to update/break the chain
EventHandlers.trigger(:on_wild_battle_end, pkmn.species_data.id, pkmn.level, decision) EventHandlers.trigger(:on_wild_battle_end, pkmn.species_data.id, pkmn.level, outcome)
# Return false if the player lost or drew the battle, and true if any other result # Return false if the player lost or drew the battle, and true if any other result
return (decision != 2 && decision != 5) return !Battle::Outcome.should_black_out?(outcome)
end end
#=============================================================================== #===============================================================================

View File

@@ -364,10 +364,10 @@ def pbDecideWinner(party0, party1, rating0, rating1)
score0 = pbDecideWinnerScore(party0, party1, rating0) score0 = pbDecideWinnerScore(party0, party1, rating0)
score1 = pbDecideWinnerScore(party1, party0, rating1) score1 = pbDecideWinnerScore(party1, party0, rating1)
if score0 == score1 if score0 == score1
return 5 if rating0 == rating1 return Battle::Outcome::DRAW if rating0 == rating1
return (rating0 > rating1) ? 1 : 2 return (rating0 > rating1) ? Battle::Outcome::WIN : Battle::Outcome::LOSE
else else
return (score0 > score1) ? 1 : 2 return (score0 > score1) ? Battle::Outcome::WIN : Battle::Outcome::LOSE
end end
end end
@@ -375,7 +375,7 @@ end
# #
#=============================================================================== #===============================================================================
def pbRuledBattle(team1, team2, rule) def pbRuledBattle(team1, team2, rule)
decision = 0 outcome = Battle::Outcome::UNDECIDED
if rand(100) == 0 if rand(100) == 0
level = rule.ruleset.suggestedLevel level = rule.ruleset.suggestedLevel
t_type = GameData::TrainerType.keys.first t_type = GameData::TrainerType.keys.first
@@ -406,7 +406,7 @@ def pbRuledBattle(team1, team2, rule)
battle.debug = true battle.debug = true
battle.controlPlayer = true battle.controlPlayer = true
battle.internalBattle = false battle.internalBattle = false
decision = battle.pbStartBattle outcome = battle.pbStartBattle
team1.team.each_with_index do |p, i| team1.team.each_with_index do |p, i|
next if !p next if !p
p.heal p.heal
@@ -422,13 +422,13 @@ def pbRuledBattle(team1, team2, rule)
party2 = [] party2 = []
team1.length.times { |i| party1.push(team1[i]) } team1.length.times { |i| party1.push(team1[i]) }
team2.length.times { |i| party2.push(team2[i]) } team2.length.times { |i| party2.push(team2[i]) }
decision = pbDecideWinner(party1, party2, team1.rating, team2.rating) outcome = pbDecideWinner(party1, party2, team1.rating, team2.rating)
end end
case decision case outcome
when 1 # Team 1 wins when Battle::Outcome::WIN # Team 1 wins
team1.addMatch(team2, 1) team1.addMatch(team2, 1)
team2.addMatch(team1, 0) team2.addMatch(team1, 0)
when 2 # Team 2 wins when Battle::Outcome::LOSE # Team 2 wins
team1.addMatch(team2, 0) team1.addMatch(team2, 0)
team2.addMatch(team1, 1) team2.addMatch(team1, 1)
else else