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 → How to do this...
How to do this...
2003-08-21, 11:08 AM #1
Hello all. I'm making a single-player level which is coming along great, but I'm in need of a fairly simple cog (I think). I've tried to make my own, but to no avail.

The cog needs to open two objects (doors), and then after going through the frames, they disappear. It also needs to play a sound, though I think I would just have to attach a SND file to the template to do that.

I'm sure you would just have to attach a DestroyThing message to the two doors, but I'm not sure. Any help would be appreciated.

------------------
"I'm afraid of OC'ing my video card. You never know when Ogre Calling can go terribly wrong."
2003-08-21, 12:36 PM #2
Code:
Message	Startup
Message	Activated
Message	Timer

Thing	Door0=-1
Thing	Door1=-1
Thing	Door2=-1
Thing	Door3=-1

flex	openspeed=2
flex	destroydelay=0

int	numdoors=-1	local
int	i		local

Startup:
	For(i=0; i<=3; i=i+1)
		if(Door0 > -1) NumDoors=NumDoors+1;
	for(i=0; i<=NumDoors; i=i+1;
		SetSectorAdjoins(GetThingSector(Door0));
	if(DestroyDelay < 0) DestroyDelay = 0;  // syntax checking.
	if(openSpeed < 0) OpenSpeed = 2;
	Return;

Activated:
	for(i=0; i<=NumDoors; i=i+1)
		MoveToFrame(Door01, openspeed);
	// Wait for doors to stop AFTER all doors have been told to move.
	for(i=0; i<=NumDoors; i=i+1)
		WaitForStop(Door0);
	if(DestroyDelay == 0)
		for(i=0; i<=NumDoors; i=i+1)
		DestroyThing(Door0);
	else SetTimer(DestroyDelay);
	Return;

Timer:
	for(i=0; i<=NumDoors; i=i+1)
	DestroyThing(Door0);
	Return;
This cog probably has more syntax checking systems than normal, but since I recently wiped out my computer, I can't run it through parsec or anything. I recommend doing that if it doesn't work, or perhaps beforehand. If these doors are rotational, you will need to learn about the rotatepivot command, unless you're unconcerned with the speed. However, note that rotational objects are not seen as moving by jk's engine. Don't know if that applies to you, but it's nice to know.

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

[Anoying posts] + 1.
Catloaf, meet mouseloaf.
My music
2003-08-21, 2:38 PM #3
Hmmm, didn't work at all. I put in all the right info, and the only syntax error I got in CogWriter was no symbols, which doesn't matter (right?).

If anyone needs to know, there is a puzzle in my level that you have to activate a boulder, falling down and hitting and breaking up the ground (the other door), making a new passage way. I'm trying to find puzzle cogs to make my level more interesting, but they're hard to come by.

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


[This message has been edited by Whelly (edited August 21, 2003).]
"I'm afraid of OC'ing my video card. You never know when Ogre Calling can go terribly wrong."
2003-08-21, 2:50 PM #4
And that cog really needed some parsing... [http://forums.massassi.net/html/redface.gif]

Here's a corrected version: [http://forums.massassi.net/html/wink.gif]
Code:
# open_doors.cog
#
# Open two doors and them remove them with a sound.
#
# [Dogsrool + SM]
#==============================================================#
symbols

message   startup
message   activated
message   timer

thing     door=-1
thing     door1=-1
thing     door2=-1
thing     door3=-1

flex      openSpeed=2
flex      destroyDelay=0

int       numDoors=-1      local
int       i                local

sound     removal

end
#==============================================================#
code
#------------------------------------------------------
startup:
	// find out how many doors we're working with.
	for(i = 0; i < 4 && door > -1; i = i + 1) numDoors = numDoors + 1;

	// go through all of our doors and turn their sectors' adjoins off.
	// this saves JK from trying to render through the door into sectors
	// you can't see.
	for(i = 0; i < numDoors; i = i + 1) SetSectorAdjoins(GetThingSector(door), 0);

Return;
#------------------------------------------------------
activated:
	// tell all of our doors to move to their second frame.
	for(i = 0; i < numDoors; i = i + 1)
	{
		// give the move command.
		MoveToFrame(door, 1, openSpeed);

		// since the door's sector's adjoin is off, we need
		// to turn it back on so you can see through.
		SetSectorAdjoins(GetThingSector(door), 0);
	}

	// wait for the last door to stop moving.
	WaitForStop(door);

	// because SetTimer(0) will kill a timer instead of setting it,
	// we'll use SetTimerEx() because timerEx's are killed with KillTimerEx().
	SetTimerEx(destroyDelay, 0, 0, 0);

Return;
#------------------------------------------------------
timer:
	// destroy all of our doors.
	for(i = 0; i < numDoors; i = i + 1)
	{
		// play the removal sound.
		PlaySoundThing(removal, door, 1, 10, 30, 0x100);

		// then remove the door.
		DestroyThing(door);
	}

Return;
#------------------------------------------------------
end


Perhaps the least noticeable error in the other cog was in the for loop. Always keep in mind that designated numbers start at 0 while counting numbers start at 1. NumDoors should always be one greater than the array index number needed to access the last door.

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2003-08-21, 2:58 PM #5
Quote:
<font face="Verdana, Arial" size="2">If anyone needs to know, there is a puzzle in my level that you have to activate a boulder, falling down and hitting and breaking up the ground (the other door), making a new passage way. I'm trying to find puzzle cogs to make my level more interesting, but they're hard to come by.</font>


Why the hell didn't you tell us that in the first place? [http://forums.massassi.net/html/mad.gif]

The cog does what it was written to do, it opens two doors, plays a sound and then destroys them. But it won't work very well for what you just now told us it's supposed to do....

[This message has been edited by SaberMaster (edited August 21, 2003).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2003-08-21, 3:31 PM #6
Thanks a lot, this'll work. Sorry I didn't bring it up, didn't think it was revelant (don't hit me SaberMaster! I'm sorry!). I'm pretty sure I can get this to work. Thanks again.

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


[This message has been edited by Whelly (edited August 21, 2003).]
"I'm afraid of OC'ing my video card. You never know when Ogre Calling can go terribly wrong."
2003-08-21, 5:24 PM #7
Works great, though HOM got so out of hand I just erased the SetAdjoin messages. I'm very happy how it turned out. Thanks for the help SaberMaster and DogSRoOl [http://forums.massassi.net/html/smile.gif] ! I'll post some screens of my level on Showcase later.

------------------
"I'm afraid of OC'ing my video card. You never know when Ogre Calling can go terribly wrong."
2003-08-21, 8:57 PM #8
No, I'm not going to hit anybody... [http://forums.massassi.net/html/redface.gif]

If you've got it working, then great. [http://forums.massassi.net/html/wink.gif] The reason I was mad before is because I took the time to perfect a cog only to realize that it was not working at all like it could.

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2003-08-22, 3:41 AM #9

Don't you just hate it when that happens... [http://forums.massassi.net/html/wink.gif] lol

(I'm so glad I waited ... I saw this post pop up, but it was late at night and I thought it would be best to write a cog when I was feeling *awake* ... Now being awake, I come here and find the topic has moved through several stages lol)

-Jackpot

PS: Never thought I'd see SaberMaster lose his rag [http://forums.massassi.net/html/wink.gif] - I've seen everything now... lol [http://forums.massassi.net/html/biggrin.gif]

------------------
Are you feeling lucky, cuz if you are, get your hands off me... ;)

"Life is mostly froth and bubble,
But two things stand in stone,
Kindness in another's trouble,
Courage in your own"
("Ye Wearie Wayfarer" - by Adam Lindsay Gordon)
"lucky_jackpot is the smily god..." -gothicX
"Life is mostly froth and bubble, but two things stand in stone,
Kindness in another's trouble, courage in your own"
- "Ye Wearie Wayfarer"
|| AI Builder: compatible with both JK & MotS || My website ||
2003-08-22, 4:11 PM #10
I'm the only person to have made SaberMaster mad? Dang, that was my first post here... [http://forums.massassi.net/html/smile.gif]

I like the cog forum, becuase people like lucky_jackpot and SaberMaster are kind to everybody and will help anybody out. Not like, *ahem*, other forums, where criticism turns into personal attacks. Here's to the coggers! [http://forums.massassi.net/html/biggrin.gif]

------------------
"I'm afraid of OC'ing my video card. You never know when Ogre Calling can go terribly wrong."
2003-08-27, 9:38 AM #11
Hi there [http://forums.massassi.net/html/smile.gif]

Sorry this is a late post - as I mentioned in another post, I'm on the verge of running out of free hours with my ISP for this month, so I'm cuting down (or trying to... [http://forums.massassi.net/html/wink.gif] --- roll on next month [http://forums.massassi.net/html/smile.gif] )

As I noticed you said that this was your first post here, I Just wanted to say "Welcome [http://forums.massassi.net/html/smile.gif]" to the Cog forum - feel free to come on in and join us coggers any time [http://forums.massassi.net/html/biggrin.gif]

-Jackpot

------------------
Are you feeling lucky, cuz if you are, get your hands off me... ;)

"Life is mostly froth and bubble,
But two things stand in stone,
Kindness in another's trouble,
Courage in your own"
("Ye Wearie Wayfarer" - by Adam Lindsay Gordon)
"lucky_jackpot is the smily god..." -gothicX
"Life is mostly froth and bubble, but two things stand in stone,
Kindness in another's trouble, courage in your own"
- "Ye Wearie Wayfarer"
|| AI Builder: compatible with both JK & MotS || My website ||

↑ Up to the top!