Music drop on dialogues [SOLVED]

Started by rmonic79, Fri 14/07/2017 01:59:25

Previous topic - Next topic

rmonic79

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.

Snarky

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.

rmonic79

#2
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

Snarky

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: ags
void StartTracked(this Dialog*)
{
  activeDialog = this.ID;
  this.Start();  
}

void StopDialogTracked()
{
  activeDialog = -1;
  StopDialog();
}


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.

rmonic79

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

#5
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: ags
int activeDialog = -1;

void StartCustom(this Dialog*)
{
  activeDialog = this.ID:
  // TODO: Drop the music volume
  this.Start();
}

void OnEndDialogCustom()
{
  activeDialog = -1;
  // TODO: Restore the music volume
}

// GlobalScript

function repeateadly_execute()
{
  // repeatedly_execute doesn't run during dialogs, so it must have ended
  if(activeDialog != -1)
    OnEndDialogCustom();

  // Other stuff
}


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: ags
bool isInDialogOptions;

function dialog_options_repexec(DialogOptionsRenderingInfo *info)
{
  isInDialogOptions = true;
}

function repeateadly_execute()
{
  // repeatedly_execute doesn't run during dialogs, so it must have ended
  if(activeDialog != -1 && !isInDialogOptions)
    OnEndDialogCustom();
  isInDialogOptions = false;

  // Other stuff
}

rmonic79


Snarky

(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.

rmonic79

Quote from: Snarky on Fri 14/07/2017 13:08:54
(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!

rmonic79

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 .

rmonic79

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

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.

rmonic79

To avoid dialogue inside dialogue volume drop i made .start normal when they overlap and it seems to work.

Snarky

Yeah, here's what I was thinking, but there are no doubt other ways as well:

Code: ags
int activeDialog = -1;

void StartCustom(this Dialog*)
{
  if(activeDialog == -1)
  {
    // TODO: Drop the music volume
  }
  activeDialog = this.ID:
  this.Start();
}

rmonic79

good! Thanks snarky i forgot to add you to credits, can i?
p.s. if you want your real name you can pm me

SMF spam blocked by CleanTalk