S: Interactive cutscenes issue caused by dialogs executing at end of functions

Started by David Ostman, Thu 03/03/2011 17:21:00

Previous topic - Next topic

David Ostman

Time to throw this issue up here and see if you guys can help. I hope it's not too advanced for Beginner's Tech.

Like a few people before me (judging by the search results) I've run into the issue caused by dialog.Start() always executing at the end of a function.

This hasn't been an issue so far, but this time the control is taken away from the player as he automatically follows an NPC, and the dialogs are initiated automatically, such as this:



It's a fairly long cutscene and the dialogs are used to set global variables to different values, that are called later on in the game (different things occur depending on the character's answers).

Now, it was suggested as a solution in a post by pumaman that it's best to put the rest of the code just before the stop in the dialog, but since I have 5 dialogs, each with 4 stop points on average, doing it that way just seems like a bit of a nightmare.

I might be able to design around this issue as I'm still whiteboxing the game, and I'm flexible with it, but this is how I would ideally like to present this cutscene.

Any suggestions/ideas would be appreciated :)

Khris

I guess you don't want to have lots of duplicate code, right?

You could put the code in a global function, then call that from the dialog script.

Code: ags
// Global.ash:

import function Dialog_Cutscene1();

// Global.asc

function Dialog_Cutscene1() {
  DoStuff();
  ...
}


Now you can put this in the dialog script, before each stop:
Code: ags
 Dialog_Cutscene1();


To keep things a bit more manageable, I'd start dialogs 2-5 using a timer.
At the end of Dialog_Cutscene1(), disable the interface and use a Timer to start the next dialog.

David Ostman

QuoteI guess you don't want to have lots of duplicate code, right?
That was my main concern, yeah :)

Your suggestion seems to work nicely, so thank you very much!

(Also thanks for being overall helpful, I've been doing so much searching on these forums, and you (and monkey, etc) have been tremendous sources for information over the years. You guys should consider adding Flattr buttons to your sigs :P)

SMF spam blocked by CleanTalk