查看: 3291|回复: 2

[原创发布] 状态限制

[复制链接]

薄凉看客

梦石
0
星屑
50
在线时间
1269 小时
注册时间
2010-6-20
回帖
1223
发表于 2014-11-2 20:04:30 | 显示全部楼层 |阅读模式

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

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

×
没什么可说的。。。


工程 状态限制.zip (230.86 KB, 下载次数: 94)


脚本
[pre lang="ruby" line="1"]#==============================================================================
# ■ States_Restrict(封系状态)
#------------------------------------------------------------------------------
#
#   * 说明:脚本定义了新的限制,原状态限制作废。
#           不建议作为插件使用,最好和其他脚本整合一下(难度很低)。
#
#  * 命名:英语渣,大家就凑合看吧。
#
#   * 冲突:重定义了 update_phase4_step2       主回合步骤 2 : 开始行动
#           重定义了 make_basic_action_result  生成基本行动结果
#           重定义了 make_skill_action_result  生成特技行动结果
#           重定义了 make_item_action_result   生成物品行动结果
#
#==============================================================================

module States_Restrict
  # - 优先级(按照从低到高的顺序排列)
  Priority = []
  # * 攻击
  Priority[0] = ["B", "A", "C"]
  # * 特技
  Priority[1] = ["C", "B", "A"]
  # * 物品
  Priority[2] = ["C", "B", "A"]
  
  # - 设置
  A_States_Restrict_To_Attack = [16]  # 不可攻击
  B_States_Restrict_To_Attack = []    # 只能普通攻击敌人
  C_States_Restrict_To_Attack = [15]  # 只能普通攻击同伴
  
  A_States_Restrict_To_Skill = []     # 不可(使用)技能
  B_States_Restrict_To_Skill = [14]   # 只可对敌人(只能使用攻击类技能)
  C_States_Restrict_To_Skill = []     # 只可对同伴(只能使用辅助类技能)
  
  A_States_Restrict_To_Item = [13]    # 不可(使用)物品
  B_States_Restrict_To_Item = []      # 只可对敌人(只能使用暗器类物品)
  C_States_Restrict_To_Item = []      # 只可对同伴(只能使用辅助类物品)
  
  States_Restrict_To_Guard = [16]     # 不可防御
  
  # - 用语(不用管)
  A_States_Restrict_To_Attack_Word = "不可攻击"
  B_States_Restrict_To_Attack_Word = "只能普通攻击敌人"
  C_States_Restrict_To_Attack_Word = "只能普通攻击同伴"
  
  A_States_Restrict_To_Skill_Word = "不可(使用)技能"
  B_States_Restrict_To_Skill_Word = "只可对敌人"
  C_States_Restrict_To_Skill_Word = "只可对同伴"
  
  A_States_Restrict_To_Item_Word = "不可(使用)物品"
  B_States_Restrict_To_Item_Word = "只可对敌人"
  C_States_Restrict_To_Item_Word = "只可对同伴"
  
  States_Restrict_To_Guard_Word = "不可防御"
  
end

