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 직업명띄우기 스크립트 2 백호 2009.02.21 1123
33 HUD 맵명을 표시하는 스크립트 한글로 번역한것 백호 2009.02.21 1257
32 HUD Advanced HUD Script 3 file 백호 2009.02.22 1341
31 HUD 맵 이름 표시 by Slipknot@rmxp.net (SDK호환) 2 백호 2009.02.22 1463
30 HUD 게임 플레이시 맵의 이름을 표시하는 스크립트 1 file 백호 2009.02.21 1919
29 HUD 맵 이름 뛰우기 10 WMN 2008.03.17 1966
28 HUD HUD Menu 2.0 by Raziel 3 Alkaid 2010.09.07 2031
27 HUD MOG_C_HUD. 6 file Bera 2010.09.11 2329
26 HUD 적의 남은 HP만큼 적의 이름 색깔 변하는 스크립트 6 file 백호 2009.02.21 2337
25 HUD 맵이름표시 6 캉쿤 2011.09.14 2381
24 HUD HUD Menu 1.2 by Raziel 6 file 백호 2009.02.22 2390
23 HUD 머리위에 직업명을 표시해줍니다... 9 file 제로스S2 2009.08.03 2465
22 HUD MOG_Active_Hud 3 file Bera 2010.09.11 2468
21 HUD 맵 이름 표시 스크립트 수정하기 (계속 뜨게 하기, 위치 바꾸기 등) 3 뮤리온。 2011.10.08 2886
20 HUD 맵이름 스크립트 1 file 긔염둥이♥ 2012.05.19 2913
19 HUD 맵 이름을 표시해주는 스크립트입니다. 25 임희성 2011.02.12 2936
18 HUD 맵이름 넣기(bs님의 강의랑 다르게 스크립트로) 16 file 아방스 2007.11.09 2981
17 HUD HP/SP 상태를 표시해주는 간이 윈도우 3 file 백호 2009.02.21 3067
16 HUD 넷플레이 HUD표시 2 file 백호 2009.02.22 3094
15 HUD 강화 나침반 스크립트 (원본 by 허걱) 16 file JACKY 2010.08.16 3105
Board Pagination Prev 1 2 Next
/ 2