1.8 KiB
1.8 KiB
MercanRey1.js — scan() (satır 570)
Parça 1/2 · sonraki
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)
{