Files
infinitefusion-e18/Data/Scripts/021_Debug/003_Debug_PokemonCommands.rb
2020-12-30 01:36:44 +00:00

1085 lines
36 KiB
Ruby

#===============================================================================
#
#===============================================================================
module PokemonDebugMenuCommands
@@commands = HandlerHashBasic.new
def self.register(option, hash)
@@commands.add(option, hash)
end
def self.registerIf(condition, hash)
@@commands.addIf(condition, hash)
end
def self.copy(option, *new_options)
@@commands.copy(option, *new_options)
end
def self.each
@@commands.each { |key, hash| yield key, hash }
end
def self.hasFunction?(option, function)
option_hash = @@commands[option]
return option_hash && option_hash.keys.include?(function)
end
def self.getFunction(option, function)
option_hash = @@commands[option]
return (option_hash && option_hash[function]) ? option_hash[function] : nil
end
def self.call(function, option, *args)
option_hash = @@commands[option]
return nil if !option_hash || !option_hash[function]
return (option_hash[function].call(*args) == true)
end
end
#===============================================================================
# HP/Status options
#===============================================================================
PokemonDebugMenuCommands.register("hpstatusmenu", {
"parent" => "main",
"name" => _INTL("HP/Status..."),
"always_show" => true
})
PokemonDebugMenuCommands.register("sethp", {
"parent" => "hpstatusmenu",
"name" => _INTL("Set HP"),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
if pkmn.egg?
screen.pbDisplay(_INTL("{1} is an egg.", pkmn.name))
else
params = ChooseNumberParams.new
params.setRange(0, pkmn.totalhp)
params.setDefaultValue(pkmn.hp)
newhp = pbMessageChooseNumber(
_INTL("Set {1}'s HP (max. {2}).", pkmn.name, pkmn.totalhp), params) { screen.pbUpdate }
if newhp != pkmn.hp
pkmn.hp = newhp
screen.pbRefreshSingle(pkmnid)
end
end
}
})
PokemonDebugMenuCommands.register("setstatus", {
"parent" => "hpstatusmenu",
"name" => _INTL("Set status"),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
if pkmn.egg?
screen.pbDisplay(_INTL("{1} is an egg.", pkmn.name))
elsif pkmn.hp<=0
screen.pbDisplay(_INTL("{1} is fainted, can't change status.", pkmn.name))
else
cmd = 0
loop do
cmd = screen.pbShowCommands(_INTL("Set {1}'s status.", pkmn.name), [
_INTL("[Cure]"),
_INTL("Sleep"),
_INTL("Poison"),
_INTL("Burn"),
_INTL("Paralysis"),
_INTL("Frozen")
], cmd)
break if cmd < 0
case cmd
when 0 # Cure
pkmn.healStatus
screen.pbDisplay(_INTL("{1}'s status was cured.", pkmn.name))
screen.pbRefreshSingle(pkmnid)
else # Give status problem
count = 0
cancel = false
if cmd == PBStatuses::SLEEP
params = ChooseNumberParams.new
params.setRange(0, 9)
params.setDefaultValue(3)
count = pbMessageChooseNumber(
_INTL("Set the Pokémon's sleep count."), params) { screen.pbUpdate }
cancel = true if count <= 0
end
if !cancel
pkmn.status = cmd
pkmn.statusCount = count
screen.pbRefreshSingle(pkmnid)
end
end
end
end
}
})
PokemonDebugMenuCommands.register("fullheal", {
"parent" => "hpstatusmenu",
"name" => _INTL("Fully heal"),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
if pkmn.egg?
screen.pbDisplay(_INTL("{1} is an egg.", pkmn.name))
else
pkmn.heal
screen.pbDisplay(_INTL("{1} was fully healed.", pkmn.name))
screen.pbRefreshSingle(pkmnid)
end
}
})
PokemonDebugMenuCommands.register("makefainted", {
"parent" => "hpstatusmenu",
"name" => _INTL("Make fainted"),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
if pkmn.egg?
screen.pbDisplay(_INTL("{1} is an egg.", pkmn.name))
else
pkmn.hp = 0
screen.pbRefreshSingle(pkmnid)
end
}
})
PokemonDebugMenuCommands.register("setpokerus", {
"parent" => "hpstatusmenu",
"name" => _INTL("Set Pokérus"),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
cmd = 0
loop do
pokerus = (pkmn.pokerus) ? pkmn.pokerus : 0
msg = [_INTL("{1} doesn't have Pokérus.", pkmn.name),
_INTL("Has strain {1}, infectious for {2} more days.", pokerus / 16, pokerus % 16),
_INTL("Has strain {1}, not infectious.", pokerus / 16)][pkmn.pokerusStage]
cmd = screen.pbShowCommands(msg, [
_INTL("Give random strain"),
_INTL("Make not infectious"),
_INTL("Clear Pokérus")], cmd)
break if cmd < 0
case cmd
when 0 # Give random strain
pkmn.givePokerus
screen.pbRefreshSingle(pkmnid)
when 1 # Make not infectious
if pokerus > 0
strain = pokerus / 16
p = strain << 4
pkmn.pokerus = p
screen.pbRefreshSingle(pkmnid)
end
when 2 # Clear Pokérus
pkmn.pokerus = 0
screen.pbRefreshSingle(pkmnid)
end
end
}
})
#===============================================================================
# Level/stats options
#===============================================================================
PokemonDebugMenuCommands.register("levelstats", {
"parent" => "main",
"name" => _INTL("Level/stats..."),
"always_show" => true
})
PokemonDebugMenuCommands.register("setlevel", {
"parent" => "levelstats",
"name" => _INTL("Set level"),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
if pkmn.egg?
screen.pbDisplay(_INTL("{1} is an egg.", pkmn.name))
else
mLevel = PBExperience.maxLevel
params = ChooseNumberParams.new
params.setRange(1, mLevel)
params.setDefaultValue(pkmn.level)
level = pbMessageChooseNumber(
_INTL("Set the Pokémon's level (max. {1}).", mLevel), params) { screen.pbUpdate }
if level != pkmn.level
pkmn.level = level
pkmn.calcStats
screen.pbRefreshSingle(pkmnid)
end
end
}
})
PokemonDebugMenuCommands.register("setexp", {
"parent" => "levelstats",
"name" => _INTL("Set Exp"),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
if pkmn.egg?
screen.pbDisplay(_INTL("{1} is an egg.", pkmn.name))
else
minxp = PBExperience.pbGetStartExperience(pkmn.level, pkmn.growthrate)
maxxp = PBExperience.pbGetStartExperience(pkmn.level + 1, pkmn.growthrate)
if minxp == maxxp
screen.pbDisplay(_INTL("{1} is at the maximum level.", pkmn.name))
else
params = ChooseNumberParams.new
params.setRange(minxp, maxxp - 1)
params.setDefaultValue(pkmn.exp)
newexp = pbMessageChooseNumber(
_INTL("Set the Pokémon's Exp (range {1}-{2}).",minxp, maxxp - 1), params) { screen.pbUpdate }
if newexp != pkmn.exp
pkmn.exp = newexp
pkmn.calcStats
screen.pbRefreshSingle(pkmnid)
end
end
end
}
})
PokemonDebugMenuCommands.register("hiddenvalues", {
"parent" => "levelstats",
"name" => _INTL("EV/IV/pID..."),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
numstats = 6
cmd = 0
loop do
persid = sprintf("0x%08X", pkmn.personalID)
cmd = screen.pbShowCommands(_INTL("Personal ID is {1}.", persid), [
_INTL("Set EVs"),
_INTL("Set IVs"),
_INTL("Randomise pID")], cmd)
break if cmd < 0
case cmd
when 0 # Set EVs
cmd2 = 0
loop do
totalev = 0
evcommands = []
for i in 0...numstats
evcommands.push(PBStats.getName(i) + " (#{pkmn.ev[i]})")
totalev += pkmn.ev[i]
end
evcommands.push(_INTL("Randomise all"))
evcommands.push(_INTL("Max randomise all"))
cmd2 = screen.pbShowCommands(_INTL("Change which EV?\nTotal: {1}/{2} ({3}%)",
totalev, Pokemon::EV_LIMIT,
100 * totalev / Pokemon::EV_LIMIT), evcommands, cmd2)
break if cmd2 < 0
if cmd2 < numstats
params = ChooseNumberParams.new
upperLimit = 0
for i in 0...numstats
upperLimit += pkmn.ev[i] if i != cmd2
end
upperLimit = Pokemon::EV_LIMIT - upperLimit
upperLimit = [upperLimit, Pokemon::EV_STAT_LIMIT].min
thisValue = [pkmn.ev[cmd2], upperLimit].min
params.setRange(0, upperLimit)
params.setDefaultValue(thisValue)
params.setCancelValue(thisValue)
f = pbMessageChooseNumber(_INTL("Set the EV for {1} (max. {2}).",
PBStats.getName(cmd2), upperLimit), params) { screen.pbUpdate }
if f != pkmn.ev[cmd2]
pkmn.ev[cmd2] = f
pkmn.calcStats
screen.pbRefreshSingle(pkmnid)
end
elsif cmd2 < evcommands.length # Randomise
evTotalTarget = Pokemon::EV_LIMIT
if cmd2 == evcommands.length - 2
evTotalTarget = rand(Pokemon::EV_LIMIT)
end
for i in 0...numstats
pkmn.ev[i] = 0
end
while evTotalTarget > 0
r = rand(numstats)
next if pkmn.ev[r] >= Pokemon::EV_STAT_LIMIT
addVal = 1 + rand(Pokemon::EV_STAT_LIMIT/4)
addVal = evTotalTarget if addVal > evTotalTarget
addVal = [addVal, Pokemon::EV_STAT_LIMIT - pkmn.ev[r]].min
next if addVal == 0
pkmn.ev[r] += addVal
evTotalTarget -= addVal
end
pkmn.calcStats
screen.pbRefreshSingle(pkmnid)
end
end
when 1 # Set IVs
cmd2 = 0
loop do
hiddenpower = pbHiddenPower(pkmn)
totaliv = 0
ivcommands = []
for i in 0...numstats
ivcommands.push(PBStats.getName(i) + " (#{pkmn.iv[i]})")
totaliv += pkmn.iv[i]
end
msg = _INTL("Change which IV?\nHidden Power:\n{1}, power {2}\nTotal: {3}/{4} ({5}%)",
GameData::Type.get(hiddenpower[0]).name, hiddenpower[1], totaliv, numstats * 31,
100 * totaliv / (numstats * 31))
ivcommands.push(_INTL("Randomise all"))
cmd2 = screen.pbShowCommands(msg, ivcommands, cmd2)
break if cmd2 < 0
if cmd2 < numstats
params = ChooseNumberParams.new
params.setRange(0, 31)
params.setDefaultValue(pkmn.iv[cmd2])
params.setCancelValue(pkmn.iv[cmd2])
f = pbMessageChooseNumber(_INTL("Set the IV for {1} (max. 31).",
PBStats.getName(cmd2)), params) { screen.pbUpdate }
if f != pkmn.iv[cmd2]
pkmn.iv[cmd2] = f
pkmn.calcStats
screen.pbRefreshSingle(pkmnid)
end
elsif cmd2 == ivcommands.length - 1 # Randomise
for i in 0...numstats
pkmn.iv[i] = rand(Pokemon::IV_STAT_LIMIT + 1)
end
pkmn.calcStats
screen.pbRefreshSingle(pkmnid)
end
end
when 2 # Randomise pID
pkmn.personalID = rand(2 ** 16) | rand(2 ** 16) << 16
pkmn.calcStats
screen.pbRefreshSingle(pkmnid)
end
end
}
})
PokemonDebugMenuCommands.register("sethappiness", {
"parent" => "levelstats",
"name" => _INTL("Set happiness"),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
params = ChooseNumberParams.new
params.setRange(0, 255)
params.setDefaultValue(pkmn.happiness)
h = pbMessageChooseNumber(
_INTL("Set the Pokémon's happiness (max. 255)."), params) { screen.pbUpdate }
if h != pkmn.happiness
pkmn.happiness = h
screen.pbRefreshSingle(pkmnid)
end
}
})
PokemonDebugMenuCommands.register("conteststats", {
"parent" => "levelstats",
"name" => _INTL("Contest stats..."),
"always_show" => true
})
PokemonDebugMenuCommands.register("setbeauty", {
"parent" => "conteststats",
"name" => _INTL("Set Beauty"),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
params = ChooseNumberParams.new
params.setRange(0, 255)
params.setDefaultValue(pkmn.beauty)
newval = pbMessageChooseNumber(
_INTL("Set the Pokémon's Beauty (max. 255)."), params) { screen.pbUpdate }
if newval != pkmn.beauty
pkmn.beauty = newval
screen.pbRefreshSingle(pkmnid)
end
}
})
PokemonDebugMenuCommands.register("setcool", {
"parent" => "conteststats",
"name" => _INTL("Set Cool"),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
params = ChooseNumberParams.new
params.setRange(0, 255)
params.setDefaultValue(pkmn.cool)
newval = pbMessageChooseNumber(
_INTL("Set the Pokémon's Cool (max. 255)."), params) { screen.pbUpdate }
if newval != pkmn.cool
pkmn.cool = newval
screen.pbRefreshSingle(pkmnid)
end
}
})
PokemonDebugMenuCommands.register("setcute", {
"parent" => "conteststats",
"name" => _INTL("Set Cute"),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
params = ChooseNumberParams.new
params.setRange(0, 255)
params.setDefaultValue(pkmn.cute)
newval = pbMessageChooseNumber(
_INTL("Set the Pokémon's Cute (max. 255)."), params) { screen.pbUpdate }
if newval != pkmn.cute
pkmn.cute = newval
screen.pbRefreshSingle(pkmnid)
end
}
})
PokemonDebugMenuCommands.register("setsmart", {
"parent" => "conteststats",
"name" => _INTL("Set Smart"),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
params = ChooseNumberParams.new
params.setRange(0, 255)
params.setDefaultValue(pkmn.smart)
newval = pbMessageChooseNumber(
_INTL("Set the Pokémon's Smart (max. 255)."), params) { screen.pbUpdate }
if newval != pkmn.smart
pkmn.smart = newval
screen.pbRefreshSingle(pkmnid)
end
}
})
PokemonDebugMenuCommands.register("settough", {
"parent" => "conteststats",
"name" => _INTL("Set Tough"),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
params = ChooseNumberParams.new
params.setRange(0, 255)
params.setDefaultValue(pkmn.tough)
newval = pbMessageChooseNumber(
_INTL("Set the Pokémon's Tough (max. 255)."), params) { screen.pbUpdate }
if newval != pkmn.tough
pkmn.tough = newval
screen.pbRefreshSingle(pkmnid)
end
}
})
PokemonDebugMenuCommands.register("setsheen", {
"parent" => "conteststats",
"name" => _INTL("Set Sheen"),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
params = ChooseNumberParams.new
params.setRange(0, 255)
params.setDefaultValue(pkmn.sheen)
newval = pbMessageChooseNumber(
_INTL("Set the Pokémon's Sheen (max. 255)."), params) { screen.pbUpdate }
if newval != pkmn.sheen
pkmn.sheen = newval
screen.pbRefreshSingle(pkmnid)
end
}
})
#===============================================================================
# Moves options
#===============================================================================
PokemonDebugMenuCommands.register("moves", {
"parent" => "main",
"name" => _INTL("Moves..."),
"always_show" => true
})
PokemonDebugMenuCommands.register("teachmove", {
"parent" => "moves",
"name" => _INTL("Teach move"),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
move = pbChooseMoveList
if move
pbLearnMove(pkmn, move)
screen.pbRefreshSingle(pkmnid)
end
}
})
PokemonDebugMenuCommands.register("forgetmove", {
"parent" => "moves",
"name" => _INTL("Forget move"),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
moveindex = screen.pbChooseMove(pkmn, _INTL("Choose move to forget."))
if moveindex >= 0
movename = pkmn.moves[moveindex].name
pkmn.pbDeleteMoveAtIndex(moveindex)
screen.pbDisplay(_INTL("{1} forgot {2}.", pkmn.name, movename))
screen.pbRefreshSingle(pkmnid)
end
}
})
PokemonDebugMenuCommands.register("resetmoves", {
"parent" => "moves",
"name" => _INTL("Reset moves"),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
pkmn.resetMoves
screen.pbDisplay(_INTL("{1}'s moves were reset.", pkmn.name))
screen.pbRefreshSingle(pkmnid)
}
})
PokemonDebugMenuCommands.register("setmovepp", {
"parent" => "moves",
"name" => _INTL("Set move PP"),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
cmd = 0
loop do
commands = []
for i in pkmn.moves
break if !i.id
if i.total_pp <= 0
commands.push(_INTL("{1} (PP: ---)", i.name))
else
commands.push(_INTL("{1} (PP: {2}/{3})", i.name, i.pp, i.total_pp))
end
end
commands.push(_INTL("Restore all PP"))
cmd = screen.pbShowCommands(_INTL("Alter PP of which move?"), commands, cmd)
break if cmd < 0
if cmd >= 0 && cmd < commands.length - 1 # Move
move = pkmn.moves[cmd]
movename = move.name
if move.total_pp <= 0
screen.pbDisplay(_INTL("{1} has infinite PP.", movename))
else
cmd2 = 0
loop do
msg = _INTL("{1}: PP {2}/{3} (PP Up {4}/3)", movename, move.pp, move.total_pp, move.ppup)
cmd2 = screen.pbShowCommands(msg, [
_INTL("Set PP"),
_INTL("Full PP"),
_INTL("Set PP Up")], cmd2)
break if cmd2 < 0
case cmd2
when 0 # Change PP
params = ChooseNumberParams.new
params.setRange(0, move.total_pp)
params.setDefaultValue(move.pp)
h = pbMessageChooseNumber(
_INTL("Set PP of {1} (max. {2}).", movename, move.total_pp), params) { screen.pbUpdate }
move.pp = h
when 1 # Full PP
move.pp = move.total_pp
when 2 # Change PP Up
params = ChooseNumberParams.new
params.setRange(0, 3)
params.setDefaultValue(move.ppup)
h = pbMessageChooseNumber(
_INTL("Set PP Up of {1} (max. 3).", movename), params) { screen.pbUpdate }
move.ppup = h
move.pp = move.total_pp if move.pp > move.total_pp
end
end
end
elsif cmd == commands.length - 1 # Restore all PP
pkmn.healPP
end
end
}
})
PokemonDebugMenuCommands.register("setinitialmoves", {
"parent" => "moves",
"name" => _INTL("Reset initial moves"),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
pkmn.pbRecordFirstMoves
screen.pbDisplay(_INTL("{1}'s moves were set as its first-known moves.", pkmn.name))
screen.pbRefreshSingle(pkmnid)
}
})
#===============================================================================
# Other options
#===============================================================================
PokemonDebugMenuCommands.register("setability", {
"parent" => "main",
"name" => _INTL("Set ability"),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
cmd = 0
loop do
abils = pkmn.getAbilityList
oldabil = (pkmn.ability) ? pkmn.ability.name : "No ability"
commands = []
for i in abils
commands.push(((i[1] < 2) ? "" : "(H) ") + GameData::Ability.get(i[0]).name)
end
commands.push(_INTL("Remove override"))
msg = [_INTL("Ability {1} is natural.", oldabil),
_INTL("Ability {1} is being forced.", oldabil)][pkmn.abilityflag != nil ? 1 : 0]
cmd = screen.pbShowCommands(msg, commands, cmd)
break if cmd < 0
if cmd >= 0 && cmd < abils.length # Set ability override
pkmn.setAbility(abils[cmd][1])
elsif cmd == abils.length # Remove override
pkmn.abilityflag = nil
end
screen.pbRefreshSingle(pkmnid)
end
}
})
PokemonDebugMenuCommands.register("setnature", {
"parent" => "main",
"name" => _INTL("Set nature"),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
commands = []
(PBNatures.getCount).times do |i|
statUp = PBNatures.getStatRaised(i)
statDown = PBNatures.getStatLowered(i)
if statUp != statDown
text = _INTL("{1} (+{2}, -{3})", PBNatures.getName(i),
PBStats.getNameBrief(statUp), PBStats.getNameBrief(statDown))
else
text = _INTL("{1} (---)", PBNatures.getName(i))
end
commands.push(text)
end
commands.push(_INTL("[Remove override]"))
cmd = pkmn.nature
loop do
oldnature = PBNatures.getName(pkmn.nature)
msg = [_INTL("Nature {1} is natural.", oldnature),
_INTL("Nature {1} is being forced.", oldnature)][pkmn.natureflag ? 1 : 0]
cmd = screen.pbShowCommands(msg, commands, cmd)
break if cmd < 0
if cmd >= 0 && cmd < PBNatures.getCount # Set nature override
pkmn.setNature(cmd)
pkmn.calcStats
elsif cmd == PBNatures.getCount # Remove override
pkmn.natureflag = nil
end
screen.pbRefreshSingle(pkmnid)
end
}
})
PokemonDebugMenuCommands.register("setgender", {
"parent" => "main",
"name" => _INTL("Set gender"),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
if pkmn.singleGendered?
screen.pbDisplay(_INTL("{1} is single-gendered or genderless.", pkmn.speciesName))
else
cmd = 0
loop do
oldgender = (pkmn.male?) ? _INTL("male") : _INTL("female")
msg = [_INTL("Gender {1} is natural.", oldgender),
_INTL("Gender {1} is being forced.", oldgender)][pkmn.genderflag ? 1 : 0]
cmd = screen.pbShowCommands(msg, [
_INTL("Make male"),
_INTL("Make female"),
_INTL("Remove override")], cmd)
break if cmd < 0
case cmd
when 0 # Make male
pkmn.makeMale
if !pkmn.male?
screen.pbDisplay(_INTL("{1}'s gender couldn't be changed.", pkmn.name))
end
when 1 # Make female
pkmn.makeFemale
if !pkmn.female?
screen.pbDisplay(_INTL("{1}'s gender couldn't be changed.", pkmn.name))
end
when 2 # Remove override
pkmn.genderflag = nil
end
pbSeenForm(pkmn) if !settingUpBattle
screen.pbRefreshSingle(pkmnid)
end
end
}
})
PokemonDebugMenuCommands.register("speciesform", {
"parent" => "main",
"name" => _INTL("Species/form..."),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
cmd = 0
loop do
msg = [_INTL("Species {1}, form {2}.", pkmn.speciesName, pkmn.form),
_INTL("Species {1}, form {2} (forced).", pkmn.speciesName, pkmn.form)][(pkmn.forcedForm != nil) ? 1 : 0]
cmd = screen.pbShowCommands(msg, [
_INTL("Set species"),
_INTL("Set form"),
_INTL("Remove override")], cmd)
break if cmd < 0
case cmd
when 0 # Set species
species = pbChooseSpeciesList(pkmn.species)
if species && species != pkmn.species
pkmn.species = species
pkmn.calcStats
pbSeenForm(pkmn) if !settingUpBattle
screen.pbRefreshSingle(pkmnid)
end
when 1 # Set form
cmd2 = 0
formcmds = [[], []]
GameData::Species.each do |sp|
next if sp.species != pkmn.species
form_name = sp.form_name
form_name = _INTL("Unnamed form") if !form_name || form_name.empty?
form_name = sprintf("%d: %s", sp.form, form_name)
formcmds[0].push(sp.form)
formcmds[1].push(form_name)
cmd2 = sp.form if pkmn.form == sp.form
end
if formcmds[0].length <= 1
screen.pbDisplay(_INTL("Species {1} only has one form.", pkmn.speciesName))
else
cmd2 = screen.pbShowCommands(_INTL("Set the Pokémon's form."), formcmds[1], cmd2)
next if cmd2 < 0
f = formcmds[0][cmd2]
if f != pkmn.form
if MultipleForms.hasFunction?(pkmn, "getForm")
next if !screen.pbConfirm(_INTL("This species decides its own form. Override?"))
pkmn.forcedForm = f
end
pkmn.form = f
pbSeenForm(pkmn) if !settingUpBattle
screen.pbRefreshSingle(pkmnid)
end
end
when 2 # Remove override
pkmn.forcedForm = nil
screen.pbRefreshSingle(pkmnid)
end
end
}
})
#===============================================================================
# Cosmetic options
#===============================================================================
PokemonDebugMenuCommands.register("cosmetic", {
"parent" => "main",
"name" => _INTL("Cosmetic info..."),
"always_show" => true
})
PokemonDebugMenuCommands.register("setshininess", {
"parent" => "cosmetic",
"name" => _INTL("Set shininess"),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
cmd = 0
loop do
oldshiny = (pkmn.shiny?) ? _INTL("shiny") : _INTL("normal")
msg = [_INTL("Shininess ({1}) is natural.", oldshiny),
_INTL("Shininess ({1}) is being forced.", oldshiny)][pkmn.shinyflag != nil ? 1 : 0]
cmd = screen.pbShowCommands(msg, [
_INTL("Make shiny"),
_INTL("Make normal"),
_INTL("Remove override")], cmd)
break if cmd < 0
case cmd
when 0 # Make shiny
pkmn.makeShiny
when 1 # Make normal
pkmn.makeNotShiny
when 2 # Remove override
pkmn.shinyflag = nil
end
screen.pbRefreshSingle(pkmnid)
end
}
})
PokemonDebugMenuCommands.register("setpokeball", {
"parent" => "cosmetic",
"name" => _INTL("Set Poké Ball"),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
commands = []
balls = []
for key in $BallTypes.keys
item = GameData::Item.try_get($BallTypes[key])
balls.push([key.to_i, item.name]) if item
end
balls.sort! { |a, b| a[1] <=> b[1] }
cmd = 0
for i in 0...balls.length
next if balls[i][0] != pkmn.ballused
cmd = i
break
end
balls.each { |ball| commands.push(ball[1]) }
loop do
oldball = pbBallTypeToItem(pkmn.ballused).name
cmd = screen.pbShowCommands(_INTL("{1} used.", oldball), commands, cmd)
break if cmd < 0
pkmn.ballused = balls[cmd][0]
end
}
})
PokemonDebugMenuCommands.register("setribbons", {
"parent" => "cosmetic",
"name" => _INTL("Set ribbons"),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
cmd = 0
loop do
commands = []
for i in 1..PBRibbons.maxValue
commands.push(_INTL("{1} {2}",
(pkmn.hasRibbon?(i)) ? "[Y]" : "[ ]", PBRibbons.getName(i)))
end
commands.push(_INTL("Give all"))
commands.push(_INTL("Clear all"))
cmd = screen.pbShowCommands(_INTL("{1} ribbons.", pkmn.ribbonCount), commands, cmd)
break if cmd < 0
if cmd >= 0 && cmd < PBRibbons.maxValue # Toggle ribbon
if pkmn.hasRibbon?(cmd + 1)
pkmn.takeRibbon(cmd + 1)
else
pkmn.giveRibbon(cmd + 1)
end
elsif cmd == commands.length - 2 # Give all
for i in 1..PBRibbons.maxValue
pkmn.giveRibbon(i)
end
elsif cmd == commands.length - 1 # Clear all
for i in 1..PBRibbons.maxValue
pkmn.takeRibbon(i)
end
end
end
}
})
PokemonDebugMenuCommands.register("setnickname", {
"parent" => "cosmetic",
"name" => _INTL("Set nickname"),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
cmd = 0
loop do
speciesname = pkmn.speciesName
msg = [_INTL("{1} has the nickname {2}.", speciesname, pkmn.name),
_INTL("{1} has no nickname.", speciesname)][pkmn.name == speciesname ? 1 : 0]
cmd = screen.pbShowCommands(msg, [
_INTL("Rename"),
_INTL("Erase name")], cmd)
break if cmd < 0
case cmd
when 0 # Rename
oldname = (pkmn.name && pkmn.name != speciesname) ? pkmn.name : ""
newname = pbEnterPokemonName(_INTL("{1}'s nickname?", speciesname),
0, Pokemon::MAX_NAME_SIZE, oldname, pkmn)
if newname && newname != ""
pkmn.name = newname
screen.pbRefreshSingle(pkmnid)
end
when 1 # Erase name
pkmn.name = speciesname
screen.pbRefreshSingle(pkmnid)
end
end
}
})
PokemonDebugMenuCommands.register("ownership", {
"parent" => "cosmetic",
"name" => _INTL("Ownership..."),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
cmd = 0
loop do
gender = [_INTL("Male"), _INTL("Female"), _INTL("Unknown")][pkmn.owner.gender]
msg = [_INTL("Player's Pokémon\n{1}\n{2}\n{3} ({4})", pkmn.owner.name, gender, pkmn.owner.public_id, pkmn.owner.id),
_INTL("Foreign Pokémon\n{1}\n{2}\n{3} ({4})", pkmn.owner.name, gender, pkmn.owner.public_id, pkmn.owner.id)
][pkmn.foreign?($Trainer) ? 1 : 0]
cmd = screen.pbShowCommands(msg, [
_INTL("Make player's"),
_INTL("Set OT's name"),
_INTL("Set OT's gender"),
_INTL("Random foreign ID"),
_INTL("Set foreign ID")], cmd)
break if cmd < 0
case cmd
when 0 # Make player's
pkmn.owner = Pokemon::Owner.new_from_trainer($Trainer)
when 1 # Set OT's name
pkmn.owner.name = pbEnterPlayerName(_INTL("{1}'s OT's name?", pkmn.name), 1, MAX_PLAYER_NAME_SIZE)
when 2 # Set OT's gender
cmd2 = screen.pbShowCommands(_INTL("Set OT's gender."),
[_INTL("Male"), _INTL("Female"), _INTL("Unknown")], pkmn.owner.gender)
pkmn.owner.gender = cmd2 if cmd2 >= 0
when 3 # Random foreign ID
pkmn.owner.id = $Trainer.getForeignID
when 4 # Set foreign ID
params = ChooseNumberParams.new
params.setRange(0, 65535)
params.setDefaultValue(pkmn.owner.public_id)
val = pbMessageChooseNumber(
_INTL("Set the new ID (max. 65535)."), params) { screen.pbUpdate }
pkmn.owner.id = val | val << 16
end
end
}
})
#===============================================================================
# Other options
#===============================================================================
PokemonDebugMenuCommands.register("setegg", {
"parent" => "main",
"name" => _INTL("Set egg"),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
cmd = 0
loop do
msg = [_INTL("Not an egg"),
_INTL("Egg with eggsteps: {1}.", pkmn.eggsteps)][pkmn.egg? ? 1 : 0]
cmd = screen.pbShowCommands(msg, [
_INTL("Make egg"),
_INTL("Make Pokémon"),
_INTL("Set eggsteps to 1")], cmd)
break if cmd < 0
case cmd
when 0 # Make egg
if !pkmn.egg? && (pbHasEgg?(pkmn.species) ||
screen.pbConfirm(_INTL("{1} cannot legally be an egg. Make egg anyway?", pkmn.speciesName)))
pkmn.level = EGG_LEVEL
pkmn.calcStats
pkmn.name = _INTL("Egg")
pkmn.eggsteps = pkmn.species_data.hatch_steps
pkmn.hatchedMap = 0
pkmn.obtainMode = 1
screen.pbRefreshSingle(pkmnid)
end
when 1 # Make Pokémon
if pkmn.egg?
pkmn.name = pkmn.speciesName
pkmn.eggsteps = 0
pkmn.hatchedMap = 0
pkmn.obtainMode = 0
screen.pbRefreshSingle(pkmnid)
end
when 2 # Set eggsteps to 1
pkmn.eggsteps = 1 if pkmn.egg?
end
end
}
})
PokemonDebugMenuCommands.register("shadowpkmn", {
"parent" => "main",
"name" => _INTL("Shadow Pkmn..."),
"always_show" => true,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
cmd = 0
loop do
msg = [_INTL("Not a Shadow Pokémon."),
_INTL("Heart gauge is {1} (stage {2}).", pkmn.heartgauge, pkmn.heartStage)
][pkmn.shadowPokemon? ? 1 : 0]
cmd = screen.pbShowCommands(msg, [
_INTL("Make Shadow"),
_INTL("Set heart gauge")], cmd)
break if cmd < 0
case cmd
when 0 # Make Shadow
if !pkmn.shadowPokemon?
pkmn.makeShadow
screen.pbRefreshSingle(pkmnid)
else
screen.pbDisplay(_INTL("{1} is already a Shadow Pokémon.", pkmn.name))
end
when 1 # Set heart gauge
if pkmn.shadowPokemon?
oldheart = pkmn.heartgauge
params = ChooseNumberParams.new
params.setRange(0, Pokemon::HEARTGAUGESIZE)
params.setDefaultValue(pkmn.heartgauge)
val = pbMessageChooseNumber(
_INTL("Set the heart gauge (max. {1}).", Pokemon::HEARTGAUGESIZE),
params) { screen.pbUpdate }
if val != oldheart
pkmn.adjustHeart(val - oldheart)
pbReadyToPurify(pkmn)
end
else
screen.pbDisplay(_INTL("{1} is not a Shadow Pokémon.", pkmn.name))
end
end
end
}
})
PokemonDebugMenuCommands.register("mysterygift", {
"parent" => "main",
"name" => _INTL("Mystery Gift"),
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
pbCreateMysteryGift(0, pkmn)
}
})
PokemonDebugMenuCommands.register("duplicate", {
"parent" => "main",
"name" => _INTL("Duplicate"),
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
if screen.pbConfirm(_INTL("Are you sure you want to copy this Pokémon?"))
clonedpkmn = pkmn.clone
if screen.is_a?(PokemonPartyScreen)
pbStorePokemon(clonedpkmn)
screen.pbHardRefresh
screen.pbDisplay(_INTL("The Pokémon was duplicated."))
elsif screen.is_a?(PokemonStorageScreen)
if screen.storage.pbMoveCaughtToParty(clonedpkmn)
if pkmnid[0] != -1
screen.pbDisplay(_INTL("The duplicated Pokémon was moved to your party."))
end
else
oldbox = screen.storage.currentBox
newbox = screen.storage.pbStoreCaught(clonedpkmn)
if newbox < 0
screen.pbDisplay(_INTL("All boxes are full."))
elsif newbox != oldbox
screen.pbDisplay(_INTL("The duplicated Pokémon was moved to box \"{1}.\"", screen.storage[newbox].name))
screen.storage.currentBox = oldbox
end
end
screen.pbHardRefresh
end
next true
end
}
})
PokemonDebugMenuCommands.register("delete", {
"parent" => "main",
"name" => _INTL("Delete"),
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
if screen.pbConfirm(_INTL("Are you sure you want to delete this Pokémon?"))
if screen.is_a?(PokemonPartyScreen)
screen.party[pkmnid] = nil
screen.party.compact!
screen.pbHardRefresh
elsif screen.is_a?(PokemonStorageScreen)
screen.scene.pbRelease(pkmnid, heldpoke)
(heldpoke) ? screen.heldpkmn = nil : screen.storage.pbDelete(pkmnid[0],pkmnid[1])
screen.scene.pbRefresh
end
next true
end
}
})