Vai al contenuto

Rilevato Ad-Blocker. Per favore disabilita il tuo adblocker quando navighi su makerando.com - Non c'è nessun annuncio invasivo.

  • Chatbox

    You don't have permission to chat.
    Load More
Ally

HUD Kingdom Hearts HUD

Recommended Posts

Nome Script: Kingdom Hearts HUD
Versione: 1.0(?)
Autore/i: By BigEd781 Graphics by Celianna

Informazioni:
Lo script permette di avere un hud in stile Kingdom Hearts

Istruzioni:
Copiare lo script sotto materials e le immagini della cartella Picture della demo in quella del proprio progetto

Script:

#--------------------------------------------------------------------
# A list of colors that you may use to configure the font and gauge
# colors in the config section.  Simply replace the last part of each
# statement, i.e., the part in the brackets <> below:
#
#                       Colors::<White>
#--------------------------------------------------------------------
# Continue below for the configuration section
#--------------------------------------------------------------------
# * Revisions
#   10/10/09 - Creation
#   10/19/09 - Added show_hud command.
#              Added visibility options by switch, map name, or leader
#   11/05/09 - Added fadout option
#   11/08/09 - Fixed bug caused by stale event listeners
#--------------------------------------------------------------------
# * Basic Commands
#--------------------------------------------------------------------
# * You can force the HUD to hide by using the "Script..."
#   event command with this text:
#
#      $scene.hide_hud
#
#   You can show the hud once again by using this line:
#
#      $scene_show_hud
#--------------------------------------------------------------------
module Colors

  AliceBlue = Color.new(240,248,255)
  AntiquaWhite = Color.new(250,235,215)
  Aqua = Color.new(0,255,255)
  Aquamarine = Color.new(127,255,212)
  Azure = Color.new(240,255,255)
  Beige = Color.new(245,245,220)
  Bisque = Color.new(255,228,196)
  Black = Color.new(0,0,0)
  BlanchedAlmond = Color.new(255,255,205)
  Blue = Color.new(0,0,255)
  BlueViolet = Color.new(138,43,226)
  Brown = Color.new(165,42,42)
  BurlyWood = Color.new(222,184,135)
  CadetBlue = Color.new(95,158,160)
  Chartreuse = Color.new(127,255,0)
  Chocolate = Color.new(210,105,30)
  Coral = Color.new(255,127,80)
  CornFlowerBlue = Color.new(100,149,237)
  Cornsilk = Color.new(255,248,220)
  Crimson = Color.new(220,20,60)
  Cyan = Color.new(0,255,255)
  DarkBlue = Color.new(0,0,139)
  DarkCyan = Color.new(0,139,139)
  DarkGoldenrod = Color.new(184,134,11)
  DarkGray = Color.new(169,169,169)
  DarkGreen = Color.new(0,100,0)
  DarkKhaki= Color.new(189,183,107)
  DarkMagenta = Color.new(139,0,139)
  DarkOliveGreen = Color.new(85,107,47)
  DarkOrange = Color.new(255,140,0)
  DarkRed = Color.new(139,0,0)
  DarkSalmon = Color.new(233,150,122)
  DarkSeaGreen = Color.new(143,188,143)
  DarkSlateBlue = Color.new(72,61,139)
  DarkSlateGray = Color.new(40,79,79)
  DarkTurquoise = Color.new(0,206,209)
  DarkViolet = Color.new(148,0,211)
  DeepPink = Color.new(255,20,147)
  DeepSkyBlue = Color.new(0,191,255)
  DimGray = Color.new(105,105,105)
  DodgerBlue = Color.new(30,144,255)
  FireBrick = Color.new(178,34,34)
  FloralWhite = Color.new(255,255,240)
  ForestGreen = Color.new(34,139,34)
  Fuschia = Color.new(255,0,255)
  Gainsboro = Color.new(220,220,220)
  GhostWhite = Color.new(248,248,255)
  Gold = Color.new(255,215,0)
  Goldenrod = Color.new(218,165,32)
  Gray = Color.new(128,128,128)
  Green = Color.new(0,128,0)
  GreenYellow = Color.new(173,255,47)
  Honeydew = Color.new(240,255,240)
  HotPink = Color.new(255,105,180)
  IndianRed = Color.new(205,92,92)
  Indigo = Color.new(75,0,130)
  Ivory = Color.new(255,240,240)
  Khaki = Color.new(240,230,140)
  Lavender = Color.new(230,230,250)
  LavenderBlush = Color.new(255,240,245)
  LawnGreen = Color.new(124,252,0)
  LemonChiffon = Color.new(255,250,205)
  LightBlue = Color.new(173,216,230)
  LightCoral = Color.new(240,128,128)
  LightCyan = Color.new(224,255,255)
  LightGoldenrodYellow = Color.new(250,250,210)
  LightGreen = Color.new(144,238,144)
  LightGray = Color.new(211,211,211)
  LightPink = Color.new(255,182,193)
  LightSalmon = Color.new(255,160,122)
  LightSeaGreen = Color.new(32,178,170)
  LightSkyBlue = Color.new(135,206,250)
  LightSlateGray = Color.new(119,136,153)
  LightSteelBlue = Color.new(176,196,222)
  LightYellow = Color.new(255,255,224)
  Lime = Color.new(0,255,0)
  LimeGreen = Color.new(50,205,50)
  Linen = Color.new(250,240,230)
  Magenta = Color.new(255,0,255)
  Maroon = Color.new(128,0,0)
  MediumAquamarine = Color.new(102,205,170)
  MediumBlue = Color.new(0,0,205)
  MediumOrchid = Color.new(186,85,211)
  MediumPurple = Color.new(147,112,219)
  MediumSeaGreen = Color.new(60,179,113)
  MediumSlateBlue = Color.new(123,104,238)
  MediumSpringGreen = Color.new(0,250,154)
  MediumTurquoise = Color.new(72,209,204)
  MediumVioletRed = Color.new(199,21,112)
  MidnightBlue = Color.new(25,25,112)
  MintCream = Color.new(245,255,250)
  MistyRose = Color.new(255,228,225)
  Moccasin = Color.new(255,228,181)
  NavajoWhite = Color.new(255,222,173)
  Navy = Color.new(0,0,128)
  OldLace = Color.new(253,245,230)
  Olive = Color.new(128,128,0)
  OliveDrab = Color.new(107,142,45)
  Orange = Color.new(255,165,0)
  OrangeRed = Color.new(255,69,0)
  Orchid = Color.new(218,112,214)
  PaleGoldenRod = Color.new(238,232,170)
  PaleGreen = Color.new(152,251,152)
  PaleTurquoise = Color.new(175,238,238)
  PaleVioletRed = Color.new(219,112,147)
  PapayaWhip = Color.new(255,239,213)
  PeachPuff = Color.new(255,218,155)
  Peru = Color.new(205,133,63)
  Pink = Color.new(255,192,203)
  Plum = Color.new(221,160,221)
  PowderBlue = Color.new(176,224,230)
  Purple = Color.new(128,0,128)
  Red = Color.new(255,0,0)
  RosyBrown = Color.new(188,143,143)
  RoyalBlue = Color.new(65,105,225)
  SaddleBrown = Color.new(139,69,19)
  Salmon = Color.new(250,128,114)
  SandyBrown = Color.new(244,164,96)
  SeaGreen = Color.new(46,139,87)
  Seashell = Color.new(255,245,238)
  Sienna = Color.new(160,82,45)
  Silver = Color.new(192,192,192)
  SkyBlue = Color.new(135,206,235)
  SlateBlue = Color.new(106,90,205)
  SlateGray = Color.new(112,128,144)
  Snow = Color.new(255,250,250)
  SpringGreen = Color.new(0,255,127)
  SteelBlue = Color.new(70,130,180)
  Tan = Color.new(210,180,140)
  Teal = Color.new(0,128,128)
  Thistle = Color.new(216,191,216)
  Tomato = Color.new(253,99,71)
  Turquoise = Color.new(64,244,208)
  Violet = Color.new(238,130,238)
  Wheat = Color.new(245,222,179)
  White = Color.new(255,255,255)
  WhiteSmoke = Color.new(245,245,245)
  Yellow = Color.new(255,255,0)
  YellowGreen = Color.new(154,205,50)

  GaugeGreen = Color.new(202,241,126)
  GaugeBlue = Color.new(137,222,254)

end

#--------------------------------------------------------------------
# do not touch this
class Point
  attr_reader :x
  attr_reader :y
  def initialize(x, y)
    @x, @y = x, y
  end
  def to_a
    [@x, @y]
  end
end
# or this
class ScrollDirection
  Left = 0
  Right = 1
end
#--------------------------------------------------------------------

