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}]")

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?

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
class Battle::Move
attr_reader :battle
attr_reader :realMove
@@ -28,9 +31,10 @@ class Battle::Move
return @power
end
#=============================================================================
# Creating a move
#=============================================================================
#-----------------------------------------------------------------------------
# Creating a move.
#-----------------------------------------------------------------------------
def initialize(battle, move)
@battle = battle
@realMove = move
@@ -68,9 +72,10 @@ class Battle::Move
return Battle::Move::Unimplemented.new(battle, move)
end
#=============================================================================
# About the move
#=============================================================================
#-----------------------------------------------------------------------------
# About the move.
#-----------------------------------------------------------------------------
def pbTarget(_user); return GameData::Target.get(@target); end
def total_pp

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle::Move
#=============================================================================
# Effect methods per move usage
#=============================================================================
#-----------------------------------------------------------------------------
# Effect methods per move usage.
#-----------------------------------------------------------------------------
def pbCanChooseMove?(user, commandPhase, showMessages); return true; end # For Belch
def pbDisplayChargeMessage(user); end # For Focus Punch/shell Trap/Beak Blast
def pbOnStartUse(user, targets); end
@@ -24,9 +28,10 @@ class Battle::Move
def pbShowFailMessages?(targets); return true; end
def pbMissMessage(user, target); return false; end
#=============================================================================
#-----------------------------------------------------------------------------
#
#=============================================================================
#-----------------------------------------------------------------------------
# Whether the move is currently in the "charging" turn of a two-turn move.
# Is false if Power Herb or another effect lets a two-turn move charge and
# attack in the same turn.
@@ -56,9 +61,10 @@ class Battle::Move
# For two-turn moves when they charge and attack in the same turn.
def pbQuickChargingMove(user, targets); end
#=============================================================================
# Effect methods per hit
#=============================================================================
#-----------------------------------------------------------------------------
# Effect methods per hit.
#-----------------------------------------------------------------------------
def pbOverrideSuccessCheckPerHit(user, target); return false; end
def pbCrashDamage(user); end
def pbInitialEffect(user, targets, hitNum); end
@@ -83,9 +89,10 @@ class Battle::Move
def pbSwitchOutTargetEffect(user, targets, numHits, switched_battlers); end
def pbEndOfMoveUsageEffect(user, targets, numHits, switchedBattlers); end
#=============================================================================
# Check if target is immune to the move because of its ability
#=============================================================================
#-----------------------------------------------------------------------------
# Check if target is immune to the move because of its ability.
#-----------------------------------------------------------------------------
def pbImmunityByAbility(user, target, show_message)
ret = false
if target.abilityActive? && !target.beingMoldBroken?
@@ -95,9 +102,10 @@ class Battle::Move
return ret
end
#=============================================================================
# Move failure checks
#=============================================================================
#-----------------------------------------------------------------------------
# Move failure checks.
#-----------------------------------------------------------------------------
# Check whether the move fails completely due to move-specific requirements.
def pbMoveFailed?(user, targets); return false; end
# Checks whether the move will be ineffective against the target.
@@ -156,9 +164,10 @@ class Battle::Move
return false
end
#=============================================================================
# Weaken the damage dealt (doesn't actually change a battler's HP)
#=============================================================================
#-----------------------------------------------------------------------------
# Weaken the damage dealt (doesn't actually change a battler's HP).
#-----------------------------------------------------------------------------
def pbCheckDamageAbsorption(user, target)
# Substitute will take the damage
if target.effects[PBEffects::Substitute] > 0 && !ignoresSubstitute?(user) &&
@@ -225,9 +234,10 @@ class Battle::Move
target.damageState.totalHPLost += damage
end
#=============================================================================
# Change the target's HP by the amount calculated above
#=============================================================================
#-----------------------------------------------------------------------------
# Change the target's HP by the amount calculated above.
#-----------------------------------------------------------------------------
def pbInflictHPDamage(target)
if target.damageState.substitute
target.effects[PBEffects::Substitute] -= target.damageState.hpLost
@@ -236,9 +246,10 @@ class Battle::Move
end
end
#=============================================================================
# Animate the damage dealt, including lowering the HP
#=============================================================================
#-----------------------------------------------------------------------------
# Animate the damage dealt, including lowering the HP.
#-----------------------------------------------------------------------------
# Animate being damaged and losing HP (by a move)
def pbAnimateHitAndHPLost(user, targets)
# Animate allies first, then foes
@@ -269,9 +280,10 @@ class Battle::Move
end
end
#=============================================================================
# Messages upon being hit
#=============================================================================
#-----------------------------------------------------------------------------
# Messages upon being hit.
#-----------------------------------------------------------------------------
def pbEffectivenessMessage(user, target, numTargets = 1)
return if self.is_a?(Battle::Move::FixedDamageMove)
return if target.damageState.disguise || target.damageState.iceFace

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle::Move
#=============================================================================
# Move's type calculation
#=============================================================================
#-----------------------------------------------------------------------------
# Move's type calculation.
#-----------------------------------------------------------------------------
def pbBaseType(user)
ret = @type
if ret && user.abilityActive?
@@ -26,9 +30,10 @@ class Battle::Move
return ret
end
#=============================================================================
# Type effectiveness calculation
#=============================================================================
#-----------------------------------------------------------------------------
# Type effectiveness calculation.
#-----------------------------------------------------------------------------
def pbCalcTypeModSingle(moveType, defType, user, target)
ret = Effectiveness.calculate(moveType, defType)
if Effectiveness.ineffective_type?(moveType, defType)
@@ -78,9 +83,10 @@ class Battle::Move
return ret
end
#=============================================================================
# Accuracy check
#=============================================================================
#-----------------------------------------------------------------------------
# Accuracy check.
#-----------------------------------------------------------------------------
def pbBaseAccuracy(user, target); return @accuracy; end
# Accuracy calculations for one-hit KO moves are handled elsewhere.
@@ -166,9 +172,10 @@ class Battle::Move
modifiers[:evasion_stage] = 0 if user.hasActiveAbility?(:MINDSEYE)
end
#=============================================================================
# Critical hit check
#=============================================================================
#-----------------------------------------------------------------------------
# Critical hit check.
#-----------------------------------------------------------------------------
# Return values:
# -1: Never a critical hit.
# 0: Calculate normally.
@@ -220,9 +227,10 @@ class Battle::Move
return false
end
#=============================================================================
# Damage calculation
#=============================================================================
#-----------------------------------------------------------------------------
# Damage calculation.
#-----------------------------------------------------------------------------
def pbBaseDamage(baseDmg, user, target); return baseDmg; end
def pbBaseDamageMultiplier(damageMult, user, target); return damageMult; end
def pbModifyDamage(damageMult, user, target); return damageMult; end
@@ -505,9 +513,10 @@ class Battle::Move
multipliers[:final_damage_multiplier] = pbModifyDamage(multipliers[:final_damage_multiplier], user, target)
end
#=============================================================================
# Additional effect chance
#=============================================================================
#-----------------------------------------------------------------------------
# Additional effect chance.
#-----------------------------------------------------------------------------
def pbAdditionalEffectChance(user, target, effectChance = 0)
return 0 if target.hasActiveAbility?(:SHIELDDUST) && !target.beingMoldBroken?
ret = (effectChance > 0) ? effectChance : @addlEffect

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)

