do you know if checkplatformbelow checks the platform in the level panel x and y coordinates or is checking it starting from player position ?
void antiwall3(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 y = getentityproperty(self, "a");
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 = checkplatformbelow(x+Dist,z, 5000);
Hz = checkplatformbelow(x+Dist,z+Distz, 5000);
if(Hz >= 1)
{
changeentityproperty(self, "position", x, z-Distz);
}
if(H >= 1)
{
changeentityproperty(self, "position", x+Move);
}
}
However, since the function returns entity handle instead, you will need to set a value in truck entity as it's height (maybe setting health or something)
@script
void self = getlocalvar("self");
int x = getentityproperty(self, "x");
int y = getentityproperty(self, "a");
int z = getentityproperty(self, "z");
float Vx = getentityproperty(self,"xdir");
int Dir = getentityproperty(self, "direction");
int Sx = 20;
if(Dir==0){
Sx = -20;
}
void Plat = checkplatformbelow(x+Sx, z, y+105);
if(getentityproperty(Plat,"name")=="Blok"){
if(Dir==0){ // Facing left?
changeentityproperty(self, "direction", 1);
} else {
changeentityproperty(self, "direction", 0);
}
changeentityproperty(self, "velocity", -Vx);
}
@end_script
there is still an empty space once I set Sx to 120...
ive added more length to the platform but nothing changed...
Bloodbane said:Here's the script:
@script
void self = getlocalvar("self");
int x = getentityproperty(self, "x");
int y = getentityproperty(self, "a");
int z = getentityproperty(self, "z");
float Vx = getentityproperty(self,"xdir");
int Dir = getentityproperty(self, "direction");
int Sx = 20;
if(Dir==0){
Sx = -20;
}
void Plat = checkplatformbelow(x+Sx, z, y+105);
if(getentityproperty(Plat,"name")=="Blok"){
if(Dir==0){ // Facing left?
changeentityproperty(self, "direction", 1);
} else {
changeentityproperty(self, "direction", 0);
}
changeentityproperty(self, "velocity", -Vx);
}
@end_script
The script simply finds any platform located 20 pixels in front of enemy and whose height is less than 105. If it finds any and its alias is Blok, enemy will turn around
Works well so far but not tested in overlapping platforms case. Well, I am avoiding that case whenever possible
the problem is they cant jump over a platform if they are on top of another platform@script
void self = getlocalvar("self");
void anim = getentityproperty(self,"animationID");
void hp = getentityproperty(self,"health");
int x = getentityproperty(self, "x");
int a = getentityproperty(self, "a");
int z = getentityproperty(self, "z");
int Dir = getentityproperty(self, "direction");
int Sx = 10; //----distance from platform
int jp = 1; //----jump velocity
if(anim == openborconstant("ANI_WALK"))
{
float Hy;
if(Dir==0)
{
Sx = -10;
jp = -1;
}
Hy = checkplatformbelow(x+Sx,z, 70);
if(Hy > 1 && a <= 7 && hp > 0)
{
performattack(self,openborconstant("ANI_JUMP"));
changeentityproperty(self, "velocity", 0, 0, 0);
tossentity(self, 4, jp, 0);
}
}
@end_script
void antiplat(int Dist, int Move, int Distz, int High)
{// Checks if there is platform at defined distance
// If there is platform, entity will be moved away with defined movement
void self = getlocalvar("self");
int Direction = getentityproperty(self, "direction");
int x = getentityproperty(self, "x");
int y = getentityproperty(self, "a");
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 = checkplatformbelow(x+Dist, z, y+High);
Hz = checkplatformbelow(x+Dist, z+Distz, y+High);
if(Hz){
changeentityproperty(self, "position", x, z-Distz);
}
if(H){
changeentityproperty(self, "position", x+Move);
}
}
void wallhit2(int Dist, void Ani)
{// Checks if there is wall/platform at defined distance change animation
void self = getlocalvar("self");
int Direction = getentityproperty(self, "direction");
int x = getentityproperty(self, "x");
int z = getentityproperty(self, "z");
if(Direction == 0){ //Is entity facing left?
Dist = -Dist; //Reverse Dist to match facing
}
float H = checkwall(x+Dist,z);
float Hy = checkplatformbelow(x+Dist,z, 5000);
if(H > 0 || Hy){
performattack(self, openborconstant(Ani));
}
}
Bloodbane said:Is that wallhit2 function working? I don't see anything wrong with it