Files

49 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.
# radiation_explosion.js — main() (satır 38)
[← radiation_explosion.js](index.md) · [← Master](../../wiki.md)
Parça 1/2 · [sonraki](main-2.md)
```javascript
function main(c)
{
var world = c.getWorld();
var s = c.getSubject();
var pos = s.getPosition();
var cx = Math.floor(pos.x);
var cy = Math.floor(pos.y);
var cz = Math.floor(pos.z);
// --- 1) İlk patlama sesi + merkez efekti ---
world.playSound("minecraft:entity.generic.explode", cx, cy, cz, 6.0, 0.5);
world.playSound("minecraft:entity.lightning.thunder", cx, cy, cz, 5.0, 0.6);
world.spawnParticles(PT_HUGE, true, cx + 0.5, cy + 1, cz + 0.5, 1, 0, 0, 0, 0);
// --- 2) Kademeli radyasyon hasarı: 5x 1 hasar (+yeşil particle), sonra 500 ---
// 's' (patlatan) her zaman muaf; sana hasar gelmez.
radiationDamage(c, world, s, cx, cy, cz, RADIATION_RADIUS, 0);
// --- 3) Blokları kabuk kabuk (shell) yok olacak şekilde hazırla ---
// Tüm blast küpünü bir kez tara, blokları merkeze uzaklığa göre kovala.
// shells[r] = o yarıçaptaki blok koordinatları listesi.
var shells = [];
for (var r = 0; r <= BLAST_RADIUS; r++) shells[r] = [];
var R2 = BLAST_RADIUS * BLAST_RADIUS;
for (var dx = -BLAST_RADIUS; dx <= BLAST_RADIUS; dx++)
{
for (var dy = -BLAST_RADIUS; dy <= BLAST_RADIUS; dy++)
{
var yy = cy + dy;
if (yy < Y_MIN || yy > Y_MAX) continue;
for (var dz = -BLAST_RADIUS; dz <= BLAST_RADIUS; dz++)
{
var d2 = dx * dx + dy * dy + dz * dz;
if (d2 > R2) continue; // küre dışı
var shell = Math.round(Math.sqrt(d2));
if (shell > BLAST_RADIUS) shell = BLAST_RADIUS;
```