ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Can't make event_combat_event work (https://www.esoui.com/forums/showthread.php?t=1549)

ZunaSW 05/18/14 11:30 AM

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 :)

Iyanga 05/18/14 11:50 AM

Quote:

Originally Posted by ZunaSW (Post 7986)
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?

ZunaSW 05/18/14 12:44 PM

Ahh, true. Thanks.


All times are GMT -6. The time now is 02:51 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI