area randomizer + static encounters randomizer

This commit is contained in:
infinitefusion
2022-09-17 18:03:11 -04:00
parent a81e7240b4
commit c57045616d
22 changed files with 279 additions and 210 deletions

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.

View File

@@ -3,6 +3,7 @@ module GameData
attr_accessor :id attr_accessor :id
attr_accessor :map attr_accessor :map
attr_accessor :version attr_accessor :version
attr_reader :step_chances attr_reader :step_chances
attr_reader :types attr_reader :types

View File

@@ -332,6 +332,12 @@ end
# Used when walking in tall grass, hence the additional code. # Used when walking in tall grass, hence the additional code.
def pbWildBattle(species, level, outcomeVar=1, canRun=true, canLose=false) def pbWildBattle(species, level, outcomeVar=1, canRun=true, canLose=false)
species = GameData::Species.get(species).id species = GameData::Species.get(species).id
dexnum = getDexNumberForSpecies(species)
if $game_switches[SWITCH_RANDOM_STATIC_ENCOUNTERS] && dexnum <= NB_POKEMON
newSpecies = $PokemonGlobal.psuedoBSTHash[dexnum]
species = getSpecies(newSpecies)
end
# Potentially call a different pbWildBattle-type method instead (for roaming # Potentially call a different pbWildBattle-type method instead (for roaming
# Pokémon, Safari battles, Bug Contest battles) # Pokémon, Safari battles, Bug Contest battles)
handled = [nil] handled = [nil]

View File

@@ -984,6 +984,7 @@ module Compiler
slots.compact! slots.compact!
slots.sort! { |a, b| (a[0] == b[0]) ? a[1].to_s <=> b[1].to_s : b[0] <=> a[0] } slots.sort! { |a, b| (a[0] == b[0]) ? a[1].to_s <=> b[1].to_s : b[0] <=> a[0] }
end end
p encounter_hash
GameData::Encounter.register(encounter_hash) GameData::Encounter.register(encounter_hash)
end end
# Raise an error if a map/version combo is used twice # Raise an error if a map/version combo is used twice
@@ -1055,6 +1056,7 @@ module Compiler
slots.compact! slots.compact!
slots.sort! { |a, b| (a[0] == b[0]) ? a[1].to_s <=> b[1].to_s : b[0] <=> a[0] } slots.sort! { |a, b| (a[0] == b[0]) ? a[1].to_s <=> b[1].to_s : b[0] <=> a[0] }
end end
p encounter_hash
GameData::Encounter.register(encounter_hash) GameData::Encounter.register(encounter_hash)
end end
# Save all data # Save all data

View File

