Plugin to add a TLO similar to NearestSpawn, but lets you sort by (almost) anything. Syntax is:
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:
The 2nd highest level npc in the zone:
Lowest HP group member:
It handles a a special case for MQ2Nav as well, you can do:
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.
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.
Thanks toots for the idea and donating for development!
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):
${SpawnSort[2,desc,Level,npc]}
Lowest HP group member:
Rich (BB code):
${SpawnSort[1,asc,PctHPs,group]}
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!
TLO | Data Type(s) | Description |
---|---|---|
SpawnSort | spawn • xtarget • groupmember | Returns 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
- https://github.com/RedGuides/MQ2SpawnSort
- [git] Automation options?
- Yes