FindConstructionSite

Category: Landscape
Since engine version: 4.6.5.0 CP

Description

Searches for a suitable construction site for a building of the specified type, starting at position Var(iVarNumX)/Var(iVarNumY). If a site is found, the coordinates are stored in the two specified variables and the function returns true. Otherwise, the function returns false.

Syntax

bool FindConstructionSite (id idDef, int iVarNumX, int iVarNumY);

Parameters

idDef:
id of the desired building type
iVarNumX:
Number of the variable in which the global x position of the site is to be stored. This variable should first be initialized with the x position for the start of the search.
iVarNumY:
Number of the variable in which the global y position of the site is to be stored. This variable should first be initialized with the y position for the start of the search.

Example

Var(0)=GetX(); Var(1)=GetY();
if(FindConstructionSite(HUT3, 0, 1))
	CreateConstruction(HUT3, Var(0), Var(1), GetOwner(), 1, 1);
Searches a construction site for a hut, starting at the local position. If a site is found, construction is started.
See also: CreateConstruction, SetVar, Var
Sven2, November 2001