#=============================================================================
#简易自动战斗测试版 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 < [url=home.php?mod=space&uid=25307]@Max[/url] 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
#===========================================================================