source: AE/packages/31000GlassBreakingMoves/patches/common/level0_Final/TRAM-getupfront-.oni-patch@ 963

Last change on this file since 963 was 950, checked in by s10k, 11 years ago

Package to Iritscen

File size: 1.9 KB
Line 
1@XML_TOOLS Version "2.0"
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>
Note: See TracBrowser for help on using the repository browser.