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,4 @@
#===============================================================================
# Results of battle (see module Outcome):
# 0 - Undecided or aborted
# 1 - Player won
@@ -36,7 +37,7 @@
# class Game_Temp
# def add_battle_rule
# (There is no guarantee that this list is complete.)
#===============================================================================
class Battle
module Outcome
UNDECIDED = 0
@@ -115,9 +116,8 @@ class Battle
def pbRandom(x); return rand(x); end
#=============================================================================
# Creating the battle class
#=============================================================================
#-----------------------------------------------------------------------------
def initialize(scene, p1, p2, player, opponent)
if p1.length == 0
raise ArgumentError.new(_INTL("Party 1 has no Pokémon."))
@@ -200,9 +200,10 @@ class Battle
return Outcome.decided?(@decision)
end
#=============================================================================
# Information about the type and size of the battle
#=============================================================================
#-----------------------------------------------------------------------------
# Information about the type and size of the battle.
#-----------------------------------------------------------------------------
def wildBattle?; return @opponent.nil?; end
def trainerBattle?; return !@opponent.nil?; end
@@ -236,9 +237,10 @@ class Battle
return (pbSideSize(0) > pbSideSize(1)) ? (pbSideSize(0) - 1) * 2 : (pbSideSize(1) * 2) - 1
end
#=============================================================================
# Trainers and owner-related methods
#=============================================================================
#-----------------------------------------------------------------------------
# Trainers and owner-related methods.
#-----------------------------------------------------------------------------
def pbPlayer; return @player[0]; end
# Given a battler index, returns the index within @player/@opponent of the
@@ -324,9 +326,10 @@ class Battle
return ret
end
#=============================================================================
# Get party information (counts all teams on the same side)
#=============================================================================
#-----------------------------------------------------------------------------
# Get party information (counts all teams on the same side).
#-----------------------------------------------------------------------------
def pbParty(idxBattler)
return (opposes?(idxBattler)) ? @party2 : @party1
end
@@ -407,10 +410,11 @@ class Battle
return ret
end
#=============================================================================
#-----------------------------------------------------------------------------
# Get team information (a team is only the Pokémon owned by a particular
# trainer)
#=============================================================================
# trainer).
#-----------------------------------------------------------------------------
def pbTeamIndexRangeFromBattlerIndex(idxBattler)
partyStarts = pbPartyStarts(idxBattler)
idxTrainer = pbGetOwnerIndexFromBattlerIndex(idxBattler)
@@ -464,9 +468,10 @@ class Battle
return ret
end
#=============================================================================
# Iterate through battlers
#=============================================================================
#-----------------------------------------------------------------------------
# Iterate through battlers.
#-----------------------------------------------------------------------------
# Unused
def eachBattler
@battlers.each { |b| yield b if b && !b.fainted? }
@@ -577,9 +582,10 @@ class Battle
return [idxBattler]
end
#=============================================================================
# Comparing the positions of two battlers
#=============================================================================
#-----------------------------------------------------------------------------
# Comparing the positions of two battlers.
#-----------------------------------------------------------------------------
def opposes?(idxBattler1, idxBattler2 = 0)
idxBattler1 = idxBattler1.index if idxBattler1.respond_to?("index")
idxBattler2 = idxBattler2.index if idxBattler2.respond_to?("index")
@@ -612,9 +618,10 @@ class Battle
return true
end
#=============================================================================
# Altering a party or rearranging battlers
#=============================================================================
#-----------------------------------------------------------------------------
# Altering a party or rearranging battlers.
#-----------------------------------------------------------------------------
def pbRemoveFromParty(idxBattler, idxParty)
party = pbParty(idxBattler)
# Erase the Pokémon from the party
@@ -670,9 +677,10 @@ class Battle
return true
end
#=============================================================================
#-----------------------------------------------------------------------------
#
#=============================================================================
#-----------------------------------------------------------------------------
# Returns the battler representing the Pokémon at index idxParty in its party,
# on the same side as a battler with battler index of idxBattlerOther.
def pbFindBattler(idxParty, idxBattlerOther = 0)
@@ -724,9 +732,10 @@ class Battle
return @nextPickupUse
end
#=============================================================================
# Weather
#=============================================================================
#-----------------------------------------------------------------------------
# Weather.
#-----------------------------------------------------------------------------
def defaultWeather=(value)
@field.defaultWeather = value
@field.weather = value
@@ -811,9 +820,10 @@ class Battle
# NOTE: The ability splash is hidden again in def pbStartWeather.
end
#=============================================================================
# Terrain
#=============================================================================
#-----------------------------------------------------------------------------
# Terrain.
#-----------------------------------------------------------------------------
def defaultTerrain=(value)
@field.defaultTerrain = value
@field.terrain = value
@@ -847,9 +857,10 @@ class Battle
allBattlers.each { |b| b.pbItemTerrainStatBoostCheck }
end
#=============================================================================
# Messages and animations
#=============================================================================
#-----------------------------------------------------------------------------
# Messages and animations.
#-----------------------------------------------------------------------------
def pbDisplay(msg, &block)
@scene.pbDisplayMessage(msg, &block)
end

