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

Project1

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

[已经解决] 反击脚本如何去掉“习得特技”的判定

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1438
在线时间
328 小时
注册时间
2016-4-4
帖子
168

开拓者

跳转到指定楼层
1
发表于 2016-12-24 22:01:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
RUBY 代码复制
  1. #==========================================================================
  2. # 本脚本来自[url]www.66RPG.com[/url],由ikki转载。使用请保留此信息
  3. #=========================================================================
  4.  
  5. # ▼▲▼ XRXS27. 特殊効果 SuperEX「反击」 ver.1.05 ▼▲▼
  6. # by シムナフ, ピニョン
  7.  
  8. #========================================================================
  9. # □ 自定义设定
  10. #========================================================================
  11. class Game_Battler
  12.   # 反击的状态名
  13.   STATE_COUNTER_NAME = '熔岩护甲'
  14. end
  15. #========================================================================
  16. # ◇ 说明文档
  17. #=======================================================================
  18. #****Warning! 重新定义了 Game_Actor#skill_can_use? ****
  19.  
  20. #使用方法
  21. #对于身中“反击”状态的角色,当收到单独的攻击的时候会自动反击
  22. #反击的模式可以在下面设定
  23.  
  24. #-cr (counter react)下面设定可以反击的挨打设定:
  25.  
  26. # 比如设定一个状态名为“反击 -crm”,则受到魔法攻击的时候会自动反击
  27. #-cra50(attack)   =>遭到物理攻击(普攻)的时候50%概率反击。
  28. #-crp  (physical) =>遭到物理伤害(物攻+物理技能)的时候反击。
  29. #-crm  (magic)    =>遭到法术伤害(法术技能)的时候反击。
  30. #-crs  (skill)    =>遭到技能伤害(物理技能+法术技能)的时候反击。
  31. #-cre7 (element)  =>遭到属性ID为7的攻击的时候反击。
  32.  
  33. #-ca (counter act)下面设定反击行为:
  34.  
  35. #比如设置一个状态名叫做“反击 -cas19”,那么受到攻击的时候就会用19号特技反击。
  36. #-caa  (attack)   =>使用物理攻击反击。
  37. #-cas1 (skill)    =>使用ID为1的技能反击。
  38. #-cac  (copy)     =>复制敌人攻击方式(普攻+技能)进行反击。
  39. #-cai1 (item)     =>使用ID为1的物品。
  40. #-cae  (escape)   =>逃跑,敌人使用。
  41.  
  42. #注意和即时战斗的共同使用问题……
  43.  
  44. #举例:设置一个状态,使得遭遇物理攻击的时候使用物品4,“反击 -crp -cai4”
  45.  
  46. #========================================================================
  47. # ■ Game_Battler (分割定义 1)
  48. #========================================================================
  49.  
  50. class Game_Battler
  51.   #-----------------------------------------------------------------------
  52.   # ● 状态初始化
  53.   #-----------------------------------------------------------------------
  54.   def states=(states)
  55.     @states = states
  56.   end  
  57.   #-----------------------------------------------------------------------
  58.   # ● 对象初始化
  59.   #-----------------------------------------------------------------------
  60.   alias original_initialize_before_counter_action initialize
  61.   def initialize
  62.     original_initialize_before_counter_action()
  63.     @counter_action = Game_BattleAction.new
  64.   end  
  65.   #-----------------------------------------------------------------------
  66.   # ● 获取当前的动作
  67.   #-----------------------------------------------------------------------
  68.   alias original_current_action_before_counter_action current_action
  69.   def current_action
  70.     if @counter_action.cleared?
  71.       return original_current_action_before_counter_action()
  72.     else
  73.       return @counter_action
  74.     end
  75.   end
  76.   #-----------------------------------------------------------------------
  77.   # ● 获取当前的动作
  78.   #-----------------------------------------------------------------------
  79.   def counter_action
  80.     return @counter_action
  81.   end
  82.   #-----------------------------------------------------------------------
  83.   # ● 是否待机
  84.   #-----------------------------------------------------------------------
  85.   def counter_acting?
  86.     if !@counter_action.cleared?
  87.       return true
  88.     else
  89.       return false
  90.     end
  91.   end
  92.   #-----------------------------------------------------------------------
  93.   # ● 战斗不能判定
  94.   #-----------------------------------------------------------------------
  95.   #alias original_dead_before_counter_action dead?
  96.   #def dead?
  97.   #  if self.counter_acting?
  98.   #    return false
  99.   #  else
  100.   #    return original_dead_before_counter_action()
  101.   #  end
  102.   #end  
  103.   #----------------------------------------------------------------------
  104.   # ●
  105.   #----------------------------------------------------------------------
  106.   def counter_action_for(attacker, skill = nil)
  107.     # 行动存在时
  108.     if attacker.counter_acting?
  109.       return
  110.     end
  111.     # 无法行动和不存在的情况
  112.     #if !self.movable? || !self.exist?
  113.     #  return
  114.     #end
  115.     if attacker.is_a?(Game_Actor)
  116.       if self.is_a?(Game_Actor) # 攻击目标是伙伴的情况下
  117.         return
  118.       end
  119.       ind = $game_party.get_index_by(attacker)
  120.       s_ind = $game_troop.get_index_by(self)
  121.     elsif attacker.is_a?(Game_Enemy)
  122.       if self.is_a?(Game_Enemy) # 攻击目标是伙伴的情况下
  123.         return
  124.       end
  125.       ind = $game_troop.get_index_by(attacker)
  126.       s_ind = $game_party.get_index_by(self)
  127.     end
  128.     if ind.nil? || s_ind.nil?
  129.       return
  130.     end
  131.     # 初始化反击类型为普攻
  132.     act_kind = 'a'
  133.     act_id = 0
  134.     # 检测状态
  135.     for id in @states
  136.       # 如果状态名包含“反击”
  137.       if $data_states[id].name =~ /^#{STATE_COUNTER_NAME}/
  138.         # 初始化反击行动
  139.         react_cond = false
  140.         react_succ = false
  141.         # 检测
  142.         for opt in $data_states[id].options
  143.           # 检测伤害类型
  144.           if opt =~ /^cr([apmsend])([0-9]*)/
  145.             kind = $1
  146.             id = $2.to_i
  147.             react_cond = true
  148.             # 判断伤害类型
  149.             case kind
  150.             when 'a' # 物理攻击(普攻)
  151.               if skill.nil? && (rand(100) < id)
  152.                 react_succ = true
  153.               end              
  154.             when 'p' # 物理伤害(物理技能 + 普攻)
  155.               if skill.nil? || skill.atk_f != 0
  156.                 react_succ = true
  157.               end
  158.             when 'm' # 法术伤害(法术技能)
  159.               if !skill.nil? && skill.power > 0
  160.                 react_succ = true
  161.               end
  162.             when 's' # 技能伤害(法术技能+物理技能)
  163.               if !skill.nil? && (skill.power > 0 || skill.atk_f != 0)
  164.                 react_succ = true
  165.               end              
  166.             when 'e' # 属性攻击
  167.               if id.nil? || id.zero?
  168.                 next
  169.               elsif skill.nil? # 武器攻击属性
  170.                 if attacker.is_a?(Game_Actor) && !$data_weapons[@weapon_id].nil?
  171.                   if $data_weapons[@weapon_id].element_set.include?(id)
  172.                     react_succ = true
  173.                   end
  174.                 end
  175.               elsif skill.element_set.include?(id)# 敌人攻击属性
  176.                 react_succ = true
  177.               end
  178.             when 'n' # 令目标攻击无效
  179.               no_attack = true
  180.             #when 'ss' # 目标闪避攻击时反击
  181.             #  miss_attack = true
  182.             when 'd' # 目标死亡时反击
  183.               if self.dead? && self.movable?
  184.                 react_succ = true
  185.               end
  186.             end
  187.           # 检测反击类型
  188.           elsif opt =~ /^ca([ascie])([0-9]*)/
  189.             act_kind = $1
  190.             act_id = $2.to_i
  191.             #react_cond = true
  192.           end
  193.         end
  194.         # 反击条件成立的情况下
  195.         if (!react_cond || react_succ)
  196.           counter = true
  197.           break
  198.         else
  199.           next
  200.         end
  201.       end
  202.     end
  203.     # 不反击的情况下直接返回
  204.     if !counter
  205.       return
  206.     end
  207.     # 目标攻击无效的话恢复损失气血
  208.     if no_attack == true
  209.       if self.damage != "Miss"
  210.         self.hp += self.damage
  211.         self.damage = "Miss"
  212.         self.critical = false
  213.         @state_changed = false
  214.         self.states = @old_states
  215.       end
  216.     end
  217.     # 目标没有闪避伤害时直接返回
  218.     #if miss_attack == true and self.damage != "Miss"
  219.     #  return
  220.     #end
  221.     # 如果是复制攻击方行动效果
  222.     if act_kind == 'c'
  223.       if skill.nil?
  224.         act_kind = 'a'
  225.       else
  226.         act_kind = 's'
  227.         act_id = skill.id
  228.       end
  229.     end
  230.     # 判断反击类型
  231.     case act_kind
  232.     when 'a' # 攻击 kind:0 basic:0
  233.       self.counter_action.kind = 0
  234.       self.counter_action.target_index = ind
  235.       self.counter_action.basic = 0
  236.     when 's' # 技能 kind:1 basic:0
  237.       s = $data_skills[act_id]
  238.       # 判断技能是否不存在,是否战斗可用,是否角色可用
  239.       if s.nil? || ![0,1].include?(s.occasion) || !self.skill_can_use?(act_id)
  240.         return
  241.       end
  242.       self.counter_action.skill_id = act_id
  243.       self.counter_action.kind = 1
  244.       # 1敌单体,2敌全体
  245.       if [1,2].include?(s.scope)
  246.         self.counter_action.target_index = ind
  247.       else
  248.         self.counter_action.target_index = s_ind
  249.       end
  250.     when 'i' # 物品 kind:2 basic:0
  251.       i = $data_items[act_id]
  252.       # 判断是否是角色,物品是否不存在,是否战斗可用,是否角色可用
  253.       if !self.is_a?(Game_Actor) || i.nil? || ![0,1].include?(i.occasion) || !$game_party.item_can_use?(act_id)
  254.         return
  255.       end
  256.       self.counter_action.item_id = act_id
  257.       self.counter_action.kind = 2
  258.       # 1敌单体,2敌全体
  259.       if [1,2].include?(i.scope)
  260.         self.counter_action.target_index = ind
  261.       else
  262.         self.counter_action.target_index = s_ind
  263.       end
  264.     when 'e' # 逃跑 kind:0 basic:2
  265.       # 判断是否是敌人
  266.       if !self.is_a?(Game_Enemy)
  267.         return
  268.       end
  269.       self.counter_action.kind = 0
  270.       self.counter_action.target_index = ind
  271.       self.counter_action.basic = 2      
  272.     end
  273.     return   
  274.   end  
  275.   #----------------------------------------------------------------------
  276.   # ● 普通攻击效果
  277.   #     attacker : 攻击者
  278.   #----------------------------------------------------------------------
  279.   alias original_attack_effect_before_counter_action attack_effect
  280.   def attack_effect(attacker)
  281.     @old_states = self.states.clone
  282.     val = original_attack_effect_before_counter_action(attacker)
  283.     # 检测反击
  284.     self.counter_action_for(attacker)
  285.     return val
  286.   end   
  287.   #----------------------------------------------------------------------
  288.   # ● 技能攻击效果
  289.   #     user  : 技能使用者
  290.   #     skill : 技能ID
  291.   #----------------------------------------------------------------------
  292.   alias original_skill_effect_before_counter_action skill_effect
  293.   def skill_effect(attacker, skill)
  294.     @old_states = self.states.clone
  295.     val = original_skill_effect_before_counter_action(attacker, skill)
  296.     # 检测反击
  297.     self.counter_action_for(attacker, skill)
  298.     return val
  299.   end  
  300. end
  301.  
  302. #===============================================================================
  303. # ■ Game_Actor
  304. #-------------------------------------------------------------------------------
  305. =begin
  306. class Game_Actor < Game_Battler
  307.   #----------------------------------------------------------------------
  308.   # ● 技能使用判定
  309.   #     skill_id : 技能 ID
  310.   #----------------------------------------------------------------------
  311.   def skill_can_use?(skill_id)
  312.     if not skill_learn?(skill_id)
  313.       return
  314.     end
  315.     return super
  316.   end
  317. end
  318. =end
  319.  
  320. #===============================================================================
  321. # ■ Game_BattleAction
  322. #-------------------------------------------------------------------------------
  323.  
  324. class Game_BattleAction
  325.   #-----------------------------------------------------------------------
  326.   # ● 初始化
  327.   #-----------------------------------------------------------------------  
  328.   alias :xp_original_initialize :initialize
  329.   def initialize
  330.     xp_original_initialize()
  331.     @turn_move_times = 0
  332.   end
  333.   #-----------------------------------------------------------------------
  334.   # ● 清除判定
  335.   #-----------------------------------------------------------------------
  336.   def cleared?
  337.     if @speed == 0 && @kind == 0 && @basic == 3 && @skill_id == 0 && @item_id == 0 && @target_index == -1 && @forcing == false
  338.       return true
  339.     else
  340.       return false
  341.     end
  342.   end  
  343. end
  344.  
  345. #===============================================================================
  346. # ■ Game_Party
  347. #-------------------------------------------------------------------------------
  348.  
  349. class Game_Party
  350.   #----------------------------------------------------------------------
  351.   # ● 获得角色目标
  352.   #----------------------------------------------------------------------
  353.   def get_index_by(actor)
  354.     for i in [email]0...@actors.size[/email]()
  355.       if @actors[i].equal?(actor)
  356.         return i
  357.       end
  358.     end
  359.     return nil
  360.   end
  361. end
  362.  
  363. #==========================================================================
  364. # ■ Game_Troop
  365. #--------------------------------------------------------------------------
  366.  
  367. class Game_Troop
  368.   #----------------------------------------------------------------------
  369.   # ● 获得敌人目标
  370.   #----------------------------------------------------------------------
  371.   def get_index_by(enemy)
  372.     for i in [email]0...@enemies.size[/email]()
  373.       if @enemies[i].equal?(enemy)
  374.         return i
  375.       end
  376.     end
  377.     return nil
  378.   end
  379. end
  380.  
  381. #==========================================================================
  382. # ■ Scene_Battle (分割定义 4)
  383. #--------------------------------------------------------------------------
  384.  
  385. class Scene_Battle  
  386.   #----------------------------------------------------------------------
  387.   # ● 刷新画面 (主回合步骤 6 : 刷新)
  388.   #----------------------------------------------------------------------
  389.   alias original_update_phase4_step6_before_counter_action update_phase4_step6
  390.   def update_phase4_step6
  391.     original_update_phase4_step6_before_counter_action()
  392.     clear_counter_action(@active_battler)
  393.     activate_counter_action(@action_battlers)
  394.   end
  395.   #----------------------------------------------------------------------
  396.   # ● 清除行动
  397.   #----------------------------------------------------------------------
  398.   def clear_counter_action(active_battler)
  399.     #既にカウンターを行ったバトラーのカウンターアクションをクリア
  400.     if active_battler.nil?
  401.       return
  402.     end
  403.     if !active_battler.counter_acting?
  404.       return
  405.     end
  406.     active_battler.counter_action.clear
  407.     return
  408.   end
  409.   #----------------------------------------------------------------------
  410.   # ● 行动
  411.   #----------------------------------------------------------------------
  412.   def activate_counter_action(action_battlers)   
  413.     #カウンター状態になったバトラーを一回だけアクションバトラーズにアンシフト
  414.     if !action_battlers[0].nil?
  415.       if action_battlers[0].counter_acting?#既にカウンター行動待機バトラーが居た場合
  416.         return
  417.       end
  418.     end
  419.     counter_battlers = []
  420.     $game_party.actors.each{|a|
  421.       if a.counter_acting?
  422.         counter_battlers.push(a)
  423.       end
  424.     }
  425.     $game_troop.enemies.each{|e|
  426.       if e.counter_acting?
  427.         counter_battlers.push(e)
  428.       end
  429.     }
  430.     counter_battlers = counter_battlers.sort_by{|b| b.agi}
  431.     counter_battlers.each{ |b|
  432.       action_battlers.unshift(b)
  433.     }
  434.     #p action_battlers.collect{|b| b.name}
  435.     return
  436.   end
  437. end
  438.  
  439. #===============================================================================
  440. # ■ CP战斗对应。回合战斗不必要。
  441. #-------------------------------------------------------------------------------
  442.  
  443. class Game_Battler
  444.   if method_defined?(:cp)
  445.     alias original_cp_before_counter_action cp
  446.     def cp
  447.       if self.counter_acting?
  448.         return 65535
  449.       else
  450.         return original_cp_before_counter_action()
  451.       end
  452.     end
  453.   end
  454.   if method_defined?(:cp=)
  455.     alias original_cp_before_counter_action= cp=
  456.     def cp=(n)
  457.       if self.counter_acting?
  458.         return
  459.       else
  460.         self.original_cp_before_counter_action = n
  461.       end
  462.     end
  463.   end
  464. end
  465.  
  466. #===============================================================================
  467. # ■ 状态重定义
  468. #-------------------------------------------------------------------------------
  469.  
  470. module RPG
  471.   class State
  472.     #---------------------------------------------------------
  473.     # ● 定义状态名称
  474.     #---------------------------------------------------------
  475.     def name
  476.       if @new_name.nil?
  477.         name_setting()
  478.       end
  479.       return @new_name
  480.     end
  481.     #---------------------------------------------------------
  482.     # ● 定义状态伤害与反击类型
  483.     #---------------------------------------------------------   
  484.     def options
  485.       if @options.nil?
  486.         name_setting()
  487.       end
  488.       return @options
  489.     end
  490.     #---------------------------------------------------------
  491.     # ● 获取状态名称、伤害与反击类型
  492.     #---------------------------------------------------------
  493.     def name_setting
  494.       names = @name.split(/ +-/)
  495.       # 获取名称
  496.       @new_name = names.shift
  497.       if @new_name.nil?
  498.         @new_name = ''
  499.       end
  500.       # 获取伤害与反击类型
  501.       @options = names
  502.       if @options.nil?
  503.         @options = []
  504.       end
  505.     end   
  506.   end
  507. end

