Skip to content

Trigger music to play in specific areas of the map

Dark_AnsemDark_Ansem Member Posts: 992
edited March 2018 in Builders - Scripting
As per title, I'm trying to make a script that will change the BGM of the area you're in once you step in the area, and revert it back once you leave the area.

This is the "in" script:
/*  name : bgm_trchange_in
    purpose : changes BGM music when the PC steps in the area

    by Dark_Ansem
*/

void main()
{
object oPC = GetEnteringObject();

if ( GetIsPC(oPC) )
    {
    PlayCharacterTheme(XX);
    }
}
And this is the "out" script:
/*  name : bgm_trchange_out
    purpose : reverts BGM music when the PC steps out the area

    by Dark_Ansem
*/

void main()
{
object oPC = GetExitingObject();

if ( GetIsPC(oPC) )
    {
    PlayOldTheme();
    }
}
However, they don't work. Any help please?

Comments

  • Sylvus_MoonbowSylvus_Moonbow Member Posts: 1,085
    You want to use MusicBackgroundChangeNight(GetArea(oPC), ##); and
    MusicBackgroundChangeDay(GetArea(oPC), ##);

    ## is the track reference from your ambientmusic.2da file
  • Dark_AnsemDark_Ansem Member Posts: 992

    You want to use MusicBackgroundChangeNight(GetArea(oPC), ##); and
    MusicBackgroundChangeDay(GetArea(oPC), ##);

    ## is the track reference from your ambientmusic.2da file

    Oh, that could definitely be it.
    I got the idea off the OC's scripts when talking with Aribeth or Aarin, what did I do wrong?
  • Dark_AnsemDark_Ansem Member Posts: 992
    Hold on: do I need to add "#include "NW_I0_PLOT""?
  • Sylvus_MoonbowSylvus_Moonbow Member Posts: 1,085
    No. MusicBackgroundChangeNight and MusicBackgroundChangeDay work regardless of an include file.
  • Dark_AnsemDark_Ansem Member Posts: 992

    No. MusicBackgroundChangeNight and MusicBackgroundChangeDay work regardless of an include file.

    Thanks. Then of course I'd just revert to original values when exiting?
  • Sylvus_MoonbowSylvus_Moonbow Member Posts: 1,085
    Yeah.
  • Dark_AnsemDark_Ansem Member Posts: 992
    Done, and it works, without bugs methinks.

    Source:
    /*  name: chngbgm_trg_in
        purpose : changes BGM music when the PC steps in the area
    
        by Dark_Ansem
    */
    
    void main()
    {
    object oPC = GetEnteringObject();
    
    if ( GetIsPC(oPC) )
        {
        MusicBackgroundChangeNight(GetArea(oPC), 65);
        MusicBackgroundChangeDay(GetArea(oPC), 65);
        }
    }
    /*  name: chngbgm_trg_out
        purpose : reverts BGM music when the PC steps out the area
    
        by Dark_Ansem
    */
    
    void main()
    {
    object oPC = GetExitingObject();
    
    if ( GetIsPC(oPC) )
        {
        MusicBackgroundChangeNight(GetArea(oPC), 79);
        MusicBackgroundChangeDay(GetArea(oPC), 79);
        }
    }
Sign In or Register to comment.