import { EntityDamageCause, system } from "@minecraft/server";
import { pegasusArmorConfig } from "../DATA/ArmorConfig";
export function strikeLightningEffectOnAttacker(log, attacker, hitEntity) {
    try {
        const player = hitEntity;
        for (let i = 0; i < pegasusArmorConfig.lightningAttempts; i++) {
            if (!player.isValid())
                return;
            if (Math.random() < pegasusArmorConfig.lightningChance) {
                system.run(() => {
                    if (hitEntity?.isValid()) {
                        hitEntity.dimension.playSound(pegasusArmorConfig.soundEffect.sound, hitEntity.location);
                    }
                    attacker.dimension.spawnEntity("kicu_mmad:lightning_strike", attacker.location);
                    attacker?.applyDamage(pegasusArmorConfig.lightningDamage, {
                        cause: EntityDamageCause.lightning,
                        damagingEntity: player,
                    });
                    const mobsInArea = attacker.dimension.getEntities({
                        maxDistance: pegasusArmorConfig.effectRange,
                        closest: pegasusArmorConfig.effectMaxTargets,
                        families: ["hostile"],
                    });
                    for (const target of mobsInArea) {
                        for (let j = 0; j < pegasusArmorConfig.secondaryLightningAttempts; j++) {
                            if (target.isValid() && Math.random() < pegasusArmorConfig.secondaryLightningChance) {
                                target.dimension.spawnEntity("kicu_mmad:lightning_strike", target.location);
                                target.applyDamage(pegasusArmorConfig.secondaryLightningDamage, {
                                    cause: EntityDamageCause.lightning,
                                    damagingEntity: player,
                                });
                                break;
                            }
                        }
                    }
                });
            }
        }
    }
    catch { }
}

//# sourceMappingURL=../../../../../_KiCuMountsBPDebug/kicu/mmad/A/PegasusArmour.js.map
