じ☆ve冰风 发表于 2024-4-19 23:05:54

【原创】Scene_Debug加强版(Ver1.2)

不知道有没有人发过类似的。系统自带的Scene_Debug的修改范围十分有限,仅仅是限制在开关/变量的操作上。而这个加强过的Scene_Debug可以实时修改更多的游戏对象,方便测试者对游戏进行测试。原理都是简单的,就是实现比较麻烦。

有什么BUG或者更好的建议希望大家能向我提出。
更新记录:
Ver 1.1(2014.9.6): 添加了修改独立开关的功能。
Ver 1.1(2014.9.7): 修复地图没有事件时出现的BUG
Ver 1.2(2014.9.11):添加了直接执行代码的功能。

几张预览图:





脚本(URL请自行去掉):
RUBY 代码
#============================================================================
# 调试画面加强版(Ver 1.2)BY : RyanBern
#----------------------------------------------------------------------------
# 系统自带的Scene_Debug可以用于实时调试游戏中的各种对象,数据,但是功能方面
# 过于单一,因此对Scene_Debug作了很多扩充。在这里你可以更改物品/武器/防具的
# 持有数,修改金钱的值,以及角色和队伍的调整。
# Ver 1.1更新:增加了独立开关的更改。
# Ver 1.2更新:增加了脚本直接输入的功能。(其实是在不关闭游戏的条件下利用外
#            部txt文档,手懒没做Text Area)
# 以后我要想到什么会陆续往上加。
#----------------------------------------------------------------------------
# 用法和默认调试画面的一样,在游戏测试模式下按F9可以打开调试画面。
# 如果要使用脚本直接输入功能的话,先进入这个选项,然后会自动在游戏根目录下生
# 成一个叫Debug.txt的文档,输入你想执行的脚本即可。这个不同于事件解释器里面
# 的“脚本”命令,例如不可以用@event_id表示当前事件ID等。如果输入了有错误的
# 代码,为了游戏的稳定,不使用rescue来补救,而是报错之后退出,所以请输入正确
# 的代码。
#----------------------------------------------------------------------------
# 脚本冲突方面,可能和独立装备系统,背包系统,人物仓库系统,多货币系统冲突。
# 说得简单点就是这个调试系统对游戏数据的更改是根据默认系统的方式,如果有别的
# 外挂脚本更改了游戏数据结构,那么这个调试系统就会失效。
#============================================================================


#============================================================================
# Game_Temp
#----------------------------------------------------------------------------
# 追加属性
#============================================================================

class Game_Temp
attr_accessor :debug_command      # 调试画面 保存状态用
alias rb_initialize initialize
def initialize
    rb_initialize
    @debug_command = 0
end
end


#============================================================================
# Window_DebugCommand
#----------------------------------------------------------------------------
# 调试画面的命令窗口(用于选取模式)
#============================================================================

class Window_DebugCommand < Window_Selectable
#--------------------------------------------------------------------------
# 初始化对象
#--------------------------------------------------------------------------
def initialize
    super(0, 0, 160, 320)
    self.index = 0
    refresh
end
#--------------------------------------------------------------------------
# 刷新
#--------------------------------------------------------------------------
def refresh
    ifself.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @item_max = 9
    self.contents = Bitmap.new(width - 32, @item_max * 32)
    self.contents.draw_text(4, 0, 120, 32, "开关")
    self.contents.draw_text(4, 32, 120, 32, "变量")
    self.contents.draw_text(4, 64, 120, 32, "物品")
    self.contents.draw_text(4, 96, 120, 32, "武器")
    self.contents.draw_text(4, 128, 120, 32, "防具")
    self.contents.draw_text(4, 160, 120, 32, "金钱")
    self.contents.draw_text(4, 192, 120, 32, "角色")
    self.contents.draw_text(4, 224, 120, 32, "独立开关")
    self.contents.draw_text(4, 256, 120, 32, "输入代码")
end
end


