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

@@ -1428,7 +1428,7 @@ Battle::AI::Handlers::MoveEffectScore.add("StartUserSideImmunityToStatStageLower
m.is_a?(Battle::Move::TargetMultiStatDownMove) ||
["LowerPoisonedTargetAtkSpAtkSpd1",
"PoisonTargetLowerTargetSpeed1",
"HealUserByTargetAttackLowerTargetAttack1"].include?(m.function) }
"HealUserByTargetAttackLowerTargetAttack1"].include?(m.function_code) }
score += 15
has_move = true
end

View File

@@ -128,7 +128,7 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("PoisonTarget",
score -= 5 if target.has_move_with_function?("DoublePowerIfUserPoisonedBurnedParalyzed",
"CureUserBurnPoisonParalysis")
score -= 15 if target.check_for_move { |m|
m.function == "GiveUserStatusToTarget" && user.battler.pbCanPoison?(target.battler, false, m)
m.function_code == "GiveUserStatusToTarget" && user.battler.pbCanPoison?(target.battler, false, m)
}
# Don't prefer if the target won't take damage from the poison
score -= 20 if !target.battler.takesIndirectDamage?
@@ -218,7 +218,7 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("ParalyzeTarget",
score -= 5 if target.has_move_with_function?("DoublePowerIfUserPoisonedBurnedParalyzed",
"CureUserBurnPoisonParalysis")
score -= 15 if target.check_for_move { |m|
m.function == "GiveUserStatusToTarget" && user.battler.pbCanParalyze?(target.battler, false, m)
m.function_code == "GiveUserStatusToTarget" && user.battler.pbCanParalyze?(target.battler, false, m)
}
# Don't prefer if the target can heal itself (or be healed by an ally)
if target.has_active_ability?(:SHEDSKIN)
@@ -313,7 +313,7 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("BurnTarget",
score -= 5 if target.has_move_with_function?("DoublePowerIfUserPoisonedBurnedParalyzed",
"CureUserBurnPoisonParalysis")
score -= 15 if target.check_for_move { |m|
m.function == "GiveUserStatusToTarget" && user.battler.pbCanBurn?(target.battler, false, m)
m.function_code == "GiveUserStatusToTarget" && user.battler.pbCanBurn?(target.battler, false, m)
}
# Don't prefer if the target won't take damage from the burn
score -= 20 if !target.battler.takesIndirectDamage?

View File

@@ -189,7 +189,7 @@ Battle::AI::Handlers::MoveBasePower.add("PowerHigherWithLessPP",
proc { |power, move, user, target, ai, battle|
next 0 if move.move.pp == 0 && move.move.totalpp > 0
dmgs = [200, 80, 60, 50, 40]
ppLeft = [move.pp - 1, dmgs.length - 1].min
ppLeft = [move.move.pp - 1, dmgs.length - 1].min
next dmgs[ppLeft]
}
)
@@ -463,7 +463,7 @@ Battle::AI::Handlers::MoveEffectScore.add("EnsureNextCriticalHit",
next Battle::AI::MOVE_USELESS_SCORE
end
# Prefer if user knows a damaging move which won't definitely critical hit
if user.check_for_move { |m| m.damagingMove? && m.function != "AlwaysCriticalHit"}
if user.check_for_move { |m| m.damagingMove? && m.function_code != "AlwaysCriticalHit"}
score += 15
end
next score

View File

@@ -77,7 +77,7 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("UserTargetSwapItems",
# Don't prefer if user used this move in the last round
score -= 15 if user.battler.lastMoveUsed &&
GameData::Move.exists?(user.battler.lastMoveUsed) &&
GameData::Move.get(user.battler.lastMoveUsed).function_code == move.function
GameData::Move.get(user.battler.lastMoveUsed).function_code == move.function_code
next score
}
)

View File

@@ -155,18 +155,23 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("EffectDependsOnEnvironme
function_code = "ParalyzeTarget"
when 9
function_code = "FreezeTarget"
when 5
function_code = "LowerTargetAttack1"
when 14
function_code = "LowerTargetDefense1"
when 3
function_code = "LowerTargetSpAtk1"
when 4, 6, 12
function_code = "LowerTargetSpeed1"
when 8
function_code = "LowerTargetAccuracy1"
when 7, 11, 13
function_code = "FlinchTarget"
else
stat_lowered = nil
case move.move.secretPower
when 5
function_code = :ATTACK
when 14
function_code = :DEFENSE
when 3
function_code = :SPECIAL_ATTACK
when 4, 6, 12
function_code = :SPEED
when 8
function_code = :ACCURACY
end
next ai.get_score_for_target_stat_drop(score, target, [stat_lowered, 1]) if stat_lowered
end
if function_code
next Battle::AI::Handlers.apply_move_effect_against_target_score(function_code,
@@ -531,7 +536,7 @@ Battle::AI::Handlers::MoveFailureCheck.add("UseRandomUserMoveIfAsleep",
proc { |move, user, ai, battle|
will_fail = true
user.battler.eachMoveWithIndex do |m, i|
next if move.move.moveBlacklist.include?(m.function)
next if move.move.moveBlacklist.include?(m.function_code)
next if !battle.pbCanChooseMove?(user.index, i, false, true)
will_fail = false
break

View File

@@ -458,7 +458,7 @@ Battle::AI::Handlers::MoveEffectScore.add("UsedAfterAllyRoundWithDoublePower",
# No score change if no allies know this move
ally_has_move = false
ai.each_same_side_battler(user.side) do |b, i|
next if !b.has_move_with_function?(move.function)
next if !b.has_move_with_function?(move.function_code)
ally_has_move = true
break
end
@@ -556,7 +556,7 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("TargetUsesItsLastUsedMov
break if mov
end
next Battle::AI::MOVE_USELESS_SCORE if mov.nil? || (mov.pp == 0 && mov.total_pp > 0)
next Battle::AI::MOVE_USELESS_SCORE if move.move.moveBlacklist.include?(mov.function)
next Battle::AI::MOVE_USELESS_SCORE if move.move.moveBlacklist.include?(mov.function_code)
# Without lots of code here to determine good/bad moves, using this move is
# likely to just be a waste of a turn
# NOTE: Because this move can be used against a foe but is being used on an
@@ -802,7 +802,7 @@ Battle::AI::Handlers::MoveEffectAgainstTargetScore.add("DisableTargetStatusMoves
"ProtectUserFromTargetingMovesSpikyShield", # Spiky Shield
"ProtectUserBanefulBunker" # Baneful Bunker
]
if target.check_for_move { |m| m.statusMove? && protection_moves.include?(m.function) }
if target.check_for_move { |m| m.statusMove? && protection_moves.include?(m.function_code) }
score += 10
end
next score