Trigger API Reference DCEI Functions Unit1 - BLKTower/TestWiki GitHub Wiki

Table of Contents

Trigger API Reference\DCEI Functions\Unit (2/3) {Trigger-API-ReferenceDCEI-FunctionsUnit-23}

float GetUnitTotalDamage(unit unit) {float-GetUnitTotalDamageunit-unit}

float GetUnitTotalDamage(unit unit)

Description

Returns the total amount of damage a unit has dealt.

Parameters

  • unit unit the unit to get the total damage of.

Example Usage

local team_id = 1
local player_id = 1
local unit_type = "Standard MeleeUnit"
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)

local total_damage = DCEI.GetUnitTotalDamage(unit)
DCEI.LogMessage(total_damage)

int GetUnitWaypointNodeIndex(unit unit) {int-GetUnitWaypointNodeIndexunit-unit}

int GetUnitWaypointNodeIndex(unit unit)

Description

Returns the index of the waypoint a unit is traveling to.

Parameters

  • unit unit the unit to get the waypoint node index from.

Example Usage

local team_id = 1
local player_id = 1
local unit_type = "Standard MeleeUnit"
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)

DCEI.ApplyWapoint(unit, waypointoptions)

Related

Float2 GetUnitPosition2D(unit unit) {Float2-GetUnitPosition2Dunit-unit}

Float2 GetUnitPosition2D(unit unit)

Description

Returns the position of a unit.

Parameters

  • unit unit the unit to get the position of.

Example Usage

local team_id = 1
local player_id = 1
local unit_type = "Standard MeleeUnit"
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)

local position = DCEI.GetUnitPosition2D(unit)
DCEI.LogMessage("Unit position " .. position.x .. ", " .. position.y)

Float3 GetUnitPosition3D(unit unit) {Float3-GetUnitPosition3Dunit-unit}

Float3 GetUnitPosition3D(unit unit)

Description

Returns the 3D position of a unit.

Parameters

  • unit unit the unit to get the position of.

Example Usage

local team_id = 1
local player_id = 1
local unit_type = "Standard MeleeUnit"
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)

local position = DCEI.GetUnitPosition3D(unit)
DCEI.LogMessage("Unit position " .. position.x .. ", " .. position.y .. ", " .. position.z)

void SetUnitPosition2D(unit unit, float x, float z) {void-SetUnitPosition2Dunit-unit-float-x-float-z}

void SetUnitPosition2D(unit unit, float x, float z)

Description

Sets the position of a unit.

Parameters

  • unit unit the unit to set the position of.
  • float x the x-axis coordinate of the new position.
  • float z the z-axis coordinate of the new position.

Example Usage

local team_id = 1
local player_id = 1
local unit_type = "Standard MeleeUnit"
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)

local position = DCEI.GetUnitPosition2D(unit)
DCEI.LogMessage("Unit position " .. position.x .. ", " .. position.y)

DCEI.SetUnitPosition2D(unit, 15, 15)

position = DCEI.GetUnitPosition2D(unit)
DCEI.LogMessage("Unit position " .. position.x .. ", " .. position.y)

Related

void SetUnitPosition3D(unit unit, float x, float y, float z) {void-SetUnitPosition3Dunit-unit-float-x-float-y-float-z}

void SetUnitPosition3D(unit unit, float x, float y, float z)

Description

Sets the 3D position of a unit.

Parameters

  • unit unit the unit to set the position of.
  • float x the x-axis coordinate of the new position.
  • float y the y-axis coordinate of the new position.
  • float z the z-axis coordinate of the new position.

Example Usage

local team_id = 1
local player_id = 1
local unit_type = "Standard MeleeUnit"
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)

local position = DCEI.GetUnitPosition3D(unit)
DCEI.LogMessage("Unit position " .. position.x .. ", " .. position.y .. ", " .. position.z)

DCEI.SetUnitPosition3D(unit, 15, 1, 15)

position = DCEI.GetUnitPosition3D(unit)
DCEI.LogMessage("Unit position " .. position.x .. ", " .. position.y .. ", " .. position.z)

Related

void SetUnitPosition2DWithInterpolation(unit unit, float x, float z) {void-SetUnitPosition2DWithInterpolationunit-unit-float-x-float-z}

void SetUnitPosition2DWithInterpolation(unit unit, float x, float z)

Description

Sets the position of a unit while causing it to seemingly leap to that position.

Parameters

  • unit unit the unit to set the position of.
  • float x the x-axis coordinate of the new position.
  • float z the z-axis coordinate of the new position.

Example Usage

local team_id = 1
local player_id = 1
local unit_type = "Standard MeleeUnit"
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)

local position = DCEI.GetUnitPosition2D(unit)
DCEI.LogMessage("Unit position " .. position.x .. ", " .. position.y)

DCEI.SetUnitPosition2DWithInterpolation(unit, 15, 15)

position = DCEI.GetUnitPosition2D(unit)
DCEI.LogMessage("Unit position " .. position.x .. ", " .. position.y)

Related

void SetUnitPosition3DWithInterpolation(unit unit, float x, float y, float z) {void-SetUnitPosition3DWithInterpolationunit-unit-float-x-float-y-float-z}

void SetUnitPosition3DWithInterpolation(unit unit, float x, float y, float z)

Description

Sets the 3D position of a unit while causing it to seemingly leap to that position.

Parameters

  • unit unit the unit to set the position of.
  • float x the x-axis coordinate of the new position.
  • float y the y-axis coordinate of the new position.
  • float z the z-axis coordinate of the new position.

Example Usage

local team_id = 1
local player_id = 1
local unit_type = "Standard MeleeUnit"
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)

local position = DCEI.GetUnitPosition3D(unit)
DCEI.LogMessage("Unit position " .. position.x .. ", " .. position.y .. ", " .. position.z)

DCEI.SetUnitPosition3DWithInterpolation(unit, 15, 1, 15)

position = DCEI.GetUnitPosition3D(unit)
DCEI.LogMessage("Unit position " .. position.x .. ", " .. position.y .. ", " .. position.z)

Related

Float3 GetUnitRotationEuler(unit unit) {Float3-GetUnitRotationEulerunit-unit}

Float3 GetUnitRotationEuler(unit unit)

Description

Returns the 3d facing of a unit as a set of Euler Angles.

Parameters

  • unit unit the unit to get the facing of.

Example Usage

local team_id = 1
local player_id = 1
local unit_type = "Standard MeleeUnit"
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)

local rotation = DCEI.GetUnitRotationEuler(unit)
DCEI.LogMessage("Unit rotation: " .. rotation.x .. ", " .. rotation.y .. ", " .. rotation.z)

Related

void SetUnitRotationEuler(unit unit, float x, float y, float z) {void-SetUnitRotationEulerunit-unit-float-x-float-y-float-z}

void SetUnitRotationEuler(unit unit, float x, float y, float z)

Description

Sets the facing of a unit using Euler Angles.

Parameters

  • unit unit the unit to set the facing of of.
  • float x the x-axis rotation.
  • float y the y-axis rotation.
  • float z the z-axis rotation.

Example Usage

local team_id = 1
local player_id = 1
local unit_type = "Standard MeleeUnit"
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)

local rotation = DCEI.GetUnitRotationEuler(unit)
DCEI.LogMessage("Unit rotation: " .. rotation.x .. ", " .. rotation.y .. ", " .. rotation.z)

DCEI.SetUnitRotationEuler(unit,90, 150, 270)

rotation = DCEI.GetUnitRotationEuler(unit)
DCEI.LogMessage("Unit rotation: " .. rotation.x .. ", " .. rotation.y .. ", " .. rotation.z)

Related

void MoveAttack(unit target, float x, float z) {void-MoveAttackunit-target-float-x-float-z}

void MoveAttack(unit target, float x, float z)

Description

Issues an order for a unit to move to a target point while attacking any enemies they come across while moving.

Parameters

  • unit unit the unit to issue the order to.
  • float x the x-axis coordinate of the target point.
  • float z the z-axis coordinate of the target point.

Example Usage

local team_id = 1
local player_id = 1
local unit_type = "Standard MeleeUnit"
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
local enemy = DCEI.CreateUnit(-1, -1, unit_type, 12, 12)

DCEI.MoveAttack(unit, 10, 10)

Related

bool UnitExists(unit unit) {bool-UnitExistsunit-unit}

bool UnitExists(unit unit)

Description

Returns true is a units exists.

Parameters

  • unit unit the unit to check.

Example Usage

local status = DCEI.UnitExists(DCEI.UnitAny)
DCEI.LogMessage(status)

local team_id = 1
local player_id = 1
local unit_type = "Standard MeleeUnit"
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)

status = DCEI.UnitExists(unit)
DCEI.LogMessage(status)

Related

bool UnitIsAlive(unit unit) {bool-UnitIsAliveunit-unit}

