Crowbar "attack miss" Sound Created 13 years ago2011-09-03 21:33:51 UTC by gameaddict117o7 gameaddict117o7

Created 13 years ago2011-09-03 21:33:51 UTC by gameaddict117o7 gameaddict117o7

Posted 13 years ago2011-09-03 21:33:51 UTC Post #298626
This has been bugging me for a while now. In C++, how would I go about making the crowbar's "swoosh" sound when it misses play at a random pitch (sometimes a bit higher, sometimes a bit lower, etc.), like in older versions of Half-Life 1 (pre-1.1.1.0)? Right now, it just plays the sound like I'm repeating it in Windows Media Player or something. Hope what I said was understandable.
gameaddict117o7 gameaddict117o7SavebearingBoss
Posted 13 years ago2011-09-03 22:43:23 UTC Post #298630
You would probably want to make several different sound files editing the pitch, and then using a form of code to choose them in an order or at random.
Dimbeak DimbeakRotten Bastard
Posted 13 years ago2011-09-03 23:34:59 UTC Post #298631
Dimbark is right. If you look at the 9mmAR fire sounds, there are three of them at different pitches. Though there are other things in the game that have self varying pitch. I believe the crowbar impact sounds have self variable pitches. You may want to look at the code there and so how it was achieved.
Rimrook RimrookSince 2003
Posted 13 years ago2011-09-04 14:55:31 UTC Post #298646
Self-variable? As in, the sound file itself was made at a different pitch?
gameaddict117o7 gameaddict117o7SavebearingBoss
Posted 13 years ago2011-09-04 15:29:26 UTC Post #298647
Ja.
Dimbeak DimbeakRotten Bastard
Posted 13 years ago2011-09-04 18:43:26 UTC Post #298649
Some of the sounds from the crowbar and the 9mmAR have code where the pitch is changed by the game, not by different sound files. Another good example is the ricochet sound effect. Though these are all places to look in the source code to see how the effect was done so you can find a way to do it yourself. As for the actual code, you might want to ask someone who specifically knows how to code.

Otherwise its just a 12 year-old kid and a recovering surgery patient who's high on pain killers trying to help you out, which is actually quite hilarious.
Rimrook RimrookSince 2003
Posted 13 years ago2011-09-05 13:49:08 UTC Post #298667
I did the method Dimbark suggested, and made four sound files. "cbar_miss.wav" (original pitch), "cbar_miss1.wav" (null sound. The crowbar's viewmodel plays the default sound on top of the sounds in the code, which sounded weird to me.), "cbar_miss2.wav" (pitched down 5 units in audacity), and "cbar_miss3.wav" (pitched up 5 units in audacity).

After that, I went into the source code, and changed "cbar_miss1.wav" to "cbar_miss.wav", added miss2 and miss3 and it works like a charm! :)
gameaddict117o7 gameaddict117o7SavebearingBoss
Posted 13 years ago2011-09-05 13:54:37 UTC Post #298668
Here's the code I used (the bold is what I modified for that particular section:

void CCrowbar::Precache( void )
{
PRECACHE_MODEL("models/v_crowbar.mdl");
PRECACHE_MODEL("models/w_crowbar.mdl");
PRECACHE_MODEL("models/p_crowbar.mdl");
PRECACHE_SOUND("weapons/cbar_hit1.wav");
PRECACHE_SOUND("weapons/cbar_hit2.wav");
PRECACHE_SOUND("weapons/cbar_hitbod1.wav");
PRECACHE_SOUND("weapons/cbar_hitbod2.wav");
PRECACHE_SOUND("weapons/cbar_hitbod3.wav");
PRECACHE_SOUND("weapons/cbar_miss.wav");
PRECACHE_SOUND("weapons/cbar_miss2.wav");
PRECACHE_SOUND("weapons/cbar_miss3.wav");
[b]PRECACHE_SOUND("weapons/cbar_miss.wav");
PRECACHE_SOUND("weapons/cbar_miss2.wav");
PRECACHE_SOUND("weapons/cbar_miss3.wav");[/b]
void CCrowbar::PrimaryAttack()
{
if (! Swing( 1 ))
{
	SetThink( &CCrowbar::SwingAgain );
	pev->nextthink = gpGlobals->time + 0.1;
	[b]// play whoosh sound
			switch( RANDOM_LONG(0,2) )
			{
			case 0:
				EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_miss.wav", 1, ATTN_NORM); break;
			case 1:
				EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_miss2.wav", 1, ATTN_NORM); break;
			case 2:
				EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_miss3.wav", 1, ATTN_NORM); break;
			}
}
}[/b]
gameaddict117o7 gameaddict117o7SavebearingBoss
You must be logged in to post a response.