Trigger API Reference DCEI Functions Ability0 - funovus/editor-wiki 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)
* [float GetUnitAbilityCooldown(unit unit, string abilityName)](#float-getunitabilitycooldownunit-unit-string-abilityname)
* [AbilityCost GetAbilityCost(string abilityName)](#abilitycost-getabilitycoststring-abilityname)
* [bool UnitHasAbility(unit unit, string abilityName)](#bool-unithasabilityunit-unit-string-abilityname)
* [bool UnitTypeHasAbility(string unitType, string abilityName)](#bool-unittypehasabilitystring-unittype-string-abilityname)
* [int GetUnitAbilityCurrentCharge(unit unit, string abilityName)](#int-getunitabilitycurrentchargeunit-unit-string-abilityname)
* [void SetUnitAbilityCooldown(unit unit, string abilityName, float seconds)](#void-setunitabilitycooldownunit-unit-string-abilityname-float-seconds)
* [void SetUnitAbilityMaxCooldown(unit unit, string abilityName, float seconds)](#void-setunitabilitymaxcooldownunit-unit-string-abilityname-float-seconds)
* [void CastAbilityAtUnit(string abilityName, unit caster, unit target, bool immediate)](#void-castabilityatunitstring-abilityname-unit-caster-unit-target-bool-immediate)
* [void CastAbilityEffect(string abilityName, unit caster, unit target)](#void-castabilityeffectstring-abilityname-unit-caster-unit-target)
* [void CancelAbilities(unit unit)](#void-cancelabilitiesunit-unit)
* [void EnterTargetingMode(unit unit, string abilityName)](#void-entertargetingmodeunit-unit-string-abilityname)
* [void ExitTargetingMode()](#void-exittargetingmode)
* [void AddUnitAbility(string unitType, string abilityName)](#void-addunitabilitystring-unittype-string-abilityname)
* [void AddUnitAbilitySync(string unitType, string abilityName)](#void-addunitabilitysyncstring-unittype-string-abilityname)
* [void RemoveUnitAbility(string unitType, string abilityName)](#void-removeunitabilitystring-unittype-string-abilityname)
* [void RemoveUnitAbilitySync(string unitType, string abilityName)](#void-removeunitabilitysyncstring-unittype-string-abilityname)
* [void CastAbilityAtPosition(string abilityName, unit caster, float x, float z, bool immediate)](#void-castabilityatpositionstring-abilityname-unit-caster-float-x-float-z-bool-immediate)
* [void CastAbilityEffectAtPosition(string abilityName, unit caster, float x, float z)](#void-castabilityeffectatpositionstring-abilityname-unit-caster-float-x-float-z)
* [void SetAbilityCurrentCharge(unit unit, string abilityName, int chargeCount, bool clampChargeCount)](#void-setabilitycurrentchargeunit-unit-string-abilityname-int-chargecount-bool-clampchargecount)
|
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
unit
the unit to check for ability status. -
string
abilityName
the name of the ability to check.
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)
Returns the remaining cooldown of a unit's ability.
-
unit
unit
the unit to check for ability cooldown. -
string
abilityName
the 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
end
AbilityCost 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
unit
the unit to check for the ability. -
string
abilityName
the name of the ability to check for.
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)
Returns true if a unit type has an ability.
-
string
unitType
the unit type to check for the ability. -
string
abilityName
the 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)
end
int 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)
end
void 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
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.
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)
Sets the maximum cooldown of an ability on a unit to a specified time in seconds.
-
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.
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)
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
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.
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)
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
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.
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)
end
void 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
unit
the unit to enter targeting mode for. -
string
abilityName
the name of the ability to enter the targeting mode for.
function AbilityButtonPressed(unit, ability)
DCEI.EnterTargetingMode(unit, ability)
end
void ExitTargetingMode()
Exits targeting mode for any abilities currently in targeting mode.
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)
Adds an ability to a unit type.
-
string
unitType
the unit type to add the ability to. -
string
abilityName
the name of the ability to add.
function OnAbilityPurchased(unit_type, ability)
DCEI.AddUnitAbility(unit_type, ability)
end
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
unitType
the unit type to add the ability to. -
string
abilityName
the name of the ability to add.
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)
Removes an ability from a unit type.
-
string
unitType
the unit type to remove the ability from. -
string
abilityName
the name of the ability to remove.
function OnAbilityPurchaseRefunded(unit_type, ability)
DCEI.RemoveUnitAbility(unit_type, ability)
end
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
unitType
the unit type to remove the ability from. -
string
abilityName
the name of the ability to remove.
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)
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
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.
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)
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
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.
--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
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.
function BonusChargeEarned(unit, ability)
local current_charges = DCEI.GetUnitAbilityCurrentCharge(unit, ability)
DCEI.SetAbilityCurrentCharge(unit, ability, current_charges + 1, false)
end