Help: Making a player 'deaf'

Discuss programming in the QuakeC language.
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Help: Making a player 'deaf'

Post by Baker »

leileilol wrote:He wants hyperventilation sounds. Alias abuse won't help that.
Sure it will..... like this ...

Code: Select all

alias direct_hit_really_big_blast "cd eject; echo zomg that blast so big have real life effect on computer"
Imagine playing a game so real that a direct hit knocks your CD tray out or ejects your CD!

That's realism!
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
OneManClan
Posts: 247
Joined: Sat Feb 28, 2009 2:38 pm
Contact:

Re: Help: Making a player 'deaf'

Post by OneManClan »

Thanks for all the responses guys, much appreciated!

Frag.Machine, IIUC your code deals with audio only, and as Spike said, I'm using dimension_see flags to control audio. Having said that I am still studying your code, and will experiment with it at some stage, just out of curiosity.
Spike wrote:I have to ask though, is the aim to make the player unable to hear anything (including the someone-just-said-something-beep), or will you want to still be able to hear a select sounds (alternatives, announcements, etc)?
There will be alternative sounds. These include:
1. An Underwater version of the explosion (I made a second set of wavs which are played when a player is underwater, as discussed here)

2. Whilst deafened/concussed (this thread), the player will only hear his own panicky breathing and maybe an additional 'weird sound'

3. Whilst hallucinating, the player hears music (and other groovy stuff), as discussed here.

The basic solution here seems to be to replace the WRITEBYTE call with something else that does the same job. Spike suggests herethat

Potential Solution A
Spike wrote:If you use DP or FTE, you should never need to do writebytes. There is a proper builtin to do it for you, somewhere. At least that's the theory. No new standard extensions expect you to use writebyte.
I'm assuming the reason Spike hasn't suggested this in the current prob is because multiple clients are being used, though I'm wondering if it could be a matter of sending multiple client-specific messages to different clients.. ie telling them to do their equivalent of a non-WRITEBYTE explosion.
Spike wrote:SVC_TEMPENTITY: Create a temporary special effect...
TE_EXPLOSION: specifically, create a dynamic light that will fade over time, a particle effect that looks somewhat like an explosion, an explosion sprite (in quakeworld anyway)... and yes... an explosion sound effect.
You then have the 3 axis coord of the explosion effect.
Sorry, but there's nothing in the client that allows you to have the particle effect without the sound.
Potential Solution B
Send the writebyte to everyone, but change the coordinates for the deaf player so the explosion happens somewhere far far away.

Potential Solution C
LeiLeilol's suggestion to substitute the TE_EXPLOSION with a new explosion effect, where a new, entity does it's visual effects at the 'impact point' and which can be silenced if needed. I understand there's some issue w some clients not having a 'particle' effect, BUT ... deaf/hallucinating/underwater players don't need to see explosions/particle effects anyway...

Potential Solution D
a modification of the "SkinBlind" (Hallicinating player sees a different set of skins to everyone else) effect. Something like:
[EDIT: The following has been fixed by Spike (thanks!) and should actually work :D ]

Code: Select all

void (entity e) Explosion =
{

   local entity e;
   local float n;

   msg_entity = e;
   while (n < 32)
   {
		e = nextent(e);
		
		if (e.classname == "") //only if the player is actually valid
		continue;
		
		if (e.is_deaf)
		continue; // skip deaf players 
	   
		WriteByte (#MSG_ONE, #SVC_TEMPENTITY);
		WriteByte (#MSG_ONE, #TE_EXPLOSION);
		WriteCoord (#MSG_ONE, thing.origin_x);
		WriteCoord (#MSG_ONE, thing.origin_y);
		WriteCoord (#MSG_ONE, thing.origin_z);
		
		n = n+1;
   }

};
[EDIT: Ugh, I think the above wont work[EDIT: Yes it will!], because the nature of WRITEBYTES is that everyone hears them..[EDIT: not if they're sent to MSG_ONE!] OR ... will the above code will make an explosion 31 times for everyone else except the deaf player, who didn't get the message? [EDIT: No, because they're sent to MSG_ONE]Hm..]

Finally:
Potential Solution E
If your mod is in its own game dir, does that mean that the server doesn't search in other game dirs for files? Eg:
Quake/fortress/sound/foo.wav
Quake/NewMod/other_stuff
If we're playing 'NewMod', can NewMod clients access foo.wav?
Last edited by OneManClan on Sun Mar 24, 2013 2:09 am, edited 6 times in total.
leileilol
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Re: Help: Making a player 'deaf'

Post by leileilol »

Baker wrote:Imagine playing a game so real that a direct hit knocks your CD tray out or ejects your CD!

That's realism!

>2013
>implying most computers still have optical drives
i should not be here
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: Help: Making a player 'deaf'

Post by Spike »

A: Often the reason I don't suggest something is because I don't remember it.
My prior comments regarding the deprecation of writebytes in favour of builtins does not refer to their effects on the client, but only to how the writebytes are actually generated in the server. The builtins will generally do the same thing, but with less calls, less magic constants, etc.

B: changing the origin would change the particle effect position too. this is deeply flawed...

C: ezquake does not support svc_particle at all. Sending it to the client will result in the client Host_EndGame-ing off the server.
If you want to send particle() only to clients that actually support it, feel free, though I can't offer you a sensible way to detect that right now.
If you use the particle() builtin in FTE servers, FTE clients will receive the svc_particle message but ezquake will receive nothing at all.
I can modify the builtin to generate a te_explosion svc effect instead if you desire, but this will not help with muting sounds.
Additionally, you won't get dlights out of it.

D: if you're okay with deaf clients not seeing particles+dlights, go for it.
Combine with the particle builtin for clients that are deaf (dimension_send should affect particle() too), and you'd still be able to see particles with fte.

E: mods use the basic gamedirs, and their own (so id1+qw+$enginedir+$gamedir, along with home directory equivelents in certain engines). There is no standard way to specify multiple gamedirs from the server.
FTE clients are supposed to support a gamedir "fortress;agr", for example, but I'm not sure how well that works. Ezquake likely does not support it.
OneManClan
Posts: 247
Joined: Sat Feb 28, 2009 2:38 pm
Contact:

Re: Help: Making a player 'deaf'

Post by OneManClan »

Just to conclude this thread, thought you'd like to finally see the finished, perfectly working function, essentially written by Spike. Thanks to everyone for your feedback!

Code: Select all

// Replacement for the WRITEBYTE TE_EXPLOSION, which allows deafness effects
void (entity thing) Explosion=
{

	local entity e;
	local float n;
	
	
	while (n < 32)
		{
			e = nextent(e);
			
			if (e.classname != "") // if the player is actually valid
			{
				
				 if (the player e, is deaf) // (pseudocode)
				 	{
						particle (thing.origin, '0 0 0', 75, 255);
			
					}
				else 
					{
						msg_entity = e;	
						WriteByte (#MSG_ONE, #SVC_TEMPENTITY);
						WriteByte (#MSG_ONE, #TE_EXPLOSION);
						WriteCoord (#MSG_ONE, thing.origin_x);
						WriteCoord (#MSG_ONE, thing.origin_y);
						WriteCoord (#MSG_ONE, thing.origin_z);
					}
					
					
			}
			
			n = n+1;
			
		}

};
Post Reply