Fixed error in Powder's backfire message, fixed move disruption affecting recharge moves when it shouldn't, fixed error when Shell Side Arm has no targets, fixed AI not unregistering Mega Evolution if it won't do so after all

This commit is contained in:
Maruno17
2023-06-19 23:55:49 +01:00
parent 539bc0fb50
commit 17e8be9dca
8 changed files with 70 additions and 54 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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