Currently I'm trying to convert some of RPG Advocate's scripts to SDK compatible.(At least I can split methods and alias them, though I'm not a scripter) But during testing, I met a problem.
First, here's the code:
And questions:
1. When I enter debug mode(pressing X button in battle), most things work fine. But when it comes to select actor or enemy, the select cursor acts weirdly. When the cursor is on first actor and you pressed right arrow key, the cursor moves to 3rd actor, not 2nd.(and if it is on 2nd, when you move it to right, you'll see it's on 4th now) Same to enemies.(No, Actor/Enemy select in battle is normal)
2. Is there a way to alias original update_phase3?
Like this, it doesn't work correctly.
First, here's the code:
Note:
- This is for SDK2, though I haven't put SDK log yet.
- It may not work with your battle system.
- This is for SDK2, though I haven't put SDK log yet.
- It may not work with your battle system.
Code:
#==============================================================================
# ** RPG Advocate's Battle Debugger
# http://www.phylomortis.com
#------------------------------------------------------------------------------
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle < SDK::Scene_Base
#--------------------------------------------------------------------------
# * Main Processing : Window Initialization
#--------------------------------------------------------------------------
alias_method :rpg_advocate_battle_debugger_main_window, :main_window
def main_window
rpg_advocate_battle_debugger_main_window
debugger_window
end
# --------------------------
def debugger_window
d1 = "Change Character HP"
d2 = "Change Character SP"
d3 = "Complete Heal Character"
d4 = "Change Monster HP"
d5 = "Change Monster SP"
d6 = "Complete Heal Monster"
d7 = "Kill All Monsters"
d8 = "Revive All Monsters"
d9 = "Switches/Variables"
d10 = "Hide Monster"
d11 = "Show All Monsters"
d12 = "Item Management"
d13 = "Change Turn Number"
d14 = "End Battle"
e1 = "End as Victory"
e2 = "End as Escape"
e3 = "End as Defeat"
debug_commands = [d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13,
d14]
end_commands = [e1, e2, e3]
@debugging = false
@last_sv_index = -1
@sv_index = -1
@selected_entity = -1
@left_window = Window_DebugLeft.new
@right_window = Window_DebugRight.new
@left_window.active = false
@left_window.visible = false
@left_window.z = 5100
@right_window.active = false
@right_window.visible = false
@right_window.z = 5100
@end_window = Window_Command.new(200, end_commands)
count_y = $game_troop.enemies.size * 32 + 64
@count_window = Window_BattleTurn.new(count_y)
@count_window.visible = false
@count_window.z = 5000
@end_window.visible = false
@end_window.active = false
@end_window.visible = false
@end_window.x = 150
@end_window.y = 300
@end_window.z = 5020
@turn_window = Window_InputNumber.new(3)
@turn_window.active = false
@turn_window.visible = false
@turn_window.x = 150
@turn_window.y = 300
@turn_window.z = 5020
@turn_window.opacity = 255
@turn_window.back_opacity = 255
@enemyhp_window = Window_InputNumber.new(6)
@enemyhp_window.active = false
@enemyhp_window.visible = false
@enemyhp_window.x = 150
@enemyhp_window.y = 300
@enemyhp_window.z = 5040
@enemyhp_window.opacity = 255
@enemyhp_window.back_opacity = 255
@value_window = Window_InputNumber.new(4)
@value_window.active = false
@value_window.visible = false
@value_window.x = 150
@value_window.y = 300
@value_window.z = 5040
@value_window.opacity = 255
@value_window.back_opacity = 255
@var_window = Window_InputNumber.new(8)
@var_window.active = false
@var_window.visible = false
@var_window.x = 270
@var_window.y = 164
@var_window.z = 5200
@var_window.opacity = 255
@var_window.back_opacity = 255
@turn_window.opacity = 255
@turn_window.back_opacity = 255
@itemset_window = Window_Dataset.new(1)
@itemset_window.active = false
@itemset_window.visible = false
@itemset_window.x = 208
@itemset_window.y = 0
@itemset_window.z = 6000
@monsterdata_window = Window_MonsterData.new
@monsterdata_window.visible = false
@monsterdata_window.z = 5000
@battledebug_window = Window_Command.new(208, debug_commands)
@battledebug_window.x = 0
@battledebug_window.y = 0
@battledebug_window.z = 5000
@battledebug_window.visible = false
end
# --------------------------
def update_phase3 #Overwrite
if @enemy_arrow != nil && @debugging
update_debug_enemy_select
elsif @actor_arrow != nil && @debugging
update_debug_actor_select
elsif @enemy_arrow != nil
update_phase3_enemy_select
elsif @actor_arrow != nil
update_phase3_actor_select
elsif @skill_window != nil
update_phase3_skill_select
elsif @item_window != nil
update_phase3_item_select
elsif @actor_command_window.active
update_phase3_basic_command
elsif @battledebug_window.active
update_battledebug
elsif @end_window.active
update_end
elsif @turn_window.active
update_turn
elsif @itemset_window.active
update_itemset
elsif @enemyhp_window.active
update_enemyhp
elsif @value_window.active
update_value
elsif @left_window.active
update_left
elsif @right_window.active
update_right
elsif @var_window.active
update_var
end
end
# --------------------------
alias_method :rpg_advocate_battle_debugger_update_phase3_basic, :update_phase3_basic_command
def update_phase3_basic_command
rpg_advocate_battle_debugger_update_phase3_basic
if Input.trigger?(Input::X) && ($BTEST || $DEBUG)
$game_system.se_play($data_system.decision_se)
@debugging = true
@actor_command_window.active = false
@actor_command_window.visible = false
@battledebug_window.active = true
@battledebug_window.visible = true
@battledebug_window.index = 0
@monsterdata_window.refresh
@count_window.refresh
@count_window.visible = true
@monsterdata_window.visible = true
return
end
end
end
class Scene_Battle # New Methods
# ---------------------------
def update_battledebug
if @battledebug_window.active
@selected_entity = -1
end
if Input.trigger?(Input::B)
@debugging = false
@sv_index = -1
$game_system.se_play($data_system.cancel_se)
@battledebug_window.active = false
@battledebug_window.visible = false
@monsterdata_window.visible = false
@count_window.visible = false
@actor_command_window.active = true
@actor_command_window.visible = true
phase3_setup_command_window
end
if Input.trigger?(Input::C)
case @battledebug_window.index
when 0
$game_system.se_play($data_system.decision_se)
@battledebug_window.active = false
@battledebug_window.visible = false
@monsterdata_window.visible = false
@count_window.visible = false
debug_actor_select
when 1
$game_system.se_play($data_system.decision_se)
@battledebug_window.active = false
@battledebug_window.visible = false
@monsterdata_window.visible = false
@count_window.visible = false
debug_actor_select
when 2
$game_system.se_play($data_system.decision_se)
@battledebug_window.active = false
@battledebug_window.visible = false
@monsterdata_window.visible = false
@count_window.visible = false
debug_actor_select
when 3
$game_system.se_play($data_system.decision_se)
@battledebug_window.active = false
@battledebug_window.visible = false
@monsterdata_window.visible = false
@count_window.visible = false
debug_enemy_select
when 4
$game_system.se_play($data_system.decision_se)
@battledebug_window.active = false
@battledebug_window.visible = false
@monsterdata_window.visible = false
@count_window.visible = false
debug_enemy_select
when 5
$game_system.se_play($data_system.decision_se)
@battledebug_window.active = false
@battledebug_window.visible = false
@monsterdata_window.visible = false
@count_window.visible = false
debug_enemy_select
when 6
$game_system.se_play($data_system.decision_se)
for enemy in $game_troop.enemies
enemy.hp = 0
enemy.immortal = false
@battledebug_window.visible = false
@battledebug_window.active = false
@monsterdata_window.visible = false
@count_window.visible = false
start_phase5
end
when 7
$game_system.se_play($data_system.decision_se)
for enemy in $game_troop.enemies
if enemy.dead? && enemy.hidden == false
enemy.hp += 1
enemy.damage = -1
enemy.damage_pop = true
end
end
@monsterdata_window.refresh
when 8
$game_system.se_play($data_system.decision_se)
@battledebug_window.active = false
@left_window.visible = true
@right_window.visible = true
@left_window.active = true
when 9
$game_system.se_play($data_system.decision_se)
@battledebug_window.active = false
@battledebug_window.visible = false
@monsterdata_window.visible = false
@count_window.visible = false
debug_enemy_select
when 10
$game_system.se_play($data_system.decision_se)
for enemy in $game_troop.enemies
enemy.hidden = false
end
@monsterdata_window.refresh
when 11
$game_system.se_play($data_system.decision_se)
@battledebug_window.active = false
@itemset_window.index = 0
@itemset_window.active = true
@itemset_window.visible = true
when 12
$game_system.se_play($data_system.decision_se)
@battledebug_window.active = false
@turn_window.number = $game_temp.battle_turn + 1
@turn_window.active = true
@turn_window.visible = true
when 13
$game_system.se_play($data_system.decision_se)
@battledebug_window.active = false
@end_window.active = true
@end_window.visible = true
end
end
end
# ---------------------------
def update_end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
reset_debug
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
$game_system.bgm_play($game_temp.map_bgm)
battle_end(@end_window.index)
end
end
# ---------------------------
def update_turn
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
reset_debug
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
$game_temp.battle_turn = @turn_window.number - 1
reset_debug
end
end
# ---------------------------
def update_left
@sv_index = @left_window.index
if @sv_index != @last_sv_index
@last_sv_index = @left_window.index
@right_window.top_id = @left_window.index * 10 + 1
@right_window.mode = 0
if @right_window.top_id >= $data_system.switches.size
@right_window.mode = 1
s = $data_system.switches.size - 1
loop do
if s % 10 == 0
break
end
s += 1
end
@right_window.top_id -= s
end
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
reset_debug
return
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
@left_window.active = false
@right_window.active = true
@right_window.index = 0
return
end
end
# ---------------------------
def update_right
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@left_window.active = true
@right_window.active = false
@right_window.index = -1
@help_window.contents.clear
return
end
current_id = @right_window.top_id + @right_window.index
if @right_window.mode == 0
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
$game_switches[current_id] = (not $game_switches[current_id])
@right_window.refresh
return
end
end
if @right_window.mode == 1
if Input.repeat?(Input::RIGHT)
$game_system.se_play($data_system.cursor_se)
$game_variables[current_id] += 1
if $game_variables[current_id] > 99999999
$game_variables[current_id] = 99999999
end
@right_window.refresh
return
end
if Input.repeat?(Input::LEFT)
$game_system.se_play($data_system.cursor_se)
$game_variables[current_id] -= 1
if $game_variables[current_id] < -99999999
$game_variables[current_id] = -99999999
end
@right_window.refresh
return
end
if Input.repeat?(Input::C)
$game_system.se_play($data_system.decision_se)
current_id = @right_window.top_id + @right_window.index
@variable_edit = current_id
@var_window.number = $game_variables[current_id].abs
@var_window.visible = true
@var_window.active = true
@right_window.active = false
end
if Input.repeat?(Input::X)
$game_system.se_play($data_system.decision_se)
current_id = @right_window.top_id + @right_window.index
$game_variables[current_id] *= -1
@right_window.refresh
end
end
end
# ---------------------------
def update_itemset
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
reset_debug
end
if Input.repeat?(Input::RIGHT)
$game_system.se_play($data_system.cursor_se)
$game_party.gain_item(@itemset_window.index + 1, 1)
@itemset_window.refresh
end
if Input.repeat?(Input::LEFT)
$game_system.se_play($data_system.cursor_se)
$game_party.lose_item(@itemset_window.index + 1, 1)
@itemset_window.refresh
end
if Input.repeat?(Input::X)
$game_system.se_play($data_system.cursor_se)
$game_party.lose_item(@itemset_window.index + 1, 10)
@itemset_window.refresh
end
if Input.repeat?(Input::Y)
$game_system.se_play($data_system.cursor_se)
$game_party.gain_item(@itemset_window.index + 1, 10)
@itemset_window.refresh
end
end
# ---------------------------
def update_var
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@var_window.visible = false
@var_window.active = false
@right_window.active = true
@right_window.refresh
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
$game_variables[@variable_edit] = @var_window.number
@var_window.visible = false
@var_window.active = false
@right_window.active = true
@right_window.refresh
end
end
# ---------------------------
def update_enemyhp
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
reset_debug
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
$game_troop.enemies[@selected_entity].hp = @enemyhp_window.number
reset_debug
end
end
# ---------------------------
def update_value
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
reset_debug
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
case @battledebug_window.index
when 0
$game_party.actors[@selected_entity].hp = @value_window.number
when 1
$game_party.actors[@selected_entity].sp = @value_window.number
when 4
$game_troop.enemies[@selected_entity].sp = @value_window.number
end
reset_debug
end
end
# ---------------------------
def debug_enemy_select
@enemy_arrow = Arrow_Enemy.new(@spriteset.viewport1)
@enemy_arrow.help_window = @help_window
end
# ---------------------------
def debug_actor_select
@actor_arrow = Arrow_Actor.new(@spriteset.viewport2)
@actor_arrow.help_window = @help_window
end
# ---------------------------
def update_debug_enemy_select
@enemy_arrow.update
@selected_entity = @enemy_arrow.index
@enemyhp_window.x = $game_troop.enemies[@selected_entity].screen_x
@enemyhp_window.y = $game_troop.enemies[@selected_entity].screen_y
@value_window.x = $game_troop.enemies[@selected_entity].screen_x
@value_window.y = $game_troop.enemies[@selected_entity].screen_y
if @enemyhp_window.x >= 494
@enemyhp_window.x = 494
end
if @value_window.x >= 532
@value_window.x = 532
end
if @enemyhp_window.y >= 416
@enemyhp_window.y = 416
end
if @value_window.y >= 416
@value_window.y = 416
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
reset_debug
@enemy_arrow.dispose
@enemy_arrow = nil
return
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
case @battledebug_window.index
when 3
@enemyhp_window.number = $game_troop.enemies[@selected_entity].hp
when 4
@value_window.number = $game_troop.enemies[@selected_entity].sp
when 5
value = @enemy_arrow.index
$game_troop.enemies[value].recover_all
$game_troop.enemies[value].damage = "Complete Healing"
$game_troop.enemies[value].damage_pop = true
when 9
value = @enemy_arrow.index
$game_troop.enemies[value].hidden = true
end
end_debug_enemy_select
end
end
# ---------------------------
def update_debug_actor_select
@actor_arrow.update
@selected_entity = @actor_arrow.index
@value_window.x = $game_party.actors[@selected_entity].screen_x
@value_window.y = $game_party.actors[@selected_entity].screen_y
if @value_window.x >= 532
@value_window.x = 532
end
if @value_window.y >= 416
@value_window.y = 416
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
reset_debug
@actor_arrow.dispose
@actor_arrow = nil
return
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
case @battledebug_window.index
when 0
@value_window.number = $game_party.actors[@selected_entity].hp
when 1
@value_window.number = $game_party.actors[@selected_entity].sp
when 2
value = @actor_arrow.index
$game_party.actors[value].recover_all
$game_party.actors[value].damage = "Complete Healing"
$game_party.actors[value].damage_pop = true
end
end_debug_actor_select
end
end
# ---------------------------
def end_debug_enemy_select
@monsterdata_window.refresh
@help_window.visible = false
case @battledebug_window.index
when 3
@enemyhp_window.active = true
@enemyhp_window.visible = true
when 4
@value_window.active = true
@value_window.visible = true
when 5
reset_debug
when 9
reset_debug
end
@enemy_arrow.dispose
@enemy_arrow = nil
end
# ---------------------------
def end_debug_actor_select
@status_window.refresh
@help_window.visible = false
case @battledebug_window.index
when 0
@value_window.active = true
@value_window.visible = true
when 1
@value_window.active = true
@value_window.visible = true
when 2
reset_debug
end
@actor_arrow.dispose
@actor_arrow = nil
end
# ---------------------------
def reset_debug
@status_window.refresh
@monsterdata_window.refresh
@count_window.refresh
@end_window.active = false
@turn_window.active = false
@enemyhp_window.active = false
@value_window.active = false
@itemset_window.active = false
@left_window.active = false
@right_window.active = false
@end_window.visible = false
@turn_window.visible = false
@enemyhp_window.visible = false
@value_window.visible = false
@itemset_window.visible = false
@left_window.visible = false
@right_window.visible = false
@help_window.visible = false
@battledebug_window.active = true
@battledebug_window.visible = true
@monsterdata_window.visible = true
@count_window.visible = true
end
# ---------------------------
end
class Window_MonsterData < Window_Base
# ---------------------------
def initialize
@count = -1
if $game_temp.in_battle == false
lines = 1
@count = 0
else
lines = $game_troop.enemies.size
end
lines += 2
super(208, 0, 432, lines * 32)
self.contents = Bitmap.new(width - 32, height - 32)
self.back_opacity = 255
self.contents.font.name = "Arial"
self.contents.font.size = 24
refresh
end
# ---------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
if @count >= 0
self.contents.draw_text(4, 0, 200, 32, "No data to display.")
self.contents.draw_text(4, 32, 400, 32,
"Monster data window was called outside of battle.")
return
end
self.contents.fill_rect(0, 32, 400, 1, normal_color)
y = 32
self.contents.draw_text(4, 0, 72, 32, "Name")
self.contents.draw_text(194, 0, 28, 32, "HP")
self.contents.draw_text(334, 0, 28, 32, "SP")
for enemy in $game_troop.enemies
self.contents.font.color = normal_color
name = enemy.name
hp = enemy.hp
max_hp = enemy.maxhp
sp = enemy.sp
max_sp = enemy.maxsp
if hp == 0 && enemy.hidden == false
self.contents.font.color = knockout_color
end
if enemy.hidden == true
self.contents.font.color = disabled_color
end
self.contents.draw_text(4, y, 150, 32, name)
self.contents.font.color = normal_color
if enemy.hidden == true
self.contents.font.color = disabled_color
end
if hp <= max_hp / 4 && enemy.hidden == false
self.contents.font.color = crisis_color
end
if hp == 0 && enemy.hidden == false
self.contents.font.color = knockout_color
end
self.contents.draw_text(132, y, 72, 32, hp.to_s, 2)
self.contents.font.color = normal_color
if enemy.hidden == true
self.contents.font.color = disabled_color
end
self.contents.draw_text(204, y, 6, 32, "/")
self.contents.font.color = normal_color
if enemy.hidden == true
self.contents.font.color = disabled_color
end
self.contents.draw_text(210, y, 72, 32, max_hp.to_s, 2)
if enemy.hidden == true
self.contents.font.color = disabled_color
end
if sp <= max_sp / 4 && enemy.hidden == false
self.contents.font.color = crisis_color
end
if sp == 0 && enemy.hidden == false
self.contents.font.color = knockout_color
end
self.contents.draw_text(296, y, 48, 32, sp.to_s, 2)
self.contents.font.color = normal_color
if enemy.hidden == true
self.contents.font.color = disabled_color
end
self.contents.draw_text(344, y, 6, 32, "/")
self.contents.font.color = normal_color
if enemy.hidden == true
self.contents.font.color = disabled_color
end
self.contents.draw_text(350, y, 48, 32, max_sp.to_s, 2)
y += 32
end
end
# ---------------------------
def update
super
if $game_temp.in_battle == false
@count += 1
end
if @count == 100
dispose
end
end
end
class Window_BattleTurn < Window_Base
# ---------------------------
def initialize(y_coord)
super(512, y_coord, 128 ,64)
self.contents = Bitmap.new(width - 32, height - 32)
self.back_opacity = 255
self.contents.font.name = "Arial"
self.contents.font.size = 24
refresh
end
# ---------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 50, 32, "Turn")
if $game_temp.in_battle
turn = $game_temp.battle_turn + 1
else
turn = 0
end
self.contents.draw_text(60, 0, 36, 32, turn.to_s, 2)
end
# ---------------------------
def update
super
end
end
class Window_Dataset < Window_Selectable
# ---------------------------
def initialize(type)
super(0, 0, 300, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.back_opacity = 160
self.contents.font.name = "Arial"
self.contents.font.size = 24
@type = type
if @type == 1
@item_max = $data_items.size - 1
end
if @type == 2
@item_max = $data_weapons.size - 1
end
if @type == 3
@item_max = $data_armors.size - 1
end
refresh
end
# ---------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
y = 0
self.contents = Bitmap.new(width - 32, 32 * @item_max)
self.contents.clear
self.contents.font.name = "Arial"
self.contents.font.size = 24
self.opacity = 255
self.back_opacity = 255
if @type == 1
for i in 1..$data_items.size - 1
draw_item_name($data_items[i], 4, i*32 - 32)
number = $game_party.item_number(i).to_s
self.contents.draw_text(4, i*32 - 32, 262, 32, number, 2)
end
end
if @type == 2
for i in 1..$data_weapons.size - 1
draw_item_name($data_weapons[i], 4, i*32 - 32)
number = $game_party.weapon_number(i).to_s
self.contents.draw_text(4, i*32 - 32, 262, 32, number, 2)
end
end
if @type == 3
for i in 1..$data_armors.size - 1
draw_item_name($data_armors[i], 4, i*32 - 32)
number = $game_party.armor_number(i).to_s
self.contents.draw_text(4, i*32 - 32, 262, 32, number, 2)
end
end
end
# ---------------------------
def update
super
end
end
And questions:
1. When I enter debug mode(pressing X button in battle), most things work fine. But when it comes to select actor or enemy, the select cursor acts weirdly. When the cursor is on first actor and you pressed right arrow key, the cursor moves to 3rd actor, not 2nd.(and if it is on 2nd, when you move it to right, you'll see it's on 4th now) Same to enemies.(No, Actor/Enemy select in battle is normal)
2. Is there a way to alias original update_phase3?
Code:
# --------------------------
alias_method :rpg_advocate_battle_debugger_update_phase3, :update_phase3
def update_phase3
if @enemy_arrow != nil && @debugging
update_debug_enemy_select
elsif @actor_arrow != nil && @debugging
update_debug_actor_select
end
rpg_advocate_battle_debugger_update_phase3
if @battledebug_window.active
update_battledebug
elsif @end_window.active
update_end
elsif @turn_window.active
update_turn
elsif @itemset_window.active
update_itemset
elsif @enemyhp_window.active
update_enemyhp
elsif @value_window.active
update_value
elsif @left_window.active
update_left
elsif @right_window.active
update_right
elsif @var_window.active
update_var
end
end
# --------------------------