Author Topic: Music drop on dialogues [SOLVED]  (Read 441 times)

Music drop on dialogues [SOLVED]
« on: 14 Jul 2017, 01:59 »
Hi guys i noticed that with music drop everytime there is a wait or a pause in a dialogue the music goes up and down that result in a bad clipping effect.
Do you know a way to make a drop continuous when a dialogue is running? I would like maybe to make a function that refers to all dialogues that everytime i'm inside them the soundtrack drop down until stop.
« Last Edit: 18 Jul 2017, 11:28 by rmonic79 »

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Music drop on dialogues
« Reply #1 on: 14 Jul 2017, 08:07 »
You could look into the approaches suggested in this thread.

Another option would be to create a global variable (in the global variable pane) as an int that stores the currently running dialog number (and -1 if none). Then write custom wrappers for Dialog.Start() and for StopDialog() that update this variable, and make sure you're always using those rather than calling the functions directly (or using the dialog script stop). Then you check the value of this variable in repeatedly_execute_always() to decide whether to apply or disable the drop.

When you're handling the reduction on your own, you might also need to do special stuff to store and restore the original music volumes.

Re: Music drop on dialogues
« Reply #2 on: 14 Jul 2017, 09:57 »
thanks snarky i'll try to make it today! ;)
one question, how can i store the current dialogue in a global variable? i put it in rep ex always of global script but i don't know how to get it
« Last Edit: 14 Jul 2017, 10:11 by rmonic79 »

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Music drop on dialogues
« Reply #3 on: 14 Jul 2017, 10:30 »
Well, either do it as explained in the thread I linked, or just make sure you set it when dialogs start and end. In that case, you don't need repeatedly_execute().

If your global variable is called activeDialog, just create wrapper functions that look something like:

Code: Adventure Game Studio
  1. void StartTracked(this Dialog*)
  2. {
  3.   activeDialog = this.ID;
  4.   this.Start();  
  5. }
  6.  
  7. void StopDialogTracked()
  8. {
  9.   activeDialog = -1;
  10.   StopDialog();
  11. }

Now replace all calls to Dialog.Start() and StopDialog() with calls to these wrapper functions instead.

... Though it just now occurs to me that I'm not sure you can call module code or functions you've defined from the dialog script – I don't know the script precedence there (I never actually used dialogs myself). So instead of StopDialogTracked() you might have to actually write those two lines of code at the end of every dialog. That's annoying.

Re: Music drop on dialogues
« Reply #4 on: 14 Jul 2017, 10:49 »
if i have to put line by line i can put a certain percentage of music slidebar on start and regain it at all stops but i'm trying to avoiding this
 cause the game is just finished and has a lot of text and i have still to put manually in all stuff outside dialogues. If there's away to check wichever dialogues are playing or no dialogues playing i could automatize it at least inside them and maybe do some checks regarding id if needed. Is there a possibility i can procede this way?
(sorry i'm not english and i don't know if i explain this stuff well enough :) )

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Music drop on dialogues
« Reply #5 on: 14 Jul 2017, 12:41 »
There's no way to get the "am I in a dialog script?" state from AGS itself. If you need to know it, you have to keep track of it yourself, which means you have to set a flag when you enter a dialog, which means you should do all your dialog calls through a custom function.

So there's no way around changing your code, but really this should be a very simple thing to change just with search-and-replace.

As for not having to change all the StopDialog()/stop calls, you should be able to use the approach suggested by abstauber in the other thread, and if that doesn't quite work (which might be an AGS quirk having to do with custom dialog options rendering) use CW's suggestion as a further fix.

Edit:

To avoid confusion, here is abstauber's approach, adapted to your situation:

Code: Adventure Game Studio
  1. int activeDialog = -1;
  2.  
  3. void StartCustom(this Dialog*)
  4. {
  5.   activeDialog = this.ID:
  6.   // TODO: Drop the music volume
  7.   this.Start();
  8. }
  9.  
  10. void OnEndDialogCustom()
  11. {
  12.   activeDialog = -1;
  13.   // TODO: Restore the music volume
  14. }
  15.  
  16. // GlobalScript
  17.  
  18. function repeateadly_execute()
  19. {
  20.   // repeatedly_execute doesn't run during dialogs, so it must have ended
  21.   if(activeDialog != -1)
  22.     OnEndDialogCustom();
  23.  
  24.   // Other stuff
  25. }

Now just change all your calls to Dialog.Start() to Dialog.StartCustom(), which you can do with search-and-replace.

If you're finding that the music comes back up when you get to dialog options, and you're using AGS 3.4, you can try adding a little bit to the Global Script:

Code: Adventure Game Studio
  1. bool isInDialogOptions;
  2.  
  3. function dialog_options_repexec(DialogOptionsRenderingInfo *info)
  4. {
  5.   isInDialogOptions = true;
  6. }
  7.  
  8. function repeateadly_execute()
  9. {
  10.   // repeatedly_execute doesn't run during dialogs, so it must have ended
  11.   if(activeDialog != -1 && !isInDialogOptions)
  12.     OnEndDialogCustom();
  13.   isInDialogOptions = false;
  14.  
  15.   // Other stuff
  16. }
« Last Edit: 14 Jul 2017, 13:02 by Snarky »

Re: Music drop on dialogues
« Reply #6 on: 14 Jul 2017, 12:59 »
ok thanks snarky :)

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Music drop on dialogues
« Reply #7 on: 14 Jul 2017, 13:08 »
(Not sure whether you saw the code samples I added)

With this approach, a dialog isn't considered to have ended until the game stops blocking, so if you have any Wait() or blocking Walk() calls right after the dialog, the music won't come back up for those. To work around that, you can call OnEndDialogCustom() yourself at the point where you want the music volume to be restored.

Re: Music drop on dialogues
« Reply #8 on: 14 Jul 2017, 13:12 »
(Not sure whether you saw the code samples I added)

With this approach, a dialog isn't considered to have ended until the game stops blocking, so if you have any Wait() or blocking Walk() calls right after the dialog, the music won't come back up for those. To work around that, you can call OnEndDialogCustom() yourself at the point where you want the music volume to be restored.

i've seen it now, very good! i'll try asap!

Re: Music drop on dialogues
« Reply #9 on: 14 Jul 2017, 18:28 »
IT seems to work great even when dialogue options on. I'll give a deep test tomorrow. I'm on 3.4.0.6 alpha but i'll take a test also on 3.4 .

Re: Music drop on dialogues
« Reply #10 on: 15 Jul 2017, 16:01 »
I'm just trying it on 3.4 and seems to works fine too, now i overwrite all dialogue.start and make a gameplay of the entire game to take a look.

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Music drop on dialogues
« Reply #11 on: 15 Jul 2017, 17:29 »
Cool. I figure the issue Dave was having hs to do with custom dialog options rendering. There's a further tweak to make it reentrant (so you can call .StartDialogCustom multiple times without it dropping the volume repeatedly), I'll edit it in once I'm at a computer.

Re: Music drop on dialogues
« Reply #12 on: 17 Jul 2017, 11:40 »
To avoid dialogue inside dialogue volume drop i made .start normal when they overlap and it seems to work.

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Music drop on dialogues
« Reply #13 on: 17 Jul 2017, 22:35 »
Yeah, here's what I was thinking, but there are no doubt other ways as well:

Code: Adventure Game Studio
  1. int activeDialog = -1;
  2.  
  3. void StartCustom(this Dialog*)
  4. {
  5.   if(activeDialog == -1)
  6.   {
  7.     // TODO: Drop the music volume
  8.   }
  9.   activeDialog = this.ID:
  10.   this.Start();
  11. }

Re: Music drop on dialogues
« Reply #14 on: 18 Jul 2017, 11:27 »
good! Thanks snarky i forgot to add you to credits, can i?
p.s. if you want your real name you can pm me