Problem with antiwall script

dantedevil

Well-known member
I have some new stages with some walls in the bottom of the stage.
The problems comes when a hero or enemy perform an attack throwing a projectile or make a slam script. The antiwall script not detect the wall in the bottom, so then the projectile dissappear or in the slams, the character slammed dissappear and dies.
So I don't know how avoid this problem.
 
To be honest, I am changing some of my antiwall scripts to onblockwscript, instead of using a antiwall script on AnimationScript.
onblockw works WAY better.

For example, this is a wall jump code I did using onblockw. It never had failed to me http://www.chronocrash.com/forum/index.php?topic=3767.0
 
O Ilusionista said:
To be honest, I am changing some of my antiwall scripts to onblockwscript, instead of using a antiwall script on AnimationScript.
onblockw works WAY better.

For example, this is a wall jump code I did using onblockw. It never had failed to me http://www.chronocrash.com/forum/index.php?topic=3767.0


Thank you very much for your help, you really have done a great job with this.

I understand that I must add the line with the script:
Ex:
onblocksscript data/script/bockwall.c

But I do not understand what this script should contain, since in which you show me  in the link, you use the walljump. And that is not my case.
 
Dante, I don't want to sound rude. My intention is to help you, to teach you.
As we said to you some times already, you need to try to understand the scrips, instead of just copy and paste.

Unless you try to understand, you won't never truly learn.

My code was an example of how I use it as onblockwscript. You need to understand the logic to change it for your need.
 
O Ilusionista said:
Dante, I don't want to sound rude. My intention is to help you, to teach you.
As we said to you some times already, you need to try to understand the scrips, instead of just copy and paste.

Unless you try to understand, you won't never truly learn.

My code was an example of how I use it as onblockwscript. You need to understand the logic to change it for your need.

I do not pretend to "copy and paste" as you say.
I just want you to explain the difference of the wall jump script, with the onblockwscript.
And give me the steps to continue as DC did in this post:
http://www.chronocrash.com/forum/index.php?topic=3858.msg53081;topicseen#new

Don'tworry about it.
Thanks anyway...
 
Don't get it personal, buddy. I am really trying to help you in my very rare free time and I could be doing something for me.
Instead, I am trying to help someone. Don't make me regret it.

As the manual says, onblockwscript triggers when any entity is blocked by a wall. So, from any antiwall code, you can remove all the wall detect logic
void antiwall(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;
  float Hw;

  if(Direction == 0){ //Is entity facing left?                 
      Dist = -Dist; //Reverse Dist to match facing
      Move = -Move; //Reverse Move to match facing
  }

  H = checkwall(x+Dist,z);
  Hz = checkwall(x+Dist,z+Distz);
  Hw = checkwall(x+Dist,z-Distz);

  if(Hz > y && Hw <= y)
  {
    changeentityproperty(self, "position", x, z-Distz);
  }

  if(H > y)
  {
    changeentityproperty(self, "position", x+Move);
  }
}

Just change the parts you want to change, like position, direction, etc.
 
For example, from the previous code, those lines are not needed, since the engine does it for you:

Code:
  int x = getentityproperty(self, "x");
   int y = getentityproperty(self, "a");
   int z = getentityproperty(self, "z");
   float H;
   float Hz;
   float Hw;
   H = checkwall(x+Dist,z);
   Hz = checkwall(x+Dist,z+Distz);
   Hw = checkwall(x+Dist,z-Distz);
 
I really appreciate your help, my friend. My problem is that the antiwall script that I currently use does not detect in the way I want, the walls that are upper or bottom. I want the script when it detects an upper wall, move the character 2 down in the z coordinates. And when it detects a wall in the bottom, move character 2 upwards in the z coordinates.
All this to avoid problems when fire projectiles or when perform some slams.
 
In the slam case, I see what you mean - I had the same issue. I just release the character on the same spot the player is, in both x and z axis.

Maybe you are using an old version of antiwall, because the version that I want do detects walls that are bellow you. You need to put the comnand 2 times, one for checking the wall above, other to check the wall bellow.
 
I use this version:

Code:
void antiwall(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;
   float Hw;

   if(Direction == 0){ //Is entity facing left?                  
      Dist = -Dist; //Reverse Dist to match facing
      Move = -Move; //Reverse Move to match facing
   }

   H = checkwall(x+Dist,z);
   Hz = checkwall(x+Dist,z+Distz);
   Hw = checkwall(x+Dist,z-Distz);

   if(Hz > y && Hw <= y)
   {
     changeentityproperty(self, "position", x, z-Distz);
   }

   if(H > y)
   {
     changeentityproperty(self, "position", x+Move);
   }
}
 
