Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ** Game_Quest
- #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- # Holds in-game data for a quest
- #==============================================================================
- class Game_Quest
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Public Instance Variables
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- attr_reader :revealed_objectives # An array of revealed objectives
- attr_reader :complete_objectives # An array of completed objectives
- attr_reader :failed_objectives # An array of failed objectives
- attr_reader :id # The ID in $game_party.quests
- attr_reader :name # The name of the quest
- attr_reader :level # The difficulty level of the quest
- attr_accessor :banner # Picture shown at top
- attr_accessor :description # A blurb explaining the quest
- attr_accessor :client # Name of quest-giver
- attr_accessor :location # Place to do the quest
- attr_accessor :objectives # An array of strings holding objectives
- attr_accessor :prime_objectives # An array of crucial objectives
- attr_accessor :rewards # An array of reward components
- attr_accessor :common_event_id # ID of common event called at completion
- attr_accessor :icon_index # The Icon associated with this quest
- attr_accessor :custom_categories # An array of category symbols
- attr_accessor :reward_given # A switch to ensure only one reward given
- attr_accessor :concealed # A switch to show or not show the quest
- attr_accessor :cost # The cost (if in a quest shop)
- # Rewarded?
- alias rewarded? reward_given
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Object Initialization
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def initialize (id, cost = -1)
- @id = id
- @cost = cost
- reset
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Reset
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def reset
- # Set variables to corresponding arguments
- @banner, @name, @description, @client, @location, @objectives,
- @prime_objectives, @rewards, @level, @common_event_id, @icon_index,
- @custom_categories = QuestData.quest_data (id)
- # Initialize non-public arrays
- @revealed_objectives, @complete_objectives, @failed_objectives = [], [], []
- @reward_given = false
- @concealed = QuestData::MANUAL_REVEAL
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Reveal Objective
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def reveal_objective (*obj)
- for i in obj do obj.delete (i) if i >= @objectives.size end
- @revealed_objectives |= obj # Add to revealed objectives
- @revealed_objectives.sort! # Sort from lowest index to highest index
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Complete Objective
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def complete_objective (*obj)
- for i in obj
- # Can't complete if failed or non-existent
- obj.delete (i) if i >= @objectives.size || @failed_objectives.include? (i)
- # Reveal the objective if it was not previously revealed
- reveal_objective (i) unless @revealed_objectives.include? (i)
- end
- @complete_objectives |= obj # Add to complete objectives
- @complete_objectives.sort! # Sort from lowest index to highest index
- if complete?
- $game_temp.common_event_id = @common_event_id # Call common event
- @common_event_id = 0 # Don't call it again
- end
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Fail Objective
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def fail_objective (*obj)
- for i in obj
- obj.delete (i) if i >= @objectives.size
- # Reveal the objective if it was not previously revealed
- reveal_objective (i) unless @revealed_objectives.include? (i)
- end
- @failed_objectives |= obj # Add to revealed objectives
- @failed_objectives.sort! # Sort from lowest index to highest index
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Undo Objective operations
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def conceal_objective (*obj)
- obj.each { |index| @revealed_objectives.delete (index) }
- end
- def uncomplete_objective (*obj)
- for i in obj do @complete_objectives.delete (i) end
- end
- def unfail_objective (*obj)
- for i in obj do @failed_objectives.delete (i) end
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Objective Status Checks
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def objective_revealed? (*obj)
- return (obj - @revealed_objectives).empty?
- end
- def objective_complete? (*obj)
- return (obj - @complete_objectives).empty?
- end
- def objective_failed? (*obj)
- return (obj - @failed_objectives).empty?
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Complete?
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def complete?
- # Check if all prime objectives have been completed
- return (@complete_objectives & @prime_objectives) == @prime_objectives
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Failed?
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def failed?
- # Check if any prime objectives have been failed
- return !(@failed_objectives & @prime_objectives).empty?
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Set Sortable values
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def name= (string)
- @name = string
- $game_party.quests.refresh_sort (:alphabet)
- end
- def level= (value)
- @level = value
- $game_party.quests.refresh_sort (:level)
- end
- def concealed= (value)
- @concealed = value
- value ? $game_party.quests.conceal_quest (id) : $game_party.quests.reveal_quest (id)
- end
- end
- #==============================================================================
- # ** Game_Quests
- #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- # This class handles Quests. It is a wrapper for the built-in class "Hash".
- # The instance of this class is accessed by $game_party.quests
- #==============================================================================
- class Game_Quests
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Object Initialization
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def initialize
- @data = {}
- @id_sort = []
- @revealed_sort = []
- @alphabet_sort = []
- @level_sort = []
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Get Quest
- # quest_id : the ID of the quest
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def [] (quest_id)
- return Game_Quest.new (0) unless quest_id.is_a? (Integer)
- if @data[quest_id] == nil
- @data[quest_id] = Game_Quest.new (quest_id)
- reveal_quest (quest_id) unless @data[quest_id].concealed
- end
- return @data[quest_id]
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Get Quest List
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def list
- quest_list = []
- type = $game_system.quest_sort_type.to_s
- reverse = !(type.sub! (/reverse/i) { "" }).nil?
- case type.to_sym
- when :id
- @id_sort.each { |id| quest_list.push (@data[id]) }
- when :revealed
- @revealed_sort.each { |id| quest_list.push (@data[id]) }
- when :alphabet
- @alphabet_sort.each { |id| quest_list.push (@data[id]) }
- when :level
- @level_sort.each { |id| quest_list.push (@data[id]) }
- else
- quest_list = @data.values
- end
- quest_list.each { |i| quest_list.delete (i) if i.concealed }
- return reverse ? quest_list.reverse : quest_list
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Get Completed Quest List
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def completed_list
- complete_quests = []
- list.each { |i| complete_quests.push (i) if i.complete? }
- return complete_quests
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Get Failed Quest List
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def failed_list
- failed_quests = []
- list.each { |i| failed_quests.push (i) if i.failed? }
- return failed_quests
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Get Active Quest List
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def active_list
- return list - failed_list - completed_list
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Category List
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def category_list (category)
- case category
- when :all then return list
- when :active then return active_list
- when :complete then return completed_list
- when :failed then return failed_list
- else
- quest_list = []
- list.each { |quest| quest_list.push (quest) if quest.custom_categories.include? (category) }
- return quest_list
- end
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Get Location
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def get_location (quest_id)
- return nil, nil unless @data[quest_id]
- # Check all categories
- for i in 0...QuestData::CATEGORIES.size
- index = category_list (QuestData::CATEGORIES[i]).index (@data[quest_id])
- return i, index if index != nil
- end
- return nil, nil
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Revealed?
- # quest_id : the ID of a checked quest
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def revealed? (quest_id)
- return !@data[quest_id].nil? && !@data[quest_id].concealed
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Remove Quest
- # quest_id : the ID of the quest to delete
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def remove (quest_id)
- conceal_quest (quest_id)
- @data.delete (quest_id)
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Clear
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def clear
- @data.clear
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Reveal Quest
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def reveal_quest (quest_id)
- return if !@data[quest_id] ||@id_sort.include? (quest_id)
- $game_system.last_quest_id = quest_id # Open to this quest next time
- # Save sorting order in separate arrays to avoid resorting every time
- @revealed_sort.push (quest_id)
- sorted = false
- for i in 0...@id_sort.size
- if @id_sort[i] > quest_id
- @id_sort.insert (i, quest_id)
- sorted = true
- break
- end
- end
- @id_sort.push (quest_id) unless sorted
- sorted = false
- for i in 0...@alphabet_sort.size
- if @data[@alphabet_sort[i]].name.downcase > @data[quest_id].name.downcase
- @alphabet_sort.insert (i, quest_id)
- sorted = true
- break
- end
- end
- @alphabet_sort.push (quest_id) unless sorted
- sorted = false
- for i in 0...@level_sort.size
- if @data[@level_sort[i]].level > @data[quest_id].level
- @level_sort.insert (i, quest_id)
- sorted = true
- break
- end
- end
- @level_sort.push (quest_id) unless sorted
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Conceal Quest
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def conceal_quest (quest_id)
- [@revealed_sort, @alphabet_sort, @id_sort, @level_sort].each { |ary| ary.delete (quest_id) }
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Refresh Sort ~ In case the name or level of a quest is changed
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def refresh_sort (sort_type)
- case sort_type
- when :alphabet
- s = @data.values.sort { |a, b| a.name.downcase <=> b.name.downcase }
- @alphabet_sort.clear
- s.each { |quest| @alphabet_sort.push (quest.id) }
- when :level
- s = @data.values.sort { |a, b| a.level <=> b.level }
- @level_sort.clear
- s.each { |quest| @level_sort.push (quest.id) }
- end
- end
- end
- #==============================================================================
- # ** Game_Temp
- #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- # Summary of Changes:
- # new instance variables - quest_shop_array, quest_shop_name
- #==============================================================================
- class Game_Temp
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Public Instance Variables
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- attr_accessor :quest_shop_array
- attr_accessor :quest_shop_name
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Object Initialization
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- alias maba_qjrnl_iniz_5uv1 initialize
- def initialize (*args)
- maba_qjrnl_iniz_5uv1 (*args)
- @quest_shop_array = []
- @quest_shop_name = QuestData::VOCAB_PURCHASE
- end
- end
- #==============================================================================
- # ** Game_System
- #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- # Summary of Changes:
- # new instance variables - quest_disabled; qj_bg_picture; qj_bg_opacity;
- # qj_windowskin; qj_window_opacity; last_quest_id
- # aliased method - initialize
- #==============================================================================
- class Game_System
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Public Instance Variables
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- attr_reader :quest_menuaccess # Is it accessible through the menu
- attr_accessor :quest_disabled # Can you access quest journal at this time
- attr_accessor :quest_keyaccess # Is it accessible by key?
- attr_accessor :quest_sort_type # The type of sorting to use
- attr_accessor :qj_bg_picture # The filename of the background graphic
- attr_accessor :qj_bg_opacity # The opacity of the background picture
- attr_accessor :qj_windowskin # The skin of the windows in the quest scene
- attr_accessor :qj_window_opacity # The opacity of windows in the quest scene
- attr_accessor :last_quest_cat # The last [category, index] of quest viewed
- attr_accessor :last_quest_id # The ID of the last quest viewed
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Object Initialization
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- alias modlg_qstjrnl_iniz_4rd2 initialize
- def initialize (*args)
- # Run Original Method
- modlg_qstjrnl_iniz_4rd2 (*args)
- # Initialize new variables
- @quest_menuaccess = QuestData::MENU_ACCESS
- @quest_disabled = false
- @quest_keyaccess = QuestData::KEY_ACCESS
- @quest_sort_type = QuestData::SORT_TYPE
- @qj_bg_picture = QuestData::BG_PICTURE
- @qj_bg_opacity = QuestData::BG_OPACITY
- @qj_windowskin = QuestData::WINDOWS_SKIN
- @qj_window_opacity = QuestData::WINDOWS_OPACITY
- @last_quest_cat = 0
- @last_quest_id = 0
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Set Quest Access
- # Not simply accessor so I could add in compatibility
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def quest_menuaccess= (value)
- @quest_menuaccess = value
- # Full Status Menu / Phantasia-esque Compatibility
- @fscms_command_list ? c = @fscms_command_list : (@tpcms_command_list ? c = @tpcms_command_list : return)
- value ? (c.insert (QuestData::MENU_INDEX, :quest2) unless c.include? (:quest2)) :
- c.delete (:quest2)
- end
- end
- #==============================================================================
- # ** Game_Party
- #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- # Summary of Changes:
- # new instance variable - quests
- # aliased method - initialize
- #==============================================================================
- class Game_Party
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Public Instance Variables
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- attr_reader :quests
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Object Initialization
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- alias modalg_qst_jrnl_party_init_quests initialize
- def initialize
- # Run Original Method
- modalg_qst_jrnl_party_init_quests
- # Initialize @quests
- @quests = Game_Quests.new
- end
- end
- #==============================================================================
- # ** Game_Interpreter
- #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- # Summary of Changes:
- # new method - change_quest_access; change_quest_background; remove_quest;
- # quest; reveal_objective; conceal_objective; complete_objective;
- # uncomplete_objective; fail_objective; unfail_objective; quest_revealed?;
- # quest_complete?; quest_failed?; change_reward_status
- #==============================================================================
- class Game_Interpreter
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Call Quest Scene
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def call_quest (quest_id = 0)
- Sound.play_decision
- $game_system.last_quest_id = quest_id if quest_id != 0 && quest_revealed? (quest_id)
- $game_temp.next_scene = "quest"
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Call Quest Shop
- # quest_array : a series of arrays in form [a, b, [c1, c2, ..., cn], d]
- # a is the Quest ID; b is the Purchase Cost; [c1, ..., cn] is a list
- # of which objectives are revealed when the quest is bought (it can be
- # excluded and if so, then it will reveal them all); d is the ID of an
- # enabling switch, meaning it will only show up if that switch is ON
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def call_quest_shop (quest_array, shop_name = QuestData::VOCAB_PURCHASE)
- $game_temp.next_scene = "quest shop"
- $game_temp.quest_shop_array = quest_array
- $game_temp.quest_shop_name = shop_name
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Change Quest Access
- # sym - :enable, :disable, :enable_menu, :disable_menu, :enable_map, or
- # :disable_map
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def change_quest_access (sym)
- case sym
- when :enable then $game_system.quest_disabled = false
- when :disable then $game_system.quest_disabled = true
- when :enable_menu then $game_system.quest_menuaccess = true
- when :disable_menu then $game_system.quest_menuaccess = false
- when :enable_map then $game_system.quest_keyaccess = true
- when :disable_map then $game_system.quest_keyaccess = false
- end
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Change Quest Background
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def change_quest_background (picture, opacity = $game_system.qj_bg_opacity)
- $game_system.qj_bg_picture = picture
- $game_system.qj_bg_opacity = opacity
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Change Quest Windows
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def change_quest_windows (skin, opacity = $game_system.qj_window_opacity)
- $game_system.qj_windowskin = skin
- $game_system.qj_window_opacity = opacity
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Reset Quest
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def reset_quest (id)
- quest (id).reset
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Remove Quest
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def remove_quest (id)
- $game_party.quests.remove (id)
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Reveal/Conceal Quest
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def reveal_quest (id)
- $game_party.quests[id].concealed = false
- end
- def conceal_quest (id)
- $game_party.quests[id].concealed = true
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Quest
- # id : Returns the quest object with that ID
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def quest (id)
- return $game_party.quests[id]
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Quest Revealed?
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def quest_revealed? (id)
- return $game_party.quests.revealed? (id)
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Facade for Quest methods:
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- [:reveal_objective, :conceal_objective, :complete_objective,
- :uncomplete_objective, :fail_objective, :unfail_objective].each { |method|
- define_method (method) { |id, *obj| quest (id).send (method, *obj) }
- }
- [:objective_revealed?, :objective_complete?, :objective_failed?].each { |method|
- define_method (method) { |id, *obj| quest_revealed? (id) && quest (id).send (method, *obj) }
- }
- [:reset, :complete?, :rewarded?, :failed?].each { |method|
- define_method ("quest_#{method}".to_sym) { |id| quest_revealed? (id) && quest (id).send (method) }
- }
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Give Quest Reward
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def give_quest_reward (quest_id)
- return false if !quest_complete? (quest_id) || quest_rewarded? (quest_id)
- params = @params.dup
- (quest (quest_id)).rewards.each { |reward|
- next unless reward.is_a? (Array)
- @params = [reward[1], 0, 0, (reward[2] ? reward[2] : 1)]
- case reward[0]
- when 0 then command_126 # Item
- when 1 then command_127 # Weapon
- when 2 then command_128 # Armor
- when 3 # Gold
- @params = [0, 0, reward[1]]
- command_125
- when 4 # Experience
- @params = [0, 0, 0, reward[1], true]
- command_315
- end
- }
- @params = params
- change_reward_status (quest_id, true)
- return true
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Change Reward Status
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def change_reward_status (id, value = true)
- quest (id).reward_given = value
- end
- end
- #==============================================================================
- # ** Window_Base
- #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- # Summary of Changes:
- # aliased method - text_color
- #==============================================================================
- class Window_Base
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Text Color
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- alias malbr_questj2_txtcol_5rf1 text_color
- def text_color (color, *args)
- return ( color.is_a? (Array) ? Color.new (*color) : malbr_questj2_txtcol_5rf1 (color, *args) )
- end
- end
- #==============================================================================
- # ** Window_Message
- #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- # Summary of Changes:
- # aliased method - convert_special_characters
- #==============================================================================
- class Window_Message
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Convert Special Characters
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- alias ma_qstjrnl_cnvrtspecnq_6yh2 convert_special_characters
- def convert_special_characters (*args)
- # Run Original Method
- ma_qstjrnl_cnvrtspecnq_6yh2 (*args)
- @text.gsub! (/\\NQ\[(\d+)\]/i) { $game_party.quests[$1.to_i].name } # Name Quest
- end
- end
- if Object.const_defined? (:Paragrapher) && Paragrapher.const_defined? (:Formatter_SpecialCodes)
- class Paragrapher::Formatter_SpecialCodes
- alias mlg_qstj_prfrmsub_5th2 perform_substitution
- def perform_substitution (*args)
- text = mlg_qstj_prfrmsub_5th2 (*args)
- text.gsub! (/\\NQ\[(\d+)\]/i) { $game_party.quests[$1.to_i].name } # Monster Name
- return text
- end
- end
- end
- #==============================================================================
- # ** Window_QuestLabel
- #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- # This window shows the quest label at the top of the scene
- #==============================================================================
- class Window_QuestLabel < Window_Base
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Object Initialization
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def initialize (width = QuestData::LIST_WIDTH, height = 32 + WLH, text = QuestData::VOCAB_QUESTS)
- super (0, 0, width, height)
- self.windowskin = Cache.system ($game_system.qj_windowskin)
- self.opacity = $game_system.qj_window_opacity
- # Draw contents
- self.contents.font.name = QuestData::LABEL_FONTNAME unless QuestData::LABEL_FONTNAME.empty?
- if QuestData::LABEL_FONTSIZE == 0
- self.contents.font.size = [height - 36, 28].min
- # Fit it by width
- while (contents.text_size (text).width > contents.width) && contents.font.size > Font.default_size
- contents.font.size -= 1
- end
- else
- contents.font.size = QuestData::LABEL_FONTSIZE
- end
- self.contents.font.bold = QuestData::LABEL_BOLD
- self.contents.font.color = text_color (QuestData::COLOURS[:label])
- self.contents.draw_text (contents.rect, text, 1)
- end
- end
- #==============================================================================
- # ** Window_QuestPurchaseGold
- #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- # This is the gold window for the Quest Purchase scene
- #==============================================================================
- class Window_QuestPurchaseGold < Window_Base
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Object Initialization
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def initialize (y, width = QuestData::PURCHASE_LIST_WIDTH)
- super (0, y, width, 32 + WLH)
- self.windowskin = Cache.system ($game_system.qj_windowskin)
- self.opacity = $game_system.qj_window_opacity
- refresh
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Refresh
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def refresh
- self.contents.clear
- if QuestData::PURCHASE_USE_GOLD_ICON
- draw_icon (QuestData::ICONS[:gold], 0, 0)
- x = 28
- else
- x = 4
- end
- draw_currency_value ($game_party.gold, x, 0, contents.width - x)
- end
- end
- #==============================================================================
- # ** Window_QuestCategory
- #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- # This window allows you to select between which list to show
- #==============================================================================
- class Window_QuestCategory < Window_Base
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Object Initialization
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def initialize (category_index = 0, width = QuestData::LIST_WIDTH)
- hght = 56
- @all_index = QuestData::CATEGORIES.index (:all)
- hght += 8 if @all_index && QuestData::ICONS[:all] == 0
- super (0, WLH + 32, width, hght)
- self.windowskin = Cache.system ($game_system.qj_windowskin)
- self.opacity = $game_system.qj_window_opacity
- total = 24*QuestData::CATEGORIES.size
- total += 16 if hght == 64
- @spacing = (contents.width - total) / (QuestData::CATEGORIES.size - 1)
- refresh (category_index)
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Refresh
- # category_index : icon to highlight -
- # 0 => All, 1 => Active, 2 => Complete, 3 => Failed
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def refresh (category_index = 0)
- contents.clear
- for i in 0...QuestData::CATEGORIES.size
- draw_item (i, i == category_index)
- end
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Draw Category
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def draw_item (index, enabled = false)
- x = index*(24 + @spacing)
- x += 16 if @all_index && index > @all_index && contents.height == 32
- category = QuestData::CATEGORIES[index]
- if @all_index != index || contents.height == 24
- y = (contents.height == 32 ? 4 : 0)
- self.contents.clear_rect (x, y, 24, 24)
- draw_icon (QuestData::ICONS[category], x, y, enabled)
- else
- self.contents.clear_rect (x, 0, 40, 32)
- draw_icon (QuestData::ICONS[:complete], x, 0, enabled)
- draw_icon (QuestData::ICONS[:failed], x + 16, 0, enabled)
- draw_icon (QuestData::ICONS[:active], x + 8, 8, enabled)
- end
- end
- end
- #==============================================================================
- # ** Window_QuestList
- #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- # This window shows a list of quests
- #==============================================================================
- class Window_QuestList < Window_Command
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Object Initialization
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def initialize (free, width = QuestData::LIST_WIDTH, category = QuestData::CATEGORIES[0], quest_index = 0)
- super (width, [], 1, free / WLH)
- change_list (category)
- self.windowskin = Cache.system ($game_system.qj_windowskin)
- self.opacity = $game_system.qj_window_opacity
- self.index = quest_index
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Change List
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def change_list (list_type)
- if list_type.is_a? (Array)
- @commands = list_type # List passed directly
- else
- @commands = $game_party.quests.category_list (list_type)
- @commands = [] if @commands.nil?
- end
- @item_max = @commands.size
- self.contents = Bitmap.new (contents.width, [self.height - 32, @item_max*WLH].max)
- self.index = 0
- refresh
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Quest
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def quest
- return @commands[self.index]
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Draw Item
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def draw_item(index, enabled = true)
- rect = item_rect(index)
- self.contents.clear_rect(rect)
- self.contents.font.color.alpha = (enabled ? 255 : 128)
- quest = @commands[index]
- draw_icon (quest.icon_index, rect.x, rect.y, enabled)
- rect.x += 28
- rect.width -= 28
- if quest.cost > -1 # Draw the quest's cost if > -1
- self.contents.font.color = text_color (QuestData::COLOURS[:active])
- self.contents.draw_text (rect, quest.cost.to_s, 2)
- rect.width -= (self.contents.text_size (quest.cost.to_s).width + 6)
- else
- self.contents.font.color = text_color (quest.complete? ?
- QuestData::COLOURS[:complete] : (quest.failed? ?
- QuestData::COLOURS[:failed] : QuestData::COLOURS[:active]))
- end
- self.contents.draw_text(rect, quest.name)
- end
- end
- #==============================================================================
- # ** Window QuestInfo
- #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- # This window shows the details of each quest
- #==============================================================================
- class Window_QuestInfo < Window_Base
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Object Initialization
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def initialize (height = Graphics.height - (32 + WLH), x = QuestData::LIST_WIDTH, layout = QuestData::INFO_LAYOUT)
- super (x, 0, Graphics.width - x, height)
- @layout = layout
- self.windowskin = Cache.system ($game_system.qj_windowskin)
- self.opacity = $game_system.qj_window_opacity
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Refresh
- # quest : the Quest object to show
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def refresh (quest)
- contents.clear
- if quest.nil?
- create_contents
- return
- end
- @quest = quest
- # Get the Paragrapher
- if !Object.const_defined? (:Paragrapher) || !Paragrapher.const_defined? (:Formatter)
- p "This script requires the Paragraph Formatter 2.0! You can get it at RMRK:",
- " http://rmrk.net/index.php/topic,25129.0.html", "The Special Codes Formatter is supported, but you still need the base script."
- else
- if Paragrapher.const_defined? (:Formatter_SpecialCodes)
- @paragrapher = Paragrapher.new (Paragrapher::Formatter_SpecialCodes.new, Paragrapher::Artist_SpecialCodes.new)
- else
- @paragrapher = Paragrapher.new (contents.paragraph_formatter, contents.paragraph_artist)
- end
- end
- # Calculate the size of the bitmap
- h = 0
- set_font (0)
- for subtitle in @layout do h += calculate_height_req (subtitle) end
- self.contents = Bitmap.new (contents.width, [h, self.height - 32].max)
- # Draw everything in the specified order
- y = 0
- for subtitle in @layout
- if subtitle.is_a? (Array)
- max_y = y
- # Draw on same line if an array
- for i in subtitle
- y_plus = draw_section (i, y) # Don't track since on same line
- max_y = y_plus if y_plus > max_y
- end
- y = max_y
- else
- y = draw_section (subtitle, y)
- end
- end
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Calculate Height Requirement
- # section : a symbol for the heading it is asking about
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def calculate_height_req (section)
- # Calculate the amount of vertical space needed for each section
- case section
- when Array then calculate_height_req(section.max { |a, b|
- calculate_height_req(a) <=> calculate_height_req(b) })
- when :banner then return Cache.picture (@quest.banner).height unless @quest.banner.empty?
- when :name then return WLH unless @quest.name.empty?
- when :level then return WLH unless @quest.level <= 0
- when :client then return WLH unless @quest.client.empty?
- when :location then return WLH unless @quest.location.empty?
- when :description
- if @paragrapher && !@quest.description.empty?
- # Create formatted text object for the description & check total size
- bmp = Bitmap.new (contents.width - 16, WLH)
- bmp.font = contents.font.dup
- bmp.font.size = QuestData::DESC_FONTSIZE
- @desc_ft = @paragrapher.formatter.format (@quest.description, bmp)
- return (@desc_ft.lines.size*bmp.font.size) + ((3*WLH) / 2) + 4
- end
- when :objectives
- if @paragrapher && !@quest.revealed_objectives.empty?
- # Create formatted text objects for the objectives & check total size
- tw = self.contents.text_size (QuestData::OBJECTIVE_BULLET).width
- bmp = Bitmap.new (contents.width - 12 - tw, WLH)
- bmp.font = contents.font.dup
- bmp.font.size = QuestData::OBJ_FONTSIZE
- h = WLH
- @objs_ft = []
- for i in @quest.revealed_objectives
- ft = @paragrapher.formatter.format (@quest.objectives[i], bmp)
- h += (ft.lines.size * bmp.font.size) + 2
- @objs_ft.push (ft)
- end
- return h + 2
- end
- when :rewards then return WLH*(@quest.rewards.size + 1) unless @quest.rewards.empty?
- end
- return 0
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Draw Section
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def draw_section (section, y)
- set_font (0)
- case section
- when :banner then y = draw_banner (y)
- when :name then y = draw_name (y)
- when :level then y = draw_level (y)
- when :client then y = draw_client (y)
- when :location then y = draw_location (y)
- when :description then y = draw_description (y)
- when :objectives then y = draw_objectives (y)
- when :rewards then y = draw_rewards (y)
- end
- return y
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Draw Banner
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def draw_banner (y)
- return y if @quest.banner.empty?
- banner = Cache.picture (@quest.banner)
- self.contents.blt ((contents.width - banner.width) / 2, y, banner, banner.rect)
- return y + banner.height
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Draw Name
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def draw_name (y)
- return y if @quest.name.empty?
- self.contents.font.name = QuestData::NAME_FONTNAME.empty? ? Font.default_name : QuestData::NAME_FONTNAME
- self.contents.font.size = QuestData::NAME_FONTSIZE == 0 ? Font.default_size : QuestData::NAME_FONTSIZE
- self.contents.font.bold = QuestData::NAME_BOLD
- self.contents.font.color = text_color (@quest.complete? ?
- QuestData::COLOURS[:complete] : (@quest.failed? ?
- QuestData::COLOURS[:failed] : QuestData::COLOURS[:active]))
- self.contents.draw_text (0, y, self.contents.width, WLH, @quest.name, 1)
- return y + WLH
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Draw Level
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def draw_level (y)
- return y if @quest.level < 1
- if QuestData::ICONS[:level] != 0
- x = self.contents.width - 24
- @quest.level.times do
- draw_icon (QuestData::ICONS[:level], x, y)
- x -= QuestData::LEVEL_SPACE
- end
- else
- set_font (1)
- self.contents.draw_text (0, y, contents.width, WLH, @quest.level.to_s, 2)
- end
- return y + WLH
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Draw Client
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def draw_client (y)
- return y if @quest.client.empty?
- x = 0
- if QuestData::ICONS[:client] != 0
- draw_icon (QuestData::ICONS[:client], x, y)
- x += 28
- end
- if !QuestData::VOCAB_CLIENT.empty?
- set_font (1)
- self.contents.draw_text (x, y, 80, WLH, QuestData::VOCAB_CLIENT)
- x += 80
- end
- set_font (0)
- wdth = QuestData::CLIENT_WIDTH == 0 ? (contents.width - ((5*QuestData::LEVEL_SPACE) + 8)) : QuestData::CLIENT_WIDTH
- self.contents.draw_text (x, y, wdth - x, WLH, @quest.client, 2)
- return y + WLH
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Draw Location
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def draw_location (y)
- return y if @quest.location.empty?
- x = 0
- if QuestData::ICONS[:location] != 0
- draw_icon (QuestData::ICONS[:location], x, y)
- x += 28
- end
- if !QuestData::VOCAB_LOCATION.empty?
- set_font (1)
- self.contents.draw_text (x, y, 80, WLH, QuestData::VOCAB_LOCATION)
- x += 80
- end
- set_font (0)
- wdth = QuestData::LOCATION_WIDTH == 0 ? (contents.width - ((5*QuestData::LEVEL_SPACE) + 8)) : QuestData::LOCATION_WIDTH
- self.contents.draw_text (x, y, wdth - x, WLH, @quest.location, 2)
- return y + WLH
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Draw Description
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def draw_description (y)
- return y if !@paragrapher || @quest.description.empty?
- # Setup the bitmap of appropriate size for drawing the description
- hght = @desc_ft.lines.size * @desc_ft.bitmap.font.size
- font = @desc_ft.bitmap.font.dup
- @desc_ft.bitmap.dispose
- @desc_ft.bitmap = Bitmap.new (self.contents.width, hght)
- @desc_ft.bitmap.font = font
- set_font (1)
- rect = Rect.new (2, y + (WLH / 2), self.contents.width - 4, hght + WLH)
- rect2 = Rect.new (4, y + (WLH / 2) + 2, self.contents.width - 8, hght + WLH - 4)
- # Make Box
- if Bitmap.method_defined? (:fill_rounded_rect) # Bitmap Addons
- self.contents.fill_rounded_rect (rect, self.contents.font.color)
- self.contents.fill_rounded_rect (rect2, Color.new (0, 0, 0, 0))
- else
- self.contents.fill_rect (rect, self.contents.font.color)
- self.contents.clear_rect (rect2)
- end
- # Clear rect for the Description Label
- tw = self.contents.text_size (QuestData::VOCAB_DESCRIPTION).width
- self.contents.clear_rect (32, y, tw + 4, WLH)
- # Draw Description Label
- self.contents.draw_text (34, y, tw + 2, WLH, QuestData::VOCAB_DESCRIPTION)
- set_font (0)
- # Draw Description paragraph
- @paragrapher.artist.draw (@desc_ft, QuestData::JUSTIFY_PARAGRAPHS)
- self.contents.blt (8, y + WLH, @desc_ft.bitmap, @desc_ft.bitmap.rect)
- @desc_ft.bitmap.dispose
- @desc_ft = nil
- return rect.y + rect.height + 4
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Draw Objectives
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def draw_objectives (y)
- return y if !@paragrapher || @quest.revealed_objectives.empty?
- set_font (1)
- self.contents.draw_text (32, y, contents.width - 32, WLH, QuestData::VOCAB_OBJECTIVES)
- tw = self.contents.text_size (QuestData::OBJECTIVE_BULLET).width
- y += WLH
- bmp = @objs_ft[0].bitmap
- for i in 0...@quest.revealed_objectives.size
- # Draw Bullet
- set_font (1)
- self.contents.draw_text (8, y, tw, WLH, QuestData::OBJECTIVE_BULLET)
- set_font (0)
- ft = @objs_ft[i]
- ft.bitmap = Bitmap.new (contents.width, ft.lines.size*bmp.font.size)
- ft.bitmap.font = bmp.font.dup
- obj = @quest.revealed_objectives[i]
- # Get the correct color
- ft.bitmap.font.color = text_color (@quest.objective_complete? (obj) ?
- QuestData::COLOURS[:complete] : (@quest.objective_failed? (obj) ?
- QuestData::COLOURS[:failed] : QuestData::COLOURS[:active]))
- @paragrapher.artist.draw (ft, QuestData::JUSTIFY_PARAGRAPHS)
- self.contents.blt (12 + tw, y + 2, ft.bitmap, ft.bitmap.rect)
- # Modify the Y accordingly
- y += 2 + ((ft.bitmap.font.size)*ft.lines.size)
- ft.bitmap.dispose
- end
- bmp.dispose
- @objs_ft.clear
- return y + 2
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Draw Rewards
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def draw_rewards (y)
- return y if @quest.rewards.empty?
- set_font (1)
- self.contents.draw_text (32, y, contents.width - 32, WLH, QuestData::VOCAB_REWARDS)
- x = QuestData::REWARD_BULLET.empty? ? 8 : 12 + (contents.text_size (QuestData::REWARD_BULLET).width)
- y += WLH
- for reward in @quest.rewards
- # Draw Bullet
- set_font (1)
- self.contents.draw_text (8, y, 100, WLH, QuestData::REWARD_BULLET)
- set_font (0)
- self.contents.font.size = QuestData::REWARD_FONTSIZE
- if reward.is_a? (Array)
- item = nil
- case reward[0]
- when 0 then item = $data_items[reward[1]]
- when 1 then item = $data_weapons[reward[1]]
- when 2 then item = $data_armors[reward[1]]
- when 3 # Gold
- draw_icon (QuestData::ICONS[:gold], x, y)
- self.contents.font.color = normal_color
- self.contents.draw_text (x + 24, y, contents.width - x - 24, WLH, reward[1].to_s)
- if QuestData::DRAW_VOCAB_GOLD
- tw = self.contents.text_size(reward[1].to_s).width
- self.contents.font.color = system_color
- self.contents.draw_text(x + tw + 28, y, contents.width - x - 28 - tw, WLH, Vocab::gold)
- end
- when 4 # Exp
- draw_icon (QuestData::ICONS[:exp], x, y)
- self.contents.font.color = normal_color
- self.contents.draw_text (x + 24, y, contents.width - x - 24, WLH, reward[1].to_s)
- tw = self.contents.text_size(reward[1].to_s).width
- self.contents.font.color = system_color
- self.contents.draw_text(x + tw + 28, y, contents.width - x - 28 - tw, WLH, QuestData::VOCAB_EXP)
- end
- # Draw Item
- if item != nil
- draw_item_name (item, x, y)
- unless reward[2].nil? # Draw Number
- contents.font.color = system_color
- tw = contents.text_size (item.name).width + 28
- contents.draw_text (x + tw, y, 100, WLH, "#{QuestData::ITEM_NUMBER_PREFACE}#{reward[2]}")
- end
- end
- else
- set_font (0)
- # Allow use of special codes if Special Codes Formatter available
- if Object.const_defined? (:Paragrapher) && Paragrapher.const_defined? (:Formatter_SpecialCodes)
- bmp = Bitmap.new (contents.width - x, WLH)
- bmp.font = contents.font.dup
- bmp.font.size = QuestData::REWARD_FONTSIZE
- @paragrapher.paragraph (reward, bmp)
- self.contents.blt (x, y, bmp, bmp.rect)
- bmp.dispose
- else
- self.contents.draw_text (x, y, contents.width - x, WLH, reward)
- end
- end
- y += WLH
- end
- return y
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Reset Font
- # 0 => Content Font; 1 => Subtitle Font
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def set_font (type = 0)
- case type
- when 0 # Content
- self.contents.font.name = QuestData::CONTENT_FONTNAME.empty? ? Font.default_name : QuestData::CONTENT_FONTNAME
- self.contents.font.size = Font.default_size
- self.contents.font.bold = false
- self.contents.font.color = normal_color
- when 1 # Subtitle
- self.contents.font.name = QuestData::SUBTITLE_FONTNAME.empty? ? Font.default_name : QuestData::SUBTITLE_FONTNAME
- self.contents.font.size = QuestData::SUBTITLE_FONTSIZE == 0 ? Font.default_size : QuestData::SUBTITLE_FONTSIZE
- self.contents.font.bold = QuestData::SUBTITLE_BOLD
- self.contents.font.color = system_color
- end
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Colors
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def normal_color
- return text_color (QuestData::COLOURS[:content])
- end
- def system_color
- return text_color (QuestData::COLOURS[:subtitle])
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Frame Update
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def update
- if Input.press? (Input::DOWN)
- self.oy = [self.oy + 3, contents.height - self.height + 32].min
- elsif Input.press? (Input::UP)
- self.oy = [self.oy - 3, 0].max
- end
- end
- end
- #==============================================================================
- # ** Scene_Map
- #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- # Summary of Changes:
- # aliased method - update
- #==============================================================================
- class Scene_Map < Scene_Base
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Frame Update
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- alias ma_qj2_keyaces_upd_6yc1 update
- def update (*args)
- ma_qj2_keyaces_upd_6yc1 (*args)
- # If the quest log can be accessed by key and is not empty or disabled
- if $game_system.quest_keyaccess && Input.trigger? (QuestData::MAPKEY_BUTTON)
- if $game_system.quest_disabled || $game_party.quests.list.empty?
- Sound.play_buzzer
- else
- Sound.play_decision
- $game_temp.next_scene = "quest"
- end
- end
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Execute Screen Switch
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- alias malb_questj_updscene_5tg2 update_scene_change
- def update_scene_change (*args)
- scene_call = $game_temp.next_scene
- malb_questj_updscene_5tg2 (*args) # Run Original Method
- # This check first ensures that the scene call was not prevented by external
- # factors, like the player moving, then checks to see if it was quest. I
- # do it like this to ensure that it doesn't open at weird times (like while
- # the message box is open
- if $game_temp.next_scene.nil? && !scene_call.nil?
- case scene_call
- when "quest"
- $scene = Scene_Quest.new
- when "quest shop"
- $scene = Scene_QuestPurchase.new ($game_temp.quest_shop_array, $game_temp.quest_shop_name)
- end
- end
- end
- end
- #==============================================================================
- # ** Scene Quest
- #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- # This class handles the quest scene processing
- #==============================================================================
- class Scene_Quest < Scene_Base
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Object Initialization
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def initialize (*args)
- if args.size == 0 # Last Quest ID
- cat_ind = $game_system.last_quest_cat
- cat = QuestData::CATEGORIES[cat_ind]
- ind = ($game_party.quests.category_list (cat)).index ($game_party.quests[$game_system.last_quest_id])
- if !ind.nil?
- @category_index, @quest_index = cat_ind, ind
- else
- @category_index, @quest_index = $game_party.quests.get_location ($game_system.last_quest_id)
- end
- else
- @category_index = args[0] < QuestData::CATEGORIES.size ? args[0] : 0
- @quest_index = args[1]
- end
- @category_index = 0 if @category_index.nil?
- @quest_index = 0 if @quest_index.nil?
- @info_window_active = false
- @from_menu = $scene.is_a? (Scene_Menu)
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Start Processing
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def start
- super
- create_menu_background
- # Create Background picture
- unless $game_system.qj_bg_picture.empty?
- @bg_sprite = Sprite.new
- @bg_sprite.bitmap = Cache.picture ($game_system.qj_bg_picture)
- @bg_sprite.opacity = $game_system.qj_bg_opacity
- end
- free_space = Graphics.height - 96 - 2*Window_Base::WLH
- if QuestData::CATEGORIES.size > 1
- @category_window = Window_QuestCategory.new (@category_index)
- free_space -= @category_window.height
- end
- @label_window = Window_QuestLabel.new (QuestData::LIST_WIDTH, 32 + Window_Base::WLH + (free_space % Window_Base::WLH))
- y = @label_window.height
- if @category_window
- @category_window.y = y
- y += @category_window.height
- end
- @list_window = Window_QuestList.new (free_space, QuestData::LIST_WIDTH, QuestData::CATEGORIES[@category_index], @quest_index)
- @list_window.y = y
- @list_window.active = true
- @info_window = Window_QuestInfo.new
- @info_window.refresh (@list_window.quest)
- # Create Help Window
- @help_window = Window_Help.new
- @help_window.windowskin = Cache.system ($game_system.qj_windowskin)
- @help_window.opacity = $game_system.qj_window_opacity
- @help_window.y = Graphics.height - @help_window.height
- @help_window.width = Graphics.width
- @help_window.create_contents
- @help_window.set_text (QuestData::VOCAB_HELP_GENERAL, QuestData::HELP_ALIGNMENT)
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Terminate Process
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def terminate
- super
- dispose_menu_background
- if @bg_sprite # Dispose Background Sprite
- @bg_sprite.bitmap.dispose
- @bg_sprite.dispose
- end
- @label_window.dispose
- @category_window.dispose if @category_window
- @list_window.dispose
- @info_window.dispose
- @help_window.dispose
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Frame Update
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def update
- super
- update_menu_background
- if @list_window.active
- update_list_window
- elsif @info_window_active
- update_info_window
- end
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Update List Window
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def update_list_window
- @list_window.update
- update_category_window if @category_window
- if Input.trigger?(Input::B) # If Button B is pressed
- Sound.play_cancel
- return_scene
- elsif Input.trigger? (Input::C) # If C button is pressed
- action_pressed_from_list
- # If scrolling through quests
- elsif Input.press? (Input::DOWN) || Input.press? (Input::UP)
- # Refresh Info Window
- @info_window.refresh (@list_window.quest)
- end
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Update Category Window
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def update_category_window
- # If category window exists and horizontal arrow triggered
- if (Input.trigger? (Input::LEFT) || Input.trigger? (Input::RIGHT))
- add_int = Input.trigger? (Input::LEFT) ? -1 : 1
- @category_index = (@category_index + add_int) % QuestData::CATEGORIES.size
- # Play Cursor SE
- Sound.play_cursor
- # Refresh Windows
- @category_window.refresh (@category_index)
- @list_window.change_list (QuestData::CATEGORIES[@category_index])
- @info_window.refresh (@list_window.quest)
- end
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Update Info Window
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def update_info_window
- @info_window.update
- if Input.trigger? (Input::B) || Input.trigger? (Input::C)
- Sound.play_cancel
- @info_window_active = false
- @info_window.oy = 0
- @list_window.active = true
- @help_window.set_text (QuestData::VOCAB_HELP_GENERAL, QuestData::HELP_ALIGNMENT)
- end
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * C Button Pressed
- # I put this as its own method in case I want to write any patches which
- # modifies what happens when C is pressed
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def action_pressed_from_list
- if @info_window.contents.height > @info_window.height - 32
- Sound.play_decision
- @info_window_active = true
- @list_window.active = false
- @help_window.set_text (QuestData::VOCAB_HELP_SELECTED, QuestData::HELP_ALIGNMENT)
- else
- Sound.play_buzzer
- end
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Return Scene
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def return_scene
- unless @list_window.quest.nil? # Save Position
- $game_system.last_quest_id = @list_window.quest.id
- $game_system.last_quest_cat = @category_index
- end
- # Exit Quest Scene
- $scene = @from_menu ? Scene_Menu.new (QuestData::MENU_INDEX) : Scene_Map.new
- end
- end
- #==============================================================================
- # ** Scene_QuestPurchase
- #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- # This class handles processing for purchasing quests
- #==============================================================================
- class Scene_QuestPurchase < Scene_Quest
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Object Initialization
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def initialize (quest_array = [], shop_name = QuestData::VOCAB_PURCHASE)
- @quest_list, @quest_reveals = [], []
- quest_array.each { |quest_a|
- quest = Game_Quest.new (quest_a[0], (quest_a[1] ? quest_a[1] : -1))
- # Add if no switch condition or condition met and not already revealed
- if quest_a[3]
- reveals = quest_a[2]
- switch = quest_a[3]
- else
- if quest_a[2].is_a? (Array)
- reveals = quest_a[2]
- switch = nil
- else
- reveals = []
- quest.objectives.each_index { |i| reveals.push (i) }
- switch = quest_a[2]
- end
- end
- if (switch.nil? || $game_switches[switch]) && !$game_party.quests.revealed? (quest_a[0])
- # Reveal all objectives if want to show them
- quest.reveal_objective (*reveals)
- @quest_list.push (quest)
- @quest_reveals.push (reveals)
- end
- }
- @shop_name = shop_name
- @info_window_active = false
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Start Processing
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def start
- create_menu_background
- # Create Background picture
- unless $game_system.qj_bg_picture.empty?
- @bg_sprite = Sprite.new
- @bg_sprite.bitmap = Cache.picture ($game_system.qj_bg_picture)
- @bg_sprite.opacity = $game_system.qj_bg_opacity
- end
- wlh = Window_Base::WLH
- fs = Graphics.height - (96 + 2*wlh)
- @label_window = Window_QuestLabel.new (QuestData::PURCHASE_LIST_WIDTH, 32 + wlh + (fs % 24), @shop_name)
- @list_window = Window_QuestList.new (fs, QuestData::PURCHASE_LIST_WIDTH, @quest_list)
- @list_window.y = @label_window.height
- @list_window.active = true
- for i in 0...@quest_list.size
- @list_window.draw_item (i, false) if $game_party.gold < @quest_list[i].cost
- end
- @info_window = Window_QuestInfo.new (Graphics.height, QuestData::PURCHASE_LIST_WIDTH, QuestData::PURCHASE_INFO_LAYOUT)
- @info_window.refresh (@list_window.quest)
- # Create Gold Window
- @gold_window = Window_QuestPurchaseGold.new (@list_window.y + @list_window.height)
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Terminate Process
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def terminate
- dispose_menu_background
- if @bg_sprite # Dispose Background Sprite
- @bg_sprite.bitmap.dispose
- @bg_sprite.dispose
- end
- @label_window.dispose
- @list_window.dispose
- @info_window.dispose
- @gold_window.dispose
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Update Info Window
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def update_info_window
- @info_window.update
- if Input.trigger? (Input::B)
- Sound.play_cancel
- @info_window_active = false
- @info_window.oy = 0
- @list_window.active = true
- elsif Input.trigger? (Input::C)
- purchase_quest
- end
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * C Button Pressed
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def action_pressed_from_list
- if @info_window.contents.height > @info_window.height - 32
- Sound.play_decision
- @info_window_active = true
- @list_window.active = false
- else
- purchase_quest
- end
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Purchase Quest
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def purchase_quest
- if @list_window.quest.nil? || $game_party.gold < @list_window.quest.cost
- Sound.play_buzzer
- else
- (RPG::SE.new (*QuestData::PURCHASE_SE)).play # Play Purchase SE
- $game_party.lose_gold (@list_window.quest.cost) unless @list_window.quest.cost < 0
- quest = $game_party.quests[@list_window.quest.id] # Create Quest
- $game_party.quests.reveal_quest (@list_window.quest.id) # Reveal Quest
- quest.reveal_objective (*@quest_reveals[@list_window.index])
- quest.concealed = false
- @quest_list.delete_at (@list_window.index)
- @quest_reveals.delete_at (@list_window.index)
- @list_window.change_list (@quest_list)
- for i in 0...@quest_list.size
- @list_window.draw_item (i, false) if $game_party.gold < @quest_list[i].cost
- end
- @info_window.refresh (@list_window.quest)
- @gold_window.refresh
- end
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Return Scene
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def return_scene
- $scene = Scene_Map.new
- end
- end
- # YEM Main Menu Melody Compatibility
- if $imported && $imported["MainMenuMelody"]
- YEM::MENU::MENU_COMMANDS.insert (QuestData::MENU_INDEX, :quest2)
- YEM::MENU::MENU_ICONS[:quest2] = QuestData::ICONS[:menu]
- YEM::MENU::IMPORTED_COMMANDS[:quest2] = [:quest_access, :quest_disable, false, QuestData::ICONS[:menu], QuestData::VOCAB_QUESTS, "Scene_Quest"]
- class Game_Switches
- alias ma_yemmm_qustjrn_get_6yh1 []
- def [] (id, *args)
- return $game_system.quest_disabled || $game_party.quests.list.empty? if id == :quest_disable
- return !$game_system.quest_menuaccess if id == :quest_access
- return ma_yemmm_qustjrn_get_6yh1 (id, *args)
- end
- end
- # Full Status Menu System Compatibility
- elsif Game_System.method_defined? (:fscms_command_list)
- ModernAlgebra::FSCMS_CUSTOM_COMMANDS[:quest2] = [QuestData::VOCAB_QUESTS,
- QuestData::ICONS[:menu], "$game_system.quest_disabled || $game_party.quests.list.empty?",
- false, Scene_Quest]
- ModernAlgebra::FSCMS_COMMANDLIST.insert (QuestData::MENU_INDEX, :quest2) if QuestData::MENU_ACCESS
- # If Phantasia Esque Menu
- elsif Game_System.method_defined? (:tpcms_command_list)
- Phantasia_CMS::CUSTOM_COMMANDS[:quest2] = [QuestData::VOCAB_QUESTS,
- QuestData::ICONS[:menu], "$game_system.quest_disabled || $game_party.quests.list.empty?",
- false, Scene_Quest]
- Phantasia_CMS::COMMANDLIST.insert (QuestData::MENU_INDEX, :quest2) if QuestData::MENU_ACCESS
- else # Default Menu
- # Dargor's Custom Commands
- if Object.const_defined? (:Custom_Commands)
- Custom_Commands::Icons[QuestData::VOCAB_QUESTS] = QuestData::ICONS[:menu]
- end
- #============================================================================
- # ** Window_Command (unless already done by other script)
- #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- # Summary of Changes:
- # new instance variable - ma_disabled_commands
- # aliased method - initialize, draw_item
- #============================================================================
- unless Window_Command.method_defined? (:ma_disabled_commands)
- class Window_Command
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Public Instance Variable
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- attr_reader :ma_disabled_commands
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Initialize
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- alias malg_quest2_initz_6tg2 initialize
- def initialize (*args)
- @ma_disabled_commands = [] # Initialize new instance variable
- malg_quest2_initz_6tg2 (*args) # Run Original Method
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Draw Item
- # index : item number
- # enabled : enabled flag. When false, draw semi-transparently
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- alias mab_qstj_itmdraw_8ic4 draw_item
- def draw_item (index, enabled = true, *args)
- # Run Original Method
- mab_qstj_itmdraw_8ic4 (index, enabled, *args)
- enabled ? @ma_disabled_commands.delete (index) :
- (@ma_disabled_commands.push (index) if !@ma_disabled_commands.include? (index))
- end
- end
- end
- #============================================================================
- # ** Scene Menu
- #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- # Summary of Changes:
- # aliased methods - initialize; create_command_window;
- # update_command_selection; update_actor_selection
- #============================================================================
- class Scene_Menu
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Object Initialization
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- alias magba_questj_ini_5rc1 initialize
- def initialize (menu_index = 0, *args)
- magba_questj_ini_5rc1 (menu_index, *args) # Run Original Method
- if $game_system.quest_menuaccess
- # Set menu index if coming from the scene; adjust if not (and not using Dargor
- $scene.is_a? (Scene_Quest) ? @menu_index = QuestData::MENU_INDEX : (@menu_index += 1 if @menu_index >= QuestData::MENU_INDEX)
- end
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Create Command Window
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- alias modrn_qusjrnl2_cmmndwin_5th9 create_command_window
- def create_command_window (*args)
- modrn_qusjrnl2_cmmndwin_5th9 (*args) # Run Original Method
- if $game_system.quest_menuaccess
- c = @command_window.commands.dup
- c.insert (QuestData::MENU_INDEX, QuestData::VOCAB_QUESTS)
- width = @command_window.width
- disabled = @command_window.ma_disabled_commands
- @command_window.dispose
- @command_window = @command_window.class.new (width, c)
- @command_window.index = @menu_index
- # Disable all of the old commands as well
- disabled.each { |i|
- i += 1 if i >= QuestData::MENU_INDEX
- @command_window.draw_item (i, false)
- }
- @command_window.draw_item (QuestData::MENU_INDEX, false) if $game_system.quest_disabled || $game_party.quests.list.empty?
- end
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Update Command Selection
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- alias malg_questj_cmmndupd_4rn6 update_command_selection
- def update_command_selection (*args)
- if $game_system.quest_menuaccess
- # If the Quests command selected
- if @command_window.index == QuestData::MENU_INDEX && Input.trigger? (Input::C)
- if $game_system.quest_disabled || $game_party.quests.list.empty?
- Sound.play_buzzer
- else
- Sound.play_decision
- $scene = Scene_Quest.new
- end
- return
- end
- # Reduce command window index if over the states index
- change = @command_window.index > QuestData::MENU_INDEX && !Object.const_defined? (:Custom_Commands)
- @command_window.index -= 1 if change
- end
- malg_questj_cmmndupd_4rn6 (*args) # Run Original Method
- @command_window.index += 1 if $game_system.quest_menuaccess && change
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Update Actor Selection
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- alias ma_journalqst_actorupd_3gb8 update_actor_selection
- def update_actor_selection (*args)
- if $game_system.quest_menuaccess
- # Reduce command window index if over the states index
- change = @command_window.index > QuestData::MENU_INDEX
- @command_window.index -= 1 if change
- end
- ma_journalqst_actorupd_3gb8 (*args) # Run Original Method
- @command_window.index += 1 if $game_system.quest_menuaccess && change
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement