Fools Rush In – Part Fifteen

The hardest part about this project is keeping my mind compartmentalised enough to be able to deal with the disparate elements, modelling, skinning, unrealscripting, AI scripting, dialogue scripting etc whilst trying to keep a few brain cells left over to see how the story is going to play out as a whole. Trying to think about everything at the same time is too much for my limited mental resources so I'm going to have take a few steps to try and break it down into easier to digest chunks.

The run through we did last time shows a series of discrete Acts that we can use to describe basic elements. Roughly:

I'm using the term 'Act' for convenience, it doesn't have any relevance outside of a easy label I can further subdivide into 'Scenes'.

So far the AI scripting we have used has been very basic and one script file for each NPC has been sufficient. The scripting for the Angels is probably going to be quite complex however, if we're going to have them become interesting characters. It's taken me a while to figure out, but here's the scheme I came up with:

Each Angel NPC will have eight script files that will handle all of their behaviour during a particular act. This is enabled by the extremely funky command 'setscript'. So the bare bones of Agnes' set will look like this:


// ------------- Agnes Act One, filename 01_Agnes_Begin -------------

debugmode 11

// ------------- Initialise -------------

:Initialise
headtracking 0
ontrigger StartRun gotolabel StartRun

// ------------- Act Commands Start Here -------------

sleep

// ------------- Act Change -------------

:StartRun
setscript 02_Agnes_StartRun Initialise

I can't remember if I've mentioned this before but the lines that start with a double forward slash are just 'comments'. They are ignored by the system and simply for descriptive purposes, in case I forget what a particular sectionis for.

So Agnes' first script starts by setting her to 'debugmode 11', which means the script processing is printed out in green text at the top of the screen as it runs, which helps to figure out what's going on. Before we release this out into the wild we'll have to go through and remove these statements but for now they're invaluable for fixing things that are broken. Then the script hits the ':Initialise' section which is where we put preparatory commands and set up responses for game events. For now, it just sets 'headtracking 0', turning off the somewhat disconcerting effect of having Agnes always turn her head towards you. This works OK for some models, but with the light model we're using for Agnes it's a bit too easy to have her turn her head fully through 180 degrees. Which is odd.

The next line 'ontrigger StartRun gotolabel StartRun' tells Agnes to expect an event called 'StartRun' from the game at some point. This is the event spewed by the main dispatcher that we originally set to start Sarah and Beth and the Spider going but now it takes on a grander significance by signifying an Act change. Furthermore, when Agnes receives the StartRun event we're telling her script to jump to the label called 'StartRun' and execute code from there. In AI Scripts labels are denoted by a preceeding colon, ':StartRun'.

At :Startrun is the line 'setscript 02_Agnes_StartRun Initialise' which tells Agnes to use the new script file called '02_Agnes_StartRun' and start from the label called 'Initialise'. Funky.

The next script is sketched out in an identical manner:


// ------------- Agnes Act Two, filename 02_Agnes_StartRun -------------

debugmode 11

//------------- Initialise -------------

:Initialise
ontrigger ArtilleryStrike gotolabel ArtilleryStrike

// ------------- Act Commands Start Here -------------

sleep

//------------- Act Change -------------
:ArtilleryStrike
setscript 03_Agnes_ArtilleryStrike Initialise

And so is the next:


// ------------- Agnes Act Three, filename 03_Agnes_ArtilleryStrike -------------

debugmode 11

//------------- Initialise -------------

:Initialise
ontrigger SpookScouts gotolabel SpookScouts

// ------------- Act Commands Start Here -------------

sleep

//------------- Act Change -------------
:SpookScouts
setscript 04_Agnes_SpookScouts Initialise


...and so on.

We set up a script chain for each of the Angel NPCs in an identical manner, so the overall model we end up with looks something like this:

We end up with a marching series of locations that enables us to define the behavior of the NPCs at any point along the timeline.

We /could/ have assigned a single script to each bot that handled everything for the duration of the entire timeline, but apart from generating a huge unwieldy block of commands for each character the setscript command is funky not because we can use it to chain scripts together but because it means we can can load ANY script from ANY event.

Have a look at this modified diagram for Anna:

...um, well, yeah, we tripled the number of scripts but because we can send the processing to any script we choose on any event, say from a conversation option, if we say something to Anna that makes her sad or happy, we can send an event to her current script that shuffles us over to another script that will better reflect her behavior. It means we have a mechanism for adapting the behavior of the NPCs according to the actions of the player for the duration of the game. Which is funky.

I'm going to cross off all the 'script' entries from our plan, because we've laid the foundations. Obviously there's still a lot of things to do script-wise, but the plan will have to be re-evaluated before too long in any case.

Next time we'll look at setting up the dialog files in a similar fashion. Dialog files are very different though, so they need to be treated as a separate topic.

Comments: on the _blackbored

Next: Part Sixteen