(Although, I still count 272 semicolons in the actual createpath.lua file

Code: Select all
hf_type = sprintf("ChoiceOptionByName \'%s\'",name)
Code: Select all
! Accept quest 1
! Accept quest 2
? Complete quest 1
option 1
option 2
Code: Select all
Command> addressPtrsBase = memoryReadInt(getProc(), addresses.getTEXT)
Command> startloc = memoryReadInt(getProc(), addressPtrsBase + 0x268)
Command> endloc = memoryReadInt(getProc(), addressPtrsBase + 0x26C)
Command> st="Leave conversation" found = findPatternInProcess(getProc(),string.char(0)..st..string.char(0), string.rep("x",#st+2),startloc,endloc) print(memoryReadString(getProc(),found+1)) repeat found = found -1 if memoryReadByte(getProc(), found) == 0 then break end until false print(memoryReadString(getProc(),found+1))
Leave conversation
HOUSE_MAID_LEAVE_TALK
Have you looking into a way to detect when multiple quest reward options are offered and possibly prompting the user to select one? ie: CompleteQuestByName(123456,2) I know that I've created waypoints in the past where I forgot to add the second option to pick the reward, and the bot would just brute force its way through accepting the first option.Bill D Cat wrote:AcceptQuestByName() is easy. The issue lies in CompleteQuestByName() where there are multiple quest rewards to pick from.
Code: Select all
if player.Class1 == CLASS_WARRIOR or player.Class1 == CLASS_KNIGHT then
CompleteQuestByName(123456,1) -- Chain Armor Option
elseif player.Class1 == CLASS_SCOUT or player.Class1 == CLASS_ROGUE then
CompleteQuestByName(123456,2) -- Leather Armor Option
elseif player.Class1 == CLASS_MAGE or player.Class1 == CLASS_PRIEST then
CompleteQuestByName(123456,1) -- Cloth Armor Option
end
Code: Select all
CompleteQuestByName(123456,1) -- questname -- (cloth hat name), leather hat name, chain hat name, plate hat name
Code: Select all
getKeyString("the string")
Code: Select all
getKeyString("the string", true, "SC_", "SP")
Code: Select all
function getKeyStrings(text, returnfirst, keytextstart, keytextend)
local proc = getProc()
local addressPtrsBase = memoryReadInt(proc, addresses.getTEXT)
local startloc = memoryReadInt(proc, addressPtrsBase + 0x268)
local endloc = memoryReadInt(proc, addressPtrsBase + 0x26C)
local results = {}
-- Returns the key string of the text found at address 'address'. 'address' points to the 0 before the text.
local function getkeystr(address)
repeat
address = address -1
until memoryReadByte(proc, address) == 0
if address < startloc then
address = startloc
else
address = address + 1
end
return memoryReadString(proc, address)
end
-- Returns nil if no results and prints them if there are results. Only applies to result tables.
local function getResults()
if #results == 0 then
return
else
table.print(results)
return results
end
end
--== First search for an exact match with findPatternInProcess because it's so fast.
local rangestart = startloc
local found, tmpkey
repeat
found = findPatternInProcess(proc, string.char(0)..text..string.char(0), string.rep("x",#text+2), rangestart, endloc-rangestart);
if found ~= 0 then
tmpkey = getkeystr(found)
if (keytextstart == nil or tmpkey > keytextstart) and (keytextend == nil or keytextend > tmpkey) then
if returnfirst == true then
return tmpkey
else
table.insert(results, tmpkey)
end
end
rangestart = found + #text+1 -- continue from here to find more matches
if rangestart >= endloc then break end
end
until found == 0
-- If results found, return them.
if #results > 0 then
return getResults()
end
--== Now search for text with substrings that match.
-- Get the start address
local address = startloc
if keytextstart then
address = findPatternInProcess(proc, string.char(0)..keytextstart, string.rep("x",#keytextstart+1), startloc, endloc-startloc)+1;
end
local tmpkey, tmptext, tmpstrpat = "","",""
local translatedSubTEXT
repeat repeat -- Second 'repeat' is break loop
-- Get key string and text
tmpkey = memoryReadString(proc, address) -- key string
address = address + #tmpkey + 1
tmptext = memoryReadString(proc, address) -- text
address = address + #tmptext + 1
-- end of specified key string range
if keytextend and tmpkey > keytextend then
return getResults()
end
-- only search key strings with substrings.
if not string.find(tmptext,"%[") then break end
-- Skip text with variables, eg. [$var], because they wont match anyway.
if string.find(tmptext,"%[%$") then break end
-- Skip text with %s or %d because they wont match anyway.
if string.find(tmptext,"%%[sd]") then break end
-- Create find pattern
tmpstrpat = string.gsub(tmptext,"[%(%)%-%+%*%?]","%%%1") -- prefix special characters with '%'
tmpstrpat = string.gsub(tmpstrpat,"%[.-%]",".*") -- change substrings to '.*'
if string.find(tmpstrpat,"%w") and string.find(text, tmpstrpat) then
for subTEXT in string.gmatch(tmptext,"%[([^%$].-)%]") do
if tonumber(subTEXT) then -- Must be id
translatedSubTEXT = GetIdName(tonumber(subTEXT))
else
translatedSubTEXT = getTEXT(subTEXT)
end
if translatedSubTEXT ~= nil and translatedSubTEXT ~= subTEXT and not string.find(translatedSubTEXT,"%%") then
tmptext = string.gsub(tmptext, "%["..subTEXT.."%]", translatedSubTEXT, 1)
end
end
if tmptext == text then
if returnfirst == true then
return tmpkey
else
table.insert(results, tmpkey)
end
end
end
until true until address >= endloc-1
return getResults()
end
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 1 guest