anim follow1
@script
if(frame>=1){
void self = getlocalvar("self");
int x = getentityproperty(self, "x"); // Get current x coordinate
int z = getentityproperty(self, "z"); // Get current y coordinate
int Dir = getentityproperty(self, "direction"); // Get current facing direction
int Screen = openborvariant("hResolution"); // Get screen length
int XPos = openborvariant("xpos"); // Get scroll position
int MinZ = openborvariant("PLAYER_MIN_Z");
int MaxZ = openborvariant("PLAYER_MAX_Z");
int R = rand()%15;
int Zidth = MaxZ - MinZ;
int Step = Zidth*0.17;
int Tz;
if(z <= MinZ + Step*2){
Tz = MinZ + Step*3 + R;
} else if(z <= MinZ + Step*4){
Tz = MinZ + Step*5 + R;
} else {
Tz = MinZ + Step + R;
}
if((x >= XPos + Screen + 100) && Dir == 1){
changeentityproperty(self, "direction", 0);
changeentityproperty(self, "position", XPos + Screen + 100, Tz);
changeentityproperty(self, "velocity", -2);
} else if((x <= XPos - 100) && Dir == 0){
changeentityproperty(self, "direction", 1);
changeentityproperty(self, "position", XPos-100, Tz);
changeentityproperty(self, "velocity", 2);
}
}
@end_script
...