Files

29 lines
983 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Hector_Tudors.js — pickTarget() (satır 2069)
[← Hector_Tudors.js](index.md) · [← Master](../../wiki.md)
```javascript
function pickTarget(p, dist) {
try {
var r = p.rayTrace(dist);
if (r && r.isEntity && r.isEntity()) {
var e = r.getEntity();
if (e && e.isLivingBase() && !e.isSame(p)) return e;
}
} catch (err) {}
var pos = p.getPosition(), look = p.getLook(), eh = p.getEyeHeight();
var best = null, bd = 999;
for (var d = 2; d <= dist; d += 2) {
var ax = pos.x + look.x * d, ay = pos.y + eh + look.y * d, az = pos.z + look.z * d;
var es = enemies(p.getWorld(), ax, ay, az, 2.5, p);
for (var i = 0; i < es.length; i++) {
var ep = es[i].getPosition();
var dd = dist3(pos.x, pos.y, pos.z, ep.x, ep.y, ep.z);
if (dd < bd) { bd = dd; best = es[i]; }
}
if (best) break;
}
return best;
}
```