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

@@ -82,14 +82,14 @@ class Battle::Battler
end
def defense
return @spdef if @battle.field.effects[PBEffects::WonderRoom]>0
return @spdef if @battle.field.effects[PBEffects::WonderRoom] > 0
return @defense
end
attr_writer :defense
def spdef
return @defense if @battle.field.effects[PBEffects::WonderRoom]>0
return @defense if @battle.field.effects[PBEffects::WonderRoom] > 0
return @spdef
end
@@ -102,7 +102,7 @@ class Battle::Battler
@pokemon.hp = value.to_i if @pokemon
end
def fainted?; return @hp<=0; end
def fainted?; return @hp <= 0; end
attr_reader :status
@@ -211,12 +211,12 @@ class Battle::Battler
def pbThis(lowerCase = false)
if opposes?
if @battle.trainerBattle?
return lowerCase ? _INTL("the opposing {1}",name) : _INTL("The opposing {1}",name)
return lowerCase ? _INTL("the opposing {1}", name) : _INTL("The opposing {1}", name)
else
return lowerCase ? _INTL("the wild {1}",name) : _INTL("The wild {1}",name)
return lowerCase ? _INTL("the wild {1}", name) : _INTL("The wild {1}", name)
end
elsif !pbOwnedByPlayer?
return lowerCase ? _INTL("the ally {1}",name) : _INTL("The ally {1}",name)
return lowerCase ? _INTL("the ally {1}", name) : _INTL("The ally {1}", name)
end
return name
end
@@ -240,10 +240,10 @@ class Battle::Battler
#=============================================================================
def pbSpeed
return 1 if fainted?
stageMul = [2,2,2,2,2,2, 2, 3,4,5,6,7,8]
stageDiv = [8,7,6,5,4,3, 2, 2,2,2,2,2,2]
stageMul = [2, 2, 2, 2, 2, 2, 2, 3, 4, 5, 6, 7, 8]
stageDiv = [8, 7, 6, 5, 4, 3, 2, 2, 2, 2, 2, 2, 2]
stage = @stages[:SPEED] + 6
speed = @speed*stageMul[stage]/stageDiv[stage]
speed = @speed * stageMul[stage] / stageDiv[stage]
speedMult = 1.0
# Ability effects that alter calculated Speed
if abilityActive?
@@ -254,8 +254,8 @@ class Battle::Battler
speedMult = Battle::ItemEffects.triggerSpeedCalc(self.item, self, speedMult)
end
# Other effects
speedMult *= 2 if pbOwnSide.effects[PBEffects::Tailwind]>0
speedMult /= 2 if pbOwnSide.effects[PBEffects::Swamp]>0
speedMult *= 2 if pbOwnSide.effects[PBEffects::Tailwind] > 0
speedMult /= 2 if pbOwnSide.effects[PBEffects::Swamp] > 0
# Paralysis
if status == :PARALYSIS && !hasActiveAbility?(:QUICKFEET)
speedMult /= (Settings::MECHANICS_GENERATION >= 7) ? 2 : 4
@@ -266,20 +266,20 @@ class Battle::Battler
speedMult *= 1.1
end
# Calculation
return [(speed*speedMult).round,1].max
return [(speed * speedMult).round, 1].max
end
def pbWeight
ret = (@pokemon) ? @pokemon.weight : 500
ret += @effects[PBEffects::WeightChange]
ret = 1 if ret<1
ret = 1 if ret < 1
if abilityActive? && !@battle.moldBreaker
ret = Battle::AbilityEffects.triggerWeightCalc(self.ability, self, ret)
end
if itemActive?
ret = Battle::ItemEffects.triggerWeightCalc(self.item, self, ret)
end
return [ret,1].max
return [ret, 1].max
end
#=============================================================================
@@ -415,10 +415,10 @@ class Battle::Battler
def itemActive?(ignoreFainted = false)
return false if fainted? && !ignoreFainted
return false if @effects[PBEffects::Embargo]>0
return false if @battle.field.effects[PBEffects::MagicRoom]>0
return false if @effects[PBEffects::Embargo] > 0
return false if @battle.field.effects[PBEffects::MagicRoom] > 0
return false if @battle.corrosiveGas[@index % 2][@pokemonIndex]
return false if hasActiveAbility?(:KLUTZ,ignoreFainted)
return false if hasActiveAbility?(:KLUTZ, ignoreFainted)
return true
end
@@ -515,9 +515,9 @@ class Battle::Battler
if showMsg
@battle.pbShowAbilitySplash(self)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} is unaffected!",pbThis))
@battle.pbDisplay(_INTL("{1} is unaffected!", pbThis))
else
@battle.pbDisplay(_INTL("{1} is unaffected because of its {2}!",pbThis,abilityName))
@battle.pbDisplay(_INTL("{1} is unaffected because of its {2}!", pbThis, abilityName))
end
@battle.pbHideAbilitySplash(self)
end
@@ -531,7 +531,7 @@ class Battle::Battler
return false if pbHasType?(:GROUND) || pbHasType?(:ROCK) || pbHasType?(:STEEL)
return false if inTwoTurnAttack?("TwoTurnAttackInvulnerableUnderground",
"TwoTurnAttackInvulnerableUnderwater")
return false if hasActiveAbility?([:OVERCOAT,:SANDFORCE,:SANDRUSH,:SANDVEIL])
return false if hasActiveAbility?([:OVERCOAT, :SANDFORCE, :SANDRUSH, :SANDVEIL])
return false if hasActiveItem?(:SAFETYGOGGLES)
return true
end
@@ -541,7 +541,7 @@ class Battle::Battler
return false if pbHasType?(:ICE)
return false if inTwoTurnAttack?("TwoTurnAttackInvulnerableUnderground",
"TwoTurnAttackInvulnerableUnderwater")
return false if hasActiveAbility?([:OVERCOAT,:ICEBODY,:SNOWCLOAK])
return false if hasActiveAbility?([:OVERCOAT, :ICEBODY, :SNOWCLOAK])
return false if hasActiveItem?(:SAFETYGOGGLES)
return true
end
@@ -561,7 +561,7 @@ class Battle::Battler
def affectedByPowder?(showMsg = false)
return false if fainted?
if pbHasType?(:GRASS) && Settings::MORE_TYPE_EFFECTS
@battle.pbDisplay(_INTL("{1} is unaffected!",pbThis)) if showMsg
@battle.pbDisplay(_INTL("{1} is unaffected!", pbThis)) if showMsg
return false
end
if Settings::MECHANICS_GENERATION >= 6
@@ -569,9 +569,9 @@ class Battle::Battler
if showMsg
@battle.pbShowAbilitySplash(self)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} is unaffected!",pbThis))
@battle.pbDisplay(_INTL("{1} is unaffected!", pbThis))
else
@battle.pbDisplay(_INTL("{1} is unaffected because of its {2}!",pbThis,abilityName))
@battle.pbDisplay(_INTL("{1} is unaffected because of its {2}!", pbThis, abilityName))
end
@battle.pbHideAbilitySplash(self)
end
@@ -579,7 +579,7 @@ class Battle::Battler
end
if hasActiveItem?(:SAFETYGOGGLES)
if showMsg
@battle.pbDisplay(_INTL("{1} is unaffected because of its {2}!",pbThis,itemName))
@battle.pbDisplay(_INTL("{1} is unaffected because of its {2}!", pbThis, itemName))
end
return false
end
@@ -588,15 +588,15 @@ class Battle::Battler
end
def canHeal?
return false if fainted? || @hp>=@totalhp
return false if @effects[PBEffects::HealBlock]>0
return false if fainted? || @hp >= @totalhp
return false if @effects[PBEffects::HealBlock] > 0
return true
end
def affectedByContactEffect?(showMsg = false)
return false if fainted?
if hasActiveItem?(:PROTECTIVEPADS)
@battle.pbDisplay(_INTL("{1} protected itself with the {2}!",pbThis,itemName)) if showMsg
@battle.pbDisplay(_INTL("{1} protected itself with the {2}!", pbThis, itemName)) if showMsg
return false
end
return true
@@ -615,23 +615,23 @@ class Battle::Battler
end
def movedThisRound?
return @lastRoundMoved && @lastRoundMoved==@battle.turnCount
return @lastRoundMoved && @lastRoundMoved == @battle.turnCount
end
def usingMultiTurnAttack?
return true if @effects[PBEffects::TwoTurnAttack]
return true if @effects[PBEffects::HyperBeam]>0
return true if @effects[PBEffects::Rollout]>0
return true if @effects[PBEffects::Outrage]>0
return true if @effects[PBEffects::Uproar]>0
return true if @effects[PBEffects::Bide]>0
return true if @effects[PBEffects::HyperBeam] > 0
return true if @effects[PBEffects::Rollout] > 0
return true if @effects[PBEffects::Outrage] > 0
return true if @effects[PBEffects::Uproar] > 0
return true if @effects[PBEffects::Bide] > 0
return false
end
def inTwoTurnAttack?(*arg)
return false if !@effects[PBEffects::TwoTurnAttack]
ttaFunction = GameData::Move.get(@effects[PBEffects::TwoTurnAttack]).function_code
arg.each { |a| return true if a==ttaFunction }
arg.each { |a| return true if a == ttaFunction }
return false
end
@@ -645,10 +645,10 @@ class Battle::Battler
end
def pbEncoredMoveIndex
return -1 if @effects[PBEffects::Encore]==0 || !@effects[PBEffects::EncoreMove]
return -1 if @effects[PBEffects::Encore] == 0 || !@effects[PBEffects::EncoreMove]
ret = -1
eachMoveWithIndex do |m,i|
next if m.id!=@effects[PBEffects::EncoreMove]
eachMoveWithIndex do |m, i|
next if m.id != @effects[PBEffects::EncoreMove]
ret = i
break
end
@@ -656,31 +656,31 @@ class Battle::Battler
end
def initialItem
return @battle.initialItems[@index&1][@pokemonIndex]
return @battle.initialItems[@index & 1][@pokemonIndex]
end
def setInitialItem(value)
item_data = GameData::Item.try_get(value)
new_item = (item_data) ? item_data.id : nil
@battle.initialItems[@index&1][@pokemonIndex] = new_item
@battle.initialItems[@index & 1][@pokemonIndex] = new_item
end
def recycleItem
return @battle.recycleItems[@index&1][@pokemonIndex]
return @battle.recycleItems[@index & 1][@pokemonIndex]
end
def setRecycleItem(value)
item_data = GameData::Item.try_get(value)
new_item = (item_data) ? item_data.id : nil
@battle.recycleItems[@index&1][@pokemonIndex] = new_item
@battle.recycleItems[@index & 1][@pokemonIndex] = new_item
end
def belched?
return @battle.belch[@index&1][@pokemonIndex]
return @battle.belch[@index & 1][@pokemonIndex]
end
def setBelched
@battle.belch[@index&1][@pokemonIndex] = true
@battle.belch[@index & 1][@pokemonIndex] = true
end
#=============================================================================
@@ -689,13 +689,13 @@ class Battle::Battler
# 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")
return (@index&1)!=(i&1)
return (@index & 1) != (i & 1)
end
# Returns whether the given position/battler is near to self.
def near?(i)
i = i.index if i.respond_to?("index")
return @battle.nearBattlers?(@index,i)
return @battle.nearBattlers?(@index, i)
end
# Returns whether self is owned by the player.
@@ -710,13 +710,13 @@ class Battle::Battler
# Returns 0 if self is on the player's side, or 1 if self is on the opposing
# side.
def idxOwnSide
return @index&1
return @index & 1
end
# Returns 1 if self is on the player's side, or 0 if self is on the opposing
# side.
def idxOpposingSide
return (@index&1)^1
return (@index & 1) ^ 1
end
# Returns the data structure for this battler's side.
@@ -733,7 +733,7 @@ class Battle::Battler
# Unused
def eachAlly
@battle.battlers.each do |b|
yield b if b && !b.fainted? && !b.opposes?(@index) && b.index!=@index
yield b if b && !b.fainted? && !b.opposes?(@index) && b.index != @index
end
end
@@ -766,6 +766,6 @@ class Battle::Battler
@battle.pbGetOpposingIndicesInOrder(@index).each do |i|
return @battle.battlers[i] if @battle.battlers[i]
end
return @battle.battlers[(@index^1)]
return @battle.battlers[(@index ^ 1)]
end
end

View File

