Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
205 changes: 204 additions & 1 deletion Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,203 @@ function AAPClassic.getContinent()
end
end
end

local function AAP_Quest_Text(AAP_Value)
if (type(AAP_Value) == "table" ) then
local index,value,text
text = ""
for index,value in pairs(AAP_Value) do
text = text .. ("[".. index .. "]")
end
return text
end
if AAP_Value == nil then return "nil" end
if (AAPClassic["questsNames"][AAP_Value] and AAPClassic["questsNames"][AAP_Value]["T"]) then
return ("[" .. AAP_Value .. "] " .. AAPClassic["questsNames"][AAP_Value]["T"] )
else
return ("["..AAP_Value .. "]")
end
end


local function AAP_SlashCmd(AAP_index)
if (AAP_index == "reset") then
print("AAP: Resetting Zone.")
local CurStep = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]
local Step = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]
AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = 1
AAPClassic.QH.FuncLoopNumber = 1
elseif (string.find(AAP_index,"^setzone")) then
local _, _, cmd, newZone = string.find(AAP_index, "%s?(%w+)%s?(.*)")
print("Setting zone to: ".. newZone)
if (AAPClassic.Path[newZone]) then
AAPClassic.QH.ZoneNr = newZone
AAPC1[AAPClassic.Realm][AAPClassic.Name]["setzone"]=newZone
AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = 1
AAPClassic.QH.FuncLoopNumber = 1
else
print("No such zone: "..newZone)
end

elseif (AAP_index == "zones") then
local k, zone, zones
zones={}
for k in pairs(AAPClassic.Path) do table.insert(zones, k) end
table.sort(zones, function(a,b)
return (tonumber(string.match(a,"[0-9]*")) or 0) < (tonumber(string.match(b,"[0-9]*")) or 0)
end );
for _,zone in ipairs(zones) do
print("Zone: " .. zone)
end

--print("Scammomg Zone: ".. zone)

elseif (AAP_index == "checkup") then
local QuestZones, zone, list, order, id, remove, need, TurninStep
QuestZones={}
remove={}
need={}
TurninStep={}
local ZoneSteps = AAPClassic.Path[AAPClassic.QH.ZoneNr]
local CurStep = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]
local NumSteps = getn(ZoneSteps)
print("AAP Current Zone: " .. AAPClassic.QH.ZoneNr);
print("AAP Current Step: " .. CurStep .. " of " .. NumSteps)
--This does a lot of work.
--It makes a map of all quest turnins and the zones they are in so we can check the quest log against them.
--This lets the user remove unneeded quests from their log.
--It also lets us tell them which zone each quest in their log is for, so if they should have turned it in earlier
--they can choose to abandon it or go back and turn it in.
for zone,list in pairs(AAPClassic.Path) do
--print("Scanning Zone: ".. zone)
for i = getn(list), 1, -1 do
--print(zone .. ":" .. i)
if list[i]["PickUp"] then
for order,id in pairs(list[i]["PickUp"]) do
QuestZones[id]=zone
end
end
if list[i]["Done"] then
for order,id in pairs(list[i]["Done"]) do
--print(zone .. ":" .. id)
QuestZones[id]=zone
end
end
if list[i]["Qpart"] then
for id,ignore in pairs(list[i]["Qpart"]) do
QuestZones[id]=zone
end
end
end
end
--gather which step we turn each quest in in this zone
for i = NumSteps, 1,-1 do
if ZoneSteps[i]["Done"] then
for order,id in pairs(ZoneSteps[i]["Done"]) do
TurninStep[id] = i
end
end
end
--look for quests we should have now by checking what quests we turn in after this step but don't pick up
for i = NumSteps, CurStep,-1 do
if ZoneSteps[i]["Qpart"] then
for id,ignore in pairs(ZoneSteps[i]["Qpart"]) do
need[id] = i
end
end
if ZoneSteps[i]["Done"] then
for order,id in pairs(ZoneSteps[i]["Done"]) do
need[id] = i
end
end
if ZoneSteps[i]["PickUp"] then
for order,id in pairs(ZoneSteps[i]["PickUp"]) do
need[id] = nil
end
end
end
for id,step in pairs(need) do
--print("Need " .. id .. " for " .. step)
end

for i = 1, GetNumQuestLogEntries() do
local title, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, id = GetQuestLogTitle(i)
if (isHeader) then
--ignore
elseif (need[id]) then
--print("Finishing in this zone: " .. AAP_Quest_Text(id))
need[id]=nil
elseif (QuestZones[id]) then
if (QuestZones[id] == AAPClassic.QH.ZoneNr) then
if (TurninStep[id] and (TurninStep[id] < CurStep)) then
print("Should have completed quest already " .. AAP_Quest_Text(id) .. " in step " .. TurninStep[id])
end
else
print("For another zone:" .. QuestZones[id] .. ": " .. AAP_Quest_Text(id))
end
else
--this quest isn't anywhere in the list of quests to be done
remove[id]=1
end


