Skip to content

04. Basic template for reactions

sergiodinapoli edited this page Sep 11, 2021 · 1 revision

The following may be used as a basic template for reactions:

<InteractionDef ParentName="SpeakUpReply">
<defName>Weather</defName>
<label>react - weather</label>
<logRulesInitiator>
<rulesStrings>
<li>r_logentry->I just love sunny days!</li>
<li>r_logentry->Yes, it's perfect for a picnic!</li>
<li>r_logentry->Nice weather is a blessing for all of us!</li>
</rulesStrings>
</logRulesInitiator>
</InteractionDef>

Let's examine its main elements:
a) <InteractionDef ParentName="SpeakUpReply">
It's the outermost tag, enclosing our social interaction.

b) <defName>Weather</defName>
If the Patches.xml file (the one with the opening sentences) contains a line with a matching tag (i.e. r_logentry(tag=Weather)-> in this case), this social interaction will be called and used as a reaction to that opening line.

c) <label>react - weather</label>
This is used for debugging/internal management mainly. When you debug in-game, you will see "react - weather" in the possible interactions list.

d) <rulesStrings>
It encloses all the <li> elements, i.e. all the lines of dialogue.

e) <li>r_logentry->I just love sunny days!</li>
This is one of the lines of dialogue. Each line must:

  • start with <li> and end with </li>
  • have r_logentry-> just after <li>
    IMPORTANT: if you write r_logentry- and forget the >, the game will crash. Typos in general might be fatal so it's very important to make all the efforts to avoid them.

In this simple example, the reacting pawn will randomly use one of the three sentences listed here.

In our examples in the previous page, Patches.xml contains a line with the (tag=Weather) call. Since our reaction here contains <defName>Weather</defName>, it will be actually be chosen and launched as a reaction. So, we can expect this dialogue to occur:

Pawn1: What a nice sunny day!
Pawn2: Yes, it's perfect for a picnic!

Or also:
Pawn1: What a nice sunny day!
Pawn2: I just love sunny days!

Of course, if our Interactions.xml contained another InteractionDef with a <defName>FineFood</defName> element with all its food-related lines, the dialogue would have been about food and not about weather. This is because in the example in the previous page, Patches.xml contains this line:
<li>r_logentry(tag=FineFood)->I had a fine meal.</li>
where you can notice the (tag=FineFood) call.

You can insert as many <li> lines as you wish. For higher readibility, you might want to organize them with comments, such as <!-- = MyDialogue = -->.