Advertisement
mjshi

Mobius's Quest Journal

Jul 8th, 2015
1,387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 26.22 KB | None | 0 0
  1. #==============================================================================
  2. # ** Mobius -- Quests
  3. #------------------------------------------------------------------------------
  4. #  A simple module used to hold customizable constants
  5. #  Version 2.0a, edited by mjshi
  6. #  Requires: None
  7. #==============================================================================
  8.  
  9. #==============================================================================
  10. # CUSTOMIZATION START
  11. #==============================================================================
  12. module Mobius
  13.   module Quests
  14.     #--------------------------------------------------------------------------
  15.     # * Module constants
  16.     #--------------------------------------------------------------------------
  17.       CREATE_ENCRYPTED = false              # Determines encrypted file creation
  18.       USE_ENCRYPTED = false                 # Sets use of encrypted file
  19.       QUEST_FILENAME = "Data/QuestData.txt" # Sets unencrypted filename
  20.       USE_SWITCHES_VARIABLES = true         # Sets use of switches/variables
  21.       FIRST_SWITCH_ID = 2                   # Sets the first switch ID
  22.       FIRST_VARIABLE_ID = 2                 # Sets the first variable ID
  23.       RENAME_SWITCHES_VARIABLES = true      # Determines renaming of switches/variables
  24.       SHOW_ALL_QUESTS = false               # DEBUGGING FEATURE - Always shows all quests  
  25.   end
  26. end
  27. #==============================================================================
  28. # CUSTOMIZATION END -- DON'T EDIT BELOW THIS LINE!!!
  29. #==============================================================================
  30.  
  31. #==============================================================================
  32. # ** Game Quest -- Mobius
  33. #------------------------------------------------------------------------------
  34. #  The class that holds quests. Each instance of Game Quest is used to hold
  35. #  one quest.
  36. #==============================================================================
  37.  
  38. class Game_Quest
  39.   #--------------------------------------------------------------------------
  40.   # * Class Variables
  41.   #--------------------------------------------------------------------------
  42.     @@total_quests = 0           # Used to track number of quest objects
  43.  
  44.   #--------------------------------------------------------------------------
  45.   # * Public Instance Variables
  46.   #--------------------------------------------------------------------------
  47.     attr_reader   :id            # ID
  48.     attr_reader   :name          # Name
  49.     #attr_accessor :phase         # Phase
  50.     attr_reader   :known         # Known status (true / false)
  51.     attr_reader   :completed     # Completed status (true / false)
  52.   #--------------------------------------------------------------------------
  53.   # * Object Initialization
  54.   #--------------------------------------------------------------------------
  55.   def initialize(name = "", info_array = [] )
  56.     @id = @@total_quests
  57.     @@total_quests += 1
  58.     @name = name
  59.     @phase = 0
  60.     @phase_variable = @id + Mobius::Quests::FIRST_VARIABLE_ID
  61.     @known = false
  62.     @known_switch = ( (@id * 2) + Mobius::Quests::FIRST_SWITCH_ID )
  63.     @completed = false
  64.     @completed_switch = ( (@id * 2) + 1 + Mobius::Quests::FIRST_SWITCH_ID )
  65.     # The info array contains text that corresponds to the current phase
  66.     # of the quest. So, you simply need to get the info in the i-th position
  67.     # of the array for the i-th phase
  68.     @info_array = info_array
  69.     # Call rename if set in customization
  70.     rename if (Mobius::Quests::RENAME_SWITCHES_VARIABLES and Mobius::Quests::USE_SWITCHES_VARIABLES)
  71.   end
  72.   #--------------------------------------------------------------------------
  73.   # * Get Current Info
  74.   # Returns text info for the current phase
  75.   #--------------------------------------------------------------------------
  76.   def get_current_info
  77.     @info_array.fetch(@phase, [])
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   # * Phase=
  81.   # Sets the quest phase
  82.   #--------------------------------------------------------------------------
  83.   def phase=(value)
  84.     # Set phase
  85.     @phase = value
  86.     if Mobius::Quests::USE_SWITCHES_VARIABLES
  87.       # Set phase variable
  88.       $game_variables[@phase_variable] = value
  89.       # Refresh map
  90.       $game_map.need_refresh = true
  91.     end
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # * Discover
  95.   # Changes quest state known to true
  96.   #--------------------------------------------------------------------------
  97.   def discover
  98.     # Set known flag
  99.     @known = true
  100.     if Mobius::Quests::USE_SWITCHES_VARIABLES
  101.       # Set known switch
  102.       $game_switches[@known_switch] = true
  103.       # Refresh map
  104.       $game_map.need_refresh = true
  105.     end
  106.   end
  107.   #--------------------------------------------------------------------------
  108.   # * Complete
  109.   # Changes quest state completed to true
  110.   #--------------------------------------------------------------------------
  111.   def complete
  112.     # Set completed flag
  113.     @completed = true
  114.     if Mobius::Quests::USE_SWITCHES_VARIABLES
  115.       # Set completed switch
  116.       $game_switches[@completed_switch] = true
  117.       # Refresh map
  118.       $game_map.need_refresh = true
  119.     end
  120.   end
  121.   #--------------------------------------------------------------------------
  122.   # * Data Check
  123.   # Updates quest phase, known, and completed with switch/variable  
  124.   #--------------------------------------------------------------------------
  125.   def data_check
  126.     if Mobius::Quests::USE_SWITCHES_VARIABLES
  127.       @phase = $game_variables[@phase_variable]
  128.       @known = $game_switches[@known_switch]
  129.       @completed = $game_switches[@completed_switch]
  130.     end
  131.   end
  132.   #--------------------------------------------------------------------------
  133.   # * Rename
  134.   # Renames associated switches and variables
  135.   #--------------------------------------------------------------------------
  136.   def rename
  137.     str = @name + " Phase"
  138.     $data_system.variables[@phase_variable] = str
  139.     str = @name + " Known"
  140.     $data_system.switches[@known_switch] = str
  141.     str = @name + " Completed"
  142.     $data_system.switches[@completed_switch] = str
  143.     save_data($data_system, "Data/System.rxdata")
  144.   rescue
  145.     print(self.to_s)
  146.     raise
  147.   end
  148.   #--------------------------------------------------------------------------
  149.   # * to_s
  150.   # Returns quest object data as string
  151.   # Mostly used for debugging purposes
  152.   #--------------------------------------------------------------------------
  153.   def to_s
  154.     "Quest ID: #{@id}\n" +
  155.     "Quest Name: #{@name}\n" +
  156.     "Quest Info:\n" +
  157.     @info_array.join("\n")
  158.   end
  159. end
  160.  
  161. #==============================================================================
  162. # ** Game_Quests
  163. #------------------------------------------------------------------------------
  164. #  This class handles the Game Quest arrays. Refer to "$game_quests" for the
  165. #  instance of this class.
  166. #==============================================================================
  167.  
  168. class Game_Quests
  169.   #--------------------------------------------------------------------------
  170.   # * Public Instance Variables
  171.   #--------------------------------------------------------------------------
  172.     attr_accessor :all_quests           # Array of all quest objects
  173.     attr_accessor :current_quests       # Array of all current quest objects
  174.     attr_accessor :completed_quests     # Array of all completed quest objects
  175.   #--------------------------------------------------------------------------
  176.   # * Object Initialization
  177.   #--------------------------------------------------------------------------
  178.   def initialize
  179.     @all_quests = []
  180.     @current_quests = []
  181.     @completed_quests = []
  182.     setup
  183.   end
  184.   #--------------------------------------------------------------------------
  185.   # * Add Quest - adds a quest object to the all_quests array
  186.   #--------------------------------------------------------------------------
  187.   def add_quest(quest)
  188.     @all_quests.push(quest)
  189.   end
  190.   #--------------------------------------------------------------------------
  191.   # * Sort Quests
  192.   # Refreshes the current_quests and completed_quests arrays
  193.   # Also sorts them as well as the all quests array by ID's
  194.   #--------------------------------------------------------------------------
  195.   def sort_quests
  196.     # Sort the all_quests array by ID
  197.     @all_quests.sort {|a,b| a.id <=> b.id }
  198.     # Reset the current and completed quest arrays
  199.     @current_quests = []
  200.     @completed_quests = []
  201.     # Push known and completed quests to their appropiate arrays
  202.     for quest in @all_quests
  203.       if quest.known and quest.completed
  204.         @completed_quests.push(quest)
  205.       elsif quest.known
  206.         @current_quests.push(quest)
  207.       end
  208.     end
  209.   end
  210.   #--------------------------------------------------------------------------
  211.   # * Discover Quest - uses quest name or id to change state of quest to known
  212.   #--------------------------------------------------------------------------
  213.   def discover_quest(name_or_id)
  214.     # Check if passed value is ID
  215.     if name_or_id.is_a?(Integer)
  216.       # Check if ID is valid
  217.       if @all_quests[name_or_id].is_a?(Game_Quest)
  218.         # Set quest to known
  219.         @all_quests[name_or_id].discover
  220.       else # If ID is invalid
  221.         # Print debug message
  222.         print("The quest ID provided (#{name_or_id}) is not valid.")
  223.       end
  224.     elsif name_or_id.is_a?(String)
  225.       # Look up quest using name
  226.       quest_to_change = @all_quests.find {|quest| quest.name == name_or_id}
  227.       # Check if quest is valid
  228.       if quest_to_change.is_a?(Game_Quest)
  229.         # Set quest to known
  230.         quest_to_change.discover
  231.       else # If quest is invalid
  232.         # Print debug message
  233.         print("The quest name '#{name_or_id}' was not found.\n" +
  234.               "Check that the quest exists and that the spelling\n" +
  235.               "is correct." )
  236.       end
  237.     else # If input is invalid
  238.       # Print debug message
  239.       print("Unrecognized input provided to method 'discover_quest'.\n" +
  240.             "Input should be either an integer for the quest ID or\n" +
  241.             "a string representing the quest name." )
  242.     end
  243.     sort_quests
  244.   end
  245.   # Create shorthand name for eventing scripts
  246.   alias dq discover_quest
  247.   #--------------------------------------------------------------------------
  248.   # * Set Phase - uses quest name or id to change phase
  249.   #--------------------------------------------------------------------------
  250.   def set_phase(name_or_id, phase)
  251.     # Check if passed value is ID
  252.     if name_or_id.is_a?(Integer)
  253.       # Set quest to known
  254.       @all_quests[name_or_id].phase = phase
  255.     else
  256.       # Look up quest using name
  257.       quest_to_change = @all_quests.find {|quest| quest.name == name_or_id}
  258.       # Set quest to known
  259.       quest_to_change.phase = phase
  260.     end
  261.     sort_quests
  262.   end
  263.   # Create shorthand name for eventing scripts
  264.   alias sp set_phase
  265.   #--------------------------------------------------------------------------
  266.   # * Complete Quest
  267.   # Uses quest name or id to change state of quest to complete
  268.   #--------------------------------------------------------------------------
  269.   def complete_quest(name_or_id)
  270.     # Check if passed value is ID
  271.     if name_or_id.is_a?(Integer)
  272.       # Check if ID is valid
  273.       if @all_quests[name_or_id].is_a?(Game_Quest)
  274.         # Set quest to known
  275.         @all_quests[name_or_id].complete
  276.       else # If ID is invalid
  277.         # Print debug message
  278.         print("The quest ID provided (#{name_or_id}) is not valid." +
  279.               "Check that the quest exists and that the id is correct." )
  280.       end
  281.     elsif name_or_id.is_a?(String)
  282.       # Look up quest using name
  283.       quest_to_change = @all_quests.find {|quest| quest.name == name_or_id}
  284.       # Check if quest is valid
  285.       if quest_to_change.is_a?(Game_Quest)
  286.         # Set quest to known
  287.         quest_to_change.complete
  288.       else # If quest is invalid
  289.         # Print debug message
  290.         print("The quest name '#{name_or_id}' was not found.\n" +
  291.               "Check that the quest exists and that the spelling\n" +
  292.               "is correct." )
  293.       end
  294.     else # If input is invalid
  295.       # Print debug message
  296.       print("Unrecognized input provided to method 'discover_quest'.\n" +
  297.             "Input should be either an integer for the quest ID or\n" +
  298.             "a string representing the quest name." )
  299.     end
  300.     sort_quests
  301.   end
  302.   # Create shorthand name for eventing scripts
  303.   alias cq complete_quest
  304.   #--------------------------------------------------------------------------
  305.   # * Data Check
  306.   # Performs a data check on the specified quest
  307.   #--------------------------------------------------------------------------
  308.   def data_check(id)
  309.     @all_quests[id].data_check
  310.   end
  311.   #--------------------------------------------------------------------------
  312.   # * Data Check All
  313.   # Performs a data check on all quests
  314.   #--------------------------------------------------------------------------
  315.   def data_check_all
  316.     for quest in @all_quests
  317.       quest.data_check
  318.     end
  319.   end
  320.   #--------------------------------------------------------------------------
  321.   # * Setup - Performs first time setup of quest data
  322.   #--------------------------------------------------------------------------
  323.   def setup
  324.     # if true
  325.     if Mobius::Quests::CREATE_ENCRYPTED
  326.       # Load unencrypted data
  327.       Game_Quests.normal_setup
  328.       # Create encrypted .rxdata
  329.       Game_Quests.create_encrypted
  330.     # elsif true
  331.     elsif Mobius::Quests::USE_ENCRYPTED
  332.       # Load encrypted data
  333.       Game_Quests.encrypted_setup
  334.     else
  335.       # Load unencrypted data
  336.       Game_Quests.normal_setup
  337.     end
  338.     # initialize Game_Quest object data from $data_quests array
  339.     for quest in $data_quests
  340.       self.add_quest(quest)
  341.     end
  342.     # Set Main Quest to known
  343.     discover_quest(0)
  344.   end
  345.   #--------------------------------------------------------------------------
  346.   # * GQs - Normal Setup
  347.   # Class method that intializes normal quest data
  348.   #--------------------------------------------------------------------------
  349.   def Game_Quests.normal_setup
  350.     # Create array of quest data from file
  351.     quest_array = File.open(Mobius::Quests::QUEST_FILENAME) {|f|
  352.                 f.readlines("mobius_quest_break\n\n")}
  353.     # Remove empty last element if necessary
  354.     if quest_array.last.rstrip == ""
  355.       quest_array.pop
  356.     end
  357.     # Initialize $data_quests array
  358.     $data_quests = Array.new
  359.     # Create Game_Quest objects from data
  360.     for quest_data in quest_array
  361.       # Split quest data by paragraph
  362.       quest_data_array = quest_data.split("\n\n")
  363.       # Remove file delimiter "mobius_quest_break\n\n"
  364.       quest_data_array.pop
  365.       # Set and remove name
  366.       name = quest_data_array.shift
  367.       # Initialize info array
  368.       info_array = []
  369.       # Organize phase info into useable line lengths
  370.       for quest_data_line in quest_data_array
  371.         new_arr = []
  372.         # Split phase info into words
  373.         temp_arr = quest_data_line.split
  374.         temp_str = ""
  375.         for word in temp_arr
  376.           # Rejoin words together
  377.           temp_str.concat(word + " ")
  378.           # When line length is useable, push to new_arr
  379.           if temp_str.size >= 35
  380.             new_arr.push(temp_str.strip)
  381.             temp_str = ""
  382.           end
  383.         end
  384.         # Push leftover string
  385.         new_arr.push(temp_str.strip) unless temp_str == ""
  386.         # Push phase info to info_array
  387.         info_array.push(new_arr)
  388.       end
  389.       # Push new Game_Quest object to $data_quests array
  390.       $data_quests.push(Game_Quest.new(name, info_array))
  391.     end
  392.   end
  393.   #--------------------------------------------------------------------------
  394.   # * GQs - Encrypted Setup
  395.   # Class method that intializes encrypted quest data
  396.   #--------------------------------------------------------------------------
  397.   def Game_Quests.encrypted_setup
  398.     # load encrypted data
  399.     $data_quests = load_data("Data/Quests.rxdata")
  400.   end
  401.   #--------------------------------------------------------------------------
  402.   # * GQs - Create Setup
  403.   # Class method that creates encrypted quest data
  404.   #--------------------------------------------------------------------------
  405.   def Game_Quests.create_encrypted
  406.     # save encrypted data
  407.     save_data($data_quests, "Data/Quests.rxdata")
  408.   end
  409. end
  410.  
  411. #==============================================================================
  412. # ** Window Quest Info
  413. #------------------------------------------------------------------------------
  414. #  This window lists the info for the quests
  415. #==============================================================================
  416.  
  417. class Window_QuestInfo < Window_Selectable
  418.   #--------------------------------------------------------------------------
  419.   # * Object Initialization
  420.   #--------------------------------------------------------------------------
  421.   def initialize()
  422.     super(200, 0, 440, 480)
  423.     self.active = false
  424.     self.contents = Bitmap.new(width - 32, height - 32)
  425.     self.index = -1
  426.     refresh([""])
  427.   end
  428.   #--------------------------------------------------------------------------
  429.   # * Refresh
  430.   #--------------------------------------------------------------------------
  431.   def refresh(text_array)
  432.     # Clear old contents
  433.     if self.contents != nil
  434.       self.contents.clear
  435.     end
  436.     # Set font color
  437.     self.contents.font.color = normal_color
  438.     # Break if text_array is nil
  439.     return unless text_array
  440.     # Draw info
  441.     for i in 0...text_array.size
  442.       line = text_array[i]
  443.       self.contents.draw_text(0, i * 22, 408, 22, line)
  444.     end
  445.   end
  446. end
  447.  
  448. #==============================================================================
  449. # ** Window Quest List
  450. #------------------------------------------------------------------------------
  451. #  This window lists all currently active/completed quests
  452. #==============================================================================
  453.  
  454. class Window_QuestList < Window_Selectable
  455.   #--------------------------------------------------------------------------
  456.   # * Object Initialization
  457.   #--------------------------------------------------------------------------
  458.   def initialize()
  459.     super(0, 0, 200, 480)
  460.     @current_quests = []        # Array of current quests
  461.     @completed_quests = []      # Array of completed quests
  462.     @top_half_size = 0          # Number of rows of current quests
  463.     @bottom_half_size = 0       # Number of rows of completed quests
  464.     self.active = true
  465.     self.index = 0
  466.     refresh
  467.   end
  468.   #--------------------------------------------------------------------------
  469.   # * Refresh
  470.   #--------------------------------------------------------------------------
  471.   def refresh
  472.     # Determine total number of rows
  473.     @item_max = [@top_half_size + @bottom_half_size, 1].max
  474.     if self.contents != nil
  475.       self.contents.dispose
  476.     end
  477.     # Draw bitmap
  478.     self.contents = Bitmap.new(200 - 32, row_max * 32)
  479.     self.contents.font.color = normal_color
  480.     # Draw current quests
  481.     for i in 0...@top_half_size
  482.       quest_name = @current_quests[i].name
  483.       self.contents.draw_text(8, i * 32, 160, 32, quest_name)
  484.     end
  485.     self.contents.font.color = disabled_color
  486.     # Draw completed quests
  487.     for i in 0...@bottom_half_size
  488.       quest_name = @completed_quests[i].name
  489.       self.contents.draw_text(8, i * 32 + @top_half_size *
  490.       32, 160, 32, quest_name)
  491.     end
  492.   end
  493.   #--------------------------------------------------------------------------
  494.   # * Set Quests
  495.   #--------------------------------------------------------------------------
  496.   def set_quests(new_current_quests, new_completed_quests)
  497.     if @current_quests != new_current_quests or
  498.        @completed_quests != new_completed_quests
  499.        #set new quests
  500.        @current_quests = new_current_quests
  501.        @completed_quests = new_completed_quests
  502.        @top_half_size = @current_quests.size
  503.        @bottom_half_size = @completed_quests.size
  504.        #call update
  505.        refresh
  506.     end
  507.   end
  508.   #--------------------------------------------------------------------------
  509.   # * Get Index Info
  510.   #   Returns the text info from which ever quest is currently highlighted
  511.   #--------------------------------------------------------------------------
  512.   def get_index_info
  513.     # Unless there are no quests
  514.     unless @current_quests.empty? and @completed_quests.empty?
  515.       # Determine cursor location
  516.      if self.index < @top_half_size
  517.         # Get selected quest info
  518.         @current_quests[self.index].get_current_info
  519.       else
  520.         # Get selected quest info
  521.         @completed_quests[self.index - @top_half_size].get_current_info
  522.       end
  523.     end
  524.   end
  525. end
  526.  
  527. #==============================================================================
  528. # ** Scene_Quest
  529. #------------------------------------------------------------------------------
  530. #  This class performs quest screen processing.
  531. #==============================================================================
  532.  
  533. class Scene_Quest
  534.   #--------------------------------------------------------------------------
  535.   # * Object Initialization
  536.   #--------------------------------------------------------------------------
  537.   def initialize(return_scene = $scene.type)
  538.     @return_scene = return_scene
  539.   end
  540.   #--------------------------------------------------------------------------
  541.   # * Main Processing
  542.   #--------------------------------------------------------------------------
  543.   def main
  544.     # Make QuestList Window
  545.     @quest_list_window = Window_QuestList.new
  546.     # Make QuestInfo Window
  547.     @quest_info_window = Window_QuestInfo.new
  548.     # Create memory variable
  549.     @list_index = @quest_list_window.index
  550.     # Update Game Quests
  551.     $game_quests.data_check_all if Mobius::Quests::USE_SWITCHES_VARIABLES
  552.     $game_quests.sort_quests
  553.     # Refresh QuestList
  554.     unless Mobius::Quests::SHOW_ALL_QUESTS
  555.       # Normal refresh
  556.       @quest_list_window.set_quests($game_quests.current_quests,
  557.                                     $game_quests.completed_quests)
  558.     else
  559.       # DEBUG refresh
  560.       @quest_list_window.set_quests($game_quests.all_quests, [] )
  561.     end
  562.     # Redraw info window
  563.     new_text = @quest_list_window.get_index_info
  564.     @quest_info_window.refresh(new_text)
  565.     # Execute transition
  566.     Graphics.transition
  567.     # Main loop
  568.     loop do
  569.       # Update game screen
  570.       Graphics.update
  571.       # Update input information
  572.       Input.update
  573.       # Frame update
  574.       update
  575.       # Abort loop if screen is changed
  576.       if $scene != self
  577.         break
  578.       end
  579.     end
  580.     # Prepare for transition
  581.     Graphics.freeze
  582.     # Dispose of windows
  583.     @quest_list_window.dispose
  584.     @quest_info_window.dispose
  585.  
  586.   end
  587.   #--------------------------------------------------------------------------
  588.   # * Frame Update
  589.   #--------------------------------------------------------------------------
  590.   def update
  591.     # Update windows
  592.     @quest_list_window.update
  593.     # If index has changed
  594.     if @list_index != @quest_list_window.index
  595.       # Redraw info window
  596.       new_text = @quest_list_window.get_index_info
  597.       @quest_info_window.refresh(new_text)
  598.       # Set index memory
  599.       @list_index = @quest_list_window.index
  600.     end
  601.     # When cancel
  602.     if Input.trigger?(Input::B)
  603.       # Play cancel SE
  604.       $game_system.se_play($data_system.cancel_se)
  605.       # Check what to return to
  606.       if @return_scene == Scene_Map
  607.         $scene = @return_scene.new
  608.       else
  609.         $scene = @return_scene.new(3)
  610.       end
  611.     end
  612.   end
  613. end
  614.  
  615. # Changes to Scene_Title
  616. class Scene_Title
  617.  
  618.   # Alias old method
  619.   alias mobius_command_new_game command_new_game
  620.   def command_new_game
  621.     # Call old method
  622.     mobius_command_new_game
  623.     # Initialize Game_Quests object
  624.     $game_quests = Game_Quests.new
  625.   end
  626. end
  627.  
  628. # Changes to Scene_Save
  629. class Scene_Save
  630.  
  631.   # Alias old method
  632.   alias mobius_write_save_data write_save_data
  633.   def write_save_data(file)
  634.     # Call old method
  635.     mobius_write_save_data(file)
  636.     # Dump Game_Quests object state to the save file
  637.     Marshal.dump($game_quests, file)
  638.   end
  639. end
  640.  
  641. # Changes to Scene_Load
  642. class Scene_Load
  643.  
  644.   # Alias old method
  645.   alias mobius_read_save_data read_save_data
  646.   def read_save_data(file)
  647.     # Call old method
  648.     mobius_read_save_data(file)
  649.     # Load Game_Quests object state from the save file
  650.     $game_quests = Marshal.load(file)
  651.   end
  652.  
  653. end
  654.  
  655. # Changes to Interpreter
  656. class Interpreter
  657.   # Create alias
  658.   alias mobius_command_121 command_121
  659.   #--------------------------------------------------------------------------
  660.   # * Control Switches
  661.   #--------------------------------------------------------------------------
  662.   def command_121
  663.     mobius_command_121
  664.     # Only do this is using switches/variables
  665.     if Mobius::Quests::USE_SWITCHES_VARIABLES
  666.       # Get first quest switch id
  667.       first = Mobius::Quests::FIRST_SWITCH_ID
  668.       # Loop for group control
  669.       for i in @parameters[0] .. @parameters[1]        
  670.         # If first id and chosen id have same parity
  671.         if (first % 2) == ( i % 2 )
  672.           # Determine corresponding quest id
  673.           id = ( i - first ) / 2
  674.         # If first id and chosen id have different parity
  675.         else
  676.           # Determine corresponding quest id
  677.           id = ( i - first - 1 ) / 2
  678.         end
  679.         $game_quests.data_check(id)      
  680.       end
  681.     end
  682.     # Continue
  683.     return true
  684.   end
  685.   # Create alias
  686.   alias mobius_command_122 command_122
  687.   #--------------------------------------------------------------------------
  688.   # * Control Variables
  689.   #--------------------------------------------------------------------------
  690.   def command_122
  691.     mobius_command_122
  692.     # Only do this is using switches/variables
  693.     if Mobius::Quests::USE_SWITCHES_VARIABLES
  694.       # Get first quest switch id
  695.       first = Mobius::Quests::FIRST_VARIABLE_ID
  696.       # Loop for group control
  697.       for i in @parameters[0] .. @parameters[1]        
  698.         # Determine corresponding quest id
  699.         id = ( i - first )
  700.         $game_quests.data_check(id)
  701.       end
  702.     end
  703.     # Continue
  704.     return true
  705.   end
  706. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement