Originally Posted by sirinsidiator
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
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:
if self.unitList[unit] ~= nil then
values["name"] = self.unitList[unit]["name"]
values["player"] = self.unitList[unit]["player"]
values["group"] = self.unitList[unit]["group"]
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:
function GroupDamage.onCombatEvent(_, result, isError, _, _, _, sourceName, sourceType, targetName, targetType, hitValue, _, _, _, sourceUnitId, targetUnitId, abilityId)
if isError then return end
GroupDamage:UpdateUnitList(sourceUnitId, sourceName, sourceType)
GroupDamage:UpdateUnitList(targetUnitId, targetName, targetType)
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
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
--only go on if it's an actual hit event
if (not isDamage and not isHeal) or abilityId == 41467 or abilityId == 57466 or abilityId == 57468 or hitValue < 2 then return end
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
local hit = {
["sourceId"] = sourceUnitId,
["targetId"] = targetUnitId,
["hitValue"] = hitValue,
["abilityId"] = abilityId,
["crit"] = isCrit,
["heal"] = isHeal,
["timeMs"] = GetGameTimeMilliseconds()
}
GroupDamage:Proces****Event(hit)
end
function GroupDamage.onEffectChanged(_, _, _, _, unitTag, _, _, _, _, _, _, _, _, unitName, unitId, _)
if unitTag:match("group") ~= nil then
unitTag = 3
end
GroupDamage:UpdateUnitList(unitId, unitName, unitTag)
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?