@@ -2,7 +2,7 @@ class Battle::Battler
#=============================================================================
# Creating a battler
#=============================================================================
def initialize(btl,idxBattler)
def initialize(btl, idxBattler)
@battle = btl
@index = idxBattler
@captured = false
@@ -33,7 +33,7 @@ class Battle::Battler
end
# Used by Future Sight only, when Future Sight's user is no longer in battle.
def pbInitDummyPokemon(pkmn,idxParty)
def pbInitDummyPokemon(pkmn, idxParty)
raise _INTL("An egg can't be an active Pokémon.") if pkmn.egg?
@name = pkmn.name
@species = pkmn.species
@@ -57,13 +57,13 @@ class Battle::Battler
@dummy = true
end
def pbInitialize(pkmn,idxParty,batonPass = false)
pbInitPokemon(pkmn,idxParty)
def pbInitialize(pkmn, idxParty, batonPass = false)
pbInitPokemon(pkmn, idxParty)
pbInitEffects(batonPass)
@damageState.reset
end
def pbInitPokemon(pkmn,idxParty)
def pbInitPokemon(pkmn, idxParty)
raise _INTL("An egg can't be an active Pokémon.") if pkmn.egg?
@name = pkmn.name
@species = pkmn.species
@@ -85,8 +85,8 @@ class Battle::Battler
@pokemonIndex = idxParty
@participants = [] # Participants earn Exp. if this battler is defeated
@moves = []
pkmn.moves.each_with_index do |m,i|
@moves[i] = Battle::Move.from_pokemon_move(@battle,m)
pkmn.moves.each_with_index do |m, i|
@moves[i] = Battle::Move.from_pokemon_move(@battle, m)
end
end
@@ -94,10 +94,10 @@ class Battle::Battler
if batonPass
# These effects are passed on if Baton Pass is used, but they need to be
# reapplied
@effects[PBEffects::LaserFocus] = (@effects[PBEffects::LaserFocus]>0) ? 2 : 0
@effects[PBEffects::LockOn] = (@effects[PBEffects::LockOn]>0) ? 2 : 0
@effects[PBEffects::LaserFocus] = (@effects[PBEffects::LaserFocus] > 0) ? 2 : 0
@effects[PBEffects::LockOn] = (@effects[PBEffects::LockOn] > 0) ? 2 : 0
if @effects[PBEffects::PowerTrick]
@attack,@defense = @defense,@attack
@attack, @defense = @defense, @attack
end
# These effects are passed on if Baton Pass is used, but they need to be
# cancelled in certain circumstances anyway
@@ -131,7 +131,7 @@ class Battle::Battler
@effects[PBEffects::Substitute] = 0
@effects[PBEffects::Telekinesis] = 0
end
@fainted = (@hp==0)
@fainted = (@hp == 0)
@lastAttacker = []
@lastFoeAttacker = []
@lastHPLost = 0
@@ -154,7 +154,7 @@ class Battle::Battler
@turnCount = 0
@effects[PBEffects::Attract] = -1
@battle.allBattlers.each do |b| # Other battlers no longer attracted to self
b.effects[PBEffects::Attract] = -1 if b.effects[PBEffects::Attract]==@index
b.effects[PBEffects::Attract] = -1 if b.effects[PBEffects::Attract] == @index
end
@effects[PBEffects::BanefulBunker] = false
@effects[PBEffects::BeakBlast] = false
@@ -204,8 +204,8 @@ class Battle::Battler
end
@effects[PBEffects::KingsShield] = false
@battle.allBattlers.each do |b| # Other battlers lose their lock-on against self
next if b.effects[PBEffects::LockOn]==0
next if b.effects[PBEffects::LockOnPos]!=@index
next if b.effects[PBEffects::LockOn] == 0
next if b.effects[PBEffects::LockOnPos] != @index
b.effects[PBEffects::LockOn] = 0
b.effects[PBEffects::LockOnPos] = -1
end
@@ -213,7 +213,7 @@ class Battle::Battler
@effects[PBEffects::MagicCoat] = false
@effects[PBEffects::MeanLook] = -1
@battle.allBattlers.each do |b| # Other battlers no longer blocked by self
b.effects[PBEffects::MeanLook] = -1 if b.effects[PBEffects::MeanLook]==@index
b.effects[PBEffects::MeanLook] = -1 if b.effects[PBEffects::MeanLook] == @index
end
@effects[PBEffects::MeFirst] = false
@effects[PBEffects::Metronome] = 0
@@ -250,7 +250,7 @@ class Battle::Battler
@effects[PBEffects::Roost] = false
@effects[PBEffects::SkyDrop] = -1
@battle.allBattlers.each do |b| # Other battlers no longer Sky Dropped by self
b.effects[PBEffects::SkyDrop] = -1 if b.effects[PBEffects::SkyDrop]==@index
b.effects[PBEffects::SkyDrop] = -1 if b.effects[PBEffects::SkyDrop] == @index
end
@effects[PBEffects::SlowStart] = 0
@effects[PBEffects::SmackDown] = false
@@ -271,7 +271,7 @@ class Battle::Battler
@effects[PBEffects::TrappingMove] = nil
@effects[PBEffects::TrappingUser] = -1
@battle.allBattlers.each do |b| # Other battlers no longer trapped by self
next if b.effects[PBEffects::TrappingUser]!=@index
next if b.effects[PBEffects::TrappingUser] != @index
b.effects[PBEffects::Trapping] = 0
b.effects[PBEffects::TrappingUser] = -1
end

View File

@@ -2,16 +2,16 @@ class Battle::Battler
#=============================================================================
# Change HP
#=============================================================================
def pbReduceHP(amt,anim = true,registerDamage = true,anyAnim = true)
def pbReduceHP(amt, anim = true, registerDamage = true, anyAnim = true)
amt = amt.round
amt = @hp if amt>@hp
amt = 1 if amt<1 && !fainted?
amt = @hp if amt > @hp
amt = 1 if amt < 1 && !fainted?
oldHP = @hp
self.hp -= amt
PBDebug.log("[HP change] #{pbThis} lost #{amt} HP (#{oldHP}=>#{@hp})") if amt>0
raise _INTL("HP less than 0") if @hp<0
raise _INTL("HP greater than total HP") if @hp>@totalhp
@battle.scene.pbHPChanged(self,oldHP,anim) if anyAnim && amt>0
PBDebug.log("[HP change] #{pbThis} lost #{amt} HP (#{oldHP}=>#{@hp})") if amt > 0
raise _INTL("HP less than 0") if @hp < 0
raise _INTL("HP greater than total HP") if @hp > @totalhp
@battle.scene.pbHPChanged(self, oldHP, anim) if anyAnim && amt > 0
if amt > 0 && registerDamage
@droppedBelowHalfHP = true if @hp < @totalhp / 2 && @hp + amt >= @totalhp / 2
@tookDamageThisRound = true
@@ -19,32 +19,32 @@ class Battle::Battler
return amt
end
def pbRecoverHP(amt,anim = true,anyAnim = true)
def pbRecoverHP(amt, anim = true, anyAnim = true)
amt = amt.round
amt = @totalhp-@hp if amt>@totalhp-@hp
amt = 1 if amt<1 && @hp<@totalhp
amt = @totalhp - @hp if amt > @totalhp - @hp
amt = 1 if amt < 1 && @hp < @totalhp
oldHP = @hp
self.hp += amt
PBDebug.log("[HP change] #{pbThis} gained #{amt} HP (#{oldHP}=>#{@hp})") if amt>0
raise _INTL("HP less than 0") if @hp<0
raise _INTL("HP greater than total HP") if @hp>@totalhp
@battle.scene.pbHPChanged(self,oldHP,anim) if anyAnim && amt>0
PBDebug.log("[HP change] #{pbThis} gained #{amt} HP (#{oldHP}=>#{@hp})") if amt > 0
raise _INTL("HP less than 0") if @hp < 0
raise _INTL("HP greater than total HP") if @hp > @totalhp
@battle.scene.pbHPChanged(self, oldHP, anim) if anyAnim && amt > 0
@droppedBelowHalfHP = false if @hp >= @totalhp / 2
return amt
end
def pbRecoverHPFromDrain(amt,target,msg = nil)
def pbRecoverHPFromDrain(amt, target, msg = nil)
if target.hasActiveAbility?(:LIQUIDOOZE)
@battle.pbShowAbilitySplash(target)
pbReduceHP(amt)
@battle.pbDisplay(_INTL("{1} sucked up the liquid ooze!",pbThis))
@battle.pbDisplay(_INTL("{1} sucked up the liquid ooze!", pbThis))
@battle.pbHideAbilitySplash(target)
pbItemHPHealCheck
else
msg = _INTL("{1} had its energy drained!",target.pbThis) if nil_or_empty?(msg)
msg = _INTL("{1} had its energy drained!", target.pbThis) if nil_or_empty?(msg)
@battle.pbDisplay(msg)
if canHeal?
amt = (amt*1.3).floor if hasActiveItem?(:BIGROOT)
amt = (amt * 1.3).floor if hasActiveItem?(:BIGROOT)
pbRecoverHP(amt)
end
end
@@ -66,7 +66,7 @@ class Battle::Battler
return
end
return if @fainted # Has already fainted properly
@battle.pbDisplayBrief(_INTL("{1} fainted!",pbThis)) if showMessage
@battle.pbDisplayBrief(_INTL("{1} fainted!", pbThis)) if showMessage
PBDebug.log("[Pokémon fainted] #{pbThis} (#{@index})") if !showMessage
@battle.scene.pbFaintBattler(self)
@battle.pbSetDefeated(self) if opposes?
@@ -80,7 +80,7 @@ class Battle::Battler
@pokemon.changeHappiness((badLoss) ? "faintbad" : "faint")
end
# Reset form
@battle.peer.pbOnLeavingBattle(@battle,@pokemon,@battle.usedInBattle[idxOwnSide][@index/2])
@battle.peer.pbOnLeavingBattle(@battle, @pokemon, @battle.usedInBattle[idxOwnSide][@index / 2])
@pokemon.makeUnmega if mega?
@pokemon.makeUnprimal if primal?
# Do other things
@@ -98,26 +98,26 @@ class Battle::Battler
#=============================================================================
# Move PP
#=============================================================================
def pbSetPP(move,pp)
def pbSetPP(move, pp)
move.pp = pp
# No need to care about @effects[PBEffects::Mimic], since Mimic can't copy
# Mimic
if move.realMove && move.id==move.realMove.id && !@effects[PBEffects::Transform]
if move.realMove && move.id == move.realMove.id && !@effects[PBEffects::Transform]
move.realMove.pp = pp
end
end
def pbReducePP(move)
return true if usingMultiTurnAttack?
return true if move.pp<0 # Don't reduce PP for special calls of moves
return true if move.total_pp<=0 # Infinite PP, can always be used
return false if move.pp==0 # Ran out of PP, couldn't reduce
pbSetPP(move,move.pp-1) if move.pp>0
return true if move.pp < 0 # Don't reduce PP for special calls of moves
return true if move.total_pp <= 0 # Infinite PP, can always be used
return false if move.pp == 0 # Ran out of PP, couldn't reduce
pbSetPP(move, move.pp - 1) if move.pp > 0
return true
end
def pbReducePPOther(move)
pbSetPP(move,move.pp-1) if move.pp>0
pbSetPP(move, move.pp - 1) if move.pp > 0
end
#=============================================================================
@@ -150,17 +150,17 @@ class Battle::Battler
#=============================================================================
# Forms
#=============================================================================
def pbChangeForm(newForm,msg)
return if fainted? || @effects[PBEffects::Transform] || @form==newForm
def pbChangeForm(newForm, msg)
return if fainted? || @effects[PBEffects::Transform] || @form == newForm
oldForm = @form
oldDmg = @totalhp-@hp
oldDmg = @totalhp - @hp
self.form = newForm
pbUpdate(true)
@hp = @totalhp-oldDmg
@hp = @totalhp - oldDmg
@effects[PBEffects::WeightChange] = 0 if Settings::MECHANICS_GENERATION >= 6
@battle.scene.pbChangePokemon(self,@pokemon)
@battle.scene.pbChangePokemon(self, @pokemon)
@battle.scene.pbRefreshOne(@index)
@battle.pbDisplay(msg) if msg && msg!=""
@battle.pbDisplay(msg) if msg && msg != ""
PBDebug.log("[Form changed] #{pbThis} changed from form #{oldForm} to form #{newForm}")
@battle.pbSetSeen(self)
end
@@ -169,7 +169,7 @@ class Battle::Battler
return if fainted? || @effects[PBEffects::Transform]
# Shaymin - reverts if frozen
if isSpecies?(:SHAYMIN) && frozen?
pbChangeForm(0,_INTL("{1} transformed!",pbThis))
pbChangeForm(0, _INTL("{1} transformed!", pbThis))
end
end
@@ -179,7 +179,7 @@ class Battle::Battler
if isSpecies?(:KELDEO)
newForm = 0
newForm = 1 if pbHasMove?(:SECRETSWORD)
pbChangeForm(newForm,_INTL("{1} transformed!",pbThis))
pbChangeForm(newForm, _INTL("{1} transformed!", pbThis))
end
end
@@ -194,13 +194,13 @@ class Battle::Battler
when :Rain, :HeavyRain then newForm = 2
when :Hail then newForm = 3
end
if @form!=newForm
@battle.pbShowAbilitySplash(self,true)
if @form != newForm
@battle.pbShowAbilitySplash(self, true)
@battle.pbHideAbilitySplash(self)
pbChangeForm(newForm,_INTL("{1} transformed!",pbThis))
pbChangeForm(newForm, _INTL("{1} transformed!", pbThis))
end
else
pbChangeForm(0,_INTL("{1} transformed!",pbThis))
pbChangeForm(0, _INTL("{1} transformed!", pbThis))
end
end
# Cherrim - Flower Gift
@@ -208,13 +208,13 @@ class Battle::Battler
if hasActiveAbility?(:FLOWERGIFT)
newForm = 0
newForm = 1 if [:Sun, :HarshSun].include?(effectiveWeather)
if @form!=newForm
@battle.pbShowAbilitySplash(self,true)
if @form != newForm
@battle.pbShowAbilitySplash(self, true)
@battle.pbHideAbilitySplash(self)
pbChangeForm(newForm,_INTL("{1} transformed!",pbThis))
pbChangeForm(newForm, _INTL("{1} transformed!", pbThis))
end
else
pbChangeForm(0,_INTL("{1} transformed!",pbThis))
pbChangeForm(0, _INTL("{1} transformed!", pbThis))
end
end
# Eiscue - Ice Face
@@ -233,57 +233,57 @@ class Battle::Battler
pbCheckFormOnWeatherChange if !endOfRound
# Darmanitan - Zen Mode
if isSpecies?(:DARMANITAN) && self.ability == :ZENMODE
if @hp<=@totalhp/2
if @hp <= @totalhp / 2
if (@form % 2) == 0
@battle.pbShowAbilitySplash(self,true)
@battle.pbShowAbilitySplash(self, true)
@battle.pbHideAbilitySplash(self)
pbChangeForm(@form + 1, _INTL("{1} triggered!", abilityName))
end
elsif (@form % 2) != 0
@battle.pbShowAbilitySplash(self,true)
@battle.pbShowAbilitySplash(self, true)
@battle.pbHideAbilitySplash(self)
pbChangeForm(@form - 1, _INTL("{1} triggered!", abilityName))
end
end
# Minior - Shields Down
if isSpecies?(:MINIOR) && self.ability == :SHIELDSDOWN
if @hp>@totalhp/2 # Turn into Meteor form
newForm = (@form>=7) ? @form-7 : @form
if @form!=newForm
@battle.pbShowAbilitySplash(self,true)
if @hp > @totalhp / 2 # Turn into Meteor form
newForm = (@form >= 7) ? @form - 7 : @form
if @form != newForm
@battle.pbShowAbilitySplash(self, true)
@battle.pbHideAbilitySplash(self)
pbChangeForm(newForm,_INTL("{1} deactivated!",abilityName))
pbChangeForm(newForm, _INTL("{1} deactivated!", abilityName))
elsif !endOfRound
@battle.pbDisplay(_INTL("{1} deactivated!",abilityName))
@battle.pbDisplay(_INTL("{1} deactivated!", abilityName))
end
elsif @form<7 # Turn into Core form
@battle.pbShowAbilitySplash(self,true)
elsif @form < 7 # Turn into Core form
@battle.pbShowAbilitySplash(self, true)
@battle.pbHideAbilitySplash(self)
pbChangeForm(@form+7,_INTL("{1} activated!",abilityName))
pbChangeForm(@form + 7, _INTL("{1} activated!", abilityName))
end
end
# Wishiwashi - Schooling
if isSpecies?(:WISHIWASHI) && self.ability == :SCHOOLING
if @level>=20 && @hp>@totalhp/4
if @form!=1
@battle.pbShowAbilitySplash(self,true)
if @level >= 20 && @hp > @totalhp / 4
if @form != 1
@battle.pbShowAbilitySplash(self, true)
@battle.pbHideAbilitySplash(self)
pbChangeForm(1,_INTL("{1} formed a school!",pbThis))
pbChangeForm(1, _INTL("{1} formed a school!", pbThis))
end
elsif @form!=0
@battle.pbShowAbilitySplash(self,true)
elsif @form != 0
@battle.pbShowAbilitySplash(self, true)
@battle.pbHideAbilitySplash(self)
pbChangeForm(0,_INTL("{1} stopped schooling!",pbThis))
pbChangeForm(0, _INTL("{1} stopped schooling!", pbThis))
end
end
# Zygarde - Power Construct
if isSpecies?(:ZYGARDE) && self.ability == :POWERCONSTRUCT && endOfRound
if @hp<=@totalhp/2 && @form<2 # Turn into Complete Forme
newForm = @form+2
if @hp <= @totalhp / 2 && @form < 2 # Turn into Complete Forme
newForm = @form + 2
@battle.pbDisplay(_INTL("You sense the presence of many!"))
@battle.pbShowAbilitySplash(self,true)
@battle.pbShowAbilitySplash(self, true)
@battle.pbHideAbilitySplash(self)
pbChangeForm(newForm,_INTL("{1} transformed into its Complete Forme!",pbThis))
pbChangeForm(newForm, _INTL("{1} transformed into its Complete Forme!", pbThis))
end
end
# Morpeko - Hunger Switch
@@ -311,7 +311,7 @@ class Battle::Battler
@effects[PBEffects::LaserFocus] = target.effects[PBEffects::LaserFocus]
end
@moves.clear
target.moves.each_with_index do |m,i|
target.moves.each_with_index do |m, i|
@moves[i] = Battle::Move.from_pokemon_move(@battle, Pokemon::Move.new(m.id))
@moves[i].pp = 5
@moves[i].total_pp = 5
@@ -320,7 +320,7 @@ class Battle::Battler
@effects[PBEffects::DisableMove] = nil
@effects[PBEffects::WeightChange] = target.effects[PBEffects::WeightChange]
@battle.scene.pbRefreshOne(@index)
@battle.pbDisplay(_INTL("{1} transformed into {2}!",pbThis,target.pbThis(true)))
@battle.pbDisplay(_INTL("{1} transformed into {2}!", pbThis, target.pbThis(true)))
pbOnLosingAbility(oldAbil)
end

