# Jedi Knight Cog Script
#
# prl_funicular_switch.cog
# modified from 00_elev_switch.cog
# Sylvicolus [PRL] 27 February 2001
# http://www.lactarius.com/sylvicolus/jk/
#
# When either of two switches are activated, This elevator
# or funicular will go from frame 0 to frame 1,
# sleep, then come back down to frame 0.
# An alarm will sound, then a pause, before elevator starts moving.
# Elevator will not react to "blocked" message.
#
# This cog is not supported by LucasArts Entertainment Co.
symbols
message activated
message arrived
message timer
surface switch1 linkid=1
surface switch2 linkid=1
thing elevator linkid=2
flex start_wait=0.5 desc=pause_before_alarm
flex move_wait=2.0 desc=pause_before_moving
flex sleeptime=5.0
flex speed=2.0
sound wav0=Activate02.wav
sound alarm=00alarmloop01.wav
end
# ========================================================
code
activated:
if (GetSenderId() != 1) return; // message came from elevator
if (GetWallCel(switch1) == 1) return;
SetWallCel(switch1, 1);
SetWallCel(switch2, 1);
PlaySoundPos(wav0, SurfaceCenter(switch1), 0.6, -1, -1, 0);
PlaySoundPos(wav0, SurfaceCenter(switch2), 0.6, -1, -1, 0);
sleep(start_wait);
PlaySoundThing(alarm, elevator, 3.0, -1, -1, 0x84);
sleep(start_wait);
PlaySoundThing(alarm, elevator, 3.0, -1, -1, 0x84);
sleep(move_wait);
MoveToFrame(elevator, 1, speed);
return;
arrived:
if (GetCurFrame(elevator) == 0)
{
SetWallCel(switch1, 0);
SetWallCel(switch2, 0);
PlaySoundPos(wav0, SurfaceCenter(switch1), 0.6, -1, -1, 0);
PlaySoundPos(wav0, SurfaceCenter(switch2), 0.6, -1, -1, 0);
} else {
// Set sleep time at top
SetTimer(sleeptime);
}
return;
timer:
// Send elevator down
PlaySoundThing(alarm, elevator, 3.0, -1, -1, 0);
sleep(start_wait);
PlaySoundThing(alarm, elevator, 3.0, -1, -1, 0);
sleep(move_wait);
MoveToFrame(elevator, 0, speed);
return;
end
|