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 → Hopefully this is easy... =\
Hopefully this is easy... =\
2004-10-17, 10:03 AM #1
Hi all,

I think this should be simple, but I can't figure it out myself... =\

I'd be very, very grateful if someone could provide me with (what I think will be a simple) cog script that does the following:

It should be Multiplayer compatible. So, the effects of the cog should be the same on all players' computers.

The player activates a switch (a surface), causing a number of (let's say 30?) surfaces to switch textures. This can be done up to 4 times, so there are 4 'sets' of textures.

I think there are two ways to do it (but I don't know how to code) :

1. The cog could cause the textures on all the surfaces to change to different textures. OR:
2. The cog could cause all the mats (which are in this case multi-celled mats) to switch to their next cell. In this case all the mats would have four cells.

I don't know which of these two methods is easier to do, because I really do not understand enough of the code to write it myself. And maybe there is even an easier method... Or maybe this cog exists already... I have no idea...

It should be easy, right? =)

Any help is welcome!

Thanks for having a look,

JoS
ORJ / My Level: ORJ Temple Tournament I
2004-10-17, 2:11 PM #2
SetSurfaceMat(surface, mat);

It's in the datamaster under the surface catagory. I used it several years ago before coming to massassi, and it did work.

Ah, found it. This isn't the code for your cog, but people here at massassi can dissect it to make your code (I have to go study french)
Code:
Symbols

Message Startup
Message Activated
Message Timer

thing    door			nolink

flex		wait1=0.5			// sleep before playing handprint animation
flex		wait2=0.07			// Sleep between scanning animations
flex		wait3=1.0			// sleep before playing final animation
flex		wait4=1.0			// sleep before opening door after final animation
flex		wait5=5.0			// sleep before closing door after it opens
flex		speed=1.0			// speed of door
sound		scan=forcefieldhum01.wav	// scaning sound

Surface	Switch		nolink	// just here to control activations, switch can not be activated
Surface	Floor			// the handprint scanner

Flex 		Time=.5
flex		wait6=0.3			// Sleep between button animations
sound		beep=beep2.wav	// scaning sound
sound		activate=activate02.wav	// scaning sound

Material	off=m_blue_printscan_1.mat		local			// the materials for the scanner
Material	scan1=m_blue_printscan_1a.mat		local
Material	scan2=m_blue_printscan_1b.mat		local
Material	scan3=m_blue_printscan_1c.mat		local
Material	scan4=m_blue_printscan_1d.mat		local
Material	scan5=m_blue_printscan_1e.mat		local
Material	scan6=m_blue_printscan_1f.mat		local
Material	scan7=m_blue_printscan_1g.mat		local
Material	scan8=m_blue_printscan_1h.mat		local
Material	scan9=m_blue_printscan_1i.mat		local
Material	scan10=m_blue_printscan_1j.mat		local
Material	scan11=m_blue_printscan_1k.mat		local
Material	scan12=m_blue_printscan_1l.mat		local
Material	scan13=m_blue_printscan_1m.mat		local
Material	scan14=m_blue_printscan_1n.mat		local
Material	scan15=m_blue_printscan_1o.mat		local
Material	scan16=m_blue_printscan_1p.mat		local
Material	scan17=m_blue_printscan_1q.mat		local
Material	scan18=m_blue_printscan_1r.mat		local
Material	scan19=m_blue_printscan_1s.mat		local
Material	scan20=m_blue_printscan_1t.mat		local
Material	scan21=m_blue_printscan_1u.mat		local
Material	scan22=m_blue_printscan_1v.mat		local
Material	scan23=m_blue_printscan_1w.mat		local
Material	scan24=m_blue_printscan_1x.mat		local
Material	scan25=m_blue_printscan_1y.mat		local
Material	scan26=m_blue_printscan_1z.mat		local
Material	scan27=m_blue_printscan_1za.mat		local
Material	scan28=m_blue_printscan_1zb.mat	local
Material	scan29=m_blue_printscan_1zc.mat	local
Material	scan30=m_blue_printscan_1zd.mat	local
Material	scan31=m_blue_printscan_1ze.mat	local
Material	scan32=m_blue_printscan_1zf.mat	local
Material	scan33=m_blue_printscan_1zg.mat	local
Material	scan34=m_blue_printscan_1zh.mat	local
Material	scan35=m_blue_printscan_1zi.mat	local
Material	scan36=m_blue_printscan_1zj.mat	local
Material	scan37=m_blue_printscan_1zk.mat	local
Material	scan38=m_blue_printscan_1zl.mat	local
Material	scan39=m_blue_printscan_1zm.mat	local
Material	scan40=m_blue_printscan_1zn.mat	local
Material	scan41=m_blue_printscan_1zo.mat	local
Material	scan42=m_blue_printscan_1zp.mat	local
Material	scan43=m_blue_printscan_1zq.mat	local
Material	scan44=m_blue_printscan_1zr.mat	local
Material	scan45=m_blue_printscan_1zs.mat	local
Material	scan46=m_blue_printscan_1zt.mat	local
Material	scan47=m_blue_printscan_1zu.mat	local
Material	scan48=m_red_printscan_1.mat	local
Material	button=m_blue_printscan_button_1.mat	local
Material	button1=m_blue_printscan_button_2.mat	local
Material	button2=m_blue_printscan_button_3.mat	local
Material	button3=m_blue_printscan_button_4.mat	local
Material	button4=m_blue_printscan_button_5.mat	local
End
Code

Startup:
Setwallcel(Switch, 0);
Stop;

Activated:								// If player presses button
If(Getwallcel(Switch) == 1) Stop;					// If button has already been pushed don't restart
Sleep(wait1);								// Wait time before playing handprint animation
Setwallcel(Switch, 1);						// This prevents the cog from being activated while active
Setsurfacemat(Floor, button);					// Animation start
PlaySoundPos(beep, SurfaceCenter(floor), 40, -1, 2, 0);	// Play beep sound
Sleep(wait6);								// Wait time between animations
Setsurfacemat(Floor, button1);
PlaySoundPos(beep, SurfaceCenter(floor), 40, -1, 2, 0);
Sleep(wait6);
Setsurfacemat(Floor, button2);
PlaySoundPos(beep, SurfaceCenter(floor), 40, -1, 2, 0);
Sleep(wait6);
Setsurfacemat(Floor, button3);
PlaySoundPos(beep, SurfaceCenter(floor), 40, -1, 2, 0);
Sleep(wait6);
Setsurfacemat(Floor, button4);
PlaySoundPos(activate, SurfaceCenter(floor), 40, -1, 2, 0);	// Play activate sound
Sleep(wait6);
PlaySoundPos(scan, SurfaceCenter(floor), 40, -1, 2, 0);	// Play scanning sound
Setsurfacemat(Floor, scan1);
Sleep(wait2);
Setsurfacemat(Floor, scan2);
Sleep(wait2);
Setsurfacemat(Floor, scan3);
Sleep(wait2);
Setsurfacemat(Floor, scan4);
Sleep(wait2);
Setsurfacemat(Floor, scan5);
Sleep(wait2);
Setsurfacemat(Floor, scan6);
Sleep(wait2);
Setsurfacemat(Floor, scan7);
Sleep(wait2);
Setsurfacemat(Floor, scan8);
Sleep(wait2);
Setsurfacemat(Floor, scan9);
Sleep(wait2);
Setsurfacemat(Floor, scan10);
Sleep(wait2);
Setsurfacemat(Floor, scan11);
Sleep(wait2);
Setsurfacemat(Floor, scan12);
Sleep(wait2);
Setsurfacemat(Floor, scan13);
Sleep(wait2);
Setsurfacemat(Floor, scan14);
Sleep(wait2);
Setsurfacemat(Floor, scan15);
Sleep(wait2);
Setsurfacemat(Floor, scan16);
Sleep(wait2);
Setsurfacemat(Floor, scan17);
Sleep(wait2);
Setsurfacemat(Floor, scan18);
Sleep(wait2);
Setsurfacemat(Floor, scan19);
Sleep(wait2);
Setsurfacemat(Floor, scan20);
Sleep(wait2);
Setsurfacemat(Floor, scan21);
Sleep(wait2);
Setsurfacemat(Floor, scan22);
Sleep(wait2);
Setsurfacemat(Floor, scan23);
Sleep(wait2);
Setsurfacemat(Floor, scan24);
Sleep(wait2);
Setsurfacemat(Floor, scan25);
Sleep(wait2);
Setsurfacemat(Floor, scan26);
Sleep(wait2);
Setsurfacemat(Floor, scan27);
Sleep(wait2);
Setsurfacemat(Floor, scan28);
Sleep(wait2);
Setsurfacemat(Floor, scan29);
Sleep(wait2);
Setsurfacemat(Floor, scan30);
Sleep(wait2);
Setsurfacemat(Floor, scan31);
Sleep(wait2);
Setsurfacemat(Floor, scan32);
Sleep(wait2);
Setsurfacemat(Floor, scan33);
Sleep(wait2);
Setsurfacemat(Floor, scan34);
Sleep(wait2);
Setsurfacemat(Floor, scan35);
Sleep(wait2);
Setsurfacemat(Floor, scan36);
Sleep(wait2);
Setsurfacemat(Floor, scan37);
Sleep(wait2);
Setsurfacemat(Floor, scan38);
Sleep(wait2);
Setsurfacemat(Floor, scan39);
Sleep(wait2);
Setsurfacemat(Floor, scan40);
Sleep(wait2);
Setsurfacemat(Floor, scan41);
Sleep(wait2);
Setsurfacemat(Floor, scan42);
Sleep(wait2);
Setsurfacemat(Floor, scan43);
Sleep(wait2);
Setsurfacemat(Floor, scan44);
Sleep(wait2);
Setsurfacemat(Floor, scan45);
Sleep(wait2);
Setsurfacemat(Floor, scan46);
Sleep(wait2);
Setsurfacemat(Floor, scan47);
Sleep(wait3);
Setsurfacemat(Floor, scan48);
Sleep(wait4);
MoveToFrame(door, 1, speed);	// Move door to second frame
Sleep(wait5);
MoveToFrame(door, 0, speed);	// Move door back to first frame
WaitForStop(door);
Settimer(Time);
Stop;

Timer:
Setwallcel(Switch, 0);		// Allow the cog to be activated again
Setsurfacemat(Floor, Off);		// set animation back to the first frame
Stop;

End

The cog cycles through many materials (in the level, it was a handprint scanner) then opens a door which closes after a delay.

[edit] forgot to mention, it does sync over multiplayer automatically. Also, don't make fun of my naming system, this was several years ago. [/edit]

[edit2] I just realized that GBK must have helped with this, since he is the only person that has helped me and uses the verb stop; so if you use this, give him some credit too [/edit2]
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2004-10-17, 5:30 PM #3
Allright, that's a start! :D It's pretty much Chinese to me, but I'm sure someone else can distill something out of this! Thanks!

Erm, I just thought of something. If there were only one 'switch', you'd have to 'cycle' through the sets of textures. Let's make it so that it has a switch for every set of textures. So you can 'choose sets' ...
ORJ / My Level: ORJ Temple Tournament I
2004-10-19, 4:04 PM #4
here is a cog that should do what you want.
i didnt test it but it should work, hopefully :o
Code:
#################################################
# Jedi Knight Cog Script	(JK\MotS)
#---------------------------------------------------------
# SURFACE_CHANGE01.COG
# -When one of the 4 switchs are activated up to 30
#  surfaces will change to the mat-cell that goes with
#  that switch and a sound that goes with the activated
#  switch will play in a loop.
#---------------------------------------------------------
# Written By DSLS_DeathSythe
# This COG is NOT supported by LucasArts Entertainment Co.
#################################################
flags=0x240
symbols
#---------------------------------------------------------
message     startup
message     activated
message     trigger
message     join
#--------------------#
int         act_trig=1

surface     switch01=-1
surface     switch02=-1
surface     switch03=-1
surface     switch04=-1

thing       sound_pos=-1
sound       loop_snd01
sound       loop_snd02
sound       loop_snd03
sound       loop_snd04
flex        sound_vol=1.0
flex        min_radius=-1.0
flex        max_radius=-1.0

surface     chngSurf01=-1
surface     chngSurf02=-1
surface     chngSurf03=-1
surface     chngSurf04=-1
surface     chngSurf05=-1
surface     chngSurf06=-1
surface     chngSurf07=-1
surface     chngSurf08=-1
surface     chngSurf09=-1
surface     chngSurf10=-1
surface     chngSurf11=-1
surface     chngSurf12=-1
surface     chngSurf13=-1
surface     chngSurf14=-1
surface     chngSurf15=-1
surface     chngSurf16=-1
surface     chngSurf17=-1
surface     chngSurf18=-1
surface     chngSurf19=-1
surface     chngSurf20=-1
surface     chngSurf21=-1
surface     chngSurf22=-1
surface     chngSurf23=-1
surface     chngSurf24=-1
surface     chngSurf25=-1
surface     chngSurf26=-1
surface     chngSurf27=-1
surface     chngSurf28=-1
surface     chngSurf29=-1
surface     chngSurf30=-1
#--------------------#
int         status=0                                      local
int         a=0                                           local
int         channel=-1                                    local
#---------------------------------------------------------
end
#================================================
code
#---------------------------------------------------------
startup:
	if(!IsServer()) return;
	status = 0;
	for(a=0; a<30; a=a+1)
		if(chngSurf01[a] != -1)
			SetSurfaceCel(chngSurf01[a], status);
	channel = PlaySoundThing(loop_snd01[status], sound_pos, sound_vol, min_radius, max_radius, 0x1);
return;
#---------------------------------------------------------
activated:
	if(GetSenderRef() == switch01) status = 0;
	else if(GetSenderRef() == switch02) status = 1;
	else if(GetSenderRef() == switch03) status = 2;
	else if(GetSenderRef() == switch04) status = 3;
	else return;
	SendTrigger(-1, act_trig, status, 0, 0, 0);
return;
#---------------------------------------------------------
trigger:
	if(GetSourceRef() != act_trig) return;
	status = GetParam(0);
	for(a=0; a<30; a=a+1)
		if(chngSurf01[a] != -1)
			SetSurfaceCel(chngSurf01[a], status);
	if(channel != -1)
		{
		StopSound(channel, 0.0);
		channel = -1;
		}
	channel = PlaySoundThing(loop_snd01[status], sound_pos, sound_vol, min_radius, max_radius, 0x1);
return;
#---------------------------------------------------------
join:
	if(!IsServer()) return;
	SendTrigger(-1, act_trig, status, 0, 0, 0);
return;
#---------------------------------------------------------
end
#################################################

[edit: fixed the cog]
[edit: made the sound changes you wanted]
Famous last words - "It seemed like a good idea at the time."
2004-10-19, 4:53 PM #5
Wooooowwwwww, thanks!!! I'm going to test this out! :D

I'll be back with the results ;)
ORJ / My Level: ORJ Temple Tournament I
2004-10-19, 6:16 PM #6
Ok, it's not doing anything, but I think it's something small.

Maybe I set it up wrong?

I used a 4-celled mat to test, so that couldn't be it.

Maybe the act_trig is not right? (It's set to 1 now).

What do I need to put in the 'Used_chngSurfs'? The number of surfaces that is actually being used? Or just leave it on 30?
ORJ / My Level: ORJ Temple Tournament I
2004-10-19, 10:40 PM #7
i fixed it
i had forgot it needed to be flags=0x240 not flag=0x240
try it now it should work
i also took out the used_chngsurfs so you dont need to worry
about that anymore
and the act_trig can be any whole number as long as it is not the
same as any other triggers in any other cogs you are useing in
the level
Famous last words - "It seemed like a good idea at the time."
2004-10-20, 4:09 AM #8
Awesomeness! It works now! :D

Very good job, man. It'll make for an ultra-cool addition to my temple! (Yes I'm still working on the same big level, which is ever more near completion.)

Don't worry about credit, you'll get it. I even credit people who did not actually contribute to the endresult, but just tried to help. :)

