Advertisement
JaxxLTiming

JLT Ace Actor Alignment System v1.00

Jul 21st, 2013
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 18.71 KB | None | 0 0
  1. #=========================================================================
  2. #                     JLT Ace Actor Alignment 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 assign your actors an "alignment" between
  8. #     good and evil or however you choose to define it. You can set an initial
  9. #     alignment as well as add or subtract from the alignment variable through
  10. #     script calls.
  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].alignment += number  - to add points
  19. #       $game_actors[actor_id].alignment -= number  - to remove points
  20. #
  21. #     - To set an actor's initial alignment enter <Initial_Align: number>
  22. #       into the actor's notebox, all actors are neutral, or '0,' alignment by default.
  23. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  24. #~ ------------------------------------------------------------------------------------
  25. #~ ------------------------------------------------------------------------------------
  26. #~ ------------------------------------------------------------------------------------
  27. #~ ------------------------------------------------------------------------------------
  28.   #--------------------------------------------------------------------------
  29.   # * Customize the appearence of the alignment bar below.
  30.   #--------------------------------------------------------------------------
  31. #~ ------------------------------------------------------------------------------------
  32. #~ ------------------------------------------------------------------------------------
  33. #~ ------------------------------------------------------------------------------------
  34. #~ ------------------------------------------------------------------------------------
  35.  
  36. module JLT_Alignment_Settings
  37.  
  38.   VOCAB_ALIGNMENT = "ALIGNMENT"
  39.   ALIGNMENT_TEXT_COLOR = 0
  40.   # Choose the term that is displayed next to the bar.
  41.   # I wouldn't recommend making this term more than 9-10 characters long, it will squish the bar a lot.
  42.  
  43.   MAX = 100  # Change the upper and lower bounds of the bar.
  44.   # For example, if you set this to 100, the lowest alignment will be -100 and the maximum will be 100.
  45.  
  46.   ALIGNMENT_LIST          = ["Pure Evil", "Evil", "Bad", "Neutral", "Good", "Saint", "Divine"]
  47.   ALIGNMENT_LIST_COLORS   = [         18,     10,     2,         8,     14,       6,        0]
  48.   # The end slots of the array define what the alignment is if it exceeds your set maximum or minimum value.
  49.   # What this means is that your actor will not become, for example, "Divine" or "Pure Evil" unless his alignment
  50.   #   goes above 100, if your MAX = 100, or dips below -100.
  51.  
  52.   # Add as many alignments as you like as long as there are an odd number.
  53.   # List the colors you want each alignment text to be, make sure the positions in the arrays match.
  54.  
  55.   SLIDER_ICON = 529     # Choose icon to use as a slider over the bar.
  56.   GAUGE_COLOR_1 = 8    # Choose left-most color on bar.
  57.   GAUGE_COLOR_2 = 0     # Choose right-most color on bar.
  58.  
  59.   USE_LEFT_BOUND_ICON = true    # To turn on the left boundary icon, set to true.
  60.   LEFT_BOUND_ICON = 531         # Choose the icon for the left boundary of the bar.
  61.   USE_RIGHT_BOUND_ICON = true   # To turn on the right boundary icon, set to true.
  62.   RIGHT_BOUND_ICON = 532        # Choose the icon for the right boundary of the bar.
  63.   USE_INCREMENT_ICON = true     # To turn on increment icons, set to true.
  64.   INCREMENT_ICON = 530          # Choose the icon for the the incrememnts of the bar.
  65.  
  66. end
  67. #~ ------------------------------------------------------------------------------------
  68. #~ ------------------------------------------------------------------------------------
  69. #~ ------------------------------------------------------------------------------------
  70. #~ ------------------------------------------------------------------------------------
  71.   #--------------------------------------------------------------------------
  72.   # * End of customization settings, do not edit below here unless you know what you're doing.
  73.   #--------------------------------------------------------------------------
  74. #~ ------------------------------------------------------------------------------------
  75. #~ ------------------------------------------------------------------------------------
  76. #~ ------------------------------------------------------------------------------------
  77. #~ ------------------------------------------------------------------------------------
  78.  
  79. include JLT_Alignment_Settings
  80.  
  81. class Window_MenuStatus
  82.   #--------------------------------------------------------------------------
  83.   # alias: Draw Simple Status
  84.   #--------------------------------------------------------------------------
  85.   alias jlt_draw_actor_simp_status_alignment_jksdgb   draw_actor_simple_status
  86.   def draw_actor_simple_status(actor, x, y)
  87.     checker = 0
  88.     gauge_length = MAX * 2
  89.     gauge_segments = ALIGNMENT_LIST.size
  90.     gauge_length_per_segment = gauge_length / gauge_segments
  91.     slider_low_x = VOCAB_ALIGNMENT.size * 7.4 - 9
  92.     slider_high_x = 101
  93.     actual_gauge_length = slider_high_x - slider_low_x
  94.     slider_init_x = (slider_high_x - slider_low_x) / 2
  95.     super
  96.     make_font_smaller
  97.     change_color(text_color(ALIGNMENT_TEXT_COLOR), enabled = true)
  98.     draw_text(x, y + line_height * 2.8, width, line_height, VOCAB_ALIGNMENT)
  99.     normal_color
  100.     var1 = $game_actors[actor.id].alignment
  101.     slider_adjust = var1 * 2 * slider_init_x / (MAX * 2)
  102.     draw_gauge(x + VOCAB_ALIGNMENT.size * 7.4, y + line_height * 2.45 + 2, 117 - (VOCAB_ALIGNMENT.size * 7.4), 1.0, text_color(GAUGE_COLOR_1), text_color(GAUGE_COLOR_2))
  103.     draw_left_bound_icon(USE_LEFT_BOUND_ICON, LEFT_BOUND_ICON, x, slider_low_x, y, line_height)
  104.     draw_right_bound_icon(USE_RIGHT_BOUND_ICON, RIGHT_BOUND_ICON, x, slider_high_x, y, line_height)
  105.     draw_increment_icon(ALIGNMENT_LIST, USE_INCREMENT_ICON, INCREMENT_ICON, actual_gauge_length, slider_init_x, x, slider_low_x, y, line_height)
  106.     draw_icon(SLIDER_ICON, x + slider_low_x + slider_init_x + draw_alignment_text(ALIGNMENT_LIST_COLORS, var1, MAX, slider_adjust, x, y, line_height, width, ALIGNMENT_LIST, gauge_length_per_segment, slider_init_x), y + line_height * 2.73 + 2)
  107.     make_font_bigger
  108.     jlt_draw_actor_simp_status_alignment_jksdgb(actor, x, y)
  109.   end
  110.  
  111.   #--------------------------------------------------------------------------
  112.   # new: Calculate Array_ID for any alignment not min, max, or middle
  113.   #--------------------------------------------------------------------------
  114.  
  115.   def calc_alignment(var1, gauge_length_per_segment, max)
  116.     array_id = 0
  117.     segment_overflow_check = 1.5
  118.     condition = segment_overflow_check + gauge_length_per_segment
  119.     while condition < MAX
  120.       condition = segment_overflow_check + gauge_length_per_segment
  121.       segment_overflow_check = segment_overflow_check + gauge_length_per_segment
  122.       if var1 >= segment_overflow_check
  123.         array_id += 1
  124.       end
  125.       if var1 <= -segment_overflow_check
  126.         array_id -= 1
  127.       end
  128.     end
  129.     return array_id
  130.   end
  131.  
  132.   #--------------------------------------------------------------------------
  133.   # new: Draw left boundary icon
  134.   #--------------------------------------------------------------------------
  135.  
  136.   def draw_left_bound_icon(use_left_bound, left_bound_icon, x, slider_low_x, y, line_height)
  137.     if use_left_bound
  138.     draw_icon(left_bound_icon, x + slider_low_x, y + line_height * 2.73 + 2)
  139.     end
  140.     return
  141.   end
  142.  
  143.   #--------------------------------------------------------------------------
  144.   # new: Draw right boundary icon
  145.   #--------------------------------------------------------------------------
  146.  
  147.   def draw_right_bound_icon(use_right_bound, right_bound_icon, x, slider_high_x, y, line_height)
  148.     if use_right_bound
  149.     draw_icon(right_bound_icon, x + slider_high_x + 1, y + line_height * 2.73 + 2)
  150.     end
  151.     return
  152.   end
  153.  
  154.   #--------------------------------------------------------------------------
  155.   # new: Draw increment icons
  156.   #--------------------------------------------------------------------------
  157.  
  158.   def draw_increment_icon(alignment_list, use_increment, increment_icon, actual_gauge_length, slider_init_x, x, slider_low_x, y, line_height)
  159.     if use_increment
  160.       draw_icon(increment_icon, x + slider_low_x + slider_init_x + 1, y + line_height * 2.73 + 2)
  161.       number_of_increments = alignment_list.size / 2
  162.       increment_multiplier = 1
  163.       while number_of_increments > 0
  164.         draw_icon(increment_icon, x + slider_low_x + slider_init_x + 1 + (increment_multiplier * (actual_gauge_length / (alignment_list.size - 1))), y + line_height * 2.73 + 2)
  165.         draw_icon(increment_icon, x + slider_low_x + slider_init_x + 1 - (increment_multiplier * (actual_gauge_length / (alignment_list.size - 1))), y + line_height * 2.73 + 2)
  166.         increment_multiplier = increment_multiplier + 1
  167.         number_of_increments = number_of_increments - 2
  168.       end
  169.     end
  170.     return
  171.   end
  172.  
  173.   #--------------------------------------------------------------------------
  174.   # new: Draw alignment text
  175.   #--------------------------------------------------------------------------
  176.  
  177.   def draw_alignment_text(alignment_list_colors, var1, max, slider_adjust, x, y, line_height, width, alignment_list, gauge_length_per_segment, slider_init_x)
  178.     checker = 0
  179.     if var1 <= -max;
  180.       slider_adjust = 0
  181.       slider_adjust -= slider_init_x
  182.       change_color(text_color(alignment_list_colors[0]), enabled = true)
  183.       draw_text(x + 120, y + line_height * 2.8, width, line_height, alignment_list[0])
  184.       normal_color
  185.       return slider_adjust
  186.     end
  187.     if var1 >= MAX;
  188.       slider_adjust = 0
  189.       slider_adjust += slider_init_x
  190.       change_color(text_color(alignment_list_colors[alignment_list.size - 1]), enabled = true)
  191.       draw_text(x + 120, y + line_height * 2.8, width, line_height, alignment_list[alignment_list.size - 1])
  192.       normal_color
  193.       return slider_adjust
  194.     end
  195.     if var1 < gauge_length_per_segment && var1 > -gauge_length_per_segment
  196.       change_color(text_color(alignment_list_colors[(alignment_list.size - 1) / 2]), enabled = true)
  197.       draw_text(x + 120, y + line_height * 2.8, width, line_height, alignment_list[(alignment_list.size - 1) / 2])
  198.       normal_color
  199.       return slider_adjust
  200.     end
  201.     if checker == 0
  202.       alignment_list_colors
  203.       change_color(text_color(alignment_list_colors[((alignment_list.size - 1) / 2) + calc_alignment(var1, gauge_length_per_segment, max)]), enabled = true)
  204.       draw_text(x + 120, y + line_height * 2.8, width, line_height, alignment_list[((alignment_list.size - 1) / 2) + calc_alignment(var1, gauge_length_per_segment, max)])
  205.       normal_color
  206.       return slider_adjust
  207.     end
  208.   end
  209. end
  210.  
  211. #==============================================================================
  212. # ** Game_Actor
  213. #------------------------------------------------------------------------------
  214. #  This class handles actors. It is used within the Game_Actors class
  215. # ($game_actors) and is also referenced from the Game_Party class ($game_party).
  216. #==============================================================================
  217.  
  218. class Game_Actor < Game_Battler
  219.   #--------------------------------------------------------------------------
  220.   # * Public Instance Variables
  221.   #--------------------------------------------------------------------------
  222.   attr_accessor :alignment
  223.   #--------------------------------------------------------------------------
  224.   # alias: Setup
  225.   #--------------------------------------------------------------------------
  226.   alias jlt_game_actor_setup_66vfgbr    setup
  227.   def setup(actor_id)
  228.       @alignment = 0
  229.     @pre_align = $data_actors[actor_id].note[/<Initial_Align:*\s*(\W\d+)>/im]
  230.     if $1 && $1 != ""; @alignment = $1.to_i; end
  231.     jlt_game_actor_setup_66vfgbr(actor_id)
  232.   end
  233. end
  234.  
  235. #==============================================================================
  236. # ** Window_Status
  237. #------------------------------------------------------------------------------
  238. #  This window displays full status specs on the status screen.
  239. #==============================================================================
  240.  
  241. class Window_Status < Window_Selectable
  242.   #--------------------------------------------------------------------------
  243.   # alias: Draw Block 1
  244.   #--------------------------------------------------------------------------
  245.   alias jlt_draw_block1_add_alignment_8923hdvz    refresh
  246.   def refresh
  247.     jlt_draw_block1_add_alignment_8923hdvz
  248.     checker = 0
  249.     gauge_length = MAX * 2
  250.     gauge_segments = ALIGNMENT_LIST.size
  251.     gauge_length_per_segment = gauge_length / gauge_segments
  252.     slider_low_x = VOCAB_ALIGNMENT.size * 7.4 - 9
  253.     slider_high_x = 101
  254.     actual_gauge_length = slider_high_x - slider_low_x
  255.     slider_init_x = (slider_high_x - slider_low_x) / 2
  256.     make_font_smaller
  257.     change_color(text_color(ALIGNMENT_TEXT_COLOR), enabled = true)
  258.     draw_text(x, y + line_height, width, line_height, VOCAB_ALIGNMENT)
  259.     normal_color
  260.     var1 = $game_actors[@actor.id].alignment
  261.     slider_adjust = var1 * 2 * slider_init_x / (MAX * 2)
  262.     draw_gauge(x + VOCAB_ALIGNMENT.size * 7.4, y + line_height - 7, 117 - (VOCAB_ALIGNMENT.size * 7.4), 1.0, text_color(GAUGE_COLOR_1), text_color(GAUGE_COLOR_2))
  263.     draw_left_bound_icon(USE_LEFT_BOUND_ICON, LEFT_BOUND_ICON, x, slider_low_x, y, line_height)
  264.     draw_right_bound_icon(USE_RIGHT_BOUND_ICON, RIGHT_BOUND_ICON, x, slider_high_x, y, line_height)
  265.     draw_increment_icon(ALIGNMENT_LIST, USE_INCREMENT_ICON, INCREMENT_ICON, actual_gauge_length, slider_init_x, x, slider_low_x, y, line_height)
  266.     draw_icon(SLIDER_ICON, x + slider_low_x + slider_init_x + draw_alignment_text(ALIGNMENT_LIST_COLORS, var1, MAX, slider_adjust, x, y, line_height, width, ALIGNMENT_LIST, gauge_length_per_segment, slider_init_x), y + line_height)
  267.     make_font_bigger
  268.   end
  269.  
  270.   #--------------------------------------------------------------------------
  271.   # new: Calculate Array_ID for any alignment not min, max, or middle
  272.   #--------------------------------------------------------------------------
  273.  
  274.   def calc_alignment(var1, gauge_length_per_segment, max)
  275.     array_id = 0
  276.     segment_overflow_check = 1.5
  277.     condition = segment_overflow_check + gauge_length_per_segment
  278.     while condition < MAX
  279.       condition = segment_overflow_check + gauge_length_per_segment
  280.       segment_overflow_check = segment_overflow_check + gauge_length_per_segment
  281.       if var1 >= segment_overflow_check
  282.         array_id += 1
  283.       end
  284.       if var1 <= -segment_overflow_check
  285.         array_id -= 1
  286.       end
  287.     end
  288.     return array_id
  289.   end
  290.  
  291.   #--------------------------------------------------------------------------
  292.   # new: Draw left boundary icon
  293.   #--------------------------------------------------------------------------
  294.  
  295.   def draw_left_bound_icon(use_left_bound, left_bound_icon, x, slider_low_x, y, line_height)
  296.     if use_left_bound
  297.     draw_icon(left_bound_icon, x + slider_low_x, y + line_height)
  298.     end
  299.     return
  300.   end
  301.  
  302.   #--------------------------------------------------------------------------
  303.   # new: Draw right boundary icon
  304.   #--------------------------------------------------------------------------
  305.  
  306.   def draw_right_bound_icon(use_right_bound, right_bound_icon, x, slider_high_x, y, line_height)
  307.     if use_right_bound
  308.     draw_icon(right_bound_icon, x + slider_high_x + 1, y + line_height)
  309.     end
  310.     return
  311.   end
  312.  
  313.   #--------------------------------------------------------------------------
  314.   # new: Draw increment icons
  315.   #--------------------------------------------------------------------------
  316.  
  317.   def draw_increment_icon(alignment_list, use_increment, increment_icon, actual_gauge_length, slider_init_x, x, slider_low_x, y, line_height)
  318.     if use_increment
  319.       draw_icon(increment_icon, x + slider_low_x + slider_init_x + 1, y + line_height)
  320.       number_of_increments = alignment_list.size / 2
  321.       increment_multiplier = 1
  322.       while number_of_increments > 0
  323.         draw_icon(increment_icon, x + slider_low_x + slider_init_x + 1 + (increment_multiplier * (actual_gauge_length / (alignment_list.size - 1))), y + line_height)
  324.         draw_icon(increment_icon, x + slider_low_x + slider_init_x + 1 - (increment_multiplier * (actual_gauge_length / (alignment_list.size - 1))), y + line_height)
  325.         increment_multiplier = increment_multiplier + 1
  326.         number_of_increments = number_of_increments - 2
  327.       end
  328.     end
  329.     return
  330.   end
  331.  
  332.   #--------------------------------------------------------------------------
  333.   # new: Draw alignment text
  334.   #--------------------------------------------------------------------------
  335.  
  336.   def draw_alignment_text(alignment_list_colors, var1, max, slider_adjust, x, y, line_height, width, alignment_list, gauge_length_per_segment, slider_init_x)
  337.     checker = 0
  338.     if var1 <= -max;
  339.       slider_adjust = 0
  340.       slider_adjust -= slider_init_x
  341.       change_color(text_color(alignment_list_colors[0]), enabled = true)
  342.       draw_text(x + 120, y + line_height, width, line_height, alignment_list[0])
  343.       normal_color
  344.       return slider_adjust
  345.     end
  346.     if var1 >= MAX;
  347.       slider_adjust = 0
  348.       slider_adjust += slider_init_x
  349.       change_color(text_color(alignment_list_colors[alignment_list.size - 1]), enabled = true)
  350.       draw_text(x + 120, y + line_height, width, line_height, alignment_list[alignment_list.size - 1])
  351.       normal_color
  352.       return slider_adjust
  353.     end
  354.     if var1 < gauge_length_per_segment && var1 > -gauge_length_per_segment
  355.       change_color(text_color(alignment_list_colors[(alignment_list.size - 1) / 2]), enabled = true)
  356.       draw_text(x + 120, y + line_height, width, line_height, alignment_list[(alignment_list.size - 1) / 2])
  357.       normal_color
  358.       return slider_adjust
  359.     end
  360.     if checker == 0
  361.       alignment_list_colors
  362.       change_color(text_color(alignment_list_colors[((alignment_list.size - 1) / 2) + calc_alignment(var1, gauge_length_per_segment, max)]), enabled = true)
  363.       draw_text(x + 120, y + line_height, width, line_height, alignment_list[((alignment_list.size - 1) / 2) + calc_alignment(var1, gauge_length_per_segment, max)])
  364.       normal_color
  365.       return slider_adjust
  366.     end
  367.   end
  368. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement