In the editor, click on Help -> How to use. It's pretty great
Just follow it and you can recreate an example.
Just follow it and you can recreate an example.
This seems to be a problem with the forum. The file appears to still be attached to the post, but the link is indeed broken. If I can hunt up the zip package, I will try to re-upload it to the thread.
###############################################################################
## RSQS - Reedo's Simple Quest System
## Version 0.1 (beta)
## September 16, 2013
## By Reedo
###############################################################################
## REFERENCES
##
## None. This is an original script by Reedo.
###############################################################################
## FEATURES
##
## + Easy-to-use quest system
## + Unlimited quests with unlimited categories
## + Multi-stage quests, unlimited stages per quest (minimum one)
## + Unlimited number of requirements per stage
## - Party has certain number of items in inventory
## - Collect specified number of virtual item drops from battle
## - Kill specified number of certain enemy
## - Specified switch is set or not set
## - Specified variable equals the given value
## + Unlimited number of rewards per stage
## - award gold
## - award experience
## - award items
## - award armor
## - award weapons
## + Automatic quest updates at end of battle
## + Simple event script command interface using $game_reedo_quests
## - assign quests from an event
## - provide quest status feedback from an event
## - turn in a quest from an event
## + Quest configuration via easy-to-write secondary script
##
###############################################################################
## COMPATIBILITY
##
## Should be compatible with most other scripts.
##
## OVERWRITES (0*)
## Modifies DataManager and BattleManager, but maintains existing
## method implementations on overwritten methods.
###############################################################################
## REQUIREMENTS
##
## Requires seperate configuration script to setup quests.
## Requires on-map events and or common events to manage quests.
###############################################################################
## INSTALLATION
##
## Plug-and-play*(see requirements)
##
## Insert below Materials, above other add-on scripts.
###############################################################################
## RIGHTS & RESTRICTIONS
##
## As with most Reedo scripts, this script is free to re-use, as-is,
## in personal, educational, and commercial RPGVX Ace development projects,
## providing that: this script is credited in writing displayed readily
## to the user of the final compiled code assembly.
##
## Reedo retains all rights of intellect and ownership.
## You forego all rights of warranty by utilizing this script.
###############################################################################
###############################################################################
## USER OPTIONS
###############################################################################
module RSQS
STAGE_COMPLETE_MESSAGE_FORMAT = "Stage Complete: %s"
STAGE_WORKING_MESSAGE_FORMAT = "You are still working on %s."
STAGE_WORKING_USE_STORY = true
QUEST_ITEM_UPDATE_MESSAGE_FORMAT = "Found Quest Item: %s"
QUEST_REQUIREMENT_MET_MESSAGE_FORMAT = "You've met the requirements for: %s"
QUEST_COMPLETE_ME_NAME = "fanfare1"
QUEST_COMPLETE_ME_PITCH = 100
QUEST_COMPLETE_ME_VOLUME = 100
end
###############################################################################
## MAIN SCRIPT
###############################################################################
## EDITS BEYOND THIS POINT ARE AT YOUR OWN RISK!!!
###############################################################################
module RSQSDataManager
def RSQSDataManager.included(mod)
@m_load_normal_database = mod.method:)load_normal_database)
@m_create_game_objects = mod.method:)create_game_objects)
@m_make_save_contents = mod.method:)make_save_contents)
@m_extract_save_contents = mod.method:)extract_save_contents)
end
def get_load_normal_database
@m_load_normal_database
end
def get_create_game_objects
@m_create_game_objects
end
def get_make_save_contents
@m_make_save_contents
end
def get_extract_save_contents
@m_extract_save_contents
end
module_function :get_load_normal_database
module_function :get_create_game_objects
module_function :get_make_save_contents
module_function :get_extract_save_contents
end
module RSQSBattleManager
def RSQSBattleManager.included(mod)
@m_gain_drop_items = mod.method:)gain_drop_items)
end
def get_gain_drop_items
@m_gain_drop_items
end
module_function :get_gain_drop_items
end
module DataManager
include RSQSDataManager
def self.load_normal_database
RSQSDataManager.get_load_normal_database[]
begin
$data_reedo_quests = load_data("Data/ReedoQuestData.rvdata2")
rescue
$data_reedo_quests = []
end
end
def self.create_game_objects
RSQSDataManager.get_create_game_objects[]
$game_reedo_quests = Reedo_Quests.new
begin
qm = ReedoQuestManager
rescue
qm = nil
end
qm.load_quests if qm
end
def self.make_save_contents
contents = RSQSDataManager.get_make_save_contents[]
contents[:reedo_quests] = $game_reedo_quests
contents
end
def self.extract_save_contents(contents)
RSQSDataManager.get_extract_save_contents[contents]
$game_reedo_quests = contents[:reedo_quests]
$game_reedo_quests = Reedo_Quests.new if !$game_reedo_quests
end
end
module BattleManager
include RSQSBattleManager
def self.gain_drop_items
reedo_gain_quest_updates
RSQSBattleManager.get_gain_drop_items[]
end
def self.reedo_gain_quest_updates
$game_troop.dead_members.each do |enemy|
$game_reedo_quests.active_quests.each do |quest|
if quest.current_stage
if !quest.current_stage.complete?
quest.current_stage.requirements.each do |requirement|
requirement.kills.each_key do |enemyid|
requirement.kill_count[enemyid] += 1 if enemyid == enemy.enemy_id
end
requirement.virtual.each_key do |item|
if item.providers.keys.include?(enemy.enemy_id)
if rand(0) <= item.providers[enemy.enemy_id]
requirement.virtual_count[item] += 1
$game_message.add(sprintf(RSQS::QUEST_ITEM_UPDATE_MESSAGE_FORMAT, item.name))
end
end
end
end
if quest.current_stage.complete?
$game_message.add(sprintf(RSQS::QUEST_REQUIREMENT_MET_MESSAGE_FORMAT, quest.current_stage.name))
end
end
end
end
end
end
end
class Reedo_Quest_Virtual_Item
attr_reader :name # name of virtual item
attr_reader :providers # hash of enemy ID and drop chance
def initialize
[USER=83971]@Name[/USER] = ""
@providers = {}
end
def set_name(itemName)
[USER=83971]@Name[/USER] = itemName
end
def add_provider(enemyId, chance)
@providers[enemyId] = chance
end
end
class Reedo_Quest_Requirement
attr_reader :items # hash of item ID and required count
attr_reader :virtual # hash of virtual item and required count
attr_reader :kills # hash of enemy ID and required count
attr_reader :switches # hash of switch id and state flag
attr_reader :variables # hash of variable name and value
attr_reader :virtual_count # hash of virtual item and current count
attr_reader :kill_count # hash of enemy ID and current count
def initialize
@items = {}
@virtual = {}
@kills = {}
@switches = {}
@variables = {}
@virtual_count = {}
@kill_count = {}
end
def add_item(itemId, reqCount)
@items[itemId] = reqCount
end
def add_virtual(item, reqCount)
@virtual[item] = reqCount
@virtual_count[item] = 0
end
def add_kill(enemyId, reqCount)
@kills[enemyId] = reqCount
@kill_count[enemyId] = 0
end
def add_switch(switchId, state)
@switches[switchId] = state
end
def add_variable(variableId, value)
@variables[variableId] = value
end
def kills_left(enemyId)
@kills[enemyId] - @kill_count[enemyId]
end
def virtual_left
@virtual[item] - @virtual_count[item]
end
def complete?
@items.each do |key, value|
return false if $game_party.item_number($data_items[key]) < value
end
@virtual.each do |key, value|
return false if @virtual_count[key] < value
end
@kills.each do |key, value|
return false if @kill_count[key] < value
end
@switches.each do |key, value|
return false if !$game_switches[key] == value
end
@variables.each do |key, value|
return false if !$game_variables[key] == value
end
return true
end
end
class Reedo_Quest_Reward
attr_reader :gold # amount of gold rewarded
attr_reader :exp # amount of experience rewarded
attr_reader :items # hash of reward item id and count
attr_reader :armors # hash of reward armor id and count
attr_reader :weapons # hash of reward weapon id and count
def initialize
@gold = 0
[USER=111104]@Exp[/USER] = 0
@items = {}
@armors = {}
@weapons = {}
end
def award_gold(value)
@gold = value
end
def award_exp(value)
[USER=111104]@Exp[/USER] = value
end
def award_item(itemId, count)
@items[itemId] = count
end
def award_armor(armorId, count)
@armors[armorId] = count
end
def award_weapon(weaponId, count)
@weapons[weaponId] = cout
end
end
class Reedo_Quest_Stage
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :quest # the quest the stage belongs to
attr_accessor :stage_number # order of stage in quest line
attr_accessor :stage_name # name of the stage (optional)
attr_reader :requirements # array of requirements to complete stage
attr_reader :rewards # array of rewards for completing stage
attr_accessor :story_text # message to display
def initialize
@quest = nil
@stage_number = 0
@stage_name = nil
@requirements = []
@rewards = []
@story_text = ""
end
def complete?
@requirements.each do |requirement|
return false if !requirement.complete?
end
return true
end
def name
return @stage_name if @stage_name and @stage_name.size > 0
return @quest.quest_name if @quest and @quest.quest_name and @quest.quest_name.size > 0
return "(???)"
end
def set_story(text)
story_text = text
end
def set_owner(ownerQuest)
@quest = ownerQuest
end
end
class Reedo_Quest
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :category # quest type category name (unique id)
attr_reader :quest_name # name of the quest (unique id)
attr_reader :description # brief description of quest
attr_reader :stages # array of stages
attr_reader :stage_index # index of active quest stage
def initialize
@category = "Quest"
[USER=83971]@Name[/USER] = ""
@description = ""
@stages = []
@stage_index = 0
end
def initialize(name, cat)
@category = cat
@quest_name = name
@description = ""
@stages = []
@stage_index = 0
end
def add_stage(stage)
stage.set_owner(self)
@stages.push(stage)
end
def set_description(text)
@description = text
end
def assign_rewards
if current_stage
current_stage.rewards.each do |reward|
if reward.gold > 0
$game_party.gain_gold(reward.gold)
msg = sprintf(Vocab::obtainGold, reward.gold)
$game_message.add('\.' + msg)
end
if reward.exp > 0
$game_party.alive_members.each do |member|
member.gain_exp(reward.exp)
end
msg = sprintf(Vocab::obtainExp, reward.exp)
$game_message.add('\.' + msg)
end
reward.items.each_key do |itemId|
item = $data_items[itemId]
$game_party.gain_item(item, reward.items[itemId])
$game_message.add(sprintf(Vocab::obtainItem, item.name))
end
reward.armors.each_key do |itemId|
item = $data_armors[itemId]
$game_party.gain_item(item, reward.armors[itemId])
$game_message.add(sprintf(Vocab::obtainItem, item.name))
end
reward.weapons.each_key do |itemId|
item = $data_weapons[itemId]
$game_party.gain_item(item, reward.weapons[itemId])
$game_message.add(sprintf(Vocab::obtainItem, item.name))
end
end
end
end
# determines if quest is completed
def complete?
@stage_index >= stages.size
end
# gets the currently active quest stage
def current_stage
@stages.sort_by{|item| item.stage_number}[stage_index]
end
# attempts to turn in a quest if complete; returns true/false indicating success
def turn_in(showComplete = true, showWorking = false)
if !complete?
if current_stage.complete?
if showComplete
$game_reedo_quests.play_quest_complete_me
msg = sprintf(RSQS::STAGE_COMPLETE_MESSAGE_FORMAT, current_stage.name)
$game_message.add('\.' + msg)
end
assign_rewards
@stage_index += 1
return true
end
if showWorking
if RSQS::STAGE_WORKING_USE_STORY
msg = sprintf(current_stage.story_text, current_stage.name)
$game_message.add('\.' + msg)
else
msg = sprintf(RSQS::STAGE_WORKING_MESSAGE_FORMAT, current_stage.name)
$game_message.add('\.' + msg)
end
end
end
return false
end
end
class Reedo_Quests
def initialize
@quests = []
@quest_ids = []
@quest_complete_me = RPG::ME.new(RSQS::QUEST_COMPLETE_ME_NAME,
RSQS::QUEST_COMPLETE_ME_VOLUME, RSQS::QUEST_COMPLETE_ME_PITCH)
end
def active_quests
@quests.select {|quest| !quest.complete? }
end
def assign_quest(questId)
@quests.push($data_reedo_quests[questId])
@quest_ids.push(questId)
end
def contains?(questId)
@quest_ids.include?(questId)
end
def get_quest(questId)
@quests[@quest_ids.index(questId)]
end
def play_quest_complete_me
@quest_complete_me.play
end
end
###############################################################################
## RSQS - Reedo's Simple Quest System
## Version 0.3 (beta)
## September 23, 2013
## By Reedo
###############################################################################
## REFERENCES
##
## None. This is an original script by Reedo.
###############################################################################
## FEATURES
##
## + Easy-to-use quest system
## + Unlimited quests with unlimited categories
## + Multi-stage quests, unlimited stages per quest (minimum one)
## + Unlimited number of requirements per stage
## - Party has certain number of items in inventory
## - Collect specified number of virtual item drops from battle
## - Kill specified number of certain enemy
## - Specified switch is set or not set
## - Specified variable equals the given value
## + Unlimited number of rewards per stage
## - award gold
## - award experience
## - award items
## - award armor
## - award weapons
## + Automatic quest updates at end of battle
## + Simple event script command interface using $game_reedo_quests
## - assign quests from an event
## - provide quest status feedback from an event
## - turn in a quest from an event
## + Quest configuration via easy-to-write secondary script
###############################################################################
##
## COMPATIBILITY
##
## Should be compatible with most other scripts.
###############################################################################
## REQUIREMENTS
##
## 1) Requires RSQS Editor available at:
## or seperate configuration script to setup quests.
##
## 2) Requires on-map events and/or common events to manage quests.
###############################################################################
## INSTALLATION
##
## Plug-and-play*(see requirements)
##
## Insert below Materials, above other add-on scripts.
###############################################################################
## RIGHTS & RESTRICTIONS
##
## As with most Reedo scripts, this script is free to re-use, as-is,
## in personal, educational, and commercial RPGVX Ace development projects,
## providing that: this script is credited in writing displayed readily
## to the user of the final compiled code assembly.
##
## Reedo retains all rights of intellect and ownership.
## You forego all rights of warranty by utilizing this script.
###############################################################################
###############################################################################
## USER OPTIONS
###############################################################################
module RSQS
STAGE_COMPLETE_MESSAGE_FORMAT = "Stage Complete: %s"
STAGE_WORKING_MESSAGE_FORMAT = "You are still working on %s."
STAGE_WORKING_USE_STORY = true
QUEST_ITEM_UPDATE_MESSAGE_FORMAT = "Found Quest Item: %s"
QUEST_REQUIREMENT_MET_MESSAGE_FORMAT = "You've met the requirements for: %s"
QUEST_COMPLETE_ME_NAME = "fanfare1"
QUEST_COMPLETE_ME_PITCH = 100
QUEST_COMPLETE_ME_VOLUME = 100
end
###############################################################################
## MAIN SCRIPT
###############################################################################
## EDITS BEYOND THIS POINT ARE AT YOUR OWN RISK!!!
###############################################################################
module DataManager
class << self
alias reedo_sqs_dm_load_normal_database
load_normal_database alias reedo_sqs_dm_create_game_objects
create_game_objects alias reedo_sqs_dm_make_save_contents
make_save_contents alias reedo_sqs_dm_extract_save_contents
extract_save_contents
end
def self.load_normal_database
reedo_sqs_dm_load_normal_database
begin
$data_reedo_quests = load_data("Data/ReedoQuestData.rvdata2")
rescue $data_reedo_quests = []
end
end
def self.create_game_objects
reedo_sqs_dm_create_game_objects
$game_reedo_quests = Reedo_Quests.new
begin
qm = ReedoQuestManager
rescue qm = nil
end
qm.load_quests if qm
end
def self.make_save_contents
contents = reedo_sqs_dm_make_save_contents
contents[:reedo_quests] = $game_reedo_quests
contents
end
def self.extract_save_contents(contents)
reedo_sqs_dm_extract_save_contents(contents)
$game_reedo_quests = contents[:reedo_quests]
$game_reedo_quests = Reedo_Quests.new
if !$game_reedo_quests
end
end
module BattleManager
class << self
alias reedo_sqs_bm_gain_drop_items
gain_drop_items
end
def self.gain_drop_items
reedo_gain_quest_updates
reedo_sqs_bm_gain_drop_items
end
def self.reedo_gain_quest_updates
$game_troop.dead_members.each
do |enemy|
$game_reedo_quests.active_quests.each
do |quest|
if quest.current_stage
if !quest.current_stage.complete?
quest.current_stage.requirements.each
do |requirement|
requirement.kills.each_key
do |enemyid|
requirement.kill_count[enemyid] += 1
if enemyid == enemy.enemy_id
end
requirement.virtual.each_key
do |item|
if item.providers.keys.include?(enemy.enemy_id)
if rand(0) <= item.providers[enemy.enemy_id]
requirement.virtual_count[item] += 1
$game_message.add(sprintf(RSQS::QUEST_ITEM_UPDATE_MESSAGE_FORMAT, item.name)
end
end
end
end
if quest.current_stage.complete?
$game_message.add(sprintf(RSQS::QUEST_REQUIREMENT_MET_MESSAGE_FORMAT, quest.current_stage.name))
end
end
end
end
end
end
end
class Reedo_Quest_Virtual_Item
attr_reader :name # name of virtual item
attr_reader :providers # hash of enemy ID and drop chance def initialize
@name = ""
@providers = {}
end
def set_name(itemName)
@name = itemName
end
def add_provider(enemyId, chance)
@providers[enemyId] = chance
end
end
class Reedo_Quest_Requirement
attr_reader :items # hash of item ID and required count
attr_reader :virtual # hash of virtual item and required count
attr_reader :kills # hash of enemy ID and required count
attr_reader :switches # hash of switch id and state flag
attr_reader :variables # hash of variable name and value
attr_reader :virtual_count # hash of virtual item and current count
attr_reader :kill_count # hash of enemy ID and current count
def initialize
@items = {}
@virtual = {}
@kills = {}
@switches = {}
@variables = {}
@virtual_count = {}
@kill_count = {}
end
def add_item(itemId, reqCount)
@items[itemId] = reqCount
end
def add_virtual(item, reqCount)
@virtual[item] = reqCount
@virtual_count[item] = 0
end
def add_kill(enemyId, reqCount)
@kills[enemyId] = reqCount
@kill_count[enemyId] = 0
end
def add_switch(switchId, state)
@switches[switchId] = state
end
def add_variable(variableId, value)
@variables[variableId] = value
end
def kills_left(enemyId)
result = @kills[enemyId] - @kill_count[enemyId]
return result if result > -1
return 0
end
def virtual_left(orderId)
item = @virtual.keys[orderId]
result = @virtual[item] - @virtual_count[item]
return result if result > -1
return 0
end
def items_left(itemId)
result = @items[itemId] - $game_party.item_number($data_items[itemId])
return result if result > -1
return 0
end
def complete?
@items.each
do |key, value|
return false if $game_party.item_number($data_items[key]) < value
end
@virtual.each
do |key, value|
return false if @virtual_count[key] < value
end
@kills.each
do |key, value|
return false if @kill_count[key] < value
end
@switches.each
do |key, value|
return false if !$game_switches[key] == value
end
@variables.each
do |key, value|
return false if !$game_variables[key] == value
end
return true
end
def reset
@virtual.each_key
do |key|
@virtual_count[key] = 0
end
@kills.each_key
do |key|
@kill_count[key] = 0
end end
end
class Reedo_Quest_Reward
attr_reader :gold # amount of gold rewarded
attr_reader :exp # amount of experience rewarded
attr_reader :items # hash of reward item id and count
attr_reader :armors # hash of reward armor id and count
attr_reader :weapons # hash of reward weapon id and count
def initialize
@gold = 0
@exp = 0
@items = {}
@armors = {}
@weapons = {}
end
def award_gold(value)
@gold = value
end
def award_exp(value)
@exp = value
end
def award_item(itemId, count)
@items[itemId] = count
end
def award_armor(armorId, count)
@armors[armorId] = count
end
def award_weapon(weaponId, count)
@weapons[weaponId] = count
end
end
class Reedo_Quest_Stage
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :quest # the quest the stage belongs to
attr_accessor :stage_number # order of stage in quest line
attr_accessor :stage_name # name of the stage (optional)
attr_reader :requirements # array of requirements to complete stage
attr_reader :rewards # array of rewards for completing stage
attr_accessor :story_text # message to display
def initialize
@quest = nil
@stage_number = 0
@stage_name = nil
@requirements = []
@rewards = []
@story_text = ""
end
def complete?
@requirements.each
do |requirement|
return false if !requirement.complete?
end
return true
end
def name
return @stage_name if @stage_name and @stage_name.size > 0
return @quest.quest_name if @quest and @quest.quest_name and @quest.quest_name.size > 0
return "(???)"
end
def reset
@requirements.each
do |requirement|
requirement.reset
end
end
def set_story(text)
story_text = text
end
def set_owner(ownerQuest)
@quest = ownerQuest
end
end
class Reedo_Quest
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :category # quest type category name (unique id)
attr_reader :quest_name # name of the quest (unique id)
attr_reader :description # brief description of quest
attr_reader :stages # array of stages
attr_reader :stage_index # index of active quest stage
def initialize
@category = "Quest"
@name = ""
@description = ""
@stages = []
@stage_index = 0
end
def initialize(name, cat)
@category = cat
@quest_name = name
@description = ""
@stages = []
@stage_index = 0
end
def add_stage(stage)
stage.set_owner(self)
@stages.push(stage)
end
def set_description(text)
@description = text
end
def get_description
return @description if @description && @description.size > 0
return current_stage.story_text if current_stage.story_text && !complete?
return ""
end
def assign_rewards(show)
if current_stage
current_stage.rewards.each
do |reward|
if reward.gold > 0
$game_party.gain_gold(reward.gold)
msg = sprintf(Vocab::obtainGold, reward.gold)
if show $game_message.add('\.' + msg)
if show
end
if reward.exp > 0
$game_party.alive_members.each
do |member|
member.gain_exp(reward.exp)
end msg = sprintf(Vocab::obtainExp, reward.exp) if show $game_message.add('\.' + msg)
if show
end reward.items.each_key
do |itemId|
item = $data_items[itemId]
$game_party.gain_item(item, reward.items[itemId])
$game_message.add(sprintf(Vocab::obtainItem, item.name))
if show
end
reward.armors.each_key
do |itemId|
item = $data_armors[itemId]
$game_party.gain_item(item, reward.armors[itemId])
$game_message.add(sprintf(Vocab::obtainItem, item.name))
if show
end reward.weapons.each_key
do |itemId|
item = $data_weapons[itemId]
$game_party.gain_item(item, reward.weapons[itemId])
$game_message.add(sprintf(Vocab::obtainItem, item.name))
if show
end
end
end
end
# determines if quest is completed
def complete?
@stage_index >= stages.size
end
# gets the currently active quest stage
def current_stage
@stages.sort_by{|item| item.stage_number}[stage_index]
end
def reset
@stage_index = 0
@stages.each
do |stage|
stage.reset
end
end
# attempts to turn in the current quest stage if the quest is not complete; returns true/false indicating success
def turn_in(showComplete = true, showWorking = false)
if !complete?
if current_stage.complete?
if showComplete
$game_reedo_quests.play_quest_complete_me
msg = sprintf(RSQS::STAGE_COMPLETE_MESSAGE_FORMAT, current_stage.name)
$game_message.add('\.' + msg)
end
assign_rewards(showComplete)
@stage_index += 1
return true
end
if showWorking
if RSQS::STAGE_WORKING_USE_STORY
msg = sprintf(current_stage.story_text, current_stage.name)
$game_message.add('\.' + msg)
else
msg = sprintf(RSQS::STAGE_WORKING_MESSAGE_FORMAT, current_stage.name)
$game_message.add('\.' + msg)
end
end
end
return false endendclass Reedo_Quests
def initialize
@quests = []
@quest_ids = []
@quest_complete_me = RPG::ME.new(RSQS::QUEST_COMPLETE_ME_NAME, RSQS::QUEST_COMPLETE_ME_VOLUME, RSQS::QUEST_COMPLETE_ME_PITCH)
end
def active_quests
@quests.select {|quest| !quest.complete? }
end
def known_quests
@quests
end
def assign_quest(questId)
@quests.push($data_reedo_quests[questId])
@quest_ids.push(questId)
end
def contains?(questId)
@quest_ids.include?(questId)
end
def get_quest(questId)
@quests[@quest_ids.index(questId)]
end
def play_quest_complete_me
@quest_complete_me.play
end
end
###############################################################################
## RSQS - Reedo's Simple Quest System
## Version 0.1 (beta)
## September 16, 2013
## By Reedo
###############################################################################
## REFERENCES
##
## None. This is an original script by Reedo.
###############################################################################
## FEATURES
##
## + Easy-to-use quest system
## + Unlimited quests with unlimited categories
## + Multi-stage quests, unlimited stages per quest (minimum one)
## + Unlimited number of requirements per stage
## - Party has certain number of items in inventory
## - Collect specified number of virtual item drops from battle
## - Kill specified number of certain enemy
## - Specified switch is set or not set
## - Specified variable equals the given value
## + Unlimited number of rewards per stage
## - award gold
## - award experience
## - award items
## - award armor
## - award weapons
## + Automatic quest updates at end of battle
## + Simple event script command interface using $game_reedo_quests
## - assign quests from an event
## - provide quest status feedback from an event
## - turn in a quest from an event
## + Quest configuration via easy-to-write secondary script
##
###############################################################################
## COMPATIBILITY
##
## Should be compatible with most other scripts.
##
## OVERWRITES (0*)
## Modifies DataManager and BattleManager, but maintains existing
## method implementations on overwritten methods.
###############################################################################
## REQUIREMENTS
##
## Requires seperate configuration script to setup quests.
## Requires on-map events and or common events to manage quests.
###############################################################################
## INSTALLATION
##
## Plug-and-play*(see requirements)
##
## Insert below Materials, above other add-on scripts.
###############################################################################
## RIGHTS & RESTRICTIONS
##
## As with most Reedo scripts, this script is free to re-use, as-is,
## in personal, educational, and commercial RPGVX Ace development projects,
## providing that: this script is credited in writing displayed readily
## to the user of the final compiled code assembly.
##
## Reedo retains all rights of intellect and ownership.
## You forego all rights of warranty by utilizing this script.
###############################################################################
###############################################################################
## USER OPTIONS
###############################################################################
module RSQS
STAGE_COMPLETE_MESSAGE_FORMAT = "Stage Complete: %s"
STAGE_WORKING_MESSAGE_FORMAT = "You are still working on %s."
STAGE_WORKING_USE_STORY = true
QUEST_ITEM_UPDATE_MESSAGE_FORMAT = "Found Quest Item: %s"
QUEST_REQUIREMENT_MET_MESSAGE_FORMAT = "You've met the requirements for: %s"
QUEST_COMPLETE_ME_NAME = "fanfare1"
QUEST_COMPLETE_ME_PITCH = 100
QUEST_COMPLETE_ME_VOLUME = 100
end
###############################################################################
## MAIN SCRIPT
###############################################################################
## EDITS BEYOND THIS POINT ARE AT YOUR OWN RISK!!!
###############################################################################
module RSQSDataManager
def RSQSDataManager.included(mod)
@m_load_normal_database = mod.method(:load_normal_database)
@m_create_game_objects = mod.method(:create_game_objects)
@m_make_save_contents = mod.method(:make_save_contents)
@m_extract_save_contents = mod.method(:extract_save_contents)
end
def get_load_normal_database
@m_load_normal_database
end
def get_create_game_objects
@m_create_game_objects
end
def get_make_save_contents
@m_make_save_contents
end
def get_extract_save_contents
@m_extract_save_contents
end
module_function :get_load_normal_database
module_function :get_create_game_objects
module_function :get_make_save_contents
module_function :get_extract_save_contents
end
module RSQSBattleManager
def RSQSBattleManager.included(mod)
@m_gain_drop_items = mod.method(:gain_drop_items)
end
def get_gain_drop_items
@m_gain_drop_items
end
module_function :get_gain_drop_items
end
module DataManager
include RSQSDataManager
def self.load_normal_database
RSQSDataManager.get_load_normal_database[]
begin
$data_reedo_quests = load_data("Data/ReedoQuestData.rvdata2")
rescue
$data_reedo_quests = []
end
end
def self.create_game_objects
RSQSDataManager.get_create_game_objects[]
$game_reedo_quests = Reedo_Quests.new
begin
qm = ReedoQuestManager
rescue
qm = nil
end
qm.load_quests if qm
end
def self.make_save_contents
contents = RSQSDataManager.get_make_save_contents[]
contents[:reedo_quests] = $game_reedo_quests
contents
end
def self.extract_save_contents(contents)
RSQSDataManager.get_extract_save_contents[contents]
$game_reedo_quests = contents[:reedo_quests]
$game_reedo_quests = Reedo_Quests.new if !$game_reedo_quests
end
end
module BattleManager
include RSQSBattleManager
def self.gain_drop_items
reedo_gain_quest_updates
RSQSBattleManager.get_gain_drop_items[]
end
def self.reedo_gain_quest_updates
$game_troop.dead_members.each do |enemy|
$game_reedo_quests.active_quests.each do |quest|
if quest.current_stage
if !quest.current_stage.complete?
quest.current_stage.requirements.each do |requirement|
requirement.kills.each_key do |enemyid|
requirement.kill_count[enemyid] += 1 if enemyid == enemy.enemy_id
end
requirement.virtual.each_key do |item|
if item.providers.keys.include?(enemy.enemy_id)
if rand(0) <= item.providers[enemy.enemy_id]
requirement.virtual_count[item] += 1
$game_message.add(sprintf(RSQS::QUEST_ITEM_UPDATE_MESSAGE_FORMAT, item.name))
end
end
end
end
if quest.current_stage.complete?
$game_message.add(sprintf(RSQS::QUEST_REQUIREMENT_MET_MESSAGE_FORMAT, quest.current_stage.name))
end
end
end
end
end
end
end
class Reedo_Quest_Virtual_Item
attr_reader :name # name of virtual item
attr_reader :providers # hash of enemy ID and drop chance
def initialize
@name = ""
@providers = {}
end
def set_name(itemName)
@name = itemName
end
def add_provider(enemyId, chance)
@providers[enemyId] = chance
end
end
class Reedo_Quest_Requirement
attr_reader :items # hash of item ID and required count
attr_reader :virtual # hash of virtual item and required count
attr_reader :kills # hash of enemy ID and required count
attr_reader :switches # hash of switch id and state flag
attr_reader :variables # hash of variable name and value
attr_reader :virtual_count # hash of virtual item and current count
attr_reader :kill_count # hash of enemy ID and current count
def initialize
@items = {}
@virtual = {}
@kills = {}
@switches = {}
@variables = {}
@virtual_count = {}
@kill_count = {}
end
def add_item(itemId, reqCount)
@items[itemId] = reqCount
end
def add_virtual(item, reqCount)
@virtual[item] = reqCount
@virtual_count[item] = 0
end
def add_kill(enemyId, reqCount)
@kills[enemyId] = reqCount
@kill_count[enemyId] = 0
end
def add_switch(switchId, state)
@switches[switchId] = state
end
def add_variable(variableId, value)
@variables[variableId] = value
end
def kills_left(enemyId)
@kills[enemyId] - @kill_count[enemyId]
end
def virtual_left
@virtual[item] - @virtual_count[item]
end
def complete?
@items.each do |key, value|
return false if $game_party.item_number($data_items[key]) < value
end
@virtual.each do |key, value|
return false if @virtual_count[key] < value
end
@kills.each do |key, value|
return false if @kill_count[key] < value
end
@switches.each do |key, value|
return false if !$game_switches[key] == value
end
@variables.each do |key, value|
return false if !$game_variables[key] == value
end
return true
end
end
class Reedo_Quest_Reward
attr_reader :gold # amount of gold rewarded
attr_reader :exp # amount of experience rewarded
attr_reader :items # hash of reward item id and count
attr_reader :armors # hash of reward armor id and count
attr_reader :weapons # hash of reward weapon id and count
def initialize
@gold = 0
@exp = 0
@items = {}
@armors = {}
@weapons = {}
end
def award_gold(value)
@gold = value
end
def award_exp(value)
@exp = value
end
def award_item(itemId, count)
@items[itemId] = count
end
def award_armor(armorId, count)
@armors[armorId] = count
end
def award_weapon(weaponId, count)
@weapons[weaponId] = cout
end
end
class Reedo_Quest_Stage
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :quest # the quest the stage belongs to
attr_accessor :stage_number # order of stage in quest line
attr_accessor :stage_name # name of the stage (optional)
attr_reader :requirements # array of requirements to complete stage
attr_reader :rewards # array of rewards for completing stage
attr_accessor :story_text # message to display
def initialize
@quest = nil
@stage_number = 0
@stage_name = nil
@requirements = []
@rewards = []
@story_text = ""
end
def complete?
@requirements.each do |requirement|
return false if !requirement.complete?
end
return true
end
def name
return @stage_name if @stage_name and @stage_name.size > 0
return @quest.quest_name if @quest and @quest.quest_name and @quest.quest_name.size > 0
return "(???)"
end
def set_story(text)
story_text = text
end
def set_owner(ownerQuest)
@quest = ownerQuest
end
end
class Reedo_Quest
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :category # quest type category name (unique id)
attr_reader :quest_name # name of the quest (unique id)
attr_reader :description # brief description of quest
attr_reader :stages # array of stages
attr_reader :stage_index # index of active quest stage
def initialize
@category = "Quest"
@name = ""
@description = ""
@stages = []
@stage_index = 0
end
def initialize(name, cat)
@category = cat
@quest_name = name
@description = ""
@stages = []
@stage_index = 0
end
def add_stage(stage)
stage.set_owner(self)
@stages.push(stage)
end
def set_description(text)
@description = text
end
def assign_rewards
if current_stage
current_stage.rewards.each do |reward|
if reward.gold > 0
$game_party.gain_gold(reward.gold)
msg = sprintf(Vocab::ObtainGold, reward.gold)
$game_message.add('\.' + msg)
end
if reward.exp > 0
$game_party.alive_members.each do |member|
member.gain_exp(reward.exp)
end
msg = sprintf(Vocab::ObtainExp, reward.exp)
$game_message.add('\.' + msg)
end
reward.items.each_key do |itemId|
item = $data_items[itemId]
$game_party.gain_item(item, reward.items[itemId])
$game_message.add(sprintf(Vocab::ObtainItem, item.name))
end
reward.armors.each_key do |itemId|
item = $data_armors[itemId]
$game_party.gain_item(item, reward.armors[itemId])
$game_message.add(sprintf(Vocab::ObtainItem, item.name))
end
reward.weapons.each_key do |itemId|
item = $data_weapons[itemId]
$game_party.gain_item(item, reward.weapons[itemId])
$game_message.add(sprintf(Vocab::ObtainItem, item.name))
end
end
end
end
# determines if quest is completed
def complete?
@stage_index >= stages.size
end
# gets the currently active quest stage
def current_stage
@stages.sort_by{|item| item.stage_number}[stage_index]
end
# attempts to turn in a quest if complete; returns true/false indicating success
def turn_in(showComplete = true, showWorking = false)
if !complete?
if current_stage.complete?
if showComplete
$game_reedo_quests.play_quest_complete_me
msg = sprintf(RSQS::STAGE_COMPLETE_MESSAGE_FORMAT, current_stage.name)
$game_message.add('\.' + msg)
end
assign_rewards
@stage_index += 1
return true
end
if showWorking
if RSQS::STAGE_WORKING_USE_STORY
msg = sprintf(current_stage.story_text, current_stage.name)
$game_message.add('\.' + msg)
else
msg = sprintf(RSQS::STAGE_WORKING_MESSAGE_FORMAT, current_stage.name)
$game_message.add('\.' + msg)
end
end
end
return false
end
end
class Reedo_Quests
def initialize
@quests = []
@quest_ids = []
@quest_complete_me = RPG::ME.new(RSQS::QUEST_COMPLETE_ME_NAME,
RSQS::QUEST_COMPLETE_ME_VOLUME, RSQS::QUEST_COMPLETE_ME_PITCH)
end
def active_quests
@quests.select {|quest| !quest.complete? }
end
def assign_quest(questId)
@quests.push($data_reedo_quests[questId])
@quest_ids.push(questId)
end
def contains?(questId)
@quest_ids.include?(questId)
end
def get_quest(questId)
@quests[@quest_ids.index(questId)]
end
def play_quest_complete_me
@quest_complete_me.play
end
end
Original thread: https://forums.rpgmakerweb.com/threads/rsqs-reedos-simple-quest-system-beta.18205/