I’m planning to make a quest system for my game, and I’m also planning to make an item system for my game, in which players can earn.
My only issue is, how am I supposed to make a list of items for the players (In a Datastore and in their Inventory), and how should I also go about making a quest system?
Well taking a step back and asking ourselves what is a quest system?
Well a quest is when the PLAYER has to do something, and in return they get a REWARD
Okay we now what a quest system is so now what?
Alright lets just say that we want to give the player a quest to go get something, let’s say it’s an apple.
Okay, as the game how are we gonna check if the player has gotten the apple?
Well, we can continously check the distance from the player to the apple right?
Now we are tracking the players position to the apple we gotta check if they are close!
Well check the magnitude of the positions and see if its under a certain threshold, if so then we got the apple, break the loop and the quest is completed!
@hyva_banaan Has a great example, everytime a player does a task im guessing he checks if it corresponds with the quest type that the player has an acts responds accordingly
Personally I created a simple (kind of) function inside a ModuleScript to handle all of this.
This is the main loop that gets called every time something is done, that is a type of quest:
for name, quest in pairs(questData.currentQuests) do
if quest.Type == actionType and quest.Progress < quest.Goal then
quest.Progress += 1
if quest.Progress >= quest.Goal then
-- the quest has been completed
end
end
end
For handling the calls, I have created a function like this:
function module.fireAction(questData, actionType: string)
if (not questData) or (not actionType) then return end
return handleAction(questData, actionType)
end
questData contains all of the available quests. actionType is the type that the quests contain.
I can say for sure, that if you follow the basic principle of not trusting the client, but rather doing the important tasks on the server, you will be fine from exploiters.
As for the performance, I have not ran any tests or anything like that, so I can’t really say. Although I think that if you do not plan on having 50 players in the same server, you should be fine.
I just like it more, it is efficient and comes with many features. You do not have to use it though, it’s a matter of personal opinion.
You would need to have a table of numbers for all available quests. Values for the number could be the following:
0 - Not on quest
1 - Quest in progress
2 - Quest completed
So before you give a quest to a player, you can use that to make sure that the prerequisite quests have been completed. You don’t really want custom code for each quest. You want to make a quest engine that reads information from a table and processes it. You will need to code for each type of quest though… There’s like 5 different types of quests:
Kill - You go out and kill one or more of something.
Gather - You go out and get one or more of something.
Escort - You go out and escort someone safely.
Delivery - You are tasked with delivering an object to someone.
Talk - You are tasked to go and talk to someone.
There’s a few more that’s on Wikipedia. The quest engine would read the quest type and then call the specific code to make it happen. Also part of the quest information would be the rewards table. Experience, money, items, etc… would be given. And don’t forget the text of the quest itself. A prime example of a RPG quest system would be what’s found in World of Warcraft since quests make up a large part of that game.
For items, you would need a custom inventory system. Each item is an entry into a table and would supposedly contain the following items:
Stat Modifiers
Special Effects/Abilities
Various Flags (more on that later)
Model Definition
The flags would include if the item was wearable, what slot it’s in, etc… It’s quite an endeavor to make something like this. Hopefully this is enough to get you started. Something like this requires a lot of forethought and design.