Quantcast
Calculating incoming damage - WoWInterface
Thread Tools Display Modes
03-25-20, 04:06 AM   #1
doofus
A Flamescale Wyrmkin
Join Date: Feb 2018
Posts: 131
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?
  Reply With Quote
03-25-20, 06:13 PM   #2
doofus
A Flamescale Wyrmkin
Join Date: Feb 2018
Posts: 131
Post

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
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Calculating incoming damage

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