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 → Cargo lift cog
Cargo lift cog
2004-04-10, 12:21 PM #1
Simple cargo lift cog I wrote, as the cogs in the JK game itself are too complicated to be used in general situations. I figured I'd post it here just in case anyone wants to use it. Just remember to give me credit.

Creates cargo crates (or whatever other objects you might want to use) at a ghost position at user defined intervals, sends the crates to the frame 1 of that ghost position, and destroys them. Also plays a sound that accompanies the crates. Can be used as either a vertical cargo lift, or in conjunction with a cog that scrolls textures as a conveyor belt transporting crates horizontally.

Code:
# Jedi Knight Cog Script
#
# DS_cargolift.cog
#
# Cog that controls a simple cargo lift.  Crates are created at a ghost point at
# a user defined time interval, sent to frame 1 of the ghost point at a user defined 
# speed, and then destroyed.  The ghost object used must have two frames, frame 0 being
# the same as the ghost objects position, and frame 1 being the target that the crates
# are sent too.
#
# [DSettahr]
#
# (C) 2004 by DSettahr.  You may use or modify this cog as you like as long as you
# provide credit to me.

symbols

	message		startup
	message		pulse
	message		arrived
	thing 		start
	template	cratetemplate=crate4_6
	flex		interval=15.0
	flex		speed=2.0
	thing		crate					local
	sound		liftsnd=00ConveyorAmb02.wav 		local
	int		curFrame				local
	int 		soundchannel0=-1			local

end

code

startup:

	//Set the pulse rate from the user defined interval
	SetPulse( interval );

	return;

pulse:

	//Create the crate at the ghost object
	crate = CreateThing( cratetemplate, start );
	CaptureThing( crate );

	//Play the lift sound
	soundchannel0 = PlaySoundThing( liftsnd, crate, 2, -1, -1, 0x81 );

	//Send the crate on its path to frame 1
	MoveToFrame( crate, 1, speed );

	return;

arrived:

	//Get the frame of the crate
	curFrame = GetCurFrame( GetSenderRef() );

	if ( curFrame == 1 ) {

		//Destroy the crate
		DestroyThing( GetSenderRef() );

	}

	return;

end


------------------
And everything under the sun is in tune, but the sun is eclipsed by the moon...
DSettahr's Homepage | Cantina Cloud | Rally NY

[This message has been edited by DSettahr (edited April 13, 2004).]
2004-04-10, 6:28 PM #2
Wow, super. This looks like it might be exactly what I'm looking for in one of my upcoming single player level ideas. Tell me, can it handle numerous different templates variations (say 5 - 10 kinds) that can be generated at multiple ghost positions and move towards different ghost endpoints, at which point they are destroyed (I hope that made a fraction of sense)?

