View Single Post
02/27/23, 10:38 AM   #3
mgsnakes
AddOn Author - Click to view addons
Join Date: Mar 2022
Posts: 5
Originally Posted by Baertram View Post
Did you check on your player that this debuf is actually shown at the player as a buff?
if the buff is not there you cannot listen for it at the events.
If you click C to show the player buffs it shows you all the buffs you currently got, as names. The abilityIds of them are not shown.

You either need an addon like Srendar and enable the debug to show the current player buffs ids behind the name.
Or you can list them to chat via some code like this (by e.g. using a slash command /playerbuffs that runs this function "ShowPlayerBuffs"):

Lua Code:
  1. function ShowPlayerBuffs(unitTag)
  2.     unitTag = unitTag or "player"
  3.     local entries = {}
  4.     table.insert(entries, "================ START OF PLAYER BUFFs ===============")
  5.     table.insert(entries, zo_strformat("\"<<1>>\" Buffs:", unitTag))
  6.     local buffName, abilityId, _
  7.     local numBuffs = GetNumBuffs(unitTag)
  8.     if numBuffs > 0 then
  9.         for i = 1, numBuffs do
  10.             buffName, _, _, _, _, _, _, _, _, _, abilityId = GetUnitBuffInfo(unitTag, i)
  11.             table.insert(entries, zo_strformat("<<1>>. [<<2>>] <<C:3>>", i, abilityId, ZO_SELECTED_TEXT:Colorize(buffName)))
  12.         end
  13.     else
  14.         table.insert(entries, "<NO buffs active!")
  15.     end
  16.     table.insert(entries, "================ END OF PLAYER BUFFs ===============")
  17.  
  18.     if #entries > 0 then
  19.         for _, entryText in ipairs(entries) do
  20.             d(entryText)
  21.         end
  22.     end
  23. end
  24.  
  25. SLASH_COMMANDS["/playerbuffs"] = function() ShowPlayerBuffs("player") end


If you have found the correct abilityId or buffId that is shown as the playerbuff you can then simply do a test via an event
EVENT_EFFECT_CHANGED using a filter like this, to react on it:

Lua Code:
  1. local function OnCinderShotEffectChanged(eventId, changeType, effectSlot, effectName, unitTag, beginTime, endTime, stackCount, iconName, buffType, effectType, abilityType, statusEffectType, unitName, unitId, abilityId, sourceType)
  2.  if changeType == EFFECT_RESULT_GAINED or changeType == EFFECT_RESULT_UPDATED then --buff was gained or it updated
  3.    d(">CinderShot effect GAINED as player buff!")
  4.  elseif changeType == EFFECT_RESULT_FADED then
  5.    d("<CinderShot effect LOST AGAIN as player buff!")
  6.  end
  7. end
  8.  
  9. local abilityIdOfTheCinderShotBuff =  ????? --enter the number of the abilityId here which is shown as player buff as you got it
  10.  
  11. EVENT_MANAGER:RegisterForEvent("MyAddonTest1", EVENT_EFFECT_CHANGED, OnCinderShotEffectChanged)
  12. EVENT_MANAGER:AddFilterForEvent("MyAddonTest1", EVENT_EFFECT_CHANGED, REGISTER_FILTER_ABILITY_ID, abilityIdOfTheCinderShotBuff) --will only filter for the cinderShot buffid!
  13. EVENT_MANAGER:AddFilterForEvent("MyAddonTest1", EVENT_EFFECT_CHANGED, REGISTER_FILTER_UNIT_TAG, "player") --will only find it on yourself, the player!




Edit:
I'm not sure where you got that
ACTION_RESULT_EFFECT_GAINED
constant from but in teh current API the 2nd parameter of the EVET_EFFECT_CHANGED event is using the type EffectResult which can be one of these:
Code:
h5. EffectResult
* EFFECT_RESULT_FADED
* EFFECT_RESULT_FULL_REFRESH
* EFFECT_RESULT_GAINED
* EFFECT_RESULT_TRANSFER
* EFFECT_RESULT_UPDATED
Hello, yes I already did a test with Srandarr & CMX to get the debuff ID : 170392.
When I'm alone in the instance, I only have this debuff that appears but when we are a complete group, and 4 players can have the debuff simultaneously, there are these 4 IDs: 170401, 170399, 170396, 170392.

For ACTION_RESULT_EFFECT_GAINED, this is what is used in Code Combat Alert for the sound alert https://prnt.sc/wSdnl20zhiN7 I just copied a functional code to adapt it to what I wanted in the Qcell addon

EDIT: I tried the test code you provided https://prnt.sc/NvUHjnTvnI_o

Last edited by mgsnakes : 02/27/23 at 10:54 AM.
  Reply With Quote