Mercurial > wow > wowdb-profiler
comparison Main.lua @ 171:40624eb09591 1.0.21
Since many NPCs are for some reason flagged as VEHICLE, allow that in NPC-only checks.
author | James D. Callahan III <jcallahan@curse.com> |
---|---|
date | Tue, 16 Oct 2012 15:13:10 -0500 |
parents | 5f6d5a1a62e1 |
children | 7354ae12d0f1 |
comparison
equal
deleted
inserted
replaced
170:3b1f1e47897c | 171:40624eb09591 |
---|---|
375 end | 375 end |
376 return tonumber(item_link:match("item:(%d+)")) | 376 return tonumber(item_link:match("item:(%d+)")) |
377 end | 377 end |
378 | 378 |
379 | 379 |
380 local function UnitTypeIsNPC(unit_type) | |
381 return unit_type == private.UNIT_TYPES.NPC or unit_type == private.UNIT_TYPES.VEHICLE | |
382 end | |
383 | |
384 | |
380 local ParseGUID | 385 local ParseGUID |
381 do | 386 do |
382 local UNIT_TYPE_BITMASK = 0x007 | 387 local UNIT_TYPE_BITMASK = 0x007 |
383 | 388 |
384 function ParseGUID(guid) | 389 function ParseGUID(guid) |
868 current_target_id = nil | 873 current_target_id = nil |
869 return | 874 return |
870 end | 875 end |
871 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("target")) | 876 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("target")) |
872 | 877 |
873 if not unit_idnum or unit_type ~= private.UNIT_TYPES.NPC then | 878 if not unit_idnum or not UnitTypeIsNPC(unit_type) then |
874 return | 879 return |
875 end | 880 end |
876 current_target_id = unit_idnum | 881 current_target_id = unit_idnum |
877 | 882 |
878 local npc = NPCEntry(unit_idnum) | 883 local npc = NPCEntry(unit_idnum) |
1092 if not spell_id then | 1097 if not spell_id then |
1093 return | 1098 return |
1094 end | 1099 end |
1095 local source_type, source_id = ParseGUID(source_guid) | 1100 local source_type, source_id = ParseGUID(source_guid) |
1096 | 1101 |
1097 if not source_id or source_type ~= private.UNIT_TYPES.NPC then | 1102 if not source_id or not UnitTypeIsNPC(source_type) then |
1098 return | 1103 return |
1099 end | 1104 end |
1100 | 1105 |
1101 if bit.band(FLAGS_NPC_CONTROL, source_flags) == FLAGS_NPC_CONTROL and bit.band(FLAGS_NPC, source_flags) ~= 0 then | 1106 if bit.band(FLAGS_NPC_CONTROL, source_flags) == FLAGS_NPC_CONTROL and bit.band(FLAGS_NPC, source_flags) ~= 0 then |
1102 local encounter_data = NPCEntry(source_id).encounter_data[InstanceDifficultyToken()] | 1107 local encounter_data = NPCEntry(source_id).encounter_data[InstanceDifficultyToken()] |
1112 SPELL_CAST_START = RecordNPCSpell, | 1117 SPELL_CAST_START = RecordNPCSpell, |
1113 SPELL_CAST_SUCCESS = function(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name) | 1118 SPELL_CAST_SUCCESS = function(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name) |
1114 if spell_id == HEAL_BATTLE_PETS_SPELL_ID then | 1119 if spell_id == HEAL_BATTLE_PETS_SPELL_ID then |
1115 local unit_type, unit_idnum = ParseGUID(source_guid) | 1120 local unit_type, unit_idnum = ParseGUID(source_guid) |
1116 | 1121 |
1117 if unit_type == private.UNIT_TYPES.NPC and unit_idnum then | 1122 if unit_idnum and UnitTypeIsNPC(unit_type) then |
1118 NPCEntry(unit_idnum).stable_master = true | 1123 NPCEntry(unit_idnum).stable_master = true |
1119 end | 1124 end |
1120 end | 1125 end |
1121 RecordNPCSpell(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name) | 1126 RecordNPCSpell(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name) |
1122 end, | 1127 end, |
1124 if dest_guid ~= _G.UnitGUID("target") then | 1129 if dest_guid ~= _G.UnitGUID("target") then |
1125 return | 1130 return |
1126 end | 1131 end |
1127 local unit_type, unit_idnum = ParseGUID(dest_guid) | 1132 local unit_type, unit_idnum = ParseGUID(dest_guid) |
1128 | 1133 |
1129 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then | 1134 if not unit_idnum or not UnitTypeIsNPC(unit_type) then |
1130 reputation_npc_id = nil | 1135 reputation_npc_id = nil |
1131 private.harvesting = nil | 1136 private.harvesting = nil |
1132 return | 1137 return |
1133 end | 1138 end |
1134 reputation_npc_id = unit_idnum | 1139 reputation_npc_id = unit_idnum |
1556 | 1561 |
1557 function WDP:UpdateMerchantItems(event_name) | 1562 function WDP:UpdateMerchantItems(event_name) |
1558 if not current_merchant or event_name == "MERCHANT_SHOW" then | 1563 if not current_merchant or event_name == "MERCHANT_SHOW" then |
1559 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("target")) | 1564 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("target")) |
1560 | 1565 |
1561 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then | 1566 if not unit_idnum or not UnitTypeIsNPC(unit_type) then |
1562 return | 1567 return |
1563 end | 1568 end |
1564 merchant_standing = select(2, UnitFactionStanding("target")) | 1569 merchant_standing = select(2, UnitFactionStanding("target")) |
1565 current_merchant = NPCEntry(unit_idnum) | 1570 current_merchant = NPCEntry(unit_idnum) |
1566 current_merchant.sells = current_merchant.sells or {} | 1571 current_merchant.sells = current_merchant.sells or {} |
1676 if current_action.spell_label ~= "MIND_CONTROL" then | 1681 if current_action.spell_label ~= "MIND_CONTROL" then |
1677 return | 1682 return |
1678 end | 1683 end |
1679 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("pet")) | 1684 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("pet")) |
1680 | 1685 |
1681 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then | 1686 if not unit_idnum or not UnitTypeIsNPC(unit_type) then |
1682 return | 1687 return |
1683 end | 1688 end |
1684 NPCEntry(unit_idnum).mind_control = true | 1689 NPCEntry(unit_idnum).mind_control = true |
1685 table.wipe(current_action) | 1690 table.wipe(current_action) |
1686 end | 1691 end |
2025 | 2030 |
2026 if not unit_idnum or (required_type and unit_type ~= required_type) then | 2031 if not unit_idnum or (required_type and unit_type ~= required_type) then |
2027 return | 2032 return |
2028 end | 2033 end |
2029 | 2034 |
2030 if unit_type == private.UNIT_TYPES.NPC then | 2035 if UnitTypeIsNPC(unit_type) then |
2031 NPCEntry(unit_idnum)[field] = true | 2036 NPCEntry(unit_idnum)[field] = true |
2032 elseif unit_type == private.UNIT_TYPES.OBJECT then | 2037 elseif unit_type == private.UNIT_TYPES.OBJECT then |
2033 DBEntry("objects", unit_idnum)[field] = true | 2038 DBEntry("objects", unit_idnum)[field] = true |
2034 UpdateDBEntryLocation("objects", unit_idnum) | 2039 UpdateDBEntryLocation("objects", unit_idnum) |
2035 end | 2040 end |