WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Calculating incoming damage (https://www.wowinterface.com/forums/showthread.php?t=57886)

doofus 03-25-20 04:06 AM

Calculating incoming damage
 
Apologies if I have asked this before (I did a search, could not find it).

I would like to get an idea of incoming damage onto a player, before heals and other absorbs that do not tick regularly. I do not want to have to parse the combat log and my calculation needs only to be approximate.

Eg Armor and Stagger are always on, reduce incoming damage, and have to be reckoned with. However a player's heal is not guaranteed, regular or constant and I do not want to figure it in.

The very easy solution is to look at player's HP over time and deduce incoming damage. That figure however would be skewed by heals received and other (one time) effects (eg a HP potion).

For the Monk I thought I could look into the Stagger amount and stagger % which I can read programmatically and from there deduce incoming damage.

But I would like a general method where I can do it using API calls rather than parsing combat log, as mentioned above. Can you help?

doofus 03-25-20 06:13 PM

To answer my own question, in the end I parsed the Combat log, first attempt, has not been tested, maybe there are more incoming damage categories.

Code:


-- pseudo code
"COMBAT_LOG_EVENT_UNFILTERED"
  CombatLogGetCurrentEventInfo()


local function BA_AE_ProcessCombatLogEvent( current event info  )
  local playerGUID = UnitGUID("player");
  local timestamp, subevent, _, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = ...
 
  if ( sourceGUID ~= playerGUID and destGUID ~= playerGUID ) then
    return;
  end

  -- incoming damage
  if ( destGUID == playerGUID and destGUID ~= sourceGUID
  ) then
    local spellId, spellName, spellSchool;
    local amount = 0;
    if ( subevent == "SPELL_DAMAGE"
    ) then
      spellId, spellName, spellSchool, amount = select(12, ...)   
    end
    if ( subevent == "SWING_DAMAGE"
    ) then
      amount = select(12, ...);
    end
    if ( amount > 0 ) then
      local timeNow = GetTime();
      rawIncomingDamage[#rawIncomingDamage+1] = { amount, timeNow };
    end
   
  end
 
end

I basically store incoming damage amounts into an array which I then scan over a specific period of time to determine incoming damage.

Code:

local function BA_AE_IncomingDamage( timePeriod )
  local timeNow = GetTime();
  local incomingDamage = 0;
  for i = 1, #rawIncomingDamage do
    local timeRecorded = rawIncomingDamage[i][2];
    if ( timeNow - timeRecorded <= timePeriod  ) then
      incomingDamage = incomingDamage + rawIncomingDamage[i][1];
    end
  end
  return incomingDamage;
end



All times are GMT -6. The time now is 08:18 PM.

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