More item randomization options

This commit is contained in:
infinitefusion
2022-09-23 23:15:38 -04:00
parent 77c3220d10
commit efd97dc9fe
14 changed files with 505 additions and 278 deletions

View File

@@ -25,6 +25,10 @@ Frogman
The story and dialogues were based off Pok<6F>mon Red and Blue, as well as The story and dialogues were based off Pok<6F>mon Red and Blue, as well as
Pok<EFBFBD>mon Gold and Silver. Both games are made by Game Freak. Pok<EFBFBD>mon Gold and Silver. Both games are made by Game Freak.
#################################
Modern Mode by Tomate & Blaquaza
########################################################### ###########################################################
### Fusion Sprites ### ### Fusion Sprites ###
########################################################## ##########################################################
@@ -149,7 +153,6 @@ kakakiamekerasakia#3792, ItsThatSimple#6320, Gelos#9875, GalaxyDJx#0001, Fullmet
Evil Mailman#0604, elpano2#9588, Cenna#6226, Catdesu#0845, CaseyAether#2205, carni#0124, Buttlu#7240 Evil Mailman#0604, elpano2#9588, Cenna#6226, Catdesu#0845, CaseyAether#2205, carni#0124, Buttlu#7240
Triple fusion sprites Triple fusion sprites
######################## ########################
Legendary birds fusion sprite by Universez Legendary birds fusion sprite by Universez

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -786,7 +786,8 @@ end
# Picking up an item found on the ground # Picking up an item found on the ground
#=============================================================================== #===============================================================================
def pbItemBall(item, quantity = 1, item_name = "", canRandom = true) def pbItemBall(item, quantity = 1, item_name = "", canRandom = true)
if canRandom canRandom = false if !$game_switches[SWITCH_RANDOM_ITEMS_GENERAL]
if canRandom && ($game_switches[SWITCH_RANDOM_FOUND_ITEMS] || $game_switches[SWITCH_RANDOM_FOUND_TMS])
item = pbGetRandomItem(item) if canRandom #fait rien si pas activé item = pbGetRandomItem(item) if canRandom #fait rien si pas activé
else else
item = GameData::Item.get(item) item = GameData::Item.get(item)
@@ -833,9 +834,23 @@ end
#=============================================================================== #===============================================================================
def pbReceiveItem(item, quantity = 1, item_name = "", music = nil) def pbReceiveItem(item, quantity = 1, item_name = "", music = nil, canRandom=true)
#item_name -> pour donner un autre nom à l'item. Pas encore réimplémenté et surtout là pour éviter que ça plante quand des events essaient de le faire #item_name -> pour donner un autre nom à l'item. Pas encore réimplémenté et surtout là pour éviter que ça plante quand des events essaient de le faire
item = GameData::Item.get(item) canRandom = false if !$game_switches[SWITCH_RANDOM_ITEMS_GENERAL]
if canRandom && ($game_switches[SWITCH_RANDOM_GIVEN_ITEMS] || $game_switches[SWITCH_RANDOM_GIVEN_TMS])
item = pbGetRandomItem(item) if canRandom #fait rien si pas activé
else
item = GameData::Item.get(item)
end
# item = GameData::Item.get(item)
# if $game_switches[SWITCH_RANDOM_ITEMS] && $game_switches[SWITCH_RANDOM_GIVEN_ITEMS]
# item = pbGetRandomItem(item.id)
# end
#
# if $game_switches[SWITCH_RANDOM_ITEMS] && $game_switches[SWITCH_RANDOM_GIVEN_TMS]
# item = getRandomGivenTM(item)
# end
return false if !item || quantity < 1 return false if !item || quantity < 1
itemname = (quantity > 1) ? item.name_plural : item.name itemname = (quantity > 1) ? item.name_plural : item.name
pocket = item.pocket pocket = item.pocket

View File

@@ -648,10 +648,30 @@ class PokemonMartScreen
end end
end end
def replaceShopStockWithRandomized(stock)
if $PokemonGlobal.randomItemsHash != nil
newStock = []
for item in stock
newItem =$PokemonGlobal.randomItemsHash[item]
if newItem != nil && GameData::Item.get(newItem).price >0
newStock << newItem
else
newStock << item
end
end
return newStock
end
return stock
end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
def pbPokemonMart(stock,speech=nil,cantsell=false) def pbPokemonMart(stock,speech=nil,cantsell=false)
if $game_switches[SWITCH_RANDOM_ITEMS] && $game_switches[SWITCH_RANDOM_SHOP_ITEMS]
stock = replaceShopStockWithRandomized(stock)
end
for i in 0...stock.length for i in 0...stock.length
stock[i] = GameData::Item.get(stock[i]).id stock[i] = GameData::Item.get(stock[i]).id
stock[i] = nil if GameData::Item.get(stock[i]).is_important? && $PokemonBag.pbHasItem?(stock[i]) stock[i] = nil if GameData::Item.get(stock[i]).is_important? && $PokemonBag.pbHasItem?(stock[i])

View File

