XP 스크립트

http://www.dubealex.com/asylum/index.php?showtopic=9869

맵상에서 파티의 HP,SP,EXP등을 보여주는 스크립트 중 하나입니다. 게임 중 스위치를 이용해서 HUD 표시를 ON/OFF할 수 있습니다.



class Scene_Map

SWITCH_ID = 1
$center_hud = false

alias raz_hud_main main
alias raz_hud_update update

def main
@size = $game_party.actors.size
raz_hud_main
@hud_window.dispose
for i in 0...$game_party.actors.size
@hud_dummy[i].dispose
end
end

def update
if @size != $game_party.actors.size
@hud_window.refresh
show_window
end
if @hud != true
main_window
end
turn_hud_on_off
@hud_window.update
raz_hud_update
end

def show_window
@size = $game_party.actors.size
for i in 0..3
@hud_dummy[i].visible = ($game_party.actors[i] != nil)
end
end

def main_window
@opacity = 200
@hud_dummy = []
for i in 0...4
y = $game_party.actors.size - 1
x = 240 - (y * 80)
if $center_hud == true
@hud_dummy[i] = Window_Base.new(160 * i + x, 372,160, 108)
else
@hud_dummy[i] = Window_Base.new(160 * i, 372,160, 108)
end
@hud_dummy[i].opacity = @opacity
@hud_dummy[i].visible = false
end
@hud_window = Window_HUD.new
for i in 0...$game_party.actors.size
@hud_dummy[i].visible = $game_party.actors[i] != nil
end
@hud = true
end

def turn_hud_on_off
if $game_switches[SWITCH_ID] == false
@hud_window.visible = false
for i in 0...$game_party.actors.size
@hud_dummy[i].visible = false
end
end


if $game_switches[SWITCH_ID] == true
@hud_window.visible = true
for i in 0...$game_party.actors.size
@hud_dummy[i].visible = true
end
end
end

end


class Window_HUD < Window_Base
def initialize
super(0, 0, 800, 600)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
eval("@old_hp#{i+1} = actor.hp; @old_sp#{i+1} = actor.sp; @old_exp#{i+1} = actor.now_exp")
end
refresh
end

def refresh
self.contents.clear
for i in 0...$game_party.actors.size
a = $game_party.actors.size - 1
actor = $game_party.actors[i]
if $center_hud == true
x = (i * 160 + 25) + (240 - (a * 80))
else
x = i * 160 + 25
end
self.contents.font.size = 21
draw_actor_graphic(actor, x - 15, 445)
self.contents.font.color = normal_color
self.contents.draw_text(x - 25, 360, 100, 32, actor.name)
width = 100
height = 6
draw_slant_bar(x + 8, 396, actor.hp, actor.maxhp, width, height, Color.new(150, 0, 0), Color.new(155, 155, 60))
draw_slant_bar(x + 8, 416, actor.sp, actor.maxsp, width, height, Color.new(0, 0, 150), Color.new(60, 155, 155))
unless actor.level == 99
draw_slant_bar(x + 8, 436, actor.now_exp, actor.next_exp, width, height, Color.new(0, 150, 0), Color.new(60, 255, 60))
else
draw_slant_bar(x + 8, 436, 1, 1, width = 100, height = 6, Color.new(0, 150, 0), Color.new(60, 255, 60))
end
self.contents.font.size = 16
draw_actor_state(actor, x + 45, 360)
self.contents.font.color = normal_color
self.contents.font.bold = true
self.contents.font.color = actor.hp == 0 ? knockout_color : actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
self.contents.draw_text(x + 16, 382, 100, 32, "#{actor.hp}/#{actor.maxhp}", 1)
self.contents.font.color = actor.sp == 0 ? crisis_color : actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
self.contents.draw_text(x + 16, 402, 100, 32, "#{actor.sp}/#{actor.maxsp}", 1)
self.contents.font.color = system_color
self.contents.font.size = 20
self.contents.font.bold = false
self.contents.draw_text(x, 384, 50, 32, $data_system.words.hp)
self.contents.draw_text(x, 404, 50, 32, $data_system.words.sp)
self.contents.draw_text(x, 424, 50, 32, "Exp")
end
end

