-
Notifications
You must be signed in to change notification settings - Fork 14
06. Wildcards
Let's consider:
<li>r_logentry(WEATHER==clear,INITIATOR_mood>=0.25,tag=WeatherGoodMood)->What a nice sunny day!</li>
We'd certainly like to give more variety and let the pawns speak several sentences in the same situation, to avoid frequent repetitions.
So, we could add this code:
<li>r_logentry(WEATHER==clear,INITIATOR_mood>=0.25,tag=WeatherGoodMood)->What a fine sunny weather!</li>
<li>r_logentry(WEATHER==clear,INITIATOR_mood>=0.25,tag=WeatherGoodMood)->What a pleasant sun we have today!</li>
It gets quite repetitive and typos can occur more easily.
Wildcards help reducing this problem with the following strategy:
<li>r_logentry(WEATHER==clear,INITIATOR_mood>=0.25,tag=WeatherGoodMood)->[weather_clear_good_mood]</li>
<li>weather_clear_good_mood->What a nice sunny day!</li>
<li>weather_clear_good_mood->What a fine sunny weather!</li>
<li>weather_clear_good_mood->What a pleasant sun we have today!</li>
Whatever is written between the [] brackets is called a wildcard and - when read by the code - it will expand in one of the name-matching options listed below.
This structure lets you avoid repetitions (and related typos) and have a clearer view of when the dialogue line is used.
If you plan to have more depth and detail, I believe the best practice is per-condition wildcards, organized into a commented structure.
Here's an example (you can add indentation yourself, for even higher readibility):
<!--=== CLEAR WEATHER ===-->
<li>r_logentry(WEATHER==clear,tag=WeatherClear)->[weather_clear]</li>
<li>weather_clear->We have a clear weather today.</li>
<!--=== CLEAR WEATHER === GOOD MOOD -->
<li>weather_clear(INITIATOR_mood>=0.25,tag=WeatherClear_GoodMood)->[weather_clear_good_mood]</li>
<li>weather_clear_good_mood->What a nice sunny day!</li>
<li>weather_clear_good_mood->What a fine sunny weather!</li>
<li>weather_clear_good_mood->What a pleasant sun we have today!</li>
So we create a separate "paragraph" for managing clear weather and then a "sub-paragraph" for managing the specific case of clear weather AND pawns having good mood.
This is a good practice only if you plan to write complex dialogues - otherwise it's much better to use a simpler line, without wildcards.
As you can see, wildcards can be recursively managed (i.e. you can have wildcards embedded in wildcards) and are hugely useful to organize your XML.
But they come with several rigid rules we must keep track of.