Quests and conversations

Quests

kcds.characters.Quest writes entries into the game's own journal. The server stores each quest, so players who join late or reload still have it. A quest goes to one player or, when you leave out player, to everyone in its dimension.

const { Quest } = kcds.characters;
const { Vector3 } = kcds.math;

const delivery = Quest.give('deliver_grain', 'Grain for the mill', {
  player,
  description: 'The miller needs three sacks of grain.',
  objectives: [
    { text: 'Collect the grain', position: new Vector3(512, 830, 31) },
    { text: 'Bring it to the miller' },
  ],
  track: true,
});

delivery.setObjective(0, { text: 'Collect the grain', progress: 'done' });
delivery.setProgress('done');

A quest has up to 8 objectives. An objective with a position shows on the map while the quest is being tracked.

SettingValues
type'main', 'side' (default), 'activity', 'event', 'micro', 'racing'
progress'active', 'done', 'failed'
announcefalse leaves out the game's notification

To look quests up, use Quest.find(key, dimension?, player?) or Quest.all(). On a quest, remove() deletes it and track(player?) and untrack(player?) change tracking. The event questTrackingChanged(quest, player, tracked) tells you when tracking changes.

Conversations

kcds.characters.Dialogue opens the game's dialogue list with a line above it. Your script decides what each choice does.

const { Dialogue } = kcds.characters;
const { Events } = kcds.core;

Events.on('npcInteract', (npc, player) => {
  const page = {
    line: 'What brings you to the mill?',
    options: [
      { id: 'work', text: 'I am looking for work.' },
      { id: 'bye', text: 'Nothing. Farewell.' },
    ],
  };
  Dialogue.open(player, page, { npc });
});

Events.on('dialogueChoice', (session, player, optionId) => {
  if (optionId === 'bye') {
    Dialogue.close(session);
    return;
  }
  Dialogue.update(session, {
    line: 'Carry these sacks.',
    options: [{ id: 'bye', text: 'Right away.' }],
  });
});

Each page needs 1 to 8 options with different ids. Set enabled: false to grey one out.

You can also say when a conversation should end by itself:

  • npc: when this speaker dies
  • position and radius: when the player walks away
  • timeout: after a set time

The event dialogueClosed(session, player, reason) reports the end. The reason is 0 when your script closed it, 1 when the player backed out, 2 when another dialogue replaced it and 3 when it was interrupted.

The game's own conversations

Conversations from the game with its NPCs are always off on KCDS servers, because they crashed players' games (the "Vyřešíme to spolu" option). Use Dialogue instead.

Talking to another player is a separate game feature that you can enable with kcds.players.Interactions.set('playerTalk', true); see Server rules.

Reference: Quest, Dialogue.