Trigger API Reference DCEI Functions Behavior0 - BLKTower/TestWiki GitHub Wiki
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
unitthe unit to count the behavior stack count on. -
string
behaviorNamethe 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
unitthe unit to apply the behavior to. -
string
behaviorNamethe name of the behavior to apply. -
count
countthe 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
casterthe unit that the behavior is considered to be the caster and owner of the applied behavior. -
unit
sourcethe unit that the behavior is considered to have originated from. -
unit
targetthe unit to apply the behavior to. -
string
behaviorNamethe name of the behavior to apply. -
count
countthe 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
unitthe unit to remove the behavior from. -
string
behaviorNamethe name of the behavior to remove. -
count
countthe 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
unitthe unit with the behavior on it. -
string
behaviorNamethe name of the behavior to set the duration for. -
float
durationthe duration to set the behavior to. -
bool
extendDurationif 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)