Alignment system

Introduction


This script adds a simple and easy-to-use alignment system to your game. This will allow the charcter to be good, evil, or anything in-between. You can even change it up from alignment to other stuff like Rank or Vampirism.


Features


- Adds Alignment
- Easy to add/subtract points
- Easy to make new alignment names
- Adds alignment name in status menu
- You can add tags to equipment/skills to require a certain alignment condition


Screenshots


Content Hidden Spoiler
Image


How To Use


Content Hidden Spoiler
The alignment name and value match to the corresponding one in the other array.

EX: In the default, "Very Evil" is the first name, and -100 is the first condition

This means, if -100 or lower is the value of $game_system.alignment, the
character will be "Very Evil".
--------------------------------------------------------------------------------
How to change alignment: We have 2 command to change alignment points.

sub_alignment(points) and add_alignment(points)

In both commands, replace "points" with the amount of change you want in the
character's alignment points.

sub_alignment will subtract the amount of points.
add_alignment will add the amount of points


Script


  1. #===============================================================================
  2. # Alignment System V.2
  3. # By Jet10985
  4. # Help by: Crimsonseas, Piejamas, Originalwij, Yanfly, Mithran
  5. # Inspired by: Synthesis
  6. #===============================================================================
  7. # This script is not open for distribution to other sites without permission
  8. # from me, Jet10985. Please credit me if you use this script.
  9. #===============================================================================
  10. # This script will allow you to add a nice alignment system to your game, which
  11. # can be used for more then alignment. EX: Ranks, Vampirism, etc.
  12. # This script has: 5 customization options.
  13. #===============================================================================
  14.  
  15. =begin
  16. The alignment name and value match to the corresponding one in the other array.
  17.  
  18. EX: In the default, "Very Evil" is the first name, and -100 is the first condition
  19.  
  20. This means, if -100 or lower is the value of $game_system.alignment, the
  21. character will be "Very Evil".
  22. --------------------------------------------------------------------------------
  23. How to change alignment: We have 2 command to change alignment points.
  24.  
  25. sub_alignment(points) and add_alignment(points)
  26.  
  27. In both commands, replace "points" with the amount of change you want in the
  28. character's alignment points.
  29.  
  30. sub_alignment will subtract the amount of points.
  31. add_alignment will add the amount of points
  32. --------------------------------------------------------------------------------
  33. Tagging equipment and skills:
  34.  
  35. To tag these in the database to require a certain amount of alignment points,
  36. add the tag
  37.  
  38. <alignment ##>
  39.  
  40. where ## is the number of points required. make sure you keep
  41. the <> because that's actually required.
  42. =end
  43.  
  44. module AlignmentOptions
  45.  
  46.   ALIGNMENT_NAME = ["Very Evil", "Evil", "Neutral", "Good", "Very Good"]
  47.  
  48.   ALIGNMENT_CONDITION = [-100, -50, 0, 50, 100] # What the value of $game_system.alignment
  49.                                                 # needs to be to correspond to the alignment name
  50.                                                
  51.   NAME_OF_ALIGNMENT = "Alignment" # This is what alignment will be called altogether
  52.  
  53.   USE_VARIABLE = false
  54.  
  55.   VARIABLE_ID = 5
  56.  
  57. end # ending module
  58. #===============================================================================
  59. class Game_System
  60.  
  61.   include AlignmentOptions
  62.    
  63.   alias jet5830_initialize initialize
  64.   def initialize
  65.     jet5830_initialize
  66.     @alignment = 0
  67.   end
  68.  
  69.   def alignment
  70.     USE_VARIABLE ? $game_variables[VARIABLE_ID] : @alignment
  71.   end
  72.  
  73.   def alignment=(new_value)
  74.     USE_VARIABLE ? $game_variables[VARIABLE_ID] = new_value : @alignment = new_value
  75.   end
  76. end # ending Game_System addition
  77.  
  78. class Game_Interpreter
  79.  
  80.   def add_alignment(points) # adding easy-to-us command to add alignment points
  81.     $game_system.alignment += points # adding the arguement value from the variable
  82.   end # ending definition
  83.  
  84.   def sub_alignment(points) # adding easy-to-us command to subtract alignment points
  85.     $game_system.alignment -= points # subtracting the arguement value from the variable
  86.   end # ending definition
  87. end # ending addition to Game_Interpreter
  88.  
  89. class Window_Status
  90.  
  91.   include AlignmentOptions # including the options defined in the module AlignmentOptions
  92.  
  93.   alias jet5839_refresh refresh unless $@ # aliasing my new command to avoid compatibility issues
  94.   def refresh
  95.     jet5839_refresh # calls the old method
  96.     self.contents.font.color = system_color # redefines the self contained font color
  97.     self.contents.draw_text(290, 110, 500, 500, NAME_OF_ALIGNMENT + ":") # draws the name of alignment
  98.     self.contents.font.color = normal_color # redefines the self contained font color
  99.     self.contents.draw_text(400, 110, 500, 500, draw_alignment) # draws the alignment name in the window
  100.   end # ending definition alias
  101. end
  102.  
  103. class Window_Base
  104.  
  105.   include AlignmentOptions
  106.  
  107.   def draw_alignment # Definition of Draw_alignment
  108.     if $game_system.alignment <= ALIGNMENT_CONDITION.min
  109.       return ALIGNMENT_NAME.min
  110.     elsif $game_system.alignment >= ALIGNMENT_CONDITION.max
  111.       return ALIGNMENT_NAME.max
  112.     elsif
  113.       for i in 0...ALIGNMENT_CONDITION.size
  114.         if $game_system.alignment < ALIGNMENT_CONDITION[i]
  115.           return ALIGNMENT_NAME[i-1]
  116.         end
  117.       end
  118.     end
  119.   end
  120. end
  121.  
  122. module Jet
  123.     def self.get_note(obj, tag)
  124.     notebox = obj.note.dup
  125.     taglist = notebox.scan(/<.+>/)
  126.     for t in taglist
  127.       text = t.split(/[ <>]/)
  128.       text.delete("")
  129.       for item in text
  130.         return text[text.index(item) + 1] if item == tag
  131.       end
  132.     end
  133.     return nil
  134.   end
  135. end
  136.  
  137. module RPG
  138.   class BaseItem
  139.     def alignment
  140.       if @alignment_req.nil?
  141.         txt = Jet.get_note(self, "alignment")
  142.         @alignment_req = txt.nil? ? :unaligned : txt.to_i
  143.       end
  144.       return @alignment_req
  145.     end
  146.   end
  147. end
  148.  
  149. class Game_Actor
  150.  
  151.   include AlignmentOptions
  152.  
  153.   alias jet3849_skill_can_use? skill_can_use?
  154.   def skill_can_use?(skill)
  155.     if skill.alignment != :unaligned
  156.       q = (ALIGNMENT_CONDITION.size / 2)
  157.       if (skill.alignment < 0 or skill.alignment > 0) && ($game_system.alignment == 0)
  158.         return false unless ((ALIGNMENT_CONDITION[q - 1] / 2)..(ALIGNMENT_CONDITION[q + 1] / 2)) === skill.alignment
  159.       elsif skill.alignment > 0
  160.         return false unless $game_system.alignment >= skill.alignment
  161.       elsif skill.alignment < 0
  162.         return false unless $game_system.alignment <= skill.alignment
  163.       elsif skill.alignment == 0
  164.         return false unless (ALIGNMENT_CONDITION[q - 1]..ALIGNMENT_CONDITION[q + 1]) === skill.alignment
  165.       end
  166.     end
  167.     jet3849_skill_can_use?(skill)
  168.   end
  169. end
  170.  
  171. class Scene_Base
  172.  
  173.   def equip_check
  174.     check_equipment = @item_window.item.alignment
  175.     if check_equipment != :unaligned
  176.       if check_equipment < 0
  177.         return 1
  178.       elsif check_equipment > 0
  179.         return 0
  180.       elsif check_equipment == 0
  181.         return 2
  182.       end
  183.     else
  184.       return 3
  185.     end
  186.   end
  187. end
  188.  
  189. class Scene_Equip
  190.  
  191.   include AlignmentOptions
  192.  
  193.   alias jet5839_start start
  194.   def start
  195.     jet5839_start
  196.     @des_window = Window_Base.new(0, 185, 544, 56)
  197.     @des_window.visible = false
  198.   end
  199.  
  200.   alias jet1047_terminate terminate
  201.   def terminate
  202.     jet1047_terminate
  203.     @des_window.dispose
  204.   end
  205.  
  206.   alias jet2094_update update
  207.   def update
  208.     jet2094_update
  209.     @des_window.update
  210.   end
  211.  
  212.   def update_item_selection
  213.     if Input.trigger?(Input::B)
  214.       Sound.play_cancel
  215.       @equip_window.active = true
  216.       @item_window.active = false
  217.       @item_window.index = -1
  218.     elsif Input.trigger?(Input::C)
  219.       if @item_window.item != nil
  220.         q = (ALIGNMENT_CONDITION.size / 2)
  221.         final_check = equip_check
  222.         if final_check == 0 && $game_system.alignment >= @item_window.item.alignment
  223.           full_equip_process
  224.         elsif final_check == 1 && $game_system.alignment <= @item_window.item.alignment
  225.           full_equip_process
  226.         elsif final_check == 3
  227.           full_equip_process
  228.         elsif final_check == 2 && (ALIGNMENT_CONDITION[q - 1])..(ALIGNMENT_CONDITION[q + 1]) === @item_window.item.alignment
  229.           full_equip_process
  230.         elsif (final_check == 0 or final_check == 1) && ($game_system.alignment == 0 && ((ALIGNMENT_CONDITION[q - 1] / 2)..(ALIGNMENT_CONDITION[q + 1] / 2)) === @item_window.item.alignment)
  231.           full_equip_process
  232.         end
  233.       else
  234.         full_equip_process
  235.       end
  236.     end
  237.   end
  238.  
  239.   def full_equip_process
  240.     Sound.play_equip
  241.     @actor.change_equip(@equip_window.index, @item_window.item)
  242.     @equip_window.active = true
  243.     @item_window.active = false
  244.     @item_window.index = -1
  245.     @equip_window.refresh
  246.     for item_window in @item_windows
  247.       item_window.refresh
  248.     end
  249.   end
  250. end
  251.  
  252.  