#==============================================================================
# ■ Window_DebugLeft
#------------------------------------------------------------------------------
#  调试画面、指定开关及变量块的窗口。
#==============================================================================

class Window_DebugLeft < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
    super(160, 0, 192, 352)
    self.active = false
    self.index = -1
    @mode = 0
    @debug_actor_items = ["替换队员", "增减等级", "增减MaxHP", "增减MaxSP",
      "增减力量", "增减灵巧", "增减速度", "增减魔力"]
    refresh
end
def adjust_cursor
    ifself.index > @item_max - 1
      self.index = @item_max - 1
    end
end
def mode=(mode)
    if@mode != mode
      @mode = mode
      refresh
    end
end
def real_max
    case@mode
    when0
      return$data_system.switches.size - 1
    when1
      return$data_system.variables.size - 1
    when2
      return$data_items.size - 1
    when3
      return$data_weapons.size - 1
    when4
      return$data_armors.size - 1
    when6
      return@debug_actor_items.size
    when7
      return@map_info.nil? ? 1 : @map_info.keys.size
    else
      return1
    end
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
    ifself.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    case@mode
    # Switches
    when0
      @item_max = ($data_system.switches.size - 1 + 9) / 10
    # Variables
    when1
      @item_max = ($data_system.variables.size - 1 + 9) / 10
    # Items
    when2
      @item_max = ($data_items.size - 1 + 9) / 10
    # Weapons
    when3
      @item_max = ($data_weapons.size - 1 + 9) / 10
    # Armors
    when4
      @item_max = ($data_armors.size - 1 + 9) / 10
    # Actors
    when6
      @item_max = @debug_actor_items.size
    # SelfSwitches
    when7
      if@map_info.nil?
      @map_info = load_data("Data/MapInfos.rxdata")
      @map_id_array = @map_info.keys.sort
      end
      @item_max = @map_info.keys.size
    else
      @item_max = 1
    end
    case@mode
    when5
      self.contents = Bitmap.new(width - 32, 32)
      self.contents.draw_text(4, 0, width - 36, 32, "点击修改金钱")
    when6
      self.contents = Bitmap.new(width - 32, @item_max * 32)
      @debug_actor_items.each_with_indexdo |item, i|
      self.contents.draw_text(4, i*32, width - 36, 32, item)
      end
    when7
      self.contents = Bitmap.new(width - 32, @item_max * 32)
      @map_id_array.each_with_indexdo |id, i|
      name = @map_info.name
      text = sprintf("%03d:%s", id, name)
      self.contents.draw_text(4, i*32, width - 36, 32, text)
      end
    when8
      self.contents = Bitmap.new(width - 32, 32)
      self.contents.draw_text(4, 0, width - 36, 32, "点击执行代码")
    else
      self.contents = Bitmap.new(width - 32, @item_max * 32)
      (0...@item_max).eachdo |i|
      text = sprintf("%s [%04d-%04d]", ["S","V","I","W","A"][@mode], i*10+1, .min)
      self.contents.draw_text(4, i*32, width - 36, 32, text)
      end
    end
end
#--------------------------------------------------------------------------
# ● 获取模式
#--------------------------------------------------------------------------
def mode
    @mode
end
#--------------------------------------------------------------------------
# ● 获取开头显示的 ID
#--------------------------------------------------------------------------
def top_id
    returnself.index * 10 + 1
end
#--------------------------------------------------------------------------
# 获取地图 ID (在模式为7[独立开关]的情况下有效)
#--------------------------------------------------------------------------
def map_id
    return@mode == 7 ? @map_id_array : 0
end
end


#==============================================================================
# ■ Window_DebugRight
#------------------------------------------------------------------------------
#  调试画面、个别显示开关及变量的窗口。
#==============================================================================

class Window_DebugRight < Window_Selectable
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader   :mode                     # 模式
attr_reader   :sub_mode               # 子模式(角色用)
attr_reader   :top_id                   # 开头显示的 ID
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
    super(160+192, 0, 448-160, 352)
    self.index = -1
    self.active = false
    @item_max = 10
    @mode = 0
    @sub_mode = -1
    @map_id = 0
    @map = nil
    @top_id = 1
    refresh
end
#--------------------------------------------------------------------------
# 获取实际显示最大项目数
# (这个方法是为了解决越界BUG)
#--------------------------------------------------------------------------
def real_max
    case@mode
    when0
      return$data_system.switches.size - 1
    when1
      return$data_system.variables.size - 1
    when2
      return$data_items.size - 1
    when3
      return$data_weapons.size - 1
    when4
      return$data_armors.size - 1
    when6
      return$data_actors.size - 1
    when7
      return@map.nil? ? 1 : 4 * @map.events.keys.size
    when8
      return3
    else
      return1
    end
end
#--------------------------------------------------------------------------
# 模式为7[独立开关]的条件下,获取当前开关的主键
#--------------------------------------------------------------------------
def key
    return[]if@mode != 7 || @item_max == 0
    event_id = @event_id_array
    tag = ['A', 'B', 'C', 'D']
    return[@map_id, event_id, tag]
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh(need_reload_map = false)
    ifself.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    if@mode == 7
      if@map.nil? || need_reload_map
      @map = load_data(sprintf("Data/Map%03d.rxdata", @map_id))
      @event_id_array = @map.events.keys.sort
      end
    end
    @item_max = .include?(@mode) ? real_max : .min
    returnif@item_max == 0
    self.contents = Bitmap.new(width - 32, @item_max * 32)
    (0...@item_max).eachdo |i|
      case@mode
      when0
      name = $data_system.switches[@top_id+i]
      status = $game_switches[@top_id+i] ? "" : ""
      when1
      name = $data_system.variables[@top_id+i]
      status = $game_variables[@top_id+i].to_s
      when2
      name = $data_items[@top_id+i].name
      status = $game_party.item_number(@top_id+i).to_s
      when3
      name = $data_weapons[@top_id+i].name
      status = $game_party.weapon_number(@top_id+i).to_s
      when4
      name = $data_armors[@top_id+i].name
      status = $game_party.armor_number(@top_id+i).to_s
      when5
      name = "金钱"
      status = $game_party.gold.to_s
      when6
      actor = $game_actors
      name = actor.name
      case@sub_mode
      when0
          status = $game_party.actors.include?(actor) ? "" : ""
      when1
          status = actor.level.to_s
      when2
          status = actor.maxhp.to_s
      when3
          status = actor.maxsp.to_s
      when4
          status = actor.str.to_s
      when5
          status = actor.dex.to_s
      when6
          status = actor.agi.to_s
      when7
          status = actor.int.to_s
      else
          status = ""
      end
      when7
      event_id = @event_id_array
      event = @map.events
      tag = ['A', 'B', 'C', 'D']
      name = event.name + " : " + tag
      status = $game_self_switches[[@map_id, event_id, tag]] ? "" : ""
      else
      name = ''
      status = ''
      end
      if name == nil
      name = ''
      end
      if@mode == 5
      self.contents.draw_text(4, 0, width - 36, 32, name)
      self.contents.draw_text(0 ,0, width - 32, 32, status, 2)
      return
      end
      if@mode == 8
      texts = []
      texts = "在游戏根目录下的"
      texts = "Debug.txt文件内键入"
      texts = "代码,点击确认键执行"
      texts.each_with_indexdo |s, i|
          self.contents.draw_text(4, 32 * i, width - 36, 32, s)
      end
      return
      end
      if@mode == 7
      self.contents.draw_text(4, i * 32, 204, 32, name)
      self.contents.draw_text(208, i * 32, 48, 32, status, 2)
      next
      end
      id_text = sprintf("%04d:", @mode == 6 ? 1+i : @top_id+i)
      self.contents.draw_text(4, i * 32, 60, 32, id_text)
      self.contents.draw_text(60, i * 32, 148, 32, name)
      self.contents.draw_text(208, i * 32, 48, 32, status, 2)
    end
