# Jedi Knight Cog Script
#
# prl_alarm1a.cog
# Sylvicolus [PRL] 28 July 2001
#
# Alarm triggered by entering sector or by switch.
# Alarm turned off by activating switch
# For use with a regular 2-celled switch.
#
# This cog is not supported by LucasArts Entertainment Co.
symbols
message startup
message entered
message activate
sector alarmsector
surface alarmswitch linkid=1
flex volume=2.0
flex AlarmMaxDistance=20
sound alarm=00AlarmLoop03.WAV
flex FadeOut=0.2 local
int channel local
int alarmstatus=0 local
int done=0 local
end
# ========================================================
code
startup:
setwallcel(alarmswitch, 1);
return;
## Sets the switch mat to the 2nd cell, which is green or off position.
entered:
if (done) return;
done=1;
call soundalarm;
return;
soundalarm:
alarmstatus=1;
setwallcel(alarmswitch, 0);
channel = PlaySoundPos(alarm, GetSurfaceCenter(alarmswitch), volume, 1, AlarmMaxDistance, 0x1);
return;
activate:
if (alarmstatus==0)
{
call soundalarm;
return;
}
alarmstatus=0;
StopSound(channel,FadeOut);
setwallcel(alarmswitch, 1);
return;
end
|