设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2696|回复: 2
打印 上一主题 下一主题

[原创发布] 状态限制

[复制链接]

Lv1.梦旅人

薄凉看客

梦石
0
星屑
50
在线时间
1269 小时
注册时间
2010-6-20
帖子
1316
跳转到指定楼层
1
发表于 2014-11-2 20:04:30 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
没什么可说的。。。


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


脚本
RUBY 代码复制
  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.  
  17. module States_Restrict
  18.   # - 优先级(按照从低到高的顺序排列)
  19.   Priority = []
  20.   # * 攻击
  21.   Priority[0] = ["B", "A", "C"]
  22.   # * 特技
  23.   Priority[1] = ["C", "B", "A"]
  24.   # * 物品
  25.   Priority[2] = ["C", "B", "A"]
  26.  
  27.   # - 设置
  28.   A_States_Restrict_To_Attack = [16]  # 不可攻击
  29.   B_States_Restrict_To_Attack = []    # 只能普通攻击敌人
  30.   C_States_Restrict_To_Attack = [15]  # 只能普通攻击同伴
  31.  
  32.   A_States_Restrict_To_Skill = []     # 不可(使用)技能
  33.   B_States_Restrict_To_Skill = [14]   # 只可对敌人(只能使用攻击类技能)
  34.   C_States_Restrict_To_Skill = []     # 只可对同伴(只能使用辅助类技能)
  35.  
  36.   A_States_Restrict_To_Item = [13]    # 不可(使用)物品
  37.   B_States_Restrict_To_Item = []      # 只可对敌人(只能使用暗器类物品)
  38.   C_States_Restrict_To_Item = []      # 只可对同伴(只能使用辅助类物品)
  39.  
  40.   States_Restrict_To_Guard = [16]     # 不可防御
  41.  
  42.   # - 用语(不用管)
  43.   A_States_Restrict_To_Attack_Word = "不可攻击"
  44.   B_States_Restrict_To_Attack_Word = "只能普通攻击敌人"
  45.   C_States_Restrict_To_Attack_Word = "只能普通攻击同伴"
  46.  
  47.   A_States_Restrict_To_Skill_Word = "不可(使用)技能"
  48.   B_States_Restrict_To_Skill_Word = "只可对敌人"
  49.   C_States_Restrict_To_Skill_Word = "只可对同伴"
  50.  
  51.   A_States_Restrict_To_Item_Word = "不可(使用)物品"
  52.   B_States_Restrict_To_Item_Word = "只可对敌人"
  53.   C_States_Restrict_To_Item_Word = "只可对同伴"
  54.  
  55.   States_Restrict_To_Guard_Word = "不可防御"
  56.  
  57. end
  58.  
  59. class Game_Battler
  60.   def restriction_zhouzhou
  61.  
  62.     command = []
  63.     # - 攻击指令
  64.     for index in States_Restrict::Priority[0]
  65.       if index == "B"
  66.         if (@states & States_Restrict::B_States_Restrict_To_Attack).size > 0
  67.           command[0] = States_Restrict::B_States_Restrict_To_Attack_Word
  68.         end
  69.       elsif index == "A"
  70.         if (@states & States_Restrict::A_States_Restrict_To_Attack).size > 0
  71.           command[0] = States_Restrict::A_States_Restrict_To_Attack_Word
  72.         end
  73.       elsif index == "C"
  74.         if (@states & States_Restrict::C_States_Restrict_To_Attack).size > 0
  75.           command[0] = States_Restrict::C_States_Restrict_To_Attack_Word
  76.         end
  77.       end
  78.     end
  79.  
  80.     # - 特技指令
  81.     for index in States_Restrict::Priority[1]
  82.       if index == "C"
  83.         if (@states & States_Restrict::C_States_Restrict_To_Skill).size > 0
  84.           command[1] = States_Restrict::C_States_Restrict_To_Skill_Word
  85.         end
  86.       elsif index == "B"
  87.         if (@states & States_Restrict::B_States_Restrict_To_Skill).size > 0
  88.           command[1] = States_Restrict::B_States_Restrict_To_Skill_Word
  89.         end
  90.       elsif index == "A"
  91.         if (@states & States_Restrict::A_States_Restrict_To_Skill).size > 0
  92.           command[1] = States_Restrict::A_States_Restrict_To_Skill_Word
  93.         end
  94.       end
  95.     end
  96.  
  97.     # - 物品指令
  98.     for index in States_Restrict::Priority[2]
  99.       if index == "C"
  100.         if (@states & States_Restrict::C_States_Restrict_To_Item).size > 0
  101.           command[2] = States_Restrict::C_States_Restrict_To_Item_Word
  102.         end
  103.       elsif index == "B"
  104.         if (@states & States_Restrict::B_States_Restrict_To_Item).size > 0
  105.           command[2] = States_Restrict::B_States_Restrict_To_Item_Word
  106.         end
  107.       elsif index == "A"
  108.         if (@states & States_Restrict::A_States_Restrict_To_Item).size > 0
  109.           command[2] = States_Restrict::A_States_Restrict_To_Item_Word
  110.         end
  111.       end
  112.     end
  113.  
  114.     # - 防御指令
  115.     if (@states & States_Restrict::States_Restrict_To_Guard).size > 0
  116.       command[3] = States_Restrict::States_Restrict_To_Guard_Word
  117.     end
  118.  
  119.     return command
  120.  
  121.   end
  122. end
  123.  
  124. # - 参战人数
  125. class Game_Party
  126.   def exist_size
  127.     actor_size = 0
  128.     for i in $game_party.actors
  129.       actor_size += 1 if i.exist?
  130.     end
  131.     return actor_size
  132.   end
  133. end
  134. class Game_Troop
  135.   def exist_size
  136.     actor_size = 0
  137.     for i in $game_troop.enemies
  138.       actor_size += 1 if i.exist?
  139.     end
  140.     return actor_size
  141.   end
  142. end
  143.  
  144. class Scene_Battle
  145.   # - 检查限制
  146.   def check_to_restrict
  147.     re = @active_battler.restriction_zhouzhou
  148.     # - 攻击
  149.     if re[0] != nil
  150.       # - 限制
  151.       if (@active_battler.current_action.kind != 0 or
  152.         @active_battler.current_action.basic != 0) and
  153.         re[0] != States_Restrict::A_States_Restrict_To_Attack_Word
  154.         @active_battler.current_action.kind = 0
  155.         @active_battler.current_action.basic = 0
  156.       # - 无效指令
  157.       elsif @active_battler.current_action.kind == 0 and
  158.         @active_battler.current_action.basic == 0 and
  159.         re[0] == States_Restrict::A_States_Restrict_To_Attack_Word
  160.         # 清除行动强制对像的战斗者
  161.         $game_temp.forcing_battler = nil
  162.         # 移至步骤 1
  163.         @phase4_step = 1
  164.         return
  165.       end
  166.     end
  167.     # - 特技
  168.     if re[1] != nil
  169.       if @active_battler.current_action.kind == 1 and
  170.         re[1] == States_Restrict::A_States_Restrict_To_Skill_Word
  171.         # 清除行动强制对像的战斗者
  172.         $game_temp.forcing_battler = nil
  173.         # 移至步骤 1
  174.         @phase4_step = 1
  175.         return
  176.       end
  177.     end
  178.     # - 物品
  179.     if re[2] != nil
  180.       if @active_battler.current_action.kind == 2 and
  181.         re[2] == States_Restrict::A_States_Restrict_To_Item_Word
  182.         # 清除行动强制对像的战斗者
  183.         $game_temp.forcing_battler = nil
  184.         # 移至步骤 1
  185.         @phase4_step = 1
  186.         return
  187.       end
  188.     end
  189.     # - 防御
  190.     if re[3] != nil
  191.       if @active_battler.current_action.kind == 0 and
  192.         @active_battler.current_action.basic == 1
  193.         # 清除行动强制对像的战斗者
  194.         $game_temp.forcing_battler = nil
  195.         # 移至步骤 1
  196.         @phase4_step = 1
  197.         return
  198.       end
  199.     end
  200.   end
  201.   #--------------------------------------------------------------------------
  202.   # ● 刷新画面 (主回合步骤 2 : 开始行动)
  203.   #--------------------------------------------------------------------------
  204.   def update_phase4_step2
  205.     # 如果不是强制行动
  206.     unless @active_battler.current_action.forcing
  207.       check_to_restrict
  208.     end
  209.     # 清除对像战斗者
  210.     @target_battlers = []
  211.     # 行动种类分支
  212.     case @active_battler.current_action.kind
  213.     when 0  # 基本
  214.       make_basic_action_result
  215.     when 1  # 特技
  216.       make_skill_action_result
  217.     when 2  # 物品
  218.       make_item_action_result
  219.     end
  220.     # 移至步骤 3
  221.     if @phase4_step == 2
  222.       @phase4_step = 3
  223.     end
  224.   end
  225.   #--------------------------------------------------------------------------
  226.   # ● 生成基本行动结果
  227.   #--------------------------------------------------------------------------
  228.   def make_basic_action_result
  229.     # 攻击的情况下
  230.     if @active_battler.current_action.basic == 0
  231.       re = @active_battler.restriction_zhouzhou[0]
  232.       # 设置攻击 ID
  233.       @animation1_id = @active_battler.animation1_id
  234.       @animation2_id = @active_battler.animation2_id
  235.       # 行动方的战斗者是敌人的情况下
  236.       if @active_battler.is_a?(Game_Enemy)
  237.         # - 普通攻击同伴
  238.         if re == States_Restrict::C_States_Restrict_To_Attack_Word
  239.           if $game_troop.exist_size > 1
  240.             target = $game_troop.random_target_enemy
  241.             while target == @active_battler
  242.               target = $game_troop.random_target_enemy
  243.             end
  244.           else
  245.             # 清除强制行动对像的战斗者
  246.             $game_temp.forcing_battler = nil
  247.             # 移至步骤 1
  248.             @phase4_step = 1
  249.             return
  250.           end
  251.         # - 普通攻击敌人
  252.         elsif re == States_Restrict::B_States_Restrict_To_Attack_Word
  253.           target = $game_party.random_target_actor
  254.         # - 无限制
  255.         elsif re == nil
  256.           index = @active_battler.current_action.target_index
  257.           target = $game_party.smooth_target_actor(index)
  258.         else
  259.           return
  260.         end
  261.       end
  262.       # 行动方的战斗者是角色的情况下
  263.       if @active_battler.is_a?(Game_Actor)
  264.         # - 普通攻击同伴
  265.         if re == States_Restrict::C_States_Restrict_To_Attack_Word
  266.           if $game_party.exist_size > 1
  267.             target = $game_party.random_target_actor
  268.             while target == @active_battler
  269.               target = $game_party.random_target_actor
  270.             end
  271.           else
  272.             # 清除强制行动对像的战斗者
  273.             $game_temp.forcing_battler = nil
  274.             # 移至步骤 1
  275.             @phase4_step = 1
  276.             return
  277.           end
  278.         # - 普通攻击敌人
  279.         elsif re == States_Restrict::B_States_Restrict_To_Attack_Word
  280.           target = $game_troop.random_target_enemy
  281.         # - 无限制
  282.         elsif re == nil
  283.           index = @active_battler.current_action.target_index
  284.           target = $game_troop.smooth_target_enemy(index)
  285.         else
  286.           return
  287.         end
  288.       end
  289.       # 设置对像方的战斗者序列
  290.       @target_battlers = [target]
  291.       # 应用通常攻击效果
  292.       for target in @target_battlers
  293.         target.attack_effect(@active_battler)
  294.       end
  295.       return
  296.     end
  297.     # 防御的情况下
  298.     if @active_battler.current_action.basic == 1
  299.       # 帮助窗口显示"防御"
  300.       @help_window.set_text($data_system.words.guard, 1)
  301.       return
  302.     end
  303.     # 逃跑的情况下
  304.     if @active_battler.is_a?(Game_Enemy) and
  305.        @active_battler.current_action.basic == 2
  306.       #  帮助窗口显示"逃跑"
  307.       @help_window.set_text("逃跑", 1)
  308.       # 逃跑
  309.       @active_battler.escape
  310.       return
  311.     end
  312.     # 什么也不做的情况下
  313.     if @active_battler.current_action.basic == 3
  314.       # 清除强制行动对像的战斗者
  315.       $game_temp.forcing_battler = nil
  316.       # 移至步骤 1
  317.       @phase4_step = 1
  318.       return
  319.     end
  320.   end
  321.   #--------------------------------------------------------------------------
  322.   # ● 生成特技行动结果
  323.   #--------------------------------------------------------------------------
  324.   def make_skill_action_result
  325.     re = @active_battler.restriction_zhouzhou[1]
  326.     # 获取特技
  327.     [url=home.php?mod=space&uid=260100]@skill[/url] = $data_skills[@active_battler.current_action.skill_id]
  328.     # 如果不是强制行动
  329.     unless @active_battler.current_action.forcing
  330.       # 因为 SP 耗尽而无法使用的情况下
  331.       unless @active_battler.skill_can_use?(@skill.id)
  332.         # 清除强制行动对像的战斗者
  333.         $game_temp.forcing_battler = nil
  334.         # 移至步骤 1
  335.         @phase4_step = 1
  336.         return
  337.       end
  338.     end
  339.     # 设置对像侧战斗者
  340.     set_target_battlers(@skill.scope)
  341.     # - 限制特技
  342.     case re
  343.     when States_Restrict::A_States_Restrict_To_Skill_Word
  344.       # 清除强制行动对像的战斗者
  345.       $game_temp.forcing_battler = nil
  346.       # 移至步骤 1
  347.       @phase4_step = 1
  348.       return
  349.     when States_Restrict::B_States_Restrict_To_Skill_Word
  350.       if @active_battler.is_a?(Game_Actor)
  351.         if @target_battlers[0].is_a?(Game_Actor)
  352.           # 清除强制行动对像的战斗者
  353.           $game_temp.forcing_battler = nil
  354.           # 移至步骤 1
  355.           @phase4_step = 1
  356.           return
  357.         end
  358.       elsif @active_battler.is_a?(Game_Enemy)
  359.         if @target_battlers[0].is_a?(Game_Enemy)
  360.           # 清除强制行动对像的战斗者
  361.           $game_temp.forcing_battler = nil
  362.           # 移至步骤 1
  363.           @phase4_step = 1
  364.           return
  365.         end
  366.       end
  367.     when States_Restrict::C_States_Restrict_To_Skill_Word
  368.       if @active_battler.is_a?(Game_Actor)
  369.         if @target_battlers[0].is_a?(Game_Enemy)
  370.           # 清除强制行动对像的战斗者
  371.           $game_temp.forcing_battler = nil
  372.           # 移至步骤 1
  373.           @phase4_step = 1
  374.           return
  375.         end
  376.       elsif @active_battler.is_a?(Game_Enemy)
  377.         if @target_battlers[0].is_a?(Game_Actor)
  378.           # 清除强制行动对像的战斗者
  379.           $game_temp.forcing_battler = nil
  380.           # 移至步骤 1
  381.           @phase4_step = 1
  382.           return
  383.         end
  384.       end
  385.     end
  386.     # 消耗 SP
  387.     @active_battler.sp -= @skill.sp_cost
  388.     # 刷新状态窗口
  389.     @status_window.refresh
  390.     # 在帮助窗口显示特技名
  391.     @help_window.set_text(@skill.name, 1)
  392.     # 设置动画 ID
  393.     @animation1_id = @skill.animation1_id
  394.     @animation2_id = @skill.animation2_id
  395.     # 设置公共事件 ID
  396.     @common_event_id = @skill.common_event_id
  397.     # 应用特技效果
  398.     for target in @target_battlers
  399.       target.skill_effect(@active_battler, @skill)
  400.     end
  401.   end
  402.   #--------------------------------------------------------------------------
  403.   # ● 生成物品行动结果
  404.   #--------------------------------------------------------------------------
  405.   def make_item_action_result
  406.     re = @active_battler.restriction_zhouzhou[2]
  407.     # 获取物品
  408.     @item = $data_items[@active_battler.current_action.item_id]
  409.     # 因为物品耗尽而无法使用的情况下
  410.     unless $game_party.item_can_use?(@item.id)
  411.       # 移至步骤 1
  412.       @phase4_step = 1
  413.       return
  414.     end
  415.     # 设置对像侧战斗者
  416.     set_target_battlers(@item.scope)
  417.     # - 限制物品
  418.     case re
  419.     when States_Restrict::A_States_Restrict_To_Item_Word
  420.       # 清除强制行动对像的战斗者
  421.       $game_temp.forcing_battler = nil
  422.       # 移至步骤 1
  423.       @phase4_step = 1
  424.       return
  425.     when States_Restrict::B_States_Restrict_To_Item_Word
  426.       if @active_battler.is_a?(Game_Actor)
  427.         if @target_battlers[0].is_a?(Game_Actor)
  428.           # 清除强制行动对像的战斗者
  429.           $game_temp.forcing_battler = nil
  430.           # 移至步骤 1
  431.           @phase4_step = 1
  432.           return
  433.         end
  434.       elsif @active_battler.is_a?(Game_Enemy)
  435.         if @target_battlers[0].is_a?(Game_Enemy)
  436.           # 清除强制行动对像的战斗者
  437.           $game_temp.forcing_battler = nil
  438.           # 移至步骤 1
  439.           @phase4_step = 1
  440.           return
  441.         end
  442.       end
  443.     when States_Restrict::C_States_Restrict_To_Item_Word
  444.       if @active_battler.is_a?(Game_Actor)
  445.         if @target_battlers[0].is_a?(Game_Enemy)
  446.           # 清除强制行动对像的战斗者
  447.           $game_temp.forcing_battler = nil
  448.           # 移至步骤 1
  449.           @phase4_step = 1
  450.           return
  451.         end
  452.       elsif @active_battler.is_a?(Game_Enemy)
  453.         if @target_battlers[0].is_a?(Game_Actor)
  454.           # 清除强制行动对像的战斗者
  455.           $game_temp.forcing_battler = nil
  456.           # 移至步骤 1
  457.           @phase4_step = 1
  458.           return
  459.         end
  460.       end
  461.     end
  462.     # 消耗品的情况下
  463.     if @item.consumable
  464.       # 使用的物品减 1
  465.       $game_party.lose_item(@item.id, 1)
  466.     end
  467.     # 在帮助窗口显示物品名
  468.     @help_window.set_text(@item.name, 1)
  469.     # 设置动画 ID
  470.     @animation1_id = @item.animation1_id
  471.     @animation2_id = @item.animation2_id
  472.     # 设置公共事件 ID
  473.     @common_event_id = @item.common_event_id
  474.     # 应用物品效果
  475.     for target in @target_battlers
  476.       target.item_effect(@item)
  477.     end
  478.   end
  479. end
  480. #------------------------------------------------------------------------------

Lv1.梦旅人

梦石
0
星屑
211
在线时间
905 小时
注册时间
2010-9-6
帖子
3229
2
发表于 2014-11-5 09:51:36 手机端发表。 | 只看该作者
好像很久以前就已经有状态限制技能的脚本了,而且比写个简便的说…
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
9275
在线时间
2504 小时
注册时间
2011-5-20
帖子
15389

开拓者

3
发表于 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
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-30 13:57

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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