Database Tables:
Code: Select all
quests
id, lua_script
This table serves as an index to the quest system. To create a new quest, you must add it to this table. NOTE: Unlike the previous LUA scripts, you must specify the path to the script as well. If the script is called KillCrabs.lua in the Quests directory, you would need to put Quests\KillCrabs.lua in the lua_script field. This is as design so that you can organize quests however you want.
character_quests
id, char_id, quest_id, completed_date
This table holds both current and completed quests. Quests that have not been completed yet will have a null in the completed_date field.
character_quest_progress
id, char_id, quest_id, step_id, progress
This table is used to keep track of character quest progress.
Code: Select all
function spawn(NPC)
ProvidesQuest(NPC, 1)
end
function hailed(NPC, Spawn)
FaceTarget(NPC, Spawn)
conversation = CreateConversation()
if HasQuest(Spawn, 1) then
AddConversationOption(conversation, "No problem")
StartConversation(conversation, NPC, Spawn, "Hello again " .. GetName(Spawn) .. ". Thank you for accepting my task.")
else
if HasCompletedQuest(Spawn, 1) then
AddConversationOption(conversation, "Anytime")
StartConversation(conversation, NPC, Spawn, "Hello again " .. GetName(Spawn) .. ". Thank you for killing those crabs.")
else
AddConversationOption(conversation, "Why can't you kill them?", "KillThemYourself")
AddConversationOption(conversation, "Why should I help you?", "WhyHelpYou")
StartConversation(conversation, NPC, Spawn, "Greetings " .. GetName(Spawn) .. "! Thank you for coming. Could you please kill some of the crabs on the shore for me? I haven't liked them ever since I was pinched as a child.")
end
end
end
function KillThemYourself(NPC, Spawn)
conversation = CreateConversation()
AddConversationOption(conversation, "A dragon? Right.... Anyways, I want a good pair of leggings for this favor.", "GiveMeQuest")
AddConversationOption(conversation, "I'll need 12 bottles of Rum, 3 pints of Ale, and 12 gold pieces. I'm not risking my life for nothing!", "TooGreedy")
StartConversation(conversation, NPC, Spawn, "I could kill them myself, but my sword was recently damaged while I was battling a dragon.")
end
function TooGreedy(NPC, Spawn)
conversation = CreateConversation()
AddConversationOption(conversation, "Have Fun.")
StartConversation(conversation, NPC, Spawn, "Forget it, you are too greedy. I'll get another adventurer to do it for me.")
Emote(NPC, " makes a rude gesture at you.", Spawn)
end
function GiveMeQuest(NPC, Spawn)
OfferQuest(NPC, Spawn, 1)
conversation = CreateConversation()
AddConversationOption(conversation, "Bye")
StartConversation(conversation, NPC, Spawn, "Well you drive a hard bargain, but very well. I agree to your terms.")
end
function WhyHelpYou(NPC, Spawn)
conversation = CreateConversation()
AddConversationOption(conversation, "Give me some coins and a some of those leggings the merchant is selling.", "GiveMeQuest")
AddConversationOption(conversation, "Hmm, how much do you have? I don't know if you have enough to pay me what I want...", "TooGreedy")
StartConversation(conversation, NPC, Spawn, "I will pay you if you are that greedy...")
endCode: Select all
ProvidesQuest(NPC, Quest ID) - Tells the system that this NPC offers the quest so that it will check the spells prereqs and if it passes, will display the quest icon over the NPC's head.
conversation = CreateConversation() - Used to create a new Conversation. This is necessary before you can them.
AddConversationOption(Conversation, Text option, Function) - The given function is called when the user selects this text option.
StartConversation(Conversation, NPC, Spawn, Text) - This initiates the conversation and displays what the NPC says (text) and the options that were added using the AddConversationOption function.
OfferQuest(NPC, Spawn, Quest ID) - Offers the quest to the Spawn (Player).Code: Select all
--[[
This is the EQ2Emu example LUA Quest.
These functions are shared, so don't save any character data in them.
If you have any questions be sure to read the Quest Functions.txt in the Quests directory or the wiki site location on the eq2emulator.net website.
--]]
function Init(Quest)
RegisterQuest(Quest, "Kill Crabs", "Hallmark", "Queen's Colony", 1, "Murrar Shar is deathly afraid of crabs and wants you to kill some of them for him.")
AddQuestRewardItem(Quest, 1001)
AddQuestRewardCoin(Quest, 78)
SetQuestRewardExp(Quest, 200)
SetQuestPrereqLevel(Quest, 1)
AddQuestStepKill(Quest, 1, "Kill 5 of the crabs on the nearby shore", 5, "Kill Crabs for Murrar Shar", 28, 546, 568, 569)
AddQuestStepCompleteAction(Quest, 1, "KilledAllCrabs")
SetCompletedDescription(Quest, "This is the description that is displayed when the quest is completed and shown in the completed quest list.")
end
function Accepted(Quest, QuestGiver, Player)
if QuestGiver ~= nil then
if GetDistance(Player, QuestGiver) < 30 then
FaceTarget(QuestGiver, Player)
Say(QuestGiver, "Thank you for accepting this task " .. GetName(Player) .. ". Please return to me when you have completed it.")
Emote(QuestGiver, " thanks you warmly.", Player)
end
end
end
function Declined(Quest, QuestGiver, Player)
if QuestGiver ~= nil then
if GetDistance(Player, QuestGiver) < 30 then
FaceTarget(QuestGiver, Player)
Say(QuestGiver, "If you change your mind " .. GetName(Player) .. ", you know where to find me.")
Emote(QuestGiver, " glares at you.", Player)
end
end
end
function KilledAllCrabs(Quest, QuestGiver, Player)
UpdateQuestStepDescription(Quest, 1, "I killed the crabs as Murrar requested.")
AddQuestStepChat(Quest, 2, "I need to speak with Murrar Shar to obtain my reward.", "", 547)
AddQuestStepCompleteAction(Quest, 2, "Completed")
end
function Completed(Quest, QuestGiver, Player)
UpdateQuestStepDescription(Quest, 1, "I spoke to Murrar Shar")
UpdateQuestDescription(Quest, "I killed some of the crabs on the beach for Murrar Shar.")
GiveQuestReward(Quest, Player)
end
Code: Select all
The following LUA functions are used in creating/using Quests:
Note that the first parameter is ALWAYS Quest. See KillCrabs.lua for a working example of these functions.
REQUIRED FUNCTIONS (placed in an init() function):
RegisterQuest(Quest, Quest Name, Quest Type, Quest Zone, Quest level, Description)
Optional Functions (mainly used in init() function):
SetQuestPrereqLevel(Quest, Level)
NOTE: Level required to be given the quest
AddQuestPrereqQuest(Quest, Quest ID)
NOTE: Quest that must be completed before this quest can be given
AddQuestPrereqItem(Quest, Item ID, Quantity)
NOTE: Quantity is optional and defaults to 1
Item that the player must have to get the quest
AddQuestPrereqFaction(Quest, Faction ID, Faction Amount Lower, Faction Amount Upper)
NOTE: not currently used but here for when it is completed
Quest is offered when the character's faction is between the Faction Amount Lower and Faction Amount Upper (if Faction Amount Upper is used, otherwise faction is >= Faction Amount Lower)
AddQuestRewardItem(Quest, Item ID, Quantity)
NOTE: Quantity is optional and defaults to 1
AddQuestRewardCoin(Quest, Copper, Silver, Gold, Plat)
NOTE: all parameters but copper are optional
AddQuestRewardFaction(Quest, Faction ID, Amount)
NOTE: not currently used but here for when it is completed
SetQuestRewardStatus(Quest, Amount)
NOTE: not currently used but here for when it is completed
SetQuestRewardComment(Quest, Text)
SetQuestRewardExp(Quest, Amount)
AddQuestStepKill(Quest, Step ID, Description, Quantity, TaskGroupText, NPC ID(s))
NOTE: ID is a unique number that you want to use for this step. It is used later to track player progress. Each quest can use whichever IDs you want as long as the ID is not repeated in the same quest.
TaskGroupText is optional, but if used this Quest Step will be a bullet underneath the TaskGroup created with the TaskGroupText.
If you dont want to use TaskGroupText use an empty string in the field (ie "")
You can have multiple bullets under the same TaskGroup by using the same TaskGroupText in multiple addQuestStepKill function calls.
AddQuestStepChat(Quest, Step ID, Description, TaskGroupText, NPC ID(s))
AddQuestStepObtainItem(Quest, Step ID, Description, Quantity, TaskGroupText, Item ID(s))
AddQuestStepLocation(Quest, Step ID, Description, X, Y, Z, MaxVariation, TaskGroupText)
NOTE: MaxVariation is the distance the player can be from the location and still get credit
AddQuestStepCompleteAction(Quest, Step ID, Function Name)
NOTE: LUA Function that is called when this step is completed.
SetCompletedDescription(Quest, Description)
NOTE: Description that is used after a quest has been completed.
UpdateQuestStepDescription(Quest, Step ID, Description)
function Accepted(Quest, QuestGiver, Player)
NOTE: This function is called when a player accepts the quest
function Declined(Quest, QuestGiver, Player)
NOTE: This function is called when a player declines the questhttp://eq2emulator.net/ScreenShots/QuestSystem1.jpg
http://eq2emulator.net/ScreenShots/QuestSystem2.jpg
http://eq2emulator.net/ScreenShots/QuestSystem3.jpg
http://eq2emulator.net/ScreenShots/QuestSystem4.jpg
http://eq2emulator.net/ScreenShots/QuestSystem5.jpg
http://eq2emulator.net/ScreenShots/QuestSystem6.jpg
http://eq2emulator.net/ScreenShots/QuestSystem7.jpg
http://eq2emulator.net/ScreenShots/QuestSystem8.jpg
http://eq2emulator.net/ScreenShots/QuestSystem9.jpg
If you have any questions let me know.