Requirement Functions

Announcements, support questions, and discussion for Quest Machine.
Post Reply
AArtlone
Posts: 37
Joined: Tue Mar 09, 2021 2:54 am

Requirement Functions

Post by AArtlone »

Hi!

I continue exploring the possibilities of the Quest Generation and currently, I am looking at the Requirement Functions(RF).

I did not manage to find much info on RFs in your manual, video series, or Demo scene.

I have also noticed that there is no template for the RF. Is there a reason for that? Do you not recommend creating custom Requirement Functions?

In general, I would appreciate it very much if you could share your thoughts on what RFs are intended to be used for, and perhaps some best practices or use-case examples.

Thanks in advance.

Artem
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: Requirement Functions

Post by Tony Li »

Hi Artem,

I've made a note to add documentation on requirement functions to the manual and also add a template script.

A requirement function defines a condition that must be true in order for a quest generator to use an action.

Requirement functions are ScriptableObject assets. To add a requirement function to an action, create a requirement function asset, and assign it to the action's Requirements section.

This is the entire definition of RequirementFunction:

Code: Select all

public abstract class RequirementFunction : ScriptableObject
{
    public abstract string typeName { get; }
    public abstract bool IsTrue(WorldModel worldModel);
}
  • typeName is just for displaying a human readable description in the editor.
  • IsTrue(worldModel) checks if a given world model meets the requirement.
To write a custom requirement function, make a subclass of RequirementFunction and override typeName and IsTrue. Then create an asset using that script, and assign it to an action.

Quest Machine includes one built-in subclass: FactionRequirementFunction requires that one entity type's faction toward another entity type is within a specified range. You can examine FactionRequirementFunction for ideas. It makes use of the EntitySpecifier type, which lets the designer specify entity types in flexible ways (e.g., current quester, current quest giver, specific entity type, etc.).

Several of the integration packages include additional requirement functions. For example, the Love/Hate integration includes a function that checks Love/Hate's more extensive faction system.
AArtlone
Posts: 37
Joined: Tue Mar 09, 2021 2:54 am

Re: Requirement Functions

Post by AArtlone »

Hi Tony!

Thanks for the response and explanation. Indeed adding the documentation for it would be helpful.

I just want to clarify something. My initial understanding of the RequirementFunction (RF) was that it decides on it's own whether the action can be performed. But now I understand that it works on top of the check that checks whether the entity is in a domain.

So that means that once we completed the basic check, for example, if the Orc is in the Forest, we can use the RF to check some additional information related to the Entity.

Please correct me if I am wrong.

Thanks in advance.
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: Requirement Functions

Post by Tony Li »

Hi,

Yes, your understanding is exactly correct.
AArtlone
Posts: 37
Joined: Tue Mar 09, 2021 2:54 am

Re: Requirement Functions

Post by AArtlone »

Alright, thanks a lot!

Till next time :)
Post Reply