View File

@@ -1,18 +1,21 @@
#===============================================================================
#
#===============================================================================
class Battle
class BattleAbortedException < Exception; end
#-----------------------------------------------------------------------------
def pbAbort
raise BattleAbortedException.new("Battle aborted")
end
#=============================================================================
# Makes sure all Pokémon exist that need to. Alter the type of battle if
# necessary. Will never try to create battler positions, only delete them
# (except for wild Pokémon whose number of positions are fixed). Reduces the
# size of each side by 1 and tries again. If the side sizes are uneven, only
# the larger side's size will be reduced by 1 each time, until both sides are
# an equal size (then both sides will be reduced equally).
#=============================================================================
def pbEnsureParticipants
# Prevent battles larger than 2v2 if both sides have multiple trainers
# NOTE: This is necessary to ensure that battlers can never become unable to
@@ -103,9 +106,10 @@ class Battle
end
end
#=============================================================================
#-----------------------------------------------------------------------------
# Set up all battlers
#=============================================================================
#-----------------------------------------------------------------------------
def pbCreateBattler(idxBattler, pkmn, idxParty)
if !@battlers[idxBattler].nil?
raise _INTL("Battler index {1} already exists", idxBattler)
@@ -164,9 +168,10 @@ class Battle
return ret
end
#=============================================================================
# Send out all battlers at the start of battle
#=============================================================================
#-----------------------------------------------------------------------------
# Send out all battlers at the start of battle.
#-----------------------------------------------------------------------------
def pbStartBattleSendOut(sendOuts)
# "Want to battle" messages
if wildBattle?
@@ -241,9 +246,10 @@ class Battle
end
end
#=============================================================================
# Start a battle
#=============================================================================
#-----------------------------------------------------------------------------
# Start a battle.
#-----------------------------------------------------------------------------
def pbStartBattle
PBDebug.log("")
PBDebug.log("================================================================")
@@ -317,9 +323,10 @@ class Battle
pbBattleLoop
end
#=============================================================================
# Main battle loop
#=============================================================================
#-----------------------------------------------------------------------------
# Main battle loop.
#-----------------------------------------------------------------------------
def pbBattleLoop
@turnCount = 0
loop do # Now begin the battle loop
@@ -347,9 +354,10 @@ class Battle
pbEndOfBattle
end
#=============================================================================
# End of battle
#=============================================================================
#-----------------------------------------------------------------------------
# End of battle.
#-----------------------------------------------------------------------------
def pbGainMoney
return if !@internalBattle || !@moneyGain
# Money rewarded from opposing trainers
@@ -511,9 +519,10 @@ class Battle
return @decision
end
#=============================================================================
# Judging
#=============================================================================
#-----------------------------------------------------------------------------
# Judging.
#-----------------------------------------------------------------------------
def pbJudgeCheckpoint(user, move = nil); end
def pbDecisionOnTime

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle
#=============================================================================
# Gaining Experience
#=============================================================================
#-----------------------------------------------------------------------------
# Gaining Experience.
#-----------------------------------------------------------------------------
def pbGainExp
# Play wild victory music if it's the end of the battle (has to be here)
@scene.pbWildBattleSuccess if wildBattle? && pbAllFainted?(1) && !pbAllFainted?(0)
@@ -223,9 +227,10 @@ class Battle
end
end
#=============================================================================
# Learning a move
#=============================================================================
#-----------------------------------------------------------------------------
# Learning a move.
#-----------------------------------------------------------------------------
def pbLearnMove(idxParty, newMove)
pkmn = pbParty(0)[idxParty]
return if !pkmn

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle
#=============================================================================
# Choosing a move/target
#=============================================================================
#-----------------------------------------------------------------------------
# Choosing a move/target.
#-----------------------------------------------------------------------------
def pbCanChooseMove?(idxBattler, idxMove, showMessages, sleepTalk = false)
battler = @battlers[idxBattler]
move = battler.moves[idxMove]
@@ -130,9 +134,9 @@ class Battle
return true
end
#=============================================================================
# Turn order calculation (priority)
#=============================================================================
#-----------------------------------------------------------------------------
# Turn order calculation (priority).
#-----------------------------------------------------------------------------
def pbCalculatePriority(fullCalc = false, indexArray = nil)
needRearranging = false
if fullCalc

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle
#=============================================================================
# Choosing Pokémon to switch
#=============================================================================
#-----------------------------------------------------------------------------
# Choosing Pokémon to switch.
#-----------------------------------------------------------------------------
# Checks whether the replacement Pokémon (at party index idxParty) can enter
# battle.
# NOTE: Messages are only shown while in the party screen when choosing a
@@ -104,10 +108,11 @@ class Battle
return true
end
#=============================================================================
#-----------------------------------------------------------------------------
# Open the party screen and potentially pick a replacement Pokémon (or AI
# chooses replacement)
#=============================================================================
# chooses replacement).
#-----------------------------------------------------------------------------
# Open party screen and potentially choose a Pokémon to switch with. Used in
# all instances where the party screen is opened.
def pbPartyScreen(idxBattler, checkLaxOnly = false, canCancel = false, shouldRegister = false)
@@ -134,9 +139,10 @@ class Battle
return @battleAI.pbDefaultChooseNewEnemy(idxBattler)
end
#=============================================================================
# Switching Pokémon
#=============================================================================
#-----------------------------------------------------------------------------
# Switching Pokémon.
#-----------------------------------------------------------------------------
# General switching method that checks if any Pokémon need to be sent out and,
# if so, does. Called at the end of each round.
def pbEORSwitch(favorDraws = false)
@@ -296,9 +302,10 @@ class Battle
end
end
#=============================================================================
# Effects upon a Pokémon entering battle
#=============================================================================
#-----------------------------------------------------------------------------
# Effects upon a Pokémon entering battle.
#-----------------------------------------------------------------------------
# Called at the start of battle only.
def pbOnAllBattlersEnteringBattle
pbCalculatePriority(true)

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle
#=============================================================================
# Choosing to use an item
#=============================================================================
#-----------------------------------------------------------------------------
# Choosing to use an item.
#-----------------------------------------------------------------------------
def pbCanUseItemOnPokemon?(item, pkmn, battler, scene, showMessages = true)
if !pkmn || pkmn.egg?
scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages
@@ -43,9 +47,10 @@ class Battle
return true
end
#=============================================================================
# Using an item
#=============================================================================
#-----------------------------------------------------------------------------
# Using an item.
#-----------------------------------------------------------------------------
def pbConsumeItemInBag(item, idxBattler)
return if !item
return if !GameData::Item.get(item).consumed_after_use?

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle
#=============================================================================
#-----------------------------------------------------------------------------
# Running from battle
#=============================================================================
#-----------------------------------------------------------------------------
def pbCanRun?(idxBattler)
return false if trainerBattle?
battler = @battlers[idxBattler]

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle
#=============================================================================
# Shifting a battler to another position in a battle larger than double
#=============================================================================
#-----------------------------------------------------------------------------
# Shifting a battler to another position in a battle larger than double.
#-----------------------------------------------------------------------------
def pbCanShift?(idxBattler)
return false if pbSideSize(0) <= 2 && pbSideSize(1) <= 2 # Double battle or smaller
idxOther = -1
@@ -25,9 +29,10 @@ class Battle
return true
end
#=============================================================================
# Calling at a battler
#=============================================================================
#-----------------------------------------------------------------------------
# Calling at a battler.
#-----------------------------------------------------------------------------
def pbRegisterCall(idxBattler)
@choices[idxBattler][0] = :Call
@choices[idxBattler][1] = 0
@@ -61,9 +66,10 @@ class Battle
end
end
#=============================================================================
# Choosing to Mega Evolve a battler
#=============================================================================
#-----------------------------------------------------------------------------
# Choosing to Mega Evolve a battler.
#-----------------------------------------------------------------------------
def pbHasMegaRing?(idxBattler)
if pbOwnedByPlayer?(idxBattler)
@mega_rings.each { |item| return true if $bag.has?(item) }
@@ -129,9 +135,10 @@ class Battle
return @megaEvolution[side][owner] == idxBattler
end
#=============================================================================
# Mega Evolving a battler
#=============================================================================
#-----------------------------------------------------------------------------
# Mega Evolving a battler.
#-----------------------------------------------------------------------------
def pbMegaEvolve(idxBattler)
battler = @battlers[idxBattler]
return if !battler || !battler.pokemon
@@ -174,9 +181,10 @@ class Battle
pbCalculatePriority(false, [idxBattler]) if Settings::RECALCULATE_TURN_ORDER_AFTER_MEGA_EVOLUTION
end
#=============================================================================
# Primal Reverting a battler
#=============================================================================
#-----------------------------------------------------------------------------
# Primal Reverting a battler.
#-----------------------------------------------------------------------------
def pbPrimalReversion(idxBattler)
battler = @battlers[idxBattler]
return if !battler || !battler.pokemon || battler.fainted?

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle
#=============================================================================
# Clear commands
#=============================================================================
#-----------------------------------------------------------------------------
# Clear commands.
#-----------------------------------------------------------------------------
def pbClearChoice(idxBattler)
@choices[idxBattler] = [] if !@choices[idxBattler]
@choices[idxBattler][0] = :None
@@ -22,16 +26,18 @@ class Battle
pbClearChoice(idxBattler)
end
#=============================================================================
# Use main command menu (Fight/Pokémon/Bag/Run)
#=============================================================================
#-----------------------------------------------------------------------------
# Use main command menu (Fight/Pokémon/Bag/Run).
#-----------------------------------------------------------------------------
def pbCommandMenu(idxBattler, firstAction)
return @scene.pbCommandMenu(idxBattler, firstAction)
end
#=============================================================================
# Check whether actions can be taken
#=============================================================================
#-----------------------------------------------------------------------------
# Check whether actions can be taken.
#-----------------------------------------------------------------------------
def pbCanShowCommands?(idxBattler)
battler = @battlers[idxBattler]
return false if !battler || battler.fainted?
@@ -53,9 +59,10 @@ class Battle
return usable
end
#=============================================================================
# Use sub-menus to choose an action, and register it if is allowed
#=============================================================================
#-----------------------------------------------------------------------------
# Use sub-menus to choose an action, and register it if is allowed.
#-----------------------------------------------------------------------------
# Returns true if a choice was made, false if cancelled.
def pbFightMenu(idxBattler)
# Auto-use Encored move or no moves choosable, so auto-use Struggle
@@ -168,9 +175,10 @@ class Battle
end
end
#=============================================================================
# Command phase
#=============================================================================
#-----------------------------------------------------------------------------
# Command phase.
#-----------------------------------------------------------------------------
def pbCommandPhase
@command_phase = true
@scene.pbBeginCommandPhase

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle
#=============================================================================
# Attack phase actions
#=============================================================================
#-----------------------------------------------------------------------------
# Attack phase actions.
#-----------------------------------------------------------------------------
# Quick Claw, Custap Berry's "X let it move first!" message.
def pbAttackPhasePriorityChangeMessages
pbPriority.each do |b|
@@ -170,9 +174,10 @@ class Battle
end
end
#=============================================================================
# Attack phase
#=============================================================================
#-----------------------------------------------------------------------------
# Attack phase.
#-----------------------------------------------------------------------------
def pbAttackPhase
@scene.pbBeginAttackPhase
# Reset certain effects

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle
#=============================================================================
# End Of Round end weather check and weather effects
#=============================================================================
#-----------------------------------------------------------------------------
# End Of Round end weather check and weather effects.
#-----------------------------------------------------------------------------
def pbEOREndWeather(priority)
# NOTE: Primordial weather doesn't need to be checked here, because if it
# could wear off here, it will have worn off already.
@@ -74,9 +78,10 @@ class Battle
battler.pbFaint if battler.fainted?
end
#=============================================================================
# End Of Round use delayed moves (Future Sight, Doom Desire)
#=============================================================================
#-----------------------------------------------------------------------------
# End Of Round use delayed moves (Future Sight, Doom Desire).
#-----------------------------------------------------------------------------
def pbEORUseFutureSight(position, position_index)
return if !position || position.effects[PBEffects::FutureSightCounter] == 0
position.effects[PBEffects::FutureSightCounter] -= 1
@@ -116,9 +121,10 @@ class Battle
position.effects[PBEffects::FutureSightUserPartyIndex] = -1
end
#=============================================================================
# End Of Round healing from Wish
#=============================================================================
#-----------------------------------------------------------------------------
# End Of Round healing from Wish.
#-----------------------------------------------------------------------------
def pbEORWishHealing
@positions.each_with_index do |pos, idxPos|
next if !pos || pos.effects[PBEffects::Wish] == 0
@@ -131,9 +137,10 @@ class Battle
end
end
#=============================================================================
# End Of Round Sea of Fire damage (Fire Pledge + Grass Pledge combination)
#=============================================================================
#-----------------------------------------------------------------------------
# End Of Round Sea of Fire damage (Fire Pledge + Grass Pledge combination).
#-----------------------------------------------------------------------------
def pbEORSeaOfFireDamage(priority)
2.times do |side|
next if sides[side].effects[PBEffects::SeaOfFire] == 0
@@ -152,9 +159,10 @@ class Battle
end
end
#=============================================================================
# End Of Round healing from Grassy Terrain
#=============================================================================
#-----------------------------------------------------------------------------
# End Of Round healing from Grassy Terrain.
#-----------------------------------------------------------------------------
def pbEORTerrainHealing(battler)
return if battler.fainted?
# Grassy Terrain (healing)
@@ -165,9 +173,10 @@ class Battle
end
end
#=============================================================================
# End Of Round various healing effects
#=============================================================================
#-----------------------------------------------------------------------------
# End Of Round various healing effects.
#-----------------------------------------------------------------------------
def pbEORHealingEffects(priority)
# Aqua Ring
priority.each do |battler|
@@ -205,9 +214,10 @@ class Battle
end
end
#=============================================================================
# End Of Round deal damage from status problems
#=============================================================================
#-----------------------------------------------------------------------------
# End Of Round deal damage from status problems.
#-----------------------------------------------------------------------------
def pbEORStatusProblemDamage(priority)
# Damage from poisoning
priority.each do |battler|
@@ -255,9 +265,10 @@ class Battle
end
end
#=============================================================================
# End Of Round deal damage from effects (except by trapping)
#=============================================================================
#-----------------------------------------------------------------------------
# End Of Round deal damage from effects (except by trapping).
#-----------------------------------------------------------------------------
def pbEOREffectDamage(priority)
# Damage from sleep (Nightmare)
priority.each do |battler|
@@ -278,9 +289,10 @@ class Battle
end
end
#=============================================================================
# End Of Round deal damage to trapped battlers
#=============================================================================
#-----------------------------------------------------------------------------
# End Of Round deal damage to trapped battlers.
#-----------------------------------------------------------------------------
TRAPPING_MOVE_COMMON_ANIMATIONS = {
:BIND => "Bind",
:CLAMP => "Clamp",
@@ -312,9 +324,10 @@ class Battle
end
end
#=============================================================================
# End Of Round end effects that apply to a battler
#=============================================================================
#-----------------------------------------------------------------------------
# End Of Round end effects that apply to a battler.
#-----------------------------------------------------------------------------
def pbEORCountDownBattlerEffect(priority, effect)
priority.each do |battler|
next if battler.fainted? || battler.effects[effect] == 0
@@ -394,9 +407,10 @@ class Battle
end
end
#=============================================================================
# End Of Round end effects that apply to one side of the field
#=============================================================================
#-----------------------------------------------------------------------------
# End Of Round end effects that apply to one side of the field.
#-----------------------------------------------------------------------------
def pbEORCountDownSideEffect(side, effect, msg)
return if @sides[side].effects[effect] <= 0
@sides[side].effects[effect] -= 1
@@ -436,9 +450,10 @@ class Battle
_INTL("{1}'s Aurora Veil wore off!", @battlers[side].pbTeam))
end
#=============================================================================
# End Of Round end effects that apply to the whole field
#=============================================================================
#-----------------------------------------------------------------------------
# End Of Round end effects that apply to the whole field.
#-----------------------------------------------------------------------------
def pbEORCountDownFieldEffect(effect, msg)
return if @field.effects[effect] <= 0
@field.effects[effect] -= 1
@@ -470,9 +485,10 @@ class Battle
_INTL("Magic Room wore off, and held items' effects returned to normal!"))
end
#=============================================================================
# End Of Round end terrain check
#=============================================================================
#-----------------------------------------------------------------------------
# End Of Round end terrain check.
#-----------------------------------------------------------------------------
def pbEOREndTerrain
# Count down terrain duration
@field.terrainDuration -= 1 if @field.terrainDuration > 0
@@ -509,9 +525,10 @@ class Battle
end
end
#=============================================================================
# End Of Round end self-inflicted effects on battler
#=============================================================================
#-----------------------------------------------------------------------------
# End Of Round end self-inflicted effects on battler.
#-----------------------------------------------------------------------------
def pbEOREndBattlerSelfEffects(battler)
return if battler.fainted?
# Hyper Mode (Shadow Pokémon)
@@ -541,9 +558,10 @@ class Battle
end
end
#=============================================================================
# End Of Round shift distant battlers to middle positions
#=============================================================================
#-----------------------------------------------------------------------------
# End Of Round shift distant battlers to middle positions.
#-----------------------------------------------------------------------------
def pbEORShiftDistantBattlers
# Move battlers around if none are near to each other
# NOTE: This code assumes each side has a maximum of 3 battlers on it, and
@@ -596,9 +614,10 @@ class Battle
end
end
#=============================================================================
# Main End Of Round phase method
#=============================================================================
#-----------------------------------------------------------------------------
# Main End Of Round phase method.
#-----------------------------------------------------------------------------
def pbEndOfRoundPhase
PBDebug.log("")
PBDebug.log("[End of round #{@turnCount + 1}]")