PDA

View Full Version : Airlock door COG problem



Emon
02-08-2001, 03:09 PM
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

Sylvicolus
02-08-2001, 04:19 PM
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

Emon
02-08-2001, 04:27 PM
I wasn't sure either. But it doesn't matter, I'm just going to use Nebula's great COG from Deep.

Emon
02-08-2001, 06:05 PM
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!