Added decent spacing to all scripts thanks to Rubocop

This commit is contained in:
Maruno17
2021-12-18 15:25:40 +00:00
parent f7b76ae62e
commit d17fc40a47
207 changed files with 18577 additions and 18587 deletions

View File

@@ -2,36 +2,36 @@ class Battle::Battler
#=============================================================================
# Turn processing
#=============================================================================
def pbProcessTurn(choice,tryFlee = true)
def pbProcessTurn(choice, tryFlee = true)
return false if fainted?
# Wild roaming Pokémon always flee if possible
if tryFlee && wild? &&
@battle.rules["alwaysflee"] && @battle.pbCanRun?(@index)
pbBeginTurn(choice)
pbSEPlay("Battle flee")
@battle.pbDisplay(_INTL("{1} fled from battle!",pbThis))
@battle.pbDisplay(_INTL("{1} fled from battle!", pbThis))
@battle.decision = 3
pbEndTurn(choice)
return true
end
# Shift with the battler next to this one
if choice[0]==:Shift
if choice[0] == :Shift
idxOther = -1
case @battle.pbSideSize(@index)
when 2
idxOther = (@index+2)%4
idxOther = (@index + 2) % 4
when 3
if @index!=2 && @index!=3 # If not in middle spot already
idxOther = ((@index%2)==0) ? 2 : 3
if @index != 2 && @index != 3 # If not in middle spot already
idxOther = ((@index % 2) == 0) ? 2 : 3
end
end
if idxOther>=0
@battle.pbSwapBattlers(@index,idxOther)
if idxOther >= 0
@battle.pbSwapBattlers(@index, idxOther)
case @battle.pbSideSize(@index)
when 2
@battle.pbDisplay(_INTL("{1} moved across!",pbThis))
@battle.pbDisplay(_INTL("{1} moved across!", pbThis))
when 3
@battle.pbDisplay(_INTL("{1} moved to the center!",pbThis))
@battle.pbDisplay(_INTL("{1} moved to the center!", pbThis))
end
end
pbBeginTurn(choice)
@@ -40,7 +40,7 @@ class Battle::Battler
return true
end
# If this battler's action for this round wasn't "use a move"
if choice[0]!=:UseMove
if choice[0] != :UseMove
# Clean up effects that end at battler's turn
pbBeginTurn(choice)
pbEndTurn(choice)
@@ -57,7 +57,7 @@ class Battle::Battler
# Use the move
PBDebug.log("[Move usage] #{pbThis} started using #{choice[2].name}")
PBDebug.logonerr {
pbUseMove(choice,choice[2]==@battle.struggle)
pbUseMove(choice, choice[2] == @battle.struggle)
}
@battle.pbJudge
# Update priority order
@@ -77,7 +77,7 @@ class Battle::Battler
@effects[PBEffects::MoveNext] = false
@effects[PBEffects::Quash] = 0
# Encore's effect ends if the encored move is no longer available
if @effects[PBEffects::Encore]>0 && pbEncoredMoveIndex<0
if @effects[PBEffects::Encore] > 0 && pbEncoredMoveIndex < 0
@effects[PBEffects::Encore] = 0
@effects[PBEffects::EncoreMove] = nil
end
@@ -91,8 +91,8 @@ class Battle::Battler
def pbCancelMoves(full_cancel = false)
# Outragers get confused anyway if they are disrupted during their final
# turn of using the move
if @effects[PBEffects::Outrage]==1 && pbCanConfuseSelf?(false) && !full_cancel
pbConfuse(_INTL("{1} became confused due to fatigue!",pbThis))
if @effects[PBEffects::Outrage] == 1 && pbCanConfuseSelf?(false) && !full_cancel
pbConfuse(_INTL("{1} became confused due to fatigue!", pbThis))
end
# Cancel usage of most multi-turn moves
@effects[PBEffects::TwoTurnAttack] = nil
@@ -102,13 +102,13 @@ class Battle::Battler
@effects[PBEffects::Bide] = 0
@currentMove = nil
# Reset counters for moves which increase them when used in succession
@effects[PBEffects::FuryCutter] = 0
@effects[PBEffects::FuryCutter] = 0
end
def pbEndTurn(_choice)
@lastRoundMoved = @battle.turnCount # Done something this round
if !@effects[PBEffects::ChoiceBand] &&
(hasActiveItem?([:CHOICEBAND,:CHOICESPECS,:CHOICESCARF]) ||
(hasActiveItem?([:CHOICEBAND, :CHOICESPECS, :CHOICESCARF]) ||
hasActiveAbility?(:GORILLATACTICS))
if @lastMoveUsed && pbHasMove?(@lastMoveUsed)
@effects[PBEffects::ChoiceBand] = @lastMoveUsed
@@ -117,7 +117,7 @@ class Battle::Battler
end
end
@effects[PBEffects::BeakBlast] = false
@effects[PBEffects::Charge] = 0 if @effects[PBEffects::Charge]==1
@effects[PBEffects::Charge] = 0 if @effects[PBEffects::Charge] == 1
@effects[PBEffects::GemConsumed] = nil
@effects[PBEffects::ShellTrap] = false
@battle.allBattlers.each { |b| b.pbContinualAbilityChecks } # Trace, end primordial weathers
@@ -125,16 +125,16 @@ class Battle::Battler
def pbConfusionDamage(msg)
@damageState.reset
confusionMove = Battle::Move::Confusion.new(@battle,nil)
confusionMove = Battle::Move::Confusion.new(@battle, nil)
confusionMove.calcType = confusionMove.pbCalcType(self) # nil
@damageState.typeMod = confusionMove.pbCalcTypeMod(confusionMove.calcType,self,self) # 8
confusionMove.pbCheckDamageAbsorption(self,self)
confusionMove.pbCalcDamage(self,self)
confusionMove.pbReduceDamage(self,self)
@damageState.typeMod = confusionMove.pbCalcTypeMod(confusionMove.calcType, self, self) # 8
confusionMove.pbCheckDamageAbsorption(self, self)
confusionMove.pbCalcDamage(self, self)
confusionMove.pbReduceDamage(self, self)
self.hp -= @damageState.hpLost
confusionMove.pbAnimateHitAndHPLost(self,[self])
confusionMove.pbAnimateHitAndHPLost(self, [self])
@battle.pbDisplay(msg) # "It hurt itself in its confusion!"
confusionMove.pbRecordDamageLost(self,self)
confusionMove.pbRecordDamageLost(self, self)
confusionMove.pbEndureKOMessage(self)
pbFaint if fainted?
pbItemHPHealCheck
@@ -144,11 +144,11 @@ class Battle::Battler
# Simple "use move" method, used when a move calls another move and for Future
# Sight's attack
#=============================================================================
def pbUseMoveSimple(moveID,target = -1,idxMove = -1,specialUsage = true)
def pbUseMoveSimple(moveID, target = -1, idxMove = -1, specialUsage = true)
choice = []
choice[0] = :UseMove # "Use move"
choice[1] = idxMove # Index of move to be used in user's moveset
if idxMove>=0
if idxMove >= 0
choice[2] = @moves[idxMove]
else
choice[2] = Battle::Move.from_pokemon_move(@battle, Pokemon::Move.new(moveID))
@@ -156,27 +156,27 @@ class Battle::Battler
end
choice[3] = target # Target (-1 means no target yet)
PBDebug.log("[Move usage] #{pbThis} started using the called/simple move #{choice[2].name}")
pbUseMove(choice,specialUsage)
pbUseMove(choice, specialUsage)
end
#=============================================================================
# Master "use move" method
#=============================================================================
def pbUseMove(choice,specialUsage = false)
def pbUseMove(choice, specialUsage = false)
# NOTE: This is intentionally determined before a multi-turn attack can
# set specialUsage to true.
skipAccuracyCheck = (specialUsage && choice[2]!=@battle.struggle)
skipAccuracyCheck = (specialUsage && choice[2] != @battle.struggle)
# Start using the move
pbBeginTurn(choice)
# Force the use of certain moves if they're already being used
if usingMultiTurnAttack?
choice[2] = Battle::Move.from_pokemon_move(@battle, Pokemon::Move.new(@currentMove))
specialUsage = true
elsif @effects[PBEffects::Encore]>0 && choice[1]>=0 &&
elsif @effects[PBEffects::Encore] > 0 && choice[1] >= 0 &&
@battle.pbCanShowCommands?(@index)
idxEncoredMove = pbEncoredMoveIndex
if idxEncoredMove>=0 && @battle.pbCanChooseMove?(@index,idxEncoredMove,false)
if choice[1]!=idxEncoredMove # Change move if battler was Encored mid-round
if idxEncoredMove >= 0 && @battle.pbCanChooseMove?(@index, idxEncoredMove, false)
if choice[1] != idxEncoredMove # Change move if battler was Encored mid-round
choice[1] = idxEncoredMove
choice[2] = @moves[idxEncoredMove]
choice[3] = -1 # No target chosen
@@ -188,7 +188,7 @@ class Battle::Battler
return if !move # if move was not chosen somehow
# Try to use the move (inc. disobedience)
@lastMoveFailed = false
if !pbTryUseMove(choice,move,specialUsage,skipAccuracyCheck)
if !pbTryUseMove(choice, move, specialUsage, skipAccuracyCheck)
@lastMoveUsed = nil
@lastMoveUsedType = nil
if !specialUsage
@@ -205,7 +205,7 @@ class Battle::Battler
# Subtract PP
if !specialUsage
if !pbReducePP(move)
@battle.pbDisplay(_INTL("{1} used {2}!",pbThis,move.name))
@battle.pbDisplay(_INTL("{1} used {2}!", pbThis, move.name))
@battle.pbDisplay(_INTL("But there was no PP left for the move!"))
@lastMoveUsed = nil
@lastMoveUsedType = nil
@@ -220,9 +220,9 @@ class Battle::Battler
# Stance Change
if isSpecies?(:AEGISLASH) && self.ability == :STANCECHANGE
if move.damagingMove?
pbChangeForm(1,_INTL("{1} changed to Blade Forme!",pbThis))
pbChangeForm(1, _INTL("{1} changed to Blade Forme!", pbThis))
elsif move.id == :KINGSSHIELD
pbChangeForm(0,_INTL("{1} changed to Shield Forme!",pbThis))
pbChangeForm(0, _INTL("{1} changed to Shield Forme!", pbThis))
end
end
# Calculate the move's type during this usage
@@ -238,10 +238,10 @@ class Battle::Battler
@effects[PBEffects::TwoTurnAttack] = nil # Cancel use of two-turn attack
end
# Add to counters for moves which increase them when used in succession
move.pbChangeUsageCounters(self,specialUsage)
move.pbChangeUsageCounters(self, specialUsage)
# Charge up Metronome item
if hasActiveItem?(:METRONOME) && !move.callsAnotherMove?
if @lastMoveUsed && @lastMoveUsed==move.id && !@lastMoveFailed
if @lastMoveUsed && @lastMoveUsed == move.id && !@lastMoveFailed
@effects[PBEffects::Metronome] += 1
else
@effects[PBEffects::Metronome] = 0
@@ -259,10 +259,10 @@ class Battle::Battler
@battle.lastMoveUser = @index # For "self KO" battle clause to avoid draws
@battle.successStates[@index].useState = 1 # Battle Arena - assume failure
# Find the default user (self or Snatcher) and target(s)
user = pbFindUser(choice,move)
user = pbChangeUser(choice,move,user)
targets = pbFindTargets(choice,move,user)
targets = pbChangeTargets(move,user,targets)
user = pbFindUser(choice, move)
user = pbChangeUser(choice, move, user)
targets = pbFindTargets(choice, move, user)
targets = pbChangeTargets(move, user, targets)
# Pressure
if !specialUsage
targets.each do |b|
@@ -282,9 +282,9 @@ class Battle::Battler
@battle.pbPriority(true).each do |b|
next if !b || !b.abilityActive?
if Battle::AbilityEffects.triggerMoveBlocking(b.ability, b, user, targets, move, @battle)
@battle.pbDisplayBrief(_INTL("{1} used {2}!",user.pbThis,move.name))
@battle.pbDisplayBrief(_INTL("{1} used {2}!", user.pbThis, move.name))
@battle.pbShowAbilitySplash(b)
@battle.pbDisplay(_INTL("{1} cannot use {2}!",user.pbThis,move.name))
@battle.pbDisplay(_INTL("{1} cannot use {2}!", user.pbThis, move.name))
@battle.pbHideAbilitySplash(b)
user.lastMoveFailed = true
pbCancelMoves
@@ -301,11 +301,11 @@ class Battle::Battler
# Snatch's message (user is the new user, self is the original user)
if move.snatched
@lastMoveFailed = true # Intentionally applies to self, not user
@battle.pbDisplay(_INTL("{1} snatched {2}'s move!",user.pbThis,pbThis(true)))
@battle.pbDisplay(_INTL("{1} snatched {2}'s move!", user.pbThis, pbThis(true)))
end
# "But it failed!" checks
if move.pbMoveFailed?(user,targets)
PBDebug.log(sprintf("[Move failed] In function code %s's def pbMoveFailed?",move.function))
if move.pbMoveFailed?(user, targets)
PBDebug.log(sprintf("[Move failed] In function code %s's def pbMoveFailed?", move.function))
user.lastMoveFailed = true
pbCancelMoves
pbEndTurn(choice)
@@ -313,15 +313,15 @@ class Battle::Battler
end
# Perform set-up actions and display messages
# Messages include Magnitude's number and Pledge moves' "it's a combo!"
move.pbOnStartUse(user,targets)
move.pbOnStartUse(user, targets)
# Self-thawing due to the move
if user.status == :FROZEN && move.thawsUser?
user.pbCureStatus(false)
@battle.pbDisplay(_INTL("{1} melted the ice!",user.pbThis))
@battle.pbDisplay(_INTL("{1} melted the ice!", user.pbThis))
end
# Powder
if user.effects[PBEffects::Powder] && move.calcType == :FIRE
@battle.pbCommonAnimation("Powder",user)
@battle.pbCommonAnimation("Powder", user)
@battle.pbDisplay(_INTL("When the flame touched the powder on the Pokémon, it exploded!"))
user.lastMoveFailed = true
if ![:Rain, :HeavyRain].include?(user.effectiveWeather) && user.takesIndirectDamage?
@@ -361,15 +361,15 @@ class Battle::Battler
@battle.pbShowAbilitySplash(user)
user.pbChangeTypes(move.calcType)
typeName = GameData::Type.get(move.calcType).name
@battle.pbDisplay(_INTL("{1}'s type changed to {2}!",user.pbThis,typeName))
@battle.pbDisplay(_INTL("{1}'s type changed to {2}!", user.pbThis, typeName))
@battle.pbHideAbilitySplash(user)
# NOTE: The GF games say that if Curse is used by a non-Ghost-type
# Pokémon which becomes Ghost-type because of Protean, it should
# target and curse itself. I think this is silly, so I'm making it
# choose a random opponent to curse instead.
if move.function=="CurseTargetOrLowerUserSpd1RaiseUserAtkDef1" && targets.length==0
if move.function == "CurseTargetOrLowerUserSpd1RaiseUserAtkDef1" && targets.length == 0
choice[3] = -1
targets = pbFindTargets(choice,move,user)
targets = pbFindTargets(choice, move, user)
end
end
end
@@ -394,7 +394,7 @@ class Battle::Battler
b.damageState.unaffected = true
end
# Magic Coat/Magic Bounce checks (for moves which don't target Pokémon)
if targets.length==0 && move.statusMove? && move.canMagicCoat?
if targets.length == 0 && move.statusMove? && move.canMagicCoat?
@battle.pbPriority(true).each do |b|
next if b.fainted? || !b.opposes?(user)
next if b.semiInvulnerable?
@@ -411,14 +411,14 @@ class Battle::Battler
end
end
# Get the number of hits
numHits = move.pbNumHits(user,targets)
numHits = move.pbNumHits(user, targets)
# Process each hit in turn
realNumHits = 0
for i in 0...numHits
break if magicCoater>=0 || magicBouncer>=0
success = pbProcessMoveHit(move,user,targets,i,skipAccuracyCheck)
break if magicCoater >= 0 || magicBouncer >= 0
success = pbProcessMoveHit(move, user, targets, i, skipAccuracyCheck)
if !success
if i==0 && targets.length>0
if i == 0 && targets.length > 0
hasFailed = false
targets.each do |t|
next if t.damageState.protected
@@ -439,7 +439,7 @@ class Battle::Battler
end
# Battle Arena only - attack is successful
@battle.successStates[user.index].useState = 2
if targets.length>0
if targets.length > 0
@battle.successStates[user.index].typeMod = 0
targets.each do |b|
next if b.damageState.unaffected
@@ -449,17 +449,17 @@ class Battle::Battler
# Effectiveness message for multi-hit moves
# NOTE: No move is both multi-hit and multi-target, and the messages below
# aren't quite right for such a hypothetical move.
if numHits>1
if numHits > 1
if move.damagingMove?
targets.each do |b|
next if b.damageState.unaffected || b.damageState.substitute
move.pbEffectivenessMessage(user,b,targets.length)
move.pbEffectivenessMessage(user, b, targets.length)
end
end
if realNumHits==1
if realNumHits == 1
@battle.pbDisplay(_INTL("Hit 1 time!"))
elsif realNumHits>1
@battle.pbDisplay(_INTL("Hit {1} times!",realNumHits))
elsif realNumHits > 1
@battle.pbDisplay(_INTL("Hit {1} times!", realNumHits))
end
end
# Magic Coat's bouncing back (move has targets)
@@ -467,38 +467,38 @@ class Battle::Battler
next if b.fainted?
next if !b.damageState.magicCoat && !b.damageState.magicBounce
@battle.pbShowAbilitySplash(b) if b.damageState.magicBounce
@battle.pbDisplay(_INTL("{1} bounced the {2} back!",b.pbThis,move.name))
@battle.pbDisplay(_INTL("{1} bounced the {2} back!", b.pbThis, move.name))
@battle.pbHideAbilitySplash(b) if b.damageState.magicBounce
newChoice = choice.clone
newChoice[3] = user.index
newTargets = pbFindTargets(newChoice,move,b)
newTargets = pbChangeTargets(move,b,newTargets)
success = pbProcessMoveHit(move,b,newTargets,0,false)
newTargets = pbFindTargets(newChoice, move, b)
newTargets = pbChangeTargets(move, b, newTargets)
success = pbProcessMoveHit(move, b, newTargets, 0, false)
b.lastMoveFailed = true if !success
targets.each { |otherB| otherB.pbFaint if otherB && otherB.fainted? }
user.pbFaint if user.fainted?
end
# Magic Coat's bouncing back (move has no targets)
if magicCoater>=0 || magicBouncer>=0
mc = @battle.battlers[(magicCoater>=0) ? magicCoater : magicBouncer]
if magicCoater >= 0 || magicBouncer >= 0
mc = @battle.battlers[(magicCoater >= 0) ? magicCoater : magicBouncer]
if !mc.fainted?
user.lastMoveFailed = true
@battle.pbShowAbilitySplash(mc) if magicBouncer>=0
@battle.pbDisplay(_INTL("{1} bounced the {2} back!",mc.pbThis,move.name))
@battle.pbHideAbilitySplash(mc) if magicBouncer>=0
success = pbProcessMoveHit(move,mc,[],0,false)
@battle.pbShowAbilitySplash(mc) if magicBouncer >= 0
@battle.pbDisplay(_INTL("{1} bounced the {2} back!", mc.pbThis, move.name))
@battle.pbHideAbilitySplash(mc) if magicBouncer >= 0
success = pbProcessMoveHit(move, mc, [], 0, false)
mc.lastMoveFailed = true if !success
targets.each { |b| b.pbFaint if b && b.fainted? }
user.pbFaint if user.fainted?
end
end
# Move-specific effects after all hits
targets.each { |b| move.pbEffectAfterAllHits(user,b) }
targets.each { |b| move.pbEffectAfterAllHits(user, b) }
# Faint if 0 HP
targets.each { |b| b.pbFaint if b && b.fainted? }
user.pbFaint if user.fainted?
# External/general effects after all hits. Eject Button, Shell Bell, etc.
pbEffectsAfterMove(user,targets,move,realNumHits)
pbEffectsAfterMove(user, targets, move, realNumHits)
@battle.allBattlers.each do |b|
b.droppedBelowHalfHP = false
b.statsDropped = false
@@ -511,7 +511,7 @@ class Battle::Battler
# Battle Arena only - update skills
@battle.allBattlers.each { |b| @battle.successStates[b.index].updateSkill }
# Shadow Pokémon triggering Hyper Mode
pbHyperMode if @battle.choices[@index][0]!=:None # Not if self is replaced
pbHyperMode if @battle.choices[@index][0] != :None # Not if self is replaced
# End of move usage
pbEndTurn(choice)
# Instruct
@@ -519,56 +519,56 @@ class Battle::Battler
next if !b.effects[PBEffects::Instruct] || !b.lastMoveUsed
b.effects[PBEffects::Instruct] = false
idxMove = -1
b.eachMoveWithIndex { |m,i| idxMove = i if m.id==b.lastMoveUsed }
next if idxMove<0
b.eachMoveWithIndex { |m, i| idxMove = i if m.id == b.lastMoveUsed }
next if idxMove < 0
oldLastRoundMoved = b.lastRoundMoved
@battle.pbDisplay(_INTL("{1} used the move instructed by {2}!",b.pbThis,user.pbThis(true)))
@battle.pbDisplay(_INTL("{1} used the move instructed by {2}!", b.pbThis, user.pbThis(true)))
b.effects[PBEffects::Instructed] = true
if b.pbCanChooseMove?(@moves[idxMove], false)
PBDebug.logonerr {
b.pbUseMoveSimple(b.lastMoveUsed,b.lastRegularMoveTarget,idxMove,false)
b.pbUseMoveSimple(b.lastMoveUsed, b.lastRegularMoveTarget, idxMove, false)
}
b.lastRoundMoved = oldLastRoundMoved
@battle.pbJudge
return if @battle.decision>0
return if @battle.decision > 0
end
b.effects[PBEffects::Instructed] = false
end
# Dancer
if !@effects[PBEffects::Dancer] && !user.lastMoveFailed && realNumHits>0 &&
!move.snatched && magicCoater<0 && @battle.pbCheckGlobalAbility(:DANCER) &&
if !@effects[PBEffects::Dancer] && !user.lastMoveFailed && realNumHits > 0 &&
!move.snatched && magicCoater < 0 && @battle.pbCheckGlobalAbility(:DANCER) &&
move.danceMove?
dancers = []
@battle.pbPriority(true).each do |b|
dancers.push(b) if b.index!=user.index && b.hasActiveAbility?(:DANCER)
dancers.push(b) if b.index != user.index && b.hasActiveAbility?(:DANCER)
end
while dancers.length>0
while dancers.length > 0
nextUser = dancers.pop
oldLastRoundMoved = nextUser.lastRoundMoved
# NOTE: Petal Dance being used because of Dancer shouldn't lock the
# Dancer into using that move, and shouldn't contribute to its
# turn counter if it's already locked into Petal Dance.
oldOutrage = nextUser.effects[PBEffects::Outrage]
nextUser.effects[PBEffects::Outrage] += 1 if nextUser.effects[PBEffects::Outrage]>0
nextUser.effects[PBEffects::Outrage] += 1 if nextUser.effects[PBEffects::Outrage] > 0
oldCurrentMove = nextUser.currentMove
preTarget = choice[3]
preTarget = user.index if nextUser.opposes?(user) || !nextUser.opposes?(preTarget)
@battle.pbShowAbilitySplash(nextUser,true)
@battle.pbShowAbilitySplash(nextUser, true)
@battle.pbHideAbilitySplash(nextUser)
if !Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} kept the dance going with {2}!",
nextUser.pbThis,nextUser.abilityName))
nextUser.pbThis, nextUser.abilityName))
end
nextUser.effects[PBEffects::Dancer] = true
if nextUser.pbCanChooseMove?(move, false)
PBDebug.logonerr {
nextUser.pbUseMoveSimple(move.id,preTarget)
nextUser.pbUseMoveSimple(move.id, preTarget)
}
nextUser.lastRoundMoved = oldLastRoundMoved
nextUser.effects[PBEffects::Outrage] = oldOutrage
nextUser.currentMove = oldCurrentMove
@battle.pbJudge
return if @battle.decision>0
return if @battle.decision > 0
end
nextUser.effects[PBEffects::Dancer] = false
end
@@ -578,19 +578,19 @@ class Battle::Battler
#=============================================================================
# Attack a single target
#=============================================================================
def pbProcessMoveHit(move,user,targets,hitNum,skipAccuracyCheck)
def pbProcessMoveHit(move, user, targets, hitNum, skipAccuracyCheck)
return false if user.fainted?
# For two-turn attacks being used in a single turn
move.pbInitialEffect(user,targets,hitNum)
move.pbInitialEffect(user, targets, hitNum)
numTargets = 0 # Number of targets that are affected by this hit
# Count a hit for Parental Bond (if it applies)
user.effects[PBEffects::ParentalBond] -= 1 if user.effects[PBEffects::ParentalBond]>0
user.effects[PBEffects::ParentalBond] -= 1 if user.effects[PBEffects::ParentalBond] > 0
# Accuracy check (accuracy/evasion calc)
if hitNum==0 || move.successCheckPerHit?
if hitNum == 0 || move.successCheckPerHit?
targets.each do |b|
b.damageState.missed = false
next if b.damageState.unaffected
if pbSuccessCheckPerHit(move,user,b,skipAccuracyCheck)
if pbSuccessCheckPerHit(move, user, b, skipAccuracyCheck)
numTargets += 1
else
b.damageState.missed = true
@@ -598,10 +598,10 @@ class Battle::Battler
end
end
# If failed against all targets
if targets.length>0 && numTargets==0 && !move.worksWithNoTargets?
if targets.length > 0 && numTargets == 0 && !move.worksWithNoTargets?
targets.each do |b|
next if !b.damageState.missed || b.damageState.magicCoat
pbMissMessage(move,user,b)
pbMissMessage(move, user, b)
if user.itemActive?
Battle::ItemEffects.triggerOnMissingTarget(user.item, user, b, move, hitNum, @battle)
end
@@ -623,25 +623,25 @@ class Battle::Battler
targets.each do |b|
next if b.damageState.unaffected
# Check whether Substitute/Disguise will absorb the damage
move.pbCheckDamageAbsorption(user,b)
move.pbCheckDamageAbsorption(user, b)
# Calculate the damage against b
# pbCalcDamage shows the "eat berry" animation for SE-weakening
# berries, although the message about it comes after the additional
# effect below
move.pbCalcDamage(user,b,targets.length) # Stored in damageState.calcDamage
move.pbCalcDamage(user, b, targets.length) # Stored in damageState.calcDamage
# Lessen damage dealt because of False Swipe/Endure/etc.
move.pbReduceDamage(user,b) # Stored in damageState.hpLost
move.pbReduceDamage(user, b) # Stored in damageState.hpLost
end
end
# Show move animation (for this hit)
move.pbShowAnimation(move.id,user,targets,hitNum)
move.pbShowAnimation(move.id, user, targets, hitNum)
# Type-boosting Gem consume animation/message
if user.effects[PBEffects::GemConsumed] && hitNum==0
if user.effects[PBEffects::GemConsumed] && hitNum == 0
# NOTE: The consume animation and message for Gems are shown now, but the
# actual removal of the item happens in def pbEffectsAfterMove.
@battle.pbCommonAnimation("UseItem",user)
@battle.pbCommonAnimation("UseItem", user)
@battle.pbDisplay(_INTL("The {1} strengthened {2}'s power!",
GameData::Item.get(user.effects[PBEffects::GemConsumed]).name,move.name))
GameData::Item.get(user.effects[PBEffects::GemConsumed]).name, move.name))
end
# Messages about missed target(s) (relevant for multi-target moves only)
if !move.pbRepeatHit?
@@ -659,29 +659,29 @@ class Battle::Battler
# This just changes the HP amounts and does nothing else
targets.each { |b| move.pbInflictHPDamage(b) if !b.damageState.unaffected }
# Animate the hit flashing and HP bar changes
move.pbAnimateHitAndHPLost(user,targets)
move.pbAnimateHitAndHPLost(user, targets)
end
# Self-Destruct/Explosion's damaging and fainting of user
move.pbSelfKO(user) if hitNum==0
move.pbSelfKO(user) if hitNum == 0
user.pbFaint if user.fainted?
if move.pbDamagingMove?
targets.each do |b|
next if b.damageState.unaffected
# NOTE: This method is also used for the OHKO special message.
move.pbHitEffectivenessMessages(user,b,targets.length)
move.pbHitEffectivenessMessages(user, b, targets.length)
# Record data about the hit for various effects' purposes
move.pbRecordDamageLost(user,b)
move.pbRecordDamageLost(user, b)
end
# Close Combat/Superpower's stat-lowering, Flame Burst's splash damage,
# and Incinerate's berry destruction
targets.each do |b|
next if b.damageState.unaffected
move.pbEffectWhenDealingDamage(user,b)
move.pbEffectWhenDealingDamage(user, b)
end
# Ability/item effects such as Static/Rocky Helmet, and Grudge, etc.
targets.each do |b|
next if b.damageState.unaffected
pbEffectsOnMakingHit(move,user,b)
pbEffectsOnMakingHit(move, user, b)
end
# Disguise/Endure/Sturdy/Focus Sash/Focus Band messages
targets.each do |b|
@@ -695,11 +695,11 @@ class Battle::Battler
# because Flame Burst's splash damage affects non-targets)
@battle.pbPriority(true).each { |b| b.pbFaint if b && b.fainted? }
end
@battle.pbJudgeCheckpoint(user,move)
@battle.pbJudgeCheckpoint(user, move)
# Main effect (recoil/drain, etc.)
targets.each do |b|
next if b.damageState.unaffected
move.pbEffectAgainstTarget(user,b)
move.pbEffectAgainstTarget(user, b)
end
move.pbEffectGeneral(user)
targets.each { |b| b.pbFaint if b && b.fainted? }
@@ -707,21 +707,21 @@ class Battle::Battler
# Additional effect
if !user.hasActiveAbility?(:SHEERFORCE)
targets.each do |b|
next if b.damageState.calcDamage==0
chance = move.pbAdditionalEffectChance(user,b)
next if chance<=0
if @battle.pbRandom(100)<chance
move.pbAdditionalEffect(user,b)
next if b.damageState.calcDamage == 0
chance = move.pbAdditionalEffectChance(user, b)
next if chance <= 0
if @battle.pbRandom(100) < chance
move.pbAdditionalEffect(user, b)
end
end
end
# Make the target flinch (because of an item/ability)
targets.each do |b|
next if b.fainted?
next if b.damageState.calcDamage==0 || b.damageState.substitute
chance = move.pbFlinchChance(user,b)
next if chance<=0
if @battle.pbRandom(100)<chance
next if b.damageState.calcDamage == 0 || b.damageState.substitute
chance = move.pbFlinchChance(user, b)
next if chance <= 0
if @battle.pbRandom(100) < chance
PBDebug.log("[Item/ability triggered] #{user.pbThis}'s King's Rock/Razor Fang or Stench")
b.pbFlinch(user)
end
@@ -733,7 +733,7 @@ class Battle::Battler
targets.each do |b|
next if b.damageState.unaffected
next if !b.damageState.berryWeakened
@battle.pbDisplay(_INTL("The {1} weakened the damage to {2}!",b.itemName,b.pbThis(true)))
@battle.pbDisplay(_INTL("The {1} weakened the damage to {2}!", b.itemName, b.pbThis(true)))
b.pbConsumeItem
end
# Steam Engine (goes here because it should be after stat changes caused by