赞 | 0 |
VIP | 1 |
好人卡 | 0 |
积分 | 1 |
经验 | 6986 |
最后登录 | 2013-3-15 |
在线时间 | 55 小时 |
Lv1.梦旅人 v
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 55 小时
- 注册时间
- 2007-12-19
- 帖子
- 99
|
RMVX的自动战斗是有AI的,不是XP那种随机行动
大概就是评估每个行动(普通攻击、每种特技对每个可能的目标等等)的价值,然后取价值最大的作为最终行动。
详见:
Game_Actor 670行
#--------------------------------------------------------------------------
# ● 戦闘行動の作成 (自動戦闘用)
#--------------------------------------------------------------------------
def make_action
@action.clear
return unless movable?
action_list = []
action = Game_BattleAction.new(self)
action.set_attack
action.evaluate
action_list.push(action)
for skill in skills
action = Game_BattleAction.new(self)
action.set_skill(skill.id)
action.evaluate
action_list.push(action)
end
max_value = 0
for action in action_list
if action.value > max_value
@action = action
max_value = action.value
end
end
end
Game_BattleAction 288行
#--------------------------------------------------------------------------
# ● 行動の価値評価 (自動戦闘用)
# @value および @target_index を自動的に設定する。
#--------------------------------------------------------------------------
def evaluate
if attack?
evaluate_attack
elsif skill?
evaluate_skill
else
@value = 0
end
if @value > 0
@value + rand(nil)
end
end
#--------------------------------------------------------------------------
# ● 通常攻撃の評価
#--------------------------------------------------------------------------
def evaluate_attack
@value = 0
for target in opponents_unit.existing_members
value = evaluate_attack_with_target(target)
if value > @value
@value = value
@target_index = target.index
end
end
end
#--------------------------------------------------------------------------
# ● 通常攻撃の評価 (ターゲット指定)
# target : 対象バトラー
#--------------------------------------------------------------------------
def evaluate_attack_with_target(target)
target.clear_action_results
target.make_attack_damage_value(battler)
return target.hp_damage.to_f / [target.hp, 1].max
end
#--------------------------------------------------------------------------
# ● スキルの評価
#--------------------------------------------------------------------------
def evaluate_skill
@value = 0
unless battler.skill_can_use?(skill)
return
end
if skill.for_opponent?
targets = opponents_unit.existing_members
elsif skill.for_user?
targets = [battler]
elsif skill.for_dead_friend?
targets = friends_unit.dead_members
else
targets = friends_unit.existing_members
end
for target in targets
value = evaluate_skill_with_target(target)
if skill.for_all?
@value += value
elsif value > @value
@value = value
@target_index = target.index
end
end
end
#--------------------------------------------------------------------------
# ● スキルの評価 (ターゲット指定)
# target : 対象バトラー
#--------------------------------------------------------------------------
def evaluate_skill_with_target(target)
target.clear_action_results
target.make_obj_damage_value(battler, skill)
if skill.for_opponent?
return target.hp_damage.to_f / [target.hp, 1].max
else
recovery = [-target.hp_damage, target.maxhp - target.hp].min
return recovery.to_f / target.maxhp
end
end
没实测过,不过八九不离十了吧{/gg} |
|