Project1

标题: 这个脚本有什么问题 [打印本页]

作者: qqyxzyb    时间: 2013-7-22 20:00
标题: 这个脚本有什么问题
本帖最后由 qqyxzyb 于 2013-8-5 10:42 编辑

    本来是想做一个吸收对方魔法攻击用来抵挡物理伤害的技能,但是不知为何加上这段脚本之后技能就再也打不死对方了……看了半天也没明白问题出在哪……
  1.       # HP 的伤害计算
  2.       # 检测对象是否拥有无光之盾状态
  3.       if self.states.include?(18)
  4.         #判断剩余的能量是否足以抵挡此次攻击
  5.         if self.damage <= self.energy * 2
  6.         self.hp -= self.damage / 2
  7.         self.energy -= self.damage / 2
  8.         #不足的情况,只抵挡剩余能量的伤害,同时能量值清零
  9.         else self.damage -= self.energy
  10.         self.hp -= self.damage
  11.         self.energy = 0
  12.         end
  13.       else self.hp -= self.damage
  14.       end
复制代码
这一段是应用通常攻击效果时插在hp的伤害计算那一部分的,18号状态是用那个技能给自己附加的状态
  1.       # HP 的伤害减法运算
  2.       # 检测对象是否拥有无光之盾状态
  3.       if self.states.include?(18)
  4.         #判断对手使用的是否是魔法攻击
  5.         if skill.atk_f == 0
  6.           if self.damage > self.level * 100      #无光之盾的能量上限
  7.             self.damage -= self.level * 100
  8.             last_hp = self.hp
  9.             self.hp -= self.damage
  10.             effective |= self.hp != last_hp
  11.           elsif self.damage + self.energy > self.level * 100
  12.             self.energy = self.level * 100
  13.           else self.energy += self.damage
  14.           end
  15.         #判断剩余的能量是否足以抵挡此次攻击
  16.         elsif self.damage <= self.energy * 2
  17.           last_hp = self.hp
  18.           self.hp -= self.damage / 2
  19.           effective |= self.hp != last_hp
  20.           self.energy -= self.damage / 2
  21.         #不足的情况,只抵挡剩余能量的伤害,同时能量值清零
  22.         else self.damage -= self.energy
  23.           last_hp = self.hp
  24.           self.hp -= self.damage
  25.           effective |= self.hp != last_hp
  26.           self.energy = 0
  27.         end
  28.         end
  29.       last_hp = self.hp
  30.       self.hp -= self.damage
  31.       effective |= self.hp != last_hp
  32.       end
复制代码
这一段就是应用特技部分的修改,我试过了,如果将这两段改回原样就可以使用特技正常地打死对方,所以问题肯定在这两段里面,求大神指点0
作者: wwwcctvty    时间: 2013-7-22 20:17
2个13行和22行应该有问题,貌似语法不对吧。
作者: qqyxzyb    时间: 2013-7-25 12:57
人工置顶
作者: qqyxzyb    时间: 2013-7-30 09:41
人工置顶




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