Added script to make two random AI trainers battle, tweaked battle messages when logged, fixed typos

This commit is contained in:
Maruno17
2022-09-06 22:57:51 +01:00
parent b8c61a6038
commit eecb7a1453
27 changed files with 335 additions and 154 deletions

View File

@@ -8,7 +8,7 @@ class Battle::Battler
amt = 1 if amt < 1 && !fainted?
oldHP = @hp
self.hp -= amt
PBDebug.log("[HP change] #{pbThis} lost #{amt} HP (#{oldHP}=>#{@hp})") if amt > 0
PBDebug.log("[HP change] #{pbThis} lost #{amt} HP (#{oldHP} -> #{@hp})") if amt > 0
raise _INTL("HP less than 0") if @hp < 0
raise _INTL("HP greater than total HP") if @hp > @totalhp
@battle.scene.pbHPChanged(self, oldHP, anim) if anyAnim && amt > 0
@@ -26,7 +26,7 @@ class Battle::Battler
amt = 1 if amt < 1 && @hp < @totalhp
oldHP = @hp
self.hp += amt
PBDebug.log("[HP change] #{pbThis} gained #{amt} HP (#{oldHP}=>#{@hp})") if amt > 0
PBDebug.log("[HP change] #{pbThis} gained #{amt} HP (#{oldHP} -> #{@hp})") if amt > 0
raise _INTL("HP less than 0") if @hp < 0
raise _INTL("HP greater than total HP") if @hp > @totalhp
@battle.scene.pbHPChanged(self, oldHP, anim) if anyAnim && amt > 0

View File

@@ -37,7 +37,7 @@ class Battle::Battler
if increment > 0
stat_name = GameData::Stat.get(stat).name
new = @stages[stat] + increment
PBDebug.log("[Stat change] #{pbThis}'s #{stat_name}: #{@stages[stat]} -> #{new} (+#{increment})")
PBDebug.log("[Stat change] #{pbThis}'s #{stat_name} changed by +#{increment} (#{@stages[stat]} -> #{new})")
@stages[stat] += increment
@statsRaisedThisRound = true
end
@@ -187,7 +187,7 @@ class Battle::Battler
if increment > 0
stat_name = GameData::Stat.get(stat).name
new = @stages[stat] - increment
PBDebug.log("[Stat change] #{pbThis}'s #{stat_name}: #{@stages[stat]} -> #{new} (-#{increment})")
PBDebug.log("[Stat change] #{pbThis}'s #{stat_name} changed by -#{increment} (#{@stages[stat]} -> #{new})")
@stages[stat] -= increment
@statsLoweredThisRound = true
@statsDropped = true

View File

@@ -47,7 +47,7 @@ class Battle::Battler
return false
end
# Use the move
PBDebug.log("[Move usage] #{pbThis} started using #{choice[2].name}")
PBDebug.log("[Use move] #{pbThis} (#{@index}) used #{choice[2].name}")
PBDebug.logonerr {
pbUseMove(choice, choice[2] == @battle.struggle)
}
@@ -146,7 +146,7 @@ class Battle::Battler
choice[2].pp = -1
end
choice[3] = target # Target (-1 means no target yet)
PBDebug.log("[Move usage] #{pbThis} started using the called/simple move #{choice[2].name}")
PBDebug.log("[Use move] #{pbThis} used the called/simple move #{choice[2].name}")
pbUseMove(choice, specialUsage)
end

View File

@@ -192,10 +192,12 @@ class Battle::Battler
return false
end
if @effects[PBEffects::HyperBeam] > 0 # Intentionally before Truant
PBDebug.log("[Move failed] #{pbThis} is recharging after using #{move.name}")
@battle.pbDisplay(_INTL("{1} must recharge!", pbThis))
return false
end
if choice[1] == -2 # Battle Palace
PBDebug.log("[Move failed] #{pbThis} can't act in the Battle Palace somehow")
@battle.pbDisplay(_INTL("{1} appears incapable of using its power!", pbThis))
return false
end
@@ -210,6 +212,7 @@ class Battle::Battler
else
pbContinueStatus
if !move.usableWhenAsleep? # Snore/Sleep Talk
PBDebug.log("[Move failed] #{pbThis} is asleep")
@lastMoveFailed = true
return false
end
@@ -220,6 +223,7 @@ class Battle::Battler
pbCureStatus
else
pbContinueStatus
PBDebug.log("[Move failed] #{pbThis} is frozen")
@lastMoveFailed = true
return false
end
@@ -235,12 +239,14 @@ class Battle::Battler
@battle.pbDisplay(_INTL("{1} is loafing around!", pbThis))
@lastMoveFailed = true
@battle.pbHideAbilitySplash(self)
PBDebug.log("[Move failed] #{pbThis} can't act because of #{abilityName}")
return false
end
end
# Flinching
if @effects[PBEffects::Flinch]
@battle.pbDisplay(_INTL("{1} flinched and couldn't move!", pbThis))
PBDebug.log("[Move failed] #{pbThis} flinched")
if abilityActive?
Battle::AbilityEffects.triggerOnFlinch(self.ability, self, @battle)
end
@@ -259,6 +265,7 @@ class Battle::Battler
threshold = (Settings::MECHANICS_GENERATION >= 7) ? 33 : 50 # % chance
if @battle.pbRandom(100) < threshold
pbConfusionDamage(_INTL("It hurt itself in its confusion!"))
PBDebug.log("[Move failed] #{pbThis} hurt itself in its confusion")
@lastMoveFailed = true
return false
end
@@ -267,6 +274,7 @@ class Battle::Battler
# Paralysis
if @status == :PARALYSIS && @battle.pbRandom(100) < 25
pbContinueStatus
PBDebug.log("[Move failed] #{pbThis} is paralyzed")
@lastMoveFailed = true
return false
end
@@ -277,6 +285,7 @@ class Battle::Battler
@battle.battlers[@effects[PBEffects::Attract]].pbThis(true)))
if @battle.pbRandom(100) < 50
@battle.pbDisplay(_INTL("{1} is immobilized by love!", pbThis))
PBDebug.log("[Move failed] #{pbThis} is immobilized by love")
@lastMoveFailed = true
return false
end
@@ -295,7 +304,10 @@ class Battle::Battler
# Two-turn attacks can't fail here in the charging turn
return true if user.effects[PBEffects::TwoTurnAttack]
# Move-specific failures
return false if move.pbFailsAgainstTarget?(user, target, show_message)
if move.pbFailsAgainstTarget?(user, target, show_message)
PBDebug.log(sprintf("[Move failed] In function code %s's def pbFailsAgainstTarget?", move.function))
return false
end
# Immunity to priority moves because of Psychic Terrain
if @battle.field.terrain == :Psychic && target.affectedByTerrain? && target.opposes?(user) &&
@battle.choices[user.index][4] > 0 # Move priority saved from pbCalculatePriority
@@ -551,15 +563,17 @@ class Battle::Battler
miss = true
end
end
target.damageState.invulnerable = true if miss
if !miss
if miss
target.damageState.invulnerable = true
PBDebug.log("[Move failed] Target is semi-invulnerable")
else
# Called by another move
return true if skipAccuracyCheck
# Accuracy check
return true if move.pbAccuracyCheck(user, target) # Includes Counter/Mirror Coat
PBDebug.log("[Move failed] Failed pbAccuracyCheck")
end
# Missed
PBDebug.log("[Move failed] Failed pbAccuracyCheck or target is semi-invulnerable")
return false
end