GetAreaSize(int, object)
Gets the size of the area measured in tiles.
int GetAreaSize( int nAreaDimension, object oArea );
Parameters
nAreaDimension
The area dimension that you wish to determine. AREA_HEIGHT or AREA_WIDTH.
oArea
The area that you wish to get the size of.
Description
Gets the size of the area measured in tiles.
Specifying AREA_HEIGHT in the nAreaDimension parameter causes the function to return the height of oArea. Using AREA_WIDTH there causes the function to the width of oArea. Anything else will result in an unpredictable return value.
Remarks
The function returns the number of tiles that the area is wide/high, or zero on an error. If no valid area (or object) is specified, it uses the area of the caller. If an object other than an area is specified, it will use the area that the object is currently in.
One tile = 10.0 meters
Version
1.67
Example
// Generate a random location in an area based on the area's size. void main() { // Determine the area to generate the location in. object oArea = GetObjectByTag("Area_Tag"); // If a valid area was found, compute the random location. if(GetIsObjectValid(oArea)) { // Determine the width and height of the area in tiles. int iWidthInTiles = GetAreaSize(AREA_WIDTH, oArea); int iHeightInTiles = GetAreaSize(AREA_HEIGHT, oArea); // Convert the width and height from tiles into meters. int iWidthInMeters = iWidthInTiles * 10; int iHeightInMeters = iHeightInTiles * 10; // Generate a random position in the area. float fXPosition = IntToFloat(Random(iWidthInMeters * 10)) / 10.0; float fYPosition = IntToFloat(Random(iHeightInMeters * 10)) / 10.0; float fZPosition = 0.0; vector vRandomPos = Vector(fXPosition, fYPosition, fZPosition); // Convert the random position to obtain the random location. float fFacing = 0.0; location lRandom = Location(oArea, vRandomPos, fFacing); } }
See Also
functions:  | GetArea |
categories:  | Area Functions |
constants:  | AREA_* |
author: bernosky, editor: Mistress, contributor: Axe Murderer