See also: FieldTypes

AllCastles

Usage:

AllCastles(fieldId1,fieldId2)

Example:

AllCastles(0,159399)

This function returns an array of MapCastleBean objects within an area. The first fieldId will be the northwest (top left) most corner of the area. The second fieldId will be the southeast (bottom right) most corner of the area. Both values must be field id not coordinates.

This example returns an array of all MapCastleBean objects within the state of Friesland:

This example will return an array of all MapCastleBean objects within a specified distance. Like a radius but in a rectangle...

FieldIdToCoords

Usage:

FieldIdToCoords(fieldId)

Example:

fid = 284460
echo FieldIdToCoords(fid)

This function converts a field id into coordinates.

This example finds the coordinates of a field id:

FindField

Usage:

FindField(x,y,radius,FieldTypes[,level])

Example:

FindField(city.x,city.y,20,12,10)

See also: FieldTypes

This function can find objects on the map within a specified radius of the searching city. You can for example use FindField to generate a list of all players near you, or all npcs level 10 within 20 miles, or whatever. The FieldTypes usable with FindField are linked above. The level is optional and can be omitted, or you may use "0" for any level. You can echo the results directly, or find and manipulate them from $result.

This example finds all the flats within a specified radius around your city, then echos the level of each:

This example gets a list of all npcs level 10 within 20 miles of your city, and then sorts them into an array of nearest to furthest from your city. Note - these are fieldIds not coordinates. You can turn the fieldIds into coordinates using FieldIdToCoords

FormatDistance

Usage:

FormatDistance(fieldId1,fieldId2)

Example:

FormatDistance(12345,23456)

This function finds the distance between two field ids and displays it in a nice readable format.

Basic example:

This example finds the distance between your own city and a target coordinates:

GetDetailInfo

Usage:

GetDetailInfo(FieldId,[priority],[expireSeconds],[compareSeconds])

Example:

echo GetDetailInfo(GetFieldId(123,456)).name

This function is used to get detailed information about a field id. Field id is required as a parameter, priority, expire seconds, and compare seconds are optional.

Priority is a true/false value to determine whether to place a request to the top of the queue for faster processing. It is only used if we have to queue update request. The default is false.

ExpireSeconds is how long since map data was last updated until the bot considers data "expired". This uses current time or value of "now" parameters as described below. The default is 0. If data is considered expired, the bot will queue an update request as needed.

CompareSeconds is the timestamp used to compare with for ExpireSeconds. The bot uses the current time if this is set to 0. The default is 0.

This example returns previously cached map data if we have it cached less than 30 seconds ago (then it returns null, and auto-requests map update)

The above would make "data" into a variable containing the MapCastleBean object for that field id, which you could then reference, for example:

Or you can even echo the entire object with all it's properties like so:

GetFieldId

Usage:

GetFieldId(coords)

Example:

coords = "460,355"
echo GetFieldId(coords)

This function converts coordinates into a field id.

The field id is a number between 0-63999. Each number directly corresponds to a square on the 800x800 grid map. The game server uses field ids to reference all the squares on the map... 0,0 has field id of 0.... 1,0 has field id of 1... 799,0 has field id of 799... 1,1 is field id 800... and so on. Many of the advanced scripting functions require you to convert your coordinates into fieldIds to use them.

This example finds the coordinates of a field id:

GetFieldName

Usage:

GetFieldName(#)

Example:

GetFieldName(10)

This function converts a numeric field value into a named string, for example:

The possible field numerics -> strings are as follows:

GetLevel

Usage:

GetLevel(fieldId)

Example:

GetLevel(city.fieldId)

This function returns the level of whatever is located at a certain field id.

GetZoneName

Usage:

GetZoneName(fieldId)

Example:

GetZoneName(city.fieldId)

This function returns the name of the state a field id is located in.

MapDistance

Usage:

MapDistance(x1,y1,x2,y2)

Example:

MapDistance(123,456,111,222)

This function finds the distance between two sets of coordinates on the map.

This example finds the distance between your own city and target coordinates, rounded to 2 decimal places:

StateCoords

Usage:

StateCoords(zone)

Example:

StateCoords("bohemia")

The function returns the state coordinates range, or null if invalid. You may use the zone name or number, for example "Friesland" or 0.

Some examples:


CategoryFunctions

MapFunctions (last edited 2016-05-16 18:23:10 by Inanna)