A zone represent a patch of land in Northgard that can be colonized and exploited by the players. Any entity is located in
Variables
read onlybuildings:Array<Building>
All the buildings in the zone. Include player built buildings and gameplay buildings like Wolf Den or Swamp, but not decorative rocks, trees or grasses.
read onlycolonize:Float
[HostOnly] The progress of a zone colonisation, if the zone is neutral or contested. Goes from 0 to 1, at which the zone owner become the owner referenced by colonizeBy.
read onlycolonizeBy:Float
[HostOnly] The player current attacking the zone, if the zone is neutral or contested.
maxBuildings:Int
[HostOnly] The maximum number of building a zone can hold, excluding the additional buildings from a developped zone or from Kraken's Shallow Waters
Methods
addUnit(kind:UnitKind, ?nb:Int, ?owner:Player, ?withSpawnSfx:Bool, ?modelsNb:Array<Int>, ?radiusMax:Float):Array<Unit>
[HostOnly] Add a unit of a certain UnitKind at a random position in the zone.
Parameters:
kind | The kind of unit to add. |
---|---|
nb | [Optional] A number of units to spawn at once. Spawn one by default. |
owner | [Optional] The units' owner. Is the main player by default. |
withSpawnSfx | [Optional] Set at true to play the spawn sound effect. False by default. |
modelsNb | [Optional] An array of variant ids to change the visuals of each new units with variants. |
rayMax | [Optional] Constrain the spawn position inside a radius from the center of the zone. |
createBuilding(kind:BuildingKind, randomSeed:Bool = false, ?opt:{variant:Null<Int>, pos:Null<{y:Float, x:Float}>, index:Null<Int>, flip:Null<Bool>, creator:Null<Player>, center:Null<Bool>}):Building
Add a building to the zone at a random location. This doesn't add grass or dirt around the building.
Parameters:
kind | The kind of the building you want to add. |
---|---|
randomSeed | Using a random seed ensure the building won't be placed twice at the same position between two games. |
center | Set to true if you want the building to be placed at the center of the zone, if possible. |
variant | Variant index of a building if available, 0 by default. |
flip | Do we flip the building. |
index | When placing multiple buildings of the same time at once, giving the index can help the generation place them. Used by TallGrass and Poisonous Swamp only. |
creator | Required for buildings creator based, like Altar of Kings, relics or Ancient Battleground. |
Returns:
The created building, or null if it couldn't be placed.
getDepositResCount(res:ResourceKind):Float
Tell the quantity of a specific ore resource is available in the whole zone.
Parameters:
res | The kind of resource we want to count. Only works with an ore resource like Stone, Iron, RimeSteel or Gemstone. |
---|
Returns:
Float
getUnit(kind:UnitKind):Unit
Get the unit of a given kind which entered the zone first.
Parameters:
kind |
---|
Returns:
Unit
takeControl(newOwner:Player, alert:Bool = true):Void
[HostOnly] Immediately give the control of the zone to the given player.
Parameters:
newOwner | |
---|---|
alert | [Optional] Do we generate an alert to the player as he lose or gain a zone. |