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

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