查看: 95|回复: 0

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

[复制链接]
  • TA的每日心情
    开心
    前天 09:55
  • 签到天数: 37 天

    连续签到: 3 天

    [LV.5]常住居民I

    2028

    主题

    32

    回帖

    7260

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    0
    卡币
    5184
    OK点
    16
    积分
    7260
    发表于 同元一千年八月三日(秋) | 显示全部楼层 |阅读模式
    前几天看到某人(爆焰)的提问,他启发了我的灵感,于是就诞生了这么一个东西……

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

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

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

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

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

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

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

    (附件内不包括下面的脚本,请自行复制粘贴,我只是主站搜不到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. classRPG::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.       return1
    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.     unlessself.inputable?
    54.       return
    55.     end
    56.     available_actions = []
    57.     rating_max = 0
    58.     for action inself.actions
    59.       n = $game_temp.battle_turn
    60.       a = action.condition_turn_a
    61.       b = action.condition_turn_b
    62.       if(b == 0and n != a)or
    63.          (b > 0and(n < 1or n < a or n % b != a % b))
    64.         next
    65.       end
    66.       ifself.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 > 0and$game_switches[switch_id] == false
    74.         next
    75.       end
    76.       if action.kind == 1
    77.         unlessself.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_aor$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.                   ifrand(@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 == trueand
    260.         ((@action > 0and@action_battlers.empty?)or(@action == 0and
    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. #===========================================================================
    复制代码
       
                 本帖来自P1论坛作者羞射了,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=254441  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 论坛版权

    使用道具 举报

    ahome_bigavatar:guest
    ahome_bigavatar:welcomelogin
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2024-5-12 21:59 , Processed in 0.048981 second(s), 44 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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