Remove Scripts folder to convert to submodule

This commit is contained in:
chardub
2025-04-19 15:43:57 -04:00
parent 0807a7ea79
commit 58da1023c1
429 changed files with 0 additions and 165507 deletions

View File

@@ -1,428 +0,0 @@
#===============================================================================
#
#===============================================================================
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
register(id, id[/double/], 3,
id[/^factory/] ? BattleFactoryID : BattleTowerID,
id[/open$/] ? 1 : 0)
pbWriteCup(id, rules)
end
def register(id, doublebattle, numPokemon, battletype, mode = 1)
ensureType(id)
if battletype == BattleFactoryID
@bc.setExtraData(BattleFactoryData.new(@bc))
numPokemon = 3
battletype = BattleTowerID
end
@rules = modeToRules(doublebattle, numPokemon, battletype, mode) if !@rules
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
INITIAL_BST=350
def initialize(bcdata)
@bcdata = bcdata
end
def pbPrepareRentals
@rentals = pbBattleFactoryPokemon(pbBattleChallenge.rules, @bcdata.wins, @bcdata.swaps, [])
@trainerid = @bcdata.nextTrainer
bttrainers = pbGetBTTrainers(pbBattleChallenge.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
@bcdata.setParty(@rentals)
}
end
def pbPrepareSwaps
@oldopponent = @opponent.party
trainerid = @bcdata.nextTrainer
bttrainers = pbGetBTTrainers(pbBattleChallenge.currentChallenge)
trainerdata = bttrainers[trainerid]
@opponent = NPCTrainer.new(
pbGetMessageFromHash(MessageTypes::TrainerNames, trainerdata[1]),
trainerdata[0])
opponentPkmn = pbBattleFactoryPokemon(pbBattleChallenge.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(pbBattleChallenge.currentChallenge)
trainerdata = bttrainers[@trainerid]
return pbOrganizedBattleEx(@opponent, challenge.rules,
pbGetMessageFromHash(MessageTypes::EndSpeechLose, trainerdata[4]),
pbGetMessageFromHash(MessageTypes::EndSpeechWin, trainerdata[3]))
end
end

View File

@@ -1,316 +0,0 @@
#===============================================================================
#
#===============================================================================
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 listAllPokemon
list=[]
for i in 0..PBSpecies.maxValue
list << i
end
return list
end
def pbGetBTPokemon(challenge_id)
customsOnly = !$game_switches[SWITCH_BATTLE_FACTORY_INCLUDE_ALL]
if customsOnly
customsList = getCustomSpeciesList()
return customsList if customsList
end
return listAllPokemon
# list=[]
# while list.length <= target_size
# list << generate_random_species(max_bst)
# end
# return list
end
def generate_random_species(max_bst)
additional_bst = $game_variables[120]
species=0
bonus = 0
while (species==0) # Loop Start
bonus+= 5 #+ de chance de pogner un bon poke a chaque loop (permet d'eviter infinite loop)
species=rand(PBSpecies.maxValue)+1
bst = calcBaseStatsSum(species)
species=0 if bst > max_bst+additional_bst
end
return species
end
#===============================================================================
#
#===============================================================================
def pbEntryScreen(ableproc=nil)
retval = false
pbFadeOutIn {
scene = PokemonParty_Scene.new
screen = PokemonPartyScreen.new(scene, $Trainer.party)
ret = screen.pbPokemonMultipleEntryScreenEx(pbBattleChallenge.rules.ruleset,ableproc)
# Set party
pbBattleChallenge.setParty(ret) if ret
# Continue (return true) if Pokémon were chosen
retval = (ret != nil && ret.length > 0)
}
return retval
end
def pbEntryScreenArgs(*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 getTrainerTypeGraphic(trainerType)
case trainerType
when :YOUNGSTER then return "BW (19)"
when :LASS then return "BW (23)"
when :POKEMANIAC then return "BW (30)"
when :PSYCHIC_F then return "BW (30)"
when :GENTLEMAN then return "BW (55)"
when :LADY then return "BW (28)"
when :CAMPER then return "BW (59)"
when :PICNICKER then return "BW (60)"
when :TUBER_M then return "BWTuber_male"
when :TUBER_F then return "BWTuber_female"
when :SWIMMER_M then return "BWSwimmerLand"
when :SWIMMER_F then return "BWSwimmer_female2"
when :COOLTRAINER_F then return "BW024"
when :JUGGLER then return "BWHarlequin"
when :POKEMONBREEDER then return "BW028"
when :BUGCATCHER then return "BWBugCatcher_male"
when :BLACKBELT then return "BWBlackbelt"
when :FISHERMAN then return "BW (71)"
when :RUINMANIAC then return "BW (72)"
when :TAMER then return "BW (69)"
when :BEAUTY then return "BW015"
when :AROMALADY then return "BWAomalady"
when :ROCKER then return "BWPunkGuy"
when :BIRDKEEPER then return "BW (29)"
when :SAILOR then return "BWSailor"
when :HIKER then return "BWHiker"
when :ENGINEER then return "BW (75)"
when :COOLTRAINER_M then return "BW023"
when :BIKER then return "BW055"
when :CRUSHGIRL then return "BWBattleGirl"
when :POKEMONRANGER_M then return "BW (47)"
when :POKEMONRANGER_F then return "BW (48)"
when :PSYCHIC_M then return "BW (30)"
when :CHANNELER then return "BW (40)"
when :GAMBLER then return "BW (111)"
when :SCIENTIST then return "BW (81)"
when :SUPERNERD then return "BW (81)"
when :CUEBALL then return "BWRoughneck"
end
end
#===============================================================================
#
#===============================================================================
def pbBattleChallengeGraphic(event)
nextTrainer = pbBattleChallenge.nextTrainer
bttrainers = pbGetBTTrainers(pbBattleChallenge.currentChallenge)
trainerType = (bttrainers[nextTrainer][0] rescue nil)
filename = getTrainerTypeGraphic(trainerType)
begin
filename = "" if nil_or_empty?(filename)
bitmap = AnimatedBitmap.new("Graphics/Characters/" + filename)
bitmap.dispose
event.character_name = filename
rescue
event.character_name = "BWClerk"
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

View File

@@ -1,188 +0,0 @@
#===============================================================================
# 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 || 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(rndpoke,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
#
minBst = pbGet(VAR_BATTLE_TOWER_MIN_BST)
maxBst = pbGet(VAR_BATTLE_TOWER_MAX_BST)
loop do
opponent.party.clear
while opponent.party.length < rules.ruleset.suggestedNumber
rndpoke = getRandomPokemonSpecies(btpokemon,minBst,maxBst)
opponent.party.push(createPokemon(rndpoke,level, indvalues, nil))
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 881. They are scaled based on the actual size of btpokemon.
# Group 1 is 0 - 173. Group 2 is 174 - 371. Group 3 is 372 - 881.
if level == GameData::GrowthRate.max_level # Open Level (Level 100)
table = [
[372, 491], # Group 3 (first quarter)
[492, 610], # Group 3 (second quarter)
[611, 729], # Group 3 (third quarter)
[730, 849], # Group 3 (fourth quarter)
[372, 881], # All of Group 3
[372, 881], # All of Group 3
[372, 881], # All of Group 3
[372, 881] # This line is used for all higher sets (all of Group 3)
]
else
table = [
[ 0, 173], # Group 1
[174, 272], # Group 2 (first half)
[273, 371], # Group 2 (second half)
[372, 491], # Group 3 (first quarter)
[492, 610], # Group 3 (second quarter)
[611, 729], # Group 3 (third quarter)
[730, 849], # Group 3 (fourth quarter)
[372, 881] # This line is used for all higher sets (all of Group 3)
]
end
pokemonNumbers[0] = table[set][0] * btpokemon.length / 881
pokemonNumbers[1] = table[set][1] * btpokemon.length / 881
# 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
old_min = rules.ruleset.minLength
old_max = rules.ruleset.maxLength
if rentals.length == 0
rules.ruleset.setNumber(6) # Rentals
else
rules.ruleset.setNumber(old_max + rentals.length) # Opponent
end
party = []
loop do
party.clear
while party.length < ((rentals.length == 0) ? 6 : old_max)
rnd = pokemonNumbers[0] + rand(pokemonNumbers[1] - pokemonNumbers[0] + 1)
rndpoke = btpokemon[rnd]
indvalue = (party.length < iv_threshold) ? ivs[0] : ivs[1]
party.push(createPokemon(rndpoke,level, indvalue, nil))
end
break if rules.ruleset.isValid?([].concat(party).concat(rentals))
end
rules.ruleset.setNumberRange(old_min, old_max)
return party
end
def createPokemon(species, level, iv, trainer)
pkmn = Pokemon.new(species, level, trainer)
pkmn.personalID = rand(2 ** 16) | rand(2 ** 16) << 16
GameData::Stat.each_main { |s| pkmn.iv[s.id] = iv }
pkmn.calc_stats
return pkmn
end
#list is a list of dex numbers of possible choices
def getRandomPokemonSpecies(list=[],minBST=0,maxBST=1000)
if list == []
list = listAllPokemon
end
bst=-1
while (bst < minBST || bst > maxBST)
chosenPokemon = list.sample
bst = calcBaseStatsSum(chosenPokemon)
end
return chosenPokemon
end

View File

@@ -1,146 +0,0 @@
#===============================================================================
#
#===============================================================================
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..."))
pbMessage(endspeech || "...")
$PokemonTemp.lastbattle = nil
pbMEStop
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(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

View File

@@ -1,230 +0,0 @@
class BattleSwapScene
def pbStartRentScene(rentals)
@rentals = rentals
@mode = 0 # rental (pick 3 out of 6 initial Pokémon)
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99999
@sprites = {}
addBackgroundPlane(@sprites, "bg", "rentbg", @viewport)
@sprites["title"] = Window_UnformattedTextPokemon.newWithSize(
_INTL("RENTAL POKÉMON"), 0, 0, Graphics.width, 64, @viewport)
@sprites["list"] = Window_AdvancedCommandPokemonEx.newWithSize(
[], 0, 64, Graphics.width, Graphics.height - 128 , @viewport)
@sprites["help"] = Window_UnformattedTextPokemon.newWithSize("",
0, Graphics.height - 64, Graphics.width, 64, @viewport)
@sprites["msgwindow"] = Window_AdvancedTextPokemon.newWithSize("",
0, Graphics.height - 64, Graphics.height, 64, @viewport)
@sprites["msgwindow"].visible = false
pbUpdateChoices([])
pbDeactivateWindows(@sprites)
pbFadeInAndShow(@sprites) { pbUpdate }
end
def pbStartSwapScene(currentPokemon, newPokemon)
@currentPokemon = currentPokemon
@newPokemon = newPokemon
@mode = 1 # swap (pick 1 out of 3 opponent's Pokémon to take)
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99999
@sprites = {}
addBackgroundPlane(@sprites, "bg", "swapbg", @viewport)
@sprites["title"] = Window_UnformattedTextPokemon.newWithSize(
_INTL("POKÉMON SWAP"), 0, 0, Graphics.width, 64, @viewport)
@sprites["list"] = Window_AdvancedCommandPokemonEx.newWithSize(
[], 0, 64, Graphics.width, Graphics.height - 128, @viewport)
@sprites["help"] = Window_UnformattedTextPokemon.newWithSize(
"", 0, Graphics.height - 64, Graphics.width, 64, @viewport)
@sprites["msgwindow"] = Window_AdvancedTextPokemon.newWithSize(
"", 0, Graphics.height - 64, Graphics.width, 64, @viewport)
@sprites["msgwindow"].visible = false
pbInitSwapScreen
pbDeactivateWindows(@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 }
pbDisposeSpriteHash(@sprites)
@viewport.dispose
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
cmd = _INTL("{1} - {2} Pokémon", pkmn.speciesName, category)
cmd = "<c3=E82010,F8A8B8>" + cmd if choices.include?(i) # Red text
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
elsif 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
def pbUpdate
pbUpdateSpriteHash(@sprites)
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.include?(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.include?(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