Files

66 lines
1.8 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.
# MercanRey1.js — scan() (satır 570)
[← MercanRey1.js](index.md) · [← Master](../../wiki.md)
Parça 1/2 · [sonraki](scan-2.md)
```javascript
function scan(observer)
{
var pos = observer.getPosition();
var entities = observer.getWorld().getEntities(pos.x - RANGE, pos.y - RANGE, pos.z - RANGE, pos.x + RANGE, pos.y + RANGE, pos.z + RANGE);
var rows = [];
var totalRisk = 0;
for (var i = 0; i < entities.size(); i++)
{
var entity = entities.get(i);
if (entity == null || entity.isSame(observer) || !entity.isLivingBase())
{
continue;
}
var entityPos = entity.getPosition();
var distance = Math.sqrt(distanceSq(pos, entityPos));
if (distance > RANGE)
{
continue;
}
var profile = readProfile(entity);
var risk = clamp(profile.risk + Math.max(0, 12 - distance) * 1.5, 0, 100);
totalRisk += risk;
rows.push({
name: String(entity.getName()),
uuid: String(entity.getUniqueId()),
distance: Math.round(distance * 10) / 10,
className: profile.label,
action: profile.action,
counter: profile.counter,
probability: Math.round(profile.probability),
risk: Math.round(risk),
direction: directionName(entity),
tags: profile.tags
});
}
rows.sort(function (a, b)
{
if (b.risk !== a.risk)
{
return b.risk - a.risk;
}
return b.probability - a.probability;
});
var averageRisk = rows.length === 0 ? 0 : Math.round(totalRisk / rows.length);
var bestDecision = "ortam temiz";
if (rows.length > 0)
{
```