AvernumScript/Appendix/Location and Distance Calls

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Note that none of these functions are meant to be used in outdoors mode. They will not return proper values. Also, if you are writing a creature or terrain script, be sure to look up the calls my_loc_x() and my_loc_y().

short char_loc_x(short which_char)[edit]

Returns the x coordinate of the character which_char.

short char_loc_y(short which_char)[edit]

Returns the y coordinate of the character which_char.

short char_dist_to_loc(short which_char,short x, short y)[edit]

Returns the distance of character which_char from location {x,y}.


UNCONFIRMED: Using ME here, or -1, from a creature script doesn't seem to work right. It gives a distance number, but does not give the distance from the creature whose script was running. I had to use the creature's number. You can do this through using the constant my_number.

short char_on_loc(short x,short y)[edit]

Returns the number of the character on space {x,y}. If there is no character there, returns -1. Unlike char_on_spot(), this call also checks if one of the player’s characters is there.

short dist_to_waypoint(short which_char,short which_point)[edit]

Returns the distance of character which_char from waypoint which_point.

short group_dist_to_loc(short which_group,short x, short y)[edit]

Returns the distance of closest character in group which_group to the location {x,y}. Remember that group 0 is the party (in case you want to see who in the party is closest to a point). If the group is empty, the distance returned is 10000.

short my_dist_from_start()[edit]

This call can only be made from a creature script. Returns the character’s distance, in spaces, from where it started.