질문과 답변

Extra Form

#--# Basic Enemy HP Bars v 2.8.2
#
# Adds customizable hp bars to enemies in battle. See configuration
#  below for more detail. Also allows for the option of using a nice
#  graphical hp bar from a image file.
#
# Usage: Plug and play, customize as needed.
#
#------#
#-- Script by: V.M of D.T
#
#- Questions or comments can be:
#    given by email: sumptuaryspade@live.ca
#    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
#   All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
#
#--- Free to use in any project, commercial or non-commercial, with credit given
# - - Though a donation's always a nice way to say thank you~ (I also accept actual thank you's)
 
#Customization starts here:
module DTP_HP
  #Whether to place the hp bar above or below the enemy
  ABOVE_MONSTER = true
  #Whether to use a custome image or not:
  #Image would be placed in Graphics/System and named Custom_HP.png
  CUSTOM_BAR = false
  #Whether to include the hp bar or not
  USE_HP_BAR = true
  #Whether to include an mp bar or not
  USE_MP_BAR = true
 
  #The width of the hp bar
  BAR_WIDTH = 66
  #The height of the hp bar
  BAR_HEIGHT = 5
  #The width of the border around the hp bar
  BORDER_WIDTH = 1
  #The height of the border around the hp bar
  BORDER_HEIGHT = 1
  #Offset the hp bar along the x-axis(left,right)
  BAR_OFFSET_X = 0
  #Offset the hp bar along the y-axis(up,down)
  BAR_OFFSET_Y = 0
 
  #Color for the back of the hp bar
  COLOR_BAR_BACK = Color.new(0,0,0,200)
  #First color for the hp bar gradient
  COLOR_BAR_1 = Color.new(255,0,0)
  #Second color for the hp bar gradient
  COLOR_BAR_2 = Color.new(200,100,100)
  #Outside border color
  COLOR_BORDER_1 = Color.new(0,0,0,185)
  #Inside border color
  COLOR_BORDER_2 = Color.new(255,255,255,185)
  #First color for the mp bar gradient
  MP_COLOR_BAR_1 = Color.new(0,175,255)
  #Second color fot he mp bar gradient
  MP_COLOR_BAR_2 = Color.new(0,0,255)
 
  #Whether to display text or not
  USE_TEXT = true
  #Text to be displayed, chp = current hp, mhp = max hp, php = percentage hp
  #Examples: "php%" or "chp/mhp" or "chp - php%"
  TEXT_DISPLAY = "chp"
  #Offset for the text along the x-axis(left,right)
  TEXT_OFFSET_X = 5
  #Offset for the text along the y-axis(up,down)
  TEXT_OFFSET_Y = -24
  #Size of the displayed text
  TEXT_SIZE = Font.default_size
  #Font of the displayed text
  TEXT_FONT = Font.default_name
 
  #Show bars only when specific actor in party. Array format. Example: [8,7]
  #Set to [] to not use actor only
  SPECIFIC_ACTOR = []
  #Show enemy hp bar only if certain state is applied (like a scan state)
  #Set to 0 to not use state only
  SCAN_STATE = 0
  #Enemies will show hp bar as long as they have been affected but scan state
  #at least once before
  SCAN_ONCE = false
  #Hp bars will only show when you are targetting a monster
  ONLY_ON_TARGET = false
 
  #Text to display if it's a boss monster, accepts same arguments
  BOSS_TEXT = "???"
  #The width of the boss hp bar
  BOSS_BAR_WIDTH = 66
  #The height of the boss hp bar
  BOSS_BAR_HEIGHT = 5
  #The width of the border around the boss hp bar
  BOSS_BORDER_WIDTH = 1
  #The height of the border around the boss hp bar
  BOSS_BORDER_HEIGHT = 1
  #ID's of boss monsters in array format.
  BOSS_MONSTERS = []
end
#Customization ends here
 
