randomizer - wild Pokémon

This commit is contained in:
infinitefusion
2022-04-30 23:27:05 -04:00
parent 2a76ee27e9
commit dd05aa1f1c
13 changed files with 158 additions and 47 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -550,7 +550,11 @@ end
#=============================================================================== #===============================================================================
# Main message-displaying function # Main message-displaying function
#=============================================================================== #===============================================================================
def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = nil) def pbMessageDisplayNoSound(msgwindow, message, letterbyletter = true, commandProc = nil)
pbMessageDisplay(msgwindow,message,letterbyletter,commandProc,false)
end
def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = nil,withSound=true)
return if !msgwindow return if !msgwindow
oldletterbyletter = msgwindow.letterbyletter oldletterbyletter = msgwindow.letterbyletter
msgwindow.letterbyletter = (letterbyletter) ? true : false msgwindow.letterbyletter = (letterbyletter) ? true : false
@@ -692,10 +696,12 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
end end
end end
end end
if startSE != nil if withSound
pbSEPlay(pbStringToAudioFile(startSE)) if startSE != nil
elsif signWaitCount == 0 && letterbyletter pbSEPlay(pbStringToAudioFile(startSE))
pbPlayDecisionSE() elsif signWaitCount == 0 && letterbyletter
pbPlayDecisionSE()
end
end end
########## Position message window ############## ########## Position message window ##############
pbRepositionMessageWindow(msgwindow, linecount) pbRepositionMessageWindow(msgwindow, linecount)
@@ -865,6 +871,23 @@ def pbMessage(message, commands = nil, cmdIfCancel = 0, skin = nil, defaultCmd =
return ret return ret
end end
def pbMessageNoSound(message, commands = nil, cmdIfCancel = 0, skin = nil, defaultCmd = 0, &block)
ret = 0
msgwindow = pbCreateMessageWindow(nil, skin)
if commands
ret = pbMessageDisplayNoSound(msgwindow, message, true,
proc { |msgwindow|
next Kernel.pbShowCommands(msgwindow, commands, cmdIfCancel, defaultCmd, &block)
}, &block)
else
pbMessageDisplay(msgwindow, message, &block)
end
pbDisposeMessageWindow(msgwindow)
Input.update
return ret
end
def pbConfirmMessage(message, &block) def pbConfirmMessage(message, &block)
return (pbMessage(message, [_INTL("Yes"), _INTL("No")], 2, &block) == 0) return (pbMessage(message, [_INTL("Yes"), _INTL("No")], 2, &block) == 0)
end end

View File

@@ -169,6 +169,7 @@ module GameData
trainer.lose_text = self.lose_text trainer.lose_text = self.lose_text
isRematch = $game_switches[SWITCH_IS_REMATCH] isRematch = $game_switches[SWITCH_IS_REMATCH]
isPlayingRandomized = $game_switches[SWITCH_RANDOM_TRAINERS] && !$game_switches[SWITCH_FIRST_RIVAL_BATTLE]
rematchId = getRematchId(trainer.name, trainer.trainer_type) rematchId = getRematchId(trainer.name, trainer.trainer_type)
# Create each Pokémon owned by the trainer # Create each Pokémon owned by the trainer

View File

@@ -191,18 +191,30 @@ Events.onChangeDirection += proc {
} }
def isFusionForced? def isFusionForced?
return false if $game_switches[SWITCH_RANDOMIZED_WILD_POKEMON] return false if $game_switches[SWITCH_RANDOM_WILD_TO_FUSION]
return $game_switches[SWITCH_FORCE_FUSE_NEXT_POKEMON] || $game_switches[SWITCH_FORCE_ALL_WILD_FUSIONS] return $game_switches[SWITCH_FORCE_FUSE_NEXT_POKEMON] || $game_switches[SWITCH_FORCE_ALL_WILD_FUSIONS]
end end
def isFusedEncounter def isFusedEncounter
return false if !SWITCH_FUSED_WILD_POKEMON[35] return false if !SWITCH_FUSED_WILD_POKEMON[35]
return false if $game_switches[SWITCH_RANDOMIZED_WILD_POKEMON] return false if $game_switches[SWITCH_RANDOM_WILD_TO_FUSION]
return true if isFusionForced?() return true if isFusionForced?()
chance = pbGet(VAR_WILD_FUSION_RATE) == 0 ? 5 : pbGet(VAR_WILD_FUSION_RATE) chance = pbGet(VAR_WILD_FUSION_RATE) == 0 ? 5 : pbGet(VAR_WILD_FUSION_RATE)
return (rand(chance) == 0) return (rand(chance) == 0)
end end
def getEncounter(encounter_type)
encounter = $PokemonEncounters.choose_wild_pokemon(encounter_type)
if $game_switches[SWITCH_RANDOM_WILD] #wild poke random activated
if $game_switches[SWITCH_WILD_RANDOM_GLOBAL] && encounter != nil
encounter[0] = getRandomizedTo(encounter[0])
end
end
return encounter
end
def pbBattleOnStepTaken(repel_active) def pbBattleOnStepTaken(repel_active)
return if $Trainer.able_pokemon_count == 0 return if $Trainer.able_pokemon_count == 0
return if !$PokemonEncounters.encounter_possible_here? return if !$PokemonEncounters.encounter_possible_here?
@@ -210,13 +222,16 @@ def pbBattleOnStepTaken(repel_active)
return if !encounter_type return if !encounter_type
return if !$PokemonEncounters.encounter_triggered?(encounter_type, repel_active) return if !$PokemonEncounters.encounter_triggered?(encounter_type, repel_active)
$PokemonTemp.encounterType = encounter_type $PokemonTemp.encounterType = encounter_type
encounter = $PokemonEncounters.choose_wild_pokemon(encounter_type)
encounter = getEncounter(encounter_type)
if isFusedEncounter() if isFusedEncounter()
encounter_fusedWith = $PokemonEncounters.choose_wild_pokemon(encounter_type) encounter_fusedWith = getEncounter(encounter_type)
if encounter[0] != encounter_fusedWith[0] if encounter[0] != encounter_fusedWith[0]
encounter[0] = getFusionSpecies(encounter[0], encounter_fusedWith[0]) encounter[0] = getFusionSpecies(encounter[0], encounter_fusedWith[0])
end end
end end
$game_switches[SWITCH_FORCE_FUSE_NEXT_POKEMON] = false $game_switches[SWITCH_FORCE_FUSE_NEXT_POKEMON] = false
encounter = EncounterModifier.trigger(encounter) encounter = EncounterModifier.trigger(encounter)

