This is extremely rough atm but its an update to show yall what I am playing with. also I haven't even loaded the db yet so I don't know if it even remotely functions.
I currently need a way to query the quest window for live quests if it doesn't have a quest I want it to acquire said quest thus eliminating all spam.
[CODE title="main.Lua"]
local mq = require 'mq'
local sqlite3 = require 'lsqlite3'
local db = sqlite3.open('quest_database.db')
-- Function to execute SQL queries
local function executeQuery(query)
assert(db:exec(query) == sqlite3.OK, db:errmsg())
end
-- Create the quests table
executeQuery[[
CREATE TABLE IF NOT EXISTS quests (
id INTEGER PRIMARY KEY,
npcName TEXT,
npcX INTEGER,
npcY INTEGER,
npcZ INTEGER,
zoneName TEXT,
invisRequired INTEGER,
ivuRequired INTEGER,
sosRequired INTEGER,
requestPhrase TEXT
)
]]
-- Create the prerequisites table
executeQuery[[
CREATE TABLE IF NOT EXISTS prerequisites (
questId INTEGER,
prerequisiteQuestId INTEGER,
FOREIGN KEY (questId) REFERENCES quests (id),
FOREIGN KEY (prerequisiteQuestId) REFERENCES quests (id)
)
]]
-- Create the completed_quests table
executeQuery[[
CREATE TABLE IF NOT EXISTS completed_quests (
questId INTEGER,
FOREIGN KEY (questId) REFERENCES quests (id)
)
]]
-- Function to insert a quest into the quests table
local function insertQuest(npcName, npcX, npcY, npcZ, zoneName, invisRequired, ivuRequired, sosRequired, requestPhrase)
local query = string.format(
[[
INSERT INTO quests (npcName, npcX, npcY, npcZ, zoneName, invisRequired, ivuRequired, sosRequired, requestPhrase)
VALUES ('%s', %d, %d, %d, '%s', %d, %d, %d, '%s')
]],
npcName, npcX, npcY, npcZ, zoneName, invisRequired and 1 or 0, ivuRequired and 1 or 0, sosRequired and 1 or 0, requestPhrase
)
executeQuery(query)
end
-- Function to insert a prerequisite relationship into the prerequisites table
local function insertPrerequisite(questId, prerequisiteQuestId)
local query = string.format(
[[
INSERT INTO prerequisites (questId, prerequisiteQuestId)
VALUES (%d, %d)
]],
questId, prerequisiteQuestId
)
executeQuery(query)
end
-- Function to mark a quest as completed in the completed_quests table
local function markQuestAsCompleted(questId)
local query = string.format(
[[
INSERT INTO completed_quests (questId)
VALUES (%d)
]],
questId
)
executeQuery(query)
end
-- Function to check if a quest is completed
local function isQuestCompleted(questId)
local query = string.format(
[[
SELECT COUNT(*) FROM completed_quests
WHERE questId = %d
]],
questId
)
local stmt = db:prepare(query)
local result = stmt:step() == sqlite3.ROW
stmt:finalize()
return result
end
-- Function to retrieve the prerequisite quest IDs for a given quest
local function getPrerequisites(questId)
local query = string.format(
[[
SELECT prerequisiteQuestId FROM prerequisites
WHERE questId = %d
]],
questId
)
local stmt = db:prepare(query)
local prerequisites = {}
while stmt:step() == sqlite3.ROW do
table.insert(prerequisites, stmt:get_value(0))
end
stmt:finalize()
return prerequisites
end
-- Function to retrieve all quests from the quests table
local function getQuests()
local query = [[
SELECT * FROM quests
]]
local stmt = db:prepare(query)
local quests = {}
while stmt:step() == sqlite3.ROW do
local quest = {
id = stmt:get_value(0),
npcName = stmt:get_value(1),
npcX = stmt:get_value(2),
npcY = stmt:get_value(3),
npcZ = stmt:get_value(4),
zoneName = stmt:get_value(5),
invisRequired = stmt:get_value(6) == 1,
ivuRequired = stmt:get_value(7) == 1,
sosRequired = stmt:get_value(8) == 1,
requestPhrase = stmt:get_value(9)
}
table.insert(quests, quest)
end
stmt:finalize()
return quests
end
-- Add your logic to move to NPC and claim rewards
local function MoveToNpcAndClaimReward(quest)
-- Retrieve the NPC location
local npcX, npcY, npcZ = GetNpcLocation(quest.npcName)
-- Calculate the target coordinates based on the NPC location
local targetX = npcX + randomValueX
local targetY = npcY + randomValueY
local targetZ = npcZ + randomValueZ
-- Check if already near the target location
local currentX, currentY, currentZ = mq.TLO.Me.X(), mq.TLO.Me.Y(), mq.TLO.Me.Z()
if currentX and currentY and currentZ then
if currentX >= targetX - 10 and currentX <= targetX + 10 and
currentY >= targetY - 10 and currentY <= targetY + 10 then
print('Already near the target location.')
else
-- Move to the target location
print('Time to go to the target location!')
mq.cmdf('/nav locyxz %d %d %d', targetY, targetX, targetZ)
mq.delay(1000) -- Adjust the delay as needed to allow time for navigation
end
else
print('Unable to retrieve character location. Skipping movement check.')
end
mq.cmdf('/multiline ; /face %s ; /target %s ; /hail', quest.npcName, quest.npcName)
mq.delay(500)
mq.delay(math.random(1000))
while OpenRewardWindow() do
mq.cmd('/mqrewards claim')
mq.delay(math.random(500))
end
mq.delay(1000)
mq.delay(math.random(1000))
end
-- Main loop
while true do
-- Retrieve all quests from the database
local quests = getQuests()
-- Iterate over the quests
for _, quest in ipairs(quests) do
-- Check if the quest is completed
if not isQuestCompleted(quest.id) then
-- Check if all prerequisites are completed
local prerequisites = getPrerequisites(quest.id)
local allPrerequisitesCompleted = true
for _, prerequisiteQuestId in ipairs(prerequisites) do
if not isQuestCompleted(prerequisiteQuestId) then
allPrerequisitesCompleted = false
break
end
end
-- Execute the logic for the quest if it's not completed and all prerequisites are completed
if allPrerequisitesCompleted then
MoveToNpcAndClaimReward(quest)
markQuestAsCompleted(quest.id)
end
end
end
-- Sleep for some time before checking the quests again
mq.sleep(3000) -- Sleep for 3 seconds
end
-- Close the database connection
db:close()
[/CODE]
[CODE title="mq.Lua"]-- mq.Lua - Minimalist multi-threading library
-- Version: 1.0
local mq = {}
local sleepImpl = function(ms)
local start = os.clock()
while os.clock() - start < ms / 1000 do end
end
local sleep = function(ms)
local co = coroutine.running()
mq.schedule(ms, function() coroutine.resume(co) end)
coroutine.yield()
end
local scheduled = {}
local updateRate = 0.1
local lastUpdate = os.clock()
mq.schedule = function(ms, fn)
local startTime = os.clock() + ms / 1000
table.insert(scheduled, {startTime = startTime, fn = fn})
end
mq.update = function()
local now = os.clock()
if now - lastUpdate >= updateRate then
lastUpdate = now
local i = 1
while i <= #scheduled do
local entry = scheduled
if entry.startTime <= now then
table.remove(scheduled, i)
entry.fn()
else
i = i + 1
end
end
end
end
mq.sleep = sleep
mq.sleepImpl = sleepImpl
return mq
[/CODE]
[CODE title="database.lua"]
-- Required libraries
local sqlite3 = require("lsqlite3")
-- Open the database or create it if it doesn't exist
local db = sqlite3.open("questly.db")
-- Create the NPCs table
local createNpcsTable = [[
CREATE TABLE IF NOT EXISTS npcs (
id INTEGER PRIMARY KEY,
name TEXT,
zoneName TEXT,
invisibility_required INTEGER DEFAULT 0,
ivu_required INTEGER DEFAULT 0,
sos_required INTEGER DEFAULT 0,
invisibility_sufficient INTEGER DEFAULT 0,
ivu_sufficient INTEGER DEFAULT 0,
sos_sufficient INTEGER DEFAULT 0,
invisibility_not_required INTEGER DEFAULT 0,
ivu_not_required INTEGER DEFAULT 0,
sos_not_required INTEGER DEFAULT 0
)
]]
db:exec(createNpcsTable)
-- Insert NPC data into the NPCs table
local insertNpcData = [[
INSERT INTO npcs (name, zoneName, invisibility_required, ivu_required, sos_required, invisibility_sufficient, ivu_sufficient, sos_sufficient, invisibility_not_required, ivu_not_required, sos_not_required)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
]]
local npcData = {
{ "Ruppoc Rockjumper", "thulehouse1", 1, 1, 1, 0, 0, 0, 0, 0, 0 },
-- Add more NPCs here
}
for _, npc in ipairs(npcData) do
db:exec(insertNpcData, npc)
end
-- Create the Quests table
local createQuestsTable = [[
CREATE TABLE IF NOT EXISTS quests (
id INTEGER PRIMARY KEY,
name TEXT,
npcId INTEGER,
requestPhrase TEXT,
prerequisiteQuestId INTEGER,
stage INTEGER,
FOREIGN KEY (npcId) REFERENCES npcs (id),
FOREIGN KEY (prerequisiteQuestId) REFERENCES quests (id)
)
]]
db:exec(createQuestsTable)
-- Insert Quest data into the Quests table
local insertQuestData = [[
INSERT INTO quests (name, npcId, requestPhrase, prerequisiteQuestId, stage)
VALUES (?, ?, ?, ?, ?)
]]
local questData = {
{ "Thinning Out Their Numbers: Bone Crafters and Quaking Haunts", 1, "bone crafters", nil, 0 },
{ "Thinning Out Their Numbers: Rotdogs and Snakes", 1, "snakes", nil, 0 },
{ "Thinning Out Their Numbers: Skeletons and Bone Golems", 1, "skeletons", nil, 0 },
{ "Thinning Out Their Numbers: Terror Guards", 1, "terror guards", nil, 0 },
{ "Thinning Out Their Numbers: Terror Spinners and Sleeper Cubes", 1, "terror spinners", nil, 0 },
-- Add more quests here
}
for _, quest in ipairs(questData) do
db:exec(insertQuestData, quest)
end
-- Close the database connection
db:close()
[/CODE]
[CODE title="invis.lua"]-- invis.lua
-- Function to check if the character has the invisibility ability
local function HasInvisibilityAbility()
-- Implement your logic here to check if the character has the invisibility ability
end
-- Function to check if the invisibility ability is sufficient for the quest
local function IsInvisibilitySufficient()
-- Implement your logic here to check if the invisibility ability is sufficient for the quest
end
-- Function to cast the invisibility ability
local function CastInvisibility()
-- Implement your logic here to cast the invisibility ability
end
-- Function to check if the character has the IVU ability
local function HasIVUAbility()
-- Implement your logic here to check if the character has the IVU ability
end
-- Function to check if the IVU ability is sufficient for the quest
local function IsIVUSufficient()
-- Implement your logic here to check if the IVU ability is sufficient for the quest
end
-- Function to cast the IVU ability
local function CastIVU()
-- Implement your logic here to cast the IVU ability
end
-- Function to check if the character has the SOS ability
local function HasSOSAbility()
-- Implement your logic here to check if the character has the SOS ability
end
-- Function to check if the SOS ability is sufficient for the quest
local function IsSOSSufficient()
-- Implement your logic here to check if the SOS ability is sufficient for the quest
end
-- Function to activate the SOS ability
local function ActivateSOS()
-- Implement your logic here to activate the SOS ability
end
-- Function to move to the quest location
local function MoveToLocation(location)
-- Implement your logic here to move to the specified location
end
-- Function to check and activate abilities before moving
local function CheckAndActivateAbilities(quest)
-- Check the required scenarios and available abilities
local invisibilityRequired = quest.invisibilityRequired
local ivuRequired = quest.ivuRequired
local sosRequired = quest.sosRequired
local invisibilityAvailable = HasInvisibilityAbility()
local ivuAvailable = HasIVUAbility()
local sosAvailable = HasSOSAbility()
-- Check if the abilities are sufficient
local invisibilitySufficient = invisibilityAvailable and IsInvisibilitySufficient()
local ivuSufficient = ivuAvailable and IsIVUSufficient()
local sosSufficient = sosAvailable and IsSOSSufficient()
-- Check and activate abilities based on the required scenarios
if invisibilityRequired and ivuRequired and sosRequired then
if invisibilitySufficient and ivuSufficient and sosSufficient then
-- All abilities are available and sufficient
CastInvisibility()
CastIVU()
ActivateSOS()
MoveToLocation(quest.location)
else
-- Abilities are either not available or not sufficient
print("Abilities required but not available or sufficient!")
end
elseif invisibilityRequired and not ivuRequired and not sosRequired then
if invisibilitySufficient then
-- Invisibility is available and sufficient
CastInvisibility()
MoveToLocation(quest.location)
else
-- Invisibility is either not available or not sufficient
print("Invisibility required but not available or sufficient!")
end
elseif invisibilityRequired and ivuRequired and not sosRequired then
if invisibilitySufficient and ivuSufficient then
-- Invisibility and IVU are available and sufficient
CastInvisibility()
CastIVU()
MoveToLocation(quest.location)
else
-- Invisibility and/or IVU are either not available or not sufficient
print("Invisibility and/or IVU required but not available or sufficient!")
end
-- Add more conditions for the remaining scenarios
else
-- No abilities required
MoveToLocation(quest.location)
end
end
-- Return the functions as a module
return {
CheckAndActivateAbilities = CheckAndActivateAbilities
}
[/CODE]
[CODE title="classes"]-- classes.lua
-- Demo Class: ExampleClass
-- This is a demo class that shows how to use the child class files.
-- You can reference this class structure to understand how to use the child classes for other EverQuest classes.
local class_info = {
{
classShortName = "EXM",
className = "ExampleClass",
Invisibility = {
{
name = "Invisibility",
activation = {
ability = "cast Invisibility",
level = 8,
type = "spell" -- Valid types: ability, aa (Alternate Advancement), spell
}
}
},
ivu = {
{
name = "IvU Evade",
activation = {
ability = "IvU Evade",
level = 12,
type = "ability" -- Valid types: ability, aa (Alternate Advancement), spell
}
}
},
evade = {
{
name = "Evade",
activation = {
ability = "Evade",
level = 6,
type = "ability" -- Valid types: ability, aa (Alternate Advancement), spell
}
}
},
sos = {
{
name = "SOS",
activation = {
ability = "SOS",
level = 18,
type = "ability" -- Valid types: ability, aa (Alternate Advancement), spell
}
}
}
},
-- Include the other EverQuest class files
dofile("classes/Bard.lua"),
dofile("classes/Beastlord.lua"),
dofile("classes/Berserker.lua"),
dofile("classes/Cleric.lua"),
dofile("classes/Druid.lua"),
dofile("classes/Enchanter.lua"),
dofile("classes/Magician.lua"),
dofile("classes/Monk.lua"),
dofile("classes/Necromancer.lua"),
dofile("classes/Paladin.lua"),
dofile("classes/Ranger.lua"),
dofile("classes/Rogue.lua"),
dofile("classes/Shadowknight.lua"),
dofile("classes/Shaman.lua"),
dofile("classes/Warrior.lua"),
dofile("classes/Wizard.lua")
}
return class_info
[/CODE]