Jump to content

Home

Blaster alt_fire sound (E-11 with scope mod) / need help


Path-x

Recommended Posts

Hey,

 

I am making a mod where you can use scope on E-11. Basically the scope script is the same as for the sniper rifle which is: mouse1 for rapid fire and mouse two for zooming/scope and then converting alt_attack from mouse2 to mouse1.

 

Everything works fine I only have one minor problem that I just can't seem to fix. When you press mouse2 to start zooming it also makes an alt_fire sound. It doesn't take any energy/ammo (I scripted it so) but it still makes the sound of alt fire.

 

I am about to give up so if anyone did anything similar or is more expert at this please help. It would also help if anyone know where the code that sets the relation between the keys and blaster sounds is located.

Link to comment
Share on other sites

My guess is line 1912 in cg_waepons.c (I don't have VS installed at the moment, so I can't try it out myself):

// play a sound
if (altFire)
{
	// play a sound
	for ( c = 0 ; c < 4 ; c++ ) {
		if ( !weap->altFlashSound[c] ) {
			break;
		}
	}
	if ( c > 0 ) {
		c = rand() % c;
		if ( weap->altFlashSound[c] )
		{
			trap_S_StartSound( NULL, ent->number, CHAN_WEAPON, weap->altFlashSound[c] );
		}
	}
}

 

The blaster's altFlashSound is set to sound/weapons/blaster/alt_fire.wav BTW, so you should try and override that file with silence first.

Link to comment
Share on other sites

Thanks for the quick reply. I tried to experiment with that a little but I couldn't fix it. I think if you mute the sound based on altFire it doesn't solve the problem. I think I should find the way to remove the sound based on BUTTON_ALT_ATTACK which is mouse2 key.

 

Here are some prepositions from bg_pmove.c file.

 

line6222

if ( pm->ps->weaponstate == WEAPON_CHARGING )
{
	// weapon has a charge, so let us do an attack
#ifdef _DEBUG
	Com_Printf("Firing.  Charge time=%d\n", pm->cmd.serverTime - pm->ps->weaponChargeTime);
#endif

	// dumb, but since we shoot a charged weapon on button-up, we need to repress this button for now
	pm->cmd.buttons |= BUTTON_ATTACK;
	pm->ps->eFlags |= EF_FIRING;
}
else if ( pm->ps->weaponstate == WEAPON_CHARGING_ALT )
{
	// weapon has a charge, so let us do an alt-attack
#ifdef _DEBUG
	Com_Printf("Firing.  Charge time=%d\n", pm->cmd.serverTime - pm->ps->weaponChargeTime);
#endif


               // dumb, but since we shoot a charged weapon on button-up, we need to repress this button for now
	pm->cmd.buttons |= BUTTON_ALT_ATTACK;
	pm->ps->eFlags |= (EF_FIRING|EF_ALT_FIRING);
}

 

This one is basically from charged weapon section. Sniper rifle belongs to this section so the tirck might be in this. The reason I brought up this code is the comment: "// dumb, but since we shoot a charged weapon on button-up, we need to repress this button for now".

 

line7659

