mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
randomizer - trainer teams
This commit is contained in:
Binary file not shown.
@@ -70,6 +70,10 @@ module GameData
|
||||
return (self::DATA.has_key?(key)) ? self::DATA[key] : nil
|
||||
end
|
||||
|
||||
def self.list_all()
|
||||
return self::DATA
|
||||
end
|
||||
|
||||
def initialize(hash)
|
||||
@id = hash[:id]
|
||||
@id_number = hash[:id_number]
|
||||
@@ -110,6 +114,15 @@ module GameData
|
||||
end
|
||||
end
|
||||
|
||||
def replace_species_to_randomized(species,trainerId,pokemonIndex)
|
||||
return species if $game_switches[SWITCH_FIRST_RIVAL_BATTLE]
|
||||
if $PokemonGlobal.randomTrainersHash[trainerId] == nil
|
||||
Kernel.pbMessage(_INTL("The trainers need to be re-shuffled."))
|
||||
Kernel.pbShuffleTrainers()
|
||||
end
|
||||
new_species_dex = $PokemonGlobal.randomTrainersHash[trainerId][pokemonIndex]
|
||||
return getSpecies(new_species_dex)
|
||||
end
|
||||
|
||||
def replaceSingleSpeciesModeIfApplicable(species)
|
||||
if $game_switches[SWITCH_SINGLE_POKEMON_MODE]
|
||||
@@ -150,6 +163,8 @@ module GameData
|
||||
return species
|
||||
end
|
||||
|
||||
|
||||
|
||||
def to_trainer
|
||||
placeholder_species = [Settings::RIVAL_STARTER_PLACEHOLDER_SPECIES,
|
||||
Settings::VAR_1_PLACEHOLDER_SPECIES,
|
||||
@@ -173,9 +188,11 @@ module GameData
|
||||
rematchId = getRematchId(trainer.name, trainer.trainer_type)
|
||||
|
||||
# Create each Pokémon owned by the trainer
|
||||
index = 0
|
||||
@pokemon.each do |pkmn_data|
|
||||
#replace placeholder species infinite fusion edit
|
||||
species = GameData::Species.get(pkmn_data[:species]).species
|
||||
species = replace_species_to_randomized(species,self.id,index) if isPlayingRandomized
|
||||
if placeholder_species.include?(species)
|
||||
species = replace_species_with_placeholder(species)
|
||||
end
|
||||
@@ -252,6 +269,8 @@ module GameData
|
||||
end
|
||||
pkmn.poke_ball = pkmn_data[:poke_ball] if pkmn_data[:poke_ball]
|
||||
pkmn.calc_stats
|
||||
|
||||
index +=1
|
||||
end
|
||||
return trainer
|
||||
end
|
||||
|
||||
@@ -45,7 +45,7 @@ def generate_random_species(max_bst)
|
||||
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 = calcBaseStats(species)
|
||||
bst = calcBaseStatsSum(species)
|
||||
species=0 if bst > max_bst+additional_bst
|
||||
end
|
||||
return species
|
||||
|
||||
@@ -117,20 +117,20 @@ end
|
||||
|
||||
####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 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 bstOk(newspecies,oldPokemonSpecies,bst_range=50)
|
||||
newBST = getBaseStats(newspecies)
|
||||
originalBST = getBaseStats(oldPokemonSpecies)
|
||||
newBST = calcBaseStatsSum(newspecies)
|
||||
originalBST = calcBaseStatsSum(oldPokemonSpecies)
|
||||
return newBST < originalBST-bst_range || newBST > originalBST+bst_range
|
||||
end
|
||||
|
||||
@@ -283,31 +283,24 @@ def Kernel.pbRandomizeTM()
|
||||
end
|
||||
|
||||
def getNewSpecies(oldSpecies,bst_range=50, ignoreRivalPlaceholder = false, maxDexNumber = PBSpecies.maxValue )
|
||||
return oldSpecies if (oldSpecies == RIVAL_STARTER_PLACEHOLDER_SPECIES && !ignoreRivalPlaceholder)
|
||||
return oldSpecies if oldSpecies >= NUM_ZAPMOLCUNO
|
||||
return oldSpecies if (oldSpecies == Settings::RIVAL_STARTER_PLACEHOLDER_SPECIES && !ignoreRivalPlaceholder)
|
||||
return oldSpecies if oldSpecies >= Settings::ZAPMOLCUNO_NB
|
||||
newspecies = rand(maxDexNumber - 1) + 1
|
||||
newBST = Kernel.getBaseStats(newspecies)
|
||||
originalBST = Kernel.getBaseStats(oldSpecies)
|
||||
while bstOk(newspecies,oldSpecies,bst_range)
|
||||
newspecies = rand(maxDexNumber - 1) + 1
|
||||
newBST = Kernel.getBaseStats(newspecies)
|
||||
end
|
||||
return newspecies
|
||||
end
|
||||
|
||||
|
||||
def getNewCustomSpecies(oldSpecies,customSpeciesList,bst_range=50, ignoreRivalPlaceholder = false)
|
||||
return oldSpecies if (oldSpecies == RIVAL_STARTER_PLACEHOLDER_SPECIES && !ignoreRivalPlaceholder)
|
||||
return oldSpecies if oldSpecies >= NUM_ZAPMOLCUNO
|
||||
return oldSpecies if (oldSpecies == Settings::RIVAL_STARTER_PLACEHOLDER_SPECIES && !ignoreRivalPlaceholder)
|
||||
return oldSpecies if oldSpecies >= Settings::ZAPMOLCUNO_NB
|
||||
i = rand(customSpeciesList.length - 1) + 1
|
||||
newspecies = customSpeciesList[i]
|
||||
|
||||
newBST = Kernel.getBaseStats(newspecies)
|
||||
originalBST = Kernel.getBaseStats(oldSpecies)
|
||||
while bstOk(newspecies,oldSpecies,bst_range)
|
||||
i = rand(customSpeciesList.length - 1)#+1
|
||||
newspecies = customSpeciesList[i]
|
||||
newBST = Kernel.getBaseStats(newspecies)
|
||||
end
|
||||
return newspecies
|
||||
end
|
||||
@@ -321,29 +314,54 @@ end
|
||||
|
||||
|
||||
|
||||
def Kernel.pbShuffleTrainers(bst_range = 50)
|
||||
def Kernel.pbShuffleTrainers(bst_range = 50,customsOnly=false,customsList=nil)
|
||||
if customsOnly && customsList == nil
|
||||
customsOnly = false
|
||||
end
|
||||
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])
|
||||
trainers_data = GameData::Trainer.list_all
|
||||
trainers_data.each do |key, value|
|
||||
trainer = trainers_data[key]
|
||||
i=0
|
||||
new_party = []
|
||||
for poke in trainer.pokemon
|
||||
old_poke = GameData::Species.get(poke[:species]).id_number
|
||||
new_poke = customsOnly ? getNewCustomSpecies(old_poke,customsList) : getNewSpecies(old_poke)
|
||||
new_party << new_poke
|
||||
end
|
||||
randomTrainersHash[i] = (trainer)
|
||||
randomTrainersHash[trainer.id] = new_party
|
||||
playShuffleSE(i)
|
||||
i += 1
|
||||
if i % 2 == 0
|
||||
n = (i.to_f/trainers.length)*100
|
||||
Kernel.pbMessageNoSound(_INTL("\\ts[]Shuffling trainers...\\n {1}%\\^",sprintf('%.2f', n),PBSpecies.maxValue))
|
||||
n = (i.to_f/trainers.length)*100
|
||||
Kernel.pbMessageNoSound(_INTL("\\ts[]Shuffling trainers...\\n {1}%\\^",sprintf('%.2f', n),PBSpecies.maxValue))
|
||||
end
|
||||
#Kernel.pbMessage(_INTL("pushing trainer {1}: {2} ",i,trainer))
|
||||
end
|
||||
$PokemonGlobal.randomTrainersHash = randomTrainersHash
|
||||
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(_INTL("\\ts[]Shuffling trainers...\\n {1}%\\^",sprintf('%.2f', n),PBSpecies.maxValue))
|
||||
# end
|
||||
# #Kernel.pbMessage(_INTL("pushing trainer {1}: {2} ",i,trainer))
|
||||
# end
|
||||
# $PokemonGlobal.randomTrainersHash = randomTrainersHash
|
||||
# end
|
||||
|
||||
def Kernel.pbShuffleTrainersCustom()(bst_range = 50)
|
||||
def Kernel.pbShuffleTrainersCustom(bst_range = 50)
|
||||
randomTrainersHash = Hash.new
|
||||
|
||||
Kernel.pbMessage(_INTL("Parsing custom sprites folder"))
|
||||
@@ -359,32 +377,32 @@ def Kernel.pbShuffleTrainersCustom()(bst_range = 50)
|
||||
bst_range=999
|
||||
else
|
||||
Kernel.pbMessage(_INTL("Trainer Pokémon will include auto-generated sprites."))
|
||||
return Kernel.pbShuffleTrainers(bst_range)
|
||||
return Kernel.pbShuffleTrainers(bst_range) ##use regular shuffle if not enough sprites
|
||||
end
|
||||
end
|
||||
|
||||
##use regular shuffle if not enough sprites
|
||||
|
||||
|
||||
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(_INTL("\\ts[]Shuffling trainers (custom sprites only)...\\n {1}%\\^",sprintf('%.2f', n),PBSpecies.maxValue))
|
||||
end
|
||||
#Kernel.pbMessage(_INTL("pushing trainer {1}: {2} ",i,trainer))
|
||||
end
|
||||
$PokemonGlobal.randomTrainersHash = randomTrainersHash
|
||||
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(_INTL("\\ts[]Shuffling trainers (custom sprites only)...\\n {1}%\\^",sprintf('%.2f', n),PBSpecies.maxValue))
|
||||
# end
|
||||
# #Kernel.pbMessage(_INTL("pushing trainer {1}: {2} ",i,trainer))
|
||||
# end
|
||||
# $PokemonGlobal.randomTrainersHash = randomTrainersHash
|
||||
|
||||
|
||||
|
||||
#def getRandomCustomSprite()
|
||||
# filesList = Dir["./Graphics/CustomBattlers/*"]
|
||||
# i = rand(filesList.length-1)
|
||||
|
||||
@@ -126,61 +126,61 @@ def getBaseStatsFormattedForRandomizer(dex_num)
|
||||
return statsArray
|
||||
end
|
||||
|
||||
def Kernel.pbShuffleDexTrainers()
|
||||
# create hash
|
||||
psuedoHash = Hash.new
|
||||
psuedoBSTHash = Hash.new
|
||||
|
||||
#Create array of all pokemon dex numbers
|
||||
pokeArray = []
|
||||
for i in 1..PBSpecies.maxValue
|
||||
pokeArray.push(i)
|
||||
end
|
||||
#randomize hash
|
||||
pokeArrayRand = pokeArray.dup
|
||||
pokeArrayRand.shuffle!
|
||||
pokeArray.insert(0,nil)
|
||||
# fill random hash
|
||||
#random hash will have to be accessed by number, not internal name
|
||||
for i in 1...pokeArrayRand.length
|
||||
psuedoHash[i]=pokeArrayRand[i]
|
||||
end
|
||||
|
||||
#use pokeArrayRand to fill in the BST hash also
|
||||
#loop through the actual dex, and use the first mon in pokeArrayRand with
|
||||
#BST in the same 100 range
|
||||
for i in 1..PBSpecies.maxValue
|
||||
if i % 20 == 0
|
||||
n = (i.to_f/PBSpecies.maxValue)*100
|
||||
#Kernel.pbMessage(_INTL("\\ts[]Shuffling...\\n {1}%\\^",sprintf('%.2f', n),PBSpecies.maxValue))
|
||||
end
|
||||
|
||||
baseStats=calcBaseStats(i)
|
||||
baseStat_target = 0
|
||||
for k in 0...baseStats.length
|
||||
baseStat_target+=baseStats[k]
|
||||
end
|
||||
baseStat_target = (baseStat_target/50).floor
|
||||
for j in 1...pokeArrayRand.length
|
||||
baseStats=calcBaseStats([pokeArrayRand[j]])
|
||||
baseStat_temp = 0
|
||||
for l in 0...baseStats.length
|
||||
baseStat_temp+=baseStats[l]
|
||||
end
|
||||
baseStat_temp = (baseStat_temp/50).floor
|
||||
#if a match, add to hash, remove from array, and cycle to next poke in dex
|
||||
if baseStat_temp == baseStat_target
|
||||
psuedoBSTHash[i]=pokeArrayRand[j]
|
||||
pokeArrayRand.delete(pokeArrayRand[j])
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#add hashes to global data0
|
||||
#$PokemonGlobal.psuedoHash = psuedoHash
|
||||
$PokemonGlobal.pseudoBSTHashTrainers = psuedoBSTHash
|
||||
end
|
||||
# def Kernel.pbShuffleDexTrainers()
|
||||
# # create hash
|
||||
# psuedoHash = Hash.new
|
||||
# psuedoBSTHash = Hash.new
|
||||
#
|
||||
# #Create array of all pokemon dex numbers
|
||||
# pokeArray = []
|
||||
# for i in 1..PBSpecies.maxValue
|
||||
# pokeArray.push(i)
|
||||
# end
|
||||
# #randomize hash
|
||||
# pokeArrayRand = pokeArray.dup
|
||||
# pokeArrayRand.shuffle!
|
||||
# pokeArray.insert(0,nil)
|
||||
# # fill random hash
|
||||
# #random hash will have to be accessed by number, not internal name
|
||||
# for i in 1...pokeArrayRand.length
|
||||
# psuedoHash[i]=pokeArrayRand[i]
|
||||
# end
|
||||
#
|
||||
# #use pokeArrayRand to fill in the BST hash also
|
||||
# #loop through the actual dex, and use the first mon in pokeArrayRand with
|
||||
# #BST in the same 100 range
|
||||
# for i in 1..PBSpecies.maxValue
|
||||
# if i % 20 == 0
|
||||
# n = (i.to_f/PBSpecies.maxValue)*100
|
||||
# #Kernel.pbMessage(_INTL("\\ts[]Shuffling...\\n {1}%\\^",sprintf('%.2f', n),PBSpecies.maxValue))
|
||||
# end
|
||||
#
|
||||
# baseStats=calcBaseStats(i)
|
||||
# baseStat_target = 0
|
||||
# for k in 0...baseStats.length
|
||||
# baseStat_target+=baseStats[k]
|
||||
# end
|
||||
# baseStat_target = (baseStat_target/50).floor
|
||||
# for j in 1...pokeArrayRand.length
|
||||
# baseStats=calcBaseStats([pokeArrayRand[j]])
|
||||
# baseStat_temp = 0
|
||||
# for l in 0...baseStats.length
|
||||
# baseStat_temp+=baseStats[l]
|
||||
# end
|
||||
# baseStat_temp = (baseStat_temp/50).floor
|
||||
# #if a match, add to hash, remove from array, and cycle to next poke in dex
|
||||
# if baseStat_temp == baseStat_target
|
||||
# psuedoBSTHash[i]=pokeArrayRand[j]
|
||||
# pokeArrayRand.delete(pokeArrayRand[j])
|
||||
# break
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# #add hashes to global data0
|
||||
# #$PokemonGlobal.psuedoHash = psuedoHash
|
||||
# $PokemonGlobal.pseudoBSTHashTrainers = psuedoBSTHash
|
||||
# end
|
||||
|
||||
def getRandomizedTo(species)
|
||||
return species if !$PokemonGlobal.psuedoBSTHash
|
||||
|
||||
@@ -64,7 +64,7 @@ def pbWonderTrade(lvl, except = [], except2 = [], premiumWonderTrade = true)
|
||||
poke = $Trainer.party[pbGet(1)]
|
||||
$PokemonBag.pbStoreItem(poke.item, 1) if poke.item != nil
|
||||
myPoke = poke.species
|
||||
chosenBST = calcBaseStats(myPoke)
|
||||
chosenBST = calcBaseStatsSum(myPoke)
|
||||
# The following excecption fields are for hardcoding the blacklisted pokemon
|
||||
# without adding them in the events.
|
||||
#except+=[]
|
||||
@@ -78,7 +78,7 @@ def pbWonderTrade(lvl, except = [], except2 = [], premiumWonderTrade = true)
|
||||
bonus += 5 #+ de chance de pogner un bon poke a chaque loop (permet d'eviter infinite loop)
|
||||
|
||||
species = rand(PBSpecies.maxValue) + 1
|
||||
bst = calcBaseStats(species)
|
||||
bst = calcBaseStatsSum(species)
|
||||
# Redo the loop if pokemon is too evolved for its level
|
||||
#species=0 if lvl < pbGetMinimumLevel(species)# && pbGetPreviousForm(species) != species # && pbGetPreviousForm(species)!=species
|
||||
# Redo the loop if the species is an exception.
|
||||
@@ -146,7 +146,7 @@ def pbGRS(minBST, chosenBST, luck, rare, except2)
|
||||
bonus += 5 #+ de chance de pogner un bon poke a chaque loop (permet d'eviter infinite loop)
|
||||
|
||||
species = rand(PBSpecies.maxValue) + 1
|
||||
bst = calcBaseStats(species)
|
||||
bst = calcBaseStatsSum(species)
|
||||
# Redo the loop if pokemon is too evolved for its level
|
||||
#species=0 if lvl < pbGetMinimumLevel(species)# && pbGetPreviousForm(species) != species # && pbGetPreviousForm(species)!=species
|
||||
# Redo the loop if the species is an exception.
|
||||
@@ -172,7 +172,7 @@ end
|
||||
|
||||
|
||||
|
||||
def calcBaseStats(species)
|
||||
def calcBaseStatsSum(species)
|
||||
stats = GameData::Species.get(species).base_stats
|
||||
sum = 0
|
||||
sum += stats[:HP]
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user