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 → Here's a doozy of a request...
Here's a doozy of a request...
2005-02-20, 1:11 PM #1
Alright, this may be a lot for one cog, and if so, I don't care if it is broken down into a few cogs. Alright here's what I need a cog to do.

- When a surface is activated, two sectors get a light value of 1.
- Once seven surfaces are activated, a thing moves from one frame to the next and stays at the second frame until not all of the surfaces are activated.
- Once all seven surfaces are activated and the thing moves to the second frame, a non-local sound is played through-out the entire level.
- The surface, sector, thing, and sound values will be given through JED.
- All of these actions made by the cog should be non-local.

This is all for now. Many thanks to the person who can get this working. Credit will also be given.
Who made you God to say "I'll take your life from you"?
2005-02-20, 2:43 PM #2
Hi!
What you describe seems easy enough and I believe it can be done in one COG.

Code:
# Light Puzzle
#
# By Edward
symbols

message    startup
message    activated
message    pulse

sector     rooma0
sector     roomb0
sector     rooma1
sector     roomb1
sector     rooma2
sector     roomb2
sector     rooma3
sector     roomb3
sector     rooma4
sector     roomb4
sector     rooma5
sector     roomb5
sector     rooma6
sector     roomb6
flex       seclight
surface    lightswitch
sound      lighton
sound      lightoff

surface    movecombo0
surface    movecombo1
surface    movecombo2
surface    movecombo3
surface    movecombo4
surface    movecombo5
surface    movecombo6
sound      moveon
sound      moveoff
thing      object
flex       speed
sound      moving

int        i		local

end
#
code
startup:
        MoveToFrame(object,0,100);
        for(i=0; i<7; i=i+1)
        {
            SetSectorLight(rooma0,0,1);
            SetSectorLight(roomb0,0,1);
        }
        SetPulse(0.1);
return;
activated:
          for(i=0; i<7; i=i+1)
          {
              if(GetSenderRef()==movecombo0)
              {
                  If(GetWallCel(movecombo0)==0)
                  {
                      SetWallCel(movecombo0,1);
                      PlaySoundPos(moveon, GetSurfaceCenter(movecombo0), 1, -1, -1, 0x0);
                      SetSectorLight(rooma0,1,1);
                      SetSectorLight(roomb0,1,1);
                  }
                  else
                  {
                      SetWallCel(movecombo0,0);
                      PlaySoundPos(moveoff, GetSurfaceCenter(movecombo0), 1, -1, -1, 0x0);
                      SetSectorLight(rooma0,0,1);
                      SetSectorLight(roomb0,0,1);
                  }                  
              }
          }
return;
pulse:
      if(GetWallCel(movecombo0)==1 && GetWallCel(movecombo1)==1 && GetWallCel(movecombo2)==1 && GetWallCel(movecombo3)==1 && GetWallCel(movecombo4)==1 && GetWallCel(movecombo5)==1 && GetWallCel(movecombo6)==1)
      {
          if(GetCurFrame(object)==0 && !(IsMoving(object)))
          {
              MoveToFrame(object,1,speed);
              PlaySoundGlobal(moving,1,0,0x0);
          }
      }
      else
      {
          if(GetCurFrame(object)==1 && !(IsMoving(object)))
          {
              MoveToFrame(object,0,speed);
              PlaySoundGlobal(moving,1,0,0x0);
          }
      }
return;
end


OK, there it is... Might work, might not, I don't know... Haven't tested, and it is late at night...

/Edward
And darn the forums for making a line-break at the most unatural places for a COG. Maybe I should just link a whole page next time someone asks for a COG.
Edward's Cognative Hazards
2005-02-20, 3:26 PM #3
sorry, I should have been more clear in describing it. Once one of the seven surfaces are activated, 2 sectors should get a light value of 1. And for every surface activated, there are 2 sectors whose light values change. So there are 7 surfaces that are to be activated, and 14 sectors that should have a change in light value. It should all be non-local so everyone experiences the change in light, moving of thing, and sound playing. And once all surfaces are activated, then the thing moves to its second frame. Sorry for any confusion.
Who made you God to say "I'll take your life from you"?
2005-02-20, 3:31 PM #4
Actually, you just need to put spaces in there, after commas for example... then massassi won't break up the code (unless you have an uber-long symbol name or something crazy like that)

Oh, and while cleaning it up, I parsed it and a typo in the symbols -- 'movon' and 'movoff' should have been 'moveon' and 'moveoff'. It's been fixed above. well now that there's been an update I guess I don't need to repost your cog eh? ;)

Unless Edward speaks up, I'll prolly just let him handle this one.
May the mass times acceleration be with you.
2005-02-21, 8:15 AM #5
OK. Here's the newer version!

