• 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 - Focusing on the mob with lowest HPs

Sometimes I get a bunch of mobs in the XTarget window which spread my group members' pets' attention. I am trying to code a way so they always fixate on whichever mob has lowest HP percentage.

So I have created the function below, which I call at a later time within the code if needed. Unfortunately, it is not doing what I want. Can anyone spot where the logic is wrong?

Code:
--- All pets in group to switch targets to the lowest mob in the xTarget window
    local function TargetLowestHP()
        ---Lets pick the mob in the xTarget window with lowest HP, so pets stick to it before moving to the next mob.
        local CurrentLowestMob = 0 --- This is just a default to declare the variable
        local CurrentLowestMobID = 0 --- This is just a default to declare the variable
        local CurrentLowestMobName = "0" --- This is just a default to declare the variable
        local CurrentLowestMobCleanName = "0" --- This is just a default to declare the variable
        local CurrentLowestMob = 100 --- This is just a default to declare the variable
        local CombatMobs = mq.TLO.Me.XTarget()
        local CombatSlots = mq.TLO.Me.XTargetSlots()
        local PetOwner = "0" --- This is just a default to declare the variable
        --- Lets find out the mob in Xtarget with lowest HPs
        for i = 1, CombatSlots do
            local MobsID = mq.TLO.Me.XTarget(i).ID() or 0 -- safety net: incase of a nil, make it 0
            if MobsID > 0 and mq.TLO.Me.XTarget(i).Type.NotEqual(CORPSE)() and mq.TLO.Me.XTarget(i).PctHPs() > 0  then -- safety net: make sure mob(i) is actually alive
                if mq.TLO.Me.XTarget(i).PctHPs() < CurrentLowestPctHPs then
                    CurrentLowestMob = mq.TLO.Me.XTarget(i).PctHPs()
                    CurrentLowestMobIndex = i
                end
                CurrentLowestMob = mq.TLO.Me.XTarget(CurrentLowestMobIndex).Name()
                CurrentLowestMobCleanName = mq.TLO.Me.XTarget(CurrentLowestMobIndex).CleanName()
                CurrentLowestMobID = mq.TLO.Me.XTarget(CurrentLowestMobIndex).ID()
                --- Now that we know which of the mobs in XTarget with lowest HP, lets all switch to that one.
                for j=0,NumberOfGroupMembers do
                    if mq.TLO.Group.Member(j).ID() and mq.TLO.Group.Member(j).Type.NotEqual(CORPSE)() and mq.TLO.Group.Member(j).Pet.ID() ~= 0 then
                        if mq.TLO.Group.Member(j).Pet.Target() ~= CurrentLowestMob then
                            mq.TLO.Group.Member(j).Pet.DoTarget(CurrentLowestMob)
                            mq.delay(50)
                            PetOwner = mq.TLO.Group.Member(j).CleanName()
                            mq.cmd('/dex %s /pet attack', PetOwner)
                        end
                    end
                end
            end
        end
    end
 
Are you actually setting CurrentLowestPctHPs?

I don't see an initial value being set and I don't see it being updated when you find new mobs.
 
Question - Focusing on the mob with lowest HPs

Users who are viewing this thread

Back
Top
Cart