How tasks work

From ADRIFT 5 Manual Wiki
Revision as of 04:01, 1 February 2014 by Saabie (Talk | contribs)

Jump to: navigation, search
THE MAIN ITEMS
Locations
Objects
Tasks
---- Specific
---- General
---- System
---- Executing sub-tasks
---- How tasks work
Characters
Events
Variables
Groups
Properties
Text Overrides
Hints
Synonyms
User functions

This is a step-by-step description of how ADRIFT processes a players command and chooses which tasks to run.

It is not meant to be read through start to finish, it is provided as a reference for more advanced ADRIFT uses to help design more complex multiple-task commands and debug problems.

  1. The first thing the parser does is replace the words "it", "them", "him" and "her" with the appropriate object or character that the player most recently refered to.
  2. The parser now checks each general task, starting from the one with the lowest number in the "Task Priority:" field on its "Advanced" page and proceeding in order until it finds a match between the player's input and one of the command lines of a task, using "Advanced Command Construction" matching.
  3. When it finds a matching general task, it now tries to match the references. Eg.If the command contains an %object% reference then ADRIFT searches through all of the objects in the game trying to find one which matches what the player typed in that part of the input. Note that the player may have entered the names of several objects, eg. "the watch and the pendant" or "all except the hat" or "pens" (which can mean all objects with "pen" as the noun if no objects are called "pens"). All of these must match items in the game.
  4. The player may have typed an ambiguous name that matches several items in the game, for example "pen" could match "red pen", "blue pen" or "green pen" if these all exist. To decide which one the player meant, ADRIFT uses a "scope" system to help choose between them.
    1. The first thing scope does is to check the items against the restrictions of the general task, if only one of them passes then it is assumed to be the one the player meant.
    2. If more than one passes restrictions then scope checks to see if one of those is currently visible to the player and chooses it.
    3. If none of them are currently visible, then scope checks to see if one of the items has ever been seen by the player.
    4. If more than one item passes these scope checks, then the player is asked a disambiguation question such as "Do you mean the red pen, the blue pen or the green pen?" to determine which item they meant.
  5. ADRIFT has now matched all of the objects, characters and/or locations that the player mentioned to the references in the command, so it can start to execute the task. If there are multiple items for a reference then ADRIFT executes the task once for each item, but only displays the text box once. Functions in the text box which have a different result are combined into a list, so if we run the task for the objects "a blue pen", "a gold coin" and "a flower" then the text "You pick up %object%.Name" is displayed as "You pick up the blue pen, the gold coin and the flower"
  6. The restrictions of the general task are now checked. If a restriction fails then ADRIFT skips that general task and resumes searching through the lower priority general tasks for the next match.
    1. If the restriction that failed has a completely blank text box OR it finds a matching general task that does NOT have the "This task can be overridden by other task restriction failures" checkbox selected, then ADRIFT tries to execute this new task.
    2. If the restriction that failed contains text AND the "This task can be overridden by other task restriction failures" checkbox IS selected on the new task, then ADRIFT will ignore it and continue searching for another match.
    3. If the restriction that failed contains text, and ADRIFT does not find another task that it can execute, then that text is displayed to the player as a failure message and the player is prompted to enter their next command.
  7. If the restrictions pass then ADRIFT next checks to see if that general task has any specific tasks that are set to "run before" or "override" it.
    1. These tasks are checked in priority order.
    2. If the specific task has had any of its references made specific to a particular item, then that must be the item specified by the player, otherwise it is ignored.
    3. All of the restrictions of the specific task must pass, otherwise the same steps specified in section 6 above for general tasks are performed for the specific tasks.
    4. If the specific task matches and passes restrictions then:
      1. It could itself have specific tasks that override it, so if present we recursivly execute them now.
      2. If the option "Display completion message Before/After executing actions" on the "Advanced" page of this task is set to "Before", then the text box contents are displayed to the player.
      3. The task's actions are performed. These can execute other tasks for further processing.
      4. If "Display completion message Before/After executing actions" is set to "After", then the text box contents are displayed.
    5. If the specific task that executes has the "Continue executing matching lower priority tasks (multiple matching)" checkbox selected on its "Advanced" page, then ADRIFT continues to check any remaining specific tasks in priority order.
  8. If there are no "override" tasks, or they fail matching or restrictions, then the text box of the general task is displayed to the player and its actions are performed. If a "run before" task has executed successfully then it controls which parts of the general task execute with its "Display parent message" and "Execute parent actions" check boxes. The order they are done in is controlled by "Display completion message Before/After executing actions" on the general task "Advanced" page.
  9. ADRIFT next checks to see if that general task has any specific tasks that are set to "Run after" it, and if so, and they match the references and pass restrictions, then they are executed.
  10. Finally, ADRIFT checks the "Continue executing matching lower priority tasks (multiple matching)" checkbox on the "Advanced" page of the general task. If this is selected then ADRIFT continues to search lower priority general tasks for another match and goes back to step 3 above if it finds one.


<<< Executing sub-tasksMain_PageCharacters >>>