@script
{
if (frame == 48) {
void vEnt,self = getlocalvar("self");
int dx =100,dy=0,dz=0;
int dir = getentityproperty(self, "direction");
int tgtdir = 0;
if(dir==0) { dx = -dx; }
setlocalvar("T"+self, findtarget(self));
void target = getlocalvar("T"+self);
void TType = getentityproperty(target, "type");
tgtdir = getentityproperty(target, "direction");
if( getlocalvar("T"+self) != NULL()&&TType == openborconstant("TYPE_ENEMY"))
{
int Tx = getentityproperty(target, "x");
int Tz = getentityproperty(target, "z");
changeentityproperty(self, "position", Tx+dx, Tz+dz, dy);
if (dir == 0)
{
if (Tx+dx > dx)
{ changeentityproperty(self, "direction", 1);
} else { changeentityproperty(self, "direction", 0); }
} else {
if (Tx+dx > dx)
{ changeentityproperty(self, "direction", 0);
} else { changeentityproperty(self, "direction", 1); }
}
} else { changeentityproperty(self, "animation", openborconstant("ANI_FAINT")); }
}
}
@end_script