Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #------------------------------------------------------------------------------#
  2. #  Galv's Explorer's HUD
  3. #------------------------------------------------------------------------------#
  4. #  For: RPGMAKER VX ACE
  5. #  Version 1.7
  6. #------------------------------------------------------------------------------#
  7. #  2012-11-07 - Version 1.7 - some optimisation thanks to Niclas
  8. #  2012-11-06 - Version 1.6 - more bug fixes
  9. #  2012-11-06 - Version 1.5 - fixed so HUD doesn't appear in battle
  10. #  2012-11-06 - Version 1.4 - added tp option and functionality
  11. #  2012-11-06 - Version 1.3 - added options to disable windows
  12. #  2012-11-06 - Version 1.2 - fixed map name bug not updating
  13. #  2012-11-06 - Version 1.1 - changed z values of HUD
  14. #  2012-11-06 - Version 1.0 - release
  15. #------------------------------------------------------------------------------#
  16. #  A HUD that displays information that might be useful for an RPG with a lot of
  17. #  exploring. Can toggle it on or off when needed with a button. The info
  18. #  displayed is the actor leading the party, so it works well with a script
  19. #  such as Tsukihime's Rotate Formation to switch the lead actor with the press
  20. #  of a button.
  21. #------------------------------------------------------------------------------#
  22. #  Visit: http://xtsukihime.wordpress.com/rmvxa-scripts/
  23. #  To find latest versions of Tsukihime's scripts.
  24. #------------------------------------------------------------------------------#
  25.  
  26. ($imported ||= {})["Galv_Explorers_Hud"] = true
  27.  
  28. module Galvs_Hud
  29.  
  30. #------------------------------------------------------------------------------#
  31. #  SCRIPT SETUP OPTIONS
  32. #------------------------------------------------------------------------------#
  33.  
  34.   # GENERAL
  35.  
  36.   TOGGLE_SWITCH = 1       # Switch ID. When ON, hud is visible. When OFF its not
  37.  
  38.   ACTIVATE_BUTTON = :Z    # Button to toggle hud visibility switch. (:Z is "D")
  39.                           # to disable make ACTIVATE_BUTTON = nil
  40.                          
  41.   HUD_SKIN = "InfoHud"    # A windowskin to apply to the HUD. Located in
  42.                           # /Graphics/System/
  43.                           # Change to "Window" to use normal skin.
  44.  
  45.   SHOW_EQUIP = 0          # The equipment piece shown. This is the slot ID.
  46.                           # 0 = weapon
  47.                           # 1 = shield
  48.                           # 2 = head
  49.                           # 3 = body
  50.                           # 4 = accessory
  51.  
  52.   SHOW_TP = true          # Show TP in top bar.
  53.  
  54.  
  55.   # BOTTOM BAR
  56.  
  57.   SHOW_GOLD = true        # display gold in bottom bar
  58.   SHOW_MAPNAME = true     # display map display name in bottom bar
  59.   SHOW_COORDS = true      # display x,y coordinates in bottom bar
  60.  
  61.   REMOVE_WINDOWS = false  # This applies for above options that are set to false
  62.                           # true = windows removed. false = windows blank
  63.                          
  64.  
  65. #------------------------------------------------------------------------------#
  66. #  SCRIPT SETUP OPTIONS
  67. #------------------------------------------------------------------------------#
  68.                          
  69. end
  70.  
  71. class Scene_Map < Scene_Base
  72.  
  73.   alias galv_hud_create_spriteset create_spriteset
  74.   def create_spriteset
  75.     galv_hud_create_spriteset
  76.     create_hud
  77.   end
  78.  
  79.   alias galv_hud_update update
  80.   def update
  81.     galv_hud_update
  82.     check_trigger
  83.     update_hud if !@galv_hud.nil? && !scene_changing?
  84.   end
  85.  
  86.   def update_hud
  87.     @galv_hud.update
  88.   end
  89.  
  90.   def create_hud
  91.     @galv_hud = Galv_Hud.new(@viewport2)
  92.   end  
  93.  
  94.   def check_trigger
  95.     if Input.trigger?(Galvs_Hud::ACTIVATE_BUTTON)
  96.       $game_switches[Galvs_Hud::TOGGLE_SWITCH] ^= true
  97.     end
  98.   end
  99.  
  100.   alias galv_hud_dispose_spriteset dispose_spriteset
  101.   def dispose_spriteset
  102.     galv_hud_dispose_spriteset
  103.     @galv_hud.dispose
  104.   end
  105.  
  106. end
  107.  
  108.  
  109. class Galv_Hud < Scene_Base
  110.  
  111.   def initialize(viewport)
  112.     super(viewport)
  113.     create_gold_window
  114.     create_coords_window
  115.     create_location_window
  116.     create_status_window
  117.     $game_temp.hud_update[4] = []
  118.     $game_temp.hud_update[6] = ""
  119.     $game_temp.hud_update[7] = $game_party.members[0].tp
  120.   end
  121.  
  122.   def create_status_window
  123.     @status_window = Window_HudStatus.new
  124.     @status_window.x = 0
  125.     @status_window.y = 0
  126.     @status_window.z = @status_window.z - 10
  127.     @status_window.hide if !$game_switches[Galvs_Hud::TOGGLE_SWITCH]
  128.   end
  129.  
  130.   def create_gold_window
  131.     @gold_window = Window_QuickGold.new
  132.     @gold_window.x = 0
  133.     @gold_window.y = Graphics.height - @gold_window.height
  134.     @gold_window.z = @gold_window.z - 10
  135.     @gold_window.hide if !$game_switches[Galvs_Hud::TOGGLE_SWITCH]
  136.   end
  137.  
  138.   def dispose
  139.     @location_window.dispose
  140.     @gold_window.dispose
  141.     @status_window.dispose
  142.     @coords_window.dispose
  143.   end
  144.  
  145.   def create_coords_window
  146.     @coords_window = Window_Coords.new
  147.     @coords_window.x = Graphics.width - @coords_window.width
  148.     @coords_window.y = Graphics.height - @coords_window.height
  149.     @coords_window.z = @coords_window.z - 10
  150.     @coords_window.hide if !$game_switches[Galvs_Hud::TOGGLE_SWITCH]
  151.   end
  152.  
  153.   def create_location_window
  154.     @location_window = Window_Location.new
  155.     @location_window.x = @gold_window.width
  156.     @location_window.y = Graphics.height - @location_window.height
  157.     @location_window.z = @location_window.z - 10
  158.     @location_window.hide if !$game_switches[Galvs_Hud::TOGGLE_SWITCH]
  159.   end
  160.  
  161.   def update
  162.     check_need_refresh
  163.     hide_windows if !$game_switches[Galvs_Hud::TOGGLE_SWITCH]
  164.     show_windows if $game_switches[Galvs_Hud::TOGGLE_SWITCH]
  165.     @coords_window.refresh if Galvs_Hud::SHOW_COORDS
  166.   end
  167.  
  168.   def check_need_refresh
  169.     a = $game_party.members[0]
  170.     if $game_temp.hud_update != [a.id,a.hp,a.mp,a.exp,a.state_icons,$game_party.gold,$game_map.display_name,a.tp]
  171.       refresh_windows
  172.     else
  173.       return
  174.     end
  175.   end
  176.  
  177.   def refresh_windows
  178.       @status_window.refresh
  179.       @gold_window.refresh
  180.       @location_window.refresh
  181.       $game_temp.hud_update[5] = $game_party.gold
  182.   end
  183.  
  184.   def hide_windows
  185.     if @status_window.visible
  186.       @gold_window.hide
  187.       @location_window.hide
  188.       @coords_window.hide
  189.       @status_window.hide
  190.     end
  191.   end
  192.  
  193.   def show_windows
  194.     if !@status_window.visible
  195.       @gold_window.show
  196.       @location_window.show
  197.       @coords_window.show
  198.       @status_window.show
  199.     end
  200.   end
  201.  
  202. end # Galv_Hud
  203.  
  204.  
  205. class Window_Location < Window_Base
  206.  
  207.   def initialize
  208.     super(0, 0, window_width, fitting_height(1))
  209.     self.openness = 255
  210.     self.windowskin = Cache.system(Galvs_Hud::HUD_SKIN)
  211.     self.opacity = 0 if !Galvs_Hud::SHOW_MAPNAME && Galvs_Hud::REMOVE_WINDOWS
  212.     refresh
  213.   end
  214.  
  215.   def window_width
  216.     return (Graphics.width - 130 - 130)
  217.   end
  218.  
  219.   def refresh
  220.     $game_temp.hud_update[6] = $game_map.display_name
  221.     return if !Galvs_Hud::SHOW_MAPNAME
  222.     contents.clear
  223.     draw_text((contents.width / 2) - ((locate_text.length * 10) / 2), 0, Graphics.width / 2, line_height, locate_text)
  224.    
  225.   end
  226.  
  227.   def locate_text
  228.     $game_map.display_name
  229.   end
  230.  
  231.   def open
  232.     refresh
  233.     super
  234.   end
  235.  
  236. end # Window_Location < Window_Base
  237.  
  238.  
  239. class Window_Coords < Window_Base
  240.  
  241.   def initialize
  242.     super(0, 0, window_width, fitting_height(1))
  243.     self.openness = 255
  244.     self.windowskin = Cache.system(Galvs_Hud::HUD_SKIN)
  245.     self.opacity = 0 if !Galvs_Hud::SHOW_COORDS && Galvs_Hud::REMOVE_WINDOWS
  246.     refresh
  247.   end
  248.  
  249.   def window_width
  250.     return 130
  251.   end
  252.  
  253.   def refresh
  254.     return if !Galvs_Hud::SHOW_COORDS
  255.     contents.clear
  256.     change_color(normal_color)
  257.     draw_text(15, 0, contents.width, line_height, $game_player.x.to_s)
  258.     draw_text(70, 0, contents.width, line_height, $game_player.y.to_s)
  259.     change_color(system_color)
  260.     draw_text(0, 0, window_width, line_height, "X")
  261.     draw_text(55, 0, window_width, line_height, "Y")
  262.   end
  263.  
  264.   def open
  265.     refresh
  266.     super
  267.   end
  268.  
  269. end # Window_Coords < Window_Base
  270.  
  271.  
  272. class Window_QuickGold < Window_Base
  273.  
  274.   def initialize
  275.     super(0, 0, window_width, fitting_height(1))
  276.     self.openness = 255
  277.     self.windowskin = Cache.system(Galvs_Hud::HUD_SKIN)
  278.     self.opacity = 0 if !Galvs_Hud::SHOW_GOLD && Galvs_Hud::REMOVE_WINDOWS
  279.     refresh
  280.   end
  281.  
  282.   def window_width
  283.     return 130
  284.   end
  285.  
  286.   def refresh
  287.     return if !Galvs_Hud::SHOW_GOLD
  288.     contents.clear
  289.     draw_currency_value(value, currency_unit, 4, 0, contents.width - 8)
  290.   end
  291.  
  292.   def value
  293.     $game_party.gold
  294.   end
  295.  
  296.   def currency_unit
  297.     Vocab::currency_unit
  298.   end
  299.  
  300.   def open
  301.     refresh
  302.     super
  303.   end
  304.  
  305. end # Window_QuickGold < Window_Base
  306.  
  307.  
  308. class Window_HudStatus < Window_Selectable
  309.   def initialize
  310.     super(0, 0, window_width, window_height)
  311.     refresh
  312.     self.openness = 255
  313.     self.windowskin = Cache.system(Galvs_Hud::HUD_SKIN)
  314.   end
  315.  
  316.   def window_width
  317.     Graphics.width
  318.   end
  319.  
  320.   def window_height
  321.     fitting_height(visible_line_number)
  322.   end
  323.  
  324.   def visible_line_number
  325.     return 2
  326.   end
  327.  
  328.   def item_max
  329.     1
  330.   end
  331.  
  332.   def refresh
  333.     contents.clear
  334.     draw_item(0)
  335.     draw_equips($game_party.members[0].equips[Galvs_Hud::SHOW_EQUIP].id) unless $game_party.members[0].equips[Galvs_Hud::SHOW_EQUIP].nil?
  336.   end
  337.  
  338.   def draw_item(index)
  339.     actor = $game_party.battle_members[index]
  340.     draw_basic_area(basic_area_rect(index), actor)
  341.     draw_gauge_area(gauge_area_rect(index), actor)
  342.     draw_face(actor.face_name, actor.face_index, x, y - 30, actor.hp > 0)
  343.     draw_actor_level(actor, Graphics.width - 90, y + line_height * 1)
  344.     $game_temp.hud_update[0] = $game_party.members[0].id
  345.   end
  346.  
  347.   def draw_equips(index)
  348.     if Galvs_Hud::SHOW_EQUIP <= 0
  349.       item = $data_weapons[index]
  350.     else
  351.       item = $data_armors[index]
  352.     end
  353.     if item
  354.       rect = item_rect(1)
  355.       rect.width -= 4
  356.       draw_item_name(item, rect.x + 100, rect.y, $game_party.members[0].hp > 0)
  357.     end
  358.   end
  359.  
  360.   def basic_area_rect(index)
  361.     rect = item_rect_for_text(index)
  362.     rect.width -= gauge_area_width + 10
  363.     rect
  364.   end
  365.  
  366.   def gauge_area_rect(index)
  367.     rect = item_rect_for_text(index)
  368.     rect.x += rect.width - gauge_area_width
  369.     rect.width = gauge_area_width
  370.     rect
  371.   end
  372.  
  373.   def gauge_area_width
  374.     return 220
  375.   end
  376.  
  377.   def draw_basic_area(rect, actor)
  378.     draw_actor_icons(actor, rect.x + 104, rect.y, rect.width - 104)
  379.     $game_temp.hud_update[4] = $game_party.members[0].state_icons
  380.   end
  381.  
  382.   def draw_gauge_area(rect, actor)
  383.     if $data_system.opt_display_tp
  384.       draw_gauge_area_with_tp(rect, actor)
  385.     else
  386.       draw_gauge_area_without_tp(rect, actor)
  387.     end
  388.   end
  389.  
  390.   def draw_gauge_area_with_tp(rect, actor)
  391.     draw_actor_hp(actor, rect.x - 60, rect.y, 132)
  392.     draw_actor_tp(actor, rect.x + 82, rect.y + 25, 64) unless !Galvs_Hud::SHOW_TP
  393.     draw_actor_mp(actor, rect.x + 82, rect.y, 64)
  394.     draw_actor_xp(actor, rect.x + 156, rect.y, 64)
  395.     $game_temp.hud_update[1] = $game_party.members[0].hp
  396.     $game_temp.hud_update[2] = $game_party.members[0].mp
  397.     $game_temp.hud_update[3] = $game_party.members[0].exp
  398.     $game_temp.hud_update[7] = $game_party.members[0].tp
  399.   end
  400.  
  401.   def draw_actor_xp(actor, x, y, width = 124)
  402.     draw_gauge(x, y, width, (actor.exp.to_f - actor.class.exp_for_level(actor.level)) / (actor.class.exp_for_level(actor.level + 1) - actor.class.exp_for_level(actor.level)), text_color(6), text_color(14))
  403.     change_color(system_color)
  404.     draw_text(x, y, 30, line_height, "EXP")
  405.   end
  406.  
  407. end # Window_HudStatus < Window_Selectable
  408.  
  409.  
  410.  
  411. class Sprite_Timer < Sprite
  412.  
  413.   alias galv_hud_update_position update_position
  414.   def update_position
  415.     galv_hud_update_position
  416.     self.y = 70 if $game_switches[Galvs_Hud::TOGGLE_SWITCH]
  417.   end
  418. end # Sprite_Timer < Sprite
  419.  
  420.  
  421. class Window_MapName < Window_Base
  422.  
  423.   alias galv_hud_update update
  424.   def update
  425.     galv_hud_update
  426.     update_position if $game_map.name_display
  427.   end
  428.  
  429.   def update_position
  430.     if $game_switches[Galvs_Hud::TOGGLE_SWITCH]
  431.       self.y = 70
  432.     else
  433.       self.y = 0
  434.     end
  435.   end
  436.  
  437. end # Window_MapName < Window_Base
  438.  
  439.  
  440. class Game_Temp
  441.   attr_accessor :hud_update
  442.  
  443.   alias galv_hud_initialize initialize
  444.   def initialize
  445.     galv_hud_initialize
  446.     @hud_update = []
  447.   end
  448.  
  449. end # Game_Temp