| 1 |
@XML_TOOLS Version "2.0" |
| 2 |
|
| 3 |
@CUSTOM_CODE |
| 4 |
<code> |
| 5 |
var myBuilder = new JSXMLBuilder(); |
| 6 |
myBuilder.load($xmlData); |
| 7 |
|
| 8 |
var elements = myBuilder.elements[0]; |
| 9 |
var particles = elements.childElement("Animation").childElement("Particles"); |
| 10 |
var added_to_head = false, added_to_feet = false; |
| 11 |
|
| 12 |
// Check if glass_break is assigned to Head and one of the feet; |
| 13 |
// remove it from any other bones if present |
| 14 |
for (var i = 0; (particles.childElement(i)); i++) |
| 15 |
{ |
| 16 |
var particle = particles.childElement(i); |
| 17 |
var bone = particle.childElement("Bone").text; |
| 18 |
var name = particle.childElement("Name").text; |
| 19 |
if (name == "glass_break") |
| 20 |
{ |
| 21 |
if (bone == "Head") |
| 22 |
added_to_head = true; |
| 23 |
else if (bone == "RightFoot") |
| 24 |
added_to_feet = true; |
| 25 |
else |
| 26 |
myBuilder.removeElement(particle.index); |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
// Exit if we are past Oni's limit on TRAM particles |
| 31 |
if (particles.length >= 16) |
| 32 |
return; |
| 33 |
|
| 34 |
// Add the glass_break particle to the desired bones if it's not there already |
| 35 |
var heights = elements.childElement("Animation").childElement("Heights"); |
| 36 |
var anim_length; |
| 37 |
for (anim_length = 0; (heights.childElement(anim_length)); anim_length++) {;} |
| 38 |
if (!added_to_head) |
| 39 |
myBuilder.addElementAt("Particle", |
| 40 |
"", |
| 41 |
"<Start>0</Start>\ |
| 42 |
<End>" + (anim_length-1) + "</End>\ |
| 43 |
<Bone>Head</Bone>\ |
| 44 |
<Name>glass_break</Name>", |
| 45 |
particles.index + 1, |
| 46 |
particles.level + 1); |
| 47 |
|
| 48 |
// Exit if we are past Oni's limit on TRAM particles |
| 49 |
if (particles.length >= 16) |
| 50 |
return; |
| 51 |
|
| 52 |
if (!added_to_feet) |
| 53 |
myBuilder.addElementAt("Particle", |
| 54 |
"", |
| 55 |
"<Start>0</Start>\ |
| 56 |
<End>" + (anim_length-1) + "</End>\ |
| 57 |
<Bone>RightFoot</Bone>\ |
| 58 |
<Name>glass_break</Name>", |
| 59 |
particles.index + 1, |
| 60 |
particles.level + 1); |
| 61 |
|
| 62 |
// Update the global variable with the new XML |
| 63 |
$xmlData = myBuilder.generateXML(); |
| 64 |
</code> |