设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2051|回复: 3
打印 上一主题 下一主题

[原创发布] 按键重复上次技能系统(2017.2.6 更新)

[复制链接]

Lv2.观梦者

梦石
0
星屑
305
在线时间
95 小时
注册时间
2012-8-24
帖子
34
跳转到指定楼层
1
发表于 2016-11-18 11:50:22 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 我是好人a1a1 于 2017-2-6 08:40 编辑

#=============================================================================
#按键重复上次技能系统(2017.2.6 更新) (part 3)
#-----------------------------------------------------------------------------
# by我是好人a1a1     
# 这是第3部分,最复杂的部分。第1,2部分是定义的部分。为了避免第1部分太长,第2,3部分太短,留意不到,第2,3部分在2楼补充
# 编写和调试了十天,由于改的地方太多
# 只能用part 3替换Scene_Battle 3,再追加part 1和part 2的定义,就能实现按键重复上次技能
# 使用方法:在选择攻击,技能,防御,物品的画面,按下Shift,重复上次技能
# PS:与涉及Scene_Battle 3重定义的复杂脚本一起使用,会发生冲突
#=============================================================================
class Scene_Battle
  #--------------------------------------------------------------------------
  # ● 开始角色命令回合
  #--------------------------------------------------------------------------
  def start_phase3
    # 转移到回合 3
    @phase = 3
    # 设置角色为非选择状态
    @actor_index = -1
    @active_battler = nil
    # 输入下一个角色的命令
    phase3_next_actor
  end
  #--------------------------------------------------------------------------
  # ● 转到输入下一个角色的命令
  #--------------------------------------------------------------------------
  def phase3_next_actor
    # 循环
    begin
      # 角色的明灭效果 OFF
      if @active_battler != nil
        @active_battler.blink = false
      end
      # 最后的角色的情况
      if @actor_index == $game_party.actors.size-1
        # 开始主回合
        start_phase4
        return
      end
      # 推进角色索引
      @actor_index += 1
      @active_battler = $game_party.actors[@actor_index]
      @active_battler.blink = true
    # 如果角色是在无法接受指令的状态就再试
    end until @active_battler.inputable?
    # 设置角色的命令窗口
    phase3_setup_command_window
  end
  #--------------------------------------------------------------------------
  # ● 转向前一个角色的命令输入
  #--------------------------------------------------------------------------
  def phase3_prior_actor
    # 循环
    begin
      # 角色的明灭效果 OFF
      if @active_battler != nil
        @active_battler.blink = false
      end
      # 最初的角色的情况下
      if @actor_index == 0
        # 开始同伴指令回合
        start_phase2
        return
      end
      # 返回角色索引
      @actor_index -= 1
      @active_battler = $game_party.actors[@actor_index]
      @active_battler.blink = true
    # 如果角色是在无法接受指令的状态就再试
    end until @active_battler.inputable?
    # 设置角色的命令窗口
    phase3_setup_command_window
  end
  #--------------------------------------------------------------------------
  # ● 设置角色指令窗口
  #--------------------------------------------------------------------------
  def phase3_setup_command_window
    # 同伴指令窗口无效化
    @party_command_window.active = false
    @party_command_window.visible = false
    # 角色指令窗口无效化
    @actor_command_window.active = true
    @actor_command_window.visible = true
    # 设置角色指令窗口的位置
    @actor_command_window.x = @actor_index * 160
    # 设置索引为 0
    @actor_command_window.index = 0
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面 (角色命令回合)
  #--------------------------------------------------------------------------
  def update_phase3
    # 敌人光标有效的情况下
    if @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
    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
    if Input.trigger?(Input::SHIFT)      
       $game_system.se_play($data_system.decision_se)      
        again_skill
      end      
       def again_skill
        if $game_system.last_skill[@active_battler.id] == nil
          $game_system.se_play($data_system.cancel_se)
          print "没有上次技能使用记录"  
          return
        else
          @skill =  $data_skills[$game_system.last_skill[@active_battler.id]]
          @haoren = 0
         if @skill == nil or not @active_battler.skill_can_use?(@skill.id)           
           if @skill == nil         
           print  "没有上次技能使用记录"
           else
           print  "剩余魔法不足"
           end
         # 演奏冻结 SE
         $game_system.se_play($data_system.buzzer_se)
         return
         end        
       end
      # 演奏确定 SE
      $game_system.se_play($data_system.decision_se)
      @haoren = 0
      # 设置行动
      @active_battler.current_action.kind = 1
      @active_battler.current_action.skill_id = @skill.id
      # 设置特技窗口为不可见状态
      #@skill_window.visible = false
      # 效果范围是敌单体的情况下
      if @skill.scope == 1
        # 开始选择敌人
        start_enemy_select
      # 效果范围是我方单体的情况下
      elsif @skill.scope == 3 or @skill.scope == 5
        # 开始选择角色
        start_actor_select
      # 效果范围不是单体的情况下
      else
        # 选择特技结束
        end_last_select
        # 转到下一位角色的指令输入
        phase3_next_actor
     end
