赞 | 2 |
VIP | 0 |
好人卡 | 0 |
积分 | 10 |
经验 | 4244 |
最后登录 | 2025-1-1 |
在线时间 | 237 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 957
- 在线时间
- 237 小时
- 注册时间
- 2011-6-9
- 帖子
- 42
|
如题
在设置了自动战斗,我方角色的攻击选择是我想通过敏捷去调,敏捷越高越容易出特技(我设特技不用MP)
#--------------------------------------------------------------------------
# ● 评价行动价值 (自动战斗用)
# 自动设置 @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
|
|