walllplatform dirchange--------------------------------
void StayPlat(int Rx, int Vx)
{// Finds platform edge within defined range. Turn around if edge is found
// Rx : Check distance in x axis
// Vx : Velocity to move
void self = getlocalvar("self");
int Dir = getentityproperty(self, "direction");
int x = getentityproperty(self, "x");
int y = getentityproperty(self, "a");
int z = getentityproperty(self, "z");
void Plat = checkplatformbelow(x, z, y+2);
void PlatA; void PlatB;
if(Plat){ // on a platform
if(Dir==1){
PlatA = checkplatformbelow(x+Rx, z, y+2);
PlatB = checkplatformbelow(x+Rx, z, y-2);
} else {
PlatA = checkplatformbelow(x-Rx, z, y+2);
PlatB = checkplatformbelow(x-Rx, z, y-2);
}
if(Plat!=PlatA && PlatA==PlatB && Dir==1){
changeentityproperty(self, "velocity", -Vx);
changeentityproperty(self, "direction", 0);
} else if(Plat!=PlatA && PlatA==PlatB && Dir==0){
changeentityproperty(self, "velocity", Vx);
changeentityproperty(self, "direction", 1);
}
}
}
----------platforma lewoprawo
@script
void self = getlocalvar("self");
int Dir = getentityproperty(self, "direction");
int x = getentityproperty(self, "x");
int y = getentityproperty(self, "a");
int z = getentityproperty(self, "z");
void Plat = checkplatformbelow(x, z, y+2);
void PlatA; void PlatB;
if(Plat){ // on a platform
if(Dir==1){
PlatA = checkplatformbelow(x+5, z, y+2);
PlatB = checkplatformbelow(x+5, z, y-2);
} else {
PlatA = checkplatformbelow(x-5, z, y+2);
PlatB = checkplatformbelow(x-5, z, y-2);
}
if(Plat!=PlatA && PlatA==PlatB && Dir==1){
changeentityproperty(self, "velocity", -2);
changeentityproperty(self, "direction", 0);
} else if(Plat!=PlatA && PlatA==PlatB && Dir==0){
changeentityproperty(self, "velocity", 2);
changeentityproperty(self, "direction", 1);
}
}
@end_script
-------------------- sciana i automatobrot
@script
void self = getlocalvar("self");
int Dir = getentityproperty(self, "direction");
int x = getentityproperty(self, "x");
int z = getentityproperty(self, "z");
int Wall = checkwall(x,z);
int WallC;
if(Dir==1){
WallC = checkwall(x+10,z);
} else {
WallC = checkwall(x-10,z);
}
if(Wall!=0 && Wall > WallC && Dir==1){
changeentityproperty(self, "velocity", -2);
changeentityproperty(self, "direction", 0);
} else if(Wall!=0 && Wall > WallC && Dir==0){
changeentityproperty(self, "velocity", 2);
changeentityproperty(self, "direction", 1);
}
@end_script
--
wallplatnofall
@script
void self = getlocalvar("self");
int Dir = getentityproperty(self, "direction");
int x = getentityproperty(self, "x");
int y = getentityproperty(self, "a");
int z = getentityproperty(self, "z");
int Width = openborvariant("levelwidth");
void Plat = checkplatformbelow(x, z, y+2);
int Length; int Px; void PlatA; void PlatB; int Wall;
if(x > Width - 10){
changeentityproperty(self, "velocity", -1);
changeentityproperty(self, "direction", 0);
} else if(x < 10){
changeentityproperty(self, "velocity", 1);
changeentityproperty(self, "direction", 1);
} else if(Plat){ // on a platform
Length = getentityproperty(Plat, "antigrab");
Px = getentityproperty(Plat, "x");
if(Dir==1){
PlatA = checkplatformbelow(x+24, z, y+2);
PlatB = checkplatformbelow(x+24, z, y-2);
} else {
PlatA = checkplatformbelow(x-24, z, y+2);
PlatB = checkplatformbelow(x-24, z, y-2);
}
if(x >= Px + Length/2 - 23 && PlatA==PlatB){
changeentityproperty(self, "velocity", -1);
changeentityproperty(self, "direction", 0);
} else if(x <= Px - Length/2 + 23 && PlatA==PlatB){
changeentityproperty(self, "velocity", 1);
changeentityproperty(self, "direction", 1);
}
} else { // on a wall
if(Dir==1){
Wall = checkwall(x+26,z);
} else {
Wall = checkwall(x-26,z);
}
if(y > Wall && Dir==1){
changeentityproperty(self, "velocity", -1);
changeentityproperty(self, "direction", 0);
} else if(y > Wall && Dir==0){
changeentityproperty(self, "velocity", 1);
changeentityproperty(self, "direction", 1);
}
}
@end_script
----
wall bump and turn
@script
void self = getlocalvar("self");
int x = getentityproperty(self, "x");
int z = getentityproperty(self, "z");
int Dir = getentityproperty(self, "direction");
int sped = getentityproperty(self, "speed");
int Sx = 1;
if(Dir==0){
Sx = -Sx;
changeentityproperty(self, "velocity", 0-sped );
}
if(Dir==1){
changeentityproperty(self, "velocity", sped );
}
void Plat = checkwall(x+Sx, z);
if( Dir == 0 && frame > 0 && x-(x-Plat) > 20 ){
changeentityproperty(self, "direction", 1 );
}
if( Dir == 1 && frame > 0 && x-(x-Plat) > 20 ){
changeentityproperty(self, "direction", 0 );
}
@end_script
---
platform end and turn
@script
void self = getlocalvar("self");
int x = getentityproperty(self, "x");
int z = getentityproperty(self, "z");
int y = getentityproperty(self, "a");
int Dir = getentityproperty(self, "direction");
int sped = getentityproperty(self, "speed");
void Plat = checkplatformbetween(x, z, y-100, 200);
if(Dir==0){
changeentityproperty(self, "velocity", -1 ,0,0);
}
if(Dir==1){
changeentityproperty(self, "velocity", 1 ,0,0);
}
if(Dir==0 && x+getentityproperty(Plat, "health")/2+2 <= getentityproperty(Plat, "x")){
changeentityproperty(self, "direction", 1 );
}
if(Dir==1 && x-getentityproperty(Plat, "health")/2-2 >= getentityproperty(Plat, "x")){
changeentityproperty(self, "direction", 0 );
}
@end_script