Implementation

To implement Quests and Missions, we can heavily used functionalities given by Interactions, Dialog and Perceptions systems. Cf related RFC to more info about these systems.

The Quests system is heavily flexible and generic.

Quests creation

Quests can be created with the QuestsEditor (manual creation) or automagically by the game itself (in reaction to some events).

Quest object

The game manages a list of Quest objects.

A Quest object contains:

Requested and forbidden criterions determine who can do a given Quest and who can't (for example, murders are for evil people).

Note

It's possible a quester doesn't match anymore the criterions during or at the end of the Quest.

The states in the state machine are used to keep questers progression.

The Quest can be not linear (several ways to one or several exits).

For Quests for groups, it's possible to divide the group (several states should be accomplished at the same time) or not (action to difficult for one person).

A Quest can be unique (only one quester can succeed). It's removed after the first success.

A Quest can be 'one times only' (a given quester can do it only one times). A mark is kept on the quester for remembering.

Example 1. State machine of a Murder Mission

(0) --> (1) --|--> (2) |--> (3)

State 0: the Quest giver explains the Mission/Quest. 0 -> 1: the quester kills the victim. State 1: (nothing) 1 -> 2: the quester brings the corpse to the Quest giver State 2: reward 1000 gold. 1 -> 3: the quester brings just the victim ID card to the Quest giver. State 3: reward 100 gold (and if he/she/it lies, the quest giver could send new questers to kill the lier).

To detect a state change, we could wrap a detector around some Actions. For example, if the quester should deliver an object to somebody, the "to give" Action is wrapped. If the quester calls the new Action with the good object and the good receiver as parameters, the Quest state is changed and the original Action is called. If not, the original Action is directly called. The quester can also progress in the Quest just by saying a word to somebody (see Dialog-RFC).

Each Character keeps a list of QuestID (for missions/quests he/she/it's doing).

QuestsEditor

The QuestsEditor offers a GUI interface to create Quests (a text interface can also exist). To create a Quest, you need to provide a list of potential Quest givers, the requested and forbidden criterions and a state machine.

The list of potential Quest givers can contain:

Items of the list/a named group can be affected by 4 operators:

This list can't be empty.

Example 2. A list of potential Quest givers

[EntityID: Raoul] AND ( [Group: SecurityForces] AND NOT [Type: elf] ) where SecurityForces = ( [Influence: Guard] OR [Influence: Watchman] OR [Influence: Fighter] )

As soon as one of the Quest givers matches criterions, a Quest object is created and the Quest giver can propose the Quest.

The criterions list can contain:

Items of the criterions list/a named group can be affected by the 4 operators.

Note

It could also contain affects, memories, relationships, as soon as they had be defined...

Example 3. A criterions list

Quester should match [Property: Strength >= 13] OR [Influence: Guard] AND NOT [Possession: Malediction ring].

The state machine is defined by an initial state, one or more transitions and state effects.

A transition is defined by an origin state, a destination state and a transition condition.

A transition condition can contain:

Items of a transition/a named group can be affected by the 4 operators (except for Action(s)).

State effects are operations to be executed when the corresponding state is reached. Operation mean a list (EntityID, Action, Parameters).

Example 4. A state machine

Initial state '0' Transition: '0' to '1' ([Action: 'kill' with victim's EntityID as parameter]) Transition: '1' to '2' ([Action: 'give' with quest giver as destination and victim's corpse as object] AND [Possession: corpse] Transition: '1' to '3' ([Action: 'give' with quest giver as destination and victim's ID card as object] AND [Possession: ID card] State 0: [EntityID: Quest giver][Action: explains][Parameters: MissionID] State 1: (nothing) State 2: [EntityID: Quest giver][Action: special_give][Parameters: 1000 gold to quester] ('special_give' is 'give' if the quest giver has 1000 gold and 'say I am sorry and give what I am' if not) State 3: [EntityID: Quest giver][Action: defiant_special_give] [Parameters: 100 gold to quester] ('defiant_special_give' is 'special_give' with only 100 gold, and a quest murder is created, with rumour 'victim is alive' as needed criterion)