Mercurial > wow > wowdb-profiler
comparison Main.lua @ 95:c4172766561f
Record NPC says, whispers, and yells.
author | James D. Callahan III <jcallahan@curse.com> |
---|---|
date | Wed, 29 Aug 2012 15:24:29 -0500 |
parents | 75751f08d9f5 |
children | e378295b2d6f |
comparison
equal
deleted
inserted
replaced
94:75751f08d9f5 | 95:c4172766561f |
---|---|
48 AUCTION_HOUSE_SHOW = true, | 48 AUCTION_HOUSE_SHOW = true, |
49 BANKFRAME_OPENED = true, | 49 BANKFRAME_OPENED = true, |
50 BATTLEFIELDS_SHOW = true, | 50 BATTLEFIELDS_SHOW = true, |
51 BLACK_MARKET_ITEM_UPDATE = true, | 51 BLACK_MARKET_ITEM_UPDATE = true, |
52 CHAT_MSG_LOOT = true, | 52 CHAT_MSG_LOOT = true, |
53 CHAT_MSG_MONSTER_SAY = "RecordQuote", | |
54 CHAT_MSG_MONSTER_WHISPER = "RecordQuote", | |
55 CHAT_MSG_MONSTER_YELL = "RecordQuote", | |
53 CHAT_MSG_SYSTEM = true, | 56 CHAT_MSG_SYSTEM = true, |
54 COMBAT_LOG_EVENT_UNFILTERED = true, | 57 COMBAT_LOG_EVENT_UNFILTERED = true, |
55 COMBAT_TEXT_UPDATE = true, | 58 COMBAT_TEXT_UPDATE = true, |
56 FORGE_MASTER_OPENED = true, | 59 FORGE_MASTER_OPENED = true, |
57 GOSSIP_SHOW = true, | 60 GOSSIP_SHOW = true, |
87 local AF = private.ACTION_TYPE_FLAGS | 90 local AF = private.ACTION_TYPE_FLAGS |
88 | 91 |
89 | 92 |
90 local PLAYER_CLASS = _G.select(2, _G.UnitClass("player")) | 93 local PLAYER_CLASS = _G.select(2, _G.UnitClass("player")) |
91 local PLAYER_GUID = _G.UnitGUID("player") | 94 local PLAYER_GUID = _G.UnitGUID("player") |
95 local PLAYER_NAME = _G.UnitName("player") | |
92 local PLAYER_RACE = _G.select(2, _G.UnitRace("player")) | 96 local PLAYER_RACE = _G.select(2, _G.UnitRace("player")) |
97 | |
93 | 98 |
94 ----------------------------------------------------------------------- | 99 ----------------------------------------------------------------------- |
95 -- Local variables. | 100 -- Local variables. |
96 ----------------------------------------------------------------------- | 101 ----------------------------------------------------------------------- |
97 local anvil_spell_ids = {} | 102 local anvil_spell_ids = {} |
99 local currently_drunk | 104 local currently_drunk |
100 local db | 105 local db |
101 local durability_timer_handle | 106 local durability_timer_handle |
102 local faction_standings = {} | 107 local faction_standings = {} |
103 local forge_spell_ids = {} | 108 local forge_spell_ids = {} |
109 local languages_known = {} | |
110 local name_to_id_map = {} | |
104 local reputation_npc_id | 111 local reputation_npc_id |
105 local target_location_timer_handle | 112 local target_location_timer_handle |
106 local current_target_id | 113 local current_target_id |
107 | 114 |
108 | 115 |
502 | 509 |
503 function WDP:OnEnable() | 510 function WDP:OnEnable() |
504 for event_name, mapping in pairs(EVENT_MAPPING) do | 511 for event_name, mapping in pairs(EVENT_MAPPING) do |
505 self:RegisterEvent(event_name, (_G.type(mapping) ~= "boolean") and mapping or nil) | 512 self:RegisterEvent(event_name, (_G.type(mapping) ~= "boolean") and mapping or nil) |
506 end | 513 end |
514 | |
515 for index = 1, _G.GetNumLanguages() do | |
516 languages_known[_G.GetLanguageByIndex(index)] = true | |
517 end | |
507 durability_timer_handle = self:ScheduleRepeatingTimer("ProcessDurability", 30) | 518 durability_timer_handle = self:ScheduleRepeatingTimer("ProcessDurability", 30) |
508 target_location_timer_handle = self:ScheduleRepeatingTimer("UpdateTargetLocation", 0.5) | 519 target_location_timer_handle = self:ScheduleRepeatingTimer("UpdateTargetLocation", 0.5) |
509 | 520 |
510 _G.hooksecurefunc("UseContainerItem", function(bag_index, slot_index, target_unit) | 521 _G.hooksecurefunc("UseContainerItem", function(bag_index, slot_index, target_unit) |
511 if target_unit then | 522 if target_unit then |
616 ("%d:%d"):format(item_id, quantity) | 627 ("%d:%d"):format(item_id, quantity) |
617 } | 628 } |
618 GenericLootUpdate("zones") | 629 GenericLootUpdate("zones") |
619 table.wipe(action_data) | 630 table.wipe(action_data) |
620 end | 631 end |
632 | |
633 | |
634 do | |
635 local function ReplaceName(text) | |
636 if text == PLAYER_NAME then | |
637 return "<name>" | |
638 end | |
639 end | |
640 | |
641 | |
642 function WDP:RecordQuote(event_name, message, source_name, language_name) | |
643 if not source_name or not name_to_id_map[source_name] or (language_name ~= "" and not languages_known[language_name]) then | |
644 return | |
645 end | |
646 local npc = NPCEntry(name_to_id_map[source_name]) | |
647 npc.quotes = npc.quotes or {} | |
648 npc.quotes[event_name] = npc.quotes[event_name] or {} | |
649 npc.quotes[event_name][message:gsub("(%w+)", ReplaceName)] = true | |
650 end | |
651 end -- do-block | |
621 | 652 |
622 | 653 |
623 do | 654 do |
624 local SOBER_MATCH = _G.DRUNK_MESSAGE_ITEM_SELF1:gsub("%%s", ".+") | 655 local SOBER_MATCH = _G.DRUNK_MESSAGE_ITEM_SELF1:gsub("%%s", ".+") |
625 | 656 |
1231 if max_power > 0 then | 1262 if max_power > 0 then |
1232 local power_type = _G.UnitPowerType("target") | 1263 local power_type = _G.UnitPowerType("target") |
1233 encounter_data[npc_level].power = ("%s:%d"):format(POWER_TYPE_NAMES[_G.tostring(power_type)] or power_type, max_power) | 1264 encounter_data[npc_level].power = ("%s:%d"):format(POWER_TYPE_NAMES[_G.tostring(power_type)] or power_type, max_power) |
1234 end | 1265 end |
1235 end | 1266 end |
1267 name_to_id_map[_G.UnitName("target")] = unit_idnum | |
1268 | |
1236 table.wipe(action_data) | 1269 table.wipe(action_data) |
1237 action_data.type = AF.NPC | 1270 action_data.type = AF.NPC |
1238 action_data.identifier = unit_idnum | 1271 action_data.identifier = unit_idnum |
1239 action_data.npc_level = npc_level | 1272 action_data.npc_level = npc_level |
1240 self:UpdateTargetLocation() | 1273 self:UpdateTargetLocation() |