XP 스크립트

HP & SP Bars on Map
Version: 1.0


Last Update
May 23, 2006.

Introduction

This is an updated and better version of my old HP bar script, this one will work faster and have some new features like the SP bar.

Features
  • Display nice bars for the HP and SP.
  • Allow the player change the current actor by pressing A (shift) and R or L (numpad).
  • Display the name and level of the current actor.
  • Changes the x position of the timer if the bars are showing.
Screenshots


#==============================================================================
# ** HP & SP Bars on Map
#------------------------------------------------------------------------------
# Slipknot
# 1.0
# 05.23.06
#==============================================================================

#------------------------------------------------------------------------------
# SDK Log
#------------------------------------------------------------------------------
SDK.log('HP & SP Bars on Map', 'Slipknot', 1.0, '05.23.06')

#------------------------------------------------------------------------------
# Begin SDK Enabled Check
#------------------------------------------------------------------------------
if SDK.state('HP & SP Bars on Map') == true

module MapBars_Settings
 #--------------------------------------------------------------------------
 HPBar = true
 #--------------------------------------------------------------------------
 SPBar = true
 #--------------------------------------------------------------------------
 LevelText = 'Lv: '
 #--------------------------------------------------------------------------
 AllowChange = true
 #--------------------------------------------------------------------------
end

#------------------------------------------------------------------------------
# Begin Scene_Map Edit
#------------------------------------------------------------------------------
class Scene_Map
 #--------------------------------------------------------------------------
 # * Public Instance Variables
 #--------------------------------------------------------------------------
 attr_reader(:sprite_bars)
 #--------------------------------------------------------------------------
 # * Alias
 #--------------------------------------------------------------------------
 alias slipknot_mapbars_maindraw main_draw
 alias slipknot_mapbars_updgraphics update_graphics
 alias slipknot_mapbars_maindispose main_dispose
 #--------------------------------------------------------------------------
 # * Main Draw
 #--------------------------------------------------------------------------
 def main_draw
    slipknot_mapbars_maindraw
    @sprite_bars = Sprite_Bars.new
 end
 #--------------------------------------------------------------------------
 # * Main Dispose
 #--------------------------------------------------------------------------
 def main_dispose
    slipknot_mapbars_maindispose
    @sprite_bars.dispose
 end
 #--------------------------------------------------------------------------
 # * Update Graphics
 #--------------------------------------------------------------------------
 def update_graphics
    slipknot_mapbars_updgraphics
    @sprite_bars.update
 end
end
#------------------------------------------------------------------------------
# End Scene_Map Edit
#------------------------------------------------------------------------------

#------------------------------------------------------------------------------
# Begin Interpreter Edit
#------------------------------------------------------------------------------
class Interpreter
 #--------------------------------------------------------------------------
 # * Public Instance Variables
 #--------------------------------------------------------------------------
 attr_reader(:hp_bar, :sp_bar, :bars_index)
 attr_accessor(:bars_need_refresh)
 #--------------------------------------------------------------------------
 # * Alias
 #--------------------------------------------------------------------------
 alias slipknot_mapbars_initialize initialize
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize(depth = 0, main = false)
    slipknot_mapbars_initialize(depth, main)
    if main
  @bars_need_refresh = true
  @hp_bar = MapBars_Settings::HPBar
  @sp_bar = MapBars_Settings::SPBar
  @bars_index = 0
    end
 end
 #--------------------------------------------------------------------------
 # * Bar's Actor Index
 #--------------------------------------------------------------------------
 def bars_index=(index)
    if @bars_index != index
  @bars_index = index
  @bars_need_refresh = true
    end
    return true
 end
 def set_bars_index(index = 0)
    self.bars_index = (index)
 end
 #--------------------------------------------------------------------------
 # * Show HP Bar
 #--------------------------------------------------------------------------
 def show_hp_bar(value = true)
    @hp_bar = value
    @bars_need_refresh = true
 end
 #--------------------------------------------------------------------------
 # * Show SP Bar
 #--------------------------------------------------------------------------
 def show_sp_bar(value = true)
    @sp_bar = value
    @bars_need_refresh = true
 end
end
#------------------------------------------------------------------------------
# End Interpreter Edit
#------------------------------------------------------------------------------

