Sub GetTarget2
/declare count int local
/declare mobcheck int local
:Acquire
/if (${SpawnCount[npc radius ${RV_MaxRadius}]}) {
/for count 1 to ${SpawnCount[npc radius ${RV_MaxRadius}]}
/if (${NearestSpawn[${count},npc radius ${RV_MaxRadius}].Z}<${RV_MinZRange}) /goto :next
/if (${NearestSpawn[${count},npc radius ${RV_MaxRadius}].Z}>${RV_MaxZRange}) /goto :next
/for mobcheck 1 to ${RV_MobArray.Size}
/if (${NearestSpawn[${count},npc radius ${RV_MaxRadius}].CleanName.Equal[${RV_MobArray[${mobcheck}]}]}) /goto :goodname
/next mobcheck
/goto :next
:goodname
/squelch /tar ID ${NearestSpawn[${count},npc radius ${RV_MaxRadius}].ID}
/delay 1s (${Target.ID}==${NearestSpawn[${count},npc radius ${RV_MaxRadius}].ID})
/if (${Target.PctHPs}<100) {
/squelch /target clear
/goto :next
}
/varset RV_HasTarget 1
/varset RV_MyTargetName ${Target.CleanName}
/echo Acquired ${Target.CleanName} at range ${Int[${Target.Distance}]}
/return
:next
/next count
}
/delay 2s
/varcalc RV_FailCounter ${RV_FailCounter}+1
/echo Failed to Acquire Target in Range ${RV_MaxRadius} ${RV_FailCounter} Time(s)
/if (${RV_FailCounter}>=${RV_FailMax}) {
/echo Waiting for Respawns, Resetting Failure Counter...
/delay 60s
/varset RV_FailCounter 0
}
/goto :Acquire
/return