mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
compatibility items trainers
This commit is contained in:
198
Data/Scripts/025-Randomizer/Random Pokemon.rb
Normal file
198
Data/Scripts/025-Randomizer/Random Pokemon.rb
Normal file
@@ -0,0 +1,198 @@
|
||||
################################################################################
|
||||
# Randomized Pokemon Script
|
||||
# By Umbreon
|
||||
################################################################################
|
||||
# Used for a randomized pokemon challenge mainly.
|
||||
#
|
||||
# By randomized, I mean EVERY pokemon will be random, even interacted pokemon
|
||||
# like legendaries. (You may easily disable the randomizer for certain
|
||||
# situations like legendary battles and starter selecting.)
|
||||
#
|
||||
# To use: simply activate Switch Number X
|
||||
# (X = the number listed After "Switch = ", default is switch number 36.)
|
||||
#
|
||||
# If you want certain pokemon to NEVER appear, add them inside the black list.
|
||||
# (This does not take into effect if the switch stated above is off.)
|
||||
#
|
||||
# If you want ONLY certain pokemon to appear, add them to the whitelist. This
|
||||
# is only recommended when the amount of random pokemon available is around
|
||||
# 32 or less.(This does not take into effect if the switch stated above is off.)
|
||||
#
|
||||
################################################################################
|
||||
|
||||
########################## You may edit any settings below this freely.
|
||||
module RandomizedChallenge
|
||||
Switch = 36 # switch ID to randomize a pokemon, if it's on then ALL
|
||||
# pokemon will be randomized. No exceptions.
|
||||
|
||||
BlackListedPokemon = [] #[PBSpecies::MEW, PBSpecies::ARCEUS]
|
||||
# Pokemon to Black List. Any pokemon in here will NEVER appear.
|
||||
|
||||
WhiteListedPokemon = []
|
||||
# Leave this empty if all pokemon are allowed, otherwise only pokemon listed
|
||||
# above will be selected.
|
||||
end
|
||||
|
||||
######################### Do not edit anything below here.
|
||||
class PokeBattle_Pokemon
|
||||
|
||||
alias randomized_init initialize
|
||||
|
||||
def initialize(species, level, player = nil, withMoves = true)
|
||||
|
||||
if $game_switches && $game_switches[RandomizedChallenge::Switch]
|
||||
if $game_switches[991]
|
||||
species = rand(PBSpecies.maxValue - 1) + 1
|
||||
basestatsum = $pkmn_dex[species][5][0] # HP
|
||||
basestatsum += $pkmn_dex[species][5][1] # Attack
|
||||
basestatsum += $pkmn_dex[species][5][2] # Defense
|
||||
basestatsum += $pkmn_dex[species][5][3] # Speed
|
||||
basestatsum += $pkmn_dex[species][5][4] # Special Attack
|
||||
basestatsum += $pkmn_dex[species][5][5] # Special Defense
|
||||
|
||||
while basestatsum > $game_variables[53] || basestatsum < $game_variables[87]
|
||||
species = rand(PBSpecies.maxValue - 1) + 1
|
||||
basestatsum = $pkmn_dex[species][5][0] # HP
|
||||
basestatsum += $pkmn_dex[species][5][1] # Attack
|
||||
basestatsum += $pkmn_dex[species][5][2] # Defense
|
||||
basestatsum += $pkmn_dex[species][5][3] # Speed
|
||||
basestatsum += $pkmn_dex[species][5][4] # Special Attack
|
||||
basestatsum += $pkmn_dex[species][5][5] # Special Defense
|
||||
end
|
||||
#Kernel.pbMessage(_INTL("total = {1}, {2}",basestatsum, PBSpecies.getName(species)))
|
||||
else
|
||||
if $game_switches[841]
|
||||
species = getRandomCustomSprite()
|
||||
else
|
||||
species = rand(PBSpecies.maxValue - 1) + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
randomized_init(species, level, player, withMoves)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def getRandomCustomSprite()
|
||||
filesList = Dir["./Graphics/CustomBattlers/*"]
|
||||
i = rand(filesList.length - 1)
|
||||
path = filesList[i]
|
||||
file = File.basename(path, ".*")
|
||||
splitPoke = file.split(".")
|
||||
head = splitPoke[0].to_i
|
||||
body = splitPoke[1].to_i
|
||||
return (body * NB_POKEMON) + head
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
##########################
|
||||
# Trainer house shit
|
||||
#########################
|
||||
#Battleformat : 0 = single
|
||||
# 1 = double
|
||||
def Kernel.pbTrainerHouse(bstMin,bstMax,level,battleformat)
|
||||
return false if !validateLevel()
|
||||
#activate random Pokemon
|
||||
$game_switches[991] = true
|
||||
|
||||
#Set game variables
|
||||
$game_variables[87]=bstMin
|
||||
$game_variabes[53]=bstMax
|
||||
|
||||
#initialize variables
|
||||
trainerHouse=true
|
||||
currentStreak=0
|
||||
backupTeamLevels()
|
||||
doubleBattle = battleformat == 1 ? true : false
|
||||
|
||||
|
||||
while trainerHouse
|
||||
currentStreak += 1
|
||||
TrainerHouseVictory(currentStreak) if TrainerHouseBattle(level)
|
||||
end
|
||||
end
|
||||
|
||||
def backupTeamLevels()
|
||||
$game_variables[91] = $Trainer.pokemonParty[0].level
|
||||
$game_variables[92] = $Trainer.pokemonParty[1].level
|
||||
$game_variables[93] = $Trainer.pokemonParty[2].level
|
||||
end
|
||||
|
||||
#choisir le trainer a combattre en fonction du level
|
||||
def TrainerHouseBattle(level,battleformat)
|
||||
victoryMessage = getVictoryMessage()
|
||||
getTrainerHouseBattle(rand(1),level,battleformat)
|
||||
return
|
||||
end
|
||||
|
||||
#initialiser background & musique pour le combat
|
||||
def setBattleConstants()
|
||||
$PokemonGlobal.nextBattleBGM="SubwayTrainerBattle"
|
||||
$PokemonGlobal.nextBattleBack="IndoorC"
|
||||
end
|
||||
|
||||
#Ajouter les TP après un victoire
|
||||
def TrainerHouseVictory(currentStreak)
|
||||
tp_won = currentStreak + 1
|
||||
$game_variables[49] = tp_won
|
||||
end
|
||||
|
||||
#Valider si le niveau est un challenge possible
|
||||
def validateLevel(level)
|
||||
validLevels=[25,50,100]
|
||||
return validLevels.include?(level)
|
||||
end
|
||||
|
||||
def getVictoryMessage()
|
||||
return "You're good!"
|
||||
end
|
||||
|
||||
def getTrainerHouseBattle(IsMale,level,single=true)
|
||||
victoryMessage = getVictoryMessage()
|
||||
|
||||
LV25MALE_SINGLE = pbTrainerBattle(PBTrainers::COOLTRAINER_M2,"Matthew",_I(victoryMessage),false,0,true)
|
||||
LV25FEMALE_SINGLE = pbTrainerBattle(PBTrainers::COOLTRAINER_F2,"Jessica",_I(victoryMessage),false,0,true)
|
||||
LV25MALE_DOUBLE = pbTrainerBattle(PBTrainers::COOLTRAINER_M2,"Alex",_I(victoryMessage),false,0,true)
|
||||
LV25FEMALE_DOUBLE = pbTrainerBattle(PBTrainers::COOLTRAINER_F2,"Laurie",_I(victoryMessage),false,0,true)
|
||||
|
||||
LV50MALE_SINGLE = pbTrainerBattle(PBTrainers::COOLTRAINER_M2,"Alberto",_I(victoryMessage),false,0,true)
|
||||
LV50FEMALE_SINGLE = pbTrainerBattle(PBTrainers::COOLTRAINER_F2,"Skyler",_I(victoryMessage),true,0,true)
|
||||
LV50MALE_DOUBLE = pbTrainerBattle(PBTrainers::COOLTRAINER_M2,"Patrick",_I(victoryMessage),false,0,true)
|
||||
LV50FEMALE_DOUBLE = pbTrainerBattle(PBTrainers::COOLTRAINER_F2,"Heather",_I(victoryMessage),true,0,true)
|
||||
|
||||
LV100MALE_SINGLE = pbTrainerBattle(PBTrainers::COOLTRAINER_M2,"Joe",_I(victoryMessage),false,0,true)
|
||||
LV100FEMALE_SINGLE = pbTrainerBattle(PBTrainers::COOLTRAINER_F2,"Melissa",_I(victoryMessage),true,0,true)
|
||||
LV100MALE_DOUBLE = pbTrainerBattle(PBTrainers::COOLTRAINER_M2,"Stephen",_I(victoryMessage),false,0,true)
|
||||
LV100FEMALE_DOUBLE = pbTrainerBattle(PBTrainers::COOLTRAINER_F2,"Kim",_I(victoryMessage),true,0,true)
|
||||
|
||||
|
||||
|
||||
if single #SINGLE
|
||||
if level == 25
|
||||
return LV25MALE_SINGLE if IsMale == 1
|
||||
return LV25FEMALE_SINGLE
|
||||
elsif level == 50
|
||||
return LV50MALE_SINGLE if IsMale == 1
|
||||
return LV50FEMALE_SINGLE
|
||||
else
|
||||
return LV100MALE_SINGLE if IsMale == 1
|
||||
return LV100FEMALE_SINGLE
|
||||
end
|
||||
else #DOUBLE
|
||||
if level == 25
|
||||
return LV25MALE_DOUBLE if IsMale == 1
|
||||
return LV25FEMALE_DOUBLE
|
||||
elsif level == 50
|
||||
return LV50MALE_DOUBLE if IsMale == 1
|
||||
return LV50FEMALE_DOUBLE
|
||||
else
|
||||
return LV100MALE_DOUBLE if IsMale == 1
|
||||
return LV100FEMALE_DOUBLE
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
=end
|
||||
235
Data/Scripts/025-Randomizer/RandomizerSettings.rb
Normal file
235
Data/Scripts/025-Randomizer/RandomizerSettings.rb
Normal file
@@ -0,0 +1,235 @@
|
||||
module OptionTypes
|
||||
WILD_POKE = 0
|
||||
TRAINER_POKE = 1
|
||||
end
|
||||
|
||||
class RandomizerOptionsScene < PokemonOption_Scene
|
||||
RANDOM_WILD = 778
|
||||
RANDOM_TRAINERS = 987
|
||||
RANDOM_STARTERS = 954
|
||||
RANDOM_ITEMS = 958
|
||||
RANDOM_TMS = 959
|
||||
|
||||
|
||||
def initialize
|
||||
super
|
||||
@openTrainerOptions = false
|
||||
@openWildOptions = false
|
||||
|
||||
end
|
||||
|
||||
def pbStartScene
|
||||
super
|
||||
@changedColor = true
|
||||
@sprites["title"]=Window_UnformattedTextPokemon.newWithSize(
|
||||
_INTL("Randomizer settings"),0,0,Graphics.width,64,@viewport)
|
||||
@sprites["textbox"].text=_INTL("Set the randomizer settings")
|
||||
pbFadeInAndShow(@sprites) { pbUpdate }
|
||||
end
|
||||
|
||||
def pbGetOptionsIngame()
|
||||
options = [
|
||||
EnumOption.new(_INTL("Starters"), [_INTL("On"), _INTL("Off")],
|
||||
proc { $game_switches[RANDOM_STARTERS] ? 0 : 1 },
|
||||
proc { |value|
|
||||
$game_switches[RANDOM_STARTERS] = value == 0
|
||||
}
|
||||
),
|
||||
|
||||
EnumOption.new(_INTL("Trainers"), [_INTL("On"), _INTL("Off")],
|
||||
proc { $game_switches[RANDOM_TRAINERS] ? 0 : 1 },
|
||||
proc { |value|
|
||||
if !$game_switches[RANDOM_TRAINERS] && value == 0
|
||||
@openTrainerOptions = true
|
||||
openTrainerOptionsMenu()
|
||||
end
|
||||
$game_switches[RANDOM_TRAINERS] = value == 0
|
||||
}
|
||||
),
|
||||
|
||||
EnumOption.new(_INTL("Wild Pokémon"), [_INTL("On"), _INTL("Off")],
|
||||
proc {
|
||||
$game_switches[RANDOM_WILD] ? 0 : 1
|
||||
},
|
||||
proc { |value|
|
||||
if !$game_switches[RANDOM_WILD] && value == 0
|
||||
@openWildOptions = true
|
||||
openWildPokemonOptionsMenu()
|
||||
end
|
||||
$game_switches[RANDOM_WILD] = value == 0
|
||||
}
|
||||
),
|
||||
EnumOption.new(_INTL("Items"), [_INTL("On"), _INTL("Off")],
|
||||
proc { $game_switches[RANDOM_ITEMS] ? 0 : 1 },
|
||||
proc { |value|
|
||||
$game_switches[RANDOM_ITEMS] = value == 0
|
||||
}
|
||||
),
|
||||
EnumOption.new(_INTL("TMs"), [_INTL("On"), _INTL("Off")],
|
||||
proc { $game_switches[RANDOM_TMS] ? 0 : 1 },
|
||||
proc { |value|
|
||||
$game_switches[RANDOM_TMS] = value == 0
|
||||
}
|
||||
),
|
||||
]
|
||||
return options
|
||||
end
|
||||
|
||||
def openTrainerOptionsMenu()
|
||||
return if !@openTrainerOptions
|
||||
scene = RandomizerTrainerOptionsScene.new
|
||||
screen = PokemonOption.new(scene)
|
||||
pbFadeOutIn(99999) {
|
||||
screen.pbStartScreen
|
||||
pbUpdateSceneMap
|
||||
}
|
||||
@openTrainerOptions = false
|
||||
end
|
||||
|
||||
def openWildPokemonOptionsMenu()
|
||||
return if !@openWildOptions
|
||||
scene = RandomizerWildPokemonOptionsScene.new
|
||||
screen = PokemonOption.new(scene)
|
||||
pbFadeOutIn(99999) {
|
||||
screen.pbStartScreen
|
||||
pbUpdateSceneMap
|
||||
}
|
||||
@openWildOptions = false
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
class RandomizerTrainerOptionsScene < PokemonOption_Scene
|
||||
RANDOM_TEAMS_CUSTOM_SPRITES = 600
|
||||
RANDOM_HELD_ITEMS = 843
|
||||
RANDOM_GYM_TYPES = 921
|
||||
|
||||
def initialize
|
||||
@changedColor = false
|
||||
end
|
||||
|
||||
def pbStartScene
|
||||
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: Trainers"),0,0,Graphics.width,64,@viewport)
|
||||
@sprites["textbox"].text=_INTL("Set the randomizer settings for trainers")
|
||||
|
||||
|
||||
pbFadeInAndShow(@sprites) { pbUpdate }
|
||||
end
|
||||
|
||||
def pbFadeInAndShow(sprites, visiblesprites = nil)
|
||||
return if !@changedColor
|
||||
super
|
||||
end
|
||||
|
||||
def pbGetOptionsIngame()
|
||||
options = [
|
||||
EnumOption.new(_INTL("Custom Sprites only"), [_INTL("On"), _INTL("Off")],
|
||||
proc { $game_switches[RANDOM_TEAMS_CUSTOM_SPRITES] ? 0 : 1 },
|
||||
proc { |value|
|
||||
$game_switches[RANDOM_TEAMS_CUSTOM_SPRITES] = value == 0
|
||||
}
|
||||
),
|
||||
EnumOption.new(_INTL("Trainer Held items"), [_INTL("On"), _INTL("Off")],
|
||||
proc { $game_switches[RANDOM_HELD_ITEMS] ? 0 : 1 },
|
||||
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
|
||||
end
|
||||
|
||||
|
||||
class RandomizerWildPokemonOptionsScene < PokemonOption_Scene
|
||||
RANDOM_WILD_AREA = 777
|
||||
RANDOM_WILD_GLOBAL = 956
|
||||
RANDOM_STATIC = 955
|
||||
REGULAR_TO_FUSIONS = 953
|
||||
GIFT_POKEMON = 780
|
||||
|
||||
def initialize
|
||||
@changedColor = false
|
||||
end
|
||||
|
||||
def pbStartScene
|
||||
super
|
||||
@sprites["option"].nameBaseColor = Color.new(70, 170, 40)
|
||||
@sprites["option"].nameShadowColor = Color.new(40, 100, 20)
|
||||
@changedColor = true
|
||||
for i in 0...@PokemonOptions.length
|
||||
@sprites["option"][i] = (@PokemonOptions[i].get || 0)
|
||||
end
|
||||
@sprites["title"]=Window_UnformattedTextPokemon.newWithSize(
|
||||
_INTL("Randomizer settings: Wild Pokémon"),0,0,Graphics.width,64,@viewport)
|
||||
@sprites["textbox"].text=_INTL("Set the randomizer settings for wild Pokémon")
|
||||
pbFadeInAndShow(@sprites) { pbUpdate }
|
||||
end
|
||||
|
||||
def pbFadeInAndShow(sprites, visiblesprites = nil)
|
||||
return if !@changedColor
|
||||
super
|
||||
end
|
||||
|
||||
def pbGetOptionsIngame()
|
||||
options = [
|
||||
EnumOption.new(_INTL("Type"), [_INTL("Global"), _INTL("Area")],
|
||||
proc {
|
||||
if $game_switches[RANDOM_WILD_AREA]
|
||||
1
|
||||
else
|
||||
0
|
||||
end
|
||||
},
|
||||
proc { |value|
|
||||
if value == 0
|
||||
$game_switches[RANDOM_WILD_GLOBAL] = true
|
||||
$game_switches[RANDOM_WILD_AREA] = false
|
||||
else
|
||||
value == 1
|
||||
$game_switches[RANDOM_WILD_GLOBAL] = false
|
||||
$game_switches[RANDOM_WILD_AREA] = true
|
||||
end
|
||||
}
|
||||
),
|
||||
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")],
|
||||
proc { $game_switches[GIFT_POKEMON] ? 0 : 1 },
|
||||
proc { |value|
|
||||
$game_switches[GIFT_POKEMON] = value == 0
|
||||
}
|
||||
),
|
||||
|
||||
EnumOption.new(_INTL("Fuse everything"), [_INTL("On"), _INTL("Off")],
|
||||
proc { $game_switches[REGULAR_TO_FUSIONS] ? 0 : 1 },
|
||||
proc { |value|
|
||||
$game_switches[REGULAR_TO_FUSIONS] = value == 0
|
||||
}
|
||||
),
|
||||
]
|
||||
return options
|
||||
end
|
||||
end
|
||||
38
Data/Scripts/025-Randomizer/RandomizerUtils.rb
Normal file
38
Data/Scripts/025-Randomizer/RandomizerUtils.rb
Normal file
@@ -0,0 +1,38 @@
|
||||
def pbGetRandomItem(item)
|
||||
#keyItem ou HM -> on randomize pas
|
||||
return item if $ItemData[item][ITEMTYPE] == 6 || $ItemData[item][ITEMUSE] == 4
|
||||
return item if isConst?(item, PBItems, :CELLBATTERY)
|
||||
return item if isConst?(item, PBItems, :MAGNETSTONE)
|
||||
|
||||
#TM
|
||||
if ($ItemData[item][ITEMUSE] == 3)
|
||||
return $game_switches[959] ? pbGetRandomTM() : item
|
||||
end
|
||||
#item normal
|
||||
return item if !$game_switches[958]
|
||||
#berries
|
||||
return pbGetRandomBerry() if $ItemData[item][ITEMTYPE] == 5
|
||||
newItem = rand(PBItems.maxValue)
|
||||
#on veut pas de tm ou keyitem
|
||||
while ($ItemData[newItem][ITEMUSE] == 3 || $ItemData[newItem][ITEMUSE] == 4 || $ItemData[newItem][ITEMTYPE] == 6)
|
||||
newItem = rand(PBItems.maxValue)
|
||||
end
|
||||
return newItem
|
||||
end
|
||||
|
||||
def pbGetRandomBerry()
|
||||
newItem = rand(PBItems.maxValue)
|
||||
while (!($ItemData[newItem][ITEMTYPE] == 5))
|
||||
newItem = rand(PBItems.maxValue)
|
||||
end
|
||||
return newItem
|
||||
end
|
||||
|
||||
def pbGetRandomTM()
|
||||
newItem = rand(PBItems.maxValue)
|
||||
while (!($ItemData[newItem][ITEMUSE] == 3)) # || $ItemData[newItem][ITEMUSE]==4))
|
||||
newItem = rand(PBItems.maxValue)
|
||||
end
|
||||
return newItem
|
||||
end
|
||||
|
||||
164
Data/Scripts/025-Randomizer/randomizer - encounters.rb
Normal file
164
Data/Scripts/025-Randomizer/randomizer - encounters.rb
Normal file
@@ -0,0 +1,164 @@
|
||||
##### by route
|
||||
#
|
||||
# Randomize encounter by routes
|
||||
# Script by Frogman
|
||||
#
|
||||
|
||||
def Kernel.randomizeWildPokemonByRoute()
|
||||
bstRange = $game_variables[197]
|
||||
randomizeToFusions = $game_switches[953]
|
||||
$game_switches[829] = 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 = map[1][1]
|
||||
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.puts data.inspect
|
||||
|
||||
|
||||
def displayProgress(current,total,bst)
|
||||
return if bst >= 100
|
||||
return if bst >= 20 && current % 10 != 0
|
||||
Kernel.pbMessageNoSound(_INTL("\\ts[]Generating encounters file...\\n Map {1}/{2}\\^",current,total))
|
||||
end
|
||||
|
||||
|
||||
class PokemonEncounters
|
||||
|
||||
def setup(mapID)
|
||||
@density=nil
|
||||
@stepcount=0
|
||||
@enctypes=[]
|
||||
begin
|
||||
|
||||
data=load_data(getEncountersFilePath())
|
||||
if data.is_a?(Hash) && data[mapID]
|
||||
@density=data[mapID][0]
|
||||
@enctypes=data[mapID][1]
|
||||
else
|
||||
@density=nil
|
||||
@enctypes=[]
|
||||
end
|
||||
rescue
|
||||
@density=nil
|
||||
@enctypes=[]
|
||||
end
|
||||
end
|
||||
|
||||
def getEncountersFilePath()
|
||||
if $game_switches[777] && $game_switches[778] #[777] = random-by-area [778] = wildpokerandom activated
|
||||
return "Data/encounters_randomized.dat"
|
||||
else
|
||||
return "Data/encounters.dat"
|
||||
end
|
||||
end
|
||||
|
||||
def pbMapEncounter(mapID,enctype)
|
||||
if enctype<0 || enctype>EncounterTypes::EnctypeChances.length
|
||||
raise ArgumentError.new(_INTL("Encounter type out of range"))
|
||||
end
|
||||
data=load_data(getEncountersFilePath())
|
||||
if data.is_a?(Hash) && data[mapID]
|
||||
enctypes=data[mapID][1]
|
||||
else
|
||||
return nil
|
||||
end
|
||||
return nil if enctypes[enctype]==nil
|
||||
chances=EncounterTypes::EnctypeChances[enctype]
|
||||
chancetotal=0
|
||||
chances.each {|a| chancetotal+=a}
|
||||
rnd=rand(chancetotal)
|
||||
chosenpkmn=0
|
||||
chance=0
|
||||
for i in 0...chances.length
|
||||
chance+=chances[i]
|
||||
if rnd<chance
|
||||
chosenpkmn=i
|
||||
break
|
||||
end
|
||||
end
|
||||
encounter=enctypes[enctype][chosenpkmn]
|
||||
level=encounter[1]+rand(1+encounter[2]-encounter[1])
|
||||
return [encounter[0],level]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
def getRandomPokemon(originalPokemon,bstRange,maxDexNumber)
|
||||
originalBst = getBaseStatsTotal(originalPokemon)
|
||||
bstMin = originalBst-bstRange
|
||||
bstMax = originalBst+bstRange
|
||||
|
||||
foundAPokemon = false
|
||||
while ! foundAPokemon
|
||||
newPoke = rand(maxDexNumber-1)+1
|
||||
newPokeBST = getBaseStatsTotal(newPoke)
|
||||
if newPokeBST >= bstMin && newPokeBST <= bstMax
|
||||
foundAPokemon = true
|
||||
end
|
||||
end
|
||||
return newPoke
|
||||
end
|
||||
|
||||
def getBaseStatsTotal(species)
|
||||
baseStats=$pkmn_dex[species][5]
|
||||
baseStat_temp = 0
|
||||
for i in 0...baseStats.length
|
||||
baseStat_temp+=baseStats[i]
|
||||
end
|
||||
return (baseStat_temp/range).floor
|
||||
end
|
||||
|
||||
|
||||
######################################################
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
693
Data/Scripts/025-Randomizer/randomizer gym leader edit.rb
Normal file
693
Data/Scripts/025-Randomizer/randomizer gym leader edit.rb
Normal file
@@ -0,0 +1,693 @@
|
||||
#A l'entrée d'un gym: mettre $game_variables[113] = au numéro du gym
|
||||
#pewter = 0, ceruean = 1 etc.
|
||||
#Le remettre a -1 à la sortie du gym
|
||||
#Le mettre a -1 au début du jeu
|
||||
#
|
||||
#Aussi des trucs modifiés dans le dude qui donne les freshwater au début
|
||||
#Faudrait aussi s'assurer que il dise pas n'importe quoi en pas randomized
|
||||
#
|
||||
#Voir cerulean gym pour implantation
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#initialiser la RANDOM_TYPE_ARRAY au début du jeu en runnant Kernel.initRandomTypeArray(8)
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
##################################################################
|
||||
# TODO:
|
||||
#
|
||||
#
|
||||
#
|
||||
###
|
||||
###############################################################
|
||||
#
|
||||
|
||||
|
||||
|
||||
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]
|
||||
#$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
|
||||
end
|
||||
|
||||
|
||||
def setRivalStarter(starter1, starter2, starter3, choice)
|
||||
starters=[starter1,starter2,starter3]
|
||||
starters.delete_at(choice)
|
||||
if starters[0] > NB_POKEMON || starters[1] > NB_POKEMON
|
||||
rivalStarter = starters[0]
|
||||
else
|
||||
rivalStarter = starters[0]*NB_POKEMON+starters[1]
|
||||
end
|
||||
pbSet(250,rivalStarter)
|
||||
$game_switches[840] = true
|
||||
end
|
||||
|
||||
def setRivalStarterSpecific(rivalStarter)
|
||||
pbSet(250,rivalStarter)
|
||||
$game_switches[840] = true
|
||||
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
|
||||
newspecies = rand(PBSpecies.maxValue - 1) + 1
|
||||
newBST = getBaseStats(newspecies)
|
||||
originalBST = getBaseStats(m.species)
|
||||
while !gymLeaderOk(newspecies) || bstOk(newspecies,m.species,$game_variables[197])
|
||||
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)
|
||||
|
||||
end
|
||||
|
||||
return party
|
||||
end
|
||||
|
||||
def randomizedRivalFirstBattle(party)
|
||||
return party if $game_switches[953] #full random
|
||||
starter1 = $PokemonGlobal.psuedoBSTHash[1]
|
||||
starter2 = $PokemonGlobal.psuedoBSTHash[4]
|
||||
starter3 = $PokemonGlobal.psuedoBSTHash[7]
|
||||
playerChoice = $game_variables[7]
|
||||
|
||||
for m in party
|
||||
next if !m
|
||||
case playerChoice
|
||||
when 0 then newspecies = starter2*NB_POKEMON+starter3
|
||||
when 1 then newspecies = starter1*NB_POKEMON+starter3
|
||||
when 2 then newspecies = starter1*NB_POKEMON+starter2
|
||||
else
|
||||
end
|
||||
m.species= newspecies
|
||||
m.name = PBSpecies.getName(newspecies)
|
||||
m.resetMoves
|
||||
m.calcStats
|
||||
end
|
||||
return party
|
||||
end
|
||||
end
|
||||
#######
|
||||
# end of class
|
||||
######
|
||||
|
||||
|
||||
####methodes utilitaires
|
||||
|
||||
def getBaseStats(species)
|
||||
basestatsum = $pkmn_dex[species][5][0] # HP
|
||||
basestatsum +=$pkmn_dex[species][5][1] # Attack
|
||||
basestatsum +=$pkmn_dex[species][5][2] # Defense
|
||||
basestatsum +=$pkmn_dex[species][5][3] # Speed
|
||||
basestatsum +=$pkmn_dex[species][5][4] # Special Attack
|
||||
basestatsum +=$pkmn_dex[species][5][5] # Special Defense
|
||||
return basestatsum
|
||||
end
|
||||
|
||||
|
||||
def bstOk(newspecies,oldPokemonSpecies,bst_range=50)
|
||||
newBST = getBaseStats(newspecies)
|
||||
originalBST = getBaseStats(oldPokemonSpecies)
|
||||
return newBST < originalBST-bst_range || newBST > originalBST+bst_range
|
||||
end
|
||||
|
||||
def gymLeaderOk(newspecies)
|
||||
return true if $game_variables[152] == -1 #not in a gym
|
||||
leaderType=getLeaderType()
|
||||
if leaderType == nil
|
||||
return true
|
||||
else
|
||||
return true if SpeciesHasType?(leaderType,newspecies)
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def getLeaderType()
|
||||
currentGym = $game_variables[152]
|
||||
if currentGym > $game_variables[151].length
|
||||
return nil
|
||||
else
|
||||
typeIndex = $game_variables[151][currentGym]
|
||||
type = PBTypes.getName(typeIndex)
|
||||
end
|
||||
return typeIndex
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
##Version alternatives de fonctions pour fonctionner avec numero de species
|
||||
def SpeciesHasType?(type,species)
|
||||
if type.is_a?(String) || type.is_a?(Symbol)
|
||||
return isConst?(getSpeciesType1(species),PBTypes,type) || isConst?(getSpeciesType2(species),PBTypes,type)
|
||||
else
|
||||
return getSpeciesType1(species)==type || getSpeciesType2(species)==type
|
||||
end
|
||||
end
|
||||
|
||||
# Returns this Pokémon's first type.
|
||||
def getSpeciesType1(species)
|
||||
return $pkmn_dex[species][3]
|
||||
end
|
||||
|
||||
# Returns this Pokémon's second type.
|
||||
def getSpeciesType2(species)
|
||||
return $pkmn_dex[species][4]
|
||||
end
|
||||
|
||||
|
||||
|
||||
############
|
||||
|
||||
|
||||
|
||||
#summarize random options
|
||||
def Kernel.sumRandomOptions()
|
||||
answer = $game_switches[954] ? "On" : "Off"
|
||||
stringOptions = "\nStarters: " << answer
|
||||
|
||||
answer = $game_switches[778] ? "On" : "Off"
|
||||
stringOptions << "\nWild Pokémon: " << answer << " "
|
||||
if $game_switches[777]
|
||||
stringOptions << "(Area)"
|
||||
else
|
||||
stringOptions << "(Global)"
|
||||
end
|
||||
|
||||
answer = $game_switches[987] ? "On" : "Off"
|
||||
stringOptions << "\nTrainers: " << answer
|
||||
|
||||
answer = $game_switches[955] ? "On" : "Off"
|
||||
stringOptions << "\nStatic encounters: " << answer
|
||||
|
||||
answer = $game_switches[780] ? "On" : "Off"
|
||||
stringOptions << "\nGift Pokémon: " << answer
|
||||
|
||||
answer = $game_switches[958] ? "On" : "Off"
|
||||
stringOptions << "\nItems: " << answer
|
||||
|
||||
answer = $game_switches[959] ? "On" : "Off"
|
||||
stringOptions << "\nTMs: " << answer
|
||||
|
||||
|
||||
return stringOptions
|
||||
end
|
||||
|
||||
|
||||
def countVisitedMaps
|
||||
count = 0
|
||||
for i in 0..$PokemonGlobal.visitedMaps.length
|
||||
count +=1 if $PokemonGlobal.visitedMaps[i]
|
||||
end
|
||||
return count
|
||||
end
|
||||
|
||||
def Kernel.sumGameStats()
|
||||
stringStats = ""
|
||||
|
||||
|
||||
|
||||
stringStats << "Seen " << $Trainer.pokedexSeen.to_s << " Pokémon"
|
||||
stringStats << "\nCaught " << $Trainer.pokedexOwned.to_s << " Pokémon"
|
||||
|
||||
|
||||
stringStats << "\nBeaten the Elite Four " << $game_variables[174].to_s << " times"
|
||||
stringStats << "\nFused " << $game_variables[126].to_s << " Pokémon"
|
||||
|
||||
|
||||
stringStats << "\nRematched " << $game_variables[162].to_s << " Gym Leaders"
|
||||
stringStats << "\nTook " << $PokemonGlobal.stepcount.to_s << " steps"
|
||||
stringStats << "\nVisited " << countVisitedMaps.to_s << " different areas"
|
||||
|
||||
if $game_switches[910]
|
||||
stringStats << "\nMade " << $game_variables[164].to_s << " Wonder Trades"
|
||||
end
|
||||
|
||||
stringStats << "\nTipped $" << $game_variables[100].to_s << " to clowns"
|
||||
stringStats << "\nDestroyed " << $game_variables[163].to_s << " sandcastles"
|
||||
|
||||
if $game_variables[43] > 0 || $game_variables[44] >0
|
||||
stringStats << "\nWon $" << $game_variables[43].to_s << " against gamblers"
|
||||
stringStats << "\nLost $" << $game_variables[44].to_s << " against gamblers"
|
||||
end
|
||||
stringStats << "\nSpent $" << $game_variables[225].to_s << " at hotels"
|
||||
|
||||
|
||||
|
||||
stringStats << "\nAccepted " << $game_variables[96].to_s << " quests"
|
||||
stringStats << "\nCompleted " << $game_variables[98].to_s << " quests"
|
||||
stringStats << "\nDiscovered " << $game_variables[193].to_s << " secrets"
|
||||
|
||||
if $game_switches[912]
|
||||
stringStats << "\nDied " << $game_variables[191].to_s << " times in Pikachu's adventure"
|
||||
if $game_variables[193] >= 1
|
||||
stringStats << "\nCollected " << $game_variables[194].to_s << " coins with Pikachu"
|
||||
end
|
||||
end
|
||||
return stringStats
|
||||
end
|
||||
|
||||
|
||||
def Kernel.pbRandomizeTM()
|
||||
tmList = []
|
||||
for item in $itemData
|
||||
#machine=$ItemData[item][ITEMMACHINE]
|
||||
#movename=PBMoves.getName(machine)
|
||||
#Kernel.pbMessage(_INTL("It contained {1}.\1",item))
|
||||
|
||||
tmList << item if pbIsHiddenMachine?(item)
|
||||
end
|
||||
end
|
||||
|
||||
def getNewSpecies(oldSpecies,bst_range=50, ignoreRivalPlaceholder = false, maxDexNumber = PBSpecies.maxValue )
|
||||
return oldSpecies if (oldSpecies == RIVAL_STARTER_PLACEHOLDER_SPECIES && !ignoreRivalPlaceholder)
|
||||
return oldSpecies if oldSpecies >= NUM_ZAPMOLCUNO
|
||||
newspecies = rand(maxDexNumber - 1) + 1
|
||||
newBST = Kernel.getBaseStats(newspecies)
|
||||
originalBST = Kernel.getBaseStats(oldSpecies)
|
||||
while bstOk(newspecies,oldSpecies,bst_range)
|
||||
newspecies = rand(maxDexNumber - 1) + 1
|
||||
newBST = Kernel.getBaseStats(newspecies)
|
||||
end
|
||||
return newspecies
|
||||
end
|
||||
|
||||
|
||||
def getNewCustomSpecies(oldSpecies,customSpeciesList,bst_range=50, ignoreRivalPlaceholder = false)
|
||||
return oldSpecies if (oldSpecies == RIVAL_STARTER_PLACEHOLDER_SPECIES && !ignoreRivalPlaceholder)
|
||||
return oldSpecies if oldSpecies >= NUM_ZAPMOLCUNO
|
||||
i = rand(customSpeciesList.length - 1) + 1
|
||||
newspecies = customSpeciesList[i]
|
||||
|
||||
newBST = Kernel.getBaseStats(newspecies)
|
||||
originalBST = Kernel.getBaseStats(oldSpecies)
|
||||
while bstOk(newspecies,oldSpecies,bst_range)
|
||||
i = rand(customSpeciesList.length - 1)#+1
|
||||
newspecies = customSpeciesList[i]
|
||||
newBST = Kernel.getBaseStats(newspecies)
|
||||
end
|
||||
return newspecies
|
||||
end
|
||||
|
||||
|
||||
def playShuffleSE(i)
|
||||
if i % 40 == 0 || i == 0
|
||||
pbSEPlay("Charm",60)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
def Kernel.pbShuffleTrainers(bst_range = 50)
|
||||
randomTrainersHash = Hash.new
|
||||
|
||||
trainers=load_data("Data/trainers.dat")
|
||||
i=0
|
||||
for trainer in trainers
|
||||
for poke in trainer[3]
|
||||
poke[TPSPECIES]=getNewSpecies(poke[TPSPECIES])
|
||||
end
|
||||
randomTrainersHash[i] = (trainer)
|
||||
playShuffleSE(i)
|
||||
i += 1
|
||||
if i % 2 == 0
|
||||
n = (i.to_f/trainers.length)*100
|
||||
Kernel.pbMessageNoSound(_INTL("\\ts[]Shuffling trainers...\\n {1}%\\^",sprintf('%.2f', n),PBSpecies.maxValue))
|
||||
end
|
||||
#Kernel.pbMessage(_INTL("pushing trainer {1}: {2} ",i,trainer))
|
||||
end
|
||||
$PokemonGlobal.randomTrainersHash = randomTrainersHash
|
||||
end
|
||||
|
||||
|
||||
def Kernel.pbShuffleTrainersCustom()(bst_range = 50)
|
||||
randomTrainersHash = Hash.new
|
||||
|
||||
Kernel.pbMessage(_INTL("Parsing custom sprites folder"))
|
||||
customsList = getCustomSpeciesList()
|
||||
Kernel.pbMessage(_INTL("{1} Pokémon found",customsList.length.to_s))
|
||||
|
||||
if customsList.length == 0
|
||||
Kernel.pbMessage(_INTL("To use custom sprites, please place correctly named sprites in the /CustomBattlers folder. See readMe.txt for more information"))
|
||||
Kernel.pbMessage(_INTL("Trainer Pokémon will include auto-generated sprites."))
|
||||
return Kernel.pbShuffleTrainers(bst_range)
|
||||
elsif customsList.length < 200
|
||||
if Kernel.pbConfirmMessage(_INTL("Too few custom sprites were found. This will result in a very low Pokémon variety for trainers. Continue anyway?"))
|
||||
bst_range=999
|
||||
else
|
||||
Kernel.pbMessage(_INTL("Trainer Pokémon will include auto-generated sprites."))
|
||||
return Kernel.pbShuffleTrainers(bst_range)
|
||||
end
|
||||
end
|
||||
|
||||
##use regular shuffle if not enough sprites
|
||||
|
||||
|
||||
trainers=load_data("Data/trainers.dat")
|
||||
i=0
|
||||
for trainer in trainers
|
||||
for poke in trainer[3]
|
||||
poke[TPSPECIES]=getNewCustomSpecies(poke[TPSPECIES],customsList)
|
||||
end
|
||||
randomTrainersHash[i] = (trainer)
|
||||
playShuffleSE(i)
|
||||
i += 1
|
||||
if i % 2 == 0
|
||||
n = (i.to_f/trainers.length)*100
|
||||
Kernel.pbMessageNoSound(_INTL("\\ts[]Shuffling trainers (custom sprites only)...\\n {1}%\\^",sprintf('%.2f', n),PBSpecies.maxValue))
|
||||
end
|
||||
#Kernel.pbMessage(_INTL("pushing trainer {1}: {2} ",i,trainer))
|
||||
end
|
||||
$PokemonGlobal.randomTrainersHash = randomTrainersHash
|
||||
end
|
||||
|
||||
|
||||
#def getRandomCustomSprite()
|
||||
# filesList = Dir["./Graphics/CustomBattlers/*"]
|
||||
# i = rand(filesList.length-1)
|
||||
# path = filesList[i]
|
||||
# file = File.basename(path, ".*")
|
||||
# splitPoke = file.split(".")
|
||||
# head = splitPoke[0].to_i
|
||||
# body = splitPoke[1].to_i
|
||||
# return (body*NB_POKEMON)+head
|
||||
#end
|
||||
|
||||
|
||||
def getCustomSpeciesList()
|
||||
filesList = Dir["./Graphics/CustomBattlers/*"]
|
||||
speciesList = []
|
||||
maxDexNumber = (NB_POKEMON * NB_POKEMON) + NB_POKEMON
|
||||
maxVal = filesList.length-1
|
||||
for i in 0..maxVal
|
||||
path = filesList[i]
|
||||
file = File.basename(path, ".*")
|
||||
splitPoke = file.split(".")
|
||||
head = splitPoke[0].to_i
|
||||
body = splitPoke[1].to_i
|
||||
fused = (body*NB_POKEMON)+head
|
||||
if fused <= maxDexNumber && fused > 0
|
||||
speciesList << fused
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
return speciesList
|
||||
end
|
||||
|
||||
|
||||
def Kernel.getBaseStats(species)
|
||||
if $pkmn_dex[species] == nil
|
||||
print species
|
||||
end
|
||||
|
||||
basestatsum = $pkmn_dex[species][5][0] # HP
|
||||
basestatsum +=$pkmn_dex[species][5][1] # Attack
|
||||
basestatsum +=$pkmn_dex[species][5][2] # Defense
|
||||
basestatsum +=$pkmn_dex[species][5][3] # Speed
|
||||
basestatsum +=$pkmn_dex[species][5][4] # Special Attack
|
||||
basestatsum +=$pkmn_dex[species][5][5] # Special Defense
|
||||
return basestatsum
|
||||
end
|
||||
|
||||
|
||||
def Kernel.gymLeaderRematchHint()
|
||||
hints = [
|
||||
"I heard that Brock has a huge interest in Pokémon fossils. He donated a lot of fossils he excavated to the Pewter City Museum.",
|
||||
"Misty is a pro at swimming. I heard she trains every single morning.",
|
||||
"Did you know that Lt. Surge used the magnetic fields generated by his Pokémon to navigate his plane back when he was in the army. He still loves a good magnetic field.",
|
||||
"Erika is a lover of nature. She loves going to parks to relax during the day.",
|
||||
"Koga has been seen leaving Fuschia city in the evenings. The rumors say he's preparing for a new job somewhere else...",
|
||||
"People say that Sabrina never sleeps. I wonder where she goes when she leaves her gym at night.",
|
||||
"The hot-headed Blaine is a man of extremes. He likes to explore around his hometown during the day.",
|
||||
"Giovanni is a mysterious man. I wonder where he goes in the evening. Probably somewhere as remote as possible to meditate in peace...",
|
||||
"I heard that Whitney went to school in one of the towns near Goldenrod before becoming a Gym Leader. She kept in touch with her old teacher and she goes to visit sometimes in the evening.",
|
||||
"Kurt is always on the lookout for Bug-type Pokémon. He goes hunting early in the morning.",
|
||||
"Falkner rises up early in the morning. You can usually find him in high places.",
|
||||
"Clair is a member of a famous clan of dragon masters. She goes to a special place to pray at night.",
|
||||
"Chuck is a martial arts pro. I've seen him train with Saffron City's dojo master back in the days.",
|
||||
"Morty is a mysterious man. He's been known to be one of the few people who dare enter Pokémon Tower at night.",
|
||||
"Pryce is an ice-type expert who has been around for a long time. He used to train in the Ice Tunnel between Mahogany Town and Blackthorn City before it froze over.",
|
||||
"Jasmine is on vacation in the Sevii Islands. She likes to rise up early to explore around the islands when no one's around."
|
||||
]
|
||||
arr = []
|
||||
n=0
|
||||
for i in 426..437
|
||||
if !$game_switches[i]
|
||||
arr.push(n)
|
||||
end
|
||||
n+=1
|
||||
end
|
||||
arr.push(508); arr.push(509); arr.push(510); arr.push(511);
|
||||
n+=4
|
||||
|
||||
if arr.length > 0
|
||||
return hints[arr[rand(arr.length)]]
|
||||
end
|
||||
return "You got every Gym Leader to come here. This place is more popular than ever!\nNow go and battle them!"
|
||||
end
|
||||
|
||||
def getTrainerParty(trainer)
|
||||
if $game_switches[47]
|
||||
for poke in trainer[3]
|
||||
inverseFusion(poke)
|
||||
end
|
||||
end
|
||||
return trainer[3]
|
||||
end
|
||||
|
||||
def inverseFusion(pokemon)
|
||||
species=pokemon[TPSPECIES]
|
||||
return pokemon if species <= CONST_NB_POKE
|
||||
return pokemon if species > (CONST_NB_POKE * CONST_NB_POKE) + CONST_NB_POKE
|
||||
body = getBasePokemonID(species,true)
|
||||
head = getBasePokemonID(species,false)
|
||||
newspecies = (head)*CONST_NB_POKE+body
|
||||
pokemon[TPSPECIES] = newspecies
|
||||
return pokemon
|
||||
end
|
||||
|
||||
|
||||
def addRandomHeldItems(trainerParty)
|
||||
for poke in trainerParty
|
||||
if poke.item == nil
|
||||
poke.item = PBItems::ORANBERRY#PBItems.sample
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def addHealingItem(items)
|
||||
if $Trainer.numbadges < 1
|
||||
items << PBItems::ORANBERRY
|
||||
elsif $Trainer.numbadges <=2
|
||||
items << PBItems::POTION
|
||||
elsif $Trainer.numbadges <=4
|
||||
items << PBItems::SUPERPOTION
|
||||
elsif $Trainer.numbadges <=6
|
||||
items << PBItems::FULLHEAL
|
||||
items << PBItems::SUPERPOTION
|
||||
elsif $Trainer.numbadges <= 8
|
||||
items << PBItems::FULLHEAL
|
||||
items << PBItems::HYPERPOTION
|
||||
elsif $Trainer.numbadges >= 9
|
||||
items << PBItems::FULLRESTORE
|
||||
end
|
||||
|
||||
return items
|
||||
end
|
||||
|
||||
#####Overload de pbLoadTrainer
|
||||
def pbLoadTrainer(trainerid,trainername,partyid=0)
|
||||
if trainerid.is_a?(String) || trainerid.is_a?(Symbol)
|
||||
if !hasConst?(PBTrainers,trainerid)
|
||||
raise _INTL("Trainer type does not exist ({1}, {2}, ID {3})",trainerid,trainername,partyid)
|
||||
end
|
||||
trainerid=getID(PBTrainers,trainerid)
|
||||
end
|
||||
success=false
|
||||
items=[]
|
||||
party=[]
|
||||
opponent=nil
|
||||
trainers=load_data("Data/trainers.dat")
|
||||
trainerIndex=-1
|
||||
|
||||
for trainer in trainers
|
||||
trainerIndex+=1
|
||||
name=trainer[1]
|
||||
thistrainerid=trainer[0]
|
||||
thispartyid=trainer[4]
|
||||
next if trainerid!=thistrainerid || name!=trainername || partyid!=thispartyid
|
||||
items=trainer[2].clone
|
||||
|
||||
if $game_switches[666] #hard mode
|
||||
items = addHealingItem(items)
|
||||
end
|
||||
|
||||
|
||||
name=pbGetMessageFromHash(MessageTypes::TrainerNames,name)
|
||||
for i in RIVALNAMES
|
||||
if isConst?(trainerid,PBTrainers,i[0]) && $game_variables[i[1]]!=0
|
||||
name=$game_variables[i[1]]
|
||||
end
|
||||
end
|
||||
opponent=PokeBattle_Trainer.new(name,thistrainerid)
|
||||
opponent.setForeignID($Trainer) if $Trainer
|
||||
|
||||
|
||||
#use le random Array si randomized starters (et pas 1ere rival battle)
|
||||
isPlayingRandomized = $game_switches[987] && !$game_switches[46]
|
||||
if isPlayingRandomized && $PokemonGlobal.randomTrainersHash[trainerIndex] == nil
|
||||
Kernel.pbMessage(_INTL("The trainers need to be re-shuffled."))
|
||||
Kernel.pbShuffleTrainers()
|
||||
end
|
||||
trainerParty = isPlayingRandomized ? $PokemonGlobal.randomTrainersHash[trainerIndex][3] : getTrainerParty(trainer)
|
||||
|
||||
|
||||
isRematch = $game_switches[200]
|
||||
rematchId = getRematchId(trainername,trainerid)
|
||||
for poke in trainerParty
|
||||
##
|
||||
species=poke[TPSPECIES]
|
||||
species = replaceRivalStarterIfNecessary(species)
|
||||
|
||||
|
||||
level= $game_switches[666] ? (poke[TPLEVEL]*1.1).ceil : poke[TPLEVEL]
|
||||
|
||||
if isRematch
|
||||
nbRematch = getNumberRematch(rematchId)
|
||||
level = getRematchLevel(level,nbRematch)
|
||||
species = evolveRematchPokemon(nbRematch,species)
|
||||
end
|
||||
|
||||
pokemon=PokeBattle_Pokemon.new(species,level,opponent)
|
||||
#pokemon.form=poke[TPFORM]
|
||||
pokemon.resetMoves
|
||||
|
||||
|
||||
pokemon.setItem( $game_switches[843] ? rand(PBItems.maxValue) : poke[TPITEM])
|
||||
|
||||
if poke[TPMOVE1]>0 || poke[TPMOVE2]>0 || poke[TPMOVE3]>0 || poke[TPMOVE4]>0
|
||||
k=0
|
||||
for move in [TPMOVE1,TPMOVE2,TPMOVE3,TPMOVE4]
|
||||
pokemon.moves[k]=PBMove.new(poke[move])
|
||||
k+=1
|
||||
end
|
||||
pokemon.moves.compact!
|
||||
end
|
||||
pokemon.setAbility(poke[TPABILITY])
|
||||
pokemon.setGender(poke[TPGENDER])
|
||||
if poke[TPSHINY] # if this is a shiny Pokémon
|
||||
pokemon.makeShiny
|
||||
else
|
||||
pokemon.makeNotShiny
|
||||
end
|
||||
pokemon.setNature(poke[TPNATURE])
|
||||
iv=poke[TPIV]
|
||||
for i in 0...6
|
||||
pokemon.iv[i]=iv&0x1F
|
||||
pokemon.ev[i]=[85,level*3/2].min
|
||||
end
|
||||
pokemon.happiness=poke[TPHAPPINESS]
|
||||
pokemon.name=poke[TPNAME] if poke[TPNAME] && poke[TPNAME]!=""
|
||||
if poke[TPSHADOW] # if this is a Shadow Pokémon
|
||||
pokemon.makeShadow rescue nil
|
||||
pokemon.pbUpdateShadowMoves(true) rescue nil
|
||||
pokemon.makeNotShiny
|
||||
end
|
||||
pokemon.ballused=poke[TPBALL]
|
||||
pokemon.calcStats
|
||||
party.push(pokemon)
|
||||
end
|
||||
success=true
|
||||
break
|
||||
end
|
||||
return success ? [opponent,items,party] : nil
|
||||
end
|
||||
|
||||
def getRematchId(trainername, trainerid)
|
||||
return trainername + trainerid.to_s
|
||||
end
|
||||
|
||||
|
||||
def replaceRivalStarterIfNecessary(species)
|
||||
if species == RIVAL_STARTER_PLACEHOLDER_SPECIES
|
||||
if !$game_switches[840] || pbGet(250) == 0#not DEFINED_RIVAL_STARTER
|
||||
fixRivalStarter()
|
||||
end
|
||||
rivalStarter = pbGet(250)
|
||||
if rivalStarter > 0
|
||||
species = pbGet(250)
|
||||
end
|
||||
end
|
||||
return species
|
||||
end
|
||||
|
||||
def fixRivalStarter()
|
||||
#set starter baseform
|
||||
if $PokemonGlobal.psuedoBSTHash == nil
|
||||
psuedoHash = Hash.new
|
||||
for i in 0..NB_POKEMON
|
||||
psuedoHash[i] = i
|
||||
end
|
||||
$PokemonGlobal.psuedoBSTHash = psuedoHash
|
||||
end
|
||||
starterChoice = pbGet(7)
|
||||
|
||||
s1 = $PokemonGlobal.psuedoBSTHash[1]
|
||||
s2 = $PokemonGlobal.psuedoBSTHash[4]
|
||||
s3= $PokemonGlobal.psuedoBSTHash[7]
|
||||
setRivalStarter(s3,s2,s1,starterChoice)
|
||||
|
||||
#evolve en fct des badges
|
||||
rivalStarter = pbGet(250)
|
||||
|
||||
if $game_switches[68] #beat blue cerulean
|
||||
rivalStarter = evolveBody(rivalStarter)
|
||||
end
|
||||
|
||||
if $game_switches[89] #beat blue SS Anne
|
||||
rivalStarter = evolveHead(rivalStarter)
|
||||
end
|
||||
|
||||
if $game_switches[228] #beat silph co
|
||||
rivalStarter = evolveBody(rivalStarter)
|
||||
end
|
||||
|
||||
if $game_switches[11] #got badge 8
|
||||
rivalStarter = evolveHead(rivalStarter)
|
||||
end
|
||||
|
||||
if $game_switches[12] #beat league
|
||||
rivalStarter = evolveBody(rivalStarter)
|
||||
rivalStarter = evolveHead(rivalStarter)
|
||||
end
|
||||
|
||||
#RIVAL_STARTER_IS_DEFINED
|
||||
pbSet(250,rivalStarter)
|
||||
$game_switches[840] = true
|
||||
end
|
||||
|
||||
169
Data/Scripts/025-Randomizer/randomizer.rb
Normal file
169
Data/Scripts/025-Randomizer/randomizer.rb
Normal file
@@ -0,0 +1,169 @@
|
||||
class PokemonGlobalMetadata
|
||||
attr_accessor :psuedoHash
|
||||
attr_accessor :psuedoBSTHash
|
||||
attr_accessor :pseudoBSTHashTrainers
|
||||
attr_accessor :randomTrainersHash
|
||||
|
||||
|
||||
alias random_init initialize
|
||||
def initialize
|
||||
random_init
|
||||
@psuedoHash=nil
|
||||
@psuedoBSTHash=nil
|
||||
end
|
||||
end
|
||||
|
||||
##############
|
||||
# randomizer shuffle
|
||||
# ##############
|
||||
def Kernel.pbShuffleDex(range=50,type=0)
|
||||
$game_switches[855] = true # Randomized at least once
|
||||
|
||||
#type 0: BST
|
||||
#type 1: full random
|
||||
#type: 2 by route (not implemented)
|
||||
range = 1 if range == 0
|
||||
# create hash
|
||||
psuedoHash = Hash.new
|
||||
psuedoBSTHash = Hash.new
|
||||
|
||||
#Create array of all pokemon dex numbers
|
||||
pokeArray = []
|
||||
|
||||
|
||||
monLimit = type == 1 ? 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#pas de arceus
|
||||
baseStats=$pkmn_dex[i][5]
|
||||
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
|
||||
baseStats=$pkmn_dex[pokeArrayRand[j]][5]
|
||||
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 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
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
#ajoute x happiness a tous les party member
|
||||
def Kernel.raisePartyHappiness(increment)
|
||||
return
|
||||
# for poke in $Trainer.party
|
||||
# next if poke.isEgg?
|
||||
# poke.happiness += increment
|
||||
# end
|
||||
|
||||
end
|
||||
|
||||
|
||||
def Kernel.pbShuffleDexTrainers()
|
||||
# create hash
|
||||
psuedoHash = Hash.new
|
||||
psuedoBSTHash = Hash.new
|
||||
|
||||
#Create array of all pokemon dex numbers
|
||||
pokeArray = []
|
||||
for i in 1..PBSpecies.maxValue
|
||||
pokeArray.push(i)
|
||||
end
|
||||
#randomize hash
|
||||
pokeArrayRand = pokeArray.dup
|
||||
pokeArrayRand.shuffle!
|
||||
pokeArray.insert(0,nil)
|
||||
# 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..PBSpecies.maxValue
|
||||
if i % 20 == 0
|
||||
n = (i.to_f/PBSpecies.maxValue)*100
|
||||
#Kernel.pbMessage(_INTL("\\ts[]Shuffling...\\n {1}%\\^",sprintf('%.2f', n),PBSpecies.maxValue))
|
||||
end
|
||||
|
||||
baseStats=$pkmn_dex[i][I]
|
||||
baseStat_target = 0
|
||||
for k in 0...baseStats.length
|
||||
baseStat_target+=baseStats[k]
|
||||
end
|
||||
baseStat_target = (baseStat_target/50).floor
|
||||
for j in 1...pokeArrayRand.length
|
||||
baseStats=$pkmn_dex[pokeArrayRand[j]][5]
|
||||
baseStat_temp = 0
|
||||
for l in 0...baseStats.length
|
||||
baseStat_temp+=baseStats[l]
|
||||
end
|
||||
baseStat_temp = (baseStat_temp/50).floor
|
||||
#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])
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#add hashes to global data0
|
||||
#$PokemonGlobal.psuedoHash = psuedoHash
|
||||
$PokemonGlobal.pseudoBSTHashTrainers = psuedoBSTHash
|
||||
end
|
||||
Reference in New Issue
Block a user