not loop / ready


(nikita) #1

When i give in the weap file a ready sound it makes it loop
now i want it to be 1 time play when am changing to the specfic weapon
how do i make the ready sound of the weapon play once when reising up?

do i need to change something here?

}
} else if( !Q_stricmp( token.string, “readySound” ) ) {
if( !PC_String_ParseNoAlloc( handle, filename, sizeof(filename) ) ) {
return CG_RW_ParseError( handle, “expected readySound filename” );
} else {
weaponInfo->readySound = trap_S_RegisterSound( filename, qfalse );

or here? its in the thompson.weap the ready sound i added =
readySound “sound/weapons/thompson/thompson_ready.wav”

THE sounds are not looped + mono + 22 khz


(P4nth3r) #2

I’m not sure if this works, but can’t you just alter the:

switchSound // allow overriding of weaponswitch sound

in the weapon config files for that?

Greetz Panther aka Way2Evil


(Jaquboss) #3

quick way: add event to finishweaponchange, however you may want to not modify server stuff, then it is better to find something for client


(nikita) #4

switch sound is when u switching mode sound of the weapon not the weapon himself such as when u put the silencer on a colt he uses switchsound
its not ready sound thanks anyway… anything else?


(Jaquboss) #5

bg_pmove.c :
two ways: after animation is played
under

	if( pm->ps->weaponstate == WEAPON_RAISING ) {
		pm->ps->weaponstate = WEAPON_READY;

or when animation is played
under

	if( pm->ps->weaponstate == WEAPON_DROPPING_TORELOAD ) {
		pm->ps->weaponstate = WEAPON_RAISING_TORELOAD;
	} else {
		pm->ps->weaponstate = WEAPON_RAISING;
	}

add

			PM_AddEvent( EV_SWITCHWEAPON );

now declare EV_SWITCHWEAPON ( add it in lists in bg_public.h and bg_misc.c )
you can now add under ( cg_event.c )

	case EV_EMPTYCLIP:
		DEBUGNAME("EV_EMPTYCLIP");
		break;
	case EV_SWITCHWEAPON :
		DEBUGNAME("EV_SWITCHWEAPON ");
			trap_S_StartSound (NULL, es->number, CHAN_WEAPON, cg_weapons[es->weapon].raiseSound );
		break;

add sfxHandle_t raiseSound; to weaponInfo_t ( cg_local.h
and in cg_weapons.c rewrite this

		/*} else if( !Q_stricmp( token.string, "ammoIcon" ) ) {
			if( !PC_String_ParseNoAlloc( handle, filename, sizeof(filename) ) ) {
				return CG_RW_ParseError( handle, "expected ammoIcon filename" );
			} else {
				weaponInfo->ammoIcon = trap_R_RegisterShader( filename );
			}*/

to this

		} else if( !Q_stricmp( token.string, "raiseSound" ) ) {
			if( !PC_String_ParseNoAlloc( handle, filename, sizeof(filename) ) ) {
				return CG_RW_ParseError( handle, "raise sound filename" );
			} else {
				weaponInfo->raiseSound= trap_S_RegisterSound( filename, qfalse );
			}

havent tried so dont yell if there are errors


(nikita) #6

thank you but its now making the sound when i switch FROM a weapon
instead of TO a weapon

let me explien more

spose i want a reise sound for thompson
he uses the reguler change sound when am reising thompson but when am reising other weapon after i lowered thompson then his making the right sound…
a bit confused how to fix . thank you


(Jaquboss) #7

try to use first way after animation, it seems it uses old weapon for this

trap_S_StartSound (NULL, es->number, CHAN_WEAPON, cg_weapons[es->weapon].raiseSound ); 

also try to put that PM_AddEvent( EV_SWITCHWEAPON ); lower in the func, and at last small fix
up

trap_S_StartSound (NULL, es->number, CHAN_WEAPON, cg_weapons[es->weapon].raiseSound ); 

stick

if( cg_weapons[es->weapon].raiseSound ) 

(nikita) #8

huh you explien better on the first explimation part
where to put what again?


(Jaquboss) #9

after

 if( pm->ps->weaponstate == WEAPON_RAISING ) {
      pm->ps->weaponstate = WEAPON_READY;

(nikita) #10

am more then confused am not a programmer or anything i ment i want to know in witch file to put what
now u gave me 3 parts to put them all in bg_pmove_c after
if( pm->ps->weaponstate == WEAPON_RAISING ) {
pm->ps->weaponstate = WEAPON_READY;
or each part goes to another place and if so please tell what file witch thing g2g


(Jaquboss) #11

place there

 PM_AddEvent( EV_SWITCHWEAPON );

as i said only problem is that it was using old weapon, in the moment i suggested
that is

if( pm->ps->weaponstate == WEAPON_RAISING ) {
pm->ps->weaponstate = WEAPON_READY; 

it should be ok
so:

if( pm->ps->weaponstate == WEAPON_RAISING ) {
pm->ps->weaponstate = WEAPON_READY; 
PM_AddEvent( EV_SWITCHWEAPON );

(*Shadow* Commando) #12

If you want a new switchsound for all weapons you can do this:

Use Jaquboss’s code:

      } else if( !Q_stricmp( token.string, "raiseSound" ) ) { 
         if( !PC_String_ParseNoAlloc( handle, filename, sizeof(filename) ) ) { 
            return CG_RW_ParseError( handle, "raise sound filename" ); 
         } else { 
            weaponInfo->raiseSound= trap_S_RegisterSound( filename, qfalse ); 
         }

In cg_local.h add:

sfxHandle_t raiseSound;

And in cg_weapons.c cg_playswitchsound:

	sfxHandle_t	switchsound;
	sfxHandle_t	gunsound;

	switchsound = cgs.media.selectSound;
	gunsound = cg_weapons[newweap].raiseSound;

	trap_S_StartSound (NULL, cg.snap->ps.clientNum, CHAN_WEAPON, gunsound );

This way it will play the normal switchsound, and a sound you set in the *.weap file.
If you only want the new sound to be played, remove:

trap_S_StartSound (NULL, cg.snap->ps.clientNum, CHAN_WEAPON, switchsound );