Advertisement
diamondandplatinum3

Morality Gauge Difference ~ RGSS3

Apr 24th, 2013
482
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.25 KB | None | 0 0
  1. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  2. #             Morality Gauge Difference ~ Add-On
  3. #             Author: DiamondandPlatinum3
  4. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5. #  Description:
  6. #
  7. #    This Add-On makes it so that your morality metre now shows the offset
  8. #    between good and evil. The more you align yourself to one type of
  9. #    morality, the further the gauge goes in a certain direction.
  10. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  11. #------------------------------------------------------------------------------
  12. #  Instructions:
  13. #  
  14. #     In the editable region below you can set up what is necessary.
  15. #     Make sure the main morality script is placed anywhere above this
  16. #     Add-On.
  17. #
  18. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  19. module DiamondandPlatinum3
  20.   module MoralityMetre
  21.     #===========================================
  22.     #   Editable Region
  23.     #===========================================
  24.    
  25.     # The GAUGE_WIDTH option in the main morality metre editable region
  26.     # is now obsolete and is no longer used, however the rest of the
  27.     # editable options are still used, so be sure to set them up.
  28.    
  29.     # Values for the colour of the lines that are in between the
  30.     # Good and Evil Gauges
  31.                                 # [ Red,    Green,   Blue,   Opacity  ]
  32.     GAUGE_CENTRE_LINE_COLOUR    = [ 0,       255,     0,       255    ]
  33.     GAUGE_MAX_EVIL_LINE_COLOUR  = [ 100,     0,       0,       255    ]
  34.     GAUGE_MAX_GOOD_LINE_COLOUR  = [ 0,       0,       255,     255    ]
  35.    
  36.     #===========================================
  37.     #   End of Editable Region
  38.     #===========================================
  39.   end
  40. end
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48. #==============================================================================
  49. # ** Window_MoralityMetre
  50. #------------------------------------------------------------------------------
  51. #  Defines the window and its contents
  52. #==============================================================================
  53. class Window_MoralityMetre < Window_Base
  54.   include DiamondandPlatinum3::MoralityMetre
  55.   #--------------------------------------------------------------------------
  56.   # * Refresh
  57.   #--------------------------------------------------------------------------
  58.   def refresh
  59.     contents.clear
  60.     gauge_y_pos = (contents.height - GAUGE_HEIGHT)
  61.    
  62.     # Change Text Colour if 50% Good
  63.     contents.font.out_color = self.get_colour2() if get_should_text_be_outlined?()
  64.    
  65.     # Draw Text
  66.     contents.draw_text( 0, 0, contents.width, 25, self.get_title(), 1 )
  67.    
  68.     # Blur Text if 50% Evil
  69.     contents.blur if get_should_text_be_blured?()
  70.  
  71.     # Draw Morality Gauge
  72.     draw_evil_gauge(gauge_y_pos)
  73.     draw_good_gauge(gauge_y_pos)
  74.    
  75.     # Fix the Alpha channels
  76.     fix_evil_gauge(gauge_y_pos)
  77.     fix_good_gauge(gauge_y_pos)
  78.    
  79.     # Draw Lines
  80.     draw_left_line(gauge_y_pos)
  81.     draw_centre_line(gauge_y_pos)
  82.     draw_right_line(gauge_y_pos)
  83.   end
  84.   #--------------------------------------------------------------------------
  85.   # * Draw Gauge
  86.   #--------------------------------------------------------------------------
  87.   def draw_gauge(x, y, width, rate, color1, color2)
  88.     fill_w = (width * rate).to_i
  89.     gauge_y = y
  90.     contents.fill_rect(x, gauge_y, width, GAUGE_HEIGHT, gauge_back_color)
  91.     contents.gradient_fill_rect(x, gauge_y, fill_w, GAUGE_HEIGHT, color1, color2, true)
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # * Draw Evil Gauge
  95.   #--------------------------------------------------------------------------
  96.   def draw_evil_gauge(y)
  97.     width = (contents.width * 0.5)
  98.     draw_gauge(0, y, width, 1.0, self.get_colour1(), self.get_colour2())
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # * Draw Good Gauge
  102.   #--------------------------------------------------------------------------
  103.   def draw_good_gauge(y)
  104.     width = (contents.width * 0.5)
  105.     x = (contents.width * 0.5)
  106.     draw_gauge(x, y, width, 1.0, self.get_colour1(), self.get_colour2())
  107.   end
  108.   #--------------------------------------------------------------------------
  109.   # * Fix Evil Gauge
  110.   #--------------------------------------------------------------------------
  111.   def fix_evil_gauge(yPos)
  112.     evilness  = $game_variables[MORALITY_VARIABLE_ID].to_f / (MORALITY_VARIABLE_RANGE * 0.5).to_f
  113.     start     = 0
  114.     fin       = (contents.width * 0.5).to_i
  115.    
  116.     for x in 0..fin
  117.       if (x.to_f / fin < evilness)
  118.         for y in yPos..(contents.height)
  119.           # if Pixel is not in range of players evilness level
  120.           # set the alpha of that pixel to zero
  121.           contents.set_pixel(x, y, Color.new(0, 0, 0, 0))
  122.         end
  123.       end
  124.     end
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   # * Fix Good Gauge
  128.   #--------------------------------------------------------------------------
  129.   def fix_good_gauge(yPos)
  130.     goodness  = $game_variables[MORALITY_VARIABLE_ID].to_f / (MORALITY_VARIABLE_RANGE * 0.5).to_f
  131.     start     = (contents.width * 0.5).to_i
  132.     fin       = (contents.width).to_i
  133.    
  134.    
  135.     for x in start..fin
  136.       if (x.to_f / start > goodness)
  137.         for y in yPos..(contents.height)
  138.           contents.set_pixel(x, y, Color.new(0, 0, 0, 0))
  139.         end
  140.       end
  141.     end
  142.   end
  143.   #--------------------------------------------------------------------------
  144.   # * Draw Centre Line
  145.   #--------------------------------------------------------------------------
  146.   def draw_left_line(yPos)    
  147.     for x in 0..1
  148.       for y in yPos..(contents.height)
  149.         contents.set_pixel(x, y, Color.new(*GAUGE_MAX_EVIL_LINE_COLOUR))
  150.       end
  151.     end
  152.   end
  153.   #--------------------------------------------------------------------------
  154.   # * Draw Centre Line
  155.   #--------------------------------------------------------------------------
  156.   def draw_centre_line(yPos)
  157.     xPos = (contents.width * 0.5).to_i
  158.    
  159.     for x in (xPos - 1)..(xPos + 1)
  160.       for y in yPos..(contents.height)
  161.         contents.set_pixel(x, y, Color.new(*GAUGE_CENTRE_LINE_COLOUR))
  162.       end
  163.     end
  164.   end
  165.   #--------------------------------------------------------------------------
  166.   # * Draw Centre Line
  167.   #--------------------------------------------------------------------------
  168.   def draw_right_line(yPos)    
  169.     for x in (contents.width - 2)..(contents.width - 1)
  170.       for y in yPos..(contents.height)
  171.         contents.set_pixel(x, y, Color.new(*GAUGE_MAX_GOOD_LINE_COLOUR))
  172.       end
  173.     end
  174.   end
  175. end
  176.  
  177.  
  178.  
  179. #--------------------------------------------------------------------------
  180. # * Inform User of Non-working Script
  181. #--------------------------------------------------------------------------
  182. msgbox_p("This script has not detected an active version of DiamondandPlatinum3's Morality Metre.",
  183.          "It's possible you are using an outdated version or you have placed this add-on above that script.",
  184.          "If the latter is the case, please put this script in a slot below the Morality Metre Script"
  185.         ) unless ($diamondandplatinum3_scripts ||= {})[:MoralityMetre_Ver20]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement