# Jedi Knight Missions Cog Script
#
# prl_thing_move2.cog
# Sylvicolus [PRL] 9 February 2002
#
# Thing_to_move can be an elevator, platform, or any thing
# (if a door then adjoins, light not affected).
# **Thing is started from and returned to frame 1.
# Thing can be called/sent to frame 0 or frame 2.
#
# Only supply values for the types of triggers you want to use.
# Trigger number sends thing to that frame, for example:
# surface_trigger0 (linkid=0) sends thing to frame 0
# thing_trigger2 (linkid=2) sends thing to frame 2
# GetSenderId(); is used to determine which frame to move to.
#
# If you need more triggers for a particular frame
# just add them to the symbols section.
#
# This cog is not supported by LucasArts Entertainment Co.
symbols
message startup
message activated
message entered
thing thing_to_move nolink
surface surface_trigger0 linkid=0
sector sector_trigger0 linkid=0
thing thing_trigger0 linkid=0
surface surface_trigger2 linkid=2
sector sector_trigger2 linkid=2
thing thing_trigger2 linkid=2
flex start_wait=0.5 desc=pause_before_moving
flex sleeptime=2.0
flex speed=4.0
sound trigger_sound=Activate02.wav
sound return_sound=beep2.wav
int active=0 local
int trigger=0 local
int triggerid local
int triggertype local
end
# ========================================================
code
startup:
sleep(1.0);
MoveToFrame(thing_to_move,1,speed);
return;
activated:
entered:
if (active) return;
active=1;
triggertype = GetSenderType();
triggerid = GetSenderId();
trigger = GetSenderRef();
sleep(0.2);
if (triggertype==3) //trigger is a thing
{
PlaySoundThing(trigger_sound, GetThingPos(trigger), 1, -1, -1, 0 );
call movething;
PlaySoundThing(return_sound, GetThingPos(trigger), 1, -1, -1, 0 );
}
else if (triggertype==5) //trigger is a sector
{
PlaySoundThing(trigger_sound, GetThingPos(thing_to_move), 1, -1, -1, 0 );
call movething;
PlaySoundThing(return_sound, GetThingPos(thing_to_move), 1, -1, -1, 0 );
}
else if (triggertype==6) //trigger is a surface
{
PlaySoundPos(trigger_sound, SurfaceCenter(trigger), 1, -1, -1, 0 );
SetWallCel(trigger,1);
call movething;
PlaySoundPos(return_sound, SurfaceCenter(trigger), 1, -1, -1, 0 );
SetWallCel(trigger,0);
}
active=0;
return;
movething:
sleep(start_wait);
MoveToFrame(thing_to_move,triggerid,speed);
WaitForStop(thing_to_move);
sleep(sleeptime);
MoveToFrame(thing_to_move,1,speed);
WaitForStop(thing_to_move);
return;
end
|