@XML_TOOLS Version "2.0" @CUSTOM_CODE var myBuilder = new JSXMLBuilder(); myBuilder.load($xmlData); var elements = myBuilder.elements[0]; var particles = elements.childElement("Animation").childElement("Particles"); var added_to_head = false, added_to_feet = false; // Check if glass_break is assigned to Head and one of the feet; // remove it from any other bones if present for (var i = 0; (particles.childElement(i)); i++) { var particle = particles.childElement(i); var bone = particle.childElement("Bone").text; var name = particle.childElement("Name").text; if (name == "glass_break") { if (bone == "Head") added_to_head = true; else if (bone == "RightFoot") added_to_feet = true; else myBuilder.removeElement(particle.index); } } // Exit if we are past Oni's limit on TRAM particles if (particles.length >= 16) return; // Add the glass_break particle to the desired bones if it's not there already var heights = elements.childElement("Animation").childElement("Heights"); var anim_length; for (anim_length = 0; (heights.childElement(anim_length)); anim_length++) {;} if (!added_to_head) myBuilder.addElementAt("Particle", "", "0\ " + (anim_length-1) + "\ Head\ glass_break", particles.index + 1, particles.level + 1); // Exit if we are past Oni's limit on TRAM particles if (particles.length >= 16) return; if (!added_to_feet) myBuilder.addElementAt("Particle", "", "0\ " + (anim_length-1) + "\ RightFoot\ glass_break", particles.index + 1, particles.level + 1); // Update the global variable with the new XML $xmlData = myBuilder.generateXML();