@@ -113,10 +113,8 @@ class RandomizerOptionsScene < PokemonOption_Scene
@openWildOptions = false @openWildOptions = false
end end
end end
class RandomizerTrainerOptionsScene < PokemonOption_Scene class RandomizerTrainerOptionsScene < PokemonOption_Scene
RANDOM_TEAMS_CUSTOM_SPRITES = 600 RANDOM_TEAMS_CUSTOM_SPRITES = 600
RANDOM_HELD_ITEMS = 843 RANDOM_HELD_ITEMS = 843
@@ -138,7 +136,6 @@ class RandomizerTrainerOptionsScene < PokemonOption_Scene
_INTL("Randomizer settings: Trainers"), 0, 0, Graphics.width, 64, @viewport) _INTL("Randomizer settings: Trainers"), 0, 0, Graphics.width, 64, @viewport)
@sprites["textbox"].text = _INTL("Set the randomizer settings for trainers") @sprites["textbox"].text = _INTL("Set the randomizer settings for trainers")
pbFadeInAndShow(@sprites) { pbUpdate } pbFadeInAndShow(@sprites) { pbUpdate }
end end
@@ -167,7 +164,6 @@ class RandomizerTrainerOptionsScene < PokemonOption_Scene
end end
end end
class RandomizerWildPokemonOptionsScene < PokemonOption_Scene class RandomizerWildPokemonOptionsScene < PokemonOption_Scene
RANDOM_WILD_AREA = 777 RANDOM_WILD_AREA = 777
RANDOM_WILD_GLOBAL = 956 RANDOM_WILD_GLOBAL = 956
@@ -200,7 +196,7 @@ class RandomizerWildPokemonOptionsScene < PokemonOption_Scene
def pbGetOptions(inloadscreen = false) def pbGetOptions(inloadscreen = false)
options = [ options = [
EnumOption.new(_INTL("Type"), [_INTL("Global")],#, _INTL("Area")], EnumOption.new(_INTL("Type"), [_INTL("Global"), _INTL("Area")],
proc { proc {
if $game_switches[RANDOM_WILD_AREA] if $game_switches[RANDOM_WILD_AREA]
1 1
@@ -217,14 +213,19 @@ class RandomizerWildPokemonOptionsScene < PokemonOption_Scene
$game_switches[RANDOM_WILD_GLOBAL] = false $game_switches[RANDOM_WILD_GLOBAL] = false
$game_switches[RANDOM_WILD_AREA] = true $game_switches[RANDOM_WILD_AREA] = true
end end
} },
[
"Randomizes Pokémon using a one-to-one mapping of the Pokedex",
"Randomizes the encounters in each route individually"
]
),
EnumOption.new(_INTL("Static encounters"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[RANDOM_STATIC] ? 0 : 1 },
proc { |value|
$game_switches[RANDOM_STATIC] = value == 0
},
"Randomize Pokémon that appear in the overworld (including legendaries)"
), ),
# EnumOption.new(_INTL("Static encounters"), [_INTL("On"), _INTL("Off")],
# proc { $game_switches[RANDOM_STATIC] ? 0 : 1 },
# proc { |value|
# $game_switches[RANDOM_STATIC] = value == 0
# }
# ),
EnumOption.new(_INTL("Gift Pokémon"), [_INTL("On"), _INTL("Off")], EnumOption.new(_INTL("Gift Pokémon"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[GIFT_POKEMON] ? 0 : 1 }, proc { $game_switches[GIFT_POKEMON] ? 0 : 1 },
@@ -243,14 +244,13 @@ class RandomizerWildPokemonOptionsScene < PokemonOption_Scene
proc { $game_switches[SWITCH_RANDOM_WILD_ONLY_CUSTOMS] ? 0 : 1 }, proc { $game_switches[SWITCH_RANDOM_WILD_ONLY_CUSTOMS] ? 0 : 1 },
proc { |value| proc { |value|
$game_switches[SWITCH_RANDOM_WILD_ONLY_CUSTOMS] = value == 0 $game_switches[SWITCH_RANDOM_WILD_ONLY_CUSTOMS] = value == 0
}, "(When fuse everything option is on) Randomize only to Pokémon that have a custom sprite." }, "(With fuse everything option) Randomize only to Pokémon that have a custom sprite."
) )
] ]
return options return options
end end
end end
class RandomizerGymOptionsScene < PokemonOption_Scene class RandomizerGymOptionsScene < PokemonOption_Scene
RANDOM_GYM_TYPES = 921 RANDOM_GYM_TYPES = 921
@@ -270,7 +270,6 @@ class RandomizerGymOptionsScene < PokemonOption_Scene
_INTL("Randomizer settings: Gyms"), 0, 0, Graphics.width, 64, @viewport) _INTL("Randomizer settings: Gyms"), 0, 0, Graphics.width, 64, @viewport)
@sprites["textbox"].text = _INTL("Set the randomizer settings for gyms") @sprites["textbox"].text = _INTL("Set the randomizer settings for gyms")
pbFadeInAndShow(@sprites) { pbUpdate } pbFadeInAndShow(@sprites) { pbUpdate }
end end

View File