def update
super
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
if (eval("@old_hp#{i+1}") != actor.hp or eval("@old_sp#{i+1}") != actor.sp or
eval("@old_exp#{i+1}") != actor.now_exp)
refresh
eval("@old_hp#{i+1} = actor.hp; @old_sp#{i+1} = actor.sp; @old_exp#{i+1} = actor.now_exp")
end
end
end
end

class Window_Base < Window
def draw_slant_bar(x, y, min, max, width = 152, height = 6,
bar_color = Color.new(150, 0, 0, 255), end_color = Color.new(255, 255, 60, 255))
for i in 0..height
self.contents.fill_rect(x + i, y + height - i, width + 1, 1, Color.new(50, 50, 50, 255))
end
for i in 1..(height - 1)
r = 100 * (height - i) / height + 0 * i / height
g = 100 * (height - i) / height + 0 * i / height
b = 100 * (height - i) / height + 0 * i / height
a = 255 * (height - i) / height + 255 * i / height
self.contents.fill_rect(x + i, y + height - i, width, 1, Color.new(r, b, g, a))
end
for i in 1..( (min / max.to_f) * width - 1)
for j in 1..(height - 1)
r = bar_color.red * (width - i) / width + end_color.red * i / width
g = bar_color.green * (width - i) / width + end_color.green * i / width
b = bar_color.blue * (width - i) / width + end_color.blue * i / width
a = bar_color.alpha * (width - i) / width + end_color.alpha * i / width
self.contents.fill_rect(x + i + j, y + height - j, 1, 1, Color.new(r, g, b, a))
end
end
end
end

class Game_Actor
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
Comment '6'

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 스크립트 자료 게시물 작성시 주의사항 습작 2012.12.24 6153
34 HUD 맵이름 스크립트 1 file 긔염둥이♥ 2012.05.19 2913
33 HUD 맵 이름 표시와 미니맵을 같이하자 8 file 뮤리온。 2011.10.08 4190
32 HUD 맵 이름 표시 스크립트 수정하기 (계속 뜨게 하기, 위치 바꾸기 등) 3 뮤리온。 2011.10.08 2886
31 HUD 맵이름표시 6 캉쿤 2011.09.14 2379
30 HUD 맵 이름을 표시해주는 스크립트입니다. 25 임희성 2011.02.12 2936
29 HUD 시트르산의 나침반 스크립트 19 file 시트르산 2011.01.23 3195
28 HUD 주인공,NPC이름 머리 나타내기 49 file 송긔 2010.11.28 6058
27 HUD [게이지바]3.0버젼「현재시간, 플레이시간, 걸음수, 윈도우 이동 추가」(HelloCoa2Ver3.0) 63 file 코아 코스튬 2010.10.30 4921
26 HUD [게이지바]2.0버젼「체력,마나,경험치,직업,캐릭터,레벨,돈,맵이름」(HelloCoa2Ver2.0) 67 file 코아 코스튬 2010.10.23 5550
25 HUD MOG_Active_Hud 3 file Bera 2010.09.11 2468
24 HUD MOG_C_HUD. 6 file Bera 2010.09.11 2329
23 HUD HUD Menu 2.0 by Raziel 3 Alkaid 2010.09.07 2031
22 HUD 강화 나침반 스크립트 (원본 by 허걱) 16 file JACKY 2010.08.16 3105
21 HUD 캐릭터 아래 SP,HP표시해주는 스크립트 33 file 김!제스! 2010.08.04 4269
20 HUD 맵이름스크립트 52 file 이안 2010.01.17 3552
19 HUD 이름띄우기스크립트 - [ID홍길동] 이 아닌 [홍길동]으로 표기하기 27 블루레스 2009.11.06 4054
18 HUD [VX 가능] 이벤트 이름 띄우기 41 file 독도2005 2009.08.22 3901
17 HUD [맵이동시 맵이름을 표시] 심플한 디자인 36 file 제로스S2 2009.08.05 5000
16 HUD 머리위에 직업명을 표시해줍니다... 9 file 제로스S2 2009.08.03 2465
» HUD HUD Menu 1.2 by Raziel 6 file 백호 2009.02.22 2390
Board Pagination Prev 1 2 Next
/ 2