Trigger API Reference\DCEI Events\Effect

void TriggerAddEffectEvent(string effectName, TypedCallback<EffectContext> trigger, bool simple = False)

void TriggerAddEffectEvent(string effectName, TypedCallback<EffectContext> trigger, bool simple = False)

Description


This event is triggered when an effect occurs. Use TriggeringEffectName and TriggeringEffectContext to get the name and context of the effect. This function can also pass the effect context as a parameter to the callback function.

Parameters

Callback Parameters

Example Usage

function OnDoNothing(effect_context)
    local context = DCEI.TriggeringEffectContext
    local caster_name = DCEI.GetUnitType(context.caster)
    local source_name = DCEI.GetUnitType(context.source)
    local target_name = DCEI.GetUnitType(context.target)

    DCEI.LogMessage(caster_name .. " did nothing to " .. target_name .. " via " .. source_name .. ".")
end

DCEI.TriggerAddEffectEvent(DCEI.Effect("DoNothing"), OnDoNothing, true)

void TriggerAddEffectHookEvent(string effectName, TypedCallback<EffectContext> trigger, bool simple = False)

void TriggerAddEffectHookEvent(string effectName, TypedCallback<EffectContext> trigger, bool simple = False)

Description


Effect hooks allow you to intercept an effect and modify the data before executing it during Lua run-time. In the following example, this effect hook intercepts a launch missile effect to make it use the very unit it’s attacking as the missile for the Launch Missile effect. See Using Effect Hooks

Parameters

Callback Parameters

Example Usage

DCEI.TriggerAddEffectHookEvent(
    DCEI.Effect("Standard RangedUnit Weapon Launch"),
    function(context)
        if DCEI.EvaluateEffectHookExpression("RandomChance 100%") ~= 0 then
            local field_path = {"launchMissile", "missileUnit"}
            local missile_unit = DCEI.GetUnitType(context.target)
            DCEI.SetEffectHookFieldValue(field_path, missile_unit)
        end
    end
)