Trigger API Reference DCEI Functions Behavior0 - BLKTower/TestWiki 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}

int GetUnitBehaviorStackCount(unit unit, string behaviorName)

Description

Returns the stack count of a behavior on a unit.

Parameters

  • unit unit the unit to count the behavior stack count on.
  • string behaviorName the name of the behavior to get the stack count of.

Example Usage

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)

Description

Applies a behavior to a unit.

Parameters

  • 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.

Example Usage

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)

Description

Applies a behavior to a unit with source and caster references

Parameters

  • 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.

Example Usage

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)

Description

Removes a behavior from a unit.

Parameters

  • 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.

Example Usage

-- 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)

Description

Sets the duration of a behavior currently on a unit.

Parameters

  • 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.

Example Usage

-- 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)

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