filler

Warden Chestplate

Take enough damage to perform a powerful revenge attack

← 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 Chestplate", 1, {customDisplayName: "Warden Chestplate",customDescription: "Do revenge damage \nRevenge Damage: 0", customAttributes: {weaponId: 1, damage_absorbed: 0, "enchantmentTier":"Tier 5", enchantments: {"Protection":2, "Health Regen": 1}}})

function onPlayerDamagingOtherPlayerWard(aId, eId, damage, item) {
  let held = api.getItemSlot(eId, 47);

  if (api.getEffects(aId).includes("Revenge")) {
    api.applyEffect(eId, "Slowness", 5000, {inbuiltLevel: 1});
    api.removeEffect(aId, "Revenge");
    api.attemptApplyDamage({
        eId: aId, // the player/entity causing damage
        hitEId: eId, // the player/entity receiving damage
        attemptedDmgAmt: Math.floor(api.getHealth(eId) * 0.25),
        withItem: "Diamond Chestplate",
        isTrueDamage: true
    })
  }

  if (check_item(held, "Diamond Chestplate", "Warden Chestplate", 1)) {
    let current_damage = held.attributes.customAttributes.damage_absorbed;

    if (current_damage >= 150) {
      api.setItemSlot(
        eId,
        47,
        "Diamond Chestplate",
        1,
        {
          customDisplayName: "Warden Chestplate",
          customDescription: "Do revenge damage \nRevenge Damage: 0",
          customAttributes: { weaponId: 1, damage_absorbed: 0, "enchantmentTier":"Tier 5", enchantments: {"Protection":2, "Health Regen": 1}}
        }
      );
      api.applyEffect(eId, "Revenge", null, { icon: "Brown Wool" });
      api.sendMessage(eId, "Revenge is active", {color: "red"})
    } else {
      let new_damage = current_damage + damage;
      api.setItemSlot(
        eId,
        47,
        "Diamond Chestplate",
        1,
        {
          customDisplayName: "Warden Chestplate",
          customDescription: `Do revenge damage \nRevenge Damage: ${new_damage}`,
          customAttributes: { weaponId: 1, damage_absorbed: new_damage, "enchantmentTier":"Tier 5", enchantments: {"Protection":2, "Health Regen": 1} }
        }
      );
    }
  }

  return
}
      

World Code:




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