Hello and welcome to another installment of the Blightmare dev blog.  Today we’re going to take a quick look at a system that is in the early stages of development: scripting.  I’ll start by describing what we mean by scripting and then I’ll talk about what we have implemented so far in Blightmare.

 

What is scripting?  The answer to this question depends on the context.  In our context, it refers to the ability for someone to build a piece of content without having to write code.  An example of this might be a special event that happens when Blissa enters a new area.  Setting up the event is something that needs to be easy to change by a designer so they can make it do exactly what they want.  Allowing this type of authoring frees up programmers to focus on more systemic things which can be a really big time savings.

Some games use scripting for all gameplay elements.  This means that designers are essentially creating all the content themselves instead of a hybrid between design and programming.  On some teams and for some projects, this can be a very beneficial way to do things.  Like everything, there is a cost to trying this approach.  In order to support all the variety required by designers, the building blocks of the scripting system in this case must be very generic.  Sometimes that means building a special piece of code just to allow a designer to do one thing.  At that point, the cost is potentially higher than just coding up the mechanic directly.  In the end it’s a balancing act between what is supported through scripting and what is kept within the realm of compiled logic.

For Blightmare, we have a very limited set of actions available to the scripting system.  So far the list includes:

  • Show a fullscreen image
  • Fade the screen to a color
  • Play a sound
  • Reset the level
  • Set the camera position
  • Spawn an object
  • Spawn the player
  • Toggle input
  • Wait for the player to be at a specific location
  • Wait some amount of time

 

There are a few additional types of actions that we anticipate needing before the system is complete, but the bulk of them are done.  The primary use case for scripts in Blightmare is to advance the story and to do special introductions for some mechanics.  In the end, we may not get a lot of time savings from the scripting system, but the flexibility that it affords us for the highly specialized and unique parts of the game that we intend to use it for should give us good parallelization when we get closer to shipping the game which is a great thing.

 

Let’s finish up today by talking a bit about how the implementation actually works.  A script in Blightmare is an ordered list of actions.  Each action runs to completion.  What completion means is completely dependent on the action – it might just be waiting some amount of real world time, or it could be done immediately.  The data for a script is stored with the level that it applies to as a JSON array.  This means that the script actions can’t reference objects in Unity like a normal component might.  To get around this, we enumerate every Unity object that is used in a script and store them in a big list which the script actions can index into.

Each action has a unique editor plugin so that a user can setup whatever data is relevant to that action – the color to fade to for example.  We have some editor utilities that make it pretty quick to build a plugin, so creating a new action from scratch can take as little as 20 minutes from creating the files to testing to publishing for use.  We haven’t gotten any real use out of the scripting system yet, so it’s still too early to render a verdict on how well it works or if it was worthwhile, but from the tests that I’ve done while building it, I’m fairly optimistic that it will save time overall.

Next week I’ll put together a video showing how the scripting system can be used in the editor along with a demonstration of how it plays out in-game.  I hope you’ll stop by again to check it out.

 

If you’re enjoying the blog and want to support the game, please head over to Steam and wishlist Blightmare.  Keeping up to date with posts here as well as any announcements about the game is as easy as following us on Twitter.  Thanks for reading!