Boss Intro CutsceneI've continued work on polishing the game's first boss fight, and adding an intro cutscene that plays before the fight.
First let's have a look at the cutscene:
There's a little more polish to be done but I'm really happy with how it's turned out so far
I think this cutscene is a good example of the tone I'll be aiming for with other cutscenes in the game. There's no plot as such, but I can show some little developments in the behaviour of the characters throughout the game.
Scripting systemIn
a previous post I gave an overview of how the data and code for the boss tank itself is structured, including the scripting system that controls the tank during the fight.
I've now expanded this scripting system to make it a bit more generic, and not only for boss fights. I was intended on doing this when I first started the boss scripting system - it was a good way to justify spending a lot of time on a scripting system!
Previously when I placed the "B" icon representing the boss in the editor, it would create a BossScript entity, the BossController entity, and all the entities representing the different parts of the tank. I've separated out the BossScript entity (and renamed it to BScript just to help remind me it's not strictly boss-related) so it's now placed separately, and it can be linked up to any entity, not just bosses. Here's how the boss room looks in the editor:
The "B" is the boss, and the script above it is the same one I used to have - it controls the boss' movements during the actual fight.
CutsceneRole entityI now also have the "C" icons - these are CutsceneRole entities. CutsceneRole is a generic entity which is basically a sprite that animates and moves around. They're totally generic and data-driven; an XML file tells it which sprite sheet to load, which animations it can play, the size of the collision on the entity, etc.
I'm using three CutsceneRoles for this cutscene: the one nearest the boss is Kuila. The one next to her is Gearbox, her walking toolbox. Finally the entity in the air is Kuila's wrench, used in the part where she throws the wrench into the toolbox.
BScript entitiesEach CutsceneRole entity has its own script. There's also a script floating on the left side of the room which controls Leilani for the duration of the cutscene.
At its simplest the script is a list of actions and delays. There are also some things like a very basic variable system for tracking values. I covered this in the previous post mentioned above, but I'll give another example - the script for Gearbox during this cutscene.
- Set variable 'WrenchLanded' to 0
- Looping animation 'AsleepOpen'
- Delay until 'WrenchLanded' == 1
- Animation 'AsleepOpenBounce'
- Delay until animation finished
- Animation 'AsleepOpenToClosed'
- Delay until animation finished
- Looping animation 'AsleepClosed'
- Delay 0.3 seconds
- Animation 'WakeUp'
- Delay until animation finished
- Delay 0.1 seconds
- Walk to the right edge of the room + 9 tiles (i.e. walk off screen)
- Delay 1.7 seconds
- Unpause path movement for 'RightWall' entity
- Delay until finished walking
- Deactivate entity
- End script
Some interesting parts about this are:
The 'WrenchLanded' variable is used as the trigger for when the Gearbox knows that the wrench has been thrown by Kuila and landed in the toolbox. This variable is set externally from the Wrench's script. This is how scripts communicate and chain actions together through the cutscene.
This script is also responsible for triggering the right wall of the boss room to close. It makes sense to handle it from this script since it needs to tie in with the timing of Gearbox walking off screen. Scripts are mostly focused on controlling one entity - but they do have the ability to control other entities if I want to, which is useful for cases like this.
The majority of this script is just focused on playing individual animations. There's one more complex command, which is telling Gearbox to walk to a certain position. There are certain actions like moving to a location, or jumping to a location, which were originally designed for the boss to do, but are supported by the CutsceneRole entity as well. When the script tells Gearbox to walk to a point, this results in Gearbox turning around, then walking until reaching the desired position. Acceleration, max speed, and deceleration when reaching the desired position, are all taken into account. Similarly there's a Jump action which is used to make Kuila jump into the tank, and is also used for the Wrench 'jumping' from Kuila to Gearbox.
Short Version of the CutsceneFinally, I also made a short version of the cutscene which plays when replaying the boss fight after dying. The scripts can handle branches (if statements), so each script has a separate branch for doing the shorter version of the cutscene.
For the Gearbox script, the branch for the short version of the cutscene is very simple:
- If persistent variable 'BombTankIntroSeen' == 1
- Deactivate entity
- End script
So he won't be seen on screen at all.
Thanks for reading!