# Method Global:RegisterCreatureEvent [-] [+]

Registers a Creature event handler.

    enum CreatureEvents
    {
        CREATURE_EVENT_ON_ENTER_COMBAT                    = 1,  // (event, creature, target) - Can return true to stop normal action
        CREATURE_EVENT_ON_ENTER_EVADE_MODE                = 2,  // (event, creature) - Can return true to stop normal action
        CREATURE_EVENT_ON_TARGET_DIED                     = 3,  // (event, creature, victim) - Can return true to stop normal action
        CREATURE_EVENT_ON_DIED                            = 4,  // (event, creature, killer) - Can return true to stop normal action
        CREATURE_EVENT_ON_SPAWN                           = 5,  // (event, creature) - Can return true to stop normal action
        CREATURE_EVENT_ON_REACH_WP                        = 6,  // (event, creature, type, id) - Can return true to stop normal action
        CREATURE_EVENT_ON_AIUPDATE                        = 7,  // (event, creature, diff) - Can return true to stop normal action
        CREATURE_EVENT_ON_RECEIVE_EMOTE                   = 8,  // (event, creature, player, emoteid) - Can return true to stop normal action
        CREATURE_EVENT_ON_DAMAGE_TAKEN                    = 9,  // (event, creature, attacker, damage, damageSchoolMask, spellInfo) - Can return new damage
        CREATURE_EVENT_ON_PRE_COMBAT                      = 10, // (event, creature, target) - Can return true to stop normal action
        CREATURE_EVENT_ON_ATTACKER_STATE_UPDATE           = 11, // (event, creature, target) - Can return true to stop normal action
        CREATURE_EVENT_ON_OWNER_ATTACKED                  = 12, // (event, creature, target) - Can return true to stop normal action            // Not on mangos
        CREATURE_EVENT_ON_OWNER_ATTACKED_AT               = 13, // (event, creature, attacker) - Can return true to stop normal action          // Not on mangos
        CREATURE_EVENT_ON_HIT_BY_SPELL                    = 14, // (event, creature, caster, spellid) - Can return true to stop normal action
        CREATURE_EVENT_ON_SPELL_HIT_TARGET                = 15, // (event, creature, target, spellid) - Can return true to stop normal action
        // UNUSED                                         = 16, // (event, creature)
        // UNUSED                                         = 17, // (event, creature)
        // UNUSED                                         = 18, // (event, creature)
        CREATURE_EVENT_ON_JUST_SUMMONED_CREATURE          = 19, // (event, creature, summon) - Can return true to stop normal action
        CREATURE_EVENT_ON_SUMMONED_CREATURE_DESPAWN       = 20, // (event, creature, summon) - Can return true to stop normal action
        CREATURE_EVENT_ON_SUMMONED_CREATURE_DIED          = 21, // (event, creature, summon, killer) - Can return true to stop normal action    // Not on mangos
        CREATURE_EVENT_ON_SUMMONED                        = 22, // (event, creature, summoner) - Can return true to stop normal action
        CREATURE_EVENT_ON_RESET                           = 23, // (event, creature)
        CREATURE_EVENT_ON_REACH_HOME                      = 24, // (event, creature) - Can return true to stop normal action
        // UNUSED                                         = 25, // (event, creature)
        CREATURE_EVENT_ON_CORPSE_REMOVED                  = 26, // (event, creature, respawndelay) - Can return true to stop normal action, can return new respawndelay as second return value
        CREATURE_EVENT_ON_MOVE_IN_LOS                     = 27, // (event, creature, unit) - Can return true to stop normal action. Does not actually check LOS, just uses the sight range
        // UNUSED                                         = 28, // (event, creature)
        // UNUSED                                         = 29, // (event, creature)
        CREATURE_EVENT_ON_DUMMY_EFFECT                    = 30, // (event, caster, spellid, effindex, creature)
        CREATURE_EVENT_ON_QUEST_ACCEPT                    = 31, // (event, player, creature, quest) - Can return true
        // UNUSED                                         = 32, // (event, creature)
        // UNUSED                                         = 33, // (event, creature)
        CREATURE_EVENT_ON_QUEST_REWARD                    = 34, // (event, player, creature, quest, opt) - Can return true
        CREATURE_EVENT_ON_DIALOG_STATUS                   = 35, // (event, player, creature)
        CREATURE_EVENT_ON_ADD                             = 36, // (event, creature)
        CREATURE_EVENT_ON_REMOVE                          = 37, // (event, creature)
        CREATURE_EVENT_ON_SPELL_CAST                      = 38, // (event, creature, spell, skipCheck)
        CREATURE_EVENT_ON_CAN_START_ATTACK                = 39, // (event, creature, target) - Can return false to stop normal action.
        CREATURE_EVENT_ON_SEND_LIST_INVENTORY             = 40, // (event, creature, target) - Can return false to stop normal action.
    };

## Synopsis

`cancel = RegisterCreatureEvent( entry, event, function )`

`cancel = RegisterCreatureEvent( entry, event, function, shots )`

## Arguments

`number entry`

  The ID of one or more Creatures.

  Valid numbers: integers from 0 to 4,294,967,295.

`number event`

  Refer to CreatureEvents above.

  Valid numbers: integers from 0 to 4,294,967,295.

`function function`

  Function that will be called when the event occurs.

`number shots (0)`

  The number of times the function will be called, 0 means "always call this function".

  Valid numbers: integers from 0 to 4,294,967,295.

## Returns

`function cancel`

  A function that cancels the binding when called.

# Keyboard shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result

# Search tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct` (or `str`), `enum`, `trait`, `typedef` (or `tdef`).

Generated on
© 2010 - 2024 Eluna Lua Engine