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

Project1

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

[原创发布] 【简易自动战斗】测试版 ver.0.1(RTAB)

[复制链接]

Lv1.梦旅人

梦石
0
星屑
47
在线时间
976 小时
注册时间
2011-4-30
帖子
860
跳转到指定楼层
1
发表于 2012-11-26 21:50:37 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 羞射了 于 2012-11-26 21:55 编辑

前几天看到某人(爆焰)的提问,他启发了我的灵感,于是就诞生了这么一个东西……

所谓“简易自动战斗”是指让玩家角色可以直接使用RM自带的自动战斗,类似于敌人的行为模式,而非重写一个复杂的AI设定。

具体设定方式为:数据库某号“职业”对应数据库某号“敌人”的行为模式,例如写成“剑士[26]”,就将剑士职业的自动战斗设置关联为第26号敌人的行为模式,

未设置对应关系的职业如“剑士”等,默认对应1号敌人的行为,具体行为模式请自行设置。

当前版本仅提供“全体自动战斗”以及开关功能(F5),单独角色的自动战斗暂不提供,

其实很容易修改,有兴趣的玩家可以自行研究或66rpg论坛PM我。

需要RTAB战斗系统的支持,贴到后面就能用,RTAB017整合版测试也无问题……

欢迎有兴趣的玩家参与测试并提出反馈意见……

