Show / Hide Table of Contents

Class QuestMachine

Hosts quests and manages their execution during play. Quests are instantiated from a source text template. It's possible to have the same quest multiple times (e.g. same fetch quest from two different mage guildhalls). Running quests can perform actions in the world (e.g. spawn enemies and play sounds). Or they can provide data to external systems like the NPC dialog interface (e.g. 'tell me about' and 'rumors'). Quest support is considered to be in very early prototype stages and may change at any time.

Inheritance
Object
Object
Component
Behaviour
MonoBehaviour
QuestMachine
Namespace: DaggerfallWorkshop.Game.Questing
Assembly: Assembly-CSharp.dll
Syntax
public class QuestMachine : MonoBehaviour

Fields

| Improve this Doc View Source

questFoeTag

Declaration
public const string questFoeTag = "QuestFoe"
Field Value
Type Description
String
| Improve this Doc View Source

questItemTag

Declaration
public const string questItemTag = "QuestItem"
Field Value
Type Description
String
| Improve this Doc View Source

questPersonTag

Declaration
public const string questPersonTag = "QuestPerson"
Field Value
Type Description
String

Properties

| Improve this Doc View Source

DiseasesTable

Gets the diseases data table.

Declaration
public Table DiseasesTable { get; }
Property Value
Type Description
Table
| Improve this Doc View Source

FactionsTable

Gets the factions data table.

Declaration
public Table FactionsTable { get; }
Property Value
Type Description
Table
| Improve this Doc View Source

FoesTable

Gets the foes data table.

Declaration
public Table FoesTable { get; }
Property Value
Type Description
Table
| Improve this Doc View Source

GlobalVarsTable

Gets the global variables data table.

Declaration
public Table GlobalVarsTable { get; }
Property Value
Type Description
Table
| Improve this Doc View Source

HasInstance

Declaration
public static bool HasInstance { get; }
Property Value
Type Description
Boolean
| Improve this Doc View Source

Instance

Declaration
public static QuestMachine Instance { get; }
Property Value
Type Description
QuestMachine
| Improve this Doc View Source

InternalSeed

Return a new random seed

Declaration
public int InternalSeed { get; }
Property Value
Type Description
Int32
| Improve this Doc View Source

IsDebugModeEnabled

Returns true if debug mode enabled. This causes original quest source line to be stored and serialized with quests. Always enabled at this stage of development.

Declaration
public bool IsDebugModeEnabled { get; }
Property Value
Type Description
Boolean
| Improve this Doc View Source

ItemsTable

Gets the items data table.

Declaration
public Table ItemsTable { get; }
Property Value
Type Description
Table
| Improve this Doc View Source

LastNPCClicked

Gets or sets StaticNPC last clicked by player.

Declaration
public StaticNPC LastNPCClicked { get; set; }
Property Value
Type Description
StaticNPC
| Improve this Doc View Source

PlacesTable

Gets the places data table.

Declaration
public Table PlacesTable { get; }
Property Value
Type Description
Table
| Improve this Doc View Source

QuestCount

Gets count of all quests running at this time.

Declaration
public int QuestCount { get; }
Property Value
Type Description
Int32
| Improve this Doc View Source

QuestSourceFolder

Gets Quests source folder in StreamingAssets.

Declaration
public static string QuestSourceFolder { get; }
Property Value
Type Description
String
| Improve this Doc View Source

SiteLinkCount

Gets current count of all active SiteLinks.

Declaration
public int SiteLinkCount { get; }
Property Value
Type Description
Int32
| Improve this Doc View Source

SoundsTable

Gets the sounds data table.

Declaration
public Table SoundsTable { get; }
Property Value
Type Description
Table
| Improve this Doc View Source

SpellsTable

Gets the spells data table.

Declaration
public Table SpellsTable { get; }
Property Value
Type Description
Table
| Improve this Doc View Source

StaticMessagesTable

Gets the static message names data table.

Declaration
public Table StaticMessagesTable { get; }
Property Value
Type Description
Table
| Improve this Doc View Source

TablesSourceFolder

Gets Tables source folder in StreamingAssets. TODO: This folder isn't ultimately exclusive to quests. Find a more generic spot later, e.g. GameManager.

