查看: 998|回复: 4

if 伤害大于0 脚本怎么写?

  [复制链接]
梦石
0
星屑
50
在线时间
28 小时
注册时间
2008-12-11
回帖
86
发表于 2009-2-19 18:50:20 | 显示全部楼层 |阅读模式

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

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

×
要在Scene_Battle 4的 # 显示伤害 的地方加一个判断:if 目标的伤害大于0,但是写成 if target.damage > 0 (彩色部分)战斗时就出错了,应该怎么写?

    for target in @target_battlers
      
      if target.state?(63)
        if @active_battler.current_action.basic == 0 and @active_battler.current_action.kind == 0 and target.damage != "Miss" and target.damage > 0
          target.animation_id = 98
          target.damage = "attack reflected"
          target.damage_pop = true
          @active_battler.hp -= @active_battler.damage.to_i
          @active_battler.damage_pop = true
        end
      end

版务信息:本贴由楼主自主结贴~
梦石
0
星屑
60
在线时间
41 小时
注册时间
2008-3-5
回帖
1992
发表于 2009-2-19 20:11:22 | 显示全部楼层
target.damage == "Miss"时,你这样判断,就会字符串类型不匹配
你它囧一字母君谁记得……
当时那把剑离我的喉咙只有0.01工分。可是一柱香之后,这个女主人会深深的爱上我,虽然本人平生说了无数的谎话,可是这句最有效:“你应该这么做,我也应该死。
曾经有一取ID的机会放在我面前,我没有珍惜,等我失去的时候我才后悔莫及,人世间最痛苦的事莫过于此。你的剑在我的咽喉上割下去吧!不用再犹豫了!如果上天能够给我一个再来一次的机会,我绝对会取个汉字君。如果非要给这ID加点修饰的话,我希望是……红色加粗……

回复

使用道具 举报

梦石
0
星屑
50
在线时间
28 小时
注册时间
2008-12-11
回帖
86
 楼主| 发表于 2009-2-19 22:34:48 | 显示全部楼层
那么后面加个.to_i可以了吧?

if @active_battler.current_action.basic == 0 and @active_battler.current_action.kind == 0 and target.damage != "Miss" and target.damage.to_i > 0
回复

使用道具 举报

粉蜘蛛秀秀

梦石
0
星屑
76
在线时间
39 小时
注册时间
2007-6-4
回帖
346

贵宾第1届Title华丽大赛新人奖

发表于 2009-2-19 22:40:55 | 显示全部楼层
if target.damage.is_a?(Numeric)
  if target.damage > 0
    ......
  end
end
系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~
http://rpg.blue/upload_program/files/hide_xiu_96911465.png
回复

使用道具 举报

梦石
0
星屑
50
在线时间
28 小时
注册时间
2008-12-11
回帖
86
 楼主| 发表于 2009-2-19 23:05:25 | 显示全部楼层
用 target.damage.to_i 可以判断吗?
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部