Unit Events

From ArcEmu-Wiki
Revision as of 15:25, 5 September 2010 by Sympathy (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


This is a list of Creature (also known as Unit, but more appropriately named Creature since Unit involves Players and GameObjects) Events. They are fired when certain things happen in the game world. You can utilize these events using RegisterUnitEvent(CreatureID, EventID, Function). The words in parentheses at the end of each line are the arguments that the Lua Engine passes to the function that is registered to this event. For example, if I were to hook a function (Sympathy_OnTakeDamage) to the event 23, said function would be passed pUnit, event, pAttacker and pAmount arguments. For more information, check the RegisterUnitEvent(CreatureID, EventID, Function) page.

function Sympathy_OnTakeDamage(pUnit, _, pAttacker, fAmount)
	-- The Lua Engine passes 4 arguments here.
	-- pUnit: The Creature this function is hooked to.
	-- Event: Usually omitted. In this event (ON_TAKE_DAMAGE), "Event" will ALWAYS assume the value of 23.
	-- pAttacker: The Unit attacking this Creature.
	-- fAmount: The Amount of Damage the Creature took.
	-- Here, I'll deal half the damage the attacker dealt to the Creature back to it using the Lightning Bolt visual, 25449.
	pUnit:DealDamage(pAttacker, (fAmount / 2), 25449)
RegisterUnitEvent(ENTRYID, 23, Sympathy_OnTakeDamage)


	CREATURE_EVENT_ON_ENTER_COMBAT				= 1, 		--(pUnit, event, pAttacker)
	CREATURE_EVENT_ON_LEAVE_COMBAT				= 2,		--(pUnit, event, pLastTarget)
	CREATURE_EVENT_ON_TARGET_DIED				= 3,		--(pUnit, event, pDied)
	CREATURE_EVENT_ON_DIED					= 4,		--(pUnit, event, pLastTarget)
	CREATURE_EVENT_ON_TARGET_PARRIED			= 5,		--(pUnit, event, pTarget)
	CREATURE_EVENT_ON_TARGET_DODGED				= 6,		--(pUnit, event, pTarget)
	CREATURE_EVENT_ON_TARGET_BLOCKED			= 7,		--(pUnit, event, pTarget, pAmount)
	CREATURE_EVENT_ON_TARGET_CRIT_HIT			= 8,		--(pUnit, event, pTarget, pAmount)
	CREATURE_EVENT_ON_PARRY					= 9,		--(pUnit, event, pTarget)
	CREATURE_EVENT_ON_DODGED				= 10,		--(pUnit, event, pTarget)
	CREATURE_EVENT_ON_BLOCKED				= 11,		--(pUnit, event, pTarget, pAmount)
	CREATURE_EVENT_ON_CRIT_HIT				= 12,		--(pUnit, event, pTarget, pAmount)
	CREATURE_EVENT_ON_HIT					= 13,		--(pUnit, event, pTarget, pAmount)
	CREATURE_EVENT_ON_ASSIST_TARGET_DIED			= 14,		--(pUnit, event, pAssistTarget)
	CREATURE_EVENT_ON_FEAR					= 15,		--(pUnit, event, pTarget, pSpell)
	CREATURE_EVENT_ON_FLEE					= 16,		--(pUnit, event, pTarget)
	CREATURE_EVENT_ON_CALL_FOR_HELP				= 17,		--(pUnit, event)
	CREATURE_EVENT_ON_LOAD					= 18,		--(pUnit, event)
	CREATURE_EVENT_ON_REACH_WP				= 19,		--(pUnit, event, pWaypointId, pForwards)
	CREATURE_EVENT_ON_LOOT_TAKEN				= 20,		--(pUnit, event, pPlayer, pItemId)
	CREATURE_EVENT_ON_AIUPDATE				= 21,		--(pUnit, event)
	CREATURE_EVENT_ON_EMOTE					= 22,		--(pUnit, event, pPlayer, pEmote)
	CREATURE_EVENT_ON_DAMAGE_TAKEN 				= 23,		--(pUnit, event, pAttacker, pAmount)
Personal tools