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

Project1

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

[已经过期] 想在反击脚本中添加窗口文字提示“反击”

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1237
在线时间
163 小时
注册时间
2019-10-4
帖子
217
跳转到指定楼层
1
发表于 2022-10-11 16:45:13 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 guoxiaomi 于 2022-10-12 22:41 编辑

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

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

本版积分规则

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

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

GMT+8, 2024-5-4 07:00

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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