@@ -9,6 +9,8 @@ class RandomizerOptionsScene < PokemonOption_Scene
@openTrainerOptions = false @openTrainerOptions = false
@openWildOptions = false @openWildOptions = false
@openGymOptions = false @openGymOptions = false
@openItemOptions = false
end end
def getDefaultDescription def getDefaultDescription
@@ -26,14 +28,19 @@ class RandomizerOptionsScene < PokemonOption_Scene
def pbGetOptions(inloadscreen = false) def pbGetOptions(inloadscreen = false)
options = [ options = [
EnumOption.new(_INTL("Starters"), [_INTL("On"), _INTL("Off")], EnumOption.new(_INTL("Pokémon"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_RANDOM_STARTERS] ? 0 : 1 }, proc {
$game_switches[SWITCH_RANDOM_WILD] ? 0 : 1
},
proc { |value| proc { |value|
$game_switches[SWITCH_RANDOM_STARTERS] = value == 0 if !$game_switches[SWITCH_RANDOM_WILD] && value == 0
}, "Randomize the selection of starters to choose from at the start of the game" @openWildOptions = true
openWildPokemonOptionsMenu()
end
$game_switches[SWITCH_RANDOM_WILD] = value == 0
}, "Select the randomizer options for Pokémon"
), ),
EnumOption.new(_INTL("NPC Trainers"), [_INTL("On"), _INTL("Off")],
EnumOption.new(_INTL("Trainers"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_RANDOM_TRAINERS] ? 0 : 1 }, proc { $game_switches[SWITCH_RANDOM_TRAINERS] ? 0 : 1 },
proc { |value| proc { |value|
if !$game_switches[SWITCH_RANDOM_TRAINERS] && value == 0 if !$game_switches[SWITCH_RANDOM_TRAINERS] && value == 0
@@ -41,7 +48,7 @@ class RandomizerOptionsScene < PokemonOption_Scene
openTrainerOptionsMenu() openTrainerOptionsMenu()
end end
$game_switches[SWITCH_RANDOM_TRAINERS] = value == 0 $game_switches[SWITCH_RANDOM_TRAINERS] = value == 0
}, "Select the randomizer options for regular trainers" }, "Select the randomizer options for trainers"
), ),
EnumOption.new(_INTL("Gym trainers"), [_INTL("On"), _INTL("Off")], EnumOption.new(_INTL("Gym trainers"), [_INTL("On"), _INTL("Off")],
@@ -55,30 +62,17 @@ class RandomizerOptionsScene < PokemonOption_Scene
}, "Limit gym trainers to a single type" }, "Limit gym trainers to a single type"
), ),
EnumOption.new(_INTL("Wild Pokémon"), [_INTL("On"), _INTL("Off")],
proc {
$game_switches[SWITCH_RANDOM_WILD] ? 0 : 1
},
proc { |value|
if !$game_switches[SWITCH_RANDOM_WILD] && value == 0
@openWildOptions = true
openWildPokemonOptionsMenu()
end
$game_switches[SWITCH_RANDOM_WILD] = value == 0
}, "Select the randomizer options for wild Pokémon"
),
EnumOption.new(_INTL("Items"), [_INTL("On"), _INTL("Off")], EnumOption.new(_INTL("Items"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_RANDOM_ITEMS] ? 0 : 1 }, proc { $game_switches[SWITCH_RANDOM_ITEMS_GENERAL] ? 0 : 1 },
proc { |value| proc { |value|
$game_switches[SWITCH_RANDOM_ITEMS] = value == 0 if !$game_switches[SWITCH_RANDOM_ITEMS_GENERAL] && value == 0
}, "Randomize the items picked up on the ground" @openItemOptions = true
), openItemOptionsMenu()
EnumOption.new(_INTL("TMs"), [_INTL("On"), _INTL("Off")], end
proc { $game_switches[SWITCH_RANDOM_TMS] ? 0 : 1 }, $game_switches[SWITCH_RANDOM_ITEMS_GENERAL] = value == 0
proc { |value| }, "Select the randomizer options for items"
$game_switches[SWITCH_RANDOM_TMS] = value == 0
}, "Randomize the TMs picked up on the ground"
), ),
] ]
return options return options
end end
@@ -93,6 +87,16 @@ class RandomizerOptionsScene < PokemonOption_Scene
@openGymOptions = false @openGymOptions = false
end end
def openItemOptionsMenu()
return if !@openItemOptions
pbFadeOutIn {
scene = RandomizerItemOptionsScene.new
screen = PokemonOptionScreen.new(scene)
screen.pbStartScreen
}
@openItemOptions = false
end
def openTrainerOptionsMenu() def openTrainerOptionsMenu()
return if !@openTrainerOptions return if !@openTrainerOptions
pbFadeOutIn { pbFadeOutIn {
@@ -117,7 +121,6 @@ end
class RandomizerTrainerOptionsScene < PokemonOption_Scene class RandomizerTrainerOptionsScene < PokemonOption_Scene
RANDOM_TEAMS_CUSTOM_SPRITES = 600 RANDOM_TEAMS_CUSTOM_SPRITES = 600
RANDOM_HELD_ITEMS = 843
RANDOM_GYM_TYPES = 921 RANDOM_GYM_TYPES = 921
def initialize def initialize
@@ -152,12 +155,6 @@ class RandomizerTrainerOptionsScene < PokemonOption_Scene
$game_switches[RANDOM_TEAMS_CUSTOM_SPRITES] = value == 0 $game_switches[RANDOM_TEAMS_CUSTOM_SPRITES] = value == 0
}, },
"Use only Pokémon that have custom sprites in trainer teams" "Use only Pokémon that have custom sprites in trainer teams"
),
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
}, "Give random held items to all trainers"
) )
] ]
return options return options
@@ -219,6 +216,12 @@ class RandomizerWildPokemonOptionsScene < PokemonOption_Scene
"Randomizes the encounters in each route individually" "Randomizes the encounters in each route individually"
] ]
), ),
EnumOption.new(_INTL("Starters"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_RANDOM_STARTERS] ? 0 : 1 },
proc { |value|
$game_switches[SWITCH_RANDOM_STARTERS] = value == 0
}, "Randomize the selection of starters to choose from at the start of the game"
),
EnumOption.new(_INTL("Static encounters"), [_INTL("On"), _INTL("Off")], EnumOption.new(_INTL("Static encounters"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[RANDOM_STATIC] ? 0 : 1 }, proc { $game_switches[RANDOM_STATIC] ? 0 : 1 },
proc { |value| proc { |value|
@@ -302,4 +305,106 @@ class RandomizerGymOptionsScene < PokemonOption_Scene
] ]
return options return options
end end
end
class RandomizerItemOptionsScene < PokemonOption_Scene
RANDOM_HELD_ITEMS = 843
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: Items"), 0, 0, Graphics.width, 64, @viewport)
@sprites["textbox"].text = _INTL("Set the randomizer settings for items")
pbFadeInAndShow(@sprites) { pbUpdate }
end
def pbFadeInAndShow(sprites, visiblesprites = nil)
return if !@changedColor
super
end
def pbGetOptions(inloadscreen = false)
options = [
EnumOption.new(_INTL("Type"), [_INTL("Mapped"), _INTL("Dynamic")],
proc {
if $game_switches[SWITCH_RANDOM_ITEMS_DYNAMIC]
1
else
0
end
},
proc { |value|
if value == 0
$game_switches[SWITCH_RANDOM_ITEMS_MAPPED] = true
$game_switches[SWITCH_RANDOM_ITEMS_DYNAMIC] = false
else
value == 1
$game_switches[SWITCH_RANDOM_ITEMS_MAPPED] = false
$game_switches[SWITCH_RANDOM_ITEMS_DYNAMIC] = true
end
},
# proc { $game_switches[SWITCH_RANDOM_ITEMS_FULL] ? 0 : 1 },
# proc { |value|
# $game_switches[SWITCH_RANDOM_ITEMS_MAPPED] = value == 0
# $game_switches[SWITCH_RANDOM_ITEMS_FULL] = value == 1
# }, ["Random items are decided at the start of the game", "Random items are decided as you obtain them"]
),
EnumOption.new(_INTL("Found items"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_RANDOM_FOUND_ITEMS] ? 0 : 1 },
proc { |value|
$game_switches[SWITCH_RANDOM_FOUND_ITEMS] = value == 0
$game_switches[SWITCH_RANDOM_ITEMS] = $game_switches[SWITCH_RANDOM_FOUND_ITEMS] || $game_switches[SWITCH_RANDOM_GIVEN_ITEMS]
}, "Randomize the items picked up on the ground"
),
EnumOption.new(_INTL("Found TMs"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_RANDOM_FOUND_TMS] ? 0 : 1 },
proc { |value|
$game_switches[SWITCH_RANDOM_FOUND_TMS] = value == 0
$game_switches[SWITCH_RANDOM_TMS] = $game_switches[SWITCH_RANDOM_FOUND_TMS] || $game_switches[SWITCH_RANDOM_GIVEN_TMS]
}, "Randomize the TMs picked up on the ground"
),
EnumOption.new(_INTL("Given items"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_RANDOM_GIVEN_ITEMS] ? 0 : 1 },
proc { |value|
$game_switches[SWITCH_RANDOM_GIVEN_ITEMS] = value == 0
$game_switches[SWITCH_RANDOM_ITEMS] = $game_switches[SWITCH_RANDOM_FOUND_ITEMS] || $game_switches[SWITCH_RANDOM_GIVEN_ITEMS]
}, "Randomize the items given by NPCs (might make some quests impossible to complete)"
),
EnumOption.new(_INTL("Given TMs"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_RANDOM_GIVEN_TMS] ? 0 : 1 },
proc { |value|
$game_switches[SWITCH_RANDOM_GIVEN_TMS] = value == 0
$game_switches[SWITCH_RANDOM_TMS] = $game_switches[SWITCH_RANDOM_FOUND_TMS] || $game_switches[SWITCH_RANDOM_GIVEN_TMS]
}, "Randomize the TMs given by NPCs"
),
EnumOption.new(_INTL("Shops items"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_RANDOM_SHOP_ITEMS] ? 0 : 1 },
proc { |value|
$game_switches[SWITCH_RANDOM_SHOP_ITEMS] = value == 0
}, "Randomizes the items available in shops (always mapped)"
),
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
}, "Give random held items to all trainers"
)
]
return options
end
end end

