How to change music in level

DJGameFreakTheIguana

Active member
Fir of all, it's been a while guys, how's it goin' with yall.  8)

Anyway, I'm working on this stage here, but once you get done knocking out some enemies, a certain group of enemies will come soon to be followed by a boss after you KO some of them, but I want the music to change as soon as this group comes out, not just the boss. I remember there was a command to make the music change once you get the cordnated spot of the level, but I have no idea how it was. Does anyone here know about it?

x)
 
It's in the manual, but music is mentioned several times so it's easy to miss.

Code:
music {path} {offset}

~Optional.
~{path} points to a .bor music file which will be played during the stage.
~{offset} is position in bytes music will return to when it loops. For instance, with a .bor file with 128000 byte size, setting offset to 64000 would make music loop from halfway of the music.
~you can change the music during a stage using "at" and giving a new file path, like this:
music   data/music/newmusic.ogg
at        600
 
Oh right, the manual, need to find that and save it bit by bit in catagories like I did the old one(before we got the .CHM files), but yeah, thanks a lot man, and the looping command sounds pretty tight.

x)
 
I know what you mean, You can try this if you want,

I started making a new help file before lavalit went down, it's got the new manual included, all those old tutorials and some new ones.

https://www.dropbox.com/s/70xfc1hz4wrth5h/OpenBoR%20Help.pdf

There's a download option at the top
 
Music can also be changed at will with a single line script function (playmusic). With a bit of ingenuity you can do all kinds of fun things with this. See this video for an example. Boomboxes in the stage are a semi hidden Easter egg; pressing attack next to them will have the character tune in another station - IOW change the stage music.

The function is from all the way back in 2010 and could use some serious updates, but still works just fine. It is triggered by the key event, and works by detecting proximity to a specific invisible obstacle model. It's also written so a single model works for as many different music switch sets as you want. Aggression and HP spawn settings control the tracks that instance of the obstacle will cycle through.

http://youtu.be/WMH7knXt0UY

Code:
#include	"data/scripts/vars/index.h"
#include	"data/scripts/com/file0001.h"
#include	"data/scripts/com/soun0005.h"

void musi0001(void vEnt, int iNotch){

	/*
    musi0001
    Damon Vaughn Caskey
    2010-12-29
	Cycle music tracks using passed entity's agression, nodrop and juggle points value.

	vEnt: Target entity.  	
    */

	int		iMH, iND, iAG;									//Target entity's max guardpoints, nodrop, and aggression settings.
	char	cTrack;											//Music track name.

	if(!vEnt){	vEnt = getlocalvar("self");	}				//If no entity passed use caller.
		
	iAG	=	getentityproperty(vEnt, "aggression");			//Get aggression (row).
	iND	=	getentityproperty(vEnt, "nodrop");				//Get nodrop (colmun).
	iMH	=	getentityproperty(vEnt, "maxhealth");			//Get health (sound).

	if(iND < 1){	iND = 1;	}							//Failsafe column to 1.

	cTrack = file0001(8, "music", ""+iAG+"", iND);			//open music file and get argument.
	
	if(!cTrack)												//Argument null or invalid?
	{		
		iND = 1;											//Reset column.
		cTrack = file0001(8, "music", ""+iAG+"", iND);		//Try getting track again.
	}

	if(cTrack)												//Track found?
	{
		if(iMH)
		{
			soun0005(vEnt, iMH, -1, 1, 0, 0);				//Play sound effect.
		}
		playmusic("data/music/" + cTrack + ".bor", 1);		//Apply the track.
	}
	
	changeentityproperty(vEnt, "nodrop", iND+iNotch);		//Increment or decrement jugglepoints for next call.
}
 
That actually seems pretty tight. As for now, my main idea, outside of tha pirticular stage, was to make a menu where you can change the music at will. I got some of it still saved in that old pokemon demo I made, but so far, I only have the menu to show, but the game keeps going. I wanna get it to where the game pause when I find a way to summon the menu.

x)
 
music  data/music/subboss.bor
at  2550

Is it possible to make music change to subboss.bor track at 2550 scrollpos but only after 10 seconds?

I need something like next:

music data/music/track1.ogg
at            0

musicfade 2
at 2000

