查看: 3332|回复: 2

[原创发布] 状态限制

[复制链接]

薄凉看客

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

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

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

×
没什么可说的。。。


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


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

  16. module States_Restrict
  17.   # - 优先级(按照从低到高的顺序排列)
  18.   Priority = []
  19.   # * 攻击
  20.   Priority[0] = ["B", "A", "C"]
  21.   # * 特技
  22.   Priority[1] = ["C", "B", "A"]
  23.   # * 物品
  24.   Priority[2] = ["C", "B", "A"]
  25.   
  26.   # - 设置
  27.   A_States_Restrict_To_Attack = [16]  # 不可攻击
  28.   B_States_Restrict_To_Attack = []    # 只能普通攻击敌人
  29.   C_States_Restrict_To_Attack = [15]  # 只能普通攻击同伴
  30.   
  31.   A_States_Restrict_To_Skill = []     # 不可(使用)技能
  32.   B_States_Restrict_To_Skill = [14]   # 只可对敌人(只能使用攻击类技能)
  33.   C_States_Restrict_To_Skill = []     # 只可对同伴(只能使用辅助类技能)
  34.   
  35.   A_States_Restrict_To_Item = [13]    # 不可(使用)物品
  36.   B_States_Restrict_To_Item = []      # 只可对敌人(只能使用暗器类物品)
  37.   C_States_Restrict_To_Item = []      # 只可对同伴(只能使用辅助类物品)
  38.   
  39.   States_Restrict_To_Guard = [16]     # 不可防御
  40.   
  41.   # - 用语(不用管)
  42.   A_States_Restrict_To_Attack_Word = "不可攻击"
  43.   B_States_Restrict_To_Attack_Word = "只能普通攻击敌人"
  44.   C_States_Restrict_To_Attack_Word = "只能普通攻击同伴"
  45.   
  46.   A_States_Restrict_To_Skill_Word = "不可(使用)技能"
  47.   B_States_Restrict_To_Skill_Word = "只可对敌人"
  48.   C_States_Restrict_To_Skill_Word = "只可对同伴"
  49.   
  50.   A_States_Restrict_To_Item_Word = "不可(使用)物品"
  51.   B_States_Restrict_To_Item_Word = "只可对敌人"
  52.   C_States_Restrict_To_Item_Word = "只可对同伴"
  53.   
  54.   States_Restrict_To_Guard_Word = "不可防御"
  55.   
  56. end

  57. class Game_Battler
  58.   def restriction_zhouzhou
  59.    
  60.     command = []
  61.     # - 攻击指令
  62.     for index in States_Restrict::Priority[0]
  63.       if index == "B"
  64.         if (@states & States_Restrict::B_States_Restrict_To_Attack).size > 0
  65.           command[0] = States_Restrict::B_States_Restrict_To_Attack_Word
  66.         end
  67.       elsif index == "A"
  68.         if (@states & States_Restrict::A_States_Restrict_To_Attack).size > 0
  69.           command[0] = States_Restrict::A_States_Restrict_To_Attack_Word
  70.         end
  71.       elsif index == "C"
  72.         if (@states & States_Restrict::C_States_Restrict_To_Attack).size > 0
  73.           command[0] = States_Restrict::C_States_Restrict_To_Attack_Word
  74.         end
  75.       end
  76.     end
  77.   
  78.     # - 特技指令
  79.     for index in States_Restrict::Priority[1]
  80.       if index == "C"
  81.         if (@states & States_Restrict::C_States_Restrict_To_Skill).size > 0
  82.           command[1] = States_Restrict::C_States_Restrict_To_Skill_Word
  83.         end
  84.       elsif index == "B"
  85.         if (@states & States_Restrict::B_States_Restrict_To_Skill).size > 0
  86.           command[1] = States_Restrict::B_States_Restrict_To_Skill_Word
  87.         end
  88.       elsif index == "A"
  89.         if (@states & States_Restrict::A_States_Restrict_To_Skill).size > 0
  90.           command[1] = States_Restrict::A_States_Restrict_To_Skill_Word
  91.         end
  92.       end
  93.     end
  94.    
  95.     # - 物品指令
  96.     for index in States_Restrict::Priority[2]
  97.       if index == "C"
  98.         if (@states & States_Restrict::C_States_Restrict_To_Item).size > 0
  99.           command[2] = States_Restrict::C_States_Restrict_To_Item_Word
  100.         end
  101.       elsif index == "B"
  102.         if (@states & States_Restrict::B_States_Restrict_To_Item).size > 0
  103.           command[2] = States_Restrict::B_States_Restrict_To_Item_Word
  104.         end
  105.       elsif index == "A"
  106.         if (@states & States_Restrict::A_States_Restrict_To_Item).size > 0
  107.           command[2] = States_Restrict::A_States_Restrict_To_Item_Word
  108.         end
  109.       end
  110.     end
  111.    
  112.     # - 防御指令
  113.     if (@states & States_Restrict::States_Restrict_To_Guard).size > 0
  114.       command[3] = States_Restrict::States_Restrict_To_Guard_Word
  115.     end
  116.    
  117.     return command
  118.    
  119.   end
  120. end

  121. # - 参战人数
  122. class Game_Party
  123.   def exist_size
  124.     actor_size = 0
  125.     for i in $game_party.actors
  126.       actor_size += 1 if i.exist?
  127.     end
  128.     return actor_size
  129.   end
  130. end
  131. class Game_Troop
  132.   def exist_size
  133.     actor_size = 0
  134.     for i in $game_troop.enemies
  135.       actor_size += 1 if i.exist?
  136.     end
  137.     return actor_size
  138.   end
  139. end

  140. class Scene_Battle
  141.   # - 检查限制
  142.   def check_to_restrict
  143.     re = @active_battler.restriction_zhouzhou
  144.     # - 攻击
  145.     if re[0] != nil
  146.       # - 限制
  147.       if (@active_battler.current_action.kind != 0 or
  148.         @active_battler.current_action.basic != 0) and
  149.         re[0] != States_Restrict::A_States_Restrict_To_Attack_Word
  150.         @active_battler.current_action.kind = 0
  151.         @active_battler.current_action.basic = 0
  152.       # - 无效指令
  153.       elsif @active_battler.current_action.kind == 0 and
  154.         @active_battler.current_action.basic == 0 and
  155.         re[0] == States_Restrict::A_States_Restrict_To_Attack_Word
  156.         # 清除行动强制对像的战斗者
  157.         $game_temp.forcing_battler = nil
  158.         # 移至步骤 1
  159.         @phase4_step = 1
  160.         return
  161.       end
  162.     end
  163.     # - 特技
  164.     if re[1] != nil
  165.       if @active_battler.current_action.kind == 1 and
  166.         re[1] == States_Restrict::A_States_Restrict_To_Skill_Word
  167.         # 清除行动强制对像的战斗者
  168.         $game_temp.forcing_battler = nil
  169.         # 移至步骤 1
  170.         @phase4_step = 1
  171.         return
  172.       end
  173.     end
  174.     # - 物品
  175.     if re[2] != nil
  176.       if @active_battler.current_action.kind == 2 and
  177.         re[2] == States_Restrict::A_States_Restrict_To_Item_Word
  178.         # 清除行动强制对像的战斗者
  179.         $game_temp.forcing_battler = nil
  180.         # 移至步骤 1
  181.         @phase4_step = 1
  182.         return
  183.       end
  184.     end
  185.     # - 防御
  186.     if re[3] != nil
  187.       if @active_battler.current_action.kind == 0 and
  188.         @active_battler.current_action.basic == 1
  189.         # 清除行动强制对像的战斗者
  190.         $game_temp.forcing_battler = nil
  191.         # 移至步骤 1
  192.         @phase4_step = 1
  193.         return
  194.       end
  195.     end
  196.   end
  197.   #--------------------------------------------------------------------------
  198.   # ● 刷新画面 (主回合步骤 2 : 开始行动)
  199.   #--------------------------------------------------------------------------
  200.   def update_phase4_step2
  201.     # 如果不是强制行动
  202.     unless @active_battler.current_action.forcing
  203.       check_to_restrict
  204.     end
  205.     # 清除对像战斗者
  206.     @target_battlers = []
  207.     # 行动种类分支
  208.     case @active_battler.current_action.kind
  209.     when 0  # 基本
  210.       make_basic_action_result
  211.     when 1  # 特技
  212.       make_skill_action_result
  213.     when 2  # 物品
  214.       make_item_action_result
  215.     end
  216.     # 移至步骤 3
  217.     if @phase4_step == 2
  218.       @phase4_step = 3
  219.     end
  220.   end
  221.   #--------------------------------------------------------------------------
  222.   # ● 生成基本行动结果
  223.   #--------------------------------------------------------------------------
  224.   def make_basic_action_result
  225.     # 攻击的情况下
  226.     if @active_battler.current_action.basic == 0
  227.       re = @active_battler.restriction_zhouzhou[0]
  228.       # 设置攻击 ID
  229.       @animation1_id = @active_battler.animation1_id
  230.       @animation2_id = @active_battler.animation2_id
  231.       # 行动方的战斗者是敌人的情况下
  232.       if @active_battler.is_a?(Game_Enemy)
  233.         # - 普通攻击同伴
  234.         if re == States_Restrict::C_States_Restrict_To_Attack_Word
  235.           if $game_troop.exist_size > 1
  236.             target = $game_troop.random_target_enemy
  237.             while target == @active_battler
  238.               target = $game_troop.random_target_enemy
  239.             end
  240.           else
  241.             # 清除强制行动对像的战斗者
  242.             $game_temp.forcing_battler = nil
  243.             # 移至步骤 1
  244.             @phase4_step = 1
  245.             return
  246.           end
  247.         # - 普通攻击敌人
  248.         elsif re == States_Restrict::B_States_Restrict_To_Attack_Word
  249.           target = $game_party.random_target_actor
  250.         # - 无限制
  251.         elsif re == nil
  252.           index = @active_battler.current_action.target_index
  253.           target = $game_party.smooth_target_actor(index)
  254.         else
  255.           return
  256.         end
  257.       end
  258.       # 行动方的战斗者是角色的情况下
  259.       if @active_battler.is_a?(Game_Actor)
  260.         # - 普通攻击同伴
  261.         if re == States_Restrict::C_States_Restrict_To_Attack_Word
  262.           if $game_party.exist_size > 1
  263.             target = $game_party.random_target_actor
  264.             while target == @active_battler
  265.               target = $game_party.random_target_actor
  266.             end
  267.           else
  268.             # 清除强制行动对像的战斗者
  269.             $game_temp.forcing_battler = nil
  270.             # 移至步骤 1
  271.             @phase4_step = 1
  272.             return
  273.           end
  274.         # - 普通攻击敌人
  275.         elsif re == States_Restrict::B_States_Restrict_To_Attack_Word
  276.           target = $game_troop.random_target_enemy
  277.         # - 无限制
  278.         elsif re == nil
  279.           index = @active_battler.current_action.target_index
  280.           target = $game_troop.smooth_target_enemy(index)
  281.         else
  282.           return
  283.         end
  284.       end
  285.       # 设置对像方的战斗者序列
  286.       @target_battlers = [target]
  287.       # 应用通常攻击效果
  288.       for target in @target_battlers
  289.         target.attack_effect(@active_battler)
  290.       end
  291.       return
  292.     end
  293.     # 防御的情况下
  294.     if @active_battler.current_action.basic == 1
  295.       # 帮助窗口显示"防御"
  296.       @help_window.set_text($data_system.words.guard, 1)
  297.       return
  298.     end
  299.     # 逃跑的情况下
  300.     if @active_battler.is_a?(Game_Enemy) and
  301.        @active_battler.current_action.basic == 2
  302.       #  帮助窗口显示"逃跑"
  303.       @help_window.set_text("逃跑", 1)
  304.       # 逃跑
  305.       @active_battler.escape
  306.       return
  307.     end
  308.     # 什么也不做的情况下
  309.     if @active_battler.current_action.basic == 3
  310.       # 清除强制行动对像的战斗者
  311.       $game_temp.forcing_battler = nil
  312.       # 移至步骤 1
  313.       @phase4_step = 1
  314.       return
  315.     end
  316.   end
  317.   #--------------------------------------------------------------------------
  318.   # ● 生成特技行动结果
  319.   #--------------------------------------------------------------------------
  320.   def make_skill_action_result
  321.     re = @active_battler.restriction_zhouzhou[1]
  322.     # 获取特技
  323.     [url=home.php?mod=space&uid=260100]@skill[/url] = $data_skills[@active_battler.current_action.skill_id]
  324.     # 如果不是强制行动
  325.     unless @active_battler.current_action.forcing
  326.       # 因为 SP 耗尽而无法使用的情况下
  327.       unless @active_battler.skill_can_use?(@skill.id)
  328.         # 清除强制行动对像的战斗者
  329.         $game_temp.forcing_battler = nil
  330.         # 移至步骤 1
  331.         @phase4_step = 1
  332.         return
  333.       end
  334.     end
  335.     # 设置对像侧战斗者
  336.     set_target_battlers(@skill.scope)
  337.     # - 限制特技
  338.     case re
  339.     when States_Restrict::A_States_Restrict_To_Skill_Word
  340.       # 清除强制行动对像的战斗者
  341.       $game_temp.forcing_battler = nil
  342.       # 移至步骤 1
  343.       @phase4_step = 1
  344.       return
  345.     when States_Restrict::B_States_Restrict_To_Skill_Word
  346.       if @active_battler.is_a?(Game_Actor)
  347.         if @target_battlers[0].is_a?(Game_Actor)
  348.           # 清除强制行动对像的战斗者
  349.           $game_temp.forcing_battler = nil
  350.           # 移至步骤 1
  351.           @phase4_step = 1
  352.           return
  353.         end
  354.       elsif @active_battler.is_a?(Game_Enemy)
  355.         if @target_battlers[0].is_a?(Game_Enemy)
  356.           # 清除强制行动对像的战斗者
  357.           $game_temp.forcing_battler = nil
  358.           # 移至步骤 1
  359.           @phase4_step = 1
  360.           return
  361.         end
  362.       end
  363.     when States_Restrict::C_States_Restrict_To_Skill_Word
  364.       if @active_battler.is_a?(Game_Actor)
  365.         if @target_battlers[0].is_a?(Game_Enemy)
  366.           # 清除强制行动对像的战斗者
  367.           $game_temp.forcing_battler = nil
  368.           # 移至步骤 1
  369.           @phase4_step = 1
  370.           return
  371.         end
  372.       elsif @active_battler.is_a?(Game_Enemy)
  373.         if @target_battlers[0].is_a?(Game_Actor)
  374.           # 清除强制行动对像的战斗者
  375.           $game_temp.forcing_battler = nil
  376.           # 移至步骤 1
  377.           @phase4_step = 1
  378.           return
  379.         end
  380.       end
  381.     end
  382.     # 消耗 SP
  383.     @active_battler.sp -= @skill.sp_cost
  384.     # 刷新状态窗口
  385.     @status_window.refresh
  386.     # 在帮助窗口显示特技名
  387.     @help_window.set_text(@skill.name, 1)
  388.     # 设置动画 ID
  389.     @animation1_id = @skill.animation1_id
  390.     @animation2_id = @skill.animation2_id
  391.     # 设置公共事件 ID
  392.     @common_event_id = @skill.common_event_id
  393.     # 应用特技效果
  394.     for target in @target_battlers
  395.       target.skill_effect(@active_battler, @skill)
  396.     end
  397.   end
  398.   #--------------------------------------------------------------------------
  399.   # ● 生成物品行动结果
  400.   #--------------------------------------------------------------------------
  401.   def make_item_action_result
  402.     re = @active_battler.restriction_zhouzhou[2]
  403.     # 获取物品
  404.     @item = $data_items[@active_battler.current_action.item_id]
  405.     # 因为物品耗尽而无法使用的情况下
  406.     unless $game_party.item_can_use?(@item.id)
  407.       # 移至步骤 1
  408.       @phase4_step = 1
  409.       return
  410.     end
  411.     # 设置对像侧战斗者
  412.     set_target_battlers(@item.scope)
  413.     # - 限制物品
  414.     case re
  415.     when States_Restrict::A_States_Restrict_To_Item_Word
  416.       # 清除强制行动对像的战斗者
  417.       $game_temp.forcing_battler = nil
  418.       # 移至步骤 1
  419.       @phase4_step = 1
  420.       return
  421.     when States_Restrict::B_States_Restrict_To_Item_Word
  422.       if @active_battler.is_a?(Game_Actor)
  423.         if @target_battlers[0].is_a?(Game_Actor)
  424.           # 清除强制行动对像的战斗者
  425.           $game_temp.forcing_battler = nil
  426.           # 移至步骤 1
  427.           @phase4_step = 1
  428.           return
  429.         end
  430.       elsif @active_battler.is_a?(Game_Enemy)
  431.         if @target_battlers[0].is_a?(Game_Enemy)
  432.           # 清除强制行动对像的战斗者
  433.           $game_temp.forcing_battler = nil
  434.           # 移至步骤 1
  435.           @phase4_step = 1
  436.           return
  437.         end
  438.       end
  439.     when States_Restrict::C_States_Restrict_To_Item_Word
  440.       if @active_battler.is_a?(Game_Actor)
  441.         if @target_battlers[0].is_a?(Game_Enemy)
  442.           # 清除强制行动对像的战斗者
  443.           $game_temp.forcing_battler = nil
  444.           # 移至步骤 1
  445.           @phase4_step = 1
  446.           return
  447.         end
  448.       elsif @active_battler.is_a?(Game_Enemy)
  449.         if @target_battlers[0].is_a?(Game_Actor)
  450.           # 清除强制行动对像的战斗者
  451.           $game_temp.forcing_battler = nil
  452.           # 移至步骤 1
  453.           @phase4_step = 1
  454.           return
  455.         end
  456.       end
  457.     end
  458.     # 消耗品的情况下
  459.     if @item.consumable
  460.       # 使用的物品减 1
  461.       $game_party.lose_item(@item.id, 1)
  462.     end
  463.     # 在帮助窗口显示物品名
  464.     @help_window.set_text(@item.name, 1)
  465.     # 设置动画 ID
  466.     @animation1_id = @item.animation1_id
  467.     @animation2_id = @item.animation2_id
  468.     # 设置公共事件 ID
  469.     @common_event_id = @item.common_event_id
  470.     # 应用物品效果
  471.     for target in @target_battlers
  472.       target.item_effect(@item)
  473.     end
  474.   end
  475. end
  476. #------------------------------------------------------------------------------
复制代码
梦石
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.

在本版发帖返回顶部