Mercurial > wow > wowdb-profiler
comparison Main.lua @ 44:2a9bb8175562
Detect reputation modifier buffs and remove their effects before storing gains.
author | James D. Callahan III <jcallahan@curse.com> |
---|---|
date | Thu, 14 Jun 2012 16:41:01 -0500 |
parents | 15f2e3d8463b |
children | 5d5a490724ec |
comparison
equal
deleted
inserted
replaced
43:15f2e3d8463b | 44:2a9bb8175562 |
---|---|
553 combat_log_func(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, ...) | 553 combat_log_func(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, ...) |
554 end | 554 end |
555 end -- do-block | 555 end -- do-block |
556 | 556 |
557 | 557 |
558 function WDP:COMBAT_TEXT_UPDATE(event, message_type, faction_name, amount) | 558 do |
559 if message_type ~= "FACTION" then | 559 local DIPLOMACY_SPELL_ID = 20599 |
560 return | 560 local MR_POP_RANK1_SPELL_ID = 78634 |
561 end | 561 local MR_POP_RANK2_SPELL_ID = 78635 |
562 local npc = NPCEntry(action_data.identifier) | 562 |
563 | 563 local REP_BUFFS = { |
564 if not npc then | 564 [_G.GetSpellInfo(30754)] = "CENARION_FAVOR", |
565 return | 565 [_G.GetSpellInfo(24705)] = "GRIM_VISAGE", |
566 end | 566 [_G.GetSpellInfo(32098)] = "HONOR_HOLD_FAVOR", |
567 local encounter_data = npc.encounter_data[InstanceDifficultyToken()].stats | 567 [_G.GetSpellInfo(39913)] = "NAZGRELS_FERVOR", |
568 local reputation_data = encounter_data[action_data.npc_level].reputations | 568 [_G.GetSpellInfo(39953)] = "SONG_OF_BATTLE", |
569 | 569 [_G.GetSpellInfo(61849)] = "SPIRIT_OF_SHARING", |
570 if not reputation_data then | 570 [_G.GetSpellInfo(32096)] = "THRALLMARS_FAVOR", |
571 reputation_data = {} | 571 [_G.GetSpellInfo(39911)] = "TROLLBANES_COMMAND", |
572 encounter_data[action_data.npc_level].reputations = reputation_data | 572 [_G.GetSpellInfo(95987)] = "UNBURDENED", |
573 end | 573 [_G.GetSpellInfo(100951)] = "WOW_ANNIVERSARY", |
574 UpdateFactionData() | 574 } |
575 reputation_data[("%s:%s"):format(faction_name, faction_standings[faction_name])] = amount | 575 |
576 end | 576 |
577 local FACTION_NAMES = { | |
578 CENARION_CIRCLE = _G.GetFactionInfoByID(609), | |
579 HONOR_HOLD = _G.GetFactionInfoByID(946), | |
580 THE_SHATAR = _G.GetFactionInfoByID(935), | |
581 THRALLMAR = _G.GetFactionInfoByID(947), | |
582 } | |
583 | |
584 | |
585 local MODIFIERS = { | |
586 CENARION_FAVOR = { | |
587 faction = FACTION_NAMES.CENARION_CIRCLE, | |
588 modifier = 0.25, | |
589 }, | |
590 GRIM_VISAGE = { | |
591 modifier = 0.1, | |
592 }, | |
593 HONOR_HOLD_FAVOR = { | |
594 faction = FACTION_NAMES.HONOR_HOLD, | |
595 modifier = 0.25, | |
596 }, | |
597 NAZGRELS_FERVOR = { | |
598 faction = FACTION_NAMES.THRALLMAR, | |
599 modifier = 0.1, | |
600 }, | |
601 SONG_OF_BATTLE = { | |
602 faction = FACTION_NAMES.THE_SHATAR, | |
603 modifier = 0.1, | |
604 }, | |
605 SPIRIT_OF_SHARING = { | |
606 modifier = 0.1, | |
607 }, | |
608 THRALLMARS_FAVOR = { | |
609 faction = FACTION_NAMES.THRALLMAR, | |
610 modifier = 0.25, | |
611 }, | |
612 TROLLBANES_COMMAND = { | |
613 faction = FACTION_NAMES.HONOR_HOLD, | |
614 modifier = 0.1, | |
615 }, | |
616 UNBURDENED = { | |
617 modifier = 0.1, | |
618 }, | |
619 WOW_ANNIVERSARY = { | |
620 modifier = 0.08, | |
621 } | |
622 } | |
623 | |
624 | |
625 function WDP:COMBAT_TEXT_UPDATE(event, message_type, faction_name, amount) | |
626 if message_type ~= "FACTION" then | |
627 return | |
628 end | |
629 UpdateFactionData() | |
630 | |
631 local npc = NPCEntry(action_data.identifier) | |
632 if not npc then | |
633 return | |
634 end | |
635 local encounter_data = npc.encounter_data[InstanceDifficultyToken()].stats | |
636 local reputation_data = encounter_data[action_data.npc_level].reputations | |
637 | |
638 if not reputation_data then | |
639 reputation_data = {} | |
640 encounter_data[action_data.npc_level].reputations = reputation_data | |
641 end | |
642 local modifier = 1 | |
643 | |
644 if _G.IsSpellKnown(DIPLOMACY_SPELL_ID) then | |
645 modifier = modifier + 0.1 | |
646 end | |
647 | |
648 if _G.IsSpellKnown(MR_POP_RANK2_SPELL_ID) then | |
649 modifier = modifier + 0.1 | |
650 elseif _G.IsSpellKnown(MR_POP_RANK1_SPELL_ID) then | |
651 modifier = modifier + 0.05 | |
652 end | |
653 | |
654 for buff_name, buff_label in pairs(REP_BUFFS) do | |
655 if _G.UnitBuff("player", buff_name) then | |
656 local modded_faction = MODIFIERS[buff_label].faction | |
657 | |
658 if not modded_faction or faction_name == modded_faction then | |
659 modifier = modifier + MODIFIERS[buff_label].modifier | |
660 end | |
661 end | |
662 end | |
663 reputation_data[("%s:%s"):format(faction_name, faction_standings[faction_name])] = math.floor(amount / modifier) | |
664 end | |
665 end -- do-block | |
577 | 666 |
578 | 667 |
579 function WDP:ITEM_TEXT_BEGIN() | 668 function WDP:ITEM_TEXT_BEGIN() |
580 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("npc")) | 669 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("npc")) |
581 | 670 |
768 update_func() | 857 update_func() |
769 end | 858 end |
770 end -- do-block | 859 end -- do-block |
771 | 860 |
772 | 861 |
773 local POINT_MATCH_PATTERNS = { | 862 do |
774 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING:gsub("%%d", "(%%d+)")), -- May no longer be necessary | 863 local POINT_MATCH_PATTERNS = { |
775 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_3V3:gsub("%%d", "(%%d+)")), -- May no longer be necessary | 864 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING:gsub("%%d", "(%%d+)")), -- May no longer be necessary |
776 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_5V5:gsub("%%d", "(%%d+)")), -- May no longer be necessary | 865 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_3V3:gsub("%%d", "(%%d+)")), -- May no longer be necessary |
777 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_BG:gsub("%%d", "(%%d+)")), | 866 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_5V5:gsub("%%d", "(%%d+)")), -- May no longer be necessary |
778 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_3V3_BG:gsub("%%d", "(%%d+)")), | 867 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_BG:gsub("%%d", "(%%d+)")), |
779 } | 868 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_3V3_BG:gsub("%%d", "(%%d+)")), |
780 | 869 } |
781 function WDP:UpdateMerchantItems(event) | 870 |
782 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("target")) | 871 function WDP:UpdateMerchantItems(event) |
783 | 872 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("target")) |
784 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then | 873 |
785 return | 874 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then |
786 end | 875 return |
787 local _, merchant_standing = UnitFactionStanding("target") | 876 end |
788 local merchant = NPCEntry(unit_idnum) | 877 local _, merchant_standing = UnitFactionStanding("target") |
789 merchant.sells = merchant.sells or {} | 878 local merchant = NPCEntry(unit_idnum) |
790 | 879 merchant.sells = merchant.sells or {} |
791 local num_items = _G.GetMerchantNumItems() | 880 |
792 | 881 local num_items = _G.GetMerchantNumItems() |
793 for item_index = 1, num_items do | 882 |
794 local _, _, copper_price, stack_size, num_available, _, extended_cost = _G.GetMerchantItemInfo(item_index) | 883 for item_index = 1, num_items do |
795 local item_id = ItemLinkToID(_G.GetMerchantItemLink(item_index)) | 884 local _, _, copper_price, stack_size, num_available, _, extended_cost = _G.GetMerchantItemInfo(item_index) |
796 | 885 local item_id = ItemLinkToID(_G.GetMerchantItemLink(item_index)) |
797 if item_id and item_id > 0 then | 886 |
798 local price_string = ActualCopperCost(copper_price, merchant_standing) | 887 if item_id and item_id > 0 then |
799 | 888 local price_string = ActualCopperCost(copper_price, merchant_standing) |
800 if extended_cost then | 889 |
801 local bg_points = 0 | 890 if extended_cost then |
802 local personal_points = 0 | 891 local bg_points = 0 |
803 | 892 local personal_points = 0 |
804 DatamineTT:ClearLines() | 893 |
805 DatamineTT:SetMerchantItem(item_index) | 894 DatamineTT:ClearLines() |
806 | 895 DatamineTT:SetMerchantItem(item_index) |
807 for line_index = 1, DatamineTT:NumLines() do | 896 |
808 local current_line = _G["WDPDatamineTTTextLeft" .. line_index] | 897 for line_index = 1, DatamineTT:NumLines() do |
809 | 898 local current_line = _G["WDPDatamineTTTextLeft" .. line_index] |
810 if not current_line then | 899 |
811 break | 900 if not current_line then |
812 end | 901 break |
813 local breakout | 902 end |
814 | 903 local breakout |
815 for match_index = 1, #POINT_MATCH_PATTERNS do | 904 |
816 local match1, match2 = current_line:GetText():match(POINT_MATCH_PATTERNS[match_index]) | 905 for match_index = 1, #POINT_MATCH_PATTERNS do |
817 personal_points = personal_points + (match1 or 0) | 906 local match1, match2 = current_line:GetText():match(POINT_MATCH_PATTERNS[match_index]) |
818 bg_points = bg_points + (match2 or 0) | 907 personal_points = personal_points + (match1 or 0) |
819 | 908 bg_points = bg_points + (match2 or 0) |
820 if match1 or match2 then | 909 |
821 breakout = true | 910 if match1 or match2 then |
911 breakout = true | |
912 break | |
913 end | |
914 end | |
915 | |
916 if breakout then | |
822 break | 917 break |
823 end | 918 end |
824 end | 919 end |
825 | 920 local currency_list = {} |
826 if breakout then | 921 local item_count = _G.GetMerchantItemCostInfo(item_index) |
827 break | 922 price_string = ("%s:%s:%s"):format(price_string, bg_points, personal_points) |
923 | |
924 for cost_index = 1, item_count do | |
925 local icon_texture, amount_required, currency_link = _G.GetMerchantItemCostItem(item_index, cost_index) | |
926 local currency_id = currency_link and ItemLinkToID(currency_link) or nil | |
927 | |
928 if (not currency_id or currency_id < 1) and icon_texture then | |
929 currency_id = icon_texture:match("[^\\]+$"):lower() | |
930 end | |
931 | |
932 if currency_id then | |
933 currency_list[#currency_list + 1] = ("(%s:%s)"):format(amount_required, currency_id) | |
934 end | |
935 end | |
936 | |
937 for currency_index = 1, #currency_list do | |
938 price_string = ("%s:%s"):format(price_string, currency_list[currency_index]) | |
828 end | 939 end |
829 end | 940 end |
830 local currency_list = {} | 941 merchant.sells[("%s:%s:[%s]"):format(item_id, stack_size, price_string)] = num_available |
831 local item_count = _G.GetMerchantItemCostInfo(item_index) | 942 end |
832 price_string = ("%s:%s:%s"):format(price_string, bg_points, personal_points) | 943 end |
833 | 944 |
834 for cost_index = 1, item_count do | 945 if _G.CanMerchantRepair() then |
835 local icon_texture, amount_required, currency_link = _G.GetMerchantItemCostItem(item_index, cost_index) | 946 merchant.can_repair = true |
836 local currency_id = currency_link and ItemLinkToID(currency_link) or nil | 947 end |
837 | 948 end |
838 if (not currency_id or currency_id < 1) and icon_texture then | 949 end -- do-block |
839 currency_id = icon_texture:match("[^\\]+$"):lower() | |
840 end | |
841 | |
842 if currency_id then | |
843 currency_list[#currency_list + 1] = ("(%s:%s)"):format(amount_required, currency_id) | |
844 end | |
845 end | |
846 | |
847 for currency_index = 1, #currency_list do | |
848 price_string = ("%s:%s"):format(price_string, currency_list[currency_index]) | |
849 end | |
850 end | |
851 merchant.sells[("%s:%s:[%s]"):format(item_id, stack_size, price_string)] = num_available | |
852 end | |
853 end | |
854 | |
855 if _G.CanMerchantRepair() then | |
856 merchant.can_repair = true | |
857 end | |
858 end | |
859 | |
860 | 950 |
861 function WDP:PET_BAR_UPDATE() | 951 function WDP:PET_BAR_UPDATE() |
862 if not action_data.label or not action_data.label == "mind_control" then | 952 if not action_data.label or not action_data.label == "mind_control" then |
863 return | 953 return |
864 end | 954 end |