bool UnitIsAlive(unit unit)

Description

Returns true if a unit is alive.

Parameters

  • unit unit the unit to check.

Example Usage

local team_id = 1
local player_id = 1
local unit_type = "Standard MeleeUnit"
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)

local status = DCEI.UnitIsAlive(unit)
DCEI.LogMessage("Unit is " .. (status and "alive." or "dead."))

Related

bool UnitIsMoving(unit unit) {bool-UnitIsMovingunit-unit}

bool UnitIsMoving(unit unit)

Description

Returns true if a unit is moving.

Parameters

  • unit unit the unit to check.

Example Usage

local team_id = 1
local player_id = 1
local unit_type = "Standard MeleeUnit"
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)

local status = DCEI.UnitIsMoving(unit)
DCEI.LogMessage("Unit is " .. (status and "" or "not ") .. "moving.")

DCEI.Move(unit, 13, 13)
DCEI.TriggerAddTimerEventElapsed(function()
    status = DCEI.UnitIsMoving(unit)
    DCEI.LogMessage("Unit is " .. (status and "" or "not ") .. "moving.")
end, 0.5, false, true)

Related

void EnableUnitSelection(unit target) {void-EnableUnitSelectionunit-target}

void EnableUnitSelection(unit target)

Description

Parameters

Example Usage

void EnableUnitSelectionSync(unit target) {void-EnableUnitSelectionSyncunit-target}

void EnableUnitSelectionSync(unit target)

⚠️Warning⚠️: This api was deprecated at 7/19/2022, and will be removed after 90 days.

Description

Enables selection for a unit.

Parameters

  • unit target the unit to enable selection on.

Example Usage

local team_id = 1
local player_id = 1
local unit_type = "Standard MeleeUnit"
local x, z = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, z)

DCEI.DisableUnitSelection(unit)
DCEI.EnableUnitSelection(unit)

Related

void DisableUnitSelection(unit target) {void-DisableUnitSelectionunit-target}

void DisableUnitSelection(unit target)

Description

Parameters

Example Usage

void DisableUnitSelectionSync(unit target) {void-DisableUnitSelectionSyncunit-target}

void DisableUnitSelectionSync(unit target)

⚠️Warning⚠️: This api was deprecated at 7/19/2022, and will be removed after 90 days.

Description

Disables selection for a unit.

Parameters

  • unit target the unit to disable selection on.

Example Usage

local team_id = 1
local player_id = 1
local unit_type = "Standard MeleeUnit"
local x, z = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, z)

DCEI.DisableUnitSelection(unit)

float GetMaxShield(unit unit) {float-GetMaxShieldunit-unit}

float GetMaxShield(unit unit)

Description

Returns the maximum shields of a unit.

Parameters

  • unit unit the unit to check.

Example Usage

DCEI.TriggerAddTimerEventElapsed(function()
    local team_id = 1
    local player_id = 1
    local unit_type = "Standard MeleeUnit"
    local x, y = 16, 16
    local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
    DCEI.Wait(1)

    DCEI.SetShield(unit, 5)
    DCEI.SetMaxShield(unit,30)
    local shields = DCEI.GetShield(unit)
    local max_shields = DCEI.GetMaxShield(unit)
    DCEI.LogMessage(unit_type .. " has " .. shields .. "/" .. max_shields .. " shields currently.")

    DCEI.AddShield(unit, 10)
    shields = DCEI.GetShield(unit)
    DCEI.LogMessage(unit_type .. " has " .. shields .. "/" .. max_shields .. " shields currently.")
end, 
0.0)

void SetMaxShield(unit unit, float value) {void-SetMaxShieldunit-unit-float-value}

void SetMaxShield(unit unit, float value)

Description

Sets the maximum shields for a unit.

Parameters

  • unit unit the unit to modify.
  • float value the new maximum for the unit.

Example Usage

DCEI.TriggerAddTimerEventElapsed(function()
    local team_id = 1
    local player_id = 1
    local unit_type = "Standard MeleeUnit"
    local x, y = 16, 16
    local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
    DCEI.Wait(1)

    DCEI.SetShield(unit, 5)
    DCEI.SetMaxShield(unit,30)
    local shields = DCEI.GetShield(unit)
    local max_shields = DCEI.GetMaxShield(unit)
    DCEI.LogMessage(unit_type .. " has " .. shields .. "/" .. max_shields .. " shields currently.")

    DCEI.AddShield(unit, 10)
    shields = DCEI.GetShield(unit)
    DCEI.LogMessage(unit_type .. " has " .. shields .. "/" .. max_shields .. " shields currently.")
end, 
0.0)

float GetShield(unit unit) {float-GetShieldunit-unit}

float GetShield(unit unit)

Description

Returns the current shields of a unit.

Parameters

  • unit unit the unit to check.

Example Usage

DCEI.TriggerAddTimerEventElapsed(function()
    local team_id = 1
    local player_id = 1
    local unit_type = "Standard MeleeUnit"
    local x, y = 16, 16
    local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
    DCEI.Wait(1)

    DCEI.SetShield(unit, 5)
    DCEI.SetMaxShield(unit,30)
    local shields = DCEI.GetShield(unit)
    local max_shields = DCEI.GetMaxShield(unit)
    DCEI.LogMessage(unit_type .. " has " .. shields .. "/" .. max_shields .. " shields currently.")

    DCEI.AddShield(unit, 10)
    shields = DCEI.GetShield(unit)
    DCEI.LogMessage(unit_type .. " has " .. shields .. "/" .. max_shields .. " shields currently.")
end, 
0.0)

void AddShield(unit unit, float value) {void-AddShieldunit-unit-float-value}

void AddShield(unit unit, float value)

Description

Increases the current shields of a unit by a set amount up to its maximum.

Parameters

  • unit unit the unit to add shields to.
  • float amount the amount of shields to add.

Example Usage

DCEI.TriggerAddTimerEventElapsed(function()
    local team_id = 1
    local player_id = 1
    local unit_type = "Standard MeleeUnit"
    local x, y = 16, 16
    local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
    DCEI.Wait(1)

    DCEI.SetShield(unit, 5)
    DCEI.SetMaxShield(unit,30)
    local shields = DCEI.GetShield(unit)
    local max_shields = DCEI.GetMaxShield(unit)
    DCEI.LogMessage(unit_type .. " has " .. shields .. "/" .. max_shields .. " shields currently.")

    DCEI.AddShield(unit, 10)
    shields = DCEI.GetShield(unit)
    DCEI.LogMessage(unit_type .. " has " .. shields .. "/" .. max_shields .. " shields currently.")
end, 
0.0)

void SetShield(unit unit, float value) {void-SetShieldunit-unit-float-value}

void SetShield(unit unit, float value)

Description

Increases the current shields of a unit by a set amount up to its maximum.

Parameters

  • unit unit the unit to add shields to.
  • float value the amount of shields to add.

Example Usage

DCEI.TriggerAddTimerEventElapsed(function()
    local team_id = 1
    local player_id = 1
    local unit_type = "Standard MeleeUnit"
    local x, y = 16, 16
    local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
    DCEI.Wait(1)

    DCEI.SetShield(unit, 5)
    DCEI.SetMaxShield(unit,30)
    local shields = DCEI.GetShield(unit)
    local max_shields = DCEI.GetMaxShield(unit)
    DCEI.LogMessage(unit_type .. " has " .. shields .. "/" .. max_shields .. " shields currently.")

    DCEI.AddShield(unit, 10)
    shields = DCEI.GetShield(unit)
    DCEI.LogMessage(unit_type .. " has " .. shields .. "/" .. max_shields .. " shields currently.")
end, 
0.0)

float GetMaxHealth(unit unit) {float-GetMaxHealthunit-unit}

float GetMaxHealth(unit unit)

Description

Returns the maximum health of a unit.

Parameters

  • unit unit the unit to check.

Example Usage

DCEI.TriggerAddTimerEventElapsed(function()
    local team_id = 1
    local player_id = 1
    local unit_type = "Standard MeleeUnit"
    local x, y = 16, 16
    local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
    DCEI.Wait(1)

    DCEI.SetHealth(unit, 5)
    DCEI.SetMaxHealth(unit,30)
    local hp = DCEI.GetHealth(unit)
    local max_hp = DCEI.GetMaxHealth(unit)
    DCEI.LogMessage(unit_type .. " has " .. hp .. "/" .. max_hp .. " hp currently.")

    DCEI.AddHealth(unit, 10)
    hp = DCEI.GetHealth(unit)
    DCEI.LogMessage(unit_type .. " has " .. hp .. "/" .. max_hp .. " hp currently.")
end, 
0.0)

void SetMaxHealth(unit unit, float value) {void-SetMaxHealthunit-unit-float-value}