end
for i = 1, GetNumQuestLogEntries() do
local title, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, id = GetQuestLogTitle(i)
if (not isHeader and remove[id]) then
print("Quest not part of autopilot!: " .. AAP_Quest_Text(id))
end
end
for id,ignore in pairs(need) do
if (IsQuestFlaggedCompleted(id)) then
need[id]=nil
end
end
for id,ignore in pairs(need) do
print("WARNING! Quest Missing From Log: ".. AAP_Quest_Text(id))
end


elseif (AAP_index == "auto") then
AAPC1[AAPClassic.Realm][AAPClassic.Name]["noauto"]=false
elseif (AAP_index == "noauto") then
AAPC1[AAPClassic.Realm][AAPClassic.Name]["noauto"]=true
elseif (AAP_index == "status") then
local CurStep = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]
local Step = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]
local ZoneSteps = AAPClassic.Path[AAPClassic.QH.ZoneNr]
local NumSteps = getn(ZoneSteps)

print("AAP Current Zone: " .. AAPClassic.QH.ZoneNr)
print("AAP Current Step: " .. CurStep .. " of " .. NumSteps)
for i=0,10 do
local StepNo = CurStep+i
local Step = AAPClassic.Path[AAPClassic.QH.ZoneNr][StepNo]
if (Step ~= nil) then
if (Step["PickUp"]) then
local id = Step["PickUp"][1]
print ("Next Steps: " .. StepNo .. " Pick Up: " .. AAP_Quest_Text(id))
elseif (Step["Done"]) then
print ("Next Steps: " .. StepNo .. " Hand In: " .. AAP_Quest_Text(Step["Done"][1]))
elseif (Step["CRange"]) then
if (Step["ExtraLine"] ~= nil) then
print ("Next Steps: " .. StepNo .. " Run to Waypoint " .. Step["TT"]["x"] .. "," .. Step["TT"]["y"] .. "(" .. Step["ExtraLine"] .. ")")
else
print ("Next Steps: " .. StepNo .. " Run to Waypoint " .. Step["TT"]["x"] .. "," .. Step["TT"]["y"])
end
elseif (Step["Qpart"]) then
for id,ignore in pairs(Step["Qpart"]) do
print ("Next Steps: " .. StepNo .. " Work On: " .. AAP_Quest_Text(id))
end
elseif (Step["ExtraLine"] ~= nil) then
print("Next Steps: " .. CurStep+i .. ":" .. Step["ExtraLine"])
else
print("Next Steps: " .. CurStep+i .. ":" )
end
if (AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep+i]["PickUp"] ~= nil) then
end
end
end
elseif (AAP_index == "skip") then
print("AAP: Skipping QuestStep.")
local CurStep = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]
Expand Down Expand Up @@ -116,7 +306,20 @@ local function AAP_SlashCmd(AAP_index)
AAPClassic.QH.FuncLoopNumber = 1
end
else

if (AAP_index and AAP_index ~= "help" and AAP_index ~= '') then
print("No such aap command: "..AAP_index)
end
local cc = "|cFF00FFCC"
print ("Azeroth Auto Pilot Usage: /aap [command] where command can be:")
print ("/aap [no]auto: "..cc.."turn automatic skipping of dialogs on [or off] ")
print ("/aap reset: "..cc.."reset progress in this zone to the beginning")
print ("/aap skip: "..cc.."skip the current step and move to the next one")
print ("/aap helper: "..cc.."toggle quest helper integration")
print ("/aap status: "..cc.."show current zone and next few steps")
print ("/aap explore: "..cc.."toggle human exploring mode")
print ("/aap zones: "..cc.."list the zones of questing that have been configured")
print ("/aap setzone: "..cc.."override the auto-detection and manually set the current zone")
print ("/aap checkup: "..cc.."scan quest log for unneeded, missing or old quests")
end
end
AAPClassic.EventFrame = CreateFrame("Frame")
Expand Down
43 changes: 30 additions & 13 deletions QuestHandler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ local nr = 0
end
end
function AAPClassic.QH.UpdateMapId()
if (AAPClassic.Faction == "Horde") then
if (AAPC1[AAPClassic.Realm][AAPClassic.Name]["setzone"]) then
AAPClassic.QH.ZoneNr=AAPC1[AAPClassic.Realm][AAPClassic.Name]["setzone"]
elseif (AAPClassic.Faction == "Horde") then
AAPClassic.QH.UpdateMapIdHorde()
else
AAPClassic.QH.UpdateMapIdAlly()
Expand Down Expand Up @@ -567,6 +569,11 @@ function AAPClassic.QH.FunctionLoop()
elseif (AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]["Grind"]) then
AAPClassic.QH.BookingList.Grind = 1
elseif (AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]["UpdMapID"]) then
if ( AAPC1[AAPClassic.Realm][AAPClassic.Name]["setzone"] ) then
print("Reached the end of manually configured zone: " .. AAPC1[AAPClassic.Realm][AAPClassic.Name]["setzone"])
print("Resetting to default zone detection")
AAPC1[AAPClassic.Realm][AAPClassic.Name]["setzone"]=nil
end
AAPClassic.QH.BookingList.UpdateMapId = 1
end

