Quests
The quest system is a way to create and manage quests in your game. Quests can have multiple stages, and players can complete them to earn rewards or progress in the story.
Initialize
To initialize a quest, create a new instance of the QuestBaseModel class (or your custom class) and add it to the game quest dictionary when the game is initialized.
RegisteredQuests.add is required to save the quests in the game.
import { mcRoom, terrace } from "@/content/rooms";
import { RegisteredQuests } from "@drincs/nqtr";
export const aliceQuest = new QuestBaseModel(
"aliceQuest",
[
// stages
new StageBaseModel("talk_alice1", {
onStart: () => {
terrace.addCommitment("alice_quest_talk");
},
name: "Talk to Alice",
description: "Talk to Alice on the terrace",
}),
new StageBaseModel("order_products", {
onStart: () => {
mcRoom.addActivity("order_product");
},
name: "Order products",
description: "Order the products with your PC",
}),
new StageBaseModel("take_products", {
onStart: (_, { toast }) => {
terrace.addActivity("take_product");
toast("You can take the products on the Terrace");
},
name: "Take products",
description: "Take products on the Terrace",
requestDescriptionToStart: "Wait for the products you ordered to arrive (2 day)",
deltaDateRequired: 2,
}),
new StageBaseModel("talk_alice2", {
name: "Talk to Alice",
description: "Talk to Alice on the terrace",
}),
],
{
// props
name: "Help Alice",
description:
'To learn more about how the repo works, Talk to Alice. \nGoing when she is there will automatically start an "Event" (see aliceQuest.tsx to learn more). \nAfter that an action will be added to open the pc, in MC room. \n\n(during the quest you can talk to Alice and you will see her talking during the quests of the same Quest)',
image: "alice_terrace0A",
onStart: (quest, { toast, uiTransition }) => {
toast(uiTransition("notify_quest_is_started", { quest: quest.name }));
},
onContinue: (stage, { toast, uiTransition }) => {
toast(uiTransition("notify_quest_is_updated", { quest: stage.name }));
},
},
);
RegisteredQuests.add(aliceQuest);Start
To start a quest, you can use the quest.start method of the Quest class. This method will set the current stage to the first stage of the quest and trigger the onStart action defined in the quest.
import { newLabel } from "@drincs/pixi-vn";
import { aliceQuest } from "@/content/quests/alice.quest";
export const startLabel = newLabel("start", [
async (props) => {
await aliceQuest.start(props);
},
]);Continue
To go to the next stage of a quest, you can use the quest.continue method of the Quest class. This method will set the current stage to the next stage of the quest and trigger the onContinue action defined in the quest.
import { newLabel } from "@drincs/pixi-vn";
import { aliceQuest } from "@/content/quests/alice.quest";
export const startLabel = newLabel("start", [
async (props) => {
await aliceQuest.continue(props);
},
]);Get
To get a quest by its id, use the RegisteredQuests.get function.
import { RegisteredQuests } from "@drincs/nqtr";
const aliceQuest = RegisteredQuests.get("aliceQuest");Get all
To get all quests, use the RegisteredQuests.values function.
import { RegisteredQuests } from "@drincs/nqtr";
const quests = RegisteredQuests.values();