#projectile hit entity issues
1 messages · Page 1 of 1 (latest)
he can't help you if he doesn't know what's inside of the projectileType map
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
yeah because you are using .get() method and it only exist in map
const projectileTypes = new Map();```
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]);
@ancient dawn are you able to help me
@stark tapir
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.
@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
Bump
@ancient dawn
Bump
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.
Ill give that a try tommorrow
im not sure why but its no longer setting the entities stats