randomizer - gym trainers

This commit is contained in:
infinitefusion
2022-05-01 13:51:59 -04:00
parent 2365dfeb51
commit 089975984e
11 changed files with 192 additions and 57 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -204,6 +204,17 @@ module GameData
return @id_number > Settings::NB_POKEMON return @id_number > Settings::NB_POKEMON
end end
def hasType?(type)
type = GameData::Type.get(type).id
return self.types.include?(type)
end
def types
types = [@type1]
types << @type2 if @type2 && @type2 != @type1
return types
end
def apply_metrics_to_sprite(sprite, index, shadow = false) def apply_metrics_to_sprite(sprite, index, shadow = false)
if shadow if shadow
if (index & 1) == 1 # Foe Pokémon if (index & 1) == 1 # Foe Pokémon

View File

@@ -114,8 +114,52 @@ module GameData
end end
end end
def replace_species_to_randomized(species,trainerId,pokemonIndex) #todo customsListinCache so it's faster
return species if $game_switches[SWITCH_FIRST_RIVAL_BATTLE] def generateRandomGymSpecies(old_species)
customsList = getCustomSpeciesList()
bst_range = pbGet(VAR_RANDOMIZER_TRAINER_BST)
gym_index = pbGet(VAR_CURRENT_GYM_TYPE)
type_id = pbGet(VAR_GYM_TYPES_ARRAY)[gym_index]
gym_type = GameData::Type.get(type_id)
return old_species if type_id == -1
while true
new_species = $game_switches[SWITCH_RANDOM_GYM_CUSTOMS] ? getSpecies(getNewCustomSpecies(old_species, customsList, bst_range)) : getSpecies(getNewSpecies(old_species, bst_range))
if new_species.hasType?(gym_type)
return new_species
end
end
end
def replace_species_to_randomized_gym(species, trainerId, pokemonIndex)
if $PokemonGlobal.randomGymTrainersHash == nil
$PokemonGlobal.randomGymTrainersHash = {}
end
if $game_switches[SWITCH_RANDOM_GYM_PERSIST_TEAMS] && $PokemonGlobal.randomGymTrainersHash != nil
if $PokemonGlobal.randomGymTrainersHash[trainerId] != nil && $PokemonGlobal.randomGymTrainersHash[trainerId].length >= $PokemonGlobal.randomTrainersHash[trainerId].length
return getSpecies($PokemonGlobal.randomGymTrainersHash[trainerId][pokemonIndex])
end
end
new_species = generateRandomGymSpecies(species)
if $game_switches[SWITCH_RANDOM_GYM_PERSIST_TEAMS]
add_generated_species_to_gym_array(new_species, trainerId)
end
return new_species
end
def add_generated_species_to_gym_array(new_species, trainerId)
expected_team_length =1
expected_team_length = $PokemonGlobal.randomTrainersHash[trainerId].length if $PokemonGlobal.randomTrainersHash[trainerId]
new_team = []
if $PokemonGlobal.randomGymTrainersHash[trainerId]
new_team = $PokemonGlobal.randomGymTrainersHash[trainerId]
end
if new_team.length < expected_team_length
new_team << new_species.id_number
end
$PokemonGlobal.randomGymTrainersHash[trainerId] = new_team
end
def replace_species_to_randomized_regular(species, trainerId, pokemonIndex)
if $PokemonGlobal.randomTrainersHash[trainerId] == nil if $PokemonGlobal.randomTrainersHash[trainerId] == nil
Kernel.pbMessage(_INTL("The trainers need to be re-shuffled.")) Kernel.pbMessage(_INTL("The trainers need to be re-shuffled."))
Kernel.pbShuffleTrainers() Kernel.pbShuffleTrainers()
@@ -124,6 +168,19 @@ module GameData
return getSpecies(new_species_dex) return getSpecies(new_species_dex)
end end
def isGymBattle
return ($game_switches[SWITCH_RANDOM_TRAINERS] && ($game_variables[VAR_CURRENT_GYM_TYPE] != -1) || ($game_switches[SWITCH_FIRST_RIVAL_BATTLE] && $game_switches[SWITCH_RANDOM_STARTERS]))
end
def replace_species_to_randomized(species, trainerId, pokemonIndex)
return species if $game_switches[SWITCH_FIRST_RIVAL_BATTLE]
if isGymBattle() && $game_switches[SWITCH_RANDOMIZE_GYMS_SEPARATELY]
return replace_species_to_randomized_gym(species, trainerId, pokemonIndex)
end
return replace_species_to_randomized_regular(species, trainerId, pokemonIndex)
end
def replaceSingleSpeciesModeIfApplicable(species) def replaceSingleSpeciesModeIfApplicable(species)
if $game_switches[SWITCH_SINGLE_POKEMON_MODE] if $game_switches[SWITCH_SINGLE_POKEMON_MODE]
if $game_switches[SWITCH_SINGLE_POKEMON_MODE_HEAD] if $game_switches[SWITCH_SINGLE_POKEMON_MODE_HEAD]
@@ -131,7 +188,7 @@ module GameData
elsif $game_switches[SWITCH_SINGLE_POKEMON_MODE_BODY] elsif $game_switches[SWITCH_SINGLE_POKEMON_MODE_BODY]
return replaceFusionsBodyWithSpecies(species) return replaceFusionsBodyWithSpecies(species)
elsif $game_switches[SWITCH_SINGLE_POKEMON_MODE_RANDOM] elsif $game_switches[SWITCH_SINGLE_POKEMON_MODE_RANDOM]
if(rand(2) == 0) if (rand(2) == 0)
return replaceFusionsHeadWithSpecies(species) return replaceFusionsHeadWithSpecies(species)
else else
return replaceFusionsBodyWithSpecies(species) return replaceFusionsBodyWithSpecies(species)
@@ -146,7 +203,7 @@ module GameData
if speciesId > NB_POKEMON if speciesId > NB_POKEMON
bodyPoke = getBodyID(speciesId) bodyPoke = getBodyID(speciesId)
headPoke = pbGet(VAR_SINGLE_POKEMON_MODE) headPoke = pbGet(VAR_SINGLE_POKEMON_MODE)
newSpecies = bodyPoke*NB_POKEMON+headPoke newSpecies = bodyPoke * NB_POKEMON + headPoke
return getPokemon(newSpecies) return getPokemon(newSpecies)
end end
return species return species
@@ -157,14 +214,12 @@ module GameData
if speciesId > NB_POKEMON if speciesId > NB_POKEMON
bodyPoke = pbGet(VAR_SINGLE_POKEMON_MODE) bodyPoke = pbGet(VAR_SINGLE_POKEMON_MODE)
headPoke = getHeadID(species) headPoke = getHeadID(species)
newSpecies = bodyPoke*NB_POKEMON+headPoke newSpecies = bodyPoke * NB_POKEMON + headPoke
return getPokemon(newSpecies) return getPokemon(newSpecies)
end end
return species return species
end end
def to_trainer def to_trainer
placeholder_species = [Settings::RIVAL_STARTER_PLACEHOLDER_SPECIES, placeholder_species = [Settings::RIVAL_STARTER_PLACEHOLDER_SPECIES,
Settings::VAR_1_PLACEHOLDER_SPECIES, Settings::VAR_1_PLACEHOLDER_SPECIES,
@@ -184,7 +239,7 @@ module GameData
trainer.lose_text = self.lose_text trainer.lose_text = self.lose_text
isRematch = $game_switches[SWITCH_IS_REMATCH] isRematch = $game_switches[SWITCH_IS_REMATCH]
isPlayingRandomized = $game_switches[SWITCH_RANDOM_TRAINERS] && !$game_switches[SWITCH_FIRST_RIVAL_BATTLE] isPlayingRandomized = $game_switches[SWITCH_RANDOM_TRAINERS] && !$game_switches[SWITCH_FIRST_RIVAL_BATTLE]
rematchId = getRematchId(trainer.name, trainer.trainer_type) rematchId = getRematchId(trainer.name, trainer.trainer_type)
# Create each Pokémon owned by the trainer # Create each Pokémon owned by the trainer
@@ -192,7 +247,7 @@ module GameData
@pokemon.each do |pkmn_data| @pokemon.each do |pkmn_data|
#replace placeholder species infinite fusion edit #replace placeholder species infinite fusion edit
species = GameData::Species.get(pkmn_data[:species]).species species = GameData::Species.get(pkmn_data[:species]).species
species = replace_species_to_randomized(species,self.id,index) if isPlayingRandomized species = replace_species_to_randomized(species, self.id, index) if isPlayingRandomized
if placeholder_species.include?(species) if placeholder_species.include?(species)
species = replace_species_with_placeholder(species) species = replace_species_with_placeholder(species)
end end
@@ -216,14 +271,12 @@ module GameData
end end
#### ####
#trainer rematch infinite fusion edit #trainer rematch infinite fusion edit
if isRematch if isRematch
nbRematch = getNumberRematch(rematchId) nbRematch = getNumberRematch(rematchId)
level = getRematchLevel(level, nbRematch) level = getRematchLevel(level, nbRematch)
species = evolveRematchPokemon(nbRematch, species) species = evolveRematchPokemon(nbRematch, species)
end end
#
pkmn = Pokemon.new(species, level, trainer, false) pkmn = Pokemon.new(species, level, trainer, false)
trainer.party.push(pkmn) trainer.party.push(pkmn)
@@ -270,7 +323,7 @@ module GameData
pkmn.poke_ball = pkmn_data[:poke_ball] if pkmn_data[:poke_ball] pkmn.poke_ball = pkmn_data[:poke_ball] if pkmn_data[:poke_ball]
pkmn.calc_stats pkmn.calc_stats
index +=1 index += 1
end end
return trainer return trainer
end end

View File

@@ -8,6 +8,7 @@ class RandomizerOptionsScene < PokemonOption_Scene
super super
@openTrainerOptions = false @openTrainerOptions = false
@openWildOptions = false @openWildOptions = false
@openGymOptions = false
end end
def pbStartScene(inloadscreen = false) def pbStartScene(inloadscreen = false)
@@ -39,6 +40,17 @@ class RandomizerOptionsScene < PokemonOption_Scene
} }
), ),
EnumOption.new(_INTL("Gyms"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_RANDOMIZE_GYMS_SEPARATELY] ? 0 : 1 },
proc { |value|
if !$game_switches[SWITCH_RANDOMIZE_GYMS_SEPARATELY] && value == 0
@openGymOptions = true
openGymOptionsMenu()
end
$game_switches[SWITCH_RANDOMIZE_GYMS_SEPARATELY] = value == 0
}
),
EnumOption.new(_INTL("Wild Pokémon"), [_INTL("On"), _INTL("Off")], EnumOption.new(_INTL("Wild Pokémon"), [_INTL("On"), _INTL("Off")],
proc { proc {
$game_switches[SWITCH_RANDOM_WILD] ? 0 : 1 $game_switches[SWITCH_RANDOM_WILD] ? 0 : 1
@@ -67,6 +79,16 @@ class RandomizerOptionsScene < PokemonOption_Scene
return options return options
end end
def openGymOptionsMenu()
return if !@openGymOptions
pbFadeOutIn {
scene = RandomizerGymOptionsScene.new
screen = PokemonOptionScreen.new(scene)
screen.pbStartScreen
}
@openGymOptions = false
end
def openTrainerOptionsMenu() def openTrainerOptionsMenu()
return if !@openTrainerOptions return if !@openTrainerOptions
pbFadeOutIn { pbFadeOutIn {
@@ -134,14 +156,7 @@ class RandomizerTrainerOptionsScene < PokemonOption_Scene
proc { |value| proc { |value|
$game_switches[RANDOM_HELD_ITEMS] = value == 0 $game_switches[RANDOM_HELD_ITEMS] = value == 0
} }
), )
EnumOption.new(_INTL("Gym types"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[RANDOM_GYM_TYPES] ? 0 : 1 },
proc { |value|
$game_switches[RANDOM_GYM_TYPES] = value == 0
}
),
] ]
return options return options
end end
@@ -228,4 +243,59 @@ class RandomizerWildPokemonOptionsScene < PokemonOption_Scene
] ]
return options return options
end end
end
class RandomizerGymOptionsScene < PokemonOption_Scene
RANDOM_GYM_TYPES = 921
def initialize
@changedColor = false
end
def pbStartScene(inloadscreen = false)
super
@sprites["option"].nameBaseColor = Color.new(35, 130, 200)
@sprites["option"].nameShadowColor = Color.new(20, 75, 115)
@changedColor = true
for i in 0...@PokemonOptions.length
@sprites["option"][i] = (@PokemonOptions[i].get || 0)
end
@sprites["title"]=Window_UnformattedTextPokemon.newWithSize(
_INTL("Randomizer settings: Gyms"),0,0,Graphics.width,64,@viewport)
@sprites["textbox"].text=_INTL("Set the randomizer settings for gyms")
pbFadeInAndShow(@sprites) { pbUpdate }
end
def pbFadeInAndShow(sprites, visiblesprites = nil)
return if !@changedColor
super
end
def pbGetOptions(inloadscreen = false)
options = [
EnumOption.new(_INTL("Gym types"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[RANDOM_GYM_TYPES] ? 0 : 1 },
proc { |value|
$game_switches[RANDOM_GYM_TYPES] = value == 0
}
),
EnumOption.new(_INTL("Rerandomize each battle"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_GYM_RANDOM_EACH_BATTLE] ? 0 : 1 },
proc { |value|
$game_switches[SWITCH_GYM_RANDOM_EACH_BATTLE] = value == 0
$game_switches[SWITCH_RANDOM_GYM_PERSIST_TEAMS] = !$game_switches[SWITCH_GYM_RANDOM_EACH_BATTLE]
}
),
EnumOption.new(_INTL("Custom sprites only (Slower)"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_RANDOM_GYM_CUSTOMS] ? 0 : 1 },
proc { |value|
$game_switches[SWITCH_RANDOM_GYM_CUSTOMS] = value == 0
}
)
]
return options
end
end end

