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 → Playambient2.cog modification
Playambient2.cog modification
2008-08-30, 6:24 PM #1
First let me thank everyone that has helped me so far with cogs.

Currently 00_playambient2.cog plays sounds from ghostobjects or things when you enter a sector.

I need a cog that instead plays a sound globally after entering a trigger sector; respectively it stops playing the sound when you enter a another trigger sector. Using "things" currently ends up causing alot of problems if you need sounds in many areas of a room. Usually causing some sounds to not play at all because it clutters all the different sound channels that jk has.

The cogs needs a volume int, up to 8 trigger sectors. 4 to turn it on and 4 to turn it off. (for areas that have more than 1 way in or out.)

Probably simple to most of you but I myself, cant make sense out of simple code work heh; it never was one of my strong points.
2008-08-30, 6:43 PM #2
Whats wrong with using normal sector sounds?
And when the moment is right, I'm gonna fly a kite.
2008-08-30, 9:34 PM #3
I figured that question would be brought up. I'm using that as a method of playing a starwars music track throughout the entire level.

To my knowledge that was the only way to play a music track. When you enter another sector it doesnt stop playing or doesnt double play and it restarts whenever you die or whenever it reaches the end of the track.

Anyways anyone still want to help me with this? :)
2008-08-31, 10:50 AM #4
Wow, thats a waste. It would be better to use the CD music or add a playsoundglobal(); call to your startup cog. Something like this should do it;

Code:
PlaySong(start_on_this_track,end_at_this_track,loop_from_this_track);

-or-

PlaySoundLocal(your_sound_track,volume,panning,0x1); #0x1 flag == looping
And when the moment is right, I'm gonna fly a kite.
2008-09-01, 5:34 PM #5
I'll use that in my future levels but as of now I still need the cog that I requested. It would be a bit tedious to use your suggestion with my current levels. heh that would be quite alot of sector editing in 6 levels.
2008-09-03, 5:40 PM #6
Maybe the cog should just have two trigger sectors: one to turn it on and one to turn it off. That woud make things so much easier. Then you could just use the cog 4 times...
er...
2008-09-03, 5:43 PM #7
Unless you need them because there are multiple routes to set it off. Nvm, I see what you mean now.
er...
2008-09-03, 6:56 PM #8
Here you go. Sectors 1-4 start the music, 5-8 end it. I incorperated a fade in and out feature. If it's to slow change the numbers in red to smaller numbers like 0.5
If you're using soundtrack from the disk I'm gonna have to change it a little bit. Right now it's set up for your own music file. If there are any bugs tell me.


Code:
 
symbols
message Entered
message Timer
message User0
message User1
sector sector1 linkid=1
sector sector2 linkid=1
sector sector3 linkid=1
sector sector4 linkid=1
sector sector5 linkid=2
sector sector6 linkid=2
sector sector7 linkid=2
sector sector8 linkid=2
sound music
int sender local
int donestart=0 local
int sound0 local
flex curvol=0.1 local
end
# ========================================================================================
code
Entered:
sender = GetSenderID();
if ((sender == 1))
{
call User0;
}
else
{
call User1;
}
return;
User0://starting sound
if(donestart == 1) return;
donestart= 1;
sound0 = PlaySoundLocal(music, curvol, 0.0, 0x1); 
SetTimer(1.0);
return;
 
User1://ending sound
if(donestart == 0) return;
donestart= 0;
SetTimer(1.0);
return;
 
Timer:
If(donestart == 1)// starting fade in
{
if(curvol >= 0.9) return;
curvol = curvol + 0.1;
ChangeSoundVol(sound0, curvol, 
        1.0
    ); 
SetTimer(
        1.0
    );
}
else// start fading out
{
if(curvol <= 0.1) 
{
StopSound(sound0, 0.0);
return;
}
curvol = curvol - 0.1;
ChangeSoundVol(sound0, curvol, 
        1.0
    );
SetTimer(
        1.0
    );
}
 
return;
 
end
er...
2008-09-04, 8:49 PM #9
Hey thanks for the reply lexen. I just got my new computer so I don't currently have jk installed. I'll give this a test as soon as that occurs.
2008-09-08, 6:22 AM #10
Ok it has some serious bugs lol. Instead of playing the sound I set, it starts playing the first sound in my sounds in level list. If I delete that sound in my sounds in level list, then it starts playing the next sound and so on.
2008-09-08, 6:47 AM #11
hmm disregard that. I have no idea what it was, maybe just a bug from a fresh install of jkedit, but its fine now. Thanks for the assistance :)
2008-09-08, 7:41 PM #12
hmmm... did you have a space in the filename?
Oh well, glad it's working for you.
er...

↑ Up to the top!