View File

@@ -12,7 +12,7 @@ class Battle::Battler
if Battle::AbilityEffects.triggerStatusCheckNonIgnorable(self.ability, self, checkStatus)
return true
end
return @status==checkStatus
return @status == checkStatus
end
def pbHasAnyStatus?
@@ -22,11 +22,11 @@ class Battle::Battler
return @status != :NONE
end
def pbCanInflictStatus?(newStatus,user,showMessages,move = nil,ignoreStatus = false)
def pbCanInflictStatus?(newStatus, user, showMessages, move = nil, ignoreStatus = false)
return false if fainted?
selfInflicted = (user && user.index==@index)
selfInflicted = (user && user.index == @index)
# Already have that status problem
if self.status==newStatus && !ignoreStatus
if self.status == newStatus && !ignoreStatus
if showMessages
msg = ""
case self.status
@@ -42,18 +42,18 @@ class Battle::Battler
end
# Trying to replace a status problem with another one
if self.status != :NONE && !ignoreStatus && !selfInflicted
@battle.pbDisplay(_INTL("It doesn't affect {1}...",pbThis(true))) if showMessages
@battle.pbDisplay(_INTL("It doesn't affect {1}...", pbThis(true))) if showMessages
return false
end
# Trying to inflict a status problem on a Pokémon behind a substitute
if @effects[PBEffects::Substitute]>0 && !(move && move.ignoresSubstitute?(user)) &&
if @effects[PBEffects::Substitute] > 0 && !(move && move.ignoresSubstitute?(user)) &&
!selfInflicted
@battle.pbDisplay(_INTL("It doesn't affect {1}...",pbThis(true))) if showMessages
@battle.pbDisplay(_INTL("It doesn't affect {1}...", pbThis(true))) if showMessages
return false
end
# Weather immunity
if newStatus == :FROZEN && [:Sun, :HarshSun].include?(effectiveWeather)
@battle.pbDisplay(_INTL("It doesn't affect {1}...",pbThis(true))) if showMessages
@battle.pbDisplay(_INTL("It doesn't affect {1}...", pbThis(true))) if showMessages
return false
end
# Terrains immunity
@@ -66,15 +66,15 @@ class Battle::Battler
return false
end
when :Misty
@battle.pbDisplay(_INTL("{1} surrounds itself with misty terrain!",pbThis(true))) if showMessages
@battle.pbDisplay(_INTL("{1} surrounds itself with misty terrain!", pbThis(true))) if showMessages
return false
end
end
# Uproar immunity
if newStatus == :SLEEP && !(hasActiveAbility?(:SOUNDPROOF) && !@battle.moldBreaker)
@battle.allBattlers.each do |b|
next if b.effects[PBEffects::Uproar]==0
@battle.pbDisplay(_INTL("But the uproar kept {1} awake!",pbThis(true))) if showMessages
next if b.effects[PBEffects::Uproar] == 0
@battle.pbDisplay(_INTL("But the uproar kept {1} awake!", pbThis(true))) if showMessages
return false
end
end
@@ -96,7 +96,7 @@ class Battle::Battler
hasImmuneType |= pbHasType?(:ICE)
end
if hasImmuneType
@battle.pbDisplay(_INTL("It doesn't affect {1}...",pbThis(true))) if showMessages
@battle.pbDisplay(_INTL("It doesn't affect {1}...", pbThis(true))) if showMessages
return false
end
# Ability immunity
@@ -133,19 +133,19 @@ class Battle::Battler
case newStatus
when :SLEEP
msg = _INTL("{1} stays awake because of {2}'s {3}!",
pbThis,immAlly.pbThis(true),immAlly.abilityName)
pbThis, immAlly.pbThis(true), immAlly.abilityName)
when :POISON
msg = _INTL("{1} cannot be poisoned because of {2}'s {3}!",
pbThis,immAlly.pbThis(true),immAlly.abilityName)
pbThis, immAlly.pbThis(true), immAlly.abilityName)
when :BURN
msg = _INTL("{1} cannot be burned because of {2}'s {3}!",
pbThis,immAlly.pbThis(true),immAlly.abilityName)
pbThis, immAlly.pbThis(true), immAlly.abilityName)
when :PARALYSIS
msg = _INTL("{1} cannot be paralyzed because of {2}'s {3}!",
pbThis,immAlly.pbThis(true),immAlly.abilityName)
pbThis, immAlly.pbThis(true), immAlly.abilityName)
when :FROZEN
msg = _INTL("{1} cannot be frozen solid because of {2}'s {3}!",
pbThis,immAlly.pbThis(true),immAlly.abilityName)
pbThis, immAlly.pbThis(true), immAlly.abilityName)
end
else
case newStatus
@@ -162,15 +162,15 @@ class Battle::Battler
return false
end
# Safeguard immunity
if pbOwnSide.effects[PBEffects::Safeguard]>0 && !selfInflicted && move &&
if pbOwnSide.effects[PBEffects::Safeguard] > 0 && !selfInflicted && move &&
!(user && user.hasActiveAbility?(:INFILTRATOR))
@battle.pbDisplay(_INTL("{1}'s team is protected by Safeguard!",pbThis)) if showMessages
@battle.pbDisplay(_INTL("{1}'s team is protected by Safeguard!", pbThis)) if showMessages
return false
end
return true
end
def pbCanSynchronizeStatus?(newStatus,target)
def pbCanSynchronizeStatus?(newStatus, target)
return false if fainted?
# Trying to replace a status problem with another one
return false if self.status != :NONE
@@ -204,7 +204,7 @@ class Battle::Battler
return false
end
# Safeguard immunity
if pbOwnSide.effects[PBEffects::Safeguard]>0 &&
if pbOwnSide.effects[PBEffects::Safeguard] > 0 &&
!(user && user.hasActiveAbility?(:INFILTRATOR))
return false
end
@@ -214,7 +214,7 @@ class Battle::Battler
#=============================================================================
# Generalised infliction of status problem
#=============================================================================
def pbInflictStatus(newStatus,newStatusCount = 0,msg = nil,user = nil)
def pbInflictStatus(newStatus, newStatusCount = 0, msg = nil, user = nil)
# Inflict the new status
self.status = newStatus
self.statusCount = newStatusCount
@@ -234,7 +234,7 @@ class Battle::Battler
when :SLEEP
@battle.pbDisplay(_INTL("{1} fell asleep!", pbThis))
when :POISON
if newStatusCount>0
if newStatusCount > 0
@battle.pbDisplay(_INTL("{1} was badly poisoned!", pbThis))
else
@battle.pbDisplay(_INTL("{1} was poisoned!", pbThis))
@@ -304,7 +304,7 @@ class Battle::Battler
# NOTE: Bulbapedia claims that Safeguard shouldn't prevent sleep due to
# drowsiness. I disagree with this too. Compare with the other sided
# effects Misty/Electric Terrain, which do prevent it.
return false if pbOwnSide.effects[PBEffects::Safeguard]>0
return false if pbOwnSide.effects[PBEffects::Safeguard] > 0
return true
end
@@ -438,20 +438,20 @@ class Battle::Battler
#=============================================================================
# Confusion
#=============================================================================
def pbCanConfuse?(user = nil,showMessages = true,move = nil,selfInflicted = false)
def pbCanConfuse?(user = nil, showMessages = true, move = nil, selfInflicted = false)
return false if fainted?
if @effects[PBEffects::Confusion]>0
@battle.pbDisplay(_INTL("{1} is already confused.",pbThis)) if showMessages
if @effects[PBEffects::Confusion] > 0
@battle.pbDisplay(_INTL("{1} is already confused.", pbThis)) if showMessages
return false
end
if @effects[PBEffects::Substitute]>0 && !(move && move.ignoresSubstitute?(user)) &&
if @effects[PBEffects::Substitute] > 0 && !(move && move.ignoresSubstitute?(user)) &&
!selfInflicted
@battle.pbDisplay(_INTL("But it failed!")) if showMessages
return false
end
# Terrains immunity
if affectedByTerrain? && @battle.field.terrain == :Misty && Settings::MECHANICS_GENERATION >= 7
@battle.pbDisplay(_INTL("{1} surrounds itself with misty terrain!",pbThis(true))) if showMessages
@battle.pbDisplay(_INTL("{1} surrounds itself with misty terrain!", pbThis(true))) if showMessages
return false
end
if selfInflicted || !@battle.moldBreaker
@@ -459,31 +459,31 @@ class Battle::Battler
if showMessages
@battle.pbShowAbilitySplash(self)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} doesn't become confused!",pbThis))
@battle.pbDisplay(_INTL("{1} doesn't become confused!", pbThis))
else
@battle.pbDisplay(_INTL("{1}'s {2} prevents confusion!",pbThis,abilityName))
@battle.pbDisplay(_INTL("{1}'s {2} prevents confusion!", pbThis, abilityName))
end
@battle.pbHideAbilitySplash(self)
end
return false
end
end
if pbOwnSide.effects[PBEffects::Safeguard]>0 && !selfInflicted &&
if pbOwnSide.effects[PBEffects::Safeguard] > 0 && !selfInflicted &&
!(user && user.hasActiveAbility?(:INFILTRATOR))
@battle.pbDisplay(_INTL("{1}'s team is protected by Safeguard!",pbThis)) if showMessages
@battle.pbDisplay(_INTL("{1}'s team is protected by Safeguard!", pbThis)) if showMessages
return false
end
return true
end
def pbCanConfuseSelf?(showMessages)
return pbCanConfuse?(nil,showMessages,nil,true)
return pbCanConfuse?(nil, showMessages, nil, true)
end
def pbConfuse(msg = nil)
@effects[PBEffects::Confusion] = pbConfusionDuration
@battle.pbCommonAnimation("Confusion",self)
msg = _INTL("{1} became confused!",pbThis) if nil_or_empty?(msg)
@battle.pbCommonAnimation("Confusion", self)
msg = _INTL("{1} became confused!", pbThis) if nil_or_empty?(msg)
@battle.pbDisplay(msg)
PBDebug.log("[Lingering effect] #{pbThis}'s confusion count is #{@effects[PBEffects::Confusion]}")
# Confusion cures
@@ -492,7 +492,7 @@ class Battle::Battler
end
def pbConfusionDuration(duration = -1)
duration = 2+@battle.pbRandom(4) if duration<=0
duration = 2 + @battle.pbRandom(4) if duration <= 0
return duration
end
@@ -503,27 +503,27 @@ class Battle::Battler
#=============================================================================
# Attraction
#=============================================================================
def pbCanAttract?(user,showMessages = true)
def pbCanAttract?(user, showMessages = true)
return false if fainted?
return false if !user || user.fainted?
if @effects[PBEffects::Attract]>=0
@battle.pbDisplay(_INTL("{1} is unaffected!",pbThis)) if showMessages
if @effects[PBEffects::Attract] >= 0
@battle.pbDisplay(_INTL("{1} is unaffected!", pbThis)) if showMessages
return false
end
agender = user.gender
ogender = gender
if agender==2 || ogender==2 || agender==ogender
@battle.pbDisplay(_INTL("{1} is unaffected!",pbThis)) if showMessages
if agender == 2 || ogender == 2 || agender == ogender
@battle.pbDisplay(_INTL("{1} is unaffected!", pbThis)) if showMessages
return false
end
if !@battle.moldBreaker
if hasActiveAbility?([:AROMAVEIL,:OBLIVIOUS])
if hasActiveAbility?([:AROMAVEIL, :OBLIVIOUS])
if showMessages
@battle.pbShowAbilitySplash(self)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} is unaffected!",pbThis))
@battle.pbDisplay(_INTL("{1} is unaffected!", pbThis))
else
@battle.pbDisplay(_INTL("{1}'s {2} prevents romance!",pbThis,abilityName))
@battle.pbDisplay(_INTL("{1}'s {2} prevents romance!", pbThis, abilityName))
end
@battle.pbHideAbilitySplash(self)
end
@@ -534,9 +534,9 @@ class Battle::Battler
if showMessages
@battle.pbShowAbilitySplash(self)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} is unaffected!",pbThis))
@battle.pbDisplay(_INTL("{1} is unaffected!", pbThis))
else
@battle.pbDisplay(_INTL("{1}'s {2} prevents romance!",b.pbThis,b.abilityName))
@battle.pbDisplay(_INTL("{1}'s {2} prevents romance!", b.pbThis, b.abilityName))
end
@battle.pbHideAbilitySplash(self)
end
@@ -547,14 +547,14 @@ class Battle::Battler
return true
end
def pbAttract(user,msg = nil)
def pbAttract(user, msg = nil)
@effects[PBEffects::Attract] = user.index
@battle.pbCommonAnimation("Attract",self)
msg = _INTL("{1} fell in love!",pbThis) if nil_or_empty?(msg)
@battle.pbCommonAnimation("Attract", self)
msg = _INTL("{1} fell in love!", pbThis) if nil_or_empty?(msg)
@battle.pbDisplay(msg)
# Destiny Knot
if hasActiveItem?(:DESTINYKNOT) && user.pbCanAttract?(self,false)
user.pbAttract(self,_INTL("{1} fell in love from the {2}!",user.pbThis(true),itemName))
if hasActiveItem?(:DESTINYKNOT) && user.pbCanAttract?(self, false)
user.pbAttract(self, _INTL("{1} fell in love from the {2}!", user.pbThis(true), itemName))
end
# Attraction cures
pbItemStatusCureCheck

