Advertisement
AngryPacman

[VXA] Neo Gauge Ultimate

Feb 3rd, 2012
6,860
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 15.83 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Neo Gauge Ultimate Ace (1.1a)
  4. # 21/02/2012
  5. # Ported to Ace by Pacman (original script by Woratana and edited by Pacman)
  6. # This script changes the way gauges are drawn. This script supports drawing
  7. # gauges horizontally and vertically, uses a 3-colour gradient, has a very
  8. # simple setup and two brilliant methods to change the bitmap.
  9. # Note that much of this work is Woratana's, you should credit him the same as
  10. # (if not more than) me. I do not claim writing this script entirely, I edited
  11. # the VX version a while back, and this is the VXA port of that.
  12. #
  13. # Detailed instructions on the configuration are below.
  14. #
  15. #===============================================================================
  16.  
  17. class Window_Base < Window  # DO NOT TOUCH THIS
  18.  
  19.   #==========================================================================
  20.   # NEO GAUGE SETTING #
  21.   # Color: Color.new(Red, Green, Blue) # Each number you can put integer 0-255
  22.   # * You can use this site to get RGB color:
  23.   # http://web.njit.edu/~kevin/rgb.txt.html
  24.   #==========================================================================
  25.   GAUGE_GLOW_EFFECT = true # Use glow effect?
  26.   GAUGE_GLOW_COLOR = Color.new(0,0,0) # Glow color
  27.  
  28.   GAUGE_OUTSIDE_BORDER = true # Use outside border?
  29.   GAUGE_OUTSIDE_BORDER_COLOR = Color.new(255,255,255)
  30.   GAUGE_OUTSIDE_BORDER_COLOR2 = Color.new(255,255,255)
  31.   GAUGE_CLEAR_CORNER_OUTSIDE_BORDER = true
  32.  
  33.   GAUGE_INSIDE_BORDER = false # Use inside border?
  34.   GAUGE_INSIDE_BORDER_COLOR = Color.new(255, 255, 255)
  35.   GAUGE_INSIDE_BORDER_COLOR2 = Color.new(0, 0, 0)
  36.   #=============================================================
  37.   # NEO HP/MP/TP/STATS GAUGE SETTING #
  38.   #=============================================================
  39.   # Note: The HPMP options also apply to the TP gauge.
  40.   HPMP_GAUGE_HEIGHT = 8 # gauge height (minumum: 6)
  41.   # Recommend to use HPMP_GAUGE_HEIGHT at least 8,
  42.   # if you're using GAUGE_INSIDE_BORDER in Neo-Gauge
  43.   HPMP_GAUGE_X_PLUS = 0 # Move gauge horizontally (+,-)
  44.   HPMP_GAUGE_Y_PLUS = ((-1)*(HPMP_GAUGE_HEIGHT - 6)) # (+,-)
  45.   # Change '((-1)*(HPMP_GAUGE_HEIGHT - 6))' to number to move gauge vertically
  46.  
  47.   # BACK GAUGE COLORS
  48.   BACK_GCOLOR_1 = Color.new(0, 0, 0) # Black [Color1]
  49.   BACK_GCOLOR_2 = Color.new(100, 100, 100) # Dark Gray [Color2]
  50.   BACK_GCOLOR_3 = Color.new(200, 200, 200) # Light Gray [Color3]
  51.  
  52.   USE_HP_GAUGE = true # Use HP Gauge? (true/false)
  53.   USE_MP_GAUGE = true # Use MP Gauge?
  54.   USE_TP_GAUGE = true # Use TP Gauge?
  55.   USE_STATS_GAUGE = true # Use Attack/Defense/Spirit/Agility/Luck Gauge?
  56.  
  57.   # HP GAUGE COLORS
  58.   HP_GCOLOR_1 = Color.new(139,0,0) # Dark Red
  59.   HP_GCOLOR_2 = Color.new(255,0,0) # Pure Red
  60.   HP_GCOLOR_3 = Color.new(255,193,37) # Goldenrod
  61.  
  62.   # MP GAUGE COLORS
  63.   MP_GCOLOR_1 = Color.new(0,0,128) # Dark Blue
  64.   MP_GCOLOR_2 = Color.new(0,191,255) # Blue
  65.   MP_GCOLOR_3 = Color.new(46,139,87) # Light Green
  66.  
  67.   # TP GAUGE COLORS
  68.   TP_GCOLOR_1 = Color.new(0, 100, 0)  # Dark Green
  69.   TP_GCOLOR_2 = Color.new(191, 255, 0)  # Lime Green
  70.   TP_GCOLOR_3 = Color.new(173, 255, 47) # Yellow Green
  71.  
  72.   # STAT GAUGE COLORS
  73.   STAT_GCOLOR_1 = Color.new(0,0,128)
  74.   STAT_GCOLOR_2 = Color.new(0,191,255)
  75.   STAT_GCOLOR_3 = Color.new(152,251,152)
  76.  
  77. #===============================================================================
  78. #
  79. # END CONFIGURATION
  80. #
  81. #===============================================================================
  82.  
  83. #==============================================================================
  84. # ■ Window_Base
  85. #------------------------------------------------------------------------------
  86. #  ゲーム中の全てのウィンドウのスーパークラスです。
  87. #==============================================================================
  88.   #--------------------------------------------------------------------------
  89.   # * Get Gauge Back Colours
  90.   #--------------------------------------------------------------------------
  91.   def neo_gauge_back_color
  92.     return BACK_GCOLOR_1, BACK_GCOLOR_2, BACK_GCOLOR_3
  93.   end
  94.   #--------------------------------------------------------------------------
  95. if USE_HP_GAUGE
  96.   #--------------------------------------------------------------------------
  97.   # * Draw Actor HP
  98.   #--------------------------------------------------------------------------
  99.   def draw_actor_hp(actor, x, y, width = 124)
  100.     gwidth = width * actor.hp / actor.mhp
  101.     cg = neo_gauge_back_color
  102.     c1, c2, c3 = cg[0], cg[1], cg[2]
  103.     draw_neo_gauge(x + HPMP_GAUGE_X_PLUS, y + line_height - 8 +
  104.       HPMP_GAUGE_Y_PLUS, width, HPMP_GAUGE_HEIGHT, c1, c2, c3)
  105.     (1..3).each {|i| eval("c#{i} = HP_GCOLOR_#{i}")}
  106.     draw_neo_gauge(x + HPMP_GAUGE_X_PLUS, y + line_height - 8 +
  107.       HPMP_GAUGE_Y_PLUS, gwidth, HPMP_GAUGE_HEIGHT, c1, c2, c3, false, false,
  108.       width, 30)
  109.     change_color(system_color)
  110.     draw_text(x, y, 30, line_height, Vocab::hp_a)
  111.     draw_current_and_max_values(x, y, width, actor.hp, actor.mhp,
  112.       hp_color(actor), normal_color)
  113.   end
  114.   #--------------------------------------------------------------------------
  115. end
  116. if USE_MP_GAUGE
  117.   #--------------------------------------------------------------------------
  118.   # * Draw Actor MP
  119.   #--------------------------------------------------------------------------
  120.   def draw_actor_mp(actor, x, y, width = 124)
  121.     gwidth = width * actor.mp / [actor.mmp, 1].max
  122.     cg = neo_gauge_back_color
  123.     c1, c2, c3 = cg[0], cg[1], cg[2]
  124.     draw_neo_gauge(x + HPMP_GAUGE_X_PLUS, y + line_height - 8 +
  125.       HPMP_GAUGE_Y_PLUS, width, HPMP_GAUGE_HEIGHT, c1, c2, c3)
  126.     (1..3).each {|i| eval("c#{i} = MP_GCOLOR_#{i}")}
  127.     draw_neo_gauge(x + HPMP_GAUGE_X_PLUS, y + line_height - 8 +
  128.       HPMP_GAUGE_Y_PLUS, gwidth, HPMP_GAUGE_HEIGHT, c1, c2, c3, false, false,
  129.       width, 40)
  130.     change_color(system_color)
  131.     draw_text(x, y, 30, line_height, Vocab::mp_a)
  132.     draw_current_and_max_values(x, y, width, actor.mp, actor.mmp,
  133.       mp_color(actor), normal_color)
  134.   end
  135.   #--------------------------------------------------------------------------
  136. end
  137. if USE_TP_GAUGE
  138.   #--------------------------------------------------------------------------
  139.   # * Draw Actor TP
  140.   #--------------------------------------------------------------------------
  141.   def draw_actor_tp(actor, x, y, width = 124)
  142.     gwidth = width * actor.tp / 100
  143.     cg = neo_gauge_back_color
  144.     c1, c2, c3 = cg[0], cg[1], cg[2]
  145.     draw_neo_gauge(x + HPMP_GAUGE_X_PLUS, y + line_height - 8 +
  146.       HPMP_GAUGE_Y_PLUS, width, HPMP_GAUGE_HEIGHT, c1, c2, c3)
  147.     (1..3).each {|i| eval("c#{i} = TP_GCOLOR_#{i}")}
  148.     draw_neo_gauge(x + HPMP_GAUGE_X_PLUS, y + line_height - 8 +
  149.       HPMP_GAUGE_Y_PLUS, gwidth, HPMP_GAUGE_HEIGHT, c1, c2, c3, false, false,
  150.       width, 40)
  151.     change_color(system_color)
  152.     draw_text(x, y, 30, line_height, Vocab::tp_a)
  153.     change_color(tp_color(actor))
  154.     draw_text(x + width - 42, y, 42, line_height, actor.tp.to_i, 2)
  155.   end
  156.   #--------------------------------------------------------------------------
  157. end
  158. if USE_STATS_GAUGE
  159.   #--------------------------------------------------------------------------
  160.   # * Draw Actor Stats
  161.   #--------------------------------------------------------------------------
  162.   def draw_actor_param(actor, x, y, param_id)
  163.     param_name = Vocab::param(param_id)
  164.     param_value = actor.param(param_id)
  165.     param_max = actor.neo_param_max(param_id)
  166.     width = 156
  167.     gwidth = width * param_value / [param_max, 1].max
  168.     cg = neo_gauge_back_color
  169.     draw_neo_gauge(x + HPMP_GAUGE_X_PLUS, y + line_height - 8 +
  170.       HPMP_GAUGE_Y_PLUS, width, HPMP_GAUGE_HEIGHT, cg[0], cg[1], cg[2])
  171.     c1, c2, c3 = STAT_GCOLOR_1, STAT_GCOLOR_2, STAT_GCOLOR_3
  172.     draw_neo_gauge(x + HPMP_GAUGE_X_PLUS, y + line_height - 8 +
  173.       HPMP_GAUGE_Y_PLUS, gwidth, HPMP_GAUGE_HEIGHT, c1, c2, c3, false, false,
  174.       width, 40)
  175.     change_color(system_color)
  176.     draw_text(x, y, 120, line_height, param_name)
  177.     change_color(normal_color)
  178.     draw_text(x + 120, y, 36, line_height, param_value, 2)
  179.   end
  180.   #--------------------------------------------------------------------------
  181. end
  182.   #--------------------------------------------------------------------------
  183.   # * Draw Neo Gauge
  184.   #     c1, c2, c3  : 3 Colours in the gradient
  185.   #     vert  : Whether the gauge is vertical or not.
  186.   #     outline   : Draw an outline of the gauge?
  187.   #     max_width : Maximum width the gauge can reach.
  188.   #     c2_spot   : Point where the second colour is drawn.
  189.   #--------------------------------------------------------------------------
  190.   def draw_neo_gauge(x, y, width, height, c1, c2, c3, vert = false,
  191.       outline = true, max_width = nil, c2_spot = 50)  
  192.     if max_width.nil? # Get Max Width
  193.       max_width = vert ? height : width
  194.     end
  195.     glow = GAUGE_GLOW_EFFECT
  196.     dx = x; dy = y
  197.     x = y = 0
  198.     bitmap = Bitmap.new(max_width, height)
  199.     if glow # If drawing glow
  200.       if outline  # If drawing outline
  201.         if vert; rect = Rect.new(x, y, width, max_width)  # Make vertical gauge
  202.         else; rect = Rect.new(x, y, max_width, height)  # Make horizontal gauge
  203.         end
  204.         bitmap.fill_rect(rect, GAUGE_GLOW_COLOR)  # Make glow
  205.         bitmap.neo_clear_corner(rect.x, rect.y, rect.width, rect.height) # Clear
  206.       else  # No outline
  207.         height -= 2; width -= 2; x += 1; y += 1
  208.         if GAUGE_INSIDE_BORDER
  209.           height -= 2; width -= 2; x += 1; y += 1
  210.         end
  211.       end
  212.     end
  213.   #--------------------------------------------------------------------------
  214.   # I'm not going to comment every line. There's a lot of stuff here. It may
  215.   # look daunting, but it's actually not that diffciult to get your head
  216.   # around. If you really want to figure this all out, just look at it a lot.
  217.   # Failing that, you could probably just ask a more experienced scripter or
  218.   # myself.
  219.   #--------------------------------------------------------------------------
  220.     if vert
  221.       if glow; gx = gx2 = x + 1; gy = y
  222.       else; gx = gx2 = x; gy = y
  223.       end
  224.       gy2 = gy - 1 + ((c2_spot * max_width) / 100)
  225.       gw = gw2 = width - 2; gh = ((c2_spot * max_width) / 100)
  226.       gh2 = max_width - gh - 2
  227.       bitmap.gradient_fill_rect(gx, gy, gw, gh, c1, c2, true)
  228.       bitmap.gradient_fill_rect(gx2, gy2, gw2, gh2, c2, c3, true)
  229.       gh = (gh + gh2)
  230.     else
  231.       if glow; gx = x; gy = gy2 = y
  232.         gx = x + 1; gy = gy2 = y + 1
  233.       else; gx = x; gy = gy2 = y
  234.       end
  235.       gx2 = gx - 1 + ((c2_spot *  max_width) / 100)
  236.       gw = ((c2_spot * max_width) / 100); gh = gh2 = (height - 2)
  237.       gw2 = max_width - gw - 2
  238.       bitmap.gradient_fill_rect(gx, gy, gw, gh, c1, c2)
  239.       bitmap.gradient_fill_rect(gx2, gy2, gw2, gh2, c2, c3)
  240.       gw = (gw + gw2)
  241.     end
  242.     if outline
  243.       if GAUGE_OUTSIDE_BORDER
  244.         bitmap.draw_neo_border(gx, gy, gw, gh, GAUGE_OUTSIDE_BORDER_COLOR,
  245.           GAUGE_OUTSIDE_BORDER_COLOR2)
  246.         if GAUGE_CLEAR_CORNER_OUTSIDE_BORDER
  247.           bitmap.neo_clear_corner(gx, gy, gw, gh)
  248.         end
  249.       end
  250.       if GAUGE_INSIDE_BORDER
  251.         gx += 1; gy += 1; gw -= 2; gh -= 2
  252.         bitmap.draw_neo_border(gx, gy, gw, gh, GAUGE_INSIDE_BORDER_COLOR,
  253.           GAUGE_INSIDE_BORDER_COLOR2)
  254.       end
  255.     end
  256.     rect = Rect.new(0, 0, width, bitmap.height)
  257.     self.contents.blt(dx, dy, bitmap, rect)
  258.     bitmap.dispose
  259.   end
  260. end
  261.  
  262. #==============================================================================
  263. # ■ Bitmap
  264. #------------------------------------------------------------------------------
  265. #  かわいいですね。
  266. #==============================================================================
  267.  
  268. class Bitmap
  269.   #--------------------------------------------------------------------------
  270.   # * Draw border of Neo Gauge
  271.   #--------------------------------------------------------------------------
  272.   def draw_neo_border(x, y, width, height, color, color2 = color, size = 1)
  273.     gradient_fill_rect(x, y, width, size, color, color2)
  274.     fill_rect(x, y, size, height, color)
  275.     fill_rect(x + width - size, y, size, height, color2)
  276.     gradient_fill_rect(x, y + height - size, width, size, color, color2)
  277.   end
  278.   #--------------------------------------------------------------------------
  279.   # * Clear Corner of Neo Gauge
  280.   #--------------------------------------------------------------------------
  281.   def neo_clear_corner(x, y, width, height, size = 1)
  282.     clear_rect(x, y, size, size)
  283.     clear_rect(x + width - size, y, size, size)
  284.     clear_rect(x, y + height - size, size, size)
  285.     clear_rect(x + width - size, y + height - size, size, size)
  286.   end
  287. end
  288.  
  289. #==============================================================================
  290. # ■ Game_Battler
  291. #------------------------------------------------------------------------------
  292. #  スプライトや行動に関するメソッドを追加したバトラーのクラスです。このクラス
  293. # は Game_Actor クラスと Game_Enemy クラスのスーパークラスとして使用されます。
  294. #==============================================================================
  295.  
  296. class Game_Battler < Game_BattlerBase
  297.   #--------------------------------------------------------------------------
  298.   # * Get class (simpler method)
  299.   #--------------------------------------------------------------------------
  300.   def klass
  301.     self.class if self.is_a?(Game_Actor)
  302.   end
  303.   #--------------------------------------------------------------------------
  304.   # * Get Neo Parameter Max
  305.   #--------------------------------------------------------------------------
  306.   def neo_param_max(param_id)
  307.     case param_id
  308.     when 2; maxatk
  309.     when 3; maxdef
  310.     when 4; maxspi
  311.     when 5; maxmdef
  312.     when 6; maxagi
  313.     when 7; maxluk
  314.     end
  315.   end
  316.   #--------------------------------------------------------------------------
  317.   # * Max attack
  318.   #--------------------------------------------------------------------------
  319.   def maxatk
  320.     n = atk
  321.     if self.is_a?(Game_Actor)
  322.       n = n - klass.params[2, @level] + klass.params[2, 99]
  323.     end
  324.     return n
  325.   end
  326.   #--------------------------------------------------------------------------
  327.   # * Max defense
  328.   #--------------------------------------------------------------------------
  329.   def maxdef
  330.     n = atk
  331.     if self.is_a?(Game_Actor)
  332.       n = n - klass.params[3, @level] + klass.params[3, 99]
  333.     end
  334.     return n
  335.   end
  336.   #--------------------------------------------------------------------------
  337.   # * Max magic
  338.   #--------------------------------------------------------------------------
  339.   def maxspi
  340.     n = atk
  341.     if self.is_a?(Game_Actor)
  342.       n = n - klass.params[4, @level] + klass.params[4, 99]
  343.     end
  344.     return n
  345.   end
  346.   #--------------------------------------------------------------------------
  347.   # * Max magic defense
  348.   #--------------------------------------------------------------------------
  349.   def maxmdef
  350.     n = atk
  351.     if self.is_a?(Game_Actor)
  352.       n = n - klass.params[5, @level] + klass.params[5, 99]
  353.     end
  354.     return n
  355.   end
  356.   #--------------------------------------------------------------------------
  357.   # * Max agility
  358.   #--------------------------------------------------------------------------
  359.   def maxagi
  360.     n = atk
  361.     if self.is_a?(Game_Actor)
  362.       n = n - klass.params[6, @level] + klass.params[6, 99]
  363.     end
  364.     return n
  365.   end
  366.   #--------------------------------------------------------------------------
  367.   # * Max luck
  368.   #--------------------------------------------------------------------------
  369.   def maxluk
  370.     n = atk
  371.     if self.is_a?(Game_Actor)
  372.       n = n - klass.params[7, @level] + klass.params[7, 99]
  373.     end
  374.     return n
  375.   end
  376. end
  377.  
  378. $imported ||= {}
  379. $imported[:neo_gauge_ultimate]
  380.  
  381. #===============================================================================
  382. #
  383. # END OF SCRIPT
  384. #
  385. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement