How should I go about making a quest system and item system?

Hello Developers,

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?

1 Like

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?

Alright, so that would be a loop.

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!

But quest will be more complex than that. Players will also need to collect x amount of something and use x amount of something.

And also, how would I even check and save the quest that the player is on?

Well obivously they will be more complex but you gotta start somewhere?

I have recently completed a quest system for my game Stack the Blocks!.

What I have done is create a system like this:
(these are the available quests)

local quests = {
	
	[1] = {
		Title = "Place 10 blocks.",
		Goal = 10,
		Type = "BlockPlaced",
		Progress = 0,
		Reward = 25,
	},
	
	[2] = {
		Title = "Get a combo of 6.",
		Goal = 6,
		Type = "Combo",
		Progress = 0,
		Reward = 50,
	},
	
	[3] = {
		Title = "Beat 1 friend.",
		Goal = 1,
		Type = "FriendScore",
		Progress = 0,
		Reward = 100,
	},
	
	[4] = {
		Title = "Place 100 blocks.",
		Goal = 100,
		Type = "BlockPlaced",
		Progress = 0,
		Reward = 150,
	}
	
}

Once a player accomplishes something, I just check if the player has a quest with the same type in their DataStore. Simple.

I increment the progress with 1, until it reaches the goal. Once it does, I reward the player.

3 Likes

@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

2 Likes

I’ll try to go off of this, although, how would you exactly check and frequently update the quest data?

1 Like

And also, would you put that in a module script or a regular server script?

1 Like

Personally I created a simple (kind of) function inside a ModuleScript to handle all of this.

image

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.

Yes, that is exactly what I am doing. I do not know how resource efficient it is compared to hard-coding the quests, but at least it’s more readable

1 Like

Is there any particular reason why you put this in Server Storage? And do you know if this is not only efficient but un-exploitable?

And why profile over data store service?

1 Like

Okay okay.

Organizational purposes.


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.

1 Like

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:

  1. Kill - You go out and kill one or more of something.
  2. Gather - You go out and get one or more of something.
  3. Escort - You go out and escort someone safely.
  4. Delivery - You are tasked with delivering an object to someone.
  5. 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.

1 Like