void SetMaxHealth(unit unit, float value)

Description

Sets the maximum health for a unit.

Parameters

  • unit unit the unit to modify.
  • float value the new maximum for the unit.

Example Usage

DCEI.TriggerAddTimerEventElapsed(function()
    local team_id = 1
    local player_id = 1
    local unit_type = "Standard MeleeUnit"
    local x, y = 16, 16
    local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
    DCEI.Wait(1)

    DCEI.SetHealth(unit, 5)
    DCEI.SetMaxHealth(unit,30)
    local hp = DCEI.GetHealth(unit)
    local max_hp = DCEI.GetMaxHealth(unit)
    DCEI.LogMessage(unit_type .. " has " .. hp .. "/" .. max_hp .. " hp currently.")

    DCEI.AddHealth(unit, 10)
    hp = DCEI.GetHealth(unit)
    DCEI.LogMessage(unit_type .. " has " .. hp .. "/" .. max_hp .. " hp currently.")
end, 
0.0)

float GetMaxMana(unit unit) {float-GetMaxManaunit-unit}

float GetMaxMana(unit unit)

Description

Returns the maximum mana of a unit.

Parameters

  • unit unit the unit to check.

Example Usage

DCEI.TriggerAddTimerEventElapsed(function()
    local team_id = 1
    local player_id = 1
    local unit_type = "Standard MeleeUnit"
    local x, y = 16, 16
    local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
    DCEI.Wait(1)

    DCEI.SetMaxMana(unit, 20)
    DCEI.SetMana(5)
    local mana = DCEI.GetMana(unit)
    local max_mana = DCEI.GetMaxMana(unit)
    DCEI.LogMessage(unit_type .. " has " .. mana .. "/" .. max_mana .. " mana currently.")

    DCEI.AddMana(unit, 10)
    mana = DCEI.GetMana(unit)
    DCEI.LogMessage(unit_type .. " has " .. mana .. "/" .. max_mana .. " mana currently.")
end, 
0.0)

void SetMaxMana(unit unit, float value) {void-SetMaxManaunit-unit-float-value}

void SetMaxMana(unit unit, float value)

Description

Sets the maximum mana for a unit.

Parameters

  • unit unit the unit to modify.
  • float value the new maximum for the unit.

Example Usage

DCEI.TriggerAddTimerEventElapsed(function()
    local team_id = 1
    local player_id = 1
    local unit_type = "Standard MeleeUnit"
    local x, y = 16, 16
    local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
    DCEI.Wait(1)

    DCEI.SetMaxMana(unit, 20)
    DCEI.SetMana(5)
    local mana = DCEI.GetMana(unit)
    local max_mana = DCEI.GetMaxMana(unit)
    DCEI.LogMessage(unit_type .. " has " .. mana .. "/" .. max_mana .. " mana currently.")

    DCEI.AddMana(unit, 10)
    mana = DCEI.GetMana(unit)
    DCEI.LogMessage(unit_type .. " has " .. mana .. "/" .. max_mana .. " mana currently.")
end, 
0.0)

void SetGoldBounty(unit unit, float amount) {void-SetGoldBountyunit-unit-float-amount}

void SetGoldBounty(unit unit, float amount)

Description

Sets the bounty for a unit.

Parameters

  • unit unit the unit to set the bounty on.
  • float amount the amount of gold the unit is worth.

Example Usage

local team_id = 1
local player_id = 1
local unit_type = "Standard MeleeUnit"
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)

DCEI.SetGoldBounty(unit, 5.0)
local bounty = DCEI.GetUnitBounty(unit)
DCEI.LogMessage(unit_type .. " has a bounty of " .. bounty .. " gold.")

Related

void ApplyWaypoint(unit unit, string waypointName, float waypointDispersal) {void-ApplyWaypointunit-unit-string-waypointName-float-waypointDispersal}

void ApplyWaypoint(unit unit, string waypointName, float waypointDispersal)

Description

Commands a unit attempt to move along the specified waypoints.

Parameters

  • unit unit the unit to command.
  • string waypointName the waypoint to move along.
  • float waypointDispersal the pathing offset to follow. 0.5 is center, 0 is left, 1 is right.

Example Usage

void ApplyWaypoint(unit unit, WaypointOptions option) {void-ApplyWaypointunit-unit-WaypointOptions-option}

void ApplyWaypoint(unit unit, WaypointOptions option)

Description

Parameters

Example Usage

Related

⚠️ **GitHub.com Fallback** ⚠️