Code Block:
api.giveItem(myId, "Wood Sword", 1, {
customDisplayName: "Kill Aura Sword"
});
World Code:
//world code (from THECATSAPPLE)
const dealMeleeDamage = (hittingEId) => {
const playerPosition = api.getPosition(hittingEId);
const playerIds = api.getPlayerIds();
for (const targetId of playerIds) {
if (targetId !== hittingEId) {
const targetPosition = api.getPosition(targetId);
const distance = Math.sqrt(
Math.pow(playerPosition[0] - targetPosition[0], 2) +
Math.pow(playerPosition[1] - targetPosition[1], 2) +
Math.pow(playerPosition[2] - targetPosition[2], 2)
);
if (distance < 7) {
api.applyMeleeHit(hittingEId, targetId, [0,0,0]); // Direction can be adjusted;
api.applyImpulse(targetId, 0, 5, 0)
}
}
}
};
onPlayerClick = (playerId) => {
const held = api.getHeldItem(playerId);
if (
held?.attributes?.customDisplayName === "Kill Aura Sword"
){dealMeleeDamage(playerId);}
};