Thanks again, this is great :D
ORJ / My Level: ORJ Temple Tournament I
2004-10-20, 5:50 PM #9
Lol, I hate to say this, but I have two questions (and I promise that will be the last about this cog)...

1. Suppose I would want to increase the number of surfaces, how would I do that? Correct me if I'm wrong: Just replace all instances of '30' with the number I want? Plus ofcourse a 'surface chngSurf#X=-1' line for every extra surface I add?

2. Is it possible to implement a part that does the following:

Let's say there is a ghost from which position a sound is continuously played (looped)... now let's say if you press switch X, not only will all the surfaces switch to 'set X', but the sound which is played from the ghost position will also change to 'sound X'.

So there will be 4 sounds, 1 for every switch (and thus, for every set of surfaces)...

Is that possible? If noone feels like implementing these changes, feel free to tell me how to do it myself....

These are my last requests, I promise. :)
ORJ / My Level: ORJ Temple Tournament I
2004-10-20, 8:24 PM #10
1. yes thats one way you would add more surfaces that the cog effects.
are all these surfaces going to be using the same multi-celled mat or are some of them going to be different?
i ask because there is an easy way to change the cog so that it would change the cell on the surfaces with the mat and you wouldnt have to enter all the surfaces into the cog from jed and you could have it effect as many surfaces as you want.
even if you were using more than one multi-celled mat i could still make the change if you want.