Expand to see the code.


Patches


Content Hidden Spoiler
Place all patches below my alignment script AND the script being patched.


YERD Status ReDux:
  1. class Window_Status
  2.  
  3.   alias jet5999_refresh refresh unless $@
  4.   def refresh
  5.     jet5999_refresh
  6.     self.contents.font.color = system_color # redefines the self contained font color
  7.     self.contents.draw_text(279, 96, 106, WLH, NAME_OF_ALIGNMENT + ":") # draws the name of alignment
  8.     self.contents.font.color = normal_color # redefines the self contained font color
  9.     self.contents.draw_text(382, 96, 90, WLH, draw_alignment) # draws the alignment name in the window
  10.   end
  11. end
Expand to see the code.


Future Features


- Weapons/armor/skills dependent on alignment DONE
- Choose bewteen an in-game variable and add_alignment(points) DONE
- Suggested Features


FAQ


Q: How do I add or subtract points?
A: Read the Instructions!

Q: How do I add more alignment names?
A: Add the name, in quotes, where you want to. Then add the points requirement in the same place, but in the other array.
EX:

  1. ALIGNMENT_NAMES = ["Very Evil", "Kinda Evil", "evil", "neutral", "good", "very good"]
Expand to see the code.

I added "Kinda Evil" between "very evil" and "evil". Now I must add the requirement.

  1. ALIGNMENT_CONDITION = [-100, -75, -50, 0, 50, 100]
Expand to see the code.

See how i added -75 between the requirement for "very evil" and "evil" just like i put "kinda evil"? Thats how.


Credit and Thanks

- Jet10985
- CrimsonSeas (rpgmakervx.net)
- Piejamas (rpgmakervx.net)
- Mithran (rpgmakervx.net)
- Yanfly
- OriginalWij (rpgmakervx.net)
- Synthesis

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=69329