Trigger API Reference\DCEI Functions\Unit

string DefaultHero()

string DefaultHero()

Description


Wild Sky only. Returns the default hero.

Example Usage

    local hero_names = {}
    table.insert(hero_names, DCEI.DefaultHero())
    for _, hero in ipairs(DCEI.ExtraHeros()) do
        table.insert(hero_names, hero)
    end

object ExtraHeros()

object ExtraHeros()

Description


Wild Sky only. Returns other heroes players have equipped.

Example Usage

    local hero_names = {}
    table.insert(hero_names, DCEI.DefaultHero())
    for _, hero in ipairs(DCEI.ExtraHeros()) do
        table.insert(hero_names, hero)
    end

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

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

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)

float GetPlayerStats(int playerId, string statsName)

float GetPlayerStats(int playerId, string statsName)

Description


This is used in conjunction with simple units to improve performance. Ordinary methods of getting damaged dealt or tracking XP are not performant enough or don't work with simple units. For more info about simple units, see Simple Units Guide.

Parameters

Example Usage

-- Get XP for player
local experience = DCEI.GetPlayerStats(1, 1)

void ResetPlayerStats()

void ResetPlayerStats()

Description


Resets the stats tracking from DCEI.GetPlayerStats

Example Usage

-- Rests XP, damage, kill simple stats
DCEI.ResetPlayerStats()

void SetUnitMass(unit unit, float massValue)

void SetUnitMass(unit unit, float massValue)

Description


Set a unit's mass. This affects how units behave whrn Simple Force is applied. Bigger mass value means higher inertia. Units that don't have mass se default to 1 mass.

Parameters

Example Usage

local new_simple_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,
})

DCEI.SetUnitMass(new_simple_unit, 2)

void SetUnitSimpleTag(unit unit, SimpleTagOptions options)

void SetUnitSimpleTag(unit unit, SimpleTagOptions options)

Description

Parameters

Example Usage

void SetSimpleHealthData(unit unit, SimpleHealthOptions options)

void SetSimpleHealthData(unit unit, SimpleHealthOptions options)

Description


Set Simple Health Component for simple or normal unit. For more info about simple units, see Simple Units Guide.

Parameters

Example Usage

local new_simple_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,
})

DCEI.SetSimpleHealthData(new_simple_unit, {max = 10, value = 10})

void SetSimpleUnitMoveTargetUnit(unit unit, unit targetUnit)

void SetSimpleUnitMoveTargetUnit(unit unit, unit targetUnit)

Description


Set a given simple unit to move to the target unit. For more info about simple units, see Simple Units Guide.

Parameters

Example Usage

function Spawner:SpawnHostile(unit_properties, position, rotation, velocity, target)
    local unit = DCEI.CreateSimpleUnit(
        PLAYERS.Hostile,
        unit_properties.Unit,
        unit_properties.Collider,
        position.x,
        position.y,
        rotation.x,
        rotation.y,
        velocity.x,
        velocity.y
    )

    DCEI.SetSimpleUnitMoveTargetUnit(unit, target)
    return unit
end

void SetSimpleUnitMoveTargetWorldPosition2D(unit unit, float x, float y)

void SetSimpleUnitMoveTargetWorldPosition2D(unit unit, float x, float y)

Description


Set Simple Unit Move Target Location. For more info about simple units, see Simple Units Guide.

Parameters

Example Usage

function Spawner:SpawnHostile(unit_properties, position, rotation, velocity, target_pos)
    local unit = DCEI.CreateSimpleUnit(
        PLAYERS.Hostile,
        unit_properties.Unit,
        unit_properties.Collider,
        position.x,
        position.y,
        rotation.x,
        rotation.y,
        velocity.x,
        velocity.y
    )

    DCEI.SetSimpleUnitMoveTargetWorldPosition2D(unit, target_pos.x, target_pos.y)
    return unit
end

void SetSimpleUnitMoveTargetDirection(unit unit, float dx, float dy)

void SetSimpleUnitMoveTargetDirection(unit unit, float dx, float dy)

Description


Set simple unit move target direction. For more info about simple units, see Simple Units Guide.

Parameters

Example Usage

function Spawner:SpawnHostile(unit_properties, position, rotation, velocity)
    local unit = DCEI.CreateSimpleUnit(
        PLAYERS.Hostile,
        unit_properties.Unit,
        unit_properties.Collider,
        position.x,
        position.y,
        rotation.x,
        rotation.y,
        velocity.x,
        velocity.y
    )

    DCEI.SetSimpleUnitMoveTargetDirection(unit, move_vector.x, move_vector.y)
    return unit
end

void SetSimpleUnitTeamId(unit unit, int teamId)

void SetSimpleUnitTeamId(unit unit, int teamId)

Description


Set the team ID for an existing simple unit.

Parameters

Example Usage

function Units.Spawn.Hostile(hostile_data, position, facing, velocity, life)
    local unit_data = {
        Collider = {
            belongs_to_layer_mask = 1,
            collides_with_layer_mask = 3,
            take_damage = false,
            radius = 3,
        },
        Unit = {
            type_name = DCEI.Unit("Collector"),
            max_health = 1,
        },
    }
    local position = {x = 15, y = 15}
    local facing_down = {x = 0, y = -1}
    local still_velocity = {x = 0, y = 0}
    local unit = DCEI.CreateSimpleUnit(
        1,
        unit_data.Unit,
        unit_data.Collider,
        position.x,
        position.y,
        facing_down.x,
        facing_down.y,
        still_velocity.x,
        still_velocity.y
    )
    DCEI.SetSimpleUnitTeamId(unit, TEAMS.Hostile)

    return unit
end

void RegisterSimpleAnimationSequence(int id, SimpleAnimationSequence sequence)

void RegisterSimpleAnimationSequence(int id, SimpleAnimationSequence sequence)

Description

Parameters

Example Usage

void ApplyTransformAnimationToSimpleUnit(unit unit, SimpleUnitTransformAnimationOptions options)

void ApplyTransformAnimationToSimpleUnit(unit unit, SimpleUnitTransformAnimationOptions options)

Description


Applies a simple transformation animation to a simple unit.

Parameters

Example Usage

local unit_data = {
    Collider = {
        belongs_to_layer_mask = 1,
        collides_with_layer_mask = 3,
        take_damage = false,
        radius = 3,
    },
    Unit = {
        type_name = DCEI.Unit("Archer"),
    },
}

local position = { x = 18, y = 18 }
local facing_down = { x = 0, y = -1 }
local still_velocity = { x = 0, y = 0 }
local new_simple_unit = DCEI.CreateSimpleUnit(
    1,
    unit_data.Unit,
    unit_data.Collider,
    position.x,
    position.y,
    facing_down.x,
    facing_down.y,
    still_velocity.x,
    still_velocity.y
)

local simple_animation_transformation_option = {
    start_scale = { x = 0, y = 0, z = 0 },
    random_position_offset = { x = 0, y = 0, z = 0 },
    end_scale = { x = 1, y = 1, z = 1 },
    end_position = { x = 0, y = 0, z = 0 },
    end_degree = 360,
    pivot = { x = 0, y = 0 },
    start_seconds = 0,
    end_seconds = 1,
}

DCEI.ApplyTransformAnimationToSimpleUnit(new_simple_unit, simple_animation_transformation_option)

void ApplyTintColorAnimationToSimpleUnit(unit unit, SimpleUnitTintColorAnimationOptions options)

void ApplyTintColorAnimationToSimpleUnit(unit unit, SimpleUnitTintColorAnimationOptions options)

Description


Applies a simple tint animation to a simple unit.

Parameters

Example Usage

function AnimateSimpleUnit()
    local unit_data = {
        Collider = {
            belongs_to_layer_mask = 1,
            collides_with_layer_mask = 3,
            take_damage = false,
            radius = 3,
        },
        Unit = {
            type_name = DCEI.Unit("Collector"),
            max_health = 1,
        },
    }
    local position = {x = 15, y = 15}
    local facing_down = {x = 0, y = -1}
    local still_velocity = {x = 0, y = 0}
    local unit = DCEI.CreateSimpleUnit(
        1,
        unit_data.Unit,
        unit_data.Collider,
        position.x,
        position.y,
        facing_down.x,
        facing_down.y,
        still_velocity.x,
        still_velocity.y
    )
    DCEI.ApplyTintColorAnimationToSimpleUnit(unit, {            
        start_tint_color = { x = 0, y = 0, z = 0},
        end_tint_color = { x = 1, y = 1, z = 1},
        start_alpha = 1,
        end_alpha = 1,
        start_seconds = 1,
        end_seconds = 4
    })

    return unit