class Sprite_Battler
  alias hpbar_update update
  alias hpbar_dispose dispose
  def update
    hpbar_update
    return unless @battler.is_a?(Game_Enemy)
    if @battler
      update_hp_bar
    end
  end
  def update_hp_bar
    boss = DTP_HP::BOSS_MONSTERS.include?(@battler.enemy_id)
    setup_bar if @hp_bar.nil?
    if @text_display.nil?
      @text_display = Sprite_Base.new(self.viewport)
      @text_display.bitmap = Bitmap.new(100,DTP_HP::TEXT_SIZE)
      @text_display.bitmap.font.size = DTP_HP::TEXT_SIZE
      @text_display.bitmap.font.name = DTP_HP::TEXT_FONT
      @text_display.x = @hp_bar.x + DTP_HP::TEXT_OFFSET_X
      @text_display.y = @hp_bar.y + DTP_HP::TEXT_OFFSET_Y
      @text_display.z = 105
    end
    determine_visible
    return unless @hp_bar.visible
    if @hp_bar.opacity != self.opacity
      @hp_bar.opacity = self.opacity
      @mp_bar.opacity = @hp_bar.opacity if DTP_HP::USE_MP_BAR
    end
    @hp_bar.bitmap.clear
    if !boss
      width = DTP_HP::BAR_WIDTH
      height = DTP_HP::BAR_HEIGHT
      bwidth = DTP_HP::BORDER_WIDTH
      bheight = DTP_HP::BORDER_HEIGHT
    else
      width = DTP_HP::BOSS_BAR_WIDTH
      height = DTP_HP::BOSS_BAR_HEIGHT
      bwidth = DTP_HP::BOSS_BORDER_WIDTH
      bheight = DTP_HP::BOSS_BORDER_HEIGHT
    end
    btotal = (bwidth + bheight) * 2
    rwidth = @hp_bar.bitmap.width
    rheight = @hp_bar.bitmap.height
    if !DTP_HP::CUSTOM_BAR && DTP_HP::USE_HP_BAR
      @hp_bar.bitmap.fill_rect(0,0,rwidth,rheight,DTP_HP::COLOR_BAR_BACK)
      @hp_bar.bitmap.fill_rect(bwidth,bheight,rwidth-bwidth*2,rheight-bheight*2,DTP_HP::COLOR_BORDER_2)
      @hp_bar.bitmap.fill_rect(bwidth*2,bheight*2,width,height,DTP_HP::COLOR_BORDER_1)
    end
    hp_width = @battler.hp_rate * width
    if DTP_HP::USE_HP_BAR
      @hp_bar.bitmap.gradient_fill_rect(bwidth*2,bheight*2,hp_width,height,DTP_HP::COLOR_BAR_1,DTP_HP::COLOR_BAR_2)
    end
    if DTP_HP::CUSTOM_BAR && DTP_HP::USE_HP_BAR
      border_bitmap = Bitmap.new("Graphics/System/Custom_HP.png")
      rect = Rect.new(0,0,border_bitmap.width,border_bitmap.height)
      @hp_bar.bitmap.blt(0,0,border_bitmap,rect)
    end
    if DTP_HP::USE_MP_BAR
      @mp_bar.bitmap.clear
      if !DTP_HP::CUSTOM_BAR
        @mp_bar.bitmap.fill_rect(0,0,rwidth,rheight,DTP_HP::COLOR_BAR_BACK)
        @mp_bar.bitmap.fill_rect(bwidth,bheight,rwidth-bwidth*2,rheight-bheight*2,DTP_HP::COLOR_BORDER_2)
        @mp_bar.bitmap.fill_rect(bwidth*2,bheight*2,width,height,DTP_HP::COLOR_BORDER_1)
      end
      mp_width = @battler.mp_rate * width
      @mp_bar.bitmap.gradient_fill_rect(bwidth*2,bheight*2,mp_width,height,DTP_HP::MP_COLOR_BAR_1,DTP_HP::MP_COLOR_BAR_2)
      if DTP_HP::CUSTOM_BAR
        border_bitmap = Bitmap.new("Graphics/System/Custom_HP.png")
        rect = Rect.new(0,0,border_bitmap.width,border_bitmap.height)
        @mp_bar.bitmap.blt(0,0,border_bitmap,rect)
      end
    end
    return unless DTP_HP::USE_TEXT
    @text_display.opacity = @hp_bar.opacity if @text_display.opacity != @hp_bar.opacity
    @text_display.bitmap.clear
    text = DTP_HP::TEXT_DISPLAY.clone
    text = DTP_HP::BOSS_TEXT.clone if DTP_HP::BOSS_MONSTERS.include?(@battler.enemy_id)
    text.gsub!(/chp/) {@battler.hp}
    text.gsub!(/mhp/) {@battler.mhp}
    text.gsub!(/php/) {(@battler.hp_rate * 100).to_i}
    @text_display.bitmap.draw_text(0,0,100,@text_display.height,text)
  end
  def setup_bar
    boss = DTP_HP::BOSS_MONSTERS.include?(@battler.enemy_id)
    @hp_bar = Sprite_Base.new(self.viewport)
    if !boss
      width = DTP_HP::BAR_WIDTH + DTP_HP::BORDER_WIDTH * 4
      height = DTP_HP::BAR_HEIGHT + DTP_HP::BORDER_HEIGHT * 4
    else
      width = DTP_HP::BOSS_BAR_WIDTH + DTP_HP::BOSS_BORDER_WIDTH * 4
      height = DTP_HP::BOSS_BAR_HEIGHT + DTP_HP::BOSS_BORDER_HEIGHT * 4
    end
    @hp_bar.bitmap = Bitmap.new(width,height)
    @hp_bar.x = self.x - @hp_bar.width / 2 + DTP_HP::BAR_OFFSET_X
    @hp_bar.y = self.y + DTP_HP::BAR_OFFSET_Y - self.bitmap.height - @hp_bar.height
    @hp_bar.y = self.y + DTP_HP::BAR_OFFSET_Y unless DTP_HP::ABOVE_MONSTER
    @hp_bar.x = 0 if @hp_bar.x < 0
    @hp_bar.y = 0 if @hp_bar.y < 0
    @hp_bar.z = 104
    if DTP_HP::USE_MP_BAR
      @mp_bar = Sprite_Base.new(self.viewport)
      @mp_bar.bitmap = Bitmap.new(@hp_bar.width,@hp_bar.height)
      @mp_bar.x = @hp_bar.x + 6
      @mp_bar.y = @hp_bar.y + @mp_bar.height - 3
      @mp_bar.z = 103
    end
  end
  def determine_visible
    if !@battler.alive?
      @hp_bar.visible = false
      @mp_bar.visible = false if @mp_bar
      @text_display.visible = false
      if DTP_HP::SCAN_ONCE and DTP_HP::SCAN_STATE == 1
        $game_party.monster_scans[@battler.enemy_id] = true
      end
      return if !@battler.alive?
    end
    @hp_bar.visible = true
    if DTP_HP::SCAN_STATE != 0
      @hp_bar.visible = false
      @hp_bar.visible = true if @battler.state?(DTP_HP::SCAN_STATE)
      if DTP_HP::SCAN_ONCE
        @hp_bar.visible = true if $game_party.monster_scans[@battler.enemy_id] == true
        $game_party.monster_scans[@battler.enemy_id] = true if @hp_bar.visible
      end
    end
    if !DTP_HP::SPECIFIC_ACTOR.empty?
      @hp_bar.visible = false unless DTP_HP::SCAN_STATE != 0
      DTP_HP::SPECIFIC_ACTOR.each do |i|
        next unless $game_party.battle_members.include?($game_actors[i])
        @hp_bar.visible = true
      end
    end
    if DTP_HP::ONLY_ON_TARGET
      return unless SceneManager.scene.is_a?(Scene_Battle)
      return unless SceneManager.scene.enemy_window
      @hp_bar.visible = SceneManager.scene.target_window_index == @battler.index
      @hp_bar.visible = false if !SceneManager.scene.enemy_window.active
    end
    @text_display.visible = false if !@hp_bar.visible
    @text_display.visible = true if @hp_bar.visible
    @mp_bar.visible = @hp_bar.visible if DTP_HP::USE_MP_BAR
  end
  def dispose
    @hp_bar.dispose if @hp_bar
    @mp_bar.dispose if @mp_bar
    @text_display.dispose if @text_display
    hpbar_dispose
  end
