View Single Post
Old 05-26-2013, 12:59 PM   #4
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.
It's possible using Lua for sure.

Either something like (I forget if this works right):
Code:
local death_sound = "soundname"

-- sounds need to be precached
function precache()
	PrecacheSound( death_sound )
end

function player_killed( player, damageinfo )
	-- could test various things about the death here 
	-- and then only play the sound depending on certain conditions

	-- 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
or something like (no clue if this would actually work, haven't moved sound entities before):
Code:
function player_killed( player, damageinfo )
	-- could test various things about the death here 
	-- and then only play the sound depending on certain conditions

	-- teleport the entity (like an ambient_generic or w/e) 
	-- with the given name to the location of the death 
	-- and then trigger it to play its sound
	local sound_ent_name = "entity_name"
	local deathpos = player:GetOrigin()
	local sound_ent = GetEntityByName( sound_ent_name )
	sound_ent:SetOrigin( deathpos.x, deathpos.y, deathpos.z )
	OutputEvent(sound_ent_name, "PlaySound")
end
The second method might get somewhat weird when multiple people are dying in rapid succession in different places around the map (the entity would be teleporting all around, I'm not sure how it'd sound).

Both are completely untested.
__________________
#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

Last edited by squeek.; 05-26-2013 at 01:01 PM.
squeek. is offline   Reply With Quote