Sound for thing or surface -- prl_playsound.cog
This cog plays a sound when a surface or thing is activated by the player. I mostly use this for fake doors but it can be used for other effects. You can also choose a voice wav to be played the first time. 17 March 2002

# Jedi Knight Cog Script
#
# prl_playsound.cog
# Sylvicolus [PRL] 17 March 2002
#
# Play sound on thing or surface when activated.
# If dialogue=1 then also play a voice wav the first time.
# 
# Example sounds from MOTS
# door click = lvrclik2.wav
# door bang  = df_door2-3.wav
# door thump = df_door3-3.wav
#
# kk61202.wav = not getting in that way
# kk60026.wav = locked
# kk60027.wav = locked!
# kk60022.wav = there must be a way out of here
# kk60023.wav = nothing
# kk60028.wav = huh, stuck
# kk60071.wav = hey, open up!
# kk60077.wav = I guess this thing's broken
#
# This cog is not supported by LucasArts Entertainment Co.

symbols	
	message	activated
	sound	playsound=lvrclik2.wav
	sound	playvoice=kk61202.wav
	int	dialogue=0
	int	said=0 		local
	int	trigger=0	local
	int	triggertype	local

	thing	thing0
	thing	thing1
	thing	thing2
	thing	thing3
	thing	thing4
	thing	thing5
	thing	thing6
	surface	surface0
	surface	surface1
	surface	surface2
	surface	surface3
	surface	surface4
	surface	surface5
	surface	surface6
	surface	surface7
	surface	surface8
	surface	surface9

end

code

activated:
	triggertype = GetSenderType();
	trigger = GetSenderRef();
	sleep(0.2);
	if (triggertype==3)		//trigger is a thing
	{
		PlaySoundThing(playsound, GetThingPos(trigger), 1, -1, -1, 0 );
	}
	else if (triggertype==6)	//trigger is a surface
	{
		PlaySoundPos(playsound, SurfaceCenter(trigger), 1, -1, -1, 0 );
	}
	if (dialogue && !said)
	{
		said=1;
		Sleep(GetSoundLen(playsound+1));
		PlaySoundLocal(playvoice, 1,  0, 0x4);
	}
	return;  

end