设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2530|回复: 7

[已经过期] 请问如何判断角色进入异常状态

[复制链接]

Lv1.梦旅人

梦石
0
星屑
105
在线时间
9 小时
注册时间
2020-3-2
帖子
7
发表于 2020-4-2 22:21:11 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
请问如何判断角色进入异常状态(中毒,黑暗之类)
我想在这两行加入判断异常状态的语句
elsif (actor.hp.to_f/actor.mhp) < 0.25 && actor.hp != 0 #血量比<0.25并且没死
      draw_face(actor.face_name, actor.face_index+2, x, y, enabled)
我改的是
elsif actor.state?(2)||(actor.hp.to_f/actor.mhp) < 0.25 && actor.hp != 0 #血量比<0.25并且没死
      draw_face(actor.face_name, actor.face_index+2, x, y, enabled)
但是没反应,是怎么回事啊
RUBY 代码复制
  1. def draw_actor_face(actor, x, y, enabled = true)
  2.     #重点部分
  3.     #上面的优先于下面的条件
  4.     if if $vic && actor.hp != 0 #胜利时
  5.       draw_face(actor.face_name, actor.face_index+7, x, y, enabled)
  6.     elsif $ating && actor.id == $atid #除了正在防御外,行动者的头像更改
  7.       draw_face(actor.face_name, actor.face_index+1, x, y, enabled)
  8.     elsif $tffing && actor.id == $tffid #如果受到回复,被回复者的头像更改
  9.       draw_face(actor.face_name, actor.face_index+4, x, y, enabled)
  10.     elsif $hpd && actor.id == $hpdid # 如果受到伤害,受到伤害者头像更变
  11.       draw_face(actor.face_name, actor.face_index+5, x, y, enabled)
  12.     elsif $ging && actor.id == $gid #正在防御者的头像更改
  13.       draw_face(actor.face_name, actor.face_index+6, x, y, enabled)
  14.     else
  15.     if (actor.hp.to_f/actor.mhp) >= 0.25 #血量比>=0.25
  16.       draw_face(actor.face_name, actor.face_index, x, y, enabled)
  17.     elsif (actor.hp.to_f/actor.mhp) < 0.25 && actor.hp != 0 #血量比<0.25并且没死
  18.       draw_face(actor.face_name, actor.face_index+2, x, y, enabled)
  19.     elsif actor.hp == 0#死了
  20.       draw_face(actor.face_name, actor.face_index+3, x, y, enabled)
  21.     end
  22.     end
  23.   end
  24. end
头像被屏蔽

Lv4.逐梦者 (禁止发言)

梦石
0
星屑
5701
在线时间
922 小时
注册时间
2013-8-29
帖子
1468
发表于 2020-4-2 23:42:04 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 1 反对 0

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
105
在线时间
9 小时
注册时间
2020-3-2
帖子
7
 楼主| 发表于 2020-4-3 06:59:21 | 显示全部楼层
chanszeman1018 发表于 2020-4-2 23:42
elsif (actor.hp.to_f/actor.mhp) < 0.25 && actor.hp != 0 && actor.state?(2) #血量比

但是我想要的效果是
(如果(血量比<0.25并且没死)或者(有2号狀态但是没死)时
显示3号图片)
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv4.逐梦者 (禁止发言)

梦石
0
星屑
5701
在线时间
922 小时
注册时间
2013-8-29
帖子
1468
发表于 2020-4-3 08:05:04 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
105
在线时间
9 小时
注册时间
2020-3-2
帖子
7
 楼主| 发表于 2020-4-3 09:38:16 | 显示全部楼层
chanszeman1018 发表于 2020-4-3 08:05
那么加段
elsif actor.state?(2) && actor.hp != 0 #有2号狀态但是没死
      draw_face(actor.face_name ...

我感觉可行但是仍然没有反应。。。
确认一下,中毒是2号状态吧?
如果我想判断其他状态是不是还要一行一行地判断啊
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv4.逐梦者 (禁止发言)

梦石
0
星屑
5701
在线时间
922 小时
注册时间
2013-8-29
帖子
1468
发表于 2020-4-3 10:01:33 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
105
在线时间
9 小时
注册时间
2020-3-2
帖子
7
 楼主| 发表于 2020-4-3 10:03:22 | 显示全部楼层
chanszeman1018 发表于 2020-4-3 10:01
我想我不懂得解答你的问题
还是等楼下解答吧~抱歉~

没关系,谢谢你回答我的问题
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
105
在线时间
9 小时
注册时间
2020-3-2
帖子
7
 楼主| 发表于 2020-4-3 14:36:26 | 显示全部楼层
请问我插入以下两段代码后报错怎么办
报错提示是“发生systemstackerror
stack level too deep”

  1. class Game_BattlerBase
  2.   def state?(state_id)
  3.     @states.include?(state_id)
  4.   if @states.include?(2)
  5.     if self.is_a?(Game_Actor)
  6.       $sta = true
  7.       $staid = self.id
  8.     end
  9.   end
  10.   end
  11. end
复制代码
  1.     elsif (actor.hp.to_f/actor.mhp) < 0.25 && actor.hp != 0 #血量比<0.25并且没死
  2.       draw_face(actor.face_name, actor.face_index+2, x, y, enabled)
  3.     elsif $sta && actor.id == $staid && actor.hp != 0 #有2号狀态但是没死
  4.       draw_face(actor.face_name, actor.face_index+2, x, y, enabled)
复制代码
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-3-29 10:36

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表