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 기타 Rataime's Multi Demo 1 file 백호 2009.02.22 834
980 스킬 Grouping and Detail (Items/Skills) 1 file 백호 2009.02.21 839
979 기타 Sized Events 0.1 by Toby@rmxp.org file 백호 2009.02.22 845
978 이동 및 탈것 Memorize Location R2 by dubealex file 백호 2009.02.22 846
977 아이템 SG_Escape Only Items by sandgolem (SDK호환) 백호 2009.02.22 850
976 기타 [XP/VX/VXA] Map Screenshot by LiTTleDRAgo 1 Alkaid 2014.02.13 850
975 기타 Quick Animations by SephirothSpawn (SDK호환) 백호 2009.02.22 851
974 기타 Introduction & optional Splash 2.1 by SephirothSpawn (SDK호환) 1 백호 2009.02.22 860
973 이동 및 탈것 SG_Wait for Move Completion Fix by sandgolem (SDK호환) 백호 2009.02.22 860
972 스킬 [KGC] Skill Grouping 백호 2009.02.21 861
971 기타 RM2K Facesets, Inn & Windowskin Colors by DerVVulfman@rmxp.org 1 file 백호 2009.02.22 866
970 기타 Difficulty Options by SephirothSpawn 백호 2009.02.22 869
969 메뉴 1-Scene CMS 1.03 by LegACy@rmxp.org (SDK호환) file 백호 2009.02.22 871
968 온라인 인터넷 웹 상에서의 시간을 취득하는 스크립트 1 이우 2016.05.24 872
967 기타 Dynamic Stores by Astro_mech@rmxp.net 1 file 백호 2009.02.22 878
966 기타 아래 스크립트에 대한 Guillaume777님의 개량판입니다. 백호 2009.02.22 880
965 아이템 Easy Item & Gold Gain by SephirothSpawn (SDK호환) 백호 2009.02.22 880
964 기타 [XP/VX/VXA] Drago Core Engine Alkaid 2014.02.13 883
963 기타 SG_Settings Control by sandgolem 백호 2009.02.22 884
962 메뉴 Customizable Ring Menu by SephirothSpawn 백호 2009.02.22 884
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