查看: 2050|回复: 4

[已经解决] 关于重复上回合脚本的问题

[复制链接]
梦石
0
星屑
479
在线时间
30 小时
注册时间
2017-5-30
回帖
35
发表于 2017-10-18 18:54:19 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 樱桃丸子aab 于 2017-10-18 20:52 编辑

使用后会报错:脚本 '' 的 61行 发生了 NoMethodError
undefined method 'kind=' for nil:NilClass

可能是和我现有的脚本冲突了,请问具体要从哪个角度去排查,或者应该怎么改,麻烦了

【问题已经更新,在3楼】

  1. #==============================================================================
  2. # 本脚本来自[url=http://www.66rpg.com]www.66rpg.com[/url],转载和使用请保留此信息  
  3. #重复上回合动作  v1.1
  4. #by 叶子       Date: 12-12-2005
  5. #QQ:121058265
  6. #本脚本根据66rpg的站长柳柳提出的思路制作
  7. #如发现有bug请与作者联系或上66rpg发贴说明
  8. #==============================================================================
  9. #当战斗时按下T键,
  10. #当前角色就会重复上回合的动作(包括攻击,特技,防御,物品)。
  11. #当战斗时按下R键,
  12. #所有角色就会重复上回合的动作。
  13. #当战斗时按下F键,
  14. #所有角色就会普通攻击同一个敌人。
  15. #脚本占用了第一号开关。
  16. #当第一号开关打开时,重复上回合动作功能关闭。
  17. #如果想用其他开关,改第130,263,323行中相应内容。
  18. #--------------------------------------------------------------------------
  19. class Game_Battler
  20. #--------------------------------------------------------------------------
  21. # ● 初始化对像
  22. #--------------------------------------------------------------------------
  23. def initialize
  24.    @battler_name = ""
  25.    @battler_hue = 0
  26.    @hp = 0
  27.    @sp = 0
  28.    @pp = 0
  29.    @states = []
  30.    @states_turn = {}
  31.    @maxhp_plus = 0
  32.    @maxsp_plus = 0
  33.    @maxpp_plus = 0
  34.    @str_plus = 0
  35.    @dex_plus = 0
  36.    @agi_plus = 0
  37.    @int_plus = 0
  38.    @hidden = false
  39.    @immortal = false
  40.    @damage_pop = false
  41.    @damage = nil
  42.    @critical = false
  43.    @animation_id = 0
  44.    @animation_hit = false
  45.    @white_flash = false
  46.    @blink = false
  47.    @current_action = Game_BattleAction.new
  48.    @last_action = Game_BattleAction.new
  49. end
  50. #--------------------------------------------------------------------------
  51. # ● 获取前一回合的动作
  52. #--------------------------------------------------------------------------
  53. def last_action
  54.    return @last_action
  55. end
  56. end

  57. class Game_Party
  58. def last_actions
  59.    for actor in @actors
  60.      actor.last_action.kind = actor.current_action.kind
  61.      actor.last_action.basic = actor.current_action.basic
  62.      actor.last_action.forcing = actor.current_action.forcing
  63.      actor.last_action.target_index = actor.current_action.target_index
  64.      actor.last_action.skill_id = actor.current_action.skill_id
  65.      actor.last_action.item_id = actor.current_action.item_id
  66.    end
  67. end
  68. end

  69. class Scene_Battle
  70. #--------------------------------------------------------------------------
  71. # ● 开始同伴命令回合
  72. #--------------------------------------------------------------------------
  73. def start_phase2
  74.    # 转移到回合 2
  75.    @phase = 2
  76.    # 设置角色为非选择状态
  77.    @actor_index = -1
  78.    @active_battler = nil
  79.    # 有效化同伴指令窗口
  80.    @party_command_window.active = true
  81.    @party_command_window.visible = true
  82.    # 无效化角色指令窗口
  83.    @actor_command_window.active = false
  84.    @actor_command_window.visible = false
  85.    # 清除主回合标志
  86.    $game_temp.battle_main_phase = false
  87.    # 记录行动
  88.    $game_party.last_actions
  89.    # 清除全体同伴的行动
  90.    $game_party.clear_actions
  91.    # 不能输入命令的情况下
  92.    unless $game_party.inputable?
  93.      # 开始主回合
  94.      start_phase4
  95.    end
  96. end
  97. #--------------------------------------------------------------------------
  98. # ● 刷新画面 (同伴命令回合)
  99. #--------------------------------------------------------------------------
  100. def update_phase2
  101.    # 按下 C 键的情况下
  102.    if Input.trigger?(Input::C)
  103.      # 同伴指令窗口光标位置分支
  104.      case @party_command_window.index
  105.      when 0  # 战斗
  106.        # 演奏确定 SE
  107.        $game_system.se_play($data_system.decision_se)
  108.        # 开始角色的命令回合
  109.        start_phase3
  110.      when 1  # 逃跑
  111.        # 不能逃跑的情况下
  112.        if $game_temp.battle_can_escape == false
  113.          # 演奏冻结 SE
  114.          $game_system.se_play($data_system.buzzer_se)
  115.          return
  116.        end
  117.        # 演奏确定 SE
  118.        $game_system.se_play($data_system.decision_se)
  119.        # 逃走处理
  120.        update_phase2_escape
  121.      end
  122.      return
  123.    end
  124.    #------------------------------
  125.    # 按下 R 键的情况下
  126.    #------------------------------
  127.    if Kboard.keyboard($R_Key_R)
  128.      #如果一号开关打开就禁止重复上回合动作
  129.      if $game_switches[1] == true #开关号可以改,把那个1改成你要的开关号
  130.        # 演奏冻结 SE
  131.        $game_system.se_play($data_system.buzzer_se)
  132.        return
  133.      end
  134.      for a in $game_party.actors
  135.        if a.inputable?
  136.          case a.last_action.kind
  137.          when 0  # 攻击,防御
  138.            #防御
  139.            if a.last_action.basic == 1
  140.              # 设置行动
  141.              a.current_action.kind = 0
  142.              a.current_action.basic = 1
  143.              #攻击
  144.              else
  145.              # 设置行动
  146.              a.current_action.kind = 0
  147.              a.current_action.basic = 0
  148.              a.current_action.target_index = a.last_action.target_index
  149.            end
  150.          when 1  # 特技
  151.          skill_id = a.last_action.skill_id
  152.          if a.skill_learn?(skill_id) and  
  153.            a.skill_can_use?(skill_id)
  154.            # 设置行动
  155.            a.current_action.kind = 1
  156.            a.current_action.skill_id = a.last_action.skill_id
  157.            a.current_action.target_index = a.last_action.target_index
  158.          else
  159.            # 不能使用就攻击
  160.            if $data_skills[skill_id].scope < 3
  161.              a.current_action.kind = 0
  162.              a.current_action.basic = 0
  163.              a.current_action.target_index = a.last_action.target_index
  164.            else
  165.              a.current_action.kind = 0
  166.              a.current_action.basic = 0
  167.              a.current_action.target_index = 0
  168.            end
  169.          end
  170.          when 2  # 物品
  171.            item_id = a.last_action.item_id
  172.            if $game_party.item_can_use?(item_id)
  173.              # 设置行动
  174.              a.current_action.kind = 2
  175.              a.current_action.item_id = a.last_action.item_id
  176.              a.current_action.target_index = a.last_action.target_index
  177.            else
  178.              # 不能使用就攻击
  179.              a.current_action.kind = 0
  180.              a.current_action.basic = 0
  181.              a.current_action.target_index = 0
  182.            end
  183.          end
  184.        end
  185.      end
  186.      # 演奏确定 SE
  187.      $game_system.se_play($data_system.decision_se)
  188.      start_phase4
  189.      return
  190.    end
  191.    #------------------------------
  192.    # 按下 F 键的情况下
  193.    #------------------------------
  194.    if Kboard.keyboard($R_Key_T)
  195.      for a in $game_party.actors
  196.        if a.inputable?
  197.          a.current_action.kind = 0
  198.          a.current_action.basic = 0
  199.          a.current_action.target_index = 0
  200.        end
  201.      end
  202.      # 演奏确定 SE
  203.      $game_system.se_play($data_system.decision_se)
  204.      start_phase4
  205.      return
  206.    end
  207. end
  208. #--------------------------------------------------------------------------
  209. # ● 刷新画面 (角色命令回合 : 基本命令)
  210. #--------------------------------------------------------------------------
  211. def update_phase3_basic_command
  212.    # 按下 B 键的情况下
  213.    if Input.trigger?(Input::B)
  214.      # 演奏取消 SE
  215.      $game_system.se_play($data_system.cancel_se)
  216.      # 转向前一个角色的指令输入
  217.      phase3_prior_actor
  218.      return
  219.    end
  220.    # 按下 C 键的情况下
  221.    if Input.trigger?(Input::C)
  222.      # 角色指令窗口光标位置分之
  223.      case @actor_command_window.index
  224.      when 0  # 攻击
  225.        # 演奏确定 SE
  226.        $game_system.se_play($data_system.decision_se)
  227.        # 设置行动
  228.        @active_battler.current_action.kind = 0
  229.        @active_battler.current_action.basic = 0
  230.        # 开始选择敌人
  231.        start_enemy_select
  232.      when 1  # 特技
  233.        # 演奏确定 SE
  234.        $game_system.se_play($data_system.decision_se)
  235.        # 设置行动
  236.        @active_battler.current_action.kind = 1
  237.        # 开始选择特技
  238.        start_skill_select
  239.      when 2  # 防御
  240.        # 演奏确定 SE
  241.        $game_system.se_play($data_system.decision_se)
  242.        # 设置行动
  243.        @active_battler.current_action.kind = 0
  244.        @active_battler.current_action.basic = 1
  245.        # 转向下一位角色的指令输入
  246.        phase3_next_actor
  247.      when 3  # 物品
  248.        # 演奏确定 SE
  249.        $game_system.se_play($data_system.decision_se)
  250.        # 设置行动
  251.        @active_battler.current_action.kind = 2
  252.        # 开始选择物品
  253.        start_item_select
  254.      end
  255.      return
  256.    end
  257.    #------------------------------
  258.    # 按下 T 建的情况下
  259.    #------------------------------
  260.    if Kboard.keyboard($R_Key_T)
  261.      #如果一号开关打开就禁止重复上回合动作
  262.      if $game_switches[1] == true #开关号可以改,把那个1改成你要的开关号
  263.        # 演奏冻结 SE
  264.        $game_system.se_play($data_system.buzzer_se)
  265.        return
  266.      end
  267.      case @active_battler.last_action.kind
  268.      when 0  # 攻击,防御
  269.        #防御
  270.        if @active_battler.last_action.basic == 1
  271.          # 设置行动
  272.          @active_battler.current_action.kind = 0
  273.          @active_battler.current_action.basic = 1
  274.          # 演奏确定 SE
  275.          $game_system.se_play($data_system.decision_se)
  276.          phase3_next_actor
  277.          #攻击
  278.          else
  279.          # 演奏确定 SE
  280.          $game_system.se_play($data_system.decision_se)
  281.          # 设置行动
  282.          @active_battler.current_action.kind = 0
  283.          @active_battler.current_action.basic = 0
  284.          @active_battler.current_action.target_index = @active_battler.last_action.target_index
  285.          phase3_next_actor
  286.        end
  287.      when 1  # 特技
  288.        skill_id = @active_battler.last_action.skill_id
  289.        if @active_battler.skill_learn?(skill_id) and
  290.          @active_battler.skill_can_use?(skill_id)
  291.          # 设置行动
  292.          @active_battler.current_action.kind = 1
  293.          @active_battler.current_action.skill_id = @active_battler.last_action.skill_id
  294.          @active_battler.current_action.target_index = @active_battler.last_action.target_index
  295.          phase3_next_actor
  296.        else
  297.          # 演奏冻结 SE
  298.          $game_system.se_play($data_system.buzzer_se)
  299.        end
  300.      when 2  # 物品
  301.        item_id = @active_battler.last_action.item_id
  302.        if $game_party.item_can_use?(item_id)
  303.          # 设置行动
  304.          @active_battler.current_action.kind = 2
  305.          @active_battler.current_action.item_id = @active_battler.last_action.item_id
  306.          @active_battler.current_action.target_index = @active_battler.last_action.target_index
  307.          # 演奏确定 SE
  308.          $game_system.se_play($data_system.decision_se)
  309.          phase3_next_actor
  310.        else
  311.          # 演奏冻结 SE
  312.          $game_system.se_play($data_system.buzzer_se)
  313.        end
  314.      end
  315.      return
  316.    end
  317.    #------------------------------
  318.    # 按下 R 键的情况下
  319.    #------------------------------
  320.    if Kboard.keyboard($R_Key_R)
  321.      #如果一号开关打开就禁止重复上回合动作
  322.      if $game_switches[1] == true #开关号可以改,把那个1改成你要的开关号
  323.        # 演奏冻结 SE
  324.        $game_system.se_play($data_system.buzzer_se)
  325.        return
  326.      end
  327.      for a in $game_party.actors
  328.        if a.inputable?
  329.          case a.last_action.kind
  330.          when 0  # 攻击,防御
  331.            #防御
  332.            if a.last_action.basic == 1
  333.              # 设置行动
  334.              a.current_action.kind = 0
  335.              a.current_action.basic = 1
  336.              #攻击
  337.              else
  338.              # 设置行动
  339.              a.current_action.kind = 0
  340.              a.current_action.basic = 0
  341.              a.current_action.target_index = a.last_action.target_index
  342.            end
  343.          when 1  # 特技
  344.          skill_id = a.last_action.skill_id
  345.          if a.skill_learn?(skill_id) and  
  346.            a.skill_can_use?(skill_id)
  347.            # 设置行动
  348.            a.current_action.kind = 1
  349.            a.current_action.skill_id = a.last_action.skill_id
  350.            a.current_action.target_index = a.last_action.target_index
  351.          elsif
  352.            # 不能使用就攻击
  353.            if $data_skills[skill_id].scope < 3
  354.              a.current_action.kind = 0
  355.              a.current_action.basic = 0
  356.              a.current_action.target_index = a.last_action.target_index
  357.            else
  358.              a.current_action.kind = 0
  359.              a.current_action.basic = 0
  360.              a.current_action.target_index = 0
  361.            end
  362.          end
  363.          when 2  # 物品
  364.            item_id = a.last_action.item_id
  365.            if $game_party.item_can_use?(item_id)
  366.              # 设置行动
  367.              a.current_action.kind = 2
  368.              a.current_action.item_id = a.last_action.item_id
  369.              a.current_action.target_index = a.last_action.target_index
  370.            else
  371.              # 不能使用就攻击
  372.              a.current_action.kind = 0
  373.              a.current_action.basic = 0
  374.              a.current_action.target_index = 0
  375.            end
  376.          end
  377.        end
  378.        # 角色的明灭效果 OFF
  379.        if a != nil
  380.          a.blink = false
  381.        end
  382.      end
  383.      # 演奏确定 SE
  384.      $game_system.se_play($data_system.decision_se)
  385.      start_phase4
  386.      return
  387.    end
  388.    #------------------------------
  389.    # 按下 F 键的情况下
  390.    #------------------------------
  391.    if Kboard.keyboard($R_Key_F)
  392.      for a in $game_party.actors
  393.        if a.inputable?
  394.          a.current_action.kind = 0
  395.          a.current_action.basic = 0
  396.          a.current_action.target_index = 0
  397.        end
  398.        # 角色的明灭效果 OFF
  399.        if a != nil
  400.          a.blink = false
  401.        end
  402.      end
  403.      # 演奏确定 SE
  404.      $game_system.se_play($data_system.decision_se)
  405.      start_phase4
  406.      return
  407.    end
  408. end
  409. end
  410. #==============================================================================
  411. # 本脚本来自[url=http://www.66rpg.com]www.66rpg.com[/url],转载和使用请保留此信息  
  412. #==============================================================================
