CyberForte

DoW HUD

Oct 10th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 11.31 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Battler HUD
  4. # Version 3.0
  5. # By Pacman (rmrk.net)
  6. # Description: There are a lot of battle scripts for VX out there, and they're
  7. # mostly fantastic. However, they all require so much configuration. This script
  8. # is the ultimate plug-and-play battle HUD: all you have to do is put it in the
  9. # editor and alter one thing if you really want to. This script simply puts the
  10. # actor's defined face into the battle window along with their HP and MP.
  11. # There is now also a HUD for the enemy selection part of battle. It contains
  12. # the enemies' names, HPs, MPs and states. You can prevent the HUD from drawing
  13. # these values buy placing certain tags in the enemy's notebox:
  14. #
  15. # UNKNOWN_STATUS      - Nothing is drawn.
  16. # UNKNOWN_STATE       - The states are not drawn.
  17. # UNKNOWN_NAME        - The name is not drawn.
  18. # UNKNOWN_HP          - The HP is not drawn.
  19. # UNKNOWN_MP          - The MP is not drawn.
  20. #
  21. # Instructions: Put this script under materials and above main in the script
  22. # editor. Change CharOpa to the desired opactiy if you wish, and let the
  23. # script do the rest. You can also change the font type, size and colour in the
  24. # configuration.
  25. #
  26. # Support: I reside almost ever-presently at rmrk.net.
  27. #
  28. #===============================================================================
  29.  
  30. module PacBFH   # <- Do not touch
  31. #-------------------------------------------------------------------------------
  32. # EDITING SECTION
  33. #-------------------------------------------------------------------------------
  34.   USE_ACTOR = true  # Use actor HUD?
  35.   USE_ENEMY = true  # Use enemy HUD?
  36.   CharOpa = 150 # Default 150
  37.   ORIG_COLOURS = true # Use original HP/MP colours or my new colours?
  38.   Colour = [255, 255, 255]  # RGB(A) values, separated by commas.
  39.   Size = 17 # Size of the name text
  40.   Font = "Verdana"  # Font of the name text
  41.   HPMP_SIZE = false # Does 'size' apply to the drawing of HP and MP?
  42. #-------------------------------------------------------------------------------
  43. # END EDITING SECTION
  44. #-------------------------------------------------------------------------------
  45. end
  46.  
  47. if PacBFH::USE_ACTOR
  48. #==============================================================================
  49. # ** Window_BattleStatus
  50. #------------------------------------------------------------------------------
  51. #  This window displays the status of all party members on the battle screen.
  52. #==============================================================================
  53.  
  54. class Window_BattleStatus < Window_Selectable
  55.   #--------------------------------------------------------------------------
  56.   # Alias listing
  57.   #--------------------------------------------------------------------------
  58.   alias pacman_WBS_ini initialize unless $@
  59.   #--------------------------------------------------------------------------
  60.   # * Object Initialization
  61.   #--------------------------------------------------------------------------
  62.   def initialize
  63.     super(0, 0, 416, 128, 1)
  64.     @column_max = $game_party.members.size
  65.     refresh
  66.     self.active = false
  67.     self.opacity = 255
  68.     self.cursor_rect.set(0, self.index * 96, 90, 90)
  69.   end
  70.   #--------------------------------------------------------------------------
  71.   # * Draw Item
  72.   #     index : Item number
  73.   #--------------------------------------------------------------------------
  74.   def draw_item(index)
  75.     rect = item_rect(index)
  76.     rect.x += 4
  77.     rect.width -= 8
  78.     rect.height = 96
  79.     self.contents.clear_rect(rect)
  80.     self.contents.font.color = Color.new(*PacBFH::Colour)
  81.     self.contents.font.size = PacBFH::Size
  82.     self.contents.font.name = PacBFH::Font
  83.     actor = $game_party.members[index]
  84.     draw_actor_face2(actor, index * 96,0,80)
  85.     draw_actor_name(actor, index * 96 + 8, 0)
  86.     draw_actor_state(actor, index * 96 + 4, 32, 20)
  87.     self.contents.font.size = PacBFH::HPMP_SIZE ? PacBFH::Size : 14
  88.     draw_hp_and_mp(actor, index * 96, 50, 90)
  89.     self.contents.font.color = Font.default_color
  90.     self.contents.font.name = Font.default_name
  91.     self.contents.font.size = Font.default_size
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # * Frame update for cursor
  95.   #--------------------------------------------------------------------------
  96.   def update_cursor
  97.     if @index < 0
  98.       self.cursor_rect.empty
  99.     else
  100.       self.cursor_rect.set(index*96, 0, 90, 96)
  101.     end
  102.   end
  103. end
  104.  
  105.  
  106. #==============================================================================
  107. # ** Window_Base
  108. #------------------------------------------------------------------------------
  109. #  This is a superclass of all windows in the game.
  110. #==============================================================================
  111.  
  112. class Window_Base < Window
  113.   #--------------------------------------------------------------------------
  114.   # * Secondary Method of drawing actor face
  115.   #     actor : actor
  116.   #     x     : draw spot x-coordinate
  117.   #     y     : draw spot y-coordinate
  118.   #     width : width of box
  119.   #     height: height of box
  120.   #--------------------------------------------------------------------------
  121.   def draw_actor_face2(actor, x, y, width = 96, height = 96)
  122.     draw_face2(actor.face_name, actor.face_index, x, y, width, height)    
  123.   end
  124.   #--------------------------------------------------------------------------
  125.   # * Secondary Method of drawing face graphics
  126.   #     face_name  : Face graphic filename
  127.   #     face_index : Face graphic index
  128.   #     x          : draw spot x-coordinate
  129.   #     y          : draw spot y-coordinate
  130.   #     width      : width of box
  131.   #     height     : height of box
  132.   #--------------------------------------------------------------------------
  133.   def draw_face2(face_name, face_index, x, y, width = 96, height = 96)
  134.     bitmap = Cache.face(face_name)
  135.     rect = Rect.new(0, 0, 0, 0)
  136.     rect.x = face_index % 4 * 96 + (96 - width) / 2
  137.     rect.y = face_index / 4 * 96 + (96 - height) / 2
  138.     rect.width = width
  139.     rect.height = height -10
  140.     self.contents.blt(x + 5, y + 5, bitmap, rect, PacBFH::CharOpa)
  141.     bitmap.dispose
  142.   end
  143.   #--------------------------------------------------------------------------
  144.   # * Draw Actor HP and MP
  145.   #     actor : actor whose stats are to be drawn
  146.   #     x     : draw spot x-coordinate
  147.   #     y     : draw spot y_coordinate
  148.   #     width : width of draw spot
  149.   #--------------------------------------------------------------------------
  150.   def draw_hp_and_mp(actor, x, y, width)
  151.     if PacBFH::ORIG_COLOURS
  152.       back_color = gauge_back_color
  153.       hp_color1 = hp_gauge_color1
  154.       hp_color2 = hp_gauge_color2
  155.       mp_color1 = mp_gauge_color1
  156.       mp_color2 = mp_gauge_color2
  157.     else
  158.       back_color = Color.new(39, 58, 83, 255)
  159.       hp_color1 = Color.new(66, 114, 164, 255)
  160.       hp_color2 = Color.new(122, 175, 229, 255)
  161.       mp_color1 = Color.new(93, 50, 158, 255)
  162.       mp_color2 = Color.new(145, 122, 229, 255)    
  163.     end
  164.     self.contents.fill_rect(x + 5, y + 15, width - 10, 7, back_color)
  165.     self.contents.gradient_fill_rect(x + 7, y + 17, (width - 14) * actor.hp /
  166.      actor.maxhp, 3, hp_color1, hp_color2)
  167.     self.contents.draw_text(x + 5, y, width - 10, 20, Vocab::hp, 0)
  168.     self.contents.draw_text(x + 5, y, width - 10, 20, actor.hp.to_s + "/" +
  169.      actor.maxhp.to_s, 2)
  170.     self.contents.fill_rect(x + 5, y + 35, width - 10, 7, back_color)
  171.     if actor.maxmp != 0
  172.       self.contents.gradient_fill_rect(x + 7, y + 37, (width - 14) * actor.mp /
  173.        actor.maxmp, 3, mp_color1, mp_color2)
  174.     else
  175.       self.contents.gradient_fill_rect(x + 7, y + 37, (width - 14) * actor.mp,
  176.        3, mp_color1, mp_color2)
  177.     end
  178.     self.contents.draw_text(x + 5, y + 20, width - 10, 20, Vocab::mp, 0)
  179.     self.contents.draw_text(x + 5, y + 20, width - 10, 20,
  180.      actor.mp.to_s + "/" + actor.maxmp.to_s, 2)
  181.   end
  182. end
  183. end
  184.  
  185. if PacBFH::USE_ENEMY
  186. #==============================================================================
  187. # ** Window_TargetEnemy
  188. #------------------------------------------------------------------------------
  189. #  Window for selecting the enemy who is the action target on the battle
  190. # screen.
  191. #==============================================================================
  192.  
  193. class Window_TargetEnemy < Window_Command
  194.   #--------------------------------------------------------------------------
  195.   # * Object Initialization
  196.   #--------------------------------------------------------------------------
  197.   def initialize
  198.     @enemies = []
  199.     commands = []
  200.     $game_troop.members.each do |enemy|
  201.       next unless enemy.exist?
  202.       @enemies.push(enemy)
  203.       commands.push(enemy.name)
  204.     end
  205.     super(416, commands)
  206.     self.height = 128
  207.   end
  208.   #--------------------------------------------------------------------------
  209.   # * Get Enemy Object
  210.   #--------------------------------------------------------------------------
  211.   def enemy
  212.     return @enemies[@index]
  213.   end
  214.   #--------------------------------------------------------------------------
  215.   # * Draw Item
  216.   #     index : item number
  217.   #--------------------------------------------------------------------------
  218.   def draw_item(index)
  219.     rect = item_rect(index)
  220.     rect.x += 4
  221.     rect.width -= 8
  222.     self.contents.clear_rect(rect)
  223.     self.contents.font.color = normal_color
  224.     actor = @enemies[index]
  225.     unless actor.stat_note?('UNKNOWN_STATUS')
  226.       draw_actor_name(actor, 4, rect.y) unless actor.stat_note?('UNKNOW_NAME')
  227.       unless actor.stat_note?('UNKNOWN_STATUS')
  228.         draw_actor_state(actor, 114, rect.y, 48)
  229.       end
  230.       unless actor.stat_note?('UNKNOWN_HP')
  231.         draw_actor_hp(actor, 174, rect.y, 120)
  232.       end
  233.       unless actor.stat_note?('UNKNOWN_MP')
  234.         draw_actor_mp(actor, 310, rect.y, 70)
  235.       end
  236.     end
  237.   end
  238. end
  239.  
  240. #==============================================================================
  241. # ** Game_Enemy
  242. #------------------------------------------------------------------------------
  243. #  This class handles enemy characters. It's used within the Game_Troop class
  244. # ($game_troop).
  245. #==============================================================================
  246.  
  247. class Game_Enemy < Game_Battler
  248.   #--------------------------------------------------------------------------
  249.   # Public Instance Variables
  250.   #--------------------------------------------------------------------------
  251.   attr_reader :status_note
  252.   #--------------------------------------------------------------------------
  253.   # Alias listing
  254.   #--------------------------------------------------------------------------
  255.   alias pac_unstat_ini initialize unless $@
  256.   #--------------------------------------------------------------------------
  257.   # * Object Initialization
  258.   #--------------------------------------------------------------------------
  259.   def initialize(*args)
  260.     pac_unstat_ini(*args)
  261.     @status_note = enemy.note
  262.   end
  263.   #--------------------------------------------------------------------------
  264.   # * Get tag from enemy note
  265.   #--------------------------------------------------------------------------
  266.   def stat_note?(note)
  267.     return @status_note.include?(note)
  268.   end
  269. end
  270. end
  271.  
  272. #===============================================================================
  273. #
  274. # END OF SCRIPT
  275. #
  276. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment