Callback Usage

Registering Events

This library uses CallbackHandler-1.0, so registering for an event is as easy as:

local luc = LibStub("LibUnitControl-1.0")

function MyAddon:UnitGainControl(unitID)
  DEFAULT_CHAT_FRAME:AddMessage( UnitName(unitID) .. " has gained control of their character!" )
end

function MyAddon:UnitLostControl(unitID)
  DEFAULT_CHAT_FRAME:AddMessage( UnitName(unitID) .. " has lost control of their character!" )
end

function MyAddon:Initialize()
  luc.RegisterCallback(self, "LUC_UNIT_GAIN_CONTROL", "UnitGainControl")
  luc.RegisterCallback(self, "LUC_UNIT_LOST_CONTROL", "UnitLostControl")
end

Unit Aura Events

These events are triggered when a unit gains or loses control of their character (by being stunned, feared, charmed, etc...).

Events

LUC_UNIT_GAIN_AURA
LUC_UNIT_LOST_AURA

Args

unitID
The unit id (player, pet, etc...).
spellID
The spells global id.
spellName
The name of the spell.
spellMask
The spell's modifier bitmask.


Unit Mod Events

These events are triggered when a unit gains or loses an aura which has effects that modify the status of the character (such as being disarmed, snared, stunned, etc...).

Events

LUC_UNIT_GAIN_MOD
LUC_UNIT_LOST_MOD

Args

unitID
The unit id (player, pet, etc...).
effectMask
The effect's modifier bitmask.
effectName
The name of the spell effect modifier.


Unit Mod Specific Events

These events are triggered when a unit gains or loses an aura which has effects that correspond to the events name.

Events

LUC_UNIT_GAIN_MOD_BANISH
LUC_UNIT_GAIN_MOD_CHARM
LUC_UNIT_GAIN_MOD_CONFUSE
LUC_UNIT_GAIN_MOD_DISARM
LUC_UNIT_GAIN_MOD_DISARM_MH
LUC_UNIT_GAIN_MOD_DISARM_OH
LUC_UNIT_GAIN_MOD_DISARM_RS
LUC_UNIT_GAIN_MOD_DISORIENT
LUC_UNIT_GAIN_MOD_FEAR
LUC_UNIT_GAIN_MOD_FREEZE
LUC_UNIT_GAIN_MOD_HORRIFY
LUC_UNIT_GAIN_MOD_INCAPACITATE
LUC_UNIT_GAIN_MOD_NOCONTROL
LUC_UNIT_GAIN_MOD_PACIFY
LUC_UNIT_GAIN_MOD_POLYMORPH
LUC_UNIT_GAIN_MOD_ROOT
LUC_UNIT_GAIN_MOD_SAP
LUC_UNIT_GAIN_MOD_SHACKLE
LUC_UNIT_GAIN_MOD_SILENCE
LUC_UNIT_GAIN_MOD_SLEEP
LUC_UNIT_GAIN_MOD_SNARE
LUC_UNIT_GAIN_MOD_STUN
LUC_UNIT_GAIN_MOD_TURN
LUC_UNIT_LOST_MOD_BANISH
LUC_UNIT_LOST_MOD_CHARM
LUC_UNIT_LOST_MOD_CONFUSE
LUC_UNIT_LOST_MOD_DISARM
LUC_UNIT_LOST_MOD_DISARM_MH
LUC_UNIT_LOST_MOD_DISARM_OH
LUC_UNIT_LOST_MOD_DISARM_RS
LUC_UNIT_LOST_MOD_DISORIENT
LUC_UNIT_LOST_MOD_FEAR
LUC_UNIT_LOST_MOD_FREEZE
LUC_UNIT_LOST_MOD_HORRIFY
LUC_UNIT_LOST_MOD_INCAPACITATE
LUC_UNIT_LOST_MOD_NOCONTROL
LUC_UNIT_LOST_MOD_PACIFY
LUC_UNIT_LOST_MOD_POLYMORPH
LUC_UNIT_LOST_MOD_ROOT
LUC_UNIT_LOST_MOD_SAP
LUC_UNIT_LOST_MOD_SHACKLE
LUC_UNIT_LOST_MOD_SILENCE
LUC_UNIT_LOST_MOD_SLEEP
LUC_UNIT_LOST_MOD_SNARE
LUC_UNIT_LOST_MOD_STUN
LUC_UNIT_LOST_MOD_TURN

Args

guid
The unit's GUID.
effectMask
The effect's modifier bitmask.


Unit Control Events

