# HG changeset patch # User James D. Callahan III # Date 1336574089 18000 # Node ID a82c5d1134db4fec7c52c3c27cffd66018e5b786 # Parent dae28edbbd6145ef7fc52d185a6aa9646d616892 Record reputation gains from NPC deaths. diff -r dae28edbbd61 -r a82c5d1134db Main.lua --- a/Main.lua Tue May 08 14:55:35 2012 -0500 +++ b/Main.lua Wed May 09 09:34:49 2012 -0500 @@ -327,19 +327,13 @@ -- Event handlers. ----------------------------------------------------------------------- function WDP:COMBAT_TEXT_UPDATE(event, message_type, faction_name, amount) - -- if message_type ~= "FACTION" or _G.UnitIsUnit("target", "questnpc") then - -- return - -- end - -- local unit_type, unit_idnum = self:ParseGUID(_G.UnitGUID("target")) - -- local npc = DBEntry("npcs", unit_idnum) - -- - -- if not npc then - -- return - -- end - -- npc.reputations = npc.reputations or {} - -- npc.reputations[faction_name] = amount - -- - -- print(("%s: %s, %s, %s"):format(event, message_type, faction_name, amount)) + local npc = DBEntry("npcs", action_data.id_num) + + if not npc then + return + end + npc.stats[action_data.npc_level].reputations = npc.stats[action_data.npc_level].reputations or {} + npc.stats[action_data.npc_level].reputations[faction_name] = amount end @@ -639,8 +633,6 @@ if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then return end - table.wipe(action_data) - local npc = DBEntry("npcs", unit_idnum) local _, class_token = _G.UnitClass("target") npc.class = class_token @@ -681,6 +673,10 @@ npc.stats[npc_level].power = ("%s:%d"):format(POWER_TYPE_NAMES[_G.tostring(power_type)] or power_type, max_power) end end + table.wipe(action_data) + action_data.type = AF.NPC + action_data.id_num = unit_idnum + action_data.npc_level = npc_level end end -- do-block