2. not a hard thing to add, i already did it to the cog i posted.
try it and see if it works right.
Famous last words - "It seemed like a good idea at the time."
2004-10-21, 4:03 AM #11
Whoa, thanks! That was quick!

Yes, I will be using several different multi-celled mats. I don't know how many different ones at this moment (yet)... Were you thinking about a method in which we do not change all the surfaces, but instead all the mats with names x and y, etc.?

K, I'll test this out :D
ORJ / My Level: ORJ Temple Tournament I
2004-10-21, 4:30 AM #12
Allright, the sound thing works just fine! :) Thanks for adding the volume and range controls :D
ORJ / My Level: ORJ Temple Tournament I
2004-10-21, 11:54 AM #13
try this cog if you want
it does all the same stuff that the other one does but is easier to setup in jed.
you dont have to go through and list all the surfaces
Code:
#################################################
# Jedi Knight Cog Script	(JK\MotS)
#---------------------------------------------------------
# SURFACE_CHANGE02.COG
# -When one of the 4 switchs are activated all surfaces
#  with the chngCel_mat will change to the cell that goes
#  with that switch and a sound that goes with the
#  activated switch will play in a loop.
#---------------------------------------------------------
# Written By DSLS_DeathSythe
# This COG is NOT supported by LucasArts Entertainment Co.
#################################################
flags=0x240
symbols
#---------------------------------------------------------
message     startup
message     activated
message     trigger
message     join
#--------------------#
int         act_trig=1

