查看: 2322|回复: 4

[已经过期] 伤害美化和回蓝状态冲突如图

[复制链接]
梦石
0
星屑
1442
在线时间
171 小时
注册时间
2019-10-4
回帖
162
发表于 2023-1-7 22:45:31 | 显示全部楼层 |阅读模式

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

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

×
[pre lang="ruby"]# ğÁ›ė֜ΦʼѢ©ӊЭѭӬذª ver0.90

class Scene_Battle
  alias :main_original :main
  def atb_setup
    for path in ["num_n", "num_c", "num_rh"]
      for i in 0..9
        RPG::Cache.numeric(path + i.to_s)
      end
    end
    for path in ["critical", "miss"]
      RPG::Cache.numeric(path)
    end
    main
  end
end

module RPG
  class Sprite < ::Sprite
    def damage(value, critical)
      dispose_damage
      if value.is_a?(Numeric)
        damage_string = value.abs.to_s
      else
        damage_string = value.to_s
      end
      if value.is_a?(Numeric)
        damage_string = value.abs.to_s
      else
        damage_string = value.to_s
      end
      bitmap = Bitmap.new(160, 48)
      if value.is_a?(Numeric)
        if value >= 0
          if critical
            bitmap.draw_numlic(0, 12, 160, 36, value, 1, 1)
          else
            bitmap.draw_numlic(0, 12, 160, 36, value, 0, 1)
          end
        else
          bitmap.draw_numlic(0, 12, 160, 36, value, 2, 1)
        end
      else
        bitmap.draw_numlic(0, 12, 160, 36, value, 3, 1)
      end
      @_damage_sprite = ::Sprite.new
      @_damage_sprite.bitmap = bitmap
      @_damage_sprite.ox = 80 + self.viewport.ox
      @_damage_sprite.oy = 20 + self.viewport.oy
      @_damage_sprite.x = self.x + self.viewport.rect.x
      @_damage_sprite.y = self.y - self.oy / 2 + self.viewport.rect.y
      @_damage_sprite.z = 3000
      @_damage_duration = 40
    end
  end
end

class Bitmap
  def draw_numlic(x, y, width, height, value, element, align = 0)
    if value.is_a?(Numeric)
      value = value.abs
      if value > 0
        log = Math.log10(value).to_i
      else
        log = 0
      end
      filename = "num_"
      case element
      when 0
        filename += "n"
      when 1
        file = RPG::Cache.numeric("critical")
        blt(x + width / 2 - file.rect.width / 2, y - 12, file, file.rect)
        filename += "c"
      when 2
        filename += "rh"
      end
      if align == 1
        x += width / 2 - 13 - 9 * (log)
      end
      while log >= 0
        case value / (10 ** log)
        when 0
          file = RPG::Cache.numeric(filename + "0")
        when 1
          file = RPG::Cache.numeric(filename + "1")
        when 2
          file = RPG::Cache.numeric(filename + "2")
        when 3
          file = RPG::Cache.numeric(filename + "3")
        when 4
          file = RPG::Cache.numeric(filename + "4")
        when 5
          file = RPG::Cache.numeric(filename + "5")
        when 6
          file = RPG::Cache.numeric(filename + "6")
        when 7
          file = RPG::Cache.numeric(filename + "7")
        when 8
          file = RPG::Cache.numeric(filename + "8")
        when 9
          file = RPG::Cache.numeric(filename + "9")
        end
        blt(x, y, file, file.rect)
        x += 18
        value %= 10 ** log
        log -= 1
      end
    else
      case value
      when ""
        return
      when "Miss"
        file = RPG::Cache.numeric("miss")
      else
        file = RPG::Cache.numeric(value)
      end
      if align == 1
        x += width / 2 - file.rect.width / 2
      end
      blt(x, y, file, file.rect)
    end
  end
end

module RPG
  module Cache
    def self.numeric(filename)
      self.load_bitmap("Graphics/String/", filename)
    end
  end
[/pre]

[pre lang="ruby"] elsif self.state?(34)

      # 设置伤害

      #self.damage = -self.maxhp / 30

      recover_sp = self.maxsp / 20

      # HP 的伤害减法运算

      #self.hp -= self.damage

      self.sp += recover_sp[/pre] QQ截图20230107223726.png
梦石
2
星屑
13779
在线时间
2319 小时
注册时间
2011-6-4
回帖
586
发表于 2023-1-8 16:20:51 | 显示全部楼层
本帖最后由 真·可乐 于 2023-1-8 16:23 编辑

粗暴的方法:似乎有潜在的问题,已移除回答。

点评

其实是怎么说呢,就是缺少了SP回复的图片显示。但是我不会写,我希望就是能跳过不显示SP也好,只希望持续回复蓝量而不报错  发表于 2023-1-8 16:39
BUG反馈请加QQ 529283039
水友群 917854767

回复

使用道具 举报

梦石
0
星屑
8003
在线时间
1184 小时
注册时间
2007-7-29
回帖
2014
发表于 2023-1-8 17:21:16 | 显示全部楼层
在21行后加入:
  1. return if value == nil
复制代码
强行不显示nil的伤害。

PS:无测试,仅理论可行。

点评

还是放弃回蓝效果了 出现了另外一个BUG 不使用持续回蓝的 情况下还是不会报错出现nil的。 不过还是表示感谢  发表于 2023-1-13 17:41
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部