Entity change model or animation based on current music?

oldyz

Well-known member
This account is temporarily muted.
i would like to have an entity either change model or change its animation based on what music is currently playing

in the case of model change, it would be more likely to occur during the spawn animation:

basically if frame 1
detect current music
if music is 0 or null
or music is 03.ogg
change model to disco stu 3

will probably add more details later, i have been battling a nasty cold over the past days
 
There are plenty of ways to manipulate music, but nothing to tell you what music is playing. You have to know and track that beforehand. Set a global variable at start of a level to keep the default track. Any time you change music or take some action that would cause the engine to (like spawning a boss), just make sure to update that variable.

From there, you have entities check the variable and act accordingly. If it were me, I would #define a set of integer constants instead of song names. Not required, but far faster, more efficient, and will let you leverage switch structures.

C:
#ifndef MUSIC_TRACK_LIST
#define MUSIC_TRACK_LIST 1

#define MUSIC_TRACK_NONE                0
#define MUSIC_TRACK_HOTEL_CALIFORNIA     1
#define MUSIC_TRACK_BUTTERFLY            2

#endif

C:
int music_track = getglobalvar("music_current");

switch(music_track)
{
    default:
    case MUSIC_TRACK_NONE:
     
        // No muisc or variable not defined.
        break;
     
    case MUSIC_TRACK_HOTEL_CALIFORNIA:
     
        // Take actions for the Eagles!
        break;    
     
    case MUSIC_TRACK_BUTTERFLY:
     
        // Playing Swing Out Sister in OpenBOR?
        break;
}

DC
 
@DCurrent

OK, so i think i have a new understanding of how the menu option that displays the music that is currently playing works-
00 o.png

so basically the engine is not detecting what is currently playing, but it is only detecting that a file started to play, beyond that it does not know..

so with your provided code, everytime a song changes to another, it gives it a value or activates a switch of sorts and that value stays in play, entitiy detects this value and acts accordingly.

the only problem i see is with levels that are using music overlap,
on my module , levels that have no music (because the music came from a previous level) will load and feature the game's main Menu music, using this variables trick the engine will consider or "detect" the variable as none or 0?

either i would have to set the global variable script beyond just the level to "asign register or catalog all tracks with a value", or create 3 alernative model changes for entiites in those weird levels ?
 
Back
Top Bottom