コード例 #1
0
static void Use_Target_Speaker( edict_t *ent, edict_t *other, edict_t *activator )
{
	if( ent->spawnflags & 3 )
	{
		// looping sound toggles
		if( ent->s.sound )
			ent->s.sound = 0; // turn it off
		else
			ent->s.sound = ent->noise_index; // start it
		ent->r.svflags ^= SVF_NOCLIENT;
	}
	else
	{
		// normal sound
		if( ent->spawnflags & 8 )
			G_Sound( activator, CHAN_VOICE, ent->noise_index, ent->attenuation );
		else if( ent->spawnflags & 16 )
			G_LocalSound( activator, CHAN_AUTO, ent->noise_index );
		else if( ent->spawnflags & 4 )
			G_GlobalSound( CHAN_AUTO, ent->noise_index );
		// use a G_PositionedSound, because this entity won't normally be
		// sent to any clients because it is invisible
		else
			G_PositionedSound( ent->s.origin, CHAN_VOICE, ent->noise_index, ent->attenuation );
	}
}
コード例 #2
0
ファイル: g_items.cpp プロジェクト: Clever-Boy/qfusion
void DoRespawn( edict_t *ent )
{
	if( ent->team )
	{
		edict_t	*master;
		int count;
		int choice;

		master = ent->teammaster;
		
		assert( master != NULL );

		if( master ) {
			for( count = 0, ent = master; ent; ent = ent->chain, count++ );

			choice = rand() % count;

			for( count = 0, ent = master; count < choice; ent = ent->chain, count++ );
		}
	}

	ent->r.solid = SOLID_TRIGGER;
	ent->r.svflags &= ~SVF_NOCLIENT;
	ent->s.effects &= ~EF_GHOST;

	GClip_LinkEntity( ent );

	// send an effect
	G_AddEvent( ent, EV_ITEM_RESPAWN, ent->item ? ent->item->tag : 0, true );

	// powerups announce their presence with a global sound
	if( ent->item && ( ent->item->type & IT_POWERUP ) )
	{
		if( ent->item->tag == POWERUP_QUAD )
			G_GlobalSound( CHAN_AUTO, trap_SoundIndex( S_ITEM_QUAD_RESPAWN ) );
		if( ent->item->tag == POWERUP_SHELL )
			G_GlobalSound( CHAN_AUTO, trap_SoundIndex( S_ITEM_WARSHELL_RESPAWN ) );
		if( ent->item->tag == POWERUP_REGEN )
			G_GlobalSound( CHAN_AUTO, trap_SoundIndex( S_ITEM_REGEN_RESPAWN ) );
	}
}