View File

@@ -59,9 +59,12 @@ class PokeRadar_UI
} }
end end
def addPokemonIcon(pokemonId, blackened = false, rare=false) def addPokemonIcon(species, blackened = false, rare=false)
pokemonId=dexNum(species)
iconId = _INTL("icon{1}", pokemonId) iconId = _INTL("icon{1}", pokemonId)
pokemonBitmap = pbCheckPokemonIconFiles(getDexNumberForSpecies(pokemonId)) pokemonBitmap = pbCheckPokemonIconFiles(getDexNumberForSpecies(pokemonId))
if rare if rare
outlineSprite = IconSprite.new(@current_x, @current_y) outlineSprite = IconSprite.new(@current_x, @current_y)
outlineSprite.setBitmap("Graphics/Pictures/Pokeradar/highlight") outlineSprite.setBitmap("Graphics/Pictures/Pokeradar/highlight")
@@ -69,8 +72,13 @@ class PokeRadar_UI
@sprites[iconId + "_outline"] = outlineSprite @sprites[iconId + "_outline"] = outlineSprite
end end
iconSprite = IconSprite.new(@current_x, @current_y) if pokemonId > NB_POKEMON
iconSprite.setBitmap(pokemonBitmap) iconSprite = createFusionIcon(pokemonId,@current_x,@current_y)
else
iconSprite = IconSprite.new(@current_x, @current_y)
iconSprite.setBitmap(pokemonBitmap)
end
@sprites[iconId] = iconSprite @sprites[iconId] = iconSprite
@sprites[iconId].src_rect.width /= 2 @sprites[iconId].src_rect.width /= 2
@@ -92,6 +100,29 @@ class PokeRadar_UI
end end
def createFusionIcon(pokemonId,x,y)
bodyPoke_number = getBodyID(pokemonId)
headPoke_number = getHeadID(pokemonId, bodyPoke_number)
bodyPoke = GameData::Species.get(bodyPoke_number).species
headPoke = GameData::Species.get(headPoke_number).species
bitmap1 = AnimatedBitmap.new(GameData::Species.icon_filename(headPoke))
bitmap2 = AnimatedBitmap.new(GameData::Species.icon_filename(bodyPoke))
for i in 0..bitmap1.width-1
for j in ((bitmap1.height / 2) + Settings::FUSION_ICON_SPRITE_OFFSET)..bitmap1.height-1
temp = bitmap2.bitmap.get_pixel(i, j)
bitmap1.bitmap.set_pixel(i, j, temp)
end
end
icon = IconSprite.new(x, y)
icon.setBitmapDirectly(bitmap1)
return icon
end
end end

