# HG changeset patch # User James D. Callahan III # Date 1335891869 18000 # Node ID 0ec5c8f4b72be8be86237173ca5b671b2addb0e9 # Parent 94bc939c2ca6f4c7a60a8a8bc834294d2e38a8d7 Better support for looting from world objects. diff -r 94bc939c2ca6 -r 0ec5c8f4b72b Main.lua --- 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")