Triggers and cutscenes

The weekdays went by well – I each day I addeda nother little tid bit in the forms of what I call “triggers” which are ways of communicating with the game engine – outside of the game engine. So via XML (if this sounds too fancy for you – think of them as regular text files).

Here is an example of trigger:

__triggerType attr1="ship_command"
__shipName attr1="playerRaider"
__commandType attr1="goto_position"
__position x="0" y="0" z="-200"
__reletiveObject attr1="playerRaider"

This trigger causes the ship named “playerRaider” to be issued a command to go to a position. Because a reletive object is specified (the same ship that’s being given the command” the position is calculated in front of the reltive object. Meaning that this ship will fly forward about 200 units in space. Using these sorts of triggers I can give orders to ships, I can create ships, I can destroy ships, basically do anything I want in a scripted fashion. Meaning that I can write a story line :) and that they are easily moddable – though time consuming.

This weekend I wanted to add something more substancial than the little daily triggers of the days past, so I started working on a cut scene system. To do this first I re-factored a lot of old code and put in better “state” logic in the main game loop. It was a combination of flags (booleans) and states on top of states, fairly messy. I re-factored it to be much better so adding the cutscene state would be easy. On Saturday I had a rudimentary cutscene manager working – only swapping to another camera outside of the ship’s camera. And tonight I have a bits of “cutscene fragments.”

Here’s a sample of a cutscene file (again in XML/text):

__reletiveObject attr1="playerRaider"
__lookAtObject attr1="playerRaider"
__cameraPosition x="50" y="50" z="-100"
__duration attr1="4"
__headingText attr1=" "
__headingText attr1="Raider class light frigate prototype test"

__attachment attr1="playerRaider"
__cameraPosition x="30" y="20" z="-50"
__duration attr1="10"/

This excerpt will have the cutscene camera look at the player ship at a certain position for a certain duration, display some text and then change to another position. Combining this with triggers the game will support a healthy dose of cutscenes :)

I’m very excited – I was bit worried on the cutscene aspect and now it is shaping up well, but it also is becoming more and more apparent how much work it will be to create a good visual/story experience – in scripting terms.

This upcoming week I plan on adding more triggers, more cutscene code – mobile cameras, zooming in/out, fade in/out, meanwhile adding in the beginings of the storyline.