import { world, system } from "@minecraft/server";
import * as atkUtils from "../attackUtils";

//aplies weakness to entities in range
system.afterEvents.scriptEventReceive.subscribe(e => {
    if (!(e.id == "oct_eg:necro_pet" && e.message == "weakness")) return;

    const necro = e.sourceEntity;
    const owner = necro.getComponent("minecraft:tameable").tamedToPlayer;

    for (const target of atkUtils.getValidTargetsInRange(necro, { maxDistance: 5, startLocation: necro.location, excludedEntities: [owner] })) {
        target.addEffect("minecraft:weakness", 40, { showParticles: false, amplifier: 0 });
    }
})
