filler

Sky Piercer

Hitting enemies mid air pierces their armour, giving them weakness

← Back to main

Code Block:


function check_item(item, item_name, custom_name, customId){
  return (
    item &&
    item.name === item_name &&
    item.attributes.customDisplayName === custom_name &&
    item.attributes.customAttributes.weaponId === customId
  );
}

api.giveItem(myId, "Diamond Bow", 1, {customDisplayName: "Sky Piercer",customDescription: "Hitting enemies mid-air pierces their armour", customAttributes: {weaponId: 1, "enchantmentTier":"Tier 5", enchantments: {"Quick Charge":1, "Arrow Damage":1}}})

function onPlayerDamagingOtherPlayerSky(aId, eId, damage, item){
  if(item !== "Arrow"){return}
  if(api.getHeldItem(aId).name === "Arrow"){return}
  if(api.getEffects(aId).includes("Sky Strike") && !api.getEffects(aId).includes("Sky Cooldown")){
    api.removeEffect(aId,"Sky Strike")
    api.applyEffect(eId, "Weakness", 7000, {inbuiltLevel: 4})
    api.applyEffect(aId, "Sky Cooldown", 20000, {icon: "White Wool"})
    api.sendMessage(aId, "You have smited a Player!", {color: "red"})
  }
}

function ChargedSky(aId){
  held = api.getHeldItem(aId)
  if(check_item(held,"Diamond Bow","Sky Piercer",1) && checkCharge(aId)){
    api.applyEffect(aId, "Sky Strike", 4000, {icon: "White Wool"})
  } else {
    return
  }
}

function checkCharge(pid){
  pos = api.getPosition(pid)
  if(api.getBlock(pos[0], pos[1]-1, pos[2]) === "Air"){
    return true
  } else{
    return false
  }
}
      

World Code:




// Handle attack logic
onPlayerDamagingOtherPlayer = (attackingPlayer, damagedPlayer, damageDealt, withItem, bodyPartHit, damagerDbId)=> {
  onPlayerDamagingOtherPlayerSky(attackingPlayer, damagedPlayer, damageDealt, withItem)
};

onPlayerFinishChargingItem = (pId, use, item, dura) => {
  ChargedSky(pId)
}