Advertisement
TheSixth

Map HUD by Sixth

Sep 2nd, 2015
1,498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 35.61 KB | None | 0 0
  1. #===============================================================================
  2. # * [ACE] Map HUD EX
  3. #===============================================================================
  4. # * Made by: Sixth (www.rpgmakervxace.net, www.forums.rpgmakerweb.com)
  5. # * Version: 1.3
  6. # * Updated: 06/10/2015
  7. # * Requires: -------
  8. #-------------------------------------------------------------------------------
  9. # * < Change Log >
  10. #-------------------------------------------------------------------------------
  11. # * Version 1.0 (13/06/2015)
  12. #   - Initial release.
  13. # * Version 1.1 (01/07/2015)
  14. #   - Added compatibility with my Menu Engine script.
  15. #   - You can now set the numeric display type for every gauge shown separately.
  16. #   - Fixed an update method which updated constantly instead of only when
  17. #     necessary.
  18. # * Version 1.2 (10/07/2015)
  19. #   - Made it impossible to toggle the visibility of the HUD during events.
  20. # * Version 1.3 (06/10/2015)
  21. #   - Added state/buff display.
  22. #-------------------------------------------------------------------------------
  23. # * < Description >
  24. #-------------------------------------------------------------------------------
  25. # * This script is aimed for games where the player can control only one actor
  26. #   at a time, such as a game with an action battle system and the likes.
  27. # * This script adds a map HUD which can display the following information:
  28. #   - HP, MP, TP, XP, state/buff icons
  29. # * All information displayed will be the party leader's data!
  30. # * You can set what to show, where to show, how to show, and more!
  31. # * The HUD is purely image based. You can use any images you want!
  32. # * Two kinds of image bar filling is possible, can be horizontal or vertical.
  33. # * Image based number drawing is possible too, with my Picture Drawing script!
  34. # * Toggle the HUD with a single press of a button or by toggling a switch
  35. #   anytime during the game!
  36. # * A little bonus: play an animation on the player upon a level up!
  37. # * Tons of settings for you to configure!
  38. # * Say goodbye to the old and boring default bars and make your own!
  39. #-------------------------------------------------------------------------------
  40. # * < Usage Information >
  41. #-------------------------------------------------------------------------------
  42. # * This script uses a custom made folder setup to get the location of the
  43. #   pictures used. All images used must be in that folder!
  44. #   You can set the folder location with the 'ImgFolder' setting!
  45. #-------------------------------------------------------------------------------
  46. # * < Installation >
  47. #-------------------------------------------------------------------------------
  48. # * Place this script below Materials but above Main!
  49. #-------------------------------------------------------------------------------
  50. # * < Compatibility Info >
  51. #-------------------------------------------------------------------------------
  52. # * No known incompatibilities.
  53. #-------------------------------------------------------------------------------
  54. # * < Known Issues >
  55. #-------------------------------------------------------------------------------
  56. # * No known issues.
  57. #-------------------------------------------------------------------------------
  58. # * < Terms of Use >
  59. #-------------------------------------------------------------------------------
  60. # * Free to use for whatever purposes you want.
  61. # * Credit me (Sixth) in your game, pretty please! :P
  62. # * Posting modified versions of this script is allowed as long as you notice me
  63. #   about it with a link to it!
  64. #===============================================================================
  65. $imported = {} if $imported.nil?
  66. $imported["SixthMapHUD"] = true
  67. #===============================================================================
  68. # Settings:
  69. #===============================================================================
  70. module SixthMapHUD # <-- No touchy-touchy!
  71.   #-----------------------------------------------------------------------------
  72.   # Image Folder Settings:
  73.   #-----------------------------------------------------------------------------
  74.   # Set up a custom folder where your map HUD pictures will be read from.
  75.   # All pictures used must be in this folder!
  76.   #-----------------------------------------------------------------------------
  77.   ImgFolder = "Graphics/MapHUD/"
  78.  
  79.   #-----------------------------------------------------------------------------
  80.   # Switch Settings:
  81.   #-----------------------------------------------------------------------------
  82.   # Set up a switch used to toggle the HUD at will during the game.
  83.   # Useful for eventing, I guess.
  84.   # Enter the ID of the switch you want to use for this.
  85.   # Don't forget that you MUST turn this switch ON to show the HUD!
  86.   #-----------------------------------------------------------------------------
  87.   HUDSwitch = 100
  88.  
  89.   #-----------------------------------------------------------------------------
  90.   # Button Settings:
  91.   #-----------------------------------------------------------------------------
  92.   # Set up a button for toggling the HUD at will during the game.
  93.   # In case you want to give the option of hiding the HUD for the player, this
  94.   # is just the thing you need. And why wouldn't you give that option, right?
  95.   # Enter the symbol of the button you want to use.
  96.   # Enter nil to disable this feature (not really recommended by me, thou).
  97.   #-----------------------------------------------------------------------------
  98.   ToggleHUD = :R
  99.  
  100.   #-----------------------------------------------------------------------------
  101.   # Animation Settings:
  102.   #-----------------------------------------------------------------------------
  103.   # In case you want to show an animation on the player when he/she levels up,
  104.   # you can enter an animation ID here.
  105.   # Set it to 0 to disable this feature.
  106.   #-----------------------------------------------------------------------------
  107.   LvlAnim = 149
  108.  
  109.   #-----------------------------------------------------------------------------
  110.   # Horizontal Fill Rate Settings:
  111.   #-----------------------------------------------------------------------------
  112.   # You have two options to draw the current rate of a stat with the horizontal
  113.   # filling type of the bars:
  114.   #
  115.   #   :rect = This is the same as how every vertical gauge will operate.
  116.   #           You have a fill rate image, and depending on the current rate of
  117.   #           the stat, only a certain portion of that image will be drawn from
  118.   #           the left side of the image. So, if the player got 50% from MP, the
  119.   #           bar will only draw half of the image from the left side as is.
  120.   #           This is good for unusual shaped bars without a foreground image,
  121.   #           for example.
  122.   # :stretch = The second mode instead will pack the whole image into a box, and
  123.   #            the width and height of the box will depend on the current rate
  124.   #            of the stat. Generally takes more processing time, but should
  125.   #            not be noticeable.
  126.   #-----------------------------------------------------------------------------
  127.   HorzMode = :rect
  128.  
  129.   #-----------------------------------------------------------------------------
  130.   # Data Display Settings:
  131.   #-----------------------------------------------------------------------------
  132.   # You can define what data to show on the map HUD here.
  133.   # You can also set the bar's filling type up here.
  134.   #
  135.   # Available keys are:
  136.   #   :hp, :mp, :tp, :xp
  137.   # All of these can have a bar/gauge shown.
  138.   #
  139.   # Available filling type symbols:
  140.   #   :vert, :horz
  141.   # It should be obvious which one does what, right?
  142.   # The vertical fill type will fill from down to up.
  143.   # The horizontal fill type will fill from left to right.
  144.   #
  145.   # Any key missing from this hash setting will not be shown on the HUD at all!
  146.   # So, if you want to hide, let's say, the TP bar, just comment out the :tp
  147.   # settings, and it won't show up ever on the HUD.
  148.   #-----------------------------------------------------------------------------
  149.   HUDs = { # <-- No touchy-touchy!
  150.     :hp => :horz,
  151.     :mp => :horz,
  152.     :tp => :vert,
  153.     :xp => :horz,
  154.   } # <-- No touchy-touchy!
  155.    
  156.   #-----------------------------------------------------------------------------
  157.   # Dynamic Text Color Settings:
  158.   #-----------------------------------------------------------------------------
  159.   # In the case of HP, MP and TP value displays, it is possible to set up
  160.   # different colors for the text depending on the percentage of current HP, MP
  161.   # and TP respectively.
  162.   # You can set up infinite amount of color changes here for each data.
  163.   # If you are using my Picture Number Drawing script to display the values,
  164.   # you can seet up style changes too here.
  165.   #
  166.   # Format:
  167.   #
  168.   # 1. Regular text based format:
  169.   #  
  170.   #     percentage => [Red,Blue,Green,Alpha],
  171.   #
  172.   #   So, 4 integer numbers in an array.
  173.   #   Valid values are from 0 to 255 for all of them!
  174.   #   Replace the percentage with an integer value from 0 to 100.
  175.   #   0 = 0%, 25 = 25%, 100 = 100%, and so on.
  176.   #
  177.   # 2. Picture number drawing format:
  178.   #
  179.   #     percentage => ["image_file",row_index],
  180.   #
  181.   #   Replace the image_file with the name of the image you want to use.
  182.   #   Replace the row_index with the index of the style you want to use from the
  183.   #   image.
  184.   #   The percentage means the same thing like at the regular text based format.
  185.   #   Remember that the images used here must be in the folder you set in my
  186.   #   Picture Number Drawing script!
  187.   #
  188.   # The settings must be from lowest to highest percentage values!
  189.   #-----------------------------------------------------------------------------
  190.   TxtColors = { # <-- No touchy-touchy!
  191.     :hp => { # Settings for the HP display.
  192.       10 => ["hpnums1va",2],
  193.       33 => ["hpnums1va",0],
  194.       100 => ["hpnums1va",1],
  195.     },
  196.     :mp => { # Settings for the MP display.
  197.       10 => ["mpnums1va",2],
  198.       33 => ["mpnums1va",0],
  199.       100 => ["mpnums1va",1],
  200.     },
  201.     :tp => { # Settings for the TP display.
  202.       99 => ["mpnums1va",0],
  203.       100 => ["mpnums1va",2],
  204.     }
  205.   } # <-- No touchy-touchy!
  206.    
  207.   #-----------------------------------------------------------------------------
  208.   # Advanced Data Display Settings:
  209.   #-----------------------------------------------------------------------------
  210.   # From here on, you can configure the details of your HP, MP, TP and XP bars.
  211.   # Every data uses the same format!
  212.   #
  213.   # You can set up 3 static picture for each bar, but all of them are optional!
  214.   # These are the :pic1, :pic2, and :pic3 settings.
  215.   # You can simply omit any of them in case you don't wanna use all 3 for all
  216.   # types of data.
  217.   #
  218.   # And you can set up a fill rate picture, that is the :fill setting.
  219.   # The fill pictures got one simple rule to follow:
  220.   # If you use the image for a vertical bar, the image used must not contain
  221.   # any empty pixels on the top or on the bottom of the image, and if you use
  222.   # it for a horizontal bar, it should not contain any empty pixels on the left
  223.   # or right side of the picture!
  224.   #
  225.   # The settings for the :pic1, :pic2, :pic3 and :fill use the same format!
  226.   # The available options are:
  227.   #
  228.   #   :img => "file name",
  229.   # The name of the image file to use.
  230.   # You don't have to use a boring, old and simple linear gauge image!
  231.   # Spheres, swords, irregular shapes, all of them will work!
  232.   #
  233.   #   :pos => [x,y],
  234.   # The X and Y position of the image.
  235.   #
  236.   #   :opa => value,
  237.   # The opacity value for the image. Valid values: 0 - 255.
  238.   #
  239.   #   :z => value,
  240.   # The Z value of the image, so you can set backgrounds and foregrounds too
  241.   # for your fancy bars!
  242.   #
  243.   # The last setting is named :txt, and will let you set up the visuals of the
  244.   # numeric displays for your HUD.
  245.   # If you comment out or delete the :txt settings for a data, it will not have
  246.   # a numeric display at all, only the bar itself!
  247.   # The available options here are:
  248.   #
  249.   #   :style => type,
  250.   # Two options here: :text or :picture.
  251.   # :text will use the default text drawing method, while :picture will use my
  252.   # picture number drawing method (requires my Picture Number Drawing script!).
  253.   #
  254.   #   :type => type,
  255.   # This will determine how the numeric info will be shown.
  256.   # You get 3 options (2 for the XP data!):
  257.   #   :current = This will only display the current HP/MP/TP.
  258.   #              Can NOT select this for the XP text!
  259.   #   :direct = Will display the data like this: current / max .
  260.   #   :percentage = Will display the data like this: percentage_value% .
  261.   # In case you have set your :type to percentage, you will need to set up
  262.   # another setting named :decimals for it.
  263.   # Remember that you need a % and a . extra character set up in the Picture
  264.   # Number Drawing script to show those characters for the :percentage type, and
  265.   # you will need a / extra character set up for the :direct type!
  266.   #
  267.   #   :decimals => value,
  268.   # The amount of decimals to display for the numeric data if the text's :type
  269.   # is set to :percentage. Must be an integer number from 0 to infinity!
  270.   # You don't need to set this up if the text's :type is not :percentage!
  271.   #
  272.   #   :img => ["image_file",row_index],
  273.   # The style setup for the picture drawing method.
  274.   # Replace the image_file with the name of the image you want to use.
  275.   # Replace the row_index with the index of the style you want to use from the
  276.   # image.
  277.   #
  278.   #   :pos1 => [x,y],
  279.   # The X and Y position of the sprite which will contain the text display.
  280.   #
  281.   #   :pos2 => [x,y],
  282.   # The text's X and Y position INSIDE the sprite used.
  283.   # Since some text types got some unusual letters, it is wise to set the text's
  284.   # position a few pixels from the edges, so it will be displayed correctly
  285.   # without leftover pixels from the previous value display.
  286.   #
  287.   #   :size1 => [width,height],
  288.   # The width and height of the bitmap created for the text.
  289.   #
  290.   #   :size2 => [width,height],
  291.   # The width and height reserved for the text itself INSIDE the bitmap.
  292.   # Do NOT use higher values than for the :size1 setup, or some text might get
  293.   # cut down from the display!
  294.   # The same reason as for :pos2, this ssetting has been made. If you see some
  295.   # pixels left from a previous drawing, you might need to lower the size of
  296.   # this setting and/or increase the size of the :size1 setting!
  297.   # This should only matter for the regular drawing method, not for the image
  298.   # based number drawing method!
  299.   #
  300.   #   :align => value,
  301.   # The alignment used for the text. 0 = left, 1 = middle, 2 = right.
  302.   #
  303.   #   :font => [["type1","type2", ...],size],
  304.   # The font settings for the text.
  305.   # An array which contains another array and a single integer number.
  306.   # Replace the "types" with the name of the font types you want to use.
  307.   # Font types on the left in the font type array gets priority over the right
  308.   # ones, so as soon as a valid type is detected on the system, that one will
  309.   # be selected, the rest will be ignored.
  310.   # Replace the size with the font size you want to use for the text.
  311.   #
  312.   #   :opa => value,
  313.   # The opacity value for the text display. Valid values: 0 - 255.
  314.   #
  315.   #   :z => value,
  316.   # The Z value of the sprite containing the text.
  317.   #
  318.   # And this is it! Have fun with designing cool gauges!
  319.   #-----------------------------------------------------------------------------  
  320.   HPBar = { # Settings for the HP display.
  321. #~     :pic1 => {
  322. #~       :img => "HPBackP2v2",
  323. #~       :pos => [5,Graphics.height-59],
  324. #~       :opa => 200,
  325. #~       :z => 270,
  326. #~     },
  327.     :pic2 => {
  328.       :img => "xpback2a",
  329.       :pos => [35,38],
  330.       :opa => 150,
  331.       :z => 240,
  332.     },
  333.     :pic3 => {
  334.       :img => "hpfore2a",
  335.       :pos => [35,18],
  336.       :opa => 240,
  337.       :z => 260,
  338.     },
  339.     :fill => {
  340.       :img => "hpfill2a",
  341.       :pos => [40,40],
  342.       :opa => 240,
  343.       :z => 255,
  344.     },
  345.     :txt => {
  346.       :style => :picture, :type => :direct,
  347.       :img => ["hpnums1va",1],
  348.       :pos1 => [-39,31],
  349.       :pos2 => [190,0],
  350.       :size1 => [200,60],
  351.       :size2 => [200,60],
  352.       :font => [["Parry Hotter","Old English Text MT"],36],
  353.       :align => 2,
  354.       :opa => 240,
  355.       :z => 272,
  356.     }
  357.   } # <-- No touchy-touchy!
  358.  
  359.   MPBar = { # Settings for the MP display.
  360. #~     :pic1 => {
  361. #~       :img => "MPBackP2v2",
  362. #~       :pos => [Graphics.width-197,Graphics.height-59],
  363. #~       :opa => 200,
  364. #~       :z => 270,
  365. #~     },
  366.     :pic2 => {
  367.       :img => "xpback2a",
  368.       :pos => [28,70],
  369.       :opa => 150,
  370.       :z => 240,
  371.     },
  372.     :pic3 => {
  373.       :img => "mpfore2a",
  374.       :pos => [28,50],
  375.       :opa => 240,
  376.       :z => 260,
  377.     },
  378.     :fill => {
  379.       :img => "mpfill2a",
  380.       :pos => [33,72],
  381.       :opa => 240,
  382.       :z => 255,
  383.     },
  384.     :txt => {
  385.       :style => :picture, :type => :direct,
  386.       :img => ["mpnums1va",1],
  387.       :pos1 => [-46,63],
  388.       :pos2 => [190,0],
  389.       :size1 => [200,60],
  390.       :size2 => [200,60],
  391.       :font => [["Parry Hotter","Old English Text MT"],36],
  392.       :align => 2,
  393.       :opa => 240,
  394.       :z => 272,
  395.     }
  396.   } # <-- No touchy-touchy!
  397.  
  398.   TPBar = { # Settings for the TP display.
  399.     :pic1 => {
  400.       :img => "tpback1a",
  401.       :pos => [194,28],
  402.       :opa => 150,
  403.       :z => 220,
  404.     },
  405.     :pic3 => {
  406.       :img => "tpfore2a",
  407.       :pos => [216,104],
  408.       :opa => 240,
  409.       :z => 260,
  410.     },
  411.     :fill => {
  412.       :img => "tpfill1a",
  413.       :pos => [199,33],
  414.       :opa => 240,
  415.       :z => 255,
  416.     },
  417.   } # <-- No touchy-touchy!
  418.  
  419.   XPBar = { # Settings for the XP display.
  420.     :pic1 => {
  421.       :img => "xpback2a",
  422.       :pos => [23,102],
  423.       :opa => 150,
  424.       :z => 200,
  425.     },
  426.     :pic3 => {
  427.       :img => "xpfore2a",
  428.       :pos => [23,82],
  429.       :opa => 240,
  430.       :z => 260,
  431.     },
  432.     :fill => {
  433.       :img => "xpfill2a",
  434.       :pos => [28,104],
  435.       :opa => 240,
  436.       :z => 220,
  437.     },
  438.     :txt => {
  439.       :style => :picture, :type => :direct, :decimals => 2,
  440.       :img => ["hpnums1va",0],
  441.       :pos1 => [-51,95],
  442.       :pos2 => [190,0],
  443.       :size1 => [200,60],
  444.       :size2 => [200,60],
  445.       :font => [["Parry Hotter","Old English Text MT"],36],
  446.       :align => 2,
  447.       :opa => 240,
  448.       :z => 272,
  449.     }
  450.   } # <-- No touchy-touchy!
  451.  
  452.   #-----------------------------------------------------------------------------
  453.   # State/Buff Display Settings:
  454.   #-----------------------------------------------------------------------------
  455.   # Settings for the state/buff display.
  456.   # All the state and buff icons will be displayed in an invisible window.
  457.   # If there are more icons than what fits into the window, the icons will start
  458.   # to scroll either horizontally or vertically.
  459.   #
  460.   #   :pos => [x,y],
  461.   # The position of the state/buff display window.
  462.   #
  463.   #   :size => [width,height],
  464.   # The size of the state/buff display window.
  465.   #
  466.   #   :opa => value,
  467.   # The opacity of the state/buff display window. (0 - 255)
  468.   #
  469.   #   :z => value,
  470.   # The Z value of the state/buff display window.
  471.   #
  472.   #   :anim => {:type => :horz/:vert, :speed => value, :wait => value},
  473.   # The scrolling settings for the state/buff icons inside the window.
  474.   # :type = The scroll type of the window.
  475.   #         Can be :horz (horizontal) or :vert (vertical).
  476.   # :speed = The speed of the scrolling. Measured in pixels.
  477.   #          This many pixel will be scrolled in each frames when needed.
  478.   #          Higher values mean quicker scrolling.
  479.   # :wait = The wait time between changing scrolling directions.
  480.   #         This many frames will the scrolling stop once it reached the
  481.   #         last/first icon in the window. 60 = 1 second.
  482.   #-----------------------------------------------------------------------------
  483.   Icons = { # <-- No touchy-touchy!
  484.     :pos => [78,104],
  485.     :size => [4*24,24],
  486.     :opa => 255,
  487.     :z => 110,
  488.     :anim => {:type => :horz, :speed => 2, :wait => 180},
  489.   } # <-- No touchy-touchy!
  490.  
  491. end # <-- No touchy-touchy!
  492. #===============================================================================
  493. # End of settings! O.o
  494. # Don't look below, someone may find out!
  495. #===============================================================================
  496.  
  497. module Cache
  498.  
  499.   def self.maphud(filename)
  500.     load_bitmap(SixthMapHUD::ImgFolder, filename)
  501.   end
  502.  
  503. end
  504.  
  505. class Game_Actor < Game_Battler
  506.  
  507.   def get_xp_info
  508.     s1 = exp - current_level_exp
  509.     s2 = exp_for_level(level + 1) - current_level_exp
  510.     if max_level?
  511.       exp_rate = 1.0
  512.     else
  513.       exp_rate = s1.to_f / s2
  514.     end
  515.     return [s1,s2,exp_rate]
  516.   end
  517.  
  518.   def xp_text(type,dec=0)
  519.     inf = get_xp_info
  520.     if max_level?
  521.       txt = "-------"
  522.     else
  523.       case type
  524.       when :direct
  525.         t1 = inf[0]; t2 = inf[1]
  526.         txt = t1.to_s + "/" + t2.to_s
  527.       when :percentage
  528.         txt = sprintf("%1.#{dec}f%",inf[2]*100)
  529.       end
  530.     end
  531.     return txt
  532.   end
  533.    
  534.   alias sixth_HUD7754 gain_exp
  535.   def gain_exp(exp)
  536.     if SceneManager.scene_is?(Scene_Map)
  537.       change_exp(self.exp + (exp * final_exp_rate).to_i, false)
  538.     else
  539.       sixth_HUD7754(exp)
  540.     end
  541.   end
  542.  
  543.   alias sixth_HUD9908 level_up
  544.   def level_up
  545.     sixth_HUD9908
  546.     if SceneManager.scene_is?(Scene_Map) && SixthMapHUD::LvlAnim != 0
  547.       $game_player.animation_id = SixthMapHUD::LvlAnim
  548.     end
  549.   end
  550.  
  551. end
  552.  
  553. class Scene_Map < Scene_Base
  554.  
  555.   alias sixth_hpHUD7766 start
  556.   def start
  557.     @leadmp = [$game_party.members[0].mp,$game_party.members[0].mmp]
  558.     @leadhp = [$game_party.members[0].hp,$game_party.members[0].mhp]
  559.     @leadtp = [$game_party.members[0].tp,$game_party.members[0].max_tp]
  560.     @leadxp = $game_party.members[0].get_xp_info
  561.     @togglesw = $game_switches[SixthMapHUD::HUDSwitch]
  562.     sixth_hpHUD7766
  563.     init_HUD
  564.     toggle_HUD($game_switches[SixthMapHUD::HUDSwitch])
  565.   end
  566.  
  567.   def init_HUD
  568.     @thehud = {}
  569.     SixthMapHUD::HUDs.each do |sym,info|
  570.       make_emHUD(sym,info)
  571.     end
  572.     update_fill_rates(true)
  573.     init_icon_display
  574.   end
  575.  
  576.   def init_icon_display
  577.     pos = SixthMapHUD::Icons[:pos]
  578.     sz = SixthMapHUD::Icons[:size]
  579.     anim = SixthMapHUD::Icons[:anim]
  580.     rect = Rect.new(pos[0],pos[1],sz[0],sz[1])
  581.     @aicons = ScrollIcons.new(rect,$game_party.members[0],anim)
  582.     @aicons.z = SixthMapHUD::Icons[:z]
  583.   end
  584.  
  585.   def make_emHUD(sym,type)
  586.     @thehud[sym] = {} if @thehud[sym].nil?
  587.     case sym
  588.     when :hp
  589.       rate = $game_party.members[0].hp_rate
  590.       inf = SixthMapHUD::HPBar
  591.     when :mp
  592.       rate = $game_party.members[0].mp_rate
  593.       inf = SixthMapHUD::MPBar
  594.     when :tp
  595.       rate = $game_party.members[0].tp_rate
  596.       inf = SixthMapHUD::TPBar
  597.     when :xp
  598.       rate = $game_party.members[0].get_xp_info[2]
  599.       inf = SixthMapHUD::XPBar
  600.     end
  601.     [:pic1,:pic2,:pic3,:txt].each do |pic|
  602.       next if inf[pic].nil?
  603.       @thehud[sym][pic] = Sprite.new
  604.       unless pic == :txt
  605.       @thehud[sym][pic].bitmap = Cache.maphud(inf[pic][:img]) if !inf[pic][:img].nil?
  606.         @thehud[sym][pic].x = inf[pic][:pos][0]
  607.         @thehud[sym][pic].y = inf[pic][:pos][1]
  608.       end
  609.       @thehud[sym][pic].opacity = inf[pic][:opa]
  610.       @thehud[sym][pic].z = inf[pic][:z]
  611.     end
  612.     if !inf[:txt].nil?
  613.       @thehud[sym][:txt].bitmap = Bitmap.new(inf[:txt][:size1][0],inf[:txt][:size1][1])
  614.       @thehud[sym][:txt].x = inf[:txt][:pos1][0]
  615.       @thehud[sym][:txt].y = inf[:txt][:pos1][1]
  616.       if inf[:txt][:style] == :picture
  617.         @thehud[sym][:txt].bitmap.num_style = inf[:txt][:img]  
  618.       else
  619.         @thehud[sym][:txt].bitmap.font.name = inf[:txt][:font][0]
  620.         @thehud[sym][:txt].bitmap.font.size = inf[:txt][:font][1]
  621.       end
  622.     end
  623.     fillpic = Cache.maphud(inf[:fill][:img])
  624.     yy = inf[:fill][:pos][1]; xx = inf[:fill][:pos][0]
  625.     @thehud[sym][:fill] = SpritedBar1.new(xx,yy,fillpic,rate,sym) if type == :vert
  626.     @thehud[sym][:fill] = SpritedBar2.new(xx,yy,fillpic,rate,sym) if type == :horz
  627.     @thehud[sym][:fill].opacity = inf[:fill][:opa]
  628.     @thehud[sym][:fill].z = inf[:fill][:z]
  629.     @thehud[sym][:fill].update_fill_rate
  630.   end
  631.    
  632.   alias sixth_hpHUD8888 update
  633.   def update
  634.     sixth_hpHUD8888
  635.     update_HUD_fill
  636.     update_fill_rates
  637.     toggle_HUDinit if Input.trigger?(SixthMapHUD::ToggleHUD) && !$game_map.interpreter.running?
  638.     if @togglesw != $game_switches[SixthMapHUD::HUDSwitch]
  639.       toggle_HUD($game_switches[SixthMapHUD::HUDSwitch])
  640.       @togglesw = $game_switches[SixthMapHUD::HUDSwitch]
  641.     end
  642.   end
  643.  
  644.   def update_HUD_fill
  645.     @thehud.each do |sym,sprite|
  646.       sprite[:fill].update
  647.     end
  648.   end
  649.  
  650.   def update_fill_rates(force=false)
  651.     if ((@leadhp[0] != $game_party.members[0].hp || @leadhp[1] != $game_party.members[0].mhp) || force) && !@thehud[:hp][:txt].nil?
  652.       change_txt_color(:hp,$game_party.members[0].hp_rate)
  653.       case SixthMapHUD::HPBar[:txt][:type]
  654.       when :direct
  655.         txt = $game_party.members[0].hp.to_s + "/" + $game_party.members[0].mhp.to_s
  656.       when :percentage
  657.         txt = sprintf("%1.#{SixthMapHUD::HPBar[:txt][:decimals]}f%",$game_party.members[0].hp_rate*100)
  658.       when :current
  659.         txt = $game_party.members[0].hp
  660.       end
  661.       update_bar_txt(@thehud[:hp][:txt],SixthMapHUD::HPBar[:txt],txt)
  662.       @leadhp = [$game_party.members[0].hp,$game_party.members[0].mhp]
  663.     end
  664.     if ((@leadmp[0] != $game_party.members[0].mp || @leadmp[1] != $game_party.members[0].mmp) || force) && !@thehud[:mp][:txt].nil?
  665.       change_txt_color(:mp,$game_party.members[0].mp_rate)
  666.       case SixthMapHUD::MPBar[:txt][:type]
  667.       when :direct
  668.         txt = $game_party.members[0].mp.to_s + "/" + $game_party.members[0].mmp.to_s
  669.       when :percentage
  670.         txt = sprintf("%1.#{SixthMapHUD::MPBar[:txt][:decimals]}f%",$game_party.members[0].mp_rate*100)
  671.       when :current
  672.         txt = $game_party.members[0].mp
  673.       end
  674.       update_bar_txt(@thehud[:mp][:txt],SixthMapHUD::MPBar[:txt],txt)
  675.       @leadmp = [$game_party.members[0].mp,$game_party.members[0].mmp]
  676.     end
  677.     if ((@leadtp[0] != $game_party.members[0].tp || @leadtp[1] != $game_party.members[0].max_tp) || force) && !@thehud[:tp][:txt].nil?
  678.       change_txt_color(:tp,$game_party.members[0].tp_rate)
  679.       case SixthMapHUD::TPBar[:txt][:type]
  680.       when :direct
  681.         txt = $game_party.members[0].tp.to_i.to_s + "/" + $game_party.members[0].max_tp.to_s
  682.       when :percentage
  683.         txt = sprintf("%1.#{SixthMapHUD::TPBar[:txt][:decimals]}f%",$game_party.members[0].tp_rate*100)
  684.       when :current
  685.         txt = $game_party.members[0].tp.to_i
  686.       end
  687.       update_bar_txt(@thehud[:tp][:txt],SixthMapHUD::TPBar[:txt],txt)
  688.       @leadtp = [$game_party.members[0].tp,$game_party.members[0].max_tp]
  689.     end
  690.     if (@leadxp != $game_party.members[0].get_xp_info || force) && !@thehud[:xp][:txt].nil?
  691.       txt = $game_party.members[0].xp_text(SixthMapHUD::XPBar[:txt][:type],SixthMapHUD::XPBar[:txt][:decimals])
  692.       update_bar_txt(@thehud[:xp][:txt],SixthMapHUD::XPBar[:txt],txt)
  693.       @leadxp = $game_party.members[0].get_xp_info
  694.     end    
  695.   end
  696.  
  697.   def change_txt_color(sym,data)
  698.     SixthMapHUD::TxtColors[sym].each do |key,val|
  699.       if (data*100) <= key
  700.         if val.size == 2
  701.           @thehud[sym][:txt].bitmap.num_style = val
  702.         else
  703.           @thehud[sym][:txt].bitmap.font.color = Color.new(*val)
  704.         end
  705.         break
  706.       end
  707.     end
  708.   end
  709.    
  710.   def update_bar_txt(bar,info,data)
  711.     rect = Rect.new(0,0,info[:size1][0],info[:size1][1])
  712.     bar.bitmap.clear_rect(rect)
  713.     if info[:style] == :picture
  714.       bar.bitmap.draw_numbers(info[:pos2][0],info[:pos2][1],data,255,info[:align])
  715.     else
  716.       rectt = Rect.new(info[:pos2][0],info[:pos2][1],info[:size2][0],info[:size2][1])
  717.       bar.bitmap.draw_text(rectt,data,info[:align])
  718.     end
  719.   end
  720.    
  721.   def toggle_HUDinit
  722.     $game_switches[SixthMapHUD::HUDSwitch] = !$game_switches[SixthMapHUD::HUDSwitch]
  723.   end
  724.  
  725.   def toggle_HUD(opa)
  726.     @thehud.each do |sym,sprites|
  727.       if opa == true
  728.         case sym
  729.         when :hp
  730.           inf = SixthMapHUD::HPBar
  731.         when :mp
  732.           inf = SixthMapHUD::MPBar
  733.         when :tp
  734.           inf = SixthMapHUD::TPBar
  735.         when :xp
  736.           inf = SixthMapHUD::XPBar
  737.         end
  738.       end
  739.       sprites.each do |sym2,sprite|
  740.         opac = opa == true ? inf[sym2][:opa] : 0
  741.         sprite.opacity = opac
  742.       end
  743.     end
  744.     opac = opa == true ? SixthMapHUD::Icons[:opa] : 0
  745.     @aicons.contents_opacity = opac
  746.   end
  747.  
  748.   def dispose_the_HUD
  749.     @thehud.each do |sym,sprites|
  750.       sprites.each do |sym2,sprite|
  751.         sprite.bitmap.dispose
  752.         sprite.dispose
  753.       end
  754.     end
  755.   end
  756.  
  757.   alias sixth_hpHUD9986 dispose_spriteset
  758.   def dispose_spriteset
  759.     dispose_the_HUD
  760.     sixth_hpHUD9986
  761.   end
  762.  
  763. end
  764.  
  765. class SpritedBar1 < Sprite_Base
  766.  
  767.   def initialize(x,y,pic,rate,sym)
  768.     super(nil)
  769.     self.x = x; self.y = y
  770.     @ori_y = self.y
  771.     @rate = rate; @sym = sym
  772.     self.bitmap = pic
  773.     src_rect.height = self.bitmap.height * @rate
  774.     src_rect.y = self.bitmap.height - src_rect.height
  775.     self.y = @ori_y + src_rect.y
  776.   end
  777.  
  778.   def update
  779.     super
  780.     update_rate
  781.   end
  782.  
  783.   def update_rate
  784.     case @sym
  785.     when :hp
  786.       if @rate != $game_party.members[0].hp_rate
  787.         @rate = $game_party.members[0].hp_rate
  788.         update_fill_rate
  789.       end
  790.     when :mp
  791.       if @rate != $game_party.members[0].mp_rate
  792.         @rate = $game_party.members[0].mp_rate
  793.         update_fill_rate
  794.       end
  795.     when :tp
  796.       if @rate != $game_party.members[0].tp_rate
  797.         @rate = $game_party.members[0].tp_rate
  798.         update_fill_rate
  799.       end
  800.     when :xp
  801.       if @rate != $game_party.members[0].get_xp_info[2]
  802.         @rate = $game_party.members[0].get_xp_info[2]
  803.         update_fill_rate
  804.       end
  805.     when :timer
  806.       if @rate != $game_timer.fill_rate
  807.         @rate = $game_timer.fill_rate
  808.         update_fill_rate
  809.       end
  810.     end
  811.   end
  812.  
  813.   def update_fill_rate
  814.     src_rect.height = self.bitmap.height * @rate
  815.     src_rect.y = self.bitmap.height - src_rect.height
  816.     self.y = @ori_y + src_rect.y
  817.   end
  818.  
  819. end
  820.  
  821. class SpritedBar2 < Sprite_Base
  822.  
  823.   def initialize(x,y,pic,rate,sym)
  824.     super(nil)
  825.     self.x = x; self.y = y
  826.     @rate = rate; @sym = sym; @pic = pic
  827.     if SixthMapHUD::HorzMode == :rect
  828.       self.bitmap = pic
  829.     else
  830.       self.bitmap = Bitmap.new(pic.width,pic.height)
  831.     end
  832.     update_fill_rate
  833.   end
  834.  
  835.   def update
  836.     super
  837.     update_rate
  838.   end
  839.  
  840.   def update_rate
  841.     case @sym
  842.     when :hp
  843.       if @rate != $game_party.members[0].hp_rate
  844.         @rate = $game_party.members[0].hp_rate
  845.         update_fill_rate
  846.       end
  847.     when :mp
  848.       if @rate != $game_party.members[0].mp_rate
  849.         @rate = $game_party.members[0].mp_rate
  850.         update_fill_rate
  851.       end
  852.     when :tp
  853.       if @rate != $game_party.members[0].tp_rate
  854.         @rate = $game_party.members[0].tp_rate
  855.         update_fill_rate
  856.       end
  857.     when :xp
  858.       if @rate != $game_party.members[0].get_xp_info[2]
  859.         @rate = $game_party.members[0].get_xp_info[2]
  860.         update_fill_rate
  861.       end
  862.     when :timer
  863.       if @rate != $game_timer.fill_rate
  864.         @rate = $game_timer.fill_rate
  865.         update_fill_rate
  866.       end
  867.     end
  868.   end
  869.  
  870.   def update_fill_rate
  871.     if SixthMapHUD::HorzMode == :rect
  872.       src_rect.width = self.bitmap.width * @rate
  873.     else
  874.       full_rect = Rect.new(0,0,@pic.width,@pic.height)
  875.       new_rect = Rect.new(0,0,@pic.width*@rate,@pic.height)
  876.       self.bitmap.clear_rect(full_rect)
  877.       self.bitmap.stretch_blt(new_rect,@pic,full_rect,SixthMapHUD::XPBar[:fill][:opa])
  878.     end
  879.   end
  880.  
  881. end
  882.  
  883. unless $imported && $imported["SixthMenuEngine"]
  884. class ScrollIcons < Window_Base
  885.    
  886.   def initialize(rect,actor,anim)
  887.     @rect = rect
  888.     @actor = actor; @icons = actor.state_icons; @anim = anim
  889.     case @anim[:type]
  890.     when :horz
  891.       @w = @actor.state_icons.size*24; @h = rect.height
  892.       @w = 1 if @w == 0
  893.       @count = actor.state_icons.size > rect.width/24 ? @anim[:wait] : 0
  894.     when :vert
  895.       @w = rect.width; @h = @actor.state_icons.size*24
  896.       @h = 1 if @h == 0
  897.       @count = actor.state_icons.size > rect.height/24 ? @anim[:wait] : 0
  898.     end
  899.     @dir = :down
  900.     super(rect.x,rect.y,rect.width,rect.height)
  901.     self.opacity = 0
  902.     self.arrows_visible = false
  903.     draw_them_icons
  904.   end
  905.  
  906.   def standard_padding
  907.     0
  908.   end
  909.  
  910.   def set_actor(actor)
  911.     @actor = actor
  912.     case @anim[:type]
  913.     when :horz
  914.       @count = @actor.state_icons.size > @rect.width/24 ? @anim[:wait] : 0
  915.     when :vert
  916.       @count = @actor.state_icons.size > @rect.height/24 ? @anim[:wait] : 0
  917.     end
  918.     self.ox = 0; self.oy = 0
  919.     update_icons(true)
  920.   end
  921.  
  922.   def contents_width
  923.     @w
  924.   end
  925.  
  926.   def contents_height
  927.     @h
  928.   end
  929.  
  930.   def draw_them_icons
  931.     create_contents
  932.     draw_actor_icons(@actor, 0, 0)
  933.   end
  934.    
  935.   def draw_actor_icons(actor, x, y)
  936.     icons = (actor.state_icons + actor.buff_icons)
  937.     case @anim[:type]
  938.     when :horz
  939.       icons.each_with_index {|n, i| draw_icon(n, x + 24 * i, y) }
  940.     when :vert
  941.       icons.each_with_index {|n, i| draw_icon(n, x, y + 24 * i) }
  942.     end
  943.   end
  944.    
  945.   def update_scrolling_horz
  946.     if @actor.state_icons.size > @rect.width/24
  947.       if @count <= 0
  948.         if @dir == :down
  949.           if self.ox < (@actor.state_icons.size - @rect.width/24) * 24
  950.             self.ox += @anim[:speed]
  951.             self.ox = [self.ox,(@actor.state_icons.size - @rect.width/24) * 24].min
  952.           end
  953.           if self.ox == (@actor.state_icons.size - @rect.width/24) * 24
  954.             @dir = :up
  955.             @count = @anim[:wait]
  956.           end
  957.         elsif @dir == :up
  958.           if self.ox > 0
  959.             self.ox -= @anim[:speed]
  960.             self.ox = [self.ox,0].max
  961.           end
  962.           if self.ox == 0
  963.             @dir = :down
  964.             @count = @anim[:wait]
  965.           end
  966.         end
  967.       end
  968.     elsif @actor.state_icons.size <= @rect.width/24
  969.       self.ox = 0 if self.ox != 0
  970.     end
  971.     @count -= 1 if @count > 0
  972.   end
  973.  
  974.   def update_scrolling_vert
  975.     if @actor.state_icons.size > @rect.height/24
  976.       if @count <= 0
  977.         if @dir == :down
  978.           if self.oy < (@actor.state_icons.size - @rect.height/24) * 24
  979.             self.oy += @anim[:speed]
  980.             self.oy = [self.oy,(@actor.state_icons.size - @rect.height/24) * 24].min
  981.           end
  982.           if self.oy == (@actor.state_icons.size - @rect.height/24) * 24
  983.             @dir = :up
  984.             @count = @anim[:wait]
  985.           end
  986.         elsif @dir == :up
  987.           if self.oy > 0
  988.             self.oy -= @anim[:speed]
  989.             self.oy = [self.oy,0].max
  990.           end
  991.           if self.oy == 0
  992.             @dir = :down
  993.             @count = @anim[:wait]
  994.           end
  995.         end
  996.       end
  997.     elsif @actor.state_icons.size <= @rect.height/24
  998.       self.oy = 0 if self.oy != 0
  999.     end
  1000.     @count -= 1 if @count > 0
  1001.   end
  1002.  
  1003.   def update_icons(force=false)
  1004.     if @icons != @actor.state_icons || force
  1005.       case @anim[:type]
  1006.       when :horz
  1007.         @w = @actor.state_icons.size*24 if @w != @actor.state_icons.size*24
  1008.         @w = 1 if @w == 0
  1009.       when :vert
  1010.         @h = @actor.state_icons.size*24 if @h != @actor.state_icons.size*24
  1011.         @h = 1 if @h == 0
  1012.       end
  1013.       draw_them_icons
  1014.       @icons = @actor.state_icons
  1015.     end
  1016.   end
  1017.  
  1018.   def update
  1019.     super
  1020.     update_icons
  1021.     case @anim[:type]
  1022.     when :horz
  1023.       update_scrolling_horz
  1024.     when :vert
  1025.       update_scrolling_vert
  1026.     end
  1027.   end
  1028.  
  1029. end
  1030. end
  1031. #==============================================================================
  1032. # !!END OF SCRIPT - OHH, NOES!!
  1033. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement