mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-09 22:24:58 +00:00
Added decent spacing to all scripts thanks to Rubocop
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user