View File

@@ -94,30 +94,32 @@ module Battle::AI::Handlers
AbilityRanking = AbilityHandlerHash.new
ItemRanking = ItemHandlerHash.new
def self.move_will_fail?(function_code, *args)
module_function
def move_will_fail?(function_code, *args)
return MoveFailureCheck.trigger(function_code, *args) || false
end
def self.move_will_fail_against_target?(function_code, *args)
def move_will_fail_against_target?(function_code, *args)
return MoveFailureAgainstTargetCheck.trigger(function_code, *args) || false
end
def self.apply_move_effect_score(function_code, score, *args)
def apply_move_effect_score(function_code, score, *args)
ret = MoveEffectScore.trigger(function_code, score, *args)
return (ret.nil?) ? score : ret
end
def self.apply_move_effect_against_target_score(function_code, score, *args)
def apply_move_effect_against_target_score(function_code, score, *args)
ret = MoveEffectAgainstTargetScore.trigger(function_code, score, *args)
return (ret.nil?) ? score : ret
end
def self.get_base_power(function_code, power, *args)
def get_base_power(function_code, power, *args)
ret = MoveBasePower.trigger(function_code, power, *args)
return (ret.nil?) ? power : ret
end
def self.apply_general_move_score_modifiers(score, *args)
def apply_general_move_score_modifiers(score, *args)
GeneralMoveScore.each do |id, score_proc|
new_score = score_proc.call(score, *args)
score = new_score if new_score
@@ -125,7 +127,7 @@ module Battle::AI::Handlers
return score
end
def self.apply_general_move_against_target_score_modifiers(score, *args)
def apply_general_move_against_target_score_modifiers(score, *args)
GeneralMoveAgainstTargetScore.each do |id, score_proc|
new_score = score_proc.call(score, *args)
score = new_score if new_score
@@ -133,7 +135,7 @@ module Battle::AI::Handlers
return score
end
def self.should_switch?(*args)
def should_switch?(*args)
ret = false
ShouldSwitch.each do |id, switch_proc|
ret ||= switch_proc.call(*args)
@@ -142,7 +144,7 @@ module Battle::AI::Handlers
return ret
end
def self.should_not_switch?(*args)
def should_not_switch?(*args)
ret = false
ShouldNotSwitch.each do |id, switch_proc|
ret ||= switch_proc.call(*args)
@@ -151,12 +153,12 @@ module Battle::AI::Handlers
return ret
end
def self.modify_ability_ranking(ability, score, *args)
def modify_ability_ranking(ability, score, *args)
ret = AbilityRanking.trigger(ability, score, *args)
return (ret.nil?) ? score : ret
end
def self.modify_item_ranking(item, score, *args)
def modify_item_ranking(item, score, *args)
ret = ItemRanking.trigger(item, score, *args)
return (ret.nil?) ? score : ret
end

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
module PBEffects
#===========================================================================
# These effects apply to a battler
#===========================================================================
#-----------------------------------------------------------------------------
# These effects apply to a battler.
#-----------------------------------------------------------------------------
AquaRing = 0
Attract = 1
BanefulBunker = 2
@@ -123,9 +127,10 @@ module PBEffects
WeightChange = 115
Yawn = 116
#=============================================================================
# These effects apply to a battler position
#=============================================================================
#-----------------------------------------------------------------------------
# These effects apply to a battler position.
#-----------------------------------------------------------------------------
FutureSightCounter = 700
FutureSightMove = 701
FutureSightUserIndex = 702
@@ -136,9 +141,10 @@ module PBEffects
WishAmount = 707
WishMaker = 708
#=============================================================================
# These effects apply to a side
#=============================================================================
#-----------------------------------------------------------------------------
# These effects apply to a side.
#-----------------------------------------------------------------------------
AuroraVeil = 800
CraftyShield = 801
EchoedVoiceCounter = 802
@@ -162,9 +168,10 @@ module PBEffects
ToxicSpikes = 820
WideGuard = 821
#=============================================================================
# These effects apply to the battle (i.e. both sides)
#=============================================================================
#-----------------------------------------------------------------------------
# These effects apply to the battle (i.e. both sides).
#-----------------------------------------------------------------------------
AmuletCoin = 900
FairyLock = 901
FusionBolt = 902

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
module Battle::CatchAndStoreMixin
#=============================================================================
# Store caught Pokémon
#=============================================================================
#-----------------------------------------------------------------------------
# Store caught Pokémon.
#-----------------------------------------------------------------------------
def pbStorePokemon(pkmn)
# Nickname the Pokémon (unless it's a Shadow Pokémon)
if !pkmn.shadowPokemon?
@@ -102,9 +106,10 @@ module Battle::CatchAndStoreMixin
@caughtPokemon.clear
end
#=============================================================================
# Throw a Poké Ball
#=============================================================================
#-----------------------------------------------------------------------------
# Throw a Poké Ball.
#-----------------------------------------------------------------------------
def pbThrowPokeBall(idxBattler, ball, catch_rate = nil, showPlayer = false)
# Determine which Pokémon you're throwing the Poké Ball at
battler = nil
@@ -196,9 +201,10 @@ module Battle::CatchAndStoreMixin
end
end
#=============================================================================
# Calculate how many shakes a thrown Poké Ball will make (4 = capture)
#=============================================================================
#-----------------------------------------------------------------------------
# Calculate how many shakes a thrown Poké Ball will make (4 = capture).
#-----------------------------------------------------------------------------
def pbCaptureCalc(pkmn, battler, catch_rate, ball)
return 4 if $DEBUG && Input.press?(Input::CTRL)
# Get a catch rate if one wasn't provided

