comparison Main.lua @ 27:120740b8a54f

Record what skills profession trainers train, the player's class, and each skill's minimum level and minimum profession level requirements.
author James D. Callahan III <jcallahan@curse.com>
date Thu, 17 May 2012 11:40:33 -0500
parents 565af5d2002a
children 11afd2cc0b83
comparison
equal deleted inserted replaced
26:565af5d2002a 27:120740b8a54f
38 38
39 39
40 local EVENT_MAPPING = { 40 local EVENT_MAPPING = {
41 COMBAT_LOG_EVENT_UNFILTERED = true, 41 COMBAT_LOG_EVENT_UNFILTERED = true,
42 COMBAT_TEXT_UPDATE = true, 42 COMBAT_TEXT_UPDATE = true,
43 LOOT_CLOSED = true,
44 LOOT_OPENED = true, 43 LOOT_OPENED = true,
45 MERCHANT_SHOW = "UpdateMerchantItems", 44 MERCHANT_SHOW = "UpdateMerchantItems",
46 MERCHANT_UPDATE = "UpdateMerchantItems", 45 MERCHANT_UPDATE = "UpdateMerchantItems",
47 PET_BAR_UPDATE = true, 46 PET_BAR_UPDATE = true,
48 PLAYER_TARGET_CHANGED = true, 47 PLAYER_TARGET_CHANGED = true,
49 QUEST_COMPLETE = true, 48 QUEST_COMPLETE = true,
50 QUEST_DETAIL = true, 49 QUEST_DETAIL = true,
51 QUEST_LOG_UPDATE = true, 50 QUEST_LOG_UPDATE = true,
51 TRAINER_SHOW = true,
52 UNIT_QUEST_LOG_CHANGED = true, 52 UNIT_QUEST_LOG_CHANGED = true,
53 UNIT_SPELLCAST_FAILED = "HandleSpellFailure", 53 UNIT_SPELLCAST_FAILED = "HandleSpellFailure",
54 UNIT_SPELLCAST_FAILED_QUIET = "HandleSpellFailure", 54 UNIT_SPELLCAST_FAILED_QUIET = "HandleSpellFailure",
55 UNIT_SPELLCAST_INTERRUPTED = "HandleSpellFailure", 55 UNIT_SPELLCAST_INTERRUPTED = "HandleSpellFailure",
56 UNIT_SPELLCAST_SENT = true, 56 UNIT_SPELLCAST_SENT = true,
57 UNIT_SPELLCAST_SUCCEEDED = true, 57 UNIT_SPELLCAST_SUCCEEDED = true,
58 } 58 }
59 59
60 60
61 local AF = private.ACTION_TYPE_FLAGS 61 local AF = private.ACTION_TYPE_FLAGS
62
63
64 local PLAYER_CLASS = _G.select(2, _G.UnitClass("player"))
62 65
63 66
64 ----------------------------------------------------------------------- 67 -----------------------------------------------------------------------
65 -- Local variables. 68 -- Local variables.
66 ----------------------------------------------------------------------- 69 -----------------------------------------------------------------------
393 end 396 end
394 end -- do-block 397 end -- do-block
395 398
396 399
397 function WDP:COMBAT_TEXT_UPDATE(event, message_type, faction_name, amount) 400 function WDP:COMBAT_TEXT_UPDATE(event, message_type, faction_name, amount)
398 local npc = DBEntry("npcs", action_data.id_num) 401 local npc = DBEntry("npcs", action_data.identifier)
399 402
400 if not npc then 403 if not npc then
401 return 404 return
402 end 405 end
403 npc.encounter_data[action_data.npc_level].reputations = npc.encounter_data[action_data.npc_level].reputations or {} 406 npc.encounter_data[action_data.npc_level].reputations = npc.encounter_data[action_data.npc_level].reputations or {}
404 npc.encounter_data[action_data.npc_level].reputations[faction_name] = amount 407 npc.encounter_data[action_data.npc_level].reputations[faction_name] = amount
405 end
406
407
408 function WDP:LOOT_CLOSED()
409 -- table.wipe(action_data)
410 end 408 end
411 409
412 410
413 do 411 do
414 local re_gold = _G.GOLD_AMOUNT:gsub("%%d", "(%%d+)") 412 local re_gold = _G.GOLD_AMOUNT:gsub("%%d", "(%%d+)")
453 [AF.NPC] = function() 451 [AF.NPC] = function()
454 if not _G.UnitExists("target") or _G.UnitIsFriend("player", "target") or _G.UnitIsPlayer("target") or _G.UnitPlayerControlled("target") then 452 if not _G.UnitExists("target") or _G.UnitIsFriend("player", "target") or _G.UnitIsPlayer("target") or _G.UnitPlayerControlled("target") then
455 return false 453 return false
456 end 454 end
457 local unit_type, id_num = WDP:ParseGUID(_G.UnitGUID("target")) 455 local unit_type, id_num = WDP:ParseGUID(_G.UnitGUID("target"))
458 action_data.id_num = id_num 456 action_data.identifier = id_num
459 return true 457 return true
460 end, 458 end,
461 [AF.OBJECT] = true, 459 [AF.OBJECT] = true,
462 [AF.ZONE] = function() 460 [AF.ZONE] = function()
463 return action_data.label and _G.IsFishingLoot() 461 return action_data.label and _G.IsFishingLoot()
464 end, 462 end,
465 } 463 }
466 464
467 465
468 local function GenericLootUpdate(data_type) 466 local function GenericLootUpdate(data_type)
469 local entry = DBEntry(data_type, action_data.id_num) 467 local entry = DBEntry(data_type, action_data.identifier)
470 468
469 print("GenericLootUpdate")
471 if not entry then 470 if not entry then
471 print(("Missing DB entry for %s (%s)"):format(data_type, tostring(action_data.identifier)))
472 return 472 return
473 end 473 end
474 local loot_type = action_data.label or "drops" 474 local loot_type = action_data.label or "drops"
475 entry[loot_type] = entry[loot_type] or {} 475 entry[loot_type] = entry[loot_type] or {}
476 476
671 671
672 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then 672 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then
673 return 673 return
674 end 674 end
675 DBEntry("npcs", unit_idnum).mind_control = true 675 DBEntry("npcs", unit_idnum).mind_control = true
676 print("Wiping action_data")
676 table.wipe(action_data) 677 table.wipe(action_data)
677 end 678 end
678 679
679 680
680 do 681 do
756 npc.encounter_data[npc_level].power = ("%s:%d"):format(POWER_TYPE_NAMES[_G.tostring(power_type)] or power_type, max_power) 757 npc.encounter_data[npc_level].power = ("%s:%d"):format(POWER_TYPE_NAMES[_G.tostring(power_type)] or power_type, max_power)
757 end 758 end
758 end 759 end
759 table.wipe(action_data) 760 table.wipe(action_data)
760 action_data.type = AF.NPC 761 action_data.type = AF.NPC
761 action_data.id_num = unit_idnum 762 action_data.identifier = unit_idnum
762 action_data.npc_level = npc_level 763 action_data.npc_level = npc_level
763 end 764 end
764 end -- do-block 765 end -- do-block
765 766
766 do 767 do
789 790
790 791
791 function WDP:QUEST_DETAIL() 792 function WDP:QUEST_DETAIL()
792 local quest = UpdateQuestJuncture("begin") 793 local quest = UpdateQuestJuncture("begin")
793 794
794 local _, class = _G.UnitClass("player")
795 quest.classes = quest.classes or {} 795 quest.classes = quest.classes or {}
796 quest.classes[class] = true 796 quest.classes[PLAYER_CLASS] = true
797 797
798 local _, race = _G.UnitRace("player") 798 local _, race = _G.UnitRace("player")
799 quest.races = quest.races or {} 799 quest.races = quest.races or {}
800 quest.races[race] = true 800 quest.races[race] = true
801 end 801 end
810 function WDP:UNIT_QUEST_LOG_CHANGED(event, unit_id) 810 function WDP:UNIT_QUEST_LOG_CHANGED(event, unit_id)
811 if unit_id ~= "player" then 811 if unit_id ~= "player" then
812 return 812 return
813 end 813 end
814 self:RegisterEvent("QUEST_LOG_UPDATE") 814 self:RegisterEvent("QUEST_LOG_UPDATE")
815 end
816
817
818 function WDP:TRAINER_SHOW()
819 if not _G.IsTradeskillTrainer() then
820 return
821 end
822 local unit_type, unit_idnum = self:ParseGUID(_G.UnitGUID("target"))
823 local npc = DBEntry("npcs", unit_idnum)
824 npc.teaches = npc.teaches or {}
825
826 -- Get the initial trainer filters
827 local available = _G.GetTrainerServiceTypeFilter("available")
828 local unavailable = _G.GetTrainerServiceTypeFilter("unavailable")
829 local used = _G.GetTrainerServiceTypeFilter("used")
830
831 -- Clear the trainer filters
832 _G.SetTrainerServiceTypeFilter("available", 1)
833 _G.SetTrainerServiceTypeFilter("unavailable", 1)
834 _G.SetTrainerServiceTypeFilter("used", 1)
835
836 for index = 1, _G.GetNumTrainerServices(), 1 do
837 local spell_name, rank_name, _, _, required_level = _G.GetTrainerServiceInfo(index)
838
839 if spell_name then
840 DatamineTT:ClearLines()
841 DatamineTT:SetTrainerService(index)
842
843 local _, _, spell_id = DatamineTT:GetSpell()
844 local profession, min_skill = _G.GetTrainerServiceSkillReq(index)
845 profession = profession or "General"
846
847 local class_professions = npc.teaches[PLAYER_CLASS]
848 if not class_professions then
849 npc.teaches[PLAYER_CLASS] = {}
850 class_professions = npc.teaches[PLAYER_CLASS]
851 end
852
853 local profession_skills = class_professions[profession]
854 if not profession_skills then
855 class_professions[profession] = {}
856 profession_skills = class_professions[profession]
857 end
858 profession_skills[spell_id] = ("%d:%d"):format(required_level, min_skill)
859 end
860 end
861
862 -- Reset the filters to what they were before
863 _G.SetTrainerServiceTypeFilter("available", available or 0)
864 _G.SetTrainerServiceTypeFilter("unavailable", unavailable or 0)
865 _G.SetTrainerServiceTypeFilter("used", used or 0)
815 end 866 end
816 867
817 868
818 function WDP:UNIT_SPELLCAST_SENT(event_name, unit_id, spell_name, spell_rank, target_name, spell_line) 869 function WDP:UNIT_SPELLCAST_SENT(event_name, unit_id, spell_name, spell_rank, target_name, spell_line)
819 if private.tracked_line or unit_id ~= "player" then 870 if private.tracked_line or unit_id ~= "player" then