Skip to content

Dialogues

Luke100000 edited this page Dec 31, 2022 · 7 revisions

Dialogues consist of questions, answers, results, and actions.

Question

Asked by the villager

  • Has an unique id defined by their file name.
  • Can be marked as silent, which prevents the villager from saying this phrase out loud. Instead, the last phrase will on top.
  • Can be flagged as auto, which automatically selects a random answer. Necessary to jump to another answer without asking a question.
  • Contains a list of possible answers.
{
  "silent": false,
  "auto": true,
  "answers": [
    ...
  ]
}

Naming the file the same as an existing question will either replace it, if the namespace is mca, or extend it if you use a custom namespace.

Answer

Possible answer for the player

  • Has a name, unique across the question.
  • Uses dialogue.questionId.answerName as translation.
  • Can have a comma separated list of constraints required to make this answer visible. See constraints chapter for documentation.
  • Can have a priority to define the order of injection, positive numbers add the answers on top. See example chapter for more info.
  • Has a list of results.
{
  "name": "answerName",
  "constraints": "!adult",
  "priority": 1,
  "results": [
    ...
  ]
}

Result

Possible outcomes caused by an answer

  • Has a base chance
  • A list of conditions where each has an additive chance modifier, and one or more predicates. See Gifts predicates for a list of possible conditions.
  • Has a flag on whether to apply fatigue, the often you speak, the less likely the success.
  • Has a map of actions to execute, if this result happens.
{
  "baseChance": 4,
  "applyFatigue": false,
  "conditions": [
    ...
  ]
  "actions": {
    ...
  }
}

Action

Actions are key-value pairs performed in a result:

  • next define the next question
  • say says a phrase, prefixed by dialogue.
  • positive grant hearts and mood
  • negative does the opposite
  • command passed to the CommandHandler. This is more dev-related.

Constraints

Check out the list of possible constraints here. In the constrain string, use lowercase and no spaces and ! to invert, e.g. !adult,!teen. https://github.com/Luke100000/minecraft-comes-alive/blob/1.18.2/common/src/main/java/net/mca/entity/interaction/Constraint.java

Examples

There is an example data and resource pack available: https://github.com/Luke100000/minecraft-comes-alive/blob/1.18.2/example/rockPaperScissor.zip

It contains the rock paper scissor part from the MCA.

  • /data/your_namespace/dialogues/main.json contains the injection into the main question.
  • /data/your_namespace/dialogues/rock_paper_scissor.json contains the actual game.
  • /assets/your_namespace/lang/en_us.json contains the translations
Clone this wiki locally