View Single Post
Old 05-28-2013, 04:40 AM   #8
squeek.
Stuff Do-er
Lua Team
Wiki Team
Fortress Forever Staff
 
squeek.'s Avatar
 
Join Date: Mar 2007
Location: Northern California
Class/Position: Rallygun Shooter
Gametype: Conc tag (you just wait)
Affiliations: Mustache Brigade
Posts Rated Helpful 352 Times
Send a message via AIM to squeek.
Sure.

Code:
death_sounds = { 
	[Player.kScout] = "customsound.scout",
	[Player.kSniper] = "customsound.sniper",
	[Player.kSoldier] = "customsound.soldier",
	[Player.kDemoman] = "customsound.demoman",
	[Player.kMedic] = "customsound.medic",
	[Player.kHwguy] = "customsound.hwguy",
	[Player.kPyro] = "customsound.pyro",
	[Player.kSpy] = "customsound.spy",
	[Player.kEngineer] = "customsound.engineer",
	[Player.kCivilian] = "customsound.civilian"
}

-- sounds need to be precached
function precache()
	-- precache each sound in the table
	for class_id,death_sound in pairs(death_sounds) do
		PrecacheSound( death_sound )
	end
end

function player_killed( player, damageinfo )
	-- could test various things about the death here 
	-- and then only play the sound depending on certain conditions
	local death_sound = death_sounds[ player:GetClass() ]

	-- emit sound from the dying player
	-- EmitSound will play a sound from a sound script 
	-- (you can write a <mapname>_level_sounds.txt 
	-- in the maps folder if you want a custom sound I think, 
	-- see ff_waterpolo_level_sounds.txt)
	player:EmitSound( death_sound )
end
You can also use soundscripts to randomly choose between a number of different sounds, like so (taken from scripts/game_sounds_ff_player.txt):
Code:
	"Player.Pain"
	{
		"channel"		"CHAN_VOICE"
		"volume"		"1.0"
		"CompatibilityAttenuation"	"1.0"

		"rndwave"
		{
			"wave"		"player/pain1.wav"
			"wave"		"player/pain2.wav"
			"wave"		"player/pain3.wav"
			"wave"		"player/pain4.wav"
			"wave"		"player/pain5.wav"
			"wave"		"player/pain6.wav"
			"wave"		"player/pain7.wav"
			"wave"		"player/pain8.wav"
		}
	}
That will use one of pain1-pain8.wav each time Player.Pain is played.
__________________
#FF.Pickup ยค Fortress-Forever pickups

My Non-official Maps
Released FF_DM_Squeek - FF_2Mesa3_Classic - FF_Siege_Classic
Beta FF_Myth - FF_Redlight_Greenlight

Sick of the people on the internet, always moanin'. They just moan.
- Karl Pilkington
squeek. is offline   Reply With Quote


1 members found this post helpful.