comparison Main.lua @ 98:6b118dd1baf4

Mark NPCs which generate reputation from being harvested as such (MoP crops). Remove reputation_npc_id as soon as it is no longer needed to prevent false-positives.
author James D. Callahan III <jcallahan@curse.com>
date Fri, 31 Aug 2012 10:18:03 -0500
parents f6369b88454f
children e684a68efc5f
comparison
equal deleted inserted replaced
97:f6369b88454f 98:6b118dd1baf4
506 local category_format = ("<%s>"):format(category) 506 local category_format = ("<%s>"):format(category)
507 text = text:gsub(lookup, category_format):gsub(lookup:lower(), category_format) 507 text = text:gsub(lookup, category_format):gsub(lookup:lower(), category_format)
508 end 508 end
509 return text 509 return text
510 end 510 end
511
512
513 end -- do-block 511 end -- do-block
514 512
515 513
516 ----------------------------------------------------------------------- 514 -----------------------------------------------------------------------
517 -- Methods. 515 -- Methods.
731 UNIT_DIED = function(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name) 729 UNIT_DIED = function(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name)
732 local unit_type, unit_idnum = ParseGUID(dest_guid) 730 local unit_type, unit_idnum = ParseGUID(dest_guid)
733 731
734 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then 732 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then
735 reputation_npc_id = nil 733 reputation_npc_id = nil
734 private.harvesting = nil
736 return 735 return
737 end 736 end
738 reputation_npc_id = unit_idnum 737 reputation_npc_id = unit_idnum
739 end, 738 end,
740 } 739 }
823 822
824 if not faction_name or not faction_standings[faction_name] then 823 if not faction_name or not faction_standings[faction_name] then
825 return 824 return
826 end 825 end
827 local npc = NPCEntry(reputation_npc_id) 826 local npc = NPCEntry(reputation_npc_id)
827 reputation_npc_id = nil
828 828
829 if not npc then 829 if not npc then
830 return 830 private.harvesting = nil
831 end 831 return
832 end
833 npc.harvested = private.harvesting
834 private.harvesting = nil
835
832 local modifier = 1 836 local modifier = 1
833 837
834 if _G.IsSpellKnown(DIPLOMACY_SPELL_ID) then 838 if _G.IsSpellKnown(DIPLOMACY_SPELL_ID) then
835 modifier = modifier + 0.1 839 modifier = modifier + 0.1
836 end 840 end
850 end 854 end
851 end 855 end
852 end 856 end
853 npc.reputations = npc.reputations or {} 857 npc.reputations = npc.reputations or {}
854 npc.reputations[("%s:%s"):format(faction_name, faction_standings[faction_name])] = math.floor(amount / modifier) 858 npc.reputations[("%s:%s"):format(faction_name, faction_standings[faction_name])] = math.floor(amount / modifier)
855 reputation_npc_id = nil
856 end 859 end
857 end -- do-block 860 end -- do-block
858 861
859 862
860 function WDP:ITEM_TEXT_BEGIN(event_name) 863 function WDP:ITEM_TEXT_BEGIN(event_name)
1586 end 1589 end
1587 private.tracked_line = nil 1590 private.tracked_line = nil
1588 1591
1589 if spell_name:match("^Harvest.+") then 1592 if spell_name:match("^Harvest.+") then
1590 reputation_npc_id = current_target_id 1593 reputation_npc_id = current_target_id
1594 private.harvesting = true
1591 end 1595 end
1592 1596
1593 if anvil_spell_ids[spell_id] then 1597 if anvil_spell_ids[spell_id] then
1594 UpdateDBEntryLocation("objects", OBJECT_ID_ANVIL) 1598 UpdateDBEntryLocation("objects", OBJECT_ID_ANVIL)
1595 elseif forge_spell_ids[spell_id] then 1599 elseif forge_spell_ids[spell_id] then