This AI is still in early stages of development.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Sometimes there's a need to sequence a number of actions, one after the other, for example in campaign scripts to unfold part of the plot.

In WZScript, there seems to be a pause() command, although I can't find it documented anywhere. Here's an excerpt from Goth's cam4 script:

showConsoleText(_("Sgt.Gibbs: Next objective is to the north. Then we'll cut eastward and rendevous with Team Two."), player);
pause(50);
showConsoleText(_("Sgt.Wilkes: -- Wilkes to Gibbs. You folks have got a horde of angry Scavengers headed your way from the north. --"), player);
pause(50);
showConsoleText(_("Sgt.Gibbs: Thanks for the heads up, Sergeant. We'll be ready!"), player);

If you did something like that in Javascript, the game would hang. So we're going to need to use queue(), but even then the code would be a mess because we'd need vast numbers of functions.

However, we can probably create a little API that will help us achieve our goals in a fairly clean manner. Using it would look something like this...

include("path/to/APIs/Sequence.js");
 
// define a sequence, probably store in in an external .js file and include() it
Sequence.define("introSequence", processor, [
	"Sgt.Gibbs: Next objective is to the north. Then we'll cut eastward and rendevous with Team Two.", 50,
	"Sgt.Wilkes: -- Wilkes to Gibbs. You folks have got a horde of angry Scavengers headed your way from the north. --", 50,
	"Sgt.Gibbs: Thanks for the heads up, Sergeant. We'll be ready!"
]);
 
// start a sequence, eg. during an event
function eventGameInit() {
	// various init
	Sequence(introSequence);
	// various other stuff
}

The sequence above is simplified version of what Goth is doing in cam4 – the sequencer also needs to be able to handle function calls, because code is often running in between console messages (eg. to spawn droids, etc).

Anyway, that's the sort of thing Sequence API should handle. Currently working on a prototype...

  • No labels