comparison Main.lua @ 23:2ff0171bddae

Record spells/skills an NPC uses.
author James D. Callahan III <jcallahan@curse.com>
date Mon, 14 May 2012 12:25:10 -0500
parents 7e4ce6371608
children 7cc6ca206c00
comparison
equal deleted inserted replaced
22:7e4ce6371608 23:2ff0171bddae
36 } 36 }
37 } 37 }
38 38
39 39
40 local EVENT_MAPPING = { 40 local EVENT_MAPPING = {
41 COMBAT_LOG_EVENT_UNFILTERED = true,
41 COMBAT_TEXT_UPDATE = true, 42 COMBAT_TEXT_UPDATE = true,
42 LOOT_CLOSED = true, 43 LOOT_CLOSED = true,
43 LOOT_OPENED = true, 44 LOOT_OPENED = true,
44 MERCHANT_SHOW = "UpdateMerchantItems", 45 MERCHANT_SHOW = "UpdateMerchantItems",
45 MERCHANT_UPDATE = "UpdateMerchantItems", 46 MERCHANT_UPDATE = "UpdateMerchantItems",
339 340
340 341
341 ----------------------------------------------------------------------- 342 -----------------------------------------------------------------------
342 -- Event handlers. 343 -- Event handlers.
343 ----------------------------------------------------------------------- 344 -----------------------------------------------------------------------
345 do
346 local EXTRACT_GAS_SPELL_ID = 30427
347 local FLAGS_NPC = bit.bor(_G.COMBATLOG_OBJECT_TYPE_GUARDIAN, _G.COMBATLOG_OBJECT_CONTROL_NPC)
348 local FLAGS_NPC_CONTROL = bit.bor(_G.COMBATLOG_OBJECT_AFFILIATION_OUTSIDER, _G.COMBATLOG_OBJECT_CONTROL_NPC)
349
350
351 local function RecordNPCSpell(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name)
352 if not spell_id then
353 return
354 end
355 local source_type, source_id = WDP:ParseGUID(source_guid)
356
357 if not source_id or source_type ~= private.UNIT_TYPES.NPC then
358 return
359 end
360
361 if bit.band(FLAGS_NPC_CONTROL, source_flags) == FLAGS_NPC_CONTROL and bit.band(FLAGS_NPC, source_flags) ~= 0 then
362 local npc = DBEntry("npcs", source_id)
363 local instance_token = InstanceDifficultyToken()
364 npc.spells = npc.spells or {}
365 npc.spells[instance_token] = npc.spells[instance_token] or {}
366 npc.spells[instance_token][spell_id] = true
367 end
368 end
369
370
371 local COMBAT_LOG_FUNCS = {
372 SPELL_AURA_APPLIED = RecordNPCSpell,
373 SPELL_CAST_START = RecordNPCSpell,
374 SPELL_CAST_SUCCESS = RecordNPCSpell,
375 UNIT_DISSIPATES = function(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags)
376 -- TODO: Write this.
377 end,
378 }
379
380
381 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, ...)
382 local combat_log_func = COMBAT_LOG_FUNCS[sub_event]
383
384 if not combat_log_func then
385 return
386 end
387 combat_log_func(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, ...)
388 end
389 end -- do-block
390
391
344 function WDP:COMBAT_TEXT_UPDATE(event, message_type, faction_name, amount) 392 function WDP:COMBAT_TEXT_UPDATE(event, message_type, faction_name, amount)
345 local npc = DBEntry("npcs", action_data.id_num) 393 local npc = DBEntry("npcs", action_data.id_num)
346 394
347 if not npc then 395 if not npc then
348 return 396 return