View File

@@ -29,14 +29,16 @@
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_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_ARRAY = [: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,:DRAGON]
#$randomTrainersArray = [] #$randomTrainersArray = []
#[fighting dojo est 9eme (1), 0 au debut pour pasavoir a faire -1] #[fighting dojo est 9eme (1), 0 au debut pour pasavoir a faire -1]
def Kernel.initRandomTypeArray() def Kernel.initRandomTypeArray()
typesArray = [0,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,14,15,11,17].shuffle #ne pas remettre 10 (QMARKS) typesArray = GYM_TYPES_ARRAY.shuffle #ne pas remettre 10 (QMARKS)
$game_variables[151] = $game_switches[921] ? typesArray : GYM_TYPES_ARRAY $game_variables[VAR_GYM_TYPES_ARRAY] = $game_switches[SWITCH_RANDOMIZED_GYM_TYPES] ? typesArray : GYM_TYPES_ARRAY
end end
@@ -61,27 +63,16 @@ end
class PokeBattle_Battle class PokeBattle_Battle
CONST_BST_RANGE = 25 #unused. $game_variables[197] a la place CONST_BST_RANGE = 25 #unused. $game_variables[197] a la place
def randomize_opponent_party(party) def randomize_opponent_party(party)
#return randomizedRivalFirstBattle(party) if $game_switches[46] && $game_switches[954] for pokemon in party
newparty = [] next if !pokemon
for m in party
next if !m
newspecies = rand(PBSpecies.maxValue - 1) + 1 newspecies = rand(PBSpecies.maxValue - 1) + 1
newBST = getBaseStats(newspecies) while !gymLeaderOk(newspecies) || bstOk(newspecies,pokemon.species,$game_variables[VAR_RANDOMIZER_WILD_POKE_BST])
originalBST = getBaseStats(m.species)
while !gymLeaderOk(newspecies) || bstOk(newspecies,m.species,$game_variables[197])
newspecies = rand(PBSpecies.maxValue - 1) + 1 newspecies = rand(PBSpecies.maxValue - 1) + 1
newBST = getBaseStats(newspecies)
#originalBST = getBaseStats(m.species)
end end
# Kernel.pbMessage(_INTL("OLD = {1}",newspecies)) pokemon.species = newspecies
pokemon.name = PBSpecies.getName(newspecies)
m.species = newspecies pokemon.resetMoves
m.name = PBSpecies.getName(newspecies) pokemon.calcStats
m.resetMoves
m.calcStats
#pbInitPokemon(m,m.species)
end end
return party return party
@@ -283,26 +274,28 @@ def Kernel.pbRandomizeTM()
end end
def getNewSpecies(oldSpecies,bst_range=50, ignoreRivalPlaceholder = false, maxDexNumber = PBSpecies.maxValue ) def getNewSpecies(oldSpecies,bst_range=50, ignoreRivalPlaceholder = false, maxDexNumber = PBSpecies.maxValue )
return oldSpecies if (oldSpecies == Settings::RIVAL_STARTER_PLACEHOLDER_SPECIES && !ignoreRivalPlaceholder) oldSpecies_dex = dexNum(oldSpecies)
return oldSpecies if oldSpecies >= Settings::ZAPMOLCUNO_NB return oldSpecies_dex if (oldSpecies_dex == Settings::RIVAL_STARTER_PLACEHOLDER_SPECIES && !ignoreRivalPlaceholder)
newspecies = rand(maxDexNumber - 1) + 1 return oldSpecies_dex if oldSpecies_dex >= Settings::ZAPMOLCUNO_NB
while bstOk(newspecies,oldSpecies,bst_range) newspecies_dex = rand(maxDexNumber - 1) + 1
newspecies = rand(maxDexNumber - 1) + 1 while bstOk(newspecies_dex,oldSpecies_dex,bst_range)
newspecies_dex = rand(maxDexNumber - 1) + 1
end end
return newspecies return newspecies_dex
end end
def getNewCustomSpecies(oldSpecies,customSpeciesList,bst_range=50, ignoreRivalPlaceholder = false) def getNewCustomSpecies(oldSpecies,customSpeciesList,bst_range=50, ignoreRivalPlaceholder = false)
return oldSpecies if (oldSpecies == Settings::RIVAL_STARTER_PLACEHOLDER_SPECIES && !ignoreRivalPlaceholder) oldSpecies_dex = dexNum(oldSpecies)
return oldSpecies if oldSpecies >= Settings::ZAPMOLCUNO_NB return oldSpecies_dex if (oldSpecies_dex == Settings::RIVAL_STARTER_PLACEHOLDER_SPECIES && !ignoreRivalPlaceholder)
return oldSpecies_dex if oldSpecies_dex >= Settings::ZAPMOLCUNO_NB
i = rand(customSpeciesList.length - 1) + 1 i = rand(customSpeciesList.length - 1) + 1
newspecies = customSpeciesList[i] newspecies_dex = customSpeciesList[i]
while bstOk(newspecies,oldSpecies,bst_range) while bstOk(newspecies_dex,oldSpecies_dex,bst_range)
i = rand(customSpeciesList.length - 1)#+1 i = rand(customSpeciesList.length - 1)#+1
newspecies = customSpeciesList[i] newspecies_dex = customSpeciesList[i]
end end
return newspecies return newspecies_dex
end end