Declaration
public string TablesSourceFolder { get; }
Property Value
Type Description
String

Methods

| Improve this Doc View Source

ActiveFactionPersons(Int32)

Gets any assigned Person resources of faction ID across all quests.

Declaration
public Person[] ActiveFactionPersons(int factionID)
Parameters
Type Name Description
Int32 factionID

FactionID to search for.

Returns
Type Description
Person[]

Person array.

| Improve this Doc View Source

ActiveQuestor(StaticNPC.NPCData)

Finds an active questor given a specific static NPC. NPCData passed must be populated with runtime data such as map id and building key.

Declaration
public Person ActiveQuestor(StaticNPC.NPCData npcData)
Parameters
Type Name Description
StaticNPC.NPCData npcData
Returns
Type Description
Person
| Improve this Doc View Source

ActiveQuestor(Int32)

Find an active questor for an individual NPC faction ID across all quests. Individual NPCs can only be assigned as a questor by one quest at a time.

Declaration
public Person ActiveQuestor(int factionID)
Parameters
Type Name Description
Int32 factionID

FactionID of individual NPC to search for.

Returns
Type Description
Person

Person resource.

| Improve this Doc View Source

AddFactionListener(Int32, IQuestAction)

Add a faction listener for the individual faction ID. Does nothing if faction ID already claimed.

Declaration
public void AddFactionListener(int factionID, IQuestAction owner)
Parameters
Type Name Description
Int32 factionID
IQuestAction owner
| Improve this Doc View Source

AddSiteLink(SiteLink)

Adds a site link to quest machine. There is no strong unique key to use for site links so they are stored in a flat list. Only a small number of site links will be ever active at one time in normal play.

Declaration
public void AddSiteLink(SiteLink siteLink)
Parameters
Type Name Description
SiteLink siteLink

SiteLink to add.

| Improve this Doc View Source

ClearQuests()

Declaration
public void ClearQuests()
| Improve this Doc View Source

ClearState()

Resets operating state - clears all quests, sitelinks, debuggers, etc. Quests will not be disposed or tombstoned they will just be dropped for garbage collector.

Declaration
public void ClearState()
| Improve this Doc View Source

CreateMessagePrompt(Message)

Creates a yes/no prompt from quest message. Caller must set events and call Show() when ready.

Declaration
public DaggerfallMessageBox CreateMessagePrompt(Message message)
Parameters
Type Name Description
Message message
Returns
Type Description
DaggerfallMessageBox
| Improve this Doc View Source

CreateMessagePrompt(Quest, Int32)

Creates a yes/no prompt from quest message. Caller must set events and call Show() when ready.

Declaration
public DaggerfallMessageBox CreateMessagePrompt(Quest quest, int id)
Parameters
Type Name Description
Quest quest
Int32 id
Returns
Type Description
DaggerfallMessageBox
| Improve this Doc View Source

CreateSiteLink(Quest, Symbol)

Creates a new SiteLink at Place.

Declaration
public static void CreateSiteLink(Quest parentQuest, Symbol placeSymbol)
Parameters
Type Name Description
Quest parentQuest
Symbol placeSymbol
| Improve this Doc View Source

CullResourceTarget(QuestResource, Symbol)

Removes an existing quest resource allocation (if present). This is called when allocating a resource to ensure it is removed from any previous SiteLinks For example, Sx011 will move Barenziah's book from Orsinium to Scourg Barrow after a time limit expires. Allocation needs to be removed from Orsinium or item will be present in both locations. This needs to be done in a way that does not break resources allocated from other quests.

Declaration
public void CullResourceTarget(QuestResource resource, Symbol newPlace)
Parameters
Type Name Description
QuestResource resource

The resource to cull. No action taken if resource null or not found.

Symbol newPlace
| Improve this Doc View Source

FindQuestMachine(out QuestMachine)

Declaration
public static bool FindQuestMachine(out QuestMachine questMachineOut)
Parameters
Type Name Description
QuestMachine questMachineOut
Returns
Type Description
Boolean
| Improve this Doc View Source

FindQuests(String, Boolean)

Finds quests based on quest name.

Declaration
public ulong[] FindQuests(string questName, bool activeOnly = false)
Parameters
Type Name Description
String questName