surface     switch01=-1
surface     switch02=-1
surface     switch03=-1
surface     switch04=-1

material    chngCel_mat01
material    chngCel_mat02
material    chngCel_mat03
material    chngCel_mat04
material    chngCel_mat05

thing       sound_pos=-1
sound       loop_snd01
sound       loop_snd02
sound       loop_snd03
sound       loop_snd04
flex        sound_vol=1.0
flex        min_radius=-1.0
flex        max_radius=-1.0
#--------------------#
int         status=0                                      local
int         channel=-1                                    local
int         a=0                                           local
int         count=5                                       local
#---------------------------------------------------------
end
#================================================
code
#---------------------------------------------------------
startup:
	if(!IsServer()) return;
	status = 0;
	for(a=0; a<count; a=a+1)
		SetMaterialCel(chngCel_mat01[a], status);
	channel = PlaySoundThing(loop_snd01[status], sound_pos, sound_vol, min_radius, max_radius, 0x1);
return;
#---------------------------------------------------------
activated:
	if(GetSenderRef() == switch01) status = 0;
	else if(GetSenderRef() == switch02) status = 1;
	else if(GetSenderRef() == switch03) status = 2;
	else if(GetSenderRef() == switch04) status = 3;
	else return;
	SendTrigger(-1, act_trig, status, 0, 0, 0);
