• You've discovered RedGuides 📕 an EverQuest multi-boxing community 🛡️🧙🗡️. We want you to play several EQ characters at once, come join us and say hello! 👋
  • IS THIS SITE UGLY? Change the look. To dismiss this notice, click the X --->
Resource icon

Utility MQ2SpawnSort

Other Authors
Included in Very Vanilla
Very Vanilla Included! No need to download.
Server Type
🏢 Live 🏘️ Emu TLP Test

Wiki Manual
Plugin to add a TLO similar to NearestSpawn, but lets you sort by (almost) anything. Syntax is:

Rich (BB code):
${SpawnSort[<n>,<asc|desc>,<member>,<spawn search string>]}

It returns the nth spawn that matches your spawn search string, sorting in ascending or descending order by whatever member you like (Level, PctHPs, etc). The member to sort by can be anything on a spawn type, so if you can do ${Spawn[something].<member>}, it'll work. A notable exception is "sub-members", like Class.ShortName. If there's a period in there, it won't work :(.

Some random examples:

The lowest level player within 100 yards:

Rich (BB code):
${SpawnSort[1,asc,Level,pc radius 100]}

The 2nd highest level npc in the zone:

Rich (BB code):

Lowest HP group member:

Rich (BB code):

It handles a a special case for MQ2Nav as well, you can do:

Rich (BB code):
/varset closestNPCID ${SpawnSort[1,asc,PathLength,npc radius 1000].ID}

Which will give you the closest NPC within 1000 yards, but using MQ2Nav path length instead of just straight line distance. PathExists works too, in case you just want to find the first spawn you can navigate to but don't care about distance.

The returned type is spawn, so if ${Spawn[].Whatever} works, so will ${SpawnSort[].Whatever}.

If the spawn search string restricts it to NPCs on your xtarget (i.e. includes xtarhater), you can sort by xtarget members, e.g. PctAggro, and it will return XTargetType instead of SpawnType. E.g.

Rich (BB code):
# if any npcs on xtarget have less than 100% aggro
/if (${SpawnSort[1,asc,PctAggro,xtarhater].PctAggro} < 100) {
    /varset npcIDontHaveAggroOnID ${SpawnSort[1,asc,PctAggro,xtarhater].ID}
    # stuff to get aggro back

You can also use "group" in spawn search, and sort by something on groupmember (probably the most useful is PctAggro again). It'll return GroupMemberType too. e.g.

Rich (BB code):
# if the highest aggro player in the group isn't the main assist
/if (!${SpawnSort[1,desc,PctAggro,group].MainAssist}) {
    /varset playerWithAggroID ${SpawnSort[1,desc,PctAggro,group].ID}
    # heal them or whatever

Thanks toots for the idea and donating for development!

TLOData Type(s)Description
SpawnSortspawnxtargetgroupmemberReturns the nth spawn that matches your spawn search string, sorting in ascending or descending order by any spawn member. There's a special case to handle MQ2Nav as well, see examples.
Source Repository
[git] Automation options?
First release
Last update
5.00 star(s) 1 ratings

More resources from alynel

Share this resource

Latest updates

  1. 20230219

    〰️Commits Update for v143 Addresses https://github.com/macroquest/macroquest/issues/635...

Latest reviews

will replace of lot of stuf in any pull macro even in kiss.