User Tools

Site Tools


scripting:reference:system_functions:worldmapfunctions

World / Map Functions

This group collects a few different sets of functions relating to the world -

  1. Functions for converting co-ordinates from map ('tile') to world scale
  2. Functions for finding out how much of a particular object can be found in specified locations
  3. 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

sysActivateBuildingProximityEvent( buildingID, range ) - Activates a proximity trigger for the current player on the specified buildingID.
Used to trigger 4 different events:
Event( “BuildingIDProxEnter”, “BuildingID”) and if that doesnt exist..
Event( “BuildingProxEnter”, “”)
and the reverse..
Event( “BuildingIDProxLeave”, “BuildingID”) and if that doesnt exist..
Event( “BuildingProxLeave”, “”)

sysDeactivateBuildingProximityEvent

sysDeactivateBuildingProximityEvent( buildingID )

sysActivateRangeEvent

sysActivateRangeEvent( eventID, worldX, worldY, range ) - Activates a proximity trigger for the current player using a world coordinate. Atm, eventID is not used, only one range event can be active for the player at any one time. mm, atm seems to only triggers the event “RangeLeave” when a player leaves the range. curious.

sysDeactivateRangeEvent

sysIsInScriptZone

sysIsInScriptZone( MapX, MapY, ZoneIDNum ) used to query if the specified map coord is within the specified 'ScriptZone'. Script zones are added via the F10 world editor.

sysNumPlayersInBuildZone

sysNumPlayersInRCMode

sysNumPlayersInScriptZone

sysNumPlayersInScriptZone( ScriptZoneIDNum ) returns the number of players currently within the specified ScriptZone.


Not yet functional:

sysActivateLocalProximityEvent

sysDeactivateLocalProximityEvent

scripting/reference/system_functions/worldmapfunctions.txt · Last modified: 2020/02/07 19:00 by mit

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki