fixes download sprite option + various small fixes

This commit is contained in:
infinitefusion
2023-02-12 13:40:01 -05:00
parent d2e5828b62
commit 0b64dcb3dd

View File

@@ -12,42 +12,42 @@ class PokeBattle_Battle
p1 = pbParty(0) p1 = pbParty(0)
@battlers.each do |b| @battlers.each do |b|
next unless b && b.opposes? # Can only gain Exp from fainted foes 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 next unless b.fainted? || b.captured
# Count the number of participants # Count the number of participants
numPartic = 0 numPartic = 0
b.participants.each do |partic| 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 numPartic += 1
end end
# Find which Pokémon have an Exp Share # Find which Pokémon have an Exp Share
expShare = [] expShare = []
if !expAll if !expAll
eachInTeam(0,0) do |pkmn,i| eachInTeam(0, 0) do |pkmn, i|
next if !pkmn.able? next if !pkmn.able?
next if !pkmn.hasItem?(:EXPSHARE) && GameData::Item.try_get(@initialItems[0][i]) != :EXPSHARE next if !pkmn.hasItem?(:EXPSHARE) && GameData::Item.try_get(@initialItems[0][i]) != :EXPSHARE
expShare.push(i) expShare.push(i)
end end
end end
# Calculate EV and Exp gains for the participants # 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 # Gain EVs and Exp for participants
eachInTeam(0,0) do |pkmn,i| eachInTeam(0, 0) do |pkmn, i|
next if !pkmn.able? next if !pkmn.able?
next unless b.participants.include?(i) || expShare.include?(i) next unless b.participants.include?(i) || expShare.include?(i)
pbGainEVsOne(i,b) pbGainEVsOne(i, b)
pbGainExpOne(i,b,numPartic,expShare,expAll) pbGainExpOne(i, b, numPartic, expShare, expAll)
end end
# Gain EVs and Exp for all other Pokémon because of Exp All # Gain EVs and Exp for all other Pokémon because of Exp All
if expAll if expAll
showMessage = true showMessage = true
eachInTeam(0,0) do |pkmn,i| eachInTeam(0, 0) do |pkmn, i|
next if !pkmn.able? next if !pkmn.able?
next if b.participants.include?(i) || expShare.include?(i) next if b.participants.include?(i) || expShare.include?(i)
pbDisplayPaused(_INTL("Your party Pokémon in waiting also got Exp. Points!")) if showMessage pbDisplayPaused(_INTL("Your party Pokémon in waiting also got Exp. Points!")) if showMessage
showMessage = false showMessage = false
pbGainEVsOne(i,b) pbGainEVsOne(i, b)
pbGainExpOne(i,b,numPartic,expShare,expAll,false) pbGainExpOne(i, b, numPartic, expShare, expAll, false)
end end
end end
end end
@@ -56,18 +56,18 @@ class PokeBattle_Battle
end end
end end
def pbGainEVsOne(idxParty,defeatedBattler) def pbGainEVsOne(idxParty, defeatedBattler)
pkmn = pbParty(0)[idxParty] # The Pokémon gaining EVs from defeatedBattler pkmn = pbParty(0)[idxParty] # The Pokémon gaining EVs from defeatedBattler
evYield = defeatedBattler.pokemon.evYield evYield = defeatedBattler.pokemon.evYield
# Num of effort points pkmn already has # Num of effort points pkmn already has
evTotal = 0 evTotal = 0
GameData::Stat.each_main { |s| evTotal += pkmn.ev[s.id] } GameData::Stat.each_main { |s| evTotal += pkmn.ev[s.id] }
# Modify EV yield based on pkmn's held item # Modify EV yield based on pkmn's held item
if !BattleHandlers.triggerEVGainModifierItem(pkmn.item,pkmn,evYield) if !BattleHandlers.triggerEVGainModifierItem(pkmn.item, pkmn, evYield)
BattleHandlers.triggerEVGainModifierItem(@initialItems[0][idxParty],pkmn,evYield) BattleHandlers.triggerEVGainModifierItem(@initialItems[0][idxParty], pkmn, evYield)
end end
# Double EV gain because of Pokérus # 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 } evYield.each_key { |stat| evYield[stat] *= 2 }
end end
# Gain EVs for each stat in turn # Gain EVs for each stat in turn
@@ -89,13 +89,11 @@ class PokeBattle_Battle
end end
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 EVs from defeatedBattler pkmn = pbParty(0)[idxParty] # The Pokémon gaining EVs from defeatedBattler
growth_rate = pkmn.growth_rate growth_rate = pkmn.growth_rate
# Don't bother calculating if gainer is already at max Exp # 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 pkmn.calc_stats # To ensure new EVs still have an effect
return return
end end
@@ -104,31 +102,32 @@ class PokeBattle_Battle
level = defeatedBattler.level level = defeatedBattler.level
# Main Exp calculation # Main Exp calculation
exp = 0 exp = 0
a = level*defeatedBattler.pokemon.base_exp a = level * defeatedBattler.pokemon.base_exp
if expShare.length>0 && (isPartic || hasExpShare) if expShare.length > 0 && (isPartic || hasExpShare)
if numPartic==0 # No participants, all Exp goes to Exp Share holders if numPartic == 0 # No participants, all Exp goes to Exp Share holders
exp = a / (Settings::SPLIT_EXP_BETWEEN_GAINERS ? expShare.length : 1) exp = a / (Settings::SPLIT_EXP_BETWEEN_GAINERS ? expShare.length : 1)
elsif Settings::SPLIT_EXP_BETWEEN_GAINERS # Gain from participating and/or Exp Share elsif Settings::SPLIT_EXP_BETWEEN_GAINERS # Gain from participating and/or Exp Share
exp = a/(2*numPartic) if isPartic exp = a / (2 * numPartic) if isPartic
exp += a/(2*expShare.length) if hasExpShare exp += a / (2 * expShare.length) if hasExpShare
else # Gain from participating and/or Exp Share (Exp not split) else
exp = (isPartic) ? a : a/2 # Gain from participating and/or Exp Share (Exp not split)
exp = (isPartic) ? a : a / 2
end end
elsif isPartic # Participated in battle, no Exp Shares held by anyone elsif isPartic # Participated in battle, no Exp Shares held by anyone
exp = a / (Settings::SPLIT_EXP_BETWEEN_GAINERS ? numPartic : 1) exp = a / (Settings::SPLIT_EXP_BETWEEN_GAINERS ? numPartic : 1)
elsif expAll # Didn't participate in battle, gaining Exp due to Exp All 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 # 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. # from Gen 1, i.e. Exp isn't split between all Pokémon gaining it.
exp = a/2 exp = a / 2
end end
return if exp<=0 return if exp <= 0
# Pokémon gain more Exp from trainer battles # 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) # Scale the gained Exp based on the gainer's level (or not)
if Settings::SCALED_EXP_FORMULA if Settings::SCALED_EXP_FORMULA
exp /= 5 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 = levelAdjust ** 5
levelAdjust = Math.sqrt(levelAdjust) levelAdjust = Math.sqrt(levelAdjust)
exp *= levelAdjust exp *= levelAdjust
exp = exp.floor exp = exp.floor
@@ -142,36 +141,36 @@ class PokeBattle_Battle
pkmn.isSelfFusion? #also self fusions pkmn.isSelfFusion? #also self fusions
if isOutsider if isOutsider
if pkmn.owner.language != 0 && pkmn.owner.language != pbPlayer.language if pkmn.owner.language != 0 && pkmn.owner.language != pbPlayer.language
exp = (exp*1.7).floor exp = (exp * 1.7).floor
else else
exp = (exp*1.5).floor exp = (exp * 1.5).floor
end end
end end
# Modify Exp gain based on pkmn's held item # Modify Exp gain based on pkmn's held item
i = BattleHandlers.triggerExpGainModifierItem(pkmn.item,pkmn,exp) i = BattleHandlers.triggerExpGainModifierItem(pkmn.item, pkmn, exp)
if i<0 if i < 0
i = BattleHandlers.triggerExpGainModifierItem(@initialItems[0][idxParty],pkmn,exp) i = BattleHandlers.triggerExpGainModifierItem(@initialItems[0][idxParty], pkmn, exp)
end end
exp = i if i>=0 exp = i if i >= 0
# Make sure Exp doesn't exceed the maximum # Make sure Exp doesn't exceed the maximum
expFinal = growth_rate.add_exp(pkmn.exp, exp) expFinal = growth_rate.add_exp(pkmn.exp, exp)
expGained = expFinal-pkmn.exp expGained = expFinal - pkmn.exp
return if expGained<=0 return if expGained <= 0
# "Exp gained" message # "Exp gained" message
if showMessages if showMessages
if isOutsider 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 else
pbDisplayPaused(_INTL("{1} got {2} Exp. Points!",pkmn.name,expGained)) pbDisplayPaused(_INTL("{1} got {2} Exp. Points!", pkmn.name, expGained))
end end
end end
curLevel = pkmn.level curLevel = pkmn.level
newLevel = growth_rate.level_from_exp(expFinal) newLevel = growth_rate.level_from_exp(expFinal)
if newLevel<curLevel if newLevel < curLevel
debugInfo = "Levels: #{curLevel}->#{newLevel} | Exp: #{pkmn.exp}->#{expFinal} | gain: #{expGained}" debugInfo = "Levels: #{curLevel}->#{newLevel} | Exp: #{pkmn.exp}->#{expFinal} | gain: #{expGained}"
raise RuntimeError.new( raise RuntimeError.new(
_INTL("{1}'s new level is less than its\r\ncurrent level, which shouldn't happen.\r\n[Debug: {2}]", _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 end
# Give Exp # Give Exp
if pkmn.shadowPokemon? if pkmn.shadowPokemon?
@@ -180,11 +179,12 @@ class PokeBattle_Battle
end end
tempExp1 = pkmn.exp tempExp1 = pkmn.exp
battler = pbFindBattler(idxParty) battler = pbFindBattler(idxParty)
loop do # For each level gained in turn... loop do
# For each level gained in turn...
# EXP Bar animation # EXP Bar animation
levelMinExp = growth_rate.minimum_exp_for_level(curLevel) levelMinExp = growth_rate.minimum_exp_for_level(curLevel)
levelMaxExp = growth_rate.minimum_exp_for_level(curLevel + 1) levelMaxExp = growth_rate.minimum_exp_for_level(curLevel + 1)
tempExp2 = (levelMaxExp<expFinal) ? levelMaxExp : expFinal tempExp2 = (levelMaxExp < expFinal) ? levelMaxExp : expFinal
pkmn.exp = tempExp2 pkmn.exp = tempExp2
if pkmn.isFusion? if pkmn.isFusion?
@@ -195,10 +195,10 @@ class PokeBattle_Battle
end end
end end
@scene.pbEXPBar(battler,levelMinExp,levelMaxExp,tempExp1,tempExp2) @scene.pbEXPBar(battler, levelMinExp, levelMaxExp, tempExp1, tempExp2)
tempExp1 = tempExp2 tempExp1 = tempExp2
curLevel += 1 curLevel += 1
if curLevel>newLevel if curLevel > newLevel
# Gained all the Exp now, end the animation # Gained all the Exp now, end the animation
pkmn.calc_stats pkmn.calc_stats
battler.pbUpdate(false) if battler battler.pbUpdate(false) if battler
@@ -206,7 +206,7 @@ class PokeBattle_Battle
break break
end end
# Levelled up # Levelled up
pbCommonAnimation("LevelUp",battler) if battler pbCommonAnimation("LevelUp", battler) if battler
oldTotalHP = pkmn.totalhp oldTotalHP = pkmn.totalhp
oldAttack = pkmn.attack oldAttack = pkmn.attack
oldDefense = pkmn.defense oldDefense = pkmn.defense
@@ -219,19 +219,22 @@ class PokeBattle_Battle
pkmn.calc_stats pkmn.calc_stats
battler.pbUpdate(false) if battler battler.pbUpdate(false) if battler
@scene.pbRefreshOne(battler.index) if battler @scene.pbRefreshOne(battler.index) if battler
pbDisplayPaused(_INTL("{1} grew to Lv. {2}!",pkmn.name,curLevel)) pbDisplayPaused(_INTL("{1} grew to Lv. {2}!", pkmn.name, curLevel))
@scene.pbLevelUp(pkmn,battler,oldTotalHP,oldAttack,oldDefense, if !$game_switches[SWITCH_NO_LEVELS_MODE]
oldSpAtk,oldSpDef,oldSpeed) @scene.pbLevelUp(pkmn, battler, oldTotalHP, oldAttack, oldDefense,
oldSpAtk, oldSpDef, oldSpeed)
end
# Learn all moves learned at this level # Learn all moves learned at this level
moveList = pkmn.getMoveList 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
end end
#============================================================================= #=============================================================================
# Learning a move # Learning a move
#============================================================================= #=============================================================================
def pbLearnMove(idxParty,newMove) def pbLearnMove(idxParty, newMove)
pkmn = pbParty(0)[idxParty] pkmn = pbParty(0)[idxParty]
return if !pkmn return if !pkmn
pkmnName = pkmn.name pkmnName = pkmn.name
@@ -242,7 +245,7 @@ class PokeBattle_Battle
# Pokémon has space for the new move; just learn it # Pokémon has space for the new move; just learn it
if pkmn.moves.length < Pokemon::MAX_MOVES if pkmn.moves.length < Pokemon::MAX_MOVES
pkmn.moves.push(Pokemon::Move.new(newMove)) pkmn.moves.push(Pokemon::Move.new(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 if battler
battler.moves.push(PokeBattle_Move.from_pokemon_move(self, pkmn.moves.last)) battler.moves.push(PokeBattle_Move.from_pokemon_move(self, pkmn.moves.last))
battler.pbCheckFormOnMovesetChange battler.pbCheckFormOnMovesetChange
@@ -253,24 +256,24 @@ class PokeBattle_Battle
loop do loop do
pbDisplayPaused(_INTL("{1} wants to learn {2}, but it already knows {3} moves.", pbDisplayPaused(_INTL("{1} wants to learn {2}, but it already knows {3} moves.",
pkmnName, moveName, pkmn.moves.length.to_word)) pkmnName, moveName, pkmn.moves.length.to_word))
if pbDisplayConfirm(_INTL("Forget a move to learn {1}?",moveName)) if pbDisplayConfirm(_INTL("Forget a move to learn {1}?", moveName))
pbDisplayPaused(_INTL("Which move should be forgotten?")) pbDisplayPaused(_INTL("Which move should be forgotten?"))
forgetMove = @scene.pbForgetMove(pkmn,newMove) forgetMove = @scene.pbForgetMove(pkmn, newMove)
if forgetMove>=0 if forgetMove >= 0
oldMoveName = pkmn.moves[forgetMove].name oldMoveName = pkmn.moves[forgetMove].name
pkmn.moves[forgetMove] = Pokemon::Move.new(newMove) # Replaces current/total PP pkmn.moves[forgetMove] = Pokemon::Move.new(newMove) # Replaces current/total PP
battler.moves[forgetMove] = PokeBattle_Move.from_pokemon_move(self, pkmn.moves[forgetMove]) if battler battler.moves[forgetMove] = PokeBattle_Move.from_pokemon_move(self, pkmn.moves[forgetMove]) if battler
pbDisplayPaused(_INTL("1, 2, and... ... ... Ta-da!")) pbDisplayPaused(_INTL("1, 2, and... ... ... Ta-da!"))
pbDisplayPaused(_INTL("{1} forgot how to use {2}. And...",pkmnName,oldMoveName)) pbDisplayPaused(_INTL("{1} forgot how to use {2}. And...", pkmnName, oldMoveName))
pbDisplay(_INTL("{1} learned {2}!",pkmnName,moveName)) { pbSEPlay("Pkmn move learnt") } pbDisplay(_INTL("{1} learned {2}!", pkmnName, moveName)) { pbSEPlay("Pkmn move learnt") }
battler.pbCheckFormOnMovesetChange if battler battler.pbCheckFormOnMovesetChange if battler
break break
elsif pbDisplayConfirm(_INTL("Give up on learning {1}?",moveName)) elsif pbDisplayConfirm(_INTL("Give up on learning {1}?", moveName))
pbDisplay(_INTL("{1} did not learn {2}.",pkmnName,moveName)) pbDisplay(_INTL("{1} did not learn {2}.", pkmnName, moveName))
break break
end end
elsif pbDisplayConfirm(_INTL("Give up on learning {1}?",moveName)) elsif pbDisplayConfirm(_INTL("Give up on learning {1}?", moveName))
pbDisplay(_INTL("{1} did not learn {2}.",pkmnName,moveName)) pbDisplay(_INTL("{1} did not learn {2}.", pkmnName, moveName))
break break
end end
end end