Added battle debug functions for setting position effects and NPC trainer items

This commit is contained in:
Maruno17
2022-01-17 22:55:01 +00:00
parent b550ad9c07
commit f872db2618
3 changed files with 113 additions and 14 deletions

View File

@@ -105,7 +105,7 @@ class Battle
@field = ActiveField.new # Whole field (gravity/rooms) @field = ActiveField.new # Whole field (gravity/rooms)
@sides = [ActiveSide.new, # Player's side @sides = [ActiveSide.new, # Player's side
ActiveSide.new] # Foe's side ActiveSide.new] # Foe's side
@positions = [] # Battler positions @positions = [] # Battler positions
@battlers = [] @battlers = []
@sideSizes = [1, 1] # Single battle, 1v1 @sideSizes = [1, 1] # Single battle, 1v1
@backdrop = "" @backdrop = ""

View File

@@ -1,17 +1,13 @@
=begin =begin
# TODO: # TODO:
Positions (Battle::ActivePosition) turnCount - Is currently read-only, probably not worth being able to set
PBEffects::HealingWish initialItems - Array of two arrays, each with one value per party index
PBEffects::LunarDance recycleItems - Array of two arrays, each with one value per party index
turnCount belch - Array of two arrays, each with one value per party index
items (of foe trainers) corrosiveGas - Array of two arrays, each with one value per party index
initialItems - Array of two arrays, each with one value per party index first_poke_ball - both for Ball Fetch
recycleItems - Array of two arrays, each with one value per party index poke_ball_failed - both for Ball Fetch
belch - Array of two arrays, each with one value per party index
corrosiveGas - Array of two arrays, each with one value per party index
first_poke_ball - both for Ball Fetch
poke_ball_failed - both for Ball Fetch
View party screen for each trainer's team, be able to edit properties of Pokémon View party screen for each trainer's team, be able to edit properties of Pokémon
that aren't in battle. that aren't in battle.
@@ -38,7 +34,7 @@ MenuHandlers.add(:battle_debug_menu, :list_player_battlers, {
cmds = [] cmds = []
battle.allSameSideBattlers.each do |b| battle.allSameSideBattlers.each do |b|
battlers.push(b) battlers.push(b)
text = "[#{b.index}] #{b.name} " text = "[#{b.index}] #{b.name}"
if b.pbOwnedByPlayer? if b.pbOwnedByPlayer?
text += " (yours)" text += " (yours)"
else else
@@ -64,7 +60,7 @@ MenuHandlers.add(:battle_debug_menu, :list_foe_battlers, {
cmds = [] cmds = []
battle.allOtherSideBattlers.each do |b| battle.allOtherSideBattlers.each do |b|
battlers.push(b) battlers.push(b)
cmds.push("[#{b.index}] #{b.name} ") cmds.push("[#{b.index}] #{b.name}")
end end
cmd = 0 cmd = 0
loop do loop do
@@ -303,6 +299,42 @@ MenuHandlers.add(:battle_debug_menu, :opposing_side, {
} }
}) })
MenuHandlers.add(:battle_debug_menu, :position_effects, {
"name" => _INTL("Battler Position Effects..."),
"parent" => :field,
"description" => _INTL("Effects that apply to individual battler positions."),
"effect" => proc { |battle|
positions = []
cmds = []
battle.positions.each_with_index do |position, i|
next if !position
positions.push(i)
battler = battle.battlers[i]
if battler && !battler.fainted?
text = "[#{i}] #{battler.name}"
else
text = _INTL("[#{i}] (empty)", i)
end
if battler.pbOwnedByPlayer?
text += " (yours)"
elsif battle.opposes?(i)
text += " (opposing)"
else
text += " (ally's)"
end
cmds.push(text)
end
cmd = 0
loop do
cmd = pbMessage("\\ts[]" + _INTL("Choose a battler position."), cmds, -1, nil, cmd)
break if cmd < 0
editor = Battle::DebugSetEffects.new(battle, :position, positions[cmd])
editor.update
editor.dispose
end
}
})
#=============================================================================== #===============================================================================
# Trainer Options # Trainer Options
#=============================================================================== #===============================================================================
@@ -312,6 +344,58 @@ MenuHandlers.add(:battle_debug_menu, :trainers, {
"description" => _INTL("Variables that apply to trainers.") "description" => _INTL("Variables that apply to trainers.")
}) })
MenuHandlers.add(:battle_debug_menu, :trainer_items, {
"name" => _INTL("NPC Trainer Items"),
"parent" => :trainers,
"description" => _INTL("View and change the items each NPC trainer has access to."),
"effect" => proc { |battle|
cmd = 0
loop do
# Find all NPC trainers and their items
commands = []
item_arrays = []
trainer_indices = []
if battle.opponent
battle.opponent.each_with_index do |trainer, i|
items = battle.items ? battle.items[i].clone : []
commands.push(_INTL("Opponent {1}: {2} ({3} items)", i + 1, trainer.full_name, items.length))
item_arrays.push(items)
trainer_indices.push([1, i])
end
end
if battle.player.length > 1
battle.player.each_with_index do |trainer, i|
next if i == 0 # Player
items = battle.ally_items ? battle.ally_items[i].clone : []
commands.push(_INTL("Ally {1}: {2} ({3} items)", i, trainer.full_name, items.length))
item_arrays.push(items)
trainer_indices.push([0, i])
end
end
if commands.length == 0
pbMessage("\\ts[]" + _INTL("There are no NPC trainers in this battle."))
break
end
# Choose a trainer
cmd = pbMessage("\\ts[]" + _INTL("Choose a trainer."), commands, -1, nil, cmd)
break if cmd < 0
# Get trainer's items
items = item_arrays[cmd]
indices = trainer_indices[cmd]
# Edit trainer's items
item_list_property = GameDataPoolProperty.new(:Item)
new_items = item_list_property.set(nil, items)
if indices[0] == 0 # Ally
battle.ally_items = [] if !battle.ally_items
battle.ally_items[indices[1]] = new_items
else # Opponent
battle.items = [] if !battle.items
battle.items[indices[1]] = new_items
end
end
}
})
MenuHandlers.add(:battle_debug_menu, :mega_evolution, { MenuHandlers.add(:battle_debug_menu, :mega_evolution, {
"name" => _INTL("Mega Evolution"), "name" => _INTL("Mega Evolution"),
"parent" => :trainers, "parent" => :trainers,

View File

@@ -163,6 +163,18 @@ module Battle::DebugVariables
PBEffects::WaterSportField => { name: "Water Sport duration (Gen 6+)", default: 0 }, PBEffects::WaterSportField => { name: "Water Sport duration (Gen 6+)", default: 0 },
PBEffects::WonderRoom => { name: "Wonder Room duration", default: 0 } PBEffects::WonderRoom => { name: "Wonder Room duration", default: 0 }
} }
POSITION_EFFECTS = {
# PBEffects::FutureSightCounter - too complex to be worth bothering with
# PBEffects::FutureSightMove - too complex to be worth bothering with
# PBEffects::FutureSightUserIndex - too complex to be worth bothering with
# PBEffects::FutureSightUserPartyIndex - too complex to be worth bothering with
PBEffects::HealingWish => { name: "Whether Healing Wish is waiting to apply", default: false },
PBEffects::LunarDance => { name: "Whether Lunar Dance is waiting to apply", default: false }
# PBEffects::Wish - too complex to be worth bothering with
# PBEffects::WishAmount - too complex to be worth bothering with
# PBEffects::WishMaker - too complex to be worth bothering with
}
end end
#=============================================================================== #===============================================================================
@@ -250,6 +262,9 @@ class Battle::DebugSetEffects
when :side when :side
@variables_data = Battle::DebugVariables::SIDE_EFFECTS @variables_data = Battle::DebugVariables::SIDE_EFFECTS
@variables = @battle.sides[@side].effects @variables = @battle.sides[@side].effects
when :position
@variables_data = Battle::DebugVariables::POSITION_EFFECTS
@variables = @battle.positions[@side].effects
when :battler when :battler
@variables_data = Battle::DebugVariables::BATTLER_EFFECTS @variables_data = Battle::DebugVariables::BATTLER_EFFECTS
@variables = @battle.battlers[@side].effects @variables = @battle.battlers[@side].effects