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,4 +1,6 @@
#===============================================================================
# Battle scene (the visuals of the battle)
#===============================================================================
class Battle::Scene
attr_accessor :abortable # For non-interactive battles, can quit immediately
attr_reader :viewport
@@ -73,9 +75,10 @@ class Battle::Scene
return ret
end
#=============================================================================
# Updating and refreshing
#=============================================================================
#-----------------------------------------------------------------------------
# Updating and refreshing.
#-----------------------------------------------------------------------------
def pbUpdate(cw = nil)
pbGraphicsUpdate
pbInputUpdate
@@ -139,17 +142,19 @@ class Battle::Scene
end
end
#=============================================================================
# Party lineup
#=============================================================================
#-----------------------------------------------------------------------------
# Party lineup.
#-----------------------------------------------------------------------------
# Returns whether the party line-ups are currently coming on-screen
def inPartyAnimation?
return @animations.length > 0
end
#=============================================================================
# Window displays
#=============================================================================
#-----------------------------------------------------------------------------
# Window displays.
#-----------------------------------------------------------------------------
def pbShowWindow(windowType)
# NOTE: If you are not using fancy graphics for the command/fight menus, you
# will need to make "messageBox" also visible if the windowtype if
@@ -307,9 +312,10 @@ class Battle::Scene
end
end
#=============================================================================
# Sprites
#=============================================================================
#-----------------------------------------------------------------------------
# Sprites.
#-----------------------------------------------------------------------------
def pbAddSprite(id, x, y, filename, viewport)
sprite = @sprites[id] || IconSprite.new(x, y, viewport)
if filename
@@ -348,9 +354,10 @@ class Battle::Scene
pbRefresh
end
#=============================================================================
# Phases
#=============================================================================
#-----------------------------------------------------------------------------
# Phases.
#-----------------------------------------------------------------------------
def pbBeginCommandPhase
@sprites["messageWindow"].text = ""
end
@@ -371,9 +378,10 @@ class Battle::Scene
pbDisposeSprites
end
#=============================================================================
#-----------------------------------------------------------------------------
#
#=============================================================================
#-----------------------------------------------------------------------------
def pbSelectBattler(idxBattler, selectMode = 1)
numWindows = @battle.sideSizes.max * 2
numWindows.times do |i|
@@ -401,9 +409,10 @@ class Battle::Scene
@lastMove[idxBattler] = 0
end
#=============================================================================
#-----------------------------------------------------------------------------
#
#=============================================================================
#-----------------------------------------------------------------------------
# This method is called when the player wins a wild Pokémon battle.
# This method can change the battle's music for example.
def pbWildBattleSuccess

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle::Scene
#=============================================================================
# Create the battle scene and its elements
#=============================================================================
#-----------------------------------------------------------------------------
# Create the battle scene and its elements.
#-----------------------------------------------------------------------------
def initialize
@battle = nil
@abortable = false

View File

