Fixed rare bug in disobedience check

This commit is contained in:
Maruno17
2021-12-28 22:14:56 +00:00
parent 3e9d3b0a68
commit 01ce5d347c

View File

@@ -109,22 +109,22 @@ class Battle::Battler
return true if !@battle.pbOwnedByPlayer?(@index) return true if !@battle.pbOwnedByPlayer?(@index)
disobedient = false disobedient = false
# Pokémon may be disobedient; calculate if it is # Pokémon may be disobedient; calculate if it is
badge_level = 10 * (@battle.pbPlayer.badge_count + 1)
badge_level = GameData::GrowthRate.max_level if @battle.pbPlayer.badge_count >= 8
if Settings::ANY_HIGH_LEVEL_POKEMON_CAN_DISOBEY || if Settings::ANY_HIGH_LEVEL_POKEMON_CAN_DISOBEY ||
(Settings::FOREIGN_HIGH_LEVEL_POKEMON_CAN_DISOBEY && @pokemon.foreign?(@battle.pbPlayer)) (Settings::FOREIGN_HIGH_LEVEL_POKEMON_CAN_DISOBEY && @pokemon.foreign?(@battle.pbPlayer))
badgeLevel = 10 * (@battle.pbPlayer.badge_count + 1) if @level > badge_level
badgeLevel = GameData::GrowthRate.max_level if @battle.pbPlayer.badge_count >= 8 a = ((@level + badge_level) * @battle.pbRandom(256) / 256).floor
if @level > badgeLevel disobedient |= (a >= badge_level)
a = ((@level + badgeLevel) * @battle.pbRandom(256) / 256).floor
disobedient |= (a >= badgeLevel)
end end
end end
disobedient |= !pbHyperModeObedience(choice[2]) disobedient |= !pbHyperModeObedience(choice[2])
return true if !disobedient return true if !disobedient
# Pokémon is disobedient; make it do something else # Pokémon is disobedient; make it do something else
return pbDisobey(choice, badgeLevel) return pbDisobey(choice, badge_level)
end end
def pbDisobey(choice, badgeLevel) def pbDisobey(choice, badge_level)
move = choice[2] move = choice[2]
PBDebug.log("[Disobedience] #{pbThis} disobeyed") PBDebug.log("[Disobedience] #{pbThis} disobeyed")
@effects[PBEffects::Rage] = false @effects[PBEffects::Rage] = false
@@ -133,9 +133,9 @@ class Battle::Battler
@battle.pbDisplay(_INTL("{1} ignored orders and kept sleeping!", pbThis)) @battle.pbDisplay(_INTL("{1} ignored orders and kept sleeping!", pbThis))
return false return false
end end
b = ((@level + badgeLevel) * @battle.pbRandom(256) / 256).floor b = ((@level + badge_level) * @battle.pbRandom(256) / 256).floor
# Use another move # Use another move
if b < badgeLevel if b < badge_level
@battle.pbDisplay(_INTL("{1} ignored orders!", pbThis)) @battle.pbDisplay(_INTL("{1} ignored orders!", pbThis))
return false if !@battle.pbCanShowFightMenu?(@index) return false if !@battle.pbCanShowFightMenu?(@index)
otherMoves = [] otherMoves = []
@@ -150,7 +150,7 @@ class Battle::Battler
choice[3] = -1 choice[3] = -1
return true return true
end end
c = @level - badgeLevel c = @level - badge_level
r = @battle.pbRandom(256) r = @battle.pbRandom(256)
# Fall asleep # Fall asleep
if r < c && pbCanSleep?(self, false) if r < c && pbCanSleep?(self, false)