end

void ClearTintColorAnimationToSimpleUnit(unit unit)

void ClearTintColorAnimationToSimpleUnit(unit unit)

Description


Clears a simple tint animation from a simple unit.

Parameters

Example Usage

function AnimateSimpleUnit()
    local unit_data = {
        Collider = {
            belongs_to_layer_mask = 1,
            collides_with_layer_mask = 3,
            take_damage = false,
            radius = 3,
        },
        Unit = {
            type_name = DCEI.Unit("Collector"),
            max_health = 1,
        },
    }
    local position = {x = 15, y = 15}
    local facing_down = {x = 0, y = -1}
    local still_velocity = {x = 0, y = 0}
    local unit = DCEI.CreateSimpleUnit(
        1,
        unit_data.Unit,
        unit_data.Collider,
        position.x,
        position.y,
        facing_down.x,
        facing_down.y,
        still_velocity.x,
        still_velocity.y
    )
    DCEI.ApplyTintColorAnimationToSimpleUnit(unit, {            
        start_tint_color = { x = 0, y = 0, z = 0},
        end_tint_color = { x = 1, y = 1, z = 1},
        start_alpha = 1,
        end_alpha = 1,
        start_seconds = 1,
        end_seconds = 4
    })

    DCEI.Wait(2)
    -- This interrupts the tint color animation after 2 seconds and clears it.
    DCEI.ClearTintColorAnimationToSimpleUnit(unit)

    return unit
end

void AddKillTimerToSimpleUnit(unit unit, float seconds)

void AddKillTimerToSimpleUnit(unit unit, float seconds)

Description


Kill simple unit after some time.

Parameters

Example Usage

function TemporarySimpleUnit()
    local unit_data = {
        Collider = {
            belongs_to_layer_mask = 1,
            collides_with_layer_mask = 3,
            take_damage = false,
            radius = 3,
        },
        Unit = {
            type_name = DCEI.Unit("Collector"),
            max_health = 1,
        },
    }
    local position = {x = 15, y = 15}
    local facing_down = {x = 0, y = -1}
    local still_velocity = {x = 0, y = 0}
    local unit = DCEI.CreateSimpleUnit(
        1,
        unit_data.Unit,
        unit_data.Collider,
        position.x,
        position.y,
        facing_down.x,
        facing_down.y,
        still_velocity.x,
        still_velocity.y
    )
    DCEI.AddKillTimerToSimpleUnit(unit, 15)

    return unit
end

void AddRemoveTimerToSimpleUnit(unit unit, float seconds)

void AddRemoveTimerToSimpleUnit(unit unit, float seconds)

Description


Remove simple unit after some time.

Parameters

Example Usage

function TemporarySimpleUnit()
    local unit_data = {
        Collider = {
            belongs_to_layer_mask = 1,
            collides_with_layer_mask = 3,
            take_damage = false,
            radius = 3,
        },
        Unit = {
            type_name = DCEI.Unit("Collector"),
            max_health = 1,
        },
    }
    local position = {x = 15, y = 15}
    local facing_down = {x = 0, y = -1}
    local still_velocity = {x = 0, y = 0}
    local unit = DCEI.CreateSimpleUnit(
        1,
        unit_data.Unit,
        unit_data.Collider,
        position.x,
        position.y,
        facing_down.x,
        facing_down.y,
        still_velocity.x,
        still_velocity.y
    )
    DCEI.AddRemoveTimerToSimpleUnit(unit, 15)

    return unit
end

void ApplySimpleMoverTargetUnit(unit unit, unit target, float speed, float accelerationMagnitude, float startSeconds, float endSeconds)

void ApplySimpleMoverTargetUnit(unit unit, unit target, float speed, float accelerationMagnitude, float startSeconds, float endSeconds)

Description


Applies a simple mover to a simple unit which moves it toward a target unit.

Parameters

Example Usage

    local target_unit = DCEI.CreateUnit(-1, -1, DCEI.Unit("MyUnit"), 15, 15)

    local missile_simple_unit = DCEI.CreateSimpleUnit(2, {
        max_health = 10,
        type_name = DCEI.Unit("simple_missile_type"),
    }, {
        belongs_to_layer_mask = 2,
        collides_with_layer_mask = 1,
        radius = 0.2,
        take_damage = false,
    }, caster_position.x, caster_position.y, 1, 1, 0, 0)

    DCEI.ApplySimpleMoverTargetUnit(
        missile_simple_unit, --unit
        target_unit, --target
        15, --speed
        5, --accelerationMagnitude
        0, --startSeconds
        1.0625 --endSeconds
    )

void ApplySimpleMoverUniformAcceleration(unit unit, float velocityX, float velocityY, float accelerationX, float accelerationY, float startSeconds, float endSeconds)

void ApplySimpleMoverUniformAcceleration(unit unit, float velocityX, float velocityY, float accelerationX, float accelerationY, float startSeconds, float endSeconds)

Description


Applies a simple mover to a simple unit.

Parameters

Example Usage

    local missile_simple_unit = DCEI.CreateSimpleUnit(2, {
        max_health = 10,
        type_name = DCEI.Unit("simple_missile_type"),
    }, {
        belongs_to_layer_mask = 2,
        collides_with_layer_mask = 1,
        radius = 0.2,
        take_damage = false,
    }, caster_position.x, caster_position.y, 1, 1, 0, 0)

    local distance = Util.VectorMinus(target_position, caster_position)

    DCEI.ApplySimpleMoverUniformAcceleration(
        missile_simple_unit, --unit
        0, --velocityX
        distance.y, --velocityY
        0, --accelerationX
        0, --accelerationY
        0, --startSeconds
        1.0625 --endSeconds
    )

void ApplySimpleMoverSineWave(unit unit, float amplitude, float periodSeconds, float startSeconds, float endSeconds)

void ApplySimpleMoverSineWave(unit unit, float amplitude, float periodSeconds, float startSeconds, float endSeconds)

Description


Applies a sine simple mover to a simple unit.

Parameters

Example Usage

    local target_unit = DCEI.CreateUnit(-1, -1, DCEI.Unit("MyUnit"), 15, 15)

    local missile_simple_unit = DCEI.CreateSimpleUnit(2, {
        max_health = 10,
        type_name = DCEI.Unit("simple_missile_type"),
    }, {
        belongs_to_layer_mask = 2,
        collides_with_layer_mask = 1,
        radius = 0.2,
        take_damage = false,
    }, caster_position.x, caster_position.y, 1, 1, 0, 0)

    DCEI.ApplySimpleMoverSineWave(
        missile_simple_unit, --unit
        5, --amplitude
        1, --periodSeconds
        0, --startSeconds
        1.0625 --endSeconds
    )

void ApplySimpleMoverTargetLocation(unit unit, Float3 targetLocation, float speed, float accelerationMagnitude, float startSeconds, float endSeconds)

void ApplySimpleMoverTargetLocation(unit unit, Float3 targetLocation, float speed, float accelerationMagnitude, float startSeconds, float endSeconds)

Description


Applies a simple mover to a simple unit which moves it toward a target location.

Parameters

Example Usage

    local target_location = {x = 0.0, y = 12.0, z = 0.5}

    local missile_simple_unit = DCEI.CreateSimpleUnit(2, {
        max_health = 10,
        type_name = DCEI.Unit("simple_missile_type"),
    }, {
        belongs_to_layer_mask = 2,
        collides_with_layer_mask = 1,
        radius = 0.2,
        take_damage = false,
    }, caster_position.x, caster_position.y, 1, 1, 0, 0)

    DCEI.ApplySimpleMoverTargetUnit(
        missile_simple_unit, --unit
        target_location, --targetLocation
        15, --speed
        5, --accelerationMagnitude
        0, --startSeconds
        1.0625 --endSeconds
    )

