#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
# ============================================================================
# 伤害效果美化 v1.0 by SailCat
# ============================================================================
# 脚本使用说明:
# 1.使用时需要将Damage.png复制到你的游戏的Graphics/Pictures目录下
# 2.Damage.png文件的格式:
# 大小为180 x 96
# (0, 0) - (179, 31)为伤害值的数字表,其中每个数字宽18,高32
# (0, 32) - (179, 63)为回复值(伤害负值)的数字表,其中每个数字宽18,高32
# (0, 64) - (89, 95)为会心一击标记的图画,长宽为90 x 32
# (90, 64) - (179, 95)为未命中标记的图画,长宽为90 x 32
# ============================================================================
module RPG
class Sprite < ::Sprite
#--------------------------------------------------------------------------
# ● 伤害值描画
#--------------------------------------------------------------------------
def damage(value, critical, sp_damage = false)
# 释放伤害
dispose_damage
# 如果伤害值是数值
if value.is_a?(Numeric)
# 绝对值转为字符串
damage_string = value.abs.to_s
else
# 转为字符串
damage_string = value.to_s
end
# 初始化位图
bitmap = Bitmap.new(162, 64)
bitmap.font.name = "Arial Black"
bitmap.font.size = 32
# 伤害值是数值的情况下
if value.is_a?(Numeric)
# 分割伤害值字符串
damage_array = damage_string.scan(/./)
damage_x = 81 - damage_string.size * 9
# 伤害值为负的情况下
if value < 0
# 调用回复数字表
rect_y = 32
else
# 调用伤害数字表
rect_y = 0
end
# 循环伤害值字符串
for char in damage_array
number = char.to_i
# 显示伤害数字
if sp_damage
bitmap.blt(damage_x, 32, RPG::Cache.picture("Damagesp"),
Rect.new(number * 18, rect_y, 18, 32))
damage_x += 18
else
bitmap.blt(damage_x, 32, RPG::Cache.picture("Damage"),
Rect.new(number * 18, rect_y, 18, 32))
damage_x += 18
end
end
# 伤害值不是数值的情况
else
# Miss 的情况下
if value == "Miss"
# 显示未击中图画
bitmap.blt(36, 28, RPG::Cache.picture("Damage"), Rect.new(90, 64, 90, 32))
end
# 免疫的情况下
if value == "Nothing"
# 显示未击中图画
bitmap.blt(36, 28, RPG::Cache.picture("Damage"), Rect.new(0, 96, 90, 32))
end
# 反射的情况下
if value == "Mirro return"
# 显示未击中图画
bitmap.blt(36, 28, RPG::Cache.picture("Damage"), Rect.new(90, 96, 90, 32))
end
end
# 会心一击标志打开的情况
if critical
# 显示会心一击图画
bitmap.blt(36, 0, RPG::Cache.picture("Damage"), Rect.new(0, 64, 90, 32))
end
# 伤害值定位
@_damage_sprite = ::Sprite.new(self.viewport)
@_damage_sprite.bitmap = bitmap
@_damage_sprite.ox = 81
@_damage_sprite.oy = 20
@_damage_sprite.x = self.x
@_damage_sprite.y = self.y - self.oy / 2
@_damage_sprite.z = 3000
@_damage_duration = 40
end
end
end
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |