Potential Target Macro

Fixxer

Active member
Joined
May 22, 2011
Messages
429
Reaction score
32
Points
28
I was wondering if I could get some help to finish this. It works, but the problem I am running into is that before the potential target reaches 45% health, the character is constantly targeting and clearing its target.

How can I check the health of a target to determine if I want to target it or not?

Also, I realize this is a mess, so if you have any suggestions to help me clean it up so it isn't such a hack would be appreciated.

Code:
#turbo 40 

Sub Main 
:loopstart 
/if (${Target.ID}==FALSE) {
   /call NewTarget 
} else { 
   /call NextTarget 
}
/if (${Target.Distance}>175) { 
   /target clear
}
/if (${Target.PctHPs}>45)  {
   /target clear
}
   /goto :loopstart
/return 

Sub NewTarget 
/declare potentialTarget int local ${Spawn[npc radius 175].ID} 
/declare i int local 1 

:targetLoop
/if (${Spawn[id ${potentialTarget}].Distance}<1) { 
   /return
} 
/if (${Spawn[id ${potentialTarget}].LineOfSight}) { 
   /target id ${potentialTarget} 
/if (${Target.PctHPs}>45)  {
   /target clear
   /return
   } else {
   /face
   /pet kill
} else { 
   /goto :loopstart
}
/return 

Sub NextTarget
/declare potentialTarget int local ${Spawn[npc radius 175].ID} 
/declare i int local 1 
/if (!${Target.LineOfSight}) { 
   /target clear
/return 
} 
/if (${Target.Distance}>175) { 
   /target clear
/return 
} else { 
   /varset i ${i} + 1 
   /varset potentialTarget ${NearestSpawn[${i},npc radius 175].ID}
|   /delay 35
   /return
}
/goto :loopstart
/return
 
I was wondering if I could get some help to finish this. It works, but the problem I am running into is that before the potential target reaches 45% health, the character is constantly targeting and clearing its target.

How can I check the health of a target to determine if I want to target it or not?

Also, I realize this is a mess, so if you have any suggestions to help me clean it up so it isn't such a hack would be appreciated.

Code:
#turbo 40 

Sub Main 
:loopstart 
/if (${Target.ID}==FALSE) {
   /call NewTarget 
} else { 
   /call NextTarget 
}
/if (${Target.Distance}>175) { 
   /target clear
}
/if (${Target.PctHPs}>45)  {
   /target clear
}
   /goto :loopstart
/return 

Sub NewTarget 
/declare potentialTarget int local ${Spawn[npc radius 175].ID} 
/declare i int local 1 

:targetLoop
/if (${Spawn[id ${potentialTarget}].Distance}<1) { 
   /return
} 
/if (${Spawn[id ${potentialTarget}].LineOfSight}) { 
   /target id ${potentialTarget} 
/if (${Target.PctHPs}>45)  {
   /target clear
   /return
   } else {
   /face
   /pet kill
} else { 
   /goto :loopstart
}
/return 

Sub NextTarget
/declare potentialTarget int local ${Spawn[npc radius 175].ID} 
/declare i int local 1 
/if (!${Target.LineOfSight}) { 
   /target clear
/return 
} 
/if (${Target.Distance}>175) { 
   /target clear
/return 
} else { 
   /varset i ${i} + 1 
   /varset potentialTarget ${NearestSpawn[${i},npc radius 175].ID}
|   /delay 35
   /return
}
/goto :loopstart
/return

"It works, but the problem I am running into is that before the potential target reaches 45% health, the character is constantly targeting and clearing its target."

-> /if (${Target.PctHPs}>45)
 
Yes... That is part of my problem. I am trying to figure out how to determine if a potential target is worthy of being a target, without actually targeting it.

In this case, if there is line of sight & within a distance of 175 & 45% or less health, then target and kill...

I can't seem to figure out how to make it happen without actually targeting the spawn, and even then, the code is pretty rough (my skills are weak)...

Worst case scenario would be to use it as is, but I can't help but wonder if there is a way to prevent the MQ2 window from getting spammed with "clear target"...
 
Last edited:
You don't always get timely HP info on mobs unless you *do* have them on target. Outside of 600' they update even less reliably. For the purposes of this conversation, xtarget counts as having them on target.
 
Last edited:
Could you give an example of how I might use that? I have cleaned up my code somewhat... I'll post it again. I really am open to suggestions on how to improve on this.

Thanks. :)

Code:
#turbo 40 

Sub Main 
:loopstart 
/if (${Target.ID}==FALSE) {
   /call NewTarget 
} else { 
   /call NextTarget 
}
/if (${Target.Distance}>175) { 
   /target clear
}
   /goto :loopstart
/return 

Sub NewTarget 
/declare potentialTarget int local ${Spawn[npc radius 175].ID} 
/declare i int local 1 

:targetLoop
/if (${Spawn[id ${potentialTarget}].Distance}<1) { 
   /return
} 
/if (${Spawn[id ${potentialTarget}].LineOfSight}) { 
   /target id ${potentialTarget}
   }
/if (${Target.PctHPs}>45)  {
   /delay 3
   /target clear
   /return
   } else {
|   /face
   /pet kill
} else { 
   /goto :loopstart
}
/return 

Sub NextTarget
/declare potentialTarget int local ${Spawn[npc radius 175].ID} 
/declare i int local 1 
/if (!${Target.LineOfSight}) { 
   /target clear
/return 
} 
/if (${Target.Distance}>175) { 
   /target clear
/return 
} else { 
   /varset i ${i} + 1 
   /varset potentialTarget ${NearestSpawn[${i},npc radius 175].ID}
|   /delay 35
   /return
}
/goto :loopstart
/return
 
${Spawn[npc radius 175].PctHPs} will return whatever last known is, but like i said, it isnt always reliable due to how spawn info is updated when you dont have something on target/xtarget.
 
I thought that if the mob was close, that it updates more frequently so the target can be displayed on the screen and coming after you... Else you would have mobs running to you invisibly and wouldn't show up until you get hit. Is that not the case?
 
I thought that if the mob was close, that it updates more frequently so the target can be displayed on the screen and coming after you... Else you would have mobs running to you invisibly and wouldn't show up until you get hit. Is that not the case?
location and hp udpates are not necessarily linked. have you never noticed that when you first target mobs on raids they are always 100%? then their hitpoints immediately drop to their actual amount? target/xtarget is what forces a realtime update. others may only update every tick or longer. it is how they save bandwidth. the game was developed around dialup mostly and those same mechanics are in place.
 
Pete has already pointed out the shortcomings for getting a NPCs hp.

I'd ask what is the primary purpose for this targetting. Is this for a plvlee macro or something like that? What is responsible for damaging the targets in the first place? There may be an alternative approach that you could take depending on the exact situation. For example, if it's plvling related and you can run a macro and eqbc on another character that is damaging the targets, you might could relay the information through EQBC so that you only target mobs worth targeting.

Dev
 
Yes, for power leveling. The characters being power leveled are not mine, so I am limited. How is information passed through EQBC? Is there a command to specify?
 
Ah ok, I see so the character this is running on is waiting until 45% just to assist in killing mobs faster. In that case if you aren't running any of the characters directly involved with killing the mob that would have it on their target or xtarget list anyway, your options are limited due to the way EQ updates the hitpoints.

Like Pete said, without targeting or having the mob on your XTarget list, EQ will not send HP updates on the mob. You will be limited to either cycling through targets to update their hitpoints, or possibly as an alternative cycling through /assisting the plvlees so that you can see what hp their targets are at.

The only other thing I could suggest would be, take a really low level ae nuke that does minimal damage, and cast it on the group of mobs that are being killed by the plvlees, so that they get added to your XTarget list and then you can get relevant HP on them without directly targetting (up to the number of Xtargets available to you).
 
as long as someone in your box crew has the targets on extended target, you could pass them via eqbc w/ netbots enabled. but if you are like pulling 50 mobs at one and you want to hit each of them 1 time, you are probably better off just making a wizard/bard and PL them alongside your other toon so that they can AE damage and be done with it. there are various PL macs available to hit each mob once though. i even have one posted called PL.mac somewhere.