Thread Tools Display Modes
05/18/14, 11:30 AM   #1
ZunaSW
Join Date: Mar 2014
Posts: 37
Can't make event_combat_event work

Hi again, sorry my english. I'm trying to make something happens when the enemy hits the player, and I have this code now:

Code:
local function MyEventOnHit(result, isError, abilityName, abilityGraphic, abilityActionSlotType, sourceName, sourceType, targetName, targetType, hitValue, powerType, damageType, log)
end
  local wm = GetWindowManager()
  local t = wm:CreateTopLevelWindow(nil)
  t:SetDimensions(32,32)
  t:SetAnchor(CENTER,GuiRoot,CENTER,0,0)
  Tex = wm:CreateControl(nil, t, CT_TEXTURE)
  Tex:SetTexture("TestAddon/textures/tex.dds")
  Tex:SetAnchorFill(t)
  Tex:SetHidden(true)

EVENT_MANAGER:RegisterForEvent(name, EVENT_COMBAT_EVENT, MyEventOnHit)

function MyEventOnHit( eventCode , result , isError , abilityName, abilityGraphic, abilityActionSlotType, sourceName, sourceType, targetName, targetType, hitValue, powerType, damageType, log )
	if targetType == COMBAT_UNIT_TYPE_OTHER then
		if damageType == DAMAGE_TYPE_COLD or
		damageType == DAMAGE_TYPE_DISEASE or
		damageType == DAMAGE_TYPE_DROWN or
		damageType == DAMAGE_TYPE_EARTH or
		damageType == DAMAGE_TYPE_FIRE or
		damageType == DAMAGE_TYPE_GENERIC or
		damageType == DAMAGE_TYPE_MAGIC or
		damageType == DAMAGE_TYPE_NONE or
		damageType == DAMAGE_TYPE_OBLIVION or
		damageType == DAMAGE_TYPE_PHYSICAL or
		damageType == DAMAGE_TYPE_POISON or
		damageType == DAMAGE_TYPE_SHOCK then
			Tex:SetHidden(false)
		end
	end
end
NOTE: The texture it's just a test to see if it works.

What I want to do is when an enemy (all type of enemies) hits the player, with any damage type, something happen. I don't know if I'm doing this right with that code above. Also, I'm not sure if the targetType it's ok or not. But when I enter the game, and make an enemy attacks me and hits me, nothing happens :/ I'm not really sure I'm doing this right. Can someone help me?
Thank you
  Reply With Quote
05/18/14, 11:50 AM   #2
Iyanga
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 183
Originally Posted by ZunaSW View Post
Lua Code:
  1. local function MyEventOnHit(result, isError, abilityName, abilityGraphic, abilityActionSlotType, sourceName, sourceType, targetName, targetType, hitValue, powerType, damageType, log)
  2. end
  3.  
  4. EVENT_MANAGER:RegisterForEvent(name, EVENT_COMBAT_EVENT, MyEventOnHit)
In the code you posted you have a local function that does nothing, because there is nothing written between "function" and "end" and a global function with the very same name.

What result do you expect?
  Reply With Quote
05/18/14, 12:44 PM   #3
ZunaSW
Join Date: Mar 2014
Posts: 37
Ahh, true. Thanks.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Can't make event_combat_event work

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off