Trigger API Reference DCEI Functions Unit1 - funovus/editor-wiki 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)
* [int GetUnitWaypointNodeIndex(unit unit)](#int-getunitwaypointnodeindexunit-unit)
* [Float2 GetUnitPosition2D(unit unit)](#float2-getunitposition2dunit-unit)
* [Float3 GetUnitPosition3D(unit unit)](#float3-getunitposition3dunit-unit)
* [void SetUnitPosition2D(unit unit, float x, float z)](#void-setunitposition2dunit-unit-float-x-float-z)
* [void SetUnitPosition3D(unit unit, float x, float y, float z)](#void-setunitposition3dunit-unit-float-x-float-y-float-z)
* [void SetUnitPosition2DWithInterpolation(unit unit, float x, float z)](#void-setunitposition2dwithinterpolationunit-unit-float-x-float-z)
* [void SetUnitPosition3DWithInterpolation(unit unit, float x, float y, float z)](#void-setunitposition3dwithinterpolationunit-unit-float-x-float-y-float-z)
* [Float3 GetUnitRotationEuler(unit unit)](#float3-getunitrotationeulerunit-unit)
* [void SetUnitRotationEuler(unit unit, float x, float y, float z)](#void-setunitrotationeulerunit-unit-float-x-float-y-float-z)
* [void MoveAttack(unit target, float x, float z)](#void-moveattackunit-target-float-x-float-z)
* [bool UnitExists(unit unit)](#bool-unitexistsunit-unit)
* [bool UnitIsAlive(unit unit)](#bool-unitisaliveunit-unit)
* [bool UnitIsMoving(unit unit)](#bool-unitismovingunit-unit)
* [void EnableUnitSelection(unit target)](#void-enableunitselectionunit-target)
* [void EnableUnitSelectionSync(unit target)](#void-enableunitselectionsyncunit-target)
* [void DisableUnitSelection(unit target)](#void-disableunitselectionunit-target)
* [void DisableUnitSelectionSync(unit target)](#void-disableunitselectionsyncunit-target)
* [float GetMaxShield(unit unit)](#float-getmaxshieldunit-unit)
* [void SetMaxShield(unit unit, float value)](#void-setmaxshieldunit-unit-float-value)
* [float GetShield(unit unit)](#float-getshieldunit-unit)
* [void AddShield(unit unit, float value)](#void-addshieldunit-unit-float-value)
* [void SetShield(unit unit, float value)](#void-setshieldunit-unit-float-value)
* [float GetMaxHealth(unit unit)](#float-getmaxhealthunit-unit)
* [void SetMaxHealth(unit unit, float value)](#void-setmaxhealthunit-unit-float-value)
* [float GetMaxMana(unit unit)](#float-getmaxmanaunit-unit)
* [void SetMaxMana(unit unit, float value)](#void-setmaxmanaunit-unit-float-value)
* [void SetGoldBounty(unit unit, float amount)](#void-setgoldbountyunit-unit-float-amount)
* [void ApplyWaypoint(unit unit, string waypointName, float waypointDispersal)](#void-applywaypointunit-unit-string-waypointname-float-waypointdispersal)
* [void ApplyWaypoint(unit unit, WaypointOptions option)](#void-applywaypointunit-unit-waypointoptions-option)
|
Trigger API Reference\DCEI Functions\Unit (2/3) {Trigger-API-ReferenceDCEI-FunctionsUnit-23}
float GetUnitTotalDamage(unit unit)
Returns the total amount of damage a unit has dealt.
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)
Returns the index of the waypoint a unit is traveling to.
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)
Float2 GetUnitPosition2D(unit unit)
Returns the position of a unit.
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)
Returns the 3D position of a unit.
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)
Sets the position of a unit.
-
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.
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)
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)
Sets the 3D position of a unit.
-
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.
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)
void SetUnitPosition2DWithInterpolation(unit unit, float x, float z) {void-SetUnitPosition2DWithInterpolationunit-unit-float-x-float-z}
void SetUnitPosition2DWithInterpolation(unit unit, float x, float z)
Sets the position of a unit while causing it to seemingly leap to that position.
-
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.
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)
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)
Sets the 3D position of a unit while causing it to seemingly leap to that position.
-
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.
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)
Float3 GetUnitRotationEuler(unit unit)
Returns the 3d facing of a unit as a set of Euler Angles.
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)
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)
Sets the facing of a unit using Euler Angles.
-
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.
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)
void MoveAttack(unit target, float x, float z)
Issues an order for a unit to move to a target point while attacking any enemies they come across while moving.
-
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.
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)
bool UnitExists(unit unit)
Returns true is a units exists.
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)
bool UnitIsAlive(unit unit)
Returns true if a unit is alive.
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."))
bool UnitIsMoving(unit unit)
Returns true if a unit is moving.
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)
void EnableUnitSelection(unit target)
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)
void EnableUnitSelectionSync(unit target)
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)
void DisableUnitSelection(unit target)
Disables selection for a unit.
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)
void DisableUnitSelectionSync(unit target)
Disables selection for a unit.
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)
Returns the maximum shields of a unit.
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)
Sets the maximum shields for a unit.
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)
Returns the current shields of a unit.
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)
Increases the current shields of a unit by a set amount up to its maximum.
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)
Increases the current shields of a unit by a set amount up to its maximum.
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)
Returns the maximum health of a unit.
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)
Sets the maximum health for a unit.
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)
Returns the maximum mana of a unit.
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)
Sets the maximum mana for a unit.
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)
Sets the bounty for a unit.
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.")
void ApplyWaypoint(unit unit, string waypointName, float waypointDispersal) {void-ApplyWaypointunit-unit-string-waypointName-float-waypointDispersal}
void ApplyWaypoint(unit unit, string waypointName, float waypointDispersal)
Commands a unit attempt to move along the specified waypoints.
-
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.
void ApplyWaypoint(unit unit, WaypointOptions option) {void-ApplyWaypointunit-unit-WaypointOptions-option}
void ApplyWaypoint(unit unit, WaypointOptions option)