Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

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


alignment.png

How To Use


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


[rgss]#===============================================================================
# Alignment System V.2
# By Jet10985
# Help by: Crimsonseas, Piejamas, Originalwij, Yanfly, Mithran
# Inspired by: Synthesis
#===============================================================================
# This script is not open for distribution to other sites without permission
# from me, Jet10985. Please credit me if you use this script.
#===============================================================================
# This script will allow you to add a nice alignment system to your game, which
# can be used for more then alignment. EX: Ranks, Vampirism, etc.
# This script has: 5 customization options.
#===============================================================================
 
<span style="color:#000080; font-style:italic;">=begin
<span style="color:#000080; font-style:italic;">The alignment name and value match to the corresponding one in the other array.
<span style="color:#000080; font-style:italic;"> 
<span style="color:#000080; font-style:italic;">EX: In the default, "Very Evil" is the first name, and -100 is the first condition
<span style="color:#000080; font-style:italic;"> 
<span style="color:#000080; font-style:italic;">This means, if -100 or lower is the value of $game_system.alignment, the
<span style="color:#000080; font-style:italic;">character will be "Very Evil".
<span style="color:#000080; font-style:italic;">--------------------------------------------------------------------------------
<span style="color:#000080; font-style:italic;">How to change alignment: We have 2 command to change alignment points.
<span style="color:#000080; font-style:italic;"> 
<span style="color:#000080; font-style:italic;">sub_alignment(points) and add_alignment(points)
<span style="color:#000080; font-style:italic;"> 
<span style="color:#000080; font-style:italic;">In both commands, replace "points" with the amount of change you want in the
<span style="color:#000080; font-style:italic;">character's alignment points.
<span style="color:#000080; font-style:italic;"> 
<span style="color:#000080; font-style:italic;">sub_alignment will subtract the amount of points.
<span style="color:#000080; font-style:italic;">add_alignment will add the amount of points
<span style="color:#000080; font-style:italic;">--------------------------------------------------------------------------------
<span style="color:#000080; font-style:italic;">Tagging equipment and skills:
<span style="color:#000080; font-style:italic;"> 
<span style="color:#000080; font-style:italic;">To tag these in the database to require a certain amount of alignment points,
<span style="color:#000080; font-style:italic;">add the tag
<span style="color:#000080; font-style:italic;"> 
<span style="color:#000080; font-style:italic;"><alignment ##>
<span style="color:#000080; font-style:italic;"> 
<span style="color:#000080; font-style:italic;">where ## is the number of points required. make sure you keep
<span style="color:#000080; font-style:italic;">the <> because that's actually required.
<span style="color:#000080; font-style:italic;">=end
 
module AlignmentOptions
 
  ALIGNMENT_NAME = ["Very Evil", "Evil", "Neutral", "Good", "Very Good"]
 
  ALIGNMENT_CONDITION = [-100, -50, 0, 50, 100] # What the value of $game_system.alignment
                                                # needs to be to correspond to the alignment name
                                               
  NAME_OF_ALIGNMENT = "Alignment" # This is what alignment will be called altogether
 
  USE_VARIABLE = false
 
  VARIABLE_ID = 5
 
end # ending module
#===============================================================================
class Game_System
 
  include AlignmentOptions
   
  alias jet5830_initialize initialize
  def initialize
    jet5830_initialize
    @alignment = 0
  end
 
  def alignment
    USE_VARIABLE ? $game_variables[VARIABLE_ID] : @alignment
  end
 
  def alignment=(new_value)
    USE_VARIABLE ? $game_variables[VARIABLE_ID] = new_value : @alignment = new_value
  end
end # ending Game_System addition
 
class Game_Interpreter
 
  def add_alignment(points) # adding easy-to-us command to add alignment points
    $game_system.alignment += points # adding the arguement value from the variable
  end # ending definition
 
  def sub_alignment(points) # adding easy-to-us command to subtract alignment points
    $game_system.alignment -= points # subtracting the arguement value from the variable
  end # ending definition
end # ending addition to Game_Interpreter
 
class Window_Status
 
  include AlignmentOptions # including the options defined in the module AlignmentOptions
 
  alias jet5839_refresh refresh unless $@ # aliasing my new command to avoid compatibility issues
  def refresh
    jet5839_refresh # calls the old method
    self.contents.font.color = system_color # redefines the self contained font color
    self.contents.draw_text(290, 110, 500, 500, NAME_OF_ALIGNMENT + ":") # draws the name of alignment
    self.contents.font.color = normal_color # redefines the self contained font color
    self.contents.draw_text(400, 110, 500, 500, draw_alignment) # draws the alignment name in the window
  end # ending definition alias
end
 
