Files

60 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.
# 3NPC.js — handleKoru() (satır 510)
[← 3NPC.js](index.md) · [← Master](../../wiki.md)
Parça 1/2 · [sonraki](handleKoru-2.md)
```javascript
function handleKoru(ctx, soldiers, commander)
{
var pp = commander.getPosition();
var activeSoldiers = [];
for (var i = 0; i < soldiers.size(); i++) {
var s = soldiers.get(i);
if (s && !isOmni(s)) {
var mem = getMem(s.getUniqueId());
if (!mem.bekle) activeSoldiers.push(s);
}
}
var count = activeSoldiers.length;
if (count === 0) return;
var radius = 3.0;
var angleStep = (Math.PI * 2) / count;
var arrivedCount = 0;
for (var i = 0; i < count; i++) {
var s = activeSoldiers[i];
var angle = i * angleStep;
var tx = pp.x + radius * Math.cos(angle);
var tz = pp.z + radius * Math.sin(angle);
var sp = s.getPosition();
var dx = tx - sp.x; var dz = tz - sp.z;
var mem = getMem(s.getUniqueId());
if (Math.sqrt(dx*dx + dz*dz) > 1.5) {
if (Math.sqrt(Math.pow(tx - mem.tx, 2) + Math.pow(tz - mem.tz, 2)) > 2.0) {
s.clearEntityPatrols();
s.addEntityPatrol(tx, pp.y, tz, 1.2, false, "");
mem.tx = tx; mem.tz = tz; mem.arrived = false;
}
} else {
arrivedCount++;
if (!mem.arrived) {
s.clearEntityPatrols();
s.setMotion(0,0,0);
mem.arrived = true;
}
var lookYaw = Math.atan2(-(tx - pp.x), (tz - pp.z)) * 180 / Math.PI;
s.setRotations(0, lookYaw, lookYaw);
}
}
if (arrivedCount === count) {
var shieldActive = mappet.get("nano_koru_shield_active");
if (!shieldActive) {
```