What's new
  • Visit Rebornbuddy
  • Visit Resources
  • Visit API Documentation
  • Visit Downloads
  • Visit Portal
  • Visit Panda Profiles
  • Visit LLamamMagic

How to retrieve closest monster

tozededao

Community Developer
Joined
Jan 15, 2010
Messages
1,225
Reaction score
5
I was trying to return the closest monster to the character and I'm not able to do it consistently. Sometimes it works othertimes it doesn't. Here's what I have:
Code:
var closestTarget = CombatTargeting.Targets<Monster>().Where(
                        m =>
                            m.Distance < 30 &&
                            ExilePather.PathDistance(myPos, m.Position, true, !PewPewShatterSettings.Instance.LeaveFrame) < 30)
                    .OrderBy(m => m.Distance).FirstOrDefault();

How should I be doing this?
 
I was trying to return the closest monster to the character and I'm not able to do it consistently. Sometimes it works othertimes it doesn't. Here's what I have:
Code:
var closestTarget = CombatTargeting.Targets<Monster>().Where(
                        m =>
                            m.Distance < 30 &&
                            ExilePather.PathDistance(myPos, m.Position, true, !PewPewShatterSettings.Instance.LeaveFrame) < 30)
                    .OrderBy(m => m.Distance).FirstOrDefault();

How should I be doing this?

The code looks good,try to log closestTarget infos to see if there's any flaws in checks, but for me it's pretty much all you can do
 
Your targeting inclusions will affect which monsters are in that list. Check that first to make sure none are being eliminated that you think otherwise should be there.

Also, consider the isometric perspective when looking at monsters that should be "close" or not. The game axis is rotated on an 45 degree angle I think it was, so visually, one direction is closer than the other, but distance wise, they are the same.
 
Back
Top