void antiwall(int Dist, int Move, int Distz)
{// Checks if there is wall at defined distance
// If there is wall, entity will be moved away with defined movement
void self = getlocalvar("self");
int Direction = getentityproperty(self, "direction");
int x = getentityproperty(self, "x");
int z = getentityproperty(self, "z");
float H;
float Hz;
if (Direction == 0){ //Is entity facing left?
Dist = -Dist; //Reverse Dist to match facing
Move = -Move; //Reverse Move to match facing
}
H = checkwall(x+Dist,z);
Hz = checkwall(x+Dist,z+Distz);
if(Hz > 0)
{
changeentityproperty(self, "position", x, z-Distz);
changeentityproperty(self, "velocity", 0, 0, 0); //Stop moving!
}
if(H > 0)
{
changeentityproperty(self, "position", x+Move);
changeentityproperty(self, "velocity", 0, 0, 0); //Stop moving!
}
}