comparison Main.lua @ 119:8df432f8a15a 1.0.7

Made gas extraction work with the new loot system.
author James D. Callahan III <jcallahan@curse.com>
date Sun, 16 Sep 2012 19:03:36 -0500
parents 08bc44830424
children ea4e4d3cc673
comparison
equal deleted inserted replaced
118:08bc44830424 119:8df432f8a15a
404 function GenericLootUpdate(data_type, top_field) 404 function GenericLootUpdate(data_type, top_field)
405 local loot_type = action_data.loot_label or "drops" 405 local loot_type = action_data.loot_label or "drops"
406 local loot_count = ("%s_count"):format(loot_type) 406 local loot_count = ("%s_count"):format(loot_type)
407 local source_list = {} 407 local source_list = {}
408 408
409 for source_guid, loot_data in pairs(action_data.loot_sources) do -- TODO: Find out why this breaks with gas extractions. 409 if action_data.loot_sources then
410 local entry, source_id 410 for source_guid, loot_data in pairs(action_data.loot_sources) do
411 411 local entry, source_id
412 if action_data.type == AF.ITEM then 412
413 -- Items return the player as the source, so we need to use the item's ID (disenchant, milling, etc) 413 if action_data.type == AF.ITEM then
414 source_id = action_data.identifier 414 -- Items return the player as the source, so we need to use the item's ID (disenchant, milling, etc)
415 entry = DBEntry(data_type, source_id) 415 source_id = action_data.identifier
416 elseif action_data.type == AF.OBJECT then 416 entry = DBEntry(data_type, source_id)
417 source_id = ("%s:%s"):format(action_data.spell_label, select(2, ParseGUID(source_guid))) 417 elseif action_data.type == AF.OBJECT then
418 entry = DBEntry(data_type, source_id) 418 source_id = ("%s:%s"):format(action_data.spell_label, select(2, ParseGUID(source_guid)))
419 else 419 entry = DBEntry(data_type, source_id)
420 source_id = select(2, ParseGUID(source_guid)) 420 else
421 entry = DBEntry(data_type, source_id) 421 source_id = select(2, ParseGUID(source_guid))
422 end 422 entry = DBEntry(data_type, source_id)
423 423 end
424 if entry then 424
425 local loot_table = LootTable(entry, loot_type, top_field) 425 if entry then
426 426 local loot_table = LootTable(entry, loot_type, top_field)
427 if not source_list[source_guid] then 427
428 if top_field then 428 if not source_list[source_guid] then
429 entry[top_field][loot_count] = (entry[top_field][loot_count] or 0) + 1 429 if top_field then
430 else 430 entry[top_field][loot_count] = (entry[top_field][loot_count] or 0) + 1
431 entry[loot_count] = (entry[loot_count] or 0) + 1 431 else
432 entry[loot_count] = (entry[loot_count] or 0) + 1
433 end
434 source_list[source_guid] = true
432 end 435 end
433 source_list[source_guid] = true 436 UpdateDBEntryLocation(data_type, source_id)
434 end 437
435 UpdateDBEntryLocation(data_type, source_id) 438 for item_id, quantity in pairs(loot_data) do
436 439 table.insert(loot_table, ("%d:%d"):format(item_id, quantity))
437 for item_id, quantity in pairs(loot_data) do 440 end
438 table.insert(loot_table, ("%d:%d"):format(item_id, quantity))
439 end 441 end
440 end 442 end
441 end 443 end
442 -- TODO: Remove this when GetLootSourceInfo() has values for money 444 -- TODO: Remove this when GetLootSourceInfo() has values for money
443 if #action_data.loot_list <= 0 then 445 if #action_data.loot_list <= 0 then