class Game_Battler
  def restriction_zhouzhou
   
    command = []
    # - 攻击指令
    for index in States_Restrict::Priority[0]
      if index == "B"
        if (@states & States_Restrict::B_States_Restrict_To_Attack).size > 0
          command[0] = States_Restrict::B_States_Restrict_To_Attack_Word
        end
      elsif index == "A"
        if (@states & States_Restrict::A_States_Restrict_To_Attack).size > 0
          command[0] = States_Restrict::A_States_Restrict_To_Attack_Word
        end
      elsif index == "C"
        if (@states & States_Restrict::C_States_Restrict_To_Attack).size > 0
          command[0] = States_Restrict::C_States_Restrict_To_Attack_Word
        end
      end
    end
  
    # - 特技指令
    for index in States_Restrict::Priority[1]
      if index == "C"
        if (@states & States_Restrict::C_States_Restrict_To_Skill).size > 0
          command[1] = States_Restrict::C_States_Restrict_To_Skill_Word
        end
      elsif index == "B"
        if (@states & States_Restrict::B_States_Restrict_To_Skill).size > 0
          command[1] = States_Restrict::B_States_Restrict_To_Skill_Word
        end
      elsif index == "A"
        if (@states & States_Restrict::A_States_Restrict_To_Skill).size > 0
          command[1] = States_Restrict::A_States_Restrict_To_Skill_Word
        end
      end
    end
   
    # - 物品指令
    for index in States_Restrict::Priority[2]
      if index == "C"
        if (@states & States_Restrict::C_States_Restrict_To_Item).size > 0
          command[2] = States_Restrict::C_States_Restrict_To_Item_Word
        end
      elsif index == "B"
        if (@states & States_Restrict::B_States_Restrict_To_Item).size > 0
          command[2] = States_Restrict::B_States_Restrict_To_Item_Word
        end
      elsif index == "A"
        if (@states & States_Restrict::A_States_Restrict_To_Item).size > 0
          command[2] = States_Restrict::A_States_Restrict_To_Item_Word
        end
      end
    end
   
    # - 防御指令
    if (@states & States_Restrict::States_Restrict_To_Guard).size > 0
      command[3] = States_Restrict::States_Restrict_To_Guard_Word
    end
   
    return command
   
  end
end

# - 参战人数
class Game_Party
  def exist_size
    actor_size = 0
    for i in $game_party.actors
      actor_size += 1 if i.exist?
    end
    return actor_size
  end
end
class Game_Troop
  def exist_size
    actor_size = 0
    for i in $game_troop.enemies
      actor_size += 1 if i.exist?
    end
    return actor_size
  end
end

