henesua

aa_ex_music

Feb 13th, 2012
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.98 KB | None | 0 0
  1. //::///////////////////////////////////////////////
  2. //:: aa_ex_music
  3. //:://////////////////////////////////////////////
  4. /*
  5.     Use: Executed by an area
  6.  
  7.     Recursive script function that cycles through a series of songs.
  8.     Local int: SONG_ID_01 (see: ambientmusic.2da)
  9.     Local int: SONG_LENGTH_01 (list of lengths is in aa_music_read)
  10.  
  11.     Last two chars of each local variable are the index of the track.
  12.  
  13. */
  14. //:://////////////////////////////////////////////
  15. //:: Created By: The Magus (2012 feb 13)
  16. //:: Modified:
  17. //:://////////////////////////////////////////////
  18.  
  19. #include "aa_inc_time"
  20.  
  21. void main()
  22. {
  23.     object oArea    = OBJECT_SELF;
  24.     int nPCs        = GetLocalInt(oArea, "PC_COUNT");
  25.     int nNow        = GetCurrentGameTime(TRUE);
  26.     int nChange     = GetLocalInt(oArea, "SONG_CHANGE_TIME");
  27.     // only continue if one or more players are present
  28.     if(nPCs>0 && nChange<=nNow)
  29.     {
  30.         int nTrack      = GetLocalInt(oArea, "SONG_ID_CURRENT")+1;
  31.         int nSongID, nSongLength; float fSongLength; string sTrack;
  32.         if(nTrack<10)
  33.             sTrack = "0"+IntToString(nTrack);
  34.         else
  35.             sTrack = IntToString(nTrack);
  36.  
  37.         nSongID     = GetLocalInt(oArea, "SONG_ID_"+sTrack);
  38.         if(!nSongID)
  39.         {
  40.             nTrack      = 1;
  41.             nSongID     = GetLocalInt(oArea, "SONG_ID_01");
  42.             nSongLength = GetLocalInt(oArea, "SONG_LENGTH_01");
  43.         }
  44.         else
  45.             nSongLength = GetLocalInt(oArea, "SONG_LENGTH_"+sTrack);
  46.  
  47.         MusicBackgroundStop(oArea);
  48.         MusicBackgroundSetDelay(oArea, 0);
  49.         MusicBackgroundChangeDay(oArea, nSongID);
  50.         MusicBackgroundChangeNight(oArea, nSongID);
  51.         MusicBackgroundPlay(oArea);
  52.  
  53.         SetLocalInt(oArea, "SONG_ID_CURRENT", nTrack);
  54.         SetLocalInt(oArea, "SONG_CHANGE_TIME", nNow+nChange);
  55.         fSongLength = IntToFloat(nNow+nChange)+2.0;
  56.         DelayCommand(fSongLength, ExecuteScript("aa_ex_music", oArea));
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment