Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: beomoud on Mon 16/02/2009 11:28:09

Title: Problem with diagonal wall baseline
Post by: beomoud on Mon 16/02/2009 11:28:09
What i want to do is have a diagonal wall but i don't know what to do with it's baseline. When the character is in one side another may be on the other side and may appear to be in front of the wall when i need him to be behind it... How do i handle this?
Title: Re: Problem with diagonal wall baseline
Post by: jastorman on Mon 16/02/2009 11:59:07
You could split the wall into several walk-behinds, each with a different baseline. There is probably a smoother way of achieving the same result, but I don't know it.
Title: Re: Problem with diagonal wall baseline
Post by: Charity on Tue 17/02/2009 05:19:40
I would use regions.  Put a region over all the walkeable areas behind the wall.  Set the wall's baseline to the highest point on the wall that a character can stand in front of.

In the room script, make a function something like
function BehindWall (this Character*) {
  if (region[1].GetAtRoomXY(this.x, this.y) (
    int offset = this.y - [[a number greater than the difference between the wall's baseline and the lowest point where you can stand behind the walll]];
    if (offset<1) offset=1; //Experiment with removing this line, but I'm pretty sure it will crash you if you go to close to the top of the screen.
    this.baseline=offset;
  }
  else this.baseline=this.y;
}


Then in the room's repeatedly execute script, run the BehindWall function on every character that has the potential of standing behind the wall.

I haven't tested this, and depending on how the layout is, it might produce some weird results.  But something along these lines might work for you.

If you can make it so only one character ever goes behind the wall, you can just use the region and reset the wall's baseline with SetWalkBehindBase.
Title: Re: Problem with diagonal wall baseline
Post by: Trent R on Tue 17/02/2009 07:28:51
Lyaer's code sounds like it should work. But I personally would change this Character* to something like Character *CharAtRegion. This is because 'this' is used for extender functions, and it would bother me to see player.BehindWall pop up on the Autocomplete.

But that is purely a personal opinion. Nothing wrong with the code itself.

~Trent
Title: Re: Problem with diagonal wall baseline
Post by: Khris on Tue 17/02/2009 07:43:22
Some additional thoughts:
if the second character isn't going to change positions, you can make them ignore walkbehinds (by settings their .IgnoreWalkbehinds  to true).

The best way to approach this really depends on whether there're going to be objects there, too, whether the other character's are moving, etc.

If you give us more info, we can provide you with the best solution.