mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-12 23:44:58 +00:00
Rearranged OrgBattle scripts
This commit is contained in:
@@ -0,0 +1,425 @@
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class BattleChallenge
|
||||
attr_reader :currentChallenge
|
||||
|
||||
BattleTowerID = 0
|
||||
BattlePalaceID = 1
|
||||
BattleArenaID = 2
|
||||
BattleFactoryID = 3
|
||||
|
||||
def initialize
|
||||
@bc = BattleChallengeData.new
|
||||
@currentChallenge = -1
|
||||
@types = {}
|
||||
end
|
||||
|
||||
def set(id, numrounds, rules)
|
||||
@id = id
|
||||
@numRounds = numrounds
|
||||
@rules = rules
|
||||
pbWriteCup(id, rules)
|
||||
end
|
||||
|
||||
def register(id, doublebattle, numrounds, numPokemon, battletype, mode = 1)
|
||||
ensureType(id)
|
||||
if battletype == BattleFactoryID
|
||||
@bc.setExtraData(BattleFactoryData.new(@bc))
|
||||
numPokemon = 3
|
||||
battletype = BattleTowerID
|
||||
end
|
||||
@numRounds = numrounds
|
||||
@rules = modeToRules(doublebattle, numPokemon, battletype, mode)
|
||||
end
|
||||
|
||||
def rules
|
||||
if !@rules
|
||||
@rules = modeToRules(self.data.doublebattle, self.data.numPokemon,
|
||||
self.data.battletype, self.data.mode)
|
||||
end
|
||||
return @rules
|
||||
end
|
||||
|
||||
def modeToRules(doublebattle, numPokemon, battletype, mode)
|
||||
rules = PokemonChallengeRules.new
|
||||
# Set the battle type
|
||||
case battletype
|
||||
when BattlePalaceID
|
||||
rules.setBattleType(BattlePalace.new)
|
||||
when BattleArenaID
|
||||
rules.setBattleType(BattleArena.new)
|
||||
doublebattle = false
|
||||
else # Factory works the same as Tower
|
||||
rules.setBattleType(BattleTower.new)
|
||||
end
|
||||
# Set standard rules and maximum level
|
||||
case mode
|
||||
when 1 # Open Level
|
||||
rules.setRuleset(StandardRules.new(numPokemon, GameData::GrowthRate.max_level))
|
||||
rules.setLevelAdjustment(OpenLevelAdjustment.new(30))
|
||||
when 2 # Battle Tent
|
||||
rules.setRuleset(StandardRules.new(numPokemon, GameData::GrowthRate.max_level))
|
||||
rules.setLevelAdjustment(OpenLevelAdjustment.new(60))
|
||||
else
|
||||
rules.setRuleset(StandardRules.new(numPokemon, 50))
|
||||
rules.setLevelAdjustment(OpenLevelAdjustment.new(50))
|
||||
end
|
||||
# Set whether battles are single or double
|
||||
if doublebattle
|
||||
rules.addBattleRule(DoubleBattle.new)
|
||||
else
|
||||
rules.addBattleRule(SingleBattle.new)
|
||||
end
|
||||
return rules
|
||||
end
|
||||
|
||||
def start(*args)
|
||||
t = ensureType(@id)
|
||||
@currentChallenge = @id # must appear before pbStart
|
||||
@bc.pbStart(t, @numRounds)
|
||||
end
|
||||
|
||||
def pbStart(challenge)
|
||||
end
|
||||
|
||||
def pbEnd
|
||||
if @currentChallenge != -1
|
||||
ensureType(@currentChallenge).saveWins(@bc)
|
||||
@currentChallenge = -1
|
||||
end
|
||||
@bc.pbEnd
|
||||
end
|
||||
|
||||
def pbBattle
|
||||
return @bc.extraData.pbBattle(self) if @bc.extraData # Battle Factory
|
||||
opponent = pbGenerateBattleTrainer(self.nextTrainer, self.rules)
|
||||
bttrainers = pbGetBTTrainers(@id)
|
||||
trainerdata = bttrainers[self.nextTrainer]
|
||||
ret = pbOrganizedBattleEx(opponent,self.rules,
|
||||
pbGetMessageFromHash(MessageTypes::EndSpeechLose, trainerdata[4]),
|
||||
pbGetMessageFromHash(MessageTypes::EndSpeechWin, trainerdata[3]))
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbInChallenge?
|
||||
return pbInProgress?
|
||||
end
|
||||
|
||||
def pbInProgress?
|
||||
return @bc.inProgress
|
||||
end
|
||||
|
||||
def pbResting?
|
||||
return @bc.resting
|
||||
end
|
||||
|
||||
def extra; @bc.extraData; end
|
||||
def decision; @bc.decision; end
|
||||
def wins; @bc.wins; end
|
||||
def swaps; @bc.swaps; end
|
||||
def battleNumber; @bc.battleNumber; end
|
||||
def nextTrainer; @bc.nextTrainer; end
|
||||
def pbGoOn; @bc.pbGoOn; end
|
||||
def pbAddWin; @bc.pbAddWin; end
|
||||
def pbCancel; @bc.pbCancel; end
|
||||
def pbRest; @bc.pbRest; end
|
||||
def pbMatchOver?; @bc.pbMatchOver?; end
|
||||
def pbGoToStart; @bc.pbGoToStart; end
|
||||
|
||||
def setDecision(value)
|
||||
@bc.decision = value
|
||||
end
|
||||
|
||||
def setParty(value)
|
||||
@bc.setParty(value)
|
||||
end
|
||||
|
||||
def data
|
||||
return nil if !pbInProgress? || @currentChallenge < 0
|
||||
return ensureType(@currentChallenge).clone
|
||||
end
|
||||
|
||||
def getCurrentWins(challenge)
|
||||
return ensureType(challenge).currentWins
|
||||
end
|
||||
|
||||
def getPreviousWins(challenge)
|
||||
return ensureType(challenge).previousWins
|
||||
end
|
||||
|
||||
def getMaxWins(challenge)
|
||||
return ensureType(challenge).maxWins
|
||||
end
|
||||
|
||||
def getCurrentSwaps(challenge)
|
||||
return ensureType(challenge).currentSwaps
|
||||
end
|
||||
|
||||
def getPreviousSwaps(challenge)
|
||||
return ensureType(challenge).previousSwaps
|
||||
end
|
||||
|
||||
def getMaxSwaps(challenge)
|
||||
return ensureType(challenge).maxSwaps
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def ensureType(id)
|
||||
@types[id] = BattleChallengeType.new if !@types[id]
|
||||
return @types[id]
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class BattleChallengeData
|
||||
attr_reader :battleNumber
|
||||
attr_reader :numRounds
|
||||
attr_reader :party
|
||||
attr_reader :inProgress
|
||||
attr_reader :resting
|
||||
attr_reader :wins
|
||||
attr_reader :swaps
|
||||
attr_accessor :decision
|
||||
attr_reader :extraData
|
||||
|
||||
def initialize
|
||||
reset
|
||||
end
|
||||
|
||||
def setExtraData(value)
|
||||
@extraData = value
|
||||
end
|
||||
|
||||
def setParty(value)
|
||||
if @inProgress
|
||||
$Trainer.party = value
|
||||
@party = value
|
||||
else
|
||||
@party = value
|
||||
end
|
||||
end
|
||||
|
||||
def pbStart(t, numRounds)
|
||||
@inProgress = true
|
||||
@resting = false
|
||||
@decision = 0
|
||||
@swaps = t.currentSwaps
|
||||
@wins = t.currentWins
|
||||
@battleNumber = 1
|
||||
@trainers = []
|
||||
raise _INTL("Number of rounds is 0 or less.") if numRounds <= 0
|
||||
@numRounds = numRounds
|
||||
# Get all the trainers for the next set of battles
|
||||
btTrainers = pbGetBTTrainers(pbBattleChallenge.currentChallenge)
|
||||
while @trainers.length < @numRounds
|
||||
newtrainer = pbBattleChallengeTrainer(@wins + @trainers.length, btTrainers)
|
||||
found = false
|
||||
for tr in @trainers
|
||||
found = true if tr == newtrainer
|
||||
end
|
||||
@trainers.push(newtrainer) if !found
|
||||
end
|
||||
@start = [$game_map.map_id, $game_player.x, $game_player.y]
|
||||
@oldParty = $Trainer.party
|
||||
$Trainer.party = @party if @party
|
||||
Game.save(safe: true)
|
||||
end
|
||||
|
||||
def pbGoToStart
|
||||
if $scene.is_a?(Scene_Map)
|
||||
$game_temp.player_transferring = true
|
||||
$game_temp.player_new_map_id = @start[0]
|
||||
$game_temp.player_new_x = @start[1]
|
||||
$game_temp.player_new_y = @start[2]
|
||||
$game_temp.player_new_direction = 8
|
||||
$scene.transfer_player
|
||||
end
|
||||
end
|
||||
|
||||
def pbAddWin
|
||||
return if !@inProgress
|
||||
@battleNumber += 1
|
||||
@wins += 1
|
||||
end
|
||||
|
||||
def pbAddSwap
|
||||
@swaps += 1 if @inProgress
|
||||
end
|
||||
|
||||
def pbMatchOver?
|
||||
return true if !@inProgress || @decision != 0
|
||||
return @battleNumber > @numRounds
|
||||
end
|
||||
|
||||
def pbRest
|
||||
return if !@inProgress
|
||||
@resting = true
|
||||
pbSaveInProgress
|
||||
end
|
||||
|
||||
def pbGoOn
|
||||
return if !@inProgress
|
||||
@resting = false
|
||||
pbSaveInProgress
|
||||
end
|
||||
|
||||
def pbCancel
|
||||
$Trainer.party = @oldParty if @oldParty
|
||||
reset
|
||||
end
|
||||
|
||||
def pbEnd
|
||||
$Trainer.party = @oldParty
|
||||
return if !@inProgress
|
||||
save = (@decision != 0)
|
||||
reset
|
||||
$game_map.need_refresh = true
|
||||
Game.save(safe: true) if save
|
||||
end
|
||||
|
||||
def nextTrainer
|
||||
return @trainers[@battleNumber - 1]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def reset
|
||||
@inProgress = false
|
||||
@resting = false
|
||||
@start = nil
|
||||
@decision = 0
|
||||
@wins = 0
|
||||
@swaps = 0
|
||||
@battleNumber = 0
|
||||
@trainers = []
|
||||
@oldParty = nil
|
||||
@party = nil
|
||||
@extraData = nil
|
||||
end
|
||||
|
||||
def pbSaveInProgress
|
||||
oldmapid = $game_map.map_id
|
||||
oldx = $game_player.x
|
||||
oldy = $game_player.y
|
||||
olddirection = $game_player.direction
|
||||
$game_map.map_id = @start[0]
|
||||
$game_player.moveto2(@start[1], @start[2])
|
||||
$game_player.direction = 8 # facing up
|
||||
Game.save(safe: true)
|
||||
$game_map.map_id = oldmapid
|
||||
$game_player.moveto2(oldx, oldy)
|
||||
$game_player.direction = olddirection
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class BattleChallengeType
|
||||
attr_accessor :currentWins
|
||||
attr_accessor :previousWins
|
||||
attr_accessor :maxWins
|
||||
attr_accessor :currentSwaps
|
||||
attr_accessor :previousSwaps
|
||||
attr_accessor :maxSwaps
|
||||
attr_reader :doublebattle
|
||||
attr_reader :numPokemon
|
||||
attr_reader :battletype
|
||||
attr_reader :mode
|
||||
|
||||
def initialize
|
||||
@previousWins = 0
|
||||
@maxWins = 0
|
||||
@currentWins = 0
|
||||
@currentSwaps = 0
|
||||
@previousSwaps = 0
|
||||
@maxSwaps = 0
|
||||
end
|
||||
|
||||
def saveWins(challenge)
|
||||
if challenge.decision == 0 # if undecided
|
||||
@currentWins = 0
|
||||
@currentSwaps = 0
|
||||
else
|
||||
if challenge.decision == 1 # if won
|
||||
@currentWins = challenge.wins
|
||||
@currentSwaps = challenge.swaps
|
||||
else # if lost
|
||||
@currentWins = 0
|
||||
@currentSwaps = 0
|
||||
end
|
||||
@maxWins = [@maxWins, challenge.wins].max
|
||||
@previousWins = challenge.wins
|
||||
@maxSwaps = [@maxSwaps, challenge.swaps].max
|
||||
@previousSwaps = challenge.swaps
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Battle Factory data
|
||||
#===============================================================================
|
||||
class BattleFactoryData
|
||||
def initialize(bcdata)
|
||||
@bcdata = bcdata
|
||||
end
|
||||
|
||||
def pbPrepareRentals
|
||||
@rentals = pbBattleFactoryPokemon(pbBattleChallenge.rules, @bcdata.wins, @bcdata.swaps, [])
|
||||
@trainerid = @bcdata.nextTrainer
|
||||
bttrainers = pbGetBTTrainers(@bcdata.currentChallenge)
|
||||
trainerdata = bttrainers[@trainerid]
|
||||
@opponent = NPCTrainer.new(
|
||||
pbGetMessageFromHash(MessageTypes::TrainerNames, trainerdata[1]),
|
||||
trainerdata[0])
|
||||
opponentPkmn = pbBattleFactoryPokemon(pbBattleChallenge.rules, @bcdata.wins, @bcdata.swaps, @rentals)
|
||||
@opponent.party = opponentPkmn.shuffle[0, 3]
|
||||
end
|
||||
|
||||
def pbChooseRentals
|
||||
pbFadeOutIn {
|
||||
scene = BattleSwapScene.new
|
||||
screen = BattleSwapScreen.new(scene)
|
||||
@rentals = screen.pbStartRent(@rentals)
|
||||
@bcdata.pbAddSwap
|
||||
pbBattleChallenge.setParty(@rentals)
|
||||
}
|
||||
end
|
||||
|
||||
def pbPrepareSwaps
|
||||
@oldopponent = @opponent.party
|
||||
trainerid = @bcdata.nextTrainer
|
||||
bttrainers = pbGetBTTrainers(@bcdata.currentChallenge)
|
||||
trainerdata = bttrainers[trainerid]
|
||||
@opponent = NPCTrainer.new(
|
||||
pbGetMessageFromHash(MessageTypes::TrainerNames, trainerdata[1]),
|
||||
trainerdata[0])
|
||||
opponentPkmn = pbBattleFactoryPokemon(challenge.rules, @bcdata.wins, @bcdata.swaps,
|
||||
[].concat(@rentals).concat(@oldopponent))
|
||||
@opponent.party = opponentPkmn.shuffle[0, 3]
|
||||
end
|
||||
|
||||
def pbChooseSwaps
|
||||
swapMade = true
|
||||
pbFadeOutIn {
|
||||
scene = BattleSwapScene.new
|
||||
screen = BattleSwapScreen.new(scene)
|
||||
swapMade = screen.pbStartSwap(@rentals, @oldopponent)
|
||||
@bcdata.pbAddSwap if swapMade
|
||||
@bcdata.setParty(@rentals)
|
||||
}
|
||||
return swapMade
|
||||
end
|
||||
|
||||
def pbBattle(challenge)
|
||||
bttrainers = pbGetBTTrainers(@bcdata.currentChallenge)
|
||||
trainerdata = bttrainers[@trainerid]
|
||||
return pbOrganizedBattleEx(@opponent, challenge.rules,
|
||||
pbGetMessageFromHash(MessageTypes::EndSpeechLose, trainerdata[4]),
|
||||
pbGetMessageFromHash(MessageTypes::EndSpeechWin, trainerdata[3]))
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,223 @@
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
def pbBattleChallenge
|
||||
$PokemonGlobal.challenge = BattleChallenge.new if !$PokemonGlobal.challenge
|
||||
return $PokemonGlobal.challenge
|
||||
end
|
||||
|
||||
def pbBattleChallengeBattle
|
||||
return pbBattleChallenge.pbBattle
|
||||
end
|
||||
|
||||
# Used in events
|
||||
def pbHasEligible?(*arg)
|
||||
return pbBattleChallenge.rules.ruleset.hasValidTeam?($Trainer.party)
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
def pbGetBTTrainers(challengeID)
|
||||
trlists = (load_data("Data/trainer_lists.dat") rescue [])
|
||||
trlists.each { |tr| return tr[0] if !tr[5] && tr[2].include?(challengeID) }
|
||||
trlists.each { |tr| return tr[0] if tr[5] } # is default list
|
||||
return []
|
||||
end
|
||||
|
||||
def pbGetBTPokemon(challengeID)
|
||||
trlists = (load_data("Data/trainer_lists.dat") rescue [])
|
||||
trlists.each { |tr| return tr[1] if !tr[5] && tr[2].include?(challengeID) }
|
||||
trlists.each { |tr| return tr[1] if tr[5] } # is default list
|
||||
return []
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
def pbEntryScreen(*arg)
|
||||
retval = false
|
||||
pbFadeOutIn {
|
||||
scene = PokemonParty_Scene.new
|
||||
screen = PokemonPartyScreen.new(scene, $Trainer.party)
|
||||
ret = screen.pbPokemonMultipleEntryScreenEx(pbBattleChallenge.rules.ruleset)
|
||||
# Set party
|
||||
pbBattleChallenge.setParty(ret) if ret
|
||||
# Continue (return true) if Pokémon were chosen
|
||||
retval = (ret != nil && ret.length > 0)
|
||||
}
|
||||
return retval
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class Game_Player < Game_Character
|
||||
def moveto2(x, y)
|
||||
@x = x
|
||||
@y = y
|
||||
@real_x = @x * Game_Map::REAL_RES_X
|
||||
@real_y = @y * Game_Map::REAL_RES_Y
|
||||
@prelock_direction = 0
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class Game_Event
|
||||
def pbInChallenge?
|
||||
return pbBattleChallenge.pbInChallenge?
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
def pbBattleChallengeGraphic(event)
|
||||
nextTrainer = pbBattleChallenge.nextTrainer
|
||||
bttrainers = pbGetBTTrainers(pbBattleChallenge.currentChallenge)
|
||||
filename = GameData::TrainerType.charset_filename_brief((bttrainers[nextTrainer][0] rescue nil))
|
||||
begin
|
||||
filename = "NPC 01" if nil_or_empty?(filename)
|
||||
bitmap = AnimatedBitmap.new("Graphics/Characters/" + filename)
|
||||
bitmap.dispose
|
||||
event.character_name = filename
|
||||
rescue
|
||||
event.character_name = "NPC 01"
|
||||
end
|
||||
end
|
||||
|
||||
def pbBattleChallengeBeginSpeech
|
||||
return "..." if !pbBattleChallenge.pbInProgress?
|
||||
bttrainers = pbGetBTTrainers(pbBattleChallenge.currentChallenge)
|
||||
tr = bttrainers[pbBattleChallenge.nextTrainer]
|
||||
return (tr) ? pbGetMessageFromHash(MessageTypes::BeginSpeech, tr[2]) : "..."
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PBPokemon
|
||||
attr_accessor :species
|
||||
attr_accessor :item
|
||||
attr_accessor :nature
|
||||
attr_accessor :move1
|
||||
attr_accessor :move2
|
||||
attr_accessor :move3
|
||||
attr_accessor :move4
|
||||
attr_accessor :ev
|
||||
|
||||
# This method is how each Pokémon is compiled from the PBS files listing
|
||||
# Battle Tower/Cup Pokémon.
|
||||
def self.fromInspected(str)
|
||||
insp = str.gsub(/^\s+/, "").gsub(/\s+$/, "")
|
||||
pieces = insp.split(/\s*;\s*/)
|
||||
species = (GameData::Species.exists?(pieces[0])) ? GameData::Species.get(pieces[0]).id : nil
|
||||
item = (GameData::Item.exists?(pieces[1])) ? GameData::Item.get(pieces[1]).id : nil
|
||||
nature = (GameData::Nature.exists?(pieces[2])) ? GameData::Nature.get(pieces[2]).id : nil
|
||||
ev = pieces[3].split(/\s*,\s*/)
|
||||
ev_array = []
|
||||
ev.each do |stat|
|
||||
case stat.upcase
|
||||
when "HP" then ev_array.push(:HP)
|
||||
when "ATK" then ev_array.push(:ATTACK)
|
||||
when "DEF" then ev_array.push(:DEFENSE)
|
||||
when "SA", "SPATK" then ev_array.push(:SPECIAL_ATTACK)
|
||||
when "SD", "SPDEF" then ev_array.push(:SPECIAL_DEFENSE)
|
||||
when "SPD" then ev_array.push(:SPEED)
|
||||
end
|
||||
end
|
||||
moves = pieces[4].split(/\s*,\s*/)
|
||||
moveid = []
|
||||
for i in 0...Pokemon::MAX_MOVES
|
||||
move_data = GameData::Move.try_get(moves[i])
|
||||
moveid.push(move_data.id) if move_data
|
||||
end
|
||||
if moveid.length == 0
|
||||
GameData::Move.each { |mov| moveid.push(mov.id); break } # Get any one move
|
||||
end
|
||||
return self.new(species, item, nature, moveid[0], moveid[1], moveid[2], moveid[3], ev_array)
|
||||
end
|
||||
|
||||
def self.fromPokemon(pkmn)
|
||||
mov1 = (pkmn.moves[0]) ? pkmn.moves[0].id : nil
|
||||
mov2 = (pkmn.moves[1]) ? pkmn.moves[1].id : nil
|
||||
mov3 = (pkmn.moves[2]) ? pkmn.moves[2].id : nil
|
||||
mov4 = (pkmn.moves[3]) ? pkmn.moves[3].id : nil
|
||||
ev_array = []
|
||||
GameData::Stat.each_main do |s|
|
||||
ev_array.push(s.id) if pkmn.ev[s.id] > 60
|
||||
end
|
||||
return self.new(pkmn.species, pkmn.item_id, pkmn.nature,
|
||||
mov1, mov2, mov3, mov4, ev_array)
|
||||
end
|
||||
|
||||
def initialize(species, item, nature, move1, move2, move3, move4, ev)
|
||||
@species = species
|
||||
itm = GameData::Item.try_get(item)
|
||||
@item = itm ? itm.id : nil
|
||||
@nature = nature
|
||||
@move1 = move1
|
||||
@move2 = move2
|
||||
@move3 = move3
|
||||
@move4 = move4
|
||||
@ev = ev
|
||||
end
|
||||
|
||||
def inspect
|
||||
c1 = GameData::Species.get(@species).id
|
||||
c2 = (@item) ? GameData::Item.get(@item).id : ""
|
||||
c3 = (@nature) ? GameData::Nature.get(@nature).id : ""
|
||||
evlist = ""
|
||||
@ev.each do |stat|
|
||||
evlist += "," if evlist != ""
|
||||
evlist += stat.real_name_brief
|
||||
end
|
||||
c4 = (@move1) ? GameData::Move.get(@move1).id : ""
|
||||
c5 = (@move2) ? GameData::Move.get(@move2).id : ""
|
||||
c6 = (@move3) ? GameData::Move.get(@move3).id : ""
|
||||
c7 = (@move4) ? GameData::Move.get(@move4).id : ""
|
||||
return "#{c1};#{c2};#{c3};#{evlist};#{c4},#{c5},#{c6},#{c7}"
|
||||
end
|
||||
|
||||
# Unused.
|
||||
def tocompact
|
||||
return "#{species},#{item},#{nature},#{move1},#{move2},#{move3},#{move4},#{ev}"
|
||||
end
|
||||
|
||||
=begin
|
||||
def _dump(depth)
|
||||
return [@species, @item, @nature, @move1, @move2, @move3, @move4, @ev].pack("vvCvvvvC")
|
||||
end
|
||||
|
||||
def self._load(str)
|
||||
data = str.unpack("vvCvvvvC")
|
||||
return self.new(data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7])
|
||||
end
|
||||
=end
|
||||
|
||||
def convertMove(move)
|
||||
move = :FRUSTRATION if move == :RETURN && GameData::Move.exists?(:FRUSTRATION)
|
||||
return move
|
||||
end
|
||||
|
||||
def createPokemon(level, iv, trainer)
|
||||
pkmn = Pokemon.new(@species, level, trainer, false)
|
||||
pkmn.item = @item
|
||||
pkmn.personalID = rand(2**16) | rand(2**16) << 16
|
||||
pkmn.nature = nature
|
||||
pkmn.happiness = 0
|
||||
pkmn.moves.push(Pokemon::Move.new(self.convertMove(@move1)))
|
||||
pkmn.moves.push(Pokemon::Move.new(self.convertMove(@move2))) if @move2
|
||||
pkmn.moves.push(Pokemon::Move.new(self.convertMove(@move3))) if @move3
|
||||
pkmn.moves.push(Pokemon::Move.new(self.convertMove(@move4))) if @move4
|
||||
pkmn.moves.compact!
|
||||
if ev.length > 0
|
||||
ev.each { |stat| pkmn.ev[stat] = Pokemon::EV_LIMIT / ev.length }
|
||||
end
|
||||
GameData::Stat.each_main { |s| pkmn.iv[s.id] = iv }
|
||||
pkmn.calc_stats
|
||||
return pkmn
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,154 @@
|
||||
#===============================================================================
|
||||
# Given an array of trainers and the number of wins the player already has,
|
||||
# returns a random trainer index. The more wins, the later in the list the
|
||||
# trainer comes from.
|
||||
#===============================================================================
|
||||
def pbBattleChallengeTrainer(win_count, bttrainers)
|
||||
# This table's start points and lengths are based on a bttrainers size of 300.
|
||||
# They are scaled based on the actual size of bttrainers later.
|
||||
table = [ # Each value is [minimum win count, range start point, range length]
|
||||
[ 0, 0, 100], # 0-100
|
||||
[ 6, 80, 40], # 80-120
|
||||
[ 7, 80, 40], # 80-120
|
||||
[13, 120, 20], # 120-140
|
||||
[14, 100, 40], # 100-140
|
||||
[20, 140, 20], # 140-160
|
||||
[21, 120, 40], # 120-160
|
||||
[27, 160, 20], # 160-180
|
||||
[28, 140, 40], # 140-180
|
||||
[34, 180, 20], # 180-200
|
||||
[35, 160, 40], # 160-200
|
||||
[41, 200, 20], # 200-220
|
||||
[42, 180, 40], # 180-220
|
||||
[48, 220, 40], # 220-260
|
||||
[49, 200, 100] # 200-300 - This line is used for all higher win_counts
|
||||
]
|
||||
slot = nil
|
||||
table.each { |val| slot = val if val[0] <= win_count && slot[0] < val[0] }
|
||||
return 0 if !slot
|
||||
# Scale the start point and length based on how many trainers are in bttrainers
|
||||
offset = slot[1] * bttrainers.length / 300
|
||||
length = slot[2] * bttrainers.length / 300
|
||||
# Return a random trainer index from the chosen range
|
||||
return offset + rand(length)
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
def pbGenerateBattleTrainer(idxTrainer, rules)
|
||||
bttrainers = pbGetBTTrainers(pbBattleChallenge.currentChallenge)
|
||||
btpokemon = pbGetBTPokemon(pbBattleChallenge.currentChallenge)
|
||||
level = rules.ruleset.suggestedLevel
|
||||
# Create the trainer
|
||||
trainerdata = bttrainers[idxTrainer]
|
||||
opponent = NPCTrainer.new(
|
||||
pbGetMessageFromHash(MessageTypes::TrainerNames, trainerdata[1]),
|
||||
trainerdata[0])
|
||||
# Determine how many IVs the trainer's Pokémon will have
|
||||
indvalues = 31
|
||||
indvalues = 21 if idxTrainer < 220
|
||||
indvalues = 18 if idxTrainer < 200
|
||||
indvalues = 15 if idxTrainer < 180
|
||||
indvalues = 12 if idxTrainer < 160
|
||||
indvalues = 9 if idxTrainer < 140
|
||||
indvalues = 6 if idxTrainer < 120
|
||||
indvalues = 3 if idxTrainer < 100
|
||||
# Get the indices within bypokemon of the Pokémon the trainer may have
|
||||
pokemonnumbers = trainerdata[5]
|
||||
# The number of possible Pokémon is <= the required number; make them
|
||||
# all Pokémon and use them
|
||||
if pokemonnumbers.length <= rules.ruleset.suggestedNumber
|
||||
for n in pokemonnumbers
|
||||
rndpoke = btpokemon[n]
|
||||
pkmn = rndpoke.createPokemon(level, indvalues, opponent)
|
||||
opponent.party.push(pkmn)
|
||||
end
|
||||
return opponent
|
||||
end
|
||||
# There are more possible Pokémon than there are spaces available in the
|
||||
# trainer's party; randomly choose Pokémon
|
||||
loop do
|
||||
opponent.party.clear
|
||||
while opponent.party.length < rules.ruleset.suggestedNumber
|
||||
rnd = pokemonnumbers[rand(pokemonnumbers.length)]
|
||||
rndpoke = btpokemon[rnd]
|
||||
pkmn = rndpoke.createPokemon(level, indvalues, opponent)
|
||||
opponent.party.push(pkmn)
|
||||
end
|
||||
break if rules.ruleset.isValid?(opponent.party)
|
||||
end
|
||||
return opponent
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Generate a full team's worth of Pokémon which obey the given rules.
|
||||
#===============================================================================
|
||||
def pbBattleFactoryPokemon(rules, win_count, swap_count, _rentals)
|
||||
btpokemon = pbGetBTPokemon(pbBattleChallenge.currentChallenge)
|
||||
level = rules.ruleset.suggestedLevel
|
||||
pokemonNumbers = [0, 0] # Start and end indices in btpokemon
|
||||
ivs = [0, 0] # Lower and higher IV values for Pokémon to use
|
||||
iv_threshold = 6 # Number of Pokémon that use the lower IV
|
||||
set = [win_count / 7, 7].min # The set of 7 battles win_count is part of (minus 1)
|
||||
# Choose a range of Pokémon in btpokemon to randomly select from. The higher
|
||||
# the set number, the later the range lies within btpokemon (typically).
|
||||
# This table's start point and end point values are based on a btpokemon size
|
||||
# of 882. They are scaled based on the actual size of btpokemon.
|
||||
if level == GameData::GrowthRate.max_level # Open Level (Level 100)
|
||||
table = [
|
||||
[372, 467],
|
||||
[468, 563],
|
||||
[564, 659],
|
||||
[660, 755],
|
||||
[372, 881],
|
||||
[372, 881],
|
||||
[372, 881],
|
||||
[372, 881] # This line is used for all higher sets
|
||||
]
|
||||
else
|
||||
table = [
|
||||
[110, 199],
|
||||
[162, 266],
|
||||
[267, 371],
|
||||
[372, 467],
|
||||
[468, 563],
|
||||
[564, 659],
|
||||
[660, 755],
|
||||
[372, 849] # This line is used for all higher sets
|
||||
]
|
||||
end
|
||||
pokemonNumbers[0] = table[set][0] * btpokemon.length / 882
|
||||
pokemonNumbers[1] = table[set][1] * btpokemon.length / 882
|
||||
# Choose two IV values for Pokémon to use (the one for the current set, and
|
||||
# the one for the next set). The iv_threshold below determines which of these
|
||||
# two values a given Pokémon uses. The higher the set number, the higher these
|
||||
# values are.
|
||||
ivtable = [3, 6, 9, 12, 15, 21, 31, 31] # Last value is used for all higher sets
|
||||
ivs = [ivtable[set], ivtable[[set + 1, 7].min]]
|
||||
# Choose a threshold, which is the number of Pokémon with the lower IV out of
|
||||
# the two chosen above. The higher the swap_count, the lower this threshold
|
||||
# (i.e. the more Pokémon will have the higher IV).
|
||||
thresholds = [ # Each value is [minimum swap count, threshold value]
|
||||
[ 0, 6],
|
||||
[15, 5],
|
||||
[22, 4],
|
||||
[29, 3],
|
||||
[36, 2],
|
||||
[43, 1]
|
||||
]
|
||||
thresholds.each { |val| iv_threshold = val[1] if swap_count >= val[0] }
|
||||
# Randomly choose Pokémon from the range to fill the party with
|
||||
party = []
|
||||
loop do
|
||||
party.clear
|
||||
while party.length < Settings::MAX_PARTY_SIZE
|
||||
rnd = pokemonNumbers[0] + rand(pokemonNumbers[1] - pokemonNumbers[0] + 1)
|
||||
rndpoke = btpokemon[rnd]
|
||||
indvalue = (party.length < iv_threshold) ? ivs[0] : ivs[1]
|
||||
party.push(rndpoke.createPokemon(level, indvalue, nil))
|
||||
end
|
||||
break if rules.ruleset.isValid?(party)
|
||||
end
|
||||
return party
|
||||
end
|
||||
@@ -0,0 +1,145 @@
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class BattleType
|
||||
def pbCreateBattle(scene, trainer1, trainer2)
|
||||
return PokeBattle_Battle.new(scene, trainer1.party, trainer2.party, trainer1, trainer2)
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class BattleTower < BattleType
|
||||
def pbCreateBattle(scene, trainer1, trainer2)
|
||||
return PokeBattle_RecordedBattle.new(scene, trainer1.party, trainer2.party, trainer1, trainer2)
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class BattlePalace < BattleType
|
||||
def pbCreateBattle(scene, trainer1, trainer2)
|
||||
return PokeBattle_RecordedBattlePalace.new(scene, trainer1.party, trainer2.party, trainer1, trainer2)
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class BattleArena < BattleType
|
||||
def pbCreateBattle(scene, trainer1, trainer2)
|
||||
return PokeBattle_RecordedBattleArena.new(scene, trainer1.party, trainer2.party, trainer1, trainer2)
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
def pbOrganizedBattleEx(opponent, challengedata, endspeech, endspeechwin)
|
||||
# Skip battle if holding Ctrl in Debug mode
|
||||
if Input.press?(Input::CTRL) && $DEBUG
|
||||
pbMessage(_INTL("SKIPPING BATTLE..."))
|
||||
pbMessage(_INTL("AFTER WINNING..."))
|
||||
endspeech.each { |msg| pbMessage(msg || "...") }
|
||||
$PokemonTemp.lastbattle = nil
|
||||
return true
|
||||
end
|
||||
$Trainer.heal_party
|
||||
# Remember original data, to be restored after battle
|
||||
challengedata = PokemonChallengeRules.new if !challengedata
|
||||
oldlevels = challengedata.adjustLevels($Trainer.party, opponent.party)
|
||||
olditems = $Trainer.party.transform { |p| p.item_id }
|
||||
olditems2 = opponent.party.transform { |p| p.item_id }
|
||||
# Create the battle scene (the visual side of it)
|
||||
scene = pbNewBattleScene
|
||||
# Create the battle class (the mechanics side of it)
|
||||
battle = challengedata.createBattle(scene, $Trainer, opponent)
|
||||
battle.internalBattle = false
|
||||
battle.endSpeeches = [endspeech]
|
||||
battle.endSpeechesWin = [endspeechwin]
|
||||
# Set various other properties in the battle class
|
||||
pbPrepareBattle(battle)
|
||||
# Perform the battle itself
|
||||
decision = 0
|
||||
pbBattleAnimation(pbGetTrainerBattleBGM(opponent)) {
|
||||
pbSceneStandby {
|
||||
decision = battle.pbStartBattle
|
||||
}
|
||||
}
|
||||
Input.update
|
||||
# Restore both parties to their original levels
|
||||
challengedata.unadjustLevels($Trainer.party, opponent.party, oldlevels)
|
||||
# Heal both parties and restore their original items
|
||||
$Trainer.party.each_with_index do |pkmn, i|
|
||||
pkmn.heal
|
||||
pkmn.makeUnmega
|
||||
pkmn.makeUnprimal
|
||||
pkmn.item = olditems[i]
|
||||
end
|
||||
opponent.party.each_with_index do |pkmn, i|
|
||||
pkmn.heal
|
||||
pkmn.makeUnmega
|
||||
pkmn.makeUnprimal
|
||||
pkmn.item = olditems2[i]
|
||||
end
|
||||
# Save the record of the battle
|
||||
$PokemonTemp.lastbattle = nil
|
||||
if decision == 1 || decision == 2 || decision == 5 # if win, loss or draw
|
||||
$PokemonTemp.lastbattle = battle.pbDumpRecord
|
||||
end
|
||||
# Return true if the player won the battle, and false if any other result
|
||||
return (decision == 1)
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Methods that record and play back a battle.
|
||||
#===============================================================================
|
||||
def pbRecordLastBattle
|
||||
$PokemonGlobal.lastbattle = $PokemonTemp.lastbattle
|
||||
$PokemonTemp.lastbattle = nil
|
||||
end
|
||||
|
||||
def pbPlayLastBattle
|
||||
pbPlayBattle($PokemonGlobal.lastbattle)
|
||||
end
|
||||
|
||||
def pbPlayBattle(battledata)
|
||||
return if !battledata
|
||||
scene = pbNewBattleScene
|
||||
scene.abortable = true
|
||||
lastbattle = Marshal.restore(StringInput.new(battledata))
|
||||
case lastbattle[0]
|
||||
when BattleChallenge::BattleTowerID
|
||||
battleplayer = PokeBattle_BattlePlayer.new(scene, lastbattle)
|
||||
when BattleChallenge::BattlePalaceID
|
||||
battleplayer = PokeBattle_BattlePalacePlayer.new(scene, lastbattle)
|
||||
when BattleChallenge::BattleArenaID
|
||||
battleplayer = PokeBattle_BattleArenaPlayer.new(scene, lastbattle)
|
||||
end
|
||||
bgm = BattlePlayerHelper.pbGetBattleBGM(lastbattle)
|
||||
pbBattleAnimation(bgm) {
|
||||
pbSceneStandby {
|
||||
battleplayer.pbStartBattle
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Debug playback methods.
|
||||
#===============================================================================
|
||||
def pbDebugPlayBattle
|
||||
params = ChooseNumberParams.new
|
||||
params.setRange(0, 500)
|
||||
params.setInitialValue(0)
|
||||
params.setCancelValue(-1)
|
||||
num = pbMessageChooseNumber(_INTL("Choose a battle."), params)
|
||||
if num >= 0
|
||||
pbPlayBattleFromFile(sprintf("Battles/Battle%03d.dat", num))
|
||||
end
|
||||
end
|
||||
|
||||
def pbPlayBattleFromFile(filename)
|
||||
pbRgssOpen(filename, "rb") { |f| pbPlayBattle(f.read) }
|
||||
end
|
||||
@@ -0,0 +1,240 @@
|
||||
class BattleSwapScene
|
||||
def pbStartRentScene(rentals)
|
||||
# Create sprite hash
|
||||
@sprites={}
|
||||
@mode=0 # rental
|
||||
# Allocate viewport
|
||||
@rentals=rentals
|
||||
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||
@viewport.z=99999
|
||||
@sprites["title"]=Window_UnformattedTextPokemon.newWithSize(
|
||||
_INTL("RENTAL POKéMON"),0,0,Graphics.width,64,@viewport)
|
||||
@sprites["help"]=Window_UnformattedTextPokemon.newWithSize("",
|
||||
0,Graphics.height-64,Graphics.width,64,@viewport)
|
||||
@sprites["list"]=Window_AdvancedCommandPokemonEx.newWithSize(
|
||||
[],0,64,Graphics.width,Graphics.height-128,@viewport)
|
||||
@sprites["msgwindow"]=Window_AdvancedTextPokemon.newWithSize("",
|
||||
0,Graphics.height-64,Graphics.height,64,@viewport)
|
||||
@sprites["msgwindow"].visible=false
|
||||
addBackgroundPlane(@sprites,"bg","rentbg",@viewport)
|
||||
pbUpdateChoices([])
|
||||
pbDeactivateWindows(@sprites)
|
||||
# Fade in all sprites
|
||||
pbFadeInAndShow(@sprites) { pbUpdate }
|
||||
end
|
||||
|
||||
def pbStartSwapScene(currentPokemon,newPokemon)
|
||||
# Create sprite hash
|
||||
@sprites={}
|
||||
@mode=1 # swap
|
||||
# Allocate viewport
|
||||
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||
@viewport.z=99999
|
||||
@sprites["title"]=Window_UnformattedTextPokemon.newWithSize(
|
||||
_INTL("POKéMON SWAP"),0,0,Graphics.width,64,@viewport)
|
||||
@sprites["help"]=Window_UnformattedTextPokemon.newWithSize(
|
||||
"",0,Graphics.height-64,Graphics.width,64,@viewport)
|
||||
@sprites["list"]=Window_AdvancedCommandPokemonEx.newWithSize(
|
||||
[],0,64,Graphics.width,Graphics.height-128,@viewport)
|
||||
@sprites["msgwindow"]=Window_AdvancedTextPokemon.newWithSize(
|
||||
"",0,Graphics.height-64,Graphics.width,64,@viewport)
|
||||
@sprites["msgwindow"].visible=false
|
||||
addBackgroundPlane(@sprites,"bg","swapbg",@viewport)
|
||||
@currentPokemon=currentPokemon
|
||||
@newPokemon=newPokemon
|
||||
pbInitSwapScreen()
|
||||
pbDeactivateWindows(@sprites)
|
||||
# Fade in all sprites
|
||||
pbFadeInAndShow(@sprites) { pbUpdate }
|
||||
end
|
||||
|
||||
def pbInitSwapScreen
|
||||
commands=pbGetCommands(@currentPokemon,[])
|
||||
commands.push(_INTL("CANCEL"))
|
||||
@sprites["help"].text=_INTL("Select Pokémon to swap.")
|
||||
@sprites["list"].commands=commands
|
||||
@sprites["list"].index=0
|
||||
@mode=1
|
||||
end
|
||||
|
||||
# End the scene here
|
||||
def pbEndScene
|
||||
pbFadeOutAndHide(@sprites) { pbUpdate } # Fade out all sprites
|
||||
pbDisposeSpriteHash(@sprites) # Dispose all sprites
|
||||
@viewport.dispose # Dispose the viewport
|
||||
end
|
||||
|
||||
def pbShowCommands(commands)
|
||||
UIHelper.pbShowCommands(@sprites["msgwindow"],nil,commands) { pbUpdate }
|
||||
end
|
||||
|
||||
def pbConfirm(message)
|
||||
UIHelper.pbConfirm(@sprites["msgwindow"],message) { pbUpdate }
|
||||
end
|
||||
|
||||
def pbGetCommands(list, choices)
|
||||
commands = []
|
||||
for i in 0...list.length
|
||||
pkmn = list[i]
|
||||
category = pkmn.species_data.category
|
||||
selected = shadowctagFromColor(Color.new(232, 0, 0))
|
||||
cmd = _INTL("{1} - {2} Pokémon", pkmn.speciesName, category)
|
||||
cmd = selected + cmd if choices.include?(i)
|
||||
commands.push(cmd)
|
||||
end
|
||||
return commands
|
||||
end
|
||||
|
||||
# Processes the scene
|
||||
def pbChoosePokemon(canCancel)
|
||||
pbActivateWindow(@sprites,"list") {
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdate
|
||||
if Input.trigger?(Input::BACK) && canCancel
|
||||
return -1
|
||||
end
|
||||
if Input.trigger?(Input::USE)
|
||||
index=@sprites["list"].index
|
||||
if index==@sprites["list"].commands.length-1 && canCancel
|
||||
return -1
|
||||
elsif index==@sprites["list"].commands.length-2 && canCancel && @mode==2
|
||||
return -2
|
||||
else
|
||||
return index
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def pbUpdateChoices(choices)
|
||||
commands=pbGetCommands(@rentals,choices)
|
||||
@choices=choices
|
||||
if choices.length==0
|
||||
@sprites["help"].text=_INTL("Choose the first Pokémon.")
|
||||
elsif choices.length==1
|
||||
@sprites["help"].text=_INTL("Choose the second Pokémon.")
|
||||
else
|
||||
@sprites["help"].text=_INTL("Choose the third Pokémon.")
|
||||
end
|
||||
@sprites["list"].commands=commands
|
||||
end
|
||||
|
||||
def pbSwapChosen(_pkmnindex)
|
||||
commands=pbGetCommands(@newPokemon,[])
|
||||
commands.push(_INTL("PKMN FOR SWAP"))
|
||||
commands.push(_INTL("CANCEL"))
|
||||
@sprites["help"].text=_INTL("Select Pokémon to accept.")
|
||||
@sprites["list"].commands=commands
|
||||
@sprites["list"].index=0
|
||||
@mode=2
|
||||
end
|
||||
|
||||
def pbSwapCanceled
|
||||
pbInitSwapScreen
|
||||
end
|
||||
|
||||
def pbSummary(list,index)
|
||||
visibleSprites=pbFadeOutAndHide(@sprites) { pbUpdate }
|
||||
scene=PokemonSummary_Scene.new
|
||||
screen=PokemonSummaryScreen.new(scene)
|
||||
@sprites["list"].index=screen.pbStartScreen(list,index)
|
||||
pbFadeInAndShow(@sprites,visibleSprites) { pbUpdate }
|
||||
end
|
||||
|
||||
# Update the scene here, this is called once each frame
|
||||
def pbUpdate
|
||||
pbUpdateSpriteHash(@sprites)
|
||||
# Add other things that should be updated
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class BattleSwapScreen
|
||||
def initialize(scene)
|
||||
@scene = scene
|
||||
end
|
||||
|
||||
def pbStartRent(rentals)
|
||||
@scene.pbStartRentScene(rentals)
|
||||
chosen=[]
|
||||
loop do
|
||||
index=@scene.pbChoosePokemon(false)
|
||||
commands=[]
|
||||
commands.push(_INTL("SUMMARY"))
|
||||
if chosen.any? { |item| item==index }
|
||||
commands.push(_INTL("DESELECT"))
|
||||
else
|
||||
commands.push(_INTL("RENT"))
|
||||
end
|
||||
commands.push(_INTL("OTHERS"))
|
||||
command=@scene.pbShowCommands(commands)
|
||||
if command==0
|
||||
@scene.pbSummary(rentals,index)
|
||||
elsif command==1
|
||||
if chosen.any? { |item| item==index }
|
||||
chosen.delete(index)
|
||||
@scene.pbUpdateChoices(chosen.clone)
|
||||
else
|
||||
chosen.push(index)
|
||||
@scene.pbUpdateChoices(chosen.clone)
|
||||
if chosen.length==3
|
||||
if @scene.pbConfirm(_INTL("Are these three Pokémon OK?"))
|
||||
retval=[]
|
||||
chosen.each { |i| retval.push(rentals[i]) }
|
||||
@scene.pbEndScene
|
||||
return retval
|
||||
else
|
||||
chosen.delete(index)
|
||||
@scene.pbUpdateChoices(chosen.clone)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def pbStartSwap(currentPokemon,newPokemon)
|
||||
@scene.pbStartSwapScene(currentPokemon,newPokemon)
|
||||
loop do
|
||||
pkmn=@scene.pbChoosePokemon(true)
|
||||
if pkmn>=0
|
||||
commands=[_INTL("SUMMARY"),_INTL("SWAP"),_INTL("RECHOOSE")]
|
||||
command=@scene.pbShowCommands(commands)
|
||||
if command==0
|
||||
@scene.pbSummary(currentPokemon,pkmn)
|
||||
elsif command==1
|
||||
@scene.pbSwapChosen(pkmn)
|
||||
yourPkmn=pkmn
|
||||
loop do
|
||||
pkmn=@scene.pbChoosePokemon(true)
|
||||
if pkmn>=0
|
||||
if @scene.pbConfirm(_INTL("Accept this Pokémon?"))
|
||||
@scene.pbEndScene
|
||||
currentPokemon[yourPkmn]=newPokemon[pkmn]
|
||||
return true
|
||||
end
|
||||
elsif pkmn==-2
|
||||
@scene.pbSwapCanceled
|
||||
break # Back to first screen
|
||||
elsif pkmn==-1
|
||||
if @scene.pbConfirm(_INTL("Quit swapping?"))
|
||||
@scene.pbEndScene
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
# Canceled
|
||||
if @scene.pbConfirm(_INTL("Quit swapping?"))
|
||||
@scene.pbEndScene
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user