(mochi) Quests


Allow custom quests for the user to complete. By default works with the Crayta Inventory script as
installed in the adventure blueprint. Can be modified to work with your own custom inventory script.

  1. Install the (mochi) Quests v2 package ((mochi) Quests package was created incorrectly and is empty)
  2. Drag the UserQuestTemplate on to the User template

If using the default Crayta Inventory, skip to the Quest Creation instructions, otherwise continue to Custom Inventory Setup

Custom Inventory Setup
  1. On the User template select the UserQuestScripts folder
  2. Select the showAdvancedSettings checkmark - Fields under the Inventory group need to be updated
  3. inventoryScriptName - set to the name of your inventory script
  4. inventoryUpdateEventName - set to the name of the event that fires when the user inventory is updated
    (any time an item is added or removed)
  5. addItemCallback - set to the name of the callback to use to add an item to the inventory
    (signature should be (itemTemplate, count))
  6. itemCountCallback - set to the name of the callback to use to get how many of a specific item the user has
    (signature should be (itemTemplate))
  7. removeItemCallback - set to the name of the callback to use to remove an item from the inventory
    (signature should be (itemTemplate, count))
Quest Creation

You’re ready to create your first quest!
Create a new template based off of the EmptyQuestTemplate to make organization easier.

Select the QuestScripts folder in the new quest template and set questName to a user friendly text.

Add an ObjectiveScript to the Objectives folder.

Each quest can have as many objectives as desired.

Set the objectiveText to a user friendly objective name (short but descriptive)
There are two objectiveTypes that are currently implemented:
collect - this objective type is to hold a certain number items in the users inventory
settings needed are:
the item required
how many of the item is required
whether or not to consume (remove from inventory) the item at the end of the quest

`event` - this objective type is to trigger a certain event a set number of times
    settings needed are:
        the event name
        how many times this event needs to be triggered

Objectives can be mixed and matched

Add a RewardScript to the Rewards folder.

Each quest can have as many rewards as desired.

Currently the only reward type is an item reward.
settings needed are:
the item to add
how many of the item to try to add to the inventory

Claiming Quests

Now that you’ve finished creating a quest, it’s time to add a way to claim quests!
Add the QuestGiverScripts template to the entity that should give the quest.
Set the questToGive property to the quest template created above.

You may choose to have the quest be given immediately upon interacting with the entity the script folder is attached to.

If not through interact, then the function GiveQuest must be triggered through your own custom function with either
a first parameter as a user or player entity.

Completing Objectives

Fulfilling collect objectives is as simple as playing through the game and adding things to your inventory.
To trigger a quest event, the QuestEventTriggerScripts template can be added to the entity that will trigger a specific quest event.
Set the eventToTrigger property to the event name that is required by the objective.
count is how many times this action counts as for this event.

Optional flag to trigger this event on interacting with the entity that the script is attached to.

If not through interact, the function TriggerEvent should be called with a first parameter of either a user or player in order to trigger the quest event.
To directly send a quest event to the user, the function OnQuestEventTriggered should be called on the user with parameters (eventName, count).

With this, you should be able to give users quests and rewards for finishing them!

The UserQuestScript will fire an OnQuestComplete event whenever the user completes a quest.
Event parameters are (userEntity, questTemplate, questId).
Check out Crayta - Create Games for a (remixable) showcase.

For questions and bugs please contact @mochi in the official Crayta discord.