查看: 3442|回复: 3

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

[复制链接]
梦石
0
星屑
47
在线时间
976 小时
注册时间
2011-4-30
回帖
846
发表于 2012-11-26 21:50:37 | 显示全部楼层 |阅读模式

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

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

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

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

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

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

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

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

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

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

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

RTAB_sixRice_017b.rar (955.89 KB, 下载次数: 199) (附件内不包括下面的脚本,请自行复制粘贴,我只是主站搜不到017的版本才上传一下)
[pre lang="ruby" line="1"]#=============================================================================
#简易自动战斗测试版 ver.0.1(RTAB) 2012/11/26
#by 羞射了
#---------------------------------------------------------------------------
#所谓“简易自动战斗”是指让玩家角色可以直接使用RM自带的自动战斗,类似于敌人的
#行为模式,而非重写一个复杂的AI设定。
#---------------------------------------------------------------------------
#具体设定方式为:数据库某号“职业”对应数据库某号“敌人”的行为模式,
#例如写成“剑士[26]”,就将剑士职业的自动战斗设置关联为第26号敌人的行为模式,
#未设置对应关系的职业如“剑士”等,默认对应1号敌人的行为,
#具体行为模式请自行设置。
#---------------------------------------------------------------------------
#当前版本仅提供“全体自动战斗”以及开关功能(F5),单独角色的自动战斗暂不提供,
#其实很容易修改,有兴趣的玩家可以自行研究或66rpg论坛PM我。
#=============================================================================
# ■ RPG::Class
#=============================================================================
class RPG::Class
  def name
    return @name.gsub(/\[.*\]/) {""}
  end
  #--------------------------------------------------------------------------
  def original_name
    return @name
  end
  #--------------------------------------------------------------------------
  def auto_mode
    if @name =~ /\[[ ]*(\d+)\]/i
      return $1.to_i
    else
      return 1
    end
  end
end
#=============================================================================
class Game_Temp
  attr_accessor :battle_auto
  alias initialize_orig initialize
  def initialize
    initialize_orig
    @battle_auto = false
  end
end
#=============================================================================
class Game_Actor
  #--------------------------------------------------------------------------
  def actions
    return $data_enemies[$data_classes[@class_id].auto_mode].actions
  end
  #--------------------------------------------------------------------------
  def make_action
    self.current_action.clear
    unless self.inputable?
      return
    end
    available_actions = []
    rating_max = 0
    for action in self.actions
      n = $game_temp.battle_turn
      a = action.condition_turn_a
      b = action.condition_turn_b
      if (b == 0 and n != a) or
         (b > 0 and (n < 1 or n < a or n % b != a % b))
        next
      end
      if self.hp * 100.0 / self.maxhp > action.condition_hp
        next
      end
      if $game_party.max_level < action.condition_level
        next
      end
      switch_id = action.condition_switch_id
      if switch_id > 0 and $game_switches[switch_id] == false
        next
      end
      if action.kind == 1
        unless self.skill_can_use?(action.skill_id)
          next
        end
      end
      available_actions.push(action)
      if action.rating > rating_max
        rating_max = action.rating
      end
    end
    ratings_total = 0
    for action in available_actions
      if action.rating > rating_max - 3
        ratings_total += action.rating - (rating_max - 3)
      end
    end
    if ratings_total > 0
      value = rand(ratings_total)
      for action in available_actions
        if action.rating > rating_max - 3
          if value < action.rating - (rating_max - 3)
            self.current_action.kind = action.kind
            self.current_action.basic = action.basic
            self.current_action.skill_id = action.skill_id
            self.current_action.decide_random_target_for_enemy
            return
          else
            value -= action.rating - (rating_max - 3)
          end
        end
      end
    end
  end
#---------------------------------------------------------------------------
end
#===========================================================================
class Scene_Battle
#---------------------------------------------------------------------------
  alias atb_setup_orig atb_setup
  def atb_setup
    atb_setup_orig
    $game_temp.battle_auto = false
  end
#---------------------------------------------------------------------------
  def auto_action(battler)
    unless battler.current_action.forcing
      battler.make_action
    end
    action_start(battler)
  end
#---------------------------------------------------------------------------
  alias update_orig update
  def update
    update_orig
    if Input.trigger?(Input::F5)
      if $game_temp.battle_auto == true
        $game_temp.battle_auto = false
      else
        $game_temp.battle_auto = true
      end
    end
  end