class Scene_Battle
  # - 检查限制
  def check_to_restrict
    re = @active_battler.restriction_zhouzhou
    # - 攻击
    if re[0] != nil
      # - 限制
      if (@active_battler.current_action.kind != 0 or
        @active_battler.current_action.basic != 0) and
        re[0] != States_Restrict::A_States_Restrict_To_Attack_Word
        @active_battler.current_action.kind = 0
        @active_battler.current_action.basic = 0
      # - 无效指令
      elsif @active_battler.current_action.kind == 0 and
        @active_battler.current_action.basic == 0 and
        re[0] == States_Restrict::A_States_Restrict_To_Attack_Word
        # 清除行动强制对像的战斗者
        $game_temp.forcing_battler = nil
        # 移至步骤 1
        @phase4_step = 1
        return
      end
    end
    # - 特技
    if re[1] != nil
      if @active_battler.current_action.kind == 1 and
        re[1] == States_Restrict::A_States_Restrict_To_Skill_Word
        # 清除行动强制对像的战斗者
        $game_temp.forcing_battler = nil
        # 移至步骤 1
        @phase4_step = 1
        return
      end
    end
    # - 物品
    if re[2] != nil
      if @active_battler.current_action.kind == 2 and
        re[2] == States_Restrict::A_States_Restrict_To_Item_Word
        # 清除行动强制对像的战斗者
        $game_temp.forcing_battler = nil
        # 移至步骤 1
        @phase4_step = 1
        return
      end
    end
    # - 防御
    if re[3] != nil
      if @active_battler.current_action.kind == 0 and
        @active_battler.current_action.basic == 1
        # 清除行动强制对像的战斗者
        $game_temp.forcing_battler = nil
        # 移至步骤 1
        @phase4_step = 1
        return
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面 (主回合步骤 2 : 开始行动)
  #--------------------------------------------------------------------------
  def update_phase4_step2
    # 如果不是强制行动
    unless @active_battler.current_action.forcing
      check_to_restrict
    end
    # 清除对像战斗者
    @target_battlers = []
    # 行动种类分支
    case @active_battler.current_action.kind
    when 0  # 基本
      make_basic_action_result
    when 1  # 特技
      make_skill_action_result
    when 2  # 物品
      make_item_action_result
    end
    # 移至步骤 3
    if @phase4_step == 2
      @phase4_step = 3
    end
  end
  #--------------------------------------------------------------------------
  # ● 生成基本行动结果
  #--------------------------------------------------------------------------
  def make_basic_action_result
    # 攻击的情况下
    if @active_battler.current_action.basic == 0
      re = @active_battler.restriction_zhouzhou[0]
      # 设置攻击 ID
      @animation1_id = @active_battler.animation1_id
      @animation2_id = @active_battler.animation2_id
      # 行动方的战斗者是敌人的情况下
      if @active_battler.is_a?(Game_Enemy)
        # - 普通攻击同伴
        if re == States_Restrict::C_States_Restrict_To_Attack_Word
          if $game_troop.exist_size > 1
            target = $game_troop.random_target_enemy
            while target == @active_battler
              target = $game_troop.random_target_enemy
            end
          else
            # 清除强制行动对像的战斗者
            $game_temp.forcing_battler = nil
            # 移至步骤 1
            @phase4_step = 1
            return
          end
        # - 普通攻击敌人
        elsif re == States_Restrict::B_States_Restrict_To_Attack_Word
          target = $game_party.random_target_actor
        # - 无限制
        elsif re == nil
          index = @active_battler.current_action.target_index
          target = $game_party.smooth_target_actor(index)
        else
          return
        end
      end
      # 行动方的战斗者是角色的情况下
      if @active_battler.is_a?(Game_Actor)
        # - 普通攻击同伴
        if re == States_Restrict::C_States_Restrict_To_Attack_Word
          if $game_party.exist_size > 1
            target = $game_party.random_target_actor
            while target == @active_battler
              target = $game_party.random_target_actor
            end
          else
            # 清除强制行动对像的战斗者
            $game_temp.forcing_battler = nil
            # 移至步骤 1
            @phase4_step = 1
            return
          end
        # - 普通攻击敌人
        elsif re == States_Restrict::B_States_Restrict_To_Attack_Word
          target = $game_troop.random_target_enemy
        # - 无限制
        elsif re == nil
          index = @active_battler.current_action.target_index
          target = $game_troop.smooth_target_enemy(index)
        else
          return
        end
      end
      # 设置对像方的战斗者序列
      @target_battlers = [target]
      # 应用通常攻击效果
      for target in @target_battlers
        target.attack_effect(@active_battler)
      end
      return
    end
    # 防御的情况下
    if @active_battler.current_action.basic == 1
      # 帮助窗口显示"防御"
      @help_window.set_text($data_system.words.guard, 1)
      return
    end
    # 逃跑的情况下
    if @active_battler.is_a?(Game_Enemy) and
       @active_battler.current_action.basic == 2
      #  帮助窗口显示"逃跑"
      @help_window.set_text("逃跑", 1)
      # 逃跑
      @active_battler.escape
      return
    end
    # 什么也不做的情况下
    if @active_battler.current_action.basic == 3
      # 清除强制行动对像的战斗者
      $game_temp.forcing_battler = nil
      # 移至步骤 1
      @phase4_step = 1
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● 生成特技行动结果
  #--------------------------------------------------------------------------
  def make_skill_action_result
    re = @active_battler.restriction_zhouzhou[1]
    # 获取特技
    @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
    # 设置对像侧战斗者
    set_target_battlers(@skill.scope)
    # - 限制特技
    case re
    when States_Restrict::A_States_Restrict_To_Skill_Word
      # 清除强制行动对像的战斗者
      $game_temp.forcing_battler = nil
      # 移至步骤 1
      @phase4_step = 1
      return
    when States_Restrict::B_States_Restrict_To_Skill_Word
      if @active_battler.is_a?(Game_Actor)
        if @target_battlers[0].is_a?(Game_Actor)
          # 清除强制行动对像的战斗者
          $game_temp.forcing_battler = nil
          # 移至步骤 1
          @phase4_step = 1
          return
        end
      elsif @active_battler.is_a?(Game_Enemy)
        if @target_battlers[0].is_a?(Game_Enemy)
          # 清除强制行动对像的战斗者
          $game_temp.forcing_battler = nil
          # 移至步骤 1
          @phase4_step = 1
          return
        end
      end
    when States_Restrict::C_States_Restrict_To_Skill_Word
      if @active_battler.is_a?(Game_Actor)
        if @target_battlers[0].is_a?(Game_Enemy)
          # 清除强制行动对像的战斗者
          $game_temp.forcing_battler = nil
          # 移至步骤 1
          @phase4_step = 1
          return
        end
      elsif @active_battler.is_a?(Game_Enemy)
        if @target_battlers[0].is_a?(Game_Actor)
          # 清除强制行动对像的战斗者
          $game_temp.forcing_battler = nil
          # 移至步骤 1
          @phase4_step = 1
          return
        end
      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
    # 应用特技效果
    for target in @target_battlers
      target.skill_effect(@active_battler, @skill)
    end
  end
  #--------------------------------------------------------------------------
  # ● 生成物品行动结果
  #--------------------------------------------------------------------------
  def make_item_action_result
    re = @active_battler.restriction_zhouzhou[2]
    # 获取物品
    @item = $data_items[@active_battler.current_action.item_id]
    # 因为物品耗尽而无法使用的情况下
    unless $game_party.item_can_use?(@item.id)
      # 移至步骤 1
      @phase4_step = 1
      return
    end
    # 设置对像侧战斗者
    set_target_battlers(@item.scope)
    # - 限制物品
    case re
    when States_Restrict::A_States_Restrict_To_Item_Word
      # 清除强制行动对像的战斗者
      $game_temp.forcing_battler = nil
      # 移至步骤 1
      @phase4_step = 1
      return
    when States_Restrict::B_States_Restrict_To_Item_Word
      if @active_battler.is_a?(Game_Actor)
        if @target_battlers[0].is_a?(Game_Actor)
          # 清除强制行动对像的战斗者
          $game_temp.forcing_battler = nil
          # 移至步骤 1
          @phase4_step = 1
          return
        end
      elsif @active_battler.is_a?(Game_Enemy)
        if @target_battlers[0].is_a?(Game_Enemy)
          # 清除强制行动对像的战斗者
          $game_temp.forcing_battler = nil
          # 移至步骤 1
          @phase4_step = 1
          return
        end
      end
    when States_Restrict::C_States_Restrict_To_Item_Word
      if @active_battler.is_a?(Game_Actor)
        if @target_battlers[0].is_a?(Game_Enemy)
          # 清除强制行动对像的战斗者
          $game_temp.forcing_battler = nil
          # 移至步骤 1
          @phase4_step = 1
          return
        end
      elsif @active_battler.is_a?(Game_Enemy)
        if @target_battlers[0].is_a?(Game_Actor)
          # 清除强制行动对像的战斗者
          $game_temp.forcing_battler = nil
          # 移至步骤 1
          @phase4_step = 1
          return
        end
      end
    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
    # 应用物品效果
    for target in @target_battlers
      target.item_effect(@item)
    end
  end
end
#------------------------------------------------------------------------------[/pre]
梦石
0
星屑
211
在线时间
905 小时
注册时间
2010-9-6
回帖
3138
发表于 2014-11-5 09:51:36 来自手机 | 显示全部楼层
好像很久以前就已经有状态限制技能的脚本了,而且比写个简便的说…
回复

使用道具 举报

梦石
0
星屑
9292
在线时间
2504 小时
注册时间
2011-5-20
回帖
14521

开拓者

发表于 2014-11-6 22:12:03 | 显示全部楼层
如果想要中一个状态谁都可以攻击呢(比如主力队友中了睡眠需要辅助队友攻击解除掉)

点评

这里面的禁用物品是只有某个角色行动时不能使用物品还是所有的都不能?(个人认为如果是所有的角色都不能用的话可以不用弄那么长一段···)  发表于 2014-11-7 21:49
这个问题没有考虑。不过这个脚本还是有一些BUG的  发表于 2014-11-7 00:07
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部