end
    # 按下 C 键的情况下
    if Input.trigger?(Input::C)
      @haoren = -1
      # 角色指令窗口光标位置分之
      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
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面 (角色命令回合 : 选择特技)
  #--------------------------------------------------------------------------
  def update_phase3_skill_select
    # 设置特技窗口为可视状态
    @skill_window.visible = true
    # 刷新特技窗口
    @skill_window.update
    # 按下 B 键的情况下
    if Input.trigger?(Input::B)
      # 演奏取消 SE
      $game_system.se_play($data_system.cancel_se)
      # 结束特技选择
      end_skill_select
      return
    end
    # 按下 C 键的情况下
    if Input.trigger?(Input::C)
      # 获取特技选择窗口现在选择的特技的数据
      @skill = @skill_window.skill
      # 无法使用的情况下
      if @skill == nil or not @active_battler.skill_can_use?(@skill.id)
        # 演奏冻结 SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # 演奏确定 SE
      $game_system.se_play($data_system.decision_se)
      # 设置行动
      @active_battler.current_action.skill_id = @skill.id
      $game_system.last_skill[@active_battler.id] = @active_battler.current_action.skill_id
      # 设置特技窗口为不可见状态
      @skill_window.visible = false
      # 效果范围是敌单体的情况下
      if @skill.scope == 1
        # 开始选择敌人
        start_enemy_select
      # 效果范围是我方单体的情况下
      elsif @skill.scope == 3 or @skill.scope == 5
        # 开始选择角色
        start_actor_select
      # 效果范围不是单体的情况下
      else
        # 选择特技结束
        end_skill_select
        # 转到下一位角色的指令输入
        phase3_next_actor
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面 (角色命令回合 : 选择物品)
  #--------------------------------------------------------------------------
  def update_phase3_item_select
    # 设置物品窗口为可视状态
    @item_window.visible = true
    # 刷新物品窗口
    @item_window.update
    # 按下 B 键的情况下
    if Input.trigger?(Input::B)
      # 演奏取消 SE
      $game_system.se_play($data_system.cancel_se)
      # 选择物品结束
      end_item_select
      return
    end
    # 按下 C 键的情况下
    if Input.trigger?(Input::C)
      # 获取物品窗口现在选择的物品资料
      @item = @item_window.item
      # 无法使用的情况下
      unless $game_party.item_can_use?(@item.id)
        # 演奏冻结 SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # 演奏确定 SE
      $game_system.se_play($data_system.decision_se)
      # 设置行动
      @active_battler.current_action.item_id = @item.id
      # 设置物品窗口为不可见状态
      @item_window.visible = false
      # 效果范围是敌单体的情况下
      if @item.scope == 1
        # 开始选择敌人
        start_enemy_select
      # 效果范围是我方单体的情况下
      elsif @item.scope == 3 or @item.scope == 5
        # 开始选择角色
        start_actor_select
      # 效果范围不是单体的情况下
      else
        # 物品选择结束
        end_item_select
        # 转到下一位角色的指令输入
        phase3_next_actor
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面画面 (角色命令回合 : 选择敌人)
  #--------------------------------------------------------------------------
  def update_phase3_enemy_select
    # 刷新敌人箭头
    @enemy_arrow.update
    # 按下 B 键的情况下
    if Input.trigger?(Input::B)
      # 演奏取消 SE
      $game_system.se_play($data_system.cancel_se)
      # 选择敌人结束
      end_enemy_select
      return
    end
    # 按下 C 键的情况下
    if Input.trigger?(Input::C)
      # 演奏确定 SE
      $game_system.se_play($data_system.decision_se)
      # 设置行动
      @active_battler.current_action.target_index = @enemy_arrow.index
      # 选择敌人结束
      end_enemy_select
      # 显示特技窗口中的情况下
      if @skill_window != nil
        # 结束特技选择
        end_skill_select
      end
      # 显示物品窗口的情况下
      if @item_window != nil
        # 结束物品选择
        end_item_select
      end
      # 转到下一位角色的指令输入
      phase3_next_actor
    end
  end
  #--------------------------------------------------------------------------
  # ● 画面更新 (角色指令回合 : 选择角色)
  #--------------------------------------------------------------------------
  def update_phase3_actor_select
    # 刷新角色箭头
    @actor_arrow.update
    # 按下 B 键的情况下
    if Input.trigger?(Input::B)
      # 演奏取消 SE
      $game_system.se_play($data_system.cancel_se)
      # 选择角色结束
      end_actor_select
      return
    end
    # 按下 C 键的情况下
    if Input.trigger?(Input::C)
      # 演奏确定 SE
      $game_system.se_play($data_system.decision_se)
      # 设置行动
      @active_battler.current_action.target_index = @actor_arrow.index
      # 选择角色结束
      end_actor_select
      # 显示特技窗口中的情况下
      if @skill_window != nil
        # 结束特技选择
        end_skill_select
      end
      # 显示物品窗口的情况下
      if @item_window != nil
        # 结束物品选择
        end_item_select
      end
      # 转到下一位角色的指令输入
      phase3_next_actor
    end
  end
  #--------------------------------------------------------------------------
  # ● 开始选择敌人
  #--------------------------------------------------------------------------
  def start_enemy_select
    # 生成敌人箭头
    @enemy_arrow = Arrow_Enemy.new(@spriteset.viewport1)
    # 关联帮助窗口
    @enemy_arrow.help_window = @help_window
    # 无效化角色指令窗口
    @actor_command_window.active = false
    @actor_command_window.visible = false
  end
  #--------------------------------------------------------------------------
  # ● 结束选择敌人
  #--------------------------------------------------------------------------
  def end_enemy_select
    # 释放敌人箭头
    @enemy_arrow.dispose
    @enemy_arrow = nil
    # 指令为 [战斗] 的情况下
    if @actor_command_window.index == 0
      # 有效化角色指令窗口
      @actor_command_window.active = true
      @actor_command_window.visible = true
      # 隐藏帮助窗口
      @help_window.visible = false
    end
    if @actor_command_window.index != 0 and @haoren == 0
      # 有效化角色指令窗口
      #@actor_command_window.index = 0
      @actor_command_window.active = true
      @actor_command_window.visible = true
      # 隐藏帮助窗口
      @help_window.visible = false
      @skill_window = nil
      #update_phase3
      #skill_window.active  =  false
      #skill_window.visible =  false
      #update_phase3_basic_command
    end
  end
  #--------------------------------------------------------------------------
  # ● 开始选择角色
  #--------------------------------------------------------------------------
  def start_actor_select
    # 生成角色箭头
    @actor_arrow = Arrow_Actor.new(@spriteset.viewport2)
    @actor_arrow.index = @actor_index
    # 关联帮助窗口
    @actor_arrow.help_window = @help_window
    # 无效化角色指令窗口
    @actor_command_window.active = false
    @actor_command_window.visible = false
  end
  #--------------------------------------------------------------------------
  # ● 结束选择角色
  #--------------------------------------------------------------------------
   def end_actor_select
    # 释放角色箭头
    @actor_arrow.dispose
    @actor_arrow = nil
    if  @haoren == 0
      # 有效化角色指令窗口
      #@actor_command_window.index = 0
      @actor_command_window.active = true
      @actor_command_window.visible = true
      @help_window.visible = false
      @skill_window = nil
      #update_phase3
      # 隐藏帮助窗口
      #skill_window.active  =  false
      #skill_window.visible =  false
      #update_phase3_basic_command
    end
  end
  #--------------------------------------------------------------------------
  # ● 开始选择特技
  #--------------------------------------------------------------------------
  def start_skill_select
    # 生成特技窗口
    @skill_window = Window_Skill.new(@active_battler)
    # 关联帮助窗口
    @skill_window.help_window = @help_window
    # 无效化角色指令窗口
    @actor_command_window.active = false
    @actor_command_window.visible = false
  end
  #--------------------------------------------------------------------------
  # ● 选择特技结束
  #--------------------------------------------------------------------------
  def end_skill_select
    # 释放特技窗口
    @skill_window.dispose
    @skill_window = nil
    # 隐藏帮助窗口
    @help_window.visible = false
    # 有效化角色指令窗口
    @actor_command_window.active = true
    @actor_command_window.visible = true
  end
  def end_last_select
    # 隐藏帮助窗口
    @help_window.visible = false
    # 有效化角色指令窗口
    @actor_command_window.active = true
    @actor_command_window.visible = true
  end
  #--------------------------------------------------------------------------
  # ● 开始选择物品
  #--------------------------------------------------------------------------
  def start_item_select
    # 生成物品窗口
    @item_window = Window_Item.new
    # 关联帮助窗口
    @item_window.help_window = @help_window
    # 无效化角色指令窗口
    @actor_command_window.active = false
    @actor_command_window.visible = false
  end
  #--------------------------------------------------------------------------
  # ● 结束选择物品
  #--------------------------------------------------------------------------
  def end_item_select
    # 释放物品窗口
    @item_window.dispose
    @item_window = nil
    # 隐藏帮助窗口
    @help_window.visible = false
    # 有效化角色指令窗口
    @actor_command_window.active = true
    @actor_command_window.visible = true
  end
