Mercurial > wow > wowdb-profiler
comparison Main.lua @ 535:4a7989584ae8 7.2.0-5
Rewrote World Quest recording to use a less-stateful (continent-based) method of gathering World Quests.
author | MMOSimca |
---|---|
date | Tue, 18 Apr 2017 20:30:31 -0400 |
parents | 2bb33dbd3d7c |
children | ec2ee7b48c21 |
comparison
equal
deleted
inserted
replaced
534:31d084e76340 | 535:4a7989584ae8 |
---|---|
1001 end | 1001 end |
1002 | 1002 |
1003 | 1003 |
1004 -- Record data for a specific quest ID; reward data must be available or nothing will be recorded | 1004 -- Record data for a specific quest ID; reward data must be available or nothing will be recorded |
1005 -- When we reach this point, we've already checked for a valid mapID, questID, quest data, and worldQuestType | 1005 -- When we reach this point, we've already checked for a valid mapID, questID, quest data, and worldQuestType |
1006 local function RecordWorldQuestData(world_map_id, quest_id, api_data_table) | 1006 local function RecordWorldQuestData(quest_id, continent_world_map_id, zone_world_map_id, api_data_table) |
1007 | 1007 |
1008 -- Ensure we have location data and rewards (barely readable so putting it on multiple lines) | 1008 -- Ensure we have location data and rewards (barely readable so putting it on multiple lines) |
1009 -- (Honor is built in to the quest; it is not a sign rewards have been loaded) | 1009 -- (Honor is built in to the quest; it is not a sign rewards have been loaded) |
1010 if not api_data_table.x or not api_data_table.y or not api_data_table.floor or not | 1010 if not api_data_table.x or not api_data_table.y or not api_data_table.floor or not |
1011 (_G.GetQuestLogRewardXP(quest_id) > 0 or _G.GetNumQuestLogRewardCurrencies(quest_id) > 0 | 1011 (_G.GetQuestLogRewardXP(quest_id) > 0 or _G.GetNumQuestLogRewardCurrencies(quest_id) > 0 |
1012 or _G.GetNumQuestLogRewards(quest_id) > 0 or _G.GetQuestLogRewardMoney(quest_id) > 0 | 1012 or _G.GetNumQuestLogRewards(quest_id) > 0 or _G.GetQuestLogRewardMoney(quest_id) > 0 |
1013 or _G.GetQuestLogRewardArtifactXP(quest_id) > 0) then | 1013 or _G.GetQuestLogRewardArtifactXP(quest_id) > 0) then |
1014 return | 1014 return |
1015 end | 1015 end |
1016 | 1016 |
1017 -- Translate continent-level coordinates to zone-coordinates | |
1018 local oX, oY, dFloor = tonumber(api_data_table.x) or 0, tonumber(api_data_table.y) or 0, tonumber(api_data_table.floor) or 0 | |
1019 local dX, dY = HereBeDragons:TranslateZoneCoordinates(oX, oY, continent_world_map_id, 0, zone_world_map_id, dFloor, false) | |
1020 | |
1021 -- If the translation failed, stop here | |
1022 if not dX or not dY then return end | |
1023 | |
1017 local entry = DBEntry("world_quests", quest_id) | 1024 local entry = DBEntry("world_quests", quest_id) |
1018 | |
1019 if entry then | 1025 if entry then |
1020 | 1026 |
1021 -- Record location | 1027 -- Record location |
1022 entry["location"] = {} | 1028 entry["location"] = {} |
1023 entry["location"]["world_map_id"] = world_map_id | 1029 entry["location"]["world_map_id"] = zone_world_map_id |
1024 entry["location"]["x"] = (tonumber(api_data_table.x) or 0) * 100 | 1030 entry["location"]["x"] = dX * 100 |
1025 entry["location"]["y"] = (tonumber(api_data_table.y) or 0) * 100 | 1031 entry["location"]["y"] = dY * 100 |
1026 entry["location"]["floor"] = tonumber(api_data_table.floor) or 0 | 1032 entry["location"]["floor"] = dFloor |
1027 | 1033 |
1028 -- Record simple rewards (XP, money, artifact XP, honor) | 1034 -- Record simple rewards (XP, money, artifact XP, honor) |
1029 entry["rewards"] = {} | 1035 entry["rewards"] = {} |
1030 entry["rewards"]["xp"] = tonumber(_G.GetQuestLogRewardXP(quest_id)) or 0 | 1036 entry["rewards"]["xp"] = tonumber(_G.GetQuestLogRewardXP(quest_id)) or 0 |
1031 entry["rewards"]["money"] = tonumber(_G.GetQuestLogRewardMoney(quest_id)) or 0 | 1037 entry["rewards"]["money"] = tonumber(_G.GetQuestLogRewardMoney(quest_id)) or 0 |
1065 | 1071 |
1066 function WDP:ProcessWorldQuests() | 1072 function WDP:ProcessWorldQuests() |
1067 -- Ignore if player is low level (there are some world quests before max level now, but we can collect enough data from 110s alone still) | 1073 -- Ignore if player is low level (there are some world quests before max level now, but we can collect enough data from 110s alone still) |
1068 if _G.UnitLevel("player") ~= 110 then return end | 1074 if _G.UnitLevel("player") ~= 110 then return end |
1069 | 1075 |
1070 local current_world_map_id = _G.GetCurrentMapAreaID() | 1076 -- Get current continent and zones in current continent |
1071 | 1077 local continentIndex, continentID = GetCurrentMapContinent() |
1072 -- Iterate over known World Quest maps | 1078 local continentMaps = { GetMapZones(continentIndex) } |
1073 for i = 1, #private.WORLD_QUEST_MAP_IDS do | 1079 |
1074 local world_map_id = private.WORLD_QUEST_MAP_IDS[i] | 1080 -- Iterate over zones in continent |
1075 | 1081 for i = 1, #continentMaps, 2 do |
1076 -- Only bother checking the API if the world map in question is currently displayed | 1082 |
1077 if current_world_map_id == world_map_id then | 1083 -- Get data for World Quests |
1078 | 1084 local api_data = C_TaskQuest.GetQuestsForPlayerByMapID(continentMaps[i], continentID); |
1079 -- Get data for World Quests on map | 1085 |
1080 local api_data = _G.C_TaskQuest.GetQuestsForPlayerByMapID(world_map_id) | 1086 -- Iterate over the questIDs for each map, doing preload reward requests and creating SavedVariables entries |
1081 | 1087 if api_data and type(api_data) == "table" and #api_data > 0 then |
1082 -- Iterate over the questIDs for each map, doing preload reward requests and creating SavedVariables entries | 1088 for _, current_data in ipairs(api_data) do |
1083 if api_data and type(api_data) == "table" and #api_data > 0 then | 1089 |
1084 for j = 1, #api_data do | 1090 -- Check if we had a valid API table returned to us |
1085 local current_data = api_data[j] | 1091 if current_data and type(current_data) == "table" and current_data["questId"] then |
1086 | 1092 local quest_id = tonumber(current_data["questId"]) or 0 |
1087 -- Check if we had a valid API table returned to us | 1093 |
1088 if current_data and type(current_data) == "table" and current_data["questId"] then | 1094 -- Check if we have quest data |
1089 local quest_id = tonumber(current_data["questId"]) or 0 | 1095 if _G.HaveQuestData(quest_id) then |
1090 | 1096 local tag_id, tag_name, world_quest_type, rarity, is_elite, tradeskill_line_index = _G.GetQuestTagInfo(quest_id) |
1091 -- Check if we have quest data | 1097 |
1092 if _G.HaveQuestData(quest_id) then | 1098 -- Check for valid questID and whether or not it is a World Quest |
1093 local tag_id, tag_name, world_quest_type, rarity, is_elite, tradeskill_line_index = _G.GetQuestTagInfo(quest_id) | 1099 if quest_id > 0 and world_quest_type ~= nil then |
1094 | 1100 _G.C_TaskQuest.RequestPreloadRewardData(quest_id) |
1095 -- Check for valid questID and whether or not it is a World Quest | 1101 RecordWorldQuestData(quest_id, continentID, continentMaps[i], current_data) |
1096 if quest_id > 0 and world_quest_type ~= nil then | |
1097 _G.C_TaskQuest.RequestPreloadRewardData(quest_id) | |
1098 RecordWorldQuestData(world_map_id, quest_id, current_data) | |
1099 end | |
1100 end | 1102 end |
1101 end | 1103 end |
1102 end | 1104 end |
1103 end | 1105 end |
1104 end | 1106 end |