diff --git a/Data/Scripts/011_Battle/002_Battler/007_Battler_UseMove.rb b/Data/Scripts/011_Battle/002_Battler/007_Battler_UseMove.rb index 237f96054..b6aa0c7f4 100644 --- a/Data/Scripts/011_Battle/002_Battler/007_Battler_UseMove.rb +++ b/Data/Scripts/011_Battle/002_Battler/007_Battler_UseMove.rb @@ -89,7 +89,7 @@ class Battle::Battler @effects[PBEffects::Outrage] = 0 @effects[PBEffects::Uproar] = 0 @effects[PBEffects::Bide] = 0 - @currentMove = nil + @currentMove = nil if @effects[PBEffects::HyperBeam] == 0 # Reset counters for moves which increase them when used in succession @effects[PBEffects::FuryCutter] = 0 end @@ -314,7 +314,7 @@ class Battle::Battler user.lastMoveFailed = true if ![:Rain, :HeavyRain].include?(user.effectiveWeather) && user.takesIndirectDamage? user.pbTakeEffectDamage((user.totalhp / 4.0).round, false) do |hp_lost| - @battle.pbDisplay(_INTL("{1} is hurt by its {2}!", battler.pbThis, battler.itemName)) + @battle.pbDisplay(_INTL("{1} is hurt by Powder!", user.pbThis)) end @battle.pbGainExp # In case user is KO'd by this end diff --git a/Data/Scripts/011_Battle/003_Move/008_MoveEffects_MoveAttributes.rb b/Data/Scripts/011_Battle/003_Move/008_MoveEffects_MoveAttributes.rb index 03d12eb07..2f6f5db52 100644 --- a/Data/Scripts/011_Battle/003_Move/008_MoveEffects_MoveAttributes.rb +++ b/Data/Scripts/011_Battle/003_Move/008_MoveEffects_MoveAttributes.rb @@ -1121,6 +1121,7 @@ class Battle::Move::CategoryDependsOnHigherDamagePoisonTarget < Battle::Move::Po def pbOnStartUse(user, targets) target = targets[0] + return if !target max_stage = Battle::Battler::STAT_STAGE_MAXIMUM stageMul = Battle::Battler::STAT_STAGE_MULTIPLIERS stageDiv = Battle::Battler::STAT_STAGE_DIVISORS diff --git a/Data/Scripts/011_Battle/005_AI/002_AI_Switch.rb b/Data/Scripts/011_Battle/005_AI/002_AI_Switch.rb index 1b0566e9e..eccb8534b 100644 --- a/Data/Scripts/011_Battle/005_AI/002_AI_Switch.rb +++ b/Data/Scripts/011_Battle/005_AI/002_AI_Switch.rb @@ -345,16 +345,16 @@ Battle::AI::Handlers::ShouldSwitch.add(:yawning, end trapping = false ai.each_foe_battler(battler.side) do |b, i| - next if b.ability_active? && Battle::AbilityEffects.triggerCertainSwitching(b.ability, b, battle) - next if b.item_active? && Battle::ItemEffects.triggerCertainSwitching(b.item, b, battle) + next if b.ability_active? && Battle::AbilityEffects.triggerCertainSwitching(b.ability, b.battler, battle) + next if b.item_active? && Battle::ItemEffects.triggerCertainSwitching(b.item, b.battler, battle) next if Settings::MORE_TYPE_EFFECTS && b.has_type?(:GHOST) next if b.battler.trappedInBattle? # Relevant trapping effects are checked above if battler.ability_active? - trapping = Battle::AbilityEffects.triggerTrappingByTarget(battler.ability, b, battler.battler, battle) + trapping = Battle::AbilityEffects.triggerTrappingByTarget(battler.ability, b.battler, battler.battler, battle) break if trapping end if battler.item_active? - trapping = Battle::ItemEffects.triggerTrappingByTarget(battler.item, b, battler.battler, battle) + trapping = Battle::ItemEffects.triggerTrappingByTarget(battler.item, b.battler, battler.battler, battle) break if trapping end end @@ -390,16 +390,16 @@ Battle::AI::Handlers::ShouldSwitch.add(:asleep, end trapping = false ai.each_foe_battler(battler.side) do |b, i| - next if b.ability_active? && Battle::AbilityEffects.triggerCertainSwitching(b.ability, b, battle) - next if b.item_active? && Battle::ItemEffects.triggerCertainSwitching(b.item, b, battle) + next if b.ability_active? && Battle::AbilityEffects.triggerCertainSwitching(b.ability, b.battler, battle) + next if b.item_active? && Battle::ItemEffects.triggerCertainSwitching(b.item, b.battler, battle) next if Settings::MORE_TYPE_EFFECTS && b.has_type?(:GHOST) next if b.battler.trappedInBattle? # Relevant trapping effects are checked above if battler.ability_active? - trapping = Battle::AbilityEffects.triggerTrappingByTarget(battler.ability, b, battler.battler, battle) + trapping = Battle::AbilityEffects.triggerTrappingByTarget(battler.ability, b.battler, battler.battler, battle) break if trapping end if battler.item_active? - trapping = Battle::ItemEffects.triggerTrappingByTarget(battler.item, b, battler.battler, battle) + trapping = Battle::ItemEffects.triggerTrappingByTarget(battler.item, b.battler, battler.battler, battle) break if trapping end end diff --git a/Data/Scripts/011_Battle/005_AI/005_AI_ChooseMove.rb b/Data/Scripts/011_Battle/005_AI/005_AI_ChooseMove.rb index 1277ba658..6d35f0d85 100644 --- a/Data/Scripts/011_Battle/005_AI/005_AI_ChooseMove.rb +++ b/Data/Scripts/011_Battle/005_AI/005_AI_ChooseMove.rb @@ -22,25 +22,7 @@ class Battle::AI # against it. def pbGetMoveScores choices = [] - - # TODO: Delete this after testing AI. - if $tested_abilities && @user.ability_id - $tested_abilities[@user.ability_id] ||= 0 - $tested_abilities[@user.ability_id] += 1 - end - if $tested_items && @user.item_id - $tested_items[@user.item_id] ||= 0 - $tested_items[@user.item_id] += 1 - end - @user.battler.eachMoveWithIndex do |orig_move, idxMove| - - # TODO: Delete this after testing AI. - if $tested_moves - $tested_moves[orig_move.id] ||= 0 - $tested_moves[orig_move.id] += 1 - end - # Unchoosable moves aren't considered if !@battle.pbCanChooseMove?(@user.index, idxMove, false) if orig_move.pp == 0 && orig_move.total_pp > 0 @@ -366,7 +348,10 @@ class Battle::AI end if badMoves PBDebug.log_ai("#{@user.name} wants to switch due to terrible moves") - return if pbChooseToSwitchOut(true) + if pbChooseToSwitchOut(true) + @battle.pbUnregisterMegaEvolution(@user.index) + return + end PBDebug.log_ai("#{@user.name} won't switch after all") end end diff --git a/Data/Scripts/012_Overworld/001_Overworld visuals/001_Overworld_Weather.rb b/Data/Scripts/012_Overworld/001_Overworld visuals/001_Overworld_Weather.rb index f7563400e..ebe48bfb8 100644 --- a/Data/Scripts/012_Overworld/001_Overworld visuals/001_Overworld_Weather.rb +++ b/Data/Scripts/012_Overworld/001_Overworld visuals/001_Overworld_Weather.rb @@ -271,7 +271,6 @@ module RPG def update_sprite_position(sprite, index, is_new_sprite = false) return if !sprite || !sprite.bitmap || !sprite.visible - # TODO: FPS. delta_t = Graphics.delta lifetimes = (is_new_sprite) ? @new_sprite_lifetimes : @sprite_lifetimes if lifetimes[index] >= 0 @@ -287,7 +286,6 @@ module RPG if @weatherTypes[weather_type][0].category == :Rain && index.odd? # Splash sprite.opacity = (lifetimes[index] < 0.2) ? 255 : 0 # 0.2 seconds else - # TODO: FPS. dist_x = @weatherTypes[weather_type][0].particle_delta_x * delta_t dist_y = @weatherTypes[weather_type][0].particle_delta_y * delta_t sprite.x += dist_x @@ -301,7 +299,6 @@ module RPG sprite.x += Graphics.width if sprite.x - @ox < -sprite.width sprite.y -= Graphics.height if sprite.y - @oy > Graphics.height sprite.y += Graphics.height if sprite.y - @oy < -sprite.height - # TODO: FPS. sprite.opacity += @weatherTypes[weather_type][0].particle_delta_opacity * delta_t x = sprite.x - @ox y = sprite.y - @oy @@ -313,13 +310,11 @@ module RPG end def recalculate_tile_positions - # TODO: FPS. delta_t = Graphics.delta weather_type = @type if @fading && @fade_time >= [FADE_OLD_TONE_END - @time_shift, 0].max weather_type = @target_type end - # TODO: FPS. @tile_x += @weatherTypes[weather_type][0].tile_delta_x * delta_t @tile_y += @weatherTypes[weather_type][0].tile_delta_y * delta_t while @tile_x < @ox - @weatherTypes[weather_type][2][0].width @@ -416,7 +411,6 @@ module RPG @sun_magnitude = weather_max if @sun_magnitude != weather_max && @sun_magnitude != -weather_max @sun_magnitude *= -1 if (@sun_magnitude > 0 && @sun_strength > @sun_magnitude) || (@sun_magnitude < 0 && @sun_strength < 0) - # TODO: FPS. @sun_strength += @sun_magnitude.to_f * Graphics.delta / 0.4 # 0.4 seconds per half flash tone_red += @sun_strength tone_green += @sun_strength @@ -430,7 +424,6 @@ module RPG def update_fading return if !@fading old_fade_time = @fade_time - # TODO: FPS. @fade_time += Graphics.delta # Change tile bitmaps if @type != @target_type @@ -489,7 +482,6 @@ module RPG update_screen_tone # Storm flashes if @type == :Storm && !@fading - # TODO: FPS. if @time_until_flash > 0 @time_until_flash -= Graphics.delta if @time_until_flash <= 0 diff --git a/Data/Scripts/013_Items/004_Item_Phone.rb b/Data/Scripts/013_Items/004_Item_Phone.rb index 53d324950..85a2185de 100644 --- a/Data/Scripts/013_Items/004_Item_Phone.rb +++ b/Data/Scripts/013_Items/004_Item_Phone.rb @@ -574,7 +574,6 @@ EventHandlers.add(:on_frame_update, :phone_call_counter, if $PokemonGlobal.phone.time_to_next_call <= 0 $PokemonGlobal.phone.time_to_next_call = rand(20...40) * 60.0 # 20-40 minutes end - # TODO: FPS. Can probably leave this alone. $PokemonGlobal.phone.time_to_next_call -= Graphics.delta next if $PokemonGlobal.phone.time_to_next_call > 0 # Time for a random phone call; generate one diff --git a/Data/Scripts/020_Debug/001_Editor screens/003_EditorScreens_MapConnections.rb b/Data/Scripts/020_Debug/001_Editor screens/003_EditorScreens_MapConnections.rb index 57192bf04..61edbe939 100644 --- a/Data/Scripts/020_Debug/001_Editor screens/003_EditorScreens_MapConnections.rb +++ b/Data/Scripts/020_Debug/001_Editor screens/003_EditorScreens_MapConnections.rb @@ -491,7 +491,6 @@ class MapScreenScene end end end - # TODO: FPS. Scroll speed with arrow keys. Can probably leave this alone. if Input.press?(Input::UP) @mapsprites.each do |i| i[1].y += 4 if i diff --git a/Data/Scripts/022_Maruno/debug battle tests.rb b/Data/Scripts/022_Maruno/debug battle tests.rb index d6a0d4e61..0f172e8fb 100644 --- a/Data/Scripts/022_Maruno/debug battle tests.rb +++ b/Data/Scripts/022_Maruno/debug battle tests.rb @@ -1,13 +1,10 @@ # TODO: Be much more relevant with the choosing of held items. For example, # only give a weather-boosting item to a Pokémon that can create the # corresponding weather. -# TODO: Add alternate forms, which will give access to more abilities. Note that -# some alternate forms require fusion or specific held items or other -# things. -AI_MOVE_TESTING_THRESHOLD = 500 -AI_ABILITY_TESTING_THRESHOLD = 100 -AI_ITEM_TESTING_THRESHOLD = 100 +AI_MOVE_TESTING_THRESHOLD = 1500 +AI_ABILITY_TESTING_THRESHOLD = 500 +AI_ITEM_TESTING_THRESHOLD = 500 #=============================================================================== # @@ -89,6 +86,31 @@ MEGA_STONES = [ :GALLADITE, :AUDINITE, :DIANCITE ] +#=============================================================================== +# +#=============================================================================== +class Battle::AI + alias _ai_testing__pbGetMoveScores pbGetMoveScores + + def pbGetMoveScores + if $tested_abilities && @user.ability_id + $tested_abilities[@user.ability_id] ||= 0 + $tested_abilities[@user.ability_id] += 1 + end + if $tested_items && @user.item_id + $tested_items[@user.item_id] ||= 0 + $tested_items[@user.item_id] += 1 + end + @user.battler.eachMoveWithIndex do |orig_move, idxMove| + if $tested_moves + $tested_moves[orig_move.id] ||= 0 + $tested_moves[orig_move.id] += 1 + end + end + return _ai_testing__pbGetMoveScores + end +end + #=============================================================================== # #=============================================================================== @@ -125,22 +147,36 @@ def debug_set_up_trainer this_species = valid_species.sample this_level = 100 # rand(1, Settings::MAXIMUM_LEVEL) pkmn = Pokemon.new(this_species, this_level, trainer, false) + # Set form for certain species + case pkmn.species + when :GRENINJA, :SLOWKING, :GEODUDE, :GRAVELER, :GOLEM, :PONYTA, :RAPIDASH, + :GRIMER, :MUK, :SLOWBRO, :RAICHU, :DIGLETT, :DUGTRIO, :STUNFISK + pkmn.form_simple = 1 + when :DARMANITAN + pkmn.form_simple = 2 + when :CALYREX + pkmn.form_simple = [1, 2].sample # So we test both versions of As One + when :NECROZMA + pkmn.form_simple = 3 # Ultra form + end # Generate moveset for pkmn (from level-up moves first, then from tutor # moves + egg moves, then from all moves) all_moves = pkmn.getMoveList.map { |m| m[1] } all_moves.uniq! - all_moves.reject! { |m| $tested_moves[m] && $tested_moves[m] > AI_MOVE_TESTING_THRESHOLD } - if all_moves.length == 0 - all_moves = pkmn.species_data.tutor_moves.clone + pkmn.species_data.get_egg_moves.clone + if !$shown_all_moves_tested_message all_moves.reject! { |m| $tested_moves[m] && $tested_moves[m] > AI_MOVE_TESTING_THRESHOLD } if all_moves.length == 0 - all_moves = GameData::Move.keys.clone + all_moves = pkmn.species_data.tutor_moves.clone + pkmn.species_data.get_egg_moves.clone all_moves.reject! { |m| $tested_moves[m] && $tested_moves[m] > AI_MOVE_TESTING_THRESHOLD } + if all_moves.length == 0 + all_moves = GameData::Move.keys.clone + all_moves.reject! { |m| $tested_moves[m] && $tested_moves[m] > AI_MOVE_TESTING_THRESHOLD } + end + end + if all_moves.length == 0 && !$shown_all_moves_tested_message + echoln "All moves have been tested at least #{AI_MOVE_TESTING_THRESHOLD} times!" + $shown_all_moves_tested_message = true end - end - if all_moves.length == 0 && !$shown_all_moves_tested_message - echoln "All moves have been tested at least #{AI_MOVE_TESTING_THRESHOLD} times!" - $shown_all_moves_tested_message = true end moves = all_moves.sample(4) moves.each { |m| pkmn.learn_move(m) } @@ -174,7 +210,11 @@ def debug_set_up_trainer if $tested_abilities[abil] && $tested_abilities[abil] > AI_ABILITY_TESTING_THRESHOLD abils = pkmn.getAbilityList abils.reject! { |a| $tested_abilities[a[0]] && $tested_abilities[a[0]] > AI_ABILITY_TESTING_THRESHOLD } - pkmn.ability_index = abils.sample[1] if abils.length > 0 + if abils.length > 0 + pkmn.ability_index = abils.sample[1] + else + pkmn.ability = GameData::Ability.keys.sample + end end trainer.party.push(pkmn) pokemon_array.push(pkmn)