• You've discovered RedGuides, an EverQuest multi-boxing and scripting community 🧙‍♀️⚙️. We want you to play several EQ characters at once, come join us and say hello! 👋

  • A TLP without truebox has thawed (Very Vanilla ready)
    Frostreaver

Question - How does the AGGRO meter works?

Joined
Mar 20, 2024
RedCents
1,051¢
Let's imagine that I have an IF THEN statement in my code that will trigger certain actions if Aggro > 90.

Now, let's assume that there are multiple mobs listed in the xTarget window.

Will the actions be executed if I am aggro > 90 to ANY of the mobs in xTarget, or ONLY the top mob in the list?
 
by default it should only check against your target.

you can also specify an XTarget slot if you are building this into a macro or Lua. you would probably want to iterate over your XTarget list.
 
Yeah, I am building this into a Lua, and I would need it to check whether I am Aggro > 90 to ANY of the mobs in the XTarget list.

Any insights on how I could do that?
 
[CODE lang="Lua" title="from Alert Master"] for _, xTarEntry in ipairs(xTarTable) do
-- Check if xTarEntry already exists in newTable
local found = false
for j, newEntry in ipairs(newTable) do
if newEntry.MobID == xTarEntry.MobID then
-- Update newTable entry with xTarEntry data
newTable[j]['MobAggro'] = xTarEntry['MobAggro']
break
end
end
end[/CODE]
in your case you probably aren't putting it into a table first so you can just iterate over

Lua:
    if mq.TLO.Me.XTarget() > 0 then
        for i = 1, mq.TLO.Me.XTargetSlots() do
            -- check mq.TLO.Me.XTarget(i).PctAggro()
            --if mq.TLO.Me.XTarget(i).PctAggro() meets your criteria do something
        end
    end
 
Yeah, I am building this into a Lua, and I would need it to check whether I am Aggro > 90 to ANY of the mobs in the XTarget list.

Any insights on how I could do that?
[CODE lang="Lua" title="something like this"] local function CheckAggro()
local flag = false
if mq.TLO.Me.XTarget() > 0 then
for i = 1, mq.TLO.Me.XTargetSlots() do
-- check mq.TLO.Me.XTarget(i).PctAggro()
if mq.TLO.Me.XTarget(i).PctAggro() > 90 then
flag = true
return flag
end
end
end
return flag
end

-- use
if CheckAggro() then
mq.cmd('/cast %s', feignSpell)
end
[/CODE]
 
[CODE lang="lua" title="something like this"] local function CheckAggro()
local flag = false
if mq.TLO.Me.XTarget() > 0 then
for i = 1, mq.TLO.Me.XTargetSlots() do
-- check mq.TLO.Me.XTarget(i).PctAggro()
if mq.TLO.Me.XTarget(i).PctAggro() > 90 then
flag = true
return flag
end
end
end
return flag
end

-- use
if CheckAggro() then
mq.cmd('/cast %s', feignSpell)
end
[/CODE]

Thank you! one question though: I see that you have "return flag" twice inside the IF: one inside the FOR loop, and then again outside.

Any reason as of why it's twice?
 
the 2nd one is to return false if you have nothing on XTarget window or if you fail the condition checks in the for loop. the first one returns true when the conditions are met, early escape when first true value happens.
 
[CODE lang="Lua" title="Simplified Aggro Check"]local function CheckAggro()
for i = 1, mq.TLO.Me.XTarget() do
if mq.TLO.Me.XTarget(i).PctAggro() > 90 then
return true
end
end
return false
end[/CODE]

I think this can be simplified to something like this.
 
[CODE lang="lua" title="Simplified Aggro Check"]local function CheckAggro()
for i = 1, mq.TLO.Me.XTarget() do
if mq.TLO.Me.XTarget(i).PctAggro() > 90 then
return true
end
end
return false
end[/CODE]

I think this can be simplified to something like this.
indeed.
 
You will want to validate PctAggro exists before using it. In this situation it can crash your script:

if (mq.TLO.Me.XTarget(i).PctAggro() or 0) > 90 then
 
If you have a target, I would expect the PctAggro() would return between 0 and 100 percent, not nil. But I guess you never know....
 
You will want to validate PctAggro exists before using it. In this situation it can crash your script:

if (mq.TLO.Me.XTarget(i).PctAggro() or 0) > 90 then

This is an interesting take, but I am not sure I follow. Could you elaborate further please?
 
He's giving a default value of 0 in case of a nil value.

Pretty sure pctAggro returns a number always but it never hurts to be safe.
I did the check prior to make sure there was an xtarget at which point you shouldn't get a nil.
 
He's giving a default value of 0 in case of a nil value.

Pretty sure pctAggro returns a number always but it never hurts to be safe.
I did the check prior to make sure there was an xtarget at which point you shouldn't get a nil.
Did you test it when that xtarget is no longer there?

Start Loop 5 Xtargets
By loop 4 Xtarget 1 is dead, 5 moves to 4, 5 is nil etc.
I've hit a ton of these with rgmercs.
 
i never get a nil return its typically at 100 or last value when no target on xtarg for that slot.
If you check that mq.TLO.Me.XTarget(i).ID > 0 we don't care if there is nothing in that XTarget slot and skip over it.
looking back i did forget this check in the post above though.

making that my primary check I haven't had a nil PctAggro.

again though it never hurts to play it safe with a default value safety net.

and this is what i see with Lua evaulator.

1712803364556.png
 
Code:
local function CheckAggro()
   for i = 1, mq.TLO.Me.XTarget() do
      if mq.TLO.Me.XTarget(i).PctAggro() > 90 then
         return true
      end
   end
   return false
end

The problem that I am having is that, many times, neither mq.TLO.Me.XTarget() nor mq.TLO.Me.XTarget(1).PctAggro() reset back to zero when all the mobs in the Xtarget list have been killed off.

See screenshots below.

Firstly, I just zoned in and my aggro list was empty, and both mq.TLO.Me.XTarget() and mq.TLO.Me.XTarget(1).PctAggro() were at 0:

Screenshot 2024-04-11 100721.png

Then, I pulled a mob and mq.TLO.Me.XTarget() updated to 1 and mq.TLO.Me.XTarget(1).PctAggro() updated to 100:

Screenshot 2024-04-11 100734.png

Finally, my pet killed the mob off yet mq.TLO.Me.XTarget() did not go back to 0 and mq.TLO.Me.XTarget(1).PctAggro() did not reset, even though the Xtarget list was indeed empty once again:

Screenshot 2024-04-11 100854.png

Is this a bug? Why dont they reset to their original state?
 
Sorry about that I forgot the check if
mq.TLO.Me.XTarget(i).ID() > 0 check

I added it in to the prior code.
That will update properly
 
Sorry about that I forgot the check if
mq.TLO.Me.XTarget(i).ID() > 0 check

I added it in to the prior code.
That will update properly

This double-check made the trick!

While mq.TLO.Me.XTarget() still shows (incorrectly) that there are mobs in the XTarget list (even though all of them have been killed off), your mq.TLO.Me.XTarget(i).ID() > 0 double check returns that the inexistent mob's ID is obviously 0, thus preventing the IF from executing the commands within. Brilliant :)
 
and for added protection. as Derple said you can do something like this.


Code:
        for i = 1, mq.TLO.Me.XTargetSlots() do
            local xID = mq.TLO.Me.XTarget(i).ID() or 0 -- safety net incase of a nil make it 0
            if  xID > 0 then
 
Question - How does the AGGRO meter works?

Users who are viewing this thread

Back
Top
Cart