Quest name to search for.

Boolean activeOnly

Only find active quests.

Returns
Type Description
UInt64[]

ulong[] array of quest UIDs with matching quest name.

| Improve this Doc View Source

GetActionTemplate(String)

Find registered action template based on source line.

Declaration
public IQuestAction GetActionTemplate(string source)
Parameters
Type Name Description
String source

Action source line.

Returns
Type Description
IQuestAction

IQuestAction template.

| Improve this Doc View Source

GetAllActiveQuests()

Returns an array of all active (not completed, not tombstoned) quest UIDs.

Declaration
public ulong[] GetAllActiveQuests()
Returns
Type Description
UInt64[]

ulong[] array of quest UIDs.

| Improve this Doc View Source

GetAllActiveQuestSites()

Get all Place site details for all active quests.

Declaration
public SiteDetails[] GetAllActiveQuestSites()
Returns
Type Description
SiteDetails[]

SiteDetails[] array.

| Improve this Doc View Source

GetAllQuestLogMessages()

Returns a list of all active log messages from all active quests

Declaration
public List<Message> GetAllQuestLogMessages()
Returns
Type Description
List<Message>

List of log messages.

| Improve this Doc View Source

GetAllQuests()

Returns an array of all quest UIDs, even if completed or tombstoned.

Declaration
public ulong[] GetAllQuests()
Returns
Type Description
UInt64[]

ulong[] array of quest UIDs.

| Improve this Doc View Source

GetCurrentLocationQuestMarker(out QuestMarker, out Vector3)

Gets active marker in player's current location.

Declaration
public bool GetCurrentLocationQuestMarker(out QuestMarker markerOut, out Vector3 buildingOriginOut)
Parameters
Type Name Description
QuestMarker markerOut

Active QuestMarker out.

Vector3 buildingOriginOut

Building origin in scene, or Vector3.zero if not inside a building.

Returns
Type Description
Boolean

True if successful.

| Improve this Doc View Source

GetQuest(UInt64)

Gets an active or tombstoned quest based on UID.

Declaration
public Quest GetQuest(ulong questUID)
Parameters
Type Name Description
UInt64 questUID

Quest UID to retrieve.

Returns
Type Description
Quest

Quest object. Returns null if UID not found.

| Improve this Doc View Source

GetQuestSourceText(String)

Attempts to load quest source text from StreamingAssets/Quests.

Declaration
public string[] GetQuestSourceText(string questName)
Parameters
Type Name Description
String questName

Quest filename. Extension .txt is optional.

Returns
Type Description
String[]

Array of lines in quest text, or empty array.

| Improve this Doc View Source

GetSaveData()

Declaration
public QuestMachine.QuestMachineData_v1 GetSaveData()
Returns
Type Description
QuestMachine.QuestMachineData_v1
| Improve this Doc View Source

GetSiteLinks(SiteTypes, Int32, Int32, Int32)

Selects all actives site links matching parameters. Very little information is needed to determine if player is in Town, Dungeon, or Building. This information is intended to be easily reached by scene builders at layout time.

Declaration
public SiteLink[] GetSiteLinks(SiteTypes siteType, int mapId, int buildingKey = 0, int magicNumberIndex = 0)
Parameters
Type Name Description
SiteTypes siteType

Type of sites to select.

Int32 mapId

MapID in world.

Int32 buildingKey

Building key for buidings. Not used if left at default 0.

Int32 magicNumberIndex

Magic number index for fixed sites. Not used is left at default 0.

Returns
Type Description
SiteLink[]

SiteLink[] array of found links. Check for null or empty on return.

| Improve this Doc View Source

GetStoredExceptions()

Gets array of stored exceptions.

Declaration
public QuestMachine.StoredException[] GetStoredExceptions()
Returns
Type Description
QuestMachine.StoredException[]
| Improve this Doc View Source

GetTableSourceText(String)

Attempts to load table text from StreamingAssets/Tables. TODO: Tables are ultimately not exclusive to quests. Relocate this later.

Declaration
public string[] GetTableSourceText(string tableName)
Parameters
Type Name Description
String tableName

Table filename. Extension .txt is optional.

Returns
Type Description
String[]

