View Single Post
01/09/16, 11:27 AM   #9
coolmodi
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 47
Originally Posted by sirinsidiator View Post
Like you said, only players seem to have the 'x', but I wouldn't count on normal mobs not having a gender tag. For example the generic resource guards in Cyrodiil have names like "Covenant Honor Guard^M".
Mmh, then I'll filter for ^ and x to make it less suscebtible to errors.

Originally Posted by sirinsidiator View Post
The question is, why do you even need the function you posted?
You can easily get that information without keeping a list.
The COMBAT_EVENT doesn't give names or anything if you aren't source or target, so I can only collect information by unitId, and therefore need to collect names and group state (and why not player too) independent of it, and then assign names and group/player flags to the Ids if they become available. The extra unitList is needed because currentFightData is cleared for every new fight, and now I can just assign info to known IDs immediately with:

Lua Code:
  1. if self.unitList[unit] ~= nil then
  2.             values["name"] = self.unitList[unit]["name"]
  3.             values["player"] = self.unitList[unit]["player"]
  4.             values["group"] = self.unitList[unit]["group"]
  5.         end

It would ofc be possible to get rid of unitList, but then I'd need to handle everything in currentFightData and keep every unit info in for every new fight, effectively having useless info in the combatHistory, and it's also easier to handle changing IDs that way, as it only needs to be updated in unitList and every new fight will just use correct info.

Those are the event handlers if that helps to understand my thought process:

Lua Code:
  1. function GroupDamage.onCombatEvent(_, result, isError, _, _, _, sourceName, sourceType, targetName, targetType, hitValue, _, _, _, sourceUnitId, targetUnitId, abilityId)      
  2.     if isError then return end
  3.    
  4.     GroupDamage:UpdateUnitList(sourceUnitId, sourceName, sourceType)
  5.     GroupDamage:UpdateUnitList(targetUnitId, targetName, targetType)
  6.    
  7.     local isHeal = result==ACTION_RESULT_HEAL or result==ACTION_RESULT_CRITICAL_HEAL or result==ACTION_RESULT_HOT_TICK or result==ACTION_RESULT_HOT_TICK_CRITICAL
  8.     local isDamage = result==ACTION_RESULT_BLOCKED_DAMAGE or result==ACTION_RESULT_DAMAGE or result==ACTION_RESULT_CRITICAL_DAMAGE or result==ACTION_RESULT_DOT_TICK or result==ACTION_RESULT_DOT_TICK_CRITICAL or result==ACTION_RESULT_DAMAGE_SHIELDED   
  9.    
  10.     --only go on if it's an actual hit event
  11.     if (not isDamage and not isHeal) or abilityId == 41467 or abilityId == 57466 or abilityId == 57468 or hitValue < 2 then return end
  12.     local isCrit = result==ACTION_RESULT_CRITICAL_DAMAGE or result==ACTION_RESULT_CRITICAL_HEAL or result==ACTION_RESULT_DOT_TICK_CRITICAL or result==ACTION_RESULT_HOT_TICK_CRITICAL  
  13.     local hit = {
  14.         ["sourceId"]    = sourceUnitId,
  15.         ["targetId"]    = targetUnitId,
  16.         ["hitValue"]    = hitValue,
  17.         ["abilityId"]   = abilityId,
  18.         ["crit"]        = isCrit,
  19.         ["heal"]        = isHeal,
  20.         ["timeMs"]      = GetGameTimeMilliseconds()
  21.     }
  22.  
  23.     GroupDamage:Proces****Event(hit)
  24. end
  25.  
  26. function GroupDamage.onEffectChanged(_, _, _, _, unitTag, _, _, _, _, _, _, _, _, unitName, unitId, _) 
  27.     if unitTag:match("group") ~= nil then
  28.         unitTag = 3
  29.     end
  30.     GroupDamage:UpdateUnitList(unitId, unitName, unitTag)
  31. end

Edit: Also, is there any difference between using match and find to see if a string contains something? Both are not nil in that case, but find returns start and end while match returns the word(s), right?

Last edited by coolmodi : 01/09/16 at 11:57 AM.
  Reply With Quote