More or less standardised separator comments in the code

This commit is contained in:
Maruno17
2024-06-27 21:21:26 +01:00
parent 225549bfce
commit 509a414f37
198 changed files with 1907 additions and 1263 deletions

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
class Battle::Battler
# Fundamental to this object
attr_reader :battle
@@ -52,9 +55,10 @@ class Battle::Battler
ACC_EVA_STAGE_DIVISORS = [9, 8, 7, 6, 5, 4, 3, 3, 3, 3, 3, 3, 3]
STAT_STAGE_MAXIMUM = 6 # Is also the minimum (-6)
#=============================================================================
# Complex accessors
#=============================================================================
#-----------------------------------------------------------------------------
# Complex accessors.
#-----------------------------------------------------------------------------
attr_reader :level
def level=(value)
@@ -130,18 +134,20 @@ class Battle::Battler
@battle.scene.pbRefreshOne(@index)
end
#=============================================================================
# Properties from Pokémon
#=============================================================================
#-----------------------------------------------------------------------------
# Properties from Pokémon.
#-----------------------------------------------------------------------------
def happiness; return @pokemon ? @pokemon.happiness : 0; end
def affection_level; return @pokemon ? @pokemon.affection_level : 2; end
def gender; return @pokemon ? @pokemon.gender : 0; end
def nature; return @pokemon ? @pokemon.nature : nil; end
def pokerusStage; return @pokemon ? @pokemon.pokerusStage : 0; end
#=============================================================================
# Mega Evolution, Primal Reversion, Shadow Pokémon
#=============================================================================
#-----------------------------------------------------------------------------
# Mega Evolution, Primal Reversion, Shadow Pokémon.
#-----------------------------------------------------------------------------
def hasMega?
return false if @effects[PBEffects::Transform]
return @pokemon&.hasMegaForm?
@@ -160,9 +166,10 @@ class Battle::Battler
def inHyperMode?; return false; end
#=============================================================================
# Display-only properties
#=============================================================================
#-----------------------------------------------------------------------------
# Display-only properties.
#-----------------------------------------------------------------------------
def name
return @effects[PBEffects::Illusion].name if @effects[PBEffects::Illusion]
return @name
@@ -242,9 +249,10 @@ class Battle::Battler
return lowerCase ? _INTL("the opposing team") : _INTL("The opposing team")
end
#=============================================================================
# Calculated properties
#=============================================================================
#-----------------------------------------------------------------------------
# Calculated properties.
#-----------------------------------------------------------------------------
def pbSpeed
return 1 if fainted?
stage = @stages[:SPEED] + STAT_STAGE_MAXIMUM
@@ -287,9 +295,10 @@ class Battle::Battler
return [ret, 1].max
end
#=============================================================================
# Queries about what the battler has
#=============================================================================
#-----------------------------------------------------------------------------
# Queries about what the battler has.
#-----------------------------------------------------------------------------
def plainStats
ret = {}
ret[:ATTACK] = self.attack
@@ -698,9 +707,10 @@ class Battle::Battler
@battle.belch[@index & 1][@pokemonIndex] = true
end
#=============================================================================
# Methods relating to this battler's position on the battlefield
#=============================================================================
#-----------------------------------------------------------------------------
# Methods relating to this battler's position on the battlefield.
#-----------------------------------------------------------------------------
# Returns whether the given position belongs to the opposing Pokémon's side.
def opposes?(i = 0)
i = i.index if i.respond_to?("index")

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle::Battler
#=============================================================================
# Creating a battler
#=============================================================================
#-----------------------------------------------------------------------------
# Creating a battler.
#-----------------------------------------------------------------------------
def initialize(btl, idxBattler)
@battle = btl
@index = idxBattler
@@ -282,9 +286,10 @@ class Battle::Battler
@effects[PBEffects::Yawn] = 0
end
#=============================================================================
# Refreshing a battler's properties
#=============================================================================
#-----------------------------------------------------------------------------
# Refreshing a battler's properties.
#-----------------------------------------------------------------------------
def pbUpdate(fullChange = false)
return if !@pokemon
@pokemon.calc_stats

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle::Battler
#=============================================================================
# Change HP
#=============================================================================
#-----------------------------------------------------------------------------
# Change HP.
#-----------------------------------------------------------------------------
def pbReduceHP(amt, anim = true, registerDamage = true, anyAnim = true)
amt = amt.round
amt = @hp if amt > @hp
@@ -93,9 +97,10 @@ class Battle::Battler
@battle.pbEndPrimordialWeather
end
#=============================================================================
# Move PP
#=============================================================================
#-----------------------------------------------------------------------------
# Move PP.
#-----------------------------------------------------------------------------
def pbSetPP(move, pp)
move.pp = pp
# No need to care about @effects[PBEffects::Mimic], since Mimic can't copy
@@ -118,9 +123,10 @@ class Battle::Battler
pbSetPP(move, move.pp - 1) if move.pp > 0
end
#=============================================================================
# Change type
#=============================================================================
#-----------------------------------------------------------------------------
# Change type.
#-----------------------------------------------------------------------------
def pbChangeTypes(newType)
if newType.is_a?(Battle::Battler)
newTypes = newType.pbTypes
@@ -147,9 +153,10 @@ class Battle::Battler
@effects[PBEffects::Roost] = false
end
#=============================================================================
# Forms
#=============================================================================
#-----------------------------------------------------------------------------
# Forms.
#-----------------------------------------------------------------------------
def pbChangeForm(newForm, msg)
return if fainted? || @effects[PBEffects::Transform] || @form == newForm
oldForm = @form

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle::Battler
#=============================================================================
# Generalised checks for whether a status problem can be inflicted
#=============================================================================
#-----------------------------------------------------------------------------
# Generalised checks for whether a status problem can be inflicted.
#-----------------------------------------------------------------------------
# NOTE: Not all "does it have this status?" checks use this method. If the
# check is leading up to curing self of that status condition, then it
# will look at the value of @status directly instead - if it is that
@@ -212,9 +216,10 @@ class Battle::Battler
return true
end
#=============================================================================
# Generalised infliction of status problem
#=============================================================================
#-----------------------------------------------------------------------------
# Generalised infliction of status problem.
#-----------------------------------------------------------------------------
def pbInflictStatus(newStatus, newStatusCount = 0, msg = nil, user = nil)
# Inflict the new status
self.status = newStatus
@@ -269,9 +274,10 @@ class Battle::Battler
end
end
#=============================================================================
# Sleep
#=============================================================================
#-----------------------------------------------------------------------------
# Sleep.
#-----------------------------------------------------------------------------
def asleep?
return pbHasStatus?(:SLEEP)
end
@@ -323,9 +329,10 @@ class Battle::Battler
return duration
end
#=============================================================================
# Poison
#=============================================================================
#-----------------------------------------------------------------------------
# Poison.
#-----------------------------------------------------------------------------
def poisoned?
return pbHasStatus?(:POISON)
end
@@ -342,9 +349,10 @@ class Battle::Battler
pbInflictStatus(:POISON, (toxic) ? 1 : 0, msg, user)
end
#=============================================================================
# Burn
#=============================================================================
#-----------------------------------------------------------------------------
# Burn.
#-----------------------------------------------------------------------------
def burned?
return pbHasStatus?(:BURN)
end
@@ -361,9 +369,10 @@ class Battle::Battler
pbInflictStatus(:BURN, 0, msg, user)
end
#=============================================================================
# Paralyze
#=============================================================================
#-----------------------------------------------------------------------------
# Paralyze.
#-----------------------------------------------------------------------------
def paralyzed?
return pbHasStatus?(:PARALYSIS)
end
@@ -380,9 +389,10 @@ class Battle::Battler
pbInflictStatus(:PARALYSIS, 0, msg, user)
end
#=============================================================================
# Freeze
#=============================================================================
#-----------------------------------------------------------------------------
# Freeze.
#-----------------------------------------------------------------------------
def frozen?
return pbHasStatus?(:FROZEN)
end
@@ -395,9 +405,10 @@ class Battle::Battler
pbInflictStatus(:FROZEN, 0, msg, user)
end
#=============================================================================
# Generalised status displays
#=============================================================================
#-----------------------------------------------------------------------------
# Generalised status displays.
#-----------------------------------------------------------------------------
def pbContinueStatus
if self.status == :POISON && @statusCount > 0
@battle.pbCommonAnimation("Toxic", self)
@@ -436,9 +447,10 @@ class Battle::Battler
PBDebug.log("[Status change] #{pbThis}'s status was cured") if !showMessages
end
#=============================================================================
# Confusion
#=============================================================================
#-----------------------------------------------------------------------------
# Confusion.
#-----------------------------------------------------------------------------
def pbCanConfuse?(user = nil, showMessages = true, move = nil, selfInflicted = false)
return false if fainted?
if @effects[PBEffects::Confusion] > 0
@@ -499,9 +511,10 @@ class Battle::Battler
@effects[PBEffects::Confusion] = 0
end
#=============================================================================
# Attraction
#=============================================================================
#-----------------------------------------------------------------------------
# Attraction.
#-----------------------------------------------------------------------------
def pbCanAttract?(user, showMessages = true)
return false if fainted?
return false if !user || user.fainted?
@@ -562,9 +575,10 @@ class Battle::Battler
@effects[PBEffects::Attract] = -1
end
#=============================================================================
# Flinching
#=============================================================================
#-----------------------------------------------------------------------------
# Flinching.
#-----------------------------------------------------------------------------
def pbFlinch(_user = nil)
return if hasActiveAbility?(:INNERFOCUS) && !beingMoldBroken?
@effects[PBEffects::Flinch] = true

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle::Battler
#=============================================================================
# Increase stat stages
#=============================================================================
#-----------------------------------------------------------------------------
# Increase stat stages.
#-----------------------------------------------------------------------------
def statStageAtMax?(stat)
return @stages[stat] >= STAT_STAGE_MAXIMUM
end
@@ -113,9 +117,10 @@ class Battle::Battler
return ret
end
#=============================================================================
# Decrease stat stages
#=============================================================================
#-----------------------------------------------------------------------------
# Decrease stat stages.
#-----------------------------------------------------------------------------
def statStageAtMin?(stat)
return @stages[stat] <= -STAT_STAGE_MAXIMUM
end
@@ -364,9 +369,10 @@ class Battle::Battler
return pbLowerStatStageByCause(:ATTACK, 1, user, user.abilityName)
end
#=============================================================================
# Reset stat stages
#=============================================================================
#-----------------------------------------------------------------------------
# Reset stat stages.
#-----------------------------------------------------------------------------
def hasAlteredStatStages?
GameData::Stat.each_battle { |s| return true if @stages[s.id] != 0 }
return false

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle::Battler
#=============================================================================
# Ability trigger checks
#=============================================================================
#-----------------------------------------------------------------------------
# Ability trigger checks.
#-----------------------------------------------------------------------------
def pbAbilitiesOnSwitchOut
if abilityActive?
Battle::AbilityEffects.triggerOnSwitchOut(self.ability, self, false)
@@ -98,9 +102,10 @@ class Battle::Battler
end
end
#=============================================================================
# Ability curing
#=============================================================================
#-----------------------------------------------------------------------------
# Ability curing.
#-----------------------------------------------------------------------------
# Cures status conditions, confusion and infatuation.
def pbAbilityStatusCureCheck
if abilityActive?
@@ -108,9 +113,10 @@ class Battle::Battler
end
end
#=============================================================================
# Ability effects
#=============================================================================
#-----------------------------------------------------------------------------
# Ability effects.
#-----------------------------------------------------------------------------
# For abilities that grant immunity to moves of a particular type, and raises
# one of the ability's bearer's stats instead.
def pbMoveImmunityStatRaisingAbility(user, move, moveType, immuneType, stat, increment, show_message)
@@ -165,9 +171,10 @@ class Battle::Battler
return true
end
#=============================================================================
# Ability change
#=============================================================================
#-----------------------------------------------------------------------------
# Ability change.
#-----------------------------------------------------------------------------
def pbOnLosingAbility(oldAbil, suppressed = false)
if oldAbil == :NEUTRALIZINGGAS && (suppressed || !@effects[PBEffects::GastroAcid])
pbAbilitiesOnNeutralizingGasEnding
@@ -206,9 +213,10 @@ class Battle::Battler
@battle.pbEndPrimordialWeather
end
#=============================================================================
# Held item consuming/removing
#=============================================================================
#-----------------------------------------------------------------------------
# Held item consuming/removing.
#-----------------------------------------------------------------------------
def canConsumeBerry?
return false if @battle.pbCheckOpposingAbility([:UNNERVE, :ASONECHILLINGNEIGH, :ASONEGRIMNEIGH], @index)
return true
@@ -285,9 +293,10 @@ class Battle::Battler
pbSymbiosis if !own_item && !fling # Bug Bite/Pluck users trigger Symbiosis
end
#=============================================================================
# Held item trigger checks
#=============================================================================
#-----------------------------------------------------------------------------
# Held item trigger checks.
#-----------------------------------------------------------------------------
# NOTE: A Pokémon using Bug Bite/Pluck, and a Pokémon having an item thrown at
# it via Fling, will gain the effect of the item even if the Pokémon is
# affected by item-negating effects.
@@ -393,9 +402,10 @@ class Battle::Battler
end
end
#=============================================================================
# Item effects
#=============================================================================
#-----------------------------------------------------------------------------
# Item effects.
#-----------------------------------------------------------------------------
def pbConfusionBerry(item_to_use, forced, confuse_stat, confuse_msg)
return false if !forced && !canHeal?
return false if !forced && !canConsumePinchBerry?(Settings::MECHANICS_GENERATION >= 7)

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle::Battler
#=============================================================================
# Turn processing
#=============================================================================
#-----------------------------------------------------------------------------
# Turn processing.
#-----------------------------------------------------------------------------
def pbProcessTurn(choice, tryFlee = true)
return false if fainted?
# Wild roaming Pokémon always flee if possible
@@ -55,9 +59,10 @@ class Battle::Battler
return true
end
#=============================================================================
#-----------------------------------------------------------------------------
#
#=============================================================================
#-----------------------------------------------------------------------------
def pbBeginTurn(_choice)
# Cancel some lingering effects which only apply until the user next moves
@effects[PBEffects::DestinyBondPrevious] = @effects[PBEffects::DestinyBond]
@@ -131,10 +136,11 @@ class Battle::Battler
pbItemHPHealCheck
end
#=============================================================================
#-----------------------------------------------------------------------------
# Simple "use move" method, used when a move calls another move and for Future
# Sight's attack
#=============================================================================
# Sight's attack.
#-----------------------------------------------------------------------------
def pbUseMoveSimple(moveID, target = -1, idxMove = -1, specialUsage = true)
choice = []
choice[0] = :UseMove # "Use move"
@@ -150,9 +156,10 @@ class Battle::Battler
pbUseMove(choice, specialUsage)
end
#=============================================================================
# Master "use move" method
#=============================================================================
#-----------------------------------------------------------------------------
# Master "use move" method.
#-----------------------------------------------------------------------------
def pbUseMove(choice, specialUsage = false)
# NOTE: This is intentionally determined before a multi-turn attack can
# set specialUsage to true.
@@ -582,9 +589,10 @@ class Battle::Battler
end
end
#=============================================================================
# Attack a single target
#=============================================================================
#-----------------------------------------------------------------------------
# Attack a single target.
#-----------------------------------------------------------------------------
def pbProcessMoveHit(move, user, targets, hitNum, skipAccuracyCheck)
return false if user.fainted?
# For two-turn attacks being used in a single turn

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle::Battler
#=============================================================================
# Get move's user
#=============================================================================
#-----------------------------------------------------------------------------
# Get move's user.
#-----------------------------------------------------------------------------
def pbFindUser(_choice, _move)
return self
end
@@ -30,9 +34,10 @@ class Battle::Battler
return user
end
#=============================================================================
# Get move's default target(s)
#=============================================================================
#-----------------------------------------------------------------------------
# Get move's default target(s).
#-----------------------------------------------------------------------------
def pbFindTargets(choice, move, user)
preTarget = choice[3] # A target that was already chosen
targets = []
@@ -90,9 +95,10 @@ class Battle::Battler
return targets
end
#=============================================================================
# Redirect attack to another target
#=============================================================================
#-----------------------------------------------------------------------------
# Redirect attack to another target.
#-----------------------------------------------------------------------------
def pbChangeTargets(move, user, targets)
target_data = move.pbTarget(user)
return targets if @battle.switching # For Pursuit interrupting a switch
@@ -167,9 +173,10 @@ class Battle::Battler
return targets
end
#=============================================================================
# Register target
#=============================================================================
#-----------------------------------------------------------------------------
# Register target.
#-----------------------------------------------------------------------------
def pbAddTarget(targets, user, target, move, nearOnly = true, allowUser = false)
return false if !target || (target.fainted? && !move.targetsPosition?)
return false if !allowUser && target == user

View File

@@ -1,12 +1,13 @@
#===============================================================================
#
#===============================================================================
class Battle::Battler
#=============================================================================
# Decide whether the trainer is allowed to tell the Pokémon to use the given
# move. Called when choosing a command for the round.
# Also called when processing the Pokémon's action, because these effects also
# prevent Pokémon action. Relevant because these effects can become active
# earlier in the same round (after choosing the command but before using the
# move) or an unusable move may be called by another move such as Metronome.
#=============================================================================
def pbCanChooseMove?(move, commandPhase, showMessages = true, specialUsage = false)
# Disable
if @effects[PBEffects::DisableMove] == move.id && !specialUsage
@@ -99,9 +100,9 @@ class Battle::Battler
return true
end
#=============================================================================
# Obedience check
#=============================================================================
#-----------------------------------------------------------------------------
# Obedience check.
# Return true if Pokémon continues attacking (although it may have chosen to
# use a different move in disobedience), or false if attack stops.
def pbObedienceCheck?(choice)
@@ -175,11 +176,11 @@ class Battle::Battler
return false
end
#=============================================================================
#-----------------------------------------------------------------------------
# Check whether the user (self) is able to take action at all.
# If this returns true, and if PP isn't a problem, the move will be considered
# to have been used (even if it then fails for whatever reason).
#=============================================================================
def pbTryUseMove(choice, move, specialUsage, skipAccuracyCheck)
# Check whether it's possible for self to use the given move
# NOTE: Encore has already changed the move being used, no need to have a
@@ -296,10 +297,10 @@ class Battle::Battler
return true
end
#=============================================================================
#-----------------------------------------------------------------------------
# Initial success check against the target. Done once before the first hit.
# Includes move-specific failure conditions, protections and type immunities.
#=============================================================================
def pbSuccessCheckAgainstTarget(move, user, target, targets)
show_message = move.pbShowFailMessages?(targets)
typeMod = move.pbCalcTypeMod(move.calcType, user, target)
@@ -595,10 +596,10 @@ class Battle::Battler
return true
end
#=============================================================================
#-----------------------------------------------------------------------------
# Per-hit success check against the target.
# Includes semi-invulnerable move use and accuracy calculation.
#=============================================================================
def pbSuccessCheckPerHit(move, user, target, skipAccuracyCheck)
# Two-turn attacks can't fail here in the charging turn
return true if user.effects[PBEffects::TwoTurnAttack]
@@ -617,9 +618,9 @@ class Battle::Battler
return false
end
#=============================================================================
#-----------------------------------------------------------------------------
# Message shown when a move fails the per-hit success check above.
#=============================================================================
def pbMissMessage(move, user, target)
if target.damageState.affection_missed
@battle.pbDisplay(_INTL("{1} avoided the move in time with your shout!", target.pbThis))

View File

@@ -1,7 +1,8 @@
#===============================================================================
#
#===============================================================================
class Battle::Battler
#=============================================================================
# Effect per hit
#=============================================================================
# Effect per hit.
def pbEffectsOnMakingHit(move, user, target)
if target.damageState.calcDamage > 0 && !target.damageState.substitute
# Target's ability
@@ -82,9 +83,7 @@ class Battle::Battler
end
end
#=============================================================================
# Effects after all hits (i.e. at end of move usage)
#=============================================================================
# Effects after all hits (i.e. at end of move usage).
def pbEffectsAfterMove(user, targets, move, numHits)
# Defrost
if move.damagingMove?