View File

@@ -1,13 +1,14 @@
class PokemonGlobalMetadata class PokemonGlobalMetadata
attr_accessor :psuedoHash attr_accessor :psuedoHash
attr_accessor :psuedoBSTHash attr_accessor :psuedoBSTHash
attr_accessor :pseudoBSTHashTrainers
attr_accessor :randomTrainersHash attr_accessor :randomTrainersHash
attr_accessor :randomGymTrainersHash
alias random_init initialize alias random_init initialize
def initialize def initialize
random_init random_init
@randomGymTrainersHash=nil
@psuedoHash=nil @psuedoHash=nil
@psuedoBSTHash=nil @psuedoBSTHash=nil
end end
@@ -186,4 +187,4 @@ def getRandomizedTo(species)
return species if !$PokemonGlobal.psuedoBSTHash return species if !$PokemonGlobal.psuedoBSTHash
return $PokemonGlobal.psuedoBSTHash[dexNum(species)] return $PokemonGlobal.psuedoBSTHash[dexNum(species)]
# code here # code here
end end

View File

@@ -50,9 +50,13 @@ SWITCH_RANDOM_TMS = 959
SWITCH_WILD_RANDOM_GLOBAL=956 SWITCH_WILD_RANDOM_GLOBAL=956
SWITCH_RANDOM_STATIC_ENCOUNTERS=955 SWITCH_RANDOM_STATIC_ENCOUNTERS=955
SWITCH_RANDOM_WILD_ONLY_CUSTOMS=664 SWITCH_RANDOM_WILD_ONLY_CUSTOMS=664
SWITCH_RANDOM_GYM_PERSIST_TEAMS=663
SWITCH_GYM_RANDOM_EACH_BATTLE = 668
SWITCH_RANDOM_GYM_CUSTOMS=662
SWITCH_RANDOMIZE_GYMS_SEPARATELY = 667
SWITCH_RANDOMIZED_GYM_TYPES=921
#Other switches
#Random switches
SWITCH_RACE_BIKE = 984 SWITCH_RACE_BIKE = 984
SWITCH_IS_REMATCH=200 SWITCH_IS_REMATCH=200
SWITCH_SINGLE_POKEMON_MODE=790 SWITCH_SINGLE_POKEMON_MODE=790
@@ -83,6 +87,9 @@ VAR_PREMIUM_WONDERTRADE_LEFT=111
VAR_PREMIUM_WONDERTRADE_LEFT=111 VAR_PREMIUM_WONDERTRADE_LEFT=111
#Randomizer #Randomizer
VAR_RANDOMIZER_WILD_POKE_BST=197 VAR_RANDOMIZER_WILD_POKE_BST=197
VAR_RANDOMIZER_TRAINER_BST=195
VAR_GYM_TYPES_ARRAY=151
VAR_CURRENT_GYM_TYPE=152
############# #############
# OTHERS # # OTHERS #

Binary file not shown.