#------------------------------------------------------------------------------
# Begin Spriteset_Map Edit
#------------------------------------------------------------------------------
class Spriteset_Map
 #--------------------------------------------------------------------------
 # * Alias
 #--------------------------------------------------------------------------
 alias slipknot_mapbars_updpicturesprites update_picture_sprites
 #--------------------------------------------------------------------------
 # * Update Picture Sprites
 #--------------------------------------------------------------------------
 def update_picture_sprites
    @timer_sprite.x = ($game_system.map_interpreter.sp_bar ||
  $game_system.map_interpreter.sp_bar) ? 400 : 552
    slipknot_mapbars_updpicturesprites
 end
end
#------------------------------------------------------------------------------
# End Spriteset_Map Edit
#------------------------------------------------------------------------------

class Sprite_Bars < Window_Base
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize
    @sprite = Sprite.new()
    @sprite.bitmap = Bitmap.new(144, 82)
    @sprite.x = 488
    @sprite.y = 8
    @old_hp = @old_sp = false
    interpreter.bars_need_refresh = true
    update
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
    if ! hp? && ! sp?
  bitmap.clear
  return
    end
    if MapBars_Settings::AllowChange && Input.press?(11)
  if Input.repeat?(Input::L)
 interpreter.bars_index = (interpreter.bars_index - 1) % $game_party.actors.size
  end
  if Input.repeat?(Input::R)
 interpreter.bars_index = (interpreter.bars_index + 1) % $game_party.actors.size
  end
    end
    actor = $game_party.actors[interpreter.bars_index]
    if need_refresh?
  bitmap.clear
  lvt = MapBars_Settings::LevelText + actor.level.to_s
  width = bitmap.text_size(lvt).width
  draw_text(1, 0, 143 - width, 22, actor.name)
  draw_text(143 - width, 0, width, 22, lvt)
    end  
    if hp? && (need_refresh? || @old_hp != actor.hp)
  draw_hp_bar(actor, 0, 22)
  @old_hp = actor.hp
  hp = true
    end
    if sp? && (need_refresh? || @old_sp != actor.sp)
  y = hp != nil ? 30 : 0
  draw_sp_bar(actor, 0, y + 22)
  @old_sp = actor.sp
    end
    interpreter.bars_need_refresh = false
 end
 #--------------------------------------------------------------------------
 # * @sprite.bitmap & $game_system.map_interpreter
 #--------------------------------------------------------------------------
 def bitmap
    @sprite.bitmap
 end
 def interpreter
    $game_system.map_interpreter
 end
 #--------------------------------------------------------------------------
 # * Return Interpreter Variables
 #--------------------------------------------------------------------------
 def need_refresh?
    interpreter.bars_need_refresh
 end
 def hp?
    interpreter.hp_bar
 end
 def sp?
    interpreter.sp_bar
 end
 #--------------------------------------------------------------------------
 # * Dispose
 #--------------------------------------------------------------------------
 def dispose
    @sprite.dispose
    bitmap.dispose
 end
 #--------------------------------------------------------------------------
 # * Draw HP Bar
 #--------------------------------------------------------------------------
 def draw_hp_bar(actor, x, y)
    bitmap.fill_rect(x, y, 144, 30, Color.new(0, 0, 0, 0))
    bitmap.font.color = system_color
    draw_text(x, y, 32, 30, $data_system.words.hp)
    hp_x = x + 36
    x += 32
    bitmap.fill_rect(x, y + 14, 112, 10, Color.new(0, 0, 0))
    width = 112.0 * actor.hp / actor.maxhp
    red = 144.0
    step = 80.0 / (width - 2).to_f
    for p in 0...(width - 2)
  bitmap.fill_rect(x + p + 1, y + 15, 1, 8, Color.new(red, 64, 32))
  red += step
    end
    bitmap.font.size -= 2
    bitmap.font.color = actor.hp == 0 ? knockout_color :
  actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
    draw_text(hp_x, y, 48, 26, actor.hp.to_s, 2)
    bitmap.font.color = normal_color
    draw_text(hp_x + 48, y, 12, 26, '/', 1)
    draw_text(hp_x + 60, y, 48, 26, actor.maxhp.to_s)
    bitmap.font.size += 2
 end
 #--------------------------------------------------------------------------
 # * Draw SP Bar
 #--------------------------------------------------------------------------
 def draw_sp_bar(actor, x, y)
    bitmap.fill_rect(x, y, 144, 30, Color.new(0, 0, 0, 0))
    self.bitmap.font.color = system_color
    draw_text(x, y, 32, 30, $data_system.words.sp)
    sp_x = x + 36
    x += 32
    bitmap.fill_rect(x, y + 14, 112, 10, Color.new(0, 0, 0))
    width = 112.0 * actor.sp / actor.maxsp
    blue = 144.0
    step = 80.0 / (width - 2).to_f
    for p in 0...(width - 2)
  bitmap.fill_rect(x + p + 1, y + 15, 1, 8, Color.new(32, 64, blue))
  blue += step
    end
    bitmap.font.size -= 2
    bitmap.font.color = actor.sp == 0 ? knockout_color :
  actor.sp <= actor.maxhp / 4 ? crisis_color : normal_color
    draw_text(sp_x, y, 46, 26, actor.sp.to_s, 2)
    bitmap.font.color = normal_color
    draw_text(sp_x + 46, y, 10, 26, '/', 1)
    draw_text(sp_x + 58, y, 46, 26, actor.maxsp.to_s)
    bitmap.font.size += 2
 end
 #--------------------------------------------------------------------------
 # * Draw Outline Text
 #--------------------------------------------------------------------------
 def draw_text(x, y, width, height, string, align = 0)
    col = bitmap.font.color.dup
    bitmap.font.color = Color.new(32, 32, 32, col.alpha)
    bitmap.draw_text(x - 1, y, width, height, string, align)
    bitmap.draw_text(x, y - 1, width, height, string, align)
    bitmap.draw_text(x + 1, y, width, height, string, align)
    bitmap.draw_text(x, y + 1, width, height, string, align)
    bitmap.font.color = col
    bitmap.draw_text(x, y, width, height, string, align)
 end