View File

@@ -20,11 +20,40 @@ HELD_ITEMS = [:AIRBALLOON, :BRIGHTPOWDER, :EVIOLITE, :FLOATSTONE, :DESTINYKNOT,
:PETAYABERRY, :APICOTBERRY, :LANSATBERRY, :STARFBERRY, :ENIGMABERRY, :MICLEBERRY, :CUSTAPBERRY, :PETAYABERRY, :APICOTBERRY, :LANSATBERRY, :STARFBERRY, :ENIGMABERRY, :MICLEBERRY, :CUSTAPBERRY,
:JABOCABERRY, :ROWAPBERRY, :FAIRYGEM] :JABOCABERRY, :ROWAPBERRY, :FAIRYGEM]
ITEM_EXCEPTIONS= [:COVERFOSSIL, :PLUMEFOSSIL, :ACCURACYUP,:DAMAGEUP,:ANCIENTSTONE,:ODDKEYSTONE_FULL,:TM00 ] INVALID_ITEMS = [:COVERFOSSIL, :PLUMEFOSSIL, :ACCURACYUP, :DAMAGEUP, :ANCIENTSTONE, :ODDKEYSTONE_FULL, :TM00]
RANDOM_ITEM_EXCEPTIONS = [:DNASPLICERS, :POKEBALL]
def pbGetRandomItem(item_id) def getRandomGivenTM(item)
return nil if item_id == nil return item if item == nil
item = GameData::Item.get(item_id) if $game_switches[SWITCH_RANDOM_ITEMS_MAPPED]
newItem = $PokemonGlobal.randomTMsHash[item.id]
return GameData::Item.get(newItem) if newItem != nil
end
if $game_switches[SWITCH_RANDOM_ITEMS_DYNAMIC]
return pbGetRandomTM
end
return item
end
def getMappedRandomItem(item)
if (item.is_TM?)
return item if !$game_switches[SWITCH_RANDOM_TMS]
if $game_switches[SWITCH_RANDOM_TMS]
newItem = $PokemonGlobal.randomTMsHash[item.id]
return GameData::Item.get(newItem) if newItem != nil
end
return item
else
return item if !$game_switches[SWITCH_RANDOM_ITEMS]
if $game_switches[SWITCH_RANDOM_ITEMS]
newItem = $PokemonGlobal.randomItemsHash[item.id]
return GameData::Item.get(newItem) if newItem != nil
return item
end
end
end
def getDynamicRandomItem(item)
#keyItem ou HM -> on randomize pas #keyItem ou HM -> on randomize pas
return item if item.is_key_item? return item if item.is_key_item?
return item if item.is_HM? return item if item.is_HM?
@@ -35,7 +64,8 @@ def pbGetRandomItem(item_id)
return $game_switches[SWITCH_RANDOM_TMS] ? pbGetRandomTM() : item return $game_switches[SWITCH_RANDOM_TMS] ? pbGetRandomTM() : item
end end
#item normal #item normal
return item if !$game_switches[SWITCH_RANDOM_ITEMS] return item if !$game_switches[SWITCH_RANDOM_ITEMS_DYNAMIC] || !$game_switches[SWITCH_RANDOM_ITEMS]
#berries #berries
return pbGetRandomBerry() if item.is_berry? return pbGetRandomBerry() if item.is_berry?
@@ -43,13 +73,25 @@ def pbGetRandomItem(item_id)
items_list = GameData::Item.list_all items_list = GameData::Item.list_all
newItem_id = items_list.keys.sample newItem_id = items_list.keys.sample
newItem = GameData::Item.get(newItem_id) newItem = GameData::Item.get(newItem_id)
while (newItem.is_machine? || newItem.is_key_item? || ITEM_EXCEPTIONS.include?(newItem)) while (newItem.is_machine? || newItem.is_key_item? || INVALID_ITEMS.include?(newItem))
newItem_id = items_list.keys.sample newItem_id = items_list.keys.sample
newItem = GameData::Item.get(newItem_id) newItem = GameData::Item.get(newItem_id)
end end
return newItem return newItem
end end
def pbGetRandomItem(item_id)
return nil if item_id == nil
item = GameData::Item.get(item_id)
return item if !($game_switches[SWITCH_RANDOM_ITEMS] || $game_switches[SWITCH_RANDOM_TMS])
if $game_switches[SWITCH_RANDOM_ITEMS_MAPPED]
return getMappedRandomItem(item)
elsif $game_switches[SWITCH_RANDOM_ITEMS_DYNAMIC]
return getDynamicRandomItem(item)
end
return item
end
def pbGetRandomHeldItem() def pbGetRandomHeldItem()
newItem_id = HELD_ITEMS.sample newItem_id = HELD_ITEMS.sample
newItem = GameData::Item.get(newItem_id) newItem = GameData::Item.get(newItem_id)

