Files

41 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.
# Hector_Tudors.js — cast_boomerang() (satır 1704)
[← Hector_Tudors.js](index.md) · [← Master](../../wiki.md)
```javascript
function cast_boomerang(c) {
var p = c.getPlayer(); if (!p) return;
if (guard(p, "boomerang")) return;
var w = c.getWorld(), pos = p.getPosition(), eh = p.getEyeHeight(), look = p.getLook();
var sx = pos.x + look.x * 1.5, sy = pos.y + eh, sz = pos.z + look.z * 1.5;
title(p, "§b§lYÜZ BUMERANGI", "§3fırlat!");
w.playSound("minecraft:entity.snowball.throw", sx, sy, sz, 1.2, 0.9);
var sp = 1.4, maxd = 22, t = 0, phase = 0, hx = sx, hy = sy, hz = sz;
function loop(ctx) {
var ww = ctx.getWorld(), caster = ctx.getPlayer();
if (phase === 0) {
var d = t * sp;
if (d >= maxd) { phase = 1; }
else { hx = sx + look.x * d; hy = sy + look.y * d; hz = sz + look.z * d; }
}
if (phase === 1) {
var cp = caster.getPosition(), tx = cp.x, ty = cp.y + eh, tz = cp.z;
var dx = tx - hx, dy = ty - hy, dz = tz - hz, dd = Math.sqrt(dx * dx + dy * dy + dz * dz);
if (dd < 1.6) { ww.playSound("minecraft:entity.item.pickup", tx, ty, tz, 1, 1.2); return; }
var s2 = Math.min(sp * 1.3, dd);
hx += (dx / dd) * s2; hy += (dy / dd) * s2; hz += (dz / dd) * s2;
}
showHead(ww, hx, hy, hz, 2.0, 3);
fx(ww, "endRod", hx, hy, hz, 5, 0.1, 0.1, 0.1, 0.02);
fx(ww, "portal", hx, hy, hz, 4, 0.15, 0.15, 0.15, 0.03);
var es = enemies(ww, hx, hy, hz, 2.2, caster);
for (var i = 0; i < es.length; i++) { hurt(es[i], 10, caster); es[i].setFallDistance(0); }
t++;
if (t > 200) return;
ctx.scheduleScript(1, loop);
}
c.scheduleScript(1, loop);
}
```