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 → is this cog possible
12
is this cog possible
2002-08-22, 12:47 AM #1
ok here's what i was wondering

is there any way to these elements together with a cog to make a really cool effect by using a cog to control them

elements:
1.blinding sun cog
2.rain/snow cog
3.sky textures/night and day

ok for the control part i mean a cog that can move the blinding sun(ghost im sure) along a path to appear to be change time of day, now depending in the sun(ghost) postion have the sky textures fade or blend creating the illusion of the time of day,with the rain and snow have it randomly rain or snow or nothing but sunshine , with the time of day have it so the level maker can decide
what amount of time equals 24 hours

example: every 2hours real time = 24 hours game time
so the speed of the sun(ghost) should be determined by what the real time varaible is


so can this be done?

2002-08-22, 2:58 AM #2
Yes, I did it myself a while back:

[ INSERT NEEDLESSLY BIG COG HERE ]

I don't think that the rain was implemented in this one, but it can easily be added.

[This message has been edited by Lord_Grismath (edited August 22, 2002).]
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-08-22, 3:00 AM #3
And SaberMaster is going to kill me about the whole arrays issue any minute now, but I cogged that before I was entirely aware of array manipulation.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-08-22, 5:00 AM #4
I bet SaberMaster is typig up a response right now. But your right Grismath. You should rewrite the cog befor SaberMaster does. [http://forums.massassi.net/html/wink.gif]

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-08-22, 8:41 AM #5
OH MY HOLY GOD!! USE ARRAYS!!! [http://forums.massassi.net/html/eek.gif]

------------------
I used to believe that we only want what we can't have. I was wrong. The truth is, the wonderful truth is, we only want what we think we can't have.

JK editing resources.
And when the moment is right, I'm gonna fly a kite.
2002-08-22, 12:25 PM #6
I have seen many desperate cogs, but that one... [http://forums.massassi.net/html/eek.gif] And you posted that?

That cog uses way too many variables to work - more than it appears because its thing arrays aren't defined.

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-08-22, 1:06 PM #7
JF, I'll see what I can do for the weather system. [http://forums.massassi.net/html/wink.gif]

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-08-22, 2:39 PM #8
Ok, SM, do what you wish for a weather system, I'm re-writing version 2 of skytime as I write this.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-08-22, 3:51 PM #9
I give you version 2! Please ask if you'd like to use this. It sends messages to a dispatcher cog which then does dynamic stuff based on the time of day. The dispatcher must be programmed to be custom to a level.

[ This was version 2 ]

[This message has been edited by Lord_Grismath (edited August 23, 2002).]
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-08-22, 4:41 PM #10
My eyes, I can see agian. Its soo much better Grismath. I've ran across 1 problem, I wrote a cog to change a 'skybox' materials, you know surface flag 0x200, but it didn't work, so I deleted it, there might have been a problem within the cog's coding, but I wouldn't bet on it. It was very simple.

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-08-22, 4:48 PM #11
sabermaster:
for your help on the wheather
thank you [http://forums.massassi.net/html/smile.gif]


Lord_Grismath:

thank you for posting the skymaster cog
i would like to use it

are you still working on the dispatcher cog ?
2002-08-23, 12:39 AM #12
You're free to use it, just give me credit in the readme.

As for the dispatcher cog, I guess I'll write something up as to a general format for writing one, but it needs to be tailored to your level.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-08-23, 12:55 AM #13
what information do you need to know for it to be tailored to my level?

2002-08-23, 12:59 AM #14
Well I was hoping you'd write it yourself, but I can make an example dispatcher sometime soon.

I give you version 2.1! (fixing a few potential errors)

Code:
# skymaster.cog
# v. 2.1
#  This cog allows you to define up to twenty sky surfaces which change dynamically
# on a user-defined interval, simulating the passing of a day.  This cog should also
# be coupled with a user-designed dispatcher cog which can then implement other changes
# throughout the level based on the time of day.
#
# [Grismath]
#======================================================================================#
symbols
message		startup
message		pulse
flex		timeint				// Duration of each time period (pulse length)
int		period=1	local		// Current time period (dawn, day, etc.)
material	dawn
material	day
material	late
material	dusk
material	night
surface		sky0
surface		sky1
surface		sky2
surface		sky3
surface		sky4
surface		sky5
surface		sky6
surface		sky7
surface		sky8
surface		sky9
surface		sky10
surface		sky11
surface		sky12
surface		sky13
surface		sky14
surface		sky15
surface		sky16
surface		sky17
surface		sky18
surface		sky19
int		defined				// Number of defined surfaces
int		X=0		local
cog		dispatcher			// Level-custom dispatching cog
end
#======================================================================================#
code
#--------------------------------------------------------
startup:
 Sleep(0.5);
 SetPulse(timeint);
return;
#--------------------------------------------------------
pulse:
for(X=0; X<defined; X=X+1) {
 if(period==1) {
  SetSurfaceMat(sky0[X], dawn);
 }
 if(period==2) {
  SetSurfaceMat(sky0[X], day);
 }
 if(period==3) {
  SetSurfaceMat(sky0[X], late);
 }
 if(period==4) {
  SetSurfaceMat(sky0[X], dusk);
 }
 if(period==5) {
  SetSurfaceMat(sky0[X], night);
 }}
if(period==1) SendMessage(dispatcher, user1);
if(period==2) SendMessage(dispatcher, user2);
if(period==3) SendMessage(dispatcher, user3);
if(period==4) SendMessage(dispatcher, user4);
if(period==5) SendMessage(dispatcher, user5);
if(period==5) period=0;
period=period+1;
return;
#--------------------------------------------------------
end
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-08-23, 1:03 AM #15
Oooh, and as an added bonus: SkyUniversal.cog, as per DP's suggestion.

Code:
# skyuniversal.cog
# v. 1.0
#  This cog dynamically changes every surface flagged as 'sky' (0x200) in the level
# on a user-defined interval, simulating the passing of a day.  This cog should also
# be coupled with a user-designed dispatcher cog which can then implement other changes
# throughout the level based on the time of day.
#
# [Grismath]
#======================================================================================#
symbols
message		startup
message		pulse
flex		timeint				// Duration of each time period (pulse length)
int		period=1	local		// Current time period (dawn, day, etc.)
material	dawn
material	day
material	late
material	dusk
material	night
int		X=0		local
cog		dispatcher			// Level-custom dispatching cog
end
#======================================================================================#
code
#--------------------------------------------------------
startup: 
Sleep(0.5); 
SetPulse(timeint);
return;
#--------------------------------------------------------
pulse:
for(X=0; X<=GetSurfaceCount(); X=X+1) {
 if(Getthingflags(X) == 0x200) {
 if(period==1) {
  SetSurfaceMat(X, dawn);
 }
 if(period==2) {
  SetSurfaceMat(X, day);
 }
 if(period==3) {
  SetSurfaceMat(X, late);
 }
 if(period==4) {
  SetSurfaceMat(X, dusk);
 }
 if(period==5) {
  SetSurfaceMat(X, night);
 }}}
if(period==1) SendMessage(dispatcher, user1);
if(period==2) SendMessage(dispatcher, user2);
if(period==3) SendMessage(dispatcher, user3);
if(period==4) SendMessage(dispatcher, user4);
if(period==5) SendMessage(dispatcher, user5);
if(period==5) period=0;
period=period+1;
return;
#--------------------------------------------------------
end


If you'd like to use this one ask, and it's the same policy as that for SkyMaster.cog.

[This message has been edited by Lord_Grismath (edited August 23, 2002).]
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-08-23, 2:25 AM #16
HEre's an example dispatcher cog which give marching orders to the rest of the cogs that control dynamic aspects of your level.

Code:
# dispatcher0.cog
# 8.23.02
#  This is merely an example dispatcher cog, displaying how one can utilise
# input from the SkyMaster/Universal cogs.
#
# [Grismath]
#======================================================================================#
symbols
message		user1
message		user2
message		user3
message		user4
message		user5
cog		weather
cog		shops
cog		people
cog		lights
int		debug=0
end
#======================================================================================#
code
#--------------------------------------------------------
user1:
if(debug==1) print("It is dawn.");
SendMessage(weather, user1);
SendMessage(shops, user1);
SendMessage(people, user1);
SendMessage(lights, user1);
return;
#--------------------------------------------------------
user2:
if(debug==1) print("The day has begun.");
SendMessage(weather, user2);
SendMessage(shops, user2);
SendMessage(people, user2);
SendMessage(lights, user2);
return;
#--------------------------------------------------------
user3:
if(debug==1) print("The day continues.");
SendMessage(weather, user3);
SendMessage(shops, user3);
SendMessage(people, user3);
SendMessage(lights, user3);
return;
#--------------------------------------------------------
user4:
if(debug==1) print("Dusk settles.");
SendMessage(weather, user4);
SendMessage(shops, user4);
SendMessage(people, user4);
SendMessage(lights, user4);
return;
#--------------------------------------------------------
user5:
if(debug==1) print("It is night.");
SendMessage(weather, user5);
SendMessage(shops, user5);
SendMessage(people, user5);
SendMessage(lights, user5);
return;
#--------------------------------------------------------
end
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-08-23, 2:26 AM #17
Here's a weather cog that goes with the dispatcher, however as for the rest you'll have to make them yourself to fit your level.

Code:
# weather.cog
# 8.23.02
#   Randomly creates weather effects which last for the duration of a time period.
#
# [Grismath]
#======================================================================================#
symbols
message		user1
message		user2
message		user3
message		user4
message		user5
message		pulse
flex		interval=0.25
flex		random			local
int		dummy			local
template	stream=+rain
int		X=0			local

thing		pos0
thing		pos1	
thing		pos2      
thing		pos3	
thing		pos4
thing		pos5	
thing		pos6	
thing		pos7
thing		pos8
thing		pos9
thing		pos10
thing		pos11
thing		pos12
thing		pos13
thing		pos14
thing		pos15
thing		pos16
thing		pos17
thing		pos18
thing		pos19
int		defined=0
end
#======================================================================================#
code
#--------------------------------------------------------
user1:
SetPulse(0);
random=rand();
if(random <= 0.25) SetPulse(interval);
return;
#--------------------------------------------------------
user2:
SetPulse(0);
random=rand();
if(random <= 0.25) SetPulse(interval);
return;
#--------------------------------------------------------
user3:
SetPulse(0);
random=rand();
if(random <= 0.25) SetPulse(interval);
return;
#--------------------------------------------------------
user4:
SetPulse(0);
random=rand();
if(random <= 0.25) SetPulse(interval);
return;
#--------------------------------------------------------
user5:
SetPulse(0);
random=rand();
if(random <= 0.25) SetPulse(interval);
return;
#--------------------------------------------------------
pulse:
for(X=0; X<defined; X=X+1) {
dummy=FireProjectile(pos0[X], stream, -1, -1, '0 0 0', '0 0 0', 1.0, 0x20, -1, -1);
}
return;
#--------------------------------------------------------
end
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-08-23, 3:29 AM #18
Quote:
<font face="Verdana, Arial" size="2">Originally posted by Lord_Grismath:
if(debug==1) print("It is dawn.");</font>



His corruption is complete.

------------------
I used to believe that we only want what we can't have. I was wrong. The truth is, the wonderful truth is, we only want what we think we can't have.

JK editing resources.
And when the moment is right, I'm gonna fly a kite.
2002-08-23, 6:43 AM #19
Eh? Please elaborate.

And look who's talking, you Stop; anarchist!
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-08-23, 7:23 AM #20
That function is nearly identical to those I use in the tvtcs... 'Cept for the fact that I use 'JKstringconcatasciistring()', and you use 'Print()'...


Me? Anarchist? Naa, a phreaker if anything... [http://forums.massassi.net/html/biggrin.gif]

------------------
I used to believe that we only want what we can't have. I was wrong. The truth is, the wonderful truth is, we only want what we think we can't have.

JK editing resources.
And when the moment is right, I'm gonna fly a kite.
2002-08-23, 7:41 AM #21
Errr... it was merely an unconscious addition... *shiftyeyes*
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-08-23, 8:25 AM #22
Suure...

------------------
I used to believe that we only want what we can't have. I was wrong. The truth is, the wonderful truth is, we only want what we think we can't have.

JK editing resources.
And when the moment is right, I'm gonna fly a kite.
2002-08-23, 11:11 AM #23
SaberMaster helped me make a blinding sun cog a while ago, check for it in the downloads here.
I'm just an old man with a skooma problem.
2002-08-23, 11:13 AM #24
That, however, is apparently JK only.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-08-23, 11:27 AM #25
Any cog that works for JK will work for MotS, except for ones with RotatePivot().

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-08-23, 4:45 PM #26
This thread has had a lot of attention. [http://forums.massassi.net/html/smile.gif]

I've made a weather system consisting of four cogs: a control cog, a surface cog, a precipitation cog, and a sun cog. And they work well enough. I'll get some templates to go with them and post them tomorrow. I've been kind of busy lately... [http://forums.massassi.net/html/frown.gif]

BTW, is this for multiplayer?

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

[This message has been edited by SaberMaster (edited August 23, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-08-23, 5:12 PM #27
ill say it has to my surprise at that
but im gald to see there so much interest in this

Lord_Grismath

while i do plan to write my own cogs, right now im still trying to master jed and while ive become pretty good , ive only had this game for about 2 months, so that i would say makes me a noob ,the good new is i do have some background in programming, the bad news is it was using the language basic when i was in junior high(that was like in 87)
2002-08-24, 2:37 AM #28
I'd be very interested to see your sun cog, but for the others, we should compare notes and combine them into one MEGA COG! [http://forums.massassi.net/html/eek.gif]
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-08-24, 9:01 AM #29
Combining the different cogs into one cog, would impose symbol limits on the cog, and
make it hard to work with. I prefer to make several smaller cogs which each have a specific
purpose (a concept known as encapsulation).

As it is, the control cog communicates with the other weather cogs with triggers. One
benifit of this is that you can duplicate the precipitation cog, for example, and have
two cogs respond to the same trigger.

The code for this weather system is below. And it's a bit long. [http://forums.massassi.net/html/smile.gif] The control cog:

Code:
# wthr_control.cog
#
# Server-only weather control cog. Do not copy this cog.
#
# Variables:
#
# dayHours
#	Input the time in hours of the length of your virtual day. This
#	is a flex time so use decimal numbers if you need to.
#
# numPrecips
#	Input the number of pecipitations (ex. rain, snow) that you
#	want to use. No more than four.
#
# precipChance0 - precipChance3
#	This is the chance for the precipitation to be created. A
#	chance of 1 means that the precipitation will always be
#	created; 0 means that it will never be created. You'll
#	want a low chance such as 0.1 or less.
#
# minPrecipDuration0 - minPrecipDuration3
#	This is the minimum time for each precipitation to last ingame.
#
# maxPrecipDuration0 - maxPrecipDuration3
#	This is the maximum time for each precipitation to last ingame.
#
# precipTrigger0 - precipTrigger3
#	Input the trigger ID that will be used to communicate to the precipitation's
#	cog. Although there is only on precipitation .cog file, you can duplicate
#	the cog in the level and give different symbol values to each. And so
#	each precipitation will have its own duplicate of the precip cog.
#
# surfTrigger
#	This is the trigger ID that will be used to communicate with the
#	surface cog.
#
# sunTrigger
#	This is the trigger ID that will be used to communicate with the
#	sun cog.
#
# [SM]
#===============================================#
symbols

message	startup
message	pulse
message	timer

flex		dayHours=0.7
flex		numPrecips
flex		daySecs			local
int		i				local
int		id				local

flex		precipChance0=0.1
flex		precipChance1=0.1
flex		precipChance2=0.1
flex		precipChance3=0.1

flex		precipTime0		local
flex		precipTime1		local
flex		precipTime2		local
flex		precipTime3		local

flex		minPrecipDuration0=15
flex		minPrecipDuration1=15
flex		minPrecipDuration2=15
flex		minPrecipDuration3=15

flex		maxPrecipDuration0=60
flex		maxPrecipDuration1=60
flex		maxPrecipDuration2=60
flex		maxPrecipDuration3=60

int		precipTrigger0=100
int		precipTrigger1=101
int		precipTrigger2=102
int		precipTrigger3=103

int		precipOn0=0	local
int		precipOn1=0	local
int		precipOn2=0	local
int		precipOn3=0	local

int		surfTrigger=104
int		sunTrigger=105

end
#===============================================#
code
#--------------------------------------------------------
startup:
	daySecs = dayHours * 3600;
	SetPulse(1);
	SendTrigger(-1, surfTrigger, daySecs, 0, 0, 0);
	SendTrigger(-1, sunTrigger, daySecs, 0, 0, 0);

Return;
#--------------------------------------------------------
pulse:
	// Don't do anything while a precipitation is in effect.
	if(precipOn0 || precipOn1 || precipOn2 || precipOn3) Return;

	for(i=0; i < numPrecips; i=i+1) if(precipChance0 > Rand())
	{
		// tell the precipitation cog to begin.
		SendTrigger(-1, precipTrigger0, 0, 0, 0, 0);
		precipOn0=1;
		precipTime0=Rand() * (maxPrecipDuration0 - minPrecipDuration0) + minPrecipDuration0;
		SetTimerEx(precipTime0, i, 0, 0);
		Return;
	}

Return;
#--------------------------------------------------------
timer:
	// stop the precipitation effect.
	id = GetSenderID();
	SendTrigger(-1, precipTrigger0[id], 0, 0, 0, 0);
	precipOn0[id]=0;

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


The surface cog:

Code:
# wthr_surface.cog
#
# Weather cog to change surfaces' materials
# during the length of the day. It will start upon
# receiving a trigger from the control cog.
#
# Variables:
#
# surf0 - surf19
#	Define the surfaces whose mat will be changed.
#
# mat0 - mat9
#	Define the materials to give to the surfaces in order of time.
#
# numMats
#	Input the number of mats that you defined.
#
# numSurfs
#	Input the number of surfaces that you defined.
#
# surfTrigger
#	Input the trigger ID that the surface cog and control should
#	communicate with.
#
# You may use copies of this cog in the level to define different
# numbers of materials and also to change more surfaces.
#
# [SM]
#===============================================#
flags=0x240
#===============================================#
symbols

message	trigger
message	pulse

surface	surf0=-1
surface	surf1=-1
surface	surf2=-1
surface	surf3=-1
surface	surf4=-1
surface	surf5=-1
surface	surf6=-1
surface	surf7=-1
surface	surf8=-1
surface	surf9=-1
surface	surf10=-1
surface	surf11=-1
surface	surf12=-1
surface	surf13=-1
surface	surf14=-1
surface	surf15=-1
surface	surf16=-1
surface	surf17=-1
surface	surf18=-1
surface	surf19=-1

material	mat0=dflt.mat
material	mat1=dflt.mat
material	mat2=dflt.mat
material	mat3=dflt.mat
material	mat4=dflt.mat
material	mat5=dflt.mat
material	mat6=dflt.mat
material	mat7=dflt.mat
material	mat8=dflt.mat
material	mat9=dflt.mat

int		numMats=0
int		numSurfs=0
int		surfTrigger=104
int		curMat=-1		local
int		i				local

flex		changeRate		local

end
#===============================================#
code
#--------------------------------------------------------
trigger:
	if(GetSourceRef() != surfTrigger) Return;
	changeRate=GetParam(0) / numMats;
	call pulse;
	SetPulse(changeRate);

Return;
#--------------------------------------------------------
pulse:
	curMat=curMat+1;
	if(curMat == numMats) curMat=0;
	for(i=0; i < numSurfs; i=i+1) SetSurfaceMat(surf0, mat0[curMat]);

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


The precipitation cog:

Code:
# wthr_precip.cog
#
# Weather cog to create precipitation at ghost locations. The precipitation
# effect is begun and ended by a trigger from the server.
#
# Variables
#
# precipTemp
#	This is the template that you will use for this precipitation
#
# ghost0 - ghost5
#	These are the ghost locations to create the individual precipitation
#	elements at. This cog only needs five ghosts because of the
#	semi-random creation of the elements. More than one element
#	will be created at a ghost during a burst.
#
# precipTrigger
#	This is the trigger ID that this precipitation will use to communicate with
#	the control cog.
#
# numBurstElements
#	Input the number of precipitation elements that you want to be created
#	during a precipitation burst.
#
# elementSpeedMult
#	This is a multiplier for a precipitation element's speed. So if you wanted
#	it to rain harder in a certain area, you would increase this number. But
#	for normal precipitation, leave this at 1.
#
# burstInterval
#	Input the interval between precipitation bursts.
#
# xMove
#	Input the x axis velocity for an element. This can be used to simulate
#	wind blowing the rain to the side.
#
# yMove
#	Input the y axis velocity for an element.
#
# This cog is meant to be duplicated in the level to accomodate up to four
# precipitations. Each copy can be given its own trigger and have its own
# settings in the control cog. But if you wanted to have more than five ghosts
# for a precipitation, then you can have more than one precip cog respond
# to the same trigger.
#
# This cog can be used to simulate any precipitation. Whether it be rain, sleet,
# hail, snow, or even lightning.
#
# [SM]
#===============================================#
flags=0x240
#===============================================#
symbols

template	precipTemp

thing		ghost0
thing		ghost1
thing		ghost2
thing		ghost3
thing		ghost4
thing		ghost5

int		numGhosts		local
int		precipTrigger=100
int		numBurstElements=50
int		i				local
int		precipOn=0		local

thing		parent			local
thing		precip			local

flex		elementSpeedMult=1
flex		burstInterval=1
flex		xMove=0.2
flex		yMove=0.2

message	startup
message	trigger
message	pulse
message	timer

end
#===============================================#
code
#--------------------------------------------------------
startup:
	for(numGhosts=0; numGhosts < 20 && numGhosts != -1; numGhosts=numGhosts+1);

Return;
#--------------------------------------------------------
trigger:
	if(GetSourceRef() != precipTrigger) Return;
	if(!precipOn) SetPulse(burstInterval);
	else SetPulse(0);
	precipOn = 1 - precipOn;

Return;
#--------------------------------------------------------
pulse:
	for(i=0; i < numBurstElements; i=i+1) SetTimerEx(Rand(), Rand() * 6, 0, 0);

Return;
#--------------------------------------------------------
timer:
	if(GetSenderID() > 5) Return;	// for than 1 in 75,000 chance...
	parent = ghost0[GetSenderID()];
	precip=FireProjectile(parent, precipTemp, -1, -1, VectorSet(Rand(), 0, Rand()), '0 0 0', elementSpeedMult, 0x1, 0, 0);
	SetThingVel(precip, VectorSet(xMove, yMove, VectorZ(GetThingVel(precip))));

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


And the sun cog:

Code:
# wthr_sun.cog
#
# Weather cog for the sun. Do not copy this cog.
#
# Variables
#
# sun
#	This is a thing placed in the level that you will use as your sun.
#
# maxDayLight
#	This is the maximum light to be used at high noon.
#
# minDayLight
#	This is the minimum light to use during the day except at noon.
#
# nightLight
#	This is the amount of light to use at night when the sun will not
#	be visible.
#
# sunTrigger
#	This is the trigger ID that will be used to communicate with the control
#	cog.
#
# numFrames
#	This is the number of frame positions that you will use. Note that the
#	sun does not have to have real frames in the level.
#
# noLightChange
#	If you do not want the sun cog to change the lighting for day and night,
#	set this variable to 1. Otherwise, leave it at 0.
#
# noSunGlare
#	If you want to disable the sun's glare, set this to 1. Otherwise, leave it
#	at 0.
#
# framePos0 - framePos9
#	These vectors are the positions of virtual frames that will be used by the sun.
#	If you want, create frames in the level and copy their positions to use for these
#	variables. REMEMBER that the sun must not be path-controlled and need not
#	have any frames.
#
# sunRed
#	This is the amount of red color in the sun's glare.
#
# sunGreen
#	This is the amount of green color in the sun's glare.
#
# sunBlue
#	This is the amount of blue color in the sun's glare.
#
# The sun object that you use must move by physics so that it can have
# its velocity set by this cog. This cog will move the sun along the positions
# that you input so that it can rise and fall in the sky. Unfortuneately, a real
# frame system is not possible here as MoveToFrame() does not use a
# JKU per second speed. It seems to use something much slower. So the
# virtual frame system must be used.
#
# Noon will be when the sun is in the middle of its daylight journey. It will
# last for about a third of the day (not the total day mind you, just the daylight
# portion). When nearing noon, the sun's brightness will begin to increase.
# And at noon exactly, the sun will reach the maxDayLight. And afterwards
# the daylight will fade back to the minDayLight.
#
# [SM]
#===============================================#
flags=0x240
#===============================================#
symbols

thing		sun

flex		maxDayLight=1
flex		minDayLight=0.8
flex		nightLight=0.2

int		sunTrigger=105
int		numFrames

int		noLightChange=0
int		noSunGlare=0

vector	framePos0
vector	framePos1
vector	framePos2
vector	framePos3
vector	framePos4
vector	framePos5
vector	framePos6
vector	framePos7
vector	framePos8
vector	framePos9

int		sunRed=100
int		sunGreen=100
int		sunBlue=80

flex		dayLen		local
flex		moveRate	local
flex		moveSpeed	local
flex		dist			local
flex		traveltime=0	local
flex		dot			local
flex		starttime		local
flex		timeLeft		local
flex		noon		local
flex		curTime		local
flex		noonLen		local
flex		diff			local
flex		maxInputDiff	local
flex		maxOutputDiff	local

vector	moveVec		local

thing		player		local

int		framesLeft	local
int		night=0		local
int		frame=0		local
int		sunHandle=-1	local

message	trigger
message	pulse
message	timer

end
#===============================================#
code
#--------------------------------------------------------
trigger:
	if(GetSourceRef() != sunTrigger) Return;
	player = GetLocalPlayerThing();
	dayLen = GetParam(0) / 2;
	noonLen = dayLen / 3;
	SetPulse(0.1);
	SetTimerEx(0, 1, 0, 0);

Return;
#--------------------------------------------------------
pulse:
	if(IsThingVisible(sun) && !noSunGlare) dot=ThingViewDot(player, sun);
	else dot=0;
	if(dot < 0) dot=0;

	FreeColorEffect(sunHandle);
	if(night && !noLightChange) sunHandle=NewColorEffect(player, 0, 0, 0, 0, 0, 0, 0, 0, nightLight);
	else if(!night && !noLightChange)
	{
		noon = dayLen / 2;
		curTime = GetFlexGameTime() - starttime;
		if(noon > curTime) diff=noon-curTime;
		else diff=curTime - noon;
		if(diff < noonLen / 2)
		{
			// reverse diff (max-0 to 0-max) and scale it from 0 to the difference between the light values (0.2 by default).
			maxInputDiff=noonLen / 2;
			maxOutputDiff=maxDayLight - minDayLight;
			diff = (maxInputDiff - diff) * (maxOutputDiff) / maxInputDiff;
			sunHandle=NewColorEffect(0, 0, 0, 0, 0, 0, sunRed*dot, sunGreen*dot, sunBlue*dot, minDayLight + diff);
		}
		else sunHandle=NewColorEffect(0, 0, 0, 0, 0, 0, sunRed*dot, sunGreen*dot, sunBlue*dot, minDayLight);
	}
	else if(!night && !noSunGlare) sunHandle=NewColorEffect(0, 0, 0, 0, 0, 0, sunRed*dot, sunGreen*dot, sunBlue*dot, 1);

Return;
#--------------------------------------------------------
timer:
	if(GetSenderID() == 1)
	{
		if(frame == numFrames - 1)
		{
			night=1;
			traveltime=0;
			starttime=GetFlexGameTime();
			SetThingCurGeoMode(sun, 0);
		}
		else if(frame == 0)
		{
			night=0;
			traveltime=0;
			starttime=GetFlexGameTime();
			SetThingCurGeoMode(sun, 4);
		}

		if(!night) frame=frame+1;
		else frame=frame-1;

		dist=VectorDist(GetThingPos(sun), framePos0[frame]);
		traveltime=GetFlexGameTime() - starttime;

		timeLeft = dayLen - traveltime;
		if(!night) framesLeft = numFrames - frame;
		else framesLeft = frame + 1;
		moveRate = timeLeft / framesLeft;

		moveSpeed=dist / moveRate;
		moveVec=VectorSub(framePos0[frame], GetThingPos(sun));
		SetThingLook(sun, moveVec);
		SetThingVel(sun, VectorScale(moveVec, moveSpeed));

		SetTimerEx(moveRate, 1, 0, 0);
	}

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


The sun, rain, and rain_exp templates:

Quote:
<font face="Verdana, Arial" size="2">
# DESC: World Sun
# BBOX: 0 0 0 0 0 0
sun none orient=(0/0/0) type=ghost move=physics sprite=sun.spr

# DESC: Rain Explosion
# BBOX: 0 0 0 0 0 0
+rain_exp none orient=(0/0/0) type=explosion timer=0.5 sprite=splash.spr typeflags=0x1

# DESC: Rain Precipitation
# BBOX: 0 0 0 0 0 0
rain none orient=(0/0/0) thingflags=0x8000000 type=weapon collide=1 move=physics size=0.001 movesize=0.001 sprite=rain.spr vel=(0/0/-1) explode=+rain_exp typeflags=0xc timer=3
</font>


For the templates, you'll have to provide a sun.spr and a rain.spr. For the sun, you
could use forcedstruct_150.spr temporarily, and for the rain sprite, there are a few rain
mods out there with sprites and mats - credit the authors, of course.

The header of each cog include full instructions on how to use it and what
symbol values to provide. If you need these cogs to work in MP, I'll add sync coding to
them for joining players. [http://forums.massassi.net/html/smile.gif]

Any questions / comments?

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

[This message has been edited by SaberMaster (edited August 24, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-08-24, 10:48 AM #30
[http://forums.massassi.net/html/eek.gif]

SM, you've blown me out of the water. Any chance that I could use those?
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-08-24, 11:39 AM #31
Sure, go ahead. [http://forums.massassi.net/html/wink.gif]

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-08-24, 5:38 PM #32
There good cogs and all, but why not use RotateThing() instead of frames? Rounder and easier to make in the level.

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-08-24, 5:45 PM #33
holy smokes,its the motherload of cogs

thanks sabermaster ,and if you dont mind id like to use them aswell
2002-08-25, 1:01 AM #34
Errr... I'm encountering some formatting problems, i.e. copying cogs from here and pasting into any other text utility, as it removes all of the line spacing and breaking. Could you e-mail the cogs to admin@gcwc.net
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-08-25, 5:38 AM #35
Alright, I emailed you both. [http://forums.massassi.net/html/wink.gif]

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

[This message has been edited by SaberMaster (edited August 25, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-08-25, 5:45 AM #36
Quote:
<font face="Verdana, Arial" size="2">but why not use RotateThing() instead of frames?</font>


I might have used it, had it existed. [http://forums.massassi.net/html/tongue.gif]

But if you meant RotatePivot(), that is frame movement. I had problems getting frame movement to work, so I had to create a system with SetThingVel() that corrects for JK's slight timing errors.

However, I would welcome any improvements. [http://forums.massassi.net/html/tongue.gif]

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-08-25, 5:54 AM #37
Thanks for the cogs, SM.

I'm considering mewthods on how to tackle perhaps implementing a feature in which rain only fires from certain ghosts in the player's view.

I'm making an adventure-type level, and thus have set cams, and this could be dependent on the cam, however I doubt that a single cog for all level cameras (which are currently independent cogs) merged with the weather cog would be feasible.

Secondly, as a bit of a side note, do we know what the maximum number of defined symbols is?
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-08-25, 5:58 AM #38
Whatever it is.

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-08-25, 5:59 AM #39
Huh?
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-08-25, 6:15 AM #40
Rotate(thing)Pivot();

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
12

↑ Up to the top!