60 lines
1.8 KiB
Markdown
60 lines
1.8 KiB
Markdown
# ezoic_viltrumite.js — doPunch() (satır 217)
|
||
|
||
[← ezoic_viltrumite.js](index.md) · [← Master](../../wiki.md)
|
||
|
||
Parça 1/2 · [sonraki](doPunch-2.md)
|
||
|
||
```javascript
|
||
function doPunch(c) {
|
||
var p = c.getPlayer();
|
||
if (!p) return;
|
||
if (onlyEzoic(p)) return;
|
||
if (onCooldown(p, "punch")) return;
|
||
setCooldown(p, "punch");
|
||
|
||
var w = c.getWorld();
|
||
var look = p.getLook();
|
||
var pos = p.getPosition();
|
||
var eyeH = p.getEyeHeight();
|
||
var sx = pos.x, sy = pos.y + eyeH, sz = pos.z;
|
||
|
||
p.swingArm();
|
||
|
||
// RayTrace — 6 blok mesafede entity veya blok ara
|
||
var hit = null;
|
||
var hitPos = null;
|
||
var hitDist = 999;
|
||
|
||
// Manuel entity tarama (5 blok menzil)
|
||
var ents = w.getEntities(sx, sy, sz, 6);
|
||
for (var i = 0; i < ents.size(); i++) {
|
||
var e = ents.get(i);
|
||
if (e.isSame(p) || isEzoic(e)) continue;
|
||
if (!e.isLivingBase()) continue;
|
||
|
||
var ep = e.getPosition();
|
||
var toX = ep.x - sx, toY = (ep.y + e.getHeight() * 0.5) - sy, toZ = ep.z - sz;
|
||
var dot = toX * look.x + toY * look.y + toZ * look.z;
|
||
if (dot < 0.5 || dot > 6) continue;
|
||
|
||
// Bakış çizgisine mesafe kontrolü
|
||
var projX = sx + look.x * dot, projY = sy + look.y * dot, projZ = sz + look.z * dot;
|
||
var offX = ep.x - projX, offY = (ep.y + e.getHeight()*0.5) - projY, offZ = ep.z - projZ;
|
||
var offDist = Math.sqrt(offX*offX + offY*offY + offZ*offZ);
|
||
|
||
if (offDist < 2.0 && dot < hitDist) {
|
||
hit = e;
|
||
hitDist = dot;
|
||
hitPos = ep;
|
||
}
|
||
}
|
||
|
||
if (hit) {
|
||
// === ENTITY'E YUMRUK ===
|
||
var tx = hitPos.x, ty = hitPos.y, tz = hitPos.z;
|
||
|
||
hit.damage(25);
|
||
hit.addMotion(look.x * 3.5, 0.9, look.z * 3.5);
|
||
hit.setFallDistance(0);
|
||
```
|