Ventwig

VTS-HorzFace BattleHUD

May 24th, 2013
1,132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 16.30 KB | None | 0 0
  1. #============================================================================
  2. #VTS-HorzFace BattleHud
  3. #By Ventwig
  4. #Version 1 - May 24 2013
  5. #For RPGMaker VX Ace
  6. #============================================================================
  7. # So, here's my second script, which also happens to be a face HUD.
  8. #=============================================================================
  9. # Description:
  10. # This code here takes the bland lines and bars of the normal battle HUD
  11. # and spices it up by showing faces (centered in the window and suppouring
  12. # up to four party members) and full-length bars, too :)
  13. # The party command and actor commands are also turned into cool horizontal
  14. # selectable windows, as well as a few other resizings
  15. #==============================================================================
  16. # Compatability:
  17. #  Don't expect much with anything that involves the basic commands window >.>
  18. #  Works with Neo Gauge Ultimate Ace
  19. #===============================================================================
  20. # Instructions: Put in materials, above main. Almost Plug and Play
  21. # Put above Neo Gauge Ultimate Ace if used
  22. #==============================================================================
  23. # Credit is not required to use my scripts, but you are not allowed to
  24. # re-post them and/or claim them as your own.
  25. # If you would like to make an edit, please contact me first.
  26. #===============================================================================
  27. # NOTES:
  28. # Recommended with Jet's Simple Sideview.
  29. # The overall effect together is simple and amazing in my opinion.
  30. # These are my recommended settings:
  31. #
  32. # FIELD_POS = [400, 180]
  33. # FIELD_SPACING = [25, 20]
  34. #
  35. # FIELD_POS = [400, 200]
  36. # FIELD_SPACING = [30, 15]
  37. #############################################################################
  38. #Customization - There's really none...let me know if you need something!
  39. #############################################################################
  40.  
  41. class Window_BattleStatus < Window_Selectable  
  42.   ###################################################################
  43.   #Sets up what appears in the HUD
  44.   #Questions names and HUD, then displays them
  45.   #################################################################  
  46.   #Set up the window's start-up
  47.   def initialize
  48.         #Draws window
  49.         super(0,0,545,120)
  50.         self.z = 0
  51.         @x, @y = 5, 50
  52.         @party_size = $game_party.all_members.size
  53.         battle_hud
  54.   end
  55.  
  56.   def battle_hud
  57.           if $game_party.all_members.size == 1
  58.             @actor = $game_party.members[0]
  59.             @actor_hp = @actor.hp
  60.             @actor_mp = @actor.mp
  61.             @actor_tp = @actor.tp
  62.             draw_actor_face(@actor, @x+189, @y-50, enabled = true)
  63.             draw_actor_hp(@actor, @x-5+189, @y-50)
  64.             draw_actor_mp(@actor, @x-5+189, @y-50+75-17)
  65.             draw_actor_tp(@actor, @x-5+189, @y-50+75)
  66.             draw_actor_icons(@actor, @x-5+190, @y-10)
  67.           elsif $game_party.all_members.size == 2
  68.             @actor = $game_party.members[0]
  69.             @actor2 = $game_party.members[1]
  70.             @actor_hp = @actor.hp
  71.             @actor_mp = @actor.mp
  72.             @actor2_hp = @actor2.hp
  73.             @actor2_mp = @actor2.mp
  74.             @actor_tp = @actor.tp
  75.             @actor2_tp = @actor2.tp
  76.             draw_actor_face(@actor, @x+126, @y-50, enabled = true)
  77.             draw_actor_face(@actor2, @x+252, @y-50, enabled = true)
  78.             draw_actor_hp(@actor, @x-5+126, @y-50)
  79.             draw_actor_hp(@actor2, @x-5+252, @y-50)
  80.             draw_actor_mp(@actor, @x-5+126, @y-50+75-17)
  81.             draw_actor_mp(@actor2, @x-5+252, @y-50+75-17)
  82.             draw_actor_tp(@actor, @x-5+126, @y-50+75)
  83.             draw_actor_tp(@actor2, @x-5+252, @y-50+75)
  84.             draw_actor_icons(@actor, @x-5+126, @y-10)
  85.             draw_actor_icons(@actor2, @x-5+252, @y-10)
  86.         elsif $game_party.all_members.size == 3
  87.             @actor = $game_party.members[0]
  88.             @actor2 = $game_party.members[1]
  89.             @actor3 = $game_party.members[2]
  90.             @actor_hp = @actor.hp
  91.             @actor_mp = @actor.mp
  92.             @actor2_hp = @actor2.hp
  93.             @actor2_mp = @actor2.mp
  94.             @actor3_hp = @actor3.hp
  95.             @actor3_mp = @actor3.mp
  96.             @actor_tp = @actor.tp
  97.             @actor2_tp = @actor2.tp
  98.             @actor3_tp = @actor3.tp
  99.             draw_actor_face(@actor, @x+63, @y-50, enabled = true)
  100.             draw_actor_face(@actor2, @x+189, @y-50, enabled = true)
  101.             draw_actor_face(@actor3, @x+315, @y-50, enabled = true)  
  102.             draw_actor_hp(@actor, @x-5+63, @y-50)
  103.             draw_actor_hp(@actor2, @x-5+189, @y-50)
  104.             draw_actor_hp(@actor3, @x-5+315, @y-50)
  105.             draw_actor_mp(@actor, @x-5+63, @y-50+75-17)
  106.             draw_actor_mp(@actor2, @x-5+189, @y-50+75-17)
  107.             draw_actor_mp(@actor3, @x-5+315, @y-50+75-17)
  108.             draw_actor_tp(@actor, @x-5+63, @y-50+75)
  109.             draw_actor_tp(@actor2, @x-5+189, @y-50+75)
  110.             draw_actor_tp(@actor3, @x-5+315, @y-50+75)
  111.             draw_actor_icons(@actor, @x-5+63, @y-10)
  112.             draw_actor_icons(@actor2, @x-5+189, @y-10)
  113.             draw_actor_icons(@actor3, @x-5+315, @y-10)
  114.         elsif $game_party.all_members.size > 3
  115.             @actor = $game_party.members[0]
  116.             @actor2 = $game_party.members[1]
  117.             @actor3 = $game_party.members[2]
  118.             @actor4 = $game_party.members[3]
  119.             @actor_hp = @actor.hp
  120.             @actor_mp = @actor.mp
  121.             @actor2_hp = @actor2.hp
  122.             @actor2_mp = @actor2.mp
  123.             @actor3_hp = @actor3.hp
  124.             @actor3_mp = @actor3.mp
  125.             @actor4_hp = @actor4.hp
  126.             @actor4_mp = @actor4.mp
  127.             @actor_tp = @actor.tp
  128.             @actor2_tp = @actor2.tp
  129.             @actor3_tp = @actor3.tp
  130.             @actor4_tp = @actor4.tp
  131.             @actor_draw = @x
  132.             draw_actor_face(@actor, @x, @y-50, enabled = true)
  133.             draw_actor_face(@actor2, @x+126, @y-50, enabled = true)
  134.             draw_actor_face(@actor3, @x+252, @y-50, enabled = true)            
  135.             draw_actor_face(@actor4, @x+378, @y-50, enabled = true)
  136.             draw_actor_hp(@actor, @x-5, @y-50)
  137.             draw_actor_hp(@actor2, @x-5+126, @y-50)
  138.             draw_actor_hp(@actor3, @x-5+252, @y-50)
  139.             draw_actor_hp(@actor4, @x-5+378, @y-50)
  140.             draw_actor_mp(@actor, @x-5, @y-50+75-17)
  141.             draw_actor_mp(@actor2, @x-5+126, @y-50+75-17)
  142.             draw_actor_mp(@actor3, @x-5+252, @y-50+75-17)
  143.             draw_actor_mp(@actor4, @x-5+378, @y-50+75-17)
  144.             draw_actor_tp(@actor, @x-5, @y-50+75)
  145.             draw_actor_tp(@actor2, @x-5+126, @y-50+75)
  146.             draw_actor_tp(@actor3, @x-5+252, @y-50+75)
  147.             draw_actor_tp(@actor4, @x-5+378, @y-50+75)
  148.             draw_actor_icons(@actor, @x-5, @y-10)
  149.             draw_actor_icons(@actor2, @x-5+126, @y-10)
  150.             draw_actor_icons(@actor3, @x-5+252, @y-10)
  151.             draw_actor_icons(@actor4, @x-5+378, @y-10)
  152.           end
  153.     end
  154.        
  155.    
  156.   def item_rect(index)
  157.     if $game_party.all_members.size == 1
  158.       rect = Rect.new
  159.       rect.width = 126
  160.       rect.height = 126
  161.       rect.x = 189 + index / col_max * 126
  162.       rect.y = 0
  163.       rect
  164.     elsif $game_party.all_members.size == 2
  165.       rect = Rect.new
  166.       rect.width = 126
  167.       rect.height = 126
  168.       rect.x = 126 + index / col_max * 126
  169.       rect.y = 0
  170.       rect
  171.     elsif $game_party.all_members.size == 3
  172.       rect = Rect.new
  173.       rect.width = 126
  174.       rect.height = 126
  175.       rect.x = 63 + index / col_max * 126
  176.       rect.y = 0
  177.       rect
  178.     elsif $game_party.all_members.size > 3
  179.       rect = Rect.new
  180.       rect.width = 126
  181.       rect.height = 126
  182.       rect.x = 0 + index / col_max * 126
  183.       rect.y = 0
  184.       rect
  185.     end
  186.   end
  187.  
  188.      ###################################################################
  189.      #Refresh the window to show all changes to the HUD
  190.      #It just copies the intizalize code.
  191.      #Also choos when to updat
  192.      #################################################################
  193.      
  194.      def refresh
  195.        contents.clear
  196.        battle_hud
  197.        @party_size = $game_party.all_members.size
  198.     end    
  199.     def update
  200.     # Chooses when to update the code.
  201.     # Checks the party size, then if any member's HP or MP was damaged.
  202.     # If any of the features are changed, it replays the intialize
  203.       super
  204.         if @party_size != $game_party.all_members.size
  205.           refresh
  206.         end
  207.         if @party_size > 0
  208.           if $game_party.members[0].hp != @actor_hp  or $game_party.members[0].mp != @actor_mp or $game_party.members[0].tp != @actor_tp
  209.  
  210.              refresh
  211.           end
  212.         end
  213.       if @party_size > 1
  214.         if $game_party.members[1].hp != @actor2_hp or $game_party.members[1].mp != @actor2_mp or $game_party.members[1].tp != @actor2_tp
  215.  
  216.           refresh
  217.         end
  218.       end  
  219.       if @party_size > 2
  220.         if $game_party.members[2].hp != @actor3_hp or $game_party.members[2].mp != @actor3_mp or $game_party.members[2].tp != @actor3_tp
  221.  
  222.           refresh
  223.         end
  224.       end
  225.       if @party_size > 3
  226.         if $game_party.members[3].hp != @actor4_hp or $game_party.members[3].mp != @actor4_mp or $game_party.members[3].tp != @actor4_tp
  227.  
  228.           refresh
  229.         end
  230.       end
  231.     end
  232. end  
  233.  
  234. #====================================================================
  235. class Window_PartyHorzCommand < Window_HorzCommand
  236.   #--------------------------------------------------------------------------
  237.   # * Object Initialization
  238.   #--------------------------------------------------------------------------
  239.   def initialize(window_width)
  240.     @window_width = window_width
  241.     super(0, 0)
  242.   end
  243.   #--------------------------------------------------------------------------
  244.   # * Get Window Width
  245.   #--------------------------------------------------------------------------
  246.   def window_width
  247.     @window_width
  248.   end
  249.   #--------------------------------------------------------------------------
  250.   # * Get Digit Count
  251.   #--------------------------------------------------------------------------
  252.   def col_max
  253.     return 2
  254.   end
  255.   #--------------------------------------------------------------------------
  256.   # * Create Command List
  257.   #--------------------------------------------------------------------------
  258.   def make_command_list
  259.     add_command(Vocab::fight,  :fight)
  260.     add_command(Vocab::escape, :escape, BattleManager.can_escape?)
  261.   end
  262.   #--------------------------------------------------------------------------
  263.   # * Setup
  264.   #--------------------------------------------------------------------------
  265.   def setup
  266.     clear_command_list
  267.     make_command_list
  268.     refresh
  269.     select(0)
  270.     activate
  271.     open
  272.   end
  273. end
  274. #====================================================================
  275. #====================================================================
  276. class Window_ActorHorzCommand < Window_HorzCommand
  277.   #--------------------------------------------------------------------------
  278.   # * Object Initialization
  279.   #--------------------------------------------------------------------------
  280.   def initialize(window_width)
  281.     @window_width = window_width
  282.     super(0, 0)
  283.   end
  284.   #--------------------------------------------------------------------------
  285.   # * Get Window Width
  286.   #--------------------------------------------------------------------------
  287.   def window_width
  288.     @window_width
  289.   end
  290.   #--------------------------------------------------------------------------
  291.   # * Get Digit Count
  292.   #--------------------------------------------------------------------------
  293.   def col_max
  294.     return 4
  295.   end
  296.   #--------------------------------------------------------------------------
  297.   # * Create Command List
  298.   #--------------------------------------------------------------------------
  299.   def make_command_list
  300.     return unless @actor
  301.     add_attack_command
  302.     add_skill_commands
  303.     add_guard_command
  304.     add_item_command
  305.   end
  306.   #--------------------------------------------------------------------------
  307.   # * Add Attack Command to List
  308.   #--------------------------------------------------------------------------
  309.   def add_attack_command
  310.     add_command(Vocab::attack, :attack, @actor.attack_usable?)
  311.   end
  312.   #--------------------------------------------------------------------------
  313.   # * Add Skill Command to List
  314.   #--------------------------------------------------------------------------
  315.   def add_skill_commands
  316.     @actor.added_skill_types.sort.each do |stype_id|
  317.       name = $data_system.skill_types[stype_id]
  318.       add_command(name, :skill, true, stype_id)
  319.     end
  320.   end
  321.   #--------------------------------------------------------------------------
  322.   # * Add Guard Command to List
  323.   #--------------------------------------------------------------------------
  324.   def add_guard_command
  325.     add_command(Vocab::guard, :guard, @actor.guard_usable?)
  326.   end
  327.   #--------------------------------------------------------------------------
  328.   # * Add Item Command to List
  329.   #--------------------------------------------------------------------------
  330.   def add_item_command
  331.     add_command(Vocab::item, :item)
  332.   end
  333.   #--------------------------------------------------------------------------
  334.   # * Setup
  335.   #--------------------------------------------------------------------------
  336.   def setup(actor)
  337.     @actor = actor
  338.     clear_command_list
  339.     make_command_list
  340.     refresh
  341.     select(0)
  342.     activate
  343.     open
  344.   end
  345. end
  346. #====================================================================
  347. #====================================================================
  348. #====================================================================
  349.  
  350. class Scene_Battle < Scene_Base
  351.   alias face_status_create_status_window create_status_window
  352.   def create_status_window
  353.     face_status_create_status_window
  354.     @status_window = Window_BattleStatus.new
  355.     @status_window.x = 128
  356.   end  
  357.   def create_info_viewport
  358.     @info_viewport = Viewport.new
  359.     @info_viewport.rect.y = Graphics.height - @status_window.height - 48
  360.     @info_viewport.rect.height = @status_window.height + 48
  361.     @info_viewport.z = 100
  362.     @info_viewport.ox = 0
  363.     @status_window.viewport = @info_viewport
  364.   end
  365.   def move_battle_window(y)
  366.     current_y = @status_window.y
  367.     @status_window.y = [y, current_y + 16].min if current_y < y
  368.     @status_window.y = [y, current_y - 16].max if current_y > y
  369.   end
  370.   alias face_status_window_viewport update_info_viewport
  371.   def update_info_viewport
  372.     move_info_viewport(128)  if @party_command_window.active
  373.     move_battle_window(0)  if @party_command_window.active
  374.     move_battle_window(50)  if BattleManager.in_turn?
  375.   end
  376.  
  377.   def create_party_command_window
  378.     @party_command_window = Window_PartyHorzCommand.new(Graphics.width)
  379.     @party_command_window.x = 0
  380.     @party_command_window.height = 48
  381.     @party_command_window.y = Graphics.height - 48
  382.     @party_command_window.width = @status_window.width
  383.     @party_command_window.set_handler(:fight,  method(:command_fight))
  384.     @party_command_window.set_handler(:escape, method(:command_escape))
  385.     @party_command_window.unselect
  386.   end
  387.  
  388.  
  389.   def create_actor_command_window
  390.     @actor_command_window = Window_ActorHorzCommand.new(Graphics.width)
  391.     @actor_command_window.x = 0
  392.     @actor_command_window.height = 48
  393.     @actor_command_window.y = Graphics.height - 48
  394.     @actor_command_window.width = @status_window.width
  395.     @actor_command_window.set_handler(:attack, method(:command_attack))
  396.     @actor_command_window.set_handler(:skill,  method(:command_skill))
  397.     @actor_command_window.set_handler(:guard,  method(:command_guard))
  398.     @actor_command_window.set_handler(:item,   method(:command_item))
  399.     @actor_command_window.set_handler(:cancel, method(:prior_command))
  400.   end
  401.  
  402.   alias face_status_create_enemy_window create_enemy_window
  403.   def create_enemy_window
  404.     face_status_create_enemy_window
  405.     @enemy_window.x = 0
  406.     @enemy_window.width = Graphics.width
  407.   end
  408. end
  409.   #########################################################################
  410.   #End Of Script                                                          #
  411.   #########################################################################
Advertisement
Add Comment
Please, Sign In to add comment