@@ -3,61 +3,113 @@
# Randomize encounter by routes # Randomize encounter by routes
# Script by Frogman # Script by Frogman
# #
def Kernel.randomizeWildPokemonByRoute() def Kernel.randomizeWildPokemonByRoute()
bstRange = $game_variables[197] bstRange = $game_variables[VAR_RANDOMIZER_WILD_POKE_BST]
randomizeToFusions = $game_switches[953] randomizeToFusions = $game_switches[SWITCH_RANDOM_WILD_TO_FUSION]
$game_switches[829] = randomizeToFusions #unused mais probab. utile pour débugger les inévitables bugs quand les gens vont se partager leurs fichiers onlyCustoms = $game_switches[SWITCH_RANDOM_WILD_ONLY_CUSTOMS] && randomizeToFusions
customsList = onlyCustoms ? getCustomSpeciesList() : []
maxSpecies = randomizeToFusions ? PBSpecies.maxValue : NB_POKEMON maxSpecies = randomizeToFusions ? PBSpecies.maxValue : NB_POKEMON
data=load_data("Data/encounters.dat") GameData::EncounterRandom::DATA.clear
map_index = 0 GameData::Encounter.each do |enc_data|
nb_maps= data.size encounters_hash = {}
if data.is_a?(Hash) encounters_hash[:id] = enc_data.id
for map in data encounters_hash[:map] = enc_data.map
map_index += 1 encounters_hash[:version] = enc_data.version
displayProgress(map_index,nb_maps,bstRange) encounters_hash[:step_chances] = enc_data.step_chances
map_id = map[0] types_hash = {}
encountersList = map[1][1] enc_data.types.each do |key, value|
next if encountersList== nil pokemonList = value
type_index =-1 newType = randomizePokemonList(pokemonList,bstRange,maxSpecies,randomizeToFusions,customsList)
for encounterType in encountersList types_hash[key]= newType
type_index +=1 end
next if encounterType == nil encounters_hash[:types] = types_hash
previousSpecies = -1 GameData::EncounterRandom.register(encounters_hash)
previousNewSpecies = -1 end
encounter_index = 0
for encounter in encounterType # Save all data
species = encounter[0] GameData::EncounterRandom.save
if species != previousSpecies Graphics.update
newSpecies= getNewSpecies(species,bstRange,true,maxSpecies) GameData::EncounterRandom.load
previousSpecies = species end
previousNewSpecies = newSpecies
#input: [[60, :TENTACOOL,5,40, [30, :GOLDEEN, 5, 35], etc.]]
def randomizePokemonList(encountersList,bstRange=50,maxSpecies=420,customOnly=false,customsList=[])
newList=[]
for encounter in encountersList
oldPokemon = encounter[1]
if customOnly
newPokemon = getNewCustomSpecies(oldPokemon,customsList,bstRange,false)
else else
newSpecies = previousNewSpecies newPokemon = getNewSpecies(oldPokemon,bstRange,false,maxSpecies)
end end
if data[map_id][1][type_index][encounter_index] != nil newEntry =[]
data[map_id][1][type_index][encounter_index][0] = newSpecies newEntry << encounter[0]
newEntry << getSpecies(newPokemon).species
newEntry << encounter[2]
newEntry << encounter[3]
newList << newEntry
end end
encounter_index +=1 return newList
end #for -encounter
end #for encountertype
end #for - map
end #if
filename = "Data/encounters_randomized.dat"
save_data(Marshal.load(Marshal.dump(data)),filename)
$PokemonEncounters.setup($game_map.map_id)
end end
#
# def Kernel.randomizeWildPokemonByRouteOld()
# bstRange = $game_variables[VAR_RANDOMIZER_WILD_POKE_BST]
# randomizeToFusions = $game_switches[SWITCH_RANDOM_WILD_TO_FUSION]
# $game_switches[SWITCH_RANDOMIZED_WILD_POKEMON_TO_FUSIONS] = randomizeToFusions #unused mais probab. utile pour débugger les inévitables bugs quand les gens vont se partager leurs fichiers
# maxSpecies = randomizeToFusions ? PBSpecies.maxValue : NB_POKEMON
# data=load_data("Data/encounters.dat")
# map_index = 0
# nb_maps= data.size
# if data.is_a?(Hash)
# for map in data
# map_index += 1
# displayProgress(map_index,nb_maps,bstRange)
# map_id = map[0]
#
# encountersList = GameData::Encounter.get(map_id)
# p encountersList
# next if encountersList== nil
# type_index =-1
# for encounterType in encountersList
# type_index +=1
# next if encounterType == nil
# previousSpecies = -1
# previousNewSpecies = -1
# encounter_index = 0
# for encounter in encounterType
# species = encounter[0]
# if species != previousSpecies
# newSpecies= getNewSpecies(species,bstRange,true,maxSpecies)
# previousSpecies = species
# previousNewSpecies = newSpecies
# else
# newSpecies = previousNewSpecies
# end
# if data[map_id][1][type_index][encounter_index] != nil
# data[map_id][1][type_index][encounter_index][0] = newSpecies
# end
# encounter_index +=1
# end #for -encounter
# end #for encountertype
# end #for - map
# end #if
# filename = "Data/encounters_randomized.dat"
# save_data(Marshal.load(Marshal.dump(data)),filename)
# $PokemonEncounters.setup($game_map.map_id)
# end
#file = File.new('Data/test.txt', 'w') #file = File.new('Data/test.txt', 'w')
#file.puts data.inspect #file.puts data.inspect
def displayProgress(current,total,bst) # def displayProgress(current,total,bst)
return if bst >= 100 # return if bst >= 100
return if bst >= 20 && current % 10 != 0 # return if bst >= 20 && current % 10 != 0
Kernel.pbMessageNoSound(_INTL("\\ts[]Generating encounters file...\\n Map {1}/{2}\\^",current,total)) # Kernel.pbMessageNoSound(_INTL("\\ts[]Generating encounters file...\\n Map {1}/{2}\\^",current,total))
end # end
# #
# class PokemonEncounters # class PokemonEncounters
@@ -121,37 +173,37 @@ end
# end # end
#
def getRandomPokemon(originalPokemon,bstRange,maxDexNumber) # def getRandomPokemon(originalPokemon,bstRange,maxDexNumber)
originalBst = getBaseStatsTotal(originalPokemon) # originalBst = getBaseStatsTotal(originalPokemon)
bstMin = originalBst-bstRange # bstMin = originalBst-bstRange
bstMax = originalBst+bstRange # bstMax = originalBst+bstRange
#
foundAPokemon = false # foundAPokemon = false
int i=0 # int i=0
while ! foundAPokemon # while ! foundAPokemon
newPoke = rand(maxDexNumber-1)+1 # newPoke = rand(maxDexNumber-1)+1
newPokeBST = getBaseStatsTotal(newPoke) # newPokeBST = getBaseStatsTotal(newPoke)
if newPokeBST >= bstMin && newPokeBST <= bstMax # if newPokeBST >= bstMin && newPokeBST <= bstMax
foundAPokemon = true # foundAPokemon = true
end # end
i+=1 # i+=1
if i %10 ==0 # if i %10 ==0
bstMin-=5 # bstMin-=5
bstMax+=5 # bstMax+=5
end # end
end # end
return newPoke # return newPoke
end # end
#
def getBaseStatsTotal(species) # def getBaseStatsTotal(species)
baseStats=$pkmn_dex[species][5] # baseStats=$pkmn_dex[species][5]
baseStat_temp = 0 # baseStat_temp = 0
for i in 0...baseStats.length # for i in 0...baseStats.length
baseStat_temp+=baseStats[i] # baseStat_temp+=baseStats[i]
end # end
return (baseStat_temp/range).floor # return (baseStat_temp/range).floor
end # end
###################################################### ######################################################

View File

@@ -315,6 +315,14 @@ def playShuffleSE(i)
end end
end end
def getTrainersDataMode
mode = GameData::Trainer
if $game_switches && $game_switches[SWITCH_MODERN_MODE]
mode = GameData::TrainerModern
end
return mode
end
def Kernel.pbShuffleTrainers(bst_range = 50,customsOnly=false,customsList=nil) def Kernel.pbShuffleTrainers(bst_range = 50,customsOnly=false,customsList=nil)
bst_range = pbGet(VAR_RANDOMIZER_TRAINER_BST) bst_range = pbGet(VAR_RANDOMIZER_TRAINER_BST)
@@ -323,7 +331,7 @@ def Kernel.pbShuffleTrainers(bst_range = 50,customsOnly=false,customsList=nil)
customsOnly = false customsOnly = false
end end
randomTrainersHash = Hash.new randomTrainersHash = Hash.new
trainers_data = getTrainersDataMode.list_all trainers_data = GameData::Trainer.list_all
trainers_data.each do |key, value| trainers_data.each do |key, value|
trainer = trainers_data[key] trainer = trainers_data[key]
i=0 i=0

View File

@@ -63,6 +63,7 @@ SWITCH_RANDOMIZED_GYM_TYPES=921
SWITCH_RANDOM_GIFT_POKEMON = 780 SWITCH_RANDOM_GIFT_POKEMON = 780
SWITCH_RANDOM_HELD_ITEMS = 843 SWITCH_RANDOM_HELD_ITEMS = 843
SWITCH_DEFINED_RIVAL_STARTER=840 SWITCH_DEFINED_RIVAL_STARTER=840
SWITCH_RANDOMIZED_WILD_POKEMON_TO_FUSIONS=829
#Other switches #Other switches
SWITCH_RACE_BIKE = 984 SWITCH_RACE_BIKE = 984
SWITCH_IS_REMATCH=200 SWITCH_IS_REMATCH=200

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.