mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2026-11-03 08:15:47 +00:00
931 lines
31 KiB
Ruby
931 lines
31 KiB
Ruby
#A l'entrée d'un gym: mettre $game_variables[113] = au numéro du gym
|
|
#pewter = 0, ceruean = 1 etc.
|
|
#Le remettre a -1 à la sortie du gym
|
|
#Le mettre a -1 au début du jeu
|
|
#
|
|
#Aussi des trucs modifiés dans le dude qui donne les freshwater au début
|
|
#Faudrait aussi s'assurer que il dise pas n'importe quoi en pas randomized
|
|
#
|
|
#Voir cerulean gym pour implantation
|
|
#
|
|
#
|
|
#
|
|
#
|
|
#initialiser la RANDOM_TYPE_ARRAY au début du jeu en runnant Kernel.initRandomTypeArray(8)
|
|
#
|
|
#
|
|
#
|
|
#
|
|
#
|
|
#
|
|
##################################################################
|
|
# TODO:
|
|
#
|
|
#
|
|
#
|
|
###
|
|
###############################################################
|
|
#
|
|
|
|
#GYM_TYPES_ARRAY = [0,5,11,13,12,3,14,10,4,1,0,6,2,16,7,15,1,8,15,1,7,16,18,17,7,16]
|
|
GYM_TYPES_CLASSIC = [:NORMAL, :ROCK, :WATER, :ELECTRIC, :GRASS, :POISON, :PSYCHIC, :FIRE, :GROUND, :FIGHTING, :NORMAL, :BUG, :FLYING, :DRAGON, :GHOST, :ICE, :FIGHTING, :STEEL, :ICE, :FIGHTING, :GHOST, :DRAGON, :FAIRY, :DARK, :GHOST, :ROCK]
|
|
GYM_TYPES_MODERN = [:NORMAL, :STEEL, :ICE, :FIGHTING, :BUG, :DARK, :FAIRY, :PSYCHIC, :NORMAL, :FIGHTING, :FAIRY, :GRASS, :BUG, :DRAGON, :FIRE, :GHOST, :GROUND, :ELECTRIC, :WATER, :ROCK, :POISON, :FLYING, :FAIRY, :DARK, :GHOST, :DRAGON]
|
|
|
|
GYM_TYPES_HOENN_CLASSIC = [:NORMAL, :ROCK, :FIGHTING, :ELECTRIC, :FIRE, :NORMAL, :FLYING, :PSYCHIC, :WATER, :PSYCHIC, :GHOST, :ICE, :DRAGON, :STEEL]
|
|
|
|
GYM_TYPES_ARRAY = ($game_switches && $game_switches[SWITCH_MODERN_MODE]) ? GYM_TYPES_MODERN : GYM_TYPES_CLASSIC
|
|
GYM_TYPES_ARRAY_HOENN = ($game_switches && $game_switches[SWITCH_MODERN_MODE]) ? GYM_TYPES_MODERN : GYM_TYPES_HOENN_CLASSIC
|
|
|
|
|
|
#$randomTrainersArray = []
|
|
|
|
#[fighting dojo est 9eme (1), 0 au debut pour pasavoir a faire -1]
|
|
|
|
def Kernel.initRandomTypeArray()
|
|
typesArray = GYM_TYPES_ARRAY.shuffle #ne pas remettre 10 (QMARKS)
|
|
if Settings::KANTO
|
|
$game_variables[VAR_GYM_TYPES_ARRAY] = $game_switches[SWITCH_RANDOMIZED_GYM_TYPES] ? typesArray : GYM_TYPES_ARRAY
|
|
elsif Settings::HOENN
|
|
$game_variables[VAR_GYM_TYPES_ARRAY] = $game_switches[SWITCH_RANDOMIZED_GYM_TYPES] ? typesArray : GYM_TYPES_ARRAY_HOENN
|
|
end
|
|
end
|
|
|
|
# def setRivalStarter(starter1, starter2, starter3, choice)
|
|
# starters = [starter1, starter2, starter3]
|
|
# starters.delete_at(choice)
|
|
# if starters[0] > NB_POKEMON || starters[1] > NB_POKEMON
|
|
# rivalStarter = starters[0]
|
|
# else
|
|
# rivalStarter = starters[0] * NB_POKEMON + starters[1]
|
|
# end
|
|
# pbSet(VAR_RIVAL_STARTER, rivalStarter)
|
|
# $game_switches[SWITCH_DEFINED_RIVAL_STARTER] = true
|
|
# end
|
|
|
|
def setRivalStarterSpecific(rivalStarter)
|
|
pbSet(VAR_RIVAL_STARTER, rivalStarter)
|
|
$game_switches[SWITCH_DEFINED_RIVAL_STARTER] = true
|
|
end
|
|
|
|
class PokeBattle_Battle
|
|
CONST_BST_RANGE = 25 #unused. $game_variables[197] a la place
|
|
def randomize_opponent_party(party)
|
|
for pokemon in party
|
|
next if !pokemon
|
|
newspecies = rand(PBSpecies.maxValue - 1) + 1
|
|
while !gymLeaderOk(newspecies) || bstNotOk(newspecies, pokemon.species, $game_variables[VAR_RANDOMIZER_WILD_POKE_BST])
|
|
newspecies = rand(PBSpecies.maxValue - 1) + 1
|
|
end
|
|
pokemon.species = newspecies
|
|
pokemon.name = PBSpecies.getName(newspecies)
|
|
pokemon.resetMoves
|
|
pokemon.calcStats
|
|
end
|
|
|
|
return party
|
|
end
|
|
|
|
def randomizedRivalFirstBattle(party)
|
|
return party if $game_switches[953] #full random
|
|
starter1 = $PokemonGlobal.psuedoBSTHash[1]
|
|
starter2 = $PokemonGlobal.psuedoBSTHash[4]
|
|
starter3 = $PokemonGlobal.psuedoBSTHash[7]
|
|
playerChoice = $game_variables[7]
|
|
|
|
for m in party
|
|
next if !m
|
|
case playerChoice
|
|
when 0 then
|
|
newspecies = starter2 * NB_POKEMON + starter3
|
|
when 1 then
|
|
newspecies = starter1 * NB_POKEMON + starter3
|
|
when 2 then
|
|
newspecies = starter1 * NB_POKEMON + starter2
|
|
else
|
|
end
|
|
m.species = newspecies
|
|
m.name = PBSpecies.getName(newspecies)
|
|
m.resetMoves
|
|
m.calcStats
|
|
end
|
|
return party
|
|
end
|
|
end
|
|
|
|
#######
|
|
# end of class
|
|
######
|
|
|
|
####methodes utilitaires
|
|
|
|
# def getBaseStats(species)
|
|
# basestatsum = $pkmn_dex[species][5][0] # HP
|
|
# basestatsum +=$pkmn_dex[species][5][1] # Attack
|
|
# basestatsum +=$pkmn_dex[species][5][2] # Defense
|
|
# basestatsum +=$pkmn_dex[species][5][3] # Speed
|
|
# basestatsum +=$pkmn_dex[species][5][4] # Special Attack
|
|
# basestatsum +=$pkmn_dex[species][5][5] # Special Defense
|
|
# return basestatsum
|
|
# end
|
|
#
|
|
|
|
def legendaryOk(oldspecies,newspecies,includeLegendaries)
|
|
oldSpeciesIsLegendary = is_legendary(oldspecies)
|
|
if oldSpeciesIsLegendary #legendaries always randomize to legendaries
|
|
return is_legendary(newspecies)
|
|
else
|
|
return true if includeLegendaries
|
|
return !is_legendary(newspecies)
|
|
end
|
|
|
|
end
|
|
|
|
def egg_group_ok(oldSpecies_id,newSpecies_id)
|
|
oldSpecies = GameData::Species.get(oldSpecies_id)
|
|
newSpecies = GameData::Species.get(newSpecies_id)
|
|
oldEggGroups = Array(oldSpecies.egg_groups)
|
|
newEggGroups = Array(newSpecies.egg_groups)
|
|
return oldEggGroups.any? { |g| newEggGroups.include?(g) }
|
|
end
|
|
|
|
def bstNotOk(newspecies, oldPokemonSpecies, bst_range = 50)
|
|
newBST = calcBaseStatsSum(newspecies)
|
|
originalBST = calcBaseStatsSum(oldPokemonSpecies)
|
|
return newBST < originalBST - bst_range || newBST > originalBST + bst_range
|
|
end
|
|
|
|
def legendaryOk_cached(oldspecies, newspecies, includeLegendaries, legendary_cache)
|
|
old_legendary = legendary_cache[oldspecies]
|
|
return legendary_cache[newspecies] if old_legendary
|
|
return true if includeLegendaries
|
|
return !legendary_cache[newspecies]
|
|
end
|
|
|
|
def egg_group_ok_cached(oldSpecies_id, newSpecies_id, egg_group_cache)
|
|
old_groups = egg_group_cache[oldSpecies_id]
|
|
new_groups = egg_group_cache[newSpecies_id]
|
|
old_groups.any? { |g| new_groups.include?(g) }
|
|
end
|
|
|
|
def bstNotOk_cached(newspecies, oldPokemonSpecies, bst_range, bst_cache)
|
|
newBST = bst_cache[newspecies]
|
|
originalBST = bst_cache[oldPokemonSpecies]
|
|
newBST < originalBST - bst_range || newBST > originalBST + bst_range
|
|
end
|
|
|
|
def gymLeaderOk(newspecies)
|
|
return true if $game_variables[VAR_CURRENT_GYM_TYPE] == -1 #not in a gym
|
|
leaderType = getLeaderType()
|
|
if leaderType == nil
|
|
return true
|
|
else
|
|
return true if SpeciesHasType?(leaderType, newspecies)
|
|
end
|
|
return false
|
|
end
|
|
|
|
def getLeaderType()
|
|
currentGym = $game_variables[VAR_CURRENT_GYM_TYPE]
|
|
if currentGym > $game_variables[VAR_GYM_TYPES_ARRAY].length
|
|
return nil
|
|
else
|
|
typeIndex = $game_variables[VAR_GYM_TYPES_ARRAY][currentGym]
|
|
type = PBTypes.getName(typeIndex)
|
|
end
|
|
return typeIndex
|
|
end
|
|
|
|
##Version alternatives de fonctions pour fonctionner avec numero de species
|
|
def SpeciesHasType?(type, species)
|
|
if type.is_a?(String) || type.is_a?(Symbol)
|
|
return isConst?(getSpeciesType1(species), PBTypes, type) || isConst?(getSpeciesType2(species), PBTypes, type)
|
|
else
|
|
return getSpeciesType1(species) == type || getSpeciesType2(species) == type
|
|
end
|
|
end
|
|
|
|
# Returns this Pokémon's first type.
|
|
def getSpeciesType1(species)
|
|
return $pkmn_dex[species][3]
|
|
end
|
|
|
|
# Returns this Pokémon's second type.
|
|
def getSpeciesType2(species)
|
|
return $pkmn_dex[species][4]
|
|
end
|
|
|
|
############
|
|
|
|
#summarize random options
|
|
def Kernel.sumRandomOptions()
|
|
answer = $game_switches[SWITCH_RANDOM_STARTERS] ? _INTL("On") : _INTL("Off")
|
|
stringOptions = _INTL("\nStarters: ") << answer
|
|
|
|
answer = $game_switches[SWITCH_RANDOM_WILD] ? _INTL("On") : _INTL("Off")
|
|
stringOptions << _INTL("\nWild Pokémon: ") << answer << " "
|
|
if $game_switches[SWITCH_RANDOM_WILD_AREA]
|
|
stringOptions << _INTL("(Area)")
|
|
else
|
|
stringOptions << _INTL("(Global)")
|
|
end
|
|
|
|
answer = $game_switches[SWITCH_RANDOM_TRAINERS] ? _INTL("On") : _INTL("Off")
|
|
stringOptions << _INTL("\nTrainers: ") << answer
|
|
|
|
answer = $game_switches[SWITCH_RANDOM_STATIC_ENCOUNTERS] ? _INTL("On") : _INTL("Off")
|
|
stringOptions << _INTL("\nStatic encounters: ") << answer
|
|
|
|
answer = $game_switches[SWITCH_RANDOM_GIFT_POKEMON] ? _INTL("On") : _INTL("Off")
|
|
stringOptions << _INTL("\nGift Pokémon: ") << answer
|
|
|
|
answer = $game_switches[SWITCH_RANDOM_ITEMS] ? _INTL("On") : _INTL("Off")
|
|
stringOptions << _INTL("\nItems: ") << answer
|
|
|
|
answer = $game_switches[SWITCH_RANDOM_TMS] ? _INTL("On") : _INTL("Off")
|
|
stringOptions << _INTL("\nTMs: ") << answer
|
|
|
|
return stringOptions
|
|
end
|
|
|
|
def countVisitedMaps
|
|
count = 0
|
|
for i in 0..$PokemonGlobal.visitedMaps.length
|
|
count += 1 if $PokemonGlobal.visitedMaps[i]
|
|
end
|
|
return count
|
|
end
|
|
|
|
def Kernel.sumGameStats()
|
|
stringStats = ""
|
|
|
|
stringStats << _INTL("Seen {1} Pokémon",$Trainer.pokedexSeen.to_s)
|
|
stringStats << _INTL("\nCaught {1} Pokémon",$Trainer.pokedexOwned.to_s)
|
|
|
|
stringStats << _INTL("\nBeat the Elite Four {1} times",$game_variables[VAR_STAT_NB_ELITE_FOUR].to_s)
|
|
stringStats << _INTL("\nFused {1} Pokémon", $game_variables[VAR_STAT_NB_FUSIONS].to_s)
|
|
|
|
stringStats << _INTL("\nRematched {1} Gym Leaders",$game_variables[VAR_STAT_LEADER_REMATCH].to_s)
|
|
stringStats << _INTL("\nTook {1} steps",$PokemonGlobal.stepcount.to_s)
|
|
stringStats << _INTL("\nVisited {1} different areas",countVisitedMaps.to_s)
|
|
stringStats << _INTL("\nUsed {1} Rare Candies",$game_variables[VAR_STAT_RARE_CANDY])
|
|
|
|
if $game_switches[910]
|
|
stringStats << _INTL("\nMade {1} Wonder Trades",$game_variables[VAR_STAT_NB_WONDERTRADES].to_s)
|
|
end
|
|
|
|
stringStats << _INTL("\nTipped ${1} to clowns",$game_variables[VAR_STAT_CLOWN_TIP_TOTAL].to_s)
|
|
stringStats << _INTL("\nDestroyed {1} sandcastles",$game_variables[VAR_STAT_NB_SANDCASTLES].to_s)
|
|
stringStats << _INTL("\nReported {1} crimes",$game_variables[VAR_NB_CRIMES_REPORTED].to_s) if $game_variables[VAR_NB_CRIMES_REPORTED] > 0
|
|
|
|
|
|
if $game_variables[VAR_STAT_GAMBLER_WINS] > 0 || $game_variables[VAR_STAT_GAMBLER_LOSSES] > 0
|
|
stringStats << _INTL("\nWon ${1} against gamblers",$game_variables[VAR_STAT_GAMBLER_WINS].to_s)
|
|
stringStats << _INTL("\nLost ${1} against gamblers",$game_variables[VAR_STAT_GAMBLER_LOSSES].to_s)
|
|
end
|
|
stringStats << _INTL("\nSpent ${1} at hotels",$game_variables[VAR_STAT_HOTELS_SPENT].to_s)
|
|
|
|
stringStats << _INTL("\nAccepted {1} quests",$game_variables[VAR_STAT_QUESTS_ACCEPTED].to_s)
|
|
stringStats << _INTL("\nCompleted {1} quests",$game_variables[VAR_STAT_QUESTS_COMPLETED].to_s)
|
|
stringStats << _INTL("\nDiscovered {1} secrets",$game_variables[VAR_STAT_NB_SECRETS].to_s)
|
|
|
|
if $game_switches[912]
|
|
stringStats << _INTL("\nDied {1} times in Pikachu's adventure",$game_variables[191].to_s)
|
|
if $game_variables[193] >= 1
|
|
stringStats << _INTL("\nCollected {1} coins with Pikachu",$game_variables[194].to_s)
|
|
end
|
|
end
|
|
return stringStats
|
|
end
|
|
|
|
def Kernel.pbRandomizeTM()
|
|
tmList = []
|
|
for item in $itemData
|
|
#machine=$ItemData[item][ITEMMACHINE]
|
|
#movename=PBMoves.getName(machine)
|
|
#Kernel.pbMessage("It contained {1}.\1",item)
|
|
|
|
tmList << item if pbIsHiddenMachine?(item)
|
|
end
|
|
end
|
|
|
|
def getNewSpecies(oldSpecies, bst_range = 50, ignoreRivalPlaceholder = false, maxDexNumber = PBSpecies.maxValue, includeLegendaries=true, same_egg_group=false)
|
|
oldSpecies_dex = dexNum(oldSpecies)
|
|
return oldSpecies_dex if (oldSpecies_dex == Settings::RIVAL_STARTER_PLACEHOLDER_SPECIES && !ignoreRivalPlaceholder)
|
|
return oldSpecies_dex if oldSpecies_dex >= Settings::ZAPMOLCUNO_NB
|
|
|
|
if $game_switches[SWITCH_LEGENDARY_MODE]
|
|
new_species = convert_species_to_legendary(oldSpecies)
|
|
return dexNum(new_species)
|
|
end
|
|
|
|
newspecies_dex = rand(maxDexNumber - 1) + 1
|
|
i = 0
|
|
validated = false
|
|
until validated
|
|
is_valid = true
|
|
is_valid = false if bstNotOk(newspecies_dex, oldSpecies_dex, bst_range)
|
|
is_valid = false unless legendaryOk(oldSpecies_dex, newspecies_dex, includeLegendaries)
|
|
is_valid = false if same_egg_group && !egg_group_ok(oldSpecies_dex, newspecies_dex)
|
|
|
|
validated = is_valid
|
|
unless validated
|
|
newspecies_dex = rand(maxDexNumber - 1) + 1
|
|
i += 1
|
|
bst_range += 5 if i % 10 == 0
|
|
end
|
|
break if i > 200
|
|
end
|
|
|
|
return newspecies_dex
|
|
end
|
|
|
|
|
|
#Don't use cache past this point
|
|
CUSTOM_LIST_THRESHOLD = 5000
|
|
|
|
|
|
def new_bst_cache
|
|
Hash.new { |h, sp| h[sp] = calcBaseStatsSum(sp) }
|
|
end
|
|
|
|
def new_egg_group_cache
|
|
Hash.new { |h, sp| h[sp] = Array(GameData::Species.get(sp).egg_groups) }
|
|
end
|
|
|
|
def new_legendary_cache
|
|
Hash.new { |h, sp| h[sp] = is_legendary_num(sp) }
|
|
end
|
|
|
|
def getNewCustomSpecies(oldSpecies, customSpeciesList, bst_range, ignoreRivalPlaceholder, includeLegendaries, same_egg_group,
|
|
bst_cache = nil, egg_group_cache = nil, legendary_cache = nil, fallback_cache = nil)
|
|
if $game_switches[SWITCH_LEGENDARY_MODE]
|
|
return dexNum(convert_species_to_legendary(oldSpecies))
|
|
end
|
|
|
|
oldSpecies_dex = dexNum(oldSpecies)
|
|
return oldSpecies_dex if (oldSpecies_dex == Settings::RIVAL_STARTER_PLACEHOLDER_SPECIES && !ignoreRivalPlaceholder)
|
|
return oldSpecies_dex if oldSpecies_dex >= Settings::ZAPMOLCUNO_NB
|
|
|
|
#when cache not passed as argument: initialize
|
|
bst_cache ||= new_bst_cache
|
|
egg_group_cache ||= new_egg_group_cache
|
|
legendary_cache ||= new_legendary_cache
|
|
fallback_cache ||= {}
|
|
|
|
ok = lambda do |sp, range|
|
|
!bstNotOk_cached(sp, oldSpecies_dex, range, bst_cache) &&
|
|
legendaryOk_cached(oldSpecies_dex, sp, includeLegendaries, legendary_cache) &&
|
|
(!same_egg_group || egg_group_ok_cached(oldSpecies_dex, sp, egg_group_cache))
|
|
end
|
|
|
|
# Fast path: random picks (works great when the list is big)
|
|
range = bst_range
|
|
100.times do |n|
|
|
sp = customSpeciesList.sample
|
|
return sp if ok.call(sp, range)
|
|
range += 5 if (n + 1) % 10 == 0
|
|
end
|
|
|
|
# Slow path (rare with big lists, cheap with small ones): full filter, cached per old species
|
|
key = [oldSpecies_dex, bst_range, includeLegendaries, same_egg_group]
|
|
candidates = fallback_cache[key]
|
|
if candidates.nil?
|
|
range = bst_range
|
|
candidates = []
|
|
10.times do
|
|
candidates = customSpeciesList.select { |sp| ok.call(sp, range) }
|
|
break unless candidates.empty?
|
|
range += 5
|
|
end
|
|
candidates = customSpeciesList if candidates.empty?
|
|
fallback_cache[key] = candidates
|
|
end
|
|
candidates.sample
|
|
end
|
|
|
|
def playShuffleSE(i)
|
|
if i % 40 == 0 || i == 0
|
|
pbSEPlay("Charm", 60)
|
|
end
|
|
end
|
|
|
|
def getTrainersDataMode
|
|
mode = GameData::Trainer
|
|
if $game_switches && $game_switches[SWITCH_MODERN_MODE]
|
|
mode = GameData::TrainerModern
|
|
elsif $game_switches && $game_switches[SWITCH_EXPERT_MODE]
|
|
mode = GameData::TrainerExpert
|
|
end
|
|
return mode
|
|
end
|
|
|
|
def Kernel.pbShuffleTrainers(bst_range = 50, customsOnly = false, customsList = nil)
|
|
bst_range = pbGet(VAR_RANDOMIZER_TRAINER_BST)
|
|
customsOnly = false if customsOnly && customsList == nil
|
|
randomTrainersHash = Hash.new
|
|
|
|
# Create the bar BEFORE any heavy work so the screen updates immediately
|
|
progress_bar = ShuffleProgressBar.new(_INTL("Shuffling Trainers..."))
|
|
update_progress_bar(progress_bar, 0, 1)
|
|
|
|
begin
|
|
trainers_data = getTrainersDataMode.list_all
|
|
|
|
bst_cache = new_bst_cache
|
|
egg_group_cache = new_egg_group_cache
|
|
legendary_cache = new_legendary_cache
|
|
fallback_cache = {}
|
|
|
|
total = trainers_data.size
|
|
i = 0
|
|
trainers_data.each do |key, value|
|
|
trainer = trainers_data[key]
|
|
new_party = []
|
|
same_egg_group = $game_switches[SWITCH_RANDOM_TRAINERS]
|
|
for poke in trainer.pokemon
|
|
old_poke = GameData::Species.get(poke[:species]).id_number
|
|
new_poke = customsOnly ?
|
|
getNewCustomSpecies(old_poke, customsList, bst_range, false, true, same_egg_group, bst_cache, egg_group_cache, legendary_cache, fallback_cache) :
|
|
getNewSpecies(old_poke, bst_range, false, PBSpecies.maxValue, true, same_egg_group)
|
|
new_party << new_poke
|
|
end
|
|
randomTrainersHash[trainer.id] = new_party
|
|
i += 1
|
|
if i % 20 == 0 || i == total
|
|
playShuffleSE(i)
|
|
update_progress_bar(progress_bar, i, total)
|
|
end
|
|
end
|
|
ensure
|
|
progress_bar.dispose
|
|
end
|
|
|
|
$PokemonGlobal.randomTrainersHash = randomTrainersHash
|
|
$PokemonTemp.should_reshuffle_trainers = false
|
|
end
|
|
|
|
def update_progress_bar(progress_bar, nb_processed, nb_to_process)
|
|
return if !progress_bar || progress_bar.disposed?
|
|
progress_bar.progress = nb_processed.to_f / nb_to_process
|
|
progress_bar.update
|
|
end
|
|
|
|
|
|
# def Kernel.pbShuffleTrainers(bst_range = 50)
|
|
# randomTrainersHash = Hash.new
|
|
#
|
|
# trainers=load_data("Data/trainers.dat")
|
|
# i=0
|
|
# for trainer in trainers
|
|
# for poke in trainer[3]
|
|
# poke[TPSPECIES]=getNewSpecies(poke[TPSPECIES])
|
|
# end
|
|
# randomTrainersHash[i] = (trainer)
|
|
# playShuffleSE(i)
|
|
# i += 1
|
|
# if i % 2 == 0
|
|
# n = (i.to_f/trainers.length)*100
|
|
# Kernel.pbMessageNoSound("\\ts[]Shuffling trainers...\\n {1}%\\^",sprintf('%.2f', n),PBSpecies.maxValue)
|
|
# end
|
|
# #Kernel.pbMessage("pushing trainer {1}: {2} ",i,trainer)
|
|
# end
|
|
# $PokemonGlobal.randomTrainersHash = randomTrainersHash
|
|
# end
|
|
|
|
def Kernel.pbShuffleTrainersCustom(bst_range = 50)
|
|
randomTrainersHash = Hash.new
|
|
bst_range = pbGet(VAR_RANDOMIZER_TRAINER_BST)
|
|
|
|
Kernel.pbMessage(_INTL("Parsing custom sprites folder...\\wtnp[20]"))
|
|
reference_sprites = $game_switches[SWITCH_RANDOM_REFERENCE_SPRITES]
|
|
if reference_sprites
|
|
reference_sprites_list = getSelectedReferenceSprites
|
|
$PokemonTemp.selected_reference_sprites = reference_sprites_list
|
|
customsList = getSelectedReferenceSpeciesList(reference_sprites_list)
|
|
else
|
|
customsList = getCustomSpeciesList(true, true)
|
|
end
|
|
|
|
Kernel.pbMessage(_INTL("{1} sprites found. Shuffling...\\wtnp[20]", customsList.length.to_s))
|
|
|
|
if customsList.length == 0
|
|
Kernel.pbMessage(_INTL("To use custom sprites, please place correctly named sprites in the /CustomBattlers folder. See readMe.txt for more information."))
|
|
Kernel.pbMessage(_INTL("Trainer Pokémon will include auto-generated sprites."))
|
|
return Kernel.pbShuffleTrainers(bst_range)
|
|
elsif customsList.length < 100 && ! $game_switches[SWITCH_RANDOM_REFERENCE_SPRITES]
|
|
if Kernel.pbConfirmMessage(_INTL("Too few custom sprites were found. This will result in a very low Pokémon variety for trainers. Would you like to disable the Custom Sprites only option?"))
|
|
Kernel.pbMessage(_INTL("Trainer Pokémon may also include auto-generated sprites."))
|
|
return Kernel.pbShuffleTrainers(bst_range) ##use regular shuffle if not enough sprites
|
|
end
|
|
if Kernel.pbConfirmMessage(_INTL("This will result in a very low Pokémon variety for trainers. Continue anyway?"))
|
|
bst_range = 999
|
|
else
|
|
Kernel.pbMessage(_INTL("Trainer Pokémon will include auto-generated sprites."))
|
|
return Kernel.pbShuffleTrainers(bst_range) ##use regular shuffle if not enough sprites
|
|
end
|
|
end
|
|
|
|
Kernel.pbShuffleTrainers(bst_range, true, customsList)
|
|
end
|
|
|
|
# trainers=load_data("Data/trainers.dat")
|
|
# i=0
|
|
# for trainer in trainers
|
|
# for poke in trainer[3]
|
|
# poke[TPSPECIES]=getNewCustomSpecies(poke[TPSPECIES],customsList)
|
|
# end
|
|
# randomTrainersHash[i] = (trainer)
|
|
# playShuffleSE(i)
|
|
# i += 1
|
|
# if i % 2 == 0
|
|
# n = (i.to_f/trainers.length)*100
|
|
# Kernel.pbMessageNoSound("\\ts[]Shuffling trainers (custom sprites only)...\\n {1}%\\^",sprintf('%.2f', n),PBSpecies.maxValue)
|
|
# end
|
|
# #Kernel.pbMessage("pushing trainer {1}: {2} ",i,trainer)
|
|
# end
|
|
# $PokemonGlobal.randomTrainersHash = randomTrainersHash
|
|
|
|
#def getRandomCustomSprite()
|
|
# filesList = Dir["./Graphics/CustomBattlers/*"]
|
|
# i = rand(filesList.length-1)
|
|
# path = filesList[i]
|
|
# file = File.basename(path, ".*")
|
|
# splitPoke = file.split(".")
|
|
# head = splitPoke[0].to_i
|
|
# body = splitPoke[1].to_i
|
|
# return (body*NB_POKEMON)+head
|
|
#end
|
|
|
|
def getCustomSpeciesList(allowOnline = true, redownload_file = false)
|
|
speciesList = []
|
|
|
|
for num in 1..NB_POKEMON
|
|
path = Settings::CUSTOM_BATTLERS_FOLDER_INDEXED + num.to_s + "/*"
|
|
filesList = Dir[path]
|
|
maxDexNumber = (NB_POKEMON * NB_POKEMON) + NB_POKEMON
|
|
maxVal = filesList.length - 1
|
|
for i in 0..maxVal
|
|
path = filesList[i]
|
|
file = File.basename(path, ".*")
|
|
fused = getDexNumFromFilename(file)
|
|
if fused && (fused <= maxDexNumber && fused > 0)
|
|
speciesList << fused
|
|
end
|
|
|
|
end
|
|
end
|
|
|
|
# if speciesList.length <= 20000 && allowOnline
|
|
# if redownload_file && Kernel.pbConfirmMessage("Not enough local sprites found. Attempt to fetch list from the internet?")
|
|
# updateOnlineCustomSpritesFile
|
|
# end
|
|
#try to get list from github
|
|
online_list = list_online_custom_sprites(true)
|
|
return speciesList if !online_list
|
|
species_id_list = []
|
|
for file in online_list
|
|
dexnum = getDexNumFromFilename(file)
|
|
species_id_list << dexnum if dexnum && dexnum <= maxDexNumber && dexnum > 0
|
|
end
|
|
return species_id_list
|
|
#end
|
|
return speciesList
|
|
end
|
|
|
|
def getNonReferenceSprites(full_list, references_map = nil)
|
|
full_list = getCustomSpeciesList(false, false) unless full_list
|
|
references_map = map_sprites_by_reference() unless references_map
|
|
|
|
referenced = {}
|
|
references_map.each_value do |sprites|
|
|
sprites.each { |sprite| referenced[sprite] = true }
|
|
end
|
|
|
|
full_list.reject { |sprite| referenced.key?(sprite) }
|
|
return full_list
|
|
end
|
|
|
|
|
|
def getSelectedReferenceSprites
|
|
spritesList = []
|
|
path = Settings::REFERENCES_FILE_PATH
|
|
return spritesList if !File.exist?(path)
|
|
|
|
File.foreach(path) do |line|
|
|
spritename = line.chomp
|
|
spritesList << spritename if !spritename.empty?
|
|
end
|
|
return spritesList
|
|
end
|
|
def getSelectedReferenceSpeciesList(spriteslist)
|
|
species_id_list = []
|
|
for file in spriteslist
|
|
dexnum = getDexNumFromFilename(file)
|
|
species_id_list << dexnum
|
|
end
|
|
|
|
return species_id_list
|
|
end
|
|
|
|
def is_file_alt(file)
|
|
filename = file.split(".")[0]
|
|
return filename.match(/[a-zA-Z]/)
|
|
end
|
|
|
|
#input: ex: 10.10.png
|
|
def getDexNumFromFilename(filename)
|
|
begin
|
|
splitPoke = filename.split(".")
|
|
head = splitPoke[0].to_i
|
|
body = splitPoke[1].to_i
|
|
|
|
return nil if (body * NB_POKEMON) + head > (NB_POKEMON * NB_POKEMON) + NB_POKEMON
|
|
return (body * NB_POKEMON) + head
|
|
rescue
|
|
return nil
|
|
end
|
|
|
|
end
|
|
|
|
# def getCustomSpeciesList()
|
|
# filesList = Dir["./Graphics/CustomBattlers/*"]
|
|
# maxDexNumber = (NB_POKEMON * NB_POKEMON) + NB_POKEMON
|
|
# maxVal = filesList.length - 1
|
|
# for i in 0..maxVal
|
|
# path = filesList[i]
|
|
# file = File.basename(path, ".*")
|
|
# splitPoke = file.split(".")
|
|
# head = splitPoke[0].to_i
|
|
# body = splitPoke[1].to_i
|
|
# fused = (body * NB_POKEMON) + head
|
|
# if fused <= maxDexNumber && fused > 0
|
|
# speciesList << fused
|
|
# end
|
|
#
|
|
# end
|
|
# end
|
|
|
|
def Kernel.getBaseStats(species)
|
|
if $pkmn_dex[species] == nil
|
|
print species
|
|
end
|
|
|
|
basestatsum = $pkmn_dex[species][5][0] # HP
|
|
basestatsum += $pkmn_dex[species][5][1] # Attack
|
|
basestatsum += $pkmn_dex[species][5][2] # Defense
|
|
basestatsum += $pkmn_dex[species][5][3] # Speed
|
|
basestatsum += $pkmn_dex[species][5][4] # Special Attack
|
|
basestatsum += $pkmn_dex[species][5][5] # Special Defense
|
|
return basestatsum
|
|
end
|
|
|
|
def Kernel.gymLeaderRematchHint()
|
|
hints = {
|
|
426 =>_INTL("I heard that Brock has a huge interest in Pokémon fossils. He donated a lot of fossils he excavated to the Pewter City Museum."),
|
|
427 =>_INTL("Misty is a pro at swimming. I heard she trains every single morning."),
|
|
428 =>_INTL("Did you know that Lt. Surge used the magnetic fields generated by his Pokémon to navigate his plane back when he was in the army? He still loves a good magnetic field."),
|
|
429 =>_INTL("Erika is a lover of nature. She loves going to parks to relax during the day."),
|
|
430 =>_INTL("Koga has been seen leaving Fuschia city in the evenings. The rumors say he's preparing for a new job somewhere else..."),
|
|
431 =>_INTL("People say that Sabrina never sleeps. I wonder where she goes when she leaves her gym at night."),
|
|
432 =>_INTL("The hot-headed Blaine is a man of extremes. He likes to explore around his hometown during the day."),
|
|
433 =>_INTL("Giovanni is a mysterious man. I wonder where he goes in the evening. Probably somewhere as remote as possible to meditate in peace..."),
|
|
434 =>_INTL("I heard that Whitney went to school in one of the towns near Goldenrod before becoming a Gym Leader. She kept in touch with her old teacher and she goes to visit sometimes in the evening."),
|
|
435 =>_INTL("Kurt is always on the lookout for Bug-type Pokémon. He goes hunting early in the morning."),
|
|
436 =>_INTL("Falkner rises up early in the morning. You can usually find him in high places."),
|
|
437 =>_INTL("Clair is a member of a famous clan of dragon masters. She goes to a special place to pray at night."),
|
|
510 =>_INTL("Chuck is a martial arts pro. I've seen him train with Saffron City's dojo master back in the days."),
|
|
508 =>_INTL("Morty is a mysterious man. He's been known to be one of the few people who dare enter Pokémon Tower at night."),
|
|
509 =>_INTL("Pryce is an ice-type expert who has been around for a long time. He used to train in the Ice Tunnel between Mahogany Town and Blackthorn City before it froze over."),
|
|
511 =>_INTL("Jasmine is on vacation in the Sevii Islands. She likes to rise up early to explore around the islands when no one's around.")
|
|
}
|
|
remaining_leaders = []
|
|
for switch_nb in hints.keys
|
|
remaining_leaders << switch_nb unless $game_switches[switch_nb]
|
|
end
|
|
if remaining_leaders.empty?
|
|
return _INTL("You got every Gym Leader to come here. This place is more popular than ever!\nNow go and battle them!")
|
|
else
|
|
key = remaining_leaders.sample
|
|
return hints[key]
|
|
end
|
|
end
|
|
|
|
def getTrainerParty(trainer)
|
|
if $game_switches[47]
|
|
for poke in trainer[3]
|
|
inverseFusion(poke)
|
|
end
|
|
end
|
|
return trainer[3]
|
|
end
|
|
|
|
def inverseFusion(pokemon)
|
|
species = pokemon[TPSPECIES]
|
|
return pokemon if species <= CONST_NB_POKE
|
|
return pokemon if species > (CONST_NB_POKE * CONST_NB_POKE) + CONST_NB_POKE
|
|
body = getBasePokemonID(species, true)
|
|
head = getBasePokemonID(species, false)
|
|
newspecies = (head) * CONST_NB_POKE + body
|
|
pokemon[TPSPECIES] = newspecies
|
|
return pokemon
|
|
end
|
|
|
|
def addRandomHeldItems(trainerParty)
|
|
for poke in trainerParty
|
|
if poke.item == nil
|
|
poke.item = PBItems::ORANBERRY #PBItems.sample
|
|
end
|
|
end
|
|
end
|
|
|
|
def addHealingItem(items)
|
|
if $Trainer.numbadges < 1
|
|
items << PBItems::ORANBERRY
|
|
elsif $Trainer.numbadges <= 2
|
|
items << PBItems::POTION
|
|
elsif $Trainer.numbadges <= 4
|
|
items << PBItems::SUPERPOTION
|
|
elsif $Trainer.numbadges <= 6
|
|
items << PBItems::FULLHEAL
|
|
items << PBItems::SUPERPOTION
|
|
elsif $Trainer.numbadges <= 8
|
|
items << PBItems::FULLHEAL
|
|
items << PBItems::HYPERPOTION
|
|
elsif $Trainer.numbadges >= 9
|
|
items << PBItems::FULLRESTORE
|
|
end
|
|
|
|
return items
|
|
end
|
|
|
|
#####Overload de pbLoadTrainer
|
|
#
|
|
# def pbLoadTrainer(trainerid,trainername,partyid=0)
|
|
# if trainerid.is_a?(String) || trainerid.is_a?(Symbol)
|
|
# if !hasConst?(PBTrainers,trainerid)
|
|
# raise "Trainer type does not exist ({1}, {2}, ID {3})",trainerid,trainername,partyid
|
|
# end
|
|
# trainerid=getID(PBTrainers,trainerid)
|
|
# end
|
|
# success=false
|
|
# items=[]
|
|
# party=[]
|
|
# opponent=nil
|
|
# trainers=load_data("Data/trainers.dat")
|
|
# trainerIndex=-1
|
|
#
|
|
# for trainer in trainers
|
|
# trainerIndex+=1
|
|
# name=trainer[1]
|
|
# thistrainerid=trainer[0]
|
|
# thispartyid=trainer[4]
|
|
# next if trainerid!=thistrainerid || name!=trainername || partyid!=thispartyid
|
|
# items=trainer[2].clone
|
|
#
|
|
# if $game_switches[666] #hard mode
|
|
# items = addHealingItem(items)
|
|
# end
|
|
#
|
|
#
|
|
# name=pbGetMessageFromHash(MessageTypes::TrainerNames,name)
|
|
# for i in RIVALNAMES
|
|
# if isConst?(trainerid,PBTrainers,i[0]) && $game_variables[i[1]]!=0
|
|
# name=$game_variables[i[1]]
|
|
# end
|
|
# end
|
|
# opponent=PokeBattle_Trainer.new(name,thistrainerid)
|
|
# opponent.setForeignID($Trainer) if $Trainer
|
|
#
|
|
#
|
|
# #use le random Array si randomized starters (et pas 1ere rival battle)
|
|
# isPlayingRandomized = $game_switches[987] && !$game_switches[46]
|
|
# if isPlayingRandomized && $PokemonGlobal.randomTrainersHash[trainerIndex] == nil
|
|
# Kernel.pbMessage("The trainers need to be re-shuffled.")
|
|
# Kernel.pbShuffleTrainers()
|
|
# end
|
|
# trainerParty = isPlayingRandomized ? $PokemonGlobal.randomTrainersHash[trainerIndex][3] : getTrainerParty(trainer)
|
|
#
|
|
#
|
|
# isRematch = $game_switches[200]
|
|
# rematchId = getRematchId(trainername,trainerid)
|
|
# for poke in trainerParty
|
|
# ##
|
|
# species=poke[TPSPECIES]
|
|
# species = replaceRivalStarterIfNecessary(species)
|
|
#
|
|
#
|
|
# level= $game_switches[666] ? (poke[TPLEVEL]*1.1).ceil : poke[TPLEVEL]
|
|
#
|
|
# if isRematch
|
|
# nbRematch = getNumberRematch(rematchId)
|
|
# level = getRematchLevel(level,nbRematch)
|
|
# species = evolveRematchPokemon(nbRematch,species)
|
|
# end
|
|
#
|
|
# pokemon=PokeBattle_Pokemon.new(species,level,opponent)
|
|
# #pokemon.form=poke[TPFORM]
|
|
# pokemon.resetMoves
|
|
#
|
|
#
|
|
# pokemon.setItem( $game_switches[843] ? rand(PBItems.maxValue) : poke[TPITEM])
|
|
#
|
|
# if poke[TPMOVE1]>0 || poke[TPMOVE2]>0 || poke[TPMOVE3]>0 || poke[TPMOVE4]>0
|
|
# k=0
|
|
# for move in [TPMOVE1,TPMOVE2,TPMOVE3,TPMOVE4]
|
|
# pokemon.moves[k]=PBMove.new(poke[move])
|
|
# k+=1
|
|
# end
|
|
# pokemon.moves.compact!
|
|
# end
|
|
# pokemon.setAbility(poke[TPABILITY])
|
|
# pokemon.setGender(poke[TPGENDER])
|
|
# if poke[TPSHINY] # if this is a shiny Pokémon
|
|
# pokemon.makeShiny
|
|
# else
|
|
# pokemon.makeNotShiny
|
|
# end
|
|
# pokemon.setNature(poke[TPNATURE])
|
|
# iv=poke[TPIV]
|
|
# for i in 0...6
|
|
# pokemon.iv[i]=iv&0x1F
|
|
# pokemon.ev[i]=[85,level*3/2].min
|
|
# end
|
|
# pokemon.happiness=poke[TPHAPPINESS]
|
|
# pokemon.name=poke[TPNAME] if poke[TPNAME] && poke[TPNAME]!=""
|
|
# if poke[TPSHADOW] # if this is a Shadow Pokémon
|
|
# pokemon.makeShadow rescue nil
|
|
# pokemon.pbUpdateShadowMoves(true) rescue nil
|
|
# pokemon.makeNotShiny
|
|
# end
|
|
# pokemon.ballused=poke[TPBALL]
|
|
# pokemon.calcStats
|
|
# party.push(pokemon)
|
|
# end
|
|
# success=true
|
|
# break
|
|
# end
|
|
# return success ? [opponent,items,party] : nil
|
|
# end
|
|
|
|
def getRematchId(trainername, trainerid)
|
|
return trainername + trainerid.to_s
|
|
end
|
|
|
|
def replaceRivalStarterIfNecessary(species)
|
|
if species == RIVAL_STARTER_PLACEHOLDER_SPECIES
|
|
if !$game_switches[840] || pbGet(250) == 0 #not DEFINED_RIVAL_STARTER
|
|
fixRivalStarter()
|
|
end
|
|
rivalStarter = pbGet(250)
|
|
if rivalStarter > 0
|
|
species = pbGet(250)
|
|
end
|
|
end
|
|
return species
|
|
end
|
|
|
|
def fixRivalStarter()
|
|
#set starter baseform
|
|
if $PokemonGlobal.psuedoBSTHash == nil
|
|
psuedoHash = Hash.new
|
|
for i in 0..NB_POKEMON
|
|
psuedoHash[i] = i
|
|
end
|
|
$PokemonGlobal.psuedoBSTHash = psuedoHash
|
|
end
|
|
starterChoice = pbGet(7)
|
|
|
|
setRivalStarter(0, 1) if starterChoice == 2
|
|
setRivalStarter(0, 2) if starterChoice == 1
|
|
setRivalStarter(1, 2) if starterChoice == 0
|
|
setRivalStarter(0, 1) if starterChoice > 2
|
|
echoln pbGet(VAR_RIVAL_STARTER)
|
|
#evolve en fct des badges
|
|
rivalStarter = pbGet(VAR_RIVAL_STARTER)
|
|
|
|
if $game_switches[68] #beat blue cerulean
|
|
rivalStarter = evolveBody(rivalStarter)
|
|
end
|
|
|
|
if $game_switches[89] #beat blue SS Anne
|
|
rivalStarter = evolveHead(rivalStarter)
|
|
end
|
|
|
|
if $game_switches[228] #beat silph co
|
|
rivalStarter = evolveBody(rivalStarter)
|
|
end
|
|
|
|
if $game_switches[11] #got badge 8
|
|
rivalStarter = evolveHead(rivalStarter)
|
|
end
|
|
|
|
if $game_switches[12] #beat league
|
|
rivalStarter = evolveBody(rivalStarter)
|
|
rivalStarter = evolveHead(rivalStarter)
|
|
end
|
|
|
|
#RIVAL_STARTER_IS_DEFINED
|
|
pbSet(250, rivalStarter)
|
|
$game_switches[840] = true
|
|
end
|