mtrain
New member
How to force the enemy to perform leap or dash move to a defined coordinates and stop there.
I have modify script for targeting:
So i put next command to the enemy attack move:
@cmd xytarget 480 400 5 5 0 0 1 with @cmd leap or dash
where 480 is the center of the screen x coordinate and 400 is the coordinate in z axis.
But the problem is i can not make enemy to stop when he reach that coordinates, he just continue to move. How to make him stop? Thank you)
I have modify script for targeting:
void xytarget(int Xc, int Yc, float Velx, float Velz, float dx, float dz, int Stop)
{// Targetting opponent before leaping or dashing.
// Velx = x Velocity
// Velz = z Velocity
// dx = x added distance
// dz = z added distance
// Stop = flag to stop moving if no target is found
void self = getlocalvar("self");
int dir = getentityproperty(self, "direction");
float x = getentityproperty(self, "x");
float z = getentityproperty(self, "z");
if (dir == 0){ //Is entity facing left?
dx = -dx; //Reverse X direction to match facing
}
setlocalvar("T"+self, findtarget(self)); //Get nearest player
if( getlocalvar("T"+self) != NULL()){
void target = getlocalvar("T"+self);
float Tx = (openborvariant("xpos") + Xc);
float Tz = (openborvariant("ypos") + Yc);
if(Tx < x){
changeentityproperty(self, "direction", 0);
} else {
changeentityproperty(self, "direction", 1);
}
x = x+dx;
z = z+dz;
float Disx = Tx - x;
float Disz = Tz - z;
//Set both distance as positive value
if(Disx < 0){
Disx = -Disx;
}
if(Disz < 0){
Disz = -Disz;
}
// Calculate velocity for targetting
if(Disz < Disx)
{
if(Tx < x){
setlocalvar("x"+self, -Velx);
} else { setlocalvar("x"+self, Velx); }
setlocalvar("z"+self, Velx*(Tz-z)/Disx);
} else {
if(Tz < z){
setlocalvar("z"+self, -Velz);
} else { setlocalvar("z"+self, Velz); }
setlocalvar("x"+self, Velz*(Tx-x)/Disz);
}
} else {
if(Stop == 1)
{
setlocalvar("z"+self, 0);
setlocalvar("x"+self, 0);
} else {
setlocalvar("z"+self, 0);
if(dir==0){
setlocalvar("x"+self, -Velx);
} else { setlocalvar("x"+self, Velx); }
}
}
}
So i put next command to the enemy attack move:
@cmd xytarget 480 400 5 5 0 0 1 with @cmd leap or dash
where 480 is the center of the screen x coordinate and 400 is the coordinate in z axis.
But the problem is i can not make enemy to stop when he reach that coordinates, he just continue to move. How to make him stop? Thank you)