-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathout_custom.dat
456 lines (366 loc) · 15.1 KB
/
out_custom.dat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
<?xml version="1.0" encoding="UTF-8"?>
<!-- This file contains the definition of the custom XML output for the
game system. The statblock is defined as a dossier and then uses an assortment
of procedures to orchestrate the synthesis of the xml file.
CRITICAL NOTE! If your game system allows minions to be created (i.e.
heroes which are children of heroes), you MUST include custom output
that outputs images and minions. Without that, the images for minions
will not be generated properly for the public index.
(Images are generated automatically for top-level heroes in the public
index, just not for minions, so if your game doesn't use minions you
don't need to worry about this.)
-->
<document signature="Hero Lab Data">
<!-- Procedure xoname
Get the character's name, using a suitable default if unnamed. The name is
placed in the "name" text variable.
Outbound parameter: name
-->
<procedure id="xoname" scripttype="dossierxml"><![CDATA[
var name as string
if (empty(hero.actorname) = 0) then
name = hero.actorname
else
name = "Unnamed Character"
endif
]]></procedure>
<!-- Procedure xodescript
Add the specified text as a child description node, to avoid problems
with "mixed mode" (i.e. pcdata and elements under a node).
-->
<procedure id="xodescript" scripttype="dossierxml"><![CDATA[
var node as number
var xodescript as string
var child as number
child = xml[node].addchild["description"]
xml[child].text = xodescript
]]></procedure>
<!-- Procedure xotraits
Output all of the traits that satisfy the provided tag expression, reporting
the name and final value for each. The "tagexpr" text variable specifies the
constraints that must be satisfied for the list of traits. The "parentnode"
numeric variable is the node under which to add the attributes. The
"nodename" text variable is the name of the node to create.
Inbound parameter: tagexpr, nodename, parentnode
-->
<procedure id="xotraits" scripttype="dossierxml"><![CDATA[
var tagexpr as string
var nodename as string
var parentnode as number
var node as number
var xodescript as string
foreach pick in hero where tagexpr sortas explicit
node = xml[parentnode].addchild[nodename]
xml[node].attr["name"] = eachpick.field[name].text
xml[node].attr["value"] = eachpick.field[abiFinal].text
xodescript = eachpick.field[descript].text
call xodescript
if (eachpick.tagis[thing.user_added] = 0) then
xml[node].attr["useradded"] = "no"
endif
nexteach
]]></procedure>
<!-- Procedure xogrbasics
Output basic details for the gear that is the focus pick.
-->
<procedure id="xogrbasics" scripttype="dossierxml"><![CDATA[
var node as number
doneif (state.isfocus = 0)
var child as number
var xodescript as string
if (focus.tagis[thing.user_added] = 0) then
xml[node].attr["useradded"] = "no"
endif
if (focus.tagis[component.Gear] <> 0) then
child = xml[node].addchild["weight"]
xml[child].attr["text"] = focus.field[gearWeight].text
xml[child].attr["value"] = focus.field[gearWeight].value
child = xml[node].addchild["cost"]
xml[child].attr["text"] = focus.field[grCost].text
xml[child].attr["value"] = focus.field[grCost].value
endif
if (focus.stackable <> 0) then
xml[node].attr["quantity"] = focus.field[stackQty].text
endif
xodescript = focus.field[descript].text
call xodescript
]]></procedure>
<!-- Procedure xoweapons
Output all of the weapons possessed by the character, listing equipped
weapons first and including attack values, damage, and ranges for eachpick.
-->
<procedure id="xoweapons" scripttype="dossierxml"><![CDATA[
var parentnode as number
var node as number
parentnode = xmlroot.addchild["attacks"]
~output a list of all weapons (equipped first)
foreach pick in hero from WeaponBase sortas Armory
node = xml[parentnode].addchild["attack"]
xml[node].attr["name"] = eachpick.field[name].text
xml[node].attr["attack"] = eachpick.field[wpNetAtk].text
xml[node].attr["damage"] = eachpick.field[wpDamage].value
if (eachpick.field[grIsEquip].value <> 0) then
xml[node].attr["equipped"] = "yes"
endif
if (eachpick.tagis[component.WeapRange] <> 0) then
xml[node].attr["shortrange"] = eachpick.field[wpShort].text
xml[node].attr["mediumrange"] = eachpick.field[wpMedium].text
xml[node].attr["longrange"] = eachpick.field[wpLong].text
endif
~output basic gear details
perform eachpick.setfocus
call xogrbasics
nexteach
]]></procedure>
<!-- Procedure xoarmor
Output all of the armor possessed by the character, listing equipped gear
first and including the defense value for eachpick.
-->
<procedure id="xoarmor" scripttype="dossierxml"><![CDATA[
var parentnode as number
var node as number
parentnode = xmlroot.addchild["defenses"]
~output the details of all armor (equipped first)
foreach pick in hero from Defense sortas Armory
node = xml[parentnode].addchild["defense"]
xml[node].attr["name"] = eachpick.field[name].text
xml[node].attr["defense"] = eachpick.field[defResist].text
if (eachpick.field[grIsEquip].value <> 0) then
xml[node].attr["equipped"] = "yes"
endif
~output basic gear details
perform eachpick.setfocus
call xogrbasics
nexteach
]]></procedure>
<!-- Procedure xogear
Synthesize all of the gear possessed by the character, showing quantities
for appropriate gear.
-->
<procedure id="xogear" scripttype="dossierxml"><![CDATA[
var parentnode as number
var node as number
parentnode = xmlroot.addchild["gear"]
foreach pick in hero from Equipment where "!Print.NoPrint"
node = xml[parentnode].addchild["item"]
xml[node].attr["name"] = eachpick.field[name].text
~output basic gear details
perform eachpick.setfocus
call xogrbasics
nexteach
]]></procedure>
<!-- Procedure xotrackres
Output all of the tracked resources possessed by the character.
-->
<procedure id="xotrackres" scripttype="dossierxml"><![CDATA[
var parentnode as number
var node as number
parentnode = xmlroot.addchild["trackers"]
~output the details of all resources
foreach pick in hero from Tracker where "!Hide.Tracker"
node = xml[parentnode].addchild["tracker"]
xml[node].attr["name"] = eachpick.field[name].text
xml[node].attr["text"] = eachpick.field[trkUser].text
xml[node].attr["used"] = eachpick.field[trkUser].value
xml[node].attr["left"] = eachpick.field[trkLeft].value
xml[node].attr["min"] = eachpick.field[trkMin].value
xml[node].attr["max"] = eachpick.field[trkMax].value
nexteach
]]></procedure>
<!-- Procedure xonpcinfo
Checks all npc info picks with a certain tag expression and appends
their info to the text.
-->
<procedure id="xonpcinfo" scripttype="dossierxml"><![CDATA[
var parentnode as number
var tagexpr as string
var node as number
~go through the npc info picks, adding them to the info string
foreach pick in hero from NPCInfo where tagexpr sortas explicit
node = xml[parentnode].addchild["npcinfo"]
xml[node].attr["name"] = eachpick.field[name].text
xml[node].text = eachpick.field[npcInfo].text
nexteach
]]></procedure>
<!-- Procedure xoimages
Output all images, if required by the custom output type.
-->
<procedure id="xoimages" scripttype="dossierxml"><![CDATA[
~no need to do anything if this custom output doesn't want images
doneif (state.iscustimgs = 0)
var parentnode as number
var node as number
parentnode = xmlroot.addchild["images"]
foreach pick in hero from UserImage where "fieldval:uimgImage <> 0"
node = xml[parentnode].addchild["image"]
perform eachpick.field[uimgImage].xmlimgattr[node,"filename"]
nexteach
]]></procedure>
<!-- Define the statblock as a text-based dossier. The "heroxml" script actually
generates the output.
-->
<dossier
id="custom"
name="Custom Output">
<dossier_custom
default="yes">
<heroxml><![CDATA[
var txt as string
var tagexpr as string
var node as number
var parentnode as number
var nodename as string
var xodescript as string
~all heroes in the sample game system can be output using the same
~character sheet, so they all have the same nature
xmlroot.attr["nature"] = "normal"
~There's no distinction other than PC or NPC, since every character is
~built with the same rules
if (hero.tagis[CharType.typSupport] <> 0) then
xmlroot.attr["role"] = "npc"
else
xmlroot.attr["role"] = "pc"
endif
~for NPCs, add a "book" node if they have sourcebook information
if (hero.tagis[CharType.typSupport] <> 0) then
if (herofield[acBookId].isempty + herofield[acBookName].isempty < 2) then
node = xmlroot.addchild["bookinfo"]
endif
if (herofield[acBookId].isempty = 0) then
xml[node].attr["id"] = herofield[acBookId].text
endif
if (herofield[acBookName].isempty = 0) then
xml[node].attr["name"] = herofield[acBookName].text
endif
endif
~ally/enemy status
if (hero.tagis[tactical.ally] <> 0) then
xmlroot.attr["relationship"] = "ally"
else
xmlroot.attr["relationship"] = "enemy"
endif
~start by outputting our name
var name as string
call xoname
xmlroot.attr["name"] = name
~also player name
xmlroot.attr["playername"] = playername
~output any species
txt = hero.findchild[Species].field[name].text
node = xmlroot.addchild["species"]
xml[node].attr["name"] = txt
~output our total cash and XP
node = xmlroot.addchild["xp"]
xml[node].attr["total"] = #resmax[resXP]
node = xmlroot.addchild["cash"]
xml[node].attr["total"] = herofield[acCashNet].value
~output age, height and weight
parentnode = xmlroot.addchild["personal"]
xml[parentnode].attr["gender"] = child[mscPerson].field[perGender].text
xml[parentnode].attr["age"] = hero.child[mscPerson].field[perAge].text
xml[parentnode].attr["hair"] = hero.child[mscPerson].field[perHair].text
xml[parentnode].attr["eyes"] = hero.child[mscPerson].field[perEyes].text
xml[parentnode].attr["skin"] = hero.child[mscPerson].field[perSkin].text
node = parentnode
xodescript = hero.child[mscPerson].field[perInfo].text
call xodescript
~height and weight go in separate child elements
node = xml[parentnode].addchild["charheight"]
xml[node].attr["text"] = hero.child[mscPerson].field[perHeight].text
xml[node].attr["value"] = hero.child[mscPerson].field[perHeight].value
node = xml[parentnode].addchild["charweight"]
xml[node].attr["text"] = hero.child[mscPerson].field[perWeight].text
xml[node].attr["value"] = hero.child[mscPerson].field[perWeight].value
~output attributes
parentnode = xmlroot.addchild["attributes"]
nodename = "attrsys"
tagexpr = "component.AttrSys"
call xotraits
~output skills
parentnode = xmlroot.addchild["skills"]
nodename = "skill"
tagexpr = "component.Skill"
call xotraits
~output special talents
parentnode = xmlroot.addchild["talent"]
nodename = "talent"
tagexpr = "component.Talent"
call xotraits
~output derived traits
parentnode = xmlroot.addchild["traits"]
foreach pick in hero from Derived sortas explicit
node = xml[parentnode].addchild["trait"]
xml[node].attr["name"] = eachpick.field[name].text
xml[node].attr["value"] = eachpick.field[abiFinal].text
nexteach
~output weapons/attacks
call xoweapons
~output armor
call xoarmor
~output gear
call xogear
~output tracked resources
call xotrackres
~output journal entries
parentnode = xmlroot.addchild["journals"]
foreach pick in hero from Journal
node = xml[parentnode].addchild["journal"]
xml[node].attr["name"] = eachpick.field[jrnTitle].text
xml[node].attr["gamedate"] = eachpick.field[jrnGame].text
xml[node].attr["realdate"] = eachpick.field[jrnReal].text
xml[node].attr["xp"] = eachpick.usagepool[JrnlXP].value
xml[node].attr["cash"] = eachpick.usagepool[JrnlCash].value
xodescript = eachpick.field[jrnDescr].text
call xodescript
nexteach
~output user images
call xoimages
~output validation details
parentnode = xmlroot.addchild["validation"]
node = xml[parentnode].addchild["report"]
xml[node].text = hero.errorlist
if (hero.errorcount <> 0) then
foreach pick in hero.child[validgizmo].gizmo from validentry
node = xml[parentnode].addchild["validmessage"]
xml[node].text = eachpick.field[validentry].text
nexteach
endif
~output sources in use
node = xmlroot.addchild["settings"]
xml[node].attr["summary"] = hero.sourcetree
~output NPC details if this character is a NPC - if any field for any
~of the three blocks of text is set, output that block
if (hero.tagis[CharType.typSupport] <> 0) then
var tagexpr as string
var title as string
~add a node for NPC info
var npc as number
npc = xmlroot.addchild["npc"]
~values of up to 15 are basic details only
tagexpr = "val:explicit.? <= 15"
parentnode = xml[npc].addchild["basics"]
call xonpcinfo
~values of up to 30 are tactics
tagexpr = "val:explicit.? > 15 & val:explicit.? <= 30"
parentnode = xml[npc].addchild["tactics"]
call xonpcinfo
~values of up to 45 are ecology
tagexpr = "val:explicit.? > 30 & val:explicit.? <= 45"
parentnode = xml[npc].addchild["ecology"]
call xonpcinfo
~anything else is extra
tagexpr = "val:explicit.? > 45"
parentnode = xml[npc].addchild["additional"]
call xonpcinfo
endif
~output minions
parentnode = xmlroot.addchild["minions"]
foreach pick in hero where "system_tag.minion"
node = xml[parentnode].addchild["character"]
xml[node].attr["name"] = eachpick.field[name].text
perform eachpick.minion.toxml[node]
nexteach
]]></heroxml>
</dossier_custom>
</dossier>
</document>