@XML_TOOLS Version "2.0" @CUSTOM_CODE function contains(fullStringOrArray, subString){ return fullStringOrArray.indexOf(subString)!=-1; } function removeFromArray(_array, _value){ _array.splice(_array.indexOf(_value), 1); } var myBuilder = new JSXMLBuilder(); myBuilder.load($xmlData); var elements = myBuilder.elements[0]; var particles = elements.childElement("Animation").childElement("Particles"); if(!elements.childElement("Animation").childElement("Attacks")){ // if no attacks found ignore file return; } var attackElement = elements.childElement("Animation").childElement("Attacks").childElement("Attack"); var int_start,int_end,array_bones; // gather all the necessary info int_start=attackElement.childElement("Start").text; int_end=attackElement.childElement("End").text; array_bones=attackElement.childElement("Bones").text.split(" "); // Check if any of the existing particles correspond to the same bone and glass_break for (var i=0; (particles.childElement(i)); i++){ // the condition is to check if the child element exists (!= undefined) var currElement=particles.childElement(i); if(contains(array_bones,currElement.childElement("Bone").text) && currElement.childElement("Name").text=="glass_break"){ removeFromArray(array_bones,currElement.childElement("Bone").text); // not necessary to add } } // Insert the new glass particles for (var i = 0; i < array_bones.length; i++) { if( (contains(array_bones[i],"Foot")) && !contains(array_bones[i],"Calf") && !contains(array_bones[i],"Tight") || (contains(array_bones[i],"Fist")) && !contains(array_bones[i],"Wrist")){ myBuilder.addElementAt("Particle","", ""+int_start+"\ "+int_end+"\ "+array_bones[i]+"\ glass_break",particles.index+1,particles.level+1); } } $xmlData=myBuilder.generateXML(); // update the global variable with the new XML