Changes for page Mission Director Guide

Last modified by Klaus Meyer on 2025/03/31 16:39

From version 32954.1
edited by Daniel Turner
on 2023/08/22 19:00
Change comment: There is no comment for this version
To version 32955.1
edited by Daniel Turner
on 2023/08/22 19:04
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -1091,7 +1091,15 @@
1091 1091  
1092 1092  Cues can have **<patch>** elements with actions that will be performed when an old savegame is loaded. To control which savegames should be affected, you can add a //**version **//attribute to the <cue> node and a //**sinceversion**// attribute in the patch. When a cue is loaded from a savegame that has an older version than //sinceversion//, the <patch> actions will be performed immediately after loading.
1093 1093  
1094 -{{code language="xml"}}<cue [...] version="42"> <conditions> [...] </conditions> <actions> [...] </actions> <patch sinceversion="42"> [patch actions] </patch></cue>{{/code}}
1094 +{{code language="xml"}}
1095 + <cue [...] version="42">
1096 + <conditions> [...] </conditions>
1097 + <actions> [...] </actions>
1098 + <patch sinceversion="42">
1099 + [patch actions]
1100 + </patch>
1101 + </cue>
1102 +{{/code}}
1095 1095  
1096 1096  The patch actions are only performed if the cue is in a certain state, "complete" by default. Use the //**state**// attribute to change this requirement. For more information, see the XML schema documentation of the <patch> element.
1097 1097  
... ... @@ -1117,11 +1117,20 @@
1117 1117  
1118 1118  There are many conditions and conditional actions that require a value comparison, for example the condition <check_value>:
1119 1119  
1120 -{{code language="xml"}}<check_value value="$ware == ware.silicon and $amount != 0"/>{{/code}}
1128 +{{code language="xml"}}
1129 + <check_value value="$ware == ware.silicon and $amount != 0"/>
1130 +{{/code}}
1121 1121  
1122 1122  In the value attribute you specify a boolean expression, and if it is true (that is, not equal to zero), the condition is met. This is a special case: This condition and all other nodes that support a value comparison allows you to specify an upper limit, a lower limit, a number range, or a list of allowed values. Examples:
1123 1123  
1124 -{{code language="xml"}}<check_value value="FooCue.state" exact="cuestate.complete"/><check_value value="$foo.count" min="5"/><check_value value="$foo" max="player.age + 1min"/><check_value value="player.money" min="300Cr" max="600Cr"/><check_value value="$method" list="[killmethod.hitbymissile, killmethod.collected]"/><check_value value="$attention" min="attention.visible"/>{{/code}}
1134 +{{code language="xml"}}
1135 + <check_value value="FooCue.state" exact="cuestate.complete"/>
1136 + <check_value value="$foo.count" min="5"/>
1137 + <check_value value="$foo" max="player.age + 1min"/>
1138 + <check_value value="player.money" min="300Cr" max="600Cr"/>
1139 + <check_value value="$method" list="[killmethod.hitbymissile, killmethod.collected]"/>
1140 + <check_value value="$attention" min="attention.visible"/>
1141 +{{/code}}
1125 1125  
1126 1126  {{info}}Values of most enumeration types cannot be compared via ''min'' or ''max'' (also not via lt, gt, etc.). The only data types that can be used with ''min'' and ''max'' are numbers and the enumeration types ''level'' and ''attention'' (see Boolean operators). The ''exact'' attribute can be used with any type, and is equivalent to using the == operator."{{/info}}
1127 1127  
... ... @@ -1133,21 +1133,30 @@
1133 1133  
1134 1134  If an action requires a value, e.g. when you set a variable to a value, you can have some randomisation. To specify an exact value, e.g. in <set_value>, you can write this:
1135 1135  
1136 -{{code language="xml"}}<set_value name="$race" exact="race.teladi"/>{{/code}}
1153 +{{code language="xml"}}
1154 + <set_value name="$race" exact="race.teladi"/>
1155 +{{/code}}
1137 1137  
1138 1138  To select a random element from a list, this syntax can be used:
1139 1139  
1140 -{{code language="xml"}}<set_value name="$prime" list="[2, 3, 5, 7, 11]"/>{{/code}}
1159 +{{code language="xml"}}
1160 + <set_value name="$prime" list="[2, 3, 5, 7, 11]"/>
1161 +{{/code}}
1141 1141  
1142 1142  To get a random number within a given range, you can use min/max:
1143 1143  
1144 -{{code language="xml"}}<set_value name="$foo" min="-20" max="20"/><set_value name="$timeout" max="20s"/>{{/code}}
1165 +{{code language="xml"}}
1166 + <set_value name="$foo" min="-20" max="20"/>
1167 + <set_value name="$timeout" max="20s"/>
1168 +{{/code}}
1145 1145  
1146 1146  min and max have to be compatible number types. Enumeration types are not allowed, not even level and attention. The min attribute is optional and defaults to 0 (of the number type used in max).
1147 1147  
1148 1148  You can select one of 5 different probability distribution profiles for the random range, "flat" being the default (all values in the range are equally likely). If you select another profile, e.g. "increasing" to make higher numbers more likely, you also have to specify a scale value (integer) that is greater or equal to 2. Higher scale values result in higher peaks in the distribution profiles (probable values become even more probable).
1149 1149  
1150 -{{code language="xml"}}<set_value name="$foo" min="-20" max="20" profile="profile.increasing" scale="4"/>{{/code}}
1174 +{{code language="xml"}}
1175 + <set_value name="$foo" min="-20" max="20" profile="profile.increasing" scale="4"/>
1176 +{{/code}}
1151 1151  
1152 1152  \\(% id="variables-and-namespaces" %)
1153 1153  
... ... @@ -1162,27 +1162,39 @@
1162 1162  
1163 1163  You can create variables with certain actions and conditions, such as the <set_value> action:
1164 1164  
1165 -{{code language="xml"}}<set_value name="$foo" exact="$bar + 1" />{{/code}}
1191 +{{code language="xml"}}
1192 + <set_value name="$foo" exact="$bar + 1" />
1193 +{{/code}}
1166 1166  
1167 1167  <set_value> also exists as a "condition", which can be useful if you want to pass information about the conditions to the actions, that would otherwise be lost - like in a complex <check_any> event condition, where you want to create a variable only if you are in a certain check branch. (Other pseudo-conditions are <remove_value> and <debug_text>.)
1168 1168  
1169 1169  The default operation of <set_value> is "**set**", but there are more: "**add**", "**subtract**", and "**insert**". //add// and //subtract// change the value of an existing variable, which is created as 0 if it didn't exist before. If neither //min//, //max// nor //exact// attribute is provided, an exact value of 1 is assumed.
1170 1170  
1171 -{{code language="xml"}}<set_value name="$foo" operation="add" />{{/code}}
1199 +{{code language="xml"}}
1200 + <set_value name="$foo" operation="add" />
1201 +{{/code}}
1172 1172  
1173 1173  The trick is that <set_value> not only works on variables, but also on list elements and table keys:
1174 1174  
1175 -{{code language="xml"}}<set_value name="$list.{1}" exact="42" /><set_value name="$table.$foo" exact="42" />{{/code}}\\
1205 +{{code language="xml"}}
1206 + <set_value name="$list.{1}" exact="42" />
1207 + <set_value name="$table.$foo" exact="42" />
1208 +{{/code}}
1176 1176  
1177 1177  The operation //insert// is special, and it only works on lists. It inserts the value at the specified position (note that the position beyond the last element is also valid here):
1178 1178  
1179 -{{code language="xml"}}<set_value name="$list.{1}" exact="42" operation="insert" />{{/code}}
1212 +{{code language="xml"}}
1213 + <set_value name="$list.{1}" exact="42" operation="insert" />
1214 +{{/code}}
1180 1180  
1181 1181  This shifts the positions of all following elements up by one. If min/max/exact are missing, the default value is null for insertions, not 1 like in other cases.
1182 1182  
1183 1183  Appending is easier than that. The following actions are equivalent:
1184 1184  
1185 -{{code language="xml"}}<set_value name="$list.{$list.count + 1}" exact="42" operation="insert" /><append_to_list name="$list" exact="42" />{{/code}}
1220 +{{code language="xml"}}
1221 + <set_value name="$list.{$list.count + 1}" exact="42" operation="insert" />
1222 + <append_to_list name="$list" exact="42" />
1223 +{{/code}}
1186 1186  
1187 1187  Inserting at a position below 1 or above $list.count + 1 is not possible.
1188 1188  
... ... @@ -1225,14 +1225,15 @@
1225 1225  Consider this case:
1226 1226  
1227 1227  {{code language="xml"}}
1228 - <cue name="Root">
1229 - <actions>
1230 - <set_value name="$foo" />
1231 - </actions>
1232 - <cues>
1233 - <cue name="SubCue"> [...] </cue>
1266 +<cue name="Root">
1267 + <actions>
1268 + <set_value name="$foo" />
1269 + </actions>
1270 + <cues>
1271 + <cue name="SubCue"> [...]
1272 + </cue>
1234 1234   </cues>
1235 - </cue>
1274 +</cue>
1236 1236  {{/code}}
1237 1237  
1238 1238  When the root cue creates $foo, the variable is stored in the Root cue directly. But SubCue and its descendants will also need access to $foo. Of course they could write "parent.$foo" or "Root.$foo", but since it's very common to have a single location for most variables in the whole cue tree, the easy solution is to write just "$foo" - because variable names are looked up in the **namespace cue**, which is the root by default. Also newly created variables end up in the namespace, and not in "this" cue.
... ... @@ -1253,9 +1253,9 @@
1253 1253  {{warning}}Although in general the expression "$foo == namespace.$foo" is true, there is one exception: When library parameters are evaluated in the referencing cue, variables are resolved using the parent's namespace. However, the referencing cue creates a new namespace, so the namespace keyword already points to the library, not to the parent's namespace. Example:
1254 1254  
1255 1255  {{code language="xml"}}
1256 - <cue name="LibRef" ref="Lib">
1257 - <param name="Param1" value="$foo" /> <!-- $foo from parent namespace -->
1295 +<cue name="LibRef" ref="Lib">
1296 + <param name="Param1" value="$foo" /> <!-- $foo from parent namespace -->
1258 1258   <param name="Param2" value="namespace.$foo" /> <!-- LibRef.$foo (error) -->
1259 - </cue>
1298 +</cue>
1260 1260  {{/code }}
1261 1261  {{/warning}}