void SetCollisionDamageData(unit unit, CollisionDamageApplierOptions options)

void SetCollisionDamageData(unit unit, CollisionDamageApplierOptions options)

Description


Enable applying damage on collision for a given unit.

Parameters

Example Usage

DCEI.SetCollisionDamageData(self.unit, {
    timing = 1,
    cooldown = 5,
    deal_damage_value = 1,
})

void SetCollisionEffectTriggers(unit unit, SimpleUnitCastEffectOptions options)

void SetCollisionEffectTriggers(unit unit, SimpleUnitCastEffectOptions options)

Description


In development internal API.
No example usage yet

Parameters

Example Usage


In development internal API.
No example usage yet

void SetArmorData(unit unit, SimpleUnitArmorOptions options)

void SetArmorData(unit unit, SimpleUnitArmorOptions options)

Description


In development internal API.
No example usage yet

Parameters

Example Usage


In development internal API.
No example usage yet

void SetCollisionForceData(unit unit, CollisionForceApplierOptions options)

void SetCollisionForceData(unit unit, CollisionForceApplierOptions options)

Description


Enable applying force on collision for a given unit.

Parameters

Example Usage

DCEI.SetCollisionForceData(self.unit, {
    force = 10, -- Push Force (+)
    factor = -20, -- Change over Time
    duration = 0.5, -- Seconds
})

void SetCollisionStatsData(unit unit, CollisionStatsApplierOptions options)

void SetCollisionStatsData(unit unit, CollisionStatsApplierOptions options)

Description


Enable applying stats on collision for unit.

Experimental API: Not intended for wide use

Parameters

Example Usage

-- Placeholder example
DCEI.SetCollisionStatsData(unit, {stats_id = 1, delta_value = 15})

void SetCollisionMovementSpeedModifierData(unit unit, CollisionMovementSpeedModifierApplierOptions options)

void SetCollisionMovementSpeedModifierData(unit unit, CollisionMovementSpeedModifierApplierOptions options)

Description


Added API DCEI.SetCollisionMovementSpeedModifierData(Unit unit, CollisionMovementSpeedModifierApplierOptions options) and field collision_movement_speed_modifier_applier_options in SimpleUnitTypeOptions, field type is CollisionMovementSpeedModifierApplierOptions.
Once set, if it collides with other moving units, the defined movement speed modifier would be applied to them

CollisionMovementSpeedModifierApplierOptions:

BehaviorModifier modifier
float duration_seconds
CollisionTiming timing
float cooldown_seconds

Parameters

Example Usage

EXPERIMENTAL / IN-DEVELOPMENT / INTERNAL API
No official documentation. 

void SetSimpleUnitToDestroySelfOnCollision(unit unit)

void SetSimpleUnitToDestroySelfOnCollision(unit unit)

Description


Set simple unit to destroy self on collision. For more info about simple units, see Simple Units Guide.

Parameters

Example Usage

DCEI.SetSimpleUnitToDestroySelfOnCollision(unit)

void SetCollisionComponentData(unit unit, CollisionOptions options)

void SetCollisionComponentData(unit unit, CollisionOptions options)

Description


Enable collision for unit, with options

Parameters

Example Usage

-- Setup Collision Data
DCEI.SetCollisionComponentData(self.unit, {
    belongs_to_layer_mask = 1,
    collides_with_layer_mask = 3,
    take_damage = false,
    radius = 3,
})

void RegisterSimpleUnitType(string name, SimpleUnitTypeOptions options)

void RegisterSimpleUnitType(string name, SimpleUnitTypeOptions options)

Description


Register a simple unit type.

Parameters

Example Usage

function RegisterUnitType(unit_data, life, damage, speed, mass)
    local player_id = -1
    local team_id = -1
    local default_armor = 0
    local default_loot = 0
    local default_timing = 1 -- OnStart

    local meta_data = {
        type_name = DCEI.SimpleUnit("Hostile - Runner"), -- A Registered Simple Unit.
    }
    local health_data = {
        max = 6, -- The Maximum Health of the Unit.
        value = 6, -- The Current Health of the Unit.
    }
    local armor_data = {
        type = default_armor, -- Index for armor type.
    }
    local loot_data = {
        loot_id = default_loot, -- The Registered Loot Id to Drop.
        drop_rate = 0.5, -- The Chance [0 - 1] of dropping this Loot when the Unit is Killed.
    }
    local movement_data = {
        max_speed = 15, -- The Max Speed of the Unit.
        velocity = { x = 1, y = 0, z = 1 }, -- The Direction of Travel.
    }
    local local_avoidance_data = {
        enabled = false, -- Navigates around collisions.
    }
    local mover_data = {
        enabled = false,
    }
    local collision_data = {
        belongs_to_layer_mask = -1, -- The Layer of the Unit.
        collides_with_layer_mask = 1, -- The Layer the Unit can collide with.
        radius = 0.5, -- The Radius of the Unit.
    }
    local collision_damage_data = {
        timing = timing, -- The Timing (Start, Continue, Stop) that will trigger this response.
        deal_damage_value = 4, -- The amount of Damage to deal.
        cooldown = 8, -- The Delay (in Frames) before a target can be Damaged again.
    }
    local collision_force_data = {
        horizontal_force = 1.0,
        horizontal_friction = 0.1,
        vertical_force = 0.1,
        vertical_friction = 0.01,
        duration = 0.25,
        timing = default_timing,
        only_trigger_on_kill = false,
        cooldown_seconds = 0.25,
    }
    local collision_stats_data = {
        stats_name = "Spunk",
        delta_value = 1.0,
        timing = default_timing
    }
    local collision_movement_speed_modifier_applier_data = {
        modifier = {
            scaled = 0.0,
            unscaled = 1.0,
            additive_factor = 0.0,
            positive_unified_factor = 0.0,
            negative_unified_factor = 0.0,
            multiplier_factor = 0.0,
        },
        duration_seconds = 1.0,
        timing = default_timing,
        cooldown_seconds = 1.0,
    }
    local cast_effect_data = {
        collision_effects = {
            {
                timing = default_timing,
                effect_name = DCEI.Effect("Hostile - Runner Collide Effect"),
                cooldown_seconds = 1.0,
                tag_mask_filter = 0,
            },
        },
        on_death = DCEI.Effect("Hostile - Runner Death Effect"),
    }
    local tag_data = {
        value = 1,
    }
    local timer_data = {
        remove_unit_after_seconds = 10.0, -- Removes the Unit after a duration.
        kill_unit_after_seconds = 9.0, -- Kills the Unit after a duration.
    }
    local animator_data = {
        shadow_options = {
            enabled = true,
            shadow_radius = 0.5,
        },
        death_particle_effects = {1, 2, 3},
        animation_options = {
            enabled = true,
            frame_rate = 30.0,
        },
    }
    local options = {
        meta = meta_data,
        health_options = health_data,
        armor_options = armor_data,
        loot_options = loot_data,
        movement_options = movement_data,
        local_avoidance_options = local_avoidance_data,
        mover_options = mover_data,
        collision_options = collision_data,
        collision_damage_applier_options = collision_damage_data,
        collision_force_applier_options = collision_force_data,
        collision_stats_applier_options = collision_stats_data,
        collision_movement_speed_modifier_applier_options = collision_speed_data,
        cast_effect_options = cast_effect_data,
        tag_options = tag_data,
        timer_options = timer_data,
        mass = 2.0,
        animator_options = animator_data,
    }

    -- Register the simple unit type ...
    DCEI.RegisterSimpleUnitType(unit_data.Name, options)
    return unit_data.Name
end

void RegisterSimpleDamageAffinity(SimpleDamageAffinityOptions options)

void RegisterSimpleDamageAffinity(SimpleDamageAffinityOptions options)

Description


Register affinity to use with simple units.

Parameters

Example Usage

-- declare enum for damage types and armor types
local DamageTypes = {
    DEFAULT = 0,
    PHYSICAL = 1,
    MAGICAL = 2,
}

