XmlTools/Full documentation: Difference between revisions
Script 10k (talk | contribs) m (→Example) |
m (link fix) |
||
(23 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
This page lists all XmlTools commands with examples. It is the full version of the documentation of XmlTools options found on the [[XmlTools|main page]]. The main page also offers a beginner's guide to this program's syntax and links to pages that explain the concepts behind XML modding. | |||
{{TOClimit|3}} | |||
=Command-line operations= | ==Command-line operations== | ||
These are the commands that you can pass to XmlTools when directly calling it from the command line. | |||
== | ===--add-values=== | ||
====Description==== | |||
This operation allows you to add new XML values to an existing XML element that contains a list of values. The values should be space-separated and contained within quotes. | |||
Oni's game data contains various bitsets that are used to indicate the on/off status of attributes that can pertain to that object. For instance, characters in the game can have various flags such as Unkillable turned on for them. In OniSplit's XML output of this data, the flags are given names and listed within quotes as a single string. '''--add-values''' and '''--remove-values''' were designed to edit these XML representations of bitsets. | |||
Usage: | Usage: | ||
<tt>XmlTools --add-values --new-val "new values"</tt> | <tt>XmlTools --add-values --new-val "new values"</tt> | ||
===Example=== | ====Example==== | ||
Let's say you want to add the Unkillable and | Let's say you want to add the Unkillable and NonCombatant flags to character A_L18. | ||
Line 24: | Line 23: | ||
{| style="margin: 1em auto 1em auto;" <!-- Centers table --> | {| style="margin: 1em auto 1em auto;" <!-- Centers table --> | ||
! style="width: 50%;" | XML | ! style="width: 50%;" | XML Before | ||
! style="width: 50%;" | XML After | ! style="width: 50%;" | XML After | ||
|- | |- | ||
| | | | ||
Line 69: | Line 68: | ||
|} | |} | ||
==--remove-values== | ===--remove-values=== | ||
====Description==== | |||
===Description=== | This operation allows you to remove XML values from an existing XML element that contains a list of values. The values should be space-separated and contained within quotes. | ||
Oni's game data contains various bitsets that are used to indicate the on/off status of attributes that can pertain to that object. For instance, characters in the game can have various flags such as Unkillable turned on for them. In OniSplit's XML output of this data, the flags are given names and listed within quotes as a single string. '''--add-values''' and '''--remove-values''' were designed to edit these XML representations of bitsets. | |||
<tt>Usage: XmlTools --remove-values --current-val "current values to remove"</tt> | <tt>Usage: XmlTools --remove-values --current-val "current values to remove"</tt> | ||
===Example=== | ====Example==== | ||
Let's say you want to remove the UpgradeDifficulty and InfiniteAmmo flags from character D_S82. | |||
Let's say you want to remove the UpgradeDifficulty and InfiniteAmmo flags from D_S82 | |||
Line 86: | Line 84: | ||
{| style="margin: 1em auto 1em auto;" <!-- Centers table --> | {| style="margin: 1em auto 1em auto;" <!-- Centers table --> | ||
! style="width: 50%;" | XML | ! style="width: 50%;" | XML Before | ||
! style="width: 50%;" | XML After | ! style="width: 50%;" | XML After | ||
|- | |- | ||
| | | | ||
Line 131: | Line 129: | ||
|} | |} | ||
==--replace-value== | ===--replace-value=== | ||
====Description==== | |||
===Description=== | This operation allows you to execute a find/replace on existing XML elements, changing one specific value to another. | ||
This operation allows you to replace | |||
<tt>Usage: XmlTools --replace-value --current-val "currentValue" --new-val "newValue"</tt> | <tt>Usage: XmlTools --replace-value --current-val "currentValue" --new-val "newValue"</tt> | ||
===Example=== | ====Example==== | ||
Let's say you want to | Let's say you want to find all the w1_tap weapons currently assigned to characters and change them to w8_mbo. | ||
Line 147: | Line 143: | ||
{| style="margin: 1em auto 1em auto;" <!-- Centers table --> | {| style="margin: 1em auto 1em auto;" <!-- Centers table --> | ||
! style="width: 50%;" | XML | ! style="width: 50%;" | XML Before | ||
! style="width: 50%;" | XML After | ! style="width: 50%;" | XML After | ||
|- | |- | ||
| | | | ||
Line 192: | Line 188: | ||
|} | |} | ||
==--replace-all-values== | ===--replace-all-values=== | ||
====Description==== | |||
===Description=== | This operation allows you to replace the values on all matching XML elements regardless of their current value (unlike --replace-value). The new values should be space-separated and contained within quotes. | ||
This operation allows you to replace | |||
<tt>Usage: XmlTools --replace-all-values --new-val "new values"</tt> | <tt>Usage: XmlTools --replace-all-values --new-val "new values"</tt> | ||
===Example=== | ====Example==== | ||
Let's say you want to replace all the | Let's say you want to replace all existing character flags with the InfiniteAmmo and NotInitiallyPresent flags. | ||
Line 208: | Line 202: | ||
{| style="margin: 1em auto 1em auto;" <!-- Centers table --> | {| style="margin: 1em auto 1em auto;" <!-- Centers table --> | ||
! style="width: 50%;" | XML | ! style="width: 50%;" | XML Before | ||
! style="width: 50%;" | XML After | ! style="width: 50%;" | XML After | ||
|- | |- | ||
| | | | ||
Line 253: | Line 247: | ||
|} | |} | ||
==--update-elements== | ===--update-elements=== | ||
====Description==== | |||
===Description=== | This operation allows you to offset the values in a set of existing XML elements by specified amounts. The value differences must be space-separated and contained within quotes. | ||
This operation allows you to | |||
<tt>Usage: XmlTools --update-elements --diff-old-new-val "differences old-new values"</tt> | <tt>Usage: XmlTools --update-elements --diff-old-new-val "differences old-new values"</tt> | ||
===Examples=== | ====Examples==== | ||
=====Example 1===== | |||
Let's say you have a level built in a 3D modeling program and you have already set the positions in the BINACBJOCharacter file for all the characters that are to be spawned during the gameplay. However, for some reason you need to change the position of the level in the modeling program, which means that the character spawn locations are now incorrect. '''--update-elements''' provides the means for correcting them. | |||
Let's say that you know that the (x, y, z) difference between the old level's position and the new level's position is, in Oni's world units, {130, 80, 0}. Those offsets can be deducted from each spawn location. | |||
Let's say you | |||
'''XmlTools command:''' | '''XmlTools command:''' | ||
Line 273: | Line 263: | ||
{| style="margin: 1em auto 1em auto;" <!-- Centers table --> | {| style="margin: 1em auto 1em auto;" <!-- Centers table --> | ||
! style="width: 50%;" | XML | ! style="width: 50%;" | XML Before | ||
! style="width: 50%;" | XML After | ! style="width: 50%;" | XML After | ||
|- | |- | ||
| | | | ||
Line 341: | Line 331: | ||
====Example 2==== | =====Example 2===== | ||
Let's say you want to use the Tanker's forward throw attack with a new character. You know that your new character has a higher pelvis than the Tanker, which means that you need to alter the height values in every frame of the Tanker's TRAM data to match those of your new character. | |||
Let's say | Let's say that we know the difference between the pelvis height of the Tanker and your character is -0.7970685 (that is, the values that we are about to alter are this much less than what they should be). This number will be added to each value in the named XML elements. | ||
Line 352: | Line 341: | ||
{| style="margin: 1em auto 1em auto;" <!-- Centers table --> | {| style="margin: 1em auto 1em auto;" <!-- Centers table --> | ||
! style="width: 50%;" | XML | ! style="width: 50%;" | XML Before | ||
! style="width: 50%;" | XML After | ! style="width: 50%;" | XML After | ||
|- | |- | ||
| | | | ||
Line 393: | Line 382: | ||
|} | |} | ||
==--invert-elements== | ===--invert-elements=== | ||
====Description==== | |||
===Description=== | This operation allows you to invert a set of values in XML elements, for example, reversing the motion of an animation by flipping its frame values from 1, 2, 3 to 3, 2, 1. | ||
This operation allows you to invert a set of XML elements. | |||
<tt>Usage: XmlTools --invert-elements</tt> | <tt>Usage: XmlTools --invert-elements</tt> | ||
===Example=== | ====Example==== | ||
Let's say you want to invert the helicopter animation from Oni's final level. | Let's say you want to invert the helicopter animation from Oni's final level. You'll notice that the helicopter comes up from below to land on the satellite dish platform, and then it goes down again. If we invert the helicopter animation, it will come down from above, and then go back up again (which is exactly what was done in the Old China mod). | ||
For simplicity we will only edit one part of the helicopter animation: 'heli_interior09' and its Translation (position) element. Please note that to invert | For simplicity we will only edit one part of the helicopter animation: 'heli_interior09' and its Translation (position) element. Please note that to correctly invert the animation, you will need to invert the Rotation element too. | ||
'''XmlTools command:''' | '''XmlTools command:''' | ||
Line 410: | Line 397: | ||
{| style="margin: 1em auto 1em auto;" <!-- Centers table --> | {| style="margin: 1em auto 1em auto;" <!-- Centers table --> | ||
! style="width: 50%;" | XML | ! style="width: 50%;" | XML Before | ||
! style="width: 50%;" | XML After | ! style="width: 50%;" | XML After | ||
|- | |- | ||
| | | | ||
Line 471: | Line 458: | ||
|} | |} | ||
=Patch file operations | ==Patch file operations== | ||
XmlTools has a special set of commands that can be listed within a plain-text file to be executed all at once. These commands were designed for use with the AE Installer and revolve around making larger or more complex changes to the data that can only be easily conveyed to XmlTools in a text file. Since one of the following commands allows you to use any of the operations listed in the "Command-line operations" section, all the above functionality is accessible here too. See the [[XmlTools|main page]] for the syntax of supplying a patch file to XmlTools. | |||
===Description=== | ===@XML_TOOLS=== | ||
====Description==== | |||
This operation allows to specify options related | This operation allows you to specify options related to running XmlTools. Currently the only option available is "Version", which allows you to supply the minimum version of XmlTools that is required to apply the patch file. | ||
Usage: | Usage: | ||
<tt>@XML_TOOLS Version "XmlToolsVersion"</tt> | <tt>@XML_TOOLS Version "XmlToolsVersion"</tt> | ||
===Example=== | ====Example==== | ||
Let's say your patch is only compatible with XmlTools 2.0. | Let's say your patch is only compatible with XmlTools 2.0. | ||
Line 491: | Line 474: | ||
<pre>@XML_TOOLS Version "2.0"</pre> | <pre>@XML_TOOLS Version "2.0"</pre> | ||
Note that | Note that "2.0" means that it is also compatible with XmlTools 2.0a, 2.0b, etc. | ||
==@ADD_INSIDE_NODES== | ===@ADD_INSIDE_NODES=== | ||
====Description==== | |||
This operation allows you to insert a block of new XML into existing XML nodes. The XML to be inserted must be wrapped in <tt><xml></tt>...<tt></xml></tt> tags as seen below. | |||
Usage: | |||
<tt>@ADD_INSIDE_NODES</tt> | <tt>@ADD_INSIDE_NODES</tt> | ||
Line 508: | Line 490: | ||
<tt></xml></tt> | <tt></xml></tt> | ||
===Example=== | ====Example==== | ||
Let's say you want to add a new glass particle to the SWAT Griffin ONCC. | |||
Let's say | |||
'''XmlTools patch command:''' | '''XmlTools patch command:''' | ||
Line 523: | Line 504: | ||
{| style="margin: 1em auto 1em auto;" <!-- Centers table --> | {| style="margin: 1em auto 1em auto;" <!-- Centers table --> | ||
! style="width: 50%;" | XML | ! style="width: 50%;" | XML Before | ||
! style="width: 50%;" | XML After | ! style="width: 50%;" | XML After | ||
|- | |- | ||
| | | | ||
Line 563: | Line 544: | ||
|} | |} | ||
==@REMOVE_NODES== | ===@REMOVE_NODES=== | ||
====Description==== | |||
===Description=== | This operation allows you to remove existing XML nodes. | ||
This operation allows to remove existing XML nodes. | |||
Usage: | Usage: | ||
<tt>@REMOVE_NODES</tt> | <tt>@REMOVE_NODES</tt> | ||
===Example=== | ====Example==== | ||
Let's say you want to remove the glass particle from the SWAT Griffin ONCC. | |||
Let's say | |||
'''XmlTools patch command:''' | '''XmlTools patch command:''' | ||
@REMOVE_NODES XPathExpression "/Oni/ONCP/Particles/ONCPParticle[Name = 'glass_break' ]" Files "ONCCgriffin_swat.xml" | @REMOVE_NODES XPathExpression "/Oni/ONCP/Particles/ONCPParticle[@Name = 'glass_break']" Files "ONCCgriffin_swat.xml" | ||
{| style="margin: 1em auto 1em auto;" <!-- Centers table --> | {| style="margin: 1em auto 1em auto;" <!-- Centers table --> | ||
! style="width: 50%;" | XML | ! style="width: 50%;" | XML Before | ||
! style="width: 50%;" | XML After | ! style="width: 50%;" | XML After | ||
|- | |- | ||
| | | | ||
Line 620: | Line 598: | ||
|} | |} | ||
==@COMMAND== | ===@COMMAND=== | ||
====Description==== | |||
This operation allows you to use any of the [[XmlTools#Command-line_operations|command-line operations]] in a patch file. | |||
Usage: | |||
<tt>@COMMAND Options "Command line operation"</tt> | |||
Note: For command-line input operations which use quotes ("..."), replace the double quotes with single quotes (<nowiki>'...'</nowiki>). If any XPath expression also includes single quotes, you can double them (<nowiki>''...''</nowiki>) to allow XmlTools to process the command. | |||
== | ====Example==== | ||
Let's say you want to perform the same operation as in the [[#Example|--add-values example]]: adding the Unkillable and NonCombatant flags to character A_L18. | |||
===Description=== | '''XmlTools patch command:''' | ||
@COMMAND Options "--add-values --new-val 'Unkillable NonCombatant' --xpath-expression '/Oni/Objects/CHAR[@Id=<nowiki>''3926''</nowiki>]/OSD/Flags' --files 'BINACJBOCharacter.xml'" | |||
Note that in the XPath expression we replace each single quote by two single quotes, allowing XmlTools to differentiate from the single quotes used around command line options). | |||
The resulting XML file is exactly the same as in the [[#Example|--add-values example]]. | |||
===@CUSTOM_CODE=== | |||
====Description==== | |||
This operation allows you to use [[wikipedia:JavaScript|JavaScript]] to edit XML. You can use this for complex logic and mathematical tasks which aren't supported by XmlTools' basic operations. <u>You should only use this option as a '''last resort'''</u> if you are using it for a [[Making a patch mod|patch mod]], because it is '''MUCH slower''' than all the other native options. Try to <u>optimize your code as much as possible</u>, as the complexity of the code has a large effect on the overall speed of XmlTools in running JavaScript. | |||
Usage: | |||
<tt>@CUSTOM_CODE</tt> | |||
<tt><nowiki><code></nowiki></tt> | |||
<tt>JavaScript for XML editing</tt> | |||
<tt><nowiki></code></nowiki></tt> | |||
You can exit prematurely from the JavaScript code using the <tt>return</tt> keyword. It is also possible to output JavaScript variables to the console using the "echo" function: <tt>echo(var);</tt>. This function allows you to debug the code that you develop. | |||
The <tt>$xmlData</tt> global variable contains the contents of the XML file on disk. After you modify the XML, update this variable again with the new XML in order for XmlTools to update the file on disk, otherwise your changes will not take effect. | |||
XmlTools uses the JSXML XML Tools (<nowiki>http://www.petetracey.com/jsxml/index.html</nowiki>, dead link) JavaScript libraries to allow you to operate upon the XML. You can read its documentation on its website (<nowiki>http://www.petetracey.com/jsxml/documentation.html</nowiki>, dead link) or [http://script10k.oni2.net/documentation/xmltools/jsxml-documentation.htm here]. | |||
====Example==== | |||
Let's say you want to double the ammo clips and energy cells to all characters that are on the TCTF team. | |||
'''XmlTools patch command:''' | |||
@CUSTOM_CODE Files "BINACJBOCharacter.xml" | |||
<nowiki><code></nowiki> | |||
var myBuilder = new JSXMLBuilder(); | |||
myBuilder.load($xmlData); <span style="color:green">// Load the XML of the file for editing using the global variable</span> | |||
var elements = myBuilder.elements[0]; | |||
var charactersNode = elements.childElement("Objects"); | |||
var currAmmoElement, currCellsElement; | |||
<span style="color:green">// Loop over all characters</span> | |||
for (var i=0; (charactersNode.childElement(i)); i++){ <span style="color:green">// The condition checks if the 'i'th element exists (!= undefined)</span> | |||
var currChar=charactersNode.childElement(i); | |||
<span style="color:green">// Check if team is TCTF</span> | |||
if(currChar.childElement("OSD").childElement("Team").text=="TCTF"){ | |||
<span style="color:green">// Get ammo and cell 'Use' XML elements</span> | |||
currAmmoElement=currChar.childElement("OSD").childElement("Inventory").childElement("Ammo").childElement("Use"); | |||
currCellsElement=currChar.childElement("OSD").childElement("Inventory").childElement("EnergyCell").childElement("Use"); | |||
<span style="color:green">// Double the current amount of ammo and cells that the character can use</span> | |||
currAmmoElement.text=parseInt(currAmmoElement.text)*2; | |||
currCellsElement.text=parseInt(currCellsElement.text)*2; | |||
} | |||
} | |||
$xmlData=myBuilder.generateXML(); <span style="color:green">// Update the global variable with the new XML to save changes</span> | |||
<nowiki></code></nowiki> | |||
{| style="margin: 1em auto 1em auto;" <!-- Centers table --> | |||
! style="width: 50%;" | XML Before | |||
! style="width: 50%;" | XML After | |||
|- | |||
| | |||
<Oni> | |||
<Objects> | |||
... | |||
<CHAR Id="3926"> | |||
... | |||
<OSD> | |||
... | |||
<Name>A_L18</Name> | |||
<Weapon>w8_mbo</Weapon> | |||
<Inventory> | |||
<Ammo> | |||
<Use><span style="color:blue">'''2'''</span></Use> | |||
... | |||
</Ammo> | |||
<EnergyCell> | |||
<Use><span style="color:blue">'''0'''</span></Use> | |||
... | |||
</EnergyCell> | |||
</Inventory> | |||
<Team>TCTF</Team> | |||
... | |||
</OSD> | |||
</CHAR> | |||
<CHAR Id="7684"> | |||
... | |||
<OSD> | |||
... | |||
<Name>D_Sbo93</Name> | |||
<Weapon>w1_tap</Weapon> | |||
<Inventory> | |||
<Ammo> | |||
<Use><span style="color:blue">'''3'''</span></Use> | |||
... | |||
</Ammo> | |||
<EnergyCell> | |||
<Use><span style="color:blue">'''1'''</span></Use> | |||
... | |||
</EnergyCell> | |||
</Inventory> | |||
<Team>TCTF</Team> | |||
... | |||
</OSD> | |||
</CHAR> | |||
<CHAR Id="7606"> | |||
... | |||
<OSD> | |||
... | |||
<Name>D_N76</Name> | |||
<Weapon /> | |||
<Inventory> | |||
<Ammo> | |||
<Use>'''0'''</Use> | |||
... | |||
</Ammo> | |||
<EnergyCell> | |||
<Use>'''2'''</Use> | |||
... | |||
</EnergyCell> | |||
</Inventory> | |||
<Team>Neutral</Team> | |||
... | |||
</OSD> | |||
</CHAR> | |||
... | |||
... | |||
</Objects> | |||
</Oni> | |||
| | |||
<Oni> | |||
<Objects> | |||
... | |||
<CHAR Id="3926"> | |||
... | |||
<OSD> | |||
... | |||
<Name>A_L18</Name> | |||
<Weapon>w8_mbo</Weapon> | |||
<Inventory> | |||
<Ammo> | |||
<Use><span style="color:red">'''4'''</span></Use> | |||
... | |||
</Ammo> | |||
<EnergyCell> | |||
<Use><span style="color:red">'''0'''</span></Use> | |||
... | |||
</EnergyCell> | |||
</Inventory> | |||
<Team>TCTF</Team> | |||
... | |||
</OSD> | |||
</CHAR> | |||
<CHAR Id="7684"> | |||
... | |||
<OSD> | |||
... | |||
<Name>D_Sbo93</Name> | |||
<Weapon>w1_tap</Weapon> | |||
<Inventory> | |||
<Ammo> | |||
<Use><span style="color:red">'''6'''</span></Use> | |||
... | |||
</Ammo> | |||
<EnergyCell> | |||
<Use><span style="color:red">'''2'''</span></Use> | |||
... | |||
</EnergyCell> | |||
</Inventory> | |||
<Team>TCTF</Team> | |||
... | |||
</OSD> | |||
</CHAR> | |||
<CHAR Id="7606"> | |||
... | |||
<OSD> | |||
... | |||
<Name>D_N76</Name> | |||
<Weapon /> | |||
<Inventory> | |||
<Ammo> | |||
<Use>'''0'''</Use> | |||
... | |||
</Ammo> | |||
<EnergyCell> | |||
<Use>'''2'''</Use> | |||
... | |||
</EnergyCell> | |||
</Inventory> | |||
<Team>Neutral</Team> | |||
... | |||
</OSD> | |||
</CHAR> | |||
... | |||
... | |||
</Objects> | |||
</Oni> | |||
|} | |||
[[Category:Bi-platform modding tools]][[Category:Completed modding tools]][[Category:Modding tutorials]] |
Latest revision as of 12:20, 5 April 2021
This page lists all XmlTools commands with examples. It is the full version of the documentation of XmlTools options found on the main page. The main page also offers a beginner's guide to this program's syntax and links to pages that explain the concepts behind XML modding.
Command-line operations
These are the commands that you can pass to XmlTools when directly calling it from the command line.
--add-values
Description
This operation allows you to add new XML values to an existing XML element that contains a list of values. The values should be space-separated and contained within quotes.
Oni's game data contains various bitsets that are used to indicate the on/off status of attributes that can pertain to that object. For instance, characters in the game can have various flags such as Unkillable turned on for them. In OniSplit's XML output of this data, the flags are given names and listed within quotes as a single string. --add-values and --remove-values were designed to edit these XML representations of bitsets.
Usage: XmlTools --add-values --new-val "new values"
Example
Let's say you want to add the Unkillable and NonCombatant flags to character A_L18.
XmlTools command:
XmlTools --add-values --new-val "Unkillable NonCombatant" --xpath-expression "/Oni/Objects/CHAR[@Id='3926']/OSD/Flags" --files "BINACJBOCharacter.xml"
XML Before | XML After |
---|---|
<Oni>
<Objects>
<CHAR Id="3926">
<Header>
<Flags />
<Position>-37.3426628 756 -491.6369</Position>
<Rotation>0 221.15564 0</Rotation>
</Header>
<OSD>
<Flags>NotInitiallyPresent</Flags>
<Class>TCTF_lite_1</Class>
<Name>A_L18</Name>
<Weapon>w8_mbo</Weapon>
...
</OSD>
</CHAR>
...
</Objects>
</Oni>
|
<Oni>
<Objects>
<CHAR Id="3926">
<Header>
<Flags />
<Position>-37.3426628 756 -491.6369</Position>
<Rotation>0 221.15564 0</Rotation>
</Header>
<OSD>
<Flags>NotInitiallyPresent Unkillable NonCombatant</Flags>
<Class>TCTF_lite_1</Class>
<Name>A_L18</Name>
<Weapon>w8_mbo</Weapon>
...
</OSD>
</CHAR>
...
</Objects>
</Oni>
|
--remove-values
Description
This operation allows you to remove XML values from an existing XML element that contains a list of values. The values should be space-separated and contained within quotes.
Oni's game data contains various bitsets that are used to indicate the on/off status of attributes that can pertain to that object. For instance, characters in the game can have various flags such as Unkillable turned on for them. In OniSplit's XML output of this data, the flags are given names and listed within quotes as a single string. --add-values and --remove-values were designed to edit these XML representations of bitsets.
Usage: XmlTools --remove-values --current-val "current values to remove"
Example
Let's say you want to remove the UpgradeDifficulty and InfiniteAmmo flags from character D_S82.
XmlTools command:
XmlTools --remove-values --current-val "UpgradeDifficulty InfiniteAmmo" --xpath-expression "/Oni/Objects/CHAR[@Id='7643']/OSD/Flags" --files "BINACJBOCharacter.xml"
XML Before | XML After |
---|---|
<Oni>
<Objects>
<CHAR Id="7643">
<Header>
<Flags />
<Position>173.626175 0 36.94594</Position>
<Rotation>0 134.847549 0</Rotation>
</Header>
<OSD>
<Flags>NotInitiallyPresent UpgradeDifficulty InfiniteAmmo</Flags>
<ClassTCTF_swat_1</Class>
<Name>D_S82</Name>
<Weapon>w3_phr</Weapon>
...
</OSD>
</CHAR>
...
</Objects>
</Oni>
|
<Oni>
<Objects>
<CHAR Id="7643">
<Header>
<Flags />
<Position>173.626175 0 36.94594</Position>
<Rotation>0 134.847549 0</Rotation>
</Header>
<OSD>
<Flags>NotInitiallyPresent</Flags>
<ClassTCTF_swat_1</Class>
<Name>D_S82</Name>
<Weapon>w3_phr</Weapon>
...
</OSD>
</CHAR>
...
</Objects>
</Oni>
|
--replace-value
Description
This operation allows you to execute a find/replace on existing XML elements, changing one specific value to another.
Usage: XmlTools --replace-value --current-val "currentValue" --new-val "newValue"
Example
Let's say you want to find all the w1_tap weapons currently assigned to characters and change them to w8_mbo.
XmlTools command:
XmlTools --replace-value --current-val "w1_tap" --new-val "w8_mbo" --element-name "Weapon" --parent-element-name "OSD" --files "BINACJBOCharacter.xml"
XML Before | XML After |
---|---|
<Oni>
<Objects>
<CHAR Id="7209">
<Header>
<Flags />
<Position>434.9334 756 -231.2183</Position>
<Rotation>0 258.058838 0</Rotation>
</Header>
<OSD>
<Flags>NotInitiallyPresent</Flags>
<Class>TCTF_lite_1</Class>
<Name>l7</Name>
<Weapon>w1_tap</Weapon>
...
</OSD>
</CHAR>
...
</Objects>
</Oni>
|
<Oni>
<Objects>
<CHAR Id="7209">
<Header>
<Flags />
<Position>434.9334 756 -231.2183</Position>
<Rotation>0 258.058838 0</Rotation>
</Header>
<OSD>
<Flags>NotInitiallyPresent</Flags>
<Class>TCTF_lite_1</Class>
<Name>l7</Name>
<Weapon>w8_mbo</Weapon>
...
</OSD>
</CHAR>
...
</Objects>
</Oni>
|
--replace-all-values
Description
This operation allows you to replace the values on all matching XML elements regardless of their current value (unlike --replace-value). The new values should be space-separated and contained within quotes.
Usage: XmlTools --replace-all-values --new-val "new values"
Example
Let's say you want to replace all existing character flags with the InfiniteAmmo and NotInitiallyPresent flags.
XmlTools command:
XmlTools --replace-all-values --new-val "NotInitiallyPresent InfiniteAmmo" --element-name "Flags" --parent-element-name "OSD" --files "BINACJBOCharacter.xml"
XML Before | XML After |
---|---|
<Oni>
<Objects>
<CHAR Id="7643">
<Header>
<Flags />
<Position>173.626175 0 36.94594</Position>
<Rotation>0 134.847549 0</Rotation>
</Header>
<OSD>
<Flags>NoAutoDrop UpgradeDifficulty CanSpawnMultiple</Flags>
<ClassTCTF_swat_1</Class>
<Name>D_S82</Name>
<Weapon>w3_phr</Weapon>
...
</OSD>
</CHAR>
...
</Objects>
</Oni>
|
<Oni>
<Objects>
<CHAR Id="7643">
<Header>
<Flags />
<Position>173.626175 0 36.94594</Position>
<Rotation>0 134.847549 0</Rotation>
</Header>
<OSD>
<Flags>NotInitiallyPresent InfiniteAmmo</Flags>
<ClassTCTF_swat_1</Class>
<Name>D_S82</Name>
<Weapon>w3_phr</Weapon>
...
</OSD>
</CHAR>
...
</Objects>
</Oni>
|
--update-elements
Description
This operation allows you to offset the values in a set of existing XML elements by specified amounts. The value differences must be space-separated and contained within quotes.
Usage: XmlTools --update-elements --diff-old-new-val "differences old-new values"
Examples
Example 1
Let's say you have a level built in a 3D modeling program and you have already set the positions in the BINACBJOCharacter file for all the characters that are to be spawned during the gameplay. However, for some reason you need to change the position of the level in the modeling program, which means that the character spawn locations are now incorrect. --update-elements provides the means for correcting them.
Let's say that you know that the (x, y, z) difference between the old level's position and the new level's position is, in Oni's world units, {130, 80, 0}. Those offsets can be deducted from each spawn location.
XmlTools command:
XmlTools --update-elements --diff-old-new-val "130 80 0" --element-name "Position" --parent-element-name "Header" --files "BINACJBOCharacter.xml"
XML Before | XML After |
---|---|
<Oni> <Objects> <CHAR Id="3873"> <Header> ... <Position>227.145248 756 -403.65567</Position> ... </Header> ... </CHAR> <CHAR Id="3922"> <Header> ... <Position>501.63855 756 223.189484</Position> ... </Header> ... </CHAR> <CHAR Id="3926"> <Header> ... <Position>-37.3426628 756 -491.6369</Position> ... </Header> ... </CHAR> ... ... </Objects> </Oni> |
<Oni> <Objects> <CHAR Id="3873"> <Header> ... <Position>97.145248 676 -403.65567</Position> ... </Header> ... </CHAR> <CHAR Id="3922"> <Header> ... <Position>371.63855 676 223.189484</Position> ... </Header> ... </CHAR> <CHAR Id="3926"> <Header> ... <Position>-167.342663 676 -491.6369</Position> ... </Header> ... </CHAR> ... ... </Objects> </Oni> |
Example 2
Let's say you want to use the Tanker's forward throw attack with a new character. You know that your new character has a higher pelvis than the Tanker, which means that you need to alter the height values in every frame of the Tanker's TRAM data to match those of your new character.
Let's say that we know the difference between the pelvis height of the Tanker and your character is -0.7970685 (that is, the values that we are about to alter are this much less than what they should be). This number will be added to each value in the named XML elements.
XmlTools command:
XmlTools --update-elements --diff-old-new-val "-0.7970685" --element-name "Height" --parent-element-name "Heights" --files "TRAMTANCOMthrow_fw.xml"
XML Before | XML After |
---|---|
<Oni> <Animation> ... <Heights> <Height>9.12794</Height> <Height>9.25521</Height> <Height>9.401095</Height> <Height>9.556288</Height> <Height>9.711483</Height> <Height>9.857368</Height> <Height>9.984637</Height> <Height>10.0839806</Height> ... <Heights> ... </Animation> </Oni> |
<Oni> <Animation> ... <Heights> <Height>9.9250085</Height> <Height>10.0522785</Height> <Height>10.1981635</Height> <Height>10.3533565</Height> <Height>10.5085515</Height> <Height>10.6544365</Height> <Height>10.7817055</Height> <Height>10.8810491</Height> ... <Heights> ... </Animation> </Oni> |
--invert-elements
Description
This operation allows you to invert a set of values in XML elements, for example, reversing the motion of an animation by flipping its frame values from 1, 2, 3 to 3, 2, 1.
Usage: XmlTools --invert-elements
Example
Let's say you want to invert the helicopter animation from Oni's final level. You'll notice that the helicopter comes up from below to land on the satellite dish platform, and then it goes down again. If we invert the helicopter animation, it will come down from above, and then go back up again (which is exactly what was done in the Old China mod).
For simplicity we will only edit one part of the helicopter animation: 'heli_interior09' and its Translation (position) element. Please note that to correctly invert the animation, you will need to invert the Rotation element too.
XmlTools command:
XmlTools --invert-elements --element-name "Translation" --files "OBANheli_interior09.xml"
XML Before | XML After |
---|---|
<Oni> <OBAN id="0"> ... <OBANKeyFrame> ... <Translation>-184.349075 1312.973 -3162.01733</Translation> ... </OBANKeyFrame> <OBANKeyFrame> ... <Translation>-184.330032 1336.40686 -3162.01978</Translation> ... </OBANKeyFrame> ... <OBANKeyFrame> ... <Translation>-185.234482 1465.60852 -3060.43579</Translation> ... </OBANKeyFrame> <OBANKeyFrame> ... <Translation>-185.233032 1465.56641 -3060.47461</Translation> ... </OBANKeyFrame> ... </OBAN> </Oni> |
<Oni> <OBAN id="0"> ... <OBANKeyFrame> ... <Translation>-185.233032 1465.56641 -3060.47461</Translation> ... </OBANKeyFrame> <OBANKeyFrame> ... <Translation>-185.234482 1465.60852 -3060.43579</Translation> ... </OBANKeyFrame> ... <OBANKeyFrame> ... <Translation>-184.330032 1336.40686 -3162.01978</Translation> ... </OBANKeyFrame> <OBANKeyFrame> ... <Translation>-184.349075 1312.973 -3162.01733</Translation> ... </OBANKeyFrame> ... </OBAN> </Oni> |
Patch file operations
XmlTools has a special set of commands that can be listed within a plain-text file to be executed all at once. These commands were designed for use with the AE Installer and revolve around making larger or more complex changes to the data that can only be easily conveyed to XmlTools in a text file. Since one of the following commands allows you to use any of the operations listed in the "Command-line operations" section, all the above functionality is accessible here too. See the main page for the syntax of supplying a patch file to XmlTools.
@XML_TOOLS
Description
This operation allows you to specify options related to running XmlTools. Currently the only option available is "Version", which allows you to supply the minimum version of XmlTools that is required to apply the patch file.
Usage: @XML_TOOLS Version "XmlToolsVersion"
Example
Let's say your patch is only compatible with XmlTools 2.0.
XmlTools patch command:
@XML_TOOLS Version "2.0"
Note that "2.0" means that it is also compatible with XmlTools 2.0a, 2.0b, etc.
@ADD_INSIDE_NODES
Description
This operation allows you to insert a block of new XML into existing XML nodes. The XML to be inserted must be wrapped in <xml>...</xml> tags as seen below.
Usage:
@ADD_INSIDE_NODES
<xml>
XML to insert
</xml>
Example
Let's say you want to add a new glass particle to the SWAT Griffin ONCC.
XmlTools patch command:
@ADD_INSIDE_NODES ElementName "Particles" ParentElementName "ONCP" Files "ONCCgriffin_swat.xml" <xml> <ONCPParticle> <Name>glass_break</Name> <Type>glass_break</Type> <BodyPart>None</BodyPart> </ONCPParticle> </xml>
XML Before | XML After |
---|---|
<Oni> ... <ONCP id="3"> <Particles> ... <ONCPParticle> <Name>glow</Name> <Type>h2h_griglow_e01</Type> <BodyPart>None</BodyPart> </ONCPParticle> <Particles> ... </ONCP> </Oni> |
<Oni> ... <ONCP id="3"> <Particles> ... <ONCPParticle> <Name>glow</Name> <Type>h2h_griglow_e01</Type> <BodyPart>None</BodyPart> </ONCPParticle> <ONCPParticle> <Name>glass_break</Name> <Type>glass_break</Type> <BodyPart>None</BodyPart> </ONCPParticle> <Particles> ... </ONCP> </Oni> |
@REMOVE_NODES
Description
This operation allows you to remove existing XML nodes.
Usage: @REMOVE_NODES
Example
Let's say you want to remove the glass particle from the SWAT Griffin ONCC.
XmlTools patch command:
@REMOVE_NODES XPathExpression "/Oni/ONCP/Particles/ONCPParticle[@Name = 'glass_break']" Files "ONCCgriffin_swat.xml"
XML Before | XML After |
---|---|
<Oni> ... <ONCP id="3"> <Particles> ... <ONCPParticle> <Name>glow</Name> <Type>h2h_griglow_e01</Type> <BodyPart>None</BodyPart> </ONCPParticle> <ONCPParticle> <Name>glass_break</Name> <Type>glass_break</Type> <BodyPart>None</BodyPart> </ONCPParticle> <Particles> ... </ONCP> </Oni> |
<Oni> ... <ONCP id="3"> <Particles> ... <ONCPParticle> <Name>glow</Name> <Type>h2h_griglow_e01</Type> <BodyPart>None</BodyPart> </ONCPParticle> <Particles> ... </ONCP> </Oni> |
@COMMAND
Description
This operation allows you to use any of the command-line operations in a patch file.
Usage: @COMMAND Options "Command line operation"
Note: For command-line input operations which use quotes ("..."), replace the double quotes with single quotes ('...'). If any XPath expression also includes single quotes, you can double them (''...'') to allow XmlTools to process the command.
Example
Let's say you want to perform the same operation as in the --add-values example: adding the Unkillable and NonCombatant flags to character A_L18.
XmlTools patch command:
@COMMAND Options "--add-values --new-val 'Unkillable NonCombatant' --xpath-expression '/Oni/Objects/CHAR[@Id=''3926'']/OSD/Flags' --files 'BINACJBOCharacter.xml'"
Note that in the XPath expression we replace each single quote by two single quotes, allowing XmlTools to differentiate from the single quotes used around command line options).
The resulting XML file is exactly the same as in the --add-values example.
@CUSTOM_CODE
Description
This operation allows you to use JavaScript to edit XML. You can use this for complex logic and mathematical tasks which aren't supported by XmlTools' basic operations. You should only use this option as a last resort if you are using it for a patch mod, because it is MUCH slower than all the other native options. Try to optimize your code as much as possible, as the complexity of the code has a large effect on the overall speed of XmlTools in running JavaScript.
Usage:
@CUSTOM_CODE
<code>
JavaScript for XML editing
</code>
You can exit prematurely from the JavaScript code using the return keyword. It is also possible to output JavaScript variables to the console using the "echo" function: echo(var);. This function allows you to debug the code that you develop.
The $xmlData global variable contains the contents of the XML file on disk. After you modify the XML, update this variable again with the new XML in order for XmlTools to update the file on disk, otherwise your changes will not take effect.
XmlTools uses the JSXML XML Tools (http://www.petetracey.com/jsxml/index.html, dead link) JavaScript libraries to allow you to operate upon the XML. You can read its documentation on its website (http://www.petetracey.com/jsxml/documentation.html, dead link) or here.
Example
Let's say you want to double the ammo clips and energy cells to all characters that are on the TCTF team.
XmlTools patch command:
@CUSTOM_CODE Files "BINACJBOCharacter.xml" <code> var myBuilder = new JSXMLBuilder(); myBuilder.load($xmlData); // Load the XML of the file for editing using the global variable var elements = myBuilder.elements[0]; var charactersNode = elements.childElement("Objects"); var currAmmoElement, currCellsElement; // Loop over all characters for (var i=0; (charactersNode.childElement(i)); i++){ // The condition checks if the 'i'th element exists (!= undefined) var currChar=charactersNode.childElement(i); // Check if team is TCTF if(currChar.childElement("OSD").childElement("Team").text=="TCTF"){ // Get ammo and cell 'Use' XML elements currAmmoElement=currChar.childElement("OSD").childElement("Inventory").childElement("Ammo").childElement("Use"); currCellsElement=currChar.childElement("OSD").childElement("Inventory").childElement("EnergyCell").childElement("Use"); // Double the current amount of ammo and cells that the character can use currAmmoElement.text=parseInt(currAmmoElement.text)*2; currCellsElement.text=parseInt(currCellsElement.text)*2; } } $xmlData=myBuilder.generateXML(); // Update the global variable with the new XML to save changes </code>
XML Before | XML After |
---|---|
<Oni> <Objects> ... <CHAR Id="3926"> ... <OSD> ... <Name>A_L18</Name> <Weapon>w8_mbo</Weapon> <Inventory> <Ammo> <Use>2</Use> ... </Ammo> <EnergyCell> <Use>0</Use> ... </EnergyCell> </Inventory> <Team>TCTF</Team> ... </OSD> </CHAR> <CHAR Id="7684"> ... <OSD> ... <Name>D_Sbo93</Name> <Weapon>w1_tap</Weapon> <Inventory> <Ammo> <Use>3</Use> ... </Ammo> <EnergyCell> <Use>1</Use> ... </EnergyCell> </Inventory> <Team>TCTF</Team> ... </OSD> </CHAR> <CHAR Id="7606"> ... <OSD> ... <Name>D_N76</Name> <Weapon /> <Inventory> <Ammo> <Use>0</Use> ... </Ammo> <EnergyCell> <Use>2</Use> ... </EnergyCell> </Inventory> <Team>Neutral</Team> ... </OSD> </CHAR> ... ... </Objects> </Oni> |
<Oni> <Objects> ... <CHAR Id="3926"> ... <OSD> ... <Name>A_L18</Name> <Weapon>w8_mbo</Weapon> <Inventory> <Ammo> <Use>4</Use> ... </Ammo> <EnergyCell> <Use>0</Use> ... </EnergyCell> </Inventory> <Team>TCTF</Team> ... </OSD> </CHAR> <CHAR Id="7684"> ... <OSD> ... <Name>D_Sbo93</Name> <Weapon>w1_tap</Weapon> <Inventory> <Ammo> <Use>6</Use> ... </Ammo> <EnergyCell> <Use>2</Use> ... </EnergyCell> </Inventory> <Team>TCTF</Team> ... </OSD> </CHAR> <CHAR Id="7606"> ... <OSD> ... <Name>D_N76</Name> <Weapon /> <Inventory> <Ammo> <Use>0</Use> ... </Ammo> <EnergyCell> <Use>2</Use> ... </EnergyCell> </Inventory> <Team>Neutral</Team> ... </OSD> </CHAR> ... ... </Objects> </Oni> |