if ( pm->cmd.buttons & BUTTON_ALT_ATTACK ) 	{
	//if ( pm->ps->weapon == WP_BRYAR_PISTOL && pm->gametype != GT_SIEGE )
	if (0)
	{ //kind of a hack for now
		PM_AddEvent( EV_FIRE_WEAPON );
		addTime = weaponData[pm->ps->weapon].fireTime;
	}
	else if (pm->ps->weapon == WP_DISRUPTOR && pm->ps->zoomMode != 1)
	{
		PM_AddEvent( EV_FIRE_WEAPON );
		addTime = weaponData[pm->ps->weapon].fireTime;
	}
	else if (pm->ps->weapon == WP_BLASTER && pm->ps->zoomMode != 1)
	{
		PM_AddEvent( EV_FIRE_WEAPON );
		addTime = weaponData[pm->ps->weapon].fireTime;
	}

 

Another reference to alt_attack button. Only that I already set it for WP_BLASTER too.

 

line8229

if ( pm->ps->weapon == WP_DISRUPTOR || pm->ps->weapon == WP_BLASTER)
{
	if ( pm->cmd.buttons & BUTTON_ATTACK && pm->ps->zoomMode == 1 && pm->ps->zoomLocked)
	{
		// converting the main fire to an alt-fire
		pm->cmd.buttons |= BUTTON_ALT_ATTACK;
		pm->ps->eFlags |= EF_ALT_FIRING;
	}
	else if ( pm->cmd.buttons & BUTTON_ALT_ATTACK && pm->ps->zoomMode == 1 && pm->ps->zoomLocked)
	{
		pm->cmd.buttons &= ~BUTTON_ALT_ATTACK;
		pm->ps->eFlags &= ~EF_ALT_FIRING;
	}
}

 

This is a segment of code within the scope script that converts alt_attack from mouse button 2 to mouse button 1 once you zoomed the scope. I included WP_BLASTER too so this works fine.

 

Now I think the problem is that somewhere it is set for WP_BLASTER (or perhaps all the non special weapon) that when you press BUTTON_ALT_ATTACK (mouse2) it also executes the alt_fire sound. Obviously sniper rifle does no attack sound when you are pressing mouse2 but it only does the zoomin sound. So I think I should be looking for relation between the BUTTON_ALT_ATTACK and ALT_FIRE.mp3 sound rather than relation between altFire function and ALT_FIRE.mp3 sound. AltFire function is necessary for executing sound when pressing mouse1 when scope is on so I don't think I should mess with it.

Link to comment
Share on other sites

Have you tried overriding sound/weapons/blaster/alt_fire.mp3, yet? Just to be sure that it is really the sound that you hear. If so, that sound is only referenced once throughout the code, namely where the blaster's altFlashSound is intialized. And altFlashSound in turn is only referenced once (in the piece of code from my first reply). I don' think there's a direct binding between pressing alt_attack button and playing alt fire sound. If I were you, I'd put a breakpoint on line 1916 of cg_weapons.c and see if it triggers, then inspect the callstack (actually, if I were you, I'd be content in overriding blaster/alt_fire.mp3 - if it works).

Link to comment
Share on other sites

I finally managed to fix it. I added separate CASE structure for WP_BLASTER where the sounds are defined and modified/added few lines there. Works perfectly. Thanks for the replies. :D

 

Nizwiz, I didn't try to overriding it but if you wish I can try that too?

Link to comment
Share on other sites

Anyway the E-11 with scope is only a segment in a larger project I am trying to make. I always wanted to make a mod for Siege. I always found the current Siege a bit unattractive since all the combat is pretty much carried out by explosive weapons and area attack weapons (DEMP2, concussion launcher). Iconic weapons like E-11, DL-44 and Bowcaster are pretty much redundant.

 

So far I have made most of the coding to modify weapons and classes. Reducing almost all explosive/area weapons to minimum. Increasing blaster bolt speed. Detpack would now play the key role for objectives, I set a timer for it and a primitive defuse concept which is if you hit and blow the detpack it does 0 damage but if the timer goes off it does 9999 damage. Etc. Etc.

 

Well a huge amount of work still awaits since I want a map for it. Well my brother is pretty skilled at mapping but at this point is he say it's not worth it since so little people still play JKA. Yes it is a reasonable question I should ask my self too. :indif:

Link to comment
Share on other sites

Nizwiz, I didn't try to overriding it but if you wish I can try that too?

 

No sweat. Since you've managed to fix it, where's the point in pursuing the matter any futher?

 

BTW, very neat idea, this mod of yours. Don't listen to your brother (at least in this regard).

Link to comment
Share on other sites

  • 2 months later...

Argh, I've had exactly the same problem a couple of time and I can't for the life of me remember how I fixed it. It's something to do with it still trying to call a function related to the alt-fire. The best advice I can give off-hand is just to search through every point where the blaster's alt-fire is mentioned, and cut out anything you don't want.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...