@@ -1,8 +1,12 @@
#===============================================================================
#
#===============================================================================
class Battle::Scene
#=============================================================================
# The player chooses a main command for a Pokémon
#-----------------------------------------------------------------------------
# The player chooses a main command for a Pokémon.
# Return values: -1=Cancel, 0=Fight, 1=Bag, 2=Pokémon, 3=Run, 4=Call
#=============================================================================
#-----------------------------------------------------------------------------
def pbCommandMenu(idxBattler, firstAction)
shadowTrainer = (GameData::Type.exists?(:SHADOW) && @battle.trainerBattle?)
cmds = [
@@ -62,9 +66,10 @@ class Battle::Scene
return ret
end
#=============================================================================
# The player chooses a move for a Pokémon to use
#=============================================================================
#-----------------------------------------------------------------------------
# The player chooses a move for a Pokémon to use.
#-----------------------------------------------------------------------------
def pbFightMenu(idxBattler, megaEvoPossible = false)
battler = @battle.battlers[idxBattler]
cw = @sprites["fightWindow"]
@@ -132,12 +137,13 @@ class Battle::Scene
@lastMove[idxBattler] = cw.index
end
#=============================================================================
#-----------------------------------------------------------------------------
# Opens the party screen to choose a Pokémon to switch in (or just view its
# summary screens)
# summary screens).
# mode: 0=Pokémon command, 1=choose a Pokémon to send to the Boxes, 2=view
# summaries only
#=============================================================================
#-----------------------------------------------------------------------------
def pbPartyScreen(idxBattler, canCancel = false, mode = 0)
# Fade out and hide all sprites
visibleSprites = pbFadeOutAndHide(@sprites)
@@ -190,9 +196,10 @@ class Battle::Scene
pbFadeInAndShow(@sprites, visibleSprites)
end
#=============================================================================
# Opens the Bag screen and chooses an item to use
#=============================================================================
#-----------------------------------------------------------------------------
# Opens the Bag screen and chooses an item to use.
#-----------------------------------------------------------------------------
def pbItemMenu(idxBattler, _firstAction)
# Fade out and hide all sprites
visibleSprites = pbFadeOutAndHide(@sprites)
@@ -331,9 +338,11 @@ class Battle::Scene
pbFadeInAndShow(@sprites, visibleSprites) if !wasTargeting
end
#=============================================================================
# The player chooses a target battler for a move/item (non-single battles only)
#=============================================================================
#-----------------------------------------------------------------------------
# The player chooses a target battler for a move/item (non-single battles
# only).
#-----------------------------------------------------------------------------
# Returns an array containing battler names to display when choosing a move's
# target.
# nil means can't select that position, "" means can select that position but
@@ -446,9 +455,10 @@ class Battle::Scene
return ret
end
#=============================================================================
# Opens a Pokémon's summary screen to try to learn a new move
#=============================================================================
#-----------------------------------------------------------------------------
# Opens a Pokémon's summary screen to try to learn a new move.
#-----------------------------------------------------------------------------
# Called whenever a Pokémon should forget a move. It should return -1 if the
# selection is canceled, or 0 to 3 to indicate the move to forget. It should
# not allow HM moves to be forgotten.
@@ -462,16 +472,18 @@ class Battle::Scene
return ret
end
#=============================================================================
# Opens the nicknaming screen for a newly caught Pokémon
#=============================================================================
#-----------------------------------------------------------------------------
# Opens the nicknaming screen for a newly caught Pokémon.
#-----------------------------------------------------------------------------
def pbNameEntry(helpText, pkmn)
return pbEnterPokemonName(helpText, 0, Pokemon::MAX_NAME_SIZE, "", pkmn)
end
#=============================================================================
# Shows the Pokédex entry screen for a newly caught Pokémon
#=============================================================================
#-----------------------------------------------------------------------------
# Shows the Pokédex entry screen for a newly caught Pokémon.
#-----------------------------------------------------------------------------
def pbShowPokedex(species)
pbFadeOutIn do
scene = PokemonPokedexInfo_Scene.new

View File

@@ -1,7 +1,8 @@
#===============================================================================
#
#===============================================================================
class Battle::Scene
#=============================================================================
# Animates the battle intro
#=============================================================================
# Animates the battle intro.
def pbBattleIntroAnimation
# Make everything appear
introAnim = Animation::Intro.new(@sprites, @viewport, @battle)
@@ -54,9 +55,7 @@ class Battle::Scene
end
end
#=============================================================================
# Animates a party lineup appearing for the given side
#=============================================================================
# Animates a party lineup appearing for the given side.
def pbShowPartyLineup(side, fullAnim = false)
@animations.push(
Animation::LineupAppear.new(@sprites, @viewport, side,
@@ -69,11 +68,9 @@ class Battle::Scene
end
end
#=============================================================================
# Animates an opposing trainer sliding in from off-screen. Will animate a
# previous trainer that is already on-screen slide off first. Used at the end
# of battle.
#=============================================================================
def pbShowOpponent(idxTrainer)
# Set up trainer appearing animation
appearAnim = Animation::TrainerAppear.new(@sprites, @viewport, idxTrainer)
@@ -84,12 +81,10 @@ class Battle::Scene
end
end
#=============================================================================
# Animates a trainer's sprite and party lineup hiding (if they are visible).
# Animates a Pokémon being sent out into battle, then plays the shiny
# animation for it if relevant.
# sendOuts is an array; each element is itself an array: [idxBattler,pkmn]
#=============================================================================
def pbSendOutBattlers(sendOuts, startBattle = false)
return if sendOuts.length == 0
# If party balls are still appearing, wait for them to finish showing up, as
@@ -155,9 +150,7 @@ class Battle::Scene
end
end
#=============================================================================
# Animates a Pokémon being recalled into its Poké Ball and its data box hiding
#=============================================================================
# Animates a Pokémon being recalled into its Poké Ball and its data box hiding.
def pbRecall(idxBattler)
@briefMessage = false
# Recall animation
@@ -178,9 +171,10 @@ class Battle::Scene
dataBoxAnim.dispose
end
#=============================================================================
# Ability splash bar animations
#=============================================================================
#-----------------------------------------------------------------------------
# Ability splash bar animations.
#-----------------------------------------------------------------------------
def pbShowAbilitySplash(battler)
return if !USE_ABILITY_SPLASH
side = battler.index % 2
@@ -213,9 +207,10 @@ class Battle::Scene
pbShowAbilitySplash(battler)
end
#=============================================================================
# HP change animations
#=============================================================================
#-----------------------------------------------------------------------------
# HP change animations.
#-----------------------------------------------------------------------------
# Shows a HP-changing common animation and animates a data box's HP bar.
# Called by def pbReduceHP, def pbRecoverHP.
def pbHPChanged(battler, oldHP, showAnim = false)
@@ -277,9 +272,9 @@ class Battle::Scene
damageAnims.each { |a| a.dispose }
end
#=============================================================================
# Animates a data box's Exp bar
#=============================================================================
#-----------------------------------------------------------------------------
# Animates a data box's Exp bar.
def pbEXPBar(battler, startExp, endExp, tempExp1, tempExp2)
return if !battler || endExp == startExp
startExpLevel = tempExp1 - startExp
@@ -292,9 +287,7 @@ class Battle::Scene
end
end
#=============================================================================
# Shows stats windows upon a Pokémon levelling up
#=============================================================================
# Shows stats windows upon a Pokémon levelling up.
def pbLevelUp(pkmn, _battler, oldTotalHP, oldAttack, oldDefense, oldSpAtk, oldSpDef, oldSpeed)
pbTopRightWindow(
_INTL("Max. HP<r>+{1}\nAttack<r>+{2}\nDefense<r>+{3}\nSp. Atk<r>+{4}\nSp. Def<r>+{5}\nSpeed<r>+{6}",
@@ -307,9 +300,7 @@ class Battle::Scene
)
end
#=============================================================================
# Animates a Pokémon fainting
#=============================================================================
# Animates a Pokémon fainting.
def pbFaintBattler(battler)
@briefMessage = false
old_height = @sprites["pokemon_#{battler.index}"].src_rect.height
@@ -327,9 +318,10 @@ class Battle::Scene
@sprites["pokemon_#{battler.index}"].src_rect.height = old_height
end
#=============================================================================
# Animates throwing a Poké Ball at a Pokémon in an attempt to catch it
#=============================================================================
#-----------------------------------------------------------------------------
# Animates throwing a Poké Ball at a Pokémon in an attempt to catch it.
#-----------------------------------------------------------------------------
def pbThrow(ball, shakes, critical, targetBattler, showPlayer = false)
@briefMessage = false
captureAnim = Animation::PokeballThrowCapture.new(
@@ -386,9 +378,9 @@ class Battle::Scene
end
#=============================================================================
# Hides all battler shadows before yielding to a move animation, and then
# restores the shadows afterwards
#=============================================================================
# restores the shadows afterwards.
def pbSaveShadows
# Remember which shadows were visible
shadows = Array.new(@battle.battlers.length) do |i|
@@ -406,9 +398,10 @@ class Battle::Scene
end
end
#=============================================================================
# Loads a move/common animation
#=============================================================================
#-----------------------------------------------------------------------------
# Loads a move/common animation.
#-----------------------------------------------------------------------------
# Returns the animation ID to use for a given move/user. Returns nil if that
# move has no animations defined for it.
def pbFindMoveAnimDetails(move2anim, moveID, idxUser, hitNum = 0)
@@ -487,9 +480,10 @@ class Battle::Scene
return nil
end
#=============================================================================
# Plays a move/common animation
#=============================================================================
#-----------------------------------------------------------------------------
# Plays a move/common animation.
#-----------------------------------------------------------------------------
# Plays a move animation.
def pbAnimation(moveID, user, targets, hitNum = 0)
animID = pbFindMoveAnimation(moveID, user.index, hitNum)

View File

@@ -1,5 +1,5 @@
#===============================================================================
# Base class for all three menu classes below
# Base class for all three menu classes below.
#===============================================================================
class Battle::Scene::MenuBase
attr_accessor :x
@@ -92,7 +92,7 @@ class Battle::Scene::MenuBase
end
#===============================================================================
# Command menu (Fight/Pokémon/Bag/Run)
# Command menu (Fight/Pokémon/Bag/Run).
#===============================================================================
class Battle::Scene::CommandMenu < Battle::Scene::MenuBase
# If true, displays graphics from Graphics/UI/Battle/overlay_command.png
@@ -193,7 +193,7 @@ class Battle::Scene::CommandMenu < Battle::Scene::MenuBase
end
#===============================================================================
# Fight menu (choose a move)
# Fight menu (choose a move).
#===============================================================================
class Battle::Scene::FightMenu < Battle::Scene::MenuBase
attr_reader :battler
@@ -437,7 +437,7 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase
end
#===============================================================================
# Target menu (choose a move's target)
# Target menu (choose a move's target).
# NOTE: Unlike the command and fight menus, this one doesn't have a textbox-only
# version.
#===============================================================================

View File

@@ -1,5 +1,5 @@
#===============================================================================
# Data box for regular battles
# Data box for regular battles.
#===============================================================================
class Battle::Scene::PokemonDataBox < Sprite
attr_reader :battler
@@ -18,12 +18,12 @@ class Battle::Scene::PokemonDataBox < Sprite
# Height in pixels of a status icon
STATUS_ICON_HEIGHT = 16
# Text colors
NAME_BASE_COLOR = Color.new(72, 72, 72)
NAME_SHADOW_COLOR = Color.new(184, 184, 184)
MALE_BASE_COLOR = Color.new(48, 96, 216)
MALE_SHADOW_COLOR = NAME_SHADOW_COLOR
FEMALE_BASE_COLOR = Color.new(248, 88, 40)
FEMALE_SHADOW_COLOR = NAME_SHADOW_COLOR
NAME_BASE_COLOR = Color.new(72, 72, 72)
NAME_SHADOW_COLOR = Color.new(184, 184, 184)
MALE_BASE_COLOR = Color.new(48, 96, 216)
MALE_SHADOW_COLOR = NAME_SHADOW_COLOR
FEMALE_BASE_COLOR = Color.new(248, 88, 40)
FEMALE_SHADOW_COLOR = NAME_SHADOW_COLOR
def initialize(battler, sideSize, viewport = nil)
super(viewport)
@@ -413,7 +413,7 @@ class Battle::Scene::PokemonDataBox < Sprite
end
#===============================================================================
# Splash bar to announce a triggered ability
# Splash bar to announce a triggered ability.
#===============================================================================
class Battle::Scene::AbilitySplashBar < Sprite
attr_reader :battler
@@ -506,7 +506,7 @@ class Battle::Scene::AbilitySplashBar < Sprite
end
#===============================================================================
# Pokémon sprite (used in battle)
# Pokémon sprite (used in battle).
#===============================================================================
class Battle::Scene::BattlerSprite < RPG::Sprite
attr_reader :pkmn
@@ -636,7 +636,7 @@ class Battle::Scene::BattlerSprite < RPG::Sprite
end
#===============================================================================
# Shadow sprite for Pokémon (used in battle)
# Shadow sprite for Pokémon (used in battle).
#===============================================================================
class Battle::Scene::BattlerShadowSprite < RPG::Sprite
attr_reader :pkmn

View File

@@ -1,5 +1,5 @@
#===============================================================================
# Shows the battle scene fading in while elements slide around into place
# Shows the battle scene fading in while elements slide around into place.
#===============================================================================
class Battle::Scene::Animation::Intro < Battle::Scene::Animation
def initialize(sprites, viewport, battle)
@@ -59,7 +59,7 @@ end
#===============================================================================
# Shows wild Pokémon fading back to their normal color, and triggers their intro
# animations
# animations.
#===============================================================================
class Battle::Scene::Animation::Intro2 < Battle::Scene::Animation
def initialize(sprites, viewport, sideSize)
@@ -79,7 +79,7 @@ class Battle::Scene::Animation::Intro2 < Battle::Scene::Animation
end
#===============================================================================
# Makes a side's party bar and balls appear
# Makes a side's party bar and balls appear.
#===============================================================================
class Battle::Scene::Animation::LineupAppear < Battle::Scene::Animation
BAR_DISPLAY_WIDTH = 248
@@ -178,7 +178,7 @@ class Battle::Scene::Animation::LineupAppear < Battle::Scene::Animation
end
#===============================================================================
# Makes a Pokémon's data box appear
# Makes a Pokémon's data box appear.
#===============================================================================
class Battle::Scene::Animation::DataBoxAppear < Battle::Scene::Animation
def initialize(sprites, viewport, idxBox)
@@ -197,7 +197,7 @@ class Battle::Scene::Animation::DataBoxAppear < Battle::Scene::Animation
end
#===============================================================================
# Makes a Pokémon's data box disappear
# Makes a Pokémon's data box disappear.
#===============================================================================
class Battle::Scene::Animation::DataBoxDisappear < Battle::Scene::Animation
def initialize(sprites, viewport, idxBox)
@@ -215,7 +215,7 @@ class Battle::Scene::Animation::DataBoxDisappear < Battle::Scene::Animation
end
#===============================================================================
# Makes a Pokémon's ability bar appear
# Makes a Pokémon's ability bar appear.
#===============================================================================
class Battle::Scene::Animation::AbilitySplashAppear < Battle::Scene::Animation
def initialize(sprites, viewport, side)
@@ -234,7 +234,7 @@ class Battle::Scene::Animation::AbilitySplashAppear < Battle::Scene::Animation
end
#===============================================================================
# Makes a Pokémon's ability bar disappear
# Makes a Pokémon's ability bar disappear.
#===============================================================================
class Battle::Scene::Animation::AbilitySplashDisappear < Battle::Scene::Animation
def initialize(sprites, viewport, side)
@@ -524,7 +524,7 @@ class Battle::Scene::Animation::PokeballTrainerSendOut < Battle::Scene::Animatio
end
#===============================================================================
# Shows a Pokémon being recalled into its Poké Ball
# Shows a Pokémon being recalled into its Poké Ball.
#===============================================================================
class Battle::Scene::Animation::BattlerRecall < Battle::Scene::Animation
include Battle::Scene::Animation::BallAnimationMixin
@@ -572,7 +572,7 @@ class Battle::Scene::Animation::BattlerRecall < Battle::Scene::Animation
end
#===============================================================================
# Shows a Pokémon flashing after taking damage
# Shows a Pokémon flashing after taking damage.
#===============================================================================
class Battle::Scene::Animation::BattlerDamage < Battle::Scene::Animation
def initialize(sprites, viewport, idxBattler, effectiveness)
@@ -608,7 +608,7 @@ class Battle::Scene::Animation::BattlerDamage < Battle::Scene::Animation
end
#===============================================================================
# Shows a Pokémon fainting
# Shows a Pokémon fainting.
#===============================================================================
class Battle::Scene::Animation::BattlerFaint < Battle::Scene::Animation
def initialize(sprites, viewport, idxBattler, battle)
@@ -656,7 +656,7 @@ class Battle::Scene::Animation::BattlerFaint < Battle::Scene::Animation
end
#===============================================================================
# Shows the player's Poké Ball being thrown to capture a Pokémon
# Shows the player's Poké Ball being thrown to capture a Pokémon.
#===============================================================================
class Battle::Scene::Animation::PokeballThrowCapture < Battle::Scene::Animation
include Battle::Scene::Animation::BallAnimationMixin
@@ -812,7 +812,7 @@ class Battle::Scene::Animation::PokeballThrowCapture < Battle::Scene::Animation
end
#===============================================================================
# Shows the player throwing a Poké Ball and it being deflected
# Shows the player throwing a Poké Ball and it being deflected.
#===============================================================================
class Battle::Scene::Animation::PokeballThrowDeflect < Battle::Scene::Animation
include Battle::Scene::Animation::BallAnimationMixin

View File

@@ -1,5 +1,5 @@
#===============================================================================
# Used when generating new trainers for battle challenges
# Used when generating new trainers for battle challenges.
#===============================================================================
class Battle::DebugSceneNoVisuals
def initialize(log_messages = false)