From 2365dfeb514bf1bb8b1f1c3adcd2c881d3d2de63 Mon Sep 17 00:00:00 2001 From: infinitefusion Date: Sun, 1 May 2022 10:11:56 -0400 Subject: [PATCH] randomizer - trainer teams --- Data/CommonEvents.rxdata | Bin 115711 -> 115695 bytes .../010_Data/002_PBS data/013_Trainer.rb | 19 +++ .../001_Battle Frontier/002_Challenge_Data.rb | 2 +- .../randomizer gym leader edit.rb | 134 ++++++++++-------- Data/Scripts/025-Randomizer/randomizer.rb | 110 +++++++------- Data/Scripts/050_AddOns/Wondertrade.rb | 8 +- Data/System.rxdata | Bin 27403 -> 27403 bytes 7 files changed, 155 insertions(+), 118 deletions(-) diff --git a/Data/CommonEvents.rxdata b/Data/CommonEvents.rxdata index eb519db2bca12b861f53a0c364268d8a4e26da04..b987bd6d5516916c1fa07c23b807da5fa7b76984 100644 GIT binary patch delta 1636 zcmY*ZZBUd|6z(~|zATW!%c2V`!a|738W<=pAERV`RSp^Wu`}wR&IpSlAgO7%K%rn$ zsocgJI;Q40*2s+H+jys9R?%$IN!{v4P9NZ)Rtv?}q)nwl_htF&&wZbBpZlKkoO{nX z1C5HWQE79nLnfqQzXZdk6JtltmX62kM!;9*L`N>ppb4Lv5B9mYRwhm|D+2L_PcZzzgWnM>JWylN*R zwKFXiuq`b~yv_mj?BVo4v}-etmd3-x4!N@sCD#}hUmwBGuR$u?H7%Nj?>1`Bo-a^v zPCNAZdIO$j{a?1=MdrIcnYphWM2WOxSjF{PY(L?WpB%dDD2M4Ivu8 z#XyQWqKzn+6?QMDNR_WHKs5K1<8dkA>u$Rg5O%xNkgVo}I2CrRC5r94U4@wpcgit~ zRopo*1E<}sK_P3sn`J1{kA?EoJS^6p`YDJona%#CpN^>fK(_SvymtfMWt!KHqwF`Y zot^bYvQ~HSaC(XC*yK=F+w(rIuqnNEx~j6n?&x7wPd=O{Lof%>w_})_ zLpXh4jriUGH&H^=s6*=z*4Z~gaE{11hAkUqxn!C6VjPl)&W<^v`LU>r00q#4G0el! zpT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>P{s$Gh)21w%|+Cf_ z;qV}wH@T67r+l{?R=#Eq;^q4UWzaLfL)bjn0;KTzG^FB9{#_cDlGCQ$ltm<_Bg%|o z{&o&hm68ZqX$or?OknNqP;og2e=F1

>vpcjRI*4GbFztML8W?$21wwg# z9zylzoG{85#SRI9R*S!si#sz2=T+Bk$jUw;K1xu<~cYe6R?Naz|hitsc=vAs2dpDv`7i zlR+Oj^fro*89sr5|5=6w6cFj35G;RonATQXVdp=T!v%*3tI(=_ zRixI4a>B`=xsmK max_bst+additional_bst end return species diff --git a/Data/Scripts/025-Randomizer/randomizer gym leader edit.rb b/Data/Scripts/025-Randomizer/randomizer gym leader edit.rb index aed189bef..a139cbcf2 100644 --- a/Data/Scripts/025-Randomizer/randomizer gym leader edit.rb +++ b/Data/Scripts/025-Randomizer/randomizer gym leader edit.rb @@ -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,32 +283,25 @@ 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 + 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 + 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) diff --git a/Data/Scripts/025-Randomizer/randomizer.rb b/Data/Scripts/025-Randomizer/randomizer.rb index 1b05093c1..89ea36e00 100644 --- a/Data/Scripts/025-Randomizer/randomizer.rb +++ b/Data/Scripts/025-Randomizer/randomizer.rb @@ -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 diff --git a/Data/Scripts/050_AddOns/Wondertrade.rb b/Data/Scripts/050_AddOns/Wondertrade.rb index 673023aa0..601e1bbfa 100644 --- a/Data/Scripts/050_AddOns/Wondertrade.rb +++ b/Data/Scripts/050_AddOns/Wondertrade.rb @@ -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] diff --git a/Data/System.rxdata b/Data/System.rxdata index c62524468973dbdb27805ef8fe5526189251a32b..013ba908a557b6cedb663a6f2e51c0e7710c37d7 100644 GIT binary patch delta 31 ncmeCa#@Kz0al;`o-m@HQSgrUSQj3!l3sNU#N^X83rW^tQ$*&9+ delta 31 ncmeCa#@Kz0al;`oUj6SJj8^;(sl~~O1*wxVB{#niQw{+D!to2g