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

Table of Contents

Trigger API Reference\DCEI Functions\Ability {Trigger-API-ReferenceDCEI-FunctionsAbility}

bool IsUnitAbilityEnabled(unit unit, string abilityName) {bool-IsUnitAbilityEnabledunit-unit-string-abilityName}

bool IsUnitAbilityEnabled(unit unit, string abilityName)

Description

Returns true if the ability is enabled on a unit.

Parameters

  • unit unit the unit to check for ability status.
  • string abilityName the name of the ability to check.

Example Usage

function SetAbilityButtonStatus(unit, ability, button)
    local enabled = DCEI.IsUnitAbilityEnabled(unit, ability)
    DCEI.EnableButton(button, enabled)
end

float GetUnitAbilityCooldown(unit unit, string abilityName) {float-GetUnitAbilityCooldownunit-unit-string-abilityName}

float GetUnitAbilityCooldown(unit unit, string abilityName)

Description

Returns the remaining cooldown of a unit's ability.

Parameters

  • unit unit the unit to check for ability cooldown.
  • string abilityName the name of the ability to check.

Example Usage

function CooldownBonusObtained(unit, ability, reduction)
    local cooldown = DCEI.GetUnitAbilityCooldown(unit, ability)
    local reduced_cooldown = cooldown - reduction
    if reduced_cooldown > 0.0 then
        DCEI.SetUnitAbilityCooldown(unit, ability, reduced_cooldown)
    else
        DCEI.SetUnitAbilityCooldown(unit, ability, 0.0)
    end
end

AbilityCost GetAbilityCost(string abilityName) {AbilityCost-GetAbilityCoststring-abilityName}

AbilityCost GetAbilityCost(string abilityName)

Description

Returns the cost of an ability as a table.

Parameters

  • string abilityName the name of the ability to get the cost of.

Example Usage

function OnAbilityUse()
    local id = DCEI.TriggeringAbilityId
    local name = DCEI.TriggeringAbilityName
    DCEI.LogMessage(name .. " use")
    local cost = DCEI.GetAbilityCost(name)
    for key, value in pairs(cost) do
        DCEI.LogMessage(key .. " : " .. value)
    end
end

DCEI.TriggerAddUseAbilityEvent(DCEI.UnitAny, OnAbilityUse)

bool UnitHasAbility(unit unit, string abilityName) {bool-UnitHasAbilityunit-unit-string-abilityName}

bool UnitHasAbility(unit unit, string abilityName)

Description

Returns whether a unit has an ability or not.

Parameters

  • unit unit the unit to check for the ability.
  • string abilityName the name of the ability to check for.

Example Usage

function ShowAbilityButton(unit, ability, button)
    local has_ability = DCEI.UnitHasAbility(unit, ability)
    DCEI.SetActive(button, has_ability)
end

bool UnitTypeHasAbility(string unitType, string abilityName) {bool-UnitTypeHasAbilitystring-unitType-string-abilityName}

bool UnitTypeHasAbility(string unitType, string abilityName)

Description

Returns true if a unit type has an ability.

Parameters

  • string unitType the unit type to check for the ability.
  • string abilityName the name of the ability to check for.

Example Usage

function ShowUpgradeButton(unit_type, ability, button)
    local has_ability = DCEI.UnitTypeHasAbility(unit_type, ability)
    DCEI.SetActive(button, has_ability)
end

int GetUnitAbilityCurrentCharge(unit unit, string abilityName) {int-GetUnitAbilityCurrentChargeunit-unit-string-abilityName}

int GetUnitAbilityCurrentCharge(unit unit, string abilityName)

Description

Returns the number of charges a unit has left for an ability.

Parameters

  • unit unit the unit to check for charge count.
  • string abilityName the name of the ability to check.

Example Usage

function SetAbilityButtonStatus(unit, ability, button)
    local charges = DCEI.GetUnitAbilityCurrentCharge(unit, ability)
    DCEI.EnableButton(button, charges)
end

void SetUnitAbilityCooldown(unit unit, string abilityName, float seconds) {void-SetUnitAbilityCooldownunit-unit-string-abilityName-float-seconds}

void SetUnitAbilityCooldown(unit unit, string abilityName, float seconds)

Description

Sets the current remaining cooldown of an ability on a unit to a specified time in seconds.

Parameters

  • unit unit the unit to set the ability's cooldown.
  • string abilityName the name of the ability to set the cooldown for.
  • float seconds the time in seconds to set the cooldown of the ability to.

Example Usage

