filler

Zeus Bolt

Upon right click, you stun players and leap into the sky. Landing will massive damage. Hitting players has a chance to give them weakness and give you speed

← Back to main

Code Block:


api.giveItem(myId, "Gold Axe", 1, {
  customDisplayName: "Zeus Bolt"
});
      

World Code:


//Timeout Code by Sulfrox
class MinQueue{constructor(i,t,e){t=e=Uint32Array,this.c=i,this.k=new t(i+1),this.p=new e(i+1),this.h=!1,this.l=0}bbu(i){let t=this.k,e=this.p,r=t[i],h=e[i];for(;i>1;){let s=i>>>1;if(e[s]<=h)break;t[i]=t[s],e[i]=e[s],i=s}t[i]=r,e[i]=h}bbd(i){let t=this.k,e=this.p,r=t[i],h=e[i],s=1+(this.l>>>1),u=this.l+1;for(;i<s;){let n=i<<1,l=e[n],m=t[n],_=n,p=n+1;if(p<u&&e[p]<l&&(l=e[p],m=t[p],_=p),l>=h)break;t[i]=m,e[i]=l,i=_}t[i]=r,e[i]=h}push(i,t){if(this.l===this.c)throw"heap full";if(this.h)this.k[1]=i,this.p[1]=t,this.l++,this.bbd(1),this.h=!1;else{let e=this.l+1;this.k[e]=i,this.p[e]=t,this.l++,this.bbu(e)}}pop(){if(0!==this.l)return this.rpe(),this.l--,this.h=!0,this.k[1]}peekPriority(){if(0!==this.l)return this.rpe(),this.p[1]}peek(){if(0!==this.l)return this.rpe(),this.k[1]}rpe(){this.h&&(this.k[1]=this.k[this.l+1],this.p[1]=this.p[this.l+1],this.bbd(1),this.h=!1)}}let currently_running_timer,TimerQueue=new MinQueue(1024),TimerDictionary=[],TimerNum=0,TickNum=0;function setTimeOut(i,t){let e=TickNum+Math.floor(t/50);TimerDictionary[TimerNum]=i,TimerQueue.push(TimerNum,e),TimerNum++}function tick(){if(TickNum++,currently_running_timer)currently_running_timer(),currently_running_timer=void 0;else if(TimerQueue.peekPriority()<=TickNum){let i=TimerQueue.peek();void 0!==i&&(currently_running_timer=TimerDictionary[i]),TimerQueue.pop(),delete TimerDictionary[i]}}

const iceSlamCooldowns = {};
const activeIceSlams = new Set();

onPlayerAltAction = (playerId) => {
  const held = api.getHeldItem(playerId);
  if (!held || held.name !== "Gold Axe" || held.attributes?.customDisplayName !== "Zeus Bolt") return;

  const now = Date.now();
  const lastUsed = iceSlamCooldowns[playerId] || 0;
  const cooldown = 25000;

  if (now - lastUsed < cooldown) {
    const s = Math.ceil((cooldown - (now - lastUsed)) / 1000);
    api.sendMessage(playerId, `❄ Ice Slam cooldown: ${s}s`, { color: "gray" });
    return;
  }
  if (activeIceSlams.has(playerId)) return;
  activeIceSlams.add(playerId);
  iceSlamCooldowns[playerId] = now;

  api.applyImpulse(playerId, 0, 20, 0);
  const origin = api.getPosition(playerId);
  const players = api.getPlayerIds();

  for (const otherId of players) {
    if (otherId === playerId) continue;
    const pos = api.getPosition(otherId);
    const dx = pos[0] - origin[0], dy = pos[1] - origin[1], dz = pos[2] - origin[2];
    if (dx * dx + dy * dy + dz * dz <= 25)
      api.applyEffect(otherId, "Frozen", 2000, { displayName: "Frozen", icon: "Ice" });
  }

  let stillTicks = 0, lastY = origin[1];
  const checkLanding = () => {
    const pos = api.getPosition(playerId);
    if (!pos) return;
    const y = pos[1];
    const standing = api.getBlockTypesPlayerStandingOn(playerId);
    const onGround = standing.some(b => b && b !== "Air");

    stillTicks = (onGround && Math.abs(y - lastY) < 0.05) ? stillTicks + 1 : 0;
    lastY = y;

    if (stillTicks >= 3) {
      for (const otherId of players) {
        if (otherId === playerId) continue;
        const oPos = api.getPosition(otherId);
        const dx = oPos[0] - pos[0], dy = oPos[1] - pos[1], dz = oPos[2] - pos[2];
        if (dx * dx + dy * dy + dz * dz <= 25)
          api.attemptApplyDamage({ eId: playerId, hitEId: otherId, attemptedDmgAmt: 20, withItem: held.name, isTrueDamage: true });
      }
      activeIceSlams.delete(playerId);
    } else setTimeOut(checkLanding, 150);
  };
  setTimeOut(checkLanding, 150);
};

onPlayerDamagingOtherPlayer = (attacker, victim, damage, withItem) => {
  const held = api.getHeldItem(attacker);
  if (withItem === "Gold Axe" && held?.attributes?.customDisplayName === "Zeus Bolt") {
    api.applyHealthChange(victim, -damage);
    if (Math.random() < 0.3) {
      api.applyEffect(victim, "Weakness", 5000, { inbuiltLevel: 1 });
      api.applyEffect(attacker, "Speed", 5000, { inbuiltLevel: 1 });
    }
  }
};