Playing Sounds?


(Rudi) #1

Okay I feel like a total n00b for asking… but I’m trying to make hitsounds, and I can’t get the sounds to play, probably my fault, but I’ve copied code from other areas that are related to sounds.

Here’s what I’ve tried:

te = G_TempEntity( attacker, EV_GENERAL_SOUND );
te->s.eventParm = G_SoundIndex( “sound/hitshots/beep.wav” );

G_AddEvent( attacker, EV_GENERAL_SOUND, G_SoundIndex ( “sound/hitshots/beep.wav” ) );

I guess that I somehow have to trigger them both…

Any help please?

Thanks in advance :slight_smile:


(nUllSkillZ) #2

You could have a look at et-pub.
Source code is available.

Not sure but I think here in the forums is at least one thread dealing with hitsounds.
So you could also try the search.


(Rudi) #3

You don’t think I’ve tried the search?? :smiley: :smiley:

Anyway, 'course I have!


void G_Hitsound(gentity_t *targ,
		gentity_t *attacker,
		int mod,
		qboolean gib,
		qboolean headShot) 
{
	gentity_t *hs_ent;
	gclient_t *client;
	int snd;

	if(!(g_hitsounds.integer & HSF_ENABLE))
		return;
	if((g_hitsounds.integer & HSF_NO_POISON) && mod == MOD_POISON)
		return;
	if(!attacker->client)
		return;
	if(!attacker->client->pers.hitsounds)
		return;
	if(!targ->client) 
		return;
	if(mod == MOD_GOOMBA) 
		return;
	if(targ->health <= 0 && (g_hitsounds.integer & HSF_SILENT_CORPSE))
		return;

	client = targ->client;

	hs_ent = G_TempEntity(attacker->client->ps.origin, 
		       EV_GLOBAL_CLIENT_SOUND);
	hs_ent->s.teamNum = (attacker->client - level.clients);

	// default hitsound
	snd = G_SoundIndex(g_hitsound_default.string);

	if((targ->health <= 0) && (g_hitsounds.integer & HSF_NO_CORPSE_HEAD)) 
		headShot = qfalse;

	// vsay "hold your fire" on the first hit of a teammate
	// only applies if the player has been hurt before
	// and the match is not in warmup.
	if(OnSameTeam(targ, attacker)) {
		if(!(g_hitsounds.integer & HSF_NO_TEAM_WARN) &&
			(!client->lasthurt_mod || 
			 client->lasthurt_client != attacker->s.number) &&
			g_gamestate.integer == GS_PLAYING &&
			!gib) {
			
			if(client->sess.sessionTeam == TEAM_AXIS) {
				snd = G_SoundIndex(
					g_hitsound_team_warn_axis.string);
			}
			else {
				snd = G_SoundIndex(
					g_hitsound_team_warn_allies.string);
			}
		}
		else if(headShot) {

			if(!(targ->client->ps.eFlags & EF_HEADSHOT)) {
				snd = G_SoundIndex(
					g_hitsound_team_helmet.string);
			}
			else { 
				snd = G_SoundIndex(
					g_hitsound_team_head.string);
			}
		}
		else {
			snd = G_SoundIndex(g_hitsound_team_default.string);
		}
	}
	else if(headShot) {
		if(!(targ->client->ps.eFlags & EF_HEADSHOT))
			snd = G_SoundIndex(g_hitsound_helmet.string);
		else 
			snd = G_SoundIndex(g_hitsound_head.string);
	}
	hs_ent->s.eventParm = snd;
}

Copied that, and, well, nada.


(crapshoot) #4

try http://www.splashdamage.com/forums/viewtopic.php?t=12717&postdays=0&postorder=asc&highlight=hitsound&start=15

look for Jaybird’s post


(Rudi) #5

I did search, really! :shock:

But thanks!


(jaybird) #6

Of course, besides the actual code you need to make a pk3 with the sounds!


(Rudi) #7

Yes and it works! Thank you thank you thank you! And jay, whilst I have you (Well you’ve probably gone and this is off topic), how do you do the jaymod double jump.

I have looked over and changed the double jump code I found in this forum, but nothing at all makes it like yours!