function CooldownBonusObtained(unit, ability, reduction)
    local cooldown = DCEI.GetUnitAbilityCooldown(unit, ability)
    local reduced_cooldown = cooldown - reduction
    if reduced_cooldown > 0.0 then
        DCEI.SetUnitAbilityCooldown(unit, ability, reduced_cooldown)
    else
        DCEI.SetUnitAbilityCooldown(unit, ability, 0.0)
    end
end

void SetUnitAbilityMaxCooldown(unit unit, string abilityName, float seconds) {void-SetUnitAbilityMaxCooldownunit-unit-string-abilityName-float-seconds}

void SetUnitAbilityMaxCooldown(unit unit, string abilityName, float seconds)

Description

Sets the maximum cooldown of an ability on a unit to a specified time in seconds.

Parameters

  • unit unit the unit to set the ability's maximum cooldown.
  • string abilityName the name of the ability to set the maximum cooldown for.
  • float seconds the time in seconds to set the maximum cooldown of the ability to.

Example Usage

function PermanentCooldownBonusObtained(unit, ability, reduction)
    local cooldown = DCEI.GetUnitAbilityCooldown(unit, ability)
    local reduced_cooldown = cooldown - reduction
    if reduced_cooldown > 0.0 then
        DCEI.SetUnitAbilityMaxCooldown(unit, ability, reduced_cooldown)
    else
        DCEI.SetUnitAbilityMaxCooldown(unit, ability, 0.0)
    end
end

void CastAbilityAtUnit(string abilityName, unit caster, unit target, bool immediate) {void-CastAbilityAtUnitstring-abilityName-unit-caster-unit-target-bool-immediate}

void CastAbilityAtUnit(string abilityName, unit caster, unit target, bool immediate)

Description

Issues the order for a unit to cast an ability targeting another unit. For an instant ability, this will ignore the target parameter and simply cast the ability.

Parameters

  • string abilityName the name of the ability to cast.
  • unit caster the unit to cast the ability.
  • unit target the unit to target with the ability.
  • bool immediate if true, the unit will attempt to cast the ability in the same frame that it's ordered, rather than queuing the command.

Example Usage

function OnSwordAttackButtonPressed(unit)
    DCEI.CastAbilityAtUnit("Sword Swing", unit, unit, true)
end

void CastAbilityEffect(string abilityName, unit caster, unit target) {void-CastAbilityEffectstring-abilityName-unit-caster-unit-target}

void CastAbilityEffect(string abilityName, unit caster, unit target)

Description

Immediately casts the given ability's linked effect with the context provided. Unlike CastAbility(), the unit does not need to have the ability bound in order for the effect to fire.

Parameters

  • string abilityName the name of the ability to cast the effect of.
  • unit caster the unit to cast the ability.
  • unit target the unit to target with the ability.

Example Usage

function OnDoNothing()
    local context = DCEI.TriggeringEffectContext
    local ability_name = "Ability_Name"

    DCEI.CastAbilityEffect(ability_name, context.caster, context.target)
end

DCEI.TriggerAddEffectEvent("DoNothing", OnDoNothing, true)

void CancelAbilities(unit unit) {void-CancelAbilitiesunit-unit}

void CancelAbilities(unit unit)

Description

Cancels all ability orders a unit has queued.

Parameters

  • unit unit the unit to cancel abilities for.

Example Usage

function Stop(unit)
    local position = DCEI.GetUnitPosition2D(unit)
    DCEI.CancelAbilities(unit)
    DCEI.Move(unit, position.x, position.y)
end

void EnterTargetingMode(unit unit, string abilityName) {void-EnterTargetingModeunit-unit-string-abilityName}

void EnterTargetingMode(unit unit, string abilityName)

Description

Enters targeting mode for a unit's ability. Only works for targeted abilities.

Parameters

  • unit unit the unit to enter targeting mode for.
  • string abilityName the name of the ability to enter the targeting mode for.

Example Usage

function AbilityButtonPressed(unit, ability)
    DCEI.EnterTargetingMode(unit, ability)
end

void ExitTargetingMode() {void-ExitTargetingMode}

void ExitTargetingMode()

Description

Exits targeting mode for any abilities currently in targeting mode.

Example Usage

function CancelButtonPressed()
    DCEI.ExitTargetingMode()
    DCEI.SelectUnit(hero)
end

void AddUnitAbility(string unitType, string abilityName) {void-AddUnitAbilitystring-unitType-string-abilityName}