RTAB_sixRice_017b.rar (955.89 KB, 下载次数: 196) (附件内不包括下面的脚本,请自行复制粘贴,我只是主站搜不到017的版本才上传一下)
RUBY 代码复制
  1. #=============================================================================
  2. #简易自动战斗测试版 ver.0.1(RTAB) 2012/11/26
  3. #by 羞射了
  4. #---------------------------------------------------------------------------
  5. #所谓“简易自动战斗”是指让玩家角色可以直接使用RM自带的自动战斗,类似于敌人的
  6. #行为模式,而非重写一个复杂的AI设定。
  7. #---------------------------------------------------------------------------
  8. #具体设定方式为:数据库某号“职业”对应数据库某号“敌人”的行为模式,
  9. #例如写成“剑士[26]”,就将剑士职业的自动战斗设置关联为第26号敌人的行为模式,
  10. #未设置对应关系的职业如“剑士”等,默认对应1号敌人的行为,
  11. #具体行为模式请自行设置。
  12. #---------------------------------------------------------------------------
  13. #当前版本仅提供“全体自动战斗”以及开关功能(F5),单独角色的自动战斗暂不提供,
  14. #其实很容易修改,有兴趣的玩家可以自行研究或66rpg论坛PM我。
  15. #=============================================================================
  16. # ■ RPG::Class
  17. #=============================================================================
  18. class RPG::Class
  19.   def name
  20.     return @name.gsub(/\[.*\]/) {""}
  21.   end
  22.   #--------------------------------------------------------------------------
  23.   def original_name
  24.     return @name
  25.   end
  26.   #--------------------------------------------------------------------------
  27.   def auto_mode
  28.     if @name =~ /\[[ ]*(\d+)\]/i
  29.       return $1.to_i
  30.     else
  31.       return 1
  32.     end
  33.   end
  34. end
  35. #=============================================================================
  36. class Game_Temp
  37.   attr_accessor :battle_auto
  38.   alias initialize_orig initialize
  39.   def initialize
  40.     initialize_orig
  41.     @battle_auto = false
  42.   end
  43. end
  44. #=============================================================================
  45. class Game_Actor
  46.   #--------------------------------------------------------------------------
  47.   def actions
  48.     return $data_enemies[$data_classes[@class_id].auto_mode].actions
  49.   end
  50.   #--------------------------------------------------------------------------
  51.   def make_action
  52.     self.current_action.clear
  53.     unless self.inputable?
  54.       return
  55.     end
  56.     available_actions = []
  57.     rating_max = 0
  58.     for action in self.actions
  59.       n = $game_temp.battle_turn
  60.       a = action.condition_turn_a
  61.       b = action.condition_turn_b
  62.       if (b == 0 and n != a) or
  63.          (b > 0 and (n < 1 or n < a or n % b != a % b))
  64.         next
  65.       end
  66.       if self.hp * 100.0 / self.maxhp > action.condition_hp
  67.         next
  68.       end
  69.       if $game_party.max_level < action.condition_level
  70.         next
  71.       end
  72.       switch_id = action.condition_switch_id
  73.       if switch_id > 0 and $game_switches[switch_id] == false
  74.         next
  75.       end
  76.       if action.kind == 1
  77.         unless self.skill_can_use?(action.skill_id)
  78.           next
  79.         end
  80.       end
  81.       available_actions.push(action)
  82.       if action.rating > rating_max
  83.         rating_max = action.rating
  84.       end
  85.     end
  86.     ratings_total = 0
  87.     for action in available_actions
  88.       if action.rating > rating_max - 3
  89.         ratings_total += action.rating - (rating_max - 3)
  90.       end
  91.     end
  92.     if ratings_total > 0
  93.       value = rand(ratings_total)
  94.       for action in available_actions
  95.         if action.rating > rating_max - 3
  96.           if value < action.rating - (rating_max - 3)
  97.             self.current_action.kind = action.kind
  98.             self.current_action.basic = action.basic
  99.             self.current_action.skill_id = action.skill_id
  100.             self.current_action.decide_random_target_for_enemy
  101.             return
  102.           else
  103.             value -= action.rating - (rating_max - 3)
  104.           end
  105.         end
  106.       end
  107.     end
  108.   end
  109. #---------------------------------------------------------------------------
  110. end
  111. #===========================================================================
  112. class Scene_Battle
  113. #---------------------------------------------------------------------------
  114.   alias atb_setup_orig atb_setup
  115.   def atb_setup
  116.     atb_setup_orig
  117.     $game_temp.battle_auto = false
  118.   end
  119. #---------------------------------------------------------------------------
  120.   def auto_action(battler)
  121.     unless battler.current_action.forcing
  122.       battler.make_action
  123.     end
  124.     action_start(battler)
  125.   end
  126. #---------------------------------------------------------------------------
  127.   alias update_orig update
  128.   def update
  129.     update_orig
  130.     if Input.trigger?(Input::F5)
  131.       if $game_temp.battle_auto == true
  132.         $game_temp.battle_auto = false
  133.       else
  134.         $game_temp.battle_auto = true
  135.       end
  136.     end
  137.   end
  138. #---------------------------------------------------------------------------
  139.   def update_phase3
  140.     if victory? and @command_a or $game_temp.battle_auto
  141.       command_delete
  142.     #  @command.push(@active_actor)
  143.       return
  144.     end
  145.     # エネミーアローが有効の場合
  146.     if @enemy_arrow != nil
  147.       update_phase3_enemy_select
  148.     # アクターアローが有効の場合
  149.     elsif @actor_arrow != nil
  150.       update_phase3_actor_select
  151.     # スキルウィンドウが有効の場合
  152.     elsif @skill_window != nil
  153.       update_phase3_skill_select
  154.     # アイテムウィンドウが有効の場合
  155.     elsif @item_window != nil
  156.       update_phase3_item_select
  157.     # アクターコマンドウィンドウが有効の場合
  158.     elsif @actor_command_window.active
  159.       update_phase3_basic_command
  160.     end
  161.   end
  162. #---------------------------------------------------------------------------
  163.   def update_phase0
  164.     if $game_temp.battle_turn == 0
  165.       $game_temp.battle_turn = 1
  166.     end
  167.     # ATゲージ増加処理
  168.     cnt = 0
  169.     for battler in $game_party.actors + $game_troop.enemies
  170.       active?(battler)
  171.       if battler.rtp == 0
  172.         if battler.at >= @max
  173.           if battler.is_a?(Game_Actor)
  174.             if battler.inputable?
  175.               unless @action_battlers.include?(battler) or
  176.                   @command.include?(battler) or @escape == true
  177.                 if battler.current_action.forcing
  178.                   fullat_se
  179.                   force_action(battler)
  180.                   action_start(battler)
  181.                 elsif $game_temp.battle_auto####添加对自动战斗的支持判定####
  182.                   auto_action(battler)
  183.                 else
  184.                   fullat_se
  185.                   @command.push(battler)
  186.                 end
  187.               end
  188.             else
  189.               unless @action_battlers.include?(battler) or
  190.                       battler == @command[0]
  191.                 battler.current_action.clear
  192.                 if @command.include?(battler)
  193.                   @command.delete(battler)
  194.                 else
  195.                   if battler.movable?
  196.                     fullat_se
  197.                   end
  198.                 end
  199.                 action_start(battler)
  200.               end
  201.             end
  202.           else
  203.             unless @action_battlers.include?(battler)
  204.               if battler.current_action.forcing
  205.                 force_action(battler)
  206.                 action_start(battler)
  207.               else
  208.                 if @enemy_speed != 0
  209.                   if rand(@enemy_speed) == 0
  210.                     number = cnt - $game_party.actors.size
  211.                     enemy_action(number)
  212.                   end
  213.                 else
  214.                   number = cnt - $game_party.actors.size
  215.                   enemy_action(number)
  216.                 end
  217.               end
  218.             end
  219.           end
  220.         else
  221.           battler.at += battler.agi
  222.           if battler.guarding?
  223.             battler.at += battler.agi
  224.           end
  225.           if battler.movable?
  226.             battler.atp = 100 * battler.at / @max
  227.           end
  228.         end
  229.       else
  230.         if battler.rt >= battler.rtp
  231.           speller = synthe?(battler)
  232.           if speller != nil
  233.             battler = speller[0]
  234.           end
  235.           unless @action_battlers.include?(battler)
  236.             if battler.is_a?(Game_Actor)
  237.               fullat_se
  238.             end
  239.             battler.rt = battler.rtp
  240.             action_start(battler)
  241.           end
  242.         else
  243.           battler.rt += battler.agi
  244.           speller = synthe?(battler)
  245.           if speller != nil
  246.             for spell in speller
  247.               if spell != battler
  248.                 spell.rt += battler.agi
  249.               end
  250.             end
  251.           end
  252.         end
  253.       end
  254.       cnt += 1
  255.     end
  256.     # ATゲージをリフレッシュ
  257.     @status_window.at_refresh
  258.     # 逃走処理
  259.     if @escape == true and
  260.         ((@action > 0 and @action_battlers.empty?) or (@action == 0 and
  261.         (@action_battlers.empty? or @action_battlers[0].phase == 1)))
  262.       temp = false
  263.       for battler in $game_party.actors
  264.         if battler.inputable?
  265.           temp = true
  266.         end
  267.       end
  268.       if temp == true
  269.         for battler in $game_party.actors
  270.           if battler.at < [url=home.php?mod=space&uid=25307]@Max[/url] and battler.inputable?
  271.             temp = false
  272.             break
  273.           end
  274.         end
  275.         if temp == true
  276.           @escape = false
  277.           for battler in $game_party.actors
  278.             battler.at %= @max
  279.           end
  280.           $game_temp.battle_main_phase = false
  281.           update_phase2_escape
  282.         end
  283.       end
  284.     end
  285.   end
  286. #---------------------------------------------------------------------------
  287. end
  288. #===========================================================================
   