end

Lv2.观梦者

梦石
0
星屑
305
在线时间
95 小时
注册时间
2012-8-24
帖子
34
2
 楼主| 发表于 2016-11-18 11:58:54 | 只看该作者
part 1 定义上次技能
把attr_accessor :last_skill添加到Game_System  ● 定义实例变量
part 2 初始化上次技能
把$game_system.last_skill = []添加到Scene_Battle 1 的main
推荐搭配脚本
[RMXP发布] 技能按照sp消耗排序系统(2016.11.8 更新)  [复制链接]   
https://rpg.blue/forum.php?mod=viewthread&tid=397241

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
14 小时
注册时间
2013-10-15
帖子
30
3
发表于 2017-1-15 02:14:15 | 只看该作者
我是好人a1a1 发表于 2016-11-18 11:58
part 1 定义上次技能
把attr_accessor :last_skill添加到Game_System  ● 定义实例变量
part 2 初始化上次 ...

大神什么意思我小白不懂,我只要把一楼的脚本复制过去就可以用了吗?还是其他脚本也要跟着改?
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
305
在线时间
95 小时
注册时间
2012-8-24
帖子
34
4
 楼主| 发表于 2017-2-6 08:25:57 | 只看该作者
本帖最后由 我是好人a1a1 于 2017-2-6 08:34 编辑
烈焰冲锋 发表于 2017-1-15 02:14
大神什么意思我小白不懂,我只要把一楼的脚本复制过去就可以用了吗?还是其他脚本也要跟着改? ...


不好意思,因为D盘存满了,最近在处理D盘文件,很长时间没上6r。
这个脚本,编写的时候是很复杂很辛苦的,如果有人能用的到,
自然很高兴,很乐意解答

#-----------------------------------------------------------------------------
# by我是好人a1a1     
# 这是part 3,最复杂的部分。part1和part2是定义的部分。为了避免part 1太长,part2和part3太短,留意不到,part2,3在2楼补充
嗯,这是1楼的使用说明,先复制过来。

这段话的意思是,我把脚本分割成了三个部分,这是part 3,最复杂的部分。就是说这只是最复杂的第3部分。
第1,2部分是定义的部分,就是先定义重复技能的相关概念,然后第3部分才是具体运行的程序。
所以用了第3部分,还需要再添加第1,2部分,才能使用。

如果还有问题,请继续追问。
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-29 18:40

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表