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
981 HUD [게이지바]3.0버젼「현재시간, 플레이시간, 걸음수, 윈도우 이동 추가」(HelloCoa2Ver3.0) 63 file 코아 코스튬 2010.10.30 4921
980 메시지 메세지플러스3.1v스크립트(얼굴표시,메세지색상,속도등정하는스크립트) 8 백호 2009.02.21 4878
979 윈도우_게이지 (HP, SP, 경험치<소수점포함>… 12 WMN 2008.04.06 4856
978 메뉴 1인 캐릭터 메뉴 스크립트 27 file - 하늘 - 2009.08.06 4788
977 이동 및 탈것 아하! 그렇구나의 3D 신기술 체험 30 아하!잘봤어요. 2010.02.28 4772
976 전투 사이드뷰 배틀 (2003 형식으 전투)| 12 file 아방스 2007.11.09 4744
975 메시지 메세지 표시 업그레이드 11 file 백호 2009.02.21 4723
974 전투 사이드뷰 방식 스크립트. 8 file 백호 2009.02.21 4636
973 HUD 새로운방법의 맵이름 표시 31 file 백호 2009.02.21 4617
972 그래픽 부드럽게 화면이 움직이는 스크립트 입니다. 16 GangSin 2012.09.12 4587
971 전투 ABP 액알 (Action Battle Player) 14 file 백호 2009.02.22 4556
» HUD HP과 SP 바 19 Man... 2008.11.04 4534
969 이름입력 한글 이름 입력 15 ok하승헌 2010.02.18 4487
968 게이지바 만들기 [헬악이님 제공] 12 file 아방스 2007.11.09 4414
967 메뉴 메뉴에 그림넣기 4 file 백호 2009.02.22 4411
966 퀘스트 퀘스트 다이어리 15 백호 2009.02.21 4406
965 전투 XAS 여러가지버전. 9 §포뇨§ 2010.02.23 4395
964 온라인 온라인 스크립트입니다^^(예제파일) 7 캉쿤 2011.09.24 4390
963 타이틀/게임오버 타이틀 화면 커스터마이즈 (타이틀 메뉴 바꾸는 스크립트) 9 file №1 2012.08.04 4390
962 미니맵 미니맵 만들기~! 14 file 블리치캐릭셋원함 2010.11.24 4348
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ... 52 Next
/ 52