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 → Need help with a thinglight and sound.
Need help with a thinglight and sound.
2002-08-03, 5:30 PM #1
I'm trying to make it so that this cog plays one of the four wavs whenever the light flickers to the highlight, but i can't seem to get it to play the sounds.
I tried 'PlaySoundThing(rand()*sound);' but i got a bunchload of syntax errors, and I'm not to cog-literate, so any help would be appreciated.
Code:
# Jedi Knight Cog Script
#
# Made by Stormtrooper
# modified from 00_thinglight.cog
# [YB]
#
# NOT Supported By LucasArts Entertainment Co.
# Script that causes the light value attached to a thing to flicker between two values
# (Stormtrooper-added sound thing to make a lightning-thunder effect)
symbols
thing		lightthing	desc=thing_to_light
sound		sound0		desc=lightning_sound
sound		sound1		desc=lightning_sound1
sound		sound2		desc=lightning_sound2
sound		sound3		desc=lightning_sound3
flex		lowlight=0.1	desc=off_light_val
flex		highlight=0.6	desc=on_light_val
flex		offmax=0.5     	desc=max_off_interval
flex		onmax=1.0	desc=max_on_interval
message		startup		
end

# COG Section
code
startup:
	while(1) {
		thinglight(lightthing, lowlight, 0.0);
		sleep(rand()*offmax);
		thinglight(lightthing, highlight, 0.0);
		PlaySoundThing(sound, lightthing, 1.5, 10.0, -1, 0x10080);
		sleep(rand()*onmax);
	}
	stop;
end


------------------
Last week I cudn't evn spel grajuat, but now I is one.
2002-08-04, 5:53 AM #2
Use sound0[rand*4] in PlaySoundThing(); [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-04, 6:12 AM #3
I changed 'PlaySoundThing(sound, lightthing, 1.5, 10.0, -1, 0x10080);' into 'PlaySoundThing(sound0[rand*4], lightthing, 1.5, 10.0, -1, 0x10080);'
It plays the first sound, then crashes the game. any idea on how to fix this?

------------------
Last week I cudn't evn spel grajuat, but now I is one.
2002-08-04, 6:56 AM #4
Change "rand" to Rand() - those parentheses are needed. For shame, Pilot. [http://forums.massassi.net/html/tongue.gif]

Also, you're using a sound volume of 1.5, but the volume is only a 0 to 1 flex.

------------------
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-04, 7:12 AM #5
GREAT!!!! thank you, it works now.

Now, how would i make it so that the volume is randomly between 0.2 and 1?
Something with 'flex minvolume' and 'flex maxvolume' and then PlaySoundThing(sound0[Rand()*4], lightthing, Rand()*1, 10.0, -1, 0x10080);
maybe?

------------------
Last week I cudn't evn spel grajuat, but now I is one.
2002-08-04, 8:48 AM #6
sh!! , I did it agian. [http://forums.massassi.net/html/redface.gif] You don't need the *1 on the end of the volumes Rand().

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

The Magician Saber System.

[This message has been edited by Descent_pilot (edited August 04, 2002).]
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-08-04, 9:12 AM #7
OK, last thing, hopefully, The sound sometimes plays before the light flashes, so how would I make the sound wain about half a second.

------------------
Last week I cudn't evn spel grajuat, but now I is one.

*Takes out his blaster and fires shots at the wall, the blastmarks leave the words "STROOPER WUZ 'ERE!!!"
2002-08-04, 11:16 AM #8
The sound plays before the high light is set? Try changing your wav and see if that fixes it. It might be that the sound you're using is still playing when the next sound should be played.

Rand() returns a random number between 0 and 1. For a random number between 0.2 and 1, use Rand()*0.8+0.2.

------------------
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-04, 12:19 PM #9
Thank you very much, i had forgotten to delete a cog when i put the new one in, and that was what was making the thunder before the lightning.

------------------
Last week I cudn't evn spel grajuat, but now I is one.

*Takes out his blaster and fires shots at the wall, the blastmarks leave the words "STROOPER WUZ 'ERE!!!"
2002-08-05, 5:32 AM #10
Good luck. [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.

↑ Up to the top!