Author Topic: How do I play a sound to a client when their player gets hit by a projectile?  (Read 2071 times)

Question is in the title. Nothing else to say.

%client.play2D(SoundDatablock); or %client.play3D(SoundDatablock, %position);

both of these has only the target client hear it; the 3D version makes it so they hear it as if it was coming from %position.

%client.play2D(SoundDatablock); or %client.play3D(SoundDatablock, %position);

both of these has only the target client hear it; the 3D version makes it so they hear it as if it was coming from %position.
Should use %client.playSound(%soundData) instead. It's the same thing except the default method with validity checks. (For 2D)

Also, do you mean if it gets hit by a specific projectile or any projectile?

Also, do you mean if it gets hit by a specific projectile or any projectile?
gets hit by a specific projectile

ProjectileDataNameHere::onCollision(%data, %proj, %hit .. other args i forgot)
then use some statements in the %hit var to see if it has a client and then play the sound on the client

function ProjectileData::onCollision(%datablock, %proj, %col, %fade, %pos, %normal, %velocity)
%proj is the projectile, %col is what it collided with, %normal is the normal vector of the face it hit

New question: How do I make a projectile do a guaranteed kill and with a damage type?
Setting the projectile's damage to 10 billion makes it do 0 damage, and making it just do kill(); doesn't apply the damage type.

New question: How do I make a projectile do a guaranteed kill and with a damage type?
Setting the projectile's damage to 10 billion makes it do 0 damage, and making it just do kill(); doesn't apply the damage type.
you just need to directly apply the damage, since you cant dynamically set the projectile damage, and on top of that the default projectile oncollision damage code caps per-bullet damage at 100 for some bizarre reason

you just need to directly apply the damage
How would I do that?

Read the Meta-Sticky topic: Projectile::Damage
you can apply direct damage just by going into the projectile's field (projectiledata) and just apply directDamage = value; - if you go over 100 you have to use the projectile::damage above to go over 100 (have to modify the function in that topic since it still clamps it)

See Weapon_Gun for more information on direct damage from a projectile without any functions - but since you're playing a sound to a client I recommend using ProjectileNameHere::Damage and parent it
« Last Edit: September 16, 2017, 10:17:33 AM by Kyuande »

you might be able to use %player.setHealth(1); and then have it do the 100 damage normally

you might be able to use %player.setHealth(1); and then have it do the 100 damage normally
weird workaround, but i guess works.