View File

@@ -1,5 +1,5 @@
#===============================================================================
# This script modifies the battle system to implement battle rules
# This script modifies the battle system to implement battle rules.
#===============================================================================
class Battle
unless @__clauses__aliased
@@ -102,7 +102,7 @@ class Battle::Battler
end
#===============================================================================
# Double Team
# Double Team.
#===============================================================================
class Battle::Move::RaiseUserEvasion1
unless method_defined?(:__clauses__pbMoveFailed?)
@@ -119,7 +119,7 @@ class Battle::Move::RaiseUserEvasion1
end
#===============================================================================
# Minimize
# Minimize.
#===============================================================================
class Battle::Move::RaiseUserEvasion2MinimizeUser
unless method_defined?(:__clauses__pbMoveFailed?)
@@ -136,7 +136,7 @@ class Battle::Move::RaiseUserEvasion2MinimizeUser
end
#===============================================================================
# Skill Swap
# Skill Swap.
#===============================================================================
class Battle::Move::UserTargetSwapAbilities
unless method_defined?(:__clauses__pbFailsAgainstTarget?)
@@ -153,7 +153,7 @@ class Battle::Move::UserTargetSwapAbilities
end
#===============================================================================
# Sonic Boom
# Sonic Boom.
#===============================================================================
class Battle::Move::FixedDamage20
unless method_defined?(:__clauses__pbFailsAgainstTarget?)
@@ -170,7 +170,7 @@ class Battle::Move::FixedDamage20
end
#===============================================================================
# Dragon Rage
# Dragon Rage.
#===============================================================================
class Battle::Move::FixedDamage40
unless method_defined?(:__clauses__pbFailsAgainstTarget?)
@@ -238,7 +238,7 @@ class Battle::Move::OHKOHitsUndergroundTarget
end
#===============================================================================
# Self-Destruct
# Self-Destruct.
#===============================================================================
class Battle::Move::UserFaintsExplosive
unless method_defined?(:__clauses__pbMoveFailed?)
@@ -270,7 +270,7 @@ class Battle::Move::UserFaintsExplosive
end
#===============================================================================
# Perish Song
# Perish Song.
#===============================================================================
class Battle::Move::StartPerishCountsForAllBattlers
unless method_defined?(:__clauses__pbFailsAgainstTarget?)
@@ -288,7 +288,7 @@ class Battle::Move::StartPerishCountsForAllBattlers
end
#===============================================================================
# Destiny Bond
# Destiny Bond.
#===============================================================================
class Battle::Move::AttackerFaintsIfUserFaints
unless method_defined?(:__clauses__pbFailsAgainstTarget?)