Expand Down Expand Up @@ -1093,6 +1100,16 @@ function AAPClassic.CheckNamePlate()
-- end
end
end

local function IsAutocompleteOn()
local noauto = AAPC1[AAPClassic.Realm][AAPClassic.Name]["noauto"]
if ( not noauto and not IsControlKeyDown() ) then
return true
else
return false
end
end

AAPClassic.QH.LoopBooking = CreateFrame("frame")
AAPClassic.QH.LoopBooking:SetScript("OnUpdate", AAPClassic.QH.QHQueFunction)

Expand Down Expand Up @@ -1140,10 +1157,10 @@ AAPClassic.QH.EventFrame:SetScript("OnEvent", function(self, event, ...)
else
return
end
if (Step and Step["GetFP"] and not IsControlKeyDown()) then
if (Step and Step["GetFP"] and IsAutocompleteOn()) then
AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] + 1
AAPClassic.QH.FuncLoopNumber = 1
elseif (Step and Step["UseFlightPath"] and not IsControlKeyDown()) then
elseif (Step and Step["UseFlightPath"] and IsAutocompleteOn()) then
AAPClassic.QH.BookingList.UseTaxiFunc = 1
end
elseif (event=="ZONE_CHANGED") then
Expand Down Expand Up @@ -1267,22 +1284,22 @@ AAPClassic.QH.EventFrame:SetScript("OnEvent", function(self, event, ...)
return
end
end
if (IsControlKeyDown()) then
if (not IsAutocompleteOn()) then
return
end
local ActiveQuests = {GetGossipActiveQuests()}
local ActiveQNr = GetNumGossipActiveQuests()
local CLi
local NumAvailableQuests = GetNumGossipAvailableQuests()
local AvailableQuests = {GetGossipAvailableQuests()}
if (ActiveQuests and not IsControlKeyDown()) then
if (ActiveQuests and IsAutocompleteOn()) then
for CLi = 1, ActiveQNr do
if (ActiveQuests[(((CLi-1) * 6)+4)] == true) then
SelectGossipActiveQuest(CLi)
end
end
end
if (NumAvailableQuests > 0 and not IsControlKeyDown()) then
if (NumAvailableQuests > 0 and IsAutocompleteOn()) then
SelectGossipAvailableQuest(1)
end
local CurStep = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]
Expand All @@ -1291,21 +1308,21 @@ AAPClassic.QH.EventFrame:SetScript("OnEvent", function(self, event, ...)
Step = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]
end
-- Auto Gossip:
if (Step and Step["Gossip"] and not IsControlKeyDown()) then
if (Step and Step["Gossip"] and IsAutocompleteOn()) then
SelectGossipOption(1)
end
elseif (event=="QUEST_DETAIL") then
if (IsControlKeyDown()) then
if (not IsAutocompleteOn()) then
return
end
AAPClassic.QH.BookingList.AcceptQuest = 1
elseif (event=="QUEST_PROGRESS") then
if (IsControlKeyDown()) then
if (not IsAutocompleteOn()) then
return
end
AAPClassic.QH.BookingList.CompleteQuest = 1
elseif (event=="QUEST_COMPLETE") then
if (IsControlKeyDown()) then
if (not IsAutocompleteOn()) then
return
end
if (GetNumQuestChoices() > 1) then
Expand All @@ -1321,7 +1338,7 @@ AAPClassic.QH.EventFrame:SetScript("OnEvent", function(self, event, ...)
AAPClassic.QH.BookingList.GetQuestReward = 1
end
elseif (event=="QUEST_GREETING") then
if (IsControlKeyDown()) then
if (not IsAutocompleteOn()) then
return
end
local numAvailableQuests = 0;
Expand All @@ -1342,7 +1359,7 @@ AAPClassic.QH.EventFrame:SetScript("OnEvent", function(self, event, ...)
end
for i = lastAvailableQuest, numAvailableQuests do
lastAvailableQuest = i;
if (not IsControlKeyDown()) then
if (IsAutocompleteOn()) then
SelectAvailableQuest(i);
end
end
Expand Down Expand Up @@ -1465,4 +1482,4 @@ AAPClassic.QH.EventFrame:SetScript("OnEvent", function(self, event, ...)
AAPClassic.QH.FuncLoopNumber = 1
end
end
end)
end)