#--------------------------------------------------------------------
# * Configuration Section
#--------------------------------------------------------------------
module HudConfig

  # The actor id of the main character in your game.
  # This will be the character in the main hud window.
  PLAYER_ID                  = 1

  # if this is set to 'true' the HUD will go opaque.
  # when the player is walking.
  TRANSPARENT_WHEN_MOVING    = false
  # this is the minimum opacity value reached while walking.
  # this should be a value between 0 and 255.
  TRANSPARENCY_WHEN_MOVING   = 255
  # this value determines how fast the HUD will fade out and in.
  # this is in incremenets per frame (60 frames per second).
  TRANSPARENCY_SWITCH_SPEED  = 2

  # If this switch is 'ON' the hud will not appear at all.
  # Set this to 'nil' to disable the feature completely
  NO_SHOW_SWITCH             = nil

  # If this text is found in a map name the hud will
  # be disabled for that map at all times.  This text
  # will be removed from the map name proper in case
  # you are using a map name script or somethin like that.
  NO_SHOW_TEXT               = 'hud no show'

  # Display an empty hud if there is no party leader?
  SHOW_IF_NO_LEADER          = false

  # Name of the player (main character) hud graphic
  PLAYER_HUD_IMAGE_NAME      = 'player_hud'
  # Use the gren and blue mp/hp gauges?
  # You may use your own graphics, but they must
  # adhere to the same format as the originals, i.e.,
  #
  #   hud_bar_hp_000.png
  #
  # Where the '000' part is a multiple of five, from 0-100.
  PLAYER_USE_CUSTOM_GAUGE    = true

  # The physical location of the hud sprite.
  # All of the other graphic locations are relative to this one.
  PLAYER_HUD_LOC             = Point.new(0, 0)
  # The relative location of the hud image to the hud sprite.
  PLAYER_HUD_IMAGE_LOCATION  = Point.new(0, 0)    

  # The starting location of each peice of the HP gauge.
  PLAYER_HP_GAUGE_LOCATION   = Point.new(0, 0)
  # the starting location of each peice of the MP gauge.
  PLAYER_MP_GAUGE_LOCATION   = Point.new(0, 0)

  SHOW_PLAYER_FACE_IMAGE     = true
  # The location of the face graphic.
  FACE_LOCATION              = Point.new(35, 0)

  # Show all party members? (THESE FEATURES ARE NOT YET IMPLEMENTED)
  USE_MEMBER_WINDOW          = true
  MEMBER_HUD_IMAGE_NAME      = 'member_hud'
  MEMBER_USE_CUSTOM_GAUGE    = false

  # Allow the player to hide the HUD by pressing a button?
  ALLOW_HUD_HIDE             = false
  # The button which will trigger a hud move.
  HIDE_HUD_INPUT             = Input::X
  # The speed at which to move the hud.
  HUD_HIDE_SPEED             = 7
  # replace "Left" with "Right" below to change the scroll direction
  HUD_SCROLL_DIRECTION       = ScrollDirection::Left

  # Global values which are convenient for setting
  # multiple values to the same thing.
  GLOBAL_FONT_NAME           = ['Magneto', 'Consolas', 'Verdana', 'Ariel', 'Courier New']
  GLOBAL_PLAYER_FONT_SIZE    = 22
  GLOBAL_MEMBER_FONT_SIZE    = 22  

  SHOW_PLAYER_NAME            = true
  # The rest of the settings deal with setting the
  # location and style of the text displayed in the HUD
  PLAYER_NAME_FONT           = GLOBAL_FONT_NAME  
  PLAYER_NAME_COLOR          = Colors::Silver
  PLAYER_NAME_USE_ITALICS    = false
  PLAYER_NAME_USE_BOLD       = false
  PLAYER_NAME_USE_SHADOW     = true
  PLAYER_NAME_FONT_SIZE      = 20
  PLAYER_NAME_LOCATION       = Point.new(125,0)
  PLAYER_NAME_WIDTH          = 90
  PLAYER_NAME_HEIGHT         = 22

  MEMBER_NAME_FONT           = GLOBAL_FONT_NAME
  MEMBER_NAME_COLOR          = Colors::White
  MEMBER_NAME_FONT_SIZE      = GLOBAL_MEMBER_FONT_SIZE
  MEMBER_NAME_LOCATION       = Point.new(0,0)

  USE_HP_TEXT_DISPLAY        = true
  PLAYER_HP_FONT             = ['Consolas', 'Verdana', 'Ariel', 'Courier New']
  PLAYER_FULL_HP_COLOR       = Colors::GaugeGreen
  PLAYER_HP_FONT_USE_ITALICS = false
  PLAYER_HP_FONT_USE_BOLD    = true
  PLAYER_HP_FONT_USE_SHADOW  = true
  PLAYER_HP_FONT_SIZE        = 14
  PLAYER_HP_LOCATION         = Point.new(130,66)
  PLAYER_HP_WIDTH            = 76
  PLAYER_HP_HEIGHT           = 11

  MEMBER_HP_FONT             = GLOBAL_FONT_NAME  
  MEMBER_HP_FONT_SIZE        = GLOBAL_MEMBER_FONT_SIZE
  MEMBER_HP_LOCATION         = Point.new(0,0)

  USE_MP_TEXT_DISPLAY        = USE_HP_TEXT_DISPLAY
  PLAYER_MP_FONT             = PLAYER_HP_FONT
  PLAYER_FULL_MP_COLOR       = Colors::GaugeBlue
  PLAYER_MP_FONT_USE_ITALICS = PLAYER_HP_FONT_USE_ITALICS
  PLAYER_MP_FONT_USE_BOLD    = PLAYER_HP_FONT_USE_BOLD
  PLAYER_MP_FONT_USE_SHADOW  = PLAYER_HP_FONT_USE_SHADOW
  PLAYER_MP_FONT_SIZE        = PLAYER_HP_FONT_SIZE
  PLAYER_MP_LOCATION         = Point.new(PLAYER_HP_LOCATION.x, PLAYER_HP_LOCATION.y + PLAYER_HP_HEIGHT + 1)
  PLAYER_MP_WIDTH            = PLAYER_HP_WIDTH
  PLAYER_MP_HEIGHT           = PLAYER_HP_HEIGHT

  MEMBER_MP_FONT             = GLOBAL_FONT_NAME  
  MEMBER_MP_FONT_SIZE        = GLOBAL_MEMBER_FONT_SIZE
  MEMBER_MP_LOCATION         = Point.new(0,0)

  SHOW_PLAYER_LEVEL          = true
  PLAYER_LEVEL_FONT          = GLOBAL_FONT_NAME
  PLAYER_LEVEL_COLOR         = Colors::Gold
  PLAYER_LEVEL_USE_ITALICS   = false
  PLAYER_LEVEL_USE_BOLD      = false
  PLAYER_LEVEL_USE_SHADOW    = true
  PLAYER_LEVEL_FONT_SIZE     = 18
  PLAYER_LEVEL_LOCATION      = Point.new(136,24)
  PLAYER_LEVEL_WIDTH         = 36
  PLAYER_LEVEL_HEIGHT        = 35

  MEMBER_LEVEL_FONT          = GLOBAL_FONT_NAME
  MEMBER_LEVEL_COLOR         = PLAYER_LEVEL_COLOR
  MEMBER_LEVEL_FONT_SIZE     = 10
  MEMBER_LEVEL_LOCATION      = Point.new(0,0)

  #-------
  # don't change the values below unless you know what you are doing.

  # Shows above the map and below the message window by default
  PLAYER_HUD_Z               = 199

  # The text format used for gauage images.    
  HEALTH_GAUGE_FORMAT        = 'hud_bar_%s_%.3d'

  # the name of the image file used as a mask for the face graphic
  PLAYER_FACE_MASK_NAME      = 'player_face_mask'

end

class EventHandler

  def initialize
    @client_map = {}
  end

  def add_listener(id, func)
    (@client_map[id.hash] ||= []) << func
  end

  def remove_listener(id)
    return @client_map.delete(id.hash)
  end

  def alert_listeners(*args)
    @client_map.each_value { |v| v.each { |func| func.call(*args) } }
  end

  def dispose
    @client_map = nil
  end

end

class Game_Actor < Game_Battler

  attr_reader :hp_changed
  attr_reader :mp_changed
  attr_reader :maxhp_changed
  attr_reader :maxmp_changed

  alias :pre_confhud_ga_init :initialize unless $@
  def initialize(*args)
    @hp_changed = EventHandler.new
    @mp_changed = EventHandler.new
    @maxhp_changed = EventHandler.new
    @maxmp_changed = EventHandler.new
    pre_confhud_ga_init(*args)    
  end

  def on_hp_changed(*args)    
    @hp_changed.alert_listeners(*args)
  end

  def on_mp_changed(*args)    
    @mp_changed.alert_listeners(*args)
  end

  def on_maxhp_changed(*args)
    @maxhp_changed.alert_listeners(*args)
  end

  def on_maxmp_changed(*args)
    @maxmp_changed.alert_listeners(*args)
  end

  alias :pre_confhud_ga_hpequ :hp= unless $@
  def hp=(*args)
    temp = @hp    
    pre_confhud_ga_hpequ(*args)    
    on_hp_changed(@hp) unless temp == @hp
  end

  alias :pre_confhud_ga_maxhpequ :maxhp= unless $@
  def maxhp=(*args)
    temp = self.maxhp
    pre_confhud_ga_maxhpequ(*args)
    cur_max = self.maxhp
    on_maxhp_changed(cur_max) unless temp == cur_max
  end

  alias :pre_confhud_ga_mpequ :mp= unless $@
  def mp=(*args)
    temp = @mp
    pre_confhud_ga_mpequ(*args)
    on_mp_changed(@mp) unless temp == @mp
  end

  alias :pre_confhud_ga_maxmpequ :maxmp= unless $@
  def maxmp=(*args)
    temp = self.maxmp
    pre_confhud_ga_maxmpequ(*args)
    cur_max = self.maxmp
    on_maxmp_changed(cur_max) unless temp == cur_max
  end

  alias :pre_confhud_ga_recover_all :recover_all unless $@
  def recover_all(*args)
    temp_hp, temp_mp = @hp, @mp
    pre_confhud_ga_recover_all(*args)
    on_hp_changed if temp_hp != @hp
    on_mp_changed if temp_mp != @mp
  end

end

class Game_Party

  attr_reader :party_leader_changed

  alias :pre_confhud_gp_init :initialize
  def initialize(*args)
    pre_confhud_gp_init(*args)
    @party_leader_changed = EventHandler.new
  end

  def on_party_leader_changed(*args)
    party_leader_changed.alert_listeners(*args)
  end

  alias :pre_confhud_gp_add_actor :add_actor
  def add_actor(*args)
    leader = $game_party.members.first
    pre_confhud_gp_add_actor(*args)
    on_party_leader_changed unless leader == $game_party.members.first
  end

  alias :pre_confhud_gp_remove_actor :remove_actor
  def remove_actor(*args)
    leader = $game_party.members.first
    pre_confhud_gp_remove_actor(*args)
    on_party_leader_changed unless leader == $game_party.members.first
  end

end

class Game_Player < Game_Character

  attr_reader :move_begun
  attr_reader :move_end

  alias :pre_confhud_gp_init :initialize
  def initialize(*args)
    @move_begun = EventHandler.new
    @move_end = EventHandler.new
    @move_started = false
    pre_confhud_gp_init(*args)
  end

  def on_move_begun
    @move_started = true
    @move_begun.alert_listeners
  end

  def on_move_end
    @move_started = false
    @move_end.alert_listeners
  end

  alias :pre_confhud_gp_update :update
  def update
    on_move_end if !moving? && @move_started
    pre_confhud_gp_update
  end

  alias :pre_conf_hud_gp_move_d :move_down
  def move_down(*args)
    on_move_begun if passable?(@x, @y + 1)
    pre_conf_hud_gp_move_d(*args)
  end

  alias :pre_conf_hud_gp_move_l :move_left
  def move_left(*args)
    on_move_begun if passable?(@x - 1, @y)
    pre_conf_hud_gp_move_l(*args)
  end

  alias :pre_conf_hud_gp_move_u :move_up
  def move_up(*args)
    on_move_begun if passable?(@x, @y - 1)
    pre_conf_hud_gp_move_u(*args)
  end

  alias :pre_conf_hud_gp_move_r :move_right
  def move_right(*args)
    on_move_begun if passable?(@x + 1, @y)
    pre_conf_hud_gp_move_r(*args)
  end