end
 
class Scene_Battle
  attr_reader  :enemy_window
  def target_window_index
    begin
    @enemy_window.enemy.index
    rescue
      return -1
    end
  end
end
 
class Game_Party
  alias hp_bar_init initialize
  attr_accessor  :monster_scans
  def initialize
    hp_bar_init
    @monster_scans = []
  end
end

97bb63820b54410b92e30dcc31e5c393.png

이 스크립트인데 몬스터의 체력을 수치로 표현하는 대신에 그 몬스터의 이름이 나타나게 하는 방법은 없나요? (진지합니다)

혹시 몰라서 첨부파일에 텍스트 파일로 올려드릴게요.

Comment '2'
  • profile
    러닝은빛 2014.12.09 17:55

    이 스크립트에서 draw_text 를 검색하면 나오는 코드에서 마지막 인자에 text 변수가 오는데 그거 대신 @battler.name 을 넣어주세요.

    @text_display.bitmap.draw_text(0,0,100,@text_display.height,@battler.name)

    이런식으로 고치면 됩니다.

  • ?
    작삼 2014.12.09 21:28
    감사합니다!
    덕분에 해결되었습니다^^

List of Articles
종류 분류 제목 글쓴이 날짜 조회 수
공지 묻고 답하기 가이드 습작 2014.06.14 12456
RMMV 스킬사용시 MP가아닌소모 2 쿨쿨팬더 2017.07.18 153
RMVXA 스킬사용시 HP를 소비하게 하고 싶습니다. 1 쇼몬_아레하 2012.08.26 1181
RMXP 스킬북 만드는법 1 Ka이라 2014.10.22 452
RMVX 스킬만들때 분산도가 뭔가요? 4 마차군 2012.01.01 3077
RMVX 스킬만드는데 막혀요 스크립트조작 방법좀 가르쳐 주실분 바론아벨 2012.06.06 1315
스크립트 사용 RMVXA 스킬레벨 스크립트 어떻게 사용하는건지 이해를 못하겠습니다.. 도와주세요 ㅠㅠ Redkanes 2020.03.30 48
RMVX 스킬관련 질문입니다. (연속으로 질문드려 죄송해요;;;) 11 니노미야 2010.09.22 947
턴제 전투 RMVXA 스킬 효과 범위 관련 질문 Aduie 2019.10.17 50
RMVX 스킬 필요조건 관련 스크립트를 조정하고 싶습니다. 3 톰소여동생 2012.06.05 1866
RMVXA 스킬 툴셋에 관련하여 2 RPGvvxx 2016.03.26 109
스크립트 추천 RMVX 스킬 턴안넘어가고 즉시시전 스크립트 듀라듀라셀 2020.12.01 130
RMMV 스킬 타겟을 1명으로 제한 1 잠행인 2016.09.28 118
RMVX 스킬 컷인 ;;;;; 3 file 텐가와 2011.01.21 651
RMVX 스킬 커먼 이벤트 라유 2010.12.31 525
RMVX 스킬 캐릭터 컷인 5 텐가와 2011.01.19 704
RMXP 스킬 추가, 제거를 스크립트로 할수있나요? 얼정 2012.05.12 1619
RMVX 스킬 중 일부를 기본커맨드로 하기 2 뱀딸기 2012.02.23 2000
RMVXA 스킬 적용범위와 적 그룹 수를 변경... 6 휘휘 2014.01.29 706
RMVXA 스킬 적용 중 질문드리고 싶습니다 1 file AccelHacker 2016.02.26 137
RMXP 스킬 이미지만드는 법 질문드립니다. 1 시키부 2011.04.25 1420
Board Pagination Prev 1 ... 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 ... 516 Next
/ 516