String logfile []; //log fil array initial un edited String[] matchstart = { "ScriptLog: START MATCH" , "Log: appRequestExit(0)" , "Precaching:", "=" , "ScriptLog:" , "died" , "Log:"}; //important memorable parts of the log file String[] levelID = { "DM-vin.LevelInfo0", "DM-vin2.LevelInfo0" , "DM-jake.LevelInfo0" , "DM-jake2.LevelInfo0" }; // a list of the maps in the UT map list String[] firsttimepic = { "Log: Precaching: DM-vin.LevelInfo0" , "Log: Precaching: DM-vin2.LevelInfo0" , "Log: Precaching: DM-jake.LevelInfo0" , "Log: Precaching: DM-jake2.LevelInfo0" };//a list of none split strings so we know what image to push first String [] temploop; float thelist[]; //the proper float number array after formatting from the logfile float [] storeforline = new float [4]; // store line xny's int dome = 1; //picking parts of script to run int dome2 = 1; //ditto int dome3 =1; int i = 0; //counter int counter = 0; //counter int counter2 = 0; //ditto int drawcount =0; int lookforlevel =0; //counter int logstart =0; //will bw the first usefull x number in theory (providing theres no log file errors int arraylength =0; //length of the 1st array starting at matchstart int starthere =0; //N nd time round start int endhere =0; //N nd time round end int wipeit = 0; // next level was called on this line number! int colourpic =0; int coladdon =0; int propred =0; int propgreen =0; int propblue =0; int sflcount =0; //stor for line count int imagesavecount =0; int domenow =0; PImage pic; void setup (){ size(1000,1000); //size of image to be created (nicely divisible by the map size of 20,000 by 20,000) background(255,255,255); } ///////////////////////////////////////////////////////////////////////////////////////////////// void draw(){ if (dome == 1){ // for the reading of the file println ("here"); logfile = loadStrings("C:/Games/UT2004/System/UT2004.log"); dome=2; } ///////////////////////////////////////////////////////////////////////////////////////////////// if (domenow == 1){ println("I looped"); logfile = loadStrings("C:/Games/UT2004/System/UT2004.log"); arraylength = logfile.length; arraylength = arraylength-starthere; println (arraylength); arraycopy(logfile,starthere,temploop,0,arraylength); //fails at this loop println(temploop[0]); domenow=domenow+1; } ///////////////////////////////////////////////////////////////////////////////////////////////// while(dome2 == 1){ // only happens once to find the absolute beginning of the file, and the level played! if(logfile[i].equals(matchstart[0]) == true) { //find the array number of the matchstart print("we hit the start of the match at -> "); println(i+1);// +1 because you want the first x value not the words "start match" print("the first line is -> "); println (logfile[i+1]); logstart = i+1; dome2 = 2; arraylength = logfile.length-logstart;//this is the length of the proper array, it does however contain all of the potential end of the file! arraylength = arraylength-1; //because the last line of the logfile night be halfway through a line (and we dont want that) endhere = arraylength; i = logstart; //I = the beggining of the good stuff in the logfile print ("The length of the array is -> "); println (arraylength); //print("the colour of 0 is ->"); //println (pic.pixels[0]); }else{ if(logfile[i].equals(firsttimepic[0]) == true){ println ("map playing is DM-VIN"); pic = loadImage("vin.jpg"); loadPixels(); } if(logfile[i].equals(firsttimepic[1]) == true){ println ("map playing is DM-VIN2"); pic = loadImage("vin2.jpg"); loadPixels(); } if(logfile[i].equals(firsttimepic[2]) == true){ println ("map playing is DM-JAKE"); pic = loadImage("jake.jpg"); loadPixels(); } if(logfile[i].equals(firsttimepic[3]) == true){ println ("map playing is DM-JAKE2"); pic = loadImage("jake2.jpg"); loadPixels(); } i = i+1; } } /////////////////////////////////////////////////////////////////////////////////////////////// if(dome2 == 2){ String[] justnumstrings = new String [arraylength]; while (counter2 < arraylength){ String temp [] = split (logfile[i]);//in a temporary array split the stringa of line (i) of the log file if ((temp[0].equals(matchstart[4]) == true) && (temp[2].equals(matchstart[3]) == true)) { // if the first part of the line is "scriptlog" and the third part is "=" then... (this is to ignore errors in the file) if (temp[1].equals(matchstart[5]) == true){// also if you second word is "died" justnumstrings[counter] = "0"; //needs to be in quotes because were still working with strings. counter = counter+1; //needs to be seperate counters because 1 goes continuously through the log and one takes selected lines, and 1 makes sure that the beginnin of the file is ignored counter2=counter2+1; i=i+1; }else{//if we didnt die and are a normal xyz then... justnumstrings[counter] = temp[3]; //put the number string in the number string array counter = counter+1; counter2=counter2+1; i=i+1; } }else{// if we have an error (as in not "scriptlog" or "=" counter2=counter2+1; i=i+1; if ((temp[1].equals(matchstart[2]) == true) && (temp[0].equals(matchstart[6]) == true)) { //if unreal is precaching a level! print("OMG new level at ->"); println (lookforlevel); //should draw what its got up to here then search for matchstart from here //need to load relevant picture! wipeit = lookforlevel;// a marker of the line of the array in which the level changes it is the first x in the new level } } lookforlevel =lookforlevel+1; } String format = join(justnumstrings, " ");//wake a big long string out of justnumstrings eg. "123123 123213 12123 12323" thelist = float(split(format));//turn these strings into floats and put the in the array thelist dome2 = 3;// so this bit aint repeated (till I says so) // println(thelist[33]); } /////////////////////////////////////////////////////////////////////////////////////////////// position of next drawing if (thelist[drawcount] == 0){ // wjen death make colour black th bots in morning "i see te light" drawcount = drawcount+1; coladdon = 255; }else{ float temp1 = thelist[drawcount]; float temp2 = thelist[drawcount+1]; float temp3 = thelist[drawcount+2]; temp1 = temp1+10000; //the map in ut is centred and is 20000 width, to get rid of - numbers add 10000 temp2 = temp2+10000; temp3 = temp3+10000; temp1 = temp1/20; //scale of our live version is 20 times smaller than actual map temp2 = temp2/20; temp3 = temp3/20; //println(temp1); // println(temp2); //println(temp3); temp3 = temp3*8; //visually a larger circle looks nicer. (this is the z value) // if (temp3>50){ // temp3=50; // } ///////////////////////////////////////////////////////////////////////////////////////////////// colour of next drawing int x = int(temp1); //turn the x and y temp values into ints so that we can find that colour. int y = int(temp2); //x=634, y=812 //the image is in a mega pixels array which is 1,000 by 1,000 so 1,000,000 bits long y = y-1; y=y*1000; colourpic = y+x; //this finds the right array value based ion the position of the xy value of bot color c = pic.pixels[colourpic]; float thered = red(c); //seperate their colours into the seperate rgb values float thegreen = green(c); float theblue = blue(c); propred = int(thered); propgreen = int(thegreen); propblue = int(theblue); //make the colours ints as ints are all colours can be! //propred=propred+coladdon; //the check for death, If one is found 255 wiull be added to propred //if (propred>255){ //where the death circles should be //propred = 0; //propgreen =0; //propblue=0; //coladdon =0; //} float redrand = random(20); // add a slight randomness to the colours int therandred = int(redrand); float greenrand = random(20); int therandgreen = int(greenrand); float bluerand = random(20); int therandblue = int(bluerand); propred = propred+therandred; propgreen = propgreen+therandgreen; propblue = propblue+therandblue; if (propgreen > 255){//stop colour values going above 255 propgreen = 255; } if (propblue > 255){ propblue = 255; } if (propred > 255){ propred = 255; } ///////////////////////////////////////////////////////////////////////////////////////////////// now draw something (still in the else!) if (sflcount<=3){ //the first time round on a map storeforline[sflcount]=temp1; storeforline[sflcount+1]=temp2; sflcount=sflcount+2; //store the first x and y values of the line }else{ //draw full line (the final xy of a line becomes the first xy of the next stroke(propred, propgreen, propblue, 50);//added an alpha to make the lines look better smooth(); line(storeforline[0],storeforline[1],storeforline[2],storeforline[3]); sflcount = 4;//dont do the top bit again storeforline[0]= storeforline[2]; storeforline[1]= storeforline[3]; storeforline[2]=temp1; storeforline[3]=temp2; } fill(propred, propgreen, propblue); noStroke(); smooth(); ellipse(temp1, temp2, temp3, temp3); fill(255,255,255); noStroke(); smooth(); ellipse(temp1,temp2,2,2); drawcount=drawcount+3; } ///////////////////////////////////////////////////////////////////////////////////////////////// if we get a change level command! //if theres less than 3 numbers left in the array then stopit! make draw count == array length remember number so we start here nexttime if (drawcount>=arraylength-3){ starthere = drawcount; print ("I finished drawing, need to read again starting at -> "); println (starthere+1); save("image0.tif"); drawcount = 0; dome=1; domenow = 1; //noLoop(); } if (wipeit > 0){ // if we got a new level command do this... if (drawcount == wipeit){ //if we hit the last z before new level (need a minus 1) //need to wipe screen and change picture //need to make the array run through any remaining xyz's... so cut the array off at new position and make it the beginning save("image0.tif"); print ("im cleared at -> "); println (drawcount); //int fixarraylevel = drawcount; print ("Ive got this many values left in my array -> "); println(arraylength-drawcount); float [] thelist2 = new float [arraylength-drawcount]; arraycopy(thelist,drawcount,thelist2,0,arraylength-drawcount);//copy thelist from drawcount to a new array println(thelist2[0]); starthere=arraylength; //dosnt matter if its not divisible by 3 because well add to it later drawcount=0; domenow =1; //noLoop(); } } //////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////// }