end

class Window_Base < Window

  alias :pre_confhud_wb_hp_color :hp_color unless $@
  def hp_color(actor, for_hud=false)
    return HudConfig::PLAYER_FULL_HP_COLOR if for_hud && actor.hp == actor.maxhp
    return pre_confhud_wb_hp_color(actor)
  end

  alias :pre_confhud_wb_mp_color :mp_color unless $@
  def mp_color(actor, for_hud=false)
    return HudConfig::PLAYER_FULL_MP_COLOR if for_hud && actor.mp == actor.maxmp
    return pre_confhud_wb_mp_color(actor)
  end

end

class MainHud < Sprite_Base
include HudConfig

  WLH = Window_Base::WLH

  attr_accessor :actor

  def initialize(location, viewport=nil, actor=nil, visible=true)
    $game_player.move_begun.add_listener(self, lambda { player_begin_move })
    $game_player.move_end.add_listener(self, lambda { player_end_move })
    @hud_visible = visible
    @new_opacity = 255
    super(viewport)
    self.bitmap = Bitmap.new(Graphics.width, Graphics.height)
    self.x, self.y = location.x, location.y    
    self.actor = actor
  end

  def player_end_move
    @new_opacity = 255
  end

  def player_begin_move
    @new_opacity = TRANSPARENCY_WHEN_MOVING
  end

  def update
    if TRANSPARENT_WHEN_MOVING && self.opacity != @new_opacity
      incr = TRANSPARENCY_SWITCH_SPEED
      if @new_opacity < self.opacity
        new_opacity = [self.opacity - incr, @new_opacity].max
      else
        new_opacity = [self.opacity + incr, @new_opacity].min
      end
      self.opacity = new_opacity
    end
    super
  end

  def actor=(value)
    # allow nil values to cause a refresh so that the hud
    # is painted at all times, even when there are no party members.
    return if @actor == value unless value.nil?
    remove_listeners(@actor)
    add_listeners(value)
    @actor = value
    create_player_face_image
    refresh
  end

  def hud_visible?
    @hud_visible
  end

  def hud_visible=(value)
    if @hud_visible != value
      @hud_visible = value
      refresh
    end
  end

  def image_rect
    ret = hud_image.rect
    ret.x, ret.y = *PLAYER_HUD_LOC.to_a
    return ret
  end

  def create_dummy_window
    win = Window_Base.new(0, 0, 64, 64)
    win.visible = false   
    return win
  end

  # Stupid hack to get standard text colors because
  # I did not feel like copy & pasting those methods.
  def hp_color
    return (@window ||= create_dummy_window).hp_color(@actor, true)
  end

  def mp_color
    return (@window ||= create_dummy_window).mp_color(@actor, true)
  end

  def hud_image
    return Cache.picture(PLAYER_HUD_IMAGE_NAME)
  end

  def hud_location
    return PLAYER_HUD_IMAGE_LOCATION  
  end

  def hp_gauge_location
    return PLAYER_HP_GAUGE_LOCATION  
  end

  def mp_gauge_location
    return PLAYER_MP_GAUGE_LOCATION  
  end

  def name_draw_rect
    return Rect.new(
             PLAYER_NAME_LOCATION.x,
             PLAYER_NAME_LOCATION.y,
             PLAYER_NAME_WIDTH,
             PLAYER_NAME_HEIGHT
             )
  end

  def level_draw_rect    
    return Rect.new(
             PLAYER_LEVEL_LOCATION.x,
             PLAYER_LEVEL_LOCATION.y,
             PLAYER_LEVEL_WIDTH,
             PLAYER_LEVEL_HEIGHT
             )
  end

  def hp_draw_rect
    return Rect.new(
             PLAYER_HP_LOCATION.x,
             PLAYER_HP_LOCATION.y,
             PLAYER_HP_WIDTH,
             PLAYER_HP_HEIGHT
             )
  end

  def mp_draw_rect
    return Rect.new(
             PLAYER_MP_LOCATION.x,
             PLAYER_MP_LOCATION.y,
             PLAYER_MP_WIDTH,
             PLAYER_MP_HEIGHT
             )
  end

  def name_font
    font = Font.new(PLAYER_NAME_FONT, PLAYER_NAME_FONT_SIZE)
    font.color = PLAYER_NAME_COLOR
    font.italic = PLAYER_NAME_USE_ITALICS
    font.bold = PLAYER_NAME_USE_BOLD
    font.shadow = PLAYER_NAME_USE_SHADOW
    return font
  end

  def hp_font
    font = Font.new(PLAYER_HP_FONT, PLAYER_HP_FONT_SIZE)
    font.color = hp_color
    font.italic = PLAYER_HP_FONT_USE_ITALICS
    font.bold = PLAYER_HP_FONT_USE_BOLD
    font.shadow = PLAYER_HP_FONT_USE_SHADOW
    return font
  end

  def mp_font
    font = Font.new(PLAYER_MP_FONT, PLAYER_MP_FONT_SIZE)
    font.color = mp_color
    font.italic = PLAYER_MP_FONT_USE_ITALICS
    font.bold = PLAYER_MP_FONT_USE_BOLD
    font.shadow = PLAYER_MP_FONT_USE_SHADOW
    return font
  end

  def level_font
    font = Font.new(PLAYER_LEVEL_FONT, PLAYER_LEVEL_FONT_SIZE)
    font.color = PLAYER_LEVEL_COLOR
    font.italic = PLAYER_LEVEL_USE_ITALICS
    font.bold = PLAYER_LEVEL_USE_BOLD
    font.shadow = PLAYER_LEVEL_USE_SHADOW
    return font
  end

  def player_face_mask_image
    return Cache.picture(PLAYER_FACE_MASK_NAME)
  end

  def create_player_face_image(size=96)
    if @actor.nil?
      @face_image = Bitmap.new(size, size)
      return
    end    
    rect = Rect.new(0, 0, 0, 0)
    rect.x = @actor.face_index % 4 * 96 + (96 - size) / 2
    rect.y = @actor.face_index / 4 * 96 + (96 - size) / 2
    rect.width = size
    rect.height = size
    face = Cache.face(@actor.face_name)
    mask = player_face_mask_image
    @face_image = Bitmap.new(rect.width, rect.height)
    @face_image.blt(0, 0, face, rect)
    for y in 0...rect.height
      for x in 0...rect.width
        mask_color = mask.get_pixel(x, y)
        @face_image.set_pixel(x, y, mask_color) if mask_color.alpha.zero?
      end
    end
  end

  def add_listeners(actor)
    return if actor.nil?
    func = lambda { refresh }
    actor.hp_changed.add_listener(self, func)
    actor.maxhp_changed.add_listener(self, func)
    actor.mp_changed.add_listener(self, func)
    actor.maxmp_changed.add_listener(self, func)
  end

  def hp_value_changed

    refresh
  end

  def remove_listeners(actor)
    return if actor.nil?
    actor.hp_changed.remove_listener(self)  
    actor.maxhp_changed.remove_listener(self)
    actor.mp_changed.remove_listener(self)
    actor.maxmp_changed.remove_listener(self)
  end

  def draw_hud
    draw_custom_mp_gauge
    draw_custom_hp_gauge
    image = hud_image
    location = hud_location
    self.bitmap.blt(location.x, location.y, image, image.rect)
  end

  def draw_custom_hp_gauge
    cur, max = *(@actor.nil? ? [0,1] : [@actor.hp,@actor.maxhp])
    draw_gauge(hp_gauge_location, 'hp', cur, max)
  end

  def draw_custom_mp_gauge
    cur, max = *(@actor.nil? ? [0,1] : [@actor.mp,@actor.maxmp])
    draw_gauge(mp_gauge_location, 'mp', cur, max)
  end

  def draw_gauge(location, stat_name, current, max)
    percent_health = (current / max.to_f) * 100
    multiple = 5    
    percent_health = check_health_bounds(percent_health, multiple)
    percent_health = round_to_multiple_of(multiple, percent_health.round)
    file_name = HEALTH_GAUGE_FORMAT % [stat_name, percent_health]    
    image = Cache.picture(file_name)    
    self.bitmap.blt(location.x, location.y, image, image.rect)
  end  

  def round_to_multiple_of(multiple_of, num)
    # why in the fuck did I do this this way?
    # leave comments for yourself in the future dumbass.
    leftover = num % multiple_of
    return num if leftover.zero?
    if leftover > multiple_of / 2
      sym = :+
    else
      sym = :-
    end
    ret = num
    loop do
      ret = ret.send sym, 1
      break if ret % multiple_of == 0
    end
    return ret
  end

  def check_health_bounds(num, multiple)
    # dont allow the gauge to read 100 or 0 unless
    # the current health actually is 100 or 0.
    next_lower = 100 - multiple
    if num > next_lower && num < 100
      return next_lower
    elsif num < multiple && num > 0
      return multiple
    else
      return num
    end
  end

  def draw_face
    self.bitmap.blt(FACE_LOCATION.x, FACE_LOCATION.y, @face_image, @face_image.rect)
  end

  def draw_name
    return if @actor.nil?
    name = @actor.name
    rect = name_draw_rect    
    font = name_font
    temp_font = self.bitmap.font
    self.bitmap.font = font
    self.bitmap.draw_text(rect, name)
    self.bitmap.font = temp_font
  end

  def draw_level
    return if @actor.nil?
    level = @actor.level
    rect = level_draw_rect    
    font = level_font
    temp_font = self.bitmap.font
    self.bitmap.font = font
    self.bitmap.draw_text(rect, level, 1)
    self.bitmap.font = temp_font
  end

  def use_custom_gauges?
    return PLAYER_USE_CUSTOM_GAUGE  
  end

  def health_text(prefix, cur, max)
    return "#{prefix}: #{cur}/#{max}"
  end

  def draw_health(rect, font, prefix, cur, max)
    self.bitmap.font = font
    xr = rect.x + rect.width
    health_width = (rect.width * 0.33).round
    spacer_width = (health_width / 2.1).round
    temp_font = self.bitmap.font
    prefixf = prefix + ':'
    # fuck this pile of shit, move along, this will just hurt your head
    self.bitmap.draw_text(rect.x, rect.y, self.bitmap.text_size(prefixf).width, rect.height, prefixf)
    self.bitmap.draw_text(xr - spacer_width - health_width * 2 + (health_width * 0.15).round, rect.y, health_width, rect.height, cur, 2)
    self.bitmap.draw_text(xr - spacer_width - health_width, rect.y, spacer_width, rect.height, "/", 2)
    self.bitmap.draw_text(xr - health_width, rect.y, health_width, rect.height, max, 2)
    self.bitmap.font = temp_font
  end

  def draw_hp
    return if @actor.nil?
    draw_health(hp_draw_rect, hp_font, Vocab.hp_a, @actor.hp, @actor.maxhp)    
  end  

  def draw_mp
    return if @actor.nil?
    draw_health(mp_draw_rect, mp_font, Vocab.mp_a, @actor.mp, @actor.maxmp)
  end  

  def refresh   
    self.bitmap.clear  
    return unless hud_visible?
    draw_face if SHOW_PLAYER_FACE_IMAGE
    draw_hud    
    draw_name if SHOW_PLAYER_NAME
    draw_level if SHOW_PLAYER_LEVEL
    draw_hp if USE_HP_TEXT_DISPLAY
    draw_mp if USE_MP_TEXT_DISPLAY       
  end

  def dispose
    remove_listeners(@actor)
    $game_player.move_begun.remove_listener(self)
    $game_player.move_end.remove_listener(self)
    unless @window.nil?
      @window.dispose
      @window = nil
    end
    super    
  end