Edit: What I think I'm trying to say is, is it a good cog for controlling many individual sets of conveying objects (i.e. about 20), or would I need to use the same cog 20 times. Because that gets quite annnoying and time consuming, not mention it gets your cog wondow thouroughly cluttered. Not trying to complain or anything sounds terrific, I was just wondering what the cog's limitations were! [http://forums.massassi.net/html/smile.gif] )

------------------
~ Vader's Corner ~ The place to submit your poetical works!

[This message has been edited by Daft_Vader (edited April 10, 2004).]
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2004-04-10, 6:39 PM #3
You would need to use this same cog 20 times. It could be modified to support multiple lifts with just one cog, but in the long run, you'd be better off just using the same cog over and over again. That way, if something doesnt work, it'd be a lot easier to track down the problem.

And yeah, the cog window can get cluttered. My singleplayer level that I am working on right now already has quite a few placed cogs. Door cogs alone make up the majority.

------------------
And everything under the sun is in tune, but the sun is eclipsed by the moon...
DSettahr's Homepage | Cantina Cloud | Rally NY
2004-04-10, 7:30 PM #4
Quote:
<font face="Verdana, Arial" size="2">
..Door cogs alone make up the majority...

</font>


Agreed.




------------------
~ Vader's Corner ~ The place to submit your poetical works!
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2004-04-11, 1:47 AM #5
Quote:
<font face="Verdana, Arial" size="2">Originally posted by DSettahr:
...Door cogs alone make up the majority.</font>


Ya know, I wrote a cog a number of years ago that could handle *every* door in a level, with only one instance, and you didnt have to define the doors.... If I can find it, or remember how it worked, Ill post it later.

------------------
I used to believe that we must fight the future, lest change come without our consent. I was wrong. The truth is that we must embrace the future, for only with change can we remain the same.
And when the moment is right, I'm gonna fly a kite.
2004-04-11, 3:02 AM #6
GBK is t3h Cog King!!! [http://forums.massassi.net/html/biggrin.gif]

------------------
~ Vader's Corner ~ The place to submit your poetical works!
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2004-04-12, 8:40 AM #7
I couldnt find it, so I just re-wrote it.

http://12.220.246.6/src/gdc.cog


Its a cinch to install, just add it and add the '0x1000000' thing flag to every door that you want to it to operate.


This doesnt handle switches, only simple doors. But, the good news is, it can handle *ALL* the simple doors in your level.... [http://forums.massassi.net/html/wink.gif]

------------------
I used to believe that we must fight the future, lest change come without our consent. I was wrong. The truth is that we must embrace the future, for only with change can we remain the same.
And when the moment is right, I'm gonna fly a kite.
2004-04-12, 9:01 AM #8
*Saves both cogs to hd*
Cool. [http://forums.massassi.net/html/smile.gif]

------------------
Bond, Power, CA, The Force, Saber, IC, Epic, Oily Mexican Food, BG, /\ |> /\ /\/\, Sentences.
Now you know where I've been.
May the mass times acceleration be with you.
2004-04-12, 9:02 AM #9
There's a typo on line 32, GetSenderRed(), which should be GetSenderRef().
This CaptureThing() verb seems to be useful indeed.

------------------
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2004-04-12, 9:43 AM #10
Thanks, fixed.

------------------
I used to believe that we must fight the future, lest change come without our consent. I was wrong. The truth is that we must embrace the future, for only with change can we remain the same.
And when the moment is right, I'm gonna fly a kite.
2004-04-12, 1:12 PM #11
What's a simple door in compairison to a switch door? Are we talking doors that open when a player comes near? Or a door that opens when IT is pressed, or what?

JediKirby

------------------
"I was driving along listening to the radio, when Judas Priest comes on. It was 'You've got another thing coming.' All of a sudden, I enter 'VICE CITY RAMAGE MODE' and nearly ran some guy over"
- ]-[ellequin
ᵗʰᵉᵇˢᵍ๒ᵍᵐᵃᶥᶫ∙ᶜᵒᵐ
ᴸᶥᵛᵉ ᴼᵑ ᴬᵈᵃᵐ
2004-04-12, 3:15 PM #12
In the GDC cog, when the door is activated, the door opens.

I tried out both cogs -- nifty.

Dsettahr, there is one little issue with the cargo cog, though (well, not actually with the cog, but the problem probably lies in the ghost template). When you use smaller crates (like "crate4_2" for example), the crates end up created in the air (around 0.1 jku higher than I want) as opposed to on the conveyor belt. I changed the template back from "ghost" to "crate4_2" and the problem was fixed. Just thought you'd like to be aware of that.
(btw, I'm assuming the larger crates work; I haven't tried it w/larger ones for myself yet).
Also, in the symbols section, the symbol "soundchannel1" should be "soundchannel0", but the cog will work exactly the same either way.

Bottom line:
Both cogs = very cool. [http://forums.massassi.net/html/biggrin.gif]

------------------
Bond, Power, CA, The Force, Saber, IC, Epic, Oily Mexican Food, BG, /\ |> /\ /\/\, Sentences.
Now you know where I've been.
May the mass times acceleration be with you.
2004-04-12, 6:19 PM #13
Quote:
<font face="Verdana, Arial" size="2">Originally posted by jEDIkIRBY:
What's a simple door in compairison to a switch door? Are we talking doors that open when a player comes near? Or a door that opens when IT is pressed, or what?

JediKirby

</font>


Simple door: What most doors are. Normally closed, will open when directly activated. By directly, I mean the door itself...

Switch: Similar to simple doors, but operated by a switch on the wall. These types of doors normally cannot be operated directly, only by the switch.

Pad: *Very* similar to a simple door, but operated by a surface on the floor, which, when stepped on, opens the door. Very useful for small faced-paced MP levels..

Cutscene / environment doors: THese are the doors which cannot be operated by the player. They are activated when certain goals are reached, sectors are entered, etc...


The GDC could easily be modified to do other stuff, like locked doors, etc, but I wont do that unless theres a demand for it.

------------------
I used to believe that we must fight the future, lest change come without our consent. I was wrong. The truth is that we must embrace the future, for only with change can we remain the same.
And when the moment is right, I'm gonna fly a kite.
2004-04-13, 2:50 AM #14
Quote:
<font face="Verdana, Arial" size="2">Originally posted by Darth Slaw:
In the GDC cog, when the door is activated, the door opens.

I tried out both cogs -- nifty.

Dsettahr, there is one little issue with the cargo cog, though (well, not actually with the cog, but the problem probably lies in the ghost template). When you use smaller crates (like "crate4_2" for example), the crates end up created in the air (around 0.1 jku higher than I want) as opposed to on the conveyor belt. I changed the template back from "ghost" to "crate4_2" and the problem was fixed. Just thought you'd like to be aware of that.
(btw, I'm assuming the larger crates work; I haven't tried it w/larger ones for myself yet).
Also, in the symbols section, the symbol "soundchannel1" should be "soundchannel0", but the cog will work exactly the same either way.

Bottom line:
Both cogs = very cool. [http://forums.massassi.net/html/biggrin.gif]

</font>


The way I wrote the cog, you can use any thing object you want as the position where the crates are generated. Also, I think at one point there were 2 sound channels, but I got rid of one of them. No big deal, though - the cog actually doesnt even need sound channels, I had original though that I would have to manually stop the sound when the crate is destroyed, but I have found that is not true. When a sound is flagged to follow an object, it will automaticaly stop playing when that object is destroyed.

------------------
And everything under the sun is in tune, but the sun is eclipsed by the moon...
DSettahr's Homepage | Cantina Cloud | Rally NY

[This message has been edited by DSettahr (edited April 13, 2004).]

[This message has been edited by DSettahr (edited April 13, 2004).]
2004-04-13, 5:14 AM #15
I'd really appreciate if you could do some floor panels and button press doors, as I rarelly use direct doors in my levels. I also wonder if a similar cog could be written for elivators with 2 through 6 frames (I end up with quite a few frames due to different levels of the buildings the lift has to stop at)? I have no idea how difficult this would be, but I know I'd be highly appreciative.

JediKirby

------------------
"I was driving along listening to the radio, when Judas Priest comes on. It was 'You've got another thing coming.' All of a sudden, I enter 'VICE CITY RAMAGE MODE' and nearly ran some guy over"
- ]-[ellequin
ᵗʰᵉᵇˢᵍ๒ᵍᵐᵃᶥᶫ∙ᶜᵒᵐ
ᴸᶥᵛᵉ ᴼᵑ ᴬᵈᵃᵐ
2004-04-13, 6:21 AM #16
Sure, the GDC could handle simple elevators, with a bit of modification.. Switched and pad doors, on the other hand, are right out. Its not impossible, its just useless. You might just as well use regular cogs for those.

------------------
I used to believe that we must fight the future, lest change come without our consent. I was wrong. The truth is that we must embrace the future, for only with change can we remain the same.
And when the moment is right, I'm gonna fly a kite.

↑ Up to the top!