end
#--------------------------------------------------------------------------
# 设置子模式(在主模式为6[角色]的时候有效)
#   sub_mode : 新的子模式
#--------------------------------------------------------------------------
def sub_mode=(sub_mode)
    if@sub_mode != sub_mode
      @sub_mode = sub_mode
      refresh
    end
end
#--------------------------------------------------------------------------
# 设置要显示的地图(在主模式为7[独立开关]的时候有效)
#   map_id : 新的地图 ID
#--------------------------------------------------------------------------
def map_id=(map_id)
    if@map_id != (map_id)
      @map_id = map_id
      refresh(true)
    end
end
#--------------------------------------------------------------------------
# ● 设置模式
#   mode : 新的模式
#--------------------------------------------------------------------------
def mode=(mode)
    if@mode != mode
      @mode = mode
      refresh if@mode != 7
    end
end
#--------------------------------------------------------------------------
# ● 设置开头显示的 ID
#   id : 新的 ID
#--------------------------------------------------------------------------
def top_id=(id)
    if@top_id != id
      @top_id = id
      refresh
    end
end
end


#==============================================================================
# ■ Scene_Debug
#------------------------------------------------------------------------------
#  处理调试画面的类。
#==============================================================================

class Scene_Debug
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
    # 生成窗口
    @command_window = Window_DebugCommand.new
    @left_window = Window_DebugLeft.new
    @right_window = Window_DebugRight.new
    @help_window = Window_Base.new(160, 352, 480, 128)
    @help_window.contents = Bitmap.new(448, 96)
    # 还原为上次选择的项目
    @command_window.index = $game_temp.debug_command
    @left_window.top_row = $game_temp.debug_top_row
    @left_window.index = $game_temp.debug_index
    @right_window.mode = @left_window.mode = @command_window.index
    @right_window.top_id = @left_window.top_id
    # 连按计数
    @press_count = 0
    # 执行过渡
    Graphics.transition
    # 主循环
    loopdo
      # 刷新游戏画面
      Graphics.update
      # 刷新输入情报
      Input.update
      # 刷新画面
      update
      # 如果画面被切换的话就中断循环
      if$scene != self
      break
      end
    end
    # 刷新地图
    $game_map.refresh
    # 装备过渡
    Graphics.freeze
    # 释放窗口
    @command_window.dispose
    @left_window.dispose
    @right_window.dispose
    @help_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
    # 刷新窗口
    @right_window.mode = @left_window.mode = @command_window.index
    @right_window.sub_mode = @left_window.indexif@left_window.mode == 6
    if@left_window.mode == 7
      @right_window.map_id = @left_window.map_id
    else
      @right_window.map_id = 0
    end
    @right_window.top_id = @left_window.top_id
    @command_window.update
    @left_window.update
    @right_window.update
    # 记忆选择中的项目
    $game_temp.debug_command = @command_window.index
    $game_temp.debug_top_row = @left_window.top_row
    $game_temp.debug_index = @left_window.index
    if@command_window.active
      update_command
      return
    end
    # 左侧窗口被激活的情况下: 调用 update_left
    if@left_window.active
      update_left
      return
    end
    # 右侧窗口被激活的情况下: 调用 update_right
    if@right_window.active
      update_right
      return
    end
