scripting:reference:system_functions:worldmapfunctions
This is an old revision of the document!
Table of Contents
World / Map Functions
This group collects a few different sets of functions relating to the world -
- Functions for converting co-ordinates from map ('tile') to world scale
- Functions for finding out how much of a particular object can be found in specified locations
- Functions for controlling proximity ranges, where events are triggered when a player enters a particular region of the world
sysGetTileCenter
| Format | sysGetTileCenter ( World_X_or_Y ) |
|---|---|
| Description | Returns the world coordinate value for the center of the map tile nearest to the specified position |
| Returns | World coordinate of tile center |
Example:
Event( "UseItem", "TileTeleport" )
{
$tileCenterX = sysGetTileCenter( $gPlayerWorldX )
$tileCenterY = sysGetTileCenter( $gPlayerWorldY )
*setposworld %PLAYER% $tileCenterX $tileCenterY
}
sysMapToWorld
| Format | sysMapToWorld ( Map_X_or_Y ) |
|---|---|
| Description | Converts a map coordinate to a world coordinate |
| Returns | World coordinate |
Notes: There are 2 coordinate systems used in the game ; Map Coordinates range from 0 to 255 (for the default map size), 0 to 511 or 0 to 1023 (if using a larger map size) and they correspond to the 'tiles' that make up the landscape. World coordinates are in centimeters.
sysWorldToMap
| Format | sysWorldToMap ( Map_X_or_Y ) |
|---|---|
| Description | Converts a world coordinate to a map coordinate |
| Returns | Nearest map coordinate value |
sysGetBuildingAtWorldPos
sysWorldGetNumBuildingsOfType
| Format | sysWorldGetNumBuildingsOfType( BuildingType ) |
|---|---|
| Description | Returns the number of buildings of this type currently existing within the world. Useful for when you want to script a system that limits the number of a particular type of building |
| Returns | Number of this type of building currently in the world |
Example:
Event( "PlaceAnyBuilding", "" )
{
$nBuildingType = $gParam[1]
$numInWorld = sysWorldGetNumBuildingsOfType( $nBuildingType )
if ( $numInWorld >= 1 )
{
*msg %PLAYER% There can only be 1 of each type of building in the world
CancelTransaction()
}
else
{
$valid = sysIsBuildingPositionValid( $nBuildingType )
if ( $valid = 1 )
{
$buildingName = sysGetTextEntry()
$constrAmount = -1
$didAdd = sysAddBuildingWorld( $nBuildingType,$gPlayerID,$gPlayerWorldX,$gPlayerWorldY,$buildingName,$constrAmount )
}
}
}
sysGetNearestForest
sysGetNearestPlayer
| Format | sysGetNearestPlayer( WorldX, WorldY ) |
|---|---|
| Description | Returns the ID of the player closest to the specified world coordinate |
| Returns | Player ID |
Example:
$kSpecialBuildingRecordNum = 10
Event( "UseItem", "Plunger" )
{
SetBuildingContext( $kSpecialBuildingRecordNum )
$posX = $gBuildingWorldX
$posY = $gBuildingWorldY
$targetPlayerID = sysGetNearestPlayer( $posX, $posY )
$targetPlayerName = sysGetPlayerName( $targetPlayerID )
*say %PLAYER% used the plunger. The person closest to the special building was $targetPlayerName
*explodebuilding $kSpecialBuildingRecordNum
}
sysActivateBuildingProximityEvent
sysActivateLocalProximityEvent
sysActivateRangeEvent
sysDeactivateBuildingProximityEvent
sysDeactivateLocalProximityEvent
sysDeactivateRangeEvent
sysIsInScriptZone
sysNumPlayersInBuildZone
sysNumPlayersInRCMode
sysNumPlayersInScriptZone
scripting/reference/system_functions/worldmapfunctions.1581067310.txt.gz · Last modified: (external edit)