View File

@@ -3,14 +3,14 @@ class Battle::Battler
# Increase stat stages
#=============================================================================
def statStageAtMax?(stat)
return @stages[stat]>=6
return @stages[stat] >= 6
end
def pbCanRaiseStatStage?(stat,user = nil,move = nil,showFailMsg = false,ignoreContrary = false)
def pbCanRaiseStatStage?(stat, user = nil, move = nil, showFailMsg = false, ignoreContrary = false)
return false if fainted?
# Contrary
if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !@battle.moldBreaker
return pbCanLowerStatStage?(stat,user,move,showFailMsg,true)
return pbCanLowerStatStage?(stat, user, move, showFailMsg, true)
end
# Check the stat stage
if statStageAtMax?(stat)
@@ -21,20 +21,20 @@ class Battle::Battler
return true
end
def pbRaiseStatStageBasic(stat,increment,ignoreContrary = false)
def pbRaiseStatStageBasic(stat, increment, ignoreContrary = false)
if !@battle.moldBreaker
# Contrary
if hasActiveAbility?(:CONTRARY) && !ignoreContrary
return pbLowerStatStageBasic(stat,increment,true)
return pbLowerStatStageBasic(stat, increment, true)
end
# Simple
increment *= 2 if hasActiveAbility?(:SIMPLE)
end
# Change the stat stage
increment = [increment,6-@stages[stat]].min
if increment>0
increment = [increment, 6 - @stages[stat]].min
if increment > 0
stat_name = GameData::Stat.get(stat).name
new = @stages[stat]+increment
new = @stages[stat] + increment
PBDebug.log("[Stat change] #{pbThis}'s #{stat_name}: #{@stages[stat]} -> #{new} (+#{increment})")
@stages[stat] += increment
@statsRaisedThisRound = true
@@ -42,22 +42,22 @@ class Battle::Battler
return increment
end
def pbRaiseStatStage(stat,increment,user,showAnim = true,ignoreContrary = false)
def pbRaiseStatStage(stat, increment, user, showAnim = true, ignoreContrary = false)
# Contrary
if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !@battle.moldBreaker
return pbLowerStatStage(stat,increment,user,showAnim,true)
return pbLowerStatStage(stat, increment, user, showAnim, true)
end
# Perform the stat stage change
increment = pbRaiseStatStageBasic(stat,increment,ignoreContrary)
return false if increment<=0
increment = pbRaiseStatStageBasic(stat, increment, ignoreContrary)
return false if increment <= 0
# Stat up animation and message
@battle.pbCommonAnimation("StatUp",self) if showAnim
@battle.pbCommonAnimation("StatUp", self) if showAnim
arrStatTexts = [
_INTL("{1}'s {2} rose!",pbThis,GameData::Stat.get(stat).name),
_INTL("{1}'s {2} rose sharply!",pbThis,GameData::Stat.get(stat).name),
_INTL("{1}'s {2} rose drastically!",pbThis,GameData::Stat.get(stat).name)
_INTL("{1}'s {2} rose!", pbThis, GameData::Stat.get(stat).name),
_INTL("{1}'s {2} rose sharply!", pbThis, GameData::Stat.get(stat).name),
_INTL("{1}'s {2} rose drastically!", pbThis, GameData::Stat.get(stat).name)
]
@battle.pbDisplay(arrStatTexts[[increment-1,2].min])
@battle.pbDisplay(arrStatTexts[[increment - 1, 2].min])
# Trigger abilities upon stat gain
if abilityActive?
Battle::AbilityEffects.triggerOnStatGain(self.ability, self, stat, user)
@@ -65,30 +65,30 @@ class Battle::Battler
return true
end
def pbRaiseStatStageByCause(stat,increment,user,cause,showAnim = true,ignoreContrary = false)
def pbRaiseStatStageByCause(stat, increment, user, cause, showAnim = true, ignoreContrary = false)
# Contrary
if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !@battle.moldBreaker
return pbLowerStatStageByCause(stat,increment,user,cause,showAnim,true)
return pbLowerStatStageByCause(stat, increment, user, cause, showAnim, true)
end
# Perform the stat stage change
increment = pbRaiseStatStageBasic(stat,increment,ignoreContrary)
return false if increment<=0
increment = pbRaiseStatStageBasic(stat, increment, ignoreContrary)
return false if increment <= 0
# Stat up animation and message
@battle.pbCommonAnimation("StatUp",self) if showAnim
if user.index==@index
@battle.pbCommonAnimation("StatUp", self) if showAnim
if user.index == @index
arrStatTexts = [
_INTL("{1}'s {2} raised its {3}!",pbThis,cause,GameData::Stat.get(stat).name),
_INTL("{1}'s {2} sharply raised its {3}!",pbThis,cause,GameData::Stat.get(stat).name),
_INTL("{1}'s {2} drastically raised its {3}!",pbThis,cause,GameData::Stat.get(stat).name)
_INTL("{1}'s {2} raised its {3}!", pbThis, cause, GameData::Stat.get(stat).name),
_INTL("{1}'s {2} sharply raised its {3}!", pbThis, cause, GameData::Stat.get(stat).name),
_INTL("{1}'s {2} drastically raised its {3}!", pbThis, cause, GameData::Stat.get(stat).name)
]
else
arrStatTexts = [
_INTL("{1}'s {2} raised {3}'s {4}!",user.pbThis,cause,pbThis(true),GameData::Stat.get(stat).name),
_INTL("{1}'s {2} sharply raised {3}'s {4}!",user.pbThis,cause,pbThis(true),GameData::Stat.get(stat).name),
_INTL("{1}'s {2} drastically raised {3}'s {4}!",user.pbThis,cause,pbThis(true),GameData::Stat.get(stat).name)
_INTL("{1}'s {2} raised {3}'s {4}!", user.pbThis, cause, pbThis(true), GameData::Stat.get(stat).name),
_INTL("{1}'s {2} sharply raised {3}'s {4}!", user.pbThis, cause, pbThis(true), GameData::Stat.get(stat).name),
_INTL("{1}'s {2} drastically raised {3}'s {4}!", user.pbThis, cause, pbThis(true), GameData::Stat.get(stat).name)
]
end
@battle.pbDisplay(arrStatTexts[[increment-1,2].min])
@battle.pbDisplay(arrStatTexts[[increment - 1, 2].min])
# Trigger abilities upon stat gain
if abilityActive?
Battle::AbilityEffects.triggerOnStatGain(self.ability, self, stat, user)
@@ -96,15 +96,15 @@ class Battle::Battler
return true
end
def pbRaiseStatStageByAbility(stat,increment,user,splashAnim = true)
def pbRaiseStatStageByAbility(stat, increment, user, splashAnim = true)
return false if fainted?
ret = false
@battle.pbShowAbilitySplash(user) if splashAnim
if pbCanRaiseStatStage?(stat,user,nil,Battle::Scene::USE_ABILITY_SPLASH)
if pbCanRaiseStatStage?(stat, user, nil, Battle::Scene::USE_ABILITY_SPLASH)
if Battle::Scene::USE_ABILITY_SPLASH
ret = pbRaiseStatStage(stat,increment,user)
ret = pbRaiseStatStage(stat, increment, user)
else
ret = pbRaiseStatStageByCause(stat,increment,user,user.abilityName)
ret = pbRaiseStatStageByCause(stat, increment, user, user.abilityName)
end
end
@battle.pbHideAbilitySplash(user) if splashAnim
@@ -115,7 +115,7 @@ class Battle::Battler
# Decrease stat stages
#=============================================================================
def statStageAtMin?(stat)
return @stages[stat]<=-6
return @stages[stat] <= -6
end
def pbCanLowerStatStage?(stat, user = nil, move = nil, showFailMsg = false, ignoreContrary = false, ignoreMirrorArmor = false)
@@ -130,27 +130,27 @@ class Battle::Battler
return true if !statStageAtMin?(stat)
end
end
if !user || user.index!=@index # Not self-inflicted
if @effects[PBEffects::Substitute]>0 && (ignoreMirrorArmor || !(move && move.ignoresSubstitute?(user)))
@battle.pbDisplay(_INTL("{1} is protected by its substitute!",pbThis)) if showFailMsg
if !user || user.index != @index # Not self-inflicted
if @effects[PBEffects::Substitute] > 0 && (ignoreMirrorArmor || !(move && move.ignoresSubstitute?(user)))
@battle.pbDisplay(_INTL("{1} is protected by its substitute!", pbThis)) if showFailMsg
return false
end
if pbOwnSide.effects[PBEffects::Mist]>0 &&
if pbOwnSide.effects[PBEffects::Mist] > 0 &&
!(user && user.hasActiveAbility?(:INFILTRATOR))
@battle.pbDisplay(_INTL("{1} is protected by Mist!",pbThis)) if showFailMsg
@battle.pbDisplay(_INTL("{1} is protected by Mist!", pbThis)) if showFailMsg
return false
end
if abilityActive?
return false if !@battle.moldBreaker && Battle::AbilityEffects.triggerStatLossImmunity(
self.ability,self,stat,@battle,showFailMsg)
self.ability, self, stat, @battle, showFailMsg)
return false if Battle::AbilityEffects.triggerStatLossImmunityNonIgnorable(
self.ability,self,stat,@battle,showFailMsg)
self.ability, self, stat, @battle, showFailMsg)
end
if !@battle.moldBreaker
allAllies.each do |b|
next if !b.abilityActive?
return false if Battle::AbilityEffects.triggerStatLossImmunityFromAlly(
b.ability,b,self,stat,@battle,showFailMsg)
b.ability, b, self, stat, @battle, showFailMsg)
end
end
end
@@ -163,20 +163,20 @@ class Battle::Battler
return true
end
def pbLowerStatStageBasic(stat,increment,ignoreContrary = false)
def pbLowerStatStageBasic(stat, increment, ignoreContrary = false)
if !@battle.moldBreaker
# Contrary
if hasActiveAbility?(:CONTRARY) && !ignoreContrary
return pbRaiseStatStageBasic(stat,increment,true)
return pbRaiseStatStageBasic(stat, increment, true)
end
# Simple
increment *= 2 if hasActiveAbility?(:SIMPLE)
end
# Change the stat stage
increment = [increment,6+@stages[stat]].min
if increment>0
increment = [increment, 6 + @stages[stat]].min
if increment > 0
stat_name = GameData::Stat.get(stat).name
new = @stages[stat]-increment
new = @stages[stat] - increment
PBDebug.log("[Stat change] #{pbThis}'s #{stat_name}: #{@stages[stat]} -> #{new} (-#{increment})")
@stages[stat] -= increment
@statsLoweredThisRound = true
@@ -210,16 +210,16 @@ class Battle::Battler
end
end
# Perform the stat stage change
increment = pbLowerStatStageBasic(stat,increment,ignoreContrary)
return false if increment<=0
increment = pbLowerStatStageBasic(stat, increment, ignoreContrary)
return false if increment <= 0
# Stat down animation and message
@battle.pbCommonAnimation("StatDown",self) if showAnim
@battle.pbCommonAnimation("StatDown", self) if showAnim
arrStatTexts = [
_INTL("{1}'s {2} fell!",pbThis,GameData::Stat.get(stat).name),
_INTL("{1}'s {2} harshly fell!",pbThis,GameData::Stat.get(stat).name),
_INTL("{1}'s {2} severely fell!",pbThis,GameData::Stat.get(stat).name)
_INTL("{1}'s {2} fell!", pbThis, GameData::Stat.get(stat).name),
_INTL("{1}'s {2} harshly fell!", pbThis, GameData::Stat.get(stat).name),
_INTL("{1}'s {2} severely fell!", pbThis, GameData::Stat.get(stat).name)
]
@battle.pbDisplay(arrStatTexts[[increment-1,2].min])
@battle.pbDisplay(arrStatTexts[[increment - 1, 2].min])
# Trigger abilities upon stat loss
if abilityActive?
Battle::AbilityEffects.triggerOnStatLoss(self.ability, self, stat, user)
@@ -250,24 +250,24 @@ class Battle::Battler
end
end
# Perform the stat stage change
increment = pbLowerStatStageBasic(stat,increment,ignoreContrary)
return false if increment<=0
increment = pbLowerStatStageBasic(stat, increment, ignoreContrary)
return false if increment <= 0
# Stat down animation and message
@battle.pbCommonAnimation("StatDown",self) if showAnim
if user.index==@index
@battle.pbCommonAnimation("StatDown", self) if showAnim
if user.index == @index
arrStatTexts = [
_INTL("{1}'s {2} lowered its {3}!",pbThis,cause,GameData::Stat.get(stat).name),
_INTL("{1}'s {2} harshly lowered its {3}!",pbThis,cause,GameData::Stat.get(stat).name),
_INTL("{1}'s {2} severely lowered its {3}!",pbThis,cause,GameData::Stat.get(stat).name)
_INTL("{1}'s {2} lowered its {3}!", pbThis, cause, GameData::Stat.get(stat).name),
_INTL("{1}'s {2} harshly lowered its {3}!", pbThis, cause, GameData::Stat.get(stat).name),
_INTL("{1}'s {2} severely lowered its {3}!", pbThis, cause, GameData::Stat.get(stat).name)
]
else
arrStatTexts = [
_INTL("{1}'s {2} lowered {3}'s {4}!",user.pbThis,cause,pbThis(true),GameData::Stat.get(stat).name),
_INTL("{1}'s {2} harshly lowered {3}'s {4}!",user.pbThis,cause,pbThis(true),GameData::Stat.get(stat).name),
_INTL("{1}'s {2} severely lowered {3}'s {4}!",user.pbThis,cause,pbThis(true),GameData::Stat.get(stat).name)
_INTL("{1}'s {2} lowered {3}'s {4}!", user.pbThis, cause, pbThis(true), GameData::Stat.get(stat).name),
_INTL("{1}'s {2} harshly lowered {3}'s {4}!", user.pbThis, cause, pbThis(true), GameData::Stat.get(stat).name),
_INTL("{1}'s {2} severely lowered {3}'s {4}!", user.pbThis, cause, pbThis(true), GameData::Stat.get(stat).name)
]
end
@battle.pbDisplay(arrStatTexts[[increment-1,2].min])
@battle.pbDisplay(arrStatTexts[[increment - 1, 2].min])
# Trigger abilities upon stat loss
if abilityActive?
Battle::AbilityEffects.triggerOnStatLoss(self.ability, self, stat, user)
@@ -275,15 +275,15 @@ class Battle::Battler
return true
end
def pbLowerStatStageByAbility(stat,increment,user,splashAnim = true,checkContact = false)
def pbLowerStatStageByAbility(stat, increment, user, splashAnim = true, checkContact = false)
ret = false
@battle.pbShowAbilitySplash(user) if splashAnim
if pbCanLowerStatStage?(stat,user,nil,Battle::Scene::USE_ABILITY_SPLASH) &&
if pbCanLowerStatStage?(stat, user, nil, Battle::Scene::USE_ABILITY_SPLASH) &&
(!checkContact || affectedByContactEffect?(Battle::Scene::USE_ABILITY_SPLASH))
if Battle::Scene::USE_ABILITY_SPLASH
ret = pbLowerStatStage(stat,increment,user)
ret = pbLowerStatStage(stat, increment, user)
else
ret = pbLowerStatStageByCause(stat,increment,user,user.abilityName)
ret = pbLowerStatStageByCause(stat, increment, user, user.abilityName)
end
end
@battle.pbHideAbilitySplash(user) if splashAnim
@@ -293,12 +293,12 @@ class Battle::Battler
def pbLowerAttackStatStageIntimidate(user)
return false if fainted?
# NOTE: Substitute intentially blocks Intimidate even if self has Contrary.
if @effects[PBEffects::Substitute]>0
if @effects[PBEffects::Substitute] > 0
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} is protected by its substitute!",pbThis))
@battle.pbDisplay(_INTL("{1} is protected by its substitute!", pbThis))
else
@battle.pbDisplay(_INTL("{1}'s substitute protected it from {2}'s {3}!",
pbThis,user.pbThis(true),user.abilityName))
pbThis, user.pbThis(true), user.abilityName))
end
return false
end
@@ -314,22 +314,22 @@ class Battle::Battler
return false
end
if Battle::Scene::USE_ABILITY_SPLASH
return pbLowerStatStageByAbility(:ATTACK,1,user,false)
return pbLowerStatStageByAbility(:ATTACK, 1, user, false)
end
# NOTE: These checks exist to ensure appropriate messages are shown if
# Intimidate is blocked somehow (i.e. the messages should mention the
# Intimidate ability by name).
if !hasActiveAbility?(:CONTRARY)
if pbOwnSide.effects[PBEffects::Mist]>0
if pbOwnSide.effects[PBEffects::Mist] > 0
@battle.pbDisplay(_INTL("{1} is protected from {2}'s {3} by Mist!",
pbThis,user.pbThis(true),user.abilityName))
pbThis, user.pbThis(true), user.abilityName))
return false
end
if abilityActive?
if Battle::AbilityEffects.triggerStatLossImmunity(self.ability, self, :ATTACK, @battle, false) ||
Battle::AbilityEffects.triggerStatLossImmunityNonIgnorable(self.ability, self, :ATTACK, @battle, false)
@battle.pbDisplay(_INTL("{1}'s {2} prevented {3}'s {4} from working!",
pbThis,abilityName,user.pbThis(true),user.abilityName))
pbThis, abilityName, user.pbThis(true), user.abilityName))
return false
end
end
@@ -337,13 +337,13 @@ class Battle::Battler
next if !b.abilityActive?
if Battle::AbilityEffects.triggerStatLossImmunityFromAlly(b.ability, b, self, :ATTACK, @battle, false)
@battle.pbDisplay(_INTL("{1} is protected from {2}'s {3} by {4}'s {5}!",
pbThis,user.pbThis(true),user.abilityName,b.pbThis(true),b.abilityName))
pbThis, user.pbThis(true), user.abilityName, b.pbThis(true), b.abilityName))
return false
end
end
end
return false if !pbCanLowerStatStage?(:ATTACK,user)
return pbLowerStatStageByCause(:ATTACK,1,user,user.abilityName)
return false if !pbCanLowerStatStage?(:ATTACK, user)
return pbLowerStatStageByCause(:ATTACK, 1, user, user.abilityName)
end
#=============================================================================

View File

@@ -7,7 +7,7 @@ class Battle::Battler
Battle::AbilityEffects.triggerOnSwitchOut(self.ability, self, false)
end
# Reset form
@battle.peer.pbOnLeavingBattle(@battle,@pokemon,@battle.usedInBattle[idxOwnSide][@index/2])
@battle.peer.pbOnLeavingBattle(@battle, @pokemon, @battle.usedInBattle[idxOwnSide][@index / 2])
# Treat self as fainted
@hp = 0
@fainted = true
@@ -77,11 +77,11 @@ class Battle::Battler
next !b.ungainableAbility? &&
![:POWEROFALCHEMY, :RECEIVER, :TRACE].include?(b.ability_id)
}
if choices.length>0
if choices.length > 0
choice = choices[@battle.pbRandom(choices.length)]
@battle.pbShowAbilitySplash(self)
self.ability = choice.ability
@battle.pbDisplay(_INTL("{1} traced {2}'s {3}!",pbThis,choice.pbThis(true),choice.abilityName))
@battle.pbDisplay(_INTL("{1} traced {2}'s {3}!", pbThis, choice.pbThis(true), choice.abilityName))
@battle.pbHideAbilitySplash(self)
if !onSwitchIn && (unstoppableAbility? || abilityActive?)
Battle::AbilityEffects.triggerOnSwitchIn(self.ability, self, @battle)
@@ -227,7 +227,7 @@ class Battle::Battler
self.item = nil
end
def pbConsumeItem(recoverable = true,symbiosis = true,belch = true)
def pbConsumeItem(recoverable = true, symbiosis = true, belch = true)
PBDebug.log("[Item consumed] #{pbThis} consumed its held #{itemName}")
if recoverable
setRecycleItem(@item_id)
@@ -250,10 +250,10 @@ class Battle::Battler
@battle.pbShowAbilitySplash(b)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} shared its {2} with {3}!",
b.pbThis,b.itemName,pbThis(true)))
b.pbThis, b.itemName, pbThis(true)))
else
@battle.pbDisplay(_INTL("{1}'s {2} let it share its {3} with {4}!",
b.pbThis,b.abilityName,b.itemName,pbThis(true)))
b.pbThis, b.abilityName, b.itemName, pbThis(true)))
end
self.item = b.item
b.item = nil

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

View File

@@ -2,20 +2,20 @@ class Battle::Battler
#=============================================================================
# Get move's user
#=============================================================================
def pbFindUser(_choice,_move)
def pbFindUser(_choice, _move)
return self
end
def pbChangeUser(choice,move,user)
def pbChangeUser(choice, move, user)
# Snatch
move.snatched = false
if move.statusMove? && move.canSnatch?
newUser = nil
strength = 100
@battle.allBattlers.each do |b|
next if b.effects[PBEffects::Snatch]==0 ||
b.effects[PBEffects::Snatch]>=strength
next if b.effects[PBEffects::SkyDrop]>=0
next if b.effects[PBEffects::Snatch] == 0 ||
b.effects[PBEffects::Snatch] >= strength
next if b.effects[PBEffects::SkyDrop] >= 0
newUser = b
strength = b.effects[PBEffects::Snatch]
end
@@ -33,59 +33,59 @@ class Battle::Battler
#=============================================================================
# Get move's default target(s)
#=============================================================================
def pbFindTargets(choice,move,user)
def pbFindTargets(choice, move, user)
preTarget = choice[3] # A target that was already chosen
targets = []
# Get list of targets
case move.pbTarget(user).id # Curse can change its target type
when :NearAlly
targetBattler = (preTarget>=0) ? @battle.battlers[preTarget] : nil
if !pbAddTarget(targets,user,targetBattler,move)
pbAddTargetRandomAlly(targets,user,move)
targetBattler = (preTarget >= 0) ? @battle.battlers[preTarget] : nil
if !pbAddTarget(targets, user, targetBattler, move)
pbAddTargetRandomAlly(targets, user, move)
end
when :UserOrNearAlly
targetBattler = (preTarget>=0) ? @battle.battlers[preTarget] : nil
if !pbAddTarget(targets,user,targetBattler,move,true,true)
pbAddTarget(targets,user,user,move,true,true)
targetBattler = (preTarget >= 0) ? @battle.battlers[preTarget] : nil
if !pbAddTarget(targets, user, targetBattler, move, true, true)
pbAddTarget(targets, user, user, move, true, true)
end
when :AllAllies
@battle.allSameSideBattlers(user.index).each do |b|
pbAddTarget(targets,user,b,move,false,true) if b.index != user.index
pbAddTarget(targets, user, b, move, false, true) if b.index != user.index
end
when :UserAndAllies
pbAddTarget(targets,user,user,move,true,true)
pbAddTarget(targets, user, user, move, true, true)
@battle.allSameSideBattlers(user.index).each { |b| pbAddTarget(targets, user, b, move, false, true) }
when :NearFoe, :NearOther
targetBattler = (preTarget>=0) ? @battle.battlers[preTarget] : nil
if !pbAddTarget(targets,user,targetBattler,move)
if preTarget>=0 && !user.opposes?(preTarget)
pbAddTargetRandomAlly(targets,user,move)
targetBattler = (preTarget >= 0) ? @battle.battlers[preTarget] : nil
if !pbAddTarget(targets, user, targetBattler, move)
if preTarget >= 0 && !user.opposes?(preTarget)
pbAddTargetRandomAlly(targets, user, move)
else
pbAddTargetRandomFoe(targets,user,move)
pbAddTargetRandomFoe(targets, user, move)
end
end
when :RandomNearFoe
pbAddTargetRandomFoe(targets,user,move)
pbAddTargetRandomFoe(targets, user, move)
when :AllNearFoes
@battle.allOtherSideBattlers(user.index).each { |b| pbAddTarget(targets,user,b,move) }
@battle.allOtherSideBattlers(user.index).each { |b| pbAddTarget(targets, user, b, move) }
when :Foe, :Other
targetBattler = (preTarget>=0) ? @battle.battlers[preTarget] : nil
if !pbAddTarget(targets,user,targetBattler,move,false)
if preTarget>=0 && !user.opposes?(preTarget)
pbAddTargetRandomAlly(targets,user,move,false)
targetBattler = (preTarget >= 0) ? @battle.battlers[preTarget] : nil
if !pbAddTarget(targets, user, targetBattler, move, false)
if preTarget >= 0 && !user.opposes?(preTarget)
pbAddTargetRandomAlly(targets, user, move, false)
else
pbAddTargetRandomFoe(targets,user,move,false)
pbAddTargetRandomFoe(targets, user, move, false)
end
end
when :AllFoes
@battle.allOtherSideBattlers(user.index).each { |b| pbAddTarget(targets,user,b,move,false) }
@battle.allOtherSideBattlers(user.index).each { |b| pbAddTarget(targets, user, b, move, false) }
when :AllNearOthers
@battle.allBattlers.each { |b| pbAddTarget(targets, user, b, move) }
when :AllBattlers
@battle.allBattlers.each { |b| pbAddTarget(targets, user, b, move, false, true) }
else
# Used by Counter/Mirror Coat/Metal Burst/Bide
move.pbAddTarget(targets,user) # Move-specific pbAddTarget, not the def below
move.pbAddTarget(targets, user) # Move-specific pbAddTarget, not the def below
end
return targets
end
@@ -93,7 +93,7 @@ class Battle::Battler
#=============================================================================
# Redirect attack to another target
#=============================================================================
def pbChangeTargets(move,user,targets)
def pbChangeTargets(move, user, targets)
target_data = move.pbTarget(user)
return targets if @battle.switching # For Pursuit interrupting a switch
return targets if move.cannotRedirect? || move.targetsPosition?
@@ -106,9 +106,9 @@ class Battle::Battler
newTarget = nil
strength = 100 # Lower strength takes priority
priority.each do |b|
next if b.fainted? || b.effects[PBEffects::SkyDrop]>=0
next if b.effects[PBEffects::Spotlight]==0 ||
b.effects[PBEffects::Spotlight]>=strength
next if b.fainted? || b.effects[PBEffects::SkyDrop] >= 0
next if b.effects[PBEffects::Spotlight] == 0 ||
b.effects[PBEffects::Spotlight] >= strength
next if !b.opposes?(user)
next if nearOnly && !b.near?(user)
newTarget = b
@@ -117,17 +117,17 @@ class Battle::Battler
if newTarget
PBDebug.log("[Move target changed] #{newTarget.pbThis}'s Spotlight made it the target")
targets = []
pbAddTarget(targets,user,newTarget,move,nearOnly)
pbAddTarget(targets, user, newTarget, move, nearOnly)
return targets
end
# Follow Me/Rage Powder (takes priority over Lightning Rod/Storm Drain)
newTarget = nil
strength = 100 # Lower strength takes priority
priority.each do |b|
next if b.fainted? || b.effects[PBEffects::SkyDrop]>=0
next if b.fainted? || b.effects[PBEffects::SkyDrop] >= 0
next if b.effects[PBEffects::RagePowder] && !user.affectedByPowder?
next if b.effects[PBEffects::FollowMe]==0 ||
b.effects[PBEffects::FollowMe]>=strength
next if b.effects[PBEffects::FollowMe] == 0 ||
b.effects[PBEffects::FollowMe] >= strength
next if !b.opposes?(user)
next if nearOnly && !b.near?(user)
newTarget = b
@@ -136,30 +136,30 @@ class Battle::Battler
if newTarget
PBDebug.log("[Move target changed] #{newTarget.pbThis}'s Follow Me/Rage Powder made it the target")
targets = []
pbAddTarget(targets,user,newTarget,move,nearOnly)
pbAddTarget(targets, user, newTarget, move, nearOnly)
return targets
end
# Lightning Rod
targets = pbChangeTargetByAbility(:LIGHTNINGROD,:ELECTRIC,move,user,targets,priority,nearOnly)
targets = pbChangeTargetByAbility(:LIGHTNINGROD, :ELECTRIC, move, user, targets, priority, nearOnly)
# Storm Drain
targets = pbChangeTargetByAbility(:STORMDRAIN,:WATER,move,user,targets,priority,nearOnly)
targets = pbChangeTargetByAbility(:STORMDRAIN, :WATER, move, user, targets, priority, nearOnly)
return targets
end
def pbChangeTargetByAbility(drawingAbility,drawnType,move,user,targets,priority,nearOnly)
def pbChangeTargetByAbility(drawingAbility, drawnType, move, user, targets, priority, nearOnly)
return targets if move.calcType != drawnType
return targets if targets[0].hasActiveAbility?(drawingAbility)
priority.each do |b|
next if b.index==user.index || b.index==targets[0].index
next if b.index == user.index || b.index == targets[0].index
next if !b.hasActiveAbility?(drawingAbility)
next if nearOnly && !b.near?(user)
@battle.pbShowAbilitySplash(b)
targets.clear
pbAddTarget(targets,user,b,move,nearOnly)
pbAddTarget(targets, user, b, move, nearOnly)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} took the attack!",b.pbThis))
@battle.pbDisplay(_INTL("{1} took the attack!", b.pbThis))
else
@battle.pbDisplay(_INTL("{1} took the attack with its {2}!",b.pbThis,b.abilityName))
@battle.pbDisplay(_INTL("{1} took the attack with its {2}!", b.pbThis, b.abilityName))
end
@battle.pbHideAbilitySplash(b)
break
@@ -170,11 +170,11 @@ class Battle::Battler
#=============================================================================
# Register target
#=============================================================================
def pbAddTarget(targets,user,target,move,nearOnly = true,allowUser = false)
def pbAddTarget(targets, user, target, move, nearOnly = true, allowUser = false)
return false if !target || (target.fainted? && !move.targetsPosition?)
return false if !allowUser && target == user
return false if nearOnly && !user.near?(target) && target != user
targets.each { |b| return true if b.index==target.index } # Already added
targets.each { |b| return true if b.index == target.index } # Already added
targets.push(target)
return true
end
@@ -185,7 +185,7 @@ class Battle::Battler
next if nearOnly && !user.near?(b)
pbAddTarget(choices, user, b, move, nearOnly)
end
if choices.length>0
if choices.length > 0
pbAddTarget(targets, user, choices[@battle.pbRandom(choices.length)], move, nearOnly)
end
end
@@ -196,7 +196,7 @@ class Battle::Battler
next if nearOnly && !user.near?(b)
pbAddTarget(choices, user, b, move, nearOnly)
end
if choices.length>0
if choices.length > 0
pbAddTarget(targets, user, choices[@battle.pbRandom(choices.length)], move, nearOnly)
end
end

View File

