View Single Post
Old 10.07.2005, 19:58   #7
torune
Архивный участник
 
Join Date: Jul 2005
Posts: 371
Default

my full source for generating heine npc pos
in java
Code:
import java.io.*;
import java.util.*;
import java.text.NumberFormat;
import java.text.DecimalFormat; 

public class Class1 extends Thread {
	public int DELAY = 25;
	
	public void run(){
			try { Thread.sleep(DELAY); }
				catch (InterruptedException e){
					System.out.println("ERROR: Thread Sleeping unfunctionable");
			}		

	}
    public Class1(int count,String name, int pos_x,int pos_y,int pos_z,int pos_w){
    				int a,b,c,d,e,f;
    				a = pos_x - 100;
    				b = pos_x + 100;
    				
    				c = pos_y - 100;
    				d = pos_y + 100;
    				
    				e = pos_z - 100;
    				f = pos_z + 100;
					String line = "territory_begin\t[Heine_NPC_"+count+"]\t{"
									+ "{" + a + ";" + c + ";" + e + ";" + f  + "};"	
									+ "{" + b + ";" + c + ";" + e + ";" + f  + "};"	
									+ "{" + b + ";" + d + ";" + e + ";" + f  + "};"	
									+ "{" + a + ";" + d + ";" + e + ";" + f  + "}"	
									+ "}\tterritory_end\n"
									+ "npcmaker_begin\t[Heine_NPC_" + +count+"]"
									+ " \tinitial_spawn = all\tmaximum_npc = 1\n"
									+ "npc_begin\t" + name + "\tpos = "
									+ "{" + pos_x + ";" + pos_y + ";" + pos_z + ";" + pos_w  + "}"
									+ "\ttotal = 1\trespawn = 1min\tnpc_end\n"
									+ "npcmaker_end\n";

					try{
					PrintWriter out = new PrintWriter(new FileWriter("npcpos.txt",true));
					out.println(line);
					out.close(); 
					} catch (FileNotFoundException ee) { 
					    System.out.println("Error: Cannot open file for writing."); 
					} catch (IOException ee) { 
					    System.out.println("Error: Cannot write to file."); 
					} 	
	}
	
    public static void main (String args []) {
			
	      String aFileName = "npc.txt";
		  
			try{	
		
			BufferedReader in = new BufferedReader(new FileReader(aFileName));
			String line = null;
			int i = 0;
			NumberFormat formatter = new DecimalFormat("1000000");	
			while ((line = in.readLine()) != null) {
				String name, a,b,c,d;
				i ++;
				int pos_a,pos_b,pos_c,pos_d;
				StringTokenizer words = new StringTokenizer(line,";");
				try{
				//7890;[trader_espen];[商人];[伊斯本];115797;217696;-3579;16384;
				words.nextToken();	
				name = words.nextToken();
				words.nextToken();
				words.nextToken();
				a = words.nextToken();//115797
				b = words.nextToken();//217696
				c = words.nextToken();//-3579
				d = words.nextToken();//-3579
				Integer tmp = new Integer(a);
				pos_a = tmp.intValue();
				tmp = new Integer(b);
				pos_b = tmp.intValue();
				tmp = new Integer(c);
				pos_c = tmp.intValue();
				tmp = new Integer(d);
				pos_d = tmp.intValue();
				
				new Class1(i,name,pos_a,pos_b,pos_c,pos_d).start();
				}catch (NoSuchElementException e){
					System.out.println(e);
				}
				try { Thread.sleep(25); }
					catch (InterruptedException e){
						System.out.println("ERROR: Thread Sleeping unfunctionable");
				}
			}
	
			} catch (FileNotFoundException e) { 
			    System.out.println("Error: Cannot find the file"); 
			} catch (IOException e) { 
			    System.out.println("Error: Cannot load the file."); 
			} 
		
		}

}
torune is offline