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

View File

@@ -121,22 +121,26 @@ end
# variables that should remain valid only for the current map.
#===============================================================================
class PokemonMapMetadata
attr_reader :erasedEvents
attr_reader :movedEvents
attr_reader :erasedEvents
attr_reader :movedEvents
attr_accessor :strengthUsed
attr_accessor :blackFluteUsed
attr_accessor :whiteFluteUsed
attr_accessor :lower_encounter_rate # Black Flute's old effect
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
clear
end
def clear
@erasedEvents = {}
@movedEvents = {}
@strengthUsed = false
@blackFluteUsed = false
@whiteFluteUsed = false
@erasedEvents = {}
@movedEvents = {}
@strengthUsed = false
@lower_encounter_rate = false # Takes priority over @higher_encounter_rate
@higher_encounter_rate = false
@lower_level_wild_pokemon = false # Takes priority over @higher_level_wild_pokemon
@higher_level_wild_pokemon = false
end
def addErasedEvent(eventID)
@@ -145,8 +149,8 @@ class PokemonMapMetadata
end
def addMovedEvent(eventID)
key = [$game_map.map_id, eventID]
event = $game_map.events[eventID] if eventID.is_a?(Integer)
key = [$game_map.map_id, eventID]
event = $game_map.events[eventID] if eventID.is_a?(Integer)
@movedEvents[key] = [event.x, event.y, event.direction, event.through] if event
end

View File

@@ -159,17 +159,29 @@ EventHandlers.add(:on_player_step_taken, :repel_counter,
ItemHandlers::UseInField.add(:BLACKFLUTE, proc { |item|
pbUseItemMessage(item)
pbMessage(_INTL("Wild Pokémon will be repelled."))
$PokemonMap.blackFluteUsed = true
$PokemonMap.whiteFluteUsed = false
if Settings::FLUTES_CHANGE_WILD_ENCOUNTER_LEVELS
pbMessage(_INTL("Now you're more likely to encounter high-level Pokémon!"))
$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
})
ItemHandlers::UseInField.add(:WHITEFLUTE, proc { |item|
pbUseItemMessage(item)
pbMessage(_INTL("Wild Pokémon will be lured."))
$PokemonMap.blackFluteUsed = false
$PokemonMap.whiteFluteUsed = true
if Settings::FLUTES_CHANGE_WILD_ENCOUNTER_LEVELS
pbMessage(_INTL("Now you're more likely to encounter low-level Pokémon!"))
$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
})

View File

@@ -84,18 +84,24 @@ class PokemonJukeboxScreen
elsif cmdMarch >= 0 && cmd == cmdMarch
pbPlayDecisionSE
pbBGMPlay("Radio - March", 100, 100)
$PokemonMap.whiteFluteUsed = true if $PokemonMap
$PokemonMap.blackFluteUsed = false if $PokemonMap
if $PokemonMap
$PokemonMap.lower_encounter_rate = false
$PokemonMap.higher_encounter_rate = true
end
elsif cmdLullaby >= 0 && cmd == cmdLullaby
pbPlayDecisionSE
pbBGMPlay("Radio - Lullaby", 100, 100)
$PokemonMap.blackFluteUsed = true if $PokemonMap
$PokemonMap.whiteFluteUsed = false if $PokemonMap
if $PokemonMap
$PokemonMap.lower_encounter_rate = true
$PokemonMap.higher_encounter_rate = false
end
elsif cmdOak >= 0 && cmd == cmdOak
pbPlayDecisionSE
pbBGMPlay("Radio - Oak", 100, 100)
$PokemonMap.whiteFluteUsed = false if $PokemonMap
$PokemonMap.blackFluteUsed = false if $PokemonMap
if $PokemonMap
$PokemonMap.lower_encounter_rate = false
$PokemonMap.higher_encounter_rate = false
end
elsif cmdCustom >= 0 && cmd == cmdCustom
pbPlayDecisionSE
files = []
@@ -117,16 +123,20 @@ class PokemonJukeboxScreen
end
pbPlayDecisionSE
$game_system.setDefaultBGM(files[cmd2])
$PokemonMap.whiteFluteUsed = false if $PokemonMap
$PokemonMap.blackFluteUsed = false if $PokemonMap
if $PokemonMap
$PokemonMap.lower_encounter_rate = false
$PokemonMap.higher_encounter_rate = false
end
end
@scene.pbSetCommands(nil, cmdCustom)
elsif cmdTurnOff >= 0 && cmd == cmdTurnOff
pbPlayDecisionSE
$game_system.setDefaultBGM(nil)
pbBGMPlay(pbResolveAudioFile($game_map.bgm_name, $game_map.bgm.volume, $game_map.bgm.pitch))
$PokemonMap.whiteFluteUsed = false if $PokemonMap
$PokemonMap.blackFluteUsed = false if $PokemonMap
if $PokemonMap
$PokemonMap.lower_encounter_rate = false
$PokemonMap.higher_encounter_rate = false
end
else # Exit
pbPlayCloseMenuSE
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, {
"name" => _INTL("Refresh Map"),
"parent" => :field_menu,
@@ -118,7 +173,7 @@ MenuHandlers.add(:debug_menu, :storage_wallpapers, {
paperscmds.push(_INTL("Unlock all"))
paperscmds.push(_INTL("Lock all"))
(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
paperscmd = pbShowCommands(nil, paperscmds, -1, paperscmd)
break if paperscmd < 0
@@ -755,7 +810,7 @@ MenuHandlers.add(:debug_menu, :set_badges, {
badgecmds.push(_INTL("Give all"))
badgecmds.push(_INTL("Remove all"))
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
badgecmd = pbShowCommands(nil, badgecmds, -1, badgecmd)
break if badgecmd < 0
@@ -795,7 +850,7 @@ MenuHandlers.add(:debug_menu, :toggle_pokedex, {
dex_names.length.times do |i|
name = (dex_names[i].is_a?(Array)) ? dex_names[i][0] : dex_names[i]
unlocked = $player.pokedex.unlocked?(i)
dexescmds.push(_INTL("{1} {2}", unlocked ? "[Y]" : "[ ]", name))
dexescmds.push((unlocked ? "[Y]" : "[ ]") + " " + name)
end
dexescmd = pbShowCommands(nil, dexescmds, -1, dexescmd)
break if dexescmd < 0