local ArmorTypes = {
    DEFAULT = 0,
    LIGHT = 1,
    MEDIUM = 2,
    HEAVY = 3,
}

-- register defender with ArmorTypes.HEAVY
DCEI.RegisterSimpleUnitType("StandardDummy", {
    meta = { type_name = DCEI.SimpleUnit("Standard MeleeUnit")},
    collision_options = {
        belongs_to_layer_mask = 1,
        collides_with_layer_mask = 2,
        radius = 0.2,
    },
    health_options = {
        max = 1000000000,
    },
    armor_options = {
        type = ArmorTypes.HEAVY,
    }
})

-- register damage affinities
DCEI.RegisterSimpleDamageAffinity({
    entries = {
        {
            damage_type = DamageTypes.MAGICAL,
            armor_type = ArmorTypes.HEAVY,
            damage_modifier = {
                additive_factor = 0.5,
            }
        },
        {
            damage_type = DamageTypes.PHYSICAL,
            armor_type = ArmorTypes.HEAVY,
            damage_modifier = {
                unscaled = -50,
            }
        }
    }
})

-- register missile with DamageTypes.PHYSICAL
DCEI.RegisterSimpleUnitType("StandardMissile", {
    meta = { type_name = DCEI.SimpleUnit("StandardMissile")},
    movement_options = { max_speed = 1 },
    collision_options = {
        belongs_to_layer_mask = 2,
        collides_with_layer_mask = 1,
        radius = 0.5,
    },
    collision_damage_applier_options = {
        timing = 1,
        deal_damage = {
            damage_type = DamageTypes.PHYSICAL,
            damage_value = 100,
            style_index = 0,
            critical_damage_chance = 0.1,
            critical_damage_multiplier = 10,
            critical_damage_style_index = 1,
            stats_name = example_stats,
        },
    },
})

void RegisterSimpleDamageNumberStyles(SimpleDamageNumberStyleOptions options)

void RegisterSimpleDamageNumberStyles(SimpleDamageNumberStyleOptions options)

Description


Register a simple damage number style. These text settings will be used when this style is used when calling DCEI.ShowSimpleDamageNumber

Parameters

Example Usage

local function RegisterSimpleDigitStyle()
    -- damage number style
    DCEI.RegisterSimpleDamageNumberStyles({
        font_type = 1,
        duration_seconds = 0.9,
        distance_between_digits = {
            x = 0.4,
            y = 0,
            z = 0,
        },
    })

    local x_y_ratio = 1
    local x_final = 0.5

    DCEI.AddTransformAnimationToSimpleDamageNumberStyle(1, {
        start_scale = { x = 0, y = 0, z = 0 },
        random_position_offset = { x = 0, y = 0, z = 0 },
        end_scale = { x = x_final * 1.2, y = x_final * x_y_ratio * 1.2, z = x_final * 1.2 },
        end_position = { x = 0, y = 0, z = 0 },
        end_degree = 0,
        pivot = { x = 0, y = 0 },
        start_seconds = 0,
        end_seconds = 0.25,
    })

    DCEI.AddTransformAnimationToSimpleDamageNumberStyle(1, {
        start_scale = { x = x_final * 1.2, y = x_final * x_y_ratio * 1.2, z = x_final * 1.2 },
        random_position_offset = { x = 0, y = 0, z = 0 },
        end_scale = { x = x_final * 0.9, y = x_final * x_y_ratio * 0.9, z = x_final * 0.9 },
        end_position = { x = 0, y = 0, z = 0 },
        end_degree = 0,
        pivot = { x = 0, y = 0 },
        start_seconds = 0.25,
        end_seconds = 0.375,
    })

    DCEI.AddTintColorAnimationToSimpleDamageNumberStyle(1, {
        start_alpha = 0.1,
        end_alpha = 1,
        start_tint_color = { x = 1, y = 1, z = 1 },
        end_tint_color = { x = 1, y = 1, z = 1 },
        start_seconds = 0,
        end_seconds = 0.25,
    })

    DCEI.AddTintColorAnimationToSimpleDamageNumberStyle(1, {
        start_alpha = 1,
        end_alpha = 1,
        start_tint_color = { x = 1, y = 1, z = 1 },
        end_tint_color = { x = 1, y = 1, z = 1 },
        start_seconds = 0.25,
        end_seconds = 0.75,
    })
end

local function OnUnitDamaged(damage, target_unit)
    DCEI.ShowSimpleDamageNumber(target_unit, 1, damage)
end

DCEI.TriggerAddUnitDamageEvent(DCEI.CreateUnitFilter({name = DCEI.Unit("Test Unit")}), OnUnitDamaged, {critical_only = true})

void SetDefaultSimpleDamageNumberStyle(SimpleDamageNumberStyleOptions options)

void SetDefaultSimpleDamageNumberStyle(SimpleDamageNumberStyleOptions options)

Description


Sets the default style for simple damage numbers.

Parameters

Example Usage

DCEI.SetDefaultSimpleDamageNumberStyle({
    font_type = 1,
    duration_seconds = 0.9,
    distance_between_digits = {
        x = 0.4,
        y = 0,
        z = 0,
    },
})

void AddTransformAnimationToSimpleDamageNumberStyle(int idx, SimpleUnitTransformAnimationOptions options)

void AddTransformAnimationToSimpleDamageNumberStyle(int idx, SimpleUnitTransformAnimationOptions options)

Description


Add a transform animation to an simple number style registered with DCEI.RegisterSimpleDamageNumberStyles

Parameters

Example Usage

local function RegisterSimpleDigitStyle()
    -- damage number style
    DCEI.RegisterSimpleDamageNumberStyles({
        font_type = 1,
        duration_seconds = 0.9,
        distance_between_digits = {
            x = 0.4,
            y = 0,
            z = 0,
        },
    })

    local x_y_ratio = 1
    local x_final = 0.5

    DCEI.AddTransformAnimationToSimpleDamageNumberStyle(1, {
        start_scale = { x = 0, y = 0, z = 0 },
        random_position_offset = { x = 0, y = 0, z = 0 },
        end_scale = { x = x_final * 1.2, y = x_final * x_y_ratio * 1.2, z = x_final * 1.2 },
        end_position = { x = 0, y = 0, z = 0 },
        end_degree = 0,
        pivot = { x = 0, y = 0 },
        start_seconds = 0,
        end_seconds = 0.25,
    })

    DCEI.AddTransformAnimationToSimpleDamageNumberStyle(1, {
        start_scale = { x = x_final * 1.2, y = x_final * x_y_ratio * 1.2, z = x_final * 1.2 },
        random_position_offset = { x = 0, y = 0, z = 0 },
        end_scale = { x = x_final * 0.9, y = x_final * x_y_ratio * 0.9, z = x_final * 0.9 },
        end_position = { x = 0, y = 0, z = 0 },
        end_degree = 0,
        pivot = { x = 0, y = 0 },
        start_seconds = 0.25,
        end_seconds = 0.375,
    })
end

local function OnUnitDamaged(damage, target_unit)
    DCEI.ShowSimpleDamageNumber(target_unit, 1, damage)
end

DCEI.TriggerAddUnitDamageEvent(DCEI.CreateUnitFilter({name = DCEI.Unit("Test Unit")}), OnUnitDamaged, {critical_only = true})

void AddTintColorAnimationToSimpleDamageNumberStyle(int idx, SimpleUnitTintColorAnimationOptions options)

void AddTintColorAnimationToSimpleDamageNumberStyle(int idx, SimpleUnitTintColorAnimationOptions options)

Description


Add a tint animation to an simple number style registered with DCEI.RegisterSimpleDamageNumberStyles

Parameters

Example Usage

local function RegisterSimpleDigitStyle()
    -- damage number style
    DCEI.RegisterSimpleDamageNumberStyles({
        font_type = 1,
        duration_seconds = 0.9,
        distance_between_digits = {
            x = 0.4,
            y = 0,
            z = 0,
        },
    })

    local x_y_ratio = 1
    local x_final = 0.5

    DCEI.AddTransformAnimationToSimpleDamageNumberStyle(1, {
        start_scale = { x = 0, y = 0, z = 0 },
        random_position_offset = { x = 0, y = 0, z = 0 },
        end_scale = { x = x_final * 1.2, y = x_final * x_y_ratio * 1.2, z = x_final * 1.2 },
        end_position = { x = 0, y = 0, z = 0 },
        end_degree = 0,
        pivot = { x = 0, y = 0 },
        start_seconds = 0,
        end_seconds = 0.25,
    })

    DCEI.AddTransformAnimationToSimpleDamageNumberStyle(1, {
        start_scale = { x = x_final * 1.2, y = x_final * x_y_ratio * 1.2, z = x_final * 1.2 },
        random_position_offset = { x = 0, y = 0, z = 0 },
        end_scale = { x = x_final * 0.9, y = x_final * x_y_ratio * 0.9, z = x_final * 0.9 },
        end_position = { x = 0, y = 0, z = 0 },
        end_degree = 0,
        pivot = { x = 0, y = 0 },
        start_seconds = 0.25,
        end_seconds = 0.375,
    })

    DCEI.AddTintColorAnimationToSimpleDamageNumberStyle(1, {
        start_alpha = 0.1,
        end_alpha = 1,
        start_tint_color = { x = 1, y = 1, z = 1 },
        end_tint_color = { x = 1, y = 1, z = 1 },
        start_seconds = 0,
        end_seconds = 0.25,
    })

    DCEI.AddTintColorAnimationToSimpleDamageNumberStyle(1, {
        start_alpha = 1,
        end_alpha = 1,
        start_tint_color = { x = 1, y = 1, z = 1 },
        end_tint_color = { x = 1, y = 1, z = 1 },
        start_seconds = 0.25,
        end_seconds = 0.75,
    })
end

local function OnUnitDamaged(damage, target_unit)
    DCEI.ShowSimpleDamageNumber(target_unit, 1, damage)
end

DCEI.TriggerAddUnitDamageEvent(DCEI.CreateUnitFilter({name = DCEI.Unit("Test Unit")}), OnUnitDamaged, {critical_only = true})

void ShowSimpleDamageNumber(unit unit, int styleType, float damageValue)

void ShowSimpleDamageNumber(unit unit, int styleType, float damageValue)

Description


Display a simple damage number over a unit, using a style registered with DCEI.RegisterSimpleDamageNumberStyles.

Parameters

Example Usage

local function RegisterSimpleDigitStyle()
    -- damage number style
    DCEI.RegisterSimpleDamageNumberStyles({
        font_type = 1,
        duration_seconds = 0.9,
        distance_between_digits = {
            x = 0.4,
            y = 0,
            z = 0,
        },
    })

    local x_y_ratio = 1
    local x_final = 0.5

    DCEI.AddTransformAnimationToSimpleDamageNumberStyle(1, {
        start_scale = { x = 0, y = 0, z = 0 },
        random_position_offset = { x = 0, y = 0, z = 0 },
        end_scale = { x = x_final * 1.2, y = x_final * x_y_ratio * 1.2, z = x_final * 1.2 },
        end_position = { x = 0, y = 0, z = 0 },
        end_degree = 0,
        pivot = { x = 0, y = 0 },
        start_seconds = 0,
        end_seconds = 0.25,
    })

    DCEI.AddTransformAnimationToSimpleDamageNumberStyle(1, {
        start_scale = { x = x_final * 1.2, y = x_final * x_y_ratio * 1.2, z = x_final * 1.2 },
        random_position_offset = { x = 0, y = 0, z = 0 },
        end_scale = { x = x_final * 0.9, y = x_final * x_y_ratio * 0.9, z = x_final * 0.9 },
        end_position = { x = 0, y = 0, z = 0 },
        end_degree = 0,
        pivot = { x = 0, y = 0 },
        start_seconds = 0.25,
        end_seconds = 0.375,
    })

    DCEI.AddTintColorAnimationToSimpleDamageNumberStyle(1, {
        start_alpha = 0.1,
        end_alpha = 1,
        start_tint_color = { x = 1, y = 1, z = 1 },
        end_tint_color = { x = 1, y = 1, z = 1 },
        start_seconds = 0,
        end_seconds = 0.25,
    })

    DCEI.AddTintColorAnimationToSimpleDamageNumberStyle(1, {
        start_alpha = 1,
        end_alpha = 1,
        start_tint_color = { x = 1, y = 1, z = 1 },
        end_tint_color = { x = 1, y = 1, z = 1 },
        start_seconds = 0.25,
        end_seconds = 0.75,
    })
end

local function OnUnitDamaged(damage, target_unit)
    DCEI.ShowSimpleDamageNumber(target_unit, 1, damage)
end

DCEI.TriggerAddUnitDamageEvent(DCEI.CreateUnitFilter({name = DCEI.Unit("Test Unit")}), OnUnitDamaged, {critical_only = true})

unit CreateSimpleUnitAsync(string name, SimpleUnitInstanceOptions options)

unit CreateSimpleUnitAsync(string name, SimpleUnitInstanceOptions options)

Description


Create instances of Simple Unit Type that has been registered with RegisterSimpleUnitType

Parameters

Example Usage

local player_id = -1
local team_id = -1
local default_armor = 0
local default_loot = 0
local default_timing = 1 -- OnStart

local meta_data = {
    type_name = DCEI.SimpleUnit("Hostile - Runner"), -- A Registered Simple Unit.
}
local health_data = {
    max = 6, -- The Maximum Health of the Unit.
    value = 6, -- The Current Health of the Unit.
}
local armor_data = {
    type = default_armor, -- Index for armor type.
}
local loot_data = {
    loot_id = default_loot, -- The Registered Loot Id to Drop.
    drop_rate = 0.5, -- The Chance [0 - 1] of dropping this Loot when the Unit is Killed.
}
local movement_data = {
    max_speed = 15, -- The Max Speed of the Unit.
    velocity = { x = 1, y = 0, z = 1 }, -- The Direction of Travel.
}
local local_avoidance_data = {
    enabled = false, -- Navigates around collisions.
}
local mover_data = {
    enabled = false,
}
local collision_data = {
    belongs_to_layer_mask = -1, -- The Layer of the Unit.
    collides_with_layer_mask = 1, -- The Layer the Unit can collide with.
    radius = 0.5, -- The Radius of the Unit.
}
local collision_damage_data = {
    timing = timing, -- The Timing (Start, Continue, Stop) that will trigger this response.
    deal_damage_value = 4, -- The amount of Damage to deal.
    cooldown = 8, -- The Delay (in Frames) before a target can be Damaged again.
}
local collision_force_data = {
    horizontal_force = 1.0,
    horizontal_friction = 0.1,
    vertical_force = 0.1,
    vertical_friction = 0.01,
    duration = 0.25,
    timing = default_timing,
    only_trigger_on_kill = false,
    cooldown_seconds = 0.25,
}
local collision_stats_data = {
    stats_name = "Spunk",
    delta_value = 1.0,
    timing = default_timing
}
local collision_movement_speed_modifier_applier_data = {
    modifier = {
        scaled = 0.0,
        unscaled = 1.0,
        additive_factor = 0.0,
        positive_unified_factor = 0.0,
        negative_unified_factor = 0.0,
        multiplier_factor = 0.0,
    },
    duration_seconds = 1.0,
    timing = default_timing,
    cooldown_seconds = 1.0,
}
local cast_effect_data = {
    collision_effects = {
        {
            timing = default_timing,
            effect_name = DCEI.Effect("Hostile - Runner Collide Effect"),
            cooldown_seconds = 1.0,
            tag_mask_filter = 0,
        },
    },
    on_death = DCEI.Effect("Hostile - Runner Death Effect"),
}
local tag_data = {
    value = 1,
}
local timer_data = {
    remove_unit_after_seconds = 10.0, -- Removes the Unit after a duration.
    kill_unit_after_seconds = 9.0, -- Kills the Unit after a duration.
}
local animator_data = {
    shadow_options = {
        enabled = true,
        shadow_radius = 0.5,
    },
    death_particle_effects = {1, 2, 3},
    animation_options = {
        enabled = true,
        frame_rate = 30.0,
    },
}
local options = {
    meta = meta_data,
    health_options = health_data,
    armor_options = armor_data,
    loot_options = loot_data,
    movement_options = movement_data,
    local_avoidance_options = local_avoidance_data,
    mover_options = mover_data,
    collision_options = collision_data,
    collision_damage_applier_options = collision_damage_data,
    collision_force_applier_options = collision_force_data,
    collision_stats_applier_options = collision_stats_data,
    collision_movement_speed_modifier_applier_options = collision_speed_data,
    cast_effect_options = cast_effect_data,
    tag_options = tag_data,
    timer_options = timer_data,
    mass = 2.0,
    animator_options = animator_data,
}

