I made a routine called AcquireTarget2.inc which will pull any NPC which isn't near another and doesn't have any other NPCs in the path to pull (animated gif below).
Haven't had too much time to test this with the new code rewrite but the old one seemed pretty stable (although it took a while). Before the rewrite it would take 5-8 seconds (an eternity if your calling it every few seconds). Now it takes ~1.5s. Not to mention it was a major mindfuck before and took almost twice as much code (thank you all who contributed your thoughts on optimization in the Macro Help forum).
Please post any bug reports / comments you have in this thread.

BE SURE TO /call InitializeTargettingVariables somewhere in your macro ONCE!!
Code: Select all
|
| AcquireTarget will evaluate the distance between the closest
| X mobs and see if there is one that isn't too close to another mob
| Returns true if it found and targetted a valid spawn
|
| Also builds the array of ids of the nearest ${ClosestMobsToEvaluate} npcs
| This is later checked to see if mobs are moving around and if there is need
| to worry (return to anchor and reacquire target)
|
| Pieced together by SlimFastForYou.. many thanks to the MacroQuest Community for
| their help and feedback - this belongs to anyone and everyone who wants it.
|
|
Sub AcquireTarget
/varset NumCandidates 0
/for Counter 1 to 10
| CheckMob is a whore... here it is being employed as a temp spawn id holder..
| in the future it will be used for loops
/varset CurrentMobID ${NearestSpawn[${Counter},npc nopcnear].ID}
/if (!${Spawn[${CurrentMobID}].NearestSpawn[npc radius ${TooCloseDistance}].ID}) {
/varcalc NumCandidates ${NumCandidates}+1
/varset CandidateArray[${NumCandidates}] ${CurrentMobID}
}
/next Counter
/if (!${NumCandidates}) /return 0
/for Counter 1 to ${NumCandidates}
/varset CannotPull 0
/for CheckCoordinate 0 to 15
/call ComputePlane ${CheckCoordinate} 15 ${Me.Y} ${Spawn[${CandidateArray[${Counter}]}].Y}
/varset CheckY ${Macro.Return}
/call ComputePlane ${CheckCoordinate} 15 ${Me.X} ${Spawn[${CandidateArray[${Counter}]}].X}
/varset CheckX ${Macro.Return}
/if (${Spawn[loc ${CheckX} ${CheckY} npc radius ${TooCloseDistance} notid ${CandidateArray[${Counter}]}].ID}) {
/varset CannotPull 1
/varset CheckCoordinate 15
/varset CheckMob 15
}
/next CheckCoordinate
/if (!${CannotPull}) {
/varset TargetToPull ${CandidateArray[${Counter}]}
/echo Targeting ${TargetToPull}
/target id ${TargetToPull}
/return 1
}
/next Counter
/return 0
}
/return 0
Sub InitializeTargettingVariables
/squelch /target clear
/declare Counter int outer
/declare CheckMob int outer
/declare CheckCoordinate int outer
/declare CurrentMobID int outer
/declare CheckX float outer
/declare CheckY float outer
/declare CheckMobID int outer
/declare TargetToPull int outer
/declare TooCloseDistance int outer 134
/declare CannotPull bool outer
/declare NumCandidates int outer
/declare CandidateArray[10] int outer
/return
Sub ComputePlane(int Numerator, int Divisor, float MeN, float MobN)
/declare tempint int local
/declare Answer int local
/varcalc tempint ${MobN}-${MeN}
/varcalc tempint ${tempint}*${Numerator}
/varcalc Answer ${Math.Calc[${tempint}/${Divisor}]}+${MeN}
/return ${Answer}
Current Wishlist:
- Better Comments
- Alerts (good mobs, bad mobs, dont wanna go near mobs, etc)


donations for this month's patches.