Changeset 965 for AE/packages/31000GlassBreakingMoves/patches/common/level0_Final/TRAM-blownup-.oni-patch
- Timestamp:
- Mar 2, 2014, 2:50:25 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/packages/31000GlassBreakingMoves/patches/common/level0_Final/TRAM-blownup-.oni-patch
r959 r965 3 3 @CUSTOM_CODE 4 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 5 var myBuilder = new JSXMLBuilder(); 14 6 myBuilder.load($xmlData); 15 7 16 8 var elements = myBuilder.elements[0]; 9 var particles = elements.childElement("Animation").childElement("Particles"); 10 var added_to_head = false, added_to_feet = false; 17 11 18 var particles = elements.childElement("Animation").childElement("Particles"); 19 20 // Check if any of the existing particles contains a head bone 21 for (var i=0; (particles.childElement(i)); i++){ // the condition is to check if the child element exists (!= undefined) 22 var currElement=particles.childElement(i); 23 24 if(currElement.childElement("Bone").text=="Head"){ 25 if(currElement.childElement("Name").text=="glass_break"){ 26 return; // not necessary to add 27 } 28 else{ 29 // gather all the necessary info 30 var int_start=currElement.childElement("Start").text; 31 var int_end=currElement.childElement("End").text; 32 33 // Insert the new glass particle (for when he touches glass with head 34 myBuilder.addElementAt("Particle","", 35 "<Start>"+int_start+"</Start>\ 36 <End>"+int_end+"</End>\ 37 <Bone>Head</Bone>\ 38 <Name>glass_break</Name>",particles.index+1,particles.level+1); 39 break; 40 } 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); 41 27 } 42 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); 43 61 44 $xmlData=myBuilder.generateXML(); // update the global variable with the new XML 62 // Update the global variable with the new XML 63 $xmlData = myBuilder.generateXML(); 45 64 </code>
Note:
See TracChangeset
for help on using the changeset viewer.