Author Topic: Charging a projectile + Detecting water  (Read 1203 times)

Essentially I need a script that fills up a bar when you hold down the fire button and when it reaches max the weapon will fire a different projectile. Yes, I am begging for a copy-pasteable script because I cannot script worth stuff.

Also how would I explode a projectile as it collides with water or is fired underwater?
« Last Edit: September 27, 2011, 11:57:35 AM by Demian »

check the TF2 sniper

and for the water part, that might be difficult, do you mean map water or brick water?


brick water + wrench + check raycasting = problem half solved

actualy, there might already be a default way of detecting entering water
does the splash sound play when you shoot the water?

No. There's a Player::onEnterWater function, but I'm not sure about projectiles.

I looked for some sort of onEnterWater function for projectiles - datablocks and objects alike - but couldn't find anything relevant.

I do not know if projectiles have any function called when they enter water, but if you wanted to instead to a raycast, I am fairly sure that there is a raycast search typemask or whatever that will tell you if you hit water.

I do not know if projectiles have any function called when they enter water --
They must have. You can make the projectile emitter, explosion and light different when it is underwater.

Quote from: Appendix A
particleWaterEmitter

ParticleEmitter datablock used to generate particles for the projectile when
it is under water, and when it is entering or leaving water.
I tested it and it works in Blockland.

They must have. You can make the projectile emitter, explosion and light different when it is underwater.
I tested it and it works in Blockland.
Yeah sure, but is there any script callback for water entry?

Yo Demian, someone has a message for you:

Quote from: Iban
Demian, that's not true at all.

All (or at least most) default datablock properties aren't used by scripts at all unless the scripts hook into the functionality somehow. That particular property is used by the engine's client-side prediction to spawn an appropriate emitter when the project enters water.

There is no function called for a projectile entering water. There is one called for Armor::onEnterLiquid(%this, %obj) that can be used to detect if a player object enters a liquid, but it cannot work for projectiles to the best of my knowledge.

Your best best, if you really REALLY really REALLY want this, is to hook a looping schedule on the projectile after creation that does a box search on the projectile's world box looking for the $TypeMasks::WaterObjectType mask.

Well that sucks. =/ I guess I have to just deal with it then.

You can however use the "particleWaterEmitter" and "waterExplosion" fields on a ProjectileDatablock if that will help.