Advertisement
JaxxLTiming

JLT Infamy System v1.00

Jul 21st, 2013
442
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 17.13 KB | None | 0 0
  1. #=========================================================================
  2. #                     JLT Ace Infamy System v1.00
  3. #                     Author: JLT (Jaxx L. Timing)
  4. #                     Version Date: 7/21/2013 (v1.00)
  5. #=========================================================================
  6. # Description:
  7. #     This script enables you to use an infamy system in your projects.
  8. #     You can set an initial infamy value as well as add or subtract from
  9. #     a character's infamy through script calls. Most aspects of the system
  10. #     are customizable.
  11. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  12. # Instructions:
  13. #     Download http://postimg.org/image/obdosejb7/ and insert it into your game's
  14. #     Graphics/System folder. Open your resource manager and import the new icons.
  15. #     Place this script below materials and above main and you are good to go.
  16. #
  17. #     - To add or subtract from a characters alignment points use a script call
  18. #       $game_actors[actor_id].infamy += number  - to add points
  19. #       $game_actors[actor_id].infamy -= number  - to remove points
  20. #
  21. #     - To set an actor's inital alignment enter <Initial_Infamy: number>
  22. #       into the actor's note box, by default, actors start with 0 infamy.
  23. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  24. module JLT_Infamy_Settings
  25. #~ -------------------------------------------------------------------------------------------
  26. #~ -------------------------------------------------------------------------------------------
  27. #~ -------------------------------------------------------------------------------------------
  28. #~ -------------------------------------------------------------------------------------------
  29.   #--------------------------------------------------------------------------------------------
  30.   # * Customize the appearence of the infamy bar below.
  31.   #--------------------------------------------------------------------------------------------
  32. #~ -------------------------------------------------------------------------------------------
  33. #~ -------------------------------------------------------------------------------------------
  34. #~ -------------------------------------------------------------------------------------------
  35. #~ -------------------------------------------------------------------------------------------
  36.   MAX_INFAMY = 100  # Change the scale of your infamy gauge,
  37.                     # by default it is on a scale of 0 to 100.
  38.                     # There's no real reason to change this, but you can if you want.
  39.                    
  40.   INFAMY_TEXT_COLOR = 0 # color id
  41.   VOCAB_INFAMY = "Infamy"
  42.  
  43.   SHOW_MODE_TEXT = true
  44.   INFAMY_MODES = ["CLEAR", "CAUTION", "DANGER", "WANTED"]
  45.   INFAMY_MODE_NAME_COLORS = [0, 0, 0, 0]
  46.   SHOW_MODE_ICONS = true
  47.   INFAMY_MODES_ICONS = [0, 0, 534, 533]
  48.   # Choose the names of your modes, the final mode will only show when the gauge is full.
  49.   # This applies even if you change the mode weight below.
  50.  
  51.   SHOW_LARGE_MAX_INFAMY_TEXT = true
  52.   MAX_INFAMY_TEXT = "WANTED"
  53.   MAX_INFAMY_TEXT_COLOR = 18
  54.  
  55.   INFAMY_MODE_WEIGHTS = [45, 75, 90, 100]
  56.   # Explaination: Say you only want the mode right before the final one
  57.   # to show up when the bar is 95% full, set that mode's weight to 95.
  58.   # !!! Mode weight is calculated in percents !!!
  59.   # !!! Even if you change Max_Infamy to be higher/lower these numbers should be between 1 - 100 !!!
  60.  
  61.   INFAMY_MODE_COLORS = [8, 0, 0, 14, 14, 17, 2, 18]
  62.   # Change the gauge gradient for various modes.
  63.   # The array is set up like so:
  64.   #           [first mode_left color, first mode_right color, second mode_left color, etc...]
  65.  
  66. #~ -------------------------------------------------------------------------------------------
  67. #~ -------------------------------------------------------------------------------------------
  68. #~ -------------------------------------------------------------------------------------------
  69. #~ -------------------------------------------------------------------------------------------
  70.   #--------------------------------------------------------------------------------------------
  71.   # * End of customization settings, do not edit below here unless you know what you're doing.
  72.   #--------------------------------------------------------------------------------------------
  73. #~ -------------------------------------------------------------------------------------------
  74. #~ -------------------------------------------------------------------------------------------
  75. #~ -------------------------------------------------------------------------------------------
  76. #~ -------------------------------------------------------------------------------------------
  77. end
  78.  
  79. include JLT_Infamy_Settings
  80. #==============================================================================
  81. # ** Window_MenuStatus
  82. #------------------------------------------------------------------------------
  83. #  This window displays party member status on the menu screen.
  84. #==============================================================================
  85.  
  86. class Window_MenuStatus
  87. #============================================================================
  88.   #--------------------------------------------------------------------------
  89.   # * alias: Draw Item
  90.   #--------------------------------------------------------------------------
  91.  
  92.   alias jlt_window_menustatus_infamy_sui89    draw_item
  93.   def draw_item(index)
  94.     jlt_window_menustatus_infamy_sui89(index)
  95.     actor = $game_party.members[index]
  96.     enabled = $game_party.battle_members.include?(actor)
  97.     rect = item_rect(index)
  98.     draw_infamy_bar(actor, rect.x + 1, rect.y + 1)
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # * new: Draw Infamy Info
  102.   #--------------------------------------------------------------------------
  103.  
  104.   def draw_infamy_bar(actor, x, y)
  105.     gauge_rate = infamy_value(actor, MAX_INFAMY)
  106.     width = 96
  107.     height = 10
  108.     draw_infamy_gauge(x, y + 70, width, height, gauge_rate, text_color(get_infamy_gauge_color(x, y, actor, INFAMY_MODE_WEIGHTS, INFAMY_MODE_COLORS, "left")), text_color(get_infamy_gauge_color(x, y, actor, INFAMY_MODE_WEIGHTS, INFAMY_MODE_COLORS, "right")))
  109.     make_font_smaller
  110.     change_color(text_color(INFAMY_TEXT_COLOR))
  111.     draw_text(x + 1, y + 75, width, line_height, VOCAB_INFAMY)
  112.     normal_color
  113.     make_font_bigger
  114.     if SHOW_MODE_TEXT
  115.       draw_infamy_mode_text(x, y, get_infamy_mode_text_color(actor, INFAMY_MODE_WEIGHTS))
  116.     end
  117.     if SHOW_MODE_ICONS
  118.       draw_infamy_icons(actor, x, y)
  119.     end
  120.     if SHOW_LARGE_MAX_INFAMY_TEXT && infamy_value(actor, MAX_INFAMY) == 1
  121.       word_buffer = 96 - INFAMY_MODES[INFAMY_MODES.size - 1].size * 14.5
  122.       make_font_bigger
  123.       change_color(text_color(MAX_INFAMY_TEXT_COLOR))
  124.       draw_text(x + word_buffer, y + 45, width, line_height * 2, MAX_INFAMY_TEXT)
  125.       make_font_smaller
  126.     end
  127.   end
  128.   #--------------------------------------------------------------------------
  129.   # * new: Draw Infamy Gauge
  130.   #--------------------------------------------------------------------------
  131.  
  132.   def draw_infamy_gauge(x, y, width, height, rate, color1, color2)
  133.     fill_w = (width * rate).to_i
  134.     gauge_y = y + line_height - 8
  135.     contents.fill_rect(x, gauge_y, width, height, gauge_back_color)
  136.     contents.gradient_fill_rect(x + 1, gauge_y + 1, fill_w-2, height-2, color1, color2)
  137.   end
  138.   #--------------------------------------------------------------------------
  139.   # * new: Retrieve Infamy
  140.   #--------------------------------------------------------------------------
  141.  
  142.   def infamy_value(actor, max_infamy)
  143.     infamous_value = $game_actors[actor.id].infamy.to_f / max_infamy
  144.     if infamous_value > 1
  145.       infamous_value = 1
  146.     end
  147.     if infamous_value < 0
  148.       infamous_value = 0
  149.     end
  150.     return infamous_value
  151.   end
  152.   #--------------------------------------------------------------------------
  153.   # * new: Retrieve Gauge Color
  154.   #--------------------------------------------------------------------------
  155.  
  156.   def get_infamy_gauge_color(x, y, actor, infamy_weight, infamy_mode_colors, left_or_right)
  157.     counter = infamy_weight.size
  158.     size = counter - 1
  159.     while counter > 0
  160.       if $game_actors[actor.id].infamy.to_f >= infamy_weight[size]
  161.         draw_infamy_mode_text(x, y, size)
  162.         size = size * 2
  163.         if left_or_right == "right"
  164.           size = size + 1
  165.         end
  166.         return infamy_mode_colors[size]
  167.       end
  168.       counter = counter - 1
  169.       size = size - 1
  170.     end
  171.     if $game_actors[actor.id].infamy.to_f <= infamy_weight[0]
  172.       draw_infamy_mode_text(x, y, 0)
  173.       infamy_color_id = infamy_mode_colors[1]
  174.       if left_or_right == "left"
  175.         infamy_color_id = infamy_mode_colors[0]
  176.       end
  177.     end
  178.     return infamy_color_id
  179.   end
  180.   #--------------------------------------------------------------------------
  181.   # * new: Retrieve Gauge Color
  182.   #--------------------------------------------------------------------------
  183.  
  184.   def get_infamy_mode_text_color(actor, infamy_weight)
  185.     counter = infamy_weight.size
  186.     size = counter - 1
  187.     while counter > 0
  188.       if $game_actors[actor.id].infamy.to_f >= infamy_weight[size]
  189.         return size
  190.       end
  191.       counter = counter - 1
  192.       size = size - 1
  193.     end
  194.     if $game_actors[actor.id].infamy.to_f <= infamy_weight[0]
  195.       return 0
  196.     end
  197.   end
  198.   #--------------------------------------------------------------------------
  199.   # *new: Infamy Mode Text
  200.   #--------------------------------------------------------------------------
  201.  
  202.   def draw_infamy_mode_text(x, y, size)
  203.     buffer = 96 - (5 * INFAMY_MODES[size].size)
  204.     contents.font.size -= 12
  205.     change_color(text_color(INFAMY_MODE_NAME_COLORS[size]))
  206.     draw_text(x + buffer, y + 80, width, line_height, INFAMY_MODES[size])
  207.     normal_color
  208.     contents.font.size += 12
  209.   end
  210.   #--------------------------------------------------------------------------
  211.   # * new: Draw Infamy Icons
  212.   #     enabled : Enabled flag. When false, draw semi-transparently.
  213.   #--------------------------------------------------------------------------
  214.  
  215.   def draw_infamy_icons(actor, x, y)
  216.     draw_icon(INFAMY_MODES_ICONS[get_infamy_mode_text_color(actor, INFAMY_MODE_WEIGHTS)], x + 75, y, enabled = true)
  217.   end
  218. #============================================================================
  219. end
  220.  
  221. #==============================================================================
  222. # ** Game_Actor
  223. #------------------------------------------------------------------------------
  224. #  This class handles actors. It is used within the Game_Actors class
  225. # ($game_actors) and is also referenced from the Game_Party class ($game_party).
  226. #==============================================================================
  227.  
  228. class Game_Actor < Game_Battler
  229. #============================================================================
  230.   #--------------------------------------------------------------------------
  231.   # * Public Instance Variables
  232.   #--------------------------------------------------------------------------
  233.   attr_accessor :infamy
  234.   #--------------------------------------------------------------------------
  235.   # alias: Actor Setup
  236.   #--------------------------------------------------------------------------
  237.  
  238.   alias jlt_game_actor_setup_infamy_jksef6734    setup
  239.   def setup(actor_id)
  240.     @infamy = 0
  241.     @pre_infamy = $data_actors[actor_id].note[/<Initial_Infamy:*\s*(\W\d+)>/im]
  242.     if $1 && $1 != ""; @infamy = $1.to_i; end
  243.     jlt_game_actor_setup_infamy_jksef6734(actor_id)
  244.   end
  245. #============================================================================
  246. end
  247.  
  248. #==============================================================================
  249. # ** Window_Status
  250. #------------------------------------------------------------------------------
  251. #  This window displays full status specs on the status screen.
  252. #==============================================================================
  253.  
  254. class Window_Status < Window_Selectable
  255. #============================================================================
  256.   #--------------------------------------------------------------------------
  257.   # * Refresh
  258.   #--------------------------------------------------------------------------
  259.  
  260.   alias jlt_window_status_refresh_infamy_gauge_njfs76   refresh
  261.   def refresh
  262.     jlt_window_status_refresh_infamy_gauge_njfs76
  263.     draw_infamy_bar(@actor, x + 8, y + 49)
  264.   end
  265.     #--------------------------------------------------------------------------
  266.   # * new: Draw Infamy Info
  267.   #--------------------------------------------------------------------------
  268.  
  269.   def draw_infamy_bar(actor, x, y)
  270.     gauge_rate = infamy_value(actor, MAX_INFAMY)
  271.     width = 96
  272.     height = 10
  273.     draw_infamy_gauge(x, y + 70, width, height, gauge_rate, text_color(get_infamy_gauge_color(x, y, actor, INFAMY_MODE_WEIGHTS, INFAMY_MODE_COLORS, "left")), text_color(get_infamy_gauge_color(x, y, actor, INFAMY_MODE_WEIGHTS, INFAMY_MODE_COLORS, "right")))
  274.     make_font_smaller
  275.     change_color(text_color(INFAMY_TEXT_COLOR))
  276.     draw_text(x + 1, y + 75, width, line_height, VOCAB_INFAMY)
  277.     normal_color
  278.     make_font_bigger
  279.     if SHOW_MODE_TEXT
  280.       draw_infamy_mode_text(x, y, get_infamy_mode_text_color(actor, INFAMY_MODE_WEIGHTS))
  281.     end
  282.     if SHOW_MODE_ICONS
  283.       draw_infamy_icons(actor, x, y)
  284.     end
  285.     if SHOW_LARGE_MAX_INFAMY_TEXT && infamy_value(actor, MAX_INFAMY) == 1
  286.       word_buffer = 96 - INFAMY_MODES[INFAMY_MODES.size - 1].size * 14.5
  287.       make_font_bigger
  288.       change_color(text_color(MAX_INFAMY_TEXT_COLOR))
  289.       draw_text(x + word_buffer, y + 45, width, line_height * 2, INFAMY_MODES[INFAMY_MODES.size - 1])
  290.       make_font_smaller
  291.     end
  292.   end
  293.   #--------------------------------------------------------------------------
  294.   # * new: Draw Infamy Gauge
  295.   #--------------------------------------------------------------------------
  296.  
  297.   def draw_infamy_gauge(x, y, width, height, rate, color1, color2)
  298.     fill_w = (width * rate).to_i
  299.     gauge_y = y + line_height - 8
  300.     contents.fill_rect(x, gauge_y, width, height, gauge_back_color)
  301.     contents.gradient_fill_rect(x + 1, gauge_y + 1, fill_w-2, height-2, color1, color2)
  302.   end
  303.   #--------------------------------------------------------------------------
  304.   # * new: Retrieve Infamy
  305.   #--------------------------------------------------------------------------
  306.  
  307.   def infamy_value(actor, max_infamy)
  308.     infamous_value = $game_actors[actor.id].infamy.to_f / max_infamy
  309.     if infamous_value > 1
  310.       infamous_value = 1
  311.     end
  312.     if infamous_value < 0
  313.       infamous_value = 0
  314.     end
  315.     return infamous_value
  316.   end
  317.   #--------------------------------------------------------------------------
  318.   # * new: Retrieve Gauge Color
  319.   #--------------------------------------------------------------------------
  320.  
  321.   def get_infamy_gauge_color(x, y, actor, infamy_weight, infamy_mode_colors, left_or_right)
  322.     counter = infamy_weight.size
  323.     size = counter - 1
  324.     while counter > 0
  325.       if $game_actors[actor.id].infamy.to_f >= infamy_weight[size]
  326.         draw_infamy_mode_text(x, y, size)
  327.         size = size * 2
  328.         if left_or_right == "right"
  329.           size = size + 1
  330.         end
  331.         return infamy_mode_colors[size]
  332.       end
  333.       counter = counter - 1
  334.       size = size - 1
  335.     end
  336.     if $game_actors[actor.id].infamy.to_f <= infamy_weight[0]
  337.       draw_infamy_mode_text(x, y, 0)
  338.       infamy_color_id = infamy_mode_colors[1]
  339.       if left_or_right == "left"
  340.         infamy_color_id = infamy_mode_colors[0]
  341.       end
  342.     end
  343.     return infamy_color_id
  344.   end
  345.   #--------------------------------------------------------------------------
  346.   # * new: Retrieve Gauge Color
  347.   #--------------------------------------------------------------------------
  348.  
  349.   def get_infamy_mode_text_color(actor, infamy_weight)
  350.     counter = infamy_weight.size
  351.     size = counter - 1
  352.     while counter > 0
  353.       if $game_actors[actor.id].infamy.to_f >= infamy_weight[size]
  354.         return size
  355.       end
  356.       counter = counter - 1
  357.       size = size - 1
  358.     end
  359.     if $game_actors[actor.id].infamy.to_f <= infamy_weight[0]
  360.       return 0
  361.     end
  362.   end
  363.   #--------------------------------------------------------------------------
  364.   # *new: Infamy Mode Text
  365.   #--------------------------------------------------------------------------
  366.  
  367.   def draw_infamy_mode_text(x, y, size)
  368.     buffer = 96 - (5 * INFAMY_MODES[size].size)
  369.     contents.font.size -= 12
  370.     change_color(text_color(INFAMY_MODE_NAME_COLORS[size]))
  371.     draw_text(x + buffer, y + 80, width, line_height, INFAMY_MODES[size])
  372.     normal_color
  373.     contents.font.size += 12
  374.   end
  375.   #--------------------------------------------------------------------------
  376.   # * new: Draw Infamy Icons
  377.   #     enabled : Enabled flag. When false, draw semi-transparently.
  378.   #--------------------------------------------------------------------------
  379.  
  380.   def draw_infamy_icons(actor, x, y)
  381.     draw_icon(INFAMY_MODES_ICONS[get_infamy_mode_text_color(actor, INFAMY_MODE_WEIGHTS)], x + 75, y, enabled = true)
  382.   end
  383. #============================================================================
  384. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement