Advertisement
AngryPacman

Neo Gauge Ultimate

Jul 29th, 2011
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 15.35 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # You may be wondering why Woratana's Neo Gauge is in here. Well, I love it so
  4. # much I couldn't bare to run a game without it, so it's included here. That
  5. # said, it's been edited by me so I've renamed it Neo Gauge Ultimate. This is
  6. # because it's not in PAC format, and I don't think I've edited it enough to
  7. # consider it an original work.
  8. #
  9. #===============================================================================
  10.  
  11. #==============================================================================
  12. # [VX] <+ [Neo Gauge] ENGINE -> by Woratana
  13. #------------------------------------------------------------------------------
  14. # ◦ by Woratana [woratana@hotmail.com]
  15. # ◦ Released on: 25/12/2008 (D-M-Y)
  16. # ◦ Version: 2
  17. #---------------------------------------------------------------------------
  18. # ◦ Exclusive Script @ RPG RPG Revolution (http://www.rpgrevolution.com/)
  19. #---------------------------------------------------------------------------
  20. #### [FEATURES] ####
  21. # - Support horizontal/vertical gradient bar.
  22. # - Draw 3 colors gradient / user can choose spot to draw second color.
  23. # - Easy to setting gauge style.
  24. #------------------------------------------------------------------------------
  25. #==============================================================================
  26.  
  27. class Window_Base < Window
  28.   #==========================================================================
  29.   # NEO GAUGE SETTING #
  30.   # Color: Color.new(Red, Green, Blue) # Each number you can put integer 0-255
  31.   # * You can use this site to get RGB color:
  32.   # http://web.njit.edu/~kevin/rgb.txt.html
  33.   #==========================================================================
  34.   GAUGE_GLOW_EFFECT = true # Use glow effect?
  35.   GAUGE_GLOW_COLOR = Color.new(0,0,0) # Glow color
  36.  
  37.   GAUGE_OUTSIDE_BORDER = true # Use outside border?
  38.   GAUGE_OUTSIDE_BORDER_COLOR = Color.new(255,255,255)#Color.new(0, 0, 0)
  39.   GAUGE_OUTSIDE_BORDER_COLOR2 = Color.new(255,255,255)#Color.new(0, 0, 0)
  40.   GAUGE_CLEAR_CORNER_OUTSIDE_BORDER = true
  41.  
  42.   GAUGE_INSIDE_BORDER = false # Use inside border?
  43.   GAUGE_INSIDE_BORDER_COLOR = Color.new(255, 255, 255)
  44.   GAUGE_INSIDE_BORDER_COLOR2 = Color.new(0, 0, 0)
  45.   #==========================================================================
  46.  
  47.   #=============================================================
  48.   # NEO HP/MP/STATS GAUGE SETTING #
  49.   #=============================================================
  50.   HPMP_GAUGE_HEIGHT = 8 # gauge height (minumum: 6)
  51.   # Recommend to use HPMP_GAUGE_HEIGHT at least 8,
  52.   # if you're using GAUGE_INSIDE_BORDER in Neo-Gauge
  53.   HPMP_GAUGE_X_PLUS = 0 # Move gauge horizontally (+,-)
  54.   HPMP_GAUGE_Y_PLUS = ((-1)*(HPMP_GAUGE_HEIGHT - 6)) # (+,-)
  55.   # Change '((-1)*(HPMP_GAUGE_HEIGHT - 6))' to number to move gauge vertically
  56.  
  57.   # BACK GAUGE COLORS
  58.   BACK_GCOLOR_1 = Color.new(0, 0, 0) # Black [Color1]
  59.   BACK_GCOLOR_2 = Color.new(100, 100, 100) # Dark Gray [Color2]
  60.   BACK_GCOLOR_3 = Color.new(200, 200, 200) # Light Gray [Color3]
  61.  
  62.   USE_HP_GAUGE = true # Use HP Gauge? (true/false)
  63.   USE_MP_GAUGE = true # Use MP Gauge?
  64.  
  65.   # HP GAUGE COLORS
  66.   HP_GCOLOR_1 = Color.new(139,0,0) # Dark Red
  67.   HP_GCOLOR_2 = Color.new(255,0,0) # Pure Red
  68.   HP_GCOLOR_3 = Color.new(255,193,37) # Goldenrod
  69.  
  70.   # MP GAUGE COLORS
  71.   MP_GCOLOR_1 = Color.new(0,0,128) # Dark Blue
  72.   MP_GCOLOR_2 = Color.new(0,191,255) # Blue
  73.   MP_GCOLOR_3 = Color.new(46,139,87) # Light Green
  74.  
  75.   #---------------------------------------------------------
  76.  
  77.   ADSA_GAUGE_MAX_MODE = 0
  78.   # Mode for Attack/Defense/Spirit/Agility Gauge Max:
  79.   # 0: use stats at level 99 for gauge's max
  80.   # 1 or more: use that number for gauge's max
  81.  
  82.   USE_ADSA_GAUGE = true # Use Attack/Defense/Spirit/Agility Gauge?
  83.  
  84.   # ATTACK GAUGE COLORS
  85.   ATK_GCOLOR_1 = Color.new(0,0,128)
  86.   ATK_GCOLOR_2 = Color.new(0,191,255)
  87.   ATK_GCOLOR_3 = Color.new(152,251,152)
  88.  
  89.   # DEFENSE GAUGE COLORS
  90.   DEF_GCOLOR_1 = Color.new(0,0,128)
  91.   DEF_GCOLOR_2 = Color.new(0,191,255)
  92.   DEF_GCOLOR_3 = Color.new(152,251,152)
  93.  
  94.   # SPIRIT GAUGE COLORS
  95.   SPI_GCOLOR_1 = Color.new(0,0,128)
  96.   SPI_GCOLOR_2 = Color.new(0,191,255)
  97.   SPI_GCOLOR_3 = Color.new(152,251,152)
  98.  
  99.   # AGILITY GAUGE COLORS
  100.   AGI_GCOLOR_1 = Color.new(0,0,128)
  101.   AGI_GCOLOR_2 = Color.new(0,191,255)
  102.   AGI_GCOLOR_3 = Color.new(152,251,152)
  103.  
  104.   #-------------------------------------------------------------------
  105.  
  106.   USE_MOG_BASIC_MENU = false # Use Mog Basic Menu (EXP) Gauge?
  107.  
  108.   # Mog Basic Menu EXP GAUGE COLORS
  109.   MOG_EXP_GCOLOR_1 = Color.new(0,100,0)
  110.   MOG_EXP_GCOLOR_2 = Color.new(0, 255, 0)
  111.   MOG_EXP_GCOLOR_3 = Color.new(173,255,47)
  112.  
  113.   #-------------------------------------------------------------------
  114.   # [END] NEO GAUGE FINAL SETUP
  115.   #===================================================================
  116.  
  117.   #------------------------------------------------------------
  118.   # * Neo Gauge Back Color: Return back colors
  119.   #------------------------------------------------------------
  120.   def neo_gauge_back_color
  121.     return BACK_GCOLOR_1, BACK_GCOLOR_2, BACK_GCOLOR_3
  122.   end
  123.  
  124.   #--------------------------------------------------------------------------
  125.   # [Rewrite] * Draw HP gauge
  126.   #--------------------------------------------------------------------------
  127. if USE_HP_GAUGE
  128.   def draw_actor_hp_gauge(actor, x, y, width = 120)
  129.     gwidth = width * actor.hp / actor.maxhp
  130.     cg = neo_gauge_back_color
  131.     c1, c2, c3 = cg[0], cg[1], cg[2]
  132.     draw_neo_gauge(x + HPMP_GAUGE_X_PLUS, y + WLH - 8 + HPMP_GAUGE_Y_PLUS, width,
  133. HPMP_GAUGE_HEIGHT, c1, c2, c3)
  134.     (1..3).each {|i| eval("c#{i} = HP_GCOLOR_#{i}") }
  135.     draw_neo_gauge(x + HPMP_GAUGE_X_PLUS, y + WLH - 8 + HPMP_GAUGE_Y_PLUS, gwidth, HPMP_GAUGE_HEIGHT,
  136. c1, c2, c3, false, false, width, 30)
  137.   end
  138. end
  139.   #--------------------------------------------------------------------------
  140.   # [Rewrite] * Draw MP Gauge
  141.   #--------------------------------------------------------------------------
  142. if USE_MP_GAUGE
  143.   def draw_actor_mp_gauge(actor, x, y, width = 120)
  144.     gwidth = width * actor.mp / [actor.maxmp, 1].max
  145.     cg = neo_gauge_back_color
  146.     c1, c2, c3 = cg[0], cg[1], cg[2]
  147.     draw_neo_gauge(x + HPMP_GAUGE_X_PLUS, y + WLH - 8 + HPMP_GAUGE_Y_PLUS, width,
  148. HPMP_GAUGE_HEIGHT, c1, c2, c3)
  149.     (1..3).each {|i| eval("c#{i} = MP_GCOLOR_#{i}") }
  150.     draw_neo_gauge(x + HPMP_GAUGE_X_PLUS, y + WLH - 8 + HPMP_GAUGE_Y_PLUS, gwidth, HPMP_GAUGE_HEIGHT,
  151. c1, c2, c3, false, false, width, 40)
  152.   end
  153. end
  154.  
  155.   #--------------------------------------------------------------------------
  156.   # [Rewrite] * Draw Parameters
  157.   #--------------------------------------------------------------------------
  158. if USE_ADSA_GAUGE
  159.   def draw_actor_parameter(actor, x, y, type)
  160.     case type
  161.     when 0
  162.       parameter_name = Vocab::atk
  163.       parameter_value = actor.atk
  164.       parameter_value_max = actor.maxatk
  165.       (1..3).each {|i| eval("@c#{i} = ATK_GCOLOR_#{i}") }
  166.     when 1
  167.       parameter_name = Vocab::def
  168.       parameter_value = actor.def
  169.       parameter_value_max = actor.maxdef
  170.       (1..3).each {|i| eval("@c#{i} = DEF_GCOLOR_#{i}") }
  171.     when 2
  172.       parameter_name = Vocab::spi
  173.       parameter_value = actor.spi
  174.       parameter_value_max = actor.maxspi
  175.       (1..3).each {|i| eval("@c#{i} = SPI_GCOLOR_#{i}") }
  176.     when 3
  177.       parameter_name = Vocab::agi
  178.       parameter_value = actor.agi
  179.       parameter_value_max = actor.maxagi
  180.       (1..3).each {|i| eval("@c#{i} = AGI_GCOLOR_#{i}") }
  181.     end
  182.     # Draw parameter gauge
  183.     parameter_value_max = ADSA_GAUGE_MAX_MODE if ADSA_GAUGE_MAX_MODE > 0
  184.     width = 156
  185.     gwidth = width * parameter_value / [parameter_value_max, 1].max
  186.     cg = neo_gauge_back_color
  187.     draw_neo_gauge(x + HPMP_GAUGE_X_PLUS, y + WLH - 8 + HPMP_GAUGE_Y_PLUS, width,
  188. HPMP_GAUGE_HEIGHT, cg[0], cg[1], cg[2])
  189.     draw_neo_gauge(x + HPMP_GAUGE_X_PLUS, y + WLH - 8 + HPMP_GAUGE_Y_PLUS, gwidth, HPMP_GAUGE_HEIGHT,
  190. @c1, @c2, @c3, false, false, width, 40)
  191.     self.contents.font.color = system_color
  192.     self.contents.draw_text(x, y, 120, WLH, parameter_name)
  193.     self.contents.font.color = normal_color
  194.     self.contents.draw_text(x + 120, y, 36, WLH, parameter_value, 2)
  195.   end
  196. end
  197.  
  198.   #--------------------------------------------------------------------------
  199.   # [Rewrite] * Mog Basic Menu Plus EXP Gauge
  200.   #--------------------------------------------------------------------------
  201. if USE_MOG_BASIC_MENU
  202.   def draw_actor_exp_meter(actor, x, y, width = 100)  
  203.     if actor.next_exp != 0
  204.       exp = actor.now_exp
  205.     else
  206.       exp = 1
  207.     end
  208.     gw = width * exp / [actor.next_exp, 1].max
  209.     cg = neo_gauge_back_color
  210.     c1, c2, c3 = cg[0], cg[1], cg[2]
  211.     draw_neo_gauge(x + HPMP_GAUGE_X_PLUS, y + WLH - 8 + HPMP_GAUGE_Y_PLUS, width,
  212. HPMP_GAUGE_HEIGHT, c1, c2, c3)
  213.     (1..3).each {|i| eval("c#{i} = MOG_EXP_GCOLOR_#{i}") }
  214.     draw_neo_gauge(x + HPMP_GAUGE_X_PLUS, y + WLH - 8 + HPMP_GAUGE_Y_PLUS, gw, HPMP_GAUGE_HEIGHT,
  215. c1, c2, c3, false, false, width, 50)
  216.     self.contents.font.color = system_color
  217.     self.contents.draw_text(x, y, 30, WLH, "Exp")    
  218.     self.contents.font.color = normal_color
  219.     xr = x + width
  220.     self.contents.draw_text(xr - 60, y, 60, WLH,  actor.next_rest_exp_s, 2)
  221.   end
  222. end
  223.  
  224.   #--------------------------------------------------------------------------
  225.   # * Draw Neo Gauge: Draw Gauge with 3 Colors & Outline
  226.   # x : draw spot x-coordinate
  227.   # y : draw spot y-coordinate
  228.   # width : gauge width
  229.   # height : gauge height
  230.   # color1 : first color (left side)
  231.   # color2 : second color (center)
  232.   # color3 : last color (right side)
  233.   # vertical : vertical gauge? (true: vertical | false: horizontal)
  234.   # outline : draw glow & outline? (true: draw | false: draw only gradient)
  235.   # max_width : max_width that gradient will draw before cut to width
  236.   # (max_width will becomes max_height in vertical gauge)
  237.   # color2_spot = spot to draw color 2 [1:Left <- (default)50:Center -> 100:Right]
  238.   #-------------------------------------------------------------------------
  239.   def draw_neo_gauge(x, y, width, height, color1, color2, color3, vertical = false,
  240. outline = true, max_width = nil, color2_spot = 50)
  241.     if max_width == nil
  242.       max_width = vertical ? height : width
  243.     end
  244.     glow = GAUGE_GLOW_EFFECT # Set glow effect
  245.     dx = x; dy = y # Store draw spot X/Y
  246.     x = y = 0 # Change x, y for temp. bitmap
  247.     bitmap = Bitmap.new(max_width, height) # Create temp. bitmap to draw gauge
  248.     if glow # If GLOW
  249.       if outline # If drawing outline
  250.         # Create Glow rect
  251.         if vertical; rect = Rect.new(x, y, width, max_width)
  252.         else; rect = Rect.new(x, y, max_width, height)
  253.         end
  254.         bitmap.fill_rect(rect, GAUGE_GLOW_COLOR) # Draw Glow
  255.         bitmap.neo_clear_corner(rect.x, rect.y, rect.width, rect.height) # Clear Corner
  256.       else # Not drawing outline
  257.         height -= 2; width -= 2; x += 1; y += 1
  258.         if GAUGE_INSIDE_BORDER
  259.           height -= 2; width -= 2; x += 1; y += 1
  260.         end; end; end # End Draw Glow0
  261.     # Set Position/Size for Gradient
  262.     if vertical # If drawing vertical bar
  263.       if glow; gx = gx2 = x + 1; gy = y + 1 # If GLOW
  264.       else; gx = gx2 = x; gy = y # If NOT GLOW
  265.       end
  266.       gy2 = gy - 1 + ((color2_spot*max_width)/100)
  267.       gw = gw2 = width - 2; gh = ((color2_spot*max_width)/100)
  268.       gh2 = max_width - gh - 2
  269.       # Draw Vertical Gradient Bar
  270.       bitmap.gradient_fill_rect(gx, gy, gw, gh, color1, color2, true)
  271.       bitmap.gradient_fill_rect(gx2, gy2, gw2, gh2, color2, color3, true)
  272.       gh = (gh + gh2) # Change gauge height for draw border
  273.     else # Drawing horizontal bar
  274.       if glow; gx = x; gy = gy2 = y # If GLOW
  275.         gx = x + 1; gy = gy2 = y + 1;
  276.       else; gx = x; gy = gy2 = y # If NOT GLOW
  277.       end
  278.       gx2 = gx - 1 + ((color2_spot*max_width)/100)
  279.       gw = ((color2_spot*max_width)/100); gh = gh2 = (height - 2)
  280.       gw2 = max_width - gw - 2
  281.       # Draw Horizontal Gradient Bar
  282.       bitmap.gradient_fill_rect(gx, gy, gw, gh, color1, color2)
  283.       bitmap.gradient_fill_rect(gx2, gy2, gw2, gh2, color2, color3)
  284.       gw = (gw + gw2) # Change gauge width for draw border
  285.     end
  286.     if outline # If user want outline, draw borders
  287.       if GAUGE_OUTSIDE_BORDER # Draw outside border
  288.         bitmap.draw_neo_border(gx, gy, gw, gh, GAUGE_OUTSIDE_BORDER_COLOR, GAUGE_OUTSIDE_BORDER_COLOR2)
  289.         bitmap.neo_clear_corner(gx, gy, gw, gh) if GAUGE_CLEAR_CORNER_OUTSIDE_BORDER
  290.       end
  291.       if GAUGE_INSIDE_BORDER # Draw inside border
  292.         gx += 1; gy += 1; gw -= 2; gh -= 2
  293.         bitmap.draw_neo_border(gx, gy, gw, gh, GAUGE_INSIDE_BORDER_COLOR, GAUGE_INSIDE_BORDER_COLOR2)
  294.       end
  295.     end
  296.     # Cut gauge's width from 'max_width' to 'width'
  297.     rect = Rect.new(0, 0, width, bitmap.height)
  298.     self.contents.blt(dx, dy, bitmap, rect)
  299.     bitmap.dispose # Delete bitmap
  300.   end
  301. end
  302.  
  303. #==============================================================================
  304. # [Bitmap: 2 New Methods] by Woratana
  305. # => Draw Neo Border: Draw border around specific area
  306. # => Neo Clear Corner: Clear 4 corners of specific area
  307. #------------------------------------------------------------------------------
  308. class Bitmap
  309.   #--------------------------------------------------------------------------
  310.   # * Draw Neo Border: Draw gradient border around specific area
  311.   # x : area x-coordinate
  312.   # y : area y-coordinate
  313.   # width : area width
  314.   # height : area height
  315.   # color : border color (left side)
  316.   # color2 : border color (right side)
  317.   # size : border size (default is 1)
  318.   #--------------------------------------------------------------------------
  319.   def draw_neo_border(x, y, width, height, color, color2 = color, size = 1)
  320.     gradient_fill_rect(x, y, width, size, color, color2) # Top
  321.     fill_rect(x, y, size, height, color) # Left
  322.     fill_rect(x + width - size, y, size, height, color2) # Right
  323.     gradient_fill_rect(x, y + height - size, width, size, color, color2) # Down
  324.   end
  325.  
  326.   #--------------------------------------------------------------------------
  327.   # * Neo Clear Corner: Clear 4 corners of specific area
  328.   # x : area x-coordinate
  329.   # y : area y-coordinate
  330.   # width : area width
  331.   # height : area height
  332.   # size : area (size * size) that will be clear from corners
  333.   #--------------------------------------------------------------------------
  334.   def neo_clear_corner(x, y, width, height, size = 1)
  335.     clear_rect(x, y, size, size)
  336.     clear_rect(x + width - size, y, size, size)
  337.     clear_rect(x, y + height - size, size, size)
  338.     clear_rect(x + width - size, y + height - size, size, size)
  339.   end
  340. end
  341.  
  342. #==============================================================================
  343. # [Game_Batter: 4 New Methods] by Woratana
  344. # Add method to find maximum stats
  345. #------------------------------------------------------------------------------
  346. class Game_Battler
  347.   def maxatk
  348.     n = atk
  349.     n = n - actor.parameters[2, @level] + actor.parameters[2, 99] if self.is_a?(Game_Actor)
  350.     return n
  351.   end
  352.  
  353.   def maxdef
  354.     n = atk
  355.     n = n - actor.parameters[3, @level] + actor.parameters[3, 99] if self.is_a?(Game_Actor)
  356.     return n
  357.   end
  358.  
  359.   def maxspi
  360.     n = atk
  361.     n = n - actor.parameters[4, @level] + actor.parameters[4, 99] if self.is_a?(Game_Actor)
  362.     return n
  363.   end
  364.  
  365.   def maxagi
  366.     n = atk
  367.     n = n - actor.parameters[5, @level] + actor.parameters[5, 99] if self.is_a?(Game_Actor)
  368.     return n
  369.   end
  370. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement