• Hail, we're RedGuides. We want you to play six (yes, 6!) EverQuest characters at once. We have scripts and a friendly community to help, please join our playstyle and say hello! 👋
  • We've added LLM sections to our Terms & Rules and Resource Rules, for everyone's sanity & in-game safety.
    Read more
    a. Do not replace your voice with an LLM. This goes for your posts and your scripts. Drafting and editing with a tool is fine, but don't take you out of what you share.
    b. Do not replace your EQ character's voice with an LLM. We don't want scripts that speak over /ooc, /shout or other public channels. This has been an unwritten rule that's kept casino scripts off the site for decades, but we're now compelled to make it clear: keep automated communication private.

    Why Does RG Review Scripts?
    Nearly every LLM-written Lua script we see is making your character do impossible things, and rarely in a way that's beneficial to you. We've seen heavy server hammering, /target over impossible distances when /nav spawn would passively accomplish the same thing, a spawn search that fires 20+ times per second, and other pointless actions that are likely annoying GMs.

    You are welcome to use LLMs as a tool to structure, draft, and edit your work, but please read critically before hitting /lua run

Question - Delays and cast/recast times

Soandso2

Well-known member
As per usual I try to do things myself, because it is fun. I made a Lua to help me max my mage magic skills. I run it every other time or so that I level up. But there is an issue. No syntax errors or things like that, but it is something else. It has to do with cast and recast times and adding a delay, since I presume that the Lua loop does not halt and wait once the command to /cast is used. The whole thing actually works, except for the statistics part, where I get way too many "you cast this spell this many times". I have added several debug print in the casting loop, and I see that they print too many times. The Lua in its entirety is posted below. And the problems are in the highlighted area. The "casted" counter goes up too fast. Not sure what I am doing wrong. I dont see anything work logic wise but still something makes it not run as expected.

EDIT: It seems like it was the delays that were long enough. I changed the addition to the delays (highlighted below) from 250 to 1000 and all seems to work as expected.

Lua:
castDelay = mq.TLO.Spell(mSpell).CastTime() + 1000
recastDelay = mq.TLO.Spell(mSpell).RecastTime() +1000


Lua:
mq = require('mq')

require("../includes/utils")

local mSkillSpells = {
    ["Alteration"]="Renew Elements",
    ["Abjuration"]="Minor Shielding",
    ["Conjuration"]="Summon Dagger",
    ["Divination"]="True North",
    ["Evocation"]="Burst of Flame"
}

local mCasted = {
    ["Alteration"]=0,
    ["Abjuration"]=0,
    ["Conjuration"]=0,
    ["Divination"]=0,
    ["Evocation"]=0
}

local mSkillUps = {
    ["Alteration"]=0,
    ["Abjuration"]=0,
    ["Conjuration"]=0,
    ["Divination"]=0,
    ["Evocation"]=0,
    ["Specialize Alteration"]=0,
    ["Specialize Abjure"]=0,
    ["Specialize Conjuration"]=0,
    ["Specialize Divination"]=0,
    ["Specialize Evocation"]=0
}

local function skillUp(line,sSkill)
    mSkillUps[sSkill] = mSkillUps[sSkill]+1
    print("\ag"..sSkill.." skill up!")
end

local firstSpell = me.Gem(1)()
local myName = me.CleanName()
local petName = pet.CleanName()

local castDelay = 0
local recastDelay = 0

print("\ayTime for magic skills practice!")
print("\arWarning:\aw Anything on the cursor will be destroyed! You have 10 seconds to abort!")
mq.delay(10000)
if cursor.ID() then
    mq.cmd("/destroy")
end
mq.delay(1000)
print("\awSpell in gem slot one was: \ag"..firstSpell)
print("\awMy name is: \ag"..myName)
print("\awPet name is: \ag"..petName)
print ("\ayStarting the run...")

mq.event("skillup","You have become better at #1#!#*#",skillUp)

for mSkill, mSpell in pairs(mSkillSpells) do

    if cursor.ID() then
        mq.cmd("/destroy")
    end

    mq.delay(1000)
 
    castDelay = mq.TLO.Spell(mSpell).CastTime() + 250
    recastDelay = mq.TLO.Spell(mSpell).RecastTime() +250
 
    if me.Skill(mSkill)() ~= me.SkillCap(mSkill)() then
 
        if cursor.ID() then
            mq.cmd("/destroy")
        end

        print ("\ay"..mSkill)

        mq.cmdf("/memspellslot 1 %s",mSpell)
     
        mq.delay(10000)

        print("\aw Memorized \ag"..mSpell)

        print("\awCurrent skill level: \ag"..me.Skill(mSkill)().."\aw, skill cap: \am"..me.SkillCap(mSkill)())

        while me.Skill(mSkill)() ~= me.SkillCap(mSkill)() do

            if mSkill == "Alteration" then

                if target.CleanName() ~= petName then
                    print ("\aoTarget was not "..petName)
                    mq.cmd("/target "..petName)
                    print ("\awTargeted \ag"..petName)
                end
             
            elseif mSkill == "Abjuration" then

                if target.CleanName() ~= myName then
                    print ("\aoTarget was not "..myName)
                    mq.cmd("/target "..myName)
                    print ("\awTargeted \agmyself")
                end

            elseif mSkill == "Evocation" then
             
                if target.CleanName() ~= petName then
                    print ("\aoTarget was not "..petName)
                    mq.cmd("/target "..petName)
                    print ("\awTargeted \ag"..petName)
                end
             
            end
         
            mq.cmd("/cast 1")
            print("Casting delay: "..castDelay)
            mq.delay(castDelay)
            mCasted[mSkill] = mCasted[mSkill]+1
            print(mSkill.." cast " .. mCasted[mSkill] .. " times")
         
            if cursor.ID() then
                mq.cmd("/destroy")
            end
         
            print("Recasting delay: "..recastDelay)
            mq.delay(recastDelay)
         
            mq.doevents()

        end
 
    else
         print ("\aw"..mSkill.." maxed, let's try another one...")
    end
 
end

if me.Gem(1)() ~= firstSpell then
    mq.cmdf("/memspellslot 1 %s",firstSpell)
    print("\awMemorized: \ag"..firstSpell)
end

print("\ayStatistics")

for key, value in pairs(mCasted) do
    if value == 0 then
        print("\aw"..key.." not cast, probably already maxed")
    else
        print("\aw"..key..": Cast "..mCasted[key].." times, "..mSkillUps[key].." skill ups ("..tonumber(string.format("%.2f", (mSkillUps[key]/mCasted[key]*100))).."%)")
    end
end
print("\awSpecialize Abjuration: "..mSkillUps["Specialize Abjuration"].. " skill ups")
print("\awSpecialize Alteration: "..mSkillUps["Specialize Alteration"].. " skill ups")
print("\awSpecialize Conjuration: "..mSkillUps["Specialize Conjuration"].. " skill ups")
print("\awSpecialize Divination: "..mSkillUps["Specialize Divination"].. " skill ups")
print("\awSpecialize Evocation: "..mSkillUps["Specialize Evocation"].. " skill ups")

print("\ayMagic practice is over for this time!")
 
Last edited:
Question - Delays and cast/recast times

Users who are viewing this thread

Back
Top
Cart