Quest scripts syntax for AI: Difference between revisions

From PSwiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 69: Line 69:
   # ID: 1500
   # ID: 1500


   P: 15001
   P: 15001.
   Menu: Hello, who are you?
   Menu: Hello, who are you?
   Harnquist: I'm the local blacksmith!
   Harnquist: I'm the local blacksmith!

Revision as of 16:17, 6 April 2026

This is the syntax to create a quest script.

Any line starting with # is a comment. We add at the start of the file the name and prerequisites as comments.

Example:

 # Quest: Searching the blacksmith
 # ID: 1500

The quest script is divided in steps. Each one being separated with this line:

 ... NoRepeat

This line tells the engine to create a new step. Only the first step does not have the ... line

Every step starting from the second one, start with a comment stating the step number, this is important for readability. Example:

 # Step 2

Each step can have a prerequisite step to be executed, example step 3 will require step 2 to be executed. If you have parallel steps, then the requirement for step 3 and step 4 can all point to step 2.

Requiments are expressed like this, where we substitute <quest name> with the name of the quest:

 Require completion of <quest name> step 2.

Every step must have a P: line with the questid plus a progressive number, which corresponds to the step. Example, assuming our quest number is 1500, and step is 2:

 P: 15002.

Every step must have a Menu: line . This is what the player will select from the possible speak options. Example:

 Menu: Hello, who are you?

Every step must have a line with the answer from the NPC, which starts with the name of the NPC, example:

 Harnquist: I'm the local blacksmith!

Every step must have a quest note that goes into the player journal summarizing what he accomplished or learned in that step. Example:

 QuestNote You met Harnquist the local blacksmith.

Every step must finish with a line that completes the step, example:

 Complete Searching the blacksmith Step 2.

The first step is a different than the others in this way: 1) it doesn't have a Require completion of 2) instead of the "Complete" step line, it has "Assign Quest." line, which basically stores the quest in the player log as started.

The second step differs just for the fact it doesn't have a "Require completion of" line.

We also use brackets [] to indicate some visual action from the NPC, example:

 Harnquist: [He seems pleased by your question] Yes I need to forge a new longsword.

All lines except comments should always end with a period or a question/exclamation mark. This is how the engine knows that directive is completed.

We also have the possibility to have multiple questions and answers in the same step, this is done usually when the discussion is about the same topic and doesn't require a separate QuestNote. In this case the structure is P: , then Menu: , then the npc line. The P must be unique so here we append a letter to the end, example 15005a, 15005b, ...

When we move to another NPC it's required to have a separate step.

If the dialogue branches and then we need to merge it again in one step later on, we can use the OR operator that's a pipe |. This example requires step 3 or step 4 to be completed:

 Require completion of Searching the blacksmith step 3 | completion of Searching the blacksmith step 4.

A full example follows. In this example there are two parallel possible answers to the NPC question, and also a longer discussion in one last step:

 # Quest: Searching the blacksmith
 # ID: 1500
 P: 15001.
 Menu: Hello, who are you?
 Harnquist: I'm the local blacksmith!
 QuestNote You met Harnquist the local blacksmith.
 Assign Quest.
 ... NoRepeat
 # Step 2
 P: 15002.
 Menu: Do you need any help?
 Harnquist: [He seems pleased by your question] Yes I need to forge a new longsword. Are you interested in it?
 QuestNote Harnquist asked if we want to help forging a new longsword.
 Complete Searching the blacksmith Step 2.
 ... NoRepeat
 # Step 3
 Require completion of Searching the blacksmith step 2.
 P: 15003.
 Menu: Yes, sure I would like help.
 Harnquist: Great, then please bring me 10 iron ore.
 QuestNote I agreed to help, and Harnquist asked for 10 iron ore.
 Complete Searching the blacksmith Step 3.
 ... NoRepeat
 # Step 4
 Require completion of Searching the blacksmith step 2.
 P: 15004.
 Menu: Yes I want to help, but I can do it tomorrow.
 Harnquist: Ok, come back tomorrow then and please bring me 10 iron ore.
 QuestNote I had to ask one more day, and Harnquist asked for 10 iron ore to be delivered tomorrow.
 Complete Searching the blacksmith Step 4.
 ... NoRepeat
 # Step 5
 Require completion of Searching the blacksmith step 3 | completion of Searching the blacksmith step 4.
 P: 15005.
 Menu: I have the ore you requested.
 Harnquist: Very good!
 P: 15005a.
 Menu: Can you evaluate its quality?
 Harnquist: Sure I can, let me look. [Harnquist puts on a set of glasses to inspect the ore]
 QuestNote I brought the ore to Harnquist.
 Complete Searching the blacksmith Step 5.