Geography

by Deadron
Helpful functions for handling directions and random movement.
ID:91577
 
atom/proc/dd_area()
Returns the area for the object or mob, or null if the object is at the null location.

dd_direction_name(direction)
This returns a text name for direction.
For example, if direction is NORTH, this returns "NORTH".

dd_get_dist(first, second)
Returns the distance between two objects.
Objects can be anything with x and y variables.

dd_get_step(object, direction)
Returns the turf in the specified direction (NORTH, SOUTHWEST, etc) from the object.
Accepts any object with x, y, z variables defining its location.

dd_get_step_rand(object, considerDensity, randomness)
Returns a random valid turf one step away from the object (anything with x and y variables), or null if it can't find any valid turfs.

randomness determines the percentage chance that the step will be random instead of continuing in the direction the object was already moving.

dd_reverse_direction(direction)
This returns whatever direction is opposite of direction. For example, if direction is NORTH, dd_reverse_direction() returns SOUTH.

dd_step_rand(M, randomness)
Moves the object one step, returning 1 on success or null on failure.

randomness is the percentage chance that the object will move in a random direction instead of continuing in the direction it was already facing.