View Single Post
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