查看: 89|回复: 0

[转载发布] 多秒 - 多体攻击

[复制链接]
  • TA的每日心情
    开心
    7 小时前
  • 签到天数: 37 天

    连续签到: 3 天

    [LV.5]常住居民I

    2028

    主题

    32

    回帖

    7260

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    0
    卡币
    5184
    OK点
    16
    积分
    7260
    发表于 同元一千年八月五日(秋) | 显示全部楼层 |阅读模式
    物品 特技 均支持
    想秒几就秒几

    rgss1

    class Scene_Battle
      def set_target_battlers(item, type)
       
        @多秒_特技 = {} # 初始化多秒功能哈希
        @多秒_物品 = {} # 初始化多秒功能哈希
            
        # ---------------------------
        # 特技多秒 设置
        # ---------------------------
            
        @多秒_特技[57] = 3 # 57号技能 秒3 默认十字斩秒三
       
        # ---------------------------
        # 物品多秒 设置
        # ---------------------------
            
        @多秒_物品[40] = 5 # 40号物品 秒5 设置 : 敌单体即可 HP 回复量 为负值
       
        # ------------------------------------------------------
        # PS 如果设置了多秒 数据库 中效果范围怎么设置都可以
        # 但必须明确是对敌使用还是对同伴使用,并且明确 是否
        # HP 0 时使用!
        # ------------------------------------------------------
       
        if @active_battler.is_a?(Game_Enemy)
          case item.scope
          when 1  # 敌单体
            index = @active_battler.current_action.target_index
            @target_battlers.push($game_party.smooth_target_actor(index))
            敌方秒(0, item, 0, type, $game_party.smooth_target_actor(index))
          when 2  # 敌全体
            index = @active_battler.current_action.target_index
            for actor in $game_party.actors
              if actor.exist?
                @target_battlers.push(actor)
              end
            end
            敌方秒(0, item, 0, type, $game_party.smooth_target_actor(index))
          when 3  # 我方单体
            index = @active_battler.current_action.target_index
            @target_battlers.push($game_troop.smooth_target_enemy(index))
            敌方秒(0, item, 1, type, $game_troop.smooth_target_enemy(index))
          when 4  # 我方全体
            index = @active_battler.current_action.target_index
            for enemy in $game_troop.enemies
              if enemy.exist?
                @target_battlers.push(enemy)
              end
            end
            敌方秒(0, item, 1, type, $game_troop.smooth_target_enemy(index))
          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
            敌方秒(1, item, 1, type, $game_troop.smooth_target_enemy(index))
          when 6  # 我方全体 (HP 0)
            index = @active_battler.current_action.target_index
            for enemy in $game_troop.enemies
              if enemy != nil and enemy.hp0?
                @target_battlers.push(enemy)
              end
            end
            敌方秒(1, item, 1, type, $game_troop.smooth_target_enemy(index))
          when 7  # 使用者
            @target_battlers.push(@active_battler)
          end
        end
        if @active_battler.is_a?(Game_Actor)
          # 效果范围分支
          case item.scope
          when 1  # 敌单体
            index = @active_battler.current_action.target_index
            @target_battlers.push($game_troop.smooth_target_enemy(index))
            我方秒(0, item, 0, type, $game_troop.smooth_target_enemy(index))
          when 2  # 敌全体
            index = @active_battler.current_action.target_index
            for enemy in $game_troop.enemies
              if enemy.exist?
                @target_battlers.push(enemy)
              end
            end
            我方秒(0, item, 0, type, $game_troop.smooth_target_enemy(index))
          when 3  # 我方单体
            index = @active_battler.current_action.target_index
            @target_battlers.push($game_party.smooth_target_actor(index))
            我方秒(0, item, 1, type, $game_party.smooth_target_actor(index))
          when 4  # 我方全体
            index = @active_battler.current_action.target_index
            for actor in $game_party.actors
              if actor.exist?
                @target_battlers.push(actor)
              end
            end
            我方秒(0, item, 1, type, $game_party.smooth_target_actor(index))
          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
            我方秒(1, item, 1, type, $game_party.smooth_target_actor(index))
          when 6  # 我方全体 (HP 0)
            index = @active_battler.current_action.target_index
            for actor in $game_party.actors
              if actor != nil and actor.hp0?
                @target_battlers.push(actor)
              end
            end
            我方秒(1, item, 1, type, $game_party.smooth_target_actor(index))
          when 7  # 使用者
            @target_battlers.push(@active_battler)
          end
        end
      end
      #--------------------------------------------------------------------------
      # ● 生成特技行动结果
      #--------------------------------------------------------------------------
      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, 0)
        # ---------------------------------------
       
        # 应用特技效果
        for target in @target_battlers
          target.skill_effect(@active_battler, @skill)
        end
      end
      #--------------------------------------------------------------------------
      # ● 生成物品行动结果
      #--------------------------------------------------------------------------
      def make_item_action_result
        # 获取物品
        @item = $data_items[@active_battler.current_action.item_id]
        # 因为物品耗尽而无法使用的情况下
        unless $game_party.item_can_use?(@item.id)
          # 移至步骤 1
          @phase4_step = 1
          return
        end
        # 消耗品的情况下
        if @item.consumable
          # 使用的物品减 1
          $game_party.lose_item(@item.id, 1)
        end
        # 在帮助窗口显示物品名
        @help_window.set_text(@item.name, 1)
        # 设置动画 ID
        @animation1_id = @item.animation1_id
        @animation2_id = @item.animation2_id
        # 设置公共事件 ID
        @common_event_id = @item.common_event_id
        # 确定对像
        index = @active_battler.current_action.target_index
        target = $game_party.smooth_target_actor(index)
        # 设置对像侧战斗者
       
        # ---------------------------------------
        set_target_battlers(@item, 1)
        # ---------------------------------------
       
        # 应用物品效果
        for target in @target_battlers
          target.item_effect(@item)
        end
      end
      
      def 敌方秒(n, item, t, type, 目标)
        # ----------------------------------------
        return if @多秒_特技[item.id].nil? and @多秒_物品[item.id].nil?
        @target_battlers = []
        case t
        when 0
          for actor in $game_party.actors
            @target_battlers.push(actor) if actor.exist?
          end
        when 1
          for enemy in $game_troop.enemies
            @target_battlers.push(enemy) if enemy.exist?
          end
        end
        return if @多秒_特技[item.id] >= @target_battlers.size
        while @target_battlers.size > @多秒_特技[item.id]
          a = rand(@target_battlers.size)
          unless a == @target_battlers.size - 1 or
            # 如果用了我发布的嘲讽状态脚本 请把后边的注释去掉!
            @target_battlers[a] == 目标# or @target_battlers[a].state? Wall
            @target_battlers.delete_at(a)
          end
        end
        # -------------------------------------------
      end
      #   参数   是否hp0 项目 对敌还是对友 特技还是物品 目标
      def 我方秒(n, item, t, type, 目标)
        # ----------------------------------------
        return if @多秒_特技[item.id].nil? and @多秒_物品[item.id].nil?
        @target_battlers = []
        case type
        when 0 # 特技
          case t
          when 0
            for enemy in $game_troop.enemies
              case n
              when 0
                @target_battlers.push(enemy) if enemy.exist?
              when 1
                @target_battlers.push(enemy) unless enemy.exist?
              end
            end
          when 1
            for actor in $game_party.actors
              case n
              when 0
                @target_battlers.push(actor) if actor.exist?
              when 1
                @target_battlers.push(actor) unless actor.exist?
              end
            end
          end
          return if @多秒_特技[item.id] >= @target_battlers.size
          while @target_battlers.size > @多秒_特技[item.id]
            a = rand(@target_battlers.size)
            unless a == @target_battlers.size - 1 or
              @target_battlers[a] == 目标
              @target_battlers.delete_at(a)
            end
          end
        when 1 # 物品
          case t
          when 0
            for enemy in $game_troop.enemies
              case n
              when 0
                @target_battlers.push(enemy) if enemy.exist?
              when 1
                @target_battlers.push(enemy) unless enemy.exist?
              end
            end
          when 1
            for actor in $game_party.actors
              case n
              when 0
                @target_battlers.push(actor) if actor.exist?
              when 1
                @target_battlers.push(actor) unless actor.exist?
              end
            end
          end
          return if @多秒_物品[item.id] >= @target_battlers.size
          while @target_battlers.size > @多秒_物品[item.id]
            a = rand(@target_battlers.size)
            unless a == @target_battlers.size - 1 or
              @target_battlers[a] == 目标
              @target_battlers.delete_at(a)
            end
          end
        end
        # ----------------------------------------
      end
      
    end


                 本帖来自P1论坛作者恐惧剑刃,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=350002  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。

    本帖子中包含更多资源

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

    x
    天天去同能,天天有童年!
    回复 论坛版权

    使用道具 举报

    ahome_bigavatar:guest
    ahome_bigavatar:welcomelogin
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2024-5-10 16:56 , Processed in 0.049566 second(s), 44 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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