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 → Extra Light Cog
Extra Light Cog
2006-04-17, 12:35 PM #1
Sorry, another small cog request. :o

Would someone please make a cog that continuously cycles the extra light of a surface between a specified intensity and a higher or lower intensity. For example, a light panel has initial light of 0.5 upon startup and continuously cycles between 1.0 and back to 0.5 throughout the game.

This is for multiplayer, and should be the global animation of a PARTICULAR mat, NOT a surface. This will save me having to go through each surface by hand. A flex rate for me to fiddle around with would be nice as well. So, in summary:

  • A Box for mat name
  • A box for min surface light intensity
  • A box for max surface light intensity
  • A box for the flex (duration)
  • Multi-Player


Thanks!
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2006-04-17, 11:52 PM #2
Hmmm, so you wan't all those surfaces with the same mat blink synchronously?
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2006-04-18, 8:13 AM #3
Originally posted by zagibu:
Hmmm, so you wan't all those surfaces with the same mat blink synchronously?

Yes, that is correct.
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2006-04-18, 12:03 PM #4
Hope this works - I've not tested it.

matname, minlight, maxlight and duration are all as you requested. The "transitiontime" variable can be used to make a smooth transition between the two light values (set it to 1, for example, to make the light smoothly change over 1 second). I've set it at 0 by default (instant light change).

Oh, and it's local, so it won't create any network traffic in MP.

Code:
# Jedi Knight Cog Script
#
# allsurfacelightanim.COG
#
# Local cog to do a light anim between two values on all surfaces with a specific material
# 
# 18/04/06 - Chris Swan
#
# This Cog is Not supported by LucasArts Entertainment Co

# Local
flags=0x240

symbols                                                         

message	startup
message	timer
material	matname
flex		minlight=0.5
flex		maxlight=1
flex		duration=1
flex		transitiontime=0
int		surfcount		local
int		matsurfcount=0		local
int		heappointer=0		local
int		whichlight=0		local
surface	thissurf		local

end                                                                           

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

code

startup:

// Give the level some time to start up
sleep(1);

surfcount = GetSurfaceCount();

for(i = 0; i < surfcount; i = i + 1)
{
	if (GetSurfaceMat(i) == matname)
	{
		matsurfcount = matsurfcount + 1;
	}

	HeapNew(matsurfcount);

	for (i = 0; i < surfcount; i = i + 1)
	{
		if (GetSurfaceMat(i) == matname)
		{
			HeapSet(heappointer, i);
			heappointer = heappointer + 1;
		}
	}
}

SetTimer(duration);

return;


timer:

for (i = 0; i < matsurfcount; i = i + 1)
{
	thissurf = HeapGet(i);

	if (whichlight == 0)
	{
		SetSurfaceLight(thissurf, maxlight, transitiontime);
	}
	else
	{
		SetSurfaceLight(thissurf, minlight, transitiontime);
	}
}

if (whichlight == 0)
{
	whichlight = 1;
}
else
{
	whichlight = 0;
}

SetTimer(duration);

return;

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

end
2006-04-18, 2:31 PM #5
Thanks, I'll try it out!
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2006-04-18, 2:56 PM #6
Hmm, it doesn't seem to work. Does it matter what the individual surface's EXTRA LIGHT value is set to, or does the cog overlook that? Because even if the cog doesn't overlook that, I set one of my surfaces to 0 light while all those around it were 1 surface light, applied the cog, and no transitions in light intensity were made. Do you know what's going on? :confused:
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2006-04-18, 4:34 PM #7
Ah, could be because I didn't define "i" in the symbols. Try this:

Code:
# Jedi Knight Cog Script
#
# allsurfacelightanim.COG
#
# Local cog to do a light anim between two values on all surfaces with a specific material
# 
# 18/04/06 - Chris Swan
#
# This Cog is Not supported by LucasArts Entertainment Co

# Local
flags=0x240

symbols                                                         

message	startup
message	timer
material	matname
flex		minlight=0.5
flex		maxlight=1
flex		duration=1
flex		transitiontime=0
int		surfcount		local
int             i                             local
int		matsurfcount=0		local
int		heappointer=0		local
int		whichlight=0		local
surface	thissurf		local

end                                                                           

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

code

startup:

// Give the level some time to start up
sleep(1);

surfcount = GetSurfaceCount();

for(i = 0; i < surfcount; i = i + 1)
{
	if (GetSurfaceMat(i) == matname)
	{
		matsurfcount = matsurfcount + 1;
	}

	HeapNew(matsurfcount);

	for (i = 0; i < surfcount; i = i + 1)
	{
		if (GetSurfaceMat(i) == matname)
		{
			HeapSet(heappointer, i);
			heappointer = heappointer + 1;
		}
	}
}

SetTimer(duration);

return;


timer:

for (i = 0; i < matsurfcount; i = i + 1)
{
	thissurf = HeapGet(i);

	if (whichlight == 0)
	{
		SetSurfaceLight(thissurf, maxlight, transitiontime);
	}
	else
	{
		SetSurfaceLight(thissurf, minlight, transitiontime);
	}
}

if (whichlight == 0)
{
	whichlight = 1;
}
else
{
	whichlight = 0;
}

SetTimer(duration);

return;

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

end
2006-04-18, 4:49 PM #8
No, it's still not doing anything, either in SP or MP. I wonder if I'm doing something wrong?
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2006-04-19, 9:43 AM #9
Tested it now - there were a few silly bugs and a for loop bracket in the wrong place. It worked in a test level so it should be OK now.

Code:
# Jedi Knight Cog Script
#
# allsurfacelightanim.COG
#
# Local cog to do a light anim between two values on all surfaces with a specific material
# 
# 18/04/06 - Chris Swan
#
# This Cog is Not supported by LucasArts Entertainment Co

# Local
flags=0x240

symbols                                                         

message	startup
message	timer
material	matname
flex		minlight=0.5
flex		maxlight=1
flex		duration=1
flex		transitiontime=0
int		surfcount		local
int		i			local
surface	thissurf		local
material	thismat		local
int		matsurfcount=0	local
int		heappointer=0		local
int		whichlight=0		local


end                                                                           

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

code

startup:

// Give the level some time to start up
sleep(1);

// Transition of 0 still causes smooth animation, so change 0 to 0.001
if (transitiontime == 0)
{
	transitiontime = 0.001;
}

surfcount = GetSurfaceCount();

for(i = 0; i < surfcount; i = i + 1)
{
	thissurf = i;
	thismat = GetSurfaceMat(thissurf);

	if (thismat == matname)
	{
		matsurfcount = matsurfcount + 1;
	}
}
	
HeapNew(matsurfcount);

for (i = 0; i < surfcount; i = i + 1)
{

	thissurf = i;
	thismat = GetSurfaceMat(thissurf);

	if (thismat == matname)
	{
		HeapSet(heappointer, i);
		heappointer = heappointer + 1;
	}
}

SetTimer(duration);

return;


timer:

for (i = 0; i < matsurfcount; i = i + 1)
{
	thissurf = HeapGet(i);

	if (whichlight == 0)
	{
		SetSurfaceLight(thissurf, maxlight, 0);
	}
	else
	{
		SetSurfaceLight(thissurf, minlight, 0);
	}
}

if (whichlight == 0)
{
	whichlight = 1;
}
else
{
	whichlight = 0;
}

SetTimer(duration);

return;

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

end

↑ Up to the top!