Files

42 lines
1.0 KiB
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.
# divide.js — koniIleBul() (satır 63)
[← divide.js](index.md) · [← Master](../../wiki.md)
```javascript
function koniIleBul(c, p) {
var pos = p.getPosition();
var look = p.getLook();
var ey = pos.y + p.getEyeHeight();
var list = c.getWorld().getEntities(pos.x, ey, pos.z, CONFIG.MENZIL);
if (!list) return null;
var best = null;
var bestDot = CONFIG.KONI;
for (var i = 0; i < list.size(); i++) {
var e = list.get(i);
if (!e || !e.isPlayer() || e.isSame(p)) continue;
var tp = e.getPosition();
var dx = tp.x - pos.x;
var dy = (tp.y + e.getEyeHeight()) - ey;
var dz = tp.z - pos.z;
var dist = Math.sqrt(dx * dx + dy * dy + dz * dz);
if (dist < 0.01 || dist > CONFIG.MENZIL) continue;
var dot = (dx * look.x + dy * look.y + dz * look.z) / dist;
if (dot > bestDot) {
bestDot = dot;
best = e;
}
}
return best;
}
```