Mercurial > wow > wowdb-profiler
comparison Main.lua @ 20:dae28edbbd61
Record NPC factions when applicable.
author | James D. Callahan III <jcallahan@curse.com> |
---|---|
date | Tue, 08 May 2012 14:55:35 -0500 |
parents | 6a0c96063003 |
children | a82c5d1134db |
comparison
equal
deleted
inserted
replaced
19:6a0c96063003 | 20:dae28edbbd61 |
---|---|
64 ----------------------------------------------------------------------- | 64 ----------------------------------------------------------------------- |
65 local db | 65 local db |
66 local durability_timer_handle | 66 local durability_timer_handle |
67 local target_location_timer_handle | 67 local target_location_timer_handle |
68 local action_data = {} | 68 local action_data = {} |
69 local faction_names = {} | |
69 | 70 |
70 | 71 |
71 ----------------------------------------------------------------------- | 72 ----------------------------------------------------------------------- |
72 -- Helper Functions. | 73 -- Helper Functions. |
73 ----------------------------------------------------------------------- | 74 ----------------------------------------------------------------------- |
200 end | 201 end |
201 end | 202 end |
202 end | 203 end |
203 | 204 |
204 | 205 |
206 local function UpdateFactionNames() | |
207 for faction_index = 1, 1000 do | |
208 local faction_name, _, _, _, _, _, _, _, is_header = _G.GetFactionInfo(faction_index) | |
209 | |
210 if faction_name and not is_header then | |
211 faction_names[faction_name] = true | |
212 elseif not faction_name then | |
213 break | |
214 end | |
215 end | |
216 end | |
217 | |
218 | |
205 ----------------------------------------------------------------------- | 219 ----------------------------------------------------------------------- |
206 -- Methods. | 220 -- Methods. |
207 ----------------------------------------------------------------------- | 221 ----------------------------------------------------------------------- |
208 function WDP:OnInitialize() | 222 function WDP:OnInitialize() |
209 db = LibStub("AceDB-3.0"):New("WoWDBProfilerData", DATABASE_DEFAULTS, "Default").global | 223 db = LibStub("AceDB-3.0"):New("WoWDBProfilerData", DATABASE_DEFAULTS, "Default").global |
233 _G.hooksecurefunc("UseContainerItem", function(bag_index, slot_index, target_unit) | 247 _G.hooksecurefunc("UseContainerItem", function(bag_index, slot_index, target_unit) |
234 if target_unit then | 248 if target_unit then |
235 return | 249 return |
236 end | 250 end |
237 HandleItemUse(_G.GetContainerItemLink(bag_index, slot_index), bag_index, slot_index) | 251 HandleItemUse(_G.GetContainerItemLink(bag_index, slot_index), bag_index, slot_index) |
238 | |
239 end) | 252 end) |
240 | 253 |
241 _G.hooksecurefunc("UseItemByName", function(identifier, target_unit) | 254 _G.hooksecurefunc("UseItemByName", function(identifier, target_unit) |
242 if target_unit then | 255 if target_unit then |
243 return | 256 return |
629 table.wipe(action_data) | 642 table.wipe(action_data) |
630 | 643 |
631 local npc = DBEntry("npcs", unit_idnum) | 644 local npc = DBEntry("npcs", unit_idnum) |
632 local _, class_token = _G.UnitClass("target") | 645 local _, class_token = _G.UnitClass("target") |
633 npc.class = class_token | 646 npc.class = class_token |
634 -- TODO: Add faction here | 647 |
648 UpdateFactionNames() | |
649 DatamineTT:ClearLines() | |
650 DatamineTT:SetUnit("target") | |
651 | |
652 for line_index = 1, DatamineTT:NumLines() do | |
653 local current_line = _G["WDPDatamineTTTextLeft" .. line_index] | |
654 | |
655 if not current_line then | |
656 break | |
657 end | |
658 local line_text = current_line:GetText() | |
659 | |
660 if faction_names[line_text] then | |
661 npc.faction = line_text | |
662 break | |
663 end | |
664 end | |
635 npc.gender = GENDER_NAMES[_G.UnitSex("target")] or "UNDEFINED" | 665 npc.gender = GENDER_NAMES[_G.UnitSex("target")] or "UNDEFINED" |
636 npc.is_pvp = _G.UnitIsPVP("target") and true or nil | 666 npc.is_pvp = _G.UnitIsPVP("target") and true or nil |
637 npc.reaction = ("%s:%s:%s"):format(_G.UnitLevel("player"), _G.UnitFactionGroup("player"), REACTION_NAMES[_G.UnitReaction("player", "target")]) | 667 npc.reaction = ("%s:%s:%s"):format(_G.UnitLevel("player"), _G.UnitFactionGroup("player"), REACTION_NAMES[_G.UnitReaction("player", "target")]) |
638 npc.stats = npc.stats or {} | 668 npc.stats = npc.stats or {} |
639 | 669 |