Quest scripts syntax for AI: Difference between revisions

From PSwiki
Jump to navigation Jump to search
Created page with "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. 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. Exam..."
 
No edit summary
Line 2: Line 2:


Any line starting with # is a comment. We add at the start of the file the name and prerequisites as comments.
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:
The quest script is divided in steps. Each one being separated with this line:


... NoRepeat
  ... NoRepeat


This line tells the engine to create a new step. Only the first step does not have the ... line
This line tells the engine to create a new step. Only the first step does not have the ... line
Line 11: Line 16:
Every step starting from the second one, start with a comment stating the step number, this is important for readability. Example:
Every step starting from the second one, start with a comment stating the step number, this is important for readability. Example:


# Step 2
  # 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.
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.
Line 17: Line 22:
Requiments are expressed like this, where we substitute <quest name> with the name of the quest:
Requiments are expressed like this, where we substitute <quest name> with the name of the quest:


Require completion of <quest name> step 2.
  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:
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
  P: 15002.


Every step must have a Menu: line . This is what the player will select from the possible speak options. Example:
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?
  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:
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!
  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:
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.
  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.
 
A full example follows. In this example there are two parallel possible answers to the NPC question:
 
  # 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.


# Quest name
  ... NoRepeat
  # Step 4
  Require completion of Searching the blacksmith step 2.
  P: 15004.
  Menu: No sorry, I cannot do it right now.
  Harnquist: Ok, come back later then.
  QuestNote I had to refuse Harnquist offer for now.
  Complete Searching the blacksmith Step 4.

Revision as of 15:25, 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.

A full example follows. In this example there are two parallel possible answers to the NPC question:

 # 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: No sorry, I cannot do it right now.
 Harnquist: Ok, come back later then.
 QuestNote I had to refuse Harnquist offer for now.
 Complete Searching the blacksmith Step 4.