这个反击脚本中 如果用技能反击的话 需要已经习得那个特技 那么问题来了  如何去掉这个设定  让角色即使没有习得那个技能 也能用那个技能反击?

Lv5.捕梦者

梦石
0
星屑
33508
在线时间
10557 小时
注册时间
2009-3-15
帖子
4771
2
发表于 2016-12-25 10:59:42 | 只看该作者
239行
RUBY 代码复制
  1. # 判断技能是否不存在,是否战斗可用,是否角色可用
  2.  
  3. if s.nil? || ![0,1].include?(s.occasion) || !self.skill_can_use?(act_id)

去掉|| !self.skill_can_use?(act_id)应该就可以了吧..

我也是脚本盲..
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1438
在线时间
328 小时
注册时间
2016-4-4
帖子
168

开拓者

3
 楼主| 发表于 2016-12-25 13:48:14 | 只看该作者
soulsaga 发表于 2016-12-25 10:59
239行
# 判断技能是否不存在,是否战斗可用,是否角色可用

试过了 不行
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1438
在线时间
328 小时
注册时间
2016-4-4
帖子
168

开拓者

4
 楼主| 发表于 2016-12-25 14:16:02 | 只看该作者
好吧 解决了   313行 把return去掉就可以了(所以..为啥整个注释掉就不行而只注释return就可以了....)(好吧 判定的是 not skill_learn)

点评

整个注释掉应该就调用默认的判定了。 注释return应该算定义新方法  发表于 2016-12-25 18:53
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-6-18 22:18

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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