return;
#---------------------------------------------------------
trigger:
	if(GetSourceRef() != act_trig) return;
	status = GetParam(0);
	for(a=0; a<count; a=a+1)
		SetMaterialCel(chngCel_mat01[a], status);
	if(channel != -1)
		{
		StopSound(channel, 0.0);
		channel = -1;
		}
	channel = PlaySoundThing(loop_snd01[status], sound_pos, sound_vol, min_radius, max_radius, 0x1);
return;
#---------------------------------------------------------
join:
	if(!IsServer()) return;
	SendTrigger(-1, act_trig, status, 0, 0, 0);
return;
#---------------------------------------------------------
end
#################################################

setting up the switchs and sounds is just like the other one
as for the chngCel_mat#s just put the multi-celled mats you are going to use in these slots
ALL of the chngCel_mat#s have to be used or the cog will mess up
if you dont need that many then just delete the chngCel_mat#s that you dont need and change count=# to the number that you now have
if you need more just add more chngCel_mat#s and update the count=# to the number you have now
Famous last words - "It seemed like a good idea at the time."
2004-10-21, 1:24 PM #14
Dude if this works,, the sky is the limit :D

W00h00!!!

I'm testing this ;)
ORJ / My Level: ORJ Temple Tournament I
2004-10-21, 2:08 PM #15
This is awesome! It totally works :D Now I can do any number of surfaces!! Thanks a ton! If anything problematic pops up, I'll let you know... but I think this is it. :)
ORJ / My Level: ORJ Temple Tournament I
2004-10-21, 6:17 PM #16
Nice thinking there DSLS_DeathSythe! :D
-Hell Raiser

↑ Up to the top!