Post by nazari on Feb 26, 2015 15:22:05 GMT
Hi guys, I solved my problem so im replacing original post with final solved code
1 after u load input from menu file
2 code will choose wich coordinates will be used
3 character go throught all coordinates (waypoints and in the end stops)
4 now i can do all the things like stop reset etc
Imagine University or Airport or Hospital , imagine u stand in front door , and u want to be navigated to some room deep in maze , u have input , and from this input script have to set waypoints , wich character will cross untill he will reach door he was looking for
1 after u load input from menu file
2 code will choose wich coordinates will be used
3 character go throught all coordinates (waypoints and in the end stops)
4 now i can do all the things like stop reset etc
//im replacing bad code , i SOLVED IT :D
int TARGET_SM = OBJ_0; // target box
int BOT_SM = OBJ_22; //character
string door= "";
int fileHandle;
Vector3 BotLoc;
Vector3 TargetLoc;
int Waypoint=1;
int LastW=-1;
int w=0;
void Way (int i,int Xx,int Zz){ // ALL WAYPOINTS
TargetLoc.x =Xx;
TargetLoc.z =Zz;
if (IN_110 == 1 && LastW==w-1){ // after hiting target on location wich is our waypoint box increment XZ from array
LastW=w;
w++;
if (w==i){ //if i hit last waypoint
OUT_46 = 0; //stop the character
}
}
}
void Main(){
if (iInitializing()) { // im loading wich door was choosen in menu
fileHandle = iFileReadOpen(".\\nazov.txt");
if (fileHandle != -1){
iFileStringRead(fileHandle,door);
iFileClose(fileHandle);
}
Waypoint = 1;
OUT_23 = 1;
OUT_46 = 1;
}
iObjectLocation(BOT_SM,BotLoc);
TargetLoc.y = BotLoc.y; //target box have same heigth as me
iObjectLocationSet(TARGET_SM,TargetLoc); // set target box location
if(door=="1"){ // the only bad thing is u have to define every door ,
int []x = { -50,-40,-50,-40}; // length is number of waypoints coordinates are first X and first Z
int []z = { 60, 40, 20,0};
int pocet=x.length();
Way(pocet,x[w],z[w]);
}
if(door=="2"){
int []x = { -90,-90,-90};
int []z = { 60, 30, 10};
int pocet=x.length();
Way(pocet,x[w],z[w]);
}
if(door=="3"){
int []x = { -50,-40,-50,-40};
int []z = { 60, 40, 20,0};
int pocet=x.length();
Way(pocet,x[w],z[w]);
}
if(door=="4"){
int []x = { -50,-40,-50,-40,-50,-40};
int []z = { 60, 40, 20, 0, 20, 30};
int pocet=x.length();
Way(pocet,x[w],z[w]);
}
if(door=="5"){
int []x = { -50,-40,-50,-40};
int []z = { 60, 40, 20,0};
int pocet=4;
Way(pocet,x[w],z[w]);
}
}
Imagine University or Airport or Hospital , imagine u stand in front door , and u want to be navigated to some room deep in maze , u have input , and from this input script have to set waypoints , wich character will cross untill he will reach door he was looking for