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

Project1

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

[已经过期] 求助,多体攻击跟自动战斗冲突,请大大帮助修改

[复制链接]

Lv2.观梦者

梦石
0
星屑
615
在线时间
84 小时
注册时间
2012-8-12
帖子
178
跳转到指定楼层
1
发表于 2017-9-30 05:19:11 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 火焰卷轴 于 2017-10-1 20:27 编辑

人物使用自动战斗的功能时
不会触发多体攻击的效果
请大大整合修正
上传附件不能啊只能贴脚本
请大大帮助

多体攻击脚本
RUBY 代码复制
  1. class Scene_Battle
  2.   def set_target_battlers(item, type)
  3.  
  4.     @多秒_特技 = {} # 初始化多秒功能哈希
  5.     @多秒_物品 = {} # 初始化多秒功能哈希
  6.  
  7.     # ---------------------------
  8.     # 特技多秒 设置
  9.     # ---------------------------
  10.  
  11.     @多秒_特技[57] = 3 # 57号技能 秒3 默认十字斩秒三
  12.     @多秒_特技[7] = 2 #
  13.     @多秒_特技[1] = 3 #
  14.     # ---------------------------
  15.     # 物品多秒 设置
  16.     # ---------------------------
  17.  
  18.   #  @多秒_物品[40] = 5 # 40号物品 秒5 设置 : 敌单体即可 HP 回复量 为负值
  19.  
  20.     # ------------------------------------------------------
  21.     # PS 如果设置了多秒 数据库 中效果范围怎么设置都可以
  22.     # 但必须明确是对敌使用还是对同伴使用,并且明确 是否
  23.     # HP 0 时使用!
  24.     # ------------------------------------------------------
  25.  
  26.     if @active_battler.is_a?(Game_Enemy)
  27.       case item.scope
  28.       when 1  # 敌单体
  29.         index = @active_battler.current_action.target_index
  30.         @target_battlers.push($game_party.smooth_target_actor(index))
  31.         敌方秒(0, item, 0, type, $game_party.smooth_target_actor(index))
  32.       when 2  # 敌全体
  33.         index = @active_battler.current_action.target_index
  34.         for actor in $game_party.actors
  35.           if actor.exist?
  36.             @target_battlers.push(actor)
  37.           end
  38.         end
  39.         敌方秒(0, item, 0, type, $game_party.smooth_target_actor(index))
  40.       when 3  # 我方单体
  41.         index = @active_battler.current_action.target_index
  42.         @target_battlers.push($game_troop.smooth_target_enemy(index))
  43.         敌方秒(0, item, 1, type, $game_troop.smooth_target_enemy(index))
  44.       when 4  # 我方全体
  45.         index = @active_battler.current_action.target_index
  46.         for enemy in $game_troop.enemies
  47.           if enemy.exist?
  48.             @target_battlers.push(enemy)
  49.           end
  50.         end
  51.         敌方秒(0, item, 1, type, $game_troop.smooth_target_enemy(index))
  52.       when 5  # 我方单体 (HP 0)
  53.         index = @active_battler.current_action.target_index
  54.         enemy = $game_troop.enemies[index]
  55.         if enemy != nil and enemy.hp0?
  56.           @target_battlers.push(enemy)
  57.         end
  58.         敌方秒(1, item, 1, type, $game_troop.smooth_target_enemy(index))
  59.       when 6  # 我方全体 (HP 0)
  60.         index = @active_battler.current_action.target_index
  61.         for enemy in $game_troop.enemies
  62.           if enemy != nil and enemy.hp0?
  63.             @target_battlers.push(enemy)
  64.           end
  65.         end
  66.         敌方秒(1, item, 1, type, $game_troop.smooth_target_enemy(index))
  67.       when 7  # 使用者
  68.         @target_battlers.push(@active_battler)
  69.       end
  70.     end
  71.     if @active_battler.is_a?(Game_Actor)
  72.       # 效果范围分支
  73.       case item.scope
  74.       when 1  # 敌单体
  75.         index = @active_battler.current_action.target_index
  76.         @target_battlers.push($game_troop.smooth_target_enemy(index))
  77.         我方秒(0, item, 0, type, $game_troop.smooth_target_enemy(index))
  78.       when 2  # 敌全体
  79.         index = @active_battler.current_action.target_index
  80.         for enemy in $game_troop.enemies
  81.           if enemy.exist?
  82.             @target_battlers.push(enemy)
  83.           end
  84.         end
  85.         我方秒(0, item, 0, type, $game_troop.smooth_target_enemy(index))
  86.       when 3  # 我方单体
  87.         index = @active_battler.current_action.target_index
  88.         @target_battlers.push($game_party.smooth_target_actor(index))
  89.         我方秒(0, item, 1, type, $game_party.smooth_target_actor(index))
  90.       when 4  # 我方全体
  91.         index = @active_battler.current_action.target_index
  92.         for actor in $game_party.actors
  93.           if actor.exist?
  94.             @target_battlers.push(actor)
  95.           end
  96.         end
  97.         我方秒(0, item, 1, type, $game_party.smooth_target_actor(index))
  98.       when 5  # 我方单体 (HP 0)
  99.         index = @active_battler.current_action.target_index
  100.         actor = $game_party.actors[index]
  101.         if actor != nil and actor.hp0?
  102.           @target_battlers.push(actor)
  103.         end
  104.         我方秒(1, item, 1, type, $game_party.smooth_target_actor(index))
  105.       when 6  # 我方全体 (HP 0)
  106.         index = @active_battler.current_action.target_index
  107.         for actor in $game_party.actors
  108.           if actor != nil and actor.hp0?
  109.             @target_battlers.push(actor)
  110.           end
  111.         end
  112.         我方秒(1, item, 1, type, $game_party.smooth_target_actor(index))
  113.       when 7  # 使用者
  114.         @target_battlers.push(@active_battler)
  115.       end
  116.     end
  117.   end
  118.   #--------------------------------------------------------------------------
  119.   # ● 生成特技行动结果
  120.   #--------------------------------------------------------------------------
  121.   def make_skill_action_result
  122.     # 获取特技
  123.     [url=home.php?mod=space&uid=260100]@skill[/url] = $data_skills[@active_battler.current_action.skill_id]
  124.     # 如果不是强制行动
  125.     unless @active_battler.current_action.forcing
  126.       # 因为 SP 耗尽而无法使用的情况下
  127.       unless @active_battler.skill_can_use?(@skill.id)
  128.         # 清除强制行动对像的战斗者
  129.         $game_temp.forcing_battler = nil
  130.         # 移至步骤 1
  131.         @phase4_step = 1
  132.         return
  133.       end
  134.     end
  135.     # 消耗 SP
  136.     @active_battler.sp -= @skill.sp_cost
  137.     # 刷新状态窗口
  138.     @status_window.refresh
  139.     # 在帮助窗口显示特技名
  140.     @help_window.set_text(@skill.name, 1)
  141.     # 设置动画 ID
  142.     @animation1_id = @skill.animation1_id
  143.     @animation2_id = @skill.animation2_id
  144.     # 设置公共事件 ID
  145.     @common_event_id = @skill.common_event_id
  146.     # 设置对像侧战斗者
  147.  
  148.     # ---------------------------------------
  149.     set_target_battlers(@skill, 0)
  150.     # ---------------------------------------
  151.  
  152.     # 应用特技效果
  153.     for target in @target_battlers
  154.       target.skill_effect(@active_battler, @skill)
  155.     end
  156.   end
  157.   #--------------------------------------------------------------------------
  158.   # ● 生成物品行动结果
  159.   #--------------------------------------------------------------------------
  160.   def make_item_action_result
  161.     # 获取物品
  162.     @item = $data_items[@active_battler.current_action.item_id]
  163.     # 因为物品耗尽而无法使用的情况下
  164.     unless $game_party.item_can_use?(@item.id)
  165.       # 移至步骤 1
  166.       @phase4_step = 1
  167.       return
  168.     end
  169.     # 消耗品的情况下
  170.     if @item.consumable
  171.       # 使用的物品减 1
  172.       $game_party.lose_item(@item.id, 1)
  173.     end
  174.     # 在帮助窗口显示物品名
  175.     @help_window.set_text(@item.name, 1)
  176.     # 设置动画 ID
  177.     @animation1_id = @item.animation1_id
  178.     @animation2_id = @item.animation2_id
  179.     # 设置公共事件 ID
  180.     @common_event_id = @item.common_event_id
  181.     # 确定对像
  182.     index = @active_battler.current_action.target_index
  183.     target = $game_party.smooth_target_actor(index)
  184.     # 设置对像侧战斗者
  185.  
  186.     # ---------------------------------------
  187.     set_target_battlers(@item, 1)
  188.     # ---------------------------------------
  189.  
  190.     # 应用物品效果
  191.     for target in @target_battlers
  192.       target.item_effect(@item)
  193.     end
  194.   end
  195.  
  196.   def 敌方秒(n, item, t, type, 目标)
  197.     # ----------------------------------------
  198.     return if @多秒_特技[item.id].nil? and @多秒_物品[item.id].nil?
  199.     @target_battlers = []
  200.     case t
  201.     when 0
  202.       for actor in $game_party.actors
  203.         @target_battlers.push(actor) if actor.exist?
  204.       end
  205.     when 1
  206.       for enemy in $game_troop.enemies
  207.         @target_battlers.push(enemy) if enemy.exist?
  208.       end
  209.     end
  210.     return if @多秒_特技[item.id] >= @target_battlers.size
  211.     while @target_battlers.size > @多秒_特技[item.id]
  212.       a = rand(@target_battlers.size)
  213.       unless a == @target_battlers.size - 1 or
  214.         # 如果用了我发布的嘲讽状态脚本 请把后边的注释去掉!
  215.         @target_battlers[a] == 目标# or @target_battlers[a].state? Wall
  216.         @target_battlers.delete_at(a)
  217.       end
  218.     end
  219.     # -------------------------------------------
  220.   end
  221.   #   参数   是否hp0 项目 对敌还是对友 特技还是物品 目标
  222.   def 我方秒(n, item, t, type, 目标)
  223.     # ----------------------------------------
  224.     return if @多秒_特技[item.id].nil? and @多秒_物品[item.id].nil?
  225.     @target_battlers = []
  226.     case type
  227.     when 0 # 特技
  228.       case t
  229.       when 0
  230.         for enemy in $game_troop.enemies
  231.           case n
  232.           when 0
  233.             @target_battlers.push(enemy) if enemy.exist?
  234.           when 1
  235.             @target_battlers.push(enemy) unless enemy.exist?
  236.           end
  237.         end
  238.       when 1
  239.         for actor in $game_party.actors
  240.           case n
  241.           when 0
  242.             @target_battlers.push(actor) if actor.exist?
  243.           when 1
  244.             @target_battlers.push(actor) unless actor.exist?
  245.           end
  246.         end
  247.       end
  248.       return if @多秒_特技[item.id] >= @target_battlers.size
  249.       while @target_battlers.size > @多秒_特技[item.id]
  250.         a = rand(@target_battlers.size)
  251.         unless a == @target_battlers.size - 1 or
  252.           @target_battlers[a] == 目标
  253.           @target_battlers.delete_at(a)
  254.         end
  255.       end
  256.     when 1 # 物品
  257.       case t
  258.       when 0
  259.         for enemy in $game_troop.enemies
  260.           case n
  261.           when 0
  262.             @target_battlers.push(enemy) if enemy.exist?
  263.           when 1
  264.             @target_battlers.push(enemy) unless enemy.exist?
  265.           end
  266.         end
  267.       when 1
  268.         for actor in $game_party.actors
  269.           case n
  270.           when 0
  271.             @target_battlers.push(actor) if actor.exist?
  272.           when 1
  273.             @target_battlers.push(actor) unless actor.exist?
  274.           end
  275.         end
  276.       end
  277.       return if @多秒_物品[item.id] >= @target_battlers.size
  278.       while @target_battlers.size > @多秒_物品[item.id]
  279.         a = rand(@target_battlers.size)
  280.         unless a == @target_battlers.size - 1 or
  281.           @target_battlers[a] == 目标
  282.           @target_battlers.delete_at(a)
  283.         end
  284.       end
  285.     end
  286.     # ----------------------------------------
  287.   end
  288.  
  289. end


自动战斗脚本
RUBY 代码复制
  1. #==============================================================================
  2. # ★【  自动战斗  】★
  3. #==============================================================================
  4. #  by -> 芯☆淡如水
  5. #==============================================================================
  6. # ● 使用方法:复制该脚本,插入到 main 前。
  7. #==============================================================================
  8. # ● 说明:
  9. #         自动战斗,顾名思义,就是角色选择“自动战斗”后,无需玩家给角色下达
  10. #      指令,角色仍可自己行动。
  11. #        
  12. #         该自动战斗有 2 个模式:普通自动战斗 和 AI自动战斗。2 种模式的切换
  13. #       使用下面设置项的开关。
  14. #
  15. #         角色在 普通自动战斗 时,只是普通攻击敌人。选择的敌人目标偏向血较少
  16. #      者。
  17. #
  18. #         角色在 AI自动战斗 时,判断角色行动类型的流程为:复活同伴 --》 恢复
  19. #      同伴(HP和SP)--》攻击。
  20. #         如果队伍中有同伴死亡,有很大几率复活同伴(具体多大几率就不透露),
  21. #      死亡的同伴个数越多,几率越大。复活同伴的前提条件是有复活类药品或特技。
  22. #         跳过复活同伴是恢复同伴,恢复同伴的几率以整体的剩余HP/SP的百分比来
  23. #      算,百分比越小,几率越高。单体恢复同伴HP/SP的恢复对象,偏向HP/SP较少
  24. #      者。恢复同伴的前提条件是有恢复类药品或特技。
  25. #         最后是攻击,攻击判断之前有一定的几率对同伴使用 增益特技。攻击分为
  26. #      普通攻击和使用特技,几率以角色的不同而不同,如果是战士类型的角色,普通
  27. #      攻击的几率高于使用特技的几率;法师类型的角色则相反。使用特技时有一定的
  28. #      几率使用不良状态特技。所有使用特技都是以角色已习得的特技为基础。普通攻
  29. #      击和使用单体攻击特技的对象目标,也是偏向血较少者。
  30. #
  31. #
  32. #   ■ 恢复:     自动战斗者在恢复同伴时,首先确定恢复对象,根据对象需要恢复的
  33. #               HP/SP 的多少,来确定使用的物品或特技。需要恢复的对象越多,使用
  34. #               “己方全体”的物品或特技的几率越大,单个的恢复对象是不会使用
  35. #               “己方全体”的物品或特技。
  36. #              
  37. #                比如确定了某个恢复对象,该对象需要回复 HP 100 ,所能使用的物品
  38. #               或特技有 3 种:回复 HP 60 ;回复 HP 110 ;回复 HP 220 。那么自动
  39. #               战斗者会选择 “回复 HP 110” 的这个物品或特技来恢复该对象。
  40. #
  41. #
  42. #   ■ 特技攻击:  如果自动战斗者能够使用“敌全体”特技,并且敌人的数量是 2 个
  43. #               或以上时,自动战斗者有几率使用“敌全体”特技,敌人数量越多,几
  44. #               率越大。
  45. #
  46. #                  如果是单个攻击对象,首先确定对象,根据该对象剩余的 HP 来选择
  47. #               特技。在这之前会先判断普通攻击能否弄坏该对象,如果能弄坏该对象,
  48. #               就使用普通攻击,而不使用特技了。
  49. #
  50. #               比如:例1:攻击对象剩余HP:160 ,自动战斗者可使用的特技有:对该
  51. #                          对象伤害 HP 180 和 伤害 HP 260 两个特技,但自动战斗者
  52. #                          对该对象的普通攻击伤害为:HP 200 ,那么自动战斗者会
  53. #                          选择普通攻击而不使用特技。
  54. #
  55. #                     例2:攻击对象剩余HP:2000 ,自动战斗者可使用的特技有:对该
  56. #                          对象伤害 HP 200 ; 伤害 HP 600 ;伤害 HP 1000 三种,
  57. #                          那么自动战斗者会选择 伤害 HP 1000 的这个特技来攻击该
  58. #                          对象。
  59. #==============================================================================
  60. # ● 设置:
  61. #------------------------------------------------------------------------------
  62. # 打开或关闭 自动战斗功能 的开关 ID。
  63. AUTO_SWEITCHE = 1
  64. #------------------------------------------------------------------------------
  65. # 是否 AI自动战斗 的开关 ID。该开关打开为 AI自动;关闭为 普通自动。
  66. AI_AUTO_SWEITCHE = 2
  67. #------------------------------------------------------------------------------
  68. # 角色自动战斗时,自动提示的等待时间(帧)。
  69. WAIT_TIME = 50
  70. #------------------------------------------------------------------------------
  71. # 增益状态 特技 ID 。
  72. UP_PLUS_SKILLS = [53, 54]
  73. #------------------------------------------------------------------------------
  74. # 不良状态 特技 ID 。
  75. DOWN_PLUS_SKILLS = [41, 46]
  76. #=============================================================================
  77. ##############################################################################
  78. #=============================================================================
  79. class Game_Actor < Game_Battler
  80.   #--------------------------------------------------------------------------
  81.   attr_accessor :auto_battle
  82.   attr_accessor :auto_battle_targets
  83.   #--------------------------------------------------------------------------
  84.   alias add_setup_xdrs setup
  85.   def setup(actor_id)
  86.     @auto_battle = false
  87.     @auto_battle_targets = []
  88.     add_setup_xdrs(actor_id)
  89.   end
  90. end
  91. #==============================================================================
  92. class Scene_Battle
  93.   #--------------------------------------------------------------------------
  94.   def main
  95.     # 初始化战斗用的各种暂时数据
  96.     $game_temp.in_battle = true
  97.     $game_temp.battle_turn = 0
  98.     $game_temp.battle_event_flags.clear
  99.     $game_temp.battle_abort = false
  100.     $game_temp.battle_main_phase = false
  101.     $game_temp.battleback_name = $game_map.battleback_name
  102.     $game_temp.forcing_battler = nil
  103.     # 初始化战斗用事件解释器
  104.     $game_system.battle_interpreter.setup(nil, 0)
  105.     # 准备队伍
  106.     @troop_id = $game_temp.battle_troop_id
  107.     $game_troop.setup(@troop_id)
  108.     # 生成角色命令窗口
  109.     s1 = $data_system.words.attack
  110.     s2 = $data_system.words.skill
  111.     s3 = $data_system.words.guard
  112.     s4 = $data_system.words.item
  113.     s5 = "自动"
  114.     s6 = "逃跑"
  115.     if $game_switches[AUTO_SWEITCHE]
  116.       @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
  117.       @actor_command_window.y = 96
  118.     else
  119.       @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4, s6])
  120.       @actor_command_window.y = 128
  121.     end
  122.     @actor_command_window.back_opacity = 160
  123.     @actor_command_window.active = false
  124.     @actor_command_window.visible = false
  125.     # 生成其它窗口
  126.     #
  127.     @auto_top = Window_Base.new(0, 256, 160, 64)
  128.     @auto_top.contents = Bitmap.new(@auto_top.width - 32, @auto_top.height - 32)
  129.     @auto_top.contents.draw_text(0, 0, 138, 32,"确定键:取消自动")
  130.     @auto_top.back_opacity = 160
  131.     @auto_top.visible = false
  132.     #
  133.     @party_command_window = Window_PartyCommand.new
  134.     @help_window = Window_Help.new
  135.     @help_window.back_opacity = 160
  136.     @help_window.visible = false
  137.     @status_window = Window_BattleStatus.new
  138.     @message_window = Window_Message.new
  139.     # 生成活动块
  140.     @spriteset = Spriteset_Battle.new
  141.     # 初始化等待计数
  142.     @wait_count = 0
  143.     @auto_wait_count = 0
  144.     # 执行过渡
  145.     if $data_system.battle_transition == ""
  146.       Graphics.transition(20)
  147.     else
  148.       Graphics.transition(40, "Graphics/Transitions/" +
  149.         $data_system.battle_transition)
  150.     end
  151.     # 开始自由战斗回合
  152.     start_phase1
  153.     # 主循环
  154.     loop do
  155.       # 刷新游戏画面
  156.       Graphics.update
  157.       # 刷新输入信息
  158.       Input.update
  159.       # 刷新画面
  160.       update
  161.       # 如果画面切换的话就中断循环
  162.       if $scene != self
  163.         break
  164.       end
  165.     end
  166.     # 刷新地图
  167.     $game_map.refresh
  168.     # 准备过渡
  169.     Graphics.freeze
  170.     # 释放窗口
  171.     @auto_top.dispose
  172.     @actor_command_window.dispose
  173.     @party_command_window.dispose
  174.     @help_window.dispose
  175.     @status_window.dispose
  176.     @message_window.dispose
  177.     if @skill_window != nil
  178.       @skill_window.dispose
  179.     end
  180.     if @item_window != nil
  181.       @item_window.dispose
  182.     end
  183.     if @result_window != nil
  184.       @result_window.dispose
  185.     end
  186.     # 释放活动块
  187.     @spriteset.dispose
  188.     # 标题画面切换中的情况
  189.     if $scene.is_a?(Scene_Title)
  190.       # 淡入淡出画面
  191.       Graphics.transition
  192.       Graphics.freeze
  193.     end
  194.     # 战斗测试或者游戏结束以外的画面切换中的情况
  195.     if $BTEST and not $scene.is_a?(Scene_Gameover)
  196.       $scene = nil
  197.     end
  198.   end
  199.   #--------------------------------------------------------------------------
  200.   def start_phase2
  201.     # 转移到回合 2
  202.     @phase = 2
  203.     # 设置角色为非选择状态
  204.     @actor_index = -1
  205.     @active_battler = nil
  206.     unless $game_party.inputable?
  207.       # 开始主回合
  208.       start_phase4
  209.       return
  210.     end
  211.     start_phase3
  212.   end
  213.   #--------------------------------------------------------------------------
  214.   def phase3_prior_actor
  215.     # 循环
  216.     begin
  217.       # 角色的明灭效果 OFF
  218.       if @active_battler != nil
  219.         @active_battler.blink = false
  220.       end
  221.       # 最初的角色的情况下
  222.       if @actor_index == 0
  223.         $game_system.se_play($data_system.buzzer_se)
  224.         return
  225.       end
  226.       # 返回角色索引
  227.       @actor_index -= 1
  228.       @active_battler = $game_party.actors[@actor_index]
  229.       @active_battler.blink = true
  230.     # 如果角色是在无法接受指令的状态就再试
  231.     end until @active_battler.inputable?
  232.     # 设置角色的命令窗口
  233.     phase3_setup_command_window
  234.   end
  235. #--------------------------------------------------------------------------
  236.   def update_phase3_basic_command
  237.     # 按下 B 键的情况下
  238.     if Input.trigger?(Input::B)
  239.       # 演奏取消 SE
  240.       $game_system.se_play($data_system.cancel_se)
  241.       # 转向前一个角色的指令输入
  242.       phase3_prior_actor
  243.       return
  244.     end
  245.     # 按下 C 键的情况下
  246.     if Input.trigger?(Input::C)
  247.       # 角色指令窗口光标位置分之
  248.       case @actor_command_window.index
  249.       when 0  # 攻击
  250.         # 演奏确定 SE
  251.         $game_system.se_play($data_system.decision_se)
  252.         # 设置行动
  253.         @active_battler.current_action.kind = 0
  254.         @active_battler.current_action.basic = 0
  255.         # 开始选择敌人
  256.         start_enemy_select
  257.       when 1  # 特技
  258.         # 演奏确定 SE
  259.         $game_system.se_play($data_system.decision_se)
  260.         # 设置行动
  261.         @active_battler.current_action.kind = 1
  262.         # 开始选择特技
  263.         start_skill_select
  264.       when 2  # 防御
  265.         # 演奏确定 SE
  266.         $game_system.se_play($data_system.decision_se)
  267.         # 设置行动
  268.         @active_battler.current_action.kind = 0
  269.         @active_battler.current_action.basic = 1
  270.         # 转向下一位角色的指令输入
  271.         phase3_next_actor
  272.       when 3  # 物品
  273.         # 演奏确定 SE
  274.         $game_system.se_play($data_system.decision_se)
  275.         # 设置行动
  276.         @active_battler.current_action.kind = 2
  277.         # 开始选择物品
  278.         start_item_select
  279.       when 4  # 自动
  280.         if $game_switches[AUTO_SWEITCHE]
  281.           # 演奏确定 SE
  282.           $game_system.se_play($data_system.decision_se)
  283.           @actor_command_window.active = false
  284.           @actor_command_window.visible = false
  285.           @active_battler.auto_battle = true
  286.           phase3_next_actor
  287.         else
  288.            # 演奏确定 SE
  289.           $game_system.se_play($data_system.decision_se)
  290.           # 逃走处理
  291.           update_phase2_escape
  292.         end        
  293.       when 5  # 逃跑
  294.         # 不能逃跑的情况下
  295.         if $game_temp.battle_can_escape == false
  296.           # 演奏冻结 SE
  297.           $game_system.se_play($data_system.buzzer_se)
  298.           return
  299.         end
  300.         # 演奏确定 SE
  301.         $game_system.se_play($data_system.decision_se)
  302.         # 逃走处理
  303.         update_phase2_escape
  304.       end
  305.       return
  306.     end
  307.   end
  308.   #--------------------------------------------------------------------------
  309.   alias add_phase3_setup_command_window_xdrs phase3_setup_command_window
  310.   def phase3_setup_command_window
  311.     if @active_battler.auto_battle
  312.       @auto_wait_count = WAIT_TIME
  313.       @actor_command_window.active = false
  314.       @actor_command_window.visible = false
  315.       @auto_top.visible = true
  316.       @auto_top.x = @actor_index * 160
  317.       return
  318.     end
  319.     add_phase3_setup_command_window_xdrs
  320.   end
  321.   #--------------------------------------------------------------------------
  322.   alias add_update_phase3_xdrs update_phase3
  323.   def update_phase3
  324.     if @auto_wait_count > 0
  325.       update_wait_at
  326.       return
  327.     end
  328.     add_update_phase3_xdrs
  329.   end
  330.   #--------------------------------------------------------------------------
  331.   def update_wait_at
  332.     @auto_wait_count -= 1
  333.     if @auto_wait_count == 0
  334.       $game_system.se_play($data_system.decision_se)
  335.       @auto_top.visible = false
  336.       phase3_next_actor
  337.       return
  338.     end
  339.     if Input.trigger?(Input::B)
  340.       $game_system.se_play($data_system.cancel_se)
  341.       @auto_wait_count = 0
  342.       phase3_prior_actor
  343.       return
  344.     end
  345.     if Input.trigger?(Input::C)
  346.       $game_system.se_play($data_system.decision_se)
  347.       @auto_wait_count = 0
  348.       @active_battler.auto_battle = false
  349.       @auto_top.visible = false
  350.       @actor_index -= 1
  351.       phase3_next_actor
  352.     end
  353.   end
  354.   #--------------------------------------------------------------------------
  355.   def update_phase4_step2
  356.     # 如果不是强制行动
  357.     unless @active_battler.current_action.forcing
  358.       # 限制为 [敌人为普通攻击] 或 [我方为普通攻击] 的情况下
  359.       if @active_battler.restriction == 2 or @active_battler.restriction == 3
  360.         # 设置行动为攻击
  361.         @active_battler.current_action.kind = 0
  362.         @active_battler.current_action.basic = 0
  363.       end
  364.       # 限制为 [不能行动] 的情况下
  365.       if @active_battler.restriction == 4
  366.         # 清除行动强制对像的战斗者
  367.         $game_temp.forcing_battler = nil
  368.         # 移至步骤 1
  369.         @phase4_step = 1
  370.         return
  371.       end
  372.     end
  373.     # 清除对像战斗者
  374.     @target_battlers = []
  375.     if @active_battler.is_a?(Game_Actor)
  376.       if @active_battler.auto_battle and not @active_battler.dead?
  377.         set_auto_battle
  378.         case @active_battler.current_action.kind
  379.         when 0  
  380.           make_basic_auto
  381.         when 1  
  382.           make_skill_auto
  383.         when 2  
  384.           make_item_auto
  385.         end
  386.         if @phase4_step == 2
  387.           @phase4_step = 3
  388.         end
  389.         return
  390.       end
  391.     end
  392.     # 行动种类分支
  393.     case @active_battler.current_action.kind
  394.     when 0  # 基本
  395.       make_basic_action_result
  396.     when 1  # 特技
  397.       make_skill_action_result
  398.     when 2  # 物品
  399.       make_item_action_result
  400.     end
  401.     # 移至步骤 3
  402.     if @phase4_step == 2
  403.       @phase4_step = 3
  404.     end
  405.   end
  406.   #--------------------------------------------------------------------------
  407.   def make_basic_auto
  408.     case @active_battler.current_action.basic
  409.     when 0
  410.       @animation1_id = @active_battler.animation1_id
  411.       @animation2_id = @active_battler.animation2_id
  412.       if @active_battler.restriction == 3
  413.         target = $game_party.random_target_actor
  414.         @active_battler.auto_battle_targets = []
  415.         @active_battler.auto_battle_targets.push(target)
  416.       elsif @active_battler.restriction == 2
  417.         target = $game_troop.random_target_enemy
  418.         @active_battler.auto_battle_targets = []
  419.         @active_battler.auto_battle_targets.push(target)
  420.       end
  421.       @target_battlers = @active_battler.auto_battle_targets
  422.       for target in @target_battlers
  423.         target.attack_effect(@active_battler)
  424.       end
  425.       return
  426.     when 1
  427.       @help_window.set_text($data_system.words.guard, 1)
  428.       return
  429.     end
  430.   end
  431.   #--------------------------------------------------------------------------
  432.   def make_skill_auto
  433.     @skill = $data_skills[@active_battler.current_action.skill_id]
  434.     unless @active_battler.current_action.forcing
  435.       unless @active_battler.skill_can_use?(@skill.id)
  436.         $game_temp.forcing_battler = nil
  437.         @phase4_step = 1
  438.         return
  439.       end
  440.     end
  441.     @active_battler.sp -= @skill.sp_cost
  442.     @status_window.refresh
  443.     @help_window.set_text(@skill.name, 1)
  444.     @animation1_id = @skill.animation1_id
  445.     @animation2_id = @skill.animation2_id
  446.     @common_event_id = @skill.common_event_id
  447.     @target_battlers = @active_battler.auto_battle_targets
  448.     for target in @target_battlers
  449.       target.skill_effect(@active_battler, @skill)
  450.     end
  451.   end
  452.   #--------------------------------------------------------------------------
  453.   def make_item_auto
  454.     @item = $data_items[@active_battler.current_action.item_id]
  455.     unless $game_party.item_can_use?(@item.id)
  456.       @phase4_step = 1
  457.       return
  458.     end
  459.     if @item.consumable
  460.       $game_party.lose_item(@item.id, 1)
  461.     end
  462.     @help_window.set_text(@item.name, 1)
  463.     @animation1_id = @item.animation1_id
  464.     @animation2_id = @item.animation2_id
  465.     @common_event_id = @item.common_event_id
  466.     @target_battlers = @active_battler.auto_battle_targets
  467.     for target in @target_battlers
  468.       target.item_effect(@item)
  469.     end
  470.   end
  471.   #--------------------------------------------------------------------------
  472.   alias add_update_phase4_step6_xdrs update_phase4_step6
  473.   def update_phase4_step6
  474.     @active_battler.auto_battle_targets = [] if @active_battler.is_a?(Game_Actor)
  475.     add_update_phase4_step6_xdrs
  476.   end
  477.   #==============================================================================
  478.   #==============================================================================
  479.   def set_auto_battle
  480.     if $game_switches[AI_AUTO_SWEITCHE]
  481.       ai_auto_battle
  482.     else
  483.       base_atk
  484.     end
  485.   end
  486.   #----------------------------------------------------------------------------
  487.   def ai_auto_battle
  488.     set_probability
  489.     if rand (100) < @f_probability
  490.       f_actor
  491.       return
  492.     end
  493.     judge_r_actor
  494.   end
  495.   #----------------------------------------------------------------------------
  496.   def set_probability
  497.     @f_probability = 0
  498.     h = mh = s = ms = 0.0
  499.     if dead_actors != []
  500.       @f_probability = 70
  501.       @f_probability += (dead_actors.size - 1) * 20
  502.     end
  503.     for actor in all_actors
  504.       h += actor.hp
  505.       mh += actor.maxhp
  506.       s += actor.sp
  507.       ms += actor.maxsp
  508.     end
  509.     @rh_probability = 100 - (h / mh * 100).ceil
  510.     @rh_probability += pressing_actor_hp.size * 30
  511.     @rs_probability = 100 - (s / ms * 100).ceil
  512.     @rs_probability += pressing_actor_sp.size * 30
  513.   end
  514.   #----------------------------------------------------------------------------
  515.   def f_actor
  516.     @f_skills = @f_items = []
  517.     for id in @active_battler.skills
  518.       skill = $data_skills[id]
  519.       if @active_battler.skill_can_use?(id) and [5, 6].include?(skill.scope)
  520.         @f_skills.push(skill)
  521.       end
  522.     end
  523.     for id in 1...$data_items.size
  524.       item = $data_items[id]
  525.       if $game_party.item_number(id) > 0 and [5, 6].include?(item.scope)
  526.         @f_items.push(item)
  527.       end
  528.     end
  529.     if @f_skills != [] or @f_items != []
  530.       if rand (2) == 0
  531.         if @f_skills != []
  532.           f_actor_skill
  533.           return
  534.         end
  535.         f_actor_item
  536.         return
  537.       else
  538.         if @f_items != []
  539.           f_actor_item
  540.           return
  541.         end
  542.         f_actor_skill
  543.         return
  544.       end
  545.     end
  546.     judge_r_actor
  547.   end
  548.   #----------------------------------------------------------------------------
  549.   def f_actor_skill
  550.     @active_battler.current_action.kind = 1
  551.     skill = @f_skills[rand (@f_skills.size)]
  552.     @active_battler.current_action.skill_id = skill.id
  553.     set_autobattler_targets
  554.   end
  555.   #----------------------------------------------------------------------------
  556.   def f_actor_item
  557.     @active_battler.current_action.kind = 2
  558.     item = @f_items[rand (@f_items.size)]
  559.     @active_battler.current_action.item_id = item.id
  560.     set_autobattler_targets
  561.   end
  562.   #----------------------------------------------------------------------------
  563.   def judge_r_actor
  564.     if @rh_probability >= 30 and rand (120) < @rh_probability
  565.       r_actor_hp
  566.       return
  567.     end
  568.     if @rs_probability >= 50 and rand (150) < @rs_probability
  569.       r_actor_sp
  570.       return
  571.     end
  572.     judge_battle
  573.   end
  574.   #----------------------------------------------------------------------------
  575.   def r_actor_hp
  576.     if recover_hp_items != [] or recover_hp_skills != []   
  577.       if rand (2) == 0
  578.         if recover_hp_items != []
  579.           r_hp_item
  580.           return
  581.         end
  582.         r_hp_skill
  583.         return
  584.       else
  585.         if recover_hp_skills != []
  586.           r_hp_skill
  587.           return
  588.         end
  589.         r_hp_item
  590.         return
  591.       end
  592.     end
  593.     if @rs_probability >= 50 and rand (150) < @rs_probability
  594.       r_actor_sp
  595.       return
  596.     end
  597.     judge_battle
  598.   end
  599.   #----------------------------------------------------------------------------
  600.   def r_actor_sp
  601.     if recover_sp_items != []   
  602.       r_sp_item
  603.       return
  604.     end
  605.     judge_battle
  606.   end
  607.   #----------------------------------------------------------------------------
  608.   def r_hp_item
  609.     @active_battler.current_action.kind = 2
  610.     date = []
  611.     items = []
  612.     for actor in all_actors
  613.       if actor.hp * 100 < actor.maxhp * 90
  614.         date.push(actor)
  615.       end
  616.     end
  617.     for item in recover_hp_items
  618.       items.push(item) if item.scope == 4
  619.     end
  620.     if ! items.empty? and date.size >= 2
  621.       n = 10
  622.       n += (date.size - 1) * 20
  623.       if rand (100) < n
  624.         item = items[rand (items.size)]
  625.         @active_battler.current_action.item_id = item.id
  626.         @active_battler.auto_battle_targets = all_actors
  627.         return
  628.       end
  629.     end
  630.     now_items = recover_hp_items - items
  631.     if now_items.empty?
  632.       judge_battle
  633.       return
  634.     end
  635.     @active_battler.auto_battle_targets.push(targets_actor_hp)
  636.     target = @active_battler.auto_battle_targets[0]
  637.     set_use_item(now_items, target, 0)
  638.   end
  639.   #----------------------------------------------------------------------------
  640.   def r_sp_item
  641.     @active_battler.current_action.kind = 2
  642.     date = []
  643.     items = []
  644.     for actor in all_actors
  645.       if actor.sp * 100 < actor.maxsp * 60
  646.         date.push(actor)
  647.       end
  648.     end
  649.     for item in recover_sp_items
  650.       items.push(item) if item.scope == 4
  651.     end
  652.     if ! items.empty? and date.size >= 2
  653.       n = 10
  654.       n += (date.size - 1) * 20
  655.       if rand (100) < n
  656.         item = items[rand (items.size)]
  657.         @active_battler.current_action.item_id = item.id
  658.         @active_battler.auto_battle_targets = all_actors
  659.         return
  660.       end
  661.     end
  662.     now_items = recover_sp_items - items
  663.     if now_items.empty?
  664.       judge_battle
  665.       return
  666.     end
  667.     @active_battler.auto_battle_targets.push(targets_actor_sp)
  668.     target = @active_battler.auto_battle_targets[0]
  669.     set_use_item(now_items, target, 1)
  670.   end
  671.   #----------------------------------------------------------------------------
  672.   def r_hp_skill
  673.     date = []
  674.     skills = []
  675.     for actor in all_actors
  676.       if actor.hp * 100 < actor.maxhp * 90
  677.         date.push(actor)
  678.       end
  679.     end
  680.     for skill in recover_hp_skills
  681.       skills.push(skill) if skill.scope == 4
  682.     end
  683.     if ! skills.empty? and date.size >= 2
  684.       n = 20
  685.       n += (date.size - 1) * 20
  686.       if rand (100) < n
  687.         @active_battler.current_action.kind = 1
  688.         skill = skills[rand(skills.size)]
  689.         @active_battler.current_action.skill_id = skill.id
  690.         @active_battler.auto_battle_targets = all_actors
  691.         return
  692.       end
  693.     end
  694.     now_skills = recover_hp_skills - skills
  695.     if now_skills.empty?
  696.       judge_battle
  697.       return
  698.     end
  699.     @active_battler.current_action.kind = 1
  700.     @active_battler.auto_battle_targets.push(targets_actor_hp)
  701.     target = @active_battler.auto_battle_targets[0]
  702.     set_use_skill(now_skills, target)
  703.   end
  704.   #---------------------------------------------------------------------------
  705.   def judge_battle
  706.     if up_plus_skills != []
  707.       if rand (100) < 20
  708.         use_up_skill
  709.         return
  710.       end
  711.     end
  712.     battle
  713.   end
  714.   #---------------------------------------------------------------------------
  715.   def battle
  716.     n = 100 - @active_battler.hp * 100 / @active_battler.maxhp
  717.     if n > 80
  718.       if rand (150) < n
  719.         @active_battler.current_action.kind = 0
  720.         @active_battler.current_action.basic = 1
  721.         return
  722.       end
  723.     end
  724.     if @active_battler.int > @active_battler.str
  725.       n = 80
  726.     elsif @active_battler.int == @active_battler.str
  727.       n = 60
  728.     else
  729.       n = 40
  730.     end
  731.     if rand (100) < n
  732.       use_skill
  733.     else
  734.       base_atk
  735.     end
  736.   end
  737.   #---------------------------------------------------------------------------
  738.   def use_skill
  739.     if down_plus_skills != []
  740.       if rand (100) < 20
  741.         use_down_skill
  742.         return
  743.       end
  744.     end
  745.     if att_skills != []
  746.       use_att_skill
  747.       return
  748.     end
  749.     base_atk
  750.   end
  751.   #---------------------------------------------------------------------------
  752.   def use_up_skill
  753.     @active_battler.current_action.kind = 1
  754.     skill = up_plus_skills[rand (up_plus_skills.size)]
  755.     @active_battler.current_action.skill_id = skill.id
  756.     set_autobattler_targets
  757.   end
  758.   #--------------------------------------------------------------------------
  759.   def use_down_skill
  760.     @active_battler.current_action.kind = 1
  761.     skill = down_plus_skills[rand (down_plus_skills.size)]
  762.     @active_battler.current_action.skill_id = skill.id
  763.     set_autobattler_targets
  764.   end
  765.   #--------------------------------------------------------------------------
  766.   def use_att_skill
  767.     @active_battler.current_action.kind = 1
  768.     date = []
  769.     for skill in att_skills
  770.       date.push(skill) if skill.scope == 2
  771.     end
  772.     if all_enemys.size >= 2
  773.       n = 10
  774.       n += (all_enemys.size - 1) * 10
  775.       n = [n, 80].min
  776.       if rand (100) < n and ! date.empty?
  777.         skill = date[rand (date.size)]
  778.         @active_battler.current_action.skill_id = skill.id
  779.         @active_battler.auto_battle_targets = all_enemys
  780.         return
  781.       end
  782.     end
  783.     now_skills = att_skills - date
  784.     if now_skills.empty?
  785.       base_atk
  786.       return
  787.     end
  788.     @active_battler.auto_battle_targets.push(targets_enemy_hp)
  789.     target = @active_battler.auto_battle_targets[0]
  790.     if use_base_atk?(target)
  791.       base_atk
  792.       return
  793.     end
  794.     set_use_skill(now_skills, target)
  795.   end
  796.   #----------------------------------------------------------------------------
  797.   def base_atk
  798.     @active_battler.current_action.kind = 0
  799.     @active_battler.current_action.basic = 0
  800.     if @active_battler.auto_battle_targets.empty?
  801.       @active_battler.auto_battle_targets.push(targets_enemy_hp)
  802.     end
  803.   end
  804.   ############################################################################
  805.   #----------------------------------------------------------------------------
  806.   def rand_actors
  807.     date = []
  808.     while date.size != $game_party.actors.size
  809.       actor = $game_party.actors[rand ($game_party.actors.size)]
  810.       date.push(actor) if not date.include?(actor)
  811.     end
  812.     return date
  813.   end
  814.   #----------------------------------------------------------------------------
  815.   def dead_actors
  816.     date = []
  817.     for actor in rand_actors
  818.       date.push(actor) if actor.dead?
  819.     end
  820.     return date
  821.   end
  822.   #----------------------------------------------------------------------------
  823.   def all_actors
  824.     date = []
  825.     for actor in rand_actors
  826.       date.push(actor) if actor.exist?
  827.     end
  828.     return date
  829.   end
  830.   #----------------------------------------------------------------------------
  831.   def targets_actor_hp
  832.     if pressing_actor_hp != []      
  833.       target = pressing_actor_hp[rand (pressing_actor_hp.size)]
  834.       return target
  835.     end
  836.     date = []
  837.     for actor in all_actors
  838.       if actor.hp * 100 < actor.maxhp * 90
  839.         date.push(actor)
  840.       end
  841.     end
  842.     target = nil
  843.     if date != []
  844.       for actor in date
  845.         hn = 100 - actor.hp * 100 / actor.maxhp
  846.         if rand (100) < hn
  847.           target = actor
  848.           break
  849.         end
  850.       end
  851.       target = date[rand (date.size)] if target == nil
  852.     end
  853.     target = all_actors[rand (all_actors.size)] if target == nil
  854.     return target
  855.   end
  856.   #----------------------------------------------------------------------------
  857.   def targets_actor_sp
  858.     if pressing_actor_sp != []      
  859.       target = pressing_actor_sp[rand (pressing_actor_sp.size)]
  860.       return target
  861.     end
  862.     date = []
  863.     for actor in all_actors
  864.       if actor.sp * 100 < actor.maxsp * 80
  865.         date.push(actor)
  866.       end
  867.     end
  868.     target = nil
  869.     if date != []
  870.       for actor in date
  871.         sn = 100 - actor.sp * 100 / actor.maxsp
  872.         if rand (100) < sn
  873.           target = actor
  874.           break
  875.         end
  876.       end
  877.       target = date[rand (date.size)] if target == nil
  878.     end
  879.     target = all_actors[rand (all_actors.size)] if target == nil
  880.     return target
  881.   end
  882.   #----------------------------------------------------------------------------
  883.   def pressing_actor_hp
  884.     date = []
  885.     for actor in all_actors
  886.       if actor.hp * 100 <= actor.maxhp * 30
  887.         date.push(actor)
  888.       end
  889.     end
  890.     return date
  891.   end
  892.   #----------------------------------------------------------------------------
  893.   def pressing_actor_sp
  894.     date = []
  895.     for actor in all_actors
  896.       if actor.sp * 100 <= actor.maxsp * 10
  897.         date.push(actor)
  898.       end
  899.     end
  900.     return date
  901.   end
  902.   #----------------------------------------------------------------------------
  903.   def recover_hp_items
  904.     date = []
  905.     for i in 1...$data_items.size
  906.       item = $data_items
  907.       if $game_party.item_number(i) > 0 and [0, 1].include?(item.occasion)
  908.         if not [5, 6].include?(item.scope)
  909.           date.push(item) if item.recover_hp_rate > 0 or item.recover_hp > 0
  910.         end
  911.       end
  912.     end
  913.     return date
  914.   end
  915.   #----------------------------------------------------------------------------
  916.   def recover_sp_items
  917.     date = []
  918.     for i in 1...$data_items.size
  919.       item = $data_items
  920.       if $game_party.item_number(i) > 0 and [0, 1].include?(item.occasion)
  921.         date.push(item) if item.recover_sp_rate > 0 or item.recover_sp > 0
  922.       end
  923.     end
  924.     return date
  925.   end
  926.   #----------------------------------------------------------------------------
  927.   def all_enemys
  928.     date = []
  929.     for enemy in $game_troop.enemies
  930.       date.push(enemy) if enemy.exist?
  931.     end
  932.     return date
  933.   end
  934.   #----------------------------------------------------------------------------
  935.   def targets_enemy_hp
  936.     date = []
  937.     for enemy in all_enemys
  938.       if enemy.hp < enemy.maxhp
  939.         date.push(enemy)
  940.       end
  941.     end
  942.     target = nil
  943.     if date != []
  944.       for enemy in date
  945.         hn = 100 - enemy.hp * 100 / enemy.maxhp
  946.         if rand (100) < hn
  947.           target = enemy
  948.           break
  949.         end
  950.       end
  951.     end
  952.     target = all_enemys[rand (all_enemys.size)] if target == nil
  953.     return target
  954.   end
  955.   #----------------------------------------------------------------------------
  956.   def recover_hp_skills
  957.     date = []
  958.     for id in @active_battler.skills
  959.       skill = $data_skills[id]
  960.       if @active_battler.skill_can_use?(id) and skill.power < 0
  961.         date.push(skill)
  962.       end
  963.     end
  964.     return date
  965.   end
  966.   #----------------------------------------------------------------------------
  967.   def att_skills
  968.     date = []
  969.     for id in @active_battler.skills
  970.       skill = $data_skills[id]
  971.       if @active_battler.skill_can_use?(id) and skill.power > 0
  972.         date.push(skill)
  973.       end
  974.     end
  975.     return date
  976.   end
  977.   #----------------------------------------------------------------------------
  978.   def up_plus_skills
  979.     date = []
  980.     for id in @active_battler.skills
  981.       skill = $data_skills[id]
  982.       if @active_battler.skill_can_use?(id) and UP_PLUS_SKILLS.include?(id)
  983.         date.push(skill)
  984.       end
  985.     end
  986.     return date
  987.   end
  988.   #----------------------------------------------------------------------------
  989.   def down_plus_skills
  990.     date = []
  991.     for id in @active_battler.skills
  992.       skill = $data_skills[id]
  993.       if @active_battler.skill_can_use?(id) and DOWN_PLUS_SKILLS.include?(id)
  994.         date.push(skill)
  995.       end
  996.     end
  997.     return date
  998.   end
  999.   #---------------------------------------------------------------------------
  1000.   def set_use_item(items, target, toyp)
  1001.     @item = nil
  1002.     case toyp
  1003.     when 0
  1004.       date = []
  1005.       for item in items
  1006.         recover = item.recover_hp + item.recover_hp_rate * target.maxhp
  1007.         n = (recover - (target.maxhp - target.hp)).abs
  1008.         date.push(n)
  1009.       end
  1010.       date.sort!
  1011.       for item in items
  1012.         recover = item.recover_hp + item.recover_hp_rate * target.maxhp
  1013.         n = (recover - (target.maxhp - target.hp)).abs
  1014.         if n == date[0]
  1015.           @item = item
  1016.           break
  1017.         end
  1018.       end
  1019.     when 1
  1020.       date = []
  1021.       for item in items
  1022.         recover = item.recover_sp + item.recover_sp_rate * target.maxsp
  1023.         n = (recover - (target.maxsp - target.sp)).abs
  1024.         date.push(n)
  1025.       end
  1026.       date.sort!
  1027.       for item in items
  1028.         recover = item.recover_sp + item.recover_sp_rate * target.maxsp
  1029.         n = (recover - (target.maxsp - target.sp)).abs
  1030.         if n == date[0]
  1031.           @item = item
  1032.           break
  1033.         end
  1034.       end
  1035.     end
  1036.     @item = items[rand(items.size)] if @item == nil
  1037.     @active_battler.current_action.item_id = @item.id
  1038.   end
  1039.   #---------------------------------------------------------------------------
  1040.   def set_use_skill(skills, target)
  1041.     r_skills = []
  1042.     a_skills = []
  1043.     skill = nil
  1044.     for i in skills
  1045.       damage = count_skill_damage(i, target)
  1046.       if damage < 0
  1047.         n = (target.maxhp - target.hp + damage).abs
  1048.         r_skills.push(n)
  1049.       else
  1050.         n = (target.hp - damage).abs
  1051.         a_skills.push(n)
  1052.       end
  1053.     end
  1054.     r_skills.sort!
  1055.     a_skills.sort!
  1056.     for i in skills
  1057.       damage = count_skill_damage(i, target)
  1058.       if damage < 0
  1059.         n = (target.maxhp - target.hp + damage).abs
  1060.         skill = i if n == r_skills[0]
  1061.       else
  1062.         n = (target.hp - damage).abs
  1063.         skill = i if n == a_skills[0]
  1064.       end
  1065.     end
  1066.     skill = skills[rand (skills.sizs)] if skill == nil
  1067.     @active_battler.current_action.skill_id = skill.id
  1068.   end
  1069.   #----------------------------------------------------------------------------
  1070.   def count_skill_damage(skill, target)
  1071.     power = skill.power + @active_battler.atk * skill.atk_f / 100
  1072.     if power > 0
  1073.       power -= target.pdef * skill.pdef_f / 200
  1074.       power -= target.mdef * skill.mdef_f / 200
  1075.       power = [power, 0].max
  1076.     end
  1077.     rate = 20
  1078.     rate += (target.str * skill.str_f / 100)
  1079.     rate += (target.dex * skill.dex_f / 100)
  1080.     rate += (target.agi * skill.agi_f / 100)
  1081.     rate += (target.int * skill.int_f / 100)
  1082.     damage = power * rate / 20
  1083.     if skill.element_set == []
  1084.       rn = 100
  1085.     else
  1086.       rn = -100
  1087.       for i in skill.element_set
  1088.         rn = [rn, target.element_rate(i)].max
  1089.       end
  1090.     end
  1091.     damage = damage * rn / 100
  1092.     return damage
  1093.   end
  1094.   #----------------------------------------------------------------------------
  1095.   def use_base_atk?(target)
  1096.     atk = [@active_battler.atk - target.pdef / 2, 0].max
  1097.     damage = atk * (20 + @active_battler.str) / 20
  1098.     if @active_battler.element_set == []
  1099.       rn = 100
  1100.     else
  1101.       rn = -100
  1102.       for i in skill.element_set
  1103.         rn = [rn, target.element_rate(i)].max
  1104.       end
  1105.     end
  1106.     damage = damage * rn / 100
  1107.     n = target.hp - damage
  1108.     return true if n <= 0
  1109.     return false
  1110.   end
  1111.   #--------------------------------------------------------------------------
  1112.   def set_autobattler_targets
  1113.     case @active_battler.current_action.kind
  1114.     when 0
  1115.       @active_battler.auto_battle_targets.push(targets_enemy_hp)
  1116.     when 1
  1117.       skill = $data_skills[@active_battler.current_action.skill_id]
  1118.       if [5, 6].include?(skill.scope) and dead_actors != []
  1119.         if skill.scope == 5
  1120.           target = dead_actors[rand (dead_actors.size)]
  1121.           @active_battler.auto_battle_targets.push(target)
  1122.         else
  1123.           @active_battler.auto_battle_targets = dead_actors
  1124.         end
  1125.         return
  1126.       end
  1127.       if UP_PLUS_SKILLS.include?(skill.id)
  1128.         if skill.scope == 3
  1129.           target = all_actors[rand (all_actors.size)]
  1130.           @active_battler.auto_battle_targets.push(target)
  1131.         elsif skill.scope == 4
  1132.           @active_battler.auto_battle_targets = all_actors
  1133.         elsif skill.scope == 7
  1134.           @active_battler.auto_battle_targets.push(@active_battler)
  1135.         end
  1136.         return
  1137.       end
  1138.       if DOWN_PLUS_SKILLS.include?(skill.id)
  1139.         if skill.scope == 1
  1140.           target = all_enemys[rand (all_enemys.size)]
  1141.           @active_battler.auto_battle_targets.push(target)
  1142.         elsif skill.scope == 2
  1143.           @active_battler.auto_battle_targets = all_enemys
  1144.         end
  1145.         return
  1146.       end
  1147.       if skill.power > 0
  1148.         if skill.scope == 1
  1149.           @active_battler.auto_battle_targets.push(targets_enemy_hp)
  1150.         elsif skill.scope == 2
  1151.           @active_battler.auto_battle_targets = all_enemys
  1152.         end
  1153.       elsif skill.power < 0
  1154.         if skill.scope == 3
  1155.           @active_battler.auto_battle_targets.push(targets_actor_hp)
  1156.         elsif skill.scope == 4
  1157.           @active_battler.auto_battle_targets = all_actors
  1158.         end
  1159.       end
  1160.     when 2
  1161.       item = $data_items[@active_battler.current_action.item_id]
  1162.       case item.scope
  1163.       when 1
  1164.         @active_battler.auto_battle_targets.push(targets_enemy_hp)
  1165.       when 2
  1166.         @active_battler.auto_battle_targets = all_enemys
  1167.       when 3
  1168.         if (item.recover_sp_rate > 0 or item.recover_sp > 0) and
  1169.           (item.recover_hp_rate > 0 or item.recover_hp > 0)
  1170.           if rand (100) < 50
  1171.             @active_battler.auto_battle_targets.push(targets_actor_sp)
  1172.           else
  1173.             @active_battler.auto_battle_targets.push(targets_actor_hp)
  1174.           end
  1175.           return
  1176.         end
  1177.         if item.recover_hp_rate > 0 or item.recover_hp > 0
  1178.           @active_battler.auto_battle_targets.push(targets_actor_hp)
  1179.           return
  1180.         end
  1181.         if item.recover_sp_rate > 0 or item.recover_sp > 0
  1182.           @active_battler.auto_battle_targets.push(targets_actor_sp)
  1183.           return
  1184.         end
  1185.       when 4
  1186.         @active_battler.auto_battle_targets = all_actors
  1187.       when 5
  1188.         target = dead_actors[rand (dead_actors.size)]
  1189.         @active_battler.auto_battle_targets.push(target)
  1190.       when 6
  1191.         @active_battler.auto_battle_targets = dead_actors
  1192.       when 7
  1193.         @active_battler.auto_battle_targets.push(@active_battler)
  1194.       end
  1195.     end
  1196.   end
  1197. end
  1198. #==============================================================================
  1199. ###############################################################################
  1200. #==============================================================================

@芯☆淡如水

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

本版积分规则

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

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

GMT+8, 2024-9-21 18:48

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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