复制代码

梦石
1
星屑
24088
在线时间
3339 小时
注册时间
2011-7-8
回帖
3862

开拓者

发表于 2017-10-18 19:15:36 | 显示全部楼层
你的队伍里可能有不出战的队员?

评分

参与人数 1星屑 +30 收起 理由
RyanBern + 30 我很赞同

查看全部评分

熟悉rgss和ruby,xp区版主~
正在填坑:《膜拜组传奇》讲述膜拜组和学霸们的故事。
已上steam:与TXBD合作的Reformers《变革者》
* 战斗调用公共事件 *
* RGSOS 网络脚本 *
回复

使用道具 举报

梦石
0
星屑
479
在线时间
30 小时
注册时间
2017-5-30
回帖
35
 楼主| 发表于 2017-10-18 20:51:39 | 显示全部楼层
本帖最后由 樱桃丸子aab 于 2017-10-18 21:04 编辑
guoxiaomi 发表于 2017-10-18 19:15
你的队伍里可能有不出战的队员?

您真是一语中的!我新开游戏不会报错!
那么问题来了

问题1:这个脚本每回合开始的时候会让玩家判断是否用“R”键,所以导致敌人和玩家都卡在画面上固定不动,只有当玩家按了“R”或者回车后画面才开始动(原先应该角色的战斗图会有闪动,敌人也是,现在就卡在那里不动了),请问能否改善这种卡顿。