#---------------------------------------------------------------------------
  def update_phase3
    if victory? and @command_a or $game_temp.battle_auto
      command_delete
    #  @command.push(@active_actor)
      return
    end
    # エネミーアローが有効の場合
    if @enemy_arrow != nil
      update_phase3_enemy_select
    # アクターアローが有効の場合
    elsif @actor_arrow != nil
      update_phase3_actor_select
    # スキルウィンドウが有効の場合
    elsif @skill_window != nil
      update_phase3_skill_select
    # アイテムウィンドウが有効の場合
    elsif @item_window != nil
      update_phase3_item_select
    # アクターコマンドウィンドウが有効の場合
    elsif @actor_command_window.active
      update_phase3_basic_command
    end
  end
#---------------------------------------------------------------------------
  def update_phase0
    if $game_temp.battle_turn == 0
      $game_temp.battle_turn = 1
    end
    # ATゲージ増加処理
    cnt = 0
    for battler in $game_party.actors + $game_troop.enemies
      active?(battler)
      if battler.rtp == 0
        if battler.at >= @max
          if battler.is_a?(Game_Actor)
            if battler.inputable?
              unless @action_battlers.include?(battler) or
                  @command.include?(battler) or @escape == true
                if battler.current_action.forcing
                  fullat_se
                  force_action(battler)
                  action_start(battler)
                elsif $game_temp.battle_auto####添加对自动战斗的支持判定####
                  auto_action(battler)
                else
                  fullat_se
                  @command.push(battler)
                end
              end
            else
              unless @action_battlers.include?(battler) or
                      battler == @command[0]
                battler.current_action.clear
                if @command.include?(battler)
                  @command.delete(battler)
                else
                  if battler.movable?
                    fullat_se
                  end
                end
                action_start(battler)
              end
            end
          else
            unless @action_battlers.include?(battler)
              if battler.current_action.forcing
                force_action(battler)
                action_start(battler)
              else
                if @enemy_speed != 0
                  if rand(@enemy_speed) == 0
                    number = cnt - $game_party.actors.size
                    enemy_action(number)
                  end
                else
                  number = cnt - $game_party.actors.size
                  enemy_action(number)
                end
              end
            end
          end
        else
          battler.at += battler.agi
          if battler.guarding?
            battler.at += battler.agi
          end
          if battler.movable?
            battler.atp = 100 * battler.at / @max
          end
        end
      else
        if battler.rt >= battler.rtp
          speller = synthe?(battler)
          if speller != nil
            battler = speller[0]
          end
          unless @action_battlers.include?(battler)
            if battler.is_a?(Game_Actor)
              fullat_se
            end
            battler.rt = battler.rtp
            action_start(battler)
          end
        else
          battler.rt += battler.agi
          speller = synthe?(battler)
          if speller != nil
            for spell in speller
              if spell != battler
                spell.rt += battler.agi
              end
            end
          end
        end
      end
      cnt += 1
    end
    # ATゲージをリフレッシュ
    @status_window.at_refresh
    # 逃走処理
    if @escape == true and
        ((@action > 0 and @action_battlers.empty?) or (@action == 0 and
        (@action_battlers.empty? or @action_battlers[0].phase == 1)))
      temp = false
      for battler in $game_party.actors
        if battler.inputable?
          temp = true
        end
      end
      if temp == true
        for battler in $game_party.actors
          if battler.at < @Max and battler.inputable?
            temp = false
            break
          end
        end
        if temp == true
          @escape = false
          for battler in $game_party.actors
            battler.at %= @max
          end
          $game_temp.battle_main_phase = false
          update_phase2_escape
        end
      end
    end
  end
#---------------------------------------------------------------------------
end
#===========================================================================[/pre]   
湿滑落式骑!
梦石
0
星屑
244
在线时间
584 小时
注册时间
2012-9-7
回帖
592
发表于 2012-11-30 11:51:30 | 显示全部楼层
效率很高的,上次看了你的回帖,过几天就出了
话说我上次给爆焰发的AI是非RTAB的。
RTAB的AI我尝试过,但是好像不是那么好写,你居然弄这个出来了,于是进来学习一下
FTM正式版已经发布,点击图片开启传送门
回复

使用道具 举报

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

使用道具 举报

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

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

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部