# Jedi Knight Cog Script # # 03DOORSWITCH.COG # # # [SavageX] modified version of 00_doorswitch.cog # # (C) 1997 LucasArts Entertainment Co. All Rights Reserved symbols message startup message activated message arrived surface switch0 linkid=1 thing door0 linkid=2 thing soundpos flex movespeed=2.0 flex sleeptime=10.0 flex lightvalue=0.5 sound onSound=set_hi2.wav local sound offSound=lgclick1.wav local sound locksound=df_door2-3.wav local sound countdown=countdown.wav sound access=cp61317.wav sound alarm=00alarmloop01.wav sound dialogue=mj60101.wav flex lasttime=-1 local flex curtime=-1 local int doorsector local int doorstatus=0 local int movestatus=0 local int dummy local end # ======================================================================================== code startup: doorsector = GetThingSector(door0); SectorAdjoins(doorsector, 0); SectorLight(doorsector, lightvalue, 0.0); // add some light to door sector return; # ........................................................................................ activated: if (GetSenderId() == 1) { call checkstatus; if(movestatus) return; if(doorstatus == 0) { if(GetInv(player, 49) == 1) { PlaySoundpos(onSound, GetSurfaceCenter(switch0), 1.0, -1, 50.0, 0); setwallcel(switch0, 1); dummy = PlaySoundThing(alarm, soundpos, 1.0, -1, 100.0, 0x1); jkPrintUniString(-1, 2015); Sleep(2.0); jkPrintUniString(-1, 2016); Playsoundlocal(dialogue, 1, 0, 0x0); Sleep(GetSoundLen(dialogue)); sectoradjoins(doorsector, 1); call open_doors; } else { PlaySoundThing(locksound, door0, 1.0, -1, -1, 0); } } } else if (GetSenderId() == 2) { PlaySoundThing(locksound, door0, 1.0, -1, -1, 0); curtime = GetLevelTime(); if( (lasttime == -1) || (curtime - lasttime > 3) ) { PlaySoundlocal(access, 1.0, 0, 0x0); lasttime = curtime; } } return; # ........................................................................................ arrived: call checkstatus; if(movestatus) return; if(doorstatus == 1) { // all pieces are at frame 1 sleep(sleeptime); //============= Give me more time ======== sleep(sleeptime); sleep(sleeptime); sleep(sleeptime); sleep(sleeptime); //============= Give me more time ======== PlaySoundlocal(countdown, 1.0, 0, 0x0); sleep(GetSoundLen(countdown)); StopSound(dummy, 0); call close_doors; } else if(doorstatus == 0) { // all pieces are at frame 0 PlaySoundpos(onSound, GetSurfaceCenter(switch0), 1.0, -1, 50.0, 0); setwallcel(switch0, 0); sectoradjoins(doorsector, 0); } return; open_doors: movetoframe(door0, 1, movespeed); return; close_doors: movetoframe(door0, 0, movespeed); return; checkstatus: movestatus = ismoving(door0); doorstatus = getcurframe(door0); return; end