Added Debug function to edit Repel steps, Flash/Strength usage and Black/White Flute effects; split old and new Black/White Flute effects

This commit is contained in:
Maruno17
2023-05-05 20:17:07 +01:00
parent 48fb8dae73
commit 72469bbf79
6 changed files with 146 additions and 41 deletions

View File

@@ -379,3 +379,28 @@ SaveData.register_conversion(:v21_replace_phone_data) do
end end
end end
end end
SaveData.register_conversion(:v21_replace_flute_booleans) do
essentials_version 21
display_title "Updating Black/White Flute variables"
to_value :map_metadata do |metadata|
metadata.instance_eval do
if !@blackFluteUsed.nil?
if Settings::FLUTES_CHANGE_WILD_ENCOUNTER_LEVELS
@higher_level_wild_pokemon = @blackFluteUsed
else
@lower_encounter_rate = @blackFluteUsed
end
@blackFluteUsed = nil
end
if !@whiteFluteUsed.nil?
if Settings::FLUTES_CHANGE_WILD_ENCOUNTER_LEVELS
@lower_level_wild_pokemon = @whiteFluteUsed
else
@higher_encounter_rate = @whiteFluteUsed
end
@whiteFluteUsed = nil
end
end
end
end

View File

@@ -120,11 +120,12 @@ class PokemonEncounters
encounter_chance += @chance_accumulator / 200 encounter_chance += @chance_accumulator / 200
encounter_chance *= 0.8 if $PokemonGlobal.bicycle encounter_chance *= 0.8 if $PokemonGlobal.bicycle
end end
if !Settings::FLUTES_CHANGE_WILD_ENCOUNTER_LEVELS if $PokemonMap.lower_encounter_rate
encounter_chance /= 2 if $PokemonMap.blackFluteUsed encounter_chance /= 2
min_steps_needed *= 2 if $PokemonMap.blackFluteUsed min_steps_needed *= 2
encounter_chance *= 1.5 if $PokemonMap.whiteFluteUsed elsif $PokemonMap.higher_encounter_rate
min_steps_needed /= 2 if $PokemonMap.whiteFluteUsed encounter_chance *= 1.5
min_steps_needed /= 2
end end
first_pkmn = $player.first_pokemon first_pkmn = $player.first_pokemon
if first_pkmn if first_pkmn
@@ -333,12 +334,10 @@ class PokemonEncounters
end end
end end
# Black Flute and White Flute alter the level of the wild Pokémon # Black Flute and White Flute alter the level of the wild Pokémon
if Settings::FLUTES_CHANGE_WILD_ENCOUNTER_LEVELS if $PokemonMap.lower_level_wild_pokemon
if $PokemonMap.blackFluteUsed
level = [level + rand(1..4), GameData::GrowthRate.max_level].min
elsif $PokemonMap.whiteFluteUsed
level = [level - rand(1..4), 1].max level = [level - rand(1..4), 1].max
end elsif $PokemonMap.higher_level_wild_pokemon
level = [level + rand(1..4), GameData::GrowthRate.max_level].min
end end
# Return [species, level] # Return [species, level]
return [encounter[1], level] return [encounter[1], level]

View File

@@ -124,8 +124,10 @@ class PokemonMapMetadata
attr_reader :erasedEvents attr_reader :erasedEvents
attr_reader :movedEvents attr_reader :movedEvents
attr_accessor :strengthUsed attr_accessor :strengthUsed
attr_accessor :blackFluteUsed attr_accessor :lower_encounter_rate # Black Flute's old effect
attr_accessor :whiteFluteUsed attr_accessor :higher_encounter_rate # White Flute's old effect
attr_accessor :lower_level_wild_pokemon # White Flute's new effect
attr_accessor :higher_level_wild_pokemon # Black Flute's new effect
def initialize def initialize
clear clear
@@ -135,8 +137,10 @@ class PokemonMapMetadata
@erasedEvents = {} @erasedEvents = {}
@movedEvents = {} @movedEvents = {}
@strengthUsed = false @strengthUsed = false
@blackFluteUsed = false @lower_encounter_rate = false # Takes priority over @higher_encounter_rate
@whiteFluteUsed = false @higher_encounter_rate = false
@lower_level_wild_pokemon = false # Takes priority over @higher_level_wild_pokemon
@higher_level_wild_pokemon = false
end end
def addErasedEvent(eventID) def addErasedEvent(eventID)

