Files

48 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.
# pirt.js — runProjectile() (satır 178)
[← pirt.js](index.md) · [← Master](../../wiki.md)
Parça 1/6 · [sonraki](runProjectile-2.md)
```javascript
function runProjectile(c) {
var world = c.getWorld();
var shooterUUID = c.getValue("shooterUUID");
var pos = c.getValue("projPos");
var look = c.getValue("projLook");
var projTick = c.getValue("projTick");
var speed = SPELL_CONFIG.PROJECTILE_SPEED;
var nextPos = pos.add(look.multiply(speed));
// Devasa kalınlıkta duman ve toz lazeri (Volumetrik kalın hat)
var distance = pos.subtract(nextPos).length();
var steps = Math.floor(distance / 0.15);
if (steps < 1) steps = 1;
for (var i = 0; i <= steps; i++) {
var t = i / steps;
var p = pos.add(look.multiply(speed * t));
// Geniş yayılımlı (offsetli) kalın duman ve toz huzmesi (mermi kalınlaştırıldı)
spawnSpellParticle(world, SPELL_CONFIG.PARTICLE_LASER_1, p.x, p.y, p.z, 3, 0.28, 0.28, 0.28, 0.05);
spawnSpellParticle(world, SPELL_CONFIG.PARTICLE_LASER_2, p.x, p.y, p.z, 2, 0.25, 0.25, 0.25, 0.02);
if (Math.random() < 0.6) {
spawnSpellParticle(world, SPELL_CONFIG.PARTICLE_LASER_3, p.x, p.y, p.z, 2, 0.22, 0.22, 0.22, 0.02);
}
}
// Gelişmiş Raytracing: Baktığımız KİŞİ (Entity) veya BLOK (Block/Tile Entity) fark etmeksizin algılar
var ray = world.rayTrace(pos.x, pos.y, pos.z, nextPos.x, nextPos.y, nextPos.z);
var didHit = false;
var hitPos = null;
if (!ray.isMissed()) {
if (ray.isEntity()) {
var hitEntity = ray.getEntity();
// Kendimize çarpmayı engelle
if (hitEntity !== null && hitEntity.getUniqueId() !== shooterUUID) {
didHit = true;
```