查看: 5671|回复: 21

[讨论] 脚本小白学脚本@简单技能连击效果

[复制链接]
梦石
0
星屑
846
在线时间
85 小时
注册时间
2005-11-21
回帖
62
发表于 2021-12-10 19:33:50 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 黑夜守望者 于 2021-12-12 20:12 编辑

警告:后来发现本脚本修改有问题,暂时先不要用,仅供学习
有关连击推荐使用guoxiaomi大人的战斗公共事件脚本:
https://rpg.blue/thread-399295-1-13.html


看到论坛有人提问,自己琢磨了一个解决方法,不知道有没BUG
修改Scene_Battle 4里面的3处内容:
[pre lang="ruby"]#--------------------------------------------------------------------------
  # ● 开始主回合
  #--------------------------------------------------------------------------
  def start_phase4
    #+++++++++++++++++++++++++++++++++++++
    #连击次数初始化
    @times = 0
    @has_act = 0
    #+++++++++++++++++++++++++++++++++++++++
    # 转移到回合 4
    @phase = 4
    # 回合数计数
    $game_temp.battle_turn += 1
    # 搜索全页的战斗事件
    for index in 0...$data_troops[@troop_id].pages.size
      # 获取事件页
      page = $data_troops[@troop_id].pages[index]
      # 本页的范围是 [回合] 的情况下
      if page.span == 1
        # 设置已经执行标志
        $game_temp.battle_event_flags[index] = false
      end
    end
    # 设置角色为非选择状态
    @actor_index = -1
    @active_battler = nil
    # 有效化同伴指令窗口
    @party_command_window.active = false
    @party_command_window.visible = false
    # 无效化角色指令窗口
    @actor_command_window.active = false
    @actor_command_window.visible = false
    # 设置主回合标志
    $game_temp.battle_main_phase = true
    # 生成敌人行动
    for enemy in $game_troop.enemies
      enemy.make_action
    end
    # 生成行动顺序
    make_action_orders
    # 移动到步骤 1
    @phase4_step = 1
  end[/pre]
[pre lang="ruby"] #--------------------------------------------------------------------------
  # ● 生成特技行动结果
  #--------------------------------------------------------------------------
  def make_skill_action_result
    # 获取特技
    @skill = $data_skills[@active_battler.current_action.skill_id]
    # 如果不是强制行动
    unless @active_battler.current_action.forcing
      # 因为 SP 耗尽而无法使用的情况下
      unless @active_battler.skill_can_use?(@skill.id)
        # 清除强制行动对像的战斗者
        $game_temp.forcing_battler = nil
        # 移至步骤 1
        @phase4_step = 1
        return
      end
    end
    # 消耗 SP
    @active_battler.sp -= @skill.sp_cost
    # 刷新状态窗口
    @status_window.refresh
    # 在帮助窗口显示特技名
    @help_window.set_text(@skill.name, 1)
    # 设置动画 ID
    @animation1_id = @skill.animation1_id
    @animation2_id = @skill.animation2_id
    # 设置公共事件 ID
    @common_event_id = @skill.common_event_id
    # 设置对像侧战斗者
    set_target_battlers(@skill.scope)
    # 应用特技效果
    for target in @target_battlers
      target.skill_effect(@active_battler, @skill)
    end
    #++++++++++++++++++++++++++++++++++++
     if @skill.id == 82 && @has_act == 0# 连击特技id&&每步只赋值一次,如果多个连击技能就用case分歧
       @times = 2  #连击次数(攻击@times+1次)
     end
     #+++++++++++++++++++++++++++++++++++
  end[/pre]
[pre lang="ruby"]#--------------------------------------------------------------------------
  # ● 刷新画面 (主回合步骤 6 : 刷新)
  #--------------------------------------------------------------------------
  def update_phase4_step6
    # 清除强制行动对像的战斗者
    $game_temp.forcing_battler = nil
    # 公共事件 ID 有效的情况下
    if @common_event_id > 0
      # 设置事件
      common_event = $data_common_events[@common_event_id]
      $game_system.battle_interpreter.setup(common_event.list, 0)
    end
    # 移至步骤 1
#++++++++++++++++++++++++++++++++++++++++++++++++
    if @times != 0
      @times -= 1
      @has_act = 1
    for enemy in $game_troop.enemies
      if enemy.exist?     #敌人全部消灭就停止连击
        @phase4_step = 2
      else
        @phase4_step = 1
      end
    end
    else
      @phase4_step = 1
    end
#++++++++++++++++++++++++++++++++++++++++++
#   @phase4_step = 1
  end[/pre]