@@ -7,35 +7,35 @@ class Battle::Battler
# 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)
def pbCanChooseMove?(move, commandPhase, showMessages = true, specialUsage = false)
# Disable
if @effects[PBEffects::DisableMove]==move.id && !specialUsage
if @effects[PBEffects::DisableMove] == move.id && !specialUsage
if showMessages
msg = _INTL("{1}'s {2} is disabled!",pbThis,move.name)
msg = _INTL("{1}'s {2} is disabled!", pbThis, move.name)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
end
# Heal Block
if @effects[PBEffects::HealBlock]>0 && move.healingMove?
if @effects[PBEffects::HealBlock] > 0 && move.healingMove?
if showMessages
msg = _INTL("{1} can't use {2} because of Heal Block!",pbThis,move.name)
msg = _INTL("{1} can't use {2} because of Heal Block!", pbThis, move.name)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
end
# Gravity
if @battle.field.effects[PBEffects::Gravity]>0 && move.unusableInGravity?
if @battle.field.effects[PBEffects::Gravity] > 0 && move.unusableInGravity?
if showMessages
msg = _INTL("{1} can't use {2} because of gravity!",pbThis,move.name)
msg = _INTL("{1} can't use {2} because of gravity!", pbThis, move.name)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
end
# Throat Chop
if @effects[PBEffects::ThroatChop]>0 && move.soundMove?
if @effects[PBEffects::ThroatChop] > 0 && move.soundMove?
if showMessages
msg = _INTL("{1} can't use {2} because of Throat Chop!",pbThis,move.name)
msg = _INTL("{1} can't use {2} because of Throat Chop!", pbThis, move.name)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
@@ -46,7 +46,7 @@ class Battle::Battler
choiced_move_name = GameData::Move.get(@effects[PBEffects::ChoiceBand]).name
if hasActiveItem?([:CHOICEBAND, :CHOICESPECS, :CHOICESCARF])
if showMessages
msg = _INTL("The {1} only allows the use of {2}!",itemName, choiced_move_name)
msg = _INTL("The {1} only allows the use of {2}!", itemName, choiced_move_name)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
@@ -59,18 +59,18 @@ class Battle::Battler
end
end
# Taunt
if @effects[PBEffects::Taunt]>0 && move.statusMove?
if @effects[PBEffects::Taunt] > 0 && move.statusMove?
if showMessages
msg = _INTL("{1} can't use {2} after the taunt!",pbThis,move.name)
msg = _INTL("{1} can't use {2} after the taunt!", pbThis, move.name)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
end
# Torment
if @effects[PBEffects::Torment] && !@effects[PBEffects::Instructed] &&
@lastMoveUsed && move.id==@lastMoveUsed && move.id!=@battle.struggle.id
@lastMoveUsed && move.id == @lastMoveUsed && move.id != @battle.struggle.id
if showMessages
msg = _INTL("{1} can't use the same move twice in a row due to the torment!",pbThis)
msg = _INTL("{1} can't use the same move twice in a row due to the torment!", pbThis)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
@@ -78,7 +78,7 @@ class Battle::Battler
# Imprison
if @battle.allOtherSideBattlers(@index).any? { |b| b.effects[PBEffects::Imprison] && b.pbHasMove?(move.id) }
if showMessages
msg = _INTL("{1} can't use its sealed {2}!",pbThis,move.name)
msg = _INTL("{1} can't use its sealed {2}!", pbThis, move.name)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
@@ -94,7 +94,7 @@ class Battle::Battler
return false
end
# Belch
return false if !move.pbCanChooseMove?(self,commandPhase,showMessages)
return false if !move.pbCanChooseMove?(self, commandPhase, showMessages)
return true
end
@@ -105,7 +105,7 @@ class Battle::Battler
# use a different move in disobedience), or false if attack stops.
def pbObedienceCheck?(choice)
return true if usingMultiTurnAttack?
return true if choice[0]!=:UseMove
return true if choice[0] != :UseMove
return true if !@battle.internalBattle
return true if !@battle.pbOwnedByPlayer?(@index)
disobedient = false
@@ -115,61 +115,61 @@ class Battle::Battler
badgeLevel = 10 * (@battle.pbPlayer.badge_count + 1)
badgeLevel = GameData::GrowthRate.max_level if @battle.pbPlayer.badge_count >= 8
if @level > badgeLevel
a = ((@level+badgeLevel)*@battle.pbRandom(256)/256).floor
disobedient |= (a>=badgeLevel)
a = ((@level + badgeLevel) * @battle.pbRandom(256) / 256).floor
disobedient |= (a >= badgeLevel)
end
end
disobedient |= !pbHyperModeObedience(choice[2])
return true if !disobedient
# Pokémon is disobedient; make it do something else
return pbDisobey(choice,badgeLevel)
return pbDisobey(choice, badgeLevel)
end
def pbDisobey(choice,badgeLevel)
def pbDisobey(choice, badgeLevel)
move = choice[2]
PBDebug.log("[Disobedience] #{pbThis} disobeyed")
@effects[PBEffects::Rage] = false
# Do nothing if using Snore/Sleep Talk
if @status == :SLEEP && move.usableWhenAsleep?
@battle.pbDisplay(_INTL("{1} ignored orders and kept sleeping!",pbThis))
@battle.pbDisplay(_INTL("{1} ignored orders and kept sleeping!", pbThis))
return false
end
b = ((@level+badgeLevel)*@battle.pbRandom(256)/256).floor
b = ((@level + badgeLevel) * @battle.pbRandom(256) / 256).floor
# Use another move
if b<badgeLevel
@battle.pbDisplay(_INTL("{1} ignored orders!",pbThis))
if b < badgeLevel
@battle.pbDisplay(_INTL("{1} ignored orders!", pbThis))
return false if !@battle.pbCanShowFightMenu?(@index)
otherMoves = []
eachMoveWithIndex do |_m,i|
next if i==choice[1]
otherMoves.push(i) if @battle.pbCanChooseMove?(@index,i,false)
eachMoveWithIndex do |_m, i|
next if i == choice[1]
otherMoves.push(i) if @battle.pbCanChooseMove?(@index, i, false)
end
return false if otherMoves.length==0 # No other move to use; do nothing
return false if otherMoves.length == 0 # No other move to use; do nothing
newChoice = otherMoves[@battle.pbRandom(otherMoves.length)]
choice[1] = newChoice
choice[2] = @moves[newChoice]
choice[3] = -1
return true
end
c = @level-badgeLevel
c = @level - badgeLevel
r = @battle.pbRandom(256)
# Fall asleep
if r<c && pbCanSleep?(self,false)
pbSleepSelf(_INTL("{1} began to nap!",pbThis))
if r < c && pbCanSleep?(self, false)
pbSleepSelf(_INTL("{1} began to nap!", pbThis))
return false
end
# Hurt self in confusion
r -= c
if r < c && @status != :SLEEP
pbConfusionDamage(_INTL("{1} won't obey! It hurt itself in its confusion!",pbThis))
pbConfusionDamage(_INTL("{1} won't obey! It hurt itself in its confusion!", pbThis))
return false
end
# Show refusal message and do nothing
case @battle.pbRandom(4)
when 0 then @battle.pbDisplay(_INTL("{1} won't obey!",pbThis))
when 1 then @battle.pbDisplay(_INTL("{1} turned away!",pbThis))
when 2 then @battle.pbDisplay(_INTL("{1} is loafing around!",pbThis))
when 3 then @battle.pbDisplay(_INTL("{1} pretended not to notice!",pbThis))
when 0 then @battle.pbDisplay(_INTL("{1} won't obey!", pbThis))
when 1 then @battle.pbDisplay(_INTL("{1} turned away!", pbThis))
when 2 then @battle.pbDisplay(_INTL("{1} is loafing around!", pbThis))
when 3 then @battle.pbDisplay(_INTL("{1} pretended not to notice!", pbThis))
end
return false
end
@@ -179,25 +179,25 @@ class Battle::Battler
# 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)
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
# check for it here.
if !pbCanChooseMove?(move,false,true,specialUsage)
if !pbCanChooseMove?(move, false, true, specialUsage)
@lastMoveFailed = true
return false
end
# Check whether it's possible for self to do anything at all
if @effects[PBEffects::SkyDrop]>=0 # Intentionally no message here
if @effects[PBEffects::SkyDrop] >= 0 # Intentionally no message here
PBDebug.log("[Move failed] #{pbThis} can't use #{move.name} because of being Sky Dropped")
return false
end
if @effects[PBEffects::HyperBeam]>0 # Intentionally before Truant
@battle.pbDisplay(_INTL("{1} must recharge!",pbThis))
if @effects[PBEffects::HyperBeam] > 0 # Intentionally before Truant
@battle.pbDisplay(_INTL("{1} must recharge!", pbThis))
return false
end
if choice[1]==-2 # Battle Palace
@battle.pbDisplay(_INTL("{1} appears incapable of using its power!",pbThis))
if choice[1] == -2 # Battle Palace
@battle.pbDisplay(_INTL("{1} appears incapable of using its power!", pbThis))
return false
end
# Skip checking all applied effects that could make self fail doing something
@@ -206,7 +206,7 @@ class Battle::Battler
case @status
when :SLEEP
self.statusCount -= 1
if @statusCount<=0
if @statusCount <= 0
pbCureStatus
else
pbContinueStatus
@@ -217,7 +217,7 @@ class Battle::Battler
end
when :FROZEN
if !move.thawsUser?
if @battle.pbRandom(100)<20
if @battle.pbRandom(100) < 20
pbCureStatus
else
pbContinueStatus
@@ -233,7 +233,7 @@ class Battle::Battler
@effects[PBEffects::Truant] = !@effects[PBEffects::Truant]
if !@effects[PBEffects::Truant] # True means loafing, but was just inverted
@battle.pbShowAbilitySplash(self)
@battle.pbDisplay(_INTL("{1} is loafing around!",pbThis))
@battle.pbDisplay(_INTL("{1} is loafing around!", pbThis))
@lastMoveFailed = true
@battle.pbHideAbilitySplash(self)
return false
@@ -241,7 +241,7 @@ class Battle::Battler
end
# Flinching
if @effects[PBEffects::Flinch]
@battle.pbDisplay(_INTL("{1} flinched and couldn't move!",pbThis))
@battle.pbDisplay(_INTL("{1} flinched and couldn't move!", pbThis))
if abilityActive?
Battle::AbilityEffects.triggerOnFlinch(self.ability, self, @battle)
end
@@ -249,16 +249,16 @@ class Battle::Battler
return false
end
# Confusion
if @effects[PBEffects::Confusion]>0
if @effects[PBEffects::Confusion] > 0
@effects[PBEffects::Confusion] -= 1
if @effects[PBEffects::Confusion]<=0
if @effects[PBEffects::Confusion] <= 0
pbCureConfusion
@battle.pbDisplay(_INTL("{1} snapped out of its confusion.",pbThis))
@battle.pbDisplay(_INTL("{1} snapped out of its confusion.", pbThis))
else
@battle.pbCommonAnimation("Confusion",self)
@battle.pbDisplay(_INTL("{1} is confused!",pbThis))
@battle.pbCommonAnimation("Confusion", self)
@battle.pbDisplay(_INTL("{1} is confused!", pbThis))
threshold = (Settings::MECHANICS_GENERATION >= 7) ? 33 : 50 # % chance
if @battle.pbRandom(100)<threshold
if @battle.pbRandom(100) < threshold
pbConfusionDamage(_INTL("It hurt itself in its confusion!"))
@lastMoveFailed = true
return false
@@ -267,19 +267,19 @@ class Battle::Battler
end
# Paralysis
if @status == :PARALYSIS
if @battle.pbRandom(100)<25
if @battle.pbRandom(100) < 25
pbContinueStatus
@lastMoveFailed = true
return false
end
end
# Infatuation
if @effects[PBEffects::Attract]>=0
@battle.pbCommonAnimation("Attract",self)
@battle.pbDisplay(_INTL("{1} is in love with {2}!",pbThis,
if @effects[PBEffects::Attract] >= 0
@battle.pbCommonAnimation("Attract", self)
@battle.pbDisplay(_INTL("{1} is in love with {2}!", pbThis,
@battle.battlers[@effects[PBEffects::Attract]].pbThis(true)))
if @battle.pbRandom(100)<50
@battle.pbDisplay(_INTL("{1} is immobilized by love!",pbThis))
if @battle.pbRandom(100) < 50
@battle.pbDisplay(_INTL("{1} is immobilized by love!", pbThis))
@lastMoveFailed = true
return false
end
@@ -293,7 +293,7 @@ class Battle::Battler
#=============================================================================
def pbSuccessCheckAgainstTarget(move, user, target, targets)
show_message = move.pbShowFailMessages?(targets)
typeMod = move.pbCalcTypeMod(move.calcType,user,target)
typeMod = move.pbCalcTypeMod(move.calcType, user, target)
target.damageState.typeMod = typeMod
# Two-turn attacks can't fail here in the charging turn
return true if user.effects[PBEffects::TwoTurnAttack]
@@ -301,12 +301,12 @@ class Battle::Battler
return false if move.pbFailsAgainstTarget?(user, target, show_message)
# Immunity to priority moves because of Psychic Terrain
if @battle.field.terrain == :Psychic && target.affectedByTerrain? && target.opposes?(user) &&
@battle.choices[user.index][4]>0 # Move priority saved from pbCalculatePriority
@battle.choices[user.index][4] > 0 # Move priority saved from pbCalculatePriority
@battle.pbDisplay(_INTL("{1} surrounds itself with psychic terrain!", target.pbThis)) if show_message
return false
end
# Crafty Shield
if target.pbOwnSide.effects[PBEffects::CraftyShield] && user.index!=target.index &&
if target.pbOwnSide.effects[PBEffects::CraftyShield] && user.index != target.index &&
move.statusMove? && !move.pbTarget(user).targets_all
if show_message
@battle.pbCommonAnimation("CraftyShield", target)
@@ -318,7 +318,7 @@ class Battle::Battler
end
if !(user.hasActiveAbility?(:UNSEENFIST) && move.contactMove?)
# Wide Guard
if target.pbOwnSide.effects[PBEffects::WideGuard] && user.index!=target.index &&
if target.pbOwnSide.effects[PBEffects::WideGuard] && user.index != target.index &&
move.pbTarget(user).num_targets > 1 &&
(Settings::MECHANICS_GENERATION >= 7 || move.damagingMove?)
if show_message
@@ -332,7 +332,7 @@ class Battle::Battler
if move.canProtectAgainst?
# Quick Guard
if target.pbOwnSide.effects[PBEffects::QuickGuard] &&
@battle.choices[user.index][4]>0 # Move priority saved from pbCalculatePriority
@battle.choices[user.index][4] > 0 # Move priority saved from pbCalculatePriority
if show_message
@battle.pbCommonAnimation("QuickGuard", target)
@battle.pbDisplay(_INTL("Quick Guard protected {1}!", target.pbThis(true)))
@@ -376,8 +376,8 @@ class Battle::Battler
@battle.successStates[user.index].protected = true
if move.pbContactMove?(user) && user.affectedByContactEffect?
@battle.scene.pbDamageAnimation(user)
user.pbReduceHP(user.totalhp/8,false)
@battle.pbDisplay(_INTL("{1} was hurt!",user.pbThis))
user.pbReduceHP(user.totalhp / 8, false)
@battle.pbDisplay(_INTL("{1} was hurt!", user.pbThis))
user.pbItemHPHealCheck
end
return false
@@ -391,14 +391,14 @@ class Battle::Battler
target.damageState.protected = true
@battle.successStates[user.index].protected = true
if move.pbContactMove?(user) && user.affectedByContactEffect?
user.pbPoison(target) if user.pbCanPoison?(target,false)
user.pbPoison(target) if user.pbCanPoison?(target, false)
end
return false
end
# Obstruct
if target.effects[PBEffects::Obstruct] && move.damagingMove?
if show_message
@battle.pbCommonAnimation("Obstruct",target)
@battle.pbCommonAnimation("Obstruct", target)
@battle.pbDisplay(_INTL("{1} protected itself!", target.pbThis))
end
target.damageState.protected = true
@@ -468,11 +468,11 @@ class Battle::Battler
@battle.pbDisplay(_INTL("{1}'s {2} makes Ground moves miss!", target.pbThis, target.itemName)) if show_message
return false
end
if target.effects[PBEffects::MagnetRise]>0
if target.effects[PBEffects::MagnetRise] > 0
@battle.pbDisplay(_INTL("{1} makes Ground moves miss with Magnet Rise!", target.pbThis)) if show_message
return false
end
if target.effects[PBEffects::Telekinesis]>0
if target.effects[PBEffects::Telekinesis] > 0
@battle.pbDisplay(_INTL("{1} makes Ground moves miss with Telekinesis!", target.pbThis)) if show_message
return false
end
@@ -505,8 +505,8 @@ class Battle::Battler
end
end
# Substitute
if target.effects[PBEffects::Substitute]>0 && move.statusMove? &&
!move.ignoresSubstitute?(user) && user.index!=target.index
if target.effects[PBEffects::Substitute] > 0 && move.statusMove? &&
!move.ignoresSubstitute?(user) && user.index != target.index
PBDebug.log("[Target immune] #{target.pbThis} is protected by its Substitute")
@battle.pbDisplay(_INTL("{1} avoided the attack!", target.pbThis(true))) if show_message
return false
@@ -518,14 +518,14 @@ class Battle::Battler
# Per-hit success check against the target.
# Includes semi-invulnerable move use and accuracy calculation.
#=============================================================================
def pbSuccessCheckPerHit(move,user,target,skipAccuracyCheck)
def pbSuccessCheckPerHit(move, user, target, skipAccuracyCheck)
# Two-turn attacks can't fail here in the charging turn
return true if user.effects[PBEffects::TwoTurnAttack]
# Lock-On
return true if user.effects[PBEffects::LockOn]>0 &&
user.effects[PBEffects::LockOnPos]==target.index
return true if user.effects[PBEffects::LockOn] > 0 &&
user.effects[PBEffects::LockOnPos] == target.index
# Toxic
return true if move.pbOverrideSuccessCheckPerHit(user,target)
return true if move.pbOverrideSuccessCheckPerHit(user, target)
miss = false
hitsInvul = false
# No Guard
@@ -534,7 +534,7 @@ class Battle::Battler
# Future Sight
hitsInvul = true if @battle.futureSight
# Helping Hand
hitsInvul = true if move.function=="PowerUpAllyMove"
hitsInvul = true if move.function == "PowerUpAllyMove"
if !hitsInvul
# Semi-invulnerable moves
if target.effects[PBEffects::TwoTurnAttack]
@@ -550,8 +550,8 @@ class Battle::Battler
miss = true
end
end
if target.effects[PBEffects::SkyDrop]>=0 &&
target.effects[PBEffects::SkyDrop]!=user.index
if target.effects[PBEffects::SkyDrop] >= 0 &&
target.effects[PBEffects::SkyDrop] != user.index
miss = true if !move.hitsFlyingTargets?
end
end
@@ -560,7 +560,7 @@ class Battle::Battler
# Called by another move
return true if skipAccuracyCheck
# Accuracy check
return true if move.pbAccuracyCheck(user,target) # Includes Counter/Mirror Coat
return true if move.pbAccuracyCheck(user, target) # Includes Counter/Mirror Coat
end
# Missed
PBDebug.log("[Move failed] Failed pbAccuracyCheck or target is semi-invulnerable")
@@ -570,15 +570,15 @@ class Battle::Battler
#=============================================================================
# Message shown when a move fails the per-hit success check above.
#=============================================================================
def pbMissMessage(move,user,target)
def pbMissMessage(move, user, target)
if target.damageState.affection_missed
@battle.pbDisplay(_INTL("{1} avoided the move in time with your shout!", target.pbThis))
elsif move.pbTarget(user).num_targets > 1
@battle.pbDisplay(_INTL("{1} avoided the attack!",target.pbThis))
@battle.pbDisplay(_INTL("{1} avoided the attack!", target.pbThis))
elsif target.effects[PBEffects::TwoTurnAttack]
@battle.pbDisplay(_INTL("{1} avoided the attack!",target.pbThis))
elsif !move.pbMissMessage(user,target)
@battle.pbDisplay(_INTL("{1}'s attack missed!",user.pbThis))
@battle.pbDisplay(_INTL("{1} avoided the attack!", target.pbThis))
elsif !move.pbMissMessage(user, target)
@battle.pbDisplay(_INTL("{1}'s attack missed!", user.pbThis))
end
end
end

View File

@@ -2,13 +2,13 @@ class Battle::Battler
#=============================================================================
# Effect per hit
#=============================================================================
def pbEffectsOnMakingHit(move,user,target)
if target.damageState.calcDamage>0 && !target.damageState.substitute
def pbEffectsOnMakingHit(move, user, target)
if target.damageState.calcDamage > 0 && !target.damageState.substitute
# Target's ability
if target.abilityActive?(true)
oldHP = user.hp
Battle::AbilityEffects.triggerOnBeingHit(target.ability, user, target, move, @battle)
user.pbItemHPHealCheck if user.hp<oldHP
user.pbItemHPHealCheck if user.hp < oldHP
end
# Cramorant - Gulp Missile
if target.isSpecies?(:CRAMORANT) && target.ability == :GULPMISSILE &&
@@ -39,28 +39,28 @@ class Battle::Battler
if target.itemActive?(true)
oldHP = user.hp
Battle::ItemEffects.triggerOnBeingHit(target.item, user, target, move, @battle)
user.pbItemHPHealCheck if user.hp<oldHP
user.pbItemHPHealCheck if user.hp < oldHP
end
end
if target.opposes?(user)
# Rage
if target.effects[PBEffects::Rage] && !target.fainted?
if target.pbCanRaiseStatStage?(:ATTACK,target)
@battle.pbDisplay(_INTL("{1}'s rage is building!",target.pbThis))
target.pbRaiseStatStage(:ATTACK,1,target)
if target.pbCanRaiseStatStage?(:ATTACK, target)
@battle.pbDisplay(_INTL("{1}'s rage is building!", target.pbThis))
target.pbRaiseStatStage(:ATTACK, 1, target)
end
end
# Beak Blast
if target.effects[PBEffects::BeakBlast]
PBDebug.log("[Lingering effect] #{target.pbThis}'s Beak Blast")
if move.pbContactMove?(user) && user.affectedByContactEffect?
target.pbBurn(user) if target.pbCanBurn?(user,false,self)
target.pbBurn(user) if target.pbCanBurn?(user, false, self)
end
end
# Shell Trap (make the trapper move next if the trap was triggered)
if target.effects[PBEffects::ShellTrap] &&
@battle.choices[target.index][0]==:UseMove && !target.movedThisRound?
if target.damageState.hpLost>0 && !target.damageState.substitute && move.physicalMove?
@battle.choices[target.index][0] == :UseMove && !target.movedThisRound?
if target.damageState.hpLost > 0 && !target.damageState.substitute && move.physicalMove?
target.tookPhysicalHit = true
target.effects[PBEffects::MoveNext] = true
target.effects[PBEffects::Quash] = 0
@@ -70,11 +70,11 @@ class Battle::Battler
if target.effects[PBEffects::Grudge] && target.fainted?
move.pp = 0
@battle.pbDisplay(_INTL("{1}'s {2} lost all of its PP due to the grudge!",
user.pbThis,move.name))
user.pbThis, move.name))
end
# Destiny Bond (recording that it should apply)
if target.effects[PBEffects::DestinyBond] && target.fainted?
if user.effects[PBEffects::DestinyBondTarget]<0
if user.effects[PBEffects::DestinyBondTarget] < 0
user.effects[PBEffects::DestinyBondTarget] = target.index
end
end
@@ -84,7 +84,7 @@ class Battle::Battler
#=============================================================================
# Effects after all hits (i.e. at end of move usage)
#=============================================================================
def pbEffectsAfterMove(user,targets,move,numHits)
def pbEffectsAfterMove(user, targets, move, numHits)
# Defrost
if move.damagingMove?
targets.each do |b|
@@ -101,10 +101,10 @@ class Battle::Battler
# NOTE: Although Destiny Bond is similar to Grudge, they don't apply at
# the same time (although Destiny Bond does check whether it's going
# to trigger at the same time as Grudge).
if user.effects[PBEffects::DestinyBondTarget]>=0 && !user.fainted?
if user.effects[PBEffects::DestinyBondTarget] >= 0 && !user.fainted?
dbName = @battle.battlers[user.effects[PBEffects::DestinyBondTarget]].pbThis
@battle.pbDisplay(_INTL("{1} took its attacker down with it!",dbName))
user.pbReduceHP(user.hp,false)
@battle.pbDisplay(_INTL("{1} took its attacker down with it!", dbName))
user.pbReduceHP(user.hp, false)
user.pbItemHPHealCheck
user.pbFaint
@battle.pbJudgeCheckpoint(user)
@@ -117,15 +117,15 @@ class Battle::Battler
if !user.fainted? && !user.effects[PBEffects::Transform] &&
user.isSpecies?(:GRENINJA) && user.ability == :BATTLEBOND
if !@battle.pbAllFainted?(user.idxOpposingSide) &&
!@battle.battleBond[user.index&1][user.pokemonIndex]
!@battle.battleBond[user.index & 1][user.pokemonIndex]
numFainted = 0
targets.each { |b| numFainted += 1 if b.damageState.fainted }
if numFainted>0 && user.form==1
@battle.battleBond[user.index&1][user.pokemonIndex] = true
@battle.pbDisplay(_INTL("{1} became fully charged due to its bond with its Trainer!",user.pbThis))
@battle.pbShowAbilitySplash(user,true)
if numFainted > 0 && user.form == 1
@battle.battleBond[user.index & 1][user.pokemonIndex] = true
@battle.pbDisplay(_INTL("{1} became fully charged due to its bond with its Trainer!", user.pbThis))
@battle.pbShowAbilitySplash(user, true)
@battle.pbHideAbilitySplash(user)
user.pbChangeForm(2,_INTL("{1} became Ash-Greninja!",user.pbThis))
user.pbChangeForm(2, _INTL("{1} became Ash-Greninja!", user.pbThis))
end
end
end
@@ -165,13 +165,13 @@ class Battle::Battler
# U-turn/Volt Switch/Baton Pass/Parting Shot, Relic Song's form changing,
# Fling/Natural Gift consuming item.
if !switched_battlers.include?(user.index)
move.pbEndOfMoveUsageEffect(user,targets,numHits,switched_battlers)
move.pbEndOfMoveUsageEffect(user, targets, numHits, switched_battlers)
end
# User's ability/item that switches the user out (all negated by Sheer Force)
if !(user.hasActiveAbility?(:SHEERFORCE) && move.addlEffect > 0)
pbEffectsAfterMove3(user, targets, move, numHits, switched_battlers)
end
if numHits>0
if numHits > 0
@battle.allBattlers.each { |b| b.pbItemEndOfMoveCheck }
end
end
@@ -180,7 +180,7 @@ class Battle::Battler
def pbEffectsAfterMove2(user, targets, move, numHits, switched_battlers)
# Target's held item (Eject Button, Red Card, Eject Pack)
@battle.pbPriority(true).each do |b|
if targets.any? { |targetB| targetB.index==b.index }
if targets.any? { |targetB| targetB.index == b.index }
if !b.damageState.unaffected && b.damageState.calcDamage > 0 && b.itemActive?
Battle::ItemEffects.triggerAfterMoveUseFromTarget(b.item, b, user, move, switched_battlers, @battle)
end
@@ -198,7 +198,7 @@ class Battle::Battler
end
# Target's ability (Berserk, Color Change, Emergency Exit, Pickpocket, Wimp Out)
@battle.pbPriority(true).each do |b|
if targets.any? { |targetB| targetB.index==b.index }
if targets.any? { |targetB| targetB.index == b.index }
if !b.damageState.unaffected && !switched_battlers.include?(b.index) && b.abilityActive?
Battle::AbilityEffects.triggerAfterMoveUseFromTarget(b.ability, b, user, move, switched_battlers, @battle)
end