Sector triggers sound -- prl_sectorsound.cog
A cog that the plays a .wav file in certain sectors after pressing a switch. You can modify it if you need more than 4 sectors or if you want the switch to be green (1 = on) instead of red (0 = off) when the sound is on. If you don't want the switch to turn the sound off again, then delete the second part of the activate code. 23 April 2001
Written for SammyLSD; The Massassi Temple Cog Forum Post

# Jedi Knight Cog Script
#
# prl_sectorsound.cog 
# Sylvicolus [PRL] 23 April 2001
#
# Sound triggered by activating switch.  Use 1 or 2 switches.
# Activate switch again to turn sound off.
# Sound is heard inside of 1 to 4 sectors.
# Choose volume and wav sound.
#
# This cog is not supported by LucasArts Entertainment Co.
                                                         
symbols
message	activate	

surface	switch0		linkid=1
surface	switch1		linkid=1
sector	sector0		nolink
sector	sector1		nolink
sector	sector2		nolink
sector	sector3		nolink
flex	volume=1.0	
sound	wav0=00AlarmLoop03.WAV
int	channel0	local
int	channel1	local
int	channel2	local
int	channel3	local
int	soundstatus=0	local
flex	FadeOut=0.2	local

end

# ========================================================

code

startup:
	setwallcel(switch0, 1);
	if (switch1) setwallcel(switch1, 1);
	return;
## Sets the switch mat to the 2nd cell, which is green or off position. 

activate:
	if (soundstatus==0)  //turn on sound
	{
		soundstatus=1;
		setwallcel(switch0, 0);
		if (switch1) setwallcel(switch1, 0);
		channel0 = SectorSound(sector0, wav0, volume);
		if (sector1) channel1 = SectorSound(sector1, wav0, volume);
		if (sector2) channel2 = SectorSound(sector2, wav0, volume);
		if (sector3) channel3 = SectorSound(sector3, wav0, volume);
	}
	else //turn off sound
	{
		soundstatus=0;
		setwallcel(switch0, 1);
		if (switch1) setwallcel(switch1, 1);
		StopSound(channel0,FadeOut);
		if (sector1) StopSound(channel1,FadeOut);
		if (sector2) StopSound(channel2,FadeOut);
		if (sector3) StopSound(channel3,FadeOut);
	}
	return;

end