diff Main.lua @ 86:9be5fc389c13

Don't ignore headers in the faction list - they can be legitimate faction names. Small farming tweaks.
author James D. Callahan III <jcallahan@curse.com>
date Mon, 27 Aug 2012 11:20:05 -0500
parents e2b741356fc9
children 2ab6c802b485
line wrap: on
line diff
--- a/Main.lua	Thu Aug 23 14:15:01 2012 -0500
+++ b/Main.lua	Mon Aug 27 11:20:05 2012 -0500
@@ -90,7 +90,7 @@
 local currently_drunk
 local faction_standings = {}
 local reputation_npc_id
-
+local current_target_id
 
 -----------------------------------------------------------------------
 -- Helper Functions.
@@ -373,7 +373,7 @@
         for faction_index = 1, MAX_FACTION_INDEX do
             local faction_name, _, current_standing, _, _, _, _, _, is_header = _G.GetFactionInfo(faction_index)
 
-            if faction_name and not is_header then
+            if faction_name then
                 faction_standings[faction_name] = STANDING_NAMES[current_standing]
             elseif not faction_name then
                 break
@@ -1157,6 +1157,7 @@
 
     function WDP:PLAYER_TARGET_CHANGED()
         if not _G.UnitExists("target") or _G.UnitPlayerControlled("target") or currently_drunk then
+            current_target_id = nil
             return
         end
         local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("target"))
@@ -1164,6 +1165,8 @@
         if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then
             return
         end
+        current_target_id = unit_idnum
+
         local npc = NPCEntry(unit_idnum)
         local _, class_token = _G.UnitClass("target")
         npc.class = class_token
@@ -1192,7 +1195,6 @@
         action_data.type = AF.NPC
         action_data.identifier = unit_idnum
         action_data.npc_level = npc_level
-
         self:UpdateTargetLocation()
     end
 end -- do-block
@@ -1393,15 +1395,14 @@
     private.tracked_line = spell_line
 end
 
-
 function WDP:UNIT_SPELLCAST_SUCCEEDED(event_name, unit_id, spell_name, spell_rank, spell_line, spell_id)
     if unit_id ~= "player" then
         return
     end
     private.tracked_line = nil
 
-    if spell_name:match("^Harvest") then
-        reputation_npc_id = action_data.identifier
+    if spell_name:match("^Harvest.+") then
+        reputation_npc_id = current_target_id
     end
 end