湿滑落式骑!

Lv1.梦旅人

梦石
0
星屑
60
在线时间
568 小时
注册时间
2012-9-7
帖子
611
2
发表于 2012-11-30 11:51:30 | 只看该作者
效率很高的,上次看了你的回帖,过几天就出了
话说我上次给爆焰发的AI是非RTAB的。
RTAB的AI我尝试过,但是好像不是那么好写,你居然弄这个出来了,于是进来学习一下
FTM正式版已经发布,点击图片开启传送门
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
60
在线时间
568 小时
注册时间
2012-9-7
帖子
611
3
发表于 2012-11-30 12:36:17 | 只看该作者
修改了一下 单独角色自动战斗判断,以状态单独判断
elsif $game_temp.battle_auto####添加对自动战斗的支持判定####
改为  
elsif  battler.state?(XX)  XX为自己想要自动战斗的状态即可
跟F5无关系了,个人认为这样比较好吧
FTM正式版已经发布,点击图片开启传送门
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
47
在线时间
976 小时
注册时间
2011-4-30
帖子
860
4
 楼主| 发表于 2012-11-30 13:00:51 | 只看该作者
wingzeroplus 发表于 2012-11-30 12:36
修改了一下 单独角色自动战斗判断,以状态单独判断
elsif $game_temp.battle_auto####添加对自动战斗的支持 ...

本来这个地方就是留给玩家自行修改的,因为总有些细节的地方大家的需求都不一样吧?
湿滑落式骑!
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-27 22:11

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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