end

class SubHud < MainHud



end

class Game_Map

  alias :pre_confhud_gm_setup :setup
  def setup(*args)
    id = *args
    @info = load_data('Data/MapInfos.rvdata')[id]    
    pre_confhud_gm_setup(*args)
  end

  def display_hud?
    return [email protected]?(HudConfig::NO_SHOW_TEXT)
  end

end

class Scene_Map < Scene_Base
include HudConfig

  attr_reader :player_hud

  # used to keep track of the hud location between
  # setups and teardowns, i.e., if you enter the menu or battle.
  @@last_hud_ox = 0

  alias :pre_confhud_sm_start :start unless $@
  def start
    pre_confhud_sm_start
    initialize_hud
    $game_party.party_leader_changed.add_listener(self, lambda { @player_hud.actor = $game_party.members.first })
  end

  def initialize_hud
    @hud_viewport = Viewport.new(0, 0, 544, 416)
    @hud_viewport.z = PLAYER_HUD_Z
    @hud_viewport.ox = @@last_hud_ox    
    @@target_hud_location ||= @hud_viewport.ox    
    actor = $game_party.members.first
    @player_hud = MainHud.new(
      PLAYER_HUD_LOC,
      @hud_viewport,
      actor,
      hud_enabled?(actor)
      )
  end

  alias :pre_confhud_sm_update :update unless $@
  def update
    pre_confhud_sm_update
    update_hud
    update_hud_input
    update_hud_transition
  end

  alias :pre_confhud_sm_update_basic :update_basic unless $@
  def update_basic(*args)
    pre_confhud_sm_update_basic
    update_hud
  end

  def show_hud
    trigger_scroll
  end

  def hide_hud
    trigger_scroll(true)
  end

  def trigger_scroll(force_hide=false)
    @@hud_moving = true
    if @hud_viewport.ox.zero?
      hud_rect = @player_hud.image_rect      
      left = HUD_SCROLL_DIRECTION  == ScrollDirection::Left        
      offset = left ? hud_rect.width + hud_rect.x : -(Graphics.width - hud_rect.<img src='http://rpgmkr.net/forum/public/style_emoticons/<#EMO_DIR#>/sourirex.gif' class='bbc_emoticon' alt='X)' />
      @@target_hud_location = @hud_viewport.ox + offset
    elsif !force_hide
      @@target_hud_location = 0
    end                      
  end

  def update_hud
    @player_hud.hud_visible = hud_enabled?
    @player_hud.update
    @hud_viewport.update
  end

  def hud_enabled?(actor=nil)
    return false if !SHOW_IF_NO_LEADER && (actor ||= @player_hud.actor).nil?
    return false unless $game_map.display_hud?
    return false unless NO_SHOW_SWITCH.nil? || !$game_switches[NO_SHOW_SWITCH]    
    return true
  end

  def update_hud_input
    trigger_scroll if ALLOW_HUD_HIDE && Input.trigger?(HIDE_HUD_INPUT)                
  end

  def update_hud_transition
    @@hud_moving = @hud_viewport.ox != @@target_hud_location
    return unless @@hud_moving    
    incr = @hud_viewport.ox < @@target_hud_location ? HUD_HIDE_SPEED : -HUD_HIDE_SPEED    
    @hud_viewport.ox += [incr, (@hud_viewport.ox - @@target_hud_location).abs].min
  end

  alias :pre_confhud_sm_terminate :terminate unless $@
  def terminate
    pre_confhud_sm_terminate
    $game_party.party_leader_changed.remove_listener(self)
    @player_hud.dispose
    @@last_hud_ox = @hud_viewport.ox
  end

end
Demo:
http://www.mediafire.com/?g17t2tbaralgxz2

Condividi questo messaggio


Link di questo messaggio
Condividi su altri siti

Crea un account o accedi per lasciare un commento

You need to be a member in order to leave a comment

Crea un account

Iscriviti per un nuovo account nella nostra comunità. È facile!

Registra un nuovo account

Accedi

Sei già registrato? Accedi qui.

Accedi Ora

  • Contenuti simili

    • Da kaine
      Questo plugin è una sorta di fusione tra il CortiMonsterHud ed il Condition Icons(trovate i link ai rispettivi topic a fondo pagina).
      Ma allo stesso tempo è qualcosa di nuovo dato che aggiunge nuove feature.
      Ad esempio è possibile visualizzare quanti turni mancano prima che un determinato status benevolo/malevolo finisca il suo effetto.
      Un altra feature interessante, è quella di poter visualizzare a vostra discrezione, alcuni elementi e poter decidere per quanto tempo mostrarli dopo un cambiamento rilevante.
      All'interno dell'archivio trovate il file readme.html in cui è spiegato dettagliatamente il funzionamento del plugin e come configurarlo.
       
      Esempio di funzionamento:

       
       
      Autore: Aubrey The Bard
       
      Link Download:
      http://www.mediafire.com/file/i9zy47bcb852wcn/DynBattleDisplay_TvQDOUu.zip
       
      Topic CortiMonsterHud:
      http://www.makerando.com/forum/topic/499-cortimonsterhud/
       
      Topic Condition Icons:
      http://www.makerando.com/forum/topic/311-condition-icons/
    • Da Ally
      Nome Script: Melosx HUD
      Versione: 1.0
      Autore/i: Melosx
       
      Informazioni:
      HUD ad immagini che mostra face, barre PV/MP/ESP ed equip indossato. Ottimo per i vostri ABS...
       
      Istruzioni:
      Nello script della demo.
       
      Demo:
      http://www.mediafire...g04cerpxtwy62e3
       
      Script 2.0
       
       
    • Da Ally
      Nome Script: KMS Minimap
      Versione: N/D
      Autore/i: tomy, traduzione EN by Mr. Bubble

      Informazioni:
      Con lo script è possibile visualizzare l'HUD della mini mappa in cima allo schermo di gioco =)

      Screenshots:



      Istruzioni:
      Inserite lo script sotto Material.
      Istruzioni all'interno dello script.

      Script:


      #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ #_/ ◆ Minimap - KMS_MiniMap ◆ VXAce ◆ #_/ ◇ Last update : 2012/01/08 (TOMY@Kamesoft) ◇ #_/ ◇ Website: http://ytomy.sakura.ne.jp/ #_/ ◇ Translated by Mr. Bubble #_/---------------------------------------------------------------------------- #_/ Adds a minimap display. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ # This script is plug-and-play, but various customization options are available. # # To complete disable the minimap on a specific map, add [NOMAP] to the # beginning of map name. You can also use the tag <minimap hide> in the notebox. #---------------------------------------------------------------------------- # Map Notetags #---------------------------------------------------------------------------- # Map notetags are added to "Note" boxes. Right-click a map and select # Map Properties to find the "Note" box for maps. # # <minimap hide> # Completely disables the minimap on a specific map. [NOMAP] can also be # added to the beginning of map names for the same effect. #---------------------------------------------------------------------------- # Event Comment Tags #---------------------------------------------------------------------------- # Since events do not have noteboxes, comment tags are used instead. Open the # event, create a new event command, go to Tab 1, and click the "Comment..." # event command. A box will open up allowing you to enter tags. # # <minimap wall> # Add this tag to an event's comment to change its minimap color to the # same as an impassable tile. # # <minimap move> # Add this tag to an event's comment to have them blink in the minimap. # # <minimap obj n> # Add this tag to an event's comment to have them blink in the minimap with # a specified color where n is the OBJ value defined in OBJECT_COLOR which # is found in the customization module below. #---------------------------------------------------------------------------- # Usage Notes #---------------------------------------------------------------------------- # Impassable events will not appear as the correct color in the minimap. # This effect is intended. If you want an event to appear as impassable # on the minimap, add the tag <minimap wall> to an event's comment. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ #============================================================================== # ★ BEGIN Setting ★ #============================================================================== module KMS_MiniMap # * Minimap Display Toggle Button # Set to nil to disable this function SWITCH_BUTTON = :Z # * Minimap Size and Position (x, y, width, height) MAP_RECT = Rect.new(364, 20, 160, 120) # * Minimap z-layer Priority # Glitchy if this value is set too high MAP_Z = 0 # * Minimap Grid Size # A size of 3 or higher is recommended GRID_SIZE = 5 # * Mini-Map Color Settings FOREGROUND_COLOR = Color.new(224, 224, 255, 160) # Foreground (passable) BACKGROUND_COLOR = Color.new( 0, 0, 160, 160) # Background (not passable) POSITION_COLOR = Color.new(255, 0, 0, 192) # Current Position color MOVE_EVENT_COLOR = Color.new(255, 160, 0, 192) # Moving event color VEHICLE_COLOR = Color.new( 96, 128, 0, 192) # Vehicle color # * Object Color Presets # Create custom color resets for events tagged with the corresponding label OBJECT_COLOR = [ Color.new( 0, 128, 0, 192), # OBJ 1 Color.new( 0, 160, 160, 192), # OBJ 2 Color.new(160, 0, 160, 192), # OBJ 3 ] # <- Do not delete this line # * Minimap Blinking Frequency # Values 5~8 are recommended BLINK_LEVEL = 7 # * Minimap Cache Setting # This script creates a cache for each map. If the number of cached # maps exceed CACHE_NUM, oldest cached maps are deleted. CACHE_NUM = 10 end #============================================================================== # ☆ END Setting ☆ #============================================================================== $imported = {} if $imported == nil $imported["KMS_MiniMap"] = true module KMS_MiniMap # ミニマップ非表示 REGEX_NO_MINIMAP_NOTE = /<(?:ミニマップ|MINIMAP)s*(?:非表示|HIDE)>/i REGEX_NO_MINIMAP_NAME = /[NOMAP]/i # 障害物 REGEX_WALL_EVENT = /<(?:ミニマップ|MINIMAP)s*(?:壁|障害物|WALL)>/i # 移動イベント REGEX_MOVE_EVENT = /<(?:ミニマップ|MINIMAP)s*(?:移動|MOVE)>/i # オブジェクト REGEX_OBJECT = /<(?:ミニマップ|MINIMAP)s+OBJ(?:ECT)?s*(d+)>/i end # ***************************************************************************** #============================================================================== # □ KMS_Commands #============================================================================== module KMS_Commands module_function #-------------------------------------------------------------------------- # ○ ミニマップを表示 #-------------------------------------------------------------------------- def self.show_minimap $game_system.minimap_show = true end #-------------------------------------------------------------------------- # ○ ミニマップを隠す #-------------------------------------------------------------------------- def self.hide_minimap $game_system.minimap_show = false end #-------------------------------------------------------------------------- # ○ ミニマップ表示状態の取得 #-------------------------------------------------------------------------- def self.minimap_showing? return $game_system.minimap_show end #-------------------------------------------------------------------------- # ○ ミニマップをリフレッシュ #-------------------------------------------------------------------------- def self.refresh_minimap return unless $scene.is_a?(Scene_Map) $game_map.refresh if $game_map.need_refresh $scene.refresh_minimap end #-------------------------------------------------------------------------- # ○ ミニマップのオブジェクトを更新 #-------------------------------------------------------------------------- def self.update_minimap_object return unless $scene.is_a?(Scene_Map) $game_map.refresh if $game_map.need_refresh $scene.update_minimap_object end end #============================================================================== # ■ Game_Interpreter #============================================================================== class Game_Interpreter # イベントコマンドから直接コマンドを叩けるようにする include KMS_Commands end #============================================================================== # ■ RPG::Map #============================================================================== class RPG::Map #-------------------------------------------------------------------------- # ○ ミニマップのキャッシュ生成 #-------------------------------------------------------------------------- def create_minimap_cache @__minimap_show = true note.each_line { |line| if line =~ KMS_MiniMap::REGEX_NO_MINIMAP_NOTE # マップ非表示 @__minimap_show = false end } end #-------------------------------------------------------------------------- # ○ ミニマップ表示 #-------------------------------------------------------------------------- def minimap_show? create_minimap_cache if @__minimap_show.nil? return @__minimap_show end end #============================================================================== # ■ RPG::MapInfo #============================================================================== class RPG::MapInfo #-------------------------------------------------------------------------- # ● マップ名取得 #-------------------------------------------------------------------------- def name return @name.gsub(/[.*]/) { "" } end #-------------------------------------------------------------------------- # ○ オリジナルマップ名取得 #-------------------------------------------------------------------------- def original_name return @name end #-------------------------------------------------------------------------- # ○ ミニマップのキャッシュ生成 #-------------------------------------------------------------------------- def create_minimap_cache @__minimap_show = !(@name =~ KMS_MiniMap::REGEX_NO_MINIMAP_NAME) end #-------------------------------------------------------------------------- # ○ ミニマップ表示 #-------------------------------------------------------------------------- def minimap_show? create_minimap_cache if @__minimap_show == nil return @__minimap_show end end #============================================================================== # ■ Game_System #============================================================================== class Game_System #-------------------------------------------------------------------------- # ○ 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :minimap_show #-------------------------------------------------------------------------- # ○ オブジェクト初期化 #-------------------------------------------------------------------------- alias initialize_KMS_MiniMap initialize def initialize initialize_KMS_MiniMap @minimap_show = true end end #============================================================================== # ■ Game_Map #============================================================================== class Game_Map #-------------------------------------------------------------------------- # ○ 定数 #-------------------------------------------------------------------------- MINIMAP_FADE_NONE = 0 # ミニマップ フェードなし MINIMAP_FADE_IN = 1 # ミニマップ フェードイン MINIMAP_FADE_OUT = 2 # ミニマップ フェードアウト #-------------------------------------------------------------------------- # ○ 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :minimap_fade #-------------------------------------------------------------------------- # ○ ミニマップを表示するか #-------------------------------------------------------------------------- def minimap_show? return $data_mapinfos[map_id].minimap_show? && @map.minimap_show? end #-------------------------------------------------------------------------- # ○ ミニマップをフェードイン #-------------------------------------------------------------------------- def fadein_minimap @minimap_fade = MINIMAP_FADE_IN end #-------------------------------------------------------------------------- # ○ ミニマップをフェードアウト #-------------------------------------------------------------------------- def fadeout_minimap @minimap_fade = MINIMAP_FADE_OUT end end #============================================================================== # ■ Game_Event #============================================================================== class Game_Event < Game_Character #-------------------------------------------------------------------------- # ○ ミニマップ用のキャッシュを作成 #-------------------------------------------------------------------------- def __create_minimap_cache @__last_page = @page @__minimap_wall_event = false @__minimap_move_event = false @__minimap_object_type = -1 @page.list.each { |cmd| # 注釈以外に到達したら離脱 break unless [108, 408].include?(cmd.code) # 正規表現判定 case cmd.parameters[0] when KMS_MiniMap::REGEX_WALL_EVENT @__minimap_wall_event = true when KMS_MiniMap::REGEX_MOVE_EVENT @__minimap_move_event = true when KMS_MiniMap::REGEX_OBJECT @__minimap_object_type = $1.to_i end } end private :__create_minimap_cache #-------------------------------------------------------------------------- # ○ グラフィックがあるか #-------------------------------------------------------------------------- def graphic_exist? return (character_name != "" || tile_id > 0) end #-------------------------------------------------------------------------- # ○ 障害物か #-------------------------------------------------------------------------- def is_minimap_wall_event? if @__minimap_wall_event.nil? || @__last_page != @page __create_minimap_cache end return @__minimap_wall_event end #-------------------------------------------------------------------------- # ○ 移動イベントか #-------------------------------------------------------------------------- def is_minimap_move_event? if @__minimap_move_event.nil? || @__last_page != @page __create_minimap_cache end return @__minimap_move_event end #-------------------------------------------------------------------------- # ○ ミニマップオブジェクトか #-------------------------------------------------------------------------- def is_minimap_object? if @__minimap_object_type.nil? || @__last_page != @page __create_minimap_cache end return @__minimap_object_type > 0 end #-------------------------------------------------------------------------- # ○ ミニマップオブジェクトタイプ #-------------------------------------------------------------------------- def minimap_object_type if @__minimap_object_type.nil? || @__last_page != @page __create_minimap_cache end return @__minimap_object_type end end #============================================================================== # □ Game_MiniMap #------------------------------------------------------------------------------ # ミニマップを扱うクラスです。 #============================================================================== class Game_MiniMap #-------------------------------------------------------------------------- # ○ 構造体 #-------------------------------------------------------------------------- Point = Struct.new(:x, :y) Size = Struct.new(:width, :height) PassageCache = Struct.new(:map_id, :table, :scan_table) #-------------------------------------------------------------------------- # ○ クラス変数 #-------------------------------------------------------------------------- @@passage_cache = [] # 通行フラグテーブルキャッシュ #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(tilemap) @map_rect = KMS_MiniMap::MAP_RECT @grid_size = [KMS_MiniMap].max @x = 0 @y = 0 @grid_num = Point.new( (@map_rect.width + @grid_size - 1) / @grid_size, (@map_rect.height + @grid_size - 1) / @grid_size ) @draw_grid_num = Point.new(@grid_num.x + 2, @grid_num.y + 2) @draw_range_begin = Point.new(0, 0) @draw_range_end = Point.new(0, 0) @tilemap = tilemap @last_x = $game_player.x @last_y = $game_player.y @showing = false @hiding = false create_sprites refresh end #-------------------------------------------------------------------------- # ○ スプライト作成 #-------------------------------------------------------------------------- def create_sprites @viewport = Viewport.new(@map_rect) @viewport.z = KMS_MiniMap::MAP_Z # ビットマップサイズ計算 @bmp_size = Size.new( (@grid_num.x + 2) * @grid_size, (@grid_num.y + 2) * @grid_size ) @buf_bitmap = Bitmap.new(@bmp_size.width, @bmp_size.height) # マップ用スプライト作成 @map_sprite = Sprite.new(@viewport) @map_sprite.x = -@grid_size @map_sprite.y = -@grid_size @map_sprite.z = 0 @map_sprite.bitmap = Bitmap.new(@bmp_size.width, @bmp_size.height) # オブジェクト用スプライト作成 @object_sprite = Sprite_MiniMapIcon.new(@viewport) @object_sprite.x = -@grid_size @object_sprite.y = -@grid_size @object_sprite.z = 1 @object_sprite.bitmap = Bitmap.new(@bmp_size.width, @bmp_size.height) # 現在位置スプライト作成 @position_sprite = Sprite_MiniMapIcon.new @position_sprite.x = @map_rect.x + @grid_num.x / 2 * @grid_size @position_sprite.y = @map_rect.y + @grid_num.y / 2 * @grid_size @position_sprite.z = @viewport.z + 2 bitmap = Bitmap.new(@grid_size, @grid_size) bitmap.fill_rect(bitmap.rect, KMS_MiniMap::POSITION_COLOR) @position_sprite.bitmap = bitmap end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- def dispose @buf_bitmap.dispose @map_sprite.bitmap.dispose @map_sprite.dispose @object_sprite.bitmap.dispose @object_sprite.dispose @position_sprite.bitmap.dispose @position_sprite.dispose @viewport.dispose end #-------------------------------------------------------------------------- # ○ 可視状態取得 #-------------------------------------------------------------------------- def visible return @map_sprite.visible end #-------------------------------------------------------------------------- # ○ 可視状態設定 #-------------------------------------------------------------------------- def visible=(value) @viewport.visible = value @map_sprite.visible = value @object_sprite.visible = value @position_sprite.visible = value end #-------------------------------------------------------------------------- # ○ 不透明度取得 #-------------------------------------------------------------------------- def opacity return @map_sprite.opacity end #-------------------------------------------------------------------------- # ○ 不透明度設定 #-------------------------------------------------------------------------- def opacity=(value) @map_sprite.opacity = value @object_sprite.opacity = value @position_sprite.opacity = value end #-------------------------------------------------------------------------- # ○ リフレッシュ #-------------------------------------------------------------------------- def refresh update_draw_range update_passage_table update_object_list update_position draw_map draw_object Graphics.frame_reset end #-------------------------------------------------------------------------- # ○ フェードイン #-------------------------------------------------------------------------- def fadein @showing = true @hiding = false end #-------------------------------------------------------------------------- # ○ フェードアウト #-------------------------------------------------------------------------- def fadeout @showing = false @hiding = true end #-------------------------------------------------------------------------- # ○ キー入力更新 #-------------------------------------------------------------------------- def update_input return if KMS_MiniMap::SWITCH_BUTTON.nil? if Input.trigger?(KMS_MiniMap::SWITCH_BUTTON) if opacity < 255 && !@showing fadein elsif opacity > 0 && !@hiding fadeout end end end #-------------------------------------------------------------------------- # ○ 描画範囲更新 #-------------------------------------------------------------------------- def update_draw_range range = [] (2).times { |i| range[i] = @draw_grid_num[i] / 2 } @draw_range_begin.x = $game_player.x - range[0] @draw_range_begin.y = $game_player.y - range[1] @draw_range_end.x = $game_player.x + range[0] @draw_range_end.y = $game_player.y + range[1] end #-------------------------------------------------------------------------- # ○ 通行可否テーブル更新 #-------------------------------------------------------------------------- def update_passage_table cache = get_passage_table_cache @passage_table = cache.table @passage_scan_table = cache.scan_table update_around_passage_table end #-------------------------------------------------------------------------- # ○ 通行可否テーブルのキャッシュを取得 #-------------------------------------------------------------------------- def get_passage_table_cache map_id = $game_map.map_id cache = @@passage_cache.find { |c| c.map_id == map_id } # キャッシュミスしたら新規作成 if cache == nil cache = PassageCache.new(map_id) cache.table = Table.new($game_map.width, $game_map.height) cache.scan_table = Table.new( ($game_map.width + @draw_grid_num.x - 1) / @draw_grid_num.x, ($game_map.height + @draw_grid_num.y - 1) / @draw_grid_num.y ) end # 直近のキャッシュは先頭に移動し、古いキャッシュは削除 @@passage_cache.unshift(cache) @@passage_cache.delete_at(KMS_MiniMap::CACHE_NUM) return cache end #-------------------------------------------------------------------------- # ○ 通行可否テーブルのキャッシュをクリア #-------------------------------------------------------------------------- def clear_passage_table_cache return if @passage_scan_table == nil table = @passage_scan_table @passage_scan_table = Table.new(table.xsize, table.ysize) end #-------------------------------------------------------------------------- # ○ 通行可否テーブルの探索 # x, y : 探索位置 #-------------------------------------------------------------------------- def scan_passage(x, y) dx = x / @draw_grid_num.x dy = y / @draw_grid_num.y # 探索済み return if @passage_scan_table[dx, dy] == 1 # マップ範囲外 return unless dx.between?(0, @passage_scan_table.xsize - 1) return unless dy.between?(0, @passage_scan_table.ysize - 1) rx = (dx * @draw_grid_num.<img src='http://rpgmkr.net/forum/public/style_emoticons/<#EMO_DIR#>/sourirex.gif' class='bbc_emoticon' alt='X)' />...((dx + 1) * @draw_grid_num.<img src='http://rpgmkr.net/forum/public/style_emoticons/<#EMO_DIR#>/sourirex.gif' class='bbc_emoticon' alt='X)' /> ry = (dy * @draw_grid_num.y)...((dy + 1) * @draw_grid_num.y) mw = $game_map.width - 1 mh = $game_map.height - 1 # 探索範囲内の通行テーブルを生成 rx.each { |x| next unless x.between?(0, mw) ry.each { |y| next unless y.between?(0, mh) # 通行方向フラグ作成 # (↓、←、→、↑ の順に 1, 2, 4, 8 が対応) flag = 0 [2, 4, 6, 8].each{ |d| flag |= 1 << (d / 2 - 1) if $game_map.passable?(x, y, d) } @passage_table[x, y] = flag } } @passage_scan_table[dx, dy] = 1 end #-------------------------------------------------------------------------- # ○ 周辺の通行可否テーブル更新 #-------------------------------------------------------------------------- def update_around_passage_table gx = @draw_grid_num.x gy = @draw_grid_num.y dx = $game_player.x - gx / 2 dy = $game_player.y - gy / 2 scan_passage(dx, dy) scan_passage(dx + gx, dy) scan_passage(dx, dy + gy) scan_passage(dx + gx, dy + gy) end #-------------------------------------------------------------------------- # ○ オブジェクト一覧更新 #-------------------------------------------------------------------------- def update_object_list events = $game_map.events.values # WALL @wall_events = events.find_all { |e| e.is_minimap_wall_event? } # MOVE @move_events = events.find_all { |e| e.is_minimap_move_event? } # OBJ @object_list = events.find_all { |e| e.is_minimap_object? } end #-------------------------------------------------------------------------- # ○ 位置更新 #-------------------------------------------------------------------------- def update_position # 移動量算出 pt = Point.new($game_player.x, $game_player.y) ox = ($game_player.real_x - pt.<img src='http://rpgmkr.net/forum/public/style_emoticons/<#EMO_DIR#>/sourirex.gif' class='bbc_emoticon' alt='X)' /> * @grid_size oy = ($game_player.real_y - pt.y) * @grid_size @viewport.ox = ox @viewport.oy = oy # 移動していたらマップ再描画 if pt.x != @last_x || pt.y != @last_y draw_map @last_x = pt.x @last_y = pt.y end end #-------------------------------------------------------------------------- # ○ 描画範囲内判定 #-------------------------------------------------------------------------- def in_draw_range?(x, y) rb = @draw_range_begin re = @draw_range_end return (x.between?(rb.x, re.<img src='http://rpgmkr.net/forum/public/style_emoticons/<#EMO_DIR#>/sourirex.gif' class='bbc_emoticon' alt='X)' /> && y.between?(rb.y, re.y)) end #-------------------------------------------------------------------------- # ○ マップ範囲内判定 #-------------------------------------------------------------------------- def in_map_range?(x, y) mw = $game_map.width mh = $game_map.height return (x.between?(0, mw - 1) && y.between?(0, mh - 1)) end #-------------------------------------------------------------------------- # ○ マップ描画 #-------------------------------------------------------------------------- def draw_map update_around_passage_table bitmap = @map_sprite.bitmap bitmap.fill_rect(bitmap.rect, KMS_MiniMap::BACKGROUND_COLOR) draw_map_foreground(bitmap) draw_map_move_event(bitmap) end #-------------------------------------------------------------------------- # ○ 通行可能領域の描画 #-------------------------------------------------------------------------- def draw_map_foreground(bitmap) range_x = (@draw_range_begin.<img src='http://rpgmkr.net/forum/public/style_emoticons/<#EMO_DIR#>/sourirex.gif' class='bbc_emoticon' alt='X)' />..(@draw_range_end.<img src='http://rpgmkr.net/forum/public/style_emoticons/<#EMO_DIR#>/sourirex.gif' class='bbc_emoticon' alt='X)' /> range_y = (@draw_range_begin.y)..(@draw_range_end.y) map_w = $game_map.width - 1 map_h = $game_map.height - 1 rect = Rect.new(0, 0, @grid_size, @grid_size) range_x.each { |x| next unless x.between?(0, map_w) range_y.each { |y| next unless y.between?(0, map_h) next if @passage_table[x, y] == 0 next if @wall_events.find { |e| e.x == x && e.y == y } # 壁 # グリッド描画サイズ算出 rect.set(0, 0, @grid_size, @grid_size) rect.x = (x - @draw_range_begin.<img src='http://rpgmkr.net/forum/public/style_emoticons/<#EMO_DIR#>/sourirex.gif' class='bbc_emoticon' alt='X)' /> * @grid_size rect.y = (y - @draw_range_begin.y) * @grid_size flag = @passage_table[x, y] if flag & 0x01 == 0 # 下通行不能 rect.height -= 1 end if flag & 0x02 == 0 # 左通行不能 rect.x += 1 rect.width -= 1 end if flag & 0x04 == 0 # 右通行不能 rect.width -= 1 end if flag & 0x08 == 0 # 上通行不能 rect.y += 1 rect.height -= 1 end bitmap.fill_rect(rect, KMS_MiniMap::FOREGROUND_COLOR) } } end #-------------------------------------------------------------------------- # ○ 移動イベントの描画 #-------------------------------------------------------------------------- def draw_map_move_event(bitmap) rect = Rect.new(0, 0, @grid_size, @grid_size) @move_events.each { |e| rect.x = (e.x - @draw_range_begin.<img src='http://rpgmkr.net/forum/public/style_emoticons/<#EMO_DIR#>/sourirex.gif' class='bbc_emoticon' alt='X)' /> * @grid_size rect.y = (e.y - @draw_range_begin.y) * @grid_size bitmap.fill_rect(rect, KMS_MiniMap::MOVE_EVENT_COLOR) } end #-------------------------------------------------------------------------- # ○ アニメーション更新 #-------------------------------------------------------------------------- def update_animation if @showing # フェードイン self.opacity += 16 if opacity == 255 @showing = false end elsif @hiding # フェードアウト self.opacity -= 16 if opacity == 0 @hiding = false self.visible = false end end end #-------------------------------------------------------------------------- # ○ オブジェクト描画 #-------------------------------------------------------------------------- def draw_object # 下準備 bitmap = @object_sprite.bitmap bitmap.clear rect = Rect.new(0, 0, @grid_size, @grid_size) # オブジェクト描画 @object_list.each { |obj| next unless in_draw_range?(obj.x, obj.y) color = KMS_MiniMap::OBJECT_COLOR[obj.minimap_object_type - 1] next if color.nil? rect.x = (obj.real_x - @draw_range_begin.<img src='http://rpgmkr.net/forum/public/style_emoticons/<#EMO_DIR#>/sourirex.gif' class='bbc_emoticon' alt='X)' /> * @grid_size rect.y = (obj.real_y - @draw_range_begin.y) * @grid_size bitmap.fill_rect(rect, color) } # 乗り物描画 $game_map.vehicles.each { |vehicle| next if vehicle.transparent rect.x = (vehicle.real_x - @draw_range_begin.<img src='http://rpgmkr.net/forum/public/style_emoticons/<#EMO_DIR#>/sourirex.gif' class='bbc_emoticon' alt='X)' /> * @grid_size rect.y = (vehicle.real_y - @draw_range_begin.y) * @grid_size bitmap.fill_rect(rect, KMS_MiniMap::VEHICLE_COLOR) } end #-------------------------------------------------------------------------- # ○ 更新 #-------------------------------------------------------------------------- def update update_input return if !visible || opacity == 0 update_draw_range update_position update_animation draw_object @map_sprite.update @object_sprite.update @position_sprite.update end end #============================================================================== # □ Sprite_MiniMapIcon #------------------------------------------------------------------------------ # ミニマップ用アイコンのクラスです。 #============================================================================== class Sprite_MiniMapIcon < Sprite DURATION_MAX = 60 #-------------------------------------------------------------------------- # ● オブジェクト初期化 # viewport : ビューポート #-------------------------------------------------------------------------- def initialize(viewport = nil) super(viewport) @duration = DURATION_MAX / 2 end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super @duration += 1 if @duration == DURATION_MAX @duration = 0 end update_effect end #-------------------------------------------------------------------------- # ○ エフェクトの更新 #-------------------------------------------------------------------------- def update_effect self.color.set(255, 255, 255, (@duration - DURATION_MAX / 2).abs * KMS_MiniMap::BLINK_LEVEL ) end end #============================================================================== # ■ Spriteset_Map #============================================================================== class Spriteset_Map attr_reader :minimap #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias initialize_KMS_MiniMap initialize def initialize initialize_KMS_MiniMap create_minimap end #-------------------------------------------------------------------------- # ○ ミニマップの作成 #-------------------------------------------------------------------------- def create_minimap return unless $game_map.minimap_show? @minimap = Game_MiniMap.new(@tilemap) @minimap.visible = $game_system.minimap_show end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- alias dispose_KMS_MiniMap dispose def dispose dispose_KMS_MiniMap dispose_minimap end #-------------------------------------------------------------------------- # ○ ミニマップの解放 #-------------------------------------------------------------------------- def dispose_minimap @minimap.dispose unless @minimap.nil? end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- alias update_KMS_MiniMap update def update update_KMS_MiniMap update_minimap end #-------------------------------------------------------------------------- # ○ ミニマップ更新 #-------------------------------------------------------------------------- def update_minimap return if @minimap.nil? # 表示切替 @minimap.visible = $game_system.minimap_show # フェード判定 case $game_map.minimap_fade when Game_Map::MINIMAP_FADE_IN @minimap.fadein $game_map.minimap_fade = Game_Map::MINIMAP_FADE_NONE when Game_Map::MINIMAP_FADE_OUT @minimap.fadeout $game_map.minimap_fade = Game_Map::MINIMAP_FADE_NONE end @minimap.update end #-------------------------------------------------------------------------- # ○ ミニマップ全体をリフレッシュ #-------------------------------------------------------------------------- def refresh_minimap return if @minimap.nil? @minimap.clear_passage_table_cache @minimap.refresh end #-------------------------------------------------------------------------- # ○ ミニマップのオブジェクトを更新 #-------------------------------------------------------------------------- def update_minimap_object @minimap.update_object_list unless @minimap.nil? end end #============================================================================== # ■ Scene_Map #============================================================================== class Scene_Map #-------------------------------------------------------------------------- # ● 場所移動後の処理 #-------------------------------------------------------------------------- alias post_transfer_KMS_MiniMap post_transfer def post_transfer refresh_minimap post_transfer_KMS_MiniMap end #-------------------------------------------------------------------------- # ○ ミニマップ全体をリフレッシュ #-------------------------------------------------------------------------- def refresh_minimap @spriteset.refresh_minimap end #-------------------------------------------------------------------------- # ○ ミニマップのオブジェクトを更新 #-------------------------------------------------------------------------- def update_minimap_object @spriteset.update_minimap_object end end Note dell'Autore:
      Termini e condizioni d'uso sullo script, nel sito dell'autore:
      http://ytomy.sakura.ne.jp/tkool/rpgtech/rules.html]http://ytomy.sakura....tech/rules.html
    • Da Ally
      Nome Script: HUD su Mappa
      Versione: N/D
      Autore/i: Jet
       
      Informazioni:
      HUD che inserisce barre HP, MP etc, e da la possibilità di inserire anche picture extra nel caso voleste aggiungere altro su mappa.
       
      Screenshots:
       
       
       
      Istruzioni:
      Inserite lo script sotto Material.
       
      Nella demo comunque sono presenti (oltre che allo script) istruzioni e immagini necessarie per il corretto funzionamento dell'HUD.
       
      Script:
       

      #=============================================================================== # HUD # By Jet10985 (Jet) #=============================================================================== # This script will allow you to have a fully customizable hud displaying # multiple pictures and actor-related information. # This script has: 7 customization options. #=============================================================================== # Overwritten Methods: # None #------------------------------------------------------------------------------- # Aliased methods: # Spriteset_Map: initialize, update, dispose #=============================================================================== =begin Note: all pictures used in this HUD must be in the Graphics/Pictures folder. =end module Jet module HUD # These are the bars of the HUD. These takes highest display priority of # the entire hud. It follows this format: # :stat => ["Background", "Bar Image", "Overlay", x, y, switch] # Bars have 3 layers, drawn in this order: background, bar, overlay. # If you don't need one of these layers, leave the configuration as a "", # EX: :hp => ["Bar Back", "Hp Bar", "", 0, 10, 0] # switch is the visibility switch for the bar. 0 for none. BARS = { :hp => ["Bar Back", "HP Bar", "HP Overlay", 0, 10, 0], :mp => ["Bar Back", "MP Bar", "MP Overlay", 0, 40, 0], :tp => ["Bar Back", "TP Bar", "TP Overlay", 0, 70, 0] } # These are extra parts of the HUD which relate to the 1st actor. This # takes middle display priority in the HUD. Follow's this format: # :symbol => [x, y] # :symbol can be any of the following: # :graphic (Character Sprite) # :face (Character Face) # :name (Character name) # :class (Character class) # :nickname (Character nickname) # :level (Character Level) # :icons (Character buffs and states represented by icons) # :hp (Character hp in text along with default gauge) # :mp (Character mp in text along with default gauge) # :tp (Character tp in text along with default gauge) ACTOR_EXTRAS = { :face => [544 - 96, 0] } # This is the font used for the extra's sprite if text is drawn. ACTOR_EXTRAS_FONT = "Verdana" # This is the switch to make the extra's layer invisible ACTOR_EXTRAS_SWITCH = 0 # These are pictures displayed with the HUD. These take the lowest display # priority of the 3 sections. Follow this format: # "Picture Name" => [x, y, switch] # switch is the visiblility switch for this specific picture. PICTURES = { "Bar Back" => [250, 250, 0] } # Turning this switch on will make the entire HUD invisible. FULL_HUD_SWITCH = 1 # Do you want the HUD to follow any map shaking/scrolling/tinting? FOLLOW_MAP = true end end #=============================================================================== # DON'T EDIT FURTHER UNLESS YOU KNOW WHAT TO DO. #=============================================================================== ($imported ||= {})[:jet] ||= {} $imported[:jet][:HUD] = true class Spriteset_Map alias jet4856_initialize initialize def initialize(*args, &block) create_hud jet4856_initialize(*args, &block) @hudset.viewport = Jet::HUD::FOLLOW_MAP ? @viewport1 : nil end def create_hud @hudset = Spriteset_HUD.new end alias jet3745_update update def update(*args, &block) jet3745_update(*args, &block) update_hud end def update_hud if [email protected]? @hudset.visible = !$game_switches[Jet] @hudset.update end end alias jet7355_dispose dispose def dispose(*args, &block) dispose_hud jet7355_dispose(*args, &block) end def dispose_hud @hudset.dispose end end class Spriteset_HUD attr_reader :sprites, :actor attr_accessor :viewport def initialize(viewport = nil) @sprites = {} @actor = $game_party.members[0] @actor_extras = !Jet::HUD::ACTOR_EXTRAS.empty? if @actor_extras @actor_struct = Struct.new(*Jet::HUD::ACTOR_EXTRAS.keys).new Jet::HUD::ACTOR_EXTRAS.each_key {|a| @actor_struct.send("#{a}=".to_sym, (@actor.send(a) rescue true)) } end @viewport = viewport create_bars create_actor_extras if @actor_extras create_pictures @visible = 0 self.visible = !$game_switches[Jet] update end def create_bars @sprites[:bars] = {} Jet::HUD::BARS.each {|a, b| @sprites[:bars][a] = [] b[0..2].each {|c| if c == "" @sprites[:bars][a].push(Sprite.new) next end bitmap = Cache.picture(c) sprite = b.index(c) == 1 ? Sprite_Bar.new(@actor, a) : Sprite.new sprite.bitmap = bitmap sprite.x = b[3] sprite.y = b[4] @sprites[:bars][a].push(sprite) sprite.z = 1002 } } end def create_actor_extras f = Window_Base.new(0, 0, 32, 32) x = 0 - f.padding; y = 0 - f.padding width = Graphics.width + f.padding * 2 height = Graphics.height + f.padding * 2 f.dispose @sprites[:extras] = Window_Base.new(x, y, width, height) @sprites[:extras].opacity = 0 @sprites[:extras].contents.font.name = Jet::HUD::ACTOR_EXTRAS_FONT @sprites[:extras].z = 1001 Jet::HUD::ACTOR_EXTRAS.each {|a, b| @sprites[:extras].send("draw_actor_#{a}", @actor, b[0], b[1]) } end def create_pictures @sprites[:pictures] = {} Jet::HUD::PICTURES.each {|a, b| bitmap = Cache.picture(a) sprite = Sprite.new(nil) sprite.bitmap = bitmap sprite.x, sprite.y = *b[0...2] @sprites[:pictures][a] = sprite sprite.z = 1000 } end def update if @actor != $game_party.members[0] @actor = $game_party.members[0] dispose_actor_extras create_actor_extras dispose_bars create_bars end if @actor_extras do_refresh = false Jet::HUD::ACTOR_EXTRAS.each_key {|a| if @actor_struct.send(a) != (@actor.send(a) rescue true) do_refresh = true @actor_struct.send("#{a}=".to_sym, (@actor.send(a) rescue true)) end } if do_refresh dispose_actor_extras create_actor_extras end end return if !@visible update_bars update_actor_extras if @actor_extras update_pictures end def update_bars @sprites[:bars].each {|sym, a| a.each {|b| b.visible = !$game_switches[Jet][5]] b.update if b.visible b.viewport = @viewport } } end def update_actor_extras @sprites[:extras].visible = !$game_switches[Jet] @sprites[:extras].viewport = @viewport end def update_pictures @sprites[:pictures].each {|string, a| a.visible = !$game_switches[Jet][2]] a.viewport = @viewport } end def update_visibility @sprites[:pictures].each {|string, a| a.visible = @visible } @sprites[:extras].visible = @visible if @actor_extras @sprites[:bars].each {|sym, a| a.each {|b| b.visible = @visible } } end def dispose dispose_bars dispose_actor_extras if @actor_extras dispose_pictures end def dispose_bars @sprites[:bars].each_value {|a| a.each {|b| b.dispose } } end def dispose_actor_extras @sprites[:extras].dispose end def dispose_pictures @sprites[:pictures].each_value {|a| a.dispose } end def visible=(t) if @visible != t @visible = t update_visibility end end end class Sprite_Bar < Sprite def initialize(actor, type) super(nil) @actor = actor @type = type end def update begin max = @actor.send(("m" + @type.to_s).to_sym) rescue max = @actor.send(("max_" + @type.to_s).to_sym) end cur = @actor.send(@type) self.src_rect.width = (self.bitmap.width * (cur / max.to_f)).round end end Demo:http://dl.dropbox.com/u/35988679/HUD%20Demo.exe
    • Da Ally
      Nome Script: Angelo HUD
      Versione: burandon
      Autore/i: 2.5
       
      Informazioni:
      Semplice script che può essere personalizzato in vari modi (vedere le istruzioni all'interno dello script stesso) :3
       
      Screenshots:
       
       
       
      Istruzioni:
      Inserite lo script sotto Material.
      Istruzioni all'interno dello script.
       
      Script:
       

      #============================================================================== # ■ Angelo HUD v2.5 #------------------------------------------------------------------------------ #  Created by Brandon *** 8(13) customization options *** Plug N' Play! #============================================================================== #==================================================# # ▼ UPDATE LOG # #--------#--------------------------------#--------# # v1 ● first release. # # v1.2 ● not released, # # ● add HUDVISIBLESWITCH # # ● add HP, MPSWITCH # # v1.5 ● not released, # # ● add FONT NAME & SIZE # # v1.8 ● not released, # # ● add WEAPONSWITCH # # v1.9 ● not released # # ● *BUG* Lag # # ● *BUG* Texts disappea- # # rence. # # v2 ● second release # # ● fixed v1.9 *BUGS* # # ● add R, G, B _BLA & # # _BDA # # ● *BUG* Transfer Player # # crash. # # v2.1 ● third release # # ● fixed v2 *BUG* # # ● changed update method # # ● changed Scene_Map # # update and dispose # # methods. # # ● *BUG* Lag # # v2.2 ● fourth release # # ● fixed v2.1 *BUG* # # ● now HUD will only re- # # fresh when the stats # # change. # # ● improved performance # #--------#--------------------------------#--------# # v2.5 ● current release # # ● improved stability # # ● added a option to link with other Angelo# # scripts # # ● -------------------------------- # # ● added gold count if Angelo Menu is pre- # # sent. # #==================================================# # ▼ THANKS TO: # # ● King of Sadism # # ● YF # # ● Valiant # # ● Amy Pond # # ● Jet # #==================================================# #------------------------------------------------------------------------------ # ▼ Customization Options #----------------------------#------------------------------------------------- # ● HUD_VISIBLE_SWITCH # #- - - - - - - - - - - - - # # Define the switch that you want to use to turn the HUD 'ON' or 'OFF', by de- # fault it's 1. When the switch is turned 'ON' the HUD will be turned 'ON' too, # and when the switch is turned 'OFF' the HUD is turned 'OFF' too. #------------------------------#----------------------------------------------- # ● FONT_NAME & FONT_SIZE # #- - - - - - - - - - - - - - # # In FONTNAME you define the font that you want to use with the HUD information. # In FONTSIZE you define the size of the font you've decided in FONTNAME. #-------------------#---------------------------------------------------------- # ● HP_SWITCH # #- - - - - - - - -# # Define the switch that you want to use to turn the HP Display 'ON' or 'OFF', # by default it's 2. When the switch is turned 'ON' the HP Display will be # turned 'ON' too, and when the switch is turned 'OFF' the HP Display is turned # 'OFF' too. #-------------------#---------------------------------------------------------- # ● MP_SWITCH # #- - - - - - - - -# # Define the switch that you want to use to turn the MP Display 'ON' or 'OFF', # by default it's 3. When the switch is turned 'ON' the MP Display will be # turned 'ON' too, and when the switch is turned 'OFF' the MP Display is turned # 'OFF' too. #------------------------------#----------------------------------------------- # ● WEAPON_AND_NAME_SWITCH # #- - - - - - - - - - - - - - # # Define the switch that you want to use to turn the Currently Equipped Weapon # Display and Actor Name 'ON' or 'OFF', by default it's 4. When the switch is # turned 'ON' this option will be turned 'ON' too, and when the switch is # turned 'OFF' this option is turned 'OFF' too. #---------------------#-------------------------------------------------------- # ● R, G, B _BLA # #- - - - - - - - - -# # Define the amount of each color(Red, Green, Blue) presented in the lighter a- # rea of the Back of the HUD. By default it's black which means that R, G and B # are setted to '0'. #---------------------#-------------------------------------------------------- # ● R, G, B _BDA # #- - - - - - - - - -# # Define the amount of each color(Red, Green, Blue) presented in the darker a- # rea of the Back of the HUD. By default it's black which means that R, G and B # are setted to '0'. #------------------------------------------------------------------------------ # ▼ Post Scriptum #------------------------------------------------------------------------------ # ● "I want to turn all the HUD or only some part of her at the same time with # the same switch, it's possible?" #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Yes, just set the parts you wanted in the same # switch as the HUDVISIBLESWITCH. #------------------------------------------------------------------------------ # ● "Which values you recommend to use in FONTSIZE?" #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Use between 8 and 18, or the text will be too # small or too bigger. But some times it depends # on your FONTNAME. #------------------------------------------------------------------------------ # ● "Which values you recommend to use in R, G, B _BLA and _BDA?" #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # You MUST use ONLY values between 0 and 255. #------------------------------------------------------------------------------ module ANGELO HUD_VISIBLE_SWITCH = 1 FONT_NAME = "Times New Roman" FONT_SIZE = 16 HP_SWITCH = 2 MP_SWITCH = 3 WEAPON_AND_NAME_SWITCH = 4 #=======IMPORTANT=======IMPORTANT=======IMPORTANT=======IMPORTANT=======IMPORTANT # * * * IF YOU ARE USING OTHER ANGELO SCRIPTS, ENABLE THIS * * * #=======IMPORTANT=======IMPORTANT=======IMPORTANT=======IMPORTANT=======IMPORTANT ENABLE_ANGELO_LINK = false R_BLA = 0 G_BLA = 0 B_BLA = 0 R_BDA = 0 G_BDA = 0 B_BDA = 0 end #------------------------------------------------------------------------------ # !!!!DO NOT EDIT FROM HERE UNLESS YOU KNOW WHAT YOU'RE DOING!!!! #------------------------------------------------------------------------------ include ANGELO class AngeloHUD < Window_Base def initialize super(-16, -16, Graphics.width + standard_padding * 2, Graphics.height + standard_padding * 2) self.opacity = 0 $AngeloHUD = true refresh end def refresh self.contents.clear self.contents.font = Font.new(FONT_NAME, FONT_SIZE) actor = $game_party.members[0] @hp = actor.hp @mp = actor.mp @mhp = actor.mhp @mmp = actor.mmp index = 0 colorback = Color.new(R_BLA, G_BLA, B_BLA, 150) colorback2 = Color.new(R_BDA, G_BDA, B_BDA, 190) if $game_switches[HUD_VISIBLE_SWITCH] == true unless $game_switches[HP_SWITCH] == false self.contents.fill_rect(3, 364, 238, 16, colorback) self.contents.fill_rect(3, 368, 238, 8, colorback2) draw_gauge(19, 353, 200, actor.hp_rate, hp_gauge_color1, hp_gauge_color2) draw_text(40, 354, 100, 32, Vocab::hp_a) draw_current_and_max_values(90, 358, 116, actor.hp, actor.mhp, hp_color(actor), normal_color) end unless $game_switches[MP_SWITCH] == false self.contents.fill_rect(3, 395, 238, 16, colorback) self.contents.fill_rect(3, 399, 238, 8, colorback2) draw_gauge(19, 384, 200, actor.mp_rate, mp_gauge_color1, mp_gauge_color2) draw_text(40, 385, 100, 32, Vocab::mp_a) draw_current_and_max_values(90, 389, 116, actor.mp, actor.mmp, mp_color(actor), normal_color) end unless $game_switches[WEAPON_AND_NAME_SWITCH] == false self.contents.fill_rect(-64 + 85, 376, 125, 19, colorback) self.contents.fill_rect(-64 + 90, 376, 115, 19, colorback2) draw_actor_name(actor, -40 + 92, 373, 100) return unless actor.equips[index] draw_icon(actor.equips[index].icon_index, -64 + 92, 372, true)#(actor.equips[index], -64 + 92, 376, true) end end def hud_changed return true if @hp != $game_party.members[0].hp return true if @mp != $game_party.members[0].mp return true if $game_switches[HP_SWITCH] != "OFF" return true if $game_switches[MP_SWITCH] != "OFF" return true if $game_switches[WEAPON_AND_NAME_SWITCH] != "OFF" return true if $game_switches[HUD_VISIBLE_SWITCH] != "OFF" return false end end def update super refresh if hud_changed end end class Scene_Map alias hud_main create_all_windows def create_all_windows create_hud_window hud_main end def create_hud_window @hud = AngeloHUD.new if ENABLE_ANGELO_LINK && $Menu_Angelo == true @gold = Window_Gold.new @gold.opacity = 0 @gold.x = 544 - @gold.contents.width - 10 @gold.y = 375 end end end
×