这样修改以后,ID为82的技能就能连续攻击3次
+号注释里面的是添加的内容
本人自开仙境传说RO怀旧1.0服务器,QQ群552321558,人不多,娱乐用。
梦石
0
星屑
846
在线时间
85 小时
注册时间
2005-11-21
回帖
62
 楼主| 发表于 2021-12-10 20:27:01 | 显示全部楼层
本帖最后由 黑夜守望者 于 2021-12-10 20:50 编辑

另外提问者似乎需要连击的时候是随机目标的,于是再改这个地方:
[pre lang="ruby"] #--------------------------------------------------------------------------
  # ● 设置物品或特技对像方的战斗者
  #     scope : 特技或者是物品的范围
  #--------------------------------------------------------------------------
  def set_target_battlers(scope)
    # 行动方的战斗者是敌人的情况下
    if @active_battler.is_a?(Game_Enemy)
      # 效果范围分支
      case scope
      when 1  # 敌单体
        index = @active_battler.current_action.target_index
        @target_battlers.push($game_party.smooth_target_actor(index))
      when 2  # 敌全体
        for actor in $game_party.actors
          if actor.exist?
            @target_battlers.push(actor)
          end
        end
      when 3  # 我方单体
        index = @active_battler.current_action.target_index
        @target_battlers.push($game_troop.smooth_target_enemy(index))
      when 4  # 我方全体
        for enemy in $game_troop.enemies
          if enemy.exist?
            @target_battlers.push(enemy)
          end
        end
      when 5  # 我方单体 (HP 0)
        index = @active_battler.current_action.target_index
        enemy = $game_troop.enemies[index]
        if enemy != nil and enemy.hp0?
          @target_battlers.push(enemy)
        end
      when 6  # 我方全体 (HP 0)
        for enemy in $game_troop.enemies
          if enemy != nil and enemy.hp0?
            @target_battlers.push(enemy)
          end
        end
      when 7  # 使用者
        @target_battlers.push(@active_battler)
      end
    end
    # 行动方的战斗者是角色的情况下
    if @active_battler.is_a?(Game_Actor)
      # 效果范围分支
      case scope
      when 1  # 敌单体
#++++++++++++++++++++++++++++++++++++++++++++++++
       if @has_act  &&  @skill_actor ==  @active_battler.id        #连击中判定&判定连击使用者
         index = rand($game_troop.enemies.size)
        else
         index = @active_battler.current_action.target_index  
       end
#+++++++++++++++++++++++++++++++++++++++++++++++++
#        index = @active_battler.current_action.target_index
        @target_battlers.push($game_troop.smooth_target_enemy(index))
      when 2  # 敌全体
        for enemy in $game_troop.enemies
          if enemy.exist?
            @target_battlers.push(enemy)
          end
        end
      when 3  # 我方单体
        index = @active_battler.current_action.target_index
        @target_battlers.push($game_party.smooth_target_actor(index))
      when 4  # 我方全体
        for actor in $game_party.actors
          if actor.exist?
            @target_battlers.push(actor)
          end
        end
      when 5  # 我方单体 (HP 0)
        index = @active_battler.current_action.target_index
        actor = $game_party.actors[index]
        if actor != nil and actor.hp0?
          @target_battlers.push(actor)
        end
      when 6  # 我方全体 (HP 0)
        for actor in $game_party.actors
          if actor != nil and actor.hp0?
            @target_battlers.push(actor)
          end
        end
      when 7  # 使用者
        @target_battlers.push(@active_battler)
      end
    end
  end[/pre]
然后make_skill_action_result要装入一个表示连击特技使用者的变量
[pre lang="ruby"]  #--------------------------------------------------------------------------
  # ● 生成特技行动结果
  #--------------------------------------------------------------------------
  def make_skill_action_result
    # 获取特技
    @skill = $data_skills[@active_battler.current_action.skill_id]
    # 如果不是强制行动
    unless @active_battler.current_action.forcing
      # 因为 SP 耗尽而无法使用的情况下
      unless @active_battler.skill_can_use?(@skill.id)
        # 清除强制行动对像的战斗者
        $game_temp.forcing_battler = nil
        # 移至步骤 1
        @phase4_step = 1
        return
      end
    end
    # 消耗 SP
    @active_battler.sp -= @skill.sp_cost
    # 刷新状态窗口
    @status_window.refresh
    # 在帮助窗口显示特技名
    @help_window.set_text(@skill.name, 1)
    # 设置动画 ID
    @animation1_id = @skill.animation1_id
    @animation2_id = @skill.animation2_id
    # 设置公共事件 ID
    @common_event_id = @skill.common_event_id
    # 设置对像侧战斗者
    set_target_battlers(@skill.scope)
    # 应用特技效果
    for target in @target_battlers
      target.skill_effect(@active_battler, @skill)
    end
    #++++++++++++++++++++++++++++++++++++
     if @skill.id == 82 && @has_act == 0# 连击特技id&&每步只赋值一次,如果多个连击技能就用case分歧
       @times = 2  #连击次数(攻击@times+1次)
       @skill_actor = @active_battler.id   #记录使用连击的角色id
     end
     #+++++++++++++++++++++++++++++++++++
  end[/pre]
