Trigger API Reference DCEI Functions Behavior0 - funovus/editor-wiki GitHub Wiki
Table of Contents
- [Trigger API Reference\DCEI Functions\Behavior](#trigger-api-referencedcei-functionsbehavior)
* [int GetUnitBehaviorStackCount(unit unit, string behaviorName)](#int-getunitbehaviorstackcountunit-unit-string-behaviorname)
* [void ApplyBehaviorToSelf(unit unit, string behaviorName, int count)](#void-applybehaviortoselfunit-unit-string-behaviorname-int-count)
* [void ApplyBehaviorToUnit(unit caster, unit source, unit target, string behaviorName, int count)](#void-applybehaviortounitunit-caster-unit-source-unit-target-string-behaviorname-int-count)
* [void RemoveBehavior(unit unit, string behaviorName, int count)](#void-removebehaviorunit-unit-string-behaviorname-int-count)
* [void SetBehaviorDuration(unit unit, string behaviorName, float duration, bool extendDuration)](#void-setbehaviordurationunit-unit-string-behaviorname-float-duration-bool-extendduration)
|
Trigger API Reference\DCEI Functions\Behavior {Trigger-API-ReferenceDCEI-FunctionsBehavior}
int GetUnitBehaviorStackCount(unit unit, string behaviorName) {int-GetUnitBehaviorStackCountunit-unit-string-behaviorName}
int GetUnitBehaviorStackCount(unit unit, string behaviorName)
Returns the stack count of a behavior on a unit.
-
unit
unit
the unit to count the behavior stack count on. -
string
behaviorName
the name of the behavior to get the stack count of.
local team_id = 1
local player_id = 1
local unit_type = "Standard MeleeUnit"
local x, y = 16, 16
local test_subject = DCEI.CreateUnitAsync(team_id, player_id, unit_type, x, y)
DCEI.ApplyBehavior(test_subject, "Damage Taken Half", 5)
local stacks = UnitBehaviorStackCount(test_subject, "Damage Taken Half")
DCEI.LogMessage(unit_type .. " has " .. stacks .. " stacks of Damage Taken Half")
void ApplyBehaviorToSelf(unit unit, string behaviorName, int count) {void-ApplyBehaviorToSelfunit-unit-string-behaviorName-int-count}
void ApplyBehaviorToSelf(unit unit, string behaviorName, int count)
-
unit
unit
the unit to apply the behavior to. -
string
behaviorName
the name of the behavior to apply. -
count
count
the number of stacks of the chosen behavior to apply.
local team_id = 1
local player_id = 1
local unit_type = "Standard MeleeUnit"
local x, y = 16, 16
local test_subject = DCEI.CreateUnitAsync(team_id, player_id, unit_type, x, y)
DCEI.ApplyBehaviorToSelf(test_subject, "Damage Taken Half", 2)
local stacks = UnitBehaviorStackCount(test_subject, "Damage Taken Half")
DCEI.LogMessage(unit_type .. " has " .. stacks .. " stacks of Damage Taken Half")
void ApplyBehaviorToUnit(unit caster, unit source, unit target, string behaviorName, int count) {void-ApplyBehaviorToUnitunit-caster-unit-source-unit-target-string-behaviorName-int-count}
void ApplyBehaviorToUnit(unit caster, unit source, unit target, string behaviorName, int count)
Applies a behavior to a unit with source and caster references
-
unit
caster
the unit that the behavior is considered to be the caster and owner of the applied behavior. -
unit
source
the unit that the behavior is considered to have originated from. -
unit
target
the unit to apply the behavior to. -
string
behaviorName
the name of the behavior to apply. -
count
count
the number of stacks of the chosen behavior to apply.
local team_id = 1
local player_id = 1
local enemy_id = -1
local unit_type = "Standard MeleeUnit"
local x, y = 16, 16
local caster = DCEI.CreateUnitAsync(enemy_id, enemy_id, unit_type, x-1, y-1)
local source = caster
local target = DCEI.CreateUnitAsync(team_id, player_id, unit_type, x, y)
DCEI.ApplyBehaviorToUnit(caster, source, target, "Damage Taken Double", 1)
local stacks = UnitBehaviorStackCount(target, "Damage Taken Double")
DCEI.LogMessage(unit_type .. " has " .. stacks .. " stacks of Damage Taken Double")
void RemoveBehavior(unit unit, string behaviorName, int count) {void-RemoveBehaviorunit-unit-string-behaviorName-int-count}
void RemoveBehavior(unit unit, string behaviorName, int count)
Removes a behavior from a unit.
-
unit
unit
the unit to remove the behavior from. -
string
behaviorName
the name of the behavior to remove. -
count
count
the number of stacks of the chosen behavior to remove.
-- create our test subject
local team_id = 1
local player_id = 1
local unit_type = "Standard MeleeUnit"
local x, y = 16, 16
local test_subject = DCEI.CreateUnitAsync(team_id, player_id, unit_type, x, y)
-- apply behavior to them and get the count
DCEI.ApplyBehavior(test_subject, "Damage Taken Half", 3)
local stacks = UnitBehaviorStackCount(test_subject, "Damage Taken Half")
DCEI.LogMessage(unit_type .. " has " .. stacks .. " stacks of Damage Taken Half")
-- remove a stack and get the new count
DCEI.RemoveBehavior(test_subject, "Damage Taken Half", 1)
stacks = UnitBehaviorStackCount(test_subject, "Damage Taken Half")
DCEI.LogMessage(unit_type .. " has " .. stacks .. " stacks of Damage Taken Half")
void SetBehaviorDuration(unit unit, string behaviorName, float duration, bool extendDuration) {void-SetBehaviorDurationunit-unit-string-behaviorName-float-duration-bool-extendDuration}
void SetBehaviorDuration(unit unit, string behaviorName, float duration, bool extendDuration)
Sets the duration of a behavior currently on a unit.
-
unit
unit
the unit with the behavior on it. -
string
behaviorName
the name of the behavior to set the duration for. -
float
duration
the duration to set the behavior to. -
bool
extendDuration
if true, the duration of the behavior is extended by the duration instead of set.
-- Create our test subject
local team_id = 1
local player_id = 1
local unit_type = "Standard MeleeUnit"
local x, y = 16, 16
local test_subject = DCEI.CreateUnitAsync(team_id, player_id, unit_type, x, y)
-- Apply our behavior
DCEI.ApplyBehaviorWithDuration(test_subject, "Damage Taken Half", 3.0, false)
-- extend the duration by a random duration between 0 and 1.5 seconds.
DCEI.SetBehaviorDuration(test_subject, "Damage Taken Half", math.random() * 1.5, true)