Array of lines in table text, or empty array.

| Improve this Doc View Source

HasFactionListener(Int32)

Check if a faction listener is active for the individual faction ID.

Declaration
public bool HasFactionListener(int factionID)
Parameters
Type Name Description
Int32 factionID
Returns
Type Description
Boolean
| Improve this Doc View Source

HasSiteLink(Quest, Symbol)

Checks if a Place has a SiteLink available.

Declaration
public static bool HasSiteLink(Quest parentQuest, Symbol placeSymbol)
Parameters
Type Name Description
Quest parentQuest
Symbol placeSymbol
Returns
Type Description
Boolean
| Improve this Doc View Source

IsIndividualNPC(Int32)

Checks if NPC is a special individual NPC. These NPCs can exist in world even if not currently part of any active quests.

Declaration
public bool IsIndividualNPC(int factionID)
Parameters
Type Name Description
Int32 factionID

Faction ID of individual NPC.

Returns
Type Description
Boolean

True if this is an individual NPC.

| Improve this Doc View Source

IsIndividualQuestNPCAtSiteLink(Int32)

Walks SiteLink > Quest > Place > QuestMarkers > Target to see if an individual NPC has been placed elsewhere. Used only to determine if an individual NPC should be disabled at home location by layout builders. Ignores non-individual NPCs.

Declaration
public bool IsIndividualQuestNPCAtSiteLink(int factionID)
Parameters
Type Name Description
Int32 factionID

Faction ID of individual NPC.

Returns
Type Description
Boolean

True if individual has been placed elsewhere, otherwise false.

| Improve this Doc View Source

IsLastNPCClickedAnActiveQuestor(IMacroContextProvider)

Checks if last NPC clicked is questor for any quests. This is used for quest turn-in and reward process.

Declaration
public bool IsLastNPCClickedAnActiveQuestor(IMacroContextProvider mcp = null)
Parameters
Type Name Description
IMacroContextProvider mcp

External secondary context provider for quest macro expansion. (optional)

Returns
Type Description
Boolean

True if this NPC is a questor in any quest.

| Improve this Doc View Source

IsNPCDataEqual(StaticNPC.NPCData, StaticNPC.NPCData)

Checks if two sets of StaticNPC data reference the same NPC. Notes:

  • Still working through some issues here.
  • Possible for Questor NPC to be moved.
  • This will likely become more robust and conditional as quest system progresses.
Declaration
public bool IsNPCDataEqual(StaticNPC.NPCData person1, StaticNPC.NPCData person2)
Parameters
Type Name Description
StaticNPC.NPCData person1
StaticNPC.NPCData person2
Returns
Type Description
Boolean

True if person1 and person2 are considered the same.

| Improve this Doc View Source

IsProtectedQuest(Quest)

Checks if a quest is protected from ending prematurely.

Declaration
public static bool IsProtectedQuest(Quest quest)
Parameters
Type Name Description
Quest quest
Returns
Type Description
Boolean

True if quest is protected.

| Improve this Doc View Source

IsQuestComplete(UInt64)

Check if quest UID has been completed in quest machine.

Declaration
public bool IsQuestComplete(ulong questUID)
Parameters
Type Name Description
UInt64 questUID

Quest UID to check.

Returns
Type Description
Boolean

True if quest is complete. Also returns false if quest not found.

| Improve this Doc View Source

IsQuestTombstoned(UInt64)

Check if quest UID has been tombstoned in quest machine.

Declaration
public bool IsQuestTombstoned(ulong questUID)
Parameters
Type Name Description
UInt64 questUID

Quest UID to check.

Returns
Type Description
Boolean

True if quest is tombstoned. Also returns false if quest not found.

| Improve this Doc View Source

Log(Quest, String)

Declaration
public static void Log(Quest quest, string text)
Parameters
Type Name Description
Quest quest
String text
| Improve this Doc View Source

Log(String)

Declaration
public static void Log(string text)
Parameters
Type Name Description
String text
| Improve this Doc View Source

LogFormat(Quest, String, Object[])

Declaration
public static void LogFormat(Quest quest, string text, params object[] p)
Parameters
Type Name Description
Quest quest
String text
Object[] p
| Improve this Doc View Source

