ID:157815
Dec 28 2009, 9:43 am
|
|
I'm currently programming 4-dir step_away, however, they run into walls/do not determine proper directions. What proc should I look up to determine if that direction is blocked?
|
Dec 28 2009, 9:46 am
|
|
Use get_step() to get the turf in a given direction, then check if that turf is dense or occupied.
|
get_step() will find a turf in a direction, and Enter() can be called to determine whether or not you can enter a turf.
My suggestion for this would be to use get_step_away() to find a turf that's "away" (as it's a bit more than just stepping in a direction that's away). Then, get_dir() to find what direction that's in. You can determine if it's a diagonal dir with if(dir&(dir-1)), which is true only for diagonal directions. Then, the two cardinal components are dir&(NORTH|SOUTH) and dir&(EAST|WEST). You can then use get_step() and Enter() to find which one is valid, and pick one of them to step into. |