comparison Main.lua @ 308:22e2e16318e5

Loot fixes.
author James D. Callahan III <jcallahan@curse.com>
date Tue, 30 Jul 2013 11:53:53 -0500
parents c33ab3413737
children 3b9c6d588e62
comparison
equal deleted inserted replaced
307:c33ab3413737 308:22e2e16318e5
654 end 654 end
655 source_list[source_id] = true 655 source_list[source_id] = true
656 end 656 end
657 UpdateDBEntryLocation(data_type, source_id) 657 UpdateDBEntryLocation(data_type, source_id)
658 658
659 for item_id, quantity in pairs(loot_data) do 659 if current_loot.target_type == AF.OBJECT then
660 table.insert(loot_table, ("%d:%d"):format(item_id, quantity)) 660 for loot_token, quantity in pairs(loot_data) do
661 local label, currency_texture = (":"):split(loot_token)
662
663 if label == "currency" and currency_texture then
664 table.insert(loot_table, ("currency:%d:%s"):format(quantity, currency_texture))
665 elseif loot_token == "money" then
666 table.insert(loot_table, ("money:%d"):format(quantity))
667 else
668 table.insert(loot_table, ("%d:%d"):format(loot_token, quantity))
669 end
670 end
671 else
672 for item_id, quantity in pairs(loot_data) do
673 table.insert(loot_table, ("%d:%d"):format(item_id, quantity))
674 end
661 end 675 end
662 end 676 end
663 end 677 end
664 end 678 end
665 679
1210 return 1224 return
1211 end 1225 end
1212 Debug("%s: NPC and Container are nil, storing loot toast data for 5 seconds.", event_name) 1226 Debug("%s: NPC and Container are nil, storing loot toast data for 5 seconds.", event_name)
1213 1227
1214 loot_toast_data = loot_toast_data or {} 1228 loot_toast_data = loot_toast_data or {}
1215 loot_toast_data[#loot_toast_data + 1] = {loot_type, item_link, quantity, item_id} 1229 loot_toast_data[#loot_toast_data + 1] = { loot_type, item_link, quantity, item_id }
1216 1230
1217 loot_toast_data_timer_handle = WDP:ScheduleTimer(ClearLootToastData, 5) 1231 loot_toast_data_timer_handle = WDP:ScheduleTimer(ClearLootToastData, 5)
1218 end 1232 end
1219 end 1233 end
1220 1234
1796 local item_id = ItemLinkToID(_G.GetLootSlotLink(loot_slot)) 1810 local item_id = ItemLinkToID(_G.GetLootSlotLink(loot_slot))
1797 current_loot.sources[source_guid] = current_loot.sources[source_guid] or {} 1811 current_loot.sources[source_guid] = current_loot.sources[source_guid] or {}
1798 current_loot.sources[source_guid][item_id] = current_loot.sources[source_guid][item_id] or 0 + slot_quantity 1812 current_loot.sources[source_guid][item_id] = current_loot.sources[source_guid][item_id] or 0 + slot_quantity
1799 guids_used[source_guid] = true 1813 guids_used[source_guid] = true
1800 elseif slot_type == _G.LOOT_SLOT_MONEY then 1814 elseif slot_type == _G.LOOT_SLOT_MONEY then
1801 Debug("money:%d", _toCopper(item_text)) 1815 if current_loot.target_type == AF.OBJECT then
1802 table.insert(current_loot.list, ("money:%d"):format(_toCopper(item_text))) 1816 Debug("money:%d", _toCopper(item_text))
1817 current_loot.sources[source_guid] = current_loot.sources[source_guid] or {}
1818 current_loot.sources[source_guid]["money"] = current_loot.sources[source_guid]["money"] or 0 + _toCopper(item_text)
1819 else
1820 Debug("money:%d", _toCopper(item_text))
1821 table.insert(current_loot.list, ("money:%d"):format(_toCopper(item_text)))
1822 end
1803 elseif slot_type == _G.LOOT_SLOT_CURRENCY then 1823 elseif slot_type == _G.LOOT_SLOT_CURRENCY then
1804 Debug("Found currency: %s", icon_texture) 1824 if current_loot.target_type == AF.OBJECT then
1805 table.insert(current_loot.list, ("currency:%d:%s"):format(slot_quantity, icon_texture:match("[^\\]+$"):lower())) 1825 local currency_token = ("currency:%s"):format(icon_texture:match("[^\\]+$"):lower())
1826 Debug("Found currency: %s", icon_texture)
1827
1828 current_loot.sources[source_guid] = current_loot.sources[source_guid] or {}
1829 current_loot.sources[source_guid][currency_token] = current_loot.sources[source_guid][currency_token] or 0 + slot_quantity
1830 else
1831 Debug("Found currency: %s", icon_texture)
1832 table.insert(current_loot.list, ("currency:%d:%s"):format(slot_quantity, icon_texture:match("[^\\]+$"):lower()))
1833 end
1806 end 1834 end
1807 end 1835 end
1808 end 1836 end
1809 end 1837 end
1810 1838