查看: 2001|回复: 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楼】

[pre lang="ruby"]#==============================================================================
# 本脚本来自www.66rpg.com,转载和使用请保留此信息  
#重复上回合动作  v1.1
#by 叶子       Date: 12-12-2005
#QQ:121058265
#本脚本根据66rpg的站长柳柳提出的思路制作
#如发现有bug请与作者联系或上66rpg发贴说明
#==============================================================================
#当战斗时按下T键,
#当前角色就会重复上回合的动作(包括攻击,特技,防御,物品)。
#当战斗时按下R键,
#所有角色就会重复上回合的动作。
#当战斗时按下F键,
#所有角色就会普通攻击同一个敌人。
#脚本占用了第一号开关。
#当第一号开关打开时,重复上回合动作功能关闭。
#如果想用其他开关,改第130,263,323行中相应内容。
#--------------------------------------------------------------------------
class Game_Battler
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
   @battler_name = ""
   @battler_hue = 0
   @hp = 0
   @sp = 0
   @pp = 0
   @states = []
   @states_turn = {}
   @maxhp_plus = 0
   @maxsp_plus = 0
   @maxpp_plus = 0
   @str_plus = 0
   @dex_plus = 0
   @agi_plus = 0
   @int_plus = 0
   @hidden = false
   @immortal = false
   @damage_pop = false
   @damage = nil
   @critical = false
   @animation_id = 0
   @animation_hit = false
   @white_flash = false
   @blink = false
   @current_action = Game_BattleAction.new
   @last_action = Game_BattleAction.new
end
#--------------------------------------------------------------------------
# ● 获取前一回合的动作
#--------------------------------------------------------------------------
def last_action
   return @last_action
end
end

class Game_Party
def last_actions
   for actor in @actors
     actor.last_action.kind = actor.current_action.kind
     actor.last_action.basic = actor.current_action.basic
     actor.last_action.forcing = actor.current_action.forcing
     actor.last_action.target_index = actor.current_action.target_index
     actor.last_action.skill_id = actor.current_action.skill_id
     actor.last_action.item_id = actor.current_action.item_id
   end
end
end

class Scene_Battle
#--------------------------------------------------------------------------
# ● 开始同伴命令回合
#--------------------------------------------------------------------------
def start_phase2
   # 转移到回合 2
   @phase = 2
   # 设置角色为非选择状态
   @actor_index = -1
   @active_battler = nil
   # 有效化同伴指令窗口
   @party_command_window.active = true
   @party_command_window.visible = true
   # 无效化角色指令窗口
   @actor_command_window.active = false
   @actor_command_window.visible = false
   # 清除主回合标志
   $game_temp.battle_main_phase = false
   # 记录行动
   $game_party.last_actions
   # 清除全体同伴的行动
   $game_party.clear_actions
   # 不能输入命令的情况下
   unless $game_party.inputable?
     # 开始主回合
     start_phase4
   end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (同伴命令回合)
