Splash sound for plat?

Discuss programming in the QuakeC language.
Post Reply
Cobalt
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA
Contact:

Splash sound for plat?

Post by Cobalt »

Was thinking about this and tried some code, so far dead end. Take the plat on E1M2 as example. When it rises, it ought to make a noise when its exiting the water, then again when it enters.

Apparently the QC creates a trigger field covering the plats max and min travel. A plat is always a model it seems generated from the map.bsp itself, and therefore its not a dynamic entity we can manipulate by checking its pointcontents at its self.origin to trigger a noise.

I suppose the only way would be to physicly map out the coordinates the trigger's box is in the water , and not - then scan the position of the moving plat and if its in that area , trigger the noise. Cant see any other way....
qbism
Posts: 1236
Joined: Thu Nov 04, 2004 5:51 am
Contact:

Re: Splash sound for plat?

Post by qbism »

Couple of triggerless ideas:
1. Add a feature to plat qc to play an extra non-looped sound with some time delay. Or percentage of travel distance. Different delay (and optionally different sound) for up and down directions.

2. The plat sound file could be a single long sound rather than a short loop. Takes effort to mix the sound and time it properly, but it could go into even more detail:
- plat start-up underwater
- plat traveling underwater
- plat breaks through water
- plat travel above water (w/ drip sounds)
- plat final travel above water (no drips)
- plat grinds to a halt

A separate 'down' sound would be needed of course.

Guess either idea needs to deal with plat obstruction/reversal. Anyway, not a final solution but an idea to mix with something else.
Ghost_Fang
Posts: 336
Joined: Thu Nov 12, 2009 4:37 am

Re: Splash sound for plat?

Post by Ghost_Fang »

isn't there a self.waterlevel that the QC uses? For the lighting gun as an example. Or is it only for players and/or non bsp entities?
Cobalt
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA
Contact:

Re: Splash sound for plat?

Post by Cobalt »

Seems to me that models like the ones for plats, doors, and func_walls, which are hard coded into the map itself, have no " self ' references for many fields. I believe its because the fields in these entities were never intended to change in the game. Perhaps they are spawned as "static" entities of a sort by the engine.

If you wanted to locate their origin for example, self.origin would not work, you have to use .absmin and .absmax to calculate the center just like they do in the original code that supplies a sound for the teleports , which is: ((self.mins + self.maxs) * 0.5)

The other trick here is that the plats are thinking via the SUB_Calcmove () routine , when the player steps into its trigger field. The code more or less" flings " the plat to its destination and seems to time it to know when its reached max travel, then does the same thing again, only in reverse.

Could be possibel to assign a different .think to happen while the plat is moving - one that checks pointcontents (absmax) of the plat to determine water or open air. I have experimented a bit with this concept, and its almost working, but not every plat will work with it...such as the ones on E2M2 for some reason. Must be their absmin /max are calculated differently.
Ghost_Fang wrote:isn't there a self.waterlevel that the QC uses? For the lighting gun as an example. Or is it only for players and/or non bsp entities?
Cobalt
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA
Contact:

Re: Splash sound for plat?

Post by Cobalt »

UPDATE:

Worked on this a little more today.

The plat on E1M2 is not to hard to code because it travels completely in and out of water. However, on a map like E2M2 for example - the first thing is there are doors really being used in most cases, not plats. Not a huge problem, only also all of them are unlike the one in E1M2 where these are spawned apparently already in water, and some part of them remains in water.

I am thinking maybe spawn an entity with setattachment function so that the entity is about dead center of the plat or doors top + about 10 quake units higher than its absmax_z......and have it travel / setorigin always to that same distance as the door / plat operates. FInally , assign a content transition for that entity.

Only trick is, I have not used setattachment at all yet. Would it only be "visible" to the door / plat entity? There is also the concept of just spawning a regular dynamic entity instead and basicly doing the same thing and make the door its .owner ...... ?
Post Reply