View File

@@ -159,17 +159,29 @@ EventHandlers.add(:on_player_step_taken, :repel_counter,
ItemHandlers::UseInField.add(:BLACKFLUTE, proc { |item| ItemHandlers::UseInField.add(:BLACKFLUTE, proc { |item|
pbUseItemMessage(item) pbUseItemMessage(item)
pbMessage(_INTL("Wild Pokémon will be repelled.")) if Settings::FLUTES_CHANGE_WILD_ENCOUNTER_LEVELS
$PokemonMap.blackFluteUsed = true pbMessage(_INTL("Now you're more likely to encounter high-level Pokémon!"))
$PokemonMap.whiteFluteUsed = false $PokemonMap.higher_level_wild_pokemon = true
$PokemonMap.lower_level_wild_pokemon = false
else
pbMessage(_INTL("The likelihood of encountering Pokémon decreased!"))
$PokemonMap.lower_encounter_rate = true
$PokemonMap.higher_encounter_rate = false
end
next true next true
}) })
ItemHandlers::UseInField.add(:WHITEFLUTE, proc { |item| ItemHandlers::UseInField.add(:WHITEFLUTE, proc { |item|
pbUseItemMessage(item) pbUseItemMessage(item)
pbMessage(_INTL("Wild Pokémon will be lured.")) if Settings::FLUTES_CHANGE_WILD_ENCOUNTER_LEVELS
$PokemonMap.blackFluteUsed = false pbMessage(_INTL("Now you're more likely to encounter low-level Pokémon!"))
$PokemonMap.whiteFluteUsed = true $PokemonMap.lower_level_wild_pokemon = true
$PokemonMap.higher_level_wild_pokemon = false
else
pbMessage(_INTL("The likelihood of encountering Pokémon increased!"))
$PokemonMap.higher_encounter_rate = true
$PokemonMap.lower_encounter_rate = false
end
next true next true
}) })

View File

@@ -84,18 +84,24 @@ class PokemonJukeboxScreen
elsif cmdMarch >= 0 && cmd == cmdMarch elsif cmdMarch >= 0 && cmd == cmdMarch
pbPlayDecisionSE pbPlayDecisionSE
pbBGMPlay("Radio - March", 100, 100) pbBGMPlay("Radio - March", 100, 100)
$PokemonMap.whiteFluteUsed = true if $PokemonMap if $PokemonMap
$PokemonMap.blackFluteUsed = false if $PokemonMap $PokemonMap.lower_encounter_rate = false
$PokemonMap.higher_encounter_rate = true
end
elsif cmdLullaby >= 0 && cmd == cmdLullaby elsif cmdLullaby >= 0 && cmd == cmdLullaby
pbPlayDecisionSE pbPlayDecisionSE
pbBGMPlay("Radio - Lullaby", 100, 100) pbBGMPlay("Radio - Lullaby", 100, 100)
$PokemonMap.blackFluteUsed = true if $PokemonMap if $PokemonMap
$PokemonMap.whiteFluteUsed = false if $PokemonMap $PokemonMap.lower_encounter_rate = true
$PokemonMap.higher_encounter_rate = false
end
elsif cmdOak >= 0 && cmd == cmdOak elsif cmdOak >= 0 && cmd == cmdOak
pbPlayDecisionSE pbPlayDecisionSE
pbBGMPlay("Radio - Oak", 100, 100) pbBGMPlay("Radio - Oak", 100, 100)
$PokemonMap.whiteFluteUsed = false if $PokemonMap if $PokemonMap
$PokemonMap.blackFluteUsed = false if $PokemonMap $PokemonMap.lower_encounter_rate = false
$PokemonMap.higher_encounter_rate = false
end
elsif cmdCustom >= 0 && cmd == cmdCustom elsif cmdCustom >= 0 && cmd == cmdCustom
pbPlayDecisionSE pbPlayDecisionSE
files = [] files = []
@@ -117,16 +123,20 @@ class PokemonJukeboxScreen
end end
pbPlayDecisionSE pbPlayDecisionSE
$game_system.setDefaultBGM(files[cmd2]) $game_system.setDefaultBGM(files[cmd2])
$PokemonMap.whiteFluteUsed = false if $PokemonMap if $PokemonMap
$PokemonMap.blackFluteUsed = false if $PokemonMap $PokemonMap.lower_encounter_rate = false
$PokemonMap.higher_encounter_rate = false
end
end end
@scene.pbSetCommands(nil, cmdCustom) @scene.pbSetCommands(nil, cmdCustom)
elsif cmdTurnOff >= 0 && cmd == cmdTurnOff elsif cmdTurnOff >= 0 && cmd == cmdTurnOff
pbPlayDecisionSE pbPlayDecisionSE
$game_system.setDefaultBGM(nil) $game_system.setDefaultBGM(nil)
pbBGMPlay(pbResolveAudioFile($game_map.bgm_name, $game_map.bgm.volume, $game_map.bgm.pitch)) pbBGMPlay(pbResolveAudioFile($game_map.bgm_name, $game_map.bgm.volume, $game_map.bgm.pitch))
$PokemonMap.whiteFluteUsed = false if $PokemonMap if $PokemonMap
$PokemonMap.blackFluteUsed = false if $PokemonMap $PokemonMap.lower_encounter_rate = false
$PokemonMap.higher_encounter_rate = false
end
else # Exit else # Exit
pbPlayCloseMenuSE pbPlayCloseMenuSE
break break

View File

@@ -65,6 +65,61 @@ MenuHandlers.add(:debug_menu, :variables, {
} }
}) })
MenuHandlers.add(:debug_menu, :edit_field_effects, {
"name" => _INTL("Change Field Effects"),
"parent" => :field_menu,
"description" => _INTL("Edit Repel steps, Strength and Flash usage, and Black/White Flute effects."),
"effect" => proc {
cmd = 0
loop do
cmds = []
cmds.push(_INTL("Repel steps: {1}", $PokemonGlobal.repel))
cmds.push(($PokemonMap.strengthUsed ? "[Y]" : "[ ]") + " " + _INTL("Strength used"))
cmds.push(($PokemonGlobal.flashUsed ? "[Y]" : "[ ]") + " " + _INTL("Flash used"))
cmds.push(($PokemonMap.lower_encounter_rate ? "[Y]" : "[ ]") + " " + _INTL("Lower encounter rate"))
cmds.push(($PokemonMap.higher_encounter_rate ? "[Y]" : "[ ]") + " " + _INTL("Higher encounter rate"))
cmds.push(($PokemonMap.lower_level_wild_pokemon ? "[Y]" : "[ ]") + " " + _INTL("Lower level wild Pokémon"))
cmds.push(($PokemonMap.higher_level_wild_pokemon ? "[Y]" : "[ ]") + " " + _INTL("Higher level wild Pokémon"))
cmd = pbShowCommands(nil, cmds, -1, cmd)
break if cmd < 0
case cmd
when 0 # Repel steps
params = ChooseNumberParams.new
params.setRange(0, 99999)
params.setDefaultValue($PokemonGlobal.repel)
$PokemonGlobal.repel = pbMessageChooseNumber(_INTL("Set the Pokémon's level."), params)
when 1 # Strength used
$PokemonMap.strengthUsed = !$PokemonMap.strengthUsed
when 2 # Flash used
if $game_map.metadata&.dark_map && $scene.is_a?(Scene_Map)
$PokemonGlobal.flashUsed = !$PokemonGlobal.flashUsed
darkness = $game_temp.darkness_sprite
darkness.dispose if darkness && !darkness.disposed?
$game_temp.darkness_sprite = DarknessSprite.new
$scene.spriteset&.addUserSprite($game_temp.darkness_sprite)
if $PokemonGlobal.flashUsed
$game_temp.darkness_sprite.radius = $game_temp.darkness_sprite.radiusMax
end
else
pbMessage(_INTL("You're not in a dark map!"))
end
when 3 # Lower encounter rate
$PokemonMap.lower_encounter_rate ||= false
$PokemonMap.lower_encounter_rate = !$PokemonMap.lower_encounter_rate
when 4 # Higher encounter rate
$PokemonMap.higher_encounter_rate ||= false
$PokemonMap.higher_encounter_rate = !$PokemonMap.higher_encounter_rate
when 5 # Lower level wild Pokémon
$PokemonMap.lower_level_wild_pokemon ||= false
$PokemonMap.lower_level_wild_pokemon = !$PokemonMap.lower_level_wild_pokemon
when 6 # Higher level wild Pokémon
$PokemonMap.higher_level_wild_pokemon ||= false
$PokemonMap.higher_level_wild_pokemon = !$PokemonMap.higher_level_wild_pokemon
end
end
}
})
MenuHandlers.add(:debug_menu, :refresh_map, { MenuHandlers.add(:debug_menu, :refresh_map, {
"name" => _INTL("Refresh Map"), "name" => _INTL("Refresh Map"),
"parent" => :field_menu, "parent" => :field_menu,
@@ -118,7 +173,7 @@ MenuHandlers.add(:debug_menu, :storage_wallpapers, {
paperscmds.push(_INTL("Unlock all")) paperscmds.push(_INTL("Unlock all"))
paperscmds.push(_INTL("Lock all")) paperscmds.push(_INTL("Lock all"))
(PokemonStorage::BASICWALLPAPERQTY...w.length).each do |i| (PokemonStorage::BASICWALLPAPERQTY...w.length).each do |i|
paperscmds.push(_INTL("{1} {2}", unlockarray[i] ? "[Y]" : "[ ]", w[i])) paperscmds.push((unlockarray[i] ? "[Y]" : "[ ]") + " " + w[i])
end end
paperscmd = pbShowCommands(nil, paperscmds, -1, paperscmd) paperscmd = pbShowCommands(nil, paperscmds, -1, paperscmd)
break if paperscmd < 0 break if paperscmd < 0
@@ -755,7 +810,7 @@ MenuHandlers.add(:debug_menu, :set_badges, {
badgecmds.push(_INTL("Give all")) badgecmds.push(_INTL("Give all"))
badgecmds.push(_INTL("Remove all")) badgecmds.push(_INTL("Remove all"))
24.times do |i| 24.times do |i|
badgecmds.push(_INTL("{1} Badge {2}", $player.badges[i] ? "[Y]" : "[ ]", i + 1)) badgecmds.push(($player.badges[i] ? "[Y]" : "[ ]") + " " + _INTL("Badge {1}", i + 1))
end end
badgecmd = pbShowCommands(nil, badgecmds, -1, badgecmd) badgecmd = pbShowCommands(nil, badgecmds, -1, badgecmd)
break if badgecmd < 0 break if badgecmd < 0
@@ -795,7 +850,7 @@ MenuHandlers.add(:debug_menu, :toggle_pokedex, {
dex_names.length.times do |i| dex_names.length.times do |i|
name = (dex_names[i].is_a?(Array)) ? dex_names[i][0] : dex_names[i] name = (dex_names[i].is_a?(Array)) ? dex_names[i][0] : dex_names[i]
unlocked = $player.pokedex.unlocked?(i) unlocked = $player.pokedex.unlocked?(i)
dexescmds.push(_INTL("{1} {2}", unlocked ? "[Y]" : "[ ]", name)) dexescmds.push((unlocked ? "[Y]" : "[ ]") + " " + name)
end end
dexescmd = pbShowCommands(nil, dexescmds, -1, dexescmd) dexescmd = pbShowCommands(nil, dexescmds, -1, dexescmd)
break if dexescmd < 0 break if dexescmd < 0