LogFormat(String, Object[])

Declaration
public static void LogFormat(string text, params object[] p)
Parameters
Type Name Description
String text
Object[] p
| Improve this Doc View Source

ParseQuest(String, String[], Int32, Boolean)

Instantiate a new quest from source text array.

Declaration
public Quest ParseQuest(string questName, string[] questSource, int factionId = 0, bool partialParse = false)
Parameters
Type Name Description
String questName

Name of quest filename. Extensions .txt is optional.

String[] questSource

Array of lines from quest source file.

Int32 factionId

Faction id of quest giver for guilds.

Boolean partialParse

If true the QRC and QBN sections will not be parsed.

Returns
Type Description
Quest

Quest.

| Improve this Doc View Source

PurgeAllQuests(Boolean)

Immediately tombstones then removes all quests.

Declaration
public int PurgeAllQuests(bool keepStoryQuests = false)
Parameters
Type Name Description
Boolean keepStoryQuests

Retain main story quests (start with S0000).

Returns
Type Description
Int32

Number of quests removed.

| Improve this Doc View Source

RaiseOnQuestEndedEvent(Quest)

Declaration
protected virtual void RaiseOnQuestEndedEvent(Quest quest)
Parameters
Type Name Description
Quest quest
| Improve this Doc View Source

RaiseOnQuestErrorTerminationEvent(Quest)

Declaration
protected virtual void RaiseOnQuestErrorTerminationEvent(Quest quest)
Parameters
Type Name Description
Quest quest
| Improve this Doc View Source

RaiseOnQuestStartedEvent(Quest)

Declaration
protected virtual void RaiseOnQuestStartedEvent(Quest quest)
Parameters
Type Name Description
Quest quest
| Improve this Doc View Source

RaiseOnRegisterCustomerActionsEvent()

Declaration
protected virtual void RaiseOnRegisterCustomerActionsEvent()
| Improve this Doc View Source

RaiseOnTickEvent()

Declaration
protected virtual void RaiseOnTickEvent()
| Improve this Doc View Source

RegisterAction(IQuestAction)

Register a new action in the quest engine.

Declaration
public void RegisterAction(IQuestAction actionTemplate)
Parameters
Type Name Description
IQuestAction actionTemplate

IQuestAction template.

| Improve this Doc View Source

RemoveAllQuestSiteLinks(UInt64)

Removes all site links for a quest. Typically done when quest has completed.

Declaration
public void RemoveAllQuestSiteLinks(ulong questUID)
Parameters
Type Name Description
UInt64 questUID

UID of quest to remove site links to.

| Improve this Doc View Source

RemoveFactionListener(Int32)

Remove a faction listener for the individual faction ID. Does nothing if faction ID not claimed.

Declaration
public void RemoveFactionListener(int factionID)
Parameters
Type Name Description
Int32 factionID
| Improve this Doc View Source

RemoveQuest(Quest)

Removes a quest completely from quest machine. Tombstones quest before removal.

Declaration
public bool RemoveQuest(Quest quest)
Parameters
Type Name Description
Quest quest
Returns
Type Description
Boolean

True if quest was removed.

| Improve this Doc View Source

RemoveQuest(UInt64)

Removes a quest completely from quest machine. Tombstones quest before removal.

Declaration
public bool RemoveQuest(ulong questUID)
Parameters
Type Name Description
UInt64 questUID

Quest UID.

Returns
Type Description
Boolean

True if quest was removed.

| Improve this Doc View Source

RestoreSaveData(QuestMachine.QuestMachineData_v1)

Declaration
public void RestoreSaveData(QuestMachine.QuestMachineData_v1 data)
Parameters
Type Name Description
QuestMachine.QuestMachineData_v1 data
| Improve this Doc View Source

ScheduleQuest(Quest)

Schedules quest to start on next tick.

Declaration
public void ScheduleQuest(Quest quest)
Parameters
Type Name Description
Quest quest

Quest.

| Improve this Doc View Source

SetLastNPCClicked(StaticNPC)

Sets the last StaticNPC clicked by player. Always called by PlayerActivate when player clicks on GameObject holding StaticNPC behaviour.

Declaration
public void SetLastNPCClicked(StaticNPC npc)
Parameters
Type Name Description
StaticNPC npc
| Improve this Doc View Source