View File

@@ -665,7 +665,7 @@ def pbSpriteSetAnimFrame(sprite, frame, user = nil, target = nil, inEditor = fal
end
#===============================================================================
# Animation player
# Animation player.
#===============================================================================
class PBAnimationPlayerX
attr_accessor :looping

View File

@@ -64,14 +64,14 @@ module Battle::AbilityEffects
# Running from battle
CertainEscapeFromBattle = AbilityHandlerHash.new # Run Away
#=============================================================================
#-----------------------------------------------------------------------------
def self.trigger(hash, *args, ret: false)
new_ret = hash.trigger(*args)
return (!new_ret.nil?) ? new_ret : ret
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerSpeedCalc(ability, battler, mult)
return trigger(SpeedCalc, ability, battler, mult, ret: mult)
@@ -81,13 +81,13 @@ module Battle::AbilityEffects
return trigger(WeightCalc, ability, battler, weight, ret: weight)
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerOnHPDroppedBelowHalf(ability, user, move_user, battle)
return trigger(OnHPDroppedBelowHalf, ability, user, move_user, battle)
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerStatusCheckNonIgnorable(ability, battler, status)
return trigger(StatusCheckNonIgnorable, ability, battler, status)
@@ -113,7 +113,7 @@ module Battle::AbilityEffects
return trigger(StatusCure, ability, battler)
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerStatLossImmunity(ability, battler, stat, battle, show_messages)
return trigger(StatLossImmunity, ability, battler, stat, battle, show_messages)
@@ -135,7 +135,7 @@ module Battle::AbilityEffects
OnStatLoss.trigger(ability, battler, stat, user)
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerPriorityChange(ability, battler, move, priority)
return trigger(PriorityChange, ability, battler, move, priority, ret: priority)
@@ -149,7 +149,7 @@ module Battle::AbilityEffects
PriorityBracketUse.trigger(ability, battler, battle)
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerOnFlinch(ability, battler, battle)
OnFlinch.trigger(ability, battler, battle)
@@ -163,13 +163,13 @@ module Battle::AbilityEffects
return trigger(MoveImmunity, ability, user, target, move, type, battle, show_message)
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerModifyMoveBaseType(ability, user, move, type)
return trigger(ModifyMoveBaseType, ability, user, move, type, ret: type)
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerAccuracyCalcFromUser(ability, mods, user, target, move, type)
AccuracyCalcFromUser.trigger(ability, mods, user, target, move, type)
@@ -183,7 +183,7 @@ module Battle::AbilityEffects
AccuracyCalcFromTarget.trigger(ability, mods, user, target, move, type)
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerDamageCalcFromUser(ability, user, target, move, mults, power, type)
DamageCalcFromUser.trigger(ability, user, target, move, mults, power, type)
@@ -213,7 +213,7 @@ module Battle::AbilityEffects
return trigger(CriticalCalcFromTarget, ability, user, target, move, crit_stage, ret: crit_stage)
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerOnBeingHit(ability, user, target, move, battle)
OnBeingHit.trigger(ability, user, target, move, battle)
@@ -223,7 +223,7 @@ module Battle::AbilityEffects
OnDealingHit.trigger(ability, user, target, move, battle)
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerOnEndOfUsingMove(ability, user, targets, move, battle)
OnEndOfUsingMove.trigger(ability, user, targets, move, battle)
@@ -233,7 +233,7 @@ module Battle::AbilityEffects
AfterMoveUseFromTarget.trigger(ability, target, user, move, switched_battlers, battle)
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerEndOfRoundWeather(ability, weather, battler, battle)
EndOfRoundWeather.trigger(ability, weather, battler, battle)
@@ -251,7 +251,7 @@ module Battle::AbilityEffects
EndOfRoundGainItem.trigger(ability, battler, battle)
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerCertainSwitching(ability, switcher, battle)
return trigger(CertainSwitching, ability, switcher, battle)
@@ -285,7 +285,7 @@ module Battle::AbilityEffects
OnIntimidated.trigger(ability, battler, battle)
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerCertainEscapeFromBattle(ability, battler)
return trigger(CertainEscapeFromBattle, ability, battler)

View File

@@ -50,14 +50,14 @@ module Battle::ItemEffects
# Running from battle
CertainEscapeFromBattle = ItemHandlerHash.new # Smoke Ball
#=============================================================================
#-----------------------------------------------------------------------------
def self.trigger(hash, *args, ret: false)
new_ret = hash.trigger(*args)
return (!new_ret.nil?) ? new_ret : ret
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerSpeedCalc(item, battler, mult)
return trigger(SpeedCalc, item, battler, mult, ret: mult)
@@ -67,7 +67,7 @@ module Battle::ItemEffects
return trigger(WeightCalc, item, battler, w, ret: w)
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerHPHeal(item, battler, battle, forced)
return trigger(HPHeal, item, battler, battle, forced)
@@ -77,19 +77,19 @@ module Battle::ItemEffects
return trigger(OnStatLoss, item, user, move_user, battle)
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerStatusCure(item, battler, battle, forced)
return trigger(StatusCure, item, battler, battle, forced)
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerStatLossImmunity(item, battler, stat, battle, show_messages)
return trigger(StatLossImmunity, item, battler, stat, battle, show_messages)
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerPriorityBracketChange(item, battler, battle)
return trigger(PriorityBracketChange, item, battler, battle, ret: 0)
@@ -99,13 +99,13 @@ module Battle::ItemEffects
PriorityBracketUse.trigger(item, battler, battle)
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerOnMissingTarget(item, user, target, move, hit_num, battle)
OnMissingTarget.trigger(item, user, target, move, hit_num, battle)
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerAccuracyCalcFromUser(item, mods, user, target, move, type)
AccuracyCalcFromUser.trigger(item, mods, user, target, move, type)
@@ -115,7 +115,7 @@ module Battle::ItemEffects
AccuracyCalcFromTarget.trigger(item, mods, user, target, move, type)
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerDamageCalcFromUser(item, user, target, move, mults, power, type)
DamageCalcFromUser.trigger(item, user, target, move, mults, power, type)
@@ -133,7 +133,7 @@ module Battle::ItemEffects
return trigger(CriticalCalcFromTarget, item, user, target, move, crit_stage, ret: crit_stage)
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerOnBeingHit(item, user, target, move, battle)
OnBeingHit.trigger(item, user, target, move, battle)
@@ -143,7 +143,7 @@ module Battle::ItemEffects
return trigger(OnBeingHitPositiveBerry, item, battler, battle, forced)
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerAfterMoveUseFromTarget(item, battler, user, move, switched_battlers, battle)
AfterMoveUseFromTarget.trigger(item, battler, user, move, switched_battlers, battle)
@@ -161,7 +161,7 @@ module Battle::ItemEffects
return trigger(OnEndOfUsingMoveStatRestore, item, battler, battle, forced)
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerExpGainModifier(item, battler, exp)
return trigger(ExpGainModifier, item, battler, exp, ret: -1)
@@ -173,7 +173,7 @@ module Battle::ItemEffects
return true
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerWeatherExtender(item, weather, duration, battler, battle)
return trigger(WeatherExtender, item, weather, duration, battler, battle, ret: duration)
@@ -187,7 +187,7 @@ module Battle::ItemEffects
return trigger(TerrainStatBoost, item, battler, battle)
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerEndOfRoundHealing(item, battler, battle)
EndOfRoundHealing.trigger(item, battler, battle)
@@ -197,7 +197,7 @@ module Battle::ItemEffects
EndOfRoundEffect.trigger(item, battler, battle)
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerCertainSwitching(item, switcher, battle)
return trigger(CertainSwitching, item, switcher, battle)
@@ -215,7 +215,7 @@ module Battle::ItemEffects
return trigger(OnIntimidated, item, battler, battle)
end
#=============================================================================
#-----------------------------------------------------------------------------
def self.triggerCertainEscapeFromBattle(item, battler)
return trigger(CertainEscapeFromBattle, item, battler)

View File

@@ -30,6 +30,7 @@ end
#===============================================================================
# IsUnconditional
#===============================================================================
Battle::PokeBallEffects::IsUnconditional.add(:MASTERBALL, proc { |ball, battle, battler|
next true
})
@@ -40,6 +41,7 @@ Battle::PokeBallEffects::IsUnconditional.add(:MASTERBALL, proc { |ball, battle,
# Ball is a Beast Ball). In this case, all Balls' catch rates are set
# elsewhere to 0.1x.
#===============================================================================
Battle::PokeBallEffects::ModifyCatchRate.add(:GREATBALL, proc { |ball, catchRate, battle, battler|
next catchRate * 1.5
})
@@ -189,6 +191,7 @@ Battle::PokeBallEffects::ModifyCatchRate.add(:BEASTBALL, proc { |ball, catchRate
#===============================================================================
# OnCatch
#===============================================================================
Battle::PokeBallEffects::OnCatch.add(:HEALBALL, proc { |ball, battle, pkmn|
pkmn.heal
})

View File

@@ -1,5 +1,5 @@
#===============================================================================
# Simple battler class for the wild Pokémon in a Safari Zone battle
# Simple battler class for the wild Pokémon in a Safari Zone battle.
#===============================================================================
class Battle::FakeBattler
attr_reader :battle
@@ -55,7 +55,7 @@ class Battle::FakeBattler
end
#===============================================================================
# Data box for safari battles
# Data box for safari battles.
#===============================================================================
class Battle::Scene::SafariDataBox < Sprite
attr_accessor :selected
@@ -213,7 +213,7 @@ class Battle::Scene::Animation::ThrowRock < Battle::Scene::Animation
end
#===============================================================================
# Safari Zone battle scene (the visuals of the battle)
# Safari Zone battle scene (the visuals of the battle).
#===============================================================================
class Battle::Scene
def pbSafariStart
@@ -269,7 +269,7 @@ class Battle::Scene
end
#===============================================================================
# Safari Zone battle class
# Safari Zone battle class.
#===============================================================================
class SafariBattle
attr_reader :battlers # Array of fake battler objects
@@ -294,9 +294,6 @@ class SafariBattle
def pbRandom(x); return rand(x); end
#-----------------------------------------------------------------------------
# Initialize the battle class
#-----------------------------------------------------------------------------
def initialize(scene, player, party2)
@scene = scene
@peer = Battle::Peer.new
@@ -326,8 +323,9 @@ class SafariBattle
def defaultTerrain=(value); end
#-----------------------------------------------------------------------------
# Information about the type and size of the battle
# Information about the type and size of the battle.
#-----------------------------------------------------------------------------
def wildBattle?; return true; end
def trainerBattle?; return false; end
@@ -338,8 +336,9 @@ class SafariBattle
end
#-----------------------------------------------------------------------------
# Trainers and owner-related
# Trainers and owner-related.
#-----------------------------------------------------------------------------
def pbPlayer; return @player[0]; end
def opponent; return nil; end
@@ -365,8 +364,9 @@ class SafariBattle
end
#-----------------------------------------------------------------------------
# Get party info (counts all teams on the same side)
# Get party info (counts all teams on the same side).
#-----------------------------------------------------------------------------
def pbParty(idxBattler)
return (opposes?(idxBattler)) ? @party2 : nil
end
@@ -374,8 +374,9 @@ class SafariBattle
def pbAllFainted?(idxBattler = 0); return false; end
#-----------------------------------------------------------------------------
# Battler-related
# Battler-related.
#-----------------------------------------------------------------------------
def opposes?(idxBattler1, idxBattler2 = 0)
idxBattler1 = idxBattler1.index if idxBattler1.respond_to?("index")
idxBattler2 = idxBattler2.index if idxBattler2.respond_to?("index")
@@ -386,8 +387,9 @@ class SafariBattle
def pbGainExp; end
#-----------------------------------------------------------------------------
# Messages and animations
# Messages and animations.
#-----------------------------------------------------------------------------
def pbDisplay(msg, &block)
@scene.pbDisplayMessage(msg, &block)
end
@@ -411,8 +413,9 @@ class SafariBattle
end
#-----------------------------------------------------------------------------
# Safari battle-specific methods
# Safari battle-specific methods.
#-----------------------------------------------------------------------------
def pbEscapeRate(catch_rate)
return 125 if catch_rate <= 45 # Escape factor 9 (45%)
return 100 if catch_rate <= 60 # Escape factor 7 (35%)

View File

@@ -1,5 +1,5 @@
#===============================================================================
# Bug-Catching Contest battle scene (the visuals of the battle)
# Bug-Catching Contest battle scene (the visuals of the battle).
#===============================================================================
class Battle::Scene
alias _bugContest_pbInitSprites pbInitSprites unless method_defined?(:_bugContest_pbInitSprites)
@@ -27,7 +27,7 @@ class Battle::Scene
end
#===============================================================================
# Bug-Catching Contest battle class
# Bug-Catching Contest battle class.
#===============================================================================
class BugContestBattle < Battle
attr_accessor :ballCount

View File

@@ -1,5 +1,5 @@
#===============================================================================
# Success state
# Success state.
#===============================================================================
class Battle::SuccessState
attr_accessor :typeMod