daily pastebin goal
12%
SHARE
TWEET

IMPLEMENT

a guest Dec 31st, 2013 6 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================
  2. # ** Game_Quest
  3. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  4. #  Holds in-game data for a quest
  5. #==============================================================================
  6.  
  7. class Game_Quest
  8.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  9.   # * Public Instance Variables
  10.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  11.   attr_reader   :revealed_objectives # An array of revealed objectives
  12.   attr_reader   :complete_objectives # An array of completed objectives
  13.   attr_reader   :failed_objectives   # An array of failed objectives
  14.   attr_reader   :id                  # The ID in $game_party.quests
  15.   attr_reader   :name                # The name of the quest
  16.   attr_reader   :level               # The difficulty level of the quest
  17.   attr_accessor :banner              # Picture shown at top
  18.   attr_accessor :description         # A blurb explaining the quest
  19.   attr_accessor :client              # Name of quest-giver
  20.   attr_accessor :location            # Place to do the quest
  21.   attr_accessor :objectives          # An array of strings holding objectives
  22.   attr_accessor :prime_objectives    # An array of crucial objectives
  23.   attr_accessor :rewards             # An array of reward components
  24.   attr_accessor :common_event_id     # ID of common event called at completion
  25.   attr_accessor :icon_index          # The Icon associated with this quest
  26.   attr_accessor :custom_categories   # An array of category symbols
  27.   attr_accessor :reward_given        # A switch to ensure only one reward given
  28.   attr_accessor :concealed           # A switch to show or not show the quest
  29.   attr_accessor :cost                # The cost (if in a quest shop)
  30.   # Rewarded?
  31.   alias rewarded? reward_given
  32.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  33.   # * Object Initialization
  34.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  35.   def initialize (id, cost = -1)
  36.     @id = id
  37.     @cost = cost
  38.     reset
  39.   end
  40.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  41.   # * Reset
  42.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  43.   def reset
  44.     # Set variables to corresponding arguments
  45.     @banner, @name, @description, @client, @location, @objectives,
  46.       @prime_objectives, @rewards, @level, @common_event_id, @icon_index,
  47.       @custom_categories = QuestData.quest_data (id)
  48.     # Initialize non-public arrays
  49.     @revealed_objectives, @complete_objectives, @failed_objectives = [], [], []
  50.     @reward_given = false
  51.     @concealed = QuestData::MANUAL_REVEAL
  52.   end
  53.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  54.   # * Reveal Objective
  55.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  56.   def reveal_objective (*obj)
  57.     for i in obj do obj.delete (i) if i >= @objectives.size end
  58.     @revealed_objectives |= obj # Add to revealed objectives
  59.     @revealed_objectives.sort! # Sort from lowest index to highest index
  60.   end
  61.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  62.   # * Complete Objective
  63.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  64.   def complete_objective (*obj)
  65.     for i in obj
  66.       # Can't complete if failed or non-existent
  67.       obj.delete (i) if i >= @objectives.size || @failed_objectives.include? (i)
  68.       # Reveal the objective if it was not previously revealed
  69.       reveal_objective (i) unless @revealed_objectives.include? (i)
  70.     end
  71.     @complete_objectives |= obj # Add to complete objectives
  72.     @complete_objectives.sort! # Sort from lowest index to highest index
  73.     if complete?
  74.       $game_temp.common_event_id = @common_event_id # Call common event
  75.       @common_event_id = 0 # Don't call it again
  76.     end
  77.   end
  78.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  79.   # * Fail Objective
  80.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  81.   def fail_objective (*obj)
  82.     for i in obj
  83.       obj.delete (i) if i >= @objectives.size
  84.       # Reveal the objective if it was not previously revealed
  85.       reveal_objective (i) unless @revealed_objectives.include? (i)
  86.     end
  87.     @failed_objectives |= obj # Add to revealed objectives
  88.     @failed_objectives.sort! # Sort from lowest index to highest index
  89.   end
  90.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  91.   # * Undo Objective operations
  92.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  93.   def conceal_objective (*obj)
  94.     obj.each { |index| @revealed_objectives.delete (index) }
  95.   end
  96.   def uncomplete_objective (*obj)
  97.     for i in obj do @complete_objectives.delete (i) end
  98.   end
  99.   def unfail_objective (*obj)
  100.     for i in obj do @failed_objectives.delete (i) end
  101.   end
  102.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  103.   # * Objective Status Checks
  104.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  105.   def objective_revealed? (*obj)
  106.     return (obj - @revealed_objectives).empty?
  107.   end
  108.   def objective_complete? (*obj)
  109.     return (obj - @complete_objectives).empty?
  110.   end
  111.   def objective_failed? (*obj)
  112.     return (obj - @failed_objectives).empty?
  113.   end
  114.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  115.   # * Complete?
  116.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  117.   def complete?
  118.     # Check if all prime objectives have been completed
  119.     return (@complete_objectives & @prime_objectives) == @prime_objectives
  120.   end
  121.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  122.   # * Failed?
  123.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  124.   def failed?
  125.     # Check if any prime objectives have been failed
  126.     return !(@failed_objectives & @prime_objectives).empty?
  127.   end
  128.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  129.   # * Set Sortable values
  130.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  131.   def name= (string)
  132.     @name = string
  133.     $game_party.quests.refresh_sort (:alphabet)
  134.   end
  135.   def level= (value)
  136.     @level = value
  137.     $game_party.quests.refresh_sort (:level)
  138.   end
  139.   def concealed= (value)
  140.     @concealed = value
  141.     value ? $game_party.quests.conceal_quest (id) : $game_party.quests.reveal_quest (id)
  142.   end
  143. end
  144.  
  145. #==============================================================================
  146. # ** Game_Quests
  147. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  148. #  This class handles Quests. It is a wrapper for the built-in class "Hash".
  149. # The instance of this class is accessed by $game_party.quests
  150. #==============================================================================
  151.  
  152. class Game_Quests
  153.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  154.   # * Object Initialization
  155.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  156.   def initialize
  157.     @data = {}
  158.     @id_sort = []
  159.     @revealed_sort = []
  160.     @alphabet_sort = []
  161.     @level_sort = []
  162.   end
  163.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  164.   # * Get Quest
  165.   #    quest_id : the ID of the quest
  166.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  167.   def [] (quest_id)
  168.     return Game_Quest.new (0) unless quest_id.is_a? (Integer)
  169.     if @data[quest_id] == nil
  170.       @data[quest_id] = Game_Quest.new (quest_id)
  171.       reveal_quest (quest_id) unless @data[quest_id].concealed
  172.     end
  173.     return @data[quest_id]
  174.   end
  175.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  176.   # * Get Quest List
  177.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  178.   def list
  179.     quest_list = []
  180.     type = $game_system.quest_sort_type.to_s
  181.     reverse = !(type.sub! (/reverse/i) { "" }).nil?
  182.     case type.to_sym
  183.     when :id
  184.       @id_sort.each { |id| quest_list.push (@data[id]) }
  185.     when :revealed
  186.       @revealed_sort.each { |id| quest_list.push (@data[id]) }
  187.     when :alphabet
  188.       @alphabet_sort.each { |id| quest_list.push (@data[id]) }
  189.     when :level
  190.       @level_sort.each { |id| quest_list.push (@data[id]) }
  191.     else
  192.       quest_list = @data.values
  193.     end
  194.     quest_list.each { |i| quest_list.delete (i) if i.concealed }
  195.     return reverse ? quest_list.reverse : quest_list
  196.   end
  197.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  198.   # * Get Completed Quest List
  199.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  200.   def completed_list
  201.     complete_quests = []
  202.     list.each { |i| complete_quests.push (i) if i.complete? }
  203.     return complete_quests
  204.   end
  205.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  206.   # * Get Failed Quest List
  207.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  208.   def failed_list
  209.     failed_quests = []
  210.     list.each { |i| failed_quests.push (i) if i.failed? }
  211.     return failed_quests
  212.   end
  213.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  214.   # * Get Active Quest List
  215.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  216.   def active_list
  217.     return list - failed_list - completed_list
  218.   end
  219.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  220.   # * Category List
  221.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  222.   def category_list (category)
  223.     case category
  224.     when :all then return list
  225.     when :active then return active_list
  226.     when :complete then return completed_list
  227.     when :failed then return failed_list
  228.     else
  229.       quest_list = []
  230.       list.each { |quest| quest_list.push (quest) if quest.custom_categories.include? (category) }
  231.       return quest_list
  232.     end
  233.   end
  234.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  235.   # * Get Location
  236.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  237.   def get_location (quest_id)
  238.     return nil, nil unless @data[quest_id]
  239.     # Check all categories
  240.     for i in 0...QuestData::CATEGORIES.size
  241.       index = category_list (QuestData::CATEGORIES[i]).index (@data[quest_id])
  242.       return i, index if index != nil
  243.     end
  244.     return nil, nil
  245.   end
  246.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  247.   # * Revealed?
  248.   #    quest_id : the ID of a checked quest
  249.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  250.   def revealed? (quest_id)
  251.     return !@data[quest_id].nil? && !@data[quest_id].concealed
  252.   end
  253.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  254.   # * Remove Quest
  255.   #    quest_id : the ID of the quest to delete
  256.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  257.   def remove (quest_id)
  258.     conceal_quest (quest_id)
  259.     @data.delete (quest_id)
  260.   end
  261.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  262.   # * Clear
  263.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  264.   def clear
  265.     @data.clear
  266.   end
  267.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  268.   # * Reveal Quest
  269.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  270.   def reveal_quest (quest_id)
  271.     return if !@data[quest_id] ||@id_sort.include? (quest_id)
  272.     $game_system.last_quest_id = quest_id # Open to this quest next time
  273.     # Save sorting order in separate arrays to avoid resorting every time
  274.     @revealed_sort.push (quest_id)
  275.     sorted = false
  276.     for i in 0...@id_sort.size
  277.       if @id_sort[i] > quest_id
  278.         @id_sort.insert (i, quest_id)
  279.         sorted = true
  280.         break
  281.       end
  282.     end
  283.     @id_sort.push (quest_id) unless sorted
  284.     sorted = false
  285.     for i in 0...@alphabet_sort.size
  286.       if @data[@alphabet_sort[i]].name.downcase > @data[quest_id].name.downcase
  287.         @alphabet_sort.insert (i, quest_id)
  288.         sorted = true
  289.         break
  290.       end
  291.     end
  292.     @alphabet_sort.push (quest_id) unless sorted
  293.     sorted = false
  294.     for i in 0...@level_sort.size
  295.       if @data[@level_sort[i]].level > @data[quest_id].level
  296.         @level_sort.insert (i, quest_id)
  297.         sorted = true
  298.         break
  299.       end
  300.     end
  301.     @level_sort.push (quest_id) unless sorted
  302.   end
  303.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  304.   # * Conceal Quest
  305.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  306.   def conceal_quest (quest_id)
  307.     [@revealed_sort, @alphabet_sort, @id_sort, @level_sort].each { |ary| ary.delete (quest_id) }
  308.   end
  309.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  310.   # * Refresh Sort ~ In case the name or level of a quest is changed
  311.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  312.   def refresh_sort (sort_type)
  313.     case sort_type
  314.     when :alphabet
  315.       s = @data.values.sort { |a, b| a.name.downcase <=> b.name.downcase }
  316.       @alphabet_sort.clear
  317.       s.each { |quest| @alphabet_sort.push (quest.id) }
  318.     when :level
  319.       s = @data.values.sort { |a, b| a.level <=> b.level }
  320.       @level_sort.clear
  321.       s.each { |quest| @level_sort.push (quest.id) }
  322.     end
  323.   end
  324. end
  325.  
  326. #==============================================================================
  327. # ** Game_Temp
  328. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  329. #  Summary of Changes:
  330. #    new instance variables - quest_shop_array, quest_shop_name
  331. #==============================================================================
  332.  
  333. class Game_Temp
  334.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  335.   # * Public Instance Variables
  336.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  337.   attr_accessor :quest_shop_array
  338.   attr_accessor :quest_shop_name
  339.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  340.   # * Object Initialization
  341.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  342.   alias maba_qjrnl_iniz_5uv1 initialize
  343.   def initialize (*args)
  344.     maba_qjrnl_iniz_5uv1 (*args)
  345.     @quest_shop_array = []
  346.     @quest_shop_name = QuestData::VOCAB_PURCHASE
  347.   end
  348. end
  349.  
  350. #==============================================================================
  351. # ** Game_System
  352. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  353. #  Summary of Changes:
  354. #    new instance variables - quest_disabled; qj_bg_picture; qj_bg_opacity;
  355. #      qj_windowskin; qj_window_opacity; last_quest_id
  356. #    aliased method - initialize
  357. #==============================================================================
  358.  
  359. class Game_System
  360.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  361.   # * Public Instance Variables
  362.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  363.   attr_reader   :quest_menuaccess  # Is it accessible through the menu
  364.   attr_accessor :quest_disabled    # Can you access quest journal at this time
  365.   attr_accessor :quest_keyaccess   # Is it accessible by key?
  366.   attr_accessor :quest_sort_type   # The type of sorting to use
  367.   attr_accessor :qj_bg_picture     # The filename of the background graphic
  368.   attr_accessor :qj_bg_opacity     # The opacity of the background picture
  369.   attr_accessor :qj_windowskin     # The skin of the windows in the quest scene
  370.   attr_accessor :qj_window_opacity # The opacity of windows in the quest scene
  371.   attr_accessor :last_quest_cat    # The last [category, index] of quest viewed
  372.   attr_accessor :last_quest_id     # The ID of the last quest viewed
  373.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  374.   # * Object Initialization
  375.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  376.   alias modlg_qstjrnl_iniz_4rd2 initialize
  377.   def initialize (*args)
  378.     # Run Original Method
  379.     modlg_qstjrnl_iniz_4rd2 (*args)
  380.     # Initialize new variables
  381.     @quest_menuaccess = QuestData::MENU_ACCESS
  382.     @quest_disabled = false
  383.     @quest_keyaccess = QuestData::KEY_ACCESS
  384.     @quest_sort_type = QuestData::SORT_TYPE
  385.     @qj_bg_picture = QuestData::BG_PICTURE
  386.     @qj_bg_opacity = QuestData::BG_OPACITY
  387.     @qj_windowskin = QuestData::WINDOWS_SKIN
  388.     @qj_window_opacity = QuestData::WINDOWS_OPACITY
  389.     @last_quest_cat = 0
  390.     @last_quest_id = 0
  391.   end
  392.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  393.   # * Set Quest Access
  394.   #    Not simply accessor so I could add in compatibility
  395.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  396.   def quest_menuaccess= (value)
  397.     @quest_menuaccess = value
  398.     # Full Status Menu / Phantasia-esque Compatibility
  399.     @fscms_command_list ? c = @fscms_command_list : (@tpcms_command_list ? c = @tpcms_command_list : return)
  400.     value ? (c.insert (QuestData::MENU_INDEX, :quest2) unless c.include? (:quest2)) :
  401.       c.delete (:quest2)
  402.   end
  403. end
  404.  
  405. #==============================================================================
  406. # ** Game_Party
  407. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  408. #  Summary of Changes:
  409. #    new instance variable - quests
  410. #    aliased method - initialize
  411. #==============================================================================
  412.  
  413. class Game_Party
  414.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  415.   # * Public Instance Variables
  416.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  417.   attr_reader   :quests
  418.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  419.   # * Object Initialization
  420.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  421.   alias modalg_qst_jrnl_party_init_quests initialize
  422.   def initialize
  423.     # Run Original Method
  424.     modalg_qst_jrnl_party_init_quests
  425.     # Initialize @quests
  426.     @quests = Game_Quests.new
  427.   end
  428. end
  429.  
  430. #==============================================================================
  431. # ** Game_Interpreter
  432. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  433. #  Summary of Changes:
  434. #    new method - change_quest_access; change_quest_background; remove_quest;
  435. #      quest; reveal_objective; conceal_objective; complete_objective;
  436. #      uncomplete_objective; fail_objective; unfail_objective; quest_revealed?;
  437. #      quest_complete?; quest_failed?; change_reward_status
  438. #==============================================================================
  439.  
  440. class Game_Interpreter
  441.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  442.   # * Call Quest Scene
  443.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  444.   def call_quest (quest_id = 0)
  445.     Sound.play_decision
  446.     $game_system.last_quest_id = quest_id if quest_id != 0 && quest_revealed? (quest_id)
  447.     $game_temp.next_scene = "quest"
  448.   end
  449.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  450.   # * Call Quest Shop
  451.   #    quest_array : a series of arrays in form [a, b, [c1, c2, ..., cn], d]
  452.   #      a is the Quest ID; b is the Purchase Cost; [c1, ..., cn] is a list
  453.   #      of which objectives are revealed when the quest is bought (it can be
  454.   #      excluded and if so, then it will reveal them all); d is the ID of an
  455.   #      enabling switch, meaning it will only show up if that switch is ON
  456.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  457.   def call_quest_shop (quest_array, shop_name = QuestData::VOCAB_PURCHASE)
  458.     $game_temp.next_scene = "quest shop"
  459.     $game_temp.quest_shop_array = quest_array
  460.     $game_temp.quest_shop_name = shop_name
  461.   end
  462.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  463.   # * Change Quest Access
  464.   #    sym - :enable, :disable, :enable_menu, :disable_menu, :enable_map, or
  465.   #     :disable_map
  466.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  467.   def change_quest_access (sym)
  468.     case sym
  469.     when :enable then $game_system.quest_disabled = false
  470.     when :disable then $game_system.quest_disabled = true
  471.     when :enable_menu then $game_system.quest_menuaccess = true
  472.     when :disable_menu then $game_system.quest_menuaccess = false
  473.     when :enable_map then $game_system.quest_keyaccess = true
  474.     when :disable_map then $game_system.quest_keyaccess = false
  475.     end
  476.   end
  477.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  478.   # * Change Quest Background
  479.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  480.   def change_quest_background (picture, opacity = $game_system.qj_bg_opacity)
  481.     $game_system.qj_bg_picture = picture
  482.     $game_system.qj_bg_opacity = opacity
  483.   end
  484.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  485.   # * Change Quest Windows
  486.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  487.   def change_quest_windows (skin, opacity = $game_system.qj_window_opacity)
  488.     $game_system.qj_windowskin = skin
  489.     $game_system.qj_window_opacity = opacity
  490.   end
  491.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  492.   # * Reset Quest
  493.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  494.   def reset_quest (id)
  495.     quest (id).reset
  496.   end
  497.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  498.   # * Remove Quest
  499.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  500.   def remove_quest (id)
  501.     $game_party.quests.remove (id)
  502.   end
  503.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  504.   # * Reveal/Conceal Quest
  505.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  506.   def reveal_quest (id)
  507.     $game_party.quests[id].concealed = false
  508.   end
  509.   def conceal_quest (id)
  510.     $game_party.quests[id].concealed = true
  511.   end
  512.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  513.   # * Quest
  514.   #    id : Returns the quest object with that ID
  515.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  516.   def quest (id)
  517.     return $game_party.quests[id]
  518.   end
  519.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  520.   # * Quest Revealed?
  521.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  522.   def quest_revealed? (id)
  523.     return $game_party.quests.revealed? (id)
  524.   end
  525.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  526.   # * Facade for Quest methods:
  527.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  528.   [:reveal_objective, :conceal_objective, :complete_objective,
  529.    :uncomplete_objective, :fail_objective, :unfail_objective].each { |method|
  530.     define_method (method) { |id, *obj| quest (id).send (method, *obj) }
  531.   }
  532.   [:objective_revealed?, :objective_complete?, :objective_failed?].each { |method|
  533.     define_method (method) { |id, *obj| quest_revealed? (id) && quest (id).send (method, *obj) }
  534.   }
  535.   [:reset, :complete?, :rewarded?, :failed?].each { |method|
  536.     define_method ("quest_#{method}".to_sym) { |id| quest_revealed? (id) && quest (id).send (method) }
  537.   }
  538.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  539.   # * Give Quest Reward
  540.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  541.   def give_quest_reward (quest_id)
  542.     return false if !quest_complete? (quest_id) || quest_rewarded? (quest_id)
  543.     params = @params.dup
  544.     (quest (quest_id)).rewards.each { |reward|
  545.       next unless reward.is_a? (Array)
  546.       @params = [reward[1], 0, 0, (reward[2] ? reward[2] : 1)]
  547.       case reward[0]
  548.       when 0 then command_126 # Item
  549.       when 1 then command_127 # Weapon
  550.       when 2 then command_128 # Armor
  551.       when 3 # Gold
  552.         @params = [0, 0, reward[1]]
  553.         command_125
  554.       when 4 # Experience
  555.         @params = [0, 0, 0, reward[1], true]
  556.         command_315
  557.       end
  558.     }
  559.     @params = params
  560.     change_reward_status (quest_id, true)
  561.     return true
  562.   end
  563.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  564.   # * Change Reward Status
  565.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  566.   def change_reward_status (id, value = true)
  567.     quest (id).reward_given = value
  568.   end
  569. end
  570.  
  571. #==============================================================================
  572. # ** Window_Base
  573. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  574. #  Summary of Changes:
  575. #    aliased method - text_color
  576. #==============================================================================
  577.  
  578. class Window_Base
  579.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  580.   # * Text Color
  581.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  582.   alias malbr_questj2_txtcol_5rf1 text_color
  583.   def text_color (color, *args)
  584.     return ( color.is_a? (Array) ? Color.new (*color) :  malbr_questj2_txtcol_5rf1 (color, *args) )
  585.   end
  586. end
  587.  
  588. #==============================================================================
  589. # ** Window_Message
  590. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  591. #  Summary of Changes:
  592. #    aliased method - convert_special_characters
  593. #==============================================================================
  594.  
  595. class Window_Message
  596.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  597.   # * Convert Special Characters
  598.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  599.   alias ma_qstjrnl_cnvrtspecnq_6yh2 convert_special_characters
  600.   def convert_special_characters (*args)
  601.     # Run Original Method
  602.     ma_qstjrnl_cnvrtspecnq_6yh2 (*args)
  603.     @text.gsub! (/\\NQ\[(\d+)\]/i) { $game_party.quests[$1.to_i].name } # Name Quest
  604.   end
  605. end
  606.  
  607. if Object.const_defined? (:Paragrapher) && Paragrapher.const_defined? (:Formatter_SpecialCodes)
  608.   class Paragrapher::Formatter_SpecialCodes
  609.     alias mlg_qstj_prfrmsub_5th2 perform_substitution
  610.     def perform_substitution (*args)
  611.       text = mlg_qstj_prfrmsub_5th2 (*args)
  612.       text.gsub! (/\\NQ\[(\d+)\]/i) { $game_party.quests[$1.to_i].name } # Monster Name
  613.       return text
  614.     end
  615.   end
  616. end
  617.  
  618. #==============================================================================
  619. # ** Window_QuestLabel
  620. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  621. #  This window shows the quest label at the top of the scene
  622. #==============================================================================
  623.  
  624. class Window_QuestLabel < Window_Base
  625.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  626.   # * Object Initialization
  627.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  628.   def initialize (width = QuestData::LIST_WIDTH, height = 32 + WLH, text = QuestData::VOCAB_QUESTS)
  629.     super (0, 0, width, height)
  630.     self.windowskin = Cache.system ($game_system.qj_windowskin)
  631.     self.opacity = $game_system.qj_window_opacity
  632.     # Draw contents
  633.     self.contents.font.name = QuestData::LABEL_FONTNAME unless QuestData::LABEL_FONTNAME.empty?
  634.     if QuestData::LABEL_FONTSIZE == 0
  635.       self.contents.font.size = [height - 36, 28].min
  636.       # Fit it by width
  637.       while (contents.text_size (text).width > contents.width) && contents.font.size > Font.default_size
  638.         contents.font.size -= 1
  639.       end
  640.     else
  641.       contents.font.size = QuestData::LABEL_FONTSIZE
  642.     end
  643.     self.contents.font.bold = QuestData::LABEL_BOLD
  644.     self.contents.font.color = text_color (QuestData::COLOURS[:label])
  645.     self.contents.draw_text (contents.rect, text, 1)
  646.   end
  647. end
  648.  
  649. #==============================================================================
  650. # ** Window_QuestPurchaseGold
  651. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  652. #  This is the gold window for the Quest Purchase scene
  653. #==============================================================================
  654.  
  655. class Window_QuestPurchaseGold < Window_Base
  656.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  657.   # * Object Initialization
  658.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  659.   def initialize (y, width = QuestData::PURCHASE_LIST_WIDTH)
  660.     super (0, y, width, 32 + WLH)
  661.     self.windowskin = Cache.system ($game_system.qj_windowskin)
  662.     self.opacity = $game_system.qj_window_opacity
  663.     refresh
  664.   end
  665.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  666.   # * Refresh
  667.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  668.   def refresh
  669.     self.contents.clear
  670.     if QuestData::PURCHASE_USE_GOLD_ICON
  671.       draw_icon (QuestData::ICONS[:gold], 0, 0)
  672.       x = 28
  673.     else
  674.       x = 4
  675.     end
  676.     draw_currency_value ($game_party.gold, x, 0, contents.width - x)
  677.   end
  678. end
  679.  
  680. #==============================================================================
  681. # ** Window_QuestCategory
  682. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  683. #  This window allows you to select between which list to show
  684. #==============================================================================
  685.  
  686. class Window_QuestCategory < Window_Base
  687.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  688.   # * Object Initialization
  689.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  690.   def initialize (category_index = 0, width = QuestData::LIST_WIDTH)
  691.     hght = 56
  692.     @all_index = QuestData::CATEGORIES.index (:all)
  693.     hght += 8 if @all_index && QuestData::ICONS[:all] == 0
  694.     super (0, WLH + 32, width, hght)
  695.     self.windowskin = Cache.system ($game_system.qj_windowskin)
  696.     self.opacity = $game_system.qj_window_opacity
  697.     total = 24*QuestData::CATEGORIES.size
  698.     total += 16 if hght == 64
  699.     @spacing = (contents.width - total) / (QuestData::CATEGORIES.size - 1)
  700.     refresh (category_index)
  701.   end
  702.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  703.   # * Refresh
  704.   #    category_index : icon to highlight -
  705.   #                       0 => All, 1 => Active, 2 => Complete, 3 => Failed
  706.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  707.   def refresh (category_index = 0)
  708.     contents.clear
  709.     for i in 0...QuestData::CATEGORIES.size
  710.       draw_item (i, i == category_index)
  711.     end
  712.   end
  713.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  714.   # * Draw Category
  715.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  716.   def draw_item (index, enabled = false)
  717.     x = index*(24 + @spacing)
  718.     x += 16 if @all_index && index > @all_index && contents.height == 32
  719.     category = QuestData::CATEGORIES[index]
  720.     if @all_index != index || contents.height == 24
  721.       y = (contents.height == 32 ? 4 : 0)
  722.       self.contents.clear_rect (x, y, 24, 24)
  723.       draw_icon (QuestData::ICONS[category], x, y, enabled)
  724.     else
  725.       self.contents.clear_rect (x, 0, 40, 32)
  726.       draw_icon (QuestData::ICONS[:complete], x, 0, enabled)
  727.       draw_icon (QuestData::ICONS[:failed], x + 16, 0, enabled)
  728.       draw_icon (QuestData::ICONS[:active], x + 8, 8, enabled)
  729.     end
  730.   end
  731. end
  732.  
  733. #==============================================================================
  734. # ** Window_QuestList
  735. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  736. #  This window shows a list of quests
  737. #==============================================================================
  738.  
  739. class Window_QuestList < Window_Command
  740.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  741.   # * Object Initialization
  742.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  743.   def initialize (free, width = QuestData::LIST_WIDTH, category = QuestData::CATEGORIES[0], quest_index = 0)
  744.     super (width, [], 1, free / WLH)
  745.     change_list (category)
  746.     self.windowskin = Cache.system ($game_system.qj_windowskin)
  747.     self.opacity = $game_system.qj_window_opacity
  748.     self.index = quest_index
  749.   end
  750.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  751.   # * Change List
  752.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  753.   def change_list (list_type)
  754.     if list_type.is_a? (Array)
  755.       @commands = list_type # List passed directly
  756.     else
  757.       @commands = $game_party.quests.category_list (list_type)
  758.       @commands = [] if @commands.nil?
  759.     end
  760.     @item_max = @commands.size
  761.     self.contents = Bitmap.new (contents.width, [self.height - 32, @item_max*WLH].max)
  762.     self.index = 0
  763.     refresh
  764.   end
  765.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  766.   # * Quest
  767.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  768.   def quest
  769.     return @commands[self.index]
  770.   end
  771.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  772.   # * Draw Item
  773.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  774.   def draw_item(index, enabled = true)
  775.     rect = item_rect(index)
  776.     self.contents.clear_rect(rect)
  777.     self.contents.font.color.alpha = (enabled ? 255 : 128)
  778.     quest = @commands[index]
  779.     draw_icon (quest.icon_index, rect.x, rect.y, enabled)
  780.     rect.x += 28
  781.     rect.width -= 28
  782.     if quest.cost > -1 # Draw the quest's cost if > -1
  783.       self.contents.font.color = text_color (QuestData::COLOURS[:active])
  784.       self.contents.draw_text (rect, quest.cost.to_s, 2)
  785.       rect.width -= (self.contents.text_size (quest.cost.to_s).width + 6)
  786.     else
  787.       self.contents.font.color = text_color (quest.complete? ?
  788.         QuestData::COLOURS[:complete] : (quest.failed? ?
  789.         QuestData::COLOURS[:failed] : QuestData::COLOURS[:active]))
  790.     end
  791.     self.contents.draw_text(rect, quest.name)
  792.   end
  793. end
  794.  
  795. #==============================================================================
  796. # ** Window QuestInfo
  797. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  798. #  This window shows the details of each quest
  799. #==============================================================================
  800.  
  801. class Window_QuestInfo < Window_Base
  802.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  803.   # * Object Initialization
  804.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  805.   def initialize (height = Graphics.height - (32 + WLH), x = QuestData::LIST_WIDTH, layout = QuestData::INFO_LAYOUT)
  806.     super (x, 0, Graphics.width - x, height)
  807.     @layout = layout
  808.     self.windowskin = Cache.system ($game_system.qj_windowskin)
  809.     self.opacity = $game_system.qj_window_opacity
  810.   end
  811.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  812.   # * Refresh
  813.   #    quest : the Quest object to show
  814.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  815.   def refresh (quest)
  816.     contents.clear
  817.     if quest.nil?
  818.       create_contents
  819.       return
  820.     end
  821.     @quest = quest
  822.     # Get the Paragrapher
  823.     if !Object.const_defined? (:Paragrapher) || !Paragrapher.const_defined? (:Formatter)
  824.       p "This script requires the Paragraph Formatter 2.0! You can get it at RMRK:",
  825.       "    http://rmrk.net/index.php/topic,25129.0.html", "The Special Codes Formatter is supported, but you still need the base script."
  826.     else
  827.       if Paragrapher.const_defined? (:Formatter_SpecialCodes)
  828.         @paragrapher = Paragrapher.new (Paragrapher::Formatter_SpecialCodes.new, Paragrapher::Artist_SpecialCodes.new)
  829.       else
  830.         @paragrapher = Paragrapher.new (contents.paragraph_formatter, contents.paragraph_artist)
  831.       end
  832.     end
  833.     # Calculate the size of the bitmap
  834.     h = 0
  835.     set_font (0)
  836.     for subtitle in @layout do h += calculate_height_req (subtitle) end
  837.     self.contents = Bitmap.new (contents.width, [h, self.height - 32].max)
  838.     # Draw everything in the specified order
  839.     y = 0
  840.     for subtitle in @layout
  841.       if subtitle.is_a? (Array)
  842.         max_y = y
  843.         # Draw on same line if an array
  844.         for i in subtitle
  845.           y_plus = draw_section (i, y) # Don't track since on same line
  846.           max_y = y_plus if y_plus > max_y
  847.         end
  848.         y = max_y
  849.       else
  850.         y = draw_section (subtitle, y)
  851.       end
  852.     end
  853.   end
  854.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  855.   # * Calculate Height Requirement
  856.   #    section : a symbol for the heading it is asking about
  857.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  858.   def calculate_height_req (section)
  859.     # Calculate the amount of vertical space needed for each section
  860.     case section
  861.     when Array then calculate_height_req(section.max { |a, b|
  862.         calculate_height_req(a) <=> calculate_height_req(b) })
  863.     when :banner then return Cache.picture (@quest.banner).height unless @quest.banner.empty?
  864.     when :name then return WLH unless @quest.name.empty?
  865.     when :level then return WLH unless @quest.level <= 0
  866.     when :client then return WLH unless @quest.client.empty?
  867.     when :location then return WLH unless @quest.location.empty?
  868.     when :description
  869.       if @paragrapher && !@quest.description.empty?
  870.         # Create formatted text object for the description & check total size
  871.         bmp = Bitmap.new (contents.width - 16, WLH)
  872.         bmp.font = contents.font.dup
  873.         bmp.font.size = QuestData::DESC_FONTSIZE
  874.         @desc_ft = @paragrapher.formatter.format (@quest.description, bmp)
  875.         return (@desc_ft.lines.size*bmp.font.size) + ((3*WLH) / 2) + 4
  876.       end
  877.     when :objectives
  878.       if @paragrapher && !@quest.revealed_objectives.empty?
  879.         # Create formatted text objects for the objectives & check total size
  880.         tw = self.contents.text_size (QuestData::OBJECTIVE_BULLET).width
  881.         bmp = Bitmap.new (contents.width - 12 - tw, WLH)
  882.         bmp.font = contents.font.dup
  883.         bmp.font.size = QuestData::OBJ_FONTSIZE
  884.         h = WLH
  885.         @objs_ft = []
  886.         for i in @quest.revealed_objectives
  887.           ft = @paragrapher.formatter.format (@quest.objectives[i], bmp)
  888.           h += (ft.lines.size * bmp.font.size) + 2
  889.           @objs_ft.push (ft)
  890.         end
  891.         return h + 2
  892.       end
  893.     when :rewards then return WLH*(@quest.rewards.size + 1) unless @quest.rewards.empty?
  894.     end
  895.     return 0
  896.   end
  897.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  898.   # * Draw Section
  899.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  900.   def draw_section (section, y)
  901.     set_font (0)
  902.     case section
  903.     when :banner then y = draw_banner (y)
  904.     when :name then y = draw_name (y)
  905.     when :level then y = draw_level (y)
  906.     when :client then y = draw_client (y)
  907.     when :location then y = draw_location (y)
  908.     when :description then y = draw_description (y)
  909.     when :objectives then y = draw_objectives (y)
  910.     when :rewards then y = draw_rewards (y)
  911.     end
  912.     return y
  913.   end
  914.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  915.   # * Draw Banner
  916.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  917.   def draw_banner (y)
  918.     return y if @quest.banner.empty?
  919.     banner = Cache.picture (@quest.banner)
  920.     self.contents.blt ((contents.width - banner.width) / 2, y, banner, banner.rect)
  921.     return y + banner.height
  922.   end
  923.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  924.   # * Draw Name
  925.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  926.   def draw_name (y)
  927.     return y if @quest.name.empty?
  928.     self.contents.font.name = QuestData::NAME_FONTNAME.empty? ? Font.default_name : QuestData::NAME_FONTNAME
  929.     self.contents.font.size = QuestData::NAME_FONTSIZE == 0 ? Font.default_size : QuestData::NAME_FONTSIZE
  930.     self.contents.font.bold = QuestData::NAME_BOLD
  931.     self.contents.font.color = text_color (@quest.complete? ?
  932.       QuestData::COLOURS[:complete] : (@quest.failed? ?
  933.       QuestData::COLOURS[:failed] : QuestData::COLOURS[:active]))
  934.     self.contents.draw_text (0, y, self.contents.width, WLH, @quest.name, 1)
  935.     return y + WLH
  936.   end
  937.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  938.   # * Draw Level
  939.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  940.   def draw_level (y)
  941.     return y if @quest.level < 1
  942.     if QuestData::ICONS[:level] != 0
  943.       x = self.contents.width - 24
  944.       @quest.level.times do
  945.         draw_icon (QuestData::ICONS[:level], x, y)
  946.         x -= QuestData::LEVEL_SPACE
  947.       end
  948.     else
  949.       set_font (1)
  950.       self.contents.draw_text (0, y, contents.width, WLH, @quest.level.to_s, 2)
  951.     end
  952.     return y + WLH
  953.   end
  954.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  955.   # * Draw Client
  956.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  957.   def draw_client (y)
  958.     return y if @quest.client.empty?
  959.     x = 0
  960.     if QuestData::ICONS[:client] != 0
  961.       draw_icon (QuestData::ICONS[:client], x, y)
  962.       x += 28
  963.     end
  964.     if !QuestData::VOCAB_CLIENT.empty?
  965.       set_font (1)
  966.       self.contents.draw_text (x, y, 80, WLH, QuestData::VOCAB_CLIENT)
  967.       x += 80
  968.     end
  969.     set_font (0)
  970.     wdth = QuestData::CLIENT_WIDTH == 0 ? (contents.width - ((5*QuestData::LEVEL_SPACE) + 8)) : QuestData::CLIENT_WIDTH
  971.     self.contents.draw_text (x, y, wdth -  x, WLH, @quest.client, 2)
  972.     return y + WLH
  973.   end
  974.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  975.   # * Draw Location
  976.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  977.   def draw_location (y)
  978.     return y if @quest.location.empty?
  979.     x = 0
  980.     if QuestData::ICONS[:location] != 0
  981.       draw_icon (QuestData::ICONS[:location], x, y)
  982.       x += 28
  983.     end
  984.     if !QuestData::VOCAB_LOCATION.empty?
  985.       set_font (1)
  986.       self.contents.draw_text (x, y, 80, WLH, QuestData::VOCAB_LOCATION)
  987.       x += 80
  988.     end
  989.     set_font (0)
  990.     wdth = QuestData::LOCATION_WIDTH == 0 ? (contents.width - ((5*QuestData::LEVEL_SPACE) + 8)) : QuestData::LOCATION_WIDTH
  991.     self.contents.draw_text (x, y, wdth - x, WLH, @quest.location, 2)
  992.     return y + WLH
  993.   end
  994.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  995.   # * Draw Description
  996.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  997.   def draw_description (y)
  998.     return y if !@paragrapher || @quest.description.empty?
  999.     # Setup the bitmap of appropriate size for drawing the description
  1000.     hght = @desc_ft.lines.size * @desc_ft.bitmap.font.size
  1001.     font = @desc_ft.bitmap.font.dup
  1002.     @desc_ft.bitmap.dispose
  1003.     @desc_ft.bitmap = Bitmap.new (self.contents.width, hght)
  1004.     @desc_ft.bitmap.font = font
  1005.     set_font (1)
  1006.     rect = Rect.new (2, y + (WLH / 2), self.contents.width - 4, hght + WLH)
  1007.     rect2 = Rect.new (4, y + (WLH / 2) + 2, self.contents.width - 8, hght + WLH - 4)
  1008.     # Make Box
  1009.     if Bitmap.method_defined? (:fill_rounded_rect) # Bitmap Addons
  1010.       self.contents.fill_rounded_rect (rect, self.contents.font.color)
  1011.       self.contents.fill_rounded_rect (rect2, Color.new (0, 0, 0, 0))
  1012.     else
  1013.       self.contents.fill_rect (rect, self.contents.font.color)
  1014.       self.contents.clear_rect (rect2)
  1015.     end
  1016.     # Clear rect for the Description Label
  1017.     tw = self.contents.text_size (QuestData::VOCAB_DESCRIPTION).width
  1018.     self.contents.clear_rect (32, y, tw + 4, WLH)
  1019.     # Draw Description Label
  1020.     self.contents.draw_text (34, y, tw + 2, WLH, QuestData::VOCAB_DESCRIPTION)
  1021.     set_font (0)
  1022.     # Draw Description paragraph
  1023.     @paragrapher.artist.draw (@desc_ft, QuestData::JUSTIFY_PARAGRAPHS)
  1024.     self.contents.blt (8, y + WLH, @desc_ft.bitmap, @desc_ft.bitmap.rect)
  1025.     @desc_ft.bitmap.dispose
  1026.     @desc_ft = nil
  1027.     return rect.y + rect.height + 4
  1028.   end
  1029.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1030.   # * Draw Objectives
  1031.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1032.   def draw_objectives (y)
  1033.     return y if !@paragrapher || @quest.revealed_objectives.empty?
  1034.     set_font (1)
  1035.     self.contents.draw_text (32, y, contents.width - 32, WLH, QuestData::VOCAB_OBJECTIVES)
  1036.     tw = self.contents.text_size (QuestData::OBJECTIVE_BULLET).width
  1037.     y += WLH
  1038.     bmp = @objs_ft[0].bitmap
  1039.     for i in 0...@quest.revealed_objectives.size
  1040.       # Draw Bullet
  1041.       set_font (1)
  1042.       self.contents.draw_text (8, y, tw, WLH, QuestData::OBJECTIVE_BULLET)
  1043.       set_font (0)
  1044.       ft = @objs_ft[i]
  1045.       ft.bitmap = Bitmap.new (contents.width, ft.lines.size*bmp.font.size)
  1046.       ft.bitmap.font = bmp.font.dup
  1047.       obj = @quest.revealed_objectives[i]
  1048.       # Get the correct color
  1049.       ft.bitmap.font.color = text_color (@quest.objective_complete? (obj) ?
  1050.         QuestData::COLOURS[:complete] : (@quest.objective_failed? (obj) ?
  1051.         QuestData::COLOURS[:failed] : QuestData::COLOURS[:active]))
  1052.       @paragrapher.artist.draw (ft, QuestData::JUSTIFY_PARAGRAPHS)
  1053.       self.contents.blt (12 + tw, y + 2, ft.bitmap, ft.bitmap.rect)
  1054.       # Modify the Y accordingly
  1055.       y += 2 + ((ft.bitmap.font.size)*ft.lines.size)
  1056.       ft.bitmap.dispose
  1057.     end
  1058.     bmp.dispose
  1059.     @objs_ft.clear
  1060.     return y + 2
  1061.   end
  1062.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1063.   # * Draw Rewards
  1064.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1065.   def draw_rewards (y)
  1066.     return y if @quest.rewards.empty?
  1067.     set_font (1)
  1068.     self.contents.draw_text (32, y, contents.width - 32, WLH, QuestData::VOCAB_REWARDS)
  1069.     x = QuestData::REWARD_BULLET.empty? ? 8 : 12 + (contents.text_size (QuestData::REWARD_BULLET).width)
  1070.     y += WLH
  1071.     for reward in @quest.rewards
  1072.       # Draw Bullet
  1073.       set_font (1)
  1074.       self.contents.draw_text (8, y, 100, WLH, QuestData::REWARD_BULLET)
  1075.       set_font (0)
  1076.       self.contents.font.size = QuestData::REWARD_FONTSIZE
  1077.       if reward.is_a? (Array)
  1078.         item = nil
  1079.         case reward[0]
  1080.         when 0 then item = $data_items[reward[1]]
  1081.         when 1 then item = $data_weapons[reward[1]]
  1082.         when 2 then item = $data_armors[reward[1]]
  1083.         when 3 # Gold
  1084.           draw_icon (QuestData::ICONS[:gold], x, y)
  1085.           self.contents.font.color = normal_color
  1086.           self.contents.draw_text (x + 24, y, contents.width - x - 24, WLH, reward[1].to_s)
  1087.           if QuestData::DRAW_VOCAB_GOLD
  1088.             tw = self.contents.text_size(reward[1].to_s).width
  1089.             self.contents.font.color = system_color
  1090.             self.contents.draw_text(x + tw + 28, y, contents.width - x - 28 - tw, WLH, Vocab::gold)
  1091.           end
  1092.         when 4 # Exp
  1093.           draw_icon (QuestData::ICONS[:exp], x, y)
  1094.           self.contents.font.color = normal_color
  1095.           self.contents.draw_text (x + 24, y, contents.width - x - 24, WLH, reward[1].to_s)
  1096.           tw = self.contents.text_size(reward[1].to_s).width
  1097.           self.contents.font.color = system_color
  1098.           self.contents.draw_text(x + tw + 28, y, contents.width - x - 28 - tw, WLH, QuestData::VOCAB_EXP)
  1099.         end
  1100.         # Draw Item
  1101.         if item != nil
  1102.           draw_item_name (item, x, y)
  1103.           unless reward[2].nil? # Draw Number
  1104.             contents.font.color = system_color
  1105.             tw = contents.text_size (item.name).width + 28
  1106.             contents.draw_text (x + tw, y, 100, WLH, "#{QuestData::ITEM_NUMBER_PREFACE}#{reward[2]}")
  1107.           end
  1108.         end
  1109.       else
  1110.         set_font (0)
  1111.         # Allow use of special codes if Special Codes Formatter available
  1112.         if Object.const_defined? (:Paragrapher) && Paragrapher.const_defined? (:Formatter_SpecialCodes)
  1113.           bmp = Bitmap.new (contents.width - x, WLH)
  1114.           bmp.font = contents.font.dup
  1115.           bmp.font.size = QuestData::REWARD_FONTSIZE
  1116.           @paragrapher.paragraph (reward, bmp)
  1117.           self.contents.blt (x, y, bmp, bmp.rect)
  1118.           bmp.dispose
  1119.         else
  1120.           self.contents.draw_text (x, y, contents.width - x, WLH, reward)
  1121.         end
  1122.       end
  1123.       y += WLH
  1124.     end
  1125.     return y
  1126.   end
  1127.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1128.   # * Reset Font
  1129.   #    0 => Content Font; 1 => Subtitle Font
  1130.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1131.   def set_font (type = 0)
  1132.     case type
  1133.     when 0 # Content
  1134.       self.contents.font.name = QuestData::CONTENT_FONTNAME.empty? ? Font.default_name : QuestData::CONTENT_FONTNAME
  1135.       self.contents.font.size = Font.default_size
  1136.       self.contents.font.bold = false
  1137.       self.contents.font.color = normal_color
  1138.     when 1 # Subtitle
  1139.       self.contents.font.name = QuestData::SUBTITLE_FONTNAME.empty? ? Font.default_name : QuestData::SUBTITLE_FONTNAME
  1140.       self.contents.font.size = QuestData::SUBTITLE_FONTSIZE == 0 ? Font.default_size : QuestData::SUBTITLE_FONTSIZE
  1141.       self.contents.font.bold = QuestData::SUBTITLE_BOLD
  1142.       self.contents.font.color = system_color
  1143.     end
  1144.   end
  1145.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1146.   # * Colors
  1147.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1148.   def normal_color
  1149.     return text_color (QuestData::COLOURS[:content])
  1150.   end
  1151.   def system_color
  1152.     return text_color (QuestData::COLOURS[:subtitle])
  1153.   end
  1154.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1155.   # * Frame Update
  1156.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1157.   def update
  1158.     if Input.press? (Input::DOWN)
  1159.       self.oy = [self.oy + 3, contents.height - self.height + 32].min
  1160.     elsif Input.press? (Input::UP)
  1161.       self.oy = [self.oy - 3, 0].max
  1162.     end
  1163.   end
  1164. end
  1165.  
  1166. #==============================================================================
  1167. # ** Scene_Map
  1168. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1169. #  Summary of Changes:
  1170. #    aliased method - update
  1171. #==============================================================================
  1172.  
  1173.   class Scene_Map < Scene_Base
  1174.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1175.   # * Frame Update
  1176.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1177.   alias ma_qj2_keyaces_upd_6yc1 update
  1178.   def update (*args)
  1179.     ma_qj2_keyaces_upd_6yc1 (*args)
  1180.     # If the quest log can be accessed by key and is not empty or disabled
  1181.     if $game_system.quest_keyaccess && Input.trigger? (QuestData::MAPKEY_BUTTON)
  1182.       if $game_system.quest_disabled || $game_party.quests.list.empty?
  1183.         Sound.play_buzzer
  1184.       else
  1185.         Sound.play_decision
  1186.         $game_temp.next_scene = "quest"
  1187.       end
  1188.     end
  1189.   end
  1190.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1191.   # * Execute Screen Switch
  1192.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1193.   alias malb_questj_updscene_5tg2 update_scene_change
  1194.   def update_scene_change (*args)
  1195.     scene_call = $game_temp.next_scene
  1196.     malb_questj_updscene_5tg2 (*args) # Run Original Method
  1197.     # This check first ensures that the scene call was not prevented by external
  1198.     #  factors, like the player moving, then checks to see if it was quest. I
  1199.     #  do it like this to ensure that it doesn't open at weird times (like while
  1200.     #  the message box is open
  1201.     if $game_temp.next_scene.nil? && !scene_call.nil?
  1202.       case scene_call
  1203.       when "quest"
  1204.         $scene = Scene_Quest.new
  1205.       when "quest shop"
  1206.         $scene = Scene_QuestPurchase.new ($game_temp.quest_shop_array, $game_temp.quest_shop_name)
  1207.       end
  1208.     end
  1209.   end
  1210. end
  1211.  
  1212. #==============================================================================
  1213. # ** Scene Quest
  1214. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1215. #  This class handles the quest scene processing
  1216. #==============================================================================
  1217.  
  1218. class Scene_Quest < Scene_Base
  1219.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1220.   # * Object Initialization
  1221.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1222.   def initialize (*args)
  1223.     if args.size == 0 # Last Quest ID
  1224.       cat_ind = $game_system.last_quest_cat
  1225.       cat = QuestData::CATEGORIES[cat_ind]
  1226.       ind = ($game_party.quests.category_list (cat)).index ($game_party.quests[$game_system.last_quest_id])
  1227.       if !ind.nil?
  1228.         @category_index, @quest_index = cat_ind, ind
  1229.       else
  1230.         @category_index, @quest_index = $game_party.quests.get_location ($game_system.last_quest_id)
  1231.       end
  1232.     else
  1233.       @category_index = args[0] < QuestData::CATEGORIES.size ? args[0] : 0
  1234.       @quest_index = args[1]
  1235.     end
  1236.     @category_index = 0 if @category_index.nil?
  1237.     @quest_index = 0 if @quest_index.nil?
  1238.     @info_window_active = false
  1239.     @from_menu = $scene.is_a? (Scene_Menu)
  1240.   end
  1241.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1242.   # * Start Processing
  1243.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1244.   def start
  1245.     super
  1246.     create_menu_background
  1247.     # Create Background picture
  1248.     unless $game_system.qj_bg_picture.empty?
  1249.       @bg_sprite = Sprite.new
  1250.       @bg_sprite.bitmap = Cache.picture ($game_system.qj_bg_picture)
  1251.       @bg_sprite.opacity = $game_system.qj_bg_opacity
  1252.     end
  1253.     free_space = Graphics.height - 96 - 2*Window_Base::WLH
  1254.     if QuestData::CATEGORIES.size > 1
  1255.       @category_window = Window_QuestCategory.new (@category_index)
  1256.       free_space -= @category_window.height
  1257.     end
  1258.     @label_window = Window_QuestLabel.new (QuestData::LIST_WIDTH, 32 + Window_Base::WLH + (free_space % Window_Base::WLH))
  1259.     y = @label_window.height
  1260.     if @category_window
  1261.       @category_window.y = y
  1262.       y += @category_window.height
  1263.     end
  1264.     @list_window = Window_QuestList.new (free_space, QuestData::LIST_WIDTH, QuestData::CATEGORIES[@category_index], @quest_index)
  1265.     @list_window.y = y
  1266.     @list_window.active = true
  1267.     @info_window = Window_QuestInfo.new
  1268.     @info_window.refresh (@list_window.quest)
  1269.     # Create Help Window
  1270.     @help_window = Window_Help.new
  1271.     @help_window.windowskin = Cache.system ($game_system.qj_windowskin)
  1272.     @help_window.opacity = $game_system.qj_window_opacity
  1273.     @help_window.y = Graphics.height - @help_window.height
  1274.     @help_window.width = Graphics.width
  1275.     @help_window.create_contents
  1276.     @help_window.set_text (QuestData::VOCAB_HELP_GENERAL, QuestData::HELP_ALIGNMENT)
  1277.   end
  1278.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1279.   # * Terminate Process
  1280.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1281.   def terminate
  1282.     super
  1283.     dispose_menu_background
  1284.     if @bg_sprite # Dispose Background Sprite
  1285.       @bg_sprite.bitmap.dispose
  1286.       @bg_sprite.dispose
  1287.     end
  1288.     @label_window.dispose
  1289.     @category_window.dispose if @category_window
  1290.     @list_window.dispose
  1291.     @info_window.dispose
  1292.     @help_window.dispose
  1293.   end
  1294.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1295.   # * Frame Update
  1296.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1297.   def update
  1298.     super
  1299.     update_menu_background
  1300.     if @list_window.active
  1301.       update_list_window
  1302.     elsif @info_window_active
  1303.       update_info_window
  1304.     end
  1305.   end
  1306.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1307.   # * Update List Window
  1308.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1309.   def update_list_window
  1310.     @list_window.update
  1311.     update_category_window if @category_window
  1312.     if Input.trigger?(Input::B) # If Button B is pressed
  1313.       Sound.play_cancel
  1314.       return_scene
  1315.     elsif Input.trigger? (Input::C) # If C button is pressed
  1316.       action_pressed_from_list
  1317.     # If scrolling through quests
  1318.     elsif Input.press? (Input::DOWN) || Input.press? (Input::UP)
  1319.       # Refresh Info Window
  1320.       @info_window.refresh (@list_window.quest)
  1321.     end
  1322.   end
  1323.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1324.   # * Update Category Window
  1325.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1326.   def update_category_window
  1327.     # If category window exists and horizontal arrow triggered
  1328.     if (Input.trigger? (Input::LEFT) || Input.trigger? (Input::RIGHT))
  1329.       add_int = Input.trigger? (Input::LEFT) ? -1 : 1
  1330.       @category_index = (@category_index + add_int) % QuestData::CATEGORIES.size
  1331.       # Play Cursor SE
  1332.       Sound.play_cursor
  1333.       # Refresh Windows
  1334.       @category_window.refresh (@category_index)
  1335.       @list_window.change_list (QuestData::CATEGORIES[@category_index])
  1336.       @info_window.refresh (@list_window.quest)
  1337.     end
  1338.   end
  1339.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1340.   # * Update Info Window
  1341.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1342.   def update_info_window
  1343.     @info_window.update
  1344.     if Input.trigger? (Input::B) || Input.trigger? (Input::C)
  1345.       Sound.play_cancel
  1346.       @info_window_active = false
  1347.       @info_window.oy = 0
  1348.       @list_window.active = true
  1349.       @help_window.set_text (QuestData::VOCAB_HELP_GENERAL, QuestData::HELP_ALIGNMENT)
  1350.     end
  1351.   end
  1352.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1353.   # * C Button Pressed
  1354.   #    I put this as its own method in case I want to write any patches which
  1355.   #   modifies what happens when C is pressed
  1356.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1357.   def action_pressed_from_list
  1358.     if @info_window.contents.height > @info_window.height - 32
  1359.       Sound.play_decision
  1360.       @info_window_active = true
  1361.       @list_window.active = false
  1362.       @help_window.set_text (QuestData::VOCAB_HELP_SELECTED, QuestData::HELP_ALIGNMENT)
  1363.     else
  1364.       Sound.play_buzzer
  1365.     end
  1366.   end
  1367.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1368.   # * Return Scene
  1369.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1370.   def return_scene
  1371.     unless @list_window.quest.nil? # Save Position
  1372.       $game_system.last_quest_id = @list_window.quest.id
  1373.       $game_system.last_quest_cat = @category_index
  1374.     end
  1375.     # Exit Quest Scene
  1376.     $scene = @from_menu ? Scene_Menu.new (QuestData::MENU_INDEX) : Scene_Map.new
  1377.   end
  1378. end
  1379.  
  1380. #==============================================================================
  1381. # ** Scene_QuestPurchase
  1382. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1383. #  This class handles processing for purchasing quests
  1384. #==============================================================================
  1385.  
  1386. class Scene_QuestPurchase < Scene_Quest
  1387.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1388.   # * Object Initialization
  1389.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1390.   def initialize (quest_array = [], shop_name = QuestData::VOCAB_PURCHASE)
  1391.     @quest_list, @quest_reveals = [], []
  1392.     quest_array.each { |quest_a|
  1393.       quest = Game_Quest.new (quest_a[0], (quest_a[1] ? quest_a[1] : -1))
  1394.       # Add if no switch condition or condition met and not already revealed
  1395.       if quest_a[3]
  1396.         reveals = quest_a[2]
  1397.         switch = quest_a[3]
  1398.       else
  1399.         if quest_a[2].is_a? (Array)
  1400.           reveals = quest_a[2]
  1401.           switch = nil
  1402.         else
  1403.           reveals = []
  1404.           quest.objectives.each_index { |i| reveals.push (i) }
  1405.           switch = quest_a[2]
  1406.         end
  1407.       end
  1408.       if (switch.nil? || $game_switches[switch]) && !$game_party.quests.revealed? (quest_a[0])
  1409.         # Reveal all objectives if want to show them
  1410.         quest.reveal_objective (*reveals)
  1411.         @quest_list.push (quest)
  1412.         @quest_reveals.push (reveals)
  1413.       end
  1414.     }
  1415.     @shop_name = shop_name
  1416.     @info_window_active = false
  1417.   end
  1418.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1419.   # * Start Processing
  1420.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1421.   def start
  1422.     create_menu_background
  1423.     # Create Background picture
  1424.     unless $game_system.qj_bg_picture.empty?
  1425.       @bg_sprite = Sprite.new
  1426.       @bg_sprite.bitmap = Cache.picture ($game_system.qj_bg_picture)
  1427.       @bg_sprite.opacity = $game_system.qj_bg_opacity
  1428.     end
  1429.     wlh = Window_Base::WLH
  1430.     fs = Graphics.height - (96 + 2*wlh)
  1431.     @label_window = Window_QuestLabel.new (QuestData::PURCHASE_LIST_WIDTH, 32 + wlh + (fs % 24), @shop_name)
  1432.     @list_window = Window_QuestList.new (fs, QuestData::PURCHASE_LIST_WIDTH, @quest_list)
  1433.     @list_window.y = @label_window.height
  1434.     @list_window.active = true
  1435.     for i in 0...@quest_list.size
  1436.       @list_window.draw_item (i, false) if $game_party.gold < @quest_list[i].cost
  1437.     end
  1438.     @info_window = Window_QuestInfo.new (Graphics.height, QuestData::PURCHASE_LIST_WIDTH, QuestData::PURCHASE_INFO_LAYOUT)
  1439.     @info_window.refresh (@list_window.quest)
  1440.     # Create Gold Window
  1441.     @gold_window = Window_QuestPurchaseGold.new (@list_window.y + @list_window.height)
  1442.   end
  1443.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1444.   # * Terminate Process
  1445.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1446.   def terminate
  1447.     dispose_menu_background
  1448.     if @bg_sprite # Dispose Background Sprite
  1449.       @bg_sprite.bitmap.dispose
  1450.       @bg_sprite.dispose
  1451.     end
  1452.     @label_window.dispose
  1453.     @list_window.dispose
  1454.     @info_window.dispose
  1455.     @gold_window.dispose
  1456.   end
  1457.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1458.   # * Update Info Window
  1459.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1460.   def update_info_window
  1461.     @info_window.update
  1462.     if Input.trigger? (Input::B)
  1463.       Sound.play_cancel
  1464.       @info_window_active = false
  1465.       @info_window.oy = 0
  1466.       @list_window.active = true
  1467.     elsif Input.trigger? (Input::C)
  1468.       purchase_quest
  1469.     end
  1470.   end
  1471.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1472.   # * C Button Pressed
  1473.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1474.   def action_pressed_from_list
  1475.     if @info_window.contents.height > @info_window.height - 32
  1476.       Sound.play_decision
  1477.       @info_window_active = true
  1478.       @list_window.active = false
  1479.     else
  1480.       purchase_quest
  1481.     end
  1482.   end
  1483.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1484.   # * Purchase Quest
  1485.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1486.   def purchase_quest
  1487.     if @list_window.quest.nil? || $game_party.gold < @list_window.quest.cost
  1488.       Sound.play_buzzer
  1489.     else
  1490.       (RPG::SE.new (*QuestData::PURCHASE_SE)).play # Play Purchase SE
  1491.       $game_party.lose_gold (@list_window.quest.cost) unless @list_window.quest.cost < 0
  1492.       quest = $game_party.quests[@list_window.quest.id] # Create Quest
  1493.       $game_party.quests.reveal_quest (@list_window.quest.id) # Reveal Quest
  1494.       quest.reveal_objective (*@quest_reveals[@list_window.index])
  1495.       quest.concealed = false
  1496.       @quest_list.delete_at (@list_window.index)
  1497.       @quest_reveals.delete_at (@list_window.index)
  1498.       @list_window.change_list (@quest_list)
  1499.       for i in 0...@quest_list.size
  1500.         @list_window.draw_item (i, false) if $game_party.gold < @quest_list[i].cost
  1501.       end
  1502.       @info_window.refresh (@list_window.quest)
  1503.       @gold_window.refresh
  1504.     end
  1505.   end
  1506.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1507.   # * Return Scene
  1508.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1509.   def return_scene
  1510.     $scene = Scene_Map.new
  1511.   end
  1512. end
  1513.  
  1514. # YEM Main Menu Melody Compatibility
  1515. if $imported && $imported["MainMenuMelody"]
  1516.   YEM::MENU::MENU_COMMANDS.insert (QuestData::MENU_INDEX, :quest2)
  1517.   YEM::MENU::MENU_ICONS[:quest2] = QuestData::ICONS[:menu]
  1518.   YEM::MENU::IMPORTED_COMMANDS[:quest2] = [:quest_access, :quest_disable, false, QuestData::ICONS[:menu], QuestData::VOCAB_QUESTS, "Scene_Quest"]
  1519.  
  1520.   class Game_Switches
  1521.     alias ma_yemmm_qustjrn_get_6yh1 []
  1522.     def [] (id, *args)
  1523.       return $game_system.quest_disabled || $game_party.quests.list.empty? if id == :quest_disable
  1524.       return !$game_system.quest_menuaccess if id == :quest_access
  1525.       return ma_yemmm_qustjrn_get_6yh1 (id, *args)
  1526.     end
  1527.   end
  1528. # Full Status Menu System Compatibility
  1529. elsif Game_System.method_defined? (:fscms_command_list)
  1530.   ModernAlgebra::FSCMS_CUSTOM_COMMANDS[:quest2] = [QuestData::VOCAB_QUESTS,
  1531.     QuestData::ICONS[:menu], "$game_system.quest_disabled || $game_party.quests.list.empty?",
  1532.     false, Scene_Quest]
  1533.   ModernAlgebra::FSCMS_COMMANDLIST.insert (QuestData::MENU_INDEX, :quest2) if QuestData::MENU_ACCESS
  1534. # If Phantasia Esque Menu
  1535. elsif Game_System.method_defined? (:tpcms_command_list)
  1536.   Phantasia_CMS::CUSTOM_COMMANDS[:quest2] = [QuestData::VOCAB_QUESTS,
  1537.     QuestData::ICONS[:menu], "$game_system.quest_disabled || $game_party.quests.list.empty?",
  1538.     false, Scene_Quest]
  1539.   Phantasia_CMS::COMMANDLIST.insert (QuestData::MENU_INDEX, :quest2) if QuestData::MENU_ACCESS
  1540. else # Default Menu
  1541.   # Dargor's Custom Commands
  1542.   if Object.const_defined? (:Custom_Commands)
  1543.     Custom_Commands::Icons[QuestData::VOCAB_QUESTS] = QuestData::ICONS[:menu]
  1544.   end
  1545.   #============================================================================
  1546.   # ** Window_Command (unless already done by other script)
  1547.   #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1548.   #  Summary of Changes:
  1549.   #    new instance variable - ma_disabled_commands
  1550.   #    aliased method - initialize, draw_item
  1551.   #============================================================================
  1552.   unless Window_Command.method_defined? (:ma_disabled_commands)
  1553.     class Window_Command
  1554.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1555.       # * Public Instance Variable
  1556.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1557.       attr_reader :ma_disabled_commands
  1558.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1559.       # * Initialize
  1560.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1561.       alias malg_quest2_initz_6tg2 initialize
  1562.       def initialize (*args)
  1563.         @ma_disabled_commands = [] # Initialize new instance variable
  1564.         malg_quest2_initz_6tg2 (*args) # Run Original Method
  1565.       end
  1566.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1567.       # * Draw Item
  1568.       #     index   : item number
  1569.       #     enabled : enabled flag. When false, draw semi-transparently
  1570.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1571.       alias mab_qstj_itmdraw_8ic4 draw_item
  1572.       def draw_item (index, enabled = true, *args)
  1573.         # Run Original Method
  1574.         mab_qstj_itmdraw_8ic4 (index, enabled, *args)
  1575.         enabled ? @ma_disabled_commands.delete (index) :
  1576.           (@ma_disabled_commands.push (index) if !@ma_disabled_commands.include? (index))
  1577.       end
  1578.     end
  1579.   end
  1580.   #============================================================================
  1581.   # ** Scene Menu
  1582.   #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1583.   #  Summary of Changes:
  1584.   #    aliased methods - initialize; create_command_window;
  1585.   #      update_command_selection; update_actor_selection
  1586.   #============================================================================
  1587.  
  1588.   class Scene_Menu
  1589.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1590.     # * Object Initialization
  1591.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1592.     alias magba_questj_ini_5rc1 initialize
  1593.     def initialize (menu_index = 0, *args)
  1594.       magba_questj_ini_5rc1 (menu_index, *args) # Run Original Method
  1595.       if $game_system.quest_menuaccess
  1596.         # Set menu index if coming from the scene; adjust if not (and not using Dargor
  1597.         $scene.is_a? (Scene_Quest) ? @menu_index = QuestData::MENU_INDEX : (@menu_index += 1 if @menu_index >= QuestData::MENU_INDEX)
  1598.       end
  1599.     end
  1600.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1601.     # * Create Command Window
  1602.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1603.     alias modrn_qusjrnl2_cmmndwin_5th9 create_command_window
  1604.     def create_command_window (*args)
  1605.       modrn_qusjrnl2_cmmndwin_5th9 (*args) # Run Original Method
  1606.       if $game_system.quest_menuaccess
  1607.         c = @command_window.commands.dup
  1608.         c.insert (QuestData::MENU_INDEX, QuestData::VOCAB_QUESTS)
  1609.         width = @command_window.width
  1610.         disabled = @command_window.ma_disabled_commands
  1611.         @command_window.dispose
  1612.         @command_window = @command_window.class.new (width, c)
  1613.         @command_window.index = @menu_index
  1614.         # Disable all of the old commands as well
  1615.         disabled.each { |i|
  1616.           i += 1 if i >= QuestData::MENU_INDEX
  1617.           @command_window.draw_item (i, false)
  1618.         }
  1619.         @command_window.draw_item (QuestData::MENU_INDEX, false) if $game_system.quest_disabled || $game_party.quests.list.empty?
  1620.       end
  1621.     end
  1622.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1623.     # * Update Command Selection
  1624.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1625.     alias malg_questj_cmmndupd_4rn6 update_command_selection
  1626.     def update_command_selection (*args)
  1627.       if $game_system.quest_menuaccess
  1628.       # If the Quests command selected
  1629.         if @command_window.index == QuestData::MENU_INDEX && Input.trigger? (Input::C)
  1630.           if $game_system.quest_disabled || $game_party.quests.list.empty?
  1631.             Sound.play_buzzer
  1632.           else
  1633.             Sound.play_decision
  1634.             $scene = Scene_Quest.new
  1635.           end
  1636.           return
  1637.         end
  1638.         # Reduce command window index if over the states index
  1639.         change = @command_window.index > QuestData::MENU_INDEX && !Object.const_defined? (:Custom_Commands)
  1640.         @command_window.index -= 1 if change
  1641.       end
  1642.       malg_questj_cmmndupd_4rn6 (*args) # Run Original Method
  1643.       @command_window.index += 1 if $game_system.quest_menuaccess && change
  1644.     end
  1645.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1646.     # * Update Actor Selection
  1647.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1648.     alias ma_journalqst_actorupd_3gb8 update_actor_selection
  1649.     def update_actor_selection (*args)
  1650.       if $game_system.quest_menuaccess
  1651.         # Reduce command window index if over the states index
  1652.         change = @command_window.index > QuestData::MENU_INDEX
  1653.         @command_window.index -= 1 if change
  1654.       end
  1655.       ma_journalqst_actorupd_3gb8 (*args) # Run Original Method
  1656.       @command_window.index += 1 if $game_system.quest_menuaccess && change
  1657.     end
  1658.   end
  1659. end
RAW Paste Data
Top