void AddUnitAbility(string unitType, string abilityName)

Description

Parameters

Example Usage

void AddUnitAbilitySync(string unitType, string abilityName) {void-AddUnitAbilitySyncstring-unitType-string-abilityName}

void AddUnitAbilitySync(string unitType, string abilityName)

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

Description

Adds an ability to a unit type.

Parameters

  • string unitType the unit type to add the ability to.
  • string abilityName the name of the ability to add.

Example Usage

function OnAbilityPurchased(unit_type, ability)
    DCEI.AddUnitAbilitySync(unit_type, ability)
end

void RemoveUnitAbility(string unitType, string abilityName) {void-RemoveUnitAbilitystring-unitType-string-abilityName}

void RemoveUnitAbility(string unitType, string abilityName)

Description

Parameters

Example Usage

void RemoveUnitAbilitySync(string unitType, string abilityName) {void-RemoveUnitAbilitySyncstring-unitType-string-abilityName}

void RemoveUnitAbilitySync(string unitType, string abilityName)

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

Description

Removes an ability from a unit type.

Parameters

  • string unitType the unit type to remove the ability from.
  • string abilityName the name of the ability to remove.

Example Usage

function OnAbilityPurchaseRefunded(unit_type, ability)
    DCEI.RemoveUnitAbilitySync(unit_type, ability)
end

void CastAbilityAtPosition(string abilityName, unit caster, float x, float z, bool immediate) {void-CastAbilityAtPositionstring-abilityName-unit-caster-float-x-float-z-bool-immediate}

void CastAbilityAtPosition(string abilityName, unit caster, float x, float z, bool immediate)

Description

Issues the order for a unit to cast an ability targeting another unit. For an instant ability, this will ignore the target parameter and simply cast the ability.

Parameters

  • string abilityName the name of the ability to cast.
  • unit caster the unit which will cast the ability.
  • float x the x-axis coordinate to cast the ability at.
  • float z the z-axis coordinate to cast the ability at.
  • bool immediate if true, the unit will attempt to cast the ability in the same frame that it's ordered, rather than queuing the command.

Example Usage

function OnFireballButtonPressed(unit)
    local facing = DCEI.GetUnitFacing2D(unit)
    local position = DCEI.GetUnitPosition2D(unit)
    local angle = math.atan(facing.y/facing.x)
    local target = {
        x = position.x + 2.0*math.cos(angle),
        z = position.y + 2.0*math.sin(angle)
    }
    DCEI.CastAbilityAtPosition("Fireball", unit, target.x, target.z, true)
end

void CastAbilityEffectAtPosition(string abilityName, unit caster, float x, float z) {void-CastAbilityEffectAtPositionstring-abilityName-unit-caster-float-x-float-z}

void CastAbilityEffectAtPosition(string abilityName, unit caster, float x, float z)

Description

Immediately casts the given ability's linked effect at a location with the context provided. Unlike CastAbilityAtPosition(), the unit does not need to have the ability bound in order for the effect to fire.

Parameters

  • string abilityName the name of the ability to cast the effect of.
  • unit caster the unit to cast the ability.
  • float x the X coordinate.
  • float z the Z coordinate.

Example Usage

--Whenever a unit casts an ability, they instantly 'cast' a duplicate targeting (16, 16)
function OnAbilityCast()
    local unit = DCEI.TriggeringUnit
    local ability_name = DCEI.TriggeringAbilityName
    DCEI.CastAbilityEffectAtPosition(ability_name, unit, 16, 16)
end

DCEI.TriggerAddCastAbilityEvent(DCEI.UnitAny, OnAbilityCast)

void SetAbilityCurrentCharge(unit unit, string abilityName, int chargeCount, bool clampChargeCount) {void-SetAbilityCurrentChargeunit-unit-string-abilityName-int-chargeCount-bool-clampChargeCount}

void SetAbilityCurrentCharge(unit unit, string abilityName, int chargeCount, bool clampChargeCount)

Description

Sets the current number of charges for an ability on a unit.

Parameters

  • unit unit the unit to set ability charges for.
  • string abilityName the name of the ability to set the charges for.
  • int chargeCount the number of charges to set the ability to.
  • bool clampChargeCount if true, the number of charges is clamped to the maximum charge count set for the ability.

Example Usage

function BonusChargeEarned(unit, ability)
    local current_charges = DCEI.GetUnitAbilityCurrentCharge(unit, ability)
    DCEI.SetAbilityCurrentCharge(unit, ability, current_charges + 1, false)
end

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