Fixed Pokédex showing genders for the wrong species, fixed AI always switching sleeping/frozen Pokémon, fixed class PngAnimatedBitmap animating slowly

This commit is contained in:
Maruno17
2023-08-23 21:08:32 +01:00
parent ea7b5d56d2
commit efea53aa5a
5 changed files with 12 additions and 9 deletions

View File

@@ -48,14 +48,14 @@ class PngAnimatedBitmap
if filename[/^\[(\d+)(?:,(\d+))?\]/] # Starts with 1 or 2 numbers in brackets
# File has a frame count
numFrames = $1.to_i
duration = $2.to_i
duration = $2.to_i # In 1/20ths of a second
duration = 5 if duration == 0
raise "Invalid frame count in #{filename}" if numFrames <= 0
raise "Invalid frame duration in #{filename}" if duration <= 0
if panorama.width % numFrames != 0
raise "Bitmap's width (#{panorama.width}) is not divisible by frame count: #{filename}"
end
@frame_duration = duration
@frame_duration = duration / 20.0
subWidth = panorama.width / numFrames
numFrames.times do |i|
subBitmap = Bitmap.new(subWidth, panorama.height)
@@ -99,7 +99,7 @@ class PngAnimatedBitmap
# Actually returns the total number of 1/20ths of a second this animation lasts.
def totalFrames
return @frame_duration * @frames.length
return (@frame_duration * @frames.length * 20).to_i
end
def each

View File

@@ -408,8 +408,10 @@ Battle::AI::Handlers::ShouldSwitch.add(:asleep,
end
# Doesn't have sufficiently raised stats that would be lost by switching
next false if battler.stages.any? { |key, val| val >= 2 }
# 50% chance to not bother
next false if ai.pbAIRandom(100) < 50
# A reserve Pokémon is awake and not frozen
next false if reserves.none? { |pkmn| ![:SLEEP, :FROZEN].include?(pkmn.status) }
# 60% chance to not bother
next false if ai.pbAIRandom(100) < 60
PBDebug.log_ai("#{battler.name} wants to switch because it is asleep and can't do anything")
next true
}

View File

@@ -342,7 +342,8 @@ class Battle::AI
if @trainer.high_skill? && @user.can_switch_lax?
badMoves = false
if max_score <= MOVE_USELESS_SCORE
badMoves = true
badMoves = user_battler.can_attack?
badMoves = true if !badMoves && pbAIRandom(100) < 25
elsif max_score < MOVE_BASE_SCORE * move_score_threshold && user_battler.turnCount > 2
badMoves = true if pbAIRandom(100) < 80
end

View File

@@ -154,7 +154,7 @@ class PokemonPokedexInfo_Scene
def pbGetAvailableForms
ret = []
multiple_forms = false
gender_differences = (GameData::Species.front_sprite_filename(@species, 0) == GameData::Species.front_sprite_filename(@species, 0, 1))
gender_differences = (GameData::Species.front_sprite_filename(@species, 0) != GameData::Species.front_sprite_filename(@species, 0, 1))
# Find all genders/forms of @species that have been seen
GameData::Species.each do |sp|
next if sp.species != @species

View File

@@ -126,7 +126,7 @@ MenuHandlers.add(:debug_menu, :safari_zone_and_bug_contest, {
break
end
end
when 1 # Safari Balls
when 1 # Sport Balls
params = ChooseNumberParams.new
params.setRange(0, 99999)
params.setDefaultValue(contest.ballcount)
@@ -162,7 +162,7 @@ MenuHandlers.add(:debug_menu, :edit_field_effects, {
params = ChooseNumberParams.new
params.setRange(0, 99999)
params.setDefaultValue($PokemonGlobal.repel)
$PokemonGlobal.repel = pbMessageChooseNumber(_INTL("Set the Pokémon's level."), params)
$PokemonGlobal.repel = pbMessageChooseNumber(_INTL("Set the number of steps remaining."), params)
when 1 # Strength used
$PokemonMap.strengthUsed = !$PokemonMap.strengthUsed
when 2 # Flash used