Project1

标题: 战斗判断最少血量 但是不会进行刷新重新判断的问题 [打印本页]

作者: jiushiainilip19    时间: 2016-4-18 22:20
标题: 战斗判断最少血量 但是不会进行刷新重新判断的问题
@cinderelmini
RUBY 代码复制
  1. party = $game_party.actors.dup
  2.         min_hp_actor = party.sort!{|a, b| a.hp <=> b.hp}.shift
  3.         p $min_hp_actor.name

这段代码我用在战斗中是这样的
RUBY 代码复制
  1. i
  2. if @active_battler.is_a?(Game_Actor) && @skill.id == 67
  3.    next if @active_battler.dead?
  4.     actor = $game_party.actors.dup
  5.     min_hp_actor = @actor.sort!{|a, b| a.hp <=> b.hp}.shift
  6.     s_tem = @active_battler.dex * 90 / 100 + rand(@active_battler.sp * 30 / 100)
  7.     min_hp_actor.hp += s_tem
  8.     min_hp_actor.damage = -s_tem
  9.     min_hp_actor.damage_pop = true
  10.     min_hp_actor.animation_id=15
  11.   end

技能对象是地方单体  我在战斗中定义新附加效果给我军血量最低的角色恢复3次效果
出现问题:如何判断最低血量那个角色挂了后  在继续重新判断生存中的角色中最低HP的对象

                 除非挂了的那个重新复活在继续重新判断

以往都是用 if actor.exist? 来判断存在的角色 但是如果用在上面 没效果。。!
    min_hp_actor.hp += s_tem   if min_hp_actor.hp>0
    min_hp_actor.damage = -s_tem   if min_hp_actor.hp>0
这种办法一旦最低角色挂了 就会找不到对象了!不会刷新重新来判断!

作者: cinderelmini    时间: 2016-4-18 22:27
本帖最后由 cinderelmini 于 2016-4-18 22:49 编辑
  1.   if @active_battler.is_a?(Game_Actor) && @skill.id == 67
  2.     temp_party = $game_party.actors.sort{|a, b| a.hp <=> b.hp}
  3.     min_hp_actor = temp_party.shift
  4.     while !min_hp_actor.exist?
  5.       min_hp_actor = temp_party.shift
  6.     end
  7.     #p $min_hp_actor.name   
  8.     s_tem = @active_battler.dex * 90 / 100 + rand(@active_battler.sp * 30 / 100)
  9.     min_hp_actor.hp += s_tem
  10.     min_hp_actor.damage = -s_tem
  11.     min_hp_actor.damage_pop = true
  12.     min_hp_actor.animation_id=15
  13. end
复制代码
这样试试~
作者: jiushiainilip19    时间: 2016-4-18 22:40
本帖最后由 jiushiainilip19 于 2016-4-18 22:55 编辑
cinderelmini 发表于 2016-4-18 22:27
这样试试看~也许会弹,弹了再说吧。。
顺便,乃代码框里第四行和第五行的actor不是同一个→_→ ...

  1. if @active_battler.is_a?(Game_Actor) && @skill.id == 67
  2.     temp_party = $game_party.actors.sort{|a, b| a.hp <=> b.hp}
  3.     min_hp_actor = temp_party.shift
  4.     min_hp_actor = temp_party.shift until min_hp_actor.exist?
  5.     s_tem = @active_battler.dex * 90 / 100 + rand(@active_battler.sp * 30 / 100)
  6.     min_hp_actor.hp += s_tem
  7.     min_hp_actor.damage = -s_tem
  8.     min_hp_actor.damage_pop = true
  9.     min_hp_actor.animation_id=15
  10.   end
复制代码
重复了一个 min_hp_actor = temp_party.shift 居然也变得可以了!不过我还是用你上面难得好些




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1