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 → cog needed
cog needed
2003-06-15, 9:31 AM #1
I need a cog that will open a door when activated unless a player hits a surface then the door will be "Locked" and remains locked till a player hits the switch again.

------------------
I and only I know what I'm thinking.
<SalvadorChicka> i wasn't all "omg canadians have sex with each other!"
2003-06-15, 12:04 PM #2
By "Hits a surface" do you mean activates a switch, or damages it with a weapon?

------------------
"The Just shall live by faith." - Galatians 3:11
To edit is human... To COG is divine!!
Catloaf, meet mouseloaf.
My music
2003-06-16, 7:46 AM #3
activates a surface

------------------
I and only I know what I'm thinking.
<SalvadorChicka> i wasn't all "omg canadians have sex with each other!"
2003-06-16, 8:51 AM #4
I'll see what I can do. [http://forums.massassi.net/html/biggrin.gif]

------------------
"The Just shall live by faith." - Galatians 3:11
To edit is human... To COG is divine!!

pegasus_1984: Stop bushing that dang suck button.
guitarofgold: NOOOOOOOOO!!!!
Catloaf, meet mouseloaf.
My music
2003-06-16, 6:48 PM #5
Thank you, Anything that works would be greatly appreciated.

------------------
I and only I know what I'm thinking.
<SalvadorChicka> i wasn't all "omg canadians have sex with each other!"
2003-06-17, 8:14 AM #6
Code:
# Jedi Knight Cog Script
#
# 00_lockToggle.cog
#
# Toggles the lock on a door from either of 2 switches.
# Modified by Brandon Bull (aka DogSRoOL) from "00_door.cog"
#
# [IS]
#
# ========================================================================================

symbols
message      startup                                                          
message      activate                                                         
message      arrived                                                          
message      timer                                                            
message      blocked                                                          

surface      switch0                            linkid=4                      
surface      switch1                            linkid=4                      
thing        door0                              linkid=0                      mask=0x405
thing        door1                              linkid=1                      mask=0x405
thing        door2                              linkid=2                      mask=0x405
thing        door3                              linkid=3                      mask=0x405

float        moveSpeed=8.0                                                    
float        sleepTime=2.0                                                    
float        lightValue=0.5                                                   

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

sound        locksound=df_door2-3.wav                                         
end                                                                           

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

code

startup:
	for (i=0; i<=3; i=i+1)
		if (door0 >= 0) numDoors = numDoors + 1;

	doorSector = GetThingSector(door0);
	SetSectorAdjoins(doorSector, 0);
	SetSectorLight(doorSector, lightValue, 0.0);		// add some light to door sector
	return;

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

activated:
	if(GetSenderID() == 4)
	{
		locked = 1 - locked;	// produces 0 or 1, depending on current value.
		Return;
	}
	else
	{
		if(locked)
		{
			PlaySoundThing(GetSenderRef(), locksound, 1, -1, -1, 0x80);
			Return;
		}
		else
		{
			call CheckStatus;
			if (moveStatus) return;
			if (doorStatus == 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:
	for (i=0; i<=3; i=i+1)
		if (door0 >= 0) MoveToFrame(door0, 1, moveSpeed);
	return;

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

CloseDoors:
	for (i=0; i<=3; i=i+1)
		if (door0 >= 0) MoveToFrame(door0, 0, moveSpeed);
	return;

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

CheckStatus:
	moveStatus = 0;
	doorStatus = 0;

	for (i=0; i<=3; i=i+1)
	{
		if (door0 >= 0)
		{
			moveStatus = moveStatus + IsThingMoving(door0);
			doorStatus = doorStatus + GetCurFrame(door0);
		}
	}
	return;

end

I admit that I didn't actually test this, but as far as I know, it should work.

[edit: modified the cog]
[edit2: removed some unneccesary {} ]
------------------
"The Just shall live by faith." - Galatians 3:11
To edit is human... To COG is divine!!

pegasus_1984: Stop bushing that dang suck button.
guitarofgold: NOOOOOOOOO!!!!

[This message has been edited by DogSRoOL (edited June 17, 2003).]
Catloaf, meet mouseloaf.
My music
2003-06-17, 8:56 AM #7
Your use of tabs brings a tear of joy to my eye. [http://forums.massassi.net/html/smile.gif]

------------------
Bassoon, n. A brazen instrument into which a fool blows out his brains.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2003-06-17, 9:20 AM #8
I must do it that way, for it is the law of Cog.

"So it is written...
So it shall be done."
[/ramblings]

Oops, I see a tab I missed! *GASP* Why, LEC?!

------------------
"The Just shall live by faith." - Galatians 3:11
To edit is human... To COG is divine!!

pegasus_1984: Stop bushing that dang suck button.
guitarofgold: NOOOOOOOOO!!!!
-------[end post]-------
Catloaf, meet mouseloaf.
My music

↑ Up to the top!