Fixes for Battle Arena

This commit is contained in:
Maruno17
2021-05-04 21:30:26 +01:00
parent 3d88b85f56
commit 6efca2f9a8
5 changed files with 113 additions and 105 deletions

View File

@@ -74,6 +74,10 @@ class Window
attr_reader :openness
attr_reader :stretch
def inspect
return self.to_s.chop + ">"
end
def windowskin
@_windowskin
end

View File

@@ -88,10 +88,10 @@ class PokeBattle_Battler
# Pursuit was used specially to intercept a switching foe.
# Cancels the use of multi-turn moves and counters thereof. Note that Hyper
# Beam's effect is NOT cancelled.
def pbCancelMoves
def pbCancelMoves(full_cancel = false)
# Outragers get confused anyway if they are disrupted during their final
# turn of using the move
if @effects[PBEffects::Outrage]==1 && pbCanConfuseSelf?(false)
if @effects[PBEffects::Outrage]==1 && pbCanConfuseSelf?(false) && !full_cancel
pbConfuse(_INTL("{1} became confused due to fatigue!",pbThis))
end
# Cancel usage of most multi-turn moves

View File

@@ -1,3 +1,37 @@
#===============================================================================
# Success state
#===============================================================================
class PokeBattle_SuccessState
attr_accessor :typeMod
attr_accessor :useState # 0 - not used, 1 - failed, 2 - succeeded
attr_accessor :protected
attr_accessor :skill
def initialize; clear; end
def clear(full=true)
@typeMod = Effectiveness::NORMAL_EFFECTIVE
@useState = 0
@protected = false
@skill = 0 if full
end
def updateSkill
if @useState==1
@skill = -2 if !@protected
elsif @useState==2
if Effectiveness.super_effective?(@typeMod); @skill = 2
elsif Effectiveness.normal?(@typeMod); @skill = 1
elsif Effectiveness.not_very_effective?(@typeMod); @skill = -1
else; @skill = -2 # Ineffective
end
end
clear(false)
end
end
#===============================================================================
#
#===============================================================================
@@ -94,15 +128,18 @@ class PokeBattle_BattleArena < PokeBattle_Battle
def pbEndOfRoundPhase
super
return if @decision != 0
@count += 1
# Update skill rating
for side in 0...2
@skill[side] += self.successStates[side].skill_level
@skill[side] += self.successStates[side].skill
end
# PBDebug.log("[Mind: #{@mind.inspect}, Skill: #{@skill.inspect}]")
if @count==3
@battlers[0].pbCancelMoves
@battlers[1].pbCancelMoves
# Increment turn counter
@count += 1
return if @count < 3
# Half all multi-turn moves
@battlers[0].pbCancelMoves(true)
@battlers[1].pbCancelMoves(true)
# Calculate scores in each category
ratings1 = [0, 0, 0]
ratings2 = [0, 0, 0]
if @mind[0] == @mind[1]
@@ -132,12 +169,13 @@ class PokeBattle_BattleArena < PokeBattle_Battle
else
ratings2[2] = 2
end
# Show scores
@scene.pbBattleArenaJudgment(@battlers[0], @battlers[1], ratings1.clone, ratings2.clone)
# Calculate total scores
points = [0, 0]
for i in 0...ratings1.length
points[0] += ratings1[i]
points[1] += ratings2[i]
end
ratings1.each { |val| points[0] += val }
ratings2.each { |val| points[1] += val }
# Make judgment
if points[0] == points[1]
pbDisplay(_INTL("{1} tied the opponent\n{2} in a referee's decision!",
@battlers[0].name, @battlers[1].name))
@@ -162,7 +200,6 @@ class PokeBattle_BattleArena < PokeBattle_Battle
pbEORSwitch
end
end
end
@@ -305,8 +342,8 @@ class PokeBattle_Scene
ensure
pbDisposeMessageWindow(msgwindow)
dimmingvp.dispose
infowindow.contents.dispose
infowindow.dispose
infowindow.contents.dispose if infowindow && infowindow.contents
infowindow.dispose if infowindow
end
end
end

View File

@@ -48,37 +48,3 @@ class PokeBattle_DamageState
@berryWeakened = false
end
end
################################################################################
# Success state (used for Battle Arena)
################################################################################
class PokeBattle_SuccessState
attr_accessor :typeMod
attr_accessor :useState # 0 - not used, 1 - failed, 2 - succeeded
attr_accessor :protected
attr_accessor :skill
def initialize; clear; end
def clear(full=true)
@typeMod = Effectiveness::NORMAL_EFFECTIVE
@useState = 0
@protected = false
@skill = 0 if full
end
def updateSkill
if @useState==1
@skill = -2 if !@protected
elsif @useState==2
if Effectiveness.super_effective?(@typeMod); @skill = 2
elsif Effectiveness.normal?(@typeMod); @skill = 1
elsif Effectiveness.not_very_effective?(@typeMod); @skill = -1
else; @skill = -2 # Ineffective
end
end
clear(false)
end
end

View File

@@ -159,9 +159,10 @@ class PBPokemon
pokemon.nature = nature
pokemon.happiness=0
pokemon.moves[0] = Pokemon::Move.new(self.convertMove(@move1))
pokemon.moves[1] = Pokemon::Move.new(self.convertMove(@move2))
pokemon.moves[2] = Pokemon::Move.new(self.convertMove(@move3))
pokemon.moves[3] = Pokemon::Move.new(self.convertMove(@move4))
pokemon.moves[1] = (@move2) ? Pokemon::Move.new(self.convertMove(@move2)) : nil
pokemon.moves[2] = (@move3) ? Pokemon::Move.new(self.convertMove(@move3)) : nil
pokemon.moves[3] = (@move4) ? Pokemon::Move.new(self.convertMove(@move4)) : nil
pokemon.moves.compact!
if ev.length > 0
ev.each { |stat| pokemon.ev[stat] = Pokemon::EV_LIMIT / ev.length }
end