comparison Main.lua @ 367:1dc56d8e1260

Fixed several flawed logical statements and added disenchanting support to the looted item verification.
author MMOSimca <MMOSimca@gmail.com>
date Sun, 19 Oct 2014 07:34:16 -0400
parents 7e7d57948295
children 2e122726c7dd
comparison
equal deleted inserted replaced
366:7e7d57948295 367:1dc56d8e1260
1364 if loot_type == "item" then 1364 if loot_type == "item" then
1365 local item_id = ItemLinkToID(item_link) 1365 local item_id = ItemLinkToID(item_link)
1366 if item_id then 1366 if item_id then
1367 Debug("%s: %s X %d (%d)", event_name, item_link, quantity, item_id) 1367 Debug("%s: %s X %d (%d)", event_name, item_link, quantity, item_id)
1368 RecordItemData(item_id, item_link, true) 1368 RecordItemData(item_id, item_link, true)
1369 current_loot.sources[container_id][item_id] = current_loot.sources[container_id][item_id] or 0 + quantity 1369 current_loot.sources[container_id][item_id] = (current_loot.sources[container_id][item_id] or 0) + quantity
1370 else 1370 else
1371 Debug("%s: ItemID is nil, from item link %s", event_name, item_link) 1371 Debug("%s: ItemID is nil, from item link %s", event_name, item_link)
1372 current_loot = nil 1372 current_loot = nil
1373 return 1373 return
1374 end 1374 end
1375 elseif loot_type == "money" then 1375 elseif loot_type == "money" then
1376 Debug("%s: money X %d", event_name, quantity) 1376 Debug("%s: money X %d", event_name, quantity)
1377 current_loot.sources[container_id]["money"] = current_loot.sources[container_id]["money"] or 0 + quantity 1377 current_loot.sources[container_id]["money"] = (current_loot.sources[container_id]["money"] or 0) + quantity
1378 elseif loot_type == "currency" then 1378 elseif loot_type == "currency" then
1379 local currency_texture = CurrencyLinkToTexture(item_link) 1379 local currency_texture = CurrencyLinkToTexture(item_link)
1380 if currency_texture and currency_texture ~= "" then 1380 if currency_texture and currency_texture ~= "" then
1381 Debug("%s: %s X %d", event_name, currency_texture, quantity) 1381 Debug("%s: %s X %d", event_name, currency_texture, quantity)
1382 local currency_token = ("currency:%s"):format(currency_texture) 1382 local currency_token = ("currency:%s"):format(currency_texture)
1383 current_loot.sources[container_id][currency_token] = current_loot.sources[container_id][currency_token] or 0 + quantity 1383 current_loot.sources[container_id][currency_token] = (current_loot.sources[container_id][currency_token] or 0) + quantity
1384 else 1384 else
1385 Debug("%s: Currency texture is nil, from currency link %s", event_name, item_link) 1385 Debug("%s: Currency texture is nil, from currency link %s", event_name, item_link)
1386 current_loot = nil 1386 current_loot = nil
1387 return 1387 return
1388 end 1388 end
1802 if locked_item_id then 1802 if locked_item_id then
1803 break 1803 break
1804 end 1804 end
1805 end 1805 end
1806 1806
1807 if not locked_item_id or (current_action.identifier and current_action.identifier ~= locked_item_id) then 1807 if (not current_action.spell_label == "DISENCHANT") and (not locked_item_id or (current_action.identifier and current_action.identifier ~= locked_item_id)) then
1808 return false 1808 return false
1809 end 1809 end
1810 current_action.identifier = locked_item_id 1810 current_action.identifier = locked_item_id
1811 return true 1811 return true
1812 end, 1812 end,
2058 2058
2059 if slot_type == LOOT_SLOT_ITEM then 2059 if slot_type == LOOT_SLOT_ITEM then
2060 local item_id = ItemLinkToID(_G.GetLootSlotLink(loot_slot)) 2060 local item_id = ItemLinkToID(_G.GetLootSlotLink(loot_slot))
2061 Debug("GUID: %s - Type:ID: %s - ItemID: %d - Amount: %d (%d)", loot_info[loot_index], source_key, item_id, loot_info[loot_index + 1], slot_quantity) 2061 Debug("GUID: %s - Type:ID: %s - ItemID: %d - Amount: %d (%d)", loot_info[loot_index], source_key, item_id, loot_info[loot_index + 1], slot_quantity)
2062 current_loot.sources[source_guid] = current_loot.sources[source_guid] or {} 2062 current_loot.sources[source_guid] = current_loot.sources[source_guid] or {}
2063 current_loot.sources[source_guid][item_id] = current_loot.sources[source_guid][item_id] or 0 + loot_quantity 2063 current_loot.sources[source_guid][item_id] = (current_loot.sources[source_guid][item_id] or 0) + loot_quantity
2064 guids_used[source_guid] = true 2064 guids_used[source_guid] = true
2065 elseif slot_type == LOOT_SLOT_MONEY then 2065 elseif slot_type == LOOT_SLOT_MONEY then
2066 Debug("GUID: %s - Type:ID: %s - Money - Amount: %d (%d)", loot_info[loot_index], source_key, loot_info[loot_index + 1], slot_quantity) 2066 Debug("GUID: %s - Type:ID: %s - Money - Amount: %d (%d)", loot_info[loot_index], source_key, loot_info[loot_index + 1], slot_quantity)
2067 if current_loot.target_type == AF.ZONE then 2067 if current_loot.target_type == AF.ZONE then
2068 table.insert(current_loot.list, ("money:%d"):format(loot_quantity)) 2068 table.insert(current_loot.list, ("money:%d"):format(loot_quantity))
2069 else 2069 else
2070 current_loot.sources[source_guid] = current_loot.sources[source_guid] or {} 2070 current_loot.sources[source_guid] = current_loot.sources[source_guid] or {}
2071 current_loot.sources[source_guid]["money"] = current_loot.sources[source_guid]["money"] or 0 + loot_quantity 2071 current_loot.sources[source_guid]["money"] = (current_loot.sources[source_guid]["money"] or 0) + loot_quantity
2072 guids_used[source_guid] = true 2072 guids_used[source_guid] = true
2073 end 2073 end
2074 elseif slot_type == LOOT_SLOT_CURRENCY then 2074 elseif slot_type == LOOT_SLOT_CURRENCY then
2075 -- Same bug with GetLootSlotInfo() will screw up currency when it happens, so we won't process this slot's loot. 2075 -- Same bug with GetLootSlotInfo() will screw up currency when it happens, so we won't process this slot's loot.
2076 if icon_texture then 2076 if icon_texture then
2079 table.insert(current_loot.list, ("currency:%d:%s"):format(loot_quantity, icon_texture:match("[^\\]+$"):lower())) 2079 table.insert(current_loot.list, ("currency:%d:%s"):format(loot_quantity, icon_texture:match("[^\\]+$"):lower()))
2080 else 2080 else
2081 local currency_token = ("currency:%s"):format(icon_texture:match("[^\\]+$"):lower()) 2081 local currency_token = ("currency:%s"):format(icon_texture:match("[^\\]+$"):lower())
2082 2082
2083 current_loot.sources[source_guid] = current_loot.sources[source_guid] or {} 2083 current_loot.sources[source_guid] = current_loot.sources[source_guid] or {}
2084 current_loot.sources[source_guid][currency_token] = current_loot.sources[source_guid][currency_token] or 0 + loot_quantity 2084 current_loot.sources[source_guid][currency_token] = (current_loot.sources[source_guid][currency_token] or 0) + loot_quantity
2085 guids_used[source_guid] = true 2085 guids_used[source_guid] = true
2086 end 2086 end
2087 else 2087 else
2088 Debug("%s: Slot quantity is nil for loot slot %d of the entity with GUID %s and Type:ID: %s.", event_name, loot_slot, loot_info[loot_index], source_key) 2088 Debug("%s: Slot quantity is nil for loot slot %d of the entity with GUID %s and Type:ID: %s.", event_name, loot_slot, loot_info[loot_index], source_key)
2089 end 2089 end