Heartbeat sound


(Xterm1n8or) #1

Hi all :smiley:

Having had some moderate success with sounds, i thought i’d try another.
I’m ultimately trying to produce a shellshock effect. This will be in the form of 2 things:[ul]1. A heartbeat sound.
2. Some way to ‘muffle’ the surrounding sound.[/ul]This affect will take place while the player has been critically injured and is waiting to be revived by a medic.

I think that i have pretty much done part 1. This is what i have:
outpost.menu:

        YESNO( 8, 106, (SUBWINDOW_WIDTH)-4, 10, "Heartbeat:", .2, 8, "cg_heartbeat", "Enable/Disable Heartbeat sounds" )

cg_local.h:

extern  vmCvar_t        cg_heartbeat;

sfxHandle_t heartbeat;

cg_main.c:

vmCvar_t    cg_heartbeat;

    { &cg_heartbeat, "cg_heartbeat", "1", CVAR_ARCHIVE },

    cgs.media.heartbeat =           trap_S_RegisterSound( "sound/outpost/heartbeat.wav", qfalse );

ui_main.c:

    { NULL, "cg_heartbeat", "1", CVAR_ARCHIVE },

I think i have everything i need here, except for the next bit (which i’m having trouble with):

if(cg_heartbeat.integer > 0) trap_S_StartLocalSound( cgs.media.countPrepare, CHAN_ANNOUNCER );

There are 2 things i can see wrong with the last bit of code[ul]1. The sound is played through the announcer. Will that not make it so everybody hears?
2. I’m not sure where to put it. I thought it should go where the player is in that state. So far i’ve only found this:[/ul]bg_move.c:

void PM_UpdateViewAngles( playerState_t *ps, pmoveExt_t *pmext, usercmd_t *cmd, void (trace)( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentMask ), int tracemask ) {	//----(SA)	modified
	short	temp;
	int		i;
	pmove_t tpm;
	vec3_t oldViewAngles;

	// DHM - Nerve :: Added support for PMF_TIME_LOCKPLAYER
	if ( ps->pm_type == PM_INTERMISSION || ps->pm_flags & PMF_TIME_LOCKPLAYER ) {
		return;		// no view changes at all
	}

	if ( ps->pm_type != PM_SPECTATOR && ps->stats[STAT_HEALTH] <= 0 ) {

		// DHM - Nerve :: Allow players to look around while 'wounded' or lock to a medic if nearby
		temp = cmd->angles[1] + ps->delta_angles[1];
		// rain - always allow this.  viewlocking will take precedence
		// if a medic is found
		// rain - using a full short and converting on the client so that
		// we get >1 degree resolution
		ps->stats[STAT_DEAD_YAW] = temp;
		return;		// no view changes at all
	}

Hope you can help, many thanks :smiley: