HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Alternate 2 Songs In A Loop Forever For 1 LocalPlayer?

03-06-2008, 04:01 PM#1
Brash
I had 1 song before that was a Sound variable (not music variable) so it would play in the regular sound channels and i simply had it check-marked to be looping and it would play forever for the player (localplayer) that happened to type "-musicOn". And that worked great..

BUT

Now i have added another song!

I am having trouble figuring out the best way on how to loop them both back and forth so that it plays track1 then track 2.. then track 1 then track 2.. forever for ONLY the localplayer that happens to turn it on with the -musicon command..

it's a 12 player map and i dont want it spamming other players that dont wish to hear it.
03-06-2008, 04:18 PM#2
sas_Skorpion
How about a countdown timer ?

Event
-Players types -musicon
-Countdown timer2 expires
Actions
-start coundown timer1 (length of the first song)
-play song1


trigger 2
event
-countdown timer 1 epxpires
action
start countdown timer2
play song2
03-06-2008, 06:15 PM#3
Brash
Okay, thanks.
thought it might be something like that but I didn't know if there was a smoother more innate & simplier way that the editor handles tracks.
03-07-2008, 06:29 AM#4
Pyrogasm
Well, you could use 2 globals (and 1 temp local) to switch between the 2 songs, like this:
Trigger:
Collapse Events
Countdown Timer - MusicTimer expires
Conditions
Collapse Actions
Set TempSound = Sound1
Set Sound1 = Sound2
Set Sound2 = TempSound
Set TempDuration = Sound1
Set Duration1 = Duration2
Set Duration2 = TempDuration
----- Local player stuff -----
Sound - Fade out Sound1 over 0.10 seconds
Sound - Fade in Sound2 over 0.10 seconds
-- End Local player stuff -----
Countdown Timer - Start MusicTimer as a 1-shot timer that will expire in Duration1 seconds
03-07-2008, 07:14 AM#5
Tide-Arc Ephemera
Here's a list of functions that I think exist (but not in these words):
- Wait until sound finishes
- Run trigger

So my plan would be to make the songs sound files. It would run in this order:

1. Play song A
2. Wait for song A to finish
3. Play song B
4. Wait for song B to finish
5. Run (this trigger)

I'd post it but I have a... lack of World Editor.
03-07-2008, 05:07 PM#6
Brash
lol. wow that's a simple way to do it. i shy away from wait states.. think it's okay to use them here? i've grown afraid of them. heh

and pyro's method confusing me. i'm still staring it unsure of what all that back and forthing of making things equaling eachother would do.
03-07-2008, 09:08 PM#7
Pyrogasm
It's running everything through variables and switching them before re-starting the timer.

Oh, and I wouldn't use waits. They're very inaccurate and just bad in general if you can use timers instead.
03-08-2008, 06:49 AM#8
Brash
yeah wait states seem to always be bad from what i have read before.

okay now i have one set up and it works great when i play singleplayer but for some reason i'm getting server splits online with this trigger running

i havn't been able to figure out why when i have the sounds segregated within a localplayer check.


Trigger:
Music On
Collapse Actions
Set MusicBooCheckON[(Player number of (Triggering player))] = True
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
LocalPlayer Equal to (Triggering player)
Collapse Then - Actions
Sound - Stop MusicLastCreatedTrack[(Player number of LocalPlayer)] Immediately
Sound - Play MusicTrack[(Random integer number between 1 and 2)]
Collapse Else - Actions
Do nothing
Set MusicLastCreatedTrack[(Player number of (Triggering player))] = (Last played sound)
Countdown Timer - Start MusicTrack_Timer[(Player number of (Triggering player))] as a One-shot timer that will expire in (0.01 + (Length of MusicLastCreatedTrack[(Player number of (Triggering player))])) seconds
03-08-2008, 06:51 AM#9
Tide-Arc Ephemera
That last played sound will be unique to each player, so syncing that sound on a variable wouldn't be a great idea.

EDIT!
What's wrong with my method?
03-08-2008, 07:40 AM#10
Brash
Quote:
Originally Posted by Tide-Arc Ephemera
That last played sound will be unique to each player, so syncing that sound on a variable wouldn't be a great idea.

i dont quite grasp what you mean here.

you mean the "udg_MusicLastCreatedTrack[(Player number of (Triggering player))]" variable?

where should it be? inside or outside of that localplayer check?


Quote:
Originally Posted by Tide-Arc Ephemera
EDIT!
What's wrong with my method?

I'm not sure. just decided on the other guy's cuz im leary of wait states.
03-08-2008, 07:45 AM#11
Tide-Arc Ephemera
Ok, what I meant was that each player have the "last played song" registered as something different. If you were to refer to "last played song", it would cause a different event for each player, causing a server split because you're using data from each player to a global variable.

It's hard to explain because I know how it works but never told quite... in words how it worked. I figured it out after a few statements before auto-tuning out of it.

I think someone else will give a better answer.

EDIT!
The best comparison I can think of at the moment... say you stored an integer (somehow) using GetLocalPlayer() and then you tried to create a number of units based on that integer. It's going to give a different physical result to each player, causing a desync.
03-08-2008, 07:56 AM#12
Brash
so which is causing the desync.. that i set a variable outside of the condition or that i'm stopping that variable inside of it?


edit: also, doesn't the array on that variable help to restrict it to the same player? If the localplayer check was compared to the triggering player.. and then i have the variable set to that sound played there to that triggering player.. then shouldn't setting the array on the variable to that same triggering player also restrict it to equal out?
03-08-2008, 08:24 AM#13
Tide-Arc Ephemera
Array variables wouldn't help at all... array is just a capability to have multiples of any one variable.

The desync is being caused when you're storing the "last played song"... so yes, it is just out of the conditions.
03-08-2008, 09:56 AM#14
Brash
Okay, so i need to keep it generalized and not have anything outside of it ever target the "last played sound" when that maybe different outside of the local machine?

Here is what i came up with. Is this better?


Trigger:
Actions
Set MusicBooCheckON[(Player number of (Triggering player))] = True
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
MusicTrackNum[(Player number of (Triggering player))] Equal to 2
Collapse Then - Actions
Set MusicTrackNum[(Player number of (Triggering player))] = 1
Collapse Else - Actions
Set MusicTrackNum[(Player number of (Triggering player))] = 2
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
LocalPlayer Equal to (Triggering player)
Collapse Then - Actions
Collapse For each (Integer A) from 1 to 2, do (Actions)
Collapse Loop - Actions
Sound - Stop MusicTrack[(Integer A)] Immediately
Sound - Play MusicTrack[MusicTrackNum[(Player number of (Triggering player))]]
Collapse Else - Actions
Do nothing
Countdown Timer - Start MusicTrack_Timer[(Player number of (Triggering player))] as a One-shot timer that will expire in (Length of MusicTrack[MusicTrackNum[(Player number of (Triggering player))]]) seconds
03-08-2008, 10:01 AM#15
Tide-Arc Ephemera
That should work as far as I know. I haven't GUI'd in a little bit, but I see no reasons why that would desync.