32 lines
951 B
Markdown
32 lines
951 B
Markdown
# npc.js — startLoop() (satır 374)
|
||
|
||
[← npc.js](index.md) · [← Master](../../wiki.md)
|
||
|
||
Parça 3/3 · [önceki](startLoop-2.md)
|
||
|
||
```javascript
|
||
// hasar anında, hasar alan oyuncunun yanında diyalog aç (cooldown'lı)
|
||
var now = Date.now();
|
||
if (now > (mappet.get("hector_dialogue_cd") || 0))
|
||
{
|
||
target.executeCommand("/mp dialogue open @p[r=5] " + DIALOGUE_ID);
|
||
mappet.set("hector_dialogue_cd", now + DIALOGUE_CD_MS);
|
||
}
|
||
|
||
continue;
|
||
}
|
||
|
||
if (dist < STOP_DIST) continue;
|
||
|
||
// hedefe doğru it + yüzünü çevir
|
||
e.addMotion((dx / dist) * FOLLOW_SPEED, 0, (dz / dist) * FOLLOW_SPEED);
|
||
e.setRotations(0, yaw, yaw);
|
||
}
|
||
|
||
ctx.scheduleScript(LOOP_TICKS, loop);
|
||
}
|
||
|
||
c.scheduleScript(LOOP_TICKS, loop);
|
||
}
|
||
```
|