View File

@@ -107,13 +107,15 @@ def pbPokeRadarCancel
$PokemonTemp.pokeradar = nil $PokemonTemp.pokeradar = nil
end end
def listPokemonInCurrentRoute(encounterType, onlySeen = false, onlyUnseen = false) def listPokemonInCurrentRoute(encounterType, onlySeen = false, onlyUnseen = false)
return [] if encounterType == nil return [] if encounterType == nil
processed = [] processed = []
seen = [] seen = []
unseen = [] unseen = []
for encounter in $PokemonEncounters.listPossibleEncounters(encounterType) for encounter in $PokemonEncounters.listPossibleEncounters(encounterType)
species = encounter[1] species = $game_switches[SWITCH_RANDOM_WILD] ? getRandomizedTo(encounter[1]) : encounter[1]
if !processed.include?(species) if !processed.include?(species)
if $Trainer.seen?(species) if $Trainer.seen?(species)
seen << species seen << species

View File

@@ -4,13 +4,6 @@ module OptionTypes
end end
class RandomizerOptionsScene < PokemonOption_Scene class RandomizerOptionsScene < PokemonOption_Scene
RANDOM_WILD = 778
RANDOM_TRAINERS = 987
RANDOM_STARTERS = 954
RANDOM_ITEMS = 958
RANDOM_TMS = 959
def initialize def initialize
super super
@openTrainerOptions = false @openTrainerOptions = false
@@ -29,45 +22,45 @@ 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("Starters"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[RANDOM_STARTERS] ? 0 : 1 }, proc { $game_switches[SWITCH_RANDOM_STARTERS] ? 0 : 1 },
proc { |value| proc { |value|
$game_switches[RANDOM_STARTERS] = value == 0 $game_switches[SWITCH_RANDOM_STARTERS] = value == 0
} }
), ),
EnumOption.new(_INTL("Trainers"), [_INTL("On"), _INTL("Off")], EnumOption.new(_INTL("Trainers"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[RANDOM_TRAINERS] ? 0 : 1 }, proc { $game_switches[SWITCH_RANDOM_TRAINERS] ? 0 : 1 },
proc { |value| proc { |value|
if !$game_switches[RANDOM_TRAINERS] && value == 0 if !$game_switches[SWITCH_RANDOM_TRAINERS] && value == 0
@openTrainerOptions = true @openTrainerOptions = true
openTrainerOptionsMenu() openTrainerOptionsMenu()
end end
$game_switches[RANDOM_TRAINERS] = value == 0 $game_switches[SWITCH_RANDOM_TRAINERS] = value == 0
} }
), ),
EnumOption.new(_INTL("Wild Pokémon"), [_INTL("On"), _INTL("Off")], EnumOption.new(_INTL("Wild Pokémon"), [_INTL("On"), _INTL("Off")],
proc { proc {
$game_switches[RANDOM_WILD] ? 0 : 1 $game_switches[SWITCH_RANDOM_WILD] ? 0 : 1
}, },
proc { |value| proc { |value|
if !$game_switches[RANDOM_WILD] && value == 0 if !$game_switches[SWITCH_RANDOM_WILD] && value == 0
@openWildOptions = true @openWildOptions = true
openWildPokemonOptionsMenu() openWildPokemonOptionsMenu()
end end
$game_switches[RANDOM_WILD] = value == 0 $game_switches[SWITCH_RANDOM_WILD] = value == 0
} }
), ),
EnumOption.new(_INTL("Items"), [_INTL("On"), _INTL("Off")], EnumOption.new(_INTL("Items"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[RANDOM_ITEMS] ? 0 : 1 }, proc { $game_switches[SWITCH_RANDOM_ITEMS] ? 0 : 1 },
proc { |value| proc { |value|
$game_switches[RANDOM_ITEMS] = value == 0 $game_switches[SWITCH_RANDOM_ITEMS] = value == 0
} }
), ),
EnumOption.new(_INTL("TMs"), [_INTL("On"), _INTL("Off")], EnumOption.new(_INTL("TMs"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[RANDOM_TMS] ? 0 : 1 }, proc { $game_switches[SWITCH_RANDOM_TMS] ? 0 : 1 },
proc { |value| proc { |value|
$game_switches[RANDOM_TMS] = value == 0 $game_switches[SWITCH_RANDOM_TMS] = value == 0
} }
), ),
] ]
@@ -226,6 +219,12 @@ class RandomizerWildPokemonOptionsScene < PokemonOption_Scene
$game_switches[REGULAR_TO_FUSIONS] = value == 0 $game_switches[REGULAR_TO_FUSIONS] = value == 0
} }
), ),
EnumOption.new(_INTL("Custom sprites only"), [_INTL("On"), _INTL("Off")],
proc { $game_switches[SWITCH_RANDOM_WILD_ONLY_CUSTOMS] ? 0 : 1 },
proc { |value|
$game_switches[SWITCH_RANDOM_WILD_ONLY_CUSTOMS] = value == 0
}
)
] ]
return options return options
end end

