Problem description:How would I code the ability for a mob to walk into a turf only from certain directions and make so a mob can only exit that same turf from certain directions? |
Could you expand about what you mean by Bitflags? Or at least, how you suggest to use bitflags in this situation?
|
DarkLordZargog wrote:
Could you expand about what you mean by Bitflags? Or at least, how you suggest to use bitflags in this situation? Instead of a list variable containing the allowed directions, you'd use a variable with key flags toggled on: // allow /turf/example turfs to only allow entrance from the north side Checking would look like:
if(some_movable.dir & allowed_directions)
|
Could you put that in a format as if you were writing it out for a turf? Just so I can see it put together into a code. I only say that because when I put it together it still didn't register what i'm trying to get it to do, so maybe my formatting was incorrect in this sense.
|
NORTHEAST is NORTH | EAST, so NORTH | NORTHEAST | NORTHWEST is the same as NORTHEAST | WEST.
If you want to include diagonals in the list of allowed entrances, a different way of handling bitflags is called for. That's beyond the scope of this post. For the purposes of this post, I assume using just the cardinal directions is sufficient. In which case: turf/directional The == d check is because if you allow north but not west, then entry from the northwest should be forbidden. |
If I wanted to replicate that same effect but for Exit() what would I need to call to get_dir?
|
Exit() (and Enter()) has a second argument, which refers to the "new loc" that the mover is trying to move to.
turf/directional |
Now I have one last question: How would I call it so even if the direction isn't passable, you could still pass through it if your density = 0.
|
Just include a density check at the beginning. If density is 0 (use the ! operator) return 1.
|
Then you'd set the passable list to a list of directions like list(NORTH,SOUTH,WEST)