#--------------------------------------------------------------------------
# ● 评价行动价值 (自动战斗用)
# 自动设置 @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
end
dsu_plus_rewardpost_czw作者: Lenneth 时间: 2011-6-13 04:48
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