Posted by Brightblade on October 27, 1998 at 18:36:01:
In Reply to: Camera and Door Cog posted by matt on October 27, 1998 at 16:48:00:
: I have another cog question. What I want this cog to do is open a door and go to an external camera view at a specified ghost point from hitting one console. The point being to press the console that opens a door in another room, and then the camera shows you what you've done. The camera part works fine but I can't get the door to work. It's strange because the door worked one time but after it started to open it disappeared and the doorway started HOMming. Is it possible to put 2 different actions like this in one cog and have them activated by only one console? Thanks. Here's the cog:
: symbols
: thing console desc=console
: thing camera0 desc=camera_ghost
: thing door0
:
: flex delay=1.5 desc=delay
: flex movespeed=8.0
: flex sleeptime=2.0
: flex lightvalue=0.5
:
: int doorsector local
: int numdoors=0 local
: int doorstatus=0 local
: int movestatus=0 local
: int garbage=-1 local
: int dummy=0 local
:
: int old_camera local
: int player local
: int active=0 local
:
: sound onSound=set_hi2.wav local
: sound offSound=lgclick1.wav local
: sound locksound=df_door2-3.wav local
: message startup
: message arrived
: message blocked
: message activated
: message timer
: end
: # ========================================================================================
: code
: startup:
: if(door0 >= 0) numdoors = numdoors + 1;
: if(door1 >= 0) numdoors = numdoors + 1;
: if(door2 >= 0) numdoors = numdoors + 1;
: if(door3 >= 0) numdoors = numdoors + 1;
: doorsector = GetThingSector(door0);
: SectorAdjoins(doorsector, 0);
: SectorLight(doorsector, lightvalue, 0.0);
: return;
: # ........................................................................................
: activated:
: if(active) Return;
: active = 1;
:
: if (GetSenderId() == 1)
: {
: dummy=PlaySoundLocal(locksound, 1, 0, 0);
: }
: else if (GetSenderId() == 2)
: {
: call checkstatus;
: if (movestatus) return;
: if (doorstatus == 0)
: {
: garbage = PlaySoundThing(onSound, door0, 0.6, -1, -1, 0);
: garbage = setwallcel(console, 1);
: if (console >= 0) garbage = setwallcel(console, 1);
: sectoradjoins(doorsector, 1);
: call open_doors;
: }
: }
: player = GetSourceRef();
: if(player == GetLocalPlayerThing())
:
: SetActorFlags(player, 0xa00000);
: old_camera = GetCurrentCamera();
: SetCurrentCamera(0);
: SetCameraFocus(0, camera0);
:
: Sleep(delay);
:
: SetTimer(delay);
: Return;
: timer:
: ClearActorFlags(player, 0xa00000);
: SetCameraFocus(0, player);
: SetCurrentCamera(old_camera);
: active = 0;
: Return;
:
: # ........................................................................................
: arrived:
: call checkstatus;
: if(movestatus) return;
: if(doorstatus == numdoors)
: {
: sleep(sleeptime);
: call close_doors;
: }
: else if(doorstatus == 0)
: {
: garbage = PlaySoundThing(offSound, door0, 0.6, -1, -1, 0);
: garbage = setwallcel(console, 0);
: if(console >= 0) garbage = setwallcel(console, 0);
: sectoradjoins(doorsector, 0);
: }
: return;
: # ........................................................................................
: blocked:
: call open_doors;
: return;
: # ........................................................................................
: open_doors:
: movetoframe(door0, 1, movespeed);
: if (door1 >= 0) movetoframe(door1, 1, movespeed);
: if (door2 >= 0) movetoframe(door2, 1, movespeed);
: if (door3 >= 0) movetoframe(door3, 1, movespeed);
: return;
: close_doors:
: movetoframe(door0, 0, movespeed);
: if (door1 >= 0) movetoframe(door1, 0, movespeed);
: if (door2 >= 0) movetoframe(door2, 0, movespeed);
: if (door3 >= 0) movetoframe(door3, 0, movespeed);
: return;
: checkstatus:
: movestatus = ismoving(door0);
: if (door1 >= 0) movestatus = movestatus + ismoving(door1);
: if (door2 >= 0) movestatus = movestatus + ismoving(door2);
: if (door3 >= 0) movestatus = movestatus + ismoving(door3);
: doorstatus = getcurframe(door0);
: if (door1 >= 0) doorstatus = doorstatus + getcurframe(door1);
: if (door2 >= 0) doorstatus = doorstatus + getcurframe(door2);
: if (door3 >= 0) doorstatus = doorstatus + getcurframe(door3);
: return;
:
: end