-- Register the simple unit type ...
DCEI.RegisterSimpleUnitType("Hostile - Runner", options)

-- ... then create an instance of it.
DCEI.CreateSimpleUnitAsync("Hostile - Runner", {
    player_id = player_id,
    team_id = team_id,
    position = { x = 15, y = 0, z = 15 },
    facing = { x = 0, y = 0 },
    velocity = { x = 1, y = 0, z = 1 },
    move_target_unit = nil, -- Unit reference
    move_target_position = nil, -- {x,y,z}
    move_target_direction = nil, -- {x,y,z}
})

unit CreateSimpleUnitSync(string name, SimpleUnitInstanceOptions options)

unit CreateSimpleUnitSync(string name, SimpleUnitInstanceOptions options)

Description


Create instances of Simple Unit Type that has been registered with RegisterSimpleUnitType. its parameters are the same as DCEI.CreateSimpleUnitAsync, but it would return an Unit for further operations

Parameters

Example Usage

local player_id = -1
local team_id = -1
local default_armor = 0
local default_loot = 0
local default_timing = 1 -- OnStart

local meta_data = {
    type_name = DCEI.SimpleUnit("Hostile - Runner"), -- A Registered Simple Unit.
}
local health_data = {
    max = 6, -- The Maximum Health of the Unit.
    value = 6, -- The Current Health of the Unit.
}
local armor_data = {
    type = default_armor, -- Index for armor type.
}
local loot_data = {
    loot_id = default_loot, -- The Registered Loot Id to Drop.
    drop_rate = 0.5, -- The Chance [0 - 1] of dropping this Loot when the Unit is Killed.
}
local movement_data = {
    max_speed = 15, -- The Max Speed of the Unit.
    velocity = { x = 1, y = 0, z = 1 }, -- The Direction of Travel.
}
local local_avoidance_data = {
    enabled = false, -- Navigates around collisions.
}
local mover_data = {
    enabled = false,
}
local collision_data = {
    belongs_to_layer_mask = -1, -- The Layer of the Unit.
    collides_with_layer_mask = 1, -- The Layer the Unit can collide with.
    radius = 0.5, -- The Radius of the Unit.
}
local collision_damage_data = {
    timing = timing, -- The Timing (Start, Continue, Stop) that will trigger this response.
    deal_damage_value = 4, -- The amount of Damage to deal.
    cooldown = 8, -- The Delay (in Frames) before a target can be Damaged again.
}
local collision_force_data = {
    horizontal_force = 1.0,
    horizontal_friction = 0.1,
    vertical_force = 0.1,
    vertical_friction = 0.01,
    duration = 0.25,
    timing = default_timing,
    only_trigger_on_kill = false,
    cooldown_seconds = 0.25,
}
local collision_stats_data = {
    stats_name = "Spunk",
    delta_value = 1.0,
    timing = default_timing
}
local collision_movement_speed_modifier_applier_data = {
    modifier = {
        scaled = 0.0,
        unscaled = 1.0,
        additive_factor = 0.0,
        positive_unified_factor = 0.0,
        negative_unified_factor = 0.0,
        multiplier_factor = 0.0,
    },
    duration_seconds = 1.0,
    timing = default_timing,
    cooldown_seconds = 1.0,
}
local cast_effect_data = {
    collision_effects = {
        {
            timing = default_timing,
            effect_name = DCEI.Effect("Hostile - Runner Collide Effect"),
            cooldown_seconds = 1.0,
            tag_mask_filter = 0,
        },
    },
    on_death = DCEI.Effect("Hostile - Runner Death Effect"),
}
local tag_data = {
    value = 1,
}
local timer_data = {
    remove_unit_after_seconds = 10.0, -- Removes the Unit after a duration.
    kill_unit_after_seconds = 9.0, -- Kills the Unit after a duration.
}
local animator_data = {
    shadow_options = {
        enabled = true,
        shadow_radius = 0.5,
    },
    death_particle_effects = {1, 2, 3},
    animation_options = {
        enabled = true,
        frame_rate = 30.0,
    },
}
local options = {
    meta = meta_data,
    health_options = health_data,
    armor_options = armor_data,
    loot_options = loot_data,
    movement_options = movement_data,
    local_avoidance_options = local_avoidance_data,
    mover_options = mover_data,
    collision_options = collision_data,
    collision_damage_applier_options = collision_damage_data,
    collision_force_applier_options = collision_force_data,
    collision_stats_applier_options = collision_stats_data,
    collision_movement_speed_modifier_applier_options = collision_speed_data,
    cast_effect_options = cast_effect_data,
    tag_options = tag_data,
    timer_options = timer_data,
    mass = 2.0,
    animator_options = animator_data,
}

-- Register the simple unit type ...
DCEI.RegisterSimpleUnitType("Hostile - Runner", options)

-- ... then create an instance of it.
local new_unit = DCEI.CreateSimpleUnitSync("Hostile - Runner", {
    player_id = player_id,
    team_id = team_id,
    position = { x = 15, y = 0, z = 15 },
    facing = { x = 0, y = 0 },
    velocity = { x = 1, y = 0, z = 1 },
    move_target_unit = nil, -- Unit reference
    move_target_position = nil, -- {x,y,z}
    move_target_direction = nil, -- {x,y,z}
})

int RegisterSimpleLoot(string lootName, string unitName, SimpleUnitInstanceOptions options)

int RegisterSimpleLoot(string lootName, string unitName, SimpleUnitInstanceOptions options)

Description


Register simple unit loop type to use for simple unit system

Parameters

Example Usage

Experimental / in-development / internal API
No example usage

void SetSimpleUnitLootData(unit unit, string name, float dropRate)

void SetSimpleUnitLootData(unit unit, string name, float dropRate)

Description


Set simple unit to have a chance to drop loot that was previously registered with the same name using DCEI.RegisterSimpleLoot. For more info about simple units, see Simple Units Guide.

Parameters

Example Usage

local unit_options = {
    type_name = DCEI.Unit("XP Item"),
    max_health = 1,
    drop_rate = 0,
}
local collision_options = {
    belongs_to_layer_mask = 1,
    collides_with_layer_mask = 2,
    radius = 0.5,
    take_damage = false,
}
local collision_stats = {
    stats_id = 1,
    delta_value = reward,
}

DCEI.RegisterSimpleLoot("basic_loot", unit_options, collision_options, collision_stats)
DCEI.SetSimpleUnitLootData(unit, "basic_loot", 1.00)

unit CreateUnitAsync(int teamId, int playerId, string unitType, float x, float z, float dx = 0, float dz = 1)

unit CreateUnitAsync(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. Asynchronous, meaning the unit may not finish initializing until the next frame. Wait a full frame before trying to reference the created unit with other APIs.

Parameters

Example Usage

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

unit CreateChildUnit(unit parent, string unitType, float x, float z, float dx = 0, float dz = 1)

unit CreateChildUnit(unit parent, string unitType, float x, float z, float dx = 0, float dz = 1)

Description


Creates a child unit for a parent unit. Used for Wild Sky to create pets that follow and defend parent units.

Parameters

Example Usage

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

DCEI.CreateChildUnit(parent_unit, unit_type, x + 1, y + 1)

unit CreateChildUnitAsync(unit parent, string unitType, float x, float z)

unit CreateChildUnitAsync(unit parent, string unitType, float x, float z)

Description


Creates a child unit for a parent unit. Used for Wild Sky to create pets that follow and defend parent units. Asynchronous, meaning the unit may not be created/initialized on the same frame. Wait a full frame before trying to reference the created unit.

Parameters

Example Usage

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

DCEI.CreateChildUnitAsync(parent_unit, unit_type, x + 1, y + 1)

void KillUnit(unit unit)

void KillUnit(unit unit)

Description


Kills a unit.

Parameters

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)

