Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.92 KB | None | 0 0
  1. local function qcRound(num, idp)
  2.     return tonumber(string.format("%." .. (idp or 0) .. "f", num))
  3. end
  4.  
  5. function qcUpdateInitiatorData()
  6.  
  7.     for qcIndex, qcEntry in pairs(qcWorkingDB) do
  8.         if (qcWorkingDB[qcIndex][12] == nil) then
  9.             qcWorkingDB[qcIndex][12] = {}
  10.         end
  11.         if (qcWorkingDB[qcIndex][13] == nil) then
  12.             qcWorkingDB[qcIndex][13] = {}
  13.         else
  14.             wipe(qcWorkingDB[qcIndex][13])
  15.         end
  16.     end
  17.  
  18.     for qcMapIndex, qcMapEntry in pairs(qcPinDB) do
  19.         for qcInitiatorIndex, qcInitiatorEntry in pairs(qcPinDB[qcMapIndex]) do
  20.             for qcInitiatorQuestIndex, qcInitiatorQuestEntry in pairs(qcPinDB[qcMapIndex][qcInitiatorIndex][7]) do
  21.                 if (qcWorkingDB[qcInitiatorQuestEntry] == nil) then
  22.                     print("Quest not found:", qcInitiatorQuestEntry)
  23.                 else
  24.                     --local qcFloorName = _G["DUNGEON_FLOOR_" .. strupper(GetMapInfo() or "") .. (qcPinDB[qcMapIndex][qcInitiatorIndex][1])] or 0
  25.                     --if (qcFloorName ~= 0) then print(qcFloorName) end
  26.                     table.insert(qcWorkingDB[qcInitiatorQuestEntry][13],{qcPinDB[qcMapIndex][qcInitiatorIndex][3],qcPinDB[qcMapIndex][qcInitiatorIndex][4],qcMapIndex,qcPinDB[qcMapIndex][qcInitiatorIndex][1],qcRound(qcPinDB[qcMapIndex][qcInitiatorIndex][5],1),qcRound(qcPinDB[qcMapIndex][qcInitiatorIndex][6],1)})
  27.                 end
  28.             end
  29.         end
  30.     end
  31.  
  32. end
  33.  
  34. function qcVerifyMapDataExists()
  35.  
  36. --  SetMapToCurrentZone()
  37.  
  38.     local qcQuestID = GetQuestID()
  39.     local qcMapID = C_Map.GetBestMapForUnit("player")
  40.     local qcMapName = C_Map.GetMapInfo(qcMapID)
  41.  
  42.     if not (qcPinDB[qcMapID]) then
  43.         PlaySound("8959", "1115")
  44.         if (qcMapName == nil) then
  45.             print(string.format("|cFF9482C9Quest Completist DEBUG:|r [%d] |cffabd473Map ID %d [CANNOT DETECT MAP NAME] does not yet exist.|r",qcQuestID,qcMapID,(qcMapID)))
  46.         else
  47.             print(string.format("|cFF9482C9Quest Completist DEBUG:|r [%d] |cffabd473Map ID %d [%s] does not yet exist.|r",qcQuestID,qcMapID,C_Map.GetMapInfo(qcMapID)))
  48.         end
  49.         return nil
  50.     end
  51.  
  52.     local X, Y = C_Map.GetPlayerMapPosition(qcMapID, "player")
  53.     local qcX = tonumber(string.format("%.1f",X*100))
  54.     local qcY = tonumber(string.format("%.1f",Y*100))
  55.     local qcInitiatorFound
  56.     local qcInitiatorIndex
  57.     local qcQuestFound
  58.  
  59.     for qcIndex, qcEntry in pairs(qcPinDB[qcMapID]) do
  60.         if (qcEntry[4] == UnitName("questnpc")) then
  61.             if (qcEntry[5] >= qcX-0.1) and (qcEntry[5] <= qcX+0.1) and (qcEntry[6] >= qcY-0.1) and (qcEntry[6] <= qcY+0.1) then
  62.                 qcInitiatorFound = true
  63.                 qcInitiatorIndex = qcIndex
  64.                 for qcQuestIndex, qcQuestEntry in pairs(qcEntry[7]) do
  65.                     if (qcQuestEntry == qcQuestID) then
  66.                         qcQuestFound = true
  67.                     end
  68.                 end
  69.             end
  70.         end
  71.     end
  72.  
  73.     if not (qcQuestFound == true) then
  74.         if (qcInitiatorFound == true) then
  75.             PlaySoundFile("Interface\\AddOns\\QuestCompletist\\debug.mp3","8959")
  76.             print(string.format("|cFF9482C9Quest Completist DEBUG:|r [%d:%d] |cffabd473Initiator exists in map data, but quest needs added.|r [Initiator Index: %d]",qcMapID,qcQuestID,qcInitiatorIndex))
  77.         else
  78.             PlaySound("8959","1115")
  79.             print(string.format("|cFF9482C9Quest Completist DEBUG:|r [%d:%d] |cffabd473Neither initiator or quest found in map data. If initiator is stationary new map entry is likely needed.|r",qcMapID,qcQuestID))
  80.         end
  81.     end
  82.  
  83. end
  84.  
  85. function qcGenerateMapData()
  86.  
  87. --  SetMapToCurrentZone()
  88.     local qcQuestID = GetQuestID()
  89.     local qcMapID = C_Map.GetBestMapForUnit("player")
  90. --  local qcMapLevel = GetCurrentMapDungeonLevel()
  91.  
  92.     local qcIconType = 1
  93.     if (QuestIsDaily()) then
  94.         qcIconType = 3
  95.     end
  96.  
  97.     local qcInitiatorGUID = UnitGUID("questnpc")
  98.     local qcInitiatorID = 0
  99.     do
  100.         --local qcGUIDTypeBits = tonumber(strsub(qcInitiatorGUID,3,5),16)
  101.         local qcGUIDType = 0 --bit.band(qcGUIDTypeBits,0x00F)
  102.         if (qcGUIDType == 3) then
  103.             qcInitiatorID = tonumber(strsub(qcInitiatorGUID,7,10),16)
  104.         else
  105.             qcInitiatorID = 0
  106.         end
  107.     end
  108.  
  109.     local qcInitiatorName = UnitName("questnpc") or ""
  110.     if (qcInitiatorName == UnitName("player")) then
  111.         qcInitiatorName = "CHANGE_TO_NIL"
  112.     end
  113.  
  114.     local qcX = 0
  115.     local qxY = 0
  116.     do
  117.         local X, Y = C_Map.GetPlayerMapPosition(qcMapID, "player")
  118.         qcX = tonumber(string.format("%.1f",X*100))
  119.         qcY = tonumber(string.format("%.1f",Y*100))
  120.     end
  121.     print(string.format("ZONE MAP:   |cFF69CCF0[%d] = {%d,%d,%d,%q,%.1f,%.1f,{%d}},|r", qcMapID, qcMapLevel, qcIconType, qcInitiatorID, qcInitiatorName, qcX, qcY, qcQuestID))
  122.    
  123.     if (ZoomOut()) then
  124.         local qcMapID = C_Map.GetBestMapForUnit("player")
  125. --      local qcMapLevel = GetCurrentMapDungeonLevel()
  126.         do
  127.             local X, Y = C_Map.GetPlayerMapPosition(qcMapID, "player")
  128.             qcX = tonumber(string.format("%.1f",X*100))
  129.             qcY = tonumber(string.format("%.1f",Y*100))
  130.         end
  131.         if not ((qcX == 0) and (qcY ==0)) then
  132.             print(string.format("PARENT ZONE:   [%d] = {%d,%d,%d,%q,%.1f,%.1f,{%d}},", qcMapID, qcMapLevel, qcIconType, qcInitiatorID, qcInitiatorName, qcX, qcY, qcQuestID))
  133.         end
  134.     end
  135.  
  136. --  SetMapByID(14)
  137.     local qcMapID = C_Map.GetBestMapForUnit("player")
  138. --  local qcMapLevel = GetCurrentMapDungeonLevel()
  139.     do
  140.         local X, Y = C_Map.GetPlayerMapPosition(qcMapID, "player")
  141.         qcX = tonumber(string.format("%.1f",X*100))
  142.         qcY = tonumber(string.format("%.1f",Y*100))
  143.     end
  144.     if not ((qcX == 0) and (qcY ==0)) then
  145.         print(string.format("EK MAP:   [%d] = {%d,%d,%d,%q,%.1f,%.1f,{%d}},", qcMapID, qcMapLevel, qcIconType, qcInitiatorID, qcInitiatorName, qcX, qcY, qcQuestID))
  146.     end
  147.  
  148. --  SetMapByID(13)
  149.     local qcMapID = C_Map.GetBestMapForUnit("player")
  150. --  local qcMapLevel = GetCurrentMapDungeonLevel()
  151.     do
  152.         local X, Y = C_Map.GetPlayerMapPosition(qcMapID, "player")
  153.         qcX = tonumber(string.format("%.1f",X*100))
  154.         qcY = tonumber(string.format("%.1f",Y*100))
  155.     end
  156.     if not ((qcX == 0) and (qcY ==0)) then
  157.         print(string.format("KA MAP:   [%d] = {%d,%d,%d,%q,%.1f,%.1f,{%d}},", qcMapID, qcMapLevel, qcIconType, qcInitiatorID, qcInitiatorName, qcX, qcY, qcQuestID))
  158.     end
  159.  
  160. --  SetMapByID(485)
  161.     local qcMapID = C_Map.GetBestMapForUnit("player")
  162. --  local qcMapLevel = GetCurrentMapDungeonLevel()
  163.     do
  164.         local X, Y = C_Map.GetPlayerMapPosition(qcMapID, "player")
  165.         qcX = tonumber(string.format("%.1f",X*100))
  166.         qcY = tonumber(string.format("%.1f",Y*100))
  167.     end
  168.     if not ((qcX == 0) and (qcY ==0)) then
  169.         print(string.format("NR MAP:   [%d] = {%d,%d,%d,%q,%.1f,%.1f,{%d}},", qcMapID, qcMapLevel, qcIconType, qcInitiatorID, qcInitiatorName, qcX, qcY, qcQuestID))
  170.     end
  171.  
  172. --  SetMapByID(466)
  173.     local qcMapID = C_Map.GetBestMapForUnit("player")
  174. --  local qcMapLevel = GetCurrentMapDungeonLevel()
  175.     do
  176.         local X, Y = C_Map.GetPlayerMapPosition(qcMapID, "player")
  177.         qcX = tonumber(string.format("%.1f",X*100))
  178.         qcY = tonumber(string.format("%.1f",Y*100))
  179.     end
  180.     if not ((qcX == 0) and (qcY ==0)) then
  181.         print(string.format("OL MAP:   [%d] = {%d,%d,%d,%q,%.1f,%.1f,{%d}},", qcMapID, qcMapLevel, qcIconType, qcInitiatorID, qcInitiatorName, qcX, qcY, qcQuestID))
  182.     end
  183.  
  184. end
  185.  
  186. function qcFindMappedNILQuests()
  187.  
  188.     local qcCount = 0
  189.  
  190.     for qcMapIndex, qcMapEntry in pairs(qcPinDB) do
  191.         for qcInitiatorIndex, qcInitiatorEntry in pairs(qcPinDB[qcMapIndex]) do
  192.             for qcInitiatorQuestIndex, qcInitiatorQuestEntry in pairs(qcPinDB[qcMapIndex][qcInitiatorIndex][7]) do
  193.                 if (qcQuestDatabase[qcInitiatorQuestEntry] == nil) then
  194.                     qcCount = qcCount + 1
  195.                     print(qcInitiatorQuestEntry .. " - Given by: " .. tostring(qcPinDB[qcMapIndex][qcInitiatorIndex][4]))
  196.                 end
  197.             end
  198.         end
  199.     end
  200.    
  201.     print(qcCount)
  202.  
  203. end
  204.  
  205. function qcFindQuestsWithNoMapDataByZone()
  206.  
  207.     local tableinsert = table.insert
  208.     local stringformat = string.format
  209.    
  210.     wipe(qcWorkingLog)
  211.  
  212.     for qcCategoryIndex, qcCategoryEntry in pairs(qcQuestCategories) do
  213.         local qcFound
  214.         local qcCountFound = 0
  215.         local qcCountNotFound = 0
  216.         local qcQuestCount = 0
  217.         qcCategoryID = qcCategoryEntry[1]
  218.         tableinsert(qcWorkingLog, stringformat("\t%s [%d]",qcCategoryEntry[2],qcCategoryID))
  219.         for qcQuestIndex, qcQuestEntry in pairs(qcQuestDatabase) do
  220.             qcFound = false
  221.             if (qcQuestEntry[5] == qcCategoryID) then
  222.                 qcQuestCount = (qcQuestCount + 1)
  223.                 for qcMapIndex, qcMapEntry in pairs(qcPinDB) do
  224.                     for qcInitiatorIndex, qcInitiatorEntry in pairs(qcPinDB[qcMapIndex]) do
  225.                         for qcInitiatorQuestIndex, qcInitiatorQuestEntry in pairs(qcPinDB[qcMapIndex][qcInitiatorIndex][7]) do
  226.                             if (qcInitiatorQuestEntry == qcQuestIndex) then
  227.                                 qcFound = true
  228.                                 --break
  229.                             end
  230.                         end
  231.                     end
  232.                 end
  233.                 if not (qcFound) then
  234.                     tableinsert(qcWorkingLog, stringformat("\t\t[%d] [%d] %s",qcQuestEntry[1],qcQuestEntry[7],qcQuestEntry[2]))
  235.                     qcCountNotFound = (qcCountNotFound + 1)
  236.                 else
  237.                     qcCountFound = (qcCountFound + 1)
  238.                 end
  239.             end
  240.         end
  241.         if not (qcQuestCount == 0) then
  242.             tableinsert(qcWorkingLog, "\t\tOut of " .. qcQuestCount .. " quests, map data was found for " .. qcCountFound .. " (" .. qcRound(((qcCountFound/qcQuestCount)*100),2) .. "%), and " .. qcCountNotFound .. " (" .. qcRound(((qcCountNotFound/qcQuestCount)*100),2) .. "%) had no map data assosiated with it.")
  243.         end
  244.     end
  245.  
  246. end
  247.  
  248. function qcFindQuestsWithNoMapData(qcCategoryID)
  249.  
  250.     local qcFound
  251.     local qcCountFound = 0
  252.     local qcCountNotFound = 0
  253.     local qcQuestCount = 0
  254.     if (qcCategoryID == nil) then
  255.         for qcQuestIndex, qcQuestEntry in pairs(qcQuestDatabase) do
  256.             qcFound = false
  257.             qcQuestCount = (qcQuestCount + 1)
  258.             for qcMapIndex, qcMapEntry in pairs(qcPinDB) do
  259.                 for qcInitiatorIndex, qcInitiatorEntry in pairs(qcPinDB[qcMapIndex]) do
  260.                     for qcInitiatorQuestIndex, qcInitiatorQuestEntry in pairs(qcPinDB[qcMapIndex][qcInitiatorIndex][7]) do
  261.                         if (qcInitiatorQuestEntry == qcQuestIndex) then
  262.                             qcFound = true
  263.                             --break
  264.                         end
  265.                     end
  266.                 end
  267.             end
  268.             if not (qcFound) then
  269.                 print(qcQuestIndex)
  270.                 -- Log the quest details.
  271.                 -- Possibly log them by Map ID or zone or something similar?
  272.                 qcCountNotFound = (qcCountNotFound + 1)
  273.             else
  274.                 qcCountFound = (qcCountFound + 1)
  275.             end
  276.         end
  277.     else
  278.         for qcQuestIndex, qcQuestEntry in pairs(qcQuestDatabase) do
  279.             qcFound = false
  280.             if (qcQuestEntry[5] == qcCategoryID) then
  281.                 qcQuestCount = (qcQuestCount + 1)
  282.                 for qcMapIndex, qcMapEntry in pairs(qcPinDB) do
  283.                     for qcInitiatorIndex, qcInitiatorEntry in pairs(qcPinDB[qcMapIndex]) do
  284.                         for qcInitiatorQuestIndex, qcInitiatorQuestEntry in pairs(qcPinDB[qcMapIndex][qcInitiatorIndex][7]) do
  285.                             if (qcInitiatorQuestEntry == qcQuestIndex) then
  286.                                 qcFound = true
  287.                                 --break
  288.                             end
  289.                         end
  290.                     end
  291.                 end
  292.                 if not (qcFound) then
  293.                     print(qcQuestIndex)
  294.                     -- Log the quest details.
  295.                     -- Possibly log them by Map ID or zone or something similar?
  296.                     qcCountNotFound = (qcCountNotFound + 1)
  297.                 else
  298.                     qcCountFound = (qcCountFound + 1)
  299.                 end
  300.             end
  301.         end
  302.     end
  303.  
  304.     print("Out of " .. qcQuestCount .. " quests, map data was found for " .. qcCountFound .. " (" .. qcRound(((qcCountFound/qcQuestCount)*100),2) .. "%), and " .. qcCountNotFound .. " (" .. qcRound(((qcCountNotFound/qcQuestCount)*100),2) .. "%) had no map data assosiated with it.")
  305.  
  306. end                    
  307.  
  308. function qcQueryMapDataForQuest(qcQuestID)
  309.  
  310.     if not (qcQuestID) then return nil end
  311.     local qcFound
  312.     for qcMapIndex, qcMapEntry in pairs(qcPinDB) do
  313.         for qcInitiatorIndex, qcInitiatorEntry in pairs(qcPinDB[qcMapIndex]) do
  314.             for qcInitiatorQuestIndex, qcInitiatorQuestEntry in pairs(qcPinDB[qcMapIndex][qcInitiatorIndex][7]) do
  315.                 if (qcInitiatorQuestEntry == qcQuestID) then
  316.                     if not (qcFound) then
  317.                         print("Quest: " .. qcInitiatorQuestEntry .. " - " .. qcQuestDatabase[qcInitiatorQuestEntry][2])
  318.                         print("   Given by: " .. tostring(qcPinDB[qcMapIndex][qcInitiatorIndex][4]))
  319.                         print("      Located on Map ID: " .. qcMapIndex .. " @ " .. qcPinDB[qcMapIndex][qcInitiatorIndex][5] .. ", " .. qcPinDB[qcMapIndex][qcInitiatorIndex][6])
  320.                     else
  321.                         print("   Also given by: " .. tostring(qcPinDB[qcMapIndex][qcInitiatorIndex][4]))
  322.                         print("      Located on Map ID: " .. qcMapIndex .. " @ " .. qcPinDB[qcMapIndex][qcInitiatorIndex][5] .. ", " .. qcPinDB[qcMapIndex][qcInitiatorIndex][6])
  323.                     end
  324.                     qcFound = true
  325.                 end
  326.             end
  327.         end
  328.     end
  329.  
  330. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement