#projectile hit entity issues

1 messages · Page 1 of 1 (latest)

ancient dawn
#

Are you using the right information? .id refers to an entity’s identifier which is kinda like a uuid, did you mean to use .typeId?

plucky sluice
#

maybe idk do you have a fix my head hurts

#

@ancient dawn

stark tapir
#

he can't help you if he doesn't know what's inside of the projectileType map

plucky sluice
#

wait did i need a projectileType map

#

@stark tapiri didnt know i needed it cause i just want it to run on any projectile

#

tho maybe thats a good idea to have idk how it changes things tho

stark tapir
#
const projectileTypes = new Map();```
plucky sluice
#

then where do i define the projectiles in that map

#

@stark tapir

#

wait dont i do it as const projectileTypes = new Map([projectile info here]);

plucky sluice
#

@ancient dawn are you able to help me

plucky sluice
#

@stark tapir

ancient dawn
#

If you want more help list all of your code and explain in decent detail what you want to do. I told you what I thought was the most likely issue but it could also be the other variables that you didn’t list.

plucky sluice
#

@ancient dawn what i want is for projectile when hit takes in the source of who hit puts them as source so it gets there stats who was hit so it gets there stats runs the dealDamage function so when you hit an entity it runs the deal damage accordingly also is it possible to make it so a player is req to have arrow in its offhand slot

plucky sluice
#

Bump

plucky sluice
#

@ancient dawn

plucky sluice
#

Bump

ancient dawn
#
world.afterEvents.projectileHitEntity.subscribe((evd) => {
    const { projectile, source } = evd;
    if (!source) return;

    const hitEntity = evd.getEntityHit()?.entity;
    if (!hitEntity) return;

    // Log a warning if the projectile type is unknown
    if (!PROJECTILE_STATS.has(projectile.typeId)) {
        console.warn(`Unknown projectile: ${projectile.typeId}, using default behavior.`);
    }

    try {
        dealDamage("rangeValue", "rangeStrength", source, hitEntity);
    } catch (error) {
        console.error("Error in dealDamage:", error);
    }
});

not sure about the rest of the function, but here, like I was saying, the id of the mob just uses .typeId.

plucky sluice
#

Ill give that a try tommorrow

plucky sluice