end

#------------------------------------------------------------------------------
# End SDK Enabled Test
#------------------------------------------------------------------------------
end
Comment '19'

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 스크립트 자료 게시물 작성시 주의사항 습작 2012.12.24 6153
34 HUD 맵이름 넣기(bs님의 강의랑 다르게 스크립트로) 16 file 아방스 2007.11.09 2981
33 HUD 맵 이름 뛰우기 10 WMN 2008.03.17 1966
» HUD HP과 SP 바 19 Man... 2008.11.04 4534
31 HUD 맵이름표시 ps인간 2009.01.23 3441
30 HUD 게임 플레이시 맵의 이름을 표시하는 스크립트 1 file 백호 2009.02.21 1919
29 HUD HP/SP 상태를 표시해주는 간이 윈도우 3 file 백호 2009.02.21 3067
28 HUD 적의 남은 HP만큼 적의 이름 색깔 변하는 스크립트 6 file 백호 2009.02.21 2337
27 HUD 맵명을 표시하는 스크립트 한글로 번역한것 백호 2009.02.21 1257
26 HUD xp대화창에 얼굴, 이름 넣기!! [방법두 있음] 3 백호 2009.02.21 3545
25 HUD 직업명띄우기 스크립트 2 백호 2009.02.21 1123
24 HUD 새로운방법의 맵이름 표시 31 file 백호 2009.02.21 4617
23 HUD Advanced HUD Script 3 file 백호 2009.02.22 1341
22 HUD 맵 이름 표시 by Slipknot@rmxp.net (SDK호환) 2 백호 2009.02.22 1463
21 HUD 넷플레이 HUD표시 2 file 백호 2009.02.22 3094
20 HUD HUD Menu 1.2 by Raziel 6 file 백호 2009.02.22 2390
19 HUD 머리위에 직업명을 표시해줍니다... 9 file 제로스S2 2009.08.03 2465
18 HUD [맵이동시 맵이름을 표시] 심플한 디자인 36 file 제로스S2 2009.08.05 5000
17 HUD [VX 가능] 이벤트 이름 띄우기 41 file 독도2005 2009.08.22 3902
16 HUD 이름띄우기스크립트 - [ID홍길동] 이 아닌 [홍길동]으로 표기하기 27 블루레스 2009.11.06 4054
15 HUD 맵이름스크립트 52 file 이안 2010.01.17 3552
Board Pagination Prev 1 2 Next
/ 2