import { Entity, system, world } from "@minecraft/server";
import { dsEntity, scanerMobs } from "./communs";

system.runInterval(()=>{
    projetil()
})

function projetil() {
    dsEntity.forEach((dimension)=>{
        world.getDimension(dimension).getEntities().forEach((entity)=>{
            if (entity.hasTag('projetil')) {
                scanerMobs(entity,{maxDistance:2,minDistance:0,location:entity.location,excludeFamilies:["boss"],excludeTags:["projetil"]}).forEach((victim)=>{
                    if (entity.typeId == 'ns_ab:web') victim.addEffect('slowness',60,{
                        showParticles: false,
                        amplifier: 10
                    })
                    entity.setRotation(victim.getRotation())
                    victim.applyDamage(4);
                    entity.clearVelocity();
                    entity.removeTag('projetil')
                })
            }
        })
    })
}