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

@@ -92,10 +92,10 @@ class Battle
#=============================================================================
# Creating the battle class
#=============================================================================
def initialize(scene,p1,p2,player,opponent)
if p1.length==0
def initialize(scene, p1, p2, player, opponent)
if p1.length == 0
raise ArgumentError.new(_INTL("Party 1 has no Pokémon."))
elsif p2.length==0
elsif p2.length == 0
raise ArgumentError.new(_INTL("Party 2 has no Pokémon."))
end
@scene = scene
@@ -106,7 +106,7 @@ class Battle
ActiveSide.new] # Foe's side
@positions = [] # Battler positions
@battlers = []
@sideSizes = [1,1] # Single battle, 1v1
@sideSizes = [1, 1] # Single battle, 1v1
@backdrop = ""
@backdropBase = nil
@time = 0
@@ -194,15 +194,15 @@ class Battle
end
def singleBattle?
return pbSideSize(0)==1 && pbSideSize(1)==1
return pbSideSize(0) == 1 && pbSideSize(1) == 1
end
def pbSideSize(index)
return @sideSizes[index%2]
return @sideSizes[index % 2]
end
def maxBattlerIndex
return (pbSideSize(0)>pbSideSize(1)) ? (pbSideSize(0)-1)*2 : pbSideSize(1)*2-1
return (pbSideSize(0) > pbSideSize(1)) ? (pbSideSize(0) - 1) * 2 : pbSideSize(1) * 2 - 1
end
#=============================================================================
@@ -219,11 +219,11 @@ class Battle
return 0 if !trainer
case trainer.length
when 2
n = pbSideSize(idxBattler%2)
return [0,0,1][idxBattler/2] if n==3
return idxBattler/2 # Same as [0,1][idxBattler/2], i.e. 2 battler slots
n = pbSideSize(idxBattler % 2)
return [0, 0, 1][idxBattler / 2] if n == 3
return idxBattler / 2 # Same as [0,1][idxBattler/2], i.e. 2 battler slots
when 3
return idxBattler/2
return idxBattler / 2
end
return 0
end
@@ -234,10 +234,10 @@ class Battle
return (trainer.nil?) ? nil : trainer[idxTrainer]
end
def pbGetOwnerIndexFromPartyIndex(idxBattler,idxParty)
def pbGetOwnerIndexFromPartyIndex(idxBattler, idxParty)
ret = -1
pbPartyStarts(idxBattler).each_with_index do |start,i|
break if start>idxParty
pbPartyStarts(idxBattler).each_with_index do |start, i|
break if start > idxParty
ret = i
end
return ret
@@ -245,8 +245,8 @@ class Battle
# Only used for the purpose of an error message when one trainer tries to
# switch another trainer's Pokémon.
def pbGetOwnerFromPartyIndex(idxBattler,idxParty)
idxTrainer = pbGetOwnerIndexFromPartyIndex(idxBattler,idxParty)
def pbGetOwnerFromPartyIndex(idxBattler, idxParty)
idxTrainer = pbGetOwnerIndexFromPartyIndex(idxBattler, idxParty)
trainer = (opposes?(idxBattler)) ? @opponent : @player
return (trainer.nil?) ? nil : trainer[idxTrainer]
end
@@ -254,7 +254,7 @@ class Battle
def pbGetOwnerName(idxBattler)
idxTrainer = pbGetOwnerIndexFromBattlerIndex(idxBattler)
return @opponent[idxTrainer].full_name if opposes?(idxBattler) # Opponent
return @player[idxTrainer].full_name if idxTrainer>0 # Ally trainer
return @player[idxTrainer].full_name if idxTrainer > 0 # Ally trainer
return @player[idxTrainer].name # Player
end
@@ -266,24 +266,24 @@ class Battle
# Returns whether the battler in position idxBattler is owned by the same
# trainer that owns the Pokémon in party slot idxParty. This assumes that
# both the battler position and the party slot are from the same side.
def pbIsOwner?(idxBattler,idxParty)
def pbIsOwner?(idxBattler, idxParty)
idxTrainer1 = pbGetOwnerIndexFromBattlerIndex(idxBattler)
idxTrainer2 = pbGetOwnerIndexFromPartyIndex(idxBattler,idxParty)
return idxTrainer1==idxTrainer2
idxTrainer2 = pbGetOwnerIndexFromPartyIndex(idxBattler, idxParty)
return idxTrainer1 == idxTrainer2
end
def pbOwnedByPlayer?(idxBattler)
return false if opposes?(idxBattler)
return pbGetOwnerIndexFromBattlerIndex(idxBattler)==0
return pbGetOwnerIndexFromBattlerIndex(idxBattler) == 0
end
# Returns the number of Pokémon positions controlled by the given trainerIndex
# on the given side of battle.
def pbNumPositions(side,idxTrainer)
def pbNumPositions(side, idxTrainer)
ret = 0
for i in 0...pbSideSize(side)
t = pbGetOwnerIndexFromBattlerIndex(i*2+side)
next if t!=idxTrainer
t = pbGetOwnerIndexFromBattlerIndex(i * 2 + side)
next if t != idxTrainer
ret += 1
end
return ret
@@ -314,7 +314,7 @@ class Battle
partyOrders = pbPartyOrder(idxBattler)
idxStart, _idxEnd = pbTeamIndexRangeFromBattlerIndex(idxBattler)
ret = []
eachInTeamFromBattlerIndex(idxBattler) { |pkmn,i| ret[partyOrders[i]-idxStart] = pkmn }
eachInTeamFromBattlerIndex(idxBattler) { |pkmn, i| ret[partyOrders[i] - idxStart] = pkmn }
return ret
end
@@ -329,7 +329,7 @@ class Battle
party = pbParty(idxBattler)
inBattleIndices = allSameSideBattlers(idxBattler).map { |b| b.pokemonIndex }
count = 0
party.each_with_index do |pkmn,idxParty|
party.each_with_index do |pkmn, idxParty|
next if !pkmn || !pkmn.able?
next if inBattleIndices.include?(idxParty)
count += 1
@@ -338,7 +338,7 @@ class Battle
end
def pbAllFainted?(idxBattler = 0)
return pbAbleCount(idxBattler)==0
return pbAbleCount(idxBattler) == 0
end
def pbTeamAbleNonActiveCount(idxBattler = 0)
@@ -360,10 +360,10 @@ class Battle
ret = []
idxTeam = -1
nextStart = 0
party.each_with_index do |pkmn,i|
if i>=nextStart
party.each_with_index do |pkmn, i|
if i >= nextStart
idxTeam += 1
nextStart = (idxTeam<partyStarts.length-1) ? partyStarts[idxTeam+1] : party.length
nextStart = (idxTeam < partyStarts.length - 1) ? partyStarts[idxTeam + 1] : party.length
end
next if !pkmn || !pkmn.able?
ret[idxTeam] = 0 if !ret[idxTeam]
@@ -380,27 +380,27 @@ class Battle
partyStarts = pbPartyStarts(idxBattler)
idxTrainer = pbGetOwnerIndexFromBattlerIndex(idxBattler)
idxPartyStart = partyStarts[idxTrainer]
idxPartyEnd = (idxTrainer<partyStarts.length-1) ? partyStarts[idxTrainer+1] : pbParty(idxBattler).length
idxPartyEnd = (idxTrainer < partyStarts.length - 1) ? partyStarts[idxTrainer + 1] : pbParty(idxBattler).length
return idxPartyStart, idxPartyEnd
end
def pbTeamLengthFromBattlerIndex(idxBattler)
idxPartyStart, idxPartyEnd = pbTeamIndexRangeFromBattlerIndex(idxBattler)
return idxPartyEnd-idxPartyStart
return idxPartyEnd - idxPartyStart
end
def eachInTeamFromBattlerIndex(idxBattler)
party = pbParty(idxBattler)
idxPartyStart, idxPartyEnd = pbTeamIndexRangeFromBattlerIndex(idxBattler)
party.each_with_index { |pkmn,i| yield pkmn,i if pkmn && i>=idxPartyStart && i<idxPartyEnd }
party.each_with_index { |pkmn, i| yield pkmn, i if pkmn && i >= idxPartyStart && i < idxPartyEnd }
end
def eachInTeam(side,idxTrainer)
def eachInTeam(side, idxTrainer)
party = pbParty(side)
partyStarts = pbPartyStarts(side)
idxPartyStart = partyStarts[idxTrainer]
idxPartyEnd = (idxTrainer<partyStarts.length-1) ? partyStarts[idxTrainer+1] : party.length
party.each_with_index { |pkmn,i| yield pkmn,i if pkmn && i>=idxPartyStart && i<idxPartyEnd }
idxPartyEnd = (idxTrainer < partyStarts.length - 1) ? partyStarts[idxTrainer + 1] : party.length
party.each_with_index { |pkmn, i| yield pkmn, i if pkmn && i >= idxPartyStart && i < idxPartyEnd }
end
# Used for Illusion.
@@ -412,8 +412,8 @@ class Battle
partyOrders = pbPartyOrder(idxBattler)
idxPartyStart, idxPartyEnd = pbTeamIndexRangeFromBattlerIndex(idxBattler)
ret = -1
party.each_with_index do |pkmn,i|
next if i<idxPartyStart || i>=idxPartyEnd # Check the team only
party.each_with_index do |pkmn, i|
next if i < idxPartyStart || i >= idxPartyEnd # Check the team only
next if !pkmn || !pkmn.able? # Can't copy a non-fainted Pokémon or egg
ret = i if ret < 0 || partyOrders[i] > partyOrders[ret]
end
@@ -421,10 +421,10 @@ class Battle
end
# Used to calculate money gained/lost after winning/losing a battle.
def pbMaxLevelInTeam(side,idxTrainer)
def pbMaxLevelInTeam(side, idxTrainer)
ret = 1
eachInTeam(side,idxTrainer) do |pkmn,_i|
ret = pkmn.level if pkmn.level>ret
eachInTeam(side, idxTrainer) do |pkmn, _i|
ret = pkmn.level if pkmn.level > ret
end
return ret
end
@@ -481,7 +481,7 @@ class Battle
return nil
end
def pbCheckOpposingAbility(abil,idxBattler = 0,nearOnly = false)
def pbCheckOpposingAbility(abil, idxBattler = 0, nearOnly = false)
allOtherSideBattlers(idxBattler).each do |b|
next if nearOnly && !b.near?(idxBattler)
return b if b.hasActiveAbility?(abil)
@@ -503,31 +503,31 @@ class Battle
return [1]
when 2 # 1v2
return [0] if opposes?(idxBattler)
return [3,1]
return [3, 1]
when 3 # 1v3
return [0] if opposes?(idxBattler)
return [3,5,1]
return [3, 5, 1]
end
when 2
case pbSideSize(1)
when 1 # 2v1
return [0,2] if opposes?(idxBattler)
return [0, 2] if opposes?(idxBattler)
return [1]
when 2 # 2v2 double
return [[3,1],[2,0],[1,3],[0,2]][idxBattler]
return [[3, 1], [2, 0], [1, 3], [0, 2]][idxBattler]
when 3 # 2v3
return [[5,3,1],[2,0],[3,1,5]][idxBattler] if idxBattler<3
return [0,2]
return [[5, 3, 1], [2, 0], [3, 1, 5]][idxBattler] if idxBattler < 3
return [0, 2]
end
when 3
case pbSideSize(1)
when 1 # 3v1
return [2,0,4] if opposes?(idxBattler)
return [2, 0, 4] if opposes?(idxBattler)
return [1]
when 2 # 3v2
return [[3,1],[2,4,0],[3,1],[2,0,4],[1,3]][idxBattler]
return [[3, 1], [2, 4, 0], [3, 1], [2, 0, 4], [1, 3]][idxBattler]
when 3 # 3v3 triple
return [[5,3,1],[4,2,0],[3,5,1],[2,0,4],[1,3,5],[0,2,4]][idxBattler]
return [[5, 3, 1], [4, 2, 0], [3, 5, 1], [2, 0, 4], [1, 3, 5], [0, 2, 4]][idxBattler]
end
end
return [idxBattler]
@@ -536,30 +536,30 @@ class Battle
#=============================================================================
# Comparing the positions of two battlers
#=============================================================================
def opposes?(idxBattler1,idxBattler2 = 0)
def opposes?(idxBattler1, idxBattler2 = 0)
idxBattler1 = idxBattler1.index if idxBattler1.respond_to?("index")
idxBattler2 = idxBattler2.index if idxBattler2.respond_to?("index")
return (idxBattler1&1)!=(idxBattler2&1)
return (idxBattler1 & 1) != (idxBattler2 & 1)
end
def nearBattlers?(idxBattler1,idxBattler2)
return false if idxBattler1==idxBattler2
return true if pbSideSize(0)<=2 && pbSideSize(1)<=2
def nearBattlers?(idxBattler1, idxBattler2)
return false if idxBattler1 == idxBattler2
return true if pbSideSize(0) <= 2 && pbSideSize(1) <= 2
# Get all pairs of battler positions that are not close to each other
pairsArray = [[0,4],[1,5]] # Covers 3v1 and 1v3
pairsArray = [[0, 4], [1, 5]] # Covers 3v1 and 1v3
case pbSideSize(0)
when 3
case pbSideSize(1)
when 3 # 3v3 (triple)
pairsArray.push([0,1])
pairsArray.push([4,5])
pairsArray.push([0, 1])
pairsArray.push([4, 5])
when 2 # 3v2
pairsArray.push([0,1])
pairsArray.push([3,4])
pairsArray.push([0, 1])
pairsArray.push([3, 4])
end
when 2 # 2v3
pairsArray.push([0,1])
pairsArray.push([2,5])
pairsArray.push([0, 1])
pairsArray.push([2, 5])
end
# See if any pair matches the two battlers being assessed
pairsArray.each do |pair|
@@ -571,7 +571,7 @@ class Battle
#=============================================================================
# Altering a party or rearranging battlers
#=============================================================================
def pbRemoveFromParty(idxBattler,idxParty)
def pbRemoveFromParty(idxBattler, idxParty)
party = pbParty(idxBattler)
# Erase the Pokémon from the party
party[idxParty] = nil
@@ -579,27 +579,27 @@ class Battle
# in it (to avoid gaps)
partyOrders = pbPartyOrder(idxBattler)
partyStarts = pbPartyStarts(idxBattler)
idxTrainer = pbGetOwnerIndexFromPartyIndex(idxBattler,idxParty)
idxTrainer = pbGetOwnerIndexFromPartyIndex(idxBattler, idxParty)
idxPartyStart = partyStarts[idxTrainer]
idxPartyEnd = (idxTrainer<partyStarts.length-1) ? partyStarts[idxTrainer+1] : party.length
idxPartyEnd = (idxTrainer < partyStarts.length - 1) ? partyStarts[idxTrainer + 1] : party.length
origPartyPos = partyOrders[idxParty] # Position of erased Pokémon initially
partyOrders[idxParty] = idxPartyEnd # Put erased Pokémon last in the team
party.each_with_index do |_pkmn,i|
next if i<idxPartyStart || i>=idxPartyEnd # Only check the team
next if partyOrders[i]<origPartyPos # Appeared before erased Pokémon
party.each_with_index do |_pkmn, i|
next if i < idxPartyStart || i >= idxPartyEnd # Only check the team
next if partyOrders[i] < origPartyPos # Appeared before erased Pokémon
partyOrders[i] -= 1 # Appeared after erased Pokémon; bump it up by 1
end
end
def pbSwapBattlers(idxA,idxB)
def pbSwapBattlers(idxA, idxB)
return false if !@battlers[idxA] || !@battlers[idxB]
# Can't swap if battlers aren't owned by the same trainer
return false if opposes?(idxA,idxB)
return false if pbGetOwnerIndexFromBattlerIndex(idxA)!=pbGetOwnerIndexFromBattlerIndex(idxB)
return false if opposes?(idxA, idxB)
return false if pbGetOwnerIndexFromBattlerIndex(idxA) != pbGetOwnerIndexFromBattlerIndex(idxB)
@battlers[idxA], @battlers[idxB] = @battlers[idxB], @battlers[idxA]
@battlers[idxA].index, @battlers[idxB].index = @battlers[idxB].index, @battlers[idxA].index
@choices[idxA], @choices[idxB] = @choices[idxB], @choices[idxA]
@scene.pbSwapBattlerSprites(idxA,idxB)
@scene.pbSwapBattlerSprites(idxA, idxB)
# Swap the target of any battlers' effects that point at either of the
# swapped battlers, to ensure they still point at the correct target
# NOTE: LeechSeed is not swapped, because drained HP goes to whichever
@@ -619,8 +619,8 @@ class Battle
PBEffects::TrappingUser]
allBattlers.each do |b|
for i in effectsToSwap
next if b.effects[i]!=idxA && b.effects[i]!=idxB
b.effects[i] = (b.effects[i]==idxA) ? idxB : idxA
next if b.effects[i] != idxA && b.effects[i] != idxB
b.effects[i] = (b.effects[i] == idxA) ? idxB : idxA
end
end
return true
@@ -631,19 +631,19 @@ class Battle
#=============================================================================
# Returns the battler representing the Pokémon at index idxParty in its party,
# on the same side as a battler with battler index of idxBattlerOther.
def pbFindBattler(idxParty,idxBattlerOther = 0)
allSameSideBattlers(idxBattlerOther).each { |b| return b if b.pokemonIndex==idxParty }
def pbFindBattler(idxParty, idxBattlerOther = 0)
allSameSideBattlers(idxBattlerOther).each { |b| return b if b.pokemonIndex == idxParty }
return nil
end
# Only used for Wish, as the Wishing Pokémon will no longer be in battle.
def pbThisEx(idxBattler,idxParty)
def pbThisEx(idxBattler, idxParty)
party = pbParty(idxBattler)
if opposes?(idxBattler)
return _INTL("The opposing {1}",party[idxParty].name) if trainerBattle?
return _INTL("The wild {1}",party[idxParty].name)
return _INTL("The opposing {1}", party[idxParty].name) if trainerBattle?
return _INTL("The wild {1}", party[idxParty].name)
end
return _INTL("The ally {1}",party[idxParty].name) if !pbOwnedByPlayer?(idxBattler)
return _INTL("The ally {1}", party[idxParty].name) if !pbOwnedByPlayer?(idxBattler)
return party[idxParty].name
end
@@ -696,13 +696,13 @@ class Battle
end
# Used for causing weather by a move or by an ability.
def pbStartWeather(user,newWeather,fixedDuration = false,showAnim = true)
return if @field.weather==newWeather
def pbStartWeather(user, newWeather, fixedDuration = false, showAnim = true)
return if @field.weather == newWeather
@field.weather = newWeather
duration = (fixedDuration) ? 5 : -1
if duration>0 && user && user.itemActive?
if duration > 0 && user && user.itemActive?
duration = Battle::ItemEffects.triggerWeatherExtender(user.item,
@field.weather,duration,user,self)
@field.weather, duration, user, self)
end
@field.weatherDuration = duration
weather_data = GameData::BattleWeather.try_get(@field.weather)
@@ -743,11 +743,11 @@ class Battle
pbDisplay("The mysterious air current has dissipated!")
end
end
if @field.weather!=oldWeather
if @field.weather != oldWeather
# Check for form changes caused by the weather changing
allBattlers.each { |b| b.pbCheckFormOnWeatherChange }
# Start up the default weather
pbStartWeather(nil,@field.defaultWeather) if @field.defaultWeather != :None
pbStartWeather(nil, @field.defaultWeather) if @field.defaultWeather != :None
end
end
@@ -774,13 +774,13 @@ class Battle
@field.terrainDuration = -1
end
def pbStartTerrain(user,newTerrain,fixedDuration = true)
return if @field.terrain==newTerrain
def pbStartTerrain(user, newTerrain, fixedDuration = true)
return if @field.terrain == newTerrain
@field.terrain = newTerrain
duration = (fixedDuration) ? 5 : -1
if duration>0 && user && user.itemActive?
if duration > 0 && user && user.itemActive?
duration = Battle::ItemEffects.triggerTerrainExtender(user.item,
newTerrain,duration,user,self)
newTerrain, duration, user, self)
end
@field.terrainDuration = duration
terrain_data = GameData::BattleTerrain.try_get(@field.terrain)
@@ -804,35 +804,35 @@ class Battle
#=============================================================================
# Messages and animations
#=============================================================================
def pbDisplay(msg,&block)
@scene.pbDisplayMessage(msg,&block)
def pbDisplay(msg, &block)
@scene.pbDisplayMessage(msg, &block)
end
def pbDisplayBrief(msg)
@scene.pbDisplayMessage(msg,true)
@scene.pbDisplayMessage(msg, true)
end
def pbDisplayPaused(msg,&block)
@scene.pbDisplayPausedMessage(msg,&block)
def pbDisplayPaused(msg, &block)
@scene.pbDisplayPausedMessage(msg, &block)
end
def pbDisplayConfirm(msg)
return @scene.pbDisplayConfirmMessage(msg)
end
def pbShowCommands(msg,commands,canCancel = true)
@scene.pbShowCommands(msg,commands,canCancel)
def pbShowCommands(msg, commands, canCancel = true)
@scene.pbShowCommands(msg, commands, canCancel)
end
def pbAnimation(move,user,targets,hitNum = 0)
@scene.pbAnimation(move,user,targets,hitNum) if @showAnims
def pbAnimation(move, user, targets, hitNum = 0)
@scene.pbAnimation(move, user, targets, hitNum) if @showAnims
end
def pbCommonAnimation(name,user = nil,targets = nil)
@scene.pbCommonAnimation(name,user,targets) if @showAnims
def pbCommonAnimation(name, user = nil, targets = nil)
@scene.pbCommonAnimation(name, user, targets) if @showAnims
end
def pbShowAbilitySplash(battler,delay = false,logTrigger = true)
def pbShowAbilitySplash(battler, delay = false, logTrigger = true)
PBDebug.log("[Ability triggered] #{battler.pbThis}'s #{battler.abilityName}") if logTrigger
return if !Scene::USE_ABILITY_SPLASH
@scene.pbShowAbilitySplash(battler)

View File

@@ -22,18 +22,18 @@ class Battle
# trainer, it's possible that battlers will be unable to move close
# enough to hit each other if there are multiple trainers on each
# side.
if trainerBattle? && (@sideSizes[0]>2 || @sideSizes[1]>2) &&
@player.length>1 && @opponent.length>1
if trainerBattle? && (@sideSizes[0] > 2 || @sideSizes[1] > 2) &&
@player.length > 1 && @opponent.length > 1
raise _INTL("Can't have battles larger than 2v2 where both sides have multiple trainers")
end
# Find out how many Pokémon each trainer has
side1counts = pbAbleTeamCounts(0)
side2counts = pbAbleTeamCounts(1)
# Change the size of the battle depending on how many wild Pokémon there are
if wildBattle? && side2counts[0]!=@sideSizes[1]
if @sideSizes[0]==@sideSizes[1]
if wildBattle? && side2counts[0] != @sideSizes[1]
if @sideSizes[0] == @sideSizes[1]
# Even number of battlers per side, change both equally
@sideSizes = [side2counts[0],side2counts[0]]
@sideSizes = [side2counts[0], side2counts[0]]
else
# Uneven number of battlers per side, just change wild side's size
@sideSizes[1] = side2counts[0]
@@ -44,31 +44,31 @@ class Battle
loop do
needsChanging = false
for side in 0...2 # Each side in turn
next if side==1 && wildBattle? # Wild side's size already checked above
sideCounts = (side==0) ? side1counts : side2counts
next if side == 1 && wildBattle? # Wild side's size already checked above
sideCounts = (side == 0) ? side1counts : side2counts
requireds = []
# Find out how many Pokémon each trainer on side needs to have
for i in 0...@sideSizes[side]
idxTrainer = pbGetOwnerIndexFromBattlerIndex(i*2+side)
idxTrainer = pbGetOwnerIndexFromBattlerIndex(i * 2 + side)
requireds[idxTrainer] = 0 if requireds[idxTrainer].nil?
requireds[idxTrainer] += 1
end
# Compare the have values with the need values
if requireds.length>sideCounts.length
if requireds.length > sideCounts.length
raise _INTL("Error: def pbGetOwnerIndexFromBattlerIndex gives invalid owner index ({1} for battle type {2}v{3}, trainers {4}v{5})",
requireds.length-1,@sideSizes[0],@sideSizes[1],side1counts.length,side2counts.length)
requireds.length - 1, @sideSizes[0], @sideSizes[1], side1counts.length, side2counts.length)
end
sideCounts.each_with_index do |_count,i|
if !requireds[i] || requireds[i]==0
sideCounts.each_with_index do |_count, i|
if !requireds[i] || requireds[i] == 0
raise _INTL("Player-side trainer {1} has no battler position for their Pokémon to go (trying {2}v{3} battle)",
i+1,@sideSizes[0],@sideSizes[1]) if side==0
i + 1, @sideSizes[0], @sideSizes[1]) if side == 0
raise _INTL("Opposing trainer {1} has no battler position for their Pokémon to go (trying {2}v{3} battle)",
i+1,@sideSizes[0],@sideSizes[1]) if side==1
i + 1, @sideSizes[0], @sideSizes[1]) if side == 1
end
next if requireds[i]<=sideCounts[i] # Trainer has enough Pokémon to fill their positions
if requireds[i]==1
raise _INTL("Player-side trainer {1} has no able Pokémon",i+1) if side==0
raise _INTL("Opposing trainer {1} has no able Pokémon",i+1) if side==1
next if requireds[i] <= sideCounts[i] # Trainer has enough Pokémon to fill their positions
if requireds[i] == 1
raise _INTL("Player-side trainer {1} has no able Pokémon", i + 1) if side == 0
raise _INTL("Opposing trainer {1} has no able Pokémon", i + 1) if side == 1
end
# Not enough Pokémon, try lowering the number of battler positions
needsChanging = true
@@ -81,18 +81,18 @@ class Battle
if wildBattle?
PBDebug.log("#{@sideSizes[0]}v#{@sideSizes[1]} battle isn't possible " +
"(#{side1counts} player-side teams versus #{side2counts[0]} wild Pokémon)")
newSize = @sideSizes[0]-1
newSize = @sideSizes[0] - 1
else
PBDebug.log("#{@sideSizes[0]}v#{@sideSizes[1]} battle isn't possible " +
"(#{side1counts} player-side teams versus #{side2counts} opposing teams)")
newSize = @sideSizes.max-1
newSize = @sideSizes.max - 1
end
if newSize==0
if newSize == 0
raise _INTL("Couldn't lower either side's size any further, battle isn't possible")
end
for side in 0...2
next if side==1 && wildBattle? # Wild Pokémon's side size is fixed
next if @sideSizes[side]==1 || newSize>@sideSizes[side]
next if side == 1 && wildBattle? # Wild Pokémon's side size is fixed
next if @sideSizes[side] == 1 || newSize > @sideSizes[side]
@sideSizes[side] = newSize
end
PBDebug.log("Trying #{@sideSizes[0]}v#{@sideSizes[1]} battle instead")
@@ -102,52 +102,52 @@ class Battle
#=============================================================================
# Set up all battlers
#=============================================================================
def pbCreateBattler(idxBattler,pkmn,idxParty)
def pbCreateBattler(idxBattler, pkmn, idxParty)
if !@battlers[idxBattler].nil?
raise _INTL("Battler index {1} already exists",idxBattler)
raise _INTL("Battler index {1} already exists", idxBattler)
end
@battlers[idxBattler] = Battler.new(self,idxBattler)
@battlers[idxBattler] = Battler.new(self, idxBattler)
@positions[idxBattler] = ActivePosition.new
pbClearChoice(idxBattler)
@successStates[idxBattler] = SuccessState.new
@battlers[idxBattler].pbInitialize(pkmn,idxParty)
@battlers[idxBattler].pbInitialize(pkmn, idxParty)
end
def pbSetUpSides
ret = [[],[]]
ret = [[], []]
for side in 0...2
# Set up wild Pokémon
if side==1 && wildBattle?
pbParty(1).each_with_index do |pkmn,idxPkmn|
pbCreateBattler(2*idxPkmn+side,pkmn,idxPkmn)
if side == 1 && wildBattle?
pbParty(1).each_with_index do |pkmn, idxPkmn|
pbCreateBattler(2 * idxPkmn + side, pkmn, idxPkmn)
# Changes the Pokémon's form upon entering battle (if it should)
@peer.pbOnEnteringBattle(self, @battlers[2 * idxPkmn + side], pkmn, true)
pbSetSeen(@battlers[2*idxPkmn+side])
pbSetSeen(@battlers[2 * idxPkmn + side])
@usedInBattle[side][idxPkmn] = true
end
next
end
# Set up player's Pokémon and trainers' Pokémon
trainer = (side==0) ? @player : @opponent
trainer = (side == 0) ? @player : @opponent
requireds = []
# Find out how many Pokémon each trainer on side needs to have
for i in 0...@sideSizes[side]
idxTrainer = pbGetOwnerIndexFromBattlerIndex(i*2+side)
idxTrainer = pbGetOwnerIndexFromBattlerIndex(i * 2 + side)
requireds[idxTrainer] = 0 if requireds[idxTrainer].nil?
requireds[idxTrainer] += 1
end
# For each trainer in turn, find the needed number of Pokémon for them to
# send out, and initialize them
battlerNumber = 0
trainer.each_with_index do |_t,idxTrainer|
trainer.each_with_index do |_t, idxTrainer|
ret[side][idxTrainer] = []
eachInTeam(side,idxTrainer) do |pkmn,idxPkmn|
eachInTeam(side, idxTrainer) do |pkmn, idxPkmn|
next if !pkmn.able?
idxBattler = 2*battlerNumber+side
pbCreateBattler(idxBattler,pkmn,idxPkmn)
idxBattler = 2 * battlerNumber + side
pbCreateBattler(idxBattler, pkmn, idxPkmn)
ret[side][idxTrainer].push(idxBattler)
battlerNumber += 1
break if ret[side][idxTrainer].length>=requireds[idxTrainer]
break if ret[side][idxTrainer].length >= requireds[idxTrainer]
end
end
end
@@ -163,71 +163,71 @@ class Battle
foeParty = pbParty(1)
case foeParty.length
when 1
pbDisplayPaused(_INTL("Oh! A wild {1} appeared!",foeParty[0].name))
pbDisplayPaused(_INTL("Oh! A wild {1} appeared!", foeParty[0].name))
when 2
pbDisplayPaused(_INTL("Oh! A wild {1} and {2} appeared!",foeParty[0].name,
pbDisplayPaused(_INTL("Oh! A wild {1} and {2} appeared!", foeParty[0].name,
foeParty[1].name))
when 3
pbDisplayPaused(_INTL("Oh! A wild {1}, {2} and {3} appeared!",foeParty[0].name,
foeParty[1].name,foeParty[2].name))
pbDisplayPaused(_INTL("Oh! A wild {1}, {2} and {3} appeared!", foeParty[0].name,
foeParty[1].name, foeParty[2].name))
end
else # Trainer battle
case @opponent.length
when 1
pbDisplayPaused(_INTL("You are challenged by {1}!",@opponent[0].full_name))
pbDisplayPaused(_INTL("You are challenged by {1}!", @opponent[0].full_name))
when 2
pbDisplayPaused(_INTL("You are challenged by {1} and {2}!",@opponent[0].full_name,
pbDisplayPaused(_INTL("You are challenged by {1} and {2}!", @opponent[0].full_name,
@opponent[1].full_name))
when 3
pbDisplayPaused(_INTL("You are challenged by {1}, {2} and {3}!",
@opponent[0].full_name,@opponent[1].full_name,@opponent[2].full_name))
@opponent[0].full_name, @opponent[1].full_name, @opponent[2].full_name))
end
end
# Send out Pokémon (opposing trainers first)
for side in [1,0]
next if side==1 && wildBattle?
for side in [1, 0]
next if side == 1 && wildBattle?
msg = ""
toSendOut = []
trainers = (side==0) ? @player : @opponent
trainers = (side == 0) ? @player : @opponent
# Opposing trainers and partner trainers's messages about sending out Pokémon
trainers.each_with_index do |t,i|
next if side==0 && i==0 # The player's message is shown last
msg += "\r\n" if msg.length>0
trainers.each_with_index do |t, i|
next if side == 0 && i == 0 # The player's message is shown last
msg += "\r\n" if msg.length > 0
sent = sendOuts[side][i]
case sent.length
when 1
msg += _INTL("{1} sent out {2}!",t.full_name,@battlers[sent[0]].name)
msg += _INTL("{1} sent out {2}!", t.full_name, @battlers[sent[0]].name)
when 2
msg += _INTL("{1} sent out {2} and {3}!",t.full_name,
@battlers[sent[0]].name,@battlers[sent[1]].name)
msg += _INTL("{1} sent out {2} and {3}!", t.full_name,
@battlers[sent[0]].name, @battlers[sent[1]].name)
when 3
msg += _INTL("{1} sent out {2}, {3} and {4}!",t.full_name,
@battlers[sent[0]].name,@battlers[sent[1]].name,@battlers[sent[2]].name)
msg += _INTL("{1} sent out {2}, {3} and {4}!", t.full_name,
@battlers[sent[0]].name, @battlers[sent[1]].name, @battlers[sent[2]].name)
end
toSendOut.concat(sent)
end
# The player's message about sending out Pokémon
if side==0
msg += "\r\n" if msg.length>0
if side == 0
msg += "\r\n" if msg.length > 0
sent = sendOuts[side][0]
case sent.length
when 1
msg += _INTL("Go! {1}!",@battlers[sent[0]].name)
msg += _INTL("Go! {1}!", @battlers[sent[0]].name)
when 2
msg += _INTL("Go! {1} and {2}!",@battlers[sent[0]].name,@battlers[sent[1]].name)
msg += _INTL("Go! {1} and {2}!", @battlers[sent[0]].name, @battlers[sent[1]].name)
when 3
msg += _INTL("Go! {1}, {2} and {3}!",@battlers[sent[0]].name,
@battlers[sent[1]].name,@battlers[sent[2]].name)
msg += _INTL("Go! {1}, {2} and {3}!", @battlers[sent[0]].name,
@battlers[sent[1]].name, @battlers[sent[2]].name)
end
toSendOut.concat(sent)
end
pbDisplayBrief(msg) if msg.length>0
pbDisplayBrief(msg) if msg.length > 0
# The actual sending out of Pokémon
animSendOuts = []
toSendOut.each do |idxBattler|
animSendOuts.push([idxBattler,@battlers[idxBattler].pokemon])
animSendOuts.push([idxBattler, @battlers[idxBattler].pokemon])
end
pbSendOut(animSendOuts,true)
pbSendOut(animSendOuts, true)
end
end
@@ -238,11 +238,11 @@ class Battle
PBDebug.log("")
PBDebug.log("******************************************")
logMsg = "[Started battle] "
if @sideSizes[0]==1 && @sideSizes[1]==1
if @sideSizes[0] == 1 && @sideSizes[1] == 1
logMsg += "Single "
elsif @sideSizes[0]==2 && @sideSizes[1]==2
elsif @sideSizes[0] == 2 && @sideSizes[1] == 2
logMsg += "Double "
elsif @sideSizes[0]==3 && @sideSizes[1]==3
elsif @sideSizes[0] == 3 && @sideSizes[1] == 3
logMsg += "Triple "
else
logMsg += "#{@sideSizes[0]}v#{@sideSizes[1]} "
@@ -309,8 +309,8 @@ class Battle
@turnCount = 0
loop do # Now begin the battle loop
PBDebug.log("")
PBDebug.log("***Round #{@turnCount+1}***")
if @debug && @turnCount>=100
PBDebug.log("***Round #{@turnCount + 1}***")
if @debug && @turnCount >= 100
@decision = pbDecisionOnTime
PBDebug.log("")
PBDebug.log("***Undecided after 100 rounds, aborting***")
@@ -320,13 +320,13 @@ class Battle
PBDebug.log("")
# Command phase
PBDebug.logonerr { pbCommandPhase }
break if @decision>0
break if @decision > 0
# Attack phase
PBDebug.logonerr { pbAttackPhase }
break if @decision>0
break if @decision > 0
# End of round phase
PBDebug.logonerr { pbEndOfRoundPhase }
break if @decision>0
break if @decision > 0
@turnCount += 1
end
pbEndOfBattle
@@ -340,29 +340,29 @@ class Battle
# Money rewarded from opposing trainers
if trainerBattle?
tMoney = 0
@opponent.each_with_index do |t,i|
@opponent.each_with_index do |t, i|
tMoney += pbMaxLevelInTeam(1, i) * t.base_money
end
tMoney *= 2 if @field.effects[PBEffects::AmuletCoin]
tMoney *= 2 if @field.effects[PBEffects::HappyHour]
oldMoney = pbPlayer.money
pbPlayer.money += tMoney
moneyGained = pbPlayer.money-oldMoney
if moneyGained>0
moneyGained = pbPlayer.money - oldMoney
if moneyGained > 0
$stats.battle_money_gained += moneyGained
pbDisplayPaused(_INTL("You got ${1} for winning!",moneyGained.to_s_formatted))
pbDisplayPaused(_INTL("You got ${1} for winning!", moneyGained.to_s_formatted))
end
end
# Pick up money scattered by Pay Day
if @field.effects[PBEffects::PayDay]>0
if @field.effects[PBEffects::PayDay] > 0
@field.effects[PBEffects::PayDay] *= 2 if @field.effects[PBEffects::AmuletCoin]
@field.effects[PBEffects::PayDay] *= 2 if @field.effects[PBEffects::HappyHour]
oldMoney = pbPlayer.money
pbPlayer.money += @field.effects[PBEffects::PayDay]
moneyGained = pbPlayer.money-oldMoney
if moneyGained>0
moneyGained = pbPlayer.money - oldMoney
if moneyGained > 0
$stats.battle_money_gained += moneyGained
pbDisplayPaused(_INTL("You picked up ${1}!",moneyGained.to_s_formatted))
pbDisplayPaused(_INTL("You picked up ${1}!", moneyGained.to_s_formatted))
end
end
end
@@ -370,27 +370,27 @@ class Battle
def pbLoseMoney
return if !@internalBattle || !@moneyGain
return if $game_switches[Settings::NO_MONEY_LOSS]
maxLevel = pbMaxLevelInTeam(0,0) # Player's Pokémon only, not partner's
multiplier = [8,16,24,36,48,64,80,100,120]
maxLevel = pbMaxLevelInTeam(0, 0) # Player's Pokémon only, not partner's
multiplier = [8, 16, 24, 36, 48, 64, 80, 100, 120]
idxMultiplier = [pbPlayer.badge_count, multiplier.length - 1].min
tMoney = maxLevel*multiplier[idxMultiplier]
tMoney = pbPlayer.money if tMoney>pbPlayer.money
tMoney = maxLevel * multiplier[idxMultiplier]
tMoney = pbPlayer.money if tMoney > pbPlayer.money
oldMoney = pbPlayer.money
pbPlayer.money -= tMoney
moneyLost = oldMoney-pbPlayer.money
if moneyLost>0
moneyLost = oldMoney - pbPlayer.money
if moneyLost > 0
$stats.battle_money_lost += moneyLost
if trainerBattle?
pbDisplayPaused(_INTL("You gave ${1} to the winner...",moneyLost.to_s_formatted))
pbDisplayPaused(_INTL("You gave ${1} to the winner...", moneyLost.to_s_formatted))
else
pbDisplayPaused(_INTL("You panicked and dropped ${1}...",moneyLost.to_s_formatted))
pbDisplayPaused(_INTL("You panicked and dropped ${1}...", moneyLost.to_s_formatted))
end
end
end
def pbEndOfBattle
oldDecision = @decision
@decision = 4 if @decision==1 && wildBattle? && @caughtPokemon.length>0
@decision = 4 if @decision == 1 && wildBattle? && @caughtPokemon.length > 0
case oldDecision
##### WIN #####
when 1
@@ -400,52 +400,52 @@ class Battle
@scene.pbTrainerBattleSuccess
case @opponent.length
when 1
pbDisplayPaused(_INTL("You defeated {1}!",@opponent[0].full_name))
pbDisplayPaused(_INTL("You defeated {1}!", @opponent[0].full_name))
when 2
pbDisplayPaused(_INTL("You defeated {1} and {2}!",@opponent[0].full_name,
pbDisplayPaused(_INTL("You defeated {1} and {2}!", @opponent[0].full_name,
@opponent[1].full_name))
when 3
pbDisplayPaused(_INTL("You defeated {1}, {2} and {3}!",@opponent[0].full_name,
@opponent[1].full_name,@opponent[2].full_name))
pbDisplayPaused(_INTL("You defeated {1}, {2} and {3}!", @opponent[0].full_name,
@opponent[1].full_name, @opponent[2].full_name))
end
@opponent.each_with_index do |_t,i|
@opponent.each_with_index do |_t, i|
@scene.pbShowOpponent(i)
msg = (@endSpeeches[i] && @endSpeeches[i]!="") ? @endSpeeches[i] : "..."
pbDisplayPaused(msg.gsub(/\\[Pp][Nn]/,pbPlayer.name))
msg = (@endSpeeches[i] && @endSpeeches[i] != "") ? @endSpeeches[i] : "..."
pbDisplayPaused(msg.gsub(/\\[Pp][Nn]/, pbPlayer.name))
end
end
# Gain money from winning a trainer battle, and from Pay Day
pbGainMoney if @decision!=4
pbGainMoney if @decision != 4
# Hide remaining trainer
@scene.pbShowOpponent(@opponent.length) if trainerBattle? && @caughtPokemon.length>0
@scene.pbShowOpponent(@opponent.length) if trainerBattle? && @caughtPokemon.length > 0
##### LOSE, DRAW #####
when 2, 5
PBDebug.log("")
PBDebug.log("***Player lost***") if @decision==2
PBDebug.log("***Player drew with opponent***") if @decision==5
PBDebug.log("***Player lost***") if @decision == 2
PBDebug.log("***Player drew with opponent***") if @decision == 5
if @internalBattle
pbDisplayPaused(_INTL("You have no more Pokémon that can fight!"))
if trainerBattle?
case @opponent.length
when 1
pbDisplayPaused(_INTL("You lost against {1}!",@opponent[0].full_name))
pbDisplayPaused(_INTL("You lost against {1}!", @opponent[0].full_name))
when 2
pbDisplayPaused(_INTL("You lost against {1} and {2}!",
@opponent[0].full_name,@opponent[1].full_name))
@opponent[0].full_name, @opponent[1].full_name))
when 3
pbDisplayPaused(_INTL("You lost against {1}, {2} and {3}!",
@opponent[0].full_name,@opponent[1].full_name,@opponent[2].full_name))
@opponent[0].full_name, @opponent[1].full_name, @opponent[2].full_name))
end
end
# Lose money from losing a battle
pbLoseMoney
pbDisplayPaused(_INTL("You blacked out!")) if !@canLose
elsif @decision==2
elsif @decision == 2
if @opponent
@opponent.each_with_index do |_t,i|
@opponent.each_with_index do |_t, i|
@scene.pbShowOpponent(i)
msg = (@endSpeechesWin[i] && @endSpeechesWin[i]!="") ? @endSpeechesWin[i] : "..."
pbDisplayPaused(msg.gsub(/\\[Pp][Nn]/,pbPlayer.name))
msg = (@endSpeechesWin[i] && @endSpeechesWin[i] != "") ? @endSpeechesWin[i] : "..."
pbDisplayPaused(msg.gsub(/\\[Pp][Nn]/, pbPlayer.name))
end
end
end
@@ -456,12 +456,12 @@ class Battle
# Register captured Pokémon in the Pokédex, and store them
pbRecordAndStoreCaughtPokemon
# Collect Pay Day money in a wild battle that ended in a capture
pbGainMoney if @decision==4
pbGainMoney if @decision == 4
# Pass on Pokérus within the party
if @internalBattle
infected = []
$player.party.each_with_index do |pkmn,i|
infected.push(i) if pkmn.pokerusStage==1
$player.party.each_with_index do |pkmn, i|
infected.push(i) if pkmn.pokerusStage == 1
end
infected.each do |idxParty|
strain = $player.party[idxParty].pokerusStrain
@@ -480,9 +480,9 @@ class Battle
pbCancelChoice(b.index) # Restore unused items to Bag
Battle::AbilityEffects.triggerOnSwitchOut(b.ability, b, true) if b.abilityActive?
end
pbParty(0).each_with_index do |pkmn,i|
pbParty(0).each_with_index do |pkmn, i|
next if !pkmn
@peer.pbOnLeavingBattle(self,pkmn,@usedInBattle[0][i],true) # Reset form
@peer.pbOnLeavingBattle(self, pkmn, @usedInBattle[0][i], true) # Reset form
pkmn.item = @initialItems[0][i]
end
return @decision
@@ -491,11 +491,11 @@ class Battle
#=============================================================================
# Judging
#=============================================================================
def pbJudgeCheckpoint(user,move = nil); end
def pbJudgeCheckpoint(user, move = nil); end
def pbDecisionOnTime
counts = [0,0]
hpTotals = [0,0]
counts = [0, 0]
hpTotals = [0, 0]
for side in 0...2
pbParty(side).each do |pkmn|
next if !pkmn || !pkmn.able?
@@ -503,29 +503,29 @@ class Battle
hpTotals[side] += pkmn.hp
end
end
return 1 if counts[0]>counts[1] # Win (player has more able Pokémon)
return 2 if counts[0]<counts[1] # Loss (foe has more able Pokémon)
return 1 if hpTotals[0]>hpTotals[1] # Win (player has more HP in total)
return 2 if hpTotals[0]<hpTotals[1] # Loss (foe has more HP in total)
return 1 if counts[0] > counts[1] # Win (player has more able Pokémon)
return 2 if counts[0] < counts[1] # Loss (foe has more able Pokémon)
return 1 if hpTotals[0] > hpTotals[1] # Win (player has more HP in total)
return 2 if hpTotals[0] < hpTotals[1] # Loss (foe has more HP in total)
return 5 # Draw
end
# Unused
def pbDecisionOnTime2
counts = [0,0]
hpTotals = [0,0]
counts = [0, 0]
hpTotals = [0, 0]
for side in 0...2
pbParty(side).each do |pkmn|
next if !pkmn || !pkmn.able?
counts[side] += 1
hpTotals[side] += 100*pkmn.hp/pkmn.totalhp
hpTotals[side] += 100 * pkmn.hp / pkmn.totalhp
end
hpTotals[side] /= counts[side] if counts[side]>1
hpTotals[side] /= counts[side] if counts[side] > 1
end
return 1 if counts[0]>counts[1] # Win (player has more able Pokémon)
return 2 if counts[0]<counts[1] # Loss (foe has more able Pokémon)
return 1 if hpTotals[0]>hpTotals[1] # Win (player has a bigger average HP %)
return 2 if hpTotals[0]<hpTotals[1] # Loss (foe has a bigger average HP %)
return 1 if counts[0] > counts[1] # Win (player has more able Pokémon)
return 2 if counts[0] < counts[1] # Loss (foe has more able Pokémon)
return 1 if hpTotals[0] > hpTotals[1] # Win (player has a bigger average HP %)
return 2 if hpTotals[0] < hpTotals[1] # Loss (foe has a bigger average HP %)
return 5 # Draw
end

View File

@@ -12,42 +12,42 @@ class Battle
p1 = pbParty(0)
@battlers.each do |b|
next unless b && b.opposes? # Can only gain Exp from fainted foes
next if b.participants.length==0
next if b.participants.length == 0
next unless b.fainted? || b.captured
# Count the number of participants
numPartic = 0
b.participants.each do |partic|
next unless p1[partic] && p1[partic].able? && pbIsOwner?(0,partic)
next unless p1[partic] && p1[partic].able? && pbIsOwner?(0, partic)
numPartic += 1
end
# Find which Pokémon have an Exp Share
expShare = []
if !expAll
eachInTeam(0,0) do |pkmn,i|
eachInTeam(0, 0) do |pkmn, i|
next if !pkmn.able?
next if !pkmn.hasItem?(:EXPSHARE) && GameData::Item.try_get(@initialItems[0][i]) != :EXPSHARE
expShare.push(i)
end
end
# Calculate EV and Exp gains for the participants
if numPartic>0 || expShare.length>0 || expAll
if numPartic > 0 || expShare.length > 0 || expAll
# Gain EVs and Exp for participants
eachInTeam(0,0) do |pkmn,i|
eachInTeam(0, 0) do |pkmn, i|
next if !pkmn.able?
next unless b.participants.include?(i) || expShare.include?(i)
pbGainEVsOne(i,b)
pbGainExpOne(i,b,numPartic,expShare,expAll)
pbGainEVsOne(i, b)
pbGainExpOne(i, b, numPartic, expShare, expAll)
end
# Gain EVs and Exp for all other Pokémon because of Exp All
if expAll
showMessage = true
eachInTeam(0,0) do |pkmn,i|
eachInTeam(0, 0) do |pkmn, i|
next if !pkmn.able?
next if b.participants.include?(i) || expShare.include?(i)
pbDisplayPaused(_INTL("Your party Pokémon in waiting also got Exp. Points!")) if showMessage
showMessage = false
pbGainEVsOne(i,b)
pbGainExpOne(i,b,numPartic,expShare,expAll,false)
pbGainEVsOne(i, b)
pbGainExpOne(i, b, numPartic, expShare, expAll, false)
end
end
end
@@ -56,7 +56,7 @@ class Battle
end
end
def pbGainEVsOne(idxParty,defeatedBattler)
def pbGainEVsOne(idxParty, defeatedBattler)
pkmn = pbParty(0)[idxParty] # The Pokémon gaining EVs from defeatedBattler
evYield = defeatedBattler.pokemon.evYield
# Num of effort points pkmn already has
@@ -67,7 +67,7 @@ class Battle
Battle::ItemEffects.triggerEVGainModifier(@initialItems[0][idxParty], pkmn, evYield)
end
# Double EV gain because of Pokérus
if pkmn.pokerusStage>=1 # Infected or cured
if pkmn.pokerusStage >= 1 # Infected or cured
evYield.each_key { |stat| evYield[stat] *= 2 }
end
# Gain EVs for each stat in turn
@@ -89,11 +89,11 @@ class Battle
end
end
def pbGainExpOne(idxParty,defeatedBattler,numPartic,expShare,expAll,showMessages = true)
def pbGainExpOne(idxParty, defeatedBattler, numPartic, expShare, expAll, showMessages = true)
pkmn = pbParty(0)[idxParty] # The Pokémon gaining Exp from defeatedBattler
growth_rate = pkmn.growth_rate
# Don't bother calculating if gainer is already at max Exp
if pkmn.exp>=growth_rate.maximum_exp
if pkmn.exp >= growth_rate.maximum_exp
pkmn.calc_stats # To ensure new EVs still have an effect
return
end
@@ -102,30 +102,30 @@ class Battle
level = defeatedBattler.level
# Main Exp calculation
exp = 0
a = level*defeatedBattler.pokemon.base_exp
if expShare.length>0 && (isPartic || hasExpShare)
if numPartic==0 # No participants, all Exp goes to Exp Share holders
a = level * defeatedBattler.pokemon.base_exp
if expShare.length > 0 && (isPartic || hasExpShare)
if numPartic == 0 # No participants, all Exp goes to Exp Share holders
exp = a / (Settings::SPLIT_EXP_BETWEEN_GAINERS ? expShare.length : 1)
elsif Settings::SPLIT_EXP_BETWEEN_GAINERS # Gain from participating and/or Exp Share
exp = a/(2*numPartic) if isPartic
exp += a/(2*expShare.length) if hasExpShare
exp = a / (2 * numPartic) if isPartic
exp += a / (2 * expShare.length) if hasExpShare
else # Gain from participating and/or Exp Share (Exp not split)
exp = (isPartic) ? a : a/2
exp = (isPartic) ? a : a / 2
end
elsif isPartic # Participated in battle, no Exp Shares held by anyone
exp = a / (Settings::SPLIT_EXP_BETWEEN_GAINERS ? numPartic : 1)
elsif expAll # Didn't participate in battle, gaining Exp due to Exp All
# NOTE: Exp All works like the Exp Share from Gen 6+, not like the Exp All
# from Gen 1, i.e. Exp isn't split between all Pokémon gaining it.
exp = a/2
exp = a / 2
end
return if exp<=0
return if exp <= 0
# Pokémon gain more Exp from trainer battles
exp = (exp*1.5).floor if trainerBattle?
exp = (exp * 1.5).floor if trainerBattle?
# Scale the gained Exp based on the gainer's level (or not)
if Settings::SCALED_EXP_FORMULA
exp /= 5
levelAdjust = (2*level+10.0)/(pkmn.level+level+10.0)
levelAdjust = (2 * level + 10.0) / (pkmn.level + level + 10.0)
levelAdjust = levelAdjust**5
levelAdjust = Math.sqrt(levelAdjust)
exp *= levelAdjust
@@ -139,19 +139,19 @@ class Battle
(pkmn.owner.language != 0 && pkmn.owner.language != pbPlayer.language))
if isOutsider
if pkmn.owner.language != 0 && pkmn.owner.language != pbPlayer.language
exp = (exp*1.7).floor
exp = (exp * 1.7).floor
else
exp = (exp*1.5).floor
exp = (exp * 1.5).floor
end
end
# Exp. Charm increases Exp gained
exp = exp * 3 / 2 if $bag.has?(:EXPCHARM)
# Modify Exp gain based on pkmn's held item
i = Battle::ItemEffects.triggerExpGainModifier(pkmn.item, pkmn, exp)
if i<0
if i < 0
i = Battle::ItemEffects.triggerExpGainModifier(@initialItems[0][idxParty], pkmn, exp)
end
exp = i if i>=0
exp = i if i >= 0
# Boost Exp gained with high affection
if Settings::AFFECTION_EFFECTS && @internalBattle && pkmn.affection_level >= 4 && !pkmn.mega?
exp = exp * 6 / 5
@@ -159,22 +159,22 @@ class Battle
end
# Make sure Exp doesn't exceed the maximum
expFinal = growth_rate.add_exp(pkmn.exp, exp)
expGained = expFinal-pkmn.exp
return if expGained<=0
expGained = expFinal - pkmn.exp
return if expGained <= 0
# "Exp gained" message
if showMessages
if isOutsider
pbDisplayPaused(_INTL("{1} got a boosted {2} Exp. Points!",pkmn.name,expGained))
pbDisplayPaused(_INTL("{1} got a boosted {2} Exp. Points!", pkmn.name, expGained))
else
pbDisplayPaused(_INTL("{1} got {2} Exp. Points!",pkmn.name,expGained))
pbDisplayPaused(_INTL("{1} got {2} Exp. Points!", pkmn.name, expGained))
end
end
curLevel = pkmn.level
newLevel = growth_rate.level_from_exp(expFinal)
if newLevel<curLevel
if newLevel < curLevel
debugInfo = "Levels: #{curLevel}->#{newLevel} | Exp: #{pkmn.exp}->#{expFinal} | gain: #{expGained}"
raise _INTL("{1}'s new level is less than its\r\ncurrent level, which shouldn't happen.\r\n[Debug: {2}]",
pkmn.name,debugInfo)
pkmn.name, debugInfo)
end
# Give Exp
if pkmn.shadowPokemon?
@@ -191,12 +191,12 @@ class Battle
# EXP Bar animation
levelMinExp = growth_rate.minimum_exp_for_level(curLevel)
levelMaxExp = growth_rate.minimum_exp_for_level(curLevel + 1)
tempExp2 = (levelMaxExp<expFinal) ? levelMaxExp : expFinal
tempExp2 = (levelMaxExp < expFinal) ? levelMaxExp : expFinal
pkmn.exp = tempExp2
@scene.pbEXPBar(battler,levelMinExp,levelMaxExp,tempExp1,tempExp2)
@scene.pbEXPBar(battler, levelMinExp, levelMaxExp, tempExp1, tempExp2)
tempExp1 = tempExp2
curLevel += 1
if curLevel>newLevel
if curLevel > newLevel
# Gained all the Exp now, end the animation
pkmn.calc_stats
battler.pbUpdate(false) if battler
@@ -204,7 +204,7 @@ class Battle
break
end
# Levelled up
pbCommonAnimation("LevelUp",battler) if battler
pbCommonAnimation("LevelUp", battler) if battler
oldTotalHP = pkmn.totalhp
oldAttack = pkmn.attack
oldDefense = pkmn.defense
@@ -217,19 +217,19 @@ class Battle
pkmn.calc_stats
battler.pbUpdate(false) if battler
@scene.pbRefreshOne(battler.index) if battler
pbDisplayPaused(_INTL("{1} grew to Lv. {2}!",pkmn.name,curLevel))
@scene.pbLevelUp(pkmn,battler,oldTotalHP,oldAttack,oldDefense,
oldSpAtk,oldSpDef,oldSpeed)
pbDisplayPaused(_INTL("{1} grew to Lv. {2}!", pkmn.name, curLevel))
@scene.pbLevelUp(pkmn, battler, oldTotalHP, oldAttack, oldDefense,
oldSpAtk, oldSpDef, oldSpeed)
# Learn all moves learned at this level
moveList = pkmn.getMoveList
moveList.each { |m| pbLearnMove(idxParty,m[1]) if m[0]==curLevel }
moveList.each { |m| pbLearnMove(idxParty, m[1]) if m[0] == curLevel }
end
end
#=============================================================================
# Learning a move
#=============================================================================
def pbLearnMove(idxParty,newMove)
def pbLearnMove(idxParty, newMove)
pkmn = pbParty(0)[idxParty]
return if !pkmn
pkmnName = pkmn.name
@@ -240,7 +240,7 @@ class Battle
# Pokémon has space for the new move; just learn it
if pkmn.numMoves < Pokemon::MAX_MOVES
pkmn.learn_move(newMove)
pbDisplay(_INTL("{1} learned {2}!",pkmnName,moveName)) { pbSEPlay("Pkmn move learnt") }
pbDisplay(_INTL("{1} learned {2}!", pkmnName, moveName)) { pbSEPlay("Pkmn move learnt") }
if battler
battler.moves.push(Move.from_pokemon_move(self, pkmn.moves.last))
battler.pbCheckFormOnMovesetChange
@@ -252,18 +252,18 @@ class Battle
pkmnName, moveName, pkmn.numMoves.to_word))
if pbDisplayConfirm(_INTL("Should {1} forget a move to learn {2}?", pkmnName, moveName))
loop do
forgetMove = @scene.pbForgetMove(pkmn,newMove)
if forgetMove>=0
forgetMove = @scene.pbForgetMove(pkmn, newMove)
if forgetMove >= 0
oldMoveName = pkmn.moves[forgetMove].name
pkmn.moves[forgetMove] = Pokemon::Move.new(newMove) # Replaces current/total PP
battler.moves[forgetMove] = Move.from_pokemon_move(self, pkmn.moves[forgetMove]) if battler
pbDisplayPaused(_INTL("1, 2, and... ... ... Ta-da!")) { pbSEPlay("Battle ball drop") }
pbDisplayPaused(_INTL("{1} forgot how to use {2}. And...",pkmnName,oldMoveName))
pbDisplay(_INTL("{1} learned {2}!",pkmnName,moveName)) { pbSEPlay("Pkmn move learnt") }
pbDisplayPaused(_INTL("{1} forgot how to use {2}. And...", pkmnName, oldMoveName))
pbDisplay(_INTL("{1} learned {2}!", pkmnName, moveName)) { pbSEPlay("Pkmn move learnt") }
battler.pbCheckFormOnMovesetChange if battler
break
elsif pbDisplayConfirm(_INTL("Give up on learning {1}?",moveName))
pbDisplay(_INTL("{1} did not learn {2}.",pkmnName,moveName))
elsif pbDisplayConfirm(_INTL("Give up on learning {1}?", moveName))
pbDisplay(_INTL("{1} did not learn {2}.", pkmnName, moveName))
break
end
end

View File

@@ -2,30 +2,30 @@ class Battle
#=============================================================================
# Choosing a move/target
#=============================================================================
def pbCanChooseMove?(idxBattler,idxMove,showMessages,sleepTalk = false)
def pbCanChooseMove?(idxBattler, idxMove, showMessages, sleepTalk = false)
battler = @battlers[idxBattler]
move = battler.moves[idxMove]
return false unless move
if move.pp==0 && move.total_pp>0 && !sleepTalk
if move.pp == 0 && move.total_pp > 0 && !sleepTalk
pbDisplayPaused(_INTL("There's no PP left for this move!")) if showMessages
return false
end
if battler.effects[PBEffects::Encore]>0
if battler.effects[PBEffects::Encore] > 0
idxEncoredMove = battler.pbEncoredMoveIndex
return false if idxEncoredMove>=0 && idxMove!=idxEncoredMove
return false if idxEncoredMove >= 0 && idxMove != idxEncoredMove
end
return battler.pbCanChooseMove?(move,true,showMessages,sleepTalk)
return battler.pbCanChooseMove?(move, true, showMessages, sleepTalk)
end
def pbCanChooseAnyMove?(idxBattler,sleepTalk = false)
def pbCanChooseAnyMove?(idxBattler, sleepTalk = false)
battler = @battlers[idxBattler]
battler.eachMoveWithIndex do |m,i|
next if m.pp==0 && m.total_pp>0 && !sleepTalk
if battler.effects[PBEffects::Encore]>0
battler.eachMoveWithIndex do |m, i|
next if m.pp == 0 && m.total_pp > 0 && !sleepTalk
if battler.effects[PBEffects::Encore] > 0
idxEncoredMove = battler.pbEncoredMoveIndex
next if idxEncoredMove>=0 && i!=idxEncoredMove
next if idxEncoredMove >= 0 && i != idxEncoredMove
end
next if !battler.pbCanChooseMove?(m,true,false,sleepTalk)
next if !battler.pbCanChooseMove?(m, true, false, sleepTalk)
return true
end
return false
@@ -33,7 +33,7 @@ class Battle
# Called when the Pokémon is Encored, or if it can't use any of its moves.
# Makes the Pokémon use the Encored move (if Encored), or Struggle.
def pbAutoChooseMove(idxBattler,showMessages = true)
def pbAutoChooseMove(idxBattler, showMessages = true)
battler = @battlers[idxBattler]
if battler.fainted?
pbClearChoice(idxBattler)
@@ -41,7 +41,7 @@ class Battle
end
# Encore
idxEncoredMove = battler.pbEncoredMoveIndex
if idxEncoredMove>=0 && pbCanChooseMove?(idxBattler,idxEncoredMove,false)
if idxEncoredMove >= 0 && pbCanChooseMove?(idxBattler, idxEncoredMove, false)
encoreMove = battler.moves[idxEncoredMove]
@choices[idxBattler][0] = :UseMove # "Use move"
@choices[idxBattler][1] = idxEncoredMove # Index of move to be used
@@ -50,15 +50,15 @@ class Battle
return true if singleBattle?
if pbOwnedByPlayer?(idxBattler)
if showMessages
pbDisplayPaused(_INTL("{1} has to use {2}!",battler.name,encoreMove.name))
pbDisplayPaused(_INTL("{1} has to use {2}!", battler.name, encoreMove.name))
end
return pbChooseTarget(battler,encoreMove)
return pbChooseTarget(battler, encoreMove)
end
return true
end
# Struggle
if pbOwnedByPlayer?(idxBattler) && showMessages
pbDisplayPaused(_INTL("{1} has no moves left!",battler.name))
pbDisplayPaused(_INTL("{1} has no moves left!", battler.name))
end
@choices[idxBattler][0] = :UseMove # "Use move"
@choices[idxBattler][1] = -1 # Index of move to be used
@@ -67,10 +67,10 @@ class Battle
return true
end
def pbRegisterMove(idxBattler,idxMove,showMessages = true)
def pbRegisterMove(idxBattler, idxMove, showMessages = true)
battler = @battlers[idxBattler]
move = battler.moves[idxMove]
return false if !pbCanChooseMove?(idxBattler,idxMove,showMessages)
return false if !pbCanChooseMove?(idxBattler, idxMove, showMessages)
@choices[idxBattler][0] = :UseMove # "Use move"
@choices[idxBattler][1] = idxMove # Index of move to be used
@choices[idxBattler][2] = move # Battle::Move object
@@ -78,54 +78,54 @@ class Battle
return true
end
def pbChoseMove?(idxBattler,moveID)
def pbChoseMove?(idxBattler, moveID)
return false if !@battlers[idxBattler] || @battlers[idxBattler].fainted?
if @choices[idxBattler][0]==:UseMove && @choices[idxBattler][1]
if @choices[idxBattler][0] == :UseMove && @choices[idxBattler][1]
return @choices[idxBattler][2].id == moveID
end
return false
end
def pbChoseMoveFunctionCode?(idxBattler,code)
def pbChoseMoveFunctionCode?(idxBattler, code)
return false if @battlers[idxBattler].fainted?
if @choices[idxBattler][0]==:UseMove && @choices[idxBattler][1]
if @choices[idxBattler][0] == :UseMove && @choices[idxBattler][1]
return @choices[idxBattler][2].function == code
end
return false
end
def pbRegisterTarget(idxBattler,idxTarget)
def pbRegisterTarget(idxBattler, idxTarget)
@choices[idxBattler][3] = idxTarget # Set target of move
end
# Returns whether the idxTarget will be targeted by a move with target_data
# used by a battler in idxUser.
def pbMoveCanTarget?(idxUser,idxTarget,target_data)
def pbMoveCanTarget?(idxUser, idxTarget, target_data)
return false if target_data.num_targets == 0
case target_data.id
when :NearAlly
return false if opposes?(idxUser,idxTarget)
return false if !nearBattlers?(idxUser,idxTarget)
return false if opposes?(idxUser, idxTarget)
return false if !nearBattlers?(idxUser, idxTarget)
when :UserOrNearAlly
return true if idxUser==idxTarget
return false if opposes?(idxUser,idxTarget)
return false if !nearBattlers?(idxUser,idxTarget)
return true if idxUser == idxTarget
return false if opposes?(idxUser, idxTarget)
return false if !nearBattlers?(idxUser, idxTarget)
when :AllAllies
return false if idxUser == idxTarget
return false if opposes?(idxUser, idxTarget)
when :UserAndAllies
return false if opposes?(idxUser,idxTarget)
return false if opposes?(idxUser, idxTarget)
when :NearFoe, :RandomNearFoe, :AllNearFoes
return false if !opposes?(idxUser,idxTarget)
return false if !nearBattlers?(idxUser,idxTarget)
return false if !opposes?(idxUser, idxTarget)
return false if !nearBattlers?(idxUser, idxTarget)
when :Foe
return false if !opposes?(idxUser,idxTarget)
return false if !opposes?(idxUser, idxTarget)
when :AllFoes
return false if !opposes?(idxUser,idxTarget)
return false if !opposes?(idxUser, idxTarget)
when :NearOther, :AllNearOthers
return false if !nearBattlers?(idxUser,idxTarget)
return false if !nearBattlers?(idxUser, idxTarget)
when :Other
return false if idxUser==idxTarget
return false if idxUser == idxTarget
end
return true
end
@@ -133,14 +133,14 @@ class Battle
#=============================================================================
# Turn order calculation (priority)
#=============================================================================
def pbCalculatePriority(fullCalc = false,indexArray = nil)
def pbCalculatePriority(fullCalc = false, indexArray = nil)
needRearranging = false
if fullCalc
@priorityTrickRoom = (@field.effects[PBEffects::TrickRoom]>0)
@priorityTrickRoom = (@field.effects[PBEffects::TrickRoom] > 0)
# Recalculate everything from scratch
randomOrder = Array.new(maxBattlerIndex+1) { |i| i }
(randomOrder.length-1).times do |i| # Can't use shuffle! here
r = i+pbRandom(randomOrder.length-i)
randomOrder = Array.new(maxBattlerIndex + 1) { |i| i }
(randomOrder.length - 1).times do |i| # Can't use shuffle! here
r = i + pbRandom(randomOrder.length - i)
randomOrder[i], randomOrder[r] = randomOrder[r], randomOrder[i]
end
@priority.clear
@@ -148,10 +148,10 @@ class Battle
b = @battlers[i]
next if !b
# [battler, speed, sub-priority, priority, tie-breaker order]
bArray = [b,b.pbSpeed,0,0,randomOrder[i]]
if @choices[b.index][0]==:UseMove || @choices[b.index][0]==:Shift
bArray = [b, b.pbSpeed, 0, 0, randomOrder[i]]
if @choices[b.index][0] == :UseMove || @choices[b.index][0] == :Shift
# Calculate move's priority
if @choices[b.index][0]==:UseMove
if @choices[b.index][0] == :UseMove
move = @choices[b.index][2]
pri = move.pbPriority(b)
if b.abilityActive?
@@ -168,7 +168,7 @@ class Battle
# Abilities (Stall)
if b.abilityActive?
newSubPri = Battle::AbilityEffects.triggerPriorityBracketChange(b.ability, b, subPri, self)
if subPri!=newSubPri
if subPri != newSubPri
subPri = newSubPri
b.effects[PBEffects::PriorityAbility] = true
b.effects[PBEffects::PriorityItem] = false
@@ -177,7 +177,7 @@ class Battle
# Items (Quick Claw, Custap Berry, Lagging Tail, Full Incense)
if b.itemActive?
newSubPri = Battle::ItemEffects.triggerPriorityBracketChange(b.item, b, subPri, self)
if subPri!=newSubPri
if subPri != newSubPri
subPri = newSubPri
b.effects[PBEffects::PriorityAbility] = false
b.effects[PBEffects::PriorityItem] = true
@@ -189,9 +189,9 @@ class Battle
end
needRearranging = true
else
if (@field.effects[PBEffects::TrickRoom]>0)!=@priorityTrickRoom
if (@field.effects[PBEffects::TrickRoom] > 0) != @priorityTrickRoom
needRearranging = true
@priorityTrickRoom = (@field.effects[PBEffects::TrickRoom]>0)
@priorityTrickRoom = (@field.effects[PBEffects::TrickRoom] > 0)
end
# Just recheck all battler speeds
@priority.each do |orderArray|
@@ -199,24 +199,24 @@ class Battle
next if indexArray && !indexArray.include?(orderArray[0].index)
oldSpeed = orderArray[1]
orderArray[1] = orderArray[0].pbSpeed
needRearranging = true if orderArray[1]!=oldSpeed
needRearranging = true if orderArray[1] != oldSpeed
end
end
# Reorder the priority array
if needRearranging
@priority.sort! { |a,b|
if a[3]!=b[3]
@priority.sort! { |a, b|
if a[3] != b[3]
# Sort by priority (highest value first)
b[3]<=>a[3]
elsif a[2]!=b[2]
b[3] <=> a[3]
elsif a[2] != b[2]
# Sort by sub-priority (highest value first)
b[2]<=>a[2]
b[2] <=> a[2]
elsif @priorityTrickRoom
# Sort by speed (lowest first), and use tie-breaker if necessary
(a[1]==b[1]) ? b[4]<=>a[4] : a[1]<=>b[1]
(a[1] == b[1]) ? b[4] <=> a[4] : a[1] <=> b[1]
else
# Sort by speed (highest first), and use tie-breaker if necessary
(a[1]==b[1]) ? b[4]<=>a[4] : b[1]<=>a[1]
(a[1] == b[1]) ? b[4] <=> a[4] : b[1] <=> a[1]
end
}
# Write the priority order to the debug log
@@ -236,8 +236,8 @@ class Battle
if onlySpeedSort
# Sort battlers by their speed stats and tie-breaker order only.
tempArray = []
@priority.each { |pArray| tempArray.push([pArray[0],pArray[1],pArray[4]]) }
tempArray.sort! { |a,b| (a[1]==b[1]) ? b[2]<=>a[2] : b[1]<=>a[1] }
@priority.each { |pArray| tempArray.push([pArray[0], pArray[1], pArray[4]]) }
tempArray.sort! { |a, b| (a[1] == b[1]) ? b[2] <=> a[2] : b[1] <=> a[1] }
tempArray.each { |tArray| ret.push(tArray[0]) }
else
# Sort battlers by priority, sub-priority and their speed. Ties are

View File

@@ -6,18 +6,18 @@ class Battle
# battle.
# NOTE: Messages are only shown while in the party screen when choosing a
# command for the next round.
def pbCanSwitchLax?(idxBattler,idxParty,partyScene = nil)
return true if idxParty<0
def pbCanSwitchLax?(idxBattler, idxParty, partyScene = nil)
return true if idxParty < 0
party = pbParty(idxBattler)
return false if idxParty>=party.length
return false if idxParty >= party.length
return false if !party[idxParty]
if party[idxParty].egg?
partyScene.pbDisplay(_INTL("An Egg can't battle!")) if partyScene
return false
end
if !pbIsOwner?(idxBattler,idxParty)
if !pbIsOwner?(idxBattler, idxParty)
if partyScene
owner = pbGetOwnerFromPartyIndex(idxBattler,idxParty)
owner = pbGetOwnerFromPartyIndex(idxBattler, idxParty)
partyScene.pbDisplay(_INTL("You can't switch {1}'s Pokémon with one of yours!",
owner.name))
end
@@ -28,7 +28,7 @@ class Battle
party[idxParty].name)) if partyScene
return false
end
if pbFindBattler(idxParty,idxBattler)
if pbFindBattler(idxParty, idxBattler)
partyScene.pbDisplay(_INTL("{1} is already in battle!",
party[idxParty].name)) if partyScene
return false
@@ -40,13 +40,13 @@ class Battle
# switch out (and that its replacement at party index idxParty can switch in).
# NOTE: Messages are only shown while in the party screen when choosing a
# command for the next round.
def pbCanSwitch?(idxBattler,idxParty = -1,partyScene = nil)
def pbCanSwitch?(idxBattler, idxParty = -1, partyScene = nil)
# Check whether party Pokémon can switch in
return false if !pbCanSwitchLax?(idxBattler,idxParty,partyScene)
return false if !pbCanSwitchLax?(idxBattler, idxParty, partyScene)
# Make sure another battler isn't already choosing to switch to the party
# Pokémon
allSameSideBattlers(idxBattler).each do |b|
next if choices[b.index][0]!=:SwitchOut || choices[b.index][1]!=idxParty
next if choices[b.index][0] != :SwitchOut || choices[b.index][1] != idxParty
partyScene.pbDisplay(_INTL("{1} has already been selected.",
pbParty(idxBattler)[idxParty].name)) if partyScene
return false
@@ -69,7 +69,7 @@ class Battle
return true if Settings::MORE_TYPE_EFFECTS && battler.pbHasType?(:GHOST)
# Other certain trapping effects
if battler.trappedInBattle?
partyScene.pbDisplay(_INTL("{1} can't be switched out!",battler.pbThis)) if partyScene
partyScene.pbDisplay(_INTL("{1} can't be switched out!", battler.pbThis)) if partyScene
return false
end
# Trapping abilities/items
@@ -77,15 +77,15 @@ class Battle
next if !b.abilityActive?
if Battle::AbilityEffects.triggerTrappingByTarget(b.ability, battler, b, self)
partyScene.pbDisplay(_INTL("{1}'s {2} prevents switching!",
b.pbThis,b.abilityName)) if partyScene
b.pbThis, b.abilityName)) if partyScene
return false
end
end
allOtherSideBattlers(idxBattler).each do |b|
next if !b.itemActive?
if Battle::ItemEffects.triggerTrappingByTarget(b.item,battler,b,self)
if Battle::ItemEffects.triggerTrappingByTarget(b.item, battler, b, self)
partyScene.pbDisplay(_INTL("{1}'s {2} prevents switching!",
b.pbThis,b.itemName)) if partyScene
b.pbThis, b.itemName)) if partyScene
return false
end
end
@@ -93,14 +93,14 @@ class Battle
end
def pbCanChooseNonActive?(idxBattler)
pbParty(idxBattler).each_with_index do |_pkmn,i|
return true if pbCanSwitchLax?(idxBattler,i)
pbParty(idxBattler).each_with_index do |_pkmn, i|
return true if pbCanSwitchLax?(idxBattler, i)
end
return false
end
def pbRegisterSwitch(idxBattler,idxParty)
return false if !pbCanSwitch?(idxBattler,idxParty)
def pbRegisterSwitch(idxBattler, idxParty)
return false if !pbCanSwitch?(idxBattler, idxParty)
@choices[idxBattler][0] = :SwitchOut
@choices[idxBattler][1] = idxParty # Party index of Pokémon to switch in
@choices[idxBattler][2] = nil
@@ -113,16 +113,16 @@ class Battle
#=============================================================================
# Open party screen and potentially choose a Pokémon to switch with. Used in
# all instances where the party screen is opened.
def pbPartyScreen(idxBattler,checkLaxOnly = false,canCancel = false,shouldRegister = false)
def pbPartyScreen(idxBattler, checkLaxOnly = false, canCancel = false, shouldRegister = false)
ret = -1
@scene.pbPartyScreen(idxBattler,canCancel) { |idxParty,partyScene|
@scene.pbPartyScreen(idxBattler, canCancel) { |idxParty, partyScene|
if checkLaxOnly
next false if !pbCanSwitchLax?(idxBattler,idxParty,partyScene)
next false if !pbCanSwitchLax?(idxBattler, idxParty, partyScene)
else
next false if !pbCanSwitch?(idxBattler,idxParty,partyScene)
next false if !pbCanSwitch?(idxBattler, idxParty, partyScene)
end
if shouldRegister
next false if idxParty<0 || !pbRegisterSwitch(idxBattler,idxParty)
next false if idxParty < 0 || !pbRegisterSwitch(idxBattler, idxParty)
end
ret = idxParty
next true
@@ -132,9 +132,9 @@ class Battle
# For choosing a replacement Pokémon when prompted in the middle of other
# things happening (U-turn, Baton Pass, in def pbEORSwitch).
def pbSwitchInBetween(idxBattler,checkLaxOnly = false,canCancel = false)
return pbPartyScreen(idxBattler,checkLaxOnly,canCancel) if pbOwnedByPlayer?(idxBattler)
return @battleAI.pbDefaultChooseNewEnemy(idxBattler,pbParty(idxBattler))
def pbSwitchInBetween(idxBattler, checkLaxOnly = false, canCancel = false)
return pbPartyScreen(idxBattler, checkLaxOnly, canCancel) if pbOwnedByPlayer?(idxBattler)
return @battleAI.pbDefaultChooseNewEnemy(idxBattler, pbParty(idxBattler))
end
#=============================================================================
@@ -143,10 +143,10 @@ class Battle
# General switching method that checks if any Pokémon need to be sent out and,
# if so, does. Called at the end of each round.
def pbEORSwitch(favorDraws = false)
return if @decision>0 && !favorDraws
return if @decision==5 && favorDraws
return if @decision > 0 && !favorDraws
return if @decision == 5 && favorDraws
pbJudge
return if @decision>0
return if @decision > 0
# Check through each fainted battler to see if that spot can be filled.
switched = []
loop do
@@ -162,9 +162,9 @@ class Battle
# NOTE: The player is only offered the chance to switch their own
# Pokémon when an opponent replaces a fainted Pokémon in single
# battles. In double battles, etc. there is no such offer.
if @internalBattle && @switchStyle && trainerBattle? && pbSideSize(0)==1 &&
if @internalBattle && @switchStyle && trainerBattle? && pbSideSize(0) == 1 &&
opposes?(idxBattler) && !@battlers[0].fainted? && !switched.include?(0) &&
pbCanChooseNonActive?(0) && @battlers[0].effects[PBEffects::Outrage]==0
pbCanChooseNonActive?(0) && @battlers[0].effects[PBEffects::Outrage] == 0
idxPartyForName = idxPartyNew
enemyParty = pbParty(idxBattler)
if enemyParty[idxPartyNew].ability == :ILLUSION && !pbCheckGlobalAbility(:NEUTRALIZINGGAS)
@@ -173,82 +173,82 @@ class Battle
end
if pbDisplayConfirm(_INTL("{1} is about to send in {2}. Will you switch your Pokémon?",
opponent.full_name, enemyParty[idxPartyForName].name))
idxPlayerPartyNew = pbSwitchInBetween(0,false,true)
if idxPlayerPartyNew>=0
idxPlayerPartyNew = pbSwitchInBetween(0, false, true)
if idxPlayerPartyNew >= 0
pbMessageOnRecall(@battlers[0])
pbRecallAndReplace(0,idxPlayerPartyNew)
pbRecallAndReplace(0, idxPlayerPartyNew)
switched.push(0)
end
end
end
pbRecallAndReplace(idxBattler,idxPartyNew)
pbRecallAndReplace(idxBattler, idxPartyNew)
switched.push(idxBattler)
elsif trainerBattle? # Player switches in in a trainer battle
idxPlayerPartyNew = pbGetReplacementPokemonIndex(idxBattler) # Owner chooses
pbRecallAndReplace(idxBattler,idxPlayerPartyNew)
pbRecallAndReplace(idxBattler, idxPlayerPartyNew)
switched.push(idxBattler)
else # Player's Pokémon has fainted in a wild battle
switch = false
if !pbDisplayConfirm(_INTL("Use next Pokémon?"))
switch = (pbRun(idxBattler,true)<=0)
switch = (pbRun(idxBattler, true) <= 0)
else
switch = true
end
if switch
idxPlayerPartyNew = pbGetReplacementPokemonIndex(idxBattler) # Owner chooses
pbRecallAndReplace(idxBattler,idxPlayerPartyNew)
pbRecallAndReplace(idxBattler, idxPlayerPartyNew)
switched.push(idxBattler)
end
end
end
break if switched.length==0
break if switched.length == 0
pbOnBattlerEnteringBattle(switched)
end
end
def pbGetReplacementPokemonIndex(idxBattler,random = false)
def pbGetReplacementPokemonIndex(idxBattler, random = false)
if random
choices = [] # Find all Pokémon that can switch in
eachInTeamFromBattlerIndex(idxBattler) do |_pkmn,i|
choices.push(i) if pbCanSwitchLax?(idxBattler,i)
eachInTeamFromBattlerIndex(idxBattler) do |_pkmn, i|
choices.push(i) if pbCanSwitchLax?(idxBattler, i)
end
return -1 if choices.length==0
return -1 if choices.length == 0
return choices[pbRandom(choices.length)]
else
return pbSwitchInBetween(idxBattler,true)
return pbSwitchInBetween(idxBattler, true)
end
end
# Actually performs the recalling and sending out in all situations.
def pbRecallAndReplace(idxBattler,idxParty,randomReplacement = false,batonPass = false)
def pbRecallAndReplace(idxBattler, idxParty, randomReplacement = false, batonPass = false)
@scene.pbRecall(idxBattler) if !@battlers[idxBattler].fainted?
@battlers[idxBattler].pbAbilitiesOnSwitchOut # Inc. primordial weather check
@scene.pbShowPartyLineup(idxBattler&1) if pbSideSize(idxBattler)==1
pbMessagesOnReplace(idxBattler,idxParty) if !randomReplacement
pbReplace(idxBattler,idxParty,batonPass)
@scene.pbShowPartyLineup(idxBattler & 1) if pbSideSize(idxBattler) == 1
pbMessagesOnReplace(idxBattler, idxParty) if !randomReplacement
pbReplace(idxBattler, idxParty, batonPass)
end
def pbMessageOnRecall(battler)
if battler.pbOwnedByPlayer?
if battler.hp<=battler.totalhp/4
pbDisplayBrief(_INTL("Good job, {1}! Come back!",battler.name))
elsif battler.hp<=battler.totalhp/2
pbDisplayBrief(_INTL("OK, {1}! Come back!",battler.name))
elsif battler.turnCount>=5
pbDisplayBrief(_INTL("{1}, that's enough! Come back!",battler.name))
elsif battler.turnCount>=2
pbDisplayBrief(_INTL("{1}, come back!",battler.name))
if battler.hp <= battler.totalhp / 4
pbDisplayBrief(_INTL("Good job, {1}! Come back!", battler.name))
elsif battler.hp <= battler.totalhp / 2
pbDisplayBrief(_INTL("OK, {1}! Come back!", battler.name))
elsif battler.turnCount >= 5
pbDisplayBrief(_INTL("{1}, that's enough! Come back!", battler.name))
elsif battler.turnCount >= 2
pbDisplayBrief(_INTL("{1}, come back!", battler.name))
else
pbDisplayBrief(_INTL("{1}, switch out! Come back!",battler.name))
pbDisplayBrief(_INTL("{1}, switch out! Come back!", battler.name))
end
else
owner = pbGetOwnerName(battler.index)
pbDisplayBrief(_INTL("{1} withdrew {2}!",owner,battler.name))
pbDisplayBrief(_INTL("{1} withdrew {2}!", owner, battler.name))
end
end
# Only called from def pbRecallAndReplace and Battle Arena's def pbSwitch.
def pbMessagesOnReplace(idxBattler,idxParty)
def pbMessagesOnReplace(idxBattler, idxParty)
party = pbParty(idxBattler)
newPkmnName = party[idxParty].name
if party[idxParty].ability == :ILLUSION && !pbCheckGlobalAbility(:NEUTRALIZINGGAS)
@@ -257,45 +257,45 @@ class Battle
end
if pbOwnedByPlayer?(idxBattler)
opposing = @battlers[idxBattler].pbDirectOpposing
if opposing.fainted? || opposing.hp==opposing.totalhp
pbDisplayBrief(_INTL("You're in charge, {1}!",newPkmnName))
elsif opposing.hp>=opposing.totalhp/2
pbDisplayBrief(_INTL("Go for it, {1}!",newPkmnName))
elsif opposing.hp>=opposing.totalhp/4
pbDisplayBrief(_INTL("Just a little more! Hang in there, {1}!",newPkmnName))
if opposing.fainted? || opposing.hp == opposing.totalhp
pbDisplayBrief(_INTL("You're in charge, {1}!", newPkmnName))
elsif opposing.hp >= opposing.totalhp / 2
pbDisplayBrief(_INTL("Go for it, {1}!", newPkmnName))
elsif opposing.hp >= opposing.totalhp / 4
pbDisplayBrief(_INTL("Just a little more! Hang in there, {1}!", newPkmnName))
else
pbDisplayBrief(_INTL("Your opponent's weak! Get 'em, {1}!",newPkmnName))
pbDisplayBrief(_INTL("Your opponent's weak! Get 'em, {1}!", newPkmnName))
end
else
owner = pbGetOwnerFromBattlerIndex(idxBattler)
pbDisplayBrief(_INTL("{1} sent out {2}!",owner.full_name,newPkmnName))
pbDisplayBrief(_INTL("{1} sent out {2}!", owner.full_name, newPkmnName))
end
end
# Only called from def pbRecallAndReplace above and Battle Arena's def
# pbSwitch.
def pbReplace(idxBattler,idxParty,batonPass = false)
def pbReplace(idxBattler, idxParty, batonPass = false)
party = pbParty(idxBattler)
idxPartyOld = @battlers[idxBattler].pokemonIndex
# Initialise the new Pokémon
@battlers[idxBattler].pbInitialize(party[idxParty],idxParty,batonPass)
@battlers[idxBattler].pbInitialize(party[idxParty], idxParty, batonPass)
# Reorder the party for this battle
partyOrder = pbPartyOrder(idxBattler)
partyOrder[idxParty],partyOrder[idxPartyOld] = partyOrder[idxPartyOld],partyOrder[idxParty]
partyOrder[idxParty], partyOrder[idxPartyOld] = partyOrder[idxPartyOld], partyOrder[idxParty]
# Send out the new Pokémon
pbSendOut([[idxBattler,party[idxParty]]])
pbCalculatePriority(false,[idxBattler]) if Settings::RECALCULATE_TURN_ORDER_AFTER_SPEED_CHANGES
pbSendOut([[idxBattler, party[idxParty]]])
pbCalculatePriority(false, [idxBattler]) if Settings::RECALCULATE_TURN_ORDER_AFTER_SPEED_CHANGES
end
# Called from def pbReplace above and at the start of battle.
# sendOuts is an array; each element is itself an array: [idxBattler,pkmn]
def pbSendOut(sendOuts,startBattle = false)
def pbSendOut(sendOuts, startBattle = false)
sendOuts.each { |b| @peer.pbOnEnteringBattle(self, @battlers[b[0]], b[1]) }
@scene.pbSendOutBattlers(sendOuts,startBattle)
@scene.pbSendOutBattlers(sendOuts, startBattle)
sendOuts.each do |b|
@scene.pbResetMoveIndex(b[0])
pbSetSeen(@battlers[b[0]])
@usedInBattle[b[0]&1][b[0]/2] = true
@usedInBattle[b[0] & 1][b[0] / 2] = true
end
end

View File

@@ -2,13 +2,13 @@ class Battle
#=============================================================================
# Choosing to use an item
#=============================================================================
def pbCanUseItemOnPokemon?(item,pkmn,battler,scene,showMessages = true)
def pbCanUseItemOnPokemon?(item, pkmn, battler, scene, showMessages = true)
if !pkmn || pkmn.egg?
scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages
return false
end
# Embargo
if battler && battler.effects[PBEffects::Embargo]>0
if battler && battler.effects[PBEffects::Embargo] > 0
scene.pbDisplay(_INTL("Embargo's effect prevents the item's use on {1}!",
battler.pbThis(true))) if showMessages
return false
@@ -24,7 +24,7 @@ class Battle
return false
end
def pbRegisterItem(idxBattler,item,idxTarget = nil,idxMove = nil)
def pbRegisterItem(idxBattler, item, idxTarget = nil, idxMove = nil)
# Register for use of item on a Pokémon in the party
@choices[idxBattler][0] = :UseItem
@choices[idxBattler][1] = item # ID of item to be used
@@ -32,14 +32,14 @@ class Battle
@choices[idxBattler][3] = idxMove # Index of move to recharge (Ethers)
# Delete the item from the Bag. If it turns out it will have no effect, it
# will be re-added to the Bag later.
pbConsumeItemInBag(item,idxBattler)
pbConsumeItemInBag(item, idxBattler)
return true
end
#=============================================================================
# Using an item
#=============================================================================
def pbConsumeItemInBag(item,idxBattler)
def pbConsumeItemInBag(item, idxBattler)
return if !item
return if !GameData::Item.get(item).consumed_after_use?
if pbOwnedByPlayer?(idxBattler)
@@ -52,7 +52,7 @@ class Battle
end
end
def pbReturnUnusedItemToBag(item,idxBattler)
def pbReturnUnusedItemToBag(item, idxBattler)
return if !item
return if !GameData::Item.get(item).consumed_after_use?
if pbOwnedByPlayer?(idxBattler)
@@ -67,41 +67,41 @@ class Battle
end
end
def pbUseItemMessage(item,trainerName)
def pbUseItemMessage(item, trainerName)
itemName = GameData::Item.get(item).name
if itemName.starts_with_vowel?
pbDisplayBrief(_INTL("{1} used an {2}.",trainerName,itemName))
pbDisplayBrief(_INTL("{1} used an {2}.", trainerName, itemName))
else
pbDisplayBrief(_INTL("{1} used a {2}.",trainerName,itemName))
pbDisplayBrief(_INTL("{1} used a {2}.", trainerName, itemName))
end
end
# Uses an item on a Pokémon in the trainer's party.
def pbUseItemOnPokemon(item,idxParty,userBattler)
def pbUseItemOnPokemon(item, idxParty, userBattler)
trainerName = pbGetOwnerName(userBattler.index)
pbUseItemMessage(item,trainerName)
pbUseItemMessage(item, trainerName)
pkmn = pbParty(userBattler.index)[idxParty]
battler = pbFindBattler(idxParty,userBattler.index)
battler = pbFindBattler(idxParty, userBattler.index)
ch = @choices[userBattler.index]
if ItemHandlers.triggerCanUseInBattle(item,pkmn,battler,ch[3],true,self,@scene,false)
ItemHandlers.triggerBattleUseOnPokemon(item,pkmn,battler,ch,@scene)
if ItemHandlers.triggerCanUseInBattle(item, pkmn, battler, ch[3], true, self, @scene, false)
ItemHandlers.triggerBattleUseOnPokemon(item, pkmn, battler, ch, @scene)
ch[1] = nil # Delete item from choice
return
end
pbDisplay(_INTL("But it had no effect!"))
# Return unused item to Bag
pbReturnUnusedItemToBag(item,userBattler.index)
pbReturnUnusedItemToBag(item, userBattler.index)
end
# Uses an item on a Pokémon in battle that belongs to the trainer.
def pbUseItemOnBattler(item,idxParty,userBattler)
def pbUseItemOnBattler(item, idxParty, userBattler)
trainerName = pbGetOwnerName(userBattler.index)
pbUseItemMessage(item,trainerName)
battler = pbFindBattler(idxParty,userBattler.index)
pbUseItemMessage(item, trainerName)
battler = pbFindBattler(idxParty, userBattler.index)
ch = @choices[userBattler.index]
if battler
if ItemHandlers.triggerCanUseInBattle(item,battler.pokemon,battler,ch[3],true,self,@scene,false)
ItemHandlers.triggerBattleUseOnBattler(item,battler,@scene)
if ItemHandlers.triggerCanUseInBattle(item, battler.pokemon, battler, ch[3], true, self, @scene, false)
ItemHandlers.triggerBattleUseOnBattler(item, battler, @scene)
ch[1] = nil # Delete item from choice
battler.pbItemOnStatDropped
return
@@ -112,31 +112,31 @@ class Battle
pbDisplay(_INTL("But it's not where this item can be used!"))
end
# Return unused item to Bag
pbReturnUnusedItemToBag(item,userBattler.index)
pbReturnUnusedItemToBag(item, userBattler.index)
end
# Uses a Poké Ball in battle directly.
def pbUsePokeBallInBattle(item,idxBattler,userBattler)
idxBattler = userBattler.index if idxBattler<0
def pbUsePokeBallInBattle(item, idxBattler, userBattler)
idxBattler = userBattler.index if idxBattler < 0
battler = @battlers[idxBattler]
ItemHandlers.triggerUseInBattle(item,battler,self)
ItemHandlers.triggerUseInBattle(item, battler, self)
@choices[userBattler.index][1] = nil # Delete item from choice
end
# Uses an item in battle directly.
def pbUseItemInBattle(item,idxBattler,userBattler)
def pbUseItemInBattle(item, idxBattler, userBattler)
trainerName = pbGetOwnerName(userBattler.index)
pbUseItemMessage(item,trainerName)
battler = (idxBattler<0) ? userBattler : @battlers[idxBattler]
pbUseItemMessage(item, trainerName)
battler = (idxBattler < 0) ? userBattler : @battlers[idxBattler]
pkmn = battler.pokemon
ch = @choices[userBattler.index]
if ItemHandlers.triggerCanUseInBattle(item,pkmn,battler,ch[3],true,self,@scene,false)
ItemHandlers.triggerUseInBattle(item,battler,self)
if ItemHandlers.triggerCanUseInBattle(item, pkmn, battler, ch[3], true, self, @scene, false)
ItemHandlers.triggerUseInBattle(item, battler, self)
ch[1] = nil # Delete item from choice
return
end
pbDisplay(_INTL("But it had no effect!"))
# Return unused item to Bag
pbReturnUnusedItemToBag(item,userBattler.index)
pbReturnUnusedItemToBag(item, userBattler.index)
end
end

View File

@@ -27,7 +27,7 @@ class Battle
# 1: Succeeded at fleeing, battle will end
# duringBattle is true for replacing a fainted Pokémon during the End Of Round
# phase, and false for choosing the Run command.
def pbRun(idxBattler,duringBattle = false)
def pbRun(idxBattler, duringBattle = false)
battler = @battlers[idxBattler]
if battler.opposes?
return 0 if trainerBattle?
@@ -50,7 +50,7 @@ class Battle
pbDisplayPaused(_INTL("No! There's no running from a Trainer battle!"))
elsif pbDisplayConfirm(_INTL("Would you like to forfeit the match and quit now?"))
pbSEPlay("Battle flee")
pbDisplay(_INTL("{1} forfeited the match!",self.pbPlayer.name))
pbDisplay(_INTL("{1} forfeited the match!", self.pbPlayer.name))
@decision = 3
return 1
end
@@ -77,7 +77,7 @@ class Battle
# Abilities that guarantee escape
if battler.abilityActive?
if Battle::AbilityEffects.triggerCertainEscapeFromBattle(battler.ability, battler)
pbShowAbilitySplash(battler,true)
pbShowAbilitySplash(battler, true)
pbHideAbilitySplash(battler)
pbSEPlay("Battle flee")
pbDisplayPaused(_INTL("You got away safely!"))
@@ -89,7 +89,7 @@ class Battle
if battler.itemActive?
if Battle::ItemEffects.triggerCertainEscapeFromBattle(battler.item, battler)
pbSEPlay("Battle flee")
pbDisplayPaused(_INTL("{1} fled using its {2}!", battler.pbThis,battler.itemName))
pbDisplayPaused(_INTL("{1} fled using its {2}!", battler.pbThis, battler.itemName))
@decision = 3
return 1
end
@@ -103,14 +103,14 @@ class Battle
allOtherSideBattlers(idxBattler).each do |b|
next if !b.abilityActive?
if Battle::AbilityEffects.triggerTrappingByTarget(b.ability, battler, b, self)
pbDisplayPaused(_INTL("{1} prevents escape with {2}!",b.pbThis,b.abilityName))
pbDisplayPaused(_INTL("{1} prevents escape with {2}!", b.pbThis, b.abilityName))
return 0
end
end
allOtherSideBattlers(idxBattler).each do |b|
next if !b.itemActive?
if Battle::ItemEffects.triggerTrappingByTarget(b.item, battler, b, self)
pbDisplayPaused(_INTL("{1} prevents escape with {2}!",b.pbThis,b.itemName))
pbDisplayPaused(_INTL("{1} prevents escape with {2}!", b.pbThis, b.itemName))
return 0
end
end
@@ -123,16 +123,16 @@ class Battle
speedEnemy = 1
allOtherSideBattlers(idxBattler).each do |b|
speed = b.speed
speedEnemy = speed if speedEnemy<speed
speedEnemy = speed if speedEnemy < speed
end
# Compare speeds and perform fleeing calculation
if speedPlayer>speedEnemy
if speedPlayer > speedEnemy
rate = 256
else
rate = (speedPlayer*128)/speedEnemy
rate += @runCommand*30
rate = (speedPlayer * 128) / speedEnemy
rate += @runCommand * 30
end
if rate>=256 || @battleAI.pbAIRandom(256)<rate
if rate >= 256 || @battleAI.pbAIRandom(256) < rate
pbSEPlay("Battle flee")
pbDisplayPaused(_INTL("You got away safely!"))
@decision = 3

View File

@@ -3,18 +3,18 @@ class Battle
# Shifting a battler to another position in a battle larger than double
#=============================================================================
def pbCanShift?(idxBattler)
return false if pbSideSize(0)<=2 && pbSideSize(1)<=2 # Double battle or smaller
return false if pbSideSize(0) <= 2 && pbSideSize(1) <= 2 # Double battle or smaller
idxOther = -1
case pbSideSize(idxBattler)
when 1
return false # Only one battler on that side
when 2
idxOther = (idxBattler+2)%4
idxOther = (idxBattler + 2) % 4
when 3
return false if idxBattler==2 || idxBattler==3 # In middle spot already
idxOther = ((idxBattler%2)==0) ? 2 : 3
return false if idxBattler == 2 || idxBattler == 3 # In middle spot already
idxOther = ((idxBattler % 2) == 0) ? 2 : 3
end
return false if pbGetOwnerIndexFromBattlerIndex(idxBattler)!=pbGetOwnerIndexFromBattlerIndex(idxOther)
return false if pbGetOwnerIndexFromBattlerIndex(idxBattler) != pbGetOwnerIndexFromBattlerIndex(idxOther)
return true
end
@@ -38,20 +38,20 @@ class Battle
def pbCall(idxBattler)
battler = @battlers[idxBattler]
trainerName = pbGetOwnerName(idxBattler)
pbDisplay(_INTL("{1} called {2}!",trainerName,battler.pbThis(true)))
pbDisplay(_INTL("{1}!",battler.name))
pbDisplay(_INTL("{1} called {2}!", trainerName, battler.pbThis(true)))
pbDisplay(_INTL("{1}!", battler.name))
if battler.shadowPokemon?
if battler.inHyperMode?
battler.pokemon.hyper_mode = false
battler.pokemon.change_heart_gauge("call")
pbDisplay(_INTL("{1} came to its senses from the Trainer's call!",battler.pbThis))
pbDisplay(_INTL("{1} came to its senses from the Trainer's call!", battler.pbThis))
else
pbDisplay(_INTL("But nothing happened!"))
end
elsif battler.status == :SLEEP
battler.pbCureStatus
elsif battler.pbCanRaiseStatStage?(:ACCURACY,battler)
battler.pbRaiseStatStage(:ACCURACY,1,battler)
elsif battler.pbCanRaiseStatStage?(:ACCURACY, battler)
battler.pbRaiseStatStage(:ACCURACY, 1, battler)
battler.pbItemOnStatDropped
else
pbDisplay(_INTL("But nothing happened!"))
@@ -85,11 +85,11 @@ class Battle
return false if !@battlers[idxBattler].hasMega?
return false if @battlers[idxBattler].wild?
return true if $DEBUG && Input.press?(Input::CTRL)
return false if @battlers[idxBattler].effects[PBEffects::SkyDrop]>=0
return false if @battlers[idxBattler].effects[PBEffects::SkyDrop] >= 0
return false if !pbHasMegaRing?(idxBattler)
side = @battlers[idxBattler].idxOwnSide
owner = pbGetOwnerIndexFromBattlerIndex(idxBattler)
return @megaEvolution[side][owner]==-1
return @megaEvolution[side][owner] == -1
end
def pbRegisterMegaEvolution(idxBattler)
@@ -101,13 +101,13 @@ class Battle
def pbUnregisterMegaEvolution(idxBattler)
side = @battlers[idxBattler].idxOwnSide
owner = pbGetOwnerIndexFromBattlerIndex(idxBattler)
@megaEvolution[side][owner] = -1 if @megaEvolution[side][owner]==idxBattler
@megaEvolution[side][owner] = -1 if @megaEvolution[side][owner] == idxBattler
end
def pbToggleRegisteredMegaEvolution(idxBattler)
side = @battlers[idxBattler].idxOwnSide
owner = pbGetOwnerIndexFromBattlerIndex(idxBattler)
if @megaEvolution[side][owner]==idxBattler
if @megaEvolution[side][owner] == idxBattler
@megaEvolution[side][owner] = -1
else
@megaEvolution[side][owner] = idxBattler
@@ -117,7 +117,7 @@ class Battle
def pbRegisteredMegaEvolution?(idxBattler)
side = @battlers[idxBattler].idxOwnSide
owner = pbGetOwnerIndexFromBattlerIndex(idxBattler)
return @megaEvolution[side][owner]==idxBattler
return @megaEvolution[side][owner] == idxBattler
end
#=============================================================================
@@ -137,28 +137,28 @@ class Battle
# Mega Evolve
case battler.pokemon.megaMessage
when 1 # Rayquaza
pbDisplay(_INTL("{1}'s fervent wish has reached {2}!",trainerName,battler.pbThis))
pbDisplay(_INTL("{1}'s fervent wish has reached {2}!", trainerName, battler.pbThis))
else
pbDisplay(_INTL("{1}'s {2} is reacting to {3}'s {4}!",
battler.pbThis,battler.itemName,trainerName,pbGetMegaRingName(idxBattler)))
battler.pbThis, battler.itemName, trainerName, pbGetMegaRingName(idxBattler)))
end
pbCommonAnimation("MegaEvolution",battler)
pbCommonAnimation("MegaEvolution", battler)
battler.pokemon.makeMega
battler.form = battler.pokemon.form
battler.pbUpdate(true)
@scene.pbChangePokemon(battler,battler.pokemon)
@scene.pbChangePokemon(battler, battler.pokemon)
@scene.pbRefreshOne(idxBattler)
pbCommonAnimation("MegaEvolution2",battler)
pbCommonAnimation("MegaEvolution2", battler)
megaName = battler.pokemon.megaName
megaName = _INTL("Mega {1}", battler.pokemon.speciesName) if nil_or_empty?(megaName)
pbDisplay(_INTL("{1} has Mega Evolved into {2}!",battler.pbThis,megaName))
pbDisplay(_INTL("{1} has Mega Evolved into {2}!", battler.pbThis, megaName))
side = battler.idxOwnSide
owner = pbGetOwnerIndexFromBattlerIndex(idxBattler)
@megaEvolution[side][owner] = -2
if battler.isSpecies?(:GENGAR) && battler.mega?
battler.effects[PBEffects::Telekinesis] = 0
end
pbCalculatePriority(false,[idxBattler]) if Settings::RECALCULATE_TURN_ORDER_AFTER_MEGA_EVOLUTION
pbCalculatePriority(false, [idxBattler]) if Settings::RECALCULATE_TURN_ORDER_AFTER_MEGA_EVOLUTION
# Trigger ability
battler.pbOnLosingAbility(old_ability)
battler.pbTriggerAbilityOnGainingIt
@@ -172,20 +172,20 @@ class Battle
return if !battler || !battler.pokemon || battler.fainted?
return if !battler.hasPrimal? || battler.primal?
if battler.isSpecies?(:KYOGRE)
pbCommonAnimation("PrimalKyogre",battler)
pbCommonAnimation("PrimalKyogre", battler)
elsif battler.isSpecies?(:GROUDON)
pbCommonAnimation("PrimalGroudon",battler)
pbCommonAnimation("PrimalGroudon", battler)
end
battler.pokemon.makePrimal
battler.form = battler.pokemon.form
battler.pbUpdate(true)
@scene.pbChangePokemon(battler,battler.pokemon)
@scene.pbChangePokemon(battler, battler.pokemon)
@scene.pbRefreshOne(idxBattler)
if battler.isSpecies?(:KYOGRE)
pbCommonAnimation("PrimalKyogre2",battler)
pbCommonAnimation("PrimalKyogre2", battler)
elsif battler.isSpecies?(:GROUDON)
pbCommonAnimation("PrimalGroudon2",battler)
pbCommonAnimation("PrimalGroudon2", battler)
end
pbDisplay(_INTL("{1}'s Primal Reversion!\nIt reverted to its primal form!",battler.pbThis))
pbDisplay(_INTL("{1}'s Primal Reversion!\nIt reverted to its primal form!", battler.pbThis))
end
end

View File

@@ -25,8 +25,8 @@ class Battle
#=============================================================================
# Use main command menu (Fight/Pokémon/Bag/Run)
#=============================================================================
def pbCommandMenu(idxBattler,firstAction)
return @scene.pbCommandMenu(idxBattler,firstAction)
def pbCommandMenu(idxBattler, firstAction)
return @scene.pbCommandMenu(idxBattler, firstAction)
end
#=============================================================================
@@ -42,11 +42,11 @@ class Battle
def pbCanShowFightMenu?(idxBattler)
battler = @battlers[idxBattler]
# Encore
return false if battler.effects[PBEffects::Encore]>0
return false if battler.effects[PBEffects::Encore] > 0
# No moves that can be chosen (will Struggle instead)
usable = false
battler.eachMoveWithIndex do |_m,i|
next if !pbCanChooseMove?(idxBattler,i,false)
battler.eachMoveWithIndex do |_m, i|
next if !pbCanChooseMove?(idxBattler, i, false)
usable = true
break
end
@@ -64,7 +64,7 @@ class Battle
return true if pbAutoFightMenu(idxBattler)
# Regular move selection
ret = false
@scene.pbFightMenu(idxBattler,pbCanMegaEvolve?(idxBattler)) { |cmd|
@scene.pbFightMenu(idxBattler, pbCanMegaEvolve?(idxBattler)) { |cmd|
case cmd
when -1 # Cancel
when -2 # Toggle Mega Evolution
@@ -75,11 +75,11 @@ class Battle
pbRegisterShift(idxBattler)
ret = true
else # Chose a move to use
next false if cmd<0 || !@battlers[idxBattler].moves[cmd] ||
next false if cmd < 0 || !@battlers[idxBattler].moves[cmd] ||
!@battlers[idxBattler].moves[cmd].id
next false if !pbRegisterMove(idxBattler,cmd)
next false if !pbRegisterMove(idxBattler, cmd)
next false if !singleBattle? &&
!pbChooseTarget(@battlers[idxBattler],@battlers[idxBattler].moves[cmd])
!pbChooseTarget(@battlers[idxBattler], @battlers[idxBattler].moves[cmd])
ret = true
end
next true
@@ -89,36 +89,36 @@ class Battle
def pbAutoFightMenu(idxBattler); return false; end
def pbChooseTarget(battler,move)
def pbChooseTarget(battler, move)
target_data = move.pbTarget(battler)
idxTarget = @scene.pbChooseTarget(battler.index,target_data)
return false if idxTarget<0
pbRegisterTarget(battler.index,idxTarget)
idxTarget = @scene.pbChooseTarget(battler.index, target_data)
return false if idxTarget < 0
pbRegisterTarget(battler.index, idxTarget)
return true
end
def pbItemMenu(idxBattler,firstAction)
def pbItemMenu(idxBattler, firstAction)
if !@internalBattle
pbDisplay(_INTL("Items can't be used here."))
return false
end
ret = false
@scene.pbItemMenu(idxBattler,firstAction) { |item,useType,idxPkmn,idxMove,itemScene|
@scene.pbItemMenu(idxBattler, firstAction) { |item, useType, idxPkmn, idxMove, itemScene|
next false if !item
battler = pkmn = nil
case useType
when 1, 2 # Use on Pokémon/Pokémon's move
next false if !ItemHandlers.hasBattleUseOnPokemon(item)
battler = pbFindBattler(idxPkmn,idxBattler)
battler = pbFindBattler(idxPkmn, idxBattler)
pkmn = pbParty(idxBattler)[idxPkmn]
next false if !pbCanUseItemOnPokemon?(item,pkmn,battler,itemScene)
next false if !pbCanUseItemOnPokemon?(item, pkmn, battler, itemScene)
when 3 # Use on battler
next false if !ItemHandlers.hasBattleUseOnBattler(item)
battler = pbFindBattler(idxPkmn,idxBattler)
battler = pbFindBattler(idxPkmn, idxBattler)
pkmn = battler.pokemon if battler
next false if !pbCanUseItemOnPokemon?(item,pkmn,battler,itemScene)
next false if !pbCanUseItemOnPokemon?(item, pkmn, battler, itemScene)
when 4 # Poké Balls
next false if idxPkmn<0
next false if idxPkmn < 0
battler = @battlers[idxPkmn]
pkmn = battler.pokemon if battler
when 5 # No target (Poké Doll, Guard Spec., Launcher items)
@@ -129,8 +129,8 @@ class Battle
end
next false if !pkmn
next false if !ItemHandlers.triggerCanUseInBattle(item,
pkmn,battler,idxMove,firstAction,self,itemScene)
next false if !pbRegisterItem(idxBattler,item,idxPkmn,idxMove)
pkmn, battler, idxMove, firstAction, self, itemScene)
next false if !pbRegisterItem(idxBattler, item, idxPkmn, idxMove)
ret = true
next true
}
@@ -140,16 +140,16 @@ class Battle
def pbPartyMenu(idxBattler)
ret = -1
if @debug
ret = @battleAI.pbDefaultChooseNewEnemy(idxBattler,pbParty(idxBattler))
ret = @battleAI.pbDefaultChooseNewEnemy(idxBattler, pbParty(idxBattler))
else
ret = pbPartyScreen(idxBattler,false,true,true)
ret = pbPartyScreen(idxBattler, false, true, true)
end
return ret>=0
return ret >= 0
end
def pbRunMenu(idxBattler)
# Regardless of succeeding or failing to run, stop choosing actions
return pbRun(idxBattler)!=0
return pbRun(idxBattler) != 0
end
def pbCallMenu(idxBattler)
@@ -172,19 +172,19 @@ class Battle
def pbCommandPhase
@scene.pbBeginCommandPhase
# Reset choices if commands can be shown
@battlers.each_with_index do |b,i|
@battlers.each_with_index do |b, i|
next if !b
pbClearChoice(i) if pbCanShowCommands?(i)
end
# Reset choices to perform Mega Evolution if it wasn't done somehow
for side in 0...2
@megaEvolution[side].each_with_index do |megaEvo,i|
@megaEvolution[side][i] = -1 if megaEvo>=0
@megaEvolution[side].each_with_index do |megaEvo, i|
@megaEvolution[side][i] = -1 if megaEvo >= 0
end
end
# Choose actions for the round (player first, then AI)
pbCommandPhaseLoop(true) # Player chooses their actions
return if @decision!=0 # Battle ended, stop choosing actions
return if @decision != 0 # Battle ended, stop choosing actions
pbCommandPhaseLoop(false) # AI chooses their actions
end
@@ -194,11 +194,11 @@ class Battle
actioned = []
idxBattler = -1
loop do
break if @decision!=0 # Battle ended, stop choosing actions
break if @decision != 0 # Battle ended, stop choosing actions
idxBattler += 1
break if idxBattler>=@battlers.length
next if !@battlers[idxBattler] || pbOwnedByPlayer?(idxBattler)!=isPlayer
next if @choices[idxBattler][0]!=:None # Action is forced, can't choose one
break if idxBattler >= @battlers.length
next if !@battlers[idxBattler] || pbOwnedByPlayer?(idxBattler) != isPlayer
next if @choices[idxBattler][0] != :None # Action is forced, can't choose one
next if !pbCanShowCommands?(idxBattler) # Action is forced, can't choose one
# AI controls this battler
if @controlPlayer || !pbOwnedByPlayer?(idxBattler)
@@ -209,17 +209,17 @@ class Battle
actioned.push(idxBattler)
commandsEnd = false # Whether to cancel choosing all other actions this round
loop do
cmd = pbCommandMenu(idxBattler,actioned.length==1)
cmd = pbCommandMenu(idxBattler, actioned.length == 1)
# If being Sky Dropped, can't do anything except use a move
if cmd>0 && @battlers[idxBattler].effects[PBEffects::SkyDrop]>=0
pbDisplay(_INTL("Sky Drop won't let {1} go!",@battlers[idxBattler].pbThis(true)))
if cmd > 0 && @battlers[idxBattler].effects[PBEffects::SkyDrop] >= 0
pbDisplay(_INTL("Sky Drop won't let {1} go!", @battlers[idxBattler].pbThis(true)))
next
end
case cmd
when 0 # Fight
break if pbFightMenu(idxBattler)
when 1 # Bag
if pbItemMenu(idxBattler,actioned.length==1)
if pbItemMenu(idxBattler, actioned.length == 1)
commandsEnd = true if pbItemUsesAllActions?(@choices[idxBattler][1])
break
end
@@ -240,10 +240,10 @@ class Battle
pbDebugMenu
next
when -1 # Go back to previous battler's action choice
next if actioned.length<=1
next if actioned.length <= 1
actioned.pop # Forget this battler was done
idxBattler = actioned.last-1
pbCancelChoice(idxBattler+1) # Clear the previous battler's choice
idxBattler = actioned.last - 1
pbCancelChoice(idxBattler + 1) # Clear the previous battler's choice
actioned.pop # Forget the previous battler was done
break
end

View File

@@ -15,7 +15,7 @@ class Battle
def pbAttackPhaseCall
pbPriority.each do |b|
next unless @choices[b.index][0]==:Call && !b.fainted?
next unless @choices[b.index][0] == :Call && !b.fainted?
b.lastMoveFailed = false # Counts as a successful move for Stomping Tantrum
pbCall(b.index)
end
@@ -25,31 +25,31 @@ class Battle
@switching = true
pbPriority.each do |b|
next if b.fainted? || !b.opposes?(idxSwitcher) # Shouldn't hit an ally
next if b.movedThisRound? || !pbChoseMoveFunctionCode?(b.index,"PursueSwitchingFoe")
next if b.movedThisRound? || !pbChoseMoveFunctionCode?(b.index, "PursueSwitchingFoe")
# Check whether Pursuit can be used
next unless pbMoveCanTarget?(b.index,idxSwitcher,@choices[b.index][2].pbTarget(b))
next unless pbCanChooseMove?(b.index,@choices[b.index][1],false)
next unless pbMoveCanTarget?(b.index, idxSwitcher, @choices[b.index][2].pbTarget(b))
next unless pbCanChooseMove?(b.index, @choices[b.index][1], false)
next if b.status == :SLEEP || b.status == :FROZEN
next if b.effects[PBEffects::SkyDrop]>=0
next if b.effects[PBEffects::SkyDrop] >= 0
next if b.hasActiveAbility?(:TRUANT) && b.effects[PBEffects::Truant]
# Mega Evolve
if !b.wild?
owner = pbGetOwnerIndexFromBattlerIndex(b.index)
pbMegaEvolve(b.index) if @megaEvolution[b.idxOwnSide][owner]==b.index
pbMegaEvolve(b.index) if @megaEvolution[b.idxOwnSide][owner] == b.index
end
# Use Pursuit
@choices[b.index][3] = idxSwitcher # Change Pursuit's target
if b.pbProcessTurn(@choices[b.index],false)
if b.pbProcessTurn(@choices[b.index], false)
b.effects[PBEffects::Pursuit] = true
end
break if @decision>0 || @battlers[idxSwitcher].fainted?
break if @decision > 0 || @battlers[idxSwitcher].fainted?
end
@switching = false
end
def pbAttackPhaseSwitch
pbPriority.each do |b|
next unless @choices[b.index][0]==:SwitchOut && !b.fainted?
next unless @choices[b.index][0] == :SwitchOut && !b.fainted?
idxNewPkmn = @choices[b.index][1] # Party index of Pokémon to switch to
b.lastMoveFailed = false # Counts as a successful move for Stomping Tantrum
@lastMoveUser = b.index
@@ -57,13 +57,13 @@ class Battle
pbMessageOnRecall(b)
# Pursuit interrupts switching
pbPursuit(b.index)
return if @decision>0
return if @decision > 0
# Switch Pokémon
allBattlers.each do |b|
b.droppedBelowHalfHP = false
b.statsDropped = false
end
pbRecallAndReplace(b.index,idxNewPkmn)
pbRecallAndReplace(b.index, idxNewPkmn)
pbOnBattlerEnteringBattle(b.index, true)
end
end
@@ -94,9 +94,9 @@ class Battle
def pbAttackPhaseMegaEvolution
pbPriority.each do |b|
next if b.wild?
next unless @choices[b.index][0]==:UseMove && !b.fainted?
next unless @choices[b.index][0] == :UseMove && !b.fainted?
owner = pbGetOwnerIndexFromBattlerIndex(b.index)
next if @megaEvolution[b.idxOwnSide][owner]!=b.index
next if @megaEvolution[b.idxOwnSide][owner] != b.index
pbMegaEvolve(b.index)
end
end
@@ -104,7 +104,7 @@ class Battle
def pbAttackPhaseMoves
# Show charging messages (Focus Punch)
pbPriority.each do |b|
next unless @choices[b.index][0]==:UseMove && !b.fainted?
next unless @choices[b.index][0] == :UseMove && !b.fainted?
next if b.movedThisRound?
@choices[b.index][2].pbDisplayChargeMessage(b)
end
@@ -115,28 +115,28 @@ class Battle
advance = false
priority.each do |b|
next unless b.effects[PBEffects::MoveNext] && !b.fainted?
next unless @choices[b.index][0]==:UseMove || @choices[b.index][0]==:Shift
next unless @choices[b.index][0] == :UseMove || @choices[b.index][0] == :Shift
next if b.movedThisRound?
advance = b.pbProcessTurn(@choices[b.index])
break if advance
end
return if @decision>0
return if @decision > 0
next if advance
# Regular priority order
priority.each do |b|
next if b.effects[PBEffects::Quash]>0 || b.fainted?
next unless @choices[b.index][0]==:UseMove || @choices[b.index][0]==:Shift
next if b.effects[PBEffects::Quash] > 0 || b.fainted?
next unless @choices[b.index][0] == :UseMove || @choices[b.index][0] == :Shift
next if b.movedThisRound?
advance = b.pbProcessTurn(@choices[b.index])
break if advance
end
return if @decision>0
return if @decision > 0
next if advance
# Quashed
if Settings::MECHANICS_GENERATION >= 8
priority.each do |b|
next unless b.effects[PBEffects::Quash] > 0 && !b.fainted?
next unless @choices[b.index][0]==:UseMove || @choices[b.index][0]==:Shift
next unless @choices[b.index][0] == :UseMove || @choices[b.index][0] == :Shift
next if b.movedThisRound?
advance = b.pbProcessTurn(@choices[b.index])
break if advance
@@ -147,9 +147,9 @@ class Battle
quashLevel += 1
moreQuash = false
priority.each do |b|
moreQuash = true if b.effects[PBEffects::Quash]>quashLevel
next unless b.effects[PBEffects::Quash]==quashLevel && !b.fainted?
next unless @choices[b.index][0]==:UseMove || @choices[b.index][0]==:Shift
moreQuash = true if b.effects[PBEffects::Quash] > quashLevel
next unless b.effects[PBEffects::Quash] == quashLevel && !b.fainted?
next unless @choices[b.index][0] == :UseMove || @choices[b.index][0] == :Shift
next if b.movedThisRound?
advance = b.pbProcessTurn(@choices[b.index])
break
@@ -157,12 +157,12 @@ class Battle
break if advance || !moreQuash
end
end
return if @decision>0
return if @decision > 0
next if advance
# Check for all done
priority.each do |b|
if !b.fainted? && !b.movedThisRound?
advance = true if @choices[b.index][0]==:UseMove || @choices[b.index][0]==:Shift
advance = true if @choices[b.index][0] == :UseMove || @choices[b.index][0] == :Shift
end
break if advance
end
@@ -178,15 +178,15 @@ class Battle
def pbAttackPhase
@scene.pbBeginAttackPhase
# Reset certain effects
@battlers.each_with_index do |b,i|
@battlers.each_with_index do |b, i|
next if !b
b.turnCount += 1 if !b.fainted?
@successStates[i].clear
if @choices[i][0]!=:UseMove && @choices[i][0]!=:Shift && @choices[i][0]!=:SwitchOut
if @choices[i][0] != :UseMove && @choices[i][0] != :Shift && @choices[i][0] != :SwitchOut
b.effects[PBEffects::DestinyBond] = false
b.effects[PBEffects::Grudge] = false
end
b.effects[PBEffects::Rage] = false if !pbChoseMoveFunctionCode?(i,"StartRaiseUserAtk1WhenDamaged")
b.effects[PBEffects::Rage] = false if !pbChoseMoveFunctionCode?(i, "StartRaiseUserAtk1WhenDamaged")
end
PBDebug.log("")
# Calculate move order for this round
@@ -195,9 +195,9 @@ class Battle
pbAttackPhasePriorityChangeMessages
pbAttackPhaseCall
pbAttackPhaseSwitch
return if @decision>0
return if @decision > 0
pbAttackPhaseItems
return if @decision>0
return if @decision > 0
pbAttackPhaseMegaEvolution
pbAttackPhaseMoves
end

View File

@@ -2,27 +2,27 @@ class Battle
#=============================================================================
# Decrement effect counters
#=============================================================================
def pbEORCountDownBattlerEffect(priority,effect)
def pbEORCountDownBattlerEffect(priority, effect)
priority.each do |b|
next if b.fainted? || b.effects[effect]==0
next if b.fainted? || b.effects[effect] == 0
b.effects[effect] -= 1
yield b if block_given? && b.effects[effect]==0
yield b if block_given? && b.effects[effect] == 0
end
end
def pbEORCountDownSideEffect(side,effect,msg)
if @sides[side].effects[effect]>0
def pbEORCountDownSideEffect(side, effect, msg)
if @sides[side].effects[effect] > 0
@sides[side].effects[effect] -= 1
pbDisplay(msg) if @sides[side].effects[effect]==0
pbDisplay(msg) if @sides[side].effects[effect] == 0
end
end
def pbEORCountDownFieldEffect(effect,msg)
if @field.effects[effect]>0
def pbEORCountDownFieldEffect(effect, msg)
if @field.effects[effect] > 0
@field.effects[effect] -= 1
if @field.effects[effect]==0
if @field.effects[effect] == 0
pbDisplay(msg)
if effect==PBEffects::MagicRoom
if effect == PBEffects::MagicRoom
pbPriority(true).each { |b| b.pbItemTerrainStatBoostCheck }
end
end
@@ -36,9 +36,9 @@ class Battle
# NOTE: Primordial weather doesn't need to be checked here, because if it
# could wear off here, it will have worn off already.
# Count down weather duration
@field.weatherDuration -= 1 if @field.weatherDuration>0
@field.weatherDuration -= 1 if @field.weatherDuration > 0
# Weather wears off
if @field.weatherDuration==0
if @field.weatherDuration == 0
case @field.weather
when :Sun then pbDisplay(_INTL("The sunlight faded."))
when :Rain then pbDisplay(_INTL("The rain stopped."))
@@ -50,7 +50,7 @@ class Battle
# Check for form changes caused by the weather changing
allBattlers.each { |b| b.pbCheckFormOnWeatherChange }
# Start up the default weather
pbStartWeather(nil,@field.defaultWeather) if @field.defaultWeather != :None
pbStartWeather(nil, @field.defaultWeather) if @field.defaultWeather != :None
return if @field.weather == :None
end
# Weather continues
@@ -77,23 +77,23 @@ class Battle
case b.effectiveWeather
when :Sandstorm
next if !b.takesSandstormDamage?
pbDisplay(_INTL("{1} is buffeted by the sandstorm!",b.pbThis))
pbDisplay(_INTL("{1} is buffeted by the sandstorm!", b.pbThis))
@scene.pbDamageAnimation(b)
b.pbReduceHP(b.totalhp/16,false)
b.pbReduceHP(b.totalhp / 16, false)
b.pbItemHPHealCheck
b.pbFaint if b.fainted?
when :Hail
next if !b.takesHailDamage?
pbDisplay(_INTL("{1} is buffeted by the hail!",b.pbThis))
pbDisplay(_INTL("{1} is buffeted by the hail!", b.pbThis))
@scene.pbDamageAnimation(b)
b.pbReduceHP(b.totalhp/16,false)
b.pbReduceHP(b.totalhp / 16, false)
b.pbItemHPHealCheck
b.pbFaint if b.fainted?
when :ShadowSky
next if !b.takesShadowSkyDamage?
pbDisplay(_INTL("{1} is hurt by the shadow sky!",b.pbThis))
pbDisplay(_INTL("{1} is hurt by the shadow sky!", b.pbThis))
@scene.pbDamageAnimation(b)
b.pbReduceHP(b.totalhp/16,false)
b.pbReduceHP(b.totalhp / 16, false)
b.pbItemHPHealCheck
b.pbFaint if b.fainted?
end
@@ -105,7 +105,7 @@ class Battle
#=============================================================================
def pbEORTerrain
# Count down terrain duration
@field.terrainDuration -= 1 if @field.terrainDuration>0
@field.terrainDuration -= 1 if @field.terrainDuration > 0
# Terrain wears off
if @field.terrain != :None && @field.terrainDuration == 0
case @field.terrain
@@ -149,7 +149,7 @@ class Battle
if !singleBattle?
swaps = [] # Each element is an array of two battler indices to swap
for side in 0...2
next if pbSideSize(side)==1 # Only battlers on sides of size 2+ need to move
next if pbSideSize(side) == 1 # Only battlers on sides of size 2+ need to move
# Check if any battler on this side is near any battler on the other side
anyNear = false
allSameSideBattlers(side).each do |b|
@@ -170,25 +170,25 @@ class Battle
# Get the position to move to
pos = -1
case pbSideSize(side)
when 2 then pos = [2,3,0,1][b.index] # The unoccupied position
when 3 then pos = (side==0) ? 2 : 3 # The centre position
when 2 then pos = [2, 3, 0, 1][b.index] # The unoccupied position
when 3 then pos = (side == 0) ? 2 : 3 # The centre position
end
next if pos<0
next if pos < 0
# Can't move if the same trainer doesn't control both positions
idxOwner = pbGetOwnerIndexFromBattlerIndex(b.index)
next if pbGetOwnerIndexFromBattlerIndex(pos)!=idxOwner
swaps.push([b.index,pos])
next if pbGetOwnerIndexFromBattlerIndex(pos) != idxOwner
swaps.push([b.index, pos])
end
end
# Move battlers around
swaps.each do |pair|
next if pbSideSize(pair[0])==2 && swaps.length>1
next if !pbSwapBattlers(pair[0],pair[1])
next if pbSideSize(pair[0]) == 2 && swaps.length > 1
next if !pbSwapBattlers(pair[0], pair[1])
case pbSideSize(side)
when 2
pbDisplay(_INTL("{1} moved across!",@battlers[pair[1]].pbThis))
pbDisplay(_INTL("{1} moved across!", @battlers[pair[1]].pbThis))
when 3
pbDisplay(_INTL("{1} moved to the center!",@battlers[pair[1]].pbThis))
pbDisplay(_INTL("{1} moved to the center!", @battlers[pair[1]].pbThis))
end
end
end
@@ -207,36 +207,36 @@ class Battle
# Weather
pbEORWeather(priority)
# Future Sight/Doom Desire
@positions.each_with_index do |pos,idxPos|
next if !pos || pos.effects[PBEffects::FutureSightCounter]==0
@positions.each_with_index do |pos, idxPos|
next if !pos || pos.effects[PBEffects::FutureSightCounter] == 0
pos.effects[PBEffects::FutureSightCounter] -= 1
next if pos.effects[PBEffects::FutureSightCounter]>0
next if pos.effects[PBEffects::FutureSightCounter] > 0
next if !@battlers[idxPos] || @battlers[idxPos].fainted? # No target
moveUser = nil
allBattlers.each do |b|
next if b.opposes?(pos.effects[PBEffects::FutureSightUserIndex])
next if b.pokemonIndex!=pos.effects[PBEffects::FutureSightUserPartyIndex]
next if b.pokemonIndex != pos.effects[PBEffects::FutureSightUserPartyIndex]
moveUser = b
break
end
next if moveUser && moveUser.index==idxPos # Target is the user
next if moveUser && moveUser.index == idxPos # Target is the user
if !moveUser # User isn't in battle, get it from the party
party = pbParty(pos.effects[PBEffects::FutureSightUserIndex])
pkmn = party[pos.effects[PBEffects::FutureSightUserPartyIndex]]
if pkmn && pkmn.able?
moveUser = Battler.new(self,pos.effects[PBEffects::FutureSightUserIndex])
moveUser.pbInitDummyPokemon(pkmn,pos.effects[PBEffects::FutureSightUserPartyIndex])
moveUser = Battler.new(self, pos.effects[PBEffects::FutureSightUserIndex])
moveUser.pbInitDummyPokemon(pkmn, pos.effects[PBEffects::FutureSightUserPartyIndex])
end
end
next if !moveUser # User is fainted
move = pos.effects[PBEffects::FutureSightMove]
pbDisplay(_INTL("{1} took the {2} attack!",@battlers[idxPos].pbThis,
pbDisplay(_INTL("{1} took the {2} attack!", @battlers[idxPos].pbThis,
GameData::Move.get(move).name))
# NOTE: Future Sight failing against the target here doesn't count towards
# Stomping Tantrum.
userLastMoveFailed = moveUser.lastMoveFailed
@futureSight = true
moveUser.pbUseMoveSimple(move,idxPos)
moveUser.pbUseMoveSimple(move, idxPos)
@futureSight = false
moveUser.lastMoveFailed = userLastMoveFailed
@battlers[idxPos].pbFaint if @battlers[idxPos].fainted?
@@ -246,20 +246,20 @@ class Battle
pos.effects[PBEffects::FutureSightUserPartyIndex] = -1
end
# Wish
@positions.each_with_index do |pos,idxPos|
next if !pos || pos.effects[PBEffects::Wish]==0
@positions.each_with_index do |pos, idxPos|
next if !pos || pos.effects[PBEffects::Wish] == 0
pos.effects[PBEffects::Wish] -= 1
next if pos.effects[PBEffects::Wish]>0
next if pos.effects[PBEffects::Wish] > 0
next if !@battlers[idxPos] || !@battlers[idxPos].canHeal?
wishMaker = pbThisEx(idxPos,pos.effects[PBEffects::WishMaker])
wishMaker = pbThisEx(idxPos, pos.effects[PBEffects::WishMaker])
@battlers[idxPos].pbRecoverHP(pos.effects[PBEffects::WishAmount])
pbDisplay(_INTL("{1}'s wish came true!",wishMaker))
pbDisplay(_INTL("{1}'s wish came true!", wishMaker))
end
# Sea of Fire damage (Fire Pledge + Grass Pledge combination)
for side in 0...2
next if sides[side].effects[PBEffects::SeaOfFire]==0
@battle.pbCommonAnimation("SeaOfFire") if side==0
@battle.pbCommonAnimation("SeaOfFireOpp") if side==1
next if sides[side].effects[PBEffects::SeaOfFire] == 0
@battle.pbCommonAnimation("SeaOfFire") if side == 0
@battle.pbCommonAnimation("SeaOfFireOpp") if side == 1
priority.each do |b|
next if b.opposes?(side)
next if !b.takesIndirectDamage? || b.pbHasType?(:FIRE)
@@ -275,8 +275,8 @@ class Battle
# Grassy Terrain (healing)
if @field.terrain == :Grassy && b.affectedByTerrain? && b.canHeal?
PBDebug.log("[Lingering effect] Grassy Terrain heals #{b.pbThis(true)}")
b.pbRecoverHP(b.totalhp/16)
pbDisplay(_INTL("{1}'s HP was restored.",b.pbThis))
b.pbRecoverHP(b.totalhp / 16)
pbDisplay(_INTL("{1}'s HP was restored.", b.pbThis))
end
# Healer, Hydration, Shed Skin
Battle::AbilityEffects.triggerEndOfRoundHealing(b.ability, b, self) if b.abilityActive?
@@ -309,27 +309,27 @@ class Battle
priority.each do |b|
next if !b.effects[PBEffects::AquaRing]
next if !b.canHeal?
hpGain = b.totalhp/16
hpGain = (hpGain*1.3).floor if b.hasActiveItem?(:BIGROOT)
hpGain = b.totalhp / 16
hpGain = (hpGain * 1.3).floor if b.hasActiveItem?(:BIGROOT)
b.pbRecoverHP(hpGain)
pbDisplay(_INTL("Aqua Ring restored {1}'s HP!",b.pbThis(true)))
pbDisplay(_INTL("Aqua Ring restored {1}'s HP!", b.pbThis(true)))
end
# Ingrain
priority.each do |b|
next if !b.effects[PBEffects::Ingrain]
next if !b.canHeal?
hpGain = b.totalhp/16
hpGain = (hpGain*1.3).floor if b.hasActiveItem?(:BIGROOT)
hpGain = b.totalhp / 16
hpGain = (hpGain * 1.3).floor if b.hasActiveItem?(:BIGROOT)
b.pbRecoverHP(hpGain)
pbDisplay(_INTL("{1} absorbed nutrients with its roots!",b.pbThis))
pbDisplay(_INTL("{1} absorbed nutrients with its roots!", b.pbThis))
end
# Leech Seed
priority.each do |b|
next if b.effects[PBEffects::LeechSeed]<0
next if b.effects[PBEffects::LeechSeed] < 0
next if !b.takesIndirectDamage?
recipient = @battlers[b.effects[PBEffects::LeechSeed]]
next if !recipient || recipient.fainted?
pbCommonAnimation("LeechSeed",recipient,b)
pbCommonAnimation("LeechSeed", recipient, b)
b.pbTakeEffectDamage(b.totalhp / 8) { |hp_lost|
recipient.pbRecoverHPFromDrain(hp_lost, b,
_INTL("{1}'s health is sapped by Leech Seed!", b.pbThis))
@@ -339,38 +339,38 @@ class Battle
end
# Damage from Hyper Mode (Shadow Pokémon)
priority.each do |b|
next if !b.inHyperMode? || @choices[b.index][0]!=:UseMove
hpLoss = b.totalhp/24
next if !b.inHyperMode? || @choices[b.index][0] != :UseMove
hpLoss = b.totalhp / 24
@scene.pbDamageAnimation(b)
b.pbReduceHP(hpLoss,false)
pbDisplay(_INTL("The Hyper Mode attack hurts {1}!",b.pbThis(true)))
b.pbReduceHP(hpLoss, false)
pbDisplay(_INTL("The Hyper Mode attack hurts {1}!", b.pbThis(true)))
b.pbFaint if b.fainted?
end
# Damage from poisoning
priority.each do |b|
next if b.fainted?
next if b.status != :POISON
if b.statusCount>0
if b.statusCount > 0
b.effects[PBEffects::Toxic] += 1
b.effects[PBEffects::Toxic] = 16 if b.effects[PBEffects::Toxic]>16
b.effects[PBEffects::Toxic] = 16 if b.effects[PBEffects::Toxic] > 16
end
if b.hasActiveAbility?(:POISONHEAL)
if b.canHeal?
anim_name = GameData::Status.get(:POISON).animation
pbCommonAnimation(anim_name, b) if anim_name
pbShowAbilitySplash(b)
b.pbRecoverHP(b.totalhp/8)
b.pbRecoverHP(b.totalhp / 8)
if Scene::USE_ABILITY_SPLASH
pbDisplay(_INTL("{1}'s HP was restored.",b.pbThis))
pbDisplay(_INTL("{1}'s HP was restored.", b.pbThis))
else
pbDisplay(_INTL("{1}'s {2} restored its HP.",b.pbThis,b.abilityName))
pbDisplay(_INTL("{1}'s {2} restored its HP.", b.pbThis, b.abilityName))
end
pbHideAbilitySplash(b)
end
elsif b.takesIndirectDamage?
b.droppedBelowHalfHP = false
dmg = (b.statusCount==0) ? b.totalhp/8 : b.totalhp*b.effects[PBEffects::Toxic]/16
b.pbContinueStatus { b.pbReduceHP(dmg,false) }
dmg = (b.statusCount == 0) ? b.totalhp / 8 : b.totalhp * b.effects[PBEffects::Toxic] / 16
b.pbContinueStatus { b.pbReduceHP(dmg, false) }
b.pbItemHPHealCheck
b.pbAbilitiesOnDamageTaken
b.pbFaint if b.fainted?
@@ -381,9 +381,9 @@ class Battle
priority.each do |b|
next if b.status != :BURN || !b.takesIndirectDamage?
b.droppedBelowHalfHP = false
dmg = (Settings::MECHANICS_GENERATION >= 7) ? b.totalhp/16 : b.totalhp/8
dmg = (dmg/2.0).round if b.hasActiveAbility?(:HEATPROOF)
b.pbContinueStatus { b.pbReduceHP(dmg,false) }
dmg = (Settings::MECHANICS_GENERATION >= 7) ? b.totalhp / 16 : b.totalhp / 8
dmg = (dmg / 2.0).round if b.hasActiveAbility?(:HEATPROOF)
b.pbContinueStatus { b.pbReduceHP(dmg, false) }
b.pbItemHPHealCheck
b.pbAbilitiesOnDamageTaken
b.pbFaint if b.fainted?
@@ -406,11 +406,11 @@ class Battle
end
# Trapping attacks (Bind/Clamp/Fire Spin/Magma Storm/Sand Tomb/Whirlpool/Wrap)
priority.each do |b|
next if b.fainted? || b.effects[PBEffects::Trapping]==0
next if b.fainted? || b.effects[PBEffects::Trapping] == 0
b.effects[PBEffects::Trapping] -= 1
moveName = GameData::Move.get(b.effects[PBEffects::TrappingMove]).name
if b.effects[PBEffects::Trapping]==0
pbDisplay(_INTL("{1} was freed from {2}!",b.pbThis,moveName))
if b.effects[PBEffects::Trapping] == 0
pbDisplay(_INTL("{1} was freed from {2}!", b.pbThis, moveName))
else
case b.effects[PBEffects::TrappingMove]
when :BIND then pbCommonAnimation("Bind", b)
@@ -423,9 +423,9 @@ class Battle
else pbCommonAnimation("Wrap", b)
end
if b.takesIndirectDamage?
hpLoss = (Settings::MECHANICS_GENERATION >= 6) ? b.totalhp/8 : b.totalhp/16
hpLoss = (Settings::MECHANICS_GENERATION >= 6) ? b.totalhp / 8 : b.totalhp / 16
if @battlers[b.effects[PBEffects::TrappingUser]].hasActiveItem?(:BINDINGBAND)
hpLoss = (Settings::MECHANICS_GENERATION >= 6) ? b.totalhp/6 : b.totalhp/8
hpLoss = (Settings::MECHANICS_GENERATION >= 6) ? b.totalhp / 6 : b.totalhp / 8
end
@scene.pbDamageAnimation(b)
b.pbTakeEffectDamage(hpLoss, false) { |hp_lost|
@@ -443,18 +443,18 @@ class Battle
b.pbItemOnStatDropped
end
# Taunt
pbEORCountDownBattlerEffect(priority,PBEffects::Taunt) { |battler|
pbDisplay(_INTL("{1}'s taunt wore off!",battler.pbThis))
pbEORCountDownBattlerEffect(priority, PBEffects::Taunt) { |battler|
pbDisplay(_INTL("{1}'s taunt wore off!", battler.pbThis))
}
# Encore
priority.each do |b|
next if b.fainted? || b.effects[PBEffects::Encore]==0
next if b.fainted? || b.effects[PBEffects::Encore] == 0
idxEncoreMove = b.pbEncoredMoveIndex
if idxEncoreMove>=0
if idxEncoreMove >= 0
b.effects[PBEffects::Encore] -= 1
if b.effects[PBEffects::Encore]==0 || b.moves[idxEncoreMove].pp==0
if b.effects[PBEffects::Encore] == 0 || b.moves[idxEncoreMove].pp == 0
b.effects[PBEffects::Encore] = 0
pbDisplay(_INTL("{1}'s encore ended!",b.pbThis))
pbDisplay(_INTL("{1}'s encore ended!", b.pbThis))
end
else
PBDebug.log("[End of effect] #{b.pbThis}'s encore ended (encored move no longer known)")
@@ -463,29 +463,29 @@ class Battle
end
end
# Disable/Cursed Body
pbEORCountDownBattlerEffect(priority,PBEffects::Disable) { |battler|
pbEORCountDownBattlerEffect(priority, PBEffects::Disable) { |battler|
battler.effects[PBEffects::DisableMove] = nil
pbDisplay(_INTL("{1} is no longer disabled!",battler.pbThis))
pbDisplay(_INTL("{1} is no longer disabled!", battler.pbThis))
}
# Magnet Rise
pbEORCountDownBattlerEffect(priority,PBEffects::MagnetRise) { |battler|
pbDisplay(_INTL("{1}'s electromagnetism wore off!",battler.pbThis))
pbEORCountDownBattlerEffect(priority, PBEffects::MagnetRise) { |battler|
pbDisplay(_INTL("{1}'s electromagnetism wore off!", battler.pbThis))
}
# Telekinesis
pbEORCountDownBattlerEffect(priority,PBEffects::Telekinesis) { |battler|
pbDisplay(_INTL("{1} was freed from the telekinesis!",battler.pbThis))
pbEORCountDownBattlerEffect(priority, PBEffects::Telekinesis) { |battler|
pbDisplay(_INTL("{1} was freed from the telekinesis!", battler.pbThis))
}
# Heal Block
pbEORCountDownBattlerEffect(priority,PBEffects::HealBlock) { |battler|
pbDisplay(_INTL("{1}'s Heal Block wore off!",battler.pbThis))
pbEORCountDownBattlerEffect(priority, PBEffects::HealBlock) { |battler|
pbDisplay(_INTL("{1}'s Heal Block wore off!", battler.pbThis))
}
# Embargo
pbEORCountDownBattlerEffect(priority,PBEffects::Embargo) { |battler|
pbDisplay(_INTL("{1} can use items again!",battler.pbThis))
pbEORCountDownBattlerEffect(priority, PBEffects::Embargo) { |battler|
pbDisplay(_INTL("{1} can use items again!", battler.pbThis))
battler.pbItemTerrainStatBoostCheck
}
# Yawn
pbEORCountDownBattlerEffect(priority,PBEffects::Yawn) { |battler|
pbEORCountDownBattlerEffect(priority, PBEffects::Yawn) { |battler|
if battler.pbCanSleepYawn?
PBDebug.log("[Lingering effect] #{battler.pbThis} fell asleep because of Yawn")
battler.pbSleep
@@ -494,59 +494,59 @@ class Battle
# Perish Song
perishSongUsers = []
priority.each do |b|
next if b.fainted? || b.effects[PBEffects::PerishSong]==0
next if b.fainted? || b.effects[PBEffects::PerishSong] == 0
b.effects[PBEffects::PerishSong] -= 1
pbDisplay(_INTL("{1}'s perish count fell to {2}!",b.pbThis,b.effects[PBEffects::PerishSong]))
if b.effects[PBEffects::PerishSong]==0
pbDisplay(_INTL("{1}'s perish count fell to {2}!", b.pbThis, b.effects[PBEffects::PerishSong]))
if b.effects[PBEffects::PerishSong] == 0
perishSongUsers.push(b.effects[PBEffects::PerishSongUser])
b.pbReduceHP(b.hp)
end
b.pbItemHPHealCheck
b.pbFaint if b.fainted?
end
if perishSongUsers.length>0
if perishSongUsers.length > 0
# If all remaining Pokemon fainted by a Perish Song triggered by a single side
if (perishSongUsers.find_all { |idxBattler| opposes?(idxBattler) }.length==perishSongUsers.length) ||
(perishSongUsers.find_all { |idxBattler| !opposes?(idxBattler) }.length==perishSongUsers.length)
if (perishSongUsers.find_all { |idxBattler| opposes?(idxBattler) }.length == perishSongUsers.length) ||
(perishSongUsers.find_all { |idxBattler| !opposes?(idxBattler) }.length == perishSongUsers.length)
pbJudgeCheckpoint(@battlers[perishSongUsers[0]])
end
end
# Check for end of battle
if @decision>0
if @decision > 0
pbGainExp
return
end
for side in 0...2
# Reflect
pbEORCountDownSideEffect(side,PBEffects::Reflect,
_INTL("{1}'s Reflect wore off!",@battlers[side].pbTeam))
pbEORCountDownSideEffect(side, PBEffects::Reflect,
_INTL("{1}'s Reflect wore off!", @battlers[side].pbTeam))
# Light Screen
pbEORCountDownSideEffect(side,PBEffects::LightScreen,
_INTL("{1}'s Light Screen wore off!",@battlers[side].pbTeam))
pbEORCountDownSideEffect(side, PBEffects::LightScreen,
_INTL("{1}'s Light Screen wore off!", @battlers[side].pbTeam))
# Safeguard
pbEORCountDownSideEffect(side,PBEffects::Safeguard,
_INTL("{1} is no longer protected by Safeguard!",@battlers[side].pbTeam))
pbEORCountDownSideEffect(side, PBEffects::Safeguard,
_INTL("{1} is no longer protected by Safeguard!", @battlers[side].pbTeam))
# Mist
pbEORCountDownSideEffect(side,PBEffects::Mist,
_INTL("{1} is no longer protected by mist!",@battlers[side].pbTeam))
pbEORCountDownSideEffect(side, PBEffects::Mist,
_INTL("{1} is no longer protected by mist!", @battlers[side].pbTeam))
# Tailwind
pbEORCountDownSideEffect(side,PBEffects::Tailwind,
_INTL("{1}'s Tailwind petered out!",@battlers[side].pbTeam))
pbEORCountDownSideEffect(side, PBEffects::Tailwind,
_INTL("{1}'s Tailwind petered out!", @battlers[side].pbTeam))
# Lucky Chant
pbEORCountDownSideEffect(side,PBEffects::LuckyChant,
_INTL("{1}'s Lucky Chant wore off!",@battlers[side].pbTeam))
pbEORCountDownSideEffect(side, PBEffects::LuckyChant,
_INTL("{1}'s Lucky Chant wore off!", @battlers[side].pbTeam))
# Pledge Rainbow
pbEORCountDownSideEffect(side,PBEffects::Rainbow,
_INTL("The rainbow on {1}'s side disappeared!",@battlers[side].pbTeam(true)))
pbEORCountDownSideEffect(side, PBEffects::Rainbow,
_INTL("The rainbow on {1}'s side disappeared!", @battlers[side].pbTeam(true)))
# Pledge Sea of Fire
pbEORCountDownSideEffect(side,PBEffects::SeaOfFire,
_INTL("The sea of fire around {1} disappeared!",@battlers[side].pbTeam(true)))
pbEORCountDownSideEffect(side, PBEffects::SeaOfFire,
_INTL("The sea of fire around {1} disappeared!", @battlers[side].pbTeam(true)))
# Pledge Swamp
pbEORCountDownSideEffect(side,PBEffects::Swamp,
_INTL("The swamp around {1} disappeared!",@battlers[side].pbTeam(true)))
pbEORCountDownSideEffect(side, PBEffects::Swamp,
_INTL("The swamp around {1} disappeared!", @battlers[side].pbTeam(true)))
# Aurora Veil
pbEORCountDownSideEffect(side,PBEffects::AuroraVeil,
_INTL("{1}'s Aurora Veil wore off!",@battlers[side].pbTeam(true)))
pbEORCountDownSideEffect(side, PBEffects::AuroraVeil,
_INTL("{1}'s Aurora Veil wore off!", @battlers[side].pbTeam(true)))
end
# Trick Room
pbEORCountDownFieldEffect(PBEffects::TrickRoom,
@@ -572,27 +572,27 @@ class Battle
next if b.fainted?
# Hyper Mode (Shadow Pokémon)
if b.inHyperMode?
if pbRandom(100)<10
if pbRandom(100) < 10
b.pokemon.hyper_mode = false
pbDisplay(_INTL("{1} came to its senses!",b.pbThis))
pbDisplay(_INTL("{1} came to its senses!", b.pbThis))
else
pbDisplay(_INTL("{1} is in Hyper Mode!",b.pbThis))
pbDisplay(_INTL("{1} is in Hyper Mode!", b.pbThis))
end
end
# Uproar
if b.effects[PBEffects::Uproar]>0
if b.effects[PBEffects::Uproar] > 0
b.effects[PBEffects::Uproar] -= 1
if b.effects[PBEffects::Uproar]==0
pbDisplay(_INTL("{1} calmed down.",b.pbThis))
if b.effects[PBEffects::Uproar] == 0
pbDisplay(_INTL("{1} calmed down.", b.pbThis))
else
pbDisplay(_INTL("{1} is making an uproar!",b.pbThis))
pbDisplay(_INTL("{1} is making an uproar!", b.pbThis))
end
end
# Slow Start's end message
if b.effects[PBEffects::SlowStart]>0
if b.effects[PBEffects::SlowStart] > 0
b.effects[PBEffects::SlowStart] -= 1
if b.effects[PBEffects::SlowStart]==0
pbDisplay(_INTL("{1} finally got its act together!",b.pbThis))
if b.effects[PBEffects::SlowStart] == 0
pbDisplay(_INTL("{1} finally got its act together!", b.pbThis))
end
end
# Bad Dreams, Moody, Speed Boost
@@ -603,12 +603,12 @@ class Battle
Battle::AbilityEffects.triggerEndOfRoundGainItem(b.ability, b, self) if b.abilityActive?
end
pbGainExp
return if @decision>0
return if @decision > 0
# Form checks
priority.each { |b| b.pbCheckForm(true) }
# Switch Pokémon in if possible
pbEORSwitch
return if @decision>0
return if @decision > 0
# In battles with at least one side of size 3+, move battlers around if none
# are near to any foes
pbEORShiftDistantBattlers
@@ -617,7 +617,7 @@ class Battle
# Reset/count down battler-specific effects (no messages)
allBattlers.each do |b|
b.effects[PBEffects::BanefulBunker] = false
b.effects[PBEffects::Charge] -= 1 if b.effects[PBEffects::Charge]>0
b.effects[PBEffects::Charge] -= 1 if b.effects[PBEffects::Charge] > 0
b.effects[PBEffects::Counter] = -1
b.effects[PBEffects::CounterTarget] = -1
b.effects[PBEffects::Electrify] = false
@@ -627,12 +627,12 @@ class Battle
b.effects[PBEffects::FocusPunch] = false
b.effects[PBEffects::FollowMe] = 0
b.effects[PBEffects::HelpingHand] = false
b.effects[PBEffects::HyperBeam] -= 1 if b.effects[PBEffects::HyperBeam]>0
b.effects[PBEffects::HyperBeam] -= 1 if b.effects[PBEffects::HyperBeam] > 0
b.effects[PBEffects::KingsShield] = false
b.effects[PBEffects::LaserFocus] -= 1 if b.effects[PBEffects::LaserFocus]>0
if b.effects[PBEffects::LockOn]>0 # Also Mind Reader
b.effects[PBEffects::LaserFocus] -= 1 if b.effects[PBEffects::LaserFocus] > 0
if b.effects[PBEffects::LockOn] > 0 # Also Mind Reader
b.effects[PBEffects::LockOn] -= 1
b.effects[PBEffects::LockOnPos] = -1 if b.effects[PBEffects::LockOn]==0
b.effects[PBEffects::LockOnPos] = -1 if b.effects[PBEffects::LockOn] == 0
end
b.effects[PBEffects::MagicBounce] = false
b.effects[PBEffects::MagicCoat] = false
@@ -649,7 +649,7 @@ class Battle
b.effects[PBEffects::Snatch] = 0
b.effects[PBEffects::SpikyShield] = false
b.effects[PBEffects::Spotlight] = 0
b.effects[PBEffects::ThroatChop] -= 1 if b.effects[PBEffects::ThroatChop]>0
b.effects[PBEffects::ThroatChop] -= 1 if b.effects[PBEffects::ThroatChop] > 0
b.lastHPLost = 0
b.lastHPLostFromFoe = 0
b.droppedBelowHalfHP = false
@@ -677,7 +677,7 @@ class Battle
end
# Reset/count down field-specific effects (no messages)
@field.effects[PBEffects::IonDeluge] = false
@field.effects[PBEffects::FairyLock] -= 1 if @field.effects[PBEffects::FairyLock]>0
@field.effects[PBEffects::FairyLock] -= 1 if @field.effects[PBEffects::FairyLock] > 0
@field.effects[PBEffects::FusionBolt] = false
@field.effects[PBEffects::FusionFlare] = false
@endOfRound = false

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

View File

@@ -67,7 +67,7 @@ class Battle::Move
def pbTarget(_user); return GameData::Target.get(@target); end
def total_pp
return @total_pp if @total_pp && @total_pp>0 # Usually undefined
return @total_pp if @total_pp && @total_pp > 0 # Usually undefined
return @realMove.total_pp if @realMove
return 0
end
@@ -75,7 +75,7 @@ class Battle::Move
# NOTE: This method is only ever called while using a move (and also by the
# AI), so using @calcType here is acceptable.
def physicalMove?(thisType = nil)
return (@category==0) if Settings::MOVE_CATEGORY_PER_MOVE
return (@category == 0) if Settings::MOVE_CATEGORY_PER_MOVE
thisType ||= @calcType
thisType ||= @type
return true if !thisType
@@ -85,15 +85,15 @@ class Battle::Move
# NOTE: This method is only ever called while using a move (and also by the
# AI), so using @calcType here is acceptable.
def specialMove?(thisType = nil)
return (@category==1) if Settings::MOVE_CATEGORY_PER_MOVE
return (@category == 1) if Settings::MOVE_CATEGORY_PER_MOVE
thisType ||= @calcType
thisType ||= @type
return false if !thisType
return GameData::Type.get(thisType).special?
end
def damagingMove?; return @category!=2; end
def statusMove?; return @category==2; end
def damagingMove?; return @category != 2; end
def statusMove?; return @category == 2; end
def pbPriority(user); return @priority; end
@@ -135,7 +135,7 @@ class Battle::Move
# Causes perfect accuracy (param=1) and double damage (param=2).
def tramplesMinimize?(_param = 1); return false; end
def nonLethal?(_user,_target); return false; end # For False Swipe
def nonLethal?(_user, _target); return false; end # For False Swipe
def ignoresSubstitute?(user) # user is the Pokémon using this move
if Settings::MECHANICS_GENERATION >= 6

View File

@@ -2,14 +2,14 @@ class Battle::Move
#=============================================================================
# Effect methods per move usage
#=============================================================================
def pbCanChooseMove?(user,commandPhase,showMessages); return true; end # For Belch
def pbCanChooseMove?(user, commandPhase, showMessages); return true; end # For Belch
def pbDisplayChargeMessage(user); end # For Focus Punch/shell Trap/Beak Blast
def pbOnStartUse(user,targets); end
def pbAddTarget(targets,user); end # For Counter, etc. and Bide
def pbOnStartUse(user, targets); end
def pbAddTarget(targets, user); end # For Counter, etc. and Bide
def pbModifyTargets(targets, user); end # For Dragon Darts
# Reset move usage counters (child classes can increment them).
def pbChangeUsageCounters(user,specialUsage)
def pbChangeUsageCounters(user, specialUsage)
user.effects[PBEffects::FuryCutter] = 0
user.effects[PBEffects::ParentalBond] = 0
user.effects[PBEffects::ProtectRate] = 1
@@ -18,11 +18,11 @@ class Battle::Move
end
def pbDisplayUseMessage(user)
@battle.pbDisplayBrief(_INTL("{1} used {2}!",user.pbThis,@name))
@battle.pbDisplayBrief(_INTL("{1} used {2}!", user.pbThis, @name))
end
def pbShowFailMessages?(targets); return true; end
def pbMissMessage(user,target); return false; end
def pbMissMessage(user, target); return false; end
#=============================================================================
#
@@ -42,9 +42,9 @@ class Battle::Move
# The maximum number of hits in a round this move will actually perform. This
# can be 1 for Beat Up, and can be 2 for any moves affected by Parental Bond.
def pbNumHits(user,targets)
def pbNumHits(user, targets)
if user.hasActiveAbility?(:PARENTALBOND) && pbDamagingMove? &&
!chargingTurnMove? && targets.length==1
!chargingTurnMove? && targets.length == 1
# Record that Parental Bond applies, to weaken the second attack
user.effects[PBEffects::ParentalBond] = 3
return 2
@@ -55,29 +55,29 @@ class Battle::Move
#=============================================================================
# Effect methods per hit
#=============================================================================
def pbOverrideSuccessCheckPerHit(user,target); return false; end
def pbOverrideSuccessCheckPerHit(user, target); return false; end
def pbCrashDamage(user); end
def pbInitialEffect(user,targets,hitNum); end
def pbInitialEffect(user, targets, hitNum); end
def pbDesignateTargetsForHit(targets, hitNum); return targets; end # For Dragon Darts
def pbRepeatHit?; return false; end # For Dragon Darts
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
return if !showAnimation
if user.effects[PBEffects::ParentalBond]==1
@battle.pbCommonAnimation("ParentalBond",user,targets)
if user.effects[PBEffects::ParentalBond] == 1
@battle.pbCommonAnimation("ParentalBond", user, targets)
else
@battle.pbAnimation(id,user,targets,hitNum)
@battle.pbAnimation(id, user, targets, hitNum)
end
end
def pbSelfKO(user); end
def pbEffectWhenDealingDamage(user,target); end
def pbEffectAgainstTarget(user,target); end
def pbEffectWhenDealingDamage(user, target); end
def pbEffectAgainstTarget(user, target); end
def pbEffectGeneral(user); end
def pbAdditionalEffect(user,target); end
def pbEffectAfterAllHits(user,target); end # Move effects that occur after all hits
def pbAdditionalEffect(user, target); end
def pbEffectAfterAllHits(user, target); end # Move effects that occur after all hits
def pbSwitchOutTargetEffect(user, targets, numHits, switched_battlers); end
def pbEndOfMoveUsageEffect(user,targets,numHits,switchedBattlers); end
def pbEndOfMoveUsageEffect(user, targets, numHits, switchedBattlers); end
#=============================================================================
# Check if target is immune to the move because of its ability
@@ -96,7 +96,7 @@ class Battle::Move
# Move failure checks
#=============================================================================
# Check whether the move fails completely due to move-specific requirements.
def pbMoveFailed?(user,targets); return false; end
def pbMoveFailed?(user, targets); return false; end
# Checks whether the move will be ineffective against the target.
def pbFailsAgainstTarget?(user, target, show_message); return false; end
@@ -114,24 +114,24 @@ class Battle::Move
end
def pbMoveFailedTargetAlreadyMoved?(target, showMessage = true)
if (@battle.choices[target.index][0]!=:UseMove &&
@battle.choices[target.index][0]!=:Shift) || target.movedThisRound?
if (@battle.choices[target.index][0] != :UseMove &&
@battle.choices[target.index][0] != :Shift) || target.movedThisRound?
@battle.pbDisplay(_INTL("But it failed!")) if showMessage
return true
end
return false
end
def pbMoveFailedAromaVeil?(user,target,showMessage = true)
def pbMoveFailedAromaVeil?(user, target, showMessage = true)
return false if @battle.moldBreaker
if target.hasActiveAbility?(:AROMAVEIL)
if showMessage
@battle.pbShowAbilitySplash(target)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} is unaffected!",target.pbThis))
@battle.pbDisplay(_INTL("{1} is unaffected!", target.pbThis))
else
@battle.pbDisplay(_INTL("{1} is unaffected because of its {2}!",
target.pbThis,target.abilityName))
target.pbThis, target.abilityName))
end
@battle.pbHideAbilitySplash(target)
end
@@ -142,10 +142,10 @@ class Battle::Move
if showMessage
@battle.pbShowAbilitySplash(target)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} is unaffected!",target.pbThis))
@battle.pbDisplay(_INTL("{1} is unaffected!", target.pbThis))
else
@battle.pbDisplay(_INTL("{1} is unaffected because of {2}'s {3}!",
target.pbThis,b.pbThis(true),b.abilityName))
target.pbThis, b.pbThis(true), b.abilityName))
end
@battle.pbHideAbilitySplash(target)
end
@@ -157,10 +157,10 @@ class Battle::Move
#=============================================================================
# Weaken the damage dealt (doesn't actually change a battler's HP)
#=============================================================================
def pbCheckDamageAbsorption(user,target)
def pbCheckDamageAbsorption(user, target)
# Substitute will take the damage
if target.effects[PBEffects::Substitute]>0 && !ignoresSubstitute?(user) &&
(!user || user.index!=target.index)
if target.effects[PBEffects::Substitute] > 0 && !ignoresSubstitute?(user) &&
(!user || user.index != target.index)
target.damageState.substitute = true
return
end
@@ -172,17 +172,17 @@ class Battle::Move
end
# Disguise will take the damage
if !@battle.moldBreaker && target.isSpecies?(:MIMIKYU) &&
target.form==0 && target.ability == :DISGUISE
target.form == 0 && target.ability == :DISGUISE
target.damageState.disguise = true
return
end
end
def pbReduceDamage(user,target)
def pbReduceDamage(user, target)
damage = target.damageState.calcDamage
# Substitute takes the damage
if target.damageState.substitute
damage = target.effects[PBEffects::Substitute] if damage>target.effects[PBEffects::Substitute]
damage = target.effects[PBEffects::Substitute] if damage > target.effects[PBEffects::Substitute]
target.damageState.hpLost = damage
target.damageState.totalHPLost += damage
return
@@ -190,22 +190,22 @@ class Battle::Move
# Disguise/Ice Face takes the damage
return if target.damageState.disguise || target.damageState.iceFace
# Target takes the damage
if damage>=target.hp
if damage >= target.hp
damage = target.hp
# Survive a lethal hit with 1 HP effects
if nonLethal?(user,target)
if nonLethal?(user, target)
damage -= 1
elsif target.effects[PBEffects::Endure]
target.damageState.endured = true
damage -= 1
elsif damage==target.totalhp
elsif damage == target.totalhp
if target.hasActiveAbility?(:STURDY) && !@battle.moldBreaker
target.damageState.sturdy = true
damage -= 1
elsif target.hasActiveItem?(:FOCUSSASH) && target.hp==target.totalhp
elsif target.hasActiveItem?(:FOCUSSASH) && target.hp == target.totalhp
target.damageState.focusSash = true
damage -= 1
elsif target.hasActiveItem?(:FOCUSBAND) && @battle.pbRandom(100)<10
elsif target.hasActiveItem?(:FOCUSBAND) && @battle.pbRandom(100) < 10
target.damageState.focusBand = true
damage -= 1
elsif Settings::AFFECTION_EFFECTS && @battle.internalBattle &&
@@ -218,7 +218,7 @@ class Battle::Move
end
end
end
damage = 0 if damage<0
damage = 0 if damage < 0
target.damageState.hpLost = damage
target.damageState.totalHPLost += damage
end
@@ -238,14 +238,14 @@ class Battle::Move
# Animate the damage dealt, including lowering the HP
#=============================================================================
# Animate being damaged and losing HP (by a move)
def pbAnimateHitAndHPLost(user,targets)
def pbAnimateHitAndHPLost(user, targets)
# Animate allies first, then foes
animArray = []
for side in 0...2 # side here means "allies first, then foes"
targets.each do |b|
next if b.damageState.unaffected || b.damageState.hpLost==0
next if (side==0 && b.opposes?(user)) || (side==1 && !b.opposes?(user))
oldHP = b.hp+b.damageState.hpLost
next if b.damageState.unaffected || b.damageState.hpLost == 0
next if (side == 0 && b.opposes?(user)) || (side == 1 && !b.opposes?(user))
oldHP = b.hp + b.damageState.hpLost
PBDebug.log("[Move damage] #{b.pbThis} lost #{b.damageState.hpLost} HP (#{oldHP}=>#{b.hp})")
effectiveness = 0
if Effectiveness.resistant?(b.damageState.typeMod)
@@ -253,9 +253,9 @@ class Battle::Move
elsif Effectiveness.super_effective?(b.damageState.typeMod)
effectiveness = 2
end
animArray.push([b,oldHP,effectiveness])
animArray.push([b, oldHP, effectiveness])
end
if animArray.length>0
if animArray.length > 0
@battle.scene.pbHitAndHPLossAnimation(animArray)
animArray.clear
end
@@ -265,27 +265,27 @@ class Battle::Move
#=============================================================================
# Messages upon being hit
#=============================================================================
def pbEffectivenessMessage(user,target,numTargets = 1)
def pbEffectivenessMessage(user, target, numTargets = 1)
return if target.damageState.disguise || target.damageState.iceFace
if Effectiveness.super_effective?(target.damageState.typeMod)
if numTargets>1
@battle.pbDisplay(_INTL("It's super effective on {1}!",target.pbThis(true)))
if numTargets > 1
@battle.pbDisplay(_INTL("It's super effective on {1}!", target.pbThis(true)))
else
@battle.pbDisplay(_INTL("It's super effective!"))
end
elsif Effectiveness.not_very_effective?(target.damageState.typeMod)
if numTargets>1
@battle.pbDisplay(_INTL("It's not very effective on {1}...",target.pbThis(true)))
if numTargets > 1
@battle.pbDisplay(_INTL("It's not very effective on {1}...", target.pbThis(true)))
else
@battle.pbDisplay(_INTL("It's not very effective..."))
end
end
end
def pbHitEffectivenessMessages(user,target,numTargets = 1)
def pbHitEffectivenessMessages(user, target, numTargets = 1)
return if target.damageState.disguise || target.damageState.iceFace
if target.damageState.substitute
@battle.pbDisplay(_INTL("The substitute took damage for {1}!",target.pbThis(true)))
@battle.pbDisplay(_INTL("The substitute took damage for {1}!", target.pbThis(true)))
end
if target.damageState.critical
if $game_temp.party_critical_hits_dealt && user.pbOwnedByPlayer?
@@ -307,12 +307,12 @@ class Battle::Move
end
end
# Effectiveness message, for moves with 1 hit
if !multiHitMove? && user.effects[PBEffects::ParentalBond]==0
pbEffectivenessMessage(user,target,numTargets)
if !multiHitMove? && user.effects[PBEffects::ParentalBond] == 0
pbEffectivenessMessage(user, target, numTargets)
end
if target.damageState.substitute && target.effects[PBEffects::Substitute]==0
if target.damageState.substitute && target.effects[PBEffects::Substitute] == 0
target.effects[PBEffects::Substitute] = 0
@battle.pbDisplay(_INTL("{1}'s substitute faded!",target.pbThis))
@battle.pbDisplay(_INTL("{1}'s substitute faded!", target.pbThis))
end
end
@@ -322,10 +322,10 @@ class Battle::Move
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("Its disguise served it as a decoy!"))
else
@battle.pbDisplay(_INTL("{1}'s disguise served it as a decoy!",target.pbThis))
@battle.pbDisplay(_INTL("{1}'s disguise served it as a decoy!", target.pbThis))
end
@battle.pbHideAbilitySplash(target)
target.pbChangeForm(1,_INTL("{1}'s disguise was busted!",target.pbThis))
target.pbChangeForm(1, _INTL("{1}'s disguise was busted!", target.pbThis))
target.pbReduceHP(target.totalhp / 8, false) if Settings::MECHANICS_GENERATION >= 8
elsif target.damageState.iceFace
@battle.pbShowAbilitySplash(target)
@@ -335,36 +335,36 @@ class Battle::Move
target.pbChangeForm(1, _INTL("{1} transformed!", target.pbThis))
@battle.pbHideAbilitySplash(target)
elsif target.damageState.endured
@battle.pbDisplay(_INTL("{1} endured the hit!",target.pbThis))
@battle.pbDisplay(_INTL("{1} endured the hit!", target.pbThis))
elsif target.damageState.sturdy
@battle.pbShowAbilitySplash(target)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} endured the hit!",target.pbThis))
@battle.pbDisplay(_INTL("{1} endured the hit!", target.pbThis))
else
@battle.pbDisplay(_INTL("{1} hung on with Sturdy!",target.pbThis))
@battle.pbDisplay(_INTL("{1} hung on with Sturdy!", target.pbThis))
end
@battle.pbHideAbilitySplash(target)
elsif target.damageState.focusSash
@battle.pbCommonAnimation("UseItem",target)
@battle.pbDisplay(_INTL("{1} hung on using its Focus Sash!",target.pbThis))
@battle.pbCommonAnimation("UseItem", target)
@battle.pbDisplay(_INTL("{1} hung on using its Focus Sash!", target.pbThis))
target.pbConsumeItem
elsif target.damageState.focusBand
@battle.pbCommonAnimation("UseItem",target)
@battle.pbDisplay(_INTL("{1} hung on using its Focus Band!",target.pbThis))
@battle.pbCommonAnimation("UseItem", target)
@battle.pbDisplay(_INTL("{1} hung on using its Focus Band!", target.pbThis))
elsif target.damageState.affection_endured
@battle.pbDisplay(_INTL("{1} toughed it out so you wouldn't feel sad!", target.pbThis))
end
end
# Used by Counter/Mirror Coat/Metal Burst/Revenge/Focus Punch/Bide/Assurance.
def pbRecordDamageLost(user,target)
def pbRecordDamageLost(user, target)
damage = target.damageState.hpLost
# NOTE: In Gen 3 where a move's category depends on its type, Hidden Power
# is for some reason countered by Counter rather than Mirror Coat,
# regardless of its calculated type. Hence the following two lines of
# code.
moveType = nil
moveType = :NORMAL if @function=="TypeDependsOnUserIVs" # Hidden Power
moveType = :NORMAL if @function == "TypeDependsOnUserIVs" # Hidden Power
if physicalMove?(moveType)
target.effects[PBEffects::Counter] = damage
target.effects[PBEffects::CounterTarget] = user.index
@@ -372,7 +372,7 @@ class Battle::Move
target.effects[PBEffects::MirrorCoat] = damage
target.effects[PBEffects::MirrorCoatTarget] = user.index
end
if target.effects[PBEffects::Bide]>0
if target.effects[PBEffects::Bide] > 0
target.effects[PBEffects::BideDamage] += damage
target.effects[PBEffects::BideTarget] = user.index
end

View File

@@ -29,7 +29,7 @@ class Battle::Move
#=============================================================================
# Type effectiveness calculation
#=============================================================================
def pbCalcTypeModSingle(moveType,defType,user,target)
def pbCalcTypeModSingle(moveType, defType, user, target)
ret = Effectiveness.calculate_one(moveType, defType)
# Ring Target
if target.hasActiveItem?(:RINGTARGET)
@@ -57,7 +57,7 @@ class Battle::Move
return ret
end
def pbCalcTypeMod(moveType,user,target)
def pbCalcTypeMod(moveType, user, target)
return Effectiveness::NORMAL_EFFECTIVE if !moveType
return Effectiveness::NORMAL_EFFECTIVE if moveType == :GROUND &&
target.pbHasType?(:FLYING) &&
@@ -73,8 +73,8 @@ class Battle::Move
typeMods[0] = Effectiveness::SUPER_EFFECTIVE_ONE
end
else
tTypes.each_with_index do |type,i|
typeMods[i] = pbCalcTypeModSingle(moveType,type,user,target)
tTypes.each_with_index do |type, i|
typeMods[i] = pbCalcTypeModSingle(moveType, type, user, target)
end
end
# Multiply all effectivenesses together
@@ -87,15 +87,15 @@ class Battle::Move
#=============================================================================
# Accuracy check
#=============================================================================
def pbBaseAccuracy(user,target); return @accuracy; end
def pbBaseAccuracy(user, target); return @accuracy; end
# Accuracy calculations for one-hit KO moves are handled elsewhere.
def pbAccuracyCheck(user,target)
def pbAccuracyCheck(user, target)
# "Always hit" effects and "always hit" accuracy
return true if target.effects[PBEffects::Telekinesis]>0
return true if target.effects[PBEffects::Telekinesis] > 0
return true if target.effects[PBEffects::Minimize] && tramplesMinimize?(1)
baseAcc = pbBaseAccuracy(user,target)
return true if baseAcc==0
baseAcc = pbBaseAccuracy(user, target)
return true if baseAcc == 0
# Calculate all multiplier effects
modifiers = {}
modifiers[:base_accuracy] = baseAcc
@@ -103,14 +103,14 @@ class Battle::Move
modifiers[:evasion_stage] = target.stages[:EVASION]
modifiers[:accuracy_multiplier] = 1.0
modifiers[:evasion_multiplier] = 1.0
pbCalcAccuracyModifiers(user,target,modifiers)
pbCalcAccuracyModifiers(user, target, modifiers)
# Check if move can't miss
return true if modifiers[:base_accuracy] == 0
# Calculation
accStage = [[modifiers[:accuracy_stage], -6].max, 6].min + 6
evaStage = [[modifiers[:evasion_stage], -6].max, 6].min + 6
stageMul = [3,3,3,3,3,3, 3, 4,5,6,7,8,9]
stageDiv = [9,8,7,6,5,4, 3, 3,3,3,3,3,3]
stageMul = [3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9]
stageDiv = [9, 8, 7, 6, 5, 4, 3, 3, 3, 3, 3, 3, 3]
accuracy = 100.0 * stageMul[accStage] / stageDiv[accStage]
evasion = 100.0 * stageMul[evaStage] / stageDiv[evaStage]
accuracy = (accuracy * modifiers[:accuracy_multiplier]).round
@@ -128,29 +128,29 @@ class Battle::Move
return r < threshold
end
def pbCalcAccuracyModifiers(user,target,modifiers)
def pbCalcAccuracyModifiers(user, target, modifiers)
# Ability effects that alter accuracy calculation
if user.abilityActive?
Battle::AbilityEffects.triggerAccuracyCalcFromUser(user.ability,
modifiers,user,target,self,@calcType)
modifiers, user, target, self, @calcType)
end
user.allAllies.each do |b|
next if !b.abilityActive?
Battle::AbilityEffects.triggerAccuracyCalcFromAlly(b.ability,
modifiers,user,target,self,@calcType)
modifiers, user, target, self, @calcType)
end
if target.abilityActive? && !@battle.moldBreaker
Battle::AbilityEffects.triggerAccuracyCalcFromTarget(target.ability,
modifiers,user,target,self,@calcType)
modifiers, user, target, self, @calcType)
end
# Item effects that alter accuracy calculation
if user.itemActive?
Battle::ItemEffects.triggerAccuracyCalcFromUser(user.item,
modifiers,user,target,self,@calcType)
modifiers, user, target, self, @calcType)
end
if target.itemActive?
Battle::ItemEffects.triggerAccuracyCalcFromTarget(target.item,
modifiers,user,target,self,@calcType)
modifiers, user, target, self, @calcType)
end
# Other effects, inc. ones that set accuracy_multiplier or evasion_stage to
# specific values
@@ -172,41 +172,41 @@ class Battle::Move
# -1: Never a critical hit.
# 0: Calculate normally.
# 1: Always a critical hit.
def pbCritialOverride(user,target); return 0; end
def pbCritialOverride(user, target); return 0; end
# Returns whether the move will be a critical hit.
def pbIsCritical?(user,target)
return false if target.pbOwnSide.effects[PBEffects::LuckyChant]>0
def pbIsCritical?(user, target)
return false if target.pbOwnSide.effects[PBEffects::LuckyChant] > 0
# Set up the critical hit ratios
ratios = (Settings::NEW_CRITICAL_HIT_RATE_MECHANICS) ? [24,8,2,1] : [16,8,4,3,2]
ratios = (Settings::NEW_CRITICAL_HIT_RATE_MECHANICS) ? [24, 8, 2, 1] : [16, 8, 4, 3, 2]
c = 0
# Ability effects that alter critical hit rate
if c>=0 && user.abilityActive?
if c >= 0 && user.abilityActive?
c = Battle::AbilityEffects.triggerCriticalCalcFromUser(user.ability, user, target, c)
end
if c>=0 && target.abilityActive? && !@battle.moldBreaker
if c >= 0 && target.abilityActive? && !@battle.moldBreaker
c = Battle::AbilityEffects.triggerCriticalCalcFromTarget(target.ability, user, target, c)
end
# Item effects that alter critical hit rate
if c>=0 && user.itemActive?
if c >= 0 && user.itemActive?
c = Battle::ItemEffects.triggerCriticalCalcFromUser(user.item, user, target, c)
end
if c>=0 && target.itemActive?
if c >= 0 && target.itemActive?
c = Battle::ItemEffects.triggerCriticalCalcFromTarget(target.item, user, target, c)
end
return false if c<0
return false if c < 0
# Move-specific "always/never a critical hit" effects
case pbCritialOverride(user,target)
case pbCritialOverride(user, target)
when 1 then return true
when -1 then return false
end
# Other effects
return true if c>50 # Merciless
return true if user.effects[PBEffects::LaserFocus]>0
return true if c > 50 # Merciless
return true if user.effects[PBEffects::LaserFocus] > 0
c += 1 if highCriticalRate?
c += user.effects[PBEffects::FocusEnergy]
c += 1 if user.inHyperMode? && @type == :SHADOW
c = ratios.length-1 if c>=ratios.length
c = ratios.length - 1 if c >= ratios.length
# Calculation
return true if ratios[c] == 1
r = @battle.pbRandom(ratios[c])
@@ -222,49 +222,49 @@ class Battle::Move
#=============================================================================
# Damage calculation
#=============================================================================
def pbBaseDamage(baseDmg,user,target); return baseDmg; end
def pbBaseDamageMultiplier(damageMult,user,target); return damageMult; end
def pbModifyDamage(damageMult,user,target); return damageMult; end
def pbBaseDamage(baseDmg, user, target); return baseDmg; end
def pbBaseDamageMultiplier(damageMult, user, target); return damageMult; end
def pbModifyDamage(damageMult, user, target); return damageMult; end
def pbGetAttackStats(user,target)
def pbGetAttackStats(user, target)
if specialMove?
return user.spatk, user.stages[:SPECIAL_ATTACK]+6
return user.spatk, user.stages[:SPECIAL_ATTACK] + 6
end
return user.attack, user.stages[:ATTACK]+6
return user.attack, user.stages[:ATTACK] + 6
end
def pbGetDefenseStats(user,target)
def pbGetDefenseStats(user, target)
if specialMove?
return target.spdef, target.stages[:SPECIAL_DEFENSE]+6
return target.spdef, target.stages[:SPECIAL_DEFENSE] + 6
end
return target.defense, target.stages[:DEFENSE]+6
return target.defense, target.stages[:DEFENSE] + 6
end
def pbCalcDamage(user,target,numTargets = 1)
def pbCalcDamage(user, target, numTargets = 1)
return if statusMove?
if target.damageState.disguise || target.damageState.iceFace
target.damageState.calcDamage = 1
return
end
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]
# Get the move's type
type = @calcType # nil is treated as physical
# Calculate whether this hit deals critical damage
target.damageState.critical = pbIsCritical?(user,target)
target.damageState.critical = pbIsCritical?(user, target)
# Calcuate base power of move
baseDmg = pbBaseDamage(@baseDamage,user,target)
baseDmg = pbBaseDamage(@baseDamage, user, target)
# Calculate user's attack stat
atk, atkStage = pbGetAttackStats(user,target)
atk, atkStage = pbGetAttackStats(user, target)
if !target.hasActiveAbility?(:UNAWARE) || @battle.moldBreaker
atkStage = 6 if target.damageState.critical && atkStage<6
atk = (atk.to_f*stageMul[atkStage]/stageDiv[atkStage]).floor
atkStage = 6 if target.damageState.critical && atkStage < 6
atk = (atk.to_f * stageMul[atkStage] / stageDiv[atkStage]).floor
end
# Calculate target's defense stat
defense, defStage = pbGetDefenseStats(user,target)
defense, defStage = pbGetDefenseStats(user, target)
if !user.hasActiveAbility?(:UNAWARE)
defStage = 6 if target.damageState.critical && defStage>6
defense = (defense.to_f*stageMul[defStage]/stageDiv[defStage]).floor
defStage = 6 if target.damageState.critical && defStage > 6
defense = (defense.to_f * stageMul[defStage] / stageDiv[defStage]).floor
end
# Calculate all multiplier effects
multipliers = {
@@ -273,17 +273,17 @@ class Battle::Move
:defense_multiplier => 1.0,
:final_damage_multiplier => 1.0
}
pbCalcDamageMultipliers(user,target,numTargets,type,baseDmg,multipliers)
pbCalcDamageMultipliers(user, target, numTargets, type, baseDmg, multipliers)
# Main damage calculation
baseDmg = [(baseDmg * multipliers[:base_damage_multiplier]).round, 1].max
atk = [(atk * multipliers[:attack_multiplier]).round, 1].max
defense = [(defense * multipliers[:defense_multiplier]).round, 1].max
damage = (((2.0 * user.level / 5 + 2).floor * baseDmg * atk / defense).floor / 50).floor + 2
damage = [(damage * multipliers[:final_damage_multiplier]).round, 1].max
damage = [(damage * multipliers[:final_damage_multiplier]).round, 1].max
target.damageState.calcDamage = damage
end
def pbCalcDamageMultipliers(user,target,numTargets,type,baseDmg,multipliers)
def pbCalcDamageMultipliers(user, target, numTargets, type, baseDmg, multipliers)
# Global abilities
if (@battle.pbCheckGlobalAbility(:DARKAURA) && type == :DARK) ||
(@battle.pbCheckGlobalAbility(:FAIRYAURA) && type == :FAIRY)
@@ -296,7 +296,7 @@ class Battle::Move
# Ability effects that alter damage
if user.abilityActive?
Battle::AbilityEffects.triggerDamageCalcFromUser(user.ability,
user,target,self,multipliers,baseDmg,type)
user, target, self, multipliers, baseDmg, type)
end
if !@battle.moldBreaker
# NOTE: It's odd that the user's Mold Breaker prevents its partner's
@@ -305,31 +305,31 @@ class Battle::Move
user.allAllies.each do |b|
next if !b.abilityActive?
Battle::AbilityEffects.triggerDamageCalcFromAlly(b.ability,
user,target,self,multipliers,baseDmg,type)
user, target, self, multipliers, baseDmg, type)
end
if target.abilityActive?
Battle::AbilityEffects.triggerDamageCalcFromTarget(target.ability,
user,target,self,multipliers,baseDmg,type) if !@battle.moldBreaker
user, target, self, multipliers, baseDmg, type) if !@battle.moldBreaker
Battle::AbilityEffects.triggerDamageCalcFromTargetNonIgnorable(target.ability,
user,target,self,multipliers,baseDmg,type)
user, target, self, multipliers, baseDmg, type)
end
target.allAllies.each do |b|
next if !b.abilityActive?
Battle::AbilityEffects.triggerDamageCalcFromTargetAlly(b.ability,
user,target,self,multipliers,baseDmg,type)
user, target, self, multipliers, baseDmg, type)
end
end
# Item effects that alter damage
if user.itemActive?
Battle::ItemEffects.triggerDamageCalcFromUser(user.item,
user,target,self,multipliers,baseDmg,type)
user, target, self, multipliers, baseDmg, type)
end
if target.itemActive?
Battle::ItemEffects.triggerDamageCalcFromTarget(target.item,
user,target,self,multipliers,baseDmg,type)
user, target, self, multipliers, baseDmg, type)
end
# Parental Bond's second attack
if user.effects[PBEffects::ParentalBond]==1
if user.effects[PBEffects::ParentalBond] == 1
multipliers[:base_damage_multiplier] /= (Settings::MECHANICS_GENERATION >= 7) ? 4 : 2
end
# Other
@@ -339,7 +339,7 @@ class Battle::Move
if user.effects[PBEffects::HelpingHand] && !self.is_a?(Battle::Move::Confusion)
multipliers[:base_damage_multiplier] *= 1.5
end
if user.effects[PBEffects::Charge]>0 && type == :ELECTRIC
if user.effects[PBEffects::Charge] > 0 && type == :ELECTRIC
multipliers[:base_damage_multiplier] *= 2
end
# Mud Sport
@@ -347,7 +347,7 @@ class Battle::Move
if @battle.allBattlers.any? { |b| b.effects[PBEffects::MudSport] }
multipliers[:base_damage_multiplier] /= 3
end
if @battle.field.effects[PBEffects::MudSportField]>0
if @battle.field.effects[PBEffects::MudSportField] > 0
multipliers[:base_damage_multiplier] /= 3
end
end
@@ -356,7 +356,7 @@ class Battle::Move
if @battle.allBattlers.any? { |b| b.effects[PBEffects::WaterSport] }
multipliers[:base_damage_multiplier] /= 3
end
if @battle.field.effects[PBEffects::WaterSportField]>0
if @battle.field.effects[PBEffects::WaterSportField] > 0
multipliers[:base_damage_multiplier] /= 3
end
end
@@ -390,7 +390,7 @@ class Battle::Move
end
end
# Multi-targeting attacks
if numTargets>1
if numTargets > 1
multipliers[:final_damage_multiplier] *= 0.75
end
# Weather
@@ -422,7 +422,7 @@ class Battle::Move
end
# Random variance
if !self.is_a?(Battle::Move::Confusion)
random = 85+@battle.pbRandom(16)
random = 85 + @battle.pbRandom(16)
multipliers[:final_damage_multiplier] *= random / 100.0
end
# STAB
@@ -444,13 +444,13 @@ class Battle::Move
if !ignoresReflect? && !target.damageState.critical &&
!user.hasActiveAbility?(:INFILTRATOR)
if target.pbOwnSide.effects[PBEffects::AuroraVeil] > 0
if @battle.pbSideBattlerCount(target)>1
if @battle.pbSideBattlerCount(target) > 1
multipliers[:final_damage_multiplier] *= 2 / 3.0
else
multipliers[:final_damage_multiplier] /= 2
end
elsif target.pbOwnSide.effects[PBEffects::Reflect] > 0 && physicalMove?
if @battle.pbSideBattlerCount(target)>1
if @battle.pbSideBattlerCount(target) > 1
multipliers[:final_damage_multiplier] *= 2 / 3.0
else
multipliers[:final_damage_multiplier] /= 2
@@ -476,12 +476,12 @@ class Battle::Move
#=============================================================================
# Additional effect chance
#=============================================================================
def pbAdditionalEffectChance(user,target,effectChance = 0)
def pbAdditionalEffectChance(user, target, effectChance = 0)
return 0 if target.hasActiveAbility?(:SHIELDDUST) && !@battle.moldBreaker
ret = (effectChance>0) ? effectChance : @addlEffect
ret = (effectChance > 0) ? effectChance : @addlEffect
if Settings::MECHANICS_GENERATION >= 6 || @function != "EffectDependsOnEnvironment"
ret *= 2 if user.hasActiveAbility?(:SERENEGRACE) ||
user.pbOwnSide.effects[PBEffects::Rainbow]>0
user.pbOwnSide.effects[PBEffects::Rainbow] > 0
end
ret = 100 if $DEBUG && Input.press?(Input::CTRL)
return ret
@@ -489,17 +489,17 @@ class Battle::Move
# NOTE: Flinching caused by a move's effect is applied in that move's code,
# not here.
def pbFlinchChance(user,target)
def pbFlinchChance(user, target)
return 0 if flinchingMove?
return 0 if target.hasActiveAbility?(:SHIELDDUST) && !@battle.moldBreaker
ret = 0
if user.hasActiveAbility?(:STENCH,true)
if user.hasActiveAbility?(:STENCH, true)
ret = 10
elsif user.hasActiveItem?([:KINGSROCK,:RAZORFANG],true)
elsif user.hasActiveItem?([:KINGSROCK, :RAZORFANG], true)
ret = 10
end
ret *= 2 if user.hasActiveAbility?(:SERENEGRACE) ||
user.pbOwnSide.effects[PBEffects::Rainbow]>0
user.pbOwnSide.effects[PBEffects::Rainbow] > 0
return ret
end
end

View File

@@ -8,7 +8,7 @@
# Status moves always fail.
#===============================================================================
class Battle::Move::Unimplemented < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if statusMove?
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -21,7 +21,7 @@ end
# Pseudomove for confusion damage.
#===============================================================================
class Battle::Move::Confusion < Battle::Move
def initialize(battle,move)
def initialize(battle, move)
@battle = battle
@realMove = move
@id = :CONFUSEDAMAGE
@@ -41,16 +41,16 @@ class Battle::Move::Confusion < Battle::Move
@snatched = false
end
def physicalMove?(thisType = nil); return true; end
def specialMove?(thisType = nil); return false; end
def pbCritialOverride(user,target); return -1; end
def physicalMove?(thisType = nil); return true; end
def specialMove?(thisType = nil); return false; end
def pbCritialOverride(user, target); return -1; end
end
#===============================================================================
# Struggle.
#===============================================================================
class Battle::Move::Struggle < Battle::Move
def initialize(battle,move)
def initialize(battle, move)
@battle = battle
@realMove = nil # Not associated with a move
@id = (move) ? move.id : :STRUGGLE
@@ -73,10 +73,10 @@ class Battle::Move::Struggle < Battle::Move
def physicalMove?(thisType = nil); return true; end
def specialMove?(thisType = nil); return false; end
def pbEffectAfterAllHits(user,target)
def pbEffectAfterAllHits(user, target)
return if target.damageState.unaffected
user.pbReduceHP((user.totalhp/4.0).round,false)
@battle.pbDisplay(_INTL("{1} is damaged by recoil!",user.pbThis))
user.pbReduceHP((user.totalhp / 4.0).round, false)
@battle.pbDisplay(_INTL("{1} is damaged by recoil!", user.pbThis))
user.pbItemHPHealCheck
end
end
@@ -87,19 +87,19 @@ end
class Battle::Move::StatUpMove < Battle::Move
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
return false if damagingMove?
return !user.pbCanRaiseStatStage?(@statUp[0],user,self,true)
return !user.pbCanRaiseStatStage?(@statUp[0], user, self, true)
end
def pbEffectGeneral(user)
return if damagingMove?
user.pbRaiseStatStage(@statUp[0],@statUp[1],user)
user.pbRaiseStatStage(@statUp[0], @statUp[1], user)
end
def pbAdditionalEffect(user,target)
if user.pbCanRaiseStatStage?(@statUp[0],user,self)
user.pbRaiseStatStage(@statUp[0],@statUp[1],user)
def pbAdditionalEffect(user, target)
if user.pbCanRaiseStatStage?(@statUp[0], user, self)
user.pbRaiseStatStage(@statUp[0], @statUp[1], user)
end
end
end
@@ -110,16 +110,16 @@ end
class Battle::Move::MultiStatUpMove < Battle::Move
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
return false if damagingMove?
failed = true
for i in 0...@statUp.length/2
next if !user.pbCanRaiseStatStage?(@statUp[i*2],user,self)
for i in 0...@statUp.length / 2
next if !user.pbCanRaiseStatStage?(@statUp[i * 2], user, self)
failed = false
break
end
if failed
@battle.pbDisplay(_INTL("{1}'s stats won't go any higher!",user.pbThis))
@battle.pbDisplay(_INTL("{1}'s stats won't go any higher!", user.pbThis))
return true
end
return false
@@ -128,19 +128,19 @@ class Battle::Move::MultiStatUpMove < Battle::Move
def pbEffectGeneral(user)
return if damagingMove?
showAnim = true
for i in 0...@statUp.length/2
next if !user.pbCanRaiseStatStage?(@statUp[i*2],user,self)
if user.pbRaiseStatStage(@statUp[i*2],@statUp[i*2+1],user,showAnim)
for i in 0...@statUp.length / 2
next if !user.pbCanRaiseStatStage?(@statUp[i * 2], user, self)
if user.pbRaiseStatStage(@statUp[i * 2], @statUp[i * 2 + 1], user, showAnim)
showAnim = false
end
end
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
showAnim = true
for i in 0...@statUp.length/2
next if !user.pbCanRaiseStatStage?(@statUp[i*2],user,self)
if user.pbRaiseStatStage(@statUp[i*2],@statUp[i*2+1],user,showAnim)
for i in 0...@statUp.length / 2
next if !user.pbCanRaiseStatStage?(@statUp[i * 2], user, self)
if user.pbRaiseStatStage(@statUp[i * 2], @statUp[i * 2 + 1], user, showAnim)
showAnim = false
end
end
@@ -151,12 +151,12 @@ end
# Lower multiple of user's stats.
#===============================================================================
class Battle::Move::StatDownMove < Battle::Move
def pbEffectWhenDealingDamage(user,target)
def pbEffectWhenDealingDamage(user, target)
return if @battle.pbAllFainted?(target.idxOwnSide)
showAnim = true
for i in 0...@statDown.length/2
next if !user.pbCanLowerStatStage?(@statDown[i*2],user,self)
if user.pbLowerStatStage(@statDown[i*2],@statDown[i*2+1],user,showAnim)
for i in 0...@statDown.length / 2
next if !user.pbCanLowerStatStage?(@statDown[i * 2], user, self)
if user.pbLowerStatStage(@statDown[i * 2], @statDown[i * 2 + 1], user, showAnim)
showAnim = false
end
end
@@ -174,15 +174,15 @@ class Battle::Move::TargetStatDownMove < Battle::Move
return !target.pbCanLowerStatStage?(@statDown[0], user, self, show_message)
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if damagingMove?
target.pbLowerStatStage(@statDown[0],@statDown[1],user)
target.pbLowerStatStage(@statDown[0], @statDown[1], user)
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
return if !target.pbCanLowerStatStage?(@statDown[0],user,self)
target.pbLowerStatStage(@statDown[0],@statDown[1],user)
return if !target.pbCanLowerStatStage?(@statDown[0], user, self)
target.pbLowerStatStage(@statDown[0], @statDown[1], user)
end
end
@@ -195,8 +195,8 @@ class Battle::Move::TargetMultiStatDownMove < Battle::Move
def pbFailsAgainstTarget?(user, target, show_message)
return false if damagingMove?
failed = true
for i in 0...@statDown.length/2
next if !target.pbCanLowerStatStage?(@statDown[i*2],user,self)
for i in 0...@statDown.length / 2
next if !target.pbCanLowerStatStage?(@statDown[i * 2], user, self)
failed = false
break
end
@@ -205,19 +205,19 @@ class Battle::Move::TargetMultiStatDownMove < Battle::Move
# is shown here, I know.
canLower = false
if target.hasActiveAbility?(:CONTRARY) && !@battle.moldBreaker
for i in 0...@statDown.length/2
next if target.statStageAtMax?(@statDown[i*2])
for i in 0...@statDown.length / 2
next if target.statStageAtMax?(@statDown[i * 2])
canLower = true
break
end
@battle.pbDisplay(_INTL("{1}'s stats won't go any higher!",user.pbThis)) if !canLower && show_message
@battle.pbDisplay(_INTL("{1}'s stats won't go any higher!", user.pbThis)) if !canLower && show_message
else
for i in 0...@statDown.length/2
next if target.statStageAtMin?(@statDown[i*2])
for i in 0...@statDown.length / 2
next if target.statStageAtMin?(@statDown[i * 2])
canLower = true
break
end
@battle.pbDisplay(_INTL("{1}'s stats won't go any lower!",user.pbThis)) if !canLower && show_message
@battle.pbDisplay(_INTL("{1}'s stats won't go any lower!", user.pbThis)) if !canLower && show_message
end
if canLower
target.pbCanLowerStatStage?(@statDown[0], user, self, show_message)
@@ -264,11 +264,11 @@ class Battle::Move::TargetMultiStatDownMove < Battle::Move
@battle.pbHideAbilitySplash(target) # To hide target's Mirror Armor splash
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
pbLowerTargetMultipleStats(user, target) if !damagingMove?
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
pbLowerTargetMultipleStats(user, target) if !target.damageState.substitute
end
end
@@ -277,12 +277,12 @@ end
# Fixed damage-inflicting move.
#===============================================================================
class Battle::Move::FixedDamageMove < Battle::Move
def pbFixedDamage(user,target); return 1; end
def pbFixedDamage(user, target); return 1; end
def pbCalcDamage(user,target,numTargets = 1)
def pbCalcDamage(user, target, numTargets = 1)
target.damageState.critical = false
target.damageState.calcDamage = pbFixedDamage(user,target)
target.damageState.calcDamage = 1 if target.damageState.calcDamage<1
target.damageState.calcDamage = pbFixedDamage(user, target)
target.damageState.calcDamage = 1 if target.damageState.calcDamage < 1
end
end
@@ -315,16 +315,16 @@ class Battle::Move::TwoTurnMove < Battle::Move
return super
end
def pbAccuracyCheck(user,target)
def pbAccuracyCheck(user, target)
return true if !@damagingTurn
return super
end
def pbInitialEffect(user,targets,hitNum)
pbChargingTurnMessage(user,targets) if @chargingTurn
def pbInitialEffect(user, targets, hitNum)
pbChargingTurnMessage(user, targets) if @chargingTurn
if @chargingTurn && @damagingTurn # Move only takes one turn to use
pbShowAnimation(@id,user,targets,1) # Charging anim
targets.each { |b| pbChargingTurnEffect(user,b) }
pbShowAnimation(@id, user, targets, 1) # Charging anim
targets.each { |b| pbChargingTurnEffect(user, b) }
if @powerHerb
# Moves that would make the user semi-invulnerable will hide the user
# after the charging animation, so the "UseItem" animation shouldn't show
@@ -335,39 +335,39 @@ class Battle::Move::TwoTurnMove < Battle::Move
"TwoTurnAttackInvulnerableInSkyParalyzeTarget",
"TwoTurnAttackInvulnerableRemoveProtections",
"TwoTurnAttackInvulnerableInSkyTargetCannotAct"].include?(@function)
@battle.pbCommonAnimation("UseItem",user)
@battle.pbCommonAnimation("UseItem", user)
end
@battle.pbDisplay(_INTL("{1} became fully charged due to its Power Herb!",user.pbThis))
@battle.pbDisplay(_INTL("{1} became fully charged due to its Power Herb!", user.pbThis))
user.pbConsumeItem
end
end
pbAttackingTurnMessage(user,targets) if @damagingTurn
pbAttackingTurnMessage(user, targets) if @damagingTurn
end
def pbChargingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} began charging up!",user.pbThis))
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} began charging up!", user.pbThis))
end
def pbAttackingTurnMessage(user,targets)
def pbAttackingTurnMessage(user, targets)
end
def pbChargingTurnEffect(user,target)
def pbChargingTurnEffect(user, target)
# Skull Bash/Sky Drop are the only two-turn moves with an effect here, and
# the latter just records the target is being Sky Dropped
end
def pbAttackingTurnEffect(user,target)
def pbAttackingTurnEffect(user, target)
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
if @damagingTurn
pbAttackingTurnEffect(user,target)
pbAttackingTurnEffect(user, target)
elsif @chargingTurn
pbChargingTurnEffect(user,target)
pbChargingTurnEffect(user, target)
end
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
hitNum = 1 if @chargingTurn && !@damagingTurn # Charging anim
super
end
@@ -381,9 +381,9 @@ class Battle::Move::HealingMove < Battle::Move
def pbHealAmount(user); return 1; end
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
if user.hp==user.totalhp
@battle.pbDisplay(_INTL("{1}'s HP is full!",user.pbThis))
def pbMoveFailed?(user, targets)
if user.hp == user.totalhp
@battle.pbDisplay(_INTL("{1}'s HP is full!", user.pbThis))
return true
end
return false
@@ -392,7 +392,7 @@ class Battle::Move::HealingMove < Battle::Move
def pbEffectGeneral(user)
amt = pbHealAmount(user)
user.pbRecoverHP(amt)
@battle.pbDisplay(_INTL("{1}'s HP was restored.",user.pbThis))
@battle.pbDisplay(_INTL("{1}'s HP was restored.", user.pbThis))
end
end
@@ -401,16 +401,16 @@ end
#===============================================================================
class Battle::Move::RecoilMove < Battle::Move
def recoilMove?; return true; end
def pbRecoilDamage(user,target); return 1; end
def pbRecoilDamage(user, target); return 1; end
def pbEffectAfterAllHits(user,target)
def pbEffectAfterAllHits(user, target)
return if target.damageState.unaffected
return if !user.takesIndirectDamage?
return if user.hasActiveAbility?(:ROCKHEAD)
amt = pbRecoilDamage(user,target)
amt = 1 if amt<1
user.pbReduceHP(amt,false)
@battle.pbDisplay(_INTL("{1} is damaged by recoil!",user.pbThis))
amt = pbRecoilDamage(user, target)
amt = 1 if amt < 1
user.pbReduceHP(amt, false)
@battle.pbDisplay(_INTL("{1} is damaged by recoil!", user.pbThis))
user.pbItemHPHealCheck
end
end
@@ -419,18 +419,18 @@ end
# Protect move.
#===============================================================================
class Battle::Move::ProtectMove < Battle::Move
def initialize(battle,move)
def initialize(battle, move)
super
@sidedEffect = false
end
def pbChangeUsageCounters(user,specialUsage)
def pbChangeUsageCounters(user, specialUsage)
oldVal = user.effects[PBEffects::ProtectRate]
super
user.effects[PBEffects::ProtectRate] = oldVal
end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if @sidedEffect
if user.pbOwnSide.effects[@effect]
user.effects[PBEffects::ProtectRate] = 1
@@ -443,8 +443,8 @@ class Battle::Move::ProtectMove < Battle::Move
return true
end
if (!@sidedEffect || Settings::MECHANICS_GENERATION <= 5) &&
user.effects[PBEffects::ProtectRate]>1 &&
@battle.pbRandom(user.effects[PBEffects::ProtectRate])!=0
user.effects[PBEffects::ProtectRate] > 1 &&
@battle.pbRandom(user.effects[PBEffects::ProtectRate]) != 0
user.effects[PBEffects::ProtectRate] = 1
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -468,9 +468,9 @@ class Battle::Move::ProtectMove < Battle::Move
def pbProtectMessage(user)
if @sidedEffect
@battle.pbDisplay(_INTL("{1} protected {2}!",@name,user.pbTeam(true)))
@battle.pbDisplay(_INTL("{1} protected {2}!", @name, user.pbTeam(true)))
else
@battle.pbDisplay(_INTL("{1} protected itself!",user.pbThis))
@battle.pbDisplay(_INTL("{1} protected itself!", user.pbThis))
end
end
end
@@ -479,12 +479,12 @@ end
# Weather-inducing move.
#===============================================================================
class Battle::Move::WeatherMove < Battle::Move
def initialize(battle,move)
def initialize(battle, move)
super
@weatherType = :None
end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
case @battle.field.weather
when :HarshSun
@battle.pbDisplay(_INTL("The extremely harsh sunlight was not lessened at all!"))
@@ -503,7 +503,7 @@ class Battle::Move::WeatherMove < Battle::Move
end
def pbEffectGeneral(user)
@battle.pbStartWeather(user,@weatherType,true,false)
@battle.pbStartWeather(user, @weatherType, true, false)
end
end
@@ -511,7 +511,7 @@ end
# Pledge move.
#===============================================================================
class Battle::Move::PledgeMove < Battle::Move
def pbOnStartUse(user,targets)
def pbOnStartUse(user, targets)
@pledgeSetup = false
@pledgeCombo = false
@pledgeOtherUser = nil
@@ -519,7 +519,7 @@ class Battle::Move::PledgeMove < Battle::Move
@overrideAnim = nil
# Check whether this is the use of a combo move
@combos.each do |i|
next if i[0]!=user.effects[PBEffects::FirstPledge]
next if i[0] != user.effects[PBEffects::FirstPledge]
@battle.pbDisplay(_INTL("The two moves have become one! It's a combined move!"))
@pledgeCombo = true
@comboEffect = i[1]
@@ -529,11 +529,11 @@ class Battle::Move::PledgeMove < Battle::Move
return if @pledgeCombo
# Check whether this is the setup of a combo move
user.allAllies.each do |b|
next if @battle.choices[b.index][0]!=:UseMove || b.movedThisRound?
next if @battle.choices[b.index][0] != :UseMove || b.movedThisRound?
move = @battle.choices[b.index][2]
next if !move
@combos.each do |i|
next if i[0]!=move.function
next if i[0] != move.function
@pledgeSetup = true
@pledgeOtherUser = b
break
@@ -558,7 +558,7 @@ class Battle::Move::PledgeMove < Battle::Move
return super
end
def pbBaseDamage(baseDmg,user,target)
def pbBaseDamage(baseDmg, user, target)
baseDmg *= 2 if @pledgeCombo
return baseDmg
end
@@ -567,33 +567,33 @@ class Battle::Move::PledgeMove < Battle::Move
user.effects[PBEffects::FirstPledge] = nil
return if !@pledgeSetup
@battle.pbDisplay(_INTL("{1} is waiting for {2}'s move...",
user.pbThis,@pledgeOtherUser.pbThis(true)))
user.pbThis, @pledgeOtherUser.pbThis(true)))
@pledgeOtherUser.effects[PBEffects::FirstPledge] = @function
@pledgeOtherUser.effects[PBEffects::MoveNext] = true
user.lastMoveFailed = true # Treated as a failure for Stomping Tantrum
end
def pbEffectAfterAllHits(user,target)
def pbEffectAfterAllHits(user, target)
return if !@pledgeCombo
msg = nil
animName = nil
case @comboEffect
when :SeaOfFire # Grass + Fire
if user.pbOpposingSide.effects[PBEffects::SeaOfFire]==0
if user.pbOpposingSide.effects[PBEffects::SeaOfFire] == 0
user.pbOpposingSide.effects[PBEffects::SeaOfFire] = 4
msg = _INTL("A sea of fire enveloped {1}!",user.pbOpposingTeam(true))
msg = _INTL("A sea of fire enveloped {1}!", user.pbOpposingTeam(true))
animName = (user.opposes?) ? "SeaOfFire" : "SeaOfFireOpp"
end
when :Rainbow # Fire + Water
if user.pbOwnSide.effects[PBEffects::Rainbow]==0
if user.pbOwnSide.effects[PBEffects::Rainbow] == 0
user.pbOwnSide.effects[PBEffects::Rainbow] = 4
msg = _INTL("A rainbow appeared in the sky on {1}'s side!",user.pbTeam(true))
msg = _INTL("A rainbow appeared in the sky on {1}'s side!", user.pbTeam(true))
animName = (user.opposes?) ? "RainbowOpp" : "Rainbow"
end
when :Swamp # Water + Grass
if user.pbOpposingSide.effects[PBEffects::Swamp]==0
if user.pbOpposingSide.effects[PBEffects::Swamp] == 0
user.pbOpposingSide.effects[PBEffects::Swamp] = 4
msg = _INTL("A swamp enveloped {1}!",user.pbOpposingTeam(true))
msg = _INTL("A swamp enveloped {1}!", user.pbOpposingTeam(true))
animName = (user.opposes?) ? "Swamp" : "SwampOpp"
end
end
@@ -601,7 +601,7 @@ class Battle::Move::PledgeMove < Battle::Move
@battle.pbCommonAnimation(animName) if animName
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
return if @pledgeSetup # No animation for setting up
id = @overrideAnim if @overrideAnim
return super

View File

@@ -10,9 +10,9 @@ end
class Battle::Move::DoesNothingCongratulations < Battle::Move
def pbEffectGeneral(user)
if user.wild?
@battle.pbDisplay(_INTL("Congratulations from {1}!",user.pbThis(true)))
@battle.pbDisplay(_INTL("Congratulations from {1}!", user.pbThis(true)))
else
@battle.pbDisplay(_INTL("Congratulations, {1}!",@battle.pbGetOwnerName(user.index)))
@battle.pbDisplay(_INTL("Congratulations, {1}!", @battle.pbGetOwnerName(user.index)))
end
end
end
@@ -23,7 +23,7 @@ end
class Battle::Move::DoesNothingFailsIfNoAlly < Battle::Move
def ignoresSubstitute?(user); return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.allAllies.length == 0
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -53,7 +53,7 @@ end
class Battle::Move::AddMoneyGainedFromBattle < Battle::Move
def pbEffectGeneral(user)
if user.pbOwnedByPlayer?
@battle.field.effects[PBEffects::PayDay] += 5*user.level
@battle.field.effects[PBEffects::PayDay] += 5 * user.level
end
@battle.pbDisplay(_INTL("Coins were scattered everywhere!"))
end
@@ -73,7 +73,7 @@ end
# Fails if this isn't the user's first turn. (First Impression)
#===============================================================================
class Battle::Move::FailsIfNotUserFirstTurn < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.turnCount > 1
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -91,9 +91,9 @@ class Battle::Move::FailsIfUserHasUnusedMove < Battle::Move
hasOtherMoves = false
hasUnusedMoves = false
user.eachMove do |m|
hasThisMove = true if m.id==@id
hasOtherMoves = true if m.id!=@id
hasUnusedMoves = true if m.id!=@id && !user.movesUsed.include?(m.id)
hasThisMove = true if m.id == @id
hasOtherMoves = true if m.id != @id
hasUnusedMoves = true if m.id != @id && !user.movesUsed.include?(m.id)
end
if !hasThisMove || !hasOtherMoves || hasUnusedMoves
@battle.pbDisplay(_INTL("But it failed!")) if show_message
@@ -107,10 +107,10 @@ end
# Fails unless user has consumed a berry at some point. (Belch)
#===============================================================================
class Battle::Move::FailsIfUserNotConsumedBerry < Battle::Move
def pbCanChooseMove?(user,commandPhase,showMessages)
def pbCanChooseMove?(user, commandPhase, showMessages)
if !user.belched?
if showMessages
msg = _INTL("{1} hasn't eaten any held berry, so it can't possibly belch!",user.pbThis)
msg = _INTL("{1} hasn't eaten any held berry, so it can't possibly belch!", user.pbThis)
(commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg)
end
return false
@@ -118,7 +118,7 @@ class Battle::Move::FailsIfUserNotConsumedBerry < Battle::Move
return true
end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !user.belched?
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -156,7 +156,7 @@ class Battle::Move::FailsUnlessTargetSharesTypeWithUser < Battle::Move
break
end
if !sharesType
@battle.pbDisplay(_INTL("{1} is unaffected!",target.pbThis)) if show_message
@battle.pbDisplay(_INTL("{1} is unaffected!", target.pbThis)) if show_message
return true
end
return false
@@ -169,17 +169,17 @@ end
class Battle::Move::FailsIfUserDamagedThisTurn < Battle::Move
def pbDisplayChargeMessage(user)
user.effects[PBEffects::FocusPunch] = true
@battle.pbCommonAnimation("FocusPunch",user)
@battle.pbDisplay(_INTL("{1} is tightening its focus!",user.pbThis))
@battle.pbCommonAnimation("FocusPunch", user)
@battle.pbDisplay(_INTL("{1} is tightening its focus!", user.pbThis))
end
def pbDisplayUseMessage(user)
super if !user.effects[PBEffects::FocusPunch] || user.lastHPLost==0
super if !user.effects[PBEffects::FocusPunch] || user.lastHPLost == 0
end
def pbMoveFailed?(user,targets)
if user.effects[PBEffects::FocusPunch] && user.lastHPLost>0
@battle.pbDisplay(_INTL("{1} lost its focus and couldn't move!",user.pbThis))
def pbMoveFailed?(user, targets)
if user.effects[PBEffects::FocusPunch] && user.lastHPLost > 0
@battle.pbDisplay(_INTL("{1} lost its focus and couldn't move!", user.pbThis))
return true
end
return false
@@ -192,13 +192,13 @@ end
#===============================================================================
class Battle::Move::FailsIfTargetActed < Battle::Move
def pbFailsAgainstTarget?(user, target, show_message)
if @battle.choices[target.index][0]!=:UseMove
if @battle.choices[target.index][0] != :UseMove
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
oppMove = @battle.choices[target.index][2]
if !oppMove ||
(oppMove.function!="UseMoveTargetIsAboutToUse" &&
(oppMove.function != "UseMoveTargetIsAboutToUse" &&
(target.movedThisRound? || oppMove.statusMove?))
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
@@ -217,9 +217,9 @@ class Battle::Move::CrashDamageIfFailsUnusableInGravity < Battle::Move
def pbCrashDamage(user)
return if !user.takesIndirectDamage?
@battle.pbDisplay(_INTL("{1} kept going and crashed!",user.pbThis))
@battle.pbDisplay(_INTL("{1} kept going and crashed!", user.pbThis))
@battle.scene.pbDamageAnimation(user)
user.pbReduceHP(user.totalhp/2,false)
user.pbReduceHP(user.totalhp / 2, false)
user.pbItemHPHealCheck
user.pbFaint if user.fainted?
end
@@ -229,7 +229,7 @@ end
# Starts sunny weather. (Sunny Day)
#===============================================================================
class Battle::Move::StartSunWeather < Battle::Move::WeatherMove
def initialize(battle,move)
def initialize(battle, move)
super
@weatherType = :Sun
end
@@ -239,7 +239,7 @@ end
# Starts rainy weather. (Rain Dance)
#===============================================================================
class Battle::Move::StartRainWeather < Battle::Move::WeatherMove
def initialize(battle,move)
def initialize(battle, move)
super
@weatherType = :Rain
end
@@ -249,7 +249,7 @@ end
# Starts sandstorm weather. (Sandstorm)
#===============================================================================
class Battle::Move::StartSandstormWeather < Battle::Move::WeatherMove
def initialize(battle,move)
def initialize(battle, move)
super
@weatherType = :Sandstorm
end
@@ -259,7 +259,7 @@ end
# Starts hail weather. (Hail)
#===============================================================================
class Battle::Move::StartHailWeather < Battle::Move::WeatherMove
def initialize(battle,move)
def initialize(battle, move)
super
@weatherType = :Hail
end
@@ -271,7 +271,7 @@ end
# (Electric Terrain)
#===============================================================================
class Battle::Move::StartElectricTerrain < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if @battle.field.terrain == :Electric
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -290,7 +290,7 @@ end
# (Grassy Terrain)
#===============================================================================
class Battle::Move::StartGrassyTerrain < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if @battle.field.terrain == :Grassy
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -309,7 +309,7 @@ end
# (Misty Terrain)
#===============================================================================
class Battle::Move::StartMistyTerrain < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if @battle.field.terrain == :Misty
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -328,7 +328,7 @@ end
# Pokémon only. (Psychic Terrain)
#===============================================================================
class Battle::Move::StartPsychicTerrain < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if @battle.field.terrain == :Psychic
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -375,8 +375,8 @@ end
class Battle::Move::AddSpikesToFoeSide < Battle::Move
def canMagicCoat?; return true; end
def pbMoveFailed?(user,targets)
if user.pbOpposingSide.effects[PBEffects::Spikes]>=3
def pbMoveFailed?(user, targets)
if user.pbOpposingSide.effects[PBEffects::Spikes] >= 3
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -397,8 +397,8 @@ end
class Battle::Move::AddToxicSpikesToFoeSide < Battle::Move
def canMagicCoat?; return true; end
def pbMoveFailed?(user,targets)
if user.pbOpposingSide.effects[PBEffects::ToxicSpikes]>=2
def pbMoveFailed?(user, targets)
if user.pbOpposingSide.effects[PBEffects::ToxicSpikes] >= 2
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -418,7 +418,7 @@ end
class Battle::Move::AddStealthRocksToFoeSide < Battle::Move
def canMagicCoat?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.pbOpposingSide.effects[PBEffects::StealthRock]
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -439,7 +439,7 @@ end
class Battle::Move::AddStickyWebToFoeSide < Battle::Move
def canMagicCoat?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.pbOpposingSide.effects[PBEffects::StickyWeb]
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -523,22 +523,22 @@ end
class Battle::Move::UserMakeSubstitute < Battle::Move
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
if user.effects[PBEffects::Substitute]>0
@battle.pbDisplay(_INTL("{1} already has a substitute!",user.pbThis))
def pbMoveFailed?(user, targets)
if user.effects[PBEffects::Substitute] > 0
@battle.pbDisplay(_INTL("{1} already has a substitute!", user.pbThis))
return true
end
@subLife = user.totalhp/4
@subLife = 1 if @subLife<1
if user.hp<=@subLife
@subLife = user.totalhp / 4
@subLife = 1 if @subLife < 1
if user.hp <= @subLife
@battle.pbDisplay(_INTL("But it does not have enough HP left to make a substitute!"))
return true
end
return false
end
def pbOnStartUse(user,targets)
user.pbReduceHP(@subLife,false,false)
def pbOnStartUse(user, targets)
user.pbReduceHP(@subLife, false, false)
user.pbItemHPHealCheck
end
@@ -546,7 +546,7 @@ class Battle::Move::UserMakeSubstitute < Battle::Move
user.effects[PBEffects::Trapping] = 0
user.effects[PBEffects::TrappingMove] = nil
user.effects[PBEffects::Substitute] = @subLife
@battle.pbDisplay(_INTL("{1} put in a substitute!",user.pbThis))
@battle.pbDisplay(_INTL("{1} put in a substitute!", user.pbThis))
end
end
@@ -555,44 +555,44 @@ end
# Raises user's Speed by 1 stage (Gen 8+). (Rapid Spin)
#===============================================================================
class Battle::Move::RemoveUserBindingAndEntryHazards < Battle::Move::StatUpMove
def initialize(battle,move)
def initialize(battle, move)
super
@statUp = [:SPEED, 1]
end
def pbEffectAfterAllHits(user,target)
def pbEffectAfterAllHits(user, target)
return if user.fainted? || target.damageState.unaffected
if user.effects[PBEffects::Trapping]>0
if user.effects[PBEffects::Trapping] > 0
trapMove = GameData::Move.get(user.effects[PBEffects::TrappingMove]).name
trapUser = @battle.battlers[user.effects[PBEffects::TrappingUser]]
@battle.pbDisplay(_INTL("{1} got free of {2}'s {3}!",user.pbThis,trapUser.pbThis(true),trapMove))
@battle.pbDisplay(_INTL("{1} got free of {2}'s {3}!", user.pbThis, trapUser.pbThis(true), trapMove))
user.effects[PBEffects::Trapping] = 0
user.effects[PBEffects::TrappingMove] = nil
user.effects[PBEffects::TrappingUser] = -1
end
if user.effects[PBEffects::LeechSeed]>=0
if user.effects[PBEffects::LeechSeed] >= 0
user.effects[PBEffects::LeechSeed] = -1
@battle.pbDisplay(_INTL("{1} shed Leech Seed!",user.pbThis))
@battle.pbDisplay(_INTL("{1} shed Leech Seed!", user.pbThis))
end
if user.pbOwnSide.effects[PBEffects::StealthRock]
user.pbOwnSide.effects[PBEffects::StealthRock] = false
@battle.pbDisplay(_INTL("{1} blew away stealth rocks!",user.pbThis))
@battle.pbDisplay(_INTL("{1} blew away stealth rocks!", user.pbThis))
end
if user.pbOwnSide.effects[PBEffects::Spikes]>0
if user.pbOwnSide.effects[PBEffects::Spikes] > 0
user.pbOwnSide.effects[PBEffects::Spikes] = 0
@battle.pbDisplay(_INTL("{1} blew away spikes!",user.pbThis))
@battle.pbDisplay(_INTL("{1} blew away spikes!", user.pbThis))
end
if user.pbOwnSide.effects[PBEffects::ToxicSpikes]>0
if user.pbOwnSide.effects[PBEffects::ToxicSpikes] > 0
user.pbOwnSide.effects[PBEffects::ToxicSpikes] = 0
@battle.pbDisplay(_INTL("{1} blew away poison spikes!",user.pbThis))
@battle.pbDisplay(_INTL("{1} blew away poison spikes!", user.pbThis))
end
if user.pbOwnSide.effects[PBEffects::StickyWeb]
user.pbOwnSide.effects[PBEffects::StickyWeb] = false
@battle.pbDisplay(_INTL("{1} blew away sticky webs!",user.pbThis))
@battle.pbDisplay(_INTL("{1} blew away sticky webs!", user.pbThis))
end
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
super if Settings::MECHANICS_GENERATION >= 8
end
end
@@ -608,7 +608,7 @@ class Battle::Move::AttackTwoTurnsLater < Battle::Move
return super
end
def pbAccuracyCheck(user,target)
def pbAccuracyCheck(user, target)
return true if !@battle.futureSight
return super
end
@@ -619,14 +619,14 @@ class Battle::Move::AttackTwoTurnsLater < Battle::Move
def pbFailsAgainstTarget?(user, target, show_message)
if !@battle.futureSight &&
@battle.positions[target.index].effects[PBEffects::FutureSightCounter]>0
@battle.positions[target.index].effects[PBEffects::FutureSightCounter] > 0
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if @battle.futureSight # Attack is hitting
effects = @battle.positions[target.index].effects
effects[PBEffects::FutureSightCounter] = 3
@@ -634,13 +634,13 @@ class Battle::Move::AttackTwoTurnsLater < Battle::Move
effects[PBEffects::FutureSightUserIndex] = user.index
effects[PBEffects::FutureSightUserPartyIndex] = user.pokemonIndex
if @id == :DOOMDESIRE
@battle.pbDisplay(_INTL("{1} chose Doom Desire as its destiny!",user.pbThis))
@battle.pbDisplay(_INTL("{1} chose Doom Desire as its destiny!", user.pbThis))
else
@battle.pbDisplay(_INTL("{1} foresaw an attack!",user.pbThis))
@battle.pbDisplay(_INTL("{1} foresaw an attack!", user.pbThis))
end
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
hitNum = 1 if !@battle.futureSight # Charging anim
super
end
@@ -650,17 +650,17 @@ end
# User switches places with its ally. (Ally Switch)
#===============================================================================
class Battle::Move::UserSwapsPositionsWithAlly < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
numTargets = 0
@idxAlly = -1
idxUserOwner = @battle.pbGetOwnerIndexFromBattlerIndex(user.index)
user.allAllies.each do |b|
next if @battle.pbGetOwnerIndexFromBattlerIndex(b.index)!=idxUserOwner
next if @battle.pbGetOwnerIndexFromBattlerIndex(b.index) != idxUserOwner
next if !b.near?(user)
numTargets += 1
@idxAlly = b.index
end
if numTargets!=1
if numTargets != 1
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -670,9 +670,9 @@ class Battle::Move::UserSwapsPositionsWithAlly < Battle::Move
def pbEffectGeneral(user)
idxA = user.index
idxB = @idxAlly
if @battle.pbSwapBattlers(idxA,idxB)
if @battle.pbSwapBattlers(idxA, idxB)
@battle.pbDisplay(_INTL("{1} and {2} switched places!",
@battle.battlers[idxB].pbThis,@battle.battlers[idxA].pbThis(true)))
@battle.battlers[idxB].pbThis, @battle.battlers[idxA].pbThis(true)))
[idxA, idxB].each { |idx| @battle.pbEffectsOnBattlerEnteringPosition(@battle.battlers[idx]) }
end
end
@@ -685,7 +685,7 @@ end
class Battle::Move::BurnAttackerBeforeUserActs < Battle::Move
def pbDisplayChargeMessage(user)
user.effects[PBEffects::BeakBlast] = true
@battle.pbCommonAnimation("BeakBlast",user)
@battle.pbDisplay(_INTL("{1} started heating up its beak!",user.pbThis))
@battle.pbCommonAnimation("BeakBlast", user)
@battle.pbDisplay(_INTL("{1} started heating up its beak!", user.pbThis))
end
end

View File

@@ -9,14 +9,14 @@ class Battle::Move::SleepTarget < Battle::Move
return !target.pbCanSleep?(user, show_message, self)
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if damagingMove?
target.pbSleep
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
target.pbSleep if target.pbCanSleep?(user,false,self)
target.pbSleep if target.pbCanSleep?(user, false, self)
end
end
@@ -24,9 +24,9 @@ end
# Puts the target to sleep. Fails if user is not Darkrai. (Dark Void (Gen 7+))
#===============================================================================
class Battle::Move::SleepTargetIfUserDarkrai < Battle::Move::SleepTarget
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !user.isSpecies?(:DARKRAI) && user.effects[PBEffects::TransformSpecies] != :DARKRAI
@battle.pbDisplay(_INTL("But {1} can't use the move!",user.pbThis))
@battle.pbDisplay(_INTL("But {1} can't use the move!", user.pbThis))
return true
end
return false
@@ -38,13 +38,13 @@ end
# (Relic Song)
#===============================================================================
class Battle::Move::SleepTargetChangeUserMeloettaForm < Battle::Move::SleepTarget
def pbEndOfMoveUsageEffect(user,targets,numHits,switchedBattlers)
return if numHits==0
def pbEndOfMoveUsageEffect(user, targets, numHits, switchedBattlers)
return if numHits == 0
return if user.fainted? || user.effects[PBEffects::Transform]
return if !user.isSpecies?(:MELOETTA)
return if user.hasActiveAbility?(:SHEERFORCE) && @addlEffect>0
newForm = (user.form+1)%2
user.pbChangeForm(newForm,_INTL("{1} transformed!",user.pbThis))
return if user.hasActiveAbility?(:SHEERFORCE) && @addlEffect > 0
newForm = (user.form + 1) % 2
user.pbChangeForm(newForm, _INTL("{1} transformed!", user.pbThis))
end
end
@@ -55,17 +55,17 @@ class Battle::Move::SleepTargetNextTurn < Battle::Move
def canMagicCoat?; return true; end
def pbFailsAgainstTarget?(user, target, show_message)
if target.effects[PBEffects::Yawn]>0
if target.effects[PBEffects::Yawn] > 0
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
return true if !target.pbCanSleep?(user,true,self)
return true if !target.pbCanSleep?(user, true, self)
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::Yawn] = 2
@battle.pbDisplay(_INTL("{1} made {2} drowsy!",user.pbThis,target.pbThis(true)))
@battle.pbDisplay(_INTL("{1} made {2} drowsy!", user.pbThis, target.pbThis(true)))
end
end
@@ -75,7 +75,7 @@ end
class Battle::Move::PoisonTarget < Battle::Move
def canMagicCoat?; return true; end
def initialize(battle,move)
def initialize(battle, move)
super
@toxic = false
end
@@ -85,14 +85,14 @@ class Battle::Move::PoisonTarget < Battle::Move
return !target.pbCanPoison?(user, show_message, self)
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if damagingMove?
target.pbPoison(user,nil,@toxic)
target.pbPoison(user, nil, @toxic)
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
target.pbPoison(user,nil,@toxic) if target.pbCanPoison?(user,false,self)
target.pbPoison(user, nil, @toxic) if target.pbCanPoison?(user, false, self)
end
end
@@ -103,18 +103,18 @@ class Battle::Move::PoisonTargetLowerTargetSpeed1 < Battle::Move
def canMagicCoat?; return true; end
def pbFailsAgainstTarget?(user, target, show_message)
if !target.pbCanPoison?(user,false,self) &&
!target.pbCanLowerStatStage?(:SPEED,user,self)
if !target.pbCanPoison?(user, false, self) &&
!target.pbCanLowerStatStage?(:SPEED, user, self)
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
return false
end
def pbEffectAgainstTarget(user,target)
target.pbPoison(user) if target.pbCanPoison?(user,false,self)
if target.pbCanLowerStatStage?(:SPEED,user,self)
target.pbLowerStatStage(:SPEED,1,user)
def pbEffectAgainstTarget(user, target)
target.pbPoison(user) if target.pbCanPoison?(user, false, self)
if target.pbCanLowerStatStage?(:SPEED, user, self)
target.pbLowerStatStage(:SPEED, 1, user)
end
end
end
@@ -123,12 +123,12 @@ end
# Badly poisons the target. (Poison Fang, Toxic)
#===============================================================================
class Battle::Move::BadPoisonTarget < Battle::Move::PoisonTarget
def initialize(battle,move)
def initialize(battle, move)
super
@toxic = true
end
def pbOverrideSuccessCheckPerHit(user,target)
def pbOverrideSuccessCheckPerHit(user, target)
return (Settings::MORE_TYPE_EFFECTS && statusMove? && user.pbHasType?(:POISON))
end
end
@@ -144,14 +144,14 @@ class Battle::Move::ParalyzeTarget < Battle::Move
return !target.pbCanParalyze?(user, show_message, self)
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if damagingMove?
target.pbParalyze(user)
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
target.pbParalyze(user) if target.pbCanParalyze?(user,false,self)
target.pbParalyze(user) if target.pbCanParalyze?(user, false, self)
end
end
@@ -175,8 +175,8 @@ end
#===============================================================================
class Battle::Move::ParalyzeTargetTrampleMinimize < Battle::Move::ParalyzeTarget
def tramplesMinimize?(param = 1)
return true if param==1 && Settings::MECHANICS_GENERATION >= 6 # Perfect accuracy
return true if param==2 # Double damage
return true if param == 1 && Settings::MECHANICS_GENERATION >= 6 # Perfect accuracy
return true if param == 2 # Double damage
return super
end
end
@@ -188,7 +188,7 @@ end
class Battle::Move::ParalyzeTargetAlwaysHitsInRainHitsTargetInSky < Battle::Move::ParalyzeTarget
def hitsFlyingTargets?; return true; end
def pbBaseAccuracy(user,target)
def pbBaseAccuracy(user, target)
case target.effectiveWeather
when :Sun, :HarshSun
return 50
@@ -205,14 +205,14 @@ end
class Battle::Move::ParalyzeFlinchTarget < Battle::Move
def flinchingMove?; return true; end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
chance = pbAdditionalEffectChance(user,target,10)
return if chance==0
if @battle.pbRandom(100)<chance
target.pbParalyze(user) if target.pbCanParalyze?(user,false,self)
chance = pbAdditionalEffectChance(user, target, 10)
return if chance == 0
if @battle.pbRandom(100) < chance
target.pbParalyze(user) if target.pbCanParalyze?(user, false, self)
end
target.pbFlinch(user) if @battle.pbRandom(100)<chance
target.pbFlinch(user) if @battle.pbRandom(100) < chance
end
end
@@ -227,14 +227,14 @@ class Battle::Move::BurnTarget < Battle::Move
return !target.pbCanBurn?(user, show_message, self)
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if damagingMove?
target.pbBurn(user)
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
target.pbBurn(user) if target.pbCanBurn?(user,false,self)
target.pbBurn(user) if target.pbCanBurn?(user, false, self)
end
end
@@ -254,14 +254,14 @@ end
class Battle::Move::BurnFlinchTarget < Battle::Move
def flinchingMove?; return true; end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
chance = pbAdditionalEffectChance(user,target,10)
return if chance==0
if @battle.pbRandom(100)<chance
target.pbBurn(user) if target.pbCanBurn?(user,false,self)
chance = pbAdditionalEffectChance(user, target, 10)
return if chance == 0
if @battle.pbRandom(100) < chance
target.pbBurn(user) if target.pbCanBurn?(user, false, self)
end
target.pbFlinch(user) if @battle.pbRandom(100)<chance
target.pbFlinch(user) if @battle.pbRandom(100) < chance
end
end
@@ -276,14 +276,14 @@ class Battle::Move::FreezeTarget < Battle::Move
return !target.pbCanFreeze?(user, show_message, self)
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if damagingMove?
target.pbFreeze
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
target.pbFreeze if target.pbCanFreeze?(user,false,self)
target.pbFreeze if target.pbCanFreeze?(user, false, self)
end
end
@@ -291,7 +291,7 @@ end
# Freezes the target. Effectiveness against Water-type is 2x. (Freeze-Dry)
#===============================================================================
class Battle::Move::FreezeTargetSuperEffectiveAgainstWater < Battle::Move::FreezeTarget
def pbCalcTypeModSingle(moveType,defType,user,target)
def pbCalcTypeModSingle(moveType, defType, user, target)
return Effectiveness::SUPER_EFFECTIVE_ONE if defType == :WATER
return super
end
@@ -301,7 +301,7 @@ end
# Freezes the target. Accuracy perfect in hail. (Blizzard)
#===============================================================================
class Battle::Move::FreezeTargetAlwaysHitsInHail < Battle::Move::FreezeTarget
def pbBaseAccuracy(user,target)
def pbBaseAccuracy(user, target)
return 0 if target.effectiveWeather == :Hail
return super
end
@@ -313,14 +313,14 @@ end
class Battle::Move::FreezeFlinchTarget < Battle::Move
def flinchingMove?; return true; end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
chance = pbAdditionalEffectChance(user,target,10)
return if chance==0
if @battle.pbRandom(100)<chance
target.pbFreeze if target.pbCanFreeze?(user,false,self)
chance = pbAdditionalEffectChance(user, target, 10)
return if chance == 0
if @battle.pbRandom(100) < chance
target.pbFreeze if target.pbCanFreeze?(user, false, self)
end
target.pbFlinch(user) if @battle.pbRandom(100)<chance
target.pbFlinch(user) if @battle.pbRandom(100) < chance
end
end
@@ -328,7 +328,7 @@ end
# Burns, freezes or paralyzes the target. (Tri Attack)
#===============================================================================
class Battle::Move::ParalyzeBurnOrFreezeTarget < Battle::Move
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
case @battle.pbRandom(3)
when 0 then target.pbBurn(user) if target.pbCanBurn?(user, false, self)
@@ -342,7 +342,7 @@ end
# User passes its status problem to the target. (Psycho Shift)
#===============================================================================
class Battle::Move::GiveUserStatusToTarget < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.status == :NONE
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -351,33 +351,33 @@ class Battle::Move::GiveUserStatusToTarget < Battle::Move
end
def pbFailsAgainstTarget?(user, target, show_message)
if !target.pbCanInflictStatus?(user.status,user,false,self)
if !target.pbCanInflictStatus?(user.status, user, false, self)
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
msg = ""
case user.status
when :SLEEP
target.pbSleep
msg = _INTL("{1} woke up.",user.pbThis)
msg = _INTL("{1} woke up.", user.pbThis)
when :POISON
target.pbPoison(user,nil,user.statusCount!=0)
msg = _INTL("{1} was cured of its poisoning.",user.pbThis)
target.pbPoison(user, nil, user.statusCount != 0)
msg = _INTL("{1} was cured of its poisoning.", user.pbThis)
when :BURN
target.pbBurn(user)
msg = _INTL("{1}'s burn was healed.",user.pbThis)
msg = _INTL("{1}'s burn was healed.", user.pbThis)
when :PARALYSIS
target.pbParalyze(user)
msg = _INTL("{1} was cured of paralysis.",user.pbThis)
msg = _INTL("{1} was cured of paralysis.", user.pbThis)
when :FROZEN
target.pbFreeze
msg = _INTL("{1} was thawed out.",user.pbThis)
msg = _INTL("{1} was thawed out.", user.pbThis)
end
if msg!=""
if msg != ""
user.pbCureStatus(false)
@battle.pbDisplay(msg)
end
@@ -390,7 +390,7 @@ end
class Battle::Move::CureUserBurnPoisonParalysis < Battle::Move
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if ![:BURN, :POISON, :PARALYSIS].include?(user.status)
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -403,11 +403,11 @@ class Battle::Move::CureUserBurnPoisonParalysis < Battle::Move
user.pbCureStatus(false)
case old_status
when :BURN
@battle.pbDisplay(_INTL("{1} healed its burn!",user.pbThis))
@battle.pbDisplay(_INTL("{1} healed its burn!", user.pbThis))
when :POISON
@battle.pbDisplay(_INTL("{1} cured its poisoning!",user.pbThis))
@battle.pbDisplay(_INTL("{1} cured its poisoning!", user.pbThis))
when :PARALYSIS
@battle.pbDisplay(_INTL("{1} cured its paralysis!",user.pbThis))
@battle.pbDisplay(_INTL("{1} cured its paralysis!", user.pbThis))
end
end
end
@@ -426,7 +426,7 @@ class Battle::Move::CureUserPartyStatus < Battle::Move
def canSnatch?; return true; end
def worksWithNoTargets?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
has_effect = @battle.allSameSideBattlers(user).any? { |b| b.status != :NONE }
if !has_effect
has_effect = @battle.pbParty(user.index).any? { |pkmn| pkmn && pkmn.able? && pkmn.status != :NONE }
@@ -442,7 +442,7 @@ class Battle::Move::CureUserPartyStatus < Battle::Move
return target.status == :NONE
end
def pbAromatherapyHeal(pkmn,battler = nil)
def pbAromatherapyHeal(pkmn, battler = nil)
oldStatus = (battler) ? battler.status : pkmn.status
curedName = (battler) ? battler.pbThis : pkmn.name
if battler
@@ -453,21 +453,21 @@ class Battle::Move::CureUserPartyStatus < Battle::Move
end
case oldStatus
when :SLEEP
@battle.pbDisplay(_INTL("{1} was woken from sleep.",curedName))
@battle.pbDisplay(_INTL("{1} was woken from sleep.", curedName))
when :POISON
@battle.pbDisplay(_INTL("{1} was cured of its poisoning.",curedName))
@battle.pbDisplay(_INTL("{1} was cured of its poisoning.", curedName))
when :BURN
@battle.pbDisplay(_INTL("{1}'s burn was healed.",curedName))
@battle.pbDisplay(_INTL("{1}'s burn was healed.", curedName))
when :PARALYSIS
@battle.pbDisplay(_INTL("{1} was cured of paralysis.",curedName))
@battle.pbDisplay(_INTL("{1} was cured of paralysis.", curedName))
when :FROZEN
@battle.pbDisplay(_INTL("{1} was thawed out.",curedName))
@battle.pbDisplay(_INTL("{1} was thawed out.", curedName))
end
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
# Cure all Pokémon in battle on the user's side.
pbAromatherapyHeal(target.pokemon,target)
pbAromatherapyHeal(target.pokemon, target)
end
def pbEffectGeneral(user)
@@ -481,14 +481,14 @@ class Battle::Move::CureUserPartyStatus < Battle::Move
# Cure all Pokémon in the user's and partner trainer's party.
# NOTE: This intentionally affects the partner trainer's inactive Pokémon
# too.
@battle.pbParty(user.index).each_with_index do |pkmn,i|
@battle.pbParty(user.index).each_with_index do |pkmn, i|
next if !pkmn || !pkmn.able? || pkmn.status == :NONE
next if @battle.pbFindBattler(i,user) # Skip Pokémon in battle
next if @battle.pbFindBattler(i, user) # Skip Pokémon in battle
pbAromatherapyHeal(pkmn)
end
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
super
if @id == :AROMATHERAPY
@battle.pbDisplay(_INTL("A soothing aroma wafted through the area!"))
@@ -502,7 +502,7 @@ end
# Cures the target's burn. (Sparkling Aria)
#===============================================================================
class Battle::Move::CureTargetBurn < Battle::Move
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.fainted? || target.damageState.substitute
return if target.status != :BURN
target.pbCureStatus
@@ -516,8 +516,8 @@ end
class Battle::Move::StartUserSideImmunityToInflictedStatus < Battle::Move
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
if user.pbOwnSide.effects[PBEffects::Safeguard]>0
def pbMoveFailed?(user, targets)
if user.pbOwnSide.effects[PBEffects::Safeguard] > 0
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -526,7 +526,7 @@ class Battle::Move::StartUserSideImmunityToInflictedStatus < Battle::Move
def pbEffectGeneral(user)
user.pbOwnSide.effects[PBEffects::Safeguard] = 5
@battle.pbDisplay(_INTL("{1} became cloaked in a mystical veil!",user.pbTeam))
@battle.pbDisplay(_INTL("{1} became cloaked in a mystical veil!", user.pbTeam))
end
end
@@ -536,12 +536,12 @@ end
class Battle::Move::FlinchTarget < Battle::Move
def flinchingMove?; return true; end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if damagingMove?
target.pbFlinch(user)
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
target.pbFlinch(user)
end
@@ -553,8 +553,8 @@ end
#===============================================================================
class Battle::Move::FlinchTargetTrampleMinimize < Battle::Move::FlinchTarget
def tramplesMinimize?(param = 1)
return true if param==1 && Settings::MECHANICS_GENERATION >= 6 # Perfect accuracy
return true if param==2 # Double damage
return true if param == 1 && Settings::MECHANICS_GENERATION >= 6 # Perfect accuracy
return true if param == 2 # Double damage
return super
end
end
@@ -565,7 +565,7 @@ end
class Battle::Move::FlinchTargetFailsIfUserNotAsleep < Battle::Move::FlinchTarget
def usableWhenAsleep?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !user.asleep?
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -579,7 +579,7 @@ end
# (Fake Out)
#===============================================================================
class Battle::Move::FlinchTargetFailsIfNotUserFirstTurn < Battle::Move::FlinchTarget
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.turnCount > 1
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -595,11 +595,11 @@ end
class Battle::Move::FlinchTargetDoublePowerIfTargetInSky < Battle::Move::FlinchTarget
def hitsFlyingTargets?; return true; end
def pbBaseDamage(baseDmg,user,target)
def pbBaseDamage(baseDmg, user, target)
baseDmg *= 2 if target.inTwoTurnAttack?("TwoTurnAttackInvulnerableInSky",
"TwoTurnAttackInvulnerableInSkyParalyzeTarget",
"TwoTurnAttackInvulnerableInSkyTargetCannotAct") ||
target.effects[PBEffects::SkyDrop]>=0
target.effects[PBEffects::SkyDrop] >= 0
return baseDmg
end
end
@@ -615,14 +615,14 @@ class Battle::Move::ConfuseTarget < Battle::Move
return !target.pbCanConfuse?(user, show_message, self)
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if damagingMove?
target.pbConfuse
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
return if !target.pbCanConfuse?(user,false,self)
return if !target.pbCanConfuse?(user, false, self)
target.pbConfuse
end
end
@@ -634,7 +634,7 @@ end
class Battle::Move::ConfuseTargetAlwaysHitsInRainHitsTargetInSky < Battle::Move::ConfuseTarget
def hitsFlyingTargets?; return true; end
def pbBaseAccuracy(user,target)
def pbBaseAccuracy(user, target)
case target.effectiveWeather
when :Sun, :HarshSun
return 50
@@ -659,14 +659,14 @@ class Battle::Move::AttractTarget < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if damagingMove?
target.pbAttract(user)
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
target.pbAttract(user) if target.pbCanAttract?(user,false)
target.pbAttract(user) if target.pbCanAttract?(user, false)
end
end
@@ -676,7 +676,7 @@ end
class Battle::Move::SetUserTypesBasedOnEnvironment < Battle::Move
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !user.canChangeType?
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -742,7 +742,7 @@ class Battle::Move::SetUserTypesBasedOnEnvironment < Battle::Move
def pbEffectGeneral(user)
user.pbChangeTypes(@newType)
typeName = GameData::Type.get(@newType).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))
end
end
@@ -794,7 +794,7 @@ end
class Battle::Move::SetUserTypesToTargetTypes < Battle::Move
def ignoresSubstitute?(user); return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !user.canChangeType?
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -804,22 +804,22 @@ class Battle::Move::SetUserTypesToTargetTypes < Battle::Move
def pbFailsAgainstTarget?(user, target, show_message)
newTypes = target.pbTypes(true)
if newTypes.length==0 # Target has no type to copy
if newTypes.length == 0 # Target has no type to copy
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
if user.pbTypes==target.pbTypes &&
user.effects[PBEffects::Type3]==target.effects[PBEffects::Type3]
if user.pbTypes == target.pbTypes &&
user.effects[PBEffects::Type3] == target.effects[PBEffects::Type3]
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
user.pbChangeTypes(target)
@battle.pbDisplay(_INTL("{1}'s type changed to match {2}'s!",
user.pbThis,target.pbThis(true)))
user.pbThis, target.pbThis(true)))
end
end
@@ -831,20 +831,20 @@ end
class Battle::Move::SetUserTypesToUserMoveType < Battle::Move
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !user.canChangeType?
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
userTypes = user.pbTypes(true)
@newTypes = []
user.eachMoveWithIndex do |m,i|
break if Settings::MECHANICS_GENERATION >= 6 && i>0
user.eachMoveWithIndex do |m, i|
break if Settings::MECHANICS_GENERATION >= 6 && i > 0
next if GameData::Type.get(m.type).pseudo_type
next if userTypes.include?(m.type)
@newTypes.push(m.type) if !@newTypes.include?(m.type)
end
if @newTypes.length==0
if @newTypes.length == 0
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -855,7 +855,7 @@ class Battle::Move::SetUserTypesToUserMoveType < Battle::Move
newType = @newTypes[@battle.pbRandom(@newTypes.length)]
user.pbChangeTypes(newType)
typeName = GameData::Type.get(newType).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))
end
end
@@ -896,10 +896,10 @@ class Battle::Move::SetTargetTypesToWater < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.pbChangeTypes(:WATER)
typeName = GameData::Type.get(:WATER).name
@battle.pbDisplay(_INTL("{1}'s type changed to {2}!",target.pbThis,typeName))
@battle.pbDisplay(_INTL("{1}'s type changed to {2}!", target.pbThis, typeName))
end
end
@@ -917,10 +917,10 @@ class Battle::Move::AddGhostTypeToTarget < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::Type3] = :GHOST
typeName = GameData::Type.get(:GHOST).name
@battle.pbDisplay(_INTL("{1} transformed into the {2} type!",target.pbThis,typeName))
@battle.pbDisplay(_INTL("{1} transformed into the {2} type!", target.pbThis, typeName))
end
end
@@ -938,10 +938,10 @@ class Battle::Move::AddGrassTypeToTarget < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::Type3] = :GRASS
typeName = GameData::Type.get(:GRASS).name
@battle.pbDisplay(_INTL("{1} transformed into the {2} type!",target.pbThis,typeName))
@battle.pbDisplay(_INTL("{1} transformed into the {2} type!", target.pbThis, typeName))
end
end
@@ -949,7 +949,7 @@ end
# User loses their Fire type. Fails if user is not Fire-type. (Burn Up)
#===============================================================================
class Battle::Move::UserLosesFireType < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !user.pbHasType?(:FIRE)
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -957,10 +957,10 @@ class Battle::Move::UserLosesFireType < Battle::Move
return false
end
def pbEffectAfterAllHits(user,target)
def pbEffectAfterAllHits(user, target)
if !user.effects[PBEffects::BurnUp]
user.effects[PBEffects::BurnUp] = true
@battle.pbDisplay(_INTL("{1} burned itself out!",user.pbThis))
@battle.pbDisplay(_INTL("{1} burned itself out!", user.pbThis))
end
end
end
@@ -971,7 +971,7 @@ end
class Battle::Move::SetTargetAbilityToSimple < Battle::Move
def canMagicCoat?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !GameData::Ability.exists?(:SIMPLE)
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -987,12 +987,12 @@ class Battle::Move::SetTargetAbilityToSimple < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
@battle.pbShowAbilitySplash(target,true,false)
def pbEffectAgainstTarget(user, target)
@battle.pbShowAbilitySplash(target, true, false)
oldAbil = target.ability
target.ability = :SIMPLE
@battle.pbReplaceAbilitySplash(target)
@battle.pbDisplay(_INTL("{1} acquired {2}!",target.pbThis,target.abilityName))
@battle.pbDisplay(_INTL("{1} acquired {2}!", target.pbThis, target.abilityName))
@battle.pbHideAbilitySplash(target)
target.pbOnLosingAbility(oldAbil)
target.pbTriggerAbilityOnGainingIt
@@ -1005,7 +1005,7 @@ end
class Battle::Move::SetTargetAbilityToInsomnia < Battle::Move
def canMagicCoat?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !GameData::Ability.exists?(:INSOMNIA)
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -1021,12 +1021,12 @@ class Battle::Move::SetTargetAbilityToInsomnia < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
@battle.pbShowAbilitySplash(target,true,false)
def pbEffectAgainstTarget(user, target)
@battle.pbShowAbilitySplash(target, true, false)
oldAbil = target.ability
target.ability = :INSOMNIA
@battle.pbReplaceAbilitySplash(target)
@battle.pbDisplay(_INTL("{1} acquired {2}!",target.pbThis,target.abilityName))
@battle.pbDisplay(_INTL("{1} acquired {2}!", target.pbThis, target.abilityName))
@battle.pbHideAbilitySplash(target)
target.pbOnLosingAbility(oldAbil)
target.pbTriggerAbilityOnGainingIt
@@ -1039,7 +1039,7 @@ end
class Battle::Move::SetUserAbilityToTargetAbility < Battle::Move
def ignoresSubstitute?(user); return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.unstoppableAbility?
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -1048,7 +1048,7 @@ class Battle::Move::SetUserAbilityToTargetAbility < Battle::Move
end
def pbFailsAgainstTarget?(user, target, show_message)
if !target.ability || user.ability==target.ability
if !target.ability || user.ability == target.ability
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
@@ -1060,13 +1060,13 @@ class Battle::Move::SetUserAbilityToTargetAbility < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
@battle.pbShowAbilitySplash(user,true,false)
def pbEffectAgainstTarget(user, target)
@battle.pbShowAbilitySplash(user, true, false)
oldAbil = user.ability
user.ability = target.ability
@battle.pbReplaceAbilitySplash(user)
@battle.pbDisplay(_INTL("{1} copied {2}'s {3}!",
user.pbThis,target.pbThis(true),target.abilityName))
user.pbThis, target.pbThis(true), target.abilityName))
@battle.pbHideAbilitySplash(user)
user.pbOnLosingAbility(oldAbil)
user.pbTriggerAbilityOnGainingIt
@@ -1079,7 +1079,7 @@ end
class Battle::Move::SetTargetAbilityToUserAbility < Battle::Move
def canMagicCoat?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !user.ability
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -1100,12 +1100,12 @@ class Battle::Move::SetTargetAbilityToUserAbility < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
@battle.pbShowAbilitySplash(target,true,false)
def pbEffectAgainstTarget(user, target)
@battle.pbShowAbilitySplash(target, true, false)
oldAbil = target.ability
target.ability = user.ability
@battle.pbReplaceAbilitySplash(target)
@battle.pbDisplay(_INTL("{1} acquired {2}!",target.pbThis,target.abilityName))
@battle.pbDisplay(_INTL("{1} acquired {2}!", target.pbThis, target.abilityName))
@battle.pbHideAbilitySplash(target)
target.pbOnLosingAbility(oldAbil)
target.pbTriggerAbilityOnGainingIt
@@ -1118,7 +1118,7 @@ end
class Battle::Move::UserTargetSwapAbilities < Battle::Move
def ignoresSubstitute?(user); return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !user.ability
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -1151,10 +1151,10 @@ class Battle::Move::UserTargetSwapAbilities < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
if user.opposes?(target)
@battle.pbShowAbilitySplash(user,false,false)
@battle.pbShowAbilitySplash(target,true,false)
@battle.pbShowAbilitySplash(user, false, false)
@battle.pbShowAbilitySplash(target, true, false)
end
oldUserAbil = user.ability
oldTargetAbil = target.ability
@@ -1165,10 +1165,10 @@ class Battle::Move::UserTargetSwapAbilities < Battle::Move
@battle.pbReplaceAbilitySplash(target)
end
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} swapped Abilities with its target!",user.pbThis))
@battle.pbDisplay(_INTL("{1} swapped Abilities with its target!", user.pbThis))
else
@battle.pbDisplay(_INTL("{1} swapped its {2} Ability with its target's {3} Ability!",
user.pbThis,target.abilityName,user.abilityName))
user.pbThis, target.abilityName, user.abilityName))
end
if user.opposes?(target)
@battle.pbHideAbilitySplash(user)
@@ -1195,10 +1195,10 @@ class Battle::Move::NegateTargetAbility < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::GastroAcid] = true
target.effects[PBEffects::Truant] = false
@battle.pbDisplay(_INTL("{1}'s Ability was suppressed!",target.pbThis))
@battle.pbDisplay(_INTL("{1}'s Ability was suppressed!", target.pbThis))
target.pbOnLosingAbility(target.ability, true)
end
end
@@ -1208,15 +1208,15 @@ end
# performed its action this round. (Core Enforcer)
#===============================================================================
class Battle::Move::NegateTargetAbilityIfTargetActed < Battle::Move
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if target.damageState.substitute || target.effects[PBEffects::GastroAcid]
return if target.unstoppableAbility?
return if @battle.choices[target.index][0]!=:UseItem &&
!((@battle.choices[target.index][0]==:UseMove ||
@battle.choices[target.index][0]==:Shift) && target.movedThisRound?)
return if @battle.choices[target.index][0] != :UseItem &&
!((@battle.choices[target.index][0] == :UseMove ||
@battle.choices[target.index][0] == :Shift) && target.movedThisRound?)
target.effects[PBEffects::GastroAcid] = true
target.effects[PBEffects::Truant] = false
@battle.pbDisplay(_INTL("{1}'s Ability was suppressed!",target.pbThis))
@battle.pbDisplay(_INTL("{1}'s Ability was suppressed!", target.pbThis))
target.pbOnLosingAbility(target.ability, true)
end
end
@@ -1226,7 +1226,7 @@ end
# (Moongeist Beam, Sunsteel Strike)
#===============================================================================
class Battle::Move::IgnoreTargetAbility < Battle::Move
def pbChangeUsageCounters(user,specialUsage)
def pbChangeUsageCounters(user, specialUsage)
super
@battle.moldBreaker = true if !specialUsage
end
@@ -1239,10 +1239,10 @@ class Battle::Move::StartUserAirborne < Battle::Move
def unusableInGravity?; return true; end
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.effects[PBEffects::Ingrain] ||
user.effects[PBEffects::SmackDown] ||
user.effects[PBEffects::MagnetRise]>0
user.effects[PBEffects::MagnetRise] > 0
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -1251,7 +1251,7 @@ class Battle::Move::StartUserAirborne < Battle::Move
def pbEffectGeneral(user)
user.effects[PBEffects::MagnetRise] = 5
@battle.pbDisplay(_INTL("{1} levitated with electromagnetism!",user.pbThis))
@battle.pbDisplay(_INTL("{1} levitated with electromagnetism!", user.pbThis))
end
end
@@ -1265,7 +1265,7 @@ class Battle::Move::StartTargetAirborneAndAlwaysHitByMoves < Battle::Move
def pbFailsAgainstTarget?(user, target, show_message)
if target.effects[PBEffects::Ingrain] ||
target.effects[PBEffects::SmackDown] ||
target.effects[PBEffects::Telekinesis]>0
target.effects[PBEffects::Telekinesis] > 0
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
@@ -1280,9 +1280,9 @@ class Battle::Move::StartTargetAirborneAndAlwaysHitByMoves < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::Telekinesis] = 3
@battle.pbDisplay(_INTL("{1} was hurled into the air!",target.pbThis))
@battle.pbDisplay(_INTL("{1} was hurled into the air!", target.pbThis))
end
end
@@ -1300,19 +1300,19 @@ end
class Battle::Move::HitsTargetInSkyGroundsTarget < Battle::Move
def hitsFlyingTargets?; return true; end
def pbCalcTypeModSingle(moveType,defType,user,target)
def pbCalcTypeModSingle(moveType, defType, user, target)
return Effectiveness::NORMAL_EFFECTIVE_ONE if moveType == :GROUND && defType == :FLYING
return super
end
def pbEffectAfterAllHits(user,target)
def pbEffectAfterAllHits(user, target)
return if target.fainted?
return if target.damageState.unaffected || target.damageState.substitute
return if target.inTwoTurnAttack?("TwoTurnAttackInvulnerableInSkyTargetCannotAct") ||
target.effects[PBEffects::SkyDrop]>=0 # Sky Drop
target.effects[PBEffects::SkyDrop] >= 0 # Sky Drop
return if !target.airborne? && !target.inTwoTurnAttack?("TwoTurnAttackInvulnerableInSky",
"TwoTurnAttackInvulnerableInSkyParalyzeTarget")
target.effects[PBEffects::SmackDown] = true
target.effects[PBEffects::SmackDown] = true
if target.inTwoTurnAttack?("TwoTurnAttackInvulnerableInSky",
"TwoTurnAttackInvulnerableInSkyParalyzeTarget") # NOTE: Not Sky Drop.
target.effects[PBEffects::TwoTurnAttack] = nil
@@ -1320,7 +1320,7 @@ class Battle::Move::HitsTargetInSkyGroundsTarget < Battle::Move
end
target.effects[PBEffects::MagnetRise] = 0
target.effects[PBEffects::Telekinesis] = 0
@battle.pbDisplay(_INTL("{1} fell straight down!",target.pbThis))
@battle.pbDisplay(_INTL("{1} fell straight down!", target.pbThis))
end
end
@@ -1329,8 +1329,8 @@ end
# (Gravity)
#===============================================================================
class Battle::Move::StartGravity < Battle::Move
def pbMoveFailed?(user,targets)
if @battle.field.effects[PBEffects::Gravity]>0
def pbMoveFailed?(user, targets)
if @battle.field.effects[PBEffects::Gravity] > 0
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -1349,9 +1349,9 @@ class Battle::Move::StartGravity < Battle::Move
@battle.pbClearChoice(b.index) if !b.movedThisRound?
showMessage = true
end
if b.effects[PBEffects::MagnetRise]>0 ||
b.effects[PBEffects::Telekinesis]>0 ||
b.effects[PBEffects::SkyDrop]>=0
if b.effects[PBEffects::MagnetRise] > 0 ||
b.effects[PBEffects::Telekinesis] > 0 ||
b.effects[PBEffects::SkyDrop] >= 0
b.effects[PBEffects::MagnetRise] = 0
b.effects[PBEffects::Telekinesis] = 0
b.effects[PBEffects::SkyDrop] = -1
@@ -1367,7 +1367,7 @@ end
# User transforms into the target. (Transform)
#===============================================================================
class Battle::Move::TransformUserIntoTarget < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.effects[PBEffects::Transform]
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -1384,12 +1384,12 @@ class Battle::Move::TransformUserIntoTarget < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
user.pbTransform(target)
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
super
@battle.scene.pbChangePokemon(user,targets[0].pokemon)
@battle.scene.pbChangePokemon(user, targets[0].pokemon)
end
end

View File

@@ -2,16 +2,16 @@
# Hits twice.
#===============================================================================
class Battle::Move::HitTwoTimes < Battle::Move
def multiHitMove?; return true; end
def pbNumHits(user,targets); return 2; end
def multiHitMove?; return true; end
def pbNumHits(user, targets); return 2; end
end
#===============================================================================
# Hits twice. May poison the target on each hit. (Twineedle)
#===============================================================================
class Battle::Move::HitTwoTimesPoisonTarget < Battle::Move::PoisonTarget
def multiHitMove?; return true; end
def pbNumHits(user,targets); return 2; end
def multiHitMove?; return true; end
def pbNumHits(user, targets); return 2; end
end
#===============================================================================
@@ -69,19 +69,19 @@ end
# An accuracy check is performed for each hit.
#===============================================================================
class Battle::Move::HitThreeTimesPowersUpWithEachHit < Battle::Move
def multiHitMove?; return true; end
def pbNumHits(user,targets); return 3; end
def multiHitMove?; return true; end
def pbNumHits(user, targets); return 3; end
def successCheckPerHit?
return @accCheckPerHit
end
def pbOnStartUse(user,targets)
def pbOnStartUse(user, targets)
@calcBaseDmg = 0
@accCheckPerHit = !user.hasActiveAbility?(:SKILLLINK)
end
def pbBaseDamage(baseDmg,user,target)
def pbBaseDamage(baseDmg, user, target)
@calcBaseDmg += baseDmg
return @calcBaseDmg
end
@@ -103,7 +103,7 @@ end
class Battle::Move::HitTwoToFiveTimes < Battle::Move
def multiHitMove?; return true; end
def pbNumHits(user,targets)
def pbNumHits(user, targets)
hitChances = [
2, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3,
@@ -111,7 +111,7 @@ class Battle::Move::HitTwoToFiveTimes < Battle::Move
5, 5, 5
]
r = @battle.pbRandom(hitChances.length)
r = hitChances.length-1 if user.hasActiveAbility?(:SKILLLINK)
r = hitChances.length - 1 if user.hasActiveAbility?(:SKILLLINK)
return hitChances[r]
end
end
@@ -121,12 +121,12 @@ end
# (Water Shuriken)
#===============================================================================
class Battle::Move::HitTwoToFiveTimesOrThreeForAshGreninja < Battle::Move::HitTwoToFiveTimes
def pbNumHits(user,targets)
def pbNumHits(user, targets)
return 3 if user.isSpecies?(:GRENINJA) && user.form == 2
return super
end
def pbBaseDamage(baseDmg,user,target)
def pbBaseDamage(baseDmg, user, target)
return 20 if user.isSpecies?(:GRENINJA) && user.form == 2
return super
end
@@ -171,27 +171,27 @@ end
class Battle::Move::HitOncePerUserTeamMember < Battle::Move
def multiHitMove?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
@beatUpList = []
@battle.eachInTeamFromBattlerIndex(user.index) do |pkmn,i|
@battle.eachInTeamFromBattlerIndex(user.index) do |pkmn, i|
next if !pkmn.able? || pkmn.status != :NONE
@beatUpList.push(i)
end
if @beatUpList.length==0
if @beatUpList.length == 0
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
return false
end
def pbNumHits(user,targets)
def pbNumHits(user, targets)
return @beatUpList.length
end
def pbBaseDamage(baseDmg,user,target)
def pbBaseDamage(baseDmg, user, target)
i = @beatUpList.shift # First element in array, and removes it from array
atk = @battle.pbParty(user.index)[i].baseStats[:ATTACK]
return 5+(atk/10)
return 5 + (atk / 10)
end
end
@@ -209,8 +209,8 @@ end
# Two turn attack. Skips first turn, attacks second turn. (Razor Wind)
#===============================================================================
class Battle::Move::TwoTurnAttack < Battle::Move::TwoTurnMove
def pbChargingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} whipped up a whirlwind!",user.pbThis))
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} whipped up a whirlwind!", user.pbThis))
end
end
@@ -232,11 +232,11 @@ class Battle::Move::TwoTurnAttackOneTurnInSun < Battle::Move::TwoTurnMove
return ret
end
def pbChargingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} took in sunlight!",user.pbThis))
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} took in sunlight!", user.pbThis))
end
def pbBaseDamageMultiplier(damageMult,user,target)
def pbBaseDamageMultiplier(damageMult, user, target)
damageMult /= 2 if ![:None, :Sun, :HarshSun].include?(user.effectiveWeather)
return damageMult
end
@@ -247,13 +247,13 @@ end
# May paralyze the target.
#===============================================================================
class Battle::Move::TwoTurnAttackParalyzeTarget < Battle::Move::TwoTurnMove
def pbChargingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} became cloaked in a freezing light!",user.pbThis))
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} became cloaked in a freezing light!", user.pbThis))
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
target.pbParalyze(user) if target.pbCanParalyze?(user,false,self)
target.pbParalyze(user) if target.pbCanParalyze?(user, false, self)
end
end
@@ -262,13 +262,13 @@ end
# May burn the target.
#===============================================================================
class Battle::Move::TwoTurnAttackBurnTarget < Battle::Move::TwoTurnMove
def pbChargingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} became cloaked in freezing air!",user.pbThis))
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} became cloaked in freezing air!", user.pbThis))
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
target.pbBurn(user) if target.pbCanBurn?(user,false,self)
target.pbBurn(user) if target.pbCanBurn?(user, false, self)
end
end
@@ -279,11 +279,11 @@ end
class Battle::Move::TwoTurnAttackFlinchTarget < Battle::Move::TwoTurnMove
def flinchingMove?; return true; end
def pbChargingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} became cloaked in a harsh light!",user.pbThis))
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} became cloaked in a harsh light!", user.pbThis))
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
target.pbFlinch(user)
end
@@ -294,27 +294,27 @@ end
# Special Defense and Speed by 2 stages each in the second turn. (Geomancy)
#===============================================================================
class Battle::Move::TwoTurnAttackRaiseUserSpAtkSpDefSpd2 < Battle::Move::TwoTurnMove
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
return false if user.effects[PBEffects::TwoTurnAttack] # Charging turn
if !user.pbCanRaiseStatStage?(:SPECIAL_ATTACK,user,self) &&
!user.pbCanRaiseStatStage?(:SPECIAL_DEFENSE,user,self) &&
!user.pbCanRaiseStatStage?(:SPEED,user,self)
@battle.pbDisplay(_INTL("{1}'s stats won't go any higher!",user.pbThis))
if !user.pbCanRaiseStatStage?(:SPECIAL_ATTACK, user, self) &&
!user.pbCanRaiseStatStage?(:SPECIAL_DEFENSE, user, self) &&
!user.pbCanRaiseStatStage?(:SPEED, user, self)
@battle.pbDisplay(_INTL("{1}'s stats won't go any higher!", user.pbThis))
return true
end
return false
end
def pbChargingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} is absorbing power!",user.pbThis))
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} is absorbing power!", user.pbThis))
end
def pbEffectGeneral(user)
return if !@damagingTurn
showAnim = true
[:SPECIAL_ATTACK,:SPECIAL_DEFENSE,:SPEED].each do |s|
next if !user.pbCanRaiseStatStage?(s,user,self)
if user.pbRaiseStatStage(s,2,user,showAnim)
[:SPECIAL_ATTACK, :SPECIAL_DEFENSE, :SPEED].each do |s|
next if !user.pbCanRaiseStatStage?(s, user, self)
if user.pbRaiseStatStage(s, 2, user, showAnim)
showAnim = false
end
end
@@ -326,13 +326,13 @@ end
# (Skull Bash)
#===============================================================================
class Battle::Move::TwoTurnAttackChargeRaiseUserDefense1 < Battle::Move::TwoTurnMove
def pbChargingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} tucked in its head!",user.pbThis))
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} tucked in its head!", user.pbThis))
end
def pbChargingTurnEffect(user,target)
if user.pbCanRaiseStatStage?(:DEFENSE,user,self)
user.pbRaiseStatStage(:DEFENSE,1,user)
def pbChargingTurnEffect(user, target)
if user.pbCanRaiseStatStage?(:DEFENSE, user, self)
user.pbRaiseStatStage(:DEFENSE, 1, user)
end
end
end
@@ -358,8 +358,8 @@ end
# (Handled in Battler's pbSuccessCheckPerHit): Is semi-invulnerable during use.
#===============================================================================
class Battle::Move::TwoTurnAttackInvulnerableUnderground < Battle::Move::TwoTurnMove
def pbChargingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} burrowed its way under the ground!",user.pbThis))
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} burrowed its way under the ground!", user.pbThis))
end
end
@@ -368,8 +368,8 @@ end
# (Handled in Battler's pbSuccessCheckPerHit): Is semi-invulnerable during use.
#===============================================================================
class Battle::Move::TwoTurnAttackInvulnerableUnderwater < Battle::Move::TwoTurnMove
def pbChargingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} hid underwater!",user.pbThis))
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} hid underwater!", user.pbThis))
end
end
@@ -380,8 +380,8 @@ end
class Battle::Move::TwoTurnAttackInvulnerableInSky < Battle::Move::TwoTurnMove
def unusableInGravity?; return true; end
def pbChargingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} flew up high!",user.pbThis))
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} flew up high!", user.pbThis))
end
end
@@ -393,13 +393,13 @@ end
class Battle::Move::TwoTurnAttackInvulnerableInSkyParalyzeTarget < Battle::Move::TwoTurnMove
def unusableInGravity?; return true; end
def pbChargingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} sprang up!",user.pbThis))
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} sprang up!", user.pbThis))
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.damageState.substitute
target.pbParalyze(user) if target.pbCanParalyze?(user,false,self)
target.pbParalyze(user) if target.pbCanParalyze?(user, false, self)
end
end
@@ -426,44 +426,44 @@ class Battle::Move::TwoTurnAttackInvulnerableInSkyTargetCannotAct < Battle::Move
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
if target.effects[PBEffects::Substitute]>0 && !ignoresSubstitute?(user)
if target.effects[PBEffects::Substitute] > 0 && !ignoresSubstitute?(user)
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
if Settings::MECHANICS_GENERATION >= 6 && target.pbWeight>=2000 # 200.0kg
if Settings::MECHANICS_GENERATION >= 6 && target.pbWeight >= 2000 # 200.0kg
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
if target.semiInvulnerable? ||
(target.effects[PBEffects::SkyDrop]>=0 && @chargingTurn)
(target.effects[PBEffects::SkyDrop] >= 0 && @chargingTurn)
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
if target.effects[PBEffects::SkyDrop]!=user.index && @damagingTurn
if target.effects[PBEffects::SkyDrop] != user.index && @damagingTurn
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
return false
end
def pbCalcTypeMod(movetype,user,target)
def pbCalcTypeMod(movetype, user, target)
return Effectiveness::INEFFECTIVE if target.pbHasType?(:FLYING)
return super
end
def pbChargingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} took {2} into the sky!",user.pbThis,targets[0].pbThis(true)))
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} took {2} into the sky!", user.pbThis, targets[0].pbThis(true)))
end
def pbAttackingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} was freed from the Sky Drop!",targets[0].pbThis))
def pbAttackingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} was freed from the Sky Drop!", targets[0].pbThis))
end
def pbChargingTurnEffect(user,target)
def pbChargingTurnEffect(user, target)
target.effects[PBEffects::SkyDrop] = user.index
end
def pbAttackingTurnEffect(user,target)
def pbAttackingTurnEffect(user, target)
target.effects[PBEffects::SkyDrop] = -1
end
end
@@ -473,11 +473,11 @@ end
# use. Ends target's protections upon hit. (Shadow Force, Phantom Force)
#===============================================================================
class Battle::Move::TwoTurnAttackInvulnerableRemoveProtections < Battle::Move::TwoTurnMove
def pbChargingTurnMessage(user,targets)
@battle.pbDisplay(_INTL("{1} vanished instantly!",user.pbThis))
def pbChargingTurnMessage(user, targets)
@battle.pbDisplay(_INTL("{1} vanished instantly!", user.pbThis))
end
def pbAttackingTurnEffect(user,target)
def pbAttackingTurnEffect(user, target)
target.effects[PBEffects::BanefulBunker] = false
target.effects[PBEffects::KingsShield] = false
target.effects[PBEffects::Obstruct] = false
@@ -499,10 +499,10 @@ end
#===============================================================================
class Battle::Move::MultiTurnAttackPreventSleeping < Battle::Move
def pbEffectGeneral(user)
return if user.effects[PBEffects::Uproar]>0
return if user.effects[PBEffects::Uproar] > 0
user.effects[PBEffects::Uproar] = 3
user.currentMove = @id
@battle.pbDisplay(_INTL("{1} caused an uproar!",user.pbThis))
@battle.pbDisplay(_INTL("{1} caused an uproar!", user.pbThis))
@battle.pbPriority(true).each do |b|
next if b.fainted? || b.status != :SLEEP
next if b.hasActiveAbility?(:SOUNDPROOF)
@@ -516,15 +516,15 @@ end
# (Outrage, Petal Dange, Thrash)
#===============================================================================
class Battle::Move::MultiTurnAttackConfuseUserAtEnd < Battle::Move
def pbEffectAfterAllHits(user,target)
if !target.damageState.unaffected && user.effects[PBEffects::Outrage]==0
user.effects[PBEffects::Outrage] = 2+@battle.pbRandom(2)
def pbEffectAfterAllHits(user, target)
if !target.damageState.unaffected && user.effects[PBEffects::Outrage] == 0
user.effects[PBEffects::Outrage] = 2 + @battle.pbRandom(2)
user.currentMove = @id
end
if user.effects[PBEffects::Outrage]>0
if user.effects[PBEffects::Outrage] > 0
user.effects[PBEffects::Outrage] -= 1
if user.effects[PBEffects::Outrage]==0 && user.pbCanConfuseSelf?(false)
user.pbConfuse(_INTL("{1} became confused due to fatigue!",user.pbThis))
if user.effects[PBEffects::Outrage] == 0 && user.pbCanConfuseSelf?(false)
user.pbConfuse(_INTL("{1} became confused due to fatigue!", user.pbThis))
end
end
end
@@ -535,7 +535,7 @@ end
# Power is also doubled if user has curled up. (Ice Ball, Rollout)
#===============================================================================
class Battle::Move::MultiTurnAttackPowersUpEachTurn < Battle::Move
def pbBaseDamage(baseDmg,user,target)
def pbBaseDamage(baseDmg, user, target)
shift = (5 - user.effects[PBEffects::Rollout]) # 0-4, where 0 is most powerful
shift = 0 if user.effects[PBEffects::Rollout] == 0 # For first turn
shift += 1 if user.effects[PBEffects::DefenseCurl]
@@ -543,7 +543,7 @@ class Battle::Move::MultiTurnAttackPowersUpEachTurn < Battle::Move
return baseDmg
end
def pbEffectAfterAllHits(user,target)
def pbEffectAfterAllHits(user, target)
if !target.damageState.unaffected && user.effects[PBEffects::Rollout] == 0
user.effects[PBEffects::Rollout] = 5
user.currentMove = @id
@@ -558,23 +558,23 @@ end
# (Bide)
#===============================================================================
class Battle::Move::MultiTurnAttackBideThenReturnDoubleDamage < Battle::Move::FixedDamageMove
def pbAddTarget(targets,user)
return if user.effects[PBEffects::Bide]!=1 # Not the attack turn
def pbAddTarget(targets, user)
return if user.effects[PBEffects::Bide] != 1 # Not the attack turn
idxTarget = user.effects[PBEffects::BideTarget]
t = (idxTarget>=0) ? @battle.battlers[idxTarget] : nil
if !user.pbAddTarget(targets,user,t,self,false)
user.pbAddTargetRandomFoe(targets,user,self,false)
t = (idxTarget >= 0) ? @battle.battlers[idxTarget] : nil
if !user.pbAddTarget(targets, user, t, self, false)
user.pbAddTargetRandomFoe(targets, user, self, false)
end
end
def pbMoveFailed?(user,targets)
return false if user.effects[PBEffects::Bide]!=1 # Not the attack turn
if user.effects[PBEffects::BideDamage]==0
def pbMoveFailed?(user, targets)
return false if user.effects[PBEffects::Bide] != 1 # Not the attack turn
if user.effects[PBEffects::BideDamage] == 0
@battle.pbDisplay(_INTL("But it failed!"))
user.effects[PBEffects::Bide] = 0 # No need to reset other Bide variables
return true
end
if targets.length==0
if targets.length == 0
@battle.pbDisplay(_INTL("But there was no target..."))
user.effects[PBEffects::Bide] = 0 # No need to reset other Bide variables
return true
@@ -582,15 +582,15 @@ class Battle::Move::MultiTurnAttackBideThenReturnDoubleDamage < Battle::Move::Fi
return false
end
def pbOnStartUse(user,targets)
@damagingTurn = (user.effects[PBEffects::Bide]==1) # If attack turn
def pbOnStartUse(user, targets)
@damagingTurn = (user.effects[PBEffects::Bide] == 1) # If attack turn
end
def pbDisplayUseMessage(user)
if @damagingTurn # Attack turn
@battle.pbDisplayBrief(_INTL("{1} unleashed energy!",user.pbThis))
elsif user.effects[PBEffects::Bide]>1 # Charging turns
@battle.pbDisplayBrief(_INTL("{1} is storing energy!",user.pbThis))
@battle.pbDisplayBrief(_INTL("{1} unleashed energy!", user.pbThis))
elsif user.effects[PBEffects::Bide] > 1 # Charging turns
@battle.pbDisplayBrief(_INTL("{1} is storing energy!", user.pbThis))
else
super # Start using Bide
end
@@ -601,12 +601,12 @@ class Battle::Move::MultiTurnAttackBideThenReturnDoubleDamage < Battle::Move::Fi
return super
end
def pbFixedDamage(user,target)
return user.effects[PBEffects::BideDamage]*2
def pbFixedDamage(user, target)
return user.effects[PBEffects::BideDamage] * 2
end
def pbEffectGeneral(user)
if user.effects[PBEffects::Bide]==0 # Starting using Bide
if user.effects[PBEffects::Bide] == 0 # Starting using Bide
user.effects[PBEffects::Bide] = 3
user.effects[PBEffects::BideDamage] = 0
user.effects[PBEffects::BideTarget] = -1
@@ -615,7 +615,7 @@ class Battle::Move::MultiTurnAttackBideThenReturnDoubleDamage < Battle::Move::Fi
user.effects[PBEffects::Bide] -= 1
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
hitNum = 1 if !@damagingTurn # Charging anim
super
end

View File

@@ -2,22 +2,22 @@
# Heals user to full HP. User falls asleep for 2 more rounds. (Rest)
#===============================================================================
class Battle::Move::HealUserFullyAndFallAsleep < Battle::Move::HealingMove
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.asleep?
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
return true if !user.pbCanSleep?(user,true,self,true)
return true if !user.pbCanSleep?(user, true, self, true)
return true if super
return false
end
def pbHealAmount(user)
return user.totalhp-user.hp
return user.totalhp - user.hp
end
def pbEffectGeneral(user)
user.pbSleepSelf(_INTL("{1} slept and became healthy!",user.pbThis),3)
user.pbSleepSelf(_INTL("{1} slept and became healthy!", user.pbThis), 3)
super
end
end
@@ -27,7 +27,7 @@ end
#===============================================================================
class Battle::Move::HealUserHalfOfTotalHP < Battle::Move::HealingMove
def pbHealAmount(user)
return (user.totalhp/2.0).round
return (user.totalhp / 2.0).round
end
end
@@ -36,14 +36,14 @@ end
# Synthesis)
#===============================================================================
class Battle::Move::HealUserDependingOnWeather < Battle::Move::HealingMove
def pbOnStartUse(user,targets)
def pbOnStartUse(user, targets)
case user.effectiveWeather
when :Sun, :HarshSun
@healAmount = (user.totalhp*2/3.0).round
@healAmount = (user.totalhp * 2 / 3.0).round
when :None, :StrongWinds
@healAmount = (user.totalhp/2.0).round
@healAmount = (user.totalhp / 2.0).round
else
@healAmount = (user.totalhp/4.0).round
@healAmount = (user.totalhp / 4.0).round
end
end
@@ -68,7 +68,7 @@ end
#===============================================================================
class Battle::Move::HealUserHalfOfTotalHPLoseFlyingTypeThisTurn < Battle::Move::HealingMove
def pbHealAmount(user)
return (user.totalhp/2.0).round
return (user.totalhp / 2.0).round
end
def pbEffectGeneral(user)
@@ -94,10 +94,10 @@ class Battle::Move::CureTargetStatusHealUserHalfOfTotalHP < Battle::Move::Healin
end
def pbHealAmount(user)
return (user.totalhp/2.0).round
return (user.totalhp / 2.0).round
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.pbCureStatus
super
end
@@ -129,28 +129,28 @@ class Battle::Move::HealUserByTargetAttackLowerTargetAttack1 < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
# Calculate target's effective attack value
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]
atk = target.attack
atkStage = target.stages[:ATTACK]+6
healAmt = (atk.to_f*stageMul[atkStage]/stageDiv[atkStage]).floor
atkStage = target.stages[:ATTACK] + 6
healAmt = (atk.to_f * stageMul[atkStage] / stageDiv[atkStage]).floor
# Reduce target's Attack stat
if target.pbCanLowerStatStage?(:ATTACK,user,self)
target.pbLowerStatStage(:ATTACK,1,user)
if target.pbCanLowerStatStage?(:ATTACK, user, self)
target.pbLowerStatStage(:ATTACK, 1, user)
end
# Heal user
if target.hasActiveAbility?(:LIQUIDOOZE)
@battle.pbShowAbilitySplash(target)
user.pbReduceHP(healAmt)
@battle.pbDisplay(_INTL("{1} sucked up the liquid ooze!",user.pbThis))
@battle.pbDisplay(_INTL("{1} sucked up the liquid ooze!", user.pbThis))
@battle.pbHideAbilitySplash(target)
user.pbItemHPHealCheck
elsif user.canHeal?
healAmt = (healAmt*1.3).floor if user.hasActiveItem?(:BIGROOT)
healAmt = (healAmt * 1.3).floor if user.hasActiveItem?(:BIGROOT)
user.pbRecoverHP(healAmt)
@battle.pbDisplay(_INTL("{1}'s HP was restored.",user.pbThis))
@battle.pbDisplay(_INTL("{1}'s HP was restored.", user.pbThis))
end
end
end
@@ -161,10 +161,10 @@ end
class Battle::Move::HealUserByHalfOfDamageDone < Battle::Move
def healingMove?; return Settings::MECHANICS_GENERATION >= 6; end
def pbEffectAgainstTarget(user,target)
return if target.damageState.hpLost<=0
hpGain = (target.damageState.hpLost/2.0).round
user.pbRecoverHPFromDrain(hpGain,target)
def pbEffectAgainstTarget(user, target)
return if target.damageState.hpLost <= 0
hpGain = (target.damageState.hpLost / 2.0).round
user.pbRecoverHPFromDrain(hpGain, target)
end
end
@@ -183,10 +183,10 @@ class Battle::Move::HealUserByHalfOfDamageDoneIfTargetAsleep < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
return if target.damageState.hpLost<=0
hpGain = (target.damageState.hpLost/2.0).round
user.pbRecoverHPFromDrain(hpGain,target)
def pbEffectAgainstTarget(user, target)
return if target.damageState.hpLost <= 0
hpGain = (target.damageState.hpLost / 2.0).round
user.pbRecoverHPFromDrain(hpGain, target)
end
end
@@ -196,10 +196,10 @@ end
class Battle::Move::HealUserByThreeQuartersOfDamageDone < Battle::Move
def healingMove?; return Settings::MECHANICS_GENERATION >= 6; end
def pbEffectAgainstTarget(user,target)
return if target.damageState.hpLost<=0
hpGain = (target.damageState.hpLost*0.75).round
user.pbRecoverHPFromDrain(hpGain,target)
def pbEffectAgainstTarget(user, target)
return if target.damageState.hpLost <= 0
hpGain = (target.damageState.hpLost * 0.75).round
user.pbRecoverHPFromDrain(hpGain, target)
end
end
@@ -278,7 +278,7 @@ class Battle::Move::HealTargetHalfOfTotalHP < Battle::Move
def canMagicCoat?; return true; end
def pbFailsAgainstTarget?(user, target, show_message)
if target.hp==target.totalhp
if target.hp == target.totalhp
@battle.pbDisplay(_INTL("{1}'s HP is full!", target.pbThis)) if show_message
return true
elsif !target.canHeal?
@@ -288,13 +288,13 @@ class Battle::Move::HealTargetHalfOfTotalHP < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
hpGain = (target.totalhp/2.0).round
def pbEffectAgainstTarget(user, target)
hpGain = (target.totalhp / 2.0).round
if pulseMove? && user.hasActiveAbility?(:MEGALAUNCHER)
hpGain = (target.totalhp*3/4.0).round
hpGain = (target.totalhp * 3 / 4.0).round
end
target.pbRecoverHP(hpGain)
@battle.pbDisplay(_INTL("{1}'s HP was restored.",target.pbThis))
@battle.pbDisplay(_INTL("{1}'s HP was restored.", target.pbThis))
end
end
@@ -307,7 +307,7 @@ class Battle::Move::HealTargetDependingOnGrassyTerrain < Battle::Move
def canMagicCoat?; return true; end
def pbFailsAgainstTarget?(user, target, show_message)
if target.hp==target.totalhp
if target.hp == target.totalhp
@battle.pbDisplay(_INTL("{1}'s HP is full!", target.pbThis)) if show_message
return true
elsif !target.canHeal?
@@ -317,11 +317,11 @@ class Battle::Move::HealTargetDependingOnGrassyTerrain < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
hpGain = (target.totalhp/2.0).round
hpGain = (target.totalhp*2/3.0).round if @battle.field.terrain == :Grassy
def pbEffectAgainstTarget(user, target)
hpGain = (target.totalhp / 2.0).round
hpGain = (target.totalhp * 2 / 3.0).round if @battle.field.terrain == :Grassy
target.pbRecoverHP(hpGain)
@battle.pbDisplay(_INTL("{1}'s HP was restored.",target.pbThis))
@battle.pbDisplay(_INTL("{1}'s HP was restored.", target.pbThis))
end
end
@@ -333,8 +333,8 @@ class Battle::Move::HealUserPositionNextTurn < Battle::Move
def healingMove?; return true; end
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
if @battle.positions[user.index].effects[PBEffects::Wish]>0
def pbMoveFailed?(user, targets)
if @battle.positions[user.index].effects[PBEffects::Wish] > 0
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -343,7 +343,7 @@ class Battle::Move::HealUserPositionNextTurn < Battle::Move
def pbEffectGeneral(user)
@battle.positions[user.index].effects[PBEffects::Wish] = 2
@battle.positions[user.index].effects[PBEffects::WishAmount] = (user.totalhp/2.0).round
@battle.positions[user.index].effects[PBEffects::WishAmount] = (user.totalhp / 2.0).round
@battle.positions[user.index].effects[PBEffects::WishMaker] = user.pokemonIndex
end
end
@@ -355,7 +355,7 @@ end
class Battle::Move::StartHealUserEachTurn < Battle::Move
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.effects[PBEffects::AquaRing]
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -365,7 +365,7 @@ class Battle::Move::StartHealUserEachTurn < Battle::Move
def pbEffectGeneral(user)
user.effects[PBEffects::AquaRing] = true
@battle.pbDisplay(_INTL("{1} surrounded itself with a veil of water!",user.pbThis))
@battle.pbDisplay(_INTL("{1} surrounded itself with a veil of water!", user.pbThis))
end
end
@@ -376,7 +376,7 @@ end
class Battle::Move::StartHealUserEachTurnTrapUserInBattle < Battle::Move
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.effects[PBEffects::Ingrain]
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -386,7 +386,7 @@ class Battle::Move::StartHealUserEachTurnTrapUserInBattle < Battle::Move
def pbEffectGeneral(user)
user.effects[PBEffects::Ingrain] = true
@battle.pbDisplay(_INTL("{1} planted its roots!",user.pbThis))
@battle.pbDisplay(_INTL("{1} planted its roots!", user.pbThis))
end
end
@@ -402,9 +402,9 @@ class Battle::Move::StartDamageTargetEachTurnIfTargetAsleep < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::Nightmare] = true
@battle.pbDisplay(_INTL("{1} began having a nightmare!",target.pbThis))
@battle.pbDisplay(_INTL("{1} began having a nightmare!", target.pbThis))
end
end
@@ -416,7 +416,7 @@ class Battle::Move::StartLeechSeedTarget < Battle::Move
def canMagicCoat?; return true; end
def pbFailsAgainstTarget?(user, target, show_message)
if target.effects[PBEffects::LeechSeed]>=0
if target.effects[PBEffects::LeechSeed] >= 0
@battle.pbDisplay(_INTL("{1} evaded the attack!", target.pbThis)) if show_message
return true
end
@@ -427,14 +427,14 @@ class Battle::Move::StartLeechSeedTarget < Battle::Move
return false
end
def pbMissMessage(user,target)
@battle.pbDisplay(_INTL("{1} evaded the attack!",target.pbThis))
def pbMissMessage(user, target)
@battle.pbDisplay(_INTL("{1} evaded the attack!", target.pbThis))
return true
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::LeechSeed] = user.index
@battle.pbDisplay(_INTL("{1} was seeded!",target.pbThis))
@battle.pbDisplay(_INTL("{1} was seeded!", target.pbThis))
end
end
@@ -459,16 +459,16 @@ end
class Battle::Move::UserLosesHalfOfTotalHPExplosive < Battle::Move
def worksWithNoTargets?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !@battle.moldBreaker
bearer = @battle.pbCheckGlobalAbility(:DAMP)
if bearer!=nil
if bearer != nil
@battle.pbShowAbilitySplash(bearer)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} cannot use {2}!",user.pbThis,@name))
@battle.pbDisplay(_INTL("{1} cannot use {2}!", user.pbThis, @name))
else
@battle.pbDisplay(_INTL("{1} cannot use {2} because of {3}'s {4}!",
user.pbThis,@name,bearer.pbThis(true),bearer.abilityName))
user.pbThis, @name, bearer.pbThis(true), bearer.abilityName))
end
@battle.pbHideAbilitySplash(bearer)
return true
@@ -479,7 +479,7 @@ class Battle::Move::UserLosesHalfOfTotalHPExplosive < Battle::Move
def pbSelfKO(user)
return if !user.takesIndirectDamage?
user.pbReduceHP((user.totalhp/2.0).round,false)
user.pbReduceHP((user.totalhp / 2.0).round, false)
user.pbItemHPHealCheck
end
end
@@ -489,18 +489,18 @@ end
#===============================================================================
class Battle::Move::UserFaintsExplosive < Battle::Move
def worksWithNoTargets?; return true; end
def pbNumHits(user,targets); return 1; end
def pbNumHits(user, targets); return 1; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !@battle.moldBreaker
bearer = @battle.pbCheckGlobalAbility(:DAMP)
if bearer!=nil
if bearer != nil
@battle.pbShowAbilitySplash(bearer)
if Battle::Scene::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} cannot use {2}!",user.pbThis,@name))
@battle.pbDisplay(_INTL("{1} cannot use {2}!", user.pbThis, @name))
else
@battle.pbDisplay(_INTL("{1} cannot use {2} because of {3}'s {4}!",
user.pbThis,@name,bearer.pbThis(true),bearer.abilityName))
user.pbThis, @name, bearer.pbThis(true), bearer.abilityName))
end
@battle.pbHideAbilitySplash(bearer)
return true
@@ -511,7 +511,7 @@ class Battle::Move::UserFaintsExplosive < Battle::Move
def pbSelfKO(user)
return if user.fainted?
user.pbReduceHP(user.hp,false)
user.pbReduceHP(user.hp, false)
user.pbItemHPHealCheck
end
end
@@ -532,19 +532,19 @@ end
# User faints (if successful).
#===============================================================================
class Battle::Move::UserFaintsFixedDamageUserHP < Battle::Move::FixedDamageMove
def pbNumHits(user,targets); return 1; end
def pbNumHits(user, targets); return 1; end
def pbOnStartUse(user,targets)
def pbOnStartUse(user, targets)
@finalGambitDamage = user.hp
end
def pbFixedDamage(user,target)
def pbFixedDamage(user, target)
return @finalGambitDamage
end
def pbSelfKO(user)
return if user.fainted?
user.pbReduceHP(user.hp,false)
user.pbReduceHP(user.hp, false)
user.pbItemHPHealCheck
end
end
@@ -556,9 +556,9 @@ end
class Battle::Move::UserFaintsLowerTargetAtkSpAtk2 < Battle::Move::TargetMultiStatDownMove
def canMagicCoat?; return false; end
def initialize(battle,move)
def initialize(battle, move)
super
@statDown = [:ATTACK,2,:SPECIAL_ATTACK,2]
@statDown = [:ATTACK, 2, :SPECIAL_ATTACK, 2]
end
# NOTE: The user faints even if the target's stats cannot be changed, so this
@@ -569,7 +569,7 @@ class Battle::Move::UserFaintsLowerTargetAtkSpAtk2 < Battle::Move::TargetMultiSt
def pbSelfKO(user)
return if user.fainted?
user.pbReduceHP(user.hp,false)
user.pbReduceHP(user.hp, false)
user.pbItemHPHealCheck
end
end
@@ -582,7 +582,7 @@ class Battle::Move::UserFaintsHealAndCureReplacement < Battle::Move
def healingMove?; return true; end
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !@battle.pbCanChooseNonActive?(user.index)
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -592,7 +592,7 @@ class Battle::Move::UserFaintsHealAndCureReplacement < Battle::Move
def pbSelfKO(user)
return if user.fainted?
user.pbReduceHP(user.hp,false)
user.pbReduceHP(user.hp, false)
user.pbItemHPHealCheck
@battle.positions[user.index].effects[PBEffects::HealingWish] = true
end
@@ -606,7 +606,7 @@ class Battle::Move::UserFaintsHealAndCureReplacementRestorePP < Battle::Move
def healingMove?; return true; end
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !@battle.pbCanChooseNonActive?(user.index)
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -616,7 +616,7 @@ class Battle::Move::UserFaintsHealAndCureReplacementRestorePP < Battle::Move
def pbSelfKO(user)
return if user.fainted?
user.pbReduceHP(user.hp,false)
user.pbReduceHP(user.hp, false)
user.pbItemHPHealCheck
@battle.positions[user.index].effects[PBEffects::LunarDance] = true
end
@@ -626,10 +626,10 @@ end
# All current battlers will perish after 3 more rounds. (Perish Song)
#===============================================================================
class Battle::Move::StartPerishCountsForAllBattlers < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
failed = true
targets.each do |b|
next if b.effects[PBEffects::PerishSong]>0 # Heard it before
next if b.effects[PBEffects::PerishSong] > 0 # Heard it before
failed = false
break
end
@@ -641,15 +641,15 @@ class Battle::Move::StartPerishCountsForAllBattlers < Battle::Move
end
def pbFailsAgainstTarget?(user, target, show_message)
return target.effects[PBEffects::PerishSong]>0 # Heard it before
return target.effects[PBEffects::PerishSong] > 0 # Heard it before
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::PerishSong] = 4
target.effects[PBEffects::PerishSongUser] = user.index
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
super
@battle.pbDisplay(_INTL("All Pokémon that hear the song will faint in three turns!"))
end
@@ -660,7 +660,7 @@ end
# (Destiny Bond)
#===============================================================================
class Battle::Move::AttackerFaintsIfUserFaints < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if Settings::MECHANICS_GENERATION >= 7 && user.effects[PBEffects::DestinyBondPrevious]
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -670,7 +670,7 @@ class Battle::Move::AttackerFaintsIfUserFaints < Battle::Move
def pbEffectGeneral(user)
user.effects[PBEffects::DestinyBond] = true
@battle.pbDisplay(_INTL("{1} is hoping to take its attacker down with it!",user.pbThis))
@battle.pbDisplay(_INTL("{1} is hoping to take its attacker down with it!", user.pbThis))
end
end
@@ -681,6 +681,6 @@ end
class Battle::Move::SetAttackerMovePPTo0IfUserFaints < Battle::Move
def pbEffectGeneral(user)
user.effects[PBEffects::Grudge] = true
@battle.pbDisplay(_INTL("{1} wants its target to bear a grudge!",user.pbThis))
@battle.pbDisplay(_INTL("{1} wants its target to bear a grudge!", user.pbThis))
end
end

View File

@@ -3,7 +3,7 @@
# Items stolen from wild Pokémon are kept after the battle.
#===============================================================================
class Battle::Move::UserTakesTargetItem < Battle::Move
def pbEffectAfterAllHits(user,target)
def pbEffectAfterAllHits(user, target)
return if user.wild? # Wild Pokémon can't thieve
return if user.fainted?
return if target.damageState.unaffected || target.damageState.substitute
@@ -20,7 +20,7 @@ class Battle::Move::UserTakesTargetItem < Battle::Move
else
target.pbRemoveItem(false)
end
@battle.pbDisplay(_INTL("{1} stole {2}'s {3}!",user.pbThis,target.pbThis(true),itemName))
@battle.pbDisplay(_INTL("{1} stole {2}'s {3}!", user.pbThis, target.pbThis(true), itemName))
user.pbHeldItemTriggerCheck
end
end
@@ -35,7 +35,7 @@ class Battle::Move::TargetTakesUserItem < Battle::Move
return super
end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !user.item || user.unlosableItem?(user.item)
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -51,7 +51,7 @@ class Battle::Move::TargetTakesUserItem < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
itemName = user.itemName
target.item = user.item
# Permanently steal the item from wild Pokémon
@@ -61,7 +61,7 @@ class Battle::Move::TargetTakesUserItem < Battle::Move
else
user.pbRemoveItem(false)
end
@battle.pbDisplay(_INTL("{1} received {2} from {3}!",target.pbThis,itemName,user.pbThis(true)))
@battle.pbDisplay(_INTL("{1} received {2} from {3}!", target.pbThis, itemName, user.pbThis(true)))
target.pbHeldItemTriggerCheck
end
end
@@ -71,7 +71,7 @@ end
# (Switcheroo, Trick)
#===============================================================================
class Battle::Move::UserTargetSwapItems < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.wild?
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -107,7 +107,7 @@ class Battle::Move::UserTargetSwapItems < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
oldUserItem = user.item
oldUserItemName = user.itemName
oldTargetItem = target.item
@@ -122,9 +122,9 @@ class Battle::Move::UserTargetSwapItems < Battle::Move
if target.wild? && !user.initialItem && oldTargetItem == target.initialItem
user.setInitialItem(oldTargetItem)
end
@battle.pbDisplay(_INTL("{1} switched items with its opponent!",user.pbThis))
@battle.pbDisplay(_INTL("{1} obtained {2}.",user.pbThis,oldTargetItemName)) if oldTargetItem
@battle.pbDisplay(_INTL("{1} obtained {2}.",target.pbThis,oldUserItemName)) if oldUserItem
@battle.pbDisplay(_INTL("{1} switched items with its opponent!", user.pbThis))
@battle.pbDisplay(_INTL("{1} obtained {2}.", user.pbThis, oldTargetItemName)) if oldTargetItem
@battle.pbDisplay(_INTL("{1} obtained {2}.", target.pbThis, oldUserItemName)) if oldUserItem
user.pbHeldItemTriggerCheck
target.pbHeldItemTriggerCheck
end
@@ -136,7 +136,7 @@ end
class Battle::Move::RestoreUserConsumedItem < Battle::Move
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !user.recycleItem
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -153,9 +153,9 @@ class Battle::Move::RestoreUserConsumedItem < Battle::Move
user.effects[PBEffects::PickupUse] = 0
itemName = GameData::Item.get(item).name
if itemName.starts_with_vowel?
@battle.pbDisplay(_INTL("{1} found an {2}!",user.pbThis,itemName))
@battle.pbDisplay(_INTL("{1} found an {2}!", user.pbThis, itemName))
else
@battle.pbDisplay(_INTL("{1} found a {2}!",user.pbThis,itemName))
@battle.pbDisplay(_INTL("{1} found a {2}!", user.pbThis, itemName))
end
user.pbHeldItemTriggerCheck
end
@@ -166,17 +166,17 @@ end
# If target has a losable item, damage is multiplied by 1.5.
#===============================================================================
class Battle::Move::RemoveTargetItem < Battle::Move
def pbBaseDamage(baseDmg,user,target)
def pbBaseDamage(baseDmg, user, target)
if Settings::MECHANICS_GENERATION >= 6 &&
target.item && !target.unlosableItem?(target.item)
# NOTE: Damage is still boosted even if target has Sticky Hold or a
# substitute.
baseDmg = (baseDmg*1.5).round
baseDmg = (baseDmg * 1.5).round
end
return baseDmg
end
def pbEffectAfterAllHits(user,target)
def pbEffectAfterAllHits(user, target)
return if user.wild? # Wild Pokémon can't knock off
return if user.fainted?
return if target.damageState.unaffected || target.damageState.substitute
@@ -184,7 +184,7 @@ class Battle::Move::RemoveTargetItem < Battle::Move
return if target.hasActiveAbility?(:STICKYHOLD) && !@battle.moldBreaker
itemName = target.itemName
target.pbRemoveItem(false)
@battle.pbDisplay(_INTL("{1} dropped its {2}!",target.pbThis,itemName))
@battle.pbDisplay(_INTL("{1} dropped its {2}!", target.pbThis, itemName))
end
end
@@ -192,12 +192,12 @@ end
# Target's berry/Gem is destroyed. (Incinerate)
#===============================================================================
class Battle::Move::DestroyTargetBerryOrGem < Battle::Move
def pbEffectWhenDealingDamage(user,target)
def pbEffectWhenDealingDamage(user, target)
return if target.damageState.substitute || target.damageState.berryWeakened
return if !target.item || (!target.item.is_berry? &&
!(Settings::MECHANICS_GENERATION >= 6 && target.item.is_gem?))
target.pbRemoveItem
@battle.pbDisplay(_INTL("{1}'s {2} was incinerated!",target.pbThis,target.itemName))
@battle.pbDisplay(_INTL("{1}'s {2} was incinerated!", target.pbThis, target.itemName))
end
end
@@ -251,16 +251,16 @@ class Battle::Move::StartTargetCannotUseItem < Battle::Move
def canMagicCoat?; return true; end
def pbFailsAgainstTarget?(user, target, show_message)
if target.effects[PBEffects::Embargo]>0
if target.effects[PBEffects::Embargo] > 0
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::Embargo] = 5
@battle.pbDisplay(_INTL("{1} can't use items anymore!",target.pbThis))
@battle.pbDisplay(_INTL("{1} can't use items anymore!", target.pbThis))
end
end
@@ -270,7 +270,7 @@ end
#===============================================================================
class Battle::Move::StartNegateHeldItems < Battle::Move
def pbEffectGeneral(user)
if @battle.field.effects[PBEffects::MagicRoom]>0
if @battle.field.effects[PBEffects::MagicRoom] > 0
@battle.field.effects[PBEffects::MagicRoom] = 0
@battle.pbDisplay(_INTL("The area returned to normal!"))
else
@@ -279,8 +279,8 @@ class Battle::Move::StartNegateHeldItems < Battle::Move
end
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
return if @battle.field.effects[PBEffects::MagicRoom]>0 # No animation
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
return if @battle.field.effects[PBEffects::MagicRoom] > 0 # No animation
super
end
end
@@ -374,7 +374,7 @@ end
# User consumes target's berry and gains its effect. (Bug Bite, Pluck)
#===============================================================================
class Battle::Move::UserConsumeTargetBerry < Battle::Move
def pbEffectAfterAllHits(user,target)
def pbEffectAfterAllHits(user, target)
return if user.fainted? || target.fainted?
return if target.damageState.unaffected || target.damageState.substitute
return if !target.item || !target.item.is_berry?
@@ -382,8 +382,8 @@ class Battle::Move::UserConsumeTargetBerry < Battle::Move
item = target.item
itemName = target.itemName
target.pbRemoveItem
@battle.pbDisplay(_INTL("{1} stole and ate its target's {2}!",user.pbThis,itemName))
user.pbHeldItemTriggerCheck(item,false)
@battle.pbDisplay(_INTL("{1} stole and ate its target's {2}!", user.pbThis, itemName))
user.pbHeldItemTriggerCheck(item, false)
end
end
@@ -391,114 +391,114 @@ end
# User flings its item at the target. Power/effect depend on the item. (Fling)
#===============================================================================
class Battle::Move::ThrowUserItemAtTarget < Battle::Move
def initialize(battle,move)
def initialize(battle, move)
super
# 80 => all Mega Stones
# 10 => all Berries
@flingPowers = {
130 => [:IRONBALL],
100 => [:HARDSTONE,:RAREBONE,
100 => [:HARDSTONE, :RAREBONE,
# Fossils
:ARMORFOSSIL,:CLAWFOSSIL,:COVERFOSSIL,:DOMEFOSSIL,:HELIXFOSSIL,
:JAWFOSSIL,:OLDAMBER,:PLUMEFOSSIL,:ROOTFOSSIL,:SAILFOSSIL,
:ARMORFOSSIL, :CLAWFOSSIL, :COVERFOSSIL, :DOMEFOSSIL, :HELIXFOSSIL,
:JAWFOSSIL, :OLDAMBER, :PLUMEFOSSIL, :ROOTFOSSIL, :SAILFOSSIL,
:SKULLFOSSIL],
90 => [:DEEPSEATOOTH,:GRIPCLAW,:THICKCLUB,
90 => [:DEEPSEATOOTH, :GRIPCLAW, :THICKCLUB,
# Plates
:DRACOPLATE,:DREADPLATE,:EARTHPLATE,:FISTPLATE,:FLAMEPLATE,
:ICICLEPLATE,:INSECTPLATE,:IRONPLATE,:MEADOWPLATE,:MINDPLATE,
:PIXIEPLATE,:SKYPLATE,:SPLASHPLATE,:SPOOKYPLATE,:STONEPLATE,
:TOXICPLATE,:ZAPPLATE],
80 => [:ASSAULTVEST,:CHIPPEDPOT,:CRACKEDPOT,:DAWNSTONE,:DUSKSTONE,
:ELECTIRIZER,:HEAVYDUTYBOOTS,:MAGMARIZER,:ODDKEYSTONE,:OVALSTONE,
:PROTECTOR,:QUICKCLAW,:RAZORCLAW,:SACHET,:SAFETYGOGGLES,
:SHINYSTONE,:STICKYBARB,:WEAKNESSPOLICY,:WHIPPEDDREAM],
70 => [:DRAGONFANG,:POISONBARB,
:DRACOPLATE, :DREADPLATE, :EARTHPLATE, :FISTPLATE, :FLAMEPLATE,
:ICICLEPLATE, :INSECTPLATE, :IRONPLATE, :MEADOWPLATE, :MINDPLATE,
:PIXIEPLATE, :SKYPLATE, :SPLASHPLATE, :SPOOKYPLATE, :STONEPLATE,
:TOXICPLATE, :ZAPPLATE],
80 => [:ASSAULTVEST, :CHIPPEDPOT, :CRACKEDPOT, :DAWNSTONE, :DUSKSTONE,
:ELECTIRIZER, :HEAVYDUTYBOOTS, :MAGMARIZER, :ODDKEYSTONE, :OVALSTONE,
:PROTECTOR, :QUICKCLAW, :RAZORCLAW, :SACHET, :SAFETYGOGGLES,
:SHINYSTONE, :STICKYBARB, :WEAKNESSPOLICY, :WHIPPEDDREAM],
70 => [:DRAGONFANG, :POISONBARB,
# EV-training items (Macho Brace is 60)
:POWERANKLET,:POWERBAND,:POWERBELT,:POWERBRACER,:POWERLENS,
:POWERANKLET, :POWERBAND, :POWERBELT, :POWERBRACER, :POWERLENS,
:POWERWEIGHT,
# Drives
:BURNDRIVE,:CHILLDRIVE,:DOUSEDRIVE,:SHOCKDRIVE],
60 => [:ADAMANTORB,:DAMPROCK,:GRISEOUSORB,:HEATROCK,:LEEK,:LUSTROUSORB,
:MACHOBRACE,:ROCKYHELMET,:STICK,:TERRAINEXTENDER],
50 => [:DUBIOUSDISC,:SHARPBEAK,
:BURNDRIVE, :CHILLDRIVE, :DOUSEDRIVE, :SHOCKDRIVE],
60 => [:ADAMANTORB, :DAMPROCK, :GRISEOUSORB, :HEATROCK, :LEEK, :LUSTROUSORB,
:MACHOBRACE, :ROCKYHELMET, :STICK, :TERRAINEXTENDER],
50 => [:DUBIOUSDISC, :SHARPBEAK,
# Memories
:BUGMEMORY,:DARKMEMORY,:DRAGONMEMORY,:ELECTRICMEMORY,:FAIRYMEMORY,
:FIGHTINGMEMORY,:FIREMEMORY,:FLYINGMEMORY,:GHOSTMEMORY,
:GRASSMEMORY,:GROUNDMEMORY,:ICEMEMORY,:POISONMEMORY,
:PSYCHICMEMORY,:ROCKMEMORY,:STEELMEMORY,:WATERMEMORY],
40 => [:EVIOLITE,:ICYROCK,:LUCKYPUNCH],
30 => [:ABSORBBULB,:ADRENALINEORB,:AMULETCOIN,:BINDINGBAND,:BLACKBELT,
:BLACKGLASSES,:BLACKSLUDGE,:BOTTLECAP,:CELLBATTERY,:CHARCOAL,
:CLEANSETAG,:DEEPSEASCALE,:DRAGONSCALE,:EJECTBUTTON,:ESCAPEROPE,
:EXPSHARE,:FLAMEORB,:FLOATSTONE,:FLUFFYTAIL,:GOLDBOTTLECAP,
:HEARTSCALE,:HONEY,:KINGSROCK,:LIFEORB,:LIGHTBALL,:LIGHTCLAY,
:LUCKYEGG,:LUMINOUSMOSS,:MAGNET,:METALCOAT,:METRONOME,
:MIRACLESEED,:MYSTICWATER,:NEVERMELTICE,:PASSORB,:POKEDOLL,
:POKETOY,:PRISMSCALE,:PROTECTIVEPADS,:RAZORFANG,:SACREDASH,
:SCOPELENS,:SHELLBELL,:SHOALSALT,:SHOALSHELL,:SMOKEBALL,:SNOWBALL,
:SOULDEW,:SPELLTAG,:TOXICORB,:TWISTEDSPOON,:UPGRADE,
:BUGMEMORY, :DARKMEMORY, :DRAGONMEMORY, :ELECTRICMEMORY, :FAIRYMEMORY,
:FIGHTINGMEMORY, :FIREMEMORY, :FLYINGMEMORY, :GHOSTMEMORY,
:GRASSMEMORY, :GROUNDMEMORY, :ICEMEMORY, :POISONMEMORY,
:PSYCHICMEMORY, :ROCKMEMORY, :STEELMEMORY, :WATERMEMORY],
40 => [:EVIOLITE, :ICYROCK, :LUCKYPUNCH],
30 => [:ABSORBBULB, :ADRENALINEORB, :AMULETCOIN, :BINDINGBAND, :BLACKBELT,
:BLACKGLASSES, :BLACKSLUDGE, :BOTTLECAP, :CELLBATTERY, :CHARCOAL,
:CLEANSETAG, :DEEPSEASCALE, :DRAGONSCALE, :EJECTBUTTON, :ESCAPEROPE,
:EXPSHARE, :FLAMEORB, :FLOATSTONE, :FLUFFYTAIL, :GOLDBOTTLECAP,
:HEARTSCALE, :HONEY, :KINGSROCK, :LIFEORB, :LIGHTBALL, :LIGHTCLAY,
:LUCKYEGG, :LUMINOUSMOSS, :MAGNET, :METALCOAT, :METRONOME,
:MIRACLESEED, :MYSTICWATER, :NEVERMELTICE, :PASSORB, :POKEDOLL,
:POKETOY, :PRISMSCALE, :PROTECTIVEPADS, :RAZORFANG, :SACREDASH,
:SCOPELENS, :SHELLBELL, :SHOALSALT, :SHOALSHELL, :SMOKEBALL, :SNOWBALL,
:SOULDEW, :SPELLTAG, :TOXICORB, :TWISTEDSPOON, :UPGRADE,
# Healing items
:ANTIDOTE,:AWAKENING,:BERRYJUICE,:BIGMALASADA,:BLUEFLUTE,
:BURNHEAL,:CASTELIACONE,:ELIXIR,:ENERGYPOWDER,:ENERGYROOT,:ETHER,
:FRESHWATER,:FULLHEAL,:FULLRESTORE,:HEALPOWDER,:HYPERPOTION,
:ICEHEAL,:LAVACOOKIE,:LEMONADE,:LUMIOSEGALETTE,:MAXELIXIR,
:MAXETHER,:MAXHONEY,:MAXPOTION,:MAXREVIVE,:MOOMOOMILK,:OLDGATEAU,
:PARALYZEHEAL,:PARLYZHEAL,:PEWTERCRUNCHIES,:POTION,:RAGECANDYBAR,
:REDFLUTE,:REVIVALHERB,:REVIVE,:SHALOURSABLE,:SODAPOP,
:SUPERPOTION,:SWEETHEART,:YELLOWFLUTE,
:ANTIDOTE, :AWAKENING, :BERRYJUICE, :BIGMALASADA, :BLUEFLUTE,
:BURNHEAL, :CASTELIACONE, :ELIXIR, :ENERGYPOWDER, :ENERGYROOT, :ETHER,
:FRESHWATER, :FULLHEAL, :FULLRESTORE, :HEALPOWDER, :HYPERPOTION,
:ICEHEAL, :LAVACOOKIE, :LEMONADE, :LUMIOSEGALETTE, :MAXELIXIR,
:MAXETHER, :MAXHONEY, :MAXPOTION, :MAXREVIVE, :MOOMOOMILK, :OLDGATEAU,
:PARALYZEHEAL, :PARLYZHEAL, :PEWTERCRUNCHIES, :POTION, :RAGECANDYBAR,
:REDFLUTE, :REVIVALHERB, :REVIVE, :SHALOURSABLE, :SODAPOP,
:SUPERPOTION, :SWEETHEART, :YELLOWFLUTE,
# Battle items
:XACCURACY,:XACCURACY2,:XACCURACY3,:XACCURACY6,
:XATTACK,:XATTACK2,:XATTACK3,:XATTACK6,
:XDEFEND,:XDEFEND2,:XDEFEND3,:XDEFEND6,
:XDEFENSE,:XDEFENSE2,:XDEFENSE3,:XDEFENSE6,
:XSPATK,:XSPATK2,:XSPATK3,:XSPATK6,
:XSPECIAL,:XSPECIAL2,:XSPECIAL3,:XSPECIAL6,
:XSPDEF,:XSPDEF2,:XSPDEF3,:XSPDEF6,
:XSPEED,:XSPEED2,:XSPEED3,:XSPEED6,
:DIREHIT,:DIREHIT2,:DIREHIT3,
:ABILITYURGE,:GUARDSPEC,:ITEMDROP,:ITEMURGE,:RESETURGE,
:XACCURACY, :XACCURACY2, :XACCURACY3, :XACCURACY6,
:XATTACK, :XATTACK2, :XATTACK3, :XATTACK6,
:XDEFEND, :XDEFEND2, :XDEFEND3, :XDEFEND6,
:XDEFENSE, :XDEFENSE2, :XDEFENSE3, :XDEFENSE6,
:XSPATK, :XSPATK2, :XSPATK3, :XSPATK6,
:XSPECIAL, :XSPECIAL2, :XSPECIAL3, :XSPECIAL6,
:XSPDEF, :XSPDEF2, :XSPDEF3, :XSPDEF6,
:XSPEED, :XSPEED2, :XSPEED3, :XSPEED6,
:DIREHIT, :DIREHIT2, :DIREHIT3,
:ABILITYURGE, :GUARDSPEC, :ITEMDROP, :ITEMURGE, :RESETURGE,
:MAXMUSHROOMS,
# Vitamins
:CALCIUM,:CARBOS,:HPUP,:IRON,:PPUP,:PPMAX,:PROTEIN,:ZINC,
:CALCIUM, :CARBOS, :HPUP, :IRON, :PPUP, :PPMAX, :PROTEIN, :ZINC,
:RARECANDY,
# Most evolution stones (see also 80)
:EVERSTONE,:FIRESTONE,:ICESTONE,:LEAFSTONE,:MOONSTONE,:SUNSTONE,
:THUNDERSTONE,:WATERSTONE,:SWEETAPPLE,:TARTAPPLE, :GALARICACUFF,
:EVERSTONE, :FIRESTONE, :ICESTONE, :LEAFSTONE, :MOONSTONE, :SUNSTONE,
:THUNDERSTONE, :WATERSTONE, :SWEETAPPLE, :TARTAPPLE, :GALARICACUFF,
:GALARICAWREATH,
# Repels
:MAXREPEL,:REPEL,:SUPERREPEL,
:MAXREPEL, :REPEL, :SUPERREPEL,
# Mulches
:AMAZEMULCH,:BOOSTMULCH,:DAMPMULCH,:GOOEYMULCH,:GROWTHMULCH,
:RICHMULCH,:STABLEMULCH,:SURPRISEMULCH,
:AMAZEMULCH, :BOOSTMULCH, :DAMPMULCH, :GOOEYMULCH, :GROWTHMULCH,
:RICHMULCH, :STABLEMULCH, :SURPRISEMULCH,
# Shards
:BLUESHARD,:GREENSHARD,:REDSHARD,:YELLOWSHARD,
:BLUESHARD, :GREENSHARD, :REDSHARD, :YELLOWSHARD,
# Valuables
:BALMMUSHROOM,:BIGMUSHROOM,:BIGNUGGET,:BIGPEARL,:COMETSHARD,
:NUGGET,:PEARL,:PEARLSTRING,:RELICBAND,:RELICCOPPER,:RELICCROWN,
:RELICGOLD,:RELICSILVER,:RELICSTATUE,:RELICVASE,:STARDUST,
:STARPIECE,:STRANGESOUVENIR,:TINYMUSHROOM,
:BALMMUSHROOM, :BIGMUSHROOM, :BIGNUGGET, :BIGPEARL, :COMETSHARD,
:NUGGET, :PEARL, :PEARLSTRING, :RELICBAND, :RELICCOPPER, :RELICCROWN,
:RELICGOLD, :RELICSILVER, :RELICSTATUE, :RELICVASE, :STARDUST,
:STARPIECE, :STRANGESOUVENIR, :TINYMUSHROOM,
# Exp Candies
:EXPCANDYXS, :EXPCANDYS, :EXPCANDYM, :EXPCANDYL, :EXPCANDYXL],
20 => [ # Feathers
:CLEVERFEATHER,:GENIUSFEATHER,:HEALTHFEATHER,:MUSCLEFEATHER,
:PRETTYFEATHER,:RESISTFEATHER,:SWIFTFEATHER,
:CLEVERWING,:GENIUSWING,:HEALTHWING,:MUSCLEWING,:PRETTYWING,
:RESISTWING,:SWIFTWING],
10 => [:AIRBALLOON,:BIGROOT,:BRIGHTPOWDER,:CHOICEBAND,:CHOICESCARF,
:CHOICESPECS,:DESTINYKNOT,:DISCOUNTCOUPON,:EXPERTBELT,:FOCUSBAND,
:FOCUSSASH,:LAGGINGTAIL,:LEFTOVERS,:MENTALHERB,:METALPOWDER,
:MUSCLEBAND,:POWERHERB,:QUICKPOWDER,:REAPERCLOTH,:REDCARD,
:RINGTARGET,:SHEDSHELL,:SILKSCARF,:SILVERPOWDER,:SMOOTHROCK,
:SOFTSAND,:SOOTHEBELL,:WHITEHERB,:WIDELENS,:WISEGLASSES,:ZOOMLENS,
:CLEVERFEATHER, :GENIUSFEATHER, :HEALTHFEATHER, :MUSCLEFEATHER,
:PRETTYFEATHER, :RESISTFEATHER, :SWIFTFEATHER,
:CLEVERWING, :GENIUSWING, :HEALTHWING, :MUSCLEWING, :PRETTYWING,
:RESISTWING, :SWIFTWING],
10 => [:AIRBALLOON, :BIGROOT, :BRIGHTPOWDER, :CHOICEBAND, :CHOICESCARF,
:CHOICESPECS, :DESTINYKNOT, :DISCOUNTCOUPON, :EXPERTBELT, :FOCUSBAND,
:FOCUSSASH, :LAGGINGTAIL, :LEFTOVERS, :MENTALHERB, :METALPOWDER,
:MUSCLEBAND, :POWERHERB, :QUICKPOWDER, :REAPERCLOTH, :REDCARD,
:RINGTARGET, :SHEDSHELL, :SILKSCARF, :SILVERPOWDER, :SMOOTHROCK,
:SOFTSAND, :SOOTHEBELL, :WHITEHERB, :WIDELENS, :WISEGLASSES, :ZOOMLENS,
# Terrain seeds
:ELECTRICSEED,:GRASSYSEED,:MISTYSEED,:PSYCHICSEED,
:ELECTRICSEED, :GRASSYSEED, :MISTYSEED, :PSYCHICSEED,
# Nectar
:PINKNECTAR,:PURPLENECTAR,:REDNECTAR,:YELLOWNECTAR,
:PINKNECTAR, :PURPLENECTAR, :REDNECTAR, :YELLOWNECTAR,
# Incenses
:FULLINCENSE,:LAXINCENSE,:LUCKINCENSE,:ODDINCENSE,:PUREINCENSE,
:ROCKINCENSE,:ROSEINCENSE,:SEAINCENSE,:WAVEINCENSE,
:FULLINCENSE, :LAXINCENSE, :LUCKINCENSE, :ODDINCENSE, :PUREINCENSE,
:ROCKINCENSE, :ROSEINCENSE, :SEAINCENSE, :WAVEINCENSE,
# Scarves
:BLUESCARF,:GREENSCARF,:PINKSCARF,:REDSCARF,:YELLOWSCARF,
:BLUESCARF, :GREENSCARF, :PINKSCARF, :REDSCARF, :YELLOWSCARF,
# Mints
:LONELYMINT, :ADAMANTMINT, :NAUGHTYMINT, :BRAVEMINT, :BOLDMINT,
:IMPISHMINT, :LAXMINT, :RELAXEDMINT, :MODESTMINT, :MILDMINT,
@@ -527,7 +527,7 @@ class Battle::Move::ThrowUserItemAtTarget < Battle::Move
@willFail = true if !flingableItem
end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if @willFail
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -539,13 +539,13 @@ class Battle::Move::ThrowUserItemAtTarget < Battle::Move
super
pbCheckFlingSuccess(user)
if !@willFail
@battle.pbDisplay(_INTL("{1} flung its {2}!",user.pbThis,user.itemName))
@battle.pbDisplay(_INTL("{1} flung its {2}!", user.pbThis, user.itemName))
end
end
def pbNumHits(user,targets); return 1; end
def pbNumHits(user, targets); return 1; end
def pbBaseDamage(baseDmg,user,target)
def pbBaseDamage(baseDmg, user, target)
return 0 if !user.item
return 10 if user.item.is_berry?
return 80 if user.item.is_mega_stone?
@@ -554,36 +554,36 @@ class Battle::Move::ThrowUserItemAtTarget < Battle::Move
ret = 10 if ret < 10
return ret
end
@flingPowers.each do |power,items|
@flingPowers.each do |power, items|
return power if items.include?(user.item_id)
end
return 10
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if target.damageState.substitute
return if target.hasActiveAbility?(:SHIELDDUST) && !@battle.moldBreaker
case user.item_id
when :POISONBARB
target.pbPoison(user) if target.pbCanPoison?(user,false,self)
target.pbPoison(user) if target.pbCanPoison?(user, false, self)
when :TOXICORB
target.pbPoison(user,nil,true) if target.pbCanPoison?(user,false,self)
target.pbPoison(user, nil, true) if target.pbCanPoison?(user, false, self)
when :FLAMEORB
target.pbBurn(user) if target.pbCanBurn?(user,false,self)
target.pbBurn(user) if target.pbCanBurn?(user, false, self)
when :LIGHTBALL
target.pbParalyze(user) if target.pbCanParalyze?(user,false,self)
target.pbParalyze(user) if target.pbCanParalyze?(user, false, self)
when :KINGSROCK, :RAZORFANG
target.pbFlinch(user)
else
target.pbHeldItemTriggerCheck(user.item,true)
target.pbHeldItemTriggerCheck(user.item, true)
end
end
def pbEndOfMoveUsageEffect(user,targets,numHits,switchedBattlers)
def pbEndOfMoveUsageEffect(user, targets, numHits, switchedBattlers)
# NOTE: The item is consumed even if this move was Protected against or it
# missed. The item is not consumed if the target was switched out by
# an effect like a target's Red Card.
# NOTE: There is no item consumption animation.
user.pbConsumeItem(true,true,false) if user.item
user.pbConsumeItem(true, true, false) if user.item
end
end

View File

@@ -6,11 +6,11 @@ class Battle::Move::RedirectAllMovesToUser < Battle::Move
def pbEffectGeneral(user)
user.effects[PBEffects::FollowMe] = 1
user.allAllies.each do |b|
next if b.effects[PBEffects::FollowMe]<user.effects[PBEffects::FollowMe]
user.effects[PBEffects::FollowMe] = b.effects[PBEffects::FollowMe]+1
next if b.effects[PBEffects::FollowMe] < user.effects[PBEffects::FollowMe]
user.effects[PBEffects::FollowMe] = b.effects[PBEffects::FollowMe] + 1
end
user.effects[PBEffects::RagePowder] = true if powderMove?
@battle.pbDisplay(_INTL("{1} became the center of attention!",user.pbThis))
@battle.pbDisplay(_INTL("{1} became the center of attention!", user.pbThis))
end
end
@@ -21,13 +21,13 @@ end
class Battle::Move::RedirectAllMovesToTarget < Battle::Move
def canMagicCoat?; return true; end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::Spotlight] = 1
target.allAllies.each do |b|
next if b.effects[PBEffects::Spotlight]<target.effects[PBEffects::Spotlight]
target.effects[PBEffects::Spotlight] = b.effects[PBEffects::Spotlight]+1
next if b.effects[PBEffects::Spotlight] < target.effects[PBEffects::Spotlight]
target.effects[PBEffects::Spotlight] = b.effects[PBEffects::Spotlight] + 1
end
@battle.pbDisplay(_INTL("{1} became the center of attention!",target.pbThis))
@battle.pbDisplay(_INTL("{1} became the center of attention!", target.pbThis))
end
end
@@ -44,20 +44,20 @@ end
# but I think that's silly so I've omitted that effect.
#===============================================================================
class Battle::Move::RandomlyDamageOrHealTarget < Battle::Move
def pbOnStartUse(user,targets)
def pbOnStartUse(user, targets)
@presentDmg = 0 # 0 = heal, >0 = damage
r = @battle.pbRandom(100)
if r<40
if r < 40
@presentDmg = 40
elsif r<70
elsif r < 70
@presentDmg = 80
elsif r<80
elsif r < 80
@presentDmg = 120
end
end
def pbFailsAgainstTarget?(user, target, show_message)
return false if @presentDmg>0
return false if @presentDmg > 0
if !target.canHeal?
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
@@ -66,22 +66,22 @@ class Battle::Move::RandomlyDamageOrHealTarget < Battle::Move
end
def pbDamagingMove?
return false if @presentDmg==0
return false if @presentDmg == 0
return super
end
def pbBaseDamage(baseDmg,user,target)
def pbBaseDamage(baseDmg, user, target)
return @presentDmg
end
def pbEffectAgainstTarget(user,target)
return if @presentDmg>0
target.pbRecoverHP(target.totalhp/4)
@battle.pbDisplay(_INTL("{1}'s HP was restored.",target.pbThis))
def pbEffectAgainstTarget(user, target)
return if @presentDmg > 0
target.pbRecoverHP(target.totalhp / 4)
@battle.pbDisplay(_INTL("{1}'s HP was restored.", target.pbThis))
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
hitNum = 1 if @presentDmg==0 # Healing anim
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
hitNum = 1 if @presentDmg == 0 # Healing anim
super
end
end
@@ -92,18 +92,18 @@ end
#===============================================================================
class Battle::Move::HealAllyOrDamageFoe < Battle::Move
def pbTarget(user)
return GameData::Target.get(:NearFoe) if user.effects[PBEffects::HealBlock]>0
return GameData::Target.get(:NearFoe) if user.effects[PBEffects::HealBlock] > 0
return super
end
def pbOnStartUse(user,targets)
def pbOnStartUse(user, targets)
@healing = false
@healing = !user.opposes?(targets[0]) if targets.length>0
@healing = !user.opposes?(targets[0]) if targets.length > 0
end
def pbFailsAgainstTarget?(user, target, show_message)
return false if !@healing
if target.effects[PBEffects::Substitute]>0 && !ignoresSubstitute?(user)
if target.effects[PBEffects::Substitute] > 0 && !ignoresSubstitute?(user)
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
@@ -119,13 +119,13 @@ class Battle::Move::HealAllyOrDamageFoe < Battle::Move
return super
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if !@healing
target.pbRecoverHP(target.totalhp/2)
@battle.pbDisplay(_INTL("{1}'s HP was restored.",target.pbThis))
target.pbRecoverHP(target.totalhp / 2)
@battle.pbDisplay(_INTL("{1}'s HP was restored.", target.pbThis))
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
hitNum = 1 if @healing # Healing anim
super
end
@@ -148,11 +148,11 @@ class Battle::Move::CurseTargetOrLowerUserSpd1RaiseUserAtkDef1 < Battle::Move
return super
end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
return false if user.pbHasType?(:GHOST)
if !user.pbCanLowerStatStage?(:SPEED,user,self) &&
!user.pbCanRaiseStatStage?(:ATTACK,user,self) &&
!user.pbCanRaiseStatStage?(:DEFENSE,user,self)
if !user.pbCanLowerStatStage?(:SPEED, user, self) &&
!user.pbCanRaiseStatStage?(:ATTACK, user, self) &&
!user.pbCanRaiseStatStage?(:DEFENSE, user, self)
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -170,30 +170,30 @@ class Battle::Move::CurseTargetOrLowerUserSpd1RaiseUserAtkDef1 < Battle::Move
def pbEffectGeneral(user)
return if user.pbHasType?(:GHOST)
# Non-Ghost effect
if user.pbCanLowerStatStage?(:SPEED,user,self)
user.pbLowerStatStage(:SPEED,1,user)
if user.pbCanLowerStatStage?(:SPEED, user, self)
user.pbLowerStatStage(:SPEED, 1, user)
end
showAnim = true
if user.pbCanRaiseStatStage?(:ATTACK,user,self)
if user.pbRaiseStatStage(:ATTACK,1,user,showAnim)
if user.pbCanRaiseStatStage?(:ATTACK, user, self)
if user.pbRaiseStatStage(:ATTACK, 1, user, showAnim)
showAnim = false
end
end
if user.pbCanRaiseStatStage?(:DEFENSE,user,self)
user.pbRaiseStatStage(:DEFENSE,1,user,showAnim)
if user.pbCanRaiseStatStage?(:DEFENSE, user, self)
user.pbRaiseStatStage(:DEFENSE, 1, user, showAnim)
end
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if !user.pbHasType?(:GHOST)
# Ghost effect
@battle.pbDisplay(_INTL("{1} cut its own HP and laid a curse on {2}!",user.pbThis,target.pbThis(true)))
@battle.pbDisplay(_INTL("{1} cut its own HP and laid a curse on {2}!", user.pbThis, target.pbThis(true)))
target.effects[PBEffects::Curse] = true
user.pbReduceHP(user.totalhp/2, false, false)
user.pbReduceHP(user.totalhp / 2, false, false)
user.pbItemHPHealCheck
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
hitNum = 1 if !user.pbHasType?(:GHOST) # Non-Ghost anim
super
end
@@ -203,9 +203,9 @@ end
# Effect depends on the environment. (Secret Power)
#===============================================================================
class Battle::Move::EffectDependsOnEnvironment < Battle::Move
def flinchingMove?; return [6,10,12].include?(@secretPower); end
def flinchingMove?; return [6, 10, 12].include?(@secretPower); end
def pbOnStartUse(user,targets)
def pbOnStartUse(user, targets)
# NOTE: This is Gen 7's list plus some of Gen 6 plus a bit of my own.
@secretPower = 0 # Body Slam, paralysis
case @battle.field.terrain
@@ -249,46 +249,46 @@ class Battle::Move::EffectDependsOnEnvironment < Battle::Move
# method is called per hit and this move's additional effect only occurs
# once per use, after all the hits have happened (two hits are possible
# via Parental Bond).
def pbEffectAfterAllHits(user,target)
def pbEffectAfterAllHits(user, target)
return if target.fainted?
return if target.damageState.unaffected || target.damageState.substitute
chance = pbAdditionalEffectChance(user,target)
return if @battle.pbRandom(100)>=chance
chance = pbAdditionalEffectChance(user, target)
return if @battle.pbRandom(100) >= chance
case @secretPower
when 2
target.pbSleep if target.pbCanSleep?(user,false,self)
target.pbSleep if target.pbCanSleep?(user, false, self)
when 10
target.pbBurn(user) if target.pbCanBurn?(user,false,self)
target.pbBurn(user) if target.pbCanBurn?(user, false, self)
when 0, 1
target.pbParalyze(user) if target.pbCanParalyze?(user,false,self)
target.pbParalyze(user) if target.pbCanParalyze?(user, false, self)
when 9
target.pbFreeze if target.pbCanFreeze?(user,false,self)
target.pbFreeze if target.pbCanFreeze?(user, false, self)
when 5
if target.pbCanLowerStatStage?(:ATTACK,user,self)
target.pbLowerStatStage(:ATTACK,1,user)
if target.pbCanLowerStatStage?(:ATTACK, user, self)
target.pbLowerStatStage(:ATTACK, 1, user)
end
when 14
if target.pbCanLowerStatStage?(:DEFENSE,user,self)
target.pbLowerStatStage(:DEFENSE,1,user)
if target.pbCanLowerStatStage?(:DEFENSE, user, self)
target.pbLowerStatStage(:DEFENSE, 1, user)
end
when 3
if target.pbCanLowerStatStage?(:SPECIAL_ATTACK,user,self)
target.pbLowerStatStage(:SPECIAL_ATTACK,1,user)
if target.pbCanLowerStatStage?(:SPECIAL_ATTACK, user, self)
target.pbLowerStatStage(:SPECIAL_ATTACK, 1, user)
end
when 4, 6, 12
if target.pbCanLowerStatStage?(:SPEED,user,self)
target.pbLowerStatStage(:SPEED,1,user)
if target.pbCanLowerStatStage?(:SPEED, user, self)
target.pbLowerStatStage(:SPEED, 1, user)
end
when 8
if target.pbCanLowerStatStage?(:ACCURACY,user,self)
target.pbLowerStatStage(:ACCURACY,1,user)
if target.pbCanLowerStatStage?(:ACCURACY, user, self)
target.pbLowerStatStage(:ACCURACY, 1, user)
end
when 7, 11, 13
target.pbFlinch(user)
end
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
id = :BODYSLAM # Environment-specific anim
case @secretPower
when 1 then id = :THUNDERSHOCK if GameData::Move.exists?(:THUNDERSHOCK)
@@ -347,9 +347,9 @@ class Battle::Move::TargetNextFireMoveDamagesTarget < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::Powder] = true
@battle.pbDisplay(_INTL("{1} is covered in powder!",user.pbThis))
@battle.pbDisplay(_INTL("{1} is covered in powder!", user.pbThis))
end
end
@@ -357,12 +357,12 @@ end
# Power is doubled if Fusion Flare has already been used this round. (Fusion Bolt)
#===============================================================================
class Battle::Move::DoublePowerAfterFusionFlare < Battle::Move
def pbChangeUsageCounters(user,specialUsage)
def pbChangeUsageCounters(user, specialUsage)
@doublePower = @battle.field.effects[PBEffects::FusionFlare]
super
end
def pbBaseDamageMultiplier(damageMult,user,target)
def pbBaseDamageMultiplier(damageMult, user, target)
damageMult *= 2 if @doublePower
return damageMult
end
@@ -371,8 +371,8 @@ class Battle::Move::DoublePowerAfterFusionFlare < Battle::Move
@battle.field.effects[PBEffects::FusionBolt] = true
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
hitNum = 1 if (targets.length>0 && targets[0].damageState.critical) ||
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
hitNum = 1 if (targets.length > 0 && targets[0].damageState.critical) ||
@doublePower # Charged anim
super
end
@@ -382,12 +382,12 @@ end
# Power is doubled if Fusion Bolt has already been used this round. (Fusion Flare)
#===============================================================================
class Battle::Move::DoublePowerAfterFusionBolt < Battle::Move
def pbChangeUsageCounters(user,specialUsage)
def pbChangeUsageCounters(user, specialUsage)
@doublePower = @battle.field.effects[PBEffects::FusionBolt]
super
end
def pbBaseDamageMultiplier(damageMult,user,target)
def pbBaseDamageMultiplier(damageMult, user, target)
damageMult *= 2 if @doublePower
return damageMult
end
@@ -396,8 +396,8 @@ class Battle::Move::DoublePowerAfterFusionBolt < Battle::Move
@battle.field.effects[PBEffects::FusionFlare] = true
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
hitNum = 1 if (targets.length>0 && targets[0].damageState.critical) ||
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
hitNum = 1 if (targets.length > 0 && targets[0].damageState.critical) ||
@doublePower # Charged anim
super
end
@@ -418,9 +418,9 @@ class Battle::Move::PowerUpAllyMove < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::HelpingHand] = true
@battle.pbDisplay(_INTL("{1} is ready to help {2}!",user.pbThis,target.pbThis(true)))
@battle.pbDisplay(_INTL("{1} is ready to help {2}!", user.pbThis, target.pbThis(true)))
end
end
@@ -429,23 +429,23 @@ end
# (Counter)
#===============================================================================
class Battle::Move::CounterPhysicalDamage < Battle::Move::FixedDamageMove
def pbAddTarget(targets,user)
def pbAddTarget(targets, user)
t = user.effects[PBEffects::CounterTarget]
return if t<0 || !user.opposes?(t)
user.pbAddTarget(targets,user,@battle.battlers[t],self,false)
return if t < 0 || !user.opposes?(t)
user.pbAddTarget(targets, user, @battle.battlers[t], self, false)
end
def pbMoveFailed?(user,targets)
if targets.length==0
def pbMoveFailed?(user, targets)
if targets.length == 0
@battle.pbDisplay(_INTL("But there was no target..."))
return true
end
return false
end
def pbFixedDamage(user,target)
dmg = user.effects[PBEffects::Counter]*2
dmg = 1 if dmg==0
def pbFixedDamage(user, target)
dmg = user.effects[PBEffects::Counter] * 2
dmg = 1 if dmg == 0
return dmg
end
end
@@ -455,23 +455,23 @@ end
# (Mirror Coat)
#===============================================================================
class Battle::Move::CounterSpecialDamage < Battle::Move::FixedDamageMove
def pbAddTarget(targets,user)
def pbAddTarget(targets, user)
t = user.effects[PBEffects::MirrorCoatTarget]
return if t<0 || !user.opposes?(t)
user.pbAddTarget(targets,user,@battle.battlers[t],self,false)
return if t < 0 || !user.opposes?(t)
user.pbAddTarget(targets, user, @battle.battlers[t], self, false)
end
def pbMoveFailed?(user,targets)
if targets.length==0
def pbMoveFailed?(user, targets)
if targets.length == 0
@battle.pbDisplay(_INTL("But there was no target..."))
return true
end
return false
end
def pbFixedDamage(user,target)
dmg = user.effects[PBEffects::MirrorCoat]*2
dmg = 1 if dmg==0
def pbFixedDamage(user, target)
dmg = user.effects[PBEffects::MirrorCoat] * 2
dmg = 1 if dmg == 0
return dmg
end
end
@@ -481,24 +481,24 @@ end
# the power. (Metal Burst)
#===============================================================================
class Battle::Move::CounterDamagePlusHalf < Battle::Move::FixedDamageMove
def pbAddTarget(targets,user)
return if user.lastFoeAttacker.length==0
def pbAddTarget(targets, user)
return if user.lastFoeAttacker.length == 0
lastAttacker = user.lastFoeAttacker.last
return if lastAttacker<0 || !user.opposes?(lastAttacker)
user.pbAddTarget(targets,user,@battle.battlers[lastAttacker],self,false)
return if lastAttacker < 0 || !user.opposes?(lastAttacker)
user.pbAddTarget(targets, user, @battle.battlers[lastAttacker], self, false)
end
def pbMoveFailed?(user,targets)
if targets.length==0
def pbMoveFailed?(user, targets)
if targets.length == 0
@battle.pbDisplay(_INTL("But there was no target..."))
return true
end
return false
end
def pbFixedDamage(user,target)
dmg = (user.lastHPLostFromFoe*1.5).floor
dmg = 1 if dmg==0
def pbFixedDamage(user, target)
dmg = (user.lastHPLostFromFoe * 1.5).floor
dmg = 1 if dmg == 0
return dmg
end
end
@@ -510,9 +510,9 @@ end
class Battle::Move::UserAddStockpileRaiseDefSpDef1 < Battle::Move
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
if user.effects[PBEffects::Stockpile]>=3
@battle.pbDisplay(_INTL("{1} can't stockpile any more!",user.pbThis))
def pbMoveFailed?(user, targets)
if user.effects[PBEffects::Stockpile] >= 3
@battle.pbDisplay(_INTL("{1} can't stockpile any more!", user.pbThis))
return true
end
return false
@@ -521,16 +521,16 @@ class Battle::Move::UserAddStockpileRaiseDefSpDef1 < Battle::Move
def pbEffectGeneral(user)
user.effects[PBEffects::Stockpile] += 1
@battle.pbDisplay(_INTL("{1} stockpiled {2}!",
user.pbThis,user.effects[PBEffects::Stockpile]))
user.pbThis, user.effects[PBEffects::Stockpile]))
showAnim = true
if user.pbCanRaiseStatStage?(:DEFENSE,user,self)
if user.pbRaiseStatStage(:DEFENSE,1,user,showAnim)
if user.pbCanRaiseStatStage?(:DEFENSE, user, self)
if user.pbRaiseStatStage(:DEFENSE, 1, user, showAnim)
user.effects[PBEffects::StockpileDef] += 1
showAnim = false
end
end
if user.pbCanRaiseStatStage?(:SPECIAL_DEFENSE,user,self)
if user.pbRaiseStatStage(:SPECIAL_DEFENSE,1,user,showAnim)
if user.pbCanRaiseStatStage?(:SPECIAL_DEFENSE, user, self)
if user.pbRaiseStatStage(:SPECIAL_DEFENSE, 1, user, showAnim)
user.effects[PBEffects::StockpileSpDef] += 1
end
end
@@ -542,33 +542,33 @@ end
# 0. Decreases the user's Defense and Special Defense by X stages each. (Spit Up)
#===============================================================================
class Battle::Move::PowerDependsOnUserStockpile < Battle::Move
def pbMoveFailed?(user,targets)
if user.effects[PBEffects::Stockpile]==0
def pbMoveFailed?(user, targets)
if user.effects[PBEffects::Stockpile] == 0
@battle.pbDisplay(_INTL("But it failed to spit up a thing!"))
return true
end
return false
end
def pbBaseDamage(baseDmg,user,target)
return 100*user.effects[PBEffects::Stockpile]
def pbBaseDamage(baseDmg, user, target)
return 100 * user.effects[PBEffects::Stockpile]
end
def pbEffectAfterAllHits(user,target)
return if user.fainted? || user.effects[PBEffects::Stockpile]==0
def pbEffectAfterAllHits(user, target)
return if user.fainted? || user.effects[PBEffects::Stockpile] == 0
return if target.damageState.unaffected
@battle.pbDisplay(_INTL("{1}'s stockpiled effect wore off!",user.pbThis))
@battle.pbDisplay(_INTL("{1}'s stockpiled effect wore off!", user.pbThis))
return if @battle.pbAllFainted?(target.idxOwnSide)
showAnim = true
if user.effects[PBEffects::StockpileDef]>0 &&
user.pbCanLowerStatStage?(:DEFENSE,user,self)
if user.pbLowerStatStage(:DEFENSE,user.effects[PBEffects::StockpileDef],user,showAnim)
if user.effects[PBEffects::StockpileDef] > 0 &&
user.pbCanLowerStatStage?(:DEFENSE, user, self)
if user.pbLowerStatStage(:DEFENSE, user.effects[PBEffects::StockpileDef], user, showAnim)
showAnim = false
end
end
if user.effects[PBEffects::StockpileSpDef]>0 &&
user.pbCanLowerStatStage?(:SPECIAL_DEFENSE,user,self)
user.pbLowerStatStage(:SPECIAL_DEFENSE,user.effects[PBEffects::StockpileSpDef],user,showAnim)
if user.effects[PBEffects::StockpileSpDef] > 0 &&
user.pbCanLowerStatStage?(:SPECIAL_DEFENSE, user, self)
user.pbLowerStatStage(:SPECIAL_DEFENSE, user.effects[PBEffects::StockpileSpDef], user, showAnim)
end
user.effects[PBEffects::Stockpile] = 0
user.effects[PBEffects::StockpileDef] = 0
@@ -584,14 +584,14 @@ class Battle::Move::HealUserDependingOnUserStockpile < Battle::Move
def healingMove?; return true; end
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
if user.effects[PBEffects::Stockpile]==0
def pbMoveFailed?(user, targets)
if user.effects[PBEffects::Stockpile] == 0
@battle.pbDisplay(_INTL("But it failed to swallow a thing!"))
return true
end
if !user.canHeal? &&
user.effects[PBEffects::StockpileDef]==0 &&
user.effects[PBEffects::StockpileSpDef]==0
user.effects[PBEffects::StockpileDef] == 0 &&
user.effects[PBEffects::StockpileSpDef] == 0
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -600,25 +600,25 @@ class Battle::Move::HealUserDependingOnUserStockpile < Battle::Move
def pbEffectGeneral(user)
hpGain = 0
case [user.effects[PBEffects::Stockpile],1].max
when 1 then hpGain = user.totalhp/4
when 2 then hpGain = user.totalhp/2
case [user.effects[PBEffects::Stockpile], 1].max
when 1 then hpGain = user.totalhp / 4
when 2 then hpGain = user.totalhp / 2
when 3 then hpGain = user.totalhp
end
if user.pbRecoverHP(hpGain)>0
@battle.pbDisplay(_INTL("{1}'s HP was restored.",user.pbThis))
if user.pbRecoverHP(hpGain) > 0
@battle.pbDisplay(_INTL("{1}'s HP was restored.", user.pbThis))
end
@battle.pbDisplay(_INTL("{1}'s stockpiled effect wore off!",user.pbThis))
@battle.pbDisplay(_INTL("{1}'s stockpiled effect wore off!", user.pbThis))
showAnim = true
if user.effects[PBEffects::StockpileDef]>0 &&
user.pbCanLowerStatStage?(:DEFENSE,user,self)
if user.pbLowerStatStage(:DEFENSE,user.effects[PBEffects::StockpileDef],user,showAnim)
if user.effects[PBEffects::StockpileDef] > 0 &&
user.pbCanLowerStatStage?(:DEFENSE, user, self)
if user.pbLowerStatStage(:DEFENSE, user.effects[PBEffects::StockpileDef], user, showAnim)
showAnim = false
end
end
if user.effects[PBEffects::StockpileSpDef]>0 &&
user.pbCanLowerStatStage?(:SPECIAL_DEFENSE,user,self)
user.pbLowerStatStage(:SPECIAL_DEFENSE,user.effects[PBEffects::StockpileSpDef],user,showAnim)
if user.effects[PBEffects::StockpileSpDef] > 0 &&
user.pbCanLowerStatStage?(:SPECIAL_DEFENSE, user, self)
user.pbLowerStatStage(:SPECIAL_DEFENSE, user.effects[PBEffects::StockpileSpDef], user, showAnim)
end
user.effects[PBEffects::Stockpile] = 0
user.effects[PBEffects::StockpileDef] = 0
@@ -632,7 +632,7 @@ end
# swamp on the opposing side.
#===============================================================================
class Battle::Move::GrassPledge < Battle::Move::PledgeMove
def initialize(battle,move)
def initialize(battle, move)
super
# [Function code to combo with, effect, override type, override animation]
@combos = [["FirePledge", :SeaOfFire, :FIRE, :FIREPLEDGE],
@@ -646,7 +646,7 @@ end
# user's side or a sea of fire on the opposing side.
#===============================================================================
class Battle::Move::FirePledge < Battle::Move::PledgeMove
def initialize(battle,move)
def initialize(battle, move)
super
# [Function code to combo with, effect, override type, override animation]
@combos = [["WaterPledge", :Rainbow, :WATER, :WATERPLEDGE],
@@ -660,7 +660,7 @@ end
# opposing side or a rainbow on the user's side.
#===============================================================================
class Battle::Move::WaterPledge < Battle::Move::PledgeMove
def initialize(battle,move)
def initialize(battle, move)
super
# [Function code to combo with, effect, override type, override animation]
@combos = [["GrassPledge", :Swamp, :GRASS, :GRASSPLEDGE],
@@ -674,7 +674,7 @@ end
class Battle::Move::UseLastMoveUsed < Battle::Move
def callsAnotherMove?; return true; end
def initialize(battle,move)
def initialize(battle, move)
super
@moveBlacklist = [
# Struggle, Belch
@@ -738,12 +738,12 @@ class Battle::Move::UseLastMoveUsed < Battle::Move
end
end
def pbChangeUsageCounters(user,specialUsage)
def pbChangeUsageCounters(user, specialUsage)
super
@copied_move = @battle.lastMoveUsed
end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !@copied_move ||
@moveBlacklist.include?(GameData::Move.get(@copied_move).function_code)
@battle.pbDisplay(_INTL("But it failed!"))
@@ -773,11 +773,11 @@ class Battle::Move::UseLastMoveUsedByTarget < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
user.pbUseMoveSimple(target.lastRegularMoveUsed,target.index)
def pbEffectAgainstTarget(user, target)
user.pbUseMoveSimple(target.lastRegularMoveUsed, target.index)
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
# No animation
end
end
@@ -790,7 +790,7 @@ class Battle::Move::UseMoveTargetIsAboutToUse < Battle::Move
def ignoresSubstitute?(user); return true; end
def callsAnotherMove?; return true; end
def initialize(battle,move)
def initialize(battle, move)
super
@moveBlacklist = [
"UserTakesTargetItem", # Covet, Thief
@@ -818,7 +818,7 @@ class Battle::Move::UseMoveTargetIsAboutToUse < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
user.effects[PBEffects::MeFirst] = true
user.pbUseMoveSimple(@battle.choices[target.index][2].id)
user.effects[PBEffects::MeFirst] = false
@@ -834,7 +834,7 @@ end
class Battle::Move::UseMoveDependingOnEnvironment < Battle::Move
def callsAnotherMove?; return true; end
def pbOnStartUse(user,targets)
def pbOnStartUse(user, targets)
# NOTE: It's possible in theory to not have the move Nature Power wants to
# turn into, but what self-respecting game wouldn't at least have Tri
# Attack in it?
@@ -882,7 +882,7 @@ class Battle::Move::UseMoveDependingOnEnvironment < Battle::Move
end
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
@battle.pbDisplay(_INTL("{1} turned into {2}!", @name, GameData::Move.get(@npMove).name))
user.pbUseMoveSimple(@npMove, target.index)
end
@@ -894,7 +894,7 @@ end
class Battle::Move::UseRandomMove < Battle::Move
def callsAnotherMove?; return true; end
def initialize(battle,move)
def initialize(battle, move)
super
@moveBlacklist = [
"FlinchTargetFailsIfUserNotAsleep", # Snore
@@ -977,7 +977,7 @@ class Battle::Move::UseRandomMove < Battle::Move
]
end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
@metronomeMove = nil
move_keys = GameData::Move.keys
# NOTE: You could be really unlucky and roll blacklisted moves 1000 times in
@@ -1009,7 +1009,7 @@ end
class Battle::Move::UseRandomMoveFromUserParty < Battle::Move
def callsAnotherMove?; return true; end
def initialize(battle,move)
def initialize(battle, move)
super
@moveBlacklist = [
# Struggle, Belch
@@ -1092,11 +1092,11 @@ class Battle::Move::UseRandomMoveFromUserParty < Battle::Move
end
end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
@assistMoves = []
# NOTE: This includes the Pokémon of ally trainers in multi battles.
@battle.pbParty(user.index).each_with_index do |pkmn,i|
next if !pkmn || i==user.pokemonIndex
@battle.pbParty(user.index).each_with_index do |pkmn, i|
next if !pkmn || i == user.pokemonIndex
next if Settings::MECHANICS_GENERATION >= 6 && pkmn.egg?
pkmn.moves.each do |move|
next if @moveBlacklist.include?(move.function_code)
@@ -1104,7 +1104,7 @@ class Battle::Move::UseRandomMoveFromUserParty < Battle::Move
@assistMoves.push(move.id)
end
end
if @assistMoves.length==0
if @assistMoves.length == 0
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -1124,7 +1124,7 @@ class Battle::Move::UseRandomUserMoveIfAsleep < Battle::Move
def usableWhenAsleep?; return true; end
def callsAnotherMove?; return true; end
def initialize(battle,move)
def initialize(battle, move)
super
@moveBlacklist = [
"MultiTurnAttackPreventSleeping", # Uproar
@@ -1165,14 +1165,14 @@ class Battle::Move::UseRandomUserMoveIfAsleep < Battle::Move
]
end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
@sleepTalkMoves = []
user.eachMoveWithIndex do |m,i|
user.eachMoveWithIndex do |m, i|
next if @moveBlacklist.include?(m.function)
next if !@battle.pbCanChooseMove?(user.index,i,false,true)
next if !@battle.pbCanChooseMove?(user.index, i, false, true)
@sleepTalkMoves.push(i)
end
if !user.asleep? || @sleepTalkMoves.length==0
if !user.asleep? || @sleepTalkMoves.length == 0
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -1181,7 +1181,7 @@ class Battle::Move::UseRandomUserMoveIfAsleep < Battle::Move
def pbEffectGeneral(user)
choice = @sleepTalkMoves[@battle.pbRandom(@sleepTalkMoves.length)]
user.pbUseMoveSimple(user.moves[choice].id,user.pbDirectOpposing.index)
user.pbUseMoveSimple(user.moves[choice].id, user.pbDirectOpposing.index)
end
end
@@ -1192,7 +1192,7 @@ end
class Battle::Move::BounceBackProblemCausingStatusMoves < Battle::Move
def pbEffectGeneral(user)
user.effects[PBEffects::MagicCoat] = true
@battle.pbDisplay(_INTL("{1} shrouded itself with Magic Coat!",user.pbThis))
@battle.pbDisplay(_INTL("{1} shrouded itself with Magic Coat!", user.pbThis))
end
end
@@ -1203,10 +1203,10 @@ class Battle::Move::StealAndUseBeneficialStatusMove < Battle::Move
def pbEffectGeneral(user)
user.effects[PBEffects::Snatch] = 1
@battle.allBattlers.each do |b|
next if b.effects[PBEffects::Snatch]<user.effects[PBEffects::Snatch]
user.effects[PBEffects::Snatch] = b.effects[PBEffects::Snatch]+1
next if b.effects[PBEffects::Snatch] < user.effects[PBEffects::Snatch]
user.effects[PBEffects::Snatch] = b.effects[PBEffects::Snatch] + 1
end
@battle.pbDisplay(_INTL("{1} waits for a target to make a move!",user.pbThis))
@battle.pbDisplay(_INTL("{1} waits for a target to make a move!", user.pbThis))
end
end
@@ -1217,7 +1217,7 @@ end
class Battle::Move::ReplaceMoveThisBattleWithTargetLastMoveUsed < Battle::Move
def ignoresSubstitute?(user); return true; end
def initialize(battle,move)
def initialize(battle, move)
super
@moveBlacklist = [
"UseRandomMove", # Metronome
@@ -1230,7 +1230,7 @@ class Battle::Move::ReplaceMoveThisBattleWithTargetLastMoveUsed < Battle::Move
]
end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.effects[PBEffects::Transform] || !user.pbHasMove?(@id)
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -1250,12 +1250,12 @@ class Battle::Move::ReplaceMoveThisBattleWithTargetLastMoveUsed < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
user.eachMoveWithIndex do |m,i|
next if m.id!=@id
def pbEffectAgainstTarget(user, target)
user.eachMoveWithIndex do |m, i|
next if m.id != @id
newMove = Pokemon::Move.new(target.lastRegularMoveUsed)
user.moves[i] = Battle::Move.from_pokemon_move(@battle,newMove)
@battle.pbDisplay(_INTL("{1} learned {2}!",user.pbThis,newMove.name))
user.moves[i] = Battle::Move.from_pokemon_move(@battle, newMove)
@battle.pbDisplay(_INTL("{1} learned {2}!", user.pbThis, newMove.name))
user.pbCheckFormOnMovesetChange
break
end
@@ -1268,7 +1268,7 @@ end
class Battle::Move::ReplaceMoveWithTargetLastMoveUsed < Battle::Move
def ignoresSubstitute?(user); return true; end
def initialize(battle,move)
def initialize(battle, move)
super
@moveBlacklist = [
"ReplaceMoveWithTargetLastMoveUsed", # Sketch (this move)
@@ -1277,7 +1277,7 @@ class Battle::Move::ReplaceMoveWithTargetLastMoveUsed < Battle::Move
]
end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.effects[PBEffects::Transform] || !user.pbHasMove?(@id)
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -1297,13 +1297,13 @@ class Battle::Move::ReplaceMoveWithTargetLastMoveUsed < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
user.eachMoveWithIndex do |m,i|
next if m.id!=@id
def pbEffectAgainstTarget(user, target)
user.eachMoveWithIndex do |m, i|
next if m.id != @id
newMove = Pokemon::Move.new(target.lastRegularMoveUsed)
user.pokemon.moves[i] = newMove
user.moves[i] = Battle::Move.from_pokemon_move(@battle,newMove)
@battle.pbDisplay(_INTL("{1} learned {2}!",user.pbThis,newMove.name))
user.moves[i] = Battle::Move.from_pokemon_move(@battle, newMove)
@battle.pbDisplay(_INTL("{1} learned {2}!", user.pbThis, newMove.name))
user.pbCheckFormOnMovesetChange
break
end

View File

@@ -2,7 +2,7 @@
# User flees from battle. (Teleport (Gen 7-))
#===============================================================================
class Battle::Move::FleeFromBattle < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !@battle.pbCanRun?(user.index)
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -11,7 +11,7 @@ class Battle::Move::FleeFromBattle < Battle::Move
end
def pbEffectGeneral(user)
@battle.pbDisplay(_INTL("{1} fled from battle!",user.pbThis))
@battle.pbDisplay(_INTL("{1} fled from battle!", user.pbThis))
@battle.decision = 3 # Escaped
end
end
@@ -21,7 +21,7 @@ end
# (Teleport (Gen 8+))
#===============================================================================
class Battle::Move::SwitchOutUserStatusMove < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.wild?
if !@battle.pbCanRun?(user.index)
@battle.pbDisplay(_INTL("But it failed!"))
@@ -34,15 +34,15 @@ class Battle::Move::SwitchOutUserStatusMove < Battle::Move
return false
end
def pbEndOfMoveUsageEffect(user,targets,numHits,switchedBattlers)
def pbEndOfMoveUsageEffect(user, targets, numHits, switchedBattlers)
return if user.wild?
@battle.pbDisplay(_INTL("{1} went back to {2}!",user.pbThis,
@battle.pbDisplay(_INTL("{1} went back to {2}!", user.pbThis,
@battle.pbGetOwnerName(user.index)))
@battle.pbPursuit(user.index)
return if user.fainted?
newPkmn = @battle.pbGetReplacementPokemonIndex(user.index) # Owner chooses
return if newPkmn<0
@battle.pbRecallAndReplace(user.index,newPkmn)
return if newPkmn < 0
@battle.pbRecallAndReplace(user.index, newPkmn)
@battle.pbClearChoice(user.index) # Replacement Pokémon does nothing this round
@battle.moldBreaker = false
@battle.pbOnBattlerEnteringBattle(user.index)
@@ -51,7 +51,7 @@ class Battle::Move::SwitchOutUserStatusMove < Battle::Move
def pbEffectGeneral(user)
if user.wild?
@battle.pbDisplay(_INTL("{1} fled from battle!",user.pbThis))
@battle.pbDisplay(_INTL("{1} fled from battle!", user.pbThis))
@battle.decision = 3 # Escaped
end
end
@@ -62,21 +62,21 @@ end
# (U-turn, Volt Switch)
#===============================================================================
class Battle::Move::SwitchOutUserDamagingMove < Battle::Move
def pbEndOfMoveUsageEffect(user,targets,numHits,switchedBattlers)
return if user.fainted? || numHits==0 || @battle.pbAllFainted?(user.idxOpposingSide)
def pbEndOfMoveUsageEffect(user, targets, numHits, switchedBattlers)
return if user.fainted? || numHits == 0 || @battle.pbAllFainted?(user.idxOpposingSide)
targetSwitched = true
targets.each do |b|
targetSwitched = false if !switchedBattlers.include?(b.index)
end
return if targetSwitched
return if !@battle.pbCanChooseNonActive?(user.index)
@battle.pbDisplay(_INTL("{1} went back to {2}!",user.pbThis,
@battle.pbDisplay(_INTL("{1} went back to {2}!", user.pbThis,
@battle.pbGetOwnerName(user.index)))
@battle.pbPursuit(user.index)
return if user.fainted?
newPkmn = @battle.pbGetReplacementPokemonIndex(user.index) # Owner chooses
return if newPkmn<0
@battle.pbRecallAndReplace(user.index,newPkmn)
return if newPkmn < 0
@battle.pbRecallAndReplace(user.index, newPkmn)
@battle.pbClearChoice(user.index) # Replacement Pokémon does nothing this round
@battle.moldBreaker = false
@battle.pbOnBattlerEnteringBattle(user.index)
@@ -89,28 +89,28 @@ end
# switches out. Ignores trapping moves. (Parting Shot)
#===============================================================================
class Battle::Move::LowerTargetAtkSpAtk1SwitchOutUser < Battle::Move::TargetMultiStatDownMove
def initialize(battle,move)
def initialize(battle, move)
super
@statDown = [:ATTACK,1,:SPECIAL_ATTACK,1]
@statDown = [:ATTACK, 1, :SPECIAL_ATTACK, 1]
end
def pbEndOfMoveUsageEffect(user,targets,numHits,switchedBattlers)
def pbEndOfMoveUsageEffect(user, targets, numHits, switchedBattlers)
switcher = user
targets.each do |b|
next if switchedBattlers.include?(b.index)
switcher = b if b.effects[PBEffects::MagicCoat] || b.effects[PBEffects::MagicBounce]
end
return if switcher.fainted? || numHits==0
return if switcher.fainted? || numHits == 0
return if !@battle.pbCanChooseNonActive?(switcher.index)
@battle.pbDisplay(_INTL("{1} went back to {2}!",switcher.pbThis,
@battle.pbDisplay(_INTL("{1} went back to {2}!", switcher.pbThis,
@battle.pbGetOwnerName(switcher.index)))
@battle.pbPursuit(switcher.index)
return if switcher.fainted?
newPkmn = @battle.pbGetReplacementPokemonIndex(switcher.index) # Owner chooses
return if newPkmn<0
@battle.pbRecallAndReplace(switcher.index,newPkmn)
return if newPkmn < 0
@battle.pbRecallAndReplace(switcher.index, newPkmn)
@battle.pbClearChoice(switcher.index) # Replacement Pokémon does nothing this round
@battle.moldBreaker = false if switcher.index==user.index
@battle.moldBreaker = false if switcher.index == user.index
@battle.pbOnBattlerEnteringBattle(switcher.index)
switchedBattlers.push(switcher.index)
end
@@ -121,7 +121,7 @@ end
# replacement. (Baton Pass)
#===============================================================================
class Battle::Move::SwitchOutUserPassOnEffects < Battle::Move
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !@battle.pbCanChooseNonActive?(user.index)
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -129,13 +129,13 @@ class Battle::Move::SwitchOutUserPassOnEffects < Battle::Move
return false
end
def pbEndOfMoveUsageEffect(user,targets,numHits,switchedBattlers)
return if user.fainted? || numHits==0
def pbEndOfMoveUsageEffect(user, targets, numHits, switchedBattlers)
return if user.fainted? || numHits == 0
return if !@battle.pbCanChooseNonActive?(user.index)
@battle.pbPursuit(user.index)
return if user.fainted?
newPkmn = @battle.pbGetReplacementPokemonIndex(user.index) # Owner chooses
return if newPkmn<0
return if newPkmn < 0
@battle.pbRecallAndReplace(user.index, newPkmn, false, true)
@battle.pbClearChoice(user.index) # Replacement Pokémon does nothing this round
@battle.moldBreaker = false
@@ -175,14 +175,14 @@ class Battle::Move::SwitchOutTargetStatusMove < Battle::Move
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
if @battle.wildBattle? && target.level>user.level
if @battle.wildBattle? && target.level > user.level
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
if @battle.trainerBattle?
canSwitch = false
@battle.eachInTeamFromBattlerIndex(target.index) do |_pkmn,i|
next if !@battle.pbCanSwitchLax?(target.index,i)
@battle.eachInTeamFromBattlerIndex(target.index) do |_pkmn, i|
next if !@battle.pbCanSwitchLax?(target.index, i)
canSwitch = true
break
end
@@ -205,10 +205,10 @@ class Battle::Move::SwitchOutTargetStatusMove < Battle::Move
next if b.fainted? || b.damageState.unaffected
next if b.effects[PBEffects::Ingrain]
next if b.hasActiveAbility?(:SUCTIONCUPS) && !@battle.moldBreaker
newPkmn = @battle.pbGetReplacementPokemonIndex(b.index,true) # Random
next if newPkmn<0
newPkmn = @battle.pbGetReplacementPokemonIndex(b.index, true) # Random
next if newPkmn < 0
@battle.pbRecallAndReplace(b.index, newPkmn, true)
@battle.pbDisplay(_INTL("{1} was dragged out!",b.pbThis))
@battle.pbDisplay(_INTL("{1} was dragged out!", b.pbThis))
@battle.pbClearChoice(b.index) # Replacement Pokémon does nothing this round
@battle.pbOnBattlerEnteringBattle(b.index)
switched_battlers.push(b.index)
@@ -224,9 +224,9 @@ end
# For damaging moves. (Circle Throw, Dragon Tail)
#===============================================================================
class Battle::Move::SwitchOutTargetDamagingMove < Battle::Move
def pbEffectAgainstTarget(user,target)
if @battle.wildBattle? && target.level<=user.level && @battle.canRun &&
(target.effects[PBEffects::Substitute]==0 || ignoresSubstitute?(user))
def pbEffectAgainstTarget(user, target)
if @battle.wildBattle? && target.level <= user.level && @battle.canRun &&
(target.effects[PBEffects::Substitute] == 0 || ignoresSubstitute?(user))
@battle.decision = 3
end
end
@@ -238,10 +238,10 @@ class Battle::Move::SwitchOutTargetDamagingMove < Battle::Move
next if b.fainted? || b.damageState.unaffected || b.damageState.substitute
next if b.effects[PBEffects::Ingrain]
next if b.hasActiveAbility?(:SUCTIONCUPS) && !@battle.moldBreaker
newPkmn = @battle.pbGetReplacementPokemonIndex(b.index,true) # Random
next if newPkmn<0
newPkmn = @battle.pbGetReplacementPokemonIndex(b.index, true) # Random
next if newPkmn < 0
@battle.pbRecallAndReplace(b.index, newPkmn, true)
@battle.pbDisplay(_INTL("{1} was dragged out!",b.pbThis))
@battle.pbDisplay(_INTL("{1} was dragged out!", b.pbThis))
@battle.pbClearChoice(b.index) # Replacement Pokémon does nothing this round
@battle.pbOnBattlerEnteringBattle(b.index)
switched_battlers.push(b.index)
@@ -255,36 +255,36 @@ end
# at end of each round.
#===============================================================================
class Battle::Move::BindTarget < Battle::Move
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if target.fainted? || target.damageState.substitute
return if target.effects[PBEffects::Trapping]>0
return if target.effects[PBEffects::Trapping] > 0
# Set trapping effect duration and info
if user.hasActiveItem?(:GRIPCLAW)
target.effects[PBEffects::Trapping] = (Settings::MECHANICS_GENERATION >= 5) ? 8 : 6
else
target.effects[PBEffects::Trapping] = 5+@battle.pbRandom(2)
target.effects[PBEffects::Trapping] = 5 + @battle.pbRandom(2)
end
target.effects[PBEffects::TrappingMove] = @id
target.effects[PBEffects::TrappingUser] = user.index
# Message
msg = _INTL("{1} was trapped in the vortex!",target.pbThis)
msg = _INTL("{1} was trapped in the vortex!", target.pbThis)
case @id
when :BIND
msg = _INTL("{1} was squeezed by {2}!",target.pbThis,user.pbThis(true))
msg = _INTL("{1} was squeezed by {2}!", target.pbThis, user.pbThis(true))
when :CLAMP
msg = _INTL("{1} clamped {2}!",user.pbThis,target.pbThis(true))
msg = _INTL("{1} clamped {2}!", user.pbThis, target.pbThis(true))
when :FIRESPIN
msg = _INTL("{1} was trapped in the fiery vortex!",target.pbThis)
msg = _INTL("{1} was trapped in the fiery vortex!", target.pbThis)
when :INFESTATION
msg = _INTL("{1} has been afflicted with an infestation by {2}!",target.pbThis,user.pbThis(true))
msg = _INTL("{1} has been afflicted with an infestation by {2}!", target.pbThis, user.pbThis(true))
when :MAGMASTORM
msg = _INTL("{1} became trapped by Magma Storm!",target.pbThis)
msg = _INTL("{1} became trapped by Magma Storm!", target.pbThis)
when :SANDTOMB
msg = _INTL("{1} became trapped by Sand Tomb!",target.pbThis)
msg = _INTL("{1} became trapped by Sand Tomb!", target.pbThis)
when :WHIRLPOOL
msg = _INTL("{1} became trapped in the vortex!",target.pbThis)
msg = _INTL("{1} became trapped in the vortex!", target.pbThis)
when :WRAP
msg = _INTL("{1} was wrapped by {2}!",target.pbThis,user.pbThis(true))
msg = _INTL("{1} was wrapped by {2}!", target.pbThis, user.pbThis(true))
end
@battle.pbDisplay(msg)
end
@@ -298,7 +298,7 @@ end
class Battle::Move::BindTargetDoublePowerIfTargetUnderwater < Battle::Move::BindTarget
def hitsDivingTargets?; return true; end
def pbModifyDamage(damageMult,user,target)
def pbModifyDamage(damageMult, user, target)
damageMult *= 2 if target.inTwoTurnAttack?("TwoTurnAttackInvulnerableUnderwater")
return damageMult
end
@@ -313,7 +313,7 @@ class Battle::Move::TrapTargetInBattle < Battle::Move
def pbFailsAgainstTarget?(user, target, show_message)
return false if damagingMove?
if target.effects[PBEffects::MeanLook]>=0
if target.effects[PBEffects::MeanLook] >= 0
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
@@ -324,18 +324,18 @@ class Battle::Move::TrapTargetInBattle < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
return if damagingMove?
target.effects[PBEffects::MeanLook] = user.index
@battle.pbDisplay(_INTL("{1} can no longer escape!",target.pbThis))
@battle.pbDisplay(_INTL("{1} can no longer escape!", target.pbThis))
end
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.fainted? || target.damageState.substitute
return if target.effects[PBEffects::MeanLook]>=0
return if target.effects[PBEffects::MeanLook] >= 0
return if Settings::MORE_TYPE_EFFECTS && target.pbHasType?(:GHOST)
target.effects[PBEffects::MeanLook] = user.index
@battle.pbDisplay(_INTL("{1} can no longer escape!",target.pbThis))
@battle.pbDisplay(_INTL("{1} can no longer escape!", target.pbThis))
end
end
@@ -383,8 +383,8 @@ end
# No Pokémon can switch out or flee until the end of the next round. (Fairy Lock)
#===============================================================================
class Battle::Move::TrapAllBattlersInBattleForOneTurn < Battle::Move
def pbMoveFailed?(user,targets)
if @battle.field.effects[PBEffects::FairyLock]>0
def pbMoveFailed?(user, targets)
if @battle.field.effects[PBEffects::FairyLock] > 0
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
@@ -403,12 +403,12 @@ end
# (Handled in Battle's pbAttackPhase): Makes this attack happen before switching.
#===============================================================================
class Battle::Move::PursueSwitchingFoe < Battle::Move
def pbAccuracyCheck(user,target)
def pbAccuracyCheck(user, target)
return true if @battle.switching
return super
end
def pbBaseDamage(baseDmg,user,target)
def pbBaseDamage(baseDmg, user, target)
baseDmg *= 2 if @battle.switching
return baseDmg
end
@@ -421,21 +421,21 @@ end
class Battle::Move::UsedAfterUserTakesPhysicalDamage < Battle::Move
def pbDisplayChargeMessage(user)
user.effects[PBEffects::ShellTrap] = true
@battle.pbCommonAnimation("ShellTrap",user)
@battle.pbDisplay(_INTL("{1} set a shell trap!",user.pbThis))
@battle.pbCommonAnimation("ShellTrap", user)
@battle.pbDisplay(_INTL("{1} set a shell trap!", user.pbThis))
end
def pbDisplayUseMessage(user)
super if user.tookPhysicalHit
end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !user.effects[PBEffects::ShellTrap]
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
if !user.tookPhysicalHit
@battle.pbDisplay(_INTL("{1}'s shell trap didn't work!",user.pbThis))
@battle.pbDisplay(_INTL("{1}'s shell trap didn't work!", user.pbThis))
return true
end
return false
@@ -447,7 +447,7 @@ end
# If an ally is about to use the same move, make it go next, ignoring priority.
#===============================================================================
class Battle::Move::UsedAfterAllyRoundWithDoublePower < Battle::Move
def pbBaseDamage(baseDmg,user,target)
def pbBaseDamage(baseDmg, user, target)
baseDmg *= 2 if user.pbOwnSide.effects[PBEffects::Round]
return baseDmg
end
@@ -455,8 +455,8 @@ class Battle::Move::UsedAfterAllyRoundWithDoublePower < Battle::Move
def pbEffectGeneral(user)
user.pbOwnSide.effects[PBEffects::Round] = true
user.allAllies.each do |b|
next if @battle.choices[b.index][0]!=:UseMove || b.movedThisRound?
next if @battle.choices[b.index][2].function!=@function
next if @battle.choices[b.index][0] != :UseMove || b.movedThisRound?
next if @battle.choices[b.index][2].function != @function
b.effects[PBEffects::MoveNext] = true
b.effects[PBEffects::Quash] = 0
break
@@ -487,10 +487,10 @@ class Battle::Move::TargetActsNext < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::MoveNext] = true
target.effects[PBEffects::Quash] = 0
@battle.pbDisplay(_INTL("{1} took the kind offer!",target.pbThis))
@battle.pbDisplay(_INTL("{1} took the kind offer!", target.pbThis))
end
end
@@ -509,30 +509,30 @@ class Battle::Move::TargetActsLast < Battle::Move
# Target is already maximally Quashed and will move last anyway
highestQuash = 0
@battle.allBattlers.each do |b|
next if b.effects[PBEffects::Quash]<=highestQuash
next if b.effects[PBEffects::Quash] <= highestQuash
highestQuash = b.effects[PBEffects::Quash]
end
if highestQuash>0 && target.effects[PBEffects::Quash]==highestQuash
if highestQuash > 0 && target.effects[PBEffects::Quash] == highestQuash
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
# Target was already going to move last
if highestQuash==0 && @battle.pbPriority.last.index==target.index
if highestQuash == 0 && @battle.pbPriority.last.index == target.index
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
highestQuash = 0
@battle.allBattlers.each do |b|
next if b.effects[PBEffects::Quash]<=highestQuash
next if b.effects[PBEffects::Quash] <= highestQuash
highestQuash = b.effects[PBEffects::Quash]
end
target.effects[PBEffects::Quash] = highestQuash+1
target.effects[PBEffects::Quash] = highestQuash + 1
target.effects[PBEffects::MoveNext] = false
@battle.pbDisplay(_INTL("{1}'s move was postponed!",target.pbThis))
@battle.pbDisplay(_INTL("{1}'s move was postponed!", target.pbThis))
end
end
@@ -542,7 +542,7 @@ end
class Battle::Move::TargetUsesItsLastUsedMoveAgain < Battle::Move
def ignoresSubstitute?(user); return true; end
def initialize(battle,move)
def initialize(battle, move)
super
@moveBlacklist = [
"MultiTurnAttackBideThenReturnDoubleDamage", # Bide
@@ -596,9 +596,9 @@ class Battle::Move::TargetUsesItsLastUsedMoveAgain < Battle::Move
return true
end
targetMove = @battle.choices[target.index][2]
if targetMove && (targetMove.function=="FailsIfUserDamagedThisTurn" || # Focus Punch
targetMove.function=="UsedAfterUserTakesPhysicalDamage" || # Shell Trap
targetMove.function=="BurnAttackerBeforeUserActs") # Beak Blast
if targetMove && (targetMove.function == "FailsIfUserDamagedThisTurn" || # Focus Punch
targetMove.function == "UsedAfterUserTakesPhysicalDamage" || # Shell Trap
targetMove.function == "BurnAttackerBeforeUserActs") # Beak Blast
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
@@ -607,17 +607,17 @@ class Battle::Move::TargetUsesItsLastUsedMoveAgain < Battle::Move
return true
end
idxMove = -1
target.eachMoveWithIndex do |m,i|
idxMove = i if m.id==target.lastRegularMoveUsed
target.eachMoveWithIndex do |m, i|
idxMove = i if m.id == target.lastRegularMoveUsed
end
if target.moves[idxMove].pp==0 && target.moves[idxMove].total_pp>0
if target.moves[idxMove].pp == 0 && target.moves[idxMove].total_pp > 0
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::Instruct] = true
end
end
@@ -628,17 +628,17 @@ end
#===============================================================================
class Battle::Move::StartSlowerBattlersActFirst < Battle::Move
def pbEffectGeneral(user)
if @battle.field.effects[PBEffects::TrickRoom]>0
if @battle.field.effects[PBEffects::TrickRoom] > 0
@battle.field.effects[PBEffects::TrickRoom] = 0
@battle.pbDisplay(_INTL("{1} reverted the dimensions!",user.pbThis))
@battle.pbDisplay(_INTL("{1} reverted the dimensions!", user.pbThis))
else
@battle.field.effects[PBEffects::TrickRoom] = 5
@battle.pbDisplay(_INTL("{1} twisted the dimensions!",user.pbThis))
@battle.pbDisplay(_INTL("{1} twisted the dimensions!", user.pbThis))
end
end
def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true)
return if @battle.field.effects[PBEffects::TrickRoom]>0 # No animation
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
return if @battle.field.effects[PBEffects::TrickRoom] > 0 # No animation
super
end
end
@@ -710,15 +710,15 @@ class Battle::Move::DisableTargetLastMoveUsed < Battle::Move
def canMagicCoat?; return true; end
def pbFailsAgainstTarget?(user, target, show_message)
if target.effects[PBEffects::Disable]>0 || !target.lastRegularMoveUsed
if target.effects[PBEffects::Disable] > 0 || !target.lastRegularMoveUsed
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
return true if pbMoveFailedAromaVeil?(user, target, show_message)
canDisable = false
target.eachMove do |m|
next if m.id!=target.lastRegularMoveUsed
next if m.pp==0 && m.total_pp>0
next if m.id != target.lastRegularMoveUsed
next if m.pp == 0 && m.total_pp > 0
canDisable = true
break
end
@@ -729,10 +729,10 @@ class Battle::Move::DisableTargetLastMoveUsed < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::Disable] = 5
target.effects[PBEffects::DisableMove] = target.lastRegularMoveUsed
@battle.pbDisplay(_INTL("{1}'s {2} was disabled!",target.pbThis,
@battle.pbDisplay(_INTL("{1}'s {2} was disabled!", target.pbThis,
GameData::Move.get(target.lastRegularMoveUsed).name))
target.pbItemStatusCureCheck
end
@@ -754,9 +754,9 @@ class Battle::Move::DisableTargetUsingSameMoveConsecutively < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::Torment] = true
@battle.pbDisplay(_INTL("{1} was subjected to torment!",target.pbThis))
@battle.pbDisplay(_INTL("{1} was subjected to torment!", target.pbThis))
target.pbItemStatusCureCheck
end
end
@@ -768,7 +768,7 @@ class Battle::Move::DisableTargetUsingDifferentMove < Battle::Move
def ignoresSubstitute?(user); return true; end
def canMagicCoat?; return true; end
def initialize(battle,move)
def initialize(battle, move)
super
@moveBlacklist = [
"DisableTargetUsingDifferentMove", # Encore
@@ -796,7 +796,7 @@ class Battle::Move::DisableTargetUsingDifferentMove < Battle::Move
end
def pbFailsAgainstTarget?(user, target, show_message)
if target.effects[PBEffects::Encore]>0
if target.effects[PBEffects::Encore] > 0
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
@@ -812,8 +812,8 @@ class Battle::Move::DisableTargetUsingDifferentMove < Battle::Move
return true if pbMoveFailedAromaVeil?(user, target, show_message)
canEncore = false
target.eachMove do |m|
next if m.id!=target.lastRegularMoveUsed
next if m.pp==0 && m.total_pp>0
next if m.id != target.lastRegularMoveUsed
next if m.pp == 0 && m.total_pp > 0
canEncore = true
break
end
@@ -824,10 +824,10 @@ class Battle::Move::DisableTargetUsingDifferentMove < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::Encore] = 4
target.effects[PBEffects::EncoreMove] = target.lastRegularMoveUsed
@battle.pbDisplay(_INTL("{1} received an encore!",target.pbThis))
@battle.pbDisplay(_INTL("{1} received an encore!", target.pbThis))
target.pbItemStatusCureCheck
end
end
@@ -840,7 +840,7 @@ class Battle::Move::DisableTargetStatusMoves < Battle::Move
def canMagicCoat?; return true; end
def pbFailsAgainstTarget?(user, target, show_message)
if target.effects[PBEffects::Taunt]>0
if target.effects[PBEffects::Taunt] > 0
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
@@ -862,9 +862,9 @@ class Battle::Move::DisableTargetStatusMoves < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::Taunt] = 4
@battle.pbDisplay(_INTL("{1} fell for the taunt!",target.pbThis))
@battle.pbDisplay(_INTL("{1} fell for the taunt!", target.pbThis))
target.pbItemStatusCureCheck
end
end
@@ -876,7 +876,7 @@ class Battle::Move::DisableTargetHealingMoves < Battle::Move
def canMagicCoat?; return true; end
def pbFailsAgainstTarget?(user, target, show_message)
if target.effects[PBEffects::HealBlock]>0
if target.effects[PBEffects::HealBlock] > 0
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
@@ -884,9 +884,9 @@ class Battle::Move::DisableTargetHealingMoves < Battle::Move
return false
end
def pbEffectAgainstTarget(user,target)
def pbEffectAgainstTarget(user, target)
target.effects[PBEffects::HealBlock] = 5
@battle.pbDisplay(_INTL("{1} was prevented from healing!",target.pbThis))
@battle.pbDisplay(_INTL("{1} was prevented from healing!", target.pbThis))
target.pbItemStatusCureCheck
end
end
@@ -895,10 +895,10 @@ end
# Target cannot use sound-based moves for 2 more rounds. (Throat Chop)
#===============================================================================
class Battle::Move::DisableTargetSoundMoves < Battle::Move
def pbAdditionalEffect(user,target)
def pbAdditionalEffect(user, target)
return if target.fainted? || target.damageState.substitute
@battle.pbDisplay(_INTL("The effects of {1} prevent {2} from using certain moves!",
@name,target.pbThis(true))) if target.effects[PBEffects::ThroatChop]==0
@name, target.pbThis(true))) if target.effects[PBEffects::ThroatChop] == 0
target.effects[PBEffects::ThroatChop] = 3
end
end
@@ -909,7 +909,7 @@ end
class Battle::Move::DisableTargetMovesKnownByUser < Battle::Move
def canSnatch?; return true; end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if user.effects[PBEffects::Imprison]
@battle.pbDisplay(_INTL("But it failed!"))
return true
@@ -919,6 +919,6 @@ class Battle::Move::DisableTargetMovesKnownByUser < Battle::Move
def pbEffectGeneral(user)
user.effects[PBEffects::Imprison] = true
@battle.pbDisplay(_INTL("{1} sealed any moves its target shares with it!",user.pbThis))
@battle.pbDisplay(_INTL("{1} sealed any moves its target shares with it!", user.pbThis))
end
end

View File

@@ -84,9 +84,9 @@ class Battle::Scene
def pbGraphicsUpdate
# Update lineup animations
if @animations.length>0
if @animations.length > 0
shouldCompact = false
@animations.each_with_index do |a,i|
@animations.each_with_index do |a, i|
a.update
if a.animDone?
a.dispose
@@ -100,7 +100,7 @@ class Battle::Scene
@sprites["battle_bg"].update if @sprites["battle_bg"].respond_to?("update")
Graphics.update
@frameCounter += 1
@frameCounter = @frameCounter%(Graphics.frame_rate*12/20)
@frameCounter = @frameCounter % (Graphics.frame_rate * 12 / 20)
end
def pbInputUpdate
@@ -113,7 +113,7 @@ class Battle::Scene
def pbFrameUpdate(cw = nil)
cw.update if cw
@battle.battlers.each_with_index do |b,i|
@battle.battlers.each_with_index do |b, i|
next if !b
@sprites["dataBox_#{i}"].update(@frameCounter) if @sprites["dataBox_#{i}"]
@sprites["pokemon_#{i}"].update(@frameCounter) if @sprites["pokemon_#{i}"]
@@ -122,7 +122,7 @@ class Battle::Scene
end
def pbRefresh
@battle.battlers.each_with_index do |b,i|
@battle.battlers.each_with_index do |b, i|
next if !b
@sprites["dataBox_#{i}"].refresh if @sprites["dataBox_#{i}"]
end
@@ -147,7 +147,7 @@ class Battle::Scene
#=============================================================================
# Returns whether the party line-ups are currently coming on-screen
def inPartyAnimation?
return @animations.length>0
return @animations.length > 0
end
#=============================================================================
@@ -157,11 +157,11 @@ class Battle::Scene
# NOTE: If you are not using fancy graphics for the command/fight menus, you
# will need to make "messageBox" also visible if the windowtype if
# COMMAND_BOX/FIGHT_BOX respectively.
@sprites["messageBox"].visible = (windowType==MESSAGE_BOX)
@sprites["messageWindow"].visible = (windowType==MESSAGE_BOX)
@sprites["commandWindow"].visible = (windowType==COMMAND_BOX)
@sprites["fightWindow"].visible = (windowType==FIGHT_BOX)
@sprites["targetWindow"].visible = (windowType==TARGET_BOX)
@sprites["messageBox"].visible = (windowType == MESSAGE_BOX)
@sprites["messageWindow"].visible = (windowType == MESSAGE_BOX)
@sprites["commandWindow"].visible = (windowType == COMMAND_BOX)
@sprites["fightWindow"].visible = (windowType == FIGHT_BOX)
@sprites["targetWindow"].visible = (windowType == TARGET_BOX)
end
# This is for the end of brief messages, which have been lingering on-screen
@@ -185,7 +185,7 @@ class Battle::Scene
# NOTE: A regular message is displayed for 1 second after it fully appears (or
# less if Back/Use is pressed). Disappears automatically after that time.
def pbDisplayMessage(msg,brief = false)
def pbDisplayMessage(msg, brief = false)
pbWaitMessage
pbShowWindow(MESSAGE_BOX)
cw = @sprites["messageWindow"]
@@ -235,7 +235,7 @@ class Battle::Scene
pbWaitMessage
pbShowWindow(MESSAGE_BOX)
cw = @sprites["messageWindow"]
cw.text = _INTL("{1}\1",msg)
cw.text = _INTL("{1}\1", msg)
PBDebug.log(msg)
yielded = false
timer = 0.0
@@ -269,19 +269,19 @@ class Battle::Scene
end
def pbDisplayConfirmMessage(msg)
return pbShowCommands(msg,[_INTL("Yes"),_INTL("No")],1)==0
return pbShowCommands(msg, [_INTL("Yes"), _INTL("No")], 1) == 0
end
def pbShowCommands(msg,commands,defaultValue)
def pbShowCommands(msg, commands, defaultValue)
pbWaitMessage
pbShowWindow(MESSAGE_BOX)
dw = @sprites["messageWindow"]
dw.text = msg
cw = Window_CommandPokemon.new(commands)
cw.height = Graphics.height - dw.height if cw.height > Graphics.height - dw.height
cw.x = Graphics.width-cw.width
cw.y = Graphics.height-cw.height-dw.height
cw.z = dw.z+1
cw.x = Graphics.width - cw.width
cw.y = Graphics.height - cw.height - dw.height
cw.z = dw.z + 1
cw.index = 0
cw.viewport = @viewport
PBDebug.log(msg)
@@ -289,7 +289,7 @@ class Battle::Scene
cw.visible = (!dw.busy?)
pbUpdate(cw)
dw.update
if Input.trigger?(Input::BACK) && defaultValue>=0
if Input.trigger?(Input::BACK) && defaultValue >= 0
if dw.busy?
pbPlayDecisionSE if dw.pausing?
dw.resume
@@ -314,8 +314,8 @@ class Battle::Scene
#=============================================================================
# Sprites
#=============================================================================
def pbAddSprite(id,x,y,filename,viewport)
sprite = @sprites[id] || IconSprite.new(x,y,viewport)
def pbAddSprite(id, x, y, filename, viewport)
sprite = @sprites[id] || IconSprite.new(x, y, viewport)
if filename
sprite.setBitmap(filename) rescue nil
end
@@ -323,7 +323,7 @@ class Battle::Scene
return sprite
end
def pbAddPlane(id,filename,viewport)
def pbAddPlane(id, filename, viewport)
sprite = AnimatedPlane.new(viewport)
if filename
sprite.setBitmap(filename)
@@ -337,12 +337,12 @@ class Battle::Scene
end
# Used by Ally Switch.
def pbSwapBattlerSprites(idxA,idxB)
def pbSwapBattlerSprites(idxA, idxB)
@sprites["pokemon_#{idxA}"], @sprites["pokemon_#{idxB}"] = @sprites["pokemon_#{idxB}"], @sprites["pokemon_#{idxA}"]
@sprites["shadow_#{idxA}"], @sprites["shadow_#{idxB}"] = @sprites["shadow_#{idxB}"], @sprites["shadow_#{idxA}"]
@lastCmd[idxA], @lastCmd[idxB] = @lastCmd[idxB], @lastCmd[idxA]
@lastMove[idxA], @lastMove[idxB] = @lastMove[idxB], @lastMove[idxA]
[idxA,idxB].each do |i|
[idxA, idxB].each do |i|
@sprites["pokemon_#{i}"].index = i
@sprites["pokemon_#{i}"].pbSetPosition
@sprites["shadow_#{i}"].index = i
@@ -379,22 +379,22 @@ class Battle::Scene
#=============================================================================
#
#=============================================================================
def pbSelectBattler(idxBattler,selectMode = 1)
numWindows = @battle.sideSizes.max*2
def pbSelectBattler(idxBattler, selectMode = 1)
numWindows = @battle.sideSizes.max * 2
for i in 0...numWindows
sel = (idxBattler.is_a?(Array)) ? !idxBattler[i].nil? : i==idxBattler
sel = (idxBattler.is_a?(Array)) ? !idxBattler[i].nil? : i == idxBattler
selVal = (sel) ? selectMode : 0
@sprites["dataBox_#{i}"].selected = selVal if @sprites["dataBox_#{i}"]
@sprites["pokemon_#{i}"].selected = selVal if @sprites["pokemon_#{i}"]
end
end
def pbChangePokemon(idxBattler,pkmn)
def pbChangePokemon(idxBattler, pkmn)
idxBattler = idxBattler.index if idxBattler.respond_to?("index")
pkmnSprite = @sprites["pokemon_#{idxBattler}"]
shadowSprite = @sprites["shadow_#{idxBattler}"]
back = !@battle.opposes?(idxBattler)
pkmnSprite.setPokemonBitmap(pkmn,back)
pkmnSprite.setPokemonBitmap(pkmn, back)
shadowSprite.setPokemonBitmap(pkmn)
# Set visibility of battler's shadow
shadowSprite.visible = pkmn.species_data.shows_shadow? if shadowSprite && !back

View File

@@ -14,10 +14,10 @@ class Battle::Scene
# Called whenever the battle begins.
def pbStartBattle(battle)
@battle = battle
@viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99999
@lastCmd = Array.new(@battle.battlers.length,0)
@lastMove = Array.new(@battle.battlers.length,0)
@lastCmd = Array.new(@battle.battlers.length, 0)
@lastMove = Array.new(@battle.battlers.length, 0)
pbInitSprites
pbBattleIntroAnimation
end
@@ -27,12 +27,12 @@ class Battle::Scene
# The background image and each side's base graphic
pbCreateBackdropSprites
# Create message box graphic
messageBox = pbAddSprite("messageBox",0,Graphics.height-96,
"Graphics/Pictures/Battle/overlay_message",@viewport)
messageBox = pbAddSprite("messageBox", 0, Graphics.height - 96,
"Graphics/Pictures/Battle/overlay_message", @viewport)
messageBox.z = 195
# Create message window (displays the message)
msgWindow = Window_AdvancedTextPokemon.newWithSize("",
16,Graphics.height-96+2,Graphics.width-32,96,@viewport)
16, Graphics.height - 96 + 2, Graphics.width - 32, 96, @viewport)
msgWindow.z = 200
msgWindow.opacity = 0
msgWindow.baseColor = MESSAGE_BASE_COLOR
@@ -40,52 +40,52 @@ class Battle::Scene
msgWindow.letterbyletter = true
@sprites["messageWindow"] = msgWindow
# Create command window
@sprites["commandWindow"] = CommandMenu.new(@viewport,200)
@sprites["commandWindow"] = CommandMenu.new(@viewport, 200)
# Create fight window
@sprites["fightWindow"] = FightMenu.new(@viewport,200)
@sprites["fightWindow"] = FightMenu.new(@viewport, 200)
# Create targeting window
@sprites["targetWindow"] = TargetMenu.new(@viewport,200,@battle.sideSizes)
@sprites["targetWindow"] = TargetMenu.new(@viewport, 200, @battle.sideSizes)
pbShowWindow(MESSAGE_BOX)
# The party lineup graphics (bar and balls) for both sides
for side in 0...2
partyBar = pbAddSprite("partyBar_#{side}",0,0,
"Graphics/Pictures/Battle/overlay_lineup",@viewport)
partyBar = pbAddSprite("partyBar_#{side}", 0, 0,
"Graphics/Pictures/Battle/overlay_lineup", @viewport)
partyBar.z = 120
partyBar.mirror = true if side==0 # Player's lineup bar only
partyBar.mirror = true if side == 0 # Player's lineup bar only
partyBar.visible = false
for i in 0...NUM_BALLS
ball = pbAddSprite("partyBall_#{side}_#{i}",0,0,nil,@viewport)
ball = pbAddSprite("partyBall_#{side}_#{i}", 0, 0, nil, @viewport)
ball.z = 121
ball.visible = false
end
# Ability splash bars
if USE_ABILITY_SPLASH
@sprites["abilityBar_#{side}"] = AbilitySplashBar.new(side,@viewport)
@sprites["abilityBar_#{side}"] = AbilitySplashBar.new(side, @viewport)
end
end
# Player's and partner trainer's back sprite
@battle.player.each_with_index do |p,i|
pbCreateTrainerBackSprite(i,p.trainer_type,@battle.player.length)
@battle.player.each_with_index do |p, i|
pbCreateTrainerBackSprite(i, p.trainer_type, @battle.player.length)
end
# Opposing trainer(s) sprites
if @battle.trainerBattle?
@battle.opponent.each_with_index do |p,i|
pbCreateTrainerFrontSprite(i,p.trainer_type,@battle.opponent.length)
@battle.opponent.each_with_index do |p, i|
pbCreateTrainerFrontSprite(i, p.trainer_type, @battle.opponent.length)
end
end
# Data boxes and Pokémon sprites
@battle.battlers.each_with_index do |b,i|
@battle.battlers.each_with_index do |b, i|
next if !b
@sprites["dataBox_#{i}"] = PokemonDataBox.new(b,@battle.pbSideSize(i),@viewport)
@sprites["dataBox_#{i}"] = PokemonDataBox.new(b, @battle.pbSideSize(i), @viewport)
pbCreatePokemonSprite(i)
end
# Wild battle, so set up the Pokémon sprite(s) accordingly
if @battle.wildBattle?
@battle.pbParty(1).each_with_index do |pkmn,i|
index = i*2+1
pbChangePokemon(index,pkmn)
@battle.pbParty(1).each_with_index do |pkmn, i|
index = i * 2 + 1
pbChangePokemon(index, pkmn)
pkmnSprite = @sprites["pokemon_#{index}"]
pkmnSprite.tone = Tone.new(-80,-80,-80)
pkmnSprite.tone = Tone.new(-80, -80, -80)
pkmnSprite.visible = true
end
end
@@ -99,92 +99,92 @@ class Battle::Scene
# Put everything together into backdrop, bases and message bar filenames
backdropFilename = @battle.backdrop
baseFilename = @battle.backdrop
baseFilename = sprintf("%s_%s",baseFilename,@battle.backdropBase) if @battle.backdropBase
baseFilename = sprintf("%s_%s", baseFilename, @battle.backdropBase) if @battle.backdropBase
messageFilename = @battle.backdrop
if time
trialName = sprintf("%s_%s",backdropFilename,time)
if pbResolveBitmap(sprintf("Graphics/Battlebacks/"+trialName+"_bg"))
trialName = sprintf("%s_%s", backdropFilename, time)
if pbResolveBitmap(sprintf("Graphics/Battlebacks/" + trialName + "_bg"))
backdropFilename = trialName
end
trialName = sprintf("%s_%s",baseFilename,time)
if pbResolveBitmap(sprintf("Graphics/Battlebacks/"+trialName+"_base0"))
trialName = sprintf("%s_%s", baseFilename, time)
if pbResolveBitmap(sprintf("Graphics/Battlebacks/" + trialName + "_base0"))
baseFilename = trialName
end
trialName = sprintf("%s_%s",messageFilename,time)
if pbResolveBitmap(sprintf("Graphics/Battlebacks/"+trialName+"_message"))
trialName = sprintf("%s_%s", messageFilename, time)
if pbResolveBitmap(sprintf("Graphics/Battlebacks/" + trialName + "_message"))
messageFilename = trialName
end
end
if !pbResolveBitmap(sprintf("Graphics/Battlebacks/"+baseFilename+"_base0")) &&
if !pbResolveBitmap(sprintf("Graphics/Battlebacks/" + baseFilename + "_base0")) &&
@battle.backdropBase
baseFilename = @battle.backdropBase
if time
trialName = sprintf("%s_%s",baseFilename,time)
if pbResolveBitmap(sprintf("Graphics/Battlebacks/"+trialName+"_base0"))
trialName = sprintf("%s_%s", baseFilename, time)
if pbResolveBitmap(sprintf("Graphics/Battlebacks/" + trialName + "_base0"))
baseFilename = trialName
end
end
end
# Finalise filenames
battleBG = "Graphics/Battlebacks/"+backdropFilename+"_bg"
playerBase = "Graphics/Battlebacks/"+baseFilename+"_base0"
enemyBase = "Graphics/Battlebacks/"+baseFilename+"_base1"
messageBG = "Graphics/Battlebacks/"+messageFilename+"_message"
battleBG = "Graphics/Battlebacks/" + backdropFilename + "_bg"
playerBase = "Graphics/Battlebacks/" + baseFilename + "_base0"
enemyBase = "Graphics/Battlebacks/" + baseFilename + "_base1"
messageBG = "Graphics/Battlebacks/" + messageFilename + "_message"
# Apply graphics
bg = pbAddSprite("battle_bg",0,0,battleBG,@viewport)
bg = pbAddSprite("battle_bg", 0, 0, battleBG, @viewport)
bg.z = 0
bg = pbAddSprite("battle_bg2",-Graphics.width,0,battleBG,@viewport)
bg = pbAddSprite("battle_bg2", -Graphics.width, 0, battleBG, @viewport)
bg.z = 0
bg.mirror = true
for side in 0...2
baseX, baseY = Battle::Scene.pbBattlerPosition(side)
base = pbAddSprite("base_#{side}",baseX,baseY,
(side==0) ? playerBase : enemyBase,@viewport)
base.z = 1
base = pbAddSprite("base_#{side}", baseX, baseY,
(side == 0) ? playerBase : enemyBase, @viewport)
base.z = 1
if base.bitmap
base.ox = base.bitmap.width/2
base.oy = (side==0) ? base.bitmap.height : base.bitmap.height/2
base.ox = base.bitmap.width / 2
base.oy = (side == 0) ? base.bitmap.height : base.bitmap.height / 2
end
end
cmdBarBG = pbAddSprite("cmdBar_bg",0,Graphics.height-96,messageBG,@viewport)
cmdBarBG = pbAddSprite("cmdBar_bg", 0, Graphics.height - 96, messageBG, @viewport)
cmdBarBG.z = 180
end
def pbCreateTrainerBackSprite(idxTrainer,trainerType,numTrainers = 1)
if idxTrainer==0 # Player's sprite
def pbCreateTrainerBackSprite(idxTrainer, trainerType, numTrainers = 1)
if idxTrainer == 0 # Player's sprite
trainerFile = GameData::TrainerType.player_back_sprite_filename(trainerType)
else # Partner trainer's sprite
trainerFile = GameData::TrainerType.back_sprite_filename(trainerType)
end
spriteX, spriteY = Battle::Scene.pbTrainerPosition(0,idxTrainer,numTrainers)
trainer = pbAddSprite("player_#{idxTrainer+1}",spriteX,spriteY,trainerFile,@viewport)
spriteX, spriteY = Battle::Scene.pbTrainerPosition(0, idxTrainer, numTrainers)
trainer = pbAddSprite("player_#{idxTrainer + 1}", spriteX, spriteY, trainerFile, @viewport)
return if !trainer.bitmap
# Alter position of sprite
trainer.z = 80+idxTrainer
if trainer.bitmap.width>trainer.bitmap.height*2
trainer.z = 80 + idxTrainer
if trainer.bitmap.width > trainer.bitmap.height * 2
trainer.src_rect.x = 0
trainer.src_rect.width = trainer.bitmap.width/5
trainer.src_rect.width = trainer.bitmap.width / 5
end
trainer.ox = trainer.src_rect.width/2
trainer.ox = trainer.src_rect.width / 2
trainer.oy = trainer.bitmap.height
end
def pbCreateTrainerFrontSprite(idxTrainer,trainerType,numTrainers = 1)
def pbCreateTrainerFrontSprite(idxTrainer, trainerType, numTrainers = 1)
trainerFile = GameData::TrainerType.front_sprite_filename(trainerType)
spriteX, spriteY = Battle::Scene.pbTrainerPosition(1,idxTrainer,numTrainers)
trainer = pbAddSprite("trainer_#{idxTrainer+1}",spriteX,spriteY,trainerFile,@viewport)
spriteX, spriteY = Battle::Scene.pbTrainerPosition(1, idxTrainer, numTrainers)
trainer = pbAddSprite("trainer_#{idxTrainer + 1}", spriteX, spriteY, trainerFile, @viewport)
return if !trainer.bitmap
# Alter position of sprite
trainer.z = 7+idxTrainer
trainer.ox = trainer.src_rect.width/2
trainer.z = 7 + idxTrainer
trainer.ox = trainer.src_rect.width / 2
trainer.oy = trainer.bitmap.height
end
def pbCreatePokemonSprite(idxBattler)
sideSize = @battle.pbSideSize(idxBattler)
batSprite = BattlerSprite.new(@viewport,sideSize,idxBattler,@animations)
batSprite = BattlerSprite.new(@viewport, sideSize, idxBattler, @animations)
@sprites["pokemon_#{idxBattler}"] = batSprite
shaSprite = BattlerShadowSprite.new(@viewport,sideSize,idxBattler)
shaSprite = BattlerShadowSprite.new(@viewport, sideSize, idxBattler)
shaSprite.visible = false
@sprites["shadow_#{idxBattler}"] = shaSprite
end

View File

@@ -3,18 +3,18 @@ class Battle::Scene
# The player chooses a main command for a Pokémon
# Return values: -1=Cancel, 0=Fight, 1=Bag, 2=Pokémon, 3=Run, 4=Call
#=============================================================================
def pbCommandMenu(idxBattler,firstAction)
def pbCommandMenu(idxBattler, firstAction)
shadowTrainer = (GameData::Type.exists?(:SHADOW) && @battle.trainerBattle?)
cmds = [
_INTL("What will\n{1} do?",@battle.battlers[idxBattler].name),
_INTL("What will\n{1} do?", @battle.battlers[idxBattler].name),
_INTL("Fight"),
_INTL("Bag"),
_INTL("Pokémon"),
(shadowTrainer) ? _INTL("Call") : (firstAction) ? _INTL("Run") : _INTL("Cancel")
]
ret = pbCommandMenuEx(idxBattler,cmds,(shadowTrainer) ? 2 : (firstAction) ? 0 : 1)
ret = 4 if ret==3 && shadowTrainer # Convert "Run" to "Call"
ret = -1 if ret==3 && !firstAction # Convert "Run" to "Cancel"
ret = pbCommandMenuEx(idxBattler, cmds, (shadowTrainer) ? 2 : (firstAction) ? 0 : 1)
ret = 4 if ret == 3 && shadowTrainer # Convert "Run" to "Call"
ret = -1 if ret == 3 && !firstAction # Convert "Run" to "Cancel"
return ret
end
@@ -23,11 +23,11 @@ class Battle::Scene
# 2 = regular battle with "Call" (for Shadow Pokémon battles)
# 3 = Safari Zone
# 4 = Bug Catching Contest
def pbCommandMenuEx(idxBattler,texts,mode = 0)
def pbCommandMenuEx(idxBattler, texts, mode = 0)
pbShowWindow(COMMAND_BOX)
cw = @sprites["commandWindow"]
cw.setTexts(texts)
cw.setIndexAndMode(@lastCmd[idxBattler],mode)
cw.setIndexAndMode(@lastCmd[idxBattler], mode)
pbSelectBattler(idxBattler)
ret = -1
loop do
@@ -35,22 +35,22 @@ class Battle::Scene
pbUpdate(cw)
# Update selected command
if Input.trigger?(Input::LEFT)
cw.index -= 1 if (cw.index&1)==1
cw.index -= 1 if (cw.index & 1) == 1
elsif Input.trigger?(Input::RIGHT)
cw.index += 1 if (cw.index&1)==0
cw.index += 1 if (cw.index & 1) == 0
elsif Input.trigger?(Input::UP)
cw.index -= 2 if (cw.index&2)==2
cw.index -= 2 if (cw.index & 2) == 2
elsif Input.trigger?(Input::DOWN)
cw.index += 2 if (cw.index&2)==0
cw.index += 2 if (cw.index & 2) == 0
end
pbPlayCursorSE if cw.index!=oldIndex
pbPlayCursorSE if cw.index != oldIndex
# Actions
if Input.trigger?(Input::USE) # Confirm choice
pbPlayDecisionSE
ret = cw.index
@lastCmd[idxBattler] = ret
break
elsif Input.trigger?(Input::BACK) && mode==1 # Cancel
elsif Input.trigger?(Input::BACK) && mode == 1 # Cancel
pbPlayCancelSE
break
elsif Input.trigger?(Input::F9) && $DEBUG # Debug menu
@@ -65,7 +65,7 @@ class Battle::Scene
#=============================================================================
# The player chooses a move for a Pokémon to use
#=============================================================================
def pbFightMenu(idxBattler,megaEvoPossible = false)
def pbFightMenu(idxBattler, megaEvoPossible = false)
battler = @battle.battlers[idxBattler]
cw = @sprites["fightWindow"]
cw.battler = battler
@@ -74,7 +74,7 @@ class Battle::Scene
moveIndex = @lastMove[idxBattler]
end
cw.shiftMode = (@battle.pbCanShift?(idxBattler)) ? 1 : 0
cw.setIndexAndMode(moveIndex,(megaEvoPossible) ? 1 : 0)
cw.setIndexAndMode(moveIndex, (megaEvoPossible) ? 1 : 0)
needFullRefresh = true
needRefresh = false
loop do
@@ -87,7 +87,7 @@ class Battle::Scene
if needRefresh
if megaEvoPossible
newMode = (@battle.pbRegisteredMegaEvolution?(idxBattler)) ? 2 : 1
cw.mode = newMode if newMode!=cw.mode
cw.mode = newMode if newMode != cw.mode
end
needRefresh = false
end
@@ -96,19 +96,19 @@ class Battle::Scene
pbUpdate(cw)
# Update selected command
if Input.trigger?(Input::LEFT)
cw.index -= 1 if (cw.index&1)==1
cw.index -= 1 if (cw.index & 1) == 1
elsif Input.trigger?(Input::RIGHT)
if battler.moves[cw.index+1] && battler.moves[cw.index+1].id
cw.index += 1 if (cw.index&1)==0
if battler.moves[cw.index + 1] && battler.moves[cw.index + 1].id
cw.index += 1 if (cw.index & 1) == 0
end
elsif Input.trigger?(Input::UP)
cw.index -= 2 if (cw.index&2)==2
cw.index -= 2 if (cw.index & 2) == 2
elsif Input.trigger?(Input::DOWN)
if battler.moves[cw.index+2] && battler.moves[cw.index+2].id
cw.index += 2 if (cw.index&2)==0
if battler.moves[cw.index + 2] && battler.moves[cw.index + 2].id
cw.index += 2 if (cw.index & 2) == 0
end
end
pbPlayCursorSE if cw.index!=oldIndex
pbPlayCursorSE if cw.index != oldIndex
# Actions
if Input.trigger?(Input::USE) # Confirm choice
pbPlayDecisionSE
@@ -126,7 +126,7 @@ class Battle::Scene
needRefresh = true
end
elsif Input.trigger?(Input::SPECIAL) # Shift
if cw.shiftMode>0
if cw.shiftMode > 0
pbPlayDecisionSE
break if yield -3
needRefresh = true
@@ -140,7 +140,7 @@ class Battle::Scene
# Opens the party screen to choose a Pokémon to switch in (or just view its
# summary screens)
#=============================================================================
def pbPartyScreen(idxBattler,canCancel = false)
def pbPartyScreen(idxBattler, canCancel = false)
# Fade out and hide all sprites
visibleSprites = pbFadeOutAndHide(@sprites)
# Get player's party
@@ -149,14 +149,14 @@ class Battle::Scene
modParty = @battle.pbPlayerDisplayParty(idxBattler)
# Start party screen
scene = PokemonParty_Scene.new
switchScreen = PokemonPartyScreen.new(scene,modParty)
switchScreen.pbStartScene(_INTL("Choose a Pokémon."),@battle.pbNumPositions(0,0))
switchScreen = PokemonPartyScreen.new(scene, modParty)
switchScreen.pbStartScene(_INTL("Choose a Pokémon."), @battle.pbNumPositions(0, 0))
# Loop while in party screen
loop do
# Select a Pokémon
scene.pbSetHelpText(_INTL("Choose a Pokémon."))
idxParty = switchScreen.pbChoosePokemon
if idxParty<0
if idxParty < 0
next if !canCancel
break
end
@@ -167,29 +167,29 @@ class Battle::Scene
commands[cmdSwitch = commands.length] = _INTL("Switch In") if modParty[idxParty].able?
commands[cmdSummary = commands.length] = _INTL("Summary")
commands[commands.length] = _INTL("Cancel")
command = scene.pbShowCommands(_INTL("Do what with {1}?",modParty[idxParty].name),commands)
if cmdSwitch>=0 && command==cmdSwitch # Switch In
command = scene.pbShowCommands(_INTL("Do what with {1}?", modParty[idxParty].name), commands)
if cmdSwitch >= 0 && command == cmdSwitch # Switch In
idxPartyRet = -1
partyPos.each_with_index do |pos,i|
next if pos!=idxParty+partyStart
partyPos.each_with_index do |pos, i|
next if pos != idxParty + partyStart
idxPartyRet = i
break
end
break if yield idxPartyRet, switchScreen
elsif cmdSummary>=0 && command==cmdSummary # Summary
scene.pbSummary(idxParty,true)
elsif cmdSummary >= 0 && command == cmdSummary # Summary
scene.pbSummary(idxParty, true)
end
end
# Close party screen
switchScreen.pbEndScene
# Fade back into battle screen
pbFadeInAndShow(@sprites,visibleSprites)
pbFadeInAndShow(@sprites, visibleSprites)
end
#=============================================================================
# Opens the Bag screen and chooses an item to use
#=============================================================================
def pbItemMenu(idxBattler,_firstAction)
def pbItemMenu(idxBattler, _firstAction)
# Fade out and hide all sprites
visibleSprites = pbFadeOutAndHide(@sprites)
# Set Bag starting positions
@@ -216,10 +216,10 @@ class Battle::Scene
useType = item.battle_use
cmdUse = -1
commands = []
commands[cmdUse = commands.length] = _INTL("Use") if useType && useType!=0
commands[cmdUse = commands.length] = _INTL("Use") if useType && useType != 0
commands[commands.length] = _INTL("Cancel")
command = itemScene.pbShowCommands(_INTL("{1} is selected.",itemName),commands)
next unless cmdUse>=0 && command==cmdUse # Use
command = itemScene.pbShowCommands(_INTL("{1} is selected.", itemName), commands)
next unless cmdUse >= 0 && command == cmdUse # Use
# Use types:
# 0 = not usable in battle
# 1 = use on Pokémon (lots of items, Blue Flute)
@@ -233,11 +233,11 @@ class Battle::Scene
# are the only available Pokémon/battler to use the item on
case useType
when 1 # Use on Pokémon
if @battle.pbTeamLengthFromBattlerIndex(idxBattler)==1
if @battle.pbTeamLengthFromBattlerIndex(idxBattler) == 1
break if yield item.id, useType, @battle.battlers[idxBattler].pokemonIndex, -1, itemScene
end
when 3 # Use on battler
if @battle.pbPlayerBattlerCount==1
if @battle.pbPlayerBattlerCount == 1
break if yield item.id, useType, @battle.battlers[idxBattler].pokemonIndex, -1, itemScene
end
end
@@ -250,38 +250,38 @@ class Battle::Scene
modParty = @battle.pbPlayerDisplayParty(idxBattler)
# Start party screen
pkmnScene = PokemonParty_Scene.new
pkmnScreen = PokemonPartyScreen.new(pkmnScene,modParty)
pkmnScreen.pbStartScene(_INTL("Use on which Pokémon?"),@battle.pbNumPositions(0,0))
pkmnScreen = PokemonPartyScreen.new(pkmnScene, modParty)
pkmnScreen.pbStartScene(_INTL("Use on which Pokémon?"), @battle.pbNumPositions(0, 0))
idxParty = -1
# Loop while in party screen
loop do
# Select a Pokémon
pkmnScene.pbSetHelpText(_INTL("Use on which Pokémon?"))
idxParty = pkmnScreen.pbChoosePokemon
break if idxParty<0
break if idxParty < 0
idxPartyRet = -1
partyPos.each_with_index do |pos,i|
next if pos!=idxParty+partyStart
partyPos.each_with_index do |pos, i|
next if pos != idxParty + partyStart
idxPartyRet = i
break
end
next if idxPartyRet<0
next if idxPartyRet < 0
pkmn = party[idxPartyRet]
next if !pkmn || pkmn.egg?
idxMove = -1
if useType==2 # Use on Pokémon's move
idxMove = pkmnScreen.pbChooseMove(pkmn,_INTL("Restore which move?"))
next if idxMove<0
if useType == 2 # Use on Pokémon's move
idxMove = pkmnScreen.pbChooseMove(pkmn, _INTL("Restore which move?"))
next if idxMove < 0
end
break if yield item.id, useType, idxPartyRet, idxMove, pkmnScene
end
pkmnScene.pbEndScene
break if idxParty>=0
break if idxParty >= 0
# Cancelled choosing a Pokémon; show the Bag screen again
itemScene.pbFadeInScene
when 4 # Use on opposing battler (Poké Balls)
idxTarget = -1
if @battle.pbOpposingBattlerCount(idxBattler)==1
if @battle.pbOpposingBattlerCount(idxBattler) == 1
@battle.allOtherSideBattlers(idxBattler).each { |b| idxTarget = b.index }
break if yield item.id, useType, idxTarget, -1, itemScene
else
@@ -292,8 +292,8 @@ class Battle::Scene
tempVisibleSprites = visibleSprites.clone
tempVisibleSprites["commandWindow"] = false
tempVisibleSprites["targetWindow"] = true
idxTarget = pbChooseTarget(idxBattler,GameData::Target.get(:Foe),tempVisibleSprites)
if idxTarget>=0
idxTarget = pbChooseTarget(idxBattler, GameData::Target.get(:Foe), tempVisibleSprites)
if idxTarget >= 0
break if yield item.id, useType, idxTarget, -1, self
end
# Target invalid/cancelled choosing a target; show the Bag screen again
@@ -312,7 +312,7 @@ class Battle::Scene
# Close Bag screen
itemScene.pbEndScene
# Fade back into battle screen (if not already showing it)
pbFadeInAndShow(@sprites,visibleSprites) if !wasTargeting
pbFadeInAndShow(@sprites, visibleSprites) if !wasTargeting
end
#=============================================================================
@@ -322,7 +322,7 @@ class Battle::Scene
# target.
# nil means can't select that position, "" means can select that position but
# there is no battler there, otherwise is a battler's name.
def pbCreateTargetTexts(idxBattler,target_data)
def pbCreateTargetTexts(idxBattler, target_data)
texts = Array.new(@battle.battlers.length) do |i|
next nil if !@battle.battlers[i]
showName = false
@@ -331,15 +331,15 @@ class Battle::Scene
# other targets are handled by the "else" part.
case target_data.id
when :None, :User, :RandomNearFoe
showName = (i==idxBattler)
showName = (i == idxBattler)
when :UserSide
showName = !@battle.opposes?(i,idxBattler)
showName = !@battle.opposes?(i, idxBattler)
when :FoeSide
showName = @battle.opposes?(i,idxBattler)
showName = @battle.opposes?(i, idxBattler)
when :BothSides
showName = true
else
showName = @battle.pbMoveCanTarget?(i,idxBattler,target_data)
showName = @battle.pbMoveCanTarget?(i, idxBattler, target_data)
end
next nil if !showName
next (@battle.battlers[i].fainted?) ? "" : @battle.battlers[i].name
@@ -349,22 +349,22 @@ class Battle::Scene
# Returns the initial position of the cursor when choosing a target for a move
# in a non-single battle.
def pbFirstTarget(idxBattler,target_data)
def pbFirstTarget(idxBattler, target_data)
case target_data.id
when :NearAlly
@battle.allSameSideBattlers(idxBattler).each do |b|
next if b.index==idxBattler || !@battle.nearBattlers?(b,idxBattler)
next if b.index == idxBattler || !@battle.nearBattlers?(b, idxBattler)
next if b.fainted?
return b.index
end
@battle.allSameSideBattlers(idxBattler).each do |b|
next if b.index==idxBattler || !@battle.nearBattlers?(b,idxBattler)
next if b.index == idxBattler || !@battle.nearBattlers?(b, idxBattler)
return b.index
end
when :NearFoe, :NearOther
indices = @battle.pbGetOpposingIndicesInOrder(idxBattler)
indices.each { |i| return i if @battle.nearBattlers?(i,idxBattler) && !@battle.battlers[i].fainted? }
indices.each { |i| return i if @battle.nearBattlers?(i,idxBattler) }
indices.each { |i| return i if @battle.nearBattlers?(i, idxBattler) && !@battle.battlers[i].fainted? }
indices.each { |i| return i if @battle.nearBattlers?(i, idxBattler) }
when :Foe, :Other
indices = @battle.pbGetOpposingIndicesInOrder(idxBattler)
indices.each { |i| return i if !@battle.battlers[i].fainted? }
@@ -373,37 +373,37 @@ class Battle::Scene
return idxBattler # Target the user initially
end
def pbChooseTarget(idxBattler,target_data,visibleSprites = nil)
def pbChooseTarget(idxBattler, target_data, visibleSprites = nil)
pbShowWindow(TARGET_BOX)
cw = @sprites["targetWindow"]
# Create an array of battler names (only valid targets are named)
texts = pbCreateTargetTexts(idxBattler,target_data)
texts = pbCreateTargetTexts(idxBattler, target_data)
# Determine mode based on target_data
mode = (target_data.num_targets == 1) ? 0 : 1
cw.setDetails(texts,mode)
cw.index = pbFirstTarget(idxBattler,target_data)
pbSelectBattler((mode==0) ? cw.index : texts,2) # Select initial battler/data box
pbFadeInAndShow(@sprites,visibleSprites) if visibleSprites
cw.setDetails(texts, mode)
cw.index = pbFirstTarget(idxBattler, target_data)
pbSelectBattler((mode == 0) ? cw.index : texts, 2) # Select initial battler/data box
pbFadeInAndShow(@sprites, visibleSprites) if visibleSprites
ret = -1
loop do
oldIndex = cw.index
pbUpdate(cw)
# Update selected command
if mode==0 # Choosing just one target, can change index
if mode == 0 # Choosing just one target, can change index
if Input.trigger?(Input::LEFT) || Input.trigger?(Input::RIGHT)
inc = ((cw.index%2)==0) ? -2 : 2
inc = ((cw.index % 2) == 0) ? -2 : 2
inc *= -1 if Input.trigger?(Input::RIGHT)
indexLength = @battle.sideSizes[cw.index%2]*2
indexLength = @battle.sideSizes[cw.index % 2] * 2
newIndex = cw.index
loop do
newIndex += inc
break if newIndex<0 || newIndex>=indexLength
break if newIndex < 0 || newIndex >= indexLength
next if texts[newIndex].nil?
cw.index = newIndex
break
end
elsif (Input.trigger?(Input::UP) && (cw.index%2)==0) ||
(Input.trigger?(Input::DOWN) && (cw.index%2)==1)
elsif (Input.trigger?(Input::UP) && (cw.index % 2) == 0) ||
(Input.trigger?(Input::DOWN) && (cw.index % 2) == 1)
tryIndex = @battle.pbGetOpposingIndicesInOrder(cw.index)
tryIndex.each do |idxBattlerTry|
next if texts[idxBattlerTry].nil?
@@ -411,9 +411,9 @@ class Battle::Scene
break
end
end
if cw.index!=oldIndex
if cw.index != oldIndex
pbPlayCursorSE
pbSelectBattler(cw.index,2) # Select the new battler/data box
pbSelectBattler(cw.index, 2) # Select the new battler/data box
end
end
if Input.trigger?(Input::USE) # Confirm
@@ -436,12 +436,12 @@ class Battle::Scene
# Called whenever a Pokémon should forget a move. It should return -1 if the
# selection is canceled, or 0 to 3 to indicate the move to forget. It should
# not allow HM moves to be forgotten.
def pbForgetMove(pkmn,moveToLearn)
def pbForgetMove(pkmn, moveToLearn)
ret = -1
pbFadeOutIn {
scene = PokemonSummary_Scene.new
screen = PokemonSummaryScreen.new(scene)
ret = screen.pbStartForgetScreen([pkmn],0,moveToLearn)
ret = screen.pbStartForgetScreen([pkmn], 0, moveToLearn)
}
return ret
end
@@ -449,7 +449,7 @@ class Battle::Scene
#=============================================================================
# Opens the nicknaming screen for a newly caught Pokémon
#=============================================================================
def pbNameEntry(helpText,pkmn)
def pbNameEntry(helpText, pkmn)
return pbEnterPokemonName(helpText, 0, Pokemon::MAX_NAME_SIZE, "", pkmn)
end

View File

@@ -4,7 +4,7 @@ class Battle::Scene
#=============================================================================
def pbBattleIntroAnimation
# Make everything appear
introAnim = Animation::Intro.new(@sprites,@viewport,@battle)
introAnim = Animation::Intro.new(@sprites, @viewport, @battle)
loop do
introAnim.update
pbUpdate
@@ -19,8 +19,8 @@ class Battle::Scene
# entrance animation. Be sure to set it up like a Pokémon entrance
# animation, i.e. add them to @animations so that they can play out
# while party lineups appear and messages show.
pbShowPartyLineup(0,true)
pbShowPartyLineup(1,true)
pbShowPartyLineup(0, true)
pbShowPartyLineup(1, true)
return
end
# Wild battle: play wild Pokémon's intro animations (including cry), show
@@ -28,14 +28,14 @@ class Battle::Scene
# shiny animation(s)
# Set up data box animation
for i in 0...@battle.sideSizes[1]
idxBattler = 2*i+1
idxBattler = 2 * i + 1
next if !@battle.battlers[idxBattler]
dataBoxAnim = Animation::DataBoxAppear.new(@sprites,@viewport,idxBattler)
dataBoxAnim = Animation::DataBoxAppear.new(@sprites, @viewport, idxBattler)
@animations.push(dataBoxAnim)
end
# Set up wild Pokémon returning to normal colour and playing intro
# animations (including cry)
@animations.push(Animation::Intro2.new(@sprites,@viewport,@battle.sideSizes[1]))
@animations.push(Animation::Intro2.new(@sprites, @viewport, @battle.sideSizes[1]))
# Play all the animations
while inPartyAnimation?
pbUpdate
@@ -43,7 +43,7 @@ class Battle::Scene
# Show shiny animation for wild Pokémon
if @battle.showAnims
for i in 0...@battle.sideSizes[1]
idxBattler = 2*i+1
idxBattler = 2 * i + 1
next if !@battle.battlers[idxBattler] || !@battle.battlers[idxBattler].shiny?
if Settings::SUPER_SHINY && @battle.battlers[idxBattler].super_shiny?
pbCommonAnimation("SuperShiny", @battle.battlers[idxBattler])
@@ -57,9 +57,9 @@ class Battle::Scene
#=============================================================================
# Animates a party lineup appearing for the given side
#=============================================================================
def pbShowPartyLineup(side,fullAnim = false)
@animations.push(Animation::LineupAppear.new(@sprites,@viewport,
side,@battle.pbParty(side),@battle.pbPartyStarts(side),fullAnim))
def pbShowPartyLineup(side, fullAnim = false)
@animations.push(Animation::LineupAppear.new(@sprites, @viewport,
side, @battle.pbParty(side), @battle.pbPartyStarts(side), fullAnim))
if !fullAnim
while inPartyAnimation?
pbUpdate
@@ -74,7 +74,7 @@ class Battle::Scene
#=============================================================================
def pbShowOpponent(idxTrainer)
# Set up trainer appearing animation
appearAnim = Animation::TrainerAppear.new(@sprites,@viewport,idxTrainer)
appearAnim = Animation::TrainerAppear.new(@sprites, @viewport, idxTrainer)
@animations.push(appearAnim)
# Play the animation
while inPartyAnimation?
@@ -88,8 +88,8 @@ class Battle::Scene
# animation for it if relevant.
# sendOuts is an array; each element is itself an array: [idxBattler,pkmn]
#=============================================================================
def pbSendOutBattlers(sendOuts,startBattle = false)
return if sendOuts.length==0
def pbSendOutBattlers(sendOuts, startBattle = false)
return if sendOuts.length == 0
# If party balls are still appearing, wait for them to finish showing up, as
# the FadeAnimation will make them disappear.
while inPartyAnimation?
@@ -99,29 +99,29 @@ class Battle::Scene
# Make all trainers and party lineups disappear (player-side trainers may
# animate throwing a Poké Ball)
if @battle.opposes?(sendOuts[0][0])
fadeAnim = Animation::TrainerFade.new(@sprites,@viewport,startBattle)
fadeAnim = Animation::TrainerFade.new(@sprites, @viewport, startBattle)
else
fadeAnim = Animation::PlayerFade.new(@sprites,@viewport,startBattle)
fadeAnim = Animation::PlayerFade.new(@sprites, @viewport, startBattle)
end
# For each battler being sent out, set the battler's sprite and create two
# animations (the Poké Ball moving and battler appearing from it, and its
# data box appearing)
sendOutAnims = []
sendOuts.each_with_index do |b,i|
sendOuts.each_with_index do |b, i|
pkmn = @battle.battlers[b[0]].effects[PBEffects::Illusion] || b[1]
pbChangePokemon(b[0],pkmn)
pbChangePokemon(b[0], pkmn)
pbRefresh
if @battle.opposes?(b[0])
sendOutAnim = Animation::PokeballTrainerSendOut.new(@sprites,@viewport,
@battle.pbGetOwnerIndexFromBattlerIndex(b[0])+1,
@battle.battlers[b[0]],startBattle,i)
sendOutAnim = Animation::PokeballTrainerSendOut.new(@sprites, @viewport,
@battle.pbGetOwnerIndexFromBattlerIndex(b[0]) + 1,
@battle.battlers[b[0]], startBattle, i)
else
sendOutAnim = Animation::PokeballPlayerSendOut.new(@sprites,@viewport,
@battle.pbGetOwnerIndexFromBattlerIndex(b[0])+1,
@battle.battlers[b[0]],startBattle,i)
sendOutAnim = Animation::PokeballPlayerSendOut.new(@sprites, @viewport,
@battle.pbGetOwnerIndexFromBattlerIndex(b[0]) + 1,
@battle.battlers[b[0]], startBattle, i)
end
dataBoxAnim = Animation::DataBoxAppear.new(@sprites,@viewport,b[0])
sendOutAnims.push([sendOutAnim,dataBoxAnim,false])
dataBoxAnim = Animation::DataBoxAppear.new(@sprites, @viewport, b[0])
sendOutAnims.push([sendOutAnim, dataBoxAnim, false])
end
# Play all animations
loop do
@@ -159,7 +159,7 @@ class Battle::Scene
def pbRecall(idxBattler)
@briefMessage = false
# Recall animation
recallAnim = Animation::BattlerRecall.new(@sprites,@viewport,idxBattler)
recallAnim = Animation::BattlerRecall.new(@sprites, @viewport, idxBattler)
loop do
recallAnim.update if recallAnim
pbUpdate
@@ -167,7 +167,7 @@ class Battle::Scene
end
recallAnim.dispose
# Data box disappear animation
dataBoxAnim = Animation::DataBoxDisappear.new(@sprites,@viewport,idxBattler)
dataBoxAnim = Animation::DataBoxDisappear.new(@sprites, @viewport, idxBattler)
loop do
dataBoxAnim.update
pbUpdate
@@ -181,10 +181,10 @@ class Battle::Scene
#=============================================================================
def pbShowAbilitySplash(battler)
return if !USE_ABILITY_SPLASH
side = battler.index%2
side = battler.index % 2
pbHideAbilitySplash(battler) if @sprites["abilityBar_#{side}"].visible
@sprites["abilityBar_#{side}"].battler = battler
abilitySplashAnim = Animation::AbilitySplashAppear.new(@sprites,@viewport,side)
abilitySplashAnim = Animation::AbilitySplashAppear.new(@sprites, @viewport, side)
loop do
abilitySplashAnim.update
pbUpdate
@@ -195,9 +195,9 @@ class Battle::Scene
def pbHideAbilitySplash(battler)
return if !USE_ABILITY_SPLASH
side = battler.index%2
side = battler.index % 2
return if !@sprites["abilityBar_#{side}"].visible
abilitySplashAnim = Animation::AbilitySplashDisappear.new(@sprites,@viewport,side)
abilitySplashAnim = Animation::AbilitySplashDisappear.new(@sprites, @viewport, side)
loop do
abilitySplashAnim.update
pbUpdate
@@ -216,23 +216,23 @@ class Battle::Scene
#=============================================================================
# Shows a HP-changing common animation and animates a data box's HP bar.
# Called by def pbReduceHP, def pbRecoverHP.
def pbHPChanged(battler,oldHP,showAnim = false)
def pbHPChanged(battler, oldHP, showAnim = false)
@briefMessage = false
if battler.hp>oldHP
pbCommonAnimation("HealthUp",battler) if showAnim && @battle.showAnims
elsif battler.hp<oldHP
pbCommonAnimation("HealthDown",battler) if showAnim && @battle.showAnims
if battler.hp > oldHP
pbCommonAnimation("HealthUp", battler) if showAnim && @battle.showAnims
elsif battler.hp < oldHP
pbCommonAnimation("HealthDown", battler) if showAnim && @battle.showAnims
end
@sprites["dataBox_#{battler.index}"].animateHP(oldHP,battler.hp,battler.totalhp)
@sprites["dataBox_#{battler.index}"].animateHP(oldHP, battler.hp, battler.totalhp)
while @sprites["dataBox_#{battler.index}"].animatingHP
pbUpdate
end
end
def pbDamageAnimation(battler,effectiveness = 0)
def pbDamageAnimation(battler, effectiveness = 0)
@briefMessage = false
# Damage animation
damageAnim = Animation::BattlerDamage.new(@sprites,@viewport,battler.index,effectiveness)
damageAnim = Animation::BattlerDamage.new(@sprites, @viewport, battler.index, effectiveness)
loop do
damageAnim.update
pbUpdate
@@ -249,9 +249,9 @@ class Battle::Scene
# Set up animations
damageAnims = []
targets.each do |t|
anim = Animation::BattlerDamage.new(@sprites,@viewport,t[0].index,t[2])
anim = Animation::BattlerDamage.new(@sprites, @viewport, t[0].index, t[2])
damageAnims.push(anim)
@sprites["dataBox_#{t[0].index}"].animateHP(t[1],t[0].hp,t[0].totalhp)
@sprites["dataBox_#{t[0].index}"].animateHP(t[1], t[0].hp, t[0].totalhp)
end
# Update loop
loop do
@@ -278,13 +278,13 @@ class Battle::Scene
#=============================================================================
# Animates a data box's Exp bar
#=============================================================================
def pbEXPBar(battler,startExp,endExp,tempExp1,tempExp2)
def pbEXPBar(battler, startExp, endExp, tempExp1, tempExp2)
return if !battler || endExp == startExp
startExpLevel = tempExp1-startExp
endExpLevel = tempExp2-startExp
expRange = endExp-startExp
startExpLevel = tempExp1 - startExp
endExpLevel = tempExp2 - startExp
expRange = endExp - startExp
dataBox = @sprites["dataBox_#{battler.index}"]
dataBox.animateExp(startExpLevel,endExpLevel,expRange)
dataBox.animateExp(startExpLevel, endExpLevel, expRange)
while dataBox.animatingExp
pbUpdate
end
@@ -293,14 +293,14 @@ class Battle::Scene
#=============================================================================
# Shows stats windows upon a Pokémon levelling up
#=============================================================================
def pbLevelUp(pkmn,_battler,oldTotalHP,oldAttack,oldDefense,oldSpAtk,oldSpDef,oldSpeed)
def pbLevelUp(pkmn, _battler, oldTotalHP, oldAttack, oldDefense, oldSpAtk, oldSpDef, oldSpeed)
pbTopRightWindow(
_INTL("Max. HP<r>+{1}\r\nAttack<r>+{2}\r\nDefense<r>+{3}\r\nSp. Atk<r>+{4}\r\nSp. Def<r>+{5}\r\nSpeed<r>+{6}",
pkmn.totalhp-oldTotalHP,pkmn.attack-oldAttack,pkmn.defense-oldDefense,
pkmn.spatk-oldSpAtk,pkmn.spdef-oldSpDef,pkmn.speed-oldSpeed))
pkmn.totalhp - oldTotalHP, pkmn.attack - oldAttack, pkmn.defense - oldDefense,
pkmn.spatk - oldSpAtk, pkmn.spdef - oldSpDef, pkmn.speed - oldSpeed))
pbTopRightWindow(
_INTL("Max. HP<r>{1}\r\nAttack<r>{2}\r\nDefense<r>{3}\r\nSp. Atk<r>{4}\r\nSp. Def<r>{5}\r\nSpeed<r>{6}",
pkmn.totalhp,pkmn.attack,pkmn.defense,pkmn.spatk,pkmn.spdef,pkmn.speed))
pkmn.totalhp, pkmn.attack, pkmn.defense, pkmn.spatk, pkmn.spdef, pkmn.speed))
end
#=============================================================================
@@ -309,8 +309,8 @@ class Battle::Scene
def pbFaintBattler(battler)
@briefMessage = false
# Pokémon plays cry and drops down, data box disappears
faintAnim = Animation::BattlerFaint.new(@sprites,@viewport,battler.index,@battle)
dataBoxAnim = Animation::DataBoxDisappear.new(@sprites,@viewport,battler.index)
faintAnim = Animation::BattlerFaint.new(@sprites, @viewport, battler.index, @battle)
dataBoxAnim = Animation::DataBoxDisappear.new(@sprites, @viewport, battler.index)
loop do
faintAnim.update
dataBoxAnim.update
@@ -324,10 +324,10 @@ class Battle::Scene
#=============================================================================
# Animates throwing a Poké Ball at a Pokémon in an attempt to catch it
#=============================================================================
def pbThrow(ball,shakes,critical,targetBattler,showPlayer = false)
def pbThrow(ball, shakes, critical, targetBattler, showPlayer = false)
@briefMessage = false
captureAnim = Animation::PokeballThrowCapture.new(@sprites,@viewport,
ball,shakes,critical,@battle.battlers[targetBattler],showPlayer)
captureAnim = Animation::PokeballThrowCapture.new(@sprites, @viewport,
ball, shakes, critical, @battle.battlers[targetBattler], showPlayer)
loop do
captureAnim.update
pbUpdate
@@ -343,7 +343,7 @@ class Battle::Scene
i = 0
loop do
pbUpdate
break if i>=Graphics.frame_rate*3.5 # 3.5 seconds
break if i >= Graphics.frame_rate * 3.5 # 3.5 seconds
i += 1
end
pbMEStop
@@ -355,20 +355,20 @@ class Battle::Scene
ball = @sprites["captureBall"]
return if !ball
# Data box disappear animation
dataBoxAnim = Animation::DataBoxDisappear.new(@sprites,@viewport,idxBattler)
dataBoxAnim = Animation::DataBoxDisappear.new(@sprites, @viewport, idxBattler)
loop do
dataBoxAnim.update
ball.opacity -= 12*20/Graphics.frame_rate if ball.opacity>0
ball.opacity -= 12 * 20 / Graphics.frame_rate if ball.opacity > 0
pbUpdate
break if dataBoxAnim.animDone? && ball.opacity<=0
break if dataBoxAnim.animDone? && ball.opacity <= 0
end
dataBoxAnim.dispose
end
def pbThrowAndDeflect(ball,idxBattler)
def pbThrowAndDeflect(ball, idxBattler)
@briefMessage = false
throwAnim = Animation::PokeballThrowDeflect.new(@sprites,@viewport,
ball,@battle.battlers[idxBattler])
throwAnim = Animation::PokeballThrowDeflect.new(@sprites, @viewport,
ball, @battle.battlers[idxBattler])
loop do
throwAnim.update
pbUpdate
@@ -403,17 +403,17 @@ class Battle::Scene
#=============================================================================
# Returns the animation ID to use for a given move/user. Returns nil if that
# move has no animations defined for it.
def pbFindMoveAnimDetails(move2anim,moveID,idxUser,hitNum = 0)
def pbFindMoveAnimDetails(move2anim, moveID, idxUser, hitNum = 0)
real_move_id = GameData::Move.get(moveID).id
noFlip = false
if (idxUser&1)==0 # On player's side
if (idxUser & 1) == 0 # On player's side
anim = move2anim[0][real_move_id]
else # On opposing side
anim = move2anim[1][real_move_id]
noFlip = true if anim
anim = move2anim[0][real_move_id] if !anim
end
return [anim+hitNum,noFlip] if anim
return [anim + hitNum, noFlip] if anim
return nil
end
@@ -483,8 +483,8 @@ class Battle::Scene
# Plays a move/common animation
#=============================================================================
# Plays a move animation.
def pbAnimation(moveID,user,targets,hitNum = 0)
animID = pbFindMoveAnimation(moveID,user.index,hitNum)
def pbAnimation(moveID, user, targets, hitNum = 0)
animID = pbFindMoveAnimation(moveID, user.index, hitNum)
return if !animID
anim = animID[0]
target = (targets && targets.is_a?(Array)) ? targets[0] : targets
@@ -492,27 +492,27 @@ class Battle::Scene
return if !animations
pbSaveShadows {
if animID[1] # On opposing side and using OppMove animation
pbAnimationCore(animations[anim],target,user,true)
pbAnimationCore(animations[anim], target, user, true)
else # On player's side, and/or using Move animation
pbAnimationCore(animations[anim],user,target)
pbAnimationCore(animations[anim], user, target)
end
}
end
# Plays a common animation.
def pbCommonAnimation(animName,user = nil,target = nil)
def pbCommonAnimation(animName, user = nil, target = nil)
return if nil_or_empty?(animName)
target = target[0] if target && target.is_a?(Array)
animations = pbLoadBattleAnimations
return if !animations
animations.each do |a|
next if !a || a.name!="Common:"+animName
pbAnimationCore(a,user,(target!=nil) ? target : user)
next if !a || a.name != "Common:" + animName
pbAnimationCore(a, user, (target != nil) ? target : user)
return
end
end
def pbAnimationCore(animation,user,target,oppMove = false)
def pbAnimationCore(animation, user, target, oppMove = false)
return if !animation
@briefMessage = false
userSprite = (user) ? @sprites["pokemon_#{user.index}"] : nil
@@ -523,7 +523,7 @@ class Battle::Scene
oldTargetX = (targetSprite) ? targetSprite.x : oldUserX
oldTargetY = (targetSprite) ? targetSprite.y : oldUserY
# Create the animation player
animPlayer = PBAnimationPlayerX.new(animation,user,target,self,oppMove)
animPlayer = PBAnimationPlayerX.new(animation, user, target, self, oppMove)
# Apply a transformation to the animation based on where the user and target
# actually are. Get the centres of each sprite.
userHeight = (userSprite && userSprite.bitmap && !userSprite.bitmap.disposed?) ? userSprite.bitmap.height : 128

View File

@@ -20,7 +20,7 @@ class Battle::Scene::MenuBase
@y = 0
@z = 0
@visible = false
@color = Color.new(0,0,0,0)
@color = Color.new(0, 0, 0, 0)
@index = 0
@mode = 0
@disposed = false
@@ -61,27 +61,27 @@ class Battle::Scene::MenuBase
oldValue = @index
@index = value
@cmdWindow.index = @index if @cmdWindow
refresh if @index!=oldValue
refresh if @index != oldValue
end
def mode=(value)
oldValue = @mode
@mode = value
refresh if @mode!=oldValue
refresh if @mode != oldValue
end
def addSprite(key,sprite)
def addSprite(key, sprite)
@sprites[key] = sprite
@visibility[key] = true
end
def setIndexAndMode(index,mode)
def setIndexAndMode(index, mode)
oldIndex = @index
oldMode = @mode
@index = index
@mode = mode
@cmdWindow.index = @index if @cmdWindow
refresh if @index!=oldIndex || @mode!=oldMode
refresh if @index != oldIndex || @mode != oldMode
end
def refresh; end
@@ -106,52 +106,52 @@ class Battle::Scene::CommandMenu < Battle::Scene::MenuBase
USE_GRAPHICS = true
# Lists of which button graphics to use in different situations/types of battle.
MODES = [
[0,2,1,3], # 0 = Regular battle
[0,2,1,9], # 1 = Regular battle with "Cancel" instead of "Run"
[0,2,1,4], # 2 = Regular battle with "Call" instead of "Run"
[5,7,6,3], # 3 = Safari Zone
[0,8,1,3] # 4 = Bug Catching Contest
[0, 2, 1, 3], # 0 = Regular battle
[0, 2, 1, 9], # 1 = Regular battle with "Cancel" instead of "Run"
[0, 2, 1, 4], # 2 = Regular battle with "Call" instead of "Run"
[5, 7, 6, 3], # 3 = Safari Zone
[0, 8, 1, 3] # 4 = Bug Catching Contest
]
def initialize(viewport,z)
def initialize(viewport, z)
super(viewport)
self.x = 0
self.y = Graphics.height-96
self.y = Graphics.height - 96
# Create message box (shows "What will X do?")
@msgBox = Window_UnformattedTextPokemon.newWithSize("",
self.x+16,self.y+2,220,Graphics.height-self.y,viewport)
self.x + 16, self.y + 2, 220, Graphics.height - self.y, viewport)
@msgBox.baseColor = TEXT_BASE_COLOR
@msgBox.shadowColor = TEXT_SHADOW_COLOR
@msgBox.windowskin = nil
addSprite("msgBox",@msgBox)
addSprite("msgBox", @msgBox)
if USE_GRAPHICS
# Create background graphic
background = IconSprite.new(self.x,self.y,viewport)
background = IconSprite.new(self.x, self.y, viewport)
background.setBitmap("Graphics/Pictures/Battle/overlay_command")
addSprite("background",background)
addSprite("background", background)
# Create bitmaps
@buttonBitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/cursor_command"))
# Create action buttons
@buttons = Array.new(4) do |i| # 4 command options, therefore 4 buttons
button = SpriteWrapper.new(viewport)
button.bitmap = @buttonBitmap.bitmap
button.x = self.x+Graphics.width-260
button.x += (((i%2)==0) ? 0 : @buttonBitmap.width/2-4)
button.y = self.y+6
button.y += (((i/2)==0) ? 0 : BUTTON_HEIGHT-4)
button.src_rect.width = @buttonBitmap.width/2
button.x = self.x + Graphics.width - 260
button.x += (i.even? ? 0 : @buttonBitmap.width / 2 - 4)
button.y = self.y + 6
button.y += (((i / 2) == 0) ? 0 : BUTTON_HEIGHT - 4)
button.src_rect.width = @buttonBitmap.width / 2
button.src_rect.height = BUTTON_HEIGHT
addSprite("button_#{i}",button)
addSprite("button_#{i}", button)
next button
end
else
# Create command window (shows Fight/Bag/Pokémon/Run)
@cmdWindow = Window_CommandPokemon.newWithSize([],
self.x+Graphics.width-240,self.y,240,Graphics.height-self.y,viewport)
self.x + Graphics.width - 240, self.y, 240, Graphics.height - self.y, viewport)
@cmdWindow.columns = 2
@cmdWindow.columnSpacing = 4
@cmdWindow.ignore_input = true
addSprite("cmdWindow",@cmdWindow)
addSprite("cmdWindow", @cmdWindow)
end
self.z = z
refresh
@@ -173,7 +173,7 @@ class Battle::Scene::CommandMenu < Battle::Scene::MenuBase
return if USE_GRAPHICS
commands = []
for i in 1..4
commands.push(value[i]) if value[i] && value[i]!=nil
commands.push(value[i]) if value[i] && value[i] != nil
end
@cmdWindow.commands = commands
end
@@ -182,9 +182,9 @@ class Battle::Scene::CommandMenu < Battle::Scene::MenuBase
return if !USE_GRAPHICS
for i in 0...@buttons.length
button = @buttons[i]
button.src_rect.x = (i==@index) ? @buttonBitmap.width/2 : 0
button.src_rect.y = MODES[@mode][i]*BUTTON_HEIGHT
button.z = self.z + ((i==@index) ? 3 : 2)
button.src_rect.x = (i == @index) ? @buttonBitmap.width / 2 : 0
button.src_rect.y = MODES[@mode][i] * BUTTON_HEIGHT
button.z = self.z + ((i == @index) ? 3 : 2)
end
end
@@ -216,16 +216,16 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase
TYPE_ICON_HEIGHT = 28
# Text colours of PP of selected move
PP_COLORS = [
Color.new(248,72,72),Color.new(136,48,48), # Red, zero PP
Color.new(248,136,32),Color.new(144,72,24), # Orange, 1/4 of total PP or less
Color.new(248,192,0),Color.new(144,104,0), # Yellow, 1/2 of total PP or less
TEXT_BASE_COLOR,TEXT_SHADOW_COLOR # Black, more than 1/2 of total PP
Color.new(248, 72, 72), Color.new(136, 48, 48), # Red, zero PP
Color.new(248, 136, 32), Color.new(144, 72, 24), # Orange, 1/4 of total PP or less
Color.new(248, 192, 0), Color.new(144, 104, 0), # Yellow, 1/2 of total PP or less
TEXT_BASE_COLOR, TEXT_SHADOW_COLOR # Black, more than 1/2 of total PP
]
def initialize(viewport,z)
def initialize(viewport, z)
super(viewport)
self.x = 0
self.y = Graphics.height-96
self.y = Graphics.height - 96
@battler = nil
@shiftMode = 0
# NOTE: @mode is for the display of the Mega Evolution button.
@@ -237,70 +237,70 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase
@megaEvoBitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/cursor_mega"))
@shiftBitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/cursor_shift"))
# Create background graphic
background = IconSprite.new(0,Graphics.height-96,viewport)
background = IconSprite.new(0, Graphics.height - 96, viewport)
background.setBitmap("Graphics/Pictures/Battle/overlay_fight")
addSprite("background",background)
addSprite("background", background)
# Create move buttons
@buttons = Array.new(Pokemon::MAX_MOVES) do |i|
button = SpriteWrapper.new(viewport)
button.bitmap = @buttonBitmap.bitmap
button.x = self.x+4
button.x += (((i%2)==0) ? 0 : @buttonBitmap.width/2-4)
button.y = self.y+6
button.y += (((i/2)==0) ? 0 : BUTTON_HEIGHT-4)
button.src_rect.width = @buttonBitmap.width/2
button.x = self.x + 4
button.x += (i.even? ? 0 : @buttonBitmap.width / 2 - 4)
button.y = self.y + 6
button.y += (((i / 2) == 0) ? 0 : BUTTON_HEIGHT - 4)
button.src_rect.width = @buttonBitmap.width / 2
button.src_rect.height = BUTTON_HEIGHT
addSprite("button_#{i}",button)
addSprite("button_#{i}", button)
next button
end
# Create overlay for buttons (shows move names)
@overlay = BitmapSprite.new(Graphics.width,Graphics.height-self.y,viewport)
@overlay = BitmapSprite.new(Graphics.width, Graphics.height - self.y, viewport)
@overlay.x = self.x
@overlay.y = self.y
pbSetNarrowFont(@overlay.bitmap)
addSprite("overlay",@overlay)
addSprite("overlay", @overlay)
# Create overlay for selected move's info (shows move's PP)
@infoOverlay = BitmapSprite.new(Graphics.width,Graphics.height-self.y,viewport)
@infoOverlay = BitmapSprite.new(Graphics.width, Graphics.height - self.y, viewport)
@infoOverlay.x = self.x
@infoOverlay.y = self.y
pbSetNarrowFont(@infoOverlay.bitmap)
addSprite("infoOverlay",@infoOverlay)
addSprite("infoOverlay", @infoOverlay)
# Create type icon
@typeIcon = SpriteWrapper.new(viewport)
@typeIcon.bitmap = @typeBitmap.bitmap
@typeIcon.x = self.x+416
@typeIcon.y = self.y+20
@typeIcon.x = self.x + 416
@typeIcon.y = self.y + 20
@typeIcon.src_rect.height = TYPE_ICON_HEIGHT
addSprite("typeIcon",@typeIcon)
addSprite("typeIcon", @typeIcon)
# Create Mega Evolution button
@megaButton = SpriteWrapper.new(viewport)
@megaButton.bitmap = @megaEvoBitmap.bitmap
@megaButton.x = self.x+120
@megaButton.y = self.y-@megaEvoBitmap.height/2
@megaButton.src_rect.height = @megaEvoBitmap.height/2
addSprite("megaButton",@megaButton)
@megaButton.x = self.x + 120
@megaButton.y = self.y - @megaEvoBitmap.height / 2
@megaButton.src_rect.height = @megaEvoBitmap.height / 2
addSprite("megaButton", @megaButton)
# Create Shift button
@shiftButton = SpriteWrapper.new(viewport)
@shiftButton.bitmap = @shiftBitmap.bitmap
@shiftButton.x = self.x+4
@shiftButton.y = self.y-@shiftBitmap.height
addSprite("shiftButton",@shiftButton)
@shiftButton.x = self.x + 4
@shiftButton.y = self.y - @shiftBitmap.height
addSprite("shiftButton", @shiftButton)
else
# Create message box (shows type and PP of selected move)
@msgBox = Window_AdvancedTextPokemon.newWithSize("",
self.x+320,self.y,Graphics.width-320,Graphics.height-self.y,viewport)
self.x + 320, self.y, Graphics.width - 320, Graphics.height - self.y, viewport)
@msgBox.baseColor = TEXT_BASE_COLOR
@msgBox.shadowColor = TEXT_SHADOW_COLOR
pbSetNarrowFont(@msgBox.contents)
addSprite("msgBox",@msgBox)
addSprite("msgBox", @msgBox)
# Create command window (shows moves)
@cmdWindow = Window_CommandPokemon.newWithSize([],
self.x,self.y,320,Graphics.height-self.y,viewport)
self.x, self.y, 320, Graphics.height - self.y, viewport)
@cmdWindow.columns = 2
@cmdWindow.columnSpacing = 4
@cmdWindow.ignore_input = true
pbSetNarrowFont(@cmdWindow.contents)
addSprite("cmdWindow",@cmdWindow)
addSprite("cmdWindow", @cmdWindow)
end
self.z = z
end
@@ -331,7 +331,7 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase
def shiftMode=(value)
oldValue = @shiftMode
@shiftMode = value
refreshShiftButton if @shiftMode!=oldValue
refreshShiftButton if @shiftMode != oldValue
end
def refreshButtonNames
@@ -348,10 +348,10 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase
# Draw move names onto overlay
@overlay.bitmap.clear
textPos = []
@buttons.each_with_index do |button,i|
@buttons.each_with_index do |button, i|
next if !@visibility["button_#{i}"]
x = button.x-self.x+button.src_rect.width/2
y = button.y-self.y+2
x = button.x - self.x + button.src_rect.width / 2
y = button.y - self.y + 2
moveNameBase = TEXT_BASE_COLOR
if GET_MOVE_TEXT_COLOR_FROM_MOVE_BUTTON && moves[i].display_type(@battler)
# NOTE: This takes a color from a particular pixel in the button
@@ -359,26 +359,26 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase
# The pixel is at coordinates 10,34 in the button box. If you
# change the graphic, you may want to change the below line of
# code to ensure the font is an appropriate color.
moveNameBase = button.bitmap.get_pixel(10,button.src_rect.y+34)
moveNameBase = button.bitmap.get_pixel(10, button.src_rect.y + 34)
end
textPos.push([moves[i].name,x,y,2,moveNameBase,TEXT_SHADOW_COLOR])
textPos.push([moves[i].name, x, y, 2, moveNameBase, TEXT_SHADOW_COLOR])
end
pbDrawTextPositions(@overlay.bitmap,textPos)
pbDrawTextPositions(@overlay.bitmap, textPos)
end
def refreshSelection
moves = (@battler) ? @battler.moves : []
if USE_GRAPHICS
# Choose appropriate button graphics and z positions
@buttons.each_with_index do |button,i|
@buttons.each_with_index do |button, i|
if !moves[i]
@visibility["button_#{i}"] = false
next
end
@visibility["button_#{i}"] = true
button.src_rect.x = (i==@index) ? @buttonBitmap.width/2 : 0
button.src_rect.x = (i == @index) ? @buttonBitmap.width / 2 : 0
button.src_rect.y = GameData::Type.get(moves[i].display_type(@battler)).icon_position * BUTTON_HEIGHT
button.z = self.z + ((i==@index) ? 4 : 3)
button.z = self.z + ((i == @index) ? 4 : 3)
end
end
refreshMoveData(moves[@index])
@@ -388,11 +388,11 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase
# Write PP and type of the selected move
if !USE_GRAPHICS
moveType = GameData::Type.get(move.display_type(@battler)).name
if move.total_pp<=0
@msgBox.text = _INTL("PP: ---<br>TYPE/{1}",moveType)
if move.total_pp <= 0
@msgBox.text = _INTL("PP: ---<br>TYPE/{1}", moveType)
else
@msgBox.text = _ISPRINTF("PP: {1: 2d}/{2: 2d}<br>TYPE/{3:s}",
move.pp,move.total_pp,moveType)
move.pp, move.total_pp, moveType)
end
return
end
@@ -406,12 +406,12 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase
type_number = GameData::Type.get(move.display_type(@battler)).icon_position
@typeIcon.src_rect.y = type_number * TYPE_ICON_HEIGHT
# PP text
if move.total_pp>0
ppFraction = [(4.0*move.pp/move.total_pp).ceil,3].min
if move.total_pp > 0
ppFraction = [(4.0 * move.pp / move.total_pp).ceil, 3].min
textPos = []
textPos.push([_INTL("PP: {1}/{2}",move.pp,move.total_pp),
448,44,2,PP_COLORS[ppFraction*2],PP_COLORS[ppFraction*2+1]])
pbDrawTextPositions(@infoOverlay.bitmap,textPos)
textPos.push([_INTL("PP: {1}/{2}", move.pp, move.total_pp),
448, 44, 2, PP_COLORS[ppFraction * 2], PP_COLORS[ppFraction * 2 + 1]])
pbDrawTextPositions(@infoOverlay.bitmap, textPos)
end
end
@@ -450,57 +450,57 @@ class Battle::Scene::TargetMenu < Battle::Scene::MenuBase
# Lists of which button graphics to use in different situations/types of battle.
MODES = [
[0,2,1,3], # 0 = Regular battle
[0,2,1,9], # 1 = Regular battle with "Cancel" instead of "Run"
[0,2,1,4], # 2 = Regular battle with "Call" instead of "Run"
[5,7,6,3], # 3 = Safari Zone
[0,8,1,3] # 4 = Bug Catching Contest
[0, 2, 1, 3], # 0 = Regular battle
[0, 2, 1, 9], # 1 = Regular battle with "Cancel" instead of "Run"
[0, 2, 1, 4], # 2 = Regular battle with "Call" instead of "Run"
[5, 7, 6, 3], # 3 = Safari Zone
[0, 8, 1, 3] # 4 = Bug Catching Contest
]
CMD_BUTTON_WIDTH_SMALL = 170
TEXT_BASE_COLOR = Color.new(240,248,224)
TEXT_SHADOW_COLOR = Color.new(64,64,64)
TEXT_BASE_COLOR = Color.new(240, 248, 224)
TEXT_SHADOW_COLOR = Color.new(64, 64, 64)
def initialize(viewport,z,sideSizes)
def initialize(viewport, z, sideSizes)
super(viewport)
@sideSizes = sideSizes
maxIndex = (@sideSizes[0]>@sideSizes[1]) ? (@sideSizes[0]-1)*2 : @sideSizes[1]*2-1
@smallButtons = (@sideSizes.max>2)
maxIndex = (@sideSizes[0] > @sideSizes[1]) ? (@sideSizes[0] - 1) * 2 : @sideSizes[1] * 2 - 1
@smallButtons = (@sideSizes.max > 2)
self.x = 0
self.y = Graphics.height-96
self.y = Graphics.height - 96
@texts = []
# NOTE: @mode is for which buttons are shown as selected.
# 0=select 1 button (@index), 1=select all buttons with text
# Create bitmaps
@buttonBitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/cursor_target"))
# Create target buttons
@buttons = Array.new(maxIndex+1) do |i|
numButtons = @sideSizes[i%2]
next if numButtons<=i/2
@buttons = Array.new(maxIndex + 1) do |i|
numButtons = @sideSizes[i % 2]
next if numButtons <= i / 2
# NOTE: Battler indexes go from left to right from the perspective of
# that side's trainer, so inc is different for each side for the
# same value of i/2.
inc = ((i%2)==0) ? i/2 : numButtons-1-i/2
inc = ((i % 2) == 0) ? i / 2 : numButtons - 1 - i / 2
button = SpriteWrapper.new(viewport)
button.bitmap = @buttonBitmap.bitmap
button.src_rect.width = (@smallButtons) ? CMD_BUTTON_WIDTH_SMALL : @buttonBitmap.width/2
button.src_rect.width = (@smallButtons) ? CMD_BUTTON_WIDTH_SMALL : @buttonBitmap.width / 2
button.src_rect.height = BUTTON_HEIGHT
if @smallButtons
button.x = self.x+170-[0,82,166][numButtons-1]
button.x = self.x + 170 - [0, 82, 166][numButtons - 1]
else
button.x = self.x+138-[0,116][numButtons-1]
button.x = self.x + 138 - [0, 116][numButtons - 1]
end
button.x += (button.src_rect.width-4)*inc
button.y = self.y+6
button.y += (BUTTON_HEIGHT-4)*((i+1)%2)
addSprite("button_#{i}",button)
button.x += (button.src_rect.width - 4) * inc
button.y = self.y + 6
button.y += (BUTTON_HEIGHT - 4) * ((i + 1) % 2)
addSprite("button_#{i}", button)
next button
end
# Create overlay (shows target names)
@overlay = BitmapSprite.new(Graphics.width,Graphics.height-self.y,viewport)
@overlay = BitmapSprite.new(Graphics.width, Graphics.height - self.y, viewport)
@overlay.x = self.x
@overlay.y = self.y
pbSetNarrowFont(@overlay.bitmap)
addSprite("overlay",@overlay)
addSprite("overlay", @overlay)
self.z = z
refresh
end
@@ -515,7 +515,7 @@ class Battle::Scene::TargetMenu < Battle::Scene::MenuBase
@overlay.z += 5 if @overlay
end
def setDetails(texts,mode)
def setDetails(texts, mode)
@texts = texts
@mode = mode
refresh
@@ -523,30 +523,30 @@ class Battle::Scene::TargetMenu < Battle::Scene::MenuBase
def refreshButtons
# Choose appropriate button graphics and z positions
@buttons.each_with_index do |button,i|
@buttons.each_with_index do |button, i|
next if !button
sel = false
buttonType = 0
if @texts[i]
sel ||= (@mode==0 && i==@index)
sel ||= (@mode==1)
buttonType = ((i%2)==0) ? 1 : 2
sel ||= (@mode == 0 && i == @index)
sel ||= (@mode == 1)
buttonType = ((i % 2) == 0) ? 1 : 2
end
buttonType = 2*buttonType + ((@smallButtons) ? 1 : 0)
button.src_rect.x = (sel) ? @buttonBitmap.width/2 : 0
button.src_rect.y = buttonType*BUTTON_HEIGHT
buttonType = 2 * buttonType + ((@smallButtons) ? 1 : 0)
button.src_rect.x = (sel) ? @buttonBitmap.width / 2 : 0
button.src_rect.y = buttonType * BUTTON_HEIGHT
button.z = self.z + ((sel) ? 3 : 2)
end
# Draw target names onto overlay
@overlay.bitmap.clear
textpos = []
@buttons.each_with_index do |button,i|
@buttons.each_with_index do |button, i|
next if !button || nil_or_empty?(@texts[i])
x = button.x-self.x+button.src_rect.width/2
y = button.y-self.y+2
textpos.push([@texts[i],x,y,2,TEXT_BASE_COLOR,TEXT_SHADOW_COLOR])
x = button.x - self.x + button.src_rect.width / 2
y = button.y - self.y + 2
textpos.push([@texts[i], x, y, 2, TEXT_BASE_COLOR, TEXT_SHADOW_COLOR])
end
pbDrawTextPositions(@overlay.bitmap,textpos)
pbDrawTextPositions(@overlay.bitmap, textpos)
end
def refresh

View File

@@ -12,14 +12,14 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
# Maximum time in seconds to make a change to the HP bar.
HP_BAR_CHANGE_TIME = 1.0
STATUS_ICON_HEIGHT = 16
NAME_BASE_COLOR = Color.new(72,72,72)
NAME_SHADOW_COLOR = Color.new(184,184,184)
MALE_BASE_COLOR = Color.new(48,96,216)
NAME_BASE_COLOR = Color.new(72, 72, 72)
NAME_SHADOW_COLOR = Color.new(184, 184, 184)
MALE_BASE_COLOR = Color.new(48, 96, 216)
MALE_SHADOW_COLOR = NAME_SHADOW_COLOR
FEMALE_BASE_COLOR = Color.new(248,88,40)
FEMALE_BASE_COLOR = Color.new(248, 88, 40)
FEMALE_SHADOW_COLOR = NAME_SHADOW_COLOR
def initialize(battler,sideSize,viewport = nil)
def initialize(battler, sideSize, viewport = nil)
super(viewport)
@battler = battler
@sprites = {}
@@ -39,18 +39,18 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
end
def initializeDataBoxGraphic(sideSize)
onPlayerSide = ((@battler.index%2)==0)
onPlayerSide = ((@battler.index % 2) == 0)
# Get the data box graphic and set whether the HP numbers/Exp bar are shown
if sideSize==1 # One Pokémon on side, use the regular dara box BG
if sideSize == 1 # One Pokémon on side, use the regular dara box BG
bgFilename = ["Graphics/Pictures/Battle/databox_normal",
"Graphics/Pictures/Battle/databox_normal_foe"][@battler.index%2]
"Graphics/Pictures/Battle/databox_normal_foe"][@battler.index % 2]
if onPlayerSide
@showHP = true
@showExp = true
end
else # Multiple Pokémon on side, use the thin dara box BG
bgFilename = ["Graphics/Pictures/Battle/databox_thin",
"Graphics/Pictures/Battle/databox_thin_foe"][@battler.index%2]
"Graphics/Pictures/Battle/databox_thin_foe"][@battler.index % 2]
end
@databoxBitmap.dispose if @databoxBitmap
@databoxBitmap = AnimatedBitmap.new(bgFilename)
@@ -80,23 +80,23 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
@hpBarBitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/overlay_hp"))
@expBarBitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/overlay_exp"))
# Create sprite to draw HP numbers on
@hpNumbers = BitmapSprite.new(124,16,viewport)
@hpNumbers = BitmapSprite.new(124, 16, viewport)
pbSetSmallFont(@hpNumbers.bitmap)
@sprites["hpNumbers"] = @hpNumbers
# Create sprite wrapper that displays HP bar
@hpBar = SpriteWrapper.new(viewport)
@hpBar.bitmap = @hpBarBitmap.bitmap
@hpBar.src_rect.height = @hpBarBitmap.height/3
@hpBar.src_rect.height = @hpBarBitmap.height / 3
@sprites["hpBar"] = @hpBar
# Create sprite wrapper that displays Exp bar
@expBar = SpriteWrapper.new(viewport)
@expBar.bitmap = @expBarBitmap.bitmap
@sprites["expBar"] = @expBar
# Create sprite wrapper that displays everything except the above
@contents = BitmapWrapper.new(@databoxBitmap.width,@databoxBitmap.height)
@contents = BitmapWrapper.new(@databoxBitmap.width, @databoxBitmap.height)
self.bitmap = @contents
self.visible = false
self.z = 150+((@battler.index)/2)*5
self.z = 150 + ((@battler.index) / 2) * 5
pbSetSystemFont(self.bitmap)
end
@@ -112,23 +112,23 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
def x=(value)
super
@hpBar.x = value+@spriteBaseX+102
@expBar.x = value+@spriteBaseX+6
@hpNumbers.x = value+@spriteBaseX+80
@hpBar.x = value + @spriteBaseX + 102
@expBar.x = value + @spriteBaseX + 6
@hpNumbers.x = value + @spriteBaseX + 80
end
def y=(value)
super
@hpBar.y = value+40
@expBar.y = value+74
@hpNumbers.y = value+52
@hpBar.y = value + 40
@expBar.y = value + 74
@hpNumbers.y = value + 52
end
def z=(value)
super
@hpBar.z = value+1
@expBar.z = value+1
@hpNumbers.z = value+2
@hpBar.z = value + 1
@expBar.z = value + 1
@hpNumbers.z = value + 2
end
def opacity=(value)
@@ -164,43 +164,43 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
def exp_fraction
return 0.0 if @rangeExp == 0
return (@animatingExp) ? @currentExp.to_f/@rangeExp : @battler.pokemon.exp_fraction
return (@animatingExp) ? @currentExp.to_f / @rangeExp : @battler.pokemon.exp_fraction
end
def animateHP(oldHP,newHP,rangeHP)
def animateHP(oldHP, newHP, rangeHP)
@currentHP = oldHP
@endHP = newHP
@rangeHP = rangeHP
# NOTE: A change in HP takes the same amount of time to animate, no matter
# how big a change it is.
@hpIncPerFrame = (newHP-oldHP).abs/(HP_BAR_CHANGE_TIME*Graphics.frame_rate)
@hpIncPerFrame = (newHP - oldHP).abs / (HP_BAR_CHANGE_TIME * Graphics.frame_rate)
# minInc is the smallest amount that HP is allowed to change per frame.
# This avoids a tiny change in HP still taking HP_BAR_CHANGE_TIME seconds.
minInc = (rangeHP*4)/(@hpBarBitmap.width*HP_BAR_CHANGE_TIME*Graphics.frame_rate)
@hpIncPerFrame = minInc if @hpIncPerFrame<minInc
minInc = (rangeHP * 4) / (@hpBarBitmap.width * HP_BAR_CHANGE_TIME * Graphics.frame_rate)
@hpIncPerFrame = minInc if @hpIncPerFrame < minInc
@animatingHP = true
end
def animateExp(oldExp,newExp,rangeExp)
def animateExp(oldExp, newExp, rangeExp)
return if rangeExp == 0
@currentExp = oldExp
@endExp = newExp
@rangeExp = rangeExp
# NOTE: Filling the Exp bar from empty to full takes EXP_BAR_FILL_TIME
# seconds no matter what. Filling half of it takes half as long, etc.
@expIncPerFrame = rangeExp/(EXP_BAR_FILL_TIME*Graphics.frame_rate)
@expIncPerFrame = rangeExp / (EXP_BAR_FILL_TIME * Graphics.frame_rate)
@animatingExp = true
pbSEPlay("Pkmn exp gain") if @showExp
end
def pbDrawNumber(number,btmp,startX,startY,align = 0)
def pbDrawNumber(number, btmp, startX, startY, align = 0)
# -1 means draw the / character
n = (number == -1) ? [10] : number.to_i.digits.reverse
charWidth = @numbersBitmap.width/11
charWidth = @numbersBitmap.width / 11
charHeight = @numbersBitmap.height
startX -= charWidth*n.length if align==1
startX -= charWidth * n.length if align == 1
n.each do |i|
btmp.blt(startX,startY,@numbersBitmap.bitmap,Rect.new(i*charWidth,0,charWidth,charHeight))
btmp.blt(startX, startY, @numbersBitmap.bitmap, Rect.new(i * charWidth, 0, charWidth, charHeight))
startX += charWidth
end
end
@@ -211,42 +211,42 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
textPos = []
imagePos = []
# Draw background panel
self.bitmap.blt(0,0,@databoxBitmap.bitmap,Rect.new(0,0,@databoxBitmap.width,@databoxBitmap.height))
self.bitmap.blt(0, 0, @databoxBitmap.bitmap, Rect.new(0, 0, @databoxBitmap.width, @databoxBitmap.height))
# Draw Pokémon's name
nameWidth = self.bitmap.text_size(@battler.name).width
nameOffset = 0
nameOffset = nameWidth-116 if nameWidth>116
textPos.push([@battler.name,@spriteBaseX+8-nameOffset,0,false,NAME_BASE_COLOR,NAME_SHADOW_COLOR])
nameOffset = nameWidth - 116 if nameWidth > 116
textPos.push([@battler.name, @spriteBaseX + 8 - nameOffset, 0, false, NAME_BASE_COLOR, NAME_SHADOW_COLOR])
# Draw Pokémon's gender symbol
case @battler.displayGender
when 0 # Male
textPos.push([_INTL(""),@spriteBaseX+126,0,false,MALE_BASE_COLOR,MALE_SHADOW_COLOR])
textPos.push([_INTL(""), @spriteBaseX + 126, 0, false, MALE_BASE_COLOR, MALE_SHADOW_COLOR])
when 1 # Female
textPos.push([_INTL(""),@spriteBaseX+126,0,false,FEMALE_BASE_COLOR,FEMALE_SHADOW_COLOR])
textPos.push([_INTL(""), @spriteBaseX + 126, 0, false, FEMALE_BASE_COLOR, FEMALE_SHADOW_COLOR])
end
pbDrawTextPositions(self.bitmap,textPos)
pbDrawTextPositions(self.bitmap, textPos)
# Draw Pokémon's level
imagePos.push(["Graphics/Pictures/Battle/overlay_lv",@spriteBaseX+140,16])
pbDrawNumber(@battler.level,self.bitmap,@spriteBaseX+162,16)
imagePos.push(["Graphics/Pictures/Battle/overlay_lv", @spriteBaseX + 140, 16])
pbDrawNumber(@battler.level, self.bitmap, @spriteBaseX + 162, 16)
# Draw shiny icon
if @battler.shiny?
shinyX = (@battler.opposes?(0)) ? 206 : -6 # Foe's/player's
imagePos.push(["Graphics/Pictures/shiny",@spriteBaseX+shinyX,36])
imagePos.push(["Graphics/Pictures/shiny", @spriteBaseX + shinyX, 36])
end
# Draw Mega Evolution/Primal Reversion icon
if @battler.mega?
imagePos.push(["Graphics/Pictures/Battle/icon_mega",@spriteBaseX+8,34])
imagePos.push(["Graphics/Pictures/Battle/icon_mega", @spriteBaseX + 8, 34])
elsif @battler.primal?
primalX = (@battler.opposes?) ? 208 : -28 # Foe's/player's
if @battler.isSpecies?(:KYOGRE)
imagePos.push(["Graphics/Pictures/Battle/icon_primal_Kyogre",@spriteBaseX+primalX,4])
imagePos.push(["Graphics/Pictures/Battle/icon_primal_Kyogre", @spriteBaseX + primalX, 4])
elsif @battler.isSpecies?(:GROUDON)
imagePos.push(["Graphics/Pictures/Battle/icon_primal_Groudon",@spriteBaseX+primalX,4])
imagePos.push(["Graphics/Pictures/Battle/icon_primal_Groudon", @spriteBaseX + primalX, 4])
end
end
# Draw owned icon (foe Pokémon only)
if @battler.owned? && @battler.opposes?(0)
imagePos.push(["Graphics/Pictures/Battle/icon_own",@spriteBaseX+8,36])
imagePos.push(["Graphics/Pictures/Battle/icon_own", @spriteBaseX + 8, 36])
end
# Draw status icon
if @battler.status != :NONE
@@ -255,10 +255,10 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
else
s = GameData::Status.get(@battler.status).icon_position
end
imagePos.push(["Graphics/Pictures/Battle/icon_statuses",@spriteBaseX+24,36,
imagePos.push(["Graphics/Pictures/Battle/icon_statuses", @spriteBaseX + 24, 36,
0, s * STATUS_ICON_HEIGHT, -1, STATUS_ICON_HEIGHT]) if s >= 0
end
pbDrawImagePositions(self.bitmap,imagePos)
pbDrawImagePositions(self.bitmap, imagePos)
refreshHP
refreshExp
end
@@ -268,24 +268,24 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
return if !@battler.pokemon
# Show HP numbers
if @showHP
pbDrawNumber(self.hp,@hpNumbers.bitmap,54,2,1)
pbDrawNumber(-1,@hpNumbers.bitmap,54,2) # / char
pbDrawNumber(@battler.totalhp,@hpNumbers.bitmap,70,2)
pbDrawNumber(self.hp, @hpNumbers.bitmap, 54, 2, 1)
pbDrawNumber(-1, @hpNumbers.bitmap, 54, 2) # / char
pbDrawNumber(@battler.totalhp, @hpNumbers.bitmap, 70, 2)
end
# Resize HP bar
w = 0
if self.hp>0
w = @hpBarBitmap.width.to_f*self.hp/@battler.totalhp
w = 1 if w<1
if self.hp > 0
w = @hpBarBitmap.width.to_f * self.hp / @battler.totalhp
w = 1 if w < 1
# NOTE: The line below snaps the bar's width to the nearest 2 pixels, to
# fit in with the rest of the graphics which are doubled in size.
w = ((w/2.0).round)*2
w = ((w / 2.0).round) * 2
end
@hpBar.src_rect.width = w
hpColor = 0 # Green bar
hpColor = 1 if self.hp<=@battler.totalhp/2 # Yellow bar
hpColor = 2 if self.hp<=@battler.totalhp/4 # Red bar
@hpBar.src_rect.y = hpColor*@hpBarBitmap.height/3
hpColor = 1 if self.hp <= @battler.totalhp / 2 # Yellow bar
hpColor = 2 if self.hp <= @battler.totalhp / 4 # Red bar
@hpBar.src_rect.y = hpColor * @hpBarBitmap.height / 3
end
def refreshExp
@@ -293,22 +293,22 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
w = exp_fraction * @expBarBitmap.width
# NOTE: The line below snaps the bar's width to the nearest 2 pixels, to
# fit in with the rest of the graphics which are doubled in size.
w = ((w/2).round)*2
w = ((w / 2).round) * 2
@expBar.src_rect.width = w
end
def updateHPAnimation
return if !@animatingHP
if @currentHP<@endHP # Gaining HP
if @currentHP < @endHP # Gaining HP
@currentHP += @hpIncPerFrame
@currentHP = @endHP if @currentHP>=@endHP
elsif @currentHP>@endHP # Losing HP
@currentHP = @endHP if @currentHP >= @endHP
elsif @currentHP > @endHP # Losing HP
@currentHP -= @hpIncPerFrame
@currentHP = @endHP if @currentHP<=@endHP
@currentHP = @endHP if @currentHP <= @endHP
end
# Refresh the HP bar/numbers
refreshHP
@animatingHP = false if @currentHP==@endHP
@animatingHP = false if @currentHP == @endHP
end
def updateExpAnimation
@@ -318,29 +318,29 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
@animatingExp = false
return
end
if @currentExp<@endExp # Gaining Exp
if @currentExp < @endExp # Gaining Exp
@currentExp += @expIncPerFrame
@currentExp = @endExp if @currentExp>=@endExp
elsif @currentExp>@endExp # Losing Exp
@currentExp = @endExp if @currentExp >= @endExp
elsif @currentExp > @endExp # Losing Exp
@currentExp -= @expIncPerFrame
@currentExp = @endExp if @currentExp<=@endExp
@currentExp = @endExp if @currentExp <= @endExp
end
# Refresh the Exp bar
refreshExp
return if @currentExp!=@endExp # Exp bar still has more to animate
return if @currentExp != @endExp # Exp bar still has more to animate
# Exp bar is completely filled, level up with a flash and sound effect
if @currentExp>=@rangeExp
if @expFlash==0
if @currentExp >= @rangeExp
if @expFlash == 0
pbSEStop
@expFlash = Graphics.frame_rate/5
@expFlash = Graphics.frame_rate / 5
pbSEPlay("Pkmn exp full")
self.flash(Color.new(64,200,248,192),@expFlash)
self.flash(Color.new(64, 200, 248, 192), @expFlash)
for i in @sprites
i[1].flash(Color.new(64,200,248,192),@expFlash) if !i[1].disposed?
i[1].flash(Color.new(64, 200, 248, 192), @expFlash) if !i[1].disposed?
end
else
@expFlash -= 1
@animatingExp = false if @expFlash==0
@animatingExp = false if @expFlash == 0
end
else
pbSEStop
@@ -349,16 +349,16 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
end
end
QUARTER_ANIM_PERIOD = Graphics.frame_rate*3/20
QUARTER_ANIM_PERIOD = Graphics.frame_rate * 3 / 20
def updatePositions(frameCounter)
self.x = @spriteX
self.y = @spriteY
# Data box bobbing while Pokémon is selected
if @selected==1 || @selected==2 # Choosing commands/targeted or damaged
case (frameCounter/QUARTER_ANIM_PERIOD).floor
when 1 then self.y = @spriteY-2
when 3 then self.y = @spriteY+2
if @selected == 1 || @selected == 2 # Choosing commands/targeted or damaged
case (frameCounter / QUARTER_ANIM_PERIOD).floor
when 1 then self.y = @spriteY - 2
when 3 then self.y = @spriteY + 2
end
end
end
@@ -383,10 +383,10 @@ end
class Battle::Scene::AbilitySplashBar < SpriteWrapper
attr_reader :battler
TEXT_BASE_COLOR = Color.new(0,0,0)
TEXT_SHADOW_COLOR = Color.new(248,248,248)
TEXT_BASE_COLOR = Color.new(0, 0, 0)
TEXT_SHADOW_COLOR = Color.new(248, 248, 248)
def initialize(side,viewport = nil)
def initialize(side, viewport = nil)
super(viewport)
@side = side
@battler = nil
@@ -394,15 +394,15 @@ class Battle::Scene::AbilitySplashBar < SpriteWrapper
@bgBitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/ability_bar"))
@bgSprite = SpriteWrapper.new(viewport)
@bgSprite.bitmap = @bgBitmap.bitmap
@bgSprite.src_rect.y = (side==0) ? 0 : @bgBitmap.height/2
@bgSprite.src_rect.height = @bgBitmap.height/2
@bgSprite.src_rect.y = (side == 0) ? 0 : @bgBitmap.height / 2
@bgSprite.src_rect.height = @bgBitmap.height / 2
# Create bitmap that displays the text
@contents = BitmapWrapper.new(@bgBitmap.width,@bgBitmap.height/2)
@contents = BitmapWrapper.new(@bgBitmap.width, @bgBitmap.height / 2)
self.bitmap = @contents
pbSetSystemFont(self.bitmap)
# Position the bar
self.x = (side==0) ? -Graphics.width/2 : Graphics.width
self.y = (side==0) ? 180 : 80
self.x = (side == 0) ? -Graphics.width / 2 : Graphics.width
self.y = (side == 0) ? 180 : 80
self.z = 120
self.visible = false
end
@@ -426,7 +426,7 @@ class Battle::Scene::AbilitySplashBar < SpriteWrapper
def z=(value)
super
@bgSprite.z = value-1
@bgSprite.z = value - 1
end
def opacity=(value)
@@ -453,14 +453,14 @@ class Battle::Scene::AbilitySplashBar < SpriteWrapper
self.bitmap.clear
return if !@battler
textPos = []
textX = (@side==0) ? 10 : self.bitmap.width-8
textX = (@side == 0) ? 10 : self.bitmap.width - 8
# Draw Pokémon's name
textPos.push([_INTL("{1}'s",@battler.name),textX,-4,@side==1,
TEXT_BASE_COLOR,TEXT_SHADOW_COLOR,true])
textPos.push([_INTL("{1}'s", @battler.name), textX, -4, @side == 1,
TEXT_BASE_COLOR, TEXT_SHADOW_COLOR, true])
# Draw Pokémon's ability
textPos.push([@battler.abilityName,textX,26,@side==1,
TEXT_BASE_COLOR,TEXT_SHADOW_COLOR,true])
pbDrawTextPositions(self.bitmap,textPos)
textPos.push([@battler.abilityName, textX, 26, @side == 1,
TEXT_BASE_COLOR, TEXT_SHADOW_COLOR, true])
pbDrawTextPositions(self.bitmap, textPos)
end
def update
@@ -480,7 +480,7 @@ class Battle::Scene::BattlerSprite < RPG::Sprite
attr_accessor :selected
attr_reader :sideSize
def initialize(viewport,sideSize,index,battleAnimations)
def initialize(viewport, sideSize, index, battleAnimations)
super(viewport)
@pkmn = nil
@sideSize = sideSize
@@ -511,12 +511,12 @@ class Battle::Scene::BattlerSprite < RPG::Sprite
def x=(value)
@spriteX = value
super(value+@spriteXExtra)
super(value + @spriteXExtra)
end
def y=(value)
@spriteY = value
super(value+@spriteYExtra)
super(value + @spriteYExtra)
end
def width; return (self.bitmap) ? self.bitmap.width : 0; end
@@ -530,27 +530,27 @@ class Battle::Scene::BattlerSprite < RPG::Sprite
# Set sprite's origin to bottom middle
def pbSetOrigin
return if !@_iconBitmap
self.ox = @_iconBitmap.width/2
self.ox = @_iconBitmap.width / 2
self.oy = @_iconBitmap.height
end
def pbSetPosition
return if !@_iconBitmap
pbSetOrigin
if (@index%2)==0
self.z = 50+5*@index/2
if (@index % 2) == 0
self.z = 50 + 5 * @index / 2
else
self.z = 50-5*(@index+1)/2
self.z = 50 - 5 * (@index + 1) / 2
end
# Set original position
p = Battle::Scene.pbBattlerPosition(@index,@sideSize)
p = Battle::Scene.pbBattlerPosition(@index, @sideSize)
@spriteX = p[0]
@spriteY = p[1]
# Apply metrics
@pkmn.species_data.apply_metrics_to_sprite(self, @index)
end
def setPokemonBitmap(pkmn,back = false)
def setPokemonBitmap(pkmn, back = false)
@pkmn = pkmn
@_iconBitmap.dispose if @_iconBitmap
@_iconBitmap = GameData::Species.sprite_bitmap_from_pokemon(@pkmn, back)
@@ -566,8 +566,8 @@ class Battle::Scene::BattlerSprite < RPG::Sprite
@pkmn.play_cry if @pkmn
end
QUARTER_ANIM_PERIOD = Graphics.frame_rate*3/20
SIXTH_ANIM_PERIOD = Graphics.frame_rate*2/20
QUARTER_ANIM_PERIOD = Graphics.frame_rate * 3 / 20
SIXTH_ANIM_PERIOD = Graphics.frame_rate * 2 / 20
def update(frameCounter = 0)
return if !@_iconBitmap
@@ -577,8 +577,8 @@ class Battle::Scene::BattlerSprite < RPG::Sprite
self.bitmap = @_iconBitmap.bitmap
# Pokémon sprite bobbing while Pokémon is selected
@spriteYExtra = 0
if @selected==1 # When choosing commands for this Pokémon
case (frameCounter/QUARTER_ANIM_PERIOD).floor
if @selected == 1 # When choosing commands for this Pokémon
case (frameCounter / QUARTER_ANIM_PERIOD).floor
when 1 then @spriteYExtra = 2
when 3 then @spriteYExtra = -2
end
@@ -587,8 +587,8 @@ class Battle::Scene::BattlerSprite < RPG::Sprite
self.y = self.y
self.visible = @spriteVisible
# Pokémon sprite blinking when targeted
if @selected==2 && @spriteVisible
case (frameCounter/SIXTH_ANIM_PERIOD).floor
if @selected == 2 && @spriteVisible
case (frameCounter / SIXTH_ANIM_PERIOD).floor
when 2, 5 then self.visible = false
else self.visible = true
end
@@ -607,7 +607,7 @@ class Battle::Scene::BattlerShadowSprite < RPG::Sprite
attr_accessor :index
attr_accessor :selected
def initialize(viewport,sideSize,index)
def initialize(viewport, sideSize, index)
super(viewport)
@pkmn = nil
@sideSize = sideSize
@@ -629,8 +629,8 @@ class Battle::Scene::BattlerShadowSprite < RPG::Sprite
# Set sprite's origin to centre
def pbSetOrigin
return if !@_iconBitmap
self.ox = @_iconBitmap.width/2
self.oy = @_iconBitmap.height/2
self.ox = @_iconBitmap.width / 2
self.oy = @_iconBitmap.height / 2
end
def pbSetPosition
@@ -638,7 +638,7 @@ class Battle::Scene::BattlerShadowSprite < RPG::Sprite
pbSetOrigin
self.z = 3
# Set original position
p = Battle::Scene.pbBattlerPosition(@index,@sideSize)
p = Battle::Scene.pbBattlerPosition(@index, @sideSize)
self.x = p[0]
self.y = p[1]
# Apply metrics

View File

@@ -1,5 +1,5 @@
class Battle::Scene::Animation
def initialize(sprites,viewport)
def initialize(sprites, viewport)
@sprites = sprites
@viewport = viewport
@pictureEx = [] # For all the PictureEx
@@ -14,10 +14,10 @@ class Battle::Scene::Animation
end
def createProcesses; end
def empty?; return @pictureEx.length==0; end
def empty?; return @pictureEx.length == 0; end
def animDone?; return @animDone; end
def addSprite(s,origin = PictureOrigin::TopLeft)
def addSprite(s, origin = PictureOrigin::TopLeft)
num = @pictureEx.length
picture = PictureEx.new(s.z)
picture.x = s.x
@@ -25,20 +25,20 @@ class Battle::Scene::Animation
picture.visible = s.visible
picture.color = s.color.clone
picture.tone = s.tone.clone
picture.setOrigin(0,origin)
picture.setOrigin(0, origin)
@pictureEx[num] = picture
@pictureSprites[num] = s
return picture
end
def addNewSprite(x,y,name,origin = PictureOrigin::TopLeft)
def addNewSprite(x, y, name, origin = PictureOrigin::TopLeft)
num = @pictureEx.length
picture = PictureEx.new(num)
picture.setXY(0,x,y)
picture.setName(0,name)
picture.setOrigin(0,origin)
picture.setXY(0, x, y)
picture.setName(0, name)
picture.setOrigin(0, origin)
@pictureEx[num] = picture
s = IconSprite.new(x,y,@viewport)
s = IconSprite.new(x, y, @viewport)
s.setBitmap(name)
@pictureSprites[num] = s
@tempSprites.push(s)
@@ -49,11 +49,11 @@ class Battle::Scene::Animation
return if @animDone
@tempSprites.each { |s| s.update if s }
finished = true
@pictureEx.each_with_index do |p,i|
@pictureEx.each_with_index do |p, i|
next if !p.running?
finished = false
p.update
setPictureIconSprite(@pictureSprites[i],p)
setPictureIconSprite(@pictureSprites[i], p)
end
@animDone = true if finished
end
@@ -96,110 +96,110 @@ module Battle::Scene::Animation::BallAnimationMixin
return ball
end
def ballTracksHand(ball,traSprite,safariThrow = false)
def ballTracksHand(ball, traSprite, safariThrow = false)
# Back sprite isn't animated, no hand-tracking needed
if traSprite.bitmap.width<traSprite.bitmap.height*2
ball.setVisible(7,true)
if traSprite.bitmap.width < traSprite.bitmap.height * 2
ball.setVisible(7, true)
ballStartX = traSprite.x
ballStartX -= ball.totalDuration*(Graphics.width/(2*16)) if !safariThrow
ballStartY = traSprite.y-traSprite.bitmap.height/2
ballStartX -= ball.totalDuration * (Graphics.width / (2 * 16)) if !safariThrow
ballStartY = traSprite.y - traSprite.bitmap.height / 2
return ballStartX, ballStartY
end
# Back sprite is animated, make the Poké Ball track the trainer's hand
coordSets = [[traSprite.x-44,traSprite.y-32],[-10,-36],[118,-4]]
coordSets = [[traSprite.x - 44, traSprite.y - 32], [-10, -36], [118, -4]]
case @trainer.trainer_type
when :POKEMONTRAINER_Leaf
coordSets = [[traSprite.x-30,traSprite.y-30],[-18,-36],[118,-6]]
coordSets = [[traSprite.x - 30, traSprite.y - 30], [-18, -36], [118, -6]]
when :POKEMONTRAINER_Brendan
coordSets = [[traSprite.x-46,traSprite.y-40],[-4,-30],[118,-2]]
coordSets = [[traSprite.x - 46, traSprite.y - 40], [-4, -30], [118, -2]]
when :POKEMONTRAINER_May
coordSets = [[traSprite.x-44,traSprite.y-38],[-8,-30],[122,0]]
coordSets = [[traSprite.x - 44, traSprite.y - 38], [-8, -30], [122, 0]]
end
# Arm stretched out behind player
ball.setVisible(0,true)
ball.setXY(0,coordSets[0][0],coordSets[0][1])
ball.moveDelta(0,5,-5*(Graphics.width/(2*16)),0) if !safariThrow
ball.setDelta(0,-12,0) if safariThrow
ball.setVisible(0, true)
ball.setXY(0, coordSets[0][0], coordSets[0][1])
ball.moveDelta(0, 5, -5 * (Graphics.width / (2 * 16)), 0) if !safariThrow
ball.setDelta(0, -12, 0) if safariThrow
# Arm mid throw
ball.setDelta(5,coordSets[1][0],coordSets[1][1])
ball.moveDelta(5,2,-2*(Graphics.width/(2*16)),0) if !safariThrow
ball.setDelta(5,34,0) if safariThrow
ball.setDelta(5, coordSets[1][0], coordSets[1][1])
ball.moveDelta(5, 2, -2 * (Graphics.width / (2 * 16)), 0) if !safariThrow
ball.setDelta(5, 34, 0) if safariThrow
# Start of throw
ball.setDelta(7,coordSets[2][0],coordSets[2][1])
ball.setDelta(7,-14,0) if safariThrow
ball.setDelta(7, coordSets[2][0], coordSets[2][1])
ball.setDelta(7, -14, 0) if safariThrow
# Update Poké Ball trajectory's start position
ballStartX = ballStartY = 0
coordSets.each do |c|
ballStartX += c[0]
ballStartY += c[1]
end
ballStartX -= ball.totalDuration*(Graphics.width/(2*16)) if !safariThrow
ballStartX -= ball.totalDuration * (Graphics.width / (2 * 16)) if !safariThrow
ballStartX += 8 if safariThrow # -12 + 34 - 14
return ballStartX, ballStartY
end
def trainerThrowingFrames(ball,trainer,traSprite)
ball.setZ(0,traSprite.z-1)
def trainerThrowingFrames(ball, trainer, traSprite)
ball.setZ(0, traSprite.z - 1)
# Change trainer's frames
size = traSprite.src_rect.width # Width per frame
trainer.setSrc(0,size,0)
trainer.setSrc(5,size*2,0)
trainer.setSrc(7,size*3,0)
trainer.setSrc(9,size*4,0)
trainer.setSrc(18,0,0)
trainer.setSrc(0, size, 0)
trainer.setSrc(5, size * 2, 0)
trainer.setSrc(7, size * 3, 0)
trainer.setSrc(9, size * 4, 0)
trainer.setSrc(18, 0, 0)
# Alter trainer's positioning
trainer.setDelta(0,-12,0)
trainer.setDelta(5,34,0)
trainer.setDelta(7,-14,0)
trainer.setDelta(9,28,0)
trainer.moveDelta(10,3,-6,6)
trainer.setDelta(18,-4,0)
trainer.setDelta(19,-26,-6)
trainer.setDelta(0, -12, 0)
trainer.setDelta(5, 34, 0)
trainer.setDelta(7, -14, 0)
trainer.setDelta(9, 28, 0)
trainer.moveDelta(10, 3, -6, 6)
trainer.setDelta(18, -4, 0)
trainer.setDelta(19, -26, -6)
# Make ball track the trainer's hand
ballStartX, ballStartY = ballTracksHand(ball,traSprite,true)
ballStartX, ballStartY = ballTracksHand(ball, traSprite, true)
return ballStartX, ballStartY
end
def createBallTrajectory(ball,delay,duration,startX,startY,midX,midY,endX,endY)
def createBallTrajectory(ball, delay, duration, startX, startY, midX, midY, endX, endY)
# NOTE: This trajectory is the same regardless of whether the player's
# sprite is being shown on-screen (and sliding off while animating a
# throw). Instead, that throw animation and initialDelay are designed
# to make sure the Ball's trajectory starts at the same position.
ball.setVisible(delay,true)
a = 2*startY - 4*midY + 2*endY
b = 4*midY - 3*startY - endY
ball.setVisible(delay, true)
a = 2 * startY - 4 * midY + 2 * endY
b = 4 * midY - 3 * startY - endY
c = startY
for i in 1..duration
t = i.to_f/duration # t ranges from 0 to 1
x = startX + (endX-startX)*t # Linear in t
y = a*t**2 + b*t + c # Quadratic in t
ball.moveXY(delay+i-1,1,x,y)
t = i.to_f / duration # t ranges from 0 to 1
x = startX + (endX - startX) * t # Linear in t
y = a * t**2 + b * t + c # Quadratic in t
ball.moveXY(delay + i - 1, 1, x, y)
end
createBallTumbling(ball,delay,duration)
createBallTumbling(ball, delay, duration)
end
def createBallTumbling(ball,delay,duration)
def createBallTumbling(ball, delay, duration)
# Animate ball frames
numTumbles = 1
numFrames = 1
if @ballSprite && @ballSprite.bitmap.width>=@ballSprite.bitmap.height
if @ballSprite && @ballSprite.bitmap.width >= @ballSprite.bitmap.height
# 2* because each frame is twice as tall as it is wide
numFrames = 2*@ballSprite.bitmap.width/@ballSprite.bitmap.height
numFrames = 2 * @ballSprite.bitmap.width / @ballSprite.bitmap.height
end
if numFrames>1
if numFrames > 1
curFrame = 0
for i in 1..duration
thisFrame = numFrames*numTumbles*i/duration
if thisFrame>curFrame
thisFrame = numFrames * numTumbles * i / duration
if thisFrame > curFrame
curFrame = thisFrame
ball.setSrc(delay+i-1,(curFrame%numFrames)*@ballSprite.bitmap.height/2,0)
ball.setSrc(delay + i - 1, (curFrame % numFrames) * @ballSprite.bitmap.height / 2, 0)
end
end
ball.setSrc(delay+duration,0,0)
ball.setSrc(delay + duration, 0, 0)
end
# Rotate ball
ball.moveAngle(delay,duration,360*3)
ball.setAngle(delay+duration,0)
ball.moveAngle(delay, duration, 360 * 3)
ball.setAngle(delay + duration, 0)
end
def ballSetOpen(ball, delay, poke_ball)
@@ -228,24 +228,24 @@ module Battle::Scene::Animation::BallAnimationMixin
ballSetOpen(ball, delay, poke_ball)
end
def battlerAppear(battler,delay,battlerX,battlerY,batSprite,color)
battler.setVisible(delay,true)
battler.setOpacity(delay,255)
battler.moveXY(delay,5,battlerX,battlerY)
battler.moveZoom(delay,5,100,[batSprite,:pbPlayIntroAnimation])
def battlerAppear(battler, delay, battlerX, battlerY, batSprite, color)
battler.setVisible(delay, true)
battler.setOpacity(delay, 255)
battler.moveXY(delay, 5, battlerX, battlerY)
battler.moveZoom(delay, 5, 100, [batSprite, :pbPlayIntroAnimation])
# NOTE: As soon as the battler sprite finishes zooming, and just as it
# starts changing its tone to normal, it plays its intro animation.
color.alpha = 0
battler.moveColor(delay+5,10,color)
battler.moveColor(delay + 5, 10, color)
end
def battlerAbsorb(battler,delay,battlerX,battlerY,color)
def battlerAbsorb(battler, delay, battlerX, battlerY, color)
color.alpha = 255
battler.moveColor(delay,10,color)
battler.moveColor(delay, 10, color)
delay = battler.totalDuration
battler.moveXY(delay,5,battlerX,battlerY)
battler.moveZoom(delay,5,0)
battler.setVisible(delay+5,false)
battler.moveXY(delay, 5, battlerX, battlerY)
battler.moveZoom(delay, 5, 0)
battler.setVisible(delay + 5, false)
end
# The regular Poké Ball burst animation.

View File

@@ -4,15 +4,15 @@
class Battle::DebugSceneNoLogging
def initialize
@battle = nil
@lastCmd = [0,0,0,0]
@lastMove = [0,0,0,0]
@lastCmd = [0, 0, 0, 0]
@lastMove = [0, 0, 0, 0]
end
# Called whenever the battle begins.
def pbStartBattle(battle)
@battle = battle
@lastCmd = [0,0,0,0]
@lastMove = [0,0,0,0]
@lastCmd = [0, 0, 0, 0]
@lastMove = [0, 0, 0, 0]
end
def pbBlitz(keys)
@@ -23,61 +23,61 @@ class Battle::DebugSceneNoLogging
def pbBeginCommandPhase; end
def pbBeginAttackPhase; end
def pbShowOpponent(idxTrainer); end
def pbDamageAnimation(battler,effectiveness = 0); end
def pbCommonAnimation(animName,user = nil,target = nil); end
def pbAnimation(moveID,user,targets,hitNum = 0); end
def pbDamageAnimation(battler, effectiveness = 0); end
def pbCommonAnimation(animName, user = nil, target = nil); end
def pbAnimation(moveID, user, targets, hitNum = 0); end
def pbEndBattle(result); end
def pbWildBattleSuccess; end
def pbTrainerBattleSuccess; end
def pbBattleArenaJudgment(b1,b2,r1,r2); end
def pbBattleArenaBattlers(b1,b2); end
def pbBattleArenaJudgment(b1, b2, r1, r2); end
def pbBattleArenaBattlers(b1, b2); end
def pbRefresh; end
def pbDisplayMessage(msg,brief = false); end
def pbDisplayMessage(msg, brief = false); end
def pbDisplayPausedMessage(msg); end
def pbDisplayConfirmMessage(msg); return true; end
def pbShowCommands(msg,commands,defaultValue); return 0; end
def pbShowCommands(msg, commands, defaultValue); return 0; end
def pbSendOutBattlers(sendOuts,startBattle = false); end
def pbSendOutBattlers(sendOuts, startBattle = false); end
def pbRecall(idxBattler); end
def pbItemMenu(idxBattler,firstAction); return -1; end
def pbItemMenu(idxBattler, firstAction); return -1; end
def pbResetMoveIndex(idxBattler); end
def pbHPChanged(battler,oldHP,showAnim = false); end
def pbHPChanged(battler, oldHP, showAnim = false); end
def pbFaintBattler(battler); end
def pbEXPBar(battler,startExp,endExp,tempExp1,tempExp2); end
def pbEXPBar(battler, startExp, endExp, tempExp1, tempExp2); end
def pbLevelUp(pkmn, battler, oldTotalHP, oldAttack, oldDefense,
oldSpAtk, oldSpDef, oldSpeed); end
def pbForgetMove(pkmn,moveToLearn); return 0; end # Always forget first move
def pbForgetMove(pkmn, moveToLearn); return 0; end # Always forget first move
def pbCommandMenu(idxBattler,firstAction)
return 1 if rand(15)==0 # Bag
return 4 if rand(10)==0 # Call
return 0 # Fight
def pbCommandMenu(idxBattler, firstAction)
return 1 if rand(15) == 0 # Bag
return 4 if rand(10) == 0 # Call
return 0 # Fight
end
def pbFightMenu(idxBattler,megaEvoPossible = false)
def pbFightMenu(idxBattler, megaEvoPossible = false)
battler = @battle.battlers[idxBattler]
50.times do
break if yield rand(battler.move.length)
end
end
def pbChooseTarget(idxBattler,target_data,visibleSprites = nil)
def pbChooseTarget(idxBattler, target_data, visibleSprites = nil)
targets = @battle.allOtherSideBattlers(idxBattler).map { |b| b.index }
return -1 if targets.length==0
return -1 if targets.length == 0
return targets.sample
end
def pbPartyScreen(idxBattler,canCancel = false)
def pbPartyScreen(idxBattler, canCancel = false)
replacements = []
@battle.eachInTeamFromBattlerIndex(idxBattler) do |_b,idxParty|
replacements.push(idxParty) if !@battle.pbFindBattler(idxParty,idxBattler)
@battle.eachInTeamFromBattlerIndex(idxBattler) do |_b, idxParty|
replacements.push(idxParty) if !@battle.pbFindBattler(idxParty, idxBattler)
end
return if replacements.length==0
return if replacements.length == 0
50.times do
break if yield replacements[rand(replacements.length)],self
break if yield replacements[rand(replacements.length)], self
end
end
end

View File

@@ -31,17 +31,17 @@ class Battle::AI
sum += c[1]
n += 1
end
return 0 if n<2
return 0 if n < 2
mean = sum.to_f / n
varianceTimesN = 0
choices.each do |c|
next if c[1]<=0
deviation = c[1].to_f-mean
varianceTimesN += deviation*deviation
next if c[1] <= 0
deviation = c[1].to_f - mean
varianceTimesN += deviation * deviation
end
# Using population standard deviation
# [(n-1) makes it a sample std dev, would be 0 with only 1 sample]
return Math.sqrt(varianceTimesN/n)
return Math.sqrt(varianceTimesN / n)
end
#=============================================================================

View File

@@ -12,7 +12,7 @@ class Battle::AI
idxTarget = @battle.battlers[idxTarget].pokemonIndex # Party Pokémon
end
# Register use of item
@battle.pbRegisterItem(idxBattler,item,idxTarget)
@battle.pbRegisterItem(idxBattler, item, idxTarget)
PBDebug.log("[AI] #{user.pbThis} (#{user.index}) will use item #{GameData::Item.get(item).name}")
return true
end
@@ -22,7 +22,7 @@ class Battle::AI
def pbEnemyItemToUse(idxBattler)
return nil if !@battle.internalBattle
items = @battle.pbGetOwnerItems(idxBattler)
return nil if !items || items.length==0
return nil if !items || items.length == 0
# Determine target of item (always the Pokémon choosing the action)
idxTarget = idxBattler # Battler using the item
battler = @battle.battlers[idxTarget]
@@ -40,7 +40,7 @@ class Battle::AI
:LEMONADE => (Settings::REBALANCED_HEALING_ITEM_AMOUNTS) ? 70 : 80,
:MOOMOOMILK => 100,
:ORANBERRY => 10,
:SITRUSBERRY => battler.totalhp/4,
:SITRUSBERRY => battler.totalhp / 4,
:ENERGYPOWDER => (Settings::REBALANCED_HEALING_ITEM_AMOUNTS) ? 60 : 50,
:ENERGYROOT => (Settings::REBALANCED_HEALING_ITEM_AMOUNTS) ? 120 : 200
}
@@ -103,9 +103,9 @@ class Battle::AI
usableXItems = []
items.each do |i|
next if !i
next if !@battle.pbCanUseItemOnPokemon?(i,pkmn,battler,@battle.scene,false)
next if !ItemHandlers.triggerCanUseInBattle(i,pkmn,battler,nil,
false,self,@battle.scene,false)
next if !@battle.pbCanUseItemOnPokemon?(i, pkmn, battler, @battle.scene, false)
next if !ItemHandlers.triggerCanUseInBattle(i, pkmn, battler, nil,
false, self, @battle.scene, false)
# Log HP healing items
if losthp > 0
power = hpItems[i]
@@ -140,28 +140,28 @@ class Battle::AI
end
end
# Prioritise using a HP restoration item
if usableHPItems.length>0 && (battler.hp<=battler.totalhp/4 ||
(battler.hp<=battler.totalhp/2 && pbAIRandom(100)<30))
usableHPItems.sort! { |a,b| (a[1]==b[1]) ? a[2]<=>b[2] : a[1]<=>b[1] }
if usableHPItems.length > 0 && (battler.hp <= battler.totalhp / 4 ||
(battler.hp <= battler.totalhp / 2 && pbAIRandom(100) < 30))
usableHPItems.sort! { |a, b| (a[1] == b[1]) ? a[2] <=> b[2] : a[1] <=> b[1] }
prevItem = nil
usableHPItems.each do |i|
return i[0], idxTarget if i[2]>=losthp
return i[0], idxTarget if i[2] >= losthp
prevItem = i
end
return prevItem[0], idxTarget
end
# Next prioritise using a status-curing item
if usableStatusItems.length>0 && pbAIRandom(100)<40
usableStatusItems.sort! { |a,b| a[1]<=>b[1] }
if usableStatusItems.length > 0 && pbAIRandom(100) < 40
usableStatusItems.sort! { |a, b| a[1] <=> b[1] }
return usableStatusItems[0][0], idxTarget
end
# Next try using an X item
if usableXItems.length>0 && pbAIRandom(100)<30
usableXItems.sort! { |a,b| (a[1]==b[1]) ? a[2]<=>b[2] : a[1]<=>b[1] }
if usableXItems.length > 0 && pbAIRandom(100) < 30
usableXItems.sort! { |a, b| (a[1] == b[1]) ? a[2] <=> b[2] : a[1] <=> b[1] }
prevItem = nil
usableXItems.each do |i|
break if prevItem && i[1]>prevItem[1]
return i[0], idxTarget if i[1]+i[2]>=6
break if prevItem && i[1] > prevItem[1]
return i[0], idxTarget if i[1] + i[2] >= 6
prevItem = i
end
return prevItem[0], idxTarget

View File

@@ -3,10 +3,10 @@ class Battle::AI
# Decide whether the opponent should switch Pokémon
#=============================================================================
def pbEnemyShouldWithdraw?(idxBattler)
return pbEnemyShouldWithdrawEx?(idxBattler,false)
return pbEnemyShouldWithdrawEx?(idxBattler, false)
end
def pbEnemyShouldWithdrawEx?(idxBattler,forceSwitch)
def pbEnemyShouldWithdrawEx?(idxBattler, forceSwitch)
return false if @battle.wildBattle?
shouldSwitch = forceSwitch
batonPass = -1
@@ -15,13 +15,13 @@ class Battle::AI
battler = @battle.battlers[idxBattler]
# If Pokémon is within 6 levels of the foe, and foe's last move was
# super-effective and powerful
if !shouldSwitch && battler.turnCount>0 && skill>=PBTrainerAI.highSkill
if !shouldSwitch && battler.turnCount > 0 && skill >= PBTrainerAI.highSkill
target = battler.pbDirectOpposing(true)
if !target.fainted? && target.lastMoveUsed &&
(target.level-battler.level).abs<=6
(target.level - battler.level).abs <= 6
moveData = GameData::Move.get(target.lastMoveUsed)
moveType = moveData.type
typeMod = pbCalcTypeMod(moveType,target,battler)
typeMod = pbCalcTypeMod(moveType, target, battler)
if Effectiveness.super_effective?(typeMod) && moveData.base_damage > 50
switchChance = (moveData.base_damage > 70) ? 30 : 20
shouldSwitch = (pbAIRandom(100) < switchChance)
@@ -30,14 +30,14 @@ class Battle::AI
end
# Pokémon can't do anything (must have been in battle for at least 5 rounds)
if !@battle.pbCanChooseAnyMove?(idxBattler) &&
battler.turnCount && battler.turnCount>=5
battler.turnCount && battler.turnCount >= 5
shouldSwitch = true
end
# Pokémon is Perish Songed and has Baton Pass
if skill>=PBTrainerAI.highSkill && battler.effects[PBEffects::PerishSong]==1
battler.eachMoveWithIndex do |m,i|
next if m.function!="SwitchOutUserPassOnEffects" # Baton Pass
next if !@battle.pbCanChooseMove?(idxBattler,i,false)
if skill >= PBTrainerAI.highSkill && battler.effects[PBEffects::PerishSong] == 1
battler.eachMoveWithIndex do |m, i|
next if m.function != "SwitchOutUserPassOnEffects" # Baton Pass
next if !@battle.pbCanChooseMove?(idxBattler, i, false)
batonPass = i
break
end
@@ -45,96 +45,96 @@ class Battle::AI
# Pokémon will faint because of bad poisoning at the end of this round, but
# would survive at least one more round if it were regular poisoning instead
if battler.status == :POISON && battler.statusCount > 0 &&
skill>=PBTrainerAI.highSkill
toxicHP = battler.totalhp/16
nextToxicHP = toxicHP*(battler.effects[PBEffects::Toxic]+1)
if battler.hp<=nextToxicHP && battler.hp>toxicHP*2
shouldSwitch = true if pbAIRandom(100)<80
skill >= PBTrainerAI.highSkill
toxicHP = battler.totalhp / 16
nextToxicHP = toxicHP * (battler.effects[PBEffects::Toxic] + 1)
if battler.hp <= nextToxicHP && battler.hp > toxicHP * 2
shouldSwitch = true if pbAIRandom(100) < 80
end
end
# Pokémon is Encored into an unfavourable move
if battler.effects[PBEffects::Encore]>0 && skill>=PBTrainerAI.mediumSkill
if battler.effects[PBEffects::Encore] > 0 && skill >= PBTrainerAI.mediumSkill
idxEncoredMove = battler.pbEncoredMoveIndex
if idxEncoredMove>=0
if idxEncoredMove >= 0
scoreSum = 0
scoreCount = 0
battler.allOpposing.each do |b|
scoreSum += pbGetMoveScore(battler.moves[idxEncoredMove],battler,b,skill)
scoreSum += pbGetMoveScore(battler.moves[idxEncoredMove], battler, b, skill)
scoreCount += 1
end
if scoreCount>0 && scoreSum/scoreCount<=20
shouldSwitch = true if pbAIRandom(100)<80
if scoreCount > 0 && scoreSum / scoreCount <= 20
shouldSwitch = true if pbAIRandom(100) < 80
end
end
end
# If there is a single foe and it is resting after Hyper Beam or is
# Truanting (i.e. free turn)
if @battle.pbSideSize(battler.index+1)==1 &&
!battler.pbDirectOpposing.fainted? && skill>=PBTrainerAI.highSkill
if @battle.pbSideSize(battler.index + 1) == 1 &&
!battler.pbDirectOpposing.fainted? && skill >= PBTrainerAI.highSkill
opp = battler.pbDirectOpposing
if opp.effects[PBEffects::HyperBeam]>0 ||
if opp.effects[PBEffects::HyperBeam] > 0 ||
(opp.hasActiveAbility?(:TRUANT) && opp.effects[PBEffects::Truant])
shouldSwitch = false if pbAIRandom(100)<80
shouldSwitch = false if pbAIRandom(100) < 80
end
end
# Sudden Death rule - I'm not sure what this means
if @battle.rules["suddendeath"] && battler.turnCount>0
if battler.hp<=battler.totalhp/4 && pbAIRandom(100)<30
if @battle.rules["suddendeath"] && battler.turnCount > 0
if battler.hp <= battler.totalhp / 4 && pbAIRandom(100) < 30
shouldSwitch = true
elsif battler.hp<=battler.totalhp/2 && pbAIRandom(100)<80
elsif battler.hp <= battler.totalhp / 2 && pbAIRandom(100) < 80
shouldSwitch = true
end
end
# Pokémon is about to faint because of Perish Song
if battler.effects[PBEffects::PerishSong]==1
if battler.effects[PBEffects::PerishSong] == 1
shouldSwitch = true
end
if shouldSwitch
list = []
idxPartyStart, idxPartyEnd = @battle.pbTeamIndexRangeFromBattlerIndex(idxBattler)
@battle.pbParty(idxBattler).each_with_index do |pkmn,i|
@battle.pbParty(idxBattler).each_with_index do |pkmn, i|
next if i == idxPartyEnd - 1 # Don't choose to switch in ace
next if !@battle.pbCanSwitch?(idxBattler,i)
next if !@battle.pbCanSwitch?(idxBattler, i)
# If perish count is 1, it may be worth it to switch
# even with Spikes, since Perish Song's effect will end
if battler.effects[PBEffects::PerishSong]!=1
if battler.effects[PBEffects::PerishSong] != 1
# Will contain effects that recommend against switching
spikes = battler.pbOwnSide.effects[PBEffects::Spikes]
# Don't switch to this if too little HP
if spikes>0
spikesDmg = [8,6,4][spikes-1]
if pkmn.hp<=pkmn.totalhp/spikesDmg
if spikes > 0
spikesDmg = [8, 6, 4][spikes - 1]
if pkmn.hp <= pkmn.totalhp / spikesDmg
next if !pkmn.hasType?(:FLYING) && !pkmn.hasActiveAbility?(:LEVITATE)
end
end
end
# moveType is the type of the target's last used move
if moveType && Effectiveness.ineffective?(pbCalcTypeMod(moveType,battler,battler))
if moveType && Effectiveness.ineffective?(pbCalcTypeMod(moveType, battler, battler))
weight = 65
typeMod = pbCalcTypeModPokemon(pkmn,battler.pbDirectOpposing(true))
typeMod = pbCalcTypeModPokemon(pkmn, battler.pbDirectOpposing(true))
if Effectiveness.super_effective?(typeMod)
# Greater weight if new Pokemon's type is effective against target
weight = 85
end
list.unshift(i) if pbAIRandom(100)<weight # Put this Pokemon first
elsif moveType && Effectiveness.resistant?(pbCalcTypeMod(moveType,battler,battler))
list.unshift(i) if pbAIRandom(100) < weight # Put this Pokemon first
elsif moveType && Effectiveness.resistant?(pbCalcTypeMod(moveType, battler, battler))
weight = 40
typeMod = pbCalcTypeModPokemon(pkmn,battler.pbDirectOpposing(true))
typeMod = pbCalcTypeModPokemon(pkmn, battler.pbDirectOpposing(true))
if Effectiveness.super_effective?(typeMod)
# Greater weight if new Pokemon's type is effective against target
weight = 60
end
list.unshift(i) if pbAIRandom(100)<weight # Put this Pokemon first
list.unshift(i) if pbAIRandom(100) < weight # Put this Pokemon first
else
list.push(i) # put this Pokemon last
end
end
if list.length>0
if batonPass>=0 && @battle.pbRegisterMove(idxBattler,batonPass,false)
if list.length > 0
if batonPass >= 0 && @battle.pbRegisterMove(idxBattler, batonPass, false)
PBDebug.log("[AI] #{battler.pbThis} (#{idxBattler}) will use Baton Pass to avoid Perish Song")
return true
end
if @battle.pbRegisterSwitch(idxBattler,list[0])
if @battle.pbRegisterSwitch(idxBattler, list[0])
PBDebug.log("[AI] #{battler.pbThis} (#{idxBattler}) will switch with " +
"#{@battle.pbParty(idxBattler)[list[0]].name}")
return true
@@ -147,19 +147,19 @@ class Battle::AI
#=============================================================================
# Choose a replacement Pokémon
#=============================================================================
def pbDefaultChooseNewEnemy(idxBattler,party)
def pbDefaultChooseNewEnemy(idxBattler, party)
enemies = []
idxPartyStart, idxPartyEnd = @battle.pbTeamIndexRangeFromBattlerIndex(idxBattler)
party.each_with_index do |_p,i|
party.each_with_index do |_p, i|
next if i == idxPartyEnd - 1 && enemies.length > 0 # Ignore ace if possible
enemies.push(i) if @battle.pbCanSwitchLax?(idxBattler,i)
enemies.push(i) if @battle.pbCanSwitchLax?(idxBattler, i)
end
return -1 if enemies.length==0
return pbChooseBestNewEnemy(idxBattler,party,enemies)
return -1 if enemies.length == 0
return pbChooseBestNewEnemy(idxBattler, party, enemies)
end
def pbChooseBestNewEnemy(idxBattler,party,enemies)
return -1 if !enemies || enemies.length==0
def pbChooseBestNewEnemy(idxBattler, party, enemies)
return -1 if !enemies || enemies.length == 0
best = -1
bestSum = 0
enemies.each do |i|
@@ -172,7 +172,7 @@ class Battle::AI
sum += Effectiveness.calculate(m.type, bTypes[0], bTypes[1], bTypes[2])
end
end
if best==-1 || sum>bestSum
if best == -1 || sum > bestSum
best = i
bestSum = sum
end

View File

@@ -14,12 +14,12 @@ class Battle::AI
# NOTE: A move is only added to the choices array if it has a non-zero
# score.
choices = []
user.eachMoveWithIndex do |_m,i|
next if !@battle.pbCanChooseMove?(idxBattler,i,false)
user.eachMoveWithIndex do |_m, i|
next if !@battle.pbCanChooseMove?(idxBattler, i, false)
if wildBattler
pbRegisterMoveWild(user,i,choices)
pbRegisterMoveWild(user, i, choices)
else
pbRegisterMoveTrainer(user,i,choices,skill)
pbRegisterMoveTrainer(user, i, choices, skill)
end
end
# Figure out useful information about the choices
@@ -27,54 +27,54 @@ class Battle::AI
maxScore = 0
choices.each do |c|
totalScore += c[1]
maxScore = c[1] if maxScore<c[1]
maxScore = c[1] if maxScore < c[1]
end
# Log the available choices
if $INTERNAL
logMsg = "[AI] Move choices for #{user.pbThis(true)} (#{user.index}): "
choices.each_with_index do |c,i|
choices.each_with_index do |c, i|
logMsg += "#{user.moves[c[0]].name}=#{c[1]}"
logMsg += " (target #{c[2]})" if c[2]>=0
logMsg += ", " if i<choices.length-1
logMsg += " (target #{c[2]})" if c[2] >= 0
logMsg += ", " if i < choices.length - 1
end
PBDebug.log(logMsg)
end
# Find any preferred moves and just choose from them
if !wildBattler && skill>=PBTrainerAI.highSkill && maxScore>100
if !wildBattler && skill >= PBTrainerAI.highSkill && maxScore > 100
stDev = pbStdDev(choices)
if stDev>=40 && pbAIRandom(100)<90
if stDev >= 40 && pbAIRandom(100) < 90
preferredMoves = []
choices.each do |c|
next if c[1]<200 && c[1]<maxScore*0.8
next if c[1] < 200 && c[1] < maxScore * 0.8
preferredMoves.push(c)
preferredMoves.push(c) if c[1]==maxScore # Doubly prefer the best move
preferredMoves.push(c) if c[1] == maxScore # Doubly prefer the best move
end
if preferredMoves.length>0
if preferredMoves.length > 0
m = preferredMoves[pbAIRandom(preferredMoves.length)]
PBDebug.log("[AI] #{user.pbThis} (#{user.index}) prefers #{user.moves[m[0]].name}")
@battle.pbRegisterMove(idxBattler,m[0],false)
@battle.pbRegisterTarget(idxBattler,m[2]) if m[2]>=0
@battle.pbRegisterMove(idxBattler, m[0], false)
@battle.pbRegisterTarget(idxBattler, m[2]) if m[2] >= 0
return
end
end
end
# Decide whether all choices are bad, and if so, try switching instead
if !wildBattler && skill>=PBTrainerAI.highSkill
if !wildBattler && skill >= PBTrainerAI.highSkill
badMoves = false
if (maxScore<=20 && user.turnCount>2) ||
(maxScore<=40 && user.turnCount>5)
badMoves = true if pbAIRandom(100)<80
if (maxScore <= 20 && user.turnCount > 2) ||
(maxScore <= 40 && user.turnCount > 5)
badMoves = true if pbAIRandom(100) < 80
end
if !badMoves && totalScore<100 && user.turnCount>1
if !badMoves && totalScore < 100 && user.turnCount > 1
badMoves = true
choices.each do |c|
next if !user.moves[c[0]].damagingMove?
badMoves = false
break
end
badMoves = false if badMoves && pbAIRandom(100)<10
badMoves = false if badMoves && pbAIRandom(100) < 10
end
if badMoves && pbEnemyShouldWithdrawEx?(idxBattler,true)
if badMoves && pbEnemyShouldWithdrawEx?(idxBattler, true)
if $INTERNAL
PBDebug.log("[AI] #{user.pbThis} (#{user.index}) will switch due to terrible moves")
end
@@ -82,13 +82,13 @@ class Battle::AI
end
end
# If there are no calculated choices, pick one at random
if choices.length==0
if choices.length == 0
PBDebug.log("[AI] #{user.pbThis} (#{user.index}) doesn't want to use any moves; picking one at random")
user.eachMoveWithIndex do |_m,i|
next if !@battle.pbCanChooseMove?(idxBattler,i,false)
choices.push([i,100,-1]) # Move index, score, target
user.eachMoveWithIndex do |_m, i|
next if !@battle.pbCanChooseMove?(idxBattler, i, false)
choices.push([i, 100, -1]) # Move index, score, target
end
if choices.length==0 # No moves are physically possible to use; use Struggle
if choices.length == 0 # No moves are physically possible to use; use Struggle
@battle.pbAutoChooseMove(user.index)
end
end
@@ -96,9 +96,9 @@ class Battle::AI
randNum = pbAIRandom(totalScore)
choices.each do |c|
randNum -= c[1]
next if randNum>=0
@battle.pbRegisterMove(idxBattler,c[0],false)
@battle.pbRegisterTarget(idxBattler,c[2]) if c[2]>=0
next if randNum >= 0
@battle.pbRegisterMove(idxBattler, c[0], false)
@battle.pbRegisterTarget(idxBattler, c[2]) if c[2] >= 0
break
end
# Log the result
@@ -111,40 +111,40 @@ class Battle::AI
# Get scores for the given move against each possible target
#=============================================================================
# Wild Pokémon choose their moves randomly.
def pbRegisterMoveWild(_user,idxMove,choices)
choices.push([idxMove,100,-1]) # Move index, score, target
def pbRegisterMoveWild(_user, idxMove, choices)
choices.push([idxMove, 100, -1]) # Move index, score, target
end
# Trainer Pokémon calculate how much they want to use each of their moves.
def pbRegisterMoveTrainer(user,idxMove,choices,skill)
def pbRegisterMoveTrainer(user, idxMove, choices, skill)
move = user.moves[idxMove]
target_data = move.pbTarget(user)
if target_data.num_targets > 1
# If move affects multiple battlers and you don't choose a particular one
totalScore = 0
@battle.allBattlers.each do |b|
next if !@battle.pbMoveCanTarget?(user.index,b.index,target_data)
score = pbGetMoveScore(move,user,b,skill)
next if !@battle.pbMoveCanTarget?(user.index, b.index, target_data)
score = pbGetMoveScore(move, user, b, skill)
totalScore += ((user.opposes?(b)) ? score : -score)
end
choices.push([idxMove,totalScore,-1]) if totalScore>0
choices.push([idxMove, totalScore, -1]) if totalScore > 0
elsif target_data.num_targets == 0
# If move has no targets, affects the user, a side or the whole field
score = pbGetMoveScore(move,user,user,skill)
choices.push([idxMove,score,-1]) if score>0
score = pbGetMoveScore(move, user, user, skill)
choices.push([idxMove, score, -1]) if score > 0
else
# If move affects one battler and you have to choose which one
scoresAndTargets = []
@battle.allBattlers.each do |b|
next if !@battle.pbMoveCanTarget?(user.index,b.index,target_data)
next if !@battle.pbMoveCanTarget?(user.index, b.index, target_data)
next if target_data.targets_foe && !user.opposes?(b)
score = pbGetMoveScore(move,user,b,skill)
scoresAndTargets.push([score,b.index]) if score>0
score = pbGetMoveScore(move, user, b, skill)
scoresAndTargets.push([score, b.index]) if score > 0
end
if scoresAndTargets.length>0
if scoresAndTargets.length > 0
# Get the one best target for the move
scoresAndTargets.sort! { |a,b| b[0]<=>a[0] }
choices.push([idxMove,scoresAndTargets[0][0],scoresAndTargets[0][1]])
scoresAndTargets.sort! { |a, b| b[0] <=> a[0] }
choices.push([idxMove, scoresAndTargets[0][0], scoresAndTargets[0][1]])
end
end
end
@@ -152,31 +152,31 @@ class Battle::AI
#=============================================================================
# Get a score for the given move being used against the given target
#=============================================================================
def pbGetMoveScore(move,user,target,skill = 100)
skill = PBTrainerAI.minimumSkill if skill<PBTrainerAI.minimumSkill
def pbGetMoveScore(move, user, target, skill = 100)
skill = PBTrainerAI.minimumSkill if skill < PBTrainerAI.minimumSkill
score = 100
score = pbGetMoveScoreFunctionCode(score,move,user,target,skill)
score = pbGetMoveScoreFunctionCode(score, move, user, target, skill)
# A score of 0 here means it absolutely should not be used
return 0 if score<=0
if skill>=PBTrainerAI.mediumSkill
return 0 if score <= 0
if skill >= PBTrainerAI.mediumSkill
# Prefer damaging moves if AI has no more Pokémon or AI is less clever
if @battle.pbAbleNonActiveCount(user.idxOwnSide)==0
if !(skill>=PBTrainerAI.highSkill && @battle.pbAbleNonActiveCount(target.idxOwnSide)>0)
if @battle.pbAbleNonActiveCount(user.idxOwnSide) == 0
if !(skill >= PBTrainerAI.highSkill && @battle.pbAbleNonActiveCount(target.idxOwnSide) > 0)
if move.statusMove?
score /= 1.5
elsif target.hp<=target.totalhp/2
elsif target.hp <= target.totalhp / 2
score *= 1.5
end
end
end
# Don't prefer attacking the target if they'd be semi-invulnerable
if skill>=PBTrainerAI.highSkill && move.accuracy>0 &&
(target.semiInvulnerable? || target.effects[PBEffects::SkyDrop]>=0)
if skill >= PBTrainerAI.highSkill && move.accuracy > 0 &&
(target.semiInvulnerable? || target.effects[PBEffects::SkyDrop] >= 0)
miss = true
miss = false if user.hasActiveAbility?(:NOGUARD) || target.hasActiveAbility?(:NOGUARD)
if miss && pbRoughStat(user,:SPEED,skill)>pbRoughStat(target,:SPEED,skill)
if miss && pbRoughStat(user, :SPEED, skill) > pbRoughStat(target, :SPEED, skill)
# Knows what can get past semi-invulnerability
if target.effects[PBEffects::SkyDrop]>=0
if target.effects[PBEffects::SkyDrop] >= 0
miss = false if move.hitsFlyingTargets?
else
if target.inTwoTurnAttack?("TwoTurnAttackInvulnerableInSky",
@@ -193,13 +193,13 @@ class Battle::AI
score -= 80 if miss
end
# Pick a good move for the Choice items
if user.hasActiveItem?([:CHOICEBAND,:CHOICESPECS,:CHOICESCARF]) ||
if user.hasActiveItem?([:CHOICEBAND, :CHOICESPECS, :CHOICESCARF]) ||
user.hasActiveAbility?(:GORILLATACTICS)
if move.baseDamage>=60
if move.baseDamage >= 60
score += 60
elsif move.damagingMove?
score += 30
elsif move.function=="UserTargetSwapItems"
elsif move.function == "UserTargetSwapItems"
score += 70 # Trick
else
score -= 60
@@ -236,17 +236,17 @@ class Battle::AI
end
# Adjust score based on how much damage it can deal
if move.damagingMove?
score = pbGetMoveScoreDamage(score,move,user,target,skill)
score = pbGetMoveScoreDamage(score, move, user, target, skill)
else # Status moves
# Don't prefer attacks which don't deal damage
score -= 10
# Account for accuracy of move
accuracy = pbRoughAccuracy(move,user,target,skill)
score *= accuracy/100.0
score = 0 if score<=10 && skill>=PBTrainerAI.highSkill
accuracy = pbRoughAccuracy(move, user, target, skill)
score *= accuracy / 100.0
score = 0 if score <= 10 && skill >= PBTrainerAI.highSkill
end
score = score.to_i
score = 0 if score<0
score = 0 if score < 0
return score
end
@@ -254,25 +254,25 @@ class Battle::AI
# Add to a move's score based on how much damage it will deal (as a percentage
# of the target's current HP)
#=============================================================================
def pbGetMoveScoreDamage(score,move,user,target,skill)
def pbGetMoveScoreDamage(score, move, user, target, skill)
# Don't prefer moves that are ineffective because of abilities or effects
return 0 if score<=0 || pbCheckMoveImmunity(score,move,user,target,skill)
return 0 if score <= 0 || pbCheckMoveImmunity(score, move, user, target, skill)
# Calculate how much damage the move will do (roughly)
baseDmg = pbMoveBaseDamage(move,user,target,skill)
realDamage = pbRoughDamage(move,user,target,skill,baseDmg)
baseDmg = pbMoveBaseDamage(move, user, target, skill)
realDamage = pbRoughDamage(move, user, target, skill, baseDmg)
# Account for accuracy of move
accuracy = pbRoughAccuracy(move,user,target,skill)
realDamage *= accuracy/100.0
accuracy = pbRoughAccuracy(move, user, target, skill)
realDamage *= accuracy / 100.0
# Two-turn attacks waste 2 turns to deal one lot of damage
if move.chargingTurnMove? || move.function=="AttackAndSkipNextTurn" # Hyper Beam
realDamage *= 2/3 # Not halved because semi-invulnerable during use or hits first turn
if move.chargingTurnMove? || move.function == "AttackAndSkipNextTurn" # Hyper Beam
realDamage *= 2 / 3 # Not halved because semi-invulnerable during use or hits first turn
end
# Prefer flinching external effects (note that move effects which cause
# flinching are dealt with in the function code part of score calculation)
if skill>=PBTrainerAI.mediumSkill && !move.flinchingMove?
if skill >= PBTrainerAI.mediumSkill && !move.flinchingMove?
if !target.hasActiveAbility?(:INNERFOCUS) &&
!target.hasActiveAbility?(:SHIELDDUST) &&
target.effects[PBEffects::Substitute]==0
target.effects[PBEffects::Substitute] == 0
canFlinch = false
if user.hasActiveItem?([:KINGSROCK, :RAZORFANG])
canFlinch = true
@@ -283,14 +283,14 @@ class Battle::AI
end
end
# Convert damage to percentage of target's remaining HP
damagePercentage = realDamage*100.0/target.hp
damagePercentage = realDamage * 100.0 / target.hp
# Don't prefer weak attacks
# damagePercentage /= 2 if damagePercentage<20
# Prefer damaging attack if level difference is significantly high
damagePercentage *= 1.2 if user.level-10>target.level
damagePercentage *= 1.2 if user.level - 10 > target.level
# Adjust score
damagePercentage = 120 if damagePercentage>120 # Treat all lethal moves the same
damagePercentage += 40 if damagePercentage>100 # Prefer moves likely to be lethal
damagePercentage = 120 if damagePercentage > 120 # Treat all lethal moves the same
damagePercentage += 40 if damagePercentage > 100 # Prefer moves likely to be lethal
score += damagePercentage.to_i
return score
end

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@ class Battle::AI
#=============================================================================
#
#=============================================================================
def pbTargetsMultiple?(move,user)
def pbTargetsMultiple?(move, user)
target_data = move.pbTarget(user)
return false if target_data.num_targets <= 1
num_targets = 0
@@ -26,8 +26,8 @@ class Battle::AI
#=============================================================================
# Move's type effectiveness
#=============================================================================
def pbCalcTypeModSingle(moveType,defType,user,target)
ret = Effectiveness.calculate_one(moveType,defType)
def pbCalcTypeModSingle(moveType, defType, user, target)
ret = Effectiveness.calculate_one(moveType, defType)
# Ring Target
if target.hasActiveItem?(:RINGTARGET)
ret = Effectiveness::NORMAL_EFFECTIVE_ONE if Effectiveness.ineffective_type?(moveType, defType)
@@ -54,7 +54,7 @@ class Battle::AI
return ret
end
def pbCalcTypeMod(moveType,user,target)
def pbCalcTypeMod(moveType, user, target)
return Effectiveness::NORMAL_EFFECTIVE if !moveType
return Effectiveness::NORMAL_EFFECTIVE if moveType == :GROUND &&
target.pbHasType?(:FLYING) &&
@@ -70,8 +70,8 @@ class Battle::AI
typeMods[0] = Effectiveness::SUPER_EFFECTIVE_ONE
end
else
tTypes.each_with_index do |type,i|
typeMods[i] = pbCalcTypeModSingle(moveType,type,user,target)
tTypes.each_with_index do |type, i|
typeMods[i] = pbCalcTypeModSingle(moveType, type, user, target)
end
end
# Multiply all effectivenesses together
@@ -82,41 +82,41 @@ class Battle::AI
# For switching. Determines the effectiveness of a potential switch-in against
# an opposing battler.
def pbCalcTypeModPokemon(battlerThis,_battlerOther)
def pbCalcTypeModPokemon(battlerThis, _battlerOther)
mod1 = Effectiveness.calculate(battlerThis.types[0], target.types[0], target.types[1])
mod2 = Effectiveness::NORMAL_EFFECTIVE
if battlerThis.types.length > 1
mod2 = Effectiveness.calculate(battlerThis.types[1], target.types[0], target.types[1])
mod2 = mod2.to_f / Effectivenesss::NORMAL_EFFECTIVE
end
return mod1*mod2
return mod1 * mod2
end
#=============================================================================
# Immunity to a move because of the target's ability, item or other effects
#=============================================================================
def pbCheckMoveImmunity(score,move,user,target,skill)
type = pbRoughType(move,user,skill)
typeMod = pbCalcTypeMod(type,user,target)
def pbCheckMoveImmunity(score, move, user, target, skill)
type = pbRoughType(move, user, skill)
typeMod = pbCalcTypeMod(type, user, target)
# Type effectiveness
return true if Effectiveness.ineffective?(typeMod) || score<=0
return true if Effectiveness.ineffective?(typeMod) || score <= 0
# Immunity due to ability/item/other effects
if skill>=PBTrainerAI.mediumSkill
if skill >= PBTrainerAI.mediumSkill
case type
when :GROUND
return true if target.airborne? && !move.hitsFlyingTargets?
when :FIRE
return true if target.hasActiveAbility?(:FLASHFIRE)
when :WATER
return true if target.hasActiveAbility?([:DRYSKIN,:STORMDRAIN,:WATERABSORB])
return true if target.hasActiveAbility?([:DRYSKIN, :STORMDRAIN, :WATERABSORB])
when :GRASS
return true if target.hasActiveAbility?(:SAPSIPPER)
when :ELECTRIC
return true if target.hasActiveAbility?([:LIGHTNINGROD,:MOTORDRIVE,:VOLTABSORB])
return true if target.hasActiveAbility?([:LIGHTNINGROD, :MOTORDRIVE, :VOLTABSORB])
end
return true if Effectiveness.not_very_effective?(typeMod) &&
target.hasActiveAbility?(:WONDERGUARD)
return true if move.damagingMove? && user.index!=target.index && !target.opposes?(user) &&
return true if move.damagingMove? && user.index != target.index && !target.opposes?(user) &&
target.hasActiveAbility?(:TELEPATHY)
return true if move.statusMove? && move.canMagicCoat? && target.hasActiveAbility?(:MAGICBOUNCE) &&
target.opposes?(user)
@@ -127,11 +127,11 @@ class Battle::AI
return true if target.hasActiveAbility?(:OVERCOAT)
return true if target.hasActiveItem?(:SAFETYGOGGLES)
end
return true if target.effects[PBEffects::Substitute]>0 && move.statusMove? &&
!move.ignoresSubstitute?(user) && user.index!=target.index
return true if target.effects[PBEffects::Substitute] > 0 && move.statusMove? &&
!move.ignoresSubstitute?(user) && user.index != target.index
return true if Settings::MECHANICS_GENERATION >= 7 && user.hasActiveAbility?(:PRANKSTER) &&
target.pbHasType?(:DARK) && target.opposes?(user)
return true if move.priority>0 && @battle.field.terrain == :Psychic &&
return true if move.priority > 0 && @battle.field.terrain == :Psychic &&
target.affectedByTerrain? && target.opposes?(user)
end
return false
@@ -140,19 +140,19 @@ class Battle::AI
#=============================================================================
# Get approximate properties for a battler
#=============================================================================
def pbRoughType(move,user,skill)
def pbRoughType(move, user, skill)
ret = move.type
if skill>=PBTrainerAI.highSkill
if skill >= PBTrainerAI.highSkill
ret = move.pbCalcType(user)
end
return ret
end
def pbRoughStat(battler,stat,skill)
return battler.pbSpeed if skill>=PBTrainerAI.highSkill && stat==:SPEED
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 = battler.stages[stat]+6
def pbRoughStat(battler, stat, skill)
return battler.pbSpeed if skill >= PBTrainerAI.highSkill && stat == :SPEED
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 = battler.stages[stat] + 6
value = 0
case stat
when :ATTACK then value = battler.attack
@@ -161,24 +161,24 @@ class Battle::AI
when :SPECIAL_DEFENSE then value = battler.spdef
when :SPEED then value = battler.speed
end
return (value.to_f*stageMul[stage]/stageDiv[stage]).floor
return (value.to_f * stageMul[stage] / stageDiv[stage]).floor
end
#=============================================================================
# Get a better move's base damage value
#=============================================================================
def pbMoveBaseDamage(move,user,target,skill)
def pbMoveBaseDamage(move, user, target, skill)
baseDmg = move.baseDamage
baseDmg = 60 if baseDmg==1
return baseDmg if skill<PBTrainerAI.mediumSkill
baseDmg = 60 if baseDmg == 1
return baseDmg if skill < PBTrainerAI.mediumSkill
# Covers all function codes which have their own def pbBaseDamage
case move.function
when "FlinchTargetTrampleMinimize" # Stomp
baseDmg *= 2 if skill>=PBTrainerAI.mediumSkill && target.effects[PBEffects::Minimize]
baseDmg *= 2 if skill >= PBTrainerAI.mediumSkill && target.effects[PBEffects::Minimize]
# Sonic Boom, Dragon Rage, Super Fang, Night Shade, Endeavor
when "FixedDamage20", "FixedDamage40", "FixedDamageHalfTargetHP",
"FixedDamageUserLevel", "LowerTargetHPToUserHP"
baseDmg = move.pbFixedDamage(user,target)
baseDmg = move.pbFixedDamage(user, target)
when "FixedDamageUserLevelRandom" # Psywave
baseDmg = user.level
when "OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"
@@ -187,7 +187,7 @@ class Battle::AI
baseDmg = 60
when "DoublePowerIfTargetUnderwater", "DoublePowerIfTargetUnderground",
"BindTargetDoublePowerIfTargetUnderwater"
baseDmg = move.pbModifyDamage(baseDmg,user,target)
baseDmg = move.pbModifyDamage(baseDmg, user, target)
# Gust, Twister, Venoshock, Smelling Salts, Wake-Up Slap, Facade, Hex, Brine,
# Retaliate, Weather Ball, Return, Frustration, Eruption, Crush Grip,
# Stored Power, Punishment, Hidden Power, Fury Cutter, Echoed Voice,
@@ -217,13 +217,13 @@ class Battle::AI
"PowerHigherWithTargetWeight",
"ThrowUserItemAtTarget",
"PowerDependsOnUserStockpile"
baseDmg = move.pbBaseDamage(baseDmg,user,target)
baseDmg = move.pbBaseDamage(baseDmg, user, target)
when "DoublePowerIfUserHasNoItem" # Acrobatics
baseDmg *= 2 if !user.item || user.hasActiveItem?(:FLYINGGEM)
when "PowerHigherWithTargetFasterThanUser" # Gyro Ball
targetSpeed = pbRoughStat(target,:SPEED,skill)
userSpeed = pbRoughStat(user,:SPEED,skill)
baseDmg = [[(25*targetSpeed/userSpeed).floor,150].min,1].max
targetSpeed = pbRoughStat(target, :SPEED, skill)
userSpeed = pbRoughStat(user, :SPEED, skill)
baseDmg = [[(25 * targetSpeed / userSpeed).floor, 150].min, 1].max
when "RandomlyDamageOrHealTarget" # Present
baseDmg = 50
when "RandomPowerDoublePowerIfTargetUnderground" # Magnitude
@@ -232,8 +232,8 @@ class Battle::AI
when "TypeAndPowerDependOnUserBerry" # Natural Gift
baseDmg = move.pbNaturalGiftBaseDamage(user.item_id)
when "PowerHigherWithUserHeavierThanTarget" # Heavy Slam
baseDmg = move.pbBaseDamage(baseDmg,user,target)
baseDmg *= 2 if Settings::MECHANICS_GENERATION >= 7 && skill>=PBTrainerAI.mediumSkill &&
baseDmg = move.pbBaseDamage(baseDmg, user, target)
baseDmg *= 2 if Settings::MECHANICS_GENERATION >= 7 && skill >= PBTrainerAI.mediumSkill &&
target.effects[PBEffects::Minimize]
when "AlwaysCriticalHit", "HitTwoTimes", "HitTwoTimesPoisonTarget" # Frost Breath, Double Kick, Twineedle
baseDmg *= 2
@@ -255,12 +255,12 @@ class Battle::AI
end
when "HitOncePerUserTeamMember" # Beat Up
mult = 0
@battle.eachInTeamFromBattlerIndex(user.index) do |pkmn,_i|
@battle.eachInTeamFromBattlerIndex(user.index) do |pkmn, _i|
mult += 1 if pkmn && pkmn.able? && pkmn.status == :NONE
end
baseDmg *= mult
when "TwoTurnAttackOneTurnInSun" # Solar Beam
baseDmg = move.pbBaseDamageMultiplier(baseDmg,user,target)
baseDmg = move.pbBaseDamageMultiplier(baseDmg, user, target)
when "MultiTurnAttackPowersUpEachTurn" # Rollout
baseDmg *= 2 if user.effects[PBEffects::DefenseCurl]
when "MultiTurnAttackBideThenReturnDoubleDamage" # Bide
@@ -269,23 +269,23 @@ class Battle::AI
baseDmg = user.hp
when "EffectivenessIncludesFlyingType" # Flying Press
if GameData::Type.exists?(:FLYING)
if skill>=PBTrainerAI.highSkill
if skill >= PBTrainerAI.highSkill
targetTypes = target.pbTypes(true)
mult = Effectiveness.calculate(:FLYING,
targetTypes[0],targetTypes[1],targetTypes[2])
baseDmg = (baseDmg.to_f*mult/Effectiveness::NORMAL_EFFECTIVE).round
targetTypes[0], targetTypes[1], targetTypes[2])
baseDmg = (baseDmg.to_f * mult / Effectiveness::NORMAL_EFFECTIVE).round
else
mult = Effectiveness.calculate(:FLYING,
target.types[0], target.types[1], target.effects[PBEffects::Type3])
baseDmg = (baseDmg.to_f*mult/Effectiveness::NORMAL_EFFECTIVE).round
baseDmg = (baseDmg.to_f * mult / Effectiveness::NORMAL_EFFECTIVE).round
end
end
baseDmg *= 2 if skill>=PBTrainerAI.mediumSkill && target.effects[PBEffects::Minimize]
baseDmg *= 2 if skill >= PBTrainerAI.mediumSkill && target.effects[PBEffects::Minimize]
when "DoublePowerIfUserLastMoveFailed" # Stomping Tantrum
baseDmg *= 2 if user.lastRoundMoveFailed
when "HitTwoTimesFlinchTarget" # Double Iron Bash
baseDmg *= 2
baseDmg *= 2 if skill>=PBTrainerAI.mediumSkill && target.effects[PBEffects::Minimize]
baseDmg *= 2 if skill >= PBTrainerAI.mediumSkill && target.effects[PBEffects::Minimize]
end
return baseDmg
end
@@ -293,28 +293,28 @@ class Battle::AI
#=============================================================================
# Damage calculation
#=============================================================================
def pbRoughDamage(move,user,target,skill,baseDmg)
def pbRoughDamage(move, user, target, skill, baseDmg)
# Fixed damage moves
return baseDmg if move.is_a?(Battle::Move::FixedDamageMove)
# Get the move's type
type = pbRoughType(move,user,skill)
type = pbRoughType(move, user, skill)
##### Calculate user's attack stat #####
atk = pbRoughStat(user,:ATTACK,skill)
if move.function=="UseTargetAttackInsteadOfUserAttack" # Foul Play
atk = pbRoughStat(target,:ATTACK,skill)
elsif move.function=="UseUserBaseDefenseInsteadOfUserBaseAttack" # Body Press
atk = pbRoughStat(user,:DEFENSE,skill)
atk = pbRoughStat(user, :ATTACK, skill)
if move.function == "UseTargetAttackInsteadOfUserAttack" # Foul Play
atk = pbRoughStat(target, :ATTACK, skill)
elsif move.function == "UseUserBaseDefenseInsteadOfUserBaseAttack" # Body Press
atk = pbRoughStat(user, :DEFENSE, skill)
elsif move.specialMove?(type)
if move.function=="UseTargetAttackInsteadOfUserAttack" # Foul Play
atk = pbRoughStat(target,:SPECIAL_ATTACK,skill)
if move.function == "UseTargetAttackInsteadOfUserAttack" # Foul Play
atk = pbRoughStat(target, :SPECIAL_ATTACK, skill)
else
atk = pbRoughStat(user,:SPECIAL_ATTACK,skill)
atk = pbRoughStat(user, :SPECIAL_ATTACK, skill)
end
end
##### Calculate target's defense stat #####
defense = pbRoughStat(target,:DEFENSE,skill)
if move.specialMove?(type) && move.function!="UseTargetDefenseInsteadOfTargetSpDef" # Psyshock
defense = pbRoughStat(target,:SPECIAL_DEFENSE,skill)
defense = pbRoughStat(target, :DEFENSE, skill)
if move.specialMove?(type) && move.function != "UseTargetDefenseInsteadOfTargetSpDef" # Psyshock
defense = pbRoughStat(target, :SPECIAL_DEFENSE, skill)
end
##### Calculate all multiplier effects #####
multipliers = {
@@ -325,13 +325,13 @@ class Battle::AI
}
# Ability effects that alter damage
moldBreaker = false
if skill>=PBTrainerAI.highSkill && target.hasMoldBreaker?
if skill >= PBTrainerAI.highSkill && target.hasMoldBreaker?
moldBreaker = true
end
if skill>=PBTrainerAI.mediumSkill && user.abilityActive?
if skill >= PBTrainerAI.mediumSkill && user.abilityActive?
# NOTE: These abilities aren't suitable for checking at the start of the
# round.
abilityBlacklist = [:ANALYTIC,:SNIPER,:TINTEDLENS,:AERILATE,:PIXILATE,:REFRIGERATE]
abilityBlacklist = [:ANALYTIC, :SNIPER, :TINTEDLENS, :AERILATE, :PIXILATE, :REFRIGERATE]
canCheck = true
abilityBlacklist.each do |m|
next if move.id != m
@@ -340,20 +340,20 @@ class Battle::AI
end
if canCheck
Battle::AbilityEffects.triggerDamageCalcFromUser(user.ability,
user,target,move,multipliers,baseDmg,type)
user, target, move, multipliers, baseDmg, type)
end
end
if skill>=PBTrainerAI.mediumSkill && !moldBreaker
if skill >= PBTrainerAI.mediumSkill && !moldBreaker
user.allAllies.each do |b|
next if !b.abilityActive?
Battle::AbilityEffects.triggerDamageCalcFromAlly(b.ability,
user,target,move,multipliers,baseDmg,type)
user, target, move, multipliers, baseDmg, type)
end
end
if skill>=PBTrainerAI.bestSkill && !moldBreaker && target.abilityActive?
if skill >= PBTrainerAI.bestSkill && !moldBreaker && target.abilityActive?
# NOTE: These abilities aren't suitable for checking at the start of the
# round.
abilityBlacklist = [:FILTER,:SOLIDROCK]
abilityBlacklist = [:FILTER, :SOLIDROCK]
canCheck = true
abilityBlacklist.each do |m|
next if move.id != m
@@ -362,38 +362,38 @@ class Battle::AI
end
if canCheck
Battle::AbilityEffects.triggerDamageCalcFromTarget(target.ability,
user,target,move,multipliers,baseDmg,type)
user, target, move, multipliers, baseDmg, type)
end
end
if skill>=PBTrainerAI.bestSkill && !moldBreaker
if skill >= PBTrainerAI.bestSkill && !moldBreaker
target.allAllies.each do |b|
next if !b.abilityActive?
Battle::AbilityEffects.triggerDamageCalcFromTargetAlly(b.ability,
user,target,move,multipliers,baseDmg,type)
user, target, move, multipliers, baseDmg, type)
end
end
# Item effects that alter damage
# NOTE: Type-boosting gems aren't suitable for checking at the start of the
# round.
if skill>=PBTrainerAI.mediumSkill && user.itemActive?
if skill >= PBTrainerAI.mediumSkill && user.itemActive?
# NOTE: These items aren't suitable for checking at the start of the
# round.
itemBlacklist = [:EXPERTBELT,:LIFEORB]
itemBlacklist = [:EXPERTBELT, :LIFEORB]
if !itemBlacklist.include?(user.item_id)
Battle::ItemEffects.triggerDamageCalcFromUser(user.item,
user,target,move,multipliers,baseDmg,type)
user, target, move, multipliers, baseDmg, type)
end
end
if skill>=PBTrainerAI.bestSkill && target.itemActive?
if skill >= PBTrainerAI.bestSkill && target.itemActive?
# NOTE: Type-weakening berries aren't suitable for checking at the start
# of the round.
if target.item && !target.item.is_berry?
Battle::ItemEffects.triggerDamageCalcFromTarget(target.item,
user,target,move,multipliers,baseDmg,type)
user, target, move, multipliers, baseDmg, type)
end
end
# Global abilities
if skill>=PBTrainerAI.mediumSkill
if skill >= PBTrainerAI.mediumSkill
if (@battle.pbCheckGlobalAbility(:DARKAURA) && type == :DARK) ||
(@battle.pbCheckGlobalAbility(:FAIRYAURA) && type == :FAIRY)
if @battle.pbCheckGlobalAbility(:AURABREAK)
@@ -404,25 +404,25 @@ class Battle::AI
end
end
# Parental Bond
if skill>=PBTrainerAI.mediumSkill && user.hasActiveAbility?(:PARENTALBOND)
if skill >= PBTrainerAI.mediumSkill && user.hasActiveAbility?(:PARENTALBOND)
multipliers[:base_damage_multiplier] *= 1.25
end
# Me First
# TODO
# Helping Hand - n/a
# Charge
if skill>=PBTrainerAI.mediumSkill
if user.effects[PBEffects::Charge]>0 && type == :ELECTRIC
if skill >= PBTrainerAI.mediumSkill
if user.effects[PBEffects::Charge] > 0 && type == :ELECTRIC
multipliers[:base_damage_multiplier] *= 2
end
end
# Mud Sport and Water Sport
if skill>=PBTrainerAI.mediumSkill
if skill >= PBTrainerAI.mediumSkill
if type == :ELECTRIC
if @battle.allBattlers.any? { |b| b.effects[PBEffects::MudSport] }
multipliers[:base_damage_multiplier] /= 3
end
if @battle.field.effects[PBEffects::MudSportField]>0
if @battle.field.effects[PBEffects::MudSportField] > 0
multipliers[:base_damage_multiplier] /= 3
end
end
@@ -430,13 +430,13 @@ class Battle::AI
if @battle.allBattlers.any? { |b| b.effects[PBEffects::WaterSport] }
multipliers[:base_damage_multiplier] /= 3
end
if @battle.field.effects[PBEffects::WaterSportField]>0
if @battle.field.effects[PBEffects::WaterSportField] > 0
multipliers[:base_damage_multiplier] /= 3
end
end
end
# Terrain moves
if skill>=PBTrainerAI.mediumSkill
if skill >= PBTrainerAI.mediumSkill
case @battle.field.terrain
when :Electric
multipliers[:base_damage_multiplier] *= 1.5 if type == :ELECTRIC && user.affectedByTerrain?
@@ -449,7 +449,7 @@ class Battle::AI
end
end
# Badge multipliers
if skill>=PBTrainerAI.highSkill
if skill >= PBTrainerAI.highSkill
if @battle.internalBattle
# Don't need to check the Atk/Sp Atk-boosting badges because the AI
# won't control the player's Pokémon.
@@ -463,13 +463,13 @@ class Battle::AI
end
end
# Multi-targeting attacks
if skill>=PBTrainerAI.highSkill
if pbTargetsMultiple?(move,user)
if skill >= PBTrainerAI.highSkill
if pbTargetsMultiple?(move, user)
multipliers[:final_damage_multiplier] *= 0.75
end
end
# Weather
if skill>=PBTrainerAI.mediumSkill
if skill >= PBTrainerAI.mediumSkill
case user.effectiveWeather
when :Sun, :HarshSun
if type == :FIRE
@@ -493,7 +493,7 @@ class Battle::AI
# Critical hits - n/a
# Random variance - n/a
# STAB
if skill>=PBTrainerAI.mediumSkill
if skill >= PBTrainerAI.mediumSkill
if type && user.pbHasType?(type)
if user.hasActiveAbility?(:ADAPTABILITY)
multipliers[:final_damage_multiplier] *= 2
@@ -503,12 +503,12 @@ class Battle::AI
end
end
# Type effectiveness
if skill>=PBTrainerAI.mediumSkill
typemod = pbCalcTypeMod(type,user,target)
if skill >= PBTrainerAI.mediumSkill
typemod = pbCalcTypeMod(type, user, target)
multipliers[:final_damage_multiplier] *= typemod.to_f / Effectiveness::NORMAL_EFFECTIVE
end
# Burn
if skill>=PBTrainerAI.highSkill
if skill >= PBTrainerAI.highSkill
if user.status == :BURN && move.physicalMove?(type) &&
!user.hasActiveAbility?(:GUTS) &&
!(Settings::MECHANICS_GENERATION >= 6 && move.function == "DoublePowerIfUserPoisonedBurnedParalyzed") # Facade
@@ -516,7 +516,7 @@ class Battle::AI
end
end
# Aurora Veil, Reflect, Light Screen
if skill>=PBTrainerAI.highSkill
if skill >= PBTrainerAI.highSkill
if !move.ignoresReflect? && !user.hasActiveAbility?(:INFILTRATOR)
if target.pbOwnSide.effects[PBEffects::AuroraVeil] > 0
if @battle.pbSideBattlerCount(target) > 1
@@ -540,7 +540,7 @@ class Battle::AI
end
end
# Minimize
if skill>=PBTrainerAI.highSkill
if skill >= PBTrainerAI.highSkill
if target.effects[PBEffects::Minimize] && move.tramplesMinimize?(2)
multipliers[:final_damage_multiplier] *= 2
end
@@ -554,39 +554,39 @@ class Battle::AI
atk = [(atk * multipliers[:attack_multiplier]).round, 1].max
defense = [(defense * multipliers[:defense_multiplier]).round, 1].max
damage = (((2.0 * user.level / 5 + 2).floor * baseDmg * atk / defense).floor / 50).floor + 2
damage = [(damage * multipliers[:final_damage_multiplier]).round, 1].max
damage = [(damage * multipliers[:final_damage_multiplier]).round, 1].max
# "AI-specific calculations below"
# Increased critical hit rates
if skill>=PBTrainerAI.mediumSkill
if skill >= PBTrainerAI.mediumSkill
c = 0
# Ability effects that alter critical hit rate
if c>=0 && user.abilityActive?
if c >= 0 && user.abilityActive?
c = Battle::AbilityEffects.triggerCriticalCalcFromUser(user.ability, user, target, c)
end
if skill>=PBTrainerAI.bestSkill
if c>=0 && !moldBreaker && target.abilityActive?
if skill >= PBTrainerAI.bestSkill
if c >= 0 && !moldBreaker && target.abilityActive?
c = Battle::AbilityEffects.triggerCriticalCalcFromTarget(target.ability, user, target, c)
end
end
# Item effects that alter critical hit rate
if c>=0 && user.itemActive?
if c >= 0 && user.itemActive?
c = Battle::ItemEffects.triggerCriticalCalcFromUser(user.item, user, target, c)
end
if skill>=PBTrainerAI.bestSkill
if c>=0 && target.itemActive?
if skill >= PBTrainerAI.bestSkill
if c >= 0 && target.itemActive?
c = Battle::ItemEffects.triggerCriticalCalcFromTarget(target.item, user, target, c)
end
end
# Other efffects
c = -1 if target.pbOwnSide.effects[PBEffects::LuckyChant]>0
if c>=0
c = -1 if target.pbOwnSide.effects[PBEffects::LuckyChant] > 0
if c >= 0
c += 1 if move.highCriticalRate?
c += user.effects[PBEffects::FocusEnergy]
c += 1 if user.inHyperMode? && move.type == :SHADOW
end
if c>=0
c = 4 if c>4
damage += damage*0.1*c
if c >= 0
c = 4 if c > 4
damage += damage * 0.1 * c
end
end
return damage.floor
@@ -595,19 +595,19 @@ class Battle::AI
#=============================================================================
# Accuracy calculation
#=============================================================================
def pbRoughAccuracy(move,user,target,skill)
def pbRoughAccuracy(move, user, target, skill)
# "Always hit" effects and "always hit" accuracy
if skill>=PBTrainerAI.mediumSkill
if skill >= PBTrainerAI.mediumSkill
return 125 if target.effects[PBEffects::Minimize] && move.tramplesMinimize?(1)
return 125 if target.effects[PBEffects::Telekinesis]>0
return 125 if target.effects[PBEffects::Telekinesis] > 0
end
baseAcc = move.accuracy
if skill>=PBTrainerAI.highSkill
baseAcc = move.pbBaseAccuracy(user,target)
if skill >= PBTrainerAI.highSkill
baseAcc = move.pbBaseAccuracy(user, target)
end
return 125 if baseAcc==0 && skill>=PBTrainerAI.mediumSkill
return 125 if baseAcc == 0 && skill >= PBTrainerAI.mediumSkill
# Get the move's type
type = pbRoughType(move,user,skill)
type = pbRoughType(move, user, skill)
# Calculate all modifier effects
modifiers = {}
modifiers[:base_accuracy] = baseAcc
@@ -615,62 +615,62 @@ class Battle::AI
modifiers[:evasion_stage] = target.stages[:EVASION]
modifiers[:accuracy_multiplier] = 1.0
modifiers[:evasion_multiplier] = 1.0
pbCalcAccuracyModifiers(user,target,modifiers,move,type,skill)
pbCalcAccuracyModifiers(user, target, modifiers, move, type, skill)
# Check if move can't miss
return 125 if modifiers[:base_accuracy]==0
return 125 if modifiers[:base_accuracy] == 0
# Calculation
accStage = [[modifiers[:accuracy_stage], -6].max, 6].min + 6
evaStage = [[modifiers[:evasion_stage], -6].max, 6].min + 6
stageMul = [3,3,3,3,3,3, 3, 4,5,6,7,8,9]
stageDiv = [9,8,7,6,5,4, 3, 3,3,3,3,3,3]
stageMul = [3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9]
stageDiv = [9, 8, 7, 6, 5, 4, 3, 3, 3, 3, 3, 3, 3]
accuracy = 100.0 * stageMul[accStage] / stageDiv[accStage]
evasion = 100.0 * stageMul[evaStage] / stageDiv[evaStage]
accuracy = (accuracy * modifiers[:accuracy_multiplier]).round
evasion = (evasion * modifiers[:evasion_multiplier]).round
evasion = 1 if evasion<1
evasion = 1 if evasion < 1
return modifiers[:base_accuracy] * accuracy / evasion
end
def pbCalcAccuracyModifiers(user,target,modifiers,move,type,skill)
def pbCalcAccuracyModifiers(user, target, modifiers, move, type, skill)
moldBreaker = false
if skill>=PBTrainerAI.highSkill && target.hasMoldBreaker?
if skill >= PBTrainerAI.highSkill && target.hasMoldBreaker?
moldBreaker = true
end
# Ability effects that alter accuracy calculation
if skill>=PBTrainerAI.mediumSkill
if skill >= PBTrainerAI.mediumSkill
if user.abilityActive?
Battle::AbilityEffects.triggerAccuracyCalcFromUser(user.ability,
modifiers,user,target,move,type)
modifiers, user, target, move, type)
end
user.allAllies.each do |b|
next if !b.abilityActive?
Battle::AbilityEffects.triggerAccuracyCalcFromAlly(b.ability,
modifiers,user,target,move,type)
modifiers, user, target, move, type)
end
end
if skill>=PBTrainerAI.bestSkill
if skill >= PBTrainerAI.bestSkill
if target.abilityActive? && !moldBreaker
Battle::AbilityEffects.triggerAccuracyCalcFromTarget(target.ability,
modifiers,user,target,move,type)
modifiers, user, target, move, type)
end
end
# Item effects that alter accuracy calculation
if skill>=PBTrainerAI.mediumSkill
if skill >= PBTrainerAI.mediumSkill
if user.itemActive?
Battle::ItemEffects.triggerAccuracyCalcFromUser(user.item,
modifiers,user,target,move,type)
modifiers, user, target, move, type)
end
end
if skill>=PBTrainerAI.bestSkill
if skill >= PBTrainerAI.bestSkill
if target.itemActive?
Battle::ItemEffects.triggerAccuracyCalcFromTarget(target.item,
modifiers,user,target,move,type)
modifiers, user, target, move, type)
end
end
# Other effects, inc. ones that set accuracy_multiplier or evasion_stage to specific values
if skill>=PBTrainerAI.mediumSkill
if skill >= PBTrainerAI.mediumSkill
if @battle.field.effects[PBEffects::Gravity] > 0
modifiers[:accuracy_multiplier] *= 5/3.0
modifiers[:accuracy_multiplier] *= 5 / 3.0
end
if user.effects[PBEffects::MicleBerry]
modifiers[:accuracy_multiplier] *= 1.2
@@ -679,20 +679,20 @@ class Battle::AI
modifiers[:evasion_stage] = 0 if target.effects[PBEffects::MiracleEye] && modifiers[:evasion_stage] > 0
end
# "AI-specific calculations below"
if skill>=PBTrainerAI.mediumSkill
if skill >= PBTrainerAI.mediumSkill
modifiers[:evasion_stage] = 0 if move.function == "IgnoreTargetDefSpDefEvaStatStages" # Chip Away
modifiers[:base_accuracy] = 0 if user.effects[PBEffects::LockOn]>0 &&
user.effects[PBEffects::LockOnPos]==target.index
modifiers[:base_accuracy] = 0 if user.effects[PBEffects::LockOn] > 0 &&
user.effects[PBEffects::LockOnPos] == target.index
end
if skill>=PBTrainerAI.highSkill
if move.function=="BadPoisonTarget" # Toxic
if skill >= PBTrainerAI.highSkill
if move.function == "BadPoisonTarget" # Toxic
modifiers[:base_accuracy] = 0 if Settings::MORE_TYPE_EFFECTS && move.statusMove? &&
user.pbHasType?(:POISON)
end
if ["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(move.function)
modifiers[:base_accuracy] = move.accuracy + user.level - target.level
modifiers[:accuracy_multiplier] = 0 if target.level > user.level
if skill>=PBTrainerAI.bestSkill
if skill >= PBTrainerAI.bestSkill
modifiers[:accuracy_multiplier] = 0 if target.hasActiveAbility?(:STURDY)
end
end

View File

@@ -2,7 +2,7 @@
#
#===============================================================================
class Battle::Peer
def pbStorePokemon(player,pkmn)
def pbStorePokemon(player, pkmn)
if !player.party_full?
player.party[player.party.length] = pkmn
return -1
@@ -14,7 +14,7 @@ class Battle::Peer
end
oldCurBox = pbCurrentBox
storedBox = $PokemonStorage.pbStoreCaught(pkmn)
if storedBox<0
if storedBox < 0
# NOTE: Poké Balls can't be used if storage is full, so you shouldn't ever
# see this message.
pbDisplayPaused(_INTL("Can't catch any more..."))
@@ -33,22 +33,22 @@ class Battle::Peer
end
def pbBoxName(box)
return (box<0) ? "" : $PokemonStorage[box].name
return (box < 0) ? "" : $PokemonStorage[box].name
end
def pbOnEnteringBattle(battle, battler, pkmn, wild = false)
f = MultipleForms.call("getFormOnEnteringBattle",pkmn,wild)
f = MultipleForms.call("getFormOnEnteringBattle", pkmn, wild)
pkmn.form = f if f
battler.form = pkmn.form if battler.form != pkmn.form
MultipleForms.call("changePokemonOnEnteringBattle", battler, pkmn, battle)
end
# For switching out, including due to fainting, and for the end of battle
def pbOnLeavingBattle(battle,pkmn,usedInBattle,endBattle = false)
def pbOnLeavingBattle(battle, pkmn, usedInBattle, endBattle = false)
return if !pkmn
f = MultipleForms.call("getFormOnLeavingBattle",pkmn,battle,usedInBattle,endBattle)
pkmn.form = f if f && pkmn.form!=f
pkmn.hp = pkmn.totalhp if pkmn.hp>pkmn.totalhp
f = MultipleForms.call("getFormOnLeavingBattle", pkmn, battle, usedInBattle, endBattle)
pkmn.form = f if f && pkmn.form != f
pkmn.hp = pkmn.totalhp if pkmn.hp > pkmn.totalhp
MultipleForms.call("changePokemonOnLeavingBattle", pkmn, battle, usedInBattle, endBattle)
end
end
@@ -58,9 +58,9 @@ end
#===============================================================================
class Battle::NullPeer
def pbOnEnteringBattle(battle, battler, pkmn, wild = false); end
def pbOnLeavingBattle(battle,pkmn,usedInBattle,endBattle = false); end
def pbOnLeavingBattle(battle, pkmn, usedInBattle, endBattle = false); end
def pbStorePokemon(player,pkmn)
def pbStorePokemon(player, pkmn)
player.party[player.party.length] = pkmn if !player.party_full?
return -1
end

View File

@@ -31,7 +31,7 @@ module Battle::CatchAndStoreMixin
if !pbPlayer.owned?(pkmn.species)
pbPlayer.pokedex.set_owned(pkmn.species)
if $player.has_pokedex
pbDisplayPaused(_INTL("{1}'s data was added to the Pokédex.",pkmn.name))
pbDisplayPaused(_INTL("{1}'s data was added to the Pokédex.", pkmn.name))
pbPlayer.pokedex.register_last_seen(pkmn)
@scene.pbShowPokedex(pkmn.species)
end
@@ -47,7 +47,7 @@ module Battle::CatchAndStoreMixin
#=============================================================================
# Throw a Poké Ball
#=============================================================================
def pbThrowPokeBall(idxBattler,ball,catch_rate = nil,showPlayer = false)
def pbThrowPokeBall(idxBattler, ball, catch_rate = nil, showPlayer = false)
# Determine which Pokémon you're throwing the Poké Ball at
battler = nil
if opposes?(idxBattler)
@@ -60,32 +60,32 @@ module Battle::CatchAndStoreMixin
itemName = GameData::Item.get(ball).name
if battler.fainted?
if itemName.starts_with_vowel?
pbDisplay(_INTL("{1} threw an {2}!",pbPlayer.name,itemName))
pbDisplay(_INTL("{1} threw an {2}!", pbPlayer.name, itemName))
else
pbDisplay(_INTL("{1} threw a {2}!",pbPlayer.name,itemName))
pbDisplay(_INTL("{1} threw a {2}!", pbPlayer.name, itemName))
end
pbDisplay(_INTL("But there was no target..."))
return
end
if itemName.starts_with_vowel?
pbDisplayBrief(_INTL("{1} threw an {2}!",pbPlayer.name,itemName))
pbDisplayBrief(_INTL("{1} threw an {2}!", pbPlayer.name, itemName))
else
pbDisplayBrief(_INTL("{1} threw a {2}!",pbPlayer.name,itemName))
pbDisplayBrief(_INTL("{1} threw a {2}!", pbPlayer.name, itemName))
end
# Animation of opposing trainer blocking Poké Balls (unless it's a Snag Ball
# at a Shadow Pokémon)
if trainerBattle? && !(GameData::Item.get(ball).is_snag_ball? && battler.shadowPokemon?)
@scene.pbThrowAndDeflect(ball,1)
@scene.pbThrowAndDeflect(ball, 1)
pbDisplay(_INTL("The Trainer blocked your Poké Ball! Don't be a thief!"))
return
end
# Calculate the number of shakes (4=capture)
pkmn = battler.pokemon
@criticalCapture = false
numShakes = pbCaptureCalc(pkmn,battler,catch_rate,ball)
numShakes = pbCaptureCalc(pkmn, battler, catch_rate, ball)
PBDebug.log("[Threw Poké Ball] #{itemName}, #{numShakes} shakes (4=capture)")
# Animation of Ball throw, absorb, shake and capture/burst out
@scene.pbThrow(ball,numShakes,@criticalCapture,battler.index,showPlayer)
@scene.pbThrow(ball, numShakes, @criticalCapture, battler.index, showPlayer)
# Outcome message
case numShakes
when 0
@@ -101,9 +101,9 @@ module Battle::CatchAndStoreMixin
pbDisplay(_INTL("Gah! It was so close, too!"))
Battle::PokeBallEffects.onFailCatch(ball, self, battler)
when 4
pbDisplayBrief(_INTL("Gotcha! {1} was caught!",pkmn.name))
pbDisplayBrief(_INTL("Gotcha! {1} was caught!", pkmn.name))
@scene.pbThrowSuccess # Play capture success jingle
pbRemoveFromParty(battler.index,battler.pokemonIndex)
pbRemoveFromParty(battler.index, battler.pokemonIndex)
# Gain Exp
if Settings::GAIN_EXP_FOR_CAPTURE
battler.captured = true
@@ -125,8 +125,8 @@ module Battle::CatchAndStoreMixin
pkmn.update_shadow_moves if pkmn.shadowPokemon?
pkmn.record_first_moves
# Reset form
pkmn.forced_form = nil if MultipleForms.hasFunction?(pkmn.species,"getForm")
@peer.pbOnLeavingBattle(self,pkmn,true,true)
pkmn.forced_form = nil if MultipleForms.hasFunction?(pkmn.species, "getForm")
@peer.pbOnLeavingBattle(self, pkmn, true, true)
# Make the Poké Ball and data box disappear
@scene.pbHideCaptureBall(idxBattler)
# Save the Pokémon for storage at the end of battle
@@ -141,7 +141,7 @@ module Battle::CatchAndStoreMixin
#=============================================================================
# Calculate how many shakes a thrown Poké Ball will make (4 = capture)
#=============================================================================
def pbCaptureCalc(pkmn,battler,catch_rate,ball)
def pbCaptureCalc(pkmn, battler, catch_rate, ball)
return 4 if $DEBUG && Input.press?(Input::CTRL)
# Get a catch rate if one wasn't provided
catch_rate = pkmn.species_data.catch_rate if !catch_rate
@@ -154,7 +154,7 @@ module Battle::CatchAndStoreMixin
# First half of the shakes calculation
a = battler.totalhp
b = battler.hp
x = ((3*a-2*b)*catch_rate.to_f)/(3*a)
x = ((3 * a - 2 * b) * catch_rate.to_f) / (3 * a)
# Calculation modifiers
if battler.status == :SLEEP || battler.status == :FROZEN
x *= 2.5
@@ -162,40 +162,40 @@ module Battle::CatchAndStoreMixin
x *= 1.5
end
x = x.floor
x = 1 if x<1
x = 1 if x < 1
# Definite capture, no need to perform randomness checks
return 4 if x>=255 || Battle::PokeBallEffects.isUnconditional?(ball, self, battler)
return 4 if x >= 255 || Battle::PokeBallEffects.isUnconditional?(ball, self, battler)
# Second half of the shakes calculation
y = (65536 / ((255.0/x)**0.1875)).floor
y = (65536 / ((255.0 / x)**0.1875)).floor
# Critical capture check
if Settings::ENABLE_CRITICAL_CAPTURES
dex_modifier = 0
numOwned = $player.pokedex.owned_count
if numOwned>600
if numOwned > 600
dex_modifier = 5
elsif numOwned>450
elsif numOwned > 450
dex_modifier = 4
elsif numOwned>300
elsif numOwned > 300
dex_modifier = 3
elsif numOwned>150
elsif numOwned > 150
dex_modifier = 2
elsif numOwned>30
elsif numOwned > 30
dex_modifier = 1
end
dex_modifier *= 2 if $bag.has?(:CATCHINGCHARM)
c = x * dex_modifier / 12
# Calculate the number of shakes
if c>0 && pbRandom(256)<c
if c > 0 && pbRandom(256) < c
@criticalCapture = true
return 4 if pbRandom(65536)<y
return 4 if pbRandom(65536) < y
return 0
end
end
# Calculate the number of shakes
numShakes = 0
for i in 0...4
break if numShakes<i
numShakes += 1 if pbRandom(65536)<y
break if numShakes < i
numShakes += 1 if pbRandom(65536) < y
end
return numShakes
end

View File

@@ -10,7 +10,7 @@ class Battle
def pbDecisionOnDraw
if @rules["selfkoclause"]
if self.lastMoveUser<0
if self.lastMoveUser < 0
# in extreme cases there may be no last move user
return 5 # game is a draw
elsif opposes?(self.lastMoveUser)
@@ -22,15 +22,15 @@ class Battle
return __clauses__pbDecisionOnDraw
end
def pbJudgeCheckpoint(user,move = nil)
def pbJudgeCheckpoint(user, move = nil)
if pbAllFainted?(0) && pbAllFainted?(1)
if @rules["drawclause"] # NOTE: Also includes Life Orb (not implemented)
if !(move && move.function=="HealUserByHalfOfDamageDone")
if !(move && move.function == "HealUserByHalfOfDamageDone")
# Not a draw if fainting occurred due to Liquid Ooze
@decision = (user.opposes?) ? 1 : 2 # win / loss
end
elsif @rules["modifiedselfdestructclause"]
if move && move.function=="UserFaintsExplosive" # Self-Destruct
if move && move.function == "UserFaintsExplosive" # Self-Destruct
@decision = (user.opposes?) ? 1 : 2 # win / loss
end
end
@@ -39,12 +39,12 @@ class Battle
def pbEndOfRoundPhase
__clauses__pbEndOfRoundPhase
if @rules["suddendeath"] && @decision==0
if @rules["suddendeath"] && @decision == 0
p1able = pbAbleCount(0)
p2able = pbAbleCount(1)
if p1able>p2able
if p1able > p2able
@decision = 1 # loss
elsif p1able<p2able
elsif p1able < p2able
@decision = 2 # win
end
end
@@ -62,16 +62,16 @@ class Battle::Battler
@__clauses__aliased = true
end
def pbCanSleep?(user,showMessages,move = nil,ignoreStatus = false)
selfsleep = (user && user.index==@index)
def pbCanSleep?(user, showMessages, move = nil, ignoreStatus = false)
selfsleep = (user && user.index == @index)
if ((@battle.rules["modifiedsleepclause"]) || (!selfsleep && @battle.rules["sleepclause"])) &&
pbHasStatusPokemon?(:SLEEP)
if showMessages
@battle.pbDisplay(_INTL("But {1} couldn't sleep!",pbThis(true)))
@battle.pbDisplay(_INTL("But {1} couldn't sleep!", pbThis(true)))
end
return false
end
return __clauses__pbCanSleep?(user,showMessages,move,ignoreStatus)
return __clauses__pbCanSleep?(user, showMessages, move, ignoreStatus)
end
def pbCanSleepYawn?
@@ -93,10 +93,10 @@ class Battle::Battler
count = 0
@battle.pbParty(@index).each do |pkmn|
next if !pkmn || pkmn.egg?
next if pkmn.status!=status
next if pkmn.status != status
count += 1
end
return count>0
return count > 0
end
end
@@ -105,12 +105,12 @@ end
class Battle::Move::RaiseUserEvasion1 # Double Team
alias __clauses__pbMoveFailed? pbMoveFailed?
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !damagingMove? && @battle.rules["evasionclause"]
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
return __clauses__pbMoveFailed?(user,targets)
return __clauses__pbMoveFailed?(user, targets)
end
end
@@ -119,12 +119,12 @@ end
class Battle::Move::RaiseUserEvasion2MinimizeUser # Minimize
alias __clauses__pbMoveFailed? pbMoveFailed?
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if !damagingMove? && @battle.rules["evasionclause"]
@battle.pbDisplay(_INTL("But it failed!"))
return true
end
return __clauses__pbMoveFailed?(user,targets)
return __clauses__pbMoveFailed?(user, targets)
end
end
@@ -220,12 +220,12 @@ class Battle::Move::UserFaintsExplosive # Self-Destruct
@__clauses__aliased = true
end
def pbMoveFailed?(user,targets)
def pbMoveFailed?(user, targets)
if @battle.rules["selfkoclause"]
# Check whether no unfainted Pokemon remain in either party
count = @battle.pbAbleNonActiveCount(user.idxOwnSide)
count += @battle.pbAbleNonActiveCount(user.idxOpposingSide)
if count==0
if count == 0
@battle.pbDisplay("But it failed!")
return false
end
@@ -234,13 +234,13 @@ class Battle::Move::UserFaintsExplosive # Self-Destruct
# Check whether no unfainted Pokemon remain in either party
count = @battle.pbAbleNonActiveCount(user.idxOwnSide)
count += @battle.pbAbleNonActiveCount(user.idxOpposingSide)
if count==0
@battle.pbDisplay(_INTL("{1}'s team was disqualified!",user.pbThis))
if count == 0
@battle.pbDisplay(_INTL("{1}'s team was disqualified!", user.pbThis))
@battle.decision = (user.opposes?) ? 1 : 2
return false
end
end
return __clauses__pbMoveFailed?(user,targets)
return __clauses__pbMoveFailed?(user, targets)
end
end
@@ -251,7 +251,7 @@ class Battle::Move::StartPerishCountsForAllBattlers # Perish Song
def pbFailsAgainstTarget?(user, target, show_message)
if @battle.rules["perishsongclause"] &&
@battle.pbAbleNonActiveCount(user.idxOwnSide)==0
@battle.pbAbleNonActiveCount(user.idxOwnSide) == 0
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end
@@ -266,7 +266,7 @@ class Battle::Move::AttackerFaintsIfUserFaints # Destiny Bond
def pbFailsAgainstTarget?(user, target, show_message)
if @battle.rules["perishsongclause"] &&
@battle.pbAbleNonActiveCount(user.idxOwnSide)==0
@battle.pbAbleNonActiveCount(user.idxOwnSide) == 0
@battle.pbDisplay(_INTL("But it failed!")) if show_message
return true
end

View File

@@ -34,47 +34,47 @@ end
#===============================================================================
#
#===============================================================================
def yaxisIntersect(x1,y1,x2,y2,px,py)
dx = x2-x1
dy = y2-y1
x = (dx==0) ? 0.0 : (px-x1).to_f/dx
y = (dy==0) ? 0.0 : (py-y1).to_f/dy
return [x,y]
def yaxisIntersect(x1, y1, x2, y2, px, py)
dx = x2 - x1
dy = y2 - y1
x = (dx == 0) ? 0.0 : (px - x1).to_f / dx
y = (dy == 0) ? 0.0 : (py - y1).to_f / dy
return [x, y]
end
def repositionY(x1,y1,x2,y2,tx,ty)
dx = x2-x1
dy = y2-y1
x = x1+tx*dx.to_f
y = y1+ty*dy.to_f
return [x,y]
def repositionY(x1, y1, x2, y2, tx, ty)
dx = x2 - x1
dy = y2 - y1
x = x1 + tx * dx.to_f
y = y1 + ty * dy.to_f
return [x, y]
end
def transformPoint(x1,y1,x2,y2, # Source line
x3,y3,x4,y4, # Destination line
px,py) # Source point
ret = yaxisIntersect(x1,y1,x2,y2,px,py)
ret2 = repositionY(x3,y3,x4,y4,ret[0],ret[1])
def transformPoint(x1, y1, x2, y2, # Source line
x3, y3, x4, y4, # Destination line
px, py) # Source point
ret = yaxisIntersect(x1, y1, x2, y2, px, py)
ret2 = repositionY(x3, y3, x4, y4, ret[0], ret[1])
return ret2
end
def getSpriteCenter(sprite)
return [0,0] if !sprite || sprite.disposed?
return [sprite.x,sprite.y] if !sprite.bitmap || sprite.bitmap.disposed?
centerX = sprite.src_rect.width/2
centerY = sprite.src_rect.height/2
offsetX = (centerX-sprite.ox)*sprite.zoom_x
offsetY = (centerY-sprite.oy)*sprite.zoom_y
return [sprite.x+offsetX,sprite.y+offsetY]
return [0, 0] if !sprite || sprite.disposed?
return [sprite.x, sprite.y] if !sprite.bitmap || sprite.bitmap.disposed?
centerX = sprite.src_rect.width / 2
centerY = sprite.src_rect.height / 2
offsetX = (centerX - sprite.ox) * sprite.zoom_x
offsetY = (centerY - sprite.oy) * sprite.zoom_y
return [sprite.x + offsetX, sprite.y + offsetY]
end
def isReversed(src0,src1,dst0,dst1)
return false if src0==src1
return (dst0>dst1) if src0<src1
return (dst0<dst1)
def isReversed(src0, src1, dst0, dst1)
return false if src0 == src1
return (dst0 > dst1) if src0 < src1
return (dst0 < dst1)
end
def pbCreateCel(x,y,pattern,focus = 4)
def pbCreateCel(x, y, pattern, focus = 4)
frame = []
frame[AnimFrame::X] = x
frame[AnimFrame::Y] = y
@@ -121,33 +121,33 @@ def pbConvertRPGAnimation(animation)
pbAnim.array.clear
yOffset = 0
pbAnim.position = animation.position
yOffset = -64 if animation.position==0
yOffset = 64 if animation.position==2
yOffset = -64 if animation.position == 0
yOffset = 64 if animation.position == 2
for i in 0...animation.frames.length
frame = pbAnim.addFrame
animFrame = animation.frames[i]
for j in 0...animFrame.cell_max
data = animFrame.cell_data
if data[j,0]==-1
if data[j, 0] == -1
frame.push(nil)
next
end
if animation.position==3 # Screen
if animation.position == 3 # Screen
point = transformPoint(
-160,80,160,-80,
Battle::Scene::FOCUSUSER_X,Battle::Scene::FOCUSUSER_Y,
Battle::Scene::FOCUSTARGET_X,Battle::Scene::FOCUSTARGET_Y,
data[j,1],data[j,2]
-160, 80, 160, -80,
Battle::Scene::FOCUSUSER_X, Battle::Scene::FOCUSUSER_Y,
Battle::Scene::FOCUSTARGET_X, Battle::Scene::FOCUSTARGET_Y,
data[j, 1], data[j, 2]
)
cel = pbCreateCel(point[0],point[1],data[j,0])
cel = pbCreateCel(point[0], point[1], data[j, 0])
else
cel = pbCreateCel(data[j,1],data[j,2]+yOffset,data[j,0])
cel = pbCreateCel(data[j, 1], data[j, 2] + yOffset, data[j, 0])
end
cel[AnimFrame::ZOOMX] = data[j,3]
cel[AnimFrame::ZOOMY] = data[j,3]
cel[AnimFrame::ANGLE] = data[j,4]
cel[AnimFrame::MIRROR] = data[j,5]
cel[AnimFrame::OPACITY] = data[j,6]
cel[AnimFrame::ZOOMX] = data[j, 3]
cel[AnimFrame::ZOOMY] = data[j, 3]
cel[AnimFrame::ANGLE] = data[j, 4]
cel[AnimFrame::MIRROR] = data[j, 5]
cel[AnimFrame::OPACITY] = data[j, 6]
cel[AnimFrame::BLENDTYPE] = 0
frame.push(cel)
end
@@ -173,7 +173,7 @@ end
#
#===============================================================================
class RPG::Animation
def self.fromOther(otherAnim,id)
def self.fromOther(otherAnim, id)
ret = RPG::Animation.new
ret.id = id
ret.name = otherAnim.name.clone
@@ -183,42 +183,42 @@ class RPG::Animation
return ret
end
def addSound(frame,se)
def addSound(frame, se)
timing = RPG::Animation::Timing.new
timing.frame = frame
timing.se = RPG::AudioFile.new(se,100)
timing.se = RPG::AudioFile.new(se, 100)
self.timings.push(timing)
end
def addAnimation(otherAnim,frame,x,y) # frame is zero-based
if frame+otherAnim.frames.length>=self.frames.length
totalframes = frame+otherAnim.frames.length+1
def addAnimation(otherAnim, frame, x, y) # frame is zero-based
if frame + otherAnim.frames.length >= self.frames.length
totalframes = frame + otherAnim.frames.length + 1
for i in self.frames.length...totalframes
self.frames.push(RPG::Animation::Frame.new)
end
end
self.frame_max = self.frames.length
for i in 0...otherAnim.frame_max
thisframe = self.frames[frame+i]
thisframe = self.frames[frame + i]
otherframe = otherAnim.frames[i]
cellStart = thisframe.cell_max
thisframe.cell_max += otherframe.cell_max
thisframe.cell_data.resize(thisframe.cell_max,8)
thisframe.cell_data.resize(thisframe.cell_max, 8)
for j in 0...otherframe.cell_max
thisframe.cell_data[cellStart+j,0] = otherframe.cell_data[j,0]
thisframe.cell_data[cellStart+j,1] = otherframe.cell_data[j,1]+x
thisframe.cell_data[cellStart+j,2] = otherframe.cell_data[j,2]+y
thisframe.cell_data[cellStart+j,3] = otherframe.cell_data[j,3]
thisframe.cell_data[cellStart+j,4] = otherframe.cell_data[j,4]
thisframe.cell_data[cellStart+j,5] = otherframe.cell_data[j,5]
thisframe.cell_data[cellStart+j,6] = otherframe.cell_data[j,6]
thisframe.cell_data[cellStart+j,7] = otherframe.cell_data[j,7]
thisframe.cell_data[cellStart + j, 0] = otherframe.cell_data[j, 0]
thisframe.cell_data[cellStart + j, 1] = otherframe.cell_data[j, 1] + x
thisframe.cell_data[cellStart + j, 2] = otherframe.cell_data[j, 2] + y
thisframe.cell_data[cellStart + j, 3] = otherframe.cell_data[j, 3]
thisframe.cell_data[cellStart + j, 4] = otherframe.cell_data[j, 4]
thisframe.cell_data[cellStart + j, 5] = otherframe.cell_data[j, 5]
thisframe.cell_data[cellStart + j, 6] = otherframe.cell_data[j, 6]
thisframe.cell_data[cellStart + j, 7] = otherframe.cell_data[j, 7]
end
end
for i in 0...otherAnim.timings.length
timing = RPG::Animation::Timing.new
othertiming = otherAnim.timings[i]
timing.frame = frame+othertiming.frame
timing.frame = frame + othertiming.frame
timing.se = RPG::AudioFile.new(
othertiming.se.name.clone,
othertiming.se.volume,
@@ -229,7 +229,7 @@ class RPG::Animation
timing.condition = othertiming.condition
self.timings.push(timing)
end
self.timings.sort! { |a,b| a.frame<=>b.frame }
self.timings.sort! { |a, b| a.frame <=> b.frame }
end
end
@@ -271,7 +271,7 @@ class PBAnimTiming
@colorAlpha = nil
@duration = 5
@flashScope = 0
@flashColor = Color.new(255,255,255,255)
@flashColor = Color.new(255, 255, 255, 255)
@flashDuration = 5
end
@@ -286,61 +286,61 @@ class PBAnimTiming
def to_s
case self.timingType
when 0
return "[#{@frame+1}] Play SE: #{name} (volume #{@volume}, pitch #{@pitch})"
return "[#{@frame + 1}] Play SE: #{name} (volume #{@volume}, pitch #{@pitch})"
when 1
text = sprintf("[%d] Set BG: \"%s\"",@frame+1,name)
text = sprintf("[%d] Set BG: \"%s\"", @frame + 1, name)
text += sprintf(" (color=%s,%s,%s,%s)",
(@colorRed!=nil) ? @colorRed.to_i : "-",
(@colorGreen!=nil) ? @colorGreen.to_i : "-",
(@colorBlue!=nil) ? @colorBlue.to_i : "-",
(@colorAlpha!=nil) ? @colorAlpha.to_i : "-")
text += sprintf(" (opacity=%s)",@opacity.to_i)
(@colorRed != nil) ? @colorRed.to_i : "-",
(@colorGreen != nil) ? @colorGreen.to_i : "-",
(@colorBlue != nil) ? @colorBlue.to_i : "-",
(@colorAlpha != nil) ? @colorAlpha.to_i : "-")
text += sprintf(" (opacity=%s)", @opacity.to_i)
text += sprintf(" (coords=%s,%s)",
(@bgX!=nil) ? @bgX : "-",
(@bgY!=nil) ? @bgY : "-")
(@bgX != nil) ? @bgX : "-",
(@bgY != nil) ? @bgY : "-")
return text
when 2
text = sprintf("[%d] Change BG: @%d",@frame+1,duration)
if @colorRed!=nil || @colorGreen!=nil || @colorBlue!=nil || @colorAlpha!=nil
text = sprintf("[%d] Change BG: @%d", @frame + 1, duration)
if @colorRed != nil || @colorGreen != nil || @colorBlue != nil || @colorAlpha != nil
text += sprintf(" (color=%s,%s,%s,%s)",
(@colorRed!=nil) ? @colorRed.to_i : "-",
(@colorGreen!=nil) ? @colorGreen.to_i : "-",
(@colorBlue!=nil) ? @colorBlue.to_i : "-",
(@colorAlpha!=nil) ? @colorAlpha.to_i : "-")
(@colorRed != nil) ? @colorRed.to_i : "-",
(@colorGreen != nil) ? @colorGreen.to_i : "-",
(@colorBlue != nil) ? @colorBlue.to_i : "-",
(@colorAlpha != nil) ? @colorAlpha.to_i : "-")
end
text += sprintf(" (opacity=%s)",@opacity.to_i) if @opacity!=nil
if @bgX!=nil || @bgY!=nil
text += sprintf(" (opacity=%s)", @opacity.to_i) if @opacity != nil
if @bgX != nil || @bgY != nil
text += sprintf(" (coords=%s,%s)",
(@bgX!=nil) ? @bgX : "-",
(@bgY!=nil) ? @bgY : "-")
(@bgX != nil) ? @bgX : "-",
(@bgY != nil) ? @bgY : "-")
end
return text
when 3
text = sprintf("[%d] Set FG: \"%s\"",@frame+1,name)
text = sprintf("[%d] Set FG: \"%s\"", @frame + 1, name)
text += sprintf(" (color=%s,%s,%s,%s)",
(@colorRed!=nil) ? @colorRed.to_i : "-",
(@colorGreen!=nil) ? @colorGreen.to_i : "-",
(@colorBlue!=nil) ? @colorBlue.to_i : "-",
(@colorAlpha!=nil) ? @colorAlpha.to_i : "-")
text += sprintf(" (opacity=%s)",@opacity.to_i)
(@colorRed != nil) ? @colorRed.to_i : "-",
(@colorGreen != nil) ? @colorGreen.to_i : "-",
(@colorBlue != nil) ? @colorBlue.to_i : "-",
(@colorAlpha != nil) ? @colorAlpha.to_i : "-")
text += sprintf(" (opacity=%s)", @opacity.to_i)
text += sprintf(" (coords=%s,%s)",
(@bgX!=nil) ? @bgX : "-",
(@bgY!=nil) ? @bgY : "-")
(@bgX != nil) ? @bgX : "-",
(@bgY != nil) ? @bgY : "-")
return text
when 4
text = sprintf("[%d] Change FG: @%d",@frame+1,duration)
if @colorRed!=nil || @colorGreen!=nil || @colorBlue!=nil || @colorAlpha!=nil
text = sprintf("[%d] Change FG: @%d", @frame + 1, duration)
if @colorRed != nil || @colorGreen != nil || @colorBlue != nil || @colorAlpha != nil
text += sprintf(" (color=%s,%s,%s,%s)",
(@colorRed!=nil) ? @colorRed.to_i : "-",
(@colorGreen!=nil) ? @colorGreen.to_i : "-",
(@colorBlue!=nil) ? @colorBlue.to_i : "-",
(@colorAlpha!=nil) ? @colorAlpha.to_i : "-")
(@colorRed != nil) ? @colorRed.to_i : "-",
(@colorGreen != nil) ? @colorGreen.to_i : "-",
(@colorBlue != nil) ? @colorBlue.to_i : "-",
(@colorAlpha != nil) ? @colorAlpha.to_i : "-")
end
text += sprintf(" (opacity=%s)",@opacity.to_i) if @opacity!=nil
if @bgX!=nil || @bgY!=nil
text += sprintf(" (opacity=%s)", @opacity.to_i) if @opacity != nil
if @bgX != nil || @bgY != nil
text += sprintf(" (coords=%s,%s)",
(@bgX!=nil) ? @bgX : "-",
(@bgY!=nil) ? @bgY : "-")
(@bgX != nil) ? @bgX : "-",
(@bgY != nil) ? @bgY : "-")
end
return text
end
@@ -361,7 +361,7 @@ class PBAnimations < Array
def initialize(size = 1)
@array = []
@selected = 0
size = 1 if size<1 # Always create at least one animation
size = 1 if size < 1 # Always create at least one animation
size.times do
@array.push(PBAnimation.new)
end
@@ -379,7 +379,7 @@ class PBAnimations < Array
return @array[i]
end
def []=(i,value)
def []=(i, value)
@array[i] = value
end
@@ -387,8 +387,8 @@ class PBAnimations < Array
@array.compact!
end
def insert(index,val)
@array.insert(index,val)
def insert(index, val)
@array.insert(index, val)
end
def delete_at(index)
@@ -398,7 +398,7 @@ class PBAnimations < Array
def resize(len)
idxStart = @array.length
idxEnd = len
if idxStart>idxEnd
if idxStart > idxEnd
for i in idxEnd...idxStart
@array.pop
end
@@ -407,7 +407,7 @@ class PBAnimations < Array
@array.push(PBAnimation.new)
end
end
self.selected = len if self.selected>=len
self.selected = len if self.selected >= len
end
end
@@ -440,7 +440,7 @@ class PBAnimation < Array
@hue = 0
@position = 4 # 1=target, 2=user, 3=user and target, 4=screen
@array = []
size = 1 if size<1 # Always create at least one frame
size = 1 if size < 1 # Always create at least one frame
size.times { addFrame }
@timing = []
@scope = 0
@@ -458,7 +458,7 @@ class PBAnimation < Array
return @array[i]
end
def []=(i,value)
def []=(i, value)
@array[i] = value
end
@@ -471,10 +471,10 @@ class PBAnimation < Array
end
def resize(len)
if len<@array.length
@array[len,@array.length-len] = []
elsif len>@array.length
(len-@array.length).times do
if len < @array.length
@array[len, @array.length - len] = []
elsif len > @array.length
(len - @array.length).times do
addFrame
end
end
@@ -484,128 +484,128 @@ class PBAnimation < Array
pos = @array.length
@array[pos] = []
# Move's user
@array[pos][0] = pbCreateCel(Battle::Scene::FOCUSUSER_X, Battle::Scene::FOCUSUSER_Y,-1)
@array[pos][0] = pbCreateCel(Battle::Scene::FOCUSUSER_X, Battle::Scene::FOCUSUSER_Y, -1)
@array[pos][0][AnimFrame::FOCUS] = 2
@array[pos][0][AnimFrame::LOCKED] = 1
# Move's target
@array[pos][1] = pbCreateCel(Battle::Scene::FOCUSTARGET_X, Battle::Scene::FOCUSTARGET_Y,-2)
@array[pos][1] = pbCreateCel(Battle::Scene::FOCUSTARGET_X, Battle::Scene::FOCUSTARGET_Y, -2)
@array[pos][1][AnimFrame::FOCUS] = 1
@array[pos][1][AnimFrame::LOCKED] = 1
return @array[pos]
end
def playTiming(frame,bgGraphic,bgColor,foGraphic,foColor,oldbg = [],oldfo = [],user = nil)
def playTiming(frame, bgGraphic, bgColor, foGraphic, foColor, oldbg = [], oldfo = [], user = nil)
for i in @timing
next if i.frame!=frame
next if i.frame != frame
case i.timingType
when 0 # Play SE
if i.name && i.name!=""
pbSEPlay("Anim/"+i.name,i.volume,i.pitch)
if i.name && i.name != ""
pbSEPlay("Anim/" + i.name, i.volume, i.pitch)
elsif user && user.pokemon
name = GameData::Species.cry_filename_from_pokemon(user.pokemon)
pbSEPlay(name,i.volume,i.pitch) if name
pbSEPlay(name, i.volume, i.pitch) if name
end
# if sprite
# sprite.flash(i.flashColor,i.flashDuration*2) if i.flashScope==1
# sprite.flash(nil,i.flashDuration*2) if i.flashScope==3
# end
when 1 # Set background graphic (immediate)
if i.name && i.name!=""
bgGraphic.setBitmap("Graphics/Animations/"+i.name)
if i.name && i.name != ""
bgGraphic.setBitmap("Graphics/Animations/" + i.name)
bgGraphic.ox = -i.bgX || 0
bgGraphic.oy = -i.bgY || 0
bgGraphic.color = Color.new(i.colorRed || 0,i.colorGreen || 0,i.colorBlue || 0,i.colorAlpha || 0)
bgGraphic.color = Color.new(i.colorRed || 0, i.colorGreen || 0, i.colorBlue || 0, i.colorAlpha || 0)
bgGraphic.opacity = i.opacity || 0
bgColor.opacity = 0
else
bgGraphic.setBitmap(nil)
bgGraphic.opacity = 0
bgColor.color = Color.new(i.colorRed || 0,i.colorGreen || 0,i.colorBlue || 0,i.colorAlpha || 0)
bgColor.color = Color.new(i.colorRed || 0, i.colorGreen || 0, i.colorBlue || 0, i.colorAlpha || 0)
bgColor.opacity = i.opacity || 0
end
when 2 # Move/recolour background graphic
if bgGraphic.bitmap!=nil
if bgGraphic.bitmap != nil
oldbg[0] = bgGraphic.ox || 0
oldbg[1] = bgGraphic.oy || 0
oldbg[2] = bgGraphic.opacity || 0
oldbg[3] = bgGraphic.color.clone || Color.new(0,0,0,0)
oldbg[3] = bgGraphic.color.clone || Color.new(0, 0, 0, 0)
else
oldbg[0] = 0
oldbg[1] = 0
oldbg[2] = bgColor.opacity || 0
oldbg[3] = bgColor.color.clone || Color.new(0,0,0,0)
oldbg[3] = bgColor.color.clone || Color.new(0, 0, 0, 0)
end
when 3 # Set foreground graphic (immediate)
if i.name && i.name!=""
foGraphic.setBitmap("Graphics/Animations/"+i.name)
if i.name && i.name != ""
foGraphic.setBitmap("Graphics/Animations/" + i.name)
foGraphic.ox = -i.bgX || 0
foGraphic.oy = -i.bgY || 0
foGraphic.color = Color.new(i.colorRed || 0,i.colorGreen || 0,i.colorBlue || 0,i.colorAlpha || 0)
foGraphic.color = Color.new(i.colorRed || 0, i.colorGreen || 0, i.colorBlue || 0, i.colorAlpha || 0)
foGraphic.opacity = i.opacity || 0
foColor.opacity = 0
else
foGraphic.setBitmap(nil)
foGraphic.opacity = 0
foColor.color = Color.new(i.colorRed || 0,i.colorGreen || 0,i.colorBlue || 0,i.colorAlpha || 0)
foColor.color = Color.new(i.colorRed || 0, i.colorGreen || 0, i.colorBlue || 0, i.colorAlpha || 0)
foColor.opacity = i.opacity || 0
end
when 4 # Move/recolour foreground graphic
if foGraphic.bitmap!=nil
if foGraphic.bitmap != nil
oldfo[0] = foGraphic.ox || 0
oldfo[1] = foGraphic.oy || 0
oldfo[2] = foGraphic.opacity || 0
oldfo[3] = foGraphic.color.clone || Color.new(0,0,0,0)
oldfo[3] = foGraphic.color.clone || Color.new(0, 0, 0, 0)
else
oldfo[0] = 0
oldfo[1] = 0
oldfo[2] = foColor.opacity || 0
oldfo[3] = foColor.color.clone || Color.new(0,0,0,0)
oldfo[3] = foColor.color.clone || Color.new(0, 0, 0, 0)
end
end
end
for i in @timing
case i.timingType
when 2
next if !i.duration || i.duration<=0
next if frame<i.frame || frame>i.frame+i.duration
fraction = (frame-i.frame).to_f/i.duration
if bgGraphic.bitmap!=nil
bgGraphic.ox = oldbg[0]-(i.bgX-oldbg[0])*fraction if i.bgX!=nil
bgGraphic.oy = oldbg[1]-(i.bgY-oldbg[1])*fraction if i.bgY!=nil
bgGraphic.opacity = oldbg[2]+(i.opacity-oldbg[2])*fraction if i.opacity!=nil
cr = (i.colorRed!=nil) ? oldbg[3].red+(i.colorRed-oldbg[3].red)*fraction : oldbg[3].red
cg = (i.colorGreen!=nil) ? oldbg[3].green+(i.colorGreen-oldbg[3].green)*fraction : oldbg[3].green
cb = (i.colorBlue!=nil) ? oldbg[3].blue+(i.colorBlue-oldbg[3].blue)*fraction : oldbg[3].blue
ca = (i.colorAlpha!=nil) ? oldbg[3].alpha+(i.colorAlpha-oldbg[3].alpha)*fraction : oldbg[3].alpha
bgGraphic.color = Color.new(cr,cg,cb,ca)
next if !i.duration || i.duration <= 0
next if frame < i.frame || frame > i.frame + i.duration
fraction = (frame - i.frame).to_f / i.duration
if bgGraphic.bitmap != nil
bgGraphic.ox = oldbg[0] - (i.bgX - oldbg[0]) * fraction if i.bgX != nil
bgGraphic.oy = oldbg[1] - (i.bgY - oldbg[1]) * fraction if i.bgY != nil
bgGraphic.opacity = oldbg[2] + (i.opacity - oldbg[2]) * fraction if i.opacity != nil
cr = (i.colorRed != nil) ? oldbg[3].red + (i.colorRed - oldbg[3].red) * fraction : oldbg[3].red
cg = (i.colorGreen != nil) ? oldbg[3].green + (i.colorGreen - oldbg[3].green) * fraction : oldbg[3].green
cb = (i.colorBlue != nil) ? oldbg[3].blue + (i.colorBlue - oldbg[3].blue) * fraction : oldbg[3].blue
ca = (i.colorAlpha != nil) ? oldbg[3].alpha + (i.colorAlpha - oldbg[3].alpha) * fraction : oldbg[3].alpha
bgGraphic.color = Color.new(cr, cg, cb, ca)
else
bgColor.opacity = oldbg[2]+(i.opacity-oldbg[2])*fraction if i.opacity!=nil
cr = (i.colorRed!=nil) ? oldbg[3].red+(i.colorRed-oldbg[3].red)*fraction : oldbg[3].red
cg = (i.colorGreen!=nil) ? oldbg[3].green+(i.colorGreen-oldbg[3].green)*fraction : oldbg[3].green
cb = (i.colorBlue!=nil) ? oldbg[3].blue+(i.colorBlue-oldbg[3].blue)*fraction : oldbg[3].blue
ca = (i.colorAlpha!=nil) ? oldbg[3].alpha+(i.colorAlpha-oldbg[3].alpha)*fraction : oldbg[3].alpha
bgColor.color = Color.new(cr,cg,cb,ca)
bgColor.opacity = oldbg[2] + (i.opacity - oldbg[2]) * fraction if i.opacity != nil
cr = (i.colorRed != nil) ? oldbg[3].red + (i.colorRed - oldbg[3].red) * fraction : oldbg[3].red
cg = (i.colorGreen != nil) ? oldbg[3].green + (i.colorGreen - oldbg[3].green) * fraction : oldbg[3].green
cb = (i.colorBlue != nil) ? oldbg[3].blue + (i.colorBlue - oldbg[3].blue) * fraction : oldbg[3].blue
ca = (i.colorAlpha != nil) ? oldbg[3].alpha + (i.colorAlpha - oldbg[3].alpha) * fraction : oldbg[3].alpha
bgColor.color = Color.new(cr, cg, cb, ca)
end
when 4
next if !i.duration || i.duration<=0
next if frame<i.frame || frame>i.frame+i.duration
fraction = (frame-i.frame).to_f/i.duration
if foGraphic.bitmap!=nil
foGraphic.ox = oldfo[0]-(i.bgX-oldfo[0])*fraction if i.bgX!=nil
foGraphic.oy = oldfo[1]-(i.bgY-oldfo[1])*fraction if i.bgY!=nil
foGraphic.opacity = oldfo[2]+(i.opacity-oldfo[2])*fraction if i.opacity!=nil
cr = (i.colorRed!=nil) ? oldfo[3].red+(i.colorRed-oldfo[3].red)*fraction : oldfo[3].red
cg = (i.colorGreen!=nil) ? oldfo[3].green+(i.colorGreen-oldfo[3].green)*fraction : oldfo[3].green
cb = (i.colorBlue!=nil) ? oldfo[3].blue+(i.colorBlue-oldfo[3].blue)*fraction : oldfo[3].blue
ca = (i.colorAlpha!=nil) ? oldfo[3].alpha+(i.colorAlpha-oldfo[3].alpha)*fraction : oldfo[3].alpha
foGraphic.color = Color.new(cr,cg,cb,ca)
next if !i.duration || i.duration <= 0
next if frame < i.frame || frame > i.frame + i.duration
fraction = (frame - i.frame).to_f / i.duration
if foGraphic.bitmap != nil
foGraphic.ox = oldfo[0] - (i.bgX - oldfo[0]) * fraction if i.bgX != nil
foGraphic.oy = oldfo[1] - (i.bgY - oldfo[1]) * fraction if i.bgY != nil
foGraphic.opacity = oldfo[2] + (i.opacity - oldfo[2]) * fraction if i.opacity != nil
cr = (i.colorRed != nil) ? oldfo[3].red + (i.colorRed - oldfo[3].red) * fraction : oldfo[3].red
cg = (i.colorGreen != nil) ? oldfo[3].green + (i.colorGreen - oldfo[3].green) * fraction : oldfo[3].green
cb = (i.colorBlue != nil) ? oldfo[3].blue + (i.colorBlue - oldfo[3].blue) * fraction : oldfo[3].blue
ca = (i.colorAlpha != nil) ? oldfo[3].alpha + (i.colorAlpha - oldfo[3].alpha) * fraction : oldfo[3].alpha
foGraphic.color = Color.new(cr, cg, cb, ca)
else
foColor.opacity = oldfo[2]+(i.opacity-oldfo[2])*fraction if i.opacity!=nil
cr = (i.colorRed!=nil) ? oldfo[3].red+(i.colorRed-oldfo[3].red)*fraction : oldfo[3].red
cg = (i.colorGreen!=nil) ? oldfo[3].green+(i.colorGreen-oldfo[3].green)*fraction : oldfo[3].green
cb = (i.colorBlue!=nil) ? oldfo[3].blue+(i.colorBlue-oldfo[3].blue)*fraction : oldfo[3].blue
ca = (i.colorAlpha!=nil) ? oldfo[3].alpha+(i.colorAlpha-oldfo[3].alpha)*fraction : oldfo[3].alpha
foColor.color = Color.new(cr,cg,cb,ca)
foColor.opacity = oldfo[2] + (i.opacity - oldfo[2]) * fraction if i.opacity != nil
cr = (i.colorRed != nil) ? oldfo[3].red + (i.colorRed - oldfo[3].red) * fraction : oldfo[3].red
cg = (i.colorGreen != nil) ? oldfo[3].green + (i.colorGreen - oldfo[3].green) * fraction : oldfo[3].green
cb = (i.colorBlue != nil) ? oldfo[3].blue + (i.colorBlue - oldfo[3].blue) * fraction : oldfo[3].blue
ca = (i.colorAlpha != nil) ? oldfo[3].alpha + (i.colorAlpha - oldfo[3].alpha) * fraction : oldfo[3].alpha
foColor.color = Color.new(cr, cg, cb, ca)
end
end
end
@@ -617,35 +617,35 @@ end
#===============================================================================
#
#===============================================================================
def pbSpriteSetAnimFrame(sprite,frame,user = nil,target = nil,inEditor = false)
def pbSpriteSetAnimFrame(sprite, frame, user = nil, target = nil, inEditor = false)
return if !sprite
if !frame
sprite.visible = false
sprite.src_rect = Rect.new(0,0,1,1)
sprite.src_rect = Rect.new(0, 0, 1, 1)
return
end
sprite.blend_type = frame[AnimFrame::BLENDTYPE]
sprite.angle = frame[AnimFrame::ANGLE]
sprite.mirror = (frame[AnimFrame::MIRROR]>0)
sprite.mirror = (frame[AnimFrame::MIRROR] > 0)
sprite.opacity = frame[AnimFrame::OPACITY]
sprite.visible = true
if !frame[AnimFrame::VISIBLE]==1 && inEditor
sprite.opacity /= 2
if !frame[AnimFrame::VISIBLE] == 1 && inEditor
sprite.opacity /= 2
else
sprite.visible = (frame[AnimFrame::VISIBLE]==1)
sprite.visible = (frame[AnimFrame::VISIBLE] == 1)
end
pattern = frame[AnimFrame::PATTERN]
if pattern>=0
if pattern >= 0
animwidth = 192
sprite.src_rect.set((pattern%5)*animwidth,(pattern/5)*animwidth,
animwidth,animwidth)
sprite.src_rect.set((pattern % 5) * animwidth, (pattern / 5) * animwidth,
animwidth, animwidth)
else
sprite.src_rect.set(0,0,
sprite.src_rect.set(0, 0,
(sprite.bitmap) ? sprite.bitmap.width : 128,
(sprite.bitmap) ? sprite.bitmap.height : 128)
end
sprite.zoom_x = frame[AnimFrame::ZOOMX]/100.0
sprite.zoom_y = frame[AnimFrame::ZOOMY]/100.0
sprite.zoom_x = frame[AnimFrame::ZOOMX] / 100.0
sprite.zoom_y = frame[AnimFrame::ZOOMY] / 100.0
sprite.color.set(
frame[AnimFrame::COLORRED],
frame[AnimFrame::COLORGREEN],
@@ -658,11 +658,11 @@ def pbSpriteSetAnimFrame(sprite,frame,user = nil,target = nil,inEditor = false)
frame[AnimFrame::TONEBLUE],
frame[AnimFrame::TONEGRAY]
)
sprite.ox = sprite.src_rect.width/2
sprite.oy = sprite.src_rect.height/2
sprite.ox = sprite.src_rect.width / 2
sprite.oy = sprite.src_rect.height / 2
sprite.x = frame[AnimFrame::X]
sprite.y = frame[AnimFrame::Y]
if sprite!=user && sprite!=target
if sprite != user && sprite != target
case frame[AnimFrame::PRIORITY]
when 0 # Behind everything
sprite.z = 10
@@ -671,18 +671,18 @@ def pbSpriteSetAnimFrame(sprite,frame,user = nil,target = nil,inEditor = false)
when 2 # Just behind focus
case frame[AnimFrame::FOCUS]
when 1 # Focused on target
sprite.z = (target) ? target.z-1 : 20
sprite.z = (target) ? target.z - 1 : 20
when 2 # Focused on user
sprite.z = (user) ? user.z-1 : 20
sprite.z = (user) ? user.z - 1 : 20
else # Focused on user and target, or screen
sprite.z = 20
end
when 3 # Just in front of focus
case frame[AnimFrame::FOCUS]
when 1 # Focused on target
sprite.z = (target) ? target.z+1 : 80
sprite.z = (target) ? target.z + 1 : 80
when 2 # Focused on user
sprite.z = (user) ? user.z+1 : 80
sprite.z = (user) ? user.z + 1 : 80
else # Focused on user and target, or screen
sprite.z = 80
end
@@ -702,7 +702,7 @@ class PBAnimationPlayerX
MAX_SPRITES = 60
def initialize(animation,user,target,scene = nil,oppMove = false,inEditor = false)
def initialize(animation, user, target, scene = nil, oppMove = false, inEditor = false)
@animation = animation
@user = (oppMove) ? target : user # Just used for playing user's cry
@usersprite = (user) ? scene.sprites["pokemon_#{user.index}"] : nil
@@ -715,7 +715,7 @@ class PBAnimationPlayerX
@looping = false
@animbitmap = nil # Animation sheet graphic
@frame = -1
@framesPerTick = [Graphics.frame_rate/20,1].max # 20 ticks per second
@framesPerTick = [Graphics.frame_rate / 20, 1].max # 20 ticks per second
@srcLine = nil
@dstLine = nil
@userOrig = getSpriteCenter(@usersprite)
@@ -727,7 +727,7 @@ class PBAnimationPlayerX
def initializeSprites
# Create animation sprites (0=user's sprite, 1=target's sprite)
@animsprites = []
@animsprites = []
@animsprites[0] = @usersprite
@animsprites[1] = @targetsprite
for i in 2...MAX_SPRITES
@@ -736,7 +736,7 @@ class PBAnimationPlayerX
@animsprites[i].visible = false
end
# Create background colour sprite
@bgColor = ColoredPlane.new(Color.new(0,0,0),@viewport)
@bgColor = ColoredPlane.new(Color.new(0, 0, 0), @viewport)
@bgColor.borderX = 64 if @inEditor
@bgColor.borderY = 64 if @inEditor
@bgColor.z = 5
@@ -751,7 +751,7 @@ class PBAnimationPlayerX
@bgGraphic.opacity = 0
@bgGraphic.refresh
# Create foreground colour sprite
@foColor = ColoredPlane.new(Color.new(0,0,0),@viewport)
@foColor = ColoredPlane.new(Color.new(0, 0, 0), @viewport)
@foColor.borderX = 64 if @inEditor
@foColor.borderY = 64 if @inEditor
@foColor.z = 85
@@ -783,22 +783,22 @@ class PBAnimationPlayerX
end
def animDone?
return @frame<0
return @frame < 0
end
def setLineTransform(x1,y1,x2,y2,x3,y3,x4,y4)
@srcLine = [x1,y1,x2,y2]
@dstLine = [x3,y3,x4,y4]
def setLineTransform(x1, y1, x2, y2, x3, y3, x4, y4)
@srcLine = [x1, y1, x2, y2]
@dstLine = [x3, y3, x4, y4]
end
def update
return if @frame<0
animFrame = @frame/@framesPerTick
return if @frame < 0
animFrame = @frame / @framesPerTick
# Loop or end the animation if the animation has reached the end
if animFrame >= @animation.length
@frame = (@looping) ? 0 : -1
if @frame<0
if @frame < 0
@animbitmap.dispose if @animbitmap
@animbitmap = nil
return
@@ -806,7 +806,7 @@ class PBAnimationPlayerX
end
# Load the animation's spritesheet and assign it to all the sprites.
if !@animbitmap || @animbitmap.disposed?
@animbitmap = AnimatedBitmap.new("Graphics/Animations/"+@animation.graphic,
@animbitmap = AnimatedBitmap.new("Graphics/Animations/" + @animation.graphic,
@animation.hue).deanimate
for i in 0...MAX_SPRITES
@animsprites[i].bitmap = @animbitmap if @animsprites[i]
@@ -819,7 +819,7 @@ class PBAnimationPlayerX
@foColor.update
# Update all the sprites to depict the animation's next frame
if @framesPerTick==1 || (@frame%@framesPerTick)==0
if @framesPerTick == 1 || (@frame % @framesPerTick) == 0
thisframe = @animation[animFrame]
# Make all cel sprites invisible
for i in 0...MAX_SPRITES
@@ -841,7 +841,7 @@ class PBAnimationPlayerX
sprite.bitmap = @animbitmap
end
# Apply settings to the cel sprite
pbSpriteSetAnimFrame(sprite,cel,@usersprite,@targetsprite)
pbSpriteSetAnimFrame(sprite, cel, @usersprite, @targetsprite)
case cel[AnimFrame::FOCUS]
when 1 # Focused on target
sprite.x = cel[AnimFrame::X] + @targetOrig[0] - Battle::Scene::FOCUSTARGET_X
@@ -852,13 +852,13 @@ class PBAnimationPlayerX
when 3 # Focused on user and target
next if !@srcLine || !@dstLine
point = transformPoint(
@srcLine[0],@srcLine[1],@srcLine[2],@srcLine[3],
@dstLine[0],@dstLine[1],@dstLine[2],@dstLine[3],
sprite.x,sprite.y)
@srcLine[0], @srcLine[1], @srcLine[2], @srcLine[3],
@dstLine[0], @dstLine[1], @dstLine[2], @dstLine[3],
sprite.x, sprite.y)
sprite.x = point[0]
sprite.y = point[1]
if isReversed(@srcLine[0],@srcLine[2],@dstLine[0],@dstLine[2]) &&
cel[AnimFrame::PATTERN]>=0
if isReversed(@srcLine[0], @srcLine[2], @dstLine[0], @dstLine[2]) &&
cel[AnimFrame::PATTERN] >= 0
# Reverse direction
sprite.mirror = !sprite.mirror
end
@@ -867,7 +867,7 @@ class PBAnimationPlayerX
sprite.y += 64 if @inEditor
end
# Play timings
@animation.playTiming(animFrame,@bgGraphic,@bgColor,@foGraphic,@foColor,@oldbg,@oldfo,@user)
@animation.playTiming(animFrame, @bgGraphic, @bgColor, @foGraphic, @foColor, @oldbg, @oldfo, @user)
end
@frame += 1
end

View File

@@ -7,7 +7,7 @@ class Battle::FakeBattler
attr_reader :pokemon
attr_reader :owned
def initialize(battle,index)
def initialize(battle, index)
@battle = battle
@pokemon = battle.party2[0]
@index = index
@@ -43,12 +43,12 @@ class Battle::FakeBattler
end
def pbThis(lowerCase = false)
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
def opposes?(i)
i = i.index if i.is_a?(Battle::FakeBattler)
return (@index&1)!=(i&1)
return (@index & 1) != (i & 1)
end
def pbReset; end
@@ -62,14 +62,14 @@ end
class Battle::Scene::SafariDataBox < SpriteWrapper
attr_accessor :selected
def initialize(battle,viewport = nil)
def initialize(battle, viewport = nil)
super(viewport)
@selected = 0
@battle = battle
@databox = AnimatedBitmap.new("Graphics/Pictures/Battle/databox_safari")
self.x = Graphics.width - 232
self.y = Graphics.height - 184
@contents = BitmapWrapper.new(@databox.width,@databox.height)
@contents = BitmapWrapper.new(@databox.width, @databox.height)
self.bitmap = @contents
self.visible = false
self.z = 50
@@ -79,13 +79,13 @@ class Battle::Scene::SafariDataBox < SpriteWrapper
def refresh
self.bitmap.clear
self.bitmap.blt(0,0,@databox.bitmap,Rect.new(0,0,@databox.width,@databox.height))
base = Color.new(72,72,72)
shadow = Color.new(184,184,184)
self.bitmap.blt(0, 0, @databox.bitmap, Rect.new(0, 0, @databox.width, @databox.height))
base = Color.new(72, 72, 72)
shadow = Color.new(184, 184, 184)
textpos = []
textpos.push([_INTL("Safari Balls"),30,2,false,base,shadow])
textpos.push([_INTL("Left: {1}",@battle.ballCount),30,32,false,base,shadow])
pbDrawTextPositions(self.bitmap,textpos)
textpos.push([_INTL("Safari Balls"), 30, 2, false, base, shadow])
textpos.push([_INTL("Left: {1}", @battle.ballCount), 30, 32, false, base, shadow])
pbDrawTextPositions(self.bitmap, textpos)
end
def update(frameCounter = 0)
@@ -101,59 +101,59 @@ end
class Battle::Scene::Animation::ThrowBait < Battle::Scene::Animation
include Battle::Scene::Animation::BallAnimationMixin
def initialize(sprites,viewport,battler)
def initialize(sprites, viewport, battler)
@battler = battler
@trainer = battler.battle.pbGetOwnerFromBattlerIndex(battler.index)
super(sprites,viewport)
super(sprites, viewport)
end
def createProcesses
# Calculate start and end coordinates for battler sprite movement
batSprite = @sprites["pokemon_#{@battler.index}"]
traSprite = @sprites["player_1"]
ballPos = Battle::Scene.pbBattlerPosition(@battler.index,batSprite.sideSize)
ballPos = Battle::Scene.pbBattlerPosition(@battler.index, batSprite.sideSize)
ballStartX = traSprite.x
ballStartY = traSprite.y-traSprite.bitmap.height/2
ballStartY = traSprite.y - traSprite.bitmap.height / 2
ballMidX = 0 # Unused in arc calculation
ballMidY = 122
ballEndX = ballPos[0]-40
ballEndY = ballPos[1]-4
ballEndX = ballPos[0] - 40
ballEndY = ballPos[1] - 4
# Set up trainer sprite
trainer = addSprite(traSprite,PictureOrigin::Bottom)
trainer = addSprite(traSprite, PictureOrigin::Bottom)
# Set up bait sprite
ball = addNewSprite(ballStartX,ballStartY,
"Graphics/Battle animations/safari_bait",PictureOrigin::Center)
ball.setZ(0,batSprite.z+1)
ball = addNewSprite(ballStartX, ballStartY,
"Graphics/Battle animations/safari_bait", PictureOrigin::Center)
ball.setZ(0, batSprite.z + 1)
# Trainer animation
if traSprite.bitmap.width>=traSprite.bitmap.height*2
ballStartX, ballStartY = trainerThrowingFrames(ball,trainer,traSprite)
if traSprite.bitmap.width >= traSprite.bitmap.height * 2
ballStartX, ballStartY = trainerThrowingFrames(ball, trainer, traSprite)
end
delay = ball.totalDuration # 0 or 7
# Bait arc animation
ball.setSE(delay,"Battle throw")
createBallTrajectory(ball,delay,12,
ballStartX,ballStartY,ballMidX,ballMidY,ballEndX,ballEndY)
ball.setZ(9,batSprite.z+1)
ball.setSE(delay, "Battle throw")
createBallTrajectory(ball, delay, 12,
ballStartX, ballStartY, ballMidX, ballMidY, ballEndX, ballEndY)
ball.setZ(9, batSprite.z + 1)
delay = ball.totalDuration
ball.moveOpacity(delay+8,2,0)
ball.setVisible(delay+10,false)
ball.moveOpacity(delay + 8, 2, 0)
ball.setVisible(delay + 10, false)
# Set up battler sprite
battler = addSprite(batSprite,PictureOrigin::Bottom)
battler = addSprite(batSprite, PictureOrigin::Bottom)
# Show Pokémon jumping before eating the bait
delay = ball.totalDuration+3
delay = ball.totalDuration + 3
2.times do
battler.setSE(delay,"player jump")
battler.moveDelta(delay,3,0,-16)
battler.moveDelta(delay+4,3,0,16)
delay = battler.totalDuration+1
battler.setSE(delay, "player jump")
battler.moveDelta(delay, 3, 0, -16)
battler.moveDelta(delay + 4, 3, 0, 16)
delay = battler.totalDuration + 1
end
# Show Pokémon eating the bait
delay = battler.totalDuration+3
delay = battler.totalDuration + 3
2.times do
battler.moveAngle(delay,7,5)
battler.moveDelta(delay,7,0,6)
battler.moveAngle(delay+7,7,0)
battler.moveDelta(delay+7,7,0,-6)
battler.moveAngle(delay, 7, 5)
battler.moveDelta(delay, 7, 0, 6)
battler.moveAngle(delay + 7, 7, 0)
battler.moveDelta(delay + 7, 7, 0, -6)
delay = battler.totalDuration
end
end
@@ -167,10 +167,10 @@ end
class Battle::Scene::Animation::ThrowRock < Battle::Scene::Animation
include Battle::Scene::Animation::BallAnimationMixin
def initialize(sprites,viewport,battler)
def initialize(sprites, viewport, battler)
@battler = battler
@trainer = battler.battle.pbGetOwnerFromBattlerIndex(battler.index)
super(sprites,viewport)
super(sprites, viewport)
end
def createProcesses
@@ -178,46 +178,46 @@ class Battle::Scene::Animation::ThrowRock < Battle::Scene::Animation
batSprite = @sprites["pokemon_#{@battler.index}"]
traSprite = @sprites["player_1"]
ballStartX = traSprite.x
ballStartY = traSprite.y-traSprite.bitmap.height/2
ballStartY = traSprite.y - traSprite.bitmap.height / 2
ballMidX = 0 # Unused in arc calculation
ballMidY = 122
ballEndX = batSprite.x
ballEndY = batSprite.y-batSprite.bitmap.height/2
ballEndY = batSprite.y - batSprite.bitmap.height / 2
# Set up trainer sprite
trainer = addSprite(traSprite,PictureOrigin::Bottom)
trainer = addSprite(traSprite, PictureOrigin::Bottom)
# Set up bait sprite
ball = addNewSprite(ballStartX,ballStartY,
"Graphics/Battle animations/safari_rock",PictureOrigin::Center)
ball.setZ(0,batSprite.z+1)
ball = addNewSprite(ballStartX, ballStartY,
"Graphics/Battle animations/safari_rock", PictureOrigin::Center)
ball.setZ(0, batSprite.z + 1)
# Trainer animation
if traSprite.bitmap.width>=traSprite.bitmap.height*2
ballStartX, ballStartY = trainerThrowingFrames(ball,trainer,traSprite)
if traSprite.bitmap.width >= traSprite.bitmap.height * 2
ballStartX, ballStartY = trainerThrowingFrames(ball, trainer, traSprite)
end
delay = ball.totalDuration # 0 or 7
# Bait arc animation
ball.setSE(delay,"Battle throw")
createBallTrajectory(ball,delay,12,
ballStartX,ballStartY,ballMidX,ballMidY,ballEndX,ballEndY)
ball.setZ(9,batSprite.z+1)
ball.setSE(delay, "Battle throw")
createBallTrajectory(ball, delay, 12,
ballStartX, ballStartY, ballMidX, ballMidY, ballEndX, ballEndY)
ball.setZ(9, batSprite.z + 1)
delay = ball.totalDuration
ball.setSE(delay,"Battle damage weak")
ball.moveOpacity(delay+2,2,0)
ball.setVisible(delay+4,false)
ball.setSE(delay, "Battle damage weak")
ball.moveOpacity(delay + 2, 2, 0)
ball.setVisible(delay + 4, false)
# Set up anger sprite
anger = addNewSprite(ballEndX-42,ballEndY-36,
"Graphics/Battle animations/safari_anger",PictureOrigin::Center)
anger.setVisible(0,false)
anger.setZ(0,batSprite.z+1)
anger = addNewSprite(ballEndX - 42, ballEndY - 36,
"Graphics/Battle animations/safari_anger", PictureOrigin::Center)
anger.setVisible(0, false)
anger.setZ(0, batSprite.z + 1)
# Show anger appearing
delay = ball.totalDuration+5
delay = ball.totalDuration + 5
2.times do
anger.setSE(delay,"Player jump")
anger.setVisible(delay,true)
anger.moveZoom(delay,3,130)
anger.moveZoom(delay+3,3,100)
anger.setVisible(delay+6,false)
anger.setDelta(delay+6,96,-16)
delay = anger.totalDuration+3
anger.setSE(delay, "Player jump")
anger.setVisible(delay, true)
anger.moveZoom(delay, 3, 130)
anger.moveZoom(delay + 3, 3, 100)
anger.setVisible(delay + 6, false)
anger.setDelta(delay + 6, 96, -16)
delay = anger.totalDuration + 3
end
end
end
@@ -230,8 +230,8 @@ end
class Battle::Scene
def pbSafariStart
@briefMessage = false
@sprites["dataBox_0"] = SafariDataBox.new(@battle,@viewport)
dataBoxAnim = Animation::DataBoxAppear.new(@sprites,@viewport,0)
@sprites["dataBox_0"] = SafariDataBox.new(@battle, @viewport)
dataBoxAnim = Animation::DataBoxAppear.new(@sprites, @viewport, 0)
loop do
dataBoxAnim.update
pbUpdate
@@ -242,18 +242,18 @@ class Battle::Scene
end
def pbSafariCommandMenu(index)
pbCommandMenuEx(index,[
_INTL("What will\n{1} throw?",@battle.pbPlayer.name),
pbCommandMenuEx(index, [
_INTL("What will\n{1} throw?", @battle.pbPlayer.name),
_INTL("Ball"),
_INTL("Bait"),
_INTL("Rock"),
_INTL("Run")
],3)
], 3)
end
def pbThrowBait
@briefMessage = false
baitAnim = Animation::ThrowBait.new(@sprites,@viewport,@battle.battlers[1])
baitAnim = Animation::ThrowBait.new(@sprites, @viewport, @battle.battlers[1])
loop do
baitAnim.update
pbUpdate
@@ -264,7 +264,7 @@ class Battle::Scene
def pbThrowRock
@briefMessage = false
rockAnim = Animation::ThrowRock.new(@sprites,@viewport,@battle.battlers[1])
rockAnim = Animation::ThrowRock.new(@sprites, @viewport, @battle.battlers[1])
loop do
rockAnim.update
pbUpdate
@@ -311,7 +311,7 @@ class SafariBattle
#=============================================================================
# Initialize the battle class
#=============================================================================
def initialize(scene,player,party2)
def initialize(scene, player, party2)
@scene = scene
@peer = Battle::Peer.new
@backdrop = ""
@@ -323,10 +323,10 @@ class SafariBattle
@caughtPokemon = []
@player = [player]
@party2 = party2
@sideSizes = [1,1]
@sideSizes = [1, 1]
@battlers = [
Battle::FakeBattler.new(self,0),
Battle::FakeBattler.new(self,1)
Battle::FakeBattler.new(self, 0),
Battle::FakeBattler.new(self, 1)
]
@rules = {}
@ballCount = 0
@@ -344,7 +344,7 @@ class SafariBattle
def setBattleMode(mode); end
def pbSideSize(index)
return @sideSizes[index%2]
return @sideSizes[index % 2]
end
#=============================================================================
@@ -386,28 +386,28 @@ class SafariBattle
#=============================================================================
# Battler-related
#=============================================================================
def opposes?(idxBattler1,idxBattler2 = 0)
def opposes?(idxBattler1, idxBattler2 = 0)
idxBattler1 = idxBattler1.index if idxBattler1.respond_to?("index")
idxBattler2 = idxBattler2.index if idxBattler2.respond_to?("index")
return (idxBattler1&1)!=(idxBattler2&1)
return (idxBattler1 & 1) != (idxBattler2 & 1)
end
def pbRemoveFromParty(idxBattler,idxParty); end
def pbRemoveFromParty(idxBattler, idxParty); end
def pbGainExp; end
#=============================================================================
# Messages and animations
#=============================================================================
def pbDisplay(msg,&block)
@scene.pbDisplayMessage(msg,&block)
def pbDisplay(msg, &block)
@scene.pbDisplayMessage(msg, &block)
end
def pbDisplayPaused(msg,&block)
@scene.pbDisplayPausedMessage(msg,&block)
def pbDisplayPaused(msg, &block)
@scene.pbDisplayPausedMessage(msg, &block)
end
def pbDisplayBrief(msg)
@scene.pbDisplayMessage(msg,true)
@scene.pbDisplayMessage(msg, true)
end
def pbDisplayConfirm(msg)
@@ -438,16 +438,16 @@ class SafariBattle
pkmn = @party2[0]
pbSetSeen(pkmn)
@scene.pbStartBattle(self)
pbDisplayPaused(_INTL("Wild {1} appeared!",pkmn.name))
pbDisplayPaused(_INTL("Wild {1} appeared!", pkmn.name))
@scene.pbSafariStart
weather_data = GameData::BattleWeather.try_get(@weather)
@scene.pbCommonAnimation(weather_data.animation) if weather_data
safariBall = GameData::Item.get(:SAFARIBALL).id
catch_rate = pkmn.species_data.catch_rate
catchFactor = (catch_rate*100)/1275
catchFactor = [[catchFactor,3].max,20].min
escapeFactor = (pbEscapeRate(catch_rate)*100)/1275
escapeFactor = [[escapeFactor,2].max,20].min
catchFactor = (catch_rate * 100) / 1275
catchFactor = [[catchFactor, 3].max, 20].min
escapeFactor = (pbEscapeRate(catch_rate) * 100) / 1275
escapeFactor = [[escapeFactor, 2].max, 20].min
loop do
cmd = @scene.pbSafariCommandMenu(0)
case cmd
@@ -458,46 +458,46 @@ class SafariBattle
end
@ballCount -= 1
@scene.pbRefresh
rare = (catchFactor*1275)/100
rare = (catchFactor * 1275) / 100
if safariBall
pbThrowPokeBall(1,safariBall,rare,true)
if @caughtPokemon.length>0
pbThrowPokeBall(1, safariBall, rare, true)
if @caughtPokemon.length > 0
pbRecordAndStoreCaughtPokemon
@decision = 4
end
end
when 1 # Bait
pbDisplayBrief(_INTL("{1} threw some bait at the {2}!",self.pbPlayer.name,pkmn.name))
pbDisplayBrief(_INTL("{1} threw some bait at the {2}!", self.pbPlayer.name, pkmn.name))
@scene.pbThrowBait
catchFactor /= 2 if pbRandom(100)<90 # Harder to catch
catchFactor /= 2 if pbRandom(100) < 90 # Harder to catch
escapeFactor /= 2 # Less likely to escape
when 2 # Rock
pbDisplayBrief(_INTL("{1} threw a rock at the {2}!",self.pbPlayer.name,pkmn.name))
pbDisplayBrief(_INTL("{1} threw a rock at the {2}!", self.pbPlayer.name, pkmn.name))
@scene.pbThrowRock
catchFactor *= 2 # Easier to catch
escapeFactor *= 2 if pbRandom(100)<90 # More likely to escape
escapeFactor *= 2 if pbRandom(100) < 90 # More likely to escape
when 3 # Run
pbSEPlay("Battle flee")
pbDisplayPaused(_INTL("You got away safely!"))
@decision = 3
end
catchFactor = [[catchFactor,3].max,20].min
escapeFactor = [[escapeFactor,2].max,20].min
catchFactor = [[catchFactor, 3].max, 20].min
escapeFactor = [[escapeFactor, 2].max, 20].min
# End of round
if @decision==0
if @ballCount<=0
if @decision == 0
if @ballCount <= 0
pbDisplay(_INTL("PA: You have no Safari Balls left! Game over!"))
@decision = 2
elsif pbRandom(100)<5*escapeFactor
elsif pbRandom(100) < 5 * escapeFactor
pbSEPlay("Battle flee")
pbDisplay(_INTL("{1} fled!",pkmn.name))
pbDisplay(_INTL("{1} fled!", pkmn.name))
@decision = 3
elsif cmd==1 # Bait
pbDisplay(_INTL("{1} is eating!",pkmn.name))
elsif cmd==2 # Rock
pbDisplay(_INTL("{1} is angry!",pkmn.name))
elsif cmd == 1 # Bait
pbDisplay(_INTL("{1} is eating!", pkmn.name))
elsif cmd == 2 # Rock
pbDisplay(_INTL("{1} is angry!", pkmn.name))
else
pbDisplay(_INTL("{1} is watching carefully!",pkmn.name))
pbDisplay(_INTL("{1} is watching carefully!", pkmn.name))
end
# Weather continues
weather_data = GameData::BattleWeather.try_get(@weather)

View File

@@ -8,13 +8,13 @@ class Battle::Scene
_bugContest_pbInitSprites
# "helpwindow" shows the currently caught Pokémon's details when asking if
# you want to replace it with a newly caught Pokémon.
@sprites["helpwindow"] = Window_UnformattedTextPokemon.newWithSize("",0,0,32,32,@viewport)
@sprites["helpwindow"] = Window_UnformattedTextPokemon.newWithSize("", 0, 0, 32, 32, @viewport)
@sprites["helpwindow"].z = 90
@sprites["helpwindow"].visible = false
end
def pbShowHelp(text)
@sprites["helpwindow"].resizeToFit(text,Graphics.width)
@sprites["helpwindow"].resizeToFit(text, Graphics.width)
@sprites["helpwindow"].y = 0
@sprites["helpwindow"].x = 0
@sprites["helpwindow"].text = text
@@ -40,31 +40,31 @@ class BugContestBattle < Battle
super(*arg)
end
def pbItemMenu(idxBattler,_firstAction)
return pbRegisterItem(idxBattler,@ballConst,1)
def pbItemMenu(idxBattler, _firstAction)
return pbRegisterItem(idxBattler, @ballConst, 1)
end
def pbCommandMenu(idxBattler,_firstAction)
return @scene.pbCommandMenuEx(idxBattler,[
_INTL("Sport Balls: {1}",@ballCount),
def pbCommandMenu(idxBattler, _firstAction)
return @scene.pbCommandMenuEx(idxBattler, [
_INTL("Sport Balls: {1}", @ballCount),
_INTL("Fight"),
_INTL("Ball"),
_INTL("Pokémon"),
_INTL("Run")
],4)
], 4)
end
def pbConsumeItemInBag(_item,_idxBattler)
@ballCount -= 1 if @ballCount>0
def pbConsumeItemInBag(_item, _idxBattler)
@ballCount -= 1 if @ballCount > 0
end
def pbStorePokemon(pkmn)
if pbBugContestState.lastPokemon
lastPokemon = pbBugContestState.lastPokemon
pbDisplayPaused(_INTL("You already caught a {1}.",lastPokemon.name))
pbDisplayPaused(_INTL("You already caught a {1}.", lastPokemon.name))
helptext = _INTL("STOCK POKéMON:\n {1} Lv.{2} MaxHP: {3}\nTHIS POKéMON:\n {4} Lv.{5} MaxHP: {6}",
lastPokemon.name,lastPokemon.level,lastPokemon.totalhp,
pkmn.name,pkmn.level,pkmn.totalhp
lastPokemon.name, lastPokemon.level, lastPokemon.totalhp,
pkmn.name, pkmn.level, pkmn.totalhp
)
@scene.pbShowHelp(helptext)
if pbDisplayConfirm(_INTL("Switch Pokémon?"))
@@ -77,11 +77,11 @@ class BugContestBattle < Battle
else
pbBugContestState.lastPokemon = pkmn
end
pbDisplay(_INTL("Caught {1}!",pkmn.name))
pbDisplay(_INTL("Caught {1}!", pkmn.name))
end
def pbEndOfRoundPhase
super
@decision = 3 if @ballCount<=0 && @decision==0
@decision = 3 if @ballCount <= 0 && @decision == 0
end
end

View File

@@ -60,7 +60,7 @@ class BattlePalaceBattle < Battle
def initialize(*arg)
super
@justswitched = [false,false,false,false]
@justswitched = [false, false, false, false]
@battleAI.battlePalace = true
end
@@ -76,26 +76,26 @@ class BattlePalaceBattle < Battle
end
# Different implementation of pbCanChooseMove, ignores Imprison/Torment/Taunt/Disable/Encore
def pbCanChooseMovePartial?(idxPokemon,idxMove)
def pbCanChooseMovePartial?(idxPokemon, idxMove)
thispkmn = @battlers[idxPokemon]
thismove = thispkmn.moves[idxMove]
return false if !thismove
return false if thismove.pp<=0
return false if thismove.pp <= 0
if thispkmn.effects[PBEffects::ChoiceBand] &&
thismove.id!=thispkmn.effects[PBEffects::ChoiceBand] &&
thismove.id != thispkmn.effects[PBEffects::ChoiceBand] &&
thispkmn.hasActiveItem?(:CHOICEBAND)
return false
end
# though incorrect, just for convenience (actually checks Torment later)
if thispkmn.effects[PBEffects::Torment] && thispkmn.lastMoveUsed
return false if thismove.id==thispkmn.lastMoveUsed
return false if thismove.id == thispkmn.lastMoveUsed
end
return true
end
def pbRegisterMove(idxBattler,idxMove,_showMessages = true)
def pbRegisterMove(idxBattler, idxMove, _showMessages = true)
this_battler = @battlers[idxBattler]
if idxMove==-2
if idxMove == -2
@choices[idxBattler][0] = :UseMove # "Use move"
@choices[idxBattler][1] = -2 # "Incapable of using its power..."
@choices[idxBattler][2] = @struggle
@@ -117,30 +117,30 @@ class BattlePalaceBattle < Battle
defpercent = 0
if this_battler.effects[PBEffects::Pinch]
atkpercent = @@BattlePalacePinchTable[nature][0]
defpercent = atkpercent+@@BattlePalacePinchTable[nature][1]
defpercent = atkpercent + @@BattlePalacePinchTable[nature][1]
else
atkpercent = @@BattlePalaceUsualTable[nature][0]
defpercent = atkpercent+@@BattlePalaceUsualTable[nature][1]
defpercent = atkpercent + @@BattlePalaceUsualTable[nature][1]
end
if randnum<atkpercent
if randnum < atkpercent
category = 0
elsif randnum<atkpercent+defpercent
elsif randnum < atkpercent + defpercent
category = 1
else
category = 2
end
moves = []
for i in 0...this_battler.moves.length
next if !pbCanChooseMovePartial?(idxBattler,i)
next if pbMoveCategory(this_battler.moves[i])!=category
next if !pbCanChooseMovePartial?(idxBattler, i)
next if pbMoveCategory(this_battler.moves[i]) != category
moves[moves.length] = i
end
if moves.length==0
if moves.length == 0
# No moves of selected category
pbRegisterMove(idxBattler,-2)
pbRegisterMove(idxBattler, -2)
else
chosenmove = moves[@battleAI.pbAIRandom(moves.length)]
pbRegisterMove(idxBattler,chosenmove)
pbRegisterMove(idxBattler, chosenmove)
end
return true
end
@@ -182,7 +182,7 @@ class Battle::AI
def initialize(*arg)
_battlePalace_initialize(*arg)
@justswitched = [false,false,false,false]
@justswitched = [false, false, false, false]
end
alias _battlePalace_pbEnemyShouldWithdraw? pbEnemyShouldWithdraw?
@@ -191,21 +191,21 @@ class Battle::AI
return _battlePalace_pbEnemyShouldWithdraw?(idxBattler) if !@battlePalace
thispkmn = @battle.battlers[idxBattler]
shouldswitch = false
if thispkmn.effects[PBEffects::PerishSong]==1
if thispkmn.effects[PBEffects::PerishSong] == 1
shouldswitch = true
elsif !@battle.pbCanChooseAnyMove?(idxBattler) &&
thispkmn.turnCount && thispkmn.turnCount>5
thispkmn.turnCount && thispkmn.turnCount > 5
shouldswitch = true
else
hppercent = thispkmn.hp*100/thispkmn.totalhp
hppercent = thispkmn.hp * 100 / thispkmn.totalhp
percents = []
maxindex = -1
maxpercent = 0
factor = 0
@battle.pbParty(idxBattler).each_with_index do |pkmn,i|
if @battle.pbCanSwitch?(idxBattler,i)
percents[i] = 100*pkmn.hp/pkmn.totalhp
if percents[i]>maxpercent
@battle.pbParty(idxBattler).each_with_index do |pkmn, i|
if @battle.pbCanSwitch?(idxBattler, i)
percents[i] = 100 * pkmn.hp / pkmn.totalhp
if percents[i] > maxpercent
maxindex = i
maxpercent = percents[i]
end
@@ -213,11 +213,11 @@ class Battle::AI
percents[i] = 0
end
end
if hppercent<50
factor = (maxpercent<hppercent) ? 20 : 40
if hppercent < 50
factor = (maxpercent < hppercent) ? 20 : 40
end
if hppercent<25
factor = (maxpercent<hppercent) ? 30 : 50
if hppercent < 25
factor = (maxpercent < hppercent) ? 30 : 50
end
case thispkmn.status
when :SLEEP, :FROZEN
@@ -229,19 +229,19 @@ class Battle::AI
end
if @justswitched[idxBattler]
factor -= 60
factor = 0 if factor<0
factor = 0 if factor < 0
end
shouldswitch = (pbAIRandom(100)<factor)
if shouldswitch && maxindex>=0
@battle.pbRegisterSwitch(idxBattler,maxindex)
shouldswitch = (pbAIRandom(100) < factor)
if shouldswitch && maxindex >= 0
@battle.pbRegisterSwitch(idxBattler, maxindex)
return true
end
end
@justswitched[idxBattler] = shouldswitch
if shouldswitch
@battle.pbParty(idxBattler).each_with_index do |_pkmn,i|
next if !@battle.pbCanSwitch?(idxBattler,i)
@battle.pbRegisterSwitch(idxBattler,i)
@battle.pbParty(idxBattler).each_with_index do |_pkmn, i|
next if !@battle.pbCanSwitch?(idxBattler, i)
@battle.pbRegisterSwitch(idxBattler, i)
return true
end
end

View File

@@ -17,9 +17,9 @@ class Battle::SuccessState
end
def updateSkill
if @useState==1
if @useState == 1
@skill = -2 if !@protected
elsif @useState==2
elsif @useState == 2
if Effectiveness.super_effective?(@typeMod)
@skill = 2
elsif Effectiveness.normal?(@typeMod)
@@ -43,33 +43,33 @@ class BattleArenaBattle < Battle
def initialize(*arg)
super
@battlersChanged = true
@mind = [0,0]
@skill = [0,0]
@starthp = [0,0]
@mind = [0, 0]
@skill = [0, 0]
@starthp = [0, 0]
@count = 0
@partyindexes = [0,0]
@partyindexes = [0, 0]
@battleAI.battleArena = true
end
def pbCanSwitchLax?(idxBattler,_idxParty,partyScene = nil)
def pbCanSwitchLax?(idxBattler, _idxParty, partyScene = nil)
if partyScene
partyScene.pbDisplay(_INTL("{1} can't be switched out!",@battlers[idxBattler].pbThis))
partyScene.pbDisplay(_INTL("{1} can't be switched out!", @battlers[idxBattler].pbThis))
end
return false
end
def pbEORSwitch(favorDraws = false)
return if favorDraws && @decision==5
return if !favorDraws && @decision>0
return if favorDraws && @decision == 5
return if !favorDraws && @decision > 0
pbJudge
return if @decision>0
return if @decision > 0
for side in 0...2
next if !@battlers[side].fainted?
next if @partyindexes[side]+1>=self.pbParty(side).length
next if @partyindexes[side] + 1 >= self.pbParty(side).length
@partyindexes[side] += 1
newpoke = @partyindexes[side]
pbMessagesOnReplace(side,newpoke)
pbReplace(side,newpoke)
pbMessagesOnReplace(side, newpoke)
pbReplace(side, newpoke)
pbOnBattlerEnteringBattle(side)
end
end
@@ -97,14 +97,14 @@ class BattleArenaBattle < Battle
end
def pbMindScore(move)
if move.function=="ProtectUser" || # Detect/Protect
move.function=="UserEnduresFaintingThisTurn" || # Endure
move.function=="FlinchTargetFailsIfNotUserFirstTurn" # Fake Out
if move.function == "ProtectUser" || # Detect/Protect
move.function == "UserEnduresFaintingThisTurn" || # Endure
move.function == "FlinchTargetFailsIfNotUserFirstTurn" # Fake Out
return -1
end
if move.function=="CounterPhysicalDamage" || # Counter
move.function=="CounterSpecialDamage" || # Mirror Coat
move.function=="MultiTurnAttackBideThenReturnDoubleDamage" # Bide
if move.function == "CounterPhysicalDamage" || # Counter
move.function == "CounterSpecialDamage" || # Mirror Coat
move.function == "MultiTurnAttackBideThenReturnDoubleDamage" # Bide
return 0
end
return 0 if move.statusMove?
@@ -113,16 +113,16 @@ class BattleArenaBattle < Battle
def pbCommandPhase
if @battlersChanged
@scene.pbBattleArenaBattlers(@battlers[0],@battlers[1])
@scene.pbBattleArenaBattlers(@battlers[0], @battlers[1])
@battlersChanged = false
@count = 0
end
super
return if @decision!=0
return if @decision != 0
# Update mind rating (asserting that a move was chosen)
# TODO: Actually done at Pokémon's turn
for side in 0...2
if @choices[side][2] && @choices[side][0]==:UseMove
if @choices[side][2] && @choices[side][0] == :UseMove
@mind[side] += pbMindScore(@choices[side][2])
end
end
@@ -230,7 +230,7 @@ class Battle::Scene
pbGraphicsUpdate
end
def updateJudgment(window,phase,battler1,battler2,ratings1,ratings2)
def updateJudgment(window, phase, battler1, battler2, ratings1, ratings2)
total1 = 0
total2 = 0
for i in 0...phase
@@ -240,50 +240,50 @@ class Battle::Scene
window.contents.clear
pbSetSystemFont(window.contents)
textpos = [
[battler1.name,64,-6,2,Color.new(248,0,0),Color.new(208,208,200)],
[_INTL("VS"),144,-6,2,Color.new(72,72,72),Color.new(208,208,200)],
[battler2.name,224,-6,2,Color.new(72,72,72),Color.new(208,208,200)],
[_INTL("Mind"),144,42,2,Color.new(72,72,72),Color.new(208,208,200)],
[_INTL("Skill"),144,74,2,Color.new(72,72,72),Color.new(208,208,200)],
[_INTL("Body"),144,106,2,Color.new(72,72,72),Color.new(208,208,200)],
[sprintf("%d",total1),64,154,2,Color.new(72,72,72),Color.new(208,208,200)],
[_INTL("Judgment"),144,154,2,Color.new(72,72,72),Color.new(208,208,200)],
[sprintf("%d",total2),224,154,2,Color.new(72,72,72),Color.new(208,208,200)]
[battler1.name, 64, -6, 2, Color.new(248, 0, 0), Color.new(208, 208, 200)],
[_INTL("VS"), 144, -6, 2, Color.new(72, 72, 72), Color.new(208, 208, 200)],
[battler2.name, 224, -6, 2, Color.new(72, 72, 72), Color.new(208, 208, 200)],
[_INTL("Mind"), 144, 42, 2, Color.new(72, 72, 72), Color.new(208, 208, 200)],
[_INTL("Skill"), 144, 74, 2, Color.new(72, 72, 72), Color.new(208, 208, 200)],
[_INTL("Body"), 144, 106, 2, Color.new(72, 72, 72), Color.new(208, 208, 200)],
[sprintf("%d", total1), 64, 154, 2, Color.new(72, 72, 72), Color.new(208, 208, 200)],
[_INTL("Judgment"), 144, 154, 2, Color.new(72, 72, 72), Color.new(208, 208, 200)],
[sprintf("%d", total2), 224, 154, 2, Color.new(72, 72, 72), Color.new(208, 208, 200)]
]
pbDrawTextPositions(window.contents,textpos)
pbDrawTextPositions(window.contents, textpos)
images = []
for i in 0...phase
y = [48,80,112][i]
x = (ratings1[i]==ratings2[i]) ? 64 : ((ratings1[i]>ratings2[i]) ? 0 : 32)
images.push(["Graphics/Pictures/judgment",64-16,y,x,0,32,32])
x = (ratings1[i]==ratings2[i]) ? 64 : ((ratings1[i]<ratings2[i]) ? 0 : 32)
images.push(["Graphics/Pictures/judgment",224-16,y,x,0,32,32])
y = [48, 80, 112][i]
x = (ratings1[i] == ratings2[i]) ? 64 : ((ratings1[i] > ratings2[i]) ? 0 : 32)
images.push(["Graphics/Pictures/judgment", 64 - 16, y, x, 0, 32, 32])
x = (ratings1[i] == ratings2[i]) ? 64 : ((ratings1[i] < ratings2[i]) ? 0 : 32)
images.push(["Graphics/Pictures/judgment", 224 - 16, y, x, 0, 32, 32])
end
pbDrawImagePositions(window.contents,images)
window.contents.fill_rect(16,150,256,4,Color.new(80,80,80))
pbDrawImagePositions(window.contents, images)
window.contents.fill_rect(16, 150, 256, 4, Color.new(80, 80, 80))
end
def pbBattleArenaBattlers(battler1,battler2)
def pbBattleArenaBattlers(battler1, battler2)
pbMessage(_INTL("REFEREE: {1} VS {2}!\nCommence battling!\\wtnp[20]",
battler1.name,battler2.name)) { pbBattleArenaUpdate }
battler1.name, battler2.name)) { pbBattleArenaUpdate }
end
def pbBattleArenaJudgment(battler1,battler2,ratings1,ratings2)
def pbBattleArenaJudgment(battler1, battler2, ratings1, ratings2)
msgwindow = nil
dimmingvp = nil
infowindow = nil
begin
msgwindow = pbCreateMessageWindow
dimmingvp = Viewport.new(0,0,Graphics.width,Graphics.height-msgwindow.height)
dimmingvp = Viewport.new(0, 0, Graphics.width, Graphics.height - msgwindow.height)
pbMessageDisplay(msgwindow,
_INTL("REFEREE: That's it! We will now go to judging to determine the winner!\\wtnp[20]")) {
pbBattleArenaUpdate
dimmingvp.update
}
dimmingvp.z = 99999
infowindow = SpriteWindow_Base.new(80,0,320,224)
infowindow.contents = Bitmap.new(infowindow.width-infowindow.borderX,
infowindow.height-infowindow.borderY)
infowindow = SpriteWindow_Base.new(80, 0, 320, 224)
infowindow.contents = Bitmap.new(infowindow.width - infowindow.borderX,
infowindow.height - infowindow.borderY)
infowindow.z = 99999
infowindow.visible = false
for i in 0..10
@@ -291,9 +291,9 @@ class Battle::Scene
pbInputUpdate
msgwindow.update
dimmingvp.update
dimmingvp.color = Color.new(0,0,0,i*128/10)
dimmingvp.color = Color.new(0, 0, 0, i * 128 / 10)
end
updateJudgment(infowindow,0,battler1,battler2,ratings1,ratings2)
updateJudgment(infowindow, 0, battler1, battler2, ratings1, ratings2)
infowindow.visible = true
for i in 0..10
pbGraphicsUpdate
@@ -302,21 +302,21 @@ class Battle::Scene
dimmingvp.update
infowindow.update
end
updateJudgment(infowindow,1,battler1,battler2,ratings1,ratings2)
updateJudgment(infowindow, 1, battler1, battler2, ratings1, ratings2)
pbMessageDisplay(msgwindow,
_INTL("REFEREE: Judging category 1, Mind!\nThe Pokémon showing the most guts!\\wtnp[40]")) {
pbBattleArenaUpdate
dimmingvp.update
infowindow.update
}
updateJudgment(infowindow,2,battler1,battler2,ratings1,ratings2)
updateJudgment(infowindow, 2, battler1, battler2, ratings1, ratings2)
pbMessageDisplay(msgwindow,
_INTL("REFEREE: Judging category 2, Skill!\nThe Pokémon using moves the best!\\wtnp[40]")) {
pbBattleArenaUpdate
dimmingvp.update
infowindow.update
}
updateJudgment(infowindow,3,battler1,battler2,ratings1,ratings2)
updateJudgment(infowindow, 3, battler1, battler2, ratings1, ratings2)
pbMessageDisplay(msgwindow,
_INTL("REFEREE: Judging category 3, Body!\nThe Pokémon with the most vitality!\\wtnp[40]")) {
pbBattleArenaUpdate
@@ -329,17 +329,17 @@ class Battle::Scene
total1 += ratings1[i]
total2 += ratings2[i]
end
if total1==total2
if total1 == total2
pbMessageDisplay(msgwindow,
_INTL("REFEREE: Judgment: {1} to {2}!\nWe have a draw!\\wtnp[40]",total1,total2)) {
_INTL("REFEREE: Judgment: {1} to {2}!\nWe have a draw!\\wtnp[40]", total1, total2)) {
pbBattleArenaUpdate
dimmingvp.update
infowindow.update
}
elsif total1>total2
elsif total1 > total2
pbMessageDisplay(msgwindow,
_INTL("REFEREE: Judgment: {1} to {2}!\nThe winner is {3}'s {4}!\\wtnp[40]",
total1,total2,@battle.pbGetOwnerName(battler1.index),battler1.name)) {
total1, total2, @battle.pbGetOwnerName(battler1.index), battler1.name)) {
pbBattleArenaUpdate
dimmingvp.update
infowindow.update
@@ -347,7 +347,7 @@ class Battle::Scene
else
pbMessageDisplay(msgwindow,
_INTL("REFEREE: Judgment: {1} to {2}!\nThe winner is {3}!\\wtnp[40]",
total1,total2,battler2.name)) {
total1, total2, battler2.name)) {
pbBattleArenaUpdate
dimmingvp.update
infowindow.update
@@ -360,7 +360,7 @@ class Battle::Scene
pbInputUpdate
msgwindow.update
dimmingvp.update
dimmingvp.color = Color.new(0,0,0,(10-i)*128/10)
dimmingvp.color = Color.new(0, 0, 0, (10 - i) * 128 / 10)
end
ensure
pbDisposeMessageWindow(msgwindow)

View File

@@ -31,16 +31,16 @@ module RecordedBattleModule
ret = []
for i in 0...trainer.length
if trainer[i].is_a?(Player)
ret.push([trainer[i].trainer_type,trainer[i].name.clone,trainer[i].id,trainer[i].badges.clone])
ret.push([trainer[i].trainer_type, trainer[i].name.clone, trainer[i].id, trainer[i].badges.clone])
else # NPCTrainer
ret.push([trainer[i].trainer_type,trainer[i].name.clone,trainer[i].id])
ret.push([trainer[i].trainer_type, trainer[i].name.clone, trainer[i].id])
end
end
return ret
elsif trainer[i].is_a?(Player)
return [[trainer.trainer_type,trainer.name.clone,trainer.id,trainer.badges.clone]]
return [[trainer.trainer_type, trainer.name.clone, trainer.id, trainer.badges.clone]]
else
return [[trainer.trainer_type,trainer.name.clone,trainer.id]]
return [[trainer.trainer_type, trainer.name.clone, trainer.id]]
end
end
@@ -70,51 +70,51 @@ module RecordedBattleModule
end
def pbDumpRecord
return Marshal.dump([pbGetBattleType,@properties,@rounds,@randomnumbers,@switches])
return Marshal.dump([pbGetBattleType, @properties, @rounds, @randomnumbers, @switches])
end
def pbSwitchInBetween(idxBattler,checkLaxOnly = false,canCancel = false)
def pbSwitchInBetween(idxBattler, checkLaxOnly = false, canCancel = false)
ret = super
@switches.push(ret)
return ret
end
def pbRegisterMove(idxBattler,idxMove,showMessages = true)
def pbRegisterMove(idxBattler, idxMove, showMessages = true)
if super
@rounds[@roundindex][idxBattler] = [Commands::Fight,idxMove]
@rounds[@roundindex][idxBattler] = [Commands::Fight, idxMove]
return true
end
return false
end
def pbRegisterTarget(idxBattler,idxTarget)
def pbRegisterTarget(idxBattler, idxTarget)
super
@rounds[@roundindex][idxBattler][2] = idxTarget
end
def pbRun(idxBattler,duringBattle = false)
def pbRun(idxBattler, duringBattle = false)
ret = super
@rounds[@roundindex][idxBattler] = [Commands::Run,@decision]
@rounds[@roundindex][idxBattler] = [Commands::Run, @decision]
return ret
end
def pbAutoChooseMove(idxBattler,showMessages = true)
def pbAutoChooseMove(idxBattler, showMessages = true)
ret = super
@rounds[@roundindex][idxBattler] = [Commands::Fight,-1]
@rounds[@roundindex][idxBattler] = [Commands::Fight, -1]
return ret
end
def pbRegisterSwitch(idxBattler,idxParty)
def pbRegisterSwitch(idxBattler, idxParty)
if super
@rounds[@roundindex][idxBattler] = [Commands::Pokemon,idxParty]
@rounds[@roundindex][idxBattler] = [Commands::Pokemon, idxParty]
return true
end
return false
end
def pbRegisterItem(idxBattler,item,idxTarget = nil,idxMove = nil)
def pbRegisterItem(idxBattler, item, idxTarget = nil, idxMove = nil)
if super
@rounds[@roundindex][idxBattler] = [Commands::Bag,item,idxTarget,idxMove]
@rounds[@roundindex][idxBattler] = [Commands::Bag, item, idxTarget, idxMove]
return true
end
return false
@@ -122,7 +122,7 @@ module RecordedBattleModule
def pbCommandPhase
@roundindex += 1
@rounds[@roundindex] = [[],[],[],[]]
@rounds[@roundindex] = [[], [], [], []]
super
end
@@ -146,7 +146,7 @@ module RecordedBattlePlaybackModule
Run = 3
end
def initialize(scene,battle)
def initialize(scene, battle)
@battletype = battle[0]
@properties = battle[1]
@rounds = battle[2]
@@ -183,7 +183,7 @@ module RecordedBattlePlaybackModule
super
end
def pbSwitchInBetween(_idxBattler,_checkLaxOnly = false,_canCancel = false)
def pbSwitchInBetween(_idxBattler, _checkLaxOnly = false, _canCancel = false)
ret = @switches[@switchindex]
@switchindex += 1
return ret
@@ -203,22 +203,22 @@ module RecordedBattlePlaybackModule
return if !isPlayer
@roundindex += 1
for i in 0...4
next if @rounds[@roundindex][i].length==0
next if @rounds[@roundindex][i].length == 0
pbClearChoice(i)
case @rounds[@roundindex][i][0]
when Commands::Fight
if @rounds[@roundindex][i][1]==-1
pbAutoChooseMove(i,false)
if @rounds[@roundindex][i][1] == -1
pbAutoChooseMove(i, false)
else
pbRegisterMove(i,@rounds[@roundindex][i][1])
pbRegisterMove(i, @rounds[@roundindex][i][1])
end
if @rounds[@roundindex][i][2]
pbRegisterTarget(i,@rounds[@roundindex][i][2])
pbRegisterTarget(i, @rounds[@roundindex][i][2])
end
when Commands::Bag
pbRegisterItem(i,@rounds[@roundindex][i][1],@rounds[@roundindex][i][2],@rounds[@roundindex][i][3])
pbRegisterItem(i, @rounds[@roundindex][i][1], @rounds[@roundindex][i][2], @rounds[@roundindex][i][3])
when Commands::Pokemon
pbRegisterSwitch(i,@rounds[@roundindex][i][1])
pbRegisterSwitch(i, @rounds[@roundindex][i][1])
when Commands::Run
@decision = @rounds[@roundindex][i][1]
end