Trigger API Reference DCEI Functions Ability0 - BLKTower/TestWiki GitHub Wiki
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)Returns true if the ability is enabled on a unit.
-
unit
unitthe unit to check for ability status. -
string
abilityNamethe name of the ability to check.
function SetAbilityButtonStatus(unit, ability, button)
local enabled = DCEI.IsUnitAbilityEnabled(unit, ability)
DCEI.EnableButton(button, enabled)
endfloat GetUnitAbilityCooldown(unit unit, string abilityName) {float-GetUnitAbilityCooldownunit-unit-string-abilityName}
float GetUnitAbilityCooldown(unit unit, string abilityName)Returns the remaining cooldown of a unit's ability.
-
unit
unitthe unit to check for ability cooldown. -
string
abilityNamethe name of the ability to check.
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
endAbilityCost GetAbilityCost(string abilityName)Returns the cost of an ability as a table.
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)Returns whether a unit has an ability or not.
-
unit
unitthe unit to check for the ability. -
string
abilityNamethe name of the ability to check for.
function ShowAbilityButton(unit, ability, button)
local has_ability = DCEI.UnitHasAbility(unit, ability)
DCEI.SetActive(button, has_ability)
endbool UnitTypeHasAbility(string unitType, string abilityName) {bool-UnitTypeHasAbilitystring-unitType-string-abilityName}
bool UnitTypeHasAbility(string unitType, string abilityName)Returns true if a unit type has an ability.
-
string
unitTypethe unit type to check for the ability. -
string
abilityNamethe name of the ability to check for.
function ShowUpgradeButton(unit_type, ability, button)
local has_ability = DCEI.UnitTypeHasAbility(unit_type, ability)
DCEI.SetActive(button, has_ability)
endint GetUnitAbilityCurrentCharge(unit unit, string abilityName) {int-GetUnitAbilityCurrentChargeunit-unit-string-abilityName}
int GetUnitAbilityCurrentCharge(unit unit, string abilityName)Returns the number of charges a unit has left for an ability.
function SetAbilityButtonStatus(unit, ability, button)
local charges = DCEI.GetUnitAbilityCurrentCharge(unit, ability)
DCEI.EnableButton(button, charges)
endvoid SetUnitAbilityCooldown(unit unit, string abilityName, float seconds) {void-SetUnitAbilityCooldownunit-unit-string-abilityName-float-seconds}
void SetUnitAbilityCooldown(unit unit, string abilityName, float seconds)Sets the current remaining cooldown of an ability on a unit to a specified time in seconds.
-
unit
unitthe unit to set the ability's cooldown. -
string
abilityNamethe name of the ability to set the cooldown for. -
float
secondsthe time in seconds to set the cooldown of the ability to.
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
endvoid SetUnitAbilityMaxCooldown(unit unit, string abilityName, float seconds) {void-SetUnitAbilityMaxCooldownunit-unit-string-abilityName-float-seconds}
void SetUnitAbilityMaxCooldown(unit unit, string abilityName, float seconds)Sets the maximum cooldown of an ability on a unit to a specified time in seconds.
-
unit
unitthe unit to set the ability's maximum cooldown. -
string
abilityNamethe name of the ability to set the maximum cooldown for. -
float
secondsthe time in seconds to set the maximum cooldown of the ability to.
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
endvoid 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)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.
-
string
abilityNamethe name of the ability to cast. -
unit
casterthe unit to cast the ability. -
unit
targetthe unit to target with the ability. -
bool
immediateif true, the unit will attempt to cast the ability in the same frame that it's ordered, rather than queuing the command.
function OnSwordAttackButtonPressed(unit)
DCEI.CastAbilityAtUnit("Sword Swing", unit, unit, true)
endvoid CastAbilityEffect(string abilityName, unit caster, unit target) {void-CastAbilityEffectstring-abilityName-unit-caster-unit-target}
void CastAbilityEffect(string abilityName, unit caster, unit target)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.
-
string
abilityNamethe name of the ability to cast the effect of. -
unit
casterthe unit to cast the ability. -
unit
targetthe unit to target with the ability.
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)Cancels all ability orders a unit has queued.
function Stop(unit)
local position = DCEI.GetUnitPosition2D(unit)
DCEI.CancelAbilities(unit)
DCEI.Move(unit, position.x, position.y)
endvoid EnterTargetingMode(unit unit, string abilityName) {void-EnterTargetingModeunit-unit-string-abilityName}
void EnterTargetingMode(unit unit, string abilityName)Enters targeting mode for a unit's ability. Only works for targeted abilities.
-
unit
unitthe unit to enter targeting mode for. -
string
abilityNamethe name of the ability to enter the targeting mode for.
function AbilityButtonPressed(unit, ability)
DCEI.EnterTargetingMode(unit, ability)
endvoid ExitTargetingMode()Exits targeting mode for any abilities currently in targeting mode.
function CancelButtonPressed()
DCEI.ExitTargetingMode()
DCEI.SelectUnit(hero)
endvoid AddUnitAbility(string unitType, string abilityName) {void-AddUnitAbilitystring-unitType-string-abilityName}
void AddUnitAbility(string unitType, string abilityName)void AddUnitAbilitySync(string unitType, string abilityName) {void-AddUnitAbilitySyncstring-unitType-string-abilityName}
void AddUnitAbilitySync(string unitType, string abilityName)Adds an ability to a unit type.
-
string
unitTypethe unit type to add the ability to. -
string
abilityNamethe name of the ability to add.
function OnAbilityPurchased(unit_type, ability)
DCEI.AddUnitAbilitySync(unit_type, ability)
endvoid RemoveUnitAbility(string unitType, string abilityName) {void-RemoveUnitAbilitystring-unitType-string-abilityName}
void RemoveUnitAbility(string unitType, string abilityName)void RemoveUnitAbilitySync(string unitType, string abilityName) {void-RemoveUnitAbilitySyncstring-unitType-string-abilityName}
void RemoveUnitAbilitySync(string unitType, string abilityName)Removes an ability from a unit type.
-
string
unitTypethe unit type to remove the ability from. -
string
abilityNamethe name of the ability to remove.
function OnAbilityPurchaseRefunded(unit_type, ability)
DCEI.RemoveUnitAbilitySync(unit_type, ability)
endvoid 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)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.
-
string
abilityNamethe name of the ability to cast. -
unit
casterthe unit which will cast the ability. -
float
xthe x-axis coordinate to cast the ability at. -
float
zthe z-axis coordinate to cast the ability at. -
bool
immediateif true, the unit will attempt to cast the ability in the same frame that it's ordered, rather than queuing the command.
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)
endvoid 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)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.
-
string
abilityNamethe name of the ability to cast the effect of. -
unit
casterthe unit to cast the ability. -
float
xthe X coordinate. -
float
zthe Z coordinate.
--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)Sets the current number of charges for an ability on a unit.
-
unit
unitthe unit to set ability charges for. -
string
abilityNamethe name of the ability to set the charges for. -
int
chargeCountthe number of charges to set the ability to. -
bool
clampChargeCountif true, the number of charges is clamped to the maximum charge count set for the ability.
function BonusChargeEarned(unit, ability)
local current_charges = DCEI.GetUnitAbilityCurrentCharge(unit, ability)
DCEI.SetAbilityCurrentCharge(unit, ability, current_charges + 1, false)
end