GoalDefinition

A GoalDefinition is a reusable template that describes the criteria required to complete a goal, and also the MutationActions and RenderActions that occur when the goal is completed.

GoalDefinitions provide two methods to describe their completion criteria; rules, and expressions.

Rules

GoalDefinitions have many explicit rules that can be defined and considered. Every GoalDefinition can combine as many or as few of the rules to describe the specific conditions that the goal completes. When multiple rules exist for a GoalDefinition, all rules must complete for the goal to complete.

Requires Rules

All require rules are treated as logical and. This means that when multiple values are provided for each rule, all must exist for the rule to complete.

RequiresActors

All the listed actors must exist in the same location as the actor that owns the goal.

RequiresItems

All the listed items must exist in the same location as the actor that owns the goal.

RequiresInventory

All the listed items must be in the owning actor’s inventory.

RequiresMemories

The owning actor must have all the listed memories

RequiresOwnerFacts

The owning actor must have all the listed facts

RequiresTargetActorFacts

The owning actor must be interacting with an actor that has all the listed facts.

RequiresTargetItemFacts

The owning actor must be interacting with an item that has all the listed facts.

RequiresLocationActorFacts

The owning actor must be in a location with another actor that has all the listed facts.

RequiresLocationItemFacts

The owning actor must be in a location with an item that has all the listed facts.

RequiresMinimumAge

The actor must have the goal for at least this long before it is completable.

Invalid Rules

Values for invalid rules are treated as logical or. If a rule provides more than one value, the rule completes if any of the values exist.

InvalidOwnerFacts

If the actor as one or more listed facts, the goal will not complete.

InvalidLocationActorFacts

if the owning actor is in a location with other actors, and any other actor has at least one of the listed facts, the goal will not complete.

Valid Rules

Values for valid rules are treated as logical or. If a rule provides more than one value, the rule completes if any of the values exist.

ValidLocations

The owning actor must be in one of the listed locations

ValidEpisodes

The owning actor must be in one of the listed episodes

ValidEventTypes

The owning actor must have sent an event with one of the listed types

Expressions

Expressions allow for more flexibility to describe very specific completion conditions. Expressions are small scripts that evaluate to true or false. When an expression evaluates to true, the goal completes.

Every expression has access to a variety of data to use when writing rules:

Variable Type Description
s Snapshot The current snapshot that contains all relevant StoryEngine state.
actor Actor The Actor that is under consideration for completing the goal
event Event The event that triggered the evaluation, if applicable
ctx Context The context object from the Event that triggered the evaluation. This typically contains the JSON payload from the game that emitted the event.

Refer to Expression Reference for details on how to write expressions.