• All, Gmail is currently rejecting messages from my host. I have a ticket in process, but it may take some time to resolve. Until further notice, do NOT use Gmail for your accounts. You will be unable to receive confirmations and two factor messages to login.

Solved Music change - entity theme song!

Question that is answered or resolved.

kdo

Member
Hi guys, looking around on the forum, i found a lot of threads talking about music change but not exactly how i need it.
So I need to make the background music (level) change when a certain entity is spawned, like an entity theme song, so after that entity dies, the music goes back to the background music (level) that was playing before entity to be spawned.
 
@kdo NightSlashers wide screen uses 3 methods for changing music,

one is trough animation script - 1- you change the music when an entity dies
or 2- during its spawn animation
another is trough spawn position
at scroll position X. music.ogg starts.

1, how do you want the music to syncronise during the spawn of the character?

2, do you need the level music to continue on from the point where it was interrupted?




There are flaws to the methods i currently use.

there is a boss who dies & the music changes to the next track because the change is made between death animation frames, but OpenBOR has a bug where some entities can die from a toss & the death animation does not show up, i have been trying to fix that to no success.

you can fix it by forcing death animation using script, or by activating the music using "ondeathscript'
i have not figured out how to do an ondeathscript music change either.
my workaround for this is to spawn an invisible entity using ondeathscript & an invisible entity changes the music in its first animation frame.

the drawback to doing it using ondeathscript is that if you want the music to syncronize exactly, it MIGHT screw up the timing, i find that the music sync "looks" better using the anim death method
 
1 -What i need is just start a new music when the entity is spawned and finish the music when its die,.

2-There is no need to stage music starts at the same point that its stoped. the music can be played again from the beginning.

The idea is something like a boss that appears ( so the music change) after it dies the game dont go ahead for next stage, the game play is at the same stage, so beating the boss the music back to stage music.

The spawn position method would not work, my stage has no scroll, the level is static.
 
Last edited:
What i need is just start a new music when the entity is spawned and finish the music when its die, so the stage music starts again, there is no need to start at the same point that its stoped.
Do you want the changes to be abrupt, or would you like the music to fade out & fade in?
The idea is something like a boss that appears ( so the music change) after it dies the game dont go ahead foe next stage, the game play is at the same stage, so beating the boss the music back to stage music.
You can do the music change during the spawn animation of the boss, or if you wan to be exact with the timing, but if you dont want to mess around with the spawn animation frames of this boss (in case that you want to use this same boss later with a different song & timing) , you spawn a "musicstart entity" using a group 1 1 method.
let's say you have a group of 5 enemies & after you dispatch them the music changes, you don't want the boss to appear until a high note on the song is played, so what you do is this example
group 5 5
spawn
(the enemies)
group 1 1
spawn
(the musicstart01) it starts the new song & automatically dies, so the boss spawns right after
group 1 1
spawn
the boss.

after the boss you can
A: drop a musicstart02 entity/item when it dies using the drop feature (using this method will not allow for the boss to drop a health item)
or B:
group 1 1
spawn
musicstart02, it plays the level music from the beginning again, after it dies it allows for a next group to appear right after.

if you want the next music to start before the boss features his last death animation frame, then you change the music with ondeathscript, or after the first frame of animdeath.

ondeath script can spawn the musicstart02 entity as a workaround to my current lack of an actual music change script.
 
Thank you for help me @oldyz !!! There is a problem, my mod has no groups like a normal mod, once the always use the same stage the scroll doesnt work to spawn the entitys, the ways to spawn enemys is just when player hit a specigic npc so its trigger a enemy spawn sequence, so the boss is one of them, the last enemy to be spawned. All the game is played at the same stage.
 
1 -What i need is just start a new music when the entity is spawned and finish the music when its die,.

2-There is no need to stage music starts at the same point that its stoped. the music can be played again from the beginning.

The idea is something like a boss that appears ( so the music change) after it dies the game dont go ahead for next stage, the game play is at the same stage, so beating the boss the music back to stage music.

The spawn position method would not work, my stage has no scroll, the level is static.
1 - you can play music on the fly when you spawn an entity:

Code:
spawn Sent_MKII
@script void main() {
playmusic("data/music/boss.ogg",1);
} @end_script
coords 60 180
map 3
at 1568

2 - you can use the same code on the boss death animation (either by inline script or but using cmd).

Code:
@script {
playmusic("data/music/boss.ogg",1);
} @end_script

or
Code:
@cmd playmusic "data/music/boss.ogg" 1

The only thing is: the music will restart - it won't start playing from where it was.
 
This iscript works for me in other mod.

@script
if(frame==0){ //
playmusic("data/music/lvlup.bor",1);
}
if(frame==28){ //
playmusic("data/music/lv1.bor",1);
}
@end_script

But the problem with it is that limitation frame==28 , it works perfect to level up, text, strikers..etc, entetys that use one animation like anim idle.
It could wok for if the frame==28 could be changed for something like a frame from anim death: frame data/chars/boss/death1.png

But Iam a script noob! :(
 
@O Ilusionista , thanks man, this will help me a great deal with some sync problems i have & other issues..

@kdo Ahhh, you are the one with the scripted group thing....
then what you do is try to adapt O Ilu's samples to your current script, OR incorporate musicchange entities before & after the "bosslet" entity.

@O Ilusionista, remember that kdo will need to force the death animation in case the boss dies from a toss...

i don't have access to my files right now, download NSWide & see how IgorX, the armorX, mummyX (inline/cmd) script

or the hangarX level , it features the musicentity music change
 
Thank you guys!!! I'll try this methods and finde the one that works better. I give you a feedback after try this. Thanks . I'll try NSWide.
 
I'll try NSWide
keep in mind that the names of the entites & levels i shared earlier may not match or be accurate (that is how i recall them), you have to explore the models.txt file & levels.txt files, its/they're full of notes & descriptions, & divided/listed by order of appearance & level structure (models)

the sample script you share would work too, like this:

@script
if(frame==0){ //
playmusic("data/music/lvlup.bor",1);
}
@end_script

you can use it in any animation.

NS wide will show you additional things like how music fades & how to add loop values on those cmd/inline scripts
 
Guys thank you so much! its working!!!

I use @cmd playmusic "data/music/boss.ogg" 1 in boss spawn animation to play boss music and in boss death animation used @cmd playmusic "data/music/stage.ogg" 1 to back the stage music.

Its done!!! Than you!
 
Guys thank you so much! its working!!!

I use @cmd playmusic "data/music/boss.ogg" 1 in boss spawn animation to play boss music and in boss death animation used @cmd playmusic "data/music/stage.ogg" 1 to back the stage music.

Its done!!! Than you!
I am going to rain on your parade a bit:

if the enemy dies from a toss, the music won't change, because there is no death animation.
try it in NS, defeat a zombie or a bosslet after doing a throw, they won't spill their guts or anything.

the fix is to force the anim death, something i a have tried using some answers in the forum to no success.

2nd option - use ondeathscript to call on either this:
@script {
playmusic("data/music/boss.ogg",1);
} @end_script (or a version of this)

or this 3rd
A: spawn a musicchange entity using ondeathscript -

in the NS download , there might be a script inside the scripts folder that contains a spawn function that is used for ondeathscript.
not only does it spawn things, it spawns a thing at random, all you have to do is modify the numbers so the only thing that spawns is the musicchange entity.

easiest way to find it is to do a search by date or date of creation, should be anything made after march 2021.

if its not there, you might have to wait until tomorrow - complete credit goes to @Kratus
 
remember that kdo will need to force the death animation in case the boss dies from a toss...
Even dead with a toss, the entity will still play the death animation if you set it right (falldie 2) - there is an enemy on avengers game, called "mob", who uses custom dead animations and it still plays the death animation even if you killed it using scripted slam.

They only won't play death animation if they are dead by falling on a hole - or if you instanly remove them from the screen.

Guys thank you so much! its working!!!

I use @cmd playmusic "data/music/boss.ogg" 1 in boss spawn animation to play boss music and in boss death animation used @cmd playmusic "data/music/stage.ogg" 1 to back the stage music.

Its done!!! Than you!
I am glad to know it's working :)
Btw you can use the script on the stage itself instead of the boss spawn animation, so you can use the same boss with and without the change music code if you want to (or you will have to use a script to force a spawn on a desired animation).
 
Last edited:
Back
Top Bottom