Added more debug logging to AI, fixed some bugs in AI

This commit is contained in:
Maruno17
2023-01-16 19:29:28 +00:00
parent 98f16c2afa
commit 2627d68782
21 changed files with 280 additions and 115 deletions

View File

@@ -100,11 +100,18 @@ end
# Poisons the target and decreases its Speed by 1 stage. (Toxic Thread)
#===============================================================================
class Battle::Move::PoisonTargetLowerTargetSpeed1 < Battle::Move
attr_reader :statDown
def initialize(battle, move)
super
@statDown = [:SPEED, 1]
end
def canMagicCoat?; return true; end
def pbFailsAgainstTarget?(user, target, show_message)
if !target.pbCanPoison?(user, false, self) &&
!target.pbCanLowerStatStage?(:SPEED, user, self)
!target.pbCanLowerStatStage?(@statDown[0], user, self)
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
@@ -113,8 +120,8 @@ class Battle::Move::PoisonTargetLowerTargetSpeed1 < Battle::Move
def pbEffectAgainstTarget(user, target)
target.pbPoison(user) if target.pbCanPoison?(user, false, self)
if target.pbCanLowerStatStage?(:SPEED, user, self)
target.pbLowerStatStage(:SPEED, 1, user)
if target.pbCanLowerStatStage?(@statDown[0], user, self)
target.pbLowerStatStage(@statDown[0], @statDown[1], user)
end
end
end

View File

@@ -334,13 +334,20 @@ end
# (Skull Bash)
#===============================================================================
class Battle::Move::TwoTurnAttackChargeRaiseUserDefense1 < Battle::Move::TwoTurnMove
attr_reader :statUp
def initialize(battle, move)
super
@statUp = [:DEFENSE, 1]
end
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} tucked in its head!", user.pbThis))
end
def pbChargingTurnEffect(user, target)
if user.pbCanRaiseStatStage?(:DEFENSE, user, self)
user.pbRaiseStatStage(:DEFENSE, 1, user)
if user.pbCanRaiseStatStage?(@statUp[0], user, self)
user.pbRaiseStatStage(@statUp[0], @statUp[1], user)
end
end
end

View File

@@ -109,6 +109,13 @@ end
# it). (Strength Sap)
#===============================================================================
class Battle::Move::HealUserByTargetAttackLowerTargetAttack1 < Battle::Move
attr_reader :statDown
def initialize(battle, move)
super
@statDown = [:ATTACK, 1]
end
def healingMove?; return true; end
def canMagicCoat?; return true; end
@@ -119,11 +126,11 @@ class Battle::Move::HealUserByTargetAttackLowerTargetAttack1 < Battle::Move
# works even if the stat stage cannot be changed due to an ability or
# other effect.
if !@battle.moldBreaker && target.hasActiveAbility?(:CONTRARY)
if target.statStageAtMax?(:ATTACK)
if target.statStageAtMax?(@statDown[0])
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
elsif target.statStageAtMin?(:ATTACK)
elsif target.statStageAtMin?(@statDown[0])
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
@@ -135,11 +142,11 @@ class Battle::Move::HealUserByTargetAttackLowerTargetAttack1 < Battle::Move
stageMul = [2, 2, 2, 2, 2, 2, 2, 3, 4, 5, 6, 7, 8]
stageDiv = [8, 7, 6, 5, 4, 3, 2, 2, 2, 2, 2, 2, 2]
atk = target.attack
atkStage = target.stages[:ATTACK] + 6
atkStage = target.stages[@statDown[0]] + 6
healAmt = (atk.to_f * stageMul[atkStage] / stageDiv[atkStage]).floor
# Reduce target's Attack stat
if target.pbCanLowerStatStage?(:ATTACK, user, self)
target.pbLowerStatStage(:ATTACK, 1, user)
if target.pbCanLowerStatStage?(@statDown[0], user, self)
target.pbLowerStatStage(@statDown[0], @statDown[1], user)
end
# Heal user
if target.hasActiveAbility?(:LIQUIDOOZE, true)