antiwall platform

jonsilva

New member
hello
is there a way to make the antiwall script work on platforms
like this lines are working for walls
  H = checkwall(x+Dist,z);
  Hz = checkwall(x+Dist,z+Distz);

currently there seems to be checkwall and checkhole script commands
but I cant find checkplatform anywere
 
Unfortunately, there's only this function to detect platform:

checkplatformbelow(x, z, y)

It will return the handle of platform found in defined coordinates
Too bad I don't know how to acquire platform's height and width :(

Currently, I'm using workaround such as giving health and alias to platform to make enemies turn around when blocked by platform
 
thanks
but iam having a hard time trying to figure how checkplatformbelow works
so far ive changed this lines in antiwall script
  H = checkplatformbelow(x+Dist,z, 230);
  Hz = checkplatformbelow(x+Dist,z+Distz, 230);

but the player moves in position with no platforms on screen...

I have the platform spawning in the level at 1500 its a bigtruck moving back....
if the player and enemies are at the top screen they will get stuck inside the truck...
plus I have other several levels were the player will get stuck spawning inside closed doors and laser walls that close behind him

do you know if checkplatformbelow checks the platform in the level panel x and y coordinates or is checking it starting from player position ?
 
do you know if checkplatformbelow checks the platform in the level panel x and y coordinates or is checking it starting from player position ?

That function finds a platform 'below' defined coordinate. 'Below' means the platform must not be taller than defined check height otherwise the function returns nothing (even if the offset is clearly below that check coordinate)

For your case, you need to set check height taller than truck's height. 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)
 
well ive manadge to get it working but not the way I wanted
ive used the antiwall script
Code:
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);
   }
}

the problem is I don't know how this is being calculated
  H = checkplatformbelow(x+Dist,z, 5000);
  Hz = checkplatformbelow(x+Dist,z+Distz, 5000);
for much has I change the values the result is always the same
theres an empty space when the player is close to the platform unless the check distance is lower than 80...

pltformmove.jpg


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)

can you post your platform script to make enemies turn around when blocked by a platform?... in the script above it can check the entity platform height if its higher than 5000 the player doesn't move... 





 
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
 
thanks
ive tested the script but the same thing happened
there is still an empty space once I set Sx to 120...
ive added more length to the platform but nothing changed...
I cant figure out why this happens... but except for maybe 1 or 2 bosses none of my characters passes 60 in the slams... so it wont give me any problems...
thanks...





 
there is still an empty space once I set Sx to 120...
ive added more length to the platform but nothing changed...

Hmmm.... that's strange. Let me give it a try

[days later]

No problem here, I could acquire platform even with Sx set to 120
 
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

I have a problem with the objects set with platform.  The enemies and players get stuck when fall close.
So this script can be updated to work like the antiwall scripts,  but this will be the antiplatform script.
 
you can try this one
@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
the problem is they cant jump over a platform if they are on top of another platform
 
Thanks my friend!

I see your code says "ANY JUMP".
I dont want a code to make the enemies jump over platforms.
My problem is this:
I have a obstacle (like wall), you can destroy after hit many times.
This obstacle have set the platform values to work like a wall.
Everything it's ok until a player or enemy get stuck close to him.
So I need the script act like the antiwall. If detect a platform move a player far of platform.
Thanks for your help!
 
For walls, we have checkwall function which returns height of the wall and can be used on the wall
However, checkplatformbelow , as name implies checks platform BELOW checking coordinate. Therefore if it run inside a platform, it will return nothing or at least other platform below the former if there were any

So to create antiwall platform function, you will need to set same height setting to all obstacles to ensure the function would work properly
I'm going to try creating that function later

[Hours later]

I got a working function here:

Code:
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);
   }
}

The usage is almost the same as antiwall except that antiplat has height check as 4th parameter
For regular beat'm up, that antiplat function is sufficient. But for 2D or beat'm up with complex platform system, it needs modification
 
Thanks my friend, great work!

Now I find the other same problem of walls, happend in platforms.

If raiden make the toprpedo and catch an enemy, throw him to an obstacle wall, the enmey fall and when raise he get stuck in the obsacle (set with platform).
So is posible update this script to detect wall and platforms, or need make a new one working like this but only for platforms?
Code:
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));
   }
}
 
Back
Top Bottom