Quest System

The goal of this system is to provide a framework for creating and managing quests, with a set of built-in functionality.

Quests can be complex. When you complete a quest, you may unlock another quest.

A quest may be composed of multiple parts. Maybe you can re-do quests. Maybe you can fail quests.

There are also many different types of quests, for example:

-deliver an item

-collect some items

-defeat monsters

-talk to someone

-go somewhere

I am looking for a quest system that will satisfy the following criteria:

-a quest scene that will dynamically generate a list of quests from a quest tree and allow you to accept/manage quests

-a central quest management system that will handle all quest-related logic such as checking for completion and updating quest progress

-a flexible quest system that allows users to extend it with their own rules and grammars

A centralized quest management system should handle quest availability, quest task completion, and updating quest progress, amongst other things.

Doesn't matter if you're asked to kill 20 slime or collect some eggs or to visit a particular NPC somewhere. You only need to write the management system once, and then you can just pass all your quests into it without worrying about how to handle each quest on a per-case basis.

The quest manager will provide an API that will allow you to give quests through script calls.

For this system, a quest scene will be created.

Quests will primarily be obtained from the quest scene.

It will present a list of quests available for you to choose from.

The list itself will be dynamically generated from a quest tree.

But again, the quest manager will allow users to choose how they wish to give their quests, and for sure not every game is going to be centered around a quest list.

Parser

The bulk of the system relies on a parsing algorithm that you will implement.

Because we are aiming to provide a system that allows (almost) arbitrary quests to be defined, we need to define rules and grammars.

The parser will read structured input and determine how to build all of the necessary things to allow the quest system to function.

Each type of quest is a separate component all by itself, so it is not necessary to implement every type of quest in order to have a working system.

*note: It is just my opinion that a parser will be required. If you have a better way to implement the system then by all means go for it. I only think a parser is necessary because of what is to follow.

This sounds like a computationally expensive system so optimizations would be quite important.

Quest entry

The quest tree will be parsed from a collection of quest entries. Implementation is up to you (array, hash table, external text file, ...)

Each entry will consist of the following fields. Implementation is up to you.

I think I would use an array of hash-tables when defining each quest because then you don't have to rely on hardcoded array indices, which may make it more flexible if someone decides to extend it by adding extra fields.



Code:
-a quest ID
-category
-difficulty 
-description
-prerequisites
-effects
-automatic show?
-can redo?
-Fail behavior?
-list of tasks
Quest ID. It is really a user-friendly feature so you can easily refer to a specific quest rather than trying to remember what its index is. Oh, and you can sort your collection of quests internally as well for optimization?

Category. User-defined categories. Just to organize your quests and make your GUI look more interesting. For customization.

Difficulty. User-defined for customization. A constant should be defined to indicate sorting order.

-Easy/normal/hard

-1/2/3/4/5-star (maybe the GUI will actually draw stars)

-S/A/B/C/D-rank.

Description: self-explanatory. Anyone should be able to customize the parser if you wanted to add things like control characters to make descriptions more interesting? (colors, font, icons...). Actually I think it would provide interesting options if your parser is written flexibly.

Prerequisites. A list of quests that should be completed. And possibly other conditions! Maybe you need to have an item in your inventory in order for this quest to show up. Maybe you need to be at a certain level. Anyways the parser for this should be written flexibly so that if it sees numbers then it implies quest ID's, but if it sees structured text then it should parse it as such.



Code:
<actor 1> level 10
Has 1 Golden Egg
Effects. Don't know what to call this field. Basically things that should happen when you accept this quest. You know, perhaps you get a quest item, or you lose something.



Code:
Remove 2000 gold
Remove 1 Golden Egg
Add 1 key
Automatic show? Default True.

-If true, then it will automatically show up on the quest list when the prerequisites are met.

-If false, then you will have to manually activate it via script calls. Useful if you want to control when a quest appears and the story proceeds.

Can redo? Default False

-If False, then once you complete the quest (or fail), the quest will never show up again

-If it's a value from 1 to n, then you can repeat it that many times.

-if True, then it will always re-appear, provided the pre-requisites are met.

Fail behavior?

When you fail a quest, you may want to define different behaviors.

Maybe it's game over time.

Maybe you get a refund.

Maybe you lose exp.

List of tasks.

Just a list of tasks. Like many of the previous fields, you will need to define a set of keywords for your parser and require structured input.

This is especially important because your quest management system will be using these to check whether your quest is complete or not.



Code:
Collect 10 Berries
Kill 20 Slimes
Deliver Letter to SomeNPC
Rather than the string "Berries" you would instead enter the ID in the database so that when you parse the array of quests to build your tree you know exactly which object you're referring to. I think that is the most reasonable way to do it? So maybe something like



Code:
COLLECT 10 ITEM 3
Kill 20 enEmY 1
Case-insensitive to make it more user-friendly. Also, I don't know how to specify the letter-delivery, but it is a matter of adding an extra case to your parser.

Extending the system

As mentioned, the system is meant to be designed for extensibility.

The parser should be written so that it handles different cases and consequently additional cases may be added if someone comes up with an interesting type of quest (or knows how to implement the DELIVER quests or VISIT NPC quests lol).

I would not worry too much about the GUI; we can probably just grab an existing one and just hook it up to the appropriate methods and attributes.

Compatibility

Depending on the type of quest you're implementing, there may be compatibility issues.

For example, there shouldn't be any problems if you're just checking how many of an item you have, or whether you have a golden egg in your inventory, but if you started tracking enemy kills, you might run into problems.

Fortunately the system is meant to be flexible so if a type of quest just doesn't work out, just take it out or re-write it to make it compatible.
Well, I know 3 quests scripts.

Two are quests journals but the last one seems to be a quest manager because it can count ennemies killed in battle with a script add-on.

Though, I am not 100% sure since it's in japanese but maybe it will interest you.

http://www4.plala.or...gss3/index.html

You will need to search through this site to found it, I infortunally can't give you the direct link because the site automaticly loop back on main page when you give a direct link.

Here's a resume of the quest description (google translatation).

Is a script system to centrally manage and perform quest to progress on the game, the orders for Quest by Guild※ If you want to condition the number of actual usage ※ defeated the enemy (such as how to operate from the event), please refer to the sample operation, the Kills counter is required
There're 7 scripts for that quest system:

- Quest system [Definition]

- Quest system

- Quest system [database]

- Quest system [Event]

- Quest system [Quest List]

- Guild Quest system

- Quest system [menu]

And even a demo is added.
I've been working on something for quite some time now (still mostly system design, not much coding yet) that achieves part of what you're looking for, though not in the same exact way.

I have a BNF-like text parser already written, that currently I use for "natural" language generation. The idea being that you can then communicate similar types of information multiple times without each phrase sounding mechanically identical to every other.

To extend this parser so that each node was a quest element, rather than a language element, is trivial. Making interesting quest element nodes not so much, but that can be built on over time.

Something you may want to check out: http://larc.unt.edu/techreports/LARC-2011-02.pdf

I've tried contacting the authors of that paper, but thus far, no response. Needless to say I'm interested in what they know, and their thoughts.

Ultimately, I'd like to get enough of a core engine in place so that I can use a comment tag in various events that might look something like this:

<Quest Character>

<Name=Brian>

<Requests=FetchItem,DeliverLetter,KillEnemy>

<StoryLevel=1>

Idea being that the generator then knows a name for the character (so it can generate appropriate chatter when talking about delivering to someone else, etc), and also knows which type of quest elements can be assigned to that entity. This ensures that, for instance, you don't have a quest that involves fetching medicine from a blacksmith, or delivering an anvil to the doctor, or kidnapping the daughter of someone who doesn't even have a daughter, etc.

StoryLevel, or some similar indicator, is in place to make sure that there are no quests very early in the game that involve some NPC that won't be met until much later in the game, and likewise avoids spoiling the plot by revealing a location that the player cannot yet visit, etc.

Then, add a command in Game_Interpreter for handling comments, and when it comes across a comment that looks like this, file away the information (if it's the first time seeing this NPC), or if not the first time, check to see if there's an active quest involving this NPC, and handle it accordingly. If not, then just continue with normal event execution.

Obviously, many of the moving parts in this require a bit of effort to put together, but in theory, it's all possible.

In some other discussions I've started on the various forums, an important point that's been made to me (and well taken also) is that these kinds of quests can be very stale and lifeless... certainly they shouldn't be the main focus of a game. Some of what I'm trying to do is give them a bit more personality, if only slightly. More importantly though, I think that some of these things added in do offer several useful benefits (assuming there is a reasonable world/story already in place):

  • adds some variety and replay value to the game, as it won't be the same all the time
  • improves the open world feel; even when various parts of the story conclude, there is still the option to keep playing
  • creates a more realistic and immersed feeling, since the world has characters which exist that do things that are important to the characters that have little to do with the players' main goals
  • gives the player something interesting (in moderate doses) if/when they want to collect gold, hunt for items, level up, etc.

I'm definitely interested in exchanging ideas with you (we've actually already done so offline a bit on some other things). If you want to work together on any of this stuff, I'm happy to do so.
Lol the paper was an interesting read. I guess you can produce all sorts of things when you're writing a thesis on something.

It's also made it evident that quest systems, in general, tend to be based on the same structure (until someone comes up with something innovative anyways).

However, maybe the kind of quests given in MMO's simply aren't suitable for RPG's.

The key difference being that in MMO's, there is the multiplayer factor which changes the entire thing.

Collecting 15 mushrooms from a pack of mushroom monsters can get really boring, especially if you're playing solo. This holds true even on an MMO where you're...well, playing solo.

Maybe that's why you rarely have quest systems in RPG's that aren't totally based on completing quests/missions (eg: FF tactics). The typical "quest" would usually be considered "story quests" that progress the game, and the odd "sidequests" typically reveal some more back-story about some character, place, or just get some rare item to make it look like it wasn't a complete waste of time.

The script Chaos linked looks like the size of system a good quest system should be. Of course, there are numerous other quest scripts that are not overly complex and just provide a simple "quest log" and allow you to create simple quests, which may be enough for most purposes.

But things like pre-requisites, win/lose conditions, and all of these extra things that ultimately influence the story (which means added replayability value), would require a more complex system.

But the natural language generator sounds interesting.
I actually did write the Scripts for the Quest classes (Tasks, Requirements, Dialog, etc...) which do the same thing with a separate quest editor application for it. I am not giving it out just yet because I am deciding of actually just writing the classes in C using the sqlite3 for the database making it easier to use them in different languages for interop making it reusable. One of the main reasons for doing this is that freeing up sqlite3 (db) object and freeing resources are better for memory and faster over all being in binary and not interpreted or byte code.

Original thread: https://forums.rpgmakerweb.com/threads/quest-system.3085/