问题2:经过测试,这个脚本和《去掉“战斗\逃跑”,并把逃跑加入到菜单中》脚本冲突,会导致无法逃跑,脚本如下:

  1. #=======================================================================
  2. # ■ 本脚本来自 www.66rpg.com 转载和使用时请保留此信息
  3. #-----------------------------------------------------------------------
  4. #   脚本功能:去掉战斗开始时候的 战斗/逃跑 的选择过程.
  5. #             并把逃跑加入到角色命令菜单当中
  6. #   脚本作者:后知后觉  2010-8-11 13:46:59
  7. #   使用方法:直接在 Main 前插入即可
  8. #=======================================================================
  9. class Window_PartyCommand < Window_Selectable
  10.   def visible=(value)
  11.     super(false)
  12.   end
  13.   def active=(value)
  14.     super(false)
  15.   end
  16. end
  17. class Scene_Battle
  18.   alias hzhj_old_start_phase1 start_phase1
  19.   def start_phase1
  20.     class << @actor_command_window
  21.       attr_reader :commands
  22.       def commands=(value)
  23.         @commands = value
  24.         @item_max = @commands.size
  25.         self.height = @item_max * 32 + 32
  26.         self.y = [self.y - 32, 0].max
  27.         self.contents.dispose
  28.         self.contents = Bitmap.new(width - 32, height - 32)
  29.         refresh
  30.       end
  31.     end
  32.     commands = @actor_command_window.commands
  33.     unless $game_temp.battle_can_escape
  34.       @actor_command_window.disable_item(commands.size - 1)
  35.     end
  36.     hzhj_old_start_phase1
  37.   end
  38.   alias hzhj_old_start_phase2 start_phase2
  39.   def start_phase2
  40.     hzhj_old_start_phase2
  41.     if @phase == 2
  42.       start_phase3
  43.     end
  44.   end
  45.   alias hzhj_old_update_phase3_basic_command update_phase3_basic_command
  46.   def update_phase3_basic_command
  47.     hzhj_old_update_phase3_basic_command
  48.     if Input.trigger?(13)
  49.       if @actor_command_window.index == @actor_command_window.commands.size - 1
  50.         unless $game_temp.battle_can_escape
  51.           $game_system.se_play($data_system.buzzer_se)
  52.           return
  53.         end
  54.         $game_system.se_play($data_system.decision_se)
  55.         update_phase2_escape
  56.         return
  57.       end
  58.     end
  59.   end
  60. end

  61. #=======================================================================
  62. # ■ 本脚本来自 www.66rpg.com 转载和使用时请保留此信息
  63. #=======================================================================
复制代码
回复

使用道具 举报

梦石
0
星屑
39336
在线时间
11161 小时
注册时间
2009-3-15
回帖
4768
发表于 2017-10-18 22:28:14 | 显示全部楼层
樱桃丸子aab 发表于 2017-10-18 20:51
您真是一语中的!我新开游戏不会报错!
那么问题来了

战斗\逃跑脚本放在重复上次命令脚本下面试试..

评分

参与人数 1星屑 +50 收起 理由
RyanBern + 50 认可答案

查看全部评分

回复

使用道具 举报

梦石
0
星屑
479
在线时间
30 小时
注册时间
2017-5-30
回帖
35
 楼主| 发表于 2017-10-19 01:23:46 | 显示全部楼层
soulsaga 发表于 2017-10-18 22:28
战斗\逃跑脚本放在重复上次命令脚本下面试试..

您好,感谢您的解答,问题全部解决,对您佩服之极!!!!!!!!!!!!!!!!!!!!!!!!!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部