#==============================================================================
# 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
#==============================================================================
# ============================================================================
# 伤害效果美化 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)
# 释放伤害
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
# 显示伤害数字
bitmap.blt(damage_x, 32, RPG::Cache.picture("Damage"),
Rect.new(number * 18, rect_y, 18, 32))
# 后移一位
damage_x += 18
end
# 伤害值不是数值的情况
else
# 如果伤害值不是 Miss
unless value == "Miss"
# 系统默认描画字符串
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, 27, 162, 36, damage_string, 1)
bitmap.draw_text(+1, 27, 162, 36, damage_string, 1)
bitmap.draw_text(-1, 29, 162, 36, damage_string, 1)
bitmap.draw_text(+1, 29, 162, 36, damage_string, 1)
bitmap.font.color.set(255, 255, 255)
bitmap.draw_text(0, 28, 162, 36, damage_string, 1)
# Miss 的情况下
else
# 显示未击中图画
bitmap.blt(36, 28, RPG::Cache.picture("Damage"), Rect.new(90, 64, 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
if self.is_a?(Sprite_Battler)
if self.battler.is_a?(Game_Actor)
@_damage_sprite.y -= 70 #此处您随意~
end
end
@_damage_sprite.z = 3000
@_damage_duration = 40
end
end
end
#==============================================================================
# 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
#==============================================================================