Files

1.8 KiB
Raw Permalink Blame History

potion_rain.js — q() (satır 160)

← potion_rain.js · ← Master

Parça 6/11 · önceki · sonraki

// =====================================================================
//  ENTRY
// =====================================================================
function main(c) {
    var p = c.getPlayer();
    if (!p) return;

    // Kayan pencere: basili tutulan sag tik her 200 ms'de tekrar gelir,
    // hepsi tek tik sayilir
    var name = p.getName();
    var t = now();
    var lastClick = mappet.get(G_CLICK + name);
    mappet.set(G_CLICK + name, t);
    if (lastClick !== null && lastClick !== undefined && t - Number(lastClick) < CLICK_DEBOUNCE_MS) return;

    if (p.isSneaking()) {
        openMenu(c, p);
        return;
    }
    startRain(c, p);
}

// Gorsel turler yere degince: mp script exec @s potion_rain impact {t,p,i,o}
// Subject = carpan Blockbuster mermisi
function impact(c) {
    var e = null;
    try { e = c.getSubject(); } catch (e0) {}
    if (!e) return;
    var k = KIND_MAP[String(c.getValue("t"))];
    if (!k) return;
    var w = e.getWorld();
    var pos = e.getPosition();

    if (k.explode) {
        // Gercek patlama: canlilara hasar + geri itme, blok kirmaz, ates yok
        try { w.explode(e, pos.x, pos.y, pos.z, TNT_POWER, false, false); } catch (e4) {}
    }

    var f = FX[k.fx];
    if (f) {
        try { w.playSound(f.sound, pos.x, pos.y, pos.z, f.vol, f.pitch * (0.9 + Math.random() * 0.2)); } catch (e1) {}
        try {
            var type = mappet.getParticleType(f.part);
            if (type) w.spawnParticles(type, true, pos.x, pos.y + 0.3, pos.z, f.n, 0.3, 0.2, 0.3, 0.05);
        } catch (e2) {}
    }

    if (Number(c.getValue("i")) === 1) {
        var pi = Math.floor(Number(c.getValue("p")));