[Script] [ACE] [Scene/System] Reputations / Factions

MeoDenLuoiMeoDenLuoi Posts: 1,425Registered
Scripts này có thể giúp bạn tạo ra các phe phái, danh vọng trong game và điều chỉnh nó với các thông tin, số liệu cụ thể.
Như bạn đã thấy, đây là một phe phái, có vẻ như người chơi đã hoàn thành tốt các nhiệm vụ được giao và được rất nhiều Reputations (Danh vọng)
2I0JAgg.png
Còn đây là mặt tiêu cực. Hẳn là người chơi phải làm cho phe phái này giận hoặc không bằng lòng, cho nên danh vọng đã về với con số âm.
M7ciaNm.png
[size=large]Scripts[/size]
#==============================================================================
#                           ############################
#                        ###   Reputations / Factions   ###
#                           ############################  
#
#     Version: 1.0 
#     Author: HellKiteChaoS
#
#     Credits and thanks:
#       -Galv: Modified variable outline graphic.
#       -DP3: For his video tutorials on RGSS3 scripting.
# 
#==============================================================================
 
#==============================================================================
#    Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 5/6/2013  - Started Script.
# 
#==============================================================================
#    Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Creates a window to display reputations found in game as you play. This is 
# controlled  by switches in game, as well as variables used to store the values
# of your reputation.
# 
#==============================================================================
#    Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials but above ▼ Main. Remember to save!
# 
# To call this script from a event, use:
#   SceneManager.call(ReputationScene)
#
#==============================================================================
#   Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
# 
#==============================================================================
 
 
#===============================================================================
#                                 == Setup ==
#===============================================================================
#     
#     This section is where you list the reputations you wish to use.
# 
#     RepSetup[x]:      This is the main array that will be used. This will
#                       start at 0. For every faction / reputation that you
#                       make, increase x by 1. See setup below for example.
#     
#     switch_id:        This is the switch ID used in game to represent the 
#                       reputation. Turn this switch on to display it in the 
#                       reputation list.
#
#     variable_id:      This is the variable ID used in game to represent the 
#                       reputation amount. This variable will hold the value
#                       and be shown in the window.
#
#     reputation name:  This is where you become creative and give your 
#                       reputations names.
#
#     reputation_info:  This is where you can add extra information about your     
#                       reputations. Each "info1, info2, info3" are individual
#                       lines that will be displayed. If you choose to not use     
#                       a line, simply put "" and nothing will be displayed.
#                       You do not have to use all 10 lines if you choose not to.
#     
#     Setup example:
#  
#      RepSetup[0]  = {
#        :switch_id => 15,
#        :variable_id => 30, 
#        :reputation_name => "Kingsport",
#        :reputation_info1 => "Kingsport is the greatest city across the land.",
#        :reputation_info2 => "",
#        :reputation_info3 => "Only the best goods are sold here.",
#        :reputation_info4 => "",
#        :reputation_info5 => "This faction will increase as your reputation",
#        :reputation_info6 => "with Kingston decreases. Keep this in mind.",
#        :reputation_info7 => "",
#        :reputation_info8 => "",
#        :reputation_info9 => "",
#        :reputation_info10 => ""
#        }
#     
#===============================================================================
 
module Chaos
  module RepDataSetup
#------------------------------------------------------------------------------- 
  RepSetup = [] # DO NOT TOUCH! GURRR!
#-------------------------------------------------------------------------------         
    
  RepSetup[0]  = {
    :switch_id => 15,
    :variable_id => 30, 
    :reputation_name => "Kingsport",
    :reputation_info1 => "Kingsport is the greatest city across the land.",
    :reputation_info2 => "",
    :reputation_info3 => "Only the best goods are sold here.",
    :reputation_info4 => "",
    :reputation_info5 => "This faction will increase as your reputation",
    :reputation_info6 => "with Kingston decreases. Keep this in mind.",
    :reputation_info7 => "",
    :reputation_info8 => "",
    :reputation_info9 => "",
    :reputation_info10 => ""
    }
                  
  RepSetup[1]  = {
    :switch_id => 16,
    :variable_id => 31, 
    :reputation_name => "Livington",
    :reputation_info1 => "",
    :reputation_info2 => "Great city. Plenty of rich and poor to go around!",
    :reputation_info3 => "",
    :reputation_info4 => "Killing wild animals might lower your reputation",
    :reputation_info5 => "with the Livington. They like living things...",
    :reputation_info6 => "",
    :reputation_info7 => "",
    :reputation_info8 => "",
    :reputation_info9 => "",
    :reputation_info10 => ""
    }
                      