music data/music/track2.ogg (10sec long)
at            2000

music data/music/track3.ogg (start to play after 10 sec)
at            2000

Track1 fade out and stops at 2000, and same time track2 and track3 plays, but track2 plays instantly, track3 after 10 seconds (after track2 but in the same scrollpos)
Thank you)
 
You could do track 3 in an entity and just spawn that.  the frames would control delay before the music starts.


frame
@cmd    playmusic "data/music/sboss3.bor" 1
frame
 
I have found a script:

anim idle
loop 0
delay 2
offset 0 0
@script
    void vSelf = getlocalvar("self");
if(frame==0)
{
      playmusic("DATA/music/track1.ogg", 1);
}@end_script
frame data/chars/misc/music/e.gif
frame data/chars/misc/music/e.gif

Seem to be what i need. But is it possible somehow to convert this script into next look:

spawn music
alias  DATA/music/track1.ogg
coords  100 500
at  2000

that will allow script to play music from path that was define in alias? In other case i need to create a ton of separate music entities for each music track. Thank you)
 
Nice,
Is it something that can allow multiple boss music?
Something like that :

Stage enemies = regular music.
Sub boss = scripted boss music (1)
Boss = Real (engine) boss music (2)

??

I'll need this one soon...
 
  mtrain, that script you posted changes music directly as soon as the entity is spawned. It is similar to this command:

music  DATA/music/track1.ogg
at            2000

I don't see point of remaking this command with script UNLESS you have extra effect you want

Stage enemies = regular music.
Sub boss = scripted boss music (1)
Boss = Real (engine) boss music (2)

Just change the music right before the boss (or any entity) is spawned :)
 
Bloodbane said:
Stage enemies = regular music.
Sub boss = scripted boss music (1)
Boss = Real (engine) boss music (2)

Just change the music right before the boss (or any entity) is spawned :)

OK,
The ide for me is to use:
"Sub boss" as a "REAL boss of stage" to have a boss music.
"Boss" (engine boss) as a text message for completed stage with complete music.

I'll try to experiment with that.
 
Just change the music right before the boss (or any entity) is spawned

I need this not for boss case, i need to make a cutscene in the middle of the stage, so when player reach scrollpos 6000 previous music is fades and plays a 10 sec track, and after 10 seconds at the same point i need to spawn another track2. It looks like next:

musicfade 2
at 6000

music data/music/10sec.ogg
at 6000

spawn  music
coords  0 500
at  6000

And it is working with an entity and script:

#Trigger for music
name music
health 1
type none
shadow 0
facing 1

lifespan 11

anim idle
loop 0
delay 2
offset 0 0
@script
    void vSelf = getlocalvar("self");
#if(frame==0)
{
      playmusic("DATA/music/track2.ogg", 1);
}@end_script
frame data/chars/misc/music/music.gif
frame data/chars/misc/music/music.gif
frame data/chars/misc/music/music.gif
frame data/chars/misc/music/music.gif


anim spawn
loop 0
offset 0 0
delay 1000 #10 sec delay
frame data/chars/misc/music/music.gif
delay 2
frame data/chars/misc/music/music.gif
frame data/chars/misc/music/music.gif

But i need to make a track2 to be spawned like next:

musicfade 2
at 6000

music data/music/10sec.ogg
at 6000

spawn  music
alias      DATA/music/track2.ogg
coords  0 500
at  6000

This must allow me to spawn only 1 entity in which i can define track i need, because cutscenes like this will be about 20 and for convenience it will be easier not to create 18 entities for each track, but edit 1 entity alias in the level.txt
So here is the question, is it possible to modify that script to make it check alias as variable, and put it to the path of the track?
 
Damon Caskey said:
The function is from all the way back in 2010 and could use some serious updates, but still works just fine. It is triggered by the key event, and works by detecting proximity to a specific invisible obstacle model. It's also written so a single model works for as many different music switch sets as you want. Aggression and HP spawn settings control the tracks that instance of the obstacle will cycle through.

http://youtu.be/WMH7knXt0UY

Hey man, what's the name of the song at 0:27? Sounds pretty cool, but of course scumbag Terri had to change the station in the middle of it. :P
 
Back
Top Bottom