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
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)
if shadow
if (index & 1) == 1 # Foe Pokémon

View File

@@ -114,8 +114,52 @@ module GameData
end
end
def replace_species_to_randomized(species,trainerId,pokemonIndex)
return species if $game_switches[SWITCH_FIRST_RIVAL_BATTLE]
#todo customsListinCache so it's faster
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
Kernel.pbMessage(_INTL("The trainers need to be re-shuffled."))
Kernel.pbShuffleTrainers()
@@ -124,6 +168,19 @@ module GameData
return getSpecies(new_species_dex)
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)
if $game_switches[SWITCH_SINGLE_POKEMON_MODE]
if $game_switches[SWITCH_SINGLE_POKEMON_MODE_HEAD]
@@ -131,7 +188,7 @@ module GameData
elsif $game_switches[SWITCH_SINGLE_POKEMON_MODE_BODY]
return replaceFusionsBodyWithSpecies(species)
elsif $game_switches[SWITCH_SINGLE_POKEMON_MODE_RANDOM]
if(rand(2) == 0)
if (rand(2) == 0)
return replaceFusionsHeadWithSpecies(species)
else
return replaceFusionsBodyWithSpecies(species)
@@ -146,7 +203,7 @@ module GameData
if speciesId > NB_POKEMON
bodyPoke = getBodyID(speciesId)
headPoke = pbGet(VAR_SINGLE_POKEMON_MODE)
newSpecies = bodyPoke*NB_POKEMON+headPoke
newSpecies = bodyPoke * NB_POKEMON + headPoke
return getPokemon(newSpecies)
end
return species
@@ -157,14 +214,12 @@ module GameData
if speciesId > NB_POKEMON
bodyPoke = pbGet(VAR_SINGLE_POKEMON_MODE)
headPoke = getHeadID(species)
newSpecies = bodyPoke*NB_POKEMON+headPoke
newSpecies = bodyPoke * NB_POKEMON + headPoke
return getPokemon(newSpecies)
end
return species
end
def to_trainer
placeholder_species = [Settings::RIVAL_STARTER_PLACEHOLDER_SPECIES,
Settings::VAR_1_PLACEHOLDER_SPECIES,
@@ -184,7 +239,7 @@ module GameData
trainer.lose_text = self.lose_text
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)
# Create each Pokémon owned by the trainer
@@ -192,7 +247,7 @@ module GameData
@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
species = replace_species_to_randomized(species, self.id, index) if isPlayingRandomized
if placeholder_species.include?(species)
species = replace_species_with_placeholder(species)
end
@@ -216,14 +271,12 @@ module GameData
end
####
#trainer rematch infinite fusion edit
if isRematch
nbRematch = getNumberRematch(rematchId)
level = getRematchLevel(level, nbRematch)
species = evolveRematchPokemon(nbRematch, species)
end
#
pkmn = Pokemon.new(species, level, trainer, false)
trainer.party.push(pkmn)
@@ -270,7 +323,7 @@ module GameData
pkmn.poke_ball = pkmn_data[:poke_ball] if pkmn_data[:poke_ball]
pkmn.calc_stats
index +=1
index += 1
end
return trainer
end

View File

@@ -8,6 +8,7 @@ class RandomizerOptionsScene < PokemonOption_Scene
super
@openTrainerOptions = false
@openWildOptions = false
@openGymOptions = false
end
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")],
proc {
$game_switches[SWITCH_RANDOM_WILD] ? 0 : 1
@@ -67,6 +79,16 @@ class RandomizerOptionsScene < PokemonOption_Scene
return options
end
def openGymOptionsMenu()
return if !@openGymOptions
pbFadeOutIn {
scene = RandomizerGymOptionsScene.new
screen = PokemonOptionScreen.new(scene)
screen.pbStartScreen
}
@openGymOptions = false
end
def openTrainerOptionsMenu()
return if !@openTrainerOptions
pbFadeOutIn {
@@ -134,14 +156,7 @@ class RandomizerTrainerOptionsScene < PokemonOption_Scene
proc { |value|
$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
end
@@ -228,4 +243,59 @@ class RandomizerWildPokemonOptionsScene < PokemonOption_Scene
]
return options
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

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

View File

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

View File

@@ -50,9 +50,13 @@ SWITCH_RANDOM_TMS = 959
SWITCH_WILD_RANDOM_GLOBAL=956
SWITCH_RANDOM_STATIC_ENCOUNTERS=955
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
#Random switches
#Other switches
SWITCH_RACE_BIKE = 984
SWITCH_IS_REMATCH=200
SWITCH_SINGLE_POKEMON_MODE=790
@@ -83,6 +87,9 @@ VAR_PREMIUM_WONDERTRADE_LEFT=111
VAR_PREMIUM_WONDERTRADE_LEFT=111
#Randomizer
VAR_RANDOMIZER_WILD_POKE_BST=197
VAR_RANDOMIZER_TRAINER_BST=195
VAR_GYM_TYPES_ARRAY=151
VAR_CURRENT_GYM_TYPE=152
#############
# OTHERS #

Binary file not shown.