class Game_Party
#--------------------------------------------------------------------------
# ● 对像角色的随机确定
# hp0 : 限制为 HP 0 的角色
#--------------------------------------------------------------------------
def random_target_actor(hp0 = false)
# 初始化轮流
roulette = []
# 循环
for actor in @actors
# 符合条件的场合
if (not hp0 and actor.exist?) or (hp0 and actor.hp0?)
=begin
# 获取角色职业的位置 [位置]
position = $data_classes[actor.class_id].position
#position 位置(0:前卫,1:中卫,2:后卫)。
#即是前卫的话 n = 4、中卫的话 n = 3、后卫的话 n = 2
n = 4 - position
=end
#角色在队伍第一位就被攻击率最高,随后依次降低,如果不是这种规律换算法
n = self.actors.size- self.actors.index(actor)
# 添加角色的轮流 n 回
n.times do
roulette.push(actor)
end
end
end
# 轮流大小为 0 的情况
if roulette.size == 0
return nil
end
# 转轮盘赌,决定角色
return roulette[rand(roulette.size)]
end
end[/pre]
用条件语句或者判断语句判断 self.actors.index(actor) 的值
self.actors.index(actor)==0的时候是队伍中一号队员 1的时候是队伍中二号队员
case self.actors.index(actor)
when 0
n=4
else #其他角色
n=2
end
# 获取角色职业的位置 [位置]
# position = $data_classes[actor.class_id].position
# 前卫的话 n = 4、中卫的话 n = 3、后卫的话 n = 2
# n = 4 - position
#角色在队伍第一位就被攻击率最高,随后依次降低,如果不是这种规律换算法
n = self.actors.size- self.actors.index(actor)
case self.actors.index(actor)
when 0
n=4
else #其他角色
n=2
end
# 添加角色的轮流 n 回
n.times do
roulette.push(actor)
end
end
end