Trigger API Reference\DCEI Functions\Region
Region CreateRegion(float x, float z, float w, float h)
Region CreateRegion(float x, float z, float w, float h)
Description
Parameters
- float
x
the x coordinate of the new region. - float
z
the z coordinate of the new region. - float
w
the width of the new region. - float
h
the height of the new region.
Example Usage
local region = DCEI.CreateRegion(16, 16, 4, 4)
local random_point = DCEI.GetRandomPointInRegion(region)
void RemoveRegion(Region region)
void RemoveRegion(Region region)
Description
Parameters
- Region
region
region to remove
Example Usage
function OnRegionLeave()
local r = DCEI.TriggeringRegion
DCEI.RemoveRegion(r)
end
DCEI.TriggerAddUnitEnterRegionEvent(DCEI.CreateUnitFilter({name = DCEI.Unit("Test Unit")}), region, OnRegionLeave)
Region FindRegion(string name)
Region FindRegion(string name)
Description
Returns a region by name. Currently only works for regions pre-placed in the Terrain Window.
Parameters
- string
name
the name of the existing region to return.
Example Usage
local region = DCEI.FindRegion("region_a")
local center_point = DCEI.GetCenterOfRegion(region)
bool RegionExists(string name)
bool RegionExists(string name)
Description
Returns true if the region exists. Currently only works for regions pre-placed in the Terrain Window.
Parameters
- string
name
name of the region to check.
Example Usage
function OnRegionEnter()
SCORE = SCORE + 1
end
local region = DCEI.FindRegion("region_a")
if DCEI.RegionExists(region) then
DCEI.TriggerAddUnitEnterRegionEvent(DCEI.CreateUnitFilter({name = DCEI.Unit("Test Unit")}), region, OnRegionEnter)
string GetRegionName(Region region)
string GetRegionName(Region region)
Description
Returns the name of a region. Currently only works for regions pre-placed in the Terrain Window.
Parameters
- Region
region
the region to get the name of.
Example Usage
function OnRegionEnter()
local u = DCEI.TriggeringUnit
local r = DCEI.TriggeringRegion
local region_name = DCEI.RegionName(r)
if region_name = "goal_region" then
SCORE = SCORE + 1
end
end
DCEI.TriggerAddUnitEnterRegionEvent(DCEI.CreateUnitFilter({name = DCEI.Unit("Test Unit")}), DCEI.RegionAny, OnRegionEnter)
Float2 GetRandomPointInRegion(Region region)
Float2 GetRandomPointInRegion(Region region)
Description
Returns the coordinates of a random point in the region.
Parameters
- Region
region
the region to find a random point in.
Example Usage
local region = DCEI.CreateRegion(16, 16, 4, 4)
local random_point = DCEI.GetRandomPointInRegion(region)
Float2 GetCenterOfRegion(Region region)
Float2 GetCenterOfRegion(Region region)
Description
Returns the coordinates of the center point of the region.
Parameters
- Region
region
the region to find the center point of.
Example Usage
local region = DCEI.CreateRegion(16, 16, 4, 4)
local center_point = DCEI.GetCenterOfRegion(region)
Float2 GetSizeOfRegion(Region region)
Float2 GetSizeOfRegion(Region region)
Description
Returns the X and Y dimensions of the region.
Parameters
- Region
region
the region to find the dimensions of.
Example Usage
local region = DCEI.CreateRegion(16, 16, 4, 4)
local region_size = DCEI.GetSizeOfRegion(region)
bool CheckPointInRegion(Region region, float x, float z)
bool CheckPointInRegion(Region region, float x, float z)
Description
Returns true if coordinates are within the region.
Parameters
- Region
region
the region to find the dimensions of. - float
x
the x coordinate of the point. - float
z
the z coordinate of the point.
Example Usage
local SCORE = 0
local region = DCEI.CreateRegion(16, 16, 4, 4)
if DCEI.CheckPointInRegion(region, 14, 18) then
SCORE = SCORE + 1
end
object GetUnitsInRegion(Region region)
object GetUnitsInRegion(Region region)
Description
Returns a table of the units within the region.
Parameters
- Region
region
the region to find the units within.
Example Usage
local region = DCEI.CreateRegion(16, 16, 4, 4)
local units_in_region = DCEI.GetUnitsInRegion(region)
void HideRegion(Region region)
void HideRegion(Region region)
Description
Obscures the region on the map from the player.
Parameters
- Region
region
the region to obscure (creates fog of war).
Example Usage
local region = DCEI.CreateRegion(16, 16, 4, 4)
DCEI.HideRegion(region)
void RevealRegion(Region region)
void RevealRegion(Region region)
Description
Reveals a previously hidden region on the map to the player (clears fog of war).
Parameters
- Region
region
the region to reveal.
Example Usage
local region = DCEI.CreateRegion(16, 16, 4, 4)
DCEI.HideRegion(region)
DCEI.RevealRegion(region)
void MoveRegion(Region region, float x, float z)
void MoveRegion(Region region, float x, float z)
Description
Moves the center of the region to the specified coordinates.
Parameters
- Region
region
the region to move. - float
x
the x coordinate to move the region to. - float
z
the z coordinate to move the region to.
Example Usage
local region = DCEI.CreateRegion(16, 16, 4, 4)
DCEI.MoveRegion(region, 10, 10)