class Window_Base
 
  include AlignmentOptions
 
  def draw_alignment # Definition of Draw_alignment
    if $game_system.alignment <= ALIGNMENT_CONDITION.min
      return ALIGNMENT_NAME.min
    elsif $game_system.alignment >= ALIGNMENT_CONDITION.max
      return ALIGNMENT_NAME.max
    elsif
      for i in 0...ALIGNMENT_CONDITION.size
        if $game_system.alignment < ALIGNMENT_CONDITION
          return ALIGNMENT_NAME[i-1]
        end
      end
    end
  end
end
 
module Jet
    def self.get_note(obj, tag)
    notebox = obj.note.dup
    taglist = notebox.scan(/<.+>/)
    for t in taglist
      text = t.split(/[ <>]/)
      text.delete("")
      for item in text
        return text[text.index(item) + 1] if item == tag
      end
    end
    return nil
  end
end
 
module RPG
  class BaseItem
    def alignment
      if @alignment_req.nil?
        txt = Jet.get_note(self, "alignment")
        @alignment_req = txt.nil? ? :unaligned : txt.to_i
      end
      return @alignment_req
    end
  end
end
 
class Game_Actor
 
  include AlignmentOptions
 
  alias jet3849_skill_can_use? skill_can_use?
  def skill_can_use?(skill)
    if skill.alignment != :unaligned
      q = (ALIGNMENT_CONDITION.size / 2)
      if (skill.alignment < 0 or skill.alignment > 0) && ($game_system.alignment == 0)
        return false unless ((ALIGNMENT_CONDITION[q - 1] / 2)..(ALIGNMENT_CONDITION[q + 1] / 2)) === skill.alignment
      elsif skill.alignment > 0
        return false unless $game_system.alignment >= skill.alignment
      elsif skill.alignment < 0
        return false unless $game_system.alignment <= skill.alignment
      elsif skill.alignment == 0
        return false unless (ALIGNMENT_CONDITION[q - 1]..ALIGNMENT_CONDITION[q + 1]) === skill.alignment
      end
    end
    jet3849_skill_can_use?(skill)
  end
end
 
class Scene_Base
 
  def equip_check
    check_equipment = @item_window.item.alignment
    if check_equipment != :unaligned
      if check_equipment < 0
        return 1
      elsif check_equipment > 0
        return 0
      elsif check_equipment == 0
        return 2
      end
    else
      return 3
    end
  end
end
 
class Scene_Equip
 
  include AlignmentOptions
 
  alias jet5839_start start
  def start
    jet5839_start
    @des_window = Window_Base.new(0, 185, 544, 56)
    @des_window.visible = false
  end
 
  alias jet1047_terminate terminate
  def terminate
    jet1047_terminate
    @des_window.dispose
  end
 
  alias jet2094_update update
  def update
    jet2094_update
    @des_window.update
  end
 
  def update_item_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @equip_window.active = true
      @item_window.active = false
      @item_window.index = -1
    elsif Input.trigger?(Input::C)
      if @item_window.item != nil
        q = (ALIGNMENT_CONDITION.size / 2)
        final_check = equip_check
        if final_check == 0 && $game_system.alignment >= @item_window.item.alignment
          full_equip_process
        elsif final_check == 1 && $game_system.alignment <= @item_window.item.alignment
          full_equip_process
        elsif final_check == 3
          full_equip_process
        elsif final_check == 2 && (ALIGNMENT_CONDITION[q - 1])..(ALIGNMENT_CONDITION[q + 1]) === @item_window.item.alignment
          full_equip_process
        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)
          full_equip_process
        end
      else
        full_equip_process
      end
    end
  end
 
  def full_equip_process
    Sound.play_equip
    @actor.change_equip(@equip_window.index, @item_window.item)
    @equip_window.active = true
    @item_window.active = false
    @item_window.index = -1
    @equip_window.refresh
    for item_window in @item_windows
      item_window.refresh
    end
  end
end
 
 
[/rgss]

Patches


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


YERD Status ReDux:
[rgss]class Window_Status
 
  alias jet5999_refresh refresh unless $@
  def refresh
    jet5999_refresh
    self.contents.font.color = system_color # redefines the self contained font color
    self.contents.draw_text(279, 96, 106, WLH, NAME_OF_ALIGNMENT + ":") # draws the name of alignment
    self.contents.font.color = normal_color # redefines the self contained font color
    self.contents.draw_text(382, 96, 90, WLH, draw_alignment) # draws the alignment name in the window
  end
end
[/rgss]

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:

Code:
 ALIGNMENT_NAMES = ["Very Evil", "Kinda Evil", "evil", "neutral", "good", "very good"]
I added "Kinda Evil" between "very evil" and "evil". Now I must add the requirement.

Code:
ALIGNMENT_CONDITION = [-100, -75, -50, 0, 50, 100]
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
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top