[RGSS] KGC DamageAlter
Página 1 de 1
[RGSS] KGC DamageAlter
- Script Postado no antigo fórum em 08/03/2007 -
Cópia do Tópico Original
___________________________________
Cópia do Tópico Original
___________________________________
NOTA: Precisa do KGC_Module...
Crie um novo script acima do Main e abaixo do KGC_Module.
- Código:
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/ ◆ ダメージ数値改造 - KGC_DamageAlter ◆
#_/ ◇ Last update : 2006/08/26 ◇
#_/----------------------------------------------------------------------------
#_/ ダメージ数値を改造します。
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#==============================================================================
# ★ カスタマイズ項目 ★
#==============================================================================
module KGC
# ◆ダメージ数値画像
# "Graphics/Pictures/" から読み込む。拡張子省略可。
DA_IMG_DAMAGE = "Damage01"
# ◆回復数値画像
DA_IMG_RECOVER = "Damage02"
# ◆ミス画像
DA_IMG_MISS = "Miss"
# ◆クリティカル画像
DA_IMG_CRITICAL = "Critical"
# ◆桁間隔
# 各桁の数値の描画間隔を指定。
DA_DIGIT_MARGIN = -8
# ◆演出タイプ
# 0..デフォルト 1..スライド 2..ズーム
DA_DIRECT_TYPE = 2
# ==== 以下は、数値・ミス以外の表示に使用 ====
# ◆ダメージ表示フォント
DA_FONT_NAME = "Times New Roman"
# ◆ダメージ表示サイズ
DA_FONT_SIZE = 40
# ◆ダメージ表示ボールド
DA_FONT_BOLD = true
# ◆ダメージ表示イタリック
DA_FONT_ITALIC = false
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
$imported = {} if $imported == nil
$imported["DamageAlter"] = true
#==============================================================================
# ■ RPG::Sprite
#==============================================================================
class RPG::Sprite
#------------------------------------------------------------------------
# ● オブジェクト初期化
#------------------------------------------------------------------------
unless @_initialize_damage_alter
alias initialize_KGC_DamageAlter initialize
end
@_initialize_damage_alter = true
def initialize(viewport = nil)
initialize_KGC_DamageAlter(viewport)
@_damage_duration_2 = 0
end
#------------------------------------------------------------------------
# ● ダメージスプライト作成
#------------------------------------------------------------------------
def damage(value, critical)
dispose_damage
bitmap = create_damage_bitmap(value, critical)
sprite = ::Sprite.new
sprite.bitmap = bitmap
sprite.ox = bitmap.width / 2
sprite.oy = bitmap.height / 2
sprite.x = self.x
sprite.y = self.y - self.oy / 2
sprite.z = 3000
@_damage_duration_2 = 40
if KGC::DA_DIRECT_TYPE == 2
sprite.zoom_x = 0.0
sprite.zoom_y = 5.0
end
@_damage_sprite = sprite
end
#------------------------------------------------------------------------
# ● ダメージ画像作成
# value : 数値
# critical : クリティカルフラグ
#------------------------------------------------------------------------
def create_damage_bitmap(value, critical)
if value.is_a?(Numeric) # 数値
dgt_bmp = nil
crt_bmp = nil
# 転送元画像を取得
if value < 0
dgt_bmp = RPG::Cache.picture(KGC::DA_IMG_RECOVER)
else
dgt_bmp = RPG::Cache.picture(KGC::DA_IMG_DAMAGE)
end
crt_bmp = RPG::Cache.picture(KGC::DA_IMG_CRITICAL)
# 転送矩形を取得
rect = dgt_bmp.rect.clone
rect.width /= 10
# 描画準備
dw = rect.width + KGC::DA_DIGIT_MARGIN
dh = rect.height + crt_bmp.height
dmg_dgt = value.abs.to_s.scan(/./)
# 描画幅計算
num_width = dw * dmg_dgt.size - KGC::DA_DIGIT_MARGIN
bmp_width = [num_width, crt_bmp.width].max
dmg_bmp = Bitmap.new(bmp_width, dh)
dx = (bmp_width - num_width) / 2
dy = crt_bmp.height
# 描画開始
dmg_dgt.each { |d|
rect.x = d.to_i * rect.width
dmg_bmp.blt(dx, dy, dgt_bmp, rect)
dx += dw
}
if critical
dmg_bmp.blt((dmg_bmp.width - crt_bmp.width) / 2, 0, crt_bmp, crt_bmp.rect)
end
return dmg_bmp
elsif value == "Miss" # Miss
miss = RPG::Cache.picture(KGC::DA_IMG_MISS)
dmg_bmp = Bitmap.new(miss.width, miss.height)
dmg_bmp.blt(0, 0, miss, miss.rect)
return dmg_bmp
else # その他
str = value.to_s
bitmap = Bitmap.new(160, 48)
bitmap.font.name = KGC::DA_FONT_NAME
bitmap.font.size = KGC::DA_FONT_SIZE
bitmap.font.bold = KGC::DA_FONT_BOLD
bitmap.font.italic = KGC::DA_FONT_ITALIC
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, 12-1, 160, 36, str, 1)
bitmap.draw_text(+1, 12-1, 160, 36, str, 1)
bitmap.draw_text(-1, 12+1, 160, 36, str, 1)
bitmap.draw_text(+1, 12+1, 160, 36, str, 1)
bitmap.font.color.set(255, 255, 255)
bitmap.draw_text(0, 12, 160, 36, str, 1)
return bitmap
end
end
#------------------------------------------------------------------------
# ● エフェクト表示中判定
#------------------------------------------------------------------------
unless @_effect_damage_alter
alias effect_KGC_DamageAlter? effect?
end
@_effect_damage_alter = true
def effect?
return effect_KGC_DamageAlter? || @_damage_duration_2 > 30
end
#------------------------------------------------------------------------
# ● 更新
#------------------------------------------------------------------------
unless @_update_damage_alter
alias update_KGC_DamageAlter update
end
@_update_damage_alter = true
def update
update_KGC_DamageAlter
if @_damage_duration_2 > 0 && @_damage_sprite != nil
@_damage_duration_2 -= 1
damage_direct(@_damage_sprite, @_damage_duration_2)
if @_damage_duration_2 <= 0
dispose_damage
end
else
@_damage_duration_2 = 0
end
end
#------------------------------------------------------------------------
# ● ダメージ演出
#------------------------------------------------------------------------
def damage_direct(sprite, duration)
case KGC::DA_DIRECT_TYPE
when 0 # デフォルト
damage_direct_default(sprite, duration)
when 1 # スライド
damage_direct_slide(sprite, duration)
when 2 # ズーム
damage_direct_zoom(sprite, duration)
end
end
#------------------------------------------------------------------------
# ● ダメージ演出 : デフォルト
#------------------------------------------------------------------------
def damage_direct_default(sprite, duration)
sprite.x = self.x
if duration > 27
sprite.y -= [(duration - 33) / 2 + 1, 1].max
end
sprite.opacity = 256 - (12 - duration) * 32
end
#------------------------------------------------------------------------
# ● ダメージ演出 : スライド
#------------------------------------------------------------------------
def damage_direct_slide(sprite, duration)
sprite.x = self.x
sprite.y -= 1
sprite.opacity = 256 - (12 - duration) * 32
end
#------------------------------------------------------------------------
# ● ダメージ演出 : ズーム
#------------------------------------------------------------------------
def damage_direct_zoom(sprite, duration)
sprite.x = self.x
case duration
when 39
sprite.zoom_x = 0.1
sprite.zoom_y = 4.6
when 30..38
sprite.zoom_x += 0.1
sprite.zoom_y -= 0.4
when 1..10
sprite.zoom_x += 0.1
sprite.zoom_y -= 0.1
when 0
sprite.zoom_x = 1.0
sprite.zoom_y = 1.0
end
sprite.opacity = 256 - (12 - duration) * 32
end
end
Salve essa imagem com o nome de "Damage01" sem as aspas...
Salve este outro com o nome de "Damage02" sem as aspas...
Salve esta outra com o nome "Miss" sem as aspas...
Salve essa aqui com o nome "Critical" sem as aspas...
Abraços,
Dark Dudu
Dark Dudu- Número de Mensagens : 385
Idade : 30
Localização : São Vicente - SP
Especialidade : Eventos
Data de inscrição : 01/12/2008
RMB Games
Nível de Reputação: 2
Reputação:
(61/100)
Gamescore:
(0/0)
Tópicos semelhantes
» [RGSS] GTA Loading
» [RGSS] XAS Hero v3.3
» [RGSS] KGC Module
» [RGSS]New Game+
» [RGSS] HUD Amneria [Simple] v2.0
» [RGSS] XAS Hero v3.3
» [RGSS] KGC Module
» [RGSS]New Game+
» [RGSS] HUD Amneria [Simple] v2.0
Página 1 de 1
Permissões neste sub-fórum
Não podes responder a tópicos
|
|