Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //::///////////////////////////////////////////////
- //:: aa_ex_music
- //:://////////////////////////////////////////////
- /*
- Use: Executed by an area
- Recursive script function that cycles through a series of songs.
- Local int: SONG_ID_01 (see: ambientmusic.2da)
- Last two chars determines order that track will play in.
- */
- //:://////////////////////////////////////////////
- //:: Created By: The Magus (2012 feb 14)
- //:: Modified:
- //:://////////////////////////////////////////////
- #include "aa_inc_time"
- void main()
- {
- object oArea = OBJECT_SELF;
- int nPCs = GetLocalInt(oArea, "PC_COUNT");
- int nNow = GetCurrentGameTime(TRUE);
- int nChange = GetLocalInt(oArea, "SONG_CHANGE_TIME");
- if (nPCs==0)
- {
- // no PCs present. Reset.
- MusicBackgroundStop(oArea);
- SetLocalInt(oArea, "SONG_ID_CURRENT", 0);
- MusicBackgroundChangeDay(oArea, 0);
- MusicBackgroundChangeNight(oArea, 0);
- }
- else if(nChange<=nNow)// it is time to change a song and we have a player present
- {
- int nSongID;
- int nTrack = GetLocalInt(oArea, "SONG_ID_CURRENT")+1;
- int nSongLength; float fSongLength; string sTrack;
- if(nTrack<10)
- sTrack = "0"+IntToString(nTrack);
- else
- sTrack = IntToString(nTrack);
- nSongID = GetLocalInt(oArea, "SONG_ID_"+sTrack);
- if(!nSongID)
- {
- nTrack = 1;
- nSongID = GetLocalInt(oArea, "SONG_ID_01");
- }
- string sSongLength = Get2DAString("ambientmusic","LENGTH",nSongID);
- if(sSongLength == "****")
- sSongLength = "0";
- nSongLength = StringToInt(sSongLength);
- int nDelay;
- if(nTrack==1) { nDelay = 1; }
- else { nDelay = 1; }
- MusicBackgroundStop(oArea);
- MusicBackgroundChangeDay(oArea, nSongID);
- MusicBackgroundChangeNight(oArea, nSongID);
- MusicBackgroundSetDelay(oArea, nDelay*1000);
- MusicBackgroundPlay(oArea);
- SetLocalInt(oArea, "SONG_ID_CURRENT", nTrack);
- SetLocalInt(oArea, "SONG_CHANGE_TIME", nNow+nSongLength+nDelay);
- fSongLength = IntToFloat(nSongLength+nDelay)+0.25;
- if(nSongLength>0)
- DelayCommand(fSongLength, ExecuteScript("aa_ex_music", oArea));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment