Mercurial > wow > wowdb-profiler
comparison Main.lua @ 67:8cbb3d7b8522
Renamed dead_npc_id to reputation_npc_id for clarity, and set it to nil when QUEST_COMPLETE fires so quest NPCs aren't attributed.
| author | James D. Callahan III <jcallahan@curse.com> |
|---|---|
| date | Thu, 02 Aug 2012 11:56:44 -0500 |
| parents | e84a1e960bed |
| children | 95b8bf6b6fdb |
comparison
equal
deleted
inserted
replaced
| 66:e84a1e960bed | 67:8cbb3d7b8522 |
|---|---|
| 26 | 26 |
| 27 | 27 |
| 28 ----------------------------------------------------------------------- | 28 ----------------------------------------------------------------------- |
| 29 -- Local constants. | 29 -- Local constants. |
| 30 ----------------------------------------------------------------------- | 30 ----------------------------------------------------------------------- |
| 31 local DB_VERSION = 1 | 31 local DB_VERSION = 3 |
| 32 | 32 |
| 33 local DATABASE_DEFAULTS = { | 33 local DATABASE_DEFAULTS = { |
| 34 global = { | 34 global = { |
| 35 items = {}, | 35 items = {}, |
| 36 npcs = {}, | 36 npcs = {}, |
| 80 local durability_timer_handle | 80 local durability_timer_handle |
| 81 local target_location_timer_handle | 81 local target_location_timer_handle |
| 82 local action_data = {} | 82 local action_data = {} |
| 83 local currently_drunk | 83 local currently_drunk |
| 84 local faction_standings = {} | 84 local faction_standings = {} |
| 85 local reputation_npc_id | |
| 85 | 86 |
| 86 | 87 |
| 87 ----------------------------------------------------------------------- | 88 ----------------------------------------------------------------------- |
| 88 -- Helper Functions. | 89 -- Helper Functions. |
| 89 ----------------------------------------------------------------------- | 90 ----------------------------------------------------------------------- |
| 579 | 580 |
| 580 do | 581 do |
| 581 local FLAGS_NPC = bit.bor(_G.COMBATLOG_OBJECT_TYPE_GUARDIAN, _G.COMBATLOG_OBJECT_CONTROL_NPC) | 582 local FLAGS_NPC = bit.bor(_G.COMBATLOG_OBJECT_TYPE_GUARDIAN, _G.COMBATLOG_OBJECT_CONTROL_NPC) |
| 582 local FLAGS_NPC_CONTROL = bit.bor(_G.COMBATLOG_OBJECT_AFFILIATION_OUTSIDER, _G.COMBATLOG_OBJECT_CONTROL_NPC) | 583 local FLAGS_NPC_CONTROL = bit.bor(_G.COMBATLOG_OBJECT_AFFILIATION_OUTSIDER, _G.COMBATLOG_OBJECT_CONTROL_NPC) |
| 583 | 584 |
| 584 -- This is used to record faction gains | |
| 585 local dead_npc_id | |
| 586 | |
| 587 local function RecordNPCSpell(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name) | 585 local function RecordNPCSpell(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name) |
| 588 if not spell_id then | 586 if not spell_id then |
| 589 return | 587 return |
| 590 end | 588 end |
| 591 local source_type, source_id = ParseGUID(source_guid) | 589 local source_type, source_id = ParseGUID(source_guid) |
| 607 SPELL_CAST_SUCCESS = RecordNPCSpell, | 605 SPELL_CAST_SUCCESS = RecordNPCSpell, |
| 608 UNIT_DIED = function(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name) | 606 UNIT_DIED = function(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name) |
| 609 local unit_type, unit_idnum = ParseGUID(dest_guid) | 607 local unit_type, unit_idnum = ParseGUID(dest_guid) |
| 610 | 608 |
| 611 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then | 609 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then |
| 612 dead_npc_id = nil | 610 reputation_npc_id = nil |
| 613 return | 611 return |
| 614 end | 612 end |
| 615 dead_npc_id = unit_idnum | 613 reputation_npc_id = unit_idnum |
| 616 end, | 614 end, |
| 617 } | 615 } |
| 618 | 616 |
| 619 | 617 |
| 620 function WDP:COMBAT_LOG_EVENT_UNFILTERED(event, time_stamp, sub_event, hide_caster, source_guid, source_name, source_flags, source_raid_flags, dest_guid, dest_name, dest_flags, dest_raid_flags, ...) | 618 function WDP:COMBAT_LOG_EVENT_UNFILTERED(event, time_stamp, sub_event, hide_caster, source_guid, source_name, source_flags, source_raid_flags, dest_guid, dest_name, dest_flags, dest_raid_flags, ...) |
| 691 } | 689 } |
| 692 } | 690 } |
| 693 | 691 |
| 694 | 692 |
| 695 function WDP:COMBAT_TEXT_UPDATE(event, message_type, faction_name, amount) | 693 function WDP:COMBAT_TEXT_UPDATE(event, message_type, faction_name, amount) |
| 696 if message_type ~= "FACTION" or not dead_npc_id then | 694 if message_type ~= "FACTION" or not reputation_npc_id then |
| 697 return | 695 return |
| 698 end | 696 end |
| 699 UpdateFactionData() | 697 UpdateFactionData() |
| 700 | 698 |
| 701 if not faction_name or not faction_standings[faction_name] then | 699 if not faction_name or not faction_standings[faction_name] then |
| 702 return | 700 return |
| 703 end | 701 end |
| 704 local npc = NPCEntry(dead_npc_id) | 702 local npc = NPCEntry(reputation_npc_id) |
| 705 | 703 |
| 706 if not npc then | 704 if not npc then |
| 707 return | 705 return |
| 708 end | 706 end |
| 709 local modifier = 1 | 707 local modifier = 1 |
| 727 end | 725 end |
| 728 end | 726 end |
| 729 end | 727 end |
| 730 npc.reputations = npc.reputations or {} | 728 npc.reputations = npc.reputations or {} |
| 731 npc.reputations[("%s:%s"):format(faction_name, faction_standings[faction_name])] = math.floor(amount / modifier) | 729 npc.reputations[("%s:%s"):format(faction_name, faction_standings[faction_name])] = math.floor(amount / modifier) |
| 730 reputation_npc_id = nil | |
| 732 end | 731 end |
| 733 end -- do-block | 732 end -- do-block |
| 734 | 733 |
| 735 | 734 |
| 736 function WDP:ITEM_TEXT_BEGIN() | 735 function WDP:ITEM_TEXT_BEGIN() |
| 1082 return quest | 1081 return quest |
| 1083 end | 1082 end |
| 1084 | 1083 |
| 1085 | 1084 |
| 1086 function WDP:QUEST_COMPLETE() | 1085 function WDP:QUEST_COMPLETE() |
| 1086 -- Make sure the quest NPC isn't erroneously recorded as giving reputation for quests which award it. | |
| 1087 reputation_npc_id = nil | |
| 1087 UpdateQuestJuncture("end") | 1088 UpdateQuestJuncture("end") |
| 1088 end | 1089 end |
| 1089 | 1090 |
| 1090 | 1091 |
| 1091 function WDP:QUEST_DETAIL() | 1092 function WDP:QUEST_DETAIL() |