View File

@@ -27,14 +27,11 @@
############################################################### ###############################################################
# #
#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_CLASSIC = [: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] GYM_TYPES_CLASSIC = [: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]
GYM_TYPES_MODERN = [:NORMAL,:STEEL,:ICE,:FIGHTING,:BUG,:DARK,:FAIRY,:PSYCHIC,:NORMAL,:FIGHTING,:FAIRY,:GRASS,:BUG,:DRAGON,:FIRE,:GHOST,:GROUND,:ELECTRIC,:WATER,:ROCK,:POISON,:FLYING,:FAIRY,:DARK,:GHOST,:DRAGON] GYM_TYPES_MODERN = [:NORMAL, :STEEL, :ICE, :FIGHTING, :BUG, :DARK, :FAIRY, :PSYCHIC, :NORMAL, :FIGHTING, :FAIRY, :GRASS, :BUG, :DRAGON, :FIRE, :GHOST, :GROUND, :ELECTRIC, :WATER, :ROCK, :POISON, :FLYING, :FAIRY, :DARK, :GHOST, :DRAGON]
GYM_TYPES_ARRAY = ($game_switches && $game_switches[SWITCH_MODERN_MODE]) ? GYM_TYPES_MODERN : GYM_TYPES_CLASSIC GYM_TYPES_ARRAY = ($game_switches && $game_switches[SWITCH_MODERN_MODE]) ? GYM_TYPES_MODERN : GYM_TYPES_CLASSIC
#$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]
@@ -44,71 +41,72 @@ def Kernel.initRandomTypeArray()
$game_variables[VAR_GYM_TYPES_ARRAY] = $game_switches[SWITCH_RANDOMIZED_GYM_TYPES] ? typesArray : GYM_TYPES_ARRAY $game_variables[VAR_GYM_TYPES_ARRAY] = $game_switches[SWITCH_RANDOMIZED_GYM_TYPES] ? typesArray : GYM_TYPES_ARRAY
end end
def setRivalStarter(starter1, starter2, starter3, choice) def setRivalStarter(starter1, starter2, starter3, choice)
starters=[starter1,starter2,starter3] starters = [starter1, starter2, starter3]
starters.delete_at(choice) starters.delete_at(choice)
if starters[0] > NB_POKEMON || starters[1] > NB_POKEMON if starters[0] > NB_POKEMON || starters[1] > NB_POKEMON
rivalStarter = starters[0] rivalStarter = starters[0]
else else
rivalStarter = starters[0]*NB_POKEMON+starters[1] rivalStarter = starters[0] * NB_POKEMON + starters[1]
end end
pbSet(VAR_RIVAL_STARTER,rivalStarter) pbSet(VAR_RIVAL_STARTER, rivalStarter)
$game_switches[SWITCH_DEFINED_RIVAL_STARTER] = true $game_switches[SWITCH_DEFINED_RIVAL_STARTER] = true
end end
def setRivalStarterSpecific(rivalStarter) def setRivalStarterSpecific(rivalStarter)
pbSet(VAR_RIVAL_STARTER,rivalStarter) pbSet(VAR_RIVAL_STARTER, rivalStarter)
$game_switches[SWITCH_DEFINED_RIVAL_STARTER] = true $game_switches[SWITCH_DEFINED_RIVAL_STARTER] = true
end 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)
for pokemon in party for pokemon in party
next if !pokemon next if !pokemon
newspecies = rand(PBSpecies.maxValue - 1) + 1 newspecies = rand(PBSpecies.maxValue - 1) + 1
while !gymLeaderOk(newspecies) || bstOk(newspecies,pokemon.species,$game_variables[VAR_RANDOMIZER_WILD_POKE_BST]) while !gymLeaderOk(newspecies) || bstOk(newspecies, pokemon.species, $game_variables[VAR_RANDOMIZER_WILD_POKE_BST])
newspecies = rand(PBSpecies.maxValue - 1) + 1 newspecies = rand(PBSpecies.maxValue - 1) + 1
end end
pokemon.species = newspecies pokemon.species = newspecies
pokemon.name = PBSpecies.getName(newspecies) pokemon.name = PBSpecies.getName(newspecies)
pokemon.resetMoves pokemon.resetMoves
pokemon.calcStats pokemon.calcStats
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 end
m.species= newspecies
m.name = PBSpecies.getName(newspecies) return party
m.resetMoves end
m.calcStats
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
return party
end
end end
####### #######
# end of class # end of class
###### ######
####methodes utilitaires ####methodes utilitaires
# def getBaseStats(species) # def getBaseStats(species)
@@ -121,20 +119,20 @@ end
# return basestatsum # return basestatsum
# end # end
# #
def bstOk(newspecies,oldPokemonSpecies,bst_range=50) def bstOk(newspecies, oldPokemonSpecies, bst_range = 50)
newBST = calcBaseStatsSum(newspecies) newBST = calcBaseStatsSum(newspecies)
originalBST = calcBaseStatsSum(oldPokemonSpecies) originalBST = calcBaseStatsSum(oldPokemonSpecies)
return newBST < originalBST-bst_range || newBST > originalBST+bst_range return newBST < originalBST - bst_range || newBST > originalBST + bst_range
end end
def gymLeaderOk(newspecies) def gymLeaderOk(newspecies)
return true if $game_variables[152] == -1 #not in a gym return true if $game_variables[152] == -1 #not in a gym
leaderType=getLeaderType() leaderType = getLeaderType()
if leaderType == nil if leaderType == nil
return true return true
else else
return true if SpeciesHasType?(leaderType,newspecies) return true if SpeciesHasType?(leaderType, newspecies)
end end
return false return false
end end
@@ -150,41 +148,34 @@ def getLeaderType()
return typeIndex return typeIndex
end end
##Version alternatives de fonctions pour fonctionner avec numero de species ##Version alternatives de fonctions pour fonctionner avec numero de species
def SpeciesHasType?(type,species) def SpeciesHasType?(type, species)
if type.is_a?(String) || type.is_a?(Symbol) if type.is_a?(String) || type.is_a?(Symbol)
return isConst?(getSpeciesType1(species),PBTypes,type) || isConst?(getSpeciesType2(species),PBTypes,type) return isConst?(getSpeciesType1(species), PBTypes, type) || isConst?(getSpeciesType2(species), PBTypes, type)
else else
return getSpeciesType1(species)==type || getSpeciesType2(species)==type return getSpeciesType1(species) == type || getSpeciesType2(species) == type
end end
end end
# Returns this Pokémon's first type. # Returns this Pokémon's first type.
def getSpeciesType1(species) def getSpeciesType1(species)
return $pkmn_dex[species][3] return $pkmn_dex[species][3]
end end
# Returns this Pokémon's second type. # Returns this Pokémon's second type.
def getSpeciesType2(species) def getSpeciesType2(species)
return $pkmn_dex[species][4] return $pkmn_dex[species][4]
end end
############
############
#summarize random options #summarize random options
def Kernel.sumRandomOptions() def Kernel.sumRandomOptions()
answer = $game_switches[954] ? "On" : "Off" answer = $game_switches[954] ? "On" : "Off"
stringOptions = "\nStarters: " << answer stringOptions = "\nStarters: " << answer
answer = $game_switches[778] ? "On" : "Off" answer = $game_switches[778] ? "On" : "Off"
stringOptions << "\nWild Pokémon: " << answer << " " stringOptions << "\nWild Pokémon: " << answer << " "
if $game_switches[777] if $game_switches[777]
stringOptions << "(Area)" stringOptions << "(Area)"
else else
@@ -192,142 +183,130 @@ def Kernel.sumRandomOptions()
end end
answer = $game_switches[987] ? "On" : "Off" answer = $game_switches[987] ? "On" : "Off"
stringOptions << "\nTrainers: " << answer stringOptions << "\nTrainers: " << answer
answer = $game_switches[955] ? "On" : "Off" answer = $game_switches[955] ? "On" : "Off"
stringOptions << "\nStatic encounters: " << answer stringOptions << "\nStatic encounters: " << answer
answer = $game_switches[780] ? "On" : "Off"
stringOptions << "\nGift Pokémon: " << answer
answer = $game_switches[780] ? "On" : "Off"
stringOptions << "\nGift Pokémon: " << answer
answer = $game_switches[958] ? "On" : "Off" answer = $game_switches[958] ? "On" : "Off"
stringOptions << "\nItems: " << answer stringOptions << "\nItems: " << answer
answer = $game_switches[959] ? "On" : "Off" answer = $game_switches[959] ? "On" : "Off"
stringOptions << "\nTMs: " << answer stringOptions << "\nTMs: " << answer
return stringOptions return stringOptions
end end
def countVisitedMaps def countVisitedMaps
count = 0 count = 0
for i in 0..$PokemonGlobal.visitedMaps.length for i in 0..$PokemonGlobal.visitedMaps.length
count +=1 if $PokemonGlobal.visitedMaps[i] count += 1 if $PokemonGlobal.visitedMaps[i]
end end
return count return count
end end
def Kernel.sumGameStats() def Kernel.sumGameStats()
stringStats = "" stringStats = ""
stringStats << "Seen " << $Trainer.pokedexSeen.to_s << " Pokémon"
stringStats << "Seen " << $Trainer.pokedexSeen.to_s << " Pokémon" stringStats << "\nCaught " << $Trainer.pokedexOwned.to_s << " Pokémon"
stringStats << "\nCaught " << $Trainer.pokedexOwned.to_s << " Pokémon"
stringStats << "\nBeaten the Elite Four " << $game_variables[174].to_s << " times" stringStats << "\nBeaten the Elite Four " << $game_variables[174].to_s << " times"
stringStats << "\nFused " << $game_variables[126].to_s << " Pokémon" stringStats << "\nFused " << $game_variables[126].to_s << " Pokémon"
stringStats << "\nRematched " << $game_variables[162].to_s << " Gym Leaders" stringStats << "\nRematched " << $game_variables[162].to_s << " Gym Leaders"
stringStats << "\nTook " << $PokemonGlobal.stepcount.to_s << " steps" stringStats << "\nTook " << $PokemonGlobal.stepcount.to_s << " steps"
stringStats << "\nVisited " << countVisitedMaps.to_s << " different areas" stringStats << "\nVisited " << countVisitedMaps.to_s << " different areas"
if $game_switches[910] if $game_switches[910]
stringStats << "\nMade " << $game_variables[164].to_s << " Wonder Trades" stringStats << "\nMade " << $game_variables[164].to_s << " Wonder Trades"
end 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 << "\nTipped $" << $game_variables[100].to_s << " to clowns"
stringStats << "\nWon $" << $game_variables[43].to_s << " against gamblers" stringStats << "\nDestroyed " << $game_variables[163].to_s << " sandcastles"
stringStats << "\nLost $" << $game_variables[44].to_s << " against gamblers"
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 end
stringStats << "\nSpent $" << $game_variables[225].to_s << " at hotels" 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"
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] if $game_switches[912]
stringStats << "\nDied " << $game_variables[191].to_s << " times in Pikachu's adventure" stringStats << "\nDied " << $game_variables[191].to_s << " times in Pikachu's adventure"
if $game_variables[193] >= 1 if $game_variables[193] >= 1
stringStats << "\nCollected " << $game_variables[194].to_s << " coins with Pikachu" stringStats << "\nCollected " << $game_variables[194].to_s << " coins with Pikachu"
end end
end end
return stringStats return stringStats
end end
def Kernel.pbRandomizeTM() def Kernel.pbRandomizeTM()
tmList = [] tmList = []
for item in $itemData for item in $itemData
#machine=$ItemData[item][ITEMMACHINE] #machine=$ItemData[item][ITEMMACHINE]
#movename=PBMoves.getName(machine) #movename=PBMoves.getName(machine)
#Kernel.pbMessage(_INTL("It contained {1}.\1",item)) #Kernel.pbMessage(_INTL("It contained {1}.\1",item))
tmList << item if pbIsHiddenMachine?(item) tmList << item if pbIsHiddenMachine?(item)
end end
end end
def getNewSpecies(oldSpecies,bst_range=50, ignoreRivalPlaceholder = false, maxDexNumber = PBSpecies.maxValue ) def getNewSpecies(oldSpecies, bst_range = 50, ignoreRivalPlaceholder = false, maxDexNumber = PBSpecies.maxValue)
oldSpecies_dex = dexNum(oldSpecies) oldSpecies_dex = dexNum(oldSpecies)
return oldSpecies_dex if (oldSpecies_dex == Settings::RIVAL_STARTER_PLACEHOLDER_SPECIES && !ignoreRivalPlaceholder) return oldSpecies_dex if (oldSpecies_dex == Settings::RIVAL_STARTER_PLACEHOLDER_SPECIES && !ignoreRivalPlaceholder)
return oldSpecies_dex if oldSpecies_dex >= Settings::ZAPMOLCUNO_NB return oldSpecies_dex if oldSpecies_dex >= Settings::ZAPMOLCUNO_NB
newspecies_dex = rand(maxDexNumber - 1) + 1 newspecies_dex = rand(maxDexNumber - 1) + 1
i=0 i = 0
while bstOk(newspecies_dex,oldSpecies_dex,bst_range) while bstOk(newspecies_dex, oldSpecies_dex, bst_range)
newspecies_dex = rand(maxDexNumber - 1) + 1 newspecies_dex = rand(maxDexNumber - 1) + 1
i+=1 i += 1
if i%10 == 0 if i % 10 == 0
bst_range += 5 bst_range += 5
end end
end end
return newspecies_dex return newspecies_dex
end end
def getNewCustomSpecies(oldSpecies, customSpeciesList, bst_range = 50, ignoreRivalPlaceholder = false)
def getNewCustomSpecies(oldSpecies,customSpeciesList,bst_range=50, ignoreRivalPlaceholder = false)
oldSpecies_dex = dexNum(oldSpecies) oldSpecies_dex = dexNum(oldSpecies)
return oldSpecies_dex if (oldSpecies_dex == Settings::RIVAL_STARTER_PLACEHOLDER_SPECIES && !ignoreRivalPlaceholder) return oldSpecies_dex if (oldSpecies_dex == Settings::RIVAL_STARTER_PLACEHOLDER_SPECIES && !ignoreRivalPlaceholder)
return oldSpecies_dex if oldSpecies_dex >= Settings::ZAPMOLCUNO_NB return oldSpecies_dex if oldSpecies_dex >= Settings::ZAPMOLCUNO_NB
i = rand(customSpeciesList.length - 1) + 1 i = rand(customSpeciesList.length - 1) + 1
n=0 n = 0
newspecies_dex = customSpeciesList[i] newspecies_dex = customSpeciesList[i]
while bstOk(newspecies_dex,oldSpecies_dex,bst_range) while bstOk(newspecies_dex, oldSpecies_dex, bst_range)
i = rand(customSpeciesList.length - 1)#+1 i = rand(customSpeciesList.length - 1) #+1
newspecies_dex = customSpeciesList[i] newspecies_dex = customSpeciesList[i]
n+=1 n += 1
if n % 10 == 0 if n % 10 == 0
bst_range+=5 bst_range += 5
end end
end end
return newspecies_dex return newspecies_dex
end end
def playShuffleSE(i) def playShuffleSE(i)
if i % 40 == 0 || i == 0 if i % 40 == 0 || i == 0
pbSEPlay("Charm",60) pbSEPlay("Charm", 60)
end end
end end
def getTrainersDataMode def getTrainersDataMode
mode = GameData::Trainer mode = GameData::Trainer
if $game_switches && $game_switches[SWITCH_MODERN_MODE] if $game_switches && $game_switches[SWITCH_MODERN_MODE]
mode = GameData::TrainerModern mode = GameData::TrainerModern
end end
return mode return mode
end 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)
if customsOnly && customsList == nil if customsOnly && customsList == nil
@@ -337,19 +316,19 @@ def Kernel.pbShuffleTrainers(bst_range = 50,customsOnly=false,customsList=nil)
trainers_data = GameData::Trainer.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
new_party = [] new_party = []
for poke in trainer.pokemon for poke in trainer.pokemon
old_poke = GameData::Species.get(poke[:species]).id_number old_poke = GameData::Species.get(poke[:species]).id_number
new_poke = customsOnly ? getNewCustomSpecies(old_poke,customsList,bst_range) : getNewSpecies(old_poke,bst_range) new_poke = customsOnly ? getNewCustomSpecies(old_poke, customsList, bst_range) : getNewSpecies(old_poke, bst_range)
new_party << new_poke new_party << new_poke
end end
randomTrainersHash[trainer.id] = new_party randomTrainersHash[trainer.id] = new_party
playShuffleSE(i) playShuffleSE(i)
i += 1 i += 1
if i % 2 == 0 if i % 2 == 0
n = (i.to_f/trainers.length)*100 n = (i.to_f / trainers.length) * 100
Kernel.pbMessageNoSound(_INTL("\\ts[]Shuffling trainers...\\n {1}%\\^",sprintf('%.2f', n),PBSpecies.maxValue)) Kernel.pbMessageNoSound(_INTL("\\ts[]Shuffling trainers...\\n {1}%\\^", sprintf('%.2f', n), PBSpecies.maxValue))
end end
end end
$PokemonGlobal.randomTrainersHash = randomTrainersHash $PokemonGlobal.randomTrainersHash = randomTrainersHash
@@ -382,21 +361,21 @@ def Kernel.pbShuffleTrainersCustom(bst_range = 50)
Kernel.pbMessage(_INTL("Parsing custom sprites folder")) Kernel.pbMessage(_INTL("Parsing custom sprites folder"))
customsList = getCustomSpeciesList() customsList = getCustomSpeciesList()
Kernel.pbMessage(_INTL("{1} Pokémon found",customsList.length.to_s)) Kernel.pbMessage(_INTL("{1} sprites found", customsList.length.to_s))
if customsList.length == 0 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("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.")) Kernel.pbMessage(_INTL("Trainer Pokémon will include auto-generated sprites."))
return Kernel.pbShuffleTrainers(bst_range) return Kernel.pbShuffleTrainers(bst_range) ##use regular shuffle if not enough sprites
elsif customsList.length < 200 end
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) ##use regular shuffle if not enough sprites
end
end end
Kernel.pbShuffleTrainers(bst_range,true ,customsList) Kernel.pbShuffleTrainers(bst_range, true, customsList)
end end
@@ -417,8 +396,6 @@ end
# end # end
# $PokemonGlobal.randomTrainersHash = randomTrainersHash # $PokemonGlobal.randomTrainersHash = randomTrainersHash
#def getRandomCustomSprite() #def getRandomCustomSprite()
# filesList = Dir["./Graphics/CustomBattlers/*"] # filesList = Dir["./Graphics/CustomBattlers/*"]
# i = rand(filesList.length-1) # i = rand(filesList.length-1)
@@ -430,44 +407,41 @@ end
# return (body*NB_POKEMON)+head # return (body*NB_POKEMON)+head
#end #end
def getCustomSpeciesList() def getCustomSpeciesList()
filesList = Dir["./Graphics/CustomBattlers/*"] filesList = Dir["./Graphics/CustomBattlers/*"]
speciesList = [] speciesList = []
maxDexNumber = (NB_POKEMON * NB_POKEMON) + NB_POKEMON maxDexNumber = (NB_POKEMON * NB_POKEMON) + NB_POKEMON
maxVal = filesList.length-1 maxVal = filesList.length - 1
for i in 0..maxVal for i in 0..maxVal
path = filesList[i] path = filesList[i]
file = File.basename(path, ".*") file = File.basename(path, ".*")
splitPoke = file.split(".") splitPoke = file.split(".")
head = splitPoke[0].to_i head = splitPoke[0].to_i
body = splitPoke[1].to_i body = splitPoke[1].to_i
fused = (body*NB_POKEMON)+head fused = (body * NB_POKEMON) + head
if fused <= maxDexNumber && fused > 0 if fused <= maxDexNumber && fused > 0
speciesList << fused speciesList << fused
end end
end end
return speciesList return speciesList
end end
def Kernel.getBaseStats(species) def Kernel.getBaseStats(species)
if $pkmn_dex[species] == nil if $pkmn_dex[species] == nil
print species 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 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() def Kernel.gymLeaderRematchHint()
hints = [ 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.", "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.",
@@ -488,73 +462,71 @@ def Kernel.gymLeaderRematchHint()
"Jasmine is on vacation in the Sevii Islands. She likes to rise up early to explore around the islands when no one's around." "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 = [] arr = []
n=0 n = 0
for i in 426..437 for i in 426..437
if !$game_switches[i] if !$game_switches[i]
arr.push(n) arr.push(n)
end end
n+=1 n += 1
end end
arr.push(508); arr.push(509); arr.push(510); arr.push(511); arr.push(508); arr.push(509); arr.push(510); arr.push(511);
n+=4 n += 4
if arr.length > 0 if arr.length > 0
return hints[arr[rand(arr.length)]] return hints[arr[rand(arr.length)]]
end end
return "You got every Gym Leader to come here. This place is more popular than ever!\nNow go and battle them!" return "You got every Gym Leader to come here. This place is more popular than ever!\nNow go and battle them!"
end end
def getTrainerParty(trainer) def getTrainerParty(trainer)
if $game_switches[47] if $game_switches[47]
for poke in trainer[3] for poke in trainer[3]
inverseFusion(poke) inverseFusion(poke)
end end
end end
return trainer[3] return trainer[3]
end end
def inverseFusion(pokemon) def inverseFusion(pokemon)
species=pokemon[TPSPECIES] species = pokemon[TPSPECIES]
return pokemon if species <= CONST_NB_POKE return pokemon if species <= CONST_NB_POKE
return pokemon if species > (CONST_NB_POKE * CONST_NB_POKE) + CONST_NB_POKE return pokemon if species > (CONST_NB_POKE * CONST_NB_POKE) + CONST_NB_POKE
body = getBasePokemonID(species,true) body = getBasePokemonID(species, true)
head = getBasePokemonID(species,false) head = getBasePokemonID(species, false)
newspecies = (head)*CONST_NB_POKE+body newspecies = (head) * CONST_NB_POKE + body
pokemon[TPSPECIES] = newspecies pokemon[TPSPECIES] = newspecies
return pokemon return pokemon
end end
def addRandomHeldItems(trainerParty) def addRandomHeldItems(trainerParty)
for poke in trainerParty for poke in trainerParty
if poke.item == nil if poke.item == nil
poke.item = PBItems::ORANBERRY#PBItems.sample poke.item = PBItems::ORANBERRY #PBItems.sample
end end
end end
end end
def addHealingItem(items) def addHealingItem(items)
if $Trainer.numbadges < 1 if $Trainer.numbadges < 1
items << PBItems::ORANBERRY items << PBItems::ORANBERRY
elsif $Trainer.numbadges <=2 elsif $Trainer.numbadges <= 2
items << PBItems::POTION items << PBItems::POTION
elsif $Trainer.numbadges <=4 elsif $Trainer.numbadges <= 4
items << PBItems::SUPERPOTION items << PBItems::SUPERPOTION
elsif $Trainer.numbadges <=6 elsif $Trainer.numbadges <= 6
items << PBItems::FULLHEAL items << PBItems::FULLHEAL
items << PBItems::SUPERPOTION items << PBItems::SUPERPOTION
elsif $Trainer.numbadges <= 8 elsif $Trainer.numbadges <= 8
items << PBItems::FULLHEAL items << PBItems::FULLHEAL
items << PBItems::HYPERPOTION items << PBItems::HYPERPOTION
elsif $Trainer.numbadges >= 9 elsif $Trainer.numbadges >= 9
items << PBItems::FULLRESTORE items << PBItems::FULLRESTORE
end end
return items return items
end end
#####Overload de pbLoadTrainer #####Overload de pbLoadTrainer
# #
# def pbLoadTrainer(trainerid,trainername,partyid=0) # def pbLoadTrainer(trainerid,trainername,partyid=0)
# if trainerid.is_a?(String) || trainerid.is_a?(Symbol) # if trainerid.is_a?(String) || trainerid.is_a?(Symbol)
@@ -664,65 +636,64 @@ end
# end # end
def getRematchId(trainername, trainerid) def getRematchId(trainername, trainerid)
return trainername + trainerid.to_s return trainername + trainerid.to_s
end end
def replaceRivalStarterIfNecessary(species) def replaceRivalStarterIfNecessary(species)
if species == RIVAL_STARTER_PLACEHOLDER_SPECIES if species == RIVAL_STARTER_PLACEHOLDER_SPECIES
if !$game_switches[840] || pbGet(250) == 0#not DEFINED_RIVAL_STARTER if !$game_switches[840] || pbGet(250) == 0 #not DEFINED_RIVAL_STARTER
fixRivalStarter() fixRivalStarter()
end
rivalStarter = pbGet(250)
if rivalStarter > 0
species = pbGet(250)
end
end end
return species rivalStarter = pbGet(250)
if rivalStarter > 0
species = pbGet(250)
end
end
return species
end end
def fixRivalStarter() def fixRivalStarter()
#set starter baseform #set starter baseform
if $PokemonGlobal.psuedoBSTHash == nil if $PokemonGlobal.psuedoBSTHash == nil
psuedoHash = Hash.new psuedoHash = Hash.new
for i in 0..NB_POKEMON for i in 0..NB_POKEMON
psuedoHash[i] = i psuedoHash[i] = i
end end
$PokemonGlobal.psuedoBSTHash = psuedoHash $PokemonGlobal.psuedoBSTHash = psuedoHash
end end
starterChoice = pbGet(7) starterChoice = pbGet(7)
s1 = $PokemonGlobal.psuedoBSTHash[1] s1 = $PokemonGlobal.psuedoBSTHash[1]
s2 = $PokemonGlobal.psuedoBSTHash[4] s2 = $PokemonGlobal.psuedoBSTHash[4]
s3= $PokemonGlobal.psuedoBSTHash[7] s3 = $PokemonGlobal.psuedoBSTHash[7]
setRivalStarter(s3,s2,s1,starterChoice) setRivalStarter(s3, s2, s1, starterChoice)
#evolve en fct des badges #evolve en fct des badges
rivalStarter = pbGet(250) rivalStarter = pbGet(250)
if $game_switches[68] #beat blue cerulean if $game_switches[68] #beat blue cerulean
rivalStarter = evolveBody(rivalStarter) rivalStarter = evolveBody(rivalStarter)
end end
if $game_switches[89] #beat blue SS Anne if $game_switches[89] #beat blue SS Anne
rivalStarter = evolveHead(rivalStarter) rivalStarter = evolveHead(rivalStarter)
end end
if $game_switches[228] #beat silph co if $game_switches[228] #beat silph co
rivalStarter = evolveBody(rivalStarter) rivalStarter = evolveBody(rivalStarter)
end end
if $game_switches[11] #got badge 8 if $game_switches[11] #got badge 8
rivalStarter = evolveHead(rivalStarter) rivalStarter = evolveHead(rivalStarter)
end end
if $game_switches[12] #beat league if $game_switches[12] #beat league
rivalStarter = evolveBody(rivalStarter) rivalStarter = evolveBody(rivalStarter)
rivalStarter = evolveHead(rivalStarter) rivalStarter = evolveHead(rivalStarter)
end end
#RIVAL_STARTER_IS_DEFINED #RIVAL_STARTER_IS_DEFINED
pbSet(250,rivalStarter) pbSet(250, rivalStarter)
$game_switches[840] = true $game_switches[840] = true
end end

View File

@@ -3,6 +3,9 @@ class PokemonGlobalMetadata
attr_accessor :psuedoBSTHash attr_accessor :psuedoBSTHash
attr_accessor :randomTrainersHash attr_accessor :randomTrainersHash
attr_accessor :randomGymTrainersHash attr_accessor :randomGymTrainersHash
attr_accessor :randomItemsHash
attr_accessor :randomTMsHash
alias random_init initialize alias random_init initialize
@@ -11,6 +14,9 @@ class PokemonGlobalMetadata
@randomGymTrainersHash = nil @randomGymTrainersHash = nil
@psuedoHash = nil @psuedoHash = nil
@psuedoBSTHash = nil @psuedoBSTHash = nil
@randomItemsHash = nil
@randomTMsHash = nil
end end
end end
@@ -82,7 +88,60 @@ def Kernel.pbShuffleDex(range = 50, type = 0)
$PokemonGlobal.psuedoBSTHash = get_randomized_bst_hash(pokemon_list,range,should_include_fusions) $PokemonGlobal.psuedoBSTHash = get_randomized_bst_hash(pokemon_list,range,should_include_fusions)
end end
def itemCanBeRandomized(item)
return false if item.is_machine?
return false if item.is_key_item?
return false if INVALID_ITEMS.include?(item.id)
#return false if RANDOM_ITEM_EXCEPTIONS.include?(item.id)
return true
end
def pbShuffleItems()
$game_switches[SWITCH_RANDOMIZED_AT_LEAST_ONCE] = true
randomItemsHash = Hash.new
available_items = []
for itemElement in GameData::Item.list_all
item=itemElement[1]
if itemCanBeRandomized(item)
if !available_items.include?(item.id)
available_items << item.id
end
end
end
remaining_items = available_items.clone
for itemId in available_items
if itemCanBeRandomized(GameData::Item.get(itemId))
chosenItem = remaining_items.sample
randomItemsHash[itemId] = chosenItem
remaining_items.delete(chosenItem)
end
end
$PokemonGlobal.randomItemsHash = randomItemsHash
end
def pbShuffleTMs()
$game_switches[SWITCH_RANDOMIZED_AT_LEAST_ONCE] = true
randomItemsHash = Hash.new
available_items = []
for itemElement in GameData::Item.list_all
item=itemElement[1]
if item.is_TM?
if !available_items.include?(item.id)
available_items << item.id
end
end
end
remaining_items = available_items.clone
for itemId in available_items
if GameData::Item.get(itemId).is_TM?
chosenItem = remaining_items.sample
randomItemsHash[itemId] = chosenItem
remaining_items.delete(chosenItem)
end
end
$PokemonGlobal.randomTMsHash = randomItemsHash
end
# #

View File

@@ -50,8 +50,20 @@ SWITCH_RANDOM_WILD_AREA = 777
SWITCH_RANDOM_TRAINERS = 987 SWITCH_RANDOM_TRAINERS = 987
SWITCH_RANDOM_STARTERS = 954 SWITCH_RANDOM_STARTERS = 954
SWITCH_RANDOM_ITEMS = 958
SWITCH_RANDOM_TMS = 959 SWITCH_RANDOM_ITEMS_GENERAL=759
SWITCH_RANDOM_ITEMS=751
SWITCH_RANDOM_FOUND_ITEMS=755
SWITCH_RANDOM_ITEMS_DYNAMIC = 958
SWITCH_RANDOM_ITEMS_MAPPED = 752
SWITCH_RANDOM_TMS = 758
SWITCH_RANDOM_GIVEN_ITEMS = 756
SWITCH_RANDOM_GIVEN_TMS = 757
SWITCH_RANDOM_SHOP_ITEMS = 754
SWITCH_RANDOM_FOUND_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

Binary file not shown.