Code:
[DisplayPage] http://edward.leuf.org/x/LIGHTPUZ.HTM [/DisplayPage]
Edward's Cognative Hazards
2005-02-21, 8:23 AM #6
Hate to say it Edward, but I can't copy and paste that to notepad. It's giving me different character text values when I do.
Who made you God to say "I'll take your life from you"?
2005-02-21, 7:12 PM #7
Alright, as far as I can tell, the cog works as far as playing sounds when surfaces are activated, but the change of lighting in the sectors doesn't seem to be working correctly. In the "seclight (flex)" field, I put 1 because I want the sectors to have a light value of 1 when the corresponding surface is activated. For the "lightswitch (surface)" field, I left it at -1, because I'm not quite sure what this is for. Two sectors' light values should change to 1 when their corresponding surface is activated. Not all 14 sectors' light values should change to 1 once one surface (lightswitch) is activated. This may or may not be why the lighting isn't working correctly. Thanks for your effort though. I appreciate your work.
Who made you God to say "I'll take your life from you"?
2005-02-22, 12:04 PM #8
OK. lightswitch I forgot to remove for the newer version. You can remove that. As for the sectors, I don't know what the problem is... If there are no solutions, we can always use either Surface Light or Thing Light.

/Edward
Edward's Cognative Hazards
2005-02-22, 3:39 PM #9
Surface light would have the same desired effect, so that's something that can be done.
Who made you God to say "I'll take your life from you"?
2005-02-24, 12:37 PM #10
So, can someone change the cog so it changes the surface light instead of sector light?
Who made you God to say "I'll take your life from you"?
2005-02-25, 11:28 AM #11
Someone? Anyone? This cog is the foundation for my level! It has to be done!
Who made you God to say "I'll take your life from you"?
2005-02-25, 3:24 PM #12
hmm... guess I'll take a crack at it.
Code:
# Jedi Knight Cog Script
# 
# SM_Trige's light puzzle
#
# [darthslaw]
# 
# This Cog is Not supported by LucasArts Entertainment Co

symbols
int		active_switches=0		local

int		surf				local

int		active0=0			local
int		active1=0			local
int		active2=0			local
int		active3=0			local
int		active4=0			local
int		active5=0			local
int		active6=0			local

surface		switch0				linkid=0
surface		switch1				linkid=1
surface		switch2				linkid=2
surface		switch3				linkid=3
surface		switch4				linkid=4
surface		switch5				linkid=5
surface		switch6				linkid=6

#linked to switch0
sector		sec0
sector		sec1
#linked to switch1
sector		sec2
sector		sec3
#linked to switch2
sector		sec4
sector		sec5
#linked to switch3
sector		sec6
sector		sec7
#linked to switch4
sector		sec8
sector		sec9
#linked to switch5
sector		sec10
sector		sec11
#linked to switch6
sector		sec12
sector		sec13
#lit when any switch is activated
sector		sector0
sector		sector1

thing		object=-1
flex		obj_speed=1.0

sound		sound0

message		activated

end


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

code
activated:
	if(GetSenderRef() == object) return;
	surf = GetSenderID();
	active0[surf] = 1 - active0[surf];
	SetWallCel(switch0[surf], active0[surf]);
	if(active0[surf])			//turned on
	{
		active_switches = active_switches + 1;
		//turn on sector lights
		SetSectorLight(sec0[surf * 2], 1, 0.0);
		SetSectorLight(sec0[surf * 2 + 1], 1, 0.0);
	}
	else
	{
		active_switches = active_switches - 1;
		//turn off sector lights
		SetSectorLight(sec0[surf * 2], 0, 0.0);
		SetSectorLight(sec0[surf * 2 + 1], 0, 0.0);
	}

	if(active_switches > 0)
	{
		SetSectorLight(sector0, 1, 0.0);
		SetSectorLight(sector1, 1, 0.0);
	}

	if(active_switches == 7)
	{
		if(GetCurFrame(object) != 1)
		{
			MoveToFrame(object, 1, obj_speed);
			PlaySoundGlobal(sound0, 1.0, 0.0, 0x0);
		}
	}
	else
	{
		if(GetCurFrame(object) != 0)
		{
			MoveToFrame(object, 0, obj_speed);
		}
	}

stop;
# ........................................................................................

end


haven't tested it, so it might have some kinks to work out.
May the mass times acceleration be with you.
2005-02-25, 8:36 PM #13
Slaw, your cog doesn't seem to be working either. If Evad will let you, try to change his so that the surface's light value is set to 0 (or fully lit) when the switch is activated. That seemed to be the only problem with his that I could see. But I'm grateful for your attempt all the same.
Who made you God to say "I'll take your life from you"?
2005-02-25, 10:02 PM #14
Wait, what exactly is wrong with it? I just tested and it works fine for me... aside from some very minor bugs -- for example, light in sectors 'sector0' and 'sector1' is not set back to 0 when no switches are activated, small things like that, but the cog is working according to about 98% your request, if I understand it correctly.

