【简易自动战斗】测试版 ver.0.1(RTAB)
前几天看到某人(爆焰)的提问,他启发了我的灵感,于是就诞生了这么一个东西……所谓“简易自动战斗”是指让玩家角色可以直接使用RM自带的自动战斗,类似于敌人的行为模式,而非重写一个复杂的AI设定。
具体设定方式为:数据库某号“职业”对应数据库某号“敌人”的行为模式,例如写成“剑士”,就将剑士职业的自动战斗设置关联为第26号敌人的行为模式,
未设置对应关系的职业如“剑士”等,默认对应1号敌人的行为,具体行为模式请自行设置。
当前版本仅提供“全体自动战斗”以及开关功能(F5),单独角色的自动战斗暂不提供,
其实很容易修改,有兴趣的玩家可以自行研究或66rpg论坛PM我。
需要RTAB战斗系统的支持,贴到后面就能用,RTAB017整合版测试也无问题……
欢迎有兴趣的玩家参与测试并提出反馈意见……
(附件内不包括下面的脚本,请自行复制粘贴,我只是主站搜不到017的版本才上传一下)
RUBY 代码
#=============================================================================
#简易自动战斗测试版 ver.0.1(RTAB) 2012/11/26
#by 羞射了
#---------------------------------------------------------------------------
#所谓“简易自动战斗”是指让玩家角色可以直接使用RM自带的自动战斗,类似于敌人的
#行为模式,而非重写一个复杂的AI设定。
#---------------------------------------------------------------------------
#具体设定方式为:数据库某号“职业”对应数据库某号“敌人”的行为模式,
#例如写成“剑士”,就将剑士职业的自动战斗设置关联为第26号敌人的行为模式,
#未设置对应关系的职业如“剑士”等,默认对应1号敌人的行为,
#具体行为模式请自行设置。
#---------------------------------------------------------------------------
#当前版本仅提供“全体自动战斗”以及开关功能(F5),单独角色的自动战斗暂不提供,
#其实很容易修改,有兴趣的玩家可以自行研究或66rpg论坛PM我。
#=============================================================================
# ■ RPG::Class
#=============================================================================
classRPG::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
return1
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
unlessself.inputable?
return
end
available_actions = []
rating_max = 0
for action inself.actions
n = $game_temp.battle_turn
a = action.condition_turn_a
b = action.condition_turn_b
if(b == 0and n != a)or
(b > 0and(n < 1or n < a or n % b != a % b))
next
end
ifself.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 > 0and$game_switches == false
next
end
if action.kind == 1
unlessself.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_aor$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
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
ifrand(@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
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 == trueand
((@action > 0and@action_battlers.empty?)or(@action == 0and
(@action_battlers.empty? or@action_battlers.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 < @Maxand 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
#===========================================================================
本帖来自P1论坛作者羞射了,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=254441若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。
页:
[1]