삽입 위치 :「Window_Base 」보다 아래
주의점 :「RTAB 」(와)과의 병용은 현재 할 수 없습니다.통상 전투 한정입니다.
1:RTAB 스크립트에gauge_a.txt 에 쓰여져 있는 스크립트를 삽입.
2:Systems 폴더를, 폴더마다 게임 폴더내의Graphics 폴더넣는다.
개요 설명
본대로 입니다.HP (이)나SP (을)를 게이지로 표시합니다.
또 표시중은 반짝반짝 회전하는 애니메이션을 볼 수 있습니다.
현재의HP/SP 상태에 의해, 게이지의 색은 3 단계에 변화합니다.
개조 방법
해동해 나온다"Systems" 폴더안에, 게이지를 표시하는 화상 파일이 들어가 있습니다.
그 파일을 갈아넣는 것으로, 오리지날의 게이지 표시로 하는 것이 가능합니다.
07/01/11 01:10 Ver1.03 멤버 변경 화면의 표시 불편을 수정.
06/10/29 22:20 Ver1.02 Ver1.01 에 가세해Z 좌표도 순서대로 수정하도록(듯이) 사양 변경.
06/10/29 22:00 Ver1.01 아이템 메뉴등에서 윈도우 위치가 바뀌었을 때, 게이지 위치도 추종하지 않았던 불편을 수정.
06/10/15 19:30 Ver1.00 공개.
///////////////////////////////////////////////////////////////
이 아래부터 복사하세요!
# HP/SP/ 게이지 애니메이션 표시 스크립트 Ver 1.03
# 배포원·서포트URL
# http://members.jcom.home.ne.jp/cogwheel/
# http://nioting.com
#==============================================================================
# ■ Game_Actor
#------------------------------------------------------------------------------
# 액터를 취급하는 클래스입니다.이 클래스는 Game_Actors 클래스 ($game_actors)
# 의 내부에서 사용되어Game_Party 클래스 ($game_party) (으)로부터도 참조됩니다.
#==============================================================================
class Game_Actor < Game_Battler
def now_exp
return @exp - @exp_list[@level]
end
def next_exp
return (@exp_list[@level+1] > 0 ?
@exp_list[@level+1] - @exp_list[@level] : 0)
end
end
#==============================================================================
# ■ Window_Base
#------------------------------------------------------------------------------
# 게임중의 모든 윈도우의 슈퍼 클래스입니다.
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# ● 오브젝트 초기화
# x : 윈도우의 X 좌표
# y : 윈도우의 Y 좌표
# width : 윈도우의 폭
# height : 윈도우의 높이
#--------------------------------------------------------------------------
alias :initialize_gauge :initialize
def initialize(x, y, width, height)
initialize_gauge(x, y, width, height)
# HP, SP 게이지의 초기화
@hp_gauge = {}
@sp_gauge = {}
end
#--------------------------------------------------------------------------
# ● 해방
#--------------------------------------------------------------------------
alias :dispose_gauge :dispose
def dispose
# 게이지의 삭제
gauge_delete
# 오리지날의 해방 처리
dispose_gauge
end
#--------------------------------------------------------------------------
# ● 게이지의 초기화
#--------------------------------------------------------------------------
def gauge_delete
# HP 게이지의 소거
for gauge in @hp_gauge.values
gauge[0].bitmap.dispose
gauge[0].dispose
end
# SP 게이지의 갱신
for gauge in @sp_gauge.values
gauge[0].bitmap.dispose
gauge[0].dispose
end
@hp_gauge = {}
@sp_gauge = {}
end
#--------------------------------------------------------------------------
# ● 프레임 갱신
#--------------------------------------------------------------------------
alias :update_gauge :update
def update
update_gauge
# HP 게이지의 갱신
for gauge in @hp_gauge.values
gauge_refresh(gauge, 0)
end
# SP 게이지의 갱신
for gauge in @sp_gauge.values
gauge_refresh(gauge, 1)
end
end
#--------------------------------------------------------------------------
# ● HP 게이지의 묘화
#--------------------------------------------------------------------------
# 오리지날의HP 묘화를 draw_actor_hp_hpsp (와)과 이름 변경
alias :draw_actor_hp_hpsp :draw_actor_hp
def draw_actor_hp(actor, x, y, width = 144)
# 첫묘화의 경우
if @hp_gauge[actor] == nil
# 게이지고
height = 10
# 색설정.color1: 외측선,color2: 중 범위
# color3: 하늘 게이지 다크 칼라,color4: 하늘 게이지 라이트 칼라
color1 = Color.new(0, 0, 0, 192)
color2 = Color.new(255, 255, 192, 192)
color3 = Color.new(64, 0, 0, 192)
color4 = Color.new(0, 0, 0, 192)
# 하늘 게이지의 묘화
@hp_frame = gauge_rect(width, height, color1, color2, color3, color4)
sprite = Sprite.new
sprite.bitmap = Bitmap.new(width, height)
sprite.x = self.x + x + 16
sprite.y = self.y + y + 42 - height
sprite.z = self.z + 1
count = rand(400)
# 변수rate 에 현재의HP/MHP (을)를 대입
if actor.maxhp != 0
rate = ((width - 4) * actor.hp.to_f / actor.maxhp).ceil
else
rate = width - 4
end
# 위치등 정보의 기억
@hp_gauge[actor] = [sprite, actor, rate, count, x, y - height]
# 게이지 묘화
gauge_refresh(@hp_gauge[actor], 0)
# 타겟 윈도우의 경우, 초기 상태는 비표시
@hp_gauge[actor][0].visible = false if self.is_a?(Window_Target)
end
# 변수rate 에 현재의HP/MHP (을)를 대입
if actor.maxhp != 0
rate = ((width - 4) * actor.hp.to_f / actor.maxhp).ceil
else
rate = width - 4
end
@hp_gauge[actor][2] = rate
# 오리지날의HP 묘화 처리를 호출해
draw_actor_hp_hpsp(actor, x, y, width)
end
#--------------------------------------------------------------------------
# ● SP 게이지의 묘화
#--------------------------------------------------------------------------
# 오리지날의SP 묘화를 draw_actor_sp_hpsp (와)과 이름 변경
alias :draw_actor_sp_hpsp :draw_actor_sp
def draw_actor_sp(actor, x, y, width = 144)
# 첫묘화의 경우
if @sp_gauge[actor] == nil
# 게이지고
height = 10
# 색설정.color1: 외측선,color2: 중 범위
# color3: 하늘 게이지 다크 칼라,color4: 하늘 게이지 라이트 칼라
color1 = Color.new(0, 0, 0, 192)
color2 = Color.new(255, 255, 192, 192)
color3 = Color.new(0, 64, 64, 192)
color4 = Color.new(0, 0, 0, 192)
# 하늘 게이지의 묘화
@sp_frame = gauge_rect(width, height, color1, color2, color3, color4)
sprite = Sprite.new
sprite.bitmap = Bitmap.new(width, height)
sprite.x = self.x + x + 16
sprite.y = self.y + y + 42 - height
sprite.z = self.z + 1
count = rand(400)
# 변수rate 에 현재의HP/MHP (을)를 대입
if actor.maxsp != 0
rate = ((width - 4) * actor.sp.to_f / actor.maxsp).ceil
else
rate = width - 4
end
# 위치등 정보의 기억
@sp_gauge[actor] = [sprite, actor, rate, count, x, y - height]
# 게이지 묘화
gauge_refresh(@sp_gauge[actor], 1)
# 타겟 윈도우의 경우, 초기 상태는 비표시
@sp_gauge[actor][0].visible = false if self.is_a?(Window_Target)
end
# 변수rate 에 현재의HP/MHP (을)를 대입
if actor.maxsp != 0
rate = ((width - 4) * actor.sp.to_f / actor.maxsp).ceil
else
rate = width - 4
end
@sp_gauge[actor][2] = rate
# 오리지날의HP 묘화 처리를 호출해
draw_actor_sp_hpsp(actor, x, y, width)
end
#--------------------------------------------------------------------------
# ● 하늘 게이지의 묘화
#--------------------------------------------------------------------------
def gauge_rect(width, height, color1, color2, color3, color4)
bitmap = Bitmap.new(width, height)
# 테두리 묘화
bitmap.fill_rect(0, 0, width, height, color1)
bitmap.fill_rect(1, 1, width - 2, height - 2, color2)
# 하늘 게이지의 묘화
bitmap.gradation_rect(2, 2, width-4, height-4, color3, color4, 1)
return bitmap
end
#--------------------------------------------------------------------------
# ● 실게이지의 갱신
#--------------------------------------------------------------------------
def gauge_refresh(gauge, type)
# 타입에 의해 분기
case type
when 0 # HP 게이지의 경우
graphic = RPG::Cache.system("Gauge_HP")
rate = gauge[2] * 100 / (gauge[0].bitmap.width - 4)
point = (rate < 50 ? 8 : 0) + (rate < 25 ? 8 : 0)
frame = @hp_frame
when 1 # SP 게이지의 경우
graphic = RPG::Cache.system("Gauge_SP")
rate = gauge[2] * 100 / (gauge[0].bitmap.width - 4)
point = (rate < 50 ? 8 : 0) + (rate < 25 ? 8 : 0)
frame = @sp_frame
end
# 카운트의 갱신
gauge[3] = (gauge[3] - 2) % 400
# 하늘 게이지의 것한 묘화
gauge[0].bitmap.fill_rect(0, 0, gauge[0].bitmap.width,
gauge[0].bitmap.height, Color.new(0, 0, 0, 0))
gauge[0].bitmap.blt(0, 0, frame, frame.rect)
# 게이지의 내용을 묘화 가능한 경우
if gauge[2] > 0
# 실게이지의 묘화
gauge[0].bitmap.blt(2, 2, graphic,
Rect.new(gauge[3], point, gauge[2], gauge[0].bitmap.height - 4), 192)
gauge[0].bitmap.fill_rect(3, 3, gauge[2] - 2,
gauge[0].bitmap.height - 6,Color.new(0, 0, 0, 0))
gauge[0].bitmap.blt(3, 3, graphic,
Rect.new(gauge[3]+1,point+1,gauge[2]-2,gauge[0].bitmap.height- 6), 128)
end
# 게이지 좌표의 갱신
gauge[0].x = [self.x - self.ox + gauge[4] + 16, self.x + 16].max
gauge[0].y = [self.y - self.oy + gauge[5] + 42, self.y + 16].max
gauge[0].src_rect = Rect.new([self.ox - gauge[4], 0].max,
[self.oy - gauge[5] - 26, 0].max,
[self.ox + self.width - gauge[4] - 32, gauge[0].bitmap.width].min,
[self.oy + self.height - gauge[5] - 32, gauge[0].bitmap.height].min)
gauge[0].visible = self.visible
end
#--------------------------------------------------------------------------
# ● 윈도우 X 좌표의 갱신
#--------------------------------------------------------------------------
def x=(new_x)
super(new_x)
if @hp_gauge != nil
# HP 게이지의 갱신
for gauge in @hp_gauge.values + @sp_gauge.values
gauge[0].x = self.x + gauge[4] + 16
end
end
end
#--------------------------------------------------------------------------
# ● 윈도우 Y 좌표의 갱신
#--------------------------------------------------------------------------
def y=(new_y)
super(new_y)
if @hp_gauge != nil
# HP 게이지의 갱신
for gauge in @hp_gauge.values + @sp_gauge.values
gauge[0].y = self.y + gauge[5] + 42
end
end
end
#--------------------------------------------------------------------------
# ● 윈도우 Z 좌표의 갱신
#--------------------------------------------------------------------------
def z=(new_z)
super(new_z)
if @hp_gauge != nil
# HP 게이지의 갱신
for gauge in @hp_gauge.values + @sp_gauge.values
gauge[0].z = self.z + 1
end
end
end
end
#==============================================================================
# ■ Window_Help
#------------------------------------------------------------------------------
# 스킬이나 아이템의 설명, 액터의 스테이터스등을 표시하는 윈도우입니다.
#==============================================================================
class Window_Help < Window_Base
#--------------------------------------------------------------------------
# ● 텍스트 설정
# text : 윈도우에 표시하는 문자열
# align : alignment (0.. 왼쪽 가지런히 해1.. centering,2.. 오른쪽맞춤)
#--------------------------------------------------------------------------
alias :gauge_set_text :set_text
def set_text(text, align = 0)
# 텍스트와 alignment의 적어도 한편이 전회와 다른 경우
if text != @text or align != @align
# 게이지의 삭제
gauge_delete
# 오리지날의 처리
gauge_set_text(text, align)
end
end
#--------------------------------------------------------------------------
# ● 액터 설정
# actor : 스테이터스를 표시하는 액터
#--------------------------------------------------------------------------
alias :gauge_set_actor :set_actor
def set_actor(actor)
if actor != @actor
# 게이지의 삭제
gauge_delete
# 오리지날의 처리
gauge_set_actor(actor)
end
end
#--------------------------------------------------------------------------
# ● 에너지? -설정
# enemy : 이름과 스테이트를 표시하는 에너지? -
#--------------------------------------------------------------------------
alias :gauge_set_enemy :set_enemy
def set_enemy(enemy)
# 게이지의 삭제
gauge_delete
# 오리지날의 처리
gauge_set_enemy(enemy)
end
end
#==============================================================================
# ■ Spriteset_Battle
#------------------------------------------------------------------------------
# 배틀 화면의 스프라이트를 정리한 클래스입니다.이 클래스는 Scene_Battle 곳간
# 스의 내부에서 사용됩니다.
#==============================================================================
class Spriteset_Battle
#--------------------------------------------------------------------------
# ● 오브젝트 초기화
#--------------------------------------------------------------------------
alias :initialize_gauge :initialize
def initialize
initialize_gauge
@viewport2.z = 100
end
end
#==============================================================================
# ■ Bitmap
#------------------------------------------------------------------------------
# Bitmap 클래스에 새로운 기능을 추가합니다.
#==============================================================================
class Bitmap
#--------------------------------------------------------------------------
# ● 구형을 그라데이션 표시
# color1 : 스타트 칼라
# color2 : 엔드 칼라
# align : 0: 옆에 그라데이션
# 1: 세로에 그라데이션
# 2: 비스듬하게 그라데이션(격중에 대해 주의)
#--------------------------------------------------------------------------
def gradation_rect(x, y, width, height, color1, color2, align = 0)
if align == 0
for i in x...x + width
red = color1.red + (color2.red - color1.red) * (i - x) / (width - 1)
green = color1.green +
(color2.green - color1.green) * (i - x) / (width - 1)
blue = color1.blue +
(color2.blue - color1.blue) * (i - x) / (width - 1)
alpha = color1.alpha +
(color2.alpha - color1.alpha) * (i - x) / (width - 1)
color = Color.new(red, green, blue, alpha)
fill_rect(i, y, 1, height, color)
end
elsif align == 1
for i in y...y + height
red = color1.red +
(color2.red - color1.red) * (i - y) / (height - 1)
green = color1.green +
(color2.green - color1.green) * (i - y) / (height - 1)
blue = color1.blue +
(color2.blue - color1.blue) * (i - y) / (height - 1)
alpha = color1.alpha +
(color2.alpha - color1.alpha) * (i - y) / (height - 1)
color = Color.new(red, green, blue, alpha)
fill_rect(x, i, width, 1, color)
end
elsif align == 2
for i in x...x + width
for j in y...y + height
red = color1.red + (color2.red - color1.red) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
green = color1.green + (color2.green - color1.green) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
blue = color1.blue + (color2.blue - color1.blue) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
alpha = color1.alpha + (color2.alpha - color1.alpha) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
color = Color.new(red, green, blue, alpha)
set_pixel(i, j, color)
end
end
elsif align == 3
for i in x...x + width
for j in y...y + height
red = color1.red + (color2.red - color1.red) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
green = color1.green + (color2.green - color1.green) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
blue = color1.blue + (color2.blue - color1.blue) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
alpha = color1.alpha + (color2.alpha - color1.alpha) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
color = Color.new(red, green, blue, alpha)
set_pixel(i, j, color)
end
end
end
end
end
#==============================================================================
# ■ Sprite 모듈
#------------------------------------------------------------------------------
# 애니메이션의 관리를 실시하는 모듈입니다.
#==============================================================================
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(160, 48)
bitmap.font.name = "Arial Black"
bitmap.font.size = 32
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
if value.is_a?(Numeric) and value < 0
bitmap.font.color.set(176, 255, 144)
else
bitmap.font.color.set(255, 255, 255)
end
bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
if critical
bitmap.font.size = 20
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
bitmap.font.color.set(255, 255, 255)
bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 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
def animation(animation, hit)
dispose_animation
@_animation = animation
return if @_animation == nil
@_animation_hit = hit
@_animation_duration = @_animation.frame_max
animation_name = @_animation.animation_name
animation_hue = @_animation.animation_hue
bitmap = RPG::Cache.animation(animation_name, animation_hue)
if @@_reference_count.include?(bitmap)
@@_reference_count[bitmap] += 1
else
@@_reference_count[bitmap] = 1
end
@_animation_sprites = []
if @_animation.position != 3 or not @@_animations.include?(animation)
for i in 0..15
sprite = ::Sprite.new
sprite.bitmap = bitmap
sprite.visible = false
@_animation_sprites.push(sprite)
end
unless @@_animations.include?(animation)
@@_animations.push(animation)
end
end
update_animation
end
def loop_animation(animation)
return if animation == @_loop_animation
dispose_loop_animation
@_loop_animation = animation
return if @_loop_animation == nil
@_loop_animation_index = 0
animation_name = @_loop_animation.animation_name
animation_hue = @_loop_animation.animation_hue
bitmap = RPG::Cache.animation(animation_name, animation_hue)
if @@_reference_count.include?(bitmap)
@@_reference_count[bitmap] += 1
else
@@_reference_count[bitmap] = 1
end
@_loop_animation_sprites = []
for i in 0..15
sprite = ::Sprite.new
sprite.bitmap = bitmap
sprite.visible = false
@_loop_animation_sprites.push(sprite)
end
update_loop_animation
end
def animation_set_sprites(sprites, cell_data, position)
for i in 0..15
sprite = sprites[i]
pattern = cell_data[i, 0]
if sprite == nil or pattern == nil or pattern == -1
sprite.visible = false if sprite != nil
next
end
sprite.visible = true
sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
if position == 3
if self.viewport != nil
sprite.x = self.viewport.rect.width / 2
sprite.y = self.viewport.rect.height - 160
else
sprite.x = 320
sprite.y = 240
end
else
sprite.x = self.x + self.viewport.rect.x -
self.ox + self.src_rect.width / 2
sprite.y = self.y + self.viewport.rect.y -
self.oy + self.src_rect.height / 2
sprite.y -= self.src_rect.height / 4 if position == 0
sprite.y += self.src_rect.height / 4 if position == 2
end
sprite.x += cell_data[i, 1]
sprite.y += cell_data[i, 2]
sprite.z = 2000
sprite.ox = 96
sprite.oy = 96
sprite.zoom_x = cell_data[i, 3] / 100.0
sprite.zoom_y = cell_data[i, 3] / 100.0
sprite.angle = cell_data[i, 4]
sprite.mirror = (cell_data[i, 5] == 1)
sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
sprite.blend_type = cell_data[i, 7]
end
end
end
end
#==============================================================================
# ■ RPG
#------------------------------------------------------------------------------
# 기본 모듈입니다
#==============================================================================
module RPG
#============================================================================
# ■ Cache
#----------------------------------------------------------------------------
# 화상 처리를 실시하는 모듈입니다.
#============================================================================
module Cache
def self.system(filename)
self.load_bitmap("Graphics/Systems/", filename)
end
end
end
주의점 :「RTAB 」(와)과의 병용은 현재 할 수 없습니다.통상 전투 한정입니다.
1:RTAB 스크립트에gauge_a.txt 에 쓰여져 있는 스크립트를 삽입.
2:Systems 폴더를, 폴더마다 게임 폴더내의Graphics 폴더넣는다.
개요 설명
본대로 입니다.HP (이)나SP (을)를 게이지로 표시합니다.
또 표시중은 반짝반짝 회전하는 애니메이션을 볼 수 있습니다.
현재의HP/SP 상태에 의해, 게이지의 색은 3 단계에 변화합니다.
개조 방법
해동해 나온다"Systems" 폴더안에, 게이지를 표시하는 화상 파일이 들어가 있습니다.
그 파일을 갈아넣는 것으로, 오리지날의 게이지 표시로 하는 것이 가능합니다.
07/01/11 01:10 Ver1.03 멤버 변경 화면의 표시 불편을 수정.
06/10/29 22:20 Ver1.02 Ver1.01 에 가세해Z 좌표도 순서대로 수정하도록(듯이) 사양 변경.
06/10/29 22:00 Ver1.01 아이템 메뉴등에서 윈도우 위치가 바뀌었을 때, 게이지 위치도 추종하지 않았던 불편을 수정.
06/10/15 19:30 Ver1.00 공개.
///////////////////////////////////////////////////////////////
이 아래부터 복사하세요!
# HP/SP/ 게이지 애니메이션 표시 스크립트 Ver 1.03
# 배포원·서포트URL
# http://members.jcom.home.ne.jp/cogwheel/
# http://nioting.com
#==============================================================================
# ■ Game_Actor
#------------------------------------------------------------------------------
# 액터를 취급하는 클래스입니다.이 클래스는 Game_Actors 클래스 ($game_actors)
# 의 내부에서 사용되어Game_Party 클래스 ($game_party) (으)로부터도 참조됩니다.
#==============================================================================
class Game_Actor < Game_Battler
def now_exp
return @exp - @exp_list[@level]
end
def next_exp
return (@exp_list[@level+1] > 0 ?
@exp_list[@level+1] - @exp_list[@level] : 0)
end
end
#==============================================================================
# ■ Window_Base
#------------------------------------------------------------------------------
# 게임중의 모든 윈도우의 슈퍼 클래스입니다.
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# ● 오브젝트 초기화
# x : 윈도우의 X 좌표
# y : 윈도우의 Y 좌표
# width : 윈도우의 폭
# height : 윈도우의 높이
#--------------------------------------------------------------------------
alias :initialize_gauge :initialize
def initialize(x, y, width, height)
initialize_gauge(x, y, width, height)
# HP, SP 게이지의 초기화
@hp_gauge = {}
@sp_gauge = {}
end
#--------------------------------------------------------------------------
# ● 해방
#--------------------------------------------------------------------------
alias :dispose_gauge :dispose
def dispose
# 게이지의 삭제
gauge_delete
# 오리지날의 해방 처리
dispose_gauge
end
#--------------------------------------------------------------------------
# ● 게이지의 초기화
#--------------------------------------------------------------------------
def gauge_delete
# HP 게이지의 소거
for gauge in @hp_gauge.values
gauge[0].bitmap.dispose
gauge[0].dispose
end
# SP 게이지의 갱신
for gauge in @sp_gauge.values
gauge[0].bitmap.dispose
gauge[0].dispose
end
@hp_gauge = {}
@sp_gauge = {}
end
#--------------------------------------------------------------------------
# ● 프레임 갱신
#--------------------------------------------------------------------------
alias :update_gauge :update
def update
update_gauge
# HP 게이지의 갱신
for gauge in @hp_gauge.values
gauge_refresh(gauge, 0)
end
# SP 게이지의 갱신
for gauge in @sp_gauge.values
gauge_refresh(gauge, 1)
end
end
#--------------------------------------------------------------------------
# ● HP 게이지의 묘화
#--------------------------------------------------------------------------
# 오리지날의HP 묘화를 draw_actor_hp_hpsp (와)과 이름 변경
alias :draw_actor_hp_hpsp :draw_actor_hp
def draw_actor_hp(actor, x, y, width = 144)
# 첫묘화의 경우
if @hp_gauge[actor] == nil
# 게이지고
height = 10
# 색설정.color1: 외측선,color2: 중 범위
# color3: 하늘 게이지 다크 칼라,color4: 하늘 게이지 라이트 칼라
color1 = Color.new(0, 0, 0, 192)
color2 = Color.new(255, 255, 192, 192)
color3 = Color.new(64, 0, 0, 192)
color4 = Color.new(0, 0, 0, 192)
# 하늘 게이지의 묘화
@hp_frame = gauge_rect(width, height, color1, color2, color3, color4)
sprite = Sprite.new
sprite.bitmap = Bitmap.new(width, height)
sprite.x = self.x + x + 16
sprite.y = self.y + y + 42 - height
sprite.z = self.z + 1
count = rand(400)
# 변수rate 에 현재의HP/MHP (을)를 대입
if actor.maxhp != 0
rate = ((width - 4) * actor.hp.to_f / actor.maxhp).ceil
else
rate = width - 4
end
# 위치등 정보의 기억
@hp_gauge[actor] = [sprite, actor, rate, count, x, y - height]
# 게이지 묘화
gauge_refresh(@hp_gauge[actor], 0)
# 타겟 윈도우의 경우, 초기 상태는 비표시
@hp_gauge[actor][0].visible = false if self.is_a?(Window_Target)
end
# 변수rate 에 현재의HP/MHP (을)를 대입
if actor.maxhp != 0
rate = ((width - 4) * actor.hp.to_f / actor.maxhp).ceil
else
rate = width - 4
end
@hp_gauge[actor][2] = rate
# 오리지날의HP 묘화 처리를 호출해
draw_actor_hp_hpsp(actor, x, y, width)
end
#--------------------------------------------------------------------------
# ● SP 게이지의 묘화
#--------------------------------------------------------------------------
# 오리지날의SP 묘화를 draw_actor_sp_hpsp (와)과 이름 변경
alias :draw_actor_sp_hpsp :draw_actor_sp
def draw_actor_sp(actor, x, y, width = 144)
# 첫묘화의 경우
if @sp_gauge[actor] == nil
# 게이지고
height = 10
# 색설정.color1: 외측선,color2: 중 범위
# color3: 하늘 게이지 다크 칼라,color4: 하늘 게이지 라이트 칼라
color1 = Color.new(0, 0, 0, 192)
color2 = Color.new(255, 255, 192, 192)
color3 = Color.new(0, 64, 64, 192)
color4 = Color.new(0, 0, 0, 192)
# 하늘 게이지의 묘화
@sp_frame = gauge_rect(width, height, color1, color2, color3, color4)
sprite = Sprite.new
sprite.bitmap = Bitmap.new(width, height)
sprite.x = self.x + x + 16
sprite.y = self.y + y + 42 - height
sprite.z = self.z + 1
count = rand(400)
# 변수rate 에 현재의HP/MHP (을)를 대입
if actor.maxsp != 0
rate = ((width - 4) * actor.sp.to_f / actor.maxsp).ceil
else
rate = width - 4
end
# 위치등 정보의 기억
@sp_gauge[actor] = [sprite, actor, rate, count, x, y - height]
# 게이지 묘화
gauge_refresh(@sp_gauge[actor], 1)
# 타겟 윈도우의 경우, 초기 상태는 비표시
@sp_gauge[actor][0].visible = false if self.is_a?(Window_Target)
end
# 변수rate 에 현재의HP/MHP (을)를 대입
if actor.maxsp != 0
rate = ((width - 4) * actor.sp.to_f / actor.maxsp).ceil
else
rate = width - 4
end
@sp_gauge[actor][2] = rate
# 오리지날의HP 묘화 처리를 호출해
draw_actor_sp_hpsp(actor, x, y, width)
end
#--------------------------------------------------------------------------
# ● 하늘 게이지의 묘화
#--------------------------------------------------------------------------
def gauge_rect(width, height, color1, color2, color3, color4)
bitmap = Bitmap.new(width, height)
# 테두리 묘화
bitmap.fill_rect(0, 0, width, height, color1)
bitmap.fill_rect(1, 1, width - 2, height - 2, color2)
# 하늘 게이지의 묘화
bitmap.gradation_rect(2, 2, width-4, height-4, color3, color4, 1)
return bitmap
end
#--------------------------------------------------------------------------
# ● 실게이지의 갱신
#--------------------------------------------------------------------------
def gauge_refresh(gauge, type)
# 타입에 의해 분기
case type
when 0 # HP 게이지의 경우
graphic = RPG::Cache.system("Gauge_HP")
rate = gauge[2] * 100 / (gauge[0].bitmap.width - 4)
point = (rate < 50 ? 8 : 0) + (rate < 25 ? 8 : 0)
frame = @hp_frame
when 1 # SP 게이지의 경우
graphic = RPG::Cache.system("Gauge_SP")
rate = gauge[2] * 100 / (gauge[0].bitmap.width - 4)
point = (rate < 50 ? 8 : 0) + (rate < 25 ? 8 : 0)
frame = @sp_frame
end
# 카운트의 갱신
gauge[3] = (gauge[3] - 2) % 400
# 하늘 게이지의 것한 묘화
gauge[0].bitmap.fill_rect(0, 0, gauge[0].bitmap.width,
gauge[0].bitmap.height, Color.new(0, 0, 0, 0))
gauge[0].bitmap.blt(0, 0, frame, frame.rect)
# 게이지의 내용을 묘화 가능한 경우
if gauge[2] > 0
# 실게이지의 묘화
gauge[0].bitmap.blt(2, 2, graphic,
Rect.new(gauge[3], point, gauge[2], gauge[0].bitmap.height - 4), 192)
gauge[0].bitmap.fill_rect(3, 3, gauge[2] - 2,
gauge[0].bitmap.height - 6,Color.new(0, 0, 0, 0))
gauge[0].bitmap.blt(3, 3, graphic,
Rect.new(gauge[3]+1,point+1,gauge[2]-2,gauge[0].bitmap.height- 6), 128)
end
# 게이지 좌표의 갱신
gauge[0].x = [self.x - self.ox + gauge[4] + 16, self.x + 16].max
gauge[0].y = [self.y - self.oy + gauge[5] + 42, self.y + 16].max
gauge[0].src_rect = Rect.new([self.ox - gauge[4], 0].max,
[self.oy - gauge[5] - 26, 0].max,
[self.ox + self.width - gauge[4] - 32, gauge[0].bitmap.width].min,
[self.oy + self.height - gauge[5] - 32, gauge[0].bitmap.height].min)
gauge[0].visible = self.visible
end
#--------------------------------------------------------------------------
# ● 윈도우 X 좌표의 갱신
#--------------------------------------------------------------------------
def x=(new_x)
super(new_x)
if @hp_gauge != nil
# HP 게이지의 갱신
for gauge in @hp_gauge.values + @sp_gauge.values
gauge[0].x = self.x + gauge[4] + 16
end
end
end
#--------------------------------------------------------------------------
# ● 윈도우 Y 좌표의 갱신
#--------------------------------------------------------------------------
def y=(new_y)
super(new_y)
if @hp_gauge != nil
# HP 게이지의 갱신
for gauge in @hp_gauge.values + @sp_gauge.values
gauge[0].y = self.y + gauge[5] + 42
end
end
end
#--------------------------------------------------------------------------
# ● 윈도우 Z 좌표의 갱신
#--------------------------------------------------------------------------
def z=(new_z)
super(new_z)
if @hp_gauge != nil
# HP 게이지의 갱신
for gauge in @hp_gauge.values + @sp_gauge.values
gauge[0].z = self.z + 1
end
end
end
end
#==============================================================================
# ■ Window_Help
#------------------------------------------------------------------------------
# 스킬이나 아이템의 설명, 액터의 스테이터스등을 표시하는 윈도우입니다.
#==============================================================================
class Window_Help < Window_Base
#--------------------------------------------------------------------------
# ● 텍스트 설정
# text : 윈도우에 표시하는 문자열
# align : alignment (0.. 왼쪽 가지런히 해1.. centering,2.. 오른쪽맞춤)
#--------------------------------------------------------------------------
alias :gauge_set_text :set_text
def set_text(text, align = 0)
# 텍스트와 alignment의 적어도 한편이 전회와 다른 경우
if text != @text or align != @align
# 게이지의 삭제
gauge_delete
# 오리지날의 처리
gauge_set_text(text, align)
end
end
#--------------------------------------------------------------------------
# ● 액터 설정
# actor : 스테이터스를 표시하는 액터
#--------------------------------------------------------------------------
alias :gauge_set_actor :set_actor
def set_actor(actor)
if actor != @actor
# 게이지의 삭제
gauge_delete
# 오리지날의 처리
gauge_set_actor(actor)
end
end
#--------------------------------------------------------------------------
# ● 에너지? -설정
# enemy : 이름과 스테이트를 표시하는 에너지? -
#--------------------------------------------------------------------------
alias :gauge_set_enemy :set_enemy
def set_enemy(enemy)
# 게이지의 삭제
gauge_delete
# 오리지날의 처리
gauge_set_enemy(enemy)
end
end
#==============================================================================
# ■ Spriteset_Battle
#------------------------------------------------------------------------------
# 배틀 화면의 스프라이트를 정리한 클래스입니다.이 클래스는 Scene_Battle 곳간
# 스의 내부에서 사용됩니다.
#==============================================================================
class Spriteset_Battle
#--------------------------------------------------------------------------
# ● 오브젝트 초기화
#--------------------------------------------------------------------------
alias :initialize_gauge :initialize
def initialize
initialize_gauge
@viewport2.z = 100
end
end
#==============================================================================
# ■ Bitmap
#------------------------------------------------------------------------------
# Bitmap 클래스에 새로운 기능을 추가합니다.
#==============================================================================
class Bitmap
#--------------------------------------------------------------------------
# ● 구형을 그라데이션 표시
# color1 : 스타트 칼라
# color2 : 엔드 칼라
# align : 0: 옆에 그라데이션
# 1: 세로에 그라데이션
# 2: 비스듬하게 그라데이션(격중에 대해 주의)
#--------------------------------------------------------------------------
def gradation_rect(x, y, width, height, color1, color2, align = 0)
if align == 0
for i in x...x + width
red = color1.red + (color2.red - color1.red) * (i - x) / (width - 1)
green = color1.green +
(color2.green - color1.green) * (i - x) / (width - 1)
blue = color1.blue +
(color2.blue - color1.blue) * (i - x) / (width - 1)
alpha = color1.alpha +
(color2.alpha - color1.alpha) * (i - x) / (width - 1)
color = Color.new(red, green, blue, alpha)
fill_rect(i, y, 1, height, color)
end
elsif align == 1
for i in y...y + height
red = color1.red +
(color2.red - color1.red) * (i - y) / (height - 1)
green = color1.green +
(color2.green - color1.green) * (i - y) / (height - 1)
blue = color1.blue +
(color2.blue - color1.blue) * (i - y) / (height - 1)
alpha = color1.alpha +
(color2.alpha - color1.alpha) * (i - y) / (height - 1)
color = Color.new(red, green, blue, alpha)
fill_rect(x, i, width, 1, color)
end
elsif align == 2
for i in x...x + width
for j in y...y + height
red = color1.red + (color2.red - color1.red) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
green = color1.green + (color2.green - color1.green) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
blue = color1.blue + (color2.blue - color1.blue) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
alpha = color1.alpha + (color2.alpha - color1.alpha) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
color = Color.new(red, green, blue, alpha)
set_pixel(i, j, color)
end
end
elsif align == 3
for i in x...x + width
for j in y...y + height
red = color1.red + (color2.red - color1.red) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
green = color1.green + (color2.green - color1.green) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
blue = color1.blue + (color2.blue - color1.blue) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
alpha = color1.alpha + (color2.alpha - color1.alpha) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
color = Color.new(red, green, blue, alpha)
set_pixel(i, j, color)
end
end
end
end
end
#==============================================================================
# ■ Sprite 모듈
#------------------------------------------------------------------------------
# 애니메이션의 관리를 실시하는 모듈입니다.
#==============================================================================
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(160, 48)
bitmap.font.name = "Arial Black"
bitmap.font.size = 32
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
if value.is_a?(Numeric) and value < 0
bitmap.font.color.set(176, 255, 144)
else
bitmap.font.color.set(255, 255, 255)
end
bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
if critical
bitmap.font.size = 20
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
bitmap.font.color.set(255, 255, 255)
bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 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
def animation(animation, hit)
dispose_animation
@_animation = animation
return if @_animation == nil
@_animation_hit = hit
@_animation_duration = @_animation.frame_max
animation_name = @_animation.animation_name
animation_hue = @_animation.animation_hue
bitmap = RPG::Cache.animation(animation_name, animation_hue)
if @@_reference_count.include?(bitmap)
@@_reference_count[bitmap] += 1
else
@@_reference_count[bitmap] = 1
end
@_animation_sprites = []
if @_animation.position != 3 or not @@_animations.include?(animation)
for i in 0..15
sprite = ::Sprite.new
sprite.bitmap = bitmap
sprite.visible = false
@_animation_sprites.push(sprite)
end
unless @@_animations.include?(animation)
@@_animations.push(animation)
end
end
update_animation
end
def loop_animation(animation)
return if animation == @_loop_animation
dispose_loop_animation
@_loop_animation = animation
return if @_loop_animation == nil
@_loop_animation_index = 0
animation_name = @_loop_animation.animation_name
animation_hue = @_loop_animation.animation_hue
bitmap = RPG::Cache.animation(animation_name, animation_hue)
if @@_reference_count.include?(bitmap)
@@_reference_count[bitmap] += 1
else
@@_reference_count[bitmap] = 1
end
@_loop_animation_sprites = []
for i in 0..15
sprite = ::Sprite.new
sprite.bitmap = bitmap
sprite.visible = false
@_loop_animation_sprites.push(sprite)
end
update_loop_animation
end
def animation_set_sprites(sprites, cell_data, position)
for i in 0..15
sprite = sprites[i]
pattern = cell_data[i, 0]
if sprite == nil or pattern == nil or pattern == -1
sprite.visible = false if sprite != nil
next
end
sprite.visible = true
sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
if position == 3
if self.viewport != nil
sprite.x = self.viewport.rect.width / 2
sprite.y = self.viewport.rect.height - 160
else
sprite.x = 320
sprite.y = 240
end
else
sprite.x = self.x + self.viewport.rect.x -
self.ox + self.src_rect.width / 2
sprite.y = self.y + self.viewport.rect.y -
self.oy + self.src_rect.height / 2
sprite.y -= self.src_rect.height / 4 if position == 0
sprite.y += self.src_rect.height / 4 if position == 2
end
sprite.x += cell_data[i, 1]
sprite.y += cell_data[i, 2]
sprite.z = 2000
sprite.ox = 96
sprite.oy = 96
sprite.zoom_x = cell_data[i, 3] / 100.0
sprite.zoom_y = cell_data[i, 3] / 100.0
sprite.angle = cell_data[i, 4]
sprite.mirror = (cell_data[i, 5] == 1)
sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
sprite.blend_type = cell_data[i, 7]
end
end
end
end
#==============================================================================
# ■ RPG
#------------------------------------------------------------------------------
# 기본 모듈입니다
#==============================================================================
module RPG
#============================================================================
# ■ Cache
#----------------------------------------------------------------------------
# 화상 처리를 실시하는 모듈입니다.
#============================================================================
module Cache
def self.system(filename)
self.load_bitmap("Graphics/Systems/", filename)
end
end
end