- Trigger API Reference\DCEI Functions\Unit
- CreateUnitFilter
- CreateUnit
- KillUnit
- RemoveUnit
- GetUnitType
- GetUnitTypeHealth
- GetUnitDisplayName
- GetUnitCategory
- AttachSimpleUnitToCursor
- DetachSimpleUnitFromCursor
- PlaySimpleUnitAnimationClip
- AttachUnit
- DetachUnit
- Move
- Attack
- DirectionalMove
- TurnUnitTowards
- GetHealth
- AddHealth
- SetHealth
- SetUnitOwner
- SetUnitTeamId
- GetMana
- AddMana
- SetMana
- GetUnitFacing2D
- GetUnitBounty
- GetUnitBehaviorList
- GetUnitWeaponList
- GetUnitAbilityList
- ApplyTag
- RemoveTag
- GetUnitTagCount
- GetUnitTagList
- GetUnitTotalDamage
- GetUnitPosition2D
- GetUnitPosition3D
- SetUnitPosition2D
- SetUnitPosition3D
- SetUnitPosition2DWithInterpolation
- SetUnitPosition3DWithInterpolation
- GetUnitRotationEuler
- SetUnitRotationEuler
- MoveAttack
- UnitExists
- SimpleUnitExists
- UnitIsAlive
- UnitIsMoving
- EnableUnitSelection
- DisableUnitSelection
- ShowUnitCustomHealthBar
- ConfigStatusBar
- RegisterBehaviorStatusIcon
- GetMaxShield
- SetMaxShield
- GetShield
- AddShield
- SetShield
- GetMaxHealth
- SetMaxHealth
- GetMaxMana
- SetMaxMana
- SetGoldBounty
- FollowUnit
- FollowUnitWithOffset
- ClearFollowUnit
- SelectUnit
- DeselectUnit
- FindUnit
- FindUnitsByPlayerId
- FindUnitsByTeamId
- FindUnits
- FindUnitAtPosition
- IsUnitSelected
Trigger API Reference\DCEI Functions\Unit
unit CreateUnitFilter(UnitFilter filter)
unit CreateUnitFilter(UnitFilter filter)
Description
Creates a filter for a specific unit type, which can be used with any trigger event API (like DCEI.TriggerAddUnitSelectedEvent
) that accepts a unit as a parameter. This filter will then cause the event to register only for this specific unit type rather than all unit types. See Using Trigger Event Filters
Parameters
- UnitFilter
filter
the unit filter to create.
Example Usage
-- Called when any enemy unit spawns or dies
local enemy_unit_filter = DCEI.CreateUnitFilter({ team = -1 })
DCEI.TriggerAddUnitSpawnEvent(enemy_unit_filter, function() DCEI.LogMessage("Enemy unit spawned") end, false)
DCEI.TriggerAddUnitDiedEvent(enemy_unit_filter, function() DCEI.LogMessage("Enemy unit died") end, false)
-- Called when any player unit spawns or dies
local player_unit_filter = DCEI.CreateUnitFilter({ team = 1 })
DCEI.TriggerAddUnitSpawnEvent(player_unit_filter, function() DCEI.LogMessage("Player unit spawned") end, false)
DCEI.TriggerAddUnitDiedEvent(player_unit_filter, function() DCEI.LogMessage("Player unit died") end, false)
-- Called when any "Test Unit" unit spawns or dies
local test_unit_filter = DCEI.CreateUnitFilter({ name = DCEI.Unit("Test Unit") })
DCEI.TriggerAddUnitSpawnEvent(test_unit_filter, function() DCEI.LogMessage("Test Unit spawned") end, false)
DCEI.TriggerAddUnitDiedEvent(test_unit_filter, function() DCEI.LogMessage("Test Unit died") end, false)
-- Called when player "Test Unit" unit spawns or dies
local player_test_unit_filter = DCEI.CreateUnitFilter({ team = 1, name = DCEI.Unit("Player Test Unit") })
DCEI.TriggerAddUnitSpawnEvent(player_test_unit_filter, function() DCEI.LogMessage("Player Test Unit spawned") end, false)
DCEI.TriggerAddUnitDiedEvent(player_test_unit_filter, function() DCEI.LogMessage("Player Test Unit died") end, false)
-- How to register multiple player units
local names = { DCEI.Unit("Ghost Inky"), DCEI.Unit("Ghost Blinky"), DCEI.Unit("Ghost Stinky") }
for _, name in ipairs(names) do
local unit_filter = DCEI.CreateUnitFilter({ team = 1, name = name })
DCEI.TriggerAddUnitSpawnEvent(unit_filter, function() DCEI.LogMessage(name .. " spawned") end, false)
DCEI.TriggerAddUnitDiedEvent(unit_filter, function() DCEI.LogMessage(name .. " died") end, false)
end
unit CreateUnit(int teamId, int playerId, string unitType, float x, float z, float dx = 0, float dz = 1)
unit CreateUnit(int teamId, int playerId, string unitType, float x, float z, float dx = 0, float dz = 1)
Description
Creates a unit at the specified location using default facing.
Parameters
- int
teamId
which team to create the unit for. Use1
for local player and-1
for enemy. - int
playerId
which player to create the unit for. Use1
for local player and-1
for enemy. - string
unitType
name of data for the unit type to create - float
x
the x coordinate of where to create the unit. - float
z
the y coordinate of where to create the unit. - float
dx
a value between -1.0 and 1.0 that indicates the relative direction to face along the x-axis. - float
dz
a value between -1.0 and 1.0 that indicates the relative direction at to face along y-axis.
Example Usage
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, z = 16, 16
DCEI.CreateUnit(team_id, player_id, unit_type, x, z)
Related
void KillUnit(unit unit)
void KillUnit(unit unit)
Description
Parameters
- unit
unit
the unit to kill.
Example Usage
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
DCEI.KillUnit(unit)
Related
void RemoveUnit(unit unit)
void RemoveUnit(unit unit)
Description
Parameters
- unit
unit
the unit to remove.
Example Usage
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, z = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, z)
DCEI.RemoveUnit(unit)
Related
string GetUnitType(unit unit)
string GetUnitType(unit unit)
Description
Returns the unit name as a string.
Parameters
- unit
unit
the unit to get the name of.
Example Usage
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
local unit_type = DCEI.GetUnitType(unit)
-- prints "Standard MeleeUnit
DCEI.LogMessage(unit_name)
double GetUnitTypeHealth(string unitType)
double GetUnitTypeHealth(string unitType)
Description
Returns the maximum health for a unit type.
Parameters
- string
unitType
the unit type to get the health of.
Example Usage
local unit_type = DCEI.Unit("Standard MeleeUnit")
local health = DCEI.GetUnitTypeHealth(unit_type)
DCEI.LogMessage(health)
Related
string GetUnitDisplayName(unit unit)
string GetUnitDisplayName(unit unit)
Description
Returns the Display Name of a unit as a string.
Parameters
- unit
unit
the unit whose display name to get.
Example Usage
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
local display_name = DCEI.GetUnitDisplayName(unit)
DCEI.LogMessage(display_name)
Related
string GetUnitCategory(unit unit)
string GetUnitCategory(unit unit)
Description
Returns the unit category of a unit as a string (Unit, Missile, or Structure).
Parameters
- unit
unit
the unit whose unit category to get.
Example Usage
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
local unit_category = DCEI.GetUnitCategory(unit)
-- prints "Unit"
DCEI.LogMessage(unit_category)
void AttachSimpleUnitToCursor(unit unit)
void AttachSimpleUnitToCursor(unit unit)
Description
Added DCEI.AttachSimpleUnitToCursor(unit)
and DCEI.DetachSimpleUnitFromCursor
, only actor is attached, the unit stays where it was, when detach, the animator reappear at original position
Parameters
- unit
unit
the unit whose unit category to get.
Example Usage
In-development API
No documentation
void DetachSimpleUnitFromCursor(unit unit)
void DetachSimpleUnitFromCursor(unit unit)
Description
Added DCEI.AttachSimpleUnitToCursor(unit)
and DCEI.DetachSimpleUnitFromCursor
, only actor is attached, the unit stays where it was, when detach, the animator reappear at original position
Parameters
- unit
unit
the unit whose unit category to get.
Example Usage
In-development API
No documentation
void PlaySimpleUnitAnimationClip(unit unit, string clipName, string nextClipName)
void PlaySimpleUnitAnimationClip(unit unit, string clipName, string nextClipName)
Description
Plays an animation clip on a simple unit, then loops the next animation clip.
The following clip names are supported:
"cmd_remove" // reserved keyword, remove animator
"cmd_pause" // reserved keyword, stop playing animation
"attack"
"die"
"death"
"idle"
"walk"
"action"
"action1"
"build"
"select"
"close"
"open"
"flying"
"action2"
"hit"
"birth"
"action3"
"action4"
"action5"
"fidget"
"attack1"
"victory"
"jump_start"
"jump"
"jump_end"
"channeling_start"
"channeling"
"channeling_end"
"attack2"
"dodge"
"walk2"
"walk3"
"walk4"
"walk5"
"vfx_fadeout"
"sfx_loop"
Parameters
- unit
unit
the unit that will play an animation clip. - string
clipName
the clip name to play for the unit. - string
nextClipName
the clip name to loop after clipName finishes playing.
Example Usage
local simple_unit = DCEI.CreateSimpleUnit(2, {
max_health = 10,
type_name = DCEI.Unit("simple_unit_type"),
}, {
belongs_to_layer_mask = 2,
collides_with_layer_mask = 1,
radius = 0.2,
take_damage = false,
}, position.x, position.y, 1, 1, 0, 0)
DCEI.PlaySimpleUnitAnimationClip(
simple_unit, --unit
"attack", --clipName
"idle" --nextClipName
)
Related
void AttachUnit(unit childUnit, unit parentUnit, AttachOffsetOptions option)
void AttachUnit(unit childUnit, unit parentUnit, AttachOffsetOptions option)
Description
You can use AttachUnit to attach a "Simple" unit to a "Normal" unit. It's bridge for Simple/Complex units working together.
Parameters
- unit
childUnit
the child unit in attach. - unit
parentUnit
the parent unit in attach. - AttachOffsetOptions
option
options to customize how units attach.
Example Usage
local parent_unit = DCEI.FindUnit("Ship")
local child_unit = DCEI.FindUnit("Archer")
DCEI.AttachUnit(
child_unit,
parent_unit,
{ explicit_offset = { forward = 3 }, use_child_facing = true, orientation_type = "WorldOrientation" }
)
void DetachUnit(unit unit)
void DetachUnit(unit unit)
Description
If unit is attached to a parent unit, detach this unit from it's parent unit.
Parameters
- unit
unit
the unit to detach.
Example Usage
local child_unit = DCEI.FindUnit("Archer")
DCEI.DetachUnit(child_unit)
void Move(unit unit, float x, float z)
void Move(unit unit, float x, float z)
Description
Issues an order for a unit to move to a target point.
Parameters
- unit
unit
the unit instance to issue the move command to. - float
x
the x-axis coordinate to move towards. - float
z
the z-axis coordinate to move towards.
Example Usage
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
DCEI.TriggerAddUnitMoveCommandEvent(unit, OnUnitMoveCommand)
function OnUnitMoveCommand(destination)
local unit = DCEI.TriggeringUnit
local unit_name = DCEI.GetUnitType(unit)
local position = DCEI.GetUnitPosition2D(unit)
local message = string.format("%q is moving to (%.2f, %.2f) from (%.2f, %.2f).", unit_name, destination.x, destination.y, position.x, position.y)
DCEI.LogMessage(message)
end
DCEI.Move(unit, 15, 15)
Related
void Attack(unit unit, unit target)
void Attack(unit unit, unit target)
Description
Issues an order for a unit to attack another unit, causing it to move to get in range if necessary.
Parameters
- unit
unit
the attacking unit. - unit
target
the unit to attack.
Example Usage
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
local target = DCEI.CreateUnit(team_id, player_id, unit_type, x + 1, y + 1)
DCEI.Attack(unit, target)
Related
void DirectionalMove(unit target, float right, float up)
void DirectionalMove(unit target, float right, float up)
Description
Issues an order for the unit to move in a specified direction.
Notes: The unit will not attempt to navigate around units or obstacles when using Directional Move. This function only runs for a single frame. To have the unit continue to move in a specific direction, this function must be run each frame. This useful for games with that use WASD or joystick movement to control units.
Parameters
- unit
target
the unit to move. - float
right
a value between -1.0 and 1.0 that indicates the relative speed and direction to move along the x-axis. - float
up
a value between -1.0 and 1.0 that indicates the relative speed and direction to move along the y-axis.
Example Usage
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
function OnJoystickMove()
local axes = DCEI.TriggeringJoystickAxes
-- order unit to move in direction of joystick axes
DCEI.LogMessage("(" .. axes.x .. ", " .. axes.y .. ")")
DCEI.DirectionalMove(unit, axes.x, axes.y)
end
DCEI.TriggerAddJoystickEvent(OnJoystickMove)
Related
void TurnUnitTowards(unit unit, float dx, float dz, float duration = 0)
void TurnUnitTowards(unit unit, float dx, float dz, float duration = 0)
Description
Turns a unit to face towards a specified direction.
Parameters
- unit
unit
the unit to turn. - float
dx
a value between -1.0 and 1.0 that indicates the relative direction to face along the x-axis. - float
dz
a value between -1.0 and 1.0 that indicates the relative direction at to face along y-axis. - float
duration
duration of time the turning takes
Example Usage
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
-- Make the unit face southwest
DCEI.TurnUnitTowards(unit, -1.0,-1.0, 3.0)
Related
float GetHealth(unit unit)
float GetHealth(unit unit)
Description
Returns the current 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 = DCEI.Unit("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)
void AddHealth(unit unit, float value)
void AddHealth(unit unit, float value)
Description
Increases the current health of a unit.
Parameters
- unit
unit
the unit to add health to. - float
value
the amount of health to add.
Example Usage
DCEI.TriggerAddTimerEventElapsed(function()
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("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)
DCEI.LogMessage(unit_type .. " has " .. hp .. " hp currently.")
DCEI.AddHealth(unit, 10)
hp = DCEI.GetHealth(unit)
DCEI.LogMessage(unit_type .. " has " .. hp .. " hp currently.")
end,
0)
void SetHealth(unit unit, float value)
void SetHealth(unit unit, float value)
Description
Sets the current health of a unit.
Parameters
- unit
unit
the unit to set the health of. - float
value
the amount to set it to.
Example Usage
DCEI.TriggerAddTimerEventElapsed(function()
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("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)
void SetUnitOwner(unit unit, int playerId)
void SetUnitOwner(unit unit, int playerId)
Description
Parameters
- unit
unit
the unit to change ownership of. - int
playerId
the player to give the unit to.
Example Usage
function OnRegionEnter()
DCEI.SetUnitOwner(DCEI.TriggeringUnit, 2)
DCEI.LogMessage(DCEI.GetUnitPlayerId(DCEI.TriggeringUnit))
end
DCEI.TriggerAddUnitEnterRegionEvent(DCEI.CreateUnitFilter({name = DCEI.Unit("Test Unit")}), DCEI.RegionAny, OnRegionEnter)
void SetUnitTeamId(unit unit, int teamId)
void SetUnitTeamId(unit unit, int teamId)
Description
Parameters
- unit
unit
the unit to change ownership of. - int
teamId
the team ID to assign to the unit.
Example Usage
function OnRegionEnter()
DCEI.SetUnitTeamId(DCEI.TriggeringUnit, 2)
DCEI.LogMessage(DCEI.UnitTeamId(DCEI.TriggeringUnit))
end
DCEI.TriggerAddUnitEnterRegionEvent(DCEI.CreateUnitFilter({name = DCEI.Unit("Test Unit")}), DCEI.RegionAny, OnRegionEnter)
float GetMana(unit unit)
float GetMana(unit unit)
Description
Returns the current 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 = DCEI.Unit("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(unit, 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)
void AddMana(unit unit, float value)
void AddMana(unit unit, float value)
Description
Increases the current mana of a unit.
Parameters
- unit
unit
the unit to add mana to. - float
value
the amount to add.
Example Usage
DCEI.TriggerAddTimerEventElapsed(function()
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("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(unit, 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)
void SetMana(unit unit, float value)
void SetMana(unit unit, float value)
Description
Sets the current mana of a unit.
Parameters
- unit
unit
the unit to add mana to. - float
value
the amount to set it to.
Example Usage
DCEI.TriggerAddTimerEventElapsed(function()
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("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(unit, 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)
Float2 GetUnitFacing2D(unit unit)
Float2 GetUnitFacing2D(unit unit)
Description
Returns the facing of a unit as a vector with X and Y coordinates.
Parameters
- unit
unit
the unit to get the position of.
Example Usage
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
local facing = DCEI.GetUnitFacing2D(unit)
DCEI.LogMessage(unit_type .. " is facing " .. facing.x .. ", " .. facing.y)
Related
float GetUnitBounty(unit unit)
float GetUnitBounty(unit unit)
Description
Returns the SetGoldBounty of a unit.
Parameters
- unit
unit
the unit to get the bounty of.
Example Usage
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("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
object GetUnitBehaviorList(unit unit)
object GetUnitBehaviorList(unit unit)
Description
Returns a list of behaviors on a unit along with their stack count.
Parameters
- unit
unit
the unit to get the list of behaviors from.
Example Usage
local behaviors = DCEI.GetUnitBehaviorList(unit)
for _, behavior in ipairs(behaviors) do
DCEI.LogMessage(behavior.name .. ": " .. behavior.stack_count)
end
object GetUnitWeaponList(unit unit)
object GetUnitWeaponList(unit unit)
Description
Returns a list of weapons on a unit.
Parameters
- unit
unit
the unit to get the list of weapons from.
Example Usage
local weapons = DCEI.GetUnitWeaponList(unit)
for _, weapon in ipairs(weapons) do
DCEI.LogMessage(weapon)
end
Related
object GetUnitAbilityList(unit unit)
object GetUnitAbilityList(unit unit)
Description
Returns a list of abilities on a unit.
Parameters
- unit
unit
the unit to get the list of abilities from.
Example Usage
local abilities = DCEI.GetUnitAbilityList(unit)
for _, ability in ipairs(abilities) do
DCEI.LogMessage(ability)
end
void ApplyTag(unit unit, string tagName, float duration, int stackCount)
void ApplyTag(unit unit, string tagName, float duration, int stackCount)
Description
Applies a set number of tags to a unit for a set duration.
Parameters
- unit
unit
the unit to apply the tags to. - string
tagName
the name of the tag to apply. - float
duration
the length of time to apply the tag for. A value of-1
applies it permanently. - int
stackCount
the number of tags to apply.
Example Usage
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
local tag = DCEI.Tag("Banana")
DCEI.ApplyTag(unit, tag, -1, 5)
local tag_count = DCEI.GetUnitTagCount(unit, tag)
DCEI.LogMessage(tag_count)
DCEI.RemoveTag(unit, tag, 2)
tag_count = DCEI.GetUnitTagCount(unit, tag)
DCEI.LogMessage(tag_count)
void RemoveTag(unit unit, string tagName, int stackCount = 0)
void RemoveTag(unit unit, string tagName, int stackCount = 0)
Description
Removes a set number of tags from a unit.
Parameters
- unit
unit
the unit to remove the tags from. - string
tagName
the name of the tag to remove. - int
stackCount
the number of tags to remove.
Example Usage
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
local tag = DCEI.Tag("Banana")
DCEI.ApplyTag(unit, tag, -1, 5)
local tag_count = DCEI.GetUnitTagCount(unit, tag)
DCEI.LogMessage(tag_count)
DCEI.RemoveTag(unit, tag, 2)
tag_count = DCEI.GetUnitTagCount(unit, tag)
DCEI.LogMessage(tag_count)
int GetUnitTagCount(unit unit, string tagName)
int GetUnitTagCount(unit unit, string tagName)
Description
Returns the tag count of a given tag on a unit.
Parameters
- unit
unit
the unit to count the tags on. - string
tagName
the name of the tag to count.
Example Usage
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
local tag = DCEI.Tag("Banana")
DCEI.ApplyTag(unit, tag, -1, 5)
local tag_count = DCEI.GetUnitTagCount(unit, tag)
DCEI.LogMessage(tag_count)
DCEI.RemoveTag(unit, tag, 2)
tag_count = DCEI.GetUnitTagCount(unit, tag)
DCEI.LogMessage(tag_count)
object GetUnitTagList(unit unit)
object GetUnitTagList(unit unit)
Description
Returns a list of tags on a unit
Parameters
- unit
unit
the unit to get the total damage of.
Example Usage
local tags = DCEI.GetUnitTagList(unit)
for _, tag in ipairs(tags) do
DCEI.LogMessage(tag)
end
float GetUnitTotalDamage(unit 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 = DCEI.Unit("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)
Float2 GetUnitPosition2D(unit 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 = DCEI.Unit("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 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 = DCEI.Unit("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 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 = DCEI.Unit("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 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 = DCEI.Unit("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 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 = DCEI.Unit("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 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 = DCEI.Unit("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 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 = DCEI.Unit("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 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 = DCEI.Unit("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 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
target
unit to issue the attack-move command 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 = DCEI.Unit("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 UnitExists(unit unit)
Description
Returns true if a units exists.
Parameters
- unit
unit
the unit to check.
Example Usage
local status = false
DCEI.LogMessage(status)
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
status = DCEI.UnitExists(unit) -- true
DCEI.LogMessage(status)
Related
bool SimpleUnitExists(unit unit)
bool SimpleUnitExists(unit unit)
Description
Returns true if a simple unit exists.
Parameters
- unit
unit
the simple unit to check.
Example Usage
local unit = DCEI.CreateSimpleUnitSync(simple_unit_type, {
player_id = -1,
team_id = -1,
position = { x = 15, y = 0, z = 15 },
facing = { x = 0, y = 0 },
velocity = { x = 1, y = 0, z = 1 },
move_target_unit = nil,
move_target_position = nil,
move_target_direction = nil,
})
local exists = DCEI.SimpleUnitExists(unit)
DCEI.LogMessage(tostring(exists))
bool UnitIsAlive(unit 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 = DCEI.Unit("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 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 = DCEI.Unit("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 EnableUnitSelection(unit target)
Description
Parameters
- unit
target
the unit to enable selection on.
Example Usage
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("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 DisableUnitSelection(unit target)
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 = DCEI.Unit("Standard MeleeUnit")
local x, z = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, z)
DCEI.DisableUnitSelection(unit)
void ShowUnitCustomHealthBar(unit unit, bool show)
void ShowUnitCustomHealthBar(unit unit, bool show)
Description
Enable or disable displaying a unit's custom health bar, defined in the unit's data.
Parameters
- unit
unit
the unit to enable/disable custom health bar. - bool
show
if true, displays the unit's custom health bar; if false, disables the unit's custom health bar.
Example Usage
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, z = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, z)
DCEI.ShowUnitCustomHealthBar(unit)
void ConfigStatusBar(Float3 OffsetInStatusDisplay, Float3 DistanceBetweenIcons, int MaxDisplayCount = 3)
void ConfigStatusBar(Float3 OffsetInStatusDisplay, Float3 DistanceBetweenIcons, int MaxDisplayCount = 3)
Description
Set global configuration for unit status bar for display of status icons, with an offset, a distance between icons, and a max display count. The status bar will display the highest priority status icons up to the maximum count.
Parameters
- Float3
OffsetInStatusDisplay
offset in world space from a host unit as a table of x,y,z values. - Float3
DistanceBetweenIcons
distance between status icons in world space as a table of x,y,z values. - int
MaxDisplayCount
the maximum number of status icons that will be displayed on a host unit. Default value is 3.
Example Usage
offset = {x = 0, y = 0, z = 20}
distance = {x = 5, y = 1, z = 0}
max_count = 4
DCEI.ConfigStatusBar(offset, distance, max_count)
void RegisterBehaviorStatusIcon(string behaviorName, string actorName, int priority = 0)
void RegisterBehaviorStatusIcon(string behaviorName, string actorName, int priority = 0)
Description
Define a behavior for display in the status bar, with a behavior, status icon sprite actor, and a display priority.
Parameters
- string
behaviorName
the name of the behavior to register. - string
actorName
the actor type that contains the status sprite. - int
priority
the display priority for the status icon. Default value is 0.
Example Usage
offset = {x = 0, y = 0, z = 20}
distance = {x = 5, y = 1, z = 0}
max_count = 4
DCEI.ConfigStatusBar(offset, distance, max_count)
behavior = DCEI.Behavior("Test Behavior")
actor = DCEI.Actor("Test Behavior")
priority = 10
DCEI.RegisterBehaviorStatusIcon(behavior, actor, priority)
float GetMaxShield(unit 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 = DCEI.Unit("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 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 = DCEI.Unit("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 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 = DCEI.Unit("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 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
value
amount of shields to add.
Example Usage
DCEI.TriggerAddTimerEventElapsed(function()
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("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 SetShield(unit unit, float value)
Description
Set the current shields of a unit to 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 = DCEI.Unit("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 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 = DCEI.Unit("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 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 = DCEI.Unit("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 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 = DCEI.Unit("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 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 = DCEI.Unit("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 SetGoldBounty(unit unit, float amount)
Description
Sets the SetGoldBounty 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 = DCEI.Unit("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 FollowUnit(unit unit, unit targetUnit, float offsetX, float offsetY, float distanceMax)
void FollowUnit(unit unit, unit targetUnit, float offsetX, float offsetY, float distanceMax)
Description
Commands a unit to follow another unit.
Parameters
- unit
unit
the unit to command. - unit
targetUnit
the unit to follow. - float
offsetX
x offset from the target unit. - float
offsetY
y offset from the target unit. - float
distanceMax
if the distance between the units becomes larger than this, the follower unit will move towards the target unit, using the given offsets.
Example Usage
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 16, 16
local target = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
DCEI.FollowUnit(unit, target, 1.0, 1.0, 2.0)
DCEI.Move(target, 10, 10)
void FollowUnitWithOffset(unit unit, unit targetUnit, float offset)
void FollowUnitWithOffset(unit unit, unit targetUnit, float offset)
Description
Commands a unit to follow another unit.
Parameters
- unit
unit
the unit to command. - unit
targetUnit
the unit to follow. - float
offset
offset distance from the target unit.
Example Usage
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 16, 16
local target = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
DCEI.FollowUnit(unit, target, 2.0)
DCEI.Move(target, 10, 10)
void ClearFollowUnit(unit unit)
void ClearFollowUnit(unit unit)
Description
Clears the order for a unit to follow another unit.
Parameters
- unit
unit
the unit to command.
Example Usage
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
local target = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
DCEI.FollowUnit(unit, target, 1.0, 1.0, 2.0)
DCEI.Move(target, 10, 10)
DCEI.TriggerAddTimerEventElapsed(function()
DCEI.ClearFollowUnit(unit)
end, 2.0, false, true)
void SelectUnit(unit unit)
void SelectUnit(unit unit)
Description
Selects a unit for the player.
Parameters
- unit
unit
the unit to select.
Example Usage
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, z = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, z)
DCEI.SelectUnit(unit)
if DCEI.IsUnitSelected then
DCEI.LogMessage(unit_type .. " is selected.")
end
DCEI.TriggerAddTimerEventElapsed(function()
DCEI.Deselect(unit)
end, 2.0, false, true)
if DCEI.IsUnitSelected then
DCEI.LogMessage(unit_type .. " is selected.")
else
DCEI.LogMessage(unit_type .. " is not selected.")
end
Related
void DeselectUnit(unit unit)
void DeselectUnit(unit unit)
Description
Parameters
- unit
unit
the unit to deselect.
Example Usage
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, z = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, z)
DCEI.SelectUnit(unit)
if DCEI.IsUnitSelected then
DCEI.LogMessage(unit_type .. " is selected.")
end
DCEI.TriggerAddTimerEventElapsed(function()
DCEI.Deselect(unit)
end, 2.0, false, true)
if DCEI.IsUnitSelected then
DCEI.LogMessage(unit_type .. " is selected.")
else
DCEI.LogMessage(unit_type .. " is not selected.")
end
Related
unit FindUnit(string name)
unit FindUnit(string name)
Description
Attempts to return an existing unit from its name.
Parameters
- string
name
the name of the unit type to find.
Example Usage
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 12, 12
local unit = {}
local i
for i = 1, 5 do
unit[i] = DCEI.CreateUnit(i, i % 2, unit_type, x+i, y+i)
DCEI.SetHealth(unit[i], i)
end
local test_subject = DCEI.FindUnit(unit_type)
local hp = DCEI.GetHealth(test_subject)
DCEI.LogMessage(unit_type .. " has " .. hp .. " hp currently.")
DCEI.SetUnitPosition2D(test_subject,14,10)
test_subject = DCEI.FindUnitAtPosition(unit_type, 14,14)
DCEI.LogMessage(DCEI.GetUnitType(test_subject) .. " owned by player " .. DCEI.GetUnitPlayerId(test_subject) .. " is at " .. DCEI.GetUnitPosition2D(test_subject).x .. ", " .. DCEI.GetUnitPosition2D(test_subject).y .. " currently.")
Related
object FindUnitsByPlayerId(int playerId)
object FindUnitsByPlayerId(int playerId)
Description
Returns a list of all units owned by a player.
Parameters
- int
playerId
the player id to search for units by.
Example Usage
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 12, 12
local unit = {}
local i
for i = 1, 5 do
unit[i] = DCEI.CreateUnit(i, i % 2, unit_type, x+i, y+i)
DCEI.SetHealth(unit[i], i)
end
local group = DCEI.FindUnitsByPlayerId(1)
for _, unit in ipairs(group) do
DCEI.LogMessage(DCEI.GetUnitType(unit) .. " owned by player " .. DCEI.GetUnitPlayerId(unit) .. " is at " .. DCEI.GetUnitPosition2D(unit).x .. ", " .. DCEI.GetUnitPosition2D(unit).y .. " currently.")
end
Related
object FindUnitsByTeamId(int teamId)
object FindUnitsByTeamId(int teamId)
Description
Returns a list of all units that belong to the specified team.
Parameters
- int
teamId
the team id to search for units by.
Example Usage
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 12, 12
local unit = {}
local i
for i = 1, 5 do
unit[i] = DCEI.CreateUnit(i, i % 2, unit_type, x+i, y+i)
DCEI.SetHealth(unit[i], i)
end
local group = DCEI.FindUnitsByTeamId(1)
for _, unit in ipairs(group) do
DCEI.LogMessage(DCEI.GetUnitType(unit) .. " owned by player " .. DCEI.GetUnitPlayerId(unit) .. " is at " .. DCEI.GetUnitPosition2D(unit).x .. ", " .. DCEI.GetUnitPosition2D(unit).y .. " currently.")
end
Related
object FindUnits(string name)
object FindUnits(string name)
Description
Returns a list of all units with the specified unit name.
Parameters
- string
name
the name of the unit type to find.
Example Usage
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 12, 12
local unit = {}
local i
for i = 1, 5 do
unit[i] = DCEI.CreateUnit(i, i % 2, unit_type, x+i, y+i)
DCEI.SetHealth(unit[i], i)
end
local group = DCEI.FindUnits(unit_type)
for _, unit in ipairs(group) do
DCEI.LogMessage(DCEI.GetUnitType(unit) .. " owned by player " .. DCEI.GetUnitPlayerId(unit) .. " is at " .. DCEI.GetUnitPosition2D(unit).x .. ", " .. DCEI.GetUnitPosition2D(unit).y .. " currently.")
end
Related
unit FindUnitAtPosition(string name, float x, float z)
unit FindUnitAtPosition(string name, float x, float z)
Description
Returns the unit with the given name closest to the given coordinates.
Parameters
- string
name
the name of the unit type to find. - float
x
the x-coordinate of the point to search for the unit at. - float
z
the y-coordinate of the point to search for the unit at.
Example Usage
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, z = 12, 12
local unit = {}
local i
for i = 1, 5 do
unit[i] = DCEI.CreateUnit(i, i % 2, unit_type, x + i, y + i)
DCEI.SetHealth(unit[i], i)
end
local test_subject = DCEI.FindUnit(unit_type)
local hp = DCEI.GetHealth(test_subject)
DCEI.LogMessage(unit_type .. " has " .. hp .. " hp currently.")
DCEI.SetUnitPosition2D(test_subject, 14, 10)
test_subject = DCEI.FindUnitAtPosition(unit_type, 14, 14)
DCEI.LogMessage(DCEI.GetUnitType(test_subject) .. " owned by player " .. DCEI.GetUnitPlayerId(test_subject) .. " is at " .. DCEI.GetUnitPosition2D(test_subject).x .. ", " .. DCEI.GetUnitPosition2D(test_subject).y .. " currently.")
Related
bool IsUnitSelected(unit unit)
bool IsUnitSelected(unit unit)
Description
Returns true if the unit is selected.
Parameters
- unit
unit
the unit to check.
Example Usage
local team_id = 1
local player_id = 1
local unit_type = DCEI.Unit("Standard MeleeUnit")
local x, y = 16, 16
local unit = DCEI.CreateUnit(team_id, player_id, unit_type, x, y)
DCEI.SelectUnit(unit)
if DCEI.IsUnitSelected then
DCEI.LogMessage(unit_type .. " is selected.")
end
DCEI.TriggerAddTimerEventElapsed(function()
DCEI.Deselect(unit)
end, 2.0, false, true)
if DCEI.IsUnitSelected then
DCEI.LogMessage(unit_type .. " is selected.")
else
DCEI.LogMessage(unit_type .. " is not selected.")
end