Tuesday, August 21, 2007

A door only for exit

After thinking about Brian's comment about the /open command, I figured out that some changes would be needed. At first I thought this could all be hidden by the interface but I was wrong.

To enter a building, a door had to be created (prop) next to the building. When the /open command was used (the character needed to be on the tile containing the door), a check was made against the door to know in which zone (and coordinates) to send the character.

So a building didn't really have a door. From the start something was bugging me about this but I thought I could just live with it. Then I tried to link movement with the action of entering a building, that's when I saw I made a mistake.

So instead of creating a door prop for each building, I added a property to buildings allowing to specify where the door(s) is(are) located. So when a collision with a prop is detected, a check is made to figure out if it's a building. If so, a check is made to see if the door location fits with the location the character would have been if he was allowed to move. When there's a match, the character is taken to the new zone.

To exit a building though, it works much like before but now you don't need to use the /open command. The inside of a building is a zone just like any other and not "really" the inside of a building. A zone can be linked to 4 other zones (up, right, down, left). When a character try to move outside a zone, a check is made to see if there's actually a zone linked to the desired direction. If not, the character hit a "wall". Since I don't want to add the notion of doors to zones, that's why I still have to create doors to exit buildings.

However, this one was much easier to change. When a character hit the border of the zone, a check is made to see if he's on a tile with a door on it. If so, we check the direction the character wanted to go against the "exit direction" (could be "enter direction", doesn't change anything). If there's a match, the door will tell us where the character need to go.

Some minor changes that already make the interface a bit more friendly.