mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Randomizer BST fix
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -52,7 +52,7 @@ class RandomizerOptionsScene < PokemonOption_Scene
|
||||
openGymOptionsMenu()
|
||||
end
|
||||
$game_switches[SWITCH_RANDOMIZE_GYMS_SEPARATELY] = value == 0
|
||||
}, "Randomize gym trainers/leaders separately from regular trainers (All Pokémon of a single type)"
|
||||
}, "Limit gym trainers to a single type"
|
||||
),
|
||||
|
||||
EnumOption.new(_INTL("Wild Pokémon"), [_INTL("On"), _INTL("Off")],
|
||||
@@ -239,7 +239,7 @@ class RandomizerWildPokemonOptionsScene < PokemonOption_Scene
|
||||
$game_switches[REGULAR_TO_FUSIONS] = value == 0
|
||||
},"Include fused Pokémon in the randomize pool for wild Pokémon"
|
||||
),
|
||||
EnumOption.new(_INTL("Custom sprites only (Slow)"), [_INTL("On"), _INTL("Off")],
|
||||
EnumOption.new(_INTL("Custom sprites only"), [_INTL("On"), _INTL("Off")],
|
||||
proc { $game_switches[SWITCH_RANDOM_WILD_ONLY_CUSTOMS] ? 0 : 1 },
|
||||
proc { |value|
|
||||
$game_switches[SWITCH_RANDOM_WILD_ONLY_CUSTOMS] = value == 0
|
||||
|
||||
@@ -318,6 +318,8 @@ end
|
||||
|
||||
|
||||
def Kernel.pbShuffleTrainers(bst_range = 50,customsOnly=false,customsList=nil)
|
||||
bst_range = pbGet(VAR_RANDOMIZER_TRAINER_BST)
|
||||
|
||||
if customsOnly && customsList == nil
|
||||
customsOnly = false
|
||||
end
|
||||
@@ -329,7 +331,7 @@ def Kernel.pbShuffleTrainers(bst_range = 50,customsOnly=false,customsList=nil)
|
||||
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_poke = customsOnly ? getNewCustomSpecies(old_poke,customsList,bst_range) : getNewSpecies(old_poke,bst_range)
|
||||
new_party << new_poke
|
||||
end
|
||||
randomTrainersHash[trainer.id] = new_party
|
||||
@@ -366,7 +368,8 @@ end
|
||||
|
||||
def Kernel.pbShuffleTrainersCustom(bst_range = 50)
|
||||
randomTrainersHash = Hash.new
|
||||
|
||||
bst_range = pbGet(VAR_RANDOMIZER_TRAINER_BST)
|
||||
|
||||
Kernel.pbMessage(_INTL("Parsing custom sprites folder"))
|
||||
customsList = getCustomSpeciesList()
|
||||
Kernel.pbMessage(_INTL("{1} Pokémon found",customsList.length.to_s))
|
||||
|
||||
@@ -4,101 +4,154 @@ class PokemonGlobalMetadata
|
||||
attr_accessor :randomTrainersHash
|
||||
attr_accessor :randomGymTrainersHash
|
||||
|
||||
|
||||
alias random_init initialize
|
||||
|
||||
def initialize
|
||||
random_init
|
||||
@randomGymTrainersHash=nil
|
||||
@psuedoHash=nil
|
||||
@psuedoBSTHash=nil
|
||||
@randomGymTrainersHash = nil
|
||||
@psuedoHash = nil
|
||||
@psuedoBSTHash = nil
|
||||
end
|
||||
end
|
||||
|
||||
##############
|
||||
# randomizer shuffle
|
||||
# ##############
|
||||
def Kernel.pbShuffleDex(range=50,type=0)
|
||||
$game_switches[SWITCH_RANDOMIZED_AT_LEAST_ONCE] = true
|
||||
|
||||
#type 0: BST
|
||||
#type 1: full random
|
||||
range = 1 if range == 0
|
||||
# create hash
|
||||
psuedoHash = Hash.new
|
||||
psuedoBSTHash = Hash.new
|
||||
|
||||
#pense pas que c'est utilisé mais bon...
|
||||
def get_pokemon_list(include_fusions=false)
|
||||
#Create array of all pokemon dex numbers
|
||||
pokeArray = []
|
||||
|
||||
|
||||
monLimit = type == 1 ? PBSpecies.maxValue : NB_POKEMON-1
|
||||
|
||||
monLimit = include_fusions ? PBSpecies.maxValue : NB_POKEMON - 1
|
||||
for i in 1..monLimit
|
||||
pokeArray.push(i)
|
||||
end
|
||||
#randomize hash
|
||||
pokeArrayRand = pokeArray.dup
|
||||
pokeArrayRand.shuffle!
|
||||
pokeArray.insert(0,nil)
|
||||
######
|
||||
#on remet arceus a la fin
|
||||
pokeArray.push(NB_POKEMON)
|
||||
|
||||
# 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..NB_POKEMON-1
|
||||
baseStats=getBaseStatsFormattedForRandomizer(i)
|
||||
baseStat_target = 0
|
||||
for k in 0...baseStats.length
|
||||
baseStat_target+=baseStats[k]
|
||||
end
|
||||
baseStat_target = (baseStat_target/range).floor
|
||||
for j in 1...pokeArrayRand.length
|
||||
if $game_switches[SWITCH_RANDOM_WILD_ONLY_CUSTOMS] && $game_switches[SWITCH_RANDOM_WILD_TO_FUSION] && !customSpriteExists(pokeArrayRand[j])
|
||||
next
|
||||
end
|
||||
baseStats=getBaseStatsFormattedForRandomizer(pokeArrayRand[j])
|
||||
baseStat_temp = 0
|
||||
for l in 0...baseStats.length
|
||||
baseStat_temp+=baseStats[l]
|
||||
end
|
||||
baseStat_temp = (baseStat_temp/range).floor
|
||||
|
||||
|
||||
playShuffleSE(i)
|
||||
|
||||
#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])
|
||||
if i % 2 == 0 && type == 1
|
||||
n = (i.to_f/NB_POKEMON)*100
|
||||
Kernel.pbMessageNoSound(_INTL("\\ts[]Shuffling wild Pokémon...\\n {1}%\\^",sprintf('%.2f', n),NB_POKEMON))
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
psuedoBSTHash[NB_POKEMON] = NB_POKEMON
|
||||
#add hashes to global data
|
||||
$PokemonGlobal.psuedoHash = psuedoHash
|
||||
$PokemonGlobal.psuedoBSTHash = psuedoBSTHash
|
||||
return pokeArray
|
||||
end
|
||||
|
||||
def isPartArceus(poke,type=0)
|
||||
|
||||
def get_randomized_bst_hash(poke_list, bst_range,show_progress=true)
|
||||
bst_hash = Hash.new
|
||||
for i in 1..NB_POKEMON - 1
|
||||
show_shuffle_progress(i) if show_progress
|
||||
baseStats = getBaseStatsFormattedForRandomizer(i)
|
||||
statsTotal = getStatsTotal(baseStats)
|
||||
|
||||
targetStats_max = statsTotal + bst_range
|
||||
targetStats_min = statsTotal - bst_range
|
||||
max_bst_allowed=targetStats_max
|
||||
min_bst_allowed=targetStats_min
|
||||
#if a match, add to hash, remove from array, and cycle to next poke in dex
|
||||
playShuffleSE(i)
|
||||
random_poke = poke_list.sample
|
||||
random_poke_bst=getStatsTotal(getBaseStatsFormattedForRandomizer(random_poke))
|
||||
j=0
|
||||
while(random_poke_bst <= min_bst_allowed || random_poke_bst >= max_bst_allowed)
|
||||
random_poke = poke_list.sample
|
||||
random_poke_bst=getStatsTotal(getBaseStatsFormattedForRandomizer(random_poke))
|
||||
j+=1
|
||||
if j % 5 ==0 #to avoid infinite loops if can't find anything
|
||||
min_bst_allowed-=1
|
||||
max_bst_allowed+=1
|
||||
end
|
||||
end
|
||||
bst_hash[i] = random_poke
|
||||
end
|
||||
return bst_hash
|
||||
end
|
||||
|
||||
|
||||
def show_shuffle_progress(i)
|
||||
if i % 2 == 0
|
||||
n = (i.to_f/NB_POKEMON)*100
|
||||
Kernel.pbMessageNoSound(_INTL("\\ts[]Shuffling wild Pokémon...\\n {1}%\\^",sprintf('%.2f', n),NB_POKEMON))
|
||||
end
|
||||
end
|
||||
##############
|
||||
# randomizer shuffle
|
||||
# ##############
|
||||
def Kernel.pbShuffleDex(range = 50, type = 0)
|
||||
$game_switches[SWITCH_RANDOMIZED_AT_LEAST_ONCE] = true
|
||||
|
||||
#type 0: BST
|
||||
#type 1: full random
|
||||
range = 1 if range == 0
|
||||
only_customs = $game_switches[SWITCH_RANDOM_WILD_ONLY_CUSTOMS]
|
||||
should_include_fusions = $game_switches[SWITCH_RANDOM_WILD_TO_FUSION]
|
||||
|
||||
# create hash
|
||||
pokemon_list = only_customs ? getCustomSpeciesList() : get_pokemon_list(should_include_fusions)
|
||||
$PokemonGlobal.psuedoBSTHash = get_randomized_bst_hash(pokemon_list,range,should_include_fusions)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
#
|
||||
# # ######
|
||||
# # #on remet arceus a la fin
|
||||
# # pokeArray.push(NB_POKEMON)
|
||||
#
|
||||
# # fill random hash
|
||||
# #random hash will have to be accessed by number, not internal name
|
||||
#
|
||||
# #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..NB_POKEMON-1
|
||||
# baseStats=getBaseStatsFormattedForRandomizer(i)
|
||||
# baseStat_target = 0
|
||||
# for k in 0...baseStats.length
|
||||
# baseStat_target+=baseStats[k]
|
||||
# end
|
||||
# baseStat_target = (baseStat_target+range).floor
|
||||
# for j in 1...pokeArrayRand.length
|
||||
# if $game_switches[SWITCH_RANDOM_WILD_ONLY_CUSTOMS] && $game_switches[SWITCH_RANDOM_WILD_TO_FUSION] && !customSpriteExists(pokeArrayRand[j])
|
||||
# next
|
||||
# end
|
||||
# baseStats=getBaseStatsFormattedForRandomizer(pokeArrayRand[j])
|
||||
# baseStat_temp = 0
|
||||
# for l in 0...baseStats.length
|
||||
# baseStat_temp+=baseStats[l]
|
||||
# end
|
||||
# baseStat_temp = (baseStat_temp+range).floor
|
||||
#
|
||||
#
|
||||
# playShuffleSE(i)
|
||||
#
|
||||
# #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])
|
||||
# if i % 2 == 0 && type == 1
|
||||
# n = (i.to_f/NB_POKEMON)*100
|
||||
# Kernel.pbMessageNoSound(_INTL("\\ts[]Shuffling wild Pokémon...\\n {1}%\\^",sprintf('%.2f', n),NB_POKEMON))
|
||||
# end
|
||||
# break
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# psuedoBSTHash[NB_POKEMON] = NB_POKEMON
|
||||
# #add hashes to global data
|
||||
# $PokemonGlobal.psuedoHash = psuedoHash
|
||||
# $PokemonGlobal.psuedoBSTHash = psuedoBSTHash
|
||||
# end
|
||||
|
||||
def getStatsTotal(baseStats)
|
||||
bst = 0
|
||||
for k in 0...baseStats.length
|
||||
bst += baseStats[k]
|
||||
end
|
||||
return bst
|
||||
end
|
||||
|
||||
def isPartArceus(poke, type = 0)
|
||||
return true if poke == NB_POKEMON
|
||||
if type == 1
|
||||
return true if getBasePokemonID(poke,true) == NB_POKEMON
|
||||
return true if getBasePokemonID(poke,false) == NB_POKEMON
|
||||
return true if getBasePokemonID(poke, true) == NB_POKEMON
|
||||
return true if getBasePokemonID(poke, false) == NB_POKEMON
|
||||
end
|
||||
return false
|
||||
end
|
||||
@@ -116,7 +169,7 @@ end
|
||||
#Randomizer code is shit. Too lazy to redo it.
|
||||
# Here is a cheap workaround lol
|
||||
def getBaseStatsFormattedForRandomizer(dex_num)
|
||||
statsArray=[]
|
||||
statsArray = []
|
||||
stats = GameData::Species.get(dex_num).base_stats
|
||||
statsArray << stats[:HP]
|
||||
statsArray << stats[:ATTACK]
|
||||
@@ -189,7 +242,7 @@ def getRandomizedTo(species)
|
||||
# code here
|
||||
end
|
||||
|
||||
def tryRandomizeGiftPokemon(pokemon,dontRandomize=false)
|
||||
def tryRandomizeGiftPokemon(pokemon, dontRandomize = false)
|
||||
if $game_switches[SWITCH_RANDOM_GIFT_POKEMON] && $game_switches[SWITCH_RANDOM_WILD] && !dontRandomize
|
||||
oldSpecies = dexNum(pokemon.species)
|
||||
pokemon.species = getSpecies($PokemonGlobal.psuedoBSTHash[oldSpecies])
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
75370
PBS/encounters.txt
75370
PBS/encounters.txt
File diff suppressed because it is too large
Load Diff
5414
PBS/trainers.txt
5414
PBS/trainers.txt
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user