Air Dagger
Crits do extra damage and launch you up
← 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, "Iron Sword", 1, {customDisplayName: "Air Dagger",customDescription: "Crits do extra damage", customAttributes: {weaponId: 1, "enchantmentTier":"Tier 5", enchantments: {"Critical Damage":3}}})
function onPlayerDamagingOtherPlayerDagger(aId, eId, damage, item){
let held = api.getHeldItem(aId)
let pos = api.getPosition(aId)
if (check_item(held, "Iron Sword", "Air Dagger",1)) {
if (api.getBlock(pos[0], pos[1] - 1, pos[2]) === "Air") {
api.applyImpulse(aId, 0, 15, 0)
api.applyEffect(eId, "Slowness",3000,{inbuiltLevel: 2})
api.attemptApplyDamage({
eId: eId,
hitEId: eId,
attemptedDmgAmt: Math.floor(damage * 0.5),
withItem: "Iron Sword",
isTrueDamage: true
})
}
} else{
return
}
}
World Code:
// Handle attack logic
onPlayerDamagingOtherPlayer = (attackingPlayer, damagedPlayer, damageDealt, withItem, bodyPartHit, damagerDbId)=> {
onPlayerDamagingOtherPlayerDagger(attackingPlayer, damagedPlayer, damageDealt, withItem)
};