Pokémon sent into battle now default to the Fight option, fixed bugs in Instruct, fixed some AI bugs, fixed parameter mixup for def pbMoveCanTarget?, renamed function to function_code everywhere, fixed black party Pokémon icons in storage, added some more AI testing code

This commit is contained in:
Maruno17
2023-06-18 20:12:36 +01:00
parent 9c2a9130a5
commit b5e37248b9
42 changed files with 305 additions and 174 deletions

View File

@@ -25,12 +25,12 @@ class Battle
def pbJudgeCheckpoint(user, move = nil)
if pbAllFainted?(0) && pbAllFainted?(1)
if @rules["drawclause"] # NOTE: Also includes Life Orb (not implemented)
if !(move && move.function == "HealUserByHalfOfDamageDone")
if !(move && move.function_code == "HealUserByHalfOfDamageDone")
# Not a draw if fainting occurred due to Liquid Ooze
@decision = (user.opposes?) ? 1 : 2 # win / loss
end
elsif @rules["modifiedselfdestructclause"]
if move && move.function == "UserFaintsExplosive" # Self-Destruct
if move && move.function_code == "UserFaintsExplosive" # Self-Destruct
@decision = (user.opposes?) ? 1 : 2 # win / loss
end
end

View File

@@ -1420,7 +1420,7 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:SWARM,
Battle::AbilityEffects::DamageCalcFromUser.add(:TECHNICIAN,
proc { |ability, user, target, move, mults, power, type|
if user.index != target.index && move && move.function != "Struggle" &&
if user.index != target.index && move && move.function_code != "Struggle" &&
power * mults[:power_multiplier] <= 60
mults[:power_multiplier] *= 1.5
end
@@ -1536,7 +1536,7 @@ Battle::AbilityEffects::DamageCalcFromTarget.add(:FLUFFY,
Battle::AbilityEffects::DamageCalcFromTarget.add(:FURCOAT,
proc { |ability, user, target, move, mults, power, type|
mults[:defense_multiplier] *= 2 if move.physicalMove? ||
move.function == "UseTargetDefenseInsteadOfTargetSpDef" # Psyshock
move.function_code == "UseTargetDefenseInsteadOfTargetSpDef" # Psyshock
}
)
@@ -2596,14 +2596,14 @@ Battle::AbilityEffects::OnSwitchIn.add(:ANTICIPATION,
next if m.statusMove?
if types.length > 0
moveType = m.type
if Settings::MECHANICS_GENERATION >= 6 && m.function == "TypeDependsOnUserIVs" # Hidden Power
if Settings::MECHANICS_GENERATION >= 6 && m.function_code == "TypeDependsOnUserIVs" # Hidden Power
moveType = pbHiddenPower(b.pokemon)[0]
end
eff = Effectiveness.calculate(moveType, *types)
next if Effectiveness.ineffective?(eff)
next if !Effectiveness.super_effective?(eff) &&
!["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(m.function)
elsif !["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(m.function)
!["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(m.function_code)
elsif !["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(m.function_code)
next
end
found = true
@@ -2743,12 +2743,12 @@ Battle::AbilityEffects::OnSwitchIn.add(:FOREWARN,
battle.allOtherSideBattlers(battler.index).each do |b|
b.eachMove do |m|
power = m.power
power = 160 if ["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(m.function)
power = 150 if ["PowerHigherWithUserHP"].include?(m.function) # Eruption
power = 160 if ["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(m.function_code)
power = 150 if ["PowerHigherWithUserHP"].include?(m.function_code) # Eruption
# Counter, Mirror Coat, Metal Burst
power = 120 if ["CounterPhysicalDamage",
"CounterSpecialDamage",
"CounterDamagePlusHalf"].include?(m.function)
"CounterDamagePlusHalf"].include?(m.function_code)
# Sonic Boom, Dragon Rage, Night Shade, Endeavor, Psywave,
# Return, Frustration, Crush Grip, Gyro Ball, Hidden Power,
# Natural Gift, Trump Card, Flail, Grass Knot
@@ -2764,8 +2764,8 @@ Battle::AbilityEffects::OnSwitchIn.add(:FOREWARN,
"TypeAndPowerDependOnUserBerry",
"PowerHigherWithLessPP",
"PowerLowerWithUserHP",
"PowerHigherWithTargetWeight"].include?(m.function)
power = 80 if Settings::MECHANICS_GENERATION <= 5 && m.function == "TypeDependsOnUserIVs"
"PowerHigherWithTargetWeight"].include?(m.function_code)
power = 80 if Settings::MECHANICS_GENERATION <= 5 && m.function_code == "TypeDependsOnUserIVs"
next if power < highestPower
forewarnMoves = [] if power > highestPower
forewarnMoves.push(m.name)

View File

@@ -677,7 +677,7 @@ Battle::ItemEffects::PriorityBracketUse.add(:QUICKCLAW,
Battle::ItemEffects::OnMissingTarget.add(:BLUNDERPOLICY,
proc { |item, user, target, move, hit_num, battle|
next if hit_num > 0 || target.damageState.invulnerable
next if ["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(move.function)
next if ["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(move.function_code)
next if !user.pbCanRaiseStatStage?(:SPEED, user)
battle.pbCommonAnimation("UseItem", user)
user.pbRaiseStatStageByCause(:SPEED, 2, user, user.itemName)