Mercurial > wow > wowdb-profiler
comparison Main.lua @ 340:d708222fe96b WoD
Added a large number of reputation modifiers, enabled examining items on drop, and disabled bonus ID checking from inventory processing.
author | MMOSimca <MMOSimca@gmail.com> |
---|---|
date | Mon, 22 Sep 2014 17:00:08 -0400 |
parents | e4abf4f04db3 |
children | 2bd9de08833f |
comparison
equal
deleted
inserted
replaced
339:e4abf4f04db3 | 340:d708222fe96b |
---|---|
977 end | 977 end |
978 end | 978 end |
979 end -- do-block | 979 end -- do-block |
980 | 980 |
981 | 981 |
982 local function RecordItemData(item_id, item_link, durability) | 982 local function RecordItemData(item_id, item_link, process_bonus_ids, durability) |
983 local _, _, item_string = item_link:find("^|%x+|H(.+)|h%[.+%]") | 983 local _, _, item_string = item_link:find("^|%x+|H(.+)|h%[.+%]") |
984 local item | 984 local item |
985 | 985 |
986 if item_string then | 986 if item_string then |
987 local item_results = { (":"):split(item_string) } | 987 local item_results = { (":"):split(item_string) } |
990 local unique_id = item_results[9] | 990 local unique_id = item_results[9] |
991 local upgrade_id = tonumber(item_results[11]) | 991 local upgrade_id = tonumber(item_results[11]) |
992 local instance_difficulty_id = tonumber(item_results[12]) | 992 local instance_difficulty_id = tonumber(item_results[12]) |
993 local num_bonus_ids = tonumber(item_results[13]) | 993 local num_bonus_ids = tonumber(item_results[13]) |
994 | 994 |
995 if not num_bonus_ids or num_bonus_ids == 0 then | 995 if not num_bonus_ids or num_bonus_ids == 0 or not process_bonus_ids then |
996 if (suffix_id and suffix_id ~= 0) or (instance_difficulty_id and instance_difficulty_id ~= 0) then | 996 if (suffix_id and suffix_id ~= 0) or (instance_difficulty_id and instance_difficulty_id ~= 0) then |
997 item = DBEntry("items", item_id) | 997 item = DBEntry("items", item_id) |
998 item.unique_id = bit.band(unique_id, 0xFFFF) | 998 item.unique_id = bit.band(unique_id, 0xFFFF) |
999 | 999 |
1000 if suffix_id and suffix_id ~= 0 then | 1000 if suffix_id and suffix_id ~= 0 then |
1038 for slot_index = _G.INVSLOT_FIRST_EQUIPPED, _G.INVSLOT_LAST_EQUIPPED do | 1038 for slot_index = _G.INVSLOT_FIRST_EQUIPPED, _G.INVSLOT_LAST_EQUIPPED do |
1039 local item_id = _G.GetInventoryItemID("player", slot_index) | 1039 local item_id = _G.GetInventoryItemID("player", slot_index) |
1040 | 1040 |
1041 if item_id and item_id > 0 then | 1041 if item_id and item_id > 0 then |
1042 local _, max_durability = _G.GetInventoryItemDurability(slot_index) | 1042 local _, max_durability = _G.GetInventoryItemDurability(slot_index) |
1043 RecordItemData(item_id, _G.GetInventoryItemLink("player", slot_index), max_durability) | 1043 RecordItemData(item_id, _G.GetInventoryItemLink("player", slot_index), false, max_durability) |
1044 end | 1044 end |
1045 end | 1045 end |
1046 | 1046 |
1047 for bag_index = 0, _G.NUM_BAG_SLOTS do | 1047 for bag_index = 0, _G.NUM_BAG_SLOTS do |
1048 for slot_index = 1, _G.GetContainerNumSlots(bag_index) do | 1048 for slot_index = 1, _G.GetContainerNumSlots(bag_index) do |
1049 local item_id = _G.GetContainerItemID(bag_index, slot_index) | 1049 local item_id = _G.GetContainerItemID(bag_index, slot_index) |
1050 | 1050 |
1051 if item_id and item_id > 0 then | 1051 if item_id and item_id > 0 then |
1052 local _, max_durability = _G.GetContainerItemDurability(bag_index, slot_index) | 1052 local _, max_durability = _G.GetContainerItemDurability(bag_index, slot_index) |
1053 RecordItemData(item_id, _G.GetContainerItemLink(bag_index, slot_index), max_durability) | 1053 RecordItemData(item_id, _G.GetContainerItemLink(bag_index, slot_index), false, max_durability) |
1054 end | 1054 end |
1055 end | 1055 end |
1056 end | 1056 end |
1057 end | 1057 end |
1058 | 1058 |
1266 | 1266 |
1267 if loot_type == "item" then | 1267 if loot_type == "item" then |
1268 local item_id = ItemLinkToID(item_link) | 1268 local item_id = ItemLinkToID(item_link) |
1269 if item_id then | 1269 if item_id then |
1270 Debug("%s: %s X %d (%d)", event_name, item_link, quantity, item_id) | 1270 Debug("%s: %s X %d (%d)", event_name, item_link, quantity, item_id) |
1271 RecordItemData(item_id, item_link, true) | |
1271 table.insert(encounter_data[loot_label], ("%d:%d"):format(item_id, quantity)) | 1272 table.insert(encounter_data[loot_label], ("%d:%d"):format(item_id, quantity)) |
1272 else | 1273 else |
1273 Debug("%s: ItemID is nil, from item link %s", event_name, item_link) | 1274 Debug("%s: ItemID is nil, from item link %s", event_name, item_link) |
1274 return | 1275 return |
1275 end | 1276 end |
1309 | 1310 |
1310 if loot_type == "item" then | 1311 if loot_type == "item" then |
1311 local item_id = ItemLinkToID(item_link) | 1312 local item_id = ItemLinkToID(item_link) |
1312 if item_id then | 1313 if item_id then |
1313 Debug("%s: %s X %d (%d)", event_name, item_link, quantity, item_id) | 1314 Debug("%s: %s X %d (%d)", event_name, item_link, quantity, item_id) |
1315 RecordItemData(item_id, item_link, true) | |
1314 current_loot.sources[container_id][item_id] = current_loot.sources[container_id][item_id] or 0 + quantity | 1316 current_loot.sources[container_id][item_id] = current_loot.sources[container_id][item_id] or 0 + quantity |
1315 else | 1317 else |
1316 Debug("%s: ItemID is nil, from item link %s", event_name, item_link) | 1318 Debug("%s: ItemID is nil, from item link %s", event_name, item_link) |
1317 current_loot = nil | 1319 current_loot = nil |
1318 return | 1320 return |
1340 Debug("%s: NPC and Container are nil, storing loot toast data for 5 seconds.", event_name) | 1342 Debug("%s: NPC and Container are nil, storing loot toast data for 5 seconds.", event_name) |
1341 | 1343 |
1342 loot_toast_data = loot_toast_data or {} | 1344 loot_toast_data = loot_toast_data or {} |
1343 loot_toast_data[#loot_toast_data + 1] = { loot_type, item_link, quantity } | 1345 loot_toast_data[#loot_toast_data + 1] = { loot_type, item_link, quantity } |
1344 | 1346 |
1347 local item_id = ItemLinkToID(item_link) | |
1348 if item_id then | |
1349 RecordItemData(item_id, item_link, true) | |
1350 end | |
1351 | |
1345 loot_toast_data_timer_handle = WDP:ScheduleTimer(ClearLootToastData, 5) | 1352 loot_toast_data_timer_handle = WDP:ScheduleTimer(ClearLootToastData, 5) |
1346 end | 1353 end |
1347 end | 1354 end |
1348 | 1355 |
1349 | 1356 |
1369 elseif private.raid_boss_id then | 1376 elseif private.raid_boss_id then |
1370 category = AF.NPC | 1377 category = AF.NPC |
1371 end | 1378 end |
1372 local update_func = CHAT_MSG_LOOT_UPDATE_FUNCS[category] | 1379 local update_func = CHAT_MSG_LOOT_UPDATE_FUNCS[category] |
1373 | 1380 |
1374 if not category or not update_func then | |
1375 return | |
1376 end | |
1377 local item_link, quantity = deformat(message, _G.LOOT_ITEM_PUSHED_SELF_MULTIPLE) | 1381 local item_link, quantity = deformat(message, _G.LOOT_ITEM_PUSHED_SELF_MULTIPLE) |
1378 | 1382 |
1379 if not item_link then | 1383 if not item_link then |
1380 quantity, item_link = 1, deformat(message, _G.LOOT_ITEM_PUSHED_SELF) | 1384 quantity, item_link = 1, deformat(message, _G.LOOT_ITEM_PUSHED_SELF) |
1381 end | 1385 end |
1382 local item_id = ItemLinkToID(item_link) | 1386 local item_id = ItemLinkToID(item_link) |
1383 | 1387 |
1384 if not item_id then | 1388 if not item_id then |
1389 return | |
1390 end | |
1391 | |
1392 if not category or not update_func then | |
1393 -- We still want to record the item's data, even if it doesn't need its drop location recorded | |
1394 RecordItemData(item_id, item_link, true) | |
1385 return | 1395 return |
1386 end | 1396 end |
1387 update_func(item_id, quantity) | 1397 update_func(item_id, quantity) |
1388 end | 1398 end |
1389 end | 1399 end |
1577 | 1587 |
1578 | 1588 |
1579 local DIPLOMACY_SPELL_ID = 20599 | 1589 local DIPLOMACY_SPELL_ID = 20599 |
1580 local MR_POP_RANK1_SPELL_ID = 78634 | 1590 local MR_POP_RANK1_SPELL_ID = 78634 |
1581 local MR_POP_RANK2_SPELL_ID = 78635 | 1591 local MR_POP_RANK2_SPELL_ID = 78635 |
1582 local FACTION_NAMES = private.FACTION_NAMES | 1592 local FACTION_DATA = private.FACTION_DATA |
1583 local REP_BUFFS = private.REP_BUFFS | 1593 local REP_BUFFS = private.REP_BUFFS |
1584 | 1594 |
1585 | 1595 |
1586 function WDP:COMBAT_TEXT_UPDATE(event_name, message_type, faction_name, amount) | 1596 function WDP:COMBAT_TEXT_UPDATE(event_name, message_type, faction_name, amount) |
1587 if message_type ~= "FACTION" or not killed_npc_id then | 1597 if message_type ~= "FACTION" or not killed_npc_id then |
1602 npc.harvested = private.harvesting | 1612 npc.harvested = private.harvesting |
1603 private.harvesting = nil | 1613 private.harvesting = nil |
1604 | 1614 |
1605 local modifier = 1 | 1615 local modifier = 1 |
1606 | 1616 |
1617 -- Check for modifiers from known spells | |
1607 if _G.IsSpellKnown(DIPLOMACY_SPELL_ID) then | 1618 if _G.IsSpellKnown(DIPLOMACY_SPELL_ID) then |
1608 modifier = modifier + 0.1 | 1619 modifier = modifier + 0.1 |
1609 end | 1620 end |
1610 | |
1611 if _G.IsSpellKnown(MR_POP_RANK2_SPELL_ID) then | 1621 if _G.IsSpellKnown(MR_POP_RANK2_SPELL_ID) then |
1612 modifier = modifier + 0.1 | 1622 modifier = modifier + 0.1 |
1613 elseif _G.IsSpellKnown(MR_POP_RANK1_SPELL_ID) then | 1623 elseif _G.IsSpellKnown(MR_POP_RANK1_SPELL_ID) then |
1614 modifier = modifier + 0.05 | 1624 modifier = modifier + 0.05 |
1615 end | 1625 end |
1616 | 1626 |
1617 for buff_name, rep_data_table in pairs(REP_BUFFS) do | 1627 -- Determine faction ID |
1628 local faction_ID | |
1629 for pseudo_faction_name, faction_data_table in pairs(FACTION_DATA) do | |
1630 if faction_name == faction_data_table[2] then | |
1631 faction_ID = faction_data_table[1] | |
1632 end | |
1633 end | |
1634 if faction_ID and faction_ID > 0 then | |
1635 -- Check for modifiers from Commendations (applied directly to the faction, account-wide) | |
1636 local _, _, _, _, _, _, _, _, _, _, _, _, _, _, has_bonus_rep_gain = GetFactionInfoByID(faction_ID) | |
1637 if has_bonus_rep_gain then | |
1638 modifier = modifier + 1 | |
1639 end | |
1640 end | |
1641 | |
1642 -- Check for modifiers from buffs | |
1643 for buff_name, buff_data_table in pairs(REP_BUFFS) do | |
1618 if _G.UnitBuff("player", buff_name) then | 1644 if _G.UnitBuff("player", buff_name) then |
1619 local modded_faction = rep_data_table.faction | 1645 local modded_faction = buff_data_table.faction |
1620 | 1646 |
1621 if not modded_faction or faction_name == modded_faction then | 1647 if not modded_faction or faction_name == modded_faction then |
1622 modifier = modifier + rep_data_table.modifier | 1648 if buff_data_table.ignore then |
1623 end | 1649 -- Some buffs from tabards convert all rep of other factions into rep for a specific faction. |
1624 end | 1650 -- We can't know what faction the rep was orginally from, so we must ignore the data entirely in these cases. |
1625 end | 1651 return |
1652 else | |
1653 modifier = modifier + buff_data_table.modifier | |
1654 end | |
1655 end | |
1656 end | |
1657 end | |
1658 | |
1626 npc.reputations = npc.reputations or {} | 1659 npc.reputations = npc.reputations or {} |
1627 npc.reputations[("%s:%s"):format(faction_name, faction_standings[faction_name])] = math.floor(amount / modifier) | 1660 npc.reputations[("%s:%s"):format(faction_name, faction_standings[faction_name])] = math.floor(amount / modifier) |
1628 end | 1661 end |
1629 end -- do-block | 1662 end -- do-block |
1630 | 1663 |