Trigger API Reference\DCEI Events\Behavior
TriggerHandle TriggerAddBehaviorStackIncreaseEvent(unit unit, TypedCallback<EffectContext, int> trigger, bool simple = False, BehaviorFilter filter = default)
TriggerHandle TriggerAddBehaviorStackIncreaseEvent(unit unit, TypedCallback<EffectContext, int> trigger, bool simple = False, BehaviorFilter filter = default)
Description
This event triggers when a behavior's stack count increase. This function can also pass the effect context and stack count delta as parameters to the callback function.
Parameters
- unit
unit
the unit that triggers this event. - TypedCallback<EffectContext, int>
trigger
the callback function that is run when the event is triggered. - bool
simple
this flag reduces overhead by preventing the usage of DCEI.Wait() within the trigger. You should only set this to true if the trigger does not use DCEI.Wait(). - BehaviorFilter
filter
could make this event only trigger on certain behaviors
Callback Parameters
- EffectContext
effect_context
- Int32
stack_count_delta
Example Usage
function OnUnitBehaviorIncrease(effect_context, stack_count_delta)
local name = DCEI.TriggeringBehaviorName
local u = DCEI.TriggeringUnit
local unit_type = DCEI.GetUnitType(u)
DCEI.LogMessage(unit_type .. " behavior " .. name .. " increased for a total of " .. stack_count_delta .. " stacks.")
end
DCEI.TriggerAddBehaviorStackIncreaseEvent(DCEI.CreateUnitFilter({name = DCEI.Unit("Test Unit")}), OnUnitBehaviorIncrease, true)
TriggerHandle TriggerAddBehaviorStackDecreaseEvent(unit unit, TypedCallback<EffectContext, int> trigger, bool simple = False, BehaviorFilter filter = default)
TriggerHandle TriggerAddBehaviorStackDecreaseEvent(unit unit, TypedCallback<EffectContext, int> trigger, bool simple = False, BehaviorFilter filter = default)
Description
This event triggers when a behavior's stack count decrease. This function can also pass the effect context and stack count delta as parameters to the callback function.
Parameters
- unit
unit
the unit that triggers this event. - TypedCallback<EffectContext, int>
trigger
the callback function that is run when the event is triggered. - bool
simple
this flag reduces overhead by preventing the usage of DCEI.Wait() within the trigger. You should only set this to true if the trigger does not use DCEI.Wait(). - BehaviorFilter
filter
could make this event only trigger on certain behaviors
Callback Parameters
- EffectContext
effect_context
- Int32
stack_count_delta
Example Usage
function OnUnitBehaviorDecrease(effect_context, stack_count_delta)
local name = DCEI.TriggeringBehaviorName
local u = DCEI.TriggeringUnit
local unit_type = DCEI.GetUnitType(u)
DCEI.LogMessage(unit_type .. " behavior " .. name .. " Decreased for a total of " .. stack_count_delta .. " stacks.")
end
DCEI.TriggerAddBehaviorStackDecreaseEvent(DCEI.CreateUnitFilter({name = DCEI.Unit("Test Unit")}), OnUnitBehaviorDecrease, true)
TriggerHandle TriggerAddBehaviorAddEvent(unit unit, TypedCallback<EffectContext> trigger, bool simple = False, BehaviorFilter filter = default)
TriggerHandle TriggerAddBehaviorAddEvent(unit unit, TypedCallback<EffectContext> trigger, bool simple = False, BehaviorFilter filter = default)
Description
This event triggers when a behavior is added to a unit. This function can also pass the effect context as a parameter to the callback function.
Parameters
- unit
unit
the unit that triggers this event. - TypedCallback<EffectContext>
trigger
the callback function that is run when the event is triggered. - bool
simple
this flag reduces overhead by preventing the usage of DCEI.Wait() within the trigger. You should only set this to true if the trigger does not use DCEI.Wait(). - BehaviorFilter
filter
could make this event only trigger on certain behaviors
Callback Parameters
- EffectContext
effect_context
Example Usage
function OnUnitBehaviorAdd(effect_context)
local name = DCEI.TriggeringBehaviorName
local u = DCEI.TriggeringUnit
local unit_type = DCEI.GetUnitType(u)
local stacks = DCEI.GetUnitBehaviorStackCount(u, name)
DCEI.LogMessage(unit_type .. " had " .. name .. " added for a total of " .. stacks .. " stacks.")
end
DCEI.TriggerAddBehaviorAddEvent(DCEI.CreateUnitFilter({name = DCEI.Unit("Test Unit")}), OnUnitBehaviorAdd, true)
Related
TriggerHandle TriggerAddBehaviorExpireEvent(unit unit, TypedCallback trigger, bool simple = False, BehaviorFilter filter = default)
TriggerHandle TriggerAddBehaviorExpireEvent(unit unit, TypedCallback trigger, bool simple = False, BehaviorFilter filter = default)
Description
This event triggers when a behavior expires on a unit.
Parameters
- unit
unit
the unit that triggers this event. - TypedCallback
trigger
the callback function that is run when the event is triggered. - bool
simple
this flag reduces overhead by preventing the usage of DCEI.Wait() within the trigger. You should only set this to true if the trigger does not use DCEI.Wait(). - BehaviorFilter
filter
could make this event only trigger on certain behaviors
Example Usage
function OnUnitBehaviorExpire()
local name = DCEI.TriggeringBehaviorName
local u = DCEI.TriggeringUnit
local unit_type = DCEI.GetUnitType(u)
DCEI.LogMessage(unit_type .. " lost " .. name .. " .")
end
DCEI.TriggerAddBehaviorExpireEvent(DCEI.CreateUnitFilter({name = DCEI.Unit("Test Unit")}), OnUnitBehaviorExpire, true)
Related
TriggerHandle TriggerAddBehaviorDisabledEvent(unit unit, TypedCallback trigger, bool simple = False, BehaviorFilter filter = default)
TriggerHandle TriggerAddBehaviorDisabledEvent(unit unit, TypedCallback trigger, bool simple = False, BehaviorFilter filter = default)
Description
This event triggers when a unit has a behavior on it is disabled. Use TriggeringBehaviorName to get the behavior that triggered the event.
Parameters
- unit
unit
the unit that triggers this event. - TypedCallback
trigger
the callback function that is run when the event is triggered. - bool
simple
this flag reduces overhead by preventing the usage of DCEI.Wait() within the trigger. You should only set this to true if the trigger does not use DCEI.Wait(). - BehaviorFilter
filter
could make this event only trigger on certain behaviors
Example Usage
function OnUnitBehaviorDisable()
local name = DCEI.TriggeringBehaviorName
local u = DCEI.TriggeringUnit
local unit_type = DCEI.GetUnitType(u)
local stacks = DCEI.GetUnitBehaviorStackCount(u, name)
DCEI.LogMessage(stacks .. " stacks of " .. name .. " no long have any effect on " .. unit_type ..".")
end
DCEI.TriggerAddBehaviorDisabledEvent(DCEI.CreateUnitFilter({name = DCEI.Unit("Test Unit")}), OnUnitBehaviorDisable, true)
Related
TriggerHandle TriggerAddBehaviorEnabledEvent(unit unit, TypedCallback trigger, bool simple = False, BehaviorFilter filter = default)
TriggerHandle TriggerAddBehaviorEnabledEvent(unit unit, TypedCallback trigger, bool simple = False, BehaviorFilter filter = default)
Description
This event is triggered when a unit has a behavior on it enabled. Use TriggeringBehaviorName to figure out which behavior triggered the event.
Parameters
- unit
unit
the unit that triggers this event. - TypedCallback
trigger
the callback function that is run when the event is triggered. - bool
simple
this flag reduces overhead by preventing the usage of DCEI.Wait() within the trigger. You should only set this to true if the trigger does not use DCEI.Wait(). - BehaviorFilter
filter
could make this event only trigger on certain behaviors
Example Usage
function OnUnitBehaviorEnable()
local name = DCEI.TriggeringBehaviorName
local u = DCEI.TriggeringUnit
local unit_type = DCEI.GetUnitType(u)
local stacks = DCEI.GetUnitBehaviorStackCount(u, name)
DCEI.LogMessage(stacks .. " stacks of " .. name .. " on " .. unit_type .. " now work.")
end
DCEI.TriggerAddBehaviorEnabledEvent(DCEI.CreateUnitFilter({name = DCEI.Unit("Test Unit")}), OnUnitBehaviorEnable, true)
Related
TriggerHandle TriggerAddBehaviorRemoveEvent(unit unit, TypedCallback trigger, bool simple = False, BehaviorFilter filter = default)
TriggerHandle TriggerAddBehaviorRemoveEvent(unit unit, TypedCallback trigger, bool simple = False, BehaviorFilter filter = default)
Description
This event is triggered when a unit has a behavior on it removed.
Parameters
- unit
unit
the unit that triggers this event. - TypedCallback
trigger
the callback function that is run when the event is triggered. - bool
simple
this flag reduces overhead by preventing the usage of DCEI.Wait() within the trigger. You should only set this to true if the trigger does not use DCEI.Wait(). - BehaviorFilter
filter
could make this event only trigger on certain behaviors
Example Usage
function OnUnitBehaviorRemove()
local name = DCEI.TriggeringBehaviorName
local u = DCEI.TriggeringUnit
local unit_type = DCEI.GetUnitType(u)
DCEI.LogMessage(name .. " was removed from " .. unit_type .. ".")
end
DCEI.TriggerAddBehaviorRemoveEvent(DCEI.CreateUnitFilter({name = DCEI.Unit("Test Unit")}), OnUnitBehaviorRemove, true)