end
def update_command
    @left_window.adjust_cursor
    # 按下 B 键的情况下
    if Input.trigger?(Input::B)
      # 演奏取消 SE
      $game_system.se_play($data_system.cancel_se)
      # 切换到地图画面
      $scene = Scene_Map.new
      return
    end
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      @command_window.active = false
      @left_window.active = true
      # 模式为8[执行代码]的情况下,不存在调试文件的,新建之
      if@command_window.index == 8
      text = "C (Enter) : Execute Code"
      @help_window.contents.draw_text(4, 0, 406, 32, text)
      unlessFileTest.exist?("Debug.txt")
          file = File.open("Debug.txt", "w")
          file.close
      end
      end
      return
    end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (左侧窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_left
    # 按下 B 键的情况下
    if Input.trigger?(Input::B)
      # 演奏取消 SE
      $game_system.se_play($data_system.cancel_se)
      @command_window.active = true
      @left_window.active = false
      @help_window.contents.clear
      return
    end
    # 按下 C 键的情况下
    if Input.trigger?(Input::C)
      # 演奏确定 SE
      $game_system.se_play($data_system.decision_se)
      # 显示帮助
      if@left_window.mode == 0 || @left_window.mode == 7
      text1 = "C (Enter) : ON / OFF"
      @help_window.contents.draw_text(4, 0, 406, 32, text1)
      elsif@left_window.mode == 5
      text1 = "← : -100→ : +100↑ : +1000↓ : -1000"
      text2 = "L (Pageup) : -10000"
      text3 = "R (Pagedown) : +10000"
      @help_window.contents.draw_text(4, 0, 406, 32, text1)
      @help_window.contents.draw_text(4, 32, 406, 32, text2)
      @help_window.contents.draw_text(4, 64, 406, 32, text3)
      elsif@left_window.mode == 6
      case@right_window.sub_mode
      when0
          text1 = "C (Enter) : IN / OUT"
      when1
          text1 = "← : -1   → : +1"
      when2..3
          text1 = "← : -10   → : +10"
      when4..7
          text1 = "← : -5   → : +5"
      end
      @help_window.contents.draw_text(4, 0, 406, 32, text1)
      elsif@left_window.mode != 8
      text1 = "← : -1   → : +1"
      text2 = "L (Pageup) : -10"
      text3 = "R (Pagedown) : +10"
      @help_window.contents.draw_text(4, 0, 406, 32, text1)
      @help_window.contents.draw_text(4, 32, 406, 32, text2)
      @help_window.contents.draw_text(4, 64, 406, 32, text3)
      end
      # 模式为8[执行代码]的情况下,直接执行
      if@left_window.mode == 8
      execute_code
      return
      end
      # 激活右侧窗口
      @left_window.active = false
      @right_window.active = true
      @right_window.index = 0
      return
    end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (右侧窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_right
    # 按下 B 键的情况下
    if Input.trigger?(Input::B)
      # 演奏取消 SE
      $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
    # 获取被选择的开关 / 变量的 ID
    current_id = @right_window.top_id + @right_window.index
    case@right_window.mode
    # 开关的情况下
    when0
      # 按下 C 键的情况下
      if Input.trigger?(Input::C)
      # 演奏确定 SE
      $game_system.se_play($data_system.decision_se)
      # 逆转 ON / OFF 状态
      $game_switches = (not$game_switches)
      @right_window.refresh
      return
      end
    # 变量的情况下
    when1
      # 按下右键的情况下
      if Input.repeat?(Input::RIGHT)
      # 演奏光标 SE
      $game_system.se_play($data_system.cursor_se)
      # 变量加 1
      $game_variables += 1
      # 检查上限
      if$game_variables > 99999999
          $game_variables = 99999999
      end
      @right_window.refresh
      return
      end
      # 按下左键的情况下
      if Input.repeat?(Input::LEFT)
      # 演奏光标 SE
      $game_system.se_play($data_system.cursor_se)
      # 变量减 1
      $game_variables -= 1
      # 检查下限
      if$game_variables < -99999999
          $game_variables = -99999999
      end
      @right_window.refresh
      return
      end
      # 按下 R 键的情况下
      if Input.repeat?(Input::R)
      # 演奏光标 SE
      $game_system.se_play($data_system.cursor_se)
      # 变量加 10
      $game_variables += 10
      # 检查上限
      if$game_variables > 99999999
          $game_variables = 99999999
      end
      @right_window.refresh
      return
      end
      # 按下 L 键的情况下
      if Input.repeat?(Input::L)
      # 演奏光标 SE
      $game_system.se_play($data_system.cursor_se)
      # 变量减 10
      $game_variables -= 10
      # 检查下限
      if$game_variables < -99999999
          $game_variables = -99999999
      end
      @right_window.refresh
      return
      end
    # 物品的情况下
    when2
      # 按下右键的情况下
      if Input.repeat?(Input::RIGHT)
      # 演奏光标 SE
      $game_system.se_play($data_system.cursor_se)
      # 物品数加 1
      $game_party.gain_item(current_id, 1)
      @right_window.refresh
      return
      end
      # 按下左键的情况下
      if Input.repeat?(Input::LEFT)
      # 演奏光标 SE
      $game_system.se_play($data_system.cursor_se)
      # 物品数减 1
      $game_party.lose_item(current_id, 1)
      @right_window.refresh
      return
      end
      # 按下 R 键的情况下
      if Input.repeat?(Input::R)
      # 演奏光标 SE
      $game_system.se_play($data_system.cursor_se)
      # 物品数加 10
      $game_party.gain_item(current_id, 10)
      @right_window.refresh
      return
      end
      # 按下 L 键的情况下
      if Input.repeat?(Input::L)
      # 演奏光标 SE
      $game_system.se_play($data_system.cursor_se)
      # 物品数减 10
      $game_party.lose_item(current_id, 10)
      @right_window.refresh
      return
      end
    # 武器的情况下
    when3
      # 按下右键的情况下
      if Input.repeat?(Input::RIGHT)
      # 演奏光标 SE
      $game_system.se_play($data_system.cursor_se)
      # 武器数加 1
      $game_party.gain_weapon(current_id, 1)
      @right_window.refresh
      return
      end
      # 按下左键的情况下
      if Input.repeat?(Input::LEFT)
      # 演奏光标 SE
      $game_system.se_play($data_system.cursor_se)
      # 武器数减 1
      $game_party.lose_weapon(current_id, 1)
      @right_window.refresh
      return
      end
      # 按下 R 键的情况下
      if Input.repeat?(Input::R)
      # 演奏光标 SE
      $game_system.se_play($data_system.cursor_se)
      # 武器数加 10
      $game_party.gain_weapon(current_id, 10)
      @right_window.refresh
      return
      end
      # 按下 L 键的情况下
      if Input.repeat?(Input::L)
      # 演奏光标 SE
      $game_system.se_play($data_system.cursor_se)
      # 武器数减 10
      $game_party.lose_weapon(current_id, 10)
      @right_window.refresh
      return
      end
    # 防具的情况下
    when4
      # 按下右键的情况下
      if Input.repeat?(Input::RIGHT)
      # 演奏光标 SE
      $game_system.se_play($data_system.cursor_se)
      # 防具数加 1
      $game_party.gain_armor(current_id, 1)
      @right_window.refresh
      return
      end
      # 按下左键的情况下
      if Input.repeat?(Input::LEFT)
      # 演奏光标 SE
      $game_system.se_play($data_system.cursor_se)
      # 防具数减 1
      $game_party.lose_armor(current_id, 1)
      @right_window.refresh
      return
      end
      # 按下 R 键的情况下
      if Input.repeat?(Input::R)
      # 演奏光标 SE
      $game_system.se_play($data_system.cursor_se)
      # 防具数加 10
      $game_party.gain_armor(current_id, 10)
      @right_window.refresh
      return
      end
      # 按下 L 键的情况下
      if Input.repeat?(Input::L)
      # 演奏光标 SE
      $game_system.se_play($data_system.cursor_se)
      # 防具数减 10
      $game_party.lose_armor(current_id, 10)
      @right_window.refresh
      return
      end
    # 金钱的情况下
    when5
      # 按下右键的情况下
      if Input.repeat?(Input::RIGHT)
      # 演奏光标 SE
      $game_system.se_play($data_system.cursor_se)
      # 金钱数加 100
      $game_party.gain_gold(100)
      @right_window.refresh
      return
      end
      # 按下左键的情况下
      if Input.repeat?(Input::LEFT)
      # 演奏光标 SE
      $game_system.se_play($data_system.cursor_se)
      # 金钱数减 100
      $game_party.lose_gold(100)
      @right_window.refresh
      return
      end
      if Input.repeat?(Input::UP)
      $game_system.se_play($data_system.cursor_se)
      $game_party.gain_gold(1000)
      @right_window.refresh
      return
      end
      if Input.repeat?(Input::DOWN)
      $game_system.se_play($data_system.cursor_se)
      $game_party.lose_gold(1000)
      @right_window.refresh
      return
      end
      # 按下 R 键的情况下
      if Input.repeat?(Input::R)
      # 演奏光标 SE
      $game_system.se_play($data_system.cursor_se)
      # 金钱数加 10000
      $game_party.gain_gold(10000)
      @right_window.refresh
      return
      end
      # 按下 L 键的情况下
      if Input.repeat?(Input::L)
      # 演奏光标 SE
      $game_system.se_play($data_system.cursor_se)
      # 防具数减 10
      $game_party.lose_gold(10000)
      @right_window.refresh
      return
      end
    # 角色的情况下
    when6
      update_debug_actor
    # 独立开关的情况下
    when7
      # 按下 C 键的情况下
      if Input.trigger?(Input::C)
      # 获取信息
      key = @right_window.key
      # 无效的情况下
      if key == []
          $game_system.se_play($data_system.buzzer_se)
          return
      end
      # 演奏确定 SE
      $game_system.se_play($data_system.decision_se)
      # 逆转 ON / OFF 状态
      $game_self_switches ^= true
      @right_window.refresh
      return
      end
    end
end
def update_debug_actor
    # 连按计数(只对左右键有效,这个是为了处理变化过慢的问题)
    if Input.press?(Input::LEFT) || Input.press?(Input::RIGHT)
      @press_count += 1
    else
      @press_count = 0
    end
    actor = $game_actors[@right_window.index+1]
    if Input.trigger?(Input::C)
      if@right_window.sub_mode == 0
      $game_system.se_play($data_system.decision_se)
      if$game_party.actors.include?(actor)
          $game_party.remove_actor(actor.id)
      else
          $game_party.add_actor(actor.id)
      end
      end
      return
    end
    if Input.repeat?(Input::LEFT) && @right_window.sub_mode > 0
      if@press_count80 && @press_count200
      rate = 10
      end
      $game_system.se_play($data_system.cursor_se)
      case@right_window.sub_mode
      when1
      actor.level -= 1 * rate
      when2
      actor.maxhp -= 10 * rate
      when3
      actor.maxsp -= 10 * rate
      when4
      actor.str -= 5 * rate
      when5
      actor.dex -= 5 * rate
      when6
      actor.agi -= 5 * rate
      when7
      actor.int -= 5 * rate
      end
      return
    end
    if Input.repeat?(Input::RIGHT) && @right_window.sub_mode > 0
      if@press_count80 && @press_count200
      rate = 10
      end
      $game_system.se_play($data_system.cursor_se)
      case@right_window.sub_mode
      when1
      actor.level += 1 * rate
      when2
      actor.maxhp += 10 * rate
      when3
      actor.maxsp += 10 * rate
      when4
      actor.str += 5 * rate
      when5
      actor.dex += 5 * rate
      when6
      actor.agi += 5 * rate
      when7
      actor.int += 5 * rate
      end
      return
    end
    @right_window.refresh
end
def execute_code
    ifFileTest.exist?("Debug.txt")
      file = File.open("Debug.txt", "r")
      str = file.read
      eval(str)
      file.close
      print"代码执行完毕!"
    else
      print'找不到文件"Debug.txt"'
    end
end
end

            本帖来自P1论坛作者1041235896,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=371014若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。
页: [1]
查看完整版本: 【原创】Scene_Debug加强版(Ver1.2)