#===============================================================================
#                         == Reputation title setup ==
#===============================================================================
#
#     This section is where you list the reputation title names.
#     Here you can choose to give names for reaching a specific amount of
#     reputation with a faction.
#
#     Array construction:
#     [minimum, maximum, title name]
#
#     minimum:        This variable will be what is needed to reach the title 
#                     rank. Once the in game variable has reached this amount,
#                     the title will be updated on the page.
#
#     maximum:        This variabe will fill in the range before the next title
#                     rank. For example, if you have 99 rep of reputation A,
#                     and you gain 1 more rep, you will achive the next title.
#                     To achive the next rank you need 200, so the min for the     
#                     current rank is now 100, and the max would be 199.
#
#     title name:     Here again is where you get creative. Give your ranks
#                     names. Are you loved by said people, or hated and would
#                     be killed if they ever see you.
#
#     EXAMPLE:        [400,     500,    "Loved"],
#                     [300,     399,    "Friends"] <--- Don't forget, the last
#                                                       entry in the array needs
#                                                       to NOT have a comma.
#
#===============================================================================
        RepTitle = [
        
        [400,     500,    "Exalted"],
        [300,     399,    "Allies"],
        [200,     299,    "Knighted"],   
        [50,      199,    "Friendly"],      
        [0,       49,     "Neutral"],        
        [-99,     -1,     "Unfriendly"],     
        [-199,    -100,   "Dangerous"],   
        [-500,    -200,   "Kill on sight"]
#-------------------------------------------------------------------------------
        ]   # DO NOT TOUCH THIS!
#-------------------------------------------------------------------------------        
    
 
#===============================================================================
#                       == Variable and options setup ==
#===============================================================================
 
    #---------------------------------------------------------------------------
    #   Show Reputation Title
    #   Here you can choose to show the title ranks of the reputations or not.
    #   true:   It will display the titles on the screen.
    #   false:  Will not display titles.
    #---------------------------------------------------------------------------    
        ShowTitle       = true
 
    
    #---------------------------------------------------------------------------
    #   Show Reputation Progress Gauge
    #   Here you can choose to show a progress bar.
    #   true:   It will display the progress bar at the bottom of the page.
    #   false:  Will not use the progress bar.
    #---------------------------------------------------------------------------    
        ShowGauge       = true
    
 
    #---------------------------------------------------------------------------
    #   Show Reputation Information
    #   Here you can choose to show the extra information about the reputations.
    #   true:   It will display the extra information.
    #   false:  Will not use the extra information.
    #---------------------------------------------------------------------------    
        ShowInfo       = true       
 
        
    #---------------------------------------------------------------------------
    #   Min And Max Value Setup
    #   These two variables will control the two polar ends of the reputation
    #   values. The MAXVALUE variable will control the "cap" that you can 
    #   reach with a reputation. The MINVALUE variable acts the same way, but
    #   is the cap to the lowest you can go with a reputation. 
    #
    #   MINVALUE can be less than zero.
    #   MAXVALUE must be greater than zero and greather than MINVALUE.
    #   MINVALUE and MAXVALUE must be identical numbers.
    #       Example: 500 and -500, 750 and -750, 1556 and -1556.
    #---------------------------------------------------------------------------    
        MaxValue        = 500
        MinValue        = -500
 
        
    #---------------------------------------------------------------------------
    #   Information Font Setup
    #   Here you setup the font size for the detail information about the
    #   reputations.
    #---------------------------------------------------------------------------
        FontSize        = 20
 
        
    #---------------------------------------------------------------------------
    #   Menu Name
    #   Here you choose what the selection name will be in the command menu.
    #---------------------------------------------------------------------------    
        MenuName        = "Reputations"
        
        
    #---------------------------------------------------------------------------
    #   Title Name
    #   Here you choose what the title name that will display for your titles.
    #---------------------------------------------------------------------------       
        TitleName       = "Standing"
 
        
    #---------------------------------------------------------------------------
    #   Numeric Name
    #   Here you choose the numeric name that will display under the title. 
    #---------------------------------------------------------------------------         
        NumericName      = "Value"
  
  
#===============================================================================        
  end       ###########################################################
end   ##### END SETUP CONFIGURATION. NO EDITING PAST THIS POINT GRRRRR! #####
            ###########################################################
