#===============================================================================
# Damage Images
# Author game_guy
# Version 1.4
#-------------------------------------------------------------------------------
# Intro:
# Want to spice up the way your damage looks? Tired of plain old text? Well
# now you can use images as a replacement for the text! Have different images
# for healing, dealing damage, miss and critical!
#
# Features:
# Image for Normal Damage
# Image for Healing Damage
# Image for Miss
# Image for Critical
# Basically Plug & Play
#
# Instructions:
# Go down to the config below and set all file names to the appropriate type
# of damage.
# -Setting up Images:
# Creating the images for this to work is quite easy. The easiest ones to
# create are the ones for Miss and Critical. For those two you just need an
# image that says "Miss" and "Critical". The numbers take a little bit more
# effort to setup but its still pretty simple.
#
# You need 10x1 cells. Each cell goes horizontally across with the same width
# and same height. You place numbers 0-9 in each of the cells in numeric order.
# Then import it into pictures folder and you should be done.
# e.g.
# +---------------------------------------+
# ¦ 0 ¦ 1 ¦ 2 ¦ 3 ¦ 4 ¦ 5 ¦ 6 ¦ 7 ¦ 8 ¦ 9 ¦
# +---------------------------------------+
#
# Compatibility:
# Not tested with SDK.
# Won't work for any other damage appearance mods.
#
# Version History:
# v1.0
# -Initial release
# v1.1
# -Added support for Blizz-ABS
# v1.2beta
# -Fixed Damage numbers when Healing for Blizz-ABS
# Possibly unstable. Overwrites method in BlizzABS::Utility class.
# Not sure if it can or will cause any bugs.
# v1.2
# -Removed overwrite of Utility method
# v1.3
# -Added level up image for Blizz-ABS Only
# -Added defend image for Blizz-ABS Only
# v1.4
# -Fixed healing bug...again. ._.
#
# Credits:
# game_guy ~ For creating the script.
# Blizzard ~ LoL's damage appearance gave me the idea.
#===============================================================================
module GG_DamageImages
NORMAL_FILE = "dmg_normal"
HEAL_FILE = "dmg_heal"
MISS_FILE = "dmg_miss"
CRITICAL_FILE = "dmg_critical"
LEVEL_UP_FILE = "dmg_level" # FOR BLIZZ-ABS ONLY!
DEFEND_FILE = "dmg_defend" # FOR BLIZZ-ABS ONLY!
end
module RPG
#==============================================================================
# ** RPG::Sprite
#------------------------------------------------------------------------------
# Processes effects applied to sprites.
#==============================================================================
class Sprite < ::Sprite
# Include Config Module
include GG_DamageImages
#--------------------------------------------------------------------------
# * Damage
#--------------------------------------------------------------------------
def damage(value, critical)
# dispose old damage
dispose_damage
# set heal and miss variables
heal = false
miss = false
# if value is a number
if value.is_a?(Numeric)
# set damage_string to value
damage_string = value.abs.to_s
# set heal to true if value less then zero
heal = value < 0 ? true : false
else
# set damage_string to value
damage_string = value.to_s
# set miss to true
miss = true
end
# if miss
if miss
# load miss
damage = MISS_FILE
elsif heal
# load heal
damage = HEAL_FILE
else
# load normal
damage = NORMAL_FILE
end
if critical
# load critical
crit = RPG::Cache.picture(CRITICAL_FILE)
end
# load image
image = RPG::Cache.picture(damage)
# set cell width
cwidth = image.width / 10
# set cell height
cheight = image.height
# set image height taking variables into accordance
height = critical == true ? image.height + crit.height : image.height
# set width according to amount of damage
width = damage_string.size * cwidth
# set x and y offset
yy = 0
xx = 0
# if critical
if critical
# if damage width is less then critical's image width
if width < crit.width
# set x offset
xx = crit.width / 2 - width / 2
# set new width
width = crit.width
# set y offset
yy = crit.height
end
end
# create bitmap from width and height
bitmap = Bitmap.new(width, height)
# if value is a number
if value.is_a?(Numeric)
# iterate through damage_string
for i in 0...damage_string.size
# grab actual number from damage_string
int = damage_string[i, 1].to_i
# create rectangle according to int
rect = Rect.new(int * cwidth, 0, cwidth, cheight)
# draw number
bitmap.blt(xx + i * cwidth, yy, image, rect)
end
else
# set rectangle
rect = Rect.new(0, 0, image.width, image.height)
# set new bitmap
bitmap = Bitmap.new(image.width, image.height)
# draw miss image
bitmap.blt(0, 0, image, rect)
end
# if critical
if critical
# create rectangle
rect = Rect.new(0, 0, crit.width, crit.height)
# draw critical image
bitmap.blt(0, 0, crit, rect)
end
@_damage_sprite = ::Sprite.new(self.viewport)
@_damage_sprite.bitmap = bitmap
@_damage_sprite.ox = bitmap.width / 2
@_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
if $BlizzABS
class Sprite_Damage < Sprite
include GG_DamageImages
include BlizzABS
def draw_damage(request)
heal = false
miss = false
level = false
defend = false
real_damage = false
case request.color
when Cache::DMGColors['HP+A'], Cache::DMGColors['HP+E']
heal = true
real_damage = true
when Cache::DMGColors['SP+A'], Cache::DMGColors['SP+E']
heal = true
real_damage = true
when Cache::DMGColors[Cache::TXTDefend]
defend = true
when Cache::DMGColors[Cache::TXTMiss]
miss = true
when Cache::DMGColors[Cache::TXTLvlUp]
level = true
else
real_damage = true
end
if real_damage
value = request.damage.to_i.abs
damage_string = value.to_s
else
value = request.damage
damge_string = value.to_s
end
damage_string = value.to_s if damage_string == nil
critical = request.critical
if miss
damage = MISS_FILE
elsif level
damage = LEVEL_UP_FILE
elsif defend
damage = DEFEND_FILE
elsif heal
damage = HEAL_FILE
else
damage = NORMAL_FILE
end
if critical
crit = RPG::Cache.picture(CRITICAL_FILE)
end
image = RPG::Cache.picture(damage)
cwidth = image.width / 10
cheight = image.height
height = critical == true ? image.height + crit.height : image.height
width = damage_string.size * cwidth
yy = 0
xx = 0
if critical
if width < crit.width
xx = crit.width / 2 - width / 2
width = crit.width
yy = crit.height
end
end
bitmap = Bitmap.new(width, height)
if value.is_a?(Numeric)
for i in 0...damage_string.size
int = damage_string[i, 1].to_i
rect = Rect.new(int * cwidth, 0, cwidth, cheight)
bitmap.blt(xx + i * cwidth, yy, image, rect)
end
else
rect = Rect.new(0, 0, image.width, image.height)
bitmap = Bitmap.new(image.width, image.height)
bitmap.blt(0, 0, image, rect)
end
if critical
rect = Rect.new(0, 0, crit.width, crit.height)
bitmap.blt(0, 0, crit, rect)
end
self.bitmap = bitmap
@critical = request.critical
end
end
end