void RemoveUnit(unit unit)

void RemoveUnit(unit unit)

Description


Removes a unit.

Parameters

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)

void RemoveSimpleUnit(unit unit)

void RemoveSimpleUnit(unit unit)

Description


Remove a simple unit, without triggering death effects.

Parameters

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,
})
DCEI.RemoveSimpleUnit(unit)

void KillSimpleUnit(unit unit)

void KillSimpleUnit(unit unit)

Description


Kill simple unit.

Parameters

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,
})
DCEI.KillSimpleUnit(unit)

string GetUnitType(unit unit)

string GetUnitType(unit unit)

Description


Returns the unit name as a string.

Parameters

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

Example Usage

local unit_type = DCEI.Unit("Standard MeleeUnit")
local health = DCEI.GetUnitTypeHealth(unit_type)
DCEI.LogMessage(health)

string GetUnitDisplayName(unit unit)

string GetUnitDisplayName(unit unit)

Description


Returns the Display Name of a unit as a string.

Parameters

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)

string GetUnitCategory(unit unit)

string GetUnitCategory(unit unit)

Description


Returns the unit category of a unit as a string (Unit, Missile, or Structure).

Parameters

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

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

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

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
    )

void AttachUnit(unit childUnit, unit parentUnit, AttachOffsetOptions option)

void AttachUnit(unit childUnit, unit parentUnit, AttachOffsetOptions option)

Description


Attach two units.

You can use AttachUnit to attach a "Simple" unit to a "Normal" unit. It's bridge for Simple/Complex units working together.

Parameters

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

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

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)

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

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)

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

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)

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

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)

float GetHealth(unit unit)

float GetHealth(unit unit)

Description


Returns the current health of a unit.

Parameters

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

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 AddHealthAsync(unit unit, float value)

void AddHealthAsync(unit unit, float value)

Description


Increases the current health of a unit. Async, meaning it may not happen on this exact frame.

Parameters

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.AddHealthAsync(unit, 10)

    DCEI.Wait(1)

    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

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


Sets the owner of a unit.

Parameters

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


Sets the team id of a unit.

Parameters

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)

void SetHealthValueAsync(unit unit, float amount)

void SetHealthValueAsync(unit unit, float amount)

Description


Sets the current health of a unit. Asynchronous, so may not happen on this exact frame.

Parameters

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.SetHealthValueAsync(unit, 5)
    DCEI.SetMaxHealth(unit, 30)

    DCEI.Wait(1)

    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)

float GetMana(unit unit)

float GetMana(unit unit)

Description


Returns the current mana of a unit.

Parameters

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

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 AddManaAsync(unit unit, float value)

void AddManaAsync(unit unit, float value)

Description


Increases the current mana of a unit. Asychronous, so may not occur on this frame.

Parameters

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.AddManaAsync(unit, 10)

    DCEI.Wait(1)

    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

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 SetManaValueAsync(unit unit, float amount)

void SetManaValueAsync(unit unit, float amount)

Description


Sets the current mana of a unit. Asynchronous, so may take a simulation frame to occur.

Parameters

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.SetManaValueAsync(unit, 5)

    DCEI.Wait(1)

    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

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)

float GetUnitBounty(unit unit)

float GetUnitBounty(unit unit)

Description


Returns the SetGoldBounty of a unit.

Parameters

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.")

object GetUnitBehaviorList(unit unit)

object GetUnitBehaviorList(unit unit)

Description


Returns a list of behaviors on a unit along with their stack count.

Parameters

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

Example Usage

local weapons = DCEI.GetUnitWeaponList(unit)
for _, weapon in ipairs(weapons) do
    DCEI.LogMessage(weapon)
end

object GetUnitAbilityList(unit unit)

object GetUnitAbilityList(unit unit)

Description


Returns a list of abilities on a unit.

Parameters

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

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

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

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

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

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 GetUnitRallyPoint(unit unit)

Float2 GetUnitRallyPoint(unit unit)

Description


Get the unit's rally point target, for Wild Sky units using a rally point ability.

Parameters

Example Usage

function TowerHunterHutCreateTraps(unit, quantity)
    local pos = DCEI.GetUnitPosition2D(unit)
    --local target = DCEI.FindClosestPointOnRoad(pos.x, pos.y, true)
    local target = DCEI.GetUnitRallyPoint(unit)
    for i = 1, quantity do
        DCEI.TriggerAddTimerEventElapsed(function()
            DCEI.CreateEffectAtPosition(
                "Tower HunterHut Trapmaster Trap Launch",
                unit,
                target.x + (math.random() * math.random(-1, 1) * 0.9),
                target.y + (math.random() * math.random(-1, 1) * 0.9)
            )
        end, i * 0.125)
    end
end

int GetUnitWaypointNodeIndex(unit unit)

int GetUnitWaypointNodeIndex(unit unit)

Description


Wild Sky only. Gets the index for the current node along a waypoint path that a unit is traveling, if the unit is currently travelling along a waypoint path. This can then be used with API's like ApplyWaypoint to make sure the unit resumes the waypoint at the same position it left it, if you temporarily interrupt the unit.

Parameters

Example Usage

local pos = { x = 31, y = 8 } -- spawn pos
local GoblinWarshipUnit = DCEI.CreateUnit(-1, -1, DCEI.Unit("Goblin Warship"), pos.x, pos.y, 1, -1)
DCEI.ApplyWaypoint(GoblinWarshipUnit, "GoblinWarshipFlyby", 0.5)
DCEI.Wait(5)
local node_index = DCEI.GetUnitWaypointNodeIndex(GoblinWarshipUnit)
DCEI.Stop(GoblinWarshipUnit)
DCEI.Wait(5)
DCEI.ApplyWaypoint(GoblinWarshipUnit, {
    waypoint_name = "GoblinWarshipFlyby",
    dispersal = 0.5,
    use_natural_dispersal = true,
    node_index = node_index
})

Float2 GetUnitPosition2D(unit unit)

Float2 GetUnitPosition2D(unit unit)

Description


Returns the position of a unit.

Parameters

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

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

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)

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

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)

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

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)

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

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)

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

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

Description


Sets the position of a unit. Asynchronous, so may not occur this simulation frame.

Parameters

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.SetUnitPosition2DAsync(unit, 15, 15)

DCEI.Wait(0.0625) -- Wait because the API is async

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

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

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

Description


Sets the 3D position of a unit. Asynchronous so may not occur this simulation frame.

Parameters

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.SetUnitPosition3DAsync(unit, 15, 1, 15)

DCEI.Wait(0.0625) -- Wait since the API is async

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

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

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

Description


Sets the position of a unit while causing it to seemingly leap to that position. Async so may not happen this simulation frame. Recommended you use the non-Async version.

Parameters

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.SetUnitPosition2DWithInterpolationAsync(unit, 15, 15)

DCEI.Wait(0.0625) -- Wait because this is the Async version of this API.

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

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

void SetUnitPosition3DWithInterpolationAsync(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. Async so may not occur this frame. Recommended you use the non-async version of this API.

Parameters

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.SetUnitPosition3DWithInterpolationAsync(unit, 15, 1, 15)

DCEI.Wait(0.0625) -- Wait since this is the async version of the api

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

Float3 GetUnitRotationEuler(unit unit)

Float3 GetUnitRotationEuler(unit unit)

Description


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

Parameters

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)

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

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)

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

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)

bool UnitExists(unit unit)

bool UnitExists(unit unit)

Description


Returns true if a units exists.

Parameters

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)

bool SimpleUnitExists(unit unit)

bool SimpleUnitExists(unit unit)

Description


Returns true if a simple unit exists.

Parameters

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

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."))

bool UnitIsMoving(unit unit)

bool UnitIsMoving(unit unit)

Description


Returns true if a unit is moving.

Parameters

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)

void EnableUnitSelection(unit target)

void EnableUnitSelection(unit target)

Description


Enables selection for a unit.

Parameters

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)

void DisableUnitSelection(unit target)