#===============================================================================     
 
 
class ReputationScene < Scene_Base
  include Chaos::RepDataSetup
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def start
    super()
    create_reputation_command_list()
    create_reputation_info_window()
    create_reputation_bar_outline()
    
  end
  #--------------------------------------------------------------------------
  # * Post-Start Processing
  #--------------------------------------------------------------------------
  def post_start
    super()
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super()
    return_scene() if Input.trigger?(:B)
  end
  
  def create_reputation_info_window
    @reputation_info_window = Reputation_Info_Window.new(150,0,(Graphics.width - 150) ,Graphics.height)
  end
  
  def create_reputation_command_list
    @reputation_cmmdwindow  = ReputationCommand.new(0, 0)
  end
  
  def create_reputation_bar_outline
    @bar_outline          = Sprite.new()
    @bar_outline.bitmap   = Cache.picture("RepBarCover")
    @bar_outline.x        = 190
    @bar_outline.y        = Graphics.height * 0.85
    @bar_outline.z        = 100
  end
  
  def terminate
    super()
    @bar_outline.bitmap.dispose()
    @bar_outline.dispose()
  end
end
 
#==============================================================================
# ** Window_MenuCommand
#------------------------------------------------------------------------------
#  This command window appears on the menu screen.
#==============================================================================
 
class Window_MenuCommand < Window_Command
  #--------------------------------------------------------------------------
  # * For Adding Original Commands
  #--------------------------------------------------------------------------
  alias hkchaos_customscene_windowsmenucommand_add_reputation_window_46514  add_original_commands
  def add_original_commands
    hkchaos_customscene_windowsmenucommand_add_reputation_window_46514()
    add_command(Chaos::RepDataSetup::MenuName.to_s, :reputations, true)
  end
end
 
class Scene_Menu < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * Create Command Window
  #--------------------------------------------------------------------------
  alias hkchaos_custcomscene_reputation_window_46514  create_command_window
  def create_command_window
    hkchaos_custcomscene_reputation_window_46514()
    @command_window.set_handler(:reputations,  method(:command_customscene))
  end  
  
  def command_customscene
    SceneManager.call(ReputationScene)
  end
end
 
 
class ReputationCommand < Window_Command
  include Chaos::RepDataSetup
  #--------------------------------------------------------------------------
  # * Make Command List
  #--------------------------------------------------------------------------
  def make_command_list 
    $rep_index = 0
    RepSetup.each_with_index do |index, position|
      switch_id = RepSetup[position][:switch_id]    
      next unless $game_switches[switch_id] || switch_id == 0
        text = RepSetup[position][:reputation_name]
        add_command(text, :reputation_name)
    end
  end
  
  def window_width
    return 150
  end
  
   def window_height
    return Graphics.height
  end
 
  def cursor_up(wrap = true)
    $rep_index -= 1
    if $rep_index < 0
      $rep_index = RepSetup.count - 1
    end
    if index >= col_max || index == RepSetup.count - 1 || index == 0
      select((index - col_max + item_max) % item_max)
    end
  end
  
  def cursor_down(wrap = true)
    $rep_index += 1
    if $rep_index >= RepSetup.count
      $rep_index = 0
    end
    if index < item_max - col_max || index == RepSetup.count - 1 || index == 0
      select((index + col_max) % item_max)
    end
  end
end
 
class Reputation_Info_Window < Window_Base
  include Chaos::RepDataSetup
  #--------------------------------------------------------------------------#
  # Object Initialization                                                    #
  #--------------------------------------------------------------------------#
  def initialize(x, y, width, height)
    super(x, y, width, height)    
    draw_rep_info($rep_index)
  end
  
  #--------------------------------------------------------------------------#
  # Draw Rep Info Text                                                       #
  #--------------------------------------------------------------------------#
  def draw_rep_info(index)
    #Pull data from array in setup
    rep_name    = RepSetup[index][:reputation_name]
    switch_id    = RepSetup[index][:switch_id]
    var_id      = RepSetup[index][:variable_id]
    info_line1    = RepSetup[index][:reputation_info1]
    info_line2    = RepSetup[index][:reputation_info2]
    info_line3    = RepSetup[index][:reputation_info3]
    info_line4    = RepSetup[index][:reputation_info4]
    info_line5    = RepSetup[index][:reputation_info5]
    info_line6   = RepSetup[index][:reputation_info6]
    info_line7   = RepSetup[index][:reputation_info7]
    info_line8   = RepSetup[index][:reputation_info8]
    info_line9   = RepSetup[index][:reputation_info9]
    info_line10   = RepSetup[index][:reputation_info10]
    
    #Sets up variables based on data listed above
    if $game_variables[var_id] > MaxValue
       $game_variables[var_id] = MaxValue
    end
    if $game_variables[var_id] < MinValue
       $game_variables[var_id] = MinValue
    end
 
    repvalue      = $game_variables[var_id]
    maxvalue      = MaxValue
    minvalue      = MinValue
    
    #Draws the reputation name as a title at the top left
    contents.font.bold = true
    contents.font.size = 30
    draw_text(0, 0, contents.width, 50, rep_name, 0)
    contents.font.bold = false
    contents.font.size = FontSize
    
    if ShowTitle == true
      l = 0
      for k in RepTitle 
        min = RepTitle[l][0]
        max = RepTitle[l][1]    
        if repvalue >= min && repvalue <= max              
          rank_title = RepTitle[l][2]
          draw_text(0, 20, contents.width, 75, TitleName + ": " + rank_title.to_s, 0)
          break
        end
      l += 1
      end
    end
    
    #Draws the reputation bar and amount
    if ShowGauge == true
      reprate = (((((maxvalue/maxvalue).to_f)/maxvalue).to_f) * repvalue).to_f
      rep_min_max = repvalue.to_s + " / " + maxvalue.to_s
      gh = (Graphics.height * 0.8)
      if repvalue < 0
        reprate *= -1
        color1 = hp_gauge_color1
        color2 = hp_gauge_color2
        draw_gauge_neg(40, gh+2, 150, reprate, color1, color2)
        draw_gauge_pos(191, gh+2 , 150, 0, color1, color2)
      else
        color1 = tp_gauge_color1
        color2 = tp_gauge_color2
        draw_gauge_neg(40, gh+2, 150, 0, color1, color2)
        draw_gauge_pos(191, gh+2, 150, reprate, color1, color2)
      end
      contents.font.bold = false
      contents.font.size = 20
      draw_text(0, 50, contents.width, 50, NumericName + ": " + rep_min_max.to_s, 0)
      contents.font.bold = false
      contents.font.size = FontSize
    end
    
    if ShowInfo == true
      draw_text(0, 100, contents.width, line_height, info_line1, 0)
      draw_text(0, 120, contents.width, line_height, info_line2, 0)
      draw_text(0, 140, contents.width, line_height, info_line3, 0)
      draw_text(0, 160, contents.width, line_height, info_line4, 0)
      draw_text(0, 180, contents.width, line_height, info_line5, 0)
      draw_text(0, 200, contents.width, line_height, info_line6, 0)
      draw_text(0, 220, contents.width, line_height, info_line7, 0)
      draw_text(0, 240, contents.width, line_height, info_line8, 0)
      draw_text(0, 260, contents.width, line_height, info_line9, 0)
      draw_text(0, 280, contents.width, line_height, info_line10, 0)
    end
  end
  
  def update
    super
    contents.clear
    draw_rep_info($rep_index)  
  end
  
  # Custom draw_gauge to allow gauges to build both forward and backwords to
  # display positive values and negative values.
  alias hkchaos_customgauge_neg__46514   draw_gauge
  def draw_gauge_neg(x, y, width, rate, color1, color2)
    hkchaos_customgauge_neg__46514(x, y, width, rate, color1, color2)
    fill_w = (width * rate).to_i
    gauge_y = y + line_height - 8
    contents.fill_rect(x, gauge_y, width, 30, gauge_back_color)
    contents.gradient_fill_rect(189-(width - (width * (1 - rate))), gauge_y, fill_w, 30, color1, color2)
  end
  
  alias hkchaos_customgauge_pos__46514   draw_gauge
  def draw_gauge_pos(x, y, width, rate, color1, color2)
    hkchaos_customgauge_pos__46514(x, y, width, rate, color1, color2)
    fill_w = (width * rate).to_i
    gauge_y = y + line_height - 8
    contents.fill_rect(x, gauge_y, width, 30, gauge_back_color)
    contents.gradient_fill_rect(x, gauge_y, fill_w, 30, color1, color2)
  end
end
Demo Version 1.0:
https://www.dropbox.com/sh/kh0uenovdzo559s/ZxgOlzepz1

[size=large]Điều khoản sử dụng[/size]
Xài free, nhưng phải credit tên tác giả
[size=large]Credit[/size]
Chaos

[align=right]Đã cộng 3 Cash (◡ ‿ ◡ ✿)[/align]

Comments

Sign In or Register to comment.