Changeset 965 for AE/packages/31000GlassBreakingMoves/patches/common/level0_Final/TRAMKONCOMrun_throw_fw.oni-patch
- Timestamp:
- Mar 2, 2014, 2:50:25 AM (11 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
AE/packages/31000GlassBreakingMoves/patches/common/level0_Final/TRAMKONCOMrun_throw_fw.oni-patch
r959 r965 1 1 @XML_TOOLS Version "2.0" 2 2 3 @CUSTOM_CODE 4 <code> 5 function contains(fullStringOrArray, subString){ 6 return fullStringOrArray.indexOf(subString)!=-1; 7 } 8 9 function removeFromArray(_array, _value){ 10 _array.splice(_array.indexOf(_value), 1); 11 } 12 13 var myBuilder = new JSXMLBuilder(); 14 myBuilder.load($xmlData); 15 16 var elements = myBuilder.elements[0]; 17 18 var particles = elements.childElement("Animation").childElement("Particles"); 19 20 21 if(!elements.childElement("Animation").childElement("Attacks")){ // if no attacks found ignore file 22 return; 23 } 24 25 var attackElement = elements.childElement("Animation").childElement("Attacks").childElement("Attack"); 26 27 var int_start,int_end,array_bones; 28 29 // gather all the necessary info 30 int_start=attackElement.childElement("Start").text; 31 int_end=attackElement.childElement("End").text; 32 array_bones=attackElement.childElement("Bones").text.split(" "); 33 34 // Check if any of the existing particles correspond to the same bone and glass_break 35 for (var i=0; (particles.childElement(i)); i++){ // the condition is to check if the child element exists (!= undefined) 36 var currElement=particles.childElement(i); 37 38 if(contains(array_bones,currElement.childElement("Bone").text) && currElement.childElement("Name").text=="glass_break"){ 39 removeFromArray(array_bones,currElement.childElement("Bone").text); // not necessary to add 40 } 41 } 42 43 // Insert the new glass particles 44 for (var i = 0; i < array_bones.length; i++) { 45 if(array_bones[i]=="RightFoot" || array_bones[i]=="LeftFoot" || array_bones[i]=="RightFist" || array_bones[i]=="LeftFist"){ 46 myBuilder.addElementAt("Particle","", 47 "<Start>"+int_start+"</Start>\ 48 <End>"+int_end+"</End>\ 49 <Bone>"+array_bones[i]+"</Bone>\ 50 <Name>glass_break</Name>",particles.index+1,particles.level+1); 51 } 52 } 53 54 $xmlData=myBuilder.generateXML(); // update the global variable with the new XML 55 </code> 3 @ADD_INSIDE_NODES ElementName "Particles" 4 <xml> 5 <Particle> 6 <Start>29</Start> 7 <End>39</End> 8 <Bone>LeftFoot</Bone> 9 <Name>glass_break</Name> 10 </Particle> 11 </xml>
Note:
See TracChangeset
for help on using the changeset viewer.