41 lines
1.8 KiB
Markdown
41 lines
1.8 KiB
Markdown
# potion_rain.js — q() (satır 160)
|
||
|
||
[← potion_rain.js](index.md) · [← Master](../../wiki.md)
|
||
|
||
Parça 3/11 · [önceki](q-2.md) · [sonraki](q-4.md)
|
||
|
||
```javascript
|
||
// Mermi Transform'u: boyut + bas asagi / rastgele egim
|
||
function transformFor(k, cfg) {
|
||
if (k.type === "image") return ""; // resimlerde boyut ve donus morph'un kendi Pose'unda
|
||
var s = fx3(cfg.size) + "f";
|
||
var r;
|
||
if (k.flip) r = '180f,' + fx3(Math.random() * 360) + 'f,0f';
|
||
else if (k.tilt && cfg.spin) r = fx3((Math.random() - 0.5) * 80) + 'f,' + fx3(Math.random() * 360) + 'f,' + fx3((Math.random() - 0.5) * 80) + 'f';
|
||
else r = '0f,0f,0f';
|
||
return 'Transform:{S:[' + s + ',' + s + ',' + s + '],R:[' + r + ']},';
|
||
}
|
||
|
||
// Blockbuster mermisi NBT'si: duz asagi, yercekimi, yere degince impact()
|
||
function gunNbt(k, cfg, morphNbt, owner) {
|
||
var cmd = 'mp script exec @s ' + SCRIPT_ID + ' impact {t:' + k.key + ',p:' + cfg.pot +
|
||
',i:' + (carriesPotion(k, cfg) ? 1 : 0) + ',o:' + q(owner) + '}';
|
||
// stick: yere saplanir, Kalma suresi kadar durur (VDelay), son saniyede solar
|
||
var stay = k.stick ? Math.round(cfg.stay * 20) : 0;
|
||
var life = 200 + cfg.height * 3 + stay;
|
||
return '{Gun:{Projectile:' + morphNbt + ',' + transformFor(k, cfg) +
|
||
'Gravity:0.04f,Speed:0.5f,Friction:0.98f,LifeSpan:' + life + ',Yaw:0b,Pitch:0b,' +
|
||
'Vanish:1b,VDelay:' + stay + ',Stick:' + (k.stick ? '1b' : '0b') + ',Hits:1,HX:0.5f,HY:0.5f,' +
|
||
'FadeIn:0,FadeOut:' + Math.min(20, stay) + ',' +
|
||
'Damage:' + fx3(k.damage || 0) + 'f,' +
|
||
'ImpactCommand:' + q(cmd) + ',ImpactEntityCommand:' + q(cmd) + '}}';
|
||
}
|
||
|
||
function potionAt(i) {
|
||
var pot = POTIONS[i];
|
||
return pot.id ? pot.id : POTIONS[Math.floor(Math.random() * (POTIONS.length - 1))].id;
|
||
}
|
||
|
||
// Vanilla entity NBT'si (asagi dogru hareket + sahip)
|
||
```
|