Mercurial > wow > wowdb-profiler
comparison Main.lua @ 65:3f7a12a9163c
Ensure that reputation gains are attributed to the correct NPC ID and changed where within the NPC table they are stored.
| author | James D. Callahan III <jcallahan@curse.com> | 
|---|---|
| date | Thu, 26 Jul 2012 16:36:29 -0500 | 
| parents | 2421a4d39909 | 
| children | e84a1e960bed | 
   comparison
  equal
  deleted
  inserted
  replaced
| 64:2421a4d39909 | 65:3f7a12a9163c | 
|---|---|
| 580 | 580 | 
| 581 do | 581 do | 
| 582 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) | 
| 583 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) | 
| 584 | 584 | 
| 585 -- This is used to record faction gains | |
| 586 local dead_npc_id | |
| 585 | 587 | 
| 586 local function RecordNPCSpell(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name) | 588 local function RecordNPCSpell(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name) | 
| 587 if not spell_id then | 589 if not spell_id then | 
| 588 return | 590 return | 
| 589 end | 591 end | 
| 602 | 604 | 
| 603 local COMBAT_LOG_FUNCS = { | 605 local COMBAT_LOG_FUNCS = { | 
| 604 SPELL_AURA_APPLIED = RecordNPCSpell, | 606 SPELL_AURA_APPLIED = RecordNPCSpell, | 
| 605 SPELL_CAST_START = RecordNPCSpell, | 607 SPELL_CAST_START = RecordNPCSpell, | 
| 606 SPELL_CAST_SUCCESS = RecordNPCSpell, | 608 SPELL_CAST_SUCCESS = RecordNPCSpell, | 
| 609 UNIT_DIED = function(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name) | |
| 610 local unit_type, unit_idnum = ParseGUID(dest_guid) | |
| 611 | |
| 612 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then | |
| 613 dead_npc_id = nil | |
| 614 return | |
| 615 end | |
| 616 dead_npc_id = unit_idnum | |
| 617 end, | |
| 607 } | 618 } | 
| 608 | 619 | 
| 609 | 620 | 
| 610 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, ...) | 621 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, ...) | 
| 611 local combat_log_func = COMBAT_LOG_FUNCS[sub_event] | 622 local combat_log_func = COMBAT_LOG_FUNCS[sub_event] | 
| 613 if not combat_log_func then | 624 if not combat_log_func then | 
| 614 return | 625 return | 
| 615 end | 626 end | 
| 616 combat_log_func(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, ...) | 627 combat_log_func(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, ...) | 
| 617 end | 628 end | 
| 618 end -- do-block | 629 | 
| 619 | |
| 620 | |
| 621 do | |
| 622 local DIPLOMACY_SPELL_ID = 20599 | 630 local DIPLOMACY_SPELL_ID = 20599 | 
| 623 local MR_POP_RANK1_SPELL_ID = 78634 | 631 local MR_POP_RANK1_SPELL_ID = 78634 | 
| 624 local MR_POP_RANK2_SPELL_ID = 78635 | 632 local MR_POP_RANK2_SPELL_ID = 78635 | 
| 625 | 633 | 
| 626 local REP_BUFFS = { | 634 local REP_BUFFS = { | 
| 684 } | 692 } | 
| 685 } | 693 } | 
| 686 | 694 | 
| 687 | 695 | 
| 688 function WDP:COMBAT_TEXT_UPDATE(event, message_type, faction_name, amount) | 696 function WDP:COMBAT_TEXT_UPDATE(event, message_type, faction_name, amount) | 
| 689 if message_type ~= "FACTION" or not action_data.npc_level then | 697 if message_type ~= "FACTION" or not dead_npc_id then | 
| 690 return | 698 return | 
| 691 end | 699 end | 
| 692 UpdateFactionData() | 700 UpdateFactionData() | 
| 693 | 701 | 
| 694 if not faction_name or not faction_standings[faction_name] then | 702 if not faction_name or not faction_standings[faction_name] then | 
| 695 return | 703 return | 
| 696 end | 704 end | 
| 697 local npc = NPCEntry(action_data.identifier) | 705 local npc = NPCEntry(dead_npc_id) | 
| 698 | 706 | 
| 699 if not npc then | 707 if not npc then | 
| 700 return | 708 return | 
| 701 end | |
| 702 local npc_stats = npc.encounter_data[InstanceDifficultyToken()].stats | |
| 703 | |
| 704 if not npc_stats[action_data.npc_level] then | |
| 705 npc_stats[action_data.npc_level] = {} | |
| 706 end | |
| 707 local reputation_data = npc_stats[action_data.npc_level].reputations | |
| 708 | |
| 709 if not reputation_data then | |
| 710 reputation_data = {} | |
| 711 npc_stats[action_data.npc_level].reputations = reputation_data | |
| 712 end | 709 end | 
| 713 local modifier = 1 | 710 local modifier = 1 | 
| 714 | 711 | 
| 715 if _G.IsSpellKnown(DIPLOMACY_SPELL_ID) then | 712 if _G.IsSpellKnown(DIPLOMACY_SPELL_ID) then | 
| 716 modifier = modifier + 0.1 | 713 modifier = modifier + 0.1 | 
| 729 if not modded_faction or faction_name == modded_faction then | 726 if not modded_faction or faction_name == modded_faction then | 
| 730 modifier = modifier + MODIFIERS[buff_label].modifier | 727 modifier = modifier + MODIFIERS[buff_label].modifier | 
| 731 end | 728 end | 
| 732 end | 729 end | 
| 733 end | 730 end | 
| 734 reputation_data[("%s:%s"):format(faction_name, faction_standings[faction_name])] = math.floor(amount / modifier) | 731 npc.reputations = npc.reputations or {} | 
| 732 npc.reputations[("%s:%s"):format(faction_name, faction_standings[faction_name])] = math.floor(amount / modifier) | |
| 735 end | 733 end | 
| 736 end -- do-block | 734 end -- do-block | 
| 737 | 735 | 
| 738 | 736 | 
| 739 function WDP:ITEM_TEXT_BEGIN() | 737 function WDP:ITEM_TEXT_BEGIN() | 
