diff Main.lua @ 11:0ec5c8f4b72b

Better support for looting from world objects.
author James D. Callahan III <jcallahan@curse.com>
date Tue, 01 May 2012 12:04:29 -0500
parents 94bc939c2ca6
children be3d67c28a27
line wrap: on
line diff
--- a/Main.lua	Mon Apr 30 17:14:23 2012 -0500
+++ b/Main.lua	Tue May 01 12:04:29 2012 -0500
@@ -144,11 +144,12 @@
     end
     local zone_name, x, y, map_level, instance_type = CurrentLocationData()
     local object = UnitEntry("objects", identifier)
+    object.locations = object.locations or {}
 
-    if not object[zone_name] then
-        object[zone_name] = {}
+    if not object.locations[zone_name] then
+        object.locations[zone_name] = {}
     end
-    object[zone_name][("%s:%s:%s:%s"):format(instance_type, map_level, x, y)] = true
+    object.locations[zone_name][("%s:%s:%s:%s"):format(instance_type, map_level, x, y)] = true
 end
 
 
@@ -266,6 +267,9 @@
         end
         return true
     end,
+    [AF.OBJECT] = function()
+        return true
+    end,
 }
 
 
@@ -278,6 +282,14 @@
             table.insert(npc.drops, action_data.drops[index])
         end
     end,
+    [AF.OBJECT] = function()
+        local object = UnitEntry("objects", action_data.identifier)
+        object.drops = object.drops or {}
+
+        for index = 1, #action_data.drops do
+            table.insert(object.drops, action_data.drops[index])
+        end
+    end,
 }
 
 
@@ -457,6 +469,7 @@
             npc.stats[npc_level].power = ("%s:%d"):format(POWER_TYPE_NAMES[_G.tostring(power_type)] or power_type, max_power)
         end
     end
+    action_data.type = AF.NPC -- This will be set as appropriate below
 end
 
 
@@ -525,6 +538,9 @@
         local zone_name, x, y, map_level, instance_type = CurrentLocationData()
 
         if bit.band(spell_flags, AF.OBJECT) == AF.OBJECT then
+            local identifier = ("%s:%s"):format(spell_label, target_name)
+            UpdateObjectLocation(identifier)
+
             action_data.instance_type = instance_type
             action_data.map_level = map_level
             action_data.name = target_name
@@ -532,6 +548,7 @@
             action_data.x = x
             action_data.y = y
             action_data.zone = zone_name
+            action_data.identifier = identifier
             print(("Found spell flagged for OBJECT: %s (%s, %s)"):format(zone_name, x, y))
         elseif bit.band(spell_flags, AF.ZONE) == AF.ZONE then
             print("Found spell flagged for ZONE")