void DisableUnitSelection(unit target)

Description


Disables selection for a unit.

Parameters

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

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

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

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

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

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 SetMaxShieldAsync(unit unit, float value)

void SetMaxShieldAsync(unit unit, float value)

Description


Sets the maximum shields for a unit. Async version of API; may not occur until a simulation frame tick after it's called. Recommended you use the non-async version of this API.

Parameters

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.SetMaxShieldAsync(unit,30)

    DCEI.Wait(0.0625) -- Wait because async

    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

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

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

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 AddShieldAsync(unit unit, float value)

void AddShieldAsync(unit unit, float value)

Description


Increases the current shields of a unit by a set amount up to its maximum. Async so may not occur on the same simulation frame as it's called. Recommended you use the non-async version of this API.

Parameters

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.AddShieldAsync(unit, 10)

    DCEI.Wait(0.0625) -- Wait because of async api

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

void SetShieldValueAsync(unit unit, float amount)

void SetShieldValueAsync(unit unit, float amount)

Description


Set the current shields of a unit to a set amount up to its maximum. Async so may not occur util after the current simulation frame. Recommended you use the non-async API instead.

Parameters

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.SetShieldValueAsync(unit, 5)

    DCEI.Wait(0.0625) -- Wait for async API 

    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

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

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 SetMaxHealthAsync(unit unit, float value)

void SetMaxHealthAsync(unit unit, float value)

Description


Sets the maximum health for a unit. Async, so may not occur until next simulation frame. Recommended you use the non-async version of this API.

Parameters

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.SetMaxHealthAsync(unit,30)

    DCEI.Wait(0.0625) -- Wait for async API

    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

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

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 SetMaxManaAsync(unit unit, float value)

void SetMaxManaAsync(unit unit, float value)

Description


Sets the maximum mana for a unit. Async, so may not occur until next simulation frame. Recommended you use the non-async API.

Parameters

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.SetMaxManaAsync(unit, 20)

    DCEI.Wait(0.0625) -- Async version of API

    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

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.")

void SetGoldBountyAsync(unit unit, float amount)

void SetGoldBountyAsync(unit unit, float amount)

Description


Sets the SetGoldBounty for a unit. Async so may not occur until the next simulation frame. Recommended you use the non-async version instead.

Parameters

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.SetGoldBountyAsync(unit, 5.0)

DCEI.Wait(0.0625) -- Wait because of async API

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

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

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

Description


Make a unit follow a waypoint using a certain dispersal. Wild Sky only.

Parameters

Example Usage

local pos = { x = 31, y = 8 } -- spawn pos
local GoblinWarshipUnit = DCEI.CreateUnit(-1, -1, DCEI.Unit("Goblin Warship"), pos.x, pos.y, 1, -1)
DCEI.ApplyWaypoint(GoblinWarshipUnit, "GoblinWarshipFlyby", 0.5)

void ApplyWaypoint(unit unit, WaypointOptions option)

void ApplyWaypoint(unit unit, WaypointOptions option)

Description


Make a unit follow a waypoint using additional options. Wild Sky only.

Parameters

Example Usage

local pos = { x = 31, y = 8 } -- spawn pos
local GoblinWarshipUnit = DCEI.CreateUnit(-1, -1, DCEI.Unit("Goblin Warship"), pos.x, pos.y, 1, -1)
DCEI.ApplyWaypoint(GoblinWarshipUnit, {
    waypoint_name = "GoblinWarshipFlyby",
    dispersal = 0.5,
    use_natural_dispersal = true,
    node_index = 2
})

object GetWaypointPaths(bool includeRallyDisabledLanes)

object GetWaypointPaths(bool includeRallyDisabledLanes)

Description


Wild Sky feature. Get all waypoint paths defined in the terrain editor.

Parameters

Example Usage

function HeroMakaWolfSpawner(u)
    -- First we assign the spawner a waypoint
    local paths = DCEI.GetWaypointPaths()

    local path = paths[(1 % #paths) + 1]
    local start = DCEI.GetWaypointPathStartPosition(path)
    -- Second we find the closest tower slot
    local slot = game.GetClosestUnit(DCEI.FindUnits(DCEI.Unit("Tower Slot")), start)
    if slot and slot ~= DCEI.UnitAny then
        -- Third we get a polar offset from the slot toward the start
        local pos = game.PolarOffsetFromUnit2D(slot, 0.5, game.AngleBetweenUnitAndPoint2D(slot, start))
        -- Finally we find the closest point on a road and translate the spawner
        local road = DCEI.FindClosestPointOnRoad(pos.x, pos.y, true)
        DCEI.SetUnitPosition2DAsync(u, road.x, road.y)
    end
end

Float2 GetWaypointPathStartPosition(string name, float dispersal = 0.5)

Float2 GetWaypointPathStartPosition(string name, float dispersal = 0.5)

Description


Wild Sky feature. Get the starting point of a given waypoint path.

Parameters

Example Usage

function HeroMakaWolfSpawner(u)
    -- First we assign the spawner a waypoint
    local paths = DCEI.GetWaypointPaths()

    local path = paths[(1 % #paths) + 1]
    local start = DCEI.GetWaypointPathStartPosition(path)
    -- Second we find the closest tower slot
    local slot = game.GetClosestUnit(DCEI.FindUnits(DCEI.Unit("Tower Slot")), start)
    if slot and slot ~= DCEI.UnitAny then
        -- Third we get a polar offset from the slot toward the start
        local pos = game.PolarOffsetFromUnit2D(slot, 0.5, game.AngleBetweenUnitAndPoint2D(slot, start))
        -- Finally we find the closest point on a road and translate the spawner
        local road = DCEI.FindClosestPointOnRoad(pos.x, pos.y, true)
        DCEI.SetUnitPosition2DAsync(u, road.x, road.y)
    end
end

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

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

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

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

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

void DeselectUnit(unit unit)

void DeselectUnit(unit unit)

Description


Deselects a unit.

Parameters

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

unit FindUnit(string name)

unit FindUnit(string name)

Description


Attempts to return an existing unit from its name.

Parameters

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.")

object FindUnitsByPlayerId(int playerId)

object FindUnitsByPlayerId(int playerId)

Description


Returns a list of all units owned by a player.

Parameters

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

object FindUnitsByTeamId(int teamId)

object FindUnitsByTeamId(int teamId)

Description


Returns a list of all units that belong to the specified team.

Parameters

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

object FindSimpleUnitsByName(string name)

object FindSimpleUnitsByName(string name)

Description


Find all simple units by unit type name. For more info about simple units, see Simple Units Guide.

Parameters

Example Usage

local unit_type = "Simple Unit"
local x, y = 12, 12
local unit = {}

for i = 1, 5 do
    unit[i] = DCEI.CreateSimpleUnit(
        -1
        unit_properties.Unit,
        unit_properties.Collider,
        position.x,
        position.y,
        rotation.x,
        rotation.y,
        velocity.x,
        velocity.y
    )
end

local group = DCEI.FindSimpleUnitsByName("Simple Unit")

for _, unit in ipairs(group) do
    DCEI.LogMessage("Unit Found")
end

object FindSimpleUnitsByPlayerId(int playerId)

object FindSimpleUnitsByPlayerId(int playerId)

Description


Find all simple units by owner player ID. For more info about simple units, see Simple Units Guide.

Parameters

Example Usage

local unit_type = "Simple Unit"
local x, y = 12, 12
local unit = {}

for i = 1, 5 do
    unit[i] = DCEI.CreateSimpleUnit(
        -1
        unit_properties.Unit,
        unit_properties.Collider,
        position.x,
        position.y,
        rotation.x,
        rotation.y,
        velocity.x,
        velocity.y
    )
end

local group = DCEI.FindSimpleUnitsByPlayerId(-1)

for _, unit in ipairs(group) do
    DCEI.LogMessage("Unit Found")
end

object FindUnits(string name)

object FindUnits(string name)

Description


Returns a list of all units with the specified unit name.

Parameters

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

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

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.")

bool IsUnitSelected(unit unit)

bool IsUnitSelected(unit unit)

Description


Returns true if the unit is selected.

Parameters

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