View File

@@ -17,11 +17,10 @@ end
# randomizer shuffle # randomizer shuffle
# ############## # ##############
def Kernel.pbShuffleDex(range=50,type=0) def Kernel.pbShuffleDex(range=50,type=0)
$game_switches[855] = true # Randomized at least once $game_switches[SWITCH_RANDOMIZED_AT_LEAST_ONCE] = true
#type 0: BST #type 0: BST
#type 1: full random #type 1: full random
#type: 2 by route (not implemented)
range = 1 if range == 0 range = 1 if range == 0
# create hash # create hash
psuedoHash = Hash.new psuedoHash = Hash.new
@@ -55,15 +54,18 @@ def Kernel.pbShuffleDex(range=50,type=0)
#BST in the same 100 range #BST in the same 100 range
for i in 1..NB_POKEMON-1#pas de arceus for i in 1..NB_POKEMON-1
baseStats=$pkmn_dex[i][5] baseStats=getBaseStatsFormattedForRandomizer(i)
baseStat_target = 0 baseStat_target = 0
for k in 0...baseStats.length for k in 0...baseStats.length
baseStat_target+=baseStats[k] baseStat_target+=baseStats[k]
end end
baseStat_target = (baseStat_target/range).floor baseStat_target = (baseStat_target/range).floor
for j in 1...pokeArrayRand.length for j in 1...pokeArrayRand.length
baseStats=$pkmn_dex[pokeArrayRand[j]][5] if $game_switches[SWITCH_RANDOM_WILD_ONLY_CUSTOMS] && $game_switches[SWITCH_RANDOM_WILD_TO_FUSION] && !customSpriteExists(pokeArrayRand[j])
next
end
baseStats=getBaseStatsFormattedForRandomizer(pokeArrayRand[j])
baseStat_temp = 0 baseStat_temp = 0
for l in 0...baseStats.length for l in 0...baseStats.length
baseStat_temp+=baseStats[l] baseStat_temp+=baseStats[l]
@@ -81,7 +83,6 @@ def Kernel.pbShuffleDex(range=50,type=0)
n = (i.to_f/NB_POKEMON)*100 n = (i.to_f/NB_POKEMON)*100
Kernel.pbMessageNoSound(_INTL("\\ts[]Shuffling wild Pokémon...\\n {1}%\\^",sprintf('%.2f', n),NB_POKEMON)) Kernel.pbMessageNoSound(_INTL("\\ts[]Shuffling wild Pokémon...\\n {1}%\\^",sprintf('%.2f', n),NB_POKEMON))
end end
break break
end end
end end
@@ -111,6 +112,19 @@ def Kernel.raisePartyHappiness(increment)
end end
#Randomizer code is shit. Too lazy to redo it.
# Here is a cheap workaround lol
def getBaseStatsFormattedForRandomizer(dex_num)
statsArray=[]
stats = GameData::Species.get(dex_num).base_stats
statsArray << stats[:HP]
statsArray << stats[:ATTACK]
statsArray << stats[:DEFENSE]
statsArray << stats[:SPECIAL_ATTACK]
statsArray << stats[:SPECIAL_DEFENSE]
statsArray << stats[:SPEED]
return statsArray
end
def Kernel.pbShuffleDexTrainers() def Kernel.pbShuffleDexTrainers()
# create hash # create hash
@@ -141,14 +155,14 @@ def Kernel.pbShuffleDexTrainers()
#Kernel.pbMessage(_INTL("\\ts[]Shuffling...\\n {1}%\\^",sprintf('%.2f', n),PBSpecies.maxValue)) #Kernel.pbMessage(_INTL("\\ts[]Shuffling...\\n {1}%\\^",sprintf('%.2f', n),PBSpecies.maxValue))
end end
baseStats=$pkmn_dex[i][I] baseStats=calcBaseStats(i)
baseStat_target = 0 baseStat_target = 0
for k in 0...baseStats.length for k in 0...baseStats.length
baseStat_target+=baseStats[k] baseStat_target+=baseStats[k]
end end
baseStat_target = (baseStat_target/50).floor baseStat_target = (baseStat_target/50).floor
for j in 1...pokeArrayRand.length for j in 1...pokeArrayRand.length
baseStats=$pkmn_dex[pokeArrayRand[j]][5] baseStats=calcBaseStats([pokeArrayRand[j]])
baseStat_temp = 0 baseStat_temp = 0
for l in 0...baseStats.length for l in 0...baseStats.length
baseStat_temp+=baseStats[l] baseStat_temp+=baseStats[l]
@@ -166,4 +180,10 @@ def Kernel.pbShuffleDexTrainers()
#add hashes to global data0 #add hashes to global data0
#$PokemonGlobal.psuedoHash = psuedoHash #$PokemonGlobal.psuedoHash = psuedoHash
$PokemonGlobal.pseudoBSTHashTrainers = psuedoBSTHash $PokemonGlobal.pseudoBSTHashTrainers = psuedoBSTHash
end
def getRandomizedTo(species)
return species if !$PokemonGlobal.psuedoBSTHash
return $PokemonGlobal.psuedoBSTHash[dexNum(species)]
# code here
end end

