Well, it's a bit more than you want, but this is what I have been working on for a while...
This sub will find the nearest target and check that it is not within aggro range of any other target.
Declares, defines and such from the main routine are not provided but you can see the logic in it and I keep them very descriptive for the most part. Pardon the debug messages if any...my macro is riddled with them so that I could test what was and what was not working properly.
This sub runs fine, but for some reason it will occasionally target a corpse over and over...it may be lag related, as my macro is now getting to epic proportions.
Code: Select all
Sub Find_Target
/declare CountID local
/declare CountIDClosest local
/declare Count local
/declare ForInc local
/declare Targeted_MOB local
/declare TargetX local
/declare TargetY local
:CheckForTarget
/varset CountID 0
/varset Count 0
/varset Targeted_MOB 0
/varset TargetX 0
/varset TargetY 0
/alert clear 1
| if target is passed to here, is it dead? if no, then it is our next target
/if n $target(id)!=0 /if $target(state)==DEAD {
/press esc
/attack off
/echo corpse on target cleared
}
/if n $target(id)!=0 /if $target(state)<>DEAD /if n $target(distance)<50 {
/echo live target passed to find target!
/return
} else {
/press esc
/attack off
}
| Check for a MOB in camp
/if n $searchspawn(npc,radius:@Danger_Radius)>0 {
/varset Targeted_MOB $searchspawn(npc,radius:@Danger_Radius)
/target id Targeted_MOB
/echo "$target(@Targeted_MOB,name,clean)" in camp!
/return
}
| Check for single pull loop
/varset CountIDClosest $searchspawn(npc,loc:@AnchorX:@AnchorY,radius:@Pull_Radius)
/echo @CountIDClosest is count id closest
/if n @CountIDClosest>0 {
/varset Count 1
/echo adding first mob @CountIDClosest
/alert add 1 id @CountIDClosest
}
/varset TargetX $spawn(@CountIDClosest,x)
/varset TargetY $spawn(@CountIDClosest,y)
/echo @TargetX is X @TargetY is Y
| Fucking brilliant code here thanks to Gumby
:CheckMore
/echo @CountID should be zero
/varset CountID $searchspawn(npc,loc:@TargetX:@TargetY,radius:@Aggro_Radius,noalert:1)
/delay 3s
/echo @CountID should NOT be zero if near more
/delay 2s
/if n @CountID!=0 {
/varadd Count 1
/alert add 1 id @CountID
/alert list 1
/varset CountID 0
/delay 1
/echo in the checkmore loop
/goto :CheckMore
}
| Check total of MOBs for single pulls
/if n @Count==1 {
/echo Only @Count by @CountIDClosest
/goto :Found_A_Target
} else {
/echo More than one MOB! @Count total!
/echo Waiting 15 seconds
/varset Targeted_MOB 0
/varset CountIDClosest 0
/varset CountID 0
/varset Count 0
/alert clear 1
/goto :CheckForTarget
/delay 5s
}
:Found_A_Target
/alert list 1
/echo "@CountIDClosest" is next!
/target id @CountIDClosest
/varset Targeted_MOB 0
/varset CountIDClosest 0
/varset CountID 0
/varset Count 0
/alert clear 1
/return