RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
A very simple Window_Base add-on

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 89
I am yourself!
Hello,
after first failure, now I always tested my scripts, and this is one of my scripts.
Enjoy!

Code: [Select]
#=============================================================================
# Window_Base Add on
#-----------------------------------------------------------------------------
# ** Version 1.0
# ** Based on Tsunokiette's script
# ** Modified by Sthrattoff
#=============================================================================

# Description :
# This script add some capabilities to Window_Base by enabling user to draw hp /
# sp bar, draw faceset and support for longer hp / sp name

# Instruction :
# 1. draw_actor_face --> for drawing actor's face
# 2. draw_actor_hpbar --> for drawing actor's hp bar
# 3. draw_actor_spbar --> for drawing actor's sp bar
# 4. For face picture, the file name MUST exactly same to actor's name on
#    database and the size must be 72x72
# 5. Import the face picture to Picture

# Credits :
# See the header + Enterbrain
#=============================================================================

class Window_Base < Window
     
  #--------------------------------------------------------------------------
  # * Draw HP
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : draw spot width
  #--------------------------------------------------------------------------
  def draw_actor_hp(actor, x, y, width = 144)
    # Draw "HP" text string
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 96, 32, $data_system.words.hp)
    # Calculate if there is draw space for MaxHP
    if width - 32 >= 108
      hp_x = x + width - 108
      flag = true
    elsif width - 32 >= 48
      hp_x = x + width - 48
      flag = false
    end
    # Draw HP
    self.contents.font.color = actor.hp == 0 ? knockout_color :
      actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
    self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2)
    # Draw MaxHP
    if flag
      self.contents.font.color = normal_color
      self.contents.draw_text(hp_x + 48, y, 12, 32, "/", 1)
      self.contents.draw_text(hp_x + 60, y, 48, 32, actor.maxhp.to_s)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw SP
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : draw spot width
  #--------------------------------------------------------------------------
  def draw_actor_sp(actor, x, y, width = 144)
    # Draw "SP" text string
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 96, 32, $data_system.words.sp)
    # Calculate if there is draw space for MaxHP
    if width - 32 >= 108
      sp_x = x + width - 108
      flag = true
    elsif width - 32 >= 48
      sp_x = x + width - 48
      flag = false
    end
    # Draw SP
    self.contents.font.color = actor.sp == 0 ? knockout_color :
      actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
    self.contents.draw_text(sp_x, y, 48, 32, actor.sp.to_s, 2)
    # Draw MaxSP
    if flag
      self.contents.font.color = normal_color
      self.contents.draw_text(sp_x + 48, y, 12, 32, "/", 1)
      self.contents.draw_text(sp_x + 60, y, 48, 32, actor.maxsp.to_s)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Face
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_face(actor, x, y)
    bitmap = RPG::Cache.picture(actor.name)
    self.contents.blt(x, y, bitmap, Rect.new(0, 0, 72, 72))
  end
  #--------------------------------------------------------------------------
  # * Draw HP Bar
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_hpbar(actor, x, y, w = 200)
    # Defines actor hp and maxhp
    vitality = actor.hp
    maxvitality = actor.maxhp
    # Defines color used on bar
    bordercolor = system_color
    outercolor  = Color.new(220, 10, 0, 255)
    midcolor    = Color.new(220, 35, 0, 255)
    innercolor  = Color.new(220, 60, 0, 255)
    emptycolor  = Color.new(0, 0, 0, 255)
    # Defines length of bar
    linewidth = (((vitality * 1.0) / maxvitality) * (w - 2))
    emptywidth = ((w - 1) - linewidth)
    emptyx = ((x + 1) + linewidth)
    # Drawing line and border
    borderup = Rect.new(x, y, w, 1)
    borderleft = Rect.new(x, y + 1, 1, 6)
    borderdown = Rect.new(x, y + 7, w, 1)
    borderright = Rect.new(x + w - 1, y + 1, 1, 6)
    emptyline = Rect.new(x + 1, y + 1, w - 2, 6)
    outerline = Rect.new(x + 1, y + 1, linewidth, 6)
    midline = Rect.new(x + 2, y + 2, linewidth - 2, 4)
    innerline = Rect.new(x + 3, y + 3, linewidth - 4, 2)
    # Coloring the bar
    self.contents.fill_rect(borderup, bordercolor)
    self.contents.fill_rect(borderleft, bordercolor)
    self.contents.fill_rect(borderdown, bordercolor)
    self.contents.fill_rect(borderright, bordercolor)
    self.contents.fill_rect(emptyline, emptycolor)
    self.contents.fill_rect(outerline, outercolor)
    self.contents.fill_rect(midline, midcolor)
    self.contents.fill_rect(innerline, innercolor)
  end
  #--------------------------------------------------------------------------
  # * Draw SP Bar
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_spbar(actor, x, y, w = 200)
    # Defines actor sp and maxsp
    force = actor.sp
    maxforce = actor.maxsp
    # Defines color used on bar
    bordercolor = system_color
    outercolor = Color.new(0, 110, 180, 255)
    midcolor = Color.new(0, 135, 180, 255)
    innercolor = Color.new(0, 160, 180, 255)
    emptycolor = Color.new(0, 0, 0, 255)
    # Defines length of bar
    linewidth = (((force * 1.0) / maxforce) * (w - 2))
    emptywidth = ((w - 1) - linewidth)
    emptyx = ((x + 1) + linewidth)
    # Drawing line and border
    borderup = Rect.new(x, y, w, 1)
    borderleft = Rect.new(x, y + 1, 1, 6)
    borderdown = Rect.new(x, y + 7, w, 1)
    borderright = Rect.new(x + w - 1, y + 1, 1, 6)
    emptyline = Rect.new(x + 1, y + 1, w - 2, 6)
    outerline = Rect.new(x + 1, y + 1, linewidth, 6)
    midline = Rect.new(x + 2, y + 2, linewidth - 2, 4)
    innerline = Rect.new(x + 3, y + 3, linewidth - 4, 2)
    # Coloring the bar
    self.contents.fill_rect(borderup, bordercolor)
    self.contents.fill_rect(borderleft, bordercolor)
    self.contents.fill_rect(borderdown, bordercolor)
    self.contents.fill_rect(borderright, bordercolor)
    self.contents.fill_rect(emptyline, emptycolor)
    self.contents.fill_rect(outerline, outercolor)
    self.contents.fill_rect(midline, midcolor)
    self.contents.fill_rect(innerline, innercolor)
  end
 
end
Symphony of Alderra : Memoirs of Life

Storyline : 200% (Overimaginatives)
Scripting : 100% (At last...)
Eventing  : 100%
Mapping   : 0.125%

******
Revolution is not a bed of roses.
Rep:
Level 91
Project of the Month winner for July 2009
Pretty cool, this could help a lot of beginning scripters :)

***
Rep:
Level 89
I am yourself!
Thanks ya...
Symphony of Alderra : Memoirs of Life

Storyline : 200% (Overimaginatives)
Scripting : 100% (At last...)
Eventing  : 100%
Mapping   : 0.125%

********
Rep:
Level 96
2011 Most Missed Member2010 Zero To Hero
Righteous script work bra.

********
EXA
Rep:
Level 92
Pikachu on a toilet
Project of the Month winner for April 2007
Keep up the good work. :)
Get King of Booze for Android, for iOS, for OUYA or for Windows!
Visit our website.
You can also love/hate us on Facebook or the game itself.


Get DropBox, the best free file syncing service there is!

*
? ? ? ? ? ? ? ? ? The nice kind of alien~
Rep:
Level 92
Martian - Occasionally kind
Yup, keep it up ^_^