View File

@@ -40,12 +40,17 @@ SWITCH_GOT_BADGE_15 = 45
SWITCH_GOT_BADGE_16 = 50 SWITCH_GOT_BADGE_16 = 50
#Randomizer Switches #Randomizer Switches
SWITCH_RANDOMIZED_WILD_POKEMON=953 SWITCH_RANDOM_WILD_TO_FUSION=953
SWITCH_FUSED_WILD_POKEMON=35
SWITCH_FORCE_FUSE_NEXT_POKEMON=37
SWITCH_FORCE_ALL_WILD_FUSIONS=828
SWITCH_USED_AN_INCENSE=798
SWITCH_RANDOMIZED_AT_LEAST_ONCE = 855 SWITCH_RANDOMIZED_AT_LEAST_ONCE = 855
SWITCH_RANDOM_WILD = 778
SWITCH_RANDOM_TRAINERS = 987
SWITCH_RANDOM_STARTERS = 954
SWITCH_RANDOM_ITEMS = 958
SWITCH_RANDOM_TMS = 959
SWITCH_WILD_RANDOM_GLOBAL=956
SWITCH_RANDOM_STATIC_ENCOUNTERS=955
SWITCH_RANDOM_WILD_ONLY_CUSTOMS=664
#Random switches #Random switches
SWITCH_RACE_BIKE = 984 SWITCH_RACE_BIKE = 984
@@ -55,7 +60,11 @@ SWITCH_SINGLE_POKEMON_MODE_HEAD=791
SWITCH_SINGLE_POKEMON_MODE_BODY=792 SWITCH_SINGLE_POKEMON_MODE_BODY=792
SWITCH_SINGLE_POKEMON_MODE_RANDOM=793 SWITCH_SINGLE_POKEMON_MODE_RANDOM=793
SWITCH_FISHING_AUTOHOOK = 916 SWITCH_FISHING_AUTOHOOK = 916
SWITCH_FUSED_WILD_POKEMON=35
SWITCH_FORCE_FUSE_NEXT_POKEMON=37
SWITCH_FORCE_ALL_WILD_FUSIONS=828
SWITCH_USED_AN_INCENSE=798
SWITCH_FIRST_RIVAL_BATTLE=46
############# #############
@@ -71,8 +80,13 @@ VAR_CUSTOM_SPRITES_ENABLED= 196
VAR_COMMAND_WINDOW_INDEX=249 VAR_COMMAND_WINDOW_INDEX=249
VAR_STANDARD_WONDERTRADE_LEFT=248 VAR_STANDARD_WONDERTRADE_LEFT=248
VAR_PREMIUM_WONDERTRADE_LEFT=111 VAR_PREMIUM_WONDERTRADE_LEFT=111
VAR_PREMIUM_WONDERTRADE_LEFT=111
#Randomizer
VAR_RANDOMIZER_WILD_POKE_BST=197
#OTHERS #############
# OTHERS #
#############
DIRECTION_LEFT = 4 DIRECTION_LEFT = 4
DIRECTION_RIGHT = 6 DIRECTION_RIGHT = 6
DIRECTION_DOWN = 2 DIRECTION_DOWN = 2

View File

@@ -118,6 +118,10 @@ def getPokemon(dexNum)
return GameData::Species.get(dexNum) return GameData::Species.get(dexNum)
end end
def getSpecies(dexnum)
return getPokemon(dexnum)
end
#shortcut for using in game events because of script characters limit #shortcut for using in game events because of script characters limit
def dexNum(species) def dexNum(species)
return getDexNumberForSpecies(species) return getDexNumberForSpecies(species)

View File

@@ -170,6 +170,8 @@ def pbGRS(minBST, chosenBST, luck, rare, except2)
return species return species
end end
def calcBaseStats(species) def calcBaseStats(species)
stats = GameData::Species.get(species).base_stats stats = GameData::Species.get(species).base_stats
sum = 0 sum = 0

Binary file not shown.