#--------------------------------------------------------------------------
def update_phase2
   # 按下 C 键的情况下
   if Input.trigger?(Input::C)
     # 同伴指令窗口光标位置分支
     case @party_command_window.index
     when 0  # 战斗
       # 演奏确定 SE
       $game_system.se_play($data_system.decision_se)
       # 开始角色的命令回合
       start_phase3
     when 1  # 逃跑
       # 不能逃跑的情况下
       if $game_temp.battle_can_escape == false
         # 演奏冻结 SE
         $game_system.se_play($data_system.buzzer_se)
         return
       end
       # 演奏确定 SE
       $game_system.se_play($data_system.decision_se)
       # 逃走处理
       update_phase2_escape
     end
     return
   end
   #------------------------------
   # 按下 R 键的情况下
   #------------------------------
   if Kboard.keyboard($R_Key_R)
     #如果一号开关打开就禁止重复上回合动作
     if $game_switches[1] == true #开关号可以改,把那个1改成你要的开关号
       # 演奏冻结 SE
       $game_system.se_play($data_system.buzzer_se)
       return
     end
     for a in $game_party.actors
       if a.inputable?
         case a.last_action.kind
         when 0  # 攻击,防御
           #防御
           if a.last_action.basic == 1
             # 设置行动
             a.current_action.kind = 0
             a.current_action.basic = 1
             #攻击
             else
             # 设置行动
             a.current_action.kind = 0
             a.current_action.basic = 0
             a.current_action.target_index = a.last_action.target_index
           end
         when 1  # 特技
         skill_id = a.last_action.skill_id
         if a.skill_learn?(skill_id) and  
           a.skill_can_use?(skill_id)
           # 设置行动
           a.current_action.kind = 1
           a.current_action.skill_id = a.last_action.skill_id
           a.current_action.target_index = a.last_action.target_index
         else
           # 不能使用就攻击
           if $data_skills[skill_id].scope < 3
             a.current_action.kind = 0
             a.current_action.basic = 0
             a.current_action.target_index = a.last_action.target_index
           else
             a.current_action.kind = 0
             a.current_action.basic = 0
             a.current_action.target_index = 0
           end
         end
         when 2  # 物品
           item_id = a.last_action.item_id
           if $game_party.item_can_use?(item_id)
             # 设置行动
             a.current_action.kind = 2
             a.current_action.item_id = a.last_action.item_id
             a.current_action.target_index = a.last_action.target_index
           else
             # 不能使用就攻击
             a.current_action.kind = 0
             a.current_action.basic = 0
             a.current_action.target_index = 0
           end
         end
       end
     end
     # 演奏确定 SE
     $game_system.se_play($data_system.decision_se)
     start_phase4
     return
   end
   #------------------------------
   # 按下 F 键的情况下
   #------------------------------
   if Kboard.keyboard($R_Key_T)
     for a in $game_party.actors
       if a.inputable?
         a.current_action.kind = 0
         a.current_action.basic = 0
         a.current_action.target_index = 0
       end
     end
     # 演奏确定 SE
     $game_system.se_play($data_system.decision_se)
     start_phase4
     return
   end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (角色命令回合 : 基本命令)