-'sector0' and 'sector1' are set to light=1 when at least one switch is activated, and should be set to light=0 when no switches are active.
-'sec0' and 'sec1' are set to light=1 when 'switch1' is activated, 'sec2' and 'sec3' when 'switch2' is activated, etc; the light is set to 0 again when the sectors' corresponding switch is deactivated
-play a sound and move object to frame 1 when all switches are active; move the object back to frame 0 when not all switches are active.

Did I miss something, because that's exactly what the cog will do. If I got it right, all I can say is to check your variable inputs.

You know what, maybe that stupid line of equal signs is screwing up the cog... see how the forums broke that line (highlighted red in my last post) and continued it on the next line? Delete that whole red bit from your copy and see if it works then.
May the mass times acceleration be with you.
2005-02-25, 11:40 PM #15
I'll try that. And I don't want the sectors to be completly dark when the switches aren't activated. Maybe have the light set to .2 instead of 0.
Who made you God to say "I'll take your life from you"?
2005-02-25, 11:50 PM #16
Alright, the cog is working now. It must've been the line of equals signs. But, if you could change it so the sectors go from fully lit to .2 once the switches have been deactivated, that'd be great. Also, maybe add an option to play sounds when the switches are activated/deactivated. So far, so good!
Who made you God to say "I'll take your life from you"?
2005-02-26, 10:46 AM #17
Ok then, I think I got everything this time.
Also, you can now select light values and switch sounds in Jed's cog window. :)

Code:
# Jedi Knight Cog Script
# 
# SM_Trige's light puzzle
#
# [darthslaw]
# 
# This Cog is Not supported by LucasArts Entertainment Co

symbols
int		active_switches=0		local

int		surf				local

int		active0=0			local
int		active1=0			local
int		active2=0			local
int		active3=0			local
int		active4=0			local
int		active5=0			local
int		active6=0			local

surface		switch0				linkid=0
surface		switch1				linkid=1
surface		switch2				linkid=2
surface		switch3				linkid=3
surface		switch4				linkid=4
surface		switch5				linkid=5
surface		switch6				linkid=6

#linked to switch0
sector		sec0
sector		sec1
#linked to switch1
sector		sec2
sector		sec3
#linked to switch2
sector		sec4
sector		sec5
#linked to switch3
sector		sec6
sector		sec7
#linked to switch4
sector		sec8
sector		sec9
#linked to switch5
sector		sec10
sector		sec11
#linked to switch6
sector		sec12
sector		sec13
#lit when any switch is activated
sector		sector0
sector		sector1

flex		sec_light0=0.2			#sector light when switch is deactivated
flex		sec_light1=1.0			#sector light when switch is activated

thing		object=-1
flex		obj_speed=1.0

sound		sound0				#when object moves to frame 1, play this sound

sound		switch_snd0=deactivate04.wav	#deactivated switch
sound		switch_snd1=activate04.wav	#activated switch
sound		switch_snd2=lgclick1.wav	#click -- when object is still in motion

message		activated

end


code
activated:
	if(GetSenderRef() == object) return;
	surf = GetSenderID();

	if(IsMoving(object))			//no tampering if object is moving to a frame
	{
		PlaySoundPos(switch_snd2, SurfaceCenter(switch0[surf]), 1.0, -1, -1, 0x0);
		Return;
	}

	active0[surf] = 1 - active0[surf];
	SetWallCel(switch0[surf], active0[surf]);
	PlaySoundPos(switch_snd0[active0[surf]], SurfaceCenter(switch0[surf]), 1.0, -1, -1, 0x0);

	if(active0[surf])			//turned on
	{
		active_switches = active_switches + 1;
		//turn on sector lights
		SetSectorLight(sec0[surf * 2], sec_light1, 0.0);
		SetSectorLight(sec0[surf * 2 + 1], sec_light1, 0.0);
	}
	else
	{
		active_switches = active_switches - 1;
		//turn off sector lights
		SetSectorLight(sec0[surf * 2], sec_light0, 0.0);
		SetSectorLight(sec0[surf * 2 + 1], sec_light0, 0.0);
	}

	if(active_switches > 0)
	{
		SetSectorLight(sector0, sec_light1, 0.0);
		SetSectorLight(sector1, sec_light1, 0.0);
	}
	else
	{
		SetSectorLight(sector0, sec_light0, 0.0);
		SetSectorLight(sector1, sec_light0, 0.0);
	}

	if(active_switches == 7)
	{
		if(GetCurFrame(object) != 1)
		{
			MoveToFrame(object, 1, obj_speed);
			PlaySoundGlobal(sound0, 1.0, 0.0, 0x0);
		}
	}
	else
	{
		if(GetCurFrame(object) != 0)
		{
			MoveToFrame(object, 0, obj_speed);
		}
	}

stop;
# ........................................................................................

end
May the mass times acceleration be with you.

↑ Up to the top!