From fb29f19a2826541faa3d4d007bd48aa7be8c1eed Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Wed, 29 Dec 2021 14:37:41 +0000 Subject: [PATCH] Fixed various bugs found when generating Battle Frontier challenge lists --- .../011_Battle/001_Battle/001_Battle.rb | 2 +- .../003_Move/004_Move_BaseEffects.rb | 4 ++-- .../008_MoveEffects_MoveAttributes.rb | 4 ++-- .../004_Scene/009_Battle_DebugScene.rb | 10 +++++++++ .../008_Battle_AbilityEffects.rb | 22 +++++++++---------- .../001_ChallengeGenerator_Data.rb | 6 ++--- .../003_ChallengeGenerator_Trainers.rb | 2 +- .../004_ChallengeGenerator_BattleSim.rb | 8 +++---- 8 files changed, 34 insertions(+), 24 deletions(-) diff --git a/Data/Scripts/011_Battle/001_Battle/001_Battle.rb b/Data/Scripts/011_Battle/001_Battle/001_Battle.rb index 797673b40..4330e67fb 100644 --- a/Data/Scripts/011_Battle/001_Battle/001_Battle.rb +++ b/Data/Scripts/011_Battle/001_Battle/001_Battle.rb @@ -346,7 +346,7 @@ class Battle count = 0 eachInTeamFromBattlerIndex(idxBattler) do |pkmn, i| next if !pkmn || !pkmn.able? - next if inBattleIndices.include?(idxParty) + next if inBattleIndices.include?(i) count += 1 end return count diff --git a/Data/Scripts/011_Battle/003_Move/004_Move_BaseEffects.rb b/Data/Scripts/011_Battle/003_Move/004_Move_BaseEffects.rb index 9eb62b605..54562ed7f 100644 --- a/Data/Scripts/011_Battle/003_Move/004_Move_BaseEffects.rb +++ b/Data/Scripts/011_Battle/003_Move/004_Move_BaseEffects.rb @@ -32,7 +32,7 @@ class Battle::Move::Confusion < Battle::Move @category = 0 @accuracy = 100 @pp = -1 - @target = 0 + @target = :User @priority = 0 @flags = [] @addlEffect = 0 @@ -61,7 +61,7 @@ class Battle::Move::Struggle < Battle::Move @category = 0 @accuracy = 0 @pp = -1 - @target = 0 + @target = :NearOther @priority = 0 @flags = ["Contact", "CanProtect"] @addlEffect = 0 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 8f1b7c88b..b97dea44d 100644 --- a/Data/Scripts/011_Battle/003_Move/008_MoveEffects_MoveAttributes.rb +++ b/Data/Scripts/011_Battle/003_Move/008_MoveEffects_MoveAttributes.rb @@ -1315,13 +1315,13 @@ end #=============================================================================== class Battle::Move::TypeDependsOnUserIVs < Battle::Move def pbBaseType(user) - hp = pbHiddenPower(user) + hp = pbHiddenPower(user.pokemon) return hp[0] end def pbBaseDamage(baseDmg, user, target) return super if Settings::MECHANICS_GENERATION >= 6 - hp = pbHiddenPower(user) + hp = pbHiddenPower(user.pokemon) return hp[1] end end diff --git a/Data/Scripts/011_Battle/004_Scene/009_Battle_DebugScene.rb b/Data/Scripts/011_Battle/004_Scene/009_Battle_DebugScene.rb index d5ba88691..b0bde2fbb 100644 --- a/Data/Scripts/011_Battle/004_Scene/009_Battle_DebugScene.rb +++ b/Data/Scripts/011_Battle/004_Scene/009_Battle_DebugScene.rb @@ -22,19 +22,28 @@ class Battle::DebugSceneNoLogging # Called whenever a new round begins. def pbBeginCommandPhase; end def pbBeginAttackPhase; end + def pbBeginEndOfRoundPhase; end def pbShowOpponent(idxTrainer); end def pbDamageAnimation(battler, effectiveness = 0); end def pbCommonAnimation(animName, user = nil, target = nil); end def pbAnimation(moveID, user, targets, hitNum = 0); end + def pbHitAndHPLossAnimation(targets); end + def pbShowPartyLineup(side, fullAnim = false); end + def pbShowAbilitySplash(battler, delay = false, logTrigger = true); end + def pbReplaceAbilitySplash(battler); end + def pbHideAbilitySplash(battler); end def pbEndBattle(result); end def pbWildBattleSuccess; end def pbTrainerBattleSuccess; end def pbBattleArenaJudgment(b1, b2, r1, r2); end def pbBattleArenaBattlers(b1, b2); end + def pbUpdate(cw = nil); end def pbRefresh; end + def pbRefreshOne(idxBattler); end def pbDisplayMessage(msg, brief = false); end + alias pbDisplay pbDisplayMessage def pbDisplayPausedMessage(msg); end def pbDisplayConfirmMessage(msg); return true; end def pbShowCommands(msg, commands, defaultValue); return 0; end @@ -45,6 +54,7 @@ class Battle::DebugSceneNoLogging def pbResetMoveIndex(idxBattler); end def pbHPChanged(battler, oldHP, showAnim = false); end + def pbChangePokemon(idxBattler, pkmn); end def pbFaintBattler(battler); end def pbEXPBar(battler, startExp, endExp, tempExp1, tempExp2); end def pbLevelUp(pkmn, battler, oldTotalHP, oldAttack, oldDefense, diff --git a/Data/Scripts/011_Battle/006_Other battle code/008_Battle_AbilityEffects.rb b/Data/Scripts/011_Battle/006_Other battle code/008_Battle_AbilityEffects.rb index 11657517a..bea15e390 100644 --- a/Data/Scripts/011_Battle/006_Other battle code/008_Battle_AbilityEffects.rb +++ b/Data/Scripts/011_Battle/006_Other battle code/008_Battle_AbilityEffects.rb @@ -1527,7 +1527,7 @@ Battle::AbilityEffects::DamageCalcFromTarget.add(:FLOWERGIFT, Battle::AbilityEffects::DamageCalcFromTarget.add(:FLUFFY, proc { |ability, user, target, move, mults, baseDmg, type| mults[:final_damage_multiplier] *= 2 if move.calcType == :FIRE - mults[:final_damage_multiplier] /= 2 if move.pbContactMove? + mults[:final_damage_multiplier] /= 2 if move.pbContactMove?(user) } ) @@ -1711,11 +1711,11 @@ Battle::AbilityEffects::OnBeingHit.add(:ANGERPOINT, Battle::AbilityEffects::OnBeingHit.add(:COTTONDOWN, proc { |ability, user, target, move, battle| next if battle.allBattlers.none? { |b| b.pbCanLowerStatStage?(:DEFENSE, target) } - battle.pbShowAbilitySplash(battler) + battle.pbShowAbilitySplash(target) battle.allBattlers.each do |b| b.pbLowerStatStageByAbility(:SPEED, 1, target, false) end - battle.pbHideAbilitySplash(battler) + battle.pbHideAbilitySplash(target) } ) @@ -1972,7 +1972,7 @@ Battle::AbilityEffects::OnBeingHit.add(:RATTLED, Battle::AbilityEffects::OnBeingHit.add(:SANDSPIT, proc { |ability, user, target, move, battle| - battle.pbStartWeatherAbility(:Sandstorm, battler) + battle.pbStartWeatherAbility(:Sandstorm, target) } ) @@ -2907,7 +2907,7 @@ Battle::AbilityEffects::OnSwitchIn.add(:NEUTRALIZINGGAS, # Truant - let b move on its first turn after Neutralizing Gas disappears b.effects[PBEffects::Truant] = false # Gorilla Tactics - end choice lock - if !hasActiveItem?([:CHOICEBAND, :CHOICESPECS, :CHOICESCARF]) + if !b.hasActiveItem?([:CHOICEBAND, :CHOICESPECS, :CHOICESCARF]) b.effects[PBEffects::ChoiceBand] = nil end # Illusion - end illusions @@ -2977,12 +2977,12 @@ Battle::AbilityEffects::OnSwitchIn.add(:SANDSTREAM, Battle::AbilityEffects::OnSwitchIn.add(:SCREENCLEANER, proc { |ability, battler, battle, switch_in| - next if target.pbOwnSide.effects[PBEffects::AuroraVeil] == 0 && - target.pbOwnSide.effects[PBEffects::LightScreen] == 0 && - target.pbOwnSide.effects[PBEffects::Reflect] == 0 && - target.pbOpposingSide.effects[PBEffects::AuroraVeil] == 0 && - target.pbOpposingSide.effects[PBEffects::LightScreen] == 0 && - target.pbOpposingSide.effects[PBEffects::Reflect] == 0 + next if battler.pbOwnSide.effects[PBEffects::AuroraVeil] == 0 && + battler.pbOwnSide.effects[PBEffects::LightScreen] == 0 && + battler.pbOwnSide.effects[PBEffects::Reflect] == 0 && + battler.pbOpposingSide.effects[PBEffects::AuroraVeil] == 0 && + battler.pbOpposingSide.effects[PBEffects::LightScreen] == 0 && + battler.pbOpposingSide.effects[PBEffects::Reflect] == 0 battle.pbShowAbilitySplash(battler) if battler.pbOpposingSide.effects[PBEffects::AuroraVeil] > 0 battler.pbOpposingSide.effects[PBEffects::AuroraVeil] = 0 diff --git a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/001_ChallengeGenerator_Data.rb b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/001_ChallengeGenerator_Data.rb index 4ed702394..f0202b60a 100644 --- a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/001_ChallengeGenerator_Data.rb +++ b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/001_ChallengeGenerator_Data.rb @@ -176,7 +176,7 @@ def pbGenerateChallenge(rule, tag) rule = rule.copy.setNumber(2) yield(nil) party = load_data(tag + ".rxdata") rescue [] - teams = load_data(tag + "teams.rxdata") rescue [] + teams = load_data(tag + "_teams.rxdata") rescue [] if teams.length < 10 btpokemon = pbGetBTPokemon(tag) if btpokemon && btpokemon.length != 0 @@ -218,7 +218,7 @@ def pbGenerateChallenge(rule, tag) end i += 1 end - save_data(teams, tag + "teams.rxdata") + save_data(teams, tag + "_teams.rxdata") yield(nil) while teams.length < maxteams yield(nil) if teams.length % 10 == 0 @@ -256,7 +256,7 @@ def pbGenerateChallenge(rule, tag) end end teams.sort! { |a, b| b.rating <=> a.rating } - save_data(teams, tag + "teams.rxdata") + save_data(teams, tag + "_teams.rxdata") end party = [] yield(nil) diff --git a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/003_ChallengeGenerator_Trainers.rb b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/003_ChallengeGenerator_Trainers.rb index 0cf2a46b2..9f361a654 100644 --- a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/003_ChallengeGenerator_Trainers.rb +++ b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/003_ChallengeGenerator_Trainers.rb @@ -202,7 +202,7 @@ def pbTrainerInfo(pokemonlist, trfile, rules) yield(nil) if block_given? if trIndex < 0 info = [newbttrainers, pbpokemonlist, [trfile], - trfile + "tr.txt", trfile + "pm.txt", !hasDefault] + trfile + "_trainers.txt", trfile + "_pkmn.txt", !hasDefault] trlists.push(info) end yield(nil) if block_given? diff --git a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/004_ChallengeGenerator_BattleSim.rb b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/004_ChallengeGenerator_BattleSim.rb index 3ed6ebbcd..cd1222137 100644 --- a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/004_ChallengeGenerator_BattleSim.rb +++ b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/004_ChallengeGenerator_BattleSim.rb @@ -380,7 +380,7 @@ def pbRuledBattle(team1, team2, rule) trainer2 = NPCTrainer.new("PLAYER2", t_type) items1 = [] items2 = [] - team1.each_with_index do |p, i| + team1.team.each_with_index do |p, i| next if !p if p.level != level p.level = level @@ -389,7 +389,7 @@ def pbRuledBattle(team1, team2, rule) items1[i] = p.item_id trainer1.party.push(p) end - team2.each_with_index do |p, i| + team2.team.each_with_index do |p, i| next if !p if p.level != level p.level = level @@ -404,12 +404,12 @@ def pbRuledBattle(team1, team2, rule) battle.controlPlayer = true battle.internalBattle = false decision = battle.pbStartBattle - team1.each_with_index do |p, i| + team1.team.each_with_index do |p, i| next if !p p.heal p.item = items1[i] end - team2.each_with_index do |p, i| + team2.team.each_with_index do |p, i| next if !p p.heal p.item = items2[i]