
World Code
Tags:
Combat, Command
Creator:
_Garlicbread_of_toast_
Code:
onPlayerClick = (id) =>{
let facing = api.getPlayerFacingInfo(id).dir;
let pos = api.getPosition(id);
let amount = 8;
let held = api.getHeldItem(id);
let name = held?.attributes?.customDisplayName;
if (name == "Laser"){
api.broadcastSound("cannonFire3",1,5,{
playerIdOrPos: id,
maxHearDist: 15
});
for (let i = 0; i < amount; i++){
let hit = [];
hit = [];
api.playParticleEffect({
dir2: [1, 0, 1],
dir1: [facing[0], facing[0], facing[2]],
pos1: [pos[0] += ((i+2)*facing[0]) , pos[1] +1, pos[2] += ((i+2)*facing[2])],
pos2: [pos[0] += ((i+2)*facing[0]), pos[1] +1, pos[2] +=((i+2)*facing[2])],
texture: "square_particle",
minLifeTime: 0.05 + (i/100),
maxLifeTime: 0.05 + (i/100),
minEmitPower: 2,
maxEmitPower: 2,
minSize: 0.5,
maxSize: 3 - (i/10),
manualEmitCount: 10,
gravity: [0, -2, 0],
colorGradients: [
{
timeFraction: 0,
minColor: [255, 81, 0, 1],
maxColor: [253, 3, 3, 1],
//rgb(255, 81, 0)
},
],
velocityGradients: [
{
timeFraction: 0,
factor: 1,
factor2: 1,
},
],
blendMode: 1,
});
const magnitude = Math.sqrt(
facing[0] * facing[0] +
facing[1] * facing[1] +
facing[2] * facing[2]
);
const normalized = [
facing[0] / magnitude,
facing[1] / magnitude,
facing[2] / magnitude
];
let x = Math.floor(pos[0] + normalized[0]* i);
let z = Math.floor(pos[2] + normalized[2] * i);
let y = Math.floor(pos[1]);
hit = api.getEntitiesInRect([x- 3,y - 3,z - 3],[x + 3,y + 3,z + 3]);
if (hit){
for (let h = 0; h < hit.length; h++){
let target = hit[h];
if (hit[h] != id){
api.attemptApplyDamage({
eId: id,
hitEId: target,
attemptedDmgAmt: 100,
withItem: "Red Ceramic",
attackDir: [facing[0],facing[1],facing[2]],
showCritParticles : true,
reduceVerticalKbVelocity : false
});
}
}
}
}
}
}Instructions:
use this to get your laser
api.giveItem(myId, "Gold Sword", 1, {
customDisplayName: "Laser",
customDescription: "Hit your enemies right before you hit the ground for a boost!"
});