关于连击脚本,如何触发连击时随机选择目标?

查看数: 2129 | 评论数: 3 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2023-12-20 23:26

正文摘要:

找到一个不错的连击脚本,可以自由设计连击概率和连击次数,并且连击的时候不会消耗MP 但是仍然有一个问题,每次连击时都会选择同一个目标,与其说是连击不如叫追击 如何触发连击后,进行连击的单体技能随机选择目 ...

回复

srwjrevenger 发表于 2024-1-2 22:47:22
  1. =begin
  2. 顺便把敌人的也加了,不要就把### 1 那几行删除
  3. =end
  4. class Scene_Battle
  5. #--------------------------------------------------------------------------
  6.   # ● 设置物品或特技对像方的战斗者
  7.   #     scope : 特技或者是物品的范围
  8.   #--------------------------------------------------------------------------
  9.   def set_target_battlers(scope)
  10.     # 行动方的战斗者是敌人的情况下
  11.     if @active_battler.is_a?(Game_Enemy)
  12.       # 效果范围分支
  13.       case scope
  14.       when 1  # 敌单体
  15.         index = @active_battler.current_action.target_index
  16.         
  17.         if @连击 !=nil ### 1
  18.         @target_battlers.push($game_party.random_target_actor)
  19.         return
  20.         end
  21.       
  22.         @target_battlers.push($game_party.smooth_target_actor(index))
  23.       when 2  # 敌全体
  24.         for actor in $game_party.actors
  25.           if actor.exist?
  26.             @target_battlers.push(actor)
  27.           end
  28.         end
  29.       when 3  # 我方单体
  30.         index = @active_battler.current_action.target_index
  31.         @target_battlers.push($game_troop.smooth_target_enemy(index))
  32.       when 4  # 我方全体
  33.         for enemy in $game_troop.enemies
  34.           if enemy.exist?
  35.             @target_battlers.push(enemy)
  36.           end
  37.         end
  38.       when 5  # 我方单体 (HP 0)
  39.         index = @active_battler.current_action.target_index
  40.         enemy = $game_troop.enemies[index]
  41.         if enemy != nil and enemy.hp0?
  42.           @target_battlers.push(enemy)
  43.         end
  44.       when 6  # 我方全体 (HP 0)
  45.         for enemy in $game_troop.enemies
  46.           if enemy != nil and enemy.hp0?
  47.             @target_battlers.push(enemy)
  48.           end
  49.         end
  50.       when 7  # 使用者
  51.         @target_battlers.push(@active_battler)
  52.       end
  53.     end
  54.     # 行动方的战斗者是角色的情况下
  55.     if @active_battler.is_a?(Game_Actor)
  56.       # 效果范围分支
  57.       case scope
  58.       when 1  # 敌单体
  59.         index = @active_battler.current_action.target_index
  60.         
  61.         if @连击 !=nil ### 2
  62.         @target_battlers.push($game_troop.random_target_enemy)
  63.         return
  64.         end
  65.       
  66.         @target_battlers.push($game_troop.smooth_target_enemy(index))
  67.       when 2  # 敌全体
  68.         for enemy in $game_troop.enemies
  69.           if enemy.exist?
  70.             @target_battlers.push(enemy)
  71.           end
  72.         end
  73.       when 3  # 我方单体
  74.         index = @active_battler.current_action.target_index
  75.         @target_battlers.push($game_party.smooth_target_actor(index))
  76.       when 4  # 我方全体
  77.         for actor in $game_party.actors
  78.           if actor.exist?
  79.             @target_battlers.push(actor)
  80.           end
  81.         end
  82.       when 5  # 我方单体 (HP 0)
  83.         index = @active_battler.current_action.target_index
  84.         actor = $game_party.actors[index]
  85.         if actor != nil and actor.hp0?
  86.           @target_battlers.push(actor)
  87.         end
  88.       when 6  # 我方全体 (HP 0)
  89.         for actor in $game_party.actors
  90.           if actor != nil and actor.hp0?
  91.             @target_battlers.push(actor)
  92.           end
  93.         end
  94.       when 7  # 使用者
  95.         @target_battlers.push(@active_battler)
  96.       end
  97.     end
  98.   end
  99. end #  class
复制代码


点评

多谢,已经解决  发表于 2024-1-5 00:37

评分

参与人数 1赞 +1 收起 理由
无忧谷主幻 + 1 认可答案

查看全部评分

soulsaga 发表于 2023-12-21 00:07:54
本帖最后由 soulsaga 于 2023-12-24 14:44 编辑

[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  # 敌单体
        index = @active_battler.current_action.target_index
        if $game_temp.连击FLAG
        @target_battlers.push($game_troop.random_target_enemy)
        return
        end
        @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]

未测,

点评

你不会以为我给的脚本是直接插入的吧?那是要你改的  发表于 2024-1-4 15:49
改了,51行报错  发表于 2023-12-30 23:00
改成 if @连击 !=nil 就可以了,顺便不要像我一样忘了放在 class Scene_Battle T 口 T  发表于 2023-12-30 11:29
仍然没变化…  发表于 2023-12-25 23:50
还是不行吗?那试试这个  发表于 2023-12-24 14:45

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

在本版发帖返回顶部