#--------------------------------------------------------------------------
def update_phase3_basic_command
   # 按下 B 键的情况下
   if Input.trigger?(Input::B)
     # 演奏取消 SE
     $game_system.se_play($data_system.cancel_se)
     # 转向前一个角色的指令输入
     phase3_prior_actor
     return
   end
   # 按下 C 键的情况下
   if Input.trigger?(Input::C)
     # 角色指令窗口光标位置分之
     case @actor_command_window.index
     when 0  # 攻击
       # 演奏确定 SE
       $game_system.se_play($data_system.decision_se)
       # 设置行动
       @active_battler.current_action.kind = 0
       @active_battler.current_action.basic = 0
       # 开始选择敌人
       start_enemy_select
     when 1  # 特技
       # 演奏确定 SE
       $game_system.se_play($data_system.decision_se)
       # 设置行动
       @active_battler.current_action.kind = 1
       # 开始选择特技
       start_skill_select
     when 2  # 防御
       # 演奏确定 SE
       $game_system.se_play($data_system.decision_se)
       # 设置行动
       @active_battler.current_action.kind = 0
       @active_battler.current_action.basic = 1
       # 转向下一位角色的指令输入
       phase3_next_actor
     when 3  # 物品
       # 演奏确定 SE
       $game_system.se_play($data_system.decision_se)
       # 设置行动
       @active_battler.current_action.kind = 2
       # 开始选择物品
       start_item_select
     end
     return
   end
   #------------------------------
   # 按下 T 建的情况下
   #------------------------------
   if Kboard.keyboard($R_Key_T)
     #如果一号开关打开就禁止重复上回合动作
     if $game_switches[1] == true #开关号可以改,把那个1改成你要的开关号
       # 演奏冻结 SE
       $game_system.se_play($data_system.buzzer_se)
       return
     end
     case @active_battler.last_action.kind
     when 0  # 攻击,防御
       #防御
       if @active_battler.last_action.basic == 1
         # 设置行动
         @active_battler.current_action.kind = 0
         @active_battler.current_action.basic = 1
         # 演奏确定 SE
         $game_system.se_play($data_system.decision_se)
         phase3_next_actor
         #攻击
         else
         # 演奏确定 SE
         $game_system.se_play($data_system.decision_se)
         # 设置行动
         @active_battler.current_action.kind = 0
         @active_battler.current_action.basic = 0
         @active_battler.current_action.target_index = @active_battler.last_action.target_index
         phase3_next_actor
       end
     when 1  # 特技
       skill_id = @active_battler.last_action.skill_id
       if @active_battler.skill_learn?(skill_id) and
         @active_battler.skill_can_use?(skill_id)
         # 设置行动
         @active_battler.current_action.kind = 1
         @active_battler.current_action.skill_id = @active_battler.last_action.skill_id
         @active_battler.current_action.target_index = @active_battler.last_action.target_index
         phase3_next_actor
       else
         # 演奏冻结 SE
         $game_system.se_play($data_system.buzzer_se)
       end
     when 2  # 物品
       item_id = @active_battler.last_action.item_id
       if $game_party.item_can_use?(item_id)
         # 设置行动
         @active_battler.current_action.kind = 2
         @active_battler.current_action.item_id = @active_battler.last_action.item_id
         @active_battler.current_action.target_index = @active_battler.last_action.target_index
         # 演奏确定 SE
         $game_system.se_play($data_system.decision_se)
         phase3_next_actor
       else
         # 演奏冻结 SE
         $game_system.se_play($data_system.buzzer_se)
       end
     end
     return
   end
   #------------------------------
   # 按下 R 键的情况下
   #------------------------------
   if Kboard.keyboard($R_Key_R)
     #如果一号开关打开就禁止重复上回合动作
     if $game_switches[1] == true #开关号可以改,把那个1改成你要的开关号
       # 演奏冻结 SE
       $game_system.se_play($data_system.buzzer_se)
       return
     end
     for a in $game_party.actors
       if a.inputable?
         case a.last_action.kind
         when 0  # 攻击,防御
           #防御
           if a.last_action.basic == 1
             # 设置行动
             a.current_action.kind = 0
             a.current_action.basic = 1
             #攻击
             else
             # 设置行动
             a.current_action.kind = 0
             a.current_action.basic = 0
             a.current_action.target_index = a.last_action.target_index
           end
         when 1  # 特技
         skill_id = a.last_action.skill_id
         if a.skill_learn?(skill_id) and  
           a.skill_can_use?(skill_id)
           # 设置行动
           a.current_action.kind = 1
           a.current_action.skill_id = a.last_action.skill_id
           a.current_action.target_index = a.last_action.target_index
         elsif
           # 不能使用就攻击
           if $data_skills[skill_id].scope < 3
             a.current_action.kind = 0
             a.current_action.basic = 0
             a.current_action.target_index = a.last_action.target_index
           else
             a.current_action.kind = 0
             a.current_action.basic = 0
             a.current_action.target_index = 0
           end
         end
         when 2  # 物品
           item_id = a.last_action.item_id
           if $game_party.item_can_use?(item_id)
             # 设置行动
             a.current_action.kind = 2
             a.current_action.item_id = a.last_action.item_id
             a.current_action.target_index = a.last_action.target_index
           else
             # 不能使用就攻击
             a.current_action.kind = 0
             a.current_action.basic = 0
             a.current_action.target_index = 0
           end
         end
       end
       # 角色的明灭效果 OFF
       if a != nil
         a.blink = false
       end
     end
     # 演奏确定 SE
     $game_system.se_play($data_system.decision_se)
     start_phase4
     return
   end
   #------------------------------
   # 按下 F 键的情况下
   #------------------------------
   if Kboard.keyboard($R_Key_F)
     for a in $game_party.actors
       if a.inputable?
         a.current_action.kind = 0
         a.current_action.basic = 0
         a.current_action.target_index = 0
       end
       # 角色的明灭效果 OFF
       if a != nil
         a.blink = false
       end
     end
     # 演奏确定 SE
     $game_system.se_play($data_system.decision_se)
     start_phase4
     return
   end
end
end
#==============================================================================
# 本脚本来自www.66rpg.com,转载和使用请保留此信息  
#==============================================================================
[/pre]
梦石
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
星屑
39236
在线时间
11155 小时
注册时间
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.

在本版发帖返回顶部