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 → Sound System COG Problems
Sound System COG Problems
2005-10-24, 5:17 PM #1
I designed this COG for my up-coming Theed level. The concept is based on SM Sith Lord's Sound System COG, although the design is completely different. Basically, that's what it does: when a player hits a switch, music is played on all computers, and a string appears on all computers, displaying the name of the player who turned on the music.

But there's more: the music wav's speed is actually cut down by two, to reduce file size. The COG also slows down the music by two.

Everything works fine, but the only problem is that only the host hears the music right, all other players hear it sped up.

Any ideas?

Here's the COG:

Code:
#======================================================================
# Jedi Knight Cog Script
#
# 00_music.cog
#
# By activating a switch, music will be played (in loop), until
# the switch is turned off.
#
# Concept based on a COG by SM Sith Lord
# 
# [Wes Darklighter]
#
# This cog is not made or distributed by LucasArts Entertainment Co.
#=======================================================================

flags=0x240

symbols

message 	activated

sound         wav0
sound         music

surface	switch

int           curcel                  
int		player	                    local

end

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

code

activated:
       
       player = GetSourceRef();
	
       SetSurfaceCel(switch, 1 - curcel);
       curcel = 1 - curcel;
       
       if (GetSurfaceCel(switch) == 1)

       {
       
       music = PlaySoundGlobal (wav0, 1, 0, 0x1);
       ChangeSoundPitch (music, 0.5, 0.1);
       ChangeSoundVol (music, 10, 2);

       jkStringClear();
	jkStringConcatPlayerName(player);
	jkStringConcatSpace();
	jkStringConcatAsciiString("turned on the music.");
	jkStringOutput(-3, -1);
	return;
       
       }

       else if (GetSurfaceCel(switch) == 0)

       {

       jkStringClear();
       jkStringConcatAsciiString("lolz. music stopped.");
       jkStringOutput(-3, -1);
       StopSound(music, 0);
       return;
       
       }


EDIT: ORJ_JoS is right. My bad. :)
Wes Darklighter
|Theed|
2005-10-24, 5:52 PM #2
I have no idea. What I do know, is that the cog doesn't speed up the soundfiles, it slows them down so you can hear them at the right speed.
ORJ / My Level: ORJ Temple Tournament I
2005-10-24, 8:02 PM #3
GBK used a cog similar to this in his Ode to Suzzane level. You might want to check that out. He being the master coder that he is, it's probably heard on all machines, since OTS is MP. :)
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2005-10-25, 10:56 PM #4
Sounds like you'll probably have to make use of a SendTrigger() cog verb to get it to work on all clients. Triggers are commonly used for situations like this. To learn how to use triggers, I suggest you look at the cogs used for the keys that were used in Nar Shadda CTF.
The cake is a lie... THE CAKE IS A LIE!!!!!
2005-10-26, 5:19 AM #5
Originally posted by Daft_Vader:
GBK used a cog similar to this in his Ode to Suzzane level....

OTS had music, yes, but I didnt use this "half speed" gimmick.
And when the moment is right, I'm gonna fly a kite.
2005-10-26, 7:41 PM #6
Originally posted by gbk:
OTS had music, yes, but I didnt use this "half speed" gimmick.

I was referencing your "JukeBox" machine which you could switch on and off that played the music. Sorry for not clarifying. :)
My JK Level Design | 2005 JK Hub Level Pack (Plexus) | Massassi Levels
2005-11-03, 6:55 PM #7
So Wes, how's it going with this problem? Did you try a trigger, like SavageX suggested?
ORJ / My Level: ORJ Temple Tournament I
2005-11-05, 1:02 PM #8
Well, ZeqMacaw implemented the triggers for me. It now works perfectly in MP. :D

Here's the COG if anyone's interested:

Code:
#=================================================
# Jedi Knight Cog Script
#
# 00_music.cog
#
# By activating a switch, music will be played (in loop), until
# the switch is turned off.
#
# Concept based on a COG by SM Sith Lord
# 
# [Wes Darklighter]
# ZeqMacaw 04-Nov-2005  Modified to work in MP via triggers.
#
# This cog is not made or distributed by LucasArts Entertainment Co.
#=================================================

flags=0x40

symbols
	sound     wav0
	sound     music
	int       trigger_id
	surface	  switch

	message 	startup
	message 	activated
	message 	trigger
end

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

code

startup:


	if (GetSurfaceCel(switch) == 1)
	{
		SendTrigger(GetLocalPlayerThing(), trigger_id, 1, 0, 0, 0);
	}
	else 
	{
		SetSurfaceCel(switch, 0);
		SendTrigger(GetLocalPlayerThing(), trigger_id, 0, 0, 0, 0);
	}
	return;

activated:


	SetSurfaceCel(switch, 1 - GetSurfaceCel(switch));

	if (GetSurfaceCel(switch) == 1)
	{
		SendTrigger(-1, trigger_id, 1, 0, 0, 0);
	}
	else 
	if (GetSurfaceCel(switch) == 0)
	{
		SendTrigger(-1, trigger_id, 0, 0, 0, 0);
	}
	return;

trigger:

	if (GetSourceRef() == trigger_id)
	{
		if (GetParam(0) == 1)
		{
			music = PlaySoundLocal(wav0, 1, 0, 0x1);
			ChangeSoundPitch(music, 0.5, 0.1);
			ChangeSoundVol(music, 10, 2);

			jkStringClear();
			jkStringConcatPlayerName(GetSenderRef());
			jkStringConcatSpace();
			jkStringConcatAsciiString("turned on the music.");
			jkStringOutput(-1, -1);
		}
		else
		{
			StopSound(music, 0);

		}
	}
	return;

end
Wes Darklighter
|Theed|

↑ Up to the top!