O Ilusionista said:
In the slam case, I see what you mean - I had the same issue. I just release the character on the same spot the player is, in both x and z axis.

Maybe you are using an old version of antiwall, because the version that I want do detects walls that are bellow you. You need to put the comnand 2 times, one for checking the wall above, other to check the wall bellow.

Can you show me your version?
 
Allow me to clarify something about onblockwscript and antiwall function. The former is run when entity is blocked by a wall, it works great for wall jump or bounce against wall. However it cannot be used to detect wall before touching the wall
antiwall function was coded to detect wall before touching the wall, that's why it's great to prevent entities from putting other entities inside a wall during slam or shooting

Back to topic:
dantedevil said:
I use this version:

Code:
void antiwall(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;
   float Hw;

   if(Direction == 0){ //Is entity facing left?                  
      Dist = -Dist; //Reverse Dist to match facing
      Move = -Move; //Reverse Move to match facing
   }

   H = checkwall(x+Dist,z);
   Hz = checkwall(x+Dist,z+Distz);
   Hw = checkwall(x+Dist,z-Distz);
//
   if(Hz > y && Hw <= y)
   {
     changeentityproperty(self, "position", x, z-Distz);
   }
//
   if(H > y)
   {
     changeentityproperty(self, "position", x+Move);
   }
}

You might need to fix and extend the part I wrapped with // into this:

Code:
   if(Hz > y)
   {
     changeentityproperty(self, "position", x, z-Distz);
   }
   if(Hw > y)
   {
     changeentityproperty(self, "position", x, z+Distz);
   }

HTH
 
Do You guys know how this problem is solved in actual games? In OpenBOR walls are coded as afterthought and are kinda hackarounded because theres every bug possible with them to this day like stuck in the middle or not taking walls into account when respawning and thus having players on top of high walls which are used only for blocking areas that arent meant to be walkable,  so i was wondering, maybe there is some better way to handhe such  situations?
Maybe wall code and respawn code need to have some additional checks put in place to get rid of at least respawn issue , or even have different types of walls. one type only for blocking areas and other type of walls to be used as platforms so you can walk on top of walls, and the first type should let respawn to place in actual walkable area.
I think this could be done but nobody tried yet.
I remember having issue with holes that are from top to bottom of the screen anf then after nagging a bit and testing -  new hardcoded way to respawn player after hole was introduced and it works great to this day , something like this for walls is a must IMO to save headaches.
What do You guys think ? How its done in other game engines?
 
It's done in other engines the same fundamental way we do... with vectors and collision check loops. Polygon engines use the same technique. There's really no other way. There are tricks here and there to make it less CPU intensive, but they only apply to polygonal worlds and all involve trying to guess when an object is near a wall before running the loops to make sure.

OpenBOR's walls are not an "afterthought". They're actually one of the engine's core fundamentals, and are quite well made.

The problem is moudle authors are not professionals with teams of playtesters that can ferret out every issue or interaction. And even with all that the pros have problems just as often. Heck, I've never seen or heard of a sprite based game that didn't have wall collision issues or bugs. Double Dragon's flying ladder, Sonic's Marble Zone level skip, SOTN stage clips...

Frankly it's just using bad design technique if objects get caught into walls. You have to put forethought into movement vs. stages. Ex: If you have an object that can at any time move 5 pixels in a frame, you better make sure the walls are 6 pixels thick or put checks in place to deal with it. It isn't the engine's fault if you don't and the object gets stuck behind a fence. I can't go into super detail posting from a phone... But the skinny is we need better tutorials. The walls are just fine.

DC
 
Well , i made walls over 5000 in height and i see there are some checks in engine and respawn is adjusted automatically.. so there actually is improvement on this  :) I just wish it was mentioned in manual or somewhere.
Works great so far, now i wish i was aware of this and created more interesting levels for he-man, sometimes because of bugs i had to give up on some ideas and this is pretty important cause linear left/right levels are boring after awhile.
 
Heck, I've never seen or heard of a sprite based game that didn't have wall collision issues or bugs.
I can't agree more. Any newer games (or remakes) has some issues that the old ones doesn't have, like in Bandicoot game.

The original uses cube shaped collision boxes, while the newer ones uses pill shaped ones. This detail can affect jumps vs platforms and walls. I can't find the video were they show this in action, but Youtube is full of videos with people saying that the remake is way harder.
 
Back
Top Bottom