Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Airlock door COG problem
Airlock door COG problem
2001-02-08, 12:09 PM #1
I've got a problem with my airlock door COG for my level. I modified the normal door COG to make it so when one door is open, another won't open. I want it so when the 2nd door is open, the 1st wont open till the 2nd is shut, and vise versa. I'm using the same COG on both doors, and it checks the opposite to see if it is open, and if it is, exits. But it doesn't work. Instead when you activate one, they both open and never shut. Someone please tell me what's wrong with it, or where to get a working airlock COG (not the C3 CTF ones!)

Here it is:

--------------

# Jedi Knight Cog Script
#
# 00_Door.cog
#
# Generic Door Script
#
# [IS] - Modified by EJM_Emon to be used as an airlock door COG in the EJM_Temple.
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
# ========================================================================================

symbols

message activate
message arrived
message timer
message blocked

thing door0 linkid=0 mask=0x405
thing doorLock

float moveSpeed=8.0
float sleepTime=2.0

sector doorSector local
int numDoors=0 local
int doorStatus local
int moveStatus local
int i local
int door2Status local

end

# ========================================================================================

code

activate:
call CheckStatus;
if (moveStatus) return;
if (doorStatus == 0)
{ // all pieces are at frame 0
SetSectorAdjoins(doorSector, 1);
call OpenDoors;
}
return;

# ........................................................................................

arrived:
call CheckStatus;
if (moveStatus) return;
if (doorStatus == numDoors) { // all pieces are at frame 1
SetTimer(sleepTime);
} else if (doorStatus == 0) { // all pieces are at frame 0
SetSectorAdjoins(doorSector, 0);
}
return;

# ........................................................................................

blocked:
call OpenDoors;
return;

# ........................................................................................

timer:
call CloseDoors;
return;

# ........................................................................................

OpenDoors:
call CheckDoor2;
if (door2Status != 0) return;


MoveToFrame(door0, 1, moveSpeed);

return;

# ........................................................................................

CloseDoors:
MoveToFrame(door0, 0, moveSpeed);
return;

# ........................................................................................

CheckStatus:
moveStatus = 0;
doorStatus = 0;


moveStatus = moveStatus + IsThingMoving(door0);
doorStatus = doorStatus + GetCurFrame(door0);

return;


# ........................................................................................

CheckDoor2:
door2Status = 0;
door2Status = door2Status + GetCurFrame(doorLock);
Return;

end
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-02-08, 1:19 PM #2
Hi Emon,
I assume that the cog you posted is used for door0 and you use a variation of this cog tailored for the other door thing called doorlock.

I think the doors don't close because the arrived code section calls SetTimer(sleepTime); only if (doorStatus == numDoors)
The problem is that I don't see any place in the code that would change the numDoors variable value from the initial value of 0 to the needed value of 1.
Since you are only dealing with moving one door per cog you can delete the numdoors reference from the Symbols section and change the if statement to:
if (doorStatus == 1) { // door0 is at frame 1

I can't figure out why both doors open when you only activate one?


------------------
If I have ever made any valuable discoveries, it has been owing more to
patient observation than to any other reason. -Isaac Newton
Sylvicolus JK homepage
If I have ever made any valuable discoveries, it has been owing more to
patient observation than to any other reason. -Isaac Newton
2001-02-08, 1:27 PM #3
I wasn't sure either. But it doesn't matter, I'm just going to use Nebula's great COG from Deep.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-02-08, 3:05 PM #4
Turns out I gotta use this COG.

I made that change, it helps somewhat.

I changed GetCurFrame to IsThingMoving, and that fixes them both opening at the same time. But now I can only open the 2nd when the first is in frame 1. Someone help, plz!
Bassoon, n. A brazen instrument into which a fool blows out his brains.

↑ Up to the top!