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


Creates a dynamic region.

Parameters

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


Removes a region.

Parameters

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

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

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

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

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

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

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

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

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

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

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

Example Usage

local region = DCEI.CreateRegion(16, 16, 4, 4)
DCEI.MoveRegion(region, 10, 10)