mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 13:15:01 +00:00
More error fixes in AI
This commit is contained in:
@@ -140,7 +140,7 @@ class Battle::AI
|
||||
return score
|
||||
|
||||
|
||||
|
||||
=begin
|
||||
mini_score = 1.0
|
||||
# Determine whether the move boosts Attack, Special Attack or Speed (Bulk Up
|
||||
# is sometimes not considered a sweeping move)
|
||||
@@ -230,6 +230,7 @@ class Battle::AI
|
||||
end
|
||||
|
||||
return mini_score
|
||||
=end
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
@@ -361,7 +362,7 @@ class Battle::AI
|
||||
return score
|
||||
|
||||
|
||||
|
||||
=begin
|
||||
mini_score = 1.0
|
||||
case stat
|
||||
when :ATTACK
|
||||
@@ -565,6 +566,7 @@ class Battle::AI
|
||||
end
|
||||
|
||||
return mini_score
|
||||
=end
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
|
||||
@@ -7,6 +7,8 @@ class Battle::AI
|
||||
#=============================================================================
|
||||
def pbGetDamagingMoveBaseScore
|
||||
return 100
|
||||
|
||||
=begin
|
||||
# Don't prefer moves that are ineffective because of abilities or effects
|
||||
return 0 if @target.immune_to_move?
|
||||
user_battler = @user.battler
|
||||
@@ -45,6 +47,7 @@ class Battle::AI
|
||||
damage_percentage += 40 if damage_percentage > 100 # Prefer moves likely to be lethal
|
||||
|
||||
return damage_percentage.to_i
|
||||
=end
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
@@ -53,6 +56,8 @@ class Battle::AI
|
||||
#=============================================================================
|
||||
def pbGetStatusMoveBaseScore
|
||||
return 100
|
||||
|
||||
=begin
|
||||
# TODO: Call @target.immune_to_move? here too, not just for damaging moves
|
||||
# (only if this status move will be affected).
|
||||
|
||||
@@ -295,5 +300,6 @@ class Battle::AI
|
||||
# "TargetActsLast",
|
||||
# "ProtectUserSideFromStatusMoves"
|
||||
return 100
|
||||
=end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -59,7 +59,7 @@ Battle::AI::Handlers::MoveEffectScore.add("MaxUserAttackLoseHalfOfTotalHP",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
score = ai.get_score_for_user_stat_raise(score)
|
||||
# Don't prefer the lower the user's HP is
|
||||
score -= 80 * (1 - (@user.hp.to_f / @user.totalhp)) # 0 to -40
|
||||
score -= 80 * (1 - (user.hp.to_f / user.totalhp)) # 0 to -40
|
||||
next score
|
||||
}
|
||||
)
|
||||
|
||||
@@ -413,7 +413,7 @@ Battle::AI::Handlers::MoveEffectScore.copy("FreezeTarget",
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveEffectScore.add("FreezeTarget",
|
||||
Battle::AI::Handlers::MoveEffectScore.add("FreezeFlinchTarget",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
score = Battle::AI::Handlers.apply_move_effect_score("FreezeTarget",
|
||||
score, move, user, target, ai, battle)
|
||||
|
||||
@@ -37,24 +37,18 @@ Battle::AI::Handlers::MoveEffectScore.add("HitTwoTimesPoisonTarget",
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveBasePower.copy("HitTwoTimes",
|
||||
"HitTwoTimesFlinchTarget")
|
||||
Battle::AI::Handlers::MoveEffectScore.add("HitTwoTimesFlinchTarget",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
dmg = move.rough_damage
|
||||
num_hits = move.move.pbNumHits(user.battler, [target.battler])
|
||||
# Prefer if the target has a Substitute and the first hit can break it
|
||||
if target.effects[PBEffects::Substitute] > 0 && !move.move.ignoresSubstitute?(user.battler)
|
||||
score += 10 if target.effects[PBEffects::Substitute] < dmg / num_hits
|
||||
end
|
||||
# Flinching
|
||||
if user.faster_than?(target) && target.effects[PBEffects::Substitute] < dmg / num_hits &&
|
||||
(battle.moldBreaker || !target.has_active_ability?(:INNERFOCUS))
|
||||
score += 10
|
||||
end
|
||||
# TODO: Consider effects that trigger per hit.
|
||||
# Score for hitting multiple times
|
||||
score = Battle::AI::Handlers.apply_move_effect_score("HitTwoTimes",
|
||||
score, move, user, target, ai, battle)
|
||||
# Score for flinching
|
||||
score = Battle::AI::Handlers.apply_move_effect_score("FlinchTarget",
|
||||
score, move, user, target, ai, battle)
|
||||
next score
|
||||
}
|
||||
)
|
||||
@@ -244,7 +238,7 @@ Battle::AI::Handlers::MoveEffectScore.add("TwoTurnAttack",
|
||||
has_protect_move = true
|
||||
end
|
||||
end
|
||||
if move.rough_priority > 0
|
||||
if move.rough_priority(user) > 0
|
||||
if target.check_for_move { |m| m.function == "ProtectUserSideFromPriorityMoves" }
|
||||
has_protect_move = true
|
||||
end
|
||||
@@ -305,18 +299,16 @@ Battle::AI::Handlers::MoveEffectScore.add("TwoTurnAttackBurnTarget",
|
||||
)
|
||||
|
||||
#===============================================================================
|
||||
# TODO: Review score modifiers.
|
||||
#
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveEffectScore.add("TwoTurnAttackFlinchTarget",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
# Score for being a two turn attack
|
||||
score = Battle::AI::Handlers.apply_move_effect_score("TwoTurnAttack",
|
||||
score, move, user, target, ai, battle)
|
||||
# Flinching
|
||||
if user.faster_than?(target) && target.effects[PBEffects::Substitute] == 0 &&
|
||||
(battle.moldBreaker || !target.has_active_ability?(:INNERFOCUS))
|
||||
score += 10
|
||||
end
|
||||
# Score for flinching
|
||||
score = Battle::AI::Handlers.apply_move_effect_score("FlinchTarget",
|
||||
score, move, user, target, ai, battle)
|
||||
next score
|
||||
}
|
||||
)
|
||||
|
||||
@@ -316,8 +316,8 @@ Battle::AI::Handlers::MoveEffectScore.add("TargetUsesItsLastUsedMoveAgain",
|
||||
#===============================================================================
|
||||
Battle::AI::Handlers::MoveEffectScore.add("HigherPriorityInGrassyTerrain",
|
||||
proc { |score, move, user, target, ai, battle|
|
||||
if ai.trainer.medium_skill? && @battle.field.terrain == :Grassy
|
||||
score += 40 if target.faster_than?(user)
|
||||
if ai.trainer.medium_skill? && battle.field.terrain == :Grassy
|
||||
score += 15 if target.faster_than?(user)
|
||||
end
|
||||
next score
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ Battle::AI::Handlers::GeneralMoveScore.add(:add_predicted_damage,
|
||||
dmg = move.rough_damage
|
||||
score += [15.0 * dmg / target.hp, 20].min
|
||||
score += 10 if dmg > target.hp * 1.1 # Predicted to KO the target
|
||||
next score
|
||||
next score.to_i
|
||||
end
|
||||
}
|
||||
)
|
||||
|
||||
@@ -116,7 +116,7 @@ class Battle::AI::AIMove
|
||||
end
|
||||
|
||||
##### Calculate target's defense stat #####
|
||||
defense, def_stage = pbGetDefenseStats(user, target)
|
||||
defense, def_stage = @move.pbGetDefenseStats(user.battler, target.battler)
|
||||
if !user.has_active_ability?(:UNAWARE) || @ai.battle.moldBreaker
|
||||
def_stage = 6 if is_critical && def_stage > 6
|
||||
defense = (defense.to_f * stage_mul[def_stage] / stage_div[def_stage]).floor
|
||||
@@ -552,7 +552,7 @@ class Battle::AI::AIMove
|
||||
# 3 = additional effect has an increased chance to work
|
||||
def additional_effect_usability(user, target)
|
||||
return 0 if @move.addlEffect == 0 # Doesn't have an additional effect
|
||||
return 1 if target.has_active_ability?(:SHIELDDUST) && !battle.moldBreaker
|
||||
return 1 if target.has_active_ability?(:SHIELDDUST) && !@ai.battle.moldBreaker
|
||||
return 3 if (Settings::MECHANICS_GENERATION >= 6 || self.function != "EffectDependsOnEnvironment") &&
|
||||
(user.has_active_ability?(:SERENEGRACE) || user.pbOwnSide.effects[PBEffects::Rainbow] > 0)
|
||||
return 2
|
||||
|
||||
Reference in New Issue
Block a user