本人自开仙境传说RO怀旧1.0服务器,QQ群552321558,人不多,娱乐用。
回复

使用道具 举报

梦石
0
星屑
4476
在线时间
419 小时
注册时间
2016-5-11
回帖
127
发表于 2021-12-11 12:15:30 | 显示全部楼层
感谢分享,顶支持一下
回复

使用道具 举报

素材区好人

梦石
5
星屑
12559
在线时间
4346 小时
注册时间
2011-7-21
回帖
2264

超评测参与极短28参与极短27参与极短26参与极短25参与极短24参与极短23参与极短22参与极短21参与

发表于 2021-12-11 21:02:32 | 显示全部楼层
试了一下,直接报错,无论是新工程还是改过的工程
2345截图20211211210123.png
回复

使用道具 举报

梦石
0
星屑
846
在线时间
85 小时
注册时间
2005-11-21
回帖
62
 楼主| 发表于 2021-12-11 21:04:19 | 显示全部楼层
无忧谷主幻 发表于 2021-12-11 21:02
试了一下,直接报错,无论是新工程还是改过的工程

嗯,这个不完善,我还在进一步优化。
本人自开仙境传说RO怀旧1.0服务器,QQ群552321558,人不多,娱乐用。
回复

使用道具 举报

素材区好人

梦石
5
星屑
12559
在线时间
4346 小时
注册时间
2011-7-21
回帖
2264

超评测参与极短28参与极短27参与极短26参与极短25参与极短24参与极短23参与极短22参与极短21参与

发表于 2021-12-11 21:11:41 | 显示全部楼层
黑夜守望者 发表于 2021-12-11 21:04
嗯,这个不完善,我还在进一步优化。

不知是否可以实现连击时不消耗MP
回复

使用道具 举报

梦石
0
星屑
846
在线时间
85 小时
注册时间
2005-11-21
回帖
62
 楼主| 发表于 2021-12-12 14:54:11 | 显示全部楼层
无忧谷主幻 发表于 2021-12-11 21:11
不知是否可以实现连击时不消耗MP

应该是可以,但是我也是脚本小白,容我慢慢研究研究
本人自开仙境传说RO怀旧1.0服务器,QQ群552321558,人不多,娱乐用。
回复

使用道具 举报

梦石
0
星屑
17561
在线时间
4249 小时
注册时间
2013-7-18
回帖
2491
发表于 2021-12-12 17:38:10 | 显示全部楼层
不是有连击脚本吗?何必鱼刺辛苦...
退隐....
回复

使用道具 举报

梦石
0
星屑
846
在线时间
85 小时
注册时间
2005-11-21
回帖
62
 楼主| 发表于 2021-12-12 18:09:21 | 显示全部楼层
无忧谷主幻 发表于 2021-12-11 21:11
不知是否可以实现连击时不消耗MP

我发现版主大人有可以实现连击效果的脚本,你不妨参考一下
https://rpg.blue/thread-399295-1-13.html
本人自开仙境传说RO怀旧1.0服务器,QQ群552321558,人不多,娱乐用。
回复

使用道具 举报

素材区好人

梦石
5
星屑
12559
在线时间
4346 小时
注册时间
2011-7-21
回帖
2264

超评测参与极短28参与极短27参与极短26参与极短25参与极短24参与极短23参与极短22参与极短21参与

发表于 2021-12-13 00:38:53 | 显示全部楼层
黑夜守望者 发表于 2021-12-12 18:09
我发现版主大人有可以实现连击效果的脚本,你不妨参考一下
https://rpg.blue/thread-399295-1-13.html ...

但是如果玩家能自由调整队员的位置,似乎就没用了

点评

哦..我也报错了..已修正脚本..试试?  发表于 2021-12-16 15:44
我测试过没报错..不过不知道你有没用了什么战斗脚本...  发表于 2021-12-16 15:02
确定改过了吗?用了以后还是报错了  发表于 2021-12-15 23:25
?我有写了用法吧?  发表于 2021-12-15 14:15
我试试看,如果是概率连击要怎么做?  发表于 2021-12-14 22:40
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部