void targetTele()
{// Target opponent for teleport action
void self = getlocalvar("self");
setlocalvar("T"+self, findtarget(self)); //Get nearest player
if( getlocalvar("T"+self) != NULL()){
void target = getlocalvar("T"+self);
float Tx = getentityproperty(target, "x");
float Ty = getentityproperty(target, "a");
float Tz = getentityproperty(target, "z");
setlocalvar("Tx"+self, Tx);
setlocalvar("Ty"+self, Ty);
setlocalvar("Tz"+self, Tz);
}
setlocalvar("T"+self, NULL()); //Clears variable
}
void Teletarget(float dx, float dy, float dz, int YFlag)
{// Teleport self right at target's position
// dx = x added distance
// dy = y added distance
// dz = z added distance
// YFlag = Flag to control if altitude is taken or not
void self = getlocalvar("self");
int Direction = getentityproperty(self, "direction");
float Tx = getlocalvar("Tx"+self);
float Ty;
float Tz = getlocalvar("Tz"+self);
void vSpawn;
if (Direction == 0){ //Is entity facing left?
dx = -dx; //Reverse X direction to match facing
}
if (YFlag == 1){ //Altitude is taken?
Ty = getlocalvar("Ty"+self);
} else { //Altitude is taken?
Ty = 0;
}
if(Tx!= NULL() && Ty!= NULL() && Tz!= NULL()){
changeentityproperty(self, "position", Tx+dx, Tz+dz, Ty+dy);
}
}