comparison 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
comparison
equal deleted inserted replaced
10:94bc939c2ca6 11:0ec5c8f4b72b
142 if not identifier then 142 if not identifier then
143 return 143 return
144 end 144 end
145 local zone_name, x, y, map_level, instance_type = CurrentLocationData() 145 local zone_name, x, y, map_level, instance_type = CurrentLocationData()
146 local object = UnitEntry("objects", identifier) 146 local object = UnitEntry("objects", identifier)
147 147 object.locations = object.locations or {}
148 if not object[zone_name] then 148
149 object[zone_name] = {} 149 if not object.locations[zone_name] then
150 end 150 object.locations[zone_name] = {}
151 object[zone_name][("%s:%s:%s:%s"):format(instance_type, map_level, x, y)] = true 151 end
152 object.locations[zone_name][("%s:%s:%s:%s"):format(instance_type, map_level, x, y)] = true
152 end 153 end
153 154
154 155
155 ----------------------------------------------------------------------- 156 -----------------------------------------------------------------------
156 -- Methods. 157 -- Methods.
264 local unit_type, id_num = WDP:ParseGUID(_G.UnitGUID("target")) 265 local unit_type, id_num = WDP:ParseGUID(_G.UnitGUID("target"))
265 action_data.id_num = id_num 266 action_data.id_num = id_num
266 end 267 end
267 return true 268 return true
268 end, 269 end,
270 [AF.OBJECT] = function()
271 return true
272 end,
269 } 273 }
270 274
271 275
272 local LOOT_UPDATE_FUNCS = { 276 local LOOT_UPDATE_FUNCS = {
273 [AF.NPC] = function() 277 [AF.NPC] = function()
274 local npc = UnitEntry("npcs", action_data.id_num) 278 local npc = UnitEntry("npcs", action_data.id_num)
275 npc.drops = npc.drops or {} 279 npc.drops = npc.drops or {}
276 280
277 for index = 1, #action_data.drops do 281 for index = 1, #action_data.drops do
278 table.insert(npc.drops, action_data.drops[index]) 282 table.insert(npc.drops, action_data.drops[index])
283 end
284 end,
285 [AF.OBJECT] = function()
286 local object = UnitEntry("objects", action_data.identifier)
287 object.drops = object.drops or {}
288
289 for index = 1, #action_data.drops do
290 table.insert(object.drops, action_data.drops[index])
279 end 291 end
280 end, 292 end,
281 } 293 }
282 294
283 295
455 if max_power > 0 then 467 if max_power > 0 then
456 local power_type = _G.UnitPowerType("target") 468 local power_type = _G.UnitPowerType("target")
457 npc.stats[npc_level].power = ("%s:%d"):format(POWER_TYPE_NAMES[_G.tostring(power_type)] or power_type, max_power) 469 npc.stats[npc_level].power = ("%s:%d"):format(POWER_TYPE_NAMES[_G.tostring(power_type)] or power_type, max_power)
458 end 470 end
459 end 471 end
472 action_data.type = AF.NPC -- This will be set as appropriate below
460 end 473 end
461 474
462 475
463 function WDP:QUEST_COMPLETE() 476 function WDP:QUEST_COMPLETE()
464 end 477 end
523 end 536 end
524 537
525 local zone_name, x, y, map_level, instance_type = CurrentLocationData() 538 local zone_name, x, y, map_level, instance_type = CurrentLocationData()
526 539
527 if bit.band(spell_flags, AF.OBJECT) == AF.OBJECT then 540 if bit.band(spell_flags, AF.OBJECT) == AF.OBJECT then
541 local identifier = ("%s:%s"):format(spell_label, target_name)
542 UpdateObjectLocation(identifier)
543
528 action_data.instance_type = instance_type 544 action_data.instance_type = instance_type
529 action_data.map_level = map_level 545 action_data.map_level = map_level
530 action_data.name = target_name 546 action_data.name = target_name
531 action_data.type = AF.OBJECT 547 action_data.type = AF.OBJECT
532 action_data.x = x 548 action_data.x = x
533 action_data.y = y 549 action_data.y = y
534 action_data.zone = zone_name 550 action_data.zone = zone_name
551 action_data.identifier = identifier
535 print(("Found spell flagged for OBJECT: %s (%s, %s)"):format(zone_name, x, y)) 552 print(("Found spell flagged for OBJECT: %s (%s, %s)"):format(zone_name, x, y))
536 elseif bit.band(spell_flags, AF.ZONE) == AF.ZONE then 553 elseif bit.band(spell_flags, AF.ZONE) == AF.ZONE then
537 print("Found spell flagged for ZONE") 554 print("Found spell flagged for ZONE")
538 end 555 end
539 elseif tt_unit_name and not tt_item_name then 556 elseif tt_unit_name and not tt_item_name then