SetStoredExceptions(QuestMachine.StoredException[])

Restores an array of stored exceptions.

Declaration
public void SetStoredExceptions(QuestMachine.StoredException[] exceptions)
Parameters
Type Name Description
QuestMachine.StoredException[] exceptions
| Improve this Doc View Source

SetupIndividualStaticNPC(GameObject, Int32)

Checks if NPC is a special individual NPC, then sets it up with components required for quests. If the NPC has an Individual faction, and the NPC is currently placed somewhere else in a quest, the GameObject will be deactivated

Declaration
public bool SetupIndividualStaticNPC(GameObject go, int factionID)
Parameters
Type Name Description
GameObject go

GameObject representing the static NPC

Int32 factionID

Faction ID of the NPC

Returns
Type Description
Boolean
| Improve this Doc View Source

StartQuest(Quest)

Start a parsed quest.

Declaration
public void StartQuest(Quest quest)
Parameters
Type Name Description
Quest quest

Quest.

| Improve this Doc View Source

StartQuest(String, Int32)

Parse and start a quest from quest name.

Declaration
public void StartQuest(string questName, int factionId = 0)
Parameters
Type Name Description
String questName

Quest name.

Int32 factionId

Faction id. (optional)

| Improve this Doc View Source

StoreQuestException(Quest, Exception)

Stores a quest exception in save file. Should only be used for major quest-ending errors to help diagnose difficult issues. Will only store a finite number of exceptions before overwriting oldest.

Declaration
public void StoreQuestException(Quest quest, Exception ex)
Parameters
Type Name Description
Quest quest

Quest throwing the exception.

Exception ex

Exception being thrown.

| Improve this Doc View Source

Tick()

Tick quest machine.

Declaration
public void Tick()
| Improve this Doc View Source

TombstoneQuest(Quest)

Tombstones a quest. It will remain in quest machine for "talk" links until removed. This calls Dispose() on quest, removes all related SiteLinks, then calls OnQuestEnded event.

Declaration
public void TombstoneQuest(Quest quest)
Parameters
Type Name Description
Quest quest

Quest to Tombstone.

| Improve this Doc View Source

UnmuteQuestNPCs()

Unmutes all quest NPCs. Supports console command workaround for "mute npc" bug present up to 0.7.36.

Declaration
public int UnmuteQuestNPCs()
Returns
Type Description
Int32

Events

| Improve this Doc View Source

OnQuestEnded

Declaration
public static event QuestMachine.OnQuestEndedEventHandler OnQuestEnded
Event Type
Type Description
QuestMachine.OnQuestEndedEventHandler
| Improve this Doc View Source

OnQuestErrorTermination

Declaration
public static event QuestMachine.OnQuestErrorTerminationEventHandler OnQuestErrorTermination
Event Type
Type Description
QuestMachine.OnQuestErrorTerminationEventHandler
| Improve this Doc View Source

OnQuestStarted

Declaration
public static event QuestMachine.OnQuestStartedEventHandler OnQuestStarted
Event Type
Type Description
QuestMachine.OnQuestStartedEventHandler
| Improve this Doc View Source

OnRegisterCustomActions

Declaration
public static event QuestMachine.OnRegisterCustomActionsEventHandler OnRegisterCustomActions
Event Type
Type Description
QuestMachine.OnRegisterCustomActionsEventHandler
| Improve this Doc View Source

OnTick

Declaration
public static event QuestMachine.OnTickEventHandler OnTick
Event Type
Type Description
QuestMachine.OnTickEventHandler

Extension Methods

MBExtensions.Invoke(MonoBehaviour, Action, Single)
MBExtensions.Invoke<T>(MonoBehaviour, Action<T>, T, Single)
MBExtensions.Invoke<T1, T2>(MonoBehaviour, Action<T1, T2>, T1, T2, Single)
MBExtensions.Invoke<T1, T2, T3>(MonoBehaviour, Action<T1, T2, T3>, T1, T2, T3, Single)
MBExtensions.Invoke<T1, T2, T3, T4>(MonoBehaviour, Action<T1, T2, T3, T4>, T1, T2, T3, T4, Single)
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX