import {
    world,
    system,
    EntityDamageCause
} from "@minecraft/server";

const bullets = ["wt:f34_ap_shell","wt:d5t_he_shell","wt:d5t_ap_shell","wt:f34_he_shell","wt:su152_he_shell","wt:su152_ap_shell"];

world.afterEvents.entityDie.subscribe((event) => {

    const {
        damageSource,
        deadEntity
    } = event;

    const {
        cause,
        damagingEntity,
        damagingProjectile
    } = damageSource;

    if (cause === EntityDamageCause.projectile && bullets.includes(damagingProjectile?.typeId)) {

        damagingEntity?.runCommand("execute as @s run function russian_target_destroyed");

    }

});

world.afterEvents.projectileHitEntity.subscribe((event) => {

    const {
        dimension,
        hitVector,
        location,
        projectile,
        source
    } = event;

    const entityHit = event.getEntityHit()?.entity;

    if (bullets.includes(projectile?.typeId)) {

        source?.runCommand("title @s actionbar Hit");

    }

});