Modding:Conversations

From Caves of Qud Wiki
Revision as of 01:18, 1 June 2019 by Gnarf (talk | contribs) (methods for ConversationNode added)
Jump to navigation Jump to search


THIS DOCUMENTATION IS COMPLETELY IN PROGRESS AND GNARF IS COPY/PASTING OVER IT CONSTANTLY - PLEASE REFRAIN FROM WIKI EDITS UNTIL THIS NOTICE IS REMOVED THANKS!

Conversations are loaded as templates from Conversations.xml - The base conversations can not be extended or modified through the XML, however there are events that will allow dynamically editing conversations as they happen.

Conversation Object Parts

In order to be conversable, an object should use the CovnersationScript part and attach a ConversationID which references a conversation template from Conversations.xml.

Snippet of ObjectBlueprints.xml that links Mehmet's Conversation to "JoppaMehmet"

  <object Name="Mehmet" Inherits="NPC">
    <part Name="ConversationScript" ConversationID="JoppaMehmet" />
  </object>

Conversation Classes and XML properties

The xml file for conversation consists of a single <conversations> node with multiple <conversation> nodes underneath. It does not currently support extending the base game dialog via Load="Merge" or the other similar tricks used for many of the XMLs. Creating a Conversation.xml file for your mod would be done when you want to add a new specific conversation / template to be used in the game.

Nodes: <conversation> Deserialized: XRL.World.Conversation

property details Description
ID string / required / "key" The conversation ID used to reference this conversation template via a <part Name="ConversationScript" ConversationID="....">
C# Properties
StartNodes List<ConversationNode> C# only. Represents the children <node ID="Start"> (of which there can be multiple)
NodesByID Dictionary<string, ConversationNode> C# only. Represents the children <node> that are not "Start" - the "Start" node will be added here when conversation begins and it is chosen.

Conversation's have children <node> nodes:

Nodes: <node> - Deserialized: XRL.World.ConversationNode

property details Description
ID string / required / "key" The node ID used in other "GotoID" properties, etc. Can contain multiple "Start" nodes, one of which will be selected given the other boolean filter parameters.
TradeNote boolean TradeNote="show" in XML will set this to true, it tells the conversation engine to display the [Press T or Tab to trade] after the conversation text.
bCloseable boolean Defaults to true, but Closable="false" in XML will set this to false, telling the conversation to not allow "escape" to get out of it.
Visit node triggers
CompleteQuestStep string A comma separated list of QuestID~StepID that will Complete the given quest step when the node is entered (awarding XP, etc)
GiveItem string A comma separated list of BlueprintID that will give items to the player whenever this node is entered.
Filter / Test properties for Start nodes
IfWearingBlueprint string A single BlueprintID that the player must have equipped to see this start node.

XRLCore.Core.Game.Player.Body.HasObjectEquipped(IfWearingBlueprint)

IfHasBlueprint string A single BlueprintID that the player must in their Inventory to see this start node.

XRL.Core.XRLCore.Core.Game.Player.Body.GetPart<Parts.Inventory>().FireEvent(Event.New("HasBlueprint", "Blueprint", IfHasBlueprint))

IfLevelLessOrEqual string (of a number) A string representation of the level the character must be less than or equal to to see this node.

XRL.Core.XRLCore.Core.Game.Player.Body.Statistics["Level"].Value <= Convert.ToInt32(IfLevelLessOrEqual))

IfHaveQuest string A string Quest ID the player must have to get this start node.

XRL.Core.XRLCore.Core.Game.HasQuest(IfHaveQuest)

IfNotHaveQuest string A string Quest ID the player must *NOT* have to get this start node.

!XRL.Core.XRLCore.Core.Game.HasQuest(IfNotHaveQuest)

IfFinishedQuest string A string Quest ID the player must have completed get this start node.

XRL.Core.XRLCore.Core.Game.FinishedQuest(IfFinishedQuest)

IfNotFinishedQuest string A string Quest ID the player must *NOT* have completed get this start node.

!XRL.Core.XRLCore.Core.Game.FinishedQuest(IfNotFinishedQuest)

IfFinishedQuestStep string A string Quest Step ID the player must have completed get this start node.

XRL.Core.XRLCore.Core.Game.FinishedQuestStep(IfFinishedQuestStep)

IfNotFinishedQuestStep string A string Quest Step ID the player must *NOT* have completed get this start node.

!XRL.Core.XRLCore.Core.Game.FinishedQuestStep(IfNotFinishedQuestStep)

IfHaveObservation string A string Observation ID the player must have to get this start node.

Qud.API.JournalAPI.HasObservation(IfHaveObservation)

IfHaveState string A string state flag the game must have to get this start node.

XRL.Core.XRLCore.Core.Game.HasGameState(IfHaveState)

IfNotHaveState string A string state flag the game must *NOT* have to get this start node.

!XRL.Core.XRLCore.Core.Game.HasGameState(IfNotHaveState)

IfHaveItemWithID string (C# ONLY) A specific item ID that must be in the players inventory. This is a C# only property because Obejct ID doesn't exist until the object is created from the blueprint, making this option only useful on dynamic conversation nodes.
SpecialRequirement string Other special requirements.
  • LovedByConsortium : XRLCore.Core.Game.PlayerReputation.get("Consortium") < World.Reputation.lovedRep
  • IsMapNoteRevealed:MapNoteID : Qud.API.JournalAPI.IsMapOrVillageNoteRevealed( SpecialRequirement.Split(':')[1] )
  • !IsMapNoteRevealed:MapNoteID : NOT of the above
Choices List<ConversationChoice> (C# only) The `<choice>` nodes below this node from the XML.
C# Methods
Copy(ConversationNode source) void Copies all the properties and makes a copy of each Choice in the Choices list
Test() virtual bool Tests the various If* and other requirements properties to see if the node should be chosen for a start node.
Visit(GameObject speaker, GameObject player) virtual void Tells the node that it was visited, is used to handle GiveItem and CompleteQuestStep and tracking "Visited" status.
Unused/Unimplemented properties
Filter string / deprecated A potentailly unused property, it seems to have no code paths calling it
GiveOneItem string / deprecated A seemingly unused string (on node), no code paths in base CoQ reference it
StartQuest string / deprecated A seemingly unused string (on node), no code paths in base CoQ reference it
RevealMapNoteId string / deprecated A seemingly unused string (on node), no code paths in base CoQ reference it
TakeItem string / deprecated A seemingly unused string (on node), no code paths in base CoQ reference it
ClearOwner string / deprecated A seemingly unused string (on node), no code paths in base CoQ reference it


Snippet of Conversation.xml with Mehmet's script

<?xml version="1.0" encoding="utf-8"?>
<conversations>
  <conversation ID="JoppaMehmet">
    <node ID="Start" IfNotHaveQuest="What's Eating the Watervine?">
      <text>
Live and drink, =player.formalAddressTerm=. May you find shade in Joppa.</text>
      <choice GotoID="AboutJoppa1">What can you tell me about Joppa?</choice>
      <choice GotoID="LookingForWork1">I am in search of work.</choice>
      <choice GotoID="End">Live and drink.</choice>
    </node>
    <node ID="Start" IfHaveQuest="What's Eating the Watervine?" IfNotFinishedQuest="What's Eating the Watervine?">
      <text>
Live and drink, =player.formalAddressTerm=. Have you tidings from Red Rock?
      </text>
      <choice GotoID="FinishExploringRedrock1" IfHasBlueprint="Girshling Corpse">Yes. I found bits of gnawed watervine and slew a white spiderling. I carry its corpse with me.</choice>
      <choice GotoID="End">I'm working on it, =pronouns.personTerm=! Live and drink.</choice>
    </node>
    <node ID="Start" IfHaveQuest="What's Eating the Watervine?" IfFinishedQuest="What's Eating the Watervine?">
      <text>
Live and drink, =player.formalAddressTerm=. May you find shade in Joppa.</text>
      <choice GotoID="AboutJoppa2">What can you tell me about Joppa?</choice>
      <choice GotoID="End">Live and drink.</choice>
    </node>
    <node ID="FinishExploringRedrock1">
      <text>
What a hideous thing! I dread the horrors its presence portends. Bring the
corpse to Elder Irudad's hut for the Elder to examine.
      </text>
      <choice GotoID="End">As you say.</choice>
    </node>
    <node ID="LookingForWork1">
      <text>
Some critters are eating our watervine. Faarooq claims he saw one slinking around a vine patch. Ugly little thing, he says; pale white, eight legs, an ear-splitting whine.

I noticed a bit of red dirt in the watervine pool, the same we find in the soil at a nearby &amp;Ycave to the north&amp;y we call &amp;rRed Rock.&amp;y

Travel to &amp;rRed Rock&amp;y and kill as many of these critters as you can. Bring back the corpse of one, too. &amp;GElder Irudad&amp;y will reward your efforts.
</text>
      <choice GotoID="End" StartQuest="What's Eating the Watervine?">I will do as you ask.</choice>
      <choice GotoID="Start">I will perform no such peasant's task.</choice>
    </node>
    <node ID="AboutJoppa1">
      <text>
You would be wise to speak with &amp;GElder Irudad.&amp;y Look for his hut to the north.
    </text>
      <choice GotoID="LookingForWork1" IfNotFinishedQuest="What's Eating the Watervine?">I am in search of work.</choice>
      <choice GotoID="End">Live and drink.</choice>
    </node>
    <node ID="AboutJoppa2">
      <text>
You would be wise to speak with &amp;GElder Irudad.&amp;y Look for his hut to the north.
</text>
      <choice GotoID="End">Live and drink.</choice>
    </node>
  </conversation>
</conversations>