These events are triggered when a unit gains or loses control of their character (by being stunned, feared, charmed, etc...).

Events

LUC_UNIT_GAIN_CONTROL
LUC_UNIT_LOST_CONTROL

Args

unitID
The unit id (player, pet, etc...).
effectMask
The effect's modifier bitmask.


GUID Aura Events

These events are triggered when a unit gains or loses control of their character (by being stunned, feared, charmed, etc...).

Events

LUC_GUID_GAIN_AURA
LUC_GUID_LOST_AURA

Args

unitID
The unit's GUID.
spellID
The spells global id.
spellName
The name of the spell.
spellMask
The spell's modifier bitmask.


GUID Mod Events

These events are triggered when a unit gains or loses an aura which has effects that modify the status of the character (such as being disarmed, snared, stunned, etc...). Note: This event may not trigger even though LUC_GUID_*_AURA already has. This is because the current GUID does not have an associated unitID (party1, pettarget, etc...).

Events

LUC_GUID_GAIN_MOD
LUC_GUID_LOST_MOD

Args

guid
The unit's GUID.
effectMask
The effect's modifier bitmask.
effectName
The name of the spell effect modifier.


GUID Mod Specific Events

These events are triggered when a unit gains or loses an aura which has effects that correspond to the events name. Note: This event may not trigger even though LUC_GUID_*_AURA already has. This is because the current GUID does not have an associated unitID (party1, pettarget, etc...).

Events

LUC_GUID_GAIN_MOD_BANISH
LUC_GUID_GAIN_MOD_CHARM
LUC_GUID_GAIN_MOD_CONFUSE
LUC_GUID_GAIN_MOD_DISARM
LUC_GUID_GAIN_MOD_DISARM_MH
LUC_GUID_GAIN_MOD_DISARM_OH
LUC_GUID_GAIN_MOD_DISARM_RS
LUC_GUID_GAIN_MOD_DISORIENT
LUC_GUID_GAIN_MOD_FEAR
LUC_GUID_GAIN_MOD_FREEZE
LUC_GUID_GAIN_MOD_HORRIFY
LUC_GUID_GAIN_MOD_INCAPACITATE
LUC_GUID_GAIN_MOD_NOCONTROL
LUC_GUID_GAIN_MOD_PACIFY
LUC_GUID_GAIN_MOD_POLYMORPH
LUC_GUID_GAIN_MOD_ROOT
LUC_GUID_GAIN_MOD_SAP
LUC_GUID_GAIN_MOD_SHACKLE
LUC_GUID_GAIN_MOD_SILENCE
LUC_GUID_GAIN_MOD_SLEEP
LUC_GUID_GAIN_MOD_SNARE
LUC_GUID_GAIN_MOD_STUN
LUC_GUID_GAIN_MOD_TURN
LUC_GUID_LOST_MOD_BANISH
LUC_GUID_LOST_MOD_CHARM
LUC_GUID_LOST_MOD_CONFUSE
LUC_GUID_LOST_MOD_DISARM
LUC_GUID_LOST_MOD_DISARM_MH
LUC_GUID_LOST_MOD_DISARM_OH
LUC_GUID_LOST_MOD_DISARM_RS
LUC_GUID_LOST_MOD_DISORIENT
LUC_GUID_LOST_MOD_FEAR
LUC_GUID_LOST_MOD_FREEZE
LUC_GUID_LOST_MOD_HORRIFY
LUC_GUID_LOST_MOD_INCAPACITATE
LUC_GUID_LOST_MOD_NOCONTROL
LUC_GUID_LOST_MOD_PACIFY
LUC_GUID_LOST_MOD_POLYMORPH
LUC_GUID_LOST_MOD_ROOT
LUC_GUID_LOST_MOD_SAP
LUC_GUID_LOST_MOD_SHACKLE
LUC_GUID_LOST_MOD_SILENCE
LUC_GUID_LOST_MOD_SLEEP
LUC_GUID_LOST_MOD_SNARE
LUC_GUID_LOST_MOD_STUN
LUC_GUID_LOST_MOD_TURN

Args

guid
The unit's GUID.
effectMask
The effect's modifier bitmask.


GUID Control Events

These events are triggered when a unit gains or loses control of their character (by being stunned, feared, charmed, etc...). Note: This event may not trigger even though LUC_GUID_*_AURA already has. This is because the current GUID does not have an associated unitID (party1, pettarget, etc...).

Events

LUC_GUID_GAIN_CONTROL
LUC_GUID_LOST_CONTROL

Args

guid
The unit's GUID.
effectMask
The effect's modifier bitmask.