Ventwig

Ventwig's Simple Face HUD

Apr 9th, 2012
854
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 10.77 KB | None | 0 0
  1. #============================================================================
  2. #Simple Face HUD
  3. #By Ventwig
  4. #Version 1.31 - April 14 2012
  5. #For RPGMaker VX Ace
  6. #============================================================================
  7. # This is my first script :)
  8. # Since I'm new, I know stuff in this script can be simplified, but oh well
  9. # I decided to try scripting and learned through some videos and the help
  10. # of amazing members on the forums :D
  11. # Also, thanks to XAIL's Simple Gold HUD, I was able to learn off of
  12. # it. For the stuff to show on the map.
  13. #=============================================================================
  14. # Description:
  15. # This piece of code let's you show the player's party (Max 4, Min 1) on the
  16. # top of the screen. It shows the faces of the current party members.
  17. # Only the first four in the party, which is good because there's usually only
  18. # 4 active at a time. You can choose to display names, and choose which
  19. # gauges to be shown, or even draw the sprite graphic!
  20. # Anyways, it centers the faces, too :)
  21. #==============================================================================
  22. # Compatability:
  23. #  alias-es Scene_Map
  24. #  Works with Neo Gauge Ultimate Ace
  25. #===============================================================================
  26. # Instructions: Put in materials, above main. Almost Plug and Play
  27. # Put above Neo Gauge Ultimate Ace if used
  28. #==============================================================================
  29. # Please give Credit to Ventwig if you would like to use one of my scripts
  30. # in a NON-COMMERCIAL project.
  31. # Please ask for permission if you would like to use it in a commercial game.
  32. # You may not re-distribute any of my scripts or claim as your own.
  33. # You may not release edits without permission, combatability patches are okay.
  34. #===============================================================================
  35. class Window_Face_Hud < Window_Base
  36.   #########################################################################
  37.   #Configuration! Three of them!                                          #
  38.   #########################################################################
  39.   #Draw the actors' names on the top of the face? true/false default = true
  40.   DRAW_NAME = true
  41.   #Choos which bars to draw. 1 = HP 2 = MP
  42.   #0 = Both     Anything Higher means none
  43.   #default = 0
  44.   DRAW_BARS = 0
  45.   #Switch to show/hide HUD. Recommended to hide HUD during cut-scenes.
  46.   #default = 100
  47.   #Hide if it is off (default value of switches)
  48.   HIDE_SWITCH = 100
  49.   #Selects whether or not to draw the actor's sprite over their face
  50.   DRAW_SPRITE = true
  51.   #########################################################################
  52.   #End Of configuration. Touch anything below and it'll delete system32   #
  53.   #########################################################################
  54.  
  55.   ###################################################################
  56.   #Sets up what appears in the HUD
  57.   #Questions names and HUD, then displays them
  58.   #################################################################  
  59.   #Set up the window's start-up
  60.   def initialize
  61.     #Draws window
  62.     super(0,0,545,120)
  63.     @x, @y = 5, 50
  64.     @party_size = $game_party.all_members.size
  65.     @switch_current = $game_switches[HIDE_SWITCH]
  66.     face_hud
  67.     check_visible
  68.   end
  69.  
  70.   def face_hud
  71.     #If branches for each party size to set the positioning of items
  72.     if $game_party.all_members.size == 1
  73.       @actor = $game_party.members[0]
  74.       @actor_hp = @actor.hp
  75.       @actor_mp = @actor.mp
  76.       draw_actor_face(@actor, @x+189, @y-50, enabled = true)
  77.       if DRAW_SPRITE == true
  78.         draw_actor_graphic(@actor, @x+10+189, @y+20)
  79.       end
  80.       if DRAW_BARS == 0
  81.         draw_actor_hp(@actor, @x-5+189, @y-50+75-17)
  82.         draw_actor_mp(@actor, @x-5+189, @y-50+75)
  83.       end
  84.       if DRAW_BARS == 1
  85.         draw_actor_hp(@actor, @x-5+189, @y-50+75)
  86.       end
  87.       if DRAW_BARS == 2
  88.         draw_actor_mp(@actor, @x-5+189, @y-50+75)
  89.       end
  90.       if DRAW_NAME
  91.         draw_actor_name(@actor, @x+190, @y-50)
  92.       end
  93.     end
  94.     if $game_party.all_members.size == 2
  95.       @actor = $game_party.members[0]
  96.       @actor2 = $game_party.members[1]
  97.       @actor_hp = @actor.hp
  98.       @actor_mp = @actor.mp
  99.       @actor2_hp = @actor2.hp
  100.       @actor2_mp = @actor2.mp
  101.       draw_actor_face(@actor, @x+126, @y-50, enabled = true)
  102.       draw_actor_face(@actor2, @x+252, @y-50, enabled = true)
  103.       if DRAW_SPRITE == true
  104.         draw_actor_graphic(@actor, @x+10+126, @y+20)
  105.         draw_actor_graphic(@actor2, @x+10+252, @y+20)
  106.       end
  107.       if DRAW_BARS == 0
  108.         draw_actor_hp(@actor, @x-5+126, @y-50+75-17)
  109.         draw_actor_hp(@actor2, @x-5+252, @y-50+75-17)
  110.         draw_actor_mp(@actor, @x-5+126, @y-50+75)
  111.         draw_actor_mp(@actor2, @x-5+252, @y-50+75)
  112.       end
  113.       if DRAW_BARS == 1
  114.         draw_actor_hp(@actor, @x-5+126, @y-50+75)
  115.         draw_actor_hp(@actor2, @x-5+252, @y-50+75)
  116.       end
  117.       if DRAW_BARS == 2
  118.         draw_actor_mp(@actor, @x-5+126, @y-50+75)
  119.         draw_actor_mp(@actor2, @x-5+252, @y-50+75)
  120.       end
  121.       if DRAW_NAME
  122.         draw_actor_name(@actor, @x+126, @y-50)
  123.         draw_actor_name(@actor2, @x+252, @y-50)
  124.       end
  125.     end
  126.     if $game_party.all_members.size == 3
  127.       @actor = $game_party.members[0]
  128.       @actor2 = $game_party.members[1]
  129.       @actor3 = $game_party.members[2]
  130.       @actor_hp = @actor.hp
  131.       @actor_mp = @actor.mp
  132.       @actor2_hp = @actor2.hp
  133.       @actor2_mp = @actor2.mp
  134.       @actor3_hp = @actor3.hp
  135.       @actor3_mp = @actor3.mp
  136.       draw_actor_face(@actor, @x+63, @y-50, enabled = true)
  137.       draw_actor_face(@actor2, @x+189, @y-50, enabled = true)
  138.       draw_actor_face(@actor3, @x+315, @y-50, enabled = true)  
  139.       if DRAW_SPRITE == true
  140.         draw_actor_graphic(@actor, @x+10+63, @y+20)
  141.         draw_actor_graphic(@actor2, @x+10+189, @y+20)
  142.         draw_actor_graphic(@actor3, @x+10+315, @y+20)
  143.       end
  144.       if DRAW_BARS == 0
  145.         draw_actor_hp(@actor, @x-5+63, @y-50+75-17)
  146.         draw_actor_hp(@actor2, @x-5+189, @y-50+75-17)
  147.         draw_actor_hp(@actor3, @x-5+315, @y-50+75-17)
  148.         draw_actor_mp(@actor, @x-5+63, @y-50+75)
  149.         draw_actor_mp(@actor2, @x-5+189, @y-50+75)
  150.         draw_actor_mp(@actor3, @x-5+315, @y-50+75)
  151.       end
  152.       if DRAW_BARS == 1
  153.         draw_actor_hp(@actor, @x-5+63, @y-50+75)
  154.         draw_actor_hp(@actor2, @x-5+189, @y-50+75)
  155.         draw_actor_hp(@actor3, @x-5+315, @y-50+75)
  156.       end
  157.       if DRAW_BARS == 2
  158.         draw_actor_mp(@actor, @x-5+63, @y-50+75)
  159.         draw_actor_mp(@actor2, @x-5+189, @y-50+75)
  160.         draw_actor_mp(@actor3, @x-5+315, @y-50+75)
  161.       end
  162.       if DRAW_NAME
  163.         draw_actor_name(@actor, @x+63, @y-50)
  164.         draw_actor_name(@actor2, @x+189, @y-50)
  165.         draw_actor_name(@actor3, @x+315, @y-50)
  166.       end
  167.   end
  168.     if $game_party.all_members.size > 3
  169.       @actor = $game_party.members[0]
  170.       @actor2 = $game_party.members[1]
  171.       @actor3 = $game_party.members[2]
  172.       @actor4 = $game_party.members[3]
  173.       @actor_hp = @actor.hp
  174.       @actor_mp = @actor.mp
  175.       @actor2_hp = @actor2.hp
  176.       @actor2_mp = @actor2.mp
  177.       @actor3_hp = @actor3.hp
  178.       @actor3_mp = @actor3.mp
  179.       @actor4_hp = @actor4.hp
  180.       @actor4_mp = @actor4.mp
  181.       draw_actor_face(@actor, @x, @y-50, enabled = true)
  182.       draw_actor_face(@actor2, @x+126, @y-50, enabled = true)
  183.       draw_actor_face(@actor3, @x+252, @y-50, enabled = true)            
  184.       draw_actor_face(@actor4, @x+378, @y-50, enabled = true)  
  185.       if DRAW_SPRITE == true
  186.         draw_actor_graphic(@actor, @x+10, @y+20)
  187.         draw_actor_graphic(@actor2, @x+10+126, @y+20)
  188.         draw_actor_graphic(@actor3, @x+10+252, @y+20)
  189.         draw_actor_graphic(@actor4, @x+10+378, @y+20)
  190.       end
  191.       if DRAW_BARS == 0
  192.         draw_actor_hp(@actor, @x-5, @y-50+75-17)
  193.         draw_actor_hp(@actor2, @x-5+126, @y-50+75-17)
  194.         draw_actor_hp(@actor3, @x-5+252, @y-50+75-17)
  195.         draw_actor_hp(@actor4, @x-5+378, @y-50+75-17)
  196.         draw_actor_mp(@actor, @x-5, @y-50+75)
  197.         draw_actor_mp(@actor2, @x-5+126, @y-50+75)
  198.         draw_actor_mp(@actor3, @x-5+252, @y-50+75)
  199.         draw_actor_mp(@actor4, @x-5+378, @y-50+75)
  200.       end
  201.       if DRAW_BARS == 1
  202.         draw_actor_hp(@actor, @x-5, @y-50+75)
  203.         draw_actor_hp(@actor2, @x-5+126, @y-50+75)
  204.         draw_actor_hp(@actor3, @x-5+252, @y-50+75)
  205.         draw_actor_hp(@actor4, @x-5+378, @y-50+75)
  206.       end
  207.       if DRAW_BARS == 2
  208.         draw_actor_mp(@actor, @x-5, @y-50+75)
  209.         draw_actor_mp(@actor2, @x-5+126, @y-50+75)
  210.         draw_actor_mp(@actor3, @x-5+252, @y-50+75)
  211.         draw_actor_mp(@actor4, @x-5+378, @y-50+75)
  212.       end
  213.       if DRAW_NAME
  214.         draw_actor_name(@actor, @x, @y-50)
  215.         draw_actor_name(@actor2, @x+126, @y-50)
  216.         draw_actor_name(@actor3, @x+252, @y-50)
  217.         draw_actor_name(@actor4, @x+378, @y-50)
  218.       end
  219.     end
  220.           check_visible
  221.   end
  222.    
  223.   def check_visible
  224.     if $game_switches[HIDE_SWITCH] != @switches_current
  225.       self.visible = $game_switches[HIDE_SWITCH]
  226.       @switches_current = $game_switches[HIDE_SWITCH]
  227.     end
  228.   end
  229.    
  230.  
  231. ###################################################################
  232. #Refresh the window to show all changes to the HUD
  233. #It just copies the intizalize code.
  234. #Also choose when to update
  235. #################################################################
  236.      
  237.   def refresh
  238.     contents.clear
  239.     face_hud
  240.     @party_size = $game_party.all_members.size
  241.   end
  242.        
  243.   def update
  244.     super
  245.     check_visible
  246.     if @party_size != $game_party.all_members.size
  247.       refresh
  248.     end
  249.     if @party_size > 0
  250.       if $game_party.members[0].hp != @actor_hp  or $game_party.members[0].mp != @actor_mp
  251.         refresh
  252.       end
  253.     end
  254.     if @party_size > 1
  255.       if $game_party.members[1].hp != @actor2_hp or $game_party.members[1].mp != @actor2_mp
  256.         refresh
  257.       end
  258.     end  
  259.     if @party_size > 2
  260.       if $game_party.members[2].hp != @actor3_hp or $game_party.members[2].mp != @actor3_mp
  261.         refresh
  262.       end
  263.     end
  264.     if @party_size > 3
  265.       if $game_party.members[3].hp != @actor4_hp or $game_party.members[3].mp != @actor4_mp
  266.         refresh
  267.       end
  268.     end
  269.   end
  270. end  
  271.  
  272. #Show the window on the map
  273. class Scene_Map < Scene_Base
  274.   alias original_create_all_windows create_all_windows
  275.     def create_all_windows
  276.       original_create_all_windows
  277.       create_face_window
  278.     end
  279.     def create_face_window
  280.       @face_window = Window_Face_Hud.new
  281.     end
  282. end
  283.   #########################################################################
  284.   #End Of Script                                                          #
  285.   #########################################################################
Advertisement
Add Comment
Please, Sign In to add comment